cc-viewer 1.6.269 → 1.6.271

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.
Files changed (36) hide show
  1. package/README.md +3 -17
  2. package/cli.js +13 -2
  3. package/dist/assets/{App-DzjYA7D5.js → App-LEYaH-CM.js} +1 -1
  4. package/dist/assets/{MdxEditorPanel-jhYrPElX.js → MdxEditorPanel-B7oOvR3k.js} +1 -1
  5. package/dist/assets/{Mobile-CsHrWYjl.js → Mobile-Cwf21Pmq.js} +1 -1
  6. package/dist/assets/{index-CzhQgS4q.js → index-CLfbZzwF.js} +2 -2
  7. package/dist/assets/index-wU9AHa7Y.css +1 -0
  8. package/dist/assets/seqResourceLoaders-CmFg0jyW.js +2 -0
  9. package/dist/assets/seqResourceLoaders-N07Gfom9.css +41 -0
  10. package/dist/index.html +2 -2
  11. package/dist/voice-packs/default/A_choice_for_your_consideration_sir.MP3 +0 -0
  12. package/dist/voice-packs/default/It_is_done_sir.MP3 +0 -0
  13. package/dist/voice-packs/default/The_plan_awaits_your_approval_sir.MP3 +0 -0
  14. package/dist/voice-packs/default/pack.json +13 -23
  15. package/dist/voice-packs/sanguo/ask.MP3 +0 -0
  16. package/dist/voice-packs/sanguo/end.MP3 +0 -0
  17. package/dist/voice-packs/sanguo/pack.json +24 -0
  18. package/dist/voice-packs/sanguo/plan.MP3 +0 -0
  19. package/lib/ask-bridge.js +128 -7
  20. package/lib/ask-constants.js +13 -0
  21. package/lib/ask-store.js +319 -0
  22. package/lib/ensure-hooks.js +54 -9
  23. package/lib/sdk-manager.js +4 -1
  24. package/lib/voice-pack-events.js +51 -5
  25. package/lib/voice-pack-manager.js +135 -38
  26. package/package.json +1 -1
  27. package/pty-manager.js +2 -2
  28. package/server.js +519 -43
  29. package/dist/assets/index-_4BCXKKF.css +0 -1
  30. package/dist/assets/seqResourceLoaders-BZiHSoZE.css +0 -41
  31. package/dist/assets/seqResourceLoaders-DvOHDZMB.js +0 -2
  32. package/dist/voice-packs/default/askQuestion.wav +0 -0
  33. package/dist/voice-packs/default/planApproval.wav +0 -0
  34. package/dist/voice-packs/default/timeoutWarning5min.wav +0 -0
  35. package/dist/voice-packs/default/timeoutWarning60s.wav +0 -0
  36. package/dist/voice-packs/default/turnEnd.wav +0 -0
package/README.md CHANGED
@@ -1,5 +1,4 @@
1
- <img width="1500" height="200" alt="CC-Viewer" src="https://github.com/user-attachments/assets/abec0513-1d56-4244-b7ed-9382b6c09049" />
2
-
1
+ <img height="200" width="1500" alt="CC-Viewer" src="https://github.com/user-attachments/assets/abec0513-1d56-4244-b7ed-9382b6c09049" />
3
2
 
4
3
  # CC-Viewer
5
4
 
@@ -149,7 +148,7 @@ Click the "Conversation Mode" button at the top right to parse the Main Agent's
149
148
  * Agent Team display is not yet supported
150
149
  * User messages are right-aligned (blue bubbles), Main Agent replies are left-aligned (dark bubbles)
151
150
  * `thinking` blocks are collapsed by default and rendered as Markdown — click to expand and view the reasoning; one-click translation is supported (still unstable)
152
- * User-selection messages (AskUserQuestion) are displayed in Q&A form
151
+ * User-selection messages (AskUserQuestion) are displayed in Q\&A form
153
152
  * Two-way mode sync: switching to Conversation mode auto-scrolls to the conversation that matches the selected request; switching back to the raw mode auto-scrolls to the selected request
154
153
  * Settings panel: toggle the default collapsed state of tool results and thinking blocks
155
154
  * Mobile conversation browsing: in mobile CLI mode, tap the "Conversation Browse" button in the top bar to slide out a read-only conversation view and browse the full history on your phone
@@ -195,19 +194,6 @@ You can customize plugins directly, manage all cc-viewer processes, and cc-viewe
195
194
 
196
195
  More features waiting for you to discover... for example: the system supports Agent Team and ships with a built-in Code Reviewer. Codex Code Reviewer integration is coming very soon (I strongly recommend using Codex to review Claude Code's code).
197
196
 
198
- ***
199
-
200
- **Voice pack** — bind custom audio to Claude lifecycle events. Open *Settings → Sound on approval* (toggle on to reveal the binding panel) to pick a sound for plan approvals, askUserQuestion popups, 60-min timeout warnings (5-min and 60-s tiers are separate bindings — set both for full coverage), and turn-end notifications. In CLI/PTY mode turnEnd fires via Claude Code's Stop hook (the hook auto-installs into `~/.claude/settings.json`); in SDK mode it fires from the SDK `result` event directly. Either way, it lands at the real end of a user-prompt turn — not after each individual API call.
201
-
202
- **Uninstalling cc-viewer hooks** — cc-viewer writes three entries into `~/.claude/settings.json` (`PreToolUse` × 2, `Stop` × 1), each tagged with the marker comment `# cc-viewer-managed`. If you uninstall cc-viewer (`npm uninstall -g cc-viewer`), strip the stale entries by hand or with:
203
-
204
- ```bash
205
- jq '(.hooks // {}) |= with_entries(.value |= map(select((.hooks[]?.command // "") | contains("cc-viewer-managed") | not)))' \
206
- ~/.claude/settings.json > /tmp/settings.json && mv /tmp/settings.json ~/.claude/settings.json
207
- ```
208
-
209
- This removes only the entries cc-viewer added; any third-party hooks you've configured are left alone. The bundled default pack ships with a **Pixel-Buddy chiptune SFX set** (5 short 8-bit cues, ~100 KB total). Drop your own recording into `public/voice-packs/default/<eventKey>.{wav|mp3|ogg|m4a}` to override, or upload via the Settings panel for a per-user binding. Each file ≤ 2 MB. Plays on iPad and phone too, with HTTP Range support for iOS Safari and an autoplay-block chime fallback.
210
-
211
197
  ## License
212
198
 
213
- MIT
199
+ MIT
package/cli.js CHANGED
@@ -370,7 +370,7 @@ async function runCliMode(extraClaudeArgs = [], cwd, noOpen = false) {
370
370
  // 3. 启动 PTY 中的 claude
371
371
  const { spawnClaude, killPty } = await import('./pty-manager.js');
372
372
  try {
373
- await spawnClaude(proxyPort, workingDir, extraClaudeArgs, claudePath, isNpmVersion, port, serverProtocol);
373
+ await spawnClaude(proxyPort, workingDir, extraClaudeArgs, claudePath, isNpmVersion, port, serverProtocol, serverMod.getInternalToken());
374
374
  } catch (err) {
375
375
  console.error('[CC Viewer] Failed to spawn Claude:', err.message);
376
376
  await serverMod.stopViewer();
@@ -471,7 +471,18 @@ async function runSdkMode(extraClaudeArgs = [], cwd, noOpen = false) {
471
471
  // Round-3 P0: SDK mode has no Stop hook (ensureHooks() skipped above), so
472
472
  // the only place we learn a turn ended is the SDK 'result' message. Forward
473
473
  // it to the same SSE channel the Stop hook bridge uses in PTY mode.
474
- onTurnEnd: ({ sessionId, ts }) => serverMod.broadcastTurnEnd?.(sessionId, ts),
474
+ // try/catch + warn:rising-edge flush 假设「下一轮 active 之前 onTurnEnd 已到」,
475
+ // 若 SDK 内部异常吞掉了 result 消息这条信号就丢了 —— 至少打个 warn 让排查时有线索。
476
+ // 显式 typeof 检查:以前用可选链 `?.()` 在 export 缺失时返回 undefined → catch 永远不触发
477
+ // → 「至少 warn」承诺落空,turn-end 静默丢,bug 极难追。
478
+ onTurnEnd: ({ sessionId, ts }) => {
479
+ if (typeof serverMod.broadcastTurnEnd !== 'function') {
480
+ console.warn('[sdk] serverMod.broadcastTurnEnd is not a function (export missing?); turn-end signal dropped');
481
+ return;
482
+ }
483
+ try { serverMod.broadcastTurnEnd(sessionId, ts); }
484
+ catch (err) { console.warn('[sdk] broadcastTurnEnd threw:', err?.message); }
485
+ },
475
486
  });
476
487
 
477
488
  // 注册 SDK 回调到 server.js(WS 消息路由用)