Files
codex/codex-rs/cloud-client
Benjamin Carlsson 7ee5efad4a Add typed item lifecycle events to the cloud client (#59066)
## What changed

Decode live item start and completion notifications as `TranscriptUpdate::ItemStarted` and `TranscriptUpdate::ItemCompleted`, with turn identity, lifecycle timestamps, and summaries for user messages, agent messages, reasoning, commands, and file changes.

Preserve structured agent questions even when message text is empty, optional command output and exit details, and command or patch status independently of lifecycle completion. Keep unsupported or incomplete items as opaque notifications and redact summary fields in debug output.

## Testing

Add fixtures covering lifecycle ordering alongside deltas, identity and timestamps, status and optional-field preservation, structured questions, opaque fallback, malformed payloads, thread ownership, and debug redaction.

GitOrigin-RevId: d6bf2d25ee85be17d895726c5072850a9851b55f
2026-11-03 05:43:27 +00:00
..

Codex cloud client

Reusable Rust client for native ThreadService gRPC over HTTP/2, with no TUI, conventional app-server or private monorepo dependency. This slice supports Resume and live Attach. It does not use the HTTP /grpc JSON gateway.

The caller supplies a trusted native gRPC origin (scheme/host/port, no path), ChatGPT bearer token, selected account ID and configured HttpClientFactory. HTTPS is required except for direct loopback HTTP with an unrestricted, unmanaged factory. This exception bypasses proxies to keep plaintext credentials local. For HTTPS, the shared HTTP client supplies proxy, custom CA and network policy handling; redirects are rejected. Tonic supplies gRPC framing, protobuf encoding, message bounds (64 MiB) and status/trailer handling. Bind factory policy before loading credentials; rebuild on login/account changes.

ResumeRequest.wait = false acknowledges admission, not readiness. Requests are never retried by this crate: a timeout or disconnect can leave work admitted. Attach has no history snapshot or replay guarantee. Dropping it detaches without stopping the thread or answering approvals. Streams end after their first error. Resume and Attach setup have a 150-second local deadline; live streams have no idle deadline. Setup does not send a gRPC deadline that would expire a healthy stream.

Event::Transcript decodes selected text, command output, patch, and turn updates. It validates the thread ID and exposes the decoded fields. Turn updates include start time, completion time, and duration when the server provides them. Other notifications and server requests remain opaque protobuf payloads, preserving unknown fields. These are not ProtoJSON or app-server JSON-RPC. Native status code, message and binary details are available explicitly; credentials, event and error diagnostics are redacted. Item lifecycle updates report supported message, command, and file-change summaries. Agent message summaries retain structured questions even when their text is empty. Unsupported item kinds stay opaque. History, approval replies and reconnect are subsequent slices. The minimal envelopes in wire.rs and ResumeRequest mirror ThreadService field numbers; no monorepo checkout or protobuf compiler is required to build this crate.

Provide CODEX_CLOUD_ACCESS_TOKEN and CODEX_CLOUD_ACCOUNT_ID through your environment, then run this standalone consumer from codex-rs:

cargo run -p codex-cloud-client --example attach -- "$CODEX_CLOUD_GRPC_ENDPOINT" "$CODEX_CLOUD_THREAD_ID"

Use an existing authorized thread and native gRPC origin. No production URL is assumed. Public native ingress is a rollout assumption, not proved by fixture tests. This change does not publish a package to a registry.