core/local-composer.mjs) is used by the Codex, Claude Code, and OpenCode adapters. It serves ui/composer.html and exposes an API under /api/*. The Antigravity adapter does not use it; Antigravity uses MCP App tools over stdio instead.
Server
- Base URL:
http://127.0.0.1:<port>. The port is ephemeral (0) unless an adapter passes one. - Binding:
127.0.0.1only. - Lifetime:
startLocalComposerServerhas no idle timeout by default (idleTimeoutMs = 0). The launcher used by the Codex and Claude Code hooks (core/launch-local-composer.mjs) sets 30 minutes, configurable with--idle-ms. Each request resets the timer. The OpenCode plugin starts the server without an idle timeout and closes the previous server when a new prompt is intercepted.
Request checks
Checks run in this order:- Host header (all requests): must be
127.0.0.1:<port>orlocalhost:<port>. Otherwise 403Invalid Host header. - Origin and Referer (
/api/*): if present, must behttp://127.0.0.1:<port>orhttp://localhost:<port>. Otherwise 403Cross-origin request rejected.orCross-origin referer rejected. - Session token (
/api/*): theX-EISPATCH-Tokenheader must equal the per-session token (constant-time comparison). Otherwise 401Missing or invalid EISPATCH session token.
window.__EISPATCH_LOCAL_SESSION__, together with host, hostLabel, and initialPrompt.
Request bodies larger than 5 MB are rejected. Unhandled errors, including oversized bodies and library errors, return 500 with { "error": "<message>" }. Unknown routes return 404.
Endpoints
Compose
Body fields:prompt (defaults to the initial prompt), workspacePath, tasks (optional seed tasks).
Response fields: host, hostLabel, prompt, projectContext, suggestedMetadata, counts, telemetry, graph, tasks, preview (a compile result).
Breakdown
Body fields:prompt, workspacePath, tasks. If tasks is empty, EISPATCH suggests tasks from the prompt.
Response fields: prompt, tasks, preview.
Compile
Body fields:prompt, selectedNodes, tasks, globalNotes, manualFinalPrompt.
Response: the compile result (compiledPrompt, generatedPrompt, manifest, summary). See Compiled prompt.
Approve
Body:{ "compiledPrompt": "<exact text>" }. An empty prompt returns 400 Cannot approve an empty prompt.
Random token required by the next dispatch. Only one approval is active at a time; a new approval replaces the previous one.
Revoke approval
Body:{ "approvalToken": "<token>" } (optional). The token, or the active token if none is given, is marked as consumed and the active approval is cleared. Returns { "ok": true }.
Dispatch
Body:{ "compiledPrompt": "<exact text>", "approvalToken": "<token>" }.
On success, the token is consumed before the adapter’s dispatch handler runs.
- With an adapter dispatch handler (OpenCode):
{ dispatchId: "disp_<timestamp>", host, promptHash, ...result }. The OpenCode resultmodeisopencode-session-prompt,opencode-http-session, orclipboard-fallback. - Without a handler (Codex and Claude Code):
{ dispatchId: "copy_<timestamp>", host, promptHash, mode: "clipboard-fallback", note }. The composer UI then copies the prompt for you to paste.
Library endpoints
These call the functions incore/library.mjs. See Prompt library for the entry schema.