Repository navigation
v6.6.0 — workers stay workers
claude mcp add ai-cli -s user -- npx -y @tkflyc/ai-cli-mcpWorkers stay workers
A job started by ai-cli is a fresh vendor CLI, and it loads the same user-level hooks, CLAUDE.md and memory as the session that dispatched it. Rules written for the coordinator — "ask who should run this", tool budgets, "the coordinator never writes code, always delegate" — were reaching the workers. In a full acceptance run, one Gemini worker that was told to delegate found ai-cli on disk and ran ai-cli.js run --model codex from its shell. The process watcher caught the second worker and stopped it.
6.6.0 closes this in layers:
- Every vendor CLI that ai-cli starts carries
AI_CLI_WORKER=1. One helper covers all ten launch sites: pipe and PTY runs, detached wrappers, foregroundexec, agy model discovery and the usage TUIs. - The dispatch-policy hook reads the marker.
tools/hooks/aicli-model-policy.pystill gives the coordinator its policy; a worker gets a short identity lock instead: you are the result of a dispatch, do the work yourself, don't call ai-cli, and the coordinator's role rules don't apply to you (safety limits still do). - ai-cli refuses to dispatch from inside a worker. When its own environment carries the marker, MCP
run, CLIrunandexecfail withAI_CLI_NESTED_DISPATCH_BLOCKED. The marker is inherited, so this covers a worker's own MCP server as well as anai-cliit launches from a shell. SetAI_CLI_ALLOW_NESTED=1only if you really want nested dispatch. - agy and direct-api get the lock in the prompt. They don't load hooks, so ai-cli prepends the same identity block. A test keeps the copy in
srcidentical to the hook. - direct-api's shell tools carry the marker too, so a direct-api model can't route around the block through bash.
Acceptance you can rerun
npm run verify:worker-identity is opt-in and spends tokens. It runs static checks first — installed hook identical to the repo copy, both modes print the right heading, Claude and Codex settings reference it, codex ≥ 0.160 — then, for every model, an identity probe and an explicit "delegate this with ai-cli" task. A watcher counts and stops only its own descendant processes, identified by PID plus creation time. (An earlier version keyed on PID alone killed an unrelated job after Windows reused a PID.) Reports separate safety failures — got the coordinator policy, delegated without being blocked, recursed — from capability failures such as timeouts or empty replies.
On Windows, across 40 models: 0 safety failures. 10 capability failures, mostly free models timing out or returning empty replies; each was retried once.
NVIDIA free models in the catalog
The direct-api list in models now includes the 11 NVIDIA models that passed hands-on testing, plus nvidiaFreeTierCaveats. matchesModel now resolves through providers.json, so a provider you configure yourself reports the correct routable.
Compatibility
Three visible changes:
- With
AI_CLI_WORKER=1in the environment,runandexecfail withAI_CLI_NESTED_DISPATCH_BLOCKED. SetAI_CLI_ALLOW_NESTED=1to opt out. - Prompts sent to agy and direct-api start with an identity block.
- Models of a user-defined provider are now
routable: truein the catalog when they resolve.
Full details: CHANGELOG.
繁體中文
Worker 就是 worker
ai-cli 派出的 job 是一個新啟動的 vendor CLI,它會載入和派工者同一套使用者層的 hook、CLAUDE.md 與記憶。寫給主導者的規則——「先問由誰執行」、工具預算、「主導者不寫碼、一律派工」——於是也落到了 worker 身上。全模型驗收時,一個被要求轉派的 Gemini worker 在磁碟上找到 ai-cli,從 shell 執行了 ai-cli.js run --model codex;行程監控抓到第二個 worker 並把它收掉。
6.6.0 分層處理:
- ai-cli 啟動的每個 vendor CLI 都帶
AI_CLI_WORKER=1。 一個 helper 涵蓋全部十個啟動點:pipe 與 PTY、detached wrapper、前景exec、agy 模型查詢與額度 TUI。 - 派工政策 hook 會讀這個標記。
tools/hooks/aicli-model-policy.py對主導者照樣給政策;對 worker 改給一段身分鎖:你就是派工的結果、自己把工作做完、不要呼叫 ai-cli,主導者的角色規則不適用於你(安全限制仍然適用)。 - worker 裡的 ai-cli 拒絕再派工。 自身環境帶標記時,MCP
run、CLIrun與exec一律回AI_CLI_NESTED_DISPATCH_BLOCKED。標記會被繼承,所以 worker 自己的 MCP server、以及它從 shell 叫起的ai-cli都會被擋。確定需要巢狀派工時才設AI_CLI_ALLOW_NESTED=1。 - agy 與 direct-api 由 prompt 帶身分鎖。 它們不載入 hook,ai-cli 會在 prompt 開頭加上同一段身分鎖;有測試確保
src裡的副本與 hook 逐字相同。 - direct-api 的 shell 工具也帶標記,direct-api 模型無法透過 bash 繞過。
可重複執行的驗收
npm run verify:worker-identity 需手動執行、會花 token。先做靜態檢查——已安裝的 hook 與 repo 版本相同、兩種模式輸出正確標題、Claude 與 Codex 設定都有引用、codex ≥ 0.160——再對每個模型跑身分探針與「用 ai-cli 轉派」的誘導任務。監控只計數、只終止自己的子孫行程,以 PID 加建立時間識別(只看 PID 的舊版曾在 Windows 重用 PID 後誤殺無關的 job)。報告區分安全性失敗(收到主導者政策、轉派未被擋、遞迴)與能力類失敗(逾時、空白回覆等)。
Windows 上 40 個模型:安全性失敗 0;能力類失敗 10,多為免費模型逾時或回空白,各重測一次。
NVIDIA 免費模型進入清單
models 的 direct-api 清單加入 11 顆實測可用的 NVIDIA 模型與 nvidiaFreeTierCaveats。matchesModel 改經 providers.json 解析,使用者自設的 provider 會回報正確的 routable。
相容性
看得到的變化有三處:
- 環境帶
AI_CLI_WORKER=1時,run與exec回AI_CLI_NESTED_DISPATCH_BLOCKED;設AI_CLI_ALLOW_NESTED=1可解除。 - 派給 agy 與 direct-api 的 prompt 開頭多一段身分鎖。
- 使用者自設 provider 的模型,只要解析得到,catalog 會標
routable: true。
完整內容見 CHANGELOG。