@inkeep/agents-sdk 0.17.0 → 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.js CHANGED
@@ -184,7 +184,7 @@ var DataComponent = class {
184
184
  "DataComponent constructor initialized"
185
185
  );
186
186
  }
187
- // Set context (tenantId, projectId, and baseURL) from external source (agent, graph, CLI, etc)
187
+ // Set context (tenantId, projectId, and baseURL) from external source (sub-agent, graph, CLI, etc)
188
188
  setContext(tenantId, projectId, baseURL) {
189
189
  this.tenantId = tenantId;
190
190
  this.projectId = projectId;
@@ -427,16 +427,20 @@ function buildToolManifestFromCodeTS(code, projectRoot = process.cwd()) {
427
427
  const warnings = [];
428
428
  const dependencies = {};
429
429
  for (const pkg of deps) {
430
- const v = resolveInstalledVersion(pkg, projectRoot);
431
- if (!v) {
432
- warnings.push(`Could not resolve version for "${pkg}"`);
433
- continue;
434
- }
435
- if ("unresolved" in v) {
436
- warnings.push(`Using range for "${pkg}" -> ${v.range} (no lockfile / not installed)`);
437
- dependencies[pkg] = v.range;
438
- } else {
439
- dependencies[pkg] = v.exact;
430
+ try {
431
+ const v = resolveInstalledVersion(pkg, projectRoot);
432
+ if (!v) {
433
+ warnings.push(`Could not resolve version for "${pkg}"`);
434
+ continue;
435
+ }
436
+ if ("unresolved" in v) {
437
+ warnings.push(`Using range for "${pkg}" -> ${v.range} (no lockfile / not installed)`);
438
+ dependencies[pkg] = v.range;
439
+ } else {
440
+ dependencies[pkg] = v.exact;
441
+ }
442
+ } catch {
443
+ dependencies[pkg] = false;
440
444
  }
441
445
  }
442
446
  return { dependencies, warnings };
@@ -452,7 +456,14 @@ var FunctionTool = class {
452
456
  this.id = generateIdFromName(config.name);
453
457
  if (!config.dependencies) {
454
458
  const executeCode = typeof config.execute === "string" ? config.execute : config.execute.toString();
455
- this.config.dependencies = getFunctionToolDeps(config.name, executeCode);
459
+ const deps = getFunctionToolDeps(config.name, executeCode);
460
+ for (const dep in deps) {
461
+ if (deps[dep] === false) {
462
+ delete deps[dep];
463
+ }
464
+ 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.`);
465
+ }
466
+ this.config.dependencies = deps;
456
467
  }
457
468
  logger4.info(
458
469
  {
@@ -689,34 +700,31 @@ function resolveGetter(value) {
689
700
  }
690
701
  return value;
691
702
  }
692
- var Agent = class {
703
+ var SubAgent = class {
693
704
  constructor(config) {
694
705
  __publicField(this, "config");
695
706
  __publicField(this, "type", "internal");
696
707
  __publicField(this, "baseURL");
697
708
  __publicField(this, "tenantId");
698
709
  __publicField(this, "projectId");
699
- __publicField(this, "graphId");
700
710
  __publicField(this, "initialized", false);
701
711
  this.config = { ...config, type: "internal" };
702
712
  this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
703
713
  this.tenantId = "default";
704
714
  this.projectId = "default";
705
- this.graphId = "default";
706
715
  logger6.info(
707
716
  {
708
717
  tenantId: this.tenantId,
709
- agentId: this.config.id,
718
+ subAgentId: this.config.id,
710
719
  agentName: config.name
711
720
  },
712
721
  "Agent constructor initialized"
713
722
  );
714
723
  }
715
- // Set context (tenantId, projectId, graphId, and baseURL) from external source (graph, CLI, etc)
716
- setContext(tenantId, projectId, graphId, baseURL) {
724
+ // Set context (tenantId, projectId, and baseURL) from external source (graph, CLI, etc)
725
+ setContext(tenantId, projectId, baseURL) {
717
726
  this.tenantId = tenantId;
718
727
  this.projectId = projectId;
719
- this.graphId = graphId;
720
728
  if (baseURL) {
721
729
  this.baseURL = baseURL;
722
730
  }
@@ -856,7 +864,7 @@ var Agent = class {
856
864
  await this.saveArtifactComponents();
857
865
  logger6.info(
858
866
  {
859
- agentId: this.getId()
867
+ subAgentId: this.getId()
860
868
  },
861
869
  "Agent initialized successfully"
862
870
  );
@@ -864,7 +872,7 @@ var Agent = class {
864
872
  } catch (error) {
865
873
  logger6.error(
866
874
  {
867
- agentId: this.getId(),
875
+ subAgentId: this.getId(),
868
876
  error: error instanceof Error ? error.message : "Unknown error"
869
877
  },
870
878
  "Failed to initialize agent"
@@ -896,7 +904,7 @@ var Agent = class {
896
904
  if (updateResponse.ok) {
897
905
  logger6.info(
898
906
  {
899
- agentId: this.getId()
907
+ subAgentId: this.getId()
900
908
  },
901
909
  "Agent updated successfully"
902
910
  );
@@ -905,7 +913,7 @@ var Agent = class {
905
913
  if (updateResponse.status === 404) {
906
914
  logger6.info(
907
915
  {
908
- agentId: this.getId()
916
+ subAgentId: this.getId()
909
917
  },
910
918
  "Agent not found, creating new agent"
911
919
  );
@@ -924,7 +932,7 @@ var Agent = class {
924
932
  }
925
933
  logger6.info(
926
934
  {
927
- agentId: this.getId()
935
+ subAgentId: this.getId()
928
936
  },
929
937
  "Agent created successfully"
930
938
  );
@@ -1031,7 +1039,7 @@ var Agent = class {
1031
1039
  this.config.dataComponents = () => uniqueComponents;
1032
1040
  logger6.info(
1033
1041
  {
1034
- agentId: this.getId(),
1042
+ subAgentId: this.getId(),
1035
1043
  dbComponentCount: dbDataComponents.length,
1036
1044
  configComponentCount: configComponents.length,
1037
1045
  totalComponentCount: uniqueComponents.length
@@ -1041,7 +1049,7 @@ var Agent = class {
1041
1049
  } catch (error) {
1042
1050
  logger6.error(
1043
1051
  {
1044
- agentId: this.getId(),
1052
+ subAgentId: this.getId(),
1045
1053
  error: error instanceof Error ? error.message : "Unknown error"
1046
1054
  },
1047
1055
  "Failed to load data components from database"
@@ -1088,7 +1096,7 @@ var Agent = class {
1088
1096
  this.config.artifactComponents = () => uniqueComponents;
1089
1097
  logger6.info(
1090
1098
  {
1091
- agentId: this.getId(),
1099
+ subAgentId: this.getId(),
1092
1100
  dbComponentCount: dbArtifactComponents.length,
1093
1101
  configComponentCount: configComponents.length,
1094
1102
  totalComponentCount: uniqueComponents.length
@@ -1098,7 +1106,7 @@ var Agent = class {
1098
1106
  } catch (error) {
1099
1107
  logger6.error(
1100
1108
  {
1101
- agentId: this.getId(),
1109
+ subAgentId: this.getId(),
1102
1110
  error: error instanceof Error ? error.message : "Unknown error"
1103
1111
  },
1104
1112
  "Failed to load artifact components from database"
@@ -1232,7 +1240,7 @@ var Agent = class {
1232
1240
  if (toolConfig.type === "function") {
1233
1241
  logger6.info(
1234
1242
  {
1235
- agentId: this.getId(),
1243
+ subAgentId: this.getId(),
1236
1244
  toolId
1237
1245
  },
1238
1246
  "Skipping function tool creation - will be handled at runtime"
@@ -1264,7 +1272,7 @@ var Agent = class {
1264
1272
  await this.createAgentToolRelation(tool.getId(), selectedTools, headers);
1265
1273
  logger6.info(
1266
1274
  {
1267
- agentId: this.getId(),
1275
+ subAgentId: this.getId(),
1268
1276
  toolId: tool.getId()
1269
1277
  },
1270
1278
  "Tool created and linked to agent"
@@ -1272,7 +1280,7 @@ var Agent = class {
1272
1280
  } catch (error) {
1273
1281
  logger6.error(
1274
1282
  {
1275
- agentId: this.getId(),
1283
+ subAgentId: this.getId(),
1276
1284
  toolId,
1277
1285
  error: error instanceof Error ? error.message : "Unknown error"
1278
1286
  },
@@ -1294,7 +1302,7 @@ var Agent = class {
1294
1302
  await this.createAgentDataComponentRelation(dc.getId());
1295
1303
  logger6.info(
1296
1304
  {
1297
- agentId: this.getId(),
1305
+ subAgentId: this.getId(),
1298
1306
  dataComponentId: dc.getId()
1299
1307
  },
1300
1308
  "DataComponent created and linked to agent"
@@ -1302,7 +1310,7 @@ var Agent = class {
1302
1310
  } catch (error) {
1303
1311
  logger6.error(
1304
1312
  {
1305
- agentId: this.getId(),
1313
+ subAgentId: this.getId(),
1306
1314
  dataComponentName: dataComponent2.name,
1307
1315
  error: error instanceof Error ? error.message : "Unknown error"
1308
1316
  },
@@ -1324,7 +1332,7 @@ var Agent = class {
1324
1332
  await this.createAgentArtifactComponentRelation(ac.getId());
1325
1333
  logger6.info(
1326
1334
  {
1327
- agentId: this.getId(),
1335
+ subAgentId: this.getId(),
1328
1336
  artifactComponentId: ac.getId()
1329
1337
  },
1330
1338
  "ArtifactComponent created and linked to agent"
@@ -1332,7 +1340,7 @@ var Agent = class {
1332
1340
  } catch (error) {
1333
1341
  logger6.error(
1334
1342
  {
1335
- agentId: this.getId(),
1343
+ subAgentId: this.getId(),
1336
1344
  artifactComponentName: artifactComponent2.name,
1337
1345
  error: error instanceof Error ? error.message : "Unknown error"
1338
1346
  },
@@ -1352,7 +1360,7 @@ var Agent = class {
1352
1360
  body: JSON.stringify({
1353
1361
  id: `${this.getId()}-dc-${dataComponentId}`,
1354
1362
  tenantId: this.tenantId,
1355
- agentId: this.getId(),
1363
+ subAgentId: this.getId(),
1356
1364
  dataComponentId
1357
1365
  })
1358
1366
  }
@@ -1364,7 +1372,7 @@ var Agent = class {
1364
1372
  }
1365
1373
  logger6.info(
1366
1374
  {
1367
- agentId: this.getId(),
1375
+ subAgentId: this.getId(),
1368
1376
  dataComponentId
1369
1377
  },
1370
1378
  "Created agent-dataComponent relation"
@@ -1381,7 +1389,7 @@ var Agent = class {
1381
1389
  body: JSON.stringify({
1382
1390
  id: crypto.randomUUID(),
1383
1391
  tenantId: this.tenantId,
1384
- agentId: this.getId(),
1392
+ subAgentId: this.getId(),
1385
1393
  artifactComponentId
1386
1394
  })
1387
1395
  }
@@ -1393,7 +1401,7 @@ var Agent = class {
1393
1401
  }
1394
1402
  logger6.info(
1395
1403
  {
1396
- agentId: this.getId(),
1404
+ subAgentId: this.getId(),
1397
1405
  artifactComponentId
1398
1406
  },
1399
1407
  "Created agent-artifactComponent relation"
@@ -1404,7 +1412,7 @@ var Agent = class {
1404
1412
  id: `${this.getId()}-tool-${toolId}`,
1405
1413
  tenantId: this.tenantId,
1406
1414
  projectId: this.projectId,
1407
- agentId: this.getId(),
1415
+ subAgentId: this.getId(),
1408
1416
  toolId
1409
1417
  };
1410
1418
  if (selectedTools !== void 0) {
@@ -1492,9 +1500,9 @@ function resolveGetter2(value) {
1492
1500
  }
1493
1501
  var AgentGraph = class {
1494
1502
  constructor(config) {
1495
- __publicField(this, "agents", []);
1503
+ __publicField(this, "subAgents", []);
1496
1504
  __publicField(this, "agentMap", /* @__PURE__ */ new Map());
1497
- __publicField(this, "defaultAgent");
1505
+ __publicField(this, "defaultSubAgent");
1498
1506
  __publicField(this, "baseURL");
1499
1507
  __publicField(this, "tenantId");
1500
1508
  __publicField(this, "projectId");
@@ -1510,7 +1518,7 @@ var AgentGraph = class {
1510
1518
  __publicField(this, "graphPrompt");
1511
1519
  __publicField(this, "stopWhen");
1512
1520
  __publicField(this, "dbClient");
1513
- this.defaultAgent = config.defaultAgent;
1521
+ this.defaultSubAgent = config.defaultSubAgent;
1514
1522
  this.tenantId = "default";
1515
1523
  this.projectId = "default";
1516
1524
  this.graphId = config.id;
@@ -1529,11 +1537,11 @@ var AgentGraph = class {
1529
1537
  this.stopWhen = config.stopWhen ? {
1530
1538
  transferCountIs: config.stopWhen.transferCountIs
1531
1539
  } : void 0;
1532
- this.agents = resolveGetter2(config.agents) || [];
1533
- this.agentMap = new Map(this.agents.map((agent2) => [agent2.getId(), agent2]));
1534
- if (this.defaultAgent) {
1535
- this.agents.push(this.defaultAgent);
1536
- this.agentMap.set(this.defaultAgent.getId(), this.defaultAgent);
1540
+ this.subAgents = resolveGetter2(config.subAgents) || [];
1541
+ this.agentMap = new Map(this.subAgents.map((agent) => [agent.getId(), agent]));
1542
+ if (this.defaultSubAgent) {
1543
+ this.subAgents.push(this.defaultSubAgent);
1544
+ this.agentMap.set(this.defaultSubAgent.getId(), this.defaultSubAgent);
1537
1545
  }
1538
1546
  if (this.models) {
1539
1547
  this.propagateImmediateModelSettings();
@@ -1542,8 +1550,8 @@ var AgentGraph = class {
1542
1550
  {
1543
1551
  graphId: this.graphId,
1544
1552
  tenantId: this.tenantId,
1545
- agentCount: this.agents.length,
1546
- defaultAgent: this.defaultAgent?.getName()
1553
+ agentCount: this.subAgents.length,
1554
+ defaultSubAgent: this.defaultSubAgent?.getName()
1547
1555
  },
1548
1556
  "AgentGraph created"
1549
1557
  );
@@ -1559,9 +1567,9 @@ var AgentGraph = class {
1559
1567
  this.tenantId = tenantId;
1560
1568
  this.projectId = projectId;
1561
1569
  this.baseURL = apiUrl;
1562
- for (const agent2 of this.agents) {
1563
- if (this.isInternalAgent(agent2)) {
1564
- const internalAgent = agent2;
1570
+ for (const agent of this.subAgents) {
1571
+ if (this.isInternalAgent(agent)) {
1572
+ const internalAgent = agent;
1565
1573
  if (internalAgent.setContext) {
1566
1574
  internalAgent.setContext(tenantId, projectId, apiUrl);
1567
1575
  }
@@ -1574,7 +1582,7 @@ var AgentGraph = class {
1574
1582
  }
1575
1583
  }
1576
1584
  } else {
1577
- const externalAgent2 = agent2;
1585
+ const externalAgent2 = agent;
1578
1586
  if (externalAgent2.setContext) {
1579
1587
  externalAgent2.setContext(tenantId, apiUrl);
1580
1588
  }
@@ -1598,9 +1606,11 @@ var AgentGraph = class {
1598
1606
  */
1599
1607
  async toFullGraphDefinition() {
1600
1608
  const agentsObject = {};
1601
- for (const agent2 of this.agents) {
1602
- if (this.isInternalAgent(agent2)) {
1603
- const internalAgent = agent2;
1609
+ const functionToolsObject = {};
1610
+ const functionsObject = {};
1611
+ for (const agent of this.subAgents) {
1612
+ if (this.isInternalAgent(agent)) {
1613
+ const internalAgent = agent;
1604
1614
  const transfers = internalAgent.getTransfers();
1605
1615
  const delegates = internalAgent.getDelegates();
1606
1616
  const tools = [];
@@ -1616,19 +1626,36 @@ var AgentGraph = class {
1616
1626
  headersMapping[toolId] = toolInstance.headers;
1617
1627
  }
1618
1628
  tools.push(toolId);
1629
+ if (toolInstance.constructor.name === "FunctionTool" && toolInstance instanceof FunctionTool) {
1630
+ if (!functionsObject[toolId]) {
1631
+ const functionData = toolInstance.serializeFunction();
1632
+ functionsObject[toolId] = functionData;
1633
+ }
1634
+ if (!functionToolsObject[toolId]) {
1635
+ const toolData = toolInstance.serializeTool();
1636
+ functionToolsObject[toolId] = {
1637
+ id: toolData.id,
1638
+ name: toolData.name,
1639
+ description: toolData.description,
1640
+ functionId: toolData.functionId,
1641
+ graphId: this.graphId
1642
+ // Include graphId for graph-scoped function tools
1643
+ };
1644
+ }
1645
+ }
1619
1646
  }
1620
1647
  const dataComponents = [];
1621
- const agentDataComponents = internalAgent.getDataComponents();
1622
- if (agentDataComponents) {
1623
- for (const dataComponent2 of agentDataComponents) {
1648
+ const subAgentDataComponents = internalAgent.getDataComponents();
1649
+ if (subAgentDataComponents) {
1650
+ for (const dataComponent2 of subAgentDataComponents) {
1624
1651
  const dataComponentId = dataComponent2.id || dataComponent2.name.toLowerCase().replace(/\s+/g, "-");
1625
1652
  dataComponents.push(dataComponentId);
1626
1653
  }
1627
1654
  }
1628
1655
  const artifactComponents = [];
1629
- const agentArtifactComponents = internalAgent.getArtifactComponents();
1630
- if (agentArtifactComponents) {
1631
- for (const artifactComponent2 of agentArtifactComponents) {
1656
+ const subAgentArtifactComponents = internalAgent.getArtifactComponents();
1657
+ if (subAgentArtifactComponents) {
1658
+ for (const artifactComponent2 of subAgentArtifactComponents) {
1632
1659
  const artifactComponentId = artifactComponent2.id || artifactComponent2.name.toLowerCase().replace(/\s+/g, "-");
1633
1660
  artifactComponents.push(artifactComponentId);
1634
1661
  }
@@ -1653,7 +1680,7 @@ var AgentGraph = class {
1653
1680
  type: "internal"
1654
1681
  };
1655
1682
  } else {
1656
- const externalAgent2 = agent2;
1683
+ const externalAgent2 = agent;
1657
1684
  agentsObject[externalAgent2.getId()] = {
1658
1685
  id: externalAgent2.getId(),
1659
1686
  name: externalAgent2.getName(),
@@ -1669,9 +1696,11 @@ var AgentGraph = class {
1669
1696
  id: this.graphId,
1670
1697
  name: this.graphName,
1671
1698
  description: this.graphDescription,
1672
- defaultAgentId: this.defaultAgent?.getId() || "",
1673
- agents: agentsObject,
1699
+ defaultSubAgentId: this.defaultSubAgent?.getId() || "",
1700
+ subAgents: agentsObject,
1674
1701
  contextConfig: this.contextConfig?.toObject(),
1702
+ ...Object.keys(functionToolsObject).length > 0 && { functionTools: functionToolsObject },
1703
+ ...Object.keys(functionsObject).length > 0 && { functions: functionsObject },
1675
1704
  models: this.models,
1676
1705
  statusUpdates: this.statusUpdateSettings,
1677
1706
  graphPrompt: this.graphPrompt,
@@ -1685,11 +1714,11 @@ var AgentGraph = class {
1685
1714
  async initializeAllTools() {
1686
1715
  logger8.info({ graphId: this.graphId }, "Initializing all tools in graph");
1687
1716
  const toolInitPromises = [];
1688
- for (const agent2 of this.agents) {
1689
- if (!agent2.getTools) {
1717
+ for (const agent of this.subAgents) {
1718
+ if (!agent.getTools) {
1690
1719
  continue;
1691
1720
  }
1692
- const internalAgent = agent2;
1721
+ const internalAgent = agent;
1693
1722
  const agentTools = internalAgent.getTools();
1694
1723
  for (const [toolName, toolInstance] of Object.entries(agentTools)) {
1695
1724
  if (toolInstance && typeof toolInstance === "object") {
@@ -1709,7 +1738,7 @@ var AgentGraph = class {
1709
1738
  }
1710
1739
  logger8.debug(
1711
1740
  {
1712
- agentId: agent2.getId(),
1741
+ subAgentId: agent.getId(),
1713
1742
  toolName,
1714
1743
  toolType: toolInstance.constructor.name,
1715
1744
  skipDbRegistration
@@ -1719,7 +1748,7 @@ var AgentGraph = class {
1719
1748
  } catch (error) {
1720
1749
  logger8.error(
1721
1750
  {
1722
- agentId: agent2.getId(),
1751
+ subAgentId: agent.getId(),
1723
1752
  toolName,
1724
1753
  error: error instanceof Error ? error.message : "Unknown error"
1725
1754
  },
@@ -1750,7 +1779,7 @@ var AgentGraph = class {
1750
1779
  logger8.info(
1751
1780
  {
1752
1781
  graphId: this.graphId,
1753
- agentCount: this.agents.length
1782
+ agentCount: this.subAgents.length
1754
1783
  },
1755
1784
  "Initializing agent graph using new graph endpoint"
1756
1785
  );
@@ -1804,7 +1833,7 @@ var AgentGraph = class {
1804
1833
  logger8.info(
1805
1834
  {
1806
1835
  graphId: this.graphId,
1807
- agentCount: this.agents.length
1836
+ agentCount: this.subAgents.length
1808
1837
  },
1809
1838
  "Initializing agent graph"
1810
1839
  );
@@ -1819,13 +1848,13 @@ var AgentGraph = class {
1819
1848
  "Context configuration initialized for graph"
1820
1849
  );
1821
1850
  }
1822
- const initPromises = this.agents.map(async (agent2) => {
1851
+ const initPromises = this.subAgents.map(async (agent) => {
1823
1852
  try {
1824
- agent2.config.graphId = this.graphId;
1825
- await agent2.init();
1853
+ agent.config.graphId = this.graphId;
1854
+ await agent.init();
1826
1855
  logger8.debug(
1827
1856
  {
1828
- agentId: agent2.getId(),
1857
+ subAgentId: agent.getId(),
1829
1858
  graphId: this.graphId
1830
1859
  },
1831
1860
  "Agent initialized in graph"
@@ -1833,7 +1862,7 @@ var AgentGraph = class {
1833
1862
  } catch (error) {
1834
1863
  logger8.error(
1835
1864
  {
1836
- agentId: agent2.getId(),
1865
+ subAgentId: agent.getId(),
1837
1866
  graphId: this.graphId,
1838
1867
  error: error instanceof Error ? error.message : "Unknown error"
1839
1868
  },
@@ -1851,7 +1880,7 @@ var AgentGraph = class {
1851
1880
  logger8.info(
1852
1881
  {
1853
1882
  graphId: this.graphId,
1854
- agentCount: this.agents.length
1883
+ agentCount: this.subAgents.length
1855
1884
  },
1856
1885
  "Agent graph initialized successfully"
1857
1886
  );
@@ -1871,13 +1900,13 @@ var AgentGraph = class {
1871
1900
  */
1872
1901
  async generate(input, options) {
1873
1902
  await this._init();
1874
- if (!this.defaultAgent) {
1903
+ if (!this.defaultSubAgent) {
1875
1904
  throw new Error("No default agent configured for this graph");
1876
1905
  }
1877
1906
  logger8.info(
1878
1907
  {
1879
1908
  graphId: this.graphId,
1880
- defaultAgent: this.defaultAgent.getName(),
1909
+ defaultSubAgent: this.defaultSubAgent.getName(),
1881
1910
  conversationId: options?.conversationId
1882
1911
  },
1883
1912
  "Generating response with default agent"
@@ -1890,13 +1919,13 @@ var AgentGraph = class {
1890
1919
  */
1891
1920
  async stream(input, options) {
1892
1921
  await this._init();
1893
- if (!this.defaultAgent) {
1922
+ if (!this.defaultSubAgent) {
1894
1923
  throw new Error("No default agent configured for this graph");
1895
1924
  }
1896
1925
  logger8.info(
1897
1926
  {
1898
1927
  graphId: this.graphId,
1899
- defaultAgent: this.defaultAgent.getName(),
1928
+ defaultSubAgent: this.defaultSubAgent.getName(),
1900
1929
  conversationId: options?.conversationId
1901
1930
  },
1902
1931
  "Streaming response with default agent"
@@ -1921,21 +1950,21 @@ var AgentGraph = class {
1921
1950
  /**
1922
1951
  * Run with a specific agent from the graph
1923
1952
  */
1924
- async runWith(agentId, input, options) {
1953
+ async runWith(subAgentId, input, options) {
1925
1954
  await this._init();
1926
- const agent2 = this.getAgent(agentId);
1927
- if (!agent2) {
1928
- throw new Error(`Agent '${agentId}' not found in graph`);
1955
+ const agent = this.getAgent(subAgentId);
1956
+ if (!agent) {
1957
+ throw new Error(`Agent '${subAgentId}' not found in graph`);
1929
1958
  }
1930
- if (!this.isInternalAgent(agent2)) {
1959
+ if (!this.isInternalAgent(agent)) {
1931
1960
  throw new Error(
1932
- `Agent '${agentId}' is an external agent and cannot be run directly. External agents are only accessible via delegation.`
1961
+ `Agent '${subAgentId}' is an external agent and cannot be run directly. External agents are only accessible via delegation.`
1933
1962
  );
1934
1963
  }
1935
1964
  logger8.info(
1936
1965
  {
1937
1966
  graphId: this.graphId,
1938
- agentId,
1967
+ subAgentId,
1939
1968
  conversationId: options?.conversationId
1940
1969
  },
1941
1970
  "Running with specific agent"
@@ -1943,7 +1972,7 @@ var AgentGraph = class {
1943
1972
  const response = await this.executeWithBackend(input, options);
1944
1973
  return {
1945
1974
  finalOutput: response,
1946
- agent: agent2,
1975
+ agent,
1947
1976
  turnCount: 1,
1948
1977
  usage: { inputTokens: 0, outputTokens: 0 },
1949
1978
  metadata: {
@@ -1961,17 +1990,17 @@ var AgentGraph = class {
1961
1990
  /**
1962
1991
  * Add an agent to the graph
1963
1992
  */
1964
- addAgent(agent2) {
1965
- this.agents.push(agent2);
1966
- this.agentMap.set(agent2.getId(), agent2);
1967
- if (this.models && this.isInternalAgent(agent2)) {
1968
- this.propagateModelSettingsToAgent(agent2);
1993
+ addSubAgent(agent) {
1994
+ this.subAgents.push(agent);
1995
+ this.agentMap.set(agent.getId(), agent);
1996
+ if (this.models && this.isInternalAgent(agent)) {
1997
+ this.propagateModelSettingsToAgent(agent);
1969
1998
  }
1970
1999
  logger8.info(
1971
2000
  {
1972
2001
  graphId: this.graphId,
1973
- agentId: agent2.getId(),
1974
- agentType: this.isInternalAgent(agent2) ? "internal" : "external"
2002
+ subAgentId: agent.getId(),
2003
+ agentType: this.isInternalAgent(agent) ? "internal" : "external"
1975
2004
  },
1976
2005
  "Agent added to graph"
1977
2006
  );
@@ -1979,15 +2008,15 @@ var AgentGraph = class {
1979
2008
  /**
1980
2009
  * Remove an agent from the graph
1981
2010
  */
1982
- removeAgent(id) {
2011
+ removeSubAgent(id) {
1983
2012
  const agentToRemove = this.agentMap.get(id);
1984
2013
  if (agentToRemove) {
1985
2014
  this.agentMap.delete(agentToRemove.getId());
1986
- this.agents = this.agents.filter((agent2) => agent2.getId() !== agentToRemove.getId());
2015
+ this.subAgents = this.subAgents.filter((agent) => agent.getId() !== agentToRemove.getId());
1987
2016
  logger8.info(
1988
2017
  {
1989
2018
  graphId: this.graphId,
1990
- agentId: agentToRemove.getId()
2019
+ subAgentId: agentToRemove.getId()
1991
2020
  },
1992
2021
  "Agent removed from graph"
1993
2022
  );
@@ -1998,25 +2027,25 @@ var AgentGraph = class {
1998
2027
  /**
1999
2028
  * Get all agents in the graph
2000
2029
  */
2001
- getAgents() {
2002
- return this.agents;
2030
+ getSubAgents() {
2031
+ return this.subAgents;
2003
2032
  }
2004
2033
  /**
2005
2034
  * Get all agent ids (unified method for all agent types)
2006
2035
  */
2007
- getAgentIds() {
2036
+ getSubAgentIds() {
2008
2037
  return Array.from(this.agentMap.keys());
2009
2038
  }
2010
2039
  /**
2011
2040
  * Set the default agent
2012
2041
  */
2013
- setDefaultAgent(agent2) {
2014
- this.defaultAgent = agent2;
2015
- this.addAgent(agent2);
2042
+ setdefaultSubAgent(agent) {
2043
+ this.defaultSubAgent = agent;
2044
+ this.addSubAgent(agent);
2016
2045
  logger8.info(
2017
2046
  {
2018
2047
  graphId: this.graphId,
2019
- defaultAgent: agent2.getId()
2048
+ defaultSubAgent: agent.getId()
2020
2049
  },
2021
2050
  "Default agent updated"
2022
2051
  );
@@ -2024,8 +2053,8 @@ var AgentGraph = class {
2024
2053
  /**
2025
2054
  * Get the default agent
2026
2055
  */
2027
- getDefaultAgent() {
2028
- return this.defaultAgent;
2056
+ getdefaultSubAgent() {
2057
+ return this.defaultSubAgent;
2029
2058
  }
2030
2059
  /**
2031
2060
  * Get the graph ID
@@ -2083,8 +2112,8 @@ var AgentGraph = class {
2083
2112
  */
2084
2113
  getStats() {
2085
2114
  return {
2086
- agentCount: this.agents.length,
2087
- defaultAgent: this.defaultAgent?.getName() || null,
2115
+ agentCount: this.subAgents.length,
2116
+ defaultSubAgent: this.defaultSubAgent?.getName() || null,
2088
2117
  initialized: this.initialized,
2089
2118
  graphId: this.graphId,
2090
2119
  tenantId: this.tenantId
@@ -2095,35 +2124,35 @@ var AgentGraph = class {
2095
2124
  */
2096
2125
  validate() {
2097
2126
  const errors = [];
2098
- if (this.agents.length === 0) {
2127
+ if (this.subAgents.length === 0) {
2099
2128
  errors.push("Graph must contain at least one agent");
2100
2129
  }
2101
- if (!this.defaultAgent) {
2130
+ if (!this.defaultSubAgent) {
2102
2131
  errors.push("Graph must have a default agent");
2103
2132
  }
2104
2133
  const names = /* @__PURE__ */ new Set();
2105
- for (const agent2 of this.agents) {
2106
- const name = agent2.getName();
2134
+ for (const agent of this.subAgents) {
2135
+ const name = agent.getName();
2107
2136
  if (names.has(name)) {
2108
2137
  errors.push(`Duplicate agent name: ${name}`);
2109
2138
  }
2110
2139
  names.add(name);
2111
2140
  }
2112
- for (const agent2 of this.agents) {
2113
- if (!this.isInternalAgent(agent2)) continue;
2114
- const transfers = agent2.getTransfers();
2141
+ for (const agent of this.subAgents) {
2142
+ if (!this.isInternalAgent(agent)) continue;
2143
+ const transfers = agent.getTransfers();
2115
2144
  for (const transferAgent of transfers) {
2116
2145
  if (!this.agentMap.has(transferAgent.getName())) {
2117
2146
  errors.push(
2118
- `Agent '${agent2.getName()}' has transfer to '${transferAgent.getName()}' which is not in the graph`
2147
+ `Agent '${agent.getName()}' has transfer to '${transferAgent.getName()}' which is not in the graph`
2119
2148
  );
2120
2149
  }
2121
2150
  }
2122
- const delegates = agent2.getDelegates();
2151
+ const delegates = agent.getDelegates();
2123
2152
  for (const delegateAgent of delegates) {
2124
2153
  if (!this.agentMap.has(delegateAgent.getName())) {
2125
2154
  errors.push(
2126
- `Agent '${agent2.getName()}' has delegation to '${delegateAgent.getName()}' which is not in the graph`
2155
+ `Agent '${agent.getName()}' has delegation to '${delegateAgent.getName()}' which is not in the graph`
2127
2156
  );
2128
2157
  }
2129
2158
  }
@@ -2142,8 +2171,8 @@ var AgentGraph = class {
2142
2171
  /**
2143
2172
  * Type guard to check if an agent is an internal AgentInterface
2144
2173
  */
2145
- isInternalAgent(agent2) {
2146
- return "getTransfers" in agent2 && typeof agent2.getTransfers === "function";
2174
+ isInternalAgent(agent) {
2175
+ return "getTransfers" in agent && typeof agent.getTransfers === "function";
2147
2176
  }
2148
2177
  /**
2149
2178
  * Get project-level model settingsuration defaults
@@ -2207,9 +2236,9 @@ var AgentGraph = class {
2207
2236
  }
2208
2237
  }
2209
2238
  await this.applyStopWhenInheritance();
2210
- for (const agent2 of this.agents) {
2211
- if (this.isInternalAgent(agent2)) {
2212
- this.propagateModelSettingsToAgent(agent2);
2239
+ for (const agent of this.subAgents) {
2240
+ if (this.isInternalAgent(agent)) {
2241
+ this.propagateModelSettingsToAgent(agent);
2213
2242
  }
2214
2243
  }
2215
2244
  }
@@ -2228,9 +2257,9 @@ var AgentGraph = class {
2228
2257
  this.stopWhen.transferCountIs = 10;
2229
2258
  }
2230
2259
  if (projectStopWhen?.stepCountIs !== void 0) {
2231
- for (const agent2 of this.agents) {
2232
- if (this.isInternalAgent(agent2)) {
2233
- const internalAgent = agent2;
2260
+ for (const agent of this.subAgents) {
2261
+ if (this.isInternalAgent(agent)) {
2262
+ const internalAgent = agent;
2234
2263
  if (!internalAgent.config.stopWhen) {
2235
2264
  internalAgent.config.stopWhen = {};
2236
2265
  }
@@ -2252,19 +2281,19 @@ var AgentGraph = class {
2252
2281
  /**
2253
2282
  * Propagate graph-level model settings to agents (supporting partial inheritance)
2254
2283
  */
2255
- propagateModelSettingsToAgent(agent2) {
2284
+ propagateModelSettingsToAgent(agent) {
2256
2285
  if (this.models) {
2257
- if (!agent2.config.models) {
2258
- agent2.config.models = {};
2286
+ if (!agent.config.models) {
2287
+ agent.config.models = {};
2259
2288
  }
2260
- if (!agent2.config.models.base && this.models.base) {
2261
- agent2.config.models.base = this.models.base;
2289
+ if (!agent.config.models.base && this.models.base) {
2290
+ agent.config.models.base = this.models.base;
2262
2291
  }
2263
- if (!agent2.config.models.structuredOutput && this.models.structuredOutput) {
2264
- agent2.config.models.structuredOutput = this.models.structuredOutput;
2292
+ if (!agent.config.models.structuredOutput && this.models.structuredOutput) {
2293
+ agent.config.models.structuredOutput = this.models.structuredOutput;
2265
2294
  }
2266
- if (!agent2.config.models.summarizer && this.models.summarizer) {
2267
- agent2.config.models.summarizer = this.models.summarizer;
2295
+ if (!agent.config.models.summarizer && this.models.summarizer) {
2296
+ agent.config.models.summarizer = this.models.summarizer;
2268
2297
  }
2269
2298
  }
2270
2299
  }
@@ -2272,17 +2301,17 @@ var AgentGraph = class {
2272
2301
  * Immediately propagate graph-level models to all agents during construction
2273
2302
  */
2274
2303
  propagateImmediateModelSettings() {
2275
- for (const agent2 of this.agents) {
2276
- if (this.isInternalAgent(agent2)) {
2277
- this.propagateModelSettingsToAgent(agent2);
2304
+ for (const agent of this.subAgents) {
2305
+ if (this.isInternalAgent(agent)) {
2306
+ this.propagateModelSettingsToAgent(agent);
2278
2307
  }
2279
2308
  }
2280
2309
  }
2281
2310
  /**
2282
2311
  * Type guard to check if an agent is an external AgentInterface
2283
2312
  */
2284
- isExternalAgent(agent2) {
2285
- return !this.isInternalAgent(agent2);
2313
+ isExternalAgent(agent) {
2314
+ return !this.isInternalAgent(agent);
2286
2315
  }
2287
2316
  /**
2288
2317
  * Execute agent using the backend system instead of local runner
@@ -2395,7 +2424,7 @@ var AgentGraph = class {
2395
2424
  body: JSON.stringify({
2396
2425
  id: this.graphId,
2397
2426
  name: this.graphName,
2398
- defaultAgentId: this.defaultAgent?.getId() || "",
2427
+ defaultSubAgentId: this.defaultSubAgent?.getId() || "",
2399
2428
  contextConfigId: this.contextConfig?.getId(),
2400
2429
  models: this.models
2401
2430
  })
@@ -2413,7 +2442,7 @@ var AgentGraph = class {
2413
2442
  }
2414
2443
  }
2415
2444
  async saveRelations() {
2416
- if (this.defaultAgent) {
2445
+ if (this.defaultSubAgent) {
2417
2446
  try {
2418
2447
  const updateUrl = `${this.baseURL}/tenants/${this.tenantId}/agent-graphs/${this.graphId}`;
2419
2448
  const updateResponse = await fetch(updateUrl, {
@@ -2423,7 +2452,7 @@ var AgentGraph = class {
2423
2452
  },
2424
2453
  body: JSON.stringify({
2425
2454
  id: this.graphId,
2426
- defaultAgentId: this.defaultAgent.getId(),
2455
+ defaultSubAgentId: this.defaultSubAgent.getId(),
2427
2456
  contextConfigId: this.contextConfig?.getId()
2428
2457
  })
2429
2458
  });
@@ -2433,7 +2462,7 @@ var AgentGraph = class {
2433
2462
  logger8.debug(
2434
2463
  {
2435
2464
  graphId: this.graphId,
2436
- defaultAgent: this.defaultAgent.getName()
2465
+ defaultSubAgent: this.defaultSubAgent.getName()
2437
2466
  },
2438
2467
  "Graph relationships configured"
2439
2468
  );
@@ -2451,21 +2480,21 @@ var AgentGraph = class {
2451
2480
  }
2452
2481
  async createAgentRelations() {
2453
2482
  const allRelationPromises = [];
2454
- for (const agent2 of this.agents) {
2455
- if (this.isInternalAgent(agent2)) {
2456
- const transfers = agent2.getTransfers();
2483
+ for (const agent of this.subAgents) {
2484
+ if (this.isInternalAgent(agent)) {
2485
+ const transfers = agent.getTransfers();
2457
2486
  for (const transferAgent of transfers) {
2458
2487
  allRelationPromises.push(
2459
- this.createInternalAgentRelation(agent2, transferAgent, "transfer")
2488
+ this.createInternalAgentRelation(agent, transferAgent, "transfer")
2460
2489
  );
2461
2490
  }
2462
- const delegates = agent2.getDelegates();
2491
+ const delegates = agent.getDelegates();
2463
2492
  for (const delegate of delegates) {
2464
2493
  if (delegate.type === "external") {
2465
- allRelationPromises.push(this.createExternalAgentRelation(agent2, delegate, "delegate"));
2494
+ allRelationPromises.push(this.createExternalAgentRelation(agent, delegate, "delegate"));
2466
2495
  } else {
2467
2496
  allRelationPromises.push(
2468
- this.createInternalAgentRelation(agent2, delegate, "delegate")
2497
+ this.createInternalAgentRelation(agent, delegate, "delegate")
2469
2498
  );
2470
2499
  }
2471
2500
  }
@@ -2510,8 +2539,8 @@ var AgentGraph = class {
2510
2539
  },
2511
2540
  body: JSON.stringify({
2512
2541
  graphId: this.graphId,
2513
- sourceAgentId: sourceAgent.getId(),
2514
- targetAgentId: targetAgent.getId(),
2542
+ sourceSubAgentId: sourceAgent.getId(),
2543
+ targetSubAgentId: targetAgent.getId(),
2515
2544
  relationType
2516
2545
  })
2517
2546
  });
@@ -2520,8 +2549,8 @@ var AgentGraph = class {
2520
2549
  if (response.status === 422 && errorText.includes("already exists")) {
2521
2550
  logger8.info(
2522
2551
  {
2523
- sourceAgentId: sourceAgent.getId(),
2524
- targetAgentId: targetAgent.getId(),
2552
+ sourceSubAgentId: sourceAgent.getId(),
2553
+ targetSubAgentId: targetAgent.getId(),
2525
2554
  graphId: this.graphId,
2526
2555
  relationType
2527
2556
  },
@@ -2533,8 +2562,8 @@ var AgentGraph = class {
2533
2562
  }
2534
2563
  logger8.info(
2535
2564
  {
2536
- sourceAgentId: sourceAgent.getId(),
2537
- targetAgentId: targetAgent.getId(),
2565
+ sourceSubAgentId: sourceAgent.getId(),
2566
+ targetSubAgentId: targetAgent.getId(),
2538
2567
  graphId: this.graphId,
2539
2568
  relationType
2540
2569
  },
@@ -2543,8 +2572,8 @@ var AgentGraph = class {
2543
2572
  } catch (error) {
2544
2573
  logger8.error(
2545
2574
  {
2546
- sourceAgentId: sourceAgent.getId(),
2547
- targetAgentId: targetAgent.getId(),
2575
+ sourceSubAgentId: sourceAgent.getId(),
2576
+ targetSubAgentId: targetAgent.getId(),
2548
2577
  graphId: this.graphId,
2549
2578
  relationType,
2550
2579
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2563,8 +2592,8 @@ var AgentGraph = class {
2563
2592
  },
2564
2593
  body: JSON.stringify({
2565
2594
  graphId: this.graphId,
2566
- sourceAgentId: sourceAgent.getId(),
2567
- externalAgentId: externalAgent2.getId(),
2595
+ sourceSubAgentId: sourceAgent.getId(),
2596
+ externalSubAgentId: externalAgent2.getId(),
2568
2597
  relationType
2569
2598
  })
2570
2599
  });
@@ -2573,8 +2602,8 @@ var AgentGraph = class {
2573
2602
  if (response.status === 422 && errorText.includes("already exists")) {
2574
2603
  logger8.info(
2575
2604
  {
2576
- sourceAgentId: sourceAgent.getId(),
2577
- externalAgentId: externalAgent2.getId(),
2605
+ sourceSubAgentId: sourceAgent.getId(),
2606
+ externalSubAgentId: externalAgent2.getId(),
2578
2607
  graphId: this.graphId,
2579
2608
  relationType
2580
2609
  },
@@ -2588,8 +2617,8 @@ var AgentGraph = class {
2588
2617
  }
2589
2618
  logger8.info(
2590
2619
  {
2591
- sourceAgentId: sourceAgent.getId(),
2592
- externalAgentId: externalAgent2.getId(),
2620
+ sourceSubAgentId: sourceAgent.getId(),
2621
+ externalSubAgentId: externalAgent2.getId(),
2593
2622
  graphId: this.graphId,
2594
2623
  relationType
2595
2624
  },
@@ -2598,8 +2627,8 @@ var AgentGraph = class {
2598
2627
  } catch (error) {
2599
2628
  logger8.error(
2600
2629
  {
2601
- sourceAgentId: sourceAgent.getId(),
2602
- externalAgentId: externalAgent2.getId(),
2630
+ sourceSubAgentId: sourceAgent.getId(),
2631
+ externalSubAgentId: externalAgent2.getId(),
2603
2632
  graphId: this.graphId,
2604
2633
  relationType,
2605
2634
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2613,7 +2642,7 @@ var AgentGraph = class {
2613
2642
  * Create external agents in the database
2614
2643
  */
2615
2644
  async createExternalAgents() {
2616
- const externalAgents2 = this.agents.filter((agent2) => this.isExternalAgent(agent2));
2645
+ const externalAgents2 = this.subAgents.filter((agent) => this.isExternalAgent(agent));
2617
2646
  logger8.info(
2618
2647
  {
2619
2648
  graphId: this.graphId,
@@ -2626,7 +2655,7 @@ var AgentGraph = class {
2626
2655
  await externalAgent2.init();
2627
2656
  logger8.debug(
2628
2657
  {
2629
- externalAgentId: externalAgent2.getId(),
2658
+ externalSubAgentId: externalAgent2.getId(),
2630
2659
  graphId: this.graphId
2631
2660
  },
2632
2661
  "External agent created in database"
@@ -2634,7 +2663,7 @@ var AgentGraph = class {
2634
2663
  } catch (error) {
2635
2664
  logger8.error(
2636
2665
  {
2637
- externalAgentId: externalAgent2.getId(),
2666
+ externalSubAgentId: externalAgent2.getId(),
2638
2667
  graphId: this.graphId,
2639
2668
  error: error instanceof Error ? error.message : "Unknown error"
2640
2669
  },
@@ -3206,6 +3235,7 @@ var Project = class {
3206
3235
  async toFullProjectDefinition() {
3207
3236
  const graphsObject = {};
3208
3237
  const toolsObject = {};
3238
+ const functionToolsObject = {};
3209
3239
  const functionsObject = {};
3210
3240
  const dataComponentsObject = {};
3211
3241
  const artifactComponentsObject = {};
@@ -3285,11 +3315,11 @@ var Project = class {
3285
3315
  }
3286
3316
  }
3287
3317
  }
3288
- for (const agent2 of graph.getAgents()) {
3289
- if (agent2.type === "external") {
3318
+ for (const agent of graph.getSubAgents()) {
3319
+ if (agent.type === "external") {
3290
3320
  continue;
3291
3321
  }
3292
- const agentTools = agent2.getTools();
3322
+ const agentTools = agent.getTools();
3293
3323
  for (const [, toolInstance] of Object.entries(agentTools)) {
3294
3324
  const actualTool = toolInstance;
3295
3325
  const toolId = actualTool.getId();
@@ -3298,18 +3328,13 @@ var Project = class {
3298
3328
  const functionData = actualTool.serializeFunction();
3299
3329
  functionsObject[toolId] = functionData;
3300
3330
  }
3301
- if (!toolsObject[toolId]) {
3331
+ if (!functionToolsObject[toolId]) {
3302
3332
  const toolData = actualTool.serializeTool();
3303
- const toolConfig = {
3304
- type: "function"
3305
- // No inline function details - they're in the functions table via functionId
3306
- };
3307
- toolsObject[toolId] = {
3333
+ functionToolsObject[toolId] = {
3308
3334
  id: toolData.id,
3309
3335
  name: toolData.name,
3310
3336
  description: toolData.description,
3311
- functionId: toolData.functionId,
3312
- config: toolConfig
3337
+ functionId: toolData.functionId
3313
3338
  };
3314
3339
  }
3315
3340
  } else {
@@ -3348,9 +3373,9 @@ var Project = class {
3348
3373
  }
3349
3374
  }
3350
3375
  }
3351
- const agentDataComponents = agent2.getDataComponents?.();
3352
- if (agentDataComponents) {
3353
- for (const dataComponent2 of agentDataComponents) {
3376
+ const subAgentDataComponents = agent.getDataComponents?.();
3377
+ if (subAgentDataComponents) {
3378
+ for (const dataComponent2 of subAgentDataComponents) {
3354
3379
  let dataComponentId;
3355
3380
  let dataComponentName;
3356
3381
  let dataComponentDescription;
@@ -3376,9 +3401,9 @@ var Project = class {
3376
3401
  }
3377
3402
  }
3378
3403
  }
3379
- const agentArtifactComponents = agent2.getArtifactComponents?.();
3380
- if (agentArtifactComponents) {
3381
- for (const artifactComponent2 of agentArtifactComponents) {
3404
+ const subAgentArtifactComponents = agent.getArtifactComponents?.();
3405
+ if (subAgentArtifactComponents) {
3406
+ for (const artifactComponent2 of subAgentArtifactComponents) {
3382
3407
  let artifactComponentId;
3383
3408
  let artifactComponentName;
3384
3409
  let artifactComponentDescription;
@@ -3506,13 +3531,13 @@ function agentGraph(config) {
3506
3531
  function project(config) {
3507
3532
  return new Project(config);
3508
3533
  }
3509
- function agent(config) {
3534
+ function subAgent(config) {
3510
3535
  if (!config.id) {
3511
3536
  throw new Error(
3512
- "Agent ID is required. Agents must have stable IDs for consistency across deployments."
3537
+ "Sub-Agent ID is required. Sub-Agents must have stable IDs for consistency across deployments."
3513
3538
  );
3514
3539
  }
3515
- return new Agent(config);
3540
+ return new SubAgent(config);
3516
3541
  }
3517
3542
  function credential(config) {
3518
3543
  return CredentialReferenceApiInsertSchema.parse(config);
@@ -3567,17 +3592,6 @@ function functionTool(config) {
3567
3592
  return new FunctionTool(config);
3568
3593
  }
3569
3594
 
3570
- // src/credential-ref.ts
3571
- function credentialRef(id) {
3572
- return {
3573
- __type: "credential-ref",
3574
- id
3575
- };
3576
- }
3577
- function isCredentialReference(value) {
3578
- return value && typeof value === "object" && value.__type === "credential-ref";
3579
- }
3580
-
3581
3595
  // src/utils/validateFunction.ts
3582
3596
  function validateFunction(value, name) {
3583
3597
  if (typeof value !== "function") {
@@ -3587,7 +3601,7 @@ function validateFunction(value, name) {
3587
3601
 
3588
3602
  // src/builders.ts
3589
3603
  var TransferConfigSchema = z.object({
3590
- agent: z.instanceof(Agent),
3604
+ agent: z.instanceof(SubAgent),
3591
3605
  description: z.string().optional()
3592
3606
  });
3593
3607
  function transfer(targetAgent, description, condition) {
@@ -3606,6 +3620,17 @@ function transfer(targetAgent, description, condition) {
3606
3620
  return config;
3607
3621
  }
3608
3622
 
3623
+ // src/credential-ref.ts
3624
+ function credentialRef(id) {
3625
+ return {
3626
+ __type: "credential-ref",
3627
+ id
3628
+ };
3629
+ }
3630
+ function isCredentialReference(value) {
3631
+ return value && typeof value === "object" && value.__type === "credential-ref";
3632
+ }
3633
+
3609
3634
  // src/environment-settings.ts
3610
3635
  function createEnvironmentSettings(environments) {
3611
3636
  return {
@@ -3657,7 +3682,7 @@ var ExternalAgent = class {
3657
3682
  await this.upsertExternalAgent();
3658
3683
  logger11.info(
3659
3684
  {
3660
- externalAgentId: this.getId()
3685
+ externalSubAgentId: this.getId()
3661
3686
  },
3662
3687
  "External agent initialized successfully"
3663
3688
  );
@@ -3665,7 +3690,7 @@ var ExternalAgent = class {
3665
3690
  } catch (error) {
3666
3691
  logger11.error(
3667
3692
  {
3668
- externalAgentId: this.getId(),
3693
+ externalSubAgentId: this.getId(),
3669
3694
  error: error instanceof Error ? error.message : "Unknown error"
3670
3695
  },
3671
3696
  "Failed to initialize external agent"
@@ -3707,7 +3732,7 @@ var ExternalAgent = class {
3707
3732
  if (updateResponse.ok) {
3708
3733
  logger11.info(
3709
3734
  {
3710
- externalAgentId: this.getId()
3735
+ externalSubAgentId: this.getId()
3711
3736
  },
3712
3737
  "External agent updated successfully"
3713
3738
  );
@@ -3716,7 +3741,7 @@ var ExternalAgent = class {
3716
3741
  if (updateResponse.status === 404) {
3717
3742
  logger11.info(
3718
3743
  {
3719
- externalAgentId: this.getId()
3744
+ externalSubAgentId: this.getId()
3720
3745
  },
3721
3746
  "External agent not found, creating new external agent"
3722
3747
  );
@@ -3738,7 +3763,7 @@ var ExternalAgent = class {
3738
3763
  }
3739
3764
  logger11.info(
3740
3765
  {
3741
- externalAgentId: this.getId()
3766
+ externalSubAgentId: this.getId()
3742
3767
  },
3743
3768
  "External agent created successfully"
3744
3769
  );
@@ -3826,7 +3851,7 @@ var Runner = class _Runner {
3826
3851
  logger12.info(
3827
3852
  {
3828
3853
  graphId: graph.getId(),
3829
- defaultAgent: graph.getDefaultAgent()?.getName(),
3854
+ defaultSubAgent: graph.getdefaultSubAgent()?.getName(),
3830
3855
  maxTurns,
3831
3856
  initialMessageCount: messageHistory.length
3832
3857
  },
@@ -3853,7 +3878,7 @@ var Runner = class _Runner {
3853
3878
  );
3854
3879
  return {
3855
3880
  finalOutput: response,
3856
- agent: graph.getDefaultAgent() || {},
3881
+ agent: graph.getdefaultSubAgent() || {},
3857
3882
  turnCount,
3858
3883
  usage: { inputTokens: 0, outputTokens: 0 },
3859
3884
  metadata: {
@@ -3880,7 +3905,7 @@ var Runner = class _Runner {
3880
3905
  logger12.info(
3881
3906
  {
3882
3907
  graphId: graph.getId(),
3883
- defaultAgent: graph.getDefaultAgent()?.getName()
3908
+ defaultSubAgent: graph.getdefaultSubAgent()?.getName()
3884
3909
  },
3885
3910
  "Starting graph stream"
3886
3911
  );
@@ -3945,23 +3970,23 @@ var Runner = class _Runner {
3945
3970
  if (!graph.getId()) {
3946
3971
  errors.push("Graph ID is required");
3947
3972
  }
3948
- const defaultAgent = graph.getDefaultAgent();
3949
- if (!defaultAgent) {
3973
+ const defaultSubAgent = graph.getdefaultSubAgent();
3974
+ if (!defaultSubAgent) {
3950
3975
  errors.push("Default agent is required");
3951
3976
  } else {
3952
- if (!defaultAgent.getName()) {
3977
+ if (!defaultSubAgent.getName()) {
3953
3978
  errors.push("Default agent name is required");
3954
3979
  }
3955
- if (!defaultAgent.getInstructions()) {
3980
+ if (!defaultSubAgent.getInstructions()) {
3956
3981
  errors.push("Default agent instructions are required");
3957
3982
  }
3958
3983
  }
3959
- const agents = graph.getAgents();
3984
+ const agents = graph.getSubAgents();
3960
3985
  if (agents.length === 0) {
3961
3986
  errors.push("Graph must contain at least one agent");
3962
3987
  }
3963
- for (const agent2 of agents) {
3964
- if (!agent2.getName()) {
3988
+ for (const agent of agents) {
3989
+ if (!agent.getName()) {
3965
3990
  errors.push(`Agent missing name`);
3966
3991
  }
3967
3992
  }
@@ -3974,15 +3999,15 @@ var Runner = class _Runner {
3974
3999
  * Get execution statistics for a graph
3975
4000
  */
3976
4001
  static async getExecutionStats(graph, messages, options) {
3977
- const agents = graph.getAgents();
3978
- const defaultAgent = graph.getDefaultAgent();
4002
+ const agents = graph.getSubAgents();
4003
+ const defaultSubAgent = graph.getdefaultSubAgent();
3979
4004
  const messageCount = Array.isArray(messages) ? messages.length : 1;
3980
4005
  return {
3981
4006
  estimatedTurns: Math.min(Math.max(messageCount, 1), options?.maxTurns || 10),
3982
4007
  estimatedTokens: messageCount * 100,
3983
4008
  // Rough estimate
3984
4009
  agentCount: agents.length,
3985
- defaultAgent: defaultAgent?.getName()
4010
+ defaultSubAgent: defaultSubAgent?.getName()
3986
4011
  };
3987
4012
  }
3988
4013
  };
@@ -3990,4 +4015,4 @@ var run = Runner.run.bind(Runner);
3990
4015
  var stream = Runner.stream.bind(Runner);
3991
4016
  var raceGraphs = Runner.raceGraphs.bind(Runner);
3992
4017
 
3993
- export { Agent, ArtifactComponent, DataComponent, ExternalAgent, FunctionTool, Project, Runner, Tool, agent, agentGraph, agentMcp, artifactComponent, createEnvironmentSettings, createFullProjectViaAPI, credential, credentialRef, dataComponent, deleteFullProjectViaAPI, externalAgent, externalAgents, functionTool, getFullProjectViaAPI, isCredentialReference, mcpServer, mcpTool, project, raceGraphs, registerEnvironmentSettings, run, stream, transfer, updateFullProjectViaAPI };
4018
+ export { SubAgent as Agent, ArtifactComponent, DataComponent, ExternalAgent, FunctionTool, Project, Runner, Tool, subAgent as agent, agentGraph, agentMcp, artifactComponent, createEnvironmentSettings, createFullProjectViaAPI, credential, credentialRef, dataComponent, deleteFullProjectViaAPI, externalAgent, externalAgents, functionTool, getFullProjectViaAPI, isCredentialReference, mcpServer, mcpTool, project, raceGraphs, registerEnvironmentSettings, run, stream, transfer, updateFullProjectViaAPI };