MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / selectRoutedToolsForSlackResponse

Function selectRoutedToolsForSlackResponse

server/src/addie/bolt-app.ts:1159–1291  ·  view source on GitHub ↗
(
  messageText: string,
  source: 'dm' | 'mention' | 'channel',
  memberContext: MemberContext | null,
  slackUserId: string,
  threadId: string,
  threadContext?: ThreadContext | null,
  options?: { isThread?: boolean; hasCertificationContext?: boolean; threadMessages?: string[] }
)

Source from the content-addressed store, hash-verified

1157}
1158
1159async function selectRoutedToolsForSlackResponse(
1160 messageText: string,
1161 source: 'dm' | 'mention' | 'channel',
1162 memberContext: MemberContext | null,
1163 slackUserId: string,
1164 threadId: string,
1165 threadContext?: ThreadContext | null,
1166 options?: { isThread?: boolean; hasCertificationContext?: boolean; threadMessages?: string[] }
1167): Promise<{
1168 tools: RequestTools;
1169 isAAOAdmin: boolean;
1170 unavailableHint: string;
1171 requiresPrecision: boolean;
1172 requiresDepth: boolean;
1173 confidence: ConfidenceTier;
1174}> {
1175 const { tools: userTools, isAAOAdmin: userIsAdmin } = await createUserScopedTools(
1176 memberContext,
1177 slackUserId,
1178 threadId,
1179 threadContext
1180 );
1181
1182 if (!addieRouter) {
1183 logger.warn('Addie Bolt: Router unavailable, defaulting to knowledge tool set');
1184 const fallbackSets = ['knowledge'];
1185 if (userIsAdmin && (source === 'dm' || threadContext?.viewing_channel_working_group_slug === ADMIN_CHANNEL_WG_SLUG)) {
1186 fallbackSets.push('admin');
1187 }
1188 const fallbackSystemRole = threadContext?.viewing_channel_system_role as SystemChannelRole | undefined;
1189 if (userIsAdmin && fallbackSystemRole) {
1190 for (const set of SYSTEM_CHANNEL_TOOL_SETS[fallbackSystemRole] ?? []) {
1191 if (!fallbackSets.includes(set)) {
1192 fallbackSets.push(set);
1193 }
1194 }
1195 }
1196 const { filteredTools, unavailableHint } = filterToolsBySet(
1197 userTools,
1198 fallbackSets,
1199 userIsAdmin,
1200 false
1201 );
1202 return {
1203 tools: filteredTools,
1204 isAAOAdmin: userIsAdmin,
1205 unavailableHint,
1206 requiresPrecision: false,
1207 requiresDepth: false,
1208 confidence: 'high',
1209 };
1210 }
1211
1212 const routingContext: RoutingContext = {
1213 message: messageText,
1214 source,
1215 memberContext,
1216 isThread: options?.isThread,

Callers 4

handleUserMessageFunction · 0.85
handleAppMentionFunction · 0.85
handleDirectMessageFunction · 0.85
handleActiveThreadReplyFunction · 0.85

Calls 5

filterToolsBySetFunction · 0.85
warnMethod · 0.80
quickMatchMethod · 0.80
routeMethod · 0.80
createUserScopedToolsFunction · 0.70

Tested by

no test coverage detected