feat(providers): run omo prompts through a shared pi CLI runtime - #41
Merged
Conversation
omo accepts the same non-interactive flags as Oh My Pi and emits the same JSON event stream, so the runtime is extracted rather than copied: pi-cli.ts owns the argv builder, the event normalizer, and the child lifecycle, and each CLI supplies only a descriptor. omp-cli.ts keeps its public surface as thin wrappers so existing callers and tests are untouched. Contract confirmed by capturing a real run of each CLI, not by assuming symmetry. omo emits session, message_update text/thinking deltas, and tool_execution_start/end with identical field names, plus extra envelopes (turn_start, agent_settled, tool_hook_status) and plain log lines on stdout, which the reader already skips. stdin must be closed. Both CLIs block forever on an inherited stdin: a headless run produced zero bytes until stdin was /dev/null, which the existing stdio: ['ignore', ...] spawn already satisfies. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #39, which added omo as a discovery/transcript provider. This wires the send path so omo sessions can actually be driven from ChatMux.
What changed
server/pi-cli.ts: argv builder, event normalizer, and child lifecycle for the pi-derived CLIs, parameterized by a descriptorserver/omp-cli.tsreduced to thin wrappers over it; every export keeps its signature, so existing callers andomp-cli.test.tsare untouchedserver/omo-cli.ts+omo-cli.test.tsspawnFns.omo/abortFns.omoregistered inserver/index.jsWhy extracted rather than copied
The two CLIs agree on every flag the runtime uses (
--mode json --print,--resume,--model,--thinking,@<image>) and on every event field the normalizer reads. Duplicating ~250 lines of process plumbing to change one string would have been the alternative.Contract confirmed by capture, not assumption
A real
omo --mode json --printrun emits:{"type":"session","version":3,"id":"019ff9fa-…","cwd":"/tmp/omo-json-probe"} {"type":"message_update","assistantMessageEvent":{"type":"text_delta","delta":"ok"}} {"type":"tool_execution_start","toolCallId":"toolu_01Fq…","toolName":"read","args":{"path":"…/sample.txt"}} {"type":"tool_execution_end","toolCallId":"toolu_01Fq…","result":{"content":[{"type":"text","text":"probe file\n"}]},"isError":false}Identical field names to Oh My Pi. omo additionally emits
turn_start,turn_end,agent_start,agent_settled,entry_appended,tool_hook_status, andmessage_update:text_start|text_end|toolcall_*; all are ignored, and a test pins that they stay ignored so a future mapping change is deliberate.Both CLIs also write plain log lines to stdout next to the JSON; the reader already skips unparseable lines.
stdin must be closed
A headless run with inherited stdin produced zero bytes and timed out; the same command with
< /dev/nullexited 0 and streamed the events above. The spawn already usesstdio: ['ignore', 'pipe', 'pipe'], so this is satisfied — it is called out in a comment because it is silent and total when violated.Capability matrix unchanged
supportsImagesandsupportsAbortstayfalsefor omo, mirroring the existing deliberate Oh My Pi posture (implemented in the runtime, hidden in the matrix) rather than unilaterally enabling controls.Verification
server/omo-cli.test.ts(6 tests) and the untouchedomp-cli.test.ts(3 tests) pass together, which is what shows the extraction preserved behavior. Full gate: typecheck, lint, identity, server 917, client 262.