@inkeep/agents-core 0.0.0-dev-20250930131913 → 0.0.0-dev-20250930181023

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,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-D7QP8MkV.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-D7QP8MkV.cjs';
2
+ import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-8RXSemmL.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-8RXSemmL.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-D7QP8MkV.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-D7QP8MkV.js';
2
+ import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-8RXSemmL.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-8RXSemmL.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,7 +1,7 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/sqlite-core';
3
- import '../utility-D7QP8MkV.cjs';
4
- export { k as agentArtifactComponents, O as agentArtifactComponentsRelations, i as agentDataComponents, Q as agentDataComponentsRelations, a as agentGraph, F as agentGraphRelations, e as agentRelations, S as agentRelationsRelations, m as agentToolRelations, I as agentToolRelationsRelations, d as agents, E as agentsRelations, r as apiKeys, H as apiKeysRelations, j as artifactComponents, N as artifactComponentsRelations, b as contextCache, D as contextCacheRelations, c as contextConfigs, C as contextConfigsRelations, n as conversations, L as conversationsRelations, u as credentialReferences, J as credentialReferencesRelations, h as dataComponents, P as dataComponentsRelations, f as externalAgents, G as externalAgentsRelations, q as ledgerArtifacts, x as ledgerArtifactsContextIdIdx, R as ledgerArtifactsRelations, y as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, w as ledgerArtifactsToolCallIdIdx, o as messages, M as messagesRelations, p as projects, A as projectsRelations, g as taskRelations, B as taskRelationsRelations, t as tasks, z as tasksRelations, l as tools, K as toolsRelations } from '../schema-BXVLXPQq.cjs';
3
+ import '../utility-8RXSemmL.cjs';
4
+ export { k as agentArtifactComponents, O as agentArtifactComponentsRelations, i as agentDataComponents, Q as agentDataComponentsRelations, a as agentGraph, F as agentGraphRelations, e as agentRelations, S as agentRelationsRelations, m as agentToolRelations, I as agentToolRelationsRelations, d as agents, E as agentsRelations, r as apiKeys, H as apiKeysRelations, j as artifactComponents, N as artifactComponentsRelations, b as contextCache, D as contextCacheRelations, c as contextConfigs, C as contextConfigsRelations, n as conversations, L as conversationsRelations, u as credentialReferences, J as credentialReferencesRelations, h as dataComponents, P as dataComponentsRelations, f as externalAgents, G as externalAgentsRelations, q as ledgerArtifacts, x as ledgerArtifactsContextIdIdx, R as ledgerArtifactsRelations, y as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, w as ledgerArtifactsToolCallIdIdx, o as messages, M as messagesRelations, p as projects, A as projectsRelations, g as taskRelations, B as taskRelationsRelations, t as tasks, z as tasksRelations, l as tools, K as toolsRelations } from '../schema-B0z-X5Hq.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-D7QP8MkV.js';
4
- export { k as agentArtifactComponents, O as agentArtifactComponentsRelations, i as agentDataComponents, Q as agentDataComponentsRelations, a as agentGraph, F as agentGraphRelations, e as agentRelations, S as agentRelationsRelations, m as agentToolRelations, I as agentToolRelationsRelations, d as agents, E as agentsRelations, r as apiKeys, H as apiKeysRelations, j as artifactComponents, N as artifactComponentsRelations, b as contextCache, D as contextCacheRelations, c as contextConfigs, C as contextConfigsRelations, n as conversations, L as conversationsRelations, u as credentialReferences, J as credentialReferencesRelations, h as dataComponents, P as dataComponentsRelations, f as externalAgents, G as externalAgentsRelations, q as ledgerArtifacts, x as ledgerArtifactsContextIdIdx, R as ledgerArtifactsRelations, y as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, w as ledgerArtifactsToolCallIdIdx, o as messages, M as messagesRelations, p as projects, A as projectsRelations, g as taskRelations, B as taskRelationsRelations, t as tasks, z as tasksRelations, l as tools, K as toolsRelations } from '../schema-D66X7wP_.js';
3
+ import '../utility-8RXSemmL.js';
4
+ export { k as agentArtifactComponents, O as agentArtifactComponentsRelations, i as agentDataComponents, Q as agentDataComponentsRelations, a as agentGraph, F as agentGraphRelations, e as agentRelations, S as agentRelationsRelations, m as agentToolRelations, I as agentToolRelationsRelations, d as agents, E as agentsRelations, r as apiKeys, H as apiKeysRelations, j as artifactComponents, N as artifactComponentsRelations, b as contextCache, D as contextCacheRelations, c as contextConfigs, C as contextConfigsRelations, n as conversations, L as conversationsRelations, u as credentialReferences, J as credentialReferencesRelations, h as dataComponents, P as dataComponentsRelations, f as externalAgents, G as externalAgentsRelations, q as ledgerArtifacts, x as ledgerArtifactsContextIdIdx, R as ledgerArtifactsRelations, y as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, w as ledgerArtifactsToolCallIdIdx, o as messages, M as messagesRelations, p as projects, A as projectsRelations, g as taskRelations, B as taskRelationsRelations, t as tasks, z as tasksRelations, l as tools, K as toolsRelations } from '../schema-BQoMyAN6.js';
5
5
  import 'zod';
6
6
  import 'drizzle-zod';
7
7
  import '@hono/zod-openapi';
package/dist/index.cjs CHANGED
@@ -10406,14 +10406,31 @@ var NangoCredentialStore = class {
10406
10406
  if (!isSupportedAuthMode(type)) {
10407
10407
  return null;
10408
10408
  }
10409
+ const extractAccessTokenForBearerType = (tokenString) => {
10410
+ if (tokenString && typeof tokenString === "string") {
10411
+ try {
10412
+ const parsedToken = JSON.parse(tokenString);
10413
+ if (parsedToken.access_token && typeof parsedToken.access_token === "string") {
10414
+ return parsedToken.access_token;
10415
+ }
10416
+ } catch {
10417
+ }
10418
+ return tokenString;
10419
+ }
10420
+ return void 0;
10421
+ };
10409
10422
  switch (type) {
10410
10423
  case "API_KEY":
10411
10424
  return {
10412
- token: credentials.apiKey || credentials.api_key
10425
+ token: extractAccessTokenForBearerType(
10426
+ credentials.apiKey || credentials.api_key
10427
+ )
10413
10428
  };
10414
10429
  case "APP":
10415
10430
  return {
10416
- token: credentials.accessToken || credentials.access_token
10431
+ token: extractAccessTokenForBearerType(
10432
+ credentials.accessToken || credentials.access_token
10433
+ )
10417
10434
  };
10418
10435
  case "BASIC":
10419
10436
  return {
@@ -10424,7 +10441,7 @@ var NangoCredentialStore = class {
10424
10441
  return credentials.raw;
10425
10442
  case "JWT":
10426
10443
  return {
10427
- token: credentials.token
10444
+ token: extractAccessTokenForBearerType(credentials.token)
10428
10445
  };
10429
10446
  case "OAUTH1":
10430
10447
  return {
@@ -10433,12 +10450,12 @@ var NangoCredentialStore = class {
10433
10450
  };
10434
10451
  case "OAUTH2":
10435
10452
  return {
10436
- token: credentials.access_token,
10453
+ token: extractAccessTokenForBearerType(credentials.access_token),
10437
10454
  refresh_token: credentials.refresh_token
10438
10455
  };
10439
10456
  case "OAUTH2_CC":
10440
10457
  return {
10441
- token: credentials.token,
10458
+ token: extractAccessTokenForBearerType(credentials.token),
10442
10459
  client_certificate: credentials.client_certificate,
10443
10460
  client_id: credentials.client_id,
10444
10461
  client_private_key: credentials.client_private_key,
@@ -10464,6 +10481,104 @@ var NangoCredentialStore = class {
10464
10481
  }
10465
10482
  return result;
10466
10483
  }
10484
+ /**
10485
+ * Fetch a specific Nango integration
10486
+ */
10487
+ async fetchNangoIntegration(uniqueKey) {
10488
+ try {
10489
+ const response = await this.nangoClient.getIntegration(
10490
+ { uniqueKey },
10491
+ { include: ["credentials"] }
10492
+ );
10493
+ const integration = response.data;
10494
+ let areCredentialsSet = false;
10495
+ if (integration.credentials?.type === "OAUTH2" || integration.credentials?.type === "OAUTH1" || integration.credentials?.type === "TBA") {
10496
+ areCredentialsSet = !!(integration.credentials?.client_id && integration.credentials?.client_secret);
10497
+ } else if (integration.credentials?.type === "APP") {
10498
+ areCredentialsSet = !!(integration.credentials?.app_id && integration.credentials?.app_link);
10499
+ } else {
10500
+ areCredentialsSet = true;
10501
+ }
10502
+ const { credentials: _credentials, ...integrationWithoutCredentials } = integration;
10503
+ return {
10504
+ ...integrationWithoutCredentials,
10505
+ areCredentialsSet
10506
+ };
10507
+ } catch (error) {
10508
+ if (error && typeof error === "object" && "status" in error && error.status === 404) {
10509
+ return null;
10510
+ }
10511
+ console.error(`Failed to fetch integration ${uniqueKey}:`, error);
10512
+ return null;
10513
+ }
10514
+ }
10515
+ /**
10516
+ * Create an API key credential by setting up Nango integration and importing the connection
10517
+ */
10518
+ async createNangoApiKeyConnection({
10519
+ name,
10520
+ apiKeyToSet,
10521
+ metadata
10522
+ }) {
10523
+ const provider = "private-api-bearer";
10524
+ try {
10525
+ let integration;
10526
+ try {
10527
+ const response2 = await this.nangoClient.createIntegration({
10528
+ provider,
10529
+ unique_key: name,
10530
+ display_name: name
10531
+ });
10532
+ integration = response2.data;
10533
+ } catch (error) {
10534
+ const existingIntegration = await this.fetchNangoIntegration(name);
10535
+ if (existingIntegration) {
10536
+ integration = existingIntegration;
10537
+ } else {
10538
+ console.log(`Integration creation failed for unexpected reasons`, error);
10539
+ }
10540
+ }
10541
+ if (!integration) {
10542
+ throw new Error(`Integration '${name}' not found`);
10543
+ }
10544
+ const importConnectionUrl = `${process.env.NANGO_SERVER_URL || "https://api.nango.dev"}/connections`;
10545
+ const credentials = {
10546
+ type: "API_KEY",
10547
+ apiKey: apiKeyToSet
10548
+ };
10549
+ const body = {
10550
+ provider_config_key: integration.unique_key,
10551
+ connection_id: name,
10552
+ metadata,
10553
+ credentials
10554
+ };
10555
+ const response = await fetch(importConnectionUrl, {
10556
+ method: "POST",
10557
+ headers: {
10558
+ Authorization: `Bearer ${process.env.NANGO_SECRET_KEY}`,
10559
+ "Content-Type": "application/json"
10560
+ },
10561
+ body: JSON.stringify(body)
10562
+ });
10563
+ if (!response.ok) {
10564
+ throw new Error(
10565
+ `Failed to import connection: HTTP ${response.status} - ${response.statusText}`
10566
+ );
10567
+ }
10568
+ } catch (error) {
10569
+ console.error("Unexpected error creating API key credential:", error);
10570
+ logger11.error(
10571
+ {
10572
+ error: error instanceof Error ? error.message : "Unknown error",
10573
+ name
10574
+ },
10575
+ `Unexpected error creating API key credential '${name}'`
10576
+ );
10577
+ throw new Error(
10578
+ `Failed to create API key credential '${name}': ${error instanceof Error ? error.message : "Unknown error"}`
10579
+ );
10580
+ }
10581
+ }
10467
10582
  /**
10468
10583
  * Fetch credentials from Nango API using connection information
10469
10584
  * @param connectionId - The connection ID for the Nango connection
@@ -10553,8 +10668,12 @@ var NangoCredentialStore = class {
10553
10668
  /**
10554
10669
  * Set credentials - not supported for Nango (OAuth flow handles this)
10555
10670
  */
10556
- async set(_key, _value) {
10557
- throw new Error("Setting credentials not supported for Nango store - use OAuth flow instead");
10671
+ async set(key, value) {
10672
+ await this.createNangoApiKeyConnection({
10673
+ name: key,
10674
+ apiKeyToSet: value,
10675
+ metadata: {}
10676
+ });
10558
10677
  }
10559
10678
  /**
10560
10679
  * Check if credentials exist by attempting to fetch them
@@ -10648,7 +10767,16 @@ function createDefaultCredentialStores() {
10648
10767
  })
10649
10768
  );
10650
10769
  }
10651
- stores.push(createKeyChainStore("keychain-default"));
10770
+ if (process.env.ENABLE_KEYCHAIN_STORE === "true") {
10771
+ try {
10772
+ stores.push(createKeyChainStore("keychain-default"));
10773
+ } catch (error) {
10774
+ console.warn(
10775
+ "Failed to create keychain store:",
10776
+ error instanceof Error ? error.message : error
10777
+ );
10778
+ }
10779
+ }
10652
10780
  return stores;
10653
10781
  }
10654
10782
  var loadEnvironmentFiles = () => {
@@ -10968,7 +11096,6 @@ exports.createExternalAgentRelation = createExternalAgentRelation;
10968
11096
  exports.createFullGraphServerSide = createFullGraphServerSide;
10969
11097
  exports.createFullProjectServerSide = createFullProjectServerSide;
10970
11098
  exports.createInMemoryDatabaseClient = createInMemoryDatabaseClient;
10971
- exports.createKeyChainStore = createKeyChainStore;
10972
11099
  exports.createMessage = createMessage;
10973
11100
  exports.createNangoCredentialStore = createNangoCredentialStore;
10974
11101
  exports.createOrGetConversation = createOrGetConversation;