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

@@ -26,7 +26,6 @@ import {
upsertChannelPairingRequest,
} from "../../pairing/pairing-store.js";
import { resolveAgentRoute } from "../../routing/resolve-route.js";
import { buildUntrustedChannelMetadata } from "../../security/channel-metadata.js";
import {
normalizeAllowList,
normalizeAllowListLower,
@@ -38,6 +37,7 @@ import { buildSlackSlashCommandMatcher, resolveSlackSlashCommandConfig } from ".
import { normalizeSlackChannelType } from "./context.js";
import { isSlackChannelAllowedByPolicy } from "./policy.js";
import { deliverSlackSlashReplies } from "./replies.js";
import { resolveSlackRoomContextHints } from "./room-context.js";
type SlackBlock = { type: string; [key: string]: unknown };
@@ -387,18 +387,11 @@ export function registerSlackMonitorSlashCommands(params: {
},
});
const untrustedChannelMetadata = isRoomish
? buildUntrustedChannelMetadata({
source: "slack",
label: "Slack channel description",
entries: [channelInfo?.topic, channelInfo?.purpose],
})
: undefined;
const systemPromptParts = [channelConfig?.systemPrompt?.trim() || null].filter(
(entry): entry is string => Boolean(entry),
);
const groupSystemPrompt =
systemPromptParts.length > 0 ? systemPromptParts.join("\n\n") : undefined;
const { untrustedChannelMetadata, groupSystemPrompt } = resolveSlackRoomContextHints({
isRoomish,
channelInfo,
channelConfig,
});
const ctxPayload = finalizeInboundContext({
Body: prompt,