mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 01:24:30 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Onboarding connects the first agent to an AI provider account, often with a Claude or Codex subscription sign-in > - A plugin can manage an execution environment whose driver declares `supportsLoginPty` and `requiresAgent`. Each agent's lifecycle prepares that environment for the agent, and the sign-in runs in it > - An instance can make such a plugin-managed execution environment its default > - The onboarding wizard offered browser sign-in only in a sandbox-driver environment, so it blocked the connect step in every plugin-managed execution environment > - The sign-in also cannot start until the agent's lifecycle has prepared the environment > - This pull request lets onboarding and the new-agent flow sign in through a plugin-managed execution environment, after the environment is prepared for the agent > - The benefit is that subscription sign-in works when the default environment is plugin-managed ## Linked Issues or Issue Description Refs #22695 and #20906. **What happened?** The default environment is a plugin-managed execution environment whose driver declares `supportsLoginPty`. A user starts onboarding and chooses Claude or Codex with a subscription. The connect step shows "This environment does not support browser sign-in. Go back to use an API key or choose another model." Connect stays disabled. **What did you expect to happen?** The connect step starts a browser sign-in in the plugin-managed execution environment for the onboarding agent. The agent configuration form and the AI Connections page already do this for plugin-managed environments. **Steps to reproduce** 1. Install an environment plugin with a `requiresAgent` driver that declares `supportsLoginPty`, and make its environment the instance default. 2. Start onboarding for a new company. 3. Choose Claude or Codex, and keep the subscription option. 4. See the message above. Connect is disabled. ## What Changed - The onboarding wizard and the new-agent flow use the shared `environmentSupportsLoginPty` rule. Before, both flows had their own sandbox-only check. - In a plugin-managed execution environment, onboarding sends the sign-in to its own setup agent (`requiresAgent` and `agentId` on `AdapterLoginPanel`). The new-agent flow does the same with its draft agent. - Onboarding polls the setup agent until the environment can take the sign-in for it: a Paperclip runner agent on the login environment in `verifying` or `ready`. Until then the step shows "Preparing your agent's computer…", the user-facing name for this environment. A failed preparation shows the error and a "Retry preparation" button. A failed agent read shows "Could not check your agent's computer." and retries the read. - The new-agent flow keeps the login panel unmounted until the environment is prepared (`loginHostPending` on `AgentProviderConnection`). The panel starts the sign-in on mount, and the disabled fieldset does not stop that. - Both flows latch the readiness per agent and environment (`useAgentComputerLoginReady`). A configuration change sends the setup draft through preparation again. That must not unmount a sign-in that is already on screen. - The auth-signal route now accepts a plugin-managed execution environment for `claude_local` and `codex_local`, and answers `unknown` there. Before, it returned 422, and the onboarding step stayed undecided and never showed the sign-in. The signal reads only host-local state, which says nothing about a plugin-managed environment. - The new-agent flow now says "Preparing your agent's computer…", the same as onboarding. - Each part of the login PTY question now has one owner: - Shared `environmentLoginRequiresAgent` decides whether a sign-in needs an agent. The four UI flows and the server's login target resolver use it instead of their own `driver === "plugin"` checks. - Shared `isPluginEnvironmentLoginAdapter` and `pluginEnvironmentLoginReadsCredential` decide which adapters sign in through a plugin-managed execution environment, and which of them must read the credential back. `environmentSupportsLoginPty` and the server's login target resolver use them. The server's capability resolver takes the adapter type instead of a credential-read flag. - `sandboxProviderSupportsLoginPty` decides sandbox-provider support for both the capability listing and the sign-in check. - The credential read uses `pluginSupportsLoginPty`, like the rest of the plugin login path. Before, it checked only the manifest flag and the read method. - The agent configuration form's gate is now the shared rule plus "not in create mode when an agent is required". Its duplicate driver check and an always-true condition are gone. ## Verification - `pnpm typecheck` in `ui/` and `server/`: no errors. - `npx vitest run src/lib/agent-computer-login.test.ts src/lib/agent-computer-login.hook.test.tsx src/components/new-agent/AgentProviderConnection.computer-login.test.tsx src/components/new-agent/AgentProviderConnection.test.tsx` in `ui/`: tests pass. The `AgentProviderConnection` sign-in test covers a slow preparation, and the readiness hook test covers a re-preparation of the same environment. - `npx vitest run src/__tests__/adapter-auth-signal-routes.test.ts` in `server/`: tests pass. The two new plugin-managed environment cases fail without the route change. - `pnpm typecheck` in `packages/shared/`: no errors. `npx vitest run src/environment-support.test.ts` in `packages/shared/`: 9 tests pass. - In `server/`: the device-login, setup-token, login-session runtime, sandbox-capability, credential-read and OpenAPI route suites pass (159 tests). A new credential-read case refuses a driver that does not meet the plugin login rule. - In `ui/`: the `AgentConfigForm`, `AgentProviderConnection`, `agent-computer-login` and onboarding analytics suites pass. - I did not do a live onboarding with a real plugin-managed execution environment. Reviewers who have such an instance can reproduce with the steps above. Expect "Preparing your agent's computer…", then the provider sign-in, then the hire. ## Risks - Onboarding waits for the environment's preparation before a subscription sign-in in a plugin-managed execution environment. A slow preparation makes the connect step wait for that time. An API key or a saved subscription does not wait. - The latch keeps the sign-in on screen while a configuration change prepares the same environment again. If the plugin refuses the sign-in in that window, the sign-in panel shows its usual error and retry. - The setup draft must resolve to the Paperclip runner in the plugin-managed environment. If it does not, the step stays on "Preparing your agent's computer…". Plugin-managed environments run only the Paperclip runner, so this is not expected. - No migration and no API contract change. The auth-signal route accepts one more environment driver. - The credential read now requires the full plugin login rule (`creationOperationVersion` 1 and every login worker method). A plugin that reaches the credential read already passed that rule when its login lease was acquired, so no working plugin should change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), with extended thinking and tool use (code search, shell, tests) in Claude Code. ## 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 - [ ] 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>