After commit a12d2d9 closed the lifecycle pair across every adapter, the
detail field — the human-readable summary attached to each
orchestration_events row — had drifted across five emit sites into four
different formats:
• route.ts:354 ${intent.name} — ${message} (em-dash)
• route.ts:436 openclaw worker start failed: ${msg} (verbose prefix)
• inject.ts:225 ${promptLabel} — ${result.error} (em-dash)
• worker.ts:72-3 ${intent} done | ${intent}: ${error} (split formats)
• worker.ts:88 ${error.message} (no intent context)
Downstream chart/list queries would need to grep multiple separator
formats and strip multiple prefix variants. Unified to one canonical
shape across all five sites:
success → "<intent_or_label>" (no trailing " done")
failure → "<intent_or_label>: <error>" (single-colon separator)
Operators can now split on the first colon to extract the intent label,
or pattern-match `:.*` to extract the error. The verbose "openclaw
worker start failed:" prefix is gone — the `source: 'api-orchestration'`
column already carries that context.
No schema changes. detail column is still truncated to 400 chars. The
existing task_started emits (which only carry the intent name with no
error) were already consistent and untouched.
tsc + eslint + build clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The codex/gemini branch in /api/orchestration/run emits task_started at
line ~296 before injectIntoTab. The openclaw branch did not. So every
successful openclaw run was invisible in orchestration_events — only
its orchestration_runs row existed. Commit 9a0ac77 closed the worker-
start-failure pair (failed-to-spawn now emits task_failed), but the
happy path and the in-worker error path were both still silent.
Three coordinated changes:
1. Route emits task_started before scheduleOpenClawWorker — mirrors
the codex/gemini emit shape so dispatches across all adapters look
uniform in queries.
2. scheduleOpenClawWorker signature gains userId, encodes it into
the base64 payload. The worker needs user_id to write to
orchestration_events (NOT NULL constraint).
3. Worker emits task_completed (state:'done') or task_failed
(state:'error' or thrown) after its terminal updateOrchestrationRun.
Source field 'openclaw-worker' (vs 'api-orchestration' on the start
event) so timeline queries can tell which process emitted what.
After this, orchestration_events carries a full started/completed-or-
failed pair for every openclaw dispatch — same shape as codex/gemini —
and the single dispatch-success-rate query introduced in 9a0ac77 covers
every adapter without per-adapter casing.
tsc + eslint + build clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the Claude-only prompt loop with a neutral orchestration layer
that dispatches tasks to whichever agent is available. When one brain
runs out of tokens, switching to another requires one tap.
New infrastructure:
- src/lib/orchestration/ — contract, 10 task intents, adapter definitions,
prompt renderer, OpenClaw runner, summary parser
- src/lib/agent-registry.ts — detects claude/codex/openclaw/gemini from
PATH; reads configured model from dotfiles
- src/lib/agent-preferences.ts — persists selected brain to
~/.config/cockpit-agent.json; syncs model back to Claude settings
- src/lib/agent-catalog.ts, agent-runtime.ts, switch-agent.ts — catalog,
zellij tab restart logic, agent switching action
- src/db/schema/orchestration-runs.ts + queries — DB-tracked runs
New API routes:
- /api/control/agent — GET brain config, POST to switch + restart zellij tabs
- /api/orchestration/run — brain-agnostic dispatch: claude/codex → inject
rendered prompt into zellij tab; openclaw → fires detached worker
- /api/orchestration/run/execute — synchronous execute endpoint for worker
Control panel UX:
- Brain section collapsed to a single pill, expanding only when needed
- Intent buttons replace hardcoded "OpenClaw" buttons — Next best, Test & fix,
Quality, Commit, +5 under More; each shows "via {adapter}"
- agentRunning detection uses /proc scan against configured agent matchers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>