@inkeep/agents-sdk 0.0.0-dev-20250911052037 → 0.0.0-dev-20250911063109

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.cjs CHANGED
@@ -490,11 +490,11 @@ var Agent = class {
490
490
  throw new Error("tools getter must return an array");
491
491
  }
492
492
  const toolRecord = {};
493
- for (const tool2 of tools) {
494
- if (tool2 && typeof tool2 === "object") {
495
- const id = tool2.id || tool2.getId?.() || tool2.name;
493
+ for (const tool of tools) {
494
+ if (tool && typeof tool === "object") {
495
+ const id = tool.id || tool.getId?.() || tool.name;
496
496
  if (id) {
497
- toolRecord[id] = tool2;
497
+ toolRecord[id] = tool;
498
498
  }
499
499
  }
500
500
  }
@@ -518,9 +518,9 @@ var Agent = class {
518
518
  getArtifactComponents() {
519
519
  return resolveGetter(this.config.artifactComponents) || [];
520
520
  }
521
- addTool(_name, tool2) {
521
+ addTool(_name, tool) {
522
522
  const existingTools = this.config.tools ? this.config.tools() : [];
523
- this.config.tools = () => [...existingTools, tool2];
523
+ this.config.tools = () => [...existingTools, tool];
524
524
  }
525
525
  addTransfer(...agents) {
526
526
  if (typeof this.config.canTransferTo === "function") {
@@ -775,7 +775,7 @@ var Agent = class {
775
775
  return;
776
776
  }
777
777
  const { Tool: Tool2 } = await Promise.resolve().then(() => (init_tool(), tool_exports));
778
- let tool2;
778
+ let tool;
779
779
  if (toolConfig instanceof Tool2) {
780
780
  logger4.info(
781
781
  {
@@ -785,8 +785,8 @@ var Agent = class {
785
785
  },
786
786
  "Initializing Tool instance"
787
787
  );
788
- tool2 = toolConfig;
789
- await tool2.init();
788
+ tool = toolConfig;
789
+ await tool.init();
790
790
  } else {
791
791
  logger4.info(
792
792
  {
@@ -796,7 +796,7 @@ var Agent = class {
796
796
  },
797
797
  "Creating Tool from config"
798
798
  );
799
- tool2 = new Tool2({
799
+ tool = new Tool2({
800
800
  id: toolId,
801
801
  tenantId: this.tenantId,
802
802
  name: toolConfig.name || toolId,
@@ -805,13 +805,13 @@ var Agent = class {
805
805
  activeTools: toolConfig.config?.mcp?.activeTools,
806
806
  credential: toolConfig.credential
807
807
  });
808
- await tool2.init();
808
+ await tool.init();
809
809
  }
810
- await this.createAgentToolRelation(tool2.getId());
810
+ await this.createAgentToolRelation(tool.getId());
811
811
  logger4.info(
812
812
  {
813
813
  agentId: this.getId(),
814
- toolId: tool2.getId()
814
+ toolId: tool.getId()
815
815
  },
816
816
  "Tool created and linked to agent"
817
817
  );
@@ -970,89 +970,65 @@ var Agent = class {
970
970
  }
971
971
  };
972
972
  init_tool();
973
- function agent(config) {
974
- return new Agent(config);
975
- }
976
- function credential(config) {
977
- return agentsCore.CredentialReferenceApiInsertSchema.parse(config);
978
- }
979
- var ToolConfigSchema = zod.z.object({
980
- id: zod.z.string().optional(),
981
- name: zod.z.string(),
982
- description: zod.z.string(),
983
- parameters: zod.z.record(zod.z.string(), zod.z.any()).optional(),
984
- schema: zod.z.unknown().optional()
985
- });
986
- ToolConfigSchema.extend({
987
- execute: zod.z.any()
988
- // Function - validated separately at runtime
973
+ var TransferConfigSchema = zod.z.object({
974
+ agent: zod.z.instanceof(Agent),
975
+ description: zod.z.string().optional()
989
976
  });
990
- function tool(config) {
991
- if (typeof config.execute !== "function") {
992
- throw new Error("execute must be a function");
993
- }
994
- const { execute, ...configWithoutFunction } = config;
995
- const validatedConfig = ToolConfigSchema.parse(configWithoutFunction);
996
- const fullConfig = { ...validatedConfig, execute };
997
- const computedId = fullConfig.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
998
- return {
999
- id: computedId,
1000
- name: fullConfig.name,
1001
- description: fullConfig.description,
1002
- execute: fullConfig.execute,
1003
- parameters: fullConfig.parameters,
1004
- schema: fullConfig.schema,
1005
- type: "function"
1006
- };
977
+ function generateIdFromName3(name) {
978
+ return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
1007
979
  }
1008
- function mcpServer(config) {
1009
- const deployment = config.deployment || (config.execute ? "local" : "remote");
1010
- const id = config.id || config.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
1011
- if (deployment === "local") {
1012
- if (!config.execute) {
1013
- throw new Error("Local MCP server requires an execute function");
1014
- }
980
+ function validateFunction(value, name) {
981
+ if (typeof value !== "function") {
982
+ throw new Error(`${name} must be a function`);
983
+ }
984
+ }
985
+ function agent(config) {
986
+ if (!config.id) {
1015
987
  throw new Error(
1016
- "Local MCP servers are no longer supported. Please use remote MCP servers instead."
988
+ "Agent ID is required. Agents must have stable IDs for consistency across deployments."
1017
989
  );
1018
- } else {
1019
- if (!config.serverUrl) {
1020
- throw new Error("Remote MCP server requires a serverUrl");
1021
- }
1022
- return new exports.Tool({
1023
- id,
1024
- name: config.name,
1025
- description: config.description,
1026
- serverUrl: config.serverUrl,
1027
- tenantId: config.tenantId,
1028
- credential: config.credential,
1029
- activeTools: config.activeTools,
1030
- headers: config.headers
1031
- });
1032
990
  }
991
+ return new Agent(config);
992
+ }
993
+ function mcpServer(config) {
994
+ if (!config.serverUrl) {
995
+ throw new Error("MCP server requires a serverUrl");
996
+ }
997
+ const id = config.id || generateIdFromName3(config.name);
998
+ return new exports.Tool({
999
+ id,
1000
+ name: config.name,
1001
+ description: config.description,
1002
+ serverUrl: config.serverUrl,
1003
+ tenantId: config.tenantId,
1004
+ credential: config.credential,
1005
+ activeTools: config.activeTools,
1006
+ headers: config.headers,
1007
+ imageUrl: config.imageUrl,
1008
+ transport: config.transport ? { type: config.transport } : void 0
1009
+ });
1033
1010
  }
1034
1011
  function mcpTool(config) {
1035
1012
  const validatedConfig = agentsCore.MCPToolConfigSchema.parse(config);
1036
1013
  return new exports.Tool(validatedConfig);
1037
1014
  }
1038
- var TransferConfigSchema = zod.z.object({
1039
- agent: zod.z.instanceof(Agent),
1040
- description: zod.z.string().optional()
1041
- });
1042
- var TransferSchema = TransferConfigSchema.extend({
1043
- condition: zod.z.any().optional()
1044
- // Function - validated separately at runtime when present
1045
- });
1015
+ function credential(config) {
1016
+ return agentsCore.CredentialReferenceApiInsertSchema.parse(config);
1017
+ }
1046
1018
  function transfer(targetAgent, description, condition) {
1047
- if (condition !== void 0 && typeof condition !== "function") {
1048
- throw new Error("condition must be a function when provided");
1019
+ if (condition !== void 0) {
1020
+ validateFunction(condition, "condition");
1049
1021
  }
1050
1022
  const config = {
1051
1023
  agent: targetAgent,
1052
1024
  description: description || `Hand off to ${targetAgent.getName()}`,
1053
1025
  condition
1054
1026
  };
1055
- return TransferSchema.parse(config);
1027
+ TransferConfigSchema.parse({
1028
+ agent: config.agent,
1029
+ description: config.description
1030
+ });
1031
+ return config;
1056
1032
  }
1057
1033
  function artifactComponent(config) {
1058
1034
  return new ArtifactComponent({
@@ -2876,5 +2852,4 @@ exports.raceGraphs = raceGraphs;
2876
2852
  exports.registerEnvironmentSettings = registerEnvironmentSettings;
2877
2853
  exports.run = run;
2878
2854
  exports.stream = stream;
2879
- exports.tool = tool;
2880
2855
  exports.transfer = transfer;
package/dist/index.d.cts CHANGED
@@ -451,12 +451,51 @@ declare class Tool implements ToolInterface {
451
451
  private upsertTool;
452
452
  }
453
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
+ }
454
490
  /**
455
491
  * Creates a new agent with stable ID enforcement.
456
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
+ *
457
496
  * @param config - Agent configuration including required stable ID
458
497
  * @returns A new Agent instance
459
- * @throws Error if config.id is not provided (stable IDs are required)
498
+ * @throws {Error} If config.id is not provided
460
499
  *
461
500
  * @example
462
501
  * ```typescript
@@ -468,138 +507,159 @@ declare class Tool implements ToolInterface {
468
507
  * ```
469
508
  */
470
509
  declare function agent(config: AgentConfig): Agent;
471
- declare function credential(config: CredentialReferenceApiInsert): {
472
- id: string;
473
- credentialStoreId: string;
474
- type: "nango" | "memory" | "keychain";
475
- retrievalParams?: Record<string, unknown> | null | undefined;
476
- };
477
510
  /**
478
- * Creates a tool with automatic ID generation (unlike agents which require explicit IDs).
511
+ * Creates an MCP (Model Context Protocol) server for tool functionality.
479
512
  *
480
- * Tools automatically generate IDs from their name, whereas agents require stable IDs
481
- * to be explicitly provided for consistency across deployments.
513
+ * MCP servers provide tool functionality through a standardized protocol.
514
+ * They can be remote services accessed via HTTP/WebSocket.
482
515
  *
483
- * @param config - Tool configuration with auto-generated ID
484
- * @returns A Tool instance with auto-generated ID based on name
516
+ * @param config - MCP server configuration
517
+ * @returns A Tool instance configured as an MCP server
518
+ * @throws {Error} If serverUrl is not provided
485
519
  *
486
520
  * @example
487
521
  * ```typescript
488
- * const searchTool = tool({
489
- * name: 'Search Database',
490
- * description: 'Search the product database',
491
- * execute: async (params) => { ... }
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
+ * })
492
539
  * });
493
- * // ID will be auto-generated as 'search-database'
494
540
  * ```
495
541
  */
496
- declare function tool(config: {
497
- name: string;
498
- description: string;
499
- execute: (params: any) => Promise<any>;
500
- parameters?: Record<string, any>;
501
- schema?: z.ZodJSONSchema;
502
- }): {
503
- id: string;
504
- name: string;
505
- description: string;
506
- execute: (params: any) => Promise<any>;
507
- parameters: Record<string, any> | undefined;
508
- schema: unknown;
509
- type: "function";
510
- };
542
+ declare function mcpServer(config: MCPServerConfig): Tool;
511
543
  /**
512
- * Creates an MCP (Model Context Protocol) server for tool functionality.
544
+ * Creates an MCP tool from a raw configuration object.
513
545
  *
514
- * This unified builder replaces tool(), mcpTool(), ipcTool(), and hostedTool().
515
- * All tools are MCP servers - either local (with execute function) or remote (with URL).
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()`.
516
548
  *
517
- * @param config - MCP server configuration
518
- * @returns An MCP server instance that can be used as a tool in agents
549
+ * @param config - Complete MCP tool configuration
550
+ * @returns A Tool instance
519
551
  *
520
552
  * @example
521
553
  * ```typescript
522
- * // Local MCP server with execute function (auto-wrapped via IPC)
523
- * const searchServer = mcpServer({
524
- * name: 'search',
525
- * description: 'Search the database',
526
- * execute: async (params) => {
527
- * // Implementation
528
- * return results;
529
- * }
554
+ * const customTool = mcpTool({
555
+ * id: 'custom-tool',
556
+ * name: 'Custom Tool',
557
+ * serverUrl: 'https://example.com/mcp',
558
+ * transport: { type: 'stdio' }
530
559
  * });
560
+ * ```
561
+ */
562
+ declare function mcpTool(config: MCPToolConfig$1): Tool;
563
+ /**
564
+ * Creates a credential reference for authentication.
531
565
  *
532
- * // Remote MCP server
533
- * const apiServer = mcpServer({
534
- * name: 'external_api',
535
- * description: 'External API service',
536
- * serverUrl: 'https://api.example.com/mcp'
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
537
578
  * });
538
579
  * ```
539
580
  */
540
- declare function mcpServer(config: {
541
- name: string;
542
- description: string;
543
- deployment?: "local" | "remote";
544
- execute?: (params: any) => Promise<any>;
545
- port?: number;
546
- serverUrl?: string;
547
- id?: string;
548
- parameters?: Record<string, z.ZodJSONSchema>;
549
- credential?: CredentialReferenceApiInsert;
550
- tenantId?: string;
551
- transport?: keyof typeof MCPTransportType;
552
- activeTools?: string[];
553
- headers?: Record<string, string>;
554
- }): Tool;
555
- declare function mcpTool(config: MCPToolConfig$1): Tool;
556
- declare function transfer(targetAgent: Agent, description?: string, condition?: (context: unknown) => boolean): TransferConfig;
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;
557
612
  /**
558
613
  * Creates an artifact component with automatic ID generation.
559
614
  *
615
+ * Artifact components represent structured UI components that can
616
+ * be rendered with different levels of detail (summary vs full).
617
+ *
560
618
  * @param config - Artifact component configuration
561
- * @returns An ArtifactComponent instance with auto-generated ID
619
+ * @returns An ArtifactComponent instance
562
620
  *
563
621
  * @example
564
622
  * ```typescript
565
623
  * const productCard = artifactComponent({
566
624
  * name: 'Product Card',
567
625
  * description: 'Display product information',
568
- * summaryProps: { title: 'Product', price: '$0' },
569
- * fullProps: { title: 'Product', price: '$0', description: '...' }
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
+ * }
570
636
  * });
571
637
  * ```
572
638
  */
573
- declare function artifactComponent(config: {
574
- name: string;
575
- description: string;
576
- summaryProps: Record<string, any>;
577
- fullProps: Record<string, any>;
578
- tenantId?: string;
579
- projectId?: string;
580
- }): ArtifactComponent;
639
+ declare function artifactComponent(config: ArtifactComponentConfig): ArtifactComponent;
581
640
  /**
582
641
  * Creates a data component with automatic ID generation.
583
642
  *
643
+ * Data components represent structured data that can be
644
+ * passed between agents or used in processing.
645
+ *
584
646
  * @param config - Data component configuration
585
- * @returns A DataComponent instance with auto-generated ID
647
+ * @returns A DataComponent instance
586
648
  *
587
649
  * @example
588
650
  * ```typescript
589
651
  * const userProfile = dataComponent({
590
652
  * name: 'User Profile',
591
653
  * description: 'User profile data',
592
- * props: { userId: '123', name: 'John Doe' }
654
+ * props: {
655
+ * userId: '123',
656
+ * name: 'John Doe',
657
+ * email: 'john@example.com'
658
+ * }
593
659
  * });
594
660
  * ```
595
661
  */
596
- declare function dataComponent(config: {
597
- name: string;
598
- description: string;
599
- props: Record<string, any>;
600
- tenantId?: string;
601
- projectId?: string;
602
- }): DataComponent;
662
+ declare function dataComponent(config: DataComponentConfig): DataComponent;
603
663
 
604
664
  interface EnvironmentSettingsConfig {
605
665
  credentials?: {
@@ -853,4 +913,4 @@ declare const run: typeof Runner.run;
853
913
  declare const stream: typeof Runner.stream;
854
914
  declare const raceGraphs: typeof Runner.raceGraphs;
855
915
 
856
- export { Agent, type AgentConfig, AgentError, AgentGraph, type AgentInterface, type AgentResponse, type AllAgentInterface, ArtifactComponent, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, DataComponent, ExternalAgent, type ExternalAgentInterface, type FetchDefinitionConfig, type GenerateOptions, type GraphConfig, type GraphInterface, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, type ModelSettings, ModelSettingsSchema, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, type StatusComponent, type StatusUpdateSettings, type StreamEvent, type StreamResponse, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UserMessage, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, tool, transfer };
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 };
package/dist/index.d.ts CHANGED
@@ -451,12 +451,51 @@ declare class Tool implements ToolInterface {
451
451
  private upsertTool;
452
452
  }
453
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
+ }
454
490
  /**
455
491
  * Creates a new agent with stable ID enforcement.
456
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
+ *
457
496
  * @param config - Agent configuration including required stable ID
458
497
  * @returns A new Agent instance
459
- * @throws Error if config.id is not provided (stable IDs are required)
498
+ * @throws {Error} If config.id is not provided
460
499
  *
461
500
  * @example
462
501
  * ```typescript
@@ -468,138 +507,159 @@ declare class Tool implements ToolInterface {
468
507
  * ```
469
508
  */
470
509
  declare function agent(config: AgentConfig): Agent;
471
- declare function credential(config: CredentialReferenceApiInsert): {
472
- id: string;
473
- credentialStoreId: string;
474
- type: "nango" | "memory" | "keychain";
475
- retrievalParams?: Record<string, unknown> | null | undefined;
476
- };
477
510
  /**
478
- * Creates a tool with automatic ID generation (unlike agents which require explicit IDs).
511
+ * Creates an MCP (Model Context Protocol) server for tool functionality.
479
512
  *
480
- * Tools automatically generate IDs from their name, whereas agents require stable IDs
481
- * to be explicitly provided for consistency across deployments.
513
+ * MCP servers provide tool functionality through a standardized protocol.
514
+ * They can be remote services accessed via HTTP/WebSocket.
482
515
  *
483
- * @param config - Tool configuration with auto-generated ID
484
- * @returns A Tool instance with auto-generated ID based on name
516
+ * @param config - MCP server configuration
517
+ * @returns A Tool instance configured as an MCP server
518
+ * @throws {Error} If serverUrl is not provided
485
519
  *
486
520
  * @example
487
521
  * ```typescript
488
- * const searchTool = tool({
489
- * name: 'Search Database',
490
- * description: 'Search the product database',
491
- * execute: async (params) => { ... }
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
+ * })
492
539
  * });
493
- * // ID will be auto-generated as 'search-database'
494
540
  * ```
495
541
  */
496
- declare function tool(config: {
497
- name: string;
498
- description: string;
499
- execute: (params: any) => Promise<any>;
500
- parameters?: Record<string, any>;
501
- schema?: z.ZodJSONSchema;
502
- }): {
503
- id: string;
504
- name: string;
505
- description: string;
506
- execute: (params: any) => Promise<any>;
507
- parameters: Record<string, any> | undefined;
508
- schema: unknown;
509
- type: "function";
510
- };
542
+ declare function mcpServer(config: MCPServerConfig): Tool;
511
543
  /**
512
- * Creates an MCP (Model Context Protocol) server for tool functionality.
544
+ * Creates an MCP tool from a raw configuration object.
513
545
  *
514
- * This unified builder replaces tool(), mcpTool(), ipcTool(), and hostedTool().
515
- * All tools are MCP servers - either local (with execute function) or remote (with URL).
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()`.
516
548
  *
517
- * @param config - MCP server configuration
518
- * @returns An MCP server instance that can be used as a tool in agents
549
+ * @param config - Complete MCP tool configuration
550
+ * @returns A Tool instance
519
551
  *
520
552
  * @example
521
553
  * ```typescript
522
- * // Local MCP server with execute function (auto-wrapped via IPC)
523
- * const searchServer = mcpServer({
524
- * name: 'search',
525
- * description: 'Search the database',
526
- * execute: async (params) => {
527
- * // Implementation
528
- * return results;
529
- * }
554
+ * const customTool = mcpTool({
555
+ * id: 'custom-tool',
556
+ * name: 'Custom Tool',
557
+ * serverUrl: 'https://example.com/mcp',
558
+ * transport: { type: 'stdio' }
530
559
  * });
560
+ * ```
561
+ */
562
+ declare function mcpTool(config: MCPToolConfig$1): Tool;
563
+ /**
564
+ * Creates a credential reference for authentication.
531
565
  *
532
- * // Remote MCP server
533
- * const apiServer = mcpServer({
534
- * name: 'external_api',
535
- * description: 'External API service',
536
- * serverUrl: 'https://api.example.com/mcp'
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
537
578
  * });
538
579
  * ```
539
580
  */
540
- declare function mcpServer(config: {
541
- name: string;
542
- description: string;
543
- deployment?: "local" | "remote";
544
- execute?: (params: any) => Promise<any>;
545
- port?: number;
546
- serverUrl?: string;
547
- id?: string;
548
- parameters?: Record<string, z.ZodJSONSchema>;
549
- credential?: CredentialReferenceApiInsert;
550
- tenantId?: string;
551
- transport?: keyof typeof MCPTransportType;
552
- activeTools?: string[];
553
- headers?: Record<string, string>;
554
- }): Tool;
555
- declare function mcpTool(config: MCPToolConfig$1): Tool;
556
- declare function transfer(targetAgent: Agent, description?: string, condition?: (context: unknown) => boolean): TransferConfig;
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;
557
612
  /**
558
613
  * Creates an artifact component with automatic ID generation.
559
614
  *
615
+ * Artifact components represent structured UI components that can
616
+ * be rendered with different levels of detail (summary vs full).
617
+ *
560
618
  * @param config - Artifact component configuration
561
- * @returns An ArtifactComponent instance with auto-generated ID
619
+ * @returns An ArtifactComponent instance
562
620
  *
563
621
  * @example
564
622
  * ```typescript
565
623
  * const productCard = artifactComponent({
566
624
  * name: 'Product Card',
567
625
  * description: 'Display product information',
568
- * summaryProps: { title: 'Product', price: '$0' },
569
- * fullProps: { title: 'Product', price: '$0', description: '...' }
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
+ * }
570
636
  * });
571
637
  * ```
572
638
  */
573
- declare function artifactComponent(config: {
574
- name: string;
575
- description: string;
576
- summaryProps: Record<string, any>;
577
- fullProps: Record<string, any>;
578
- tenantId?: string;
579
- projectId?: string;
580
- }): ArtifactComponent;
639
+ declare function artifactComponent(config: ArtifactComponentConfig): ArtifactComponent;
581
640
  /**
582
641
  * Creates a data component with automatic ID generation.
583
642
  *
643
+ * Data components represent structured data that can be
644
+ * passed between agents or used in processing.
645
+ *
584
646
  * @param config - Data component configuration
585
- * @returns A DataComponent instance with auto-generated ID
647
+ * @returns A DataComponent instance
586
648
  *
587
649
  * @example
588
650
  * ```typescript
589
651
  * const userProfile = dataComponent({
590
652
  * name: 'User Profile',
591
653
  * description: 'User profile data',
592
- * props: { userId: '123', name: 'John Doe' }
654
+ * props: {
655
+ * userId: '123',
656
+ * name: 'John Doe',
657
+ * email: 'john@example.com'
658
+ * }
593
659
  * });
594
660
  * ```
595
661
  */
596
- declare function dataComponent(config: {
597
- name: string;
598
- description: string;
599
- props: Record<string, any>;
600
- tenantId?: string;
601
- projectId?: string;
602
- }): DataComponent;
662
+ declare function dataComponent(config: DataComponentConfig): DataComponent;
603
663
 
604
664
  interface EnvironmentSettingsConfig {
605
665
  credentials?: {
@@ -853,4 +913,4 @@ declare const run: typeof Runner.run;
853
913
  declare const stream: typeof Runner.stream;
854
914
  declare const raceGraphs: typeof Runner.raceGraphs;
855
915
 
856
- export { Agent, type AgentConfig, AgentError, AgentGraph, type AgentInterface, type AgentResponse, type AllAgentInterface, ArtifactComponent, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, DataComponent, ExternalAgent, type ExternalAgentInterface, type FetchDefinitionConfig, type GenerateOptions, type GraphConfig, type GraphInterface, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, type ModelSettings, ModelSettingsSchema, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, type StatusComponent, type StatusUpdateSettings, type StreamEvent, type StreamResponse, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UserMessage, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, tool, transfer };
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 };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { __publicField, Tool } from './chunk-BCJFVUMJ.js';
2
2
  export { Tool } from './chunk-BCJFVUMJ.js';
3
- import { getLogger, generateIdFromName, CredentialReferenceApiInsertSchema, MCPToolConfigSchema, createDatabaseClient, getProject } from '@inkeep/agents-core';
3
+ import { getLogger, generateIdFromName, MCPToolConfigSchema, CredentialReferenceApiInsertSchema, createDatabaseClient, getProject } from '@inkeep/agents-core';
4
4
  import { z } from 'zod';
5
5
 
6
6
  var logger = getLogger("artifactComponent");
@@ -330,11 +330,11 @@ var Agent = class {
330
330
  throw new Error("tools getter must return an array");
331
331
  }
332
332
  const toolRecord = {};
333
- for (const tool2 of tools) {
334
- if (tool2 && typeof tool2 === "object") {
335
- const id = tool2.id || tool2.getId?.() || tool2.name;
333
+ for (const tool of tools) {
334
+ if (tool && typeof tool === "object") {
335
+ const id = tool.id || tool.getId?.() || tool.name;
336
336
  if (id) {
337
- toolRecord[id] = tool2;
337
+ toolRecord[id] = tool;
338
338
  }
339
339
  }
340
340
  }
@@ -358,9 +358,9 @@ var Agent = class {
358
358
  getArtifactComponents() {
359
359
  return resolveGetter(this.config.artifactComponents) || [];
360
360
  }
361
- addTool(_name, tool2) {
361
+ addTool(_name, tool) {
362
362
  const existingTools = this.config.tools ? this.config.tools() : [];
363
- this.config.tools = () => [...existingTools, tool2];
363
+ this.config.tools = () => [...existingTools, tool];
364
364
  }
365
365
  addTransfer(...agents) {
366
366
  if (typeof this.config.canTransferTo === "function") {
@@ -615,7 +615,7 @@ var Agent = class {
615
615
  return;
616
616
  }
617
617
  const { Tool: Tool2 } = await import('./tool-6K5MVNKA.js');
618
- let tool2;
618
+ let tool;
619
619
  if (toolConfig instanceof Tool2) {
620
620
  logger3.info(
621
621
  {
@@ -625,8 +625,8 @@ var Agent = class {
625
625
  },
626
626
  "Initializing Tool instance"
627
627
  );
628
- tool2 = toolConfig;
629
- await tool2.init();
628
+ tool = toolConfig;
629
+ await tool.init();
630
630
  } else {
631
631
  logger3.info(
632
632
  {
@@ -636,7 +636,7 @@ var Agent = class {
636
636
  },
637
637
  "Creating Tool from config"
638
638
  );
639
- tool2 = new Tool2({
639
+ tool = new Tool2({
640
640
  id: toolId,
641
641
  tenantId: this.tenantId,
642
642
  name: toolConfig.name || toolId,
@@ -645,13 +645,13 @@ var Agent = class {
645
645
  activeTools: toolConfig.config?.mcp?.activeTools,
646
646
  credential: toolConfig.credential
647
647
  });
648
- await tool2.init();
648
+ await tool.init();
649
649
  }
650
- await this.createAgentToolRelation(tool2.getId());
650
+ await this.createAgentToolRelation(tool.getId());
651
651
  logger3.info(
652
652
  {
653
653
  agentId: this.getId(),
654
- toolId: tool2.getId()
654
+ toolId: tool.getId()
655
655
  },
656
656
  "Tool created and linked to agent"
657
657
  );
@@ -809,89 +809,65 @@ var Agent = class {
809
809
  }
810
810
  }
811
811
  };
812
- function agent(config) {
813
- return new Agent(config);
814
- }
815
- function credential(config) {
816
- return CredentialReferenceApiInsertSchema.parse(config);
817
- }
818
- var ToolConfigSchema = z.object({
819
- id: z.string().optional(),
820
- name: z.string(),
821
- description: z.string(),
822
- parameters: z.record(z.string(), z.any()).optional(),
823
- schema: z.unknown().optional()
824
- });
825
- ToolConfigSchema.extend({
826
- execute: z.any()
827
- // Function - validated separately at runtime
812
+ var TransferConfigSchema = z.object({
813
+ agent: z.instanceof(Agent),
814
+ description: z.string().optional()
828
815
  });
829
- function tool(config) {
830
- if (typeof config.execute !== "function") {
831
- throw new Error("execute must be a function");
832
- }
833
- const { execute, ...configWithoutFunction } = config;
834
- const validatedConfig = ToolConfigSchema.parse(configWithoutFunction);
835
- const fullConfig = { ...validatedConfig, execute };
836
- const computedId = fullConfig.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
837
- return {
838
- id: computedId,
839
- name: fullConfig.name,
840
- description: fullConfig.description,
841
- execute: fullConfig.execute,
842
- parameters: fullConfig.parameters,
843
- schema: fullConfig.schema,
844
- type: "function"
845
- };
816
+ function generateIdFromName3(name) {
817
+ return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
846
818
  }
847
- function mcpServer(config) {
848
- const deployment = config.deployment || (config.execute ? "local" : "remote");
849
- const id = config.id || config.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
850
- if (deployment === "local") {
851
- if (!config.execute) {
852
- throw new Error("Local MCP server requires an execute function");
853
- }
819
+ function validateFunction(value, name) {
820
+ if (typeof value !== "function") {
821
+ throw new Error(`${name} must be a function`);
822
+ }
823
+ }
824
+ function agent(config) {
825
+ if (!config.id) {
854
826
  throw new Error(
855
- "Local MCP servers are no longer supported. Please use remote MCP servers instead."
827
+ "Agent ID is required. Agents must have stable IDs for consistency across deployments."
856
828
  );
857
- } else {
858
- if (!config.serverUrl) {
859
- throw new Error("Remote MCP server requires a serverUrl");
860
- }
861
- return new Tool({
862
- id,
863
- name: config.name,
864
- description: config.description,
865
- serverUrl: config.serverUrl,
866
- tenantId: config.tenantId,
867
- credential: config.credential,
868
- activeTools: config.activeTools,
869
- headers: config.headers
870
- });
871
829
  }
830
+ return new Agent(config);
831
+ }
832
+ function mcpServer(config) {
833
+ if (!config.serverUrl) {
834
+ throw new Error("MCP server requires a serverUrl");
835
+ }
836
+ const id = config.id || generateIdFromName3(config.name);
837
+ return new Tool({
838
+ id,
839
+ name: config.name,
840
+ description: config.description,
841
+ serverUrl: config.serverUrl,
842
+ tenantId: config.tenantId,
843
+ credential: config.credential,
844
+ activeTools: config.activeTools,
845
+ headers: config.headers,
846
+ imageUrl: config.imageUrl,
847
+ transport: config.transport ? { type: config.transport } : void 0
848
+ });
872
849
  }
873
850
  function mcpTool(config) {
874
851
  const validatedConfig = MCPToolConfigSchema.parse(config);
875
852
  return new Tool(validatedConfig);
876
853
  }
877
- var TransferConfigSchema = z.object({
878
- agent: z.instanceof(Agent),
879
- description: z.string().optional()
880
- });
881
- var TransferSchema = TransferConfigSchema.extend({
882
- condition: z.any().optional()
883
- // Function - validated separately at runtime when present
884
- });
854
+ function credential(config) {
855
+ return CredentialReferenceApiInsertSchema.parse(config);
856
+ }
885
857
  function transfer(targetAgent, description, condition) {
886
- if (condition !== void 0 && typeof condition !== "function") {
887
- throw new Error("condition must be a function when provided");
858
+ if (condition !== void 0) {
859
+ validateFunction(condition, "condition");
888
860
  }
889
861
  const config = {
890
862
  agent: targetAgent,
891
863
  description: description || `Hand off to ${targetAgent.getName()}`,
892
864
  condition
893
865
  };
894
- return TransferSchema.parse(config);
866
+ TransferConfigSchema.parse({
867
+ agent: config.agent,
868
+ description: config.description
869
+ });
870
+ return config;
895
871
  }
896
872
  function artifactComponent(config) {
897
873
  return new ArtifactComponent({
@@ -2691,4 +2667,4 @@ var run = Runner.run.bind(Runner);
2691
2667
  var stream = Runner.stream.bind(Runner);
2692
2668
  var raceGraphs = Runner.raceGraphs.bind(Runner);
2693
2669
 
2694
- export { Agent, AgentGraph, ArtifactComponent, DataComponent, ExternalAgent, Runner, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, tool, transfer };
2670
+ export { Agent, AgentGraph, ArtifactComponent, DataComponent, ExternalAgent, Runner, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, transfer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-sdk",
3
- "version": "0.0.0-dev-20250911052037",
3
+ "version": "0.0.0-dev-20250911063109",
4
4
  "description": "SDK for building and managing agents in the Inkeep Agent Framework",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -8,7 +8,7 @@
8
8
  "dependencies": {
9
9
  "nanoid": "^5.1.5",
10
10
  "zod": "^4.1.5",
11
- "@inkeep/agents-core": "^0.0.0-dev-20250911052037"
11
+ "@inkeep/agents-core": "^0.0.0-dev-20250911063109"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@biomejs/biome": "2.1.4",