u1s1-cli 1.11.6 → 1.11.7
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-setup.js +18 -5
- package/package.json +1 -1
package/dist/agent-setup.js
CHANGED
|
@@ -438,10 +438,11 @@ export default async function (pi) {
|
|
|
438
438
|
});
|
|
439
439
|
|
|
440
440
|
// ---- 隐藏各内置工具 ----
|
|
441
|
-
const { createReadTool, createBashTool, createEditTool, createWriteTool, createGrepTool, createFindTool, createLsTool } = await import("@earendil-works/pi-coding-agent");
|
|
441
|
+
const { createReadTool, createBashTool, createEditTool, createWriteTool, createGrepTool, createFindTool, createLsTool, SettingsManager } = await import("@earendil-works/pi-coding-agent");
|
|
442
442
|
const { Text } = await import("@earendil-works/pi-tui");
|
|
443
443
|
|
|
444
|
-
|
|
444
|
+
// pick(ctx) 可按会话上下文换一个同 schema 的实际执行工具(bash 按 shellPath 选)
|
|
445
|
+
function hideTool(name, orig, pick = () => orig) {
|
|
445
446
|
pi.registerTool({
|
|
446
447
|
name,
|
|
447
448
|
label: name,
|
|
@@ -449,8 +450,8 @@ export default async function (pi) {
|
|
|
449
450
|
parameters: orig.parameters,
|
|
450
451
|
// 自己管外壳:不用默认的 Box 包装,空内容才不会产生空行
|
|
451
452
|
renderShell: "self",
|
|
452
|
-
async execute(toolCallId, params, signal, onUpdate) {
|
|
453
|
-
return
|
|
453
|
+
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
454
|
+
return pick(ctx).execute(toolCallId, params, signal, onUpdate);
|
|
454
455
|
},
|
|
455
456
|
renderCall() {
|
|
456
457
|
return new Text("", 0, 0);
|
|
@@ -474,7 +475,19 @@ export default async function (pi) {
|
|
|
474
475
|
// 模型跑的 shell 命令拿不到 U1S1_API_KEY / U1S1_EP_KEY_* 等密钥(进程级守卫之外的显式一层)
|
|
475
476
|
const { stripSecretEnv } = await import(${JSON.stringify(new URL("./secret-env.js", import.meta.url).href)});
|
|
476
477
|
hideTool("read", createReadTool(cwd));
|
|
477
|
-
|
|
478
|
+
// 覆盖内置 bash 后 pi 不再替我们传 shellPath:不传就走 pi 的兜底,Git 不在 Program Files 时
|
|
479
|
+
// 会命中 System32 的 WSL 转发器,全部命令失败。与内置同源读 settings.json 的 shellPath
|
|
480
|
+
// (Windows 上由 shell-doctor 验活写入);项目级设置要看信任,故首次执行时按 ctx 解析一次
|
|
481
|
+
const bashOptions = { spawnHook: (spawnContext) => ({ ...spawnContext, env: stripSecretEnv(spawnContext.env) }) };
|
|
482
|
+
let bash;
|
|
483
|
+
const bashFor = (ctx) => {
|
|
484
|
+
if (!bash) {
|
|
485
|
+
const shellPath = SettingsManager.create(ctx?.cwd ?? cwd, undefined, { projectTrusted: ctx?.isProjectTrusted() ?? false }).getShellPath();
|
|
486
|
+
bash = createBashTool(cwd, { ...bashOptions, shellPath });
|
|
487
|
+
}
|
|
488
|
+
return bash;
|
|
489
|
+
};
|
|
490
|
+
hideTool("bash", createBashTool(cwd, bashOptions), bashFor);
|
|
478
491
|
hideTool("edit", createEditTool(cwd));
|
|
479
492
|
hideTool("write", createWriteTool(cwd));
|
|
480
493
|
hideTool("grep", createGrepTool(cwd));
|