@inkeep/agents-sdk 0.0.0-dev-20250910233133 → 0.0.0-dev-20250910233441
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/chunk-SMQ7HFDN.js +146 -0
- package/dist/index.cjs +2899 -0
- package/dist/index.d.cts +855 -0
- package/dist/index.d.ts +855 -11
- package/dist/index.js +2712 -10
- package/dist/tool-MDKZB6AJ.js +1 -0
- package/package.json +3 -3
- package/dist/__tests__/utils/testTenant.d.ts +0 -7
- package/dist/__tests__/utils/testTenant.d.ts.map +0 -1
- package/dist/__tests__/utils/testTenant.js +0 -10
- package/dist/__tests__/utils/testTenant.js.map +0 -1
- package/dist/agent.d.ts +0 -39
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js +0 -513
- package/dist/agent.js.map +0 -1
- package/dist/artifact-component.d.ts +0 -27
- package/dist/artifact-component.d.ts.map +0 -1
- package/dist/artifact-component.js +0 -118
- package/dist/artifact-component.js.map +0 -1
- package/dist/builders.d.ts +0 -211
- package/dist/builders.d.ts.map +0 -1
- package/dist/builders.js +0 -244
- package/dist/builders.js.map +0 -1
- package/dist/data-component.d.ts +0 -25
- package/dist/data-component.d.ts.map +0 -1
- package/dist/data-component.js +0 -114
- package/dist/data-component.js.map +0 -1
- package/dist/environment-settings.d.ts +0 -28
- package/dist/environment-settings.d.ts.map +0 -1
- package/dist/environment-settings.js +0 -79
- package/dist/environment-settings.js.map +0 -1
- package/dist/externalAgent.d.ts +0 -58
- package/dist/externalAgent.d.ts.map +0 -1
- package/dist/externalAgent.js +0 -163
- package/dist/externalAgent.js.map +0 -1
- package/dist/graph.d.ts +0 -200
- package/dist/graph.d.ts.map +0 -1
- package/dist/graph.js +0 -1322
- package/dist/graph.js.map +0 -1
- package/dist/graphFullClient.d.ts +0 -22
- package/dist/graphFullClient.d.ts.map +0 -1
- package/dist/graphFullClient.js +0 -189
- package/dist/graphFullClient.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/module-hosted-tool-manager.d.ts +0 -37
- package/dist/module-hosted-tool-manager.d.ts.map +0 -1
- package/dist/module-hosted-tool-manager.js +0 -378
- package/dist/module-hosted-tool-manager.js.map +0 -1
- package/dist/runner.d.ts +0 -38
- package/dist/runner.d.ts.map +0 -1
- package/dist/runner.js +0 -164
- package/dist/runner.js.map +0 -1
- package/dist/tool.d.ts +0 -29
- package/dist/tool.d.ts.map +0 -1
- package/dist/tool.js +0 -122
- package/dist/tool.js.map +0 -1
- package/dist/types.d.ts +0 -286
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -39
- package/dist/types.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,855 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { CredentialReferenceSelect, AgentApiInsert, DataComponentApiInsert, ArtifactComponentApiInsert, AgentConversationHistoryConfig, CredentialReferenceApiInsert, ToolInsert, McpTransportConfig, ArtifactComponentInsert, DataComponentInsert, MCPToolConfig as MCPToolConfig$1 } from '@inkeep/agents-core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
type ExternalAgentConfig = {
|
|
5
|
+
type?: "external";
|
|
6
|
+
tenantId?: string;
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
credentialReference?: CredentialReferenceSelect;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
declare class ExternalAgent implements ExternalAgentInterface {
|
|
15
|
+
config: ExternalAgentConfig;
|
|
16
|
+
readonly type: "external";
|
|
17
|
+
private initialized;
|
|
18
|
+
private tenantId;
|
|
19
|
+
private baseURL;
|
|
20
|
+
constructor(config: ExternalAgentConfig);
|
|
21
|
+
/**
|
|
22
|
+
* Initialize the external agent by upserting it in the database
|
|
23
|
+
*/
|
|
24
|
+
init(): Promise<void>;
|
|
25
|
+
getId(): string;
|
|
26
|
+
private upsertExternalAgent;
|
|
27
|
+
/**
|
|
28
|
+
* Get the external agent configuration
|
|
29
|
+
*/
|
|
30
|
+
getConfig(): ExternalAgentConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Get the external agent name
|
|
33
|
+
*/
|
|
34
|
+
getName(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Get the external agent base URL
|
|
37
|
+
*/
|
|
38
|
+
getBaseUrl(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Get the tenant ID
|
|
41
|
+
*/
|
|
42
|
+
getTenantId(): string;
|
|
43
|
+
getDescription(): string;
|
|
44
|
+
getCredentialReferenceId(): string | undefined;
|
|
45
|
+
getHeaders(): Record<string, string> | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Factory function to create external agents - follows the same pattern as agent()
|
|
49
|
+
*/
|
|
50
|
+
declare function externalAgent(config: ExternalAgentConfig): ExternalAgent;
|
|
51
|
+
/**
|
|
52
|
+
* Helper function to create multiple external agents
|
|
53
|
+
*/
|
|
54
|
+
declare function externalAgents(configs: Record<string, ExternalAgentConfig>): Record<string, ExternalAgent>;
|
|
55
|
+
|
|
56
|
+
interface UserMessage {
|
|
57
|
+
role: "user";
|
|
58
|
+
content: string;
|
|
59
|
+
}
|
|
60
|
+
interface AssistantMessage {
|
|
61
|
+
role: "assistant";
|
|
62
|
+
content: string;
|
|
63
|
+
toolCalls?: ToolCall[];
|
|
64
|
+
}
|
|
65
|
+
interface ToolMessage {
|
|
66
|
+
role: "tool";
|
|
67
|
+
content: string;
|
|
68
|
+
toolCallId: string;
|
|
69
|
+
}
|
|
70
|
+
interface SystemMessage {
|
|
71
|
+
role: "system";
|
|
72
|
+
content: string;
|
|
73
|
+
}
|
|
74
|
+
type Message = UserMessage | AssistantMessage | ToolMessage | SystemMessage;
|
|
75
|
+
type MessageInput = string | string[] | Message | Message[];
|
|
76
|
+
interface ToolCall {
|
|
77
|
+
id: string;
|
|
78
|
+
type: "function";
|
|
79
|
+
function: {
|
|
80
|
+
name: string;
|
|
81
|
+
arguments: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
interface ToolResult {
|
|
85
|
+
id: string;
|
|
86
|
+
result: any;
|
|
87
|
+
error?: string;
|
|
88
|
+
}
|
|
89
|
+
type AllAgentInterface = AgentInterface | ExternalAgentInterface;
|
|
90
|
+
interface AgentConfig extends Omit<AgentApiInsert, "projectId"> {
|
|
91
|
+
type?: "internal";
|
|
92
|
+
tools?: () => any[];
|
|
93
|
+
canTransferTo?: () => AgentInterface[];
|
|
94
|
+
canDelegateTo?: () => AllAgentInterface[];
|
|
95
|
+
tenantId?: string;
|
|
96
|
+
projectId?: string;
|
|
97
|
+
models?: {
|
|
98
|
+
base?: ModelSettings;
|
|
99
|
+
structuredOutput?: ModelSettings;
|
|
100
|
+
summarizer?: ModelSettings;
|
|
101
|
+
};
|
|
102
|
+
stopWhen?: {
|
|
103
|
+
stepCountIs?: number;
|
|
104
|
+
};
|
|
105
|
+
memory?: {
|
|
106
|
+
type: "conversation" | "episodic" | "short_term";
|
|
107
|
+
capacity?: number;
|
|
108
|
+
};
|
|
109
|
+
dataComponents?: () => DataComponentApiInsert[];
|
|
110
|
+
artifactComponents?: () => ArtifactComponentApiInsert[];
|
|
111
|
+
conversationHistoryConfig?: AgentConversationHistoryConfig;
|
|
112
|
+
}
|
|
113
|
+
interface ModelSettings {
|
|
114
|
+
model?: string;
|
|
115
|
+
providerOptions?: Record<string, Record<string, unknown>>;
|
|
116
|
+
}
|
|
117
|
+
declare const ModelSettingsSchema: z.ZodObject<{
|
|
118
|
+
model: z.ZodOptional<z.ZodString>;
|
|
119
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
interface ToolConfig extends ToolInsert {
|
|
122
|
+
execute: (params: any) => Promise<any>;
|
|
123
|
+
parameters?: Record<string, any>;
|
|
124
|
+
schema?: z.ZodJSONSchema;
|
|
125
|
+
}
|
|
126
|
+
interface ServerConfig {
|
|
127
|
+
type: string;
|
|
128
|
+
version?: string;
|
|
129
|
+
}
|
|
130
|
+
interface MCPToolConfig {
|
|
131
|
+
id: string;
|
|
132
|
+
name: string;
|
|
133
|
+
tenantId?: string;
|
|
134
|
+
description?: string;
|
|
135
|
+
credential?: CredentialReferenceApiInsert;
|
|
136
|
+
server?: ServerConfig;
|
|
137
|
+
serverUrl: string;
|
|
138
|
+
toolName?: string;
|
|
139
|
+
activeTools?: string[];
|
|
140
|
+
headers?: Record<string, string>;
|
|
141
|
+
mcpType?: "nango" | "generic";
|
|
142
|
+
transport?: McpTransportConfig;
|
|
143
|
+
imageUrl?: string;
|
|
144
|
+
}
|
|
145
|
+
interface FetchDefinitionConfig {
|
|
146
|
+
id: string;
|
|
147
|
+
name?: string;
|
|
148
|
+
trigger: "initialization" | "invocation";
|
|
149
|
+
url: string;
|
|
150
|
+
method?: string;
|
|
151
|
+
headers?: Record<string, string>;
|
|
152
|
+
body?: Record<string, unknown>;
|
|
153
|
+
transform?: string;
|
|
154
|
+
responseSchema?: z.ZodSchema<any>;
|
|
155
|
+
defaultValue?: unknown;
|
|
156
|
+
timeout?: number;
|
|
157
|
+
credential?: CredentialReferenceApiInsert;
|
|
158
|
+
}
|
|
159
|
+
interface RequestSchemaDefinition {
|
|
160
|
+
body?: z.ZodSchema<any>;
|
|
161
|
+
headers?: z.ZodSchema<any>;
|
|
162
|
+
query?: z.ZodSchema<any>;
|
|
163
|
+
params?: z.ZodSchema<any>;
|
|
164
|
+
}
|
|
165
|
+
interface RequestSchemaConfig {
|
|
166
|
+
schemas: RequestSchemaDefinition;
|
|
167
|
+
optional?: ("body" | "headers" | "query" | "params")[];
|
|
168
|
+
}
|
|
169
|
+
interface TransferConfig {
|
|
170
|
+
agent: AgentInterface;
|
|
171
|
+
description?: string;
|
|
172
|
+
condition?: (context: any) => boolean;
|
|
173
|
+
}
|
|
174
|
+
interface GenerateOptions {
|
|
175
|
+
maxTurns?: number;
|
|
176
|
+
maxSteps?: number;
|
|
177
|
+
temperature?: number;
|
|
178
|
+
toolChoice?: "auto" | "none" | string;
|
|
179
|
+
resourceId?: string;
|
|
180
|
+
conversationId?: string;
|
|
181
|
+
stream?: boolean;
|
|
182
|
+
customBodyParams?: Record<string, unknown>;
|
|
183
|
+
}
|
|
184
|
+
interface AgentResponse {
|
|
185
|
+
id?: string;
|
|
186
|
+
text: string;
|
|
187
|
+
toolCalls?: ToolCall[];
|
|
188
|
+
transfer?: TransferConfig;
|
|
189
|
+
finishReason: "completed" | "tool_calls" | "transfer" | "max_turns" | "error";
|
|
190
|
+
usage?: {
|
|
191
|
+
inputTokens: number;
|
|
192
|
+
outputTokens: number;
|
|
193
|
+
totalTokens?: number;
|
|
194
|
+
};
|
|
195
|
+
metadata?: Record<string, any>;
|
|
196
|
+
}
|
|
197
|
+
interface StreamResponse {
|
|
198
|
+
textStream?: AsyncGenerator<string>;
|
|
199
|
+
eventStream?: AsyncGenerator<StreamEvent>;
|
|
200
|
+
}
|
|
201
|
+
interface StreamEvent {
|
|
202
|
+
type: "text" | "tool_call" | "transfer" | "error" | "done";
|
|
203
|
+
data: any;
|
|
204
|
+
timestamp: Date;
|
|
205
|
+
}
|
|
206
|
+
interface RunResult {
|
|
207
|
+
finalOutput: string;
|
|
208
|
+
agent: AgentInterface;
|
|
209
|
+
turnCount: number;
|
|
210
|
+
usage?: {
|
|
211
|
+
inputTokens: number;
|
|
212
|
+
outputTokens: number;
|
|
213
|
+
totalTokens?: number;
|
|
214
|
+
};
|
|
215
|
+
metadata?: {
|
|
216
|
+
toolCalls: ToolCall[];
|
|
217
|
+
transfers: TransferConfig[];
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
interface StatusComponent {
|
|
221
|
+
id: string;
|
|
222
|
+
name: string;
|
|
223
|
+
type: string;
|
|
224
|
+
description?: string;
|
|
225
|
+
schema: {
|
|
226
|
+
type: "object";
|
|
227
|
+
properties: Record<string, any>;
|
|
228
|
+
required?: string[];
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
interface StatusUpdateSettings {
|
|
232
|
+
enabled?: boolean;
|
|
233
|
+
numEvents?: number;
|
|
234
|
+
timeInSeconds?: number;
|
|
235
|
+
model?: string;
|
|
236
|
+
statusComponents?: StatusComponent[];
|
|
237
|
+
prompt?: string;
|
|
238
|
+
}
|
|
239
|
+
interface GraphConfig {
|
|
240
|
+
id: string;
|
|
241
|
+
name?: string;
|
|
242
|
+
description?: string;
|
|
243
|
+
defaultAgent?: AgentInterface;
|
|
244
|
+
agents?: () => AllAgentInterface[];
|
|
245
|
+
tenantId?: string;
|
|
246
|
+
contextConfig?: any;
|
|
247
|
+
credentials?: () => CredentialReferenceApiInsert[];
|
|
248
|
+
stopWhen?: {
|
|
249
|
+
transferCountIs?: number;
|
|
250
|
+
};
|
|
251
|
+
graphPrompt?: string;
|
|
252
|
+
models?: {
|
|
253
|
+
base?: ModelSettings;
|
|
254
|
+
structuredOutput?: ModelSettings;
|
|
255
|
+
summarizer?: ModelSettings;
|
|
256
|
+
};
|
|
257
|
+
statusUpdates?: StatusUpdateSettings;
|
|
258
|
+
}
|
|
259
|
+
declare class AgentError extends Error {
|
|
260
|
+
code?: string | undefined;
|
|
261
|
+
details?: any | undefined;
|
|
262
|
+
constructor(message: string, code?: string | undefined, details?: any | undefined);
|
|
263
|
+
}
|
|
264
|
+
declare class MaxTurnsExceededError extends AgentError {
|
|
265
|
+
constructor(maxTurns: number);
|
|
266
|
+
}
|
|
267
|
+
declare class ToolExecutionError extends AgentError {
|
|
268
|
+
constructor(toolName: string, originalError: Error);
|
|
269
|
+
}
|
|
270
|
+
declare class TransferError extends AgentError {
|
|
271
|
+
constructor(sourceAgent: string, targetAgent: string, reason: string);
|
|
272
|
+
}
|
|
273
|
+
interface AgentInterface {
|
|
274
|
+
config: AgentConfig;
|
|
275
|
+
type: "internal";
|
|
276
|
+
init(): Promise<void>;
|
|
277
|
+
getId(): string;
|
|
278
|
+
getName(): string;
|
|
279
|
+
getInstructions(): string;
|
|
280
|
+
getTools(): Record<string, any>;
|
|
281
|
+
getTransfers(): AgentInterface[];
|
|
282
|
+
getDelegates(): AllAgentInterface[];
|
|
283
|
+
getDataComponents(): DataComponentApiInsert[];
|
|
284
|
+
getArtifactComponents(): ArtifactComponentApiInsert[];
|
|
285
|
+
addTool(name: string, tool: any): void;
|
|
286
|
+
addTransfer(...agents: AgentInterface[]): void;
|
|
287
|
+
addDelegate(...agents: AgentInterface[]): void;
|
|
288
|
+
}
|
|
289
|
+
interface ExternalAgentInterface {
|
|
290
|
+
config: ExternalAgentConfig;
|
|
291
|
+
type: "external";
|
|
292
|
+
init(): Promise<void>;
|
|
293
|
+
getId(): string;
|
|
294
|
+
getName(): string;
|
|
295
|
+
getDescription(): string;
|
|
296
|
+
getBaseUrl(): string;
|
|
297
|
+
getCredentialReferenceId(): string | undefined;
|
|
298
|
+
getHeaders(): Record<string, string> | undefined;
|
|
299
|
+
}
|
|
300
|
+
interface GraphInterface {
|
|
301
|
+
init(): Promise<void>;
|
|
302
|
+
setConfig(tenantId: string, projectId: string, apiUrl: string): void;
|
|
303
|
+
getId(): string;
|
|
304
|
+
getName(): string;
|
|
305
|
+
getDescription(): string | undefined;
|
|
306
|
+
getTenantId(): string;
|
|
307
|
+
generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
|
|
308
|
+
stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
|
|
309
|
+
generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
|
|
310
|
+
getDefaultAgent(): AgentInterface | undefined;
|
|
311
|
+
getAgent(name: string): AllAgentInterface | undefined;
|
|
312
|
+
getAgents(): AllAgentInterface[];
|
|
313
|
+
}
|
|
314
|
+
interface BuilderToolConfig {
|
|
315
|
+
name: string;
|
|
316
|
+
description: string;
|
|
317
|
+
config: {
|
|
318
|
+
type: "mcp";
|
|
319
|
+
mcp: {
|
|
320
|
+
server: {
|
|
321
|
+
url: string;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
parameters?: Record<string, any>;
|
|
326
|
+
}
|
|
327
|
+
interface BuilderRelationConfig {
|
|
328
|
+
targetAgent: string;
|
|
329
|
+
relationType: "transfer" | "delegate";
|
|
330
|
+
}
|
|
331
|
+
interface BuilderAgentConfig {
|
|
332
|
+
name: string;
|
|
333
|
+
description: string;
|
|
334
|
+
instructions: string;
|
|
335
|
+
tools: BuilderToolConfig[];
|
|
336
|
+
relations?: BuilderRelationConfig[];
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
declare class Agent implements AgentInterface {
|
|
340
|
+
config: AgentConfig;
|
|
341
|
+
readonly type: "internal";
|
|
342
|
+
private baseURL;
|
|
343
|
+
private tenantId;
|
|
344
|
+
private projectId;
|
|
345
|
+
private initialized;
|
|
346
|
+
constructor(config: AgentConfig);
|
|
347
|
+
getId(): string;
|
|
348
|
+
getName(): string;
|
|
349
|
+
getInstructions(): string;
|
|
350
|
+
getTools(): Record<string, unknown>;
|
|
351
|
+
getModels(): typeof this$1.config.models;
|
|
352
|
+
setModels(models: typeof this$1.config.models): void;
|
|
353
|
+
getTransfers(): AgentInterface[];
|
|
354
|
+
getDelegates(): AllAgentInterface[];
|
|
355
|
+
getDataComponents(): DataComponentApiInsert[];
|
|
356
|
+
getArtifactComponents(): ArtifactComponentApiInsert[];
|
|
357
|
+
addTool(_name: string, tool: unknown): void;
|
|
358
|
+
addTransfer(...agents: AgentInterface[]): void;
|
|
359
|
+
addDelegate(...agents: AllAgentInterface[]): void;
|
|
360
|
+
init(): Promise<void>;
|
|
361
|
+
private upsertAgent;
|
|
362
|
+
private saveToolsAndRelations;
|
|
363
|
+
private saveDataComponents;
|
|
364
|
+
private saveArtifactComponents;
|
|
365
|
+
private loadDataComponents;
|
|
366
|
+
private loadArtifactComponents;
|
|
367
|
+
private createTool;
|
|
368
|
+
private createDataComponent;
|
|
369
|
+
private createArtifactComponent;
|
|
370
|
+
private createAgentDataComponentRelation;
|
|
371
|
+
private createAgentArtifactComponentRelation;
|
|
372
|
+
private createAgentToolRelation;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
interface ArtifactComponentInterface {
|
|
376
|
+
config: Omit<ArtifactComponentInsert, "id">;
|
|
377
|
+
init(): Promise<void>;
|
|
378
|
+
getId(): ArtifactComponentInsert["id"];
|
|
379
|
+
getName(): ArtifactComponentInsert["name"];
|
|
380
|
+
getDescription(): ArtifactComponentInsert["description"];
|
|
381
|
+
getSummaryProps(): ArtifactComponentInsert["summaryProps"];
|
|
382
|
+
getFullProps(): ArtifactComponentInsert["fullProps"];
|
|
383
|
+
}
|
|
384
|
+
declare class ArtifactComponent implements ArtifactComponentInterface {
|
|
385
|
+
config: ArtifactComponentInsert;
|
|
386
|
+
private baseURL;
|
|
387
|
+
private tenantId;
|
|
388
|
+
private projectId;
|
|
389
|
+
private initialized;
|
|
390
|
+
private id;
|
|
391
|
+
constructor(config: Omit<ArtifactComponentInsert, "id">);
|
|
392
|
+
getId(): string;
|
|
393
|
+
getName(): string;
|
|
394
|
+
getDescription(): string;
|
|
395
|
+
getSummaryProps(): ArtifactComponentInsert["summaryProps"];
|
|
396
|
+
getFullProps(): ArtifactComponentInsert["fullProps"];
|
|
397
|
+
init(): Promise<void>;
|
|
398
|
+
private upsertArtifactComponent;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
interface DataComponentInterface {
|
|
402
|
+
config: Omit<DataComponentInsert, "id">;
|
|
403
|
+
init(): Promise<void>;
|
|
404
|
+
getId(): DataComponentInsert["id"];
|
|
405
|
+
getName(): DataComponentInsert["name"];
|
|
406
|
+
getDescription(): DataComponentInsert["description"];
|
|
407
|
+
getProps(): DataComponentInsert["props"];
|
|
408
|
+
}
|
|
409
|
+
declare class DataComponent implements DataComponentInterface {
|
|
410
|
+
config: DataComponentInsert;
|
|
411
|
+
private baseURL;
|
|
412
|
+
private tenantId;
|
|
413
|
+
private projectId;
|
|
414
|
+
private initialized;
|
|
415
|
+
private id;
|
|
416
|
+
constructor(config: Omit<DataComponentInsert, "id">);
|
|
417
|
+
getId(): string;
|
|
418
|
+
getName(): string;
|
|
419
|
+
getDescription(): string;
|
|
420
|
+
getProps(): DataComponentInsert["props"];
|
|
421
|
+
init(): Promise<void>;
|
|
422
|
+
private upsertDataComponent;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
interface ToolInterface {
|
|
426
|
+
config: MCPToolConfig$1;
|
|
427
|
+
init(): Promise<void>;
|
|
428
|
+
getId(): string;
|
|
429
|
+
getName(): string;
|
|
430
|
+
getDescription(): string;
|
|
431
|
+
getServerUrl(): string;
|
|
432
|
+
getActiveTools(): string[] | undefined;
|
|
433
|
+
getCredentialReferenceId(): string | null | undefined;
|
|
434
|
+
}
|
|
435
|
+
declare class Tool implements ToolInterface {
|
|
436
|
+
config: MCPToolConfig$1;
|
|
437
|
+
private baseURL;
|
|
438
|
+
private tenantId;
|
|
439
|
+
private initialized;
|
|
440
|
+
constructor(config: MCPToolConfig$1);
|
|
441
|
+
getId(): string;
|
|
442
|
+
getName(): string;
|
|
443
|
+
getDescription(): string;
|
|
444
|
+
getServerUrl(): string;
|
|
445
|
+
getActiveTools(): string[] | undefined;
|
|
446
|
+
getCredentialReferenceId(): string | null | undefined;
|
|
447
|
+
init(options?: {
|
|
448
|
+
skipDatabaseRegistration?: boolean;
|
|
449
|
+
}): Promise<void>;
|
|
450
|
+
private upsertTool;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Creates a new agent with stable ID enforcement.
|
|
455
|
+
*
|
|
456
|
+
* @param config - Agent configuration including required stable ID
|
|
457
|
+
* @returns A new Agent instance
|
|
458
|
+
* @throws Error if config.id is not provided (stable IDs are required)
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```typescript
|
|
462
|
+
* const myAgent = agent({
|
|
463
|
+
* id: 'customer-support-agent',
|
|
464
|
+
* name: 'Customer Support',
|
|
465
|
+
* prompt: 'Help customers with their questions'
|
|
466
|
+
* });
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
declare function agent(config: AgentConfig): Agent;
|
|
470
|
+
declare function credential(config: CredentialReferenceApiInsert): {
|
|
471
|
+
type: string;
|
|
472
|
+
id: string;
|
|
473
|
+
credentialStoreId: string;
|
|
474
|
+
retrievalParams?: Record<string, unknown> | null | undefined;
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* Creates a tool with automatic ID generation (unlike agents which require explicit IDs).
|
|
478
|
+
*
|
|
479
|
+
* Tools automatically generate IDs from their name, whereas agents require stable IDs
|
|
480
|
+
* to be explicitly provided for consistency across deployments.
|
|
481
|
+
*
|
|
482
|
+
* @param config - Tool configuration with auto-generated ID
|
|
483
|
+
* @returns A Tool instance with auto-generated ID based on name
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```typescript
|
|
487
|
+
* const searchTool = tool({
|
|
488
|
+
* name: 'Search Database',
|
|
489
|
+
* description: 'Search the product database',
|
|
490
|
+
* execute: async (params) => { ... }
|
|
491
|
+
* });
|
|
492
|
+
* // ID will be auto-generated as 'search-database'
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
495
|
+
declare function tool(config: {
|
|
496
|
+
name: string;
|
|
497
|
+
description: string;
|
|
498
|
+
execute: (params: any) => Promise<any>;
|
|
499
|
+
parameters?: Record<string, any>;
|
|
500
|
+
schema?: z.ZodJSONSchema;
|
|
501
|
+
}): {
|
|
502
|
+
id: string;
|
|
503
|
+
name: string;
|
|
504
|
+
description: string;
|
|
505
|
+
execute: (params: any) => Promise<any>;
|
|
506
|
+
parameters: Record<string, any> | undefined;
|
|
507
|
+
schema: unknown;
|
|
508
|
+
type: "function";
|
|
509
|
+
};
|
|
510
|
+
/**
|
|
511
|
+
* Creates an MCP (Model Context Protocol) server for tool functionality.
|
|
512
|
+
*
|
|
513
|
+
* This unified builder replaces tool(), mcpTool(), ipcTool(), and hostedTool().
|
|
514
|
+
* All tools are MCP servers - either local (with execute function) or remote (with URL).
|
|
515
|
+
*
|
|
516
|
+
* @param config - MCP server configuration
|
|
517
|
+
* @returns An MCP server instance that can be used as a tool in agents
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```typescript
|
|
521
|
+
* // Local MCP server with execute function (auto-wrapped via IPC)
|
|
522
|
+
* const searchServer = mcpServer({
|
|
523
|
+
* name: 'search',
|
|
524
|
+
* description: 'Search the database',
|
|
525
|
+
* execute: async (params) => {
|
|
526
|
+
* // Implementation
|
|
527
|
+
* return results;
|
|
528
|
+
* }
|
|
529
|
+
* });
|
|
530
|
+
*
|
|
531
|
+
* // Remote MCP server
|
|
532
|
+
* const apiServer = mcpServer({
|
|
533
|
+
* name: 'external_api',
|
|
534
|
+
* description: 'External API service',
|
|
535
|
+
* serverUrl: 'https://api.example.com/mcp'
|
|
536
|
+
* });
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
declare function mcpServer(config: {
|
|
540
|
+
name: string;
|
|
541
|
+
description: string;
|
|
542
|
+
deployment?: "local" | "remote";
|
|
543
|
+
execute?: (params: any) => Promise<any>;
|
|
544
|
+
port?: number;
|
|
545
|
+
serverUrl?: string;
|
|
546
|
+
id?: string;
|
|
547
|
+
parameters?: Record<string, z.ZodJSONSchema>;
|
|
548
|
+
credential?: CredentialReferenceApiInsert;
|
|
549
|
+
tenantId?: string;
|
|
550
|
+
transport?: "ipc" | "http" | "sse";
|
|
551
|
+
activeTools?: string[];
|
|
552
|
+
headers?: Record<string, string>;
|
|
553
|
+
}): Tool;
|
|
554
|
+
declare function mcpTool(config: MCPToolConfig$1): Tool;
|
|
555
|
+
declare function transfer(targetAgent: Agent, description?: string, condition?: (context: unknown) => boolean): TransferConfig;
|
|
556
|
+
/**
|
|
557
|
+
* Creates an artifact component with automatic ID generation.
|
|
558
|
+
*
|
|
559
|
+
* @param config - Artifact component configuration
|
|
560
|
+
* @returns An ArtifactComponent instance with auto-generated ID
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```typescript
|
|
564
|
+
* const productCard = artifactComponent({
|
|
565
|
+
* name: 'Product Card',
|
|
566
|
+
* description: 'Display product information',
|
|
567
|
+
* summaryProps: { title: 'Product', price: '$0' },
|
|
568
|
+
* fullProps: { title: 'Product', price: '$0', description: '...' }
|
|
569
|
+
* });
|
|
570
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
declare function artifactComponent(config: {
|
|
573
|
+
name: string;
|
|
574
|
+
description: string;
|
|
575
|
+
summaryProps: Record<string, any>;
|
|
576
|
+
fullProps: Record<string, any>;
|
|
577
|
+
tenantId?: string;
|
|
578
|
+
projectId?: string;
|
|
579
|
+
}): ArtifactComponent;
|
|
580
|
+
/**
|
|
581
|
+
* Creates a data component with automatic ID generation.
|
|
582
|
+
*
|
|
583
|
+
* @param config - Data component configuration
|
|
584
|
+
* @returns A DataComponent instance with auto-generated ID
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```typescript
|
|
588
|
+
* const userProfile = dataComponent({
|
|
589
|
+
* name: 'User Profile',
|
|
590
|
+
* description: 'User profile data',
|
|
591
|
+
* props: { userId: '123', name: 'John Doe' }
|
|
592
|
+
* });
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
595
|
+
declare function dataComponent(config: {
|
|
596
|
+
name: string;
|
|
597
|
+
description: string;
|
|
598
|
+
props: Record<string, any>;
|
|
599
|
+
tenantId?: string;
|
|
600
|
+
projectId?: string;
|
|
601
|
+
}): DataComponent;
|
|
602
|
+
|
|
603
|
+
interface EnvironmentSettingsConfig {
|
|
604
|
+
credentials?: {
|
|
605
|
+
[settingId: string]: CredentialReferenceApiInsert;
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Create a setting helper with TypeScript autocomplete
|
|
610
|
+
*/
|
|
611
|
+
declare function createEnvironmentSettings<T extends Record<string, EnvironmentSettingsConfig>>(environments: T): {
|
|
612
|
+
getEnvironmentSetting: (key: keyof NonNullable<T[keyof T]["credentials"]>) => Promise<CredentialReferenceApiInsert>;
|
|
613
|
+
};
|
|
614
|
+
/**
|
|
615
|
+
* Create type-safe environment configurations
|
|
616
|
+
*/
|
|
617
|
+
declare function registerEnvironmentSettings<T extends EnvironmentSettingsConfig>(config: T): T;
|
|
618
|
+
|
|
619
|
+
declare class AgentGraph implements GraphInterface {
|
|
620
|
+
private agents;
|
|
621
|
+
private agentMap;
|
|
622
|
+
private defaultAgent?;
|
|
623
|
+
private baseURL;
|
|
624
|
+
private tenantId;
|
|
625
|
+
private projectId;
|
|
626
|
+
private graphId;
|
|
627
|
+
private graphName;
|
|
628
|
+
private graphDescription?;
|
|
629
|
+
private initialized;
|
|
630
|
+
private contextConfig?;
|
|
631
|
+
private credentials?;
|
|
632
|
+
private models?;
|
|
633
|
+
private statusUpdateSettings?;
|
|
634
|
+
private graphPrompt?;
|
|
635
|
+
private stopWhen?;
|
|
636
|
+
private dbClient;
|
|
637
|
+
constructor(config: GraphConfig);
|
|
638
|
+
/**
|
|
639
|
+
* Set or update the configuration (tenantId, projectId and apiUrl)
|
|
640
|
+
* This is used by the CLI to inject configuration from inkeep.config.ts
|
|
641
|
+
*/
|
|
642
|
+
setConfig(tenantId: string, projectId: string, apiUrl: string): void;
|
|
643
|
+
/**
|
|
644
|
+
* Convert the AgentGraph to FullGraphDefinition format for the new graph endpoint
|
|
645
|
+
*/
|
|
646
|
+
private toFullGraphDefinition;
|
|
647
|
+
/**
|
|
648
|
+
* Initialize all tools in all agents (especially IPCTools that need MCP server URLs)
|
|
649
|
+
*/
|
|
650
|
+
private initializeAllTools;
|
|
651
|
+
/**
|
|
652
|
+
* Initialize the graph and all agents in the backend using the new graph endpoint
|
|
653
|
+
*/
|
|
654
|
+
init(): Promise<void>;
|
|
655
|
+
/**
|
|
656
|
+
* Legacy initialization method - kept for backward compatibility
|
|
657
|
+
* Initialize the graph and all agents in the backend using individual endpoints
|
|
658
|
+
*/
|
|
659
|
+
initLegacy(): Promise<void>;
|
|
660
|
+
/**
|
|
661
|
+
* Generate a response using the default agent
|
|
662
|
+
*/
|
|
663
|
+
generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
|
|
664
|
+
/**
|
|
665
|
+
* Stream a response using the default agent
|
|
666
|
+
*/
|
|
667
|
+
stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
|
|
668
|
+
/**
|
|
669
|
+
* Alias for stream() method for consistency with naming patterns
|
|
670
|
+
*/
|
|
671
|
+
generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
|
|
672
|
+
/**
|
|
673
|
+
* Run with a specific agent from the graph
|
|
674
|
+
*/
|
|
675
|
+
runWith(agentId: string, input: MessageInput, options?: GenerateOptions): Promise<RunResult>;
|
|
676
|
+
/**
|
|
677
|
+
* Get an agent by name (unified method for all agent types)
|
|
678
|
+
*/
|
|
679
|
+
getAgent(name: string): AllAgentInterface | undefined;
|
|
680
|
+
/**
|
|
681
|
+
* Add an agent to the graph
|
|
682
|
+
*/
|
|
683
|
+
addAgent(agent: AgentInterface): void;
|
|
684
|
+
/**
|
|
685
|
+
* Remove an agent from the graph
|
|
686
|
+
*/
|
|
687
|
+
removeAgent(id: string): boolean;
|
|
688
|
+
/**
|
|
689
|
+
* Get all agents in the graph
|
|
690
|
+
*/
|
|
691
|
+
getAgents(): AllAgentInterface[];
|
|
692
|
+
/**
|
|
693
|
+
* Get all agent ids (unified method for all agent types)
|
|
694
|
+
*/
|
|
695
|
+
getAgentIds(): string[];
|
|
696
|
+
/**
|
|
697
|
+
* Set the default agent
|
|
698
|
+
*/
|
|
699
|
+
setDefaultAgent(agent: AgentInterface): void;
|
|
700
|
+
/**
|
|
701
|
+
* Get the default agent
|
|
702
|
+
*/
|
|
703
|
+
getDefaultAgent(): AgentInterface | undefined;
|
|
704
|
+
/**
|
|
705
|
+
* Get the graph ID
|
|
706
|
+
*/
|
|
707
|
+
getId(): string;
|
|
708
|
+
getName(): string;
|
|
709
|
+
getDescription(): string | undefined;
|
|
710
|
+
getTenantId(): string;
|
|
711
|
+
/**
|
|
712
|
+
* Get the graph's model settingsuration
|
|
713
|
+
*/
|
|
714
|
+
getModels(): typeof this.models;
|
|
715
|
+
/**
|
|
716
|
+
* Set the graph's model settingsuration
|
|
717
|
+
*/
|
|
718
|
+
setModels(models: typeof this.models): void;
|
|
719
|
+
/**
|
|
720
|
+
* Get the graph's prompt configuration
|
|
721
|
+
*/
|
|
722
|
+
getGraphPrompt(): string | undefined;
|
|
723
|
+
/**
|
|
724
|
+
* Get the graph's stopWhen configuration
|
|
725
|
+
*/
|
|
726
|
+
getStopWhen(): {
|
|
727
|
+
transferCountIs?: number;
|
|
728
|
+
};
|
|
729
|
+
/**
|
|
730
|
+
* Get the graph's status updates configuration
|
|
731
|
+
*/
|
|
732
|
+
getStatusUpdateSettings(): StatusUpdateSettings | undefined;
|
|
733
|
+
/**
|
|
734
|
+
* Get the summarizer model from the graph's model settings
|
|
735
|
+
*/
|
|
736
|
+
getSummarizerModel(): ModelSettings | undefined;
|
|
737
|
+
/**
|
|
738
|
+
* Get graph statistics
|
|
739
|
+
*/
|
|
740
|
+
getStats(): {
|
|
741
|
+
agentCount: number;
|
|
742
|
+
defaultAgent: string | null;
|
|
743
|
+
initialized: boolean;
|
|
744
|
+
graphId: string;
|
|
745
|
+
tenantId: string;
|
|
746
|
+
};
|
|
747
|
+
/**
|
|
748
|
+
* Validate the graph configuration
|
|
749
|
+
*/
|
|
750
|
+
validate(): {
|
|
751
|
+
valid: boolean;
|
|
752
|
+
errors: string[];
|
|
753
|
+
};
|
|
754
|
+
private _init;
|
|
755
|
+
/**
|
|
756
|
+
* Type guard to check if an agent is an internal AgentInterface
|
|
757
|
+
*/
|
|
758
|
+
isInternalAgent(agent: AllAgentInterface): agent is AgentInterface;
|
|
759
|
+
/**
|
|
760
|
+
* Get project-level model settingsuration defaults
|
|
761
|
+
*/
|
|
762
|
+
private getProjectModelDefaults;
|
|
763
|
+
/**
|
|
764
|
+
* Get project-level stopWhen configuration defaults
|
|
765
|
+
*/
|
|
766
|
+
private getProjectStopWhenDefaults;
|
|
767
|
+
/**
|
|
768
|
+
* Apply model inheritance hierarchy: Project -> Graph -> Agent
|
|
769
|
+
*/
|
|
770
|
+
private applyModelInheritance;
|
|
771
|
+
/**
|
|
772
|
+
* Apply stopWhen inheritance hierarchy: Project -> Graph -> Agent
|
|
773
|
+
*/
|
|
774
|
+
private applyStopWhenInheritance;
|
|
775
|
+
/**
|
|
776
|
+
* Propagate graph-level model settings to agents (supporting partial inheritance)
|
|
777
|
+
*/
|
|
778
|
+
private propagateModelSettingsToAgent;
|
|
779
|
+
/**
|
|
780
|
+
* Immediately propagate graph-level models to all agents during construction
|
|
781
|
+
*/
|
|
782
|
+
private propagateImmediateModelSettings;
|
|
783
|
+
/**
|
|
784
|
+
* Type guard to check if an agent is an external AgentInterface
|
|
785
|
+
*/
|
|
786
|
+
isExternalAgent(agent: AllAgentInterface): agent is ExternalAgentInterface;
|
|
787
|
+
/**
|
|
788
|
+
* Execute agent using the backend system instead of local runner
|
|
789
|
+
*/
|
|
790
|
+
private executeWithBackend;
|
|
791
|
+
/**
|
|
792
|
+
* Parse streaming response in SSE format
|
|
793
|
+
*/
|
|
794
|
+
private parseStreamingResponse;
|
|
795
|
+
/**
|
|
796
|
+
* Normalize input messages to the expected format
|
|
797
|
+
*/
|
|
798
|
+
private normalizeMessages;
|
|
799
|
+
private saveToDatabase;
|
|
800
|
+
private saveRelations;
|
|
801
|
+
private createAgentRelations;
|
|
802
|
+
private createInternalAgentRelation;
|
|
803
|
+
private createExternalAgentRelation;
|
|
804
|
+
/**
|
|
805
|
+
* Create external agents in the database
|
|
806
|
+
*/
|
|
807
|
+
private createExternalAgents;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Helper function to create graphs - OpenAI style
|
|
811
|
+
*/
|
|
812
|
+
declare function agentGraph(config: GraphConfig): AgentGraph;
|
|
813
|
+
/**
|
|
814
|
+
* Factory function to create graph from configuration file
|
|
815
|
+
*/
|
|
816
|
+
declare function generateGraph(configPath: string): Promise<AgentGraph>;
|
|
817
|
+
|
|
818
|
+
declare class Runner {
|
|
819
|
+
/**
|
|
820
|
+
* Run a graph until completion, handling transfers and tool calls
|
|
821
|
+
* Similar to OpenAI's Runner.run() pattern
|
|
822
|
+
* NOTE: This now requires a graph instead of an agent
|
|
823
|
+
*/
|
|
824
|
+
static run(graph: GraphInterface, messages: MessageInput, options?: GenerateOptions): Promise<RunResult>;
|
|
825
|
+
/**
|
|
826
|
+
* Stream a graph's response
|
|
827
|
+
*/
|
|
828
|
+
static stream(graph: GraphInterface, messages: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
|
|
829
|
+
/**
|
|
830
|
+
* Execute multiple graphs in parallel and return the first successful result
|
|
831
|
+
*/
|
|
832
|
+
static raceGraphs(graphs: GraphInterface[], messages: MessageInput, options?: GenerateOptions): Promise<RunResult>;
|
|
833
|
+
private static normalizeToMessageHistory;
|
|
834
|
+
/**
|
|
835
|
+
* Validate graph configuration before running
|
|
836
|
+
*/
|
|
837
|
+
static validateGraph(graph: GraphInterface): {
|
|
838
|
+
valid: boolean;
|
|
839
|
+
errors: string[];
|
|
840
|
+
};
|
|
841
|
+
/**
|
|
842
|
+
* Get execution statistics for a graph
|
|
843
|
+
*/
|
|
844
|
+
static getExecutionStats(graph: GraphInterface, messages: MessageInput, options?: GenerateOptions): Promise<{
|
|
845
|
+
estimatedTurns: number;
|
|
846
|
+
estimatedTokens: number;
|
|
847
|
+
agentCount: number;
|
|
848
|
+
defaultAgent: string | undefined;
|
|
849
|
+
}>;
|
|
850
|
+
}
|
|
851
|
+
declare const run: typeof Runner.run;
|
|
852
|
+
declare const stream: typeof Runner.stream;
|
|
853
|
+
declare const raceGraphs: typeof Runner.raceGraphs;
|
|
854
|
+
|
|
855
|
+
export { Agent, type AgentConfig, AgentError, AgentGraph, type AgentInterface, type AgentResponse, type AllAgentInterface, ArtifactComponent, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, DataComponent, ExternalAgent, type ExternalAgentInterface, type FetchDefinitionConfig, type GenerateOptions, type GraphConfig, type GraphInterface, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, type ModelSettings, ModelSettingsSchema, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, type StatusComponent, type StatusUpdateSettings, type StreamEvent, type StreamResponse, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UserMessage, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, tool, transfer };
|