wezard 2.8.6 → 2.8.8
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/CLAUDE.md +1 -1
- package/README.md +2 -0
- package/cli/wezard.sh +7 -0
- package/dist/cli/codex-hook.js +6 -1
- package/dist/cli/codex-hook.js.map +1 -1
- package/dist/cli/sync.js +37 -7
- package/dist/cli/sync.js.map +1 -1
- package/dist/daemon/approval.js +97 -79
- package/dist/daemon/approval.js.map +1 -1
- package/dist/daemon/danger.js +219 -11
- package/dist/daemon/danger.js.map +1 -1
- package/dist/daemon/http.js +5 -1
- package/dist/daemon/http.js.map +1 -1
- package/dist/daemon/inbound.js +33 -0
- package/dist/daemon/inbound.js.map +1 -1
- package/dist/daemon/index.js +27 -15
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/mcp-http.js +77 -0
- package/dist/daemon/mcp-http.js.map +1 -0
- package/dist/daemon/message-events.js +3 -1
- package/dist/daemon/message-events.js.map +1 -1
- package/dist/daemon/mirror-bridge.js +53 -19
- package/dist/daemon/mirror-bridge.js.map +1 -1
- package/dist/daemon/peers.js +9 -8
- package/dist/daemon/peers.js.map +1 -1
- package/dist/daemon/pending.js.map +1 -1
- package/dist/daemon/picker-policy.js +16 -6
- package/dist/daemon/picker-policy.js.map +1 -1
- package/dist/daemon/router.js +15 -6
- package/dist/daemon/router.js.map +1 -1
- package/dist/daemon/session-cache.js.map +1 -1
- package/dist/daemon/spawn-tmux.js +5 -1
- package/dist/daemon/spawn-tmux.js.map +1 -1
- package/dist/daemon/steward-guard.js +2 -13
- package/dist/daemon/steward-guard.js.map +1 -1
- package/dist/daemon/wizard-names.js +64 -37
- package/dist/daemon/wizard-names.js.map +1 -1
- package/dist/daemon/wizard.js +13 -4
- package/dist/daemon/wizard.js.map +1 -1
- package/dist/mcp/server.js +5 -667
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.js +688 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/shared/allow-rules.js +171 -25
- package/dist/shared/allow-rules.js.map +1 -1
- package/dist/shared/chat-view.js +1 -1
- package/dist/shared/chat-view.js.map +1 -1
- package/dist/shared/config.js +16 -2
- package/dist/shared/config.js.map +1 -1
- package/dist/shared/detail-render.js +101 -11
- package/dist/shared/detail-render.js.map +1 -1
- package/dist/shared/hook-mode.js +31 -0
- package/dist/shared/hook-mode.js.map +1 -0
- package/dist/shared/modal-pane.js +79 -9
- package/dist/shared/modal-pane.js.map +1 -1
- package/dist/shared/plan.js +4 -0
- package/dist/shared/plan.js.map +1 -1
- package/dist/shared/repl-script.js +118 -0
- package/dist/shared/repl-script.js.map +1 -0
- package/dist/shared/tool-hints.js +28 -4
- package/dist/shared/tool-hints.js.map +1 -1
- package/dist/shared/turn-state.js +1 -1
- package/dist/shared/turn-state.js.map +1 -1
- package/dist/shared/world.js +3 -2
- package/dist/shared/world.js.map +1 -1
- package/hooks/pre-tool-use.sh +48 -5
- package/package.json +1 -1
- package/web/chat.css +88 -20
- package/web/chat.js +136 -18
|
@@ -46,6 +46,7 @@ import { getDetail, knowsToolUse, recordTool, recordToolResult, recordMark, reco
|
|
|
46
46
|
import { errText } from "./last-response.js";
|
|
47
47
|
import { labelFor, tagOfKey, baseOfKey, stripSigil, displayName, windowLabel, withTagHeader, withLinkedTagHeader, chatHead, headed, tagBadge, parseTagHeader, MAX_BODY_LINKS, isInternalKey, sameBot } from "../shared/session-label.js";
|
|
48
48
|
import { splitMarkdown } from "../shared/md-chunk.js";
|
|
49
|
+
import { readHookMode } from "../shared/hook-mode.js";
|
|
49
50
|
import { isWxFrame } from "../shared/wx-text.js";
|
|
50
51
|
import { chatNameOf, listChatNames, peerAddress } from "./chat-name.js";
|
|
51
52
|
import { stripAnsi, paneIsBusy, codexTurnBusy, summarizeTail, lastAssistantText, lastReply, replyToPeer as replyToPeerIn, unwrapPasted, lastContextTokens, lastModel, lastUserTurn, talkRounds, openToolUses, turnClosed, renderDialog, stripForChat, parseClosing } from "./peers.js";
|
|
@@ -1159,14 +1160,18 @@ const MODAL_PRESS_SETTLE_MS = 400;
|
|
|
1159
1160
|
const MODAL_ARROW_SETTLE_MS = 150;
|
|
1160
1161
|
const highlightedIndex = (screen) => parseModalOptions(screen).find((o) => o.selected)?.index;
|
|
1161
1162
|
const pressModalIndex = async (pane, before, index, live = () => true) => {
|
|
1162
|
-
|
|
1163
|
+
// 比的是「还是同一只框里的同一个调用」, 不是整屏原文: 屏上的进度行/计时/spinner
|
|
1164
|
+
// 每拍都在变, 拿原文比会让每一次多拍等待都判成「换了框」而停手 —— 按数字键本来
|
|
1165
|
+
// 就是在这同一只框里选的 (身份认不出时才退回整屏, 保持原来的保守口径)。
|
|
1166
|
+
const identityOf = (screen) => modalCallFingerprint(screen) ?? modalFingerprint(screen);
|
|
1167
|
+
const fingerprint = identityOf(before.screen);
|
|
1163
1168
|
const current = await detectModalPicker(pane);
|
|
1164
|
-
if (!live() || !current.modal ||
|
|
1169
|
+
if (!live() || !current.modal || identityOf(current.screen) !== fingerprint)
|
|
1165
1170
|
return current;
|
|
1166
1171
|
await runTmux(["send-keys", "-t", pane, String(index)]);
|
|
1167
1172
|
await sleep(MODAL_PRESS_SETTLE_MS);
|
|
1168
1173
|
let after = await detectModalPicker(pane);
|
|
1169
|
-
if (!after.modal ||
|
|
1174
|
+
if (!after.modal || identityOf(after.screen) !== fingerprint)
|
|
1170
1175
|
return after;
|
|
1171
1176
|
// 数字键没关掉框: 把高亮挪到目标项。guard 上限盖过任何确认框的选项数。
|
|
1172
1177
|
for (let guard = 0; guard < 8; guard++) {
|
|
@@ -1178,7 +1183,7 @@ const pressModalIndex = async (pane, before, index, live = () => true) => {
|
|
|
1178
1183
|
await runTmux(["send-keys", "-t", pane, cur < index ? "Down" : "Up"]);
|
|
1179
1184
|
await sleep(MODAL_ARROW_SETTLE_MS);
|
|
1180
1185
|
after = await detectModalPicker(pane);
|
|
1181
|
-
if (!after.modal ||
|
|
1186
|
+
if (!after.modal || identityOf(after.screen) !== fingerprint)
|
|
1182
1187
|
return after;
|
|
1183
1188
|
}
|
|
1184
1189
|
if (!live() || highlightedIndex(after.screen) !== index)
|
|
@@ -6375,7 +6380,9 @@ export const startMirror = (deps) => {
|
|
|
6375
6380
|
// 对应选项; 本地先按掉则 moot 作废卡。代按/发卡都发 chat 回执留痕。
|
|
6376
6381
|
// WEZARD_PICKER_SENTINEL=0 整体关闭。
|
|
6377
6382
|
const pickerOne = async (a, pane, sid, gen, signal) => {
|
|
6378
|
-
|
|
6383
|
+
// `wezard use cli` 同一票否决: 本地原生框是给人的, daemon 代按就等于审批没回退。
|
|
6384
|
+
const guard = () => maintenanceValid(a, pane, sid, gen, signal)
|
|
6385
|
+
&& (cliOf(a) === "codex" || (cfg.approval.enabled && readHookMode(cfg.daemon.stateDir) === "wecom"))
|
|
6379
6386
|
&& process.env.WEZARD_PICKER_SENTINEL !== "0";
|
|
6380
6387
|
if (!guard())
|
|
6381
6388
|
return;
|
|
@@ -6412,9 +6419,15 @@ export const startMirror = (deps) => {
|
|
|
6412
6419
|
}
|
|
6413
6420
|
if (hasMirrorPicker(a.sessionId))
|
|
6414
6421
|
return; // 审批卡在途, 等点击 / moot
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6422
|
+
// 去重按「同一只框里的同一个调用」, 不按整屏原文: 框外的进度行每拍都在变,
|
|
6423
|
+
// 拿原文比等于每拍都是新屏 —— 张注定失败或已回执的卡就会被无限重发。
|
|
6424
|
+
const call = modalCallFingerprint(v.screen);
|
|
6425
|
+
// 认不出调用的框 (只剩问句与选项) 用一个固定键去重: 它本来就没有可比对的内容,
|
|
6426
|
+
// 每拍重来只会重复同一条日志 / 同一条告知。
|
|
6427
|
+
const seen = call ?? "unknown-modal";
|
|
6428
|
+
if (a.pickerSentinelFp === seen)
|
|
6429
|
+
return;
|
|
6430
|
+
a.pickerSentinelFp = seen;
|
|
6418
6431
|
const pick = pickAutoAllowAnswer(parseModalOptions(v.screen));
|
|
6419
6432
|
if (!pick) {
|
|
6420
6433
|
// tail 与上面「未判成 modal」分支同款: 远端 (devcloud) 选项文案变体排查靠它,
|
|
@@ -6431,11 +6444,13 @@ export const startMirror = (deps) => {
|
|
|
6431
6444
|
deny: async () => {
|
|
6432
6445
|
if (!valid())
|
|
6433
6446
|
return;
|
|
6434
|
-
const result = await pressNativePickerUnlocked(a,
|
|
6447
|
+
const result = await pressNativePickerUnlocked(a, call, "no", valid);
|
|
6448
|
+
if (result.ok && valid())
|
|
6449
|
+
a.pickerSentinelFp = undefined; // 已按掉: 同一调用再次弹出要重新发卡
|
|
6435
6450
|
if (!valid())
|
|
6436
6451
|
return;
|
|
6437
6452
|
log.info({ target: a.target, reason: policy.reason, result }, "picker sentinel: deny rule");
|
|
6438
|
-
sendStandalone(a, `[mirror] 🚫 ${policy.reason},${result.ok ? "已拒绝 CLI 确认" : "
|
|
6453
|
+
sendStandalone(a, `[mirror] 🚫 ${policy.reason},${result.ok ? "已拒绝 CLI 确认" : `代按失败(${result.reason ?? "未知"}),请回 CLI 处理`}`);
|
|
6439
6454
|
},
|
|
6440
6455
|
allow: async () => {
|
|
6441
6456
|
if (!valid())
|
|
@@ -6444,8 +6459,9 @@ export const startMirror = (deps) => {
|
|
|
6444
6459
|
if (!valid())
|
|
6445
6460
|
return;
|
|
6446
6461
|
if (after.modal) {
|
|
6447
|
-
// 没按掉:
|
|
6448
|
-
|
|
6462
|
+
// 没按掉: 去重键换成「按完那只框」的调用身份 — pane 静止就不再重试, 免得往一个
|
|
6463
|
+
// 不认识的框里刷数字键; 内容真的变了则按下一次的身份重新判一遍策略。
|
|
6464
|
+
a.pickerSentinelFp = modalCallFingerprint(after.screen) ?? after.screen;
|
|
6449
6465
|
log.warn({ target: a.target, title: after.title, pressed: pick.index }, "picker sentinel: modal still on pane after press");
|
|
6450
6466
|
return;
|
|
6451
6467
|
}
|
|
@@ -6456,6 +6472,13 @@ export const startMirror = (deps) => {
|
|
|
6456
6472
|
manual: () => {
|
|
6457
6473
|
if (!valid())
|
|
6458
6474
|
return;
|
|
6475
|
+
if (call === undefined) {
|
|
6476
|
+
// 正文里没有任何随调用变化的行 → 人点了也无从核对是不是同一只框。发卡只会
|
|
6477
|
+
// 让他反复点到一个注定失败的回执, 所以只告知一次 (去重键在 pickerSentinelFp)。
|
|
6478
|
+
log.info({ target: a.target, title: v.title }, "picker sentinel: modal without call identity — not carded");
|
|
6479
|
+
sendStandalone(a, `[mirror] 🔒 屏上的确认框认不出调用内容${v.title ? `(${v.title})` : ""},请在 CLI 中确认。`);
|
|
6480
|
+
return;
|
|
6481
|
+
}
|
|
6459
6482
|
// 卡片路径: fire-and-forget — 长轮询在 flow 里, 哨兵循环不能被一张卡挂住;
|
|
6460
6483
|
// 防重靠 hasMirrorPicker 槽位 (含代按窗口期, 见 flow 内 finally)。
|
|
6461
6484
|
log.info({ target: a.target, toolName: ctx.toolName, agent: ctx.agent, reason: policy.reason }, "picker sentinel: forwarding native picker as approval card");
|
|
@@ -6470,10 +6493,19 @@ export const startMirror = (deps) => {
|
|
|
6470
6493
|
toolName: ctx.toolName,
|
|
6471
6494
|
toolInput: ctx.toolInput,
|
|
6472
6495
|
agent: ctx.agent,
|
|
6473
|
-
danger: policy.
|
|
6496
|
+
danger: policy.danger,
|
|
6497
|
+
singleNote: policy.note,
|
|
6474
6498
|
voteTimeoutMs: cfg.approval.longPollSec * 1000,
|
|
6475
6499
|
// Human waiting is outside the lock; the eventual press obtains a new transaction.
|
|
6476
|
-
|
|
6500
|
+
// 按掉的这一只框已经了结: 同一份调用下次再弹出 (比如命令重试) 必须重新发卡,
|
|
6501
|
+
// 不能让「这张调用已经发过」的去重键把它静默掉。代按失败则保留去重键 ——
|
|
6502
|
+
// 失败说明人已经被告知回 CLI 处理, 重发一张同样的卡只会让他再点一次。
|
|
6503
|
+
press: async (what) => {
|
|
6504
|
+
const res = await pressNativePicker(a, call, what, guard);
|
|
6505
|
+
if (res.ok && guard())
|
|
6506
|
+
a.pickerSentinelFp = undefined;
|
|
6507
|
+
return res;
|
|
6508
|
+
},
|
|
6477
6509
|
}).then((sent) => {
|
|
6478
6510
|
// 卡没发出去 (WS 断/发送失败): 清指纹, 让下一 tick 对同屏重试发卡,
|
|
6479
6511
|
// 否则这只框会被指纹永久静默。
|
|
@@ -6492,7 +6524,7 @@ export const startMirror = (deps) => {
|
|
|
6492
6524
|
if (process.env.WEZARD_PICKER_SENTINEL === "0")
|
|
6493
6525
|
return;
|
|
6494
6526
|
for (const a of byTarget.values()) {
|
|
6495
|
-
if (!a.tmuxPane || (cliOf(a) !== "codex" && !cfg.approval.enabled))
|
|
6527
|
+
if (!a.tmuxPane || (cliOf(a) !== "codex" && (!cfg.approval.enabled || readHookMode(cfg.daemon.stateDir) === "cli")))
|
|
6496
6528
|
continue;
|
|
6497
6529
|
const pane = a.tmuxPane, sid = a.sessionId, gen = a.injectGen ?? 0;
|
|
6498
6530
|
void maintenance.schedule(`picker:${a.target}`, pane, (signal) => pickerOne(a, pane, sid, gen, signal))
|
|
@@ -6521,11 +6553,13 @@ export const startMirror = (deps) => {
|
|
|
6521
6553
|
if (pickerPolicy(cfg, cliOf(a), parseConfirmContext(v.screen), false).decision === "leave") {
|
|
6522
6554
|
return { ok: false, reason: "独立原生或交互审批,请在 CLI 中处理" };
|
|
6523
6555
|
}
|
|
6524
|
-
// 按调用比对: 认不出就不按 (undefined 也不等),
|
|
6556
|
+
// 按调用比对: 认不出就不按 (undefined 也不等), 换框绝不盲按。两种失败要分开说 ——
|
|
6557
|
+
// 「认不出」是我们自己核对不了, 「已变更」是屏上的调用真的换了, 给人的处置不同。
|
|
6525
6558
|
const call = modalCallFingerprint(v.screen);
|
|
6526
|
-
if (call === undefined
|
|
6527
|
-
return { ok: false, reason: "
|
|
6528
|
-
|
|
6559
|
+
if (call === undefined)
|
|
6560
|
+
return { ok: false, reason: "屏上的确认框认不出调用内容,无法核对还是不是同一件事" };
|
|
6561
|
+
if (call !== expectCall)
|
|
6562
|
+
return { ok: false, reason: "当前确认框的操作或参数与卡片上那份不同" };
|
|
6529
6563
|
if (what === "no") {
|
|
6530
6564
|
await runTmux(["send-keys", "-t", a.tmuxPane, "Escape"]);
|
|
6531
6565
|
await sleep(MODAL_PRESS_SETTLE_MS);
|