@inkeep/agents-core 0.0.0-dev-20251009192735 → 0.0.0-dev-20251009215610

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +2 -2
  2. package/dist/{chunk-VPJ6Z5QZ.js → chunk-5LRSB445.js} +115 -118
  3. package/dist/{chunk-TO2HNKGP.js → chunk-BVURASVM.js} +74 -110
  4. package/dist/chunk-TCLX6C3C.js +271 -0
  5. package/dist/chunk-ZSQFZL3Y.js +173 -0
  6. package/dist/client-exports.cjs +483 -225
  7. package/dist/client-exports.d.cts +6 -5
  8. package/dist/client-exports.d.ts +6 -5
  9. package/dist/client-exports.js +5 -4
  10. package/dist/db/schema.cjs +114 -117
  11. package/dist/db/schema.d.cts +2 -2
  12. package/dist/db/schema.d.ts +2 -2
  13. package/dist/db/schema.js +1 -1
  14. package/dist/index.cjs +1687 -1360
  15. package/dist/index.d.cts +1530 -1524
  16. package/dist/index.d.ts +1530 -1524
  17. package/dist/index.js +1016 -989
  18. package/dist/{schema-Ct2NlO81.d.cts → schema-B1rukNyF.d.ts} +118 -137
  19. package/dist/{schema-BQk_FMBV.d.ts → schema-BIYOOKX_.d.cts} +118 -137
  20. package/dist/signoz-queries-CifqdbnO.d.cts +269 -0
  21. package/dist/signoz-queries-CifqdbnO.d.ts +269 -0
  22. package/dist/types/index.d.cts +2 -2
  23. package/dist/types/index.d.ts +2 -2
  24. package/dist/{utility-s9c5CVOe.d.cts → utility-BEeDGMP9.d.cts} +226 -297
  25. package/dist/{utility-s9c5CVOe.d.ts → utility-BEeDGMP9.d.ts} +226 -297
  26. package/dist/validation/index.cjs +243 -238
  27. package/dist/validation/index.d.cts +76 -4
  28. package/dist/validation/index.d.ts +76 -4
  29. package/dist/validation/index.js +2 -2
  30. package/drizzle/0005_wide_shriek.sql +127 -0
  31. package/drizzle/meta/0005_snapshot.json +2558 -0
  32. package/drizzle/meta/_journal.json +7 -0
  33. package/package.json +1 -1
  34. package/dist/chunk-L53XWAYG.js +0 -134
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var zod = require('zod');
3
4
  var zodOpenapi = require('@hono/zod-openapi');
4
5
  var drizzleZod = require('drizzle-zod');
5
6
  var drizzleOrm = require('drizzle-orm');
@@ -10,7 +11,44 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
11
 
11
12
  var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
12
13
 
13
- // src/validation/schemas.ts
14
+ // src/validation/event-schemas.ts
15
+ var TransferDataSchema = zod.z.object({
16
+ fromSubAgent: zod.z.string().describe("ID of the sub-agent transferring control"),
17
+ targetSubAgent: zod.z.string().describe("ID of the sub-agent receiving control"),
18
+ reason: zod.z.string().optional().describe("Reason for the transfer"),
19
+ context: zod.z.any().optional().describe("Additional context data")
20
+ });
21
+ var DelegationSentDataSchema = zod.z.object({
22
+ delegationId: zod.z.string().describe("Unique identifier for this delegation"),
23
+ fromSubAgent: zod.z.string().describe("ID of the delegating sub-agent"),
24
+ targetSubAgent: zod.z.string().describe("ID of the sub-agent receiving the delegation"),
25
+ taskDescription: zod.z.string().describe("Description of the delegated task"),
26
+ context: zod.z.any().optional().describe("Additional context data")
27
+ });
28
+ var DelegationReturnedDataSchema = zod.z.object({
29
+ delegationId: zod.z.string().describe("Unique identifier matching the original delegation"),
30
+ fromSubAgent: zod.z.string().describe("ID of the sub-agent that completed the task"),
31
+ targetSubAgent: zod.z.string().describe("ID of the sub-agent receiving the result"),
32
+ result: zod.z.any().optional().describe("Result data from the delegated task")
33
+ });
34
+ var DataOperationDetailsSchema = zod.z.object({
35
+ timestamp: zod.z.number().describe("Unix timestamp in milliseconds"),
36
+ subAgentId: zod.z.string().describe("ID of the sub-agent that generated this data"),
37
+ data: zod.z.any().describe("The actual data payload")
38
+ });
39
+ var DataOperationEventSchema = zod.z.object({
40
+ type: zod.z.string().describe("Event type identifier"),
41
+ label: zod.z.string().describe("Human-readable label for the event"),
42
+ details: DataOperationDetailsSchema
43
+ });
44
+ var A2AMessageMetadataSchema = zod.z.object({
45
+ fromSubAgentId: zod.z.string().optional().describe("ID of the sending sub-agent"),
46
+ toSubAgentId: zod.z.string().optional().describe("ID of the receiving sub-agent"),
47
+ fromExternalAgentId: zod.z.string().optional().describe("ID of the sending external agent"),
48
+ toExternalAgentId: zod.z.string().optional().describe("ID of the receiving external agent"),
49
+ taskId: zod.z.string().optional().describe("Associated task ID"),
50
+ a2aTaskId: zod.z.string().optional().describe("A2A-specific task ID")
51
+ });
14
52
  var tenantScoped = {
15
53
  tenantId: sqliteCore.text("tenant_id").notNull(),
16
54
  id: sqliteCore.text("id").notNull()
@@ -23,9 +61,9 @@ var graphScoped = {
23
61
  ...projectScoped,
24
62
  graphId: sqliteCore.text("graph_id").notNull()
25
63
  };
26
- var agentScoped = {
64
+ var subAgentScoped = {
27
65
  ...graphScoped,
28
- agentId: sqliteCore.text("agent_id").notNull()
66
+ subAgentId: sqliteCore.text("sub_agent_id").notNull()
29
67
  };
30
68
  var uiProperties = {
31
69
  name: sqliteCore.text("name").notNull(),
@@ -56,7 +94,7 @@ var agentGraph = sqliteCore.sqliteTable(
56
94
  ...projectScoped,
57
95
  name: sqliteCore.text("name").notNull(),
58
96
  description: sqliteCore.text("description"),
59
- defaultAgentId: sqliteCore.text("default_agent_id"),
97
+ defaultSubAgentId: sqliteCore.text("default_sub_agent_id"),
60
98
  // Reference to shared context configuration for all agents in this graph
61
99
  contextConfigId: sqliteCore.text("context_config_id"),
62
100
  // add fk relationship
@@ -135,8 +173,8 @@ var contextCache = sqliteCore.sqliteTable(
135
173
  )
136
174
  ]
137
175
  );
138
- var agents = sqliteCore.sqliteTable(
139
- "agents",
176
+ var subAgents = sqliteCore.sqliteTable(
177
+ "sub_agents",
140
178
  {
141
179
  ...graphScoped,
142
180
  ...uiProperties,
@@ -158,17 +196,16 @@ var agents = sqliteCore.sqliteTable(
158
196
  }).onDelete("cascade")
159
197
  ]
160
198
  );
161
- var agentRelations = sqliteCore.sqliteTable(
162
- "agent_relations",
199
+ var subAgentRelations = sqliteCore.sqliteTable(
200
+ "sub_agent_relations",
163
201
  {
164
202
  ...graphScoped,
165
- sourceAgentId: sqliteCore.text("source_agent_id").notNull(),
203
+ sourceSubAgentId: sqliteCore.text("source_sub_agent_id").notNull(),
166
204
  // For internal relationships
167
- targetAgentId: sqliteCore.text("target_agent_id"),
205
+ targetSubAgentId: sqliteCore.text("target_sub_agent_id"),
168
206
  // For external relationships
169
- externalAgentId: sqliteCore.text("external_agent_id"),
207
+ externalSubAgentId: sqliteCore.text("external_sub_agent_id"),
170
208
  relationType: sqliteCore.text("relation_type"),
171
- // 'transfer' | 'delegate'
172
209
  ...timestamps
173
210
  },
174
211
  (table) => [
@@ -176,7 +213,7 @@ var agentRelations = sqliteCore.sqliteTable(
176
213
  sqliteCore.foreignKey({
177
214
  columns: [table.tenantId, table.projectId, table.graphId],
178
215
  foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
179
- name: "agent_relations_graph_fk"
216
+ name: "sub_agent_relations_graph_fk"
180
217
  }).onDelete("cascade")
181
218
  ]
182
219
  );
@@ -212,7 +249,7 @@ var externalAgents = sqliteCore.sqliteTable(
212
249
  var tasks = sqliteCore.sqliteTable(
213
250
  "tasks",
214
251
  {
215
- ...agentScoped,
252
+ ...subAgentScoped,
216
253
  contextId: sqliteCore.text("context_id").notNull(),
217
254
  status: sqliteCore.text("status").notNull(),
218
255
  metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
@@ -221,9 +258,9 @@ var tasks = sqliteCore.sqliteTable(
221
258
  (table) => [
222
259
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
223
260
  sqliteCore.foreignKey({
224
- columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
225
- foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
226
- name: "tasks_agent_fk"
261
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
262
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
263
+ name: "tasks_sub_agent_fk"
227
264
  }).onDelete("cascade")
228
265
  ]
229
266
  );
@@ -263,10 +300,10 @@ var dataComponents = sqliteCore.sqliteTable(
263
300
  }).onDelete("cascade")
264
301
  ]
265
302
  );
266
- var agentDataComponents = sqliteCore.sqliteTable(
267
- "agent_data_components",
303
+ var subAgentDataComponents = sqliteCore.sqliteTable(
304
+ "sub_agent_data_components",
268
305
  {
269
- ...agentScoped,
306
+ ...subAgentScoped,
270
307
  dataComponentId: sqliteCore.text("data_component_id").notNull(),
271
308
  createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
272
309
  },
@@ -274,15 +311,15 @@ var agentDataComponents = sqliteCore.sqliteTable(
274
311
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
275
312
  // Foreign key constraint to agents table (ensures graph and project exist via cascade)
276
313
  sqliteCore.foreignKey({
277
- columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
278
- foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
279
- name: "agent_data_components_agent_fk"
314
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
315
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
316
+ name: "sub_agent_data_components_sub_agent_fk"
280
317
  }).onDelete("cascade"),
281
318
  // Foreign key constraint to data_components table
282
319
  sqliteCore.foreignKey({
283
320
  columns: [table.tenantId, table.projectId, table.dataComponentId],
284
321
  foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
285
- name: "agent_data_components_data_component_fk"
322
+ name: "sub_agent_data_components_data_component_fk"
286
323
  }).onDelete("cascade")
287
324
  ]
288
325
  );
@@ -303,22 +340,22 @@ var artifactComponents = sqliteCore.sqliteTable(
303
340
  }).onDelete("cascade")
304
341
  ]
305
342
  );
306
- var agentArtifactComponents = sqliteCore.sqliteTable(
307
- "agent_artifact_components",
343
+ var subAgentArtifactComponents = sqliteCore.sqliteTable(
344
+ "sub_agent_artifact_components",
308
345
  {
309
- ...agentScoped,
346
+ ...subAgentScoped,
310
347
  artifactComponentId: sqliteCore.text("artifact_component_id").notNull(),
311
348
  createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
312
349
  },
313
350
  (table) => [
314
351
  sqliteCore.primaryKey({
315
- columns: [table.tenantId, table.projectId, table.graphId, table.agentId, table.id]
352
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId, table.id]
316
353
  }),
317
354
  // Foreign key constraint to agents table (ensures graph and project exist via cascade)
318
355
  sqliteCore.foreignKey({
319
- columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
320
- foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
321
- name: "agent_artifact_components_agent_fk"
356
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
357
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
358
+ name: "sub_agent_artifact_components_sub_agent_fk"
322
359
  }).onDelete("cascade"),
323
360
  // Foreign key constraint to artifact_components table
324
361
  sqliteCore.foreignKey({
@@ -328,7 +365,7 @@ var agentArtifactComponents = sqliteCore.sqliteTable(
328
365
  artifactComponents.projectId,
329
366
  artifactComponents.id
330
367
  ],
331
- name: "agent_artifact_components_artifact_component_fk"
368
+ name: "sub_agent_artifact_components_artifact_component_fk"
332
369
  }).onDelete("cascade")
333
370
  ]
334
371
  );
@@ -384,10 +421,10 @@ var functions = sqliteCore.sqliteTable(
384
421
  }).onDelete("cascade")
385
422
  ]
386
423
  );
387
- var agentToolRelations = sqliteCore.sqliteTable(
388
- "agent_tool_relations",
424
+ var subAgentToolRelations = sqliteCore.sqliteTable(
425
+ "sub_agent_tool_relations",
389
426
  {
390
- ...agentScoped,
427
+ ...subAgentScoped,
391
428
  toolId: sqliteCore.text("tool_id").notNull(),
392
429
  selectedTools: sqliteCore.blob("selected_tools", { mode: "json" }).$type(),
393
430
  headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
@@ -397,15 +434,15 @@ var agentToolRelations = sqliteCore.sqliteTable(
397
434
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
398
435
  // Foreign key constraint to agents table (which includes project and graph scope)
399
436
  sqliteCore.foreignKey({
400
- columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
401
- foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
402
- name: "agent_tool_relations_agent_fk"
437
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
438
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
439
+ name: "sub_agent_tool_relations_agent_fk"
403
440
  }).onDelete("cascade"),
404
441
  // Foreign key constraint to tools table
405
442
  sqliteCore.foreignKey({
406
443
  columns: [table.tenantId, table.projectId, table.toolId],
407
444
  foreignColumns: [tools.tenantId, tools.projectId, tools.id],
408
- name: "agent_tool_relations_tool_fk"
445
+ name: "sub_agent_tool_relations_tool_fk"
409
446
  }).onDelete("cascade")
410
447
  ]
411
448
  );
@@ -414,7 +451,7 @@ var conversations = sqliteCore.sqliteTable(
414
451
  {
415
452
  ...projectScoped,
416
453
  userId: sqliteCore.text("user_id"),
417
- activeAgentId: sqliteCore.text("active_agent_id").notNull(),
454
+ activeSubAgentId: sqliteCore.text("active_sub_agent_id").notNull(),
418
455
  title: sqliteCore.text("title"),
419
456
  lastContextResolution: sqliteCore.text("last_context_resolution"),
420
457
  metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
@@ -438,15 +475,15 @@ var messages = sqliteCore.sqliteTable(
438
475
  role: sqliteCore.text("role").notNull(),
439
476
  // 'user' | 'agent' | 'system'
440
477
  // Agent sender/recipient tracking (nullable - only populated when relevant)
441
- fromAgentId: sqliteCore.text("from_agent_id"),
478
+ fromSubAgentId: sqliteCore.text("from_sub_agent_id"),
442
479
  // Populated when message is from an agent
443
- toAgentId: sqliteCore.text("to_agent_id"),
480
+ toSubAgentId: sqliteCore.text("to_sub_agent_id"),
444
481
  // Populated when message is directed to a specific agent (e.g., transfers/delegations)
445
482
  // External agent sender tracking
446
- fromExternalAgentId: sqliteCore.text("from_external_agent_id"),
483
+ fromExternalAgentId: sqliteCore.text("from_external_sub_agent_id"),
447
484
  // Populated when message is directed from an external agent
448
485
  // External agent recipient tracking
449
- toExternalAgentId: sqliteCore.text("to_external_agent_id"),
486
+ toExternalAgentId: sqliteCore.text("to_external_sub_agent_id"),
450
487
  // Populated when message is directed to an external agent
451
488
  // Message content stored as JSON to support both formats
452
489
  content: sqliteCore.blob("content", { mode: "json" }).$type().notNull(),
@@ -455,8 +492,6 @@ var messages = sqliteCore.sqliteTable(
455
492
  // 'user-facing' | 'internal' | 'system' | 'external'
456
493
  messageType: sqliteCore.text("message_type").notNull().default("chat"),
457
494
  // 'chat' | 'a2a-request' | 'a2a-response' | 'task-update' | 'tool-call'
458
- // Legacy agent association (consider deprecating in favor of fromAgentId/toAgentId)
459
- agentId: sqliteCore.text("agent_id"),
460
495
  taskId: sqliteCore.text("task_id"),
461
496
  parentMessageId: sqliteCore.text("parent_message_id"),
462
497
  // Remove self-reference constraint here
@@ -583,10 +618,9 @@ drizzleOrm.relations(tasks, ({ one, many }) => ({
583
618
  childRelations: many(taskRelations, {
584
619
  relationName: "parentTask"
585
620
  }),
586
- // A task belongs to one agent
587
- agent: one(agents, {
588
- fields: [tasks.agentId],
589
- references: [agents.id]
621
+ subAgent: one(subAgents, {
622
+ fields: [tasks.subAgentId],
623
+ references: [subAgents.id]
590
624
  }),
591
625
  // A task can have many messages associated with it
592
626
  messages: many(messages),
@@ -594,7 +628,7 @@ drizzleOrm.relations(tasks, ({ one, many }) => ({
594
628
  ledgerArtifacts: many(ledgerArtifacts)
595
629
  }));
596
630
  drizzleOrm.relations(projects, ({ many }) => ({
597
- agents: many(agents),
631
+ subAgents: many(subAgents),
598
632
  agentGraphs: many(agentGraph),
599
633
  tools: many(tools),
600
634
  contextConfigs: many(contextConfigs),
@@ -632,17 +666,17 @@ drizzleOrm.relations(contextCache, ({ one }) => ({
632
666
  references: [contextConfigs.id]
633
667
  })
634
668
  }));
635
- drizzleOrm.relations(agents, ({ many, one }) => ({
669
+ drizzleOrm.relations(subAgents, ({ many, one }) => ({
636
670
  project: one(projects, {
637
- fields: [agents.tenantId, agents.projectId],
671
+ fields: [subAgents.tenantId, subAgents.projectId],
638
672
  references: [projects.tenantId, projects.id]
639
673
  }),
640
674
  tasks: many(tasks),
641
675
  defaultForGraphs: many(agentGraph),
642
- sourceRelations: many(agentRelations, {
676
+ sourceRelations: many(subAgentRelations, {
643
677
  relationName: "sourceRelations"
644
678
  }),
645
- targetRelations: many(agentRelations, {
679
+ targetRelations: many(subAgentRelations, {
646
680
  relationName: "targetRelations"
647
681
  }),
648
682
  sentMessages: many(messages, {
@@ -654,18 +688,18 @@ drizzleOrm.relations(agents, ({ many, one }) => ({
654
688
  associatedMessages: many(messages, {
655
689
  relationName: "associatedAgent"
656
690
  }),
657
- toolRelations: many(agentToolRelations),
658
- dataComponentRelations: many(agentDataComponents),
659
- artifactComponentRelations: many(agentArtifactComponents)
691
+ toolRelations: many(subAgentToolRelations),
692
+ dataComponentRelations: many(subAgentDataComponents),
693
+ artifactComponentRelations: many(subAgentArtifactComponents)
660
694
  }));
661
695
  drizzleOrm.relations(agentGraph, ({ one }) => ({
662
696
  project: one(projects, {
663
697
  fields: [agentGraph.tenantId, agentGraph.projectId],
664
698
  references: [projects.tenantId, projects.id]
665
699
  }),
666
- defaultAgent: one(agents, {
667
- fields: [agentGraph.defaultAgentId],
668
- references: [agents.id]
700
+ defaultSubAgent: one(subAgents, {
701
+ fields: [agentGraph.defaultSubAgentId],
702
+ references: [subAgents.id]
669
703
  }),
670
704
  contextConfig: one(contextConfigs, {
671
705
  fields: [agentGraph.contextConfigId],
@@ -677,7 +711,7 @@ drizzleOrm.relations(externalAgents, ({ one, many }) => ({
677
711
  fields: [externalAgents.tenantId, externalAgents.projectId],
678
712
  references: [projects.tenantId, projects.id]
679
713
  }),
680
- agentRelations: many(agentRelations),
714
+ subAgentRelations: many(subAgentRelations),
681
715
  credentialReference: one(credentialReferences, {
682
716
  fields: [externalAgents.credentialReferenceId],
683
717
  references: [credentialReferences.id]
@@ -693,13 +727,13 @@ drizzleOrm.relations(apiKeys, ({ one }) => ({
693
727
  references: [agentGraph.id]
694
728
  })
695
729
  }));
696
- drizzleOrm.relations(agentToolRelations, ({ one }) => ({
697
- agent: one(agents, {
698
- fields: [agentToolRelations.agentId],
699
- references: [agents.id]
730
+ drizzleOrm.relations(subAgentToolRelations, ({ one }) => ({
731
+ subAgent: one(subAgents, {
732
+ fields: [subAgentToolRelations.subAgentId],
733
+ references: [subAgents.id]
700
734
  }),
701
735
  tool: one(tools, {
702
- fields: [agentToolRelations.toolId],
736
+ fields: [subAgentToolRelations.toolId],
703
737
  references: [tools.id]
704
738
  })
705
739
  }));
@@ -711,7 +745,7 @@ drizzleOrm.relations(tools, ({ one, many }) => ({
711
745
  fields: [tools.tenantId, tools.projectId],
712
746
  references: [projects.tenantId, projects.id]
713
747
  }),
714
- agentRelations: many(agentToolRelations),
748
+ subAgentRelations: many(subAgentToolRelations),
715
749
  credentialReference: one(credentialReferences, {
716
750
  fields: [tools.credentialReferenceId],
717
751
  references: [credentialReferences.id]
@@ -727,9 +761,9 @@ drizzleOrm.relations(conversations, ({ one, many }) => ({
727
761
  references: [projects.tenantId, projects.id]
728
762
  }),
729
763
  messages: many(messages),
730
- activeAgent: one(agents, {
731
- fields: [conversations.activeAgentId],
732
- references: [agents.id]
764
+ activeSubAgent: one(subAgents, {
765
+ fields: [conversations.activeSubAgentId],
766
+ references: [subAgents.id]
733
767
  })
734
768
  }));
735
769
  drizzleOrm.relations(messages, ({ one, many }) => ({
@@ -737,20 +771,14 @@ drizzleOrm.relations(messages, ({ one, many }) => ({
737
771
  fields: [messages.conversationId],
738
772
  references: [conversations.id]
739
773
  }),
740
- // Legacy agent association (consider deprecating)
741
- agent: one(agents, {
742
- fields: [messages.agentId],
743
- references: [agents.id],
744
- relationName: "associatedAgent"
745
- }),
746
- fromAgent: one(agents, {
747
- fields: [messages.fromAgentId],
748
- references: [agents.id],
774
+ fromSubAgent: one(subAgents, {
775
+ fields: [messages.fromSubAgentId],
776
+ references: [subAgents.id],
749
777
  relationName: "sentMessages"
750
778
  }),
751
- toAgent: one(agents, {
752
- fields: [messages.toAgentId],
753
- references: [agents.id],
779
+ toSubAgent: one(subAgents, {
780
+ fields: [messages.toSubAgentId],
781
+ references: [subAgents.id],
754
782
  relationName: "receivedMessages"
755
783
  }),
756
784
  fromExternalAgent: one(externalAgents, {
@@ -776,33 +804,40 @@ drizzleOrm.relations(messages, ({ one, many }) => ({
776
804
  relationName: "parentChild"
777
805
  })
778
806
  }));
779
- drizzleOrm.relations(artifactComponents, ({ many }) => ({
780
- agentRelations: many(agentArtifactComponents)
781
- }));
782
- drizzleOrm.relations(agentArtifactComponents, ({ one }) => ({
783
- agent: one(agents, {
784
- fields: [agentArtifactComponents.agentId],
785
- references: [agents.id]
807
+ drizzleOrm.relations(artifactComponents, ({ many, one }) => ({
808
+ project: one(projects, {
809
+ fields: [artifactComponents.tenantId, artifactComponents.projectId],
810
+ references: [projects.tenantId, projects.id]
786
811
  }),
787
- artifactComponent: one(artifactComponents, {
788
- fields: [agentArtifactComponents.artifactComponentId],
789
- references: [artifactComponents.id]
790
- })
812
+ subAgentRelations: many(subAgentArtifactComponents)
791
813
  }));
814
+ drizzleOrm.relations(
815
+ subAgentArtifactComponents,
816
+ ({ one }) => ({
817
+ subAgent: one(subAgents, {
818
+ fields: [subAgentArtifactComponents.subAgentId],
819
+ references: [subAgents.id]
820
+ }),
821
+ artifactComponent: one(artifactComponents, {
822
+ fields: [subAgentArtifactComponents.artifactComponentId],
823
+ references: [artifactComponents.id]
824
+ })
825
+ })
826
+ );
792
827
  drizzleOrm.relations(dataComponents, ({ many, one }) => ({
793
828
  project: one(projects, {
794
829
  fields: [dataComponents.tenantId, dataComponents.projectId],
795
830
  references: [projects.tenantId, projects.id]
796
831
  }),
797
- agentRelations: many(agentDataComponents)
832
+ subAgentRelations: many(subAgentDataComponents)
798
833
  }));
799
- drizzleOrm.relations(agentDataComponents, ({ one }) => ({
800
- agent: one(agents, {
801
- fields: [agentDataComponents.agentId],
802
- references: [agents.id]
834
+ drizzleOrm.relations(subAgentDataComponents, ({ one }) => ({
835
+ subAgent: one(subAgents, {
836
+ fields: [subAgentDataComponents.subAgentId],
837
+ references: [subAgents.id]
803
838
  }),
804
839
  dataComponent: one(dataComponents, {
805
- fields: [agentDataComponents.dataComponentId],
840
+ fields: [subAgentDataComponents.dataComponentId],
806
841
  references: [dataComponents.id]
807
842
  })
808
843
  }));
@@ -819,23 +854,23 @@ drizzleOrm.relations(ledgerArtifacts, ({ one }) => ({
819
854
  drizzleOrm.relations(functions, ({ many }) => ({
820
855
  tools: many(tools)
821
856
  }));
822
- drizzleOrm.relations(agentRelations, ({ one }) => ({
857
+ drizzleOrm.relations(subAgentRelations, ({ one }) => ({
823
858
  graph: one(agentGraph, {
824
- fields: [agentRelations.graphId],
859
+ fields: [subAgentRelations.graphId],
825
860
  references: [agentGraph.id]
826
861
  }),
827
- sourceAgent: one(agents, {
828
- fields: [agentRelations.sourceAgentId],
829
- references: [agents.id],
862
+ sourceSubAgent: one(subAgents, {
863
+ fields: [subAgentRelations.sourceSubAgentId],
864
+ references: [subAgents.id],
830
865
  relationName: "sourceRelations"
831
866
  }),
832
- targetAgent: one(agents, {
833
- fields: [agentRelations.targetAgentId],
834
- references: [agents.id],
867
+ targetSubAgent: one(subAgents, {
868
+ fields: [subAgentRelations.targetSubAgentId],
869
+ references: [subAgents.id],
835
870
  relationName: "targetRelations"
836
871
  }),
837
872
  externalAgent: one(externalAgents, {
838
- fields: [agentRelations.externalAgentId],
873
+ fields: [subAgentRelations.externalSubAgentId],
839
874
  references: [externalAgents.id]
840
875
  })
841
876
  }));
@@ -906,22 +941,22 @@ var createApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId:
906
941
  var createGraphScopedApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true });
907
942
  var createGraphScopedApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true });
908
943
  var createGraphScopedApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true }).partial();
909
- var AgentSelectSchema = drizzleZod.createSelectSchema(agents);
910
- var AgentInsertSchema = drizzleZod.createInsertSchema(agents).extend({
944
+ var SubAgentSelectSchema = drizzleZod.createSelectSchema(subAgents);
945
+ var SubAgentInsertSchema = drizzleZod.createInsertSchema(subAgents).extend({
911
946
  id: resourceIdSchema,
912
947
  models: ModelSchema.optional()
913
948
  });
914
- var AgentUpdateSchema = AgentInsertSchema.partial();
915
- var AgentApiSelectSchema = createGraphScopedApiSchema(AgentSelectSchema);
916
- var AgentApiInsertSchema = createGraphScopedApiInsertSchema(AgentInsertSchema);
917
- var AgentApiUpdateSchema = createGraphScopedApiUpdateSchema(AgentUpdateSchema);
918
- var AgentRelationSelectSchema = drizzleZod.createSelectSchema(agentRelations);
919
- var AgentRelationInsertSchema = drizzleZod.createInsertSchema(agentRelations).extend({
949
+ var SubAgentUpdateSchema = SubAgentInsertSchema.partial();
950
+ var SubAgentApiSelectSchema = createGraphScopedApiSchema(SubAgentSelectSchema);
951
+ var SubAgentApiInsertSchema = createGraphScopedApiInsertSchema(SubAgentInsertSchema);
952
+ var SubAgentApiUpdateSchema = createGraphScopedApiUpdateSchema(SubAgentUpdateSchema);
953
+ var AgentRelationSelectSchema = drizzleZod.createSelectSchema(subAgentRelations);
954
+ var AgentRelationInsertSchema = drizzleZod.createInsertSchema(subAgentRelations).extend({
920
955
  id: resourceIdSchema,
921
956
  graphId: resourceIdSchema,
922
- sourceAgentId: resourceIdSchema,
923
- targetAgentId: resourceIdSchema.optional(),
924
- externalAgentId: resourceIdSchema.optional()
957
+ sourceSubAgentId: resourceIdSchema,
958
+ targetSubAgentId: resourceIdSchema.optional(),
959
+ externalSubAgentId: resourceIdSchema.optional()
925
960
  });
926
961
  var AgentRelationUpdateSchema = AgentRelationInsertSchema.partial();
927
962
  var AgentRelationApiSelectSchema = createGraphScopedApiSchema(AgentRelationSelectSchema);
@@ -931,13 +966,13 @@ var AgentRelationApiInsertSchema = createGraphScopedApiInsertSchema(
931
966
  relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES)
932
967
  }).refine(
933
968
  (data) => {
934
- const hasTarget = data.targetAgentId != null;
935
- const hasExternal = data.externalAgentId != null;
969
+ const hasTarget = data.targetSubAgentId != null;
970
+ const hasExternal = data.externalSubAgentId != null;
936
971
  return hasTarget !== hasExternal;
937
972
  },
938
973
  {
939
- message: "Must specify exactly one of targetAgentId or externalAgentId",
940
- path: ["targetAgentId", "externalAgentId"]
974
+ message: "Must specify exactly one of targetSubAgentId or externalSubAgentId",
975
+ path: ["targetSubAgentId", "externalSubAgentId"]
941
976
  }
942
977
  );
943
978
  var AgentRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
@@ -946,28 +981,28 @@ var AgentRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
946
981
  relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES).optional()
947
982
  }).refine(
948
983
  (data) => {
949
- const hasTarget = data.targetAgentId != null;
950
- const hasExternal = data.externalAgentId != null;
984
+ const hasTarget = data.targetSubAgentId != null;
985
+ const hasExternal = data.externalSubAgentId != null;
951
986
  if (!hasTarget && !hasExternal) {
952
987
  return true;
953
988
  }
954
989
  return hasTarget !== hasExternal;
955
990
  },
956
991
  {
957
- message: "Must specify exactly one of targetAgentId or externalAgentId when updating agent relationships",
958
- path: ["targetAgentId", "externalAgentId"]
992
+ message: "Must specify exactly one of targetSubAgentId or externalSubAgentId when updating agent relationships",
993
+ path: ["targetSubAgentId", "externalSubAgentId"]
959
994
  }
960
995
  );
961
996
  var AgentRelationQuerySchema = zodOpenapi.z.object({
962
- sourceAgentId: zodOpenapi.z.string().optional(),
963
- targetAgentId: zodOpenapi.z.string().optional(),
964
- externalAgentId: zodOpenapi.z.string().optional()
997
+ sourceSubAgentId: zodOpenapi.z.string().optional(),
998
+ targetSubAgentId: zodOpenapi.z.string().optional(),
999
+ externalSubAgentId: zodOpenapi.z.string().optional()
965
1000
  });
966
- var ExternalAgentRelationInsertSchema = drizzleZod.createInsertSchema(agentRelations).extend({
1001
+ var ExternalAgentRelationInsertSchema = drizzleZod.createInsertSchema(subAgentRelations).extend({
967
1002
  id: resourceIdSchema,
968
1003
  graphId: resourceIdSchema,
969
- sourceAgentId: resourceIdSchema,
970
- externalAgentId: resourceIdSchema
1004
+ sourceSubAgentId: resourceIdSchema,
1005
+ externalSubAgentId: resourceIdSchema
971
1006
  });
972
1007
  var ExternalAgentRelationApiInsertSchema = createApiInsertSchema(
973
1008
  ExternalAgentRelationInsertSchema
@@ -1101,8 +1136,8 @@ var DataComponentUpdateSchema = DataComponentInsertSchema.partial();
1101
1136
  var DataComponentApiSelectSchema = createApiSchema(DataComponentSelectSchema);
1102
1137
  var DataComponentApiInsertSchema = createApiInsertSchema(DataComponentInsertSchema);
1103
1138
  var DataComponentApiUpdateSchema = createApiUpdateSchema(DataComponentUpdateSchema);
1104
- var AgentDataComponentSelectSchema = drizzleZod.createSelectSchema(agentDataComponents);
1105
- var AgentDataComponentInsertSchema = drizzleZod.createInsertSchema(agentDataComponents);
1139
+ var AgentDataComponentSelectSchema = drizzleZod.createSelectSchema(subAgentDataComponents);
1140
+ var AgentDataComponentInsertSchema = drizzleZod.createInsertSchema(subAgentDataComponents);
1106
1141
  var AgentDataComponentUpdateSchema = AgentDataComponentInsertSchema.partial();
1107
1142
  var AgentDataComponentApiSelectSchema = createGraphScopedApiSchema(
1108
1143
  AgentDataComponentSelectSchema
@@ -1131,12 +1166,12 @@ var ArtifactComponentApiInsertSchema = ArtifactComponentInsertSchema.omit({
1131
1166
  var ArtifactComponentApiUpdateSchema = createApiUpdateSchema(
1132
1167
  ArtifactComponentUpdateSchema
1133
1168
  );
1134
- var AgentArtifactComponentSelectSchema = drizzleZod.createSelectSchema(agentArtifactComponents);
1169
+ var AgentArtifactComponentSelectSchema = drizzleZod.createSelectSchema(subAgentArtifactComponents);
1135
1170
  var AgentArtifactComponentInsertSchema = drizzleZod.createInsertSchema(
1136
- agentArtifactComponents
1171
+ subAgentArtifactComponents
1137
1172
  ).extend({
1138
1173
  id: resourceIdSchema,
1139
- agentId: resourceIdSchema,
1174
+ subAgentId: resourceIdSchema,
1140
1175
  artifactComponentId: resourceIdSchema
1141
1176
  });
1142
1177
  var AgentArtifactComponentUpdateSchema = AgentArtifactComponentInsertSchema.partial();
@@ -1164,7 +1199,7 @@ var ExternalAgentApiSelectSchema = createGraphScopedApiSchema(ExternalAgentSelec
1164
1199
  var ExternalAgentApiInsertSchema = createGraphScopedApiInsertSchema(ExternalAgentInsertSchema);
1165
1200
  var ExternalAgentApiUpdateSchema = createGraphScopedApiUpdateSchema(ExternalAgentUpdateSchema);
1166
1201
  var AllAgentSchema = zodOpenapi.z.discriminatedUnion("type", [
1167
- AgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("internal") }),
1202
+ SubAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("internal") }),
1168
1203
  ExternalAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("external") })
1169
1204
  ]);
1170
1205
  var ApiKeySelectSchema = drizzleZod.createSelectSchema(apiKeys);
@@ -1319,10 +1354,10 @@ var ContextConfigApiInsertSchema = createApiInsertSchema(ContextConfigInsertSche
1319
1354
  var ContextConfigApiUpdateSchema = createApiUpdateSchema(ContextConfigUpdateSchema).omit({
1320
1355
  graphId: true
1321
1356
  });
1322
- var AgentToolRelationSelectSchema = drizzleZod.createSelectSchema(agentToolRelations);
1323
- var AgentToolRelationInsertSchema = drizzleZod.createInsertSchema(agentToolRelations).extend({
1357
+ var AgentToolRelationSelectSchema = drizzleZod.createSelectSchema(subAgentToolRelations);
1358
+ var AgentToolRelationInsertSchema = drizzleZod.createInsertSchema(subAgentToolRelations).extend({
1324
1359
  id: resourceIdSchema,
1325
- agentId: resourceIdSchema,
1360
+ subAgentId: resourceIdSchema,
1326
1361
  toolId: resourceIdSchema,
1327
1362
  selectedTools: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
1328
1363
  headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
@@ -1365,7 +1400,7 @@ var CanUseItemSchema = zodOpenapi.z.object({
1365
1400
  toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
1366
1401
  headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
1367
1402
  });
1368
- var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
1403
+ var FullGraphAgentInsertSchema = SubAgentApiInsertSchema.extend({
1369
1404
  type: zodOpenapi.z.literal("internal"),
1370
1405
  canUse: zodOpenapi.z.array(CanUseItemSchema),
1371
1406
  // All tools (both MCP and function tools)
@@ -1374,27 +1409,17 @@ var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
1374
1409
  canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1375
1410
  canDelegateTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
1376
1411
  });
1377
- var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
1378
- agents: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
1379
- // Lookup maps for UI to resolve canUse items
1380
- tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
1381
- // Get tool name/description from toolId
1382
- functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
1383
- // Get function code for function tools
1384
- contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
1385
- statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
1386
- models: ModelSchema.optional(),
1387
- stopWhen: GraphStopWhenSchema.optional(),
1388
- graphPrompt: zodOpenapi.z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
1389
- });
1390
1412
  var GraphWithinContextOfProjectSchema = AgentGraphApiInsertSchema.extend({
1391
- agents: zodOpenapi.z.record(
1413
+ subAgents: zodOpenapi.z.record(
1392
1414
  zodOpenapi.z.string(),
1393
1415
  zodOpenapi.z.discriminatedUnion("type", [
1394
1416
  FullGraphAgentInsertSchema,
1395
1417
  ExternalAgentApiInsertSchema.extend({ type: zodOpenapi.z.literal("external") })
1396
1418
  ])
1397
1419
  ),
1420
+ tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
1421
+ // Get tool name/description from toolId
1422
+ functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
1398
1423
  contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
1399
1424
  statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
1400
1425
  models: ModelSchema.optional(),
@@ -1466,72 +1491,46 @@ var HeadersScopeSchema = zodOpenapi.z.object({
1466
1491
  example: "graph_789"
1467
1492
  })
1468
1493
  });
1494
+ var TenantId = zodOpenapi.z.string().openapi({
1495
+ description: "Tenant identifier",
1496
+ example: "tenant_123"
1497
+ });
1498
+ var ProjectId = zodOpenapi.z.string().openapi({
1499
+ description: "Project identifier",
1500
+ example: "project_456"
1501
+ });
1502
+ var GraphId = zodOpenapi.z.string().openapi({
1503
+ description: "Graph identifier",
1504
+ example: "graph_789"
1505
+ });
1506
+ var SubAgentId = zodOpenapi.z.string().openapi({
1507
+ description: "Sub-agent identifier",
1508
+ example: "sub_agent_123"
1509
+ });
1469
1510
  var TenantParamsSchema = zodOpenapi.z.object({
1470
- tenantId: zodOpenapi.z.string().openapi({
1471
- description: "Tenant identifier",
1472
- example: "tenant_123"
1473
- })
1511
+ tenantId: TenantId
1474
1512
  }).openapi("TenantParams");
1475
- var TenantProjectParamsSchema = zodOpenapi.z.object({
1476
- tenantId: zodOpenapi.z.string().openapi({
1477
- description: "Tenant identifier",
1478
- example: "tenant_123"
1479
- }),
1480
- projectId: zodOpenapi.z.string().openapi({
1481
- description: "Project identifier",
1482
- example: "project_456"
1483
- })
1484
- }).openapi("TenantProjectParams");
1485
- var TenantProjectGraphParamsSchema = zodOpenapi.z.object({
1486
- tenantId: zodOpenapi.z.string().openapi({
1487
- description: "Tenant identifier",
1488
- example: "tenant_123"
1489
- }),
1490
- projectId: zodOpenapi.z.string().openapi({
1491
- description: "Project identifier",
1492
- example: "project_456"
1493
- }),
1494
- graphId: zodOpenapi.z.string().openapi({
1495
- description: "Graph identifier",
1496
- example: "graph_789"
1497
- })
1498
- }).openapi("TenantProjectGraphParams");
1499
- var TenantProjectGraphIdParamsSchema = zodOpenapi.z.object({
1500
- tenantId: zodOpenapi.z.string().openapi({
1501
- description: "Tenant identifier",
1502
- example: "tenant_123"
1503
- }),
1504
- projectId: zodOpenapi.z.string().openapi({
1505
- description: "Project identifier",
1506
- example: "project_456"
1507
- }),
1508
- graphId: zodOpenapi.z.string().openapi({
1509
- description: "Graph identifier",
1510
- example: "graph_789"
1511
- }),
1513
+ var TenantIdParamsSchema = TenantParamsSchema.extend({
1512
1514
  id: resourceIdSchema
1513
- }).openapi("TenantProjectGraphIdParams");
1514
- var TenantProjectIdParamsSchema = zodOpenapi.z.object({
1515
- tenantId: zodOpenapi.z.string().openapi({
1516
- description: "Tenant identifier",
1517
- example: "tenant_123"
1518
- }),
1519
- projectId: zodOpenapi.z.string().openapi({
1520
- description: "Project identifier",
1521
- example: "project_456"
1522
- }),
1515
+ }).openapi("TenantIdParams");
1516
+ var TenantProjectParamsSchema = TenantParamsSchema.extend({
1517
+ projectId: ProjectId
1518
+ }).openapi("TenantProjectParams");
1519
+ var TenantProjectIdParamsSchema = TenantProjectParamsSchema.extend({
1523
1520
  id: resourceIdSchema
1524
1521
  }).openapi("TenantProjectIdParams");
1525
- var TenantIdParamsSchema = zodOpenapi.z.object({
1526
- tenantId: zodOpenapi.z.string().openapi({
1527
- description: "Tenant identifier",
1528
- example: "tenant_123"
1529
- }),
1522
+ var TenantProjectGraphParamsSchema = TenantProjectParamsSchema.extend({
1523
+ graphId: GraphId
1524
+ }).openapi("TenantProjectGraphParams");
1525
+ var TenantProjectGraphIdParamsSchema = TenantProjectGraphParamsSchema.extend({
1530
1526
  id: resourceIdSchema
1531
- }).openapi("TenantIdParams");
1532
- var IdParamsSchema = zodOpenapi.z.object({
1527
+ }).openapi("TenantProjectGraphIdParams");
1528
+ var TenantProjectGraphSubAgentParamsSchema = TenantProjectGraphParamsSchema.extend({
1529
+ subAgentId: SubAgentId
1530
+ }).openapi("TenantProjectGraphSubAgentParams");
1531
+ var TenantProjectGraphSubAgentIdParamsSchema = TenantProjectGraphSubAgentParamsSchema.extend({
1533
1532
  id: resourceIdSchema
1534
- }).openapi("IdParams");
1533
+ }).openapi("TenantProjectGraphSubAgentIdParams");
1535
1534
  var PaginationQueryParamsSchema = zodOpenapi.z.object({
1536
1535
  page: zodOpenapi.z.coerce.number().min(1).default(1),
1537
1536
  limit: zodOpenapi.z.coerce.number().min(1).max(100).default(10)
@@ -1545,18 +1544,18 @@ function isExternalAgent(agent) {
1545
1544
  return "baseUrl" in agent;
1546
1545
  }
1547
1546
  function validateAndTypeGraphData(data) {
1548
- return FullGraphDefinitionSchema.parse(data);
1547
+ return GraphWithinContextOfProjectSchema.parse(data);
1549
1548
  }
1550
1549
  function validateToolReferences(graphData, availableToolIds) {
1551
1550
  if (!availableToolIds) {
1552
1551
  return;
1553
1552
  }
1554
1553
  const errors = [];
1555
- for (const [agentId, agentData] of Object.entries(graphData.agents)) {
1554
+ for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
1556
1555
  if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
1557
1556
  for (const canUseItem of agentData.canUse) {
1558
1557
  if (!availableToolIds.has(canUseItem.toolId)) {
1559
- errors.push(`Agent '${agentId}' references non-existent tool '${canUseItem.toolId}'`);
1558
+ errors.push(`Agent '${subAgentId}' references non-existent tool '${canUseItem.toolId}'`);
1560
1559
  }
1561
1560
  }
1562
1561
  }
@@ -1571,12 +1570,12 @@ function validateDataComponentReferences(graphData, availableDataComponentIds) {
1571
1570
  return;
1572
1571
  }
1573
1572
  const errors = [];
1574
- for (const [agentId, agentData] of Object.entries(graphData.agents)) {
1573
+ for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
1575
1574
  if (isInternalAgent(agentData) && agentData.dataComponents) {
1576
1575
  for (const dataComponentId of agentData.dataComponents) {
1577
1576
  if (!availableDataComponentIds.has(dataComponentId)) {
1578
1577
  errors.push(
1579
- `Agent '${agentId}' references non-existent dataComponent '${dataComponentId}'`
1578
+ `Agent '${subAgentId}' references non-existent dataComponent '${dataComponentId}'`
1580
1579
  );
1581
1580
  }
1582
1581
  }
@@ -1592,12 +1591,12 @@ function validateArtifactComponentReferences(graphData, availableArtifactCompone
1592
1591
  return;
1593
1592
  }
1594
1593
  const errors = [];
1595
- for (const [agentId, agentData] of Object.entries(graphData.agents)) {
1594
+ for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
1596
1595
  if (isInternalAgent(agentData) && agentData.artifactComponents) {
1597
1596
  for (const artifactComponentId of agentData.artifactComponents) {
1598
1597
  if (!availableArtifactComponentIds.has(artifactComponentId)) {
1599
1598
  errors.push(
1600
- `Agent '${agentId}' references non-existent artifactComponent '${artifactComponentId}'`
1599
+ `Agent '${subAgentId}' references non-existent artifactComponent '${artifactComponentId}'`
1601
1600
  );
1602
1601
  }
1603
1602
  }
@@ -1610,14 +1609,14 @@ ${errors.join("\n")}`);
1610
1609
  }
1611
1610
  function validateAgentRelationships(graphData) {
1612
1611
  const errors = [];
1613
- const availableAgentIds = new Set(Object.keys(graphData.agents));
1614
- for (const [agentId, agentData] of Object.entries(graphData.agents)) {
1612
+ const availableAgentIds = new Set(Object.keys(graphData.subAgents));
1613
+ for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
1615
1614
  if (isInternalAgent(agentData)) {
1616
1615
  if (agentData.canTransferTo && Array.isArray(agentData.canTransferTo)) {
1617
1616
  for (const targetId of agentData.canTransferTo) {
1618
1617
  if (!availableAgentIds.has(targetId)) {
1619
1618
  errors.push(
1620
- `Agent '${agentId}' has transfer target '${targetId}' that doesn't exist in graph`
1619
+ `Agent '${subAgentId}' has transfer target '${targetId}' that doesn't exist in graph`
1621
1620
  );
1622
1621
  }
1623
1622
  }
@@ -1626,7 +1625,7 @@ function validateAgentRelationships(graphData) {
1626
1625
  for (const targetId of agentData.canDelegateTo) {
1627
1626
  if (!availableAgentIds.has(targetId)) {
1628
1627
  errors.push(
1629
- `Agent '${agentId}' has delegation target '${targetId}' that doesn't exist in graph`
1628
+ `Agent '${subAgentId}' has delegation target '${targetId}' that doesn't exist in graph`
1630
1629
  );
1631
1630
  }
1632
1631
  }
@@ -1639,8 +1638,8 @@ ${errors.join("\n")}`);
1639
1638
  }
1640
1639
  }
1641
1640
  function validateGraphStructure(graphData, projectResources) {
1642
- if (graphData.defaultAgentId && !graphData.agents[graphData.defaultAgentId]) {
1643
- throw new Error(`Default agent '${graphData.defaultAgentId}' does not exist in agents`);
1641
+ if (graphData.defaultSubAgentId && !graphData.subAgents[graphData.defaultSubAgentId]) {
1642
+ throw new Error(`Default agent '${graphData.defaultSubAgentId}' does not exist in agents`);
1644
1643
  }
1645
1644
  if (projectResources) {
1646
1645
  validateToolReferences(graphData, projectResources.toolIds);
@@ -1770,9 +1769,7 @@ function validatePropsAsJsonSchema(props) {
1770
1769
  }
1771
1770
  }
1772
1771
 
1773
- exports.AgentApiInsertSchema = AgentApiInsertSchema;
1774
- exports.AgentApiSelectSchema = AgentApiSelectSchema;
1775
- exports.AgentApiUpdateSchema = AgentApiUpdateSchema;
1772
+ exports.A2AMessageMetadataSchema = A2AMessageMetadataSchema;
1776
1773
  exports.AgentArtifactComponentApiInsertSchema = AgentArtifactComponentApiInsertSchema;
1777
1774
  exports.AgentArtifactComponentApiSelectSchema = AgentArtifactComponentApiSelectSchema;
1778
1775
  exports.AgentArtifactComponentApiUpdateSchema = AgentArtifactComponentApiUpdateSchema;
@@ -1791,7 +1788,6 @@ exports.AgentGraphApiUpdateSchema = AgentGraphApiUpdateSchema;
1791
1788
  exports.AgentGraphInsertSchema = AgentGraphInsertSchema;
1792
1789
  exports.AgentGraphSelectSchema = AgentGraphSelectSchema;
1793
1790
  exports.AgentGraphUpdateSchema = AgentGraphUpdateSchema;
1794
- exports.AgentInsertSchema = AgentInsertSchema;
1795
1791
  exports.AgentRelationApiInsertSchema = AgentRelationApiInsertSchema;
1796
1792
  exports.AgentRelationApiSelectSchema = AgentRelationApiSelectSchema;
1797
1793
  exports.AgentRelationApiUpdateSchema = AgentRelationApiUpdateSchema;
@@ -1799,7 +1795,6 @@ exports.AgentRelationInsertSchema = AgentRelationInsertSchema;
1799
1795
  exports.AgentRelationQuerySchema = AgentRelationQuerySchema;
1800
1796
  exports.AgentRelationSelectSchema = AgentRelationSelectSchema;
1801
1797
  exports.AgentRelationUpdateSchema = AgentRelationUpdateSchema;
1802
- exports.AgentSelectSchema = AgentSelectSchema;
1803
1798
  exports.AgentStopWhenSchema = AgentStopWhenSchema;
1804
1799
  exports.AgentToolRelationApiInsertSchema = AgentToolRelationApiInsertSchema;
1805
1800
  exports.AgentToolRelationApiSelectSchema = AgentToolRelationApiSelectSchema;
@@ -1807,7 +1802,6 @@ exports.AgentToolRelationApiUpdateSchema = AgentToolRelationApiUpdateSchema;
1807
1802
  exports.AgentToolRelationInsertSchema = AgentToolRelationInsertSchema;
1808
1803
  exports.AgentToolRelationSelectSchema = AgentToolRelationSelectSchema;
1809
1804
  exports.AgentToolRelationUpdateSchema = AgentToolRelationUpdateSchema;
1810
- exports.AgentUpdateSchema = AgentUpdateSchema;
1811
1805
  exports.AllAgentSchema = AllAgentSchema;
1812
1806
  exports.ApiKeyApiCreationResponseSchema = ApiKeyApiCreationResponseSchema;
1813
1807
  exports.ApiKeyApiInsertSchema = ApiKeyApiInsertSchema;
@@ -1854,6 +1848,10 @@ exports.DataComponentBaseSchema = DataComponentBaseSchema;
1854
1848
  exports.DataComponentInsertSchema = DataComponentInsertSchema;
1855
1849
  exports.DataComponentSelectSchema = DataComponentSelectSchema;
1856
1850
  exports.DataComponentUpdateSchema = DataComponentUpdateSchema;
1851
+ exports.DataOperationDetailsSchema = DataOperationDetailsSchema;
1852
+ exports.DataOperationEventSchema = DataOperationEventSchema;
1853
+ exports.DelegationReturnedDataSchema = DelegationReturnedDataSchema;
1854
+ exports.DelegationSentDataSchema = DelegationSentDataSchema;
1857
1855
  exports.ErrorResponseSchema = ErrorResponseSchema;
1858
1856
  exports.ExistsResponseSchema = ExistsResponseSchema;
1859
1857
  exports.ExternalAgentApiInsertSchema = ExternalAgentApiInsertSchema;
@@ -1867,7 +1865,6 @@ exports.ExternalAgentUpdateSchema = ExternalAgentUpdateSchema;
1867
1865
  exports.FetchConfigSchema = FetchConfigSchema;
1868
1866
  exports.FetchDefinitionSchema = FetchDefinitionSchema;
1869
1867
  exports.FullGraphAgentInsertSchema = FullGraphAgentInsertSchema;
1870
- exports.FullGraphDefinitionSchema = FullGraphDefinitionSchema;
1871
1868
  exports.FullProjectDefinitionSchema = FullProjectDefinitionSchema;
1872
1869
  exports.FunctionApiInsertSchema = FunctionApiInsertSchema;
1873
1870
  exports.FunctionApiSelectSchema = FunctionApiSelectSchema;
@@ -1879,7 +1876,6 @@ exports.FunctionUpdateSchema = FunctionUpdateSchema;
1879
1876
  exports.GraphStopWhenSchema = GraphStopWhenSchema;
1880
1877
  exports.GraphWithinContextOfProjectSchema = GraphWithinContextOfProjectSchema;
1881
1878
  exports.HeadersScopeSchema = HeadersScopeSchema;
1882
- exports.IdParamsSchema = IdParamsSchema;
1883
1879
  exports.LedgerArtifactApiInsertSchema = LedgerArtifactApiInsertSchema;
1884
1880
  exports.LedgerArtifactApiSelectSchema = LedgerArtifactApiSelectSchema;
1885
1881
  exports.LedgerArtifactApiUpdateSchema = LedgerArtifactApiUpdateSchema;
@@ -1916,6 +1912,12 @@ exports.SingleResponseSchema = SingleResponseSchema;
1916
1912
  exports.StatusComponentSchema = StatusComponentSchema;
1917
1913
  exports.StatusUpdateSchema = StatusUpdateSchema;
1918
1914
  exports.StopWhenSchema = StopWhenSchema;
1915
+ exports.SubAgentApiInsertSchema = SubAgentApiInsertSchema;
1916
+ exports.SubAgentApiSelectSchema = SubAgentApiSelectSchema;
1917
+ exports.SubAgentApiUpdateSchema = SubAgentApiUpdateSchema;
1918
+ exports.SubAgentInsertSchema = SubAgentInsertSchema;
1919
+ exports.SubAgentSelectSchema = SubAgentSelectSchema;
1920
+ exports.SubAgentUpdateSchema = SubAgentUpdateSchema;
1919
1921
  exports.TaskApiInsertSchema = TaskApiInsertSchema;
1920
1922
  exports.TaskApiSelectSchema = TaskApiSelectSchema;
1921
1923
  exports.TaskApiUpdateSchema = TaskApiUpdateSchema;
@@ -1932,6 +1934,8 @@ exports.TenantIdParamsSchema = TenantIdParamsSchema;
1932
1934
  exports.TenantParamsSchema = TenantParamsSchema;
1933
1935
  exports.TenantProjectGraphIdParamsSchema = TenantProjectGraphIdParamsSchema;
1934
1936
  exports.TenantProjectGraphParamsSchema = TenantProjectGraphParamsSchema;
1937
+ exports.TenantProjectGraphSubAgentIdParamsSchema = TenantProjectGraphSubAgentIdParamsSchema;
1938
+ exports.TenantProjectGraphSubAgentParamsSchema = TenantProjectGraphSubAgentParamsSchema;
1935
1939
  exports.TenantProjectIdParamsSchema = TenantProjectIdParamsSchema;
1936
1940
  exports.TenantProjectParamsSchema = TenantProjectParamsSchema;
1937
1941
  exports.ToolApiInsertSchema = ToolApiInsertSchema;
@@ -1941,6 +1945,7 @@ exports.ToolInsertSchema = ToolInsertSchema;
1941
1945
  exports.ToolSelectSchema = ToolSelectSchema;
1942
1946
  exports.ToolStatusSchema = ToolStatusSchema;
1943
1947
  exports.ToolUpdateSchema = ToolUpdateSchema;
1948
+ exports.TransferDataSchema = TransferDataSchema;
1944
1949
  exports.URL_SAFE_ID_PATTERN = URL_SAFE_ID_PATTERN;
1945
1950
  exports.generateIdFromName = generateIdFromName;
1946
1951
  exports.isExternalAgent = isExternalAgent;