Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

docs(issue-2243): log CoS Windows CLI-spawn fix to changelog

Adam Eivy9daadb04fc51
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index d38bcb797b..d97ffa0633 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -8,6 +8,7 @@
- **A live agent TUI no longer gets reaped mid-paste.** The idle-timeout reaper only tracked `lastOutputAt` (PTY output), not client input, so pasting a large multi-line command into a running agent's session could sit in a silent reflow/commit window with no echo yet — indistinguishable from "idle" to the 5s poll. If the session happened to already be near its idle threshold, the reaper killed the PTY mid-paste, showing "[Session removed externally]" in the Shell page. The idle timer in `agentTuiSpawning.js` now also checks a new `shell.js` export, `getLastInputAt()`, and skips the reap while input arrived within the last 15s. This is deliberately keyed on input *recency*, not "is a Shell viewer attached": a regular (non-external) session's socket stays bound after its viewer navigates away — only external one-shot `tuiPromptRunner.js` runs get released via `shell:release-views` — so an attachment-based guard would have permanently suppressed idle-complete for any agent glanced at once in the Shell UI. (`server/services/shell.js`, `server/services/agentTuiSpawning.js`)
- **Swarm claim-issue runs now write the completion sentinel so the task actually finishes.** In `/do:next --swarm` mode the orchestrator ships every issue via a PR and never touches the working tree, so it was skipping the `.agent-done` completion sentinel — leaving the CoS task hanging with no summary as if the run never ended. Phase C of the swarm directive now explicitly instructs the orchestrator to write the sentinel (with a run summary of the issues claimed, their PRs, and merge outcomes) after the serialized merges, while still skipping the per-agent `/simplify`/push steps. (`server/services/cosTaskGenerator.js`)
- **[issue-2190] OpenCode Ollama providers now accept any --model flag.** The static `OPENCODE_CONFIG_CONTENT` lacked a models map, so OpenCode rejected every model with "not valid" and the agent sat idle. The config is now built dynamically at spawn time, declaring the provider's configured models (plus the model being run) under `provider.ollama.models` with bare ids — the exact shape OpenCode's `@ai-sdk/openai-compatible` provider validates `--model ollama/<id>` against. Applied across every OpenCode spawn path (CoS CLI/TUI agents, the toolkit CLI/TUI runners, and the light fire-and-collect CLI run), and a migration backfills existing installs' `data/providers.json` so a configured model's map is persisted too. Fixes the TUI eval path for local Ollama models.
+- **[issue-2243] OpenCode Ollama (and every other CLI provider) now starts under Chief of Staff on Windows.** A CoS task using OpenCode Ollama — or any npm-installed CLI provider — failed instantly with a `startup-failure` (exit code -4058) while the same provider ran fine from the Settings "Run Prompt" button. The CoS agent spawners launched the bare command (`opencode`) directly, so on Windows the `opencode.cmd` shim couldn't be found and the process never started; the "Run Prompt" path already resolved the real shim and launched it through `cmd.exe`. Both CoS spawn paths (the runner process and direct mode) now use that same resolve-and-wrap step, so the agent starts correctly. The runner path additionally now injects the OpenCode models config (the #2190 fix), so the model is accepted there too. Non-Windows installs are unaffected.
- **A busy-but-stuck TUI agent can no longer run unbounded — a wall-clock ceiling now backstops the idle reaper.** The idle-timeout reaper resets on every PTY chunk, but Claude Code repaints its `(Ns · esc to interrupt)` working counter roughly once a second while *any* tool/API call is in flight — including one stuck retrying a stalled Bedrock/network operation. A "busy-but-stuck" agent therefore keeps `lastOutputAt` advancing forever, so idle-reap never fires and the run had no ceiling at all: a real `/do:next --swarm` claim-issue orchestration churned its counter for 98 minutes (2026-07-06, agent-b1c56083) before Claude Code's *own* internal "Operation timed out" finally stopped it — had the CLI not self-terminated, the agent would have run unbounded, holding its lane, blocking the app's cooldown, and leaking a shell session. The long-running agent TUI path now arms an absolute wall-clock backstop from prompt submission (default 3h, provider-configurable via `tuiMaxRuntimeMs`), mirroring the one-shot runner's existing `hardTimeoutTimer`. If it fires with no `.agent-done` sentinel present, the run finalizes as a needs-manual-finish FAILURE (`max-runtime-timeout`) with the same "check for open or merged-but-uncleaned PRs" guidance as the merge-queue/review-loop idle-timeout paths, capturing any uncommitted worktree diff for post-mortem first; if the sentinel *is* present the run is salvaged as success. (`server/services/agentTuiSpawning.js`, `server/lib/tuiHandshake.js`, `server/lib/aiToolkit/providers.js`, `server/lib/aiToolkit/validation.js`, `server/lib/validation.js`)
- **[issue-2191] TUI agents with zero file changes are now marked failed instead of silently succeeding.** A TUI agent that idled out after showing working indicators but made no uncommitted file changes was previously finalized as `success: idle-complete` — deleting the worktree and any evidence of what happened. Now the idle-complete path checks `git status` in the worktree: if the tree is clean, it finalizes as `failure: idle-no-changes` with the TUI buffer tail as error context. Any uncommitted diff is also captured to `worktree-diff.txt` in the agent archive dir before cleanup, so post-mortems can see what (if anything) was left behind.
- **[issue-2193] Concurrent agent spawns no longer race on git worktree creation.** When two tasks for the same app spawned in the same evaluation tick, the first `git worktree add` grabbed git's per-repo worktree lock and the second failed with a lock error — blocking that task with `blockedCategory: worktree-failed` and leaving an orphan branch (`cos/task-…/agent-…`) with no worktree. Worktree creation now serializes per source repo through a single promise tail (the `issueWriteTail` pattern), so same-tick adds queue instead of colliding; `git worktree add` also retries a few times with backoff on lock errors to absorb residual external contention; and on final failure the partially-created branch is deleted (`git branch -D` + `git worktree prune`) so orphan branches stop accumulating. (`server/services/worktreeManager.js`)