wezard 2.6.4 → 2.7.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/CLAUDE.md +6 -6
- package/README.md +1 -15
- package/dist/cli/codex-hook.js +5 -1
- package/dist/cli/codex-hook.js.map +1 -1
- package/dist/cli/sync.js +5 -4
- package/dist/cli/sync.js.map +1 -1
- package/dist/daemon/approval.js +12 -5
- package/dist/daemon/approval.js.map +1 -1
- package/dist/daemon/chat-log.js +5 -5
- package/dist/daemon/chat-log.js.map +1 -1
- package/dist/daemon/chat-name.js +5 -2
- package/dist/daemon/chat-name.js.map +1 -1
- package/dist/daemon/detail.js +28 -5
- package/dist/daemon/detail.js.map +1 -1
- package/dist/daemon/direction.js +3 -2
- package/dist/daemon/direction.js.map +1 -1
- package/dist/daemon/dispatch.js +6 -0
- package/dist/daemon/dispatch.js.map +1 -0
- package/dist/daemon/handoff.js +66 -15
- package/dist/daemon/handoff.js.map +1 -1
- package/dist/daemon/inbound.js +3 -5
- package/dist/daemon/inbound.js.map +1 -1
- package/dist/daemon/index.js +1072 -714
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/jobs.js +7 -2
- package/dist/daemon/jobs.js.map +1 -1
- package/dist/daemon/last-response.js +8 -3
- package/dist/daemon/last-response.js.map +1 -1
- package/dist/daemon/message-events.js +232 -59
- package/dist/daemon/message-events.js.map +1 -1
- package/dist/daemon/mirror-bridge.js +556 -770
- package/dist/daemon/mirror-bridge.js.map +1 -1
- package/dist/daemon/mirror-store.js.map +1 -1
- package/dist/daemon/notices.js +9 -2
- package/dist/daemon/notices.js.map +1 -1
- package/dist/daemon/peers.js +122 -143
- package/dist/daemon/peers.js.map +1 -1
- package/dist/daemon/pending-items.js +33 -34
- package/dist/daemon/pending-items.js.map +1 -1
- package/dist/daemon/route.js +5 -2
- package/dist/daemon/route.js.map +1 -1
- package/dist/daemon/router.js +643 -0
- package/dist/daemon/router.js.map +1 -0
- package/dist/daemon/session-name.js +1 -1
- package/dist/daemon/session-name.js.map +1 -1
- package/dist/daemon/spawn-tmux.js +32 -13
- package/dist/daemon/spawn-tmux.js.map +1 -1
- package/dist/daemon/subagent-tail.js +3 -3
- package/dist/daemon/subagent-tail.js.map +1 -1
- package/dist/daemon/{cc-session.js → wezard-session.js} +32 -2
- package/dist/daemon/wezard-session.js.map +1 -0
- package/dist/daemon/wizard.js +5 -5
- package/dist/daemon/wizard.js.map +1 -1
- package/dist/daemon/workflow-nodes.js +3 -3
- package/dist/daemon/workflow-nodes.js.map +1 -1
- package/dist/daemon/workflow-plans.js +9 -6
- package/dist/daemon/workflow-plans.js.map +1 -1
- package/dist/mcp/server.js +38 -47
- package/dist/mcp/server.js.map +1 -1
- package/dist/shared/chat-http.js +2 -2
- package/dist/shared/chat-http.js.map +1 -1
- package/dist/shared/chat-view.js +0 -4
- package/dist/shared/chat-view.js.map +1 -1
- package/dist/shared/cli-backends.js +11 -1
- package/dist/shared/cli-backends.js.map +1 -1
- package/dist/shared/config.js +3 -44
- package/dist/shared/config.js.map +1 -1
- package/dist/shared/detail-render.js +36 -11
- package/dist/shared/detail-render.js.map +1 -1
- package/dist/shared/detail-store.js.map +1 -1
- package/dist/shared/message-footer.js +8 -8
- package/dist/shared/message-footer.js.map +1 -1
- package/dist/shared/reminder.js +104 -37
- package/dist/shared/reminder.js.map +1 -1
- package/dist/shared/role-render.js +28 -20
- package/dist/shared/role-render.js.map +1 -1
- package/dist/shared/role-search.js +3 -3
- package/dist/shared/role-search.js.map +1 -1
- package/dist/shared/role-view.js +50 -30
- package/dist/shared/role-view.js.map +1 -1
- package/dist/shared/session-label.js +25 -6
- package/dist/shared/session-label.js.map +1 -1
- package/dist/shared/turn-state.js +7 -7
- package/dist/shared/turn-state.js.map +1 -1
- package/dist/shared/world.js +1 -3
- package/dist/shared/world.js.map +1 -1
- package/hooks/pre-tool-use.sh +5 -25
- package/package.json +1 -1
- package/web/chat.css +3 -33
- package/web/chat.js +11 -62
- package/dist/daemon/answer-transfer.js +0 -56
- package/dist/daemon/answer-transfer.js.map +0 -1
- package/dist/daemon/cc-session.js.map +0 -1
- package/dist/daemon/receipts.js +0 -968
- package/dist/daemon/receipts.js.map +0 -1
- package/dist/shared/keepalive.js +0 -46
- package/dist/shared/keepalive.js.map +0 -1
package/CLAUDE.md
CHANGED
|
@@ -55,14 +55,14 @@ Three processes, all coordinating via 127.0.0.1:17890 and `~/.wezard/`:
|
|
|
55
55
|
- `inbound.ts` routes `message.text` / `message.image` / `message.mixed` → `mirror-bridge.ts`. Gates on `allowFrom`; one-shot exception is the bootstrap claim (see below).
|
|
56
56
|
- `mirror-bridge.ts` tails `<projectsDir>/<encoded(cwd)>/<sid>.jsonl` and pushes new `assistant` content to a chat — but only for turns the chat itself started: a turn opened by a human's CLI keystroke is recorded to the turn store (rolepage) and kept out of the chat (`wrc.mirror.chatOriginOnly`, brief mode only); approval/askq cards and `[mirror]` notices bypass that gate. Inbound injection is either `claude --resume <sid> -p` (writes a turn into the same jsonl) or `tmux paste-buffer` against a live TTY (only path that makes WeCom messages visible in the user's CLI window). `recentInjects` ring buffer suppresses the WeCom→CLI echo when tailing (which is why an injected line's text is stamped as the turn's `userQuery` at inject time — the tail never sees it). **Every turn has a channel** (`TurnDetailRecord.channel`): the base of the public chat it was spoken in and where its reply goes — a human can `.name` a wizard homed in another chat and the reply (text and cards) returns to the chat that asked, not the wizard's home; `""` = a private wizard↔wizard turn whose reply is pushed nowhere and lives only on the rolepage.
|
|
57
57
|
- `claim.ts` is a single-shot bootstrap: an exact-match magic phrase from any sender bypasses `allowFrom`, writes that principal as `defaultChat`, and appends to `allowFrom`. This is the **only** legitimate ingress for first-time setup.
|
|
58
|
-
- `peers.ts` is the read side of multi-agent awareness — "who else is working in this chat, and are they busy". A wizard's HOME chat is its target key's base principal (`baseOfKey`): the untagged default plus every slot `chat:xxx#slot`. Pure parsing only — bounded transcript-tail reads (`tailTurns` / `lastAssistantText` / `summarizeTail`, shared with `session-scan.ts`) and pane classification (`paneIsBusy`). **What a wizard reads about another comes from the transcript, never from a pane capture**: text turns only
|
|
58
|
+
- `peers.ts` is the read side of multi-agent awareness — "who else is working in this chat, and are they busy". A wizard's HOME chat is its target key's base principal (`baseOfKey`): the untagged default plus every slot `chat:xxx#slot`. Pure parsing only — bounded transcript-tail reads (`tailTurns` / `lastAssistantText` / `summarizeTail`, shared with `session-scan.ts`) and pane classification (`paneIsBusy`). **What a wizard reads about another comes from the transcript, never from a pane capture**: text turns only (`talkTurns`), and "where is it stuck" is `openToolUses` (a tool call left hanging on an idle session = parked on an approval card). The pane is consulted for exactly one thing, `busy`. Read-side tools (`wizard_roster` / `peek_peer` / `read_chat`) answer in plain text rendered daemon-side, not json; `read_chat` (`chat-log.ts`) is computed from session transcripts alone, not the turn store: a log = every recently-active session's ask + final answer per round, merged by timestamp, then narrowed on the rolepage's axis `role` → `chat` → `target` and cut by `since` / `until` / `limit`. Which channel a line belongs to and who said it is read back from the envelope riding on that user line (`parseEnvelope`, `shared/reminder.ts`): every wezard `<system-reminder>` carries its facts as opening-tag attributes (`wezard=envelope|hint|lead|after|mention|roster|pending`, `kind` / `from` / `chat` / `scope`, the injection event id as `msg`) and its prose only for the model; which attrs each kind may write is the `REMINDER_KINDS` registry (each attr is either read back by code or an id the model copies into `re`/`for`/`drop`), and `renderTail` lays one injection's tail out in a fixed order, envelope first — rewording the prose never breaks parsing; old attribute-less wordings keep parsing via its `LEGACY` table. The rolepage collapses each reminder into a tag named by its kind (`<envelope · .x>`, `<回执 · .x · need>`, `<roster>` …) that expands to raw on click; no envelope = a human speaking in the session's home chat. A clone's transcript starts with its parent's forked history, so its rounds older than `bornAt` are dropped. Identity (name / job / memory / lineage) lives in `wizard.ts`, not here. **Busy detection matches the TUI spinner footer** (`… (12m 31s · …)` on current versions, `esc to interrupt` on older ones) in the last 8 non-blank rows — transcript mtime is useless here, it goes quiet during long tool calls.
|
|
59
59
|
- `wizard.ts` is the identity layer over those sessions: a target key plus a **globally unique name** — the wizard's only address, written `.name` everywhere a human or model sees it (a chat's default session takes the chat's name, a slot takes its slot id; collisions get `-N` via `pickName`; `settleName` claims lazily, `settleAll` migrates at boot, default sessions first). The slot id inside the key is NOT the name: a rename never rekeys a session. Plus a one-line job description, a long-term `memory` list, and a `parent` link that makes a session a CLONE of another. The registry is a write-through json (`~/.wezard/wizards.json`, `wrc.mirror.wizardsFile`) bound process-wide via `bindWizardStore` so the IM side can read it too; everything else in the module is a pure renderer. **Identity travels as a system prompt, never as a message**: `renderCharter` builds the wizard's charter (who it is, its workspace, its clones, its memory, the chat's and the workspace's shared memory (`wizard-memory.ts`: `~/.wezard/memory/{chats,workspaces}/*.md`, human-editable, appended by `wizard_remember({scope})`), the tool roster, the orchestration playbook, the public-vs-private etiquette) and `spawn-tmux` presses it in with `--append-system-prompt "$(cat <file>)"` — so it survives `/clear`, costs no turn, and never shows in chat. Every spawn path (`/new`, a dead-pane respawn, a clone) pulls it from `MirrorBridge.setCharterProvider`, installed in `index.ts`. Since a running wizard never sees a new charter, `config_set` renders every chartered wizard's charter before and after the change and tells the affected ones (and the caller) to `handoff` — generic over whatever config the charter reads. Backends with no such flag spawn without a charter rather than with a rejected flag.
|
|
60
60
|
- **Cloning is a context fork**: `MirrorBridge.cloneSession` spawns `--resume <parent sid> --fork-session`, so the child starts holding everything the parent had read while the parent is untouched — that is what makes "load the shared material once, then fan out" work. Two invariants: `--fork-session` is mandatory (without it a second pane appends to the parent's jsonl and two chats cross-wire), and the forked transcript only appears when that pane takes its FIRST message — so the clone's opening line is the trigger, and the attach waits for the fork; if it never appears the pane is killed rather than bound to the parent's sid.
|
|
61
|
-
- **Chats are public channels, wizard↔wizard is private by default.** `send_peer` injects with `channel:""` and posts no bubble; `public:true` (the model decides) posts `emoji .a → .b` into the sender's current channel and the reply follows there. No spawn/relay/job bubbles remain — only `notify`. A `tell_peer` carrying a `job` is always private (`public` is ignored), so a fan-out's whole process stays on the rolepage; the human sees only the initiator's own closing reply, routed back along the chain that asked it. A chat with `chatPolicy.<chat>.topOnly` (top-level-only mode) on goes further (daemon-enforced in `tellPeerAs` / `/notify`): every wizard↔wizard line there is private regardless of `public`, and a wizard whose turn is working for a peer (a private peer task, or a receipt whose
|
|
61
|
+
- **Chats are public channels, wizard↔wizard is private by default.** `send_peer` injects with `channel:""` and posts no bubble; `public:true` (the model decides) posts `emoji .a → .b` into the sender's current channel and the reply follows there. No spawn/relay/job bubbles remain — only `notify`. A `tell_peer` carrying a `job` is always private (`public` is ignored), so a fan-out's whole process stays on the rolepage; the human sees only the initiator's own closing reply, routed back along the chain that asked it. A chat with `chatPolicy.<chat>.topOnly` (top-level-only mode) on goes further (daemon-enforced in `tellPeerAs` / `/notify`): every wizard↔wizard line there is private regardless of `public`, and a wizard whose turn is working for a peer (a private peer task, or a receipt whose row serves a peer task) may not `notify` it (the steward is exempt in its own chat) — the charter tells top-level wizards to explain the result in their own words.
|
|
62
62
|
- **`tell_peer` delivery policy** (`priority`) only matters when the target is busy: `normal` (default) waits for its turn to end before pasting — two senders pasting into one busy box get read as one turn; `urgent` presses Esc first (the same interrupt as `stop_wizard`, without the teardown that would drop others' queued lines); `now` pastes into the running turn (interject, answer its question; the default for `re`).
|
|
63
|
-
- `
|
|
64
|
-
- `shared/turn-state.ts` is the one vocabulary for an in-flight task: `Terminal` (the receipt statuses that settle it) plus `working` / `blocked` (parked on an approval) / `needs-input` / `errored` / `deferred`, computed on read from the
|
|
65
|
-
- `jobs.ts` is the ledger for one fan-out: which wizards belong to a job, which of them were spawned *for* it (only those get recycled on `close_job` — a long-lived wizard pulled in to help is not), and the plan, read by the rolepage's job page — opening and closing post nothing to the chat; `close_job`'s summary is archived as an episode. Each member's `outcome` is written once when its receipt settles, so "done/total" is counted by the daemon per member (not per
|
|
63
|
+
- `daemon/router.ts` makes `tell_peer` asynchronous: **one row per event** — `<event, owner, receiver>` in the journal `~/.wezard/routes.jsonl` (one op per line, folded at boot; `owner` = who owes the answer, `receiver` = where the conclusion goes, `receiver.event` = the parent row this round serves). The old machines are gone (T10): `receipts.ts`, `receiver-stack.ts`, `answer-transfer.ts`, the frame/stack parent chain and its `k` attribute, the `t…` turn ids, and the bubble answer handover. No transcript watcher locates an answer any more: the message-events layer reports each injected round's result and `router.onFinal(owner, serves, verdict)` folds it into ops (`mark` for `need`/`error`, `answer` for a conclusion); the sweeper synthesizes `timeout` (`deadline`, default 1h) / `silent` / `dead` failures the same way, delivered rather than dropped because "no answer" is also an answer. Delivery always lands the `answer` op first and then hands off: a wizard receiver gets a durable inbox entry `rcpt:<event>:<rev>` (idempotent by content revision), a chat receiver is a bubble the final gate releases. `re` continues **the same event** (`route:<event>:r<legs>`, same job and channel); the hard brake is the job budget. Ownership moves with `move` (transfer = tail call), and a receiver that no longer exists escalates along the receiver edges up to the first live wizard or to the chat root (Dead Letter); the receipt envelope's body says who was skipped / that it arrived late (no attrs — nothing reads them back). Everything the roster / peek / `list_jobs` print as 「在等 / 欠着」 is derived from the table (`owedBy` / `awaitedBy`), never stored twice. `stop_wizard` / `close_job` cascade `canceled` down the subtree before killing. Any change to router / jobs / peers: run `node scripts/receipt-regress/run.mjs`.
|
|
64
|
+
- `shared/turn-state.ts` is the one vocabulary for an in-flight task: `Terminal` (the receipt statuses that settle it) plus `working` / `blocked` (parked on an approval) / `needs-input` / `errored` / `deferred`, computed on read from the route row and one pane probe — roster, peek and `list_jobs` print the same words (`在等` / `欠着`).
|
|
65
|
+
- `jobs.ts` is the ledger for one fan-out: which wizards belong to a job, which of them were spawned *for* it (only those get recycled on `close_job` — a long-lived wizard pulled in to help is not), and the plan, read by the rolepage's job page — opening and closing post nothing to the chat; `close_job`'s summary is archived as an episode. Each member's `outcome` is written once when its receipt settles, so "done/total" is counted by the daemon per member (not per pair slot, which a later line to the same pair would overwrite); `expect` fixes the total for wizards that dispatch in stages, `maxTurns` is a hard dispatch budget (re-asks and inherited lines count). It holds no control flow on purpose: that stays in the initiating wizard's context, so a reload costs one retry instead of a resurrected state machine. Closed rows older than 24h are dropped on the next write.
|
|
66
66
|
- `notices.ts` is the other half of awareness. A charter's roster is a spawn-time snapshot and only gets staler; a variation (a birth, a `stop_wizard`, a changed job description, a chat getting named) posts one line into each affected wizard's in-memory box, and the next text injected into that pane — from a human, a peer or a scheduled task — carries it along as a `<system-reminder>`. No extra turn, no bubble, no transcript. Delivery clears the box: a notice is a hint, the truth is always `wizard_roster`.
|
|
67
67
|
- `chat-name.ts` turns a chat's unreadable `chat:wr…` id into a readable name (which its default wizard inherits), and auto-fills one from the workspace basename when nobody named it. The fill happens wherever a name is about to be handed to a model — including `renderCharter`, since a system prompt outlives the process that read it. Fill-only; a human-chosen name is never overwritten.
|
|
68
68
|
- `tasks.ts` fires a scheduled prompt into a target wizard's session — exactly equivalent to someone saying it in the chat at that moment. Lives in the daemon, not in a session, so a CLI restart / `/clear` / session end can't carry it away. It runs one fixed skeleton per shot — `trigger → gate → render → dispatch` — and nothing else: the *specifics* of each stage live in the task's own file, because a schedule is "run this logic at this time" and logic does not fit in json.
|
|
@@ -107,7 +107,7 @@ Three processes, all coordinating via 127.0.0.1:17890 and `~/.wezard/`:
|
|
|
107
107
|
- Functional first: `map`/`filter`/`reduce`, deep-merge by recursion, immutable transforms; side effects pushed to module boundaries (file IO in `shared/`, child_process in bridges, network in `ws.ts` / `http.ts`).
|
|
108
108
|
- One function = one sentence. Helpers like `extractText`, `renderInput`, `decodeKey` are pure and testable in isolation; the IO-bearing functions wire them together.
|
|
109
109
|
- Comments in source files lean toward "why" (subtle invariants like the dual `event_key` path in `approval.ts`, the 5s update window, the dedup ring buffer). Preserve them on edits.
|
|
110
|
-
- Errors should never break the workflow: `approval.fallbackOnError` defaults to `ask`,
|
|
110
|
+
- Errors should never break the workflow: `approval.fallbackOnError` defaults to `ask`, a hook that can't reach the daemon emits `allow` (no approver exists without it), other hook failures emit `ask`, every WeCom send is wrapped in try/catch that logs and continues.
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
**Codex backend**: `shared/codex.ts` adapts response_item records and discovers date-partitioned rollouts using session_meta (cwd/id). `spawn-tmux.ts` prepares native threads through the installed Codex CLI's transient app-server (thread/start, resume or fork, then thread/name/set to persist without a turn), opens a tmux pane with codex resume, and binds the known id/path/pane immediately. SessionStart maintains identity after native session switches; never invent a Claude-style transcript path or send a bootstrap message. Long startup commands run through a private temporary script to avoid PTY input truncation. MCP and developer_instructions are invocation-local TOML overrides. `cli/codex-hook.ts` bridges PreToolUse and PermissionRequest to the shared IM approval engine. Native sandbox permissions always require their own card while approval is enabled; do not reuse tool windows/skip policies. Codex does not support PreToolUse ask: unavailable approval bridges deny ordinary tools, while PermissionRequest falls back to the native prompt. `wezard sync` owns only its exact handlers in Codex hooks.json and trust hashes in config.toml; preserve third-party hooks and never bypass all hook trust. Claude project config sync does not apply to Codex.
|
package/README.md
CHANGED
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
- [绑定个人微信](#绑定个人微信默认关)
|
|
54
54
|
- [企业微信文档](#企业微信文档)
|
|
55
55
|
- [多 CLI 后端](#多-cli-后端)
|
|
56
|
-
- [缓存保活](#缓存保活默认关)
|
|
57
56
|
- [常用命令](#常用命令)
|
|
58
57
|
- [常见问题](#常见问题)
|
|
59
58
|
- [深入了解](#深入了解)
|
|
@@ -348,19 +347,6 @@ sequenceDiagram
|
|
|
348
347
|
|
|
349
348
|
---
|
|
350
349
|
|
|
351
|
-
## 缓存保活(默认关)
|
|
352
|
-
|
|
353
|
-
prompt 缓存过期后,下一轮对话要为整份上下文重新付费。保活在缓存快过期时自动发一次极小的心跳把它续上。它是为 API 默认的 5 分钟 TTL 设计的;**Claude Code 订阅写的是 1 小时缓存**(本机实测:1491 个主会话里 1490 个只写 1h,相邻两次请求隔 6–60 分钟的 230 次里 229 次整段命中),一小时内的空闲本来就不会冷,所以默认关闭。transcript 里写的是 5 分钟缓存(`cache_creation.ephemeral_5m`)的环境再打开 `wrc.mirror.keepalive.enabled`:
|
|
354
|
-
|
|
355
|
-
- 心跳节奏跟着会话实际写入的 TTL 走,按缓存真实被碰的时刻(最近一次请求的开始)计时;缓存闲置超过 10 分钟就不再续(1h 缓存因此不会被保温);
|
|
356
|
-
- 每次真实对话后最多续 6 次,之后不再续;
|
|
357
|
-
- 心跳不出现在聊天里,只记在详情页时间线;
|
|
358
|
-
- `/stop` 同时暂停保活,下次真实对话自动恢复。
|
|
359
|
-
|
|
360
|
-
路由与 `tell_peer` 冷门控判「缓存冷不冷」不依赖保活:TTL 读自 transcript 实际写入的档位,起点取最近一次请求的开始时刻。完整规则见 [技术说明](技术说明.md#prompt-cache-保活省钱心跳)。
|
|
361
|
-
|
|
362
|
-
---
|
|
363
|
-
|
|
364
350
|
## 常用命令
|
|
365
351
|
|
|
366
352
|
IM 里发 `/help` 可随时拉出完整命令表;每次 `/new`、`/clear` 之后,回执会随机附一条功能提示,用来慢慢摊开命令面。
|
|
@@ -421,7 +407,7 @@ wezard uninstall # 完整卸载(先于 npm uninstall)
|
|
|
421
407
|
|
|
422
408
|
## 深入了解
|
|
423
409
|
|
|
424
|
-
- [技术说明](技术说明.md) — 架构、消息双向同步、`.name` 路由与频道、wizard 网络(身份 / 记忆 / 分身 / 感知 / 分派 / 编排 / 回执 / 交接)、顶层模式、rolepage
|
|
410
|
+
- [技术说明](技术说明.md) — 架构、消息双向同步、`.name` 路由与频道、wizard 网络(身份 / 记忆 / 分身 / 感知 / 分派 / 编排 / 回执 / 交接)、顶层模式、rolepage、缓存冷热判定、文档 MCP 桥接
|
|
425
411
|
- [审批配置](审批配置.md) — 审批粒度、danger 名单、跳过开关的优先关系、完整判定链
|
|
426
412
|
- [CLAUDE.md](CLAUDE.md) — 模块级职责与代码约定
|
|
427
413
|
- [CHANGELOG.md](CHANGELOG.md) — 各版本变更
|
package/dist/cli/codex-hook.js
CHANGED
|
@@ -42,7 +42,11 @@ const requestApproval = async (input) => {
|
|
|
42
42
|
if (remaining <= 0) {
|
|
43
43
|
const error = e;
|
|
44
44
|
const cause = error.cause?.code ?? error.cause?.message;
|
|
45
|
-
|
|
45
|
+
const why = `bridge unavailable (${url.origin}): ${error.message}${cause ? `: ${cause}` : ""}`;
|
|
46
|
+
// Daemon down: let ordinary tools through; sandbox escalations fall back to Codex's native prompt.
|
|
47
|
+
return input.hook_event_name === "PermissionRequest"
|
|
48
|
+
? { decision: "ask", reason: why }
|
|
49
|
+
: { decision: "allow", reason: `daemon down, auto-allow: ${why}` };
|
|
46
50
|
}
|
|
47
51
|
await sleep(Math.min(1000, remaining));
|
|
48
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-hook.js","sourceRoot":"","sources":["../../cli/codex-hook.ts"],"names":[],"mappings":";AACA,qEAAqE;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAoE,MAAM,6BAA6B,CAAC;AAC3K,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,eAAe,GAAG,KAAK,EAAE,KAAyB,EAA0B,EAAE;IAClF,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,EAAE,CAAC;IACrC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO;QAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IACnF,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,oBAAoB,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACrF,+EAA+E;IAC/E,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,KAA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,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3F,OAAO;QACT,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,KAAK,CAAC,CAAC;QAC3C,2EAA2E;QAC3E,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1F,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,uCAAwC,CAAW,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAG,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3M,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,IAAI,EAAE,CAAC"}
|
package/dist/cli/sync.js
CHANGED
|
@@ -100,12 +100,15 @@ const ENV_KEYS = [
|
|
|
100
100
|
"WEZARD_DAEMON_BASE",
|
|
101
101
|
"WEZARD_DAEMON_URL",
|
|
102
102
|
"WEZARD_STATE_DIR",
|
|
103
|
-
"WEZARD_HOOK_FALLBACK",
|
|
104
103
|
"WEZARD_HOOK_TIMEOUT",
|
|
105
104
|
];
|
|
106
105
|
// Same keys under the pre-rename prefix — stripped on every sync so a migrated
|
|
107
106
|
// settings.json doesn't keep pointing the old hook at the old state dir.
|
|
108
|
-
|
|
107
|
+
// WEZARD_HOOK_FALLBACK is retired (daemon down now always allows) — strip leftovers.
|
|
108
|
+
const LEGACY_ENV_KEYS = [
|
|
109
|
+
...ENV_KEYS.map((k) => k.replace(/^WEZARD_/, "WECLAUDE_")),
|
|
110
|
+
"WECLAUDE_HOOK_FALLBACK", "WEZARD_HOOK_FALLBACK",
|
|
111
|
+
];
|
|
109
112
|
const upsertEnv = (settings, v) => {
|
|
110
113
|
const env = (settings.env ??= {});
|
|
111
114
|
for (const k of LEGACY_ENV_KEYS)
|
|
@@ -113,7 +116,6 @@ const upsertEnv = (settings, v) => {
|
|
|
113
116
|
env.WEZARD_DAEMON_BASE = v.base;
|
|
114
117
|
env.WEZARD_DAEMON_URL = `${v.base}/approve`;
|
|
115
118
|
env.WEZARD_STATE_DIR = expandHome(v.stateDir);
|
|
116
|
-
env.WEZARD_HOOK_FALLBACK = v.hookFallback;
|
|
117
119
|
// curl --max-time: 严格大于 longPollSec, 否则长挂的卡在用户点击前就断线。
|
|
118
120
|
env.WEZARD_HOOK_TIMEOUT = String(v.hookTimeoutSec);
|
|
119
121
|
return ENV_KEYS;
|
|
@@ -209,7 +211,6 @@ const main = async () => {
|
|
|
209
211
|
const envVals = {
|
|
210
212
|
base: `http://${cfg.daemon.host}:${cfg.daemon.port}`,
|
|
211
213
|
stateDir: cfg.daemon.stateDir,
|
|
212
|
-
hookFallback: cfg.approval.fallbackOnError,
|
|
213
214
|
hookTimeoutSec: cfg.approval.hookTimeoutSec,
|
|
214
215
|
};
|
|
215
216
|
const lock = readLock();
|
package/dist/cli/sync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../cli/sync.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,2EAA2E;AAC3E,oFAAoF;AACpF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,SAAS,EAA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W,yBAAyB,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,cAAc,GAAG,EAAE,EAAE,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC1J,IAAI,MAAM;gBAAE,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;;gBACtD,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QACrH,CAAC;;YAAM,OAAO,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,CAAC,MAAM;QAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC;AAC3E,CAAC,CAAC;AAEF,MAAM,IAAI,EAAE,CAAC"}
|
package/dist/daemon/approval.js
CHANGED
|
@@ -1443,18 +1443,22 @@ const decisionToHook = (d) => (d === "deny" ? "deny" : "allow");
|
|
|
1443
1443
|
// (--dangerously-skip-permissions 同义), fullAccess 是 CodeBuddy / IDE 协议注入。
|
|
1444
1444
|
// 与 hooks/pre-tool-use.sh 的 is_bypass_mode 保持同一份名单。
|
|
1445
1445
|
const BYPASS_MODES = new Set(["bypassPermissions", "fullAccess"]);
|
|
1446
|
-
// 必发卡的请求 (危险名单 / askRules) 永不走 fallbackOnError: "allow" —
|
|
1446
|
+
// 必发卡的请求 (危险名单 / askRules) 永不走 fallbackOnError: "allow" — 没人点的超时
|
|
1447
1447
|
// 降级为 ask, 交回本地 CLI 由人来确认, 而不是静默放行一次 rm。只判 danger 的话,
|
|
1448
1448
|
// 用户自己配的 askRules 在 daemon 挂掉时反而失效。
|
|
1449
1449
|
//
|
|
1450
1450
|
// `.claude/**` 守卫虽然不进 mustCard, 但在**错误面**也要走同一条降级: 正常出口靠
|
|
1451
|
-
// settleGuard 事后按框,
|
|
1451
|
+
// settleGuard 事后按框, 而这几条 (no_approver / approver_timeout; 机器人断线见 botDown)
|
|
1452
1452
|
// 要么没有 approver 可按、要么 pane 早已在等框 —— 静默 allow 就是把死锁原样放回来。
|
|
1453
|
-
// 所以调用点传的是 `mustCard || guardActive
|
|
1453
|
+
// 所以调用点传的是 `mustCard || guardActive`。
|
|
1454
1454
|
const fallback = (cfg, reason, forceSingle) => ({
|
|
1455
1455
|
decision: forceSingle && cfg.approval.fallbackOnError === "allow" ? "ask" : cfg.approval.fallbackOnError,
|
|
1456
1456
|
reason: forceSingle ? `${reason}:force_single` : reason,
|
|
1457
1457
|
});
|
|
1458
|
+
// 机器人连不上 (企微长连接断了 / 卡发不出去): 没人看得见卡, 审批这一环就当不存在, 放行 ——
|
|
1459
|
+
// 别让 hook 拖住失联期间 CLI 的正常工作。`.claude/**` 守卫例外: 放行后 CLI 照样弹原生框,
|
|
1460
|
+
// 只能交回本地 (理由同上)。
|
|
1461
|
+
const botDown = (reason, guardActive) => guardActive ? { decision: "ask", reason: `${reason}:guard` } : { decision: "allow", reason: `${reason}:auto_allow` };
|
|
1458
1462
|
const resolveApprover = (cfg, sessionId, getMirrorTarget) => {
|
|
1459
1463
|
const mirror = sessionId ? getMirrorTarget?.(sessionId) : undefined;
|
|
1460
1464
|
if (mirror)
|
|
@@ -1945,7 +1949,7 @@ export const makeApproveHandler = ({ cfg, log, client, sourcePath, getMirrorTarg
|
|
|
1945
1949
|
}
|
|
1946
1950
|
if (!canReach(client, approver)) {
|
|
1947
1951
|
log.warn("ws not connected");
|
|
1948
|
-
json(res, 200,
|
|
1952
|
+
json(res, 200, botDown("ws_disconnected", guardActive));
|
|
1949
1953
|
return;
|
|
1950
1954
|
}
|
|
1951
1955
|
// Build pending + card
|
|
@@ -2048,7 +2052,10 @@ export const makeApproveHandler = ({ cfg, log, client, sourcePath, getMirrorTarg
|
|
|
2048
2052
|
}
|
|
2049
2053
|
log.warn({ err: e.message, reqId }, "approval timed out");
|
|
2050
2054
|
const failure = e.message?.startsWith("send_card_fail:") ? e.message : "approver_timeout";
|
|
2051
|
-
|
|
2055
|
+
// 卡没发出去且此刻机器人确实断着 → 同上放行; 连接好好的发送失败 / 没人点的超时仍走 fallback。
|
|
2056
|
+
json(res, 200, (failure !== "approver_timeout" && !canReach(client, approver)
|
|
2057
|
+
? botDown(failure, guardActive)
|
|
2058
|
+
: fallback(cfg, failure, mustCard || guardActive)));
|
|
2052
2059
|
return;
|
|
2053
2060
|
}
|
|
2054
2061
|
// 必发卡的决策一律不留痕: 不写 session cache、不开自动窗口 (卡上本就没这两个
|