@myassis/gateway 1.0.36 → 1.0.37
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/services/tools/exec.js +23 -12
- package/package.json +1 -1
|
@@ -140,28 +140,39 @@ exports.execTool = {
|
|
|
140
140
|
type: 'number',
|
|
141
141
|
description: '命令超时时间(毫秒),默认 60000',
|
|
142
142
|
default: 60000,
|
|
143
|
+
},
|
|
144
|
+
isUserAsk: {
|
|
145
|
+
type: 'boolean',
|
|
146
|
+
description: '是否为用户主动要求的命令(用于绕过危险命令拦截)。如果用户明确要求执行此命令(如"帮我执行shutdown"),设置为true。',
|
|
147
|
+
default: false,
|
|
143
148
|
}
|
|
144
149
|
},
|
|
145
150
|
required: ['command'],
|
|
146
151
|
},
|
|
147
152
|
handler: async (args, sessionId) => {
|
|
148
153
|
return new Promise(async (resolve) => {
|
|
149
|
-
const { cwd, timeout = 60000, approved } = args;
|
|
154
|
+
const { cwd, timeout = 60000, approved, isUserAsk = false } = args;
|
|
150
155
|
let command = args.command;
|
|
151
|
-
//
|
|
156
|
+
// 检查危险命令(如果已批准或用户主动要求则跳过拦截)
|
|
152
157
|
if (!approved && isDangerousCommand(command)) {
|
|
153
|
-
if (
|
|
154
|
-
|
|
158
|
+
if (isUserAsk) {
|
|
159
|
+
// 用户主动要求,跳过拦截
|
|
160
|
+
logger.info(`用户主动要求执行危险命令,跳过拦截: ${command}`);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
if (!sessionId) {
|
|
164
|
+
resolve({ success: false, errorMessage: '危险命令需要用户确认,但缺少会话ID' });
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const token = addPendingApproval(command, cwd, timeout, sessionId);
|
|
168
|
+
resolve({
|
|
169
|
+
success: false,
|
|
170
|
+
needsApproval: true,
|
|
171
|
+
approvalToken: token,
|
|
172
|
+
errorMessage: `危险命令需要用户确认:${command}`,
|
|
173
|
+
});
|
|
155
174
|
return;
|
|
156
175
|
}
|
|
157
|
-
const token = addPendingApproval(command, cwd, timeout, sessionId);
|
|
158
|
-
resolve({
|
|
159
|
-
success: false,
|
|
160
|
-
needsApproval: true,
|
|
161
|
-
approvalToken: token,
|
|
162
|
-
errorMessage: `危险命令需要用户确认:${command}`,
|
|
163
|
-
});
|
|
164
|
-
return;
|
|
165
176
|
}
|
|
166
177
|
const options = {
|
|
167
178
|
cwd,
|