mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
2eea950c2ee4e76ea88407c39a52054e3a10364f
2851
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
153b48dea9 |
fix(db): honor PostgreSQL URI host parameters for Unix sockets (#14442)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Paperclip stores control-plane state in PostgreSQL through
`packages/db`
> - A self-hosted instance can reach a local PostgreSQL service through
a Unix socket
> - libpq URIs select the socket with the `host` query parameter, but
postgres.js sends that parameter as a server setting and uses TCP
> - This pull request maps the URI `host` parameter to the driver host
option in one shared helper
> - The benefit is that app connections, migrations, backups, and
restores use the socket that the URI selects
## Linked Issues or Issue Description
**What happened?**
With
`DATABASE_URL=postgresql://paperclip@localhost:5432/paperclip?host=/run/postgresql`,
Paperclip connected over TCP to `localhost` instead of the socket.
**Expected behavior**
All JavaScript connections use the socket directory in `host`.
Percent-encoded paths also work. TCP URIs do not change.
**Steps to reproduce**
1. Run PostgreSQL with a Unix socket directory.
2. Set `DATABASE_URL` to a URI with `?host=<socket-directory>`.
3. Start Paperclip or run a JavaScript backup.
4. See that the connection uses TCP, not the socket.
**Paperclip version or commit**
upstream master
|
||
|
|
f4fc0ca0bc |
build(deps): bump @cloudflare/sandbox from 0.7.21 to 0.12.14 in /scripts/typecheck-sandbox-providers (#23827)
Bumps [@cloudflare/sandbox](https://github.com/cloudflare/sandbox-sdk) from 0.7.21 to 0.12.14. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/cloudflare/sandbox-sdk/releases">@cloudflare/sandbox's releases</a>.</em></p> <blockquote> <h2><code>@cloudflare/sandbox</code><a href="https://github.com/0"><code>@0</code></a>.12.14</h2> <h3>Patch Changes</h3> <ul> <li><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/1028">#1028</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/2e4e1eb304e2cbbf5569e095e3ead296a5efbc87"><code>2e4e1eb</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Update the container runtime to Bun 1.4.4. Bun checks certificates against its own built-in CA list, and in 1.4.4 that list no longer trusts the compromised eMudhra intermediates, so the <code>bun</code> command and <code>createBackup()</code> uploads of 10 MiB or more now reject their certificates. Bun 1.4.4 also updates Brotli to 1.2.1, which fixes CVE-2026-111497. The <code>-opencode</code> image ships OpenCode 1.19.4 or later, which also runs on Bun 1.4.4.</li> </ul> <h2><code>@cloudflare/sandbox</code><a href="https://github.com/0"><code>@0</code></a>.12.13</h2> <h3>Patch Changes</h3> <ul> <li><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/1023">#1023</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/a4eaa89aada863cda9ea8a7373404029a1a32761"><code>a4eaa89</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Stop trusting certificates from the compromised eMudhra intermediate CAs in the container images. The images now ship the updated Ubuntu and Alpine CA bundles, Node.js 22.23.4, cloudflared 2026.10.2, and pip 26.2.2 in the <code>-python</code> image. Bun keeps trusting these certificates until it releases a fix, which affects <code>bun</code>, opencode, and multipart uploads in <code>createBackup()</code> for archives of 10 MiB or more. Update the container image to get this fix. See <a href="https://blog.cloudflare.com/emudhra-certificate-compromise/">the eMudhra certificate compromise</a> for details.</li> </ul> <h2><code>@cloudflare/sandbox</code><a href="https://github.com/0"><code>@0</code></a>.12.12</h2> <h3>Patch Changes</h3> <ul> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/1002">#1002</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/8dc216c5c16563d0e3f2044ad14c0657682f3fd9"><code>8dc216c</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Fix <code>mountBucket()</code> breaking an existing mount when a second call for the same mount path fails with "already in use". The existing mount now stays mounted and usable.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/1013">#1013</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/98b787b81b5526851af95e6be9ca98da13ae450d"><code>98b787b</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Keep streaming <code>exec()</code> alive while a command is quiet, and enforce its <code>timeout</code>. Quiet commands were cut off after about four minutes on the HTTP transport and five on WebSocket. The timeout was ignored on those transports, and on every transport for commands that run in a session. Requires the matching container image.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/1008">#1008</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/b2a862cffce187f56bcfae321756c0a9c91b712b"><code>b2a862c</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Keep R2 binding and credential-proxy bucket mounts working when the Sandbox Durable Object restarts while its container keeps running. The mounts used to stay listed but fail every read and write with <code>EIO</code> until <code>mountBucket()</code> was called again.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/1003">#1003</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/e8332cd3c6b0a6f958062304f922d93678f6dfed"><code>e8332cd</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Fix <code>createOpencodeServer()</code> and <code>createOpencode()</code> waiting for the full three-minute startup timeout when <code>OPENCODE_SERVER_PASSWORD</code> is set. When the password is passed in <code>env</code>, the client returned by <code>createOpencode()</code> now authenticates with it.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/1016">#1016</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/d62f020d6b1cae787fc676c11b29b7718c40f575"><code>d62f020</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Create the s3fs password file for <code>mountBucket()</code> with mode 0600 from the start. The file used to be readable by other users in the container until a chmod a moment later, long enough for a non-root process to open it and read the bucket credentials. Upgrade the container image together with the SDK to close the gap; with an older image, mounts work as before.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/996">#996</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/da3d7b6c4edde53b071c42180bca22493e864c9a"><code>da3d7b6</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Answer a preview request with <code>502</code> when the app's port in the container fails, for example because nothing listens on it or it closes the connection, and log the original error. Previously the error escaped the Sandbox, <code>proxyToSandbox()</code> answered <code>500 Proxy routing error</code>, and the log blamed a platform runtime update.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/997">#997</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/c79bf1de83e9be4d5c423b0b60fc7d48792418e7"><code>c79bf1d</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Forward WebSocket upgrades on preview URLs with <code>Host: localhost:<port></code>, like every other preview request. Dev servers that check the <code>Host</code> header, such as Vite, no longer reject HMR connections. The public hostname is still in <code>X-Forwarded-Host</code>.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/1000">#1000</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/c6760770b291531ae9a782e6ddfc2aa32ad8674c"><code>c676077</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Keep preview URLs and tunnels working on the RPC transport after the control connection reconnects. The connection closes after 1 second without calls, and the next call used to rerun the sandbox's start handling even though the container was still running. Preview URLs then returned <code>410 STALE_PREVIEW_URL</code>, <code>getExposedPorts()</code> returned an empty list, quick tunnels disappeared from <code>tunnels.list()</code>, and <code>tunnels.get()</code> could fail with "Tunnel recovery attempts were exhausted".</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/1010">#1010</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/7866d45fb7c1b83e45d1fac4f5c084d712603bb0"><code>7866d45</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Stop the first call on the RPC transport from failing when Cloudflare can't provide a container right away. The call now keeps waiting for the container within its retry window.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/995">#995</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/becade1ff2b472d50340c64b12cf1c9208d945f7"><code>becade1</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Stop the container server from crashing with <code>ENOENT: no such file or directory, watch '…/<id>.log.stderr'</code> while commands run. The crash killed every process in the container. Update the container image to pick up this fix.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/1007">#1007</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/fa571496cd1276d41c8d23672c3e6da541c4d1d1"><code>fa57149</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - <code>tunnels.get()</code> on the RPC transport now reports the real tunnel error, such as <code>cloudflared</code> failing to start or missing from the image, instead of "Tunnel recovery attempts were exhausted". It also no longer leaves a port stuck after giving up: a <code>cloudflared</code> left running from an earlier attempt is stopped and replaced. Replacing it needs the matching container image.</p> </li> </ul> <h2><code>@cloudflare/sandbox</code><a href="https://github.com/0"><code>@0</code></a>.12.11</h2> <h3>Patch Changes</h3> <ul> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/889">#889</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/119336ef67819feda18cf0f716f10db4e1eece73"><code>119336e</code></a> Thanks <a href="https://github.com/scuffi"><code>@scuffi</code></a>! - Stop backups from dropping whole directories when <code>excludes</code> or <code>gitignore: true</code> match a nested path. For example, <code>excludes: ['.cache/foo/*/node_modules']</code> no longer removes all of <code>.cache</code> from the archive. A multi-component pattern such as <code>build/output</code> now matches only relative to the backup directory, while a single-component pattern such as <code>node_modules</code> still matches at any depth. Because mksquashfs does not support <code>**</code>, a pattern like <code>**/node_modules/.cache</code> now excludes only <code>node_modules/.cache</code> at the root of the backup directory; add a pattern for each nested location that must stay out of the backup.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/914">#914</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/66862ff45736e416422736b225da90b5f1dd9cd3"><code>66862ff</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Return 404 with <code>workspace_read_not_found</code> from the bridge's <code>GET /v1/sandbox/:id/file/*</code> when the file doesn't exist. The route used to return 200 with an empty body, the same response as an empty file.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/894">#894</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/20d72db671876a3e50ab0881758cae7576ae2b6e"><code>20d72db</code></a> Thanks <a href="https://github.com/scuffi"><code>@scuffi</code></a>! - Fix local bucket mounts for large files and write bursts. On the RPC transport, objects over 4 MiB now stream into the container instead of failing with an interrupted runtime connection. Container files stream back to R2 byte for byte, without loading the whole file into Worker memory. A file being written uploads once its changes settle, instead of on every write.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/926">#926</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/6678b1378f4ba61586d26f84ee9616a171e6303c"><code>6678b13</code></a> Thanks <a href="https://github.com/ghostwriternr"><code>@ghostwriternr</code></a>! - Stop writing command text and output to Sandbox logs. Exec and process log events now record IDs, exit codes, durations, and output lengths, and the OpenAI Agents <code>Shell</code> and <code>Editor</code> adapters no longer log commands, stderr, or patch text, so secrets in commands, output, or patches no longer reach Workers Logs or container logs. Command failure messages no longer repeat the command; it remains available on the error's <code>context.command</code>.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/888">#888</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/6c9edcc4e466390f52540e48dbd3809ca80fcc89"><code>6c9edcc</code></a> Thanks <a href="https://github.com/scuffi"><code>@scuffi</code></a>! - Fix <code>restoreBackup()</code> error reporting for archives of 10 MB or more. A failed download part now throws a <code>BackupRestoreError</code> that includes curl's error output and each part's exit code, instead of a <code>Shell terminated unexpectedly</code> session error.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/sandbox-sdk/pull/887">#887</a> <a href="https://github.com/cloudflare/sandbox-sdk/commit/13f477d6fc1b4a73b61d333de6a222e8876de860"><code>13f477d</code></a> Thanks <a href="https://github.com/scuffi"><code>@scuffi</code></a>! - Sync local bucket mounts outside <code>/workspace</code>, such as <code>/data</code>, from the container back to R2. <code>watch()</code> and <code>checkChanges()</code> now accept any absolute path on every transport, as documented. A local mount whose container rejects the watch now logs one error instead of retrying forever.</p> </li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/cloudflare/sandbox-sdk/commit/b96de6ea1ca248e11a56a78f1efabc2717d6c7b9"><code>b96de6e</code></a> Version Packages (<a href="https://redirect.github.com/cloudflare/sandbox-sdk/issues/1034">#1034</a>)</li> <li><a href="https://github.com/cloudflare/sandbox-sdk/commit/2e4e1eb304e2cbbf5569e095e3ead296a5efbc87"><code>2e4e1eb</code></a> Update the container runtime to Bun 1.4.4 (<a href="https://redirect.github.com/cloudflare/sandbox-sdk/issues/1028">#1028</a>)</li> <li><a href="https://github.com/cloudflare/sandbox-sdk/commit/b3a8566c61c15bdc24d216fadb322fd673bb0aca"><code>b3a8566</code></a> Promote public refs to 0.12.13 (<a href="https://redirect.github.com/cloudflare/sandbox-sdk/issues/1027">#1027</a>)</li> <li><a href="https://github.com/cloudflare/sandbox-sdk/commit/2538b5540b2f79b56af2a81fa0fa2b353948d667"><code>2538b55</code></a> Version Packages (<a href="https://redirect.github.com/cloudflare/sandbox-sdk/issues/1026">#1026</a>)</li> <li><a href="https://github.com/cloudflare/sandbox-sdk/commit/a4eaa89aada863cda9ea8a7373404029a1a32761"><code>a4eaa89</code></a> Stop trusting compromised eMudhra intermediates (<a href="https://redirect.github.com/cloudflare/sandbox-sdk/issues/1023">#1023</a>)</li> <li><a href="https://github.com/cloudflare/sandbox-sdk/commit/7fbb9e5dd3a419570fee79bb98365668b5188984"><code>7fbb9e5</code></a> Keep polling when a rollout wrangler call fails (<a href="https://redirect.github.com/cloudflare/sandbox-sdk/issues/1018">#1018</a>)</li> <li><a href="https://github.com/cloudflare/sandbox-sdk/commit/e3ebd96707fdb86ac68ce1641963864f5e5e4a81"><code>e3ebd96</code></a> Promote public references to 0.12.12 (<a href="https://redirect.github.com/cloudflare/sandbox-sdk/issues/1019">#1019</a>)</li> <li><a href="https://github.com/cloudflare/sandbox-sdk/commit/0d96b78f58c9e808688352d621249b673767cedf"><code>0d96b78</code></a> Version Packages (<a href="https://redirect.github.com/cloudflare/sandbox-sdk/issues/1004">#1004</a>)</li> <li><a href="https://github.com/cloudflare/sandbox-sdk/commit/d62f020d6b1cae787fc676c11b29b7718c40f575"><code>d62f020</code></a> Create s3fs support files owner-only from the start (<a href="https://redirect.github.com/cloudflare/sandbox-sdk/issues/1016">#1016</a>)</li> <li><a href="https://github.com/cloudflare/sandbox-sdk/commit/98b787b81b5526851af95e6be9ca98da13ae450d"><code>98b787b</code></a> Stop cutting off quiet exec streams (<a href="https://redirect.github.com/cloudflare/sandbox-sdk/issues/1013">#1013</a>)</li> <li>Additional commits viewable in <a href="https://github.com/cloudflare/sandbox-sdk/compare/@cloudflare/sandbox@0.7.21...@cloudflare/sandbox@0.12.14">compare view</a></li> </ul> </details> <br /> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
3befcd245b |
feat(connections): add LinkedIn REST connector (v1 personal posting) (#23388)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - App connectors let agents call external APIs under company/user
grants, risk classification, and audit governance
> - LinkedIn does not publish an official remote MCP server, and its
public API separates self-serve personal posting (`Share on LinkedIn`)
from vetted commercial Company Page management (`Community Management
API`)
> - Users want a governed native LinkedIn connector without waiting
weeks for commercial review or relying on ToS-violating scrapers
> - This pull request adds a reviewed native LinkedIn REST adapter
(`server/src/services/connectors/linkedin/`) registered in
`rest-registry.ts`, extracts a shared governed REST transport
(`server/src/services/connectors/rest-transport.ts`) used by LinkedIn,
Vercel, and Supabase, and wires managed Paperclip Cloud OAuth
(`linkedin.share`) plus customer-owned OAuth fallback
> - The benefit is governed personal LinkedIn publishing
(`linkedin_get_profile`, `linkedin_create_post`, `linkedin_delete_post`)
with S4 destructive classification, shared transport security
guarantees, and clean expansion room for v2 Company Page support
## Linked Issues or Issue Description
**Subsystem affected**
Cross-cutting (multiple of the above)
**Problem or motivation**
Paperclip has no native LinkedIn connector. LinkedIn does not publish an
official remote MCP server, and standard self-serve OAuth requires a
pre-registered LinkedIn Developer App with exact callback URIs and
explicit governance for public broadcasts.
**Proposed solution**
Add a reviewed native LinkedIn REST adapter
(`server/src/services/connectors/linkedin/`) in `rest-registry.ts`
supporting v1 self-serve OIDC Sign In + Share on LinkedIn (`openid`,
`profile`, `email`, `w_member_social`), backed by a shared governed REST
transport (`server/src/services/connectors/rest-transport.ts`) shared
across LinkedIn, Vercel, and Supabase, paired with the `linkedin.share`
managed OAuth profile in `paperclip-cloud` and a customer-owned OAuth
fallback.
**Alternatives considered**
- Remote MCP: ruled out because LinkedIn has no official MCP server.
- Waiting for Community Management API review before v1: deferred to v2
so personal posting ships now without blocking on commercial app review.
## What Changed
- Extracted shared governed REST transport
(`server/src/services/connectors/rest-transport.ts` and
`rest-transport.test.ts`) owning pre-`Headers` Bearer validation, token
redaction in strings and object keys, origin/prefix pinning, `redirect:
"error"`, deadline racing with forged-504 rejection, input/output byte
caps with reader cancellation, and unified write uncertain-outcome
(`408`/`5xx`/unparseable 2xx) handling; converged LinkedIn, Vercel, and
Supabase adapters onto it.
- Added reviewed LinkedIn REST adapter
(`server/src/services/connectors/linkedin/catalog.ts`, `index.ts`,
`index.test.ts`) using `LinkedIn-Version: 202611` and registered it in
`server/src/services/connectors/rest-registry.ts`:
- `linkedin_get_profile` (`read`, also powers `probe()` via `GET
/v2/userinfo`)
- `linkedin_create_post` (`destructive`, S4; derives `author` URN from
authenticated grant via `POST /rest/posts`)
- `linkedin_delete_post` (`destructive`, S4; validates post URN via
`DELETE /rest/posts/{encoded_urn}`)
- Added `packages/shared/src/linkedin-connectors.ts` (`linkedin.share`
profile & scopes) and exported from `packages/shared/src/index.ts`.
- Wired `linkedin` / `linkedin.share` into
`server/src/services/paperclip-cloud-connector.ts`,
`server/src/services/tool-access/oauth/client-settings.ts` (with
exhaustive `managedConnectorIssuer` mapping), and
`server/src/services/tool-access/oauth/authorization-start.ts`.
- Added official sanitized LinkedIn SVG
(`ui/public/brands/apps/linkedin.svg`) and registered it in
`ui/public/brands/apps/manifest.json`.
- Added reviewed catalog override
(`scripts/app-definition-overrides/linkedin.json`), regenerated
`packages/shared/src/app-definitions/linkedin.json` and
`app-definitions.generated.ts`, added `"linkedin"` to
`CONNECTABLE_APP_SLUGS`, and added permission reviews in
`doc/connections/tool-method-permission-reviews.json`.
- Added `doc/connections/LINKEDIN.md` and indexed it in
`doc/connections/README.md`.
- Merged `master` and resynced
`tests/runner-e2e/source-sdk-public-inputs.json`.
## Verification
- `node scripts/check-app-brand-assets.mjs` — passed (115 brand
identities validated)
- `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse
HEAD) --check` — passed (`changed: false`)
- `pnpm --filter @paperclipai/shared typecheck && pnpm --filter
@paperclipai/server typecheck && pnpm --filter @paperclipai/ui
typecheck` — passed
- `pnpm exec vitest run
server/src/services/connectors/rest-transport.test.ts
server/src/services/connectors/linkedin/index.test.ts
server/src/services/connectors/vercel/index.test.ts
server/src/services/connectors/supabase/index.test.ts
server/src/services/tool-access/oauth/client-settings.test.ts
server/src/services/paperclip-cloud-connector.test.ts
server/src/__tests__/connector-tool-policy.test.ts
packages/shared/src/app-definitions.test.ts` — passed (8 files, 248/248
tests)
- `pnpm exec vitest run ui/src/lib/app-brand-assets.test.ts --project
@paperclipai/ui` — passed (7/7)
- `pnpm verify --explain` — exit 2 (global CI input
`doc/connections/tool-method-permission-reviews.json` changed; full CI
`ci / verify` and `ci / e2e` running on current head `cc7e3a8184`)
- **Live-provider proof (human-gated — pending):** Registering
Paperclip's LinkedIn Developer App + AWS Secrets Manager credentials on
`paperclip-cloud` (companion PR) and completing an interactive OAuth
sign-in on a real LinkedIn account are required before live-account
acceptance.
## Risks
- LinkedIn posts are public external broadcasts (S4); both
`linkedin_create_post` and `linkedin_delete_post` are classified
`destructive`, and `author` is always derived from the authenticated
grant rather than caller input.
- Standard self-serve LinkedIn tokens expire every 60 days without a
refresh token; UI copy and docs state this explicitly.
- Extracting `rest-transport.ts` touches Vercel and Supabase adapters
alongside LinkedIn; all three adapters' unit suites (80 tests combined)
plus dedicated `rest-transport.test.ts` pass and preserve existing
status/error codes while extending unified write
`408`/`5xx`/unparseable-2xx uncertain-outcome protection.
- Deploy the companion `paperclip-cloud` PR (`feat/linkedin-connector`)
and configure LinkedIn client credentials before enabling `managed`
sign-in on Cloud stacks.
## 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
|
||
|
|
83d80b431b |
perf(db): add partial indexes for chat_actions run publications and pending work (#23811)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - External chat connectors (GitHub, Slack, Telegram, voice) store
webhook ingress, publication receipts, and scheduled background work in
`chat_actions`
> - On large instances (~325k rows in `chat_actions`, mostly processed
`github_webhook_ingress`), two hot query families fall back to full
sequential scans because existing partial indexes do not cover their
predicates
> - `githubRunReplyState` queries `kind = 'github_review_publication'`
across all statuses (including unsettled
`received`/`processing`/`failed` rows), so PostgreSQL cannot use
`chat_actions_github_task_publications_idx` (`WHERE kind =
'github_review_publication' AND status = 'processed'`)
> - Scheduled work polling (`nextChatActionAt`, `dueChatAction`, and
pending GitHub publication/response sweeps) filters active non-terminal
statuses (`received`, `processing`, `queued`, etc.) and retryable
failures across kinds that have no matching partial work index
> - This pull request adds two concurrent, idempotent, online-compatible
partial indexes on `chat_actions`
(`chat_actions_github_run_publications_idx` and
`chat_actions_pending_work_idx`) and adds PostgreSQL `EXPLAIN (ANALYZE,
BUFFERS)` regression coverage
> - The benefit is eliminating repeated full-table sequential scans on
`chat_actions` without locking writes during migration or altering query
semantics
## Linked Issues or Issue Description
**What happened?**
On a PostgreSQL instance with ~325k `chat_actions` rows (mostly
processed `github_webhook_ingress`), `chat_actions` incurred ~103 full
sequential scans per 5 seconds (20.6 scans/s):
- `githubRunReplyState` (`server/src/services/chat-run-publications.ts`)
ran a `Parallel Seq Scan on chat_actions` (218.6 ms, 100,595 shared
buffer hits for 1 row) because
`chat_actions_github_task_publications_idx` restricts `status =
'processed'` while `githubRunReplyState` must also inspect unsettled
rows.
- Scheduled action polling (`nextChatActionAt` and `dueChatAction` in
`server/src/services/chat-action-work.ts`, plus
`nextPendingAt`/`processPending` in
`server/src/services/chat-github-reviews.ts` and
`server/src/services/chat-github-response-comments.ts`) ran full
sequential scans (62.4 ms, 25,212 shared buffer hits) because no partial
work index covered `status IN ('received', 'processing', ...) OR (status
= 'failed' AND result->>'retryable' = 'true')` by `kind`. (Existing
`review-check-work.ts` and `acknowledgement-work.ts` do not include
`'processing'` and already use `chat_actions_github_check_work_idx` and
`chat_actions_github_ack_work_idx`.)
**Expected behavior**
PostgreSQL should resolve `githubRunReplyState` and scheduled
`chat_actions` work polling through small partial indexes in
sub-millisecond time with minimal shared buffer hits and zero full
sequential scans over completed webhook history.
**Steps to reproduce**
1. Populate `chat_actions` with ~10k+ processed `github_webhook_ingress`
and `github_review_publication` rows plus active target rows, then run
`VACUUM ANALYZE chat_actions`.
2. Run `EXPLAIN (ANALYZE, BUFFERS)` on `githubRunReplyState(...)` and on
`nextChatActionAt(db, "github_webhook_ingress")` /
`dueChatAction("github_webhook_ingress")`.
3. Observe full `Seq Scan on chat_actions` scanning all table pages
before this migration.
**Paperclip version or commit**
`master` (`6a5dfc0288`)
**Deployment mode**
Self-hosted server
## What Changed
- Added `chat_actions_github_run_publications_idx` in
`packages/db/src/schema/chat_channels.ts` on `(company_id, endpoint_id,
(payload->'session'->>'issueId'), (payload->'session'->>'runId')) WHERE
kind = 'github_review_publication'`.
- Added `chat_actions_pending_work_idx` in
`packages/db/src/schema/chat_channels.ts` on `(kind, created_at, id)
WHERE status IN ('received', 'processing', 'queued',
'provider_confirmed', 'admitting', 'resolving', 'validating',
'dispatching') OR (kind = 'failed_run_retry' AND status IN ('issued',
'processing')) OR (status = 'failed' AND result->>'retryable' =
'true')`. (Excludes permanently `'issued'` kinds such as
`task_control_authorization` and completed/cancelled/non-retryable
history so the index stays minimal at rest.)
- Generated migration
`packages/db/src/migrations/0516_exotic_spectrum.sql` with idempotent
`CREATE INDEX CONCURRENTLY IF NOT EXISTS`, registered it in
`MIGRATIONS_WITH_TOP_LEVEL_STATEMENTS` in `packages/db/src/client.ts`,
and pruned schema snapshots to the 5 newest (`0512`–`0516`).
- Extended `server/src/__tests__/chat-admission-condition.test.ts` with
embedded PostgreSQL regression coverage verifying result behavior and
`EXPLAIN (ANALYZE, BUFFERS)` partial index usage (zero `Seq Scan` on
`chat_actions`) for `githubRunReplyState`, every `ScheduledChatAction`
in `CHAT_ACTION_QUEUES` (`nextChatActionAt`), `dueChatAction`
(`github_webhook_ingress`, `failed_run_retry`),
`githubChatReviewService.nextPendingAt`/`processPending`,
`githubResponseCommentService.processPending`, and
`speko_voice_reply_push` (`dispatching`).
## Verification
- Local red/green `EXPLAIN (ANALYZE, BUFFERS)` against embedded
PostgreSQL 18 with 10,003 `chat_actions` rows (8,000 processed
`github_webhook_ingress`, 1,000 processed `github_review_publication`,
500 processed `inbound_wakeup`, 500 issued `task_control_authorization`,
3 target rows) with strict result equality verified before and after
applying the concurrent partial-index migration SQL (and verified 2x
idempotent replay + `indisvalid = true`, `indisready = true`, index
sizes 152 kB and 16 kB):
| Query | Before | After (`0516`) |
| --- | --- | --- |
| `githubRunReplyState` | `Seq Scan` (0.900 ms, 2,204 buffer hits) |
`Index Scan(chat_actions_github_run_publications_idx)` (0.018 ms, 7
buffer hits) |
| `nextChatActionAt(github_webhook_ingress)` | `Seq Scan` (1.169 ms,
2,200 buffer hits) | `Bitmap Index Scan(chat_actions_pending_work_idx)`
(0.011 ms, 2 buffer hits) |
| `nextChatActionAt(provider_effect)` | `Seq Scan` (0.891 ms, 2,200
buffer hits) | `Index Scan(chat_actions_pending_work_idx)` (0.005 ms, 1
buffer hit) |
| `nextChatActionAt(failed_run_retry)` | `Index
Scan(chat_actions_company_issue_kind_idx)` (0.028 ms, 11 buffer hits) |
`Index Scan(chat_actions_pending_work_idx)` (0.006 ms, 2 buffer hits) |
| `nextChatActionAt(slash_task_start)` | `Seq Scan` (0.839 ms, 2,200
buffer hits) | `Index Scan(chat_actions_pending_work_idx)` (0.007 ms, 1
buffer hit) |
| `dueChatAction(github_webhook_ingress)` | `Seq Scan` (1.148 ms, 2,200
buffer hits) | `Bitmap Index Scan(chat_actions_pending_work_idx)` (0.010
ms, 2 buffer hits) |
| `chat-github-reviews.nextPendingAt()` | `Seq Scan` (0.807 ms, 2,200
buffer hits) | `Index Scan(chat_actions_pending_work_idx)` (0.004 ms, 2
buffer hits) |
- Verified prepared-statement execution (`PREPARE` + 10 `EXECUTE` runs)
keeps custom partial-index plans on the 10th execution (`0.004–0.010
ms`) and does not regress `githubLatestTaskResponseUrl`
(`chat_actions_github_task_publications_idx`) or `review-check-work`
(`chat_actions_github_check_work_idx`).
- Ran local checks on commit `97f0f7294262aa129dd283072108ce6932f3a447`:
- `pnpm --filter @paperclipai/db build` — PASS
- `pnpm --filter @paperclipai/db check:migrations` — PASS (1 new
migration, `online_compatible`, none blocked)
- `pnpm check:module-boundaries` — PASS
- `node scripts/check-test-budget.mjs --base origin/master` — PASS (113
nightly suites validated, 1 test file checked)
- `pnpm --filter @paperclipai/db typecheck` & `pnpm --filter
@paperclipai/server typecheck` — PASS
- `pnpm exec vitest run packages/db/src/check-migration-safety.test.ts
packages/db/src/migration-compatibility.test.ts
packages/db/src/migration-snapshot-drift.test.ts
server/src/__tests__/chat-admission-condition.test.ts` — 4 files, 149
tests passed
## Risks
- Low risk: purely additive migration creating two partial indexes with
`CREATE INDEX CONCURRENTLY IF NOT EXISTS` in
`MIGRATIONS_WITH_TOP_LEVEL_STATEMENTS`. Writes are not blocked during
index build, existing indexes
(`chat_actions_github_task_publications_idx`,
`chat_actions_github_check_work_idx`,
`chat_actions_github_ack_work_idx`) remain untouched, and previous
releases continue serving safely during rolling deploy.
- Small write-amplification trade-off: active `chat_actions` rows enter
`chat_actions_pending_work_idx` while non-terminal and leave once
settled; `chat_actions_github_run_publications_idx` tracks
`github_review_publication` rows only (excluding high-volume
`github_webhook_ingress` history).
## Model Used
- Gemini 4 Neon (Google DeepMind, XHigh reasoning, 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
- [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>
|
||
|
|
bc548a736a |
test: fix CLI bind races and SSH fixture input (#23830)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - CI runs fixtures for real CLI servers and SSH commands. > - The CLI fixture can lose its fallback port before the server binds it. > - The SSH login-profile fixture must supply the command payload on stdin. > - These fixture failures stop CI before it can verify the application behavior. > - This pull request adds bounded CLI bind retries and supplies the SSH stdin payload. > - The fixtures retain their startup deadlines, child identity checks, and behavior assertions. ## Linked Issues or Issue Description **What happened?** [Source verification 47462717613, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/47462717613/job/145492578739) failed in `cli/src/__tests__/company-import-export-e2e.test.ts`. The fixture occupied port 41511. The server selected 41512, then exited with `listen EADDRINUSE: address already in use 127.0.0.1:41512`. The suite failed before health readiness. The other 354 files passed, with 3,971 tests passed and one skipped. This cancelled [image run 47462717565](https://github.com/paperclipai/paperclip/actions/runs/47462717565). The SSH login-profile fixture also ran the command bootstrap without its stdin payload. It exited with code 125 before it could check profile behavior. [CI run 47464397195 on `ef3250d`](https://github.com/paperclipai/paperclip/actions/runs/47464397195/job/145497678930) failed on that test. The CLI shard passed in the same run. **Expected behavior** A fixture can start a fresh attempt after it loses a listener bind race to another local process. A configuration error, signal exit, health timeout, or test assertion must still fail. Runtime discovery must use the child PID and actual fallback port. The SSH fixture must supply `stdinPrefix` to execute the generated remote command. **Steps to reproduce** The failed source was master `dfe392dada69838da3d7c33a0ef00d7e4cfc60f3`, in local trusted mode. Reserve a loopback port, then make a child process bind that port. The new socket regression test does this without timing assumptions. Without the retry policy, the first collision aborts startup. For the SSH failure, run `PAPERCLIP_VITEST_RETRY=0 pnpm exec vitest run packages/adapter-utils/src/ssh-fixture.test.ts -t 'survives a bash-only login profile' --maxWorkers=1` on a host with `dash`. Before the stdin fix, it exits 125 with empty output. Refs #23813: that separate database teardown fix is already in this master revision. This failure is a listener bind collision. ## What Changed - Retry only a child exit with code 1 and the listener `EADDRINUSE` diagnostic on stderr. Limit startup to three attempts. - Release the old port reservation and start a fresh child with a fresh requested-port reservation on each attempt. - Share the original 90-second startup deadline across attempts. Keep the PID-matched runtime health check and the assertion that the server used a fallback port. - Recognize a child that has already exited by signal, so cleanup does not wait for a past exit event. - Add real-socket regression tests for recovery, failure limits, and other startup errors. - Pass `target.stdinPrefix` to the SSH login-profile fixture process, as required by the existing transport contract. ## Verification - CLI red: with the policy set to one attempt, the socket recovery test failed with the same `EADDRINUSE` diagnostic as CI. The bounded-attempt test also failed. - CLI green: `PAPERCLIP_VITEST_RETRY=0 pnpm exec vitest run cli/src/__tests__/server-startup.test.ts cli/src/__tests__/company-import-export-e2e.test.ts --maxWorkers=1` passed both suites and all five tests after rebase. CLI typecheck passed. These files have not changed since that verification. - SSH red: the targeted login-profile test failed locally with exit 125 and retries disabled, matching the CI failure on `ef3250d`. - SSH green: `PAPERCLIP_VITEST_RETRY=0 pnpm exec vitest run packages/adapter-utils/src/ssh-fixture.test.ts --maxWorkers=1` passed 26 tests, with two skipped. `pnpm exec tsc --noEmit -p packages/adapter-utils/tsconfig.json` passed. - The test budget check passed for all three changed test files. `git diff --check` passed. Final head: `4b0a5e4b96702829454b101b57be313b8908a63e`. - The CLI dependency-selection plan retained 2,347 of 3,084 test files on the previous head. Required CI will verify the final head with the SSH correction. No full local suite was run. - [Greptile rated final head `4b0a5e4b96702829454b101b57be313b8908a63e` 5/5](https://github.com/paperclipai/paperclip/pull/23830#issuecomment-7429780977), with no actionable findings or review threads. Final check results: 76 passed, six skipped, none pending or failed. The [final CI workflow](https://github.com/paperclipai/paperclip/actions/runs/47465088910) passed, and GitHub reports no merge conflicts. - Operational recovery: [image run 47463279495](https://github.com/paperclipai/paperclip/actions/runs/47463279495/job/145501215693) passed exact-source verification and published the AMD64/ARM64 manifest for master `6a5dfc028831831756bea006df4e399e31cdf281`. Tag: `ghcr.io/paperclipai/paperclip:sha-6a5dfc0`. Digest: `sha256:44576ab5bc386903dd592ed1f3e7277f60e0cd6c696590996d02330be2fbdbff`. All publication gates remained in place. This establishes publication recovery; these fixture changes address recurrence and still need to merge. ## Risks - Low risk. This changes test fixture startup only. - A persistent collision still fails after three attempts. Other failures retain their diagnostics and do not retry. Each recovered collision emits a warning in the test log. - Production listener selection is unchanged. This PR does not add a production server restart policy. - No documentation change is needed because the application contract does not change. ## Model Used - OpenAI `gpt-6.1-sol`, through the Codex harness in T3 Code, with xhigh reasoning effort and shell tools. The context window size is not exposed. ## 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> |
||
|
|
65f429305e |
build(deps-dev): bump @types/node from 24.13.3 to 24.19.2 in /packages/plugins/sandbox-providers/daytona (#19564)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 24.13.3 to 24.19.2. <details> <summary>Commits</summary> <ul> <li>See full diff in <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node">compare view</a></li> </ul> </details> <br /> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
205482b2c2 |
fix(telemetry): emit missing server telemetry across native, onboarding, and routine paths (#23297)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip emits first-party product telemetry from server lifecycle transitions so operators and Cloud analytics can measure real agent runs, completions, onboarding, and routines > - A full audit of every `track*` helper in `packages/shared/src/telemetry/events.ts` found several server code paths that perform real product transitions directly in the database without emitting their existing telemetry events: native/reconciliation terminal run failure writers (`agent.task_run`), agent-accepted `native_completion_review` closures (`agent.task_completed`), `active-run-watchdog` overwriting a null `lastHeartbeatAt` (suppressing `agent.first_heartbeat`), `onboarding-seed` creating the first agent and mission goal (`agent.created`, `goal.created`), routine suggestions creating a routine (`routine.created`), and standing check reports recording a routine run (`routine.run`) > - Because those paths bypass the REST routes or `emitTerminalAgentTaskRun` (which skips rows already written to `"failed"`), deployments under-report failed native runs, agent-reviewed completions, onboarding hires, and routine activity > - This pull request wires up the existing telemetry helpers at each missing server-side transition after transaction commit using a shared terminal-failure emitter, passes an explicit root database handle for post-commit operator-containment telemetry, skips non-terminal `retryable_failure` writes while emitting non-blocking telemetry on `retryable_failure -> terminal_failure` / `committed` transitions (including superseded retry retirement), keeps `agent-task-run-telemetry.ts` free of circular imports from `run-failure-report.ts`, updates `packages/shared/src/telemetry/README.md`, and adds embedded-Postgres regression tests covering every restored path > - The benefit is complete, deduplicated, non-blocking server-side telemetry across native runtime, onboarding, and routine flows without changing any telemetry contract schema ## Linked Issues or Issue Description Refs #22963 **What happened?** Several server-side lifecycle paths transitioned database rows directly without emitting their existing first-party telemetry events: 1. `native-session-executor.ts`, `native-restart-recovery.ts`, `native-superseded-retry.ts`, `execution-control-reconciliation.ts`, and `native-failed-run-owner-release.ts` wrote `heartbeat_runs.status = 'failed'` or transitioned `retryable_failure -> terminal_failure` directly (so `heartbeat.ts`'s `emitTerminalAgentTaskRun` later saw `previousStatus === updated.status` and skipped `agent.task_run`). 2. `issue-thread-interactions.ts` allowed an agent reviewer to accept a `native_completion_review` confirmation card and move an `in_review` task to `done` without emitting `agent.task_completed`. 3. `active-run-watchdog/adapters/postgres.ts` set `agents.lastHeartbeatAt = new Date()` unconditionally when folding a silent run instead of using `settledHeartbeat(now)`, suppressing `agent.first_heartbeat` for never-heartbeated agents. 4. `onboarding-seed.ts` created a company's first agent and mission goal without emitting `agent.created` or `goal.created`. 5. `routine-suggestions.ts` created routines from task suggestions without emitting `routine.created`, and `routine-standing-checks.ts` inserted completed `routine_runs` without emitting `routine.run`. **Expected behavior** Each of those committed transitions emits its existing first-party telemetry event once after commit, non-blocking, with accurate company and person scope (`withTelemetryActor` / `withTelemetryCompany`), using an explicit live root DB handle after outer transaction commit, skipping pending native retries (`retryable_failure`), and emitting no duplicates on replay or rollback. **Steps to reproduce** 1. Trigger any of the paths above in embedded Postgres (as exercised in `server/src/__tests__/missing-server-telemetry-emissions.test.ts`). 2. Observe that the database state transitions as expected, while the corresponding telemetry event is missing, dropped on a finished transaction, prematurely emitted on a retryable native failure, or blocking finalization while pending. **Paperclip version or commit** Merged cleanly with `master` at `054b4e1395b7f246e2c18d222b701595daf5522b` (PR head `b4e70c295b78de4bdcec1788e342c421cce1e138`). ## What Changed - `server/src/services/agent-task-run-telemetry.ts` & `server/src/services/run-failure-report.ts`: keep `isRunFailureStatus`, `isPendingNativeRetry`, and `isNewTerminalRunFailure` as pure leaf helpers in `agent-task-run-telemetry.ts` (re-exported by `run-failure-report.ts`) and colocate `emitTerminalRunFailure(db, run, options)` in `run-failure-report.ts` so `agent-task-run-telemetry.ts` never imports `run-failure-report.ts` (avoiding a circular dependency into `status-decision-committer.ts` that broke `vi.mock("../agent-task-run-telemetry.js")` in `native-task-completed-telemetry.test.ts`). Tighten `isNewTerminalRunFailure` so writes into `failed/retryable_failure` return `false` while writes leaving `retryable_failure` into a terminal failure return `true`, guard `emitAgentTaskRun` against `isPendingNativeRetry`, and select `nativePhase` in `emitAgentTaskRunById`. - `server/src/routes/issues.ts`, `server/src/services/execution-recovery-resolution.ts`, and `server/src/services/native-runtime/native-failed-run-owner-release.ts`: require an explicit root `telemetryDb: Db` whenever `controllerContainment` is set (discriminated union type plus runtime guard, removing the `input.telemetryDb ?? input.db` and `release.telemetryDb ?? db` fallbacks) so `afterTransactionCommit` always runs `emitTerminalRunFailure` against the root pool instead of a finished outer transaction, gated on `isNewTerminalRunFailure(run, settledRun)`. - `server/src/services/native-runtime/native-run-finalizer.ts` and `server/src/services/native-runtime/native-run-projection.ts`: emit non-blocking `void emitAgentTaskRun(...)` + `void reportRunFailure(...)` on the `isNewTerminalRunFailure` branch when a native run transitions from `failed/retryable_failure` to `failed/committed`, ensuring telemetry DB lookups never block finalization, projection, review responses, or chat settlement. - `server/src/services/native-runtime/native-superseded-retry.ts`, `server/src/services/native-runtime/native-finalization-reconciler.ts`, and `server/src/services/native-runtime/native-restart-recovery.ts`: return the retired `heartbeatRuns` row from `retireSupersededNativeRetry` so both `claimNativeSessionResumptions` and `claimNativeRestartRecoveries` emit `agent.task_run` and `reportRunFailure` once after commit when retiring a superseded `retryable_failure` run to `terminal_failure`. - `server/src/services/native-runtime/native-session-executor.ts`: select `runtimeMode` and `nativePhase` before the failure write, gate on `isNewTerminalRunFailure(runBeforeWrite, updatedRun)`, and emit via `emitTerminalRunFailure(input.db, terminalRunToReport, { failureReport: { nativeCloseFailure: error } })`. - `server/src/services/native-runtime/native-restart-recovery.ts`: return `updatedRun` from `endNamespaceUnverifiedRun` and call `emitTerminalRunFailure` after commit in both `claimNativeRestartRecoveries` and `boundAwaitingEvidence` (making `boundAwaitingEvidence` consistent with inline unverified-run termination for both telemetry and Sentry failure reporting). - `server/src/services/execution-control-reconciliation.ts`: gate terminal failure detection on `isNewTerminalRunFailure(run, updatedRun)` and emit via `emitTerminalRunFailure(db, terminalRunToReport)`. - `server/src/modules/active-run-watchdog/adapters/postgres.ts`: use `settledHeartbeat(now)` instead of `new Date()` when folding a silent run so a never-heartbeated agent keeps `lastHeartbeatAt = null` until its first real heartbeat. - `server/src/services/issue-thread-interactions.ts`: call `void emitAgentTaskCompleted(committedDb, completedTask)` in the post-commit `publish` hook when an agent reviewer accepts a `native_completion_review` confirmation card and closes the task to `done`. - `server/src/services/onboarding-seed.ts`: emit `trackAgentCreated` (after hire commit) and `trackGoalCreated` (via `afterTransactionCommit`) with `withTelemetryActor` when onboarding seed creates a new first agent or mission goal. - `server/src/services/routine-suggestions.ts`: emit `trackRoutineCreated` with `withTelemetryActor` after both the routine and its trigger are created. - `server/src/services/routine-standing-checks.ts`: emit `trackRoutineRun` (`source: STANDING_CHECK_TRIGGER_KIND` = `"heartbeat"`, `status: "completed"`) with `withTelemetryCompany` after committing a standing-check report. Emitting the raw value follows `packages/shared/src/telemetry/README.md`; the receiving layer and `posthog-direct/enum-fallbacks.generated.ts` normalize unknown `routine.run.source` values to `"other"` until `"heartbeat"` is promoted in the telemetry schema. - `packages/shared/src/telemetry/README.md` & `tests/runner-e2e/source-sdk-public-inputs.json`: document the restored `agent.task_run` and `agent.task_completed` emission paths per `rules/data-paths.mdc`. - `server/src/__tests__/missing-server-telemetry-emissions.test.ts`: add embedded-Postgres TDD regression tests covering every restored path, including `isNewTerminalRunFailure`, the real board containment route (`POST /api/issues/:id/recovery-actions/resolve`) for both `running` and `retryable_failure` runs, `native-session-executor` retryable vs terminal settlement, `native-restart-recovery` inline and `boundAwaitingEvidence` termination, non-blocking `finalizeNativeRun` / `projectCommittedRun` while `emitAgentTaskRun` is pending, superseded-retry retirement telemetry in both `claimNativeRestartRecoveries` and `claimNativeSessionResumptions`, and strict `telemetryDb` enforcement on `validateExecutionReconciliation`. ## Telemetry Contract Exception (`rules/data-paths.mdc`) - **Unchanged generated contract exception:** `packages/shared/src/telemetry/generated/paperclip-telemetry.ts` has no diff in this PR because all six emitted events (`agent.task_run`, `agent.task_completed`, `agent.created`, `goal.created`, `routine.created`, `routine.run`) and all of their dimensions, types, and optionality already exist unchanged in the generated contract. No new event names, dimensions, or enum values were added to the telemetry contract. - **Documentation & privacy review preserved:** `packages/shared/src/telemetry/README.md` is updated in this PR to document the restored emission paths, and privacy review remains requested per `rules/data-paths.mdc` because this PR adds callers to existing helpers in `packages/shared/src/telemetry/events.ts`. ## Verification - **RED (initial review-finding regression proof before fix on `9f10d34af2`):** `pnpm --filter @paperclipai/server exec vitest run src/__tests__/missing-server-telemetry-emissions.test.ts -t "classifies pending native retries|board containment route|retryable native session failures"` — **3/3 failed**. - **RED (targeted P1/CI/review fix pass before `b4e70c295b`):** - `pnpm --filter @paperclipai/server exec vitest run src/services/native-runtime/native-task-completed-telemetry.test.ts` — **3/3 failed** (reproducing CI shard 16 failure caused by the `agent-task-run-telemetry.ts -> run-failure-report.ts` circular import into `status-decision-committer.ts`). - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/missing-server-telemetry-emissions.test.ts -t "without awaiting emitAgentTaskRun|retiring a superseded native retry|requires an explicit root telemetryDb"` — **3/3 failed** (reproducing blocking `await emitAgentTaskRun`, missing `agent.task_run` on superseded retry retirement, and silent `telemetryDb` fallback to `input.db`). - **GREEN (on final head `b4e70c295b78de4bdcec1788e342c421cce1e138`):** - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/missing-server-telemetry-emissions.test.ts` — **1/1 file, 12/12 tests passed**. - `pnpm --filter @paperclipai/server exec vitest run src/services/native-runtime/native-task-completed-telemetry.test.ts src/__tests__/heartbeat-status-preserving-telemetry.test.ts src/__tests__/agent-task-run-telemetry.test.ts` — **3/3 files, 59/59 tests passed** (3 + 1 + 55). - **Test budget:** `node scripts/check-test-budget.mjs --files server/src/__tests__/missing-server-telemetry-emissions.test.ts` — **PASS** (113 nightly suites validated, 1 test file checked). - **Verify scope & local gap:** Local `tsc --noEmit` was skipped to avoid exceeding the container's shared 9.7 GiB cgroup memory limit; GitHub PR CI supplied full typecheck, build, serialized server suites (`ci / verify`), and E2E (`ci / e2e`) verification for head `b4e70c295b78de4bdcec1788e342c421cce1e138`. - **GitHub CI on `b4e70c295b78de4bdcec1788e342c421cce1e138`:** - `ci / verify` — **PASS** (https://github.com/paperclipai/paperclip/actions/runs/47455114528/job/145468380453; includes Typecheck + Release Registry, Build, policy, Runner support/package/native server suites, and all 20 server test shards). - `ci / e2e` — **PASS** (https://github.com/paperclipai/paperclip/actions/runs/47455114528/job/145468199932; all 16 E2E shards). - All 87 status checks completed with zero failures and zero pending checks. - **Automated reviews on `b4e70c295b78de4bdcec1788e342c421cce1e138`:** Greptile **5/5** (`SUCCESS`, unchanged-contract exception recorded), Ponytail **5/5** (`Verdict: ship`), Feynman **4/5** (zero functional defects; structural rationale recorded below and in threads, 17/17 review threads resolved). - **Structural decisions (`rules/pull-request-review.mdc` & `rules/test-budget.mdc`):** - `server/src/services/native-runtime/native-finalization-reconciler.ts` grew from 1,000 lines on `master` to 1,006 lines (+6 net lines) to keep the `retiredSupersededRun` capture, error-clear, and post-commit `void emitTerminalRunFailure` call locally visible inside `claimNativeSessionResumptions` rather than bundling an unrelated reconciler refactor into this telemetry fix. - `server/src/__tests__/missing-server-telemetry-emissions.test.ts` (1,447 lines) keeps all 12 embedded-Postgres telemetry regressions in one shared `beforeAll` suite (grouped by domain `describe` blocks) to avoid multiplying disposable Postgres startup cost across CI shards per `rules/test-budget.mdc`. ## Risks - Low risk. No telemetry schemas, event names, or dimension contracts changed; all new emissions run after transaction commit as best-effort/fire-and-forget and catch errors so telemetry can never block or fail product flows. - `native-restart-recovery.ts`'s `boundAwaitingEvidence` and `retireSupersededNativeRetry` callers now invoke terminal failure telemetry/reporting after commit, matching inline unverified-run termination. - Deployments will see more accurate counts for failed `agent.task_run`, agent-reviewed `agent.task_completed`, `agent.created` / `goal.created` during onboarding, and `routine.created` / `routine.run`, which is the intended fix. - Requesting privacy review per `rules/data-paths.mdc` because this PR adds callers to existing helpers in `packages/shared/src/telemetry/events.ts`. ## Model Used - Google Antigravity (Gemini 4 Neon, High reasoning, 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 (explicit unchanged-contract exception recorded per `rules/data-paths.mdc`) - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
b85e189408 |
perf(runner,native-runtime): silence AJV format warnings, cache validators, and retain released catalogs (#23812)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The server and Runner validate assigned MCP tool input schemas with AJV and project shared frozen tool catalogs into native sessions > - Today, AJV runs with `validateFormats: true` and no registered formats, so every tool schema with `format` keywords (such as `uuid` or `date-time`) emits two synchronous `console.warn` lines per property while still ignoring those formats > - Each call to `admitToolInputSchema` also recompiles identical schemas from scratch, `resolveAssignedCatalog` evicts a shared catalog as soon as its last active session closes (so back-to-back runs rebuild the catalog every time), and `createAssignedMcpTools` logs the over-budget and uncompilable schema warnings on every run even on a cache hit > - Together these issues produce heavy synchronous stderr/log churn and repeat CPU and allocation work on sequential runs > - This pull request disables AJV format lookup in `tool-input-schema.ts`, adds a bounded compiled-validator LRU cache with isolated error state, retains explicitly closed assigned catalogs in a bounded short-TTL warm LRU, and deduplicates catalog schema warnings per `(gatewayPublicId, catalogKey)` > - The benefit is zero `unknown format` stderr warnings, up to ~27x faster repeat schema admission, sequential catalog cache reuse across back-to-back runs, and one warning per distinct gateway and catalog instead of per-run log floods ## Linked Issues or Issue Description Refs #21274, #21482. No separate public GitHub issue exists; the bug is described below using the bug report template. **What happened?** During native agent runs that use assigned MCP tools with JSON Schema `format` annotations (such as `"format": "uuid"` and `"format": "date-time"`) or tool catalogs over the 768 KiB compile budget: 1. `admitToolInputSchema` in `packages/paperclip-runner/src/drivers/tool-input-schema.ts` creates `Ajv`, `Ajv2019`, and `Ajv2020` with `{ allErrors: true, strict: false, addUsedSchema: false }`, leaving `validateFormats` at its default (`true`) without registering any formats. AJV still ignores unknown formats because `strict: false`, but writes two synchronous `unknown format "..." ignored in schema at path "..."` `console.warn` lines per property on every compilation. 2. Repeated calls to `admitToolInputSchema` for identical schemas re-run AJV compilation (`new Function`) each time. 3. `resolveAssignedCatalog` in `server/src/services/native-runtime/assigned-mcp-tools.ts` evicts the shared catalog immediately when `holder.holders === 0`, so sequential runs for the same company and unchanged tool listing never reuse the frozen catalog. 4. `createAssignedMcpTools` logs `assigned MCP tools whose input schema is over the compile budget are offered only through assigned-tool search` and `assigned MCP tools whose input schema the Runner cannot validate are not offered` unconditionally on every call, including cache hits. **Expected behavior** 1. `admitToolInputSchema` preserves exact validation behavior (ignoring unregistered format annotations while still rejecting invalid non-string `format` values via meta-schema validation) with zero `unknown format` warnings. 2. Identical schemas reuse cached compiled validators in a bounded LRU without sharing mutable `.errors` state or allowing mutation of the cached schema. 3. Explicitly closed assigned tool catalogs stay warm in a bounded short-TTL LRU so sequential runs reuse the frozen catalog when the fresh gateway listing is unchanged, while expired or changed catalogs rebuild cleanly and idle processes hold no background polling timers. 4. Catalog schema warnings log once per distinct `(gatewayPublicId, catalogKey)` within a bounded deduplication window instead of flooding logs on every run. **Steps to reproduce** 1. Call `admitToolInputSchema` on 50 schemas containing `format: "uuid"`, `format: "date-time"`, and `format: "email"` across 20 iterations (1,000 admissions) and count `console.warn` lines matching `unknown format`. 2. Call `createAssignedMcpTools` 20 times sequentially (`close()` after each call) for the same `companyId` and `gatewayPublicId` with an unchanged listing over the 768 KiB compile budget and with an under-budget listing, counting `logger.warn` lines and schema object reuse across runs. **Paperclip version or commit** Reproduced on `master` at `306437a2a5`. **Deployment mode** Self-hosted server / Local dev (`pnpm dev`). ## What Changed - `packages/paperclip-runner/src/drivers/tool-input-schema.ts`: - Pass `validateFormats: false` to `Ajv`, `Ajv2019`, and `Ajv2020` compilers. - Add a bounded compiled-validator LRU cache (`TOOL_INPUT_SCHEMA_CACHE_MAX_ENTRIES = 512`, `TOOL_INPUT_SCHEMA_CACHE_MAX_BYTES = 16 MiB` serialized schema bytes) keyed by canonical dialect and SHA-256 of the normalized schema JSON, including caching `uncompilable` outcomes and skipping `$async` schemas. - Deep-freeze cached compiled schemas after `forgetCompiledSchema` and wrap cached `ValidateFunction` instances in `isolatedValidator` so each caller has independent `.errors` state and cached validators retain no prior error arrays. - Export `toolInputSchemaCacheStats`, `TOOL_INPUT_SCHEMA_CACHE_MAX_ENTRIES`, and `TOOL_INPUT_SCHEMA_CACHE_MAX_BYTES` for verification. - `packages/paperclip-runner/src/drivers/tool-input-schema.test.ts`: - Add tests covering zero `unknown format` warnings across all three dialects while preserving validation and rejecting invalid non-string `format` values. - Add tests covering validator cache reuse (including `$schema` fragment normalization, `uncompilable` caching, and uncached `$async` schemas), isolated `.errors` state, frozen `validate.schema`, independent `admission.schema`, and cache bounds. - Give each `reserved $id` iteration a unique `title` so every iteration still compiles fresh on the compiler. - `server/src/services/native-runtime/assigned-mcp-tools.ts`: - Retain explicitly closed shared catalogs in a bounded warm LRU (`ASSIGNED_CATALOG_RETAIN_ENTRIES = 64`, `ASSIGNED_CATALOG_RETAIN_BYTES = 32 MiB`, `ASSIGNED_CATALOG_RETAIN_TTL_MS = 60_000`) promoted back to active `sharedCatalogs` on sequential hits and invalidated automatically whenever the fresh gateway listing changes `identity`. - Unregister the `collectedCatalogs` `FinalizationRegistry` token (`catalog`) in `forgetSharedCatalog` and before re-registering in `shareAssignedCatalog` so repeated sequential warm reuses never accumulate live registrations. - Keep `FinalizationRegistry` GC drop callbacks (`drop` from `createSessionRelease`) in a separate lexical scope with no reference to `assigned` or `catalog`, releasing holds without retaining abandoned sessions. - Manage warm TTL expiry with lazy pruning on lookup/insert plus one per-entry `.unref()` `setTimeout` cleared in `forgetRetainedCatalog` on hit, eviction, or expiry. Keep `assignedRetainedCatalogCacheStats()` read-only. - Deduplicate `unavailable` and `unchecked` `logger.warn` emissions per `(gatewayPublicId, catalogKey)` in a bounded LRU (`ASSIGNED_CATALOG_WARNING_CACHE_ENTRIES = 512`, `ASSIGNED_CATALOG_WARNING_DEDUP_MS = 10 * 60_000`). - `server/src/services/native-runtime/assigned-mcp-tools.test.ts` and `server/src/services/native-runtime/assigned-mcp-tools-cache.test.ts`: - Split `describe("shared assigned tool catalogs")` into `assigned-mcp-tools-cache.test.ts` (353 lines), reducing `assigned-mcp-tools.test.ts` from 980 to 808 lines. - Add fake-timer tests verifying timer-driven and lazy warm catalog TTL expiration, invalidation on listing changes, bounded `FinalizationRegistry` registrations across 50 sequential warm reuses, and per-`(gatewayPublicId, catalogKey)` warning deduplication and window expiry. ## Verification ### Local Before vs After Benchmark Measured in the worktree against `306437a2a5` (before) and `2b3757ad58` (after): | Workload | Metric | Before | After | | --- | --- | ---: | ---: | | `admitToolInputSchema` (50 schemas w/ 4 format fields × 20 calls) | `unknown format` warnings (cold 50 / total 1,000) | 400 / 8,000 | **0 / 0** | | `admitToolInputSchema` (950 repeat admissions) | Total wall time | 144.44 ms | **5.28 ms** (27.4× faster) | | `createAssignedMcpTools` over-budget (120 tools × ~6.7 KiB, 20 sequential runs) | `unknown format` warnings | 672 | **0** | | `createAssignedMcpTools` over-budget (20 sequential runs) | Compile-budget `logger.warn` count | 20 | **1** | | `createAssignedMcpTools` over-budget (runs 2–20) | Median / total time | 1.35 ms / 29.07 ms | **1.18 ms / 23.52 ms** | | `createAssignedMcpTools` under-budget (50 tools × ~1 KiB, 20 sequential runs) | Sequential catalog cache hits | 0 / 19 | **19 / 19** | | `createAssignedMcpTools` under-budget (runs 2–20) | Median / total time | 0.34 ms / 6.81 ms | **0.29 ms / 5.66 ms** | Memory benchmark (`NODE_OPTIONS="--expose-gc" npx tsx scripts/benchmark-assigned-mcp-tools-memory.ts --tools 80 --schema-bytes 2048 --sessions 50 --turns 10`): - `sharedAcrossTurns: true`, `retainedBytesPerSession: 10052`, `bytesStillHeldAfterRelease: 321248` (unclosed sessions released on GC without entering warm retention). ### Automated Tests & Checks (on head `687fe283be`) - `pnpm --filter @paperclipai/paperclip-runner exec vitest run src/drivers/tool-input-schema.test.ts src/drivers/runner-tool-bridge.schemas.test.ts`: 2 files, 26 passed. - `pnpm --filter @paperclipai/server exec vitest run src/services/native-runtime/assigned-mcp-tools.test.ts src/services/native-runtime/assigned-mcp-tools-cache.test.ts`: 2 files, 80 passed. - `pnpm --filter @paperclipai/paperclip-runner run typecheck:typescript`: passed. - `pnpm --filter @paperclipai/server exec tsc --noEmit`: passed. - `pnpm check:module-boundaries`: passed. - `node scripts/check-test-budget.mjs --base origin/master`: passed (`2 test file(s) checked`). - `node tests/runner-e2e/source-sdk-public-inputs.mjs "$(git rev-parse HEAD)" --check`: passed (`changed: false`). ### Operational Assumptions & Sleep Safety - **Format validation parity:** `tool-input-schema.ts` never registered `ajv-formats` and ran with `strict: false`, so format keywords were never enforced before this change. Verified with real `Ajv`, `Ajv2019`, and `Ajv2020` instances across all shared fixtures plus explicit format tests. - **Warm retention lifecycle (`sleep-aware-background-work`):** Trigger is explicit `assigned.close()` releasing the last active holder (`holders === 0`). Source of truth for tool grants remains the fresh gateway listing on every `createAssignedMcpTools` call. Pending-work predicate is `retainedCatalogs.size > 0`, with one `.unref()` `setTimeout` per retained entry (at most 64 entries, 60s TTL), cleared immediately in `forgetRetainedCatalog` on hit, eviction, or expiry. When all retained entries expire or are promoted back to active, zero timers, SQL queries, or network requests remain. - **Remaining coverage:** Full repository test suites and build gates run in CI on this revision. ## Risks - **Frozen `validate.schema` in `tool-input-schema.ts`:** Cached compiled schemas are deep-frozen before reuse so callers cannot corrupt shared cache entries. All in-repo consumers (`admitToolInput`, `toolInputError`, `RepeatedToolInputRejectionGuard`) only read `validate.schema`, and `admission.schema` remains a fresh unfrozen clone. Any future consumer attempting to mutate `validate.schema` will get a `TypeError` instead of silent cross-caller corruption. - **Validator cache byte accounting:** `TOOL_INPUT_SCHEMA_CACHE_MAX_BYTES` (16 MiB) accounts for serialized schema JSON bytes rather than V8 compiled closure heap, and is paired with a 512-entry cap so total validator memory stays bounded. - **Warm catalog memory bound:** Released catalogs are held strongly for up to 60 seconds, capped strictly at 64 entries and 32 MiB accounted bytes, and cleared by per-entry `.unref()` expiry timers. Abandoned sessions dropped without `close()` are never retained, and `collectedCatalogs` unregisters tokens on release and re-share. - **Warning deduplication window:** Repeated warnings for an unchanged `(gatewayPublicId, catalogKey)` are suppressed for 10 minutes (bounded at 512 entries). Changes to the tool listing or gateway ID log immediately, and unchanged warnings re-log after the 10-minute window. - **No database schema changes or migrations.** > 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 - Gemini 4 Neon (Google DeepMind, XHigh reasoning, 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 |
||
|
|
0c456fcca1 |
fix(adapters): find Windows ACP commands through PATHEXT (#14441)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Local adapters (Claude, Codex, Gemini, Kimi) start an ACP server command for each agent > - Each adapter finds a bare ACP command, such as `codex-acp`, on `PATH` > - On Windows, that lookup only tries the exact name and ignores `PATHEXT` > - So a real install such as `codex-acp.exe` is never found, and the environment check says the ACP command is not available > - This pull request makes the lookup try each `PATHEXT` form on Windows, with the same rule that `adapter-utils` already uses > - The benefit is that ACP works on Windows with a normal `PATH` install, and all four adapters use one rule ## Linked Issues or Issue Description Fixes #14372 Related PRs: #14129 and #13053 fix the `PATHEXT` lookup in the GitHub launchers (`github-launcher.ts`). #9996 changes how the ACP engine probes `gemini --version` on Windows. They change different code, so this PR does not duplicate them. ## What Changed - `adapter-utils`: add `commandPathCandidates(dir, command, { env, includeBareName })`. It returns the files to check for a command in one `PATH` folder. On Windows it returns one file for each `PATHEXT` entry. With `includeBareName`, it also returns the bare name last. It returns the name unchanged if the command has an extension or if the platform is not Windows. - `adapter-utils`: `resolveCommandPath` now uses `commandPathCandidates`. Its behavior does not change. - `claude-local`, `codex-local`, `gemini-local`, `kimi-local`: `findCommandOnPath` in `acp.ts` now checks the `PATHEXT` forms first, then the bare name. Before this change, the four copies checked only the bare name. They still find an extensionless file, so their old results do not change. - `gemini-local`, `kimi-local`: these adapters already read `PATH` from the agent `env` config. They now also read `PATHEXT` from it, and use the host value when the config does not set it. ## Verification - `pnpm vitest run packages/adapter-utils/src/server-utils.test.ts -t commandPathCandidates`: 4 new tests, for Windows `PATHEXT` forms, the bare-name fallback, a name with an extension, and other platforms. - `pnpm vitest run packages/adapters/codex-local/src/server/acp.test.ts -t "finds a Windows codex-acp.exe"`: a new test puts `codex-acp.exe` on `PATH` and sets the platform to `win32`. It expects the ACP engine to be available for the bare command `codex-acp`. Without the fix, the test fails with the error from #14372: `Codex ACP server command is not available: codex-acp`. - `gemini-local` and `kimi-local` `acp.test.ts`: a new test in each puts `gemini.ACP` or `kimi.ACP` on a configured `PATH` and sets `PATHEXT: ".ACP"` in the agent `env` config. It expects the ACP engine to be available. Without the configured `PATHEXT` support, both tests fail. - The tests set `process.platform` to `win32`, so they also run on Linux CI. The fixture file names match the `PATHEXT` case exactly, so the tests do not depend on a case-insensitive file system. - I ran the test suites of `adapter-utils` and the four adapters on Windows, with and without this change. No test fails only with this change. - `pnpm --filter <package> typecheck` passes for `adapter-utils` and the four adapters after each commit. `scripts/check-forbidden-tokens.mjs` and `scripts/check-module-boundaries.mjs` pass. ## Risks - Low risk. On macOS and Linux, the lookup does not change: it checks the same single path. - On Windows, the lookup now prefers a `PATHEXT` file (for example `codex-acp.exe` or `codex-acp.cmd`) over an extensionless file in the same folder. In an npm `.bin` folder, it can now return `codex-acp.cmd` where it returned the extensionless shell script before. Windows cannot run that shell script directly, so the old result did not work either. An extensionless file alone is still found. > 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 - Provider: Anthropic - Model: Claude Opus 5.5 (`claude-opus-5-5`) - Tool: Claude Code, with tool use (shell commands, file edits, and test runs) - The model found the issue, wrote the change and the tests, and ran the checks. I reviewed the change and the test results. ## 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 - [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: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com> |
||
|
|
3346a95af8 |
fix(adapters): mount skill sources in the local workspace sandbox (#14340)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - `claude_local` and `codex_local` can confine a run with the local
bwrap sandbox (`filesystemScope: "workspace"`)
> - The adapters give the agent its skills as symlinks (in the prompt
bundle, or in `CODEX_HOME/skills`) to the skill source under the
Paperclip instance skills directory
> - The sandbox mounts the bundle and `CODEX_HOME`, but not the link
targets, so every link dangles
> - The agent sees no skill, not even the built-in `paperclip` skill,
and the run gives no warning
> - This pull request mounts each linked skill source read-only in the
sandbox
> - The benefit is that confined agents get the skills that the board
assigned to them
## Linked Issues or Issue Description
No issue exists. Description:
**What happened?**
A `claude_local` agent with `filesystemScope: "workspace"` and assigned
skills ran without skills. Inside the sandbox, `.claude/skills/<skill>`
in the `--add-dir` bundle was a dangling symlink to
`~/.paperclip/instances/default/skills/<company>/__runtime_cache_v1__/…`
(company skills) and to `…/@paperclipai/server/skills` (built-in
skills). `codex_local` had the same problem with `CODEX_HOME/skills`.
**Expected behavior**
The agent reads every desired skill inside the sandbox.
**Steps to reproduce**
1. Create a `claude_local` or `codex_local` agent with `filesystemScope:
"workspace"` and one company skill.
2. Run it and ask it to list its skills, or run `ls -L` on the skills
directory inside the run.
3. The links do not resolve. The workaround is to add both directories
to `filesystemExtraPaths` by hand.
**Paperclip version or commit**
Seen on 2026.916.1, reproduced on `master` at
|
||
|
|
9ccb5455a1 |
fix(adapter-utils): keep SSH profile sourcing alive under dash (#14309)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - SSH environments run the environment probe and every agent execution on an operator-configured host > - Before each remote command, the wrapper sources the login profiles so that `node` and the agent CLI are on `PATH` > - On Debian and Ubuntu, `/bin/sh` is `dash`. A bash-only line in a profile, such as `export -a`, is a special builtin error, and `dash` exits the whole shell on it > - The `|| true` guard never runs, so the probe and every run fail with exit 2 and empty stdout and stderr > - This pull request sources each profile with `command .`, in both `runSshCommand` and `buildSshSpawnTarget` > - The benefit is that a host with a bash-only `~/.bashrc` works, and exports made before the failing line stay in effect ## Linked Issues or Issue Description Refs #14226 This PR fixes items 1 and 2 of the issue. Item 3 (keep the profile diagnostics when the exit code is non-zero and both streams are empty) is not in this PR, so the issue stays open for it. ## What Changed - `packages/adapter-utils/src/ssh.ts`: in `runSshCommand` and `buildSshSpawnTarget`, source each login profile with `command .` instead of `.`. POSIX `command` removes the special builtin behavior of `.`. Under `dash`, a special builtin error or a syntax error in a profile now stops that profile at the failing line, and the wrapper shell continues. An `exit` in a profile still ends the wrapper, as before. Under `bash`, the behavior does not change. - `packages/adapter-utils/src/ssh.ts`: move the four sourcing lines into one constant, `LOGIN_PROFILE_SOURCE_LINES`, that both functions use. The dash test on `buildSshSpawnTarget` now also covers the lines that `runSshCommand` sends, and the two call sites cannot drift apart. - `packages/adapter-utils/src/ssh-fixture.test.ts`: add a test that runs the generated remote command line with `dash` as `sh`. The fake `HOME` has a `.bash_profile` that sources a `.bashrc` with `export PATH=...`, `[[ ... ]]`, and `export -a`. The test expects the command to run and `PATH` to start with the directory that `.bashrc` exported. The test is skipped when `dash` is not installed. I chose `command .` over the two fixes in the issue. The subshell plus `export -p` form re-imports the whole environment with `eval`. The `bash -lc` form changes the shell for every host. `command .` is one word per call site and keeps the current sourcing order. ## Verification - `npx vitest run packages/adapter-utils/src/ssh-fixture.test.ts -t dash` on macOS with `/bin/dash`: the new test passes 2 times in a row. - Red before the fix: with the `ssh.ts` change reverted, 1 failed. `dash` exits with status 2 before the command runs, the same symptom as the issue. - Manual check with `dash` and the profiles from the issue: the old script exits 2 with no output. The new script exits 0, and `PATH` has the entry that `.bashrc` exported before `export -a`. Under `bash`, the old and new scripts give the same output. - Mutation check: with `command . ` changed back to `. ` in the shared constant, the dash test fails. - `npx vitest run packages/adapter-utils/src/ssh-fixture.test.ts`: 21 of 21 pass, 2 runs. - `npx vitest run packages/adapter-utils` is flaky under parallel load in my checkout, on `master` and on this branch. Across runs I saw failures in `sandbox-managed-runtime`, `sandbox-callback-bridge`, `acpx-engine/execute`, `acpx-engine/startup-characterization`, `execution-target-stdin-race`, and `github-launcher-environment`. Each of the last four passes when run alone. `sandbox-managed-runtime` (2 tests) and `sandbox-callback-bridge` also fail on `master`. - `cd packages/adapter-utils && npx tsc --noEmit`: exit 0. - I did not run the SSH env-lab fixture against a real Debian or Ubuntu host. ## Risks - Low risk. POSIX specifies `command .`. I tested it in `dash` and `bash`. - Lines in a profile after the failing line still do not run under `dash`. Before this change, nothing ran at all. - This PR does not do item 3 of the issue. A profile that calls `exit` still gives a non-zero exit with empty streams. I can open a follow-up PR for it. - Six sandbox provider sites use the same sourcing lines: `cloudflare/bridge-template/src/exec.ts`, `daytona/src/login-pty.ts`, `daytona/src/plugin.ts`, `e2b/src/plugin.ts`, `exe-dev/src/plugin.ts`, and `modal/src/plugin.ts`. The default images come from Paperclip, but operators can set their own image or template, so the same bug can apply. This PR keeps the scope to SSH, as in #14226. I can open a follow-up PR for these sites. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`, Anthropic), in Claude Code with tool use (shell, file edit). It reproduced the bug with a failing test, wrote the fix, and drafted this description. A human reviewed the change. ## 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 (no documentation describes the profile sourcing) - [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> |
||
|
|
6a5dfc0288 |
feat(recents): store sidebar Recents on the server so every client shares one list (#23706)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The sidebar Recents list shows the tasks from a person's own recent activity > - Each browser kept Recents in `localStorage`. A laptop, a phone, and a second browser each showed a different list > - People expect one list for their account, the same on every client > - This pull request moves Recents to the server. The server keeps one list for each person in each company. The UI shows that list and gets live updates when another client changes it > - The benefit is that every client shows the same Recents in the same order, and a change on one client shows on the others at once ## Linked Issues or Issue Description **Is your feature request related to a problem? Please describe.** Recents is kept in the browser. When I open a task on my laptop, the task does not show in Recents on my phone or in another browser. **Describe the solution you'd like** Keep Recents on the server, so that every client that I sign in to shows the same list. **Additional context** Eligibility (which rows show) does not change. The navigation summaries still decide it (see #23675). ## What Changed - `packages/db`: new `user_recent_tasks` table (company, user, issue, `recorded_at`), unique on company + user + issue. Migration `0515` creates only a new table, so it is `online_compatible`. - `packages/shared`: `RecentTaskRecord`, `RecentTaskList`, `RECENT_TASKS_MAX_ENTRIES` (200), and the `recordRecentTaskSchema` and `importRecentTasksSchema` validators. - `server`: new `recentTaskService` and routes: - `GET /api/companies/:companyId/recent-tasks/me`: the list, newest first. - `POST /api/companies/:companyId/recent-tasks/me` `{ issueId, touch }`: `touch: true` moves the task to the top (server time). `touch: false` adds a missing task below the history and does not move an existing task. - `POST /api/companies/:companyId/recent-tasks/me/import`: imports the list that a browser kept. The later time wins. - `DELETE /api/companies/:companyId/recent-tasks/me/:issueId`. - The server keeps the newest 200 rows for each person. Each change is in the activity log as `recent_tasks.*` with `entityType: "company"` and `details.userId`. The entry does not name the task. Viewers can change their own Recents, like workspace preferences. - Record, import, and list use the normal task read decision. A private or unreadable task gets the same 404 as a missing task. The import skips it, and the list does not return it. - `server/src/realtime/live-events-ws.ts`: sends `recent_tasks.*` events only to the owner's connections, without details. - OpenAPI entries for the four routes. - `ui/src/lib/recent-tasks.ts`: the module is now a client mirror of the server list, not `localStorage`. Optimistic records and removals stay applied until a server list that was requested after the server saved them arrives. This prevents a stale list from hiding a new visit. - `ui/src/hooks/useRecentTasks.ts`: fetches the server list (`queryKeys.recentTasks`). On the first load it imports the old browser list one time and then deletes the browser copy. It does not delete ineligible rows anymore. It hides them, and it requests a new summary batch when new activity occurs on a hidden task. The `awaitingRead` flow is removed because nothing deletes the row while the read is in flight. - `LiveUpdatesProvider`: a `recent_tasks.*` event refreshes Recents. Other company views do not refresh. - A failed save is tried again one time. If it fails again, the client loads the server list again, so an unsaved change does not look saved. - The import reads only the newest browser storage version. - `SidebarRecentTasks`: the "Archive" action removes the task from the server list. - `doc/PRODUCT.md`: describes the shared list. ## Verification - `cd server && npx vitest run src/__tests__/recent-tasks-routes.test.ts` (embedded Postgres): 5 passed. The tests cover: two clients of the same person see the same order; touch and passive seed; personal and company scope (teammate, other company, agent, viewer, suspended member); removal plus activity log plus live events; import, and the 200-row limit. - `cd server && npx vitest run src/__tests__/openapi-routes.test.ts`: 59 passed. - `cd server && npx vitest run src/__tests__/recent-tasks-routes.test.ts src/__tests__/live-events-toast.test.ts`: 21 passed. This includes private-task checks and owner-only socket delivery. - `cd ui && npx vitest run src/lib/recent-tasks.test.ts src/hooks/useRecentTasks.test.tsx src/context/LiveUpdatesProvider.test.ts`: all passed. New tests cover: the same list on a second client, legacy import (success and failure), the record-and-list race, server-time adoption, and live-event scoping. - `packages/db`: `migration-compatibility.ts` classifies `0515` as `online_compatible`. - `packages/shared` typecheck: no errors. `ui` typecheck: no errors in changed files (errors exist only in the ungenerated Storybook feature-map indexes). - `server`: a typecheck of the route, service, and test graph passes. The full `server` typecheck was killed by the local memory limit (exit 137). CI covers it. - `pnpm verify` returned exit 2 (the migration needs broad CI coverage). Required CI supplies that coverage. ## Risks - Medium. This adds a table and changes where Recents is kept. - Each task open now sends one more request and writes one activity row (the same as `issue.read_marked`). The live socket sends the event only to the owner's connections. - Rows that are not eligible stay in the server list (hidden) until they fall out of the newest 200. Before, the client deleted them. - The import reads `paperclip.recentTasks.v3`, `v2`, and the oldest key one time for each browser. If the import fails, the browser copy stays and the next load tries again. - An old tab from the previous release still writes to `localStorage`. The next load of a new tab imports those entries. The later time wins, so this does not reorder newer server entries. > 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`), via Claude Code with tool use (shell, file edit, test runs). ## 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 - [ ] 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) - [ ] 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: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d939c64a6b |
fix(opencode): keep the text-first answer when only the completion call is written as text (#23806)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The Paperclip runner drives OpenCode models and asks again when a
turn ends without a final answer
> - The second request asks for a plain-text answer first, then the
`paperclip_finish` call
> - DeepSeek v4.1 flash sometimes sends that answer and then writes
`paperclip_finish` as DSML text, not as a real tool call
> - The runner discards the full reply when it finds tool-call text, so
it also discards the answer it asked for, and the turn fails with
`opencode_empty_response`
> - This pull request keeps that answer when the only text call after it
is the completion call
> - The benefit is that a turn that already did its work ends with an
answer, not a failed run and a full retry
## Linked Issues or Issue Description
Refs #21361
Refs #21761
**What happened?**
After real tool work, a reviewer agent on DeepSeek v4.1 flash
(OpenRouter) ended its turn with a tool call written as text. The runner
sent two corrections. For the second correction, the model wrote a
correct plain-text answer, a blank line, and then `paperclip_finish` as
DSML text. The runner discarded the full reply and failed the turn with
`opencode_empty_response` ("after two corrections"). The work was
already done. In one run, the model had published a PR review. In a
different run, it had posted a GitHub reply. The automatic retry then
ran the full session again. This occurred three times on staging in
three weeks, and two of the three were on the same day.
**Expected behavior**
The second correction asks for exactly this shape: an answer, then the
completion call. When the completion call is the only text call, the
runner should keep the answer. A completion call starts no work, so the
answer cannot describe an action that did not occur.
**Steps to reproduce**
1. Start an OpenCode turn that does tool work and then sends an empty
reply two times.
2. For the text-first correction, send `Here is the actual final
answer.` followed by a DSML `paperclip_paperclip_finish` call as text.
3. Before this change, the turn fails with `opencode_empty_response`.
The new `tool-work-text-finish-markup` case in `empty-response.test.ts`
does these steps.
**Paperclip version or commit**
`master` at
|
||
|
|
f530a7b167 |
Keep pause status inline and ease the agent character into sleep (#23662)
## Thinking Path
> - Paperclip helps people manage AI agents at work.
> - The agent overview shows the agent name and runtime status.
> - A pause or resume adds a status row and moves the name.
> - The name should stay in place while the agent changes state.
> - This change places the status beside the name and crown.
## Linked Issues or Issue Description
**Subsystem affected**
Agent detail header.
**Current behavior**
Pause and resume add a line of detail below the harness. The title moves
when that line appears.
**Proposed behavior**
Keep the title steady. Show progress beside the crown and keep the
paused state visible until the user resumes the agent.
## What Changed
- Resize and fade the pill with a fixed left edge. Respect reduced
motion.
- Blend the header character into its sleeping pose over 160 ms when the
agent reaches **Paused**. Keep its assigned colors and show the
onboarding sleep marks. Wake the character when resuming begins.
- Show the new pose immediately when the user requests reduced motion.
- Preserve lifecycle error details and retry controls.
- Add a development preview that lets reviewers try both transitions
without changing an agent.
## Verification
- Open an agent overview in development with `?preview=pause`. Select
**Preview pause**, wait for **Paused**, then select **Preview resume**.
- Chromium confirmed the full cycle and the 240 ms resize duration.
- Chromium confirmed that the character uses the same palette when
sleeping and awake.
- All 36 focused tests passed in four Vitest files on commit
|
||
|
|
bc526683c2 |
fix(github-chat): fix initial repository import and verify UX states (#23760)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - The GitHub Code Review Bot setup wizard registers a GitHub App,
discovers its installation repositories, imports initial repository
selections, and verifies access before activation.
> - When a user or agent saves review configuration on a draft before
installing the GitHub App, the wizard skipped initial repository import
because it required `saved.revision === 0`, leaving enabled GitHub
repositories disabled in Paperclip and showing a misleading "Enable at
least one repository from the App installation." error.
> - The wizard also closed initial repository import prematurely when
GitHub returned zero repositories, failed to refresh repositories on
retry, treated removed installations (HTTP 404) as generic 422 failures
and transient repository-sync errors as empty installations, omitted the
direct GitHub App installation link on verification errors, and kept
showing "Checking GitHub access…" while idle on a failed check.
> - This pull request decouples initial repository import from review
configuration revision, recovers verifying endpoints stuck with a
pending initial import, maps removed installations and transient
repository sync errors to structured verification check codes with
validated GitHub URLs, and updates the setup verify screen to show clear
error states, accurate paired links/labels, and active retry feedback.
> - The benefit is that pre-configured GitHub review bots connect
cleanly when the App is installed, and operators get accurate error
diagnostics, direct GitHub installation and Access settings links, and
clear retry feedback when setup checks fail.
## Linked Issues or Issue Description
**What happened?**
During GitHub Code Review Bot setup
(`/apps/chat/connect?provider=github&purpose=chat&resume=...`), the
verify step failed with "Enable at least one repository from the App
installation." even when one repository was already enabled on the
GitHub App installation. The verify screen also kept displaying
"Checking GitHub access…" when idle, did not link to the GitHub App
installation URL, and did not clearly explain whether the problem was on
GitHub or in Paperclip Access settings.
**Expected behavior**
Installing the GitHub App with one or more repositories enabled should
import and enable those repositories during initial setup even if custom
review configuration was saved earlier, while preserving that saved
configuration. When verification genuinely fails for missing
repositories, missing permissions, removed/suspended installations, or
transient GitHub repository sync errors, the screen should stop polling,
replace the checking indicator with a clear error card, pair each GitHub
link with an accurate label, link to Paperclip Access settings, and show
active checking feedback only while a retry or refetch is running.
**Steps to reproduce**
1. Create a GitHub Code Review Bot draft and save custom review
configuration (`PUT /api/chat-endpoints/:id/github/configuration`),
incrementing configuration revision to `1`.
2. Register and install the GitHub App on GitHub with one repository
selected, verify webhook delivery, and link a GitHub identity.
3. Resume
`/apps/chat/connect?provider=github&purpose=chat&resume=<endpointId>`.
4. Observe that `POST /api/chat-endpoints/:id/github/setup` leaves the
repository disabled, marks `initialRepositoriesImported: true` while
leaving `initialRepositoryImportPending: true`, and returns `state:
"verify"` with "Enable at least one repository from the App
installation." and no GitHub installation link.
**Paperclip version or commit**
Reproduced on `master` at commit `e2e2265085`.
**Deployment mode**
Self-hosted server
**Agent adapter(s) involved**
Not adapter-specific (core bug)
## What Changed
- Extract initial GitHub repository import eligibility/transition logic
into `server/src/services/chat-github-initial-import.ts` and decouple
initial repository import in `server/src/services/chat-github-wizard.ts`
from `saved.revision === 0` so pre-saved review configuration no longer
blocks enabling repositories granted during initial App installation,
while keeping `saved.revision === 0` strictly for default review
configuration writes.
- Recover verifying endpoints left in the prior half-state
(`initialRepositoriesImported: true` with
`initialRepositoryImportPending: true` and `repositorySelectionSaved`
unset) without re-enabling repositories after an explicit user save
(`repositorySelectionSaved: true`).
- Keep `initialRepositoryImportPending` open when GitHub returns zero
repositories during initial import
(`server/src/services/chat-github-wizard.ts` and
`server/src/services/chat-channels/resource-reconciliation.ts`), refresh
repository inventory on wizard retry when no enabled available
repository exists, and track transient repository-sync errors so failed
`/installation/repositories` refreshes skip initial import and emit
`repositories_sync_failed` instead of misreporting
`no_installation_repositories`.
- Map HTTP 404 on `/app/installations/:id` in
`server/src/services/chat-github-management.ts` to
`installation_missing` + `managementUrl` (keeping 401/403/5xx and
transient failures separate), and enforce `!permissionsOk` precedence
(`permissions_required`) over cached repository state.
- Preserve `setup.github.managementUrl` and sibling setup fields via
atomic `jsonb_set` in
`server/src/services/chat-channels/github/app-setup.ts`.
- Centralize strict GitHub URL validation
(`safeGitHubInstallationManagementUrl`, `safeGitHubAppInstallUrl`,
`safeGitHubAppUrl`) and structured `GitHubVerificationCheckCode` values
(including `repositories_sync_failed`) in
`packages/shared/src/types/github-app-setup.ts` and
`packages/shared/src/index.ts`, with OpenAPI schema updates in
`server/src/routes/openapi.ts` and UI API types in
`ui/src/api/githubChat.ts`.
- Extract `deriveGitHubVerifyView`, `shouldPollGitHubVerify`, and
`<GitHubVerifyStatus />` into
`ui/src/pages/apps/chat/GitHubVerifyStatus.tsx` and simplify
`ui/src/pages/apps/chat/GitHubChatSetup.tsx` so verification failures
stop 5-second background polling, pair every external GitHub link with
an accurate label (including `installation_missing` fallback to
`managementUrl`), show active checking feedback only while
retrying/refetching, and link to Paperclip Access and Connection
settings.
- Add unit, integration, and UI tests in
`server/src/services/chat-github-initial-import.test.ts`,
`server/src/services/chat-github-management.test.ts`,
`server/src/__tests__/chat-channels/github-setup-and-access.integration.test.ts`,
`ui/src/pages/apps/chat/GitHubVerifyStatus.test.ts`, and
`ui/src/pages/apps/chat/GitHubChatSetup.test.tsx`.
- Update `tests/runner-e2e/source-sdk-public-inputs.json` for the shared
type and helper exports.
## Verification
Tested on Linux through revision `9a5a949098`:
- Red-green TDD proofs:
- Pre-saved review configuration and stuck verifying endpoint recovery
(`server/src/__tests__/chat-channels/github-setup-and-access.integration.test.ts`):
confirmed both failed before the wizard fix (`Received: "verify"`,
`Expected: "connected"`) and passed after.
- Removed installation HTTP 404 (`installation_missing` +
`managementUrl`) and `!permissionsOk` precedence
(`server/src/services/chat-github-management.test.ts` + integration
test): confirmed red before fix, green after.
- Transient `/installation/repositories` 503 failure with empty cache
and valid permissions (`repositories_sync_failed`, followed by
successful retry -> `connected`) and UI `installation_missing` fallback
label (`ui/src/pages/apps/chat/GitHubVerifyStatus.test.ts`,
`GitHubChatSetup.test.tsx`,
`github-setup-and-access.integration.test.ts`): confirmed red before
fix, green after.
- Server unit & OpenAPI tests on `9a5a949098`:
- `pnpm --filter @paperclipai/server exec vitest run
src/services/chat-github-management.test.ts
src/services/chat-github-initial-import.test.ts` (47/47 passed: 39
management + 8 initial-import).
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/openapi-routes.test.ts` (59/59 passed).
- Server integration tests (`c1f234335f`; full suite running in CI on
merged head `9a5a949098`):
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/chat-channels/github-setup-and-access.integration.test.ts
-t "recovers from an empty initial GitHub repository inventory|keeps
explicitly disabled repositories disabled|imports GitHub App
installation repositories even when review configuration was
pre-saved|recovers a verifying endpoint whose
initialRepositoriesImported|returns installation_missing with
managementUrl when the GitHub installation is removed|surfaces a
retryable repositories_sync_failed check"` (6/6 passed).
- UI tests & typecheck on `9a5a949098`:
- `pnpm --filter @paperclipai/ui exec vitest run
src/pages/apps/chat/GitHubChatSetup.test.tsx
src/pages/apps/chat/GitHubVerifyStatus.test.ts
src/pages/apps/chat/chat-ui-contract.test.ts` (27/27 passed) and
`ui/src/lib/analytics/replay-masking.test.tsx` (236/236 passed).
- `pnpm --filter @paperclipai/shared build && pnpm --filter
@paperclipai/shared typecheck && pnpm --filter @paperclipai/ui
typecheck` (passed).
- `node scripts/check-token-gates.mjs` — zero violations in touched
files.
- Release registry check on `9a5a949098`:
- `node tests/runner-e2e/source-sdk-public-inputs.mjs
|
||
|
|
627e1be76d |
fix(db): give each database address time for a retransmitted SYN (#23784)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - The server reads and writes all state through one postgres.js pool
in `packages/db`.
> - Sentry recorded a production query failure. Every address of the
database host failed to connect: `connect ETIMEDOUT` on three IPv4
addresses and `ENETUNREACH` on three IPv6 addresses.
> - Node tries the addresses of a host name in turn ("happy eyeballs").
It gives each address except the last only 250 ms. The last address was
IPv6 and this host has no IPv6 route, so it failed at once.
> - Thus the connection failed after about 750 ms. One dropped SYN was
sufficient, because Linux sends the first SYN again only after 1 s. The
30 s `connect_timeout` of postgres.js did not apply.
> - This pull request gives each address 2 s by default, so a
retransmitted SYN can get an answer.
> - The benefit is that a short network stall to the database no longer
fails queries.
## Linked Issues or Issue Description
No public GitHub issue exists. This is a bug report.
**What happened?**
A server query failed with `Failed query: select ... from "companies"
...`. The cause was an `AggregateError` with code `ETIMEDOUT`. Its
errors were `ETIMEDOUT`, `ENETUNREACH`, `ETIMEDOUT`, `ENETUNREACH`,
`ETIMEDOUT`, `ENETUNREACH`. Each `ETIMEDOUT` came from Node's
per-address attempt timer (`internalConnectMultipleTimeout`), not from
postgres.js.
**Steps to reproduce**
1. Use a database host name that resolves to IPv4 addresses and IPv6
addresses, on a machine without an IPv6 route.
2. Make the IPv4 addresses drop SYN packets for less than one second.
3. Run a query that opens a new pooled connection.
**Expected behavior**
The connection waits for a retransmitted SYN. It fails only after
`connect_timeout`.
**Actual behavior**
The connection fails after about 750 ms with `AggregateError`
`ETIMEDOUT`.
## What Changed
- `patches/postgres@3.4.9.patch`: postgres.js now calls
`socket.connect({ port, host, autoSelectFamilyAttemptTimeout })` when
the new `auto_select_family_attempt_timeout` option is set. Without the
option, the call is the same as before. The change is in both the ESM
and CJS builds.
- `packages/db/src/client.ts`: new `connectAttemptTimeoutMs` client
option and `DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS` variable.
`resolveDatabaseClientOptions` sets a default of 2000 ms, so all pools
from `createDb` use it. `client.ts` was already longer than 1,000 lines.
This change adds the option next to the other driver options in that
file, because they share one parser and one mapping.
- `packages/db/src/postgres-connect-attempt-timeout.test.ts`: new
regression test. It examines the arguments that the patched driver gives
to `net.Socket.prototype.connect`.
- `packages/db/src/client-options.test.ts`: tests for the new variable,
its validation, the mapping and the default.
- `docs/deploy/database.md` and `doc/DATABASE.md`: document the new
variable.
- I did not commit `pnpm-lock.yaml`. The patch hash changes, and the
lockfile policy in `doc/ci-workflows.md` lets CI and the refresh
workflow update it.
## Verification
- Red, then green: `cd packages/db && npx vitest run
src/postgres-connect-attempt-timeout.test.ts`. Before the fix, both
tests failed. The driver called `connect(1, "127.0.0.1")` with no
options. After the fix, both tests pass.
- Focused: `npx vitest run src/postgres-connect-attempt-timeout.test.ts
src/client-options.test.ts src/postgres-connection-recovery.test.ts
src/client-disconnect-replay.test.ts src/client.test.ts
src/postgres-receive-buffer.test.ts`. Result: 6 files, 48 tests pass.
Some of these tests open real connections through the patched driver.
- `pnpm exec tsc --noEmit -p packages/db` passes.
- `pnpm verify` exits 2, because the postgres patch is a global CI
input. Required CI supplies the broad coverage.
- Manual reproduction on Node v24.23.0. A script overrides `dns.lookup`
to give the production address shape: three loopback IPv4 listeners with
full accept queues, which drop SYNs, and three unroutable IPv6
addresses. The listeners start to accept after 600 ms.
- Before: `AggregateError code=ETIMEDOUT after 764ms
inner=ETIMEDOUT,ENETUNREACH,ETIMEDOUT,ENETUNREACH,ETIMEDOUT,ENETUNREACH`.
This is the same as the production error.
- After, with the 2000 ms default: the listener accepted the client's
retransmitted SYN at 1.035 s, and the TCP connection opened. The stub
was not a Postgres server, so the query then stopped at the test's 3 s
`connect_timeout`.
## Risks
- Low risk. The option changes only how long Node waits for one address
before it tries the next one. `connect_timeout` still bounds the whole
attempt.
- If an IPv6 address comes first and drops packets without an error,
each new connection can wait up to 2 s before it tries IPv4, not 250 ms.
Operators can set `DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS` lower.
- Unix-socket connections (`path`) and custom `socket` factories do not
change.
- The patch hash of `postgres@3.4.9` changes. CI resolves the lockfile
for this run, and the refresh workflow commits the new lockfile after
merge.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use (shell, file edit 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
- [ ] 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: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
a484eb7bf8 |
build(deps): bump novita-sandbox from 1.0.3-b2 to 2.1.5 in /scripts/typecheck-sandbox-providers (#22599)
Bumps [novita-sandbox](https://novita.ai/sandbox) from 1.0.3-b2 to 2.1.5. Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
ab79cb9cdd |
fix(heartbeat): wait for an updating runtime before workspace setup fails (#23779)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Before a run starts its agent, Paperclip prepares the task workspace through a workspace provider plugin > - A hosted agent computer can apply an update. While it updates, it finishes its running tasks and refuses new workspaces > - The provider can only report this refusal as a generic `remote_incomplete` failure. Setup retries that failure two times in about 90 seconds (#23764), but an update can wait for running tasks for an hour > - So each new task on that computer fails setup, reports an error, and stops, although it only had to wait > - This pull request adds the closed provider reason `runtime_updating` and a separate wait lane for it. Setup holds the run and retries the same workspace every 2 minutes for up to 1 hour. The wait does not use the failure retry budget, and Paperclip does not report the run as a failure while the wait continues > - The benefit is that new tasks wait for an updating agent computer and then start, instead of failing ## Linked Issues or Issue Description Refs #23764, #23362 **What happened?** A hosted agent computer refused every new workspace preparation while it applied an update and finished its long running tasks. The provider reported each refusal as `remote_incomplete`. Setup failed each new run. Every retry of the same workspace failed the same way, and each failure was reported to error tracking. On one staging stack this happened 34 times in two hours, for two agents. **Expected behavior** A provider can say that the selected runtime is updating. Setup then holds the run and retries the same workspace after the update. The retry does not spend the failure budget. Paperclip reports the failure only if the wait ends without success. **Steps to reproduce** 1. Start a legacy run whose workspace preparation calls a workspace provider plugin. 2. Have the provider reject preparation because its runtime is updating. Before this change, the only fitting reason is `remote_incomplete`. 3. Setup records `workspace_storage_incomplete` and retries two times (30 s and 60 s). Then the task stops and the failure is reported, while the runtime is still updating. **Paperclip version or commit** `master` at `30334c1f03`. **Deployment mode** Hosted (Paperclip Cloud agent computers). A self-hosted workspace provider can use the same reason. ## What Changed - `packages/plugins/sdk/src/workspace-operation-error.ts`: add the closed reason `runtime_updating` ("the selected runtime is applying an update and refuses new workspaces until it finishes"). - `server/src/services/workspace-provider-failure.ts`: give `runtime_updating` a fixed, retryable message. Map it to the new setup code `workspace_runtime_updating`. Add `WORKSPACE_RUNTIME_UPDATING_RETRY` (reason `runtime_update_wait`, 30 attempts, 2 minutes apart). Add the code to `WORKSPACE_STORAGE_RETRY_CODES`, so the existing deferred error report also covers it. - `server/src/services/heartbeat/run-completion.ts` and `heartbeat/retries.ts`: schedule a failed pre-dispatch `workspace_runtime_updating` run with the wait lane, and use the lane's budget in `failedRunRetryBudgetSpent`. This is the same pattern as `runner_revision_mismatch`. - `server/src/services/execution-recovery-attempt.ts`, `modules/run-dispatch/domain/wake-context.ts`, `task-interruption-presentation.ts`: `runtime_update_wait` is an uncharged preparation wait. An answered interaction keeps its continuation through the wait, and the task shows a wait, not a failure. - `failed-preparation-retry.ts`, `legacy-execution-recovery.ts`, `recovery/service.ts`, `agent-task-run-telemetry.ts`: treat `workspace_runtime_updating` like the other transient workspace preparation codes. - `recovery/stranded-notice.ts`: add a notice for a wait that ended without success ("Agent computer was still updating"). ## Verification - Red before the change (test files only, source reverted): 9 new tests fail in `workspace-provider-failure.test.ts`, `execution-recovery-attempt.test.ts`, `heartbeat/retries.test.ts`, `heartbeat/run-completion.test.ts` and `run-failure-report-sandbox-resume.test.ts`. - `pnpm verify` did not run: its workspace link repair failed for `plugin-orchestration-smoke-example`, before test selection. The SDK change also affects many packages, so CI supplies the broad coverage. - Green after the change: the same 5 files pass (267 tests). Related files also pass: `task-interruption-automatic-path`, `task-interruption-query`, `wake-context`, `stranded-notice-remote-workspace-environment`, `task-interruption-presentation` (181 tests); `agent-task-run-telemetry`, `legacy-continuation-authority`, `heartbeat-retry-scheduling` (179 tests); plugin SDK `workspace-operation-error`, `workspace-provider` (20 tests). - `pnpm --dir server typecheck` and `pnpm --filter @paperclipai/plugin-sdk typecheck`: pass (server typecheck run with `PAPERCLIP_TYPECHECK_LOW_MEMORY=1` because of a local memory limit). - CI supplies the full suite. - Review follow-up (`cf73701742`, `d7540263bd`): update waits keep their count in `executionRetryAccounting` (`runtimeUpdateWaits`) across other retry lanes. An answered interaction whose update wait runs out is escalated like an exhausted storage wait. The pinned SDK input registry is refreshed. The two new tests failed before the fix and pass after it. `execution-recovery-attempt`, `heartbeat/retries`, `workspace-provider-failure` and `run-failure-report-sandbox-resume` pass (83 tests). `heartbeat/run-completion` and `modules/wake-queue` pass (577 tests). `tests/runner-e2e/source-sdk-public-inputs` passes (13 tests). `pnpm --dir server typecheck` passes. ## Risks - Low risk. No schema, migration, API route or wire protocol shape change. The reason set is closed and validated on both sides. An older Core that receives `runtime_updating` treats it as an unknown provider failure, as before. - A provider must not send `runtime_updating` before the new SDK is available to it. The SDK constructor rejects an unknown reason, so a provider update has to follow this change. - The wait is a bounded scheduled retry after a real refusal, not idle polling: at most 30 retries in one hour per waiting run. Each retry is one workspace preparation call. When the wait ends without success, the run is reported and the task shows a named notice with a Retry action. - Only legacy runs that fail before provider dispatch use the lane. Started and native runs keep `setup_failed`. ## Model Used - Anthropic Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code with tool use (code search, file edits, shell, local test execution, GitHub CLI). ## 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: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
14f23fef03 |
fix(plugins): offer direct Buffer setup when Composio has no sign-in link (#23782)
## Thinking Path > - Paperclip helps people manage AI agents for work. > - Plugins lets people connect tools to their agents. > - Some tool connections use the Composio gateway. > - Buffer requires a custom OAuth app in the Composio project that serves the session. > - When that gateway returns no sign-in link, Plugins can help the user open Buffer's own MCP setup. > - This pull request opens the existing connection form with the Buffer name and endpoint filled in. ## Linked Issues or Issue Description **What happened?** Plugins showed a generic error when Composio returned no Buffer sign-in link. **Expected behavior** The user can open the direct Buffer setup from the error. For other apps, the user can open Composio's app settings. **Steps to reproduce** In Plugins, select Buffer and choose a saved Composio gateway without a configured Buffer OAuth app. Select Continue. **Additional context** [Buffer's MCP setup](https://developers.buffer.com/guides/integrations/other-ai-tools.html) accepts a Buffer API key. [Composio's Buffer setup](https://composio.dev/toolkits/buffer) requires a custom OAuth app. [Composio auth configs belong to one project](https://docs.composio.dev/kb/guide/dashboard-auth-configs-navigation). Related prior work: Refs #19408. ## What Changed - Return a machine-readable code when Composio returns no sign-in link. - Offer the direct Buffer MCP form with its official address. Offer a link to Composio app settings for other toolkits. - Clear the old sign-in link when the user requests a new one. Keep the link if the completion check fails. - Document the setup options. Refresh the shared SDK test input pins. ## Verification - Reproduced the missing-link API response with an embedded database and a Composio response fixture. The new test failed on the old server. - Passed 13 focused tests across the Composio route, Plugins setup dialog, and the MCP URL prefill flow. The replacement-link test reproduced the stale link before the fix. A second test checks that the sign-in link stays available after a failed completion check. - Sent an unauthenticated MCP initialize request to Buffer's documented endpoint and confirmed that it requires authentication. A real Buffer consent or API-key test needs a Buffer account with access. ## Risks - Low risk. The new action opens the existing MCP setup page. The user chooses the credentials and access before Paperclip creates the connection. - A valid Composio sign-in link still takes the user through Composio. ## Model Used - OpenAI GPT-6 (Codex), with repository, test, and GitHub 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 described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links - [x] My branch name describes the change - [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> |
||
|
|
ca0d650f8c |
build(deps-dev): bump vitest from 4.1.12 to 5.1.2 in /scripts/typecheck-sandbox-providers (#22600)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 4.1.12 to 5.1.2. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/vitest-dev/vitest/releases">vitest's releases</a>.</em></p> <blockquote> <h2>v5.1.2</h2> <h3> 🐞 Bug Fixes</h3> <ul> <li>Report global setup errors instead of "no test files" - by <a href="https://github.com/jszumski"><code>@jszumski</code></a> and <strong>Claude Opus 5.5</strong> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12031">vitest-dev/vitest#12031</a> <a href="https://github.com/vitest-dev/vitest/commit/b7572c1e6"><!-- raw HTML omitted -->(b7572)<!-- raw HTML omitted --></a></li> <li>Warn when projects attach the same file - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12043">vitest-dev/vitest#12043</a> <a href="https://github.com/vitest-dev/vitest/commit/5f8847345"><!-- raw HTML omitted -->(5f884)<!-- raw HTML omitted --></a></li> <li><strong>browser</strong>: <ul> <li>Don&<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/39">#39</a>;t fail trace when locator has no match for non-playwright providers - by <a href="https://github.com/hi-ogawa"><code>@hi-ogawa</code></a> and <strong>Claude Opus 5.5</strong> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11975">vitest-dev/vitest#11975</a> <a href="https://github.com/vitest-dev/vitest/commit/f05003327"><!-- raw HTML omitted -->(f0500)<!-- raw HTML omitted --></a></li> <li>Save failure screenshots per instance - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12042">vitest-dev/vitest#12042</a> <a href="https://github.com/vitest-dev/vitest/commit/e0e8e0000"><!-- raw HTML omitted -->(e0e8e)<!-- raw HTML omitted --></a></li> <li>Mock assets and computed dynamic imports - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11954">vitest-dev/vitest#11954</a> <a href="https://github.com/vitest-dev/vitest/commit/c6ad97dec"><!-- raw HTML omitted -->(c6ad9)<!-- raw HTML omitted --></a></li> </ul> </li> <li><strong>cli</strong>: <ul> <li>Disallow --changed in vitest related - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12038">vitest-dev/vitest#12038</a> <a href="https://github.com/vitest-dev/vitest/commit/b3a803b1f"><!-- raw HTML omitted -->(b3a80)<!-- raw HTML omitted --></a></li> </ul> </li> <li><strong>coverage</strong>: <ul> <li>Prevent duplicate metrics caused by source map end column differences - by <a href="https://github.com/AriPerkkio"><code>@AriPerkkio</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12040">vitest-dev/vitest#12040</a> <a href="https://github.com/vitest-dev/vitest/commit/45d199c58"><!-- raw HTML omitted -->(45d19)<!-- raw HTML omitted --></a></li> </ul> </li> <li><strong>deps</strong>: <ul> <li>Update all non-major dependencies - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12050">vitest-dev/vitest#12050</a> <a href="https://github.com/vitest-dev/vitest/commit/ff6b4275f"><!-- raw HTML omitted -->(ff6b4)<!-- raw HTML omitted --></a></li> </ul> </li> <li><strong>mocker</strong>: <ul> <li>Transform a factory-mocked module once - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12027">vitest-dev/vitest#12027</a> <a href="https://github.com/vitest-dev/vitest/commit/8b0ca603a"><!-- raw HTML omitted -->(8b0ca)<!-- raw HTML omitted --></a></li> </ul> </li> <li><strong>pool</strong>: <ul> <li>Handle failed forks worker start on bun - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12039">vitest-dev/vitest#12039</a> <a href="https://github.com/vitest-dev/vitest/commit/4aec89426"><!-- raw HTML omitted -->(4aec8)<!-- raw HTML omitted --></a></li> </ul> </li> <li><strong>snapshot</strong>: <ul> <li>Remove new snapshots of a failed retry - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12052">vitest-dev/vitest#12052</a> <a href="https://github.com/vitest-dev/vitest/commit/2123874a4"><!-- raw HTML omitted -->(21238)<!-- raw HTML omitted --></a></li> </ul> </li> <li><strong>ui</strong>: <ul> <li>Ensure <code>detailsPosition: bottom</code> for auto-opened trace view - by <a href="https://github.com/hi-ogawa"><code>@hi-ogawa</code></a> and <strong>Claude Opus 5.5</strong> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12016">vitest-dev/vitest#12016</a> <a href="https://github.com/vitest-dev/vitest/commit/366ac633b"><!-- raw HTML omitted -->(366ac)<!-- raw HTML omitted --></a></li> </ul> </li> </ul> <h3> 🏎 Performance</h3> <ul> <li>Read external source maps once per run - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12106">vitest-dev/vitest#12106</a> <a href="https://github.com/vitest-dev/vitest/commit/b5a553395"><!-- raw HTML omitted -->(b5a55)<!-- raw HTML omitted --></a></li> <li><strong>expect</strong>: Reuse the key array in deep equality - by <a href="https://github.com/camc314"><code>@camc314</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12104">vitest-dev/vitest#12104</a> <a href="https://github.com/vitest-dev/vitest/commit/f88ab6cc3"><!-- raw HTML omitted -->(f88ab)<!-- raw HTML omitted --></a></li> <li><strong>mocker</strong>: Find dynamic imports with es-module-lexer - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/12028">vitest-dev/vitest#12028</a> <a href="https://github.com/vitest-dev/vitest/commit/5812ec58f"><!-- raw HTML omitted -->(5812e)<!-- raw HTML omitted --></a></li> </ul> <h5> <a href="https://github.com/vitest-dev/vitest/compare/v5.1.1...v5.1.2">View changes on GitHub</a></h5> <h2>v5.1.1</h2> <h3> 🚀 Features</h3> <ul> <li><strong>cache</strong>: Add fs module cache env variables - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11859">vitest-dev/vitest#11859</a> <a href="https://github.com/vitest-dev/vitest/commit/708c05da0"><!-- raw HTML omitted -->(708c0)<!-- raw HTML omitted --></a></li> </ul> <h3> 🐞 Bug Fixes</h3> <ul> <li>Rerun on file changes after a config restart - by <a href="https://github.com/magurotuna"><code>@magurotuna</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11772">vitest-dev/vitest#11772</a> and <a href="https://redirect.github.com/vitest-dev/vitest/issues/11829">vitest-dev/vitest#11829</a> <a href="https://github.com/vitest-dev/vitest/commit/289caab9c"><!-- raw HTML omitted -->(289ca)<!-- raw HTML omitted --></a></li> <li>Avoid leaking the context expect - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11845">vitest-dev/vitest#11845</a> <a href="https://github.com/vitest-dev/vitest/commit/3c967a7b7"><!-- raw HTML omitted -->(3c967)<!-- raw HTML omitted --></a></li> <li>Report fixture teardown errors once - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11857">vitest-dev/vitest#11857</a> <a href="https://github.com/vitest-dev/vitest/commit/6b167eb79"><!-- raw HTML omitted -->(6b167)<!-- raw HTML omitted --></a></li> <li>Improve diffs for asymmetric matchers - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11855">vitest-dev/vitest#11855</a> <a href="https://github.com/vitest-dev/vitest/commit/86775420f"><!-- raw HTML omitted -->(86775)<!-- raw HTML omitted --></a></li> <li>Apply --shard before the test run starts - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11846">vitest-dev/vitest#11846</a> <a href="https://github.com/vitest-dev/vitest/commit/e5c80b775"><!-- raw HTML omitted -->(e5c80)<!-- raw HTML omitted --></a></li> <li>Reset local expect state between retries for <code>expect.assertions/hasAssertions</code> - by <a href="https://github.com/hi-ogawa"><code>@hi-ogawa</code></a> and <strong>Claude Opus 5.5</strong> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11900">vitest-dev/vitest#11900</a> <a href="https://github.com/vitest-dev/vitest/commit/50dcdb373"><!-- raw HTML omitted -->(50dcd)<!-- raw HTML omitted --></a></li> <li>Sort test files before the seeded shuffle - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11926">vitest-dev/vitest#11926</a> <a href="https://github.com/vitest-dev/vitest/commit/3aa3045a9"><!-- raw HTML omitted -->(3aa30)<!-- raw HTML omitted --></a></li> <li>Tear down fixture contexts one at a time - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11956">vitest-dev/vitest#11956</a> <a href="https://github.com/vitest-dev/vitest/commit/5712b5fd2"><!-- raw HTML omitted -->(5712b)<!-- raw HTML omitted --></a></li> <li>Count merged errors in the error divider - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11955">vitest-dev/vitest#11955</a> <a href="https://github.com/vitest-dev/vitest/commit/4bc4f86e8"><!-- raw HTML omitted -->(4bc4f)<!-- raw HTML omitted --></a></li> <li>Match <code>-</code> and <code>.</code> in <code>noExternal</code> wildcards - by <a href="https://github.com/hi-ogawa"><code>@hi-ogawa</code></a> and <strong>Claude Opus 5.5</strong> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11978">vitest-dev/vitest#11978</a> <a href="https://github.com/vitest-dev/vitest/commit/efba8cbfe"><!-- raw HTML omitted -->(efba8)<!-- raw HTML omitted --></a></li> <li>Give each test attempt a new <code>signal</code> - by <a href="https://github.com/sheremet-va"><code>@sheremet-va</code></a> in <a href="https://redirect.github.com/vitest-dev/vitest/issues/11998">vitest-dev/vitest#11998</a> <a href="https://github.com/vitest-dev/vitest/commit/77a306757"><!-- raw HTML omitted -->(77a30)<!-- raw HTML omitted --></a></li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/vitest-dev/vitest/commit/a718e12109d7b98bac10c9f376dfeb6fe1ec309f"><code>a718e12</code></a> chore: release v5.1.2 (<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12109">#12109</a>)</li> <li><a href="https://github.com/vitest-dev/vitest/commit/5f8847345ccae6a45b180599ab3c6b528985b9f1"><code>5f88473</code></a> fix: warn when projects attach the same file (<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12043">#12043</a>)</li> <li><a href="https://github.com/vitest-dev/vitest/commit/b5a553395132d0f61b0c03377055e12700db456a"><code>b5a5533</code></a> perf: read external source maps once per run (<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12106">#12106</a>)</li> <li><a href="https://github.com/vitest-dev/vitest/commit/b3a803b1ff134c198f0c00a7e05ce34ae40df7d2"><code>b3a803b</code></a> fix(cli): disallow --changed in vitest related (<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12038">#12038</a>)</li> <li><a href="https://github.com/vitest-dev/vitest/commit/4aec89426c93b7a0e5627ae5ee32701f3a817ffe"><code>4aec894</code></a> fix(pool): handle failed forks worker start on bun (<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12039">#12039</a>)</li> <li><a href="https://github.com/vitest-dev/vitest/commit/b7572c1e61fe52dfc0271408b67a02d240dbc535"><code>b7572c1</code></a> fix: report global setup errors instead of "no test files" (<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12031">#12031</a>)</li> <li><a href="https://github.com/vitest-dev/vitest/commit/0c418880a48f220d89a56763fcc13373446f39ed"><code>0c41888</code></a> refactor: simplify console task id lookup (<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12009">#12009</a>)</li> <li><a href="https://github.com/vitest-dev/vitest/commit/161e25f663a838f6a30890f8a6827ff83ff1b3c7"><code>161e25f</code></a> chore: release v5.1.1 (<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12004">#12004</a>)</li> <li><a href="https://github.com/vitest-dev/vitest/commit/9b87492f77992bcff4356afa4dad91028964c2c1"><code>9b87492</code></a> fix: throw timeout error classes instead of Error (<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12003">#12003</a>)</li> <li><a href="https://github.com/vitest-dev/vitest/commit/77a306757d6291a0ce6f6adb7142e39886f08ffe"><code>77a3067</code></a> fix: give each test attempt a new <code>signal</code> (<a href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/11998">#11998</a>)</li> <li>Additional commits viewable in <a href="https://github.com/vitest-dev/vitest/commits/v5.1.2/packages/vitest">compare view</a></li> </ul> </details> <br /> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
a62aa6a85f |
build(deps-dev): bump wrangler from 4.164.0 to 4.170.0 in /scripts/typecheck-sandbox-providers (#22601)
Bumps [wrangler](https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler) from 4.164.0 to 4.170.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/cloudflare/workers-sdk/releases">wrangler's releases</a>.</em></p> <blockquote> <h2>wrangler@4.170.0</h2> <h3>Minor Changes</h3> <ul> <li> <p><a href="https://redirect.github.com/cloudflare/workers-sdk/pull/16678">#16678</a> <a href="https://github.com/cloudflare/workers-sdk/commit/7d57524dd15a711a4ad7ce24e631a61c6af2ba2a"><code>7d57524</code></a> Thanks <a href="https://github.com/mglewis"><code>@mglewis</code></a>! - Add local development support for <code>/cdn-cgi/image/</code> URL transformations</p> <p>When <code>images.url_transformations</code> (or <code>images.urlTransformations</code> in <code>cloudflare.config.ts</code>) is enabled, Miniflare now handles <code>/cdn-cgi/image/<options>/<source></code> requests locally before they reach your Worker. Requests return a 404 when URL transformations aren't enabled for the Worker, and a 403 when the source image isn't allowed by <code>allowed_origins</code>. Transforms use the same low-fidelity Sharp-backed mock as <code>cf.image</code> fetches, so only resize, rotate, format conversion and a small set of options are applied.</p> <p>This is a change in behaviour: previously <code>/cdn-cgi/image/</code> requests were passed through to the Worker during local development.</p> <p>Requests made through <code>SELF</code> in <code>@cloudflare/vitest-plugin</code> bypass Miniflare's routing and are not intercepted.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/workers-sdk/pull/17266">#17266</a> <a href="https://github.com/cloudflare/workers-sdk/commit/b9bb1b0764a1330b3df612352e17f494b702ac8d"><code>b9bb1b0</code></a> Thanks <a href="https://github.com/apps/dependabot"><code>@dependabot</code></a>! - Support Analog 3 in <code>wrangler setup</code></p> <p>Configure Analog’s standalone Nitro Vite plugin for Cloudflare Workers. Both <code>wrangler setup</code> and <code>create-cloudflare</code> configure the Minimal starter as a static site. Analog 2 projects continue to use the Nitro options on the Analog Vite plugin. Projects using native Nitro 3 (<code>nitro/vite</code>) should use Nitro’s generated Wrangler configuration instead.</p> </li> </ul> <h3>Patch Changes</h3> <ul> <li> <p><a href="https://redirect.github.com/cloudflare/workers-sdk/pull/17258">#17258</a> <a href="https://github.com/cloudflare/workers-sdk/commit/e96e5082112b14cc7e35197d7a098bd217bb74ba"><code>e96e508</code></a> Thanks <a href="https://github.com/irvinebroque"><code>@irvinebroque</code></a>! - Show the plan-specific Time Travel retention window in <code>wrangler d1 time-travel restore --help</code></p> <p>Previously, the <code>--timestamp</code> description said every database keeps 30 days of history, but databases on Workers Free only keep 7 days. The help text now lists the window for each plan. The error for a timestamp older than 30 days now lists both windows too.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/workers-sdk/pull/17284">#17284</a> <a href="https://github.com/cloudflare/workers-sdk/commit/5b6e6bf27a5f3e2d5e16c09b7185f906bc55e7b4"><code>5b6e6bf</code></a> Thanks <a href="https://github.com/apps/dependabot"><code>@dependabot</code></a>! - Update <code>DEFAULT_COMPAT_DATE</code> to 2026-11-29</p> <p>Use the bundled workerd release's compatibility date by default when scaffolding new projects or when no compatibility date is configured.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/workers-sdk/pull/17284">#17284</a> <a href="https://github.com/cloudflare/workers-sdk/commit/5b6e6bf27a5f3e2d5e16c09b7185f906bc55e7b4"><code>5b6e6bf</code></a> Thanks <a href="https://github.com/apps/dependabot"><code>@dependabot</code></a>! - Update dependencies of "miniflare", "wrangler"</p> <p>The following dependency versions have been updated:</p> <table> <thead> <tr> <th>Dependency</th> <th>From</th> <th>To</th> </tr> </thead> <tbody> <tr> <td><code>@cloudflare/workers-types</code></td> <td>^5.20261127.1</td> <td>^5.20261129.1</td> </tr> <tr> <td>workerd</td> <td>1.20261127.1</td> <td>1.20261129.1</td> </tr> </tbody> </table> </li> <li> <p><a href="https://redirect.github.com/cloudflare/workers-sdk/pull/17211">#17211</a> <a href="https://github.com/cloudflare/workers-sdk/commit/b91cef97e6a7472839a1291569c32c353ccef18e"><code>b91cef9</code></a> Thanks <a href="https://github.com/jamesopstad"><code>@jamesopstad</code></a>! - Keep remote bindings working after a failed change to the account or API token is reverted</p> <p>Previously, changing the account ID or API token to credentials that failed to start a remote session (for example, a malformed account ID) disposed the existing session first. Reverting the change then reused that disposed session, so remote bindings stayed offline until the development server was restarted. The existing session is now disposed only once its replacement is ready, so it keeps working if the new credentials fail to start a session.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/workers-sdk/pull/17217">#17217</a> <a href="https://github.com/cloudflare/workers-sdk/commit/fd544927145d481921d4f48ebb6e69ab20bf6c12"><code>fd54492</code></a> Thanks <a href="https://github.com/irvinebroque"><code>@irvinebroque</code></a>! - Emit explicit removal warnings for removed <code>type</code> and <code>zone_id</code> configuration fields</p> <p>Legacy Wrangler v3 <code>type</code> and <code>zone_id</code> fields now emit explicit removal warnings with migration guidance instead of being flagged as unexpected fields with a misleading "Try upgrading Wrangler" hint.</p> </li> <li> <p><a href="https://redirect.github.com/cloudflare/workers-sdk/pull/17244">#17244</a> <a href="https://github.com/cloudflare/workers-sdk/commit/a33256830dc008a2b20195d9c08c95a46fa60eb7"><code>a332568</code></a> Thanks <a href="https://github.com/dario-piotrowicz"><code>@dario-piotrowicz</code></a>! - Explain where misplaced fields belong in <code>cloudflare.config.ts</code> validation errors</p> <p>Errors for top-level fields such as <code>accountId</code> placed under <code>worker</code> now explain that they belong at the top level. Worker fields placed at the top level also include a hint to move them inside <code>worker</code>.</p> </li> <li> <p>Updated dependencies [<a href="https://github.com/cloudflare/workers-sdk/commit/7d57524dd15a711a4ad7ce24e631a61c6af2ba2a"><code>7d57524</code></a>, <a href="https://github.com/cloudflare/workers-sdk/commit/5b6e6bf27a5f3e2d5e16c09b7185f906bc55e7b4"><code>5b6e6bf</code></a>, <a href="https://github.com/cloudflare/workers-sdk/commit/5b6e6bf27a5f3e2d5e16c09b7185f906bc55e7b4"><code>5b6e6bf</code></a>, <a href="https://github.com/cloudflare/workers-sdk/commit/7d57524dd15a711a4ad7ce24e631a61c6af2ba2a"><code>7d57524</code></a>, <a href="https://github.com/cloudflare/workers-sdk/commit/fd544927145d481921d4f48ebb6e69ab20bf6c12"><code>fd54492</code></a>, <a href="https://github.com/cloudflare/workers-sdk/commit/2a10aff2cd185bc8eaca6e15f555fe579f7747c1"><code>2a10aff</code></a>]:</p> <ul> <li><a href="mailto:miniflare@5.20261129.0-beta">miniflare@5.20261129.0-beta</a></li> <li><code>@cloudflare/workers-utils</code><a href="https://github.com/0"><code>@0</code></a>.60.0</li> </ul> </li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/cloudflare/workers-sdk/commit/b1e0183c6755fc52e9a09739ddf768d582cd4e99"><code>b1e0183</code></a> Version Packages (<a href="https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler/issues/17276">#17276</a>)</li> <li><a href="https://github.com/cloudflare/workers-sdk/commit/bc09bb3b603bc1087481732988f66f38d951a048"><code>bc09bb3</code></a> [autoconfig] Support Next.js static exports on the OpenNext path (<a href="https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler/issues/17288">#17288</a>)</li> <li><a href="https://github.com/cloudflare/workers-sdk/commit/7d57524dd15a711a4ad7ce24e631a61c6af2ba2a"><code>7d57524</code></a> [miniflare] Add local development support for /cdn-cgi/image/ URL transformat...</li> <li><a href="https://github.com/cloudflare/workers-sdk/commit/e96e5082112b14cc7e35197d7a098bd217bb74ba"><code>e96e508</code></a> [wrangler] Show plan-specific D1 Time Travel retention in restore help (<a href="https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler/issues/17258">#17258</a>)</li> <li><a href="https://github.com/cloudflare/workers-sdk/commit/2639ba3ec26713d2f04b6cab33a0c7dca5b423b7"><code>2639ba3</code></a> [workers-sdk] Preserve shared remote session tests and auth test cleanup (<a href="https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler/issues/17">#17</a>...</li> <li><a href="https://github.com/cloudflare/workers-sdk/commit/b5929df1feb943d438f7ac75c9b91f9c1c98ea67"><code>b5929df</code></a> Version Packages (<a href="https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler/issues/17232">#17232</a>)</li> <li><a href="https://github.com/cloudflare/workers-sdk/commit/7072797d13393c4f431c7c797f851f67442bd2ee"><code>7072797</code></a> [autoconfig] Scaffold project files for cf setup (<a href="https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler/issues/17164">#17164</a>)</li> <li><a href="https://github.com/cloudflare/workers-sdk/commit/370ea36c3b25414b7ee521238db8cbd54e19e522"><code>370ea36</code></a> Version Packages (<a href="https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler/issues/17152">#17152</a>)</li> <li><a href="https://github.com/cloudflare/workers-sdk/commit/6bd30e3953f90d745b9fdf3464279b7267ca5231"><code>6bd30e3</code></a> [wrangler] Revert lazy remote-only binding login (<a href="https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler/issues/17223">#17223</a>)</li> <li><a href="https://github.com/cloudflare/workers-sdk/commit/e351be9ab21247e6e6e7dbc81b148f17368a7ac1"><code>e351be9</code></a> Prefer <code>CLOUDFLARE_ACCOUNT_ID</code> to the configured <code>accountId</code> (<a href="https://github.com/cloudflare/workers-sdk/tree/HEAD/packages/wrangler/issues/17205">#17205</a>)</li> <li>Additional commits viewable in <a href="https://github.com/cloudflare/workers-sdk/commits/wrangler@4.170.0/packages/wrangler">compare view</a></li> </ul> </details> <br /> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
ee05db9e16 |
fix(budgets): add Anthropic rate cards with family-max fallback and surface paused-agent budget notices (#23658)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Cost accounting prices Anthropic token receipts against rate cards
so budget policies can track spend and enforce hard stops
> - `anthropic-pricing.ts` only had rate cards for `claude-sonnet-5` and
`claude-opus-5-5`, so newer shipped models such as `claude-fable-5-2`
settled as `unpriced`
> - Because budget policies default to `unpriced_usage_policy =
"block"`, creating a spend cap on an agent that ran an unpriced model
immediately triggered a budget hard stop even when observed spend was
far below the limit
> - Meanwhile, the chat thread notice for a budget-paused agent had no
action link and did not state that messages sent while paused will not
receive a reply, and the budget incident card did not clearly explain
unpriced-usage stops or what "Keep paused" does
> - This pull request adds rate cards for shipped Anthropic models with
a conservative family-maximum fallback for uncataloged models, clarifies
the paused-agent chat notice and unpriced budget incident card, and adds
Storybook coverage
> - The benefit is that budget caps track current and future Anthropic
models accurately without false unpriced-usage lockouts, and operators
immediately see why an agent is not replying and where to resolve it
## Linked Issues or Issue Description
**What happened?**
When an agent ran a shipped Anthropic model missing from `RATE_CARDS`
(such as `claude-fable-5-2`), its usage receipts settled with
`costStatus: "unpriced"`. Creating a budget policy (which defaults to
`unpriced_usage_policy: "block"`) immediately fired a hard-stop incident
and paused the agent even when known spend was well below the limit. In
the task chat thread, the paused-agent banner gave no link to the
agent's budget page and did not clearly warn that new messages would not
trigger replies; on the budget incident card, the unpriced-usage stop
looked like a regular spend-limit alert and dismissing it via "Keep
paused" left the agent paused with no clear explanation.
**Expected behavior**
Shipped Anthropic models should have explicit rate cards, and
uncataloged models in a known Claude family (`fable`, `mythos`, `opus`,
`sonnet`, `haiku`) should fall back conservatively to the most expensive
rate card in that family rather than settling as unpriced. When an agent
is paused in chat, the notice should clearly state that messages will
not get a reply until the agent is resumed and provide a direct "Review
budget" link for budget pauses. Unpriced-usage budget stops should
clearly explain why work stopped and that "Keep paused" dismisses the
alert without resuming work.
**Steps to reproduce**
1. Run an agent on `claude-fable-5-2` using direct Anthropic API billing
so usage receipts settle as `unpriced`.
2. Add a monthly budget policy (e.g. $1,000) on that agent.
3. Observe an immediate hard-stop budget incident pausing the agent
despite low observed spend.
4. Return to the agent's chat thread and observe the paused banner lacks
a budget link and does not clearly state that new messages will not get
a reply.
## What Changed
- `server/src/services/anthropic-pricing.ts`: Added explicit standard
API rate cards for shipped Anthropic models (`claude-fable-5-2`, `5-1`,
`5`; `claude-mythos-5-2`, `5-1`, `5`; `claude-opus-5-5`, `5`, `4-8`,
`4-7`, `4-6`, `4-5`; `claude-sonnet-5-5`, `5`, `4-6`, `4-5`;
`claude-haiku-5-5`, `4-5`), normalized optional `[1m]` suffixes, and
added a dynamic family-maximum fallback (`FAMILY_MAX_RATE_CARDS`) so any
uncataloged model in a known Claude family conservatively uses the
highest rate in that group with explicit provenance.
- `server/src/services/anthropic-pricing.test.ts`: Added unit tests
covering `claude-fable-5-2` (including `[1m]`), `claude-sonnet-5-5`,
`claude-haiku-4-5`, family-maximum fallbacks across all five Claude
families, and preserving unknown/non-Anthropic models as unpriced.
- `ui/src/components/IssueChatThread.tsx`: Updated
`IssueAssigneePausedNotice` to state clearly that messages sent while
paused will not get a reply, distinguish budget pauses in the title, and
render a direct "Review budget" link to `${agentUrl(agent)}/budgets`.
- `ui/src/components/BudgetIncidentCard.tsx`: Clarified unpriced-usage
hard stops (`unpriced usage stop`, known spend vs. limit, and why
unpriced usage blocked work) and added a muted note beside "Keep paused"
explaining that dismissing the alert keeps the scope paused.
- `ui/src/components/PausedBudgetNotices.test.tsx`: Added focused jsdom
unit tests for `IssueAssigneePausedNotice` (budget pause link and manual
resume action) and `BudgetIncidentCard` (unpriced-usage hard-stop copy).
-
`ui/storybook/stories/budgets-costs/paused-agent-chat-notice.stories.tsx`:
Added production-component Storybook stories (`BudgetPausedInChat`,
`BudgetPausedWithUnpricedIncident`, `ManuallyPausedInChat`) with
interaction tests.
## Verification
- `pnpm vitest run server/src/services/anthropic-pricing.test.ts
ui/src/components/PausedBudgetNotices.test.tsx`: 2 test files, 30 tests
passed.
- `pnpm --filter @paperclipai/server typecheck`: passed.
- `pnpm --filter @paperclipai/ui typecheck` (including `node
../scripts/storybook-catalog.mjs`): passed.
- Verified all three new Storybook stories interactively in a browser
against local Storybook (`http://localhost:6006`) with zero runtime
errors and passing Storybook play assertions.
- `pnpm verify` exited 2 due to pre-existing untracked local files;
relying on required CI for full-repo coverage.
## Risks
- Low risk. Existing rate cards for `claude-sonnet-5` and
`claude-opus-5-5` keep their exact rates and versions. Family-maximum
fallbacks are intentionally conservative upper bounds and are labeled in
`pricingProvenance.evidence` as estimates rather than invoices.
- Existing already-settled `unpriced` cost events in databases are not
retroactively rewritten; this prevents new runs on shipped or future
Claude-family models from settling as unpriced.
## Model Used
- Google Gemini (Gemini 4 Neon Medium via Antigravity), with file
editing, terminal execution, browser verification, and web search 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
- [ ] 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>
|
||
|
|
4da93d2f26 |
build(deps): bump tar from 7.5.22 to 7.5.23 in /scripts/typecheck-sandbox-providers (#22602)
Bumps [tar](https://github.com/isaacs/node-tar) from 7.5.22 to 7.5.23. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/isaacs/node-tar/commit/eb92e178af52cd191d48eb70a846f61cc4dade1b"><code>eb92e17</code></a> 7.5.23</li> <li><a href="https://github.com/isaacs/node-tar/commit/158f51dce6790f37ddcd384567486c7c90c9ac0c"><code>158f51d</code></a> publish via OIDC</li> <li>See full diff in <a href="https://github.com/isaacs/node-tar/compare/v7.5.22...v7.5.23">compare view</a></li> </ul> </details> <details> <summary>Maintainer changes</summary> <p>This version was pushed to npm by <a href="https://www.npmjs.com/~GitHub%20Actions">GitHub Actions</a>, a new releaser for tar since your current version.</p> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
9d1ac1f188 |
fix(acpx): tag mid-stream transport stalls as transient_upstream so bounded retry arms (#12491)
## Thinking Path > The ACPX engine reports a mid-stream transport stall and a hard provider capacity cap under one code, `acpx_turn_failed`, but they want opposite retry semantics. Because the engine never persists `errorFamily`, the heartbeat bounded-retry ladder never arms for transport stalls (issue #11257). This classifies the two at the adapter, tagging stalls `transient_upstream` while leaving the capacity-cap subclass on its `provider_quota` path. ## Linked Issues or Issue Description Fixes #11257. Searched the open PR list — no existing PR adds ACPX transport-stall errorFamily classification. ## What Changed Rebased onto the new terminal-failure classification (`terminalFailureClassification` + per-adapter `classifyTerminalSessionFailure`). The adapter classifiers (`classifyClaudeTerminalSessionFailure`, `classifyCodexTerminalSessionFailure`) only cover `access` and provider-quota `limit` failures, so a mid-stream stall is still left with no `errorFamily` on `master`. - **`classifyAcpxTurnFailureErrorFamily(error, terminalSessionFailure?)`** (pure, exported): returns `"transient_upstream"` only for the transport-stall signature. Capacity/quota wording vetoes first, and an `access` / `limit` terminal-session category is never relabelled. - **Engine wiring**: used as a fallback **after** `classifyToolDefinitionFailure` and the adapter classifier — `terminalFailureClassification ?? fallback`. Adapter labels always win; `errorCode` stays `acpx_turn_failed`. The family flows through the existing `classifiedFailure` path into the top-level result and `resultJson`. No server change. ## Verification - `pnpm exec vitest run packages/adapter-utils/src/acpx-engine/execute.test.ts` — 232 passed, including: stall/cap/unrelated unit cases, two remote-harness runs (stall → `transient_upstream`, session cap → none), and three `classifyTerminalSessionFailure` cases (unclaimed stall → `transient_upstream`; adapter `provider_quota` wins over the fallback; unclaimed `limit` failure with stall wording stays unlabelled). - `vitest run packages/adapters/claude-local packages/adapters/codex-local` — green. - `tsc --noEmit` — `packages/adapter-utils` and `server` 0 errors. ## Risks - Text-based classification: an unmatched reword is a safe false-negative (preserves today's no-retry). A stall surfacing as a thrown error rather than a failed terminal is a follow-up. ## Model Used - Claude Opus 4.8 (Anthropic), via Claude Code with tool use. ## 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` URLs) - [x] My branch name describes the change and contains no internal ticket id - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s cc @cryppadotta @devinfoley — rebased onto the new `terminalFailureClassification` scheme; CI and Greptile are green, ready for review. |
||
|
|
eeb91a8b28 |
build(deps-dev): bump @cloudflare/workers-types from 5.20261117.1 to 5.20261120.1 in /scripts/typecheck-sandbox-providers (#22603)
Bumps [@cloudflare/workers-types](https://github.com/cloudflare/workerd) from 5.20261117.1 to 5.20261120.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/cloudflare/workerd/releases">@cloudflare/workers-types's releases</a>.</em></p> <blockquote> <h2>PGO profiles</h2> <p>The profiles that optimize the Linux release builds (build/pgo/README.md). Don't delete them: build/pgo/profile.json names one of them, as may older commits that are built again.</p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li>See full diff in <a href="https://github.com/cloudflare/workerd/commits">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
7838a12f5c |
fix(runner): upgrade Pi to 1.7.0 for the undici and minimatch security fixes (#23430)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The experimental Paperclip Runner runs Pi from a pinned, hash-verified distribution. > - That distribution pins Pi 1.0.0, which installs undici 8.10.2. > - undici 8.12.4 fixes six advisories, including GHSA-mqg3-3v4r-cm32 (high). > - Dependabot cannot do this upgrade. The pins feed `PI_DISTRIBUTION_PINS`, the closure pins and the ACPX `commandDigest`, so a Dependabot change fails CI (#22711, #18998). > - This pull request upgrades Pi to 1.7.0 by hand under `rules/acpx-profile-identity.mdc`. > - The benefit is a Pi runtime with the undici security fixes and an unchanged trust model. ## Linked Issues or Issue Description Supersedes #22711. Supersedes #18998. **What is the problem?** The Runner Pi distribution installs undici 8.10.2. undici 8.12.4 fixes GHSA-mqg3-3v4r-cm32, GHSA-7xg3-fphp-28hg, GHSA-5rm8-gv32-r954, GHSA-9v6h-8rgp-m69f, GHSA-3g9m-rv3r-w5w2 and GHSA-r4pc-4jcp-7pqc. **Why can Dependabot not fix it?** `.github/dependabot.yml` excludes `pi-distribution` on purpose. The lock, the closure pins and the profile digest must change together. **What is the fix?** Upgrade `@earendil-works/pi-coding-agent` from 1.0.0 to 1.7.0, which pins undici 8.12.4. ## What Changed - Pin `@earendil-works/pi-coding-agent` 1.7.0. Regenerate `package-lock.json` with the pinned Node 24.21.0 and its npm 11.19.0. The lock now has 126 packages and no os/cpu-specific packages. - Pi 1.6.0 and later do not ship `npm-shrinkwrap.json`. Pi pins `brace-expansion` 5.0.12 itself. So: - Remove `patches/brace-expansion@5.0.9.patch` and its setup and build plumbing. - Replace the shrinkwrap check in `verifyLockedPiPackageGraph`. Each dependency that Pi declares must install at exactly that version. Each `undici` and `brace-expansion` copy in the lock must be the reviewed release (`PI_DISTRIBUTION_PINS.undici` 8.12.4, `braceExpansion` 5.0.12). - Pi 1.7.0 (the newest Pi) pins minimatch 11.0.3. That version has GHSA-cf2h-pxjq-68xw (high), GHSA-hqmv-qgp3-jx75 and GHSA-c859-jr93-m5j4. Add an npm override to minimatch 11.0.8, the first fixed release. `PI_SECURITY_OVERRIDES` lets the verifier accept only this override, and only while Pi pins 11.0.3. A later Pi pin change fails closed and forces a new review. - Update the three `PI_DISTRIBUTION_CLOSURE_SHA256` pins. Then regenerate the ACPX profiles (TypeScript and Rust) with `generate:acpx-profiles`. - Keep profile version 37. The `commandDigest` changes with the upstream release, so saved Pi sessions start fresh. This follows the rule. - Update the version checks in `pi-installation.ts`, the Rust fixtures (`PI_ACPX_DIGEST`), the installation-integrity fixtures (the 1.0.0 digest is now the refused prior digest), the tests, the e2e qualification ID (`pi:0.0.33:1.7.0:openrouter`) and its suite-definition hashes, and `runner-pi-capabilities.md`. ## Verification - `node scripts/materialize-pi-distribution.mjs /tmp/out` passes on linux-x64. It uses the official pinned Node archive and verifies all 126 locked packages and the new closure pin. - Darwin closure pins: the lock has no platform-specific packages. So each darwin closure is the linux-x64 closure with that target's pinned Node executable. I checked this method first: it reproduces all three Pi 1.0.0 pins exactly from a linux-x64 build of master. - `PAPERCLIP_TEST_PI_RUNTIME_ROOT=<materialized runtime> node --test test/pi-native-package-contract.test.mjs`: 15/15 pass. The test runs real Pi 1.7.0 RPC through the owned ACP/MCP bridge (hello, interleaved tools, provider errors, thinking modes, warm recovery, pending cancel, path admission, aliased MCP tools). - `node --test` for the materialize, provision, build-inputs and attestation scripts: 39/39 pass. - Vitest: `pi-installation`, `pi-provision`, `native-execution`: 132 pass, 1 skipped. `tests/runner-e2e/pi-controls-evidence.test.ts`: 72/72 pass. - `generate-acpx-profiles.mjs --check` passes. - Static review against 1.0.0: `dist/core/tools/path-utils.js` is byte-identical, the tool `path` schemas are unchanged, and the extension events that we use still exist. Unknown tools still fail closed. - Not run locally: Rust tests (no cargo here) and paid live-model qualification. CI covers Rust. Pi stays a candidate profile. ## Risks - Saved Pi Runner sessions start fresh after deploy because the `commandDigest` changes. This is the expected result of an upstream upgrade. - Pi 1.0 → 1.7 has upstream behavior changes (for example, the Azure provider rename to `azure`, and new default models). The Paperclip Pi bindings do not use `azure-openai-responses`. - A darwin closure pin can be wrong only if npm installs different bytes on macOS for a platform-neutral graph. The macOS build checks the pin and fails closed. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), 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> |
||
|
|
f4baaa4f48 |
fix(pi-local): respect message roles in transcripts (#11781)
## Thinking Path > - Paperclip manages AI agents and shows their run transcripts > - The Pi local adapter converts Pi JSON stdout events into transcript entries > - Pi emits `message_end` events for user, assistant, and tool-result messages > - The parser marked text from every `message_end` event as assistant output > - This made the wake payload look like assistant output and repeated tool results > - This pull request maps user messages to user entries and ignores other non-assistant messages > - The benefit is correct speaker attribution without a change to assistant output ## Linked Issues or Issue Description Fixes: #11780 ## What Changed - Read `message.role` before creating transcript entries. - Render user messages as user entries. - Ignore tool-result and unsupported roles in `message_end`. - Add regression tests for user, assistant, tool-result, and unsupported roles. ## Verification - `pnpm exec vitest run packages/adapters/pi-local/src/ui/parse-stdout.test.ts --config packages/adapters/pi-local/vitest.config.ts` — 4 tests passed. - `pnpm --filter @paperclipai/adapter-pi-local typecheck` — passed. - `pnpm --filter @paperclipai/adapter-pi-local build` — passed. - `pnpm -r typecheck` — passed. - `pnpm build` — passed. - `pnpm test:run` — 4,498 tests passed, 30 failed, and 5 skipped. The failures are in unrelated server suites on macOS. They cover `/tmp` and `/private/tmp` path differences, workspace runtime checks, and test port allocation. The Pi parser regression tests passed again after the full run. ## Risks Low risk. This change only affects Pi `message_end` transcript classification. Assistant text and thinking output stay the same. > 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 with a GPT-5-based model. The session used reasoning, tool use, and code execution. The exact model ID and context window were not exposed to 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 - [ ] 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 |
||
|
|
0960dd464d |
perf(chat): eliminate activity_log seq scans, chat load waterfalls, and transcript storms (#23750)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Persistent agent chat pages (`/:companyPrefix/chats/:agentRef`) are a primary surface for collaborating with an agent across many tasks and turns. > - Opening an active agent chat page was slow: multiple endpoints scanned the full `activity_log` table, the page bypassed the single-request chat bootstrap, the native transcript hook aborted and retried historical run fetches across multiple waves, and pending task questions triggered N+1 per-task interaction requests. > - These bottlenecks blocked the initial chat reveal for several seconds and saturated server and database capacity during page open. > - This pull request eliminates the `activity_log` sequential scans with index-backed predicates (no schema migrations), batches pending-question interaction hydration, defers completed saved-reply run transcripts in persistent agent chats, stabilizes per-run transcript lifecycles, and enables parallel chat resolution and chat-bootstrap adoption on agent chat pages. > - The benefit is dramatically faster agent chat page loads with far fewer HTTP requests, zero `activity_log` full-table scans on hot chat paths, and no schema migrations. ## Linked Issues or Issue Description Related: #18461, #20355, #21650, #21671. **What happened?** Opening a persistent agent chat page with accumulated history and active tasks took multiple seconds before the conversation became visible and triggered dozens of concurrent API requests: 1. `decisionHistoryService.list` (`handledForBySource`) scanned all rows of `activity_log` because `(details ->> 'handledForUserId') IS NOT NULL` alone did not bind the second key of `activity_log_company_handled_for_created_idx`, and `decisions` used `NOT IN (SELECT id FROM issues ...)` which planned a full-company privacy subquery even when no settled decisions existed. 2. `activityService.forIssue` scanned all rows of `activity_log` because the `project.created` and `company.skill_created` branches omitted `entity_type`, preventing index scans. 3. `attentionService.taskQuestions` executed steady-state write transactions in `decision-retention` and unnecessary plan-document reads on read paths, and `CoordinatorChatPendingQuestion` mounted an `AttentionInteractionResolver` per question that fired one `GET /api/issues/:taskId/interactions` request per pending question. 4. `TaskChatThread` disabled saved-reply transcript deferral in `conversationMode`, fetching `/events` (and legacy `/log` fallbacks) for every historical completed run in the comment window, while `useNativeRunTranscripts` used a single shared `AbortController` that aborted and restarted in-flight sibling reads whenever run membership or live-stream state changed. 5. `AgentChat` waited serially for the agent roster and session before fetching the chat by `:agentRef`, `IssueDetail` skipped `startIssueChatBootstrap` for conversations, and the HTML preload plugin omitted the `AgentChat` chunk on `/chats/:ref` hard loads. **Expected behavior** Opening an agent chat page resolves the conversation and its first-frame data in parallel via `chat-bootstrap`, avoids sequential scans on `activity_log`, avoids fetching completed run transcripts when a saved reply is already visible, avoids aborting sibling in-flight transcript reads, and renders pending task questions without per-task N+1 interaction requests. **Steps to reproduce** 1. Create a company with a persistent agent chat that has 20+ historical replies from completed native runs, several hundred tasks assigned to that agent, pending `ask_user_questions` interactions across multiple tasks, and a large `activity_log` table. 2. Open `/:companyPrefix/chats/:agentRef` directly or from the sidebar and inspect the network waterfall and PostgreSQL query plans for `/activity`, `/decision-receipts`, `/pending-questions`, and `/heartbeat-runs/:id/events`. 3. Observe full-table `Seq Scan` plans on `activity_log`, bypassed `chat-bootstrap`, repeated aborted `/events` requests, and N+1 `/issues/:taskId/interactions` calls. **Paperclip version or commit** Reproduced on `ca21075837` (rebased onto `a3719da3ca`, final head `2995820afe`). ## What Changed - **Eliminate `activity_log` sequential scans (zero migrations)**: - `server/src/services/activity.ts`, `server/src/routes/activity.ts`, `server/src/routes/issues.ts`: Scope `forIssue` secondary branches by their canonical `entity_type` (`project` for `project.created`, `company_skill` for `company.skill_created`) and accept `companyId` from routes so PostgreSQL uses `BitmapOr` index scans instead of a full-table `Seq Scan`. - `server/src/services/decision-history.ts`: Add `(details ->> 'handledForUserId') >= ''` alongside `IS NOT NULL` in `handledForBySource` so PostgreSQL binds the partial index `activity_log_company_handled_for_created_idx`; replace `decision_target_issues.issue_id NOT IN (...)` with correlated `NOT EXISTS (...)`; add a `LIMIT 1` index probe before planning the full `decisions` privacy query when no settled decisions exist. - `server/src/services/conversation-decision-receipts.ts`, `server/src/routes/issues.ts`: Reuse the route's already-authorized conversation record instead of re-querying `source()`. - **Batch pending-question hydration and avoid steady-state retention writes**: - `packages/shared/src/types/attention.ts`, `server/src/services/issue-thread-interactions.ts`, `server/src/services/attention.ts`: Add optional `interaction?: IssueThreadInteraction | null` on `AttentionItem`, batch-hydrate interactions in `issueThreadInteractionService.listByIds` (grouping by `issueId` for acceptance readiness and skipping only `z.ZodError` legacy payloads), restrict `planDocumentMap` to actual plan confirmation interactions, and parallelize `decisionQueueItems` and `decisionTriage` reads in `enrichAttentionItems`. - `server/src/services/decision-retention.ts`: Add a read-only fast path in `syncItems` so steady-state reads skip opening a write transaction when retention rows are already current, while still syncing and bumping versions whenever `activityAt` changes. - `ui/src/components/AttentionInteractionResolver.tsx`, `ui/src/components/coordinator/CoordinatorChatPendingQuestions.tsx`: Accept optional `initialInteraction` so inline pending-question cards render immediately without N+1 `GET /issues/:taskId/interactions` requests while still honoring cache updates after mutations. - **Remove agent chat load waterfalls and transcript abort storms**: - `ui/src/components/TaskChatThread.tsx`, `ui/src/lib/run-answer-visibility.ts`: Defer completed `succeeded` run transcripts that already have a visible saved reply in `conversationMode` while preserving immediate hydration for live, failed, yielded, pending-interaction, and unanswered runs; precompute visible-answer lookups in linear time (`O(comments + runs)`) instead of quadratic scans. - `ui/src/components/transcript/useNativeRunTranscripts.ts`: Manage `AbortController`s and poll timers per run instead of one shared controller so adding sibling runs or transitioning stream health never aborts in-flight reads or refetches already-hydrated terminal runs; clear aborted in-flight tracking cleanly so expanding compact history refetches immediately. - `ui/src/pages/AgentChat.tsx`, `ui/src/pages/IssueDetail.tsx`, `ui/src/lib/vite-issue-detail-preload.ts`: Start `agentChatsApi.get` by `:agentRef` in parallel with roster/session reads on cold loads, enable `startIssueChatBootstrap` for conversations with an existing issue ID, and preload the `AgentChat` chunk alongside `IssueDetail` on `/chats/:ref` hard loads. - **Tests & SDK pin**: - Added/updated tests in `server/src/__tests__/activity-service.test.ts`, `server/src/__tests__/activity-routes.test.ts`, `server/src/__tests__/decision-history.test.ts`, `server/src/__tests__/issue-thread-interaction-routes.test.ts`, `ui/src/components/AttentionInteractionResolver.initial.test.tsx`, `ui/src/components/TaskChatThread.test.tsx`, `ui/src/components/transcript/useNativeRunTranscripts.test.tsx`, `ui/src/components/transcript/useNativeRunTranscripts.streaming.test.tsx`, and `ui/src/lib/vite-issue-detail-preload.test.ts`. - Updated `tests/runner-e2e/source-sdk-public-inputs.json` for `packages/shared/src/types/attention.ts`. ## Verification Local disposable PostgreSQL 18.1 benchmark (`200,000` `activity_log` rows, `455` tasks, `82` interactions, alternating baseline/treatment samples, `ANALYZE` run, positional `.values()` output equality verified on both empty and populated `handledForUserId` sets): | Caller/query | Before median | After median | Samples/spread | Complete output/contract check | Scope | | --- | --- | --- | --- | --- | --- | | `activityService.forIssue(50)` | `53.66 ms` (`50.78 ms` SQL exec, `11,147` buffers, `Seq Scan`) | `1.84 ms` (`0.31 ms` SQL exec, `23` buffers, `BitmapOr` index scans) | 7 alternating samples (before `48.03–62.79 ms`, after `1.34–3.18 ms`, `29.2x` speedup) | Pass (50 positional rows equal) | SQL | | `decisionHistory.handledForBySource` (40 ids, 0 rows) | `13.71 ms` (`11,193` buffers, `Seq Scan`) | `0.73 ms` (`2` buffers, `Bitmap Index Scan` on partial index) | 7 alternating samples (before `11.56–15.45 ms`, after `0.64–0.99 ms`, `18.8x` speedup) | Pass (empty + populated non-empty positional rows equal) | SQL | | `decisionHistory.handledForBySource` (40 ids, 1 matching row) | `40.35 ms` SQL exec (`11,193` buffers, `Seq Scan`) | `0.04 ms` SQL exec (`2` buffers, `Bitmap Index Scan` on partial index) | `EXPLAIN (ANALYZE, BUFFERS)` | Pass (1 positional row equal) | SQL | CI and reviews on final head `2995820afe`: - **GitHub Actions CI (`ci / verify`)**: **PASS** (all 86 check runs completed with 0 failures; `mergeStateStatus: CLEAN`). - **Greptile Review**: **5/5** (`SUCCESS`, 0 unresolved findings). - **Ponytail Paperclip Review**: **5/5** ("No actionable defects found in the reviewed paths. Verdict: Ship."). - **Feynman Nuclear Review**: **4/5** ("no confirmed defect in the new commits"). Tests and builds also verified locally: - `pnpm --filter @paperclipai/shared build` — pass - `cd server && node scripts/typecheck-layers.mjs` — pass (all 7 layers) - `pnpm --filter @paperclipai/ui typecheck` & `pnpm --filter @paperclipai/ui build` — pass - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/approval-queue-seeding-work.test.ts src/__tests__/decision-history.test.ts` — pass (28/28 and 14/14 on real embedded PostgreSQL) - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/activity-service.test.ts src/__tests__/openapi-routes.test.ts` — pass - Focused UI suites (`TaskChatThread.test.tsx`, `useNativeRunTranscripts.test.tsx`, `useNativeRunTranscripts.streaming.test.tsx`, `AttentionInteractionResolver.initial.test.tsx`, `AttentionInteractionResolver.replace.test.ts`, `IssueDetail.agentChatPanel.test.tsx`, `vite-issue-detail-preload.test.ts`) — pass ## Risks - **No schema migrations**: All SQL improvements use existing indexes. - **Completed chat run transcripts**: Persistent agent chats now defer completed `succeeded` runs that already have a visible saved reply, matching compact task behavior. Live, failed, yielded, pending-interaction, placeholder, progress-only, and hash-targeted runs still hydrate immediately. - **Inline interaction hydration**: `AttentionInteractionResolver` uses `initialInteraction` when provided and valid, skipping the mount-time `listInteractions` read; mutations and live updates continue to update/invalidate `queryKeys.issues.interactions(issueId)` and `["issues", "pending-questions"]`. Unparseable legacy interaction rows (`z.ZodError`) are omitted from the batch map and fall back cleanly to the per-issue read. - **Synthetic local proof vs production**: Local PostgreSQL benchmarks prove query plan and buffer reductions on synthetic data (`200k` rows); deployed latency improvements depend on production dataset size and cache warmth. ## Model Used Google Antigravity (Gemini) with tool use, terminal execution, and local embedded PostgreSQL profiling. ## 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> |
||
|
|
cfe5042378 |
fix(opencode): fix API key env/secret resolution and support Antigravity connector (#23387)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agent setup, environment testing, and managed AI connections pass
provider API keys into the OpenCode adapter and Paperclip Runner
> - OpenCode setup failed with `Secret not found` when a user supplied a
direct Gemini API key alongside a stale or auto-selected secret binding,
and the OpenCode runtime reported `GOOGLE_GENERATIVE_AI_API_KEY` missing
because Paperclip only passed `GEMINI_API_KEY` and limited OpenCode to
OpenRouter credentials
> - Users need reliable direct provider API keys and Google/Antigravity
API-key connectors across legacy OpenCode, native Paperclip Runner, and
Plugin Runner environments without exposing raw keys to child tool
shells
> - This pull request strips probe-overridden secret references
(including symmetric Google key aliases) before secret resolution,
prioritizes pasted API keys in setup, routes direct OpenCode provider
credentials through a runner-owned loopback proxy, and enables API-key
AI connections (including the Google / Antigravity connector) for
`opencode_local`
> - The benefit is that OpenCode agents test and run reliably with
direct provider keys or connected Google/Antigravity API keys without
false `Secret not found`, missing `GOOGLE_GENERATIVE_AI_API_KEY` errors,
or raw key leaks into child environments
## Linked Issues or Issue Description
- Fixes: #23359
- Refs #23370 (related community fix by @dev-787 for the initial Gemini
API key issue)
## What Changed
- **Server test-environment secret stripping and inheritance
(`server/src/routes/agents.ts`)**: Strip any credential key supplied in
`testCredentials` (including the symmetric `GEMINI_API_KEY` /
`GOOGLE_GENERATIVE_AI_API_KEY` pair and `hermes_gateway` `apiKey`) from
both `adapterConfig` and resolved environment `envVars` before secret
persistence normalization and runtime resolution. Scope `opencode_local`
inheritable credential groups from `@paperclipai/shared`
(`OPENCODE_PROVIDER_CREDENTIAL_ENV_KEYS`), skip inheritance when the
child supplies any OpenCode credential, and isolate multi-provider
parents to one matching provider group.
- **UI setup credential precedence (`ui/src/lib/provider-credential.ts`,
`ui/src/components/new-agent/NewAgentSetup.tsx`)**: Prefer an explicitly
entered raw API key over an auto-selected organization or personal
secret, and clear stale provider secret bindings and Google alias keys
when switching credentials or providers.
- **OpenCode direct provider keys and Gemini aliasing
(`packages/adapters/opencode-local/`, `packages/adapter-utils/`)**:
Mirror non-empty `GEMINI_API_KEY` into `GOOGLE_GENERATIVE_AI_API_KEY`
during OpenCode runtime config preparation and model discovery while
preserving blank managed isolation. Register `google`, `xai`, `groq`,
and `opencode` API key names in `api-billing-type`.
- **Runner-owned loopback credential proxy and allowlist parity
(`packages/paperclip-runner/`, `packages/plugins/sdk/`,
`packages/shared/`)**: Export canonical
`OPENCODE_PROVIDER_CREDENTIAL_ENV_KEYS` and
`OPENCODE_CREDENTIAL_ENV_KEYS` from `@paperclipai/shared`. Route direct
OpenCode provider API keys (`google`, `anthropic`, `openai`, `xai`,
`groq`, `opencode`) through a runner-owned loopback proxy
(`packages/paperclip-runner/src/drivers/opencode/provider-proxy.ts`)
with per-session bearer tokens, model-pinned endpoint allowlists, native
upstream auth header injection, request secret redaction, and redirect
refusal so raw keys never enter `opencode serve` child environments or
`opencode.json`. Allow direct provider keys across TypeScript, Rust, and
Plugin SDK allowlists, reserve `GOOGLE_API_KEY` and `GROK_API_KEY` in
TS/Rust configured-environment projections, strip ambient provider keys
(including `OPENROUTER_API_KEY`) from sanitized OpenCode runner
environments unless explicitly supplied, and redact provider keys in
output custody.
- **Antigravity / multi-provider API-key AI connections for OpenCode
(`packages/shared/`, `server/src/services/`,
`ui/src/components/ai-connections/`)**: Enable `api_key` AI connections
for `google` (Antigravity catalog slug), `anthropic`, `openai`, and
`xai` on `opencode_local` (keeping OAuth `subscription` methods
excluded), enforce provider-to-model prefix compatibility, mirror
`GEMINI_API_KEY` to `GOOGLE_GENERATIVE_AI_API_KEY` in
`prepareManagedAiRuntime`, isolate project config with
`OPENCODE_DISABLE_PROJECT_CONFIG=true`, and scope child-auth override
detection in `agent-ai-connection-default.ts` to non-empty OpenCode
credentials (supporting plain values, `secret_ref.secretId`, and
`user_secret_ref.key`).
- **Tests and pinned input registry**: Added unit, route, cross-layer
allowlist parity, and pinned `opencode@1.18.34` `bash`-tool credential
isolation tests across `adapter-utils`, `adapter-opencode-local`,
`paperclip-runner`, `server`, and `ui`, and synchronized
`tests/runner-e2e/source-sdk-public-inputs.json`.
## Verification
- `@paperclipai/adapter-utils`: `src/api-billing-type.test.ts` (17/17
tests), `typecheck`, `build` — passed
- `@paperclipai/adapter-opencode-local`:
`src/server/runtime-config.test.ts`, `src/server/models.test.ts`,
`typecheck`, `build` — passed
- `@paperclipai/shared`: full suite (123/123 files, 1426/1426 tests),
`typecheck`, `build` — passed
- `@paperclipai/paperclip-runner`: `typecheck:typescript`,
`build:typescript`, `check:package-boundaries`,
`opencode-server-driver.test.ts` (101/101 including pinned
`opencode@1.18.34` `bash`-tool test), `output-custody.test.ts` (13/13),
`configured-environment.test.ts` (35/35),
`antigravity-credentials.test.ts` (11/11), and
`durable-prp-control-plane.test.ts` — passed
- `@paperclipai/server`: `typecheck` and targeted suites
(`ai-connections.test.ts` 170/170, `agent-hire-ai-connections.test.ts`
84/84, `agent-test-environment-routes.test.ts` 72/72,
`agent-hire-auth-inheritance-routes.test.ts` 29/29,
`plugin-runner-credentials.test.ts` 43/43,
`plugin-runner-credential-names.test.ts` 6/6 cross-layer TS/Rust parity,
`opencode-local-adapter-environment.test.ts` 4/4,
`ai-auth-failure.test.ts` 32/32, `ai-provider-routing.test.ts` 21/21,
`antigravity-runner-credentials.test.ts`) — passed
- `@paperclipai/ui`: `typecheck`, `provider-credential.test.ts`,
`AiConnectionSelect.test.tsx` (20/20 tests) — passed
- `@paperclipai/plugin-sdk`: `build`, `environment-tasks.test.ts`,
`environment-task-release-resume.test.ts` (104/104) — passed on
`03dc341957`
- `@paperclipai/paperclip-runner`: `provider-traffic.test.ts` &
`provider-traffic-proxy.test.ts` alongside OpenCode/Antigravity/custody
suites (169/169) — passed on `03dc341957`
- `node tests/runner-e2e/source-sdk-public-inputs.mjs
|
||
|
|
e2e2265085 |
feat(plugins): tell a task side panel plugin when the person closes its tab (#23747)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugins can show an agent detail tab in the task side panel, next to a task > - The board mounts only the active side panel tab, and it unmounts a plugin view in the same way when the person switches tabs and when the person closes the tab > - Thus a plugin that shows a live view in a task panel tab cannot know when the person is done with it, and it cannot release the view > - A component callback does not solve this, because a background tab is not mounted when the person clicks its close control > - This pull request adds an optional declarative `taskSidePanel.closePath`, symmetric with the existing `availabilityPath` > - The benefit is that a plugin can release a live view when the person closes its tab, and plugins that do not declare the path see no change ## Linked Issues or Issue Description Refs #17796 (added plugin panels in task side panels). Related: #23609. **Subsystem affected** Plugin UI slots: `detailTab` slots with a `taskSidePanel` declaration, and the task side panel in the board UI. **Problem or motivation** A plugin panel in the task side panel gets no signal when the person closes its tab. The board unmounts the view on a close and on a tab switch in the same way, so the plugin cannot tell the two apart. A plugin that holds a live view for the panel cannot release it when the person closes the tab. **Proposed solution** Add an optional `closePath` to `taskSidePanel`. When the person closes the tab, the board sends a fire-and-forget POST to that plugin route, with the same agent, run and task as the availability request. The manifest must declare the path as a board POST route scoped to agent `:entityId`. **Alternatives considered** A callback on the mounted plugin component. It does not work for a background tab, because only the active tab is mounted. **Roadmap alignment** This extends the plugin system. It adds no product-specific behaviour to the control plane. ## What Changed - `taskSidePanel` accepts an optional `closePath`. It uses the same path rules as `availabilityPath`: a plugin-relative path with one `:entityId` segment. - Manifest validation requires a declared `POST` API route at `closePath` with `auth: "board"`, no transport, and `companyResolution: { from: "agent", param: "entityId" }`. These are the same rules as the `GET` availability route. - When the person closes a plugin panel tab in the task side panel, the board sends `POST /plugins/<pluginId>/api<closePath>?runId=<run>&issueId=<task>`, with `:entityId` replaced by the panel's agent. The board leaves out `runId` when the task has no active run. This applies to the active tab and to background tabs. - The board does not wait for the request. A failed request does not block the close, and the board logs a console warning. - The board sends no request on a tab switch, when the panel unmounts, when the person leaves the task, or when the board removes a panel that is no longer available. - A slot without `closePath` behaves as before. - The plugin SDK README and the plugin spec document the new field. A plugin declares: ```ts ui: { slots: [{ type: "detailTab", id: "screen", displayName: "Live view", exportName: "LiveView", entityTypes: ["agent"], taskSidePanel: { availabilityPath: "/agents/:entityId/view/availability", closePath: "/agents/:entityId/view/close", }, }] }, apiRoutes: [ { routeKey: "view.availability", method: "GET", path: "/agents/:entityId/view/availability", auth: "board", capability: "api.routes.register", companyResolution: { from: "agent", param: "entityId" } }, { routeKey: "view.close", method: "POST", path: "/agents/:entityId/view/close", auth: "board", capability: "api.routes.register", companyResolution: { from: "agent", param: "entityId" } }, ], ``` ## Verification - `packages/shared`: `npx vitest run src/validators/plugin.test.ts` passes (85 tests). New cases accept a valid close route and a close path equal to the availability path. They reject unsafe paths, a missing POST route, the wrong method (`GET`, `DELETE`), non-board auth, a non-agent company resolution, and the wrong agent parameter. - `ui`: `npx vitest run src/components/task-side-panel/TaskSidePanel.pluginClose.test.tsx` passes (6 tests). The tests render the task side panel and check that a close of the active tab and of a background tab sends exactly one POST to the correct URL. They also check that a tab switch, an unmount, a removal of an unavailable panel, and a slot without `closePath` send nothing, and that an idle task omits `runId` and a failed request still closes the tab. - Red check: with the board call removed, the three close tests fail. - `ui`: `npx vitest run src/hooks/useTaskPluginPanels.test.tsx` passes (56 tests). - `tsc --noEmit` passes for `packages/shared` and for `ui` source files. ## Risks - Low risk. The field is optional, and slots without it keep their current behaviour. - A plugin receives a close POST only for a person's close of the tab. The plugin must treat the request as a hint, because the request can fail or arrive late. - Existing manifests continue to validate. The availability route error message has the same text as before. > 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 (Anthropic), model ID `claude-opus-5-5`, run in Claude Code with tool use (file edits, shell, test runs) 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 merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3d3c702942 |
fix(runner): keep room to retire a session that filled its command journal (#23700)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Native agent runs use a Runner. Core keeps a durable journal of the commands that it sends to the Runner. > - The journal stops at 500 commands. A long run adds one semantic tool result to the journal for each tool call, so the journal can become full. > - The next run on the same sandbox must retire that session. It must queue `turn.stop`, `runner.drain`, `runner.suspend` and `session.close`. The full journal rejects these commands. > - Each successor run then fails with `native_predecessor_retirement_unproven` (`command_journal_full`). The task stays stuck until a person intervenes. > - This pull request keeps a separate, bounded reserve in the journal for retirement commands only. > - The benefit is that the next run can always stop and close a session whose work filled the journal. ## Linked Issues or Issue Description **What happened?** A long native run (Codex app-server) made almost 500 tool calls. Its Core command journal became full. Three automatic successor runs on the same sandbox then failed in `retireWarmPredecessor`. The error was "The previous run's session on this sandbox could not be retired (Durable PRP command journal bound exceeded: command_journal_full.)". The stack ends in `DurablePrpControlPlane.queueCommand` from `awaitRunnerSuspensionBarrier`. **Expected behavior** The next run retires the old session and continues. A full work journal must not block the commands that stop and close the session. **Steps to reproduce** 1. Create a `DurablePrpControlPlane`. 2. Queue 500 `semantic_tool.result` commands. 3. Queue `turn.stop`, `runner.drain`, `runner.suspend` or `session.close`. 4. On `master`, each of these throws `command_journal_full`. **Paperclip version or commit** `986af44e94` (`master`). The failure was seen on release `3f882fc589`. **Agent adapter(s) involved** Codex (native Runner, `paperclip_runner` adapter). The journal is not adapter-specific. Related: #20727 (a draft about the other journal bound, `command_payload_too_large`). This PR does not change that bound. ## What Changed - `durable-prp-control-plane.ts`: work commands still stop at 500 (`maxCommands`). - Retirement commands (`turn.stop`, `runner.drain`, `runner.suspend`, `runner.shutdown`, `session.close`, `session.destroy`, `run.cancel`) can use 64 more slots (`retirementCommandReserve`). Reads such as `session.snapshot` cannot use the reserve, so readiness polls cannot consume it. - The saved-state check and the checkpoint check accept up to 564 commands. Without this change, a retired journal cannot load again. - Three tests: one fills the journal and retires it, then reopens the local state. One does the same with checkpoint persistence and decodes the checkpoint. One fills the reserve to 564 commands and checks that a 565th retirement command and a read are both rejected without changing the journal. ## Verification - Red before the fix: `npx vitest run src/control-plane/durable-prp-control-plane.test.ts -t "command journal"` failed with `command_journal_full` on `turn.stop`. - Green after the fix: the same command passes (2 tests). - Each load bound is necessary: when I put back the old bound in the two validation checks, both tests fail. - Reserve bound: with the hard-cap check removed, the boundary test fails (`expected [Function] to throw an error`). - After review fixes ( |
||
|
|
bca282e587 |
feat(recents): add tasks from manual routine runs to Recents (#23675)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The sidebar Recents list shows the tasks from a person's own recent activity > - A person can run a routine manually with "Run now", and the run creates a task > - That task does not show in Recents, and opening it does not keep it there, because Recents only admits tasks under the Mine participation rule. This also affects every routine, channel, and agent-created task that a person opens > - The Mine rule keeps these tasks out of Mine on purpose, so we must not change that rule > - This pull request adds a separate Recents eligibility flag. It also admits tasks that the viewer opened and tasks from manual routine runs that the viewer started. The UI records the new task in Recents when the run starts > - The benefit is that people can find the task they just started from the sidebar at once, and Mine stays unchanged ## Linked Issues or Issue Description **Is your feature request related to a problem? Please describe.** When I run a routine manually and it creates a task, the task is not in my Recents list. I must go to the routine or the task list to find it. **Describe the solution you'd like** When I run a routine manually and a task is created, add that task to my Recents list automatically, even if I did not open it. Also, a task that a routine creates does not show in Recents even after I open it. **Additional context** Mine must continue to keep routine tasks out by default, including routines that a person starts manually (see `doc/PRODUCT.md`). ## What Changed - `server/src/services/issue-summaries.ts`: navigation summaries return a new `isRecentEligibleForMe` flag. It is true when one of these conditions is true: - The viewer participates under the Mine rule. - The viewer opened the task. The check is the viewer's `issue_read_states` row, which is unique on company, issue, and user. - The viewer started the manual routine run that created the task. The check is a `routine_runs` row found through the indexed `linked_issue_id`, with `source = 'manual'` and the same ID as the issue's `originRunId`. The issue `createdByUserId` must be the viewer, with no creating agent. `isParticipantForMe`, Mine, and unread state do not change. - `packages/shared`: add `isRecentEligibleForMe` to `IssueSummary`. - `ui/src/hooks/useRecentTasks.ts`: Recents uses `isRecentEligibleForMe` (with a fallback to `isParticipantForMe` for older cached summaries) to show, keep, and prune entries. - `ui/src/lib/recent-tasks.ts`: add `recordStartedRoutineRunTask`. It puts the run's task at the top of Recents. The summary fetch then supplies the title and status and confirms eligibility. - New `useRecordRoutineRunInRecents` hook. All five "Run now" paths call it on success: Routines (both list variants), Routine detail, Execution workspace detail, and the Responsibility screen. - `tests/runner-e2e/source-sdk-public-inputs.json`: refresh the pin for `packages/shared/src/types/issue.ts`. - `doc/PRODUCT.md`: document the Recents behavior. ## Verification - `cd ui && npx vitest run src/hooks/useRecentTasks.test.tsx`: 29 passed. The new test "shows a task from the viewer's manual routine run at the top before it is opened" fails on the old hook (red) and passes with the change (green). Other new tests cover a run that the server does not confirm (for example, a coalesced run) and a repeat run for a task that is already in Recents. - `cd server && npx vitest run src/__tests__/issue-summaries-routes.test.ts` (embedded Postgres): 24 passed. One new test checks that a manual run by the viewer is Recents-eligible but not a Mine participant, and that runs by another person and scheduled runs are not eligible. Another new test checks that a routine task the viewer opened is Recents-eligible, and that a task opened only by another person is not. That test fails on the previous service code (red) and passes with the change (green). - `ui` typecheck: no errors in changed files. (Errors exist only in ungenerated Storybook feature-map indexes, which this change does not touch.) - The full `server` typecheck was killed by the local memory limit. CI covers it. - Manual check: run a routine with "Run now", then look at sidebar Recents. The new task shows at the top before you open it. Mine does not show it. ## Risks - Low risk. No schema change and no migration. - The summaries query adds two `EXISTS` subqueries per requested task. Both use indexes (the read-state unique index and `routine_runs_linked_issue_idx`). The request is bounded by `ISSUE_SUMMARIES_MAX_IDS`. - Behavior change: Recents now keeps tasks that the person opened, also when the task is automatic work. Old local Recents entries for automatic tasks that the person read can come back. - If a manual run coalesces into an existing task that the viewer did not start, the entry is pruned after the summary read. That task does not show in Recents. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code with tool use (shell, file edit, test runs). ## 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 - [ ] 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) - [ ] 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> |
||
|
|
3f882fc589 |
fix(native): stage task-description attachments for native agents (#23688)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - People often create a task with a screenshot in its description and
assign it to a native agent.
> - The native Runner stages wake-comment files into the agent
workspace, so the agent can open an image with its file reader.
> - Files attached to the task description have no comment, so the
Runner never staged them.
> - The agent then said that it could not see the screenshot, or it
guessed from the text.
> - This pull request stages the task's own files on every native wake.
> - The benefit is that an agent can see the screenshot that explains
the task.
## Linked Issues or Issue Description
**What happened?**
A user created a task with the description "This list should probably be
sorted alphabetically" and pasted a screenshot of the list. A Claude
agent on a native sandbox replied that it could not open the screenshot
and asked which list to sort. It found the attachment through the API,
but the run had no staged path and no tool that put the image in its
workspace. When the same image was attached to a comment, the agent
opened it at once.
**Expected behavior**
A native agent can inspect files that are attached to the task
description, the same as files attached to a wake comment.
**Steps to reproduce**
1. Create a task and paste an image into its description.
2. Assign the task to a native `paperclip_runner` agent.
3. Ask the agent what the image shows.
4. The prompt has no "Paperclip native attachment access" entry for the
image, and the agent cannot see it.
**Paperclip version or commit**
`master` at
|
||
|
|
8a5b374a9c |
test: order Antigravity mode changes before admission readback (#23685)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The Runner checks provider settings before it admits an Antigravity swarm. > - A test changes a confirmed mode during admission and expects rejection. > - The fake CLI could complete model readback before it sent the mode change. > - Pipe scheduling could then move the change past admission and fail the test. > - This pull request sends the mode change before model readback. > - The test can now check admission rejection without depending on pipe timing. ## Linked Issues or Issue Description **What happened?** [Cloud readiness run 47231816304, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/47231816304/job/144707142899) failed the Antigravity test named “turns a provider mode change during admission into a typed failure, stops the CLI, and keeps the caller alive”. The open promise resolved instead of rejecting. This cancelled [image run 47231816399](https://github.com/paperclipai/paperclip/actions/runs/47231816399). **Expected behavior** The fixture must deliver the mode change while admission still waits for model readback. The runtime must reject with `ANTIGRAVITY_SWARM_RECEIPT_MISMATCH` and stop its child process. **Steps to reproduce** Run `PAPERCLIP_VITEST_RETRY=0 pnpm exec vitest run src/drivers/acpx/antigravity-swarm-runtime.test.ts --maxWorkers=1` from `packages/paperclip-runner`. Before this change, the `mode-flip` fixture wrote the valid model update before the invalid mode update. Separate pipe reads could let admission finish between them. The CI failure shows this outcome. One focused local baseline attempt passed, so the intermittent failure was not reproduced locally. ## What Changed - Send the `mode-flip` notification before the model configuration update. Admission cannot finish model readback before it receives the invalid mode. - Keep the existing rejection and child retirement assertions. The idle mode-change fixture and runtime code stay as they are. ## Verification - The full Antigravity swarm runtime file passed: 66 tests, retries disabled, one worker. - `node --check packages/paperclip-runner/test-fixtures/antigravity-cli/fake-agy-acp.mjs` passed. - `node scripts/check-test-budget.mjs --base origin/master` passed. - `git diff --check` passed. - `pnpm verify --explain` returned exit 2 because a Runner fixture needs broad CI coverage. Required CI will supply that coverage. - Final head `2c55808f394ad07dc279a6d074fecb9f61fa540f`: [PR CI run 47239627453, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/47239627453/attempts/2) passed. It reports 76 successful jobs and one skipped selection job. Both required gates (`ci / verify` and `ci / e2e`) passed. Standalone Runner image checks, macOS checks, and Windows Rust checks passed. No checks remain active. GitHub reports `CLEAN` and `MERGEABLE`. - Greptile scored this exact head 5/5 with no actionable findings or unresolved review threads. - Earlier failures remain accounted for: [the delayed initial run](https://github.com/paperclipai/paperclip/actions/runs/47239537426) was superseded by the `full-ci` label run and cancelled by PR concurrency. Attempt 1 of the replacement run passed 73 jobs, but [policy](https://github.com/paperclipai/paperclip/actions/runs/47239627453/job/144728063451) exceeded its 10-minute limit. Both final gates then failed with `Policy must succeed`, actual `cancelled`. Policy logs returned `BlobNotFound`, so the stalled step and cause are unknown. After the run completed, GitHub accepted a policy-job rerun request. This reran the reusable CI workflow in attempt 2, which passed in full. The passing retry establishes recovery; it does not establish the timeout's cause. - Separate operational issue: master image runs [47235737261](https://github.com/paperclipai/paperclip/actions/runs/47235737261) and [47238936675](https://github.com/paperclipai/paperclip/actions/runs/47238936675) failed their source observers because GitHub's Actions job-list API returned HTTP 502. Their architecture builds and exact-source readiness runs passed. The current master's job-list request still returns 502 with `per_page=100`. Small pages can read that image run, but a small-page source-readiness request also failed. There is no verified pagination workaround. This fixture change does not resolve that API failure or prove image publication. ## Risks - Low risk. The diff changes one notification's order in a test fixture. It adds no runtime behavior or configuration. - The original intermittent failure was observed in CI. The local baseline attempt passed. The fix removes the ordering gap identified in that failure. The full CI workflow passed for the final revision. - Documentation does not change because the runtime contract stays the same. ## Model Used - OpenAI `gpt-6.1-sol`, through the Codex harness in T3 Code, with xhigh reasoning effort and shell tools. The context window size is not exposed by the runtime. ## 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> |
||
|
|
07150650c9 |
test(runner): drain reattachment writers before deleting state (#23673)
## Thinking Path > - Paperclip manages agent work through durable Runner sessions. > - Release images require Cloud readiness for their exact source commit. > - A reattachment test keeps a slow event backlog active during controller recovery. > - Its bounded close can return before queued journal writes finish. > - The fixture then deletes the state directory and can fail with `ENOTEMPTY`. > - This pull request joins the fixture writers before it removes their files. ## Linked Issues or Issue Description **What happened?** [Docker run 47193580475](https://github.com/paperclipai/paperclip/actions/runs/47193580475/attempts/1) was cancelled after [Cloud readiness protocol lane 4/4](https://github.com/paperclipai/paperclip/actions/runs/47193580507/job/144565884014) failed. The event-backlog reattachment test reported `ENOTEMPTY` while removing its control-plane directory. A rerun passed on the same source commit, without fixing the race. **Expected behavior** The fixture must finish all admitted writes and stop its child before it deletes state, including when the transport close deadline expires. **Steps to reproduce** Run `runnerd-codex-transport-reattach-carried-commands.test.ts` with a one-millisecond close budget for the event-backlog case. Before this fix, the new cleanup assertion finds one accounting callback still active. **Paperclip version or commit** Observed on `23ca89e3764377224bc43527bdfa547e9608f1db`. The fix starts from `7e025ae65f9050030edf4d2cab006aa981569261`. **Deployment mode** Source checkout in GitHub Actions. Local reproduction uses macOS arm64, Node 25.6.1, and the real Rust Runner with the hermetic fake Codex fixture. Searched open PRs and issues for `ENOTEMPTY`, carried commands, and Runner teardown. No duplicate fix was found. Related earlier work: #21161 and #21442. ## What Changed - Retain all registered fixture authorities, including the detached controller. - Disable new upgrades, confirm the original child exited, stop authorities, and drain admitted connection processing before deleting state. - Exercise an expired close budget in the existing backlog case. Assert that accounting writes have finished before deletion. - The fixture owns this cleanup. Runtime close behavior and its deadlines do not change. ## Verification - Red: the focused backlog test fails with `state cleanup must wait for admitted event writes: expected 1 to be +0` before the teardown fix. - Green: `pnpm exec vitest run src/live/runnerd-codex-transport-reattach-carried-commands.test.ts` from the Runner package: 11 passed, retries disabled. - `pnpm exec tsc -p tsconfig.test.json --noEmit` from the Runner package: passed. - `git diff --check` and local secret/PII diff review: passed. - `pnpm verify --explain`: exit 2. The conservative selector cannot resolve this Runner test graph. Focused local checks passed; required PR CI supplies the broader coverage. - Tested file contents match PR head `0a6b92e026ae0fdd684cd0e8e2ff7cf513732a02`. - Final review: all 90 checks are clean, GitHub reports `CLEAN` / `MERGEABLE`, and there are no unresolved review threads. The branch includes current `master`. - An initial local attempt could not run because debug binaries were not built yet. Agent preflight completed before the red-green run. - [Linux Runner Vitest lanes 1–6](https://github.com/paperclipai/paperclip/actions/runs/47222552156): passed on PR head. Typecheck, build, Runner static checks, and support suites also passed. - [Greptile review](https://github.com/paperclipai/paperclip/pull/23673#issuecomment-7394943956): 5/5 on PR head, no actionable findings or review threads. The current-head check passed. - [Server shard 14/20](https://github.com/paperclipai/paperclip/actions/runs/47222552156/job/144668670033) was cancelled after its runner received a shutdown signal. This is recorded runner loss, not an assertion failure. The repository started attempt 2 automatically on the same PR head. The retry passed and the full [PR CI workflow](https://github.com/paperclipai/paperclip/actions/runs/47222552156/attempts/2) completed successfully. Both Runner image builds, the macOS runtime build, and all security scans also passed. ## Risks Low risk. Only one test fixture changes. Teardown now waits for its admitted writes instead of deleting their directory early. A stuck write can fail the existing test timeout and preserve the state directory. No schema, API, deployment, or runtime behavior changes. The code and regression test describe the behavior; no documentation update is needed. ## Model Used OpenAI `gpt-6.1-sol` through the Codex harness in T3 Code, with xhigh reasoning effort, shell and file 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> |
||
|
|
0208bbfbf7 |
fix(runner): compact Antigravity MCP tool descriptions and nullable/pattern schemas (#23645)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip Runner exposes Paperclip semantic tools and lifecycle tools (`paperclip_finish`, `paperclip_block`) to the Antigravity CLI (`agy` 1.5.19) over a loopback MCP bridge. > - Follow-up to #23620: real-binary reproduction with `agy` 1.5.19 against a full server catalog (85-91 tools including `runner-bridge-tools`) shows that `agy` budgets full `functionDeclarations` (name + description + inputSchema) at roughly 90 KB serialized (~60 KB raw MCP JSON). > - With only `inputSchema` metadata stripped, uncompacted multi-sentence tool `description` fields still consume ~26 KB and `pattern`/`format`/nullable unions add ~7 KB, pushing 91 tools to 65.5 KB raw and causing `agy` to drop `handoff_case` and `paperclip_finish` (and `set_task_monitor` / `call_api` when additional tools are present). > - This pull request compacts top-level tool descriptions (first sentence / 120 chars), strips `format` and `pattern`, and collapses nullable `anyOf`/`oneOf`/`type` unions in `tools/list` when `compactToolSchemas` is enabled for Antigravity, while keeping full original Ajv validation on `tools/call`. > - The benefit is that all 110/110 tools (including `paperclip_finish`, `paperclip_block`, `set_task_monitor`, `call_api`, and `handoff_case`) fit comfortably within `agy` 1.5.19's declaration budget. ## Linked Issues or Issue Description - Refs #23620 ## What Changed - `packages/paperclip-runner/src/drivers/re2-schema-patterns.ts`: - Added `compactToolDescription(description, maxLength = 120)` to trim top-level MCP tool descriptions to their first sentence (or <= 120 chars). - Extended `compactToolInputSchema` to drop `format` and `pattern` keywords and collapse nullable `anyOf`/`oneOf` (`[T, { type: "null" }]` -> `T`) and `type: [T, "null"]` -> `T`, while preserving property names, literal `enum`/`const` values, types, and `required` lists. - `packages/paperclip-runner/src/drivers/runner-tool-bridge.ts`: - Applied `compactToolDescription` alongside `compactToolInputSchema` to all `tools/list` entries (including `paperclip_finish` and `paperclip_block`) when `compactToolSchemas: true`. - Original full Ajv validators remain untouched for `tools/call`. - `packages/paperclip-runner/src/drivers/re2-schema-patterns.test.ts`: - Tightened the catalog budget regression test (`totalSchemaBytes < 25_000`, `totalDeclarationBytes < 35_000`, every description <= 120 chars, `paperclip_finish` / `paperclip_block` < 3,000 bytes). - Added regression assertions that `tools/call` still enforces stripped `pattern` rules (`read_document` rejecting `"notes.md"`), `re2PortableSchema` rewrites patterns inside properties named `enum`/`const`, and `compactToolDescription` / nullable union collapsing work as expected. ## Verification - `pnpm --dir packages/paperclip-runner exec vitest run src/drivers/re2-schema-patterns.test.ts src/drivers/runner-tool-bridge.test.ts src/drivers/acpx/antigravity-acp-runtime.test.ts` — 59/59 tests pass. - `pnpm --dir packages/paperclip-runner exec tsc -p tsconfig.json --noEmit` — passes. - `pnpm --dir packages/paperclip-runner exec tsc -p tsconfig.test.json --noEmit` — passes. - Real pinned `agy` 1.5.19 binary probe against a local mock Gemini API with 110 tools (full 64 semantic action catalog + server `runnerBridgeDefinitions` + 31 realistic extra tools + `paperclip_finish` + `paperclip_block`): **110/110 tools kept** (`keptDeclBytes: 85,286`; `paperclip_finish`, `paperclip_block`, `set_task_monitor`, `call_api`, and `handoff_case` all present). ## Risks - Low risk. Compaction applies only to `tools/list` when `compactToolSchemas: true` (Antigravity sessions only). All `tools/call` requests continue to validate against the original full Ajv schema and return plain-English schema rule diagnostics on rejection. ## Model Used - Google Gemini (Antigravity agent with tool use, shell execution, and real `agy` 1.5.19 binary 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 |
||
|
|
5f7670739d |
fix(runner): compact Antigravity MCP tool schemas so lifecycle tools stay within agy budget (#23620)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Paperclip Runner exposes Paperclip's semantic tools (`paperclip_finish`, `paperclip_block`, `set_task_monitor`, `report_progress`, `call_api`, etc.) to Google Antigravity (`agy` 1.5.19) over a loopback HTTP MCP bridge (`startRunnerToolBridge`) > - `agy` 1.5.19 packs MCP `functionDeclarations` smallest-first under a ~40 KB total schema budget and silently drops tools that exceed it instead of making them lazy-loaded > - Because the full Paperclip semantic action catalog plus reserved lifecycle tools exceeds 61 KB of JSON Schema, `agy` 1.5.19 evicted the largest tools first — starting with `paperclip_finish` (5.6 KB) and `paperclip_block` (5.0 KB), and on larger catalogs also `call_api`, `report_progress`, and `set_task_monitor` — causing ordinary Antigravity runs to finish work without being able to finalize and fail with `native_finalization_missing` > - This pull request adds `compactToolInputSchema()` and a `compactToolSchemas` option on `startRunnerToolBridge` (enabled for Antigravity in `AcpxRuntimeHost`) to strip verbose schema-level metadata from `tools/list` while keeping full original Ajv validation on every `tools/call` > - The benefit is that total schema size drops by more than half (~61 KB to ~28 KB), so all Paperclip MCP lifecycle tools stay declared in `agy` 1.5.19 with full server-side validation intact ## Linked Issues or Issue Description Refs #23168, #23536 **What happened?** Ordinary Google Antigravity runs on `agy` 1.5.19 started cleanly and executed shell/read tools (`get_task_context`, `get_identity`, `run_command`), but could not call `paperclip_finish`, `paperclip_block`, `set_task_monitor`, `report_progress`, or `call_api` because `agy` 1.5.19 silently evicted the largest MCP tool schemas from `functionDeclarations` once the server's total schema size exceeded its ~40 KB budget. Runs then ended with `native_finalization_missing: session returned no semantic result`. **Expected behavior** All Paperclip MCP lifecycle tools (`paperclip_finish`, `paperclip_block`, `set_task_monitor`, `report_progress`, `call_api`, `create_task`, etc.) remain declared in `agy` 1.5.19 `functionDeclarations` even when the full semantic action catalog and assigned tools are served, while `tools/call` continues enforcing every original JSON Schema constraint. **Steps to reproduce** 1. Start `startRunnerToolBridge` with `PAPERCLIP_SEMANTIC_ACTION_CATALOG` (`schemaPatternDialect: "re2"` without `compactToolSchemas`). 2. Connect `agy` 1.5.19 `acp` to the bridge via `session/new` `mcpServers` and inspect the outgoing `functionDeclarations` on `session/prompt`. 3. Observe `agy` 1.5.19 keeps only 60 of 66 tools and silently drops the 6 largest (`paperclip_finish`, `paperclip_block`, `handoff_case`, `create_task`, `create_case`, `create_responsibility`). **Paperclip version or commit** `master` (after #23168 / #23536) **Deployment mode** Self-hosted server ## What Changed - Add `compactToolInputSchema()` in `packages/paperclip-runner/src/drivers/re2-schema-patterns.ts` to strip schema-level metadata (`description`, `title`, `$schema`, `$id`, `examples`, `default`, `minLength`, `maxLength`, `minItems`, `maxItems`, `minimum`, `maximum`, and `additionalProperties: false`) while preserving all property keys inside `properties` / `patternProperties` / `$defs` / `definitions` (including properties named `description` or `title`), types, enums, and `required` lists. - Add `compactToolSchemas?: boolean` to `RunnerToolBridgeOptions` in `packages/paperclip-runner/src/drivers/runner-tool-bridge.ts`, applied only to `tools/list` output after compiling the full original Ajv validators. - Enable `compactToolSchemas: true` for `options.agent === "antigravity"` in `packages/paperclip-runner/src/drivers/acpx/runtime-host.ts`. - Add red-green regression tests in `packages/paperclip-runner/src/drivers/re2-schema-patterns.test.ts` and `packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.test.ts`. ## Verification - **Red (before fix)**: New regression test in `re2-schema-patterns.test.ts` failed with `expected 61366 to be less than 35000`; real `agy` 1.5.19 binary probe dropped `paperclip_finish`, `paperclip_block`, `handoff_case`, `create_task`, `create_case`, and `create_responsibility` (60/66 kept). - **Green (after fix)**: - `pnpm --dir packages/paperclip-runner exec vitest run src/drivers/re2-schema-patterns.test.ts src/drivers/runner-tool-bridge.test.ts src/drivers/acpx/antigravity-acp-runtime.test.ts` — **3 files, 58 tests passed** - `pnpm --dir packages/paperclip-runner exec tsc -p tsconfig.json --noEmit && pnpm --dir packages/paperclip-runner exec tsc -p tsconfig.test.json --noEmit` — **passed** - Real `agy` 1.5.19 binary probe with 80 tools (`PAPERCLIP_SEMANTIC_ACTION_CATALOG` + 14 extra tools + `paperclip_finish` + `paperclip_block`): **80/80 tools kept** in `functionDeclarations` (including `paperclip_finish`, `paperclip_block`, `set_task_monitor`, `report_progress`, `call_api`, `create_task`). ## Risks - Low risk. Scoped strictly to `options.agent === "antigravity"` (`compactToolSchemas: true`), and every `tools/call` invocation is still validated against the original uncompacted Ajv schema with plain-language error messages (`toolInputError`). ## Model Used - Google Gemini 4 Neon (Medium) via Antigravity agent with tool use 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 - [ ] 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> |
||
|
|
b0f682b66b | Measure when users see a reply to their onboarding chat input (#23574) | ||
|
|
6e340a3f96 |
Verify onboarding models and explain provider failures (#23563)
Verify deployment-configured model preferences with the selected account. Preserve structured provider failures and show descriptive messages for known causes through the existing onboarding error display. Keep the existing failure buttons, account binding, and retry/sign-in behavior. Validation: UI typecheck, 38 focused tests, four browser journeys, all applicable CI checks, and Greptile 5/5 with no unresolved review comments. Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|
|
cc2e1d9d43 |
Honor plugin task driver concurrency defaults on hire (#23535)
## Thinking Path > - Paperclip schedules work for agents. > - Each agent has a limit on simultaneous runs. > - A task driver can provide an execution environment with its own capacity. > - Previously the creation form sent the same limit for every driver. > - A driver can now declare the value Core saves when a new agent has no explicit limit. ## Linked Issues or Issue Description **Subsystem affected** Agent hiring and plugin environment drivers. **Current behavior** The create form, API, and import flow supply the global concurrency default before the task driver can provide one. **Proposed behavior** Let each task driver declare an optional per-agent concurrency default. Apply it once during hire and honor explicit agent limits. ## What Changed - Refreshed the three SDK source pins for the changed files. - Added the optional driver field `defaultMaxConcurrentRuns` with integer bounds from 1 through 50. - Applied it during hire using the resolved task environment. Saved the resolved runtime configuration in hire approvals. - Removed early defaults from the creation form, routes and new-agent imports. Preserved saved limits on export, including explicit values equal to the global default. Kept the current limit when importing an update with an omitted limit. ## Verification - [Full PR CI](https://github.com/paperclipai/paperclip/actions/runs/47000023360) passed on `83cce42b9a`. Server shard 16 passed on retry after a PostgreSQL connection reset on the first attempt. - `pnpm -r typecheck` passed. The SDK source pin check passed. `pnpm verify` selected broad CI coverage because the SDK input registry changed. - On rebased commit `83cce42b9a`, all 441 tests in six focused Vitest suites passed, including the MCP rollback test corrected in #23560. The SDK source pin check passed. ## Risks This affects new hires on drivers that opt in. Existing agents retain their saved configuration. Single-run provider limits still apply. An older client that explicitly sends the global default will keep that value. ## Model Used OpenAI GPT-6 via Codex. Used local source inspection, code editing, TypeScript 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> |
||
|
|
85b9586dd5 |
fix(cloud-trial): transfer OpenRouter starter proxy credentials to remote plugin Runners (#23559)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Cloud starter-inference onboarding (`free_inference_1`) runs the first OpenCode agent inside a remote plugin Runner environment using a per-run server proxy (`PAPERCLIP_OPENROUTER_PROXY_URL` and `PAPERCLIP_OPENROUTER_PROXY_TOKEN`) instead of exposing the raw OpenRouter key. > - On remote plugin Runner environments, OpenCode runs failed immediately with OpenRouter HTTP 401 (`No cookie auth credentials found`) because the proxy URL and token never reached the sandbox. > - Three boundaries stripped the proxy credentials: `preparePluginRunnerCredentials` returned early when `managedAiCredentialIdentity` was absent, `ENVIRONMENT_TASK_PROVIDER_CREDENTIAL_KEY_SETS.opencode` did not allow the proxy pair, and Rust `OPENCODE_PROVIDER_ENVIRONMENT_KEYS` in `codex_provider.rs` did not forward those keys. > - This pull request adds the `[PAPERCLIP_OPENROUTER_PROXY_URL, PAPERCLIP_OPENROUTER_PROXY_TOKEN]` pair across all three boundaries while keeping raw starter keys strictly server-side and failing closed on partial or ambiguous credentials. > - The benefit is that Cloud starter-inference OpenCode runs authenticate cleanly through the server proxy inside remote plugin Runner sandboxes. ## Linked Issues or Issue Description Refs #23401, #23427 **Summary** Transfer `PAPERCLIP_OPENROUTER_PROXY_URL` and `PAPERCLIP_OPENROUTER_PROXY_TOKEN` through the plugin Runner credential boundary and Rust `runner-core` allowlist for Cloud starter-inference OpenCode runs. **Steps to Reproduce** 1. Create a Cloud starter-inference (`free_inference_1`) workspace running OpenCode in a remote plugin Runner environment. 2. Send a message in the onboarding chat. 3. Observe `APIError` HTTP 401 (`No cookie auth credentials found`) from OpenRouter because the sandbox OpenCode proxy received neither `PAPERCLIP_OPENROUTER_PROXY_URL` nor `OPENROUTER_API_KEY`. **Expected Behavior** The remote plugin Runner receives `{ PAPERCLIP_OPENROUTER_PROXY_URL, PAPERCLIP_OPENROUTER_PROXY_TOKEN }` via the `opencode` `provider-env` credential channel, forwards them to OpenCode, and routes inference through the server-side starter proxy. ## What Changed - `packages/plugins/sdk/src/environment-tasks.ts`: Added `["PAPERCLIP_OPENROUTER_PROXY_URL", "PAPERCLIP_OPENROUTER_PROXY_TOKEN"]` to `ENVIRONMENT_TASK_PROVIDER_CREDENTIAL_KEY_SETS.opencode`. - `packages/paperclip-runner/runner/crates/runner-core/src/codex_provider.rs`: Added `"PAPERCLIP_OPENROUTER_PROXY_URL"` and `"PAPERCLIP_OPENROUTER_PROXY_TOKEN"` to `OPENCODE_PROVIDER_ENVIRONMENT_KEYS`. - `server/src/services/native-runtime/plugin-runner-credentials.ts`: Allowed `opencode` runs with both `PAPERCLIP_OPENROUTER_PROXY_URL` and `PAPERCLIP_OPENROUTER_PROXY_TOKEN` to transfer that `provider-env` credential when `identity` is absent (using `"cloud-trial"` as `accountIdentity`). - `server/src/services/native-runtime/plugin-runner-credentials.test.ts`: Added regression coverage for transferring the Cloud starter proxy pair without a managed AI connection identity and failing closed on partial or ambiguous combinations. - `tests/runner-e2e/source-sdk-public-inputs.json`: Updated reviewed SDK public inputs pin for `packages/plugins/sdk/src/environment-tasks.ts`. ## Verification - `pnpm --filter @paperclipai/plugin-sdk build` — passed. - `pnpm --filter @paperclipai/plugin-sdk exec vitest run tests/environment-tasks.test.ts tests/environment-task-release-resume.test.ts` — passed (104/104 tests). - `pnpm --filter @paperclipai/server exec vitest run src/services/native-runtime/plugin-runner-credentials.test.ts src/__tests__/plugin-runner-credential-names.test.ts` — passed (45/45 tests, verifying SDK allowlist, Runner TS allowlist, and Rust `codex_provider.rs` allowlist together). ## Risks - Low risk. Only the ephemeral per-run proxy URL and `pctrial_` token pair is allowed when both are present and non-empty; partial or mixed sets still fail closed in `environmentTaskCredentialSchema`, and raw OpenRouter keys never leave the server process. ## Model Used - Google Gemini (Antigravity agentic runtime, thinking mode with tool use 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 - [ ] 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 |
||
|
|
86927d4933 |
feat(cloud-trial): enable fast responses by default with starter inference key (#23556)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Fast responses send a brief acknowledgement in the agent's voice while the full agent run starts. > - During Cloud starter-inference onboarding (`free_inference_1`), users start chatting immediately before connecting their own model provider, so no `company_fast_responses` connection exists yet. > - Without a default fast-response path, the first chat waits silently while the Runner starts up and thinks. > - This pull request enables fast responses by default while Cloud starter inference is active, routing acknowledgements through the server-held OpenRouter starter key with `$1` quota and `llmBlocked` gate enforcement. > - The benefit is immediate, responsive first-chat acknowledgements out of the box with a clean handoff once the user connects their own model provider. ## Linked Issues or Issue Description Refs #23401, #23427 **Summary** Enable fast-response acknowledgements by default for companies running on active Cloud starter inference (`free_inference_1`), using the existing server-side OpenRouter starter inference key. **Problem Statement** Fast responses currently require both the experimental `enableFastResponses` instance flag and an explicit shared API connection in `company_fast_responses`. New Cloud starter-inference workspaces have no saved API connection yet, so users do not get fast acknowledgements during their initial onboarding chat. **Proposed Solution** Fall back to the server-side Cloud starter inference OpenRouter key (`FAST_RESPONSE_DEFAULT_MODEL`, `openai/gpt-oss-120b`) when a company has no `company_fast_responses` row and is actively on trial-only inference without a blocked gate. Respect explicit company configuration/opt-out, enforce `responsibleUserId` and `issue:read` authorization, disallow sponsored webhooks on the starter key, mark the trial exhausted on HTTP 402/limit errors, and stop using the starter key automatically once the user connects their own model provider. ## What Changed - `server/src/services/cloud-trial-proxy.ts` & `server/src/services/cloud-trial-inference.ts`: Added `isCloudTrialFastResponseEligible` and `prepareCloudTrialFastResponse`. Keeps the raw OpenRouter key strictly in server process memory, enforces `isCompanyOnTrialOnlyInference`, the `$1` quota, and the `work_requires_model` / `exhausted` gates, wraps `fetch` to call `markExhausted` immediately on HTTP 402/limit responses, and probes usage on cleanup. - `server/src/services/fast-responses.ts`: Updated `enqueueFastResponse`, `fastResponseSourceCurrent`, `settings`, `availability`, `resolve`, `process`, and `history` to use Cloud starter inference by default when no `company_fast_responses` row exists and starter inference is active and unblocked. Explicit `company_fast_responses` rows (including opt-out `enabled: false`) always take precedence, and connecting a user model provider cleanly ends starter-key usage. - `packages/shared/src/fast-response.ts`: Added optional `usingCloudTrialDefault?: boolean` to `FastResponseSettings`. - `server/src/__tests__/fast-responses.test.ts`: Added regression tests covering starter-inference default fast responses (even when `enableFastResponses` is `false`), raw key non-leakage, `work_requires_model` gate blocking, HTTP 402 exhaustion, explicit opt-out, and clean handoff after connecting a user model provider. ## Verification - `pnpm --filter @paperclipai/shared typecheck` — passed (0 errors). - `pnpm --filter @paperclipai/server typecheck` — passed (0 errors). - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/fast-responses.test.ts src/__tests__/cloud-trial-inference.test.ts` — passed (44/44 tests). ## Risks - Low risk. No database schema migration is required (`fast_response_requests.connection_id` and `grant_id` are already nullable). Self-hosted instances and `baseline` Cloud stacks are unaffected because `trialInferenceEnabled` is `false`. Companies that explicitly configure or disable `company_fast_responses` or connect their own AI provider never fall back to the starter key. ## Model Used - Google Gemini (Antigravity agentic runtime, thinking mode with tool use 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 - [ ] 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 |
||
|
|
0352347937 |
refactor(runner): remove unreferenced profile identity fixtures under test/fixtures (#23356)
Co-Authored-By: Paperclip <Paperclip-Paperclip@users.noreply.github.com> |
||
|
|
89c6e38ad1 |
Hide refresh for static Claude catalogs in Cloud agent settings (#23544)
Expose catalog refresh capability to the Cloud Claude picker. Preserve routed and account-bound model discovery. Co-Authored-By: Scott Tong <scott@scotts-mbp-m5-max.local> |
||
|
|
f5f47b1ec4 |
fix(runner): omit provider mode from ordinary Antigravity ACP runtime identity (#23536)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Paperclip Runner executes Google Antigravity agents through `AcpxRuntimeHost` and the unified `agy acp` 1.5.19 runtime (`openAntigravityAcpRuntime`) > - After #23168 moved ordinary Antigravity turns onto `openAntigravityAcpRuntime`, its `identity()` method hardcoded `mode: "persistent"`, confusing ACPX session persistence with `AcpxRuntimePortIdentity.mode` (the optional provider mode) > - Ordinary Antigravity turns resolve `binding.mode` to `undefined`, so `AcpxRuntimeHost.open()` rejected every ordinary Antigravity run during identity admission with `ACPX_ADMISSION_IDENTITY` (`ACPX runtime Provider mode does not match the admitted session configuration`) > - This pull request omits `mode` from `openAntigravityAcpRuntime`'s `identity()`, rejects unexpected provider modes passed directly to `openAntigravityAcpRuntime`, and adds an `AcpxRuntimeHost.open()` fresh-open and session-resume regression test > - The benefit is that ordinary Google Antigravity runs pass admission and resume cleanly on both local and remote runners ## Linked Issues or Issue Description Refs #23168 **What happened?** Every ordinary (non-`/swarm`) Google Antigravity run failed during `session.open` admission with `ACPX_ADMISSION_IDENTITY`: `ACPX runtime Provider mode does not match the admitted session configuration`. `openAntigravityAcpRuntime` returned `mode: "persistent"` from `identity()`, while `AcpxRuntimeHost.open()` bound `binding.mode` to `undefined` via `resolveAcpxProviderMode("antigravity", undefined)`. **Expected behavior** Ordinary Antigravity runs omit `mode` (`undefined`) in `AcpxRuntimePortIdentity`, matching `binding.mode` during both initial `AcpxRuntimeHost.open()` admission and subsequent `expectedIdentity` session resume. Only trusted `/swarm` turns (served by `openAntigravitySwarmRuntime`) carry `mode: "swarm"`. **Steps to reproduce** 1. Open an ordinary Antigravity session (`mode: undefined`) through `AcpxRuntimeHost.open()` backed by `openAntigravityAcpRuntime`. 2. Observe `AcpxRuntimeHost.open()` throw `ACPX runtime Provider mode does not match the admitted session configuration` at `runtime-host.ts` during identity verification. **Paperclip version or commit** `4db307d53c` (`master`, regression introduced in `3df59a1853` / #23168) **Deployment mode** Self-hosted server ## What Changed - Remove hardcoded `mode: "persistent"` from `openAntigravityAcpRuntime`'s `identity()` return value in `packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.ts` so `runtimeIdentity.mode` is `undefined` and matches `binding.mode` for ordinary turns. - Fail closed in `openAntigravityAcpRuntime` if a caller passes a non-`undefined` `options.mode`. - Add red-green regression tests in `packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.test.ts` covering `AcpxRuntimeHost.open()` admission, `expectedIdentity` session resume, and direct non-empty `mode` rejection. - Update the ordinary-route identity expectation in `packages/paperclip-runner/src/drivers/acpx/antigravity-swarm-route.test.ts` from `mode: "persistent"` to `mode: undefined`. ## Verification - Reproduced the exact failure before the fix: `AcpxRuntimeHost.open()` threw `ACPX runtime Provider mode does not match the admitted session configuration` on the new regression test in `packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.test.ts`. - Verified green after the fix: - `pnpm --dir packages/paperclip-runner exec vitest run src/drivers/acpx/antigravity-acp-runtime.test.ts src/drivers/acpx/antigravity-swarm-route.test.ts src/drivers/acpx/antigravity-admission.test.ts src/drivers/acpx/antigravity-acpx-runtime.test.ts src/drivers/acpx/antigravity-credentials.test.ts src/drivers/acpx/antigravity-swarm-guard.test.ts src/cli/acpx-runtime-sidecar.test.ts` (7 test files, 244 tests passed) - `pnpm --dir packages/paperclip-runner exec vitest run src/drivers/acpx/antigravity-swarm-runtime.test.ts src/drivers/acpx/runtime-host.test.ts` (157 tests passed) - `pnpm --dir packages/paperclip-runner typecheck` (TypeScript + Rust checks passed) - Live remote staging execution requires deploying this fix; local verification exercised the real `AcpxRuntimeHost` admission, binding, and resume boundary with the ordinary Antigravity ACP fixture. ## Risks - Low risk. The change aligns `openAntigravityAcpRuntime`'s reported identity with `AcpxRuntimeHost`'s existing provider-mode contract (`acpx-runtime-adapter.ts` already omits `mode` when no provider mode is active). `/swarm` turns still route through `openAntigravitySwarmRuntime` and report `mode: "swarm"`. ## Model Used - Google Gemini 4 Neon (Medium) via Antigravity agent with tool use 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 - [ ] 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> |
||
|
|
51cb918a03 |
fix(opencode): stop OpenCode from running npm inside opencode serve at startup (#23512)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - The native Runner starts `opencode serve` (pinned to 1.18.34) for
each OpenCode turn, with its own fresh config directory and a fresh
isolated `HOME`.
> - #23372, #23391 and #23428 showed that the kernel OOM killer stops
`opencode serve` at the 8 GiB sandbox limit about 50 seconds into light
turns. The memory is OpenCode's own resident set. The model traffic is
small and complete when OpenCode dies.
> - A local reproduction finds the cause. On every project bootstrap,
OpenCode installs `@opencode-ai/plugin` into its global config directory
with npm's Arborist. The install runs inside the `opencode serve`
process. It downloads about 114 MB into a fresh npm cache and keeps the
JavaScript event loop busy while it allocates. OpenCode stops answering
HTTP, emits no events, and does not send the next model request.
> - OpenCode skips this install when the directory has `node_modules`
and a `package-lock.json` that lists the dependency. Today only launches
with configured secrets write that marker, as part of output custody.
> - This pull request writes the marker for every launch.
> - The benefit is that OpenCode no longer runs npm at startup, so it
stays responsive and its memory stays flat.
## Linked Issues or Issue Description
Refs #23372 (kernel OOM evidence). Refs #23391 (memory attribution).
Refs #23428 (model traffic counts).
**What happened?**
Native OpenCode turns on cloud sandboxes fail with
`opencode_server_exited` and SIGKILL. The failure record shows
`memoryKill: observed`, an OpenCode resident set of about 8 GB at the 8
GiB limit, and one or two small, completed model responses. The run log
stops for about 42 to 48 seconds before the kill. The failures happen
with and without tool calls. Agents with configured secrets are not
affected, because output custody already writes the install marker.
**Expected behavior**
`opencode serve` stays responsive after startup. It does not download or
install packages, and its memory does not grow while it waits for a
model or a tool.
**Steps to reproduce**
1. Start `opencode serve` 1.18.34 with an empty
`$XDG_CONFIG_HOME/opencode` that has only `opencode.json`, and an empty
`HOME`, as the Runner does for an agent without configured secrets.
2. Send one request, for example `GET /config`, so that OpenCode
bootstraps the project.
3. Within about 8 seconds, OpenCode uses 100 to 150% CPU on its
JavaScript main thread. It stops answering HTTP (`GET /config` times
out), and its memory grows. `$XDG_CONFIG_HOME/opencode/node_modules` and
`$HOME/.npm/_cacache` fill with `effect`, `zod`, `yaml`, `@ai-sdk/*` and
other packages.
**Paperclip version or commit**
`master` at
|
||
|
|
725a9e36b6 |
fix(connections): let a dedicated account serve every agent picked for its connection (#23431)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - A GitHub connection can use "A dedicated account for an agent", for
example a bot account that an agent uses instead of the person who gives
instructions
> - The account lives on the grant of the agent that signed in. Core
gives one connection to one signed-in agent
> - A team often wants several agents to use the same bot account, or to
move a bot account to a new agent. Today each agent needs its own GitHub
sign-in as the bot
> - The permissions page also lets an owner pick more agents for the
connection, which looks like sharing but gives those agents nothing
> - Sharing a credential must stay under the owner's control: an install
of a connection needs only `agents:configure`, which agents and
operators have, so installs cannot be the share signal
> - This pull request adds an explicit share list for a dedicated
account. Only the person who connected the account, a company owner or
admin, or an instance admin can change it
> - The benefit is that a bot account can serve several agents without a
new sign-in, and no one else can attach the account to their agents
## Linked Issues or Issue Description
No public issue exists.
**What happened?**
A GitHub connection with a dedicated account was signed in for agent A.
The owner then picked agent B for the same connection on the permissions
page. The page showed "Used only by A" and also "2 agents selected" with
A and B. Agent B made no GitHub tool calls through the connection, and
its git work used the responsible person's GitHub account. There was no
way to let agent B use the bot account without a second GitHub sign-in
as the bot.
**Expected behavior**
The owner of a dedicated account can share it with chosen agents, and
those agents use it for managed git and the connection's tools. No one
else can share it.
**Steps to reproduce**
1. Add a GitHub connection with "A dedicated account for an agent" and
pick agent A.
2. On the connection's permissions page, pick agent B too.
3. Start a run for agent B that pushes with git. See that it uses the
responsible person's account, and that the page offers no way to share
the bot account.
**Paperclip version or commit**
`master` at
|
||
|
|
9092b0c667 |
Support live Antigravity credential writeback for both token stores (#23397)
## Thinking Path > - Paperclip manages the connections agents use to work. > - A run can outlive the Google refresh token that started it. > - Antigravity writes a rotated token to a private file. Its two runtimes use different paths and JSON layouts. > - The task already records which connection supplied its sign-in. > - Runner reports a rotation on PRP. Core saves it to that connection if the saved generation still matches. > - The next run can start with the rotated token. ## Linked Issues or Issue Description Refs #23395. Refs #23168. This PR targets `master` and includes the capability-based handler from #23395. Merging this PR lands the handler and Antigravity writeback together. **Current behavior** A managed Antigravity sign-in reaches the plugin as an environment credential. Core waits for task retirement to collect a refresh. **Proposed behavior** Seed a private auth-file. Observe refresh-token changes for the ordinary ACP server and the unified CLI. Use the existing credential update event to save them during execution. **Reason and benefit** A long-running task can keep its source connection current across successive rotations. ## What Changed - Dispatch PRP credential updates to the live writeback capability declared for the bound harness and execution target. - Send Antigravity subscriptions as auth-file credentials to environment task providers. Keep Gemini API keys and previously admitted environment credentials on their existing paths. - Watch the ACP token file and the unified CLI token file. Compare the refresh token, copy it to the bound file, and emit the existing secret-free event. - Bind writeback to the original grant, secret, session epoch, and credential generation. Save the next generation in the same transaction. ## Verification - Reproduced the failed final Google save hanging on the next session close. After commit `2b3e7897cd`, both focused cleanup suites passed (43 tests). The regression covers two overlapping close retries after the credential home is released and checks that the saved credential is removed only after persistence succeeds. - All 21 Rust observer tests passed on both builds. They cover interruption between the host file and event journal writes, a further rotation before restart, and a reconnect that supersedes the task. - On the legacy build, 422 Runner TypeScript tests passed. With the merged unified CLI on this branch, all 126 tests in the auth, credential staging, and runtime host suites passed. - The two plugin writeback database suites passed (39 tests). A refresh that starts before task stop cannot overwrite the final token after stop. - One run timed out in an unrelated process-retirement test. All three suites passed together on repeat. All OAuth documents in these tests are fixtures. No live Google sign-in was exercised. ## Risks - The agent and any process it starts are trusted not to substitute another account’s refresh token in the harness credential file. Core accepts the file’s refresh token for the original connection only while the grant, secret, session epoch, and expected credential generation still match. Substitution within that boundary is an accepted risk. [Review finding](https://github.com/paperclipai/paperclip/pull/23397#discussion_r4759261984) - Deploy with a plugin and Launcher that support the new auth-file provider. This branch includes the unified CLI from #23168 and still observes the legacy token format. > 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 GPT-6 in Codex, with local code execution and GitHub CLI. ## 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> |
||
|
|
c47452699a |
perf(server): speed up headless channel posts, replies, and SSE bursts (#23426)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Headless channels, threads, and SSE streams let agents and tools
exchange high-rate status updates and structured messages
> - A local headless benchmark on `origin/master` (`828b8c2a2a`) showed
channel posts at 226 req/s (`c=1`) and 342–346 req/s (`c=32`), with
database tuple scans growing linearly with company issue count and live
SSE streams falling behind under burst
> - CPU, heap, and PostgreSQL profiling traced the bottlenecks to an
unindexed `O(N)` `MAX(issue_number)` scan per post, redundant SQL
round-trips and uncached transactional `instance_settings` reads inside
the company row lock, upfront `FOR UPDATE` locks on normal replies,
serial per-event SSE database checks, and routing through 64 unrelated
Express sub-routers
> - This pull request adds an online-compatible `issues(company_id,
issue_number)` index so `MAX(issue_number)` floor checks run as `O(log
N)` index-only probes inside the `companies` counter update, eliminates
redundant channel/view/savepoint queries, locks parent issues on replies
only when `clientRequestId` or `after` is supplied, mounts headless
routers early, and extracts a unified bounded SSE/replay filter pipeline
with creation-time `kvLabels`/`tagLabels` snapshots and pre-change label
history lookup
> - The benefit is 2.09x to 2.67x higher channel post throughput (473
req/s at `c=1`, 885–924 req/s at `c=32`), 1.75x higher reply throughput
(1,221 req/s at `c=32`), 55.5% less heap allocation, `O(log N)`
index-only counter floor checks as issue count grows, and 100% real-time
SSE delivery under burst
## Linked Issues or Issue Description
**What existing behavior does this improve?**
`POST /api/companies/:companyId/channels/posts`, `POST
/api/companies/:companyId/issues/batch`, `POST
/api/issues/:id/comments`, and `GET
/api/companies/:companyId/events/stream` throughput, tail latency, heap
allocation, and database scalability.
**Subsystem affected**
- `packages/db/ — Drizzle schema & migrations`
- `server/ — REST API & orchestration services`
**Current behavior**
On `origin/master` (`828b8c2a2a`, Node `v26.4.0`, `darwin-arm64`, local
`embedded-postgres` with 2 live SSE subscribers):
- `createChannelPost` and `createBatchIssuesPlan` run `SELECT
coalesce(max(issue_number), 0) FROM issues WHERE company_id = $1` on
every call without an index on `(company_id, issue_number)`, scanning
every issue row in the company (`2,029` tuples/request at ~2,400
issues).
- `ensureChannel` ignores the channel row already fetched by
`assertChannelPathWritePreconditions`, runs `INSERT ... ON CONFLICT DO
NOTHING`, and selects the channel a second time.
- `createChannelPost` holds the `companies` row lock while calling
`logActivity(tx, ...)` (which skips the `instance_settings` read-through
cache on `PgTransaction` handles and opens a nested `SAVEPOINT` +
`SELECT pg_current_xact_id()`), running two round-trips in
`appendBoardEvent`, and re-querying four tables in
`loadHeadlessIssueView`.
- `POST /api/issues/:id/comments` selects all 89 `issues` columns via an
unindexed `upper(identifier)` scan when given an identifier and
unconditionally acquires `SELECT ... FOR UPDATE` on `issues` even when
neither `idempotencyKey`/`clientRequestId` nor `after` is supplied.
- `GET /api/companies/:companyId/events/stream` evaluates live events
one at a time with serial `channels` and `issues` queries per event per
subscriber and misses creation-time `labels`/`tagLabels` snapshots
during `?label=` filtering, delivering only ~302–373 of 1,000 events
during a 1,000-message burst.
- `headlessChannelsSchemasRoutes` and `headlessQueuesEventsRoutes` sit
behind 64 unrelated `api.use(...)` Express sub-routers (`15%` CPU in
`path-to-regexp` and `router`).
**Proposed behavior**
- Add an online-compatible `CREATE INDEX CONCURRENTLY IF NOT EXISTS
"issues_company_issue_number_idx" ON "issues" USING btree ("company_id",
"issue_number")` migration (`0513_closed_wither.sql`) and compute
`greatest(companies.issue_counter, coalesce((select
max(issues.issue_number) from issues where issues.company_id = $1), 0))
+ count` directly in `UPDATE companies`, preserving exact monotonic
counter floors (including lone backdated imports) via an `O(log N)`
index-only backward probe in a single round-trip.
- Return the existing channel directly in `ensureChannel` when
`allowUpdateExisting` is false, serialize newly created
`HeadlessIssueView` objects in memory, sort tag labels canonically
before `ON CONFLICT DO NOTHING` upserts, and combine
`pg_advisory_xact_lock` + `INSERT INTO board_events` into one SQL
statement.
- Pre-create `createActivityDetailsRedactor(db)` before transactions so
the 2-second `instance_settings` cache applies, prime
`pg_current_xact_id()` on existing `RETURNING` clauses, and skip nested
`db.transaction` savepoints in `persistActivity` when `db` is already a
`PgTransaction` while preserving `databaseWorkContext` attribution.
- Probe `eq(issues.identifier, normalizedUpper)` first so identifier
lookups use `issues_identifier_idx`, project only the 11 required
columns in issue route interceptors, narrow `--as` profile collision
checks to non-terminated company agents with JS `.trim()` +
`deriveAgentUrlKey` parity, and acquire `FOR UPDATE` on comment creation
only when `clientRequestId` or `after` is present.
- Extract `server/src/services/headless-board-event-stream.ts` and stamp
commit-time `kvLabels` and `tagLabels` snapshots onto issue-scoped event
payloads inside `appendBoardEvent`, so `queryBoardEventsAfter`,
`waitForBoardEvent`, and `filterBoardEventsBatchForSubscriber` share a
single stateless `eventMatchesFiltersAndAccess` verdict pipeline without
cross-batch label caches.
- Mount `headlessChannelsSchemasRoutes` and `headlessQueuesEventsRoutes`
right after `headlessIdentityRoutes` with `headlessHeartbeat` wired in
`server/src/app.ts`.
**Measured performance impact**
- `POST /channels/posts` (`c=1`): `226.4` -> `473.1 req/s` (`2.09x`),
p50 `4.27ms` -> `2.05ms`, p99 `6.98ms` -> `3.15ms`
- `POST /channels/posts` (`c=32`, single channel): `346.4` -> `885.5
req/s` (`2.56x`), p50 `91.8ms` -> `35.4ms`
- `POST /channels/posts` (`c=32`, 16 channels + 2 live SSE clients):
`342.4` -> `924.6 req/s` (`2.70x`), p50 `93.3ms` -> `33.2ms`, live SSE
events delivered during run `302` -> `1,000 / 1,000`
- `POST /issues/:id/comments` (`c=32`): `696.2` -> `1,221.6 req/s`
(`1.75x`), p50 `44.9ms` -> `25.3ms`
- Profiled 1,500 mixed messages (`c=32`): heap allocated `2,369 MB` ->
`1,054 MB` (`-55.5%`).
**Breaking changes**
None. All request/response schemas, status codes, idempotency conflict
rules, `after` stale-cursor checks, gapless `board_events.seq` commit
ordering, and private channel/issue revocation rules remain unchanged.
## What Changed
- Added `issues_company_issue_number_idx` in
`packages/db/src/schema/issues.ts`,
`packages/db/src/migrations/0513_closed_wither.sql` (`CREATE INDEX
CONCURRENTLY IF NOT EXISTS`), and `MIGRATIONS_WITH_TOP_LEVEL_STATEMENTS`
in `packages/db/src/client.ts`.
- Updated `server/src/services/headless-common.ts`,
`server/src/services/headless-channels.ts`, and
`server/src/services/headless-labels-batch.ts` to compute exact indexed
`MAX(issue_number)` counter floors inside `UPDATE companies`, return
existing channels early in `ensureChannel`, prime transaction XIDs, sort
tag label names before upsert, serialize newly created
`HeadlessIssueView` responses in memory, include `kvLabels` and
`tagLabels` snapshots on creation/ready board events, and combine
`pg_advisory_xact_lock` + `INSERT INTO board_events` into a single
round-trip.
- Updated `server/src/services/activity-log.ts` to accept an optional
pre-built `ActivityDetailsRedactor` and skip nested `db.transaction`
savepoints when `persistActivity` runs on an existing `PgTransaction`
while preserving `databaseWorkContext` attribution.
- Updated `server/src/routes/headless-channels-schemas.ts` to use
`resolveIssueCommentTarget`, pre-create the activity redactor on `db`,
prime transaction XIDs on comment inserts, and lock the parent issue
`FOR UPDATE` only when `clientRequestId` or `after` is supplied.
- Extracted `server/src/services/headless-board-event-stream.ts`
(re-exported from
`server/src/services/headless-events-schedules-interactions.ts`) and
updated `server/src/services/headless-common.ts`,
`server/src/routes/headless-queues-events.ts`, and `server/src/app.ts`
to stamp commit-time `kvLabels` and `tagLabels` snapshots in
`appendBoardEvent`, unify single-event, replay, and batched SSE
filtering without cross-batch label caches, and mount headless routers
early with `headlessHeartbeat`.
- Added regression tests in
`server/src/__tests__/headless-channels-schemas-batch.test.ts` (drifted
`issueCounter` + lone backdated `#95` floor, concurrent tag upserts, and
tab/CJK `--as` profile parity) and
`server/src/__tests__/headless-queues-leases-events.test.ts` (live SSE
burst ordering, cold-cache `?label=urgent` `exists` tag +
`labels.changed` interleaving + unlabeled `comment.posted`, and
immediate private-channel revocation).
## Verification
- `pnpm --filter @paperclipai/db run check:migrations && pnpm --filter
@paperclipai/db exec vitest run src/migration-snapshot-drift.test.ts`
(passed, 0 blocked migrations)
- `cd server && node scripts/typecheck-layers.mjs` (0 errors across all
7 layers)
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/activity-log-responsible-user.test.ts
src/__tests__/headless-channels-schemas-batch.test.ts
src/__tests__/headless-queues-leases-events.test.ts
src/__tests__/headless-task-workflows.test.ts
src/__tests__/experimental-channels-viewer.test.ts` (5 files, 41/41
tests passed)
## Risks
- Low risk. Migration `0513_closed_wither.sql` uses `CREATE INDEX
CONCURRENTLY IF NOT EXISTS` and is registered in
`MIGRATIONS_WITH_TOP_LEVEL_STATEMENTS`, so online rollouts do not block
reads or writes on `issues`. Live SSE micro-batching re-evaluates
channel and issue visibility fresh on every drained batch without
cross-batch permission caching, preserving immediate membership
revocation.
## Model Used
- Google Gemini (Antigravity agentic coding assistant, extended thinking
mode with shell, profiling, and test execution 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>
|
||
|
|
64c872e4da |
fix(opencode): record model traffic when opencode serve is OOM-killed (#23428)
## 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 turn and
sends every model request of OpenCode through a local provider proxy.
> - #23372 and #23391 showed that the kernel OOM killer stops `opencode
serve` at the 8 GiB sandbox limit about 50 seconds into light turns, and
that the memory is OpenCode's own resident set (about 7.6 GiB) and
anonymous memory.
> - The retained run log has no raw provider or SSE trace. So we cannot
tell a huge provider response, a loop of model requests, or growth
inside OpenCode on a normal stream from one another.
> - The provider proxy already sees each model request and its response.
It is the cheapest place to measure this.
> - This pull request counts the model traffic in the proxy and reports
the counts when `opencode serve` dies by a signal.
> - The benefit is that the next OOM kill shows which of the three
causes applies, so the fix can target it.
## Linked Issues or Issue Description
Refs #23372 (kernel OOM evidence). Refs #23391 (memory attribution).
**What happened?**
On a cloud sandbox, native OpenCode turns with a fast DeepSeek model
fail with `opencode_server_exited`. The failure record shows
`memoryKill: observed` and `opencodeRssBytes` of about 8.16 GB at the 8
GiB limit. The run log shows no event for about 46 seconds before the
kill. It does not show how much model traffic OpenCode handled in that
time.
**Expected behavior**
When the kernel stops `opencode serve`, the failure record says how many
model requests OpenCode sent, how many bytes the provider returned, and
how large and how old the response was that was still streaming.
**Steps to reproduce**
1. Run a native OpenCode turn through the Runner provider proxy in a
Linux sandbox with a cgroup v2 memory limit.
2. Make the kernel OOM killer stop `opencode serve` while a model
response streams.
3. Read `resultJson.nativeTurnFailure`. Before this change, it has no
model traffic counts.
**Paperclip version or commit**
`master` at
|