@dexto/core 1.8.12 → 1.9.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/approval/manager.cjs +37 -325
- package/dist/approval/manager.d.ts +10 -109
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +37 -316
- package/dist/approval/schemas.cjs +8 -51
- package/dist/approval/schemas.d.ts +5 -179
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +8 -47
- package/dist/approval/types.cjs +0 -6
- package/dist/approval/types.d.ts +2 -27
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/approval/types.js +0 -6
- package/dist/context/compaction/strategies/reactive-overflow-compaction.cjs +2 -0
- package/dist/context/compaction/strategies/reactive-overflow-compaction.d.ts.map +1 -1
- package/dist/context/compaction/strategies/reactive-overflow-compaction.js +2 -0
- package/dist/context/content-clone.cjs +55 -10
- package/dist/context/content-clone.d.ts +1 -0
- package/dist/context/content-clone.d.ts.map +1 -1
- package/dist/context/content-clone.js +53 -9
- package/dist/context/manager.cjs +25 -4
- package/dist/context/manager.d.ts +4 -2
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +25 -4
- package/dist/context/schemas.cjs +15 -1
- package/dist/context/schemas.d.ts.map +1 -1
- package/dist/context/schemas.js +15 -1
- package/dist/context/types.d.ts +11 -0
- package/dist/context/types.d.ts.map +1 -1
- package/dist/errors/DextoRuntimeError.cjs +3 -1
- package/dist/errors/DextoRuntimeError.d.ts +5 -3
- package/dist/errors/DextoRuntimeError.d.ts.map +1 -1
- package/dist/errors/DextoRuntimeError.js +3 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/types.d.ts +1 -0
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/llm/executor/provider-error.cjs +25 -4
- package/dist/llm/executor/provider-error.d.ts.map +1 -1
- package/dist/llm/executor/provider-error.js +25 -4
- package/dist/llm/executor/stream-processor.cjs +98 -7
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +98 -7
- package/dist/llm/executor/turn-executor.cjs +96 -28
- package/dist/llm/executor/turn-executor.d.ts +2 -0
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +96 -28
- package/dist/llm/providers/local/schemas.d.ts +2 -2
- package/dist/llm/services/factory.cjs +3 -2
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +3 -2
- package/dist/llm/services/types.d.ts +8 -0
- package/dist/llm/services/types.d.ts.map +1 -1
- package/dist/llm/services/vercel.cjs +6 -1
- package/dist/llm/services/vercel.d.ts +3 -2
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +6 -1
- package/dist/session/chat-session.cjs +4 -0
- package/dist/session/chat-session.d.ts +2 -1
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +4 -0
- package/dist/session/message-queue.cjs +48 -75
- package/dist/session/message-queue.d.ts +1 -2
- package/dist/session/message-queue.d.ts.map +1 -1
- package/dist/session/message-queue.js +48 -75
- package/dist/session/session-manager.cjs +14 -32
- package/dist/session/session-manager.d.ts +5 -2
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +14 -32
- package/dist/storage/approvals/types.cjs +2 -9
- package/dist/storage/approvals/types.d.ts +4 -16
- package/dist/storage/approvals/types.d.ts.map +1 -1
- package/dist/storage/approvals/types.js +2 -8
- package/dist/storage/database/types.d.ts +5 -0
- package/dist/storage/database/types.d.ts.map +1 -1
- package/dist/storage/index.cjs +0 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +1 -2
- package/dist/storage/message-queue/types.d.ts +14 -6
- package/dist/storage/message-queue/types.d.ts.map +1 -1
- package/dist/storage/stores/backend.cjs +68 -32
- package/dist/storage/stores/backend.d.ts +17 -8
- package/dist/storage/stores/backend.d.ts.map +1 -1
- package/dist/storage/stores/backend.js +69 -33
- package/dist/storage/stores/in-memory.cjs +26 -11
- package/dist/storage/stores/in-memory.d.ts.map +1 -1
- package/dist/storage/stores/in-memory.js +27 -12
- package/dist/test-utils/in-memory-storage.cjs +11 -0
- package/dist/test-utils/in-memory-storage.js +11 -0
- package/dist/test-utils/session-state-stores.cjs +25 -9
- package/dist/test-utils/session-state-stores.js +26 -10
- package/dist/tools/approval/tool-approval-policy.cjs +87 -0
- package/dist/tools/approval/tool-approval-policy.d.ts +34 -0
- package/dist/tools/approval/tool-approval-policy.d.ts.map +1 -0
- package/dist/tools/approval/tool-approval-policy.js +64 -0
- package/dist/tools/error-codes.cjs +0 -1
- package/dist/tools/error-codes.d.ts +0 -1
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +0 -1
- package/dist/tools/errors.cjs +0 -15
- package/dist/tools/errors.d.ts +0 -9
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +0 -15
- package/dist/tools/index.cjs +2 -0
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +5 -1
- package/dist/tools/tool-manager.cjs +94 -312
- package/dist/tools/tool-manager.d.ts +4 -19
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +95 -316
- package/dist/tools/types.d.ts +10 -9
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/service-initializer.cjs +3 -0
- package/dist/utils/service-initializer.d.ts +2 -1
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +3 -0
- package/package.json +2 -2
- package/dist/tools/pattern-utils.cjs +0 -33
- package/dist/tools/pattern-utils.d.ts +0 -20
- package/dist/tools/pattern-utils.d.ts.map +0 -1
- 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
|
-
// ====================
|
|
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
|
|
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
|
-
|
|
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
|
-
{
|
|
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
|
-
|
|
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
|
|
874
|
-
|
|
875
|
-
|
|
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
|
-
|
|
903
|
-
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
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
|
-
|
|
931
|
-
|
|
790
|
+
return await this.prepareApprovalRequiredToolCall({
|
|
791
|
+
approvalGate,
|
|
932
792
|
args: validatedArgs,
|
|
933
|
-
|
|
793
|
+
call,
|
|
794
|
+
...callDescription !== void 0 ? { callDescription } : {},
|
|
795
|
+
...input.runContext !== void 0 ? { runContext: input.runContext } : {},
|
|
934
796
|
...sessionId !== void 0 ? { sessionId } : {},
|
|
935
|
-
|
|
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
|
-
|
|
816
|
+
...input.approvalGate.approvalKey !== void 0 ? { approvalKey: input.approvalGate.approvalKey } : {},
|
|
817
|
+
presentationSnapshot: input.call.presentationSnapshot,
|
|
946
818
|
toolCallId: input.toolCallId,
|
|
947
|
-
args:
|
|
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
|
|
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
|
|
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
|
|
1061
|
-
const requestDetails = prepared.onGrantedRequestDetails;
|
|
909
|
+
async applyApprovalGrantedEffects(prepared, response) {
|
|
1062
910
|
const approvalRequestDetails = prepared.requestDetails;
|
|
1063
911
|
const sessionId = approvalRequestDetails.sessionId;
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
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
|
|
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
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
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
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
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
|
/**
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
229
|
-
|
|
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,
|
|
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,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,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,K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K,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EACxB,OAAO,EAAE,oBAAoB,GAE3B,OAAO,CAAC,0BAA0B,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,GACpD,0BAA0B,CAAC,QAAQ,CAAC,GACpC,IAAI,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,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
|
/**
|