@dexto/core 1.8.11 → 1.9.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 (113) hide show
  1. package/dist/approval/manager.cjs +37 -325
  2. package/dist/approval/manager.d.ts +10 -109
  3. package/dist/approval/manager.d.ts.map +1 -1
  4. package/dist/approval/manager.js +37 -316
  5. package/dist/approval/schemas.cjs +8 -51
  6. package/dist/approval/schemas.d.ts +5 -179
  7. package/dist/approval/schemas.d.ts.map +1 -1
  8. package/dist/approval/schemas.js +8 -47
  9. package/dist/approval/types.cjs +0 -6
  10. package/dist/approval/types.d.ts +2 -27
  11. package/dist/approval/types.d.ts.map +1 -1
  12. package/dist/approval/types.js +0 -6
  13. package/dist/context/content-clone.cjs +12 -8
  14. package/dist/context/content-clone.d.ts.map +1 -1
  15. package/dist/context/content-clone.js +12 -8
  16. package/dist/errors/DextoRuntimeError.cjs +3 -1
  17. package/dist/errors/DextoRuntimeError.d.ts +5 -3
  18. package/dist/errors/DextoRuntimeError.d.ts.map +1 -1
  19. package/dist/errors/DextoRuntimeError.js +3 -1
  20. package/dist/errors/index.d.ts +1 -1
  21. package/dist/errors/index.d.ts.map +1 -1
  22. package/dist/errors/types.d.ts +1 -0
  23. package/dist/errors/types.d.ts.map +1 -1
  24. package/dist/events/index.d.ts +2 -2
  25. package/dist/events/index.d.ts.map +1 -1
  26. package/dist/llm/executor/provider-error.cjs +25 -4
  27. package/dist/llm/executor/provider-error.d.ts.map +1 -1
  28. package/dist/llm/executor/provider-error.js +25 -4
  29. package/dist/llm/executor/stream-processor.cjs +61 -0
  30. package/dist/llm/executor/stream-processor.d.ts.map +1 -1
  31. package/dist/llm/executor/stream-processor.js +61 -0
  32. package/dist/llm/executor/turn-executor.cjs +93 -26
  33. package/dist/llm/executor/turn-executor.d.ts +2 -0
  34. package/dist/llm/executor/turn-executor.d.ts.map +1 -1
  35. package/dist/llm/executor/turn-executor.js +93 -26
  36. package/dist/llm/formatters/vercel.cjs +66 -0
  37. package/dist/llm/formatters/vercel.d.ts.map +1 -1
  38. package/dist/llm/formatters/vercel.js +66 -0
  39. package/dist/llm/services/factory.cjs +3 -2
  40. package/dist/llm/services/factory.d.ts.map +1 -1
  41. package/dist/llm/services/factory.js +3 -2
  42. package/dist/llm/services/types.d.ts +8 -0
  43. package/dist/llm/services/types.d.ts.map +1 -1
  44. package/dist/llm/services/vercel.cjs +6 -1
  45. package/dist/llm/services/vercel.d.ts +3 -2
  46. package/dist/llm/services/vercel.d.ts.map +1 -1
  47. package/dist/llm/services/vercel.js +6 -1
  48. package/dist/session/chat-session.cjs +3 -0
  49. package/dist/session/chat-session.d.ts +2 -1
  50. package/dist/session/chat-session.d.ts.map +1 -1
  51. package/dist/session/chat-session.js +3 -0
  52. package/dist/session/message-queue.cjs +48 -75
  53. package/dist/session/message-queue.d.ts +1 -2
  54. package/dist/session/message-queue.d.ts.map +1 -1
  55. package/dist/session/message-queue.js +48 -75
  56. package/dist/session/session-manager.cjs +14 -32
  57. package/dist/session/session-manager.d.ts +5 -2
  58. package/dist/session/session-manager.d.ts.map +1 -1
  59. package/dist/session/session-manager.js +14 -32
  60. package/dist/storage/approvals/types.cjs +2 -9
  61. package/dist/storage/approvals/types.d.ts +4 -16
  62. package/dist/storage/approvals/types.d.ts.map +1 -1
  63. package/dist/storage/approvals/types.js +2 -8
  64. package/dist/storage/database/types.d.ts +5 -0
  65. package/dist/storage/database/types.d.ts.map +1 -1
  66. package/dist/storage/index.cjs +0 -2
  67. package/dist/storage/index.d.ts +2 -2
  68. package/dist/storage/index.d.ts.map +1 -1
  69. package/dist/storage/index.js +1 -2
  70. package/dist/storage/message-queue/types.d.ts +14 -6
  71. package/dist/storage/message-queue/types.d.ts.map +1 -1
  72. package/dist/storage/stores/backend.cjs +68 -32
  73. package/dist/storage/stores/backend.d.ts +17 -8
  74. package/dist/storage/stores/backend.d.ts.map +1 -1
  75. package/dist/storage/stores/backend.js +69 -33
  76. package/dist/storage/stores/in-memory.cjs +26 -11
  77. package/dist/storage/stores/in-memory.d.ts.map +1 -1
  78. package/dist/storage/stores/in-memory.js +27 -12
  79. package/dist/test-utils/in-memory-storage.cjs +11 -0
  80. package/dist/test-utils/in-memory-storage.js +11 -0
  81. package/dist/test-utils/session-state-stores.cjs +25 -9
  82. package/dist/test-utils/session-state-stores.js +26 -10
  83. package/dist/tools/approval/tool-approval-policy.cjs +87 -0
  84. package/dist/tools/approval/tool-approval-policy.d.ts +34 -0
  85. package/dist/tools/approval/tool-approval-policy.d.ts.map +1 -0
  86. package/dist/tools/approval/tool-approval-policy.js +64 -0
  87. package/dist/tools/error-codes.cjs +0 -1
  88. package/dist/tools/error-codes.d.ts +0 -1
  89. package/dist/tools/error-codes.d.ts.map +1 -1
  90. package/dist/tools/error-codes.js +0 -1
  91. package/dist/tools/errors.cjs +0 -15
  92. package/dist/tools/errors.d.ts +0 -9
  93. package/dist/tools/errors.d.ts.map +1 -1
  94. package/dist/tools/errors.js +0 -15
  95. package/dist/tools/index.cjs +2 -0
  96. package/dist/tools/index.d.ts +1 -1
  97. package/dist/tools/index.d.ts.map +1 -1
  98. package/dist/tools/index.js +5 -1
  99. package/dist/tools/tool-manager.cjs +94 -312
  100. package/dist/tools/tool-manager.d.ts +4 -19
  101. package/dist/tools/tool-manager.d.ts.map +1 -1
  102. package/dist/tools/tool-manager.js +95 -316
  103. package/dist/tools/types.d.ts +10 -9
  104. package/dist/tools/types.d.ts.map +1 -1
  105. package/dist/utils/service-initializer.cjs +3 -0
  106. package/dist/utils/service-initializer.d.ts +2 -1
  107. package/dist/utils/service-initializer.d.ts.map +1 -1
  108. package/dist/utils/service-initializer.js +3 -0
  109. package/package.json +2 -2
  110. package/dist/tools/pattern-utils.cjs +0 -33
  111. package/dist/tools/pattern-utils.d.ts +0 -20
  112. package/dist/tools/pattern-utils.d.ts.map +0 -1
  113. package/dist/tools/pattern-utils.js +0 -10
@@ -10,11 +10,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
12
  import { ApprovalStatus, ApprovalType, DenialReason } from "../approval/types.js";
13
- import {
14
- DirectoryAccessMetadataSchema,
15
- ToolApprovalResponseDataSchema
16
- } from "../approval/schemas.js";
13
+ import { ToolApprovalMetadataSchema, ToolApprovalResponseDataSchema } from "../approval/schemas.js";
17
14
  import { matchesToolPolicyPattern, SessionToolPolicy } from "./approval/session-tool-policy.js";
15
+ import { ToolApprovalPolicy } from "./approval/tool-approval-policy.js";
18
16
  import { ToolPresentation } from "./presentation/tool-presentation.js";
19
17
  import { InstrumentClass } from "../telemetry/decorators.js";
20
18
  import {
@@ -49,6 +47,20 @@ let _ToolManager = class _ToolManager {
49
47
  this.logger,
50
48
  (pattern) => this.normalizeToolPolicyPattern(pattern)
51
49
  );
50
+ this.toolApprovalPolicy = new ToolApprovalPolicy({
51
+ getApprovalMode: () => this.approvalMode,
52
+ getLocalTool: (toolName) => this.agentTools.get(toolName),
53
+ isApprovalKeySessionApproved: ({ approvalKey, sessionId }) => this.approvalManager.isApprovalKeySessionApproved(approvalKey, sessionId),
54
+ isToolExplicitlyAllowed: async ({ toolName, sessionId }) => {
55
+ if (sessionId !== void 0 && this.isToolAutoApprovedForSession(sessionId, toolName)) {
56
+ return true;
57
+ }
58
+ if (this.isInAlwaysAllowList(toolName)) {
59
+ return true;
60
+ }
61
+ return await this.allowedToolsProvider.isToolAllowed(toolName, sessionId);
62
+ }
63
+ });
52
64
  this.toolPresentation = new ToolPresentation(
53
65
  (toolName) => this.agentTools.get(toolName),
54
66
  (toolName, args) => this.validateLocalToolArgs(toolName, args),
@@ -90,6 +102,7 @@ let _ToolManager = class _ToolManager {
90
102
  cacheValid = false;
91
103
  logger;
92
104
  sessionToolPolicy;
105
+ toolApprovalPolicy;
93
106
  toolPresentation;
94
107
  cleanupHandlers = /* @__PURE__ */ new Set();
95
108
  cleanupStarted = false;
@@ -409,58 +422,7 @@ let _ToolManager = class _ToolManager {
409
422
  }
410
423
  });
411
424
  }
412
- // ==================== Pattern Approval Helpers ====================
413
- getToolApprovalPatternKeyFn(toolName) {
414
- const tool = this.agentTools.get(toolName);
415
- return tool?.approval?.patternKey;
416
- }
417
- getToolSuggestApprovalPatternsFn(toolName) {
418
- const tool = this.agentTools.get(toolName);
419
- return tool?.approval?.suggestPatterns;
420
- }
421
- getToolApprovalOverrideFn(toolName) {
422
- const tool = this.agentTools.get(toolName);
423
- return tool?.approval?.override;
424
- }
425
- getToolApprovalOnGrantedFn(toolName) {
426
- const tool = this.agentTools.get(toolName);
427
- return tool?.approval?.onGranted;
428
- }
429
- getToolPatternKey(toolName, args) {
430
- if (toolName.startsWith(_ToolManager.MCP_TOOL_PREFIX)) {
431
- return null;
432
- }
433
- const getPatternKey = this.getToolApprovalPatternKeyFn(toolName);
434
- if (!getPatternKey) {
435
- return null;
436
- }
437
- try {
438
- return getPatternKey(args);
439
- } catch (error) {
440
- this.logger.debug(
441
- `Pattern key generation failed for '${toolName}': ${error instanceof Error ? error.message : String(error)}`
442
- );
443
- return null;
444
- }
445
- }
446
- getToolSuggestedPatterns(toolName, args) {
447
- if (toolName.startsWith(_ToolManager.MCP_TOOL_PREFIX)) {
448
- return void 0;
449
- }
450
- const suggestPatterns = this.getToolSuggestApprovalPatternsFn(toolName);
451
- if (!suggestPatterns) {
452
- return void 0;
453
- }
454
- try {
455
- const patterns = suggestPatterns(args);
456
- return patterns.length > 0 ? patterns : void 0;
457
- } catch (error) {
458
- this.logger.debug(
459
- `Pattern suggestion failed for '${toolName}': ${error instanceof Error ? error.message : String(error)}`
460
- );
461
- return void 0;
462
- }
463
- }
425
+ // ==================== Approval Helpers ====================
464
426
  /**
465
427
  * Auto-approve pending tool approval requests for the same tool.
466
428
  * Called after a user selects "remember choice" for a tool.
@@ -481,7 +443,7 @@ let _ToolManager = class _ToolManager {
481
443
  if (request.metadata.toolName !== toolName) {
482
444
  return false;
483
445
  }
484
- return request.metadata.directoryAccess === void 0;
446
+ return true;
485
447
  },
486
448
  { rememberChoice: false }
487
449
  // Don't propagate remember choice to auto-approved requests
@@ -492,18 +454,7 @@ let _ToolManager = class _ToolManager {
492
454
  );
493
455
  }
494
456
  }
495
- /**
496
- * Auto-approve pending tool approval requests that are now covered by a remembered pattern.
497
- * Called after a user selects "remember pattern" for a tool.
498
- */
499
- autoApprovePendingPatternRequests(toolName, sessionId) {
500
- if (toolName.startsWith(_ToolManager.MCP_TOOL_PREFIX)) {
501
- return;
502
- }
503
- const getPatternKey = this.getToolApprovalPatternKeyFn(toolName);
504
- if (!getPatternKey) {
505
- return;
506
- }
457
+ autoApprovePendingApprovalKeyRequests(approvalKey, sessionId) {
507
458
  const count = this.approvalManager.autoApprovePendingRequests(
508
459
  (request) => {
509
460
  if (request.type !== ApprovalType.TOOL_APPROVAL) {
@@ -512,64 +463,16 @@ let _ToolManager = class _ToolManager {
512
463
  if (request.sessionId !== sessionId) {
513
464
  return false;
514
465
  }
515
- if (request.metadata.toolName !== toolName) {
516
- return false;
517
- }
518
- if (request.metadata.directoryAccess !== void 0) {
519
- return false;
520
- }
521
- let patternKey;
522
- try {
523
- patternKey = getPatternKey(request.metadata.args);
524
- } catch (error) {
525
- this.logger.debug(
526
- `Pattern key generation failed for '${toolName}': ${error instanceof Error ? error.message : String(error)}`
527
- );
528
- return false;
529
- }
530
- if (!patternKey) return false;
531
- return this.approvalManager.matchesPattern(toolName, patternKey, sessionId);
466
+ return request.metadata.approvalKey === approvalKey;
532
467
  },
533
- { rememberPattern: void 0 }
534
- // Don't propagate pattern choice to auto-approved requests
468
+ { rememberChoice: false }
535
469
  );
536
470
  if (count > 0) {
537
471
  this.logger.info(
538
- `Auto-approved ${count} parallel request(s) for tool '${toolName}' after user selected "remember pattern"`
539
- );
540
- }
541
- }
542
- /**
543
- * Auto-approve pending tool approval requests that are now covered by a remembered directory.
544
- * Called after a user selects "remember directory" for a directory-access prompt.
545
- */
546
- autoApprovePendingDirectoryRequests(toolName, sessionId) {
547
- const count = this.approvalManager.autoApprovePendingRequests(
548
- (request) => {
549
- if (request.type !== ApprovalType.TOOL_APPROVAL) {
550
- return false;
551
- }
552
- if (request.sessionId !== sessionId) {
553
- return false;
554
- }
555
- if (request.metadata.toolName !== toolName) {
556
- return false;
557
- }
558
- const directoryAccess = request.metadata.directoryAccess;
559
- if (!directoryAccess) {
560
- return false;
472
+ "Auto-approved parallel request(s) after approval key was remembered",
473
+ {
474
+ count
561
475
  }
562
- return this.approvalManager.isDirectorySessionApproved(
563
- directoryAccess.parentDir,
564
- sessionId
565
- );
566
- },
567
- { rememberDirectory: false }
568
- );
569
- if (count > 0) {
570
- this.logger.info(
571
- 'Auto-approved parallel request(s) after user selected "remember directory"',
572
- { count, toolName }
573
476
  );
574
477
  }
575
478
  }
@@ -870,89 +773,57 @@ let _ToolManager = class _ToolManager {
870
773
  ...callDescription !== void 0 ? { callDescription } : {},
871
774
  ...eventMeta !== void 0 ? { meta: eventMeta } : {}
872
775
  };
873
- const overrideRequest = await this.getToolApprovalOverrideRequest(
874
- input.toolName,
875
- validatedArgs,
876
- input.toolCallId,
877
- sessionId,
878
- input.runContext
879
- );
880
- if (overrideRequest) {
881
- if (!overrideRequest.directoryAccess) {
882
- return {
883
- kind: "approval-required",
884
- call,
885
- onGrantedRequestDetails: overrideRequest.onGrantedRequestDetails,
886
- requestDetails: overrideRequest.requestDetails
887
- };
888
- }
889
- const quickResult2 = await this.classifyQuickApprovalRequirement(
890
- input.toolName,
891
- validatedArgs,
776
+ const approvalGate = await this.toolApprovalPolicy.resolve({
777
+ args: validatedArgs,
778
+ getContext: () => this.buildToolExecutionContext({
892
779
  sessionId,
893
- overrideRequest.directoryAccess
894
- );
895
- if (quickResult2 === "ready") {
896
- return { kind: "ready", call };
897
- }
898
- const displayPreview2 = await this.toolPresentation.preview({
899
- toolName: input.toolName,
900
- args: validatedArgs,
901
780
  toolCallId: input.toolCallId,
902
- ...sessionId !== void 0 ? { sessionId } : {},
903
- ...input.runContext !== void 0 ? { runContext: input.runContext } : {}
904
- });
905
- const suggestedPatterns2 = this.getToolSuggestedPatterns(input.toolName, validatedArgs);
906
- return {
907
- kind: "approval-required",
908
- call,
909
- onGrantedRequestDetails: overrideRequest.onGrantedRequestDetails,
910
- requestDetails: {
911
- ...overrideRequest.requestDetails,
912
- metadata: {
913
- ...overrideRequest.requestDetails.metadata,
914
- presentationSnapshot,
915
- ...callDescription !== void 0 ? { description: callDescription } : {},
916
- ...displayPreview2 !== void 0 ? { displayPreview: displayPreview2 } : {},
917
- ...suggestedPatterns2 !== void 0 ? { suggestedPatterns: suggestedPatterns2 } : {}
918
- }
919
- }
920
- };
921
- }
922
- const quickResult = await this.classifyQuickApprovalRequirement(
923
- input.toolName,
924
- validatedArgs,
925
- sessionId
926
- );
927
- if (quickResult === "ready") {
781
+ runContext: input.runContext
782
+ }),
783
+ ...sessionId !== void 0 ? { sessionId } : {},
784
+ source,
785
+ toolName: input.toolName
786
+ });
787
+ if (approvalGate.kind === "ready") {
928
788
  return { kind: "ready", call };
929
789
  }
930
- const displayPreview = await this.toolPresentation.preview({
931
- toolName: input.toolName,
790
+ return await this.prepareApprovalRequiredToolCall({
791
+ approvalGate,
932
792
  args: validatedArgs,
933
- toolCallId: input.toolCallId,
793
+ call,
794
+ ...callDescription !== void 0 ? { callDescription } : {},
795
+ ...input.runContext !== void 0 ? { runContext: input.runContext } : {},
934
796
  ...sessionId !== void 0 ? { sessionId } : {},
935
- ...input.runContext !== void 0 ? { runContext: input.runContext } : {}
797
+ toolCallId: input.toolCallId,
798
+ toolName: input.toolName
799
+ });
800
+ }
801
+ async prepareApprovalRequiredToolCall(input) {
802
+ const displayPreview = await this.toolPresentation.preview({
803
+ args: input.args,
804
+ ...input.runContext !== void 0 ? { runContext: input.runContext } : {},
805
+ ...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {},
806
+ toolCallId: input.toolCallId,
807
+ toolName: input.toolName
936
808
  });
937
- const suggestedPatterns = this.getToolSuggestedPatterns(input.toolName, validatedArgs);
938
809
  const hostRuntime = input.runContext?.hostRuntime;
939
810
  const requestDetails = {
940
811
  type: ApprovalType.TOOL_APPROVAL,
941
- ...sessionId !== void 0 ? { sessionId } : {},
812
+ ...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {},
942
813
  ...hostRuntime !== void 0 ? { hostRuntime } : {},
943
814
  metadata: {
944
815
  toolName: input.toolName,
945
- presentationSnapshot,
816
+ ...input.approvalGate.approvalKey !== void 0 ? { approvalKey: input.approvalGate.approvalKey } : {},
817
+ presentationSnapshot: input.call.presentationSnapshot,
946
818
  toolCallId: input.toolCallId,
947
- args: validatedArgs,
948
- ...callDescription !== void 0 ? { description: callDescription } : {},
949
- ...displayPreview !== void 0 ? { displayPreview } : {},
950
- ...suggestedPatterns !== void 0 ? { suggestedPatterns } : {}
819
+ args: input.args,
820
+ ...input.callDescription !== void 0 ? { description: input.callDescription } : {},
821
+ ...displayPreview !== void 0 ? { displayPreview } : {}
951
822
  }
952
823
  };
953
824
  return {
954
825
  kind: "approval-required",
955
- call,
826
+ call: input.call,
956
827
  onGrantedRequestDetails: requestDetails,
957
828
  requestDetails
958
829
  };
@@ -966,7 +837,7 @@ let _ToolManager = class _ToolManager {
966
837
  this.assertRecordedApprovalMatchesPreparedCall(prepared, request);
967
838
  return { prepared, request };
968
839
  }
969
- async applyApprovalDecision(recorded, decision, runContext) {
840
+ async applyApprovalDecision(recorded, decision) {
970
841
  if (decision.approvalId !== recorded.request.approvalId) {
971
842
  throw ToolError.executionFailed(
972
843
  recorded.prepared.call.toolName,
@@ -989,7 +860,7 @@ let _ToolManager = class _ToolManager {
989
860
  response: record.response
990
861
  };
991
862
  }
992
- await this.applyApprovalGrantedEffects(recorded.prepared, record.response, runContext);
863
+ await this.applyApprovalGrantedEffects(recorded.prepared, record.response);
993
864
  return {
994
865
  kind: "ready",
995
866
  call: {
@@ -1028,28 +899,6 @@ let _ToolManager = class _ToolManager {
1028
899
  assertOnGrantedRequestMatchesPreparedCall(prepared) {
1029
900
  const approvalDetails = prepared.requestDetails;
1030
901
  const grantedDetails = prepared.onGrantedRequestDetails;
1031
- const directoryAccess = approvalDetails.type === ApprovalType.TOOL_APPROVAL && "directoryAccess" in approvalDetails.metadata ? DirectoryAccessMetadataSchema.parse(approvalDetails.metadata.directoryAccess) : void 0;
1032
- if (directoryAccess !== void 0) {
1033
- const expected = {
1034
- type: ApprovalType.DIRECTORY_ACCESS,
1035
- sessionId: approvalDetails.sessionId,
1036
- hostRuntime: approvalDetails.hostRuntime,
1037
- metadata: directoryAccess
1038
- };
1039
- const actual = {
1040
- type: grantedDetails.type,
1041
- sessionId: grantedDetails.sessionId,
1042
- hostRuntime: grantedDetails.hostRuntime,
1043
- metadata: grantedDetails.metadata
1044
- };
1045
- if (!isDeepStrictEqual(actual, expected)) {
1046
- throw ToolError.executionFailed(
1047
- prepared.call.toolName,
1048
- "Approval granted-effects request does not match the prepared tool call"
1049
- );
1050
- }
1051
- return;
1052
- }
1053
902
  if (!isDeepStrictEqual(grantedDetails, approvalDetails)) {
1054
903
  throw ToolError.executionFailed(
1055
904
  prepared.call.toolName,
@@ -1057,26 +906,30 @@ let _ToolManager = class _ToolManager {
1057
906
  );
1058
907
  }
1059
908
  }
1060
- async applyApprovalGrantedEffects(prepared, response, runContext) {
1061
- const requestDetails = prepared.onGrantedRequestDetails;
909
+ async applyApprovalGrantedEffects(prepared, response) {
1062
910
  const approvalRequestDetails = prepared.requestDetails;
1063
911
  const sessionId = approvalRequestDetails.sessionId;
1064
- const onGranted = this.getToolApprovalOnGrantedFn(prepared.call.toolName);
1065
- if (onGranted) {
1066
- const context = this.buildToolExecutionContext({
1067
- sessionId,
1068
- toolCallId: prepared.call.toolCallId,
1069
- runContext
1070
- });
1071
- await Promise.resolve(onGranted(response, context, requestDetails));
1072
- }
1073
- if (approvalRequestDetails.type === ApprovalType.TOOL_APPROVAL && response.data) {
912
+ if (approvalRequestDetails.type === ApprovalType.TOOL_APPROVAL) {
913
+ const toolMetadata = ToolApprovalMetadataSchema.parse(approvalRequestDetails.metadata);
914
+ const approvalKey = toolMetadata.approvalKey;
915
+ const data = response.data ? ToolApprovalResponseDataSchema.parse(response.data) : void 0;
916
+ if (approvalKey !== void 0) {
917
+ await this.approvalManager.addApprovedKey(
918
+ approvalKey,
919
+ data?.rememberChoice ? "session" : "once",
920
+ sessionId
921
+ );
922
+ }
923
+ if (!data) {
924
+ return;
925
+ }
1074
926
  await this.handleRememberChoice(
1075
927
  prepared.call.toolName,
1076
928
  {
1077
- data: ToolApprovalResponseDataSchema.parse(response.data),
929
+ data,
1078
930
  ...response.sessionId !== void 0 ? { sessionId: response.sessionId } : {}
1079
931
  },
932
+ approvalKey,
1080
933
  sessionId
1081
934
  );
1082
935
  }
@@ -1132,72 +985,6 @@ let _ToolManager = class _ToolManager {
1132
985
  }
1133
986
  };
1134
987
  }
1135
- async getToolApprovalOverrideRequest(toolName, args, toolCallId, sessionId, runContext) {
1136
- if (toolName.startsWith(_ToolManager.MCP_TOOL_PREFIX)) {
1137
- return null;
1138
- }
1139
- const getApprovalOverride = this.getToolApprovalOverrideFn(toolName);
1140
- if (!getApprovalOverride) {
1141
- return null;
1142
- }
1143
- const context = this.buildToolExecutionContext({ sessionId, toolCallId, runContext });
1144
- const approvalRequest = await getApprovalOverride(args, context);
1145
- if (!approvalRequest) {
1146
- return null;
1147
- }
1148
- const requestDetails = {
1149
- ...approvalRequest,
1150
- ...sessionId && !approvalRequest.sessionId ? { sessionId } : {},
1151
- ...runContext?.hostRuntime !== void 0 && approvalRequest.hostRuntime === void 0 ? { hostRuntime: runContext.hostRuntime } : {}
1152
- };
1153
- if (requestDetails.type !== ApprovalType.DIRECTORY_ACCESS) {
1154
- return { requestDetails, onGrantedRequestDetails: requestDetails };
1155
- }
1156
- const parseResult = DirectoryAccessMetadataSchema.safeParse(requestDetails.metadata);
1157
- if (!parseResult.success) {
1158
- throw ToolError.configInvalid(
1159
- `Tool '${toolName}' returned invalid directory access metadata`
1160
- );
1161
- }
1162
- const directoryAccess = parseResult.data;
1163
- return {
1164
- directoryAccess,
1165
- onGrantedRequestDetails: requestDetails,
1166
- requestDetails: {
1167
- type: ApprovalType.TOOL_APPROVAL,
1168
- ...requestDetails.sessionId !== void 0 ? { sessionId: requestDetails.sessionId } : {},
1169
- ...requestDetails.hostRuntime !== void 0 ? { hostRuntime: requestDetails.hostRuntime } : {},
1170
- metadata: {
1171
- toolName,
1172
- toolCallId,
1173
- args,
1174
- directoryAccess
1175
- }
1176
- }
1177
- };
1178
- }
1179
- async classifyQuickApprovalRequirement(toolName, args, sessionId, directoryAccess) {
1180
- if (directoryAccess) {
1181
- return this.approvalMode === "auto-approve" ? "ready" : "approval-required";
1182
- }
1183
- if (sessionId && this.isToolAutoApprovedForSession(sessionId, toolName)) {
1184
- return "ready";
1185
- }
1186
- if (this.isInAlwaysAllowList(toolName)) {
1187
- return "ready";
1188
- }
1189
- if (await this.allowedToolsProvider.isToolAllowed(toolName, sessionId)) {
1190
- return "ready";
1191
- }
1192
- const patternKey = this.getToolPatternKey(toolName, args);
1193
- if (patternKey && this.approvalManager.matchesPattern(toolName, patternKey, sessionId)) {
1194
- return "ready";
1195
- }
1196
- if (this.approvalMode === "auto-approve") {
1197
- return "ready";
1198
- }
1199
- return "approval-required";
1200
- }
1201
988
  async executeTool(toolName, args, toolCallId, invocation) {
1202
989
  const { sessionId, runContext, hostRuntime } = this.resolveToolExecutionInvocation(invocation);
1203
990
  this.logger.debug(`\u{1F527} Tool execution requested: '${toolName}' (toolCallId: ${toolCallId})`);
@@ -1230,17 +1017,14 @@ let _ToolManager = class _ToolManager {
1230
1017
  this.resolveDirectApprovalIdentity(invocation, toolCallId)
1231
1018
  );
1232
1019
  const response = await this.requestApprovalDecision(recorded);
1233
- applied = await this.applyApprovalDecision(
1234
- recorded,
1235
- {
1236
- approvalId: response.approvalId,
1237
- status: response.status,
1238
- ...response.reason !== void 0 ? { reason: response.reason } : {},
1239
- ...response.message !== void 0 ? { message: response.message } : {},
1240
- ...response.data !== void 0 ? { data: response.data } : {}
1241
- },
1242
- runContext
1243
- );
1020
+ applied = await this.applyApprovalDecision(recorded, {
1021
+ approvalId: response.approvalId,
1022
+ status: response.status,
1023
+ ...response.reason !== void 0 ? { reason: response.reason } : {},
1024
+ ...response.message !== void 0 ? { message: response.message } : {},
1025
+ ...response.timeoutMs !== void 0 ? { timeoutMs: response.timeoutMs } : {},
1026
+ ...response.data !== void 0 ? { data: response.data } : {}
1027
+ });
1244
1028
  } catch (error) {
1245
1029
  await this.recordDirectToolExecutionFailure(prepared.call, invocation, error);
1246
1030
  throw error;
@@ -1746,26 +1530,21 @@ let _ToolManager = class _ToolManager {
1746
1530
  /**
1747
1531
  * Handle "remember" actions when user approves a tool.
1748
1532
  */
1749
- async handleRememberChoice(toolName, response, sessionId) {
1533
+ async handleRememberChoice(toolName, response, approvalKey, sessionId) {
1750
1534
  const data = response.data;
1751
1535
  if (!data) return;
1752
1536
  const rememberChoice = data.rememberChoice;
1753
- const rememberPattern = data.rememberPattern;
1754
- const rememberDirectory = data.rememberDirectory;
1755
1537
  if (rememberChoice) {
1756
1538
  const allowSessionId = sessionId ?? response.sessionId;
1757
- await this.allowedToolsProvider.allowTool(toolName, allowSessionId);
1758
- this.logger.info(
1759
- `Tool '${toolName}' added to allowed tools for session '${allowSessionId ?? "global"}' (remember choice selected)`
1760
- );
1761
- this.autoApprovePendingToolRequests(toolName, allowSessionId);
1762
- } else if (rememberPattern && this.getToolApprovalPatternKeyFn(toolName)) {
1763
- await this.approvalManager.addPattern(toolName, rememberPattern, sessionId);
1764
- this.logger.info(`Pattern '${rememberPattern}' added for tool '${toolName}' approval`);
1765
- this.autoApprovePendingPatternRequests(toolName, sessionId);
1766
- } else if (rememberDirectory) {
1767
- const allowSessionId = sessionId ?? response.sessionId;
1768
- this.autoApprovePendingDirectoryRequests(toolName, allowSessionId);
1539
+ if (approvalKey !== void 0) {
1540
+ this.autoApprovePendingApprovalKeyRequests(approvalKey, allowSessionId);
1541
+ } else {
1542
+ await this.allowedToolsProvider.allowTool(toolName, allowSessionId);
1543
+ this.logger.info(
1544
+ `Tool '${toolName}' added to allowed tools for session '${allowSessionId ?? "global"}' (remember choice selected)`
1545
+ );
1546
+ this.autoApprovePendingToolRequests(toolName, allowSessionId);
1547
+ }
1769
1548
  }
1770
1549
  }
1771
1550
  /**
@@ -2,7 +2,6 @@ import type { JSONSchema7 } from 'json-schema';
2
2
  import type { z, ZodTypeAny } from 'zod';
3
3
  import type { ToolDisplayData } from './display-types.js';
4
4
  import type { WorkspaceContext } from '../workspace/types.js';
5
- import type { ApprovalRequestDetails, ApprovalResponse } from '../approval/types.js';
6
5
  import type { ApprovalManager } from '../approval/manager.js';
7
6
  import type { DextoAgent } from '../agent/DextoAgent.js';
8
7
  import type { ToolStateStore } from '../storage/index.js';
@@ -209,9 +208,15 @@ export interface Tool<TSchema extends ZodTypeAny = ZodTypeAny> {
209
208
  /** The actual function that executes the tool - input is validated by Zod before execution */
210
209
  execute(input: z.output<TSchema>, context: ToolExecutionContext): Promise<unknown> | unknown;
211
210
  /**
212
- * Optional grouped approval-related behavior.
211
+ * Optional per-call approval policy.
212
+ *
213
+ * - `false` / `null`: this tool call does not need approval.
214
+ * - `true`: this tool call needs approval without a reusable key.
215
+ * - `string`: this tool call needs approval scoped to an opaque key owned by the tool.
216
+ *
217
+ * Core stores and checks keys opaquely; tool packages decide what keys mean.
213
218
  */
214
- approval?: ToolApproval<TSchema> | undefined;
219
+ needsApproval?: ToolNeedsApproval<TSchema> | undefined;
215
220
  /**
216
221
  * Optional grouped UI/presentation-related behavior.
217
222
  */
@@ -225,12 +230,8 @@ export interface Tool<TSchema extends ZodTypeAny = ZodTypeAny> {
225
230
  */
226
231
  aliases?: string[] | undefined;
227
232
  }
228
- export interface ToolApproval<TSchema extends ZodTypeAny = ZodTypeAny> {
229
- override?(input: z.output<TSchema>, context: ToolExecutionContext): Promise<ApprovalRequestDetails | null> | ApprovalRequestDetails | null;
230
- onGranted?(response: ApprovalResponse, context: ToolExecutionContext, approvalRequest: ApprovalRequestDetails): Promise<void> | void;
231
- patternKey?(input: z.output<TSchema>): string | null;
232
- suggestPatterns?(input: z.output<TSchema>): string[];
233
- }
233
+ export type ToolApprovalDecision = boolean | string | null;
234
+ export type ToolNeedsApproval<TSchema extends ZodTypeAny = ZodTypeAny> = ToolApprovalDecision | ((input: z.output<TSchema>, context: ToolExecutionContext) => Promise<ToolApprovalDecision> | ToolApprovalDecision);
234
235
  export interface ToolPresentation<TSchema extends ZodTypeAny = ZodTypeAny> {
235
236
  /**
236
237
  * Optional rich preview used in approval prompts.
@@ -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,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KA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UAAU,EAAE,WAAW,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,CAAC;CACL;AAMD;;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"}
@@ -221,6 +221,9 @@ async function createAgentServices(config, logger, agentEventBus, overrides, com
221
221
  },
222
222
  ...overrides?.authResolver !== void 0 && {
223
223
  authResolver: overrides.authResolver
224
+ },
225
+ ...overrides?.executionControl !== void 0 && {
226
+ executionControl: overrides.executionControl
224
227
  }
225
228
  },
226
229
  logger
@@ -20,7 +20,7 @@ import { MemoryManager } from '../memory/index.js';
20
20
  import { HookManager } from '../hooks/manager.js';
21
21
  import type { Hook } from '../hooks/types.js';
22
22
  import type { CompactionStrategy } from '../context/compaction/types.js';
23
- import type { LanguageModelFactory } from '../llm/services/types.js';
23
+ import type { LLMExecutionControl, LanguageModelFactory } from '../llm/services/types.js';
24
24
  import type { WorkspaceHandleProvider } from '../workspace/types.js';
25
25
  /**
26
26
  * Type for the core agent services returned by createAgentServices
@@ -70,6 +70,7 @@ export type InitializeServicesOptions = {
70
70
  hooks?: Hook[] | undefined;
71
71
  workspaceHandleProvider?: WorkspaceHandleProvider | undefined;
72
72
  telemetryBootstrap?: TelemetryBootstrap | undefined;
73
+ executionControl?: LLMExecutionControl | undefined;
73
74
  };
74
75
  export declare function initializeAgentTelemetry(config: AgentRuntimeSettings, logger: Logger, telemetryBootstrap?: TelemetryBootstrap | undefined): Promise<void>;
75
76
  /**