@inkeep/agents-core 0.59.0 → 0.59.2

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.
Files changed (48) hide show
  1. package/dist/auth/auth-schema.d.ts +86 -86
  2. package/dist/auth/auth-validation-schemas.d.ts +154 -154
  3. package/dist/auth/auth.d.ts +6 -6
  4. package/dist/auth/permissions.d.ts +13 -13
  5. package/dist/client-exports.d.ts +2 -2
  6. package/dist/client-exports.js +2 -2
  7. package/dist/constants/{allowed-image-formats.d.ts → allowed-file-formats.d.ts} +4 -3
  8. package/dist/constants/{allowed-image-formats.js → allowed-file-formats.js} +13 -10
  9. package/dist/credential-stores/composio-store.d.ts +28 -0
  10. package/dist/credential-stores/composio-store.js +53 -0
  11. package/dist/credential-stores/default-constants.d.ts +2 -1
  12. package/dist/credential-stores/default-constants.js +2 -1
  13. package/dist/credential-stores/defaults.js +3 -1
  14. package/dist/credential-stores/index.d.ts +3 -2
  15. package/dist/credential-stores/index.js +3 -2
  16. package/dist/data-access/index.d.ts +2 -2
  17. package/dist/data-access/index.js +2 -2
  18. package/dist/data-access/manage/subAgentRelations.d.ts +6 -6
  19. package/dist/data-access/manage/tools.js +17 -5
  20. package/dist/data-access/manage/triggers.d.ts +2 -2
  21. package/dist/data-access/runtime/conversations.d.ts +7 -7
  22. package/dist/data-access/runtime/messages.d.ts +9 -9
  23. package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +16 -7
  24. package/dist/data-access/runtime/scheduledTriggerInvocations.js +13 -1
  25. package/dist/data-access/runtime/tasks.d.ts +3 -3
  26. package/dist/data-access/runtime/triggerInvocations.d.ts +1 -1
  27. package/dist/db/manage/manage-schema.d.ts +4 -4
  28. package/dist/db/runtime/runtime-schema.d.ts +18 -18
  29. package/dist/index.d.ts +5 -4
  30. package/dist/index.js +6 -5
  31. package/dist/middleware/no-auth.d.ts +2 -2
  32. package/dist/types/utility.d.ts +1 -0
  33. package/dist/types/utility.js +2 -1
  34. package/dist/utils/credential-store-utils.js +1 -0
  35. package/dist/utils/error.d.ts +51 -51
  36. package/dist/utils/index.d.ts +2 -2
  37. package/dist/utils/index.js +4 -4
  38. package/dist/utils/third-party-mcp-servers/composio-client.d.ts +20 -4
  39. package/dist/utils/third-party-mcp-servers/composio-client.js +51 -25
  40. package/dist/utils/third-party-mcp-servers/index.d.ts +2 -2
  41. package/dist/utils/third-party-mcp-servers/index.js +2 -2
  42. package/dist/utils/third-party-mcp-servers/third-party-check.d.ts +3 -4
  43. package/dist/utils/third-party-mcp-servers/third-party-check.js +1 -2
  44. package/dist/validation/dolt-schemas.d.ts +1 -1
  45. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  46. package/dist/validation/schemas.d.ts +1688 -1667
  47. package/dist/validation/schemas.js +3 -1
  48. package/package.json +4 -4
@@ -70,19 +70,21 @@ function getComposioUserId(tenantId, projectId, credentialScope, userId) {
70
70
  * Configure a Composio MCP server config with the appropriate user_id and x-api-key.
71
71
  * Mutates serverConfig in place:
72
72
  * - Injects user_id query param into the URL (scoped by tenant/project/user)
73
+ * - Injects connected_account_id query param if provided (pins to a specific account)
73
74
  * - Injects x-api-key header from COMPOSIO_API_KEY env var
74
75
  *
75
76
  * No-op if the URL is not a composio.dev URL or already has a user_id.
76
77
  */
77
- function configureComposioMCPServer(serverConfig, tenantId, projectId, credentialScope, userId) {
78
+ function configureComposioMCPServer(serverConfig, tenantId, projectId, credentialScope, userId, connectedAccountId) {
78
79
  const baseUrl = serverConfig.url?.toString();
79
80
  if (!baseUrl?.includes("composio.dev")) return;
80
81
  const urlObj = new URL(baseUrl);
81
82
  if (!urlObj.searchParams.has("user_id")) {
82
83
  const composioUserId = getComposioUserId(tenantId, projectId, credentialScope, userId);
83
84
  urlObj.searchParams.set("user_id", composioUserId);
84
- serverConfig.url = urlObj.toString();
85
85
  }
86
+ if (connectedAccountId && !urlObj.searchParams.has("connected_account_id")) urlObj.searchParams.set("connected_account_id", connectedAccountId);
87
+ serverConfig.url = urlObj.toString();
86
88
  const composioApiKey = process.env.COMPOSIO_API_KEY;
87
89
  if (composioApiKey) serverConfig.headers = {
88
90
  ...serverConfig.headers,
@@ -135,7 +137,11 @@ async function fetchComposioConnectedAccounts(derivedUserId) {
135
137
  try {
136
138
  return await composioInstance.connectedAccounts.list({
137
139
  userIds: [derivedUserId],
138
- statuses: ["ACTIVE", "INITIATED"]
140
+ statuses: [
141
+ "ACTIVE",
142
+ "INITIATED",
143
+ "EXPIRED"
144
+ ]
139
145
  });
140
146
  } catch (error) {
141
147
  logger$1.error({ error }, "Error fetching Composio connected accounts");
@@ -144,44 +150,52 @@ async function fetchComposioConnectedAccounts(derivedUserId) {
144
150
  }
145
151
  /**
146
152
  * Check if a Composio MCP server is authenticated for the given tenant/project/user
147
- * Returns true if authenticated, false otherwise
148
153
  * @param credentialScope - 'project' for shared team credentials, 'user' for per-user credentials
149
154
  * @param userId - The actual user ID (required if credentialScope is 'user')
150
155
  */
151
156
  async function isComposioMCPServerAuthenticated(tenantId, projectId, mcpServerUrl, credentialScope = "project", userId) {
152
157
  if (!process.env.COMPOSIO_API_KEY) {
153
158
  logger$1.info({}, "Composio API key not configured, skipping auth check");
154
- return false;
159
+ return { authenticated: false };
155
160
  }
156
161
  const serverId = extractComposioServerId(mcpServerUrl);
157
162
  if (!serverId) {
158
163
  logger$1.info({ mcpServerUrl }, "Could not extract Composio server ID from URL");
159
- return false;
164
+ return { authenticated: false };
160
165
  }
161
166
  const composioUserId = getComposioUserId(tenantId, projectId, credentialScope, userId);
162
167
  const composioInstance = getComposioInstance();
163
168
  if (!composioInstance) {
164
169
  logger$1.info({}, "Composio not configured, skipping auth check");
165
- return false;
170
+ return { authenticated: false };
166
171
  }
167
172
  try {
168
173
  const [composioMcpServer, connectedAccounts] = await Promise.all([composioInstance.mcp.get(serverId), fetchComposioConnectedAccounts(composioUserId)]);
169
- if (!(composioMcpServer.authConfigIds.length > 0 ? composioMcpServer.authConfigIds[0] : null)) return false;
170
- if (!connectedAccounts) return false;
171
- const activeAuthConfigIds = new Set(connectedAccounts.items.filter((account) => account.status === "ACTIVE").map((account) => account.authConfig.id));
172
- return composioMcpServer.authConfigIds.some((authConfigId) => activeAuthConfigIds.has(authConfigId));
174
+ if (!(composioMcpServer.authConfigIds.length > 0 ? composioMcpServer.authConfigIds[0] : null)) return { authenticated: false };
175
+ if (!connectedAccounts) return { authenticated: false };
176
+ const activeAccounts = connectedAccounts.items.filter((account) => account.status === "ACTIVE");
177
+ const activeAuthConfigIds = new Set(activeAccounts.map((account) => account.authConfig.id));
178
+ if (!composioMcpServer.authConfigIds.some((authConfigId) => activeAuthConfigIds.has(authConfigId))) return { authenticated: false };
179
+ const connectedAccountId = activeAccounts.find((account) => composioMcpServer.authConfigIds.includes(account.authConfig.id))?.id;
180
+ return {
181
+ authenticated: !!connectedAccountId,
182
+ connectedAccountId
183
+ };
173
184
  } catch (error) {
174
185
  logger$1.error({
175
186
  error,
176
187
  mcpServerUrl
177
188
  }, "Error checking Composio authentication status");
178
- return false;
189
+ return {
190
+ authenticated: false,
191
+ error: true
192
+ };
179
193
  }
180
194
  }
181
195
  /**
182
196
  * Convert Composio server data to PrebuiltMCPServer format
183
197
  */
184
- function transformComposioServerData(composioMcpServer, isAuthenticated, url, thirdPartyConnectAccountUrl) {
198
+ function transformComposioServerData(composioMcpServer, isAuthenticated, url, thirdPartyConnectAccountUrl, connectedAccountId, authScheme) {
185
199
  const firstToolkit = composioMcpServer.toolkits[0];
186
200
  const category = firstToolkit ? TOOLKIT_TO_CATEGORY[firstToolkit] || "integration" : "integration";
187
201
  const imageUrl = composioMcpServer.toolkitIcons?.[firstToolkit];
@@ -195,7 +209,9 @@ function transformComposioServerData(composioMcpServer, isAuthenticated, url, th
195
209
  category,
196
210
  description,
197
211
  isOpen: isAuthenticated,
198
- thirdPartyConnectAccountUrl
212
+ thirdPartyConnectAccountUrl,
213
+ connectedAccountId,
214
+ authScheme
199
215
  };
200
216
  }
201
217
  /**
@@ -203,14 +219,14 @@ function transformComposioServerData(composioMcpServer, isAuthenticated, url, th
203
219
  * Handles account creation/deletion and returns the redirect URL
204
220
  * Returns null if account creation fails
205
221
  */
206
- async function ensureComposioAccount(composioMcpServer, derivedUserId, initiatedAccounts) {
222
+ async function ensureComposioAccount(composioMcpServer, derivedUserId, staleAccounts) {
207
223
  const firstAuthConfigId = composioMcpServer.authConfigIds[0];
208
224
  if (!firstAuthConfigId) {
209
225
  logger$1.error({ serverId: composioMcpServer.id }, "No auth config ID found for MCP server");
210
226
  return null;
211
227
  }
212
- const existingInitiatedAccount = initiatedAccounts.find((account) => account.authConfig.id === firstAuthConfigId);
213
- if (existingInitiatedAccount) await deleteComposioConnectedAccount(existingInitiatedAccount.id);
228
+ const existingStaleAccounts = staleAccounts.filter((account) => account.authConfig.id === firstAuthConfigId);
229
+ await Promise.all(existingStaleAccounts.map((account) => deleteComposioConnectedAccount(account.id)));
214
230
  try {
215
231
  const composioInstance = getComposioInstance();
216
232
  if (!composioInstance) {
@@ -249,7 +265,7 @@ async function getComposioOAuthRedirectUrl(tenantId, projectId, mcpServerUrl, cr
249
265
  }
250
266
  const composioUserId = getComposioUserId(tenantId, projectId, credentialScope, userId);
251
267
  try {
252
- return await ensureComposioAccount(await composioInstance.mcp.get(serverId), composioUserId, (await fetchComposioConnectedAccounts(composioUserId))?.items.filter((account) => account.status === "INITIATED") ?? []);
268
+ return await ensureComposioAccount(await composioInstance.mcp.get(serverId), composioUserId, (await fetchComposioConnectedAccounts(composioUserId))?.items.filter((account) => account.status === "INITIATED" || account.status === "EXPIRED") ?? []);
253
269
  } catch (error) {
254
270
  logger$1.error({
255
271
  error,
@@ -263,15 +279,21 @@ async function getComposioOAuthRedirectUrl(tenantId, projectId, mcpServerUrl, cr
263
279
  * Coordinates authentication checks and account management
264
280
  * Returns null if the server cannot be properly configured
265
281
  */
266
- async function transformComposioServer(composioMcpServer, authenticatedAuthConfigIds, initiatedAccounts, derivedUserId) {
282
+ async function transformComposioServer(composioMcpServer, authenticatedAuthConfigIds, activeAccounts, staleAccounts, derivedUserId) {
267
283
  const isAuthenticated = composioMcpServer.authConfigIds.some((authConfigId) => authenticatedAuthConfigIds.has(authConfigId));
268
284
  let thirdPartyConnectAccountUrl;
285
+ let connectedAccountId;
286
+ let authScheme;
269
287
  if (!isAuthenticated) {
270
- const redirectUrl = await ensureComposioAccount(composioMcpServer, derivedUserId, initiatedAccounts);
288
+ const redirectUrl = await ensureComposioAccount(composioMcpServer, derivedUserId, staleAccounts);
271
289
  if (!redirectUrl) return null;
272
290
  thirdPartyConnectAccountUrl = redirectUrl;
291
+ } else {
292
+ const matchingAccount = activeAccounts.find((account) => composioMcpServer.authConfigIds.includes(account.authConfig.id));
293
+ connectedAccountId = matchingAccount?.id;
294
+ authScheme = matchingAccount?.state?.authScheme;
273
295
  }
274
- return transformComposioServerData(composioMcpServer, isAuthenticated, composioMcpServer.MCPUrl, thirdPartyConnectAccountUrl);
296
+ return transformComposioServerData(composioMcpServer, isAuthenticated, composioMcpServer.MCPUrl, thirdPartyConnectAccountUrl, connectedAccountId, authScheme);
275
297
  }
276
298
  /**
277
299
  * Fetch Composio MCP servers for the catalog
@@ -323,11 +345,15 @@ async function fetchSingleComposioServer(tenantId, projectId, mcpServerUrl, cred
323
345
  const composioMcpServer = await composioInstance.mcp.get(serverId);
324
346
  const userConnectedAccounts = await composioInstance.connectedAccounts.list({
325
347
  userIds: [composioUserId],
326
- statuses: ["ACTIVE", "INITIATED"]
348
+ statuses: [
349
+ "ACTIVE",
350
+ "INITIATED",
351
+ "EXPIRED"
352
+ ]
327
353
  });
328
354
  const activeAccounts = userConnectedAccounts?.items.filter((account) => account.status === "ACTIVE");
329
- const initiatedAccounts = userConnectedAccounts?.items.filter((account) => account.status === "INITIATED");
330
- return await transformComposioServer(composioMcpServer, new Set(activeAccounts?.map((account) => account.authConfig.id) ?? []), initiatedAccounts ?? [], composioUserId);
355
+ const staleAccounts = userConnectedAccounts?.items.filter((account) => account.status === "INITIATED" || account.status === "EXPIRED");
356
+ return await transformComposioServer(composioMcpServer, new Set(activeAccounts?.map((account) => account.authConfig.id) ?? []), activeAccounts ?? [], staleAccounts ?? [], composioUserId);
331
357
  } catch (error) {
332
358
  logger$1.error({
333
359
  error,
@@ -338,4 +364,4 @@ async function fetchSingleComposioServer(tenantId, projectId, mcpServerUrl, cred
338
364
  }
339
365
 
340
366
  //#endregion
341
- export { configureComposioMCPServer, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated };
367
+ export { configureComposioMCPServer, deleteComposioConnectedAccount, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioInstance, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated };
@@ -1,3 +1,3 @@
1
- import { CredentialScope, configureComposioMCPServer, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated } from "./composio-client.js";
1
+ import { ComposioAuthResult, CredentialScope, configureComposioMCPServer, deleteComposioConnectedAccount, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioInstance, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated } from "./composio-client.js";
2
2
  import { isThirdPartyMCPServerAuthenticated } from "./third-party-check.js";
3
- export { CredentialScope, configureComposioMCPServer, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated, isThirdPartyMCPServerAuthenticated };
3
+ export { ComposioAuthResult, CredentialScope, configureComposioMCPServer, deleteComposioConnectedAccount, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioInstance, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated, isThirdPartyMCPServerAuthenticated };
@@ -1,4 +1,4 @@
1
- import { configureComposioMCPServer, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated } from "./composio-client.js";
1
+ import { configureComposioMCPServer, deleteComposioConnectedAccount, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioInstance, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated } from "./composio-client.js";
2
2
  import { isThirdPartyMCPServerAuthenticated } from "./third-party-check.js";
3
3
 
4
- export { configureComposioMCPServer, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated, isThirdPartyMCPServerAuthenticated };
4
+ export { configureComposioMCPServer, deleteComposioConnectedAccount, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioInstance, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated, isThirdPartyMCPServerAuthenticated };
@@ -1,14 +1,13 @@
1
- import { CredentialScope } from "./composio-client.js";
1
+ import { ComposioAuthResult, CredentialScope } from "./composio-client.js";
2
2
 
3
3
  //#region src/utils/third-party-mcp-servers/third-party-check.d.ts
4
4
 
5
5
  /**
6
6
  * Check if a third-party MCP server is authenticated for the given tenant/project/user
7
7
  * This is a generic function that routes to the appropriate provider-specific check
8
- * Returns true if authenticated, false otherwise
9
8
  * @param credentialScope - 'project' for shared team credentials, 'user' for per-user credentials
10
9
  * @param userId - The actual user ID (required if credentialScope is 'user')
11
10
  */
12
- declare function isThirdPartyMCPServerAuthenticated(tenantId: string, projectId: string, mcpServerUrl: string, credentialScope?: CredentialScope, userId?: string): Promise<boolean>;
11
+ declare function isThirdPartyMCPServerAuthenticated(tenantId: string, projectId: string, mcpServerUrl: string, credentialScope?: CredentialScope, userId?: string): Promise<ComposioAuthResult>;
13
12
  //#endregion
14
- export { isThirdPartyMCPServerAuthenticated };
13
+ export { type ComposioAuthResult, isThirdPartyMCPServerAuthenticated };
@@ -10,7 +10,6 @@ const logger = getLogger("third-party-check");
10
10
  /**
11
11
  * Check if a third-party MCP server is authenticated for the given tenant/project/user
12
12
  * This is a generic function that routes to the appropriate provider-specific check
13
- * Returns true if authenticated, false otherwise
14
13
  * @param credentialScope - 'project' for shared team credentials, 'user' for per-user credentials
15
14
  * @param userId - The actual user ID (required if credentialScope is 'user')
16
15
  */
@@ -20,7 +19,7 @@ async function isThirdPartyMCPServerAuthenticated(tenantId, projectId, mcpServer
20
19
  return isComposioMCPServerAuthenticated(tenantId, projectId, mcpServerUrl, credentialScope, userId);
21
20
  }
22
21
  logger.info({ mcpServerUrl }, "Unknown third-party MCP server provider");
23
- return false;
22
+ return { authenticated: false };
24
23
  }
25
24
 
26
25
  //#endregion
@@ -32,8 +32,8 @@ declare const BranchNameParamsSchema: z.ZodObject<{
32
32
  }, z.core.$strip>;
33
33
  declare const ResolvedRefSchema: z.ZodObject<{
34
34
  type: z.ZodEnum<{
35
- commit: "commit";
36
35
  tag: "tag";
36
+ commit: "commit";
37
37
  branch: "branch";
38
38
  }>;
39
39
  name: z.ZodString;
@@ -1,10 +1,10 @@
1
1
  import { z } from "@hono/zod-openapi";
2
- import * as drizzle_zod0 from "drizzle-zod";
2
+ import * as drizzle_zod15 from "drizzle-zod";
3
3
  import { AnySQLiteTable } from "drizzle-orm/sqlite-core";
4
4
 
5
5
  //#region src/validation/drizzle-schema-helpers.d.ts
6
- declare function createSelectSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>): drizzle_zod0.BuildSchema<"select", T["_"]["columns"], drizzle_zod0.BuildRefine<T["_"]["columns"], undefined>, undefined>;
7
- declare function createInsertSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>): drizzle_zod0.BuildSchema<"insert", T["_"]["columns"], drizzle_zod0.BuildRefine<Pick<T["_"]["columns"], keyof T["$inferInsert"]>, undefined>, undefined>;
6
+ declare function createSelectSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>): drizzle_zod15.BuildSchema<"select", T["_"]["columns"], drizzle_zod15.BuildRefine<T["_"]["columns"], undefined>, undefined>;
7
+ declare function createInsertSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>): drizzle_zod15.BuildSchema<"insert", T["_"]["columns"], drizzle_zod15.BuildRefine<Pick<T["_"]["columns"], keyof T["$inferInsert"]>, undefined>, undefined>;
8
8
  declare const createSelectSchema: typeof createSelectSchemaWithModifiers;
9
9
  declare const createInsertSchema: typeof createInsertSchemaWithModifiers;
10
10
  /**