Repository navigation
feat(providers): Codex on a ChatGPT plan, and Kimi via Moonshot - #100
Merged
Merged
Conversation
Companion to homebot-defect-patterns, which covers wiring — code that isn't
reachable. This covers state: code that IS reachable, runs, and still leaves
the user broken because the data on their disk was written under an older rule.
Six patterns, all observed live in one day. Four were introduced by an earlier
fix in the same session, which is the point of writing it down:
1. A fix that needs the user to act is not a fix. Correcting the code that
WRITES persisted state does nothing for state already written. Reported
three times as "Qwen selected, opus answering" — each time after a
relaunch, each time after I said it was fixed. Resolution: change the READ
rule, migrate the data, or repair the file. Not the write alone.
2. Asymmetric flag writes — one branch sets a flag, the other forgets to
clear it, and the system holds a state that says both.
3. Non-idempotent transforms compound. Encryption with no ciphertext marker
re-encrypted its own output every save, ~33% growth per pass, found as a
180,106,622-character apiKey.
4. Recovery that archives but doesn't repair loops — 42 corrupt-file archives
stamped 30 seconds apart.
5. Encoding is not corruption. A UTF-8 BOM (from my own repair) triggered
destructive recovery and wiped the user's settings.
6. "Cloud provider" does not mean "HTTP endpoint" — three features hand-rolled
a URL for a provider that is a CLI, producing "Invalid URL".
Plus a Windows subprocess section from the Codex work: spawn EINVAL on .cmd
(CVE-2024-27980) which .exe-based CLIs never hit, why the prompt must go over
stdin rather than argv once shell:true is required, and the stdin-close hang
that is invisible from a terminal because the shell closes stdin for you.
Each carries the concrete live case rather than the generality, and the
verification standard section records what actually caught these: reading the
user's real file, A/B against a stash, grepping the shipped bundle, and running
the CLI through the production spawn shape.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Two providers, one branch because both extend the same provider union and settings surfaces — separate branches would conflict by construction. CODEX (`codex`) — OpenAI's Codex CLI signed in with a ChatGPT account, so usage draws on the user's plan rather than a metered API key. Sibling of the existing claude-code provider: keyless, endpoint-less, validated on model alone, exempt from the list-models URL guard, offered in Settings. Three things only running it could have found, all fixed here: - spawn EINVAL. npm installs the CLI as codex.cmd, and modern Node refuses to spawn .cmd without shell:true (CVE-2024-27980). claude.exe is a real executable and never hits this, so copying the working provider would have shipped broken. - Prompt must NOT go in argv. Once shell:true is forced, arguments are concatenated unescaped — a prompt containing & or | would execute commands. The prompt now goes over stdin via `codex exec -`, keeping every untrusted byte off the command line; only our own literal flags remain. - stdin must be closed. Codex reads stdin for extra context even when given a prompt, and hangs forever while the pipe is open. Invisible from a terminal, where the shell had already closed it. Verified against the real CLI through the exact production spawn shape: returns PONG, exit 0, parsed from item.completed/agent_message events. Event shape confirmed against OpenAI's docs, not guessed. No tool bridge for Codex, deliberately: openai/codex#15451 reports --json output going malformed once MCP servers are active, and a corrupted stream is worse than no tools. Chat only; claude-code keeps HomeBot's gated toolset. Text also arrives per item rather than per token, so replies land in one or two chunks — the CLI's granularity, documented in the code. KIMI (`moonshot`) — OpenAI-compatible at api.moonshot.ai/v1, so no bespoke client: a base URL, a vault key field (moonshotApiKey, encrypted at rest and hydrated by resolveCloudLLM like the others), and a dropdown entry. NEEDS ADEN: an API key from platform.moonshot.ai, which requires a paid top-up. Verified: tsc clean; build green; 12 new tests (provider shape, validation, key hydration, and that codex/claude-code stay absent from PROVIDER_API_URLS); full suite 161/161, 2473/2473; all five new symbols confirmed in the shipped main bundle. Not yet exercised through the app UI — needs a relaunch and a provider switch. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
Automated PR for
claude/codex-and-kimi-providers. Auto-merges to main once CI is green.