@inkeep/agents-sdk 0.1.1 → 0.1.6

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 +2863 -0
  3. package/dist/index.d.cts +919 -0
  4. package/dist/index.d.ts +919 -11
  5. package/dist/index.js +2840 -10
  6. package/package.json +7 -6
  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,919 @@
1
+ import { MCPToolConfig as MCPToolConfig$1, CredentialReferenceApiInsert, MCPTransportType, CredentialReferenceSelect, AgentApiInsert, DataComponentApiInsert, ArtifactComponentApiInsert, AgentConversationHistoryConfig, ToolInsert, McpTransportConfig, ArtifactComponentInsert, DataComponentInsert } 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?: {
199
+ stepCountIs?: number;
200
+ };
201
+ memory?: {
202
+ type: "conversation" | "episodic" | "short_term";
203
+ capacity?: number;
204
+ };
205
+ dataComponents?: () => DataComponentApiInsert[];
206
+ artifactComponents?: () => ArtifactComponentApiInsert[];
207
+ conversationHistoryConfig?: AgentConversationHistoryConfig;
208
+ }
209
+ interface ModelSettings {
210
+ model?: string;
211
+ providerOptions?: Record<string, Record<string, unknown>>;
212
+ }
213
+ declare const ModelSettingsSchema: z.ZodObject<{
214
+ model: z.ZodOptional<z.ZodString>;
215
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
216
+ }, z.core.$strip>;
217
+ interface ToolConfig extends ToolInsert {
218
+ execute: (params: any) => Promise<any>;
219
+ parameters?: Record<string, any>;
220
+ schema?: z.ZodJSONSchema;
221
+ }
222
+ interface ServerConfig {
223
+ type: string;
224
+ version?: string;
225
+ }
226
+ interface MCPToolConfig {
227
+ id: string;
228
+ name: string;
229
+ tenantId?: string;
230
+ description?: string;
231
+ credential?: CredentialReferenceApiInsert;
232
+ server?: ServerConfig;
233
+ serverUrl: string;
234
+ toolName?: string;
235
+ activeTools?: string[];
236
+ headers?: Record<string, string>;
237
+ mcpType?: "nango" | "generic";
238
+ transport?: McpTransportConfig;
239
+ imageUrl?: string;
240
+ }
241
+ interface FetchDefinitionConfig {
242
+ id: string;
243
+ name?: string;
244
+ trigger: "initialization" | "invocation";
245
+ url: string;
246
+ method?: string;
247
+ headers?: Record<string, string>;
248
+ body?: Record<string, unknown>;
249
+ transform?: string;
250
+ responseSchema?: z.ZodSchema<any>;
251
+ defaultValue?: unknown;
252
+ timeout?: number;
253
+ credential?: CredentialReferenceApiInsert;
254
+ }
255
+ interface RequestSchemaDefinition {
256
+ body?: z.ZodSchema<any>;
257
+ headers?: z.ZodSchema<any>;
258
+ query?: z.ZodSchema<any>;
259
+ params?: z.ZodSchema<any>;
260
+ }
261
+ interface RequestSchemaConfig {
262
+ schemas: RequestSchemaDefinition;
263
+ optional?: ("body" | "headers" | "query" | "params")[];
264
+ }
265
+ interface TransferConfig {
266
+ agent: AgentInterface;
267
+ description?: string;
268
+ condition?: (context: any) => boolean;
269
+ }
270
+ interface GenerateOptions {
271
+ maxTurns?: number;
272
+ maxSteps?: number;
273
+ temperature?: number;
274
+ toolChoice?: "auto" | "none" | string;
275
+ resourceId?: string;
276
+ conversationId?: string;
277
+ stream?: boolean;
278
+ customBodyParams?: Record<string, unknown>;
279
+ }
280
+ interface AgentResponse {
281
+ id?: string;
282
+ text: string;
283
+ toolCalls?: ToolCall[];
284
+ transfer?: TransferConfig;
285
+ finishReason: "completed" | "tool_calls" | "transfer" | "max_turns" | "error";
286
+ usage?: {
287
+ inputTokens: number;
288
+ outputTokens: number;
289
+ totalTokens?: number;
290
+ };
291
+ metadata?: Record<string, any>;
292
+ }
293
+ interface StreamResponse {
294
+ textStream?: AsyncGenerator<string>;
295
+ eventStream?: AsyncGenerator<StreamEvent>;
296
+ }
297
+ interface StreamEvent {
298
+ type: "text" | "tool_call" | "transfer" | "error" | "done";
299
+ data: any;
300
+ timestamp: Date;
301
+ }
302
+ interface RunResult {
303
+ finalOutput: string;
304
+ agent: AgentInterface;
305
+ turnCount: number;
306
+ usage?: {
307
+ inputTokens: number;
308
+ outputTokens: number;
309
+ totalTokens?: number;
310
+ };
311
+ metadata?: {
312
+ toolCalls: ToolCall[];
313
+ transfers: TransferConfig[];
314
+ };
315
+ }
316
+ interface StatusComponent {
317
+ id: string;
318
+ name: string;
319
+ type: string;
320
+ description?: string;
321
+ schema: {
322
+ type: "object";
323
+ properties: Record<string, any>;
324
+ required?: string[];
325
+ };
326
+ }
327
+ interface StatusUpdateSettings {
328
+ enabled?: boolean;
329
+ numEvents?: number;
330
+ timeInSeconds?: number;
331
+ model?: string;
332
+ statusComponents?: StatusComponent[];
333
+ prompt?: string;
334
+ }
335
+ interface GraphConfig {
336
+ id: string;
337
+ name?: string;
338
+ description?: string;
339
+ defaultAgent?: AgentInterface;
340
+ agents?: () => AllAgentInterface[];
341
+ tenantId?: string;
342
+ contextConfig?: any;
343
+ credentials?: () => CredentialReferenceApiInsert[];
344
+ stopWhen?: {
345
+ transferCountIs?: number;
346
+ };
347
+ graphPrompt?: string;
348
+ models?: {
349
+ base?: ModelSettings;
350
+ structuredOutput?: ModelSettings;
351
+ summarizer?: ModelSettings;
352
+ };
353
+ statusUpdates?: StatusUpdateSettings;
354
+ }
355
+ declare class AgentError extends Error {
356
+ code?: string | undefined;
357
+ details?: any | undefined;
358
+ constructor(message: string, code?: string | undefined, details?: any | undefined);
359
+ }
360
+ declare class MaxTurnsExceededError extends AgentError {
361
+ constructor(maxTurns: number);
362
+ }
363
+ declare class ToolExecutionError extends AgentError {
364
+ constructor(toolName: string, originalError: Error);
365
+ }
366
+ declare class TransferError extends AgentError {
367
+ constructor(sourceAgent: string, targetAgent: string, reason: string);
368
+ }
369
+ interface AgentInterface {
370
+ config: AgentConfig;
371
+ type: "internal";
372
+ init(): Promise<void>;
373
+ getId(): string;
374
+ getName(): string;
375
+ getInstructions(): string;
376
+ getTools(): Record<string, any>;
377
+ getTransfers(): AgentInterface[];
378
+ getDelegates(): AllAgentInterface[];
379
+ getDataComponents(): DataComponentApiInsert[];
380
+ getArtifactComponents(): ArtifactComponentApiInsert[];
381
+ addTool(name: string, tool: any): void;
382
+ addTransfer(...agents: AgentInterface[]): void;
383
+ addDelegate(...agents: AgentInterface[]): void;
384
+ }
385
+ interface ExternalAgentInterface {
386
+ config: ExternalAgentConfig;
387
+ type: "external";
388
+ init(): Promise<void>;
389
+ getId(): string;
390
+ getName(): string;
391
+ getDescription(): string;
392
+ getBaseUrl(): string;
393
+ getCredentialReferenceId(): string | undefined;
394
+ getHeaders(): Record<string, string> | undefined;
395
+ }
396
+ interface GraphInterface {
397
+ init(): Promise<void>;
398
+ setConfig(tenantId: string, projectId: string, apiUrl: string): void;
399
+ getId(): string;
400
+ getName(): string;
401
+ getDescription(): string | undefined;
402
+ getTenantId(): string;
403
+ generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
404
+ stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
405
+ generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
406
+ getDefaultAgent(): AgentInterface | undefined;
407
+ getAgent(name: string): AllAgentInterface | undefined;
408
+ getAgents(): AllAgentInterface[];
409
+ }
410
+ interface BuilderToolConfig {
411
+ name: string;
412
+ description: string;
413
+ config: {
414
+ type: "mcp";
415
+ mcp: {
416
+ server: {
417
+ url: string;
418
+ };
419
+ };
420
+ };
421
+ parameters?: Record<string, any>;
422
+ }
423
+ interface BuilderRelationConfig {
424
+ targetAgent: string;
425
+ relationType: "transfer" | "delegate";
426
+ }
427
+ interface BuilderAgentConfig {
428
+ name: string;
429
+ description: string;
430
+ instructions: string;
431
+ tools: BuilderToolConfig[];
432
+ relations?: BuilderRelationConfig[];
433
+ }
434
+
435
+ declare class Agent implements AgentInterface {
436
+ config: AgentConfig;
437
+ readonly type: "internal";
438
+ private baseURL;
439
+ private tenantId;
440
+ private projectId;
441
+ private initialized;
442
+ constructor(config: AgentConfig);
443
+ getId(): string;
444
+ getName(): string;
445
+ getInstructions(): string;
446
+ getTools(): Record<string, unknown>;
447
+ getModels(): typeof this$1.config.models;
448
+ setModels(models: typeof this$1.config.models): void;
449
+ getTransfers(): AgentInterface[];
450
+ getDelegates(): AllAgentInterface[];
451
+ getDataComponents(): DataComponentApiInsert[];
452
+ getArtifactComponents(): ArtifactComponentApiInsert[];
453
+ addTool(_name: string, tool: Tool): void;
454
+ addTransfer(...agents: AgentInterface[]): void;
455
+ addDelegate(...agents: AllAgentInterface[]): void;
456
+ init(): Promise<void>;
457
+ private upsertAgent;
458
+ private saveToolsAndRelations;
459
+ private saveDataComponents;
460
+ private saveArtifactComponents;
461
+ private loadDataComponents;
462
+ private loadArtifactComponents;
463
+ private createTool;
464
+ private createDataComponent;
465
+ private createArtifactComponent;
466
+ private createAgentDataComponentRelation;
467
+ private createAgentArtifactComponentRelation;
468
+ private createAgentToolRelation;
469
+ }
470
+
471
+ interface ArtifactComponentInterface {
472
+ config: Omit<ArtifactComponentInsert, "id">;
473
+ init(): Promise<void>;
474
+ getId(): ArtifactComponentInsert["id"];
475
+ getName(): ArtifactComponentInsert["name"];
476
+ getDescription(): ArtifactComponentInsert["description"];
477
+ getSummaryProps(): ArtifactComponentInsert["summaryProps"];
478
+ getFullProps(): ArtifactComponentInsert["fullProps"];
479
+ }
480
+ declare class ArtifactComponent implements ArtifactComponentInterface {
481
+ config: ArtifactComponentInsert;
482
+ private baseURL;
483
+ private tenantId;
484
+ private projectId;
485
+ private initialized;
486
+ private id;
487
+ constructor(config: Omit<ArtifactComponentInsert, "id">);
488
+ getId(): string;
489
+ getName(): string;
490
+ getDescription(): string;
491
+ getSummaryProps(): ArtifactComponentInsert["summaryProps"];
492
+ getFullProps(): ArtifactComponentInsert["fullProps"];
493
+ init(): Promise<void>;
494
+ private upsertArtifactComponent;
495
+ }
496
+
497
+ interface DataComponentInterface {
498
+ config: Omit<DataComponentInsert, "id">;
499
+ init(): Promise<void>;
500
+ getId(): DataComponentInsert["id"];
501
+ getName(): DataComponentInsert["name"];
502
+ getDescription(): DataComponentInsert["description"];
503
+ getProps(): DataComponentInsert["props"];
504
+ }
505
+ declare class DataComponent implements DataComponentInterface {
506
+ config: DataComponentInsert;
507
+ private baseURL;
508
+ private tenantId;
509
+ private projectId;
510
+ private initialized;
511
+ private id;
512
+ constructor(config: Omit<DataComponentInsert, "id">);
513
+ getId(): string;
514
+ getName(): string;
515
+ getDescription(): string;
516
+ getProps(): DataComponentInsert["props"];
517
+ init(): Promise<void>;
518
+ private upsertDataComponent;
519
+ }
520
+
521
+ declare class AgentGraph implements GraphInterface {
522
+ private agents;
523
+ private agentMap;
524
+ private defaultAgent?;
525
+ private baseURL;
526
+ private tenantId;
527
+ private projectId;
528
+ private graphId;
529
+ private graphName;
530
+ private graphDescription?;
531
+ private initialized;
532
+ private contextConfig?;
533
+ private credentials?;
534
+ private models?;
535
+ private statusUpdateSettings?;
536
+ private graphPrompt?;
537
+ private stopWhen?;
538
+ private dbClient;
539
+ constructor(config: GraphConfig);
540
+ /**
541
+ * Set or update the configuration (tenantId, projectId and apiUrl)
542
+ * This is used by the CLI to inject configuration from inkeep.config.ts
543
+ */
544
+ setConfig(tenantId: string, projectId: string, apiUrl: string): void;
545
+ /**
546
+ * Convert the AgentGraph to FullGraphDefinition format for the new graph endpoint
547
+ */
548
+ private toFullGraphDefinition;
549
+ /**
550
+ * Initialize all tools in all agents (especially IPCTools that need MCP server URLs)
551
+ */
552
+ private initializeAllTools;
553
+ /**
554
+ * Initialize the graph and all agents in the backend using the new graph endpoint
555
+ */
556
+ init(): Promise<void>;
557
+ /**
558
+ * Legacy initialization method - kept for backward compatibility
559
+ * Initialize the graph and all agents in the backend using individual endpoints
560
+ */
561
+ initLegacy(): Promise<void>;
562
+ /**
563
+ * Generate a response using the default agent
564
+ */
565
+ generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
566
+ /**
567
+ * Stream a response using the default agent
568
+ */
569
+ stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
570
+ /**
571
+ * Alias for stream() method for consistency with naming patterns
572
+ */
573
+ generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
574
+ /**
575
+ * Run with a specific agent from the graph
576
+ */
577
+ runWith(agentId: string, input: MessageInput, options?: GenerateOptions): Promise<RunResult>;
578
+ /**
579
+ * Get an agent by name (unified method for all agent types)
580
+ */
581
+ getAgent(name: string): AllAgentInterface | undefined;
582
+ /**
583
+ * Add an agent to the graph
584
+ */
585
+ addAgent(agent: AgentInterface): void;
586
+ /**
587
+ * Remove an agent from the graph
588
+ */
589
+ removeAgent(id: string): boolean;
590
+ /**
591
+ * Get all agents in the graph
592
+ */
593
+ getAgents(): AllAgentInterface[];
594
+ /**
595
+ * Get all agent ids (unified method for all agent types)
596
+ */
597
+ getAgentIds(): string[];
598
+ /**
599
+ * Set the default agent
600
+ */
601
+ setDefaultAgent(agent: AgentInterface): void;
602
+ /**
603
+ * Get the default agent
604
+ */
605
+ getDefaultAgent(): AgentInterface | undefined;
606
+ /**
607
+ * Get the graph ID
608
+ */
609
+ getId(): string;
610
+ getName(): string;
611
+ getDescription(): string | undefined;
612
+ getTenantId(): string;
613
+ /**
614
+ * Get the graph's model settingsuration
615
+ */
616
+ getModels(): typeof this.models;
617
+ /**
618
+ * Set the graph's model settingsuration
619
+ */
620
+ setModels(models: typeof this.models): void;
621
+ /**
622
+ * Get the graph's prompt configuration
623
+ */
624
+ getGraphPrompt(): string | undefined;
625
+ /**
626
+ * Get the graph's stopWhen configuration
627
+ */
628
+ getStopWhen(): {
629
+ transferCountIs?: number;
630
+ };
631
+ /**
632
+ * Get the graph's status updates configuration
633
+ */
634
+ getStatusUpdateSettings(): StatusUpdateSettings | undefined;
635
+ /**
636
+ * Get the summarizer model from the graph's model settings
637
+ */
638
+ getSummarizerModel(): ModelSettings | undefined;
639
+ /**
640
+ * Get graph statistics
641
+ */
642
+ getStats(): {
643
+ agentCount: number;
644
+ defaultAgent: string | null;
645
+ initialized: boolean;
646
+ graphId: string;
647
+ tenantId: string;
648
+ };
649
+ /**
650
+ * Validate the graph configuration
651
+ */
652
+ validate(): {
653
+ valid: boolean;
654
+ errors: string[];
655
+ };
656
+ private _init;
657
+ /**
658
+ * Type guard to check if an agent is an internal AgentInterface
659
+ */
660
+ isInternalAgent(agent: AllAgentInterface): agent is AgentInterface;
661
+ /**
662
+ * Get project-level model settingsuration defaults
663
+ */
664
+ private getProjectModelDefaults;
665
+ /**
666
+ * Get project-level stopWhen configuration defaults
667
+ */
668
+ private getProjectStopWhenDefaults;
669
+ /**
670
+ * Apply model inheritance hierarchy: Project -> Graph -> Agent
671
+ */
672
+ private applyModelInheritance;
673
+ /**
674
+ * Apply stopWhen inheritance hierarchy: Project -> Graph -> Agent
675
+ */
676
+ private applyStopWhenInheritance;
677
+ /**
678
+ * Propagate graph-level model settings to agents (supporting partial inheritance)
679
+ */
680
+ private propagateModelSettingsToAgent;
681
+ /**
682
+ * Immediately propagate graph-level models to all agents during construction
683
+ */
684
+ private propagateImmediateModelSettings;
685
+ /**
686
+ * Type guard to check if an agent is an external AgentInterface
687
+ */
688
+ isExternalAgent(agent: AllAgentInterface): agent is ExternalAgentInterface;
689
+ /**
690
+ * Execute agent using the backend system instead of local runner
691
+ */
692
+ private executeWithBackend;
693
+ /**
694
+ * Parse streaming response in SSE format
695
+ */
696
+ private parseStreamingResponse;
697
+ /**
698
+ * Normalize input messages to the expected format
699
+ */
700
+ private normalizeMessages;
701
+ private saveToDatabase;
702
+ private saveRelations;
703
+ private createAgentRelations;
704
+ private createInternalAgentRelation;
705
+ private createExternalAgentRelation;
706
+ /**
707
+ * Create external agents in the database
708
+ */
709
+ private createExternalAgents;
710
+ }
711
+
712
+ /**
713
+ * Helper function to create graphs - OpenAI style
714
+ */
715
+ declare function agentGraph(config: GraphConfig): AgentGraph;
716
+ /**
717
+ * Creates a new agent with stable ID enforcement.
718
+ *
719
+ * Agents require explicit stable IDs to ensure consistency across deployments.
720
+ * This is different from tools which auto-generate IDs from their names.
721
+ *
722
+ * @param config - Agent configuration including required stable ID
723
+ * @returns A new Agent instance
724
+ * @throws {Error} If config.id is not provided
725
+ *
726
+ * @example
727
+ * ```typescript
728
+ * const myAgent = agent({
729
+ * id: 'customer-support-agent',
730
+ * name: 'Customer Support',
731
+ * prompt: 'Help customers with their questions'
732
+ * });
733
+ * ```
734
+ */
735
+ declare function agent(config: AgentConfig): Agent;
736
+ /**
737
+ * Creates a credential reference for authentication.
738
+ *
739
+ * Credentials are used to authenticate with external services.
740
+ * They should be stored securely and referenced by ID.
741
+ *
742
+ * @param config - Credential configuration
743
+ * @returns A validated credential reference
744
+ *
745
+ * @example
746
+ * ```typescript
747
+ * const apiCredential = credential({
748
+ * id: 'github-token',
749
+ * type: 'bearer',
750
+ * value: process.env.GITHUB_TOKEN
751
+ * });
752
+ * ```
753
+ */
754
+ declare function credential(config: CredentialReferenceApiInsert): {
755
+ id: string;
756
+ credentialStoreId: string;
757
+ type: "nango" | "memory" | "keychain";
758
+ retrievalParams?: Record<string, unknown> | null | undefined;
759
+ };
760
+ /**
761
+ * Creates an MCP (Model Context Protocol) server for tool functionality.
762
+ *
763
+ * MCP servers provide tool functionality through a standardized protocol.
764
+ * They can be remote services accessed via HTTP/WebSocket.
765
+ *
766
+ * @param config - MCP server configuration
767
+ * @returns A Tool instance configured as an MCP server
768
+ * @throws {Error} If serverUrl is not provided
769
+ *
770
+ * @example
771
+ * ```typescript
772
+ * // Remote MCP server
773
+ * const apiServer = mcpServer({
774
+ * name: 'external_api',
775
+ * description: 'External API service',
776
+ * serverUrl: 'https://api.example.com/mcp'
777
+ * });
778
+ *
779
+ * // With authentication
780
+ * const secureServer = mcpServer({
781
+ * name: 'secure_api',
782
+ * description: 'Secure API service',
783
+ * serverUrl: 'https://secure.example.com/mcp',
784
+ * credential: credential({
785
+ * id: 'api-key',
786
+ * type: 'bearer',
787
+ * value: process.env.API_KEY
788
+ * })
789
+ * });
790
+ * ```
791
+ */
792
+ declare function mcpServer(config: MCPServerConfig): Tool;
793
+ /**
794
+ * Creates an MCP tool from a raw configuration object.
795
+ *
796
+ * This is a low-level builder for advanced use cases where you need
797
+ * full control over the MCPToolConfig. For most cases, use `mcpServer()`.
798
+ *
799
+ * @param config - Complete MCP tool configuration
800
+ * @returns A Tool instance
801
+ *
802
+ * @example
803
+ * ```typescript
804
+ * const customTool = mcpTool({
805
+ * id: 'custom-tool',
806
+ * name: 'Custom Tool',
807
+ * serverUrl: 'https://example.com/mcp',
808
+ * transport: { type: 'stdio' }
809
+ * });
810
+ * ```
811
+ */
812
+ declare function mcpTool(config: MCPToolConfig$1): Tool;
813
+ /**
814
+ * Creates an artifact component with automatic ID generation.
815
+ *
816
+ * Artifact components represent structured UI components that can
817
+ * be rendered with different levels of detail (summary vs full).
818
+ *
819
+ * @param config - Artifact component configuration
820
+ * @returns An ArtifactComponent instance
821
+ *
822
+ * @example
823
+ * ```typescript
824
+ * const productCard = artifactComponent({
825
+ * name: 'Product Card',
826
+ * description: 'Display product information',
827
+ * summaryProps: {
828
+ * title: 'Product',
829
+ * price: '$0'
830
+ * },
831
+ * fullProps: {
832
+ * title: 'Product',
833
+ * price: '$0',
834
+ * description: 'Product description',
835
+ * image: 'product.jpg'
836
+ * }
837
+ * });
838
+ * ```
839
+ */
840
+ declare function artifactComponent(config: ArtifactComponentConfig): ArtifactComponent;
841
+ /**
842
+ * Creates a data component with automatic ID generation.
843
+ *
844
+ * Data components represent structured data that can be
845
+ * passed between agents or used in processing.
846
+ *
847
+ * @param config - Data component configuration
848
+ * @returns A DataComponent instance
849
+ *
850
+ * @example
851
+ * ```typescript
852
+ * const userProfile = dataComponent({
853
+ * name: 'User Profile',
854
+ * description: 'User profile data',
855
+ * props: {
856
+ * userId: '123',
857
+ * name: 'John Doe',
858
+ * email: 'john@example.com'
859
+ * }
860
+ * });
861
+ * ```
862
+ */
863
+ declare function dataComponent(config: DataComponentConfig): DataComponent;
864
+ declare function agentMcp(config: AgentMcpConfig): AgentMcpConfig;
865
+
866
+ interface EnvironmentSettingsConfig {
867
+ credentials?: {
868
+ [settingId: string]: CredentialReferenceApiInsert;
869
+ };
870
+ }
871
+ /**
872
+ * Create a setting helper with TypeScript autocomplete
873
+ */
874
+ declare function createEnvironmentSettings<T extends Record<string, EnvironmentSettingsConfig>>(environments: T): {
875
+ getEnvironmentSetting: (key: keyof NonNullable<T[keyof T]["credentials"]>) => Promise<CredentialReferenceApiInsert>;
876
+ };
877
+ /**
878
+ * Create type-safe environment configurations
879
+ */
880
+ declare function registerEnvironmentSettings<T extends EnvironmentSettingsConfig>(config: T): T;
881
+
882
+ declare class Runner {
883
+ /**
884
+ * Run a graph until completion, handling transfers and tool calls
885
+ * Similar to OpenAI's Runner.run() pattern
886
+ * NOTE: This now requires a graph instead of an agent
887
+ */
888
+ static run(graph: GraphInterface, messages: MessageInput, options?: GenerateOptions): Promise<RunResult>;
889
+ /**
890
+ * Stream a graph's response
891
+ */
892
+ static stream(graph: GraphInterface, messages: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
893
+ /**
894
+ * Execute multiple graphs in parallel and return the first successful result
895
+ */
896
+ static raceGraphs(graphs: GraphInterface[], messages: MessageInput, options?: GenerateOptions): Promise<RunResult>;
897
+ private static normalizeToMessageHistory;
898
+ /**
899
+ * Validate graph configuration before running
900
+ */
901
+ static validateGraph(graph: GraphInterface): {
902
+ valid: boolean;
903
+ errors: string[];
904
+ };
905
+ /**
906
+ * Get execution statistics for a graph
907
+ */
908
+ static getExecutionStats(graph: GraphInterface, messages: MessageInput, options?: GenerateOptions): Promise<{
909
+ estimatedTurns: number;
910
+ estimatedTokens: number;
911
+ agentCount: number;
912
+ defaultAgent: string | undefined;
913
+ }>;
914
+ }
915
+ declare const run: typeof Runner.run;
916
+ declare const stream: typeof Runner.stream;
917
+ declare const raceGraphs: typeof Runner.raceGraphs;
918
+
919
+ 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, 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, credential, dataComponent, externalAgent, externalAgents, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, transfer };