@inkeep/agents-sdk 0.0.0-dev-20251009233425 → 0.0.0-dev-20251010064032
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 +115 -118
- package/dist/index.d.cts +41 -52
- package/dist/index.d.ts +41 -52
- package/dist/index.js +114 -117
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -689,20 +689,18 @@ function resolveGetter(value) {
|
|
|
689
689
|
}
|
|
690
690
|
return value;
|
|
691
691
|
}
|
|
692
|
-
var
|
|
692
|
+
var SubAgent = class {
|
|
693
693
|
constructor(config) {
|
|
694
694
|
__publicField(this, "config");
|
|
695
695
|
__publicField(this, "type", "internal");
|
|
696
696
|
__publicField(this, "baseURL");
|
|
697
697
|
__publicField(this, "tenantId");
|
|
698
698
|
__publicField(this, "projectId");
|
|
699
|
-
__publicField(this, "graphId");
|
|
700
699
|
__publicField(this, "initialized", false);
|
|
701
700
|
this.config = { ...config, type: "internal" };
|
|
702
701
|
this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
|
|
703
702
|
this.tenantId = "default";
|
|
704
703
|
this.projectId = "default";
|
|
705
|
-
this.graphId = "default";
|
|
706
704
|
logger6.info(
|
|
707
705
|
{
|
|
708
706
|
tenantId: this.tenantId,
|
|
@@ -712,11 +710,10 @@ var Agent = class {
|
|
|
712
710
|
"Agent constructor initialized"
|
|
713
711
|
);
|
|
714
712
|
}
|
|
715
|
-
// Set context (tenantId, projectId,
|
|
716
|
-
setContext(tenantId, projectId,
|
|
713
|
+
// Set context (tenantId, projectId, and baseURL) from external source (graph, CLI, etc)
|
|
714
|
+
setContext(tenantId, projectId, baseURL) {
|
|
717
715
|
this.tenantId = tenantId;
|
|
718
716
|
this.projectId = projectId;
|
|
719
|
-
this.graphId = graphId;
|
|
720
717
|
if (baseURL) {
|
|
721
718
|
this.baseURL = baseURL;
|
|
722
719
|
}
|
|
@@ -1492,7 +1489,7 @@ function resolveGetter2(value) {
|
|
|
1492
1489
|
}
|
|
1493
1490
|
var AgentGraph = class {
|
|
1494
1491
|
constructor(config) {
|
|
1495
|
-
__publicField(this, "
|
|
1492
|
+
__publicField(this, "subAgents", []);
|
|
1496
1493
|
__publicField(this, "agentMap", /* @__PURE__ */ new Map());
|
|
1497
1494
|
__publicField(this, "defaultSubAgent");
|
|
1498
1495
|
__publicField(this, "baseURL");
|
|
@@ -1529,10 +1526,10 @@ var AgentGraph = class {
|
|
|
1529
1526
|
this.stopWhen = config.stopWhen ? {
|
|
1530
1527
|
transferCountIs: config.stopWhen.transferCountIs
|
|
1531
1528
|
} : void 0;
|
|
1532
|
-
this.
|
|
1533
|
-
this.agentMap = new Map(this.
|
|
1529
|
+
this.subAgents = resolveGetter2(config.subAgents) || [];
|
|
1530
|
+
this.agentMap = new Map(this.subAgents.map((agent) => [agent.getId(), agent]));
|
|
1534
1531
|
if (this.defaultSubAgent) {
|
|
1535
|
-
this.
|
|
1532
|
+
this.subAgents.push(this.defaultSubAgent);
|
|
1536
1533
|
this.agentMap.set(this.defaultSubAgent.getId(), this.defaultSubAgent);
|
|
1537
1534
|
}
|
|
1538
1535
|
if (this.models) {
|
|
@@ -1542,7 +1539,7 @@ var AgentGraph = class {
|
|
|
1542
1539
|
{
|
|
1543
1540
|
graphId: this.graphId,
|
|
1544
1541
|
tenantId: this.tenantId,
|
|
1545
|
-
agentCount: this.
|
|
1542
|
+
agentCount: this.subAgents.length,
|
|
1546
1543
|
defaultSubAgent: this.defaultSubAgent?.getName()
|
|
1547
1544
|
},
|
|
1548
1545
|
"AgentGraph created"
|
|
@@ -1559,9 +1556,9 @@ var AgentGraph = class {
|
|
|
1559
1556
|
this.tenantId = tenantId;
|
|
1560
1557
|
this.projectId = projectId;
|
|
1561
1558
|
this.baseURL = apiUrl;
|
|
1562
|
-
for (const
|
|
1563
|
-
if (this.isInternalAgent(
|
|
1564
|
-
const internalAgent =
|
|
1559
|
+
for (const agent of this.subAgents) {
|
|
1560
|
+
if (this.isInternalAgent(agent)) {
|
|
1561
|
+
const internalAgent = agent;
|
|
1565
1562
|
if (internalAgent.setContext) {
|
|
1566
1563
|
internalAgent.setContext(tenantId, projectId, apiUrl);
|
|
1567
1564
|
}
|
|
@@ -1574,7 +1571,7 @@ var AgentGraph = class {
|
|
|
1574
1571
|
}
|
|
1575
1572
|
}
|
|
1576
1573
|
} else {
|
|
1577
|
-
const externalAgent2 =
|
|
1574
|
+
const externalAgent2 = agent;
|
|
1578
1575
|
if (externalAgent2.setContext) {
|
|
1579
1576
|
externalAgent2.setContext(tenantId, apiUrl);
|
|
1580
1577
|
}
|
|
@@ -1598,9 +1595,9 @@ var AgentGraph = class {
|
|
|
1598
1595
|
*/
|
|
1599
1596
|
async toFullGraphDefinition() {
|
|
1600
1597
|
const agentsObject = {};
|
|
1601
|
-
for (const
|
|
1602
|
-
if (this.isInternalAgent(
|
|
1603
|
-
const internalAgent =
|
|
1598
|
+
for (const agent of this.subAgents) {
|
|
1599
|
+
if (this.isInternalAgent(agent)) {
|
|
1600
|
+
const internalAgent = agent;
|
|
1604
1601
|
const transfers = internalAgent.getTransfers();
|
|
1605
1602
|
const delegates = internalAgent.getDelegates();
|
|
1606
1603
|
const tools = [];
|
|
@@ -1653,7 +1650,7 @@ var AgentGraph = class {
|
|
|
1653
1650
|
type: "internal"
|
|
1654
1651
|
};
|
|
1655
1652
|
} else {
|
|
1656
|
-
const externalAgent2 =
|
|
1653
|
+
const externalAgent2 = agent;
|
|
1657
1654
|
agentsObject[externalAgent2.getId()] = {
|
|
1658
1655
|
id: externalAgent2.getId(),
|
|
1659
1656
|
name: externalAgent2.getName(),
|
|
@@ -1685,11 +1682,11 @@ var AgentGraph = class {
|
|
|
1685
1682
|
async initializeAllTools() {
|
|
1686
1683
|
logger8.info({ graphId: this.graphId }, "Initializing all tools in graph");
|
|
1687
1684
|
const toolInitPromises = [];
|
|
1688
|
-
for (const
|
|
1689
|
-
if (!
|
|
1685
|
+
for (const agent of this.subAgents) {
|
|
1686
|
+
if (!agent.getTools) {
|
|
1690
1687
|
continue;
|
|
1691
1688
|
}
|
|
1692
|
-
const internalAgent =
|
|
1689
|
+
const internalAgent = agent;
|
|
1693
1690
|
const agentTools = internalAgent.getTools();
|
|
1694
1691
|
for (const [toolName, toolInstance] of Object.entries(agentTools)) {
|
|
1695
1692
|
if (toolInstance && typeof toolInstance === "object") {
|
|
@@ -1709,7 +1706,7 @@ var AgentGraph = class {
|
|
|
1709
1706
|
}
|
|
1710
1707
|
logger8.debug(
|
|
1711
1708
|
{
|
|
1712
|
-
subAgentId:
|
|
1709
|
+
subAgentId: agent.getId(),
|
|
1713
1710
|
toolName,
|
|
1714
1711
|
toolType: toolInstance.constructor.name,
|
|
1715
1712
|
skipDbRegistration
|
|
@@ -1719,7 +1716,7 @@ var AgentGraph = class {
|
|
|
1719
1716
|
} catch (error) {
|
|
1720
1717
|
logger8.error(
|
|
1721
1718
|
{
|
|
1722
|
-
subAgentId:
|
|
1719
|
+
subAgentId: agent.getId(),
|
|
1723
1720
|
toolName,
|
|
1724
1721
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
1725
1722
|
},
|
|
@@ -1750,7 +1747,7 @@ var AgentGraph = class {
|
|
|
1750
1747
|
logger8.info(
|
|
1751
1748
|
{
|
|
1752
1749
|
graphId: this.graphId,
|
|
1753
|
-
agentCount: this.
|
|
1750
|
+
agentCount: this.subAgents.length
|
|
1754
1751
|
},
|
|
1755
1752
|
"Initializing agent graph using new graph endpoint"
|
|
1756
1753
|
);
|
|
@@ -1804,7 +1801,7 @@ var AgentGraph = class {
|
|
|
1804
1801
|
logger8.info(
|
|
1805
1802
|
{
|
|
1806
1803
|
graphId: this.graphId,
|
|
1807
|
-
agentCount: this.
|
|
1804
|
+
agentCount: this.subAgents.length
|
|
1808
1805
|
},
|
|
1809
1806
|
"Initializing agent graph"
|
|
1810
1807
|
);
|
|
@@ -1819,13 +1816,13 @@ var AgentGraph = class {
|
|
|
1819
1816
|
"Context configuration initialized for graph"
|
|
1820
1817
|
);
|
|
1821
1818
|
}
|
|
1822
|
-
const initPromises = this.
|
|
1819
|
+
const initPromises = this.subAgents.map(async (agent) => {
|
|
1823
1820
|
try {
|
|
1824
|
-
|
|
1825
|
-
await
|
|
1821
|
+
agent.config.graphId = this.graphId;
|
|
1822
|
+
await agent.init();
|
|
1826
1823
|
logger8.debug(
|
|
1827
1824
|
{
|
|
1828
|
-
subAgentId:
|
|
1825
|
+
subAgentId: agent.getId(),
|
|
1829
1826
|
graphId: this.graphId
|
|
1830
1827
|
},
|
|
1831
1828
|
"Agent initialized in graph"
|
|
@@ -1833,7 +1830,7 @@ var AgentGraph = class {
|
|
|
1833
1830
|
} catch (error) {
|
|
1834
1831
|
logger8.error(
|
|
1835
1832
|
{
|
|
1836
|
-
subAgentId:
|
|
1833
|
+
subAgentId: agent.getId(),
|
|
1837
1834
|
graphId: this.graphId,
|
|
1838
1835
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
1839
1836
|
},
|
|
@@ -1851,7 +1848,7 @@ var AgentGraph = class {
|
|
|
1851
1848
|
logger8.info(
|
|
1852
1849
|
{
|
|
1853
1850
|
graphId: this.graphId,
|
|
1854
|
-
agentCount: this.
|
|
1851
|
+
agentCount: this.subAgents.length
|
|
1855
1852
|
},
|
|
1856
1853
|
"Agent graph initialized successfully"
|
|
1857
1854
|
);
|
|
@@ -1923,11 +1920,11 @@ var AgentGraph = class {
|
|
|
1923
1920
|
*/
|
|
1924
1921
|
async runWith(subAgentId, input, options) {
|
|
1925
1922
|
await this._init();
|
|
1926
|
-
const
|
|
1927
|
-
if (!
|
|
1923
|
+
const agent = this.getAgent(subAgentId);
|
|
1924
|
+
if (!agent) {
|
|
1928
1925
|
throw new Error(`Agent '${subAgentId}' not found in graph`);
|
|
1929
1926
|
}
|
|
1930
|
-
if (!this.isInternalAgent(
|
|
1927
|
+
if (!this.isInternalAgent(agent)) {
|
|
1931
1928
|
throw new Error(
|
|
1932
1929
|
`Agent '${subAgentId}' is an external agent and cannot be run directly. External agents are only accessible via delegation.`
|
|
1933
1930
|
);
|
|
@@ -1943,7 +1940,7 @@ var AgentGraph = class {
|
|
|
1943
1940
|
const response = await this.executeWithBackend(input, options);
|
|
1944
1941
|
return {
|
|
1945
1942
|
finalOutput: response,
|
|
1946
|
-
agent
|
|
1943
|
+
agent,
|
|
1947
1944
|
turnCount: 1,
|
|
1948
1945
|
usage: { inputTokens: 0, outputTokens: 0 },
|
|
1949
1946
|
metadata: {
|
|
@@ -1961,17 +1958,17 @@ var AgentGraph = class {
|
|
|
1961
1958
|
/**
|
|
1962
1959
|
* Add an agent to the graph
|
|
1963
1960
|
*/
|
|
1964
|
-
|
|
1965
|
-
this.
|
|
1966
|
-
this.agentMap.set(
|
|
1967
|
-
if (this.models && this.isInternalAgent(
|
|
1968
|
-
this.propagateModelSettingsToAgent(
|
|
1961
|
+
addSubAgent(agent) {
|
|
1962
|
+
this.subAgents.push(agent);
|
|
1963
|
+
this.agentMap.set(agent.getId(), agent);
|
|
1964
|
+
if (this.models && this.isInternalAgent(agent)) {
|
|
1965
|
+
this.propagateModelSettingsToAgent(agent);
|
|
1969
1966
|
}
|
|
1970
1967
|
logger8.info(
|
|
1971
1968
|
{
|
|
1972
1969
|
graphId: this.graphId,
|
|
1973
|
-
subAgentId:
|
|
1974
|
-
agentType: this.isInternalAgent(
|
|
1970
|
+
subAgentId: agent.getId(),
|
|
1971
|
+
agentType: this.isInternalAgent(agent) ? "internal" : "external"
|
|
1975
1972
|
},
|
|
1976
1973
|
"Agent added to graph"
|
|
1977
1974
|
);
|
|
@@ -1979,11 +1976,11 @@ var AgentGraph = class {
|
|
|
1979
1976
|
/**
|
|
1980
1977
|
* Remove an agent from the graph
|
|
1981
1978
|
*/
|
|
1982
|
-
|
|
1979
|
+
removeSubAgent(id) {
|
|
1983
1980
|
const agentToRemove = this.agentMap.get(id);
|
|
1984
1981
|
if (agentToRemove) {
|
|
1985
1982
|
this.agentMap.delete(agentToRemove.getId());
|
|
1986
|
-
this.
|
|
1983
|
+
this.subAgents = this.subAgents.filter((agent) => agent.getId() !== agentToRemove.getId());
|
|
1987
1984
|
logger8.info(
|
|
1988
1985
|
{
|
|
1989
1986
|
graphId: this.graphId,
|
|
@@ -1998,25 +1995,25 @@ var AgentGraph = class {
|
|
|
1998
1995
|
/**
|
|
1999
1996
|
* Get all agents in the graph
|
|
2000
1997
|
*/
|
|
2001
|
-
|
|
2002
|
-
return this.
|
|
1998
|
+
getSubAgents() {
|
|
1999
|
+
return this.subAgents;
|
|
2003
2000
|
}
|
|
2004
2001
|
/**
|
|
2005
2002
|
* Get all agent ids (unified method for all agent types)
|
|
2006
2003
|
*/
|
|
2007
|
-
|
|
2004
|
+
getSubAgentIds() {
|
|
2008
2005
|
return Array.from(this.agentMap.keys());
|
|
2009
2006
|
}
|
|
2010
2007
|
/**
|
|
2011
2008
|
* Set the default agent
|
|
2012
2009
|
*/
|
|
2013
|
-
setdefaultSubAgent(
|
|
2014
|
-
this.defaultSubAgent =
|
|
2015
|
-
this.
|
|
2010
|
+
setdefaultSubAgent(agent) {
|
|
2011
|
+
this.defaultSubAgent = agent;
|
|
2012
|
+
this.addSubAgent(agent);
|
|
2016
2013
|
logger8.info(
|
|
2017
2014
|
{
|
|
2018
2015
|
graphId: this.graphId,
|
|
2019
|
-
defaultSubAgent:
|
|
2016
|
+
defaultSubAgent: agent.getId()
|
|
2020
2017
|
},
|
|
2021
2018
|
"Default agent updated"
|
|
2022
2019
|
);
|
|
@@ -2083,7 +2080,7 @@ var AgentGraph = class {
|
|
|
2083
2080
|
*/
|
|
2084
2081
|
getStats() {
|
|
2085
2082
|
return {
|
|
2086
|
-
agentCount: this.
|
|
2083
|
+
agentCount: this.subAgents.length,
|
|
2087
2084
|
defaultSubAgent: this.defaultSubAgent?.getName() || null,
|
|
2088
2085
|
initialized: this.initialized,
|
|
2089
2086
|
graphId: this.graphId,
|
|
@@ -2095,35 +2092,35 @@ var AgentGraph = class {
|
|
|
2095
2092
|
*/
|
|
2096
2093
|
validate() {
|
|
2097
2094
|
const errors = [];
|
|
2098
|
-
if (this.
|
|
2095
|
+
if (this.subAgents.length === 0) {
|
|
2099
2096
|
errors.push("Graph must contain at least one agent");
|
|
2100
2097
|
}
|
|
2101
2098
|
if (!this.defaultSubAgent) {
|
|
2102
2099
|
errors.push("Graph must have a default agent");
|
|
2103
2100
|
}
|
|
2104
2101
|
const names = /* @__PURE__ */ new Set();
|
|
2105
|
-
for (const
|
|
2106
|
-
const name =
|
|
2102
|
+
for (const agent of this.subAgents) {
|
|
2103
|
+
const name = agent.getName();
|
|
2107
2104
|
if (names.has(name)) {
|
|
2108
2105
|
errors.push(`Duplicate agent name: ${name}`);
|
|
2109
2106
|
}
|
|
2110
2107
|
names.add(name);
|
|
2111
2108
|
}
|
|
2112
|
-
for (const
|
|
2113
|
-
if (!this.isInternalAgent(
|
|
2114
|
-
const transfers =
|
|
2109
|
+
for (const agent of this.subAgents) {
|
|
2110
|
+
if (!this.isInternalAgent(agent)) continue;
|
|
2111
|
+
const transfers = agent.getTransfers();
|
|
2115
2112
|
for (const transferAgent of transfers) {
|
|
2116
2113
|
if (!this.agentMap.has(transferAgent.getName())) {
|
|
2117
2114
|
errors.push(
|
|
2118
|
-
`Agent '${
|
|
2115
|
+
`Agent '${agent.getName()}' has transfer to '${transferAgent.getName()}' which is not in the graph`
|
|
2119
2116
|
);
|
|
2120
2117
|
}
|
|
2121
2118
|
}
|
|
2122
|
-
const delegates =
|
|
2119
|
+
const delegates = agent.getDelegates();
|
|
2123
2120
|
for (const delegateAgent of delegates) {
|
|
2124
2121
|
if (!this.agentMap.has(delegateAgent.getName())) {
|
|
2125
2122
|
errors.push(
|
|
2126
|
-
`Agent '${
|
|
2123
|
+
`Agent '${agent.getName()}' has delegation to '${delegateAgent.getName()}' which is not in the graph`
|
|
2127
2124
|
);
|
|
2128
2125
|
}
|
|
2129
2126
|
}
|
|
@@ -2142,8 +2139,8 @@ var AgentGraph = class {
|
|
|
2142
2139
|
/**
|
|
2143
2140
|
* Type guard to check if an agent is an internal AgentInterface
|
|
2144
2141
|
*/
|
|
2145
|
-
isInternalAgent(
|
|
2146
|
-
return "getTransfers" in
|
|
2142
|
+
isInternalAgent(agent) {
|
|
2143
|
+
return "getTransfers" in agent && typeof agent.getTransfers === "function";
|
|
2147
2144
|
}
|
|
2148
2145
|
/**
|
|
2149
2146
|
* Get project-level model settingsuration defaults
|
|
@@ -2207,9 +2204,9 @@ var AgentGraph = class {
|
|
|
2207
2204
|
}
|
|
2208
2205
|
}
|
|
2209
2206
|
await this.applyStopWhenInheritance();
|
|
2210
|
-
for (const
|
|
2211
|
-
if (this.isInternalAgent(
|
|
2212
|
-
this.propagateModelSettingsToAgent(
|
|
2207
|
+
for (const agent of this.subAgents) {
|
|
2208
|
+
if (this.isInternalAgent(agent)) {
|
|
2209
|
+
this.propagateModelSettingsToAgent(agent);
|
|
2213
2210
|
}
|
|
2214
2211
|
}
|
|
2215
2212
|
}
|
|
@@ -2228,9 +2225,9 @@ var AgentGraph = class {
|
|
|
2228
2225
|
this.stopWhen.transferCountIs = 10;
|
|
2229
2226
|
}
|
|
2230
2227
|
if (projectStopWhen?.stepCountIs !== void 0) {
|
|
2231
|
-
for (const
|
|
2232
|
-
if (this.isInternalAgent(
|
|
2233
|
-
const internalAgent =
|
|
2228
|
+
for (const agent of this.subAgents) {
|
|
2229
|
+
if (this.isInternalAgent(agent)) {
|
|
2230
|
+
const internalAgent = agent;
|
|
2234
2231
|
if (!internalAgent.config.stopWhen) {
|
|
2235
2232
|
internalAgent.config.stopWhen = {};
|
|
2236
2233
|
}
|
|
@@ -2252,19 +2249,19 @@ var AgentGraph = class {
|
|
|
2252
2249
|
/**
|
|
2253
2250
|
* Propagate graph-level model settings to agents (supporting partial inheritance)
|
|
2254
2251
|
*/
|
|
2255
|
-
propagateModelSettingsToAgent(
|
|
2252
|
+
propagateModelSettingsToAgent(agent) {
|
|
2256
2253
|
if (this.models) {
|
|
2257
|
-
if (!
|
|
2258
|
-
|
|
2254
|
+
if (!agent.config.models) {
|
|
2255
|
+
agent.config.models = {};
|
|
2259
2256
|
}
|
|
2260
|
-
if (!
|
|
2261
|
-
|
|
2257
|
+
if (!agent.config.models.base && this.models.base) {
|
|
2258
|
+
agent.config.models.base = this.models.base;
|
|
2262
2259
|
}
|
|
2263
|
-
if (!
|
|
2264
|
-
|
|
2260
|
+
if (!agent.config.models.structuredOutput && this.models.structuredOutput) {
|
|
2261
|
+
agent.config.models.structuredOutput = this.models.structuredOutput;
|
|
2265
2262
|
}
|
|
2266
|
-
if (!
|
|
2267
|
-
|
|
2263
|
+
if (!agent.config.models.summarizer && this.models.summarizer) {
|
|
2264
|
+
agent.config.models.summarizer = this.models.summarizer;
|
|
2268
2265
|
}
|
|
2269
2266
|
}
|
|
2270
2267
|
}
|
|
@@ -2272,17 +2269,17 @@ var AgentGraph = class {
|
|
|
2272
2269
|
* Immediately propagate graph-level models to all agents during construction
|
|
2273
2270
|
*/
|
|
2274
2271
|
propagateImmediateModelSettings() {
|
|
2275
|
-
for (const
|
|
2276
|
-
if (this.isInternalAgent(
|
|
2277
|
-
this.propagateModelSettingsToAgent(
|
|
2272
|
+
for (const agent of this.subAgents) {
|
|
2273
|
+
if (this.isInternalAgent(agent)) {
|
|
2274
|
+
this.propagateModelSettingsToAgent(agent);
|
|
2278
2275
|
}
|
|
2279
2276
|
}
|
|
2280
2277
|
}
|
|
2281
2278
|
/**
|
|
2282
2279
|
* Type guard to check if an agent is an external AgentInterface
|
|
2283
2280
|
*/
|
|
2284
|
-
isExternalAgent(
|
|
2285
|
-
return !this.isInternalAgent(
|
|
2281
|
+
isExternalAgent(agent) {
|
|
2282
|
+
return !this.isInternalAgent(agent);
|
|
2286
2283
|
}
|
|
2287
2284
|
/**
|
|
2288
2285
|
* Execute agent using the backend system instead of local runner
|
|
@@ -2451,21 +2448,21 @@ var AgentGraph = class {
|
|
|
2451
2448
|
}
|
|
2452
2449
|
async createAgentRelations() {
|
|
2453
2450
|
const allRelationPromises = [];
|
|
2454
|
-
for (const
|
|
2455
|
-
if (this.isInternalAgent(
|
|
2456
|
-
const transfers =
|
|
2451
|
+
for (const agent of this.subAgents) {
|
|
2452
|
+
if (this.isInternalAgent(agent)) {
|
|
2453
|
+
const transfers = agent.getTransfers();
|
|
2457
2454
|
for (const transferAgent of transfers) {
|
|
2458
2455
|
allRelationPromises.push(
|
|
2459
|
-
this.createInternalAgentRelation(
|
|
2456
|
+
this.createInternalAgentRelation(agent, transferAgent, "transfer")
|
|
2460
2457
|
);
|
|
2461
2458
|
}
|
|
2462
|
-
const delegates =
|
|
2459
|
+
const delegates = agent.getDelegates();
|
|
2463
2460
|
for (const delegate of delegates) {
|
|
2464
2461
|
if (delegate.type === "external") {
|
|
2465
|
-
allRelationPromises.push(this.createExternalAgentRelation(
|
|
2462
|
+
allRelationPromises.push(this.createExternalAgentRelation(agent, delegate, "delegate"));
|
|
2466
2463
|
} else {
|
|
2467
2464
|
allRelationPromises.push(
|
|
2468
|
-
this.createInternalAgentRelation(
|
|
2465
|
+
this.createInternalAgentRelation(agent, delegate, "delegate")
|
|
2469
2466
|
);
|
|
2470
2467
|
}
|
|
2471
2468
|
}
|
|
@@ -2613,7 +2610,7 @@ var AgentGraph = class {
|
|
|
2613
2610
|
* Create external agents in the database
|
|
2614
2611
|
*/
|
|
2615
2612
|
async createExternalAgents() {
|
|
2616
|
-
const externalAgents2 = this.
|
|
2613
|
+
const externalAgents2 = this.subAgents.filter((agent) => this.isExternalAgent(agent));
|
|
2617
2614
|
logger8.info(
|
|
2618
2615
|
{
|
|
2619
2616
|
graphId: this.graphId,
|
|
@@ -3285,11 +3282,11 @@ var Project = class {
|
|
|
3285
3282
|
}
|
|
3286
3283
|
}
|
|
3287
3284
|
}
|
|
3288
|
-
for (const
|
|
3289
|
-
if (
|
|
3285
|
+
for (const agent of graph.getSubAgents()) {
|
|
3286
|
+
if (agent.type === "external") {
|
|
3290
3287
|
continue;
|
|
3291
3288
|
}
|
|
3292
|
-
const agentTools =
|
|
3289
|
+
const agentTools = agent.getTools();
|
|
3293
3290
|
for (const [, toolInstance] of Object.entries(agentTools)) {
|
|
3294
3291
|
const actualTool = toolInstance;
|
|
3295
3292
|
const toolId = actualTool.getId();
|
|
@@ -3348,7 +3345,7 @@ var Project = class {
|
|
|
3348
3345
|
}
|
|
3349
3346
|
}
|
|
3350
3347
|
}
|
|
3351
|
-
const subAgentDataComponents =
|
|
3348
|
+
const subAgentDataComponents = agent.getDataComponents?.();
|
|
3352
3349
|
if (subAgentDataComponents) {
|
|
3353
3350
|
for (const dataComponent2 of subAgentDataComponents) {
|
|
3354
3351
|
let dataComponentId;
|
|
@@ -3376,7 +3373,7 @@ var Project = class {
|
|
|
3376
3373
|
}
|
|
3377
3374
|
}
|
|
3378
3375
|
}
|
|
3379
|
-
const subAgentArtifactComponents =
|
|
3376
|
+
const subAgentArtifactComponents = agent.getArtifactComponents?.();
|
|
3380
3377
|
if (subAgentArtifactComponents) {
|
|
3381
3378
|
for (const artifactComponent2 of subAgentArtifactComponents) {
|
|
3382
3379
|
let artifactComponentId;
|
|
@@ -3506,13 +3503,13 @@ function agentGraph(config) {
|
|
|
3506
3503
|
function project(config) {
|
|
3507
3504
|
return new Project(config);
|
|
3508
3505
|
}
|
|
3509
|
-
function
|
|
3506
|
+
function subAgent(config) {
|
|
3510
3507
|
if (!config.id) {
|
|
3511
3508
|
throw new Error(
|
|
3512
|
-
"Agent ID is required. Agents must have stable IDs for consistency across deployments."
|
|
3509
|
+
"Sub-Agent ID is required. Sub-Agents must have stable IDs for consistency across deployments."
|
|
3513
3510
|
);
|
|
3514
3511
|
}
|
|
3515
|
-
return new
|
|
3512
|
+
return new SubAgent(config);
|
|
3516
3513
|
}
|
|
3517
3514
|
function credential(config) {
|
|
3518
3515
|
return CredentialReferenceApiInsertSchema.parse(config);
|
|
@@ -3567,17 +3564,6 @@ function functionTool(config) {
|
|
|
3567
3564
|
return new FunctionTool(config);
|
|
3568
3565
|
}
|
|
3569
3566
|
|
|
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
3567
|
// src/utils/validateFunction.ts
|
|
3582
3568
|
function validateFunction(value, name) {
|
|
3583
3569
|
if (typeof value !== "function") {
|
|
@@ -3587,7 +3573,7 @@ function validateFunction(value, name) {
|
|
|
3587
3573
|
|
|
3588
3574
|
// src/builders.ts
|
|
3589
3575
|
var TransferConfigSchema = z.object({
|
|
3590
|
-
agent: z.instanceof(
|
|
3576
|
+
agent: z.instanceof(SubAgent),
|
|
3591
3577
|
description: z.string().optional()
|
|
3592
3578
|
});
|
|
3593
3579
|
function transfer(targetAgent, description, condition) {
|
|
@@ -3606,6 +3592,17 @@ function transfer(targetAgent, description, condition) {
|
|
|
3606
3592
|
return config;
|
|
3607
3593
|
}
|
|
3608
3594
|
|
|
3595
|
+
// src/credential-ref.ts
|
|
3596
|
+
function credentialRef(id) {
|
|
3597
|
+
return {
|
|
3598
|
+
__type: "credential-ref",
|
|
3599
|
+
id
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
function isCredentialReference(value) {
|
|
3603
|
+
return value && typeof value === "object" && value.__type === "credential-ref";
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3609
3606
|
// src/environment-settings.ts
|
|
3610
3607
|
function createEnvironmentSettings(environments) {
|
|
3611
3608
|
return {
|
|
@@ -3956,12 +3953,12 @@ var Runner = class _Runner {
|
|
|
3956
3953
|
errors.push("Default agent instructions are required");
|
|
3957
3954
|
}
|
|
3958
3955
|
}
|
|
3959
|
-
const agents = graph.
|
|
3956
|
+
const agents = graph.getSubAgents();
|
|
3960
3957
|
if (agents.length === 0) {
|
|
3961
3958
|
errors.push("Graph must contain at least one agent");
|
|
3962
3959
|
}
|
|
3963
|
-
for (const
|
|
3964
|
-
if (!
|
|
3960
|
+
for (const agent of agents) {
|
|
3961
|
+
if (!agent.getName()) {
|
|
3965
3962
|
errors.push(`Agent missing name`);
|
|
3966
3963
|
}
|
|
3967
3964
|
}
|
|
@@ -3974,7 +3971,7 @@ var Runner = class _Runner {
|
|
|
3974
3971
|
* Get execution statistics for a graph
|
|
3975
3972
|
*/
|
|
3976
3973
|
static async getExecutionStats(graph, messages, options) {
|
|
3977
|
-
const agents = graph.
|
|
3974
|
+
const agents = graph.getSubAgents();
|
|
3978
3975
|
const defaultSubAgent = graph.getdefaultSubAgent();
|
|
3979
3976
|
const messageCount = Array.isArray(messages) ? messages.length : 1;
|
|
3980
3977
|
return {
|
|
@@ -3990,4 +3987,4 @@ var run = Runner.run.bind(Runner);
|
|
|
3990
3987
|
var stream = Runner.stream.bind(Runner);
|
|
3991
3988
|
var raceGraphs = Runner.raceGraphs.bind(Runner);
|
|
3992
3989
|
|
|
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 };
|
|
3990
|
+
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-sdk",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20251010064032",
|
|
4
4
|
"description": "Agents SDK for building and managing agents in the Inkeep Agent Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"nanoid": "^5.1.5",
|
|
13
13
|
"typescript": "^5.3.3",
|
|
14
14
|
"zod": "^4.1.11",
|
|
15
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
15
|
+
"@inkeep/agents-core": "^0.0.0-dev-20251010064032"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/js-yaml": "^4.0.9",
|