@inkeep/agents-work-apps 0.53.9 → 0.53.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/env.d.ts +2 -2
- package/dist/github/index.d.ts +3 -3
- package/dist/github/mcp/index.d.ts +2 -2
- package/dist/github/routes/setup.d.ts +2 -2
- package/dist/github/routes/tokenExchange.d.ts +2 -2
- package/dist/github/routes/webhooks.d.ts +2 -2
- package/dist/slack/routes/workspaces.js +2 -0
- package/dist/slack/services/blocks/index.d.ts +8 -1
- package/dist/slack/services/blocks/index.js +14 -5
- package/dist/slack/services/client.d.ts +2 -0
- package/dist/slack/services/client.js +3 -1
- package/dist/slack/services/commands/index.js +26 -12
- package/dist/slack/services/events/app-mention.js +37 -26
- package/dist/slack/services/events/direct-message.js +31 -6
- package/dist/slack/services/events/execution.d.ts +1 -0
- package/dist/slack/services/events/execution.js +5 -1
- package/dist/slack/services/events/modal-submission.js +40 -6
- package/dist/slack/services/events/streaming.d.ts +1 -0
- package/dist/slack/services/events/streaming.js +5 -4
- package/dist/slack/services/events/utils.d.ts +14 -2
- package/dist/slack/services/events/utils.js +46 -1
- package/dist/slack/services/index.d.ts +2 -2
- package/dist/slack/services/index.js +2 -2
- package/dist/slack/services/link-prompt.d.ts +2 -2
- package/dist/slack/services/nango.d.ts +1 -0
- package/dist/slack/services/nango.js +1 -0
- package/dist/slack/services/resume-intent.js +75 -23
- package/package.json +2 -2
package/dist/env.d.ts
CHANGED
|
@@ -14,11 +14,11 @@ declare const envSchema: z.ZodObject<{
|
|
|
14
14
|
pentest: "pentest";
|
|
15
15
|
}>>;
|
|
16
16
|
LOG_LEVEL: z.ZodDefault<z.ZodEnum<{
|
|
17
|
-
error: "error";
|
|
18
17
|
trace: "trace";
|
|
19
18
|
debug: "debug";
|
|
20
19
|
info: "info";
|
|
21
20
|
warn: "warn";
|
|
21
|
+
error: "error";
|
|
22
22
|
}>>;
|
|
23
23
|
INKEEP_AGENTS_RUN_DATABASE_URL: z.ZodOptional<z.ZodString>;
|
|
24
24
|
INKEEP_AGENTS_MANAGE_UI_URL: z.ZodOptional<z.ZodString>;
|
|
@@ -44,7 +44,7 @@ declare const envSchema: z.ZodObject<{
|
|
|
44
44
|
declare const env: {
|
|
45
45
|
NODE_ENV: "development" | "production" | "test";
|
|
46
46
|
ENVIRONMENT: "development" | "production" | "test" | "pentest";
|
|
47
|
-
LOG_LEVEL: "
|
|
47
|
+
LOG_LEVEL: "trace" | "debug" | "info" | "warn" | "error";
|
|
48
48
|
INKEEP_AGENTS_RUN_DATABASE_URL?: string | undefined;
|
|
49
49
|
INKEEP_AGENTS_MANAGE_UI_URL?: string | undefined;
|
|
50
50
|
GITHUB_APP_ID?: string | undefined;
|
package/dist/github/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ import "./routes/setup.js";
|
|
|
4
4
|
import "./routes/tokenExchange.js";
|
|
5
5
|
import { WebhookVerificationResult, verifyWebhookSignature } from "./routes/webhooks.js";
|
|
6
6
|
import { Hono } from "hono";
|
|
7
|
-
import * as
|
|
7
|
+
import * as hono_types3 from "hono/types";
|
|
8
8
|
|
|
9
9
|
//#region src/github/index.d.ts
|
|
10
|
-
declare function createGithubRoutes(): Hono<
|
|
11
|
-
declare const githubRoutes: Hono<
|
|
10
|
+
declare function createGithubRoutes(): Hono<hono_types3.BlankEnv, hono_types3.BlankSchema, "/">;
|
|
11
|
+
declare const githubRoutes: Hono<hono_types3.BlankEnv, hono_types3.BlankSchema, "/">;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { GenerateInstallationAccessTokenResult, GenerateTokenError, GenerateTokenResult, GitHubAppConfig, InstallationAccessToken, InstallationInfo, LookupInstallationError, LookupInstallationForRepoResult, LookupInstallationResult, WebhookVerificationResult, clearConfigCache, createAppJwt, createGithubRoutes, determineStatus, fetchInstallationDetails, fetchInstallationRepositories, generateInstallationAccessToken, getGitHubAppConfig, getGitHubAppName, getStateSigningSecret, getWebhookSecret, githubRoutes, isGitHubAppConfigured, isGitHubAppNameConfigured, isStateSigningConfigured, isWebhookConfigured, lookupInstallationForRepo, validateGitHubAppConfigOnStartup, validateGitHubInstallFlowConfigOnStartup, validateGitHubWebhookConfigOnStartup, verifyWebhookSignature };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types9 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/github/mcp/index.d.ts
|
|
5
5
|
declare const app: Hono<{
|
|
6
6
|
Variables: {
|
|
7
7
|
toolId: string;
|
|
8
8
|
};
|
|
9
|
-
},
|
|
9
|
+
}, hono_types9.BlankSchema, "/">;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types0 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/github/routes/setup.d.ts
|
|
5
|
-
declare const app: Hono<
|
|
5
|
+
declare const app: Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types1 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/github/routes/tokenExchange.d.ts
|
|
5
|
-
declare const app: Hono<
|
|
5
|
+
declare const app: Hono<hono_types1.BlankEnv, hono_types1.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types7 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/github/routes/webhooks.d.ts
|
|
5
5
|
interface WebhookVerificationResult {
|
|
@@ -7,6 +7,6 @@ interface WebhookVerificationResult {
|
|
|
7
7
|
error?: string;
|
|
8
8
|
}
|
|
9
9
|
declare function verifyWebhookSignature(payload: string, signature: string | undefined, secret: string): WebhookVerificationResult;
|
|
10
|
-
declare const app: Hono<
|
|
10
|
+
declare const app: Hono<hono_types7.BlankEnv, hono_types7.BlankSchema, "/">;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { WebhookVerificationResult, app as default, verifyWebhookSignature };
|
|
@@ -67,6 +67,7 @@ app.openapi(createProtectedRoute({
|
|
|
67
67
|
connectionId: z.string(),
|
|
68
68
|
teamId: z.string(),
|
|
69
69
|
teamName: z.string().optional(),
|
|
70
|
+
teamDomain: z.string().optional(),
|
|
70
71
|
tenantId: z.string(),
|
|
71
72
|
hasDefaultAgent: z.boolean(),
|
|
72
73
|
defaultAgentName: z.string().optional()
|
|
@@ -90,6 +91,7 @@ app.openapi(createProtectedRoute({
|
|
|
90
91
|
connectionId: w.connectionId,
|
|
91
92
|
teamId: w.teamId,
|
|
92
93
|
teamName: w.teamName,
|
|
94
|
+
teamDomain: w.teamDomain,
|
|
93
95
|
tenantId: w.tenantId,
|
|
94
96
|
hasDefaultAgent: !!w.defaultAgent,
|
|
95
97
|
defaultAgentName: w.defaultAgent?.agentName
|
|
@@ -3,6 +3,13 @@ import * as slack_block_builder0 from "slack-block-builder";
|
|
|
3
3
|
|
|
4
4
|
//#region src/slack/services/blocks/index.d.ts
|
|
5
5
|
declare function createErrorMessage(message: string): Readonly<slack_block_builder0.SlackMessageDto>;
|
|
6
|
+
declare function createContextBlockFromText(text: string): {
|
|
7
|
+
type: "context";
|
|
8
|
+
elements: {
|
|
9
|
+
type: "mrkdwn";
|
|
10
|
+
text: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
6
13
|
interface ContextBlockParams {
|
|
7
14
|
agentName: string;
|
|
8
15
|
}
|
|
@@ -120,4 +127,4 @@ declare function buildCitationsBlock(citations: Array<{
|
|
|
120
127
|
}>): any[];
|
|
121
128
|
declare function createCreateInkeepAccountMessage(acceptUrl: string, expiresInMinutes: number): Readonly<slack_block_builder0.SlackMessageDto>;
|
|
122
129
|
//#endregion
|
|
123
|
-
export { AgentConfigSources, ContextBlockParams, ToolApprovalButtonValue, ToolApprovalButtonValueSchema, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, createAlreadyLinkedMessage, createContextBlock, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage };
|
|
130
|
+
export { AgentConfigSources, ContextBlockParams, ToolApprovalButtonValue, ToolApprovalButtonValueSchema, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, createAlreadyLinkedMessage, createContextBlock, createContextBlockFromText, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage };
|
|
@@ -7,6 +7,15 @@ import { Blocks, Elements, Md, Message } from "slack-block-builder";
|
|
|
7
7
|
function createErrorMessage(message) {
|
|
8
8
|
return Message().blocks(Blocks.Section().text(message)).buildToObject();
|
|
9
9
|
}
|
|
10
|
+
function createContextBlockFromText(text) {
|
|
11
|
+
return {
|
|
12
|
+
type: "context",
|
|
13
|
+
elements: [{
|
|
14
|
+
type: "mrkdwn",
|
|
15
|
+
text
|
|
16
|
+
}]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
10
19
|
function createContextBlock(params) {
|
|
11
20
|
const { agentName } = params;
|
|
12
21
|
return {
|
|
@@ -74,7 +83,7 @@ function buildToolApprovalBlocks(params) {
|
|
|
74
83
|
type: "section",
|
|
75
84
|
text: {
|
|
76
85
|
type: "mrkdwn",
|
|
77
|
-
text:
|
|
86
|
+
text: `Approval required for *${escapeSlackMrkdwn(toolName)}*`
|
|
78
87
|
}
|
|
79
88
|
}];
|
|
80
89
|
if (input && Object.keys(input).length > 0) {
|
|
@@ -123,7 +132,7 @@ function buildToolApprovalDoneBlocks(params) {
|
|
|
123
132
|
type: "context",
|
|
124
133
|
elements: [{
|
|
125
134
|
type: "mrkdwn",
|
|
126
|
-
text: approved ? `✅
|
|
135
|
+
text: approved ? `✅ <@${actorUserId}> approved *${escapeSlackMrkdwn(toolName)}*` : `❌ <@${actorUserId}> denied *${escapeSlackMrkdwn(toolName)}*`
|
|
127
136
|
}]
|
|
128
137
|
}];
|
|
129
138
|
}
|
|
@@ -233,7 +242,7 @@ function buildDataArtifactBlocks(artifact) {
|
|
|
233
242
|
type: "section",
|
|
234
243
|
text: {
|
|
235
244
|
type: "mrkdwn",
|
|
236
|
-
text:
|
|
245
|
+
text: `*Sources*\n${lines.join("\n")}${suffix}`
|
|
237
246
|
}
|
|
238
247
|
}] };
|
|
239
248
|
}
|
|
@@ -284,7 +293,7 @@ function buildCitationsBlock(citations) {
|
|
|
284
293
|
type: "section",
|
|
285
294
|
text: {
|
|
286
295
|
type: "mrkdwn",
|
|
287
|
-
text:
|
|
296
|
+
text: `*Sources*\n${lines.join("\n")}${suffix}`
|
|
288
297
|
}
|
|
289
298
|
}];
|
|
290
299
|
}
|
|
@@ -293,4 +302,4 @@ function createCreateInkeepAccountMessage(acceptUrl, expiresInMinutes) {
|
|
|
293
302
|
}
|
|
294
303
|
|
|
295
304
|
//#endregion
|
|
296
|
-
export { ToolApprovalButtonValueSchema, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, createAlreadyLinkedMessage, createContextBlock, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage };
|
|
305
|
+
export { ToolApprovalButtonValueSchema, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, createAlreadyLinkedMessage, createContextBlock, createContextBlockFromText, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage };
|
|
@@ -29,6 +29,8 @@ declare function getSlackUserInfo(client: WebClient, userId: string): Promise<{
|
|
|
29
29
|
isAdmin: boolean | undefined;
|
|
30
30
|
isOwner: boolean | undefined;
|
|
31
31
|
avatar: string | undefined;
|
|
32
|
+
tz: string | undefined;
|
|
33
|
+
tzOffset: number | undefined;
|
|
32
34
|
} | null>;
|
|
33
35
|
/**
|
|
34
36
|
* Fetch workspace (team) information from Slack.
|
|
@@ -49,7 +49,9 @@ async function getSlackUserInfo(client, userId) {
|
|
|
49
49
|
email: result.user.profile?.email,
|
|
50
50
|
isAdmin: result.user.is_admin,
|
|
51
51
|
isOwner: result.user.is_owner,
|
|
52
|
-
avatar: result.user.profile?.image_72
|
|
52
|
+
avatar: result.user.profile?.image_72,
|
|
53
|
+
tz: result.user.tz,
|
|
54
|
+
tzOffset: result.user.tz_offset
|
|
53
55
|
};
|
|
54
56
|
return null;
|
|
55
57
|
} catch (error) {
|
|
@@ -2,11 +2,11 @@ import { env } from "../../../env.js";
|
|
|
2
2
|
import { getLogger } from "../../../logger.js";
|
|
3
3
|
import runDbClient_default from "../../../db/runDbClient.js";
|
|
4
4
|
import { findWorkspaceConnectionByTeamId } from "../nango.js";
|
|
5
|
-
import { fetchAgentsForProject, fetchProjectsForTenant, generateSlackConversationId, getChannelAgentConfig } from "../events/utils.js";
|
|
5
|
+
import { fetchAgentsForProject, fetchProjectsForTenant, formatChannelContext, formatSlackQuery, generateSlackConversationId, getChannelAgentConfig } from "../events/utils.js";
|
|
6
6
|
import { resolveEffectiveAgent } from "../agent-resolution.js";
|
|
7
7
|
import { SlackStrings } from "../../i18n/strings.js";
|
|
8
8
|
import { createAlreadyLinkedMessage, createErrorMessage, createNotLinkedMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage } from "../blocks/index.js";
|
|
9
|
-
import { getSlackClient } from "../client.js";
|
|
9
|
+
import { getSlackChannelInfo, getSlackClient, getSlackUserInfo } from "../client.js";
|
|
10
10
|
import { executeAgentPublicly } from "../events/execution.js";
|
|
11
11
|
import { buildLinkPromptMessage, resolveUnlinkedUserAction } from "../link-prompt.js";
|
|
12
12
|
import { buildAgentSelectorModal } from "../modals.js";
|
|
@@ -223,17 +223,32 @@ async function handleQuestionCommand(payload, question, _dashboardUrl, tenantId,
|
|
|
223
223
|
responseUrl: payload.responseUrl
|
|
224
224
|
});
|
|
225
225
|
const userTenantId = existingLink.tenantId;
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
226
|
+
const slackClient = getSlackClient(botToken);
|
|
227
|
+
const [resolvedAgent, channelInfo, userInfo] = await Promise.all([
|
|
228
|
+
resolveEffectiveAgent({
|
|
229
|
+
tenantId: userTenantId,
|
|
230
|
+
teamId: payload.teamId,
|
|
231
|
+
channelId: payload.channelId,
|
|
232
|
+
userId: payload.userId
|
|
233
|
+
}),
|
|
234
|
+
getSlackChannelInfo(slackClient, payload.channelId),
|
|
235
|
+
getSlackUserInfo(slackClient, payload.userId)
|
|
236
|
+
]);
|
|
232
237
|
if (!resolvedAgent) return {
|
|
233
238
|
response_type: "ephemeral",
|
|
234
239
|
...createErrorMessage("No default agent configured. Ask your admin to set a workspace default in the dashboard.")
|
|
235
240
|
};
|
|
236
|
-
const
|
|
241
|
+
const channelContext = formatChannelContext(channelInfo);
|
|
242
|
+
const userName = userInfo?.displayName || "User";
|
|
243
|
+
const now = Date.now();
|
|
244
|
+
const messageTs = `${Math.floor(now / 1e3)}.${String(now % 1e3).padStart(3, "0")}000`;
|
|
245
|
+
const formattedQuestion = formatSlackQuery({
|
|
246
|
+
text: question,
|
|
247
|
+
channelContext,
|
|
248
|
+
userName,
|
|
249
|
+
messageTs,
|
|
250
|
+
senderTimezone: userInfo?.tz ?? void 0
|
|
251
|
+
});
|
|
237
252
|
const slackUserToken = await signSlackUserToken({
|
|
238
253
|
inkeepUserId: existingLink.inkeepUserId,
|
|
239
254
|
tenantId: userTenantId,
|
|
@@ -245,8 +260,6 @@ async function handleQuestionCommand(payload, question, _dashboardUrl, tenantId,
|
|
|
245
260
|
slackChannelId: payload.channelId,
|
|
246
261
|
slackAuthorizedProjectId: resolvedAgent.projectId
|
|
247
262
|
});
|
|
248
|
-
const now = Date.now();
|
|
249
|
-
const messageTs = `${Math.floor(now / 1e3)}.${String(now % 1e3).padStart(3, "0")}000`;
|
|
250
263
|
const conversationId = generateSlackConversationId({
|
|
251
264
|
teamId: payload.teamId,
|
|
252
265
|
messageTs,
|
|
@@ -261,7 +274,8 @@ async function handleQuestionCommand(payload, question, _dashboardUrl, tenantId,
|
|
|
261
274
|
projectId: resolvedAgent.projectId,
|
|
262
275
|
agentId: resolvedAgent.agentId,
|
|
263
276
|
agentName: resolvedAgent.agentName || resolvedAgent.agentId,
|
|
264
|
-
question,
|
|
277
|
+
question: formattedQuestion,
|
|
278
|
+
rawMessageText: question,
|
|
265
279
|
conversationId,
|
|
266
280
|
entryPoint: "slash_command"
|
|
267
281
|
}).catch(async (error) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { env } from "../../../env.js";
|
|
2
2
|
import { getLogger } from "../../../logger.js";
|
|
3
3
|
import { findWorkspaceConnectionByTeamId } from "../nango.js";
|
|
4
|
-
import { checkIfBotThread, classifyError, findCachedUserMapping, formatAttachments, formatChannelContext, generateSlackConversationId, getThreadContext, getUserFriendlyErrorMessage, timedOp } from "./utils.js";
|
|
4
|
+
import { checkIfBotThread, classifyError, findCachedUserMapping, formatAttachments, formatChannelContext, formatSlackQuery, generateSlackConversationId, getThreadContext, getUserFriendlyErrorMessage, timedOp } from "./utils.js";
|
|
5
5
|
import { resolveEffectiveAgent } from "../agent-resolution.js";
|
|
6
6
|
import { SlackStrings } from "../../i18n/strings.js";
|
|
7
7
|
import { getSlackChannelInfo, getSlackClient, getSlackUserInfo, postMessageInThread } from "../client.js";
|
|
@@ -158,10 +158,11 @@ async function handleAppMention(params) {
|
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
if (isInThread && !hasQuery) {
|
|
161
|
-
const [isBotThread, contextMessages, channelInfo] = await Promise.all([
|
|
161
|
+
const [isBotThread, contextMessages, channelInfo, autoExecUserInfo] = await Promise.all([
|
|
162
162
|
checkIfBotThread(slackClient, channel, threadTs),
|
|
163
163
|
getThreadContext(slackClient, channel, threadTs),
|
|
164
|
-
getSlackChannelInfo(slackClient, channel)
|
|
164
|
+
getSlackChannelInfo(slackClient, channel),
|
|
165
|
+
getSlackUserInfo(slackClient, slackUserId)
|
|
165
166
|
]);
|
|
166
167
|
if (isBotThread) {
|
|
167
168
|
logger.info({
|
|
@@ -210,18 +211,15 @@ async function handleAppMention(params) {
|
|
|
210
211
|
agentId: agentConfig.agentId
|
|
211
212
|
});
|
|
212
213
|
span.setAttribute(SLACK_SPAN_KEYS.CONVERSATION_ID, conversationId$1);
|
|
213
|
-
const threadQuery =
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
- If appropriate, summarize key points or provide relevant information.
|
|
223
|
-
|
|
224
|
-
Respond naturally as if you're joining the conversation to help.`;
|
|
214
|
+
const threadQuery = formatSlackQuery({
|
|
215
|
+
text: "",
|
|
216
|
+
channelContext: formatChannelContext(channelInfo),
|
|
217
|
+
userName: slackUserId,
|
|
218
|
+
threadContext: contextMessages,
|
|
219
|
+
isAutoExecute: true,
|
|
220
|
+
messageTs,
|
|
221
|
+
senderTimezone: autoExecUserInfo?.tz ?? void 0
|
|
222
|
+
});
|
|
225
223
|
logger.info({
|
|
226
224
|
projectId: agentConfig.projectId,
|
|
227
225
|
agentId: agentConfig.agentId,
|
|
@@ -238,6 +236,7 @@ Respond naturally as if you're joining the conversation to help.`;
|
|
|
238
236
|
agentId: agentConfig.agentId,
|
|
239
237
|
agentName: agentDisplayName,
|
|
240
238
|
question: threadQuery,
|
|
239
|
+
rawMessageText: "",
|
|
241
240
|
conversationId: conversationId$1,
|
|
242
241
|
entryPoint: "app_mention"
|
|
243
242
|
});
|
|
@@ -247,7 +246,11 @@ Respond naturally as if you're joining the conversation to help.`;
|
|
|
247
246
|
let queryText = text;
|
|
248
247
|
const attachmentContext = formatAttachments(attachments);
|
|
249
248
|
if (isInThread && threadTs) {
|
|
250
|
-
const { result: [contextMessages, channelInfo] } = await timedOp(Promise.all([
|
|
249
|
+
const { result: [contextMessages, channelInfo, threadUserInfo] } = await timedOp(Promise.all([
|
|
250
|
+
getThreadContext(slackClient, channel, threadTs),
|
|
251
|
+
getSlackChannelInfo(slackClient, channel),
|
|
252
|
+
getSlackUserInfo(slackClient, slackUserId)
|
|
253
|
+
]), {
|
|
251
254
|
label: "thread context fetch",
|
|
252
255
|
context: {
|
|
253
256
|
teamId,
|
|
@@ -255,12 +258,15 @@ Respond naturally as if you're joining the conversation to help.`;
|
|
|
255
258
|
threadTs
|
|
256
259
|
}
|
|
257
260
|
});
|
|
258
|
-
if (contextMessages) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
if (contextMessages) queryText = formatSlackQuery({
|
|
262
|
+
text,
|
|
263
|
+
channelContext: formatChannelContext(channelInfo),
|
|
264
|
+
userName: slackUserId,
|
|
265
|
+
attachmentContext: attachmentContext || void 0,
|
|
266
|
+
threadContext: contextMessages,
|
|
267
|
+
messageTs,
|
|
268
|
+
senderTimezone: threadUserInfo?.tz ?? void 0
|
|
269
|
+
});
|
|
264
270
|
} else {
|
|
265
271
|
const { result: [channelInfo, userInfo] } = await timedOp(Promise.all([getSlackChannelInfo(slackClient, channel), getSlackUserInfo(slackClient, slackUserId)]), {
|
|
266
272
|
label: "channel/user info fetch",
|
|
@@ -269,10 +275,14 @@ Respond naturally as if you're joining the conversation to help.`;
|
|
|
269
275
|
channel
|
|
270
276
|
}
|
|
271
277
|
});
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
278
|
+
queryText = formatSlackQuery({
|
|
279
|
+
text,
|
|
280
|
+
channelContext: formatChannelContext(channelInfo),
|
|
281
|
+
userName: userInfo?.displayName || "User",
|
|
282
|
+
attachmentContext: attachmentContext || void 0,
|
|
283
|
+
messageTs,
|
|
284
|
+
senderTimezone: userInfo?.tz ?? void 0
|
|
285
|
+
});
|
|
276
286
|
}
|
|
277
287
|
const slackUserToken = await signSlackUserToken({
|
|
278
288
|
inkeepUserId: existingLink.inkeepUserId,
|
|
@@ -309,6 +319,7 @@ Respond naturally as if you're joining the conversation to help.`;
|
|
|
309
319
|
agentId: agentConfig.agentId,
|
|
310
320
|
agentName: agentDisplayName,
|
|
311
321
|
question: queryText,
|
|
322
|
+
rawMessageText: text,
|
|
312
323
|
conversationId,
|
|
313
324
|
entryPoint: "app_mention"
|
|
314
325
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getLogger } from "../../../logger.js";
|
|
2
2
|
import { findWorkspaceConnectionByTeamId } from "../nango.js";
|
|
3
|
-
import { classifyError, findCachedUserMapping, generateSlackConversationId, getThreadContext, getUserFriendlyErrorMessage } from "./utils.js";
|
|
3
|
+
import { classifyError, findCachedUserMapping, formatSlackQuery, generateSlackConversationId, getThreadContext, getUserFriendlyErrorMessage } from "./utils.js";
|
|
4
4
|
import { SlackStrings } from "../../i18n/strings.js";
|
|
5
|
-
import { getSlackClient } from "../client.js";
|
|
5
|
+
import { getSlackClient, getSlackUserInfo } from "../client.js";
|
|
6
6
|
import { SLACK_SPAN_KEYS, SLACK_SPAN_NAMES, setSpanWithError, tracer } from "../../tracer.js";
|
|
7
7
|
import { executeAgentPublicly } from "./execution.js";
|
|
8
8
|
import { buildLinkPromptMessage, resolveUnlinkedUserAction } from "../link-prompt.js";
|
|
@@ -54,7 +54,7 @@ async function handleDirectMessage(params) {
|
|
|
54
54
|
span.setAttribute(SLACK_SPAN_KEYS.AGENT_ID, defaultAgent.agentId);
|
|
55
55
|
span.setAttribute(SLACK_SPAN_KEYS.PROJECT_ID, defaultAgent.projectId);
|
|
56
56
|
const agentDisplayName = defaultAgent.agentName || defaultAgent.agentId;
|
|
57
|
-
const existingLink = await findCachedUserMapping(tenantId, slackUserId, teamId);
|
|
57
|
+
const [existingLink, userInfo] = await Promise.all([findCachedUserMapping(tenantId, slackUserId, teamId), getSlackUserInfo(slackClient, slackUserId)]);
|
|
58
58
|
if (!existingLink) {
|
|
59
59
|
logger.info({
|
|
60
60
|
slackUserId,
|
|
@@ -83,11 +83,35 @@ async function handleDirectMessage(params) {
|
|
|
83
83
|
span.end();
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
const userName = userInfo?.displayName || "User";
|
|
87
|
+
const dmChannelContext = "a Slack direct message";
|
|
88
|
+
const senderTimezone = userInfo?.tz ?? void 0;
|
|
89
|
+
let queryText;
|
|
87
90
|
if (isInThread && threadTs) {
|
|
88
91
|
const contextMessages = await getThreadContext(slackClient, channel, threadTs);
|
|
89
|
-
if (contextMessages) queryText =
|
|
90
|
-
|
|
92
|
+
if (contextMessages) queryText = formatSlackQuery({
|
|
93
|
+
text: text || "",
|
|
94
|
+
channelContext: dmChannelContext,
|
|
95
|
+
userName,
|
|
96
|
+
threadContext: contextMessages,
|
|
97
|
+
isAutoExecute: !text,
|
|
98
|
+
messageTs,
|
|
99
|
+
senderTimezone
|
|
100
|
+
});
|
|
101
|
+
else queryText = formatSlackQuery({
|
|
102
|
+
text,
|
|
103
|
+
channelContext: dmChannelContext,
|
|
104
|
+
userName,
|
|
105
|
+
messageTs,
|
|
106
|
+
senderTimezone
|
|
107
|
+
});
|
|
108
|
+
} else queryText = formatSlackQuery({
|
|
109
|
+
text,
|
|
110
|
+
channelContext: dmChannelContext,
|
|
111
|
+
userName,
|
|
112
|
+
messageTs,
|
|
113
|
+
senderTimezone
|
|
114
|
+
});
|
|
91
115
|
const slackUserToken = await signSlackUserToken({
|
|
92
116
|
inkeepUserId: existingLink.inkeepUserId,
|
|
93
117
|
tenantId,
|
|
@@ -118,6 +142,7 @@ async function handleDirectMessage(params) {
|
|
|
118
142
|
agentId: defaultAgent.agentId,
|
|
119
143
|
agentName: agentDisplayName,
|
|
120
144
|
question: queryText,
|
|
145
|
+
rawMessageText: text,
|
|
121
146
|
conversationId,
|
|
122
147
|
entryPoint: "direct_message"
|
|
123
148
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getLogger } from "../../../logger.js";
|
|
2
2
|
import { SlackStrings } from "../../i18n/strings.js";
|
|
3
|
+
import { createContextBlockFromText } from "../blocks/index.js";
|
|
3
4
|
import { streamAgentResponse } from "./streaming.js";
|
|
4
5
|
|
|
5
6
|
//#region src/slack/services/events/execution.ts
|
|
@@ -8,10 +9,12 @@ async function executeAgentPublicly(params) {
|
|
|
8
9
|
const { slackClient, channel, threadTs, agentName } = params;
|
|
9
10
|
let thinkingMessageTs = "";
|
|
10
11
|
try {
|
|
12
|
+
const thinkingText = SlackStrings.status.thinking(agentName);
|
|
11
13
|
thinkingMessageTs = (await slackClient.chat.postMessage({
|
|
12
14
|
channel,
|
|
13
15
|
...threadTs ? { thread_ts: threadTs } : {},
|
|
14
|
-
|
|
16
|
+
blocks: [createContextBlockFromText(thinkingText)],
|
|
17
|
+
text: thinkingText
|
|
15
18
|
})).ts || "";
|
|
16
19
|
} catch (error) {
|
|
17
20
|
logger.warn({
|
|
@@ -37,6 +40,7 @@ async function executeAgentPublicly(params) {
|
|
|
37
40
|
projectId: params.projectId,
|
|
38
41
|
agentId: params.agentId,
|
|
39
42
|
question: params.question,
|
|
43
|
+
rawMessageText: params.rawMessageText,
|
|
40
44
|
agentName,
|
|
41
45
|
conversationId: params.conversationId,
|
|
42
46
|
entryPoint: params.entryPoint
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getLogger } from "../../../logger.js";
|
|
2
2
|
import { findWorkspaceConnectionByTeamId } from "../nango.js";
|
|
3
|
-
import { classifyError, findCachedUserMapping, generateSlackConversationId, getThreadContext, getUserFriendlyErrorMessage } from "./utils.js";
|
|
4
|
-
import { getSlackClient } from "../client.js";
|
|
3
|
+
import { classifyError, findCachedUserMapping, formatChannelContext, formatSlackQuery, generateSlackConversationId, getThreadContext, getUserFriendlyErrorMessage } from "./utils.js";
|
|
4
|
+
import { getSlackChannelInfo, getSlackClient, getSlackUserInfo } from "../client.js";
|
|
5
5
|
import { SLACK_SPAN_KEYS, SLACK_SPAN_NAMES, setSpanWithError, tracer } from "../../tracer.js";
|
|
6
6
|
import { executeAgentPublicly } from "./execution.js";
|
|
7
7
|
import { signSlackUserToken } from "@inkeep/agents-core";
|
|
@@ -50,12 +50,45 @@ async function handleModalSubmission(view) {
|
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
const slackClient = getSlackClient(workspaceConnection.botToken);
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const [channelInfo, userInfo] = await Promise.all([getSlackChannelInfo(slackClient, metadata.channel), getSlackUserInfo(slackClient, metadata.slackUserId)]);
|
|
54
|
+
const channelContext = formatChannelContext(channelInfo);
|
|
55
|
+
const userName = userInfo?.displayName || "User";
|
|
56
|
+
const senderTimezone = userInfo?.tz ?? void 0;
|
|
57
|
+
let fullQuestion;
|
|
58
|
+
if (metadata.messageContext) fullQuestion = formatSlackQuery({
|
|
59
|
+
text: question || "",
|
|
60
|
+
channelContext,
|
|
61
|
+
userName,
|
|
62
|
+
threadContext: metadata.messageContext,
|
|
63
|
+
isAutoExecute: !question,
|
|
64
|
+
messageTs: metadata.messageTs,
|
|
65
|
+
senderTimezone
|
|
66
|
+
});
|
|
55
67
|
else if (metadata.isInThread && metadata.threadTs && includeContext) {
|
|
56
68
|
const contextMessages = await getThreadContext(slackClient, metadata.channel, metadata.threadTs);
|
|
57
|
-
if (contextMessages) fullQuestion =
|
|
58
|
-
|
|
69
|
+
if (contextMessages) fullQuestion = formatSlackQuery({
|
|
70
|
+
text: question || "",
|
|
71
|
+
channelContext,
|
|
72
|
+
userName,
|
|
73
|
+
threadContext: contextMessages,
|
|
74
|
+
isAutoExecute: !question,
|
|
75
|
+
messageTs: metadata.messageTs,
|
|
76
|
+
senderTimezone
|
|
77
|
+
});
|
|
78
|
+
else fullQuestion = formatSlackQuery({
|
|
79
|
+
text: question,
|
|
80
|
+
channelContext,
|
|
81
|
+
userName,
|
|
82
|
+
messageTs: metadata.messageTs,
|
|
83
|
+
senderTimezone
|
|
84
|
+
});
|
|
85
|
+
} else fullQuestion = formatSlackQuery({
|
|
86
|
+
text: question,
|
|
87
|
+
channelContext,
|
|
88
|
+
userName,
|
|
89
|
+
messageTs: metadata.messageTs,
|
|
90
|
+
senderTimezone
|
|
91
|
+
});
|
|
59
92
|
if (!existingLink) {
|
|
60
93
|
logger.info({
|
|
61
94
|
slackUserId: metadata.slackUserId,
|
|
@@ -94,6 +127,7 @@ async function handleModalSubmission(view) {
|
|
|
94
127
|
agentId,
|
|
95
128
|
agentName: agentDisplayName,
|
|
96
129
|
question: fullQuestion,
|
|
130
|
+
rawMessageText: question,
|
|
97
131
|
conversationId,
|
|
98
132
|
entryPoint: metadata.messageContext ? "message_shortcut" : "modal_submission"
|
|
99
133
|
});
|
|
@@ -38,11 +38,11 @@ async function withTimeout(promise, ms, label) {
|
|
|
38
38
|
* since deleting a thread anchor leaves "This message was deleted." as the root.
|
|
39
39
|
*/
|
|
40
40
|
async function cleanupThinkingMessage(params) {
|
|
41
|
-
const { slackClient, channel, thinkingMessageTs, threadTs, slackUserId, agentName,
|
|
41
|
+
const { slackClient, channel, thinkingMessageTs, threadTs, slackUserId, agentName, rawMessageText } = params;
|
|
42
42
|
if (!thinkingMessageTs) return;
|
|
43
43
|
try {
|
|
44
44
|
if (thinkingMessageTs === threadTs) {
|
|
45
|
-
const text =
|
|
45
|
+
const text = rawMessageText ? `<@${slackUserId}> to ${agentName}: "${rawMessageText}"` : `<@${slackUserId}> invoked _${agentName}_`;
|
|
46
46
|
await slackClient.chat.update({
|
|
47
47
|
channel,
|
|
48
48
|
ts: thinkingMessageTs,
|
|
@@ -62,7 +62,8 @@ async function cleanupThinkingMessage(params) {
|
|
|
62
62
|
}
|
|
63
63
|
async function streamAgentResponse(params) {
|
|
64
64
|
return tracer.startActiveSpan(SLACK_SPAN_NAMES.STREAM_AGENT_RESPONSE, async (span) => {
|
|
65
|
-
const { slackClient, channel, threadTs, thinkingMessageTs, slackUserId, teamId, jwtToken, projectId, agentId, question, agentName, conversationId, entryPoint } = params;
|
|
65
|
+
const { slackClient, channel, threadTs, thinkingMessageTs, slackUserId, teamId, jwtToken, projectId, agentId, question, rawMessageText: rawMessageTextParam, agentName, conversationId, entryPoint } = params;
|
|
66
|
+
const rawMessageText = rawMessageTextParam ?? question;
|
|
66
67
|
const threadParam = threadTs ? { thread_ts: threadTs } : {};
|
|
67
68
|
const cleanupParams = {
|
|
68
69
|
slackClient,
|
|
@@ -71,7 +72,7 @@ async function streamAgentResponse(params) {
|
|
|
71
72
|
threadTs,
|
|
72
73
|
slackUserId,
|
|
73
74
|
agentName,
|
|
74
|
-
|
|
75
|
+
rawMessageText
|
|
75
76
|
};
|
|
76
77
|
span.setAttribute(SLACK_SPAN_KEYS.TEAM_ID, teamId);
|
|
77
78
|
span.setAttribute(SLACK_SPAN_KEYS.CHANNEL_ID, channel);
|
|
@@ -11,9 +11,9 @@ declare function findCachedUserMapping(tenantId: string, slackUserId: string, te
|
|
|
11
11
|
id: string;
|
|
12
12
|
createdAt: string;
|
|
13
13
|
updatedAt: string;
|
|
14
|
+
slackUserId: string;
|
|
14
15
|
tenantId: string;
|
|
15
16
|
clientId: string;
|
|
16
|
-
slackUserId: string;
|
|
17
17
|
slackTeamId: string;
|
|
18
18
|
slackEnterpriseId: string | null;
|
|
19
19
|
inkeepUserId: string;
|
|
@@ -178,5 +178,17 @@ declare function formatChannelLabel(channelInfo: {
|
|
|
178
178
|
declare function formatChannelContext(channelInfo: {
|
|
179
179
|
name?: string;
|
|
180
180
|
} | null): string;
|
|
181
|
+
declare function formatMessageTimestamp(messageTs: string, timezone: string): string;
|
|
182
|
+
interface FormatSlackQueryOptions {
|
|
183
|
+
text: string;
|
|
184
|
+
channelContext: string;
|
|
185
|
+
userName: string;
|
|
186
|
+
attachmentContext?: string;
|
|
187
|
+
threadContext?: string;
|
|
188
|
+
isAutoExecute?: boolean;
|
|
189
|
+
messageTs?: string;
|
|
190
|
+
senderTimezone?: string;
|
|
191
|
+
}
|
|
192
|
+
declare function formatSlackQuery(options: FormatSlackQueryOptions): string;
|
|
181
193
|
//#endregion
|
|
182
|
-
export { ProjectOption, SlackAttachment, SlackErrorType, checkIfBotThread, classifyError, escapeSlackLinkText, escapeSlackMrkdwn, extractApiErrorMessage, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, formatAttachments, formatChannelContext, formatChannelLabel, generateSlackConversationId, getChannelAgentConfig, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, markdownToMrkdwn, resolveChannelAgentConfig, sendResponseUrlMessage, timedOp };
|
|
194
|
+
export { FormatSlackQueryOptions, ProjectOption, SlackAttachment, SlackErrorType, checkIfBotThread, classifyError, escapeSlackLinkText, escapeSlackMrkdwn, extractApiErrorMessage, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, formatAttachments, formatChannelContext, formatChannelLabel, formatMessageTimestamp, formatSlackQuery, generateSlackConversationId, getChannelAgentConfig, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, markdownToMrkdwn, resolveChannelAgentConfig, sendResponseUrlMessage, timedOp };
|
|
@@ -440,6 +440,51 @@ function formatChannelContext(channelInfo) {
|
|
|
440
440
|
const label = formatChannelLabel(channelInfo);
|
|
441
441
|
return label ? `the Slack channel ${label}` : "Slack";
|
|
442
442
|
}
|
|
443
|
+
function formatMessageTimestamp(messageTs, timezone) {
|
|
444
|
+
const date = /* @__PURE__ */ new Date(Number.parseFloat(messageTs) * 1e3);
|
|
445
|
+
try {
|
|
446
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
447
|
+
timeZone: timezone,
|
|
448
|
+
year: "numeric",
|
|
449
|
+
month: "short",
|
|
450
|
+
day: "numeric",
|
|
451
|
+
hour: "numeric",
|
|
452
|
+
minute: "2-digit",
|
|
453
|
+
timeZoneName: "short"
|
|
454
|
+
}).format(date);
|
|
455
|
+
} catch (error) {
|
|
456
|
+
logger.error({
|
|
457
|
+
error,
|
|
458
|
+
messageTs,
|
|
459
|
+
timezone
|
|
460
|
+
}, "Failed to format message timestamp");
|
|
461
|
+
return "";
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function formatSlackQuery(options) {
|
|
465
|
+
const { text, channelContext, userName, attachmentContext, threadContext, isAutoExecute, messageTs, senderTimezone } = options;
|
|
466
|
+
const formattedMessageTs = messageTs && senderTimezone ? formatMessageTimestamp(messageTs, senderTimezone) : "";
|
|
467
|
+
const timestampSuffix = formattedMessageTs ? ` (sent ${formattedMessageTs})` : "";
|
|
468
|
+
if (isAutoExecute && threadContext) return `A user mentioned you in a thread in ${channelContext}${timestampSuffix}.
|
|
469
|
+
|
|
470
|
+
<slack_thread_context>
|
|
471
|
+
${threadContext}
|
|
472
|
+
</slack_thread_context>
|
|
473
|
+
|
|
474
|
+
Based on the thread above, provide a helpful response. Consider:
|
|
475
|
+
- What is the main topic or question being discussed?
|
|
476
|
+
- Is there anything that needs clarification or a direct answer?
|
|
477
|
+
- If appropriate, summarize key points or provide relevant information.
|
|
478
|
+
|
|
479
|
+
Respond naturally as if you're joining the conversation to help.`;
|
|
480
|
+
if (threadContext) {
|
|
481
|
+
let messageContent = text;
|
|
482
|
+
if (attachmentContext) messageContent = `${text}\n\n<attached_content>\n${attachmentContext}\n</attached_content>`;
|
|
483
|
+
return `The following is thread context from ${channelContext}:\n\n<slack_thread_context>\n${threadContext}\n</slack_thread_context>\n\nMessage from ${userName}${timestampSuffix}: ${messageContent}`;
|
|
484
|
+
}
|
|
485
|
+
if (attachmentContext) return `The following is a message from ${channelContext} from ${userName}${timestampSuffix}: """${text}"""\n\nThe message also includes the following shared/forwarded content:\n\n<attached_content>\n${attachmentContext}\n</attached_content>`;
|
|
486
|
+
return `The following is a message from ${channelContext} from ${userName}${timestampSuffix}: """${text}"""`;
|
|
487
|
+
}
|
|
443
488
|
|
|
444
489
|
//#endregion
|
|
445
|
-
export { SlackErrorType, checkIfBotThread, classifyError, escapeSlackLinkText, escapeSlackMrkdwn, extractApiErrorMessage, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, formatAttachments, formatChannelContext, formatChannelLabel, generateSlackConversationId, getChannelAgentConfig, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, markdownToMrkdwn, resolveChannelAgentConfig, sendResponseUrlMessage, timedOp };
|
|
490
|
+
export { SlackErrorType, checkIfBotThread, classifyError, escapeSlackLinkText, escapeSlackMrkdwn, extractApiErrorMessage, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, formatAttachments, formatChannelContext, formatChannelLabel, formatMessageTimestamp, formatSlackQuery, generateSlackConversationId, getChannelAgentConfig, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, markdownToMrkdwn, resolveChannelAgentConfig, sendResponseUrlMessage, timedOp };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentResolutionParams, ResolvedAgentConfig, getAgentConfigSources, resolveEffectiveAgent } from "./agent-resolution.js";
|
|
2
|
-
import { AgentConfigSources, ContextBlockParams, ToolApprovalButtonValue, ToolApprovalButtonValueSchema, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, createAlreadyLinkedMessage, createContextBlock, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage } from "./blocks/index.js";
|
|
2
|
+
import { AgentConfigSources, ContextBlockParams, ToolApprovalButtonValue, ToolApprovalButtonValueSchema, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, createAlreadyLinkedMessage, createContextBlock, createContextBlockFromText, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage } from "./blocks/index.js";
|
|
3
3
|
import { checkUserIsChannelMember, getBotMemberChannels, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackTeamInfo, getSlackUserInfo, postMessage, postMessageInThread, revokeSlackToken } from "./client.js";
|
|
4
4
|
import { DefaultAgentConfig, SlackWorkspaceConnection, WorkspaceInstallData, clearWorkspaceConnectionCache, computeWorkspaceConnectionId, createConnectSession, deleteWorkspaceInstallation, findWorkspaceConnectionByTeamId, getConnectionAccessToken, getSlackIntegrationId, getSlackNango, getWorkspaceDefaultAgentFromNango, listWorkspaceInstallations, setWorkspaceDefaultAgent, storeWorkspaceInstallation, updateConnectionMetadata } from "./nango.js";
|
|
5
5
|
import { SlackCommandPayload, SlackCommandResponse } from "./types.js";
|
|
@@ -15,4 +15,4 @@ import { handleModalSubmission } from "./events/modal-submission.js";
|
|
|
15
15
|
import "./events/index.js";
|
|
16
16
|
import { parseSlackCommandBody, parseSlackEventBody, verifySlackRequest } from "./security.js";
|
|
17
17
|
import { getBotTokenForTeam, setBotTokenForTeam } from "./workspace-tokens.js";
|
|
18
|
-
export { AgentConfigSources, AgentOption, AgentResolutionParams, BuildAgentSelectorModalParams, BuildMessageShortcutModalParams, ContextBlockParams, DefaultAgentConfig, InlineSelectorMetadata, ModalMetadata, PublicExecutionParams, ResolvedAgentConfig, SlackCommandPayload, SlackCommandResponse, SlackErrorType, SlackWorkspaceConnection, StreamResult, ToolApprovalButtonValue, ToolApprovalButtonValueSchema, WorkspaceInstallData, buildAgentSelectorModal, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildMessageShortcutModal, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, checkIfBotThread, checkUserIsChannelMember, classifyError, clearWorkspaceConnectionCache, computeWorkspaceConnectionId, createAlreadyLinkedMessage, createConnectSession, createContextBlock, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage, deleteWorkspaceInstallation, executeAgentPublicly, extractApiErrorMessage, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, findWorkspaceConnectionByTeamId, generateSlackConversationId, getAgentConfigSources, getBotMemberChannels, getBotTokenForTeam, getChannelAgentConfig, getConnectionAccessToken, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackIntegrationId, getSlackNango, getSlackTeamInfo, getSlackUserInfo, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, getWorkspaceDefaultAgentFromNango, handleAgentPickerCommand, handleAppMention, handleCommand, handleDirectMessage, handleHelpCommand, handleLinkCommand, handleMessageShortcut, handleModalSubmission, handleOpenAgentSelectorModal, handleQuestionCommand, handleStatusCommand, handleToolApproval, handleUnlinkCommand, listWorkspaceInstallations, markdownToMrkdwn, parseSlackCommandBody, parseSlackEventBody, postMessage, postMessageInThread, resolveEffectiveAgent, revokeSlackToken, sendResponseUrlMessage, setBotTokenForTeam, setWorkspaceDefaultAgent, storeWorkspaceInstallation, streamAgentResponse, updateConnectionMetadata, verifySlackRequest };
|
|
18
|
+
export { AgentConfigSources, AgentOption, AgentResolutionParams, BuildAgentSelectorModalParams, BuildMessageShortcutModalParams, ContextBlockParams, DefaultAgentConfig, InlineSelectorMetadata, ModalMetadata, PublicExecutionParams, ResolvedAgentConfig, SlackCommandPayload, SlackCommandResponse, SlackErrorType, SlackWorkspaceConnection, StreamResult, ToolApprovalButtonValue, ToolApprovalButtonValueSchema, WorkspaceInstallData, buildAgentSelectorModal, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildMessageShortcutModal, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, checkIfBotThread, checkUserIsChannelMember, classifyError, clearWorkspaceConnectionCache, computeWorkspaceConnectionId, createAlreadyLinkedMessage, createConnectSession, createContextBlock, createContextBlockFromText, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage, deleteWorkspaceInstallation, executeAgentPublicly, extractApiErrorMessage, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, findWorkspaceConnectionByTeamId, generateSlackConversationId, getAgentConfigSources, getBotMemberChannels, getBotTokenForTeam, getChannelAgentConfig, getConnectionAccessToken, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackIntegrationId, getSlackNango, getSlackTeamInfo, getSlackUserInfo, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, getWorkspaceDefaultAgentFromNango, handleAgentPickerCommand, handleAppMention, handleCommand, handleDirectMessage, handleHelpCommand, handleLinkCommand, handleMessageShortcut, handleModalSubmission, handleOpenAgentSelectorModal, handleQuestionCommand, handleStatusCommand, handleToolApproval, handleUnlinkCommand, listWorkspaceInstallations, markdownToMrkdwn, parseSlackCommandBody, parseSlackEventBody, postMessage, postMessageInThread, resolveEffectiveAgent, revokeSlackToken, sendResponseUrlMessage, setBotTokenForTeam, setWorkspaceDefaultAgent, storeWorkspaceInstallation, streamAgentResponse, updateConnectionMetadata, verifySlackRequest };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clearWorkspaceConnectionCache, computeWorkspaceConnectionId, createConnectSession, deleteWorkspaceInstallation, findWorkspaceConnectionByTeamId, getConnectionAccessToken, getSlackIntegrationId, getSlackNango, getWorkspaceDefaultAgentFromNango, listWorkspaceInstallations, setWorkspaceDefaultAgent, storeWorkspaceInstallation, updateConnectionMetadata } from "./nango.js";
|
|
2
2
|
import { SlackErrorType, checkIfBotThread, classifyError, extractApiErrorMessage, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, generateSlackConversationId, getChannelAgentConfig, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, markdownToMrkdwn, sendResponseUrlMessage } from "./events/utils.js";
|
|
3
3
|
import { getAgentConfigSources, resolveEffectiveAgent } from "./agent-resolution.js";
|
|
4
|
-
import { ToolApprovalButtonValueSchema, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, createAlreadyLinkedMessage, createContextBlock, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage } from "./blocks/index.js";
|
|
4
|
+
import { ToolApprovalButtonValueSchema, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, createAlreadyLinkedMessage, createContextBlock, createContextBlockFromText, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage } from "./blocks/index.js";
|
|
5
5
|
import { checkUserIsChannelMember, getBotMemberChannels, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackTeamInfo, getSlackUserInfo, postMessage, postMessageInThread, revokeSlackToken } from "./client.js";
|
|
6
6
|
import { streamAgentResponse } from "./events/streaming.js";
|
|
7
7
|
import { executeAgentPublicly } from "./events/execution.js";
|
|
@@ -15,4 +15,4 @@ import "./events/index.js";
|
|
|
15
15
|
import { parseSlackCommandBody, parseSlackEventBody, verifySlackRequest } from "./security.js";
|
|
16
16
|
import { getBotTokenForTeam, setBotTokenForTeam } from "./workspace-tokens.js";
|
|
17
17
|
|
|
18
|
-
export { SlackErrorType, ToolApprovalButtonValueSchema, buildAgentSelectorModal, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildMessageShortcutModal, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, checkIfBotThread, checkUserIsChannelMember, classifyError, clearWorkspaceConnectionCache, computeWorkspaceConnectionId, createAlreadyLinkedMessage, createConnectSession, createContextBlock, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage, deleteWorkspaceInstallation, executeAgentPublicly, extractApiErrorMessage, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, findWorkspaceConnectionByTeamId, generateSlackConversationId, getAgentConfigSources, getBotMemberChannels, getBotTokenForTeam, getChannelAgentConfig, getConnectionAccessToken, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackIntegrationId, getSlackNango, getSlackTeamInfo, getSlackUserInfo, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, getWorkspaceDefaultAgentFromNango, handleAgentPickerCommand, handleAppMention, handleCommand, handleDirectMessage, handleHelpCommand, handleLinkCommand, handleMessageShortcut, handleModalSubmission, handleOpenAgentSelectorModal, handleQuestionCommand, handleStatusCommand, handleToolApproval, handleUnlinkCommand, listWorkspaceInstallations, markdownToMrkdwn, parseSlackCommandBody, parseSlackEventBody, postMessage, postMessageInThread, resolveEffectiveAgent, revokeSlackToken, sendResponseUrlMessage, setBotTokenForTeam, setWorkspaceDefaultAgent, storeWorkspaceInstallation, streamAgentResponse, updateConnectionMetadata, verifySlackRequest };
|
|
18
|
+
export { SlackErrorType, ToolApprovalButtonValueSchema, buildAgentSelectorModal, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildMessageShortcutModal, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, checkIfBotThread, checkUserIsChannelMember, classifyError, clearWorkspaceConnectionCache, computeWorkspaceConnectionId, createAlreadyLinkedMessage, createConnectSession, createContextBlock, createContextBlockFromText, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage, deleteWorkspaceInstallation, executeAgentPublicly, extractApiErrorMessage, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, findWorkspaceConnectionByTeamId, generateSlackConversationId, getAgentConfigSources, getBotMemberChannels, getBotTokenForTeam, getChannelAgentConfig, getConnectionAccessToken, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackIntegrationId, getSlackNango, getSlackTeamInfo, getSlackUserInfo, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, getWorkspaceDefaultAgentFromNango, handleAgentPickerCommand, handleAppMention, handleCommand, handleDirectMessage, handleHelpCommand, handleLinkCommand, handleMessageShortcut, handleModalSubmission, handleOpenAgentSelectorModal, handleQuestionCommand, handleStatusCommand, handleToolApproval, handleUnlinkCommand, listWorkspaceInstallations, markdownToMrkdwn, parseSlackCommandBody, parseSlackEventBody, postMessage, postMessageInThread, resolveEffectiveAgent, revokeSlackToken, sendResponseUrlMessage, setBotTokenForTeam, setWorkspaceDefaultAgent, storeWorkspaceInstallation, streamAgentResponse, updateConnectionMetadata, verifySlackRequest };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SlackLinkIntent } from "@inkeep/agents-core";
|
|
2
|
-
import * as
|
|
2
|
+
import * as slack_block_builder0 from "slack-block-builder";
|
|
3
3
|
|
|
4
4
|
//#region src/slack/services/link-prompt.d.ts
|
|
5
5
|
type LinkPromptResult = {
|
|
@@ -22,6 +22,6 @@ interface ResolveLinkActionParams {
|
|
|
22
22
|
intent?: SlackLinkIntent;
|
|
23
23
|
}
|
|
24
24
|
declare function resolveUnlinkedUserAction(params: ResolveLinkActionParams): Promise<LinkPromptResult>;
|
|
25
|
-
declare function buildLinkPromptMessage(result: LinkPromptResult): Readonly<
|
|
25
|
+
declare function buildLinkPromptMessage(result: LinkPromptResult): Readonly<slack_block_builder0.SlackMessageDto>;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { LinkPromptResult, ResolveLinkActionParams, buildLinkPromptMessage, resolveUnlinkedUserAction };
|
|
@@ -480,6 +480,7 @@ async function listWorkspaceInstallations() {
|
|
|
480
480
|
connectionId: conn.connection_id,
|
|
481
481
|
teamId: metadata.slack_team_id || "",
|
|
482
482
|
teamName: metadata.slack_team_name,
|
|
483
|
+
teamDomain: metadata.slack_team_domain || void 0,
|
|
483
484
|
botToken: credentials.credentials.access_token,
|
|
484
485
|
tenantId: metadata.tenant_id || metadata.inkeep_tenant_id || "",
|
|
485
486
|
defaultAgent
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { env } from "../../env.js";
|
|
2
2
|
import { getLogger } from "../../logger.js";
|
|
3
3
|
import { findWorkspaceConnectionByTeamId } from "./nango.js";
|
|
4
|
-
import { generateSlackConversationId, sendResponseUrlMessage } from "./events/utils.js";
|
|
4
|
+
import { formatChannelContext, formatSlackQuery, generateSlackConversationId, sendResponseUrlMessage } from "./events/utils.js";
|
|
5
5
|
import { resolveEffectiveAgent } from "./agent-resolution.js";
|
|
6
6
|
import { createContextBlock } from "./blocks/index.js";
|
|
7
|
-
import { getSlackClient } from "./client.js";
|
|
7
|
+
import { getSlackChannelInfo, getSlackClient, getSlackUserInfo } from "./client.js";
|
|
8
8
|
import { streamAgentResponse } from "./events/streaming.js";
|
|
9
9
|
import { executeAgentPublicly } from "./events/execution.js";
|
|
10
10
|
import { getInProcessFetch, signSlackUserToken } from "@inkeep/agents-core";
|
|
@@ -99,10 +99,23 @@ async function resumeMention(intent, slackClient, tokenCtx, teamId, tenantId) {
|
|
|
99
99
|
await postErrorToChannel(slackClient, intent.channelId, slackUserId, void 0, "We couldn't resume your question due to a technical issue. Please try mentioning @Inkeep again.");
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
const agentConfig = await
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
const [agentConfig, channelInfo, userInfo] = await Promise.all([
|
|
103
|
+
resolveEffectiveAgent({
|
|
104
|
+
tenantId,
|
|
105
|
+
teamId,
|
|
106
|
+
channelId: intent.channelId
|
|
107
|
+
}),
|
|
108
|
+
getSlackChannelInfo(slackClient, intent.channelId),
|
|
109
|
+
getSlackUserInfo(slackClient, slackUserId)
|
|
110
|
+
]);
|
|
111
|
+
const channelContext = formatChannelContext(channelInfo);
|
|
112
|
+
const userName = userInfo?.displayName || "User";
|
|
113
|
+
const formattedQuestion = formatSlackQuery({
|
|
114
|
+
text: intent.question,
|
|
115
|
+
channelContext,
|
|
116
|
+
userName,
|
|
117
|
+
messageTs: intent.messageTs || replyThreadTs,
|
|
118
|
+
senderTimezone: userInfo?.tz ?? void 0
|
|
106
119
|
});
|
|
107
120
|
const slackUserToken = await signSlackUserToken({
|
|
108
121
|
...tokenCtx,
|
|
@@ -128,7 +141,8 @@ async function resumeMention(intent, slackClient, tokenCtx, teamId, tenantId) {
|
|
|
128
141
|
jwtToken: slackUserToken,
|
|
129
142
|
projectId: intent.projectId,
|
|
130
143
|
agentId: intent.agentId,
|
|
131
|
-
question:
|
|
144
|
+
question: formattedQuestion,
|
|
145
|
+
rawMessageText: intent.question,
|
|
132
146
|
agentName: intent.agentId,
|
|
133
147
|
conversationId,
|
|
134
148
|
entryPoint: "smart_link_resume"
|
|
@@ -146,6 +160,15 @@ async function resumeDirectMessage(intent, slackClient, tokenCtx, teamId) {
|
|
|
146
160
|
await postErrorToChannel(slackClient, intent.channelId, slackUserId);
|
|
147
161
|
return;
|
|
148
162
|
}
|
|
163
|
+
const userInfo = await getSlackUserInfo(slackClient, slackUserId);
|
|
164
|
+
const userName = userInfo?.displayName || "User";
|
|
165
|
+
const formattedQuestion = formatSlackQuery({
|
|
166
|
+
text: intent.question,
|
|
167
|
+
channelContext: "a Slack direct message",
|
|
168
|
+
userName,
|
|
169
|
+
messageTs: intent.messageTs || void 0,
|
|
170
|
+
senderTimezone: userInfo?.tz ?? void 0
|
|
171
|
+
});
|
|
149
172
|
const slackUserToken = await signSlackUserToken({
|
|
150
173
|
...tokenCtx,
|
|
151
174
|
slackAuthorized: false
|
|
@@ -166,23 +189,37 @@ async function resumeDirectMessage(intent, slackClient, tokenCtx, teamId) {
|
|
|
166
189
|
projectId: intent.projectId,
|
|
167
190
|
agentId: intent.agentId,
|
|
168
191
|
agentName: intent.agentId,
|
|
169
|
-
question:
|
|
192
|
+
question: formattedQuestion,
|
|
193
|
+
rawMessageText: intent.question,
|
|
170
194
|
conversationId,
|
|
171
195
|
entryPoint: "smart_link_resume"
|
|
172
196
|
});
|
|
173
197
|
}
|
|
174
198
|
async function resumeCommand(intent, slackClient, tokenCtx, teamId, tenantId) {
|
|
175
199
|
const { slackUserId } = tokenCtx;
|
|
176
|
-
const resolvedAgent = await
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
200
|
+
const [resolvedAgent, channelInfo, userInfo] = await Promise.all([
|
|
201
|
+
resolveEffectiveAgent({
|
|
202
|
+
tenantId,
|
|
203
|
+
teamId,
|
|
204
|
+
channelId: intent.channelId,
|
|
205
|
+
userId: slackUserId
|
|
206
|
+
}),
|
|
207
|
+
getSlackChannelInfo(slackClient, intent.channelId),
|
|
208
|
+
getSlackUserInfo(slackClient, slackUserId)
|
|
209
|
+
]);
|
|
182
210
|
if (!resolvedAgent) {
|
|
183
211
|
await postErrorToChannel(slackClient, intent.channelId, slackUserId, void 0, "The agent couldn't be found. Try asking your question again.");
|
|
184
212
|
return;
|
|
185
213
|
}
|
|
214
|
+
const channelContext = formatChannelContext(channelInfo);
|
|
215
|
+
const userName = userInfo?.displayName || "User";
|
|
216
|
+
const formattedQuestion = formatSlackQuery({
|
|
217
|
+
text: intent.question,
|
|
218
|
+
channelContext,
|
|
219
|
+
userName,
|
|
220
|
+
messageTs: intent.messageTs || void 0,
|
|
221
|
+
senderTimezone: userInfo?.tz ?? void 0
|
|
222
|
+
});
|
|
186
223
|
await executeAndDeliver({
|
|
187
224
|
intent,
|
|
188
225
|
slackClient,
|
|
@@ -194,7 +231,8 @@ async function resumeCommand(intent, slackClient, tokenCtx, teamId, tenantId) {
|
|
|
194
231
|
teamId,
|
|
195
232
|
agentId: resolvedAgent.agentId,
|
|
196
233
|
agentName: resolvedAgent.agentName || resolvedAgent.agentId,
|
|
197
|
-
projectId: resolvedAgent.projectId
|
|
234
|
+
projectId: resolvedAgent.projectId,
|
|
235
|
+
formattedQuestion
|
|
198
236
|
});
|
|
199
237
|
}
|
|
200
238
|
async function resumeRunCommand(intent, slackClient, tokenCtx, teamId, tenantId) {
|
|
@@ -207,11 +245,15 @@ async function resumeRunCommand(intent, slackClient, tokenCtx, teamId, tenantId)
|
|
|
207
245
|
await postErrorToChannel(slackClient, intent.channelId, slackUserId);
|
|
208
246
|
return;
|
|
209
247
|
}
|
|
210
|
-
const agentConfig = await
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
248
|
+
const [agentConfig, channelInfo, userInfo] = await Promise.all([
|
|
249
|
+
resolveEffectiveAgent({
|
|
250
|
+
tenantId,
|
|
251
|
+
teamId,
|
|
252
|
+
channelId: intent.channelId
|
|
253
|
+
}),
|
|
254
|
+
getSlackChannelInfo(slackClient, intent.channelId),
|
|
255
|
+
getSlackUserInfo(slackClient, slackUserId)
|
|
256
|
+
]);
|
|
215
257
|
const slackUserToken = await signSlackUserToken({
|
|
216
258
|
...tokenCtx,
|
|
217
259
|
...getChannelAuthClaims(agentConfig, intent.channelId)
|
|
@@ -221,6 +263,15 @@ async function resumeRunCommand(intent, slackClient, tokenCtx, teamId, tenantId)
|
|
|
221
263
|
await postErrorToChannel(slackClient, intent.channelId, slackUserId, void 0, `Agent "${intent.agentIdentifier}" couldn't be found. Try asking your question again.`);
|
|
222
264
|
return;
|
|
223
265
|
}
|
|
266
|
+
const channelContext = formatChannelContext(channelInfo);
|
|
267
|
+
const userName = userInfo?.displayName || "User";
|
|
268
|
+
const formattedQuestion = formatSlackQuery({
|
|
269
|
+
text: intent.question,
|
|
270
|
+
channelContext,
|
|
271
|
+
userName,
|
|
272
|
+
messageTs: intent.messageTs || void 0,
|
|
273
|
+
senderTimezone: userInfo?.tz ?? void 0
|
|
274
|
+
});
|
|
224
275
|
await executeAndDeliver({
|
|
225
276
|
intent,
|
|
226
277
|
slackClient,
|
|
@@ -229,7 +280,8 @@ async function resumeRunCommand(intent, slackClient, tokenCtx, teamId, tenantId)
|
|
|
229
280
|
teamId,
|
|
230
281
|
agentId: agentInfo.id,
|
|
231
282
|
agentName: agentInfo.name || agentInfo.id,
|
|
232
|
-
projectId: agentInfo.projectId
|
|
283
|
+
projectId: agentInfo.projectId,
|
|
284
|
+
formattedQuestion
|
|
233
285
|
});
|
|
234
286
|
}
|
|
235
287
|
async function findAgentByIdentifierViaApi(tenantId, identifier, authToken) {
|
|
@@ -287,7 +339,7 @@ async function findAgentByIdentifierViaApi(tenantId, identifier, authToken) {
|
|
|
287
339
|
}
|
|
288
340
|
}
|
|
289
341
|
async function executeAndDeliver(params) {
|
|
290
|
-
const { intent, slackClient, slackUserToken, slackUserId, teamId, agentId, agentName, projectId } = params;
|
|
342
|
+
const { intent, slackClient, slackUserToken, slackUserId, teamId, agentId, agentName, projectId, formattedQuestion } = params;
|
|
291
343
|
const apiBaseUrl = env.INKEEP_AGENTS_API_URL || "http://localhost:3002";
|
|
292
344
|
const controller = new AbortController();
|
|
293
345
|
const timeout = setTimeout(() => controller.abort(), 3e4);
|
|
@@ -306,7 +358,7 @@ async function executeAndDeliver(params) {
|
|
|
306
358
|
body: JSON.stringify({
|
|
307
359
|
messages: [{
|
|
308
360
|
role: "user",
|
|
309
|
-
content:
|
|
361
|
+
content: formattedQuestion
|
|
310
362
|
}],
|
|
311
363
|
stream: false
|
|
312
364
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-work-apps",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.11",
|
|
4
4
|
"description": "First party integrations for Inkeep Agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"jose": "^6.1.0",
|
|
34
34
|
"minimatch": "^10.2.1",
|
|
35
35
|
"slack-block-builder": "^2.8.0",
|
|
36
|
-
"@inkeep/agents-core": "0.53.
|
|
36
|
+
"@inkeep/agents-core": "0.53.11"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@hono/zod-openapi": "^1.1.5",
|