@inkeep/agents-core 0.0.0-dev-20251014155922 → 0.0.0-dev-20251014185355

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/index.cjs CHANGED
@@ -212899,18 +212899,29 @@ async function apiFetch(url, options = {}) {
212899
212899
 
212900
212900
  // src/constants/models.ts
212901
212901
  var ANTHROPIC_MODELS = {
212902
+ CLAUDE_OPUS_4_1: "anthropic/claude-opus-4-1",
212902
212903
  CLAUDE_OPUS_4_1_20250805: "anthropic/claude-opus-4-1-20250805",
212904
+ CLAUDE_SONNET_4_5: "anthropic/claude-sonnet-4-5",
212903
212905
  CLAUDE_SONNET_4_5_20250929: "anthropic/claude-sonnet-4-5-20250929",
212906
+ CLAUDE_SONNET_4: "anthropic/claude-sonnet-4",
212904
212907
  CLAUDE_SONNET_4_20250514: "anthropic/claude-sonnet-4-20250514",
212908
+ CLAUDE_3_5_SONNET: "anthropic/claude-3-5-sonnet",
212905
212909
  CLAUDE_3_5_SONNET_20241022: "anthropic/claude-3-5-sonnet-20241022",
212910
+ CLAUDE_3_5_HAIKU: "anthropic/claude-3-5-haiku",
212906
212911
  CLAUDE_3_5_HAIKU_20241022: "anthropic/claude-3-5-haiku-20241022"
212907
212912
  };
212908
212913
  var OPENAI_MODELS = {
212914
+ GPT_5: "openai/gpt-5",
212909
212915
  GPT_5_20250807: "openai/gpt-5-2025-08-07",
212916
+ GPT_5_MINI: "openai/gpt-5-mini",
212910
212917
  GPT_5_MINI_20250807: "openai/gpt-5-mini-2025-08-07",
212918
+ GPT_5_NANO: "openai/gpt-5-nano",
212911
212919
  GPT_5_NANO_20250807: "openai/gpt-5-nano-2025-08-07",
212920
+ GPT_4_1: "openai/gpt-4.1",
212912
212921
  GPT_4_1_20250414: "openai/gpt-4.1-2025-04-14",
212922
+ GPT_4_1_MINI: "openai/gpt-4.1-mini",
212913
212923
  GPT_4_1_MINI_20250414: "openai/gpt-4.1-mini-2025-04-14",
212924
+ GPT_4_1_NANO: "openai/gpt-4.1-nano",
212914
212925
  GPT_4_1_NANO_20250414: "openai/gpt-4.1-nano-2025-04-14"
212915
212926
  };
212916
212927
  var GOOGLE_MODELS = {
@@ -213422,8 +213433,6 @@ function extractPreviewFields(schema) {
213422
213433
  // src/db/schema.ts
213423
213434
  var schema_exports = {};
213424
213435
  __export(schema_exports, {
213425
- agentFunctionToolRelations: () => agentFunctionToolRelations,
213426
- agentFunctionToolRelationsRelations: () => agentFunctionToolRelationsRelations,
213427
213436
  agentRelations: () => agentRelations,
213428
213437
  agentToolRelationsRelations: () => agentToolRelationsRelations,
213429
213438
  agents: () => agents,
@@ -213457,6 +213466,8 @@ __export(schema_exports, {
213457
213466
  subAgentArtifactComponentsRelations: () => subAgentArtifactComponentsRelations,
213458
213467
  subAgentDataComponents: () => subAgentDataComponents,
213459
213468
  subAgentDataComponentsRelations: () => subAgentDataComponentsRelations,
213469
+ subAgentFunctionToolRelations: () => subAgentFunctionToolRelations,
213470
+ subAgentFunctionToolRelationsRelations: () => subAgentFunctionToolRelationsRelations,
213460
213471
  subAgentRelations: () => subAgentRelations,
213461
213472
  subAgentRelationsRelations: () => subAgentRelationsRelations,
213462
213473
  subAgentToolRelations: () => subAgentToolRelations,
@@ -213861,8 +213872,8 @@ var subAgentToolRelations = sqliteCore.sqliteTable(
213861
213872
  }).onDelete("cascade")
213862
213873
  ]
213863
213874
  );
213864
- var agentFunctionToolRelations = sqliteCore.sqliteTable(
213865
- "agent_function_tool_relations",
213875
+ var subAgentFunctionToolRelations = sqliteCore.sqliteTable(
213876
+ "sub_agent_function_tool_relations",
213866
213877
  {
213867
213878
  ...subAgentScoped,
213868
213879
  functionToolId: sqliteCore.text("function_tool_id").notNull(),
@@ -213870,11 +213881,11 @@ var agentFunctionToolRelations = sqliteCore.sqliteTable(
213870
213881
  },
213871
213882
  (table) => [
213872
213883
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213873
- // Foreign key constraint to agents table
213884
+ // Foreign key constraint to sub_agents table
213874
213885
  sqliteCore.foreignKey({
213875
213886
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
213876
213887
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
213877
- name: "agent_function_tool_relations_agent_fk"
213888
+ name: "sub_agent_function_tool_relations_sub_agent_fk"
213878
213889
  }).onDelete("cascade"),
213879
213890
  // Foreign key constraint to functionTools table
213880
213891
  sqliteCore.foreignKey({
@@ -213885,7 +213896,7 @@ var agentFunctionToolRelations = sqliteCore.sqliteTable(
213885
213896
  functionTools.agentId,
213886
213897
  functionTools.id
213887
213898
  ],
213888
- name: "agent_function_tool_relations_function_tool_fk"
213899
+ name: "sub_agent_function_tool_relations_function_tool_fk"
213889
213900
  }).onDelete("cascade")
213890
213901
  ]
213891
213902
  );
@@ -214111,7 +214122,7 @@ var subAgentsRelations = drizzleOrm.relations(subAgents, ({ many, one }) => ({
214111
214122
  relationName: "receivedMessages"
214112
214123
  }),
214113
214124
  toolRelations: many(subAgentToolRelations),
214114
- functionToolRelations: many(agentFunctionToolRelations),
214125
+ functionToolRelations: many(subAgentFunctionToolRelations),
214115
214126
  dataComponentRelations: many(subAgentDataComponents),
214116
214127
  artifactComponentRelations: many(subAgentArtifactComponents)
214117
214128
  }));
@@ -214316,17 +214327,17 @@ var functionToolsRelations = drizzleOrm.relations(functionTools, ({ one, many })
214316
214327
  fields: [functionTools.tenantId, functionTools.projectId, functionTools.functionId],
214317
214328
  references: [functions.tenantId, functions.projectId, functions.id]
214318
214329
  }),
214319
- agentRelations: many(agentFunctionToolRelations)
214330
+ subAgentRelations: many(subAgentFunctionToolRelations)
214320
214331
  }));
214321
- var agentFunctionToolRelationsRelations = drizzleOrm.relations(
214322
- agentFunctionToolRelations,
214332
+ var subAgentFunctionToolRelationsRelations = drizzleOrm.relations(
214333
+ subAgentFunctionToolRelations,
214323
214334
  ({ one }) => ({
214324
- agent: one(subAgents, {
214325
- fields: [agentFunctionToolRelations.subAgentId],
214335
+ subAgent: one(subAgents, {
214336
+ fields: [subAgentFunctionToolRelations.subAgentId],
214326
214337
  references: [subAgents.id]
214327
214338
  }),
214328
214339
  functionTool: one(functionTools, {
214329
- fields: [agentFunctionToolRelations.functionToolId],
214340
+ fields: [subAgentFunctionToolRelations.functionToolId],
214330
214341
  references: [functionTools.id]
214331
214342
  })
214332
214343
  })
@@ -216403,12 +216414,12 @@ var getFunctionToolsForSubAgent = (db) => {
216403
216414
  scopes: { tenantId, projectId, agentId },
216404
216415
  pagination: { page: 1, limit: 1e3 }
216405
216416
  });
216406
- const relations2 = await db.select().from(agentFunctionToolRelations).where(
216417
+ const relations2 = await db.select().from(subAgentFunctionToolRelations).where(
216407
216418
  drizzleOrm.and(
216408
- drizzleOrm.eq(agentFunctionToolRelations.tenantId, tenantId),
216409
- drizzleOrm.eq(agentFunctionToolRelations.projectId, projectId),
216410
- drizzleOrm.eq(agentFunctionToolRelations.agentId, agentId),
216411
- drizzleOrm.eq(agentFunctionToolRelations.subAgentId, subAgentId)
216419
+ drizzleOrm.eq(subAgentFunctionToolRelations.tenantId, tenantId),
216420
+ drizzleOrm.eq(subAgentFunctionToolRelations.projectId, projectId),
216421
+ drizzleOrm.eq(subAgentFunctionToolRelations.agentId, agentId),
216422
+ drizzleOrm.eq(subAgentFunctionToolRelations.subAgentId, subAgentId)
216412
216423
  )
216413
216424
  );
216414
216425
  const relatedFunctionToolIds = new Set(relations2.map((r) => r.functionToolId));
@@ -216429,17 +216440,43 @@ var getFunctionToolsForSubAgent = (db) => {
216429
216440
  };
216430
216441
  };
216431
216442
  var upsertSubAgentFunctionToolRelation = (db) => async (params) => {
216432
- if (params.relationId) {
216443
+ const { scopes, subAgentId, functionToolId, relationId } = params;
216444
+ const { tenantId, projectId, agentId } = scopes;
216445
+ if (relationId) {
216433
216446
  return await updateSubAgentFunctionToolRelation(db)({
216434
- scopes: params.scopes,
216435
- relationId: params.relationId,
216447
+ scopes,
216448
+ relationId,
216436
216449
  data: {
216437
- subAgentId: params.subAgentId,
216438
- functionToolId: params.functionToolId
216450
+ subAgentId,
216451
+ functionToolId
216439
216452
  }
216440
216453
  });
216441
216454
  }
216442
- return await addFunctionToolToSubAgent(db)(params);
216455
+ try {
216456
+ const existingRelations = await db.select().from(subAgentFunctionToolRelations).where(
216457
+ drizzleOrm.and(
216458
+ drizzleOrm.eq(subAgentFunctionToolRelations.tenantId, tenantId),
216459
+ drizzleOrm.eq(subAgentFunctionToolRelations.projectId, projectId),
216460
+ drizzleOrm.eq(subAgentFunctionToolRelations.agentId, agentId),
216461
+ drizzleOrm.eq(subAgentFunctionToolRelations.subAgentId, subAgentId),
216462
+ drizzleOrm.eq(subAgentFunctionToolRelations.functionToolId, functionToolId)
216463
+ )
216464
+ ).limit(1);
216465
+ if (existingRelations.length > 0) {
216466
+ logger4.info(
216467
+ { tenantId, projectId, agentId, subAgentId, functionToolId, relationId: existingRelations[0].id },
216468
+ "Sub_agent-function tool relation already exists, returning existing relation"
216469
+ );
216470
+ return { id: existingRelations[0].id };
216471
+ }
216472
+ return await addFunctionToolToSubAgent(db)(params);
216473
+ } catch (error) {
216474
+ logger4.error(
216475
+ { tenantId, projectId, agentId, subAgentId, functionToolId, error },
216476
+ "Failed to upsert sub_agent-function tool relation"
216477
+ );
216478
+ throw error;
216479
+ }
216443
216480
  };
216444
216481
  var addFunctionToolToSubAgent = (db) => {
216445
216482
  return async (params) => {
@@ -216447,7 +216484,7 @@ var addFunctionToolToSubAgent = (db) => {
216447
216484
  const { tenantId, projectId, agentId } = scopes;
216448
216485
  try {
216449
216486
  const relationId = nanoid.nanoid();
216450
- await db.insert(agentFunctionToolRelations).values({
216487
+ await db.insert(subAgentFunctionToolRelations).values({
216451
216488
  id: relationId,
216452
216489
  tenantId,
216453
216490
  projectId,
@@ -216457,7 +216494,7 @@ var addFunctionToolToSubAgent = (db) => {
216457
216494
  });
216458
216495
  logger4.info(
216459
216496
  { tenantId, projectId, agentId, subAgentId, functionToolId, relationId },
216460
- "Function tool added to agent"
216497
+ "Function tool added to sub_agent"
216461
216498
  );
216462
216499
  return { id: relationId };
216463
216500
  } catch (error) {
@@ -216474,20 +216511,20 @@ var updateSubAgentFunctionToolRelation = (db) => {
216474
216511
  const { scopes, relationId, data } = params;
216475
216512
  const { tenantId, projectId, agentId } = scopes;
216476
216513
  try {
216477
- await db.update(agentFunctionToolRelations).set({
216514
+ await db.update(subAgentFunctionToolRelations).set({
216478
216515
  subAgentId: data.subAgentId,
216479
216516
  functionToolId: data.functionToolId
216480
216517
  }).where(
216481
216518
  drizzleOrm.and(
216482
- drizzleOrm.eq(agentFunctionToolRelations.id, relationId),
216483
- drizzleOrm.eq(agentFunctionToolRelations.tenantId, tenantId),
216484
- drizzleOrm.eq(agentFunctionToolRelations.projectId, projectId),
216485
- drizzleOrm.eq(agentFunctionToolRelations.agentId, agentId)
216519
+ drizzleOrm.eq(subAgentFunctionToolRelations.id, relationId),
216520
+ drizzleOrm.eq(subAgentFunctionToolRelations.tenantId, tenantId),
216521
+ drizzleOrm.eq(subAgentFunctionToolRelations.projectId, projectId),
216522
+ drizzleOrm.eq(subAgentFunctionToolRelations.agentId, agentId)
216486
216523
  )
216487
216524
  );
216488
216525
  logger4.info(
216489
216526
  { tenantId, projectId, agentId, relationId, data },
216490
- "Agent-function tool relation updated"
216527
+ "SubAgent-function tool relation updated"
216491
216528
  );
216492
216529
  return { id: relationId };
216493
216530
  } catch (error) {
@@ -218531,21 +218568,21 @@ var getFullAgentDefinition = (db) => async ({
218531
218568
  tenantId: functionTools.tenantId,
218532
218569
  projectId: functionTools.projectId,
218533
218570
  agentId: functionTools.agentId,
218534
- agentToolRelationId: agentFunctionToolRelations.id
218535
- }).from(agentFunctionToolRelations).innerJoin(
218571
+ agentToolRelationId: subAgentFunctionToolRelations.id
218572
+ }).from(subAgentFunctionToolRelations).innerJoin(
218536
218573
  functionTools,
218537
218574
  drizzleOrm.and(
218538
- drizzleOrm.eq(agentFunctionToolRelations.functionToolId, functionTools.id),
218539
- drizzleOrm.eq(agentFunctionToolRelations.tenantId, functionTools.tenantId),
218540
- drizzleOrm.eq(agentFunctionToolRelations.projectId, functionTools.projectId),
218541
- drizzleOrm.eq(agentFunctionToolRelations.agentId, functionTools.agentId)
218575
+ drizzleOrm.eq(subAgentFunctionToolRelations.functionToolId, functionTools.id),
218576
+ drizzleOrm.eq(subAgentFunctionToolRelations.tenantId, functionTools.tenantId),
218577
+ drizzleOrm.eq(subAgentFunctionToolRelations.projectId, functionTools.projectId),
218578
+ drizzleOrm.eq(subAgentFunctionToolRelations.agentId, functionTools.agentId)
218542
218579
  )
218543
218580
  ).where(
218544
218581
  drizzleOrm.and(
218545
- drizzleOrm.eq(agentFunctionToolRelations.tenantId, tenantId),
218546
- drizzleOrm.eq(agentFunctionToolRelations.projectId, projectId),
218547
- drizzleOrm.eq(agentFunctionToolRelations.agentId, agentId),
218548
- drizzleOrm.eq(agentFunctionToolRelations.subAgentId, agent2.id)
218582
+ drizzleOrm.eq(subAgentFunctionToolRelations.tenantId, tenantId),
218583
+ drizzleOrm.eq(subAgentFunctionToolRelations.projectId, projectId),
218584
+ drizzleOrm.eq(subAgentFunctionToolRelations.agentId, agentId),
218585
+ drizzleOrm.eq(subAgentFunctionToolRelations.subAgentId, agent2.id)
218549
218586
  )
218550
218587
  );
218551
218588
  const agentDataComponentRelations = await db.query.subAgentDataComponents.findMany({
@@ -225390,8 +225427,6 @@ exports.VALID_RELATION_TYPES = VALID_RELATION_TYPES;
225390
225427
  exports.addFunctionToolToSubAgent = addFunctionToolToSubAgent;
225391
225428
  exports.addLedgerArtifacts = addLedgerArtifacts;
225392
225429
  exports.addToolToAgent = addToolToAgent;
225393
- exports.agentFunctionToolRelations = agentFunctionToolRelations;
225394
- exports.agentFunctionToolRelationsRelations = agentFunctionToolRelationsRelations;
225395
225430
  exports.agentHasArtifactComponents = agentHasArtifactComponents;
225396
225431
  exports.agentRelations = agentRelations;
225397
225432
  exports.agentToolRelationsRelations = agentToolRelationsRelations;
@@ -225638,6 +225673,8 @@ exports.subAgentArtifactComponents = subAgentArtifactComponents;
225638
225673
  exports.subAgentArtifactComponentsRelations = subAgentArtifactComponentsRelations;
225639
225674
  exports.subAgentDataComponents = subAgentDataComponents;
225640
225675
  exports.subAgentDataComponentsRelations = subAgentDataComponentsRelations;
225676
+ exports.subAgentFunctionToolRelations = subAgentFunctionToolRelations;
225677
+ exports.subAgentFunctionToolRelationsRelations = subAgentFunctionToolRelationsRelations;
225641
225678
  exports.subAgentRelations = subAgentRelations;
225642
225679
  exports.subAgentRelationsRelations = subAgentRelationsRelations;
225643
225680
  exports.subAgentToolRelations = subAgentToolRelations;
package/dist/index.d.cts CHANGED
@@ -6,8 +6,8 @@ export { ba as A2AError, bG as A2ARequest, bH as A2AResponse, aL as APIKeySecuri
6
6
  import { CredentialStore } from './types/index.cjs';
7
7
  export { CorsConfig, ServerConfig, ServerOptions } from './types/index.cjs';
8
8
  import { LibSQLDatabase } from 'drizzle-orm/libsql';
9
- import { s as schema } from './schema-CcSN2XcZ.cjs';
10
- export { q as agentFunctionToolRelations, U as agentFunctionToolRelationsRelations, E as agentRelations, H as agentToolRelationsRelations, a as agents, w as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, r as conversations, K as conversationsRelations, x as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, m as functionTools, T as functionToolsRelations, n as functions, R as functionsRelations, v as ledgerArtifacts, Q as ledgerArtifactsRelations, u as messages, L as messagesRelations, p as projects, z as projectsRelations, k as subAgentArtifactComponents, N as subAgentArtifactComponentsRelations, i as subAgentDataComponents, P as subAgentDataComponentsRelations, e as subAgentRelations, S as subAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, D as subAgentsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from './schema-CcSN2XcZ.cjs';
9
+ import { s as schema } from './schema-BjQKqtdC.cjs';
10
+ export { E as agentRelations, H as agentToolRelationsRelations, a as agents, w as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, r as conversations, K as conversationsRelations, x as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, m as functionTools, T as functionToolsRelations, n as functions, R as functionsRelations, v as ledgerArtifacts, Q as ledgerArtifactsRelations, u as messages, L as messagesRelations, p as projects, z as projectsRelations, k as subAgentArtifactComponents, N as subAgentArtifactComponentsRelations, i as subAgentDataComponents, P as subAgentDataComponentsRelations, q as subAgentFunctionToolRelations, U as subAgentFunctionToolRelationsRelations, e as subAgentRelations, S as subAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, D as subAgentsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from './schema-BjQKqtdC.cjs';
11
11
  import { LoggerOptions, TransportSingleOptions, Logger } from 'pino';
12
12
  import { SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
13
13
  import { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
@@ -2153,7 +2153,7 @@ declare const getFunctionToolsForSubAgent: (db: DatabaseClient) => (params: {
2153
2153
  };
2154
2154
  }>;
2155
2155
  /**
2156
- * Upsert an agent-function tool relation (create if it doesn't exist, update if it does)
2156
+ * Upsert a sub_agent-function tool relation (create if it doesn't exist, update if it does)
2157
2157
  */
2158
2158
  declare const upsertSubAgentFunctionToolRelation: (db: DatabaseClient) => (params: {
2159
2159
  scopes: AgentScopeConfig;
@@ -3491,14 +3491,7 @@ declare function isValidHttpRequest(obj: any): obj is ParsedHttpRequest;
3491
3491
  declare function getCachedValidator(schema: Record<string, unknown>): ValidateFunction;
3492
3492
  declare function validationHelper(jsonSchema: Record<string, unknown>): ValidateFunction<unknown>;
3493
3493
  declare function validateAgainstJsonSchema(jsonSchema: Record<string, unknown>, context: unknown): boolean;
3494
- /**
3495
- * Validates HTTP request headers against schema
3496
- */
3497
3494
  declare function validateHttpRequestHeaders(headersSchema: any, httpRequest: ParsedHttpRequest): Promise<ContextValidationResult>;
3498
- /**
3499
- * Validates headers against the JSON Schema stored in context configuration
3500
- * Supports both legacy simple schemas and new comprehensive HTTP request schemas
3501
- */
3502
3495
  declare function validateHeaders({ tenantId, projectId, agentId, conversationId, parsedRequest, dbClient, credentialStores, }: {
3503
3496
  tenantId: string;
3504
3497
  projectId: string;
@@ -3508,9 +3501,6 @@ declare function validateHeaders({ tenantId, projectId, agentId, conversationId,
3508
3501
  dbClient: DatabaseClient;
3509
3502
  credentialStores?: CredentialStoreRegistry;
3510
3503
  }): Promise<ContextValidationResult>;
3511
- /**
3512
- * Hono middleware for context validation
3513
- */
3514
3504
  declare function contextValidationMiddleware(dbClient: DatabaseClient): (c: Context, next: Next) => Promise<void>;
3515
3505
 
3516
3506
  type ApiKeyGenerationResult = {
package/dist/index.d.ts CHANGED
@@ -6,8 +6,8 @@ export { ba as A2AError, bG as A2ARequest, bH as A2AResponse, aL as APIKeySecuri
6
6
  import { CredentialStore } from './types/index.js';
7
7
  export { CorsConfig, ServerConfig, ServerOptions } from './types/index.js';
8
8
  import { LibSQLDatabase } from 'drizzle-orm/libsql';
9
- import { s as schema } from './schema-D8h85qdU.js';
10
- export { q as agentFunctionToolRelations, U as agentFunctionToolRelationsRelations, E as agentRelations, H as agentToolRelationsRelations, a as agents, w as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, r as conversations, K as conversationsRelations, x as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, m as functionTools, T as functionToolsRelations, n as functions, R as functionsRelations, v as ledgerArtifacts, Q as ledgerArtifactsRelations, u as messages, L as messagesRelations, p as projects, z as projectsRelations, k as subAgentArtifactComponents, N as subAgentArtifactComponentsRelations, i as subAgentDataComponents, P as subAgentDataComponentsRelations, e as subAgentRelations, S as subAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, D as subAgentsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from './schema-D8h85qdU.js';
9
+ import { s as schema } from './schema-DylNIx0j.js';
10
+ export { E as agentRelations, H as agentToolRelationsRelations, a as agents, w as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, r as conversations, K as conversationsRelations, x as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, m as functionTools, T as functionToolsRelations, n as functions, R as functionsRelations, v as ledgerArtifacts, Q as ledgerArtifactsRelations, u as messages, L as messagesRelations, p as projects, z as projectsRelations, k as subAgentArtifactComponents, N as subAgentArtifactComponentsRelations, i as subAgentDataComponents, P as subAgentDataComponentsRelations, q as subAgentFunctionToolRelations, U as subAgentFunctionToolRelationsRelations, e as subAgentRelations, S as subAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, D as subAgentsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from './schema-DylNIx0j.js';
11
11
  import { LoggerOptions, TransportSingleOptions, Logger } from 'pino';
12
12
  import { SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
13
13
  import { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
@@ -2153,7 +2153,7 @@ declare const getFunctionToolsForSubAgent: (db: DatabaseClient) => (params: {
2153
2153
  };
2154
2154
  }>;
2155
2155
  /**
2156
- * Upsert an agent-function tool relation (create if it doesn't exist, update if it does)
2156
+ * Upsert a sub_agent-function tool relation (create if it doesn't exist, update if it does)
2157
2157
  */
2158
2158
  declare const upsertSubAgentFunctionToolRelation: (db: DatabaseClient) => (params: {
2159
2159
  scopes: AgentScopeConfig;
@@ -3491,14 +3491,7 @@ declare function isValidHttpRequest(obj: any): obj is ParsedHttpRequest;
3491
3491
  declare function getCachedValidator(schema: Record<string, unknown>): ValidateFunction;
3492
3492
  declare function validationHelper(jsonSchema: Record<string, unknown>): ValidateFunction<unknown>;
3493
3493
  declare function validateAgainstJsonSchema(jsonSchema: Record<string, unknown>, context: unknown): boolean;
3494
- /**
3495
- * Validates HTTP request headers against schema
3496
- */
3497
3494
  declare function validateHttpRequestHeaders(headersSchema: any, httpRequest: ParsedHttpRequest): Promise<ContextValidationResult>;
3498
- /**
3499
- * Validates headers against the JSON Schema stored in context configuration
3500
- * Supports both legacy simple schemas and new comprehensive HTTP request schemas
3501
- */
3502
3495
  declare function validateHeaders({ tenantId, projectId, agentId, conversationId, parsedRequest, dbClient, credentialStores, }: {
3503
3496
  tenantId: string;
3504
3497
  projectId: string;
@@ -3508,9 +3501,6 @@ declare function validateHeaders({ tenantId, projectId, agentId, conversationId,
3508
3501
  dbClient: DatabaseClient;
3509
3502
  credentialStores?: CredentialStoreRegistry;
3510
3503
  }): Promise<ContextValidationResult>;
3511
- /**
3512
- * Hono middleware for context validation
3513
- */
3514
3504
  declare function contextValidationMiddleware(dbClient: DatabaseClient): (c: Context, next: Next) => Promise<void>;
3515
3505
 
3516
3506
  type ApiKeyGenerationResult = {
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, DATA_SOURCES, DATA_TYPES, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, FIELD_TYPES, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, UNKNOWN_VALUE } from './chunk-QFIITHNT.js';
2
- export { ANTHROPIC_MODELS, GOOGLE_MODELS, OPENAI_MODELS } from './chunk-LZJWVTQ2.js';
2
+ export { ANTHROPIC_MODELS, GOOGLE_MODELS, OPENAI_MODELS } from './chunk-TTIPV5QP.js';
3
+ export { TaskState } from './chunk-H2F72PDA.js';
3
4
  import { getLogger, convertZodToJsonSchema } from './chunk-YECQCT5N.js';
4
5
  export { PinoLogger, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, getLogger, isZodSchema, loggerFactory, preview } from './chunk-YECQCT5N.js';
5
- import { validateAndTypeAgentData, validateAgentStructure, isInternalAgent, isExternalAgent } from './chunk-4FMDWUE4.js';
6
- export { A2AMessageMetadataSchema, DataOperationDetailsSchema, DataOperationEventSchema, DelegationReturnedDataSchema, DelegationSentDataSchema, TransferDataSchema, generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAgentStructure, validateAndTypeAgentData, validateArtifactComponentReferences, validateDataComponentReferences, validateToolReferences } from './chunk-4FMDWUE4.js';
7
- import { ContextConfigApiUpdateSchema, validatePropsAsJsonSchema } from './chunk-VICWT3WO.js';
8
- export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentInsertSchema, AgentListResponse, AgentResponse, AgentSelectSchema, AgentStopWhenSchema, AgentUpdateSchema, AgentWithinContextOfProjectSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeyListResponse, ApiKeyResponse, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentListResponse, ArtifactComponentResponse, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, CanUseItemSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigListResponse, ContextConfigResponse, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationListResponse, ConversationResponse, ConversationSelectSchema, ConversationUpdateSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceListResponse, CredentialReferenceResponse, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentListResponse, DataComponentResponse, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentListResponse, ExternalAgentResponse, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, ExternalSubAgentRelationApiInsertSchema, ExternalSubAgentRelationInsertSchema, FetchConfigSchema, FetchDefinitionSchema, FullAgentAgentInsertSchema, FullProjectDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, FunctionInsertSchema, FunctionListResponse, FunctionResponse, FunctionSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiSelectSchema, FunctionToolApiUpdateSchema, FunctionToolConfigSchema, FunctionToolInsertSchema, FunctionToolListResponse, FunctionToolResponse, FunctionToolSelectSchema, FunctionToolUpdateSchema, FunctionUpdateSchema, HeadersScopeSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageListResponse, MessageResponse, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectListResponse, ProjectModelSchema, ProjectResponse, ProjectSelectSchema, ProjectUpdateSchema, RemovedResponseSchema, SandboxConfigSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, SubAgentApiInsertSchema, SubAgentApiSelectSchema, SubAgentApiUpdateSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiUpdateSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentListResponse, SubAgentArtifactComponentResponse, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentUpdateSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiUpdateSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentListResponse, SubAgentDataComponentResponse, SubAgentDataComponentSelectSchema, SubAgentDataComponentUpdateSchema, SubAgentInsertSchema, SubAgentListResponse, SubAgentRelationApiInsertSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationInsertSchema, SubAgentRelationListResponse, SubAgentRelationQuerySchema, SubAgentRelationResponse, SubAgentRelationSelectSchema, SubAgentRelationUpdateSchema, SubAgentResponse, SubAgentSelectSchema, SubAgentStopWhenSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationListResponse, SubAgentToolRelationResponse, SubAgentToolRelationSelectSchema, SubAgentToolRelationUpdateSchema, SubAgentUpdateSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TenantProjectAgentSubAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolListResponse, ToolResponse, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema, validatePropsAsJsonSchema } from './chunk-VICWT3WO.js';
9
- import { schema_exports, contextConfigs, externalAgents, functions, functionTools, agentFunctionToolRelations, subAgentRelations, subAgents, subAgentToolRelations, tools, credentialReferences, agents, subAgentDataComponents, subAgentArtifactComponents, dataComponents, artifactComponents, projects, apiKeys, contextCache, conversations, messages, ledgerArtifacts, tasks, taskRelations } from './chunk-B6F3RF4T.js';
10
- export { agentFunctionToolRelations, agentFunctionToolRelationsRelations, agentRelations, agentToolRelationsRelations, agents, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, functionTools, functionToolsRelations, functions, functionsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, subAgentArtifactComponents, subAgentArtifactComponentsRelations, subAgentDataComponents, subAgentDataComponentsRelations, subAgentRelations, subAgentRelationsRelations, subAgentToolRelations, subAgents, subAgentsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from './chunk-B6F3RF4T.js';
11
- export { TaskState } from './chunk-H2F72PDA.js';
6
+ import { validateAndTypeAgentData, validateAgentStructure, isInternalAgent, isExternalAgent } from './chunk-VTNB6CCI.js';
7
+ export { A2AMessageMetadataSchema, DataOperationDetailsSchema, DataOperationEventSchema, DelegationReturnedDataSchema, DelegationSentDataSchema, TransferDataSchema, generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAgentStructure, validateAndTypeAgentData, validateArtifactComponentReferences, validateDataComponentReferences, validateToolReferences } from './chunk-VTNB6CCI.js';
8
+ import { ContextConfigApiUpdateSchema, validatePropsAsJsonSchema } from './chunk-RCE4G7BW.js';
9
+ export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentInsertSchema, AgentListResponse, AgentResponse, AgentSelectSchema, AgentStopWhenSchema, AgentUpdateSchema, AgentWithinContextOfProjectSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeyListResponse, ApiKeyResponse, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentListResponse, ArtifactComponentResponse, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, CanUseItemSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigListResponse, ContextConfigResponse, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationListResponse, ConversationResponse, ConversationSelectSchema, ConversationUpdateSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceListResponse, CredentialReferenceResponse, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentListResponse, DataComponentResponse, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentListResponse, ExternalAgentResponse, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, ExternalSubAgentRelationApiInsertSchema, ExternalSubAgentRelationInsertSchema, FetchConfigSchema, FetchDefinitionSchema, FullAgentAgentInsertSchema, FullProjectDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, FunctionInsertSchema, FunctionListResponse, FunctionResponse, FunctionSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiSelectSchema, FunctionToolApiUpdateSchema, FunctionToolConfigSchema, FunctionToolInsertSchema, FunctionToolListResponse, FunctionToolResponse, FunctionToolSelectSchema, FunctionToolUpdateSchema, FunctionUpdateSchema, HeadersScopeSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageListResponse, MessageResponse, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectListResponse, ProjectModelSchema, ProjectResponse, ProjectSelectSchema, ProjectUpdateSchema, RemovedResponseSchema, SandboxConfigSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, SubAgentApiInsertSchema, SubAgentApiSelectSchema, SubAgentApiUpdateSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiUpdateSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentListResponse, SubAgentArtifactComponentResponse, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentUpdateSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiUpdateSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentListResponse, SubAgentDataComponentResponse, SubAgentDataComponentSelectSchema, SubAgentDataComponentUpdateSchema, SubAgentInsertSchema, SubAgentListResponse, SubAgentRelationApiInsertSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationInsertSchema, SubAgentRelationListResponse, SubAgentRelationQuerySchema, SubAgentRelationResponse, SubAgentRelationSelectSchema, SubAgentRelationUpdateSchema, SubAgentResponse, SubAgentSelectSchema, SubAgentStopWhenSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationListResponse, SubAgentToolRelationResponse, SubAgentToolRelationSelectSchema, SubAgentToolRelationUpdateSchema, SubAgentUpdateSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TenantProjectAgentSubAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolListResponse, ToolResponse, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema, validatePropsAsJsonSchema } from './chunk-RCE4G7BW.js';
10
+ import { schema_exports, contextConfigs, externalAgents, functions, functionTools, subAgentFunctionToolRelations, subAgentRelations, subAgents, subAgentToolRelations, tools, credentialReferences, agents, subAgentDataComponents, subAgentArtifactComponents, dataComponents, artifactComponents, projects, apiKeys, contextCache, conversations, messages, ledgerArtifacts, tasks, taskRelations } from './chunk-7GKB2SDR.js';
11
+ export { agentRelations, agentToolRelationsRelations, agents, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, functionTools, functionToolsRelations, functions, functionsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, subAgentArtifactComponents, subAgentArtifactComponentsRelations, subAgentDataComponents, subAgentDataComponentsRelations, subAgentFunctionToolRelations, subAgentFunctionToolRelationsRelations, subAgentRelations, subAgentRelationsRelations, subAgentToolRelations, subAgents, subAgentsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from './chunk-7GKB2SDR.js';
12
12
  import { CredentialStoreType, MCPServerType, MCPTransportType } from './chunk-YFHT5M2R.js';
13
13
  export { CredentialStoreType, MCPServerType, MCPTransportType, TOOL_STATUS_VALUES, VALID_RELATION_TYPES } from './chunk-YFHT5M2R.js';
14
14
  import { __commonJS, __require, __publicField } from './chunk-E6R6PML7.js';
@@ -214114,12 +214114,12 @@ var getFunctionToolsForSubAgent = (db) => {
214114
214114
  scopes: { tenantId, projectId, agentId },
214115
214115
  pagination: { page: 1, limit: 1e3 }
214116
214116
  });
214117
- const relations = await db.select().from(agentFunctionToolRelations).where(
214117
+ const relations = await db.select().from(subAgentFunctionToolRelations).where(
214118
214118
  and(
214119
- eq(agentFunctionToolRelations.tenantId, tenantId),
214120
- eq(agentFunctionToolRelations.projectId, projectId),
214121
- eq(agentFunctionToolRelations.agentId, agentId),
214122
- eq(agentFunctionToolRelations.subAgentId, subAgentId)
214119
+ eq(subAgentFunctionToolRelations.tenantId, tenantId),
214120
+ eq(subAgentFunctionToolRelations.projectId, projectId),
214121
+ eq(subAgentFunctionToolRelations.agentId, agentId),
214122
+ eq(subAgentFunctionToolRelations.subAgentId, subAgentId)
214123
214123
  )
214124
214124
  );
214125
214125
  const relatedFunctionToolIds = new Set(relations.map((r) => r.functionToolId));
@@ -214140,17 +214140,43 @@ var getFunctionToolsForSubAgent = (db) => {
214140
214140
  };
214141
214141
  };
214142
214142
  var upsertSubAgentFunctionToolRelation = (db) => async (params) => {
214143
- if (params.relationId) {
214143
+ const { scopes, subAgentId, functionToolId, relationId } = params;
214144
+ const { tenantId, projectId, agentId } = scopes;
214145
+ if (relationId) {
214144
214146
  return await updateSubAgentFunctionToolRelation(db)({
214145
- scopes: params.scopes,
214146
- relationId: params.relationId,
214147
+ scopes,
214148
+ relationId,
214147
214149
  data: {
214148
- subAgentId: params.subAgentId,
214149
- functionToolId: params.functionToolId
214150
+ subAgentId,
214151
+ functionToolId
214150
214152
  }
214151
214153
  });
214152
214154
  }
214153
- return await addFunctionToolToSubAgent(db)(params);
214155
+ try {
214156
+ const existingRelations = await db.select().from(subAgentFunctionToolRelations).where(
214157
+ and(
214158
+ eq(subAgentFunctionToolRelations.tenantId, tenantId),
214159
+ eq(subAgentFunctionToolRelations.projectId, projectId),
214160
+ eq(subAgentFunctionToolRelations.agentId, agentId),
214161
+ eq(subAgentFunctionToolRelations.subAgentId, subAgentId),
214162
+ eq(subAgentFunctionToolRelations.functionToolId, functionToolId)
214163
+ )
214164
+ ).limit(1);
214165
+ if (existingRelations.length > 0) {
214166
+ logger3.info(
214167
+ { tenantId, projectId, agentId, subAgentId, functionToolId, relationId: existingRelations[0].id },
214168
+ "Sub_agent-function tool relation already exists, returning existing relation"
214169
+ );
214170
+ return { id: existingRelations[0].id };
214171
+ }
214172
+ return await addFunctionToolToSubAgent(db)(params);
214173
+ } catch (error) {
214174
+ logger3.error(
214175
+ { tenantId, projectId, agentId, subAgentId, functionToolId, error },
214176
+ "Failed to upsert sub_agent-function tool relation"
214177
+ );
214178
+ throw error;
214179
+ }
214154
214180
  };
214155
214181
  var addFunctionToolToSubAgent = (db) => {
214156
214182
  return async (params) => {
@@ -214158,7 +214184,7 @@ var addFunctionToolToSubAgent = (db) => {
214158
214184
  const { tenantId, projectId, agentId } = scopes;
214159
214185
  try {
214160
214186
  const relationId = nanoid();
214161
- await db.insert(agentFunctionToolRelations).values({
214187
+ await db.insert(subAgentFunctionToolRelations).values({
214162
214188
  id: relationId,
214163
214189
  tenantId,
214164
214190
  projectId,
@@ -214168,7 +214194,7 @@ var addFunctionToolToSubAgent = (db) => {
214168
214194
  });
214169
214195
  logger3.info(
214170
214196
  { tenantId, projectId, agentId, subAgentId, functionToolId, relationId },
214171
- "Function tool added to agent"
214197
+ "Function tool added to sub_agent"
214172
214198
  );
214173
214199
  return { id: relationId };
214174
214200
  } catch (error) {
@@ -214185,20 +214211,20 @@ var updateSubAgentFunctionToolRelation = (db) => {
214185
214211
  const { scopes, relationId, data } = params;
214186
214212
  const { tenantId, projectId, agentId } = scopes;
214187
214213
  try {
214188
- await db.update(agentFunctionToolRelations).set({
214214
+ await db.update(subAgentFunctionToolRelations).set({
214189
214215
  subAgentId: data.subAgentId,
214190
214216
  functionToolId: data.functionToolId
214191
214217
  }).where(
214192
214218
  and(
214193
- eq(agentFunctionToolRelations.id, relationId),
214194
- eq(agentFunctionToolRelations.tenantId, tenantId),
214195
- eq(agentFunctionToolRelations.projectId, projectId),
214196
- eq(agentFunctionToolRelations.agentId, agentId)
214219
+ eq(subAgentFunctionToolRelations.id, relationId),
214220
+ eq(subAgentFunctionToolRelations.tenantId, tenantId),
214221
+ eq(subAgentFunctionToolRelations.projectId, projectId),
214222
+ eq(subAgentFunctionToolRelations.agentId, agentId)
214197
214223
  )
214198
214224
  );
214199
214225
  logger3.info(
214200
214226
  { tenantId, projectId, agentId, relationId, data },
214201
- "Agent-function tool relation updated"
214227
+ "SubAgent-function tool relation updated"
214202
214228
  );
214203
214229
  return { id: relationId };
214204
214230
  } catch (error) {
@@ -216242,21 +216268,21 @@ var getFullAgentDefinition = (db) => async ({
216242
216268
  tenantId: functionTools.tenantId,
216243
216269
  projectId: functionTools.projectId,
216244
216270
  agentId: functionTools.agentId,
216245
- agentToolRelationId: agentFunctionToolRelations.id
216246
- }).from(agentFunctionToolRelations).innerJoin(
216271
+ agentToolRelationId: subAgentFunctionToolRelations.id
216272
+ }).from(subAgentFunctionToolRelations).innerJoin(
216247
216273
  functionTools,
216248
216274
  and(
216249
- eq(agentFunctionToolRelations.functionToolId, functionTools.id),
216250
- eq(agentFunctionToolRelations.tenantId, functionTools.tenantId),
216251
- eq(agentFunctionToolRelations.projectId, functionTools.projectId),
216252
- eq(agentFunctionToolRelations.agentId, functionTools.agentId)
216275
+ eq(subAgentFunctionToolRelations.functionToolId, functionTools.id),
216276
+ eq(subAgentFunctionToolRelations.tenantId, functionTools.tenantId),
216277
+ eq(subAgentFunctionToolRelations.projectId, functionTools.projectId),
216278
+ eq(subAgentFunctionToolRelations.agentId, functionTools.agentId)
216253
216279
  )
216254
216280
  ).where(
216255
216281
  and(
216256
- eq(agentFunctionToolRelations.tenantId, tenantId),
216257
- eq(agentFunctionToolRelations.projectId, projectId),
216258
- eq(agentFunctionToolRelations.agentId, agentId),
216259
- eq(agentFunctionToolRelations.subAgentId, agent2.id)
216282
+ eq(subAgentFunctionToolRelations.tenantId, tenantId),
216283
+ eq(subAgentFunctionToolRelations.projectId, projectId),
216284
+ eq(subAgentFunctionToolRelations.agentId, agentId),
216285
+ eq(subAgentFunctionToolRelations.subAgentId, agent2.id)
216260
216286
  )
216261
216287
  );
216262
216288
  const agentDataComponentRelations = await db.query.subAgentDataComponents.findMany({