@inkeep/agents-sdk 0.0.0-dev-20251009194333 → 0.0.0-dev-20251009215610
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +101 -101
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +101 -101
- package/package.json +2 -2
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;
|
|
@@ -734,7 +734,7 @@ var Agent = class {
|
|
|
734
734
|
logger6.info(
|
|
735
735
|
{
|
|
736
736
|
tenantId: this.tenantId,
|
|
737
|
-
|
|
737
|
+
subAgentId: this.config.id,
|
|
738
738
|
agentName: config.name
|
|
739
739
|
},
|
|
740
740
|
"Agent constructor initialized"
|
|
@@ -884,7 +884,7 @@ var Agent = class {
|
|
|
884
884
|
await this.saveArtifactComponents();
|
|
885
885
|
logger6.info(
|
|
886
886
|
{
|
|
887
|
-
|
|
887
|
+
subAgentId: this.getId()
|
|
888
888
|
},
|
|
889
889
|
"Agent initialized successfully"
|
|
890
890
|
);
|
|
@@ -892,7 +892,7 @@ var Agent = class {
|
|
|
892
892
|
} catch (error) {
|
|
893
893
|
logger6.error(
|
|
894
894
|
{
|
|
895
|
-
|
|
895
|
+
subAgentId: this.getId(),
|
|
896
896
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
897
897
|
},
|
|
898
898
|
"Failed to initialize agent"
|
|
@@ -924,7 +924,7 @@ var Agent = class {
|
|
|
924
924
|
if (updateResponse.ok) {
|
|
925
925
|
logger6.info(
|
|
926
926
|
{
|
|
927
|
-
|
|
927
|
+
subAgentId: this.getId()
|
|
928
928
|
},
|
|
929
929
|
"Agent updated successfully"
|
|
930
930
|
);
|
|
@@ -933,7 +933,7 @@ var Agent = class {
|
|
|
933
933
|
if (updateResponse.status === 404) {
|
|
934
934
|
logger6.info(
|
|
935
935
|
{
|
|
936
|
-
|
|
936
|
+
subAgentId: this.getId()
|
|
937
937
|
},
|
|
938
938
|
"Agent not found, creating new agent"
|
|
939
939
|
);
|
|
@@ -952,7 +952,7 @@ var Agent = class {
|
|
|
952
952
|
}
|
|
953
953
|
logger6.info(
|
|
954
954
|
{
|
|
955
|
-
|
|
955
|
+
subAgentId: this.getId()
|
|
956
956
|
},
|
|
957
957
|
"Agent created successfully"
|
|
958
958
|
);
|
|
@@ -1059,7 +1059,7 @@ var Agent = class {
|
|
|
1059
1059
|
this.config.dataComponents = () => uniqueComponents;
|
|
1060
1060
|
logger6.info(
|
|
1061
1061
|
{
|
|
1062
|
-
|
|
1062
|
+
subAgentId: this.getId(),
|
|
1063
1063
|
dbComponentCount: dbDataComponents.length,
|
|
1064
1064
|
configComponentCount: configComponents.length,
|
|
1065
1065
|
totalComponentCount: uniqueComponents.length
|
|
@@ -1069,7 +1069,7 @@ var Agent = class {
|
|
|
1069
1069
|
} catch (error) {
|
|
1070
1070
|
logger6.error(
|
|
1071
1071
|
{
|
|
1072
|
-
|
|
1072
|
+
subAgentId: this.getId(),
|
|
1073
1073
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
1074
1074
|
},
|
|
1075
1075
|
"Failed to load data components from database"
|
|
@@ -1116,7 +1116,7 @@ var Agent = class {
|
|
|
1116
1116
|
this.config.artifactComponents = () => uniqueComponents;
|
|
1117
1117
|
logger6.info(
|
|
1118
1118
|
{
|
|
1119
|
-
|
|
1119
|
+
subAgentId: this.getId(),
|
|
1120
1120
|
dbComponentCount: dbArtifactComponents.length,
|
|
1121
1121
|
configComponentCount: configComponents.length,
|
|
1122
1122
|
totalComponentCount: uniqueComponents.length
|
|
@@ -1126,7 +1126,7 @@ var Agent = class {
|
|
|
1126
1126
|
} catch (error) {
|
|
1127
1127
|
logger6.error(
|
|
1128
1128
|
{
|
|
1129
|
-
|
|
1129
|
+
subAgentId: this.getId(),
|
|
1130
1130
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
1131
1131
|
},
|
|
1132
1132
|
"Failed to load artifact components from database"
|
|
@@ -1260,7 +1260,7 @@ var Agent = class {
|
|
|
1260
1260
|
if (toolConfig.type === "function") {
|
|
1261
1261
|
logger6.info(
|
|
1262
1262
|
{
|
|
1263
|
-
|
|
1263
|
+
subAgentId: this.getId(),
|
|
1264
1264
|
toolId
|
|
1265
1265
|
},
|
|
1266
1266
|
"Skipping function tool creation - will be handled at runtime"
|
|
@@ -1292,7 +1292,7 @@ var Agent = class {
|
|
|
1292
1292
|
await this.createAgentToolRelation(tool.getId(), selectedTools, headers);
|
|
1293
1293
|
logger6.info(
|
|
1294
1294
|
{
|
|
1295
|
-
|
|
1295
|
+
subAgentId: this.getId(),
|
|
1296
1296
|
toolId: tool.getId()
|
|
1297
1297
|
},
|
|
1298
1298
|
"Tool created and linked to agent"
|
|
@@ -1300,7 +1300,7 @@ var Agent = class {
|
|
|
1300
1300
|
} catch (error) {
|
|
1301
1301
|
logger6.error(
|
|
1302
1302
|
{
|
|
1303
|
-
|
|
1303
|
+
subAgentId: this.getId(),
|
|
1304
1304
|
toolId,
|
|
1305
1305
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
1306
1306
|
},
|
|
@@ -1322,7 +1322,7 @@ var Agent = class {
|
|
|
1322
1322
|
await this.createAgentDataComponentRelation(dc.getId());
|
|
1323
1323
|
logger6.info(
|
|
1324
1324
|
{
|
|
1325
|
-
|
|
1325
|
+
subAgentId: this.getId(),
|
|
1326
1326
|
dataComponentId: dc.getId()
|
|
1327
1327
|
},
|
|
1328
1328
|
"DataComponent created and linked to agent"
|
|
@@ -1330,7 +1330,7 @@ var Agent = class {
|
|
|
1330
1330
|
} catch (error) {
|
|
1331
1331
|
logger6.error(
|
|
1332
1332
|
{
|
|
1333
|
-
|
|
1333
|
+
subAgentId: this.getId(),
|
|
1334
1334
|
dataComponentName: dataComponent2.name,
|
|
1335
1335
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
1336
1336
|
},
|
|
@@ -1352,7 +1352,7 @@ var Agent = class {
|
|
|
1352
1352
|
await this.createAgentArtifactComponentRelation(ac.getId());
|
|
1353
1353
|
logger6.info(
|
|
1354
1354
|
{
|
|
1355
|
-
|
|
1355
|
+
subAgentId: this.getId(),
|
|
1356
1356
|
artifactComponentId: ac.getId()
|
|
1357
1357
|
},
|
|
1358
1358
|
"ArtifactComponent created and linked to agent"
|
|
@@ -1360,7 +1360,7 @@ var Agent = class {
|
|
|
1360
1360
|
} catch (error) {
|
|
1361
1361
|
logger6.error(
|
|
1362
1362
|
{
|
|
1363
|
-
|
|
1363
|
+
subAgentId: this.getId(),
|
|
1364
1364
|
artifactComponentName: artifactComponent2.name,
|
|
1365
1365
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
1366
1366
|
},
|
|
@@ -1380,7 +1380,7 @@ var Agent = class {
|
|
|
1380
1380
|
body: JSON.stringify({
|
|
1381
1381
|
id: `${this.getId()}-dc-${dataComponentId}`,
|
|
1382
1382
|
tenantId: this.tenantId,
|
|
1383
|
-
|
|
1383
|
+
subAgentId: this.getId(),
|
|
1384
1384
|
dataComponentId
|
|
1385
1385
|
})
|
|
1386
1386
|
}
|
|
@@ -1392,7 +1392,7 @@ var Agent = class {
|
|
|
1392
1392
|
}
|
|
1393
1393
|
logger6.info(
|
|
1394
1394
|
{
|
|
1395
|
-
|
|
1395
|
+
subAgentId: this.getId(),
|
|
1396
1396
|
dataComponentId
|
|
1397
1397
|
},
|
|
1398
1398
|
"Created agent-dataComponent relation"
|
|
@@ -1409,7 +1409,7 @@ var Agent = class {
|
|
|
1409
1409
|
body: JSON.stringify({
|
|
1410
1410
|
id: crypto.randomUUID(),
|
|
1411
1411
|
tenantId: this.tenantId,
|
|
1412
|
-
|
|
1412
|
+
subAgentId: this.getId(),
|
|
1413
1413
|
artifactComponentId
|
|
1414
1414
|
})
|
|
1415
1415
|
}
|
|
@@ -1421,7 +1421,7 @@ var Agent = class {
|
|
|
1421
1421
|
}
|
|
1422
1422
|
logger6.info(
|
|
1423
1423
|
{
|
|
1424
|
-
|
|
1424
|
+
subAgentId: this.getId(),
|
|
1425
1425
|
artifactComponentId
|
|
1426
1426
|
},
|
|
1427
1427
|
"Created agent-artifactComponent relation"
|
|
@@ -1432,7 +1432,7 @@ var Agent = class {
|
|
|
1432
1432
|
id: `${this.getId()}-tool-${toolId}`,
|
|
1433
1433
|
tenantId: this.tenantId,
|
|
1434
1434
|
projectId: this.projectId,
|
|
1435
|
-
|
|
1435
|
+
subAgentId: this.getId(),
|
|
1436
1436
|
toolId
|
|
1437
1437
|
};
|
|
1438
1438
|
if (selectedTools !== void 0) {
|
|
@@ -1522,7 +1522,7 @@ var AgentGraph = class {
|
|
|
1522
1522
|
constructor(config) {
|
|
1523
1523
|
__publicField(this, "agents", []);
|
|
1524
1524
|
__publicField(this, "agentMap", /* @__PURE__ */ new Map());
|
|
1525
|
-
__publicField(this, "
|
|
1525
|
+
__publicField(this, "defaultSubAgent");
|
|
1526
1526
|
__publicField(this, "baseURL");
|
|
1527
1527
|
__publicField(this, "tenantId");
|
|
1528
1528
|
__publicField(this, "projectId");
|
|
@@ -1538,7 +1538,7 @@ var AgentGraph = class {
|
|
|
1538
1538
|
__publicField(this, "graphPrompt");
|
|
1539
1539
|
__publicField(this, "stopWhen");
|
|
1540
1540
|
__publicField(this, "dbClient");
|
|
1541
|
-
this.
|
|
1541
|
+
this.defaultSubAgent = config.defaultSubAgent;
|
|
1542
1542
|
this.tenantId = "default";
|
|
1543
1543
|
this.projectId = "default";
|
|
1544
1544
|
this.graphId = config.id;
|
|
@@ -1559,9 +1559,9 @@ var AgentGraph = class {
|
|
|
1559
1559
|
} : void 0;
|
|
1560
1560
|
this.agents = resolveGetter2(config.agents) || [];
|
|
1561
1561
|
this.agentMap = new Map(this.agents.map((agent2) => [agent2.getId(), agent2]));
|
|
1562
|
-
if (this.
|
|
1563
|
-
this.agents.push(this.
|
|
1564
|
-
this.agentMap.set(this.
|
|
1562
|
+
if (this.defaultSubAgent) {
|
|
1563
|
+
this.agents.push(this.defaultSubAgent);
|
|
1564
|
+
this.agentMap.set(this.defaultSubAgent.getId(), this.defaultSubAgent);
|
|
1565
1565
|
}
|
|
1566
1566
|
if (this.models) {
|
|
1567
1567
|
this.propagateImmediateModelSettings();
|
|
@@ -1571,7 +1571,7 @@ var AgentGraph = class {
|
|
|
1571
1571
|
graphId: this.graphId,
|
|
1572
1572
|
tenantId: this.tenantId,
|
|
1573
1573
|
agentCount: this.agents.length,
|
|
1574
|
-
|
|
1574
|
+
defaultSubAgent: this.defaultSubAgent?.getName()
|
|
1575
1575
|
},
|
|
1576
1576
|
"AgentGraph created"
|
|
1577
1577
|
);
|
|
@@ -1646,17 +1646,17 @@ var AgentGraph = class {
|
|
|
1646
1646
|
tools.push(toolId);
|
|
1647
1647
|
}
|
|
1648
1648
|
const dataComponents = [];
|
|
1649
|
-
const
|
|
1650
|
-
if (
|
|
1651
|
-
for (const dataComponent2 of
|
|
1649
|
+
const subAgentDataComponents = internalAgent.getDataComponents();
|
|
1650
|
+
if (subAgentDataComponents) {
|
|
1651
|
+
for (const dataComponent2 of subAgentDataComponents) {
|
|
1652
1652
|
const dataComponentId = dataComponent2.id || dataComponent2.name.toLowerCase().replace(/\s+/g, "-");
|
|
1653
1653
|
dataComponents.push(dataComponentId);
|
|
1654
1654
|
}
|
|
1655
1655
|
}
|
|
1656
1656
|
const artifactComponents = [];
|
|
1657
|
-
const
|
|
1658
|
-
if (
|
|
1659
|
-
for (const artifactComponent2 of
|
|
1657
|
+
const subAgentArtifactComponents = internalAgent.getArtifactComponents();
|
|
1658
|
+
if (subAgentArtifactComponents) {
|
|
1659
|
+
for (const artifactComponent2 of subAgentArtifactComponents) {
|
|
1660
1660
|
const artifactComponentId = artifactComponent2.id || artifactComponent2.name.toLowerCase().replace(/\s+/g, "-");
|
|
1661
1661
|
artifactComponents.push(artifactComponentId);
|
|
1662
1662
|
}
|
|
@@ -1697,8 +1697,8 @@ var AgentGraph = class {
|
|
|
1697
1697
|
id: this.graphId,
|
|
1698
1698
|
name: this.graphName,
|
|
1699
1699
|
description: this.graphDescription,
|
|
1700
|
-
|
|
1701
|
-
|
|
1700
|
+
defaultSubAgentId: this.defaultSubAgent?.getId() || "",
|
|
1701
|
+
subAgents: agentsObject,
|
|
1702
1702
|
contextConfig: this.contextConfig?.toObject(),
|
|
1703
1703
|
models: this.models,
|
|
1704
1704
|
statusUpdates: this.statusUpdateSettings,
|
|
@@ -1737,7 +1737,7 @@ var AgentGraph = class {
|
|
|
1737
1737
|
}
|
|
1738
1738
|
logger8.debug(
|
|
1739
1739
|
{
|
|
1740
|
-
|
|
1740
|
+
subAgentId: agent2.getId(),
|
|
1741
1741
|
toolName,
|
|
1742
1742
|
toolType: toolInstance.constructor.name,
|
|
1743
1743
|
skipDbRegistration
|
|
@@ -1747,7 +1747,7 @@ var AgentGraph = class {
|
|
|
1747
1747
|
} catch (error) {
|
|
1748
1748
|
logger8.error(
|
|
1749
1749
|
{
|
|
1750
|
-
|
|
1750
|
+
subAgentId: agent2.getId(),
|
|
1751
1751
|
toolName,
|
|
1752
1752
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
1753
1753
|
},
|
|
@@ -1853,7 +1853,7 @@ var AgentGraph = class {
|
|
|
1853
1853
|
await agent2.init();
|
|
1854
1854
|
logger8.debug(
|
|
1855
1855
|
{
|
|
1856
|
-
|
|
1856
|
+
subAgentId: agent2.getId(),
|
|
1857
1857
|
graphId: this.graphId
|
|
1858
1858
|
},
|
|
1859
1859
|
"Agent initialized in graph"
|
|
@@ -1861,7 +1861,7 @@ var AgentGraph = class {
|
|
|
1861
1861
|
} catch (error) {
|
|
1862
1862
|
logger8.error(
|
|
1863
1863
|
{
|
|
1864
|
-
|
|
1864
|
+
subAgentId: agent2.getId(),
|
|
1865
1865
|
graphId: this.graphId,
|
|
1866
1866
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
1867
1867
|
},
|
|
@@ -1899,13 +1899,13 @@ var AgentGraph = class {
|
|
|
1899
1899
|
*/
|
|
1900
1900
|
async generate(input, options) {
|
|
1901
1901
|
await this._init();
|
|
1902
|
-
if (!this.
|
|
1902
|
+
if (!this.defaultSubAgent) {
|
|
1903
1903
|
throw new Error("No default agent configured for this graph");
|
|
1904
1904
|
}
|
|
1905
1905
|
logger8.info(
|
|
1906
1906
|
{
|
|
1907
1907
|
graphId: this.graphId,
|
|
1908
|
-
|
|
1908
|
+
defaultSubAgent: this.defaultSubAgent.getName(),
|
|
1909
1909
|
conversationId: options?.conversationId
|
|
1910
1910
|
},
|
|
1911
1911
|
"Generating response with default agent"
|
|
@@ -1918,13 +1918,13 @@ var AgentGraph = class {
|
|
|
1918
1918
|
*/
|
|
1919
1919
|
async stream(input, options) {
|
|
1920
1920
|
await this._init();
|
|
1921
|
-
if (!this.
|
|
1921
|
+
if (!this.defaultSubAgent) {
|
|
1922
1922
|
throw new Error("No default agent configured for this graph");
|
|
1923
1923
|
}
|
|
1924
1924
|
logger8.info(
|
|
1925
1925
|
{
|
|
1926
1926
|
graphId: this.graphId,
|
|
1927
|
-
|
|
1927
|
+
defaultSubAgent: this.defaultSubAgent.getName(),
|
|
1928
1928
|
conversationId: options?.conversationId
|
|
1929
1929
|
},
|
|
1930
1930
|
"Streaming response with default agent"
|
|
@@ -1949,21 +1949,21 @@ var AgentGraph = class {
|
|
|
1949
1949
|
/**
|
|
1950
1950
|
* Run with a specific agent from the graph
|
|
1951
1951
|
*/
|
|
1952
|
-
async runWith(
|
|
1952
|
+
async runWith(subAgentId, input, options) {
|
|
1953
1953
|
await this._init();
|
|
1954
|
-
const agent2 = this.getAgent(
|
|
1954
|
+
const agent2 = this.getAgent(subAgentId);
|
|
1955
1955
|
if (!agent2) {
|
|
1956
|
-
throw new Error(`Agent '${
|
|
1956
|
+
throw new Error(`Agent '${subAgentId}' not found in graph`);
|
|
1957
1957
|
}
|
|
1958
1958
|
if (!this.isInternalAgent(agent2)) {
|
|
1959
1959
|
throw new Error(
|
|
1960
|
-
`Agent '${
|
|
1960
|
+
`Agent '${subAgentId}' is an external agent and cannot be run directly. External agents are only accessible via delegation.`
|
|
1961
1961
|
);
|
|
1962
1962
|
}
|
|
1963
1963
|
logger8.info(
|
|
1964
1964
|
{
|
|
1965
1965
|
graphId: this.graphId,
|
|
1966
|
-
|
|
1966
|
+
subAgentId,
|
|
1967
1967
|
conversationId: options?.conversationId
|
|
1968
1968
|
},
|
|
1969
1969
|
"Running with specific agent"
|
|
@@ -1998,7 +1998,7 @@ var AgentGraph = class {
|
|
|
1998
1998
|
logger8.info(
|
|
1999
1999
|
{
|
|
2000
2000
|
graphId: this.graphId,
|
|
2001
|
-
|
|
2001
|
+
subAgentId: agent2.getId(),
|
|
2002
2002
|
agentType: this.isInternalAgent(agent2) ? "internal" : "external"
|
|
2003
2003
|
},
|
|
2004
2004
|
"Agent added to graph"
|
|
@@ -2015,7 +2015,7 @@ var AgentGraph = class {
|
|
|
2015
2015
|
logger8.info(
|
|
2016
2016
|
{
|
|
2017
2017
|
graphId: this.graphId,
|
|
2018
|
-
|
|
2018
|
+
subAgentId: agentToRemove.getId()
|
|
2019
2019
|
},
|
|
2020
2020
|
"Agent removed from graph"
|
|
2021
2021
|
);
|
|
@@ -2038,13 +2038,13 @@ var AgentGraph = class {
|
|
|
2038
2038
|
/**
|
|
2039
2039
|
* Set the default agent
|
|
2040
2040
|
*/
|
|
2041
|
-
|
|
2042
|
-
this.
|
|
2041
|
+
setdefaultSubAgent(agent2) {
|
|
2042
|
+
this.defaultSubAgent = agent2;
|
|
2043
2043
|
this.addAgent(agent2);
|
|
2044
2044
|
logger8.info(
|
|
2045
2045
|
{
|
|
2046
2046
|
graphId: this.graphId,
|
|
2047
|
-
|
|
2047
|
+
defaultSubAgent: agent2.getId()
|
|
2048
2048
|
},
|
|
2049
2049
|
"Default agent updated"
|
|
2050
2050
|
);
|
|
@@ -2052,8 +2052,8 @@ var AgentGraph = class {
|
|
|
2052
2052
|
/**
|
|
2053
2053
|
* Get the default agent
|
|
2054
2054
|
*/
|
|
2055
|
-
|
|
2056
|
-
return this.
|
|
2055
|
+
getdefaultSubAgent() {
|
|
2056
|
+
return this.defaultSubAgent;
|
|
2057
2057
|
}
|
|
2058
2058
|
/**
|
|
2059
2059
|
* Get the graph ID
|
|
@@ -2112,7 +2112,7 @@ var AgentGraph = class {
|
|
|
2112
2112
|
getStats() {
|
|
2113
2113
|
return {
|
|
2114
2114
|
agentCount: this.agents.length,
|
|
2115
|
-
|
|
2115
|
+
defaultSubAgent: this.defaultSubAgent?.getName() || null,
|
|
2116
2116
|
initialized: this.initialized,
|
|
2117
2117
|
graphId: this.graphId,
|
|
2118
2118
|
tenantId: this.tenantId
|
|
@@ -2126,7 +2126,7 @@ var AgentGraph = class {
|
|
|
2126
2126
|
if (this.agents.length === 0) {
|
|
2127
2127
|
errors.push("Graph must contain at least one agent");
|
|
2128
2128
|
}
|
|
2129
|
-
if (!this.
|
|
2129
|
+
if (!this.defaultSubAgent) {
|
|
2130
2130
|
errors.push("Graph must have a default agent");
|
|
2131
2131
|
}
|
|
2132
2132
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -2423,7 +2423,7 @@ var AgentGraph = class {
|
|
|
2423
2423
|
body: JSON.stringify({
|
|
2424
2424
|
id: this.graphId,
|
|
2425
2425
|
name: this.graphName,
|
|
2426
|
-
|
|
2426
|
+
defaultSubAgentId: this.defaultSubAgent?.getId() || "",
|
|
2427
2427
|
contextConfigId: this.contextConfig?.getId(),
|
|
2428
2428
|
models: this.models
|
|
2429
2429
|
})
|
|
@@ -2441,7 +2441,7 @@ var AgentGraph = class {
|
|
|
2441
2441
|
}
|
|
2442
2442
|
}
|
|
2443
2443
|
async saveRelations() {
|
|
2444
|
-
if (this.
|
|
2444
|
+
if (this.defaultSubAgent) {
|
|
2445
2445
|
try {
|
|
2446
2446
|
const updateUrl = `${this.baseURL}/tenants/${this.tenantId}/agent-graphs/${this.graphId}`;
|
|
2447
2447
|
const updateResponse = await fetch(updateUrl, {
|
|
@@ -2451,7 +2451,7 @@ var AgentGraph = class {
|
|
|
2451
2451
|
},
|
|
2452
2452
|
body: JSON.stringify({
|
|
2453
2453
|
id: this.graphId,
|
|
2454
|
-
|
|
2454
|
+
defaultSubAgentId: this.defaultSubAgent.getId(),
|
|
2455
2455
|
contextConfigId: this.contextConfig?.getId()
|
|
2456
2456
|
})
|
|
2457
2457
|
});
|
|
@@ -2461,7 +2461,7 @@ var AgentGraph = class {
|
|
|
2461
2461
|
logger8.debug(
|
|
2462
2462
|
{
|
|
2463
2463
|
graphId: this.graphId,
|
|
2464
|
-
|
|
2464
|
+
defaultSubAgent: this.defaultSubAgent.getName()
|
|
2465
2465
|
},
|
|
2466
2466
|
"Graph relationships configured"
|
|
2467
2467
|
);
|
|
@@ -2538,8 +2538,8 @@ var AgentGraph = class {
|
|
|
2538
2538
|
},
|
|
2539
2539
|
body: JSON.stringify({
|
|
2540
2540
|
graphId: this.graphId,
|
|
2541
|
-
|
|
2542
|
-
|
|
2541
|
+
sourceSubAgentId: sourceAgent.getId(),
|
|
2542
|
+
targetSubAgentId: targetAgent.getId(),
|
|
2543
2543
|
relationType
|
|
2544
2544
|
})
|
|
2545
2545
|
});
|
|
@@ -2548,8 +2548,8 @@ var AgentGraph = class {
|
|
|
2548
2548
|
if (response.status === 422 && errorText.includes("already exists")) {
|
|
2549
2549
|
logger8.info(
|
|
2550
2550
|
{
|
|
2551
|
-
|
|
2552
|
-
|
|
2551
|
+
sourceSubAgentId: sourceAgent.getId(),
|
|
2552
|
+
targetSubAgentId: targetAgent.getId(),
|
|
2553
2553
|
graphId: this.graphId,
|
|
2554
2554
|
relationType
|
|
2555
2555
|
},
|
|
@@ -2561,8 +2561,8 @@ var AgentGraph = class {
|
|
|
2561
2561
|
}
|
|
2562
2562
|
logger8.info(
|
|
2563
2563
|
{
|
|
2564
|
-
|
|
2565
|
-
|
|
2564
|
+
sourceSubAgentId: sourceAgent.getId(),
|
|
2565
|
+
targetSubAgentId: targetAgent.getId(),
|
|
2566
2566
|
graphId: this.graphId,
|
|
2567
2567
|
relationType
|
|
2568
2568
|
},
|
|
@@ -2571,8 +2571,8 @@ var AgentGraph = class {
|
|
|
2571
2571
|
} catch (error) {
|
|
2572
2572
|
logger8.error(
|
|
2573
2573
|
{
|
|
2574
|
-
|
|
2575
|
-
|
|
2574
|
+
sourceSubAgentId: sourceAgent.getId(),
|
|
2575
|
+
targetSubAgentId: targetAgent.getId(),
|
|
2576
2576
|
graphId: this.graphId,
|
|
2577
2577
|
relationType,
|
|
2578
2578
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -2591,8 +2591,8 @@ var AgentGraph = class {
|
|
|
2591
2591
|
},
|
|
2592
2592
|
body: JSON.stringify({
|
|
2593
2593
|
graphId: this.graphId,
|
|
2594
|
-
|
|
2595
|
-
|
|
2594
|
+
sourceSubAgentId: sourceAgent.getId(),
|
|
2595
|
+
externalSubAgentId: externalAgent2.getId(),
|
|
2596
2596
|
relationType
|
|
2597
2597
|
})
|
|
2598
2598
|
});
|
|
@@ -2601,8 +2601,8 @@ var AgentGraph = class {
|
|
|
2601
2601
|
if (response.status === 422 && errorText.includes("already exists")) {
|
|
2602
2602
|
logger8.info(
|
|
2603
2603
|
{
|
|
2604
|
-
|
|
2605
|
-
|
|
2604
|
+
sourceSubAgentId: sourceAgent.getId(),
|
|
2605
|
+
externalSubAgentId: externalAgent2.getId(),
|
|
2606
2606
|
graphId: this.graphId,
|
|
2607
2607
|
relationType
|
|
2608
2608
|
},
|
|
@@ -2616,8 +2616,8 @@ var AgentGraph = class {
|
|
|
2616
2616
|
}
|
|
2617
2617
|
logger8.info(
|
|
2618
2618
|
{
|
|
2619
|
-
|
|
2620
|
-
|
|
2619
|
+
sourceSubAgentId: sourceAgent.getId(),
|
|
2620
|
+
externalSubAgentId: externalAgent2.getId(),
|
|
2621
2621
|
graphId: this.graphId,
|
|
2622
2622
|
relationType
|
|
2623
2623
|
},
|
|
@@ -2626,8 +2626,8 @@ var AgentGraph = class {
|
|
|
2626
2626
|
} catch (error) {
|
|
2627
2627
|
logger8.error(
|
|
2628
2628
|
{
|
|
2629
|
-
|
|
2630
|
-
|
|
2629
|
+
sourceSubAgentId: sourceAgent.getId(),
|
|
2630
|
+
externalSubAgentId: externalAgent2.getId(),
|
|
2631
2631
|
graphId: this.graphId,
|
|
2632
2632
|
relationType,
|
|
2633
2633
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -2654,7 +2654,7 @@ var AgentGraph = class {
|
|
|
2654
2654
|
await externalAgent2.init();
|
|
2655
2655
|
logger8.debug(
|
|
2656
2656
|
{
|
|
2657
|
-
|
|
2657
|
+
externalSubAgentId: externalAgent2.getId(),
|
|
2658
2658
|
graphId: this.graphId
|
|
2659
2659
|
},
|
|
2660
2660
|
"External agent created in database"
|
|
@@ -2662,7 +2662,7 @@ var AgentGraph = class {
|
|
|
2662
2662
|
} catch (error) {
|
|
2663
2663
|
logger8.error(
|
|
2664
2664
|
{
|
|
2665
|
-
|
|
2665
|
+
externalSubAgentId: externalAgent2.getId(),
|
|
2666
2666
|
graphId: this.graphId,
|
|
2667
2667
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
2668
2668
|
},
|
|
@@ -3376,9 +3376,9 @@ var Project = class {
|
|
|
3376
3376
|
}
|
|
3377
3377
|
}
|
|
3378
3378
|
}
|
|
3379
|
-
const
|
|
3380
|
-
if (
|
|
3381
|
-
for (const dataComponent2 of
|
|
3379
|
+
const subAgentDataComponents = agent2.getDataComponents?.();
|
|
3380
|
+
if (subAgentDataComponents) {
|
|
3381
|
+
for (const dataComponent2 of subAgentDataComponents) {
|
|
3382
3382
|
let dataComponentId;
|
|
3383
3383
|
let dataComponentName;
|
|
3384
3384
|
let dataComponentDescription;
|
|
@@ -3404,9 +3404,9 @@ var Project = class {
|
|
|
3404
3404
|
}
|
|
3405
3405
|
}
|
|
3406
3406
|
}
|
|
3407
|
-
const
|
|
3408
|
-
if (
|
|
3409
|
-
for (const artifactComponent2 of
|
|
3407
|
+
const subAgentArtifactComponents = agent2.getArtifactComponents?.();
|
|
3408
|
+
if (subAgentArtifactComponents) {
|
|
3409
|
+
for (const artifactComponent2 of subAgentArtifactComponents) {
|
|
3410
3410
|
let artifactComponentId;
|
|
3411
3411
|
let artifactComponentName;
|
|
3412
3412
|
let artifactComponentDescription;
|
|
@@ -3685,7 +3685,7 @@ var ExternalAgent = class {
|
|
|
3685
3685
|
await this.upsertExternalAgent();
|
|
3686
3686
|
logger11.info(
|
|
3687
3687
|
{
|
|
3688
|
-
|
|
3688
|
+
externalSubAgentId: this.getId()
|
|
3689
3689
|
},
|
|
3690
3690
|
"External agent initialized successfully"
|
|
3691
3691
|
);
|
|
@@ -3693,7 +3693,7 @@ var ExternalAgent = class {
|
|
|
3693
3693
|
} catch (error) {
|
|
3694
3694
|
logger11.error(
|
|
3695
3695
|
{
|
|
3696
|
-
|
|
3696
|
+
externalSubAgentId: this.getId(),
|
|
3697
3697
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
3698
3698
|
},
|
|
3699
3699
|
"Failed to initialize external agent"
|
|
@@ -3735,7 +3735,7 @@ var ExternalAgent = class {
|
|
|
3735
3735
|
if (updateResponse.ok) {
|
|
3736
3736
|
logger11.info(
|
|
3737
3737
|
{
|
|
3738
|
-
|
|
3738
|
+
externalSubAgentId: this.getId()
|
|
3739
3739
|
},
|
|
3740
3740
|
"External agent updated successfully"
|
|
3741
3741
|
);
|
|
@@ -3744,7 +3744,7 @@ var ExternalAgent = class {
|
|
|
3744
3744
|
if (updateResponse.status === 404) {
|
|
3745
3745
|
logger11.info(
|
|
3746
3746
|
{
|
|
3747
|
-
|
|
3747
|
+
externalSubAgentId: this.getId()
|
|
3748
3748
|
},
|
|
3749
3749
|
"External agent not found, creating new external agent"
|
|
3750
3750
|
);
|
|
@@ -3766,7 +3766,7 @@ var ExternalAgent = class {
|
|
|
3766
3766
|
}
|
|
3767
3767
|
logger11.info(
|
|
3768
3768
|
{
|
|
3769
|
-
|
|
3769
|
+
externalSubAgentId: this.getId()
|
|
3770
3770
|
},
|
|
3771
3771
|
"External agent created successfully"
|
|
3772
3772
|
);
|
|
@@ -3854,7 +3854,7 @@ var Runner = class _Runner {
|
|
|
3854
3854
|
logger12.info(
|
|
3855
3855
|
{
|
|
3856
3856
|
graphId: graph.getId(),
|
|
3857
|
-
|
|
3857
|
+
defaultSubAgent: graph.getdefaultSubAgent()?.getName(),
|
|
3858
3858
|
maxTurns,
|
|
3859
3859
|
initialMessageCount: messageHistory.length
|
|
3860
3860
|
},
|
|
@@ -3881,7 +3881,7 @@ var Runner = class _Runner {
|
|
|
3881
3881
|
);
|
|
3882
3882
|
return {
|
|
3883
3883
|
finalOutput: response,
|
|
3884
|
-
agent: graph.
|
|
3884
|
+
agent: graph.getdefaultSubAgent() || {},
|
|
3885
3885
|
turnCount,
|
|
3886
3886
|
usage: { inputTokens: 0, outputTokens: 0 },
|
|
3887
3887
|
metadata: {
|
|
@@ -3908,7 +3908,7 @@ var Runner = class _Runner {
|
|
|
3908
3908
|
logger12.info(
|
|
3909
3909
|
{
|
|
3910
3910
|
graphId: graph.getId(),
|
|
3911
|
-
|
|
3911
|
+
defaultSubAgent: graph.getdefaultSubAgent()?.getName()
|
|
3912
3912
|
},
|
|
3913
3913
|
"Starting graph stream"
|
|
3914
3914
|
);
|
|
@@ -3973,14 +3973,14 @@ var Runner = class _Runner {
|
|
|
3973
3973
|
if (!graph.getId()) {
|
|
3974
3974
|
errors.push("Graph ID is required");
|
|
3975
3975
|
}
|
|
3976
|
-
const
|
|
3977
|
-
if (!
|
|
3976
|
+
const defaultSubAgent = graph.getdefaultSubAgent();
|
|
3977
|
+
if (!defaultSubAgent) {
|
|
3978
3978
|
errors.push("Default agent is required");
|
|
3979
3979
|
} else {
|
|
3980
|
-
if (!
|
|
3980
|
+
if (!defaultSubAgent.getName()) {
|
|
3981
3981
|
errors.push("Default agent name is required");
|
|
3982
3982
|
}
|
|
3983
|
-
if (!
|
|
3983
|
+
if (!defaultSubAgent.getInstructions()) {
|
|
3984
3984
|
errors.push("Default agent instructions are required");
|
|
3985
3985
|
}
|
|
3986
3986
|
}
|
|
@@ -4003,14 +4003,14 @@ var Runner = class _Runner {
|
|
|
4003
4003
|
*/
|
|
4004
4004
|
static async getExecutionStats(graph, messages, options) {
|
|
4005
4005
|
const agents = graph.getAgents();
|
|
4006
|
-
const
|
|
4006
|
+
const defaultSubAgent = graph.getdefaultSubAgent();
|
|
4007
4007
|
const messageCount = Array.isArray(messages) ? messages.length : 1;
|
|
4008
4008
|
return {
|
|
4009
4009
|
estimatedTurns: Math.min(Math.max(messageCount, 1), options?.maxTurns || 10),
|
|
4010
4010
|
estimatedTokens: messageCount * 100,
|
|
4011
4011
|
// Rough estimate
|
|
4012
4012
|
agentCount: agents.length,
|
|
4013
|
-
|
|
4013
|
+
defaultSubAgent: defaultSubAgent?.getName()
|
|
4014
4014
|
};
|
|
4015
4015
|
}
|
|
4016
4016
|
};
|