@inkeep/agents-sdk 0.26.2 → 0.28.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 +118 -10
- package/dist/index.d.cts +87 -11
- package/dist/index.d.ts +87 -11
- package/dist/index.js +118 -10
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -514,7 +514,12 @@ var Agent = class {
|
|
|
514
514
|
this.subAgents = resolveGetter(config.subAgents) || [];
|
|
515
515
|
this.agentMap = new Map(this.subAgents.map((agent2) => [agent2.getId(), agent2]));
|
|
516
516
|
if (this.defaultSubAgent) {
|
|
517
|
-
this.subAgents.
|
|
517
|
+
const isAlreadyPresent = this.subAgents.some(
|
|
518
|
+
(agent2) => agent2.getId() === this.defaultSubAgent?.getId()
|
|
519
|
+
);
|
|
520
|
+
if (!isAlreadyPresent) {
|
|
521
|
+
this.subAgents.push(this.defaultSubAgent);
|
|
522
|
+
}
|
|
518
523
|
this.agentMap.set(this.defaultSubAgent.getId(), this.defaultSubAgent);
|
|
519
524
|
}
|
|
520
525
|
if (this.models) {
|
|
@@ -655,9 +660,10 @@ var Agent = class {
|
|
|
655
660
|
externalAgentId: d.externalAgent.getId(),
|
|
656
661
|
...d.headers && { headers: d.headers }
|
|
657
662
|
};
|
|
658
|
-
} else if (typeof d === "object" && "
|
|
663
|
+
} else if (typeof d === "object" && "agent" in d) {
|
|
659
664
|
return {
|
|
660
|
-
|
|
665
|
+
agentId: d.agent.getId(),
|
|
666
|
+
...d.headers && { headers: d.headers }
|
|
661
667
|
};
|
|
662
668
|
}
|
|
663
669
|
return d.getId();
|
|
@@ -1037,6 +1043,12 @@ var Agent = class {
|
|
|
1037
1043
|
tenantId: this.tenantId
|
|
1038
1044
|
};
|
|
1039
1045
|
}
|
|
1046
|
+
with(options) {
|
|
1047
|
+
return {
|
|
1048
|
+
agent: this,
|
|
1049
|
+
headers: options.headers
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1040
1052
|
/**
|
|
1041
1053
|
* Validate the agent configuration
|
|
1042
1054
|
*/
|
|
@@ -1505,7 +1517,8 @@ var DataComponent = class {
|
|
|
1505
1517
|
this.config = {
|
|
1506
1518
|
...config,
|
|
1507
1519
|
id: this.id,
|
|
1508
|
-
props: processedProps
|
|
1520
|
+
props: processedProps,
|
|
1521
|
+
render: config.render || null
|
|
1509
1522
|
};
|
|
1510
1523
|
this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
|
|
1511
1524
|
this.tenantId = "default";
|
|
@@ -1539,6 +1552,9 @@ var DataComponent = class {
|
|
|
1539
1552
|
getProps() {
|
|
1540
1553
|
return this.config.props;
|
|
1541
1554
|
}
|
|
1555
|
+
getRender() {
|
|
1556
|
+
return this.config.render;
|
|
1557
|
+
}
|
|
1542
1558
|
// Public method to ensure data component exists in backend (with upsert behavior)
|
|
1543
1559
|
async init() {
|
|
1544
1560
|
if (this.initialized) return;
|
|
@@ -1568,7 +1584,8 @@ var DataComponent = class {
|
|
|
1568
1584
|
id: this.getId(),
|
|
1569
1585
|
name: this.config.name,
|
|
1570
1586
|
description: this.config.description,
|
|
1571
|
-
props: this.config.props
|
|
1587
|
+
props: this.config.props,
|
|
1588
|
+
render: this.config.render
|
|
1572
1589
|
};
|
|
1573
1590
|
logger6.info({ dataComponentData }, "dataComponentData for create/update");
|
|
1574
1591
|
const updateResponse = await fetch(
|
|
@@ -2387,23 +2404,27 @@ var Project = class {
|
|
|
2387
2404
|
let dataComponentName;
|
|
2388
2405
|
let dataComponentDescription;
|
|
2389
2406
|
let dataComponentProps;
|
|
2407
|
+
let dataComponentRender;
|
|
2390
2408
|
if (dataComponent2.getId) {
|
|
2391
2409
|
dataComponentId = dataComponent2.getId();
|
|
2392
2410
|
dataComponentName = dataComponent2.getName();
|
|
2393
2411
|
dataComponentDescription = dataComponent2.getDescription() || "";
|
|
2394
2412
|
dataComponentProps = dataComponent2.getProps() || {};
|
|
2413
|
+
dataComponentRender = dataComponent2.getRender?.() || null;
|
|
2395
2414
|
} else {
|
|
2396
2415
|
dataComponentId = dataComponent2.id || (dataComponent2.name ? dataComponent2.name.toLowerCase().replace(/\s+/g, "-") : "");
|
|
2397
2416
|
dataComponentName = dataComponent2.name || "";
|
|
2398
2417
|
dataComponentDescription = dataComponent2.description || "";
|
|
2399
2418
|
dataComponentProps = dataComponent2.props || {};
|
|
2419
|
+
dataComponentRender = dataComponent2.render || null;
|
|
2400
2420
|
}
|
|
2401
2421
|
if (!dataComponentsObject[dataComponentId] && dataComponentName) {
|
|
2402
2422
|
dataComponentsObject[dataComponentId] = {
|
|
2403
2423
|
id: dataComponentId,
|
|
2404
2424
|
name: dataComponentName,
|
|
2405
2425
|
description: dataComponentDescription,
|
|
2406
|
-
props: dataComponentProps
|
|
2426
|
+
props: dataComponentProps,
|
|
2427
|
+
render: dataComponentRender
|
|
2407
2428
|
};
|
|
2408
2429
|
}
|
|
2409
2430
|
}
|
|
@@ -2744,6 +2765,29 @@ var Tool = class {
|
|
|
2744
2765
|
}
|
|
2745
2766
|
throw new Error(`Failed to update tool: ${updateResponse.status}`);
|
|
2746
2767
|
}
|
|
2768
|
+
/**
|
|
2769
|
+
* Creates a new AgentMcpConfig with the given configuration.
|
|
2770
|
+
*
|
|
2771
|
+
* @param config - The configuration for the AgentMcpConfig
|
|
2772
|
+
* @returns A new AgentMcpConfig
|
|
2773
|
+
*
|
|
2774
|
+
* example:
|
|
2775
|
+
* ```typescript
|
|
2776
|
+
* const tool = new Tool({
|
|
2777
|
+
* id: 'tool-id',
|
|
2778
|
+
* name: 'Tool Name',
|
|
2779
|
+
* serverUrl: 'https://example.com/mcp',
|
|
2780
|
+
* });
|
|
2781
|
+
* const agentMcpConfig = tool.with({ selectedTools: ['tool-1', 'tool-2'], headers: { 'Authorization': 'Bearer token' } });
|
|
2782
|
+
* ```
|
|
2783
|
+
*/
|
|
2784
|
+
with(config) {
|
|
2785
|
+
return {
|
|
2786
|
+
server: this,
|
|
2787
|
+
selectedTools: config.selectedTools,
|
|
2788
|
+
headers: config.headers
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2747
2791
|
};
|
|
2748
2792
|
|
|
2749
2793
|
// src/utils/tool-normalization.ts
|
|
@@ -2871,6 +2915,12 @@ var SubAgent = class {
|
|
|
2871
2915
|
if (typeof delegate === "object" && "externalAgent" in delegate) {
|
|
2872
2916
|
return false;
|
|
2873
2917
|
}
|
|
2918
|
+
if (typeof delegate === "object" && "agent" in delegate) {
|
|
2919
|
+
return false;
|
|
2920
|
+
}
|
|
2921
|
+
if (typeof delegate === "object" && "toFullAgentDefinition" in delegate) {
|
|
2922
|
+
return false;
|
|
2923
|
+
}
|
|
2874
2924
|
if (typeof delegate === "object" && "type" in delegate && delegate.type === "external") {
|
|
2875
2925
|
return false;
|
|
2876
2926
|
}
|
|
@@ -2899,8 +2949,34 @@ var SubAgent = class {
|
|
|
2899
2949
|
};
|
|
2900
2950
|
});
|
|
2901
2951
|
}
|
|
2952
|
+
getTeamAgentDelegates() {
|
|
2953
|
+
if (typeof this.config.canDelegateTo !== "function") {
|
|
2954
|
+
return [];
|
|
2955
|
+
}
|
|
2956
|
+
return this.config.canDelegateTo().filter((delegate) => {
|
|
2957
|
+
if (typeof delegate === "object" && "agent" in delegate) {
|
|
2958
|
+
return true;
|
|
2959
|
+
}
|
|
2960
|
+
if (typeof delegate === "object" && "toFullAgentDefinition" in delegate) {
|
|
2961
|
+
return true;
|
|
2962
|
+
}
|
|
2963
|
+
return false;
|
|
2964
|
+
}).map((delegate) => {
|
|
2965
|
+
if ("agent" in delegate) {
|
|
2966
|
+
return delegate;
|
|
2967
|
+
}
|
|
2968
|
+
return {
|
|
2969
|
+
agent: delegate,
|
|
2970
|
+
headers: void 0
|
|
2971
|
+
};
|
|
2972
|
+
});
|
|
2973
|
+
}
|
|
2902
2974
|
getDelegates() {
|
|
2903
|
-
return
|
|
2975
|
+
return [
|
|
2976
|
+
...this.getSubAgentDelegates(),
|
|
2977
|
+
...this.getTeamAgentDelegates(),
|
|
2978
|
+
...this.getExternalAgentDelegates()
|
|
2979
|
+
];
|
|
2904
2980
|
}
|
|
2905
2981
|
getDataComponents() {
|
|
2906
2982
|
const components = resolveGetter2(this.config.dataComponents) || [];
|
|
@@ -2910,7 +2986,8 @@ var SubAgent = class {
|
|
|
2910
2986
|
id: comp.getId(),
|
|
2911
2987
|
name: comp.getName(),
|
|
2912
2988
|
description: comp.getDescription(),
|
|
2913
|
-
props: comp.getProps()
|
|
2989
|
+
props: comp.getProps(),
|
|
2990
|
+
render: comp.getRender?.() || null
|
|
2914
2991
|
};
|
|
2915
2992
|
}
|
|
2916
2993
|
if (comp && typeof comp === "object" && comp.props && schemaConversion.isZodSchema(comp.props)) {
|
|
@@ -2918,7 +2995,8 @@ var SubAgent = class {
|
|
|
2918
2995
|
id: comp.id,
|
|
2919
2996
|
name: comp.name,
|
|
2920
2997
|
description: comp.description,
|
|
2921
|
-
props: schemaConversion.convertZodToJsonSchemaWithPreview(comp.props)
|
|
2998
|
+
props: schemaConversion.convertZodToJsonSchemaWithPreview(comp.props),
|
|
2999
|
+
render: comp.render || null
|
|
2922
3000
|
};
|
|
2923
3001
|
}
|
|
2924
3002
|
return comp;
|
|
@@ -3410,7 +3488,8 @@ var SubAgent = class {
|
|
|
3410
3488
|
id: dataComponent2.id,
|
|
3411
3489
|
name: dataComponent2.name,
|
|
3412
3490
|
description: dataComponent2.description,
|
|
3413
|
-
props: dataComponent2.props
|
|
3491
|
+
props: dataComponent2.props,
|
|
3492
|
+
render: dataComponent2.render
|
|
3414
3493
|
});
|
|
3415
3494
|
dc.setContext(this.tenantId, this.projectId);
|
|
3416
3495
|
await dc.init();
|
|
@@ -3668,6 +3747,35 @@ function isCredentialReference(value) {
|
|
|
3668
3747
|
// src/environment-settings.ts
|
|
3669
3748
|
function createEnvironmentSettings(environments) {
|
|
3670
3749
|
return {
|
|
3750
|
+
getEnvironmentCredential: (key) => {
|
|
3751
|
+
const currentEnv = process.env.INKEEP_ENV || "development";
|
|
3752
|
+
const env = environments[currentEnv];
|
|
3753
|
+
if (!env) {
|
|
3754
|
+
throw new Error(
|
|
3755
|
+
`Environment '${currentEnv}' not found. Available: ${Object.keys(environments).join(", ")}`
|
|
3756
|
+
);
|
|
3757
|
+
}
|
|
3758
|
+
const credential2 = env.credentials?.[key];
|
|
3759
|
+
if (!credential2) {
|
|
3760
|
+
throw new Error(`Credential '${String(key)}' not found in environment '${currentEnv}'`);
|
|
3761
|
+
}
|
|
3762
|
+
return credential2;
|
|
3763
|
+
},
|
|
3764
|
+
getEnvironmentMcp: (key) => {
|
|
3765
|
+
const currentEnv = process.env.INKEEP_ENV || "development";
|
|
3766
|
+
const env = environments[currentEnv];
|
|
3767
|
+
if (!env) {
|
|
3768
|
+
throw new Error(
|
|
3769
|
+
`Environment '${currentEnv}' not found. Available: ${Object.keys(environments).join(", ")}`
|
|
3770
|
+
);
|
|
3771
|
+
}
|
|
3772
|
+
const mcpServer2 = env.mcpServers?.[key];
|
|
3773
|
+
if (!mcpServer2) {
|
|
3774
|
+
throw new Error(`MCP Server '${String(key)}' not found in environment '${currentEnv}'`);
|
|
3775
|
+
}
|
|
3776
|
+
return mcpServer2;
|
|
3777
|
+
},
|
|
3778
|
+
//Deprecated: Use getEnvironmentCredential instead
|
|
3671
3779
|
getEnvironmentSetting: (key) => {
|
|
3672
3780
|
const currentEnv = process.env.INKEEP_ENV || "development";
|
|
3673
3781
|
const env = environments[currentEnv];
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArtifactComponentInsert, MCPToolConfig as MCPToolConfig$1, DataComponentApiInsert, ArtifactComponentApiInsert, CredentialReferenceApiInsert, DataComponentInsert, FunctionToolConfig, SubAgentApiInsert, AgentConversationHistoryConfig, AgentStopWhen, ModelSettings, StatusUpdateSettings,
|
|
1
|
+
import { ArtifactComponentInsert, MCPToolConfig as MCPToolConfig$1, DataComponentApiInsert, ArtifactComponentApiInsert, CredentialReferenceApiInsert, DataComponentInsert, FunctionToolConfig, SubAgentApiInsert, FullAgentDefinition, AgentConversationHistoryConfig, AgentStopWhen, ModelSettings, StatusUpdateSettings, ToolInsert, McpTransportConfig, StopWhen, FullProjectDefinition, StatusComponent as StatusComponent$1 } from '@inkeep/agents-core';
|
|
2
2
|
export { ANTHROPIC_MODELS, FunctionToolConfig, GOOGLE_MODELS, ModelSettings, OPENAI_MODELS } from '@inkeep/agents-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -40,6 +40,7 @@ interface ToolInterface {
|
|
|
40
40
|
getServerUrl(): string;
|
|
41
41
|
getActiveTools(): string[] | undefined;
|
|
42
42
|
getCredentialReferenceId(): string | null | undefined;
|
|
43
|
+
with(config: AgentMcpConfigInput): AgentMcpConfig;
|
|
43
44
|
}
|
|
44
45
|
declare class Tool implements ToolInterface {
|
|
45
46
|
config: MCPToolConfig$1;
|
|
@@ -59,6 +60,23 @@ declare class Tool implements ToolInterface {
|
|
|
59
60
|
skipDatabaseRegistration?: boolean;
|
|
60
61
|
}): Promise<void>;
|
|
61
62
|
private upsertTool;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a new AgentMcpConfig with the given configuration.
|
|
65
|
+
*
|
|
66
|
+
* @param config - The configuration for the AgentMcpConfig
|
|
67
|
+
* @returns A new AgentMcpConfig
|
|
68
|
+
*
|
|
69
|
+
* example:
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const tool = new Tool({
|
|
72
|
+
* id: 'tool-id',
|
|
73
|
+
* name: 'Tool Name',
|
|
74
|
+
* serverUrl: 'https://example.com/mcp',
|
|
75
|
+
* });
|
|
76
|
+
* const agentMcpConfig = tool.with({ selectedTools: ['tool-1', 'tool-2'], headers: { 'Authorization': 'Bearer token' } });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
with(config: AgentMcpConfigInput): AgentMcpConfig;
|
|
62
80
|
}
|
|
63
81
|
|
|
64
82
|
declare class SubAgent implements SubAgentInterface {
|
|
@@ -83,12 +101,13 @@ declare class SubAgent implements SubAgentInterface {
|
|
|
83
101
|
getTransfers(): SubAgentInterface[];
|
|
84
102
|
getSubAgentDelegates(): SubAgentInterface[];
|
|
85
103
|
getExternalAgentDelegates(): subAgentExternalAgentInterface[];
|
|
86
|
-
|
|
104
|
+
getTeamAgentDelegates(): subAgentTeamAgentInterface[];
|
|
105
|
+
getDelegates(): AllDelegateOutputInterface[];
|
|
87
106
|
getDataComponents(): DataComponentApiInsert[];
|
|
88
107
|
getArtifactComponents(): ArtifactComponentApiInsert[];
|
|
89
108
|
addTool(_name: string, tool: Tool): void;
|
|
90
109
|
addTransfer(...agents: SubAgentInterface[]): void;
|
|
91
|
-
addDelegate(...agents:
|
|
110
|
+
addDelegate(...agents: AllDelegateInputInterface[]): void;
|
|
92
111
|
init(): Promise<void>;
|
|
93
112
|
private upsertAgent;
|
|
94
113
|
private saveToolsAndRelations;
|
|
@@ -137,6 +156,10 @@ interface ArtifactComponentConfig extends ComponentConfig {
|
|
|
137
156
|
}
|
|
138
157
|
interface DataComponentConfig extends ComponentConfig {
|
|
139
158
|
props: Record<string, unknown> | z.ZodObject<any>;
|
|
159
|
+
render?: {
|
|
160
|
+
component: string;
|
|
161
|
+
mockData: Record<string, unknown>;
|
|
162
|
+
};
|
|
140
163
|
}
|
|
141
164
|
interface StatusComponentConfig {
|
|
142
165
|
type: string;
|
|
@@ -148,6 +171,15 @@ type AgentMcpConfig = {
|
|
|
148
171
|
selectedTools?: string[];
|
|
149
172
|
headers?: Record<string, string>;
|
|
150
173
|
};
|
|
174
|
+
/**
|
|
175
|
+
* Input configuration for MCP tool customization
|
|
176
|
+
*/
|
|
177
|
+
type AgentMcpConfigInput = {
|
|
178
|
+
/** Specific tools to enable from the MCP server */
|
|
179
|
+
selectedTools?: string[];
|
|
180
|
+
/** Custom headers for MCP server requests */
|
|
181
|
+
headers?: Record<string, string>;
|
|
182
|
+
};
|
|
151
183
|
/**
|
|
152
184
|
* Creates a transfer configuration for agent transfers.
|
|
153
185
|
*
|
|
@@ -174,8 +206,12 @@ type AgentMcpConfig = {
|
|
|
174
206
|
*/
|
|
175
207
|
declare function transfer(targetAgent: SubAgent, description?: string, condition?: TransferConditionFunction): TransferConfig;
|
|
176
208
|
|
|
177
|
-
type DataComponentConfigWithZod = Omit<DataComponentInsert, 'tenantId' | 'projectId' | 'props'> & {
|
|
209
|
+
type DataComponentConfigWithZod = Omit<DataComponentInsert, 'tenantId' | 'projectId' | 'props' | 'render'> & {
|
|
178
210
|
props?: Record<string, unknown> | z.ZodObject<any> | null;
|
|
211
|
+
render?: {
|
|
212
|
+
component: string;
|
|
213
|
+
mockData: Record<string, unknown>;
|
|
214
|
+
} | null;
|
|
179
215
|
};
|
|
180
216
|
interface DataComponentInterface {
|
|
181
217
|
config: Omit<DataComponentInsert, 'tenantId' | 'projectId'>;
|
|
@@ -199,6 +235,7 @@ declare class DataComponent implements DataComponentInterface {
|
|
|
199
235
|
getName(): string;
|
|
200
236
|
getDescription(): string;
|
|
201
237
|
getProps(): DataComponentInsert['props'];
|
|
238
|
+
getRender(): DataComponentInsert['render'];
|
|
202
239
|
init(): Promise<void>;
|
|
203
240
|
private upsertDataComponent;
|
|
204
241
|
}
|
|
@@ -347,13 +384,14 @@ interface ToolResult {
|
|
|
347
384
|
result: any;
|
|
348
385
|
error?: string;
|
|
349
386
|
}
|
|
350
|
-
type
|
|
387
|
+
type AllDelegateInputInterface = SubAgentInterface | subAgentExternalAgentInterface | ExternalAgentInterface | AgentInterface | subAgentTeamAgentInterface;
|
|
388
|
+
type AllDelegateOutputInterface = SubAgentInterface | subAgentExternalAgentInterface | subAgentTeamAgentInterface;
|
|
351
389
|
type SubAgentCanUseType = Tool | AgentMcpConfig | FunctionTool;
|
|
352
390
|
interface SubAgentConfig extends Omit<SubAgentApiInsert, 'projectId'> {
|
|
353
391
|
type?: 'internal';
|
|
354
392
|
canUse?: () => SubAgentCanUseType[];
|
|
355
393
|
canTransferTo?: () => SubAgentInterface[];
|
|
356
|
-
canDelegateTo?: () =>
|
|
394
|
+
canDelegateTo?: () => AllDelegateInputInterface[];
|
|
357
395
|
dataComponents?: () => (DataComponentApiInsert | DataComponentInterface | DataComponentWithZodProps)[];
|
|
358
396
|
artifactComponents?: () => (ArtifactComponentApiInsert | ArtifactComponentInterface | ArtifactComponentWithZodProps)[];
|
|
359
397
|
conversationHistoryConfig?: AgentConversationHistoryConfig;
|
|
@@ -462,7 +500,7 @@ interface AgentConfig {
|
|
|
462
500
|
id: string;
|
|
463
501
|
name?: string;
|
|
464
502
|
description?: string;
|
|
465
|
-
defaultSubAgent
|
|
503
|
+
defaultSubAgent: SubAgentInterface;
|
|
466
504
|
subAgents?: () => SubAgentInterface[];
|
|
467
505
|
contextConfig?: any;
|
|
468
506
|
credentials?: () => CredentialReferenceApiInsert[];
|
|
@@ -499,7 +537,7 @@ interface SubAgentInterface {
|
|
|
499
537
|
getInstructions(): string;
|
|
500
538
|
getTools(): Record<string, AgentTool>;
|
|
501
539
|
getTransfers(): SubAgentInterface[];
|
|
502
|
-
getDelegates():
|
|
540
|
+
getDelegates(): AllDelegateOutputInterface[];
|
|
503
541
|
getSubAgentDelegates(): SubAgentInterface[];
|
|
504
542
|
getExternalAgentDelegates(): subAgentExternalAgentInterface[];
|
|
505
543
|
getDataComponents(): DataComponentApiInsert[];
|
|
@@ -507,7 +545,7 @@ interface SubAgentInterface {
|
|
|
507
545
|
setContext(tenantId: string, projectId: string, baseURL?: string): void;
|
|
508
546
|
addTool(name: string, tool: any): void;
|
|
509
547
|
addTransfer(...agents: SubAgentInterface[]): void;
|
|
510
|
-
addDelegate(...agents:
|
|
548
|
+
addDelegate(...agents: AllDelegateInputInterface[]): void;
|
|
511
549
|
}
|
|
512
550
|
interface ExternalAgentInterface {
|
|
513
551
|
config: ExternalAgentConfig;
|
|
@@ -518,6 +556,9 @@ interface ExternalAgentInterface {
|
|
|
518
556
|
getDescription(): string;
|
|
519
557
|
getBaseUrl(): string;
|
|
520
558
|
setContext?(tenantId: string, projectId: string): void;
|
|
559
|
+
with(options: {
|
|
560
|
+
headers?: Record<string, string>;
|
|
561
|
+
}): subAgentExternalAgentInterface;
|
|
521
562
|
getCredentialReferenceId(): string | undefined;
|
|
522
563
|
getCredentialReference(): CredentialReferenceApiInsert | undefined;
|
|
523
564
|
}
|
|
@@ -525,6 +566,10 @@ type subAgentExternalAgentInterface = {
|
|
|
525
566
|
externalAgent: ExternalAgentInterface;
|
|
526
567
|
headers?: Record<string, string>;
|
|
527
568
|
};
|
|
569
|
+
type subAgentTeamAgentInterface = {
|
|
570
|
+
agent: AgentInterface;
|
|
571
|
+
headers?: Record<string, string>;
|
|
572
|
+
};
|
|
528
573
|
interface AgentInterface {
|
|
529
574
|
init(): Promise<void>;
|
|
530
575
|
setConfig(tenantId: string, projectId: string, apiUrl: string): void;
|
|
@@ -539,6 +584,9 @@ interface AgentInterface {
|
|
|
539
584
|
getSubAgent(name: string): SubAgentInterface | undefined;
|
|
540
585
|
getSubAgents(): SubAgentInterface[];
|
|
541
586
|
toFullAgentDefinition(): Promise<FullAgentDefinition>;
|
|
587
|
+
with(options: {
|
|
588
|
+
headers?: Record<string, string>;
|
|
589
|
+
}): subAgentTeamAgentInterface;
|
|
542
590
|
}
|
|
543
591
|
interface BuilderToolConfig {
|
|
544
592
|
name: string;
|
|
@@ -686,6 +734,9 @@ declare class Agent implements AgentInterface {
|
|
|
686
734
|
agentId: string;
|
|
687
735
|
tenantId: string;
|
|
688
736
|
};
|
|
737
|
+
with(options: {
|
|
738
|
+
headers?: Record<string, string>;
|
|
739
|
+
}): subAgentTeamAgentInterface;
|
|
689
740
|
/**
|
|
690
741
|
* Validate the agent configuration
|
|
691
742
|
*/
|
|
@@ -697,7 +748,7 @@ declare class Agent implements AgentInterface {
|
|
|
697
748
|
/**
|
|
698
749
|
* Type guard to check if an agent is an internal AgentInterface
|
|
699
750
|
*/
|
|
700
|
-
isInternalAgent(agent:
|
|
751
|
+
isInternalAgent(agent: AllDelegateInputInterface): agent is SubAgentInterface;
|
|
701
752
|
/**
|
|
702
753
|
* Get project-level model settingsuration defaults
|
|
703
754
|
*/
|
|
@@ -1172,6 +1223,14 @@ declare function dataComponent(config: DataComponentConfig): DataComponent;
|
|
|
1172
1223
|
* ```
|
|
1173
1224
|
*/
|
|
1174
1225
|
declare function statusComponent(config: StatusComponentConfig): StatusComponent;
|
|
1226
|
+
/**
|
|
1227
|
+
* (deprecated in favor of mcpTool.with()) Creates an agent MCP configuration.
|
|
1228
|
+
*
|
|
1229
|
+
* Agent MCP configurations are used to configure the MCP server for an agent.
|
|
1230
|
+
*
|
|
1231
|
+
* @param config - Agent MCP configuration
|
|
1232
|
+
* @returns An AgentMcpConfig instance
|
|
1233
|
+
*/
|
|
1175
1234
|
declare function agentMcp(config: AgentMcpConfig): AgentMcpConfig;
|
|
1176
1235
|
/**
|
|
1177
1236
|
* Creates a function tool that executes user-defined code in a sandboxed environment.
|
|
@@ -1263,16 +1322,33 @@ type ExtractCredentialIds<T> = T extends {
|
|
|
1263
1322
|
type UnionCredentialIds<T extends Record<string, any>> = {
|
|
1264
1323
|
[K in keyof T]: ExtractCredentialIds<T[K]>;
|
|
1265
1324
|
}[keyof T];
|
|
1325
|
+
/**
|
|
1326
|
+
* Type helper to extract tool IDs from environment configuration
|
|
1327
|
+
*/
|
|
1328
|
+
type ExtractMcpServerIds<T> = T extends {
|
|
1329
|
+
mcpServers?: infer T;
|
|
1330
|
+
} ? T extends Record<string, any> ? keyof T : never : never;
|
|
1331
|
+
/**
|
|
1332
|
+
* Type helper to create a union of all available tool IDs from multiple environments
|
|
1333
|
+
*/
|
|
1334
|
+
type UnionMcpServerIds<T extends Record<string, any>> = {
|
|
1335
|
+
[K in keyof T]: ExtractMcpServerIds<T[K]>;
|
|
1336
|
+
}[keyof T];
|
|
1266
1337
|
|
|
1267
1338
|
interface EnvironmentSettingsConfig {
|
|
1268
1339
|
credentials?: {
|
|
1269
1340
|
[settingId: string]: CredentialReferenceApiInsert;
|
|
1270
1341
|
};
|
|
1342
|
+
mcpServers?: {
|
|
1343
|
+
[mcpServerId: string]: Tool;
|
|
1344
|
+
};
|
|
1271
1345
|
}
|
|
1272
1346
|
/**
|
|
1273
1347
|
* Create a setting helper with TypeScript autocomplete
|
|
1274
1348
|
*/
|
|
1275
1349
|
declare function createEnvironmentSettings<T extends Record<string, EnvironmentSettingsConfig>>(environments: T): {
|
|
1350
|
+
getEnvironmentCredential: (key: UnionCredentialIds<T>) => CredentialReferenceApiInsert;
|
|
1351
|
+
getEnvironmentMcp: (key: UnionMcpServerIds<T>) => Tool;
|
|
1276
1352
|
getEnvironmentSetting: (key: UnionCredentialIds<T>) => CredentialReferenceApiInsert;
|
|
1277
1353
|
};
|
|
1278
1354
|
/**
|
|
@@ -1339,4 +1415,4 @@ declare const run: typeof Runner.run;
|
|
|
1339
1415
|
declare const stream: typeof Runner.stream;
|
|
1340
1416
|
declare const raceAgents: typeof Runner.raceAgents;
|
|
1341
1417
|
|
|
1342
|
-
export { type AgentConfig, AgentError, type AgentInterface, type AgentResponse, type AgentTool, type
|
|
1418
|
+
export { type AgentConfig, AgentError, type AgentInterface, type AgentResponse, type AgentTool, type AllDelegateInputInterface, type AllDelegateOutputInterface, ArtifactComponent, type ArtifactComponentInterface, type ArtifactComponentWithZodProps, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, type CredentialReference, DataComponent, type DataComponentInterface, type DataComponentWithZodProps, ExternalAgent, type ExternalAgentInterface, type ExtractCredentialIds, type FetchDefinitionConfig, FunctionTool, type GenerateOptions, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, Project, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, StatusComponent, type StatusComponentInterface, type StreamEvent, type StreamResponse, SubAgent, type SubAgentCanUseType, type SubAgentConfig, type SubAgentInterface, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UnionCredentialIds, type UserMessage, agent, agentMcp, artifactComponent, createEnvironmentSettings, createFullProjectViaAPI, credential, credentialRef, dataComponent, deleteFullProjectViaAPI, externalAgent, externalAgents, functionTool, getFullProjectViaAPI, isCredentialReference, mcpServer, mcpTool, project, raceAgents, registerEnvironmentSettings, run, statusComponent, stream, subAgent, type subAgentExternalAgentInterface, type subAgentTeamAgentInterface, transfer, updateFullProjectViaAPI };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArtifactComponentInsert, MCPToolConfig as MCPToolConfig$1, DataComponentApiInsert, ArtifactComponentApiInsert, CredentialReferenceApiInsert, DataComponentInsert, FunctionToolConfig, SubAgentApiInsert, AgentConversationHistoryConfig, AgentStopWhen, ModelSettings, StatusUpdateSettings,
|
|
1
|
+
import { ArtifactComponentInsert, MCPToolConfig as MCPToolConfig$1, DataComponentApiInsert, ArtifactComponentApiInsert, CredentialReferenceApiInsert, DataComponentInsert, FunctionToolConfig, SubAgentApiInsert, FullAgentDefinition, AgentConversationHistoryConfig, AgentStopWhen, ModelSettings, StatusUpdateSettings, ToolInsert, McpTransportConfig, StopWhen, FullProjectDefinition, StatusComponent as StatusComponent$1 } from '@inkeep/agents-core';
|
|
2
2
|
export { ANTHROPIC_MODELS, FunctionToolConfig, GOOGLE_MODELS, ModelSettings, OPENAI_MODELS } from '@inkeep/agents-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -40,6 +40,7 @@ interface ToolInterface {
|
|
|
40
40
|
getServerUrl(): string;
|
|
41
41
|
getActiveTools(): string[] | undefined;
|
|
42
42
|
getCredentialReferenceId(): string | null | undefined;
|
|
43
|
+
with(config: AgentMcpConfigInput): AgentMcpConfig;
|
|
43
44
|
}
|
|
44
45
|
declare class Tool implements ToolInterface {
|
|
45
46
|
config: MCPToolConfig$1;
|
|
@@ -59,6 +60,23 @@ declare class Tool implements ToolInterface {
|
|
|
59
60
|
skipDatabaseRegistration?: boolean;
|
|
60
61
|
}): Promise<void>;
|
|
61
62
|
private upsertTool;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a new AgentMcpConfig with the given configuration.
|
|
65
|
+
*
|
|
66
|
+
* @param config - The configuration for the AgentMcpConfig
|
|
67
|
+
* @returns A new AgentMcpConfig
|
|
68
|
+
*
|
|
69
|
+
* example:
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const tool = new Tool({
|
|
72
|
+
* id: 'tool-id',
|
|
73
|
+
* name: 'Tool Name',
|
|
74
|
+
* serverUrl: 'https://example.com/mcp',
|
|
75
|
+
* });
|
|
76
|
+
* const agentMcpConfig = tool.with({ selectedTools: ['tool-1', 'tool-2'], headers: { 'Authorization': 'Bearer token' } });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
with(config: AgentMcpConfigInput): AgentMcpConfig;
|
|
62
80
|
}
|
|
63
81
|
|
|
64
82
|
declare class SubAgent implements SubAgentInterface {
|
|
@@ -83,12 +101,13 @@ declare class SubAgent implements SubAgentInterface {
|
|
|
83
101
|
getTransfers(): SubAgentInterface[];
|
|
84
102
|
getSubAgentDelegates(): SubAgentInterface[];
|
|
85
103
|
getExternalAgentDelegates(): subAgentExternalAgentInterface[];
|
|
86
|
-
|
|
104
|
+
getTeamAgentDelegates(): subAgentTeamAgentInterface[];
|
|
105
|
+
getDelegates(): AllDelegateOutputInterface[];
|
|
87
106
|
getDataComponents(): DataComponentApiInsert[];
|
|
88
107
|
getArtifactComponents(): ArtifactComponentApiInsert[];
|
|
89
108
|
addTool(_name: string, tool: Tool): void;
|
|
90
109
|
addTransfer(...agents: SubAgentInterface[]): void;
|
|
91
|
-
addDelegate(...agents:
|
|
110
|
+
addDelegate(...agents: AllDelegateInputInterface[]): void;
|
|
92
111
|
init(): Promise<void>;
|
|
93
112
|
private upsertAgent;
|
|
94
113
|
private saveToolsAndRelations;
|
|
@@ -137,6 +156,10 @@ interface ArtifactComponentConfig extends ComponentConfig {
|
|
|
137
156
|
}
|
|
138
157
|
interface DataComponentConfig extends ComponentConfig {
|
|
139
158
|
props: Record<string, unknown> | z.ZodObject<any>;
|
|
159
|
+
render?: {
|
|
160
|
+
component: string;
|
|
161
|
+
mockData: Record<string, unknown>;
|
|
162
|
+
};
|
|
140
163
|
}
|
|
141
164
|
interface StatusComponentConfig {
|
|
142
165
|
type: string;
|
|
@@ -148,6 +171,15 @@ type AgentMcpConfig = {
|
|
|
148
171
|
selectedTools?: string[];
|
|
149
172
|
headers?: Record<string, string>;
|
|
150
173
|
};
|
|
174
|
+
/**
|
|
175
|
+
* Input configuration for MCP tool customization
|
|
176
|
+
*/
|
|
177
|
+
type AgentMcpConfigInput = {
|
|
178
|
+
/** Specific tools to enable from the MCP server */
|
|
179
|
+
selectedTools?: string[];
|
|
180
|
+
/** Custom headers for MCP server requests */
|
|
181
|
+
headers?: Record<string, string>;
|
|
182
|
+
};
|
|
151
183
|
/**
|
|
152
184
|
* Creates a transfer configuration for agent transfers.
|
|
153
185
|
*
|
|
@@ -174,8 +206,12 @@ type AgentMcpConfig = {
|
|
|
174
206
|
*/
|
|
175
207
|
declare function transfer(targetAgent: SubAgent, description?: string, condition?: TransferConditionFunction): TransferConfig;
|
|
176
208
|
|
|
177
|
-
type DataComponentConfigWithZod = Omit<DataComponentInsert, 'tenantId' | 'projectId' | 'props'> & {
|
|
209
|
+
type DataComponentConfigWithZod = Omit<DataComponentInsert, 'tenantId' | 'projectId' | 'props' | 'render'> & {
|
|
178
210
|
props?: Record<string, unknown> | z.ZodObject<any> | null;
|
|
211
|
+
render?: {
|
|
212
|
+
component: string;
|
|
213
|
+
mockData: Record<string, unknown>;
|
|
214
|
+
} | null;
|
|
179
215
|
};
|
|
180
216
|
interface DataComponentInterface {
|
|
181
217
|
config: Omit<DataComponentInsert, 'tenantId' | 'projectId'>;
|
|
@@ -199,6 +235,7 @@ declare class DataComponent implements DataComponentInterface {
|
|
|
199
235
|
getName(): string;
|
|
200
236
|
getDescription(): string;
|
|
201
237
|
getProps(): DataComponentInsert['props'];
|
|
238
|
+
getRender(): DataComponentInsert['render'];
|
|
202
239
|
init(): Promise<void>;
|
|
203
240
|
private upsertDataComponent;
|
|
204
241
|
}
|
|
@@ -347,13 +384,14 @@ interface ToolResult {
|
|
|
347
384
|
result: any;
|
|
348
385
|
error?: string;
|
|
349
386
|
}
|
|
350
|
-
type
|
|
387
|
+
type AllDelegateInputInterface = SubAgentInterface | subAgentExternalAgentInterface | ExternalAgentInterface | AgentInterface | subAgentTeamAgentInterface;
|
|
388
|
+
type AllDelegateOutputInterface = SubAgentInterface | subAgentExternalAgentInterface | subAgentTeamAgentInterface;
|
|
351
389
|
type SubAgentCanUseType = Tool | AgentMcpConfig | FunctionTool;
|
|
352
390
|
interface SubAgentConfig extends Omit<SubAgentApiInsert, 'projectId'> {
|
|
353
391
|
type?: 'internal';
|
|
354
392
|
canUse?: () => SubAgentCanUseType[];
|
|
355
393
|
canTransferTo?: () => SubAgentInterface[];
|
|
356
|
-
canDelegateTo?: () =>
|
|
394
|
+
canDelegateTo?: () => AllDelegateInputInterface[];
|
|
357
395
|
dataComponents?: () => (DataComponentApiInsert | DataComponentInterface | DataComponentWithZodProps)[];
|
|
358
396
|
artifactComponents?: () => (ArtifactComponentApiInsert | ArtifactComponentInterface | ArtifactComponentWithZodProps)[];
|
|
359
397
|
conversationHistoryConfig?: AgentConversationHistoryConfig;
|
|
@@ -462,7 +500,7 @@ interface AgentConfig {
|
|
|
462
500
|
id: string;
|
|
463
501
|
name?: string;
|
|
464
502
|
description?: string;
|
|
465
|
-
defaultSubAgent
|
|
503
|
+
defaultSubAgent: SubAgentInterface;
|
|
466
504
|
subAgents?: () => SubAgentInterface[];
|
|
467
505
|
contextConfig?: any;
|
|
468
506
|
credentials?: () => CredentialReferenceApiInsert[];
|
|
@@ -499,7 +537,7 @@ interface SubAgentInterface {
|
|
|
499
537
|
getInstructions(): string;
|
|
500
538
|
getTools(): Record<string, AgentTool>;
|
|
501
539
|
getTransfers(): SubAgentInterface[];
|
|
502
|
-
getDelegates():
|
|
540
|
+
getDelegates(): AllDelegateOutputInterface[];
|
|
503
541
|
getSubAgentDelegates(): SubAgentInterface[];
|
|
504
542
|
getExternalAgentDelegates(): subAgentExternalAgentInterface[];
|
|
505
543
|
getDataComponents(): DataComponentApiInsert[];
|
|
@@ -507,7 +545,7 @@ interface SubAgentInterface {
|
|
|
507
545
|
setContext(tenantId: string, projectId: string, baseURL?: string): void;
|
|
508
546
|
addTool(name: string, tool: any): void;
|
|
509
547
|
addTransfer(...agents: SubAgentInterface[]): void;
|
|
510
|
-
addDelegate(...agents:
|
|
548
|
+
addDelegate(...agents: AllDelegateInputInterface[]): void;
|
|
511
549
|
}
|
|
512
550
|
interface ExternalAgentInterface {
|
|
513
551
|
config: ExternalAgentConfig;
|
|
@@ -518,6 +556,9 @@ interface ExternalAgentInterface {
|
|
|
518
556
|
getDescription(): string;
|
|
519
557
|
getBaseUrl(): string;
|
|
520
558
|
setContext?(tenantId: string, projectId: string): void;
|
|
559
|
+
with(options: {
|
|
560
|
+
headers?: Record<string, string>;
|
|
561
|
+
}): subAgentExternalAgentInterface;
|
|
521
562
|
getCredentialReferenceId(): string | undefined;
|
|
522
563
|
getCredentialReference(): CredentialReferenceApiInsert | undefined;
|
|
523
564
|
}
|
|
@@ -525,6 +566,10 @@ type subAgentExternalAgentInterface = {
|
|
|
525
566
|
externalAgent: ExternalAgentInterface;
|
|
526
567
|
headers?: Record<string, string>;
|
|
527
568
|
};
|
|
569
|
+
type subAgentTeamAgentInterface = {
|
|
570
|
+
agent: AgentInterface;
|
|
571
|
+
headers?: Record<string, string>;
|
|
572
|
+
};
|
|
528
573
|
interface AgentInterface {
|
|
529
574
|
init(): Promise<void>;
|
|
530
575
|
setConfig(tenantId: string, projectId: string, apiUrl: string): void;
|
|
@@ -539,6 +584,9 @@ interface AgentInterface {
|
|
|
539
584
|
getSubAgent(name: string): SubAgentInterface | undefined;
|
|
540
585
|
getSubAgents(): SubAgentInterface[];
|
|
541
586
|
toFullAgentDefinition(): Promise<FullAgentDefinition>;
|
|
587
|
+
with(options: {
|
|
588
|
+
headers?: Record<string, string>;
|
|
589
|
+
}): subAgentTeamAgentInterface;
|
|
542
590
|
}
|
|
543
591
|
interface BuilderToolConfig {
|
|
544
592
|
name: string;
|
|
@@ -686,6 +734,9 @@ declare class Agent implements AgentInterface {
|
|
|
686
734
|
agentId: string;
|
|
687
735
|
tenantId: string;
|
|
688
736
|
};
|
|
737
|
+
with(options: {
|
|
738
|
+
headers?: Record<string, string>;
|
|
739
|
+
}): subAgentTeamAgentInterface;
|
|
689
740
|
/**
|
|
690
741
|
* Validate the agent configuration
|
|
691
742
|
*/
|
|
@@ -697,7 +748,7 @@ declare class Agent implements AgentInterface {
|
|
|
697
748
|
/**
|
|
698
749
|
* Type guard to check if an agent is an internal AgentInterface
|
|
699
750
|
*/
|
|
700
|
-
isInternalAgent(agent:
|
|
751
|
+
isInternalAgent(agent: AllDelegateInputInterface): agent is SubAgentInterface;
|
|
701
752
|
/**
|
|
702
753
|
* Get project-level model settingsuration defaults
|
|
703
754
|
*/
|
|
@@ -1172,6 +1223,14 @@ declare function dataComponent(config: DataComponentConfig): DataComponent;
|
|
|
1172
1223
|
* ```
|
|
1173
1224
|
*/
|
|
1174
1225
|
declare function statusComponent(config: StatusComponentConfig): StatusComponent;
|
|
1226
|
+
/**
|
|
1227
|
+
* (deprecated in favor of mcpTool.with()) Creates an agent MCP configuration.
|
|
1228
|
+
*
|
|
1229
|
+
* Agent MCP configurations are used to configure the MCP server for an agent.
|
|
1230
|
+
*
|
|
1231
|
+
* @param config - Agent MCP configuration
|
|
1232
|
+
* @returns An AgentMcpConfig instance
|
|
1233
|
+
*/
|
|
1175
1234
|
declare function agentMcp(config: AgentMcpConfig): AgentMcpConfig;
|
|
1176
1235
|
/**
|
|
1177
1236
|
* Creates a function tool that executes user-defined code in a sandboxed environment.
|
|
@@ -1263,16 +1322,33 @@ type ExtractCredentialIds<T> = T extends {
|
|
|
1263
1322
|
type UnionCredentialIds<T extends Record<string, any>> = {
|
|
1264
1323
|
[K in keyof T]: ExtractCredentialIds<T[K]>;
|
|
1265
1324
|
}[keyof T];
|
|
1325
|
+
/**
|
|
1326
|
+
* Type helper to extract tool IDs from environment configuration
|
|
1327
|
+
*/
|
|
1328
|
+
type ExtractMcpServerIds<T> = T extends {
|
|
1329
|
+
mcpServers?: infer T;
|
|
1330
|
+
} ? T extends Record<string, any> ? keyof T : never : never;
|
|
1331
|
+
/**
|
|
1332
|
+
* Type helper to create a union of all available tool IDs from multiple environments
|
|
1333
|
+
*/
|
|
1334
|
+
type UnionMcpServerIds<T extends Record<string, any>> = {
|
|
1335
|
+
[K in keyof T]: ExtractMcpServerIds<T[K]>;
|
|
1336
|
+
}[keyof T];
|
|
1266
1337
|
|
|
1267
1338
|
interface EnvironmentSettingsConfig {
|
|
1268
1339
|
credentials?: {
|
|
1269
1340
|
[settingId: string]: CredentialReferenceApiInsert;
|
|
1270
1341
|
};
|
|
1342
|
+
mcpServers?: {
|
|
1343
|
+
[mcpServerId: string]: Tool;
|
|
1344
|
+
};
|
|
1271
1345
|
}
|
|
1272
1346
|
/**
|
|
1273
1347
|
* Create a setting helper with TypeScript autocomplete
|
|
1274
1348
|
*/
|
|
1275
1349
|
declare function createEnvironmentSettings<T extends Record<string, EnvironmentSettingsConfig>>(environments: T): {
|
|
1350
|
+
getEnvironmentCredential: (key: UnionCredentialIds<T>) => CredentialReferenceApiInsert;
|
|
1351
|
+
getEnvironmentMcp: (key: UnionMcpServerIds<T>) => Tool;
|
|
1276
1352
|
getEnvironmentSetting: (key: UnionCredentialIds<T>) => CredentialReferenceApiInsert;
|
|
1277
1353
|
};
|
|
1278
1354
|
/**
|
|
@@ -1339,4 +1415,4 @@ declare const run: typeof Runner.run;
|
|
|
1339
1415
|
declare const stream: typeof Runner.stream;
|
|
1340
1416
|
declare const raceAgents: typeof Runner.raceAgents;
|
|
1341
1417
|
|
|
1342
|
-
export { type AgentConfig, AgentError, type AgentInterface, type AgentResponse, type AgentTool, type
|
|
1418
|
+
export { type AgentConfig, AgentError, type AgentInterface, type AgentResponse, type AgentTool, type AllDelegateInputInterface, type AllDelegateOutputInterface, ArtifactComponent, type ArtifactComponentInterface, type ArtifactComponentWithZodProps, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, type CredentialReference, DataComponent, type DataComponentInterface, type DataComponentWithZodProps, ExternalAgent, type ExternalAgentInterface, type ExtractCredentialIds, type FetchDefinitionConfig, FunctionTool, type GenerateOptions, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, Project, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, StatusComponent, type StatusComponentInterface, type StreamEvent, type StreamResponse, SubAgent, type SubAgentCanUseType, type SubAgentConfig, type SubAgentInterface, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UnionCredentialIds, type UserMessage, agent, agentMcp, artifactComponent, createEnvironmentSettings, createFullProjectViaAPI, credential, credentialRef, dataComponent, deleteFullProjectViaAPI, externalAgent, externalAgents, functionTool, getFullProjectViaAPI, isCredentialReference, mcpServer, mcpTool, project, raceAgents, registerEnvironmentSettings, run, statusComponent, stream, subAgent, type subAgentExternalAgentInterface, type subAgentTeamAgentInterface, transfer, updateFullProjectViaAPI };
|
package/dist/index.js
CHANGED
|
@@ -487,7 +487,12 @@ var Agent = class {
|
|
|
487
487
|
this.subAgents = resolveGetter(config.subAgents) || [];
|
|
488
488
|
this.agentMap = new Map(this.subAgents.map((agent2) => [agent2.getId(), agent2]));
|
|
489
489
|
if (this.defaultSubAgent) {
|
|
490
|
-
this.subAgents.
|
|
490
|
+
const isAlreadyPresent = this.subAgents.some(
|
|
491
|
+
(agent2) => agent2.getId() === this.defaultSubAgent?.getId()
|
|
492
|
+
);
|
|
493
|
+
if (!isAlreadyPresent) {
|
|
494
|
+
this.subAgents.push(this.defaultSubAgent);
|
|
495
|
+
}
|
|
491
496
|
this.agentMap.set(this.defaultSubAgent.getId(), this.defaultSubAgent);
|
|
492
497
|
}
|
|
493
498
|
if (this.models) {
|
|
@@ -628,9 +633,10 @@ var Agent = class {
|
|
|
628
633
|
externalAgentId: d.externalAgent.getId(),
|
|
629
634
|
...d.headers && { headers: d.headers }
|
|
630
635
|
};
|
|
631
|
-
} else if (typeof d === "object" && "
|
|
636
|
+
} else if (typeof d === "object" && "agent" in d) {
|
|
632
637
|
return {
|
|
633
|
-
|
|
638
|
+
agentId: d.agent.getId(),
|
|
639
|
+
...d.headers && { headers: d.headers }
|
|
634
640
|
};
|
|
635
641
|
}
|
|
636
642
|
return d.getId();
|
|
@@ -1010,6 +1016,12 @@ var Agent = class {
|
|
|
1010
1016
|
tenantId: this.tenantId
|
|
1011
1017
|
};
|
|
1012
1018
|
}
|
|
1019
|
+
with(options) {
|
|
1020
|
+
return {
|
|
1021
|
+
agent: this,
|
|
1022
|
+
headers: options.headers
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1013
1025
|
/**
|
|
1014
1026
|
* Validate the agent configuration
|
|
1015
1027
|
*/
|
|
@@ -1478,7 +1490,8 @@ var DataComponent = class {
|
|
|
1478
1490
|
this.config = {
|
|
1479
1491
|
...config,
|
|
1480
1492
|
id: this.id,
|
|
1481
|
-
props: processedProps
|
|
1493
|
+
props: processedProps,
|
|
1494
|
+
render: config.render || null
|
|
1482
1495
|
};
|
|
1483
1496
|
this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
|
|
1484
1497
|
this.tenantId = "default";
|
|
@@ -1512,6 +1525,9 @@ var DataComponent = class {
|
|
|
1512
1525
|
getProps() {
|
|
1513
1526
|
return this.config.props;
|
|
1514
1527
|
}
|
|
1528
|
+
getRender() {
|
|
1529
|
+
return this.config.render;
|
|
1530
|
+
}
|
|
1515
1531
|
// Public method to ensure data component exists in backend (with upsert behavior)
|
|
1516
1532
|
async init() {
|
|
1517
1533
|
if (this.initialized) return;
|
|
@@ -1541,7 +1557,8 @@ var DataComponent = class {
|
|
|
1541
1557
|
id: this.getId(),
|
|
1542
1558
|
name: this.config.name,
|
|
1543
1559
|
description: this.config.description,
|
|
1544
|
-
props: this.config.props
|
|
1560
|
+
props: this.config.props,
|
|
1561
|
+
render: this.config.render
|
|
1545
1562
|
};
|
|
1546
1563
|
logger6.info({ dataComponentData }, "dataComponentData for create/update");
|
|
1547
1564
|
const updateResponse = await fetch(
|
|
@@ -2360,23 +2377,27 @@ var Project = class {
|
|
|
2360
2377
|
let dataComponentName;
|
|
2361
2378
|
let dataComponentDescription;
|
|
2362
2379
|
let dataComponentProps;
|
|
2380
|
+
let dataComponentRender;
|
|
2363
2381
|
if (dataComponent2.getId) {
|
|
2364
2382
|
dataComponentId = dataComponent2.getId();
|
|
2365
2383
|
dataComponentName = dataComponent2.getName();
|
|
2366
2384
|
dataComponentDescription = dataComponent2.getDescription() || "";
|
|
2367
2385
|
dataComponentProps = dataComponent2.getProps() || {};
|
|
2386
|
+
dataComponentRender = dataComponent2.getRender?.() || null;
|
|
2368
2387
|
} else {
|
|
2369
2388
|
dataComponentId = dataComponent2.id || (dataComponent2.name ? dataComponent2.name.toLowerCase().replace(/\s+/g, "-") : "");
|
|
2370
2389
|
dataComponentName = dataComponent2.name || "";
|
|
2371
2390
|
dataComponentDescription = dataComponent2.description || "";
|
|
2372
2391
|
dataComponentProps = dataComponent2.props || {};
|
|
2392
|
+
dataComponentRender = dataComponent2.render || null;
|
|
2373
2393
|
}
|
|
2374
2394
|
if (!dataComponentsObject[dataComponentId] && dataComponentName) {
|
|
2375
2395
|
dataComponentsObject[dataComponentId] = {
|
|
2376
2396
|
id: dataComponentId,
|
|
2377
2397
|
name: dataComponentName,
|
|
2378
2398
|
description: dataComponentDescription,
|
|
2379
|
-
props: dataComponentProps
|
|
2399
|
+
props: dataComponentProps,
|
|
2400
|
+
render: dataComponentRender
|
|
2380
2401
|
};
|
|
2381
2402
|
}
|
|
2382
2403
|
}
|
|
@@ -2717,6 +2738,29 @@ var Tool = class {
|
|
|
2717
2738
|
}
|
|
2718
2739
|
throw new Error(`Failed to update tool: ${updateResponse.status}`);
|
|
2719
2740
|
}
|
|
2741
|
+
/**
|
|
2742
|
+
* Creates a new AgentMcpConfig with the given configuration.
|
|
2743
|
+
*
|
|
2744
|
+
* @param config - The configuration for the AgentMcpConfig
|
|
2745
|
+
* @returns A new AgentMcpConfig
|
|
2746
|
+
*
|
|
2747
|
+
* example:
|
|
2748
|
+
* ```typescript
|
|
2749
|
+
* const tool = new Tool({
|
|
2750
|
+
* id: 'tool-id',
|
|
2751
|
+
* name: 'Tool Name',
|
|
2752
|
+
* serverUrl: 'https://example.com/mcp',
|
|
2753
|
+
* });
|
|
2754
|
+
* const agentMcpConfig = tool.with({ selectedTools: ['tool-1', 'tool-2'], headers: { 'Authorization': 'Bearer token' } });
|
|
2755
|
+
* ```
|
|
2756
|
+
*/
|
|
2757
|
+
with(config) {
|
|
2758
|
+
return {
|
|
2759
|
+
server: this,
|
|
2760
|
+
selectedTools: config.selectedTools,
|
|
2761
|
+
headers: config.headers
|
|
2762
|
+
};
|
|
2763
|
+
}
|
|
2720
2764
|
};
|
|
2721
2765
|
|
|
2722
2766
|
// src/utils/tool-normalization.ts
|
|
@@ -2844,6 +2888,12 @@ var SubAgent = class {
|
|
|
2844
2888
|
if (typeof delegate === "object" && "externalAgent" in delegate) {
|
|
2845
2889
|
return false;
|
|
2846
2890
|
}
|
|
2891
|
+
if (typeof delegate === "object" && "agent" in delegate) {
|
|
2892
|
+
return false;
|
|
2893
|
+
}
|
|
2894
|
+
if (typeof delegate === "object" && "toFullAgentDefinition" in delegate) {
|
|
2895
|
+
return false;
|
|
2896
|
+
}
|
|
2847
2897
|
if (typeof delegate === "object" && "type" in delegate && delegate.type === "external") {
|
|
2848
2898
|
return false;
|
|
2849
2899
|
}
|
|
@@ -2872,8 +2922,34 @@ var SubAgent = class {
|
|
|
2872
2922
|
};
|
|
2873
2923
|
});
|
|
2874
2924
|
}
|
|
2925
|
+
getTeamAgentDelegates() {
|
|
2926
|
+
if (typeof this.config.canDelegateTo !== "function") {
|
|
2927
|
+
return [];
|
|
2928
|
+
}
|
|
2929
|
+
return this.config.canDelegateTo().filter((delegate) => {
|
|
2930
|
+
if (typeof delegate === "object" && "agent" in delegate) {
|
|
2931
|
+
return true;
|
|
2932
|
+
}
|
|
2933
|
+
if (typeof delegate === "object" && "toFullAgentDefinition" in delegate) {
|
|
2934
|
+
return true;
|
|
2935
|
+
}
|
|
2936
|
+
return false;
|
|
2937
|
+
}).map((delegate) => {
|
|
2938
|
+
if ("agent" in delegate) {
|
|
2939
|
+
return delegate;
|
|
2940
|
+
}
|
|
2941
|
+
return {
|
|
2942
|
+
agent: delegate,
|
|
2943
|
+
headers: void 0
|
|
2944
|
+
};
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2875
2947
|
getDelegates() {
|
|
2876
|
-
return
|
|
2948
|
+
return [
|
|
2949
|
+
...this.getSubAgentDelegates(),
|
|
2950
|
+
...this.getTeamAgentDelegates(),
|
|
2951
|
+
...this.getExternalAgentDelegates()
|
|
2952
|
+
];
|
|
2877
2953
|
}
|
|
2878
2954
|
getDataComponents() {
|
|
2879
2955
|
const components = resolveGetter2(this.config.dataComponents) || [];
|
|
@@ -2883,7 +2959,8 @@ var SubAgent = class {
|
|
|
2883
2959
|
id: comp.getId(),
|
|
2884
2960
|
name: comp.getName(),
|
|
2885
2961
|
description: comp.getDescription(),
|
|
2886
|
-
props: comp.getProps()
|
|
2962
|
+
props: comp.getProps(),
|
|
2963
|
+
render: comp.getRender?.() || null
|
|
2887
2964
|
};
|
|
2888
2965
|
}
|
|
2889
2966
|
if (comp && typeof comp === "object" && comp.props && isZodSchema(comp.props)) {
|
|
@@ -2891,7 +2968,8 @@ var SubAgent = class {
|
|
|
2891
2968
|
id: comp.id,
|
|
2892
2969
|
name: comp.name,
|
|
2893
2970
|
description: comp.description,
|
|
2894
|
-
props: convertZodToJsonSchemaWithPreview(comp.props)
|
|
2971
|
+
props: convertZodToJsonSchemaWithPreview(comp.props),
|
|
2972
|
+
render: comp.render || null
|
|
2895
2973
|
};
|
|
2896
2974
|
}
|
|
2897
2975
|
return comp;
|
|
@@ -3383,7 +3461,8 @@ var SubAgent = class {
|
|
|
3383
3461
|
id: dataComponent2.id,
|
|
3384
3462
|
name: dataComponent2.name,
|
|
3385
3463
|
description: dataComponent2.description,
|
|
3386
|
-
props: dataComponent2.props
|
|
3464
|
+
props: dataComponent2.props,
|
|
3465
|
+
render: dataComponent2.render
|
|
3387
3466
|
});
|
|
3388
3467
|
dc.setContext(this.tenantId, this.projectId);
|
|
3389
3468
|
await dc.init();
|
|
@@ -3641,6 +3720,35 @@ function isCredentialReference(value) {
|
|
|
3641
3720
|
// src/environment-settings.ts
|
|
3642
3721
|
function createEnvironmentSettings(environments) {
|
|
3643
3722
|
return {
|
|
3723
|
+
getEnvironmentCredential: (key) => {
|
|
3724
|
+
const currentEnv = process.env.INKEEP_ENV || "development";
|
|
3725
|
+
const env = environments[currentEnv];
|
|
3726
|
+
if (!env) {
|
|
3727
|
+
throw new Error(
|
|
3728
|
+
`Environment '${currentEnv}' not found. Available: ${Object.keys(environments).join(", ")}`
|
|
3729
|
+
);
|
|
3730
|
+
}
|
|
3731
|
+
const credential2 = env.credentials?.[key];
|
|
3732
|
+
if (!credential2) {
|
|
3733
|
+
throw new Error(`Credential '${String(key)}' not found in environment '${currentEnv}'`);
|
|
3734
|
+
}
|
|
3735
|
+
return credential2;
|
|
3736
|
+
},
|
|
3737
|
+
getEnvironmentMcp: (key) => {
|
|
3738
|
+
const currentEnv = process.env.INKEEP_ENV || "development";
|
|
3739
|
+
const env = environments[currentEnv];
|
|
3740
|
+
if (!env) {
|
|
3741
|
+
throw new Error(
|
|
3742
|
+
`Environment '${currentEnv}' not found. Available: ${Object.keys(environments).join(", ")}`
|
|
3743
|
+
);
|
|
3744
|
+
}
|
|
3745
|
+
const mcpServer2 = env.mcpServers?.[key];
|
|
3746
|
+
if (!mcpServer2) {
|
|
3747
|
+
throw new Error(`MCP Server '${String(key)}' not found in environment '${currentEnv}'`);
|
|
3748
|
+
}
|
|
3749
|
+
return mcpServer2;
|
|
3750
|
+
},
|
|
3751
|
+
//Deprecated: Use getEnvironmentCredential instead
|
|
3644
3752
|
getEnvironmentSetting: (key) => {
|
|
3645
3753
|
const currentEnv = process.env.INKEEP_ENV || "development";
|
|
3646
3754
|
const env = environments[currentEnv];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.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.28.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/js-yaml": "^4.0.9",
|