mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 10:07:24 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Sandboxed runs wrap `git` and `gh` with broker launchers so agents do not inherit ambient host credentials, and task feeds use `connection_intent` cards to let users connect services inline. > - When a workspace has no GitHub connection configured, anonymous sandbox launchers logged `Paperclip: GitHub capability_missing; continuing without managed credentials.` on every `git` or `gh` call, and failed local `gh --version`/`--help` commands. > - In addition, when an agent tried to clone a private GitHub repository, push to GitHub, or run `gh` without a GitHub connection configured, the task feed did not prompt the user with a GitHub connection card. > - Both issues hurt first-run clarity: noisy `capability_missing` warnings look like broken infrastructure, while unconfigured git auth failures leave users without an inline path to connect GitHub. > - This pull request marks intentional anonymous sandbox launchers silent, treats local `gh` version/help commands as local, and automatically attaches a `github` `connection_intent` card in the task feed when a run hits an unambiguous unconfigured GitHub auth failure. > - The benefit is clean anonymous git/gh execution and a one-click inline GitHub setup card when a task needs private GitHub access. ## Linked Issues or Issue Description **What happened?** In sandboxes without a GitHub connection configured, running `git` (such as `git --version` or public clones) logged `Paperclip: GitHub capability_missing; continuing without managed credentials.` and `gh --version` / `gh --help` attempted broker resolution. When an agent tried an authenticated GitHub operation (such as cloning a private repository, pushing, or running `gh`), the run failed or reported the auth error without showing a GitHub connection card in the task feed. **Expected behavior** Anonymous unconfigured sandbox launchers should run public/local `git` and local `gh` commands silently without emitting `capability_missing` warnings, while keeping `capability_missing` diagnostics for genuinely missing or failed-bridge broker configs. When an agent hits an unconfigured GitHub authentication failure during a task run or workspace clone, Paperclip should attach a `github` connection card in the task feed and mark run liveness as blocked waiting for the user. **Steps to reproduce** 1. Run an agent in a sandbox with no GitHub connection configured. 2. Execute `git --version`, `gh --version`, and `git clone https://github.com/<org>/<private-repo>.git`. 3. Observe `Paperclip: GitHub capability_missing; continuing without managed credentials.` on stdout/stderr and no GitHub connection card in the task feed after the private clone fails. **Paperclip version or commit** `a0d5f275af` (`master`) **Deployment mode** Other (sandboxed Paperclip Runner and local server) ## What Changed - Added explicit `anonymous` mode to GitHub broker launchers (`packages/adapter-utils/src/github-launcher.ts`, `packages/adapter-utils/src/execution-target.ts`, `server/src/services/heartbeat-github-launchers.ts`) and supported `"anonymous": true` in `broker.json` so intentionally unconfigured sandboxes stay quiet while missing/broken broker bridges still emit `capability_missing`. - Treated local `gh` commands (`--version`, `--help`, `-h`, `version`, `help`) as local in the `gh` launcher without contacting the credential broker. - Added `server/src/services/git-auth-connection-detection.ts` to detect unambiguous `github.com` auth failures in failed command execution events (`tool.execution.completed` and `item.completed`) and structured workspace clone failures while ignoring `exitCode === 0`, assistant prose, non-GitHub remotes, transient 5xx errors, and local non-auth git errors. - Added controller-only `connectionIntentService(db).requestForRunGitHubAuthFailure(runId, resultJsonOverride?)` in `server/src/services/connection-intents.ts` (with `completed_git_auth` run-context mode) to create a `github` `connection_intent` card in the task feed when GitHub is not already configured/usable, skipping `host` auth mode, closed tasks, non-latest runs, existing pending cards, and declined continuations. - Wired `requestForRunGitHubAuthFailure` into `classifyAndPersistRunLiveness` (`server/src/services/heartbeat/run-lifecycle.ts`) and added `githubConnectionRequested` support to `classifyRunLiveness` (`server/src/services/run-liveness.ts`) to classify the run as `blocked` (`Waiting for GitHub connection`). - Added unit and embedded-Postgres integration tests in `packages/adapter-utils/src/github-launcher.test.ts`, `server/src/services/heartbeat-github-launchers.test.ts`, and `server/src/__tests__/github-connection-auto-request.test.ts`. ## Verification - `pnpm vitest run packages/adapter-utils/src/github-launcher.test.ts` (41/41 passed) - `pnpm vitest run packages/adapter-utils/src/github-launcher-environment.test.ts --testTimeout=15000` (40 passed, 1 skipped) - `pnpm vitest run server/src/services/heartbeat-github-launchers.test.ts server/src/services/native-runtime/native-github-access.test.ts` (passed) - `pnpm vitest run server/src/__tests__/github-connection-auto-request.test.ts server/src/__tests__/connection-intents-service.test.ts server/src/__tests__/ai-auth-failure.test.ts server/src/services/heartbeat/run-comment-selection.test.ts` (86/86 passed) - `pnpm vitest run server/src/__tests__/run-liveness.test.ts` (21/21 passed) - `pnpm vitest run server/src/__tests__/heartbeat-process-recovery.test.ts -t "clone|connection|GitHub"` (6/6 passed) - `pnpm --filter @paperclipai/adapter-utils typecheck && pnpm --filter @paperclipai/server typecheck` (0 errors) ## Risks - Low risk. No database migrations or UI schema changes are required; the auto-created card reuses the existing `connection_intent` interaction kind (`serviceSlug: "github"`). - False-positive card creation is guarded by strict `github.com` host matching, non-zero command exit requirements, `githubAuthenticationMode !== "host"`, active-identity checks (`usableConnectionForAgent` and `resolveManagedGitHubIdentitySelection`), idempotent pending-card checks, and decline respect. ## Model Used - Google Gemini (Antigravity agent) with tool use and local code/test execution. ## 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