Skip to content

feat(adapter-codex-local): prove Codex device login inside a Daytona sandbox - #11097

Open
nickyleach wants to merge 5 commits into
masterfrom
feat/codex-sandbox-device-login-proof
Open

feat(adapter-codex-local): prove Codex device login inside a Daytona sandbox#11097
nickyleach wants to merge 5 commits into
masterfrom
feat/codex-sandbox-device-login-proof

Conversation

@nickyleach

@nickyleach nickyleach commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Thinking Path

  • Paperclip is the open source app people use to manage AI agents for work
  • Paperclip uses adapters to connect agents to local and remote runtimes
  • The Codex local adapter needs a safe way to prove device login in a remote sandbox
  • A proof must protect login data, isolate credentials, and clean up sandbox resources
  • This pull request adds a parser, runner, credential export, and Daytona proof CLI
  • The benefit is a repeatable proof path for Codex device login inside a Daytona sandbox

Linked Issues or Issue Description

Agent or provider

Codex local adapter with Daytona sandbox support.

Why this adapter is useful

Paperclip can prove Codex device login in a remote sandbox. The flow supports secure credential setup without exposing login data to logs or persistent shared paths.

How the agent is invoked

The proof CLI uses the Daytona SDK. It runs Codex device login in one sandbox, exports the credential to a private run-scoped home, and verifies the credential in a second sandbox.

Additional context

The parser accepts only the OpenAI device-login origin and path. The runner handles timeout and cancellation. The export step uses strict path, payload, and file-mode checks. The CLI writes the login URL and code only to the controlling terminal.

What Changed

  • Add a pure parser for the Codex device-login URL and one-time code.
  • Add a sandbox runner with timeout, cancellation, prompt, and disposal handling.
  • Add a private credential export step with run-scoped cleanup and directory locking.
  • Add a Daytona proof CLI that verifies the credential in a second sandbox.
  • Add unit tests and fixture files for parser, runner, and export behavior.

Verification

  • Run pnpm --filter @paperclipai/adapter-codex-local exec vitest run.
  • Run pnpm --filter @paperclipai/adapter-codex-local exec tsc --noEmit.
  • Review the tests for secret redaction, strict validation, cleanup, timeout, cancellation, and file modes.
  • Run the proof CLI with @daytonaio/sdk@0.203.0 or PAPERCLIP_DAYTONA_SDK_MODULE set.

Risks

  • The live proof requires a Daytona account and the Daytona SDK.
  • The proof creates remote sandboxes and deletes them during cleanup.
  • The proof writes a credential only to a private, run-scoped home.
  • The change adds a dynamic SDK import and does not add the Daytona SDK to the adapter package.
  • The pull request includes a lockfile change for local development dependencies. CI owns lockfile regeneration, so this item needs CI review.

Model Used

Codex, GPT-5, tool use, code execution, and repository review. The exact model context window and reasoning mode are controlled by the Paperclip runtime.

Checklist

  • I have included a thinking path that traces from project context to this change
  • I have specified the model used (with version and capability details)
  • I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work
  • I have searched GitHub for duplicate or related PRs and linked them above
  • I have either (a) linked existing issues with Fixes: / Closes: / Refs: OR (b) described the issue in-PR following the relevant issue template
  • I have not referenced internal/instance-local Paperclip issues or links
  • My branch name describes the change and contains no internal Paperclip ticket id or instance-derived details
  • I have run tests locally and they pass
  • I have added or updated tests where applicable
  • I have updated relevant documentation to reflect my changes
  • I have considered and documented any risks above
  • All Paperclip CI gates are green
  • Greptile is 5/5 with no open P2s, recommendations, or follow-ups
  • I will address all Greptile and reviewer comments before requesting merge

nickyleach and others added 3 commits August 8, 2026 15:19
Parse the Codex device-login output for the login URL and the one-time code.
Accept only the exact origin and path https://auth.openai.com/codex/device and
reject any query or fragment. Accept only the XXXX-XXXXX code structure. Keep the
URL and the code out of every log and every thrown error. Add redacted, real
sample fixtures from the capture step and table-driven tests.

Co-authored-by: Paperclip <noreply@paperclip.ing>
Run the Codex device-login command through an injected SandboxLoginDriver.
Surface the parsed prompt one time in memory and read the credential one time on
success. Handle a timeout and a cancellation, and always dispose the driver.
Parse the stream in an in-memory buffer only; never forward, retain, or log the
raw text, and keep the URL, the code, and any token out of every log line, the
result, and every thrown error.

Co-authored-by: Paperclip <noreply@paperclip.ing>
Install the sandbox credential into a unique, run-scoped, private proof home
under a company-scoped root. Reject the default, shared, and managed homes,
reject a symlink or a non-regular path, and reject an API-key, malformed, or
oversized payload before any write. Create the root and the home at mode 0700 and
stage auth.json at mode 0600 under a directory lock. Seed an empty home and
delegate a strictly-newer, same-identity update to the reused copy-back helper.
Add removeProofHome for the cleanup step. Never log token bytes.

Co-authored-by: Paperclip <noreply@paperclip.ing>
@commitperclip

commitperclip Bot commented Aug 8, 2026

Copy link
Copy Markdown

✅ All checks passing — ready for Greptile review and maintainer approval.

— commitperclip

@nickyleach

Copy link
Copy Markdown
Contributor Author

The PR body now contains the required issue description and deduplication checklist. CI still needs a code-owner update: remove pnpm-lock.yaml from this PR, re-push feat/codex-sandbox-device-login-proof, and rerun the checks. The verify and e2e failures result from skipped dependent jobs.

Wire the Daytona SDK to the injected SandboxLoginDriver and prove the device
login end to end. Require a Daytona environment id argument and fail loud when it
is absent, when no controlling terminal exists, or when the environment provider
is not daytona. Stream the login output in memory through a non-persisting exec
path, write the URL and the code only to the controlling terminal, install the
credential into a run-scoped proof home, and run a second sandbox that uses the
saved credential. Delete the proof home and every sandbox in a finally block on
every terminal path.

Resolve the environment record through the workspace database client (a
devDependency). Load the Daytona SDK through a dynamic import against a local
interface, so the adapter never declares the heavy SDK dependency; a live run
installs @daytonaio/sdk or sets PAPERCLIP_DAYTONA_SDK_MODULE.

Co-authored-by: Paperclip <noreply@paperclip.ing>
@nickyleach
nickyleach force-pushed the feat/codex-sandbox-device-login-proof branch from 7f3fa42 to 2fe4e6d Compare August 8, 2026 17:06
@nickyleach

Copy link
Copy Markdown
Contributor Author

@greptile review

Remove the development-only device-login proof script and its only two
devDependencies (@paperclipai/db and drizzle-orm). No production file
imports these packages, so the adapter no longer declares a data-store
dependency. This change is subtractive; it reduces the adapter surface.

Keep the production primitives: the parser, the runner, the export, their
tests, and the fixtures.

Co-authored-by: Paperclip <noreply@paperclip.ing>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant