@inkeep/agents-sdk 0.37.1 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +18 -201
- package/dist/index.d.cts +10 -6
- package/dist/index.d.ts +10 -6
- package/dist/index.js +18 -201
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -92,7 +92,7 @@ var ArtifactComponent = class {
|
|
|
92
92
|
return this.config.name;
|
|
93
93
|
}
|
|
94
94
|
getDescription() {
|
|
95
|
-
return this.config.description;
|
|
95
|
+
return this.config.description || "";
|
|
96
96
|
}
|
|
97
97
|
getProps() {
|
|
98
98
|
return this.config.props;
|
|
@@ -387,17 +387,19 @@ async function deleteFullProjectViaAPI(tenantId, apiUrl, projectId, apiKey) {
|
|
|
387
387
|
);
|
|
388
388
|
}
|
|
389
389
|
function parseError(errorText) {
|
|
390
|
+
let result;
|
|
390
391
|
try {
|
|
391
392
|
const errorJson = JSON.parse(errorText);
|
|
392
393
|
if (errorJson.error) {
|
|
393
394
|
const { error } = errorJson;
|
|
394
|
-
|
|
395
|
+
result = error?.message ?? error;
|
|
395
396
|
}
|
|
396
397
|
} catch {
|
|
397
398
|
if (errorText) {
|
|
398
|
-
|
|
399
|
+
result = errorText;
|
|
399
400
|
}
|
|
400
401
|
}
|
|
402
|
+
return result;
|
|
401
403
|
}
|
|
402
404
|
|
|
403
405
|
// src/agentFullClient.ts
|
|
@@ -623,7 +625,7 @@ var FunctionTool = class {
|
|
|
623
625
|
return this.config.name;
|
|
624
626
|
}
|
|
625
627
|
getDescription() {
|
|
626
|
-
return this.config.description;
|
|
628
|
+
return this.config.description || "";
|
|
627
629
|
}
|
|
628
630
|
getInputSchema() {
|
|
629
631
|
return this.config.inputSchema;
|
|
@@ -847,7 +849,7 @@ var Agent = class {
|
|
|
847
849
|
subAgentsObject[subAgent2.getId()] = {
|
|
848
850
|
id: subAgent2.getId(),
|
|
849
851
|
name: subAgent2.getName(),
|
|
850
|
-
description: subAgent2.config.description ||
|
|
852
|
+
description: subAgent2.config.description || "",
|
|
851
853
|
prompt: subAgent2.getInstructions(),
|
|
852
854
|
models: subAgent2.config.models,
|
|
853
855
|
stopWhen: subAgent2.config.stopWhen,
|
|
@@ -1537,193 +1539,6 @@ var Agent = class {
|
|
|
1537
1539
|
}
|
|
1538
1540
|
return [input];
|
|
1539
1541
|
}
|
|
1540
|
-
async saveToDatabase() {
|
|
1541
|
-
try {
|
|
1542
|
-
const getUrl = `${this.baseURL}/tenants/${this.tenantId}/agents/${this.agentId}`;
|
|
1543
|
-
try {
|
|
1544
|
-
const getResponse = await fetch(getUrl, {
|
|
1545
|
-
method: "GET",
|
|
1546
|
-
headers: {
|
|
1547
|
-
"Content-Type": "application/json"
|
|
1548
|
-
}
|
|
1549
|
-
});
|
|
1550
|
-
if (getResponse.ok) {
|
|
1551
|
-
logger6.info({ agentId: this.agentId }, "Agent already exists in backend");
|
|
1552
|
-
return;
|
|
1553
|
-
}
|
|
1554
|
-
if (getResponse.status !== 404) {
|
|
1555
|
-
throw new Error(`HTTP ${getResponse.status}: ${getResponse.statusText}`);
|
|
1556
|
-
}
|
|
1557
|
-
} catch (error) {
|
|
1558
|
-
if (!error.message.includes("404")) {
|
|
1559
|
-
throw error;
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
logger6.info({ agentId: this.agentId }, "Creating agent in backend");
|
|
1563
|
-
const createUrl = `${this.baseURL}/tenants/${this.tenantId}/agents`;
|
|
1564
|
-
const createResponse = await fetch(createUrl, {
|
|
1565
|
-
method: "POST",
|
|
1566
|
-
headers: {
|
|
1567
|
-
"Content-Type": "application/json"
|
|
1568
|
-
},
|
|
1569
|
-
body: JSON.stringify({
|
|
1570
|
-
id: this.agentId,
|
|
1571
|
-
name: this.agentName,
|
|
1572
|
-
defaultSubAgentId: this.defaultSubAgent?.getId() || "",
|
|
1573
|
-
contextConfigId: this.contextConfig?.getId(),
|
|
1574
|
-
models: this.models
|
|
1575
|
-
})
|
|
1576
|
-
});
|
|
1577
|
-
if (!createResponse.ok) {
|
|
1578
|
-
throw new Error(`HTTP ${createResponse.status}: ${createResponse.statusText}`);
|
|
1579
|
-
}
|
|
1580
|
-
const createData = await createResponse.json();
|
|
1581
|
-
this.agentId = createData.data.id;
|
|
1582
|
-
logger6.info({ agent: createData.data }, "Agent created in backend");
|
|
1583
|
-
} catch (error) {
|
|
1584
|
-
throw new Error(
|
|
1585
|
-
`Failed to save agent to database: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1586
|
-
);
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
async saveRelations() {
|
|
1590
|
-
if (this.defaultSubAgent) {
|
|
1591
|
-
try {
|
|
1592
|
-
const updateUrl = `${this.baseURL}/tenants/${this.tenantId}/agents/${this.agentId}`;
|
|
1593
|
-
const updateResponse = await fetch(updateUrl, {
|
|
1594
|
-
method: "PUT",
|
|
1595
|
-
headers: {
|
|
1596
|
-
"Content-Type": "application/json"
|
|
1597
|
-
},
|
|
1598
|
-
body: JSON.stringify({
|
|
1599
|
-
id: this.agentId,
|
|
1600
|
-
defaultSubAgentId: this.defaultSubAgent.getId(),
|
|
1601
|
-
contextConfigId: this.contextConfig?.getId()
|
|
1602
|
-
})
|
|
1603
|
-
});
|
|
1604
|
-
if (!updateResponse.ok) {
|
|
1605
|
-
throw new Error(`HTTP ${updateResponse.status}: ${updateResponse.statusText}`);
|
|
1606
|
-
}
|
|
1607
|
-
logger6.debug(
|
|
1608
|
-
{
|
|
1609
|
-
agentId: this.agentId,
|
|
1610
|
-
defaultSubAgent: this.defaultSubAgent.getName()
|
|
1611
|
-
},
|
|
1612
|
-
"Agent relationships configured"
|
|
1613
|
-
);
|
|
1614
|
-
} catch (error) {
|
|
1615
|
-
logger6.error(
|
|
1616
|
-
{
|
|
1617
|
-
agentId: this.agentId,
|
|
1618
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
1619
|
-
},
|
|
1620
|
-
"Failed to update agent relationships"
|
|
1621
|
-
);
|
|
1622
|
-
throw error;
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
async createSubAgentRelations() {
|
|
1627
|
-
const allSubAgentRelationPromises = [];
|
|
1628
|
-
for (const subAgent2 of this.subAgents) {
|
|
1629
|
-
const transfers = subAgent2.getTransfers();
|
|
1630
|
-
for (const transferAgent of transfers) {
|
|
1631
|
-
allSubAgentRelationPromises.push(
|
|
1632
|
-
this.createSubAgentRelation(subAgent2, transferAgent, "transfer")
|
|
1633
|
-
);
|
|
1634
|
-
}
|
|
1635
|
-
const delegates = subAgent2.getSubAgentDelegates();
|
|
1636
|
-
for (const delegate of delegates) {
|
|
1637
|
-
if (this.isInternalAgent(delegate)) {
|
|
1638
|
-
allSubAgentRelationPromises.push(
|
|
1639
|
-
this.createSubAgentRelation(subAgent2, delegate, "delegate")
|
|
1640
|
-
);
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
const results = await Promise.allSettled(allSubAgentRelationPromises);
|
|
1645
|
-
const errors = [];
|
|
1646
|
-
let successCount = 0;
|
|
1647
|
-
for (const result of results) {
|
|
1648
|
-
if (result.status === "fulfilled") {
|
|
1649
|
-
successCount++;
|
|
1650
|
-
} else {
|
|
1651
|
-
errors.push(result.reason);
|
|
1652
|
-
logger6.error(
|
|
1653
|
-
{
|
|
1654
|
-
error: result.reason instanceof Error ? result.reason.message : "Unknown error",
|
|
1655
|
-
agentId: this.agentId
|
|
1656
|
-
},
|
|
1657
|
-
"Failed to create agent relation"
|
|
1658
|
-
);
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
logger6.info(
|
|
1662
|
-
{
|
|
1663
|
-
agentId: this.agentId,
|
|
1664
|
-
totalRelations: allSubAgentRelationPromises.length,
|
|
1665
|
-
successCount,
|
|
1666
|
-
errorCount: errors.length
|
|
1667
|
-
},
|
|
1668
|
-
"Completed agent relation creation batch"
|
|
1669
|
-
);
|
|
1670
|
-
if (errors.length > 0 && successCount === 0) {
|
|
1671
|
-
throw new Error(`All ${errors.length} agent relation creations failed`);
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
async createSubAgentRelation(sourceAgent, targetAgent, relationType) {
|
|
1675
|
-
try {
|
|
1676
|
-
const response = await fetch(`${this.baseURL}/tenants/${this.tenantId}/agent-relations`, {
|
|
1677
|
-
method: "POST",
|
|
1678
|
-
headers: {
|
|
1679
|
-
"Content-Type": "application/json"
|
|
1680
|
-
},
|
|
1681
|
-
body: JSON.stringify({
|
|
1682
|
-
agentId: this.agentId,
|
|
1683
|
-
sourceSubAgentId: sourceAgent.getId(),
|
|
1684
|
-
targetSubAgentId: targetAgent.getId(),
|
|
1685
|
-
relationType
|
|
1686
|
-
})
|
|
1687
|
-
});
|
|
1688
|
-
if (!response.ok) {
|
|
1689
|
-
const errorText = await response.text().catch(() => "Unknown error");
|
|
1690
|
-
if (response.status === 422 && errorText.includes("already exists")) {
|
|
1691
|
-
logger6.info(
|
|
1692
|
-
{
|
|
1693
|
-
sourceSubAgentId: sourceAgent.getId(),
|
|
1694
|
-
targetSubAgentId: targetAgent.getId(),
|
|
1695
|
-
agentId: this.agentId,
|
|
1696
|
-
relationType
|
|
1697
|
-
},
|
|
1698
|
-
`${relationType} relation already exists, skipping creation`
|
|
1699
|
-
);
|
|
1700
|
-
return;
|
|
1701
|
-
}
|
|
1702
|
-
throw new Error(`Failed to create subAgent relation: ${response.status} - ${errorText}`);
|
|
1703
|
-
}
|
|
1704
|
-
logger6.info(
|
|
1705
|
-
{
|
|
1706
|
-
sourceSubAgentId: sourceAgent.getId(),
|
|
1707
|
-
targetSubAgentId: targetAgent.getId(),
|
|
1708
|
-
agentId: this.agentId,
|
|
1709
|
-
relationType
|
|
1710
|
-
},
|
|
1711
|
-
`${relationType} subAgent relation created successfully`
|
|
1712
|
-
);
|
|
1713
|
-
} catch (error) {
|
|
1714
|
-
logger6.error(
|
|
1715
|
-
{
|
|
1716
|
-
sourceSubAgentId: sourceAgent.getId(),
|
|
1717
|
-
targetSubAgentId: targetAgent.getId(),
|
|
1718
|
-
agentId: this.agentId,
|
|
1719
|
-
relationType,
|
|
1720
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
1721
|
-
},
|
|
1722
|
-
`Failed to create ${relationType} subAgent relation`
|
|
1723
|
-
);
|
|
1724
|
-
throw error;
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
1542
|
};
|
|
1728
1543
|
var logger7 = agentsCore.getLogger("dataComponent");
|
|
1729
1544
|
var DataComponent = class {
|
|
@@ -1774,7 +1589,7 @@ var DataComponent = class {
|
|
|
1774
1589
|
return this.config.name;
|
|
1775
1590
|
}
|
|
1776
1591
|
getDescription() {
|
|
1777
|
-
return this.config.description;
|
|
1592
|
+
return this.config.description || "";
|
|
1778
1593
|
}
|
|
1779
1594
|
getProps() {
|
|
1780
1595
|
return this.config.props;
|
|
@@ -2777,12 +2592,17 @@ var Tool = class {
|
|
|
2777
2592
|
* ```
|
|
2778
2593
|
*/
|
|
2779
2594
|
with(config) {
|
|
2780
|
-
const { selectedTools, toolPolicies } = agentsCore.normalizeToolSelections(
|
|
2595
|
+
const { selectedTools, toolPolicies } = agentsCore.normalizeToolSelections(
|
|
2596
|
+
config.selectedTools ?? void 0
|
|
2597
|
+
);
|
|
2598
|
+
const isUnspecified = config.selectedTools === void 0 || config.selectedTools === null;
|
|
2599
|
+
const resolvedSelectedTools = isUnspecified ? void 0 : selectedTools;
|
|
2600
|
+
const resolvedToolPolicies = isUnspecified || Object.keys(toolPolicies).length === 0 ? void 0 : toolPolicies;
|
|
2781
2601
|
return {
|
|
2782
2602
|
server: this,
|
|
2783
|
-
selectedTools,
|
|
2603
|
+
selectedTools: resolvedSelectedTools,
|
|
2784
2604
|
headers: config.headers,
|
|
2785
|
-
toolPolicies
|
|
2605
|
+
toolPolicies: resolvedToolPolicies
|
|
2786
2606
|
};
|
|
2787
2607
|
}
|
|
2788
2608
|
};
|
|
@@ -2862,7 +2682,7 @@ var SubAgent = class {
|
|
|
2862
2682
|
return this.config.name;
|
|
2863
2683
|
}
|
|
2864
2684
|
getInstructions() {
|
|
2865
|
-
return this.config.prompt;
|
|
2685
|
+
return this.config.prompt || "";
|
|
2866
2686
|
}
|
|
2867
2687
|
/**
|
|
2868
2688
|
* Get the agent's description (the human-readable description field)
|
|
@@ -3078,7 +2898,7 @@ var SubAgent = class {
|
|
|
3078
2898
|
id: this.getId(),
|
|
3079
2899
|
name: this.config.name,
|
|
3080
2900
|
description: this.config.description || "",
|
|
3081
|
-
prompt: this.config.prompt,
|
|
2901
|
+
prompt: this.config.prompt || "",
|
|
3082
2902
|
conversationHistoryConfig: this.config.conversationHistoryConfig,
|
|
3083
2903
|
models: this.config.models,
|
|
3084
2904
|
stopWhen: this.config.stopWhen
|
|
@@ -4136,9 +3956,6 @@ var Runner = class _Runner {
|
|
|
4136
3956
|
if (!defaultSubAgent.getName()) {
|
|
4137
3957
|
errors.push("Default agent name is required");
|
|
4138
3958
|
}
|
|
4139
|
-
if (!defaultSubAgent.getInstructions()) {
|
|
4140
|
-
errors.push("Default agent instructions are required");
|
|
4141
|
-
}
|
|
4142
3959
|
}
|
|
4143
3960
|
const subAgents = agent2.getSubAgents();
|
|
4144
3961
|
if (subAgents.length === 0) {
|
package/dist/index.d.cts
CHANGED
|
@@ -177,8 +177,13 @@ type AgentMcpConfig = {
|
|
|
177
177
|
* Supports flexible tool selection with per-tool policies
|
|
178
178
|
*/
|
|
179
179
|
type AgentMcpConfigInput = {
|
|
180
|
-
/**
|
|
181
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Tools to enable from the MCP server - can be strings or objects with policies
|
|
182
|
+
* - undefined or null: all tools enabled (no filtering)
|
|
183
|
+
* - []: zero tools enabled (explicit empty selection)
|
|
184
|
+
* - ['tool1', 'tool2']: specific tools enabled
|
|
185
|
+
*/
|
|
186
|
+
selectedTools?: McpToolSelection[] | null;
|
|
182
187
|
/** Custom headers for MCP server requests */
|
|
183
188
|
headers?: Record<string, string>;
|
|
184
189
|
};
|
|
@@ -788,10 +793,6 @@ declare class Agent implements AgentInterface {
|
|
|
788
793
|
* Normalize input messages to the expected format
|
|
789
794
|
*/
|
|
790
795
|
private normalizeMessages;
|
|
791
|
-
private saveToDatabase;
|
|
792
|
-
private saveRelations;
|
|
793
|
-
private createSubAgentRelations;
|
|
794
|
-
private createSubAgentRelation;
|
|
795
796
|
}
|
|
796
797
|
|
|
797
798
|
/**
|
|
@@ -1098,7 +1099,10 @@ declare function credential(config: CredentialReferenceApiInsert): {
|
|
|
1098
1099
|
type: "nango" | "memory" | "keychain";
|
|
1099
1100
|
createdAt?: string | undefined;
|
|
1100
1101
|
updatedAt?: string | undefined;
|
|
1102
|
+
userId?: string | null | undefined;
|
|
1101
1103
|
retrievalParams?: Record<string, unknown> | null | undefined;
|
|
1104
|
+
toolId?: string | null | undefined;
|
|
1105
|
+
createdBy?: string | null | undefined;
|
|
1102
1106
|
};
|
|
1103
1107
|
/**
|
|
1104
1108
|
* Creates an MCP (Model Context Protocol) server for tool functionality.
|
package/dist/index.d.ts
CHANGED
|
@@ -177,8 +177,13 @@ type AgentMcpConfig = {
|
|
|
177
177
|
* Supports flexible tool selection with per-tool policies
|
|
178
178
|
*/
|
|
179
179
|
type AgentMcpConfigInput = {
|
|
180
|
-
/**
|
|
181
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Tools to enable from the MCP server - can be strings or objects with policies
|
|
182
|
+
* - undefined or null: all tools enabled (no filtering)
|
|
183
|
+
* - []: zero tools enabled (explicit empty selection)
|
|
184
|
+
* - ['tool1', 'tool2']: specific tools enabled
|
|
185
|
+
*/
|
|
186
|
+
selectedTools?: McpToolSelection[] | null;
|
|
182
187
|
/** Custom headers for MCP server requests */
|
|
183
188
|
headers?: Record<string, string>;
|
|
184
189
|
};
|
|
@@ -788,10 +793,6 @@ declare class Agent implements AgentInterface {
|
|
|
788
793
|
* Normalize input messages to the expected format
|
|
789
794
|
*/
|
|
790
795
|
private normalizeMessages;
|
|
791
|
-
private saveToDatabase;
|
|
792
|
-
private saveRelations;
|
|
793
|
-
private createSubAgentRelations;
|
|
794
|
-
private createSubAgentRelation;
|
|
795
796
|
}
|
|
796
797
|
|
|
797
798
|
/**
|
|
@@ -1098,7 +1099,10 @@ declare function credential(config: CredentialReferenceApiInsert): {
|
|
|
1098
1099
|
type: "nango" | "memory" | "keychain";
|
|
1099
1100
|
createdAt?: string | undefined;
|
|
1100
1101
|
updatedAt?: string | undefined;
|
|
1102
|
+
userId?: string | null | undefined;
|
|
1101
1103
|
retrievalParams?: Record<string, unknown> | null | undefined;
|
|
1104
|
+
toolId?: string | null | undefined;
|
|
1105
|
+
createdBy?: string | null | undefined;
|
|
1102
1106
|
};
|
|
1103
1107
|
/**
|
|
1104
1108
|
* Creates an MCP (Model Context Protocol) server for tool functionality.
|
package/dist/index.js
CHANGED
|
@@ -65,7 +65,7 @@ var ArtifactComponent = class {
|
|
|
65
65
|
return this.config.name;
|
|
66
66
|
}
|
|
67
67
|
getDescription() {
|
|
68
|
-
return this.config.description;
|
|
68
|
+
return this.config.description || "";
|
|
69
69
|
}
|
|
70
70
|
getProps() {
|
|
71
71
|
return this.config.props;
|
|
@@ -360,17 +360,19 @@ async function deleteFullProjectViaAPI(tenantId, apiUrl, projectId, apiKey) {
|
|
|
360
360
|
);
|
|
361
361
|
}
|
|
362
362
|
function parseError(errorText) {
|
|
363
|
+
let result;
|
|
363
364
|
try {
|
|
364
365
|
const errorJson = JSON.parse(errorText);
|
|
365
366
|
if (errorJson.error) {
|
|
366
367
|
const { error } = errorJson;
|
|
367
|
-
|
|
368
|
+
result = error?.message ?? error;
|
|
368
369
|
}
|
|
369
370
|
} catch {
|
|
370
371
|
if (errorText) {
|
|
371
|
-
|
|
372
|
+
result = errorText;
|
|
372
373
|
}
|
|
373
374
|
}
|
|
375
|
+
return result;
|
|
374
376
|
}
|
|
375
377
|
|
|
376
378
|
// src/agentFullClient.ts
|
|
@@ -596,7 +598,7 @@ var FunctionTool = class {
|
|
|
596
598
|
return this.config.name;
|
|
597
599
|
}
|
|
598
600
|
getDescription() {
|
|
599
|
-
return this.config.description;
|
|
601
|
+
return this.config.description || "";
|
|
600
602
|
}
|
|
601
603
|
getInputSchema() {
|
|
602
604
|
return this.config.inputSchema;
|
|
@@ -820,7 +822,7 @@ var Agent = class {
|
|
|
820
822
|
subAgentsObject[subAgent2.getId()] = {
|
|
821
823
|
id: subAgent2.getId(),
|
|
822
824
|
name: subAgent2.getName(),
|
|
823
|
-
description: subAgent2.config.description ||
|
|
825
|
+
description: subAgent2.config.description || "",
|
|
824
826
|
prompt: subAgent2.getInstructions(),
|
|
825
827
|
models: subAgent2.config.models,
|
|
826
828
|
stopWhen: subAgent2.config.stopWhen,
|
|
@@ -1510,193 +1512,6 @@ var Agent = class {
|
|
|
1510
1512
|
}
|
|
1511
1513
|
return [input];
|
|
1512
1514
|
}
|
|
1513
|
-
async saveToDatabase() {
|
|
1514
|
-
try {
|
|
1515
|
-
const getUrl = `${this.baseURL}/tenants/${this.tenantId}/agents/${this.agentId}`;
|
|
1516
|
-
try {
|
|
1517
|
-
const getResponse = await fetch(getUrl, {
|
|
1518
|
-
method: "GET",
|
|
1519
|
-
headers: {
|
|
1520
|
-
"Content-Type": "application/json"
|
|
1521
|
-
}
|
|
1522
|
-
});
|
|
1523
|
-
if (getResponse.ok) {
|
|
1524
|
-
logger6.info({ agentId: this.agentId }, "Agent already exists in backend");
|
|
1525
|
-
return;
|
|
1526
|
-
}
|
|
1527
|
-
if (getResponse.status !== 404) {
|
|
1528
|
-
throw new Error(`HTTP ${getResponse.status}: ${getResponse.statusText}`);
|
|
1529
|
-
}
|
|
1530
|
-
} catch (error) {
|
|
1531
|
-
if (!error.message.includes("404")) {
|
|
1532
|
-
throw error;
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
logger6.info({ agentId: this.agentId }, "Creating agent in backend");
|
|
1536
|
-
const createUrl = `${this.baseURL}/tenants/${this.tenantId}/agents`;
|
|
1537
|
-
const createResponse = await fetch(createUrl, {
|
|
1538
|
-
method: "POST",
|
|
1539
|
-
headers: {
|
|
1540
|
-
"Content-Type": "application/json"
|
|
1541
|
-
},
|
|
1542
|
-
body: JSON.stringify({
|
|
1543
|
-
id: this.agentId,
|
|
1544
|
-
name: this.agentName,
|
|
1545
|
-
defaultSubAgentId: this.defaultSubAgent?.getId() || "",
|
|
1546
|
-
contextConfigId: this.contextConfig?.getId(),
|
|
1547
|
-
models: this.models
|
|
1548
|
-
})
|
|
1549
|
-
});
|
|
1550
|
-
if (!createResponse.ok) {
|
|
1551
|
-
throw new Error(`HTTP ${createResponse.status}: ${createResponse.statusText}`);
|
|
1552
|
-
}
|
|
1553
|
-
const createData = await createResponse.json();
|
|
1554
|
-
this.agentId = createData.data.id;
|
|
1555
|
-
logger6.info({ agent: createData.data }, "Agent created in backend");
|
|
1556
|
-
} catch (error) {
|
|
1557
|
-
throw new Error(
|
|
1558
|
-
`Failed to save agent to database: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1559
|
-
);
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
async saveRelations() {
|
|
1563
|
-
if (this.defaultSubAgent) {
|
|
1564
|
-
try {
|
|
1565
|
-
const updateUrl = `${this.baseURL}/tenants/${this.tenantId}/agents/${this.agentId}`;
|
|
1566
|
-
const updateResponse = await fetch(updateUrl, {
|
|
1567
|
-
method: "PUT",
|
|
1568
|
-
headers: {
|
|
1569
|
-
"Content-Type": "application/json"
|
|
1570
|
-
},
|
|
1571
|
-
body: JSON.stringify({
|
|
1572
|
-
id: this.agentId,
|
|
1573
|
-
defaultSubAgentId: this.defaultSubAgent.getId(),
|
|
1574
|
-
contextConfigId: this.contextConfig?.getId()
|
|
1575
|
-
})
|
|
1576
|
-
});
|
|
1577
|
-
if (!updateResponse.ok) {
|
|
1578
|
-
throw new Error(`HTTP ${updateResponse.status}: ${updateResponse.statusText}`);
|
|
1579
|
-
}
|
|
1580
|
-
logger6.debug(
|
|
1581
|
-
{
|
|
1582
|
-
agentId: this.agentId,
|
|
1583
|
-
defaultSubAgent: this.defaultSubAgent.getName()
|
|
1584
|
-
},
|
|
1585
|
-
"Agent relationships configured"
|
|
1586
|
-
);
|
|
1587
|
-
} catch (error) {
|
|
1588
|
-
logger6.error(
|
|
1589
|
-
{
|
|
1590
|
-
agentId: this.agentId,
|
|
1591
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
1592
|
-
},
|
|
1593
|
-
"Failed to update agent relationships"
|
|
1594
|
-
);
|
|
1595
|
-
throw error;
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
async createSubAgentRelations() {
|
|
1600
|
-
const allSubAgentRelationPromises = [];
|
|
1601
|
-
for (const subAgent2 of this.subAgents) {
|
|
1602
|
-
const transfers = subAgent2.getTransfers();
|
|
1603
|
-
for (const transferAgent of transfers) {
|
|
1604
|
-
allSubAgentRelationPromises.push(
|
|
1605
|
-
this.createSubAgentRelation(subAgent2, transferAgent, "transfer")
|
|
1606
|
-
);
|
|
1607
|
-
}
|
|
1608
|
-
const delegates = subAgent2.getSubAgentDelegates();
|
|
1609
|
-
for (const delegate of delegates) {
|
|
1610
|
-
if (this.isInternalAgent(delegate)) {
|
|
1611
|
-
allSubAgentRelationPromises.push(
|
|
1612
|
-
this.createSubAgentRelation(subAgent2, delegate, "delegate")
|
|
1613
|
-
);
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
const results = await Promise.allSettled(allSubAgentRelationPromises);
|
|
1618
|
-
const errors = [];
|
|
1619
|
-
let successCount = 0;
|
|
1620
|
-
for (const result of results) {
|
|
1621
|
-
if (result.status === "fulfilled") {
|
|
1622
|
-
successCount++;
|
|
1623
|
-
} else {
|
|
1624
|
-
errors.push(result.reason);
|
|
1625
|
-
logger6.error(
|
|
1626
|
-
{
|
|
1627
|
-
error: result.reason instanceof Error ? result.reason.message : "Unknown error",
|
|
1628
|
-
agentId: this.agentId
|
|
1629
|
-
},
|
|
1630
|
-
"Failed to create agent relation"
|
|
1631
|
-
);
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
logger6.info(
|
|
1635
|
-
{
|
|
1636
|
-
agentId: this.agentId,
|
|
1637
|
-
totalRelations: allSubAgentRelationPromises.length,
|
|
1638
|
-
successCount,
|
|
1639
|
-
errorCount: errors.length
|
|
1640
|
-
},
|
|
1641
|
-
"Completed agent relation creation batch"
|
|
1642
|
-
);
|
|
1643
|
-
if (errors.length > 0 && successCount === 0) {
|
|
1644
|
-
throw new Error(`All ${errors.length} agent relation creations failed`);
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
async createSubAgentRelation(sourceAgent, targetAgent, relationType) {
|
|
1648
|
-
try {
|
|
1649
|
-
const response = await fetch(`${this.baseURL}/tenants/${this.tenantId}/agent-relations`, {
|
|
1650
|
-
method: "POST",
|
|
1651
|
-
headers: {
|
|
1652
|
-
"Content-Type": "application/json"
|
|
1653
|
-
},
|
|
1654
|
-
body: JSON.stringify({
|
|
1655
|
-
agentId: this.agentId,
|
|
1656
|
-
sourceSubAgentId: sourceAgent.getId(),
|
|
1657
|
-
targetSubAgentId: targetAgent.getId(),
|
|
1658
|
-
relationType
|
|
1659
|
-
})
|
|
1660
|
-
});
|
|
1661
|
-
if (!response.ok) {
|
|
1662
|
-
const errorText = await response.text().catch(() => "Unknown error");
|
|
1663
|
-
if (response.status === 422 && errorText.includes("already exists")) {
|
|
1664
|
-
logger6.info(
|
|
1665
|
-
{
|
|
1666
|
-
sourceSubAgentId: sourceAgent.getId(),
|
|
1667
|
-
targetSubAgentId: targetAgent.getId(),
|
|
1668
|
-
agentId: this.agentId,
|
|
1669
|
-
relationType
|
|
1670
|
-
},
|
|
1671
|
-
`${relationType} relation already exists, skipping creation`
|
|
1672
|
-
);
|
|
1673
|
-
return;
|
|
1674
|
-
}
|
|
1675
|
-
throw new Error(`Failed to create subAgent relation: ${response.status} - ${errorText}`);
|
|
1676
|
-
}
|
|
1677
|
-
logger6.info(
|
|
1678
|
-
{
|
|
1679
|
-
sourceSubAgentId: sourceAgent.getId(),
|
|
1680
|
-
targetSubAgentId: targetAgent.getId(),
|
|
1681
|
-
agentId: this.agentId,
|
|
1682
|
-
relationType
|
|
1683
|
-
},
|
|
1684
|
-
`${relationType} subAgent relation created successfully`
|
|
1685
|
-
);
|
|
1686
|
-
} catch (error) {
|
|
1687
|
-
logger6.error(
|
|
1688
|
-
{
|
|
1689
|
-
sourceSubAgentId: sourceAgent.getId(),
|
|
1690
|
-
targetSubAgentId: targetAgent.getId(),
|
|
1691
|
-
agentId: this.agentId,
|
|
1692
|
-
relationType,
|
|
1693
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
1694
|
-
},
|
|
1695
|
-
`Failed to create ${relationType} subAgent relation`
|
|
1696
|
-
);
|
|
1697
|
-
throw error;
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
1515
|
};
|
|
1701
1516
|
var logger7 = getLogger("dataComponent");
|
|
1702
1517
|
var DataComponent = class {
|
|
@@ -1747,7 +1562,7 @@ var DataComponent = class {
|
|
|
1747
1562
|
return this.config.name;
|
|
1748
1563
|
}
|
|
1749
1564
|
getDescription() {
|
|
1750
|
-
return this.config.description;
|
|
1565
|
+
return this.config.description || "";
|
|
1751
1566
|
}
|
|
1752
1567
|
getProps() {
|
|
1753
1568
|
return this.config.props;
|
|
@@ -2750,12 +2565,17 @@ var Tool = class {
|
|
|
2750
2565
|
* ```
|
|
2751
2566
|
*/
|
|
2752
2567
|
with(config) {
|
|
2753
|
-
const { selectedTools, toolPolicies } = normalizeToolSelections(
|
|
2568
|
+
const { selectedTools, toolPolicies } = normalizeToolSelections(
|
|
2569
|
+
config.selectedTools ?? void 0
|
|
2570
|
+
);
|
|
2571
|
+
const isUnspecified = config.selectedTools === void 0 || config.selectedTools === null;
|
|
2572
|
+
const resolvedSelectedTools = isUnspecified ? void 0 : selectedTools;
|
|
2573
|
+
const resolvedToolPolicies = isUnspecified || Object.keys(toolPolicies).length === 0 ? void 0 : toolPolicies;
|
|
2754
2574
|
return {
|
|
2755
2575
|
server: this,
|
|
2756
|
-
selectedTools,
|
|
2576
|
+
selectedTools: resolvedSelectedTools,
|
|
2757
2577
|
headers: config.headers,
|
|
2758
|
-
toolPolicies
|
|
2578
|
+
toolPolicies: resolvedToolPolicies
|
|
2759
2579
|
};
|
|
2760
2580
|
}
|
|
2761
2581
|
};
|
|
@@ -2835,7 +2655,7 @@ var SubAgent = class {
|
|
|
2835
2655
|
return this.config.name;
|
|
2836
2656
|
}
|
|
2837
2657
|
getInstructions() {
|
|
2838
|
-
return this.config.prompt;
|
|
2658
|
+
return this.config.prompt || "";
|
|
2839
2659
|
}
|
|
2840
2660
|
/**
|
|
2841
2661
|
* Get the agent's description (the human-readable description field)
|
|
@@ -3051,7 +2871,7 @@ var SubAgent = class {
|
|
|
3051
2871
|
id: this.getId(),
|
|
3052
2872
|
name: this.config.name,
|
|
3053
2873
|
description: this.config.description || "",
|
|
3054
|
-
prompt: this.config.prompt,
|
|
2874
|
+
prompt: this.config.prompt || "",
|
|
3055
2875
|
conversationHistoryConfig: this.config.conversationHistoryConfig,
|
|
3056
2876
|
models: this.config.models,
|
|
3057
2877
|
stopWhen: this.config.stopWhen
|
|
@@ -4109,9 +3929,6 @@ var Runner = class _Runner {
|
|
|
4109
3929
|
if (!defaultSubAgent.getName()) {
|
|
4110
3930
|
errors.push("Default agent name is required");
|
|
4111
3931
|
}
|
|
4112
|
-
if (!defaultSubAgent.getInstructions()) {
|
|
4113
|
-
errors.push("Default agent instructions are required");
|
|
4114
|
-
}
|
|
4115
3932
|
}
|
|
4116
3933
|
const subAgents = agent2.getSubAgents();
|
|
4117
3934
|
if (subAgents.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
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.
|
|
15
|
+
"@inkeep/agents-core": "^0.38.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/js-yaml": "^4.0.9",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"test:coverage": "ENVIRONMENT=test vitest --run --coverage",
|
|
66
66
|
"typecheck": "tsc --noEmit",
|
|
67
67
|
"typecheck:watch": "tsc --noEmit --watch",
|
|
68
|
-
"lint": "biome lint
|
|
68
|
+
"lint": "biome lint --error-on-warnings",
|
|
69
69
|
"lint:fix": "biome check --write .",
|
|
70
70
|
"format": "biome format --write ."
|
|
71
71
|
}
|