@dexto/core 1.5.2 → 1.5.3
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/agent/DextoAgent.cjs +12 -1
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +12 -1
- package/dist/agent/schemas.d.ts +42 -0
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/approval/manager.cjs +16 -0
- package/dist/approval/manager.d.ts +10 -0
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +16 -0
- package/dist/approval/types.d.ts +11 -0
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/events/index.cjs +3 -1
- package/dist/events/index.d.ts +19 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +3 -1
- package/dist/filesystem/filesystem-service.cjs +18 -15
- package/dist/filesystem/filesystem-service.d.ts +3 -3
- package/dist/filesystem/filesystem-service.d.ts.map +1 -1
- package/dist/filesystem/filesystem-service.js +18 -15
- package/dist/filesystem/path-validator.cjs +16 -7
- package/dist/filesystem/path-validator.d.ts +10 -3
- package/dist/filesystem/path-validator.d.ts.map +1 -1
- package/dist/filesystem/path-validator.js +16 -7
- package/dist/filesystem/types.d.ts +4 -0
- package/dist/filesystem/types.d.ts.map +1 -1
- package/dist/logger/v2/schemas.cjs +4 -0
- package/dist/logger/v2/schemas.d.ts +16 -0
- package/dist/logger/v2/schemas.d.ts.map +1 -1
- package/dist/logger/v2/schemas.js +4 -0
- package/dist/logger/v2/transport-factory.cjs +4 -1
- package/dist/logger/v2/transport-factory.d.ts.map +1 -1
- package/dist/logger/v2/transport-factory.js +4 -1
- package/dist/logger/v2/transports/silent-transport.cjs +33 -0
- package/dist/logger/v2/transports/silent-transport.d.ts +15 -0
- package/dist/logger/v2/transports/silent-transport.d.ts.map +1 -0
- package/dist/logger/v2/transports/silent-transport.js +10 -0
- package/dist/tools/error-codes.cjs +1 -0
- package/dist/tools/error-codes.d.ts +1 -0
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +1 -0
- package/dist/tools/errors.cjs +17 -0
- package/dist/tools/errors.d.ts +9 -0
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +17 -0
- package/dist/tools/internal-tools/provider.cjs +3 -2
- package/dist/tools/internal-tools/provider.d.ts +1 -1
- package/dist/tools/internal-tools/provider.d.ts.map +1 -1
- package/dist/tools/internal-tools/provider.js +3 -2
- package/dist/tools/tool-manager.cjs +77 -4
- package/dist/tools/tool-manager.d.ts +18 -0
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +78 -5
- package/dist/tools/types.d.ts +5 -3
- package/dist/tools/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Silent Transport
|
|
3
|
+
*
|
|
4
|
+
* A no-op transport that discards all log entries.
|
|
5
|
+
* Used when logging needs to be completely suppressed (e.g., sub-agents).
|
|
6
|
+
*/
|
|
7
|
+
import type { ILoggerTransport, LogEntry } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* SilentTransport - Discards all log entries
|
|
10
|
+
*/
|
|
11
|
+
export declare class SilentTransport implements ILoggerTransport {
|
|
12
|
+
write(_entry: LogEntry): void;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=silent-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"silent-transport.d.ts","sourceRoot":"","sources":["../../../../src/logger/v2/transports/silent-transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE9D;;GAEG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IACpD,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI;IAI7B,OAAO,IAAI,IAAI;CAGlB"}
|
|
@@ -27,6 +27,7 @@ var ToolErrorCode = /* @__PURE__ */ ((ToolErrorCode2) => {
|
|
|
27
27
|
ToolErrorCode2["EXECUTION_FAILED"] = "tools_execution_failed";
|
|
28
28
|
ToolErrorCode2["DIRECTORY_ACCESS_DENIED"] = "tools_directory_access_denied";
|
|
29
29
|
ToolErrorCode2["VALIDATION_FAILED"] = "tools_validation_failed";
|
|
30
|
+
ToolErrorCode2["FILE_MODIFIED_SINCE_PREVIEW"] = "tools_file_modified_since_preview";
|
|
30
31
|
ToolErrorCode2["CONFIRMATION_HANDLER_MISSING"] = "tools_confirmation_handler_missing";
|
|
31
32
|
ToolErrorCode2["CONFIRMATION_TIMEOUT"] = "tools_confirmation_timeout";
|
|
32
33
|
ToolErrorCode2["CONFIRMATION_CANCELLED"] = "tools_confirmation_cancelled";
|
|
@@ -8,6 +8,7 @@ export declare enum ToolErrorCode {
|
|
|
8
8
|
EXECUTION_FAILED = "tools_execution_failed",
|
|
9
9
|
DIRECTORY_ACCESS_DENIED = "tools_directory_access_denied",
|
|
10
10
|
VALIDATION_FAILED = "tools_validation_failed",
|
|
11
|
+
FILE_MODIFIED_SINCE_PREVIEW = "tools_file_modified_since_preview",
|
|
11
12
|
CONFIRMATION_HANDLER_MISSING = "tools_confirmation_handler_missing",
|
|
12
13
|
CONFIRMATION_TIMEOUT = "tools_confirmation_timeout",
|
|
13
14
|
CONFIRMATION_CANCELLED = "tools_confirmation_cancelled",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/tools/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,aAAa;IAErB,gBAAgB,2BAA2B;IAC3C,iBAAiB,4BAA4B;IAC7C,gBAAgB,2BAA2B;IAC3C,uBAAuB,kCAAkC;IAGzD,iBAAiB,4BAA4B;
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/tools/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,aAAa;IAErB,gBAAgB,2BAA2B;IAC3C,iBAAiB,4BAA4B;IAC7C,gBAAgB,2BAA2B;IAC3C,uBAAuB,kCAAkC;IAGzD,iBAAiB,4BAA4B;IAC7C,2BAA2B,sCAAsC;IAGjE,4BAA4B,uCAAuC;IACnE,oBAAoB,+BAA+B;IACnD,sBAAsB,iCAAiC;IAGvD,cAAc,yBAAyB;IACvC,iBAAiB,uBAAuB;IACxC,iBAAiB,uBAAuB;IAGxC,cAAc,yBAAyB;IACvC,gBAAgB,2BAA2B;IAG3C,4BAA4B,kCAAkC;IAC9D,uCAAuC,6CAA6C;CACvF"}
|
|
@@ -5,6 +5,7 @@ var ToolErrorCode = /* @__PURE__ */ ((ToolErrorCode2) => {
|
|
|
5
5
|
ToolErrorCode2["EXECUTION_FAILED"] = "tools_execution_failed";
|
|
6
6
|
ToolErrorCode2["DIRECTORY_ACCESS_DENIED"] = "tools_directory_access_denied";
|
|
7
7
|
ToolErrorCode2["VALIDATION_FAILED"] = "tools_validation_failed";
|
|
8
|
+
ToolErrorCode2["FILE_MODIFIED_SINCE_PREVIEW"] = "tools_file_modified_since_preview";
|
|
8
9
|
ToolErrorCode2["CONFIRMATION_HANDLER_MISSING"] = "tools_confirmation_handler_missing";
|
|
9
10
|
ToolErrorCode2["CONFIRMATION_TIMEOUT"] = "tools_confirmation_timeout";
|
|
10
11
|
ToolErrorCode2["CONFIRMATION_CANCELLED"] = "tools_confirmation_cancelled";
|
package/dist/tools/errors.cjs
CHANGED
|
@@ -103,6 +103,23 @@ class ToolError {
|
|
|
103
103
|
{ toolName, reason, ...context }
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* File was modified between preview and execute.
|
|
108
|
+
* This is a safety check to prevent corrupting user edits.
|
|
109
|
+
*/
|
|
110
|
+
static fileModifiedSincePreview(toolName, filePath) {
|
|
111
|
+
return new import_DextoRuntimeError.DextoRuntimeError(
|
|
112
|
+
import_error_codes.ToolErrorCode.FILE_MODIFIED_SINCE_PREVIEW,
|
|
113
|
+
import_types.ErrorScope.TOOLS,
|
|
114
|
+
import_types.ErrorType.USER,
|
|
115
|
+
`File '${filePath}' was modified since the preview was generated. Please read the file again and retry the operation.`,
|
|
116
|
+
{
|
|
117
|
+
toolName,
|
|
118
|
+
filePath,
|
|
119
|
+
recovery: "Read the file with read_file tool to get current content, then retry the edit."
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
106
123
|
/**
|
|
107
124
|
* Tool unauthorized access
|
|
108
125
|
*/
|
package/dist/tools/errors.d.ts
CHANGED
|
@@ -51,6 +51,15 @@ export declare class ToolError {
|
|
|
51
51
|
toolName: string;
|
|
52
52
|
reason: string;
|
|
53
53
|
}>;
|
|
54
|
+
/**
|
|
55
|
+
* File was modified between preview and execute.
|
|
56
|
+
* This is a safety check to prevent corrupting user edits.
|
|
57
|
+
*/
|
|
58
|
+
static fileModifiedSincePreview(toolName: string, filePath: string): DextoRuntimeError<{
|
|
59
|
+
toolName: string;
|
|
60
|
+
filePath: string;
|
|
61
|
+
recovery: string;
|
|
62
|
+
}>;
|
|
54
63
|
/**
|
|
55
64
|
* Tool unauthorized access
|
|
56
65
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/tools/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAItE;;;GAGG;AACH,qBAAa,SAAS;IAClB;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM;;;IAUhC;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;;;;;IAU3E;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,MAA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MAAM,CAAC,0BAA0B,CAAC,QAAQ,EAAE,MAAM;;;IAUlD;;OAEG;IACH,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;;;;;IAUlF;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;IAUnD;;OAEG;IACH,MAAM,CAAC,2BAA2B,CAAC,QAAQ,EAAE,MAAM;;;IAUnD;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM;IAUpC;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;IAU7D;;OAEG;IACH,MAAM,CAAC,eAAe,CAClB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EAAE,EACzB,OAAO,EAAE,MAAM,GAChB,iBAAiB,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAcrE;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,iBAAiB;IAW3F;;OAEG;IACH,MAAM,CAAC,mCAAmC,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB;CAU9E"}
|
package/dist/tools/errors.js
CHANGED
|
@@ -81,6 +81,23 @@ class ToolError {
|
|
|
81
81
|
{ toolName, reason, ...context }
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* File was modified between preview and execute.
|
|
86
|
+
* This is a safety check to prevent corrupting user edits.
|
|
87
|
+
*/
|
|
88
|
+
static fileModifiedSincePreview(toolName, filePath) {
|
|
89
|
+
return new DextoRuntimeError(
|
|
90
|
+
ToolErrorCode.FILE_MODIFIED_SINCE_PREVIEW,
|
|
91
|
+
ErrorScope.TOOLS,
|
|
92
|
+
ErrorType.USER,
|
|
93
|
+
`File '${filePath}' was modified since the preview was generated. Please read the file again and retry the operation.`,
|
|
94
|
+
{
|
|
95
|
+
toolName,
|
|
96
|
+
filePath,
|
|
97
|
+
recovery: "Read the file with read_file tool to get current content, then retry the edit."
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
84
101
|
/**
|
|
85
102
|
* Tool unauthorized access
|
|
86
103
|
*/
|
|
@@ -201,7 +201,7 @@ class InternalToolsProvider {
|
|
|
201
201
|
/**
|
|
202
202
|
* Execute an internal tool - confirmation is handled by ToolManager
|
|
203
203
|
*/
|
|
204
|
-
async executeTool(toolName, args, sessionId, abortSignal) {
|
|
204
|
+
async executeTool(toolName, args, sessionId, abortSignal, toolCallId) {
|
|
205
205
|
const tool = this.internalTools.get(toolName) || this.customTools.get(toolName);
|
|
206
206
|
if (!tool) {
|
|
207
207
|
this.logger.error(`\u274C No tool found: ${toolName}`);
|
|
@@ -226,7 +226,8 @@ class InternalToolsProvider {
|
|
|
226
226
|
try {
|
|
227
227
|
const context = {
|
|
228
228
|
sessionId,
|
|
229
|
-
abortSignal
|
|
229
|
+
abortSignal,
|
|
230
|
+
toolCallId
|
|
230
231
|
};
|
|
231
232
|
const result = await tool.execute(validationResult.data, context);
|
|
232
233
|
return result;
|
|
@@ -65,7 +65,7 @@ export declare class InternalToolsProvider {
|
|
|
65
65
|
/**
|
|
66
66
|
* Execute an internal tool - confirmation is handled by ToolManager
|
|
67
67
|
*/
|
|
68
|
-
executeTool(toolName: string, args: Record<string, unknown>, sessionId?: string, abortSignal?: AbortSignal): Promise<unknown>;
|
|
68
|
+
executeTool(toolName: string, args: Record<string, unknown>, sessionId?: string, abortSignal?: AbortSignal, toolCallId?: string): Promise<unknown>;
|
|
69
69
|
/**
|
|
70
70
|
* Get internal tools in ToolSet format (excludes custom tools)
|
|
71
71
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":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AAO;IAIlC;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI1C;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIxC;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAInD;;OAEG;IACG,WAAW,CACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,SAAS,CAAC,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,OAAO,CAAC;IA0CnB;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAc3B;;OAEG;IACH,cAAc,IAAI,OAAO;IAczB;;OAEG;IACH,oBAAoB,IAAI,MAAM,EAAE;IAIhC;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACH,YAAY,IAAI,MAAM,EAAE;IAIxB;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;OAEG;IACH,oBAAoB,IAAI,MAAM;IAI9B;;OAEG;IACH,kBAAkB,IAAI,MAAM;CAG/B"}
|
|
@@ -179,7 +179,7 @@ class InternalToolsProvider {
|
|
|
179
179
|
/**
|
|
180
180
|
* Execute an internal tool - confirmation is handled by ToolManager
|
|
181
181
|
*/
|
|
182
|
-
async executeTool(toolName, args, sessionId, abortSignal) {
|
|
182
|
+
async executeTool(toolName, args, sessionId, abortSignal, toolCallId) {
|
|
183
183
|
const tool = this.internalTools.get(toolName) || this.customTools.get(toolName);
|
|
184
184
|
if (!tool) {
|
|
185
185
|
this.logger.error(`\u274C No tool found: ${toolName}`);
|
|
@@ -204,7 +204,8 @@ class InternalToolsProvider {
|
|
|
204
204
|
try {
|
|
205
205
|
const context = {
|
|
206
206
|
sessionId,
|
|
207
|
-
abortSignal
|
|
207
|
+
abortSignal,
|
|
208
|
+
toolCallId
|
|
208
209
|
};
|
|
209
210
|
const result = await tool.execute(validationResult.data, context);
|
|
210
211
|
return result;
|
|
@@ -212,6 +212,75 @@ let _ToolManager = class _ToolManager {
|
|
|
212
212
|
suggestedPatterns: (0, import_bash_pattern_utils.generateBashPatternSuggestions)(command)
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Auto-approve pending tool confirmation requests for the same tool.
|
|
217
|
+
* Called after a user selects "remember choice" for a tool.
|
|
218
|
+
* This handles the case where parallel tool calls come in before the first one is approved.
|
|
219
|
+
*
|
|
220
|
+
* @param toolName The tool name that was just remembered
|
|
221
|
+
* @param sessionId The session ID for which the tool was allowed
|
|
222
|
+
*/
|
|
223
|
+
autoApprovePendingToolRequests(toolName, sessionId) {
|
|
224
|
+
const count = this.approvalManager.autoApprovePendingRequests(
|
|
225
|
+
(request) => {
|
|
226
|
+
if (request.type !== import_types3.ApprovalType.TOOL_CONFIRMATION) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
if (request.sessionId !== sessionId) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
const metadata = request.metadata;
|
|
233
|
+
return metadata.toolName === toolName;
|
|
234
|
+
},
|
|
235
|
+
{ rememberChoice: false }
|
|
236
|
+
// Don't propagate remember choice to auto-approved requests
|
|
237
|
+
);
|
|
238
|
+
if (count > 0) {
|
|
239
|
+
this.logger.info(
|
|
240
|
+
`Auto-approved ${count} parallel request(s) for tool '${toolName}' after user selected "remember choice"`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Auto-approve pending bash command requests that match a pattern.
|
|
246
|
+
* Called after a user selects "remember pattern" for a bash command.
|
|
247
|
+
* This handles the case where parallel bash commands come in before the first one is approved.
|
|
248
|
+
*
|
|
249
|
+
* @param pattern The bash pattern that was just remembered
|
|
250
|
+
* @param sessionId The session ID for context
|
|
251
|
+
*/
|
|
252
|
+
autoApprovePendingBashRequests(pattern, sessionId) {
|
|
253
|
+
const count = this.approvalManager.autoApprovePendingRequests(
|
|
254
|
+
(request) => {
|
|
255
|
+
if (request.type !== import_types3.ApprovalType.TOOL_CONFIRMATION) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
if (request.sessionId !== sessionId) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
const metadata = request.metadata;
|
|
262
|
+
if (!this.isBashTool(metadata.toolName)) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
const command = metadata.args?.command;
|
|
266
|
+
if (!command) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
const patternKey = (0, import_bash_pattern_utils.generateBashPatternKey)(command);
|
|
270
|
+
if (!patternKey) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
return this.approvalManager.matchesBashPattern(patternKey);
|
|
274
|
+
},
|
|
275
|
+
{ rememberPattern: void 0 }
|
|
276
|
+
// Don't propagate pattern to auto-approved requests
|
|
277
|
+
);
|
|
278
|
+
if (count > 0) {
|
|
279
|
+
this.logger.info(
|
|
280
|
+
`Auto-approved ${count} parallel bash command(s) matching pattern '${pattern}'`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
215
284
|
getMcpManager() {
|
|
216
285
|
return this.mcpManager;
|
|
217
286
|
}
|
|
@@ -393,7 +462,8 @@ let _ToolManager = class _ToolManager {
|
|
|
393
462
|
actualToolName,
|
|
394
463
|
args,
|
|
395
464
|
sessionId,
|
|
396
|
-
abortSignal
|
|
465
|
+
abortSignal,
|
|
466
|
+
toolCallId
|
|
397
467
|
);
|
|
398
468
|
} else if (toolName.startsWith(_ToolManager.CUSTOM_TOOL_PREFIX)) {
|
|
399
469
|
this.logger.debug(`\u{1F527} Detected custom tool: '${toolName}'`);
|
|
@@ -409,7 +479,8 @@ let _ToolManager = class _ToolManager {
|
|
|
409
479
|
actualToolName,
|
|
410
480
|
args,
|
|
411
481
|
sessionId,
|
|
412
|
-
abortSignal
|
|
482
|
+
abortSignal,
|
|
483
|
+
toolCallId
|
|
413
484
|
);
|
|
414
485
|
} else {
|
|
415
486
|
this.logger.debug(`\u{1F527} Detected tool without proper prefix: '${toolName}'`);
|
|
@@ -627,7 +698,7 @@ let _ToolManager = class _ToolManager {
|
|
|
627
698
|
if (!tool?.getApprovalOverride) {
|
|
628
699
|
return { handled: false };
|
|
629
700
|
}
|
|
630
|
-
const approvalRequest = tool.getApprovalOverride(args);
|
|
701
|
+
const approvalRequest = await tool.getApprovalOverride(args);
|
|
631
702
|
if (!approvalRequest) {
|
|
632
703
|
return { handled: false };
|
|
633
704
|
}
|
|
@@ -728,7 +799,7 @@ let _ToolManager = class _ToolManager {
|
|
|
728
799
|
const internalTool = this.internalToolsProvider?.getTool(actualToolName);
|
|
729
800
|
if (internalTool?.generatePreview) {
|
|
730
801
|
try {
|
|
731
|
-
const context = { sessionId };
|
|
802
|
+
const context = { sessionId, toolCallId };
|
|
732
803
|
const preview = await internalTool.generatePreview(args, context);
|
|
733
804
|
displayPreview = preview ?? void 0;
|
|
734
805
|
this.logger.debug(`Generated preview for ${toolName}`);
|
|
@@ -768,11 +839,13 @@ let _ToolManager = class _ToolManager {
|
|
|
768
839
|
this.logger.info(
|
|
769
840
|
`Tool '${toolName}' added to allowed tools for session '${allowSessionId ?? "global"}' (remember choice selected)`
|
|
770
841
|
);
|
|
842
|
+
this.autoApprovePendingToolRequests(toolName, allowSessionId);
|
|
771
843
|
} else if (rememberPattern && typeof rememberPattern === "string" && this.isBashTool(toolName)) {
|
|
772
844
|
this.approvalManager.addBashPattern(rememberPattern);
|
|
773
845
|
this.logger.info(
|
|
774
846
|
`Bash pattern '${rememberPattern}' added for session approval`
|
|
775
847
|
);
|
|
848
|
+
this.autoApprovePendingBashRequests(rememberPattern, sessionId);
|
|
776
849
|
}
|
|
777
850
|
}
|
|
778
851
|
const approved = response.status === import_types3.ApprovalStatus.APPROVED;
|
|
@@ -93,6 +93,24 @@ export declare class ToolManager {
|
|
|
93
93
|
* Returns approval info if covered, or pattern suggestions if not.
|
|
94
94
|
*/
|
|
95
95
|
private checkBashPatternApproval;
|
|
96
|
+
/**
|
|
97
|
+
* Auto-approve pending tool confirmation requests for the same tool.
|
|
98
|
+
* Called after a user selects "remember choice" for a tool.
|
|
99
|
+
* This handles the case where parallel tool calls come in before the first one is approved.
|
|
100
|
+
*
|
|
101
|
+
* @param toolName The tool name that was just remembered
|
|
102
|
+
* @param sessionId The session ID for which the tool was allowed
|
|
103
|
+
*/
|
|
104
|
+
private autoApprovePendingToolRequests;
|
|
105
|
+
/**
|
|
106
|
+
* Auto-approve pending bash command requests that match a pattern.
|
|
107
|
+
* Called after a user selects "remember pattern" for a bash command.
|
|
108
|
+
* This handles the case where parallel bash commands come in before the first one is approved.
|
|
109
|
+
*
|
|
110
|
+
* @param pattern The bash pattern that was just remembered
|
|
111
|
+
* @param sessionId The session ID for context
|
|
112
|
+
*/
|
|
113
|
+
private autoApprovePendingBashRequests;
|
|
96
114
|
getMcpManager(): MCPManager;
|
|
97
115
|
/**
|
|
98
116
|
* Get all MCP tools (delegates to mcpManager.getAllTools())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-manager.d.ts","sourceRoot":"","sources":["../../src/tools/tool-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,OAAO,EAAwB,MAAM,YAAY,CAAC;AAK3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAA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W,IAAI,OAAO,CAAC,OAAO,CAAC;IAUrC;;;;;;;;;OASG;IACG,WAAW,CACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,WAAW,GAC1B,OAAO,CAAC,OAAO,YAAY,EAAE,mBAAmB,CAAC;IAwMpD;;OAEG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAuBjD;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC;QAC1B,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAClB,CAAC;IA4CF;;;;OAIG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS;IAsB1E;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,iBAAiB;IA0BzB;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;;;;;;;;OASG;YACW,2BAA2B;IAwEzC;;;;;;;;;OASG;YACW,kBAAkB;IAuNhC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9B;;OAEG;IACH,uBAAuB,IAAI,MAAM,EAAE;IAInC;;OAEG;IACH,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAI5C;;OAEG;IACH,sBAAsB,IAAI,IAAI;CAGjC"}
|
|
@@ -9,7 +9,7 @@ import { ToolError } from "./errors.js";
|
|
|
9
9
|
import { ToolErrorCode } from "./error-codes.js";
|
|
10
10
|
import { DextoRuntimeError } from "../errors/index.js";
|
|
11
11
|
import { DextoLogComponent } from "../logger/v2/types.js";
|
|
12
|
-
import { ApprovalStatus } from "../approval/types.js";
|
|
12
|
+
import { ApprovalStatus, ApprovalType } from "../approval/types.js";
|
|
13
13
|
import { InstrumentClass } from "../telemetry/decorators.js";
|
|
14
14
|
import {
|
|
15
15
|
generateBashPatternKey,
|
|
@@ -153,6 +153,75 @@ let _ToolManager = class _ToolManager {
|
|
|
153
153
|
suggestedPatterns: generateBashPatternSuggestions(command)
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Auto-approve pending tool confirmation requests for the same tool.
|
|
158
|
+
* Called after a user selects "remember choice" for a tool.
|
|
159
|
+
* This handles the case where parallel tool calls come in before the first one is approved.
|
|
160
|
+
*
|
|
161
|
+
* @param toolName The tool name that was just remembered
|
|
162
|
+
* @param sessionId The session ID for which the tool was allowed
|
|
163
|
+
*/
|
|
164
|
+
autoApprovePendingToolRequests(toolName, sessionId) {
|
|
165
|
+
const count = this.approvalManager.autoApprovePendingRequests(
|
|
166
|
+
(request) => {
|
|
167
|
+
if (request.type !== ApprovalType.TOOL_CONFIRMATION) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (request.sessionId !== sessionId) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
const metadata = request.metadata;
|
|
174
|
+
return metadata.toolName === toolName;
|
|
175
|
+
},
|
|
176
|
+
{ rememberChoice: false }
|
|
177
|
+
// Don't propagate remember choice to auto-approved requests
|
|
178
|
+
);
|
|
179
|
+
if (count > 0) {
|
|
180
|
+
this.logger.info(
|
|
181
|
+
`Auto-approved ${count} parallel request(s) for tool '${toolName}' after user selected "remember choice"`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Auto-approve pending bash command requests that match a pattern.
|
|
187
|
+
* Called after a user selects "remember pattern" for a bash command.
|
|
188
|
+
* This handles the case where parallel bash commands come in before the first one is approved.
|
|
189
|
+
*
|
|
190
|
+
* @param pattern The bash pattern that was just remembered
|
|
191
|
+
* @param sessionId The session ID for context
|
|
192
|
+
*/
|
|
193
|
+
autoApprovePendingBashRequests(pattern, sessionId) {
|
|
194
|
+
const count = this.approvalManager.autoApprovePendingRequests(
|
|
195
|
+
(request) => {
|
|
196
|
+
if (request.type !== ApprovalType.TOOL_CONFIRMATION) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
if (request.sessionId !== sessionId) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
const metadata = request.metadata;
|
|
203
|
+
if (!this.isBashTool(metadata.toolName)) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
const command = metadata.args?.command;
|
|
207
|
+
if (!command) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
const patternKey = generateBashPatternKey(command);
|
|
211
|
+
if (!patternKey) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
return this.approvalManager.matchesBashPattern(patternKey);
|
|
215
|
+
},
|
|
216
|
+
{ rememberPattern: void 0 }
|
|
217
|
+
// Don't propagate pattern to auto-approved requests
|
|
218
|
+
);
|
|
219
|
+
if (count > 0) {
|
|
220
|
+
this.logger.info(
|
|
221
|
+
`Auto-approved ${count} parallel bash command(s) matching pattern '${pattern}'`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
156
225
|
getMcpManager() {
|
|
157
226
|
return this.mcpManager;
|
|
158
227
|
}
|
|
@@ -334,7 +403,8 @@ let _ToolManager = class _ToolManager {
|
|
|
334
403
|
actualToolName,
|
|
335
404
|
args,
|
|
336
405
|
sessionId,
|
|
337
|
-
abortSignal
|
|
406
|
+
abortSignal,
|
|
407
|
+
toolCallId
|
|
338
408
|
);
|
|
339
409
|
} else if (toolName.startsWith(_ToolManager.CUSTOM_TOOL_PREFIX)) {
|
|
340
410
|
this.logger.debug(`\u{1F527} Detected custom tool: '${toolName}'`);
|
|
@@ -350,7 +420,8 @@ let _ToolManager = class _ToolManager {
|
|
|
350
420
|
actualToolName,
|
|
351
421
|
args,
|
|
352
422
|
sessionId,
|
|
353
|
-
abortSignal
|
|
423
|
+
abortSignal,
|
|
424
|
+
toolCallId
|
|
354
425
|
);
|
|
355
426
|
} else {
|
|
356
427
|
this.logger.debug(`\u{1F527} Detected tool without proper prefix: '${toolName}'`);
|
|
@@ -568,7 +639,7 @@ let _ToolManager = class _ToolManager {
|
|
|
568
639
|
if (!tool?.getApprovalOverride) {
|
|
569
640
|
return { handled: false };
|
|
570
641
|
}
|
|
571
|
-
const approvalRequest = tool.getApprovalOverride(args);
|
|
642
|
+
const approvalRequest = await tool.getApprovalOverride(args);
|
|
572
643
|
if (!approvalRequest) {
|
|
573
644
|
return { handled: false };
|
|
574
645
|
}
|
|
@@ -669,7 +740,7 @@ let _ToolManager = class _ToolManager {
|
|
|
669
740
|
const internalTool = this.internalToolsProvider?.getTool(actualToolName);
|
|
670
741
|
if (internalTool?.generatePreview) {
|
|
671
742
|
try {
|
|
672
|
-
const context = { sessionId };
|
|
743
|
+
const context = { sessionId, toolCallId };
|
|
673
744
|
const preview = await internalTool.generatePreview(args, context);
|
|
674
745
|
displayPreview = preview ?? void 0;
|
|
675
746
|
this.logger.debug(`Generated preview for ${toolName}`);
|
|
@@ -709,11 +780,13 @@ let _ToolManager = class _ToolManager {
|
|
|
709
780
|
this.logger.info(
|
|
710
781
|
`Tool '${toolName}' added to allowed tools for session '${allowSessionId ?? "global"}' (remember choice selected)`
|
|
711
782
|
);
|
|
783
|
+
this.autoApprovePendingToolRequests(toolName, allowSessionId);
|
|
712
784
|
} else if (rememberPattern && typeof rememberPattern === "string" && this.isBashTool(toolName)) {
|
|
713
785
|
this.approvalManager.addBashPattern(rememberPattern);
|
|
714
786
|
this.logger.info(
|
|
715
787
|
`Bash pattern '${rememberPattern}' added for session approval`
|
|
716
788
|
);
|
|
789
|
+
this.autoApprovePendingBashRequests(rememberPattern, sessionId);
|
|
717
790
|
}
|
|
718
791
|
}
|
|
719
792
|
const approved = response.status === ApprovalStatus.APPROVED;
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface ToolExecutionContext {
|
|
|
10
10
|
sessionId?: string | undefined;
|
|
11
11
|
/** Abort signal for cancellation support */
|
|
12
12
|
abortSignal?: AbortSignal | undefined;
|
|
13
|
+
/** Unique tool call ID for tracking parallel tool calls */
|
|
14
|
+
toolCallId?: string | undefined;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* Result of tool execution, including approval metadata
|
|
@@ -52,9 +54,9 @@ export interface InternalTool {
|
|
|
52
54
|
* @example
|
|
53
55
|
* ```typescript
|
|
54
56
|
* // File tool requesting directory access approval for external paths
|
|
55
|
-
* getApprovalOverride: (args) => {
|
|
57
|
+
* getApprovalOverride: async (args) => {
|
|
56
58
|
* const filePath = (args as {file_path: string}).file_path;
|
|
57
|
-
* if (!isPathWithinAllowed(filePath)) {
|
|
59
|
+
* if (!await isPathWithinAllowed(filePath)) {
|
|
58
60
|
* return {
|
|
59
61
|
* type: ApprovalType.DIRECTORY_ACCESS,
|
|
60
62
|
* metadata: { path: filePath, operation: 'read', ... }
|
|
@@ -64,7 +66,7 @@ export interface InternalTool {
|
|
|
64
66
|
* }
|
|
65
67
|
* ```
|
|
66
68
|
*/
|
|
67
|
-
getApprovalOverride?: (args: unknown) => ApprovalRequestDetails | null;
|
|
69
|
+
getApprovalOverride?: (args: unknown) => Promise<ApprovalRequestDetails | null> | ApprovalRequestDetails | null;
|
|
68
70
|
/**
|
|
69
71
|
* Optional callback invoked when custom approval is granted.
|
|
70
72
|
* Allows tools to handle approval responses (e.g., remember approved directories).
|
|
@@ -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,SAAS,EAAE,MAAM,KAAK,CA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