feat(desktop): runnable Codex-on-agent-kit swap behind PWRAGENT_CODEX_KIT#695
Draft
huntharo wants to merge 3 commits into
Draft
feat(desktop): runnable Codex-on-agent-kit swap behind PWRAGENT_CODEX_KIT#695huntharo wants to merge 3 commits into
huntharo wants to merge 3 commits into
Conversation
…_KIT First launchable slice of the Phase-B Codex swap. When PWRAGENT_CODEX_KIT=1, PwrAgent drives the live Codex thread through the kit's CodexThreadClient (@pwrdrvr/agent-client) instead of the in-tree CodexAppServerClient. - New CodexKitBackendClient (codex-kit-adapter.ts) implements the registry's BackendClient surface over CodexThreadClient: startThread, startTurn, stream, readThread (via the B1 reduceNormalizedThread + normalizedThreadToReplay adapter), interruptTurn, close. - codexEventToNotifications maps the kit's neutral NormalizedThreadEvents to the AppServerNotification shapes the registry + renderer already consume live (turn lifecycle, agent-message deltas/completion, tool-call items, token usage, errors). Pure + unit-tested. - Gated at one seam (backend-registry.ts construction); flag-off keeps the full in-tree client byte-for-byte unchanged. Rich Codex features (steer/compact/ review/model+skill+account queries) are intentionally unavailable under the flag in v1 — they're optional on BackendClient, so omitting them is clean. Scope is the core path you can actually launch and run a Codex turn on. The feature port + full client deletion follow. Built green: typecheck, desktop build, 6 new adapter tests, 230 backend-registry tests, boundary lint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Now that agent-client's CodexThreadClient has steer/compact/review/trust/ permissions (agent-kit branch claude/codex-feature-port), expose them through CodexKitBackendClient so the PWRAGENT_CODEX_KIT path is no longer core-chat-only: - steerTurn → kit turn/steer (maps AppServerTurnInputItem[] → UserInput[]) - compactThread → kit thread/compact/start - startReview → kit review/start - setThreadPermissions → kit thread/resume overlay - trustProject → kit config/value/write LOCAL BRIDGE (pending publish): the root pnpm override points @pwrdrvr/agent-client at a local tarball built from the agent-kit feature-port branch (file:/Users/huntharo/.../agent-kit/.worktrees/codex-port/.pack/...0.6.1.tgz), because the ported methods aren't published yet. To run: PWRAGENT_CODEX_KIT=1 pnpm --filter @pwragent/desktop dev Before merge: publish agent-client with these methods, bump the apps/desktop pin, and drop the override — CI stays red until then (expected for this draft). Built green locally against the linked build: desktop typecheck, build, 6 adapter tests, 230 backend-registry tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rn end Repro (PWRAGENT_CODEX_KIT=1, real Codex, after a steer): the thread LIST stuck "thinking" while the transcript was idle — a state divergence that shouldn't be possible. Root cause: on every startTurn the registry emits a synthetic `turn/started turnId=pending:<threadId>` placeholder, which adds to `activeTurnKeys` (the thread-list "thinking" driver). That placeholder never receives a per-turn terminal event — it is only swept by the wholesale `thread/status/changed`→non-active handler. The in-tree Codex client emits `thread/status/changed`; the kit's neutral event stream has NO thread-status event, so `normalizeNotification` drops Codex's status notifications and the adapter never re-synthesized them. The pending key leaked → list stuck thinking; the transcript reads threadStatus=idle and self-heals, so it did not. Fix: synthesize a `thread/status/changed` → idle in codexEventToNotifications at turn end (turn_completed and error), triggering the registry sweep. Single-active- turn is enforced by the registry, so idle-on-completion can't prematurely clear a concurrent turn. +2 adapter tests. (Proper long-term fix: a neutral thread_status event through agent-core so real Codex status is preserved — follow-up on the kit.) Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Draft / WIP tracker — recreated after #679 was auto-closed by a history rewrite on
main; rebased clean onto the new main (2 commits, no conflicts). The Phase-B Codex swap: PwrAgent's live Codex thread driven through the kit'sCodexThreadClient(@pwrdrvr/agent-client) behindPWRAGENT_CODEX_KIT=1, instead of the in-treeCodexAppServerClient. Flag-off keeps the in-tree client byte-for-byte unchanged (A/B-able).What runs through the kit now
CodexThreadClient(agent-kit PR feat(agent-client): port Codex steer/compact/review/trust/permissions to CodexThreadClient agent-kit#7).CodexKitBackendClient(codex-kit-adapter.ts) implements the registry'sBackendClientsurface overCodexThreadClient;codexEventToNotificationsmaps the kit's neutralNormalizedThreadEvents → theAppServerNotificationshapes the registry + renderer consume live. Gated at one seam (thecodexClientconstruction inbackend-registry.ts); downstream wiring untouched.Depends on: pwrdrvr/agent-kit#7
The ported kit methods aren't published yet, so this branch uses a local bridge: a root
pnpmoverride points@pwrdrvr/agent-clientat a tarball built from the agent-kit feature-port branch. CI is red until agent-kit#7 lands, a version is published, theapps/desktoppin is bumped, and the override is dropped. Expected for the draft.Run it (local bridge in place)
Status
Rebased onto new
main, built green locally against the linked kit build: desktop typecheck · build · 6 adapter tests · 230 backend-registry tests (242 desktop-main total). Agent-kit side (#7): 46 tests (6 new), CI green.Not yet validated end-to-end with a live GUI + real Codex — that's the launch test. Relationship to #672: independent; #672 is the parity gate (normalizer fidelity), this is the runtime wiring + feature port.
🤖 Generated with Claude Code