@inkeep/agents-sdk 0.0.0-dev-20250911192304 → 0.0.0-dev-20250911210702

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,250 @@
1
- import { CredentialReferenceSelect, AgentApiInsert, DataComponentApiInsert, ArtifactComponentApiInsert, AgentConversationHistoryConfig, CredentialReferenceApiInsert, ToolInsert, McpTransportConfig, ArtifactComponentInsert, DataComponentInsert, MCPToolConfig as MCPToolConfig$1, MCPTransportType } from '@inkeep/agents-core';
1
+ import { MCPToolConfig as MCPToolConfig$1, ArtifactComponentInsert, DataComponentInsert, CredentialReferenceApiInsert, CredentialReferenceSelect, AgentApiInsert, DataComponentApiInsert, ArtifactComponentApiInsert, AgentConversationHistoryConfig, ToolInsert, McpTransportConfig } from '@inkeep/agents-core';
2
2
  import { z } from 'zod';
3
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
+ interface ArtifactComponentInterface {
34
+ config: Omit<ArtifactComponentInsert, "id">;
35
+ init(): Promise<void>;
36
+ getId(): ArtifactComponentInsert["id"];
37
+ getName(): ArtifactComponentInsert["name"];
38
+ getDescription(): ArtifactComponentInsert["description"];
39
+ getSummaryProps(): ArtifactComponentInsert["summaryProps"];
40
+ getFullProps(): ArtifactComponentInsert["fullProps"];
41
+ }
42
+ declare class ArtifactComponent implements ArtifactComponentInterface {
43
+ config: ArtifactComponentInsert;
44
+ private baseURL;
45
+ private tenantId;
46
+ private projectId;
47
+ private initialized;
48
+ private id;
49
+ constructor(config: Omit<ArtifactComponentInsert, "id">);
50
+ getId(): string;
51
+ getName(): string;
52
+ getDescription(): string;
53
+ getSummaryProps(): ArtifactComponentInsert["summaryProps"];
54
+ getFullProps(): ArtifactComponentInsert["fullProps"];
55
+ init(): Promise<void>;
56
+ private upsertArtifactComponent;
57
+ }
58
+
59
+ interface DataComponentInterface {
60
+ config: Omit<DataComponentInsert, "id">;
61
+ init(): Promise<void>;
62
+ getId(): DataComponentInsert["id"];
63
+ getName(): DataComponentInsert["name"];
64
+ getDescription(): DataComponentInsert["description"];
65
+ getProps(): DataComponentInsert["props"];
66
+ }
67
+ declare class DataComponent implements DataComponentInterface {
68
+ config: DataComponentInsert;
69
+ private baseURL;
70
+ private tenantId;
71
+ private projectId;
72
+ private initialized;
73
+ private id;
74
+ constructor(config: Omit<DataComponentInsert, "id">);
75
+ getId(): string;
76
+ getName(): string;
77
+ getDescription(): string;
78
+ getProps(): DataComponentInsert["props"];
79
+ init(): Promise<void>;
80
+ private upsertDataComponent;
81
+ }
82
+
83
+ /**
84
+ * Function signature for transfer conditions
85
+ */
86
+ type TransferConditionFunction = (context: unknown) => boolean;
87
+ /**
88
+ * Configuration for component builders
89
+ */
90
+ interface ComponentConfig {
91
+ name: string;
92
+ description: string;
93
+ tenantId?: string;
94
+ projectId?: string;
95
+ }
96
+ interface ArtifactComponentConfig extends ComponentConfig {
97
+ summaryProps: Record<string, unknown>;
98
+ fullProps: Record<string, unknown>;
99
+ }
100
+ interface DataComponentConfig extends ComponentConfig {
101
+ props: Record<string, unknown>;
102
+ }
103
+ /**
104
+ * Creates a new agent with stable ID enforcement.
105
+ *
106
+ * Agents require explicit stable IDs to ensure consistency across deployments.
107
+ * This is different from tools which auto-generate IDs from their names.
108
+ *
109
+ * @param config - Agent configuration including required stable ID
110
+ * @returns A new Agent instance
111
+ * @throws {Error} If config.id is not provided
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * const myAgent = agent({
116
+ * id: 'customer-support-agent',
117
+ * name: 'Customer Support',
118
+ * prompt: 'Help customers with their questions'
119
+ * });
120
+ * ```
121
+ */
122
+ declare function agent(config: AgentConfig): Agent;
123
+ /**
124
+ * Creates an MCP tool from a raw configuration object.
125
+ *
126
+ * This is a low-level builder for advanced use cases where you need
127
+ * full control over the MCPToolConfig. For most cases, use `mcpServer()`.
128
+ *
129
+ * @param config - Complete MCP tool configuration
130
+ * @returns A Tool instance
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const customTool = mcpTool({
135
+ * id: 'custom-tool',
136
+ * name: 'Custom Tool',
137
+ * serverUrl: 'https://example.com/mcp',
138
+ * transport: { type: 'stdio' }
139
+ * });
140
+ * ```
141
+ */
142
+ declare function mcpTool(config: MCPToolConfig$1): Tool;
143
+ type AgentMcpConfig = {
144
+ server: Tool;
145
+ selectedTools: string[];
146
+ };
147
+ /**
148
+ * Creates a credential reference for authentication.
149
+ *
150
+ * Credentials are used to authenticate with external services.
151
+ * They should be stored securely and referenced by ID.
152
+ *
153
+ * @param config - Credential configuration
154
+ * @returns A validated credential reference
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const apiCredential = credential({
159
+ * id: 'github-token',
160
+ * type: 'bearer',
161
+ * value: process.env.GITHUB_TOKEN
162
+ * });
163
+ * ```
164
+ */
165
+ declare function credential(config: CredentialReferenceApiInsert): {
166
+ id: string;
167
+ credentialStoreId: string;
168
+ type: "nango" | "memory" | "keychain";
169
+ retrievalParams?: Record<string, unknown> | null | undefined;
170
+ };
171
+ /**
172
+ * Creates a transfer configuration for agent handoffs.
173
+ *
174
+ * Transfers allow one agent to hand off control to another agent
175
+ * based on optional conditions.
176
+ *
177
+ * @param targetAgent - The agent to transfer to
178
+ * @param description - Optional description of when/why to transfer
179
+ * @param condition - Optional function to determine if transfer should occur
180
+ * @returns A validated transfer configuration
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * // Simple transfer
185
+ * const handoff = transfer(supportAgent, 'Transfer to support');
186
+ *
187
+ * // Conditional transfer
188
+ * const conditionalHandoff = transfer(
189
+ * specialistAgent,
190
+ * 'Transfer to specialist for complex issues',
191
+ * (context) => context.complexity > 0.8
192
+ * );
193
+ * ```
194
+ */
195
+ declare function transfer(targetAgent: Agent, description?: string, condition?: TransferConditionFunction): TransferConfig;
196
+ /**
197
+ * Creates an artifact component with automatic ID generation.
198
+ *
199
+ * Artifact components represent structured UI components that can
200
+ * be rendered with different levels of detail (summary vs full).
201
+ *
202
+ * @param config - Artifact component configuration
203
+ * @returns An ArtifactComponent instance
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * const productCard = artifactComponent({
208
+ * name: 'Product Card',
209
+ * description: 'Display product information',
210
+ * summaryProps: {
211
+ * title: 'Product',
212
+ * price: '$0'
213
+ * },
214
+ * fullProps: {
215
+ * title: 'Product',
216
+ * price: '$0',
217
+ * description: 'Product description',
218
+ * image: 'product.jpg'
219
+ * }
220
+ * });
221
+ * ```
222
+ */
223
+ declare function artifactComponent(config: ArtifactComponentConfig): ArtifactComponent;
224
+ /**
225
+ * Creates a data component with automatic ID generation.
226
+ *
227
+ * Data components represent structured data that can be
228
+ * passed between agents or used in processing.
229
+ *
230
+ * @param config - Data component configuration
231
+ * @returns A DataComponent instance
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * const userProfile = dataComponent({
236
+ * name: 'User Profile',
237
+ * description: 'User profile data',
238
+ * props: {
239
+ * userId: '123',
240
+ * name: 'John Doe',
241
+ * email: 'john@example.com'
242
+ * }
243
+ * });
244
+ * ```
245
+ */
246
+ declare function dataComponent(config: DataComponentConfig): DataComponent;
247
+
4
248
  type ExternalAgentConfig = {
5
249
  type?: "external";
6
250
  tenantId?: string;
@@ -87,9 +331,10 @@ interface ToolResult {
87
331
  error?: string;
88
332
  }
89
333
  type AllAgentInterface = AgentInterface | ExternalAgentInterface;
334
+ type AgentCanUseType = Tool | AgentMcpConfig;
90
335
  interface AgentConfig extends Omit<AgentApiInsert, "projectId"> {
91
336
  type?: "internal";
92
- tools?: () => any[];
337
+ canUse?: () => AgentCanUseType[];
93
338
  canTransferTo?: () => AgentInterface[];
94
339
  canDelegateTo?: () => AllAgentInterface[];
95
340
  tenantId?: string;
@@ -354,7 +599,7 @@ declare class Agent implements AgentInterface {
354
599
  getDelegates(): AllAgentInterface[];
355
600
  getDataComponents(): DataComponentApiInsert[];
356
601
  getArtifactComponents(): ArtifactComponentApiInsert[];
357
- addTool(_name: string, tool: unknown): void;
602
+ addTool(_name: string, tool: Tool): void;
358
603
  addTransfer(...agents: AgentInterface[]): void;
359
604
  addDelegate(...agents: AllAgentInterface[]): void;
360
605
  init(): Promise<void>;
@@ -372,295 +617,6 @@ declare class Agent implements AgentInterface {
372
617
  private createAgentToolRelation;
373
618
  }
374
619
 
375
- interface ArtifactComponentInterface {
376
- config: Omit<ArtifactComponentInsert, "id">;
377
- init(): Promise<void>;
378
- getId(): ArtifactComponentInsert["id"];
379
- getName(): ArtifactComponentInsert["name"];
380
- getDescription(): ArtifactComponentInsert["description"];
381
- getSummaryProps(): ArtifactComponentInsert["summaryProps"];
382
- getFullProps(): ArtifactComponentInsert["fullProps"];
383
- }
384
- declare class ArtifactComponent implements ArtifactComponentInterface {
385
- config: ArtifactComponentInsert;
386
- private baseURL;
387
- private tenantId;
388
- private projectId;
389
- private initialized;
390
- private id;
391
- constructor(config: Omit<ArtifactComponentInsert, "id">);
392
- getId(): string;
393
- getName(): string;
394
- getDescription(): string;
395
- getSummaryProps(): ArtifactComponentInsert["summaryProps"];
396
- getFullProps(): ArtifactComponentInsert["fullProps"];
397
- init(): Promise<void>;
398
- private upsertArtifactComponent;
399
- }
400
-
401
- interface DataComponentInterface {
402
- config: Omit<DataComponentInsert, "id">;
403
- init(): Promise<void>;
404
- getId(): DataComponentInsert["id"];
405
- getName(): DataComponentInsert["name"];
406
- getDescription(): DataComponentInsert["description"];
407
- getProps(): DataComponentInsert["props"];
408
- }
409
- declare class DataComponent implements DataComponentInterface {
410
- config: DataComponentInsert;
411
- private baseURL;
412
- private tenantId;
413
- private projectId;
414
- private initialized;
415
- private id;
416
- constructor(config: Omit<DataComponentInsert, "id">);
417
- getId(): string;
418
- getName(): string;
419
- getDescription(): string;
420
- getProps(): DataComponentInsert["props"];
421
- init(): Promise<void>;
422
- private upsertDataComponent;
423
- }
424
-
425
- interface ToolInterface {
426
- config: MCPToolConfig$1;
427
- init(): Promise<void>;
428
- getId(): string;
429
- getName(): string;
430
- getDescription(): string;
431
- getServerUrl(): string;
432
- getActiveTools(): string[] | undefined;
433
- getCredentialReferenceId(): string | null | undefined;
434
- }
435
- declare class Tool implements ToolInterface {
436
- config: MCPToolConfig$1;
437
- private baseURL;
438
- private tenantId;
439
- private initialized;
440
- private projectId;
441
- constructor(config: MCPToolConfig$1);
442
- getId(): string;
443
- getName(): string;
444
- getDescription(): string;
445
- getServerUrl(): string;
446
- getActiveTools(): string[] | undefined;
447
- getCredentialReferenceId(): string | null | undefined;
448
- init(options?: {
449
- skipDatabaseRegistration?: boolean;
450
- }): Promise<void>;
451
- private upsertTool;
452
- }
453
-
454
- /**
455
- * Function signature for transfer conditions
456
- */
457
- type TransferConditionFunction = (context: unknown) => boolean;
458
- /**
459
- * Configuration for MCP server builders
460
- */
461
- interface MCPServerConfig {
462
- name: string;
463
- description: string;
464
- serverUrl: string;
465
- id?: string;
466
- parameters?: Record<string, z.ZodJSONSchema>;
467
- credential?: CredentialReferenceApiInsert;
468
- tenantId?: string;
469
- transport?: keyof typeof MCPTransportType;
470
- activeTools?: string[];
471
- headers?: Record<string, string>;
472
- imageUrl?: string;
473
- }
474
- /**
475
- * Configuration for component builders
476
- */
477
- interface ComponentConfig {
478
- name: string;
479
- description: string;
480
- tenantId?: string;
481
- projectId?: string;
482
- }
483
- interface ArtifactComponentConfig extends ComponentConfig {
484
- summaryProps: Record<string, unknown>;
485
- fullProps: Record<string, unknown>;
486
- }
487
- interface DataComponentConfig extends ComponentConfig {
488
- props: Record<string, unknown>;
489
- }
490
- /**
491
- * Creates a new agent with stable ID enforcement.
492
- *
493
- * Agents require explicit stable IDs to ensure consistency across deployments.
494
- * This is different from tools which auto-generate IDs from their names.
495
- *
496
- * @param config - Agent configuration including required stable ID
497
- * @returns A new Agent instance
498
- * @throws {Error} If config.id is not provided
499
- *
500
- * @example
501
- * ```typescript
502
- * const myAgent = agent({
503
- * id: 'customer-support-agent',
504
- * name: 'Customer Support',
505
- * prompt: 'Help customers with their questions'
506
- * });
507
- * ```
508
- */
509
- declare function agent(config: AgentConfig): Agent;
510
- /**
511
- * Creates an MCP (Model Context Protocol) server for tool functionality.
512
- *
513
- * MCP servers provide tool functionality through a standardized protocol.
514
- * They can be remote services accessed via HTTP/WebSocket.
515
- *
516
- * @param config - MCP server configuration
517
- * @returns A Tool instance configured as an MCP server
518
- * @throws {Error} If serverUrl is not provided
519
- *
520
- * @example
521
- * ```typescript
522
- * // Remote MCP server
523
- * const apiServer = mcpServer({
524
- * name: 'external_api',
525
- * description: 'External API service',
526
- * serverUrl: 'https://api.example.com/mcp'
527
- * });
528
- *
529
- * // With authentication
530
- * const secureServer = mcpServer({
531
- * name: 'secure_api',
532
- * description: 'Secure API service',
533
- * serverUrl: 'https://secure.example.com/mcp',
534
- * credential: credential({
535
- * id: 'api-key',
536
- * type: 'bearer',
537
- * value: process.env.API_KEY
538
- * })
539
- * });
540
- * ```
541
- */
542
- declare function mcpServer(config: MCPServerConfig): Tool;
543
- /**
544
- * Creates an MCP tool from a raw configuration object.
545
- *
546
- * This is a low-level builder for advanced use cases where you need
547
- * full control over the MCPToolConfig. For most cases, use `mcpServer()`.
548
- *
549
- * @param config - Complete MCP tool configuration
550
- * @returns A Tool instance
551
- *
552
- * @example
553
- * ```typescript
554
- * const customTool = mcpTool({
555
- * id: 'custom-tool',
556
- * name: 'Custom Tool',
557
- * serverUrl: 'https://example.com/mcp',
558
- * transport: { type: 'stdio' }
559
- * });
560
- * ```
561
- */
562
- declare function mcpTool(config: MCPToolConfig$1): Tool;
563
- /**
564
- * Creates a credential reference for authentication.
565
- *
566
- * Credentials are used to authenticate with external services.
567
- * They should be stored securely and referenced by ID.
568
- *
569
- * @param config - Credential configuration
570
- * @returns A validated credential reference
571
- *
572
- * @example
573
- * ```typescript
574
- * const apiCredential = credential({
575
- * id: 'github-token',
576
- * type: 'bearer',
577
- * value: process.env.GITHUB_TOKEN
578
- * });
579
- * ```
580
- */
581
- declare function credential(config: CredentialReferenceApiInsert): {
582
- id: string;
583
- credentialStoreId: string;
584
- type: "nango" | "memory" | "keychain";
585
- retrievalParams?: Record<string, unknown> | null | undefined;
586
- };
587
- /**
588
- * Creates a transfer configuration for agent handoffs.
589
- *
590
- * Transfers allow one agent to hand off control to another agent
591
- * based on optional conditions.
592
- *
593
- * @param targetAgent - The agent to transfer to
594
- * @param description - Optional description of when/why to transfer
595
- * @param condition - Optional function to determine if transfer should occur
596
- * @returns A validated transfer configuration
597
- *
598
- * @example
599
- * ```typescript
600
- * // Simple transfer
601
- * const handoff = transfer(supportAgent, 'Transfer to support');
602
- *
603
- * // Conditional transfer
604
- * const conditionalHandoff = transfer(
605
- * specialistAgent,
606
- * 'Transfer to specialist for complex issues',
607
- * (context) => context.complexity > 0.8
608
- * );
609
- * ```
610
- */
611
- declare function transfer(targetAgent: Agent, description?: string, condition?: TransferConditionFunction): TransferConfig;
612
- /**
613
- * Creates an artifact component with automatic ID generation.
614
- *
615
- * Artifact components represent structured UI components that can
616
- * be rendered with different levels of detail (summary vs full).
617
- *
618
- * @param config - Artifact component configuration
619
- * @returns An ArtifactComponent instance
620
- *
621
- * @example
622
- * ```typescript
623
- * const productCard = artifactComponent({
624
- * name: 'Product Card',
625
- * description: 'Display product information',
626
- * summaryProps: {
627
- * title: 'Product',
628
- * price: '$0'
629
- * },
630
- * fullProps: {
631
- * title: 'Product',
632
- * price: '$0',
633
- * description: 'Product description',
634
- * image: 'product.jpg'
635
- * }
636
- * });
637
- * ```
638
- */
639
- declare function artifactComponent(config: ArtifactComponentConfig): ArtifactComponent;
640
- /**
641
- * Creates a data component with automatic ID generation.
642
- *
643
- * Data components represent structured data that can be
644
- * passed between agents or used in processing.
645
- *
646
- * @param config - Data component configuration
647
- * @returns A DataComponent instance
648
- *
649
- * @example
650
- * ```typescript
651
- * const userProfile = dataComponent({
652
- * name: 'User Profile',
653
- * description: 'User profile data',
654
- * props: {
655
- * userId: '123',
656
- * name: 'John Doe',
657
- * email: 'john@example.com'
658
- * }
659
- * });
660
- * ```
661
- */
662
- declare function dataComponent(config: DataComponentConfig): DataComponent;
663
-
664
620
  interface EnvironmentSettingsConfig {
665
621
  credentials?: {
666
622
  [settingId: string]: CredentialReferenceApiInsert;
@@ -913,4 +869,4 @@ declare const run: typeof Runner.run;
913
869
  declare const stream: typeof Runner.stream;
914
870
  declare const raceGraphs: typeof Runner.raceGraphs;
915
871
 
916
- export { Agent, type AgentConfig, AgentError, AgentGraph, type AgentInterface, type AgentResponse, type AllAgentInterface, ArtifactComponent, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, DataComponent, ExternalAgent, type ExternalAgentInterface, type FetchDefinitionConfig, type GenerateOptions, type GraphConfig, type GraphInterface, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, type ModelSettings, ModelSettingsSchema, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, type StatusComponent, type StatusUpdateSettings, type StreamEvent, type StreamResponse, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UserMessage, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, transfer };
872
+ export { Agent, type AgentCanUseType, type AgentConfig, AgentError, AgentGraph, type AgentInterface, type AgentResponse, type AllAgentInterface, ArtifactComponent, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, DataComponent, ExternalAgent, type ExternalAgentInterface, type FetchDefinitionConfig, type GenerateOptions, type GraphConfig, type GraphInterface, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, type ModelSettings, ModelSettingsSchema, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, type StatusComponent, type StatusUpdateSettings, type StreamEvent, type StreamResponse, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UserMessage, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, transfer };