@inkeep/agents-cli 0.16.3 → 0.18.0

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 (3) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +681 -438
  3. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -21,11 +21,11 @@ var __export = (target, all) => {
21
21
  for (var name in all)
22
22
  __defProp(target, name, { get: all[name], enumerable: true });
23
23
  };
24
- var __copyProps = (to, from, except, desc14) => {
24
+ var __copyProps = (to, from, except, desc15) => {
25
25
  if (from && typeof from === "object" || typeof from === "function") {
26
26
  for (let key of __getOwnPropNames(from))
27
27
  if (!__hasOwnProp.call(to, key) && key !== except)
28
- __defProp(to, key, { get: () => from[key], enumerable: !(desc14 = __getOwnPropDesc(from, key)) || desc14.enumerable });
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc15 = __getOwnPropDesc(from, key)) || desc15.enumerable });
29
29
  }
30
30
  return to;
31
31
  };
@@ -66,6 +66,78 @@ var init_base_client = __esm({
66
66
  }
67
67
  });
68
68
 
69
+ // ../packages/agents-core/src/constants/otel-attributes.ts
70
+ var init_otel_attributes = __esm({
71
+ "../packages/agents-core/src/constants/otel-attributes.ts"() {
72
+ "use strict";
73
+ init_esm_shims();
74
+ }
75
+ });
76
+
77
+ // ../packages/agents-core/src/constants/signoz-queries.ts
78
+ var DATA_TYPES, FIELD_TYPES, QUERY_FIELD_CONFIGS;
79
+ var init_signoz_queries = __esm({
80
+ "../packages/agents-core/src/constants/signoz-queries.ts"() {
81
+ "use strict";
82
+ init_esm_shims();
83
+ DATA_TYPES = {
84
+ STRING: "string",
85
+ INT64: "int64",
86
+ FLOAT64: "float64",
87
+ BOOL: "bool"
88
+ };
89
+ FIELD_TYPES = {
90
+ TAG: "tag",
91
+ RESOURCE: "resource"
92
+ };
93
+ QUERY_FIELD_CONFIGS = {
94
+ // String tag fields
95
+ STRING_TAG: {
96
+ dataType: DATA_TYPES.STRING,
97
+ type: FIELD_TYPES.TAG,
98
+ isColumn: false
99
+ },
100
+ STRING_TAG_COLUMN: {
101
+ dataType: DATA_TYPES.STRING,
102
+ type: FIELD_TYPES.TAG,
103
+ isColumn: true
104
+ },
105
+ // Numeric tag fields
106
+ INT64_TAG: {
107
+ dataType: DATA_TYPES.INT64,
108
+ type: FIELD_TYPES.TAG,
109
+ isColumn: false
110
+ },
111
+ INT64_TAG_COLUMN: {
112
+ dataType: DATA_TYPES.INT64,
113
+ type: FIELD_TYPES.TAG,
114
+ isColumn: true
115
+ },
116
+ FLOAT64_TAG: {
117
+ dataType: DATA_TYPES.FLOAT64,
118
+ type: FIELD_TYPES.TAG,
119
+ isColumn: false
120
+ },
121
+ FLOAT64_TAG_COLUMN: {
122
+ dataType: DATA_TYPES.FLOAT64,
123
+ type: FIELD_TYPES.TAG,
124
+ isColumn: true
125
+ },
126
+ // Boolean tag fields
127
+ BOOL_TAG: {
128
+ dataType: DATA_TYPES.BOOL,
129
+ type: FIELD_TYPES.TAG,
130
+ isColumn: false
131
+ },
132
+ BOOL_TAG_COLUMN: {
133
+ dataType: DATA_TYPES.BOOL,
134
+ type: FIELD_TYPES.TAG,
135
+ isColumn: true
136
+ }
137
+ };
138
+ }
139
+ });
140
+
69
141
  // ../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.js
70
142
  import { webcrypto as crypto2 } from "crypto";
71
143
  function fillPool(bytes) {
@@ -258,22 +330,22 @@ var init_logger = __esm({
258
330
  */
259
331
  getLogger(name) {
260
332
  if (this.loggers.has(name)) {
261
- const logger15 = this.loggers.get(name);
262
- if (!logger15) {
333
+ const logger16 = this.loggers.get(name);
334
+ if (!logger16) {
263
335
  throw new Error(`Logger '${name}' not found in cache`);
264
336
  }
265
- return logger15;
337
+ return logger16;
266
338
  }
267
- let logger14;
339
+ let logger15;
268
340
  if (this.config.loggerFactory) {
269
- logger14 = this.config.loggerFactory(name);
341
+ logger15 = this.config.loggerFactory(name);
270
342
  } else if (this.config.defaultLogger) {
271
- logger14 = this.config.defaultLogger;
343
+ logger15 = this.config.defaultLogger;
272
344
  } else {
273
- logger14 = new PinoLogger(name, this.config.pinoConfig);
345
+ logger15 = new PinoLogger(name, this.config.pinoConfig);
274
346
  }
275
- this.loggers.set(name, logger14);
276
- return logger14;
347
+ this.loggers.set(name, logger15);
348
+ return logger15;
277
349
  }
278
350
  /**
279
351
  * Reset factory to default state
@@ -1242,7 +1314,7 @@ function columnToSchema(column, factory) {
1242
1314
  }
1243
1315
  return schema;
1244
1316
  }
1245
- function numberColumnToSchema(column, z12, coerce) {
1317
+ function numberColumnToSchema(column, z13, coerce) {
1246
1318
  let unsigned = column.getSQLType().includes("unsigned");
1247
1319
  let min;
1248
1320
  let max;
@@ -1310,20 +1382,20 @@ function numberColumnToSchema(column, z12, coerce) {
1310
1382
  min = Number.MIN_SAFE_INTEGER;
1311
1383
  max = Number.MAX_SAFE_INTEGER;
1312
1384
  }
1313
- let schema = coerce === true || coerce?.number ? integer2 ? z12.coerce.number() : z12.coerce.number().int() : integer2 ? z12.int() : z12.number();
1385
+ let schema = coerce === true || coerce?.number ? integer2 ? z13.coerce.number() : z13.coerce.number().int() : integer2 ? z13.int() : z13.number();
1314
1386
  schema = schema.gte(min).lte(max);
1315
1387
  return schema;
1316
1388
  }
1317
- function bigintColumnToSchema(column, z12, coerce) {
1389
+ function bigintColumnToSchema(column, z13, coerce) {
1318
1390
  const unsigned = column.getSQLType().includes("unsigned");
1319
1391
  const min = unsigned ? 0n : CONSTANTS.INT64_MIN;
1320
1392
  const max = unsigned ? CONSTANTS.INT64_UNSIGNED_MAX : CONSTANTS.INT64_MAX;
1321
- const schema = coerce === true || coerce?.bigint ? z12.coerce.bigint() : z12.bigint();
1393
+ const schema = coerce === true || coerce?.bigint ? z13.coerce.bigint() : z13.bigint();
1322
1394
  return schema.gte(min).lte(max);
1323
1395
  }
1324
- function stringColumnToSchema(column, z12, coerce) {
1396
+ function stringColumnToSchema(column, z13, coerce) {
1325
1397
  if (isColumnType(column, ["PgUUID"])) {
1326
- return z12.uuid();
1398
+ return z13.uuid();
1327
1399
  }
1328
1400
  let max;
1329
1401
  let regex;
@@ -1355,7 +1427,7 @@ function stringColumnToSchema(column, z12, coerce) {
1355
1427
  regex = /^[01]+$/;
1356
1428
  max = column.dimensions;
1357
1429
  }
1358
- let schema = coerce === true || coerce?.string ? z12.coerce.string() : z12.string();
1430
+ let schema = coerce === true || coerce?.string ? z13.coerce.string() : z13.string();
1359
1431
  schema = regex ? schema.regex(regex) : schema;
1360
1432
  return max && fixed ? schema.length(max) : max ? schema.max(max) : schema;
1361
1433
  }
@@ -1467,7 +1539,7 @@ import {
1467
1539
  text,
1468
1540
  unique
1469
1541
  } from "drizzle-orm/sqlite-core";
1470
- var tenantScoped, projectScoped, graphScoped, agentScoped, uiProperties, timestamps, projects, agentGraph, contextConfigs, contextCache, agents, agentRelations, externalAgents, tasks, taskRelations, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, tools, functions, agentToolRelations, conversations, messages, ledgerArtifacts, apiKeys, credentialReferences, tasksRelations, projectsRelations, taskRelationsRelations, contextConfigsRelations, contextCacheRelations, agentsRelations, agentGraphRelations, externalAgentsRelations, apiKeysRelations, agentToolRelationsRelations, credentialReferencesRelations, toolsRelations, conversationsRelations, messagesRelations, artifactComponentsRelations, agentArtifactComponentsRelations, dataComponentsRelations, agentDataComponentsRelations, ledgerArtifactsRelations, functionsRelations, agentRelationsRelations;
1542
+ var tenantScoped, projectScoped, graphScoped, subAgentScoped, uiProperties, timestamps, projects, agentGraph, contextConfigs, contextCache, subAgents, subAgentRelations, externalAgents, tasks, taskRelations, dataComponents, subAgentDataComponents, artifactComponents, subAgentArtifactComponents, tools, functionTools, functions, subAgentToolRelations, agentFunctionToolRelations, conversations, messages, ledgerArtifacts, apiKeys, credentialReferences, tasksRelations, projectsRelations, taskRelationsRelations, contextConfigsRelations, contextCacheRelations, subAgentsRelations, agentGraphRelations, externalAgentsRelations, apiKeysRelations, agentToolRelationsRelations, credentialReferencesRelations, toolsRelations, conversationsRelations, messagesRelations, artifactComponentsRelations, subAgentArtifactComponentsRelations, dataComponentsRelations, subAgentDataComponentsRelations, ledgerArtifactsRelations, functionsRelations, subAgentRelationsRelations, functionToolsRelations, agentFunctionToolRelationsRelations;
1471
1543
  var init_schema = __esm({
1472
1544
  "../packages/agents-core/src/db/schema.ts"() {
1473
1545
  "use strict";
@@ -1484,9 +1556,9 @@ var init_schema = __esm({
1484
1556
  ...projectScoped,
1485
1557
  graphId: text("graph_id").notNull()
1486
1558
  };
1487
- agentScoped = {
1559
+ subAgentScoped = {
1488
1560
  ...graphScoped,
1489
- agentId: text("agent_id").notNull()
1561
+ subAgentId: text("sub_agent_id").notNull()
1490
1562
  };
1491
1563
  uiProperties = {
1492
1564
  name: text("name").notNull(),
@@ -1517,7 +1589,7 @@ var init_schema = __esm({
1517
1589
  ...projectScoped,
1518
1590
  name: text("name").notNull(),
1519
1591
  description: text("description"),
1520
- defaultAgentId: text("default_agent_id"),
1592
+ defaultSubAgentId: text("default_sub_agent_id"),
1521
1593
  // Reference to shared context configuration for all agents in this graph
1522
1594
  contextConfigId: text("context_config_id"),
1523
1595
  // add fk relationship
@@ -1596,8 +1668,8 @@ var init_schema = __esm({
1596
1668
  )
1597
1669
  ]
1598
1670
  );
1599
- agents = sqliteTable(
1600
- "agents",
1671
+ subAgents = sqliteTable(
1672
+ "sub_agents",
1601
1673
  {
1602
1674
  ...graphScoped,
1603
1675
  ...uiProperties,
@@ -1619,17 +1691,16 @@ var init_schema = __esm({
1619
1691
  }).onDelete("cascade")
1620
1692
  ]
1621
1693
  );
1622
- agentRelations = sqliteTable(
1623
- "agent_relations",
1694
+ subAgentRelations = sqliteTable(
1695
+ "sub_agent_relations",
1624
1696
  {
1625
1697
  ...graphScoped,
1626
- sourceAgentId: text("source_agent_id").notNull(),
1698
+ sourceSubAgentId: text("source_sub_agent_id").notNull(),
1627
1699
  // For internal relationships
1628
- targetAgentId: text("target_agent_id"),
1700
+ targetSubAgentId: text("target_sub_agent_id"),
1629
1701
  // For external relationships
1630
- externalAgentId: text("external_agent_id"),
1702
+ externalSubAgentId: text("external_sub_agent_id"),
1631
1703
  relationType: text("relation_type"),
1632
- // 'transfer' | 'delegate'
1633
1704
  ...timestamps
1634
1705
  },
1635
1706
  (table) => [
@@ -1637,7 +1708,7 @@ var init_schema = __esm({
1637
1708
  foreignKey({
1638
1709
  columns: [table.tenantId, table.projectId, table.graphId],
1639
1710
  foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
1640
- name: "agent_relations_graph_fk"
1711
+ name: "sub_agent_relations_graph_fk"
1641
1712
  }).onDelete("cascade")
1642
1713
  ]
1643
1714
  );
@@ -1673,7 +1744,7 @@ var init_schema = __esm({
1673
1744
  tasks = sqliteTable(
1674
1745
  "tasks",
1675
1746
  {
1676
- ...agentScoped,
1747
+ ...subAgentScoped,
1677
1748
  contextId: text("context_id").notNull(),
1678
1749
  status: text("status").notNull(),
1679
1750
  metadata: blob("metadata", { mode: "json" }).$type(),
@@ -1682,9 +1753,9 @@ var init_schema = __esm({
1682
1753
  (table) => [
1683
1754
  primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
1684
1755
  foreignKey({
1685
- columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
1686
- foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
1687
- name: "tasks_agent_fk"
1756
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
1757
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
1758
+ name: "tasks_sub_agent_fk"
1688
1759
  }).onDelete("cascade")
1689
1760
  ]
1690
1761
  );
@@ -1724,10 +1795,10 @@ var init_schema = __esm({
1724
1795
  }).onDelete("cascade")
1725
1796
  ]
1726
1797
  );
1727
- agentDataComponents = sqliteTable(
1728
- "agent_data_components",
1798
+ subAgentDataComponents = sqliteTable(
1799
+ "sub_agent_data_components",
1729
1800
  {
1730
- ...agentScoped,
1801
+ ...subAgentScoped,
1731
1802
  dataComponentId: text("data_component_id").notNull(),
1732
1803
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`)
1733
1804
  },
@@ -1735,15 +1806,15 @@ var init_schema = __esm({
1735
1806
  primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
1736
1807
  // Foreign key constraint to agents table (ensures graph and project exist via cascade)
1737
1808
  foreignKey({
1738
- columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
1739
- foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
1740
- name: "agent_data_components_agent_fk"
1809
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
1810
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
1811
+ name: "sub_agent_data_components_sub_agent_fk"
1741
1812
  }).onDelete("cascade"),
1742
1813
  // Foreign key constraint to data_components table
1743
1814
  foreignKey({
1744
1815
  columns: [table.tenantId, table.projectId, table.dataComponentId],
1745
1816
  foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
1746
- name: "agent_data_components_data_component_fk"
1817
+ name: "sub_agent_data_components_data_component_fk"
1747
1818
  }).onDelete("cascade")
1748
1819
  ]
1749
1820
  );
@@ -1764,22 +1835,22 @@ var init_schema = __esm({
1764
1835
  }).onDelete("cascade")
1765
1836
  ]
1766
1837
  );
1767
- agentArtifactComponents = sqliteTable(
1768
- "agent_artifact_components",
1838
+ subAgentArtifactComponents = sqliteTable(
1839
+ "sub_agent_artifact_components",
1769
1840
  {
1770
- ...agentScoped,
1841
+ ...subAgentScoped,
1771
1842
  artifactComponentId: text("artifact_component_id").notNull(),
1772
1843
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`)
1773
1844
  },
1774
1845
  (table) => [
1775
1846
  primaryKey({
1776
- columns: [table.tenantId, table.projectId, table.graphId, table.agentId, table.id]
1847
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId, table.id]
1777
1848
  }),
1778
1849
  // Foreign key constraint to agents table (ensures graph and project exist via cascade)
1779
1850
  foreignKey({
1780
- columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
1781
- foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
1782
- name: "agent_artifact_components_agent_fk"
1851
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
1852
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
1853
+ name: "sub_agent_artifact_components_sub_agent_fk"
1783
1854
  }).onDelete("cascade"),
1784
1855
  // Foreign key constraint to artifact_components table
1785
1856
  foreignKey({
@@ -1789,7 +1860,7 @@ var init_schema = __esm({
1789
1860
  artifactComponents.projectId,
1790
1861
  artifactComponents.id
1791
1862
  ],
1792
- name: "agent_artifact_components_artifact_component_fk"
1863
+ name: "sub_agent_artifact_components_artifact_component_fk"
1793
1864
  }).onDelete("cascade")
1794
1865
  ]
1795
1866
  );
@@ -1799,10 +1870,7 @@ var init_schema = __esm({
1799
1870
  ...projectScoped,
1800
1871
  name: text("name").notNull(),
1801
1872
  description: text("description"),
1802
- // Tool configuration - supports both MCP and function tools
1803
1873
  config: blob("config", { mode: "json" }).$type().notNull(),
1804
- // For function tools, reference the global functions table
1805
- functionId: text("function_id"),
1806
1874
  credentialReferenceId: text("credential_reference_id"),
1807
1875
  headers: blob("headers", { mode: "json" }).$type(),
1808
1876
  // Image URL for custom tool icon (supports regular URLs and base64 encoded images)
@@ -1818,12 +1886,30 @@ var init_schema = __esm({
1818
1886
  columns: [table.tenantId, table.projectId],
1819
1887
  foreignColumns: [projects.tenantId, projects.id],
1820
1888
  name: "tools_project_fk"
1889
+ }).onDelete("cascade")
1890
+ ]
1891
+ );
1892
+ functionTools = sqliteTable(
1893
+ "function_tools",
1894
+ {
1895
+ ...graphScoped,
1896
+ name: text("name").notNull(),
1897
+ description: text("description"),
1898
+ functionId: text("function_id").notNull(),
1899
+ ...timestamps
1900
+ },
1901
+ (table) => [
1902
+ primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
1903
+ foreignKey({
1904
+ columns: [table.tenantId, table.projectId, table.graphId],
1905
+ foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
1906
+ name: "function_tools_graph_fk"
1821
1907
  }).onDelete("cascade"),
1822
- // Foreign key constraint to functions table (for function tools)
1908
+ // Foreign key constraint to functions table
1823
1909
  foreignKey({
1824
1910
  columns: [table.tenantId, table.projectId, table.functionId],
1825
1911
  foreignColumns: [functions.tenantId, functions.projectId, functions.id],
1826
- name: "tools_function_fk"
1912
+ name: "function_tools_function_fk"
1827
1913
  }).onDelete("cascade")
1828
1914
  ]
1829
1915
  );
@@ -1845,10 +1931,10 @@ var init_schema = __esm({
1845
1931
  }).onDelete("cascade")
1846
1932
  ]
1847
1933
  );
1848
- agentToolRelations = sqliteTable(
1849
- "agent_tool_relations",
1934
+ subAgentToolRelations = sqliteTable(
1935
+ "sub_agent_tool_relations",
1850
1936
  {
1851
- ...agentScoped,
1937
+ ...subAgentScoped,
1852
1938
  toolId: text("tool_id").notNull(),
1853
1939
  selectedTools: blob("selected_tools", { mode: "json" }).$type(),
1854
1940
  headers: blob("headers", { mode: "json" }).$type(),
@@ -1858,15 +1944,43 @@ var init_schema = __esm({
1858
1944
  primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
1859
1945
  // Foreign key constraint to agents table (which includes project and graph scope)
1860
1946
  foreignKey({
1861
- columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
1862
- foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
1863
- name: "agent_tool_relations_agent_fk"
1947
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
1948
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
1949
+ name: "sub_agent_tool_relations_agent_fk"
1864
1950
  }).onDelete("cascade"),
1865
- // Foreign key constraint to tools table
1951
+ // Foreign key constraint to tools table (MCP tools)
1866
1952
  foreignKey({
1867
1953
  columns: [table.tenantId, table.projectId, table.toolId],
1868
1954
  foreignColumns: [tools.tenantId, tools.projectId, tools.id],
1869
- name: "agent_tool_relations_tool_fk"
1955
+ name: "sub_agent_tool_relations_tool_fk"
1956
+ }).onDelete("cascade")
1957
+ ]
1958
+ );
1959
+ agentFunctionToolRelations = sqliteTable(
1960
+ "agent_function_tool_relations",
1961
+ {
1962
+ ...subAgentScoped,
1963
+ functionToolId: text("function_tool_id").notNull(),
1964
+ ...timestamps
1965
+ },
1966
+ (table) => [
1967
+ primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
1968
+ // Foreign key constraint to agents table
1969
+ foreignKey({
1970
+ columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
1971
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
1972
+ name: "agent_function_tool_relations_agent_fk"
1973
+ }).onDelete("cascade"),
1974
+ // Foreign key constraint to functionTools table
1975
+ foreignKey({
1976
+ columns: [table.tenantId, table.projectId, table.graphId, table.functionToolId],
1977
+ foreignColumns: [
1978
+ functionTools.tenantId,
1979
+ functionTools.projectId,
1980
+ functionTools.graphId,
1981
+ functionTools.id
1982
+ ],
1983
+ name: "agent_function_tool_relations_function_tool_fk"
1870
1984
  }).onDelete("cascade")
1871
1985
  ]
1872
1986
  );
@@ -1875,7 +1989,7 @@ var init_schema = __esm({
1875
1989
  {
1876
1990
  ...projectScoped,
1877
1991
  userId: text("user_id"),
1878
- activeAgentId: text("active_agent_id").notNull(),
1992
+ activeSubAgentId: text("active_sub_agent_id").notNull(),
1879
1993
  title: text("title"),
1880
1994
  lastContextResolution: text("last_context_resolution"),
1881
1995
  metadata: blob("metadata", { mode: "json" }).$type(),
@@ -1899,15 +2013,15 @@ var init_schema = __esm({
1899
2013
  role: text("role").notNull(),
1900
2014
  // 'user' | 'agent' | 'system'
1901
2015
  // Agent sender/recipient tracking (nullable - only populated when relevant)
1902
- fromAgentId: text("from_agent_id"),
2016
+ fromSubAgentId: text("from_sub_agent_id"),
1903
2017
  // Populated when message is from an agent
1904
- toAgentId: text("to_agent_id"),
2018
+ toSubAgentId: text("to_sub_agent_id"),
1905
2019
  // Populated when message is directed to a specific agent (e.g., transfers/delegations)
1906
2020
  // External agent sender tracking
1907
- fromExternalAgentId: text("from_external_agent_id"),
2021
+ fromExternalAgentId: text("from_external_sub_agent_id"),
1908
2022
  // Populated when message is directed from an external agent
1909
2023
  // External agent recipient tracking
1910
- toExternalAgentId: text("to_external_agent_id"),
2024
+ toExternalAgentId: text("to_external_sub_agent_id"),
1911
2025
  // Populated when message is directed to an external agent
1912
2026
  // Message content stored as JSON to support both formats
1913
2027
  content: blob("content", { mode: "json" }).$type().notNull(),
@@ -1916,8 +2030,6 @@ var init_schema = __esm({
1916
2030
  // 'user-facing' | 'internal' | 'system' | 'external'
1917
2031
  messageType: text("message_type").notNull().default("chat"),
1918
2032
  // 'chat' | 'a2a-request' | 'a2a-response' | 'task-update' | 'tool-call'
1919
- // Legacy agent association (consider deprecating in favor of fromAgentId/toAgentId)
1920
- agentId: text("agent_id"),
1921
2033
  taskId: text("task_id"),
1922
2034
  parentMessageId: text("parent_message_id"),
1923
2035
  // Remove self-reference constraint here
@@ -2044,10 +2156,9 @@ var init_schema = __esm({
2044
2156
  childRelations: many(taskRelations, {
2045
2157
  relationName: "parentTask"
2046
2158
  }),
2047
- // A task belongs to one agent
2048
- agent: one(agents, {
2049
- fields: [tasks.agentId],
2050
- references: [agents.id]
2159
+ subAgent: one(subAgents, {
2160
+ fields: [tasks.subAgentId],
2161
+ references: [subAgents.id]
2051
2162
  }),
2052
2163
  // A task can have many messages associated with it
2053
2164
  messages: many(messages),
@@ -2055,9 +2166,10 @@ var init_schema = __esm({
2055
2166
  ledgerArtifacts: many(ledgerArtifacts)
2056
2167
  }));
2057
2168
  projectsRelations = relations(projects, ({ many }) => ({
2058
- agents: many(agents),
2169
+ subAgents: many(subAgents),
2059
2170
  agentGraphs: many(agentGraph),
2060
2171
  tools: many(tools),
2172
+ functions: many(functions),
2061
2173
  contextConfigs: many(contextConfigs),
2062
2174
  externalAgents: many(externalAgents),
2063
2175
  conversations: many(conversations),
@@ -2093,17 +2205,17 @@ var init_schema = __esm({
2093
2205
  references: [contextConfigs.id]
2094
2206
  })
2095
2207
  }));
2096
- agentsRelations = relations(agents, ({ many, one }) => ({
2208
+ subAgentsRelations = relations(subAgents, ({ many, one }) => ({
2097
2209
  project: one(projects, {
2098
- fields: [agents.tenantId, agents.projectId],
2210
+ fields: [subAgents.tenantId, subAgents.projectId],
2099
2211
  references: [projects.tenantId, projects.id]
2100
2212
  }),
2101
2213
  tasks: many(tasks),
2102
2214
  defaultForGraphs: many(agentGraph),
2103
- sourceRelations: many(agentRelations, {
2215
+ sourceRelations: many(subAgentRelations, {
2104
2216
  relationName: "sourceRelations"
2105
2217
  }),
2106
- targetRelations: many(agentRelations, {
2218
+ targetRelations: many(subAgentRelations, {
2107
2219
  relationName: "targetRelations"
2108
2220
  }),
2109
2221
  sentMessages: many(messages, {
@@ -2115,30 +2227,32 @@ var init_schema = __esm({
2115
2227
  associatedMessages: many(messages, {
2116
2228
  relationName: "associatedAgent"
2117
2229
  }),
2118
- toolRelations: many(agentToolRelations),
2119
- dataComponentRelations: many(agentDataComponents),
2120
- artifactComponentRelations: many(agentArtifactComponents)
2230
+ toolRelations: many(subAgentToolRelations),
2231
+ functionToolRelations: many(agentFunctionToolRelations),
2232
+ dataComponentRelations: many(subAgentDataComponents),
2233
+ artifactComponentRelations: many(subAgentArtifactComponents)
2121
2234
  }));
2122
- agentGraphRelations = relations(agentGraph, ({ one }) => ({
2235
+ agentGraphRelations = relations(agentGraph, ({ one, many }) => ({
2123
2236
  project: one(projects, {
2124
2237
  fields: [agentGraph.tenantId, agentGraph.projectId],
2125
2238
  references: [projects.tenantId, projects.id]
2126
2239
  }),
2127
- defaultAgent: one(agents, {
2128
- fields: [agentGraph.defaultAgentId],
2129
- references: [agents.id]
2240
+ defaultSubAgent: one(subAgents, {
2241
+ fields: [agentGraph.defaultSubAgentId],
2242
+ references: [subAgents.id]
2130
2243
  }),
2131
2244
  contextConfig: one(contextConfigs, {
2132
2245
  fields: [agentGraph.contextConfigId],
2133
2246
  references: [contextConfigs.id]
2134
- })
2247
+ }),
2248
+ functionTools: many(functionTools)
2135
2249
  }));
2136
2250
  externalAgentsRelations = relations(externalAgents, ({ one, many }) => ({
2137
2251
  project: one(projects, {
2138
2252
  fields: [externalAgents.tenantId, externalAgents.projectId],
2139
2253
  references: [projects.tenantId, projects.id]
2140
2254
  }),
2141
- agentRelations: many(agentRelations),
2255
+ subAgentRelations: many(subAgentRelations),
2142
2256
  credentialReference: one(credentialReferences, {
2143
2257
  fields: [externalAgents.credentialReferenceId],
2144
2258
  references: [credentialReferences.id]
@@ -2154,13 +2268,13 @@ var init_schema = __esm({
2154
2268
  references: [agentGraph.id]
2155
2269
  })
2156
2270
  }));
2157
- agentToolRelationsRelations = relations(agentToolRelations, ({ one }) => ({
2158
- agent: one(agents, {
2159
- fields: [agentToolRelations.agentId],
2160
- references: [agents.id]
2271
+ agentToolRelationsRelations = relations(subAgentToolRelations, ({ one }) => ({
2272
+ subAgent: one(subAgents, {
2273
+ fields: [subAgentToolRelations.subAgentId],
2274
+ references: [subAgents.id]
2161
2275
  }),
2162
2276
  tool: one(tools, {
2163
- fields: [agentToolRelations.toolId],
2277
+ fields: [subAgentToolRelations.toolId],
2164
2278
  references: [tools.id]
2165
2279
  })
2166
2280
  }));
@@ -2172,14 +2286,10 @@ var init_schema = __esm({
2172
2286
  fields: [tools.tenantId, tools.projectId],
2173
2287
  references: [projects.tenantId, projects.id]
2174
2288
  }),
2175
- agentRelations: many(agentToolRelations),
2289
+ subAgentRelations: many(subAgentToolRelations),
2176
2290
  credentialReference: one(credentialReferences, {
2177
2291
  fields: [tools.credentialReferenceId],
2178
2292
  references: [credentialReferences.id]
2179
- }),
2180
- function: one(functions, {
2181
- fields: [tools.functionId],
2182
- references: [functions.id]
2183
2293
  })
2184
2294
  }));
2185
2295
  conversationsRelations = relations(conversations, ({ one, many }) => ({
@@ -2188,9 +2298,9 @@ var init_schema = __esm({
2188
2298
  references: [projects.tenantId, projects.id]
2189
2299
  }),
2190
2300
  messages: many(messages),
2191
- activeAgent: one(agents, {
2192
- fields: [conversations.activeAgentId],
2193
- references: [agents.id]
2301
+ activeSubAgent: one(subAgents, {
2302
+ fields: [conversations.activeSubAgentId],
2303
+ references: [subAgents.id]
2194
2304
  })
2195
2305
  }));
2196
2306
  messagesRelations = relations(messages, ({ one, many }) => ({
@@ -2198,20 +2308,14 @@ var init_schema = __esm({
2198
2308
  fields: [messages.conversationId],
2199
2309
  references: [conversations.id]
2200
2310
  }),
2201
- // Legacy agent association (consider deprecating)
2202
- agent: one(agents, {
2203
- fields: [messages.agentId],
2204
- references: [agents.id],
2205
- relationName: "associatedAgent"
2206
- }),
2207
- fromAgent: one(agents, {
2208
- fields: [messages.fromAgentId],
2209
- references: [agents.id],
2311
+ fromSubAgent: one(subAgents, {
2312
+ fields: [messages.fromSubAgentId],
2313
+ references: [subAgents.id],
2210
2314
  relationName: "sentMessages"
2211
2315
  }),
2212
- toAgent: one(agents, {
2213
- fields: [messages.toAgentId],
2214
- references: [agents.id],
2316
+ toSubAgent: one(subAgents, {
2317
+ fields: [messages.toSubAgentId],
2318
+ references: [subAgents.id],
2215
2319
  relationName: "receivedMessages"
2216
2320
  }),
2217
2321
  fromExternalAgent: one(externalAgents, {
@@ -2237,33 +2341,40 @@ var init_schema = __esm({
2237
2341
  relationName: "parentChild"
2238
2342
  })
2239
2343
  }));
2240
- artifactComponentsRelations = relations(artifactComponents, ({ many }) => ({
2241
- agentRelations: many(agentArtifactComponents)
2242
- }));
2243
- agentArtifactComponentsRelations = relations(agentArtifactComponents, ({ one }) => ({
2244
- agent: one(agents, {
2245
- fields: [agentArtifactComponents.agentId],
2246
- references: [agents.id]
2344
+ artifactComponentsRelations = relations(artifactComponents, ({ many, one }) => ({
2345
+ project: one(projects, {
2346
+ fields: [artifactComponents.tenantId, artifactComponents.projectId],
2347
+ references: [projects.tenantId, projects.id]
2247
2348
  }),
2248
- artifactComponent: one(artifactComponents, {
2249
- fields: [agentArtifactComponents.artifactComponentId],
2250
- references: [artifactComponents.id]
2251
- })
2349
+ subAgentRelations: many(subAgentArtifactComponents)
2252
2350
  }));
2351
+ subAgentArtifactComponentsRelations = relations(
2352
+ subAgentArtifactComponents,
2353
+ ({ one }) => ({
2354
+ subAgent: one(subAgents, {
2355
+ fields: [subAgentArtifactComponents.subAgentId],
2356
+ references: [subAgents.id]
2357
+ }),
2358
+ artifactComponent: one(artifactComponents, {
2359
+ fields: [subAgentArtifactComponents.artifactComponentId],
2360
+ references: [artifactComponents.id]
2361
+ })
2362
+ })
2363
+ );
2253
2364
  dataComponentsRelations = relations(dataComponents, ({ many, one }) => ({
2254
2365
  project: one(projects, {
2255
2366
  fields: [dataComponents.tenantId, dataComponents.projectId],
2256
2367
  references: [projects.tenantId, projects.id]
2257
2368
  }),
2258
- agentRelations: many(agentDataComponents)
2369
+ subAgentRelations: many(subAgentDataComponents)
2259
2370
  }));
2260
- agentDataComponentsRelations = relations(agentDataComponents, ({ one }) => ({
2261
- agent: one(agents, {
2262
- fields: [agentDataComponents.agentId],
2263
- references: [agents.id]
2371
+ subAgentDataComponentsRelations = relations(subAgentDataComponents, ({ one }) => ({
2372
+ subAgent: one(subAgents, {
2373
+ fields: [subAgentDataComponents.subAgentId],
2374
+ references: [subAgents.id]
2264
2375
  }),
2265
2376
  dataComponent: one(dataComponents, {
2266
- fields: [agentDataComponents.dataComponentId],
2377
+ fields: [subAgentDataComponents.dataComponentId],
2267
2378
  references: [dataComponents.id]
2268
2379
  })
2269
2380
  }));
@@ -2278,28 +2389,56 @@ var init_schema = __esm({
2278
2389
  })
2279
2390
  }));
2280
2391
  functionsRelations = relations(functions, ({ many }) => ({
2281
- tools: many(tools)
2392
+ functionTools: many(functionTools)
2282
2393
  }));
2283
- agentRelationsRelations = relations(agentRelations, ({ one }) => ({
2394
+ subAgentRelationsRelations = relations(subAgentRelations, ({ one }) => ({
2284
2395
  graph: one(agentGraph, {
2285
- fields: [agentRelations.graphId],
2396
+ fields: [subAgentRelations.graphId],
2286
2397
  references: [agentGraph.id]
2287
2398
  }),
2288
- sourceAgent: one(agents, {
2289
- fields: [agentRelations.sourceAgentId],
2290
- references: [agents.id],
2399
+ sourceSubAgent: one(subAgents, {
2400
+ fields: [subAgentRelations.sourceSubAgentId],
2401
+ references: [subAgents.id],
2291
2402
  relationName: "sourceRelations"
2292
2403
  }),
2293
- targetAgent: one(agents, {
2294
- fields: [agentRelations.targetAgentId],
2295
- references: [agents.id],
2404
+ targetSubAgent: one(subAgents, {
2405
+ fields: [subAgentRelations.targetSubAgentId],
2406
+ references: [subAgents.id],
2296
2407
  relationName: "targetRelations"
2297
2408
  }),
2298
2409
  externalAgent: one(externalAgents, {
2299
- fields: [agentRelations.externalAgentId],
2410
+ fields: [subAgentRelations.externalSubAgentId],
2300
2411
  references: [externalAgents.id]
2301
2412
  })
2302
2413
  }));
2414
+ functionToolsRelations = relations(functionTools, ({ one, many }) => ({
2415
+ project: one(projects, {
2416
+ fields: [functionTools.tenantId, functionTools.projectId],
2417
+ references: [projects.tenantId, projects.id]
2418
+ }),
2419
+ graph: one(agentGraph, {
2420
+ fields: [functionTools.tenantId, functionTools.projectId, functionTools.graphId],
2421
+ references: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id]
2422
+ }),
2423
+ function: one(functions, {
2424
+ fields: [functionTools.tenantId, functionTools.projectId, functionTools.functionId],
2425
+ references: [functions.tenantId, functions.projectId, functions.id]
2426
+ }),
2427
+ agentRelations: many(agentFunctionToolRelations)
2428
+ }));
2429
+ agentFunctionToolRelationsRelations = relations(
2430
+ agentFunctionToolRelations,
2431
+ ({ one }) => ({
2432
+ agent: one(subAgents, {
2433
+ fields: [agentFunctionToolRelations.subAgentId],
2434
+ references: [subAgents.id]
2435
+ }),
2436
+ functionTool: one(functionTools, {
2437
+ fields: [agentFunctionToolRelations.functionToolId],
2438
+ references: [functionTools.id]
2439
+ })
2440
+ })
2441
+ );
2303
2442
  }
2304
2443
  });
2305
2444
 
@@ -2328,7 +2467,7 @@ var init_utility = __esm({
2328
2467
  });
2329
2468
 
2330
2469
  // ../packages/agents-core/src/validation/schemas.ts
2331
- var StopWhenSchema, GraphStopWhenSchema, AgentStopWhenSchema, MIN_ID_LENGTH, MAX_ID_LENGTH, URL_SAFE_ID_PATTERN, resourceIdSchema, ModelSettingsSchema, ModelSchema, ProjectModelSchema, SandboxConfigSchema, FunctionToolConfigSchema, createApiSchema, createApiInsertSchema, createApiUpdateSchema, createGraphScopedApiSchema, createGraphScopedApiInsertSchema, createGraphScopedApiUpdateSchema, AgentSelectSchema, AgentInsertSchema, AgentUpdateSchema, AgentApiSelectSchema, AgentApiInsertSchema, AgentApiUpdateSchema, AgentRelationSelectSchema, AgentRelationInsertSchema, AgentRelationUpdateSchema, AgentRelationApiSelectSchema, AgentRelationApiInsertSchema, AgentRelationApiUpdateSchema, AgentRelationQuerySchema, ExternalAgentRelationInsertSchema, ExternalAgentRelationApiInsertSchema, AgentGraphSelectSchema, AgentGraphInsertSchema, AgentGraphUpdateSchema, AgentGraphApiSelectSchema, AgentGraphApiInsertSchema, AgentGraphApiUpdateSchema, TaskSelectSchema, TaskInsertSchema, TaskUpdateSchema, TaskApiSelectSchema, TaskApiInsertSchema, TaskApiUpdateSchema, TaskRelationSelectSchema, TaskRelationInsertSchema, TaskRelationUpdateSchema, TaskRelationApiSelectSchema, TaskRelationApiInsertSchema, TaskRelationApiUpdateSchema, imageUrlSchema, McpTransportConfigSchema, ToolStatusSchema, McpToolDefinitionSchema, ToolSelectSchema, ToolInsertSchema, ConversationSelectSchema, ConversationInsertSchema, ConversationUpdateSchema, ConversationApiSelectSchema, ConversationApiInsertSchema, ConversationApiUpdateSchema, MessageSelectSchema, MessageInsertSchema, MessageUpdateSchema, MessageApiSelectSchema, MessageApiInsertSchema, MessageApiUpdateSchema, ContextCacheSelectSchema, ContextCacheInsertSchema, ContextCacheUpdateSchema, ContextCacheApiSelectSchema, ContextCacheApiInsertSchema, ContextCacheApiUpdateSchema, DataComponentSelectSchema, DataComponentInsertSchema, DataComponentBaseSchema, DataComponentUpdateSchema, DataComponentApiSelectSchema, DataComponentApiInsertSchema, DataComponentApiUpdateSchema, AgentDataComponentSelectSchema, AgentDataComponentInsertSchema, AgentDataComponentUpdateSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiUpdateSchema, ArtifactComponentSelectSchema, ArtifactComponentInsertSchema, ArtifactComponentUpdateSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiUpdateSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentUpdateSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiUpdateSchema, ExternalAgentSelectSchema, ExternalAgentInsertSchema, ExternalAgentUpdateSchema, ExternalAgentApiSelectSchema, ExternalAgentApiInsertSchema, ExternalAgentApiUpdateSchema, AllAgentSchema, ApiKeySelectSchema, ApiKeyInsertSchema, ApiKeyUpdateSchema, ApiKeyApiSelectSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, CredentialReferenceSelectSchema, CredentialReferenceInsertSchema, CredentialReferenceUpdateSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiUpdateSchema, McpToolSchema, MCPToolConfigSchema, ToolUpdateSchema, ToolApiSelectSchema, ToolApiInsertSchema, ToolApiUpdateSchema, FunctionSelectSchema, FunctionInsertSchema, FunctionUpdateSchema, FunctionApiSelectSchema, FunctionApiInsertSchema, FunctionApiUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, ContextConfigSelectSchema, ContextConfigInsertSchema, ContextConfigUpdateSchema, ContextConfigApiSelectSchema, ContextConfigApiInsertSchema, ContextConfigApiUpdateSchema, AgentToolRelationSelectSchema, AgentToolRelationInsertSchema, AgentToolRelationUpdateSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiUpdateSchema, LedgerArtifactSelectSchema, LedgerArtifactInsertSchema, LedgerArtifactUpdateSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiUpdateSchema, StatusComponentSchema, StatusUpdateSchema, CanUseItemSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, GraphWithinContextOfProjectSchema, PaginationSchema, ErrorResponseSchema, ExistsResponseSchema, RemovedResponseSchema, ProjectSelectSchema, ProjectInsertSchema, ProjectUpdateSchema, ProjectApiSelectSchema, ProjectApiInsertSchema, ProjectApiUpdateSchema, FullProjectDefinitionSchema, HeadersScopeSchema, TenantParamsSchema, TenantProjectParamsSchema, TenantProjectGraphParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectIdParamsSchema, TenantIdParamsSchema, IdParamsSchema, PaginationQueryParamsSchema;
2470
+ var StopWhenSchema, GraphStopWhenSchema, SubAgentStopWhenSchema, MIN_ID_LENGTH, MAX_ID_LENGTH, URL_SAFE_ID_PATTERN, resourceIdSchema, ModelSettingsSchema, ModelSchema, ProjectModelSchema, SandboxConfigSchema, FunctionToolConfigSchema, createApiSchema, createApiInsertSchema, createApiUpdateSchema, createGraphScopedApiSchema, createGraphScopedApiInsertSchema, createGraphScopedApiUpdateSchema, SubAgentSelectSchema, SubAgentInsertSchema, SubAgentUpdateSchema, SubAgentApiSelectSchema, SubAgentApiInsertSchema, SubAgentApiUpdateSchema, SubAgentRelationSelectSchema, SubAgentRelationInsertSchema, SubAgentRelationUpdateSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiInsertSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationQuerySchema, ExternalSubAgentRelationInsertSchema, ExternalSubAgentRelationApiInsertSchema, AgentGraphSelectSchema, AgentGraphInsertSchema, AgentGraphUpdateSchema, AgentGraphApiSelectSchema, AgentGraphApiInsertSchema, AgentGraphApiUpdateSchema, TaskSelectSchema, TaskInsertSchema, TaskUpdateSchema, TaskApiSelectSchema, TaskApiInsertSchema, TaskApiUpdateSchema, TaskRelationSelectSchema, TaskRelationInsertSchema, TaskRelationUpdateSchema, TaskRelationApiSelectSchema, TaskRelationApiInsertSchema, TaskRelationApiUpdateSchema, imageUrlSchema, McpTransportConfigSchema, ToolStatusSchema, McpToolDefinitionSchema, ToolSelectSchema, ToolInsertSchema, ConversationSelectSchema, ConversationInsertSchema, ConversationUpdateSchema, ConversationApiSelectSchema, ConversationApiInsertSchema, ConversationApiUpdateSchema, MessageSelectSchema, MessageInsertSchema, MessageUpdateSchema, MessageApiSelectSchema, MessageApiInsertSchema, MessageApiUpdateSchema, ContextCacheSelectSchema, ContextCacheInsertSchema, ContextCacheUpdateSchema, ContextCacheApiSelectSchema, ContextCacheApiInsertSchema, ContextCacheApiUpdateSchema, DataComponentSelectSchema, DataComponentInsertSchema, DataComponentBaseSchema, DataComponentUpdateSchema, DataComponentApiSelectSchema, DataComponentApiInsertSchema, DataComponentApiUpdateSchema, SubAgentDataComponentSelectSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentUpdateSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiUpdateSchema, ArtifactComponentSelectSchema, ArtifactComponentInsertSchema, ArtifactComponentUpdateSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiUpdateSchema, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentUpdateSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiUpdateSchema, ExternalAgentSelectSchema, ExternalAgentInsertSchema, ExternalAgentUpdateSchema, ExternalAgentApiSelectSchema, ExternalAgentApiInsertSchema, ExternalAgentApiUpdateSchema, AllAgentSchema, ApiKeySelectSchema, ApiKeyInsertSchema, ApiKeyUpdateSchema, ApiKeyApiSelectSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, CredentialReferenceSelectSchema, CredentialReferenceInsertSchema, CredentialReferenceUpdateSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiUpdateSchema, McpToolSchema, MCPToolConfigSchema, ToolUpdateSchema, ToolApiSelectSchema, ToolApiInsertSchema, ToolApiUpdateSchema, FunctionToolSelectSchema, FunctionToolInsertSchema, FunctionToolUpdateSchema, FunctionToolApiSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiUpdateSchema, FunctionSelectSchema, FunctionInsertSchema, FunctionUpdateSchema, FunctionApiSelectSchema, FunctionApiInsertSchema, FunctionApiUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, ContextConfigSelectSchema, ContextConfigInsertSchema, ContextConfigUpdateSchema, ContextConfigApiSelectSchema, ContextConfigApiInsertSchema, ContextConfigApiUpdateSchema, SubAgentToolRelationSelectSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationUpdateSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiUpdateSchema, LedgerArtifactSelectSchema, LedgerArtifactInsertSchema, LedgerArtifactUpdateSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiUpdateSchema, StatusComponentSchema, StatusUpdateSchema, CanUseItemSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, GraphWithinContextOfProjectSchema, PaginationSchema, ErrorResponseSchema, ExistsResponseSchema, RemovedResponseSchema, ProjectSelectSchema, ProjectInsertSchema, ProjectUpdateSchema, ProjectApiSelectSchema, ProjectApiInsertSchema, ProjectApiUpdateSchema, FullProjectDefinitionSchema, HeadersScopeSchema, TenantId, ProjectId, GraphId, SubAgentId, TenantParamsSchema, TenantIdParamsSchema, TenantProjectParamsSchema, TenantProjectIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphSubAgentParamsSchema, TenantProjectGraphSubAgentIdParamsSchema, PaginationQueryParamsSchema;
2332
2471
  var init_schemas = __esm({
2333
2472
  "../packages/agents-core/src/validation/schemas.ts"() {
2334
2473
  "use strict";
@@ -2342,7 +2481,7 @@ var init_schemas = __esm({
2342
2481
  stepCountIs: z2.number().min(1).max(1e3).optional()
2343
2482
  });
2344
2483
  GraphStopWhenSchema = StopWhenSchema.pick({ transferCountIs: true });
2345
- AgentStopWhenSchema = StopWhenSchema.pick({ stepCountIs: true });
2484
+ SubAgentStopWhenSchema = StopWhenSchema.pick({ stepCountIs: true });
2346
2485
  MIN_ID_LENGTH = 1;
2347
2486
  MAX_ID_LENGTH = 255;
2348
2487
  URL_SAFE_ID_PATTERN = /^[a-zA-Z0-9\-_.]+$/;
@@ -2385,71 +2524,73 @@ var init_schemas = __esm({
2385
2524
  createGraphScopedApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true });
2386
2525
  createGraphScopedApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true });
2387
2526
  createGraphScopedApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true }).partial();
2388
- AgentSelectSchema = createSelectSchema(agents);
2389
- AgentInsertSchema = createInsertSchema(agents).extend({
2527
+ SubAgentSelectSchema = createSelectSchema(subAgents);
2528
+ SubAgentInsertSchema = createInsertSchema(subAgents).extend({
2390
2529
  id: resourceIdSchema,
2391
2530
  models: ModelSchema.optional()
2392
2531
  });
2393
- AgentUpdateSchema = AgentInsertSchema.partial();
2394
- AgentApiSelectSchema = createGraphScopedApiSchema(AgentSelectSchema);
2395
- AgentApiInsertSchema = createGraphScopedApiInsertSchema(AgentInsertSchema);
2396
- AgentApiUpdateSchema = createGraphScopedApiUpdateSchema(AgentUpdateSchema);
2397
- AgentRelationSelectSchema = createSelectSchema(agentRelations);
2398
- AgentRelationInsertSchema = createInsertSchema(agentRelations).extend({
2532
+ SubAgentUpdateSchema = SubAgentInsertSchema.partial();
2533
+ SubAgentApiSelectSchema = createGraphScopedApiSchema(SubAgentSelectSchema);
2534
+ SubAgentApiInsertSchema = createGraphScopedApiInsertSchema(SubAgentInsertSchema);
2535
+ SubAgentApiUpdateSchema = createGraphScopedApiUpdateSchema(SubAgentUpdateSchema);
2536
+ SubAgentRelationSelectSchema = createSelectSchema(subAgentRelations);
2537
+ SubAgentRelationInsertSchema = createInsertSchema(subAgentRelations).extend({
2399
2538
  id: resourceIdSchema,
2400
2539
  graphId: resourceIdSchema,
2401
- sourceAgentId: resourceIdSchema,
2402
- targetAgentId: resourceIdSchema.optional(),
2403
- externalAgentId: resourceIdSchema.optional()
2540
+ sourceSubAgentId: resourceIdSchema,
2541
+ targetSubAgentId: resourceIdSchema.optional(),
2542
+ externalSubAgentId: resourceIdSchema.optional()
2404
2543
  });
2405
- AgentRelationUpdateSchema = AgentRelationInsertSchema.partial();
2406
- AgentRelationApiSelectSchema = createGraphScopedApiSchema(AgentRelationSelectSchema);
2407
- AgentRelationApiInsertSchema = createGraphScopedApiInsertSchema(
2408
- AgentRelationInsertSchema
2544
+ SubAgentRelationUpdateSchema = SubAgentRelationInsertSchema.partial();
2545
+ SubAgentRelationApiSelectSchema = createGraphScopedApiSchema(
2546
+ SubAgentRelationSelectSchema
2547
+ );
2548
+ SubAgentRelationApiInsertSchema = createGraphScopedApiInsertSchema(
2549
+ SubAgentRelationInsertSchema
2409
2550
  ).extend({
2410
2551
  relationType: z2.enum(VALID_RELATION_TYPES)
2411
2552
  }).refine(
2412
2553
  (data) => {
2413
- const hasTarget = data.targetAgentId != null;
2414
- const hasExternal = data.externalAgentId != null;
2554
+ const hasTarget = data.targetSubAgentId != null;
2555
+ const hasExternal = data.externalSubAgentId != null;
2415
2556
  return hasTarget !== hasExternal;
2416
2557
  },
2417
2558
  {
2418
- message: "Must specify exactly one of targetAgentId or externalAgentId",
2419
- path: ["targetAgentId", "externalAgentId"]
2559
+ message: "Must specify exactly one of targetSubAgentId or externalSubAgentId",
2560
+ path: ["targetSubAgentId", "externalSubAgentId"]
2420
2561
  }
2421
2562
  );
2422
- AgentRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
2423
- AgentRelationUpdateSchema
2563
+ SubAgentRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
2564
+ SubAgentRelationUpdateSchema
2424
2565
  ).extend({
2425
2566
  relationType: z2.enum(VALID_RELATION_TYPES).optional()
2426
2567
  }).refine(
2427
2568
  (data) => {
2428
- const hasTarget = data.targetAgentId != null;
2429
- const hasExternal = data.externalAgentId != null;
2569
+ const hasTarget = data.targetSubAgentId != null;
2570
+ const hasExternal = data.externalSubAgentId != null;
2430
2571
  if (!hasTarget && !hasExternal) {
2431
2572
  return true;
2432
2573
  }
2433
2574
  return hasTarget !== hasExternal;
2434
2575
  },
2435
2576
  {
2436
- message: "Must specify exactly one of targetAgentId or externalAgentId when updating agent relationships",
2437
- path: ["targetAgentId", "externalAgentId"]
2577
+ message: "Must specify exactly one of targetSubAgentId or externalSubAgentId when updating sub-agent relationships",
2578
+ path: ["targetSubAgentId", "externalSubAgentId"]
2438
2579
  }
2439
2580
  );
2440
- AgentRelationQuerySchema = z2.object({
2441
- sourceAgentId: z2.string().optional(),
2442
- targetAgentId: z2.string().optional(),
2443
- externalAgentId: z2.string().optional()
2581
+ SubAgentRelationQuerySchema = z2.object({
2582
+ sourceSubAgentId: z2.string().optional(),
2583
+ targetSubAgentId: z2.string().optional(),
2584
+ externalSubAgentId: z2.string().optional()
2444
2585
  });
2445
- ExternalAgentRelationInsertSchema = createInsertSchema(agentRelations).extend({
2586
+ ExternalSubAgentRelationInsertSchema = createInsertSchema(subAgentRelations).extend({
2446
2587
  id: resourceIdSchema,
2447
2588
  graphId: resourceIdSchema,
2448
- sourceAgentId: resourceIdSchema,
2449
- externalAgentId: resourceIdSchema
2589
+ sourceSubAgentId: resourceIdSchema,
2590
+ externalSubAgentId: resourceIdSchema
2450
2591
  });
2451
- ExternalAgentRelationApiInsertSchema = createApiInsertSchema(
2452
- ExternalAgentRelationInsertSchema
2592
+ ExternalSubAgentRelationApiInsertSchema = createApiInsertSchema(
2593
+ ExternalSubAgentRelationInsertSchema
2453
2594
  );
2454
2595
  AgentGraphSelectSchema = createSelectSchema(agentGraph);
2455
2596
  AgentGraphInsertSchema = createInsertSchema(agentGraph).extend({
@@ -2516,32 +2657,22 @@ var init_schemas = __esm({
2516
2657
  ToolInsertSchema = createInsertSchema(tools).extend({
2517
2658
  id: resourceIdSchema,
2518
2659
  imageUrl: imageUrlSchema,
2519
- functionId: resourceIdSchema.optional(),
2520
- // For function tools, reference to global functions table
2521
- config: z2.discriminatedUnion("type", [
2522
- // MCP tools
2523
- z2.object({
2524
- type: z2.literal("mcp"),
2525
- mcp: z2.object({
2526
- server: z2.object({
2527
- url: z2.string().url()
2528
- }),
2529
- transport: z2.object({
2530
- type: z2.enum(MCPTransportType),
2531
- requestInit: z2.record(z2.string(), z2.unknown()).optional(),
2532
- eventSourceInit: z2.record(z2.string(), z2.unknown()).optional(),
2533
- reconnectionOptions: z2.custom().optional(),
2534
- sessionId: z2.string().optional()
2535
- }).optional(),
2536
- activeTools: z2.array(z2.string()).optional()
2537
- })
2538
- }),
2539
- // Function tools (reference-only, no inline duplication)
2540
- z2.object({
2541
- type: z2.literal("function")
2542
- // No inline function details - they're in the functions table via functionId
2660
+ config: z2.object({
2661
+ type: z2.literal("mcp"),
2662
+ mcp: z2.object({
2663
+ server: z2.object({
2664
+ url: z2.string().url()
2665
+ }),
2666
+ transport: z2.object({
2667
+ type: z2.enum(MCPTransportType),
2668
+ requestInit: z2.record(z2.string(), z2.unknown()).optional(),
2669
+ eventSourceInit: z2.record(z2.string(), z2.unknown()).optional(),
2670
+ reconnectionOptions: z2.custom().optional(),
2671
+ sessionId: z2.string().optional()
2672
+ }).optional(),
2673
+ activeTools: z2.array(z2.string()).optional()
2543
2674
  })
2544
- ])
2675
+ })
2545
2676
  });
2546
2677
  ConversationSelectSchema = createSelectSchema(conversations);
2547
2678
  ConversationInsertSchema = createInsertSchema(conversations).extend({
@@ -2580,20 +2711,20 @@ var init_schemas = __esm({
2580
2711
  DataComponentApiSelectSchema = createApiSchema(DataComponentSelectSchema);
2581
2712
  DataComponentApiInsertSchema = createApiInsertSchema(DataComponentInsertSchema);
2582
2713
  DataComponentApiUpdateSchema = createApiUpdateSchema(DataComponentUpdateSchema);
2583
- AgentDataComponentSelectSchema = createSelectSchema(agentDataComponents);
2584
- AgentDataComponentInsertSchema = createInsertSchema(agentDataComponents);
2585
- AgentDataComponentUpdateSchema = AgentDataComponentInsertSchema.partial();
2586
- AgentDataComponentApiSelectSchema = createGraphScopedApiSchema(
2587
- AgentDataComponentSelectSchema
2714
+ SubAgentDataComponentSelectSchema = createSelectSchema(subAgentDataComponents);
2715
+ SubAgentDataComponentInsertSchema = createInsertSchema(subAgentDataComponents);
2716
+ SubAgentDataComponentUpdateSchema = SubAgentDataComponentInsertSchema.partial();
2717
+ SubAgentDataComponentApiSelectSchema = createGraphScopedApiSchema(
2718
+ SubAgentDataComponentSelectSchema
2588
2719
  );
2589
- AgentDataComponentApiInsertSchema = AgentDataComponentInsertSchema.omit({
2720
+ SubAgentDataComponentApiInsertSchema = SubAgentDataComponentInsertSchema.omit({
2590
2721
  tenantId: true,
2591
2722
  projectId: true,
2592
2723
  id: true,
2593
2724
  createdAt: true
2594
2725
  });
2595
- AgentDataComponentApiUpdateSchema = createGraphScopedApiUpdateSchema(
2596
- AgentDataComponentUpdateSchema
2726
+ SubAgentDataComponentApiUpdateSchema = createGraphScopedApiUpdateSchema(
2727
+ SubAgentDataComponentUpdateSchema
2597
2728
  );
2598
2729
  ArtifactComponentSelectSchema = createSelectSchema(artifactComponents);
2599
2730
  ArtifactComponentInsertSchema = createInsertSchema(artifactComponents).extend({
@@ -2610,26 +2741,26 @@ var init_schemas = __esm({
2610
2741
  ArtifactComponentApiUpdateSchema = createApiUpdateSchema(
2611
2742
  ArtifactComponentUpdateSchema
2612
2743
  );
2613
- AgentArtifactComponentSelectSchema = createSelectSchema(agentArtifactComponents);
2614
- AgentArtifactComponentInsertSchema = createInsertSchema(
2615
- agentArtifactComponents
2744
+ SubAgentArtifactComponentSelectSchema = createSelectSchema(subAgentArtifactComponents);
2745
+ SubAgentArtifactComponentInsertSchema = createInsertSchema(
2746
+ subAgentArtifactComponents
2616
2747
  ).extend({
2617
2748
  id: resourceIdSchema,
2618
- agentId: resourceIdSchema,
2749
+ subAgentId: resourceIdSchema,
2619
2750
  artifactComponentId: resourceIdSchema
2620
2751
  });
2621
- AgentArtifactComponentUpdateSchema = AgentArtifactComponentInsertSchema.partial();
2622
- AgentArtifactComponentApiSelectSchema = createGraphScopedApiSchema(
2623
- AgentArtifactComponentSelectSchema
2752
+ SubAgentArtifactComponentUpdateSchema = SubAgentArtifactComponentInsertSchema.partial();
2753
+ SubAgentArtifactComponentApiSelectSchema = createGraphScopedApiSchema(
2754
+ SubAgentArtifactComponentSelectSchema
2624
2755
  );
2625
- AgentArtifactComponentApiInsertSchema = AgentArtifactComponentInsertSchema.omit({
2756
+ SubAgentArtifactComponentApiInsertSchema = SubAgentArtifactComponentInsertSchema.omit({
2626
2757
  tenantId: true,
2627
2758
  projectId: true,
2628
2759
  id: true,
2629
2760
  createdAt: true
2630
2761
  });
2631
- AgentArtifactComponentApiUpdateSchema = createGraphScopedApiUpdateSchema(
2632
- AgentArtifactComponentUpdateSchema
2762
+ SubAgentArtifactComponentApiUpdateSchema = createGraphScopedApiUpdateSchema(
2763
+ SubAgentArtifactComponentUpdateSchema
2633
2764
  );
2634
2765
  ExternalAgentSelectSchema = createSelectSchema(externalAgents).extend({
2635
2766
  credentialReferenceId: z2.string().nullable().optional(),
@@ -2643,7 +2774,7 @@ var init_schemas = __esm({
2643
2774
  ExternalAgentApiInsertSchema = createGraphScopedApiInsertSchema(ExternalAgentInsertSchema);
2644
2775
  ExternalAgentApiUpdateSchema = createGraphScopedApiUpdateSchema(ExternalAgentUpdateSchema);
2645
2776
  AllAgentSchema = z2.discriminatedUnion("type", [
2646
- AgentApiSelectSchema.extend({ type: z2.literal("internal") }),
2777
+ SubAgentApiSelectSchema.extend({ type: z2.literal("internal") }),
2647
2778
  ExternalAgentApiSelectSchema.extend({ type: z2.literal("external") })
2648
2779
  ]);
2649
2780
  ApiKeySelectSchema = createSelectSchema(apiKeys);
@@ -2750,6 +2881,14 @@ var init_schemas = __esm({
2750
2881
  ToolApiSelectSchema = createApiSchema(ToolSelectSchema);
2751
2882
  ToolApiInsertSchema = createApiInsertSchema(ToolInsertSchema);
2752
2883
  ToolApiUpdateSchema = createApiUpdateSchema(ToolUpdateSchema);
2884
+ FunctionToolSelectSchema = createSelectSchema(functionTools);
2885
+ FunctionToolInsertSchema = createInsertSchema(functionTools).extend({
2886
+ id: resourceIdSchema
2887
+ });
2888
+ FunctionToolUpdateSchema = FunctionToolInsertSchema.partial();
2889
+ FunctionToolApiSelectSchema = createApiSchema(FunctionToolSelectSchema);
2890
+ FunctionToolApiInsertSchema = createGraphScopedApiInsertSchema(FunctionToolInsertSchema);
2891
+ FunctionToolApiUpdateSchema = createApiUpdateSchema(FunctionToolUpdateSchema);
2753
2892
  FunctionSelectSchema = createSelectSchema(functions);
2754
2893
  FunctionInsertSchema = createInsertSchema(functions).extend({
2755
2894
  id: resourceIdSchema
@@ -2797,23 +2936,23 @@ var init_schemas = __esm({
2797
2936
  ContextConfigApiUpdateSchema = createApiUpdateSchema(ContextConfigUpdateSchema).omit({
2798
2937
  graphId: true
2799
2938
  });
2800
- AgentToolRelationSelectSchema = createSelectSchema(agentToolRelations);
2801
- AgentToolRelationInsertSchema = createInsertSchema(agentToolRelations).extend({
2939
+ SubAgentToolRelationSelectSchema = createSelectSchema(subAgentToolRelations);
2940
+ SubAgentToolRelationInsertSchema = createInsertSchema(subAgentToolRelations).extend({
2802
2941
  id: resourceIdSchema,
2803
- agentId: resourceIdSchema,
2942
+ subAgentId: resourceIdSchema,
2804
2943
  toolId: resourceIdSchema,
2805
2944
  selectedTools: z2.array(z2.string()).nullish(),
2806
2945
  headers: z2.record(z2.string(), z2.string()).nullish()
2807
2946
  });
2808
- AgentToolRelationUpdateSchema = AgentToolRelationInsertSchema.partial();
2809
- AgentToolRelationApiSelectSchema = createGraphScopedApiSchema(
2810
- AgentToolRelationSelectSchema
2947
+ SubAgentToolRelationUpdateSchema = SubAgentToolRelationInsertSchema.partial();
2948
+ SubAgentToolRelationApiSelectSchema = createGraphScopedApiSchema(
2949
+ SubAgentToolRelationSelectSchema
2811
2950
  );
2812
- AgentToolRelationApiInsertSchema = createGraphScopedApiInsertSchema(
2813
- AgentToolRelationInsertSchema
2951
+ SubAgentToolRelationApiInsertSchema = createGraphScopedApiInsertSchema(
2952
+ SubAgentToolRelationInsertSchema
2814
2953
  );
2815
- AgentToolRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
2816
- AgentToolRelationUpdateSchema
2954
+ SubAgentToolRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
2955
+ SubAgentToolRelationUpdateSchema
2817
2956
  );
2818
2957
  LedgerArtifactSelectSchema = createSelectSchema(ledgerArtifacts);
2819
2958
  LedgerArtifactInsertSchema = createInsertSchema(ledgerArtifacts);
@@ -2843,7 +2982,7 @@ var init_schemas = __esm({
2843
2982
  toolSelection: z2.array(z2.string()).nullish(),
2844
2983
  headers: z2.record(z2.string(), z2.string()).nullish()
2845
2984
  });
2846
- FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
2985
+ FullGraphAgentInsertSchema = SubAgentApiInsertSchema.extend({
2847
2986
  type: z2.literal("internal"),
2848
2987
  canUse: z2.array(CanUseItemSchema),
2849
2988
  // All tools (both MCP and function tools)
@@ -2853,10 +2992,15 @@ var init_schemas = __esm({
2853
2992
  canDelegateTo: z2.array(z2.string()).optional()
2854
2993
  });
2855
2994
  FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
2856
- agents: z2.record(z2.string(), z2.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
2995
+ subAgents: z2.record(
2996
+ z2.string(),
2997
+ z2.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])
2998
+ ),
2857
2999
  // Lookup maps for UI to resolve canUse items
2858
3000
  tools: z2.record(z2.string(), ToolApiInsertSchema).optional(),
2859
- // Get tool name/description from toolId
3001
+ // MCP tools (project-scoped)
3002
+ functionTools: z2.record(z2.string(), FunctionToolApiInsertSchema).optional(),
3003
+ // Function tools (graph-scoped)
2860
3004
  functions: z2.record(z2.string(), FunctionApiInsertSchema).optional(),
2861
3005
  // Get function code for function tools
2862
3006
  contextConfig: z2.optional(ContextConfigApiInsertSchema),
@@ -2866,13 +3010,20 @@ var init_schemas = __esm({
2866
3010
  graphPrompt: z2.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
2867
3011
  });
2868
3012
  GraphWithinContextOfProjectSchema = AgentGraphApiInsertSchema.extend({
2869
- agents: z2.record(
3013
+ subAgents: z2.record(
2870
3014
  z2.string(),
2871
3015
  z2.discriminatedUnion("type", [
2872
3016
  FullGraphAgentInsertSchema,
2873
3017
  ExternalAgentApiInsertSchema.extend({ type: z2.literal("external") })
2874
3018
  ])
2875
3019
  ),
3020
+ // Lookup maps for UI to resolve canUse items
3021
+ tools: z2.record(z2.string(), ToolApiInsertSchema).optional(),
3022
+ // MCP tools (project-scoped)
3023
+ functionTools: z2.record(z2.string(), FunctionToolApiInsertSchema).optional(),
3024
+ // Function tools (graph-scoped)
3025
+ functions: z2.record(z2.string(), FunctionApiInsertSchema).optional(),
3026
+ // Get function code for function tools
2876
3027
  contextConfig: z2.optional(ContextConfigApiInsertSchema),
2877
3028
  statusUpdates: z2.optional(StatusUpdateSchema),
2878
3029
  models: ModelSchema.optional(),
@@ -2913,9 +3064,9 @@ var init_schemas = __esm({
2913
3064
  FullProjectDefinitionSchema = ProjectApiInsertSchema.extend({
2914
3065
  graphs: z2.record(z2.string(), GraphWithinContextOfProjectSchema),
2915
3066
  tools: z2.record(z2.string(), ToolApiInsertSchema),
2916
- // Now includes both MCP and function tools
3067
+ // MCP tools (project-scoped)
2917
3068
  functions: z2.record(z2.string(), FunctionApiInsertSchema).optional(),
2918
- // Global functions
3069
+ // Functions (project-scoped)
2919
3070
  dataComponents: z2.record(z2.string(), DataComponentApiInsertSchema).optional(),
2920
3071
  artifactComponents: z2.record(z2.string(), ArtifactComponentApiInsertSchema).optional(),
2921
3072
  statusUpdates: z2.optional(StatusUpdateSchema),
@@ -2937,72 +3088,46 @@ var init_schemas = __esm({
2937
3088
  example: "graph_789"
2938
3089
  })
2939
3090
  });
3091
+ TenantId = z2.string().openapi({
3092
+ description: "Tenant identifier",
3093
+ example: "tenant_123"
3094
+ });
3095
+ ProjectId = z2.string().openapi({
3096
+ description: "Project identifier",
3097
+ example: "project_456"
3098
+ });
3099
+ GraphId = z2.string().openapi({
3100
+ description: "Graph identifier",
3101
+ example: "graph_789"
3102
+ });
3103
+ SubAgentId = z2.string().openapi({
3104
+ description: "Sub-agent identifier",
3105
+ example: "sub_agent_123"
3106
+ });
2940
3107
  TenantParamsSchema = z2.object({
2941
- tenantId: z2.string().openapi({
2942
- description: "Tenant identifier",
2943
- example: "tenant_123"
2944
- })
3108
+ tenantId: TenantId
2945
3109
  }).openapi("TenantParams");
2946
- TenantProjectParamsSchema = z2.object({
2947
- tenantId: z2.string().openapi({
2948
- description: "Tenant identifier",
2949
- example: "tenant_123"
2950
- }),
2951
- projectId: z2.string().openapi({
2952
- description: "Project identifier",
2953
- example: "project_456"
2954
- })
2955
- }).openapi("TenantProjectParams");
2956
- TenantProjectGraphParamsSchema = z2.object({
2957
- tenantId: z2.string().openapi({
2958
- description: "Tenant identifier",
2959
- example: "tenant_123"
2960
- }),
2961
- projectId: z2.string().openapi({
2962
- description: "Project identifier",
2963
- example: "project_456"
2964
- }),
2965
- graphId: z2.string().openapi({
2966
- description: "Graph identifier",
2967
- example: "graph_789"
2968
- })
2969
- }).openapi("TenantProjectGraphParams");
2970
- TenantProjectGraphIdParamsSchema = z2.object({
2971
- tenantId: z2.string().openapi({
2972
- description: "Tenant identifier",
2973
- example: "tenant_123"
2974
- }),
2975
- projectId: z2.string().openapi({
2976
- description: "Project identifier",
2977
- example: "project_456"
2978
- }),
2979
- graphId: z2.string().openapi({
2980
- description: "Graph identifier",
2981
- example: "graph_789"
2982
- }),
3110
+ TenantIdParamsSchema = TenantParamsSchema.extend({
2983
3111
  id: resourceIdSchema
2984
- }).openapi("TenantProjectGraphIdParams");
2985
- TenantProjectIdParamsSchema = z2.object({
2986
- tenantId: z2.string().openapi({
2987
- description: "Tenant identifier",
2988
- example: "tenant_123"
2989
- }),
2990
- projectId: z2.string().openapi({
2991
- description: "Project identifier",
2992
- example: "project_456"
2993
- }),
3112
+ }).openapi("TenantIdParams");
3113
+ TenantProjectParamsSchema = TenantParamsSchema.extend({
3114
+ projectId: ProjectId
3115
+ }).openapi("TenantProjectParams");
3116
+ TenantProjectIdParamsSchema = TenantProjectParamsSchema.extend({
2994
3117
  id: resourceIdSchema
2995
3118
  }).openapi("TenantProjectIdParams");
2996
- TenantIdParamsSchema = z2.object({
2997
- tenantId: z2.string().openapi({
2998
- description: "Tenant identifier",
2999
- example: "tenant_123"
3000
- }),
3119
+ TenantProjectGraphParamsSchema = TenantProjectParamsSchema.extend({
3120
+ graphId: GraphId
3121
+ }).openapi("TenantProjectGraphParams");
3122
+ TenantProjectGraphIdParamsSchema = TenantProjectGraphParamsSchema.extend({
3001
3123
  id: resourceIdSchema
3002
- }).openapi("TenantIdParams");
3003
- IdParamsSchema = z2.object({
3124
+ }).openapi("TenantProjectGraphIdParams");
3125
+ TenantProjectGraphSubAgentParamsSchema = TenantProjectGraphParamsSchema.extend({
3126
+ subAgentId: SubAgentId
3127
+ }).openapi("TenantProjectGraphSubAgentParams");
3128
+ TenantProjectGraphSubAgentIdParamsSchema = TenantProjectGraphSubAgentParamsSchema.extend({
3004
3129
  id: resourceIdSchema
3005
- }).openapi("IdParams");
3130
+ }).openapi("TenantProjectGraphSubAgentIdParams");
3006
3131
  PaginationQueryParamsSchema = z2.object({
3007
3132
  page: z2.coerce.number().min(1).default(1),
3008
3133
  limit: z2.coerce.number().min(1).max(100).default(10)
@@ -4616,50 +4741,63 @@ var init_client = __esm({
4616
4741
  }
4617
4742
  });
4618
4743
 
4619
- // ../packages/agents-core/src/data-access/agentRelations.ts
4620
- import { and, count, desc, eq, isNotNull } from "drizzle-orm";
4621
- var init_agentRelations = __esm({
4622
- "../packages/agents-core/src/data-access/agentRelations.ts"() {
4744
+ // ../packages/agents-core/src/data-access/contextConfigs.ts
4745
+ import { and, count, desc, eq, sql as sql2 } from "drizzle-orm";
4746
+ var init_contextConfigs = __esm({
4747
+ "../packages/agents-core/src/data-access/contextConfigs.ts"() {
4623
4748
  "use strict";
4624
4749
  init_esm_shims();
4625
4750
  init_schema();
4626
4751
  }
4627
4752
  });
4628
4753
 
4629
- // ../packages/agents-core/src/data-access/agents.ts
4630
- import { and as and2, count as count2, desc as desc2, eq as eq2, inArray } from "drizzle-orm";
4631
- var init_agents = __esm({
4632
- "../packages/agents-core/src/data-access/agents.ts"() {
4754
+ // ../packages/agents-core/src/data-access/externalAgents.ts
4755
+ import { and as and2, asc, count as count2, desc as desc2, eq as eq2 } from "drizzle-orm";
4756
+ var init_externalAgents = __esm({
4757
+ "../packages/agents-core/src/data-access/externalAgents.ts"() {
4633
4758
  "use strict";
4634
4759
  init_esm_shims();
4635
4760
  init_schema();
4636
4761
  }
4637
4762
  });
4638
4763
 
4639
- // ../packages/agents-core/src/data-access/contextConfigs.ts
4640
- import { and as and3, count as count3, desc as desc3, eq as eq3, sql as sql2 } from "drizzle-orm";
4641
- var init_contextConfigs = __esm({
4642
- "../packages/agents-core/src/data-access/contextConfigs.ts"() {
4764
+ // ../packages/agents-core/src/data-access/functions.ts
4765
+ import { and as and3, eq as eq3 } from "drizzle-orm";
4766
+ var init_functions = __esm({
4767
+ "../packages/agents-core/src/data-access/functions.ts"() {
4643
4768
  "use strict";
4644
4769
  init_esm_shims();
4645
4770
  init_schema();
4646
4771
  }
4647
4772
  });
4648
4773
 
4649
- // ../packages/agents-core/src/data-access/externalAgents.ts
4650
- import { and as and4, asc, count as count4, desc as desc4, eq as eq4 } from "drizzle-orm";
4651
- var init_externalAgents = __esm({
4652
- "../packages/agents-core/src/data-access/externalAgents.ts"() {
4774
+ // ../packages/agents-core/src/data-access/functionTools.ts
4775
+ import { and as and4, count as count3, desc as desc3, eq as eq4 } from "drizzle-orm";
4776
+ var logger4;
4777
+ var init_functionTools = __esm({
4778
+ "../packages/agents-core/src/data-access/functionTools.ts"() {
4653
4779
  "use strict";
4654
4780
  init_esm_shims();
4655
4781
  init_schema();
4782
+ init_logger();
4783
+ logger4 = getLogger("functionTools");
4656
4784
  }
4657
4785
  });
4658
4786
 
4659
- // ../packages/agents-core/src/data-access/functions.ts
4660
- import { and as and5, eq as eq5 } from "drizzle-orm";
4661
- var init_functions = __esm({
4662
- "../packages/agents-core/src/data-access/functions.ts"() {
4787
+ // ../packages/agents-core/src/data-access/subAgentRelations.ts
4788
+ import { and as and5, count as count4, desc as desc4, eq as eq5, isNotNull } from "drizzle-orm";
4789
+ var init_subAgentRelations = __esm({
4790
+ "../packages/agents-core/src/data-access/subAgentRelations.ts"() {
4791
+ "use strict";
4792
+ init_esm_shims();
4793
+ init_schema();
4794
+ }
4795
+ });
4796
+
4797
+ // ../packages/agents-core/src/data-access/subAgents.ts
4798
+ import { and as and6, count as count5, desc as desc5, eq as eq6, inArray } from "drizzle-orm";
4799
+ var init_subAgents = __esm({
4800
+ "../packages/agents-core/src/data-access/subAgents.ts"() {
4663
4801
  "use strict";
4664
4802
  init_esm_shims();
4665
4803
  init_schema();
@@ -4678,7 +4816,7 @@ var init_credential_stuffer = __esm({
4678
4816
  // ../packages/agents-core/src/utils/apiKeys.ts
4679
4817
  import { randomBytes, scrypt, timingSafeEqual } from "crypto";
4680
4818
  import { promisify } from "util";
4681
- var scryptAsync, logger4, PUBLIC_ID_LENGTH, PUBLIC_ID_ALPHABET, generatePublicId;
4819
+ var scryptAsync, logger5, PUBLIC_ID_LENGTH, PUBLIC_ID_ALPHABET, generatePublicId;
4682
4820
  var init_apiKeys = __esm({
4683
4821
  "../packages/agents-core/src/utils/apiKeys.ts"() {
4684
4822
  "use strict";
@@ -4686,7 +4824,7 @@ var init_apiKeys = __esm({
4686
4824
  init_nanoid();
4687
4825
  init_logger();
4688
4826
  scryptAsync = promisify(scrypt);
4689
- logger4 = getLogger("api-key");
4827
+ logger5 = getLogger("api-key");
4690
4828
  PUBLIC_ID_LENGTH = 12;
4691
4829
  PUBLIC_ID_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-";
4692
4830
  generatePublicId = customAlphabet(PUBLIC_ID_ALPHABET, PUBLIC_ID_LENGTH);
@@ -7328,26 +7466,26 @@ var require_resolve = __commonJS({
7328
7466
  return true;
7329
7467
  }
7330
7468
  function countKeys(schema) {
7331
- var count15 = 0, item;
7469
+ var count16 = 0, item;
7332
7470
  if (Array.isArray(schema)) {
7333
7471
  for (var i2 = 0; i2 < schema.length; i2++) {
7334
7472
  item = schema[i2];
7335
- if (typeof item == "object") count15 += countKeys(item);
7336
- if (count15 == Infinity) return Infinity;
7473
+ if (typeof item == "object") count16 += countKeys(item);
7474
+ if (count16 == Infinity) return Infinity;
7337
7475
  }
7338
7476
  } else {
7339
7477
  for (var key in schema) {
7340
7478
  if (key == "$ref") return Infinity;
7341
7479
  if (SIMPLE_INLINED[key]) {
7342
- count15++;
7480
+ count16++;
7343
7481
  } else {
7344
7482
  item = schema[key];
7345
- if (typeof item == "object") count15 += countKeys(item) + 1;
7346
- if (count15 == Infinity) return Infinity;
7483
+ if (typeof item == "object") count16 += countKeys(item) + 1;
7484
+ if (count16 == Infinity) return Infinity;
7347
7485
  }
7348
7486
  }
7349
7487
  }
7350
- return count15;
7488
+ return count16;
7351
7489
  }
7352
7490
  function getFullPath(id, normalize) {
7353
7491
  if (normalize !== false) id = normalizeId(id);
@@ -12069,14 +12207,14 @@ var require_ajv = __commonJS({
12069
12207
  return metaOpts;
12070
12208
  }
12071
12209
  function setLogger(self) {
12072
- var logger14 = self._opts.logger;
12073
- if (logger14 === false) {
12210
+ var logger15 = self._opts.logger;
12211
+ if (logger15 === false) {
12074
12212
  self.logger = { log: noop, warn: noop, error: noop };
12075
12213
  } else {
12076
- if (logger14 === void 0) logger14 = console;
12077
- if (!(typeof logger14 == "object" && logger14.log && logger14.warn && logger14.error))
12214
+ if (logger15 === void 0) logger15 = console;
12215
+ if (!(typeof logger15 == "object" && logger15.log && logger15.warn && logger15.error))
12078
12216
  throw new Error("logger must implement log, warn and error methods");
12079
- self.logger = logger14;
12217
+ self.logger = logger15;
12080
12218
  }
12081
12219
  }
12082
12220
  function noop() {
@@ -12721,12 +12859,12 @@ var init_global_utils = __esm({
12721
12859
 
12722
12860
  // ../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
12723
12861
  function logProxy(funcName, namespace, args) {
12724
- var logger14 = getGlobal("diag");
12725
- if (!logger14) {
12862
+ var logger15 = getGlobal("diag");
12863
+ if (!logger15) {
12726
12864
  return;
12727
12865
  }
12728
12866
  args.unshift(namespace);
12729
- return logger14[funcName].apply(logger14, __spreadArray([], __read(args), false));
12867
+ return logger15[funcName].apply(logger15, __spreadArray([], __read(args), false));
12730
12868
  }
12731
12869
  var __read, __spreadArray, DiagComponentLogger;
12732
12870
  var init_ComponentLogger = __esm({
@@ -12824,17 +12962,17 @@ var init_types3 = __esm({
12824
12962
  });
12825
12963
 
12826
12964
  // ../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
12827
- function createLogLevelDiagLogger(maxLevel, logger14) {
12965
+ function createLogLevelDiagLogger(maxLevel, logger15) {
12828
12966
  if (maxLevel < DiagLogLevel.NONE) {
12829
12967
  maxLevel = DiagLogLevel.NONE;
12830
12968
  } else if (maxLevel > DiagLogLevel.ALL) {
12831
12969
  maxLevel = DiagLogLevel.ALL;
12832
12970
  }
12833
- logger14 = logger14 || {};
12971
+ logger15 = logger15 || {};
12834
12972
  function _filterFunc(funcName, theLevel) {
12835
- var theFunc = logger14[funcName];
12973
+ var theFunc = logger15[funcName];
12836
12974
  if (typeof theFunc === "function" && maxLevel >= theLevel) {
12837
- return theFunc.bind(logger14);
12975
+ return theFunc.bind(logger15);
12838
12976
  }
12839
12977
  return function() {
12840
12978
  };
@@ -12901,19 +13039,19 @@ var init_diag = __esm({
12901
13039
  for (var _i = 0; _i < arguments.length; _i++) {
12902
13040
  args[_i] = arguments[_i];
12903
13041
  }
12904
- var logger14 = getGlobal("diag");
12905
- if (!logger14)
13042
+ var logger15 = getGlobal("diag");
13043
+ if (!logger15)
12906
13044
  return;
12907
- return logger14[funcName].apply(logger14, __spreadArray2([], __read2(args), false));
13045
+ return logger15[funcName].apply(logger15, __spreadArray2([], __read2(args), false));
12908
13046
  };
12909
13047
  }
12910
13048
  var self = this;
12911
- var setLogger = function(logger14, optionsOrLogLevel) {
13049
+ var setLogger = function(logger15, optionsOrLogLevel) {
12912
13050
  var _a, _b, _c;
12913
13051
  if (optionsOrLogLevel === void 0) {
12914
13052
  optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
12915
13053
  }
12916
- if (logger14 === self) {
13054
+ if (logger15 === self) {
12917
13055
  var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
12918
13056
  self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
12919
13057
  return false;
@@ -12924,7 +13062,7 @@ var init_diag = __esm({
12924
13062
  };
12925
13063
  }
12926
13064
  var oldLogger = getGlobal("diag");
12927
- var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger14);
13065
+ var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger15);
12928
13066
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
12929
13067
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
12930
13068
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -13493,18 +13631,18 @@ function getTracer(serviceName, serviceVersion) {
13493
13631
  try {
13494
13632
  return trace.getTracer(serviceName, serviceVersion);
13495
13633
  } catch (_error) {
13496
- logger5.debug({}, "OpenTelemetry tracer not available, using no-op tracer");
13634
+ logger6.debug({}, "OpenTelemetry tracer not available, using no-op tracer");
13497
13635
  return noopTracer;
13498
13636
  }
13499
13637
  }
13500
- var logger5, createNoOpSpan, noopTracer;
13638
+ var logger6, createNoOpSpan, noopTracer;
13501
13639
  var init_tracer_factory = __esm({
13502
13640
  "../packages/agents-core/src/utils/tracer-factory.ts"() {
13503
13641
  "use strict";
13504
13642
  init_esm_shims();
13505
13643
  init_esm();
13506
13644
  init_utils();
13507
- logger5 = getLogger("tracer");
13645
+ logger6 = getLogger("tracer");
13508
13646
  createNoOpSpan = () => ({
13509
13647
  setAttributes: () => ({}),
13510
13648
  recordException: () => ({}),
@@ -13555,7 +13693,7 @@ var init_utils = __esm({
13555
13693
  });
13556
13694
 
13557
13695
  // ../packages/agents-core/src/data-access/credentialReferences.ts
13558
- import { and as and6, count as count5, desc as desc5, eq as eq6, sql as sql3 } from "drizzle-orm";
13696
+ import { and as and7, count as count6, desc as desc6, eq as eq7, sql as sql3 } from "drizzle-orm";
13559
13697
  var init_credentialReferences = __esm({
13560
13698
  "../packages/agents-core/src/data-access/credentialReferences.ts"() {
13561
13699
  "use strict";
@@ -13565,8 +13703,8 @@ var init_credentialReferences = __esm({
13565
13703
  });
13566
13704
 
13567
13705
  // ../packages/agents-core/src/data-access/tools.ts
13568
- import { and as and7, count as count6, desc as desc6, eq as eq7 } from "drizzle-orm";
13569
- var logger6;
13706
+ import { and as and8, count as count7, desc as desc7, eq as eq8 } from "drizzle-orm";
13707
+ var logger7;
13570
13708
  var init_tools = __esm({
13571
13709
  "../packages/agents-core/src/data-access/tools.ts"() {
13572
13710
  "use strict";
@@ -13578,30 +13716,31 @@ var init_tools = __esm({
13578
13716
  init_utils();
13579
13717
  init_logger();
13580
13718
  init_mcp_client();
13581
- init_agentRelations();
13582
13719
  init_credentialReferences();
13583
- logger6 = getLogger("tools");
13720
+ init_subAgentRelations();
13721
+ logger7 = getLogger("tools");
13584
13722
  }
13585
13723
  });
13586
13724
 
13587
13725
  // ../packages/agents-core/src/data-access/agentGraphs.ts
13588
- import { and as and8, count as count7, desc as desc7, eq as eq8, inArray as inArray2 } from "drizzle-orm";
13726
+ import { and as and9, count as count8, desc as desc8, eq as eq9, inArray as inArray2 } from "drizzle-orm";
13589
13727
  var init_agentGraphs = __esm({
13590
13728
  "../packages/agents-core/src/data-access/agentGraphs.ts"() {
13591
13729
  "use strict";
13592
13730
  init_esm_shims();
13593
13731
  init_schema();
13594
- init_agentRelations();
13595
- init_agents();
13596
13732
  init_contextConfigs();
13597
13733
  init_externalAgents();
13598
13734
  init_functions();
13735
+ init_functionTools();
13736
+ init_subAgentRelations();
13737
+ init_subAgents();
13599
13738
  init_tools();
13600
13739
  }
13601
13740
  });
13602
13741
 
13603
13742
  // ../packages/agents-core/src/data-access/apiKeys.ts
13604
- import { and as and9, count as count8, desc as desc8, eq as eq9 } from "drizzle-orm";
13743
+ import { and as and10, count as count9, desc as desc9, eq as eq10 } from "drizzle-orm";
13605
13744
  var init_apiKeys2 = __esm({
13606
13745
  "../packages/agents-core/src/data-access/apiKeys.ts"() {
13607
13746
  "use strict";
@@ -14615,10 +14754,10 @@ var require_codegen = __commonJS({
14615
14754
  }
14616
14755
  exports.not = not2;
14617
14756
  var andCode = mappend(exports.operators.AND);
14618
- function and19(...args) {
14757
+ function and20(...args) {
14619
14758
  return args.reduce(andCode);
14620
14759
  }
14621
- exports.and = and19;
14760
+ exports.and = and20;
14622
14761
  var orCode = mappend(exports.operators.OR);
14623
14762
  function or(...args) {
14624
14763
  return args.reduce(orCode);
@@ -15779,20 +15918,20 @@ var require_resolve2 = __commonJS({
15779
15918
  return false;
15780
15919
  }
15781
15920
  function countKeys(schema) {
15782
- let count15 = 0;
15921
+ let count16 = 0;
15783
15922
  for (const key in schema) {
15784
15923
  if (key === "$ref")
15785
15924
  return Infinity;
15786
- count15++;
15925
+ count16++;
15787
15926
  if (SIMPLE_INLINED.has(key))
15788
15927
  continue;
15789
15928
  if (typeof schema[key] == "object") {
15790
- (0, util_1.eachItem)(schema[key], (sch) => count15 += countKeys(sch));
15929
+ (0, util_1.eachItem)(schema[key], (sch) => count16 += countKeys(sch));
15791
15930
  }
15792
- if (count15 === Infinity)
15931
+ if (count16 === Infinity)
15793
15932
  return Infinity;
15794
15933
  }
15795
- return count15;
15934
+ return count16;
15796
15935
  }
15797
15936
  function getFullPath(resolver, id = "", normalize) {
15798
15937
  if (normalize !== false)
@@ -17936,13 +18075,13 @@ var require_core = __commonJS({
17936
18075
  }, warn() {
17937
18076
  }, error() {
17938
18077
  } };
17939
- function getLogger2(logger14) {
17940
- if (logger14 === false)
18078
+ function getLogger2(logger15) {
18079
+ if (logger15 === false)
17941
18080
  return noLogs;
17942
- if (logger14 === void 0)
18081
+ if (logger15 === void 0)
17943
18082
  return console;
17944
- if (logger14.log && logger14.warn && logger14.error)
17945
- return logger14;
18083
+ if (logger15.log && logger15.warn && logger15.error)
18084
+ return logger15;
17946
18085
  throw new Error("logger must implement log, warn and error methods");
17947
18086
  }
17948
18087
  var KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i;
@@ -18898,8 +19037,8 @@ var require_contains2 = __commonJS({
18898
19037
  cxt.result(valid, () => cxt.reset());
18899
19038
  function validateItemsWithCount() {
18900
19039
  const schValid = gen.name("_valid");
18901
- const count15 = gen.let("count", 0);
18902
- validateItems(schValid, () => gen.if(schValid, () => checkLimits(count15)));
19040
+ const count16 = gen.let("count", 0);
19041
+ validateItems(schValid, () => gen.if(schValid, () => checkLimits(count16)));
18903
19042
  }
18904
19043
  function validateItems(_valid, block) {
18905
19044
  gen.forRange("i", 0, len, (i2) => {
@@ -18912,16 +19051,16 @@ var require_contains2 = __commonJS({
18912
19051
  block();
18913
19052
  });
18914
19053
  }
18915
- function checkLimits(count15) {
18916
- gen.code((0, codegen_1._)`${count15}++`);
19054
+ function checkLimits(count16) {
19055
+ gen.code((0, codegen_1._)`${count16}++`);
18917
19056
  if (max === void 0) {
18918
- gen.if((0, codegen_1._)`${count15} >= ${min}`, () => gen.assign(valid, true).break());
19057
+ gen.if((0, codegen_1._)`${count16} >= ${min}`, () => gen.assign(valid, true).break());
18919
19058
  } else {
18920
- gen.if((0, codegen_1._)`${count15} > ${max}`, () => gen.assign(valid, false).break());
19059
+ gen.if((0, codegen_1._)`${count16} > ${max}`, () => gen.assign(valid, false).break());
18921
19060
  if (min === 1)
18922
19061
  gen.assign(valid, true);
18923
19062
  else
18924
- gen.if((0, codegen_1._)`${count15} >= ${min}`, () => gen.assign(valid, true));
19063
+ gen.if((0, codegen_1._)`${count16} >= ${min}`, () => gen.assign(valid, true));
18925
19064
  }
18926
19065
  }
18927
19066
  }
@@ -20095,7 +20234,7 @@ var init_props_validation = __esm({
20095
20234
  });
20096
20235
 
20097
20236
  // ../packages/agents-core/src/data-access/artifactComponents.ts
20098
- import { and as and10, count as count9, desc as desc9, eq as eq10 } from "drizzle-orm";
20237
+ import { and as and11, count as count10, desc as desc10, eq as eq11 } from "drizzle-orm";
20099
20238
  var init_artifactComponents = __esm({
20100
20239
  "../packages/agents-core/src/data-access/artifactComponents.ts"() {
20101
20240
  "use strict";
@@ -20106,7 +20245,7 @@ var init_artifactComponents = __esm({
20106
20245
  });
20107
20246
 
20108
20247
  // ../packages/agents-core/src/data-access/contextCache.ts
20109
- import { and as and11, eq as eq11 } from "drizzle-orm";
20248
+ import { and as and12, eq as eq12 } from "drizzle-orm";
20110
20249
  var init_contextCache = __esm({
20111
20250
  "../packages/agents-core/src/data-access/contextCache.ts"() {
20112
20251
  "use strict";
@@ -20116,7 +20255,7 @@ var init_contextCache = __esm({
20116
20255
  });
20117
20256
 
20118
20257
  // ../packages/agents-core/src/data-access/conversations.ts
20119
- import { and as and12, count as count10, desc as desc10, eq as eq12 } from "drizzle-orm";
20258
+ import { and as and13, count as count11, desc as desc11, eq as eq13 } from "drizzle-orm";
20120
20259
  var init_conversations2 = __esm({
20121
20260
  "../packages/agents-core/src/data-access/conversations.ts"() {
20122
20261
  "use strict";
@@ -20127,7 +20266,7 @@ var init_conversations2 = __esm({
20127
20266
  });
20128
20267
 
20129
20268
  // ../packages/agents-core/src/data-access/dataComponents.ts
20130
- import { and as and13, count as count11, desc as desc11, eq as eq13 } from "drizzle-orm";
20269
+ import { and as and14, count as count12, desc as desc12, eq as eq14 } from "drizzle-orm";
20131
20270
  var init_dataComponents = __esm({
20132
20271
  "../packages/agents-core/src/data-access/dataComponents.ts"() {
20133
20272
  "use strict";
@@ -20147,7 +20286,7 @@ var init_graphFull = __esm({
20147
20286
  });
20148
20287
 
20149
20288
  // ../packages/agents-core/src/data-access/graphFull.ts
20150
- import { and as and14, eq as eq14, inArray as inArray3, not } from "drizzle-orm";
20289
+ import { and as and15, eq as eq15, inArray as inArray3, not } from "drizzle-orm";
20151
20290
  var init_graphFull2 = __esm({
20152
20291
  "../packages/agents-core/src/data-access/graphFull.ts"() {
20153
20292
  "use strict";
@@ -20155,18 +20294,20 @@ var init_graphFull2 = __esm({
20155
20294
  init_schema();
20156
20295
  init_graphFull();
20157
20296
  init_agentGraphs();
20158
- init_agentRelations();
20159
- init_agents();
20160
20297
  init_artifactComponents();
20161
20298
  init_contextConfigs();
20162
20299
  init_dataComponents();
20163
20300
  init_externalAgents();
20301
+ init_functions();
20302
+ init_functionTools();
20303
+ init_subAgentRelations();
20304
+ init_subAgents();
20164
20305
  init_tools();
20165
20306
  }
20166
20307
  });
20167
20308
 
20168
20309
  // ../packages/agents-core/src/data-access/ledgerArtifacts.ts
20169
- import { and as and15, count as count12, eq as eq15 } from "drizzle-orm";
20310
+ import { and as and16, count as count13, eq as eq16 } from "drizzle-orm";
20170
20311
  var init_ledgerArtifacts = __esm({
20171
20312
  "../packages/agents-core/src/data-access/ledgerArtifacts.ts"() {
20172
20313
  "use strict";
@@ -20176,7 +20317,7 @@ var init_ledgerArtifacts = __esm({
20176
20317
  });
20177
20318
 
20178
20319
  // ../packages/agents-core/src/data-access/messages.ts
20179
- import { and as and16, asc as asc2, count as count13, desc as desc12, eq as eq16, inArray as inArray4 } from "drizzle-orm";
20320
+ import { and as and17, asc as asc2, count as count14, desc as desc13, eq as eq17, inArray as inArray4 } from "drizzle-orm";
20180
20321
  var init_messages = __esm({
20181
20322
  "../packages/agents-core/src/data-access/messages.ts"() {
20182
20323
  "use strict";
@@ -20186,7 +20327,7 @@ var init_messages = __esm({
20186
20327
  });
20187
20328
 
20188
20329
  // ../packages/agents-core/src/data-access/projects.ts
20189
- import { and as and17, count as count14, desc as desc13, eq as eq17 } from "drizzle-orm";
20330
+ import { and as and18, count as count15, desc as desc14, eq as eq18 } from "drizzle-orm";
20190
20331
  var init_projects = __esm({
20191
20332
  "../packages/agents-core/src/data-access/projects.ts"() {
20192
20333
  "use strict";
@@ -20215,7 +20356,7 @@ var init_projectFull = __esm({
20215
20356
  });
20216
20357
 
20217
20358
  // ../packages/agents-core/src/data-access/tasks.ts
20218
- import { and as and18, eq as eq18 } from "drizzle-orm";
20359
+ import { and as and19, eq as eq19 } from "drizzle-orm";
20219
20360
  var init_tasks = __esm({
20220
20361
  "../packages/agents-core/src/data-access/tasks.ts"() {
20221
20362
  "use strict";
@@ -20240,8 +20381,6 @@ var init_data_access = __esm({
20240
20381
  init_esm_shims();
20241
20382
  init_client();
20242
20383
  init_agentGraphs();
20243
- init_agentRelations();
20244
- init_agents();
20245
20384
  init_apiKeys2();
20246
20385
  init_artifactComponents();
20247
20386
  init_contextCache();
@@ -20251,11 +20390,14 @@ var init_data_access = __esm({
20251
20390
  init_dataComponents();
20252
20391
  init_externalAgents();
20253
20392
  init_functions();
20393
+ init_functionTools();
20254
20394
  init_graphFull2();
20255
20395
  init_ledgerArtifacts();
20256
20396
  init_messages();
20257
20397
  init_projectFull();
20258
20398
  init_projects();
20399
+ init_subAgentRelations();
20400
+ init_subAgents();
20259
20401
  init_tasks();
20260
20402
  init_tools();
20261
20403
  init_validation();
@@ -20275,20 +20417,20 @@ var init_tracer = __esm({
20275
20417
  });
20276
20418
 
20277
20419
  // ../packages/agents-core/src/context/contextCache.ts
20278
- var logger7;
20420
+ var logger8;
20279
20421
  var init_contextCache2 = __esm({
20280
20422
  "../packages/agents-core/src/context/contextCache.ts"() {
20281
20423
  "use strict";
20282
20424
  init_esm_shims();
20283
20425
  init_data_access();
20284
20426
  init_logger();
20285
- logger7 = getLogger("context-cache");
20427
+ logger8 = getLogger("context-cache");
20286
20428
  }
20287
20429
  });
20288
20430
 
20289
20431
  // ../packages/agents-core/src/context/ContextResolver.ts
20290
20432
  import crypto4 from "crypto";
20291
- var logger8;
20433
+ var logger9;
20292
20434
  var init_ContextResolver = __esm({
20293
20435
  "../packages/agents-core/src/context/ContextResolver.ts"() {
20294
20436
  "use strict";
@@ -20297,12 +20439,12 @@ var init_ContextResolver = __esm({
20297
20439
  init_tracer();
20298
20440
  init_ContextFetcher();
20299
20441
  init_contextCache2();
20300
- logger8 = getLogger("context-resolver");
20442
+ logger9 = getLogger("context-resolver");
20301
20443
  }
20302
20444
  });
20303
20445
 
20304
20446
  // ../packages/agents-core/src/middleware/contextValidation.ts
20305
- var import_ajv3, logger9, ajv;
20447
+ var import_ajv3, logger10, ajv;
20306
20448
  var init_contextValidation = __esm({
20307
20449
  "../packages/agents-core/src/middleware/contextValidation.ts"() {
20308
20450
  "use strict";
@@ -20314,7 +20456,7 @@ var init_contextValidation = __esm({
20314
20456
  init_error();
20315
20457
  init_execution();
20316
20458
  init_logger();
20317
- logger9 = getLogger("context-validation");
20459
+ logger10 = getLogger("context-validation");
20318
20460
  ajv = new import_ajv3.default({ allErrors: true, strict: false });
20319
20461
  }
20320
20462
  });
@@ -20329,7 +20471,7 @@ var init_middleware = __esm({
20329
20471
  });
20330
20472
 
20331
20473
  // ../packages/agents-core/src/context/ContextFetcher.ts
20332
- var import_jmespath2, logger10;
20474
+ var import_jmespath2, logger11;
20333
20475
  var init_ContextFetcher = __esm({
20334
20476
  "../packages/agents-core/src/context/ContextFetcher.ts"() {
20335
20477
  "use strict";
@@ -20340,12 +20482,12 @@ var init_ContextFetcher = __esm({
20340
20482
  init_middleware();
20341
20483
  init_logger();
20342
20484
  init_TemplateEngine();
20343
- logger10 = getLogger("context-fetcher");
20485
+ logger11 = getLogger("context-fetcher");
20344
20486
  }
20345
20487
  });
20346
20488
 
20347
20489
  // ../packages/agents-core/src/context/context.ts
20348
- var logger11;
20490
+ var logger12;
20349
20491
  var init_context4 = __esm({
20350
20492
  "../packages/agents-core/src/context/context.ts"() {
20351
20493
  "use strict";
@@ -20354,7 +20496,7 @@ var init_context4 = __esm({
20354
20496
  init_utils();
20355
20497
  init_tracer();
20356
20498
  init_ContextResolver();
20357
- logger11 = getLogger("context");
20499
+ logger12 = getLogger("context");
20358
20500
  }
20359
20501
  });
20360
20502
 
@@ -20447,7 +20589,7 @@ var init_dist6 = __esm({
20447
20589
 
20448
20590
  // ../packages/agents-core/src/credential-stores/nango-store.ts
20449
20591
  import { z as z9 } from "zod";
20450
- var logger12, CredentialKeySchema;
20592
+ var logger13, CredentialKeySchema;
20451
20593
  var init_nango_store = __esm({
20452
20594
  "../packages/agents-core/src/credential-stores/nango-store.ts"() {
20453
20595
  "use strict";
@@ -20455,7 +20597,7 @@ var init_nango_store = __esm({
20455
20597
  init_dist6();
20456
20598
  init_types();
20457
20599
  init_logger();
20458
- logger12 = getLogger("nango-credential-store");
20600
+ logger13 = getLogger("nango-credential-store");
20459
20601
  CredentialKeySchema = z9.object({
20460
20602
  connectionId: z9.string().min(1, "connectionId must be a non-empty string"),
20461
20603
  providerConfigKey: z9.string().min(1, "providerConfigKey must be a non-empty string")
@@ -20625,6 +20767,53 @@ ${error.message}`
20625
20767
  }
20626
20768
  });
20627
20769
 
20770
+ // ../packages/agents-core/src/validation/event-schemas.ts
20771
+ import { z as z11 } from "zod";
20772
+ var TransferDataSchema, DelegationSentDataSchema, DelegationReturnedDataSchema, DataOperationDetailsSchema, DataOperationEventSchema, A2AMessageMetadataSchema;
20773
+ var init_event_schemas = __esm({
20774
+ "../packages/agents-core/src/validation/event-schemas.ts"() {
20775
+ "use strict";
20776
+ init_esm_shims();
20777
+ TransferDataSchema = z11.object({
20778
+ fromSubAgent: z11.string().describe("ID of the sub-agent transferring control"),
20779
+ targetSubAgent: z11.string().describe("ID of the sub-agent receiving control"),
20780
+ reason: z11.string().optional().describe("Reason for the transfer"),
20781
+ context: z11.any().optional().describe("Additional context data")
20782
+ });
20783
+ DelegationSentDataSchema = z11.object({
20784
+ delegationId: z11.string().describe("Unique identifier for this delegation"),
20785
+ fromSubAgent: z11.string().describe("ID of the delegating sub-agent"),
20786
+ targetSubAgent: z11.string().describe("ID of the sub-agent receiving the delegation"),
20787
+ taskDescription: z11.string().describe("Description of the delegated task"),
20788
+ context: z11.any().optional().describe("Additional context data")
20789
+ });
20790
+ DelegationReturnedDataSchema = z11.object({
20791
+ delegationId: z11.string().describe("Unique identifier matching the original delegation"),
20792
+ fromSubAgent: z11.string().describe("ID of the sub-agent that completed the task"),
20793
+ targetSubAgent: z11.string().describe("ID of the sub-agent receiving the result"),
20794
+ result: z11.any().optional().describe("Result data from the delegated task")
20795
+ });
20796
+ DataOperationDetailsSchema = z11.object({
20797
+ timestamp: z11.number().describe("Unix timestamp in milliseconds"),
20798
+ subAgentId: z11.string().describe("ID of the sub-agent that generated this data"),
20799
+ data: z11.any().describe("The actual data payload")
20800
+ });
20801
+ DataOperationEventSchema = z11.object({
20802
+ type: z11.string().describe("Event type identifier"),
20803
+ label: z11.string().describe("Human-readable label for the event"),
20804
+ details: DataOperationDetailsSchema
20805
+ });
20806
+ A2AMessageMetadataSchema = z11.object({
20807
+ fromSubAgentId: z11.string().optional().describe("ID of the sending sub-agent"),
20808
+ toSubAgentId: z11.string().optional().describe("ID of the receiving sub-agent"),
20809
+ fromExternalAgentId: z11.string().optional().describe("ID of the sending external agent"),
20810
+ toExternalAgentId: z11.string().optional().describe("ID of the receiving external agent"),
20811
+ taskId: z11.string().optional().describe("Associated task ID"),
20812
+ a2aTaskId: z11.string().optional().describe("A2A-specific task ID")
20813
+ });
20814
+ }
20815
+ });
20816
+
20628
20817
  // ../packages/agents-core/src/validation/id-validation.ts
20629
20818
  var init_id_validation = __esm({
20630
20819
  "../packages/agents-core/src/validation/id-validation.ts"() {
@@ -20639,6 +20828,7 @@ var init_validation2 = __esm({
20639
20828
  "../packages/agents-core/src/validation/index.ts"() {
20640
20829
  "use strict";
20641
20830
  init_esm_shims();
20831
+ init_event_schemas();
20642
20832
  init_graphFull();
20643
20833
  init_id_validation();
20644
20834
  init_props_validation();
@@ -20652,6 +20842,8 @@ var init_src = __esm({
20652
20842
  "use strict";
20653
20843
  init_esm_shims();
20654
20844
  init_base_client();
20845
+ init_otel_attributes();
20846
+ init_signoz_queries();
20655
20847
  init_context5();
20656
20848
  init_credential_stores();
20657
20849
  init_credential_stuffer();
@@ -20769,7 +20961,7 @@ function findConfigFile(startPath = process.cwd()) {
20769
20961
  return null;
20770
20962
  }
20771
20963
  async function loadConfigFromFile(configPath) {
20772
- logger13.info({ fromPath: configPath }, `Loading config file`);
20964
+ logger14.info({ fromPath: configPath }, `Loading config file`);
20773
20965
  let resolvedPath;
20774
20966
  if (configPath) {
20775
20967
  resolvedPath = resolve2(process.cwd(), configPath);
@@ -20789,7 +20981,7 @@ async function loadConfigFromFile(configPath) {
20789
20981
  throw new Error(`No config exported from ${resolvedPath}`);
20790
20982
  }
20791
20983
  const config = normalizeConfig(rawConfig);
20792
- logger13.info({ config: maskSensitiveConfig(config) }, `Loaded config values`);
20984
+ logger14.info({ config: maskSensitiveConfig(config) }, `Loaded config values`);
20793
20985
  return config;
20794
20986
  } catch (error) {
20795
20987
  console.warn(`Warning: Failed to load config file ${resolvedPath}:`, error);
@@ -20810,9 +21002,9 @@ async function loadConfig(configPath) {
20810
21002
  config[key] = value;
20811
21003
  }
20812
21004
  });
20813
- logger13.info({ mergedConfig: maskSensitiveConfig(config) }, `Config loaded from file`);
21005
+ logger14.info({ mergedConfig: maskSensitiveConfig(config) }, `Config loaded from file`);
20814
21006
  } else {
20815
- logger13.info(
21007
+ logger14.info(
20816
21008
  { config: maskSensitiveConfig(config) },
20817
21009
  `Using default config (no config file found)`
20818
21010
  );
@@ -20864,14 +21056,14 @@ Please add agentsRunApiUrl to your configuration file`
20864
21056
  sources
20865
21057
  };
20866
21058
  }
20867
- var logger13;
21059
+ var logger14;
20868
21060
  var init_config = __esm({
20869
21061
  "src/utils/config.ts"() {
20870
21062
  "use strict";
20871
21063
  init_esm_shims();
20872
21064
  init_src();
20873
21065
  init_tsx_loader();
20874
- logger13 = getLogger("config");
21066
+ logger14 = getLogger("config");
20875
21067
  }
20876
21068
  });
20877
21069
 
@@ -20959,7 +21151,6 @@ var init_api = __esm({
20959
21151
  async pushGraph(graphDefinition) {
20960
21152
  const tenantId = this.checkTenantId();
20961
21153
  const projectId = this.getProjectId();
20962
- graphDefinition.tenantId = tenantId;
20963
21154
  const graphId = graphDefinition.id;
20964
21155
  if (!graphId) {
20965
21156
  throw new Error("Graph must have an id property");
@@ -20968,7 +21159,10 @@ var init_api = __esm({
20968
21159
  `${this.apiUrl}/tenants/${tenantId}/projects/${projectId}/graph/${graphId}`,
20969
21160
  {
20970
21161
  method: "PUT",
20971
- body: JSON.stringify(graphDefinition)
21162
+ body: JSON.stringify({
21163
+ ...graphDefinition,
21164
+ tenantId
21165
+ })
20972
21166
  }
20973
21167
  );
20974
21168
  if (!response.ok) {
@@ -21192,8 +21386,8 @@ async function chatCommandEnhanced(graphIdInput, options) {
21192
21386
  if (graph.description) {
21193
21387
  console.log(chalk9.gray(`Description: ${graph.description}`));
21194
21388
  }
21195
- if (graph.defaultAgentId || graph.default_agent_id) {
21196
- console.log(chalk9.gray(`Default Agent: ${graph.defaultAgentId || graph.default_agent_id}`));
21389
+ if (graph.defaultSubAgentId) {
21390
+ console.log(chalk9.gray(`Default Agent: ${graph.defaultSubAgentId}`));
21197
21391
  }
21198
21392
  } catch (error) {
21199
21393
  spinner.fail("Failed to connect to graph");
@@ -21422,19 +21616,19 @@ init_esm_shims();
21422
21616
  // src/env.ts
21423
21617
  init_esm_shims();
21424
21618
  init_src();
21425
- import { z as z11 } from "zod";
21619
+ import { z as z12 } from "zod";
21426
21620
  loadEnvironmentFiles();
21427
- var envSchema2 = z11.object({
21428
- DEBUG: z11.string().optional(),
21621
+ var envSchema2 = z12.object({
21622
+ DEBUG: z12.string().optional(),
21429
21623
  // Secrets loaded from .env files (relative to where CLI is executed)
21430
- ANTHROPIC_API_KEY: z11.string().optional()
21624
+ ANTHROPIC_API_KEY: z12.string().optional()
21431
21625
  });
21432
21626
  var parseEnv2 = () => {
21433
21627
  try {
21434
21628
  const parsedEnv = envSchema2.parse(process.env);
21435
21629
  return parsedEnv;
21436
21630
  } catch (error) {
21437
- if (error instanceof z11.ZodError) {
21631
+ if (error instanceof z12.ZodError) {
21438
21632
  const missingVars = error.issues.map((issue) => issue.path.join("."));
21439
21633
  throw new Error(
21440
21634
  `\u274C Invalid environment variables: ${missingVars.join(", ")}
@@ -22067,7 +22261,7 @@ async function listGraphsCommand(options) {
22067
22261
  table.push([
22068
22262
  graph.id || "",
22069
22263
  graph.name || graph.id || "",
22070
- graph.defaultAgentId || chalk6.gray("None"),
22264
+ graph.defaultSubAgentId || chalk6.gray("None"),
22071
22265
  createdDate
22072
22266
  ]);
22073
22267
  }
@@ -22149,6 +22343,43 @@ function generatePlaceholder(jsonPath) {
22149
22343
  function shouldReplaceString(value, placeholder) {
22150
22344
  return value.length >= MIN_REPLACEMENT_LENGTH && placeholder.length < value.length;
22151
22345
  }
22346
+ function containsTemplateLiterals(value) {
22347
+ return /\{\{([^}]+)\}\}/.test(value);
22348
+ }
22349
+ function generateMultiPlaceholderString(value, jsonPath, tracker) {
22350
+ const templateLiterals = value.match(/\{\{([^}]+)\}\}/g);
22351
+ if (!templateLiterals) {
22352
+ return value;
22353
+ }
22354
+ const parts = value.split(/\{\{[^}]+\}\}/);
22355
+ let result = "";
22356
+ let partIndex = 0;
22357
+ const tempMappings = [];
22358
+ for (let i2 = 0; i2 < parts.length; i2++) {
22359
+ const part = parts[i2];
22360
+ if (part.length > 0) {
22361
+ const existingPlaceholder = tracker.valueToPlaceholder.get(part);
22362
+ if (existingPlaceholder) {
22363
+ result += existingPlaceholder;
22364
+ } else {
22365
+ const placeholder = generatePlaceholder(`${jsonPath}.part${partIndex}`);
22366
+ tempMappings.push({ placeholder, value: part });
22367
+ result += placeholder;
22368
+ }
22369
+ partIndex++;
22370
+ }
22371
+ if (i2 < templateLiterals.length) {
22372
+ result += templateLiterals[i2];
22373
+ }
22374
+ }
22375
+ if (result.length < value.length) {
22376
+ for (const mapping of tempMappings) {
22377
+ updateTracker(tracker, mapping.placeholder, mapping.value);
22378
+ }
22379
+ return result;
22380
+ }
22381
+ return value;
22382
+ }
22152
22383
  function isJsonSchemaPath(path3) {
22153
22384
  if (path3.endsWith("contextConfig.headersSchema") || path3.endsWith("responseSchema")) {
22154
22385
  return true;
@@ -22161,20 +22392,24 @@ function updateTracker(tracker, placeholder, value) {
22161
22392
  }
22162
22393
  function processObject(obj, tracker, path3 = "") {
22163
22394
  if (typeof obj === "string") {
22164
- const existingPlaceholder = tracker.valueToPlaceholder.get(obj);
22165
- if (existingPlaceholder) {
22166
- return existingPlaceholder;
22167
- }
22168
- const placeholder = generatePlaceholder(path3);
22169
- if (shouldReplaceString(obj, placeholder)) {
22170
- const existingValue = tracker.placeholderToValue.get(placeholder);
22171
- if (existingValue && existingValue !== obj) {
22172
- throw new Error(
22173
- `Placeholder collision detected: placeholder '${placeholder}' already exists with different value. Existing value length: ${existingValue.length}, New value length: ${obj.length}`
22174
- );
22395
+ if (containsTemplateLiterals(obj)) {
22396
+ return generateMultiPlaceholderString(obj, path3, tracker);
22397
+ } else {
22398
+ const existingPlaceholder = tracker.valueToPlaceholder.get(obj);
22399
+ if (existingPlaceholder) {
22400
+ return existingPlaceholder;
22401
+ }
22402
+ const placeholder = generatePlaceholder(path3);
22403
+ if (shouldReplaceString(obj, placeholder)) {
22404
+ const existingValue = tracker.placeholderToValue.get(placeholder);
22405
+ if (existingValue && existingValue !== obj) {
22406
+ throw new Error(
22407
+ `Placeholder collision detected: placeholder '${placeholder}' already exists with different value. Existing value length: ${existingValue.length}, New value length: ${obj.length}`
22408
+ );
22409
+ }
22410
+ updateTracker(tracker, placeholder, obj);
22411
+ return placeholder;
22175
22412
  }
22176
- updateTracker(tracker, placeholder, obj);
22177
- return placeholder;
22178
22413
  }
22179
22414
  return obj;
22180
22415
  }
@@ -22332,7 +22567,7 @@ var PROJECT_JSON_EXAMPLE = `
22332
22567
  "id": "customer-service",
22333
22568
  "name": "customer-service",
22334
22569
  "description": "respond to customer service requests",
22335
- "defaultAgentId": "router",
22570
+ "defaultSubAgentId": "router",
22336
22571
  "agents": {
22337
22572
  "refund-agent": {
22338
22573
  "id": "refund-agent",
@@ -22601,6 +22836,10 @@ REQUIREMENTS:
22601
22836
  - Placeholders contain multi-line content and require template literals
22602
22837
  - This prevents TypeScript syntax errors with newlines and special characters
22603
22838
  - you must import { z } from 'zod' if you are using zod schemas in the graph file.
22839
+ - you must import { headers } from '@inkeep/agents-core' and use it to create the headers schema if you are using headers in a contextConfig.
22840
+ - convert template literals to use the appropriate headers schema or context config toTemplate method. a template literal is a substring that starts with {{ and ends with }}.
22841
+ - if you see a template literal with {{headers.}}, convert it to use the headers schema toTemplate method.
22842
+ - if you see a template literal with {{contextVariableKey.field_name}}, convert it to use the context config toTemplate method.
22604
22843
  6. If you are writing zod schemas make them clean. For example if you see z.union([z.string(), z.null()]) write it as z.string().nullable()
22605
22844
 
22606
22845
  PLACEHOLDER HANDLING EXAMPLES:
@@ -22612,12 +22851,18 @@ prompt: '<{{agents.facts.prompt.abc12345}}>'
22612
22851
 
22613
22852
  FULL EXAMPLE:
22614
22853
  import { agent, agentGraph } from '@inkeep/agents-sdk';
22615
- import { contextConfig, fetchDefinition } from '@inkeep/agents-core';
22854
+ import { contextConfig, fetchDefinition, headers } from '@inkeep/agents-core';
22616
22855
  import { userProfile } from '../data-components/user-profile';
22617
22856
  import { searchTool } from '../tools/search-tool';
22618
22857
  import { weatherTool } from '../tools/weather-tool';
22619
22858
  import { z } from 'zod';
22620
22859
 
22860
+ const supportGraphHeaders = headers({
22861
+ schema: z.object({
22862
+ userId: z.string(),
22863
+ sessionToken: z.string(),
22864
+ }),
22865
+ });
22621
22866
 
22622
22867
  const supportDescriptionFetchDefinition = fetchDefinition({
22623
22868
  id: 'support-description',
@@ -22627,7 +22872,7 @@ const supportDescriptionFetchDefinition = fetchDefinition({
22627
22872
  url: 'https://api.example.com/support-description',
22628
22873
  method: 'GET',
22629
22874
  headers: {
22630
- 'Authorization': 'Bearer {{headers.sessionToken}}',
22875
+ 'Authorization': \`Bearer \${supportGraphHeaders.toTemplate('sessionToken')}\`,
22631
22876
  },
22632
22877
  transform: 'data',
22633
22878
  },
@@ -22638,10 +22883,7 @@ const supportDescriptionFetchDefinition = fetchDefinition({
22638
22883
  });
22639
22884
 
22640
22885
  const supportGraphContext = contextConfig({
22641
- headers: z.object({
22642
- userId: z.string(),
22643
- sessionToken: z.string(),
22644
- }),
22886
+ headers: supportGraphHeaders,
22645
22887
  contextVariables: {
22646
22888
  supportDescription: supportDescriptionDefinition,
22647
22889
  },
@@ -22650,7 +22892,7 @@ const supportGraphContext = contextConfig({
22650
22892
  const routerAgent = agent({
22651
22893
  id: 'router',
22652
22894
  name: 'Router Agent',
22653
- prompt: 'Route requests to appropriate agents',
22895
+ prompt: \`Route requests to appropriate agents using \${supportGraphContext.toTemplate('supportDescription.description')} for the user \${supportGraphHeaders.toTemplate('userId')}\`,
22654
22896
  canTransferTo: () => [qaAgent]
22655
22897
  });
22656
22898
 
@@ -22662,6 +22904,7 @@ const qaAgent = agent({
22662
22904
  Follow these rules:
22663
22905
  - Always be helpful
22664
22906
  - Provide accurate answers
22907
+ - Use the user's name \${supportGraphHeaders.toTemplate('userId')} when applicable
22665
22908
  - Use available tools\`,
22666
22909
  canUse: () => [searchTool, weatherTool],
22667
22910
  selectedTools: {
@@ -22675,7 +22918,7 @@ export const supportGraph = agentGraph({
22675
22918
  id: 'support-graph',
22676
22919
  name: 'Support Graph',
22677
22920
  description: 'Multi-agent support system', // Only include if description has a value
22678
- defaultAgent: routerAgent,
22921
+ defaultSubAgent: routerAgent,
22679
22922
  agents: () => [routerAgent, qaAgent]
22680
22923
  });
22681
22924
 
@@ -23493,7 +23736,7 @@ async function pullProjectCommand(options) {
23493
23736
  for (const usage of usageInfo) {
23494
23737
  usageByType[usage.type] = (usageByType[usage.type] || 0) + 1;
23495
23738
  }
23496
- const usageSummary = Object.entries(usageByType).map(([type, count15]) => `${count15} ${type}${count15 > 1 ? "s" : ""}`).join(", ");
23739
+ const usageSummary = Object.entries(usageByType).map(([type, count16]) => `${count16} ${type}${count16 > 1 ? "s" : ""}`).join(", ");
23497
23740
  console.log(chalk7.gray(` Used by: ${usageSummary}`));
23498
23741
  }
23499
23742
  }
@@ -23804,7 +24047,7 @@ async function pushCommand(options) {
23804
24047
  for (const usage of usageInfo) {
23805
24048
  usageByType[usage.type] = (usageByType[usage.type] || 0) + 1;
23806
24049
  }
23807
- const usageSummary = Object.entries(usageByType).map(([type, count15]) => `${count15} ${type}${count15 > 1 ? "s" : ""}`).join(", ");
24050
+ const usageSummary = Object.entries(usageByType).map(([type, count16]) => `${count16} ${type}${count16 > 1 ? "s" : ""}`).join(", ");
23808
24051
  console.log(chalk8.gray(` Used by: ${usageSummary}`));
23809
24052
  }
23810
24053
  }