@inkeep/agents-sdk 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.
package/dist/index.cjs CHANGED
@@ -212,7 +212,7 @@ var DataComponent = class {
212
212
  "DataComponent constructor initialized"
213
213
  );
214
214
  }
215
- // Set context (tenantId, projectId, and baseURL) from external source (agent, graph, CLI, etc)
215
+ // Set context (tenantId, projectId, and baseURL) from external source (sub-agent, graph, CLI, etc)
216
216
  setContext(tenantId, projectId, baseURL) {
217
217
  this.tenantId = tenantId;
218
218
  this.projectId = projectId;
@@ -455,16 +455,20 @@ function buildToolManifestFromCodeTS(code, projectRoot = process.cwd()) {
455
455
  const warnings = [];
456
456
  const dependencies = {};
457
457
  for (const pkg of deps) {
458
- const v = resolveInstalledVersion(pkg, projectRoot);
459
- if (!v) {
460
- warnings.push(`Could not resolve version for "${pkg}"`);
461
- continue;
462
- }
463
- if ("unresolved" in v) {
464
- warnings.push(`Using range for "${pkg}" -> ${v.range} (no lockfile / not installed)`);
465
- dependencies[pkg] = v.range;
466
- } else {
467
- dependencies[pkg] = v.exact;
458
+ try {
459
+ const v = resolveInstalledVersion(pkg, projectRoot);
460
+ if (!v) {
461
+ warnings.push(`Could not resolve version for "${pkg}"`);
462
+ continue;
463
+ }
464
+ if ("unresolved" in v) {
465
+ warnings.push(`Using range for "${pkg}" -> ${v.range} (no lockfile / not installed)`);
466
+ dependencies[pkg] = v.range;
467
+ } else {
468
+ dependencies[pkg] = v.exact;
469
+ }
470
+ } catch {
471
+ dependencies[pkg] = false;
468
472
  }
469
473
  }
470
474
  return { dependencies, warnings };
@@ -480,7 +484,14 @@ var FunctionTool = class {
480
484
  this.id = generateIdFromName(config.name);
481
485
  if (!config.dependencies) {
482
486
  const executeCode = typeof config.execute === "string" ? config.execute : config.execute.toString();
483
- this.config.dependencies = getFunctionToolDeps(config.name, executeCode);
487
+ const deps = getFunctionToolDeps(config.name, executeCode);
488
+ for (const dep in deps) {
489
+ if (deps[dep] === false) {
490
+ delete deps[dep];
491
+ }
492
+ throw new Error(`Dependency \x1B[1;32m${dep}\x1B[0m used in function tool \x1B[1;32m${config.name}\x1B[0m is neither installed nor in dependencies object.`);
493
+ }
494
+ this.config.dependencies = deps;
484
495
  }
485
496
  logger4.info(
486
497
  {
@@ -717,34 +728,31 @@ function resolveGetter(value) {
717
728
  }
718
729
  return value;
719
730
  }
720
- var Agent = class {
731
+ var SubAgent = class {
721
732
  constructor(config) {
722
733
  __publicField(this, "config");
723
734
  __publicField(this, "type", "internal");
724
735
  __publicField(this, "baseURL");
725
736
  __publicField(this, "tenantId");
726
737
  __publicField(this, "projectId");
727
- __publicField(this, "graphId");
728
738
  __publicField(this, "initialized", false);
729
739
  this.config = { ...config, type: "internal" };
730
740
  this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
731
741
  this.tenantId = "default";
732
742
  this.projectId = "default";
733
- this.graphId = "default";
734
743
  logger6.info(
735
744
  {
736
745
  tenantId: this.tenantId,
737
- agentId: this.config.id,
746
+ subAgentId: this.config.id,
738
747
  agentName: config.name
739
748
  },
740
749
  "Agent constructor initialized"
741
750
  );
742
751
  }
743
- // Set context (tenantId, projectId, graphId, and baseURL) from external source (graph, CLI, etc)
744
- setContext(tenantId, projectId, graphId, baseURL) {
752
+ // Set context (tenantId, projectId, and baseURL) from external source (graph, CLI, etc)
753
+ setContext(tenantId, projectId, baseURL) {
745
754
  this.tenantId = tenantId;
746
755
  this.projectId = projectId;
747
- this.graphId = graphId;
748
756
  if (baseURL) {
749
757
  this.baseURL = baseURL;
750
758
  }
@@ -884,7 +892,7 @@ var Agent = class {
884
892
  await this.saveArtifactComponents();
885
893
  logger6.info(
886
894
  {
887
- agentId: this.getId()
895
+ subAgentId: this.getId()
888
896
  },
889
897
  "Agent initialized successfully"
890
898
  );
@@ -892,7 +900,7 @@ var Agent = class {
892
900
  } catch (error) {
893
901
  logger6.error(
894
902
  {
895
- agentId: this.getId(),
903
+ subAgentId: this.getId(),
896
904
  error: error instanceof Error ? error.message : "Unknown error"
897
905
  },
898
906
  "Failed to initialize agent"
@@ -924,7 +932,7 @@ var Agent = class {
924
932
  if (updateResponse.ok) {
925
933
  logger6.info(
926
934
  {
927
- agentId: this.getId()
935
+ subAgentId: this.getId()
928
936
  },
929
937
  "Agent updated successfully"
930
938
  );
@@ -933,7 +941,7 @@ var Agent = class {
933
941
  if (updateResponse.status === 404) {
934
942
  logger6.info(
935
943
  {
936
- agentId: this.getId()
944
+ subAgentId: this.getId()
937
945
  },
938
946
  "Agent not found, creating new agent"
939
947
  );
@@ -952,7 +960,7 @@ var Agent = class {
952
960
  }
953
961
  logger6.info(
954
962
  {
955
- agentId: this.getId()
963
+ subAgentId: this.getId()
956
964
  },
957
965
  "Agent created successfully"
958
966
  );
@@ -1059,7 +1067,7 @@ var Agent = class {
1059
1067
  this.config.dataComponents = () => uniqueComponents;
1060
1068
  logger6.info(
1061
1069
  {
1062
- agentId: this.getId(),
1070
+ subAgentId: this.getId(),
1063
1071
  dbComponentCount: dbDataComponents.length,
1064
1072
  configComponentCount: configComponents.length,
1065
1073
  totalComponentCount: uniqueComponents.length
@@ -1069,7 +1077,7 @@ var Agent = class {
1069
1077
  } catch (error) {
1070
1078
  logger6.error(
1071
1079
  {
1072
- agentId: this.getId(),
1080
+ subAgentId: this.getId(),
1073
1081
  error: error instanceof Error ? error.message : "Unknown error"
1074
1082
  },
1075
1083
  "Failed to load data components from database"
@@ -1116,7 +1124,7 @@ var Agent = class {
1116
1124
  this.config.artifactComponents = () => uniqueComponents;
1117
1125
  logger6.info(
1118
1126
  {
1119
- agentId: this.getId(),
1127
+ subAgentId: this.getId(),
1120
1128
  dbComponentCount: dbArtifactComponents.length,
1121
1129
  configComponentCount: configComponents.length,
1122
1130
  totalComponentCount: uniqueComponents.length
@@ -1126,7 +1134,7 @@ var Agent = class {
1126
1134
  } catch (error) {
1127
1135
  logger6.error(
1128
1136
  {
1129
- agentId: this.getId(),
1137
+ subAgentId: this.getId(),
1130
1138
  error: error instanceof Error ? error.message : "Unknown error"
1131
1139
  },
1132
1140
  "Failed to load artifact components from database"
@@ -1260,7 +1268,7 @@ var Agent = class {
1260
1268
  if (toolConfig.type === "function") {
1261
1269
  logger6.info(
1262
1270
  {
1263
- agentId: this.getId(),
1271
+ subAgentId: this.getId(),
1264
1272
  toolId
1265
1273
  },
1266
1274
  "Skipping function tool creation - will be handled at runtime"
@@ -1292,7 +1300,7 @@ var Agent = class {
1292
1300
  await this.createAgentToolRelation(tool.getId(), selectedTools, headers);
1293
1301
  logger6.info(
1294
1302
  {
1295
- agentId: this.getId(),
1303
+ subAgentId: this.getId(),
1296
1304
  toolId: tool.getId()
1297
1305
  },
1298
1306
  "Tool created and linked to agent"
@@ -1300,7 +1308,7 @@ var Agent = class {
1300
1308
  } catch (error) {
1301
1309
  logger6.error(
1302
1310
  {
1303
- agentId: this.getId(),
1311
+ subAgentId: this.getId(),
1304
1312
  toolId,
1305
1313
  error: error instanceof Error ? error.message : "Unknown error"
1306
1314
  },
@@ -1322,7 +1330,7 @@ var Agent = class {
1322
1330
  await this.createAgentDataComponentRelation(dc.getId());
1323
1331
  logger6.info(
1324
1332
  {
1325
- agentId: this.getId(),
1333
+ subAgentId: this.getId(),
1326
1334
  dataComponentId: dc.getId()
1327
1335
  },
1328
1336
  "DataComponent created and linked to agent"
@@ -1330,7 +1338,7 @@ var Agent = class {
1330
1338
  } catch (error) {
1331
1339
  logger6.error(
1332
1340
  {
1333
- agentId: this.getId(),
1341
+ subAgentId: this.getId(),
1334
1342
  dataComponentName: dataComponent2.name,
1335
1343
  error: error instanceof Error ? error.message : "Unknown error"
1336
1344
  },
@@ -1352,7 +1360,7 @@ var Agent = class {
1352
1360
  await this.createAgentArtifactComponentRelation(ac.getId());
1353
1361
  logger6.info(
1354
1362
  {
1355
- agentId: this.getId(),
1363
+ subAgentId: this.getId(),
1356
1364
  artifactComponentId: ac.getId()
1357
1365
  },
1358
1366
  "ArtifactComponent created and linked to agent"
@@ -1360,7 +1368,7 @@ var Agent = class {
1360
1368
  } catch (error) {
1361
1369
  logger6.error(
1362
1370
  {
1363
- agentId: this.getId(),
1371
+ subAgentId: this.getId(),
1364
1372
  artifactComponentName: artifactComponent2.name,
1365
1373
  error: error instanceof Error ? error.message : "Unknown error"
1366
1374
  },
@@ -1380,7 +1388,7 @@ var Agent = class {
1380
1388
  body: JSON.stringify({
1381
1389
  id: `${this.getId()}-dc-${dataComponentId}`,
1382
1390
  tenantId: this.tenantId,
1383
- agentId: this.getId(),
1391
+ subAgentId: this.getId(),
1384
1392
  dataComponentId
1385
1393
  })
1386
1394
  }
@@ -1392,7 +1400,7 @@ var Agent = class {
1392
1400
  }
1393
1401
  logger6.info(
1394
1402
  {
1395
- agentId: this.getId(),
1403
+ subAgentId: this.getId(),
1396
1404
  dataComponentId
1397
1405
  },
1398
1406
  "Created agent-dataComponent relation"
@@ -1409,7 +1417,7 @@ var Agent = class {
1409
1417
  body: JSON.stringify({
1410
1418
  id: crypto.randomUUID(),
1411
1419
  tenantId: this.tenantId,
1412
- agentId: this.getId(),
1420
+ subAgentId: this.getId(),
1413
1421
  artifactComponentId
1414
1422
  })
1415
1423
  }
@@ -1421,7 +1429,7 @@ var Agent = class {
1421
1429
  }
1422
1430
  logger6.info(
1423
1431
  {
1424
- agentId: this.getId(),
1432
+ subAgentId: this.getId(),
1425
1433
  artifactComponentId
1426
1434
  },
1427
1435
  "Created agent-artifactComponent relation"
@@ -1432,7 +1440,7 @@ var Agent = class {
1432
1440
  id: `${this.getId()}-tool-${toolId}`,
1433
1441
  tenantId: this.tenantId,
1434
1442
  projectId: this.projectId,
1435
- agentId: this.getId(),
1443
+ subAgentId: this.getId(),
1436
1444
  toolId
1437
1445
  };
1438
1446
  if (selectedTools !== void 0) {
@@ -1520,9 +1528,9 @@ function resolveGetter2(value) {
1520
1528
  }
1521
1529
  var AgentGraph = class {
1522
1530
  constructor(config) {
1523
- __publicField(this, "agents", []);
1531
+ __publicField(this, "subAgents", []);
1524
1532
  __publicField(this, "agentMap", /* @__PURE__ */ new Map());
1525
- __publicField(this, "defaultAgent");
1533
+ __publicField(this, "defaultSubAgent");
1526
1534
  __publicField(this, "baseURL");
1527
1535
  __publicField(this, "tenantId");
1528
1536
  __publicField(this, "projectId");
@@ -1538,7 +1546,7 @@ var AgentGraph = class {
1538
1546
  __publicField(this, "graphPrompt");
1539
1547
  __publicField(this, "stopWhen");
1540
1548
  __publicField(this, "dbClient");
1541
- this.defaultAgent = config.defaultAgent;
1549
+ this.defaultSubAgent = config.defaultSubAgent;
1542
1550
  this.tenantId = "default";
1543
1551
  this.projectId = "default";
1544
1552
  this.graphId = config.id;
@@ -1557,11 +1565,11 @@ var AgentGraph = class {
1557
1565
  this.stopWhen = config.stopWhen ? {
1558
1566
  transferCountIs: config.stopWhen.transferCountIs
1559
1567
  } : void 0;
1560
- this.agents = resolveGetter2(config.agents) || [];
1561
- this.agentMap = new Map(this.agents.map((agent2) => [agent2.getId(), agent2]));
1562
- if (this.defaultAgent) {
1563
- this.agents.push(this.defaultAgent);
1564
- this.agentMap.set(this.defaultAgent.getId(), this.defaultAgent);
1568
+ this.subAgents = resolveGetter2(config.subAgents) || [];
1569
+ this.agentMap = new Map(this.subAgents.map((agent) => [agent.getId(), agent]));
1570
+ if (this.defaultSubAgent) {
1571
+ this.subAgents.push(this.defaultSubAgent);
1572
+ this.agentMap.set(this.defaultSubAgent.getId(), this.defaultSubAgent);
1565
1573
  }
1566
1574
  if (this.models) {
1567
1575
  this.propagateImmediateModelSettings();
@@ -1570,8 +1578,8 @@ var AgentGraph = class {
1570
1578
  {
1571
1579
  graphId: this.graphId,
1572
1580
  tenantId: this.tenantId,
1573
- agentCount: this.agents.length,
1574
- defaultAgent: this.defaultAgent?.getName()
1581
+ agentCount: this.subAgents.length,
1582
+ defaultSubAgent: this.defaultSubAgent?.getName()
1575
1583
  },
1576
1584
  "AgentGraph created"
1577
1585
  );
@@ -1587,9 +1595,9 @@ var AgentGraph = class {
1587
1595
  this.tenantId = tenantId;
1588
1596
  this.projectId = projectId;
1589
1597
  this.baseURL = apiUrl;
1590
- for (const agent2 of this.agents) {
1591
- if (this.isInternalAgent(agent2)) {
1592
- const internalAgent = agent2;
1598
+ for (const agent of this.subAgents) {
1599
+ if (this.isInternalAgent(agent)) {
1600
+ const internalAgent = agent;
1593
1601
  if (internalAgent.setContext) {
1594
1602
  internalAgent.setContext(tenantId, projectId, apiUrl);
1595
1603
  }
@@ -1602,7 +1610,7 @@ var AgentGraph = class {
1602
1610
  }
1603
1611
  }
1604
1612
  } else {
1605
- const externalAgent2 = agent2;
1613
+ const externalAgent2 = agent;
1606
1614
  if (externalAgent2.setContext) {
1607
1615
  externalAgent2.setContext(tenantId, apiUrl);
1608
1616
  }
@@ -1626,9 +1634,11 @@ var AgentGraph = class {
1626
1634
  */
1627
1635
  async toFullGraphDefinition() {
1628
1636
  const agentsObject = {};
1629
- for (const agent2 of this.agents) {
1630
- if (this.isInternalAgent(agent2)) {
1631
- const internalAgent = agent2;
1637
+ const functionToolsObject = {};
1638
+ const functionsObject = {};
1639
+ for (const agent of this.subAgents) {
1640
+ if (this.isInternalAgent(agent)) {
1641
+ const internalAgent = agent;
1632
1642
  const transfers = internalAgent.getTransfers();
1633
1643
  const delegates = internalAgent.getDelegates();
1634
1644
  const tools = [];
@@ -1644,19 +1654,36 @@ var AgentGraph = class {
1644
1654
  headersMapping[toolId] = toolInstance.headers;
1645
1655
  }
1646
1656
  tools.push(toolId);
1657
+ if (toolInstance.constructor.name === "FunctionTool" && toolInstance instanceof FunctionTool) {
1658
+ if (!functionsObject[toolId]) {
1659
+ const functionData = toolInstance.serializeFunction();
1660
+ functionsObject[toolId] = functionData;
1661
+ }
1662
+ if (!functionToolsObject[toolId]) {
1663
+ const toolData = toolInstance.serializeTool();
1664
+ functionToolsObject[toolId] = {
1665
+ id: toolData.id,
1666
+ name: toolData.name,
1667
+ description: toolData.description,
1668
+ functionId: toolData.functionId,
1669
+ graphId: this.graphId
1670
+ // Include graphId for graph-scoped function tools
1671
+ };
1672
+ }
1673
+ }
1647
1674
  }
1648
1675
  const dataComponents = [];
1649
- const agentDataComponents = internalAgent.getDataComponents();
1650
- if (agentDataComponents) {
1651
- for (const dataComponent2 of agentDataComponents) {
1676
+ const subAgentDataComponents = internalAgent.getDataComponents();
1677
+ if (subAgentDataComponents) {
1678
+ for (const dataComponent2 of subAgentDataComponents) {
1652
1679
  const dataComponentId = dataComponent2.id || dataComponent2.name.toLowerCase().replace(/\s+/g, "-");
1653
1680
  dataComponents.push(dataComponentId);
1654
1681
  }
1655
1682
  }
1656
1683
  const artifactComponents = [];
1657
- const agentArtifactComponents = internalAgent.getArtifactComponents();
1658
- if (agentArtifactComponents) {
1659
- for (const artifactComponent2 of agentArtifactComponents) {
1684
+ const subAgentArtifactComponents = internalAgent.getArtifactComponents();
1685
+ if (subAgentArtifactComponents) {
1686
+ for (const artifactComponent2 of subAgentArtifactComponents) {
1660
1687
  const artifactComponentId = artifactComponent2.id || artifactComponent2.name.toLowerCase().replace(/\s+/g, "-");
1661
1688
  artifactComponents.push(artifactComponentId);
1662
1689
  }
@@ -1681,7 +1708,7 @@ var AgentGraph = class {
1681
1708
  type: "internal"
1682
1709
  };
1683
1710
  } else {
1684
- const externalAgent2 = agent2;
1711
+ const externalAgent2 = agent;
1685
1712
  agentsObject[externalAgent2.getId()] = {
1686
1713
  id: externalAgent2.getId(),
1687
1714
  name: externalAgent2.getName(),
@@ -1697,9 +1724,11 @@ var AgentGraph = class {
1697
1724
  id: this.graphId,
1698
1725
  name: this.graphName,
1699
1726
  description: this.graphDescription,
1700
- defaultAgentId: this.defaultAgent?.getId() || "",
1701
- agents: agentsObject,
1727
+ defaultSubAgentId: this.defaultSubAgent?.getId() || "",
1728
+ subAgents: agentsObject,
1702
1729
  contextConfig: this.contextConfig?.toObject(),
1730
+ ...Object.keys(functionToolsObject).length > 0 && { functionTools: functionToolsObject },
1731
+ ...Object.keys(functionsObject).length > 0 && { functions: functionsObject },
1703
1732
  models: this.models,
1704
1733
  statusUpdates: this.statusUpdateSettings,
1705
1734
  graphPrompt: this.graphPrompt,
@@ -1713,11 +1742,11 @@ var AgentGraph = class {
1713
1742
  async initializeAllTools() {
1714
1743
  logger8.info({ graphId: this.graphId }, "Initializing all tools in graph");
1715
1744
  const toolInitPromises = [];
1716
- for (const agent2 of this.agents) {
1717
- if (!agent2.getTools) {
1745
+ for (const agent of this.subAgents) {
1746
+ if (!agent.getTools) {
1718
1747
  continue;
1719
1748
  }
1720
- const internalAgent = agent2;
1749
+ const internalAgent = agent;
1721
1750
  const agentTools = internalAgent.getTools();
1722
1751
  for (const [toolName, toolInstance] of Object.entries(agentTools)) {
1723
1752
  if (toolInstance && typeof toolInstance === "object") {
@@ -1737,7 +1766,7 @@ var AgentGraph = class {
1737
1766
  }
1738
1767
  logger8.debug(
1739
1768
  {
1740
- agentId: agent2.getId(),
1769
+ subAgentId: agent.getId(),
1741
1770
  toolName,
1742
1771
  toolType: toolInstance.constructor.name,
1743
1772
  skipDbRegistration
@@ -1747,7 +1776,7 @@ var AgentGraph = class {
1747
1776
  } catch (error) {
1748
1777
  logger8.error(
1749
1778
  {
1750
- agentId: agent2.getId(),
1779
+ subAgentId: agent.getId(),
1751
1780
  toolName,
1752
1781
  error: error instanceof Error ? error.message : "Unknown error"
1753
1782
  },
@@ -1778,7 +1807,7 @@ var AgentGraph = class {
1778
1807
  logger8.info(
1779
1808
  {
1780
1809
  graphId: this.graphId,
1781
- agentCount: this.agents.length
1810
+ agentCount: this.subAgents.length
1782
1811
  },
1783
1812
  "Initializing agent graph using new graph endpoint"
1784
1813
  );
@@ -1832,7 +1861,7 @@ var AgentGraph = class {
1832
1861
  logger8.info(
1833
1862
  {
1834
1863
  graphId: this.graphId,
1835
- agentCount: this.agents.length
1864
+ agentCount: this.subAgents.length
1836
1865
  },
1837
1866
  "Initializing agent graph"
1838
1867
  );
@@ -1847,13 +1876,13 @@ var AgentGraph = class {
1847
1876
  "Context configuration initialized for graph"
1848
1877
  );
1849
1878
  }
1850
- const initPromises = this.agents.map(async (agent2) => {
1879
+ const initPromises = this.subAgents.map(async (agent) => {
1851
1880
  try {
1852
- agent2.config.graphId = this.graphId;
1853
- await agent2.init();
1881
+ agent.config.graphId = this.graphId;
1882
+ await agent.init();
1854
1883
  logger8.debug(
1855
1884
  {
1856
- agentId: agent2.getId(),
1885
+ subAgentId: agent.getId(),
1857
1886
  graphId: this.graphId
1858
1887
  },
1859
1888
  "Agent initialized in graph"
@@ -1861,7 +1890,7 @@ var AgentGraph = class {
1861
1890
  } catch (error) {
1862
1891
  logger8.error(
1863
1892
  {
1864
- agentId: agent2.getId(),
1893
+ subAgentId: agent.getId(),
1865
1894
  graphId: this.graphId,
1866
1895
  error: error instanceof Error ? error.message : "Unknown error"
1867
1896
  },
@@ -1879,7 +1908,7 @@ var AgentGraph = class {
1879
1908
  logger8.info(
1880
1909
  {
1881
1910
  graphId: this.graphId,
1882
- agentCount: this.agents.length
1911
+ agentCount: this.subAgents.length
1883
1912
  },
1884
1913
  "Agent graph initialized successfully"
1885
1914
  );
@@ -1899,13 +1928,13 @@ var AgentGraph = class {
1899
1928
  */
1900
1929
  async generate(input, options) {
1901
1930
  await this._init();
1902
- if (!this.defaultAgent) {
1931
+ if (!this.defaultSubAgent) {
1903
1932
  throw new Error("No default agent configured for this graph");
1904
1933
  }
1905
1934
  logger8.info(
1906
1935
  {
1907
1936
  graphId: this.graphId,
1908
- defaultAgent: this.defaultAgent.getName(),
1937
+ defaultSubAgent: this.defaultSubAgent.getName(),
1909
1938
  conversationId: options?.conversationId
1910
1939
  },
1911
1940
  "Generating response with default agent"
@@ -1918,13 +1947,13 @@ var AgentGraph = class {
1918
1947
  */
1919
1948
  async stream(input, options) {
1920
1949
  await this._init();
1921
- if (!this.defaultAgent) {
1950
+ if (!this.defaultSubAgent) {
1922
1951
  throw new Error("No default agent configured for this graph");
1923
1952
  }
1924
1953
  logger8.info(
1925
1954
  {
1926
1955
  graphId: this.graphId,
1927
- defaultAgent: this.defaultAgent.getName(),
1956
+ defaultSubAgent: this.defaultSubAgent.getName(),
1928
1957
  conversationId: options?.conversationId
1929
1958
  },
1930
1959
  "Streaming response with default agent"
@@ -1949,21 +1978,21 @@ var AgentGraph = class {
1949
1978
  /**
1950
1979
  * Run with a specific agent from the graph
1951
1980
  */
1952
- async runWith(agentId, input, options) {
1981
+ async runWith(subAgentId, input, options) {
1953
1982
  await this._init();
1954
- const agent2 = this.getAgent(agentId);
1955
- if (!agent2) {
1956
- throw new Error(`Agent '${agentId}' not found in graph`);
1983
+ const agent = this.getAgent(subAgentId);
1984
+ if (!agent) {
1985
+ throw new Error(`Agent '${subAgentId}' not found in graph`);
1957
1986
  }
1958
- if (!this.isInternalAgent(agent2)) {
1987
+ if (!this.isInternalAgent(agent)) {
1959
1988
  throw new Error(
1960
- `Agent '${agentId}' is an external agent and cannot be run directly. External agents are only accessible via delegation.`
1989
+ `Agent '${subAgentId}' is an external agent and cannot be run directly. External agents are only accessible via delegation.`
1961
1990
  );
1962
1991
  }
1963
1992
  logger8.info(
1964
1993
  {
1965
1994
  graphId: this.graphId,
1966
- agentId,
1995
+ subAgentId,
1967
1996
  conversationId: options?.conversationId
1968
1997
  },
1969
1998
  "Running with specific agent"
@@ -1971,7 +2000,7 @@ var AgentGraph = class {
1971
2000
  const response = await this.executeWithBackend(input, options);
1972
2001
  return {
1973
2002
  finalOutput: response,
1974
- agent: agent2,
2003
+ agent,
1975
2004
  turnCount: 1,
1976
2005
  usage: { inputTokens: 0, outputTokens: 0 },
1977
2006
  metadata: {
@@ -1989,17 +2018,17 @@ var AgentGraph = class {
1989
2018
  /**
1990
2019
  * Add an agent to the graph
1991
2020
  */
1992
- addAgent(agent2) {
1993
- this.agents.push(agent2);
1994
- this.agentMap.set(agent2.getId(), agent2);
1995
- if (this.models && this.isInternalAgent(agent2)) {
1996
- this.propagateModelSettingsToAgent(agent2);
2021
+ addSubAgent(agent) {
2022
+ this.subAgents.push(agent);
2023
+ this.agentMap.set(agent.getId(), agent);
2024
+ if (this.models && this.isInternalAgent(agent)) {
2025
+ this.propagateModelSettingsToAgent(agent);
1997
2026
  }
1998
2027
  logger8.info(
1999
2028
  {
2000
2029
  graphId: this.graphId,
2001
- agentId: agent2.getId(),
2002
- agentType: this.isInternalAgent(agent2) ? "internal" : "external"
2030
+ subAgentId: agent.getId(),
2031
+ agentType: this.isInternalAgent(agent) ? "internal" : "external"
2003
2032
  },
2004
2033
  "Agent added to graph"
2005
2034
  );
@@ -2007,15 +2036,15 @@ var AgentGraph = class {
2007
2036
  /**
2008
2037
  * Remove an agent from the graph
2009
2038
  */
2010
- removeAgent(id) {
2039
+ removeSubAgent(id) {
2011
2040
  const agentToRemove = this.agentMap.get(id);
2012
2041
  if (agentToRemove) {
2013
2042
  this.agentMap.delete(agentToRemove.getId());
2014
- this.agents = this.agents.filter((agent2) => agent2.getId() !== agentToRemove.getId());
2043
+ this.subAgents = this.subAgents.filter((agent) => agent.getId() !== agentToRemove.getId());
2015
2044
  logger8.info(
2016
2045
  {
2017
2046
  graphId: this.graphId,
2018
- agentId: agentToRemove.getId()
2047
+ subAgentId: agentToRemove.getId()
2019
2048
  },
2020
2049
  "Agent removed from graph"
2021
2050
  );
@@ -2026,25 +2055,25 @@ var AgentGraph = class {
2026
2055
  /**
2027
2056
  * Get all agents in the graph
2028
2057
  */
2029
- getAgents() {
2030
- return this.agents;
2058
+ getSubAgents() {
2059
+ return this.subAgents;
2031
2060
  }
2032
2061
  /**
2033
2062
  * Get all agent ids (unified method for all agent types)
2034
2063
  */
2035
- getAgentIds() {
2064
+ getSubAgentIds() {
2036
2065
  return Array.from(this.agentMap.keys());
2037
2066
  }
2038
2067
  /**
2039
2068
  * Set the default agent
2040
2069
  */
2041
- setDefaultAgent(agent2) {
2042
- this.defaultAgent = agent2;
2043
- this.addAgent(agent2);
2070
+ setdefaultSubAgent(agent) {
2071
+ this.defaultSubAgent = agent;
2072
+ this.addSubAgent(agent);
2044
2073
  logger8.info(
2045
2074
  {
2046
2075
  graphId: this.graphId,
2047
- defaultAgent: agent2.getId()
2076
+ defaultSubAgent: agent.getId()
2048
2077
  },
2049
2078
  "Default agent updated"
2050
2079
  );
@@ -2052,8 +2081,8 @@ var AgentGraph = class {
2052
2081
  /**
2053
2082
  * Get the default agent
2054
2083
  */
2055
- getDefaultAgent() {
2056
- return this.defaultAgent;
2084
+ getdefaultSubAgent() {
2085
+ return this.defaultSubAgent;
2057
2086
  }
2058
2087
  /**
2059
2088
  * Get the graph ID
@@ -2111,8 +2140,8 @@ var AgentGraph = class {
2111
2140
  */
2112
2141
  getStats() {
2113
2142
  return {
2114
- agentCount: this.agents.length,
2115
- defaultAgent: this.defaultAgent?.getName() || null,
2143
+ agentCount: this.subAgents.length,
2144
+ defaultSubAgent: this.defaultSubAgent?.getName() || null,
2116
2145
  initialized: this.initialized,
2117
2146
  graphId: this.graphId,
2118
2147
  tenantId: this.tenantId
@@ -2123,35 +2152,35 @@ var AgentGraph = class {
2123
2152
  */
2124
2153
  validate() {
2125
2154
  const errors = [];
2126
- if (this.agents.length === 0) {
2155
+ if (this.subAgents.length === 0) {
2127
2156
  errors.push("Graph must contain at least one agent");
2128
2157
  }
2129
- if (!this.defaultAgent) {
2158
+ if (!this.defaultSubAgent) {
2130
2159
  errors.push("Graph must have a default agent");
2131
2160
  }
2132
2161
  const names = /* @__PURE__ */ new Set();
2133
- for (const agent2 of this.agents) {
2134
- const name = agent2.getName();
2162
+ for (const agent of this.subAgents) {
2163
+ const name = agent.getName();
2135
2164
  if (names.has(name)) {
2136
2165
  errors.push(`Duplicate agent name: ${name}`);
2137
2166
  }
2138
2167
  names.add(name);
2139
2168
  }
2140
- for (const agent2 of this.agents) {
2141
- if (!this.isInternalAgent(agent2)) continue;
2142
- const transfers = agent2.getTransfers();
2169
+ for (const agent of this.subAgents) {
2170
+ if (!this.isInternalAgent(agent)) continue;
2171
+ const transfers = agent.getTransfers();
2143
2172
  for (const transferAgent of transfers) {
2144
2173
  if (!this.agentMap.has(transferAgent.getName())) {
2145
2174
  errors.push(
2146
- `Agent '${agent2.getName()}' has transfer to '${transferAgent.getName()}' which is not in the graph`
2175
+ `Agent '${agent.getName()}' has transfer to '${transferAgent.getName()}' which is not in the graph`
2147
2176
  );
2148
2177
  }
2149
2178
  }
2150
- const delegates = agent2.getDelegates();
2179
+ const delegates = agent.getDelegates();
2151
2180
  for (const delegateAgent of delegates) {
2152
2181
  if (!this.agentMap.has(delegateAgent.getName())) {
2153
2182
  errors.push(
2154
- `Agent '${agent2.getName()}' has delegation to '${delegateAgent.getName()}' which is not in the graph`
2183
+ `Agent '${agent.getName()}' has delegation to '${delegateAgent.getName()}' which is not in the graph`
2155
2184
  );
2156
2185
  }
2157
2186
  }
@@ -2170,8 +2199,8 @@ var AgentGraph = class {
2170
2199
  /**
2171
2200
  * Type guard to check if an agent is an internal AgentInterface
2172
2201
  */
2173
- isInternalAgent(agent2) {
2174
- return "getTransfers" in agent2 && typeof agent2.getTransfers === "function";
2202
+ isInternalAgent(agent) {
2203
+ return "getTransfers" in agent && typeof agent.getTransfers === "function";
2175
2204
  }
2176
2205
  /**
2177
2206
  * Get project-level model settingsuration defaults
@@ -2235,9 +2264,9 @@ var AgentGraph = class {
2235
2264
  }
2236
2265
  }
2237
2266
  await this.applyStopWhenInheritance();
2238
- for (const agent2 of this.agents) {
2239
- if (this.isInternalAgent(agent2)) {
2240
- this.propagateModelSettingsToAgent(agent2);
2267
+ for (const agent of this.subAgents) {
2268
+ if (this.isInternalAgent(agent)) {
2269
+ this.propagateModelSettingsToAgent(agent);
2241
2270
  }
2242
2271
  }
2243
2272
  }
@@ -2256,9 +2285,9 @@ var AgentGraph = class {
2256
2285
  this.stopWhen.transferCountIs = 10;
2257
2286
  }
2258
2287
  if (projectStopWhen?.stepCountIs !== void 0) {
2259
- for (const agent2 of this.agents) {
2260
- if (this.isInternalAgent(agent2)) {
2261
- const internalAgent = agent2;
2288
+ for (const agent of this.subAgents) {
2289
+ if (this.isInternalAgent(agent)) {
2290
+ const internalAgent = agent;
2262
2291
  if (!internalAgent.config.stopWhen) {
2263
2292
  internalAgent.config.stopWhen = {};
2264
2293
  }
@@ -2280,19 +2309,19 @@ var AgentGraph = class {
2280
2309
  /**
2281
2310
  * Propagate graph-level model settings to agents (supporting partial inheritance)
2282
2311
  */
2283
- propagateModelSettingsToAgent(agent2) {
2312
+ propagateModelSettingsToAgent(agent) {
2284
2313
  if (this.models) {
2285
- if (!agent2.config.models) {
2286
- agent2.config.models = {};
2314
+ if (!agent.config.models) {
2315
+ agent.config.models = {};
2287
2316
  }
2288
- if (!agent2.config.models.base && this.models.base) {
2289
- agent2.config.models.base = this.models.base;
2317
+ if (!agent.config.models.base && this.models.base) {
2318
+ agent.config.models.base = this.models.base;
2290
2319
  }
2291
- if (!agent2.config.models.structuredOutput && this.models.structuredOutput) {
2292
- agent2.config.models.structuredOutput = this.models.structuredOutput;
2320
+ if (!agent.config.models.structuredOutput && this.models.structuredOutput) {
2321
+ agent.config.models.structuredOutput = this.models.structuredOutput;
2293
2322
  }
2294
- if (!agent2.config.models.summarizer && this.models.summarizer) {
2295
- agent2.config.models.summarizer = this.models.summarizer;
2323
+ if (!agent.config.models.summarizer && this.models.summarizer) {
2324
+ agent.config.models.summarizer = this.models.summarizer;
2296
2325
  }
2297
2326
  }
2298
2327
  }
@@ -2300,17 +2329,17 @@ var AgentGraph = class {
2300
2329
  * Immediately propagate graph-level models to all agents during construction
2301
2330
  */
2302
2331
  propagateImmediateModelSettings() {
2303
- for (const agent2 of this.agents) {
2304
- if (this.isInternalAgent(agent2)) {
2305
- this.propagateModelSettingsToAgent(agent2);
2332
+ for (const agent of this.subAgents) {
2333
+ if (this.isInternalAgent(agent)) {
2334
+ this.propagateModelSettingsToAgent(agent);
2306
2335
  }
2307
2336
  }
2308
2337
  }
2309
2338
  /**
2310
2339
  * Type guard to check if an agent is an external AgentInterface
2311
2340
  */
2312
- isExternalAgent(agent2) {
2313
- return !this.isInternalAgent(agent2);
2341
+ isExternalAgent(agent) {
2342
+ return !this.isInternalAgent(agent);
2314
2343
  }
2315
2344
  /**
2316
2345
  * Execute agent using the backend system instead of local runner
@@ -2423,7 +2452,7 @@ var AgentGraph = class {
2423
2452
  body: JSON.stringify({
2424
2453
  id: this.graphId,
2425
2454
  name: this.graphName,
2426
- defaultAgentId: this.defaultAgent?.getId() || "",
2455
+ defaultSubAgentId: this.defaultSubAgent?.getId() || "",
2427
2456
  contextConfigId: this.contextConfig?.getId(),
2428
2457
  models: this.models
2429
2458
  })
@@ -2441,7 +2470,7 @@ var AgentGraph = class {
2441
2470
  }
2442
2471
  }
2443
2472
  async saveRelations() {
2444
- if (this.defaultAgent) {
2473
+ if (this.defaultSubAgent) {
2445
2474
  try {
2446
2475
  const updateUrl = `${this.baseURL}/tenants/${this.tenantId}/agent-graphs/${this.graphId}`;
2447
2476
  const updateResponse = await fetch(updateUrl, {
@@ -2451,7 +2480,7 @@ var AgentGraph = class {
2451
2480
  },
2452
2481
  body: JSON.stringify({
2453
2482
  id: this.graphId,
2454
- defaultAgentId: this.defaultAgent.getId(),
2483
+ defaultSubAgentId: this.defaultSubAgent.getId(),
2455
2484
  contextConfigId: this.contextConfig?.getId()
2456
2485
  })
2457
2486
  });
@@ -2461,7 +2490,7 @@ var AgentGraph = class {
2461
2490
  logger8.debug(
2462
2491
  {
2463
2492
  graphId: this.graphId,
2464
- defaultAgent: this.defaultAgent.getName()
2493
+ defaultSubAgent: this.defaultSubAgent.getName()
2465
2494
  },
2466
2495
  "Graph relationships configured"
2467
2496
  );
@@ -2479,21 +2508,21 @@ var AgentGraph = class {
2479
2508
  }
2480
2509
  async createAgentRelations() {
2481
2510
  const allRelationPromises = [];
2482
- for (const agent2 of this.agents) {
2483
- if (this.isInternalAgent(agent2)) {
2484
- const transfers = agent2.getTransfers();
2511
+ for (const agent of this.subAgents) {
2512
+ if (this.isInternalAgent(agent)) {
2513
+ const transfers = agent.getTransfers();
2485
2514
  for (const transferAgent of transfers) {
2486
2515
  allRelationPromises.push(
2487
- this.createInternalAgentRelation(agent2, transferAgent, "transfer")
2516
+ this.createInternalAgentRelation(agent, transferAgent, "transfer")
2488
2517
  );
2489
2518
  }
2490
- const delegates = agent2.getDelegates();
2519
+ const delegates = agent.getDelegates();
2491
2520
  for (const delegate of delegates) {
2492
2521
  if (delegate.type === "external") {
2493
- allRelationPromises.push(this.createExternalAgentRelation(agent2, delegate, "delegate"));
2522
+ allRelationPromises.push(this.createExternalAgentRelation(agent, delegate, "delegate"));
2494
2523
  } else {
2495
2524
  allRelationPromises.push(
2496
- this.createInternalAgentRelation(agent2, delegate, "delegate")
2525
+ this.createInternalAgentRelation(agent, delegate, "delegate")
2497
2526
  );
2498
2527
  }
2499
2528
  }
@@ -2538,8 +2567,8 @@ var AgentGraph = class {
2538
2567
  },
2539
2568
  body: JSON.stringify({
2540
2569
  graphId: this.graphId,
2541
- sourceAgentId: sourceAgent.getId(),
2542
- targetAgentId: targetAgent.getId(),
2570
+ sourceSubAgentId: sourceAgent.getId(),
2571
+ targetSubAgentId: targetAgent.getId(),
2543
2572
  relationType
2544
2573
  })
2545
2574
  });
@@ -2548,8 +2577,8 @@ var AgentGraph = class {
2548
2577
  if (response.status === 422 && errorText.includes("already exists")) {
2549
2578
  logger8.info(
2550
2579
  {
2551
- sourceAgentId: sourceAgent.getId(),
2552
- targetAgentId: targetAgent.getId(),
2580
+ sourceSubAgentId: sourceAgent.getId(),
2581
+ targetSubAgentId: targetAgent.getId(),
2553
2582
  graphId: this.graphId,
2554
2583
  relationType
2555
2584
  },
@@ -2561,8 +2590,8 @@ var AgentGraph = class {
2561
2590
  }
2562
2591
  logger8.info(
2563
2592
  {
2564
- sourceAgentId: sourceAgent.getId(),
2565
- targetAgentId: targetAgent.getId(),
2593
+ sourceSubAgentId: sourceAgent.getId(),
2594
+ targetSubAgentId: targetAgent.getId(),
2566
2595
  graphId: this.graphId,
2567
2596
  relationType
2568
2597
  },
@@ -2571,8 +2600,8 @@ var AgentGraph = class {
2571
2600
  } catch (error) {
2572
2601
  logger8.error(
2573
2602
  {
2574
- sourceAgentId: sourceAgent.getId(),
2575
- targetAgentId: targetAgent.getId(),
2603
+ sourceSubAgentId: sourceAgent.getId(),
2604
+ targetSubAgentId: targetAgent.getId(),
2576
2605
  graphId: this.graphId,
2577
2606
  relationType,
2578
2607
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2591,8 +2620,8 @@ var AgentGraph = class {
2591
2620
  },
2592
2621
  body: JSON.stringify({
2593
2622
  graphId: this.graphId,
2594
- sourceAgentId: sourceAgent.getId(),
2595
- externalAgentId: externalAgent2.getId(),
2623
+ sourceSubAgentId: sourceAgent.getId(),
2624
+ externalSubAgentId: externalAgent2.getId(),
2596
2625
  relationType
2597
2626
  })
2598
2627
  });
@@ -2601,8 +2630,8 @@ var AgentGraph = class {
2601
2630
  if (response.status === 422 && errorText.includes("already exists")) {
2602
2631
  logger8.info(
2603
2632
  {
2604
- sourceAgentId: sourceAgent.getId(),
2605
- externalAgentId: externalAgent2.getId(),
2633
+ sourceSubAgentId: sourceAgent.getId(),
2634
+ externalSubAgentId: externalAgent2.getId(),
2606
2635
  graphId: this.graphId,
2607
2636
  relationType
2608
2637
  },
@@ -2616,8 +2645,8 @@ var AgentGraph = class {
2616
2645
  }
2617
2646
  logger8.info(
2618
2647
  {
2619
- sourceAgentId: sourceAgent.getId(),
2620
- externalAgentId: externalAgent2.getId(),
2648
+ sourceSubAgentId: sourceAgent.getId(),
2649
+ externalSubAgentId: externalAgent2.getId(),
2621
2650
  graphId: this.graphId,
2622
2651
  relationType
2623
2652
  },
@@ -2626,8 +2655,8 @@ var AgentGraph = class {
2626
2655
  } catch (error) {
2627
2656
  logger8.error(
2628
2657
  {
2629
- sourceAgentId: sourceAgent.getId(),
2630
- externalAgentId: externalAgent2.getId(),
2658
+ sourceSubAgentId: sourceAgent.getId(),
2659
+ externalSubAgentId: externalAgent2.getId(),
2631
2660
  graphId: this.graphId,
2632
2661
  relationType,
2633
2662
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2641,7 +2670,7 @@ var AgentGraph = class {
2641
2670
  * Create external agents in the database
2642
2671
  */
2643
2672
  async createExternalAgents() {
2644
- const externalAgents2 = this.agents.filter((agent2) => this.isExternalAgent(agent2));
2673
+ const externalAgents2 = this.subAgents.filter((agent) => this.isExternalAgent(agent));
2645
2674
  logger8.info(
2646
2675
  {
2647
2676
  graphId: this.graphId,
@@ -2654,7 +2683,7 @@ var AgentGraph = class {
2654
2683
  await externalAgent2.init();
2655
2684
  logger8.debug(
2656
2685
  {
2657
- externalAgentId: externalAgent2.getId(),
2686
+ externalSubAgentId: externalAgent2.getId(),
2658
2687
  graphId: this.graphId
2659
2688
  },
2660
2689
  "External agent created in database"
@@ -2662,7 +2691,7 @@ var AgentGraph = class {
2662
2691
  } catch (error) {
2663
2692
  logger8.error(
2664
2693
  {
2665
- externalAgentId: externalAgent2.getId(),
2694
+ externalSubAgentId: externalAgent2.getId(),
2666
2695
  graphId: this.graphId,
2667
2696
  error: error instanceof Error ? error.message : "Unknown error"
2668
2697
  },
@@ -3234,6 +3263,7 @@ var Project = class {
3234
3263
  async toFullProjectDefinition() {
3235
3264
  const graphsObject = {};
3236
3265
  const toolsObject = {};
3266
+ const functionToolsObject = {};
3237
3267
  const functionsObject = {};
3238
3268
  const dataComponentsObject = {};
3239
3269
  const artifactComponentsObject = {};
@@ -3313,11 +3343,11 @@ var Project = class {
3313
3343
  }
3314
3344
  }
3315
3345
  }
3316
- for (const agent2 of graph.getAgents()) {
3317
- if (agent2.type === "external") {
3346
+ for (const agent of graph.getSubAgents()) {
3347
+ if (agent.type === "external") {
3318
3348
  continue;
3319
3349
  }
3320
- const agentTools = agent2.getTools();
3350
+ const agentTools = agent.getTools();
3321
3351
  for (const [, toolInstance] of Object.entries(agentTools)) {
3322
3352
  const actualTool = toolInstance;
3323
3353
  const toolId = actualTool.getId();
@@ -3326,18 +3356,13 @@ var Project = class {
3326
3356
  const functionData = actualTool.serializeFunction();
3327
3357
  functionsObject[toolId] = functionData;
3328
3358
  }
3329
- if (!toolsObject[toolId]) {
3359
+ if (!functionToolsObject[toolId]) {
3330
3360
  const toolData = actualTool.serializeTool();
3331
- const toolConfig = {
3332
- type: "function"
3333
- // No inline function details - they're in the functions table via functionId
3334
- };
3335
- toolsObject[toolId] = {
3361
+ functionToolsObject[toolId] = {
3336
3362
  id: toolData.id,
3337
3363
  name: toolData.name,
3338
3364
  description: toolData.description,
3339
- functionId: toolData.functionId,
3340
- config: toolConfig
3365
+ functionId: toolData.functionId
3341
3366
  };
3342
3367
  }
3343
3368
  } else {
@@ -3376,9 +3401,9 @@ var Project = class {
3376
3401
  }
3377
3402
  }
3378
3403
  }
3379
- const agentDataComponents = agent2.getDataComponents?.();
3380
- if (agentDataComponents) {
3381
- for (const dataComponent2 of agentDataComponents) {
3404
+ const subAgentDataComponents = agent.getDataComponents?.();
3405
+ if (subAgentDataComponents) {
3406
+ for (const dataComponent2 of subAgentDataComponents) {
3382
3407
  let dataComponentId;
3383
3408
  let dataComponentName;
3384
3409
  let dataComponentDescription;
@@ -3404,9 +3429,9 @@ var Project = class {
3404
3429
  }
3405
3430
  }
3406
3431
  }
3407
- const agentArtifactComponents = agent2.getArtifactComponents?.();
3408
- if (agentArtifactComponents) {
3409
- for (const artifactComponent2 of agentArtifactComponents) {
3432
+ const subAgentArtifactComponents = agent.getArtifactComponents?.();
3433
+ if (subAgentArtifactComponents) {
3434
+ for (const artifactComponent2 of subAgentArtifactComponents) {
3410
3435
  let artifactComponentId;
3411
3436
  let artifactComponentName;
3412
3437
  let artifactComponentDescription;
@@ -3534,13 +3559,13 @@ function agentGraph(config) {
3534
3559
  function project(config) {
3535
3560
  return new Project(config);
3536
3561
  }
3537
- function agent(config) {
3562
+ function subAgent(config) {
3538
3563
  if (!config.id) {
3539
3564
  throw new Error(
3540
- "Agent ID is required. Agents must have stable IDs for consistency across deployments."
3565
+ "Sub-Agent ID is required. Sub-Agents must have stable IDs for consistency across deployments."
3541
3566
  );
3542
3567
  }
3543
- return new Agent(config);
3568
+ return new SubAgent(config);
3544
3569
  }
3545
3570
  function credential(config) {
3546
3571
  return agentsCore.CredentialReferenceApiInsertSchema.parse(config);
@@ -3595,17 +3620,6 @@ function functionTool(config) {
3595
3620
  return new FunctionTool(config);
3596
3621
  }
3597
3622
 
3598
- // src/credential-ref.ts
3599
- function credentialRef(id) {
3600
- return {
3601
- __type: "credential-ref",
3602
- id
3603
- };
3604
- }
3605
- function isCredentialReference(value) {
3606
- return value && typeof value === "object" && value.__type === "credential-ref";
3607
- }
3608
-
3609
3623
  // src/utils/validateFunction.ts
3610
3624
  function validateFunction(value, name) {
3611
3625
  if (typeof value !== "function") {
@@ -3615,7 +3629,7 @@ function validateFunction(value, name) {
3615
3629
 
3616
3630
  // src/builders.ts
3617
3631
  var TransferConfigSchema = zod.z.object({
3618
- agent: zod.z.instanceof(Agent),
3632
+ agent: zod.z.instanceof(SubAgent),
3619
3633
  description: zod.z.string().optional()
3620
3634
  });
3621
3635
  function transfer(targetAgent, description, condition) {
@@ -3634,6 +3648,17 @@ function transfer(targetAgent, description, condition) {
3634
3648
  return config;
3635
3649
  }
3636
3650
 
3651
+ // src/credential-ref.ts
3652
+ function credentialRef(id) {
3653
+ return {
3654
+ __type: "credential-ref",
3655
+ id
3656
+ };
3657
+ }
3658
+ function isCredentialReference(value) {
3659
+ return value && typeof value === "object" && value.__type === "credential-ref";
3660
+ }
3661
+
3637
3662
  // src/environment-settings.ts
3638
3663
  function createEnvironmentSettings(environments) {
3639
3664
  return {
@@ -3685,7 +3710,7 @@ var ExternalAgent = class {
3685
3710
  await this.upsertExternalAgent();
3686
3711
  logger11.info(
3687
3712
  {
3688
- externalAgentId: this.getId()
3713
+ externalSubAgentId: this.getId()
3689
3714
  },
3690
3715
  "External agent initialized successfully"
3691
3716
  );
@@ -3693,7 +3718,7 @@ var ExternalAgent = class {
3693
3718
  } catch (error) {
3694
3719
  logger11.error(
3695
3720
  {
3696
- externalAgentId: this.getId(),
3721
+ externalSubAgentId: this.getId(),
3697
3722
  error: error instanceof Error ? error.message : "Unknown error"
3698
3723
  },
3699
3724
  "Failed to initialize external agent"
@@ -3735,7 +3760,7 @@ var ExternalAgent = class {
3735
3760
  if (updateResponse.ok) {
3736
3761
  logger11.info(
3737
3762
  {
3738
- externalAgentId: this.getId()
3763
+ externalSubAgentId: this.getId()
3739
3764
  },
3740
3765
  "External agent updated successfully"
3741
3766
  );
@@ -3744,7 +3769,7 @@ var ExternalAgent = class {
3744
3769
  if (updateResponse.status === 404) {
3745
3770
  logger11.info(
3746
3771
  {
3747
- externalAgentId: this.getId()
3772
+ externalSubAgentId: this.getId()
3748
3773
  },
3749
3774
  "External agent not found, creating new external agent"
3750
3775
  );
@@ -3766,7 +3791,7 @@ var ExternalAgent = class {
3766
3791
  }
3767
3792
  logger11.info(
3768
3793
  {
3769
- externalAgentId: this.getId()
3794
+ externalSubAgentId: this.getId()
3770
3795
  },
3771
3796
  "External agent created successfully"
3772
3797
  );
@@ -3854,7 +3879,7 @@ var Runner = class _Runner {
3854
3879
  logger12.info(
3855
3880
  {
3856
3881
  graphId: graph.getId(),
3857
- defaultAgent: graph.getDefaultAgent()?.getName(),
3882
+ defaultSubAgent: graph.getdefaultSubAgent()?.getName(),
3858
3883
  maxTurns,
3859
3884
  initialMessageCount: messageHistory.length
3860
3885
  },
@@ -3881,7 +3906,7 @@ var Runner = class _Runner {
3881
3906
  );
3882
3907
  return {
3883
3908
  finalOutput: response,
3884
- agent: graph.getDefaultAgent() || {},
3909
+ agent: graph.getdefaultSubAgent() || {},
3885
3910
  turnCount,
3886
3911
  usage: { inputTokens: 0, outputTokens: 0 },
3887
3912
  metadata: {
@@ -3908,7 +3933,7 @@ var Runner = class _Runner {
3908
3933
  logger12.info(
3909
3934
  {
3910
3935
  graphId: graph.getId(),
3911
- defaultAgent: graph.getDefaultAgent()?.getName()
3936
+ defaultSubAgent: graph.getdefaultSubAgent()?.getName()
3912
3937
  },
3913
3938
  "Starting graph stream"
3914
3939
  );
@@ -3973,23 +3998,23 @@ var Runner = class _Runner {
3973
3998
  if (!graph.getId()) {
3974
3999
  errors.push("Graph ID is required");
3975
4000
  }
3976
- const defaultAgent = graph.getDefaultAgent();
3977
- if (!defaultAgent) {
4001
+ const defaultSubAgent = graph.getdefaultSubAgent();
4002
+ if (!defaultSubAgent) {
3978
4003
  errors.push("Default agent is required");
3979
4004
  } else {
3980
- if (!defaultAgent.getName()) {
4005
+ if (!defaultSubAgent.getName()) {
3981
4006
  errors.push("Default agent name is required");
3982
4007
  }
3983
- if (!defaultAgent.getInstructions()) {
4008
+ if (!defaultSubAgent.getInstructions()) {
3984
4009
  errors.push("Default agent instructions are required");
3985
4010
  }
3986
4011
  }
3987
- const agents = graph.getAgents();
4012
+ const agents = graph.getSubAgents();
3988
4013
  if (agents.length === 0) {
3989
4014
  errors.push("Graph must contain at least one agent");
3990
4015
  }
3991
- for (const agent2 of agents) {
3992
- if (!agent2.getName()) {
4016
+ for (const agent of agents) {
4017
+ if (!agent.getName()) {
3993
4018
  errors.push(`Agent missing name`);
3994
4019
  }
3995
4020
  }
@@ -4002,15 +4027,15 @@ var Runner = class _Runner {
4002
4027
  * Get execution statistics for a graph
4003
4028
  */
4004
4029
  static async getExecutionStats(graph, messages, options) {
4005
- const agents = graph.getAgents();
4006
- const defaultAgent = graph.getDefaultAgent();
4030
+ const agents = graph.getSubAgents();
4031
+ const defaultSubAgent = graph.getdefaultSubAgent();
4007
4032
  const messageCount = Array.isArray(messages) ? messages.length : 1;
4008
4033
  return {
4009
4034
  estimatedTurns: Math.min(Math.max(messageCount, 1), options?.maxTurns || 10),
4010
4035
  estimatedTokens: messageCount * 100,
4011
4036
  // Rough estimate
4012
4037
  agentCount: agents.length,
4013
- defaultAgent: defaultAgent?.getName()
4038
+ defaultSubAgent: defaultSubAgent?.getName()
4014
4039
  };
4015
4040
  }
4016
4041
  };
@@ -4018,7 +4043,7 @@ var run = Runner.run.bind(Runner);
4018
4043
  var stream = Runner.stream.bind(Runner);
4019
4044
  var raceGraphs = Runner.raceGraphs.bind(Runner);
4020
4045
 
4021
- exports.Agent = Agent;
4046
+ exports.Agent = SubAgent;
4022
4047
  exports.ArtifactComponent = ArtifactComponent;
4023
4048
  exports.DataComponent = DataComponent;
4024
4049
  exports.ExternalAgent = ExternalAgent;
@@ -4026,7 +4051,7 @@ exports.FunctionTool = FunctionTool;
4026
4051
  exports.Project = Project;
4027
4052
  exports.Runner = Runner;
4028
4053
  exports.Tool = Tool;
4029
- exports.agent = agent;
4054
+ exports.agent = subAgent;
4030
4055
  exports.agentGraph = agentGraph;
4031
4056
  exports.agentMcp = agentMcp;
4032
4057
  exports.artifactComponent = artifactComponent;