@mayijuntuan/cnb-chat 1.2.0 → 1.2.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/lib/theme-agent.mjs +16 -0
- package/package.json +1 -1
package/lib/theme-agent.mjs
CHANGED
|
@@ -60,12 +60,28 @@ const runOnce = async (messages, query, cliPath) => {
|
|
|
60
60
|
|
|
61
61
|
const full = [];
|
|
62
62
|
|
|
63
|
+
// Bash 等命令执行工具的权限回调(acceptEdits 只覆盖文件编辑,Bash 需显式授权)
|
|
64
|
+
// 容器为一次性沙箱(工作区=仓库),命令级放行 + 危险命令拦截
|
|
65
|
+
const canUseTool = async (toolName, input) => {
|
|
66
|
+
if (toolName === 'Bash') {
|
|
67
|
+
const cmd = String(input?.command || '');
|
|
68
|
+
const dangerous = ['rm -rf /', 'sudo ', 'chmod 777', 'mkfs', 'dd if=', ':(){'];
|
|
69
|
+
for (const d of dangerous) {
|
|
70
|
+
if (cmd.includes(d)) {
|
|
71
|
+
return { behavior: 'deny', message: '危险命令被拦截: ' + d };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return { behavior: 'allow', updatedInput: input };
|
|
76
|
+
};
|
|
77
|
+
|
|
63
78
|
try {
|
|
64
79
|
const q = query({
|
|
65
80
|
prompt,
|
|
66
81
|
options: {
|
|
67
82
|
cwd: process.cwd(),
|
|
68
83
|
permissionMode: 'acceptEdits',
|
|
84
|
+
canUseTool,
|
|
69
85
|
allowedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'],
|
|
70
86
|
...(MODEL ? { model: MODEL } : {}),
|
|
71
87
|
...(cliPath ? { pathToCodebuddyCode: cliPath } : {}),
|