@inkeep/agents-sdk 0.37.0 → 0.37.1

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,12 @@ var Tool = class {
2772
2777
  * ```
2773
2778
  */
2774
2779
  with(config) {
2780
+ const { selectedTools, toolPolicies } = agentsCore.normalizeToolSelections(config.selectedTools);
2775
2781
  return {
2776
2782
  server: this,
2777
- selectedTools: config.selectedTools,
2778
- headers: config.headers
2783
+ selectedTools,
2784
+ headers: config.headers,
2785
+ toolPolicies
2779
2786
  };
2780
2787
  }
2781
2788
  };
@@ -2794,6 +2801,7 @@ function normalizeAgentCanUseType(value, fallbackName) {
2794
2801
  toolId: value.server.getId(),
2795
2802
  selectedTools: value.selectedTools,
2796
2803
  headers: value.headers,
2804
+ toolPolicies: value.toolPolicies,
2797
2805
  isWrapped: true
2798
2806
  };
2799
2807
  }
@@ -2880,6 +2888,7 @@ var SubAgent = class {
2880
2888
  toolInstance = tool.server;
2881
2889
  toolInstance.selectedTools = tool.selectedTools;
2882
2890
  toolInstance.headers = tool.headers;
2891
+ toolInstance.toolPolicies = tool.toolPolicies;
2883
2892
  } else {
2884
2893
  toolInstance = tool;
2885
2894
  id = toolInstance.getId();
@@ -3433,11 +3442,13 @@ var SubAgent = class {
3433
3442
  let tool;
3434
3443
  let selectedTools;
3435
3444
  let headers;
3445
+ let toolPolicies;
3436
3446
  try {
3437
3447
  const normalizedTool = normalizeAgentCanUseType(toolConfig, toolId);
3438
3448
  tool = normalizedTool.tool;
3439
3449
  selectedTools = normalizedTool.selectedTools;
3440
3450
  headers = normalizedTool.headers;
3451
+ toolPolicies = normalizedTool.toolPolicies;
3441
3452
  tool.setContext(this.tenantId, this.projectId);
3442
3453
  await tool.init();
3443
3454
  } catch (_) {
@@ -3452,7 +3463,7 @@ var SubAgent = class {
3452
3463
  tool.setContext(this.tenantId, this.projectId);
3453
3464
  await tool.init();
3454
3465
  }
3455
- await this.createAgentToolRelation(tool.getId(), selectedTools, headers);
3466
+ await this.createAgentToolRelation(tool.getId(), selectedTools, headers, toolPolicies);
3456
3467
  logger11.info(
3457
3468
  {
3458
3469
  subAgentId: this.getId(),
@@ -3591,7 +3602,7 @@ var SubAgent = class {
3591
3602
  "Created agent-artifactComponent relation"
3592
3603
  );
3593
3604
  }
3594
- async createAgentToolRelation(toolId, selectedTools, headers) {
3605
+ async createAgentToolRelation(toolId, selectedTools, headers, toolPolicies) {
3595
3606
  const relationData = {
3596
3607
  id: `${this.getId()}-tool-${toolId}`,
3597
3608
  tenantId: this.tenantId,
@@ -3605,6 +3616,9 @@ var SubAgent = class {
3605
3616
  if (headers !== void 0) {
3606
3617
  relationData.headers = headers;
3607
3618
  }
3619
+ if (toolPolicies !== void 0 && Object.keys(toolPolicies).length > 0) {
3620
+ relationData.toolPolicies = toolPolicies;
3621
+ }
3608
3622
  const relationResponse = await fetch(
3609
3623
  `${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent-tool-relations`,
3610
3624
  {
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,15 @@ 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
+ /** Tools to enable from the MCP server - can be strings or objects with policies */
181
+ selectedTools?: McpToolSelection[];
180
182
  /** Custom headers for MCP server requests */
181
183
  headers?: Record<string, string>;
182
184
  };
@@ -347,9 +349,11 @@ interface DataComponentWithZodProps {
347
349
  type AgentTool = (Tool & {
348
350
  selectedTools?: string[];
349
351
  headers?: Record<string, string>;
352
+ toolPolicies?: Record<string, ToolPolicy>;
350
353
  }) | (FunctionTool & {
351
354
  selectedTools?: string[];
352
355
  headers?: Record<string, string>;
356
+ toolPolicies?: Record<string, ToolPolicy>;
353
357
  });
354
358
  interface UserMessage {
355
359
  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,15 @@ 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
+ /** Tools to enable from the MCP server - can be strings or objects with policies */
181
+ selectedTools?: McpToolSelection[];
180
182
  /** Custom headers for MCP server requests */
181
183
  headers?: Record<string, string>;
182
184
  };
@@ -347,9 +349,11 @@ interface DataComponentWithZodProps {
347
349
  type AgentTool = (Tool & {
348
350
  selectedTools?: string[];
349
351
  headers?: Record<string, string>;
352
+ toolPolicies?: Record<string, ToolPolicy>;
350
353
  }) | (FunctionTool & {
351
354
  selectedTools?: string[];
352
355
  headers?: Record<string, string>;
356
+ toolPolicies?: Record<string, ToolPolicy>;
353
357
  });
354
358
  interface UserMessage {
355
359
  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,12 @@ var Tool = class {
2745
2750
  * ```
2746
2751
  */
2747
2752
  with(config) {
2753
+ const { selectedTools, toolPolicies } = normalizeToolSelections(config.selectedTools);
2748
2754
  return {
2749
2755
  server: this,
2750
- selectedTools: config.selectedTools,
2751
- headers: config.headers
2756
+ selectedTools,
2757
+ headers: config.headers,
2758
+ toolPolicies
2752
2759
  };
2753
2760
  }
2754
2761
  };
@@ -2767,6 +2774,7 @@ function normalizeAgentCanUseType(value, fallbackName) {
2767
2774
  toolId: value.server.getId(),
2768
2775
  selectedTools: value.selectedTools,
2769
2776
  headers: value.headers,
2777
+ toolPolicies: value.toolPolicies,
2770
2778
  isWrapped: true
2771
2779
  };
2772
2780
  }
@@ -2853,6 +2861,7 @@ var SubAgent = class {
2853
2861
  toolInstance = tool.server;
2854
2862
  toolInstance.selectedTools = tool.selectedTools;
2855
2863
  toolInstance.headers = tool.headers;
2864
+ toolInstance.toolPolicies = tool.toolPolicies;
2856
2865
  } else {
2857
2866
  toolInstance = tool;
2858
2867
  id = toolInstance.getId();
@@ -3406,11 +3415,13 @@ var SubAgent = class {
3406
3415
  let tool;
3407
3416
  let selectedTools;
3408
3417
  let headers;
3418
+ let toolPolicies;
3409
3419
  try {
3410
3420
  const normalizedTool = normalizeAgentCanUseType(toolConfig, toolId);
3411
3421
  tool = normalizedTool.tool;
3412
3422
  selectedTools = normalizedTool.selectedTools;
3413
3423
  headers = normalizedTool.headers;
3424
+ toolPolicies = normalizedTool.toolPolicies;
3414
3425
  tool.setContext(this.tenantId, this.projectId);
3415
3426
  await tool.init();
3416
3427
  } catch (_) {
@@ -3425,7 +3436,7 @@ var SubAgent = class {
3425
3436
  tool.setContext(this.tenantId, this.projectId);
3426
3437
  await tool.init();
3427
3438
  }
3428
- await this.createAgentToolRelation(tool.getId(), selectedTools, headers);
3439
+ await this.createAgentToolRelation(tool.getId(), selectedTools, headers, toolPolicies);
3429
3440
  logger11.info(
3430
3441
  {
3431
3442
  subAgentId: this.getId(),
@@ -3564,7 +3575,7 @@ var SubAgent = class {
3564
3575
  "Created agent-artifactComponent relation"
3565
3576
  );
3566
3577
  }
3567
- async createAgentToolRelation(toolId, selectedTools, headers) {
3578
+ async createAgentToolRelation(toolId, selectedTools, headers, toolPolicies) {
3568
3579
  const relationData = {
3569
3580
  id: `${this.getId()}-tool-${toolId}`,
3570
3581
  tenantId: this.tenantId,
@@ -3578,6 +3589,9 @@ var SubAgent = class {
3578
3589
  if (headers !== void 0) {
3579
3590
  relationData.headers = headers;
3580
3591
  }
3592
+ if (toolPolicies !== void 0 && Object.keys(toolPolicies).length > 0) {
3593
+ relationData.toolPolicies = toolPolicies;
3594
+ }
3581
3595
  const relationResponse = await fetch(
3582
3596
  `${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent-tool-relations`,
3583
3597
  {
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.1",
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.1"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/js-yaml": "^4.0.9",