mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
d884e4e8778aa7b34b9708b3926a6b4e3c676dab
8775
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d884e4e877 |
fix(test): leave the claim token hash out of the recovery lock comparison (#23413)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Each master commit gets a Docker image. The image build first waits for the full test suite on that exact commit, and it stops if a test fails > - #23382 added a `claimTokenHash` column to issues. The issue service removes this column from the rows it returns, so that the hash never leaves the server > - Four tests in `issue-recovery-actions.test.ts` compare the row from `issuesSvc.update` with the full database row. The full row has `claimTokenHash`, so the comparison fails > - These tests fail on every master commit since #23382, so no master image was published after that commit > - This pull request removes `claimTokenHash` from the database row before the comparison > - The benefit is that master images build again, and the tests also make sure that the service row does not have the hash ## Linked Issues or Issue Description No public issue exists. **What happened?** After #23382 merged, the full server test suite fails on master in `issue-recovery-actions.test.ts`. The four "preserves a concurrent … decision when stale stranded recovery waits for the issue lock" tests fail with `expected { …(86) } to match object { …(83) }`, and the diff shows only `"claimTokenHash": null`. The master image build stops on this failure, so master commits after #23382 have no image. **Expected behavior** The tests pass. The service row and the database row agree on every column that the service returns. **Steps to reproduce** 1. Check out `master` atcanary/v2026.1201.0-canary.877500 |
||
|
|
c0edaa21a3 |
feat(analytics): move onboarding funnel telemetry server-side and add granular step instrumentation (#23403)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Hosted Paperclip Cloud tracks user onboarding conversion in PostHog
across server-side events and browser events
> - Onboarding funnel events (`onboarding_opened`,
`onboarding_step_viewed`, `onboarding_step_completed`,
`onboarding_step_failed`, `onboarding_dismissed`) currently fire only
from browser `posthog-js`
> - Browser `posthog-js` loads lazily after `whenPageSettles` (up to 15
seconds), drops events captured before `startProductAnalytics`
initializes, and can be blocked by privacy extensions, causing
artificial dropoff between server-side `workspace_entry` and
`onboarding_opened`
> - Step 1 (`name_org`) is unmapped in `WIZARD_STEPS`, and
`connect_model` lacks sub-step visibility (provider selection,
credential mode switch, OAuth progress, API key submission, Cloud trial
CTA, mobile handoff)
> - This pull request routes all onboarding funnel events through a
first-party `POST /api/onboarding/telemetry` endpoint backed by
`trackCloudPostHogEvent` (`posthog-node`), preserves every existing
event name verbatim, adds granular step and sub-step instrumentation,
and fixes the pre-start queue drop in `product-analytics.ts`
> - The benefit is adblocker-proof, race-free server-side onboarding
analytics in PostHog with complete step-by-step dropoff visibility and
zero breaking changes to existing insights
## Linked Issues or Issue Description
**What existing behavior does this improve?**
Cloud onboarding funnel analytics in
`ui/src/lib/analytics/onboarding-analytics.ts`,
`ui/src/lib/analytics/product-analytics.ts`,
`ui/src/components/OnboardingWizard.tsx`, and `server/src/telemetry.ts`.
**Subsystem affected**
Cross-cutting (multiple of the above)
**Current behavior**
Onboarding funnel events fire only from browser `posthog-js`. Events
captured before `ProductAnalyticsGate` calls `startProductAnalytics` are
silently dropped, queued events are lost if the user leaves before
`/_ph/static/array.js` loads, Step 1 (`name_org`) is unmapped, and
`connect_model` sub-steps (OAuth link open, code submit, retry, abandon,
provider tile click, Cloud trial CTA, mobile desktop handoff) are not
instrumented.
**Proposed behavior**
All onboarding funnel and interaction events are sent via
`fetch("/api/onboarding/telemetry", { method: "POST", keepalive: true
})` to a board-authenticated, strictly Zod-validated Express route that
forwards them server-side to PostHog via `trackCloudPostHogEvent`.
Existing event names are preserved verbatim and removed from
`posthog-js` to guarantee a single sender per event. Pre-start browser
events in `product-analytics.ts` are also buffered until
`startProductAnalytics` runs.
**Reason and benefit**
Adblockers and browser script lazy-load races can no longer drop
onboarding funnel events. Product analytics can now separate
`workspace_entry` -> `onboarding_workspace_loaded` ->
`onboarding_opened` and pinpoint exact dropoff points on every step and
`connect_model` sub-step.
**Breaking changes**
None. Existing PostHog event names (`onboarding_opened`,
`onboarding_step_viewed`, `onboarding_step_completed`,
`onboarding_step_failed`, `onboarding_dismissed`,
`agent_chat_message_sent`) are preserved verbatim. On self-hosted
installs, `trackCloudPostHogEvent` is a no-op and the endpoint returns
`204 No Content`.
## What Changed
- Added `packages/shared/src/onboarding-telemetry.ts` (exported from
`packages/shared/src/index.ts`) with strict Zod discriminated-union
schemas (`onboardingTelemetryEventSchema`), canonical event names
(`ONBOARDING_TELEMETRY_EVENTS`), and snake_case PostHog property mapping
(`onboardingTelemetryEventToPostHogProperties`).
- Added `server/src/routes/onboarding-telemetry.ts` (`POST
/api/onboarding/telemetry`), mounted in `server/src/app.ts`, enforcing
`assertBoard(req)`, `assertCompanyAccess(req, companyId)` when
`companyId` is present, strict schema validation, and server-side
delivery via `trackCloudPostHogEvent`.
- Updated `ui/src/lib/analytics/onboarding-analytics.ts` to send all
onboarding events to `/api/onboarding/telemetry` with `keepalive: true`
(removing duplicate browser `posthog-js` sends), mapped Step 1 to
`name_org`, fixed `1 -> 3` forward step completion ordering, and added
granular capture helpers.
- Instrumented `ui/src/hooks/useAgentlessOnboardingAutoOpen.ts`
(`onboarding_workspace_loaded`),
`ui/src/components/onboarding/MobileDesktopNudge.tsx`
(`onboarding_mobile_handoff_action`), and
`ui/src/components/OnboardingWizard.tsx` (all step submissions,
back/jump navigation, Cloud trial CTA, model source selection,
credential mode switching, OAuth progress stages, API key submission,
advanced toggle, and launch click). Note: `OnboardingWizard.tsx` is an
existing large file (>1,000 lines); all schema and transport logic lives
in `packages/shared/src/onboarding-telemetry.ts` and
`ui/src/lib/analytics/onboarding-analytics.ts`, with only call-site
wiring added to the wizard.
- Fixed `ui/src/lib/analytics/product-analytics.ts` to buffer events
captured before `startProductAnalytics` runs (still bounded to 50 events
and cleared on user change).
- Added server route tests in
`server/src/__tests__/onboarding-telemetry-routes.test.ts` and expanded
`ui/src/lib/analytics/onboarding-analytics.test.tsx`.
- Updated `tests/runner-e2e/source-sdk-public-inputs.json` for the new
`@paperclipai/shared` export.
## Verification
- `pnpm --filter @paperclipai/shared build` — passed.
- `pnpm --filter @paperclipai/ui typecheck` — passed.
- `pnpm --filter @paperclipai/server typecheck` — passed.
- `pnpm vitest run
server/src/__tests__/onboarding-telemetry-routes.test.ts
ui/src/lib/analytics/onboarding-analytics.test.tsx
ui/src/lib/analytics/product-analytics.test.ts
ui/src/lib/analytics/product-analytics-events.test.ts
ui/src/components/ProductAnalyticsGate.test.tsx
ui/src/hooks/useAgentlessOnboardingAutoOpen.test.tsx` — 6/6 test files
passed (41/41 tests).
- `pnpm verify` — exited with code 2 because
`tests/runner-e2e/source-sdk-public-inputs.json` requires broad CI
coverage; relying on required CI checks for the remaining broad suites.
## Risks
- Low risk: `POST /api/onboarding/telemetry` performs no database
writes, validates all fields against a strict allowlist (enums,
booleans, bounded integers, safe regex slugs), enforces board auth and
company access, and is a no-op returning `204` on self-hosted instances.
- Browser telemetry calls swallow network failures so analytics can
never block or break onboarding.
## Model Used
- Google Gemini (Gemini 4 Neon, Medium) via Antigravity agentic coding
environment with tool use and local command 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
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
|
||
|
|
689bfd04ac |
feat(onboarding): add free_inference_1 onboarding flow, dual-trigger model gate, and multi-variant PostHog attribution (#23401)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - First-time Cloud users currently must connect an external AI
provider during onboarding before they can talk to their first agent.
> - Requiring provider setup up front adds friction before users
experience their first agent chat.
> - Paperclip needs a multi-variant onboarding experiment
(`onboarding-flow`) that defaults to `baseline` while allowing an
alternate `free_inference_1` path that skips the model-connection screen
and starts with capped starter inference.
> - When a trial-only workspace either exhausts its starter credit or
creates its first executable task or subtask, Paperclip must hold the
new task, prompt the user to connect a model provider, keep LLM actions
blocked if the modal is dismissed, and automatically resume held work
once a model is connected.
> - This pull request adds multi-variant onboarding resolution, PostHog
multi-variant attribution, dual-trigger connect-model gating with
restart-safe DB hydration, the `free_inference_1` UI onboarding flow,
and full-flow Storybooks.
> - The benefit is a safe, measurable onboarding experiment that leaves
`baseline` and self-hosted installs unchanged while letting opted-in
Cloud workspaces reach their first chat immediately and upgrade
seamlessly when real work begins.
## Linked Issues or Issue Description
**Subsystem affected**
Cross-cutting (`packages/shared/`, `server/`, `ui/`)
**Problem or motivation**
New Cloud users currently hit a mandatory "Connect a model" step during
onboarding before they can open their first agent chat. Existing
trial-inference gating only supported a binary flag and only triggered
on starter-credit exhaustion, not on subtask or manual task creation,
and did not track multi-variant onboarding cohorts cleanly in PostHog.
**Proposed solution**
Introduce the extensible `onboarding-flow` experiment (`baseline`
default, `free_inference_1` variant) across shared contracts, server
services, and UI:
- Resolve `onboardingVariant` from the Cloud control plane (`GET
/v1/tenant/onboarding-config`) with safe fallbacks to
`PAPERCLIP_ONBOARDING_VARIANT`, managed config, and `"baseline"`.
- In `free_inference_1`, skip Step 4 ("Connect a model") in
`OnboardingWizard`, hire the first agent on starter inference, and drop
the user straight into the first chat.
- Support a dual-trigger connect-model gate (`exhausted` and
`work_requires_model`) that holds newly created tasks/subtasks on
trial-only workspaces (hydrated from DB across restarts), returns HTTP
402 for blocked LLM chat/runs, keeps the modal dismissible while
blocking chat composers with a "Connect a model" CTA banner, and
automatically resumes held work after provider migration.
- Stamp `$feature/onboarding-flow`, `onboarding_variant`, and immutable
`initial_onboarding_variant` across server PostHog events,
`$groupidentify` (with top-level `$group_set_once`), and browser PostHog
super-properties / `identify()`.
**Alternatives considered**
- Baking per-stack experiment variants into warm-pool container config
was ruled out because warm-pool stacks must remain homogeneous until
claim time.
- Failing agent subtask creation calls on trial-only workspaces was
ruled out because it breaks the agent's first-chat experience; creating
the task in a held state and auto-resuming it after model connection
preserves user intent.
## What Changed
- **`packages/shared`**: Added `onboarding-flow` variant
constants/helpers, `CloudTrialGateReason` (`"exhausted" |
"work_requires_model"`), `CloudTrialHeldIssueSummary`, `gateReason`,
`llmBlocked`, `heldIssueIds`, `heldIssues`, `onboardingVariant`, and
`resumedIssueIds` on cloud-inference and session/browser-analytics
contracts.
- **`server/`**:
- Added Ed25519-signed `GET /v1/tenant/onboarding-config` resolution
with warm-pool claim cache invalidation and safe `"baseline"` default.
- Added dual-trigger trial gating (`exhausted` + `work_requires_model`)
with DB-backed held-issue hydration across restarts, HTTP 402 refusal
for blocked trial runs and chat sends, and automatic wake/resume of held
subtasks upon migration.
- Updated PostHog server telemetry, `$groupidentify` (top-level
`$group_set` and `$group_set_once`), `$feature_flag_called`, and
`BrowserAnalyticsConfig` to stamp `onboarding-flow` multi-variant
properties while preserving backwards-compatible `cloud-trial-inference`
properties.
- Added and updated Vitest suites covering multi-variant resolution,
PostHog attribution, held subtask creation, cold-restart hydration, LLM
run refusal, and auto-resume.
- **`ui/`**:
- Updated `OnboardingWizard` so `free_inference_1` skips Step 4
("Connect a model"), auto-hires with `cloudTrialInference: true`, and
launches straight into the first chat while leaving `baseline`
unchanged.
- Updated `CloudTrialGate` and `CloudTrialExhaustedModal` for
dual-trigger copy (`work_requires_model` vs `exhausted`), waiting
subtask pills, and dismissible modal behavior (`required={false}`).
- Added `CloudTrialBlockedBanner` and wired LLM-blocked composer
disabling + "Connect a model" CTA into `IssueDetail` / `AgentChat` and
`DashboardChatComposer`, plus status refresh on manual task creation in
`NewIssueDialog`.
- Updated `product-analytics.ts` + tests to register
`$feature/onboarding-flow` and `onboarding_variant` super-properties and
`$set_once.initial_onboarding_variant`.
- Added full-flow Storybooks
(`free-inference-onboarding-flow.stories.tsx`) covering all 7 onboarding
and gate states.
## Verification
- `pnpm --filter @paperclipai/shared typecheck && pnpm --filter
@paperclipai/server typecheck` (0 errors)
- `pnpm --filter @paperclipai/ui typecheck` (0 errors)
- 9 targeted server Vitest suites (`cloud-trial-inference`,
`cloud-posthog-config`, `cloud-posthog-browser`,
`posthog-direct-telemetry`, `posthog-direct-transport`, `auth-routes`,
`cloud-runtime-identity`, `onboarding-seed-route`,
`issue-onboarding-first-task-routes`): 196/196 passed
- 4 targeted UI Vitest suites (`CloudTrialGate.test.tsx`,
`product-analytics.test.ts`, `onboarding-analytics.test.tsx`,
`Layout.mobile.test.tsx`): 37/37 passed
- `pnpm --filter @paperclipai/ui build` and `pnpm --filter
@paperclipai/ui build-storybook`: passed
- Visually inspected Storybook renders across all 7 `free_inference_1`
states in headless Chromium via Playwright with zero page errors.
## Risks
- Low risk to existing users: `onboardingVariant` defaults to
`"baseline"` everywhere, leaving self-hosted installs and unflagged
Cloud stacks unchanged.
- No database schema migrations are required; held trial subtasks are
hydrated from existing `issues` and `toolConnections` tables on restart.
- Requires the companion `paperclip-cloud` control-plane endpoint (`GET
/v1/tenant/onboarding-config`) to activate non-baseline variants in
Cloud; falls back safely to `"baseline"` if unavailable.
## Model Used
- Google Gemini (Antigravity agentic coding environment with multi-agent
swarm, tool use, code execution, and Playwright Storybook verification)
## 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
- [ ] 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>
|
||
|
|
b63445c8f1 |
fix(e2e): save hiring task intents at the submit boundary (#23400)
## Thinking Path > - Paperclip manages work by AI agents. > - Its product journeys verify hiring and task delegation through chat. > - Cleanup uses saved creation intents to track possible writes. > - The hiring journey saves each task intent before browser preparation. > - A navigation or editor failure can therefore leave an intent for a request that was never sent. > - This pull request saves the intent after message validation and before Send. > - Cleanup can retain strict write protection without treating failed preparation as a possible task creation. ## Linked Issues or Issue Description **What happened?** The hiring journey can save a review-task intent even when a browser failure stops the third chat request before submission. Cleanup then reports an uncertain creation outcome. A controlled navigation failure reproduces this tracking defect. The original retained browser exception is unavailable; this change does not claim its cause. **Expected behavior** Browser preparation must not register a task write. The creation intent must be saved before submission can create work. A failed intent save must stop submission. A send with a possible committed write must retain the intent. **Steps to reproduce** Inject a navigation failure before the review request after the checklist completes. The original code records the review intent despite making only two sends. The new code preserves the checklist receipt and records no review intent. **Paperclip version or commit** Reproduced from source at `5a9c06b315d9612022908b7fc189f30bac3619af`. **Deployment mode** Linux source checkout, focused workflow tests, and Chromium against the real production composer. The paid hosted acceptance case remains pending until merge. Related earlier hiring coverage and spacing fixes: #18351 and #22825. ## What Changed - Save delegated-task intents through an awaited callback after the exact mention chips are verified and before the browser clicks Send. - Cover failed review navigation, failed intent persistence, rejected mentions, and a send failure after the intent boundary. - Keep handoff references and task name in one typed object. A handoff without its intent name is no longer representable. - Keep the existing ownership, initial assignment, saved-body, seven-run, budget, and cleanup checks. - Document the submission boundary. ## Verification - Red: the new review-navigation regression failed because the old flow saved the review intent without sending that request. - Green: 78 focused flow and evidence tests pass. - All 8 real-composer Chromium checks pass. They cover both composer modes, exact saved messages, failed intent persistence, page loss after persistence, and rejected agent/project mentions. - `pnpm test:e2e:runner:typecheck` passes. - `pnpm verify --explain` could not select checks because the managed Git storage guard rejects `git ls-files`. Even the suggested shallow fetch fails. This unavailable check is not a pass. The source was compared with master through the repository API before publication. - Original head `6914c4b` passed [CI](https://github.com/paperclipai/paperclip/actions/runs/46723605434) and Greptile 5/5 with Low impact. Typecheck, four support shards, six Runner package shards, static checks, and aggregate verification passed. Build was skipped by the test-only path policy. - Review head `cd7b03f36d6d9fcac37cf80906fad2f7cd167958` passes the 78 focused tests, all 8 browser checks, and runner E2E typecheck. Its first browser attempt could not start because the resumed sandbox lacked Chromium; installation restored the check, which then passed. The current head passed [CI](https://github.com/paperclipai/paperclip/actions/runs/46727370488), including Typecheck + Release Registry, four support shards, six Runner package shards, static checks, and aggregate verification. Build is skipped by the test-only path policy. Greptile, Feynman and Ponytail each gave this head 5/5, with Low impact from Greptile. The actionable thread is resolved. Hosted acceptance must run only `hire-delegate-reuse` after merge. ## Risks The callback and Send cannot form one atomic operation. A failure after intent persistence still keeps the intent and the existing uncertain-write protection. This patch does not manufacture absence proof for old retained manifests. The original browser error remains unknown. ## Model Used OpenAI GPT-6 through Codex, with reasoning, shell tools, source editing, and Chromium. The runtime does not expose a more specific backend model revision or context size. ## 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> |
||
|
|
7585830b9c |
fix(opencode): bound cooperative abort before governed shutdown (#23399)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Native Runner saves a question before it stops the provider turn. > - The wait must retain usage and prove shutdown before the run can finish. > - OpenCode's abort HTTP request can hold the command loop for twenty seconds. > - The transport close budget is ten seconds. A late abort can delay definitive stop and suspension beyond that budget. > - This pull request limits the cooperative abort request to five seconds. > - The benefit is time for definitive shutdown, with the same accounting and suspension checks. ## Linked Issues or Issue Description **What happened?** A saved question can be followed by a failed native run. OpenCode's cooperative abort can wait longer than the transport's shutdown budget. The shutdown commands then lack time to prove provider drain and durable suspension. A saved interaction alone cannot prove that the previous executor stopped. **Expected behavior** A stalled cooperative abort must release the command loop in time for definitive process stop. A timeout must still reject interruption. It must not create a terminal event or count as successful accounting. **Steps to reproduce** Start a controlled OpenCode session. Keep its abort HTTP request pending until its signal aborts. Request interruption. Advance the controlled clock by five seconds. On the base code, the request is still pending. With this change, the request rejects and the active turn remains recorded without a terminal event or a new model request. Related prior repairs: #20494, #20519, #20838. They address saved wait recovery. This change addresses the pending cooperative abort before definitive shutdown. ## What Changed - Give only OpenCode's session abort a five-second HTTP deadline through the API helper. Other API requests keep their existing deadline. - Keep timeout errors visible. Keep physical stop, retained usage, and durable suspension proof unchanged. - Add a controlled-clock regression to the existing interruption tests. - Document the deadline and proof requirements in the durable transport contract. - Keep session state and identity formats unchanged. Previous releases' saved state needs no migration. ## Verification - Red: the new regression fails on the base code because the request signal remains active after five seconds. - Green: both interruption test files pass, 13 tests. These include idle, silent, busy-tool, provider-question handoff, pending MCP tool, and the new stalled abort case. - The eight `settles only verified governed shutdown` cases pass. They cover success, restart, foreign turn, missing proof, stop failure, timeout, provider failure, and terminal write failure. - The broader driver run has 99 passes and eight failures. The same driver file with this production change removed has 86 passes and the same eight failures. Those failures concern final-answer retention. They remain a verification gap; this PR does not change their assertions. - No hosted acceptance claim yet. After merge and automatic staging deployment, run only the question-answer-resume journey. - Required CI passed on final commit `45e39805efffbd648bfeca9697c9898593487805`: https://github.com/paperclipai/paperclip/actions/runs/46726627054. This includes typecheck, build, Runner tests, general tests, and E2E suites. - Greptile gives final commit `45e39805e` 5/5, Medium impact. All three review threads are resolved. - After review corrections, both interruption files pass again: 13 tests. The test always restores timers and attempts resource cleanup. The API helper owns the single request deadline. ## Risks - An abort response that needs more than five seconds now fails earlier. Definitive process stop must still prove shutdown. A timeout alone does not authorize session reuse or completion. - The regression uses the real driver and a controlled HTTP boundary. It does not prove hosted suspension timing. The targeted staging journey remains required. - The owning driver file already exceeds 1,000 lines. The change adds only the request deadline and its rationale at the existing abort call. A separate module would add no useful boundary. - There is no schema, saved identity, provider selection, accounting policy, or journey grading change. ## Model Used - OpenAI GPT-6, through Codex with reasoning and tools for source inspection, code editing, and 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 - [ ] 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> |
||
|
|
11d5b06864 |
fix(runner): give a plugin task prepare 60 s without a startup context (#23396)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - An environment plugin can run an agent's Runner on remote compute,
such as a remote computer
> - Before the Runner starts, Core asks the plugin to prepare the task:
its workspace, its home, and the agent's instructions and skills
> - A warm start gets the startup context's deadline for this step. A
cold start has no startup context, so prepare gets the 15 s default for
every plugin task call
> - On a remote computer, a cold prepare often takes 11-16 s. When
several runs start at once, most of them time out
> - The timeout does not stop the work. The plugin finishes it, the run
fails, and its retry repeats the same prepare, which adds load
> - This pull request gives a prepare without a startup context 60 s,
the cold admission budget the Runner gives a Claude session
> - The benefit is that a slow cold start starts late instead of failing
and starting again
## Linked Issues or Issue Description
No public issue exists.
**What happened?**
Agent runs on a plugin-provided remote computer failed at startup with
"Plugin-provided Runner execution operation unavailable; reconcile the
same task before retrying". The plugin's prepare call ran for about 15
s, then Core stopped waiting. The plugin's later host calls for that
task got "Missing or unknown invocation scope". On one agent, about half
of all cold starts failed this way while it worked through a backlog.
Successful cold starts on the same computer took 17 s at the median for
the full Runner startup, so prepare had little margin.
**Expected behavior**
A cold prepare that takes 20 s finishes, and the run starts 20 s later.
**Steps to reproduce**
1. Use an environment plugin that runs Runner tasks on remote compute,
with a cold prepare that takes more than 15 s.
2. Start a run for an agent with no warm task on that computer.
3. See the run fail at startup with the error above, and a new run start
the same prepare again.
**Paperclip version or commit**
`master` at
|
||
|
|
5a9c06b315 |
feat(analytics): make replay work content a deployment opt-in (#22820)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Hosts can enable PostHog browser analytics and session replay through deployment configuration. > - Replay masks work content, which makes task and artifact flows hard to understand. > - Hosts must decide whether their deployment may show this content. > - This pull request adds an explicit deployment opt-in, with work content masked by default. > - Eligible companies can show work content after that opt-in, while connected-account checks and secret masking still apply. ## Linked Issues or Issue Description No public issue exists. This change follows the enhancement template. **What existing behavior does this improve?** Session replay masks task descriptions, document bodies and artifact previews. A host cannot choose to show eligible work content independently of enabling replay. **Subsystem affected** Browser session replay, deployment analytics configuration, and the authenticated session contract. **Current behavior** Work content stays masked in every company. Task and artifact titles already show. PostHog project masking settings cannot override the options supplied by the board UI. **Proposed behavior** Keep work content masked by default. Set `PAPERCLIP_POSTHOG_REPLAY_WORK_CONTENT_ENABLED=1` in deployment configuration to allow it for eligible companies. Unset, `0`, and other values keep it masked. Browser analytics and replay must also be enabled. A host can keep replay enabled while work content stays masked. **Reason and benefit** Hosts control their recording policy without editing Core source. An eligible company's replay can show the task flow after the host opts in. **Breaking changes** None relative to the base branch. Self-hosted analytics remain disabled by the existing analytics gate. Existing deployments retain work-content masking unless they explicitly opt in. The session gains an optional boolean and the tool connection list gains an optional `hiddenCount` field. Missing fields fail closed. ## What Changed - Add `PAPERCLIP_POSTHOG_REPLAY_WORK_CONTENT_ENABLED`, default off. Resolve it in the existing server analytics configuration and send the effective boolean as `browserAnalytics.replayWorkContentEnabled`. The shared session schema preserves the field and accepts older servers that omit it. - Require both replay and the work-content opt-in before the UI queries company sources or permits visibility. Removing the opt-in from a refreshed session masks content even when eligible source answers remain cached. - Preserve the original company checks: complete tool connection and chat endpoint lists, no Google or Slack source, no known aggregator or router, and the selected company's route. Unknown, failed, invalidated, or hidden source data keeps content masked. Live source changes reset the check. - Mark task descriptions, document bodies, attachment and artifact previews, and file viewers as work content. Customer content, editors, comments, chat, run output and connected-account surfaces remain masked. Secrets remain blocked or redacted. Input and attribute values remain masked. - Preserve credential punctuation in task previews by reusing the shared Markdown plain-text helper. Bound conversion to the first 2,048 source characters, and always mask source-capped previews to protect incomplete credentials. Scan complete command-line flag names once before classifying secrets and reading their values. A 512 KiB hyphen input and long flag names have regression coverage. - Mask surfaces that show cut or rewritten work content, where the redaction cannot work. A cut task preview masks when the text before its 180-character limit holds a credential. The document card preview (first 4,000 characters) masks when the cut changes what the redaction masks before it. The text preview on an artifact card always masks, because the server strips hyphens and underscores from it and cuts it at 280 characters. Quoted flag values run past escaped quotes, and flag names can hold an underscore. An unquoted token that starts with `--` is read as the next flag, not as a value, so `--auth --tlsCertificateKeyFilePassword hunter2` masks `hunter2`. - Refresh the recording once when a company's work content first becomes visible. Keep the existing autocapture text and attribute masking. - Add tests for deployment switches, session parsing and exposure, disabled source requests, older servers, and withdrawal with cached data. Retain the original masking, company, secret, and source-change tests. - Document configuration, rollback, restart and tab-reload steps, residual recording risks, and the board-only `hiddenCount` API field with absent-on-older-server semantics. Refresh the shared-source pins with the maintained generator; runtime and compiler pins stay unchanged. The original implementation and commits are preserved from @nguyenm7. The deployment configuration follow-up adds the host opt-in. When squash-merging, preserve the follow-up author's credit in the squash commit body: ```text Co-Authored-By: Devin Foley <devinfoley@users.noreply.github.com> ``` ## Verification Current head `2ce967f1e1`: CI has 43 checks passed and four skipped, with none failed or pending. The Greptile review on this head is 5/5, and both findings from its previous review are fixed. No person has approved the pull request yet. The evidence below was recorded on earlier heads and is kept as the record of how the change was verified. Greptile apex review: 5/5 on `45023e6`, with no unresolved review threads. CI on that head is green: 76 checks passed and four skipped, with no failed or pending checks. The branch has no merge conflicts with master. On the final source change, locally: - `cd ui && pnpm exec vitest run src/lib/analytics src/context/LiveUpdatesProvider.test.ts src/lib/markdown-plain-text.test.ts`: 10 files, 520 tests pass. The secret-redaction cases are in `replay-secret-redaction.test.tsx`, so `replay-masking.test.tsx` stays under 1,000 lines (701). - `cd server && pnpm exec vitest run src/__tests__/cloud-posthog-config.test.ts src/__tests__/cloud-posthog-browser.test.ts src/__tests__/auth-routes.test.ts src/__tests__/posthog-direct-transport.test.ts`: 4 files, 124 tests pass. - `cd packages/shared && pnpm exec vitest run src/validators/access.test.ts`: 22 tests pass. - `pnpm exec vitest run -c tests/runner-e2e/vitest.config.ts source-sdk-public-inputs`: 13 tests pass. - Shared, server and UI package typechecks pass. Server and UI builds pass. - Token gates, module boundaries, the test budget check for changed suites, and `git diff --check` pass. - Long-preview regression proof: four rendered tests initially fail on `9f2039d` because it passes 128,005 characters to conversion. They now verify a 2,048-character input bound while calling the real helper, a maximum 180-character summary, and complete replay masking for capped sources. Inputs include backticks, stars, underscores and brackets. The earlier short-preview credential tests still pass. - Review regression proof: three rendered task-preview tests expose GitLab, GitHub and OpenAI fixture credentials on `7533fbe`; they pass after preserving token punctuation. An 80,000-hyphen input took about 3.25 seconds on that head and failed the 500 ms bound. The single-pass flag scan passes the guard with a 512 KiB prefix followed by a real password flag. - Regression proof: the added tests first failed on the prior implementation, including work content visible with a missing or false opt-in and after withdrawal. They pass with the new gate. - `pnpm verify`: exit 2, broader verification required because the analytics document is a global CI input. Required CI supplies repository-wide coverage. An earlier exit 1 identified stale shared-source pins; the maintained generator refreshed them and the 13 pin tests pass. - Direct UI `tsc --noEmit` initially lacked generated Storybook catalogs in the fresh checkout. The maintained UI typecheck generates those files and passes. A preliminary Vitest `--project ui` invocation matched no named project; the commands above use the package configuration. - Secret scan reviewed the commit diff. Gitleaks reports two generic-key matches in the generated source-pin registry; both equal the corresponding Git blob hashes. The remaining commit content scans clean. No run artifacts or private deployment data are committed. CI follow-up on `45023e6`: [server shard 10/20](https://github.com/paperclipai/paperclip/actions/runs/45560174673/job/139021948661) timed out twice at the existing 15-second limit in `issue-document-batch.integration.test.ts`, test "rejects many large documents using a size-only query before loading any bodies". The test prepares 200 half-MiB documents and later rewrites them. The same test and server code are unchanged from `9f2039d`, where [the same shard passed](https://github.com/paperclipai/paperclip/actions/runs/45558505382/job/139016469065) and this test took 8.39 seconds. The intervening commit changes UI and documentation only. The exact failing case passes locally on the current head with `cd server && pnpm exec vitest run src/services/native-runtime/issue-document-batch.integration.test.ts -t 'rejects many large documents using a size-only query before loading any bodies'` (one passed, 15 skipped). This shows local recovery; it does not establish the cause of the CI timeout. A targeted shard rerun was requested, but GitHub refused because the workflow is still running. No test limits or product code have been changed to hide the failure. This initial failure is retained here as evidence; the successful second-attempt outcome is recorded below. CI follow-up, second shard: [server shard 13/20](https://github.com/paperclipai/paperclip/actions/runs/45560174673/job/139021948654) failed `ai-connections.test.ts`, test "requires sign-in after the receiver process dies with an exchanged but unsaved token". The first attempt failed its wait for one token exchange and an advisory-lock waiter within 25 seconds. The automatic retry failed earlier because the first attempt had already inserted the fixed membership fixture. The suite, receiver helper and AI connection service are unchanged by this work. The [original PR head passed this shard](https://github.com/paperclipai/paperclip/actions/runs/45544519067/job/138970880217), with the same test taking 21.06 seconds. The exact case passes locally on `45023e6` with `cd server && pnpm exec vitest run src/__tests__/ai-connections.test.ts -t 'requires sign-in after the receiver process dies with an exchanged but unsaved token'` (one passed, 164 skipped). The cause of the missed CI wait remains unconfirmed. This local pass does not clear the failed CI result. Targeted reruns were initially blocked by GitHub while the workflow was running. See the successful second-attempt outcome below. CI recovery: [workflow attempt 2](https://github.com/paperclipai/paperclip/actions/runs/45560174673/attempts/2) completed successfully on unchanged head `45023e6`. Both previously failed shards now pass. No source edits, timeout increases, or test removals were needed. The original timeout and missed-wait causes remain unconfirmed; the earlier failures and comparison evidence above are preserved. Final acceptance uses the green current-head CI result together with the local checks and 5/5 review. Not run locally: repository-wide tests/builds or a live PostHog recording. The tests exercise the masking callback and UI state, not the externally loaded recorder. After deployment, compare a masked replay with the work-content flag unset against an opted-in eligible company. Then verify that Google/Slack or a hidden source keeps the same surfaces masked. Restart the server and reload open tabs after changing deployment environment values. ## Risks - The opt-in belongs to the host, not to the people who use the deployment. Nothing in this pull request asks or tells a user. A host that sets the flag must tell its users first. The plan for the hosted service is in #23338. - Enabling the new flag allows eligible work content to leave the instance in replay data. Leave it unset or set it to `0` to keep work content masked. No deployment or fleet policy is changed by this PR. - The flag does not bypass company eligibility checks or secret masking. Changing it affects future recording after the configuration reaches the browser; it does not remove previously recorded content. - Connection detection is a best effort. A custom MCP server with an unrelated name and URL, or credentials used directly by an agent, can carry Google or Slack data without appearing as a known source. - Secret redaction is a best effort. Unknown or unlabeled secrets, non-English labels, values on a later line or under a table header, and values outside bounded line context can be missed. Some ordinary values are over-masked. - Source changes can race with recording until the live update arrives. A missed update can extend that window to the five-minute refresh. Connection count and list queries can disagree briefly and then mask conservatively. - Hidden drafts and aggregators can keep harmless content masked. Text rendered during a source recheck stays masked until it renders again. The first visible state adds a full recording snapshot. - Task previews now inspect at most 2,048 source characters before conversion. Very long markup can produce an incomplete summary. Source-capped previews stay fully masked; opening the full task keeps the normal work-content policy. - Artifact card text previews stay masked in every company. Document card previews and cut task previews mask when a credential sits at or before the cut, so some replays show stars there while the full document shows. - Task titles, names and other previously visible surfaces remain visible and can contain copied customer text. New work-content surfaces must preserve company scoping. ## Model Used - Original implementation: Anthropic Claude Opus 5.5 (`claude-opus-5-5`) and Claude Fable 5.2 (`claude-fable-5-2`) through Claude Code, with shell, edits, tests and the original read-only exploration subagent. - Deployment configuration follow-up: OpenAI `gpt-6.1-sol` through the Codex, xhigh reasoning, shell, file edits and test tools. Context window size is not exposed by the runtime. No additional subagents. ## 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: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Devin Foley <devin@paperclip.ing> Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Dotta <bippadotta@protonmail.com> |
||
|
|
0abb7834f7 |
fix(opencode): attribute the memory that fills the sandbox before an OOM kill (#23391)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - The native Runner starts `opencode serve` for each OpenCode agent
turn in a cloud sandbox with an 8 GiB cgroup memory limit.
> - #23372 added kernel evidence to a signal death of `opencode serve`.
The first event with that evidence shows `memoryKill: "observed"` and
`memoryPeakBytes` at the 8 GiB limit, so the kernel OOM killer stopped
OpenCode.
> - These deaths happen on light turns: one or two small tool calls,
then model generation, about 30 to 60 seconds after OpenCode starts. No
large Bash command runs.
> - The record does not say which memory filled the limit: OpenCode
itself, another process, or shared memory (tmpfs). A correct fix needs
that fact.
> - This pull request samples that memory while OpenCode runs and
reports the last sample with the death.
> - The benefit is that the next OOM kill names the memory consumer, so
the fix can target it.
## Linked Issues or Issue Description
Refs #23372 (adds `memoryKill`, `memoryLimitBytes` and
`memoryPeakBytes`). Refs #17398 (the Legacy OpenCode adapter makes tool
commands the first OOM victims; that does not help when no large tool
command runs).
**What happened?**
On a cloud sandbox, native OpenCode turns fail with
`opencode_server_exited`. With #23372 deployed, the failure record shows
`signal: SIGKILL`, `memoryKill: observed`, `memoryLimitBytes:
8589934592` and `memoryPeakBytes: 8589942784`. The turn made only two
light tool calls before the kill. The record does not show which process
or memory type used the 8 GiB.
**Expected behavior**
When the kernel stops `opencode serve`, the failure record shows how
much memory OpenCode used, how the limited cgroup memory divides into
anonymous, shared and file memory, and the largest other process.
**Steps to reproduce**
1. Run a native OpenCode turn in a Linux sandbox with a cgroup v2 memory
limit.
2. Make the sandbox use all of its memory limit so that the kernel OOM
killer stops `opencode serve`.
3. Read `resultJson.nativeTurnFailure`. Before this change, it has no
memory attribution.
**Paperclip version or commit**
`master` at
|
||
|
|
07af22c57f |
feat(plugins): support agentless harness sign-in (#23392)
## Thinking Path > - Paperclip manages agents and the AI accounts they use. > - A company can connect an account before creating its first agent. > - Some plugin drivers can run sign-in in a dedicated sandbox. > - Core currently selects a saved agent for every plugin login. > - This change lets each driver declare that it can sign in without an agent. ## Linked Issues or Issue Description **Subsystem affected** Environment drivers, managed AI connections, and the agent setup UI. **Current behavior** A company with zero agents cannot start a provider login on a plugin environment, even when that driver can provision a temporary environment. **Proposed behavior** A driver can declare `supportsAgentlessLogin`. Core uses this capability when it selects a login target and acquires the lease. Drivers that omit it retain the existing agent selection. **Reason and benefit** Operators can finish connecting the account before they configure its first agent. **Additional context** The driver capability follows the per-driver adapter declaration in #22827. The onboarding flow keeps the agent readiness check from #23383. ## What Changed - Added the optional capability to the manifest, capabilities response, and login UI. - Kept company and driver validation at sign-in and lease acquisition. - Applied the plugin device-login deadline to sessions with no agent. Ordinary task provisioning keeps its existing contract. ## Verification - 122 tests passed across shared capabilities, environment target resolution, lease construction, device-login HTTP routes, and session lifecycle. - The server typecheck passed. - The SDK input registry matches the source revision. `pnpm verify` requests broader CI coverage for that registry. - After merging the current base, 82 focused tests passed, including the onboarding tests. The UI typecheck passed. All required GitHub checks passed. ## Risks Drivers must advertise this capability only when they can run and clean up a login without an agent. Existing manifests retain their previous behavior. No database migration is required. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used OpenAI Codex, GPT-6, with local code inspection and 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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
ce2e6ccc00 |
feat(ui): surface channel, key-values, lease, and schema elements on tasks (#23382)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip tasks and comments now store channel, key-value, claim lease, profile attribution, and structured schema fields on existing issue and comment tables (`channelId`, `kvLabels`, `schemaBlocks`, `resultSchemaRef`, `createdByProfile`, `actorProfile`, and claim lease fields). > - Existing board task views (`IssueProperties`, `MarkdownBody`, `CommentThread`, `IssueChatThread`, and `IssueDetail`) do not yet display these fields, and canonical `/api/issues/:id` routes do not resolve `channelPath` or strip `claimTokenHash` at serialization time. > - Users and reviewers cannot see channel provenance, key-values, active or expired claim leases, `--as <profile>` attribution, or structured `schema=<name>@<version>` blocks when they open a task in the UI. > - This pull request synchronizes the shared `Issue` and `IssueComment` contracts, resolves `channelPath` only when channel access and actor scopes allow it, strips `claimTokenHash` from issue responses, renders channel, key-values, lease, result schema, and structured schema cards across existing task views (only when set), and adds production-component Storybooks. > - The benefit is that existing task surfaces show channel, lease, key-value, profile, and schema state cleanly in place without cluttering standard tasks or adding a separate Channels navigation item, while preserving secret isolation on claim tokens. ## Linked Issues or Issue Description Refs #23329 Refs #23330 **What existing behavior does this improve?** Existing task detail, properties, Markdown body, comment thread, chat thread, and `/api/issues` HTTP serialization for tasks that carry channel, claim lease, key-value, profile attribution, or structured schema data. **Subsystem affected** Cross-cutting (`packages/shared`, `server/`, `ui/`, `ui/storybook/`, and `docs/api/`) **Current behavior** Canonical `/api/issues` routes return raw issue columns without a resolved `channelPath` and include `claimTokenHash: null` on the response shape. In `ui/`, `IssueProperties` omits channel provenance, `Key-values` editing, claim lease status, `resultSchemaRef` verification, and `--as <profile>` creator attribution. `MarkdownBody` renders ```` ```json schema=<name>@<version> ```` blocks only as plain code blocks, and comment threads show `local-board` or generic user labels instead of `actorProfile` and omit comment-level key-values. **Proposed behavior** `Issue` and `IssueComment` expose safe coordination and schema fields in `@paperclipai/shared`. Server issue routes strip `claimTokenHash` from serialized issue objects and resolve `channelPath` in batch via `findInaccessibleChannelIds` only when actor scopes and channel membership succeed (with zero extra SQL queries when `channelId` is null). `IssueProperties` mounts cohesive task property rows (`structured-task-rows.tsx`) strictly when set: `#<channelPath>` badge on `Channel`, inline `Key-values` add/edit/remove with CAS preconditions (`PATCH /api/issues/:id/kv-labels`), active vs expired `Lease` status with inline status dot and live countdown, `Result schema` matching status, and creator `--as <profile>` attribution. `MarkdownBody` and task discussion/chat threads render token-styled `SchemaBlockCard` views (`finding@1`, `test-report@1`, `git-commit@1`, `pull-request@1`, and custom `<name>@<version>` schemas) with a `Structured` / `JSON` toggle, deduplicated standalone `schemaBlocks`, `--as <actorProfile>` attribution, and comment key-value pills. Four production-component Storybooks document these states under `tasks-channels-leases-and-schemas`. **Reason and benefit** Agents and CLI workflows coordinate through existing Paperclip tasks and comments. Surfacing channel provenance, claim leases, key-values, profile attribution, and typed schema blocks directly on existing task views (and hiding those rows completely when unset) lets people inspect and edit structured task state in place without introducing new top-level navigation, while guaranteeing that `claimTokenHash` never leaves the server. **Breaking changes** None for external callers. `claimTokenHash` is omitted from serialized `/api/issues` JSON responses as a security invariant, and `channelPath` (`string | null`) is added on canonical issue read and update responses. ## What Changed - `packages/shared/src/types/issue.ts` and `tests/runner-e2e/source-sdk-public-inputs.json`: expose safe fields on `Issue` (`channelId`, `channelPath`, `createdByProfile`, `kvLabels`, `schemaBlocks`, `resultSchemaRef`, `claimEpoch`, `claimHolderAgentId`, `claimHolderUserId`, `claimHolderProfile`, `claimLeasedAt`, `claimLeaseExpiresAt`, `claimAttemptCount`) and `IssueComment` (`actorProfile`, `kvLabels`, `schemaBlocks`), never `claimTokenHash`, and synchronize the SDK public input registry pin. - `server/src/services/issues.ts`, `server/src/routes/issues.ts`, and `docs/api/issues.md`: omit `claim_token_hash` from SQL issue selections and `withIssueLabels`, strip `claimTokenHash` on HTTP serialization across issue routes, clear `kvLabels` and `schemaBlocks` on tombstoned comments, resolve `channelPath` in batch via `resolveHeadlessActor` and `findInaccessibleChannelIds` (zero extra SQL queries when `channelId` is `null`), and document the API response contract. - `server/src/__tests__/fixtures/issue-detail-response.json`, `server/src/__tests__/issue-activity-events-routes.test.ts`, and `server/src/__tests__/headless-channels-schemas-batch.test.ts`: update issue detail and update response snapshots (`channelPath: null`, no `claimTokenHash`) and add route contract coverage for `channelPath` visibility, scope enforcement, comment fields, and `claimTokenHash` omission. - `ui/src/api/issues.ts` and `ui/src/api/issues.test.ts`: add `issuesApi.updateKvLabels` targeting `PATCH /api/issues/:id/kv-labels` with CAS precondition normalization (`set`, `unset`, `if`) and unit test coverage. - `ui/src/components/issue-properties/structured-task-rows.tsx` and `IssueProperties.tsx`: add `IssueChannelRow`, `IssueKvLabelsRow` (`Key-values` with inline edit, remove, `+ Add`, CAS preconditions, touch-safe 16px inputs, and complete omission when empty), `IssueClaimLeaseRow` (inline status dot, live countdown, and omission when unset or released), `IssueResultSchemaRow` (unwrapping `InfiniteData` and identifier-keyed comment query caches, plus distinguishing `"unverified"` truncated scans from `"missing"`), and `IssueProfileAttributionRow`. - `ui/src/components/SchemaBlockCard.tsx`, `ui/src/lib/schema-block-utils.ts`, and `ui/src/components/MarkdownBody.tsx`: parse ```` ```json schema=<name>@<version> ```` fences (plus `{ schema, data }` JSON envelopes) via a static remark plugin and a bounded linear $O(N)$ single-pass CommonMark fence scanner (no multi-line backtracking regexes); render semantic-token cards for `finding@1`, `test-report@1`, `git-commit@1`, `pull-request@1`, and custom `<name>@<version>` blocks with `Structured` / `JSON` toggle, `https://`-only link safety, malformed-JSON code-block fallback, and iterative stack-safe `schemaBlocks` deduplication. - `ui/src/components/CommentStructuredMeta.tsx`, `CommentThread.tsx`, `IssueChatThread.tsx`, `TaskChatBubble.tsx`, `TaskChatDescriptionBubble.tsx`, `IssueDetail.tsx`, and chat adapters: render `--as <actorProfile>` attribution, comment-level key-value chips, and unfenced `schemaBlocks` across classic and chat task threads. - `ui/storybook/stories/tasks/channels-leases-and-schemas.stories.tsx`: add `ChannelTaskPropertiesActiveLease`, `ExpiredLeaseProperties`, `BuiltInAndCustomSchemaBlocks`, and `ChannelTaskThreadEndToEnd` stories registered under `tasks-channels-leases-and-schemas`. - `ui/src/components/issue-properties/structured-task-rows.test.tsx` and `ui/src/components/SchemaBlockCard.test.tsx`: add unit tests covering unset-row omission on standard tasks, single-badge channel provenance, CAS key-value mutations and `409` conflict rollback, inline lease status dots and countdown expiry, `InfiniteData` comment unwrapping, structured schema cards, malformed JSON fallback, linear $O(N)$ scanning on 5,000 unterminated JSON fences, newline-clamped markdown bounds, and deep deduplication. ## Verification - `pnpm --filter @paperclipai/shared build` — passed. - `cd server && node scripts/typecheck-layers.mjs` — passed (0 errors across all layers and test trees). - `cd server && npx vitest run src/__tests__/service-read-disconnect-retry.test.ts src/__tests__/issue-activity-events-routes.test.ts src/__tests__/issue-detail-statements.test.ts src/__tests__/headless-channels-schemas-batch.test.ts` — passed (54/54 tests). - `pnpm --filter @paperclipai/ui typecheck` — passed (0 errors). - `cd ui && npx vitest run src/components/issue-properties/structured-task-rows.test.tsx src/components/SchemaBlockCard.test.tsx src/api/issues.test.ts src/lib/issue-chat-messages.test.ts src/components/task-chat/task-chat-adapter.test.ts` — passed (115/115 tests). - `node scripts/check-token-gates.mjs`, `node scripts/check-test-budget.mjs`, `node scripts/check-module-boundaries.mjs`, and `node scripts/check-query-error-rendering.mjs` — all passed. - `node scripts/storybook-catalog.mjs && node scripts/storybook-catalog.mjs --check` and `node --test scripts/check-maps.test.mjs scripts/storybook-catalog.test.mjs scripts/storybook-feature-index.test.mjs` — passed (30/30 tests). - `pnpm --filter @paperclipai/ui build-storybook` — passed and verified built story IDs (`tasks-channels-leases-and-schemas--channel-task-properties-active-lease`, `tasks-channels-leases-and-schemas--expired-lease-properties`, `tasks-channels-leases-and-schemas--built-in-and-custom-schema-blocks`, `tasks-channels-leases-and-schemas--channel-task-thread-end-to-end`). ## Risks - Low risk. Standard board tasks with unset `Channel`, `Key-values`, `Lease`, and `Result schema` omit all four property rows completely, preserving existing `IssueProperties` layout and SQL query count (`0` extra queries when `channelId` is `null`). - Fenced code blocks without `schema=<name>@<version>` metadata (or with invalid JSON) fall back directly to the existing `CodeBlock` renderer. ## Model Used - Google Gemini (`gemini-3.1-pro` / Antigravity agentic coding runtime with extended thinking, code search, file editing, and terminal verification tools). ## 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> |
||
|
|
51541be36f |
fix(onboarding): start an agent-targeted sign-in only on a settled, prepared draft (#23383)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Onboarding signs the first agent in to Claude or Codex through a plugin-managed execution environment that is prepared for the agent (#23312) > - Each change to the setup draft, such as switching between Claude and OpenAI, makes Core prepare the environment again before it accepts a sign-in > - The wizard remembered that the environment had been prepared once, so it started the new sign-in during that preparation > - Core refused it with `login_agent_unavailable`, and the sign-in card showed only "Sign-in didn't finish" > - This pull request starts a sign-in only when the draft has settled on the current choice and is prepared, and shows Core's error on the card > - The benefit is that switching the sign-in source works, without an added wait ## Linked Issues or Issue Description Refs #23312 and #23315. **What happened?** In onboarding with a plugin-managed execution environment as the default, a user picked Claude, then switched to OpenAI. Every sign-in start after the switch returned `400 login_agent_unavailable`: Core refused the agent as the sign-in target. The card showed "Sign-in didn't finish. Try signing in again." **What did you expect to happen?** The OpenAI sign-in starts as soon as the environment is prepared for the new choice. **Steps to reproduce** 1. Make a plugin-managed execution environment that prepares an environment per agent the instance default. 2. Start onboarding, name the agent, and choose Claude with a subscription. 3. When the Claude sign-in shows, choose OpenAI. 4. See the sign-in fail with the message above. ## What Changed - The sign-in readiness hook takes `settled` and `holdKey`. A sign-in starts only when the agent has settled on the current choice and the environment is prepared for it. Readiness is held per agent, environment and sign-in source, so a source switch waits for the real preparation, and a sign-in already on screen stays on screen. - Onboarding treats the setup draft as settled when its saved harness (and model, when one is set) matches the selection. Each draft save puts the saved agent in the query cache at once, and readiness polls every 500 ms instead of every second. - The new-agent flow treats its draft as settled when no environment save is in flight, and polls a preparing draft every 500 ms. - Both sign-in panels show Core's start error for any sign-in that targets an agent, not only for one that Core selects automatically. ## Verification - `pnpm typecheck` in `ui/`: no errors. - The sign-in readiness helper and hook suites, the `AgentProviderConnection` suites and the `AgentConfigForm` render suite in `ui/`: 23 tests pass. A new hook test covers a switch from Claude to OpenAI and back while the environment is prepared again. - `PAPERCLIP_PLAYWRIGHT_CHANNEL=chrome npx playwright test --config tests/e2e/playwright.config.ts tests/e2e/onboarding-early-setup.spec.ts tests/e2e/onboarding.spec.ts -g "naming step creates|create-company path"`: 2 tests pass. - I reproduced the failure on a staging instance from the network log. I did not repeat the sign-in on a staging instance with this change. ## Risks - A change to the draft after a sign-in started can still make Core refuse the login lease when it acquires it. The card then shows Core's error and the usual retry. - Readiness polling is now twice as frequent while an environment is prepared. It stops when the environment is ready. - No migration and no API change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), with extended thinking and tool use (code search, shell, tests, browser network inspection) 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 - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>canary/v2026.1201.0-canary.876500 |
||
|
|
37da976b8c |
fix(monitors): preserve authorized task monitors on tasks with unresolved blockers (#23390)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents can schedule timed task monitors with `set_task_monitor` and end their turn with `yielded` and `continuation.kind: "monitor"` to check external work later > - Tasks can also have unresolved `blockedBy` dependencies while the agent still monitors independent active work such as CI or external checks > - Previously, `arbitrateNativeStatus` overrode every monitor wait on a task with unresolved blockers into `blocked` (`durable_dependency_blocker_bound`), and the heartbeat wake admission and queued-run claim paths rejected or cancelled `issue_monitor_due` wakes while blockers remained unresolved > - This pull request preserves authorized task monitor waits in `arbitrateNativeStatus` and admits server-verified `issue_monitor_due` wakes through wake admission, queued-run claim, and run-dispatch retry gates even when unresolved blockers exist > - The benefit is that authorized task monitors stay scheduled and fire on time without relaxing the dependency gate on `done`, `blocked`, unauthorized monitor claims, blocked tasks, or forged wakeups ## Linked Issues or Issue Description **What happened?** When an agent scheduled a task monitor with `set_task_monitor` on an `in_progress` task that also had unresolved `blockedBy` dependencies and finished with `reportedDisposition: "yielded"` and `continuation.kind: "monitor"`, `arbitrateNativeStatus` overrode the status to `blocked` (`durable_dependency_blocker_bound`) and stranded the monitor. Even if the task remained `in_progress`, `enqueueWakeup` and `claimQueuedRun` skipped or cancelled the due `issue_monitor_due` wake because `isDependencyReady` was `false`. **Expected behavior** An explicit, authorized task monitor (`monitorWaitAuthorized: true`, or already dispatched/superseded/preserved) stays in `scheduled_monitor_waiting` (releasing checkout) and wakes the assignee with `issue_monitor_due` when due, while `done`, `blocked`, `unfinishedResponseWait`, unauthorized monitor claims, blocked tasks, and forged `issue_monitor_due` wakes remain gated by unresolved `blockedBy` dependencies. **Steps to reproduce** 1. Create an `in_progress` task assigned to an agent and add an unresolved `blockedBy` dependency to it. 2. Schedule a task monitor on the task with `set_task_monitor` and finish the run with `reportedDisposition: "yielded"` and `continuation.kind: "monitor"`. 3. Observe `arbitrateNativeStatus` return `blocked` (`durable_dependency_blocker_bound`) instead of `scheduled_monitor_waiting`, and observe `tickIssueMonitors` skip the due monitor with `issue_dependencies_blocked`. **Paperclip version or commit** `8403e1c4ce` (`master`) **Deployment mode** Local dev (pnpm dev) ## What Changed - Updated `arbitrateNativeStatus` in `server/src/services/native-runtime/status-arbiter.ts` to exempt authorized `yielded` monitor continuations (`monitorWaitAuthorized`, `monitorWaitDispatched`, `monitorWaitSuperseded`, `monitorWaitPreserved`) from the `durable_dependency_blocker_bound` override while keeping `done`, `blocked`, `unfinishedResponseWait`, and unauthorized monitor claims gated. - Added `verifyIssueMonitorWake` in `server/src/services/issue-monitors.ts` to verify `issue_monitor_due` wakes against durable server state (claimed non-quota monitor on an `in_progress`/`in_review` task at enqueue time; admitted non-skipped `agentWakeupRequests` row at claim and retry-gate time). - Extended `allowsDependencyBlockedWake` in `server/src/modules/run-dispatch/domain/wake-context.ts` and wired `verifyIssueMonitorWake` into `enqueueWakeup` and `claimQueuedRun` (`server/src/services/heartbeat/queue.ts`) plus `loadGateFacts` and `loadStalenessFacts` (`server/src/modules/run-dispatch/adapters/postgres.ts`). - Added unit and integration regression tests in `server/src/services/native-runtime/status-arbiter.test.ts` and `server/src/__tests__/issue-monitor-scheduler.test.ts` covering authorized monitors with blockers, unauthorized monitor claims, `done` with blockers, due monitor execution with blockers, and forged `issue_monitor_due` wakeups. ## Verification - `pnpm --filter @paperclipai/server typecheck` (passed) - `pnpm --filter @paperclipai/server exec vitest run src/services/native-runtime/status-arbiter.test.ts src/__tests__/issue-monitor-scheduler.test.ts src/services/native-runtime/task-monitor.integration.test.ts` (84 passed) - `pnpm --filter @paperclipai/server exec vitest run src/modules/run-dispatch/domain/wake-context.test.ts src/services/heartbeat/scheduling.test.ts` (81 passed) - Verified red-green behavior on the new regression tests before and after applying the fix. ## Risks - Low risk. The dependency-blocker bypass is scoped strictly to server-verified non-quota task monitors on `in_progress` or `in_review` tasks (`scheduledIssueMonitorWait` + claimed `monitorWakeRequestedAt` at enqueue, and admitted `agentWakeupRequests` row at claim/retry). Blocked tasks, provider quota monitors, unauthorized monitor claims, forged `issue_monitor_due` wakeups, and `done`/`blocked` transitions retain full dependency-blocker enforcement. ## Model Used - Google Gemini (Antigravity agentic coding assistant, tool use and 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 mergecanary/v2026.1201.0-canary.876400 |
||
|
|
1c0233526d |
feat(tools): add experimental minimal channels viewer example (#23380)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Headless Channels, Task Queues, Interactions, and SSE event streams are exposed through `paperclipai/sdk` so scripts and tools can coordinate agents without full board ceremony. > - Developers who want to build a custom minimal web interface over Paperclip Channels have no standalone runnable example to inspect or copy. > - Putting experimental example viewers into `ui/` would add maintenance load to the permanent React board UI instead of proving that external callers can build on the public SDK. > - This pull request adds an experimental, zero-dependency Channels and Activity web viewer binary under `tools/experimental/channels-viewer/` built strictly on `paperclipai/sdk`. > - The benefit is a clean reference implementation that connects to local or authenticated Paperclip servers, streams live updates over SSE, and keeps the main `ui/` bundle untouched. ## Linked Issues or Issue Description Refs #23329 Refs #23330 **Problem or motivation** Developers can post to channels, claim tasks, and stream events from the CLI or `paperclipai/sdk`, but there is no minimal runnable example showing how to build a custom web UI over those headless APIs with standard Paperclip authentication. **Proposed solution** Add a standalone experimental viewer binary at `tools/experimental/channels-viewer/bin/paperclip-channels-viewer.mjs` backed by `node:http`, `paperclipai/sdk`, and zero-bundler ES modules. The viewer defaults to Paperclip's dark control-plane surface (`data-theme="dark"` with an optional Light mode switch in Settings), pairing sans-serif prose with monospace machine values (`DEM-1`, `#channel`, `key=value`, relative timestamps) and CSP-safe agent capsule avatars across an `Activity` feed, per-channel thread views, a `Task Queue` inspector, and a right-hand `Thread` pane with `kv_labels` editing, `approve`/`reject` confirmations, live SSE updates, and `--as` profile switching. **Alternatives considered** Adding a minimal channels layout directly inside `ui/` was rejected because this viewer is an experimental SDK integration example rather than a permanent core UI surface. Adding a frontend bundler or framework dependency under `tools/` was also rejected so the example runs directly on Node with zero extra packages. **Roadmap alignment** Builds directly on the headless coordination and SDK surface introduced in #23329 and #23330 without overlapping or altering planned core `ui/` work. ## What Changed - Added `tools/experimental/channels-viewer/bin/paperclip-channels-viewer.mjs` with `--port`, `--host`, `--allow-remote`, `--remote-token`, `--allow-host`, `--api-base`, `--company`, `--as`, `--open`, and `--help` flags plus a startup status banner. - Added `tools/experimental/channels-viewer/src/server.mjs`, `src/viewer-data.mjs`, `src/auth.mjs`, `src/security.mjs`, and `src/format.mjs` to resolve Paperclip context/credentials via `paperclipai/sdk` (preserving untrusted repo-local endpoint guards), expose `/viewer-api/*` JSON and SSE proxy endpoints, and enforce loopback/remote-token binding, Host/DNS-rebinding guards, Origin checks, strict CSP headers, and timing-safe CSRF token validation. - Added zero-dependency ES module frontend files (`src/public/index.html`, `styles.css`, `overlays.css`, `app.js`, `render.js`, `dom-helpers.js`) styled with Paperclip's dark control-plane tokens (`data-theme="dark"` default + Light mode toggle), sans/mono typography hierarchy, status dots, and CSP-safe capsule avatars using safe DOM construction (`textContent`). - Added `tools/experimental/channels-viewer/README.md` and a brief reference section in `doc/HEADLESS-TUTORIALS.md`. - Excluded `tools/experimental` in `.dockerignore` so production Docker build contexts remain slim. - Added `tools/experimental/channels-viewer/test/channels-viewer.test.mjs` (`node:test`) and `server/src/__tests__/experimental-channels-viewer.test.ts` (Vitest full-stack E2E with Express, embedded PostgreSQL, and live SSE). ## Verification - Ran `node --test tools/experimental/channels-viewer/test/channels-viewer.test.mjs` (4/4 tests passed). - Ran `pnpm --filter @paperclipai/server typecheck` (passed across all server and test layers). - Ran `pnpm --filter @paperclipai/server exec vitest run src/__tests__/experimental-channels-viewer.test.ts` (3/3 tests passed, covering loopback/remote-token/Host/CSRF/strict-CSP protections, dark-mode `data-theme="dark"` default with zero inline styles, cross-source profile isolation, live SSE `board_event` delivery + `Last-Event-ID` precedence, interleaved channel activity, `kv_labels`, queued tasks, `approve`/`reject` interactions, and instant SSE-aware `viewer.close()`). - Ran `node scripts/check-module-boundaries.mjs`, `node scripts/check-test-budget.mjs --base origin/master`, `node scripts/check-docker-deps-stage.mjs`, and `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse HEAD) --check` (all passed). ## Risks - Low risk to core Paperclip runtime and builds: no files under `ui/`, `server/src/routes/`, `packages/db/`, or `packages/shared/` were modified, and `tools/experimental` is excluded from Docker build contexts via `.dockerignore`. - Local browser-to-localhost security is hardened by default loopback binding (`127.0.0.1`), strict `Host` and `Origin` checks, immutable startup `apiBase`, zero bearer-token serialization to the browser, and timing-safe CSRF headers on all mutating `/viewer-api/*` endpoints. ## Model Used - Anthropic Claude Opus 4.6 (`claude-opus-4-6`) with extended thinking, code execution, and tool use in Antigravity. ## 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> |
||
|
|
de24b28b82 |
feat(runner): keep harness session state in an optional harness state directory (#22841)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Runner starts each agent's harness (ACPX agents and OpenCode) and keeps a runtime tree for each session > - All of that tree is in one runtime directory: session records, conversation history, caches, configuration, temporary homes and the turn journal > - Some hosts keep the runtime directory on fast local disk, and keep a separate durable directory that stays with the work > - These hosts cannot put the state that a session needs to continue in the durable directory without also moving large caches and data that the Runner writes again each launch > - This pull request adds one optional setting, `harnessStateDirectory`, for the state that a session needs to continue > - The benefit is that a host can keep conversations and session records durable, and keep caches and temporary data local ## Linked Issues or Issue Description **Is your feature request related to a problem?** A host can set where the Runner puts its runtime directory. It cannot set a different location for only the harness state that a later process needs to continue a session. If a host moves the full runtime directory to durable storage, it also moves caches, configuration that the Runner writes again at each launch, temporary homes and the turn journal. These are large or written frequently, and nothing needs them after the session. **Describe the solution you'd like** An optional setting names a durable directory. The Runner puts only the state that a session needs to continue in that directory. All other data stays in the runtime directory. When the setting is not set, nothing changes. **Describe alternatives you've considered** - Move the full runtime directory to durable storage. This moves caches and data that the Runner writes again each launch. - Mount local folders over the cache paths. These paths include a session ID that the Runner makes, so a host cannot know them before the Runner starts. The folder names are also not a contract. Related: #12840 (multi-turn remote sessions) and #15406 (Runner task hooks for environment plugins) touch the same runtime directories. No open PR or issue duplicates this change. ## What Changed - The Runner accepts an optional `harnessStateDirectory` setting. A host gives it as a launch option or as the `PAPERCLIP_RUNNER_HARNESS_STATE_DIR` environment variable. - When the setting is set, these folders go below `<harnessStateDirectory>/acpx/<session>/`: ACPX session records (`acpx-state`), each agent's home (`<agent>-home`) and XDG data (`data`). - When the setting is set, OpenCode's session store (`data`) and its workspace record go below `<harnessStateDirectory>/opencode/<session>/`. OpenCode recovery reads the workspace record, so a resume works after the runtime directory is gone. - The temporary home, configuration, caches, the ACPX workspace record and the turn journal stay in the runtime directory. - Recovery, session reopen, Antigravity probe retirement and the credential observer look for the state in the new location. - The Runner refuses a value that is relative, not normalized, missing, the filesystem root, or reached through a symbolic link. It also refuses a value that overlaps the workspace. The new folders are private (0700), and the directory is a protected path for the harness sandbox. - The ACPX launch descriptor, the sidecar `session.open` parameters and the runnerd environment allowlists carry the setting only when it is set. - The README tells how to use the setting. ## Verification - `tsc` for `tsconfig.json`, `tsconfig.surfaces.json` and `tsconfig.test.json`, `check:protocol-types` and `check:acpx-profiles`: pass. - Targeted Vitest files for the ACPX sandbox, recovery identity, probe retirement, the new directory module, the ACPX driver, runtime host, agent files, the native backend factory, the OpenCode driver, the OpenCode proxy input, the provider launch and the runnerd transport: pass. - Sidecar Vitest files and `node --test test/acpx-sidecar-contract.test.mjs scripts/contracts/contract-fingerprints.test.mjs`: pass. - `cargo fmt --check`, `cargo check --workspace --all-targets` and `cargo test -p paperclip-runner-core --lib credential_observer`: pass. - The tests check that: - The default layout does not change. The tests assert the exact paths. - With the setting, only the state folders move. - A reopen finds the session after the runtime directory is deleted. For OpenCode, the fake server saves and reloads the session from the session store, and recovery fails when that state is removed. - The Runner refuses each invalid value. - I did not run the full suite or the Runner integration suites locally. CI runs them. ## Risks - When the setting is not set, the layout and the saved descriptors do not change. Existing hosts see no change. - A host must enable the setting for new sessions only. A session saved without the setting does not reattach with it. The Runner refuses it with the existing "contract changed" error. - In-process ACPX recovery reads the workspace record from the runtime directory. If a host loses the runtime directory, that recovery path fails as it does now. The runnerd ACPX path is not affected, because it takes the working directory from the descriptor. - The provider-pack contract digest changes because the Rust descriptor has a new optional field and the allowlists have a new key. No ACPX profile version or command digest changes. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) by Anthropic, in Claude Code, with tool use (shell, file editing, code search) and extended thinking. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>canary/v2026.1201.0-canary.876200 |
||
|
|
d1680baf8f |
fix(onboarding): harden connect-model OAuth timeout, mobile paste, and API key recovery (#23379)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - During onboarding, new users connect an AI model via Claude/OpenAI subscription OAuth or an API key. > - Production session replays showed users failing on `connect_model` because subscription login sessions expired at 5 minutes during mobile/tab switches, the waiting spinner hid the sign-in link with no way to reopen it, pasted Claude codes failed silently without normalization or clear feedback, and rejected API keys gave a dead-end error. > - These friction points cause new users to abandon onboarding right before their first agent run. > - This pull request raises server login timeouts to 15 minutes with visibility-change polling/auto-refresh, keeps a re-open link and 60s recovery action visible while waiting, normalizes and validates pasted Claude authorization codes with explicit error messaging, and adds API key paste normalization, provider-mismatch switching, and actionable rejection links. > - The benefit is fewer onboarding drop-offs on mobile and desktop without changing backend auth protocols or schema. ## Linked Issues or Issue Description **What happened?** Users onboarding on `connect_model` hit four repeatable failure modes: 1. Subscription login sessions (`DEVICE_LOGIN_TIMEOUT_MS` and `DEFAULT_SETUP_TOKEN_SESSION_TTL_MS`) expired after 5 minutes while users switched apps/tabs for OAuth and 2FA, showing `This sign-in expired` or `Sign-in didn't finish` right when they returned. 2. After clicking `Sign in`, `ProviderSubscriptionCard` replaced the button with a disabled `Waiting…` / `Waiting for code…` spinner, leaving users with no way to reopen the OAuth URL if a mobile browser blocked the tab or they closed it. 3. Pasting a Claude authorization code with mobile line breaks, quotes, or a full callback URL could fail silently or show no explanation when rejected. 4. Pasting a rejected or wrong-provider API key showed a generic rejection message without pointing users to the provider's API keys page or offering a 1-click provider switch. **Expected behavior** Subscription sign-in sessions should give users 15 minutes to complete OAuth, immediately poll or refresh when returning to the tab, keep a re-open link and 60-second recovery action accessible, normalize and validate pasted Claude codes with clear inline feedback, and help users recover from wrong-provider or rejected API keys. **Steps to reproduce** 1. Open the onboarding wizard and advance to the Connect a model step. 2. Start a Claude or OpenAI subscription sign-in, switch tabs for 5 minutes (or close the OAuth tab), and return. 3. Paste an authorization code with extra whitespace/newlines or a callback URL into the Claude code input, or paste an Anthropic `sk-ant-...` key into OpenAI API key mode. **Paperclip version or commit** `43fedd51c5c37ccf7c7568328bac97179cdd48ba` (`master`) **Deployment mode** Other (hosted Cloud & local dev) ## What Changed - **15-minute subscription login TTLs + tab-return poll/refresh:** Raised `DEVICE_LOGIN_TIMEOUT_MS` (`server/src/services/device-login-service.ts`) and `DEFAULT_SETUP_TOKEN_SESSION_TTL_MS` (`server/src/services/setup-token-session.ts`) from 5 minutes to 15 minutes. Added `visibilitychange` listeners to both `AdapterDeviceLoginPanel` and `ClaudeSetupTokenLoginPanel` (`ui/src/components/AgentConfigForm.tsx`) to immediately refetch status on tab return and auto-refresh once if an onboarding session expired while hidden. - **Non-locking waiting state:** Updated `ProviderSubscriptionCard` (`ui/src/components/AdapterLoginChrome.tsx`) to keep an `Open sign-in link again` button visible while waiting and show a `Taking a while? Get a new link` recovery button after 60 seconds (`WAITING_HELP_DELAY_MS`). - **Claude code-paste normalization & inline validation:** Added `ui/src/lib/onboarding-login-helpers.ts` (`normalizeSubmittedBrowserCode`, `validateSubmittedBrowserCode`) to strip newlines/quotes and extract `code#state` from pasted callback URLs, surface immediate inline validation errors on invalid pastes, and show an explicit rejected-code message when a submitted code fails. - **Self-recoverable API key input:** Added `normalizeApiKeyInput`, `detectMismatchedApiKeyProvider`, and `providerApiKeysHelp` in `ui/src/lib/onboarding-login-helpers.ts`, wired into `ui/src/components/OnboardingWizard.tsx` to normalize pasted keys, offer a 1-click switch when an Anthropic/OpenAI key is pasted into the wrong provider, and link directly to the provider's API keys page when rejected. - **Module size note:** `AgentConfigForm.tsx` and `OnboardingWizard.tsx` already exceeded 1,000 lines; all new pure parsing, validation, and provider-help logic was extracted into `ui/src/lib/onboarding-login-helpers.ts` to keep edits to existing files minimal. ## Verification - `pnpm --filter @paperclipai/ui typecheck` — passed. - `pnpm --filter @paperclipai/server typecheck` — passed. - `pnpm vitest run ui/src/lib/onboarding-login-helpers.test.ts ui/src/components/AdapterLoginChrome.test.tsx ui/src/components/AgentConfigForm.render.test.tsx server/src/__tests__/device-login-service.test.ts` — 4/4 files, 84/84 tests passed. - `git ls-files "*setup-token*test*" "*onboarding*test*" | grep -E "^(server|ui)/" | xargs pnpm vitest run` — 24/24 files, 373/373 tests passed. - Note: A full local `pnpm verify` run selected 2,296 files and hit 14 unrelated local PostgreSQL/heartbeat/Tailscale hook timeouts under parallel macOS load (34,070 passed, 0 failures in login/onboarding/setup-token/device-login suites); CI will supply full-suite coverage on this PR. ## Risks - **Low risk:** Raising `DEVICE_LOGIN_TIMEOUT_MS` and `DEFAULT_SETUP_TOKEN_SESSION_TTL_MS` from 5 to 15 minutes extends the maximum lifetime of an uncompleted login sandbox lease by 10 minutes (bounded by the existing reaper and per-owner concurrency limits). No database schema, API contract, or auth protocol changes. ## Model Used - Google Gemini (Antigravity agentic assistant with thinking mode and tool use / code 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
e32b1b057f |
fix(telemetry): re-identify PostHog workspace group on Cloud stack claim (#23389)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Managed Paperclip Cloud stacks send direct server telemetry to PostHog and identify each `workspace` group with `stack_slug` and `primary_host` > - Warm-pool stacks boot before a user claims them, so startup `groupIdentify` records the placeholder `pool-<hash>` slug and host > - When a user claims a warm-pool stack, `applyCloudRuntimeIdentityAssertion` transitions the stack identity in place without restarting the process, so PostHog group properties stay stuck on `pool-<hash>` until a later restart > - This pull request adds an `onCloudRuntimeIdentityChange` listener in `cloud-runtime-identity` and subscribes the PostHog direct transport to re-send `groupIdentify` with the claimed `stack_slug` and `primary_host` > - The benefit is that PostHog workspace analytics and live dashboards immediately reflect the real claimed stack name and host for both browser and server-side events ## Linked Issues or Issue Description **What happened?** When a warm-pool Cloud stack boots, `resolveDirectTransport` announces the workspace to PostHog with its placeholder `pool-<hash>` `stack_slug` and `primary_host`. After a user claims the stack via `applyCloudRuntimeIdentityAssertion`, the server updates its runtime identity in place without restarting, so PostHog's `workspace` group keeps the stale `pool-<hash>` `stack_slug` and `primary_host` until the container eventually restarts. **Expected behavior** When a Cloud stack's runtime identity transitions from a warm-pool placeholder to its claimed slug and canonical origin, the PostHog direct transport immediately calls `groupIdentify` with the updated `stack_slug` and `primary_host` and flushes. **Steps to reproduce** 1. Start a Paperclip Cloud warm-pool instance with `PAPERCLIP_POSTHOG_PROJECT_TOKEN` and `PAPERCLIP_POSTHOG_ENVIRONMENT` configured and `PAPERCLIP_STACK_SLUG=pool-123`. 2. Apply a signed Cloud runtime identity assertion claiming the stack as `gonzo` (`https://gonzo.staging.paperclip.app`). 3. Observe PostHog `workspace` group properties for the stack: before this fix, `stack_slug` and `primary_host` remain `pool-123` / `pool-123.staging.paperclip.app` until process restart. **Paperclip version or commit** `36c2ad39c8` (`origin/master`) **Deployment mode** Other (Paperclip Cloud managed stack) ## What Changed - Added `onCloudRuntimeIdentityChange` listener registration and best-effort notification in `server/src/services/cloud-runtime-identity.ts` when `applyCloudRuntimeIdentityAssertion` changes the runtime identity (or `initializeCloudRuntimeIdentity` restores one), and cleared listeners in `resetCloudRuntimeIdentityForTests`. - Subscribed `createPostHogDirectTransport` in `server/src/services/posthog-direct/transport.ts` to `onCloudRuntimeIdentityChange` so matching `stackId` claims update any queued `pendingAnnouncement` or immediately send and flush an updated `groupIdentify` with the claimed `stack_slug` and `primary_host`; unsubscribed on `shutdown()`. - Added a regression test in `server/src/__tests__/cloud-runtime-identity.test.ts` verifying initial `pool-*` announcement, immediate `groupIdentify` + flush on claim, and no duplicate calls on idempotent claim retry. ## Verification - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/cloud-runtime-identity.test.ts src/__tests__/posthog-direct-transport.test.ts src/__tests__/posthog-direct-telemetry.test.ts` — 38/38 tests passed. - `pnpm --filter @paperclipai/server typecheck` — passed. ## Risks - Low risk. Listener notifications are wrapped in `try/catch` and the PostHog `groupIdentify` + `flush` call is fire-and-forget with error suppression, matching the existing `onCloudTrialInferenceCohortChange` pattern so telemetry failures can never disrupt runtime identity claims. ## Model Used - Google Gemini (Antigravity agent with tool use, file editing, and local 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 - [ ] I have updated relevant documentation to reflect my changes - [x] 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 - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
8403e1c4ce |
docs(connections): modularize connector playbook and add create-connector skill (#23384)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - App connectors let agents interact with external tools, suites, REST APIs, and chat channels under instance governance > - `doc/connections/CONNECTOR-PLAYBOOK.md` grew to 2,968 lines (171 KB) and accumulated stale guidance on `rest_api` adapters and setup UX, with no upfront research-and-interview gate to aim new connectors at user expectations > - An autonomous agent cannot reliably build a new connector in one command when the playbook mixes every track together and defaults blindly to remote MCP > - This pull request splits the playbook into a concise router plus six load-on-demand track guides and adds the `.agents/skills/create-connector` skill > - The benefit is that agents and contributors audit official vendor docs up front, recommend the right architecture track, and load only the guidance needed for that connector ## Linked Issues or Issue Description **Issue type** Outdated (no longer matches behavior) **Where is the issue?** `doc/connections/CONNECTOR-PLAYBOOK.md`, `doc/connections/README.md`, `.agents/skills/create-connector/` **What's wrong?** `doc/connections/CONNECTOR-PLAYBOOK.md` was a 2,968-line monolith that still claimed `rest_api` is not exposed through the gateway (despite `rest-registry.ts`, `browser-use-cloud`, and `google-workspace-rest-tools`), contradicted itself on one-screen setup vs. a two-step Access → Connect flow, and jumped straight into MCP endpoint probing without an official-docs feasibility audit or product alignment interview. **Suggested fix** Refactor `CONNECTOR-PLAYBOOK.md` into a short canonical router + universal invariants contract, move track-specific details into `doc/connections/tracks/`, and add `.agents/skills/create-connector/` with a mandatory Research-First → Proactive Recommendation & Interview gate. ## What Changed - Refactored `doc/connections/CONNECTOR-PLAYBOOK.md` from 2,968 lines to 184 lines (Phase 0 official-docs feasibility audit & interview, 6-track selection matrix, universal invariants, canonical one-screen setup UX, production validation matrix, preserved inbound anchors). - Created six focused track guides and one deep reference under `doc/connections/tracks/`: - `remote-mcp.md` (Track A) - `rest-adapter.md` (Track B) - `managed-oauth-suite.md` (Track C) - `connector-skills.md` (Track D) - `chat-channel.md` (Track E) - `local-and-aggregators.md` (Track F) - `app-definition-reference.md` (field reference, troubleshooting, provider attribution, proposal template) - Added `.agents/skills/create-connector/SKILL.md` and `.agents/skills/create-connector/brief-template.md` implementing the one-command connector workflow with three explicit human Stop Gates. - Updated `doc/connections/README.md` to link the modular playbook, track guides, and `create-connector` skill. ## Verification - Verified all relative markdown links across all 11 created/modified files resolve to existing files with zero broken links. - Verified `git diff --check` passes cleanly on all modified and added files. - Confirmed all existing inbound anchors to `CONNECTOR-PLAYBOOK.md` (`#step-9-align-with-production-validation`, `#chat-channel-connectors`, `#question-experience-inventory`, `#retain-inspectable-per-format-evidence`) remain intact. ## Risks - Low risk: documentation and agent-skill changes only; no runtime, schema, or UI code is modified. ## Model Used - Google Gemini (Antigravity agentic coding assistant, tool use and code execution enabled) ## 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 - [ ] 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> |
||
|
|
176cb8eee2 |
test(e2e): retain safe Skill Studio failure steps (#23108)
## Thinking Path > - Paperclip lets people manage agents and their saved work. > - Product E2E tests check a skill from creation through a saved Studio edit. > - A browser failure can happen after the agent completes its work. > - The report replaces each raw browser error with one general failure code. > - That code does not show which Studio step failed. > - This change keeps a fixed step code and excludes raw browser data. ## Linked Issues or Issue Description **What happened?** A skill edit journey can fail after skill creation passes. Its saved result has only `journey_operation_failed`. It cannot distinguish a missing task card from an unloaded file or a failed save. Raw browser errors can contain private content, so copying those errors into reports is unsafe. **Expected behavior** Keep a fixed code for the failed step. Keep the failed grade. Exclude browser messages, URLs, skill contents and nested error causes. **Steps to reproduce** Run the shared browser helper with a missing skill card or an editor whose saved file never loads. Before this change, both errors lose their step when the Product E2E report grades them. Refs #18305, which fixed delayed file loading and is already present. #19095 changes a separate frozen catalog observer. Neither supplies these shared journey failure codes. This patch does not establish the cause of an earlier hosted failure. ## What Changed - Give the shared Studio helper a closed set of step codes. - Keep the original browser actions, assertions and save/readback checks. - Test a missing card and an unloaded file with real Chromium. - Check that the normal journey failure formatter keeps the code and drops private error text. - Document the report codes. Classic and Cloud callers share the helper. ## Verification - On the old code, the browser suite had 2 failures and 2 passes. The failures exposed the missing step codes. - With the repair, all 4 browser checks pass. Immediate and delayed file loading still preserve the original content, save the edit, reload and read it from the task card. An unloaded file still receives no input or save. - All 5 `journey-failure.test.ts` checks pass. The new case runs the helper and the real failure formatter together. - Commands: `pnpm exec playwright test --config tests/runner-e2e/playwright-support.config.ts skill-studio-flow.spec.ts`; `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts journey-failure.test.ts`. - `pnpm test:e2e:runner:typecheck` passes. Current-head CI and reviews remain required. - `pnpm verify` could not select tests: the managed Git storage guard rejects `git ls-files`. This is not a pass. Focused commands ran directly. - These are controlled browser checks on Linux with synthetic data. No hosted provider run, staging recovery or full-plan pass is claimed. ## Risks The code names identify a failed step. They do not establish its root cause. The helper drops raw errors and their causes to protect private data. The change affects both callers of this shared helper. It adds no retries and changes no selectors, deadlines, grades, selected cases or protected pins. ## Model Used OpenAI Codex, GPT-6 family, with reasoning and code execution. The host does not expose the exact runtime model ID or context-window size. ## 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 - [ ] 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> |
||
|
|
f14929d21b |
test(e2e): retain bound question-run failure evidence (#23041)
## Thinking Path > - Paperclip helps people manage AI agents for work. > - Product E2E tests check real tasks and their saved results. > - The question journey must keep evidence when an agent run fails. > - It currently rejects that run before the first stable checkpoint is saved. > - The private report then has checks but no run failure code. > - This PR saves a small, bound failure receipt before rejection. > - The test still fails. The receipt helps the next diagnosis. ## Linked Issues or Issue Description **Describe the bug** When a native run fails before the first question checkpoint, `readClarificationState` throws `agent_run_failed`. The final `clarification.json` has no checkpoints. The report cannot show the run's machine error code. **Steps to reproduce** 1. Give the question journey an owned native task with a terminal failed run. 2. Read the first question state. 3. Inspect the private report after the journey fails. **Expected behavior** Keep a private receipt with the bound task and run IDs, status, and machine error code. Preserve the failed verdict and the empty checkpoint list. **Additional context** This repairs missing evidence. It does not repair or establish the cause of an agent failure. The reference-grading repair in #22949 is separate and remains unchanged. ## What Changed - Split binding checks from outcome checks in the shared journey validator. Check every run's company, task, agent, model, and environment before retaining a failure. Existing consumers still use the full validator. - Save `clarification-run-failure.json` in the private story directory when the question journey rejects a failed run. Keep only IDs, status, and a bounded machine code. Exclude raw errors, prompts, and provider state. - Keep the original failure if the receipt write fails. Add a fixed secondary cause code. - Add failure, binding, privacy, and final-grading regressions. Document the private receipt. ## Verification - Red: the initial regression had 6 failures and 4 passes on the old code. It reproduced the lost receipt and the first-error binding gap. - Green: 175 tests in 9 affected agent and clarification support files pass with the repository's Product E2E Vitest config. - `pnpm test:e2e:runner:typecheck` passes. - `pnpm verify` could not select tests. The managed Git storage guard rejects `git ls-files`. The focused checks above ran directly. Final CI must supply its required coverage. - The journey regression calls the real observer and validator, saves the private files, and reads them after final grading. It checks that all 11 checks still fail and no question checkpoint is invented. The task-creation UI boundary is simulated. - No live provider run was started. This is local report-path evidence, not a new staging pass. The reviewed harness must be adopted and checked through the authorized QA process after merge. ## Risks Low scope. Only Product E2E support code and its docs change. The shared validator now checks all bindings before it reports the first failed outcome. Foreign evidence still fails closed. The existing outcome, run limit, cancellation, and recovery checks remain in place. The private receipt is not added to the public report. ## Model Used - OpenAI Codex, based on GPT-6, with reasoning, tools, and code execution. This run does not expose a more specific provider model ID. ## 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 - [ ] 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> |
||
|
|
ab099dc379 |
feat(plugin-sdk): declare supported adapters per environment driver (#22827)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Environment plugins can run agent tasks on remote computers, and can run the provider sign-in for those computers > - Core decides which adapters can sign in on a plugin environment from a fixed Claude and Codex rule and a `supportsCodexLogin` flag > - A plugin cannot say which adapters it supports, so Grok has no sign-in on a plugin computer, and a plugin can run an adapter that it cannot sign in > - This pull request lets a Runner task driver declare its supported adapters, and makes support mean the full adapter lifecycle: runs and, where Paperclip offers one, sign-in > - The benefit is one extensible support contract per driver, with no partial matrix, and Grok subscription sign-in on plugin computers ## Linked Issues or Issue Description **Subsystem affected** Plugin SDK environment drivers, plugin sign-in (login pseudo-terminal), plugin Runner task credentials, and agent Runner selection. **Problem or motivation** Core allows plugin-computer sign-in only for Claude, and for Codex when the plugin can read back a credential file. The flag for that is named `supportsCodexLogin`, which does not describe what it does. A plugin cannot advertise which adapters it supports. Grok has a device sign-in in Core, but it has no sign-in on a plugin computer, and a Grok subscription cannot reach a plugin task. A plugin can also run an adapter that has no sign-in on that plugin. This gives a partial support matrix. **Proposed solution** A Runner task driver declares `supportedAdapters`. Support for an adapter means the full lifecycle. The driver must run the adapter, and it must run the Paperclip sign-in when the adapter has one. Core validates the declaration in the manifest, and Core checks it again against the methods of the running worker. An adapter that fails either check is not offered for sign-in, for save, or for runs. The sign-in contract moves to one shared map, so a new adapter sign-in is one entry in that map. **Alternatives considered** A separate per-capability table (runs, sign-in, credential read-back) was rejected. It permits the partial matrix that this change removes. The existing sign-in map and credential sets already contain the necessary data. **Additional context** Related open pull requests: Refs #14001 (Kubernetes plugin login pseudo-terminal), Refs #21327 (Grok device link in the sign-in UI). ## What Changed - Environment drivers can declare `supportedAdapters`. The manifest is rejected when the list has duplicates, when the driver is not a Runner task driver, or when it lists an adapter that has a Paperclip sign-in and the driver does not declare the login pseudo-terminal with `creationOperationVersion: 1`. - Core removes a listed adapter when the running worker does not implement the methods it needs (task methods, and sign-in methods with credential read-back for file sign-ins). Core logs a warning one time for each removed adapter. - `supportsCodexLogin` is replaced by `loginAdapters`, the adapters that can sign in on that environment. Drivers without `supportedAdapters` keep the current behaviour: Claude, and Codex when the worker reads back credentials. - A new shared sign-in map holds the adapters that Paperclip signs in and where each sign-in leaves its credential (terminal output or a file). Manifest validation, server admission, environment presentation, and the Connections sign-in step use this map. Two hard-coded Claude and Codex lists are removed. - Credential read-back accepts any file sign-in key and returns `{ kind: "auth-file", content }`. - The plugin task credential `codex-auth-json` becomes `{ type: "auth-file", provider: "codex" | "grok", content }`. - A Grok subscription is delivered to plugin tasks as an `auth-file` credential. A refreshed Grok file returns to the account through the existing write-back. The write-back record now stores its provider. - On a driver that lists adapters, Core refuses to save, offer, or submit a Runner harness that is not on the list. The error is `agent_runner_unavailable`. - The SDK README and the plugin environment task and AI connection docs describe the contract. ## Verification - `pnpm --filter @paperclipai/server typecheck`, `pnpm --filter @paperclipai/plugin-sdk typecheck`, and `pnpm --filter @paperclipai/ui typecheck` pass. - Targeted server tests pass: plugin environment driver capabilities, plugin login credential, plugin Runner credentials, plugin task credential write-back (Codex and Grok, with a provider mismatch case), environment task runtime submit gating, agent Runner selection, login environment, login session runtime, device login routes and service, setup token, login command, and adapter routes. - Plugin Runner probe and integration tests pass (run from the repository root). - Shared tests (77) and plugin SDK tests (129) pass, including the new manifest validation cases. - UI AI connection tests (67) pass. - Not run locally: the full suite (CI runs it), a render test for the Connections credential step, and an end-to-end route test for computer device sign-in admission. Unit tests cover that admission. ## Risks - Breaking change for plugins that use the plugin SDK task credential or credential read-back. `codex-auth-json` becomes `auth-file`, and the read-back result kind changes. A plugin must update to the new SDK shapes in the same release. - Plugins that do not declare `supportedAdapters` keep the current behaviour. No warning is logged for them. - `supportedAdapters` applies to Runner task drivers only. Sandbox providers reject the field. Support for sandbox providers is a separate change. - The new-agent screen does not offer sign-in on a plugin computer. That sign-in needs a target computer, and the Connections flow selects it. This is the current behaviour for Claude and Codex. - No migration. The write-back record treats a missing provider as Codex, so records written before this change still work. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, test runs) and extended thinking. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
36c2ad39c8 |
feat(runner): seed ACPX file credentials from a host file (#22843)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Paperclip Runner runs ACPX agents, such as Codex and Grok, in an isolated provider home for each session > - The Runner seeds that home only from an inline credential secret, so a host that keeps the login in a file it owns must copy it into a variable for every session > - The credential observer now writes refreshes back to a named host file (#23340), so a session should also start from that file > - This pull request seeds the isolated home from `PAPERCLIP_ACPX_AUTH_JSON_FILE` and documents the host contract > - The benefit is that a host can keep one login file per account across sessions without giving the provider access to the host's directory ## Linked Issues or Issue Description **Subsystem affected** Paperclip Runner ACPX credential staging, the Runner environment boundary (runnerd and the Rust sidecar transport), and Core's server environment handling. **Problem or motivation** An ACPX Codex or Grok session always stages its `auth.json` into the Runner's isolated home from `PAPERCLIP_ACPX_{CODEX,GROK}_AUTH_JSON_SECRET`. A host that keeps the credential in its own file must copy the file into a variable before each session. **Proposed solution** `PAPERCLIP_ACPX_AUTH_JSON_FILE` names an absolute host file. The Runner validates the file and seeds the isolated home from it; the credential observer writes refreshes back to it. The provider never sees the host path. **Alternatives considered** Point `GROK_HOME` at the host directory, as `PAPERCLIP_RUNNER_PREPARED_HARNESS_HOME` does for Claude. Rejected: the Runner writes its permission policy into `GROK_HOME` for every session, and a shared home would share session history between sessions. **Roadmap alignment** None in `ROADMAP.md`; this extends the Runner's existing ACPX credential staging. **Additional context** Builds on #23339 (write-back rules) and #23340 (observer write-back). ## What Changed - New variable `PAPERCLIP_ACPX_AUTH_JSON_FILE` for ACPX sessions whose agent uses a file credential (Codex, Grok). Any other agent, a relative path, or a combination with the inline secret or the provider API key fails admission. - Seeding reads the host file with the existing source reader (a regular file that is not a symlink, owned by the Runner user, with no group or other access, at most 256 KiB) and checks the Codex or Grok format on the exact bytes it stages. Seeding copies the file and never writes it. - The inline-secret and API-key conflicts are checked at both launch boundaries, runnerd and the Rust sidecar transport, before the environment is filtered, so a secret the allowlist drops still conflicts. - The variable crosses the sidecar boundary only for Codex and Grok and never reaches the provider. Core's server removes it from Runner environments and refuses it as an environment binding, so only the execution host can name a file. - With a host file, the lease keeps the final `auth.json` as `auth-refresh.json` when the provider stops, even when admission fails, and the next lease leaves that file in place. A warm `run.attach` or idle restart therefore cannot discard a refresh made during shutdown before the observer writes it back. - `managedCodexCredentialSourcePath` becomes `managedCredentialSourcePath` and covers Grok. - The Runner README documents the contract in a "Host credential file" section, and the protocol README notes write-back. - No code comments are added, per CONTRIBUTING.md. ## Verification - Runner vitest: `credential-file`, `grok-credentials`, `runtime-host`, `codex-credentials`, `codex-acpx-driver`, `runnerd-codex-transport`, `durable-prp-control-plane` (830 passed). They cover seeding Codex and Grok homes from a host file without exposing its path or changing the host copy; a startup refresh kept for write-back across the next start; ambiguous, relative and malformed files failing admission; the format validators; the runnerd boundary's agent and conflict checks; and the spawn-boundary allowlist. - Server vitest: `native-session-executor` and `heartbeat-project-env` (1609 passed, 7 skipped), covering the variable removed from Runner environments and refused as a binding. - `cargo test -p paperclip-runner-core --test acpx_sidecar_transport` for the sidecar boundary (Codex and Grok receive the path, Claude and a conflicting secret fail closed). - Runner and server typecheck; `cargo fmt -p paperclip-runner-core -- --check`. - Tests trimmed while splitting: the runtime host's unsafe-permission and linked-source cases (the shared reader's own tests cover both) and its Claude case (runnerd and the sidecar refuse Claude first, with their own tests). - Not run locally: clippy, the full Runner workspace tests, and the release and eviction integration suites. CI runs them. ## Risks - Both providers rotate refresh tokens, and a rotated token stops working. Each provider's own coordination stays inside the session's isolated home, and the Runner does not lock the host file. Copies of one sign-in share its refresh token wherever they live, so when two copies refresh separately the later refresh can fail that command or turn, or the provider can revoke the sign-in and the user signs in again. The README describes this and leaves the choice of how many sessions share a sign-in to the host. - The host directory must let the Runner user create and rename files beside the host file. - No migration. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, cargo and vitest runs) and extended thinking. ## 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 - [ ] 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: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8607b27e39 |
feat(runner): write ACPX credential refreshes back to the host's file (#23340)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Runner's credential observer watches an ACPX Codex or Grok session's isolated login and reports refreshes to Core > - The execution host's own copy of the login stays at the token the session started from, so it is spent once the provider rotates its refresh token > - With write-back rules in place (#23339), the observer can return each refresh to a host file the Runner is given > - This pull request has the observer write refreshes back to the file named in `PAPERCLIP_ACPX_AUTH_JSON_FILE` > - The benefit is that a host's login file stays current through every session that uses it ## Linked Issues or Issue Description **Subsystem affected** Paperclip Runner (`runner-core`): the credential observer and the native provider backend's pre-stop poll. **Problem or motivation** A refresh an ACPX Codex or Grok session makes stays in the Runner's isolated home. A host that keeps the login in its own file never receives it, and the next session starts from a token the provider has already rotated. **Proposed solution** When the Runner process names a host file, the observer writes each refresh back to it through the write-back rules, during the session and at close. **Alternatives considered** Write back only once, at session close. Rejected: a long session can refresh several times, and a crash before close would lose every rotated token. **Roadmap alignment** None in `ROADMAP.md`; this extends the Runner's existing credential observer. **Additional context** Builds on #23339. Nothing names a host file until the Runner seeds sessions from one, in the change stacked above this. ## What Changed - With `PAPERCLIP_ACPX_AUTH_JSON_FILE` set, the observer writes each refresh back during the session and at close (the provider's `auth-refresh.json` handoff). Each poll also offers a retained `auth-refresh.json` to the rules even while `auth.json` exists, so a refresh made while an old provider shut down still reaches the host file after a warm `run.attach` or idle restart reseeds the home. Write-back does not wait for an update event's acknowledgement, and a binding without the `observeCredentials` opt-in writes back without emitting events. - The host file seeds the observer's baseline, so a refresh during provider startup is still caught. - A host file that changes during a replacement is decided again at once, up to three times. A kept decision holds only while the host file keeps its stamp, so a repaired or replaced host file is compared again. - A failed write-back, or a host file that keeps changing, fails the poll, and with it the command or turn, with an error that carries no credential. The poll before a stop ignores that failure so the provider still stops; the poll after it reports. - A recovered Runner follows the host file it is given now: it adopts a new one, switches to a changed one, and stops writing back when none is named. Revision, baseline and any pending event are unchanged. - A host file is refused for any session other than an ACPX Codex or Grok one. - Saved observer state gains two optional fields (`host_file`, `silent`), omitted when unset, so existing state loads unchanged. - No code comments are added, per CONTRIBUTING.md. ## Verification - `cargo test -p paperclip-runner-core --lib credential_`: 28 passed. New observer tests cover write-back during the session and at close with and without events; a shutdown refresh written back after a restart reseeds `auth.json`; a failed write-back that fails the poll without the credential in the error and succeeds once the host file is back; a host file repaired after a kept decision receiving the refresh; the binding's path checks, provider checks and seeded baseline; recovery adopting, switching and dropping a host file; and a native Codex home refused. - `cargo test -p paperclip-runner-core --test native_provider_backend`: 47 passed. - `cargo fmt -p paperclip-runner-core -- --check`. - Not run locally: clippy and the full Runner workspace tests. CI runs them. ## Risks - A host file that cannot be written, for example on a full or read-only volume, fails the command or turn that observed it instead of being logged. Such a host is already broken, and failing visibly keeps a rotated refresh token from being lost without notice. - Copies of one sign-in share its refresh token wherever they live. When two copies refresh separately, the later refresh can fail that command or turn, or the provider can revoke the sign-in and the user signs in again. - On non-Unix hosts write-back is unsupported, like the credential observer itself. - No migration. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, cargo runs) and extended thinking. ## 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 - [ ] 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: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2d745cf432 |
feat(runner): decide and write ACPX credential refreshes back to a host file (#23339)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Paperclip Runner runs ACPX agents, such as Codex and Grok, from an isolated copy of their login in each session > - A refresh the provider makes in that copy rotates its refresh token, and the execution host's own copy of the login is then spent > - Returning the refresh to the host's file needs a rule for when the refreshed copy may replace it, and a write that never leaves the file torn or loosened > - This pull request adds those rules and that write, matching Core's local Codex and Grok adapters; nothing calls them yet > - The benefit is that the rule that decides whether a host's login is overwritten can be reviewed on its own ## Linked Issues or Issue Description **Subsystem affected** Paperclip Runner (`runner-core`), a new `credential_write_back` module. **Problem or motivation** An ACPX Codex or Grok session's refreshed `auth.json` stays in the Runner's isolated home. Both providers rotate the refresh token on refresh and refuse a rotated one, so writing a refresh back to a host file must never replace a newer login with an older one, or one account's login with another's. **Proposed solution** A module that decides, under the same rules as Core's local adapters, whether a refreshed login replaces the host file, and that replaces it atomically. A later change has the credential observer call it. **Alternatives considered** - Point the provider at the host's directory (as `PAPERCLIP_RUNNER_PREPARED_HARNESS_HOME` does for Claude), so it refreshes the host file in place. Rejected: the Runner writes its permission policy into the provider home for every session, and a shared home would share session history between sessions. - Write the refreshed file back unconditionally. Rejected: both providers rotate the refresh token and refuse a rotated one, so an older or another account's login must never replace the host's. **Roadmap alignment** None in `ROADMAP.md`; this extends the Runner's existing credential observer and ACPX credential staging. **Additional context** Codex and Grok rotate refresh tokens on refresh. The rules match the Codex and Grok local adapters' own freshness checks, so Core, the Runner and a host that applies the same rules agree on which copy wins. ## What Changed - `write_back(provider, refreshed, host_file, now)` replaces the host file only when both logins name the same account (Codex `tokens.account_id`, Grok's `<issuer>::<uuid>` key) and the refreshed one is strictly fresher: Codex `last_refresh`, at most five minutes ahead of now; Grok `expires_at` in epoch seconds, milliseconds or RFC 3339, at most 400 days ahead. An API key, another account, a tie or an unreadable time keeps the host file. Timestamps are parsed with the `time` crate (already in the lockfile), truncated to milliseconds like `Date.parse`. - Both logins must be at most 256 KiB, the host file's own bound, so a written refresh can always be read back. The host file must exist and be a private regular file owned by the Runner user, opened without following a final symlink. A missing host file is never created. - The replacement is a synced temporary file in the same directory, renamed over the host file with its mode carried over, followed by a directory sync. The host file is private, so its group grants nothing and is not carried over. If the host file changed after the decision read, the replacement is abandoned and reported as `Raced`, so the caller can decide again. - A kept decision carries the host file's stamp (device, inode, size, mtime, ctime), so a caller can tell when the host file changed and the decision no longer holds. - The module is marked `allow(dead_code)` until a caller uses it. It carries no code comments, per CONTRIBUTING.md; this description holds the explanations. ## Verification - `cargo test -p paperclip-runner-core --lib credential_write_back`: 5 passed. - A table of 21 freshness decisions for Codex and Grok: newer replaces (including a timezone offset, epoch seconds, milliseconds and RFC 3339); older, equal at millisecond precision, another account, implausibly far ahead, unreadable, missing expiry and API-key logins are kept. - The replacement is a new inode with the mode and owner kept, and no temporary file remains; a second pass keeps the file. - A missing, symlinked or group-readable host file is never created, followed or written. - A host file replaced after the decision read makes the replacement `Raced`, leaves the new file in place and removes the temporary file. - A refresh one byte over the 256 KiB bound keeps the host file; one at the bound is written. - `cargo fmt -p paperclip-runner-core -- --check`. - Not run locally: clippy and the full Runner workspace tests. CI runs them. ## Risks - None at runtime: nothing calls the module in this change. - The check before the rename is not atomic with the rename, so a small race with an external writer remains; a caller that sees `Raced` decides again. - The host directory must let the Runner user create and rename files beside the host file. - On non-Unix hosts the module reports write-back as unsupported. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, cargo runs) and extended thinking. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
caaa013a69 |
fix(e2e): wait for reset preparation and repository recovery (#23288)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Product E2E tests check real user work through the app and native agents. > - A chat reset gets its reset marker during run preparation. > - The observer can count that active reset as extra model work before preparation ends. > - The repository observer also omits the deadline needed to recognize a scheduled same-run recovery. > - This pull request keeps both observations open until the existing bounded transition completes. > - The final success checks still require the original run counts, saved results, and evidence. ## Linked Issues or Issue Description **What happened?** The chat observer can throw `chat_continuity_extra_run` while `/new` is queued or running without its reset marker. The repository observer throws `agent_run_failed` for an exact-session recovery that the server has already scheduled. **Expected behavior** Observe each transition under the original campaign deadline. Require the same final reset receipt, model turn count, completed repository runs, and artifact checks. An active or failed run must never count as a pass. **Steps to reproduce** 1. Return an unmarked queued or running reset between the second model reply and the completed reset receipt. 2. Run the chat journey observer. Before this change it reports extra model work. 3. Return a bound native repository run with `retryable_failure` and an eligible `retry_scheduled` projection. Before this change the observer rejects it before its scheduled recovery. Related: https://github.com/paperclipai/paperclip/pull/18784 and https://github.com/paperclipai/paperclip/pull/22826. The latter adds the shared recovery rule. This change supplies the repository caller's missing deadline. ## What Changed - Count excess unmarked provider runs after they succeed. Keep the existing reset count, scope, run cap, deadline and final grading checks. - Supply the repository campaign deadline to the existing native recovery validator. - Add observer regressions for queued and running reset preparation, completed extra work, immediate failed/cancelled rejection, scheduled repository recovery through success, exhausted or late recovery and the original deadline. ## Verification - Chat regression before the fix: 2 failed and 16 passed. Both failures report `chat_continuity_extra_run`. - Repository regression before the fix: 2 failed and 1 passed. Both failures report `agent_run_failed`. - After the fixes: 109 tests pass in five affected observer, grading and recovery files. - `pnpm test:e2e:runner:typecheck` passes on the final source. - `pnpm verify` cannot select tests because the managed Git storage guard rejects `git ls-files`. The focused command above supplies local test evidence. Final-head CI 46425283547 passes the selected Runner support, package, static, typecheck, policy and verification gates. General/build jobs are path-skipped. - The real observer functions ran with simulated API/browser boundaries. No new hosted provider run or deployment was made. A fresh hosted journey with the reviewed harness is still required for staging acceptance. ## Risks The chat observer can wait longer before it rejects active extra work. The original deadline and four-run cap still bound it. A completed extra provider run remains fatal. Failed or cancelled chat runs already fail in the reader before the excess-work predicate; tests prove first-read rejection with no new message. Repository recovery uses the existing shared eligibility rules; terminal, exhausted, foreign or late recovery still fails. This change does not repair or explain an underlying provider timeout. No prompt, grading rule, test selection, budget, pin or production behavior changes. ## Model Used OpenAI Codex, GPT-6 family, with reasoning and code execution. The exact model build is not exposed in this session. ## 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> |
||
|
|
00a792999c |
test(e2e): retain failed agent-settings task identity (#23371)
## Thinking Path > - Paperclip lets people manage agents and their saved work. > - Product E2E tests check whether saved agent instructions affect the next task. > - A failed work run must keep a failed test result. > - The observer currently saves task identity only after the task completes. > - A failed run leaves no task or run ID in its retained settings evidence. > - This change saves the observed identity before the failure check. > - Engineers can then find the failed run without storing raw instruction or provider data. ## Linked Issues or Issue Description **What happened?** The saved-instructions journey reads a failed native run and throws `agent_settings_native_run_failed`. Its private report then writes `issueId: null` and `runIds: []`. The observer already read the task and run, but loses their identity because it fills completed evidence only after a successful wait. **Expected behavior** Keep the created task ID, requested run IDs and observed status/native phase. Keep the test failed. Do not record instruction text, raw errors, output excerpts, account configuration or provider payloads. **Steps to reproduce** Run the existing agent-settings flow fixture with a failed native run. Read `agent-settings-observations.json`. Before this change its task ID is null. The new regression fails on that value. A denied run-detail read also loses its requested identity. Related work: #23041 retains question-journey failure evidence. #23108 adds Skill Studio browser-step codes. #23288 changes reset and repository observation waits. None covers the saved-instructions observer. This change does not repair the underlying native run failure. ## What Changed - Keep the created task identity before the first task observation. - Save requested run IDs before detail reads. Keep status and native phase from each completed read. - Keep this diagnostic separate from completed evidence and all grading checks. - Test failed runs, denied detail reads, successful completion and raw-data exclusion. - Document the private evidence fields. ## Verification - The new failed-run assertion failed before the fix: expected task ID `task`, received null. The other nine flow checks passed. - After the fix, 89 checks pass in `agent-settings-flow.test.ts`, `agent-settings-evidence.test.ts` and `observation-read.test.ts`. - Command: `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts` with those three files. - `pnpm test:e2e:runner:typecheck` passes on the final source. - The real observer and private file writer ran on Linux with simulated browser/API boundaries. Failed work still fails. A denied detail read keeps an empty observed-runs list. No second settings save occurs after either failure. - `pnpm verify` could not select tests because the managed Git guard rejects `git ls-files`. This is not a pass. Preflight installed dependencies and built required packages, then could not find Cargo. Focused checks ran directly. - No hosted provider rerun or deployment was made. Local evidence does not establish a staging pass. Hosted acceptance requires approved harness adoption. - Final-head CI and automated reviews are pending. ## Risks The new record contains private task/run IDs and lifecycle fields. It uses an explicit field projection and does not copy the full run object. It cannot make a pending or failed run pass. The change adds no work runs, retries, requests, settings edits or budget. Existing grading, cleanup and public projection remain in place. This is a reporting repair; the underlying provider or infrastructure cause remains open. ## Model Used OpenAI Codex, GPT-6 family, with reasoning, tool use and code execution. The runtime does not expose an exact model ID or context-window size. ## 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 - [ ] 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> |
||
|
|
3f80675409 |
fix(workspaces): report git's failure when archive git stops reading input (#23358)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip saves a remote agent workspace as an archive. A worker thread makes the archive and copies each Git repository into it. > - The worker sends all source refs to `git update-ref --stdin`. Git can stop before it reads all of this input, for example when it rejects a ref update or when it is stopped. > - The write to git's input then fails with `EPIPE`. The input stream had no `error` listener, so the error was uncaught in the worker thread. The worker stopped, and the capture failed with `write EPIPE` instead of git's own error. > - Sentry recorded this as an unhandled `write EPIPE` from a server worker thread on staging. > - This pull request adds an `error` listener on git's input in the archive `git()` helper. The helper reports git's exit failure. It reports the input error only when git exits with success. > - The benefit is that a failed capture shows the real Git failure and does not crash the archive worker. ## Linked Issues or Issue Description Refs #20813 Refs #21068 (draft). That PR adds the same kind of listener to six other call sites, and since `6ede87b` also to this line. This PR changes only the archive worker and adds a test that goes through the real worker thread. If #21068 merges first, rebase it to drop its hunk in `remote-workspace-snapshot-archive.ts`, or keep this change. **What happened?** A workspace capture failed with `Error: write EPIPE` from the archive worker thread. The real `git update-ref --stdin` failure was not reported. **Steps to reproduce** 1. Make a Git repository with about 3000 refs, so that the ref list is larger than a pipe buffer. 2. Put a `git` on `PATH` that exits with code 128 on `update-ref` and does not read its input. 3. Capture the directory with `captureRemoteWorkspaceDirectory`. **Expected behavior** The capture fails with the `update-ref` error (exit code 128). **Actual behavior** The archive worker stops with an uncaught `write EPIPE`, and the capture fails with `write EPIPE`. ## What Changed - `server/src/services/remote-workspace-snapshot-archive.ts`: the `git()` helper listens for `error` on the child's stdin before it writes. It rejects with git's exit error. It rejects with the input error only if git exits with success. - `server/src/services/remote-workspace-snapshot-archive-git-stdin.test.ts`: a new regression test. It captures a repository with 3000 refs through the real archive worker thread. A `git` shim closes its input and exits 128 on `update-ref`. The test expects git's error (code 128, message has `update-ref`) and no `EPIPE`. ## Verification - Red before the fix: `npx vitest run src/services/remote-workspace-snapshot-archive-git-stdin.test.ts` (in `server/`) failed with `expected 'write EPIPE' not to match /EPIPE/u`. - Green after the fix: the same test passed 3 times in a row. - The test uses `git --exec-path` to find the real git binary, so it does not depend on a git wrapper on `PATH`. - `pnpm verify` selected 1984/2340 files (most of the suite), so the broad coverage comes from required CI. ## Risks - Low risk. Only the archive `git()` helper changes. Calls without input are not changed. - A git call that exits with success but did not read all of its input now fails. Before, the uncaught error stopped the worker in that case too. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), through Claude Code with tool use and code 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 - [ ] I have updated relevant documentation to reflect my changes (not applicable: no behavior or command docs change) - [x] 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 - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>canary/v2026.1201.0-canary.875000 |
||
|
|
ea56320e10 |
feat(board): add headless channels, fenced task queues, paperclipai/sdk, and pc CLI (#23330)
<!-- Write all pull request text in Simplified Technical English (ASD-STE100): short sentences, one instruction per sentence, simple approved vocabulary, and the active voice. --> ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Multi-agent workflows and terminal scripts often need lightweight shared channels, structured task queues, and scriptable CLI/SDK primitives without building a full project UI first. > - Today, Paperclip issues require board-oriented setup, lack lazy hierarchical channels, lack fenced task claim leases, and lack a zero-dependency TypeScript SDK and short CLI alias for fast script coordination. > - Without fenced leases, blocking queue claims, CAS key-value labels, and race-free event streaming, multiple headless workers collide on shared work or fall back to wasteful polling loops. > - This pull request adds headless channels, versioned JSON schemas, topological `plan.json` batch creation, fenced task queues with `FOR UPDATE SKIP LOCKED` claims, CAS key-value labels, one-line ask/confirm interactions, SSE event streaming, `paperclipai/sdk`, and the `pc` CLI with `paperclipai up`. > - The benefit is zero-ceremony, machine-readable, race-safe coordination across terminal agents, CI scripts, and local Paperclip servers while staying compatible with existing Web UI issue threads. ## Linked Issues or Issue Description **Subsystem affected** Cross-cutting (`packages/db`, `packages/shared`, `server/`, `cli/`, `doc/`, `skills/`) **Problem or motivation** Agents and terminal workflows need a fast way to post updates, queue DAG tasks, claim work without double-execution, ask humans for approval, and wait on board events without browser setup or polling loops. Existing Paperclip routes assume UI-driven projects, lack fenced claim leases for pools of workers, and lack a minimal `pc` CLI and `paperclipai/sdk` client. **Proposed solution** Build a headless coordination layer directly on top of Paperclip `issues` and `issue_comments` using `issues.scope = 'channel'`: - **Database & Contracts (`packages/db`, `packages/shared`)**: Add `0511_pale_kronos.sql` (`issues.scope`) and `0512_stormy_the_hood.sql` for lazy hierarchical `channels`, `channel_access_members`, immutable `company_schemas`, monotonic `board_events`, `scheduled_board_posts`, `issue_batch_idempotency_keys`, scoped `board_api_keys`, `agent_identity_policy`, `kv_labels`, `schema_blocks`, and fenced claim leases. Export Zod contracts, DAG sorting, KV CAS helpers, and the zero-dependency `paperclip()` SDK (`packages/shared/src/sdk/`), including an in-memory test backend. - **Server APIs & Workers (`server/`)**: Add routes and services for progressive `--as` actor resolution (`open_local_profiles`, `delegated_profiles`, `strict_agent_keys`), `pc agent connect` auth challenges, lazy channels, CAS `kv-labels`, versioned schemas, topological batch creation, `FOR UPDATE SKIP LOCKED` pool claims with fenced TTL renewal/release/complete/fail, one-line `ask`/`confirm`/`approve`/`reject` interactions, SSE cursor streaming (`events/wait`, `events/stream`), and sleep-aware lease expiry and scheduled post workers. - **CLI, Launcher & Docs (`cli/`, `doc/`, `skills/`)**: Expose the `pc` binary alias and `paperclipai/sdk` export, add the zero-prompt `paperclipai up` / `pc up` local launcher, add `pc` commands (`post`, `reply`, `read`, `channels`, `label`, `tasks`, `ask`, `confirm`, `approve`, `reject`, `schemas`, `schedule`, `tail`, `wait`, `agent connect/login`), add documentation (`doc/CHANNELS-AND-QUEUES.md`, `doc/CLI.md`, `doc/HEADLESS-TUTORIALS.md`), and add `skills/paperclip-lite/SKILL.md`. **Alternatives considered** - **Separate message and queue tables outside `issues`**: Rejected because channel posts and queued tasks would lose Paperclip identifiers (`PC-1`), comments, attachments, privacy ACLs, and direct Web UI issue URLs (`/<prefix>/issues/PC-1`). - **Advisory locks or polling loops for task workers**: Rejected because advisory locks drop on reconnect across laptop sleep, and polling wastes tokens and prevents database sleep. Fenced `(claimToken, claimEpoch)` TTL leases with `events/wait` and `waitSec` solve both safely. **Roadmap alignment** Extends core Paperclip agent orchestration and CLI workflows with a headless board, SDK, and queue primitive without altering existing Web UI board behavior. **Additional context** This PR builds on the `issues.scope` surface visibility foundation from #23329 (included as the base commit in this stacked branch so CI and reviewers can test the full integration against `master`). ## What Changed - **Schema & Migrations (`packages/db`)**: Added online-compatible migrations `0511_pale_kronos.sql` and `0512_stormy_the_hood.sql`, schema definitions (`channels.ts`, `company_schemas.ts`, `headless_board.ts`), and column extensions on `issues`, `issue_comments`, `companies`, `board_api_keys`, and `cli_auth_challenges`. - **Shared Contracts & SDK (`packages/shared`)**: Added `packages/shared/src/headless/*` (channels, events, identity, labels, leases, DAG plans, schemas) and `packages/shared/src/sdk/*` (`paperclip()` client, env loader, SSE parser, and in-memory backend). - **Server Routes & Services (`server/`)**: Added `headless-channels-schemas.ts`, `headless-queues-events.ts`, `headless-identity.ts` routes and supporting services (`headless-channels.ts`, `headless-common.ts`, `headless-events-schedules-interactions.ts`, `headless-identity.ts`, `headless-labels-batch.ts`, `headless-schemas.ts`, `headless-task-queue.ts`), plus `issues.scope` visibility isolation and `board-auth.ts` extensions. - **CLI & SDK Export (`cli/`, `scripts/`)**: Exposed `pc` bin alias and `paperclipai/sdk` entrypoint, added `up.ts` zero-prompt launcher and `cli/src/commands/board/*` commands (`post`, `reply`, `read`, `channels`, `label`, `tasks`, `ask`, `confirm`, `approve`, `reject`, `schemas`, `schedule`, `tail`, `wait`, `agent`). - **Docs, Skill & Runner Registry (`doc/`, `skills/`, `tests/runner-e2e/`)**: Added `doc/CHANNELS-AND-QUEUES.md`, `doc/CLI.md`, `doc/HEADLESS-TUTORIALS.md`, plan docs, `skills/paperclip-lite/SKILL.md`, and synchronized `tests/runner-e2e/source-sdk-public-inputs.json`. ## Verification - `pnpm --filter @paperclipai/shared build` — passed. - `pnpm --filter @paperclipai/db check:migrations` — passed (`0511_pale_kronos.sql` and `0512_stormy_the_hood.sql` verified online-compatible, 2 new migrations since `630cf0423024`, none blocked). - `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse HEAD) --check` — passed (`598` inputs, `changed: false`). - `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/source-sdk-public-inputs.test.mjs` — 13/13 tests passed. - `node scripts/check-maps.mjs` — passed (`35` areas, `192` capability IDs aligned). - `pnpm exec vitest run packages/shared/src/headless/headless.test.ts packages/shared/src/sdk/sdk.test.ts cli/src/__tests__/headless-board-cli.test.ts` — 3 files, 22/22 tests passed. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/issue-scope-visibility.test.ts src/__tests__/headless-channels-schemas-batch.test.ts src/__tests__/headless-identity-auth.test.ts src/__tests__/headless-queues-leases-events.test.ts src/__tests__/headless-e2e-sdk-cli.test.ts` — 5 files, 25/25 tests passed. - `pnpm --filter @paperclipai/shared typecheck && pnpm --filter @paperclipai/db typecheck && pnpm --filter @paperclipai/server typecheck && pnpm --filter paperclipai typecheck` — all passed. - `pnpm --filter paperclipai build` — passed. ## Risks - **Two new migrations (`0511`, `0512`)**: Both migrations are marked online-compatible (`NOT VALID` constraints validated afterwards, `CONCURRENTLY` index creation, idempotent statements for non-transactional execution) and checked by `check:migrations`. If #23329 lands separately with `0511` modified or renumbered, this branch will rebase on top cleanly. - **Large surface area (91 files)**: Changes are primarily additive new modules (`headless-*`, `cli/src/commands/board/*`, `packages/shared/src/headless/*`, `packages/shared/src/sdk/*`); existing Web UI board behavior remains isolated via `issues.scope`. - **Full repository Vitest suite**: Only the targeted headless, SDK, CLI, server, and runner-e2e pin suites ran locally after rebasing; full cross-package CI checks will validate the remaining suite. ## Model Used - Google DeepMind Antigravity (Gemini coding agent) with tool use and code 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 - [ ] 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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing>canary/v2026.1201.0-canary.874900 |
||
|
|
43fedd51c5 |
fix(opencode): record kernel OOM evidence when opencode serve is SIGKILLed (#23372)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The native Runner starts `opencode serve` for each OpenCode agent turn and reads its event stream. > - Sometimes `opencode serve` dies by SIGKILL in the middle of a turn. The run then fails with `opencode_server_exited`. > - The failure record shows `signal: SIGKILL` and `ECONNREFUSED`, but it does not show who sent the signal. > - A SIGKILL alone does not prove a kernel OOM kill. Recent failures were short turns with few or no tool calls, so the cause is not clear. > - This pull request records the kernel cgroup v2 OOM evidence when `opencode serve` dies by a signal. > - The benefit is that the next failure tells us if the kernel memory limit killed OpenCode or if something else did. ## Linked Issues or Issue Description Refs #17398 (the Legacy OpenCode adapter makes sandbox tool commands the first OOM victims). Refs #16844 (the same protection for Claude). **What happened?** On a cloud sandbox, a native OpenCode turn failed with `opencode_server_exited`. The run failure record had `streamFailure: server_exited`, `signal: SIGKILL` and `connectionError: ECONNREFUSED`, and `timeoutFired` was false. The Runner process stayed alive. The Runner sends SIGKILL to OpenCode only at shutdown or at a failed start, so the signal came from outside the Runner. The record has no kernel memory evidence, so we cannot tell if the kernel OOM killer sent it. **Expected behavior** When `opencode serve` dies by a signal, the failure record says if the kernel recorded an OOM kill in its cgroup after launch. It also gives the memory limit and the peak use. **Steps to reproduce** 1. Start a native OpenCode turn in a Linux sandbox that uses cgroup v2. 2. Send SIGKILL to the `opencode serve` process while the turn runs. 3. Read `resultJson.nativeTurnFailure` for the failed run. Before this change, it has no memory evidence. **Paperclip version or commit** `master` atcanary/v2026.1201.0-canary.874800 |
||
|
|
6678554a5a |
fix(heartbeat): retry setup when project storage is still being prepared (#23362)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - Before a run starts its provider, Paperclip prepares the task
workspace through a workspace provider plugin.
> - A provider can answer a polled preparation with the closed reason
`storage_pending`. This means that the project's storage is still being
prepared. The provider gives this answer before any workspace effect.
> - Setup recorded this answer as a generic `setup_failed`. It scheduled
no retry. The task waited for a person to press Retry, and Sentry
received an error for each attempt.
> - This pull request gives the answer its own transient setup code,
`workspace_storage_pending`. Setup then retries the same workspace
within the bounded bootstrap budget.
> - The benefit is that a task continues by itself when the project's
storage becomes ready, and Sentry gets a report only when no retry owns
recovery.
## Linked Issues or Issue Description
Refs #19249 (the same retry for a stopped plugin worker)
Refs #21510 (the same deferred Sentry report for a saved-sandbox resume
outage)
**What happened?**
On staging, runs failed in the preparing stage with "Project storage is
still being prepared; retry the same workspace shortly". Each run waited
about 3.5 minutes in the polled preparation. Then the provider answered
`storage_pending`. The run got `setup_failed` with
`workspaceProviderFailure: { kind: "provider", reason:
"storage_pending", retryable: true }` and `executionRecovery: { kind:
"bootstrap", providerWorkStarted: false }`. No retry was scheduled. A
person pressed Retry several times, and each attempt sent a new Sentry
error.
**Expected behavior**
No workspace effect or provider work started, and the provider marks the
reason retryable. The run must retry within the bounded bootstrap
budget, as it does for `plugin_worker_unavailable`. Sentry must get a
report only when no retry is scheduled.
**Steps to reproduce**
1. Use a project whose workspace storage is still being provisioned.
2. Wake an agent whose legacy run prepares a workspace through that
provider.
3. The provider answers `storage_pending` at the end of its wait. The
run fails with `setup_failed`. No retry is scheduled.
**Paperclip version or commit**
master at
canary/v2026.1201.0-canary.874700
|
||
|
|
b3fd921cfb |
test(browser-use): keep the capture-month rollover test ahead of the database clock (#23363)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents can use Browser Use Cloud. Paperclip records its usage cost
in the cost ledger and the monthly budget.
> - A server test checks that a usage change after a UTC month rollover
goes into the correct month. The test uses a fixed fake clock:
2026-11-30T23:59:59.900Z, then 2026-12-01T00:00:00.100Z.
> - Browser Use sessions get `next_poll_at` from the database `now()`.
The poll compares that value with the fake JavaScript clock.
> - After the real time passed 2026-11-30T23:59:59.900Z, the fake clock
was behind the database clock. The poll did not select the session, so
the test failed.
> - The test fails on every `master` commit since 2026-12-01. The
post-merge Cloud readiness check fails, the Core Docker image build
stops, and staging cannot get new Core commits.
> - This pull request calculates the rollover from the next UTC month
boundary after the real time. The fake clock is always ahead of the
database clock again.
> - The benefit is that `master` image builds and staging deploys can
continue. The test still checks the same month rollover.
## Linked Issues or Issue Description
**What happened?**
`server/src/__tests__/browser-use-connection.test.ts` > "dates a new
cumulative delta in its capture month and keeps that receipt's retry
time stable" fails on current `master`. The error is `expected { …(15) }
to match object { eventsDrained: +0, result: { …(1) } }`. The budget
hold shows `amountCents: "0.0000000"` and has no `accountedCentsExact`
or `receipt`, so the first usage report (0.15 USD) was not accounted.
**Expected behavior**
The test passes on any date. A test with a fake clock must not depend on
the real date.
**Steps to reproduce**
1. Check out `master` (for example
canary/v2026.1201.0-canary.874600
|
||
|
|
743c18f3b2 |
fix(ui): drop errors thrown by browser extension scripts from browser Sentry (#23357)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The browser UI sends unhandled errors to Sentry through `ui/src/lib/sentry.ts` > - Browser extensions run their own scripts in the page. The Sentry SDK wraps their event listeners, so an extension error is reported as a Paperclip error > - The Jam bug-capture extension listens for the Navigation API `navigate` event. When its recorded network events become too large, its listener throws `RangeError: Invalid string length` from `JSON.stringify` > - No Paperclip code is at fault. These reports are noise and hide real errors > - This pull request drops errors that extension code threw, with the built-in Sentry `denyUrls` option > - The benefit is fewer false error reports. Errors that Paperclip code throws are still sent, also when an extension frame is lower on the stack ## Linked Issues or Issue Description **What happened?** Hosted staging browser Sentry recorded one unhandled `RangeError: Invalid string length`. A Paperclip link click called React Router's `History.pushState`. The browser then fired the Navigation API `navigate` event. The Sentry `BrowserApiErrors` wrapper caught the error from a listener that the Jam extension added. The top frames are `JSON.stringify (<anonymous>)`, then `re.addMany`, `t2.persistEphemeral` and `t2.beforeNavigation` in `webpack://jam-extension/injected-scripts/host-network-events.js`. A second Sentry group with the same title and the same trace is already ignored by hand. **Steps to reproduce** 1. Install the Jam bug-capture extension and let it record network events on a Paperclip page for a long time. 2. Click a Paperclip link that navigates in the app. 3. See `RangeError: Invalid string length` in the browser Sentry project. **Expected behavior** Sentry does not record errors that a browser extension's own script throws. **Actual behavior** Sentry records them as unhandled Paperclip errors. Related: #22378 (the same kind of filter for Firefox for iOS injected scripts). No duplicate PR was found (searched for `denyUrls`, `jam-extension`, and "browser extension sentry"). ## What Changed - `ui/src/lib/sentry.ts`: add the exported `BROWSER_EXTENSION_SCRIPT_URLS` list and pass it to `Sentry.init` as `denyUrls`. The list holds the `chrome-`, `moz-`, `safari-`, `safari-web-` and `ms-browser-extension://` URL schemes and Jam's `webpack://jam-extension/` script URL. A comment tells why. - `ui/src/lib/sentry.test.ts`: add a test with the real Sentry SDK. It sends the reported Jam stack and a `chrome-extension://` stack, and makes sure that Sentry drops them. It also sends an app error with a Jam frame lower on the stack and a plain app error, and makes sure that Sentry keeps them. Add an options test for which URLs are denied and which are not. - `doc/observability.md`: describe the filter next to the `__firefox__` note. ## Verification - `cd ui && pnpm exec vitest run src/lib/sentry.test.ts src/lib/browser-error-context.test.ts`: 66 passed. - Without the `ui/src/lib/sentry.ts` change (tests kept), the 2 new tests fail. With the change, all 45 tests in `sentry.test.ts` pass. - `@sentry/core` 10.71.0 `eventFilters` reads the innermost frame whose file name is not `<anonymous>` or `[native code]`. For the reported event, that is the Jam script URL. - `cd ui && pnpm exec tsc --noEmit -p .`: no errors in the changed files. The local tree has only errors from an unbuilt plugin SDK and missing generated Storybook files. CI covers the full typecheck. ## Risks - Low risk. The filter matches only the frame that threw. An extension that throws from its own script while it runs Paperclip code would also be dropped, but such an error is not a Paperclip bug. - A Paperclip error is not dropped when an extension frame is lower on the stack. A test covers this. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code execution 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 - [ ] 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: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
acb52955b7 |
fix(issues): lock the issue before the run when adopting an unowned checkout (#23355)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents change tasks through the issue routes. Before each change, the server checks that the agent's run owns the task's checkout (`assertCheckoutOwner`). > - This check clears terminal run locks and can adopt a checkout. Each step uses a short transaction that locks rows. > - The clears and the stale adoption lock the issue first and then the heartbeat run. The unowned-checkout adoption locked the run first and then updated the issue. > - Two requests for the same task can then wait on each other. PostgreSQL stops one with `deadlock detected`, and the agent's change fails with a 500. > - This pull request makes the unowned-checkout adoption lock the issue before the run. > - The benefit is one lock order (issue, then run) in all checkout ownership paths. Concurrent requests now wait in turn and do not deadlock. ## Linked Issues or Issue Description **What happened?** A hosted staging server reported `Error: Failed query: select "heartbeat_runs"."id" from "heartbeat_runs" where "heartbeat_runs"."id" = $1 for update`. The chained cause was `PostgresError: deadlock detected` (40P01). The stack was `assertAgentIssueMutationAllowed` → `assertCheckoutOwner` → a transaction that locks a heartbeat run. **Steps to reproduce** 1. Make an `in_progress` task with an agent assignee, no `checkoutRunId`, and a live `executionRunId` (run A). 2. Run A calls an issue mutation. `assertCheckoutOwner` adopts the unowned checkout: it locks run A, then updates the issue. 3. At the same time, another run of the same agent (run B) calls an issue mutation. `clearExecutionRunIfTerminal` locks the issue, then waits for run A. 4. PostgreSQL detects the cycle and stops run B's request. **Expected behavior** Run A adopts the checkout. Run B gets an ordinary 409 ownership conflict. **Actual behavior** Run B's request fails with a 500 that wraps `deadlock detected`. No public GitHub issue exists. Related earlier work: #5413 and #4258 (they added the adoption paths). No open PR fixes this deadlock. ## What Changed - `adoptUnownedCheckoutRun` in `server/src/services/issues.ts` now locks the issue row (`FOR UPDATE`) before it locks the actor's heartbeat run. This is the same order that `clearExecutionRunIfTerminal`, `clearCheckoutRunIfTerminal`, and `adoptStaleCheckoutRun` use. - New test `server/src/__tests__/issue-checkout-adoption-lock-order.test.ts`. It pauses the adoption inside its transaction, starts a concurrent ownership check from a second run, and expects no deadlock. ## Verification - Red: without the fix, the new test fails. The second request rejects with `PostgresError 40P01 deadlock detected` on `select "heartbeat_runs"."id" ... for update`. This is the same error that Sentry reported. - Green: with the fix, the new test passes. Run A adopts the checkout, and run B gets a 409. - `npx vitest run src/__tests__/issue-checkout-adoption-lock-order.test.ts` (server): 1 passed. - `npx vitest run src/__tests__/issues-service.test.ts -t "checkout|adopt|ownership"` (server): 14 passed. ## Risks - Low risk. The adoption transaction now also takes the issue row lock. The transaction then updates the same row, so it already needed this lock. The only change is the order of the locks. - No schema, API, or UI change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) through Claude Code, with tool use and code 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 - [ ] All Paperclip CI gates are green - [ ] 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: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0666aff4a4 |
fix(workspaces): clone network repositories blobless in remote sandboxes (#23347)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A Paperclip Runner task in a Cloud sandbox gets a fresh workspace: the server clones the task's repositories into the sandbox before the agent starts > - The clone is a full clone, so it downloads every historical blob. A full clone of `paperclipai/paperclip` now grows the disk by about 856 MiB > - The Cloud sandbox wraps Git in a storage guard. The guard stops one Git command when the net disk growth gets to 1 GiB, and the growth includes other writers on the same disk > - On hosted staging, the clone now stops with `stage=clone disk=full git=storage_limit exit=75`. Paperclip records `sandbox_disk_full`, the run fails during setup, and the task does not start. This happens more frequently as the repository history grows > - This pull request makes a fresh clone from a network remote blobless (`--filter=blob:none`). The clone gets all commits and trees, but only the file contents that the checkout needs > - Agent commands that the managed GitHub launcher treats as local (`git show`, `git blame`, `git log -p`, checkout) do not ask the credential broker. In a blobless clone they can need to fetch an old blob, which fails for a private repository without credentials. So the launcher now gives these commands the broker credential on demand, at most once per command > - The benefit is that the same clone grows the disk by about 409 MiB and takes less than half the time, so large repositories start again in Cloud sandboxes ## Linked Issues or Issue Description Refs #22848 (classifies the Git storage guard refusal during clone as a full sandbox disk; this PR removes the cause of that refusal for large histories) Refs #22837 (moves a restore off a full reused sandbox; the clone path in this PR is a fresh sandbox, so a new sandbox does not help) **What happened?** On hosted staging, Paperclip Runner runs fail before the agent starts. The run error is `remote_workspace_operation_failed: operation=prepare exit=1; remote_workspace_prepare_failed: stage=clone disk=full git=storage_limit exit=75 program=git` (and the same refusal with `operation=repository` for a secondary repository). The error code is `sandbox_disk_full`. Between 2026-11-27 and 2026-11-30 there were 20 such failures for three different agents. The tasks used fresh workspaces for `paperclipai/paperclip` with `paperclipai/paperclip-cloud` as a secondary repository. **Expected behavior** A fresh sandbox workspace for a large repository starts without hitting the sandbox Git storage budget. **Steps to reproduce** 1. Run `git clone --no-hardlinks https://github.com/paperclipai/paperclip.git` and measure the disk growth. I measured 856 MiB (39 s). 2. Compare with the Cloud sandbox Git storage guard budget: it stops one Git command at 1 GiB of net disk growth, and it counts other writers on the same disk. 3. Run the same clone with `--filter=blob:none`. I measured 409 MiB (17 s). **Paperclip version or commit** `master` at `c737187ec7`. The hosted staging failures were on releases `635ed5a364`, `c49e80da6c`, `629281b1e8`, `e55b475f30` and `bc98abda0c`. **Deployment mode** Hosted Cloud, Paperclip Runner with remote sandbox workspaces. ## What Changed - `server/src/services/remote-workspace-transport.ts`: - The primary workspace clone (`prepareRemoteWorkspaceDirectory`) and the secondary repository clone (`prepareRemoteRepository`) add `--filter=blob:none` when the repository URL is a network remote (`https`, `http`, `ssh`, `git`, or `user@host:path`). - The staged checkout steps after the clone (`checkout_branch`, `checkout_ref`) use the clone's credentials. Checkout of a revision other than the default branch can fetch missing blobs from the origin. Without credentials, that fetch fails for a private repository. The checks after publication still run without credentials. - A local path or `file://` origin stays a full clone. A saved workspace keeps only a promisor remote whose URL works on another machine, so a partial clone of a local origin cannot be saved. - A server that does not support filters ignores the filter and sends a full clone, so the old behavior stays available. - `server/src/services/remote-workspace-transport.test.ts`: a real-subprocess regression with a history-only blob and an origin that is reachable only through the clone credentials. It checks the blobless clone, the fetch of an older revision's files with credentials, the full clone of a local origin, and a save and restore of the blobless clone after the origin is removed. - `packages/adapter-utils/src/github-launcher.ts` (managed `git`/`gh` launcher): a local `git` command (one that does not ask the broker since #17886) now runs with the launcher as `GIT_ASKPASS`, when the launcher has a broker capability and is not anonymous. - Git calls askpass only after every credential helper declines, for example on a lazy fetch of a missing blob from a private repository. Askpass was not used before, so a lazy fetch failed with `could not read Username for 'https://github.com'`. - The launcher answers only prompts for `https://github.com` and `https://www.github.com`. It answers `x-access-token` for the username without the broker. For the password, it asks the broker. - The command's launcher keeps the first broker answer in memory and serves later prompts through a Unix socket in a private (`0700`) temporary directory. So one command asks the broker at most once, however many objects Git fetches. A command that fetches nothing does not ask the broker, as before. If the socket cannot be created, each prompt asks the broker itself. - The recursion guard still rejects every launcher invocation inside an operation, except an askpass prompt inside a local operation (which holds no credential). - I used askpass instead of a URL-scoped `credential.helper`, because a Git wrapper that adds its own `credential.<url>.helper` reset (as the Paperclip tools Git bundle does through `-c include.path`) is applied after the launcher's `GIT_CONFIG_*` entries and would remove the helper. `GIT_ASKPASS` takes priority over any `core.askPass` configuration. - `packages/adapter-utils/src/github-launcher.test.ts`: launcher tests with real Git. A local command runs `git credential fill` three times for a GitHub URL. The test checks that the managed token is returned with one broker request, that `git status` makes no request, that another host gets no answer and no request, and both broker modes (inherited URL and broker file). A second test checks that askpass is set only for local commands of a connected, non-anonymous launcher, and that the recursion guard still rejects other re-entries. - `doc/workspace-storage.md`: a note about the blobless clone. `doc/execution-github-identity.md`: the askpass behavior for local commands. ## Verification - Red: on the unfixed code, the new test fails because the clone downloads the history-only blob (`expected [] to include '<blob>'`). - A second red: with the filter but without credentials for the checkout steps, the test fails with `stage=checkout_ref git=network exit=128`. This proves that the test also covers the private-repository case. - Green: `pnpm --filter @paperclipai/server exec vitest run src/services/remote-workspace-transport.test.ts src/services/remote-workspace-readonly-capture-cause.test.ts src/services/remote-workspace-readonly-inventory-git-guard.test.ts src/services/remote-workspace-restore-disk-full.test.ts` passes (201 tests). - `src/services/remote-workspaces.integration.test.ts`, `remote-workspace-lifecycle.test.ts` and `remote-workspace-migration.test.ts` pass (347 passed, 16 skipped; the integration file skips locally). - `pnpm --filter @paperclipai/server typecheck` passes. - Launcher, red/green: without the launcher change, the 3 new launcher tests fail. With it, `src/github-launcher.test.ts` passes (44 tests). `github-launcher.test.ts`, `github-launcher-environment.test.ts` and `sandbox-callback-bridge.test.ts` in adapter-utils pass (175 tests). `packages/paperclip-runner` `src/drivers/acpx/github-launcher.test.ts` (3) and server `heartbeat-github-launchers.test.ts` (12) pass. `tsc --noEmit` passes in `packages/adapter-utils`. - Launcher, real private repository: I made a blobless clone of a private GitHub repository and ran the generated launcher with a local fake broker that returned a real GitHub token. With the old launcher, `git show <old commit>:README.md` failed with `could not read Username for 'https://github.com': terminal prompts disabled` / `could not fetch <blob> from promisor remote`. With the new launcher, it printed the file with 1 broker request. On a fresh blobless clone, `git log -p -40 -- README.md` (about 150 lazy fetches in the trace) made 1 broker request, and `git status` made 0. - Measurement on a Linux host: a full clone of `paperclipai/paperclip` grows the disk by 856 MiB; a blobless clone grows it by 409 MiB. - Not run: a live Cloud sandbox run. Hosted staging gets this change through the normal automatic deployment. After that deployment, the Sentry case gets a check that new fresh workspaces for this repository start without the refusal. - Local environment note: the tests rewrite the remote URL through `GIT_CONFIG_COUNT`. A Git wrapper first on `PATH` that sets its own `GIT_CONFIG_COUNT` makes the rewrite tests fail, also on `master`. I ran the tests with the system Git first on `PATH`. ## Risks - A blobless clone fetches file contents from the origin when an agent command needs old blobs (for example `git log -p`, `git blame`, or a checkout of another branch). These commands need network access and the run's Git credentials, the same as `git fetch`. The launcher now supplies the credential on demand (one broker request per command that needs it). The Cloud Git storage guard already measures these lazy downloads. - While a local `git` command runs, a process of the same user can read the password from the askpass socket. That user can already get the token with `gh auth token`, so this adds no new access. The token is not written to disk. - A saved workspace of a blobless clone keeps its promisor remote. The existing snapshot capture and restore support this. The new test proves a save and restore after the origin is removed. - Medium-low risk: the clone of a repository on a server without filter support is unchanged (Git ignores the filter). ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), with tool use (shell, code execution) 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 - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2033ab912f |
Update the Connect account dialog and provider chooser (#23361)
## Thinking Path > - Paperclip helps people manage agents. > - Each agent can use a managed provider account. > - People can connect that account during onboarding or from agent settings. > - The two screens used different sign-in controls. > - This change brings the wizard controls to the account dialog and groups other providers in a grid. ## Linked Issues or Issue Description **Subsystem affected** Agent settings and managed AI connections. **Current behavior** The account dialog uses different controls from onboarding and displays other providers in separate lists. **Proposed behavior** Show provider sign-in, code entry, expiry, and retry inside the credential panel. Show other providers in a compact grid. ## What Changed - Share the provider marks and sign-in controls with onboarding. - Keep the account fields visible while sign-in prepares. - Crossfade between the account form and provider grid. Keep the modal width stable. ## Verification - All 29 tests in AdapterLoginChrome and AgentProviderConnection passed. - The UI TypeScript check passed. - To check the layout, open Connect account from agent settings, choose Other Models, then return to the provider form. ## Risks - The dialog shares controls with onboarding. Changes to their defaults could affect both entry points. - Subscription sign-in depends on the selected execution environment. ## Model Used OpenAI GPT-6 through Codex, with local editing and 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) - [ ] 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 - [ ] I have updated relevant documentation to reflect my changes - [x] 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 |
||
|
|
285db75d87 |
fix(ui): name the kind of value an uncaught browser error threw (#23346)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The board UI reports uncaught browser errors to Sentry when a deployment sets a DSN > - A React event handler that throws a string reaches Sentry through `window.onerror` with no stack of its own > - The event then shows only one frame: React's event dispatch (`processDispatchQueue`). It does not show the handler that threw the value, or the kind of the value > - Breadcrumbs and the user agent are not sent by design, so we cannot tell a scripted browser session from a person > - This pull request adds two bounded facts to these reports. It does not copy the thrown value > - The benefit is that the next occurrence tells us if a string or a stackless `Error` was thrown, and if a WebDriver-controlled browser threw it ## Linked Issues or Issue Description **What happened?** One browser event on a hosted Paperclip page reported `Error: 844g8`. The mechanism was `auto.browser.global_handlers.onerror` (unhandled). The only stack frame was React's event dispatch in the main bundle, at the `catch` that reports a listener's throw. The event had no breadcrumbs and no user agent. The source location was a cloud data center region. **Expected behavior** A report that lets a maintainer find what threw the value, or at least identify the class of the throw. **Steps to reproduce** 1. Enable browser Sentry monitoring. 2. Throw a string (for example `throw "844g8"`) from a React event handler, or call `window.onerror` with a string `error` argument. 3. Look at the Sentry event. It shows `Error: 844g8` with one synthetic frame at the reported location, and there is no other attribution. **Paperclip version or commit** The event came from release `506211b9176058ae06622b2bc1150d4bb2ea2e19` (hosted production bundle). This change is based on current `master`. No duplicate or related open pull request touches this path. I searched for the error text, for `onerror`, and for non-`Error` throws. ## What Changed - `ui/src/lib/browser-error-context.ts`: Add `classifyThrownValue()`. It returns `error`, `error_stackless`, or the primitive type. It checks only if an `Error` stack has frames. It does not coerce or copy the value. - `ui/src/lib/browser-error-context.ts`: Add `browser_state.automation` from `navigator.webdriver === true`. A failed read leaves out the field and keeps the other state. - `ui/src/lib/sentry.ts`: In `beforeSend`, tag `window.onerror` reports with `browser_thrown_kind`. Rejections and caught exceptions do not get this tag. - `doc/observability.md`: Document the new tag and field. - Tests use the real `@sentry/browser` SDK for the onerror path, and unit tests for the browser state. ## Verification - `cd ui && npx vitest run src/lib/sentry.test.ts src/lib/browser-error-context.test.ts`: 68 passed. - Red/green: with the source change removed, the two new `sentry.test.ts` tests fail (`browser_thrown_kind` is `undefined`, and `browser_state.automation` is missing). With the change, they pass. - The new real-SDK test throws the string `844g8` through `window.onerror`. The SDK produces the same shape as the production event: exception value `844g8`, mechanism `auto.browser.global_handlers.onerror`. The event now also has `browser_thrown_kind: string`. - `cd ui && node ../scripts/run-tsc.mjs -b`: pass. - `pnpm verify` exited 2 (broader verification required, from global CI inputs). Required CI supplies that coverage. ## Risks - Low risk. The change adds one tag and one boolean to browser Sentry events. It does not drop, group, or suppress any event. - Every read is in a `try` block, so a failed read cannot replace or discard the original error. - `navigator.webdriver` is a standard boolean. It does not identify a person or a tenant. - This is a diagnostic. It does not fix a defect. The root cause needs a future event with these facts. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use and shell 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 - [ ] All Paperclip CI gates are green - [ ] 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: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7ce7d99f8a |
fix(runner): honor document revision limit and bound oversized document reads (#23352)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Native Runner agents read task documents through first-party tools such as `list_document_revisions`. > - Each tool result travels to the runner as one durable PRP command. A command has a bound of about 522 KB. > - `list_document_revisions` advertises `limit` (default 50, maximum 200), but the server ignored it and returned every revision. > - A case document with 55 revisions of about 70 KB each gave a result of about 3.8 MB. The journal refused it with `command_payload_too_large`. The run disconnected. Restart recovery read the same revisions again, and the run failed with `native_session_recovery_failed`. > - This pull request honors the advertised limit and returns a small named tool error when a document read is too large for one tool result. > - The benefit is that a large document history no longer fails the run. The agent gets a clear error and can ask for fewer revisions. ## Linked Issues or Issue Description Refs #20727 (classifies the oversized-command failure as a named terminal; this PR removes one cause of it) **What happened?** A native Runner agent called `list_document_revisions` with `{ "key": "sentry-case", "limit": 1 }`. The server ignored `limit` and returned all 55 revisions (about 70 KB each). The result was too large for one durable PRP command. The run disconnected. Recovery read the same result again and failed the run with `native_session_recovery_failed: Error: Durable PRP command journal bound exceeded: command_payload_too_large.` **Steps to reproduce** 1. Write a task document 5 times with bodies of about 160 KB each. 2. As a native Runner agent, call `list_document_revisions` with `limit: 1`. 3. The result contains all 5 revisions (about 800 KB), above the per-command bound. **Expected behavior** The tool returns only the requested number of revisions, newest first. A document read that cannot fit in one tool result returns a small named tool error. It does not fail the run. ## What Changed - `documentService.listIssueDocumentRevisions` accepts an optional `limit`. It keeps the newest revisions first. The HTTP route does not pass a limit, so its behavior does not change. - The native Runner `list_document_revisions` tool honors the advertised `limit` (default 50, maximum 200). - The native Runner `list_documents`, `read_document` and `list_document_revisions` tools return `paperclip_runner_read_result_too_large` when their result is above the 500,000-byte tool-result bound (`RUNNER_TOOL_RESULT_MAX_BYTES`). The message tells the agent to request fewer revisions. - `paperclip_runner_read_result_too_large` is a recoverable read error. Restart recovery returns it as a small `isError` tool result and does not fail the run. ## Verification - Red: without the fix, the new test fails. `limit: 1` returned revisions `[5, 4, 3, 2, 1]`. - Green: `cd server && npx vitest run src/services/native-runtime/paperclip-runner-tool-authority.test.ts`. All 50 tests pass. - The new test checks that `limit: 1` and `limit: 2` return the newest revisions. It also checks that an oversized history gives the named error from `execute`, and that `recover` returns an `isError` result smaller than 1 KB. - `pnpm verify` asked for broader verification (exit 2): its dependency-graph worker was stopped by local memory pressure. Required CI supplies typecheck, build and the broad test suites. ## Risks - Low risk. The change is limited to three native Runner document read tools. - An agent that called `list_document_revisions` without `limit` on a document with more than 50 revisions now gets the newest 50. Before this change it got all of them. The advertised schema already documented a default of 50. - A document read above 500,000 bytes now returns a named tool error. Before this change, such a read could not be journaled and the run failed. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) through Claude Code, with tool use and code 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 - [ ] I have updated relevant documentation to reflect my changes - [x] 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 - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
e67009db3f |
fix(voice): let board incoming-call requests wait for membership locks (#23353)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Voice connections (Speko) let a board user approve incoming phone calls and see call history in the board UI > - The incoming-call panel polls `GET /companies/:companyId/voice-phone/:endpointId/incoming` every two seconds > - The inbound voice service checks the caller's company membership with a `FOR SHARE NOWAIT` lock on every request, including these board requests > - When another transaction holds that membership row, the poll fails with Postgres error `55P03` and the error handler returns a 500 and reports it to Sentry > - This pull request makes the board routes wait for the row lock, like the other board voice routes do, and keeps `NOWAIT` for provider callbacks > - The benefit is that ordinary lock contention no longer causes 500 responses or Sentry noise for board users ## Linked Issues or Issue Description No public issue exists. This is the problem description. **What happened?** On staging, board requests to the voice incoming-call routes failed with `Failed query: select "id" from "company_memberships" ... for share nowait`, caused by `PostgresError: could not obtain lock on row in relation "company_memberships"` (`55P03`). The culprit frame is `authorizeCaller` in `voice-session-store.ts`. Sentry recorded 32 events in one day, all on staging. **Expected behavior** A board request waits for a short row lock that another transaction holds, and then returns its normal result. A concurrent membership change must not cause a 500. **Steps to reproduce** 1. Open a transaction that locks the caller's `company_memberships` row (`FOR NO KEY UPDATE`). 2. While the lock is held, call the inbound voice `list` or `decide` service method for that caller. 3. The call fails immediately with `55P03`. **Relevant logs or output** `Error: Failed query: select "id" from "company_memberships" where (... "membership_role" is distinct from 'viewer') for share nowait` caused by `PostgresError: could not obtain lock on row in relation "company_memberships"`. ## What Changed - `server/src/services/voice/voice-inbound-service.ts`: add a second session store, `boardStore`, without `nonblockingAuthority`. The board routes (`configuration`/`saveConfiguration` through `manager`, `list`, `history`, and `decide`) use it. The provider callback and tool paths (`lifecycle`, `pendingTool`, `authorizeGuest`) keep the `NOWAIT` store. - `server/src/__tests__/voice-session-store.integration.test.ts`: add a regression test. It holds the caller's membership row lock, calls `list` and `decide`, checks that both wait on the lock, releases the lock, and checks that both succeed. ## Verification - Red: with the service change stashed, the new test failed. Both requests rejected with `55P03` (`for share nowait`), which is the same error as in Sentry. - Green: `cd server && npx vitest run src/__tests__/voice-session-store.integration.test.ts` passes all 135 tests, the new test included. - `cd server && pnpm typecheck` passes. ## Risks - Low risk. Board voice requests can now wait for a row lock instead of failing at once. This matches `voice-session-service`, which already uses ordinary share locks for board routes. Each board transaction takes the membership lock as its first statement, so this change adds no new lock-order cycle. - Provider callbacks keep their fail-fast behavior. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution in an agent harness. ## 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 - [ ] 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: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
5abce3b492 |
fix(tool-access): keep OAuth redirect-policy refusals out of Sentry (#23349)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - People connect remote MCP servers to Paperclip. Many of these servers use OAuth with dynamic client registration (RFC 7591). > - Some authorization servers refuse Paperclip's callback URL with HTTP 400 `invalid_redirect_uri`. They do this because of their own redirect policy, for example an allowlist of approved clients or an HTTPS rule. > - Paperclip only sends a callback URL that it builds from a configured or trusted origin. Paperclip cannot change the provider's answer. The person already gets a 502 with remediation text: ask the provider to allowlist the callback URL, or enter a client ID. > - #22416 kept all registration 400s in Sentry on purpose, because some 400s (`invalid_client_metadata`, unknown codes) can show that Paperclip sent bad metadata. Thus each provider redirect-policy refusal still makes a Sentry crash report. > - This pull request stops the Sentry report only for a registration 400 with `invalid_redirect_uri`. All other registration failures that #22416 reports stay reported. > - The benefit is that Sentry shows Paperclip faults, not expected provider policy decisions. The person sees the same error and guidance as before. ## Linked Issues or Issue Description Refs #22416 **What happened?** A remote MCP authorization server answered Paperclip's dynamic client registration with HTTP 400 and the OAuth error `invalid_redirect_uri`. Paperclip correctly answered the person with a 502 and the message "The authorization server rejected Paperclip's callback URL." But the error handler also sent the error to Sentry as a server crash. One production event was recorded with the tags `oauth_operation=dynamic_client_registration`, `oauth_provider_status=400` and `oauth_provider_error=invalid_redirect_uri`. **Expected behavior** A provider's redirect-policy refusal is an expected external failure. Paperclip must answer with the same 502 and remediation, and must not report a crash to Sentry. Registration failures that can show a Paperclip fault must stay reported. **Steps to reproduce** 1. Connect a generic MCP server whose registration endpoint answers `400 {"error":"invalid_redirect_uri"}`. 2. Start the browser sign-in. 3. See the 502 with the callback-URL guidance, and see a new Sentry event for the same request. **Paperclip version or commit** master at |
||
|
|
fd6e940b35 |
fix(ui): stop retrying and reporting an active sign-in conflict (#23350)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The agent sign-in panel reads the user's active sign-in session before it starts a new one > - When that active session belongs to another computer or AI connection, the panel throws an error and shows "Another sign-in attempt is active" > - This is an expected state that the user must resolve. But the error has no status, so the query client classifies it as an unknown failure > - Because of that, the query retries it two times and then sends it to Sentry as an unexpected error > - This pull request marks this state as a conflict (409). The query does not retry it and does not report it. The panel shows the same message > - The benefit is that Sentry shows real failures only, and the user sees the conflict at once, not after about 3 seconds of retries ## Linked Issues or Issue Description No public issue exists. The issue is below. It follows the bug template. **What happened?** A user opened the agent sign-in panel while a different sign-in for the same owner was active on another computer or AI connection. The panel showed "Another sign-in attempt is active…". The browser also sent a handled `Error` to Sentry from the active-session query (`query_kind=adapter-login-active-session`). This happens in the displayed-code panel (Codex and similar adapters) and in the Claude setup-token panel. Both throw the same kind of error. **Expected behavior** The panel shows the conflict and the "Cancel previous sign-in and retry" action. The app does not retry the read. The app does not report the conflict to Sentry, because it is a known user state and not a failure. **Steps to reproduce** 1. Start a sign-in for an agent on computer A. Do not complete it. 2. Open the sign-in panel for an agent on computer B, as the same user. 3. The active-session read finds the session for computer A. The query retries two times, then the panel shows the conflict, and Sentry gets an event. **Paperclip version or commit** `master` at |
||
|
|
c737187ec7 |
fix(lifecycle): classify native hello timeouts (#18216)
## Thinking Path > - Paperclip verifies an agent's execution setup before it becomes ready. > - Native hello probes return a structured environment-test check. > - A timeout uses the check suffix `_hello_probe_timeout`. > - The lifecycle mapper only recognized the older `_hello_probe_timed_out` spelling. > - It therefore reported a native timeout as a generic test failure. > - This change maps both spellings to the existing timeout category. > - Operators receive the existing fixed timeout guidance without provider output. ## Linked Issues or Issue Description **What happened?** On current main, `testNativeRunnerAuthentication` emits `codex_hello_probe_timeout`. `assertHarnessTestPassed` classified it as `harness_test_failed` instead of `harness_probe_timed_out`. The OpenCode spelling in the unit table checks the generic suffix contract. It does not add or qualify a native OpenCode producer on current main. **Expected behavior** Recognize the native producer's timeout code. Keep the existing timeout category, legacy spelling, and fixed error text. **Steps to reproduce** Pass a failed environment result with the source-defined Codex timeout code to `assertHarnessTestPassed`. The added owner controls fail before the mapping change and pass afterward. The related open #16652 changes a legacy Claude probe timeout and UI behavior. It does not change this mapper. ## What Changed - Accept `_hello_probe_timeout` beside the existing `_hello_probe_timed_out` suffix. - Cover the actual Codex producer spelling, the forward-compatible OpenCode spelling, and a lookalike suffix that must remain a generic failure. - Retain existing authentication, model, command, directory, unexpected-output and success handling. ## Verification - The real owner unit suite produced **2 failing timeout cases and 25 passing controls** before the fix. The same suite passes **all 27 controls** after the fix under a focused local source-alias configuration. - Standard owning command: `pnpm --filter @paperclipai/server exec vitest run src/__tests__/agent-harness-verification.test.ts`. - Local scoped noEmit did not pass. Reused local dependency links produced ambient Express declarations, missing `tar-stream`, and mixed-source type errors. The initial load and typecheck failures are preserved. Normal remote CI must supply the final typecheck and build evidence. - `git diff --check` passes. The diff contains only the mapper and its existing unit test. - Exact-head normal CI passed on `db56f63`: 55 successful checks, two skipped checks and one neutral review check. Required `ci / verify`, `ci / e2e` and `ci / Build` passed. Greptile and the Paperclip reviewer both report 5/5 with no findings or open threads. No CI rerun was needed. Local noEmit setup remains a recorded limitation. - Native probes, model calls, databases, application builds and end-to-end journeys were not run locally. This source regression does not establish the cause of any recorded evaluation failure. ## Risks Low scope. The existing closed failure category changes for the native timeout spelling. A string that only contains that suffix in the middle still maps to generic failure. Authentication keeps priority. Failure text stays fixed. This change preserves lifecycle ownership, deferral, retry limits and deadlines. ## Model Used OpenAI GPT-6 through Codex, with source analysis and pure unit tests. The exact serving model ID and context-window size are not exposed to this worker. ## 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> |
||
|
|
66a8aa7f7e |
feat(issues): add issues.scope surface visibility foundation (#23329)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - Issues currently store human board tasks, agent-created operational
tasks, and persistent 1:1 Agent Chats in the same `issues` table.
> - Default board lists, counts, and Mine views previously relied on
ad-hoc creator and origin predicates to hide chats and separate agent
tasks.
> - Upcoming headless channels also need a clean way to isolate channel
issues from default board lists without inventing a separate task
entity.
> - This pull request adds an explicit `issues.scope` column (`board`,
`channel`, `agent`, `chat`) across the schema, shared types, service
filters, client filters, and issue routes.
> - The benefit is unified surface visibility filtering and explicit
scope derivation while keeping rolling deploys safe and preserving
existing Agent Chat and board behavior.
## Linked Issues or Issue Description
**Subsystem affected**
Cross-cutting (`packages/db`, `packages/shared`, `server/` REST API &
orchestration services, `ui/` client filters, and `docs/api/issues.md`).
**Problem or motivation**
Paperclip uses the `issues` table for human board work, automated or
agent-created operational work, and persistent 1:1 Agent Chats. Without
a dedicated surface-scope column, list, count, and Mine queries depend
on `conversationAgentId`, `createdByAgentId`, and `originKind` checks,
and there is no first-class way to isolate channel streams from default
board views.
**Proposed solution**
Add an `issues.scope` column (`board` | `channel` | `agent` | `chat`)
with `issues_scope_check` and composite indexes, expose `scope` in
shared types and Zod validators, derive default scope on issue creation
and batch imports, protect `chat` scope on 1:1 conversations and block
unauthorized agent `scope: "board"` writes across routes and
`issueService`, update server visibility queries and `applyIssueFilters`
on the client to honor `scope`, add `scope` filtering on `GET
/api/companies/:companyId/issues` and `/count`, and document the new
parameter in `docs/api/issues.md`.
**Alternatives considered**
1. Create separate tables for chats and channels. We ruled this out
because Paperclip builds assignment, comments, approvals, and execution
around a single `issues` model.
2. Add a DB `CHECK ((conversation_agent_id IS NULL) OR (scope =
'chat'))` constraint in this expand migration. We ruled this out for the
initial rollout because `ADD CONSTRAINT ... NOT VALID` still enforces
checks on new writes from older server instances that omit `scope`
during a rolling deploy.
3. Continue filtering only by `originKind` and `conversationAgentId` at
query time. We ruled this out because it cannot distinguish an explicit
chat-to-board handoff from a background agent task.
**Roadmap alignment**
Supports the **Agent Chat (including CEO Chat)** and **Work Queues** /
channel-intake directions in `ROADMAP.md` by separating surface
visibility on the shared `issues` table.
**Additional context**
This PR introduces the expand-phase schema, shared contract,
service-layer derivation, client filter handling, API filter foundation,
and API documentation. Follow-up work will build channel UI surfaces on
`issues.scope` and add the contract-phase DB check constraint after
older writers drain and re-backfill any rolling-deploy conversation
rows.
## What Changed
- Added `scope` (`board` | `channel` | `agent` | `chat`, default
`board`) to `packages/db/src/schema/issues.ts` with
`issues_scope_check`, `issues_company_scope_status_idx`, and
`issues_company_scope_updated_idx`.
- Added online-compatible migration
`packages/db/src/migrations/0511_simple_the_hunter.sql` (plus updated
Drizzle snapshot/journal and `MIGRATIONS_WITH_TOP_LEVEL_STATEMENTS`
entry in `packages/db/src/client.ts`) to backfill existing `chat` and
`agent` rows in bounded 1,000-row primary-key cursor batches matching
`isAgentCreatedIssue`, validate `issues_scope_check` with `NOT VALID` +
`VALIDATE CONSTRAINT`, and build indexes `CONCURRENTLY`.
- Exported `ISSUE_SCOPES`, `IssueScope`, and `deriveDefaultIssueScope`
in `packages/shared`, added `scope?: IssueScope` to `Issue` and
`CompactIssue`, and added optional `scope` validation to
`createIssueSchema` and `updateIssueSchema`.
- Extracted `parseScopeFilter` and `surfaceScopeCondition` in
`server/src/services/issue-visibility.ts`, and updated `issueService`
(`create`, `importIssues`, `update`, `list`, `count`, blocked inbox
counts, and Mine views) to derive default scope (including `scope:
"agent"` for creatorless imports), enforce `chat` scope on 1:1
conversations, reject `scope: "chat"` on non-conversation issues, reject
unauthorized agent `scope: "board"` creation without handoff provenance,
default chat-to-board handoffs to `board`, preserve
`nonIdleSlackIssueCondition` on non-chat/channel scope filters, let
explicit `scope` filters override `includeAgentCreatedTasks=false`, and
exclude `chat` and `channel` rows from default board queries unless
filtered by `scope`, `q`, or `issueIds`.
- Updated `applyIssueFilters` (`isBoardVisibleByDefault`) in
`ui/src/lib/issue-filters.ts` so agent-created tasks with `scope:
"board"` (such as chat-to-board handoffs) stay visible by default.
- Added `scope` query parsing (`parseIssueListScopeQueryParam`
delegating to `parseScopeFilter`) and `assertActorMayWriteIssueScope`
across `POST /companies/:companyId/issues`, `POST /issues/:id/children`,
`POST /issues/:id/accepted-plan-decompositions`, and `PATCH /issues/:id`
in `server/src/routes/issues.ts`, included `scope` in `toCompactIssue`,
and documented `scope` in `docs/api/issues.md`.
- Added tests in `server/src/__tests__/issue-scope-visibility.test.ts`
and `ui/src/lib/issue-filters.test.ts`, updated
`server/src/__tests__/fixtures/issue-detail-response.json` and
`server/src/__tests__/issues-creation-visibility.test.ts`, and refreshed
`tests/runner-e2e/source-sdk-public-inputs.json`.
## Verification
- `pnpm --filter @paperclipai/db typecheck` (`check:migrations` + `tsc
--noEmit`), `pnpm --filter @paperclipai/shared typecheck`, and `pnpm
--filter @paperclipai/server typecheck` — passed on
`3db819854ff28ebc5e875b8d9d0daa74055bef35`.
- `npx vitest run packages/db/src/migration-snapshot-drift.test.ts
server/src/__tests__/issue-scope-visibility.test.ts
server/src/__tests__/issues-creation-visibility.test.ts
server/src/__tests__/company-portability-import-batching.test.ts
ui/src/lib/issue-filters.test.ts` — 5 files, 51 tests passed (1
pre-existing skip in `company-portability-import-batching.test.ts`).
- `node tests/runner-e2e/source-sdk-public-inputs.mjs
|
||
|
|
158613ef81 |
Permit idle sleep with proved passive remote workspaces (#23335)
## Thinking Path > - Paperclip runs agent work and retains its files after a run ends. > - Remote workspaces save those files in a durable archive. > - The idle inventory still treats every remote workspace row as active work. > - A saved archive or an unused setup reservation can then keep an idle instance awake. > - This PR adds a read-only proof in the remote workspace owner and uses it in the existing idle check. > - The proof keeps active work and uncertain recovery awake and preserves all retained data. ## Linked Issues or Issue Description **What happened?** A retained `cloud_sandbox` workspace blocks idle sleep after its archive commits and its allocation is released. The passive workspace check only accepts local directories and git worktrees. An unused reservation can also remain after a bootstrap failure that started no provider work. **Expected behavior** An idle instance can sleep when existing receipts prove that its remote files are saved or that a setup reservation was never used. Missing, foreign, contradictory, and unfinished state must keep blocking sleep. **Steps to reproduce** 1. Save a remote workspace and finish its snapshot operation. 2. Release its allocation with the matching stop receipt, or retain no allocation. 3. Keep the workspace row and inspect idle safety. Before this change, the row still reports work. Related: remote workspace storage in #18403. No duplicate open sleep/workspace PR was found. ## What Changed - Add a pure SQL proof for a committed, scoped archive and its completed source operation. Require the stored encryption scheme and correctly shaped IV, tag, and ciphertext. An unchanged save can reuse an older snapshot. - Require exact release evidence for a retained location and every allocation of an unused reservation. Unused reservations require an ended legacy bootstrap, an explicit no-provider-work result, no live controller or retry, and no native finalization. A pristine reservation cannot carry retained recovery-file references. - Apply that proof through the existing passive workspace check. Keep runtime configuration, commands, due cleanup, reopen fences, and every independent run, lease, and recovery check. - Add PostgreSQL regression cases and describe the proof in the idle-safety documentation. The existing shared database fixture keeps the tests in one suite instead of adding another database startup. - Correct two pre-existing receipt browser assertions uncovered by required CI. Plain comments have supported keyed retries since October 28; the older tests assumed one POST even when receipt reads lose the race to backoff. Assert exact request identity and payload across retries, one saved comment, and preservation of the next draft. ## Verification - Receipt CI follow-up, Node 25.6.1 on macOS: the full `board-attachment-receipts.spec.ts` passed twice with four Chromium workers (28/28). Both corrected cases passed with delayed issue reads after reproducing both old failures under the same delay. `node scripts/typecheck-test-projects.mjs --reuse-declarations tests/e2e` and the focused test-budget check passed. Only browser assertions changed after the 323-test server verification. - Node 25.6.1 on macOS: `pnpm --filter @paperclipai/server typecheck` passed. - Final revision: `pnpm exec vitest run server/src/__tests__/idle-sleep-safety.test.ts server/src/__tests__/idle-sleep-diagnostics.test.ts`: 323 passed. Both suites used real embedded PostgreSQL. An earlier run also selected the remote-workspace lifecycle suite; its 16 cases were skipped because its external test database was not configured. - Red-green: the new saved-workspace regression failed before the first proof. Both unused-reservation cases failed before that proof was added. The focused regressions passed after the changes. Empty key material and a foreign allocation bound to an unused writer were also reproduced red-green during review. - `pnpm verify --explain` returned the documented exit 2 because the documentation path requires broader CI. Required CI will supply that coverage; a full local repository run was not substituted. - After rebasing onto current `master`, the focused passive-state tests and server typecheck passed again. - `git diff --check` and a staged secret/PII scan passed. - The previous revision (`078e60f`) received Greptile 5/5 with its key-format thread resolved. [Initial CI](https://github.com/paperclipai/paperclip/actions/runs/46536659729) failed in a Rust executable fixture (`ExecutableFileBusy`) and a browser receipt assertion. The targeted rerun passed Rust but failed the companion receipt test. Both browser assertions expected one POST, contrary to the documented keyed retry contract. A scratch fault fixture delaying issue reads by 1.6 seconds reproduced both old failures (`Expected: 1 / Received: 2`); both revised cases passed under the same delay. The delay fixture is kept outside the branch. Final head `97269b3420387b28fda5f35f69a6b9ed45d5bb54` is merge-ready: all required gates passed, 81 checks succeeded and four were skipped by workflow policy, Greptile is 5/5 on this head, and the one review thread is resolved. GitHub reports `MERGEABLE` / `CLEAN`. The skipped external-database local cases and earlier failed attempts remain recorded above. - No provider suspension, external wake, deployment, or cost-saving result is claimed from these local checks. The proof adds no provider call, recurring scan, or extra database round trip. It runs within the existing bounded, read-only snapshot. ## Risks This expands automatic sleep eligibility for proved passive remote state. A proof error could stop an instance with unfinished work. The new cases cover dirty or foreign authority, missing or malformed snapshot key material, incomplete operations, foreign or unverified leases, active ownership, retry state, and retained recovery references. The SQL checks the stored key format; archive decryption and object verification remain with the restore owner. The existing owned hold, generation checks, runtime probes, and final host authorization still apply. The change does not delete files, clear reservations, rewrite history, create receipts, change schedules, or add a migration. Revert the remote-provider predicate to restore the previous refusal behavior. Hosted stop/wake qualification remains part of deployment acceptance. ## Model Used OpenAI GPT-6.1-sol with xhigh reasoning through Codex in T3 Code. Tool-assisted implementation, source review, and PostgreSQL verification. ## 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 described the issue in-PR following the bug report template - [x] I have not referenced internal/instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal ticket id or instance-derived details - [x] I have run relevant tests locally and they pass; skipped external-database cases are stated above - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation - [x] I have considered and documented risks - [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 - Final revision [ci / e2e](https://github.com/paperclipai/paperclip/actions/runs/46539276027/job/142275047883): passed. - Final revision [ci / verify](https://github.com/paperclipai/paperclip/actions/runs/46539276027/job/142275348382): passed. --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
fb6632530d |
feat(onboarding): start the first chat with a welcome and choices (#23334)
## Thinking Path > - Paperclip helps people assign and track work with AI agents. > - Onboarding connects the first agent and opens its chat. > - A new user needs a clear way to start a conversation. > - A saved welcome can appear as soon as chat opens. > - The standard question card lets the user pick a goal, a product overview, or a task. > - The connected model replies after the user sends the choice. ## Linked Issues or Issue Description **Subsystem affected** Onboarding, agent chat, and subscription sign-in. **Problem or motivation** New users can land in a chat before they know what to ask. The original welcome depended on a model run, which could delay the first interaction. Local Claude sign-in could lose its code field if the browser reloaded the onboarding tab during authorization. **Proposed solution** Save a personalized welcome and a standard question card. Type the welcome when the chat opens, then show the card above the composer. Use the choice and any task description to guide the connected model. Resume the local Claude sign-in attempt when the onboarding tab reloads. **Alternatives considered** A model-written welcome can vary, but it adds a model call before the user has chosen what to do. The saved welcome gives the user the same starting points each time. **Roadmap alignment** This improves the existing first-agent flow for local and Cloud-managed instances. Related PRs: #22433 covers clearing the organization name after Back. #23326 adds the separate Cloud mobile-to-desktop handoff. ## What Changed - Save the greeting and question card together. Reuse the saved chat on entry and keep the transcript in order after a reload. - Type the greeting in the chat and reveal the standard question card above the composer. Honor reduced motion. - Collect a task description before starting the first model turn for the task option. Guide the first reply for each choice. - Restore the original local Claude sign-in attempt when the onboarding tab reloads. Show progress while it connects, and offer retry on a failed or stalled code exchange. - Update the organization name helper text and the onboarding walkthrough tests. ## Verification - See the first-chat test drive for manual steps and the credential-free browser fixture. - 659 focused Vitest tests passed, with one skipped. The UI and server typechecks and the feature map validator passed. - All 18 Chromium tests passed across the first-chat, onboarding, sign-in resume, and mobile desktop handoff specs. Coverage includes the saved greeting, chat ordering, question handoff, Claude code submission and resume, and the Cloud-managed starter model path with scripted replies. - The published Cloud service and live subscriber credentials need separate acceptance testing. ## Risks - The greeting uses the existing conversation and interaction records. No database migration is needed. - Existing in-flight model greetings can finish through the previous path. - The Claude PTY change depends on the CLI's bracketed-paste support. The runner preserves separate input writes for terminals that do not announce support. ## Model Used OpenAI Codex, GPT-6.2 Sol and GPT-6.2 Astra, with terminal and browser tooling. ## 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: Scott Tong <1504818+scotttong@users.noreply.github.com>canary/v2026.1130.0-canary.873300 |
||
|
|
1eae356c55 |
fix(analytics): remove PostHog consent banner and opt-out gating for private beta (#23333)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip Cloud sends browser product analytics and session replays to PostHog when enabled for a hosted stack (self-hosted installs never load posthog-js) > - Previously, an EU/UK/Swiss consent banner and Profile settings opt-out toggle gated browser analytics and dropped metrics when visitors did not opt in > - During private beta, we want to stop showing the consent banner and opt-out prompt anywhere while continuing to send metrics (compliance will be handled separately later) > - This pull request removes the consent banner, Profile opt-out toggle, and client-side consent gating across the UI and sets `consentRequired: false` on the server response > - The benefit is zero banner friction during private beta and uninterrupted PostHog product metrics, while keeping all replay/autocapture privacy masking and pre-load event queuing intact ## Linked Issues or Issue Description **What existing behavior does this improve?** Paperclip Cloud browser product analytics initialization (`ProductAnalyticsGate`, `ui/src/lib/analytics`, `ProfileSettings`, `cloud-posthog-browser.ts`). **Subsystem affected** Cross-cutting (multiple of the above) — `ui/` and `server/`. **Current behavior** In EU/EEA/UK/Swiss regions (or unknown time zones), `ProductAnalyticsGate` renders `AnalyticsConsentBanner` and blocks loading `posthog-js` until the visitor clicks Accept. `ProfileSettings` also renders a `ProductAnalyticsSetting` opt-out switch. **Proposed behavior** Remove `AnalyticsConsentBanner`, `ProductAnalyticsSetting`, and client-side consent gating so `ProductAnalyticsGate` loads PostHog unconditionally when `browserAnalytics` is enabled for a Cloud stack. Return `consentRequired: false` from `resolveBrowserAnalyticsConfig` so cached older UI bundles also stop prompting during rollout, and keep `opt_in_capturing()` when `has_opted_out_capturing()` is true so previously opted-out browsers resume sending metrics. **Reason and benefit** During private beta, the EU/UK consent banner adds friction and drops PostHog product metrics. Removing the banner and opt-out gating restores full metric delivery while keeping all replay/autocapture privacy masking and pre-load event queuing intact. **Breaking changes** None — `browserAnalytics.consentRequired` remains on the session payload (as `false`), self-hosted installs still receive `browserAnalytics: null`, and per-stack env controls (`PAPERCLIP_POSTHOG_BROWSER_ENABLED`, `PAPERCLIP_POSTHOG_REPLAY_ENABLED=0`) continue to work. ## What Changed - Deleted `ui/src/components/AnalyticsConsentBanner.tsx`, `ui/src/components/ProductAnalyticsSetting.tsx`, `ui/src/lib/analytics/consent.ts`, and their unit tests. - Simplified `ui/src/components/ProductAnalyticsGate.tsx` to start PostHog unconditionally after the page settles and render `null`. - Simplified `ui/src/lib/analytics/product-analytics.ts` to remove consent-state gating while keeping pre-load event queuing (`MAX_QUEUED_PRODUCT_EVENTS`) and automatic opt-in for browsers with a prior PostHog opt-out. - Removed `ProductAnalyticsSetting` from `ui/src/pages/ProfileSettings.tsx` and its mock in `ui/src/pages/mobile-collections-responsive.test.tsx`. - Updated `server/src/services/cloud-posthog-browser.ts` to always return `consentRequired: false`. - Updated `ui/src/components/ProductAnalyticsGate.test.tsx`, `ui/src/lib/analytics/onboarding-analytics.test.tsx`, `server/src/__tests__/cloud-posthog-browser.test.ts`, `server/src/__tests__/auth-routes.test.ts`, and `doc/cloud-browser-analytics.md`. ## Verification - `pnpm vitest run ui/src/components/ProductAnalyticsGate.test.tsx ui/src/lib/analytics/onboarding-analytics.test.tsx ui/src/lib/analytics/product-analytics.test.ts ui/src/pages/mobile-collections-responsive.test.tsx server/src/__tests__/cloud-posthog-browser.test.ts server/src/__tests__/auth-routes.test.ts` — all passed. - `pnpm --filter @paperclipai/ui typecheck` — passed. - `pnpm --filter @paperclipai/server typecheck` — passed. ## Risks - Low risk: self-hosted installs remain unaffected (`browserAnalytics` is still `null`). All replay/autocapture privacy masking and `/_ph` proxy allowlists remain unchanged. Per-stack opt-out (`PAPERCLIP_POSTHOG_BROWSER_ENABLED` / `PAPERCLIP_POSTHOG_REPLAY_ENABLED=0`) continues to work. ## Model Used - Google Gemini (Antigravity agent with tool use and code 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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
adc4501689 |
Add a desktop handoff to mobile Cloud onboarding (#23326)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Onboarding asks users to connect a model before they can finish setting up their agent. > - Cloud users can start setup on a phone, where provider sign-in and key entry can be difficult. > - They need a way to find the same workspace on a computer. > - This pull request adds a copyable link on the mobile model step and defers agent creation while the handoff is offered. > - A user can open the link on desktop or continue on the phone. ## Linked Issues or Issue Description **Subsystem affected** React onboarding UI and its Cloud health metadata. **Problem or motivation** On a phone, the Cloud model step does not explain how to find the same onboarding page on a computer. The fresh agent draft is local to that browser and can leave a provisional agent behind. **Proposed solution** Offer Continue on desktop and Keep going here at the start of the mobile model step. Copy the workspace's HTTPS `/onboarding` link. Ask users to sign in to the same account on desktop and explain that they may need to enter their choices again. **Alternatives considered** The original invite URL would carry an invite token. Copying the workspace's onboarding URL lets Cloud handle sign-in through its existing entry flow. **Roadmap alignment** This is a focused improvement to the existing onboarding wizard. It uses the current Cloud workspace entry flow and keeps model selection available on mobile. **Additional context** Refs #23315 for naming-step setup drafts. Related prior work: #3594 covered a native iOS-to-web handoff token and is closed. ## What Changed - Add the Cloud mobile handoff panel and clipboard fallback. - Prefer the canonical tenant HTTPS origin and build a clean `/onboarding` URL. Older tenants can use the current HTTPS tenant origin. - Defer the provisional agent in the naming and model steps while the mobile handoff is available. Desktop and self-hosted sessions keep the early-draft behavior from #23315. - Render the step indicators as round dots inside the step buttons so the mobile touch-height rule does not stretch them. - Add browser coverage for the Cloud and self-hosted paths and unit coverage for URL handling. ## Verification - Passed 52 focused Vitest tests for the onboarding route, stepper, handoff URL, and shared clipboard policy. - Passed UI typecheck, the test-budget guard, and `git diff --check`. - Passed 23 tests in desktop Chrome with four workers, including the affected CI browser shard and the upstream early-draft regression. The handoff scenarios cover the mobile dots, clipboard success and manual fallback, same-workspace desktop re-entry via simulated sign-in, continuing on mobile, and the self-hosted flow. - Manual reproduction: use a fresh Cloud test workspace and a 390 × 844 viewport. Enter an agent name and proceed to Connect a model. Open Continue on desktop and copy the link. Open it on desktop and sign in with the same account if needed. A real Cloud sign-in was outside the local fixture. ## Risks - Setup choices from the phone may need to be entered again on desktop. - Real Cloud sign-in and in-app mobile browsers still need a live tenant check. No database migration is needed. ## Model Used - OpenAI Codex with GPT-6.2 Sol (`gpt-6.2-sol`) for branch preparation and verification. Used the terminal and Chromium. The context window size is not available in the session. ## 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: Scott Tong <1504818+scotttong@users.noreply.github.com>canary/v2026.1130.0-canary.873100 |
||
|
|
d71d039ad7 |
fix(ui): link routine projects by ID (#23332)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Routines assign repeated work to an agent and an optional project. > - A routine stores its project ID, but its detail page links to the project's name-derived URL key. > - A cached name can stop identifying that project after a rename. > - This pull request uses the project ID in that link. > - The link stays attached to the selected project when its name changes. ## Linked Issues or Issue Description **What happened?** The routine detail page prefers a project's name-derived URL key over its ID. A cached routine page can link to an old project name after a rename. If another project takes that name, the old link can resolve to the other project. Saved routine associations, filters, and scheduler joins already use project IDs. **Expected behavior** The project link should identify the routine's selected project by ID. **Steps to reproduce** 1. Open a routine attached to a project named Operations. 2. Rename the project while the routine page retains its cached project data. 3. Inspect the routine's project link. Before this change, it uses `/projects/operations`. After this change, it uses `/projects/<project-id>`. ## What Changed - Use the project ID for the project link on the routine detail page. - Add rendered-link regression tests for a rename, same-name projects, and an unassigned routine. ## Verification - Confirmed that the rename and same-name link tests fail before the fix. - All 24 focused tests pass across routine page, routine form, routine list filtering, routine row selection, and company link routing. - `pnpm --filter @paperclipai/ui typecheck`: passed after building the fresh worktree's shared and plugin SDK dependencies. - `node scripts/check-test-budget.mjs --files ui/src/components/routine-page/RoutinePage.test.tsx`: passed. - `pnpm verify`: passed on final head `989dad85d8fc6dfe45cc4490e798dd8da1fb1ff1`. All 309 selected files passed: 4,012 UI tests and 537 CLI tests passed, with one UI test skipped. Environment: macOS arm64, Node 25.6.1, pnpm 9.15.4. - Earlier attempts exposed missing Postgres package library symlinks in the fresh worktree, then a run invalidated by changed setup inputs. Ran the dependency's own symlink hydration script and repeated verification on the stable final checkout. Those earlier attempts are not counted as passes. - CI [typecheck](https://github.com/paperclipai/paperclip/actions/runs/46527285069/job/142231921191), [build](https://github.com/paperclipai/paperclip/actions/runs/46527285069/job/142231921278), and [policy](https://github.com/paperclipai/paperclip/actions/runs/46527285069/job/142231921302) passed on the final head. All selected test and browser shards passed. The final [verify gate](https://github.com/paperclipai/paperclip/actions/runs/46527285069/job/142233704075) and [e2e gate](https://github.com/paperclipai/paperclip/actions/runs/46527285069/job/142233695844) passed on the same head. - [Greptile review](https://github.com/paperclipai/paperclip/pull/23332#issuecomment-7293910180): 5/5 on the final head, with no findings. - No live tenant, deployment, or browser acceptance test was run. This change only changes a link target. - Reviewed the complete diff locally for secrets, personal data, and run artifacts. ## Risks Low risk. The project page already accepts project IDs and applies its existing authorization and canonical URL handling. The link's visible label stays the project name. There is no schema or API change. Revert the link change to restore the former behavior. ## Model Used OpenAI Codex, `gpt-6.1-sol`, with xhigh reasoning effort and local code 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 Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
3884cc6df4 |
fix(ui): open Needs You on Assigned to you, keep saved filters (#23321)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Coordinator Inbox (Needs You, `/decisions`) shows the decisions and problems that wait for a person > - #22964 made the page open on "All assignees" for a board member who has no saved assignee choice > - The page title and badge read as personal, so a board member sees other people's decisions and thinks they are theirs to act on > - This pull request opens the page on "Assigned to you" again when no choice is saved, and keeps the saved toolbar from #22964 > - The benefit is that each person opens on their own work, and a board member who wants the company-wide queue picks "All assignees" once and keeps it ## Linked Issues or Issue Description Refs #22964 **What existing behavior does this improve?** The opening assignee filter on the Coordinator Inbox / Needs You page (`/decisions`). **Current behavior** A board member with no saved assignee choice opens Needs You on "All assignees". The page shows decisions that are for other people (for example, a question an agent asked the person who created the task), with no signal that the list is not personal. **Proposed behavior** Every person with no saved assignee choice opens Needs You on "Assigned to you". The assignee, agent, project, and grouping choices stay saved per company and person, as in #22964. A board member who picks "All assignees" or one person still reopens on that choice. **Reason and benefit** A page named "Needs you" must open on the work that needs this person. The saved toolbar already removes the repeated clicks that #22964 set out to remove, so the company-wide default is not necessary. ## What Changed - `ui/src/lib/coordinator-attention.ts`: `openingCoordinatorAssignee` returns "Assigned to you" when no usable choice is saved, also for board members. A saved choice that the person may open still wins. - `ui/src/components/coordinator/CoordinatorNeedsYou.toolbar.test.tsx`: Tests now start from "Assigned to you", prove that "All assignees" sticks after a person picks it, and prove that the page loads the personal feed at once when nothing is saved. The board-access wait test now covers a saved "All assignees" choice. - `ui/src/lib/coordinator-attention.test.ts`: Update the unit expectations for the opening filter. - `tests/e2e/coordinator-inbox-views.spec.ts`: Assert "Assigned to you" on open, then pick "All assignees" and prove that it and the grouping persist across navigation and reload. - `doc/PRODUCT.md`: Document the opening filter and the saved choices. ## Verification - `cd ui && npx vitest run src/components/coordinator/ src/lib/coordinator-attention.test.ts src/hooks/useAttentionViews.test.tsx src/lib/attention-views.test.ts` → 7 files, 49 tests passed. - RED check: with the old `everyone ? "all" : "me"` fallback restored, 13 tests in the toolbar and coordinator-attention suites fail. - `pnpm --filter @paperclipai/ui typecheck` → pass. - `PAPERCLIP_E2E_PORT=3257 npx playwright test --config tests/e2e/playwright.config.ts tests/e2e/coordinator-inbox-views.spec.ts` against a freshly built UI → 2 passed (desktop and mobile). ## Risks - Behavioral shift: board members who relied on the #22964 default open on "Assigned to you" until they pick "All assignees" once. After that, the saved choice applies. - A board member who already picked a filter keeps it. No saved data changes. - The classic (non-Coordinator) Decisions page is unchanged. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) by Anthropic, in Claude Code with tool use, shell execution, Vitest, and Playwright. ## 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 - [ ] 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>canary/v2026.1130.0-canary.872900 |
||
|
|
1949a8fa10 |
fix(onboarding): sign in through a plugin-managed execution environment (#23312)
## 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> |
||
|
|
554227d926 |
fix(analytics): send queued product events after consent (#23328)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Hosted workspaces record browser product events for the onboarding funnel. > - The wizard can open before a visitor accepts browser analytics. > - The capture path discarded those events and did not send them after Accept. > - This pull request holds pending events in page memory until the visitor accepts. > - The funnel can then retain the original event order and times. ## Linked Issues or Issue Description **What happened?** A visitor could open onboarding, complete steps, and then accept analytics. The earlier browser events were missing. The funnel could show server events such as workspace entry without the later onboarding events, even when the visitor used the wizard. **Expected behavior** Hold structured product events while consent is pending. Send them once after Accept, with their original order and timestamps. Discard them after Decline or a change of user. Do not load PostHog before consent. **Steps to reproduce** 1. Open a hosted workspace that requires analytics consent, with no stored choice. 2. Open onboarding and complete a step before choosing Accept. 3. Choose Accept. 4. Confirm that the opening and step events reach the analytics client once, with their original timestamps. **Paperclip version or commit** The fix is based on master at `630cf042302`. The tested PR revision is `46df54b9ede8e5757f7af1a9d41b3c3593fe3430`. **Deployment mode** Hosted workspace browser analytics. The regression runs locally in jsdom. Related merged work: #22186 added browser consent; #22814 added onboarding failure and chat events; #23315 enabled draft saving in the naming step. A search found no duplicate PR for this queue fix. ## What Changed - Track pending, granted, and denied consent in the browser analytics state. - Reuse the existing 50-event queue while consent is pending. Flush it on Accept, after the client is ready. - Clear pending events on Decline or a change of user. Apply user identity before sending the queue. - Add regression tests for the Accept button, onboarding events, queue limits, and user changes. Document the queue lifetime. - Remove the retired Runner support assertion that draft saving is limited to step 4. PR #23315 added saving in both naming and connect steps. Retain the other first-agent checks and the existing early-setup browser test for name persistence and draft reuse. ## Verification Environment: macOS arm64, Node.js v25.6.1, pnpm 9.15.4. Final local checks use revision `46df54b9ede8e5757f7af1a9d41b3c3593fe3430`. - The Accept-button regression failed before the fix: it expected the earlier events but received an empty capture list. - `pnpm exec vitest run --project @paperclipai/ui ui/src/lib/analytics ui/src/components/ProductAnalyticsGate.test.tsx ui/src/components/ProductAnalyticsSetting.test.tsx`: passed, 289 tests across 9 files. - `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/chat-catalog-domains/identity-new-company-native.test.ts`: passed, 51 tests. This suite first reproduced the stale draft-step assertion from the failed CI job. - `pnpm --filter @paperclipai/ui typecheck`: passed. - `node scripts/check-test-budget.mjs --files tests/runner-e2e/chat-catalog-domains/identity-new-company-native.test.ts ui/src/components/ProductAnalyticsGate.test.tsx ui/src/lib/analytics/onboarding-analytics.test.tsx`: passed. - `git diff origin/master...HEAD --check`: passed. - `pnpm verify`: exited 2 because `doc/cloud-browser-analytics.md` triggers broader CI coverage. Focused checks above passed; the full local suite was not run. - GitHub Actions CI: [all planned suites passed](https://github.com/paperclipai/paperclip/actions/runs/46519983330/job/142210329280) on `46df54b9ede8e5757f7af1a9d41b3c3593fe3430`, including [typecheck and release registry](https://github.com/paperclipai/paperclip/actions/runs/46519983330/job/142208788257), [build](https://github.com/paperclipai/paperclip/actions/runs/46519983330/job/142208788273), Runner support, general tests, serialized tests, and browser E2E shards. No live PostHog capture was checked. - Greptile: [5/5 on the current revision](https://github.com/paperclipai/paperclip/pull/23328#issuecomment-7292786296), with a successful check and no unresolved review threads. ## Risks - Accept now sends structured product events generated earlier in the same page visit. Nothing is sent while consent is pending. - The queue retains at most 50 events in memory. Further events are dropped until it drains. Reloading the page loses the pending queue. - This change does not record earlier page views or session replay. PostHog still loads only after consent. ## Model Used OpenAI `gpt-6.1-sol`, through the Codex harness in T3 Code, with xhigh reasoning effort and shell/code tools. The harness does not expose the context window size. ## 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> |
||
|
|
f37252180b |
fix(openclaw-gateway): keep whitespace on streamed assistant deltas (#14150)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The `openclaw_gateway` adapter streams the agent reply as `assistant` deltas and joins them into the run summary > - Each delta goes through `nonEmpty()`, which trims whitespace > - Deltas carry their word-boundary space (`" blocked"`), so the trim removes it and words run together > - The broken text is stored as the issue comment, so users see corrupted agent replies > - This pull request keeps each delta verbatim and skips only empty strings > - The benefit is that agent comments from the OpenClaw gateway are stored correctly ## Linked Issues or Issue Description Fixes #14149 ## What Changed - Add `readAssistantChunk()` in `execute.ts`. It returns a non-empty string `delta` without a trim. If there is no delta, it falls back to the trimmed `text` (the old behavior). - Use `readAssistantChunk()` in the `assistant` stream handler. - Add unit tests for whitespace-bearing, whitespace-only, empty, and non-string deltas. ## Verification - `npx vitest run src/server/execute.test.ts` in `packages/adapters/openclaw-gateway`: 12 tests pass. - `npx tsc --noEmit` in the same package: no errors. - Manual: the same one-line change is applied to a local 2026.916.1 install that showed the bug. ## Risks Low risk. The change affects only `assistant` deltas. The final `join("").trim()` still removes outer whitespace from the summary. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code 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 - [ ] I have updated relevant documentation to reflect my changes - [x] 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 - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: EpaL <358229+EpaL@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Andrew Aymeloglu <aaymeloglu@gmail.com>canary/v2026.1130.0-canary.872600 |