@inkeep/agents-sdk 0.1.1 → 0.1.7

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.
Files changed (60) hide show
  1. package/SUPPLEMENTAL_TERMS.md +40 -0
  2. package/dist/index.cjs +3334 -0
  3. package/dist/index.d.cts +1131 -0
  4. package/dist/index.d.ts +1131 -11
  5. package/dist/index.js +3305 -10
  6. package/package.json +8 -7
  7. package/dist/__tests__/utils/testTenant.d.ts +0 -7
  8. package/dist/__tests__/utils/testTenant.d.ts.map +0 -1
  9. package/dist/__tests__/utils/testTenant.js +0 -10
  10. package/dist/__tests__/utils/testTenant.js.map +0 -1
  11. package/dist/agent.d.ts +0 -47
  12. package/dist/agent.d.ts.map +0 -1
  13. package/dist/agent.js +0 -601
  14. package/dist/agent.js.map +0 -1
  15. package/dist/artifact-component.d.ts +0 -27
  16. package/dist/artifact-component.d.ts.map +0 -1
  17. package/dist/artifact-component.js +0 -116
  18. package/dist/artifact-component.js.map +0 -1
  19. package/dist/builders.d.ts +0 -211
  20. package/dist/builders.d.ts.map +0 -1
  21. package/dist/builders.js +0 -244
  22. package/dist/builders.js.map +0 -1
  23. package/dist/data-component.d.ts +0 -25
  24. package/dist/data-component.d.ts.map +0 -1
  25. package/dist/data-component.js +0 -112
  26. package/dist/data-component.js.map +0 -1
  27. package/dist/environment-settings.d.ts +0 -28
  28. package/dist/environment-settings.d.ts.map +0 -1
  29. package/dist/environment-settings.js +0 -78
  30. package/dist/environment-settings.js.map +0 -1
  31. package/dist/externalAgent.d.ts +0 -58
  32. package/dist/externalAgent.d.ts.map +0 -1
  33. package/dist/externalAgent.js +0 -161
  34. package/dist/externalAgent.js.map +0 -1
  35. package/dist/graph.d.ts +0 -200
  36. package/dist/graph.d.ts.map +0 -1
  37. package/dist/graph.js +0 -1294
  38. package/dist/graph.js.map +0 -1
  39. package/dist/graphFullClient.d.ts +0 -22
  40. package/dist/graphFullClient.d.ts.map +0 -1
  41. package/dist/graphFullClient.js +0 -189
  42. package/dist/graphFullClient.js.map +0 -1
  43. package/dist/index.d.ts.map +0 -1
  44. package/dist/index.js.map +0 -1
  45. package/dist/module-hosted-tool-manager.d.ts +0 -37
  46. package/dist/module-hosted-tool-manager.d.ts.map +0 -1
  47. package/dist/module-hosted-tool-manager.js +0 -375
  48. package/dist/module-hosted-tool-manager.js.map +0 -1
  49. package/dist/runner.d.ts +0 -38
  50. package/dist/runner.d.ts.map +0 -1
  51. package/dist/runner.js +0 -164
  52. package/dist/runner.js.map +0 -1
  53. package/dist/tool.d.ts +0 -29
  54. package/dist/tool.d.ts.map +0 -1
  55. package/dist/tool.js +0 -122
  56. package/dist/tool.js.map +0 -1
  57. package/dist/types.d.ts +0 -285
  58. package/dist/types.d.ts.map +0 -1
  59. package/dist/types.js +0 -37
  60. package/dist/types.js.map +0 -1
@@ -0,0 +1,1131 @@
1
+ import { MCPToolConfig as MCPToolConfig$1, CredentialReferenceApiInsert, MCPTransportType, CredentialReferenceSelect, AgentApiInsert, AgentStopWhen, DataComponentApiInsert, ArtifactComponentApiInsert, AgentConversationHistoryConfig, GraphStopWhen, ToolInsert, McpTransportConfig, ArtifactComponentInsert, DataComponentInsert, StopWhen, FullProjectDefinition } from '@inkeep/agents-core';
2
+ import { z } from 'zod';
3
+
4
+ interface ToolInterface {
5
+ config: MCPToolConfig$1;
6
+ init(): Promise<void>;
7
+ getId(): string;
8
+ getName(): string;
9
+ getDescription(): string;
10
+ getServerUrl(): string;
11
+ getActiveTools(): string[] | undefined;
12
+ getCredentialReferenceId(): string | null | undefined;
13
+ }
14
+ declare class Tool implements ToolInterface {
15
+ config: MCPToolConfig$1;
16
+ private baseURL;
17
+ private tenantId;
18
+ private initialized;
19
+ private projectId;
20
+ constructor(config: MCPToolConfig$1);
21
+ getId(): string;
22
+ getName(): string;
23
+ getDescription(): string;
24
+ getServerUrl(): string;
25
+ getActiveTools(): string[] | undefined;
26
+ getCredentialReferenceId(): string | null | undefined;
27
+ init(options?: {
28
+ skipDatabaseRegistration?: boolean;
29
+ }): Promise<void>;
30
+ private upsertTool;
31
+ }
32
+
33
+ /**
34
+ * Function signature for transfer conditions
35
+ */
36
+ type TransferConditionFunction = (context: unknown) => boolean;
37
+ /**
38
+ * Configuration for MCP server builders
39
+ */
40
+ interface MCPServerConfig {
41
+ name: string;
42
+ description: string;
43
+ serverUrl: string;
44
+ id?: string;
45
+ parameters?: Record<string, z.ZodJSONSchema>;
46
+ credential?: CredentialReferenceApiInsert;
47
+ tenantId?: string;
48
+ transport?: keyof typeof MCPTransportType;
49
+ activeTools?: string[];
50
+ headers?: Record<string, string>;
51
+ imageUrl?: string;
52
+ }
53
+ /**
54
+ * Configuration for component builders
55
+ */
56
+ interface ComponentConfig {
57
+ name: string;
58
+ description: string;
59
+ tenantId?: string;
60
+ projectId?: string;
61
+ }
62
+ interface ArtifactComponentConfig extends ComponentConfig {
63
+ summaryProps: Record<string, unknown>;
64
+ fullProps: Record<string, unknown>;
65
+ }
66
+ interface DataComponentConfig extends ComponentConfig {
67
+ props: Record<string, unknown>;
68
+ }
69
+ type AgentMcpConfig = {
70
+ server: Tool;
71
+ selectedTools: string[];
72
+ };
73
+ /**
74
+ * Creates a transfer configuration for agent handoffs.
75
+ *
76
+ * Transfers allow one agent to hand off control to another agent
77
+ * based on optional conditions.
78
+ *
79
+ * @param targetAgent - The agent to transfer to
80
+ * @param description - Optional description of when/why to transfer
81
+ * @param condition - Optional function to determine if transfer should occur
82
+ * @returns A validated transfer configuration
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * // Simple transfer
87
+ * const handoff = transfer(supportAgent, 'Transfer to support');
88
+ *
89
+ * // Conditional transfer
90
+ * const conditionalHandoff = transfer(
91
+ * specialistAgent,
92
+ * 'Transfer to specialist for complex issues',
93
+ * (context) => context.complexity > 0.8
94
+ * );
95
+ * ```
96
+ */
97
+ declare function transfer(targetAgent: Agent, description?: string, condition?: TransferConditionFunction): TransferConfig;
98
+
99
+ type ExternalAgentConfig = {
100
+ type?: 'external';
101
+ tenantId?: string;
102
+ id: string;
103
+ name: string;
104
+ description: string;
105
+ baseUrl: string;
106
+ credentialReference?: CredentialReferenceSelect;
107
+ headers?: Record<string, string>;
108
+ };
109
+ declare class ExternalAgent implements ExternalAgentInterface {
110
+ config: ExternalAgentConfig;
111
+ readonly type: "external";
112
+ private initialized;
113
+ private tenantId;
114
+ private baseURL;
115
+ constructor(config: ExternalAgentConfig);
116
+ /**
117
+ * Initialize the external agent by upserting it in the database
118
+ */
119
+ init(): Promise<void>;
120
+ getId(): string;
121
+ private upsertExternalAgent;
122
+ /**
123
+ * Get the external agent configuration
124
+ */
125
+ getConfig(): ExternalAgentConfig;
126
+ /**
127
+ * Get the external agent name
128
+ */
129
+ getName(): string;
130
+ /**
131
+ * Get the external agent base URL
132
+ */
133
+ getBaseUrl(): string;
134
+ /**
135
+ * Get the tenant ID
136
+ */
137
+ getTenantId(): string;
138
+ getDescription(): string;
139
+ getCredentialReferenceId(): string | undefined;
140
+ getHeaders(): Record<string, string> | undefined;
141
+ }
142
+ /**
143
+ * Factory function to create external agents - follows the same pattern as agent()
144
+ */
145
+ declare function externalAgent(config: ExternalAgentConfig): ExternalAgent;
146
+ /**
147
+ * Helper function to create multiple external agents
148
+ */
149
+ declare function externalAgents(configs: Record<string, ExternalAgentConfig>): Record<string, ExternalAgent>;
150
+
151
+ interface UserMessage {
152
+ role: 'user';
153
+ content: string;
154
+ }
155
+ interface AssistantMessage {
156
+ role: 'assistant';
157
+ content: string;
158
+ toolCalls?: ToolCall[];
159
+ }
160
+ interface ToolMessage {
161
+ role: 'tool';
162
+ content: string;
163
+ toolCallId: string;
164
+ }
165
+ interface SystemMessage {
166
+ role: 'system';
167
+ content: string;
168
+ }
169
+ type Message = UserMessage | AssistantMessage | ToolMessage | SystemMessage;
170
+ type MessageInput = string | string[] | Message | Message[];
171
+ interface ToolCall {
172
+ id: string;
173
+ type: 'function';
174
+ function: {
175
+ name: string;
176
+ arguments: string;
177
+ };
178
+ }
179
+ interface ToolResult {
180
+ id: string;
181
+ result: any;
182
+ error?: string;
183
+ }
184
+ type AllAgentInterface = AgentInterface | ExternalAgentInterface;
185
+ type AgentCanUseType = Tool | AgentMcpConfig;
186
+ interface AgentConfig extends Omit<AgentApiInsert, 'projectId'> {
187
+ type?: 'internal';
188
+ canUse?: () => AgentCanUseType[];
189
+ canTransferTo?: () => AgentInterface[];
190
+ canDelegateTo?: () => AllAgentInterface[];
191
+ tenantId?: string;
192
+ projectId?: string;
193
+ models?: {
194
+ base?: ModelSettings;
195
+ structuredOutput?: ModelSettings;
196
+ summarizer?: ModelSettings;
197
+ };
198
+ stopWhen?: AgentStopWhen;
199
+ memory?: {
200
+ type: 'conversation' | 'episodic' | 'short_term';
201
+ capacity?: number;
202
+ };
203
+ dataComponents?: () => DataComponentApiInsert[];
204
+ artifactComponents?: () => ArtifactComponentApiInsert[];
205
+ conversationHistoryConfig?: AgentConversationHistoryConfig;
206
+ }
207
+ interface ModelSettings {
208
+ model?: string;
209
+ providerOptions?: Record<string, Record<string, unknown>>;
210
+ }
211
+ declare const ModelSettingsSchema: z.ZodObject<{
212
+ model: z.ZodOptional<z.ZodString>;
213
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
214
+ }, z.core.$strip>;
215
+ interface ToolConfig extends ToolInsert {
216
+ execute: (params: any) => Promise<any>;
217
+ parameters?: Record<string, any>;
218
+ schema?: z.ZodJSONSchema;
219
+ }
220
+ interface ServerConfig {
221
+ type: string;
222
+ version?: string;
223
+ }
224
+ interface MCPToolConfig {
225
+ id: string;
226
+ name: string;
227
+ tenantId?: string;
228
+ description?: string;
229
+ credential?: CredentialReferenceApiInsert;
230
+ server?: ServerConfig;
231
+ serverUrl: string;
232
+ toolName?: string;
233
+ activeTools?: string[];
234
+ headers?: Record<string, string>;
235
+ mcpType?: 'nango' | 'generic';
236
+ transport?: McpTransportConfig;
237
+ imageUrl?: string;
238
+ }
239
+ interface FetchDefinitionConfig {
240
+ id: string;
241
+ name?: string;
242
+ trigger: 'initialization' | 'invocation';
243
+ url: string;
244
+ method?: string;
245
+ headers?: Record<string, string>;
246
+ body?: Record<string, unknown>;
247
+ transform?: string;
248
+ responseSchema?: z.ZodSchema<any>;
249
+ defaultValue?: unknown;
250
+ timeout?: number;
251
+ credential?: CredentialReferenceApiInsert;
252
+ }
253
+ interface RequestSchemaDefinition {
254
+ body?: z.ZodSchema<any>;
255
+ headers?: z.ZodSchema<any>;
256
+ query?: z.ZodSchema<any>;
257
+ params?: z.ZodSchema<any>;
258
+ }
259
+ interface RequestSchemaConfig {
260
+ schemas: RequestSchemaDefinition;
261
+ optional?: ('body' | 'headers' | 'query' | 'params')[];
262
+ }
263
+ interface TransferConfig {
264
+ agent: AgentInterface;
265
+ description?: string;
266
+ condition?: (context: any) => boolean;
267
+ }
268
+ interface GenerateOptions {
269
+ maxTurns?: number;
270
+ maxSteps?: number;
271
+ temperature?: number;
272
+ toolChoice?: 'auto' | 'none' | string;
273
+ resourceId?: string;
274
+ conversationId?: string;
275
+ stream?: boolean;
276
+ customBodyParams?: Record<string, unknown>;
277
+ }
278
+ interface AgentResponse {
279
+ id?: string;
280
+ text: string;
281
+ toolCalls?: ToolCall[];
282
+ transfer?: TransferConfig;
283
+ finishReason: 'completed' | 'tool_calls' | 'transfer' | 'max_turns' | 'error';
284
+ usage?: {
285
+ inputTokens: number;
286
+ outputTokens: number;
287
+ totalTokens?: number;
288
+ };
289
+ metadata?: Record<string, any>;
290
+ }
291
+ interface StreamResponse {
292
+ textStream?: AsyncGenerator<string>;
293
+ eventStream?: AsyncGenerator<StreamEvent>;
294
+ }
295
+ interface StreamEvent {
296
+ type: 'text' | 'tool_call' | 'transfer' | 'error' | 'done';
297
+ data: any;
298
+ timestamp: Date;
299
+ }
300
+ interface RunResult {
301
+ finalOutput: string;
302
+ agent: AgentInterface;
303
+ turnCount: number;
304
+ usage?: {
305
+ inputTokens: number;
306
+ outputTokens: number;
307
+ totalTokens?: number;
308
+ };
309
+ metadata?: {
310
+ toolCalls: ToolCall[];
311
+ transfers: TransferConfig[];
312
+ };
313
+ }
314
+ interface StatusComponent {
315
+ id: string;
316
+ name: string;
317
+ type: string;
318
+ description?: string;
319
+ schema: {
320
+ type: 'object';
321
+ properties: Record<string, any>;
322
+ required?: string[];
323
+ };
324
+ }
325
+ interface StatusUpdateSettings {
326
+ enabled?: boolean;
327
+ numEvents?: number;
328
+ timeInSeconds?: number;
329
+ model?: string;
330
+ statusComponents?: StatusComponent[];
331
+ prompt?: string;
332
+ }
333
+ interface GraphConfig {
334
+ id: string;
335
+ name?: string;
336
+ description?: string;
337
+ defaultAgent?: AgentInterface;
338
+ agents?: () => AllAgentInterface[];
339
+ tenantId?: string;
340
+ contextConfig?: any;
341
+ credentials?: () => CredentialReferenceApiInsert[];
342
+ stopWhen?: GraphStopWhen;
343
+ graphPrompt?: string;
344
+ models?: {
345
+ base?: ModelSettings;
346
+ structuredOutput?: ModelSettings;
347
+ summarizer?: ModelSettings;
348
+ };
349
+ statusUpdates?: StatusUpdateSettings;
350
+ }
351
+ declare class AgentError extends Error {
352
+ code?: string | undefined;
353
+ details?: any | undefined;
354
+ constructor(message: string, code?: string | undefined, details?: any | undefined);
355
+ }
356
+ declare class MaxTurnsExceededError extends AgentError {
357
+ constructor(maxTurns: number);
358
+ }
359
+ declare class ToolExecutionError extends AgentError {
360
+ constructor(toolName: string, originalError: Error);
361
+ }
362
+ declare class TransferError extends AgentError {
363
+ constructor(sourceAgent: string, targetAgent: string, reason: string);
364
+ }
365
+ interface AgentInterface {
366
+ config: AgentConfig;
367
+ type: 'internal';
368
+ init(): Promise<void>;
369
+ getId(): string;
370
+ getName(): string;
371
+ getInstructions(): string;
372
+ getTools(): Record<string, any>;
373
+ getTransfers(): AgentInterface[];
374
+ getDelegates(): AllAgentInterface[];
375
+ getDataComponents(): DataComponentApiInsert[];
376
+ getArtifactComponents(): ArtifactComponentApiInsert[];
377
+ addTool(name: string, tool: any): void;
378
+ addTransfer(...agents: AgentInterface[]): void;
379
+ addDelegate(...agents: AgentInterface[]): void;
380
+ }
381
+ interface ExternalAgentInterface {
382
+ config: ExternalAgentConfig;
383
+ type: 'external';
384
+ init(): Promise<void>;
385
+ getId(): string;
386
+ getName(): string;
387
+ getDescription(): string;
388
+ getBaseUrl(): string;
389
+ getCredentialReferenceId(): string | undefined;
390
+ getHeaders(): Record<string, string> | undefined;
391
+ }
392
+ interface GraphInterface {
393
+ init(): Promise<void>;
394
+ setConfig(tenantId: string, projectId: string, apiUrl: string): void;
395
+ getId(): string;
396
+ getName(): string;
397
+ getDescription(): string | undefined;
398
+ getTenantId(): string;
399
+ generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
400
+ stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
401
+ generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
402
+ getDefaultAgent(): AgentInterface | undefined;
403
+ getAgent(name: string): AllAgentInterface | undefined;
404
+ getAgents(): AllAgentInterface[];
405
+ }
406
+ interface BuilderToolConfig {
407
+ name: string;
408
+ description: string;
409
+ config: {
410
+ type: 'mcp';
411
+ mcp: {
412
+ server: {
413
+ url: string;
414
+ };
415
+ };
416
+ };
417
+ parameters?: Record<string, any>;
418
+ }
419
+ interface BuilderRelationConfig {
420
+ targetAgent: string;
421
+ relationType: 'transfer' | 'delegate';
422
+ }
423
+ interface BuilderAgentConfig {
424
+ name: string;
425
+ description: string;
426
+ instructions: string;
427
+ tools: BuilderToolConfig[];
428
+ relations?: BuilderRelationConfig[];
429
+ }
430
+
431
+ declare class Agent implements AgentInterface {
432
+ config: AgentConfig;
433
+ readonly type: "internal";
434
+ private baseURL;
435
+ private tenantId;
436
+ private projectId;
437
+ private initialized;
438
+ constructor(config: AgentConfig);
439
+ getId(): string;
440
+ getName(): string;
441
+ getInstructions(): string;
442
+ getTools(): Record<string, unknown>;
443
+ getModels(): typeof this$1.config.models;
444
+ setModels(models: typeof this$1.config.models): void;
445
+ getTransfers(): AgentInterface[];
446
+ getDelegates(): AllAgentInterface[];
447
+ getDataComponents(): DataComponentApiInsert[];
448
+ getArtifactComponents(): ArtifactComponentApiInsert[];
449
+ addTool(_name: string, tool: Tool): void;
450
+ addTransfer(...agents: AgentInterface[]): void;
451
+ addDelegate(...agents: AllAgentInterface[]): void;
452
+ init(): Promise<void>;
453
+ private upsertAgent;
454
+ private saveToolsAndRelations;
455
+ private saveDataComponents;
456
+ private saveArtifactComponents;
457
+ private loadDataComponents;
458
+ private loadArtifactComponents;
459
+ private createTool;
460
+ private createDataComponent;
461
+ private createArtifactComponent;
462
+ private createAgentDataComponentRelation;
463
+ private createAgentArtifactComponentRelation;
464
+ private createAgentToolRelation;
465
+ }
466
+
467
+ interface ArtifactComponentInterface {
468
+ config: Omit<ArtifactComponentInsert, 'id'>;
469
+ init(): Promise<void>;
470
+ getId(): ArtifactComponentInsert['id'];
471
+ getName(): ArtifactComponentInsert['name'];
472
+ getDescription(): ArtifactComponentInsert['description'];
473
+ getSummaryProps(): ArtifactComponentInsert['summaryProps'];
474
+ getFullProps(): ArtifactComponentInsert['fullProps'];
475
+ }
476
+ declare class ArtifactComponent implements ArtifactComponentInterface {
477
+ config: ArtifactComponentInsert;
478
+ private baseURL;
479
+ private tenantId;
480
+ private projectId;
481
+ private initialized;
482
+ private id;
483
+ constructor(config: Omit<ArtifactComponentInsert, 'id'>);
484
+ getId(): string;
485
+ getName(): string;
486
+ getDescription(): string;
487
+ getSummaryProps(): ArtifactComponentInsert['summaryProps'];
488
+ getFullProps(): ArtifactComponentInsert['fullProps'];
489
+ init(): Promise<void>;
490
+ private upsertArtifactComponent;
491
+ }
492
+
493
+ interface DataComponentInterface {
494
+ config: Omit<DataComponentInsert, 'id'>;
495
+ init(): Promise<void>;
496
+ getId(): DataComponentInsert['id'];
497
+ getName(): DataComponentInsert['name'];
498
+ getDescription(): DataComponentInsert['description'];
499
+ getProps(): DataComponentInsert['props'];
500
+ }
501
+ declare class DataComponent implements DataComponentInterface {
502
+ config: DataComponentInsert;
503
+ private baseURL;
504
+ private tenantId;
505
+ private projectId;
506
+ private initialized;
507
+ private id;
508
+ constructor(config: Omit<DataComponentInsert, 'id'>);
509
+ getId(): string;
510
+ getName(): string;
511
+ getDescription(): string;
512
+ getProps(): DataComponentInsert['props'];
513
+ init(): Promise<void>;
514
+ private upsertDataComponent;
515
+ }
516
+
517
+ declare class AgentGraph implements GraphInterface {
518
+ private agents;
519
+ private agentMap;
520
+ private defaultAgent?;
521
+ private baseURL;
522
+ private tenantId;
523
+ private projectId;
524
+ private graphId;
525
+ private graphName;
526
+ private graphDescription?;
527
+ private initialized;
528
+ private contextConfig?;
529
+ private credentials?;
530
+ private models?;
531
+ private statusUpdateSettings?;
532
+ private graphPrompt?;
533
+ private stopWhen?;
534
+ private dbClient;
535
+ constructor(config: GraphConfig);
536
+ /**
537
+ * Set or update the configuration (tenantId, projectId and apiUrl)
538
+ * This is used by the CLI to inject configuration from inkeep.config.ts
539
+ */
540
+ setConfig(tenantId: string, projectId: string, apiUrl: string): void;
541
+ /**
542
+ * Convert the AgentGraph to FullGraphDefinition format for the new graph endpoint
543
+ */
544
+ private toFullGraphDefinition;
545
+ /**
546
+ * Initialize all tools in all agents (especially IPCTools that need MCP server URLs)
547
+ */
548
+ private initializeAllTools;
549
+ /**
550
+ * Initialize the graph and all agents in the backend using the new graph endpoint
551
+ */
552
+ init(): Promise<void>;
553
+ /**
554
+ * Legacy initialization method - kept for backward compatibility
555
+ * Initialize the graph and all agents in the backend using individual endpoints
556
+ */
557
+ initLegacy(): Promise<void>;
558
+ /**
559
+ * Generate a response using the default agent
560
+ */
561
+ generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
562
+ /**
563
+ * Stream a response using the default agent
564
+ */
565
+ stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
566
+ /**
567
+ * Alias for stream() method for consistency with naming patterns
568
+ */
569
+ generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
570
+ /**
571
+ * Run with a specific agent from the graph
572
+ */
573
+ runWith(agentId: string, input: MessageInput, options?: GenerateOptions): Promise<RunResult>;
574
+ /**
575
+ * Get an agent by name (unified method for all agent types)
576
+ */
577
+ getAgent(name: string): AllAgentInterface | undefined;
578
+ /**
579
+ * Add an agent to the graph
580
+ */
581
+ addAgent(agent: AgentInterface): void;
582
+ /**
583
+ * Remove an agent from the graph
584
+ */
585
+ removeAgent(id: string): boolean;
586
+ /**
587
+ * Get all agents in the graph
588
+ */
589
+ getAgents(): AllAgentInterface[];
590
+ /**
591
+ * Get all agent ids (unified method for all agent types)
592
+ */
593
+ getAgentIds(): string[];
594
+ /**
595
+ * Set the default agent
596
+ */
597
+ setDefaultAgent(agent: AgentInterface): void;
598
+ /**
599
+ * Get the default agent
600
+ */
601
+ getDefaultAgent(): AgentInterface | undefined;
602
+ /**
603
+ * Get the graph ID
604
+ */
605
+ getId(): string;
606
+ getName(): string;
607
+ getDescription(): string | undefined;
608
+ getTenantId(): string;
609
+ /**
610
+ * Get the graph's model settingsuration
611
+ */
612
+ getModels(): typeof this.models;
613
+ /**
614
+ * Set the graph's model settingsuration
615
+ */
616
+ setModels(models: typeof this.models): void;
617
+ /**
618
+ * Get the graph's prompt configuration
619
+ */
620
+ getGraphPrompt(): string | undefined;
621
+ /**
622
+ * Get the graph's stopWhen configuration
623
+ */
624
+ getStopWhen(): GraphStopWhen;
625
+ /**
626
+ * Get the graph's status updates configuration
627
+ */
628
+ getStatusUpdateSettings(): StatusUpdateSettings | undefined;
629
+ /**
630
+ * Get the summarizer model from the graph's model settings
631
+ */
632
+ getSummarizerModel(): ModelSettings | undefined;
633
+ /**
634
+ * Get graph statistics
635
+ */
636
+ getStats(): {
637
+ agentCount: number;
638
+ defaultAgent: string | null;
639
+ initialized: boolean;
640
+ graphId: string;
641
+ tenantId: string;
642
+ };
643
+ /**
644
+ * Validate the graph configuration
645
+ */
646
+ validate(): {
647
+ valid: boolean;
648
+ errors: string[];
649
+ };
650
+ private _init;
651
+ /**
652
+ * Type guard to check if an agent is an internal AgentInterface
653
+ */
654
+ isInternalAgent(agent: AllAgentInterface): agent is AgentInterface;
655
+ /**
656
+ * Get project-level model settingsuration defaults
657
+ */
658
+ private getProjectModelDefaults;
659
+ /**
660
+ * Get project-level stopWhen configuration defaults
661
+ */
662
+ private getProjectStopWhenDefaults;
663
+ /**
664
+ * Apply model inheritance hierarchy: Project -> Graph -> Agent
665
+ */
666
+ private applyModelInheritance;
667
+ /**
668
+ * Apply stopWhen inheritance hierarchy: Project -> Graph -> Agent
669
+ */
670
+ private applyStopWhenInheritance;
671
+ /**
672
+ * Propagate graph-level model settings to agents (supporting partial inheritance)
673
+ */
674
+ private propagateModelSettingsToAgent;
675
+ /**
676
+ * Immediately propagate graph-level models to all agents during construction
677
+ */
678
+ private propagateImmediateModelSettings;
679
+ /**
680
+ * Type guard to check if an agent is an external AgentInterface
681
+ */
682
+ isExternalAgent(agent: AllAgentInterface): agent is ExternalAgentInterface;
683
+ /**
684
+ * Execute agent using the backend system instead of local runner
685
+ */
686
+ private executeWithBackend;
687
+ /**
688
+ * Parse streaming response in SSE format
689
+ */
690
+ private parseStreamingResponse;
691
+ /**
692
+ * Normalize input messages to the expected format
693
+ */
694
+ private normalizeMessages;
695
+ private saveToDatabase;
696
+ private saveRelations;
697
+ private createAgentRelations;
698
+ private createInternalAgentRelation;
699
+ private createExternalAgentRelation;
700
+ /**
701
+ * Create external agents in the database
702
+ */
703
+ private createExternalAgents;
704
+ }
705
+
706
+ /**
707
+ * Project configuration interface for the SDK
708
+ */
709
+ interface ProjectConfig {
710
+ id: string;
711
+ name: string;
712
+ description?: string;
713
+ tenantId?: string;
714
+ models?: {
715
+ base?: ModelSettings;
716
+ structuredOutput?: ModelSettings;
717
+ summarizer?: ModelSettings;
718
+ };
719
+ stopWhen?: StopWhen;
720
+ graphs?: () => AgentGraph[];
721
+ }
722
+ /**
723
+ * Project interface for operations
724
+ */
725
+ interface ProjectInterface {
726
+ init(): Promise<void>;
727
+ setConfig(tenantId: string, apiUrl: string): void;
728
+ getId(): string;
729
+ getName(): string;
730
+ getDescription(): string | undefined;
731
+ getTenantId(): string;
732
+ getModels(): ProjectConfig['models'];
733
+ getStopWhen(): ProjectConfig['stopWhen'];
734
+ getGraphs(): AgentGraph[];
735
+ addGraph(graph: AgentGraph): void;
736
+ removeGraph(id: string): boolean;
737
+ getStats(): {
738
+ projectId: string;
739
+ tenantId: string;
740
+ graphCount: number;
741
+ initialized: boolean;
742
+ };
743
+ validate(): {
744
+ valid: boolean;
745
+ errors: string[];
746
+ };
747
+ }
748
+ /**
749
+ * Project class for managing agent projects
750
+ *
751
+ * Projects are the top-level organizational unit that contains graphs, agents, and shared configurations.
752
+ * They provide model inheritance and execution limits that cascade down to graphs and agents.
753
+ *
754
+ * @example
755
+ * ```typescript
756
+ * const myProject = new Project({
757
+ * id: 'customer-support-project',
758
+ * name: 'Customer Support System',
759
+ * description: 'Multi-agent customer support system',
760
+ * models: {
761
+ * base: { model: 'gpt-4o-mini' },
762
+ * structuredOutput: { model: 'gpt-4o' }
763
+ * },
764
+ * stopWhen: {
765
+ * transferCountIs: 10,
766
+ * stepCountIs: 50
767
+ * }
768
+ * });
769
+ *
770
+ * await myProject.init();
771
+ * ```
772
+ */
773
+ declare class Project implements ProjectInterface {
774
+ private projectId;
775
+ private projectName;
776
+ private projectDescription?;
777
+ private tenantId;
778
+ private baseURL;
779
+ private initialized;
780
+ private models?;
781
+ private stopWhen?;
782
+ private graphs;
783
+ private graphMap;
784
+ constructor(config: ProjectConfig);
785
+ /**
786
+ * Set or update the configuration (tenantId and apiUrl)
787
+ * This is used by the CLI to inject configuration from inkeep.config.ts
788
+ */
789
+ setConfig(tenantId: string, apiUrl: string): void;
790
+ /**
791
+ * Initialize the project and create/update it in the backend using full project approach
792
+ */
793
+ init(): Promise<void>;
794
+ /**
795
+ * Get the project ID
796
+ */
797
+ getId(): string;
798
+ /**
799
+ * Get the project name
800
+ */
801
+ getName(): string;
802
+ /**
803
+ * Get the project description
804
+ */
805
+ getDescription(): string | undefined;
806
+ /**
807
+ * Get the tenant ID
808
+ */
809
+ getTenantId(): string;
810
+ /**
811
+ * Get the project's model configuration
812
+ */
813
+ getModels(): ProjectConfig['models'];
814
+ /**
815
+ * Set the project's model configuration
816
+ */
817
+ setModels(models: ProjectConfig['models']): void;
818
+ /**
819
+ * Get the project's stopWhen configuration
820
+ */
821
+ getStopWhen(): ProjectConfig['stopWhen'];
822
+ /**
823
+ * Set the project's stopWhen configuration
824
+ */
825
+ setStopWhen(stopWhen: ProjectConfig['stopWhen']): void;
826
+ /**
827
+ * Get all graphs in the project
828
+ */
829
+ getGraphs(): AgentGraph[];
830
+ /**
831
+ * Get a graph by ID
832
+ */
833
+ getGraph(id: string): AgentGraph | undefined;
834
+ /**
835
+ * Add a graph to the project
836
+ */
837
+ addGraph(graph: AgentGraph): void;
838
+ /**
839
+ * Remove a graph from the project
840
+ */
841
+ removeGraph(id: string): boolean;
842
+ /**
843
+ * Get project statistics
844
+ */
845
+ getStats(): {
846
+ projectId: string;
847
+ tenantId: string;
848
+ graphCount: number;
849
+ initialized: boolean;
850
+ };
851
+ /**
852
+ * Validate the project configuration
853
+ */
854
+ validate(): {
855
+ valid: boolean;
856
+ errors: string[];
857
+ };
858
+ /**
859
+ * Convert the Project to FullProjectDefinition format
860
+ */
861
+ private toFullProjectDefinition;
862
+ /**
863
+ * Convert project configuration to API format
864
+ */
865
+ private toApiFormat;
866
+ }
867
+
868
+ /**
869
+ * Helper function to create graphs - OpenAI style
870
+ */
871
+ declare function agentGraph(config: GraphConfig): AgentGraph;
872
+ /**
873
+ * Helper function to create projects - OpenAI style
874
+ *
875
+ * Projects are the top-level organizational unit that contains graphs, agents, and shared configurations.
876
+ * They provide model inheritance and execution limits that cascade down to graphs and agents.
877
+ *
878
+ * @param config - Project configuration
879
+ * @returns A new Project instance
880
+ *
881
+ * @example
882
+ * ```typescript
883
+ * const customerSupport = project({
884
+ * id: 'customer-support-project',
885
+ * name: 'Customer Support System',
886
+ * description: 'Multi-agent customer support system',
887
+ * models: {
888
+ * base: { model: 'gpt-4o-mini' },
889
+ * structuredOutput: { model: 'gpt-4o' }
890
+ * },
891
+ * stopWhen: {
892
+ * transferCountIs: 10,
893
+ * stepCountIs: 50
894
+ * },
895
+ * graphs: () => [
896
+ * agentGraph({
897
+ * id: 'support-graph',
898
+ * name: 'Support Graph',
899
+ * // ... graph config
900
+ * })
901
+ * ]
902
+ * });
903
+ * ```
904
+ */
905
+ declare function project(config: ProjectConfig): Project;
906
+ /**
907
+ * Creates a new agent with stable ID enforcement.
908
+ *
909
+ * Agents require explicit stable IDs to ensure consistency across deployments.
910
+ * This is different from tools which auto-generate IDs from their names.
911
+ *
912
+ * @param config - Agent configuration including required stable ID
913
+ * @returns A new Agent instance
914
+ * @throws {Error} If config.id is not provided
915
+ *
916
+ * @example
917
+ * ```typescript
918
+ * const myAgent = agent({
919
+ * id: 'customer-support-agent',
920
+ * name: 'Customer Support',
921
+ * prompt: 'Help customers with their questions'
922
+ * });
923
+ * ```
924
+ */
925
+ declare function agent(config: AgentConfig): Agent;
926
+ /**
927
+ * Creates a credential reference for authentication.
928
+ *
929
+ * Credentials are used to authenticate with external services.
930
+ * They should be stored securely and referenced by ID.
931
+ *
932
+ * @param config - Credential configuration
933
+ * @returns A validated credential reference
934
+ *
935
+ * @example
936
+ * ```typescript
937
+ * const apiCredential = credential({
938
+ * id: 'github-token',
939
+ * type: 'bearer',
940
+ * value: process.env.GITHUB_TOKEN
941
+ * });
942
+ * ```
943
+ */
944
+ declare function credential(config: CredentialReferenceApiInsert): {
945
+ id: string;
946
+ credentialStoreId: string;
947
+ type: "nango" | "memory" | "keychain";
948
+ retrievalParams?: Record<string, unknown> | null | undefined;
949
+ };
950
+ /**
951
+ * Creates an MCP (Model Context Protocol) server for tool functionality.
952
+ *
953
+ * MCP servers provide tool functionality through a standardized protocol.
954
+ * They can be remote services accessed via HTTP/WebSocket.
955
+ *
956
+ * @param config - MCP server configuration
957
+ * @returns A Tool instance configured as an MCP server
958
+ * @throws {Error} If serverUrl is not provided
959
+ *
960
+ * @example
961
+ * ```typescript
962
+ * // Remote MCP server
963
+ * const apiServer = mcpServer({
964
+ * name: 'external_api',
965
+ * description: 'External API service',
966
+ * serverUrl: 'https://api.example.com/mcp'
967
+ * });
968
+ *
969
+ * // With authentication
970
+ * const secureServer = mcpServer({
971
+ * name: 'secure_api',
972
+ * description: 'Secure API service',
973
+ * serverUrl: 'https://secure.example.com/mcp',
974
+ * credential: credential({
975
+ * id: 'api-key',
976
+ * type: 'bearer',
977
+ * value: process.env.API_KEY
978
+ * })
979
+ * });
980
+ * ```
981
+ */
982
+ declare function mcpServer(config: MCPServerConfig): Tool;
983
+ /**
984
+ * Creates an MCP tool from a raw configuration object.
985
+ *
986
+ * This is a low-level builder for advanced use cases where you need
987
+ * full control over the MCPToolConfig. For most cases, use `mcpServer()`.
988
+ *
989
+ * @param config - Complete MCP tool configuration
990
+ * @returns A Tool instance
991
+ *
992
+ * @example
993
+ * ```typescript
994
+ * const customTool = mcpTool({
995
+ * id: 'custom-tool',
996
+ * name: 'Custom Tool',
997
+ * serverUrl: 'https://example.com/mcp',
998
+ * transport: { type: 'stdio' }
999
+ * });
1000
+ * ```
1001
+ */
1002
+ declare function mcpTool(config: MCPToolConfig$1): Tool;
1003
+ /**
1004
+ * Creates an artifact component with automatic ID generation.
1005
+ *
1006
+ * Artifact components represent structured UI components that can
1007
+ * be rendered with different levels of detail (summary vs full).
1008
+ *
1009
+ * @param config - Artifact component configuration
1010
+ * @returns An ArtifactComponent instance
1011
+ *
1012
+ * @example
1013
+ * ```typescript
1014
+ * const productCard = artifactComponent({
1015
+ * name: 'Product Card',
1016
+ * description: 'Display product information',
1017
+ * summaryProps: {
1018
+ * title: 'Product',
1019
+ * price: '$0'
1020
+ * },
1021
+ * fullProps: {
1022
+ * title: 'Product',
1023
+ * price: '$0',
1024
+ * description: 'Product description',
1025
+ * image: 'product.jpg'
1026
+ * }
1027
+ * });
1028
+ * ```
1029
+ */
1030
+ declare function artifactComponent(config: ArtifactComponentConfig): ArtifactComponent;
1031
+ /**
1032
+ * Creates a data component with automatic ID generation.
1033
+ *
1034
+ * Data components represent structured data that can be
1035
+ * passed between agents or used in processing.
1036
+ *
1037
+ * @param config - Data component configuration
1038
+ * @returns A DataComponent instance
1039
+ *
1040
+ * @example
1041
+ * ```typescript
1042
+ * const userProfile = dataComponent({
1043
+ * name: 'User Profile',
1044
+ * description: 'User profile data',
1045
+ * props: {
1046
+ * userId: '123',
1047
+ * name: 'John Doe',
1048
+ * email: 'john@example.com'
1049
+ * }
1050
+ * });
1051
+ * ```
1052
+ */
1053
+ declare function dataComponent(config: DataComponentConfig): DataComponent;
1054
+ declare function agentMcp(config: AgentMcpConfig): AgentMcpConfig;
1055
+
1056
+ interface EnvironmentSettingsConfig {
1057
+ credentials?: {
1058
+ [settingId: string]: CredentialReferenceApiInsert;
1059
+ };
1060
+ }
1061
+ /**
1062
+ * Create a setting helper with TypeScript autocomplete
1063
+ */
1064
+ declare function createEnvironmentSettings<T extends Record<string, EnvironmentSettingsConfig>>(environments: T): {
1065
+ getEnvironmentSetting: (key: keyof NonNullable<T[keyof T]["credentials"]>) => Promise<CredentialReferenceApiInsert>;
1066
+ };
1067
+ /**
1068
+ * Create type-safe environment configurations
1069
+ */
1070
+ declare function registerEnvironmentSettings<T extends EnvironmentSettingsConfig>(config: T): T;
1071
+
1072
+ /**
1073
+ * Client-side functions for interacting with the Full Project API
1074
+ * These functions make HTTP requests to the server instead of direct database calls
1075
+ */
1076
+
1077
+ /**
1078
+ * Create a full project via HTTP API
1079
+ */
1080
+ declare function createFullProjectViaAPI(tenantId: string, apiUrl: string, projectData: FullProjectDefinition): Promise<FullProjectDefinition>;
1081
+ /**
1082
+ * Update a full project via HTTP API (upsert behavior)
1083
+ */
1084
+ declare function updateFullProjectViaAPI(tenantId: string, apiUrl: string, projectId: string, projectData: FullProjectDefinition): Promise<FullProjectDefinition>;
1085
+ /**
1086
+ * Get a full project via HTTP API
1087
+ */
1088
+ declare function getFullProjectViaAPI(tenantId: string, apiUrl: string, projectId: string): Promise<FullProjectDefinition | null>;
1089
+ /**
1090
+ * Delete a full project via HTTP API
1091
+ */
1092
+ declare function deleteFullProjectViaAPI(tenantId: string, apiUrl: string, projectId: string): Promise<void>;
1093
+
1094
+ declare class Runner {
1095
+ /**
1096
+ * Run a graph until completion, handling transfers and tool calls
1097
+ * Similar to OpenAI's Runner.run() pattern
1098
+ * NOTE: This now requires a graph instead of an agent
1099
+ */
1100
+ static run(graph: GraphInterface, messages: MessageInput, options?: GenerateOptions): Promise<RunResult>;
1101
+ /**
1102
+ * Stream a graph's response
1103
+ */
1104
+ static stream(graph: GraphInterface, messages: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
1105
+ /**
1106
+ * Execute multiple graphs in parallel and return the first successful result
1107
+ */
1108
+ static raceGraphs(graphs: GraphInterface[], messages: MessageInput, options?: GenerateOptions): Promise<RunResult>;
1109
+ private static normalizeToMessageHistory;
1110
+ /**
1111
+ * Validate graph configuration before running
1112
+ */
1113
+ static validateGraph(graph: GraphInterface): {
1114
+ valid: boolean;
1115
+ errors: string[];
1116
+ };
1117
+ /**
1118
+ * Get execution statistics for a graph
1119
+ */
1120
+ static getExecutionStats(graph: GraphInterface, messages: MessageInput, options?: GenerateOptions): Promise<{
1121
+ estimatedTurns: number;
1122
+ estimatedTokens: number;
1123
+ agentCount: number;
1124
+ defaultAgent: string | undefined;
1125
+ }>;
1126
+ }
1127
+ declare const run: typeof Runner.run;
1128
+ declare const stream: typeof Runner.stream;
1129
+ declare const raceGraphs: typeof Runner.raceGraphs;
1130
+
1131
+ export { Agent, type AgentCanUseType, type AgentConfig, AgentError, 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, Project, 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, agentMcp, artifactComponent, createEnvironmentSettings, createFullProjectViaAPI, credential, dataComponent, deleteFullProjectViaAPI, externalAgent, externalAgents, getFullProjectViaAPI, mcpServer, mcpTool, project, raceGraphs, registerEnvironmentSettings, run, stream, transfer, updateFullProjectViaAPI };