codex_launcher.py serves a local JSON API. Default URL:
http://127.0.0.1:6211
The API is intended for the bundled dashboard.html and trusted local tools.
Returns launcher state, sessions, queue, API version, model choices, and concurrency limits.
Returns the governance report generated from Git state.
Query parameters:
mode:worktree,staged, orbasebase: Git ref used whenmode=base
Report payloads include a preflight.checks.portability_reference_scan object:
decision:PASSorREVIEWscope: scanned governance surface familyscanned_files: files inspected with UTF-8 decodingviolations: machine-local references that need reviewexceptions: machine-local references treated as command or inline-code examples
Returns Zhongshu sessions with child department summaries and unread result counts.
Returns the latest structured plan reported by a Zhongshu session.
Returns unread and read department reports for a Zhongshu session. By default, unread reports are marked as read. Add peek=1 to inspect without marking read.
Returns a restart snapshot for a Zhongshu session: task, plan, recent reports, and child sessions.
Returns browser terminal sidecars launched through tools/codex_terminal/.
Session payloads returned by /api/status, /api/sessions, /api/zhongshu_sessions, and inbox/context endpoints may also include:
browser_terminal_idbrowser_terminal_statusbrowser_terminal_urlbrowser_terminal_titleheartbeat_status: department session liveness, one ofactive,stalled,exited, orunknownidle_seconds: seconds since the department transcript log last changed, present after heartbeat sampling
Starts a Zhongshu Codex session.
Request fields:
task: first prompt textmodel: optional model frommodel_choices
Restarts a Zhongshu session from stored context.
Request fields:
session_idmodel: optional model
Registers a structured plan from Zhongshu.
Request fields:
session_idsummaryassignments: array of department assignment objects
Assignment fields:
departmenttaskmodelfilesverifyreasonmodel_reasonselected
Starts the local tools/codex_terminal/ sidecar and returns a tokenized loopback URL for iframe embedding.
Optional request fields:
shell: override PTY shellshell_args: override PTY shell arguments
The launcher always sets host to 127.0.0.1 and port to 0, so the terminal service chooses a free loopback port and generates its own runtime token.
Stops a browser terminal sidecar.
Request fields:
id: terminal id returned by/api/browser_terminal/start
Starts or reuses a tokenized loopback browser-terminal sidecar for one governance session.
Request fields:
session_id
The sidecar stays on 127.0.0.1 and tails that session's transcript log for browser preview inside the dashboard.
Starts or queues selected department assignments after user confirmation.
Request fields:
parent_session_idassignments
Starts one department session. Used by the dashboard for manual launches.
Request fields:
departmenttaskparent_session_id: optional when one active Zhongshu session existsmodel: optional
Department sessions report by writing UTF-8 JSON files to:
.tmp/codex_governance_mailbox/<zhongshu_session_id>/incoming/
Required fields:
parent_session_iddepartment_session_iddepartmentsummary
Optional fields:
changed_filesverificationorverifications_runverifications_skippedrisksnext_actionneeds_user_confirmation
When the launcher registers a department report, it also writes a Markdown handoff packet under:
.tmp/codex_governance_mailbox/<zhongshu_session_id>/archive/handoff-*.md
The registered result includes handoff_packet with the generated path. The packet records the parent session, department session, source, objective, summary, changed files, verification, risks, and next action.
Zhongshu prompts include an inbox reduction rule: when unread results are multiple, risky, need confirmation, conflict on next_action, or include launcher_fallback, Zhongshu should use a temporary Codex subagent to read /api/zhongshu_inbox?id=<session_id>&peek=1 and summarize only. That subagent must not edit files, start departments, or make the final Zhongshu decision.
Launcher also appends key flow events to .tmp/codex_governance_audit.jsonl as JSON Lines. Current event names include session_started, session_closed, assignment_queued, zhongshu_plan_registered, result_registered, and result_updated.
Most failures return:
{
"ok": false,
"error": "message"
}