@inkeep/agents-sdk 0.39.4 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/_virtual/rolldown_runtime.js +7 -0
  2. package/dist/agent.d.ts +186 -0
  3. package/dist/agent.js +720 -0
  4. package/dist/agentFullClient.d.ts +22 -0
  5. package/dist/agentFullClient.js +120 -0
  6. package/dist/artifact-component.d.ts +34 -0
  7. package/dist/artifact-component.js +104 -0
  8. package/dist/builderFunctions.d.ts +283 -0
  9. package/dist/builderFunctions.js +327 -0
  10. package/dist/builderFunctionsExperimental.d.ts +24 -0
  11. package/dist/builderFunctionsExperimental.js +27 -0
  12. package/dist/builders.d.ts +111 -0
  13. package/dist/builders.js +52 -0
  14. package/dist/credential-provider.d.ts +176 -0
  15. package/dist/credential-provider.js +237 -0
  16. package/dist/credential-ref.d.ts +60 -0
  17. package/dist/credential-ref.js +33 -0
  18. package/dist/data-component.d.ts +39 -0
  19. package/dist/data-component.js +109 -0
  20. package/dist/environment-settings.d.ts +27 -0
  21. package/dist/environment-settings.js +41 -0
  22. package/dist/external-agent.d.ts +64 -0
  23. package/dist/external-agent.js +156 -0
  24. package/dist/function-tool.d.ts +37 -0
  25. package/dist/function-tool.js +66 -0
  26. package/dist/index.d.ts +19 -1825
  27. package/dist/index.js +19 -4058
  28. package/dist/module-hosted-tool-manager.d.ts +40 -0
  29. package/dist/module-hosted-tool-manager.js +359 -0
  30. package/dist/project.d.ts +214 -0
  31. package/dist/project.js +615 -0
  32. package/dist/projectFullClient.d.ts +23 -0
  33. package/dist/projectFullClient.js +162 -0
  34. package/dist/runner.d.ts +41 -0
  35. package/dist/runner.js +145 -0
  36. package/dist/status-component.d.ts +22 -0
  37. package/dist/status-component.js +36 -0
  38. package/dist/subAgent.d.ts +52 -0
  39. package/dist/subAgent.js +616 -0
  40. package/dist/telemetry-provider.d.ts +218 -0
  41. package/dist/telemetry-provider.js +390 -0
  42. package/dist/tool.d.ts +53 -0
  43. package/dist/tool.js +130 -0
  44. package/dist/types.d.ts +296 -0
  45. package/dist/types.js +39 -0
  46. package/dist/utils/generateIdFromName.d.ts +9 -0
  47. package/dist/utils/generateIdFromName.js +12 -0
  48. package/dist/utils/getFunctionToolDeps.d.ts +17 -0
  49. package/dist/utils/getFunctionToolDeps.js +131 -0
  50. package/dist/utils/tool-normalization.d.ts +42 -0
  51. package/dist/utils/tool-normalization.js +41 -0
  52. package/dist/utils/validateFunction.d.ts +10 -0
  53. package/dist/utils/validateFunction.js +13 -0
  54. package/package.json +11 -16
  55. package/dist/index.cjs +0 -4147
  56. package/dist/index.d.cts +0 -1825
  57. package/dist/index.d.cts.map +0 -1
  58. package/dist/index.d.ts.map +0 -1
  59. package/dist/index.js.map +0 -1
package/dist/index.d.cts DELETED
@@ -1,1825 +0,0 @@
1
- import { ANTHROPIC_MODELS, AgentConversationHistoryConfig, AgentStopWhen, ArtifactComponentApiInsert, ArtifactComponentInsert, CredentialReferenceApiInsert, DataComponentApiInsert, DataComponentInsert, FullAgentDefinition, FullProjectDefinition, FunctionToolConfig, GOOGLE_MODELS, MCPToolConfig as MCPToolConfig$1, McpToolSelection, McpTransportConfig, ModelSettings, OPENAI_MODELS, StatusComponent as StatusComponent$1, StatusUpdateSettings, StopWhen, SubAgentApiInsert, ToolInsert, ToolPolicy } from "@inkeep/agents-core";
2
- import { z } from "zod";
3
-
4
- //#region src/artifact-component.d.ts
5
- type ArtifactComponentConfigWithZod = Omit<ArtifactComponentInsert, 'tenantId' | 'projectId' | 'props'> & {
6
- props?: Record<string, unknown> | z.ZodObject<any> | null;
7
- };
8
- interface ArtifactComponentInterface {
9
- config: Omit<ArtifactComponentInsert, 'tenantId' | 'projectId'>;
10
- init(): Promise<void>;
11
- getId(): ArtifactComponentInsert['id'];
12
- getName(): ArtifactComponentInsert['name'];
13
- getDescription(): ArtifactComponentInsert['description'];
14
- getProps(): ArtifactComponentInsert['props'];
15
- setContext(tenantId: string, projectId: string, baseURL?: string): void;
16
- }
17
- declare class ArtifactComponent implements ArtifactComponentInterface {
18
- config: Omit<ArtifactComponentInsert, 'tenantId' | 'projectId'>;
19
- private baseURL;
20
- private tenantId;
21
- private projectId;
22
- private initialized;
23
- private id;
24
- constructor(config: ArtifactComponentConfigWithZod);
25
- setContext(tenantId: string, projectId: string, baseURL?: string): void;
26
- getId(): string;
27
- getName(): string;
28
- getDescription(): string;
29
- getProps(): ArtifactComponentInsert['props'];
30
- init(): Promise<void>;
31
- private upsertArtifactComponent;
32
- }
33
- //#endregion
34
- //#region src/tool.d.ts
35
- interface ToolInterface {
36
- config: MCPToolConfig$1;
37
- init(): Promise<void>;
38
- getId(): string;
39
- getName(): string;
40
- getDescription(): string;
41
- getServerUrl(): string;
42
- getActiveTools(): string[] | undefined;
43
- getCredentialReferenceId(): string | null | undefined;
44
- with(config: AgentMcpConfigInput): AgentMcpConfig;
45
- }
46
- declare class Tool implements ToolInterface {
47
- config: MCPToolConfig$1;
48
- private baseURL;
49
- private tenantId;
50
- private initialized;
51
- private projectId;
52
- constructor(config: Omit<MCPToolConfig$1, 'tenantId' | 'projectId'>);
53
- setContext(tenantId: string, projectId: string, baseURL?: string): void;
54
- getId(): string;
55
- getName(): string;
56
- getDescription(): string;
57
- getServerUrl(): string;
58
- getActiveTools(): string[] | undefined;
59
- getCredentialReferenceId(): string | null | undefined;
60
- init(options?: {
61
- skipDatabaseRegistration?: boolean;
62
- }): Promise<void>;
63
- private upsertTool;
64
- /**
65
- * Creates a new AgentMcpConfig with the given configuration.
66
- *
67
- * @param config - The configuration for the AgentMcpConfig
68
- * @returns A new AgentMcpConfig
69
- *
70
- * example:
71
- * ```typescript
72
- * const tool = new Tool({
73
- * id: 'tool-id',
74
- * name: 'Tool Name',
75
- * serverUrl: 'https://example.com/mcp',
76
- * });
77
- * const agentMcpConfig = tool.with({ selectedTools: ['tool-1', 'tool-2'], headers: { 'Authorization': 'Bearer token' } });
78
- * ```
79
- */
80
- with(config: AgentMcpConfigInput): AgentMcpConfig;
81
- }
82
- //#endregion
83
- //#region src/subAgent.d.ts
84
- declare class SubAgent implements SubAgentInterface {
85
- config: SubAgentConfig;
86
- readonly type: "internal";
87
- private baseURL;
88
- private tenantId;
89
- private projectId;
90
- private initialized;
91
- constructor(config: SubAgentConfig);
92
- setContext(tenantId: string, projectId: string, baseURL?: string): void;
93
- getId(): string;
94
- getName(): string;
95
- getInstructions(): string;
96
- /**
97
- * Get the agent's description (the human-readable description field)
98
- */
99
- getDescription(): string;
100
- getTools(): Record<string, AgentTool>;
101
- getModels(): typeof this.config.models;
102
- setModels(models: typeof this.config.models): void;
103
- getTransfers(): SubAgentInterface[];
104
- getSubAgentDelegates(): SubAgentInterface[];
105
- getExternalAgentDelegates(): subAgentExternalAgentInterface[];
106
- getTeamAgentDelegates(): subAgentTeamAgentInterface[];
107
- getDelegates(): AllDelegateOutputInterface[];
108
- getDataComponents(): DataComponentApiInsert[];
109
- getArtifactComponents(): ArtifactComponentApiInsert[];
110
- addTool(_name: string, tool: Tool): void;
111
- addTransfer(...agents: SubAgentInterface[]): void;
112
- addDelegate(...agents: AllDelegateInputInterface[]): void;
113
- init(): Promise<void>;
114
- private upsertAgent;
115
- private saveToolsAndRelations;
116
- private saveDataComponents;
117
- private saveArtifactComponents;
118
- private loadDataComponents;
119
- private loadArtifactComponents;
120
- private createFunctionTool;
121
- private createTool;
122
- private createDataComponent;
123
- private createArtifactComponent;
124
- private createAgentDataComponentRelation;
125
- private createAgentArtifactComponentRelation;
126
- private createAgentToolRelation;
127
- }
128
- //#endregion
129
- //#region src/builders.d.ts
130
- /**
131
- * Function signature for transfer conditions
132
- */
133
- type TransferConditionFunction = (context: unknown) => boolean;
134
- /**
135
- * Configuration for MCP server builders
136
- */
137
- interface MCPServerConfig {
138
- name: string;
139
- description: string;
140
- serverUrl: string;
141
- id?: string;
142
- parameters?: Record<string, z.ZodJSONSchema>;
143
- credential?: CredentialReferenceApiInsert;
144
- transport?: 'streamable_http' | 'sse';
145
- activeTools?: string[];
146
- headers?: Record<string, string>;
147
- imageUrl?: string;
148
- }
149
- /**
150
- * Configuration for component builders
151
- */
152
- interface ComponentConfig {
153
- id?: string;
154
- name: string;
155
- description: string;
156
- }
157
- interface ArtifactComponentConfig extends ComponentConfig {
158
- props: Record<string, unknown> | z.ZodObject<any>;
159
- }
160
- interface DataComponentConfig extends ComponentConfig {
161
- props: Record<string, unknown> | z.ZodObject<any>;
162
- render?: {
163
- component: string;
164
- mockData: Record<string, unknown>;
165
- };
166
- }
167
- interface StatusComponentConfig {
168
- type: string;
169
- description?: string;
170
- detailsSchema?: Record<string, unknown> | z.ZodObject<any>;
171
- }
172
- type AgentMcpConfig = {
173
- server: Tool;
174
- selectedTools?: string[];
175
- headers?: Record<string, string>;
176
- toolPolicies?: Record<string, ToolPolicy>;
177
- };
178
- /**
179
- * Input configuration for MCP tool customization
180
- * Supports flexible tool selection with per-tool policies
181
- */
182
- type AgentMcpConfigInput = {
183
- /**
184
- * Tools to enable from the MCP server - can be strings or objects with policies
185
- * - undefined or null: all tools enabled (no filtering)
186
- * - []: zero tools enabled (explicit empty selection)
187
- * - ['tool1', 'tool2']: specific tools enabled
188
- */
189
- selectedTools?: McpToolSelection[] | null;
190
- /** Custom headers for MCP server requests */
191
- headers?: Record<string, string>;
192
- };
193
- /**
194
- * Creates a transfer configuration for agent transfers.
195
- *
196
- * Transfers allow one agent to hand off control to another agent
197
- * based on optional conditions.
198
- *
199
- * @param targetAgent - The agent to transfer to
200
- * @param description - Optional description of when/why to transfer
201
- * @param condition - Optional function to determine if transfer should occur
202
- * @returns A validated transfer configuration
203
- *
204
- * @example
205
- * ```typescript
206
- * // Simple transfer
207
- * const transfer = transfer(supportAgent, 'Transfer to support');
208
- *
209
- * // Conditional transfer
210
- * const conditionalHandoff = transfer(
211
- * specialistAgent,
212
- * 'Transfer to specialist for complex issues',
213
- * (context) => context.complexity > 0.8
214
- * );
215
- * ```
216
- */
217
- declare function transfer(targetAgent: SubAgent, description?: string, condition?: TransferConditionFunction): TransferConfig;
218
- //#endregion
219
- //#region src/data-component.d.ts
220
- type DataComponentConfigWithZod = Omit<DataComponentInsert, 'tenantId' | 'projectId' | 'props' | 'render'> & {
221
- props?: Record<string, unknown> | z.ZodObject<any> | null;
222
- render?: {
223
- component: string;
224
- mockData: Record<string, unknown>;
225
- } | null;
226
- };
227
- interface DataComponentInterface {
228
- config: Omit<DataComponentInsert, 'tenantId' | 'projectId'>;
229
- init(): Promise<void>;
230
- getId(): DataComponentInsert['id'];
231
- getName(): DataComponentInsert['name'];
232
- getDescription(): DataComponentInsert['description'];
233
- getProps(): DataComponentInsert['props'];
234
- setContext(tenantId: string, projectId: string, baseURL?: string): void;
235
- }
236
- declare class DataComponent implements DataComponentInterface {
237
- config: Omit<DataComponentInsert, 'tenantId' | 'projectId'>;
238
- private baseURL;
239
- private tenantId;
240
- private projectId;
241
- private initialized;
242
- private id;
243
- constructor(config: DataComponentConfigWithZod);
244
- setContext(tenantId: string, projectId: string, baseURL?: string): void;
245
- getId(): string;
246
- getName(): string;
247
- getDescription(): string;
248
- getProps(): DataComponentInsert['props'];
249
- getRender(): DataComponentInsert['render'];
250
- init(): Promise<void>;
251
- private upsertDataComponent;
252
- }
253
- //#endregion
254
- //#region src/external-agent.d.ts
255
- type ExternalAgentConfig = {
256
- type?: 'external';
257
- id: string;
258
- name: string;
259
- description: string;
260
- baseUrl: string;
261
- credentialReference?: CredentialReferenceApiInsert;
262
- };
263
- declare class ExternalAgent implements ExternalAgentInterface {
264
- config: ExternalAgentConfig;
265
- readonly type: "external";
266
- private initialized;
267
- private tenantId;
268
- private projectId;
269
- private baseURL;
270
- constructor(config: ExternalAgentConfig);
271
- /**
272
- * Initialize the external agent by upserting it in the database
273
- */
274
- init(): Promise<void>;
275
- setContext(tenantId: string, projectId: string): void;
276
- getId(): string;
277
- with(options: {
278
- headers?: Record<string, string>;
279
- }): subAgentExternalAgentInterface;
280
- private upsertExternalAgent;
281
- /**
282
- * Get the external agent configuration
283
- */
284
- getConfig(): ExternalAgentConfig;
285
- /**
286
- * Get the external agent name
287
- */
288
- getName(): string;
289
- /**
290
- * Get the external agent base URL
291
- */
292
- getBaseUrl(): string;
293
- /**
294
- * Get the tenant ID
295
- */
296
- getTenantId(): string;
297
- getDescription(): string;
298
- getCredentialReferenceId(): string | undefined;
299
- getCredentialReference(): CredentialReferenceApiInsert | undefined;
300
- }
301
- /**
302
- * Factory function to create external agents - follows the same pattern as agent()
303
- */
304
- declare function externalAgent(config: ExternalAgentConfig): ExternalAgent;
305
- /**
306
- * Helper function to create multiple external agents
307
- */
308
- declare function externalAgents(configs: Record<string, ExternalAgentConfig>): Record<string, ExternalAgent>;
309
- //#endregion
310
- //#region src/function-tool.d.ts
311
- interface FunctionToolInterface {
312
- config: FunctionToolConfig;
313
- getId(): string;
314
- getName(): string;
315
- getDescription(): string;
316
- getInputSchema(): Record<string, unknown>;
317
- getDependencies(): Record<string, string>;
318
- getExecuteFunction(): (params: any) => Promise<any>;
319
- }
320
- declare class FunctionTool implements FunctionToolInterface {
321
- config: FunctionToolConfig;
322
- private id;
323
- constructor(config: FunctionToolConfig);
324
- getId(): string;
325
- getName(): string;
326
- getDescription(): string;
327
- getInputSchema(): Record<string, unknown>;
328
- getDependencies(): Record<string, string>;
329
- getExecuteFunction(): (params: any) => Promise<any>;
330
- serializeFunction(): {
331
- id: string;
332
- inputSchema: Record<string, unknown>;
333
- executeCode: string;
334
- dependencies: Record<string, string>;
335
- };
336
- serializeTool(): {
337
- id: string;
338
- name: string;
339
- description: string;
340
- functionId: string;
341
- };
342
- }
343
- //#endregion
344
- //#region src/types.d.ts
345
- interface ArtifactComponentWithZodProps {
346
- id: string;
347
- name: string;
348
- description: string;
349
- props?: z.ZodObject<any>;
350
- }
351
- interface DataComponentWithZodProps {
352
- id: string;
353
- name: string;
354
- description: string;
355
- props?: z.ZodObject<any>;
356
- }
357
- /**
358
- * Tool instance that may have additional metadata attached during agent processing
359
- */
360
- type AgentTool = (Tool & {
361
- selectedTools?: string[];
362
- headers?: Record<string, string>;
363
- toolPolicies?: Record<string, ToolPolicy>;
364
- }) | (FunctionTool & {
365
- selectedTools?: string[];
366
- headers?: Record<string, string>;
367
- toolPolicies?: Record<string, ToolPolicy>;
368
- });
369
- interface UserMessage {
370
- role: 'user';
371
- content: string;
372
- }
373
- interface AssistantMessage {
374
- role: 'assistant';
375
- content: string;
376
- toolCalls?: ToolCall[];
377
- }
378
- interface ToolMessage {
379
- role: 'tool';
380
- content: string;
381
- toolCallId: string;
382
- }
383
- interface SystemMessage {
384
- role: 'system';
385
- content: string;
386
- }
387
- type Message = UserMessage | AssistantMessage | ToolMessage | SystemMessage;
388
- type MessageInput = string | string[] | Message | Message[];
389
- interface ToolCall {
390
- id: string;
391
- type: 'function';
392
- function: {
393
- name: string;
394
- arguments: string;
395
- };
396
- }
397
- interface ToolResult {
398
- id: string;
399
- result: any;
400
- error?: string;
401
- }
402
- type AllDelegateInputInterface = SubAgentInterface | subAgentExternalAgentInterface | ExternalAgentInterface | AgentInterface | subAgentTeamAgentInterface;
403
- type AllDelegateOutputInterface = SubAgentInterface | subAgentExternalAgentInterface | subAgentTeamAgentInterface;
404
- type SubAgentCanUseType = Tool | AgentMcpConfig | FunctionTool;
405
- interface SubAgentConfig extends Omit<SubAgentApiInsert, 'projectId'> {
406
- type?: 'internal';
407
- canUse?: () => SubAgentCanUseType[];
408
- canTransferTo?: () => SubAgentInterface[];
409
- canDelegateTo?: () => AllDelegateInputInterface[];
410
- dataComponents?: () => (DataComponentApiInsert | DataComponentInterface | DataComponentWithZodProps)[];
411
- artifactComponents?: () => (ArtifactComponentApiInsert | ArtifactComponentInterface | ArtifactComponentWithZodProps)[];
412
- conversationHistoryConfig?: AgentConversationHistoryConfig;
413
- }
414
- interface ToolConfig extends ToolInsert {
415
- execute: (params: any) => Promise<any>;
416
- parameters?: Record<string, any>;
417
- schema?: z.ZodJSONSchema;
418
- }
419
- interface ServerConfig {
420
- type: string;
421
- version?: string;
422
- }
423
- interface MCPToolConfig {
424
- id: string;
425
- name: string;
426
- tenantId?: string;
427
- description?: string;
428
- credential?: CredentialReferenceApiInsert;
429
- server?: ServerConfig;
430
- serverUrl: string;
431
- toolName?: string;
432
- activeTools?: string[];
433
- headers?: Record<string, string>;
434
- mcpType?: 'nango' | 'generic';
435
- transport?: McpTransportConfig;
436
- imageUrl?: string;
437
- }
438
- interface FetchDefinitionConfig {
439
- id: string;
440
- name?: string;
441
- trigger: 'initialization' | 'invocation';
442
- url: string;
443
- method?: string;
444
- headers?: Record<string, string>;
445
- body?: Record<string, unknown>;
446
- transform?: string;
447
- responseSchema?: z.ZodSchema<any>;
448
- defaultValue?: unknown;
449
- timeout?: number;
450
- credential?: CredentialReferenceApiInsert;
451
- }
452
- interface RequestSchemaDefinition {
453
- body?: z.ZodSchema<any>;
454
- headers?: z.ZodSchema<any>;
455
- query?: z.ZodSchema<any>;
456
- params?: z.ZodSchema<any>;
457
- }
458
- interface RequestSchemaConfig {
459
- schemas: RequestSchemaDefinition;
460
- optional?: ('body' | 'headers' | 'query' | 'params')[];
461
- }
462
- interface TransferConfig {
463
- agent: SubAgentInterface;
464
- description?: string;
465
- condition?: (context: any) => boolean;
466
- }
467
- interface GenerateOptions {
468
- maxTurns?: number;
469
- maxSteps?: number;
470
- temperature?: number;
471
- toolChoice?: 'auto' | 'none' | string;
472
- resourceId?: string;
473
- conversationId?: string;
474
- stream?: boolean;
475
- customBodyParams?: Record<string, unknown>;
476
- }
477
- interface AgentResponse {
478
- id?: string;
479
- text: string;
480
- toolCalls?: ToolCall[];
481
- transfer?: TransferConfig;
482
- finishReason: 'completed' | 'tool_calls' | 'transfer' | 'max_turns' | 'error';
483
- usage?: {
484
- inputTokens: number;
485
- outputTokens: number;
486
- totalTokens?: number;
487
- };
488
- metadata?: Record<string, any>;
489
- }
490
- interface StreamResponse {
491
- textStream?: AsyncGenerator<string>;
492
- eventStream?: AsyncGenerator<StreamEvent>;
493
- }
494
- interface StreamEvent {
495
- type: 'text' | 'tool_call' | 'transfer' | 'error' | 'done';
496
- data: any;
497
- timestamp: Date;
498
- }
499
- interface RunResult {
500
- finalOutput: string;
501
- agent: SubAgentInterface;
502
- turnCount: number;
503
- usage?: {
504
- inputTokens: number;
505
- outputTokens: number;
506
- totalTokens?: number;
507
- };
508
- metadata?: {
509
- toolCalls: ToolCall[];
510
- transfers: TransferConfig[];
511
- };
512
- }
513
- interface AgentConfig {
514
- id: string;
515
- name?: string;
516
- description?: string;
517
- defaultSubAgent: SubAgentInterface;
518
- subAgents?: () => SubAgentInterface[];
519
- contextConfig?: any;
520
- credentials?: () => CredentialReferenceApiInsert[];
521
- stopWhen?: AgentStopWhen;
522
- prompt?: string;
523
- models?: {
524
- base?: ModelSettings;
525
- structuredOutput?: ModelSettings;
526
- summarizer?: ModelSettings;
527
- };
528
- statusUpdates?: StatusUpdateSettings;
529
- }
530
- declare class AgentError extends Error {
531
- code?: string | undefined;
532
- details?: any | undefined;
533
- constructor(message: string, code?: string | undefined, details?: any | undefined);
534
- }
535
- declare class MaxTurnsExceededError extends AgentError {
536
- constructor(maxTurns: number);
537
- }
538
- declare class ToolExecutionError extends AgentError {
539
- constructor(toolName: string, originalError: Error);
540
- }
541
- declare class TransferError extends AgentError {
542
- constructor(sourceAgent: string, targetAgent: string, reason: string);
543
- }
544
- interface SubAgentInterface {
545
- config: SubAgentConfig;
546
- type: 'internal';
547
- init(): Promise<void>;
548
- getId(): string;
549
- getName(): string;
550
- getDescription(): string;
551
- getInstructions(): string;
552
- getTools(): Record<string, AgentTool>;
553
- getTransfers(): SubAgentInterface[];
554
- getDelegates(): AllDelegateOutputInterface[];
555
- getSubAgentDelegates(): SubAgentInterface[];
556
- getExternalAgentDelegates(): subAgentExternalAgentInterface[];
557
- getDataComponents(): DataComponentApiInsert[];
558
- getArtifactComponents(): ArtifactComponentApiInsert[];
559
- setContext(tenantId: string, projectId: string, baseURL?: string): void;
560
- addTool(name: string, tool: any): void;
561
- addTransfer(...agents: SubAgentInterface[]): void;
562
- addDelegate(...agents: AllDelegateInputInterface[]): void;
563
- }
564
- interface ExternalAgentInterface {
565
- config: ExternalAgentConfig;
566
- type: 'external';
567
- init(): Promise<void>;
568
- getId(): string;
569
- getName(): string;
570
- getDescription(): string;
571
- getBaseUrl(): string;
572
- setContext?(tenantId: string, projectId: string): void;
573
- with(options: {
574
- headers?: Record<string, string>;
575
- }): subAgentExternalAgentInterface;
576
- getCredentialReferenceId(): string | undefined;
577
- getCredentialReference(): CredentialReferenceApiInsert | undefined;
578
- }
579
- type subAgentExternalAgentInterface = {
580
- externalAgent: ExternalAgentInterface;
581
- headers?: Record<string, string>;
582
- };
583
- type subAgentTeamAgentInterface = {
584
- agent: AgentInterface;
585
- headers?: Record<string, string>;
586
- };
587
- interface AgentInterface {
588
- init(): Promise<void>;
589
- setConfig(tenantId: string, projectId: string, apiUrl: string): void;
590
- getId(): string;
591
- getName(): string;
592
- getDescription(): string | undefined;
593
- getTenantId(): string;
594
- generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
595
- stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
596
- generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
597
- getDefaultSubAgent(): SubAgentInterface | undefined;
598
- getSubAgent(name: string): SubAgentInterface | undefined;
599
- getSubAgents(): SubAgentInterface[];
600
- toFullAgentDefinition(): Promise<FullAgentDefinition>;
601
- with(options: {
602
- headers?: Record<string, string>;
603
- }): subAgentTeamAgentInterface;
604
- }
605
- interface BuilderToolConfig {
606
- name: string;
607
- description: string;
608
- config: {
609
- type: 'mcp';
610
- mcp: {
611
- server: {
612
- url: string;
613
- };
614
- };
615
- };
616
- parameters?: Record<string, any>;
617
- }
618
- interface BuilderRelationConfig {
619
- targetAgent: string;
620
- relationType: 'transfer' | 'delegate';
621
- }
622
- interface BuilderAgentConfig {
623
- name: string;
624
- description: string;
625
- instructions: string;
626
- tools: BuilderToolConfig[];
627
- relations?: BuilderRelationConfig[];
628
- }
629
- //#endregion
630
- //#region src/agent.d.ts
631
- declare class Agent implements AgentInterface {
632
- private subAgents;
633
- private agentMap;
634
- private defaultSubAgent?;
635
- private baseURL;
636
- private tenantId;
637
- private projectId;
638
- private agentId;
639
- private agentName;
640
- private agentDescription?;
641
- private initialized;
642
- private contextConfig?;
643
- private credentials?;
644
- private models?;
645
- private statusUpdateSettings?;
646
- private prompt?;
647
- private stopWhen?;
648
- constructor(config: AgentConfig);
649
- /**
650
- * Set or update the configuration (tenantId, projectId and apiUrl)
651
- * This is used by the CLI to inject configuration from inkeep.config.ts
652
- */
653
- setConfig(tenantId: string, projectId: string, apiUrl: string): void;
654
- /**
655
- * Convert the Agent to FullAgentDefinition format for the new agent endpoint
656
- */
657
- toFullAgentDefinition(): Promise<FullAgentDefinition>;
658
- /**
659
- * Initialize all tools in all agents (especially IPCTools that need MCP server URLs)
660
- */
661
- private initializeAllTools;
662
- /**
663
- * Initialize the agent and all agents in the backend using the new agent endpoint
664
- */
665
- init(): Promise<void>;
666
- /**
667
- * Generate a response using the default agent
668
- */
669
- generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
670
- /**
671
- * Stream a response using the default agent
672
- */
673
- stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
674
- /**
675
- * Alias for stream() method for consistency with naming patterns
676
- */
677
- generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
678
- /**
679
- * Run with a specific agent from the agent
680
- */
681
- runWith(subAgentId: string, input: MessageInput, options?: GenerateOptions): Promise<RunResult>;
682
- /**
683
- * Get an agent by name (unified method for all agent types)
684
- */
685
- getSubAgent(name: string): SubAgentInterface | undefined;
686
- /**
687
- * Add an agent to the agent
688
- */
689
- addSubAgent(agent: SubAgentInterface): void;
690
- /**
691
- * Remove an agent from the agent
692
- */
693
- removeSubAgent(id: string): boolean;
694
- /**
695
- * Get all agents in the agent
696
- */
697
- getSubAgents(): SubAgentInterface[];
698
- /**
699
- * Get all agent ids (unified method for all agent types)
700
- */
701
- getSubAgentIds(): string[];
702
- /**
703
- * Set the default agent
704
- */
705
- setDefaultSubAgent(agent: SubAgentInterface): void;
706
- /**
707
- * Get the default agent
708
- */
709
- getDefaultSubAgent(): SubAgentInterface | undefined;
710
- /**
711
- * Get the agent ID
712
- */
713
- getId(): string;
714
- getName(): string;
715
- getDescription(): string | undefined;
716
- getTenantId(): string;
717
- /**
718
- * Get the agent's model settingsuration
719
- */
720
- getModels(): typeof this.models;
721
- /**
722
- * Set the agent's model settingsuration
723
- */
724
- setModels(models: typeof this.models): void;
725
- /**
726
- * Get the agent's prompt configuration
727
- */
728
- getPrompt(): string | undefined;
729
- /**
730
- * Get the agent's stopWhen configuration
731
- */
732
- getStopWhen(): AgentStopWhen;
733
- /**
734
- * Get the agent's status updates configuration
735
- */
736
- getStatusUpdateSettings(): StatusUpdateSettings | undefined;
737
- /**
738
- * Get the summarizer model from the agent's model settings
739
- */
740
- getSummarizerModel(): ModelSettings | undefined;
741
- /**
742
- * Get agent statistics
743
- */
744
- getStats(): {
745
- agentCount: number;
746
- defaultSubAgent: string | null;
747
- initialized: boolean;
748
- agentId: string;
749
- tenantId: string;
750
- };
751
- with(options: {
752
- headers?: Record<string, string>;
753
- }): subAgentTeamAgentInterface;
754
- /**
755
- * Validate the agent configuration
756
- */
757
- validate(): {
758
- valid: boolean;
759
- errors: string[];
760
- };
761
- private _init;
762
- /**
763
- * Type guard to check if an agent is an internal AgentInterface
764
- */
765
- isInternalAgent(agent: AllDelegateInputInterface): agent is SubAgentInterface;
766
- /**
767
- * Get project-level model settingsuration defaults
768
- */
769
- private getProjectModelDefaults;
770
- /**
771
- * Get project-level stopWhen configuration defaults
772
- */
773
- private getProjectStopWhenDefaults;
774
- /**
775
- * Apply model inheritance hierarchy: Project -> Agent -> Agent
776
- */
777
- private applyModelInheritance;
778
- /**
779
- * Apply stopWhen inheritance hierarchy: Project -> Agent -> Agent
780
- */
781
- private applyStopWhenInheritance;
782
- /**
783
- * Propagate agent-level model settings to agents (supporting partial inheritance)
784
- */
785
- private propagateModelSettingsToAgent;
786
- /**
787
- * Immediately propagate agent-level models to all agents during construction
788
- */
789
- private propagateImmediateModelSettings;
790
- /**
791
- * Execute agent using the backend system instead of local runner
792
- */
793
- private executeWithBackend;
794
- /**
795
- * Parse streaming response in SSE format
796
- */
797
- private parseStreamingResponse;
798
- /**
799
- * Normalize input messages to the expected format
800
- */
801
- private normalizeMessages;
802
- }
803
- //#endregion
804
- //#region src/project.d.ts
805
- /**
806
- * Project configuration interface for the SDK
807
- */
808
- interface ProjectConfig {
809
- id: string;
810
- name: string;
811
- description?: string;
812
- models?: {
813
- base?: ModelSettings;
814
- structuredOutput?: ModelSettings;
815
- summarizer?: ModelSettings;
816
- };
817
- stopWhen?: StopWhen;
818
- agents?: () => Agent[];
819
- tools?: () => Tool[];
820
- externalAgents?: () => ExternalAgent[];
821
- dataComponents?: () => DataComponent[];
822
- artifactComponents?: () => ArtifactComponent[];
823
- credentialReferences?: () => CredentialReferenceApiInsert[];
824
- }
825
- /**
826
- * Project interface for operations
827
- */
828
- interface ProjectInterface {
829
- init(): Promise<void>;
830
- setConfig(tenantId: string, apiUrl: string): void;
831
- getId(): string;
832
- getName(): string;
833
- getDescription(): string | undefined;
834
- getTenantId(): string;
835
- getModels(): ProjectConfig['models'];
836
- getStopWhen(): ProjectConfig['stopWhen'];
837
- getAgents(): Agent[];
838
- addAgent(agent: Agent): void;
839
- removeAgent(id: string): boolean;
840
- getStats(): {
841
- projectId: string;
842
- tenantId: string;
843
- agentCount: number;
844
- initialized: boolean;
845
- };
846
- validate(): {
847
- valid: boolean;
848
- errors: string[];
849
- };
850
- }
851
- /**
852
- * Project class for managing agent projects
853
- *
854
- * Projects are the top-level organizational unit that contains Agents, Sub Agents, and shared configurations.
855
- * They provide model inheritance and execution limits that cascade down to Agents and Sub Agents.
856
- *
857
- * @example
858
- * ```typescript
859
- * const myProject = new Project({
860
- * id: 'customer-support-project',
861
- * name: 'Customer Support System',
862
- * description: 'Multi-agent customer support system',
863
- * models: {
864
- * base: { model: 'gpt-4.1-mini' },
865
- * structuredOutput: { model: 'gpt-4.1' }
866
- * },
867
- * stopWhen: {
868
- * transferCountIs: 10,
869
- * stepCountIs: 50
870
- * }
871
- * });
872
- *
873
- * await myProject.init();
874
- * ```
875
- */
876
- declare class Project implements ProjectInterface {
877
- readonly __type: "project";
878
- private projectId;
879
- private projectName;
880
- private projectDescription?;
881
- private tenantId;
882
- private baseURL;
883
- private apiKey?;
884
- private initialized;
885
- private models?;
886
- private stopWhen?;
887
- private agents;
888
- private agentMap;
889
- private credentialReferences?;
890
- private projectTools;
891
- private projectDataComponents;
892
- private projectArtifactComponents;
893
- private projectExternalAgents;
894
- private externalAgentMap;
895
- constructor(config: ProjectConfig);
896
- /**
897
- * Set or update the configuration (tenantId and apiUrl)
898
- * This is used by the CLI to inject configuration from inkeep.config.ts
899
- */
900
- setConfig(tenantId: string, apiUrl: string, models?: ProjectConfig['models'], apiKey?: string): void;
901
- /**
902
- * Set credential references for the project
903
- * This is used by the CLI to inject environment-specific credentials
904
- */
905
- setCredentials(credentials: Record<string, CredentialReferenceApiInsert>): void;
906
- /**
907
- * Initialize the project and create/update it in the backend using full project approach
908
- */
909
- init(): Promise<void>;
910
- /**
911
- * Get the project ID
912
- */
913
- getId(): string;
914
- /**
915
- * Get the project name
916
- */
917
- getName(): string;
918
- /**
919
- * Get the project description
920
- */
921
- getDescription(): string | undefined;
922
- /**
923
- * Get the tenant ID
924
- */
925
- getTenantId(): string;
926
- /**
927
- * Get the project's model configuration
928
- */
929
- getModels(): ProjectConfig['models'];
930
- /**
931
- * Set the project's model configuration
932
- */
933
- setModels(models: ProjectConfig['models']): void;
934
- /**
935
- * Get the project's stopWhen configuration
936
- */
937
- getStopWhen(): ProjectConfig['stopWhen'];
938
- /**
939
- * Set the project's stopWhen configuration
940
- */
941
- setStopWhen(stopWhen: ProjectConfig['stopWhen']): void;
942
- /**
943
- * Get credential tracking information
944
- */
945
- getCredentialTracking(): Promise<{
946
- credentials: Record<string, any>;
947
- usage: Record<string, Array<{
948
- type: string;
949
- id: string;
950
- agentId?: string;
951
- }>>;
952
- }>;
953
- getFullDefinition(): Promise<FullProjectDefinition>;
954
- /**
955
- * Get all agent in the project
956
- */
957
- getAgents(): Agent[];
958
- /**
959
- * Get all external agents in the project
960
- */
961
- getExternalAgents(): ExternalAgent[];
962
- /**
963
- * Get an external agent by ID
964
- */
965
- getExternalAgent(id: string): ExternalAgent | undefined;
966
- /**
967
- * Add an external agent to the project
968
- */
969
- addExternalAgent(externalAgent: ExternalAgent): void;
970
- /**
971
- * Remove an external agent from the project
972
- */
973
- removeExternalAgent(id: string): boolean;
974
- /**
975
- * Get an agent by ID
976
- */
977
- getAgent(id: string): Agent | undefined;
978
- /**
979
- * Add an agent to the project
980
- */
981
- addAgent(agent: Agent): void;
982
- /**
983
- * Remove an agent from the project
984
- */
985
- removeAgent(id: string): boolean;
986
- /**
987
- * Get project statistics
988
- */
989
- getStats(): {
990
- projectId: string;
991
- tenantId: string;
992
- agentCount: number;
993
- initialized: boolean;
994
- };
995
- /**
996
- * Validate the project configuration
997
- */
998
- validate(): {
999
- valid: boolean;
1000
- errors: string[];
1001
- };
1002
- /**
1003
- * Convert the Project to FullProjectDefinition format
1004
- */
1005
- private toFullProjectDefinition;
1006
- }
1007
- //#endregion
1008
- //#region src/status-component.d.ts
1009
- type StatusComponentConfigWithZod = Omit<StatusComponent$1, 'detailsSchema'> & {
1010
- detailsSchema?: Record<string, unknown> | z.ZodObject<any>;
1011
- };
1012
- interface StatusComponentInterface {
1013
- config: StatusComponent$1;
1014
- getType(): string;
1015
- getDescription(): string | undefined;
1016
- getDetailsSchema(): StatusComponent$1['detailsSchema'];
1017
- }
1018
- declare class StatusComponent implements StatusComponentInterface {
1019
- config: StatusComponent$1;
1020
- constructor(config: StatusComponentConfigWithZod);
1021
- getType(): string;
1022
- getDescription(): string | undefined;
1023
- getDetailsSchema(): StatusComponent$1['detailsSchema'];
1024
- }
1025
- //#endregion
1026
- //#region src/builderFunctions.d.ts
1027
- /**
1028
- * Helper function to create agent - OpenAI style
1029
- */
1030
- declare function agent(config: AgentConfig): Agent;
1031
- /**
1032
- * Helper function to create projects - OpenAI style
1033
- *
1034
- * Projects are the top-level organizational unit that contains Agents, Sub Agents, and shared configurations.
1035
- * They provide model inheritance and execution limits that cascade down to Agents and Sub Agents.
1036
- *
1037
- * @param config - Project configuration
1038
- * @returns A new Project instance
1039
- *
1040
- * @example
1041
- * ```typescript
1042
- * const customerSupport = project({
1043
- * id: 'customer-support-project',
1044
- * name: 'Customer Support System',
1045
- * description: 'Multi-agent customer support system',
1046
- * models: {
1047
- * base: { model: 'gpt-4.1-mini' },
1048
- * structuredOutput: { model: 'gpt-4.1' }
1049
- * },
1050
- * stopWhen: {
1051
- * transferCountIs: 10,
1052
- * stepCountIs: 50
1053
- * },
1054
- * agent: () => [
1055
- * agent({
1056
- * id: 'support-agent',
1057
- * name: 'Support Agent',
1058
- * // ... agent config
1059
- * })
1060
- * ]
1061
- * });
1062
- * ```
1063
- */
1064
- declare function project(config: ProjectConfig): Project;
1065
- /**
1066
- * Creates a new agent with stable ID enforcement.
1067
- *
1068
- * Agents require explicit stable IDs to ensure consistency across deployments.
1069
- * This is different from tools which auto-generate IDs from their names.
1070
- *
1071
- * @param config - Agent configuration including required stable ID
1072
- * @returns A new SubAgent instance
1073
- * @throws {Error} If config.id is not provided
1074
- *
1075
- * @example
1076
- * ```typescript
1077
- * const myAgent = agent({
1078
- * id: 'customer-support-agent',
1079
- * name: 'Customer Support',
1080
- * prompt: 'Help customers with their questions'
1081
- * });
1082
- * ```
1083
- */
1084
- declare function subAgent(config: SubAgentConfig): SubAgent;
1085
- /**
1086
- * Creates a credential reference for authentication.
1087
- *
1088
- * Credentials are used to authenticate with external services.
1089
- * They should be stored securely and referenced by ID.
1090
- *
1091
- * @param config - Credential configuration
1092
- * @returns A validated credential reference
1093
- *
1094
- * @example
1095
- * ```typescript
1096
- * const apiCredential = credential({
1097
- * id: 'github-token',
1098
- * name: 'GitHub Token',
1099
- * type: 'bearer',
1100
- * value: process.env.GITHUB_TOKEN
1101
- * });
1102
- * ```
1103
- */
1104
- declare function credential(config: CredentialReferenceApiInsert): {
1105
- id: string;
1106
- name: string;
1107
- credentialStoreId: string;
1108
- type: "memory" | "keychain" | "nango";
1109
- retrievalParams?: Record<string, unknown> | null | undefined;
1110
- toolId?: string | null | undefined;
1111
- userId?: string | null | undefined;
1112
- createdBy?: string | null | undefined;
1113
- createdAt?: string | undefined;
1114
- updatedAt?: string | undefined;
1115
- };
1116
- /**
1117
- * Creates an MCP (Model Context Protocol) server for tool functionality.
1118
- *
1119
- * MCP servers provide tool functionality through a standardized protocol.
1120
- * They can be remote services accessed via HTTP/WebSocket.
1121
- *
1122
- * @param config - MCP server configuration
1123
- * @returns A Tool instance configured as an MCP server
1124
- * @throws {Error} If serverUrl is not provided
1125
- *
1126
- * @example
1127
- * ```typescript
1128
- * // Remote MCP server
1129
- * const apiServer = mcpServer({
1130
- * name: 'external_api',
1131
- * description: 'External API service',
1132
- * serverUrl: 'https://api.example.com/mcp'
1133
- * });
1134
- *
1135
- * // With authentication
1136
- * const secureServer = mcpServer({
1137
- * name: 'secure_api',
1138
- * description: 'Secure API service',
1139
- * serverUrl: 'https://secure.example.com/mcp',
1140
- * credential: credential({
1141
- * id: 'api-key',
1142
- * name: 'API Key',
1143
- * type: 'bearer',
1144
- * value: process.env.API_KEY
1145
- * })
1146
- * });
1147
- * ```
1148
- */
1149
- declare function mcpServer(config: MCPServerConfig): Tool;
1150
- /**
1151
- * Creates an MCP tool from a raw configuration object.
1152
- *
1153
- * This is a low-level builder for advanced use cases where you need
1154
- * full control over the MCPToolConfig. For most cases, use `mcpServer()`.
1155
- *
1156
- * @param config - Complete MCP tool configuration
1157
- * @returns A Tool instance
1158
- *
1159
- * @example
1160
- * ```typescript
1161
- * const customTool = mcpTool({
1162
- * id: 'custom-tool',
1163
- * name: 'Custom Tool',
1164
- * serverUrl: 'https://example.com/mcp',
1165
- * transport: { type: 'stdio' }
1166
- * });
1167
- * ```
1168
- */
1169
- declare function mcpTool(config: MCPToolConfig$1): Tool;
1170
- /**
1171
- * Creates an artifact component with automatic ID generation.
1172
- *
1173
- * Artifact components represent structured UI components that can
1174
- * be rendered with different levels of detail (summary vs full).
1175
- *
1176
- * @param config - Artifact component configuration
1177
- * @returns An ArtifactComponent instance
1178
- *
1179
- * @example
1180
- * ```typescript
1181
- * const productCard = artifactComponent({
1182
- * name: 'Product Card',
1183
- * description: 'Display product information',
1184
- * props: {
1185
- * type: 'object',
1186
- * properties: {
1187
- * title: { type: 'string', inPreview: true },
1188
- * price: { type: 'string', inPreview: true },
1189
- * description: { type: 'string' },
1190
- * image: { type: 'string' }
1191
- * }
1192
- * }
1193
- * });
1194
- * ```
1195
- */
1196
- declare function artifactComponent(config: ArtifactComponentConfig): ArtifactComponent;
1197
- /**
1198
- * Creates a data component with automatic ID generation.
1199
- *
1200
- * Data components represent structured data that can be
1201
- * passed between agents or used in processing.
1202
- *
1203
- * @param config - Data component configuration
1204
- * @returns A DataComponent instance
1205
- *
1206
- * @example
1207
- * ```typescript
1208
- * const userProfile = dataComponent({
1209
- * name: 'User Profile',
1210
- * description: 'User profile data',
1211
- * props: {
1212
- * userId: '123',
1213
- * name: 'John Doe',
1214
- * email: 'john@example.com'
1215
- * }
1216
- * });
1217
- * ```
1218
- */
1219
- declare function dataComponent(config: DataComponentConfig): DataComponent;
1220
- /**
1221
- * Creates a status component for structured status updates.
1222
- *
1223
- * Status components define the structure of status updates
1224
- * that agents can generate during long-running operations.
1225
- *
1226
- * @param config - Status component configuration
1227
- * @returns A StatusComponent instance
1228
- *
1229
- * @example
1230
- * ```typescript
1231
- * import { z } from 'zod';
1232
- *
1233
- * const toolCallStatus = statusComponent({
1234
- * type: 'tool_call_summary',
1235
- * description: 'Summary of a tool execution',
1236
- * detailsSchema: z.object({
1237
- * tool_name: z.string(),
1238
- * summary: z.string(),
1239
- * status: z.enum(['success', 'error', 'in_progress'])
1240
- * })
1241
- * });
1242
- * ```
1243
- */
1244
- declare function statusComponent(config: StatusComponentConfig): StatusComponent;
1245
- /**
1246
- * (deprecated in favor of mcpTool.with()) Creates an agent MCP configuration.
1247
- *
1248
- * Agent MCP configurations are used to configure the MCP server for an agent.
1249
- *
1250
- * @param config - Agent MCP configuration
1251
- * @returns An AgentMcpConfig instance
1252
- */
1253
- declare function agentMcp(config: AgentMcpConfig): AgentMcpConfig;
1254
- /**
1255
- * Creates a function tool that executes user-defined code in a sandboxed environment.
1256
- *
1257
- * Function tools allow users to define custom logic that runs securely in isolated
1258
- * environments. Dependencies are installed automatically in the sandbox.
1259
- *
1260
- * @param config - Function tool configuration
1261
- * @returns A FunctionTool instance
1262
- *
1263
- * @example
1264
- * ```typescript
1265
- * const calculatorTool = functionTool({
1266
- * name: 'calculator',
1267
- * description: 'Performs basic math operations',
1268
- * inputSchema: {
1269
- * type: 'object',
1270
- * properties: {
1271
- * operation: { type: 'string', enum: ['add', 'subtract', 'multiply', 'divide'] },
1272
- * a: { type: 'number' },
1273
- * b: { type: 'number' }
1274
- * },
1275
- * required: ['operation', 'a', 'b']
1276
- * },
1277
- * dependencies: {
1278
- * 'lodash': '^4.17.21'
1279
- * },
1280
- * execute: async (params) => {
1281
- * const { operation, a, b } = params;
1282
- * switch (operation) {
1283
- * case 'add': return { result: a + b };
1284
- * case 'subtract': return { result: a - b };
1285
- * case 'multiply': return { result: a * b };
1286
- * case 'divide': return { result: a / b };
1287
- * default: throw new Error(`Unknown operation: ${operation}`);
1288
- * }
1289
- * }
1290
- * });
1291
- * ```
1292
- */
1293
- declare function functionTool(config: FunctionToolConfig): FunctionTool;
1294
- //#endregion
1295
- //#region src/credential-provider.d.ts
1296
- /**
1297
- * InkeepCredentialProvider - Abstraction for Credential Management
1298
- *
1299
- * This module provides a clean abstraction over credential provider implementations.
1300
- * Cloud customers can use this without needing to know about or install internal
1301
- * dependencies like Nango.
1302
- *
1303
- * @example
1304
- * ```typescript
1305
- * // Simple usage with environment variables (default)
1306
- * import { InkeepCredentialProvider } from '@inkeep/agents-sdk'
1307
- *
1308
- * const credentials = new InkeepCredentialProvider()
1309
- *
1310
- * // With custom configuration
1311
- * const credentials = new InkeepCredentialProvider({
1312
- * type: 'memory',
1313
- * id: 'my-store'
1314
- * })
1315
- * ```
1316
- */
1317
- /**
1318
- * Base interface for all credential stores
1319
- * This is a simplified version for SDK customers
1320
- */
1321
- interface CredentialStore {
1322
- /** Unique identifier for this credential store */
1323
- readonly id: string;
1324
- /** Type of credential store */
1325
- readonly type: CredentialProviderType;
1326
- /** Get a credential by key */
1327
- get(key: string): Promise<string | null>;
1328
- /** Set a credential */
1329
- set(key: string, value: string, metadata?: Record<string, string>): Promise<void>;
1330
- /** Check if a credential exists */
1331
- has(key: string): Promise<boolean>;
1332
- /** Delete a credential */
1333
- delete(key: string): Promise<boolean>;
1334
- /** Check if the credential store is available */
1335
- checkAvailability(): Promise<{
1336
- available: boolean;
1337
- reason?: string;
1338
- }>;
1339
- }
1340
- /**
1341
- * Supported credential provider types
1342
- */
1343
- type CredentialProviderType = 'memory' | 'keychain' | 'nango' | 'custom';
1344
- /**
1345
- * Configuration for memory-based credential storage
1346
- */
1347
- interface MemoryCredentialConfig {
1348
- type: 'memory';
1349
- /** Optional store ID (defaults to 'memory-default') */
1350
- id?: string;
1351
- }
1352
- /**
1353
- * Configuration for keychain-based credential storage
1354
- */
1355
- interface KeychainCredentialConfig {
1356
- type: 'keychain';
1357
- /** Optional store ID (defaults to 'keychain-default') */
1358
- id?: string;
1359
- /** Optional service name for keychain entries */
1360
- serviceName?: string;
1361
- }
1362
- /**
1363
- * Configuration for Nango-based credential storage (OAuth management)
1364
- * Note: Using Nango requires the @nangohq/node package to be installed
1365
- */
1366
- interface NangoCredentialConfig {
1367
- type: 'nango';
1368
- /** Optional store ID (defaults to 'nango-default') */
1369
- id?: string;
1370
- /** Nango secret key (defaults to NANGO_SECRET_KEY env var) */
1371
- secretKey?: string;
1372
- /** Nango API URL (defaults to https://api.nango.dev) */
1373
- apiUrl?: string;
1374
- }
1375
- /**
1376
- * Configuration for custom credential provider
1377
- */
1378
- interface CustomCredentialConfig {
1379
- type: 'custom';
1380
- /** Custom credential store implementation */
1381
- store: CredentialStore;
1382
- }
1383
- /**
1384
- * Union type for all credential provider configurations
1385
- */
1386
- type CredentialProviderConfig = MemoryCredentialConfig | KeychainCredentialConfig | NangoCredentialConfig | CustomCredentialConfig;
1387
- /**
1388
- * InkeepCredentialProvider - Unified credential management for Inkeep SDK
1389
- *
1390
- * Provides a clean abstraction over various credential storage backends.
1391
- * Cloud customers can use simple memory-based storage, while advanced
1392
- * users can integrate with OAuth providers like Nango.
1393
- *
1394
- * @example
1395
- * ```typescript
1396
- * // Default memory-based storage
1397
- * const provider = new InkeepCredentialProvider()
1398
- *
1399
- * // Store and retrieve credentials
1400
- * await provider.set('my-api-key', 'secret-value')
1401
- * const key = await provider.get('my-api-key')
1402
- *
1403
- * // Use environment variables automatically
1404
- * process.env.MY_TOKEN = 'env-token'
1405
- * const token = await provider.get('MY_TOKEN') // Returns 'env-token'
1406
- * ```
1407
- */
1408
- declare class InkeepCredentialProvider implements CredentialStore {
1409
- private store;
1410
- constructor(config?: CredentialProviderConfig);
1411
- /**
1412
- * Create the appropriate store based on configuration
1413
- */
1414
- private createStore;
1415
- /**
1416
- * Create keychain store with dynamic import
1417
- */
1418
- private createKeychainStore;
1419
- /**
1420
- * Create Nango store with dynamic import
1421
- */
1422
- private createNangoStore;
1423
- get id(): string;
1424
- get type(): CredentialProviderType;
1425
- /**
1426
- * Get a credential by key
1427
- * @param key - The credential key
1428
- * @returns The credential value or null if not found
1429
- */
1430
- get(key: string): Promise<string | null>;
1431
- /**
1432
- * Set a credential
1433
- * @param key - The credential key
1434
- * @param value - The credential value
1435
- * @param metadata - Optional metadata
1436
- */
1437
- set(key: string, value: string, metadata?: Record<string, string>): Promise<void>;
1438
- /**
1439
- * Check if a credential exists
1440
- * @param key - The credential key
1441
- * @returns True if the credential exists
1442
- */
1443
- has(key: string): Promise<boolean>;
1444
- /**
1445
- * Delete a credential
1446
- * @param key - The credential key
1447
- * @returns True if the credential was deleted
1448
- */
1449
- delete(key: string): Promise<boolean>;
1450
- /**
1451
- * Check if the credential store is available and functional
1452
- * @returns Availability status
1453
- */
1454
- checkAvailability(): Promise<{
1455
- available: boolean;
1456
- reason?: string;
1457
- }>;
1458
- /**
1459
- * Get the underlying store (for advanced use cases)
1460
- */
1461
- getStore(): CredentialStore;
1462
- }
1463
- /**
1464
- * Factory function to create an InkeepCredentialProvider
1465
- * @param config - Configuration options
1466
- * @returns A new InkeepCredentialProvider instance
1467
- */
1468
- declare function createCredentialProvider(config?: CredentialProviderConfig): InkeepCredentialProvider;
1469
- //#endregion
1470
- //#region src/credential-ref.d.ts
1471
- /**
1472
- * Credential Reference System
1473
- *
1474
- * This module provides a way to reference credentials by ID without including
1475
- * the full credential definition in the code. Credentials are resolved from
1476
- * environment files at runtime during the push operation.
1477
- */
1478
- /**
1479
- * Represents a reference to a credential by its ID.
1480
- * The actual credential will be resolved from the environment file at push time.
1481
- */
1482
- interface CredentialReference {
1483
- __type: 'credential-ref';
1484
- id: string;
1485
- }
1486
- /**
1487
- * Create a reference to a credential by its ID.
1488
- * The credential must be defined in the environment files.
1489
- *
1490
- * @param id - The ID of the credential to reference
1491
- * @returns A credential reference that will be resolved at push time
1492
- *
1493
- * @example
1494
- * ```typescript
1495
- * const apiKeyRef = credentialRef('api-key');
1496
- *
1497
- * const fetchDef = fetchDefinition({
1498
- * credential: apiKeyRef,
1499
- * // ...
1500
- * });
1501
- * ```
1502
- */
1503
- declare function credentialRef<T extends string = string>(id: T): CredentialReference;
1504
- /**
1505
- * Type guard to check if a value is a credential reference
1506
- */
1507
- declare function isCredentialReference(value: any): value is CredentialReference;
1508
- /**
1509
- * Type helper to extract credential IDs from environment configuration
1510
- */
1511
- type ExtractCredentialIds<T> = T extends {
1512
- credentials?: infer C;
1513
- } ? C extends Record<string, any> ? keyof C : never : never;
1514
- /**
1515
- * Type helper to create a union of all available credential IDs from multiple environments
1516
- */
1517
- type UnionCredentialIds<T extends Record<string, any>> = { [K in keyof T]: ExtractCredentialIds<T[K]> }[keyof T];
1518
- /**
1519
- * Type helper to extract tool IDs from environment configuration
1520
- */
1521
- type ExtractMcpServerIds<T> = T extends {
1522
- mcpServers?: infer T;
1523
- } ? T extends Record<string, any> ? keyof T : never : never;
1524
- /**
1525
- * Type helper to create a union of all available tool IDs from multiple environments
1526
- */
1527
- type UnionMcpServerIds<T extends Record<string, any>> = { [K in keyof T]: ExtractMcpServerIds<T[K]> }[keyof T];
1528
- //#endregion
1529
- //#region src/environment-settings.d.ts
1530
- interface EnvironmentSettingsConfig {
1531
- credentials?: {
1532
- [settingId: string]: CredentialReferenceApiInsert;
1533
- };
1534
- mcpServers?: {
1535
- [mcpServerId: string]: Tool;
1536
- };
1537
- }
1538
- /**
1539
- * Create a setting helper with TypeScript autocomplete
1540
- */
1541
- declare function createEnvironmentSettings<T extends Record<string, EnvironmentSettingsConfig>>(environments: T): {
1542
- getEnvironmentCredential: (key: UnionCredentialIds<T>) => CredentialReferenceApiInsert;
1543
- getEnvironmentMcp: (key: UnionMcpServerIds<T>) => Tool;
1544
- getEnvironmentSetting: (key: UnionCredentialIds<T>) => CredentialReferenceApiInsert;
1545
- };
1546
- /**
1547
- * Create type-safe environment configurations
1548
- */
1549
- declare function registerEnvironmentSettings<T extends EnvironmentSettingsConfig>(config: T): T;
1550
- //#endregion
1551
- //#region src/projectFullClient.d.ts
1552
- /**
1553
- * Create a full project via HTTP API
1554
- */
1555
- declare function createFullProjectViaAPI(tenantId: string, apiUrl: string, projectData: FullProjectDefinition, apiKey?: string): Promise<FullProjectDefinition>;
1556
- /**
1557
- * Update a full project via HTTP API (upsert behavior)
1558
- */
1559
- declare function updateFullProjectViaAPI(tenantId: string, apiUrl: string, projectId: string, projectData: FullProjectDefinition, apiKey?: string): Promise<FullProjectDefinition>;
1560
- /**
1561
- * Get a full project via HTTP API
1562
- */
1563
- declare function getFullProjectViaAPI(tenantId: string, apiUrl: string, projectId: string, apiKey?: string): Promise<FullProjectDefinition | null>;
1564
- /**
1565
- * Delete a full project via HTTP API
1566
- */
1567
- declare function deleteFullProjectViaAPI(tenantId: string, apiUrl: string, projectId: string, apiKey?: string): Promise<void>;
1568
- //#endregion
1569
- //#region src/runner.d.ts
1570
- declare class Runner {
1571
- /**
1572
- * Run an agent until completion, handling transfers and tool calls
1573
- * Similar to OpenAI's Runner.run() pattern
1574
- * NOTE: This now requires an agent instead of an agent
1575
- */
1576
- static run(agent: AgentInterface, messages: MessageInput, options?: GenerateOptions): Promise<RunResult>;
1577
- /**
1578
- * Stream an agent's response
1579
- */
1580
- static stream(agent: AgentInterface, messages: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
1581
- /**
1582
- * Execute multiple agent in parallel and return the first successful result
1583
- */
1584
- static raceAgents(agent: AgentInterface[], messages: MessageInput, options?: GenerateOptions): Promise<RunResult>;
1585
- private static normalizeToMessageHistory;
1586
- /**
1587
- * Validate agent configuration before running
1588
- */
1589
- static validateAgent(agent: AgentInterface): {
1590
- valid: boolean;
1591
- errors: string[];
1592
- };
1593
- /**
1594
- * Get execution statistics for an agent
1595
- */
1596
- static getExecutionStats(agent: AgentInterface, messages: MessageInput, options?: GenerateOptions): Promise<{
1597
- estimatedTurns: number;
1598
- estimatedTokens: number;
1599
- subAgentCount: number;
1600
- defaultSubAgent: string | undefined;
1601
- }>;
1602
- }
1603
- declare const run: typeof Runner.run;
1604
- declare const stream: typeof Runner.stream;
1605
- declare const raceAgents: typeof Runner.raceAgents;
1606
- //#endregion
1607
- //#region src/telemetry-provider.d.ts
1608
- /**
1609
- * TelemetryProvider - Abstraction for Telemetry/Observability
1610
- *
1611
- * This module provides a clean abstraction over telemetry implementations.
1612
- * Cloud customers can use this without needing to install or configure
1613
- * OpenTelemetry or Signoz directly.
1614
- *
1615
- * Telemetry is OPT-IN - if not configured, a no-op provider is used.
1616
- *
1617
- * @example
1618
- * ```typescript
1619
- * // Opt-in to telemetry with default console logger
1620
- * import { InkeepTelemetryProvider, createConsoleTelemetryProvider } from '@inkeep/agents-sdk'
1621
- *
1622
- * const telemetry = createConsoleTelemetryProvider()
1623
- *
1624
- * // Or with OpenTelemetry (requires @opentelemetry packages)
1625
- * const telemetry = createOpenTelemetryProvider({
1626
- * serviceName: 'my-agent',
1627
- * endpoint: 'http://localhost:4318'
1628
- * })
1629
- * ```
1630
- */
1631
- /**
1632
- * Span status codes
1633
- */
1634
- declare const SpanStatus: {
1635
- readonly OK: "ok";
1636
- readonly ERROR: "error";
1637
- readonly UNSET: "unset";
1638
- };
1639
- type SpanStatusType = (typeof SpanStatus)[keyof typeof SpanStatus];
1640
- /**
1641
- * Span interface for tracing
1642
- */
1643
- interface TelemetrySpan {
1644
- /** Set span attributes */
1645
- setAttributes(attributes: Record<string, unknown>): TelemetrySpan;
1646
- /** Set a single attribute */
1647
- setAttribute(key: string, value: unknown): TelemetrySpan;
1648
- /** Record an exception */
1649
- recordException(error: Error): TelemetrySpan;
1650
- /** Set span status */
1651
- setStatus(status: SpanStatusType, message?: string): TelemetrySpan;
1652
- /** Add an event to the span */
1653
- addEvent(name: string, attributes?: Record<string, unknown>): TelemetrySpan;
1654
- /** End the span */
1655
- end(): void;
1656
- /** Check if span is recording */
1657
- isRecording(): boolean;
1658
- /** Update span name */
1659
- updateName(name: string): TelemetrySpan;
1660
- }
1661
- /**
1662
- * Span options
1663
- */
1664
- interface SpanOptions {
1665
- /** Span attributes */
1666
- attributes?: Record<string, unknown>;
1667
- /** Parent span (for context propagation) */
1668
- parent?: TelemetrySpan;
1669
- }
1670
- /**
1671
- * Tracer interface for creating spans
1672
- */
1673
- interface TelemetryTracer {
1674
- /** Start a new active span and execute callback */
1675
- startActiveSpan<T>(name: string, fn: (span: TelemetrySpan) => T): T;
1676
- startActiveSpan<T>(name: string, options: SpanOptions, fn: (span: TelemetrySpan) => T): T;
1677
- /** Start a new span without making it active */
1678
- startSpan(name: string, options?: SpanOptions): TelemetrySpan;
1679
- }
1680
- /**
1681
- * Logger interface for structured logging
1682
- */
1683
- interface TelemetryLogger {
1684
- debug(message: string, context?: Record<string, unknown>): void;
1685
- info(message: string, context?: Record<string, unknown>): void;
1686
- warn(message: string, context?: Record<string, unknown>): void;
1687
- error(message: string, context?: Record<string, unknown>): void;
1688
- }
1689
- /**
1690
- * Metrics interface for recording measurements
1691
- */
1692
- interface TelemetryMetrics {
1693
- /** Increment a counter */
1694
- increment(name: string, value?: number, attributes?: Record<string, unknown>): void;
1695
- /** Record a gauge value */
1696
- gauge(name: string, value: number, attributes?: Record<string, unknown>): void;
1697
- /** Record a histogram value */
1698
- histogram(name: string, value: number, attributes?: Record<string, unknown>): void;
1699
- }
1700
- /**
1701
- * Main telemetry provider interface
1702
- */
1703
- interface TelemetryProvider {
1704
- /** Get a tracer for creating spans */
1705
- getTracer(name: string, version?: string): TelemetryTracer;
1706
- /** Get a logger for structured logging */
1707
- getLogger(name: string): TelemetryLogger;
1708
- /** Get metrics for recording measurements */
1709
- getMetrics(name: string): TelemetryMetrics;
1710
- /** Shutdown the telemetry provider */
1711
- shutdown(): Promise<void>;
1712
- /** Check if telemetry is enabled */
1713
- isEnabled(): boolean;
1714
- }
1715
- /**
1716
- * Configuration for telemetry provider
1717
- */
1718
- interface TelemetryConfig {
1719
- /** Whether telemetry is enabled (default: false) */
1720
- enabled?: boolean;
1721
- /** Service name for identifying the source */
1722
- serviceName?: string;
1723
- /** Service version */
1724
- serviceVersion?: string;
1725
- /** Custom provider implementation */
1726
- provider?: TelemetryProvider;
1727
- }
1728
- /**
1729
- * No-op telemetry provider (default)
1730
- */
1731
- declare class NoOpTelemetryProvider implements TelemetryProvider {
1732
- getTracer(_name: string, _version?: string): TelemetryTracer;
1733
- getLogger(_name: string): TelemetryLogger;
1734
- getMetrics(_name: string): TelemetryMetrics;
1735
- shutdown(): Promise<void>;
1736
- isEnabled(): boolean;
1737
- }
1738
- /**
1739
- * Console-based telemetry provider for development/debugging
1740
- */
1741
- declare class ConsoleTelemetryProvider implements TelemetryProvider {
1742
- private serviceName;
1743
- constructor(serviceName?: string);
1744
- getTracer(name: string, _version?: string): TelemetryTracer;
1745
- getLogger(name: string): TelemetryLogger;
1746
- getMetrics(name: string): TelemetryMetrics;
1747
- shutdown(): Promise<void>;
1748
- isEnabled(): boolean;
1749
- }
1750
- /**
1751
- * InkeepTelemetryProvider - Main telemetry management class
1752
- *
1753
- * Provides a unified interface for telemetry across the SDK.
1754
- * Telemetry is OPT-IN - by default, a no-op provider is used.
1755
- */
1756
- declare class InkeepTelemetryProvider {
1757
- private provider;
1758
- constructor(config?: TelemetryConfig);
1759
- /**
1760
- * Get a tracer for creating spans
1761
- */
1762
- getTracer(name: string, version?: string): TelemetryTracer;
1763
- /**
1764
- * Get a logger for structured logging
1765
- */
1766
- getLogger(name: string): TelemetryLogger;
1767
- /**
1768
- * Get metrics recorder
1769
- */
1770
- getMetrics(name: string): TelemetryMetrics;
1771
- /**
1772
- * Check if telemetry is enabled
1773
- */
1774
- isEnabled(): boolean;
1775
- /**
1776
- * Shutdown the provider
1777
- */
1778
- shutdown(): Promise<void>;
1779
- /**
1780
- * Get the underlying provider
1781
- */
1782
- getProvider(): TelemetryProvider;
1783
- /**
1784
- * Set as the global telemetry provider
1785
- */
1786
- setAsGlobal(): void;
1787
- }
1788
- /**
1789
- * Get the global telemetry provider
1790
- */
1791
- declare function getGlobalTelemetryProvider(): TelemetryProvider;
1792
- /**
1793
- * Set the global telemetry provider
1794
- */
1795
- declare function setGlobalTelemetryProvider(provider: TelemetryProvider): void;
1796
- /**
1797
- * Create a no-op telemetry provider (default, does nothing)
1798
- */
1799
- declare function createNoOpTelemetryProvider(): InkeepTelemetryProvider;
1800
- /**
1801
- * Create a console-based telemetry provider for development
1802
- */
1803
- declare function createConsoleTelemetryProvider(serviceName?: string): InkeepTelemetryProvider;
1804
- /**
1805
- * Configuration for OpenTelemetry provider
1806
- */
1807
- interface OpenTelemetryConfig {
1808
- /** Service name */
1809
- serviceName: string;
1810
- /** Service version */
1811
- serviceVersion?: string;
1812
- /** OTLP endpoint URL */
1813
- endpoint?: string;
1814
- /** Additional resource attributes */
1815
- resourceAttributes?: Record<string, string>;
1816
- }
1817
- /**
1818
- * Create an OpenTelemetry-based provider
1819
- *
1820
- * Note: Requires @opentelemetry packages to be installed
1821
- */
1822
- declare function createOpenTelemetryProvider(config: OpenTelemetryConfig): Promise<InkeepTelemetryProvider>;
1823
- //#endregion
1824
- export { ANTHROPIC_MODELS, AgentConfig, AgentError, AgentInterface, AgentResponse, AgentTool, AllDelegateInputInterface, AllDelegateOutputInterface, ArtifactComponent, type ArtifactComponentInterface, ArtifactComponentWithZodProps, AssistantMessage, BuilderAgentConfig, BuilderRelationConfig, BuilderToolConfig, ConsoleTelemetryProvider, type CredentialProviderConfig, type CredentialProviderType, type CredentialReference, type CredentialStore, type CustomCredentialConfig, DataComponent, type DataComponentInterface, DataComponentWithZodProps, ExternalAgent, ExternalAgentInterface, type ExtractCredentialIds, FetchDefinitionConfig, FunctionTool, type FunctionToolConfig, GOOGLE_MODELS, GenerateOptions, InkeepCredentialProvider, InkeepTelemetryProvider, type KeychainCredentialConfig, MCPToolConfig, MaxTurnsExceededError, type MemoryCredentialConfig, Message, MessageInput, type ModelSettings, type NangoCredentialConfig, NoOpTelemetryProvider, OPENAI_MODELS, type OpenTelemetryConfig, Project, RequestSchemaConfig, RequestSchemaDefinition, RunResult, Runner, ServerConfig, type SpanOptions, SpanStatus, type SpanStatusType, StatusComponent, type StatusComponentInterface, StreamEvent, StreamResponse, SubAgent, SubAgentCanUseType, SubAgentConfig, SubAgentInterface, SystemMessage, type TelemetryConfig, type TelemetryLogger, type TelemetryMetrics, type TelemetryProvider, type TelemetrySpan, type TelemetryTracer, Tool, ToolCall, ToolConfig, ToolExecutionError, ToolMessage, ToolResult, TransferConfig, TransferError, type UnionCredentialIds, UserMessage, agent, agentMcp, artifactComponent, createConsoleTelemetryProvider, createCredentialProvider, createEnvironmentSettings, createFullProjectViaAPI, createNoOpTelemetryProvider, createOpenTelemetryProvider, credential, credentialRef, dataComponent, deleteFullProjectViaAPI, externalAgent, externalAgents, functionTool, getFullProjectViaAPI, getGlobalTelemetryProvider, isCredentialReference, mcpServer, mcpTool, project, raceAgents, registerEnvironmentSettings, run, setGlobalTelemetryProvider, statusComponent, stream, subAgent, subAgentExternalAgentInterface, subAgentTeamAgentInterface, transfer, updateFullProjectViaAPI };
1825
- //# sourceMappingURL=index.d.cts.map