refactor(slack): share room context hints

This commit is contained in:
Peter Steinberger
2026-02-15 17:06:17 +00:00
parent ca4c2b33d7
commit da2fde7b6f
3 changed files with 43 additions and 26 deletions

View File

@@ -0,0 +1,31 @@
import { buildUntrustedChannelMetadata } from "../../security/channel-metadata.js";
export function resolveSlackRoomContextHints(params: {
isRoomish: boolean;
channelInfo?: { topic?: string; purpose?: string };
channelConfig?: { systemPrompt?: string | null } | null;
}): {
untrustedChannelMetadata?: ReturnType<typeof buildUntrustedChannelMetadata>;
groupSystemPrompt?: string;
} {
if (!params.isRoomish) {
return {};
}
const untrustedChannelMetadata = buildUntrustedChannelMetadata({
source: "slack",
label: "Slack channel description",
entries: [params.channelInfo?.topic, params.channelInfo?.purpose],
});
const systemPromptParts = [params.channelConfig?.systemPrompt?.trim() || null].filter(
(entry): entry is string => Boolean(entry),
);
const groupSystemPrompt =
systemPromptParts.length > 0 ? systemPromptParts.join("\n\n") : undefined;
return {
untrustedChannelMetadata,
groupSystemPrompt,
};
}