LIVE 模式可直接在辦公室對專案派發任務

摘要:
與 claude-office 同功能:點選專案 agent 輸入任務,監看伺服器在該專案
cwd spawn headless session(codex exec --full-auto),過程即時可視。

根本原因:
實況模式原本只能唯讀觀察 rollout,無法從辦公室驅動真實 Codex 執行。

影響:
watcher 新增 POST /task(Origin 白名單 5173/5182、每專案排隊上限 3、
15 分鐘逾時);--full-auto 允許 AI 在專案內改檔案,僅限 localhost 使用。

修法:
- server/watch.mjs:launchTask 用 codex exec --full-auto --skip-git-repo-check -
  (prompt 走 stdin),resume 由該專案最新 rollout 檔名取 sessionId;
  新生 rollout 檔從頭 tail(born-now)
- live.ts:dispatchTask() + task_accepted/task_done;SidePanel TaskComposer

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 14:21:44 +08:00
co-authored by Claude Fable 5
parent 7d9d477166
commit 1ac46782a1
5 changed files with 320 additions and 4 deletions
+15
View File
@@ -41,6 +41,21 @@ npm run watch # http://localhost:5181/events (SSE)
注意:監看伺服器會讀取本機的 Codex 對話記錄,**只綁 127.0.0.1、不要對外開放**。
### 在辦公室下任務(LIVE 模式)
點選任一專案 agent,側邊面板會出現任務輸入框 —「🚀 派發任務」會透過
`POST /task` 讓監看伺服器在該專案目錄 spawn 一個 headless session:
```
codex exec --full-auto --skip-git-repo-check - # prompt 由 stdin 傳入
```
- 勾「續上次 session」= `codex exec resume <該專案最新 sessionId>`
- 執行過程即時演在辦公室裡,結束時事件紀錄顯示 🏁(失敗會顯示 ⚠️ 與 stderr 摘要)
- 同專案同時只跑一個任務,其餘排隊(上限 3);單一任務 15 分鐘逾時
- 安全:`/task` 僅接受 localhost 來源 + Origin 白名單(5173/5182),
`--full-auto` 允許 AI 在該專案內改檔案跑指令 — **請理解風險後再用**
## PM2 部署
```bash