@inkeep/agents-core 0.0.0-dev-20251010175818 → 0.0.0-dev-20251010180500

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
@@ -465,22 +465,22 @@ var LoggerFactory = class {
465
465
  */
466
466
  getLogger(name) {
467
467
  if (this.loggers.has(name)) {
468
- const logger14 = this.loggers.get(name);
469
- if (!logger14) {
468
+ const logger15 = this.loggers.get(name);
469
+ if (!logger15) {
470
470
  throw new Error(`Logger '${name}' not found in cache`);
471
471
  }
472
- return logger14;
472
+ return logger15;
473
473
  }
474
- let logger13;
474
+ let logger14;
475
475
  if (this.config.loggerFactory) {
476
- logger13 = this.config.loggerFactory(name);
476
+ logger14 = this.config.loggerFactory(name);
477
477
  } else if (this.config.defaultLogger) {
478
- logger13 = this.config.defaultLogger;
478
+ logger14 = this.config.defaultLogger;
479
479
  } else {
480
- logger13 = new PinoLogger(name, this.config.pinoConfig);
480
+ logger14 = new PinoLogger(name, this.config.pinoConfig);
481
481
  }
482
- this.loggers.set(name, logger13);
483
- return logger13;
482
+ this.loggers.set(name, logger14);
483
+ return logger14;
484
484
  }
485
485
  /**
486
486
  * Reset factory to default state
@@ -556,6 +556,8 @@ function extractPreviewFields(schema) {
556
556
  // src/db/schema.ts
557
557
  var schema_exports = {};
558
558
  __export(schema_exports, {
559
+ agentFunctionToolRelations: () => agentFunctionToolRelations,
560
+ agentFunctionToolRelationsRelations: () => agentFunctionToolRelationsRelations,
559
561
  agentGraph: () => agentGraph,
560
562
  agentGraphRelations: () => agentGraphRelations,
561
563
  agentToolRelationsRelations: () => agentToolRelationsRelations,
@@ -575,6 +577,8 @@ __export(schema_exports, {
575
577
  dataComponentsRelations: () => dataComponentsRelations,
576
578
  externalAgents: () => externalAgents,
577
579
  externalAgentsRelations: () => externalAgentsRelations,
580
+ functionTools: () => functionTools,
581
+ functionToolsRelations: () => functionToolsRelations,
578
582
  functions: () => functions,
579
583
  functionsRelations: () => functionsRelations,
580
584
  ledgerArtifacts: () => ledgerArtifacts,
@@ -925,10 +929,7 @@ var tools = sqliteCore.sqliteTable(
925
929
  ...projectScoped,
926
930
  name: sqliteCore.text("name").notNull(),
927
931
  description: sqliteCore.text("description"),
928
- // Tool configuration - supports both MCP and function tools
929
932
  config: sqliteCore.blob("config", { mode: "json" }).$type().notNull(),
930
- // For function tools, reference the global functions table
931
- functionId: sqliteCore.text("function_id"),
932
933
  credentialReferenceId: sqliteCore.text("credential_reference_id"),
933
934
  headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
934
935
  // Image URL for custom tool icon (supports regular URLs and base64 encoded images)
@@ -944,12 +945,30 @@ var tools = sqliteCore.sqliteTable(
944
945
  columns: [table.tenantId, table.projectId],
945
946
  foreignColumns: [projects.tenantId, projects.id],
946
947
  name: "tools_project_fk"
948
+ }).onDelete("cascade")
949
+ ]
950
+ );
951
+ var functionTools = sqliteCore.sqliteTable(
952
+ "function_tools",
953
+ {
954
+ ...graphScoped,
955
+ name: sqliteCore.text("name").notNull(),
956
+ description: sqliteCore.text("description"),
957
+ functionId: sqliteCore.text("function_id").notNull(),
958
+ ...timestamps
959
+ },
960
+ (table) => [
961
+ sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
962
+ sqliteCore.foreignKey({
963
+ columns: [table.tenantId, table.projectId, table.graphId],
964
+ foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
965
+ name: "function_tools_graph_fk"
947
966
  }).onDelete("cascade"),
948
- // Foreign key constraint to functions table (for function tools)
967
+ // Foreign key constraint to functions table
949
968
  sqliteCore.foreignKey({
950
969
  columns: [table.tenantId, table.projectId, table.functionId],
951
970
  foreignColumns: [functions.tenantId, functions.projectId, functions.id],
952
- name: "tools_function_fk"
971
+ name: "function_tools_function_fk"
953
972
  }).onDelete("cascade")
954
973
  ]
955
974
  );
@@ -988,7 +1007,7 @@ var subAgentToolRelations = sqliteCore.sqliteTable(
988
1007
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
989
1008
  name: "sub_agent_tool_relations_agent_fk"
990
1009
  }).onDelete("cascade"),
991
- // Foreign key constraint to tools table
1010
+ // Foreign key constraint to tools table (MCP tools)
992
1011
  sqliteCore.foreignKey({
993
1012
  columns: [table.tenantId, table.projectId, table.toolId],
994
1013
  foreignColumns: [tools.tenantId, tools.projectId, tools.id],
@@ -996,6 +1015,34 @@ var subAgentToolRelations = sqliteCore.sqliteTable(
996
1015
  }).onDelete("cascade")
997
1016
  ]
998
1017
  );
1018
+ var agentFunctionToolRelations = sqliteCore.sqliteTable(
1019
+ "agent_function_tool_relations",
1020
+ {
1021
+ ...subAgentScoped,
1022
+ functionToolId: sqliteCore.text("function_tool_id").notNull(),
1023
+ ...timestamps
1024
+ },
1025
+ (table) => [
1026
+ sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
1027
+ // Foreign key constraint to agents table
1028
+ sqliteCore.foreignKey({
1029
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
1030
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
1031
+ name: "agent_function_tool_relations_agent_fk"
1032
+ }).onDelete("cascade"),
1033
+ // Foreign key constraint to functionTools table
1034
+ sqliteCore.foreignKey({
1035
+ columns: [table.tenantId, table.projectId, table.graphId, table.functionToolId],
1036
+ foreignColumns: [
1037
+ functionTools.tenantId,
1038
+ functionTools.projectId,
1039
+ functionTools.graphId,
1040
+ functionTools.id
1041
+ ],
1042
+ name: "agent_function_tool_relations_function_tool_fk"
1043
+ }).onDelete("cascade")
1044
+ ]
1045
+ );
999
1046
  var conversations = sqliteCore.sqliteTable(
1000
1047
  "conversations",
1001
1048
  {
@@ -1181,6 +1228,7 @@ var projectsRelations = drizzleOrm.relations(projects, ({ many }) => ({
1181
1228
  subAgents: many(subAgents),
1182
1229
  agentGraphs: many(agentGraph),
1183
1230
  tools: many(tools),
1231
+ functions: many(functions),
1184
1232
  contextConfigs: many(contextConfigs),
1185
1233
  externalAgents: many(externalAgents),
1186
1234
  conversations: many(conversations),
@@ -1239,10 +1287,11 @@ var subAgentsRelations = drizzleOrm.relations(subAgents, ({ many, one }) => ({
1239
1287
  relationName: "associatedAgent"
1240
1288
  }),
1241
1289
  toolRelations: many(subAgentToolRelations),
1290
+ functionToolRelations: many(agentFunctionToolRelations),
1242
1291
  dataComponentRelations: many(subAgentDataComponents),
1243
1292
  artifactComponentRelations: many(subAgentArtifactComponents)
1244
1293
  }));
1245
- var agentGraphRelations = drizzleOrm.relations(agentGraph, ({ one }) => ({
1294
+ var agentGraphRelations = drizzleOrm.relations(agentGraph, ({ one, many }) => ({
1246
1295
  project: one(projects, {
1247
1296
  fields: [agentGraph.tenantId, agentGraph.projectId],
1248
1297
  references: [projects.tenantId, projects.id]
@@ -1254,7 +1303,8 @@ var agentGraphRelations = drizzleOrm.relations(agentGraph, ({ one }) => ({
1254
1303
  contextConfig: one(contextConfigs, {
1255
1304
  fields: [agentGraph.contextConfigId],
1256
1305
  references: [contextConfigs.id]
1257
- })
1306
+ }),
1307
+ functionTools: many(functionTools)
1258
1308
  }));
1259
1309
  var externalAgentsRelations = drizzleOrm.relations(externalAgents, ({ one, many }) => ({
1260
1310
  project: one(projects, {
@@ -1299,10 +1349,6 @@ var toolsRelations = drizzleOrm.relations(tools, ({ one, many }) => ({
1299
1349
  credentialReference: one(credentialReferences, {
1300
1350
  fields: [tools.credentialReferenceId],
1301
1351
  references: [credentialReferences.id]
1302
- }),
1303
- function: one(functions, {
1304
- fields: [tools.functionId],
1305
- references: [functions.id]
1306
1352
  })
1307
1353
  }));
1308
1354
  var conversationsRelations = drizzleOrm.relations(conversations, ({ one, many }) => ({
@@ -1402,7 +1448,7 @@ var ledgerArtifactsRelations = drizzleOrm.relations(ledgerArtifacts, ({ one }) =
1402
1448
  })
1403
1449
  }));
1404
1450
  var functionsRelations = drizzleOrm.relations(functions, ({ many }) => ({
1405
- tools: many(tools)
1451
+ functionTools: many(functionTools)
1406
1452
  }));
1407
1453
  var subAgentRelationsRelations = drizzleOrm.relations(subAgentRelations, ({ one }) => ({
1408
1454
  graph: one(agentGraph, {
@@ -1424,6 +1470,34 @@ var subAgentRelationsRelations = drizzleOrm.relations(subAgentRelations, ({ one
1424
1470
  references: [externalAgents.id]
1425
1471
  })
1426
1472
  }));
1473
+ var functionToolsRelations = drizzleOrm.relations(functionTools, ({ one, many }) => ({
1474
+ project: one(projects, {
1475
+ fields: [functionTools.tenantId, functionTools.projectId],
1476
+ references: [projects.tenantId, projects.id]
1477
+ }),
1478
+ graph: one(agentGraph, {
1479
+ fields: [functionTools.tenantId, functionTools.projectId, functionTools.graphId],
1480
+ references: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id]
1481
+ }),
1482
+ function: one(functions, {
1483
+ fields: [functionTools.tenantId, functionTools.projectId, functionTools.functionId],
1484
+ references: [functions.tenantId, functions.projectId, functions.id]
1485
+ }),
1486
+ agentRelations: many(agentFunctionToolRelations)
1487
+ }));
1488
+ var agentFunctionToolRelationsRelations = drizzleOrm.relations(
1489
+ agentFunctionToolRelations,
1490
+ ({ one }) => ({
1491
+ agent: one(subAgents, {
1492
+ fields: [agentFunctionToolRelations.subAgentId],
1493
+ references: [subAgents.id]
1494
+ }),
1495
+ functionTool: one(functionTools, {
1496
+ fields: [agentFunctionToolRelations.functionToolId],
1497
+ references: [functionTools.id]
1498
+ })
1499
+ })
1500
+ );
1427
1501
 
1428
1502
  // src/types/utility.ts
1429
1503
  var TOOL_STATUS_VALUES = ["healthy", "unhealthy", "unknown", "needs_auth"];
@@ -1624,32 +1698,22 @@ var ToolSelectSchema = drizzleZod.createSelectSchema(tools);
1624
1698
  var ToolInsertSchema = drizzleZod.createInsertSchema(tools).extend({
1625
1699
  id: resourceIdSchema,
1626
1700
  imageUrl: imageUrlSchema,
1627
- functionId: resourceIdSchema.optional(),
1628
- // For function tools, reference to global functions table
1629
- config: zodOpenapi.z.discriminatedUnion("type", [
1630
- // MCP tools
1631
- zodOpenapi.z.object({
1632
- type: zodOpenapi.z.literal("mcp"),
1633
- mcp: zodOpenapi.z.object({
1634
- server: zodOpenapi.z.object({
1635
- url: zodOpenapi.z.string().url()
1636
- }),
1637
- transport: zodOpenapi.z.object({
1638
- type: zodOpenapi.z.enum(MCPTransportType),
1639
- requestInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
1640
- eventSourceInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
1641
- reconnectionOptions: zodOpenapi.z.custom().optional(),
1642
- sessionId: zodOpenapi.z.string().optional()
1643
- }).optional(),
1644
- activeTools: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
1645
- })
1646
- }),
1647
- // Function tools (reference-only, no inline duplication)
1648
- zodOpenapi.z.object({
1649
- type: zodOpenapi.z.literal("function")
1650
- // No inline function details - they're in the functions table via functionId
1701
+ config: zodOpenapi.z.object({
1702
+ type: zodOpenapi.z.literal("mcp"),
1703
+ mcp: zodOpenapi.z.object({
1704
+ server: zodOpenapi.z.object({
1705
+ url: zodOpenapi.z.string().url()
1706
+ }),
1707
+ transport: zodOpenapi.z.object({
1708
+ type: zodOpenapi.z.enum(MCPTransportType),
1709
+ requestInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
1710
+ eventSourceInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
1711
+ reconnectionOptions: zodOpenapi.z.custom().optional(),
1712
+ sessionId: zodOpenapi.z.string().optional()
1713
+ }).optional(),
1714
+ activeTools: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
1651
1715
  })
1652
- ])
1716
+ })
1653
1717
  });
1654
1718
  var ConversationSelectSchema = drizzleZod.createSelectSchema(conversations);
1655
1719
  var ConversationInsertSchema = drizzleZod.createInsertSchema(conversations).extend({
@@ -1859,6 +1923,14 @@ var ToolUpdateSchema = ToolInsertSchema.partial();
1859
1923
  var ToolApiSelectSchema = createApiSchema(ToolSelectSchema);
1860
1924
  var ToolApiInsertSchema = createApiInsertSchema(ToolInsertSchema);
1861
1925
  var ToolApiUpdateSchema = createApiUpdateSchema(ToolUpdateSchema);
1926
+ var FunctionToolSelectSchema = drizzleZod.createSelectSchema(functionTools);
1927
+ var FunctionToolInsertSchema = drizzleZod.createInsertSchema(functionTools).extend({
1928
+ id: resourceIdSchema
1929
+ });
1930
+ var FunctionToolUpdateSchema = FunctionToolInsertSchema.partial();
1931
+ var FunctionToolApiSelectSchema = createApiSchema(FunctionToolSelectSchema);
1932
+ var FunctionToolApiInsertSchema = createGraphScopedApiInsertSchema(FunctionToolInsertSchema);
1933
+ var FunctionToolApiUpdateSchema = createApiUpdateSchema(FunctionToolUpdateSchema);
1862
1934
  var FunctionSelectSchema = drizzleZod.createSelectSchema(functions);
1863
1935
  var FunctionInsertSchema = drizzleZod.createInsertSchema(functions).extend({
1864
1936
  id: resourceIdSchema
@@ -1961,6 +2033,24 @@ var FullGraphAgentInsertSchema = SubAgentApiInsertSchema.extend({
1961
2033
  canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1962
2034
  canDelegateTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
1963
2035
  });
2036
+ var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
2037
+ subAgents: zodOpenapi.z.record(
2038
+ zodOpenapi.z.string(),
2039
+ zodOpenapi.z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])
2040
+ ),
2041
+ // Lookup maps for UI to resolve canUse items
2042
+ tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
2043
+ // MCP tools (project-scoped)
2044
+ functionTools: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionToolApiInsertSchema).optional(),
2045
+ // Function tools (graph-scoped)
2046
+ functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
2047
+ // Get function code for function tools
2048
+ contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
2049
+ statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
2050
+ models: ModelSchema.optional(),
2051
+ stopWhen: GraphStopWhenSchema.optional(),
2052
+ graphPrompt: zodOpenapi.z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
2053
+ });
1964
2054
  var GraphWithinContextOfProjectSchema = AgentGraphApiInsertSchema.extend({
1965
2055
  subAgents: zodOpenapi.z.record(
1966
2056
  zodOpenapi.z.string(),
@@ -1969,9 +2059,13 @@ var GraphWithinContextOfProjectSchema = AgentGraphApiInsertSchema.extend({
1969
2059
  ExternalAgentApiInsertSchema.extend({ type: zodOpenapi.z.literal("external") })
1970
2060
  ])
1971
2061
  ),
2062
+ // Lookup maps for UI to resolve canUse items
1972
2063
  tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
1973
- // Get tool name/description from toolId
2064
+ // MCP tools (project-scoped)
2065
+ functionTools: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionToolApiInsertSchema).optional(),
2066
+ // Function tools (graph-scoped)
1974
2067
  functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
2068
+ // Get function code for function tools
1975
2069
  contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
1976
2070
  statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
1977
2071
  models: ModelSchema.optional(),
@@ -2019,9 +2113,9 @@ var ProjectApiUpdateSchema = ProjectUpdateSchema.omit({ tenantId: true });
2019
2113
  var FullProjectDefinitionSchema = ProjectApiInsertSchema.extend({
2020
2114
  graphs: zodOpenapi.z.record(zodOpenapi.z.string(), GraphWithinContextOfProjectSchema),
2021
2115
  tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema),
2022
- // Now includes both MCP and function tools
2116
+ // MCP tools (project-scoped)
2023
2117
  functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
2024
- // Global functions
2118
+ // Functions (project-scoped)
2025
2119
  dataComponents: zodOpenapi.z.record(zodOpenapi.z.string(), DataComponentApiInsertSchema).optional(),
2026
2120
  artifactComponents: zodOpenapi.z.record(zodOpenapi.z.string(), ArtifactComponentApiInsertSchema).optional(),
2027
2121
  statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
@@ -2602,11 +2696,11 @@ function getCredentialStoreLookupKeyFromRetrievalParams({
2602
2696
 
2603
2697
  // src/credential-stuffer/CredentialStuffer.ts
2604
2698
  var CredentialStuffer = class {
2605
- constructor(credentialStoreRegistry, contextResolver, logger13) {
2699
+ constructor(credentialStoreRegistry, contextResolver, logger14) {
2606
2700
  this.credentialStoreRegistry = credentialStoreRegistry;
2607
2701
  this.contextResolver = contextResolver;
2608
2702
  __publicField(this, "logger");
2609
- this.logger = logger13 || getLogger("credential-stuffer");
2703
+ this.logger = logger14 || getLogger("credential-stuffer");
2610
2704
  }
2611
2705
  /**
2612
2706
  * Retrieve credentials from credential store registry
@@ -3160,6 +3254,212 @@ var deleteFunction = (db) => async (params) => {
3160
3254
  )
3161
3255
  );
3162
3256
  };
3257
+ var logger4 = getLogger("functionTools");
3258
+ var getFunctionToolById = (db) => async (params) => {
3259
+ const result = await db.select().from(functionTools).where(
3260
+ drizzleOrm.and(
3261
+ drizzleOrm.eq(functionTools.tenantId, params.scopes.tenantId),
3262
+ drizzleOrm.eq(functionTools.projectId, params.scopes.projectId),
3263
+ drizzleOrm.eq(functionTools.graphId, params.scopes.graphId),
3264
+ drizzleOrm.eq(functionTools.id, params.functionToolId)
3265
+ )
3266
+ ).limit(1);
3267
+ return result[0] ?? null;
3268
+ };
3269
+ var listFunctionTools = (db) => async (params) => {
3270
+ const page = params.pagination?.page || 1;
3271
+ const limit = Math.min(params.pagination?.limit || 10, 100);
3272
+ const offset = (page - 1) * limit;
3273
+ const whereClause = drizzleOrm.and(
3274
+ drizzleOrm.eq(functionTools.tenantId, params.scopes.tenantId),
3275
+ drizzleOrm.eq(functionTools.projectId, params.scopes.projectId),
3276
+ drizzleOrm.eq(functionTools.graphId, params.scopes.graphId)
3277
+ );
3278
+ const [functionToolsDbResults, totalResult] = await Promise.all([
3279
+ db.select().from(functionTools).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(functionTools.createdAt)),
3280
+ db.select({ count: drizzleOrm.count() }).from(functionTools).where(whereClause)
3281
+ ]);
3282
+ const total = totalResult[0]?.count || 0;
3283
+ const pages = Math.ceil(total / limit);
3284
+ return {
3285
+ data: functionToolsDbResults,
3286
+ pagination: { page, limit, total, pages }
3287
+ };
3288
+ };
3289
+ var createFunctionTool = (db) => async (params) => {
3290
+ const { data, scopes } = params;
3291
+ const { tenantId, projectId, graphId } = scopes;
3292
+ const [created] = await db.insert(functionTools).values({
3293
+ tenantId,
3294
+ projectId,
3295
+ graphId,
3296
+ id: data.id,
3297
+ name: data.name,
3298
+ description: data.description,
3299
+ functionId: data.functionId,
3300
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3301
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
3302
+ }).returning();
3303
+ return created;
3304
+ };
3305
+ var updateFunctionTool = (db) => async (params) => {
3306
+ const now = (/* @__PURE__ */ new Date()).toISOString();
3307
+ const [updated] = await db.update(functionTools).set({
3308
+ ...params.data,
3309
+ updatedAt: now
3310
+ }).where(
3311
+ drizzleOrm.and(
3312
+ drizzleOrm.eq(functionTools.tenantId, params.scopes.tenantId),
3313
+ drizzleOrm.eq(functionTools.projectId, params.scopes.projectId),
3314
+ drizzleOrm.eq(functionTools.graphId, params.scopes.graphId),
3315
+ drizzleOrm.eq(functionTools.id, params.functionToolId)
3316
+ )
3317
+ ).returning();
3318
+ return updated ?? null;
3319
+ };
3320
+ var deleteFunctionTool = (db) => async (params) => {
3321
+ const [deleted] = await db.delete(functionTools).where(
3322
+ drizzleOrm.and(
3323
+ drizzleOrm.eq(functionTools.tenantId, params.scopes.tenantId),
3324
+ drizzleOrm.eq(functionTools.projectId, params.scopes.projectId),
3325
+ drizzleOrm.eq(functionTools.graphId, params.scopes.graphId),
3326
+ drizzleOrm.eq(functionTools.id, params.functionToolId)
3327
+ )
3328
+ ).returning();
3329
+ return !!deleted;
3330
+ };
3331
+ var upsertFunctionTool = (db) => async (params) => {
3332
+ const scopes = {
3333
+ tenantId: params.scopes.tenantId,
3334
+ projectId: params.scopes.projectId,
3335
+ graphId: params.scopes.graphId
3336
+ };
3337
+ const existing = await getFunctionToolById(db)({
3338
+ scopes,
3339
+ functionToolId: params.data.id
3340
+ });
3341
+ if (existing) {
3342
+ return await updateFunctionTool(db)({
3343
+ scopes,
3344
+ functionToolId: params.data.id,
3345
+ data: {
3346
+ name: params.data.name,
3347
+ description: params.data.description,
3348
+ functionId: params.data.functionId
3349
+ }
3350
+ });
3351
+ } else {
3352
+ return await createFunctionTool(db)({
3353
+ data: params.data,
3354
+ scopes
3355
+ });
3356
+ }
3357
+ };
3358
+ var getFunctionToolsForSubAgent = (db) => {
3359
+ return async (params) => {
3360
+ const { scopes, subAgentId } = params;
3361
+ const { tenantId, projectId, graphId } = scopes;
3362
+ try {
3363
+ const functionToolsList = await listFunctionTools(db)({
3364
+ scopes: { tenantId, projectId, graphId },
3365
+ pagination: { page: 1, limit: 1e3 }
3366
+ });
3367
+ const relations2 = await db.select().from(agentFunctionToolRelations).where(
3368
+ drizzleOrm.and(
3369
+ drizzleOrm.eq(agentFunctionToolRelations.tenantId, tenantId),
3370
+ drizzleOrm.eq(agentFunctionToolRelations.projectId, projectId),
3371
+ drizzleOrm.eq(agentFunctionToolRelations.graphId, graphId),
3372
+ drizzleOrm.eq(agentFunctionToolRelations.subAgentId, subAgentId)
3373
+ )
3374
+ );
3375
+ const relatedFunctionToolIds = new Set(relations2.map((r) => r.functionToolId));
3376
+ const agentFunctionTools = functionToolsList.data.filter(
3377
+ (ft) => relatedFunctionToolIds.has(ft.id)
3378
+ );
3379
+ return {
3380
+ data: agentFunctionTools,
3381
+ pagination: functionToolsList.pagination
3382
+ };
3383
+ } catch (error) {
3384
+ logger4.error(
3385
+ { tenantId, projectId, graphId, subAgentId, error },
3386
+ "Failed to get function tools for agent"
3387
+ );
3388
+ throw error;
3389
+ }
3390
+ };
3391
+ };
3392
+ var upsertSubAgentFunctionToolRelation = (db) => async (params) => {
3393
+ if (params.relationId) {
3394
+ return await updateSubAgentFunctionToolRelation(db)({
3395
+ scopes: params.scopes,
3396
+ relationId: params.relationId,
3397
+ data: {
3398
+ subAgentId: params.subAgentId,
3399
+ functionToolId: params.functionToolId
3400
+ }
3401
+ });
3402
+ }
3403
+ return await addFunctionToolToSubAgent(db)(params);
3404
+ };
3405
+ var addFunctionToolToSubAgent = (db) => {
3406
+ return async (params) => {
3407
+ const { scopes, subAgentId, functionToolId } = params;
3408
+ const { tenantId, projectId, graphId } = scopes;
3409
+ try {
3410
+ const relationId = nanoid.nanoid();
3411
+ await db.insert(agentFunctionToolRelations).values({
3412
+ id: relationId,
3413
+ tenantId,
3414
+ projectId,
3415
+ graphId,
3416
+ subAgentId,
3417
+ functionToolId
3418
+ });
3419
+ logger4.info(
3420
+ { tenantId, projectId, graphId, subAgentId, functionToolId, relationId },
3421
+ "Function tool added to agent"
3422
+ );
3423
+ return { id: relationId };
3424
+ } catch (error) {
3425
+ logger4.error(
3426
+ { tenantId, projectId, graphId, subAgentId, functionToolId, error },
3427
+ "Failed to add function tool to agent"
3428
+ );
3429
+ throw error;
3430
+ }
3431
+ };
3432
+ };
3433
+ var updateSubAgentFunctionToolRelation = (db) => {
3434
+ return async (params) => {
3435
+ const { scopes, relationId, data } = params;
3436
+ const { tenantId, projectId, graphId } = scopes;
3437
+ try {
3438
+ await db.update(agentFunctionToolRelations).set({
3439
+ subAgentId: data.subAgentId,
3440
+ functionToolId: data.functionToolId
3441
+ }).where(
3442
+ drizzleOrm.and(
3443
+ drizzleOrm.eq(agentFunctionToolRelations.id, relationId),
3444
+ drizzleOrm.eq(agentFunctionToolRelations.tenantId, tenantId),
3445
+ drizzleOrm.eq(agentFunctionToolRelations.projectId, projectId),
3446
+ drizzleOrm.eq(agentFunctionToolRelations.graphId, graphId)
3447
+ )
3448
+ );
3449
+ logger4.info(
3450
+ { tenantId, projectId, graphId, relationId, data },
3451
+ "Agent-function tool relation updated"
3452
+ );
3453
+ return { id: relationId };
3454
+ } catch (error) {
3455
+ logger4.error(
3456
+ { tenantId, projectId, graphId, relationId, data, error },
3457
+ "Failed to update agent-function tool relation"
3458
+ );
3459
+ throw error;
3460
+ }
3461
+ };
3462
+ };
3163
3463
  var getAgentRelationById = (db) => async (params) => {
3164
3464
  return db.query.subAgentRelations.findFirst({
3165
3465
  where: drizzleOrm.and(
@@ -3572,7 +3872,6 @@ var getToolsForAgent = (db) => async (params) => {
3572
3872
  name: tools.name,
3573
3873
  description: tools.description,
3574
3874
  config: tools.config,
3575
- functionId: tools.functionId,
3576
3875
  createdAt: tools.createdAt,
3577
3876
  updatedAt: tools.updatedAt,
3578
3877
  capabilities: tools.capabilities,
@@ -3818,7 +4117,7 @@ var getSubAgentsByIds = (db) => async (params) => {
3818
4117
  );
3819
4118
  };
3820
4119
  var scryptAsync = util.promisify(crypto.scrypt);
3821
- var logger4 = getLogger("api-key");
4120
+ var logger5 = getLogger("api-key");
3822
4121
  var API_KEY_LENGTH = 32;
3823
4122
  var SALT_LENGTH = 32;
3824
4123
  var KEY_LENGTH = 64;
@@ -3855,7 +4154,7 @@ async function validateApiKey(key, storedHash) {
3855
4154
  const hashedBuffer = await scryptAsync(key, salt, KEY_LENGTH);
3856
4155
  return crypto.timingSafeEqual(storedHashBuffer, hashedBuffer);
3857
4156
  } catch (error) {
3858
- logger4.error({ error }, "Error validating API key");
4157
+ logger5.error({ error }, "Error validating API key");
3859
4158
  return false;
3860
4159
  }
3861
4160
  }
@@ -3905,7 +4204,7 @@ var buildOAuthConfig = (metadata) => ({
3905
4204
  registrationUrl: metadata.registration_endpoint,
3906
4205
  supportsDynamicRegistration: !!metadata.registration_endpoint
3907
4206
  });
3908
- var tryWellKnownEndpoints = async (baseUrl, logger13) => {
4207
+ var tryWellKnownEndpoints = async (baseUrl, logger14) => {
3909
4208
  const wellKnownUrls = getWellKnownUrls(baseUrl);
3910
4209
  for (const wellKnownUrl of wellKnownUrls) {
3911
4210
  try {
@@ -3913,21 +4212,21 @@ var tryWellKnownEndpoints = async (baseUrl, logger13) => {
3913
4212
  if (response.ok) {
3914
4213
  const metadata = await response.json();
3915
4214
  if (validateOAuthMetadata(metadata)) {
3916
- logger13?.debug({ baseUrl, wellKnownUrl }, "OAuth 2.1/PKCE support detected");
4215
+ logger14?.debug({ baseUrl, wellKnownUrl }, "OAuth 2.1/PKCE support detected");
3917
4216
  return buildOAuthConfig(metadata);
3918
4217
  }
3919
4218
  }
3920
4219
  } catch (error) {
3921
- logger13?.debug({ wellKnownUrl, error }, "OAuth endpoint check failed");
4220
+ logger14?.debug({ wellKnownUrl, error }, "OAuth endpoint check failed");
3922
4221
  }
3923
4222
  }
3924
4223
  return null;
3925
4224
  };
3926
- var checkForOAuthEndpoints = async (serverUrl, logger13) => {
3927
- const config = await discoverOAuthEndpoints(serverUrl, logger13);
4225
+ var checkForOAuthEndpoints = async (serverUrl, logger14) => {
4226
+ const config = await discoverOAuthEndpoints(serverUrl, logger14);
3928
4227
  return config !== null;
3929
4228
  };
3930
- var discoverOAuthEndpoints = async (serverUrl, logger13) => {
4229
+ var discoverOAuthEndpoints = async (serverUrl, logger14) => {
3931
4230
  try {
3932
4231
  const response = await fetch(serverUrl, {
3933
4232
  method: "POST",
@@ -3943,7 +4242,7 @@ var discoverOAuthEndpoints = async (serverUrl, logger13) => {
3943
4242
  if (metadataResponse.ok) {
3944
4243
  const metadata = await metadataResponse.json();
3945
4244
  if (metadata.authorization_servers?.length > 0) {
3946
- return await tryWellKnownEndpoints(metadata.authorization_servers[0], logger13);
4245
+ return await tryWellKnownEndpoints(metadata.authorization_servers[0], logger14);
3947
4246
  }
3948
4247
  }
3949
4248
  }
@@ -3953,25 +4252,25 @@ var discoverOAuthEndpoints = async (serverUrl, logger13) => {
3953
4252
  }
3954
4253
  const url = new URL(serverUrl);
3955
4254
  const baseUrl = `${url.protocol}//${url.host}`;
3956
- return await tryWellKnownEndpoints(baseUrl, logger13);
4255
+ return await tryWellKnownEndpoints(baseUrl, logger14);
3957
4256
  };
3958
4257
  var detectAuthenticationRequired = async ({
3959
4258
  serverUrl,
3960
4259
  toolId,
3961
4260
  error,
3962
- logger: logger13
4261
+ logger: logger14
3963
4262
  }) => {
3964
4263
  try {
3965
- const hasOAuthEndpoints = await checkForOAuthEndpoints(serverUrl, logger13);
4264
+ const hasOAuthEndpoints = await checkForOAuthEndpoints(serverUrl, logger14);
3966
4265
  if (hasOAuthEndpoints) {
3967
- logger13?.info(
4266
+ logger14?.info(
3968
4267
  { toolId, serverUrl },
3969
4268
  "OAuth 2.1/PKCE support confirmed via endpoint discovery"
3970
4269
  );
3971
4270
  return true;
3972
4271
  }
3973
4272
  } catch (discoveryError) {
3974
- logger13?.debug({ toolId, discoveryError }, "OAuth endpoint discovery failed");
4273
+ logger14?.debug({ toolId, discoveryError }, "OAuth endpoint discovery failed");
3975
4274
  }
3976
4275
  try {
3977
4276
  const response = await fetch(serverUrl, {
@@ -3990,13 +4289,13 @@ var detectAuthenticationRequired = async ({
3990
4289
  const authLower = wwwAuth.toLowerCase();
3991
4290
  const hasActiveOAuthFlow = authLower.includes("authorization_uri") || authLower.includes("as_uri=") || authLower.includes("bearer") && (authLower.includes("scope=") || authLower.includes("error_uri="));
3992
4291
  if (hasActiveOAuthFlow) {
3993
- logger13?.info(
4292
+ logger14?.info(
3994
4293
  { toolId, wwwAuth },
3995
4294
  "Active OAuth flow detected via WWW-Authenticate parameters"
3996
4295
  );
3997
4296
  return true;
3998
4297
  } else {
3999
- logger13?.debug(
4298
+ logger14?.debug(
4000
4299
  { toolId, wwwAuth },
4001
4300
  "Bearer authentication detected - likely simple token auth, not OAuth"
4002
4301
  );
@@ -4004,9 +4303,9 @@ var detectAuthenticationRequired = async ({
4004
4303
  }
4005
4304
  }
4006
4305
  } catch (fetchError) {
4007
- logger13?.debug({ toolId, fetchError }, "Direct fetch authentication check failed");
4306
+ logger14?.debug({ toolId, fetchError }, "Direct fetch authentication check failed");
4008
4307
  }
4009
- logger13?.debug(
4308
+ logger14?.debug(
4010
4309
  { toolId, error: error.message },
4011
4310
  "No OAuth 2.1/PKCE authentication requirement detected"
4012
4311
  );
@@ -4466,7 +4765,7 @@ var McpClient = class {
4466
4765
  return results;
4467
4766
  }
4468
4767
  };
4469
- var logger5 = getLogger("tracer");
4768
+ var logger6 = getLogger("tracer");
4470
4769
  var createNoOpSpan = () => ({
4471
4770
  setAttributes: () => ({}),
4472
4771
  recordException: () => ({}),
@@ -4495,21 +4794,21 @@ var noopTracer = {
4495
4794
  return createNoOpSpan();
4496
4795
  }
4497
4796
  };
4498
- function setSpanWithError(span, error, logger13, logMessage) {
4797
+ function setSpanWithError(span, error, logger14, logMessage) {
4499
4798
  span.recordException(error);
4500
4799
  span.setStatus({
4501
4800
  code: api.SpanStatusCode.ERROR,
4502
4801
  message: error.message
4503
4802
  });
4504
- if (logger13 && logMessage) {
4505
- logger13.error({ error: error.message }, logMessage);
4803
+ if (logger14 && logMessage) {
4804
+ logger14.error({ error: error.message }, logMessage);
4506
4805
  }
4507
4806
  }
4508
4807
  function getTracer(serviceName, serviceVersion) {
4509
4808
  try {
4510
4809
  return api.trace.getTracer(serviceName, serviceVersion);
4511
4810
  } catch (_error) {
4512
- logger5.debug({}, "OpenTelemetry tracer not available, using no-op tracer");
4811
+ logger6.debug({}, "OpenTelemetry tracer not available, using no-op tracer");
4513
4812
  return noopTracer;
4514
4813
  }
4515
4814
  }
@@ -4672,7 +4971,7 @@ var upsertCredentialReference = (db) => async (params) => {
4672
4971
  };
4673
4972
 
4674
4973
  // src/data-access/tools.ts
4675
- var logger6 = getLogger("tools");
4974
+ var logger7 = getLogger("tools");
4676
4975
  function extractInputSchema(toolDef) {
4677
4976
  if (toolDef.inputSchema) {
4678
4977
  return toolDef.inputSchema;
@@ -4772,7 +5071,7 @@ var discoverToolsFromServer = async (tool2, dbClient, credentialStoreRegistry) =
4772
5071
  );
4773
5072
  return toolDefinitions;
4774
5073
  } catch (error) {
4775
- logger6.error({ toolId: tool2.id, error }, "Tool discovery failed");
5074
+ logger7.error({ toolId: tool2.id, error }, "Tool discovery failed");
4776
5075
  throw error;
4777
5076
  }
4778
5077
  };
@@ -4781,8 +5080,6 @@ var dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry) => {
4781
5080
  if (dbResult.config.type !== "mcp") {
4782
5081
  return {
4783
5082
  ...rest,
4784
- functionId: rest.functionId || void 0,
4785
- // Convert null to undefined
4786
5083
  status: "unknown",
4787
5084
  availableTools: [],
4788
5085
  capabilities: capabilities || void 0,
@@ -4806,7 +5103,7 @@ var dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry) => {
4806
5103
  serverUrl: dbResult.config.mcp.server.url,
4807
5104
  toolId: dbResult.id,
4808
5105
  error,
4809
- logger: logger6
5106
+ logger: logger7
4810
5107
  });
4811
5108
  status = toolNeedsAuth ? "needs_auth" : "unhealthy";
4812
5109
  lastErrorComputed = toolNeedsAuth ? "Authentication required - OAuth login needed" : error instanceof Error ? error.message : "Tool discovery failed";
@@ -4822,8 +5119,6 @@ var dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry) => {
4822
5119
  });
4823
5120
  return {
4824
5121
  ...rest,
4825
- functionId: rest.functionId || void 0,
4826
- // Convert null to undefined
4827
5122
  status,
4828
5123
  availableTools,
4829
5124
  capabilities: capabilities || void 0,
@@ -4926,7 +5221,7 @@ var removeToolFromAgent = (db) => async (params) => {
4926
5221
  ).returning();
4927
5222
  return deleted;
4928
5223
  };
4929
- var upsertAgentToolRelation = (db) => async (params) => {
5224
+ var upsertSubAgentToolRelation = (db) => async (params) => {
4930
5225
  if (params.relationId) {
4931
5226
  return await updateAgentToolRelation(db)({
4932
5227
  scopes: params.scopes,
@@ -5200,6 +5495,33 @@ var getFullGraphDefinition = (db) => async ({
5200
5495
  drizzleOrm.eq(subAgentToolRelations.subAgentId, agent.id)
5201
5496
  )
5202
5497
  );
5498
+ const agentFunctionTools = await db.select({
5499
+ id: functionTools.id,
5500
+ name: functionTools.name,
5501
+ description: functionTools.description,
5502
+ functionId: functionTools.functionId,
5503
+ createdAt: functionTools.createdAt,
5504
+ updatedAt: functionTools.updatedAt,
5505
+ tenantId: functionTools.tenantId,
5506
+ projectId: functionTools.projectId,
5507
+ graphId: functionTools.graphId,
5508
+ agentToolRelationId: agentFunctionToolRelations.id
5509
+ }).from(agentFunctionToolRelations).innerJoin(
5510
+ functionTools,
5511
+ drizzleOrm.and(
5512
+ drizzleOrm.eq(agentFunctionToolRelations.functionToolId, functionTools.id),
5513
+ drizzleOrm.eq(agentFunctionToolRelations.tenantId, functionTools.tenantId),
5514
+ drizzleOrm.eq(agentFunctionToolRelations.projectId, functionTools.projectId),
5515
+ drizzleOrm.eq(agentFunctionToolRelations.graphId, functionTools.graphId)
5516
+ )
5517
+ ).where(
5518
+ drizzleOrm.and(
5519
+ drizzleOrm.eq(agentFunctionToolRelations.tenantId, tenantId),
5520
+ drizzleOrm.eq(agentFunctionToolRelations.projectId, projectId),
5521
+ drizzleOrm.eq(agentFunctionToolRelations.graphId, graphId),
5522
+ drizzleOrm.eq(agentFunctionToolRelations.subAgentId, agent.id)
5523
+ )
5524
+ );
5203
5525
  const agentDataComponentRelations = await db.query.subAgentDataComponents.findMany({
5204
5526
  where: drizzleOrm.and(
5205
5527
  drizzleOrm.eq(subAgentDataComponents.tenantId, tenantId),
@@ -5216,12 +5538,21 @@ var getFullGraphDefinition = (db) => async ({
5216
5538
  const agentArtifactComponentIds = agentArtifactComponentRelations.map(
5217
5539
  (rel) => rel.artifactComponentId
5218
5540
  );
5219
- const canUse = subAgentTools.map((tool2) => ({
5541
+ const mcpToolCanUse = subAgentTools.map((tool2) => ({
5220
5542
  agentToolRelationId: tool2.agentToolRelationId,
5221
5543
  toolId: tool2.id,
5222
5544
  toolSelection: tool2.selectedTools || null,
5223
5545
  headers: tool2.headers || null
5224
5546
  }));
5547
+ const functionToolCanUse = agentFunctionTools.map((tool2) => ({
5548
+ agentToolRelationId: tool2.agentToolRelationId,
5549
+ toolId: tool2.id,
5550
+ toolSelection: null,
5551
+ // Function tools don't have tool selection
5552
+ headers: null
5553
+ // Function tools don't have headers
5554
+ }));
5555
+ const canUse = [...mcpToolCanUse, ...functionToolCanUse];
5225
5556
  return {
5226
5557
  id: agent.id,
5227
5558
  name: agent.name,
@@ -5410,16 +5741,29 @@ var getFullGraphDefinition = (db) => async ({
5410
5741
  name: tool2.name,
5411
5742
  description: tool2.description,
5412
5743
  config: tool2.config,
5413
- functionId: tool2.functionId,
5414
5744
  credentialReferenceId: tool2.credentialReferenceId,
5415
5745
  imageUrl: tool2.imageUrl
5416
5746
  };
5417
5747
  }
5418
5748
  result.tools = toolsObject;
5749
+ const functionToolsList = await listFunctionTools(db)({
5750
+ scopes: { tenantId, projectId, graphId },
5751
+ pagination: { page: 1, limit: 1e3 }
5752
+ });
5753
+ const functionToolsObject = {};
5754
+ for (const functionTool of functionToolsList.data) {
5755
+ functionToolsObject[functionTool.id] = {
5756
+ id: functionTool.id,
5757
+ name: functionTool.name,
5758
+ description: functionTool.description,
5759
+ functionId: functionTool.functionId
5760
+ };
5761
+ }
5762
+ result.functionTools = functionToolsObject;
5419
5763
  const functionIds = /* @__PURE__ */ new Set();
5420
- for (const tool2 of toolsList.data) {
5421
- if (tool2.functionId) {
5422
- functionIds.add(tool2.functionId);
5764
+ for (const functionTool of functionToolsList.data) {
5765
+ if (functionTool.functionId) {
5766
+ functionIds.add(functionTool.functionId);
5423
5767
  }
5424
5768
  }
5425
5769
  if (functionIds.size > 0) {
@@ -6658,18 +7002,18 @@ var defaultLogger = {
6658
7002
  error: () => {
6659
7003
  }
6660
7004
  };
6661
- async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData) {
7005
+ async function applyExecutionLimitsInheritance(db, logger14, scopes, graphData) {
6662
7006
  const { tenantId, projectId } = scopes;
6663
7007
  try {
6664
7008
  const project = await db.query.projects.findFirst({
6665
7009
  where: drizzleOrm.and(drizzleOrm.eq(projects.tenantId, tenantId), drizzleOrm.eq(projects.id, projectId))
6666
7010
  });
6667
7011
  if (!project?.stopWhen) {
6668
- logger13.info({ projectId }, "No project stopWhen configuration found");
7012
+ logger14.info({ projectId }, "No project stopWhen configuration found");
6669
7013
  return;
6670
7014
  }
6671
7015
  const projectStopWhen = project.stopWhen;
6672
- logger13.info(
7016
+ logger14.info(
6673
7017
  {
6674
7018
  projectId,
6675
7019
  projectStopWhen
@@ -6681,7 +7025,7 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
6681
7025
  }
6682
7026
  if (graphData.stopWhen.transferCountIs === void 0 && projectStopWhen?.transferCountIs !== void 0) {
6683
7027
  graphData.stopWhen.transferCountIs = projectStopWhen.transferCountIs;
6684
- logger13.info(
7028
+ logger14.info(
6685
7029
  {
6686
7030
  graphId: graphData.id,
6687
7031
  inheritedValue: projectStopWhen.transferCountIs
@@ -6691,7 +7035,7 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
6691
7035
  }
6692
7036
  if (graphData.stopWhen.transferCountIs === void 0) {
6693
7037
  graphData.stopWhen.transferCountIs = 10;
6694
- logger13.info(
7038
+ logger14.info(
6695
7039
  {
6696
7040
  graphId: graphData.id,
6697
7041
  defaultValue: 10
@@ -6700,7 +7044,7 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
6700
7044
  );
6701
7045
  }
6702
7046
  if (projectStopWhen?.stepCountIs !== void 0) {
6703
- logger13.info(
7047
+ logger14.info(
6704
7048
  {
6705
7049
  projectId,
6706
7050
  stepCountIs: projectStopWhen.stepCountIs
@@ -6715,7 +7059,7 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
6715
7059
  }
6716
7060
  if (agent.stopWhen.stepCountIs === void 0) {
6717
7061
  agent.stopWhen.stepCountIs = projectStopWhen.stepCountIs;
6718
- logger13.info(
7062
+ logger14.info(
6719
7063
  {
6720
7064
  subAgentId,
6721
7065
  inheritedValue: projectStopWhen.stepCountIs
@@ -6727,7 +7071,7 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
6727
7071
  }
6728
7072
  }
6729
7073
  } catch (error) {
6730
- logger13.error(
7074
+ logger14.error(
6731
7075
  {
6732
7076
  projectId,
6733
7077
  error: error instanceof Error ? error.message : "Unknown error"
@@ -6736,21 +7080,21 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
6736
7080
  );
6737
7081
  }
6738
7082
  }
6739
- var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes, graphData) => {
7083
+ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes, graphData) => {
6740
7084
  const { tenantId, projectId } = scopes;
6741
7085
  const typed = validateAndTypeGraphData(graphData);
6742
7086
  validateGraphStructure(typed);
6743
- await applyExecutionLimitsInheritance(db, logger13, { tenantId, projectId }, typed);
7087
+ await applyExecutionLimitsInheritance(db, logger14, { tenantId, projectId }, typed);
6744
7088
  try {
6745
- logger13.info(
7089
+ logger14.info(
6746
7090
  {},
6747
7091
  "CredentialReferences are project-scoped - skipping credential reference creation in graph"
6748
7092
  );
6749
- logger13.info({}, "Tools are project-scoped - skipping tool creation in graph");
7093
+ logger14.info({}, "MCP Tools are project-scoped - skipping tool creation in graph");
6750
7094
  let finalGraphId;
6751
7095
  try {
6752
7096
  const graphId = typed.id || nanoid.nanoid();
6753
- logger13.info({ graphId }, "Creating agent graph metadata");
7097
+ logger14.info({ graphId }, "Creating agent graph metadata");
6754
7098
  const agentGraph2 = await upsertAgentGraph(db)({
6755
7099
  data: {
6756
7100
  id: graphId,
@@ -6768,15 +7112,15 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6768
7112
  }
6769
7113
  });
6770
7114
  finalGraphId = agentGraph2.id;
6771
- logger13.info({ graphId: finalGraphId }, "Agent graph metadata created successfully");
7115
+ logger14.info({ graphId: finalGraphId }, "Agent graph metadata created successfully");
6772
7116
  } catch (error) {
6773
- logger13.error({ graphId: typed.id, error }, "Failed to create/update graph metadata");
7117
+ logger14.error({ graphId: typed.id, error }, "Failed to create/update graph metadata");
6774
7118
  throw error;
6775
7119
  }
6776
7120
  let contextConfigId;
6777
7121
  if (typed.contextConfig) {
6778
7122
  try {
6779
- logger13.info({ contextConfigId: typed.contextConfig.id }, "Processing context config");
7123
+ logger14.info({ contextConfigId: typed.contextConfig.id }, "Processing context config");
6780
7124
  const contextConfig2 = await upsertContextConfig(db)({
6781
7125
  data: {
6782
7126
  ...typed.contextConfig,
@@ -6786,9 +7130,9 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6786
7130
  }
6787
7131
  });
6788
7132
  contextConfigId = contextConfig2.id;
6789
- logger13.info({ contextConfigId }, "Context config processed successfully");
7133
+ logger14.info({ contextConfigId }, "Context config processed successfully");
6790
7134
  } catch (error) {
6791
- logger13.error(
7135
+ logger14.error(
6792
7136
  { contextConfigId: typed.contextConfig.id, error },
6793
7137
  "Failed to create/update context config"
6794
7138
  );
@@ -6797,7 +7141,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6797
7141
  }
6798
7142
  if (contextConfigId) {
6799
7143
  try {
6800
- logger13.info(
7144
+ logger14.info(
6801
7145
  { graphId: finalGraphId, contextConfigId },
6802
7146
  "Updating graph with contextConfigId"
6803
7147
  );
@@ -6816,30 +7160,112 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6816
7160
  stopWhen: typed.stopWhen
6817
7161
  }
6818
7162
  });
6819
- logger13.info(
7163
+ logger14.info(
6820
7164
  { graphId: finalGraphId, contextConfigId },
6821
7165
  "Graph updated with contextConfigId successfully"
6822
7166
  );
6823
7167
  } catch (error) {
6824
- logger13.error(
7168
+ logger14.error(
6825
7169
  { graphId: finalGraphId, contextConfigId, error },
6826
7170
  "Failed to update graph with contextConfigId"
6827
7171
  );
6828
7172
  throw error;
6829
7173
  }
6830
7174
  }
6831
- logger13.info(
7175
+ logger14.info(
6832
7176
  {},
6833
7177
  "DataComponents are project-scoped - skipping dataComponent creation in graph"
6834
7178
  );
6835
- logger13.info(
7179
+ logger14.info(
6836
7180
  {},
6837
7181
  "ArtifactComponents are project-scoped - skipping artifactComponent creation in graph"
6838
7182
  );
7183
+ if (typed.functions && Object.keys(typed.functions).length > 0) {
7184
+ logger14.info(
7185
+ {
7186
+ graphId: finalGraphId,
7187
+ functionCount: Object.keys(typed.functions).length
7188
+ },
7189
+ "Creating functions for graph"
7190
+ );
7191
+ const functionPromises = Object.entries(typed.functions).map(
7192
+ async ([functionId, functionData]) => {
7193
+ try {
7194
+ logger14.info({ graphId: finalGraphId, functionId }, "Creating function for graph");
7195
+ await upsertFunction(db)({
7196
+ data: {
7197
+ ...functionData,
7198
+ id: functionId
7199
+ },
7200
+ scopes: { tenantId, projectId }
7201
+ });
7202
+ logger14.info({ graphId: finalGraphId, functionId }, "Function created successfully");
7203
+ } catch (error) {
7204
+ logger14.error(
7205
+ { graphId: finalGraphId, functionId, error },
7206
+ "Failed to create function for graph"
7207
+ );
7208
+ throw error;
7209
+ }
7210
+ }
7211
+ );
7212
+ await Promise.all(functionPromises);
7213
+ logger14.info(
7214
+ {
7215
+ graphId: finalGraphId,
7216
+ functionCount: Object.keys(typed.functions).length
7217
+ },
7218
+ "All functions created successfully"
7219
+ );
7220
+ }
7221
+ if (typed.functionTools && Object.keys(typed.functionTools).length > 0) {
7222
+ logger14.info(
7223
+ {
7224
+ graphId: finalGraphId,
7225
+ functionToolCount: Object.keys(typed.functionTools).length
7226
+ },
7227
+ "Creating function tools for graph"
7228
+ );
7229
+ const functionToolPromises = Object.entries(typed.functionTools).map(
7230
+ async ([functionToolId, functionToolData]) => {
7231
+ try {
7232
+ logger14.info(
7233
+ { graphId: finalGraphId, functionToolId },
7234
+ "Creating function tool in graph"
7235
+ );
7236
+ await upsertFunctionTool(db)({
7237
+ data: {
7238
+ ...functionToolData,
7239
+ id: functionToolId
7240
+ },
7241
+ scopes: { tenantId, projectId, graphId: finalGraphId }
7242
+ });
7243
+ logger14.info(
7244
+ { graphId: finalGraphId, functionToolId },
7245
+ "Function tool created successfully"
7246
+ );
7247
+ } catch (error) {
7248
+ logger14.error(
7249
+ { graphId: finalGraphId, functionToolId, error },
7250
+ "Failed to create function tool in graph"
7251
+ );
7252
+ throw error;
7253
+ }
7254
+ }
7255
+ );
7256
+ await Promise.all(functionToolPromises);
7257
+ logger14.info(
7258
+ {
7259
+ graphId: finalGraphId,
7260
+ functionToolCount: Object.keys(typed.functionTools).length
7261
+ },
7262
+ "All function tools created successfully"
7263
+ );
7264
+ }
6839
7265
  const internalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData]) => isInternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
6840
7266
  const internalAgent = agentData;
6841
7267
  try {
6842
- logger13.info({ subAgentId }, "Processing internal agent");
7268
+ logger14.info({ subAgentId }, "Processing internal agent");
6843
7269
  await upsertSubAgent(db)({
6844
7270
  data: {
6845
7271
  id: subAgentId,
@@ -6854,9 +7280,9 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6854
7280
  stopWhen: internalAgent.stopWhen
6855
7281
  }
6856
7282
  });
6857
- logger13.info({ subAgentId }, "Internal agent processed successfully");
7283
+ logger14.info({ subAgentId }, "Internal agent processed successfully");
6858
7284
  } catch (error) {
6859
- logger13.error({ subAgentId, error }, "Failed to create/update internal agent");
7285
+ logger14.error({ subAgentId, error }, "Failed to create/update internal agent");
6860
7286
  throw error;
6861
7287
  }
6862
7288
  });
@@ -6864,11 +7290,11 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6864
7290
  const internalAgentCount = Object.entries(typed.subAgents).filter(
6865
7291
  ([_, agentData]) => isInternalAgent(agentData)
6866
7292
  ).length;
6867
- logger13.info({ internalAgentCount }, "All internal agents created/updated successfully");
7293
+ logger14.info({ internalAgentCount }, "All internal agents created/updated successfully");
6868
7294
  const externalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData]) => isExternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
6869
7295
  const externalAgent = agentData;
6870
7296
  try {
6871
- logger13.info({ subAgentId }, "Processing external agent");
7297
+ logger14.info({ subAgentId }, "Processing external agent");
6872
7298
  await upsertExternalAgent(db)({
6873
7299
  data: {
6874
7300
  id: subAgentId,
@@ -6882,9 +7308,9 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6882
7308
  headers: externalAgent.headers || void 0
6883
7309
  }
6884
7310
  });
6885
- logger13.info({ subAgentId }, "External agent processed successfully");
7311
+ logger14.info({ subAgentId }, "External agent processed successfully");
6886
7312
  } catch (error) {
6887
- logger13.error({ subAgentId, error }, "Failed to create/update external agent");
7313
+ logger14.error({ subAgentId, error }, "Failed to create/update external agent");
6888
7314
  throw error;
6889
7315
  }
6890
7316
  });
@@ -6892,10 +7318,10 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6892
7318
  const externalAgentCount = Object.entries(typed.subAgents).filter(
6893
7319
  ([_, agentData]) => isExternalAgent(agentData)
6894
7320
  ).length;
6895
- logger13.info({ externalAgentCount }, "All external agents created/updated successfully");
7321
+ logger14.info({ externalAgentCount }, "All external agents created/updated successfully");
6896
7322
  if (contextConfigId) {
6897
7323
  try {
6898
- logger13.info(
7324
+ logger14.info(
6899
7325
  { graphId: finalGraphId, contextConfigId },
6900
7326
  "Updating graph with context config"
6901
7327
  );
@@ -6903,9 +7329,9 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6903
7329
  scopes: { tenantId, projectId, graphId: finalGraphId },
6904
7330
  data: { contextConfigId }
6905
7331
  });
6906
- logger13.info({ graphId: finalGraphId }, "Graph updated with context config");
7332
+ logger14.info({ graphId: finalGraphId }, "Graph updated with context config");
6907
7333
  } catch (error) {
6908
- logger13.error(
7334
+ logger14.error(
6909
7335
  { graphId: finalGraphId, error },
6910
7336
  "Failed to update graph with context config"
6911
7337
  );
@@ -6920,18 +7346,46 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6920
7346
  (async () => {
6921
7347
  try {
6922
7348
  const { toolId, toolSelection, headers: headers2, agentToolRelationId } = canUseItem;
6923
- logger13.info({ subAgentId, toolId }, "Processing agent-tool relation");
6924
- await upsertAgentToolRelation(db)({
6925
- scopes: { tenantId, projectId, graphId: finalGraphId },
6926
- subAgentId,
6927
- toolId,
6928
- selectedTools: toolSelection || void 0,
6929
- headers: headers2 || void 0,
6930
- relationId: agentToolRelationId
6931
- });
6932
- logger13.info({ subAgentId, toolId }, "Agent-tool relation processed successfully");
7349
+ const isFunctionTool = typed.functionTools && toolId in typed.functionTools;
7350
+ logger14.info(
7351
+ {
7352
+ subAgentId,
7353
+ toolId,
7354
+ hasFunctionTools: !!typed.functionTools,
7355
+ functionToolKeys: typed.functionTools ? Object.keys(typed.functionTools) : [],
7356
+ isFunctionTool
7357
+ },
7358
+ "Processing canUse item"
7359
+ );
7360
+ if (isFunctionTool) {
7361
+ logger14.info({ subAgentId, toolId }, "Processing agent-function tool relation");
7362
+ await upsertSubAgentFunctionToolRelation(db)({
7363
+ scopes: { tenantId, projectId, graphId: finalGraphId },
7364
+ subAgentId,
7365
+ functionToolId: toolId,
7366
+ relationId: agentToolRelationId
7367
+ });
7368
+ logger14.info(
7369
+ { subAgentId, toolId },
7370
+ "Agent-function tool relation processed successfully"
7371
+ );
7372
+ } else {
7373
+ logger14.info({ subAgentId, toolId }, "Processing agent-MCP tool relation");
7374
+ await upsertSubAgentToolRelation(db)({
7375
+ scopes: { tenantId, projectId, graphId: finalGraphId },
7376
+ subAgentId,
7377
+ toolId,
7378
+ selectedTools: toolSelection || void 0,
7379
+ headers: headers2 || void 0,
7380
+ relationId: agentToolRelationId
7381
+ });
7382
+ logger14.info(
7383
+ { subAgentId, toolId },
7384
+ "Agent-MCP tool relation processed successfully"
7385
+ );
7386
+ }
6933
7387
  } catch (error) {
6934
- logger13.error(
7388
+ logger14.error(
6935
7389
  { subAgentId, toolId: canUseItem.toolId, error },
6936
7390
  "Failed to create agent-tool relation"
6937
7391
  );
@@ -6942,7 +7396,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6942
7396
  }
6943
7397
  }
6944
7398
  await Promise.all(agentToolPromises);
6945
- logger13.info(
7399
+ logger14.info(
6946
7400
  { agentToolCount: Object.keys(typed.subAgents).length },
6947
7401
  "All agent-tool relations created"
6948
7402
  );
@@ -6953,7 +7407,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6953
7407
  agentDataComponentPromises.push(
6954
7408
  (async () => {
6955
7409
  try {
6956
- logger13.info(
7410
+ logger14.info(
6957
7411
  { subAgentId, dataComponentId },
6958
7412
  "Processing agent-data component relation"
6959
7413
  );
@@ -6961,12 +7415,12 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6961
7415
  scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
6962
7416
  dataComponentId
6963
7417
  });
6964
- logger13.info(
7418
+ logger14.info(
6965
7419
  { subAgentId, dataComponentId },
6966
7420
  "Agent-data component relation processed successfully"
6967
7421
  );
6968
7422
  } catch (error) {
6969
- logger13.error(
7423
+ logger14.error(
6970
7424
  { subAgentId, dataComponentId, error },
6971
7425
  "Failed to create agent-data component relation"
6972
7426
  );
@@ -6977,7 +7431,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6977
7431
  }
6978
7432
  }
6979
7433
  await Promise.all(agentDataComponentPromises);
6980
- logger13.info({}, "All agent-data component relations created");
7434
+ logger14.info({}, "All agent-data component relations created");
6981
7435
  const agentArtifactComponentPromises = [];
6982
7436
  for (const [subAgentId, agentData] of Object.entries(typed.subAgents)) {
6983
7437
  if (isInternalAgent(agentData) && agentData.artifactComponents) {
@@ -6985,7 +7439,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6985
7439
  agentArtifactComponentPromises.push(
6986
7440
  (async () => {
6987
7441
  try {
6988
- logger13.info(
7442
+ logger14.info(
6989
7443
  { subAgentId, artifactComponentId },
6990
7444
  "Processing agent-artifact component relation"
6991
7445
  );
@@ -6993,12 +7447,12 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
6993
7447
  scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
6994
7448
  artifactComponentId
6995
7449
  });
6996
- logger13.info(
7450
+ logger14.info(
6997
7451
  { subAgentId, artifactComponentId },
6998
7452
  "Agent-artifact component relation processed successfully"
6999
7453
  );
7000
7454
  } catch (error) {
7001
- logger13.error(
7455
+ logger14.error(
7002
7456
  { subAgentId, artifactComponentId, error },
7003
7457
  "Failed to create agent-artifact component relation"
7004
7458
  );
@@ -7009,7 +7463,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7009
7463
  }
7010
7464
  }
7011
7465
  await Promise.all(agentArtifactComponentPromises);
7012
- logger13.info({}, "All agent-artifact component relations created");
7466
+ logger14.info({}, "All agent-artifact component relations created");
7013
7467
  const agentRelationPromises = [];
7014
7468
  for (const [subAgentId, agentData] of Object.entries(typed.subAgents)) {
7015
7469
  if (isInternalAgent(agentData) && agentData.canTransferTo) {
@@ -7017,7 +7471,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7017
7471
  agentRelationPromises.push(
7018
7472
  (async () => {
7019
7473
  try {
7020
- logger13.info(
7474
+ logger14.info(
7021
7475
  { subAgentId, targetSubAgentId, type: "transfer" },
7022
7476
  "Processing agent transfer relation"
7023
7477
  );
@@ -7030,12 +7484,12 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7030
7484
  targetSubAgentId,
7031
7485
  relationType: "transfer"
7032
7486
  });
7033
- logger13.info(
7487
+ logger14.info(
7034
7488
  { subAgentId, targetSubAgentId, type: "transfer" },
7035
7489
  "Agent transfer relation processed successfully"
7036
7490
  );
7037
7491
  } catch (error) {
7038
- logger13.error(
7492
+ logger14.error(
7039
7493
  { subAgentId, targetSubAgentId, type: "transfer", error },
7040
7494
  "Failed to create transfer relation"
7041
7495
  );
@@ -7051,7 +7505,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7051
7505
  agentRelationPromises.push(
7052
7506
  (async () => {
7053
7507
  try {
7054
- logger13.info(
7508
+ logger14.info(
7055
7509
  { subAgentId, targetSubAgentId, type: "delegate" },
7056
7510
  "Processing agent delegation relation"
7057
7511
  );
@@ -7065,12 +7519,12 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7065
7519
  externalSubAgentId: isTargetExternal ? targetSubAgentId : void 0,
7066
7520
  relationType: "delegate"
7067
7521
  });
7068
- logger13.info(
7522
+ logger14.info(
7069
7523
  { subAgentId, targetSubAgentId, type: "delegate" },
7070
7524
  "Agent delegation relation processed successfully"
7071
7525
  );
7072
7526
  } catch (error) {
7073
- logger13.error(
7527
+ logger14.error(
7074
7528
  { subAgentId, targetSubAgentId, type: "delegate", error },
7075
7529
  "Failed to create delegation relation"
7076
7530
  );
@@ -7081,7 +7535,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7081
7535
  }
7082
7536
  }
7083
7537
  await Promise.all(agentRelationPromises);
7084
- logger13.info(
7538
+ logger14.info(
7085
7539
  { agentRelationCount: agentRelationPromises.length },
7086
7540
  "All agent relations created"
7087
7541
  );
@@ -7091,21 +7545,21 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7091
7545
  if (!createdGraph) {
7092
7546
  throw new Error("Failed to retrieve created graph");
7093
7547
  }
7094
- logger13.info({ tenantId, graphId: finalGraphId }, "Full graph created successfully");
7548
+ logger14.info({ tenantId, graphId: finalGraphId }, "Full graph created successfully");
7095
7549
  return createdGraph;
7096
7550
  } catch (error) {
7097
7551
  const errorGraphId = typed.id || "unknown";
7098
- logger13.error({ tenantId, graphId: errorGraphId, error }, "Failed to create full graph");
7552
+ logger14.error({ tenantId, graphId: errorGraphId, error }, "Failed to create full graph");
7099
7553
  throw error;
7100
7554
  }
7101
7555
  };
7102
- var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes, graphData) => {
7556
+ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes, graphData) => {
7103
7557
  const { tenantId, projectId } = scopes;
7104
7558
  const typedGraphDefinition = validateAndTypeGraphData(graphData);
7105
7559
  if (!typedGraphDefinition.id) {
7106
7560
  throw new Error("Graph ID is required");
7107
7561
  }
7108
- logger13.info(
7562
+ logger14.info(
7109
7563
  {
7110
7564
  tenantId,
7111
7565
  graphId: typedGraphDefinition.id,
@@ -7116,7 +7570,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7116
7570
  validateGraphStructure(typedGraphDefinition);
7117
7571
  await applyExecutionLimitsInheritance(
7118
7572
  db,
7119
- logger13,
7573
+ logger14,
7120
7574
  { tenantId, projectId },
7121
7575
  typedGraphDefinition
7122
7576
  );
@@ -7125,22 +7579,22 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7125
7579
  scopes: { tenantId, projectId, graphId: typedGraphDefinition.id }
7126
7580
  });
7127
7581
  if (!existingGraph) {
7128
- logger13.info(
7582
+ logger14.info(
7129
7583
  { graphId: typedGraphDefinition.id },
7130
7584
  "Graph does not exist, creating new graph"
7131
7585
  );
7132
- return createFullGraphServerSide(db)(scopes, graphData);
7586
+ return createFullGraphServerSide(db, logger14)(scopes, graphData);
7133
7587
  }
7134
7588
  const existingGraphModels = existingGraph.models;
7135
- logger13.info(
7589
+ logger14.info(
7136
7590
  {},
7137
7591
  "CredentialReferences are project-scoped - skipping credential reference update in graph"
7138
7592
  );
7139
- logger13.info({}, "Tools are project-scoped - skipping tool creation in graph update");
7593
+ logger14.info({}, "MCP Tools are project-scoped - skipping tool creation in graph update");
7140
7594
  let finalGraphId;
7141
7595
  try {
7142
7596
  const graphId = typedGraphDefinition.id || nanoid.nanoid();
7143
- logger13.info({ graphId }, "Getting/creating agent graph metadata");
7597
+ logger14.info({ graphId }, "Getting/creating agent graph metadata");
7144
7598
  const agentGraph2 = await upsertAgentGraph(db)({
7145
7599
  data: {
7146
7600
  id: graphId,
@@ -7158,9 +7612,9 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7158
7612
  }
7159
7613
  });
7160
7614
  finalGraphId = agentGraph2.id;
7161
- logger13.info({ graphId: finalGraphId }, "Agent graph metadata ready");
7615
+ logger14.info({ graphId: finalGraphId }, "Agent graph metadata ready");
7162
7616
  } catch (error) {
7163
- logger13.error(
7617
+ logger14.error(
7164
7618
  { graphId: typedGraphDefinition.id, error },
7165
7619
  "Failed to get/update graph metadata"
7166
7620
  );
@@ -7168,7 +7622,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7168
7622
  }
7169
7623
  let contextConfigId;
7170
7624
  if (typedGraphDefinition.contextConfig) {
7171
- logger13.info(
7625
+ logger14.info(
7172
7626
  { contextConfigId: typedGraphDefinition.contextConfig?.id },
7173
7627
  " context config exists"
7174
7628
  );
@@ -7184,9 +7638,9 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7184
7638
  }
7185
7639
  });
7186
7640
  contextConfigId = contextConfig2.id;
7187
- logger13.info({ contextConfigId }, "Context config processed successfully");
7641
+ logger14.info({ contextConfigId }, "Context config processed successfully");
7188
7642
  } catch (error) {
7189
- logger13.error(
7643
+ logger14.error(
7190
7644
  { contextConfigId: typedGraphDefinition.contextConfig.id, error },
7191
7645
  "Failed to create/update context config"
7192
7646
  );
@@ -7195,7 +7649,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7195
7649
  }
7196
7650
  if (contextConfigId) {
7197
7651
  try {
7198
- logger13.info(
7652
+ logger14.info(
7199
7653
  { graphId: finalGraphId, contextConfigId },
7200
7654
  "Updating graph with contextConfigId"
7201
7655
  );
@@ -7214,23 +7668,105 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7214
7668
  stopWhen: typedGraphDefinition.stopWhen
7215
7669
  }
7216
7670
  });
7217
- logger13.info(
7671
+ logger14.info(
7218
7672
  { graphId: finalGraphId, contextConfigId },
7219
7673
  "Graph updated with contextConfigId successfully"
7220
7674
  );
7221
7675
  } catch (error) {
7222
- logger13.error(
7676
+ logger14.error(
7223
7677
  { graphId: finalGraphId, contextConfigId, error },
7224
7678
  "Failed to update graph with contextConfigId"
7225
7679
  );
7226
7680
  throw error;
7227
7681
  }
7228
7682
  }
7229
- logger13.info({}, "DataComponents are project-scoped - skipping dataComponent update in graph");
7230
- logger13.info(
7683
+ logger14.info({}, "DataComponents are project-scoped - skipping dataComponent update in graph");
7684
+ logger14.info(
7231
7685
  {},
7232
7686
  "ArtifactComponents are project-scoped - skipping artifactComponent update in graph"
7233
7687
  );
7688
+ if (typedGraphDefinition.functions && Object.keys(typedGraphDefinition.functions).length > 0) {
7689
+ logger14.info(
7690
+ {
7691
+ graphId: finalGraphId,
7692
+ functionCount: Object.keys(typedGraphDefinition.functions).length
7693
+ },
7694
+ "Updating functions for graph"
7695
+ );
7696
+ const functionPromises = Object.entries(typedGraphDefinition.functions).map(
7697
+ async ([functionId, functionData]) => {
7698
+ try {
7699
+ logger14.info({ graphId: finalGraphId, functionId }, "Updating function for graph");
7700
+ await upsertFunction(db)({
7701
+ data: {
7702
+ ...functionData,
7703
+ id: functionId
7704
+ },
7705
+ scopes: { tenantId, projectId }
7706
+ });
7707
+ logger14.info({ graphId: finalGraphId, functionId }, "Function updated successfully");
7708
+ } catch (error) {
7709
+ logger14.error(
7710
+ { graphId: finalGraphId, functionId, error },
7711
+ "Failed to update function for graph"
7712
+ );
7713
+ throw error;
7714
+ }
7715
+ }
7716
+ );
7717
+ await Promise.all(functionPromises);
7718
+ logger14.info(
7719
+ {
7720
+ graphId: finalGraphId,
7721
+ functionCount: Object.keys(typedGraphDefinition.functions).length
7722
+ },
7723
+ "All functions updated successfully"
7724
+ );
7725
+ }
7726
+ if (typedGraphDefinition.functionTools && Object.keys(typedGraphDefinition.functionTools).length > 0) {
7727
+ logger14.info(
7728
+ {
7729
+ graphId: finalGraphId,
7730
+ functionToolCount: Object.keys(typedGraphDefinition.functionTools).length
7731
+ },
7732
+ "Updating function tools for graph"
7733
+ );
7734
+ const functionToolPromises = Object.entries(typedGraphDefinition.functionTools).map(
7735
+ async ([functionToolId, functionToolData]) => {
7736
+ try {
7737
+ logger14.info(
7738
+ { graphId: finalGraphId, functionToolId },
7739
+ "Updating function tool in graph"
7740
+ );
7741
+ await upsertFunctionTool(db)({
7742
+ data: {
7743
+ ...functionToolData,
7744
+ id: functionToolId
7745
+ },
7746
+ scopes: { tenantId, projectId, graphId: finalGraphId }
7747
+ });
7748
+ logger14.info(
7749
+ { graphId: finalGraphId, functionToolId },
7750
+ "Function tool updated successfully"
7751
+ );
7752
+ } catch (error) {
7753
+ logger14.error(
7754
+ { graphId: finalGraphId, functionToolId, error },
7755
+ "Failed to update function tool in graph"
7756
+ );
7757
+ throw error;
7758
+ }
7759
+ }
7760
+ );
7761
+ await Promise.all(functionToolPromises);
7762
+ logger14.info(
7763
+ {
7764
+ graphId: finalGraphId,
7765
+ functionToolCount: Object.keys(typedGraphDefinition.functionTools).length
7766
+ },
7767
+ "All function tools updated successfully"
7768
+ );
7769
+ }
7234
7770
  const internalAgentPromises = Object.entries(typedGraphDefinition.subAgents).filter(([_, agentData]) => isInternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
7235
7771
  const internalAgent = agentData;
7236
7772
  let existingAgent = null;
@@ -7258,7 +7794,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7258
7794
  (graphModels[modelType].model !== existingGraphModels[modelType].model || // OR providerOptions changed
7259
7795
  JSON.stringify(graphModels[modelType].providerOptions) !== JSON.stringify(existingGraphModels[modelType].providerOptions))) {
7260
7796
  cascadedModels[modelType] = graphModels[modelType];
7261
- logger13.info(
7797
+ logger14.info(
7262
7798
  {
7263
7799
  subAgentId,
7264
7800
  modelType,
@@ -7273,7 +7809,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7273
7809
  finalModelSettings = cascadedModels;
7274
7810
  }
7275
7811
  try {
7276
- logger13.info({ subAgentId }, "Processing internal agent");
7812
+ logger14.info({ subAgentId }, "Processing internal agent");
7277
7813
  await upsertSubAgent(db)({
7278
7814
  data: {
7279
7815
  id: subAgentId,
@@ -7288,9 +7824,9 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7288
7824
  stopWhen: internalAgent.stopWhen
7289
7825
  }
7290
7826
  });
7291
- logger13.info({ subAgentId }, "Internal agent processed successfully");
7827
+ logger14.info({ subAgentId }, "Internal agent processed successfully");
7292
7828
  } catch (error) {
7293
- logger13.error({ subAgentId, error }, "Failed to create/update internal agent");
7829
+ logger14.error({ subAgentId, error }, "Failed to create/update internal agent");
7294
7830
  throw error;
7295
7831
  }
7296
7832
  });
@@ -7298,11 +7834,11 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7298
7834
  const internalAgentCount = Object.entries(typedGraphDefinition.subAgents).filter(
7299
7835
  ([_, agentData]) => isInternalAgent(agentData)
7300
7836
  ).length;
7301
- logger13.info({ internalAgentCount }, "All internal agents created/updated successfully");
7837
+ logger14.info({ internalAgentCount }, "All internal agents created/updated successfully");
7302
7838
  const externalAgentPromises = Object.entries(typedGraphDefinition.subAgents).filter(([_, agentData]) => isExternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
7303
7839
  const externalAgent = agentData;
7304
7840
  try {
7305
- logger13.info({ subAgentId }, "Processing external agent");
7841
+ logger14.info({ subAgentId }, "Processing external agent");
7306
7842
  await upsertExternalAgent(db)({
7307
7843
  data: {
7308
7844
  id: subAgentId,
@@ -7316,9 +7852,9 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7316
7852
  headers: externalAgent.headers || void 0
7317
7853
  }
7318
7854
  });
7319
- logger13.info({ subAgentId }, "External agent processed successfully");
7855
+ logger14.info({ subAgentId }, "External agent processed successfully");
7320
7856
  } catch (error) {
7321
- logger13.error({ subAgentId, error }, "Failed to create/update external agent");
7857
+ logger14.error({ subAgentId, error }, "Failed to create/update external agent");
7322
7858
  throw error;
7323
7859
  }
7324
7860
  });
@@ -7326,7 +7862,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7326
7862
  const externalAgentCount = Object.entries(typedGraphDefinition.subAgents).filter(
7327
7863
  ([_, agentData]) => isExternalAgent(agentData)
7328
7864
  ).length;
7329
- logger13.info({ externalAgentCount }, "All external agents created/updated successfully");
7865
+ logger14.info({ externalAgentCount }, "All external agents created/updated successfully");
7330
7866
  const incomingAgentIds = new Set(Object.keys(typedGraphDefinition.subAgents));
7331
7867
  const existingInternalAgents = await listSubAgents(db)({
7332
7868
  scopes: { tenantId, projectId, graphId: finalGraphId }
@@ -7343,9 +7879,9 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7343
7879
  subAgentId: agent.id
7344
7880
  });
7345
7881
  deletedInternalCount++;
7346
- logger13.info({ subAgentId: agent.id }, "Deleted orphaned internal agent");
7882
+ logger14.info({ subAgentId: agent.id }, "Deleted orphaned internal agent");
7347
7883
  } catch (error) {
7348
- logger13.error(
7884
+ logger14.error(
7349
7885
  { subAgentId: agent.id, error },
7350
7886
  "Failed to delete orphaned internal agent"
7351
7887
  );
@@ -7361,9 +7897,9 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7361
7897
  subAgentId: agent.id
7362
7898
  });
7363
7899
  deletedExternalCount++;
7364
- logger13.info({ subAgentId: agent.id }, "Deleted orphaned external agent");
7900
+ logger14.info({ subAgentId: agent.id }, "Deleted orphaned external agent");
7365
7901
  } catch (error) {
7366
- logger13.error(
7902
+ logger14.error(
7367
7903
  { subAgentId: agent.id, error },
7368
7904
  "Failed to delete orphaned external agent"
7369
7905
  );
@@ -7371,7 +7907,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7371
7907
  }
7372
7908
  }
7373
7909
  if (deletedInternalCount > 0 || deletedExternalCount > 0) {
7374
- logger13.info(
7910
+ logger14.info(
7375
7911
  {
7376
7912
  deletedInternalCount,
7377
7913
  deletedExternalCount,
@@ -7393,7 +7929,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7393
7929
  stopWhen: typedGraphDefinition.stopWhen
7394
7930
  }
7395
7931
  });
7396
- logger13.info({ graphId: typedGraphDefinition.id }, "Graph metadata updated");
7932
+ logger14.info({ graphId: typedGraphDefinition.id }, "Graph metadata updated");
7397
7933
  const incomingRelationshipIds = /* @__PURE__ */ new Set();
7398
7934
  for (const [_subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
7399
7935
  if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
@@ -7430,10 +7966,10 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7430
7966
  deletedCount = result.rowsAffected || 0;
7431
7967
  }
7432
7968
  if (deletedCount > 0) {
7433
- logger13.info({ subAgentId, deletedCount }, "Deleted orphaned agent-tool relations");
7969
+ logger14.info({ subAgentId, deletedCount }, "Deleted orphaned agent-tool relations");
7434
7970
  }
7435
7971
  } catch (error) {
7436
- logger13.error({ subAgentId, error }, "Failed to delete orphaned agent-tool relations");
7972
+ logger14.error({ subAgentId, error }, "Failed to delete orphaned agent-tool relations");
7437
7973
  }
7438
7974
  }
7439
7975
  const agentToolPromises = [];
@@ -7444,21 +7980,36 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7444
7980
  (async () => {
7445
7981
  try {
7446
7982
  const { toolId, toolSelection, headers: headers2, agentToolRelationId } = canUseItem;
7447
- logger13.info({ subAgentId, toolId }, "Processing agent-tool relation");
7448
- await upsertAgentToolRelation(db)({
7449
- scopes: { tenantId, projectId, graphId: finalGraphId },
7450
- subAgentId,
7451
- toolId,
7452
- selectedTools: toolSelection || void 0,
7453
- headers: headers2 || void 0,
7454
- relationId: agentToolRelationId
7455
- });
7456
- logger13.info(
7457
- { subAgentId, toolId, relationId: agentToolRelationId },
7458
- "Agent-tool relation upserted"
7459
- );
7983
+ const isFunctionTool = typedGraphDefinition.functionTools && toolId in typedGraphDefinition.functionTools;
7984
+ if (isFunctionTool) {
7985
+ logger14.info({ subAgentId, toolId }, "Processing agent-function tool relation");
7986
+ await upsertSubAgentFunctionToolRelation(db)({
7987
+ scopes: { tenantId, projectId, graphId: finalGraphId },
7988
+ subAgentId,
7989
+ functionToolId: toolId,
7990
+ relationId: agentToolRelationId
7991
+ });
7992
+ logger14.info(
7993
+ { subAgentId, toolId, relationId: agentToolRelationId },
7994
+ "Agent-function tool relation upserted"
7995
+ );
7996
+ } else {
7997
+ logger14.info({ subAgentId, toolId }, "Processing agent-MCP tool relation");
7998
+ await upsertSubAgentToolRelation(db)({
7999
+ scopes: { tenantId, projectId, graphId: finalGraphId },
8000
+ subAgentId,
8001
+ toolId,
8002
+ selectedTools: toolSelection || void 0,
8003
+ headers: headers2 || void 0,
8004
+ relationId: agentToolRelationId
8005
+ });
8006
+ logger14.info(
8007
+ { subAgentId, toolId, relationId: agentToolRelationId },
8008
+ "Agent-MCP tool relation upserted"
8009
+ );
8010
+ }
7460
8011
  } catch (error) {
7461
- logger13.error(
8012
+ logger14.error(
7462
8013
  {
7463
8014
  subAgentId,
7464
8015
  toolId: canUseItem.toolId,
@@ -7474,7 +8025,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7474
8025
  }
7475
8026
  }
7476
8027
  await Promise.all(agentToolPromises);
7477
- logger13.info(
8028
+ logger14.info(
7478
8029
  { agentToolPromisesCount: agentToolPromises.length },
7479
8030
  "All agent-tool relations updated"
7480
8031
  );
@@ -7494,12 +8045,12 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7494
8045
  scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
7495
8046
  dataComponentId
7496
8047
  });
7497
- logger13.info(
8048
+ logger14.info(
7498
8049
  { subAgentId, dataComponentId },
7499
8050
  "Agent-dataComponent relation created"
7500
8051
  );
7501
8052
  } catch (error) {
7502
- logger13.error(
8053
+ logger14.error(
7503
8054
  { subAgentId, dataComponentId, error },
7504
8055
  "Failed to create agent-dataComponent relation"
7505
8056
  );
@@ -7510,7 +8061,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7510
8061
  }
7511
8062
  }
7512
8063
  await Promise.all(agentDataComponentPromises);
7513
- logger13.info(
8064
+ logger14.info(
7514
8065
  { agentDataComponentPromisesCount: agentDataComponentPromises.length },
7515
8066
  "All agent-dataComponent relations updated"
7516
8067
  );
@@ -7530,12 +8081,12 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7530
8081
  scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
7531
8082
  artifactComponentId
7532
8083
  });
7533
- logger13.info(
8084
+ logger14.info(
7534
8085
  { subAgentId, artifactComponentId },
7535
8086
  "Agent-artifactComponent relation created"
7536
8087
  );
7537
8088
  } catch (error) {
7538
- logger13.error(
8089
+ logger14.error(
7539
8090
  { subAgentId, artifactComponentId, error },
7540
8091
  "Failed to create agent-artifactComponent relation"
7541
8092
  );
@@ -7546,7 +8097,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7546
8097
  }
7547
8098
  }
7548
8099
  await Promise.all(agentArtifactComponentPromises);
7549
- logger13.info(
8100
+ logger14.info(
7550
8101
  { agentArtifactComponentPromisesCount: agentArtifactComponentPromises.length },
7551
8102
  "All agent-artifactComponent relations updated"
7552
8103
  );
@@ -7575,12 +8126,12 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7575
8126
  projectId,
7576
8127
  ...relationData
7577
8128
  });
7578
- logger13.info(
8129
+ logger14.info(
7579
8130
  { subAgentId, targetSubAgentId, isTargetExternal },
7580
8131
  "Transfer relation created"
7581
8132
  );
7582
8133
  } catch (error) {
7583
- logger13.error(
8134
+ logger14.error(
7584
8135
  { subAgentId, targetSubAgentId, error },
7585
8136
  "Failed to create transfer relation"
7586
8137
  );
@@ -7609,9 +8160,9 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7609
8160
  projectId,
7610
8161
  ...relationData
7611
8162
  });
7612
- logger13.info({ subAgentId, targetSubAgentId }, "Delegation relation created");
8163
+ logger14.info({ subAgentId, targetSubAgentId }, "Delegation relation created");
7613
8164
  } catch (error) {
7614
- logger13.error(
8165
+ logger14.error(
7615
8166
  { subAgentId, targetSubAgentId, error },
7616
8167
  "Failed to create delegation relation"
7617
8168
  );
@@ -7622,7 +8173,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7622
8173
  }
7623
8174
  }
7624
8175
  await Promise.all(agentRelationPromises);
7625
- logger13.info(
8176
+ logger14.info(
7626
8177
  { agentRelationPromisesCount: agentRelationPromises.length },
7627
8178
  "All agent relations updated"
7628
8179
  );
@@ -7632,26 +8183,26 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
7632
8183
  if (!updatedGraph) {
7633
8184
  throw new Error("Failed to retrieve updated graph");
7634
8185
  }
7635
- logger13.info({ graphId: typedGraphDefinition.id }, "Full graph updated successfully");
8186
+ logger14.info({ graphId: typedGraphDefinition.id }, "Full graph updated successfully");
7636
8187
  return updatedGraph;
7637
8188
  } catch (error) {
7638
- logger13.error({ graphId: typedGraphDefinition.id, error }, "Failed to update full graph");
8189
+ logger14.error({ graphId: typedGraphDefinition.id, error }, "Failed to update full graph");
7639
8190
  throw error;
7640
8191
  }
7641
8192
  };
7642
- var getFullGraph = (db, logger13 = defaultLogger) => async (params) => {
8193
+ var getFullGraph = (db, logger14 = defaultLogger) => async (params) => {
7643
8194
  const { scopes } = params;
7644
8195
  const { tenantId, projectId } = scopes;
7645
- logger13.info({ tenantId, graphId: scopes.graphId }, "Retrieving full graph definition");
8196
+ logger14.info({ tenantId, graphId: scopes.graphId }, "Retrieving full graph definition");
7646
8197
  try {
7647
8198
  const graph = await getFullGraphDefinition(db)({
7648
8199
  scopes: { tenantId, projectId, graphId: scopes.graphId }
7649
8200
  });
7650
8201
  if (!graph) {
7651
- logger13.info({ tenantId, graphId: scopes.graphId }, "Graph not found");
8202
+ logger14.info({ tenantId, graphId: scopes.graphId }, "Graph not found");
7652
8203
  return null;
7653
8204
  }
7654
- logger13.info(
8205
+ logger14.info(
7655
8206
  {
7656
8207
  tenantId,
7657
8208
  graphId: scopes.graphId,
@@ -7661,7 +8212,7 @@ var getFullGraph = (db, logger13 = defaultLogger) => async (params) => {
7661
8212
  );
7662
8213
  return graph;
7663
8214
  } catch (error) {
7664
- logger13.error(
8215
+ logger14.error(
7665
8216
  {
7666
8217
  tenantId,
7667
8218
  graphId: scopes.graphId,
@@ -7672,21 +8223,21 @@ var getFullGraph = (db, logger13 = defaultLogger) => async (params) => {
7672
8223
  throw error;
7673
8224
  }
7674
8225
  };
7675
- var deleteFullGraph = (db, logger13 = defaultLogger) => async (params) => {
8226
+ var deleteFullGraph = (db, logger14 = defaultLogger) => async (params) => {
7676
8227
  const { tenantId, projectId, graphId } = params.scopes;
7677
- logger13.info({ tenantId, graphId }, "Deleting full graph and related entities");
8228
+ logger14.info({ tenantId, graphId }, "Deleting full graph and related entities");
7678
8229
  try {
7679
8230
  const graph = await getFullGraphDefinition(db)({
7680
8231
  scopes: { tenantId, projectId, graphId }
7681
8232
  });
7682
8233
  if (!graph) {
7683
- logger13.info({ tenantId, graphId }, "Graph not found for deletion");
8234
+ logger14.info({ tenantId, graphId }, "Graph not found for deletion");
7684
8235
  return false;
7685
8236
  }
7686
8237
  await deleteAgentRelationsByGraph(db)({
7687
8238
  scopes: { tenantId, projectId, graphId }
7688
8239
  });
7689
- logger13.info({ tenantId, graphId }, "Agent relations deleted");
8240
+ logger14.info({ tenantId, graphId }, "Agent relations deleted");
7690
8241
  const subAgentIds = Object.keys(graph.subAgents);
7691
8242
  if (subAgentIds.length > 0) {
7692
8243
  for (const subAgentId of subAgentIds) {
@@ -7694,7 +8245,7 @@ var deleteFullGraph = (db, logger13 = defaultLogger) => async (params) => {
7694
8245
  scopes: { tenantId, projectId, graphId, subAgentId }
7695
8246
  });
7696
8247
  }
7697
- logger13.info(
8248
+ logger14.info(
7698
8249
  { tenantId, graphId, agentCount: subAgentIds.length },
7699
8250
  "Agent-tool relations deleted"
7700
8251
  );
@@ -7702,11 +8253,11 @@ var deleteFullGraph = (db, logger13 = defaultLogger) => async (params) => {
7702
8253
  await deleteAgentGraph(db)({
7703
8254
  scopes: { tenantId, projectId, graphId }
7704
8255
  });
7705
- logger13.info({ tenantId, graphId }, "Graph metadata deleted");
7706
- logger13.info({ tenantId, graphId }, "Full graph deleted successfully");
8256
+ logger14.info({ tenantId, graphId }, "Graph metadata deleted");
8257
+ logger14.info({ tenantId, graphId }, "Full graph deleted successfully");
7707
8258
  return true;
7708
8259
  } catch (error) {
7709
- logger13.error(
8260
+ logger14.error(
7710
8261
  {
7711
8262
  tenantId,
7712
8263
  graphId,
@@ -8296,10 +8847,10 @@ var defaultLogger2 = getLogger("projectFull");
8296
8847
  function validateAndTypeProjectData(projectData) {
8297
8848
  return projectData;
8298
8849
  }
8299
- var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scopes, projectData) => {
8850
+ var createFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scopes, projectData) => {
8300
8851
  const { tenantId } = scopes;
8301
8852
  const typed = validateAndTypeProjectData(projectData);
8302
- logger13.info(
8853
+ logger14.info(
8303
8854
  {
8304
8855
  tenantId,
8305
8856
  projectId: typed.id,
@@ -8318,11 +8869,11 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8318
8869
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
8319
8870
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
8320
8871
  };
8321
- logger13.info({ projectId: typed.id }, "Creating project metadata");
8872
+ logger14.info({ projectId: typed.id }, "Creating project metadata");
8322
8873
  await createProject(db)(projectPayload);
8323
- logger13.info({ projectId: typed.id }, "Project metadata created successfully");
8874
+ logger14.info({ projectId: typed.id }, "Project metadata created successfully");
8324
8875
  if (typed.credentialReferences && Object.keys(typed.credentialReferences).length > 0) {
8325
- logger13.info(
8876
+ logger14.info(
8326
8877
  {
8327
8878
  projectId: typed.id,
8328
8879
  count: Object.keys(typed.credentialReferences).length
@@ -8332,7 +8883,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8332
8883
  const credentialPromises = Object.entries(typed.credentialReferences).map(
8333
8884
  async ([_credId, credData]) => {
8334
8885
  try {
8335
- logger13.info(
8886
+ logger14.info(
8336
8887
  { projectId: typed.id, credId: credData.id },
8337
8888
  "Creating credentialReference in project"
8338
8889
  );
@@ -8343,12 +8894,12 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8343
8894
  projectId: typed.id
8344
8895
  }
8345
8896
  });
8346
- logger13.info(
8897
+ logger14.info(
8347
8898
  { projectId: typed.id, credId: credData.id },
8348
8899
  "CredentialReference created successfully"
8349
8900
  );
8350
8901
  } catch (error) {
8351
- logger13.error(
8902
+ logger14.error(
8352
8903
  { projectId: typed.id, credId: credData.id, error },
8353
8904
  "Failed to create credentialReference in project"
8354
8905
  );
@@ -8357,7 +8908,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8357
8908
  }
8358
8909
  );
8359
8910
  await Promise.all(credentialPromises);
8360
- logger13.info(
8911
+ logger14.info(
8361
8912
  {
8362
8913
  projectId: typed.id,
8363
8914
  count: Object.keys(typed.credentialReferences).length
@@ -8369,19 +8920,19 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8369
8920
  const functionPromises = Object.entries(typed.functions).map(
8370
8921
  async ([functionId, functionData]) => {
8371
8922
  try {
8372
- logger13.info({ projectId: typed.id, functionId }, "Creating project function");
8923
+ logger14.info({ projectId: typed.id, functionId }, "Creating project function");
8373
8924
  await upsertFunction(db)({
8374
8925
  data: {
8375
8926
  ...functionData
8376
8927
  },
8377
8928
  scopes: { tenantId, projectId: typed.id }
8378
8929
  });
8379
- logger13.info(
8930
+ logger14.info(
8380
8931
  { projectId: typed.id, functionId },
8381
8932
  "Project function created successfully"
8382
8933
  );
8383
8934
  } catch (error) {
8384
- logger13.error(
8935
+ logger14.error(
8385
8936
  { projectId: typed.id, functionId, error },
8386
8937
  "Failed to create global function"
8387
8938
  );
@@ -8390,7 +8941,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8390
8941
  }
8391
8942
  );
8392
8943
  await Promise.all(functionPromises);
8393
- logger13.info(
8944
+ logger14.info(
8394
8945
  {
8395
8946
  projectId: typed.id,
8396
8947
  functionCount: Object.keys(typed.functions).length
@@ -8399,7 +8950,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8399
8950
  );
8400
8951
  }
8401
8952
  if (typed.tools && Object.keys(typed.tools).length > 0) {
8402
- logger13.info(
8953
+ logger14.info(
8403
8954
  {
8404
8955
  projectId: typed.id,
8405
8956
  toolCount: Object.keys(typed.tools).length
@@ -8408,7 +8959,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8408
8959
  );
8409
8960
  const toolPromises = Object.entries(typed.tools).map(async ([toolId, toolData]) => {
8410
8961
  try {
8411
- logger13.info({ projectId: typed.id, toolId }, "Creating tool in project");
8962
+ logger14.info({ projectId: typed.id, toolId }, "Creating tool in project");
8412
8963
  await upsertTool(db)({
8413
8964
  data: {
8414
8965
  tenantId,
@@ -8416,9 +8967,9 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8416
8967
  ...toolData
8417
8968
  }
8418
8969
  });
8419
- logger13.info({ projectId: typed.id, toolId }, "Tool created successfully");
8970
+ logger14.info({ projectId: typed.id, toolId }, "Tool created successfully");
8420
8971
  } catch (error) {
8421
- logger13.error(
8972
+ logger14.error(
8422
8973
  { projectId: typed.id, toolId, error },
8423
8974
  "Failed to create tool in project"
8424
8975
  );
@@ -8426,7 +8977,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8426
8977
  }
8427
8978
  });
8428
8979
  await Promise.all(toolPromises);
8429
- logger13.info(
8980
+ logger14.info(
8430
8981
  {
8431
8982
  projectId: typed.id,
8432
8983
  toolCount: Object.keys(typed.tools).length
@@ -8435,7 +8986,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8435
8986
  );
8436
8987
  }
8437
8988
  if (typed.dataComponents && Object.keys(typed.dataComponents).length > 0) {
8438
- logger13.info(
8989
+ logger14.info(
8439
8990
  {
8440
8991
  projectId: typed.id,
8441
8992
  count: Object.keys(typed.dataComponents).length
@@ -8445,7 +8996,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8445
8996
  const dataComponentPromises = Object.entries(typed.dataComponents).map(
8446
8997
  async ([componentId, componentData]) => {
8447
8998
  try {
8448
- logger13.info(
8999
+ logger14.info(
8449
9000
  { projectId: typed.id, componentId },
8450
9001
  "Creating dataComponent in project"
8451
9002
  );
@@ -8456,12 +9007,12 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8456
9007
  projectId: typed.id
8457
9008
  }
8458
9009
  });
8459
- logger13.info(
9010
+ logger14.info(
8460
9011
  { projectId: typed.id, componentId },
8461
9012
  "DataComponent created successfully"
8462
9013
  );
8463
9014
  } catch (error) {
8464
- logger13.error(
9015
+ logger14.error(
8465
9016
  { projectId: typed.id, componentId, error },
8466
9017
  "Failed to create dataComponent in project"
8467
9018
  );
@@ -8470,7 +9021,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8470
9021
  }
8471
9022
  );
8472
9023
  await Promise.all(dataComponentPromises);
8473
- logger13.info(
9024
+ logger14.info(
8474
9025
  {
8475
9026
  projectId: typed.id,
8476
9027
  count: Object.keys(typed.dataComponents).length
@@ -8479,7 +9030,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8479
9030
  );
8480
9031
  }
8481
9032
  if (typed.artifactComponents && Object.keys(typed.artifactComponents).length > 0) {
8482
- logger13.info(
9033
+ logger14.info(
8483
9034
  {
8484
9035
  projectId: typed.id,
8485
9036
  count: Object.keys(typed.artifactComponents).length
@@ -8489,7 +9040,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8489
9040
  const artifactComponentPromises = Object.entries(typed.artifactComponents).map(
8490
9041
  async ([componentId, componentData]) => {
8491
9042
  try {
8492
- logger13.info(
9043
+ logger14.info(
8493
9044
  { projectId: typed.id, componentId },
8494
9045
  "Creating artifactComponent in project"
8495
9046
  );
@@ -8500,12 +9051,12 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8500
9051
  projectId: typed.id
8501
9052
  }
8502
9053
  });
8503
- logger13.info(
9054
+ logger14.info(
8504
9055
  { projectId: typed.id, componentId },
8505
9056
  "ArtifactComponent created successfully"
8506
9057
  );
8507
9058
  } catch (error) {
8508
- logger13.error(
9059
+ logger14.error(
8509
9060
  { projectId: typed.id, componentId, error },
8510
9061
  "Failed to create artifactComponent in project"
8511
9062
  );
@@ -8514,7 +9065,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8514
9065
  }
8515
9066
  );
8516
9067
  await Promise.all(artifactComponentPromises);
8517
- logger13.info(
9068
+ logger14.info(
8518
9069
  {
8519
9070
  projectId: typed.id,
8520
9071
  count: Object.keys(typed.artifactComponents).length
@@ -8523,7 +9074,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8523
9074
  );
8524
9075
  }
8525
9076
  if (typed.graphs && Object.keys(typed.graphs).length > 0) {
8526
- logger13.info(
9077
+ logger14.info(
8527
9078
  {
8528
9079
  projectId: typed.id,
8529
9080
  graphCount: Object.keys(typed.graphs).length
@@ -8532,27 +9083,25 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8532
9083
  );
8533
9084
  const graphPromises = Object.entries(typed.graphs).map(async ([graphId, graphData]) => {
8534
9085
  try {
8535
- logger13.info({ projectId: typed.id, graphId }, "Creating graph in project");
9086
+ logger14.info({ projectId: typed.id, graphId }, "Creating graph in project");
8536
9087
  const graphDataWithProjectResources = {
8537
9088
  ...graphData,
8538
- agents: void 0,
8539
- // Remove 'agents' property from GraphWithinContextOfProjectSchema
8540
- subAgents: graphData.subAgents,
8541
- // Map 'agents' to 'subAgents' for FullGraphDefinitionSchema
8542
9089
  tools: typed.tools || {},
8543
- // Pass project-level resources for validation
9090
+ // Pass project-level MCP tools for validation
9091
+ functions: typed.functions || {},
9092
+ // Pass project-level functions for validation
8544
9093
  dataComponents: typed.dataComponents || {},
8545
9094
  artifactComponents: typed.artifactComponents || {},
8546
9095
  credentialReferences: typed.credentialReferences || {},
8547
9096
  statusUpdates: graphData.statusUpdates === null ? void 0 : graphData.statusUpdates
8548
9097
  };
8549
- await createFullGraphServerSide(db, logger13)(
9098
+ await createFullGraphServerSide(db, logger14)(
8550
9099
  { tenantId, projectId: typed.id },
8551
9100
  graphDataWithProjectResources
8552
9101
  );
8553
- logger13.info({ projectId: typed.id, graphId }, "Graph created successfully in project");
9102
+ logger14.info({ projectId: typed.id, graphId }, "Graph created successfully in project");
8554
9103
  } catch (error) {
8555
- logger13.error(
9104
+ logger14.error(
8556
9105
  { projectId: typed.id, graphId, error },
8557
9106
  "Failed to create graph in project"
8558
9107
  );
@@ -8560,7 +9109,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8560
9109
  }
8561
9110
  });
8562
9111
  await Promise.all(graphPromises);
8563
- logger13.info(
9112
+ logger14.info(
8564
9113
  {
8565
9114
  projectId: typed.id,
8566
9115
  graphCount: Object.keys(typed.graphs).length
@@ -8568,15 +9117,15 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8568
9117
  "All project graphs created successfully"
8569
9118
  );
8570
9119
  }
8571
- logger13.info({ projectId: typed.id }, "Full project created successfully");
9120
+ logger14.info({ projectId: typed.id }, "Full project created successfully");
8572
9121
  return await getFullProject(
8573
9122
  db,
8574
- logger13
9123
+ logger14
8575
9124
  )({
8576
9125
  scopes: { tenantId, projectId: typed.id }
8577
9126
  });
8578
9127
  } catch (error) {
8579
- logger13.error(
9128
+ logger14.error(
8580
9129
  {
8581
9130
  tenantId,
8582
9131
  projectId: typed.id,
@@ -8587,13 +9136,13 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8587
9136
  throw error;
8588
9137
  }
8589
9138
  };
8590
- var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scopes, projectData) => {
9139
+ var updateFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scopes, projectData) => {
8591
9140
  const { tenantId } = scopes;
8592
9141
  const typed = validateAndTypeProjectData(projectData);
8593
9142
  if (!typed.id) {
8594
9143
  throw new Error("Project ID is required");
8595
9144
  }
8596
- logger13.info(
9145
+ logger14.info(
8597
9146
  {
8598
9147
  tenantId,
8599
9148
  projectId: typed.id,
@@ -8606,8 +9155,8 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8606
9155
  scopes: { tenantId, projectId: typed.id }
8607
9156
  });
8608
9157
  if (!existingProject) {
8609
- logger13.info({ projectId: typed.id }, "Project not found, creating new project");
8610
- return await createFullProjectServerSide(db, logger13)(
9158
+ logger14.info({ projectId: typed.id }, "Project not found, creating new project");
9159
+ return await createFullProjectServerSide(db, logger14)(
8611
9160
  { tenantId, projectId: typed.id },
8612
9161
  projectData
8613
9162
  );
@@ -8618,14 +9167,14 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8618
9167
  models: typed.models,
8619
9168
  stopWhen: typed.stopWhen
8620
9169
  };
8621
- logger13.info({ projectId: typed.id }, "Updating project metadata");
9170
+ logger14.info({ projectId: typed.id }, "Updating project metadata");
8622
9171
  await updateProject(db)({
8623
9172
  scopes: { tenantId, projectId: typed.id },
8624
9173
  data: projectUpdatePayload
8625
9174
  });
8626
- logger13.info({ projectId: typed.id }, "Project metadata updated successfully");
9175
+ logger14.info({ projectId: typed.id }, "Project metadata updated successfully");
8627
9176
  if (typed.credentialReferences && Object.keys(typed.credentialReferences).length > 0) {
8628
- logger13.info(
9177
+ logger14.info(
8629
9178
  {
8630
9179
  projectId: typed.id,
8631
9180
  count: Object.keys(typed.credentialReferences).length
@@ -8635,7 +9184,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8635
9184
  const credentialPromises = Object.entries(typed.credentialReferences).map(
8636
9185
  async ([_credId, credData]) => {
8637
9186
  try {
8638
- logger13.info(
9187
+ logger14.info(
8639
9188
  { projectId: typed.id, credId: credData.id },
8640
9189
  "Updating credentialReference in project"
8641
9190
  );
@@ -8646,12 +9195,12 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8646
9195
  projectId: typed.id
8647
9196
  }
8648
9197
  });
8649
- logger13.info(
9198
+ logger14.info(
8650
9199
  { projectId: typed.id, credId: credData.id },
8651
9200
  "CredentialReference updated successfully"
8652
9201
  );
8653
9202
  } catch (error) {
8654
- logger13.error(
9203
+ logger14.error(
8655
9204
  { projectId: typed.id, credId: credData.id, error },
8656
9205
  "Failed to update credentialReference in project"
8657
9206
  );
@@ -8660,7 +9209,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8660
9209
  }
8661
9210
  );
8662
9211
  await Promise.all(credentialPromises);
8663
- logger13.info(
9212
+ logger14.info(
8664
9213
  {
8665
9214
  projectId: typed.id,
8666
9215
  count: Object.keys(typed.credentialReferences).length
@@ -8669,7 +9218,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8669
9218
  );
8670
9219
  }
8671
9220
  if (typed.functions && Object.keys(typed.functions).length > 0) {
8672
- logger13.info(
9221
+ logger14.info(
8673
9222
  {
8674
9223
  projectId: typed.id,
8675
9224
  functionCount: Object.keys(typed.functions).length
@@ -8679,19 +9228,19 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8679
9228
  const functionPromises = Object.entries(typed.functions).map(
8680
9229
  async ([functionId, functionData]) => {
8681
9230
  try {
8682
- logger13.info({ projectId: typed.id, functionId }, "Updating project function");
9231
+ logger14.info({ projectId: typed.id, functionId }, "Updating project function");
8683
9232
  await upsertFunction(db)({
8684
9233
  data: {
8685
9234
  ...functionData
8686
9235
  },
8687
9236
  scopes: { tenantId, projectId: typed.id }
8688
9237
  });
8689
- logger13.info(
9238
+ logger14.info(
8690
9239
  { projectId: typed.id, functionId },
8691
9240
  "Project function updated successfully"
8692
9241
  );
8693
9242
  } catch (error) {
8694
- logger13.error(
9243
+ logger14.error(
8695
9244
  { projectId: typed.id, functionId, error },
8696
9245
  "Failed to update global function"
8697
9246
  );
@@ -8700,7 +9249,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8700
9249
  }
8701
9250
  );
8702
9251
  await Promise.all(functionPromises);
8703
- logger13.info(
9252
+ logger14.info(
8704
9253
  {
8705
9254
  projectId: typed.id,
8706
9255
  functionCount: Object.keys(typed.functions).length
@@ -8709,7 +9258,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8709
9258
  );
8710
9259
  }
8711
9260
  if (typed.tools && Object.keys(typed.tools).length > 0) {
8712
- logger13.info(
9261
+ logger14.info(
8713
9262
  {
8714
9263
  projectId: typed.id,
8715
9264
  toolCount: Object.keys(typed.tools).length
@@ -8718,7 +9267,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8718
9267
  );
8719
9268
  const toolPromises = Object.entries(typed.tools).map(async ([toolId, toolData]) => {
8720
9269
  try {
8721
- logger13.info({ projectId: typed.id, toolId }, "Updating tool in project");
9270
+ logger14.info({ projectId: typed.id, toolId }, "Updating tool in project");
8722
9271
  await upsertTool(db)({
8723
9272
  data: {
8724
9273
  tenantId,
@@ -8726,9 +9275,9 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8726
9275
  ...toolData
8727
9276
  }
8728
9277
  });
8729
- logger13.info({ projectId: typed.id, toolId }, "Tool updated successfully");
9278
+ logger14.info({ projectId: typed.id, toolId }, "Tool updated successfully");
8730
9279
  } catch (error) {
8731
- logger13.error(
9280
+ logger14.error(
8732
9281
  { projectId: typed.id, toolId, error },
8733
9282
  "Failed to update tool in project"
8734
9283
  );
@@ -8736,7 +9285,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8736
9285
  }
8737
9286
  });
8738
9287
  await Promise.all(toolPromises);
8739
- logger13.info(
9288
+ logger14.info(
8740
9289
  {
8741
9290
  projectId: typed.id,
8742
9291
  toolCount: Object.keys(typed.tools).length
@@ -8745,7 +9294,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8745
9294
  );
8746
9295
  }
8747
9296
  if (typed.dataComponents && Object.keys(typed.dataComponents).length > 0) {
8748
- logger13.info(
9297
+ logger14.info(
8749
9298
  {
8750
9299
  projectId: typed.id,
8751
9300
  count: Object.keys(typed.dataComponents).length
@@ -8755,7 +9304,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8755
9304
  const dataComponentPromises = Object.entries(typed.dataComponents).map(
8756
9305
  async ([componentId, componentData]) => {
8757
9306
  try {
8758
- logger13.info(
9307
+ logger14.info(
8759
9308
  { projectId: typed.id, componentId },
8760
9309
  "Updating dataComponent in project"
8761
9310
  );
@@ -8766,12 +9315,12 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8766
9315
  projectId: typed.id
8767
9316
  }
8768
9317
  });
8769
- logger13.info(
9318
+ logger14.info(
8770
9319
  { projectId: typed.id, componentId },
8771
9320
  "DataComponent updated successfully"
8772
9321
  );
8773
9322
  } catch (error) {
8774
- logger13.error(
9323
+ logger14.error(
8775
9324
  { projectId: typed.id, componentId, error },
8776
9325
  "Failed to update dataComponent in project"
8777
9326
  );
@@ -8780,7 +9329,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8780
9329
  }
8781
9330
  );
8782
9331
  await Promise.all(dataComponentPromises);
8783
- logger13.info(
9332
+ logger14.info(
8784
9333
  {
8785
9334
  projectId: typed.id,
8786
9335
  count: Object.keys(typed.dataComponents).length
@@ -8789,7 +9338,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8789
9338
  );
8790
9339
  }
8791
9340
  if (typed.artifactComponents && Object.keys(typed.artifactComponents).length > 0) {
8792
- logger13.info(
9341
+ logger14.info(
8793
9342
  {
8794
9343
  projectId: typed.id,
8795
9344
  count: Object.keys(typed.artifactComponents).length
@@ -8799,7 +9348,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8799
9348
  const artifactComponentPromises = Object.entries(typed.artifactComponents).map(
8800
9349
  async ([componentId, componentData]) => {
8801
9350
  try {
8802
- logger13.info(
9351
+ logger14.info(
8803
9352
  { projectId: typed.id, componentId },
8804
9353
  "Updating artifactComponent in project"
8805
9354
  );
@@ -8810,12 +9359,12 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8810
9359
  projectId: typed.id
8811
9360
  }
8812
9361
  });
8813
- logger13.info(
9362
+ logger14.info(
8814
9363
  { projectId: typed.id, componentId },
8815
9364
  "ArtifactComponent updated successfully"
8816
9365
  );
8817
9366
  } catch (error) {
8818
- logger13.error(
9367
+ logger14.error(
8819
9368
  { projectId: typed.id, componentId, error },
8820
9369
  "Failed to update artifactComponent in project"
8821
9370
  );
@@ -8824,7 +9373,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8824
9373
  }
8825
9374
  );
8826
9375
  await Promise.all(artifactComponentPromises);
8827
- logger13.info(
9376
+ logger14.info(
8828
9377
  {
8829
9378
  projectId: typed.id,
8830
9379
  count: Object.keys(typed.artifactComponents).length
@@ -8842,14 +9391,14 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8842
9391
  try {
8843
9392
  await deleteFullGraph(
8844
9393
  db,
8845
- logger13
9394
+ logger14
8846
9395
  )({
8847
9396
  scopes: { tenantId, projectId: typed.id, graphId: graph.id }
8848
9397
  });
8849
9398
  deletedGraphCount++;
8850
- logger13.info({ graphId: graph.id }, "Deleted orphaned graph from project");
9399
+ logger14.info({ graphId: graph.id }, "Deleted orphaned graph from project");
8851
9400
  } catch (error) {
8852
- logger13.error(
9401
+ logger14.error(
8853
9402
  { graphId: graph.id, error },
8854
9403
  "Failed to delete orphaned graph from project"
8855
9404
  );
@@ -8857,7 +9406,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8857
9406
  }
8858
9407
  }
8859
9408
  if (deletedGraphCount > 0) {
8860
- logger13.info(
9409
+ logger14.info(
8861
9410
  {
8862
9411
  deletedGraphCount,
8863
9412
  projectId: typed.id
@@ -8866,7 +9415,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8866
9415
  );
8867
9416
  }
8868
9417
  if (typed.graphs && Object.keys(typed.graphs).length > 0) {
8869
- logger13.info(
9418
+ logger14.info(
8870
9419
  {
8871
9420
  projectId: typed.id,
8872
9421
  graphCount: Object.keys(typed.graphs).length
@@ -8875,27 +9424,25 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8875
9424
  );
8876
9425
  const graphPromises = Object.entries(typed.graphs).map(async ([graphId, graphData]) => {
8877
9426
  try {
8878
- logger13.info({ projectId: typed.id, graphId }, "Updating graph in project");
9427
+ logger14.info({ projectId: typed.id, graphId }, "Updating graph in project");
8879
9428
  const graphDataWithProjectResources = {
8880
9429
  ...graphData,
8881
- agents: void 0,
8882
- // Remove 'agents' property from GraphWithinContextOfProjectSchema
8883
- subAgents: graphData.subAgents,
8884
- // Map 'agents' to 'subAgents' for FullGraphDefinitionSchema
8885
9430
  tools: typed.tools || {},
8886
- // Pass project-level resources for validation
9431
+ // Pass project-level MCP tools for validation
9432
+ functions: typed.functions || {},
9433
+ // Pass project-level functions for validation
8887
9434
  dataComponents: typed.dataComponents || {},
8888
9435
  artifactComponents: typed.artifactComponents || {},
8889
9436
  credentialReferences: typed.credentialReferences || {},
8890
9437
  statusUpdates: graphData.statusUpdates === null ? void 0 : graphData.statusUpdates
8891
9438
  };
8892
- await updateFullGraphServerSide(db, logger13)(
9439
+ await updateFullGraphServerSide(db, logger14)(
8893
9440
  { tenantId, projectId: typed.id },
8894
9441
  graphDataWithProjectResources
8895
9442
  );
8896
- logger13.info({ projectId: typed.id, graphId }, "Graph updated successfully in project");
9443
+ logger14.info({ projectId: typed.id, graphId }, "Graph updated successfully in project");
8897
9444
  } catch (error) {
8898
- logger13.error(
9445
+ logger14.error(
8899
9446
  { projectId: typed.id, graphId, error },
8900
9447
  "Failed to update graph in project"
8901
9448
  );
@@ -8903,7 +9450,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8903
9450
  }
8904
9451
  });
8905
9452
  await Promise.all(graphPromises);
8906
- logger13.info(
9453
+ logger14.info(
8907
9454
  {
8908
9455
  projectId: typed.id,
8909
9456
  graphCount: Object.keys(typed.graphs).length
@@ -8911,15 +9458,15 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8911
9458
  "All project graphs updated successfully"
8912
9459
  );
8913
9460
  }
8914
- logger13.info({ projectId: typed.id }, "Full project updated successfully");
9461
+ logger14.info({ projectId: typed.id }, "Full project updated successfully");
8915
9462
  return await getFullProject(
8916
9463
  db,
8917
- logger13
9464
+ logger14
8918
9465
  )({
8919
9466
  scopes: { tenantId, projectId: typed.id }
8920
9467
  });
8921
9468
  } catch (error) {
8922
- logger13.error(
9469
+ logger14.error(
8923
9470
  {
8924
9471
  tenantId,
8925
9472
  projectId: typed.id,
@@ -8930,23 +9477,23 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
8930
9477
  throw error;
8931
9478
  }
8932
9479
  };
8933
- var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9480
+ var getFullProject = (db, logger14 = defaultLogger2) => async (params) => {
8934
9481
  const { scopes } = params;
8935
9482
  const { tenantId, projectId } = scopes;
8936
- logger13.info({ tenantId, projectId }, "Retrieving full project definition");
9483
+ logger14.info({ tenantId, projectId }, "Retrieving full project definition");
8937
9484
  try {
8938
9485
  const project = await getProject(db)({
8939
9486
  scopes: { tenantId, projectId }
8940
9487
  });
8941
9488
  if (!project) {
8942
- logger13.info({ tenantId, projectId }, "Project not found");
9489
+ logger14.info({ tenantId, projectId }, "Project not found");
8943
9490
  return null;
8944
9491
  }
8945
- logger13.info({ tenantId, projectId }, "Project metadata retrieved");
9492
+ logger14.info({ tenantId, projectId }, "Project metadata retrieved");
8946
9493
  const graphList = await listAgentGraphs(db)({
8947
9494
  scopes: { tenantId, projectId }
8948
9495
  });
8949
- logger13.info(
9496
+ logger14.info(
8950
9497
  {
8951
9498
  tenantId,
8952
9499
  projectId,
@@ -8974,12 +9521,12 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
8974
9521
  // status, lastHealthCheck, availableTools, activeTools, lastToolsSync are all runtime
8975
9522
  };
8976
9523
  }
8977
- logger13.info(
9524
+ logger14.info(
8978
9525
  { tenantId, projectId, toolCount: Object.keys(projectTools).length },
8979
9526
  "Tools retrieved for project"
8980
9527
  );
8981
9528
  } catch (error) {
8982
- logger13.warn({ tenantId, projectId, error }, "Failed to retrieve tools for project");
9529
+ logger14.warn({ tenantId, projectId, error }, "Failed to retrieve tools for project");
8983
9530
  }
8984
9531
  const projectDataComponents = {};
8985
9532
  try {
@@ -8994,12 +9541,12 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
8994
9541
  props: component.props
8995
9542
  };
8996
9543
  }
8997
- logger13.info(
9544
+ logger14.info(
8998
9545
  { tenantId, projectId, count: Object.keys(projectDataComponents).length },
8999
9546
  "DataComponents retrieved for project"
9000
9547
  );
9001
9548
  } catch (error) {
9002
- logger13.warn(
9549
+ logger14.warn(
9003
9550
  { tenantId, projectId, error },
9004
9551
  "Failed to retrieve dataComponents for project"
9005
9552
  );
@@ -9017,12 +9564,12 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9017
9564
  props: component.props
9018
9565
  };
9019
9566
  }
9020
- logger13.info(
9567
+ logger14.info(
9021
9568
  { tenantId, projectId, count: Object.keys(projectArtifactComponents).length },
9022
9569
  "ArtifactComponents retrieved for project"
9023
9570
  );
9024
9571
  } catch (error) {
9025
- logger13.warn(
9572
+ logger14.warn(
9026
9573
  { tenantId, projectId, error },
9027
9574
  "Failed to retrieve artifactComponents for project"
9028
9575
  );
@@ -9040,12 +9587,12 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9040
9587
  retrievalParams: credential.retrievalParams
9041
9588
  };
9042
9589
  }
9043
- logger13.info(
9590
+ logger14.info(
9044
9591
  { tenantId, projectId, count: Object.keys(projectCredentialReferences).length },
9045
9592
  "CredentialReferences retrieved for project"
9046
9593
  );
9047
9594
  } catch (error) {
9048
- logger13.warn(
9595
+ logger14.warn(
9049
9596
  { tenantId, projectId, error },
9050
9597
  "Failed to retrieve credentialReferences for project"
9051
9598
  );
@@ -9054,7 +9601,7 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9054
9601
  if (graphList.length > 0) {
9055
9602
  const graphPromises = graphList.map(async (graph) => {
9056
9603
  try {
9057
- logger13.info(
9604
+ logger14.info(
9058
9605
  { tenantId, projectId, graphId: graph.id },
9059
9606
  "Retrieving full graph definition"
9060
9607
  );
@@ -9063,15 +9610,15 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9063
9610
  });
9064
9611
  if (fullGraph) {
9065
9612
  graphs[graph.id] = fullGraph;
9066
- logger13.info(
9613
+ logger14.info(
9067
9614
  { tenantId, projectId, graphId: graph.id },
9068
9615
  "Full graph definition retrieved"
9069
9616
  );
9070
9617
  } else {
9071
- logger13.warn({ tenantId, projectId, graphId: graph.id }, "Graph definition not found");
9618
+ logger14.warn({ tenantId, projectId, graphId: graph.id }, "Graph definition not found");
9072
9619
  }
9073
9620
  } catch (error) {
9074
- logger13.error(
9621
+ logger14.error(
9075
9622
  { tenantId, projectId, graphId: graph.id, error },
9076
9623
  "Failed to retrieve full graph definition"
9077
9624
  );
@@ -9098,7 +9645,7 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9098
9645
  createdAt: project.createdAt,
9099
9646
  updatedAt: project.updatedAt
9100
9647
  };
9101
- logger13.info(
9648
+ logger14.info(
9102
9649
  {
9103
9650
  tenantId,
9104
9651
  projectId,
@@ -9108,7 +9655,7 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9108
9655
  );
9109
9656
  return fullProjectDefinition;
9110
9657
  } catch (error) {
9111
- logger13.error(
9658
+ logger14.error(
9112
9659
  {
9113
9660
  tenantId,
9114
9661
  projectId,
@@ -9119,23 +9666,23 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9119
9666
  throw error;
9120
9667
  }
9121
9668
  };
9122
- var deleteFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9669
+ var deleteFullProject = (db, logger14 = defaultLogger2) => async (params) => {
9123
9670
  const { scopes } = params;
9124
9671
  const { tenantId, projectId } = scopes;
9125
- logger13.info({ tenantId, projectId }, "Deleting full project and related entities");
9672
+ logger14.info({ tenantId, projectId }, "Deleting full project and related entities");
9126
9673
  try {
9127
9674
  const project = await getFullProject(
9128
9675
  db,
9129
- logger13
9676
+ logger14
9130
9677
  )({
9131
9678
  scopes: { tenantId, projectId }
9132
9679
  });
9133
9680
  if (!project) {
9134
- logger13.info({ tenantId, projectId }, "Project not found for deletion");
9681
+ logger14.info({ tenantId, projectId }, "Project not found for deletion");
9135
9682
  return false;
9136
9683
  }
9137
9684
  if (project.graphs && Object.keys(project.graphs).length > 0) {
9138
- logger13.info(
9685
+ logger14.info(
9139
9686
  {
9140
9687
  tenantId,
9141
9688
  projectId,
@@ -9145,19 +9692,19 @@ var deleteFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9145
9692
  );
9146
9693
  const graphPromises = Object.keys(project.graphs).map(async (graphId) => {
9147
9694
  try {
9148
- logger13.info({ tenantId, projectId, graphId }, "Deleting graph from project");
9695
+ logger14.info({ tenantId, projectId, graphId }, "Deleting graph from project");
9149
9696
  await deleteFullGraph(
9150
9697
  db,
9151
- logger13
9698
+ logger14
9152
9699
  )({
9153
9700
  scopes: { tenantId, projectId, graphId }
9154
9701
  });
9155
- logger13.info(
9702
+ logger14.info(
9156
9703
  { tenantId, projectId, graphId },
9157
9704
  "Graph deleted successfully from project"
9158
9705
  );
9159
9706
  } catch (error) {
9160
- logger13.error(
9707
+ logger14.error(
9161
9708
  { tenantId, projectId, graphId, error },
9162
9709
  "Failed to delete graph from project"
9163
9710
  );
@@ -9165,7 +9712,7 @@ var deleteFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9165
9712
  }
9166
9713
  });
9167
9714
  await Promise.all(graphPromises);
9168
- logger13.info(
9715
+ logger14.info(
9169
9716
  {
9170
9717
  tenantId,
9171
9718
  projectId,
@@ -9178,13 +9725,13 @@ var deleteFullProject = (db, logger13 = defaultLogger2) => async (params) => {
9178
9725
  scopes: { tenantId, projectId }
9179
9726
  });
9180
9727
  if (!deleted) {
9181
- logger13.warn({ tenantId, projectId }, "Project deletion returned false");
9728
+ logger14.warn({ tenantId, projectId }, "Project deletion returned false");
9182
9729
  return false;
9183
9730
  }
9184
- logger13.info({ tenantId, projectId }, "Full project deleted successfully");
9731
+ logger14.info({ tenantId, projectId }, "Full project deleted successfully");
9185
9732
  return true;
9186
9733
  } catch (error) {
9187
- logger13.error(
9734
+ logger14.error(
9188
9735
  {
9189
9736
  tenantId,
9190
9737
  projectId,
@@ -9262,7 +9809,7 @@ var createValidatedDataAccess = (db, dataAccessFunctions) => {
9262
9809
 
9263
9810
  // src/utils/tracer.ts
9264
9811
  var tracer = getTracer("agents-core");
9265
- var logger7 = getLogger("context-cache");
9812
+ var logger8 = getLogger("context-cache");
9266
9813
  var ContextCache = class {
9267
9814
  constructor(tenantId, projectId, dbClient) {
9268
9815
  __publicField(this, "tenantId");
@@ -9271,7 +9818,7 @@ var ContextCache = class {
9271
9818
  this.tenantId = tenantId;
9272
9819
  this.projectId = projectId;
9273
9820
  this.dbClient = dbClient;
9274
- logger7.info(
9821
+ logger8.info(
9275
9822
  {
9276
9823
  tenantId: this.tenantId
9277
9824
  },
@@ -9306,7 +9853,7 @@ var ContextCache = class {
9306
9853
  tenantId: this.tenantId
9307
9854
  };
9308
9855
  } catch (error) {
9309
- logger7.error(
9856
+ logger8.error(
9310
9857
  {
9311
9858
  conversationId,
9312
9859
  contextConfigId,
@@ -9340,7 +9887,7 @@ var ContextCache = class {
9340
9887
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
9341
9888
  };
9342
9889
  await setCacheEntry(this.dbClient)(cacheData);
9343
- logger7.debug(
9890
+ logger8.debug(
9344
9891
  {
9345
9892
  conversationId: entry.conversationId,
9346
9893
  contextConfigId: entry.contextConfigId,
@@ -9349,7 +9896,7 @@ var ContextCache = class {
9349
9896
  "Cache entry set successfully"
9350
9897
  );
9351
9898
  } catch (error) {
9352
- logger7.error(
9899
+ logger8.error(
9353
9900
  {
9354
9901
  conversationId: entry.conversationId,
9355
9902
  contextConfigId: entry.contextConfigId,
@@ -9369,7 +9916,7 @@ var ContextCache = class {
9369
9916
  scopes: { tenantId, projectId },
9370
9917
  conversationId
9371
9918
  });
9372
- logger7.info(
9919
+ logger8.info(
9373
9920
  {
9374
9921
  conversationId,
9375
9922
  rowsCleared: result
@@ -9377,7 +9924,7 @@ var ContextCache = class {
9377
9924
  "Conversation cache cleared successfully"
9378
9925
  );
9379
9926
  } catch (error) {
9380
- logger7.error(
9927
+ logger8.error(
9381
9928
  {
9382
9929
  conversationId,
9383
9930
  error: error instanceof Error ? error.message : "Unknown error"
@@ -9396,7 +9943,7 @@ var ContextCache = class {
9396
9943
  scopes: { tenantId, projectId },
9397
9944
  contextConfigId
9398
9945
  });
9399
- logger7.info(
9946
+ logger8.info(
9400
9947
  {
9401
9948
  contextConfigId,
9402
9949
  rowsCleared: result
@@ -9404,7 +9951,7 @@ var ContextCache = class {
9404
9951
  "Context config cache cleared successfully"
9405
9952
  );
9406
9953
  } catch (error) {
9407
- logger7.error(
9954
+ logger8.error(
9408
9955
  {
9409
9956
  contextConfigId,
9410
9957
  error: error instanceof Error ? error.message : "Unknown error"
@@ -9422,14 +9969,14 @@ var ContextCache = class {
9422
9969
  const result = await cleanupTenantCache(this.dbClient)({
9423
9970
  scopes: { tenantId: this.tenantId, projectId: this.projectId }
9424
9971
  });
9425
- logger7.info(
9972
+ logger8.info(
9426
9973
  {
9427
9974
  rowsCleared: result
9428
9975
  },
9429
9976
  "Cache cleanup completed"
9430
9977
  );
9431
9978
  } catch (error) {
9432
- logger7.error(
9979
+ logger8.error(
9433
9980
  {
9434
9981
  error: error instanceof Error ? error.message : "Unknown error"
9435
9982
  },
@@ -9456,7 +10003,7 @@ var ContextCache = class {
9456
10003
  };
9457
10004
 
9458
10005
  // src/context/ContextResolver.ts
9459
- var logger8 = getLogger("context-resolver");
10006
+ var logger9 = getLogger("context-resolver");
9460
10007
  var ContextResolver = class {
9461
10008
  constructor(tenantId, projectId, dbClient, credentialStoreRegistry) {
9462
10009
  __publicField(this, "fetcher");
@@ -9467,7 +10014,7 @@ var ContextResolver = class {
9467
10014
  this.projectId = projectId;
9468
10015
  this.fetcher = new ContextFetcher(tenantId, projectId, dbClient, credentialStoreRegistry);
9469
10016
  this.cache = new ContextCache(tenantId, projectId, dbClient);
9470
- logger8.info(
10017
+ logger9.info(
9471
10018
  {
9472
10019
  tenantId: this.tenantId,
9473
10020
  hasCredentialSupport: !!credentialStoreRegistry
@@ -9480,7 +10027,7 @@ var ContextResolver = class {
9480
10027
  */
9481
10028
  async resolve(contextConfig2, options) {
9482
10029
  const startTime = Date.now();
9483
- logger8.info(
10030
+ logger9.info(
9484
10031
  {
9485
10032
  contextConfigId: contextConfig2.id,
9486
10033
  triggerEvent: options.triggerEvent,
@@ -9520,7 +10067,7 @@ var ContextResolver = class {
9520
10067
  options.conversationId,
9521
10068
  contextConfig2.id
9522
10069
  );
9523
- logger8.info(
10070
+ logger9.info(
9524
10071
  {
9525
10072
  conversationId: options.conversationId,
9526
10073
  contextConfigId: contextConfig2.id
@@ -9534,7 +10081,7 @@ var ContextResolver = class {
9534
10081
  value: options.headers,
9535
10082
  tenantId: this.tenantId
9536
10083
  });
9537
- logger8.info(
10084
+ logger9.info(
9538
10085
  {
9539
10086
  conversationId: options.conversationId,
9540
10087
  contextConfigId: contextConfig2.id
@@ -9550,7 +10097,7 @@ var ContextResolver = class {
9550
10097
  const contextVariables = contextConfig2.contextVariables || {};
9551
10098
  const contextVariableEntries = Object.entries(contextVariables);
9552
10099
  if (contextVariableEntries.length === 0) {
9553
- logger8.info(
10100
+ logger9.info(
9554
10101
  {
9555
10102
  contextConfigId: contextConfig2.id
9556
10103
  },
@@ -9586,7 +10133,7 @@ var ContextResolver = class {
9586
10133
  result
9587
10134
  ).catch((error) => {
9588
10135
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
9589
- logger8.error(
10136
+ logger9.error(
9590
10137
  {
9591
10138
  contextConfigId: contextConfig2.id,
9592
10139
  definitionId: definition.id,
@@ -9601,7 +10148,7 @@ var ContextResolver = class {
9601
10148
  });
9602
10149
  if (definition.defaultValue !== void 0) {
9603
10150
  result.resolvedContext[templateKey] = definition.defaultValue;
9604
- logger8.info(
10151
+ logger9.info(
9605
10152
  {
9606
10153
  contextConfigId: contextConfig2.id,
9607
10154
  definitionId: definition.id,
@@ -9626,7 +10173,7 @@ var ContextResolver = class {
9626
10173
  } else {
9627
10174
  parentSpan.setStatus({ code: api.SpanStatusCode.OK });
9628
10175
  }
9629
- logger8.info(
10176
+ logger9.info(
9630
10177
  {
9631
10178
  contextConfigId: contextConfig2.id,
9632
10179
  resolvedKeys: Object.keys(result.resolvedContext),
@@ -9642,7 +10189,7 @@ var ContextResolver = class {
9642
10189
  } catch (error) {
9643
10190
  const durationMs = Date.now() - startTime;
9644
10191
  setSpanWithError(parentSpan, error instanceof Error ? error : new Error(String(error)));
9645
- logger8.error(
10192
+ logger9.error(
9646
10193
  {
9647
10194
  contextConfigId: contextConfig2.id,
9648
10195
  error: error instanceof Error ? error.message : String(error),
@@ -9670,7 +10217,7 @@ var ContextResolver = class {
9670
10217
  if (cachedEntry) {
9671
10218
  result.resolvedContext[templateKey] = cachedEntry.value;
9672
10219
  result.cacheHits.push(definition.id);
9673
- logger8.debug(
10220
+ logger9.debug(
9674
10221
  {
9675
10222
  definitionId: definition.id,
9676
10223
  templateKey,
@@ -9681,7 +10228,7 @@ var ContextResolver = class {
9681
10228
  return;
9682
10229
  }
9683
10230
  result.cacheMisses.push(definition.id);
9684
- logger8.debug(
10231
+ logger9.debug(
9685
10232
  {
9686
10233
  definitionId: definition.id,
9687
10234
  templateKey,
@@ -9738,7 +10285,7 @@ var ContextResolver = class {
9738
10285
  requestHash,
9739
10286
  tenantId: this.tenantId
9740
10287
  });
9741
- logger8.debug(
10288
+ logger9.debug(
9742
10289
  {
9743
10290
  definitionId: definition.id,
9744
10291
  templateKey,
@@ -9773,7 +10320,7 @@ var ContextResolver = class {
9773
10320
  */
9774
10321
  async clearCache(tenantId, projectId, conversationId) {
9775
10322
  await this.cache.clearConversation(tenantId, projectId, conversationId);
9776
- logger8.info(
10323
+ logger9.info(
9777
10324
  {
9778
10325
  conversationId
9779
10326
  },
@@ -9783,7 +10330,7 @@ var ContextResolver = class {
9783
10330
  };
9784
10331
 
9785
10332
  // src/middleware/contextValidation.ts
9786
- var logger9 = getLogger("context-validation");
10333
+ var logger10 = getLogger("context-validation");
9787
10334
  var ajv = new Ajv__default.default({ allErrors: true, strict: false });
9788
10335
  var HTTP_REQUEST_PARTS = ["headers"];
9789
10336
  var MAX_SCHEMA_CACHE_SIZE = 1e3;
@@ -9846,7 +10393,7 @@ function validationHelper(jsonSchema) {
9846
10393
  return getCachedValidator(jsonSchema);
9847
10394
  }
9848
10395
  function validateAgainstJsonSchema(jsonSchema, context) {
9849
- logger9.debug({ jsonSchema, context }, "Validating context against JSON Schema");
10396
+ logger10.debug({ jsonSchema, context }, "Validating context against JSON Schema");
9850
10397
  const validate = validationHelper(jsonSchema);
9851
10398
  return validate(context);
9852
10399
  }
@@ -9936,7 +10483,7 @@ async function validateHttpRequestHeaders(headersSchema, httpRequest) {
9936
10483
  validatedContext: filteredContext
9937
10484
  };
9938
10485
  } catch (error) {
9939
- logger9.error(
10486
+ logger10.error(
9940
10487
  { error: error instanceof Error ? error.message : "Unknown error" },
9941
10488
  "Failed to validate headers schema"
9942
10489
  );
@@ -9989,7 +10536,7 @@ async function validateHeaders({
9989
10536
  scopes: { tenantId, projectId, graphId }
9990
10537
  });
9991
10538
  if (!agentGraph2?.contextConfigId) {
9992
- logger9.debug({ graphId }, "No context config found for graph, skipping validation");
10539
+ logger10.debug({ graphId }, "No context config found for graph, skipping validation");
9993
10540
  return {
9994
10541
  valid: true,
9995
10542
  errors: [],
@@ -10001,7 +10548,7 @@ async function validateHeaders({
10001
10548
  id: agentGraph2.contextConfigId
10002
10549
  });
10003
10550
  if (!contextConfig2) {
10004
- logger9.warn({ contextConfigId: agentGraph2.contextConfigId }, "Context config not found");
10551
+ logger10.warn({ contextConfigId: agentGraph2.contextConfigId }, "Context config not found");
10005
10552
  return {
10006
10553
  valid: false,
10007
10554
  errors: [
@@ -10013,7 +10560,7 @@ async function validateHeaders({
10013
10560
  };
10014
10561
  }
10015
10562
  if (!contextConfig2.headersSchema) {
10016
- logger9.debug(
10563
+ logger10.debug(
10017
10564
  { contextConfigId: contextConfig2.id },
10018
10565
  "No headers schema defined, accepting any context"
10019
10566
  );
@@ -10025,7 +10572,7 @@ async function validateHeaders({
10025
10572
  }
10026
10573
  try {
10027
10574
  const schema = contextConfig2.headersSchema;
10028
- logger9.debug({ contextConfigId: contextConfig2.id }, "Using headers schema validation");
10575
+ logger10.debug({ contextConfigId: contextConfig2.id }, "Using headers schema validation");
10029
10576
  const httpRequest = parsedRequest;
10030
10577
  const validationResult = await validateHttpRequestHeaders(schema, httpRequest);
10031
10578
  if (validationResult.valid) {
@@ -10048,7 +10595,7 @@ async function validateHeaders({
10048
10595
  return validationResult;
10049
10596
  }
10050
10597
  } catch (error) {
10051
- logger9.error(
10598
+ logger10.error(
10052
10599
  {
10053
10600
  contextConfigId: contextConfig2.id,
10054
10601
  error: error instanceof Error ? error.message : "Unknown error"
@@ -10066,7 +10613,7 @@ async function validateHeaders({
10066
10613
  };
10067
10614
  }
10068
10615
  } catch (error) {
10069
- logger9.error(
10616
+ logger10.error(
10070
10617
  {
10071
10618
  tenantId,
10072
10619
  graphId,
@@ -10118,7 +10665,7 @@ function contextValidationMiddleware(dbClient) {
10118
10665
  credentialStores
10119
10666
  });
10120
10667
  if (!validationResult.valid) {
10121
- logger9.warn(
10668
+ logger10.warn(
10122
10669
  {
10123
10670
  tenantId,
10124
10671
  graphId,
@@ -10133,7 +10680,7 @@ function contextValidationMiddleware(dbClient) {
10133
10680
  });
10134
10681
  }
10135
10682
  c.set("validatedContext", validationResult.validatedContext);
10136
- logger9.debug(
10683
+ logger10.debug(
10137
10684
  {
10138
10685
  tenantId,
10139
10686
  graphId,
@@ -10143,7 +10690,7 @@ function contextValidationMiddleware(dbClient) {
10143
10690
  );
10144
10691
  return next();
10145
10692
  } catch (error) {
10146
- logger9.error(
10693
+ logger10.error(
10147
10694
  {
10148
10695
  error: error instanceof Error ? error.message : "Unknown error"
10149
10696
  },
@@ -10158,7 +10705,7 @@ function contextValidationMiddleware(dbClient) {
10158
10705
  }
10159
10706
 
10160
10707
  // src/context/ContextFetcher.ts
10161
- var logger10 = getLogger("context-fetcher");
10708
+ var logger11 = getLogger("context-fetcher");
10162
10709
  var checkGraphQLErrors = (data) => {
10163
10710
  if (data && typeof data === "object" && "errors" in data) {
10164
10711
  const errorObj = data;
@@ -10187,7 +10734,7 @@ var ContextFetcher = class {
10187
10734
  this.credentialStuffer = new CredentialStuffer(credentialStoreRegistry);
10188
10735
  }
10189
10736
  this.dbClient = dbClient;
10190
- logger10.info(
10737
+ logger11.info(
10191
10738
  {
10192
10739
  tenantId: this.tenantId,
10193
10740
  defaultTimeout: this.defaultTimeout,
@@ -10201,7 +10748,7 @@ var ContextFetcher = class {
10201
10748
  */
10202
10749
  async fetch(definition, context) {
10203
10750
  const startTime = Date.now();
10204
- logger10.info(
10751
+ logger11.info(
10205
10752
  {
10206
10753
  definitionId: definition.id,
10207
10754
  url: definition.fetchConfig.url
@@ -10215,7 +10762,7 @@ var ContextFetcher = class {
10215
10762
  definition.credentialReferenceId
10216
10763
  );
10217
10764
  const response = await this.performRequest(resolvedConfig);
10218
- logger10.info({ response }, "ContextFetcher Response");
10765
+ logger11.info({ response }, "ContextFetcher Response");
10219
10766
  let transformedData = response.data;
10220
10767
  if (definition.fetchConfig.transform) {
10221
10768
  transformedData = this.transformResponse(response.data, definition.fetchConfig.transform);
@@ -10228,7 +10775,7 @@ var ContextFetcher = class {
10228
10775
  );
10229
10776
  }
10230
10777
  const durationMs = Date.now() - startTime;
10231
- logger10.info(
10778
+ logger11.info(
10232
10779
  {
10233
10780
  definitionId: definition.id,
10234
10781
  source: response.source,
@@ -10240,7 +10787,7 @@ var ContextFetcher = class {
10240
10787
  } catch (error) {
10241
10788
  const durationMs = Date.now() - startTime;
10242
10789
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
10243
- logger10.error(
10790
+ logger11.error(
10244
10791
  {
10245
10792
  definitionId: definition.id,
10246
10793
  error: errorMessage,
@@ -10257,7 +10804,7 @@ var ContextFetcher = class {
10257
10804
  scopes: { tenantId: this.tenantId, projectId: this.projectId },
10258
10805
  id: credentialReferenceId
10259
10806
  });
10260
- logger10.info({ credentialReference }, "Credential reference");
10807
+ logger11.info({ credentialReference }, "Credential reference");
10261
10808
  if (!credentialReference || !this.credentialStuffer) {
10262
10809
  throw new Error(`Credential store not found for reference ID: ${credentialReferenceId}`);
10263
10810
  }
@@ -10275,7 +10822,7 @@ var ContextFetcher = class {
10275
10822
  );
10276
10823
  return credentialData;
10277
10824
  } catch (error) {
10278
- logger10.error(
10825
+ logger11.error(
10279
10826
  {
10280
10827
  credentialReferenceId,
10281
10828
  error: error instanceof Error ? error.message : "Unknown error"
@@ -10291,7 +10838,7 @@ var ContextFetcher = class {
10291
10838
  async resolveTemplateVariables(fetchConfig, context, credentialReferenceId) {
10292
10839
  const resolved = { ...fetchConfig };
10293
10840
  resolved.url = this.interpolateTemplate(fetchConfig.url, context);
10294
- logger10.info({ resolvedUrl: resolved.url }, "Resolved URL");
10841
+ logger11.info({ resolvedUrl: resolved.url }, "Resolved URL");
10295
10842
  if (fetchConfig.headers) {
10296
10843
  resolved.headers = {};
10297
10844
  for (const [key, value] of Object.entries(fetchConfig.headers)) {
@@ -10310,7 +10857,7 @@ var ContextFetcher = class {
10310
10857
  ...resolved.headers,
10311
10858
  ...credentialHeaders
10312
10859
  };
10313
- logger10.info(
10860
+ logger11.info(
10314
10861
  {
10315
10862
  credentialReferenceId
10316
10863
  },
@@ -10318,7 +10865,7 @@ var ContextFetcher = class {
10318
10865
  );
10319
10866
  }
10320
10867
  } catch (error) {
10321
- logger10.error(
10868
+ logger11.error(
10322
10869
  {
10323
10870
  credentialReferenceId,
10324
10871
  error: error instanceof Error ? error.message : "Unknown error"
@@ -10340,7 +10887,7 @@ var ContextFetcher = class {
10340
10887
  preserveUnresolved: true
10341
10888
  });
10342
10889
  } catch (error) {
10343
- logger10.error(
10890
+ logger11.error(
10344
10891
  {
10345
10892
  template,
10346
10893
  error: error instanceof Error ? error.message : "Unknown error"
@@ -10372,7 +10919,7 @@ var ContextFetcher = class {
10372
10919
  async performRequest(config) {
10373
10920
  const startTime = Date.now();
10374
10921
  try {
10375
- logger10.debug(
10922
+ logger11.debug(
10376
10923
  {
10377
10924
  url: config.url,
10378
10925
  method: config.method
@@ -10409,7 +10956,7 @@ var ContextFetcher = class {
10409
10956
  } catch (error) {
10410
10957
  const durationMs = Date.now() - startTime;
10411
10958
  const requestError = error instanceof Error ? error : new Error("Unknown error");
10412
- logger10.warn(
10959
+ logger11.warn(
10413
10960
  {
10414
10961
  url: config.url,
10415
10962
  error: requestError.message,
@@ -10428,7 +10975,7 @@ var ContextFetcher = class {
10428
10975
  const result = jmespath__default.default.search(data, transform);
10429
10976
  return result;
10430
10977
  } catch (error) {
10431
- logger10.error(
10978
+ logger11.error(
10432
10979
  {
10433
10980
  transform,
10434
10981
  error: error instanceof Error ? error.message : "Unknown error"
@@ -10447,7 +10994,7 @@ var ContextFetcher = class {
10447
10994
  if (!isValid) {
10448
10995
  throw new Error("Data does not match JSON Schema");
10449
10996
  }
10450
- logger10.debug(
10997
+ logger11.debug(
10451
10998
  {
10452
10999
  definitionId,
10453
11000
  dataType: typeof data,
@@ -10457,7 +11004,7 @@ var ContextFetcher = class {
10457
11004
  );
10458
11005
  } catch (error) {
10459
11006
  const errorMessage = error instanceof Error ? error.message : "Unknown validation error";
10460
- logger10.error(
11007
+ logger11.error(
10461
11008
  {
10462
11009
  definitionId,
10463
11010
  jsonSchema,
@@ -10498,7 +11045,7 @@ var ContextFetcher = class {
10498
11045
  };
10499
11046
  }
10500
11047
  };
10501
- var logger11 = getLogger("context");
11048
+ var logger12 = getLogger("context");
10502
11049
  async function determineContextTrigger(tenantId, projectId, conversationId, dbClient) {
10503
11050
  const conversation = await getConversation(dbClient)({
10504
11051
  scopes: { tenantId, projectId },
@@ -10518,7 +11065,7 @@ async function handleContextConfigChange(tenantId, projectId, conversationId, gr
10518
11065
  if (conversation.lastContextResolution) {
10519
11066
  const contextResolver = new ContextResolver(tenantId, projectId, dbClient, credentialStores);
10520
11067
  await contextResolver.clearCache(tenantId, projectId, conversationId);
10521
- logger11.info(
11068
+ logger12.info(
10522
11069
  {
10523
11070
  conversationId,
10524
11071
  graphId,
@@ -10552,7 +11099,7 @@ async function handleContextResolution({
10552
11099
  scopes: { tenantId, projectId, graphId }
10553
11100
  });
10554
11101
  if (!agentGraph2?.contextConfigId) {
10555
- logger11.debug({ graphId }, "No context config found for graph");
11102
+ logger12.debug({ graphId }, "No context config found for graph");
10556
11103
  return null;
10557
11104
  }
10558
11105
  await handleContextConfigChange(
@@ -10570,7 +11117,7 @@ async function handleContextResolution({
10570
11117
  id: agentGraph2.contextConfigId
10571
11118
  });
10572
11119
  if (!contextConfig2) {
10573
- logger11.warn(
11120
+ logger12.warn(
10574
11121
  { contextConfigId: agentGraph2.contextConfigId },
10575
11122
  "Context config not found, proceeding without context resolution"
10576
11123
  );
@@ -10612,7 +11159,7 @@ async function handleContextResolution({
10612
11159
  } else {
10613
11160
  parentSpan.setStatus({ code: api.SpanStatusCode.OK });
10614
11161
  }
10615
- logger11.info(
11162
+ logger12.info(
10616
11163
  {
10617
11164
  conversationId,
10618
11165
  graphId,
@@ -10634,7 +11181,7 @@ async function handleContextResolution({
10634
11181
  "context.error_message": errorMessage
10635
11182
  });
10636
11183
  setSpanWithError(parentSpan, error instanceof Error ? error : new Error(String(error)));
10637
- logger11.error(
11184
+ logger12.error(
10638
11185
  {
10639
11186
  error: errorMessage,
10640
11187
  contextConfigId: agentGraph2?.contextConfigId,
@@ -10975,7 +11522,7 @@ var InMemoryCredentialStore = class {
10975
11522
  return this.credentials.delete(key);
10976
11523
  }
10977
11524
  };
10978
- var logger12 = getLogger("nango-credential-store");
11525
+ var logger13 = getLogger("nango-credential-store");
10979
11526
  var CredentialKeySchema = zod.z.object({
10980
11527
  connectionId: zod.z.string().min(1, "connectionId must be a non-empty string"),
10981
11528
  providerConfigKey: zod.z.string().min(1, "providerConfigKey must be a non-empty string")
@@ -11115,7 +11662,7 @@ var NangoCredentialStore = class {
11115
11662
  if (error && typeof error === "object" && "status" in error && error.status === 404) {
11116
11663
  return null;
11117
11664
  }
11118
- logger12.error(
11665
+ logger13.error(
11119
11666
  { error: error instanceof Error ? error.message : "Unknown error", uniqueKey },
11120
11667
  `Failed to fetch integration ${uniqueKey}`
11121
11668
  );
@@ -11141,7 +11688,7 @@ var NangoCredentialStore = class {
11141
11688
  });
11142
11689
  const result = JSON.stringify(essential);
11143
11690
  if (result.length > 1024) {
11144
- logger12.error(
11691
+ logger13.error(
11145
11692
  {
11146
11693
  originalLength: tokenData.length,
11147
11694
  essentialLength: result.length,
@@ -11215,7 +11762,7 @@ var NangoCredentialStore = class {
11215
11762
  );
11216
11763
  }
11217
11764
  } catch (error) {
11218
- logger12.error(
11765
+ logger13.error(
11219
11766
  {
11220
11767
  error: error instanceof Error ? error.message : "Unknown error",
11221
11768
  name
@@ -11250,7 +11797,7 @@ var NangoCredentialStore = class {
11250
11797
  };
11251
11798
  return credentialData;
11252
11799
  } catch (error) {
11253
- logger12.error(
11800
+ logger13.error(
11254
11801
  {
11255
11802
  error: error instanceof Error ? error.message : "Unknown error",
11256
11803
  connectionId,
@@ -11271,7 +11818,7 @@ var NangoCredentialStore = class {
11271
11818
  try {
11272
11819
  parsedKey = JSON.parse(key);
11273
11820
  } catch (parseError) {
11274
- logger12.warn(
11821
+ logger13.warn(
11275
11822
  {
11276
11823
  storeId: this.id,
11277
11824
  key: key.substring(0, 50),
@@ -11284,7 +11831,7 @@ var NangoCredentialStore = class {
11284
11831
  }
11285
11832
  const validationResult = CredentialKeySchema.safeParse(parsedKey);
11286
11833
  if (!validationResult.success) {
11287
- logger12.warn(
11834
+ logger13.warn(
11288
11835
  {
11289
11836
  storeId: this.id,
11290
11837
  key: key.substring(0, 100),
@@ -11302,7 +11849,7 @@ var NangoCredentialStore = class {
11302
11849
  const credentialString = JSON.stringify(credentials);
11303
11850
  return credentialString;
11304
11851
  } catch (error) {
11305
- logger12.error(
11852
+ logger13.error(
11306
11853
  {
11307
11854
  storeId: this.id,
11308
11855
  key: key.substring(0, 100),
@@ -11331,7 +11878,7 @@ var NangoCredentialStore = class {
11331
11878
  const credentials = await this.get(key);
11332
11879
  return credentials !== null;
11333
11880
  } catch (error) {
11334
- logger12.error(
11881
+ logger13.error(
11335
11882
  {
11336
11883
  error: error instanceof Error ? error.message : "Unknown error",
11337
11884
  key
@@ -11350,7 +11897,7 @@ var NangoCredentialStore = class {
11350
11897
  try {
11351
11898
  parsedKey = JSON.parse(key);
11352
11899
  } catch (parseError) {
11353
- logger12.warn(
11900
+ logger13.warn(
11354
11901
  {
11355
11902
  storeId: this.id,
11356
11903
  key: key.substring(0, 50),
@@ -11363,7 +11910,7 @@ var NangoCredentialStore = class {
11363
11910
  }
11364
11911
  const validationResult = CredentialKeySchema.safeParse(parsedKey);
11365
11912
  if (!validationResult.success) {
11366
- logger12.warn(
11913
+ logger13.warn(
11367
11914
  {
11368
11915
  storeId: this.id,
11369
11916
  key: key.substring(0, 100),
@@ -11377,7 +11924,7 @@ var NangoCredentialStore = class {
11377
11924
  await this.nangoClient.deleteConnection(providerConfigKey, connectionId);
11378
11925
  return true;
11379
11926
  } catch (error) {
11380
- logger12.error(
11927
+ logger13.error(
11381
11928
  {
11382
11929
  storeId: this.id,
11383
11930
  key: key.substring(0, 100),
@@ -11624,13 +12171,20 @@ exports.FIELD_TYPES = FIELD_TYPES;
11624
12171
  exports.FetchConfigSchema = FetchConfigSchema;
11625
12172
  exports.FetchDefinitionSchema = FetchDefinitionSchema;
11626
12173
  exports.FullGraphAgentInsertSchema = FullGraphAgentInsertSchema;
12174
+ exports.FullGraphDefinitionSchema = FullGraphDefinitionSchema;
11627
12175
  exports.FullProjectDefinitionSchema = FullProjectDefinitionSchema;
11628
12176
  exports.FunctionApiInsertSchema = FunctionApiInsertSchema;
11629
12177
  exports.FunctionApiSelectSchema = FunctionApiSelectSchema;
11630
12178
  exports.FunctionApiUpdateSchema = FunctionApiUpdateSchema;
11631
12179
  exports.FunctionInsertSchema = FunctionInsertSchema;
11632
12180
  exports.FunctionSelectSchema = FunctionSelectSchema;
12181
+ exports.FunctionToolApiInsertSchema = FunctionToolApiInsertSchema;
12182
+ exports.FunctionToolApiSelectSchema = FunctionToolApiSelectSchema;
12183
+ exports.FunctionToolApiUpdateSchema = FunctionToolApiUpdateSchema;
11633
12184
  exports.FunctionToolConfigSchema = FunctionToolConfigSchema;
12185
+ exports.FunctionToolInsertSchema = FunctionToolInsertSchema;
12186
+ exports.FunctionToolSelectSchema = FunctionToolSelectSchema;
12187
+ exports.FunctionToolUpdateSchema = FunctionToolUpdateSchema;
11634
12188
  exports.FunctionUpdateSchema = FunctionUpdateSchema;
11635
12189
  exports.GraphStopWhenSchema = GraphStopWhenSchema;
11636
12190
  exports.GraphWithinContextOfProjectSchema = GraphWithinContextOfProjectSchema;
@@ -11758,8 +12312,11 @@ exports.TransferDataSchema = TransferDataSchema;
11758
12312
  exports.UNKNOWN_VALUE = UNKNOWN_VALUE;
11759
12313
  exports.URL_SAFE_ID_PATTERN = URL_SAFE_ID_PATTERN;
11760
12314
  exports.VALID_RELATION_TYPES = VALID_RELATION_TYPES;
12315
+ exports.addFunctionToolToSubAgent = addFunctionToolToSubAgent;
11761
12316
  exports.addLedgerArtifacts = addLedgerArtifacts;
11762
12317
  exports.addToolToAgent = addToolToAgent;
12318
+ exports.agentFunctionToolRelations = agentFunctionToolRelations;
12319
+ exports.agentFunctionToolRelationsRelations = agentFunctionToolRelationsRelations;
11763
12320
  exports.agentGraph = agentGraph;
11764
12321
  exports.agentGraphRelations = agentGraphRelations;
11765
12322
  exports.agentToolRelationsRelations = agentToolRelationsRelations;
@@ -11813,6 +12370,7 @@ exports.createExternalAgent = createExternalAgent;
11813
12370
  exports.createExternalAgentRelation = createExternalAgentRelation;
11814
12371
  exports.createFullGraphServerSide = createFullGraphServerSide;
11815
12372
  exports.createFullProjectServerSide = createFullProjectServerSide;
12373
+ exports.createFunctionTool = createFunctionTool;
11816
12374
  exports.createInMemoryDatabaseClient = createInMemoryDatabaseClient;
11817
12375
  exports.createKeyChainStore = createKeyChainStore;
11818
12376
  exports.createMessage = createMessage;
@@ -11845,6 +12403,7 @@ exports.deleteExternalAgent = deleteExternalAgent;
11845
12403
  exports.deleteFullGraph = deleteFullGraph;
11846
12404
  exports.deleteFullProject = deleteFullProject;
11847
12405
  exports.deleteFunction = deleteFunction;
12406
+ exports.deleteFunctionTool = deleteFunctionTool;
11848
12407
  exports.deleteLedgerArtifactsByContext = deleteLedgerArtifactsByContext;
11849
12408
  exports.deleteLedgerArtifactsByTask = deleteLedgerArtifactsByTask;
11850
12409
  exports.deleteMessage = deleteMessage;
@@ -11865,6 +12424,8 @@ exports.extractPreviewFields = extractPreviewFields;
11865
12424
  exports.extractPublicId = extractPublicId;
11866
12425
  exports.fetchComponentRelationships = fetchComponentRelationships;
11867
12426
  exports.fetchDefinition = fetchDefinition;
12427
+ exports.functionTools = functionTools;
12428
+ exports.functionToolsRelations = functionToolsRelations;
11868
12429
  exports.functions = functions;
11869
12430
  exports.functionsRelations = functionsRelations;
11870
12431
  exports.generateAndCreateApiKey = generateAndCreateApiKey;
@@ -11911,6 +12472,8 @@ exports.getFullGraph = getFullGraph;
11911
12472
  exports.getFullGraphDefinition = getFullGraphDefinition;
11912
12473
  exports.getFullProject = getFullProject;
11913
12474
  exports.getFunction = getFunction;
12475
+ exports.getFunctionToolById = getFunctionToolById;
12476
+ exports.getFunctionToolsForSubAgent = getFunctionToolsForSubAgent;
11914
12477
  exports.getGraphAgentInfos = getGraphAgentInfos;
11915
12478
  exports.getLedgerArtifacts = getLedgerArtifacts;
11916
12479
  exports.getLedgerArtifactsByContext = getLedgerArtifactsByContext;
@@ -11967,6 +12530,7 @@ exports.listDataComponents = listDataComponents;
11967
12530
  exports.listDataComponentsPaginated = listDataComponentsPaginated;
11968
12531
  exports.listExternalAgents = listExternalAgents;
11969
12532
  exports.listExternalAgentsPaginated = listExternalAgentsPaginated;
12533
+ exports.listFunctionTools = listFunctionTools;
11970
12534
  exports.listFunctions = listFunctions;
11971
12535
  exports.listMessages = listMessages;
11972
12536
  exports.listProjects = listProjects;
@@ -12024,24 +12588,28 @@ exports.updateDataComponent = updateDataComponent;
12024
12588
  exports.updateExternalAgent = updateExternalAgent;
12025
12589
  exports.updateFullGraphServerSide = updateFullGraphServerSide;
12026
12590
  exports.updateFullProjectServerSide = updateFullProjectServerSide;
12591
+ exports.updateFunctionTool = updateFunctionTool;
12027
12592
  exports.updateMessage = updateMessage;
12028
12593
  exports.updateProject = updateProject;
12029
12594
  exports.updateSubAgent = updateSubAgent;
12595
+ exports.updateSubAgentFunctionToolRelation = updateSubAgentFunctionToolRelation;
12030
12596
  exports.updateTask = updateTask;
12031
12597
  exports.updateTool = updateTool;
12032
12598
  exports.upsertAgentArtifactComponentRelation = upsertAgentArtifactComponentRelation;
12033
12599
  exports.upsertAgentDataComponentRelation = upsertAgentDataComponentRelation;
12034
12600
  exports.upsertAgentGraph = upsertAgentGraph;
12035
12601
  exports.upsertAgentRelation = upsertAgentRelation;
12036
- exports.upsertAgentToolRelation = upsertAgentToolRelation;
12037
12602
  exports.upsertArtifactComponent = upsertArtifactComponent;
12038
12603
  exports.upsertContextConfig = upsertContextConfig;
12039
12604
  exports.upsertCredentialReference = upsertCredentialReference;
12040
12605
  exports.upsertDataComponent = upsertDataComponent;
12041
12606
  exports.upsertExternalAgent = upsertExternalAgent;
12042
12607
  exports.upsertFunction = upsertFunction;
12608
+ exports.upsertFunctionTool = upsertFunctionTool;
12043
12609
  exports.upsertLedgerArtifact = upsertLedgerArtifact;
12044
12610
  exports.upsertSubAgent = upsertSubAgent;
12611
+ exports.upsertSubAgentFunctionToolRelation = upsertSubAgentFunctionToolRelation;
12612
+ exports.upsertSubAgentToolRelation = upsertSubAgentToolRelation;
12045
12613
  exports.upsertTool = upsertTool;
12046
12614
  exports.validateAgainstJsonSchema = validateAgainstJsonSchema;
12047
12615
  exports.validateAgentRelationships = validateAgentRelationships;