LIVE 模式改為雙向對話(codex exec --json + resume 接力)

摘要:
與 claude-office 同功能:側邊面板聊天室,每則訊息 spawn
codex exec --json,捕捉 thread_id 後下一則以 codex exec resume 接力。

根本原因:
單向 /task 看不到回覆也無法追問。

影響:
watcher 新增 POST /chat 與 chat_* SSE 事件;已實測一輪對話
(thread.started → agent_message → turn.completed)正確回傳。

修法:
- watch.mjs:launchChat 解析 --json 事件流(thread_id / agent_message /
  turn.completed),chatThreads 記憶 thread
- 前端與 claude-office 同步(ChatPanel / chats store / chat_* 對映)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 14:59:24 +08:00
co-authored by Claude Fable 5
parent ef07f4b8ad
commit 89a8b75b61
6 changed files with 817 additions and 399 deletions
+11 -1
View File
@@ -41,7 +41,17 @@ npm run watch # http://localhost:5181/events (SSE)
注意:監看伺服器會讀取本機的 Codex 對話記錄,**只綁 127.0.0.1、不要對外開放**。
### 在辦公室下任務(LIVE 模式)
### 在辦公室對話(LIVE 模式)
點選專案 agent 後,側邊面板是一個**雙向聊天室**:每則訊息 spawn 一次
`codex exec --json`,從輸出捕捉 `thread_id`,下一則自動 `codex exec resume`
接力。回覆同時顯示在聊天串和小人頭上的對話氣泡。
- 「接續專案最近 session」:第一句改從該專案最近的 rollout 接續
- 「🔄 新對話」:清空 office 對話串(會終止進行中的執行)
- 事件:`POST /chat` → SSE 廣播 `chat_start` / `chat_text` / `chat_done`
### 在辦公室下任務(API)
點選任一專案 agent,側邊面板會出現任務輸入框 —「🚀 派發任務」會透過
`POST /task` 讓監看伺服器在該專案目錄 spawn 一個 headless session: