@inkeep/agents-work-apps 0.53.3 → 0.53.5
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/github/index.d.ts +3 -3
- package/dist/github/mcp/index.d.ts +2 -2
- package/dist/github/mcp/index.js +61 -1
- package/dist/github/mcp/utils.d.ts +18 -1
- package/dist/github/mcp/utils.js +52 -16
- package/dist/github/routes/setup.d.ts +2 -2
- package/dist/github/routes/tokenExchange.d.ts +2 -2
- package/dist/slack/routes/workspaces.js +3 -3
- package/dist/slack/services/client.d.ts +21 -1
- package/dist/slack/services/client.js +43 -1
- package/dist/slack/services/events/streaming.js +10 -1
- package/dist/slack/services/index.d.ts +2 -2
- package/dist/slack/services/index.js +2 -2
- package/package.json +2 -2
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_types6 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_types6.BlankEnv, hono_types6.BlankSchema, "/">;
|
|
11
|
+
declare const githubRoutes: Hono<hono_types6.BlankEnv, hono_types6.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_types1 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_types1.BlankSchema, "/">;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { app as default };
|
package/dist/github/mcp/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import runDbClient_default from "../../db/runDbClient.js";
|
|
2
2
|
import { githubMcpAuth } from "./auth.js";
|
|
3
3
|
import { ReactionContentSchema } from "./schemas.js";
|
|
4
|
-
import { commitFileChanges, commitNewFile, createIssueCommentReaction, createPullRequestReviewCommentReaction, deleteIssueCommentReaction, deletePullRequestReviewCommentReaction, fetchBranchChangedFiles, fetchComments, fetchPrFileDiffs, fetchPrFiles, fetchPrInfo, formatFileDiff, generatePrMarkdown, getGitHubClientFromRepo, listIssueCommentReactions, listIssueReactions, listPullRequestReviewCommentReactions, visualizeUpdateOperations } from "./utils.js";
|
|
4
|
+
import { commitFileChanges, commitNewFile, createIssueCommentReaction, createPullRequestReviewCommentReaction, deleteIssueCommentReaction, deletePullRequestReviewCommentReaction, fetchBranchChangedFiles, fetchComments, fetchPrFileDiffs, fetchPrFiles, fetchPrInfo, formatFileDiff, generatePrMarkdown, getGitHubClientFromRepo, listIssueCommentReactions, listIssueReactions, listPullRequestReviewCommentReactions, moveFile, visualizeUpdateOperations } from "./utils.js";
|
|
5
5
|
import { z } from "@hono/zod-openapi";
|
|
6
6
|
import { getMcpToolRepositoryAccessWithDetails } from "@inkeep/agents-core";
|
|
7
7
|
import { Hono } from "hono";
|
|
@@ -519,6 +519,66 @@ const getServer = async (toolId) => {
|
|
|
519
519
|
};
|
|
520
520
|
}
|
|
521
521
|
});
|
|
522
|
+
server.tool("move-file", `Move (rename) a file within a repository in a single atomic commit. The file content is preserved and the old path is deleted. ${getAvailableRepositoryString(repositoryAccess)}`, {
|
|
523
|
+
owner: z.string().describe("Repository owner name"),
|
|
524
|
+
repo: z.string().describe("Repository name"),
|
|
525
|
+
branch_name: z.string().describe("Branch to commit the move to"),
|
|
526
|
+
source_path: z.string().describe("Current path of the file (relative to repository root)"),
|
|
527
|
+
destination_path: z.string().describe("New path for the file (relative to repository root)"),
|
|
528
|
+
commit_message: z.string().describe("Commit message for the move")
|
|
529
|
+
}, async ({ owner, repo, branch_name, source_path, destination_path, commit_message }) => {
|
|
530
|
+
try {
|
|
531
|
+
let githubClient;
|
|
532
|
+
try {
|
|
533
|
+
githubClient = getGitHubClientFromRepo(owner, repo, installationIdMap);
|
|
534
|
+
} catch (error) {
|
|
535
|
+
return {
|
|
536
|
+
content: [{
|
|
537
|
+
type: "text",
|
|
538
|
+
text: `Error accessing GitHub: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
539
|
+
}],
|
|
540
|
+
isError: true
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
return { content: [{
|
|
544
|
+
type: "text",
|
|
545
|
+
text: `Successfully moved "${source_path}" to "${destination_path}" in ${owner}/${repo} on branch "${branch_name}"\n\nCommit SHA: ${await moveFile({
|
|
546
|
+
githubClient,
|
|
547
|
+
owner,
|
|
548
|
+
repo,
|
|
549
|
+
sourcePath: source_path,
|
|
550
|
+
destinationPath: destination_path,
|
|
551
|
+
branchName: branch_name,
|
|
552
|
+
commitMessage: commit_message
|
|
553
|
+
})}`
|
|
554
|
+
}] };
|
|
555
|
+
} catch (error) {
|
|
556
|
+
if (error instanceof Error && "status" in error) {
|
|
557
|
+
const apiError = error;
|
|
558
|
+
if (apiError.status === 404) return {
|
|
559
|
+
content: [{
|
|
560
|
+
type: "text",
|
|
561
|
+
text: `Repository ${owner}/${repo}, branch "${branch_name}", or source file "${source_path}" not found.`
|
|
562
|
+
}],
|
|
563
|
+
isError: true
|
|
564
|
+
};
|
|
565
|
+
if (apiError.status === 422) return {
|
|
566
|
+
content: [{
|
|
567
|
+
type: "text",
|
|
568
|
+
text: `Invalid move operation. The destination path "${destination_path}" may already exist or the path is invalid.`
|
|
569
|
+
}],
|
|
570
|
+
isError: true
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
return {
|
|
574
|
+
content: [{
|
|
575
|
+
type: "text",
|
|
576
|
+
text: `Error moving file: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
577
|
+
}],
|
|
578
|
+
isError: true
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
});
|
|
522
582
|
server.tool("create-pull-request", `Create a pull request in a repository. ${getAvailableRepositoryString(repositoryAccess)}`, {
|
|
523
583
|
owner: z.string().describe("Repository owner name"),
|
|
524
584
|
repo: z.string().describe("Repository name"),
|
|
@@ -236,6 +236,23 @@ declare function commitNewFile({
|
|
|
236
236
|
content: string;
|
|
237
237
|
commitMessage: string;
|
|
238
238
|
}): Promise<string>;
|
|
239
|
+
declare function moveFile({
|
|
240
|
+
githubClient,
|
|
241
|
+
owner,
|
|
242
|
+
repo,
|
|
243
|
+
sourcePath,
|
|
244
|
+
destinationPath,
|
|
245
|
+
branchName,
|
|
246
|
+
commitMessage
|
|
247
|
+
}: {
|
|
248
|
+
githubClient: Octokit;
|
|
249
|
+
owner: string;
|
|
250
|
+
repo: string;
|
|
251
|
+
sourcePath: string;
|
|
252
|
+
destinationPath: string;
|
|
253
|
+
branchName: string;
|
|
254
|
+
commitMessage: string;
|
|
255
|
+
}): Promise<string>;
|
|
239
256
|
declare function createIssueCommentReaction(octokit: Octokit, owner: string, repo: string, commentId: number, content: ReactionContent): Promise<{
|
|
240
257
|
id: number;
|
|
241
258
|
content: string;
|
|
@@ -257,4 +274,4 @@ declare function listPullRequestReviewCommentReactions(octokit: Octokit, owner:
|
|
|
257
274
|
declare function listIssueReactions(octokit: Octokit, owner: string, repo: string, issueNumber: number): Promise<ReactionDetail[]>;
|
|
258
275
|
declare function formatFileDiff(pullRequestNumber: number, files: ChangedFile[], includeContents?: boolean): Promise<string>;
|
|
259
276
|
//#endregion
|
|
260
|
-
export { CommitData, LLMUpdateOperation, PullCommit, ReactionDetail, applyOperation, applyOperations, commitFileChanges, commitNewFile, createIssueCommentReaction, createPullRequestReviewCommentReaction, deleteIssueCommentReaction, deletePullRequestReviewCommentReaction, fetchBranchChangedFiles, fetchComments, fetchCommitDetails, fetchPrCommits, fetchPrFileDiffs, fetchPrFiles, fetchPrInfo, formatFileDiff, generatePrMarkdown, getFilePathsInRepo, getGitHubClientFromInstallationId, getGitHubClientFromRepo, listIssueCommentReactions, listIssueReactions, listPullRequestReviewCommentReactions, validateLineNumbers, visualizeUpdateOperations };
|
|
277
|
+
export { CommitData, LLMUpdateOperation, PullCommit, ReactionDetail, applyOperation, applyOperations, commitFileChanges, commitNewFile, createIssueCommentReaction, createPullRequestReviewCommentReaction, deleteIssueCommentReaction, deletePullRequestReviewCommentReaction, fetchBranchChangedFiles, fetchComments, fetchCommitDetails, fetchPrCommits, fetchPrFileDiffs, fetchPrFiles, fetchPrInfo, formatFileDiff, generatePrMarkdown, getFilePathsInRepo, getGitHubClientFromInstallationId, getGitHubClientFromRepo, listIssueCommentReactions, listIssueReactions, listPullRequestReviewCommentReactions, moveFile, validateLineNumbers, visualizeUpdateOperations };
|
package/dist/github/mcp/utils.js
CHANGED
|
@@ -615,33 +615,22 @@ function visualizeUpdateOperations(fileContent, operations) {
|
|
|
615
615
|
return `Error applying operations: ${error instanceof Error ? error.message : "Unknown error"}`;
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
async function
|
|
618
|
+
async function commitTreeEntries({ githubClient, owner, repo, branchName, treeEntries, commitMessage }) {
|
|
619
619
|
const currentSha = (await githubClient.rest.git.getRef({
|
|
620
620
|
owner,
|
|
621
621
|
repo,
|
|
622
622
|
ref: `heads/${branchName}`
|
|
623
623
|
})).data.object.sha;
|
|
624
|
-
const
|
|
624
|
+
const currentCommit = await githubClient.rest.git.getCommit({
|
|
625
625
|
owner,
|
|
626
626
|
repo,
|
|
627
627
|
commit_sha: currentSha
|
|
628
|
-
})).data.tree.sha;
|
|
629
|
-
const blob = await githubClient.rest.git.createBlob({
|
|
630
|
-
owner,
|
|
631
|
-
repo,
|
|
632
|
-
content: Buffer.from(content).toString("base64"),
|
|
633
|
-
encoding: "base64"
|
|
634
628
|
});
|
|
635
629
|
const newTree = await githubClient.rest.git.createTree({
|
|
636
630
|
owner,
|
|
637
631
|
repo,
|
|
638
|
-
base_tree:
|
|
639
|
-
tree:
|
|
640
|
-
path: filePath,
|
|
641
|
-
mode: "100644",
|
|
642
|
-
type: "blob",
|
|
643
|
-
sha: blob.data.sha
|
|
644
|
-
}]
|
|
632
|
+
base_tree: currentCommit.data.tree.sha,
|
|
633
|
+
tree: treeEntries
|
|
645
634
|
});
|
|
646
635
|
const newCommit = await githubClient.rest.git.createCommit({
|
|
647
636
|
owner,
|
|
@@ -658,6 +647,26 @@ async function commitContent({ githubClient, owner, repo, filePath, branchName,
|
|
|
658
647
|
});
|
|
659
648
|
return newCommit.data.sha;
|
|
660
649
|
}
|
|
650
|
+
async function commitContent({ githubClient, owner, repo, filePath, branchName, content, commitMessage }) {
|
|
651
|
+
return commitTreeEntries({
|
|
652
|
+
githubClient,
|
|
653
|
+
owner,
|
|
654
|
+
repo,
|
|
655
|
+
branchName,
|
|
656
|
+
treeEntries: [{
|
|
657
|
+
path: filePath,
|
|
658
|
+
mode: "100644",
|
|
659
|
+
type: "blob",
|
|
660
|
+
sha: (await githubClient.rest.git.createBlob({
|
|
661
|
+
owner,
|
|
662
|
+
repo,
|
|
663
|
+
content: Buffer.from(content).toString("base64"),
|
|
664
|
+
encoding: "base64"
|
|
665
|
+
})).data.sha
|
|
666
|
+
}],
|
|
667
|
+
commitMessage
|
|
668
|
+
});
|
|
669
|
+
}
|
|
661
670
|
async function commitFileChanges({ githubClient, owner, repo, fileContent, filePath, branchName, operations, commitMessage }) {
|
|
662
671
|
try {
|
|
663
672
|
return await commitContent({
|
|
@@ -688,6 +697,33 @@ async function commitNewFile({ githubClient, owner, repo, filePath, branchName,
|
|
|
688
697
|
throw new Error(`Failed to commit new file: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
689
698
|
}
|
|
690
699
|
}
|
|
700
|
+
async function moveFile({ githubClient, owner, repo, sourcePath, destinationPath, branchName, commitMessage }) {
|
|
701
|
+
const fileResponse = await githubClient.rest.repos.getContent({
|
|
702
|
+
owner,
|
|
703
|
+
repo,
|
|
704
|
+
path: sourcePath,
|
|
705
|
+
ref: branchName
|
|
706
|
+
});
|
|
707
|
+
if (!("sha" in fileResponse.data) || Array.isArray(fileResponse.data)) throw new Error(`Source path "${sourcePath}" is not a file`);
|
|
708
|
+
return commitTreeEntries({
|
|
709
|
+
githubClient,
|
|
710
|
+
owner,
|
|
711
|
+
repo,
|
|
712
|
+
branchName,
|
|
713
|
+
treeEntries: [{
|
|
714
|
+
path: destinationPath,
|
|
715
|
+
mode: "100644",
|
|
716
|
+
type: "blob",
|
|
717
|
+
sha: fileResponse.data.sha
|
|
718
|
+
}, {
|
|
719
|
+
path: sourcePath,
|
|
720
|
+
mode: "100644",
|
|
721
|
+
type: "blob",
|
|
722
|
+
sha: null
|
|
723
|
+
}],
|
|
724
|
+
commitMessage
|
|
725
|
+
});
|
|
726
|
+
}
|
|
691
727
|
async function createIssueCommentReaction(octokit, owner, repo, commentId, content) {
|
|
692
728
|
const { data } = await octokit.rest.reactions.createForIssueComment({
|
|
693
729
|
owner,
|
|
@@ -795,4 +831,4 @@ async function formatFileDiff(pullRequestNumber, files, includeContents = false)
|
|
|
795
831
|
}
|
|
796
832
|
|
|
797
833
|
//#endregion
|
|
798
|
-
export { applyOperation, applyOperations, commitFileChanges, commitNewFile, createIssueCommentReaction, createPullRequestReviewCommentReaction, deleteIssueCommentReaction, deletePullRequestReviewCommentReaction, fetchBranchChangedFiles, fetchComments, fetchCommitDetails, fetchPrCommits, fetchPrFileDiffs, fetchPrFiles, fetchPrInfo, formatFileDiff, generatePrMarkdown, getFilePathsInRepo, getGitHubClientFromInstallationId, getGitHubClientFromRepo, listIssueCommentReactions, listIssueReactions, listPullRequestReviewCommentReactions, validateLineNumbers, visualizeUpdateOperations };
|
|
834
|
+
export { applyOperation, applyOperations, commitFileChanges, commitNewFile, createIssueCommentReaction, createPullRequestReviewCommentReaction, deleteIssueCommentReaction, deletePullRequestReviewCommentReaction, fetchBranchChangedFiles, fetchComments, fetchCommitDetails, fetchPrCommits, fetchPrFileDiffs, fetchPrFiles, fetchPrInfo, formatFileDiff, generatePrMarkdown, getFilePathsInRepo, getGitHubClientFromInstallationId, getGitHubClientFromRepo, listIssueCommentReactions, listIssueReactions, listPullRequestReviewCommentReactions, moveFile, validateLineNumbers, visualizeUpdateOperations };
|
|
@@ -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_types2 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_types2.BlankEnv, hono_types2.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getLogger } from "../../logger.js";
|
|
2
2
|
import runDbClient_default from "../../db/runDbClient.js";
|
|
3
3
|
import { clearWorkspaceConnectionCache, computeWorkspaceConnectionId, deleteWorkspaceInstallation, findWorkspaceConnectionByTeamId, getWorkspaceDefaultAgentFromNango, listWorkspaceInstallations, setWorkspaceDefaultAgent } from "../services/nango.js";
|
|
4
|
-
import { getSlackChannels, getSlackClient, revokeSlackToken } from "../services/client.js";
|
|
4
|
+
import { getBotMemberChannels, getSlackChannels, getSlackClient, revokeSlackToken } from "../services/client.js";
|
|
5
5
|
import "../services/index.js";
|
|
6
6
|
import { requireChannelMemberOrAdmin, requireWorkspaceAdmin } from "../middleware/permissions.js";
|
|
7
7
|
import { OpenAPIHono, z } from "@hono/zod-openapi";
|
|
@@ -380,7 +380,7 @@ app.openapi(createProtectedRoute({
|
|
|
380
380
|
method: "get",
|
|
381
381
|
path: "/{teamId}/channels",
|
|
382
382
|
summary: "List Channels",
|
|
383
|
-
description: "List Slack channels
|
|
383
|
+
description: "List Slack channels where the bot is a member",
|
|
384
384
|
operationId: "slack-list-channels",
|
|
385
385
|
tags: [
|
|
386
386
|
"Work Apps",
|
|
@@ -422,7 +422,7 @@ app.openapi(createProtectedRoute({
|
|
|
422
422
|
const tenantId = workspace.tenantId;
|
|
423
423
|
const slackClient = getSlackClient(workspace.botToken);
|
|
424
424
|
try {
|
|
425
|
-
const channels = await
|
|
425
|
+
const channels = await getBotMemberChannels(slackClient, limit);
|
|
426
426
|
let channelConfigs = [];
|
|
427
427
|
try {
|
|
428
428
|
channelConfigs = await listWorkAppSlackChannelAgentConfigsByTeam(runDbClient_default)(tenantId, teamId);
|
|
@@ -77,6 +77,26 @@ declare function getSlackChannels(client: WebClient, limit?: number): Promise<{
|
|
|
77
77
|
isPrivate: boolean;
|
|
78
78
|
isShared: boolean;
|
|
79
79
|
}[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Fetch only channels where the bot is a member using the `users.conversations` API.
|
|
82
|
+
*
|
|
83
|
+
* Compared to `getSlackChannels()` (which uses `conversations.list` and returns ALL visible channels),
|
|
84
|
+
* this function returns only channels the bot has been added to. It uses Tier 3 rate limits (50+ req/min)
|
|
85
|
+
* and supports up to 999 items per page, making it significantly more efficient for large workspaces.
|
|
86
|
+
*
|
|
87
|
+
* Use this for the Channel Defaults UI. Keep `getSlackChannels()` for other purposes (e.g., health checks).
|
|
88
|
+
*
|
|
89
|
+
* @param client - Authenticated Slack WebClient
|
|
90
|
+
* @param limit - Maximum number of channels to return. Fetches in pages of up to 999 until the limit is reached or all channels are returned.
|
|
91
|
+
* @returns Array of channel objects with id, name, member count, and privacy status
|
|
92
|
+
*/
|
|
93
|
+
declare function getBotMemberChannels(client: WebClient, limit?: number): Promise<{
|
|
94
|
+
id: string | undefined;
|
|
95
|
+
name: string | undefined;
|
|
96
|
+
memberCount: number | undefined;
|
|
97
|
+
isPrivate: boolean;
|
|
98
|
+
isShared: boolean;
|
|
99
|
+
}[]>;
|
|
80
100
|
/**
|
|
81
101
|
* Post a message to a Slack channel.
|
|
82
102
|
*
|
|
@@ -121,4 +141,4 @@ declare function checkUserIsChannelMember(client: WebClient, channelId: string,
|
|
|
121
141
|
*/
|
|
122
142
|
declare function revokeSlackToken(token: string): Promise<boolean>;
|
|
123
143
|
//#endregion
|
|
124
|
-
export { checkUserIsChannelMember, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackTeamInfo, getSlackUserInfo, postMessage, postMessageInThread, revokeSlackToken };
|
|
144
|
+
export { checkUserIsChannelMember, getBotMemberChannels, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackTeamInfo, getSlackUserInfo, postMessage, postMessageInThread, revokeSlackToken };
|
|
@@ -146,6 +146,48 @@ async function getSlackChannels(client, limit = 200) {
|
|
|
146
146
|
limit
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
+
function safeNumMembers(ch) {
|
|
150
|
+
const record = ch;
|
|
151
|
+
return typeof record.num_members === "number" ? record.num_members : void 0;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Fetch only channels where the bot is a member using the `users.conversations` API.
|
|
155
|
+
*
|
|
156
|
+
* Compared to `getSlackChannels()` (which uses `conversations.list` and returns ALL visible channels),
|
|
157
|
+
* this function returns only channels the bot has been added to. It uses Tier 3 rate limits (50+ req/min)
|
|
158
|
+
* and supports up to 999 items per page, making it significantly more efficient for large workspaces.
|
|
159
|
+
*
|
|
160
|
+
* Use this for the Channel Defaults UI. Keep `getSlackChannels()` for other purposes (e.g., health checks).
|
|
161
|
+
*
|
|
162
|
+
* @param client - Authenticated Slack WebClient
|
|
163
|
+
* @param limit - Maximum number of channels to return. Fetches in pages of up to 999 until the limit is reached or all channels are returned.
|
|
164
|
+
* @returns Array of channel objects with id, name, member count, and privacy status
|
|
165
|
+
*/
|
|
166
|
+
async function getBotMemberChannels(client, limit = 999) {
|
|
167
|
+
return paginateSlack({
|
|
168
|
+
fetchPage: (cursor) => client.users.conversations({
|
|
169
|
+
types: "public_channel,private_channel",
|
|
170
|
+
exclude_archived: true,
|
|
171
|
+
limit: Math.min(limit, 999),
|
|
172
|
+
cursor
|
|
173
|
+
}),
|
|
174
|
+
extractItems: (result) => {
|
|
175
|
+
if (!result.ok) {
|
|
176
|
+
logger.warn({ error: result.error }, "Slack API returned ok: false during bot member channel pagination");
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
return result.channels ? result.channels.map((ch) => ({
|
|
180
|
+
id: ch.id,
|
|
181
|
+
name: ch.name,
|
|
182
|
+
memberCount: safeNumMembers(ch),
|
|
183
|
+
isPrivate: ch.is_private ?? false,
|
|
184
|
+
isShared: ch.is_shared ?? ch.is_ext_shared ?? false
|
|
185
|
+
})) : [];
|
|
186
|
+
},
|
|
187
|
+
getNextCursor: (result) => result.response_metadata?.next_cursor || void 0,
|
|
188
|
+
limit
|
|
189
|
+
});
|
|
190
|
+
}
|
|
149
191
|
/**
|
|
150
192
|
* Post a message to a Slack channel.
|
|
151
193
|
*
|
|
@@ -257,4 +299,4 @@ async function revokeSlackToken(token) {
|
|
|
257
299
|
}
|
|
258
300
|
|
|
259
301
|
//#endregion
|
|
260
|
-
export { checkUserIsChannelMember, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackTeamInfo, getSlackUserInfo, postMessage, postMessageInThread, revokeSlackToken };
|
|
302
|
+
export { checkUserIsChannelMember, getBotMemberChannels, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackTeamInfo, getSlackUserInfo, postMessage, postMessageInThread, revokeSlackToken };
|
|
@@ -217,6 +217,7 @@ async function streamAgentResponse(params) {
|
|
|
217
217
|
const toolCallIdToName = /* @__PURE__ */ new Map();
|
|
218
218
|
const toolCallIdToInput = /* @__PURE__ */ new Map();
|
|
219
219
|
const toolErrors = [];
|
|
220
|
+
const successfulToolNames = /* @__PURE__ */ new Set();
|
|
220
221
|
const citations = [];
|
|
221
222
|
const summaryLabels = [];
|
|
222
223
|
let richMessageCount = 0;
|
|
@@ -299,6 +300,11 @@ async function streamAgentResponse(params) {
|
|
|
299
300
|
});
|
|
300
301
|
continue;
|
|
301
302
|
}
|
|
303
|
+
if (data.type === "tool-output-available" && data.toolCallId) {
|
|
304
|
+
const toolName = toolCallIdToName.get(String(data.toolCallId));
|
|
305
|
+
if (toolName) successfulToolNames.add(toolName);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
302
308
|
if (data.type === "data-component" && data.data && typeof data.data === "object") {
|
|
303
309
|
if (richMessageCount < MAX_RICH_MESSAGES) {
|
|
304
310
|
const { blocks, overflowJson, componentType } = buildDataComponentBlocks({
|
|
@@ -405,7 +411,10 @@ async function streamAgentResponse(params) {
|
|
|
405
411
|
}
|
|
406
412
|
clearTimeout(timeoutId);
|
|
407
413
|
const stopBlocks = [];
|
|
408
|
-
for (const { toolName, errorText } of toolErrors)
|
|
414
|
+
for (const { toolName, errorText } of toolErrors) {
|
|
415
|
+
if (successfulToolNames.has(toolName)) continue;
|
|
416
|
+
stopBlocks.push(buildToolOutputErrorBlock(toolName, errorText));
|
|
417
|
+
}
|
|
409
418
|
if (summaryLabels.length > 0) stopBlocks.push(buildSummaryBreadcrumbBlock(summaryLabels));
|
|
410
419
|
if (citations.length > 0) {
|
|
411
420
|
const citationBlocks = buildCitationsBlock(citations);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgentResolutionParams, ResolvedAgentConfig, getAgentConfigSources, resolveEffectiveAgent } from "./agent-resolution.js";
|
|
2
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";
|
|
3
|
-
import { checkUserIsChannelMember, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackTeamInfo, getSlackUserInfo, postMessage, postMessageInThread, revokeSlackToken } from "./client.js";
|
|
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";
|
|
6
6
|
import { handleAgentPickerCommand, handleCommand, handleHelpCommand, handleLinkCommand, handleQuestionCommand, handleStatusCommand, handleUnlinkCommand } from "./commands/index.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, 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, 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 };
|
|
@@ -2,7 +2,7 @@ import { clearWorkspaceConnectionCache, computeWorkspaceConnectionId, createConn
|
|
|
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
4
|
import { ToolApprovalButtonValueSchema, buildCitationsBlock, buildDataArtifactBlocks, buildDataComponentBlocks, buildSummaryBreadcrumbBlock, buildToolApprovalBlocks, buildToolApprovalDoneBlocks, buildToolApprovalExpiredBlocks, buildToolOutputErrorBlock, createAlreadyLinkedMessage, createContextBlock, createCreateInkeepAccountMessage, createErrorMessage, createNotLinkedMessage, createSmartLinkMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage } from "./blocks/index.js";
|
|
5
|
-
import { checkUserIsChannelMember, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackTeamInfo, getSlackUserInfo, postMessage, postMessageInThread, revokeSlackToken } from "./client.js";
|
|
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";
|
|
8
8
|
import { buildAgentSelectorModal, buildMessageShortcutModal } from "./modals.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, 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, 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 };
|
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.5",
|
|
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.1.1",
|
|
35
35
|
"slack-block-builder": "^2.8.0",
|
|
36
|
-
"@inkeep/agents-core": "0.53.
|
|
36
|
+
"@inkeep/agents-core": "0.53.5"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@hono/zod-openapi": "^1.1.5",
|