@inkeep/agents-work-apps 0.0.0-dev-20260219165156 → 0.0.0-dev-20260219204727
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/mcp/auth.d.ts +2 -2
- package/dist/github/mcp/index.d.ts +2 -2
- package/dist/github/mcp/schemas.d.ts +1 -1
- package/dist/github/routes/setup.d.ts +2 -2
- package/dist/github/routes/setup.js +1 -1
- package/dist/github/routes/tokenExchange.d.ts +2 -2
- package/dist/github/routes/tokenExchange.js +1 -1
- package/dist/github/routes/webhooks.js +1 -1
- package/dist/slack/index.js +1 -1
- package/dist/slack/services/dev-config.d.ts +23 -0
- package/dist/slack/services/dev-config.js +91 -0
- package/dist/slack/services/events/app-mention.js +2 -4
- package/dist/slack/services/events/utils.d.ts +1 -1
- package/dist/slack/services/index.js +1 -1
- package/dist/slack/services/nango.d.ts +2 -0
- package/dist/slack/services/nango.js +84 -2
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono1 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/github/mcp/auth.d.ts
|
|
4
|
-
declare const githubMcpAuth: () =>
|
|
4
|
+
declare const githubMcpAuth: () => hono1.MiddlewareHandler<{
|
|
5
5
|
Variables: {
|
|
6
6
|
toolId: string;
|
|
7
7
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types5 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_types5.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_types6 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_types6.BlankEnv, hono_types6.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { env } from "../../env.js";
|
|
2
2
|
import { getLogger } from "../../logger.js";
|
|
3
|
-
import { getStateSigningSecret, isStateSigningConfigured } from "../config.js";
|
|
4
3
|
import runDbClient_default from "../../db/runDbClient.js";
|
|
4
|
+
import { getStateSigningSecret, isStateSigningConfigured } from "../config.js";
|
|
5
5
|
import { createAppJwt, determineStatus, fetchInstallationDetails, fetchInstallationRepositories } from "../installation.js";
|
|
6
6
|
import { createInstallation, generateId, getInstallationByGitHubId, listProjectsMetadata, setProjectAccessMode, syncRepositories, updateInstallationStatusByGitHubId } from "@inkeep/agents-core";
|
|
7
7
|
import { Hono } from "hono";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types3 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_types3.BlankEnv, hono_types3.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getLogger } from "../../logger.js";
|
|
2
|
-
import { isGitHubAppConfigured } from "../config.js";
|
|
3
2
|
import runDbClient_default from "../../db/runDbClient.js";
|
|
3
|
+
import { isGitHubAppConfigured } from "../config.js";
|
|
4
4
|
import { generateInstallationAccessToken, lookupInstallationForRepo } from "../installation.js";
|
|
5
5
|
import { validateOidcToken } from "../oidcToken.js";
|
|
6
6
|
import { checkProjectRepositoryAccess, getInstallationByGitHubId } from "@inkeep/agents-core";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getLogger } from "../../logger.js";
|
|
2
|
-
import { getWebhookSecret, isWebhookConfigured } from "../config.js";
|
|
3
2
|
import runDbClient_default from "../../db/runDbClient.js";
|
|
3
|
+
import { getWebhookSecret, isWebhookConfigured } from "../config.js";
|
|
4
4
|
import { addRepositories, deleteInstallation, getInstallationByGitHubId, removeRepositories, updateInstallationStatusByGitHubId } from "@inkeep/agents-core";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
6
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
package/dist/slack/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clearWorkspaceConnectionCache, computeWorkspaceConnectionId, createConnectSession, deleteWorkspaceInstallation, findWorkspaceConnectionByTeamId, getConnectionAccessToken, getSlackIntegrationId, getSlackNango, getWorkspaceDefaultAgentFromNango, listWorkspaceInstallations, setWorkspaceDefaultAgent, storeWorkspaceInstallation, updateConnectionMetadata } from "./services/nango.js";
|
|
2
2
|
import { getChannelAgentConfig, getWorkspaceDefaultAgent } from "./services/events/utils.js";
|
|
3
|
-
import { getBotTokenForTeam, setBotTokenForTeam } from "./services/workspace-tokens.js";
|
|
4
3
|
import "./services/events/index.js";
|
|
4
|
+
import { getBotTokenForTeam, setBotTokenForTeam } from "./services/workspace-tokens.js";
|
|
5
5
|
import { dispatchSlackEvent } from "./dispatcher.js";
|
|
6
6
|
import "./routes/oauth.js";
|
|
7
7
|
import routes_default from "./routes/index.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DefaultAgentConfig } from "./nango.js";
|
|
2
|
+
|
|
3
|
+
//#region src/slack/services/dev-config.d.ts
|
|
4
|
+
interface SlackDevConfig {
|
|
5
|
+
devId: string;
|
|
6
|
+
appId: string;
|
|
7
|
+
clientId: string;
|
|
8
|
+
clientSecret: string;
|
|
9
|
+
signingSecret: string;
|
|
10
|
+
appToken: string;
|
|
11
|
+
botToken: string;
|
|
12
|
+
teamId: string;
|
|
13
|
+
teamName: string;
|
|
14
|
+
configRefreshToken?: string;
|
|
15
|
+
metadata?: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
declare function isSlackDevMode(): boolean;
|
|
18
|
+
declare function loadSlackDevConfig(): SlackDevConfig | null;
|
|
19
|
+
declare function getDevDefaultAgent(config: SlackDevConfig | null): DefaultAgentConfig | null;
|
|
20
|
+
declare function resetDevConfigCache(): void;
|
|
21
|
+
declare function saveSlackDevConfig(config: SlackDevConfig): boolean;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SlackDevConfig, getDevDefaultAgent, isSlackDevMode, loadSlackDevConfig, resetDevConfigCache, saveSlackDevConfig };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { env } from "../../env.js";
|
|
2
|
+
import { getLogger } from "../../logger.js";
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join, parse } from "node:path";
|
|
5
|
+
|
|
6
|
+
//#region src/slack/services/dev-config.ts
|
|
7
|
+
const logger = getLogger("slack-dev-config");
|
|
8
|
+
const DEV_CONFIG_FILENAME = ".slack-dev.json";
|
|
9
|
+
const CACHE_TTL_MS = 5e3;
|
|
10
|
+
let cachedConfig = null;
|
|
11
|
+
let cacheExpiresAt = 0;
|
|
12
|
+
let resolvedConfigPath;
|
|
13
|
+
function findDevConfigPath() {
|
|
14
|
+
let dir = process.cwd();
|
|
15
|
+
while (true) {
|
|
16
|
+
const candidate = join(dir, DEV_CONFIG_FILENAME);
|
|
17
|
+
if (existsSync(candidate)) return candidate;
|
|
18
|
+
const parent = dirname(dir);
|
|
19
|
+
if (parent === dir || parse(dir).root === dir) break;
|
|
20
|
+
dir = parent;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function getDevConfigPath() {
|
|
25
|
+
if (resolvedConfigPath !== void 0) return resolvedConfigPath;
|
|
26
|
+
resolvedConfigPath = findDevConfigPath();
|
|
27
|
+
return resolvedConfigPath;
|
|
28
|
+
}
|
|
29
|
+
let devModeChecked = false;
|
|
30
|
+
let devModeResult = false;
|
|
31
|
+
function isSlackDevMode() {
|
|
32
|
+
if (devModeChecked) return devModeResult;
|
|
33
|
+
devModeResult = env.ENVIRONMENT === "development" && getDevConfigPath() !== null;
|
|
34
|
+
devModeChecked = true;
|
|
35
|
+
return devModeResult;
|
|
36
|
+
}
|
|
37
|
+
function loadSlackDevConfig() {
|
|
38
|
+
if (cachedConfig && Date.now() < cacheExpiresAt) return cachedConfig;
|
|
39
|
+
const configPath = getDevConfigPath();
|
|
40
|
+
if (!configPath) return null;
|
|
41
|
+
try {
|
|
42
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
43
|
+
cachedConfig = JSON.parse(raw);
|
|
44
|
+
cacheExpiresAt = Date.now() + CACHE_TTL_MS;
|
|
45
|
+
return cachedConfig;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
logger.error({
|
|
48
|
+
error,
|
|
49
|
+
configPath
|
|
50
|
+
}, "Failed to read .slack-dev.json");
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function getDevDefaultAgent(config) {
|
|
55
|
+
if (!config?.metadata?.default_agent) return null;
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse(config.metadata.default_agent);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
logger.warn({
|
|
60
|
+
error,
|
|
61
|
+
rawValue: config.metadata.default_agent
|
|
62
|
+
}, "Failed to parse default_agent metadata as JSON - check .slack-dev.json format");
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function resetDevConfigCache() {
|
|
67
|
+
cachedConfig = null;
|
|
68
|
+
cacheExpiresAt = 0;
|
|
69
|
+
resolvedConfigPath = void 0;
|
|
70
|
+
devModeChecked = false;
|
|
71
|
+
devModeResult = false;
|
|
72
|
+
}
|
|
73
|
+
function saveSlackDevConfig(config) {
|
|
74
|
+
const configPath = getDevConfigPath();
|
|
75
|
+
if (!configPath) return false;
|
|
76
|
+
try {
|
|
77
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
78
|
+
cachedConfig = config;
|
|
79
|
+
cacheExpiresAt = Date.now() + CACHE_TTL_MS;
|
|
80
|
+
return true;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
logger.error({
|
|
83
|
+
error,
|
|
84
|
+
configPath
|
|
85
|
+
}, "Failed to write .slack-dev.json");
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { getDevDefaultAgent, isSlackDevMode, loadSlackDevConfig, resetDevConfigCache, saveSlackDevConfig };
|
|
@@ -5,7 +5,6 @@ import { SlackStrings } from "../../i18n/strings.js";
|
|
|
5
5
|
import { getSlackChannelInfo, getSlackClient, getSlackUserInfo, postMessageInThread } from "../client.js";
|
|
6
6
|
import { checkIfBotThread, classifyError, findCachedUserMapping, formatChannelContext, generateSlackConversationId, getThreadContext, getUserFriendlyErrorMessage, resolveChannelAgentConfig, timedOp } from "./utils.js";
|
|
7
7
|
import { SLACK_SPAN_KEYS, SLACK_SPAN_NAMES, setSpanWithError, tracer } from "../../tracer.js";
|
|
8
|
-
import { getBotTokenForTeam } from "../workspace-tokens.js";
|
|
9
8
|
import { streamAgentResponse } from "./streaming.js";
|
|
10
9
|
import { signSlackUserToken } from "@inkeep/agents-core";
|
|
11
10
|
|
|
@@ -60,13 +59,12 @@ async function handleAppMention(params) {
|
|
|
60
59
|
label: "workspace connection lookup",
|
|
61
60
|
context: { teamId }
|
|
62
61
|
});
|
|
63
|
-
|
|
64
|
-
if (!botToken) {
|
|
62
|
+
if (!workspaceConnection?.botToken) {
|
|
65
63
|
logger.error({ teamId }, "No bot token available — cannot respond to @mention");
|
|
66
64
|
span.end();
|
|
67
65
|
return;
|
|
68
66
|
}
|
|
69
|
-
const tenantId = workspaceConnection
|
|
67
|
+
const { botToken, tenantId } = workspaceConnection;
|
|
70
68
|
if (!tenantId) {
|
|
71
69
|
logger.error({ teamId }, "Workspace connection has no tenantId — workspace may need reinstall");
|
|
72
70
|
await getSlackClient(botToken).chat.postEphemeral({
|
|
@@ -8,9 +8,9 @@ import { AgentOption } from "../modals.js";
|
|
|
8
8
|
* Called on every @mention and /inkeep command — caching avoids redundant DB queries.
|
|
9
9
|
*/
|
|
10
10
|
declare function findCachedUserMapping(tenantId: string, slackUserId: string, teamId: string, clientId?: string): Promise<{
|
|
11
|
-
id: string;
|
|
12
11
|
createdAt: string;
|
|
13
12
|
updatedAt: string;
|
|
13
|
+
id: string;
|
|
14
14
|
tenantId: string;
|
|
15
15
|
clientId: string;
|
|
16
16
|
slackUserId: string;
|
|
@@ -5,12 +5,12 @@ import { checkUserIsChannelMember, getSlackChannelInfo, getSlackChannels, getSla
|
|
|
5
5
|
import { SlackErrorType, checkIfBotThread, classifyError, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, generateSlackConversationId, getChannelAgentConfig, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, markdownToMrkdwn, sendResponseUrlMessage } from "./events/utils.js";
|
|
6
6
|
import { buildAgentSelectorModal, buildFollowUpModal, buildMessageShortcutModal } from "./modals.js";
|
|
7
7
|
import { handleAgentPickerCommand, handleCommand, handleHelpCommand, handleLinkCommand, handleQuestionCommand, handleStatusCommand, handleUnlinkCommand } from "./commands/index.js";
|
|
8
|
-
import { getBotTokenForTeam, setBotTokenForTeam } from "./workspace-tokens.js";
|
|
9
8
|
import { streamAgentResponse } from "./events/streaming.js";
|
|
10
9
|
import { handleAppMention } from "./events/app-mention.js";
|
|
11
10
|
import { handleMessageShortcut, handleOpenAgentSelectorModal, handleOpenFollowUpModal } from "./events/block-actions.js";
|
|
12
11
|
import { handleFollowUpSubmission, handleModalSubmission } from "./events/modal-submission.js";
|
|
13
12
|
import "./events/index.js";
|
|
14
13
|
import { parseSlackCommandBody, parseSlackEventBody, verifySlackRequest } from "./security.js";
|
|
14
|
+
import { getBotTokenForTeam, setBotTokenForTeam } from "./workspace-tokens.js";
|
|
15
15
|
|
|
16
16
|
export { SlackErrorType, buildAgentSelectorModal, buildConversationResponseBlocks, buildFollowUpButton, buildFollowUpModal, buildMessageShortcutModal, checkIfBotThread, checkUserIsChannelMember, classifyError, clearWorkspaceConnectionCache, computeWorkspaceConnectionId, createAlreadyLinkedMessage, createConnectSession, createContextBlock, createErrorMessage, createJwtLinkMessage, createNotLinkedMessage, createStatusMessage, createUnlinkSuccessMessage, createUpdatedHelpMessage, deleteWorkspaceInstallation, fetchAgentsForProject, fetchProjectsForTenant, findCachedUserMapping, findWorkspaceConnectionByTeamId, generateSlackConversationId, getAgentConfigSources, getBotTokenForTeam, getChannelAgentConfig, getConnectionAccessToken, getSlackChannelInfo, getSlackChannels, getSlackClient, getSlackIntegrationId, getSlackNango, getSlackTeamInfo, getSlackUserInfo, getThreadContext, getUserFriendlyErrorMessage, getWorkspaceDefaultAgent, getWorkspaceDefaultAgentFromNango, handleAgentPickerCommand, handleAppMention, handleCommand, handleFollowUpSubmission, handleHelpCommand, handleLinkCommand, handleMessageShortcut, handleModalSubmission, handleOpenAgentSelectorModal, handleOpenFollowUpModal, handleQuestionCommand, handleStatusCommand, handleUnlinkCommand, listWorkspaceInstallations, markdownToMrkdwn, parseSlackCommandBody, parseSlackEventBody, postMessage, postMessageInThread, resolveEffectiveAgent, revokeSlackToken, sendResponseUrlMessage, setBotTokenForTeam, setWorkspaceDefaultAgent, storeWorkspaceInstallation, streamAgentResponse, updateConnectionMetadata, verifySlackRequest };
|
|
@@ -30,6 +30,8 @@ interface SlackWorkspaceConnection {
|
|
|
30
30
|
/**
|
|
31
31
|
* Find a workspace connection by Slack team ID.
|
|
32
32
|
* Uses PostgreSQL first (O(1)) with in-memory caching, then falls back to Nango.
|
|
33
|
+
* In development mode with .slack-dev.json present, returns a local connection
|
|
34
|
+
* built from the dev config file instead of hitting Nango.
|
|
33
35
|
*
|
|
34
36
|
* Performance: This function is called on every @mention and command.
|
|
35
37
|
* The PostgreSQL-first approach with caching provides O(1) lookups.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { env } from "../../env.js";
|
|
2
2
|
import { getLogger } from "../../logger.js";
|
|
3
3
|
import runDbClient_default from "../../db/runDbClient.js";
|
|
4
|
+
import { getDevDefaultAgent, isSlackDevMode, loadSlackDevConfig, saveSlackDevConfig } from "./dev-config.js";
|
|
4
5
|
import { findWorkAppSlackWorkspaceBySlackTeamId } from "@inkeep/agents-core";
|
|
5
6
|
import { Nango } from "@nangohq/node";
|
|
6
7
|
|
|
@@ -78,6 +79,10 @@ function getSlackIntegrationId() {
|
|
|
78
79
|
return env.NANGO_SLACK_INTEGRATION_ID || "slack-agent";
|
|
79
80
|
}
|
|
80
81
|
async function createConnectSession(params) {
|
|
82
|
+
if (isSlackDevMode()) {
|
|
83
|
+
logger.debug({}, "Skipping Nango connect session in dev mode");
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
81
86
|
try {
|
|
82
87
|
const nango = getSlackNango();
|
|
83
88
|
const integrationId = getSlackIntegrationId();
|
|
@@ -105,6 +110,7 @@ async function createConnectSession(params) {
|
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
112
|
async function getConnectionAccessToken(connectionId) {
|
|
113
|
+
if (isSlackDevMode()) return loadSlackDevConfig()?.botToken ?? null;
|
|
108
114
|
try {
|
|
109
115
|
const nango = getSlackNango();
|
|
110
116
|
const integrationId = getSlackIntegrationId();
|
|
@@ -117,9 +123,27 @@ async function getConnectionAccessToken(connectionId) {
|
|
|
117
123
|
return null;
|
|
118
124
|
}
|
|
119
125
|
}
|
|
126
|
+
function buildDevWorkspaceConnection(devConfig, teamId) {
|
|
127
|
+
const connection = {
|
|
128
|
+
connectionId: `dev:${teamId}`,
|
|
129
|
+
teamId,
|
|
130
|
+
teamName: devConfig.teamName || "dev",
|
|
131
|
+
botToken: devConfig.botToken,
|
|
132
|
+
tenantId: "default",
|
|
133
|
+
defaultAgent: getDevDefaultAgent(devConfig) ?? void 0
|
|
134
|
+
};
|
|
135
|
+
evictWorkspaceCache();
|
|
136
|
+
workspaceConnectionCache.set(teamId, {
|
|
137
|
+
connection,
|
|
138
|
+
expiresAt: Date.now() + CACHE_TTL_MS
|
|
139
|
+
});
|
|
140
|
+
return connection;
|
|
141
|
+
}
|
|
120
142
|
/**
|
|
121
143
|
* Find a workspace connection by Slack team ID.
|
|
122
144
|
* Uses PostgreSQL first (O(1)) with in-memory caching, then falls back to Nango.
|
|
145
|
+
* In development mode with .slack-dev.json present, returns a local connection
|
|
146
|
+
* built from the dev config file instead of hitting Nango.
|
|
123
147
|
*
|
|
124
148
|
* Performance: This function is called on every @mention and command.
|
|
125
149
|
* The PostgreSQL-first approach with caching provides O(1) lookups.
|
|
@@ -130,6 +154,15 @@ async function findWorkspaceConnectionByTeamId(teamId) {
|
|
|
130
154
|
logger.debug({ teamId }, "Workspace connection cache hit");
|
|
131
155
|
return cached.connection;
|
|
132
156
|
}
|
|
157
|
+
if (isSlackDevMode()) {
|
|
158
|
+
const devConfig = loadSlackDevConfig();
|
|
159
|
+
if (devConfig) {
|
|
160
|
+
logger.debug({ teamId }, "Using .slack-dev.json for workspace connection");
|
|
161
|
+
return buildDevWorkspaceConnection(devConfig, teamId);
|
|
162
|
+
}
|
|
163
|
+
logger.debug({ teamId }, "No .slack-dev.json found returning null");
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
133
166
|
try {
|
|
134
167
|
const dbWorkspace = await findWorkAppSlackWorkspaceBySlackTeamId(runDbClient_default)(teamId);
|
|
135
168
|
if (dbWorkspace?.nangoConnectionId) {
|
|
@@ -155,7 +188,7 @@ async function findWorkspaceConnectionByTeamId(teamId) {
|
|
|
155
188
|
}
|
|
156
189
|
}
|
|
157
190
|
logger.debug({ teamId }, "PostgreSQL lookup failed, falling back to Nango iteration");
|
|
158
|
-
return findWorkspaceConnectionByTeamIdFromNango(teamId);
|
|
191
|
+
return await findWorkspaceConnectionByTeamIdFromNango(teamId);
|
|
159
192
|
} catch (error) {
|
|
160
193
|
logger.error({
|
|
161
194
|
error,
|
|
@@ -165,6 +198,7 @@ async function findWorkspaceConnectionByTeamId(teamId) {
|
|
|
165
198
|
}
|
|
166
199
|
}
|
|
167
200
|
async function getWorkspaceDefaultAgentFromNangoByConnectionId(connectionId) {
|
|
201
|
+
if (isSlackDevMode()) return getDevDefaultAgent(loadSlackDevConfig());
|
|
168
202
|
try {
|
|
169
203
|
const nango = getSlackNango();
|
|
170
204
|
const integrationId = getSlackIntegrationId();
|
|
@@ -234,10 +268,23 @@ function clearWorkspaceConnectionCache(teamId) {
|
|
|
234
268
|
else workspaceConnectionCache.clear();
|
|
235
269
|
}
|
|
236
270
|
async function updateConnectionMetadata(connectionId, metadata) {
|
|
271
|
+
if (isSlackDevMode()) {
|
|
272
|
+
const devConfig = loadSlackDevConfig();
|
|
273
|
+
if (!devConfig) return false;
|
|
274
|
+
devConfig.metadata = {
|
|
275
|
+
...devConfig.metadata,
|
|
276
|
+
...metadata
|
|
277
|
+
};
|
|
278
|
+
return saveSlackDevConfig(devConfig);
|
|
279
|
+
}
|
|
237
280
|
try {
|
|
238
281
|
const nango = getSlackNango();
|
|
239
282
|
const integrationId = getSlackIntegrationId();
|
|
240
|
-
|
|
283
|
+
const lastUpdatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
284
|
+
await nango.updateMetadata(integrationId, connectionId, {
|
|
285
|
+
...metadata,
|
|
286
|
+
last_updated_at: lastUpdatedAt
|
|
287
|
+
});
|
|
241
288
|
return true;
|
|
242
289
|
} catch (error) {
|
|
243
290
|
logger.error({
|
|
@@ -248,6 +295,17 @@ async function updateConnectionMetadata(connectionId, metadata) {
|
|
|
248
295
|
}
|
|
249
296
|
}
|
|
250
297
|
async function setWorkspaceDefaultAgent(teamId, defaultAgent) {
|
|
298
|
+
if (isSlackDevMode()) {
|
|
299
|
+
const devConfig = loadSlackDevConfig();
|
|
300
|
+
if (!devConfig) return false;
|
|
301
|
+
devConfig.metadata = {
|
|
302
|
+
...devConfig.metadata,
|
|
303
|
+
default_agent: defaultAgent ? JSON.stringify(defaultAgent) : ""
|
|
304
|
+
};
|
|
305
|
+
const saved = saveSlackDevConfig(devConfig);
|
|
306
|
+
if (saved) clearWorkspaceConnectionCache(teamId);
|
|
307
|
+
return saved;
|
|
308
|
+
}
|
|
251
309
|
try {
|
|
252
310
|
const workspace = await findWorkspaceConnectionByTeamId(teamId);
|
|
253
311
|
if (!workspace) {
|
|
@@ -266,6 +324,7 @@ async function setWorkspaceDefaultAgent(teamId, defaultAgent) {
|
|
|
266
324
|
}
|
|
267
325
|
}
|
|
268
326
|
async function getWorkspaceDefaultAgentFromNango(teamId) {
|
|
327
|
+
if (isSlackDevMode()) return getDevDefaultAgent(loadSlackDevConfig());
|
|
269
328
|
try {
|
|
270
329
|
return (await findWorkspaceConnectionByTeamId(teamId))?.defaultAgent || null;
|
|
271
330
|
} catch (error) {
|
|
@@ -294,6 +353,13 @@ async function storeWorkspaceInstallation(data) {
|
|
|
294
353
|
teamId: data.teamId,
|
|
295
354
|
enterpriseId: data.enterpriseId
|
|
296
355
|
});
|
|
356
|
+
if (isSlackDevMode()) {
|
|
357
|
+
logger.debug({ connectionId }, "Skipping Nango store in dev mode");
|
|
358
|
+
return {
|
|
359
|
+
connectionId: `dev:${data.teamId}`,
|
|
360
|
+
success: true
|
|
361
|
+
};
|
|
362
|
+
}
|
|
297
363
|
try {
|
|
298
364
|
const integrationId = getSlackIntegrationId();
|
|
299
365
|
const secretKey = env.NANGO_SLACK_SECRET_KEY || env.NANGO_SECRET_KEY;
|
|
@@ -406,6 +472,18 @@ async function storeWorkspaceInstallation(data) {
|
|
|
406
472
|
* List all workspace installations from Nango.
|
|
407
473
|
*/
|
|
408
474
|
async function listWorkspaceInstallations() {
|
|
475
|
+
if (isSlackDevMode()) {
|
|
476
|
+
const devConfig = loadSlackDevConfig();
|
|
477
|
+
if (!devConfig) return [];
|
|
478
|
+
return [{
|
|
479
|
+
connectionId: `dev:${devConfig.teamId}`,
|
|
480
|
+
teamId: devConfig.teamId,
|
|
481
|
+
teamName: devConfig.teamName,
|
|
482
|
+
botToken: devConfig.botToken,
|
|
483
|
+
tenantId: "default",
|
|
484
|
+
defaultAgent: getDevDefaultAgent(devConfig) ?? void 0
|
|
485
|
+
}];
|
|
486
|
+
}
|
|
409
487
|
try {
|
|
410
488
|
const nango = getSlackNango();
|
|
411
489
|
const integrationId = getSlackIntegrationId();
|
|
@@ -445,6 +523,10 @@ async function listWorkspaceInstallations() {
|
|
|
445
523
|
* Delete a workspace installation from Nango.
|
|
446
524
|
*/
|
|
447
525
|
async function deleteWorkspaceInstallation(connectionId) {
|
|
526
|
+
if (isSlackDevMode()) {
|
|
527
|
+
logger.debug({ connectionId }, "Skipping Nango delete in dev mode");
|
|
528
|
+
return true;
|
|
529
|
+
}
|
|
448
530
|
try {
|
|
449
531
|
const nango = getSlackNango();
|
|
450
532
|
const integrationId = getSlackIntegrationId();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-work-apps",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20260219204727",
|
|
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.0.0-dev-
|
|
36
|
+
"@inkeep/agents-core": "0.0.0-dev-20260219204727"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@hono/zod-openapi": "^1.1.5",
|