@inkeep/agents-core 0.0.0-dev-20251003220013 → 0.0.0-dev-20251003221329

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.
@@ -1,4 +1,4 @@
1
- import { FullGraphDefinitionSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-YVZJ5VV7.js';
1
+ import { FullGraphDefinitionSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-AGEHLZUK.js';
2
2
 
3
3
  // src/validation/graphFull.ts
4
4
  function isInternalAgent(agent) {
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-BOfzG3mF.cjs';
3
- export { d as AgentStopWhen, a as AgentStopWhenSchema, e as CredentialStoreType, c as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, b as StopWhen, S as StopWhenSchema } from './utility-BOfzG3mF.cjs';
2
+ import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-Cd0qsewS.cjs';
3
+ export { d as AgentStopWhen, a as AgentStopWhenSchema, e as CredentialStoreType, c as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, b as StopWhen, S as StopWhenSchema } from './utility-Cd0qsewS.cjs';
4
4
  import 'drizzle-zod';
5
5
  import 'drizzle-orm/sqlite-core';
6
6
  import '@hono/zod-openapi';
@@ -67,8 +67,8 @@ declare const AgentApiInsertSchema: z.ZodObject<{
67
67
  canTransferTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
68
68
  canDelegateTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
69
  type: z.ZodOptional<z.ZodEnum<{
70
- external: "external";
71
70
  internal: "internal";
71
+ external: "external";
72
72
  }>>;
73
73
  }, z.core.$strip>;
74
74
  declare const ToolApiInsertSchema: z.ZodObject<{
@@ -168,11 +168,13 @@ declare const FullGraphDefinitionSchema: z.ZodObject<{
168
168
  description: z.ZodOptional<z.ZodString>;
169
169
  defaultAgentId: z.ZodOptional<z.ZodString>;
170
170
  agents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
171
- name: z.ZodString;
172
171
  id: z.ZodString;
172
+ name: z.ZodString;
173
+ description: z.ZodString;
174
+ prompt: z.ZodString;
173
175
  createdAt: z.ZodOptional<z.ZodString>;
174
176
  updatedAt: z.ZodOptional<z.ZodString>;
175
- description: z.ZodString;
177
+ conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
176
178
  models: z.ZodOptional<z.ZodObject<{
177
179
  base: z.ZodOptional<z.ZodObject<{
178
180
  model: z.ZodOptional<z.ZodString>;
@@ -196,8 +198,6 @@ declare const FullGraphDefinitionSchema: z.ZodObject<{
196
198
  }, {
197
199
  stepCountIs?: number | undefined;
198
200
  }>>>>;
199
- prompt: z.ZodString;
200
- conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
201
201
  type: z.ZodLiteral<"internal">;
202
202
  canUse: z.ZodArray<z.ZodObject<{
203
203
  agentToolRelationId: z.ZodOptional<z.ZodString>;
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-BOfzG3mF.js';
3
- export { d as AgentStopWhen, a as AgentStopWhenSchema, e as CredentialStoreType, c as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, b as StopWhen, S as StopWhenSchema } from './utility-BOfzG3mF.js';
2
+ import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-Cd0qsewS.js';
3
+ export { d as AgentStopWhen, a as AgentStopWhenSchema, e as CredentialStoreType, c as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, b as StopWhen, S as StopWhenSchema } from './utility-Cd0qsewS.js';
4
4
  import 'drizzle-zod';
5
5
  import 'drizzle-orm/sqlite-core';
6
6
  import '@hono/zod-openapi';
@@ -67,8 +67,8 @@ declare const AgentApiInsertSchema: z.ZodObject<{
67
67
  canTransferTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
68
68
  canDelegateTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
69
  type: z.ZodOptional<z.ZodEnum<{
70
- external: "external";
71
70
  internal: "internal";
71
+ external: "external";
72
72
  }>>;
73
73
  }, z.core.$strip>;
74
74
  declare const ToolApiInsertSchema: z.ZodObject<{
@@ -168,11 +168,13 @@ declare const FullGraphDefinitionSchema: z.ZodObject<{
168
168
  description: z.ZodOptional<z.ZodString>;
169
169
  defaultAgentId: z.ZodOptional<z.ZodString>;
170
170
  agents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
171
- name: z.ZodString;
172
171
  id: z.ZodString;
172
+ name: z.ZodString;
173
+ description: z.ZodString;
174
+ prompt: z.ZodString;
173
175
  createdAt: z.ZodOptional<z.ZodString>;
174
176
  updatedAt: z.ZodOptional<z.ZodString>;
175
- description: z.ZodString;
177
+ conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
176
178
  models: z.ZodOptional<z.ZodObject<{
177
179
  base: z.ZodOptional<z.ZodObject<{
178
180
  model: z.ZodOptional<z.ZodString>;
@@ -196,8 +198,6 @@ declare const FullGraphDefinitionSchema: z.ZodObject<{
196
198
  }, {
197
199
  stepCountIs?: number | undefined;
198
200
  }>>>>;
199
- prompt: z.ZodString;
200
- conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
201
201
  type: z.ZodLiteral<"internal">;
202
202
  canUse: z.ZodArray<z.ZodObject<{
203
203
  agentToolRelationId: z.ZodOptional<z.ZodString>;
@@ -1,5 +1,5 @@
1
- import { FullGraphAgentInsertSchema } from './chunk-YVZJ5VV7.js';
2
- export { AgentStopWhenSchema, GraphStopWhenSchema, StopWhenSchema } from './chunk-YVZJ5VV7.js';
1
+ import { FullGraphAgentInsertSchema } from './chunk-AGEHLZUK.js';
2
+ export { AgentStopWhenSchema, GraphStopWhenSchema, StopWhenSchema } from './chunk-AGEHLZUK.js';
3
3
  import { CredentialStoreType } from './chunk-YFHT5M2R.js';
4
4
  export { CredentialStoreType, MCPTransportType } from './chunk-YFHT5M2R.js';
5
5
  import { z } from 'zod';
@@ -1,7 +1,7 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/sqlite-core';
3
- import '../utility-BOfzG3mF.cjs';
4
- export { k as agentArtifactComponents, K as agentArtifactComponentsRelations, i as agentDataComponents, M as agentDataComponentsRelations, a as agentGraph, B as agentGraphRelations, e as agentRelations, O as agentRelationsRelations, m as agentToolRelations, E as agentToolRelationsRelations, d as agents, A as agentsRelations, r as apiKeys, D as apiKeysRelations, j as artifactComponents, J as artifactComponentsRelations, b as contextCache, z as contextCacheRelations, c as contextConfigs, y as contextConfigsRelations, n as conversations, H as conversationsRelations, u as credentialReferences, F as credentialReferencesRelations, h as dataComponents, L as dataComponentsRelations, f as externalAgents, C as externalAgentsRelations, q as ledgerArtifacts, N as ledgerArtifactsRelations, o as messages, I as messagesRelations, p as projects, w as projectsRelations, g as taskRelations, x as taskRelationsRelations, t as tasks, v as tasksRelations, l as tools, G as toolsRelations } from '../schema-DeUmRJk-.cjs';
3
+ import '../utility-Cd0qsewS.cjs';
4
+ export { k as agentArtifactComponents, K as agentArtifactComponentsRelations, i as agentDataComponents, M as agentDataComponentsRelations, a as agentGraph, B as agentGraphRelations, e as agentRelations, O as agentRelationsRelations, m as agentToolRelations, E as agentToolRelationsRelations, d as agents, A as agentsRelations, r as apiKeys, D as apiKeysRelations, j as artifactComponents, J as artifactComponentsRelations, b as contextCache, z as contextCacheRelations, c as contextConfigs, y as contextConfigsRelations, n as conversations, H as conversationsRelations, u as credentialReferences, F as credentialReferencesRelations, h as dataComponents, L as dataComponentsRelations, f as externalAgents, C as externalAgentsRelations, q as ledgerArtifacts, N as ledgerArtifactsRelations, o as messages, I as messagesRelations, p as projects, w as projectsRelations, g as taskRelations, x as taskRelationsRelations, t as tasks, v as tasksRelations, l as tools, G as toolsRelations } from '../schema-DDUpvlcp.cjs';
5
5
  import 'zod';
6
6
  import 'drizzle-zod';
7
7
  import '@hono/zod-openapi';
@@ -1,7 +1,7 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/sqlite-core';
3
- import '../utility-BOfzG3mF.js';
4
- export { k as agentArtifactComponents, K as agentArtifactComponentsRelations, i as agentDataComponents, M as agentDataComponentsRelations, a as agentGraph, B as agentGraphRelations, e as agentRelations, O as agentRelationsRelations, m as agentToolRelations, E as agentToolRelationsRelations, d as agents, A as agentsRelations, r as apiKeys, D as apiKeysRelations, j as artifactComponents, J as artifactComponentsRelations, b as contextCache, z as contextCacheRelations, c as contextConfigs, y as contextConfigsRelations, n as conversations, H as conversationsRelations, u as credentialReferences, F as credentialReferencesRelations, h as dataComponents, L as dataComponentsRelations, f as externalAgents, C as externalAgentsRelations, q as ledgerArtifacts, N as ledgerArtifactsRelations, o as messages, I as messagesRelations, p as projects, w as projectsRelations, g as taskRelations, x as taskRelationsRelations, t as tasks, v as tasksRelations, l as tools, G as toolsRelations } from '../schema-DhRzICV3.js';
3
+ import '../utility-Cd0qsewS.js';
4
+ export { k as agentArtifactComponents, K as agentArtifactComponentsRelations, i as agentDataComponents, M as agentDataComponentsRelations, a as agentGraph, B as agentGraphRelations, e as agentRelations, O as agentRelationsRelations, m as agentToolRelations, E as agentToolRelationsRelations, d as agents, A as agentsRelations, r as apiKeys, D as apiKeysRelations, j as artifactComponents, J as artifactComponentsRelations, b as contextCache, z as contextCacheRelations, c as contextConfigs, y as contextConfigsRelations, n as conversations, H as conversationsRelations, u as credentialReferences, F as credentialReferencesRelations, h as dataComponents, L as dataComponentsRelations, f as externalAgents, C as externalAgentsRelations, q as ledgerArtifacts, N as ledgerArtifactsRelations, o as messages, I as messagesRelations, p as projects, w as projectsRelations, g as taskRelations, x as taskRelationsRelations, t as tasks, v as tasksRelations, l as tools, G as toolsRelations } from '../schema-BB_Q_YNK.js';
5
5
  import 'zod';
6
6
  import 'drizzle-zod';
7
7
  import '@hono/zod-openapi';
package/dist/index.cjs CHANGED
@@ -5544,6 +5544,9 @@ var McpClient = class {
5544
5544
  { capabilities: opts.capabilities || {} }
5545
5545
  );
5546
5546
  }
5547
+ isConnected() {
5548
+ return this.connected;
5549
+ }
5547
5550
  async connect() {
5548
5551
  if (this.connected) return;
5549
5552
  await tsPattern.match(this.serverConfig).with({ type: MCPTransportType.streamableHttp }, (config) => this.connectHttp(config)).with({ type: MCPTransportType.sse }, (config) => this.connectSSE(config)).exhaustive();
@@ -10407,10 +10410,47 @@ var NangoCredentialStore = class {
10407
10410
  if (error && typeof error === "object" && "status" in error && error.status === 404) {
10408
10411
  return null;
10409
10412
  }
10410
- console.error(`Failed to fetch integration ${uniqueKey}:`, error);
10413
+ logger11.error(
10414
+ { error: error instanceof Error ? error.message : "Unknown error", uniqueKey },
10415
+ `Failed to fetch integration ${uniqueKey}`
10416
+ );
10411
10417
  return null;
10412
10418
  }
10413
10419
  }
10420
+ /**
10421
+ * Optimize OAuth token data to fit within Nango's 1024 character limit for apiKey field
10422
+ * Strategy: Remove unnecessary fields
10423
+ */
10424
+ optimizeOAuthTokenForNango(tokenData) {
10425
+ const parsed = JSON.parse(tokenData);
10426
+ const essential = {
10427
+ access_token: parsed.access_token,
10428
+ token_type: parsed.token_type,
10429
+ expires_in: parsed.expires_in,
10430
+ refresh_token: parsed.refresh_token
10431
+ };
10432
+ Object.keys(essential).forEach((key) => {
10433
+ if (essential[key] === void 0) {
10434
+ delete essential[key];
10435
+ }
10436
+ });
10437
+ const result = JSON.stringify(essential);
10438
+ if (result.length > 1024) {
10439
+ logger11.error(
10440
+ {
10441
+ originalLength: tokenData.length,
10442
+ essentialLength: result.length,
10443
+ accessTokenLength: parsed.access_token?.length || 0,
10444
+ refreshTokenLength: parsed.refresh_token?.length || 0
10445
+ },
10446
+ "OAuth token too large for Nango storage even after removing non-essential fields"
10447
+ );
10448
+ throw new Error(
10449
+ `OAuth token (${result.length} chars) exceeds Nango's 1024 character limit. Essential fields cannot be truncated without breaking functionality. Consider using keychain storage instead of Nango for this provider.`
10450
+ );
10451
+ }
10452
+ return result;
10453
+ }
10414
10454
  /**
10415
10455
  * Create an API key credential by setting up Nango integration and importing the connection
10416
10456
  */
@@ -10441,9 +10481,13 @@ var NangoCredentialStore = class {
10441
10481
  throw new Error(`Integration '${name}' not found`);
10442
10482
  }
10443
10483
  const importConnectionUrl = `${process.env.NANGO_SERVER_URL || "https://api.nango.dev"}/connections`;
10484
+ const optimizedApiKey = this.optimizeOAuthTokenForNango(apiKeyToSet);
10485
+ if (!optimizedApiKey) {
10486
+ throw new Error(`Failed to optimize OAuth token for Nango.`);
10487
+ }
10444
10488
  const credentials = {
10445
10489
  type: "API_KEY",
10446
- apiKey: apiKeyToSet
10490
+ apiKey: optimizedApiKey
10447
10491
  };
10448
10492
  const body = {
10449
10493
  provider_config_key: integration.unique_key,
@@ -10460,12 +10504,12 @@ var NangoCredentialStore = class {
10460
10504
  body: JSON.stringify(body)
10461
10505
  });
10462
10506
  if (!response.ok) {
10507
+ const errorText = await response.text();
10463
10508
  throw new Error(
10464
- `Failed to import connection: HTTP ${response.status} - ${response.statusText}`
10509
+ `Failed to import connection: HTTP ${response.status} - ${response.statusText}. Response: ${errorText}`
10465
10510
  );
10466
10511
  }
10467
10512
  } catch (error) {
10468
- console.error("Unexpected error creating API key credential:", error);
10469
10513
  logger11.error(
10470
10514
  {
10471
10515
  error: error instanceof Error ? error.message : "Unknown error",