Skip to content

feat(dsh): add the Codex Desktop handoff adapter - #2652

Merged
hidb4ai merged 3 commits into
codex/dsh-handoff-receiptsfrom
codex/dsh-handoff-codex-desktop
Nov 16, 2026
Merged

hidb4ai merged 3 commits into
codex/dsh-handoff-receiptsfrom
codex/dsh-handoff-codex-desktop

Conversation

@knqiufan

@knqiufan knqiufan commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

Refs #2514 and RFC #2528. This PR builds on #2651 (shared short draft and receipt verification).

Rationale for this change

A detected Codex installation does not establish which PowerContext plugin, Server, Scope, or permission profile a new Desktop chat will use. Launch needs to check those facts for the selected workspace and package.

What changes are included in this PR?

  • Detect and version-check the macOS app and its embedded CLI. Query the embedded app-server for the enabled PowerContext plugin, trusted hooks, required MCP tools and effective workspace settings without creating a chat.
  • Compare the receiver's MCP endpoint and authorization configuration with its hook configuration, resolve the Server and Scope, and bind preflight to the observed configuration. Check package readability in the supported Codex sandbox and compare the exact saved package hash again before launch.
  • Build the intent for a new chat in the verified directory with the draft left unsent. Support explicitly consented PowerContext setup; require a further integration check after setup. Give cold Codex app-server inspection enough time while preserving a separate allowance for the exact-package check.

Are there any user-facing changes?

Codex can be detected without being eligible to launch. The normal registry only offers launch for a qualified version and environment; opened only means the operating system accepted the request.

How was this change tested?

  • From the DSH plugin directory, pnpm exec vitest run --maxWorkers=1 tests/codex-desktop-adapter.spec.ts tests/codex-desktop-runtime.spec.ts tests/handoff.spec.ts — 36 tests passed, including changed configuration, missing tools, untrusted hooks, and package access failures. pnpm build passed.
  • In the isolated DSH Desktop flow, delivery 5cd2 opened a new native Codex chat with an unsent draft. The operator added a read-only README requirement; Codex returned the heading and CODEX-814, called Continue and ACK, and DSH verified that exact receipt.

AI usage statement

OpenAI Codex assisted with implementation, tests, local validation, and preparing this PR.

@knqiufan
knqiufan force-pushed the codex/dsh-handoff-codex-desktop branch from 305ba71 to 54d0151 Compare November 14, 2026 15:25
@knqiufan knqiufan changed the title DSH handoff: add the Codex Desktop adapter feat(dsh): add the Codex Desktop handoff adapter Nov 14, 2026
@knqiufan
knqiufan marked this pull request as ready for review November 14, 2026 15:32
}

/** Qualification is supplied by the integrator; local probing alone is never qualification. */
export function createCodexDesktopAdapter(options: CodexDesktopAdapterOptions): TargetAdapter {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Wire the adapter into the shipped Host

Neither new adapter module has a production import: apply() still calls registerHandoffBridge(ctx, runtime) with its empty adapter default, so the release bundle omits the implementation and Codex remains unavailable even for detection. Register the adapter in Host composition and include it in the distributed package while preserving the qualification gate.

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 5011a4b against 413acc3. The default Host wiring issue is fixed. Two reproduced failures remain: an app-server pipe closure can terminate the calling Host process, and catalog reads now require the macOS-only delivery writer lease. Details inline. Native macOS Desktop acceptance was not independently rerun in this Linux review environment.

Comment on lines +117 to +118
child.once('error', fail)
child.once('exit', fail)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Handle errors from the app-server stdin pipe

The child-process error listener does not handle errors emitted by child.stdin. If the app-server closes its input after replying to initialize, the following initialized write emits an unhandled EPIPE; the surrounding async catch never receives it. I reproduced this by calling createCodexDesktopRuntime(...).checkIntegration(...) with a subprocess that replies to initialization and closes fd 0: the calling Node process exits with code 1 instead of returning unknown. In a qualified Host this can terminate DSH during preflight. Route stdin stream errors through the probe failure/cleanup path so an app-server disconnect remains a recoverable check failure.

}
const handler = createHandoffHandler({
facts, requireLocal, catalog, signal: lifetime.signal,
facts, requireLocal, get catalog() { ensureServices(); return catalog! }, signal: lifetime.signal,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep target catalog reads independent of the delivery writer lease

The new catalog getter calls ensureServices(), which invokes the macOS-only lockWriter() even for GET /powercontext/targets. With an authenticated loopback owner-local Web Host (ownerLocal: true, no SSH), the same HTTP probe on Linux returns 200 with 16 targets using the base Host composition, but 403 deployment_unsupported at this head. This removes the existing manual/setup/export catalog on platforms where native launch is unavailable; it also makes listing targets contend for the global delivery writer lock. Keep catalog/detection initialization separate from mutable delivery services so read-only discovery does not require a native-launch lease.

@hidb4ai
hidb4ai merged commit 294d857 into codex/dsh-handoff-receipts Nov 16, 2026
1 check passed
@hidb4ai hidb4ai added the 1.6.0 v1.6.0 release tracking label Nov 18, 2026
hidb4ai pushed a commit that referenced this pull request Nov 18, 2026
* feat(dsh): verify and recover exact handoff receipts

* test(desktop): qualify the receipt API contract

* fix(dsh): declare handoff connection identity tools

* feat(dsh): add the Codex Desktop handoff adapter (#2652)

* feat(dsh): add the Codex Desktop handoff adapter

* fix(dsh): ship Codex Desktop diagnostics in the default Host

* fix(dsh): recover Codex probes and isolate target discovery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6.0 v1.6.0 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants