@inkeep/agents-sdk 0.26.2 → 0.27.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.
package/dist/index.cjs CHANGED
@@ -514,7 +514,12 @@ var Agent = class {
514
514
  this.subAgents = resolveGetter(config.subAgents) || [];
515
515
  this.agentMap = new Map(this.subAgents.map((agent2) => [agent2.getId(), agent2]));
516
516
  if (this.defaultSubAgent) {
517
- this.subAgents.push(this.defaultSubAgent);
517
+ const isAlreadyPresent = this.subAgents.some(
518
+ (agent2) => agent2.getId() === this.defaultSubAgent?.getId()
519
+ );
520
+ if (!isAlreadyPresent) {
521
+ this.subAgents.push(this.defaultSubAgent);
522
+ }
518
523
  this.agentMap.set(this.defaultSubAgent.getId(), this.defaultSubAgent);
519
524
  }
520
525
  if (this.models) {
@@ -655,9 +660,10 @@ var Agent = class {
655
660
  externalAgentId: d.externalAgent.getId(),
656
661
  ...d.headers && { headers: d.headers }
657
662
  };
658
- } else if (typeof d === "object" && "type" in d && d.type === "external") {
663
+ } else if (typeof d === "object" && "agent" in d) {
659
664
  return {
660
- externalAgentId: d.getId()
665
+ agentId: d.agent.getId(),
666
+ ...d.headers && { headers: d.headers }
661
667
  };
662
668
  }
663
669
  return d.getId();
@@ -1037,6 +1043,12 @@ var Agent = class {
1037
1043
  tenantId: this.tenantId
1038
1044
  };
1039
1045
  }
1046
+ with(options) {
1047
+ return {
1048
+ agent: this,
1049
+ headers: options.headers
1050
+ };
1051
+ }
1040
1052
  /**
1041
1053
  * Validate the agent configuration
1042
1054
  */
@@ -2744,6 +2756,29 @@ var Tool = class {
2744
2756
  }
2745
2757
  throw new Error(`Failed to update tool: ${updateResponse.status}`);
2746
2758
  }
2759
+ /**
2760
+ * Creates a new AgentMcpConfig with the given configuration.
2761
+ *
2762
+ * @param config - The configuration for the AgentMcpConfig
2763
+ * @returns A new AgentMcpConfig
2764
+ *
2765
+ * example:
2766
+ * ```typescript
2767
+ * const tool = new Tool({
2768
+ * id: 'tool-id',
2769
+ * name: 'Tool Name',
2770
+ * serverUrl: 'https://example.com/mcp',
2771
+ * });
2772
+ * const agentMcpConfig = tool.with({ selectedTools: ['tool-1', 'tool-2'], headers: { 'Authorization': 'Bearer token' } });
2773
+ * ```
2774
+ */
2775
+ with(config) {
2776
+ return {
2777
+ server: this,
2778
+ selectedTools: config.selectedTools,
2779
+ headers: config.headers
2780
+ };
2781
+ }
2747
2782
  };
2748
2783
 
2749
2784
  // src/utils/tool-normalization.ts
@@ -2871,6 +2906,12 @@ var SubAgent = class {
2871
2906
  if (typeof delegate === "object" && "externalAgent" in delegate) {
2872
2907
  return false;
2873
2908
  }
2909
+ if (typeof delegate === "object" && "agent" in delegate) {
2910
+ return false;
2911
+ }
2912
+ if (typeof delegate === "object" && "toFullAgentDefinition" in delegate) {
2913
+ return false;
2914
+ }
2874
2915
  if (typeof delegate === "object" && "type" in delegate && delegate.type === "external") {
2875
2916
  return false;
2876
2917
  }
@@ -2899,8 +2940,34 @@ var SubAgent = class {
2899
2940
  };
2900
2941
  });
2901
2942
  }
2943
+ getTeamAgentDelegates() {
2944
+ if (typeof this.config.canDelegateTo !== "function") {
2945
+ return [];
2946
+ }
2947
+ return this.config.canDelegateTo().filter((delegate) => {
2948
+ if (typeof delegate === "object" && "agent" in delegate) {
2949
+ return true;
2950
+ }
2951
+ if (typeof delegate === "object" && "toFullAgentDefinition" in delegate) {
2952
+ return true;
2953
+ }
2954
+ return false;
2955
+ }).map((delegate) => {
2956
+ if ("agent" in delegate) {
2957
+ return delegate;
2958
+ }
2959
+ return {
2960
+ agent: delegate,
2961
+ headers: void 0
2962
+ };
2963
+ });
2964
+ }
2902
2965
  getDelegates() {
2903
- return typeof this.config.canDelegateTo === "function" ? this.config.canDelegateTo() : [];
2966
+ return [
2967
+ ...this.getSubAgentDelegates(),
2968
+ ...this.getTeamAgentDelegates(),
2969
+ ...this.getExternalAgentDelegates()
2970
+ ];
2904
2971
  }
2905
2972
  getDataComponents() {
2906
2973
  const components = resolveGetter2(this.config.dataComponents) || [];
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ArtifactComponentInsert, MCPToolConfig as MCPToolConfig$1, DataComponentApiInsert, ArtifactComponentApiInsert, CredentialReferenceApiInsert, DataComponentInsert, FunctionToolConfig, SubAgentApiInsert, AgentConversationHistoryConfig, AgentStopWhen, ModelSettings, StatusUpdateSettings, FullAgentDefinition, ToolInsert, McpTransportConfig, StopWhen, FullProjectDefinition, StatusComponent as StatusComponent$1 } from '@inkeep/agents-core';
1
+ import { ArtifactComponentInsert, MCPToolConfig as MCPToolConfig$1, DataComponentApiInsert, ArtifactComponentApiInsert, CredentialReferenceApiInsert, DataComponentInsert, FunctionToolConfig, SubAgentApiInsert, FullAgentDefinition, AgentConversationHistoryConfig, AgentStopWhen, ModelSettings, StatusUpdateSettings, ToolInsert, McpTransportConfig, StopWhen, FullProjectDefinition, StatusComponent as StatusComponent$1 } from '@inkeep/agents-core';
2
2
  export { ANTHROPIC_MODELS, FunctionToolConfig, GOOGLE_MODELS, ModelSettings, OPENAI_MODELS } from '@inkeep/agents-core';
3
3
  import { z } from 'zod';
4
4
 
@@ -40,6 +40,7 @@ interface ToolInterface {
40
40
  getServerUrl(): string;
41
41
  getActiveTools(): string[] | undefined;
42
42
  getCredentialReferenceId(): string | null | undefined;
43
+ with(config: AgentMcpConfigInput): AgentMcpConfig;
43
44
  }
44
45
  declare class Tool implements ToolInterface {
45
46
  config: MCPToolConfig$1;
@@ -59,6 +60,23 @@ declare class Tool implements ToolInterface {
59
60
  skipDatabaseRegistration?: boolean;
60
61
  }): Promise<void>;
61
62
  private upsertTool;
63
+ /**
64
+ * Creates a new AgentMcpConfig with the given configuration.
65
+ *
66
+ * @param config - The configuration for the AgentMcpConfig
67
+ * @returns A new AgentMcpConfig
68
+ *
69
+ * example:
70
+ * ```typescript
71
+ * const tool = new Tool({
72
+ * id: 'tool-id',
73
+ * name: 'Tool Name',
74
+ * serverUrl: 'https://example.com/mcp',
75
+ * });
76
+ * const agentMcpConfig = tool.with({ selectedTools: ['tool-1', 'tool-2'], headers: { 'Authorization': 'Bearer token' } });
77
+ * ```
78
+ */
79
+ with(config: AgentMcpConfigInput): AgentMcpConfig;
62
80
  }
63
81
 
64
82
  declare class SubAgent implements SubAgentInterface {
@@ -83,12 +101,13 @@ declare class SubAgent implements SubAgentInterface {
83
101
  getTransfers(): SubAgentInterface[];
84
102
  getSubAgentDelegates(): SubAgentInterface[];
85
103
  getExternalAgentDelegates(): subAgentExternalAgentInterface[];
86
- getDelegates(): AllSubAgentInterface[];
104
+ getTeamAgentDelegates(): subAgentTeamAgentInterface[];
105
+ getDelegates(): AllDelegateOutputInterface[];
87
106
  getDataComponents(): DataComponentApiInsert[];
88
107
  getArtifactComponents(): ArtifactComponentApiInsert[];
89
108
  addTool(_name: string, tool: Tool): void;
90
109
  addTransfer(...agents: SubAgentInterface[]): void;
91
- addDelegate(...agents: AllSubAgentInterface[]): void;
110
+ addDelegate(...agents: AllDelegateInputInterface[]): void;
92
111
  init(): Promise<void>;
93
112
  private upsertAgent;
94
113
  private saveToolsAndRelations;
@@ -148,6 +167,15 @@ type AgentMcpConfig = {
148
167
  selectedTools?: string[];
149
168
  headers?: Record<string, string>;
150
169
  };
170
+ /**
171
+ * Input configuration for MCP tool customization
172
+ */
173
+ type AgentMcpConfigInput = {
174
+ /** Specific tools to enable from the MCP server */
175
+ selectedTools?: string[];
176
+ /** Custom headers for MCP server requests */
177
+ headers?: Record<string, string>;
178
+ };
151
179
  /**
152
180
  * Creates a transfer configuration for agent transfers.
153
181
  *
@@ -347,13 +375,14 @@ interface ToolResult {
347
375
  result: any;
348
376
  error?: string;
349
377
  }
350
- type AllSubAgentInterface = SubAgentInterface | subAgentExternalAgentInterface | ExternalAgentInterface;
378
+ type AllDelegateInputInterface = SubAgentInterface | subAgentExternalAgentInterface | ExternalAgentInterface | AgentInterface | subAgentTeamAgentInterface;
379
+ type AllDelegateOutputInterface = SubAgentInterface | subAgentExternalAgentInterface | subAgentTeamAgentInterface;
351
380
  type SubAgentCanUseType = Tool | AgentMcpConfig | FunctionTool;
352
381
  interface SubAgentConfig extends Omit<SubAgentApiInsert, 'projectId'> {
353
382
  type?: 'internal';
354
383
  canUse?: () => SubAgentCanUseType[];
355
384
  canTransferTo?: () => SubAgentInterface[];
356
- canDelegateTo?: () => AllSubAgentInterface[];
385
+ canDelegateTo?: () => AllDelegateInputInterface[];
357
386
  dataComponents?: () => (DataComponentApiInsert | DataComponentInterface | DataComponentWithZodProps)[];
358
387
  artifactComponents?: () => (ArtifactComponentApiInsert | ArtifactComponentInterface | ArtifactComponentWithZodProps)[];
359
388
  conversationHistoryConfig?: AgentConversationHistoryConfig;
@@ -462,7 +491,7 @@ interface AgentConfig {
462
491
  id: string;
463
492
  name?: string;
464
493
  description?: string;
465
- defaultSubAgent?: SubAgentInterface;
494
+ defaultSubAgent: SubAgentInterface;
466
495
  subAgents?: () => SubAgentInterface[];
467
496
  contextConfig?: any;
468
497
  credentials?: () => CredentialReferenceApiInsert[];
@@ -499,7 +528,7 @@ interface SubAgentInterface {
499
528
  getInstructions(): string;
500
529
  getTools(): Record<string, AgentTool>;
501
530
  getTransfers(): SubAgentInterface[];
502
- getDelegates(): AllSubAgentInterface[];
531
+ getDelegates(): AllDelegateOutputInterface[];
503
532
  getSubAgentDelegates(): SubAgentInterface[];
504
533
  getExternalAgentDelegates(): subAgentExternalAgentInterface[];
505
534
  getDataComponents(): DataComponentApiInsert[];
@@ -507,7 +536,7 @@ interface SubAgentInterface {
507
536
  setContext(tenantId: string, projectId: string, baseURL?: string): void;
508
537
  addTool(name: string, tool: any): void;
509
538
  addTransfer(...agents: SubAgentInterface[]): void;
510
- addDelegate(...agents: AllSubAgentInterface[]): void;
539
+ addDelegate(...agents: AllDelegateInputInterface[]): void;
511
540
  }
512
541
  interface ExternalAgentInterface {
513
542
  config: ExternalAgentConfig;
@@ -518,6 +547,9 @@ interface ExternalAgentInterface {
518
547
  getDescription(): string;
519
548
  getBaseUrl(): string;
520
549
  setContext?(tenantId: string, projectId: string): void;
550
+ with(options: {
551
+ headers?: Record<string, string>;
552
+ }): subAgentExternalAgentInterface;
521
553
  getCredentialReferenceId(): string | undefined;
522
554
  getCredentialReference(): CredentialReferenceApiInsert | undefined;
523
555
  }
@@ -525,6 +557,10 @@ type subAgentExternalAgentInterface = {
525
557
  externalAgent: ExternalAgentInterface;
526
558
  headers?: Record<string, string>;
527
559
  };
560
+ type subAgentTeamAgentInterface = {
561
+ agent: AgentInterface;
562
+ headers?: Record<string, string>;
563
+ };
528
564
  interface AgentInterface {
529
565
  init(): Promise<void>;
530
566
  setConfig(tenantId: string, projectId: string, apiUrl: string): void;
@@ -539,6 +575,9 @@ interface AgentInterface {
539
575
  getSubAgent(name: string): SubAgentInterface | undefined;
540
576
  getSubAgents(): SubAgentInterface[];
541
577
  toFullAgentDefinition(): Promise<FullAgentDefinition>;
578
+ with(options: {
579
+ headers?: Record<string, string>;
580
+ }): subAgentTeamAgentInterface;
542
581
  }
543
582
  interface BuilderToolConfig {
544
583
  name: string;
@@ -686,6 +725,9 @@ declare class Agent implements AgentInterface {
686
725
  agentId: string;
687
726
  tenantId: string;
688
727
  };
728
+ with(options: {
729
+ headers?: Record<string, string>;
730
+ }): subAgentTeamAgentInterface;
689
731
  /**
690
732
  * Validate the agent configuration
691
733
  */
@@ -697,7 +739,7 @@ declare class Agent implements AgentInterface {
697
739
  /**
698
740
  * Type guard to check if an agent is an internal AgentInterface
699
741
  */
700
- isInternalAgent(agent: AllSubAgentInterface): agent is SubAgentInterface;
742
+ isInternalAgent(agent: AllDelegateInputInterface): agent is SubAgentInterface;
701
743
  /**
702
744
  * Get project-level model settingsuration defaults
703
745
  */
@@ -1172,6 +1214,14 @@ declare function dataComponent(config: DataComponentConfig): DataComponent;
1172
1214
  * ```
1173
1215
  */
1174
1216
  declare function statusComponent(config: StatusComponentConfig): StatusComponent;
1217
+ /**
1218
+ * (deprecated in favor of mcpTool.with()) Creates an agent MCP configuration.
1219
+ *
1220
+ * Agent MCP configurations are used to configure the MCP server for an agent.
1221
+ *
1222
+ * @param config - Agent MCP configuration
1223
+ * @returns An AgentMcpConfig instance
1224
+ */
1175
1225
  declare function agentMcp(config: AgentMcpConfig): AgentMcpConfig;
1176
1226
  /**
1177
1227
  * Creates a function tool that executes user-defined code in a sandboxed environment.
@@ -1339,4 +1389,4 @@ declare const run: typeof Runner.run;
1339
1389
  declare const stream: typeof Runner.stream;
1340
1390
  declare const raceAgents: typeof Runner.raceAgents;
1341
1391
 
1342
- export { type AgentConfig, AgentError, type AgentInterface, type AgentResponse, type AgentTool, type AllSubAgentInterface, ArtifactComponent, type ArtifactComponentInterface, type ArtifactComponentWithZodProps, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, type CredentialReference, DataComponent, type DataComponentInterface, type DataComponentWithZodProps, ExternalAgent, type ExternalAgentInterface, type ExtractCredentialIds, type FetchDefinitionConfig, FunctionTool, type GenerateOptions, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, Project, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, StatusComponent, type StatusComponentInterface, type StreamEvent, type StreamResponse, SubAgent, type SubAgentCanUseType, type SubAgentConfig, type SubAgentInterface, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UnionCredentialIds, type UserMessage, agent, agentMcp, artifactComponent, createEnvironmentSettings, createFullProjectViaAPI, credential, credentialRef, dataComponent, deleteFullProjectViaAPI, externalAgent, externalAgents, functionTool, getFullProjectViaAPI, isCredentialReference, mcpServer, mcpTool, project, raceAgents, registerEnvironmentSettings, run, statusComponent, stream, subAgent, type subAgentExternalAgentInterface, transfer, updateFullProjectViaAPI };
1392
+ export { type AgentConfig, AgentError, type AgentInterface, type AgentResponse, type AgentTool, type AllDelegateInputInterface, type AllDelegateOutputInterface, ArtifactComponent, type ArtifactComponentInterface, type ArtifactComponentWithZodProps, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, type CredentialReference, DataComponent, type DataComponentInterface, type DataComponentWithZodProps, ExternalAgent, type ExternalAgentInterface, type ExtractCredentialIds, type FetchDefinitionConfig, FunctionTool, type GenerateOptions, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, Project, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, StatusComponent, type StatusComponentInterface, type StreamEvent, type StreamResponse, SubAgent, type SubAgentCanUseType, type SubAgentConfig, type SubAgentInterface, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UnionCredentialIds, type UserMessage, agent, agentMcp, artifactComponent, createEnvironmentSettings, createFullProjectViaAPI, credential, credentialRef, dataComponent, deleteFullProjectViaAPI, externalAgent, externalAgents, functionTool, getFullProjectViaAPI, isCredentialReference, mcpServer, mcpTool, project, raceAgents, registerEnvironmentSettings, run, statusComponent, stream, subAgent, type subAgentExternalAgentInterface, type subAgentTeamAgentInterface, transfer, updateFullProjectViaAPI };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ArtifactComponentInsert, MCPToolConfig as MCPToolConfig$1, DataComponentApiInsert, ArtifactComponentApiInsert, CredentialReferenceApiInsert, DataComponentInsert, FunctionToolConfig, SubAgentApiInsert, AgentConversationHistoryConfig, AgentStopWhen, ModelSettings, StatusUpdateSettings, FullAgentDefinition, ToolInsert, McpTransportConfig, StopWhen, FullProjectDefinition, StatusComponent as StatusComponent$1 } from '@inkeep/agents-core';
1
+ import { ArtifactComponentInsert, MCPToolConfig as MCPToolConfig$1, DataComponentApiInsert, ArtifactComponentApiInsert, CredentialReferenceApiInsert, DataComponentInsert, FunctionToolConfig, SubAgentApiInsert, FullAgentDefinition, AgentConversationHistoryConfig, AgentStopWhen, ModelSettings, StatusUpdateSettings, ToolInsert, McpTransportConfig, StopWhen, FullProjectDefinition, StatusComponent as StatusComponent$1 } from '@inkeep/agents-core';
2
2
  export { ANTHROPIC_MODELS, FunctionToolConfig, GOOGLE_MODELS, ModelSettings, OPENAI_MODELS } from '@inkeep/agents-core';
3
3
  import { z } from 'zod';
4
4
 
@@ -40,6 +40,7 @@ interface ToolInterface {
40
40
  getServerUrl(): string;
41
41
  getActiveTools(): string[] | undefined;
42
42
  getCredentialReferenceId(): string | null | undefined;
43
+ with(config: AgentMcpConfigInput): AgentMcpConfig;
43
44
  }
44
45
  declare class Tool implements ToolInterface {
45
46
  config: MCPToolConfig$1;
@@ -59,6 +60,23 @@ declare class Tool implements ToolInterface {
59
60
  skipDatabaseRegistration?: boolean;
60
61
  }): Promise<void>;
61
62
  private upsertTool;
63
+ /**
64
+ * Creates a new AgentMcpConfig with the given configuration.
65
+ *
66
+ * @param config - The configuration for the AgentMcpConfig
67
+ * @returns A new AgentMcpConfig
68
+ *
69
+ * example:
70
+ * ```typescript
71
+ * const tool = new Tool({
72
+ * id: 'tool-id',
73
+ * name: 'Tool Name',
74
+ * serverUrl: 'https://example.com/mcp',
75
+ * });
76
+ * const agentMcpConfig = tool.with({ selectedTools: ['tool-1', 'tool-2'], headers: { 'Authorization': 'Bearer token' } });
77
+ * ```
78
+ */
79
+ with(config: AgentMcpConfigInput): AgentMcpConfig;
62
80
  }
63
81
 
64
82
  declare class SubAgent implements SubAgentInterface {
@@ -83,12 +101,13 @@ declare class SubAgent implements SubAgentInterface {
83
101
  getTransfers(): SubAgentInterface[];
84
102
  getSubAgentDelegates(): SubAgentInterface[];
85
103
  getExternalAgentDelegates(): subAgentExternalAgentInterface[];
86
- getDelegates(): AllSubAgentInterface[];
104
+ getTeamAgentDelegates(): subAgentTeamAgentInterface[];
105
+ getDelegates(): AllDelegateOutputInterface[];
87
106
  getDataComponents(): DataComponentApiInsert[];
88
107
  getArtifactComponents(): ArtifactComponentApiInsert[];
89
108
  addTool(_name: string, tool: Tool): void;
90
109
  addTransfer(...agents: SubAgentInterface[]): void;
91
- addDelegate(...agents: AllSubAgentInterface[]): void;
110
+ addDelegate(...agents: AllDelegateInputInterface[]): void;
92
111
  init(): Promise<void>;
93
112
  private upsertAgent;
94
113
  private saveToolsAndRelations;
@@ -148,6 +167,15 @@ type AgentMcpConfig = {
148
167
  selectedTools?: string[];
149
168
  headers?: Record<string, string>;
150
169
  };
170
+ /**
171
+ * Input configuration for MCP tool customization
172
+ */
173
+ type AgentMcpConfigInput = {
174
+ /** Specific tools to enable from the MCP server */
175
+ selectedTools?: string[];
176
+ /** Custom headers for MCP server requests */
177
+ headers?: Record<string, string>;
178
+ };
151
179
  /**
152
180
  * Creates a transfer configuration for agent transfers.
153
181
  *
@@ -347,13 +375,14 @@ interface ToolResult {
347
375
  result: any;
348
376
  error?: string;
349
377
  }
350
- type AllSubAgentInterface = SubAgentInterface | subAgentExternalAgentInterface | ExternalAgentInterface;
378
+ type AllDelegateInputInterface = SubAgentInterface | subAgentExternalAgentInterface | ExternalAgentInterface | AgentInterface | subAgentTeamAgentInterface;
379
+ type AllDelegateOutputInterface = SubAgentInterface | subAgentExternalAgentInterface | subAgentTeamAgentInterface;
351
380
  type SubAgentCanUseType = Tool | AgentMcpConfig | FunctionTool;
352
381
  interface SubAgentConfig extends Omit<SubAgentApiInsert, 'projectId'> {
353
382
  type?: 'internal';
354
383
  canUse?: () => SubAgentCanUseType[];
355
384
  canTransferTo?: () => SubAgentInterface[];
356
- canDelegateTo?: () => AllSubAgentInterface[];
385
+ canDelegateTo?: () => AllDelegateInputInterface[];
357
386
  dataComponents?: () => (DataComponentApiInsert | DataComponentInterface | DataComponentWithZodProps)[];
358
387
  artifactComponents?: () => (ArtifactComponentApiInsert | ArtifactComponentInterface | ArtifactComponentWithZodProps)[];
359
388
  conversationHistoryConfig?: AgentConversationHistoryConfig;
@@ -462,7 +491,7 @@ interface AgentConfig {
462
491
  id: string;
463
492
  name?: string;
464
493
  description?: string;
465
- defaultSubAgent?: SubAgentInterface;
494
+ defaultSubAgent: SubAgentInterface;
466
495
  subAgents?: () => SubAgentInterface[];
467
496
  contextConfig?: any;
468
497
  credentials?: () => CredentialReferenceApiInsert[];
@@ -499,7 +528,7 @@ interface SubAgentInterface {
499
528
  getInstructions(): string;
500
529
  getTools(): Record<string, AgentTool>;
501
530
  getTransfers(): SubAgentInterface[];
502
- getDelegates(): AllSubAgentInterface[];
531
+ getDelegates(): AllDelegateOutputInterface[];
503
532
  getSubAgentDelegates(): SubAgentInterface[];
504
533
  getExternalAgentDelegates(): subAgentExternalAgentInterface[];
505
534
  getDataComponents(): DataComponentApiInsert[];
@@ -507,7 +536,7 @@ interface SubAgentInterface {
507
536
  setContext(tenantId: string, projectId: string, baseURL?: string): void;
508
537
  addTool(name: string, tool: any): void;
509
538
  addTransfer(...agents: SubAgentInterface[]): void;
510
- addDelegate(...agents: AllSubAgentInterface[]): void;
539
+ addDelegate(...agents: AllDelegateInputInterface[]): void;
511
540
  }
512
541
  interface ExternalAgentInterface {
513
542
  config: ExternalAgentConfig;
@@ -518,6 +547,9 @@ interface ExternalAgentInterface {
518
547
  getDescription(): string;
519
548
  getBaseUrl(): string;
520
549
  setContext?(tenantId: string, projectId: string): void;
550
+ with(options: {
551
+ headers?: Record<string, string>;
552
+ }): subAgentExternalAgentInterface;
521
553
  getCredentialReferenceId(): string | undefined;
522
554
  getCredentialReference(): CredentialReferenceApiInsert | undefined;
523
555
  }
@@ -525,6 +557,10 @@ type subAgentExternalAgentInterface = {
525
557
  externalAgent: ExternalAgentInterface;
526
558
  headers?: Record<string, string>;
527
559
  };
560
+ type subAgentTeamAgentInterface = {
561
+ agent: AgentInterface;
562
+ headers?: Record<string, string>;
563
+ };
528
564
  interface AgentInterface {
529
565
  init(): Promise<void>;
530
566
  setConfig(tenantId: string, projectId: string, apiUrl: string): void;
@@ -539,6 +575,9 @@ interface AgentInterface {
539
575
  getSubAgent(name: string): SubAgentInterface | undefined;
540
576
  getSubAgents(): SubAgentInterface[];
541
577
  toFullAgentDefinition(): Promise<FullAgentDefinition>;
578
+ with(options: {
579
+ headers?: Record<string, string>;
580
+ }): subAgentTeamAgentInterface;
542
581
  }
543
582
  interface BuilderToolConfig {
544
583
  name: string;
@@ -686,6 +725,9 @@ declare class Agent implements AgentInterface {
686
725
  agentId: string;
687
726
  tenantId: string;
688
727
  };
728
+ with(options: {
729
+ headers?: Record<string, string>;
730
+ }): subAgentTeamAgentInterface;
689
731
  /**
690
732
  * Validate the agent configuration
691
733
  */
@@ -697,7 +739,7 @@ declare class Agent implements AgentInterface {
697
739
  /**
698
740
  * Type guard to check if an agent is an internal AgentInterface
699
741
  */
700
- isInternalAgent(agent: AllSubAgentInterface): agent is SubAgentInterface;
742
+ isInternalAgent(agent: AllDelegateInputInterface): agent is SubAgentInterface;
701
743
  /**
702
744
  * Get project-level model settingsuration defaults
703
745
  */
@@ -1172,6 +1214,14 @@ declare function dataComponent(config: DataComponentConfig): DataComponent;
1172
1214
  * ```
1173
1215
  */
1174
1216
  declare function statusComponent(config: StatusComponentConfig): StatusComponent;
1217
+ /**
1218
+ * (deprecated in favor of mcpTool.with()) Creates an agent MCP configuration.
1219
+ *
1220
+ * Agent MCP configurations are used to configure the MCP server for an agent.
1221
+ *
1222
+ * @param config - Agent MCP configuration
1223
+ * @returns An AgentMcpConfig instance
1224
+ */
1175
1225
  declare function agentMcp(config: AgentMcpConfig): AgentMcpConfig;
1176
1226
  /**
1177
1227
  * Creates a function tool that executes user-defined code in a sandboxed environment.
@@ -1339,4 +1389,4 @@ declare const run: typeof Runner.run;
1339
1389
  declare const stream: typeof Runner.stream;
1340
1390
  declare const raceAgents: typeof Runner.raceAgents;
1341
1391
 
1342
- export { type AgentConfig, AgentError, type AgentInterface, type AgentResponse, type AgentTool, type AllSubAgentInterface, ArtifactComponent, type ArtifactComponentInterface, type ArtifactComponentWithZodProps, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, type CredentialReference, DataComponent, type DataComponentInterface, type DataComponentWithZodProps, ExternalAgent, type ExternalAgentInterface, type ExtractCredentialIds, type FetchDefinitionConfig, FunctionTool, type GenerateOptions, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, Project, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, StatusComponent, type StatusComponentInterface, type StreamEvent, type StreamResponse, SubAgent, type SubAgentCanUseType, type SubAgentConfig, type SubAgentInterface, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UnionCredentialIds, type UserMessage, agent, agentMcp, artifactComponent, createEnvironmentSettings, createFullProjectViaAPI, credential, credentialRef, dataComponent, deleteFullProjectViaAPI, externalAgent, externalAgents, functionTool, getFullProjectViaAPI, isCredentialReference, mcpServer, mcpTool, project, raceAgents, registerEnvironmentSettings, run, statusComponent, stream, subAgent, type subAgentExternalAgentInterface, transfer, updateFullProjectViaAPI };
1392
+ export { type AgentConfig, AgentError, type AgentInterface, type AgentResponse, type AgentTool, type AllDelegateInputInterface, type AllDelegateOutputInterface, ArtifactComponent, type ArtifactComponentInterface, type ArtifactComponentWithZodProps, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, type CredentialReference, DataComponent, type DataComponentInterface, type DataComponentWithZodProps, ExternalAgent, type ExternalAgentInterface, type ExtractCredentialIds, type FetchDefinitionConfig, FunctionTool, type GenerateOptions, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, Project, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, StatusComponent, type StatusComponentInterface, type StreamEvent, type StreamResponse, SubAgent, type SubAgentCanUseType, type SubAgentConfig, type SubAgentInterface, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UnionCredentialIds, type UserMessage, agent, agentMcp, artifactComponent, createEnvironmentSettings, createFullProjectViaAPI, credential, credentialRef, dataComponent, deleteFullProjectViaAPI, externalAgent, externalAgents, functionTool, getFullProjectViaAPI, isCredentialReference, mcpServer, mcpTool, project, raceAgents, registerEnvironmentSettings, run, statusComponent, stream, subAgent, type subAgentExternalAgentInterface, type subAgentTeamAgentInterface, transfer, updateFullProjectViaAPI };
package/dist/index.js CHANGED
@@ -487,7 +487,12 @@ var Agent = class {
487
487
  this.subAgents = resolveGetter(config.subAgents) || [];
488
488
  this.agentMap = new Map(this.subAgents.map((agent2) => [agent2.getId(), agent2]));
489
489
  if (this.defaultSubAgent) {
490
- this.subAgents.push(this.defaultSubAgent);
490
+ const isAlreadyPresent = this.subAgents.some(
491
+ (agent2) => agent2.getId() === this.defaultSubAgent?.getId()
492
+ );
493
+ if (!isAlreadyPresent) {
494
+ this.subAgents.push(this.defaultSubAgent);
495
+ }
491
496
  this.agentMap.set(this.defaultSubAgent.getId(), this.defaultSubAgent);
492
497
  }
493
498
  if (this.models) {
@@ -628,9 +633,10 @@ var Agent = class {
628
633
  externalAgentId: d.externalAgent.getId(),
629
634
  ...d.headers && { headers: d.headers }
630
635
  };
631
- } else if (typeof d === "object" && "type" in d && d.type === "external") {
636
+ } else if (typeof d === "object" && "agent" in d) {
632
637
  return {
633
- externalAgentId: d.getId()
638
+ agentId: d.agent.getId(),
639
+ ...d.headers && { headers: d.headers }
634
640
  };
635
641
  }
636
642
  return d.getId();
@@ -1010,6 +1016,12 @@ var Agent = class {
1010
1016
  tenantId: this.tenantId
1011
1017
  };
1012
1018
  }
1019
+ with(options) {
1020
+ return {
1021
+ agent: this,
1022
+ headers: options.headers
1023
+ };
1024
+ }
1013
1025
  /**
1014
1026
  * Validate the agent configuration
1015
1027
  */
@@ -2717,6 +2729,29 @@ var Tool = class {
2717
2729
  }
2718
2730
  throw new Error(`Failed to update tool: ${updateResponse.status}`);
2719
2731
  }
2732
+ /**
2733
+ * Creates a new AgentMcpConfig with the given configuration.
2734
+ *
2735
+ * @param config - The configuration for the AgentMcpConfig
2736
+ * @returns A new AgentMcpConfig
2737
+ *
2738
+ * example:
2739
+ * ```typescript
2740
+ * const tool = new Tool({
2741
+ * id: 'tool-id',
2742
+ * name: 'Tool Name',
2743
+ * serverUrl: 'https://example.com/mcp',
2744
+ * });
2745
+ * const agentMcpConfig = tool.with({ selectedTools: ['tool-1', 'tool-2'], headers: { 'Authorization': 'Bearer token' } });
2746
+ * ```
2747
+ */
2748
+ with(config) {
2749
+ return {
2750
+ server: this,
2751
+ selectedTools: config.selectedTools,
2752
+ headers: config.headers
2753
+ };
2754
+ }
2720
2755
  };
2721
2756
 
2722
2757
  // src/utils/tool-normalization.ts
@@ -2844,6 +2879,12 @@ var SubAgent = class {
2844
2879
  if (typeof delegate === "object" && "externalAgent" in delegate) {
2845
2880
  return false;
2846
2881
  }
2882
+ if (typeof delegate === "object" && "agent" in delegate) {
2883
+ return false;
2884
+ }
2885
+ if (typeof delegate === "object" && "toFullAgentDefinition" in delegate) {
2886
+ return false;
2887
+ }
2847
2888
  if (typeof delegate === "object" && "type" in delegate && delegate.type === "external") {
2848
2889
  return false;
2849
2890
  }
@@ -2872,8 +2913,34 @@ var SubAgent = class {
2872
2913
  };
2873
2914
  });
2874
2915
  }
2916
+ getTeamAgentDelegates() {
2917
+ if (typeof this.config.canDelegateTo !== "function") {
2918
+ return [];
2919
+ }
2920
+ return this.config.canDelegateTo().filter((delegate) => {
2921
+ if (typeof delegate === "object" && "agent" in delegate) {
2922
+ return true;
2923
+ }
2924
+ if (typeof delegate === "object" && "toFullAgentDefinition" in delegate) {
2925
+ return true;
2926
+ }
2927
+ return false;
2928
+ }).map((delegate) => {
2929
+ if ("agent" in delegate) {
2930
+ return delegate;
2931
+ }
2932
+ return {
2933
+ agent: delegate,
2934
+ headers: void 0
2935
+ };
2936
+ });
2937
+ }
2875
2938
  getDelegates() {
2876
- return typeof this.config.canDelegateTo === "function" ? this.config.canDelegateTo() : [];
2939
+ return [
2940
+ ...this.getSubAgentDelegates(),
2941
+ ...this.getTeamAgentDelegates(),
2942
+ ...this.getExternalAgentDelegates()
2943
+ ];
2877
2944
  }
2878
2945
  getDataComponents() {
2879
2946
  const components = resolveGetter2(this.config.dataComponents) || [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-sdk",
3
- "version": "0.26.2",
3
+ "version": "0.27.0",
4
4
  "description": "Agents SDK for building and managing agents in the Inkeep Agent Framework",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -12,7 +12,7 @@
12
12
  "nanoid": "^5.1.5",
13
13
  "typescript": "^5.3.3",
14
14
  "zod": "^4.1.11",
15
- "@inkeep/agents-core": "^0.26.2"
15
+ "@inkeep/agents-core": "^0.27.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/js-yaml": "^4.0.9",