@dexto/core 1.12.0 → 1.13.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.
Files changed (85) hide show
  1. package/dist/agent/DextoAgent.d.ts +2 -5
  2. package/dist/agent/DextoAgent.d.ts.map +1 -1
  3. package/dist/approval/index.cjs +4 -2
  4. package/dist/approval/index.d.ts +1 -1
  5. package/dist/approval/index.d.ts.map +1 -1
  6. package/dist/approval/index.js +3 -2
  7. package/dist/approval/manager.cjs +23 -4
  8. package/dist/approval/manager.d.ts +3 -2
  9. package/dist/approval/manager.d.ts.map +1 -1
  10. package/dist/approval/manager.js +21 -3
  11. package/dist/approval/schemas.cjs +5 -0
  12. package/dist/approval/schemas.d.ts +8 -0
  13. package/dist/approval/schemas.d.ts.map +1 -1
  14. package/dist/approval/schemas.js +5 -0
  15. package/dist/approval/types.d.ts +2 -2
  16. package/dist/approval/types.d.ts.map +1 -1
  17. package/dist/events/index.d.ts +2 -0
  18. package/dist/events/index.d.ts.map +1 -1
  19. package/dist/llm/executor/provider-options.cjs +6 -6
  20. package/dist/llm/executor/provider-options.d.ts.map +1 -1
  21. package/dist/llm/executor/provider-options.js +7 -8
  22. package/dist/llm/executor/turn-executor.cjs +13 -20
  23. package/dist/llm/executor/turn-executor.d.ts +0 -1
  24. package/dist/llm/executor/turn-executor.d.ts.map +1 -1
  25. package/dist/llm/executor/turn-executor.js +13 -20
  26. package/dist/mcp/errors.cjs +9 -0
  27. package/dist/mcp/errors.d.ts +4 -0
  28. package/dist/mcp/errors.d.ts.map +1 -1
  29. package/dist/mcp/errors.js +9 -0
  30. package/dist/mcp/manager.cjs +79 -3
  31. package/dist/mcp/manager.d.ts +14 -7
  32. package/dist/mcp/manager.d.ts.map +1 -1
  33. package/dist/mcp/manager.js +79 -3
  34. package/dist/mcp/mcp-client.cjs +52 -62
  35. package/dist/mcp/mcp-client.d.ts.map +1 -1
  36. package/dist/mcp/mcp-client.js +54 -63
  37. package/dist/storage/tool-executions/types.cjs +12 -8
  38. package/dist/storage/tool-executions/types.d.ts +9 -0
  39. package/dist/storage/tool-executions/types.d.ts.map +1 -1
  40. package/dist/storage/tool-executions/types.js +12 -8
  41. package/dist/telemetry/decorators.cjs +47 -23
  42. package/dist/telemetry/decorators.d.ts +6 -0
  43. package/dist/telemetry/decorators.d.ts.map +1 -1
  44. package/dist/telemetry/decorators.js +47 -23
  45. package/dist/telemetry/operation-span.cjs +5 -2
  46. package/dist/telemetry/operation-span.d.ts +3 -0
  47. package/dist/telemetry/operation-span.d.ts.map +1 -1
  48. package/dist/telemetry/operation-span.js +5 -2
  49. package/dist/tools/approval/tool-approval-policy.cjs +11 -1
  50. package/dist/tools/approval/tool-approval-policy.d.ts +2 -2
  51. package/dist/tools/approval/tool-approval-policy.d.ts.map +1 -1
  52. package/dist/tools/approval/tool-approval-policy.js +11 -1
  53. package/dist/tools/identity.cjs +36 -0
  54. package/dist/tools/identity.d.ts +6 -0
  55. package/dist/tools/identity.d.ts.map +1 -0
  56. package/dist/tools/identity.js +13 -0
  57. package/dist/tools/index.cjs +2 -0
  58. package/dist/tools/index.d.ts +2 -1
  59. package/dist/tools/index.d.ts.map +1 -1
  60. package/dist/tools/index.js +4 -1
  61. package/dist/tools/presentation/tool-presentation.d.ts +5 -0
  62. package/dist/tools/presentation/tool-presentation.d.ts.map +1 -1
  63. package/dist/tools/schema-fingerprint.cjs +48 -0
  64. package/dist/tools/schema-fingerprint.d.ts +4 -0
  65. package/dist/tools/schema-fingerprint.d.ts.map +1 -0
  66. package/dist/tools/schema-fingerprint.js +25 -0
  67. package/dist/tools/schemas.cjs +3 -0
  68. package/dist/tools/schemas.d.ts +1 -0
  69. package/dist/tools/schemas.d.ts.map +1 -1
  70. package/dist/tools/schemas.js +2 -0
  71. package/dist/tools/tool-manager.cjs +160 -43
  72. package/dist/tools/tool-manager.d.ts +20 -11
  73. package/dist/tools/tool-manager.d.ts.map +1 -1
  74. package/dist/tools/tool-manager.js +160 -43
  75. package/dist/tools/types.d.ts +48 -0
  76. package/dist/tools/types.d.ts.map +1 -1
  77. package/dist/utils/schema.cjs +2 -2
  78. package/dist/utils/schema.d.ts +1 -1
  79. package/dist/utils/schema.d.ts.map +1 -1
  80. package/dist/utils/schema.js +2 -2
  81. package/dist/utils/stable-fingerprint.cjs +32 -0
  82. package/dist/utils/stable-fingerprint.d.ts +3 -0
  83. package/dist/utils/stable-fingerprint.d.ts.map +1 -0
  84. package/dist/utils/stable-fingerprint.js +9 -0
  85. package/package.json +9 -2
@@ -9,6 +9,7 @@ import { ToolError } from "./errors.js";
9
9
  import { DextoRuntimeError, ErrorScope, ErrorType } from "../errors/index.js";
10
10
  import { DextoLogComponent } from "../logger/v2/types.js";
11
11
  import { convertZodSchemaToJsonSchema } from "../utils/schema.js";
12
+ import { toolSchemaFingerprint } from "./schema-fingerprint.js";
12
13
  import { ApprovalStatus, ApprovalType, DenialReason } from "../approval/types.js";
13
14
  import { ToolApprovalMetadataSchema, ToolApprovalResponseDataSchema } from "../approval/schemas.js";
14
15
  import { matchesToolPolicyPattern, SessionToolPolicy } from "./approval/session-tool-policy.js";
@@ -28,6 +29,9 @@ function isRecord(value) {
28
29
  return typeof value === "object" && value !== null && !Array.isArray(value);
29
30
  }
30
31
  _ToolManager_decorators = [InstrumentClass({
32
+ captureArguments: false,
33
+ captureErrors: false,
34
+ captureResult: false,
31
35
  prefix: "tool",
32
36
  excludeMethods: ["setHookSupport", "getApprovalManager", "getAllowedToolsProvider"]
33
37
  })];
@@ -538,15 +542,77 @@ let _ToolManager = class _ToolManager {
538
542
  async getMcpTools() {
539
543
  return await this.mcpManager.getAllTools();
540
544
  }
545
+ /**
546
+ * Return canonical tool descriptions for host-owned discovery and type generation.
547
+ * Unlike getAllTools(), schemas are not rewritten for model-provider compatibility.
548
+ */
549
+ async getToolDescriptors() {
550
+ const descriptors = [];
551
+ for (const tool of this.agentTools.values()) {
552
+ descriptors.push(await this.buildLocalToolDescriptor(tool));
553
+ }
554
+ for (const descriptor of this.mcpManager.getToolDescriptors()) {
555
+ descriptors.push(this.prefixMcpToolDescriptor(descriptor));
556
+ }
557
+ return descriptors;
558
+ }
559
+ async getToolDescriptor(toolName) {
560
+ const localTool = this.agentTools.get(toolName);
561
+ if (localTool !== void 0) {
562
+ return await this.buildLocalToolDescriptor(localTool);
563
+ }
564
+ if (!toolName.startsWith(_ToolManager.MCP_TOOL_PREFIX)) {
565
+ return void 0;
566
+ }
567
+ const mcpName = toolName.substring(_ToolManager.MCP_TOOL_PREFIX.length);
568
+ if (mcpName.length === 0) {
569
+ return void 0;
570
+ }
571
+ const descriptor = this.mcpManager.getToolDescriptor(mcpName);
572
+ return descriptor === void 0 ? void 0 : this.prefixMcpToolDescriptor(descriptor);
573
+ }
574
+ resolveToolIdentity(toolName) {
575
+ if (this.agentTools.has(toolName)) {
576
+ return { type: "local", toolId: toolName };
577
+ }
578
+ if (!toolName.startsWith(_ToolManager.MCP_TOOL_PREFIX)) {
579
+ return void 0;
580
+ }
581
+ const mcpName = toolName.substring(_ToolManager.MCP_TOOL_PREFIX.length);
582
+ return this.mcpManager.getToolDescriptor(mcpName)?.identity;
583
+ }
584
+ async buildLocalToolDescriptor(tool) {
585
+ const inputSchema = convertZodSchemaToJsonSchema(tool.inputSchema, this.logger);
586
+ const outputSchema = tool.outputSchema === void 0 ? void 0 : convertZodSchemaToJsonSchema(tool.outputSchema, this.logger, "output");
587
+ return {
588
+ name: tool.id,
589
+ description: await this.getLocalToolDescription(tool),
590
+ approval: this.approvalMode === "auto-approve" || tool.needsApproval === false || tool.needsApproval === null ? "never" : "possible",
591
+ identity: { type: "local", toolId: tool.id },
592
+ inputSchema,
593
+ ...outputSchema === void 0 ? {} : { outputSchema },
594
+ schemaFingerprint: toolSchemaFingerprint(inputSchema, outputSchema)
595
+ };
596
+ }
597
+ prefixMcpToolDescriptor(descriptor) {
598
+ return {
599
+ ...descriptor,
600
+ approval: this.approvalMode === "auto-approve" ? "never" : "possible",
601
+ name: `${_ToolManager.MCP_TOOL_PREFIX}${descriptor.name}`,
602
+ description: `${descriptor.description || "No description provided"} (via MCP servers)`
603
+ };
604
+ }
541
605
  buildToolExecutionContext(options) {
542
606
  const workspace = this.currentWorkspace;
543
607
  const baseContext = {
544
608
  sessionId: options.sessionId,
545
609
  runContext: options.runContext,
610
+ executionIdentity: options.executionIdentity,
546
611
  workspaceId: workspace?.id,
547
612
  workspace,
548
613
  abortSignal: options.abortSignal,
549
614
  toolCallId: options.toolCallId,
615
+ parentToolCallId: options.parentToolCallId,
550
616
  hostRuntime: options.runContext?.hostRuntime,
551
617
  logger: this.logger
552
618
  };
@@ -560,8 +626,14 @@ let _ToolManager = class _ToolManager {
560
626
  const sessionId = options.runContext?.sessionId ?? options.sessionId;
561
627
  return { ...options, sessionId, hostRuntime: options.runContext?.hostRuntime };
562
628
  }
563
- resolveToolExecutionIdentity(invocation, toolCallId) {
629
+ resolveToolExecutionIdentity(invocation, toolCallId, parentToolCallId) {
564
630
  if (invocation.executionIdentity !== void 0) {
631
+ if (invocation.executionIdentity.toolCallId !== toolCallId || invocation.executionIdentity.parentToolCallId !== parentToolCallId) {
632
+ throw ToolError.executionFailed(
633
+ toolCallId,
634
+ "Tool execution identity does not match the prepared call"
635
+ );
636
+ }
565
637
  return invocation.executionIdentity;
566
638
  }
567
639
  const ids = invocation.runContext?.hostRuntime?.ids;
@@ -578,6 +650,7 @@ let _ToolManager = class _ToolManager {
578
650
  runId,
579
651
  turnId,
580
652
  modelStepId,
653
+ ...parentToolCallId === void 0 ? {} : { parentToolCallId },
581
654
  toolCallId
582
655
  };
583
656
  }
@@ -623,6 +696,16 @@ let _ToolManager = class _ToolManager {
623
696
  }
624
697
  return validated;
625
698
  }
699
+ validateToolArgs(toolName, args) {
700
+ if (!toolName.startsWith(_ToolManager.MCP_TOOL_PREFIX)) {
701
+ return this.validateLocalToolArgs(toolName, args);
702
+ }
703
+ const mcpName = toolName.substring(_ToolManager.MCP_TOOL_PREFIX.length);
704
+ if (mcpName.length === 0) {
705
+ throw ToolError.invalidName(toolName, "tool name cannot be empty after prefix");
706
+ }
707
+ return this.mcpManager.validateToolInput(mcpName, args);
708
+ }
626
709
  async executeLocalTool(toolName, args, options) {
627
710
  const tool = this.agentTools.get(toolName);
628
711
  if (!tool) {
@@ -636,15 +719,15 @@ let _ToolManager = class _ToolManager {
636
719
  const context = this.buildToolExecutionContext({
637
720
  sessionId: options?.sessionId,
638
721
  abortSignal: options?.abortSignal,
722
+ executionIdentity: options?.executionIdentity,
639
723
  toolCallId: options?.toolCallId,
724
+ parentToolCallId: options?.parentToolCallId,
640
725
  runContext: options?.runContext
641
726
  });
642
727
  const result = await tool.execute(args, context);
643
728
  return result;
644
729
  } catch (error) {
645
- this.logger.error(`\u274C Local tool execution failed: ${toolName}`, {
646
- error: error instanceof Error ? error.message : String(error)
647
- });
730
+ this.logger.error(`Local tool execution failed: ${toolName}`);
648
731
  throw error;
649
732
  }
650
733
  }
@@ -673,21 +756,7 @@ let _ToolManager = class _ToolManager {
673
756
  mcpTools = {};
674
757
  }
675
758
  for (const [toolName, tool] of this.agentTools) {
676
- let description = tool.description || "No description provided";
677
- if (tool.getDescription) {
678
- try {
679
- const dynamicDescription = await tool.getDescription(
680
- this.buildToolExecutionContext({})
681
- );
682
- if (dynamicDescription.trim()) {
683
- description = dynamicDescription;
684
- }
685
- } catch (error) {
686
- this.logger.warn(
687
- `Failed to build dynamic description for '${toolName}': ${error instanceof Error ? error.message : String(error)}`
688
- );
689
- }
690
- }
759
+ const description = await this.getLocalToolDescription(tool);
691
760
  allTools[toolName] = {
692
761
  name: toolName,
693
762
  description,
@@ -713,6 +782,21 @@ let _ToolManager = class _ToolManager {
713
782
  );
714
783
  return allTools;
715
784
  }
785
+ async getLocalToolDescription(tool) {
786
+ const fallback = tool.description || "No description provided";
787
+ if (!tool.getDescription) {
788
+ return fallback;
789
+ }
790
+ try {
791
+ const description = await tool.getDescription(this.buildToolExecutionContext({}));
792
+ return description.trim() ? description : fallback;
793
+ } catch (error) {
794
+ this.logger.warn(
795
+ `Failed to build dynamic description for '${tool.id}': ${error instanceof Error ? error.message : String(error)}`
796
+ );
797
+ return fallback;
798
+ }
799
+ }
716
800
  /**
717
801
  * Get all available tools from all sources with conflict resolution
718
802
  * This is the single interface the LLM uses to discover tools
@@ -729,8 +813,8 @@ let _ToolManager = class _ToolManager {
729
813
  }
730
814
  async prepareToolCall(input) {
731
815
  const sessionId = input.runContext?.sessionId ?? input.sessionId;
732
- const source = await this.resolveExecutableToolSource(input.toolName);
733
- if (source === "unknown") {
816
+ const identity = this.resolveToolIdentity(input.toolName);
817
+ if (identity === void 0) {
734
818
  return this.createPreparedToolError(
735
819
  "unknown-tool",
736
820
  input.toolName,
@@ -749,7 +833,7 @@ let _ToolManager = class _ToolManager {
749
833
  const approvalDescription = typeof meta.callActivity?.running === "string" ? meta.callActivity.running : typeof rawToolArgs.description === "string" ? rawToolArgs.description : void 0;
750
834
  let validatedArgs;
751
835
  try {
752
- validatedArgs = this.validateLocalToolArgs(input.toolName, rawToolArgs);
836
+ validatedArgs = this.validateToolArgs(input.toolName, rawToolArgs);
753
837
  } catch (error) {
754
838
  return this.createPreparedToolError(
755
839
  "invalid-input",
@@ -761,13 +845,15 @@ let _ToolManager = class _ToolManager {
761
845
  toolName: input.toolName,
762
846
  args: validatedArgs,
763
847
  toolCallId: input.toolCallId,
848
+ ...input.parentToolCallId === void 0 ? {} : { parentToolCallId: input.parentToolCallId },
764
849
  ...sessionId !== void 0 ? { sessionId } : {},
765
850
  ...input.runContext !== void 0 ? { runContext: input.runContext } : {}
766
851
  });
767
852
  const call = {
853
+ identity,
768
854
  input: validatedArgs,
855
+ ...input.parentToolCallId === void 0 ? {} : { parentToolCallId: input.parentToolCallId },
769
856
  presentationSnapshot,
770
- source,
771
857
  toolCallId: input.toolCallId,
772
858
  toolName: input.toolName,
773
859
  ...eventMeta !== void 0 ? { meta: eventMeta } : {}
@@ -777,10 +863,11 @@ let _ToolManager = class _ToolManager {
777
863
  getContext: () => this.buildToolExecutionContext({
778
864
  sessionId,
779
865
  toolCallId: input.toolCallId,
866
+ parentToolCallId: input.parentToolCallId,
780
867
  runContext: input.runContext
781
868
  }),
782
869
  ...sessionId !== void 0 ? { sessionId } : {},
783
- source,
870
+ identity,
784
871
  toolName: input.toolName
785
872
  });
786
873
  if (approvalGate.kind === "ready") {
@@ -803,6 +890,7 @@ let _ToolManager = class _ToolManager {
803
890
  ...input.runContext !== void 0 ? { runContext: input.runContext } : {},
804
891
  ...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {},
805
892
  toolCallId: input.toolCallId,
893
+ ...input.call.parentToolCallId === void 0 ? {} : { parentToolCallId: input.call.parentToolCallId },
806
894
  toolName: input.toolName
807
895
  });
808
896
  const hostRuntime = input.runContext?.hostRuntime;
@@ -812,9 +900,11 @@ let _ToolManager = class _ToolManager {
812
900
  ...hostRuntime !== void 0 ? { hostRuntime } : {},
813
901
  metadata: {
814
902
  toolName: input.toolName,
903
+ toolIdentity: input.call.identity,
815
904
  ...input.approvalGate.approvalKey !== void 0 ? { approvalKey: input.approvalGate.approvalKey } : {},
816
905
  presentationSnapshot: input.call.presentationSnapshot,
817
906
  toolCallId: input.toolCallId,
907
+ ...input.call.parentToolCallId === void 0 ? {} : { parentToolCallId: input.call.parentToolCallId },
818
908
  args: input.args,
819
909
  ...input.approvalDescription !== void 0 ? { description: input.approvalDescription } : {},
820
910
  ...displayPreview !== void 0 ? { displayPreview } : {}
@@ -875,6 +965,14 @@ let _ToolManager = class _ToolManager {
875
965
  async requestApprovalDecision(recorded) {
876
966
  return this.approvalManager.requestApprovalDecision(recorded.request);
877
967
  }
968
+ async cancelApprovalRequest(recorded) {
969
+ await this.approvalManager.cancelApproval(recorded.request.approvalId);
970
+ await this.applyApprovalDecision(recorded, {
971
+ approvalId: recorded.request.approvalId,
972
+ reason: "system_cancelled",
973
+ status: ApprovalStatus.CANCELLED
974
+ });
975
+ }
878
976
  assertRecordedApprovalMatchesPreparedCall(prepared, request) {
879
977
  const expected = {
880
978
  type: prepared.requestDetails.type,
@@ -951,15 +1049,6 @@ let _ToolManager = class _ToolManager {
951
1049
  const outcome = response.status === ApprovalStatus.DENIED ? "approval was denied" : "approval was cancelled";
952
1050
  return `Tool '${toolName}' was not executed because ${outcome}${response.message ? `: ${response.message}` : ""}.`;
953
1051
  }
954
- async resolveExecutableToolSource(toolName) {
955
- if (this.agentTools.has(toolName)) {
956
- return "local";
957
- }
958
- if (toolName.startsWith(_ToolManager.MCP_TOOL_PREFIX) && toolName.length > _ToolManager.MCP_TOOL_PREFIX.length) {
959
- return "mcp";
960
- }
961
- return "unknown";
962
- }
963
1052
  createPreparedToolError(kind, toolName, error) {
964
1053
  return {
965
1054
  kind: "terminal",
@@ -987,7 +1076,6 @@ let _ToolManager = class _ToolManager {
987
1076
  async executeTool(toolName, args, toolCallId, invocation) {
988
1077
  const { sessionId, runContext, hostRuntime } = this.resolveToolExecutionInvocation(invocation);
989
1078
  this.logger.debug(`\u{1F527} Tool execution requested: '${toolName}' (toolCallId: ${toolCallId})`);
990
- this.logger.debug(`Tool args: ${JSON.stringify(args, null, 2)}`);
991
1079
  if (toolName === _ToolManager.MCP_TOOL_PREFIX) {
992
1080
  throw ToolError.invalidName(toolName, "tool name cannot be empty after prefix");
993
1081
  }
@@ -995,6 +1083,7 @@ let _ToolManager = class _ToolManager {
995
1083
  toolName,
996
1084
  input: args,
997
1085
  toolCallId,
1086
+ ...invocation?.executionIdentity?.parentToolCallId === void 0 ? {} : { parentToolCallId: invocation.executionIdentity.parentToolCallId },
998
1087
  ...sessionId !== void 0 ? { sessionId } : {},
999
1088
  ...runContext !== void 0 ? { runContext } : {}
1000
1089
  });
@@ -1013,7 +1102,11 @@ let _ToolManager = class _ToolManager {
1013
1102
  try {
1014
1103
  const recorded = await this.recordApprovalRequest(
1015
1104
  prepared,
1016
- this.resolveDirectApprovalIdentity(invocation, toolCallId)
1105
+ this.resolveDirectApprovalIdentity(
1106
+ invocation,
1107
+ toolCallId,
1108
+ prepared.call.parentToolCallId
1109
+ )
1017
1110
  );
1018
1111
  const response = await this.requestApprovalDecision(recorded);
1019
1112
  applied = await this.applyApprovalDecision(recorded, {
@@ -1042,6 +1135,9 @@ let _ToolManager = class _ToolManager {
1042
1135
  if (!sessionId) {
1043
1136
  return;
1044
1137
  }
1138
+ if (call.parentToolCallId !== void 0) {
1139
+ return;
1140
+ }
1045
1141
  this.agentEventBus.emit("llm:tool-call", {
1046
1142
  toolName: call.toolName,
1047
1143
  presentationSnapshot: this.toolPresentation.snapshotForToolCallEvent({
@@ -1063,7 +1159,11 @@ let _ToolManager = class _ToolManager {
1063
1159
  if (isBackgroundTasksEnabled() && call.meta?.runInBackground === true && sessionId !== void 0) {
1064
1160
  return void 0;
1065
1161
  }
1066
- const identity = this.resolveToolExecutionIdentity(invocation ?? {}, call.toolCallId);
1162
+ const identity = this.resolveToolExecutionIdentity(
1163
+ invocation ?? {},
1164
+ call.toolCallId,
1165
+ call.parentToolCallId
1166
+ );
1067
1167
  if (identity === void 0) {
1068
1168
  return void 0;
1069
1169
  }
@@ -1097,7 +1197,11 @@ let _ToolManager = class _ToolManager {
1097
1197
  );
1098
1198
  }
1099
1199
  async recordDirectToolExecutionFailure(call, invocation, error) {
1100
- const identity = this.resolveToolExecutionIdentity(invocation ?? {}, call.toolCallId);
1200
+ const identity = this.resolveToolExecutionIdentity(
1201
+ invocation ?? {},
1202
+ call.toolCallId,
1203
+ call.parentToolCallId
1204
+ );
1101
1205
  if (identity === void 0) {
1102
1206
  return;
1103
1207
  }
@@ -1130,8 +1234,12 @@ let _ToolManager = class _ToolManager {
1130
1234
  error: error instanceof Error ? error.message : String(error)
1131
1235
  });
1132
1236
  }
1133
- resolveDirectApprovalIdentity(invocation, toolCallId) {
1134
- const executionIdentity = this.resolveToolExecutionIdentity(invocation ?? {}, toolCallId);
1237
+ resolveDirectApprovalIdentity(invocation, toolCallId, parentToolCallId) {
1238
+ const executionIdentity = this.resolveToolExecutionIdentity(
1239
+ invocation ?? {},
1240
+ toolCallId,
1241
+ parentToolCallId
1242
+ );
1135
1243
  if (executionIdentity !== void 0) {
1136
1244
  return {
1137
1245
  runId: executionIdentity.runId,
@@ -1182,7 +1290,8 @@ let _ToolManager = class _ToolManager {
1182
1290
  const { sessionId, abortSignal, runContext, hostRuntime } = this.resolveToolExecutionInvocation(invocation);
1183
1291
  const durableIdentity = this.resolveToolExecutionIdentity(
1184
1292
  invocation ?? {},
1185
- call.toolCallId
1293
+ call.toolCallId,
1294
+ call.parentToolCallId
1186
1295
  );
1187
1296
  const backgroundTasksEnabled = isBackgroundTasksEnabled();
1188
1297
  const willRunInBackground = backgroundTasksEnabled && call.meta?.runInBackground === true && sessionId !== void 0;
@@ -1246,6 +1355,9 @@ let _ToolManager = class _ToolManager {
1246
1355
  this.agentEventBus.emit("tool:running", {
1247
1356
  toolName: call.toolName,
1248
1357
  toolCallId: call.toolCallId,
1358
+ ...call.parentToolCallId !== void 0 && {
1359
+ parentToolCallId: call.parentToolCallId
1360
+ },
1249
1361
  sessionId,
1250
1362
  ...hostRuntime !== void 0 && { hostRuntime }
1251
1363
  });
@@ -1270,7 +1382,7 @@ let _ToolManager = class _ToolManager {
1270
1382
  );
1271
1383
  toolArgs = modifiedPayload.args;
1272
1384
  try {
1273
- toolArgs = this.validateLocalToolArgs(call.toolName, toolArgs);
1385
+ toolArgs = this.validateToolArgs(call.toolName, toolArgs);
1274
1386
  } catch (error) {
1275
1387
  this.logger.error(
1276
1388
  `Post-hook validation failed for tool '${call.toolName}': a beforeToolCall hook may have set invalid args`
@@ -1289,7 +1401,7 @@ let _ToolManager = class _ToolManager {
1289
1401
  promise
1290
1402
  };
1291
1403
  };
1292
- if (call.source === "mcp") {
1404
+ if (call.identity.type === "mcp") {
1293
1405
  const actualToolName = call.toolName.substring(_ToolManager.MCP_TOOL_PREFIX.length);
1294
1406
  if (actualToolName.length === 0) {
1295
1407
  throw ToolError.invalidName(
@@ -1346,7 +1458,9 @@ let _ToolManager = class _ToolManager {
1346
1458
  this.executeLocalTool(call.toolName, toolArgs, {
1347
1459
  sessionId: backgroundSessionId,
1348
1460
  abortSignal,
1461
+ executionIdentity,
1349
1462
  toolCallId: call.toolCallId,
1463
+ parentToolCallId: call.parentToolCallId,
1350
1464
  runContext
1351
1465
  }),
1352
1466
  `Tool ${call.toolName}`
@@ -1370,7 +1484,9 @@ let _ToolManager = class _ToolManager {
1370
1484
  result = await this.executeLocalTool(call.toolName, toolArgs, {
1371
1485
  sessionId,
1372
1486
  abortSignal,
1487
+ executionIdentity,
1373
1488
  toolCallId: call.toolCallId,
1489
+ parentToolCallId: call.parentToolCallId,
1374
1490
  runContext
1375
1491
  });
1376
1492
  }
@@ -1406,6 +1522,7 @@ let _ToolManager = class _ToolManager {
1406
1522
  result,
1407
1523
  args: toolArgs,
1408
1524
  toolCallId: call.toolCallId,
1525
+ ...call.parentToolCallId === void 0 ? {} : { parentToolCallId: call.parentToolCallId },
1409
1526
  ...sessionId !== void 0 ? { sessionId } : {},
1410
1527
  ...runContext !== void 0 ? { runContext } : {}
1411
1528
  });
@@ -1437,7 +1554,7 @@ let _ToolManager = class _ToolManager {
1437
1554
  } catch (error) {
1438
1555
  const duration = Date.now() - startTime;
1439
1556
  this.logger.error(
1440
- `\u274C Prepared tool execution failed for ${call.toolName} after ${duration}ms, sessionId: ${sessionId ?? "global"}: ${error instanceof Error ? error.message : String(error)}`
1557
+ `Prepared tool execution failed for ${call.toolName} after ${duration}ms, sessionId: ${sessionId ?? "global"}`
1441
1558
  );
1442
1559
  const message = error instanceof Error ? error.message : String(error);
1443
1560
  if (executionId !== void 0) {
@@ -7,6 +7,7 @@ import type { WorkspaceContext } from '../workspace/types.js';
7
7
  import type { ApprovalManager } from '../approval/manager.js';
8
8
  import type { DextoAgent } from '../agent/DextoAgent.js';
9
9
  import type { ToolStateStore } from '../storage/index.js';
10
+ import type { ToolExecutionIdentity } from '../storage/tool-executions/types.js';
10
11
  import type { MCPManager } from '../mcp/manager.js';
11
12
  import type { PromptManager } from '../prompts/prompt-manager.js';
12
13
  import type { ResourceManager } from '../resources/manager.js';
@@ -16,6 +17,7 @@ import type { HostRuntimeContext } from '../runtime/index.js';
16
17
  import type { AgentRunContext } from '../runtime/run-context.js';
17
18
  import type { Skills } from '../skills/index.js';
18
19
  import type { WorkspaceManager } from '../workspace/index.js';
20
+ import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
19
21
  /**
20
22
  * Interface for forking execution to an isolated sub-agent context.
21
23
  *
@@ -55,6 +57,8 @@ export interface ToolExecutionContextBase {
55
57
  sessionId?: string | undefined;
56
58
  /** Internal run-scoped execution context for this tool invocation */
57
59
  runContext?: AgentRunContext | undefined;
60
+ /** Durable identity assigned to this concrete tool execution, when one exists. */
61
+ executionIdentity?: ToolExecutionIdentity | undefined;
58
62
  /** Workspace ID if available */
59
63
  workspaceId?: string | undefined;
60
64
  /** Workspace context if available */
@@ -63,6 +67,8 @@ export interface ToolExecutionContextBase {
63
67
  abortSignal?: AbortSignal | undefined;
64
68
  /** Unique tool call ID for tracking parallel tool calls */
65
69
  toolCallId?: string | undefined;
70
+ /** Outer tool call that owns this nested execution, when applicable. */
71
+ parentToolCallId?: string | undefined;
66
72
  /** Host-owned runtime IDs for orchestration and correlation */
67
73
  hostRuntime?: HostRuntimeContext | undefined;
68
74
  /**
@@ -132,6 +138,8 @@ export interface Tool<TSchema extends ZodTypeAny = ZodTypeAny> {
132
138
  getDescription?: ((context: ToolExecutionContext) => Promise<string> | string) | undefined;
133
139
  /** Zod schema defining the input parameters */
134
140
  inputSchema: TSchema;
141
+ /** Optional Zod schema describing a stable structured result. */
142
+ outputSchema?: ZodTypeAny | undefined;
135
143
  /** The actual function that executes the tool - input is validated by Zod before execution */
136
144
  execute(input: z.output<TSchema>, context: ToolExecutionContext): Promise<unknown> | unknown;
137
145
  /**
@@ -235,9 +243,49 @@ export interface ToolSet {
235
243
  name?: string;
236
244
  description?: string;
237
245
  parameters: JSONSchema7;
246
+ outputSchema?: JSONSchema7;
247
+ annotations?: ToolAnnotations;
238
248
  _meta?: Record<string, unknown>;
239
249
  };
240
250
  }
251
+ interface ToolDescriptorBase {
252
+ /** Name accepted by this ToolManager snapshot. */
253
+ name: string;
254
+ description: string;
255
+ inputSchema: JSONSchema7;
256
+ /** Absent when the provider cannot make a trustworthy result-shape guarantee. */
257
+ outputSchema?: JSONSchema7;
258
+ /** Stable fingerprint of the input/output contract for grant and replay validation. */
259
+ schemaFingerprint: string;
260
+ }
261
+ export type ToolIdentity = {
262
+ type: 'local';
263
+ toolId: string;
264
+ } | {
265
+ type: 'mcp';
266
+ /** Stable host connection identity; the Core/CLI implementation uses its config key. */
267
+ connectionId: string;
268
+ /** Name advertised by the upstream MCP server. */
269
+ toolName: string;
270
+ };
271
+ export interface LocalToolDescriptor extends ToolDescriptorBase {
272
+ /** Whether the current ToolManager policy may require approval after validating call input. */
273
+ approval: 'never' | 'possible';
274
+ identity: Extract<ToolIdentity, {
275
+ type: 'local';
276
+ }>;
277
+ }
278
+ export interface MCPToolDescriptor extends ToolDescriptorBase {
279
+ identity: Extract<ToolIdentity, {
280
+ type: 'mcp';
281
+ }>;
282
+ /** Untrusted MCP hints preserved for consumers; host policy must not treat them as authority. */
283
+ annotations?: ToolAnnotations;
284
+ }
285
+ export type ToolDescriptor = LocalToolDescriptor | (MCPToolDescriptor & {
286
+ /** Whether the current ToolManager policy may require approval after validating call input. */
287
+ approval: 'never' | 'possible';
288
+ });
241
289
  /**
242
290
  * Tool execution result
243
291
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK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mBAAoB,SAAQ,kBAAkB;IAC3D,+FAA+F;IAC/F,QAAQ,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC,YAAY,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IACzD,QAAQ,EAAE,OAAO,CAAC,YAAY,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;IACjD,iGAAiG;IACjG,WAAW,CAAC,EAAE,eAAe,CAAC;CACjC;AAED,MAAM,MAAM,cAAc,GACpB,mBAAmB,GACnB,CAAC,iBAAiB,GAAG;IACjB,+FAA+F;IAC/F,QAAQ,EAAE,OAAO,GAAG,UAAU,CAAC;CAClC,CAAC,CAAC;AAMT;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,CACJ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,IAAI,CAAC,wBAAwB,EAAE,WAAW,GAAG,YAAY,CAAC,GACrE,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB"}
@@ -22,10 +22,10 @@ __export(schema_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(schema_exports);
24
24
  var import_zod = require("zod");
25
- function convertZodSchemaToJsonSchema(zodSchema, logger) {
25
+ function convertZodSchemaToJsonSchema(zodSchema, logger, io = "input") {
26
26
  try {
27
27
  const converted = import_zod.z.toJSONSchema(zodSchema, {
28
- io: "input",
28
+ io,
29
29
  target: "draft-07",
30
30
  unrepresentable: "any"
31
31
  });
@@ -5,5 +5,5 @@ import type { Logger } from '../logger/v2/types.js';
5
5
  * Convert Zod schema to JSON Schema format for tool parameters
6
6
  *
7
7
  */
8
- export declare function convertZodSchemaToJsonSchema(zodSchema: z.ZodType, logger: Logger): JSONSchema7;
8
+ export declare function convertZodSchemaToJsonSchema(zodSchema: z.ZodType, logger: Logger, io?: 'input' | 'output'): JSONSchema7;
9
9
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAuB9F"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,4BAA4B,CACxC,SAAS,EAAE,CAAC,CAAC,OAAO,EACpB,MAAM,EAAE,MAAM,EACd,EAAE,GAAE,OAAO,GAAG,QAAkB,GACjC,WAAW,CAuBb"}
@@ -1,9 +1,9 @@
1
1
  import "../chunk-C6A6W6XS.js";
2
2
  import { z } from "zod";
3
- function convertZodSchemaToJsonSchema(zodSchema, logger) {
3
+ function convertZodSchemaToJsonSchema(zodSchema, logger, io = "input") {
4
4
  try {
5
5
  const converted = z.toJSONSchema(zodSchema, {
6
- io: "input",
6
+ io,
7
7
  target: "draft-07",
8
8
  unrepresentable: "any"
9
9
  });
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var stable_fingerprint_exports = {};
20
+ __export(stable_fingerprint_exports, {
21
+ stableFingerprint: () => stableFingerprint
22
+ });
23
+ module.exports = __toCommonJS(stable_fingerprint_exports);
24
+ var import_sha2 = require("@noble/hashes/sha2");
25
+ var import_utils = require("@noble/hashes/utils");
26
+ function stableFingerprint(value) {
27
+ return (0, import_utils.bytesToHex)((0, import_sha2.sha256)(value));
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ stableFingerprint
32
+ });
@@ -0,0 +1,3 @@
1
+ /** Deterministic, runtime-portable SHA-256 fingerprint for identity and contract drift. */
2
+ export declare function stableFingerprint(value: string): string;
3
+ //# sourceMappingURL=stable-fingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stable-fingerprint.d.ts","sourceRoot":"","sources":["../../src/utils/stable-fingerprint.ts"],"names":[],"mappings":"AAGA,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
@@ -0,0 +1,9 @@
1
+ import "../chunk-C6A6W6XS.js";
2
+ import { sha256 } from "@noble/hashes/sha2";
3
+ import { bytesToHex } from "@noble/hashes/utils";
4
+ function stableFingerprint(value) {
5
+ return bytesToHex(sha256(value));
6
+ }
7
+ export {
8
+ stableFingerprint
9
+ };