@inkeep/agents-sdk 0.37.0 → 0.37.2

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
@@ -778,6 +778,7 @@ var Agent = class {
778
778
  const tools = [];
779
779
  const selectedToolsMapping = {};
780
780
  const headersMapping = {};
781
+ const toolPoliciesMapping = {};
781
782
  const subAgentTools = subAgent2.getTools();
782
783
  for (const [_toolName, toolInstance] of Object.entries(subAgentTools)) {
783
784
  const toolId = toolInstance.getId();
@@ -787,6 +788,9 @@ var Agent = class {
787
788
  if (toolInstance.headers) {
788
789
  headersMapping[toolId] = toolInstance.headers;
789
790
  }
791
+ if (toolInstance.toolPolicies) {
792
+ toolPoliciesMapping[toolId] = toolInstance.toolPolicies;
793
+ }
790
794
  tools.push(toolId);
791
795
  if (toolInstance.constructor.name === "FunctionTool" && toolInstance instanceof FunctionTool) {
792
796
  if (!functionsObject[toolId]) {
@@ -837,7 +841,8 @@ var Agent = class {
837
841
  const canUse = tools.map((toolId) => ({
838
842
  toolId,
839
843
  toolSelection: selectedToolsMapping[toolId] || null,
840
- headers: headersMapping[toolId] || null
844
+ headers: headersMapping[toolId] || null,
845
+ toolPolicies: toolPoliciesMapping[toolId] || null
841
846
  }));
842
847
  subAgentsObject[subAgent2.getId()] = {
843
848
  id: subAgent2.getId(),
@@ -2772,10 +2777,15 @@ var Tool = class {
2772
2777
  * ```
2773
2778
  */
2774
2779
  with(config) {
2780
+ const { selectedTools, toolPolicies } = agentsCore.normalizeToolSelections(config.selectedTools ?? void 0);
2781
+ const isUnspecified = config.selectedTools === void 0 || config.selectedTools === null;
2782
+ const resolvedSelectedTools = isUnspecified ? void 0 : selectedTools;
2783
+ const resolvedToolPolicies = isUnspecified || Object.keys(toolPolicies).length === 0 ? void 0 : toolPolicies;
2775
2784
  return {
2776
2785
  server: this,
2777
- selectedTools: config.selectedTools,
2778
- headers: config.headers
2786
+ selectedTools: resolvedSelectedTools,
2787
+ headers: config.headers,
2788
+ toolPolicies: resolvedToolPolicies
2779
2789
  };
2780
2790
  }
2781
2791
  };
@@ -2794,6 +2804,7 @@ function normalizeAgentCanUseType(value, fallbackName) {
2794
2804
  toolId: value.server.getId(),
2795
2805
  selectedTools: value.selectedTools,
2796
2806
  headers: value.headers,
2807
+ toolPolicies: value.toolPolicies,
2797
2808
  isWrapped: true
2798
2809
  };
2799
2810
  }
@@ -2880,6 +2891,7 @@ var SubAgent = class {
2880
2891
  toolInstance = tool.server;
2881
2892
  toolInstance.selectedTools = tool.selectedTools;
2882
2893
  toolInstance.headers = tool.headers;
2894
+ toolInstance.toolPolicies = tool.toolPolicies;
2883
2895
  } else {
2884
2896
  toolInstance = tool;
2885
2897
  id = toolInstance.getId();
@@ -3433,11 +3445,13 @@ var SubAgent = class {
3433
3445
  let tool;
3434
3446
  let selectedTools;
3435
3447
  let headers;
3448
+ let toolPolicies;
3436
3449
  try {
3437
3450
  const normalizedTool = normalizeAgentCanUseType(toolConfig, toolId);
3438
3451
  tool = normalizedTool.tool;
3439
3452
  selectedTools = normalizedTool.selectedTools;
3440
3453
  headers = normalizedTool.headers;
3454
+ toolPolicies = normalizedTool.toolPolicies;
3441
3455
  tool.setContext(this.tenantId, this.projectId);
3442
3456
  await tool.init();
3443
3457
  } catch (_) {
@@ -3452,7 +3466,7 @@ var SubAgent = class {
3452
3466
  tool.setContext(this.tenantId, this.projectId);
3453
3467
  await tool.init();
3454
3468
  }
3455
- await this.createAgentToolRelation(tool.getId(), selectedTools, headers);
3469
+ await this.createAgentToolRelation(tool.getId(), selectedTools, headers, toolPolicies);
3456
3470
  logger11.info(
3457
3471
  {
3458
3472
  subAgentId: this.getId(),
@@ -3591,7 +3605,7 @@ var SubAgent = class {
3591
3605
  "Created agent-artifactComponent relation"
3592
3606
  );
3593
3607
  }
3594
- async createAgentToolRelation(toolId, selectedTools, headers) {
3608
+ async createAgentToolRelation(toolId, selectedTools, headers, toolPolicies) {
3595
3609
  const relationData = {
3596
3610
  id: `${this.getId()}-tool-${toolId}`,
3597
3611
  tenantId: this.tenantId,
@@ -3605,6 +3619,9 @@ var SubAgent = class {
3605
3619
  if (headers !== void 0) {
3606
3620
  relationData.headers = headers;
3607
3621
  }
3622
+ if (toolPolicies !== void 0 && Object.keys(toolPolicies).length > 0) {
3623
+ relationData.toolPolicies = toolPolicies;
3624
+ }
3608
3625
  const relationResponse = await fetch(
3609
3626
  `${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent-tool-relations`,
3610
3627
  {
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
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';
1
+ import { ArtifactComponentInsert, MCPToolConfig as MCPToolConfig$1, DataComponentApiInsert, ArtifactComponentApiInsert, McpToolSelection, ToolPolicy, 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
 
@@ -170,13 +170,20 @@ type AgentMcpConfig = {
170
170
  server: Tool;
171
171
  selectedTools?: string[];
172
172
  headers?: Record<string, string>;
173
+ toolPolicies?: Record<string, ToolPolicy>;
173
174
  };
174
175
  /**
175
176
  * Input configuration for MCP tool customization
177
+ * Supports flexible tool selection with per-tool policies
176
178
  */
177
179
  type AgentMcpConfigInput = {
178
- /** Specific tools to enable from the MCP server */
179
- selectedTools?: string[];
180
+ /**
181
+ * Tools to enable from the MCP server - can be strings or objects with policies
182
+ * - undefined or null: all tools enabled (no filtering)
183
+ * - []: zero tools enabled (explicit empty selection)
184
+ * - ['tool1', 'tool2']: specific tools enabled
185
+ */
186
+ selectedTools?: McpToolSelection[] | null;
180
187
  /** Custom headers for MCP server requests */
181
188
  headers?: Record<string, string>;
182
189
  };
@@ -347,9 +354,11 @@ interface DataComponentWithZodProps {
347
354
  type AgentTool = (Tool & {
348
355
  selectedTools?: string[];
349
356
  headers?: Record<string, string>;
357
+ toolPolicies?: Record<string, ToolPolicy>;
350
358
  }) | (FunctionTool & {
351
359
  selectedTools?: string[];
352
360
  headers?: Record<string, string>;
361
+ toolPolicies?: Record<string, ToolPolicy>;
353
362
  });
354
363
  interface UserMessage {
355
364
  role: 'user';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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';
1
+ import { ArtifactComponentInsert, MCPToolConfig as MCPToolConfig$1, DataComponentApiInsert, ArtifactComponentApiInsert, McpToolSelection, ToolPolicy, 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
 
@@ -170,13 +170,20 @@ type AgentMcpConfig = {
170
170
  server: Tool;
171
171
  selectedTools?: string[];
172
172
  headers?: Record<string, string>;
173
+ toolPolicies?: Record<string, ToolPolicy>;
173
174
  };
174
175
  /**
175
176
  * Input configuration for MCP tool customization
177
+ * Supports flexible tool selection with per-tool policies
176
178
  */
177
179
  type AgentMcpConfigInput = {
178
- /** Specific tools to enable from the MCP server */
179
- selectedTools?: string[];
180
+ /**
181
+ * Tools to enable from the MCP server - can be strings or objects with policies
182
+ * - undefined or null: all tools enabled (no filtering)
183
+ * - []: zero tools enabled (explicit empty selection)
184
+ * - ['tool1', 'tool2']: specific tools enabled
185
+ */
186
+ selectedTools?: McpToolSelection[] | null;
180
187
  /** Custom headers for MCP server requests */
181
188
  headers?: Record<string, string>;
182
189
  };
@@ -347,9 +354,11 @@ interface DataComponentWithZodProps {
347
354
  type AgentTool = (Tool & {
348
355
  selectedTools?: string[];
349
356
  headers?: Record<string, string>;
357
+ toolPolicies?: Record<string, ToolPolicy>;
350
358
  }) | (FunctionTool & {
351
359
  selectedTools?: string[];
352
360
  headers?: Record<string, string>;
361
+ toolPolicies?: Record<string, ToolPolicy>;
353
362
  });
354
363
  interface UserMessage {
355
364
  role: 'user';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getLogger, apiFetch, CredentialReferenceApiInsertSchema, MCPToolConfigSchema } from '@inkeep/agents-core';
1
+ import { getLogger, normalizeToolSelections, apiFetch, CredentialReferenceApiInsertSchema, MCPToolConfigSchema } from '@inkeep/agents-core';
2
2
  export { ANTHROPIC_MODELS, GOOGLE_MODELS, OPENAI_MODELS } from '@inkeep/agents-core';
3
3
  import { isZodSchema, convertZodToJsonSchemaWithPreview, convertZodToJsonSchema } from '@inkeep/agents-core/utils/schema-conversion';
4
4
  import fs from 'fs';
@@ -751,6 +751,7 @@ var Agent = class {
751
751
  const tools = [];
752
752
  const selectedToolsMapping = {};
753
753
  const headersMapping = {};
754
+ const toolPoliciesMapping = {};
754
755
  const subAgentTools = subAgent2.getTools();
755
756
  for (const [_toolName, toolInstance] of Object.entries(subAgentTools)) {
756
757
  const toolId = toolInstance.getId();
@@ -760,6 +761,9 @@ var Agent = class {
760
761
  if (toolInstance.headers) {
761
762
  headersMapping[toolId] = toolInstance.headers;
762
763
  }
764
+ if (toolInstance.toolPolicies) {
765
+ toolPoliciesMapping[toolId] = toolInstance.toolPolicies;
766
+ }
763
767
  tools.push(toolId);
764
768
  if (toolInstance.constructor.name === "FunctionTool" && toolInstance instanceof FunctionTool) {
765
769
  if (!functionsObject[toolId]) {
@@ -810,7 +814,8 @@ var Agent = class {
810
814
  const canUse = tools.map((toolId) => ({
811
815
  toolId,
812
816
  toolSelection: selectedToolsMapping[toolId] || null,
813
- headers: headersMapping[toolId] || null
817
+ headers: headersMapping[toolId] || null,
818
+ toolPolicies: toolPoliciesMapping[toolId] || null
814
819
  }));
815
820
  subAgentsObject[subAgent2.getId()] = {
816
821
  id: subAgent2.getId(),
@@ -2745,10 +2750,15 @@ var Tool = class {
2745
2750
  * ```
2746
2751
  */
2747
2752
  with(config) {
2753
+ const { selectedTools, toolPolicies } = normalizeToolSelections(config.selectedTools ?? void 0);
2754
+ const isUnspecified = config.selectedTools === void 0 || config.selectedTools === null;
2755
+ const resolvedSelectedTools = isUnspecified ? void 0 : selectedTools;
2756
+ const resolvedToolPolicies = isUnspecified || Object.keys(toolPolicies).length === 0 ? void 0 : toolPolicies;
2748
2757
  return {
2749
2758
  server: this,
2750
- selectedTools: config.selectedTools,
2751
- headers: config.headers
2759
+ selectedTools: resolvedSelectedTools,
2760
+ headers: config.headers,
2761
+ toolPolicies: resolvedToolPolicies
2752
2762
  };
2753
2763
  }
2754
2764
  };
@@ -2767,6 +2777,7 @@ function normalizeAgentCanUseType(value, fallbackName) {
2767
2777
  toolId: value.server.getId(),
2768
2778
  selectedTools: value.selectedTools,
2769
2779
  headers: value.headers,
2780
+ toolPolicies: value.toolPolicies,
2770
2781
  isWrapped: true
2771
2782
  };
2772
2783
  }
@@ -2853,6 +2864,7 @@ var SubAgent = class {
2853
2864
  toolInstance = tool.server;
2854
2865
  toolInstance.selectedTools = tool.selectedTools;
2855
2866
  toolInstance.headers = tool.headers;
2867
+ toolInstance.toolPolicies = tool.toolPolicies;
2856
2868
  } else {
2857
2869
  toolInstance = tool;
2858
2870
  id = toolInstance.getId();
@@ -3406,11 +3418,13 @@ var SubAgent = class {
3406
3418
  let tool;
3407
3419
  let selectedTools;
3408
3420
  let headers;
3421
+ let toolPolicies;
3409
3422
  try {
3410
3423
  const normalizedTool = normalizeAgentCanUseType(toolConfig, toolId);
3411
3424
  tool = normalizedTool.tool;
3412
3425
  selectedTools = normalizedTool.selectedTools;
3413
3426
  headers = normalizedTool.headers;
3427
+ toolPolicies = normalizedTool.toolPolicies;
3414
3428
  tool.setContext(this.tenantId, this.projectId);
3415
3429
  await tool.init();
3416
3430
  } catch (_) {
@@ -3425,7 +3439,7 @@ var SubAgent = class {
3425
3439
  tool.setContext(this.tenantId, this.projectId);
3426
3440
  await tool.init();
3427
3441
  }
3428
- await this.createAgentToolRelation(tool.getId(), selectedTools, headers);
3442
+ await this.createAgentToolRelation(tool.getId(), selectedTools, headers, toolPolicies);
3429
3443
  logger11.info(
3430
3444
  {
3431
3445
  subAgentId: this.getId(),
@@ -3564,7 +3578,7 @@ var SubAgent = class {
3564
3578
  "Created agent-artifactComponent relation"
3565
3579
  );
3566
3580
  }
3567
- async createAgentToolRelation(toolId, selectedTools, headers) {
3581
+ async createAgentToolRelation(toolId, selectedTools, headers, toolPolicies) {
3568
3582
  const relationData = {
3569
3583
  id: `${this.getId()}-tool-${toolId}`,
3570
3584
  tenantId: this.tenantId,
@@ -3578,6 +3592,9 @@ var SubAgent = class {
3578
3592
  if (headers !== void 0) {
3579
3593
  relationData.headers = headers;
3580
3594
  }
3595
+ if (toolPolicies !== void 0 && Object.keys(toolPolicies).length > 0) {
3596
+ relationData.toolPolicies = toolPolicies;
3597
+ }
3581
3598
  const relationResponse = await fetch(
3582
3599
  `${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent-tool-relations`,
3583
3600
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-sdk",
3
- "version": "0.37.0",
3
+ "version": "0.37.2",
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.37.0"
15
+ "@inkeep/agents-core": "^0.37.2"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/js-yaml": "^4.0.9",