paperclip/packages/shared/src
Nicky Leach e5a7fd7038
Add sandbox device-login for the Codex adapter (#11237)
## Thinking Path

> - Paperclip helps people manage AI agents for work.
> - Agent adapters connect Paperclip to tools such as the Codex command
line tool.
> - A sandboxed Codex agent may start without a credential.
> - The operator needs a safe sign-in flow that does not expose
credentials to the shared package or the sandbox.
> - This pull request adds a company-scoped device-login flow with a
temporary Daytona sandbox.
> - The flow promotes the credential only after readiness checks pass
and removes the temporary sandbox after use.
> - The result lets an operator sign in to a sandboxed Codex agent from
the agent form.

## Linked Issues or Issue Description

**Subsystem affected**

Cross-cutting (multiple of the above)

**Problem or motivation**

A Codex adapter that runs in a sandbox cannot authenticate when the
company has no pre-provisioned Codex credential.

**Proposed solution**

Add a company-scoped device-login session. Start a temporary sandbox,
run `codex login --device-auth`, stream the code and URL, verify
readiness, promote the credential, and delete the sandbox.

**Alternatives considered**

Pre-provisioning a credential does not support first-time sandbox login.
Keeping the credential in the login sandbox does not provide a durable
company credential.

**Roadmap alignment**

This supports the roadmap item for cloud and sandbox agents.

**Additional context**

The flow uses a five-minute cleanup reaper, compare-and-set status
changes, and a PostgreSQL advisory lock to protect promotion and
cleanup.

## What Changed

- Add the adapter login-session contract, database table, and migration.
- Add company-scoped server routes and a service for sandbox device
login.
- Add credential promotion, readiness checks, and cleanup after login.
- Add restart-safe cleanup for abandoned login sandboxes.
- Add sandbox login controls to the agent creation and edit forms.
- Keep device-login and vendor identifiers out of public shared and
adapter UI symbols.

## Verification

- `pnpm --filter @paperclipai/adapter-codex-local exec vitest run`
passed with 310 tests at the submitted commit.
- The server login route, service, and reaper tests passed with 45 tests
at the submitted commit.
- The agent form render tests passed with 26 tests at the submitted
commit.
- The public-symbol leak check passed at the submitted commit.
- A live Daytona sign-in flow still requires confirmation by a user with
a live sandbox.

## Risks

The migration adds a new company-scoped table. A promotion or cleanup
race could remove a credential or leave a sandbox active, so the service
uses claims, compare-and-set transitions, and an advisory lock. The live
Daytona flow needs operator confirmation because local tests do not
provide a real browser sign-in.

## Model Used

OpenAI Codex, GPT-5, tool use and code execution, extended reasoning.

## Checklist

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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-08-12 08:58:25 -07:00
..
app-definitions feat(apps): connect Notion through MCP OAuth (#11009) 2026-08-06 22:18:08 -05:00
telemetry feat(observability): rename sandbox provider spans and add run-time wrapper spans (#10999) 2026-08-06 22:31:15 -07:00
types Add sandbox device-login for the Codex adapter (#11237) 2026-08-12 08:58:25 -07:00
validators Add sandbox device-login for the Codex adapter (#11237) 2026-08-12 08:58:25 -07:00
adapter-agnostic-keys.test.ts fix: deduplicate adapter-agnostic config keys (#9058) 2026-07-05 21:47:38 -07:00
adapter-auth-session.ts Add sandbox device-login for the Codex adapter (#11237) 2026-08-12 08:58:25 -07:00
adapter-type.ts feat(adapters): external adapter plugin system with dynamic UI parser 2026-04-03 21:11:20 +01:00
adapter-types.test.ts [codex] Split backend control-plane QoL slice (#4700) 2026-04-28 16:46:45 -05:00
agent-eligibility.test.ts feat(agents): warn when an agent's escalation path routes to a paused manager (#10657) 2026-08-01 17:42:42 -07:00
agent-eligibility.ts feat(agents): warn when an agent's escalation path routes to a paused manager (#10657) 2026-08-01 17:42:42 -07:00
agent-url-key.ts feat: company portability — export/import companies and agents 2026-03-02 09:06:58 -06:00
api.ts feat: maintained in_review review-path contract + stalled-review actions (#10675) 2026-08-04 13:54:40 -05:00
app-definitions-url.test.ts feat(connections): add AppDefinition Wave 1 catalog (#9981) 2026-07-21 15:57:12 -05:00
app-definitions.generated.ts feat(connections): add AppDefinition Wave 1 catalog (#9981) 2026-07-21 15:57:12 -05:00
app-definitions.ingestion-report.json feat(connections): add AppDefinition Wave 1 catalog (#9981) 2026-07-21 15:57:12 -05:00
app-definitions.test.ts feat(apps): connect Notion through MCP OAuth (#11009) 2026-08-06 22:18:08 -05:00
app-definitions.ts feat(connections): add AppDefinition Wave 1 catalog (#9981) 2026-07-21 15:57:12 -05:00
company-import-transfer.ts feat(server): chunked resumable company import transfers (#11223) 2026-08-11 15:25:07 -07:00
config-schema.test.ts fix(config): preserve extensions and guard invalid repairs (#11005) 2026-08-07 00:41:19 -05:00
config-schema.ts fix(config): preserve extensions and guard invalid repairs (#11005) 2026-08-07 00:41:19 -05:00
constants.ts feat: make chat-style tasks the default experience (#11101) 2026-08-11 09:06:21 -07:00
decision.test.ts feat(decisions): add first-class propose mode (#10010) 2026-07-31 19:17:02 -07:00
document-anchors.test.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
document-anchors.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
env-file.test.ts fix(config): preserve env files during managed updates (#10980) 2026-08-07 00:54:43 -05:00
env-file.ts fix(config): preserve env files during managed updates (#10980) 2026-08-07 00:54:43 -05:00
environment-custom-images.test.ts Add browser SSH terminal for custom image setup (#8911) 2026-07-03 16:44:21 -07:00
environment-custom-images.ts Add browser SSH terminal for custom image setup (#8911) 2026-07-03 16:44:21 -07:00
environment-support.test.ts Enable sandbox environments for Grok local adapter (#9338) 2026-07-09 20:46:46 -07:00
environment-support.ts Enable sandbox environments for Grok local adapter (#9338) 2026-07-09 20:46:46 -07:00
execution-workspace-guards.ts Guard closed isolated workspaces on issues 2026-04-04 17:48:54 -05:00
external-objects-server.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
external-objects.test.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
external-objects.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
feature-catalog.test.ts Add a feature catalog build artifact derived from the experimental settings schema (#10055) 2026-07-22 18:12:56 -07:00
feature-catalog.ts Let tenants edit env vars on managed sandbox environments; add managed-sandbox-only mode (#11200) 2026-08-11 11:40:57 -07:00
frontmatter.test.ts Skill Studio: three-pane skill IDE with sandboxed test runs (#9241) 2026-07-09 13:08:56 -05:00
frontmatter.ts Skill Studio: three-pane skill IDE with sandboxed test runs (#9241) 2026-07-09 13:08:56 -05:00
gitignore-runtime.test.ts chore: ignore materialized Paperclip runtime directory 2026-07-08 17:59:43 -07:00
home-paths.test.ts [codex] Add LLM Wiki plugin host support (#5597) 2026-05-10 07:34:12 -05:00
home-paths.ts [codex] Add LLM Wiki plugin host support (#5597) 2026-05-10 07:34:12 -05:00
humanize-connection.test.ts feat(mcp) [split 2/8]: add governed access contracts (#9557) 2026-07-14 12:57:20 -05:00
humanize-connection.ts feat(mcp) [split 2/8]: add governed access contracts (#9557) 2026-07-14 12:57:20 -05:00
index.ts Add sandbox device-login for the Codex adapter (#11237) 2026-08-12 08:58:25 -07:00
issue-attribution.test.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
issue-attribution.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
issue-references.test.ts Fix Cloud tenant issue identifier routes (#5196) 2026-05-04 13:20:58 -05:00
issue-references.ts Fix Cloud tenant issue identifier routes (#5196) 2026-05-04 13:20:58 -05:00
issue-thread-interactions.test.ts feat(decisions): improve desk triage and queue parity (#10785) 2026-08-03 21:31:45 -05:00
issue-write-denial.test.ts feat(issues): explain cross-task agent writes with attribution, audit receipts, and actionable denials (#10843) 2026-08-04 23:02:51 -05:00
issue-write-denial.ts feat(issues): explain cross-task agent writes with attribution, audit receipts, and actionable denials (#10843) 2026-08-04 23:02:51 -05:00
network-bind.ts Introduce bind presets for deployment setup 2026-04-11 07:09:07 -05:00
pipeline-case-type.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
pipeline-health.test.ts [codex] Deduplicate pipeline automation health warnings (#9090) 2026-07-06 12:12:18 -05:00
pipeline-health.ts [codex] Deduplicate pipeline automation health warnings (#9090) 2026-07-06 12:12:18 -05:00
portability-fidelity.test.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
portability-fidelity.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
portability-hash.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
portability-zip.test.ts fix(server): raise company import zip upload limit to 1 GB and make it operator-configurable (#11184) 2026-08-10 12:47:03 -07:00
portability-zip.ts fix(server): raise company import zip upload limit to 1 GB and make it operator-configurable (#11184) 2026-08-10 12:47:03 -07:00
project-mentions.test.ts [codex] Roll up May 17 branch changes (#6210) 2026-05-17 17:15:06 -05:00
project-mentions.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
project-url-key.ts fix: append short UUID suffix to project slugs when non-ASCII characters are stripped to prevent slug collisions 2026-03-31 16:35:30 +00:00
resource-memberships.test.ts feat(server): add per-user document stars (#9952) 2026-07-27 19:13:35 -05:00
responsible-user-denial.test.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
responsible-user-denial.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
routine-variables.test.ts feat(routines): add date variable controls (#8655) 2026-06-26 12:00:16 -05:00
routine-variables.ts feat(routines): add date variable controls (#8655) 2026-06-26 12:00:16 -05:00
summary-slot.test.ts fix: isolate execution workspace summaries (#10790) 2026-08-11 08:56:32 -04:00
trust-policy.ts fix(auth): clarify protected-agent assignment blocks (#10893) 2026-08-05 10:09:17 -05:00
work-product.test.ts Add workspace file viewer and artifact links (#7681) 2026-06-09 17:17:43 -05:00
workspace-commands.test.ts [codex] Improve workspace navigation and runtime UI (#4089) 2026-04-20 06:14:32 -05:00
workspace-commands.ts [codex] Improve workspace navigation and runtime UI (#4089) 2026-04-20 06:14:32 -05:00
workspace-file-resource.test.ts fix(files): only highlight accessible workspace file links (#11090) 2026-08-11 12:11:45 -04:00