paperclip-github-plugin 0.16.1 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/paperclip-github-plugin)](https://www.npmjs.com/package/paperclip-github-plugin)
4
4
  [![CI](https://img.shields.io/github/actions/workflow/status/alvarosanchez/paperclip-github-plugin/ci.yml?branch=main&label=CI)](https://github.com/alvarosanchez/paperclip-github-plugin/actions/workflows/ci.yml)
5
- [![Node >=20](https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&logoColor=white)](https://www.npmjs.com/package/paperclip-github-plugin)
5
+ [![Node >=24.11](https://img.shields.io/badge/node-%3E%3D24.11-339933?logo=node.js&logoColor=white)](https://www.npmjs.com/package/paperclip-github-plugin)
6
6
  [![License: Apache-2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/alvarosanchez/paperclip-github-plugin/blob/main/LICENSE)
7
7
 
8
8
  GitHub Sync is a Paperclip plugin for teams that plan in Paperclip but still receive work through GitHub issues.
@@ -32,7 +32,7 @@ The plugin adds a full in-host workflow instead of a one-off import script:
32
32
  - a dashboard widget that shows sync readiness, current sync status, and run/cancel controls
33
33
  - a separate KPI dashboard widget that tracks GitHub backlog size, GitHub issues closed, and Paperclip pull requests created with recent history and historical comparisons
34
34
  - saved sync diagnostics that let operators inspect the latest per-issue failures, raw errors, and suggested next steps
35
- - a project sidebar item that opens a live project-scoped Pull Requests page for the mapped repository and can show the open PR count through a lightweight badge read
35
+ - a project sidebar item that opens a live project-scoped Pull Requests page for the mapped repository and can show the open PR count through a lightweight badge read (Paperclip `2026.831` hosts do not render it; see the compatibility boundary below)
36
36
  - manual sync actions from global, project, and issue surfaces
37
37
  - a GitHub detail tab on synced Paperclip issues that includes GitHub-marked action buttons plus the GitHub issue creator with avatar, lets operators manually link or unlink a Paperclip issue from a GitHub issue or pull request, and shows compact troubleshooting details if the host cannot provide a resolvable issue context
38
38
  - GitHub link annotations on sync-generated status transition comments when the host supports comment annotations
@@ -89,7 +89,7 @@ The owner is stored on the PR-link entity, so unrelated title/state refreshes, p
89
89
 
90
90
  ### Project pull request command center
91
91
 
92
- Each mapped project can expose a **Pull Requests** entry in the sidebar that opens a live GitHub queue page for that repository. The sidebar badge uses a lightweight total-count read, while the queue keeps the default view fast by loading only the current 10-row page, uses a repo-wide metrics read for the summary cards, reuses that cached metrics scan to keep filtered views fast by fetching only the visible filtered rows, keeps repo-scoped count, metrics, and per-PR review/check insight caches warm for repeat visits, lets operators explicitly bust those caches with Refresh when they want a live reread, shows total, mergeable, reviewable, and failing cards that filter the table, only treats a pull request as mergeable when it targets the current default branch with green checks, at least one approval, no outstanding change requests, and no unresolved review threads, includes an **Up to date** column that distinguishes current branches, clean update candidates, conflict cases, and unknown freshness when GitHub cannot confirm the comparison, shows the PR target branch with a highlighted default-branch badge, keeps the list sorted by most recently updated first, paginates larger repositories, keeps a compact bottom detail pane with markdown-and-HTML-rendered conversation plus an inline comment composer, supports deterministic **Update branch** actions for clean behind-base pull requests, adds Copilot quick actions that post `@copilot` requests for **Fix CI**, **Rebase**, and **Address review feedback**, requests Copilot through GitHub’s native reviewer flow for **Review**, keeps comment, review, quick approve/request-changes, re-run CI, merge, and close actions available, lets the review modal submit comment-only, approve, or request-changes reviews, hides any pull request action whose required GitHub permission is not verified for the saved token, and opens linked Paperclip issues in a plugin-provided right drawer so operators can stay on the queue page.
92
+ Each mapped project can expose a **Pull Requests** entry in the sidebar that opens a live GitHub queue page for that repository (on Paperclip `2026.831` the streamlined sidebar does not mount project sidebar items, so open the page directly at `/<company-prefix>/github-pull-requests?projectId=<project id>`). The sidebar badge uses a lightweight total-count read, while the queue keeps the default view fast by loading only the current 10-row page, uses a repo-wide metrics read for the summary cards, reuses that cached metrics scan to keep filtered views fast by fetching only the visible filtered rows, keeps repo-scoped count, metrics, and per-PR review/check insight caches warm for repeat visits, lets operators explicitly bust those caches with Refresh when they want a live reread, shows total, mergeable, reviewable, and failing cards that filter the table, only treats a pull request as mergeable when it targets the current default branch with green checks, at least one approval, no outstanding change requests, and no unresolved review threads, includes an **Up to date** column that distinguishes current branches, clean update candidates, conflict cases, and unknown freshness when GitHub cannot confirm the comparison, shows the PR target branch with a highlighted default-branch badge, keeps the list sorted by most recently updated first, paginates larger repositories, keeps a compact bottom detail pane with markdown-and-HTML-rendered conversation plus an inline comment composer, supports deterministic **Update branch** actions for clean behind-base pull requests, adds Copilot quick actions that post `@copilot` requests for **Fix CI**, **Rebase**, and **Address review feedback**, requests Copilot through GitHub’s native reviewer flow for **Review**, keeps comment, review, quick approve/request-changes, re-run CI, merge, and close actions available, lets the review modal submit comment-only, approve, or request-changes reviews, hides any pull request action whose required GitHub permission is not verified for the saved token, and opens linked Paperclip issues in a plugin-provided right drawer so operators can stay on the queue page.
93
93
 
94
94
  Paperclip issue linkage on the queue prefers the GitHub issue that the pull request closes, so imported GitHub issues and delivery work stay connected in the same project view. If a pull request has no closing-issue-backed link yet, the queue falls back to the Paperclip issue created directly from that pull request and updates the table immediately when that create action returns.
95
95
 
@@ -128,8 +128,8 @@ Coverage is dimensioned rather than reported as one misleading complete flag: th
128
128
 
129
129
  ## Requirements
130
130
 
131
- - Node.js 20+
132
- - a Paperclip host with plugin installation enabled. GitHub Sync is built and tested against Paperclip `2026.626.0`; the manifest relies on explicit capabilities instead of a strict host-version gate because current latest/development hosts can report `0.0.0` during plugin upgrade.
131
+ - Node.js 24.11+ (the `@paperclipai/plugin-sdk` 2026.831 line requires it)
132
+ - a Paperclip host with plugin installation enabled. GitHub Sync is built and tested against Paperclip `2026.831.1`; the manifest relies on explicit capabilities instead of a strict host-version gate because current latest/development hosts can report `0.0.0` during plugin upgrade.
133
133
  - a GitHub token with API access to the repositories you want to sync
134
134
 
135
135
  ## Install from npm
@@ -216,18 +216,18 @@ Additional behavior:
216
216
 
217
217
  The plugin is designed to avoid persisting raw credentials in plugin state.
218
218
 
219
- - GitHub tokens saved through the UI are stored as per-company Paperclip secret references.
220
- - Paperclip board access tokens are also stored as per-company secret references.
219
+ - GitHub tokens saved through the UI are stored as per-company Paperclip secret references. Paperclip `2026.831` re-enabled plugin secret refs and made plugin config company-scoped: the settings UI mirrors each saved secret into that company's GitHub Sync plugin config as a `{ "type": "secret_ref", "secretId": "<uuid>" }` binding, the host binds that secret to the plugin, and the worker resolves it with the company id and config path. This is the normal path; no worker-local copy is needed.
220
+ - Paperclip board access tokens are also stored as per-company secret references and mirrored the same way.
221
221
  - The settings UI also keeps lightweight non-secret identity labels for those saved connections, so later visits can still show who each company GitHub token and board access are connected as.
222
222
  - Agents use Paperclip's plugin tool dispatcher for GitHub Sync tools; the settings UI no longer propagates the saved GitHub token into agent environment variables.
223
223
  - The worker resolves those secret references at runtime instead of storing raw tokens in plugin state.
224
- - When the current Paperclip host rejects plugin secret refs, GitHub Sync keeps company-scoped worker-local compatibility copies for GitHub tokens and Paperclip board-access tokens in `${PAPERCLIP_HOME:-~/.paperclip}/plugins/github-sync/config.json`. Reconnect board access once after upgrading if sync still cannot authenticate Paperclip label or issue REST calls.
224
+ - When the host cannot resolve a saved secret ref (a pre-`2026.831` host that rejected plugin secret refs, or a plugin config row that still holds a pre-`2026.831` bare secret id the host will not bind), GitHub Sync keeps company-scoped worker-local compatibility copies for GitHub tokens and Paperclip board-access tokens in `${PAPERCLIP_HOME:-~/.paperclip}/plugins/github-sync/config.json`. On `2026.831` the settings page detects bare-id refs and re-mirrors them as bindings on the next visit; reconnect board access once after upgrading if sync still cannot authenticate Paperclip label or issue REST calls.
225
225
  - On authenticated Paperclip deployments, sync is blocked until the relevant company has connected Paperclip board access. On local trusted deployments, board access setup remains visible so operators can configure it for host API paths that still require board credentials, but missing board access does not by itself block sync preflight.
226
226
  - KPI API route requests must include `Authorization: Bearer <PAPERCLIP_API_KEY>` from an agent run; the Paperclip host authenticates the token and supplies the agent company before the worker records any metric event.
227
227
 
228
228
  ### Optional worker-local token file
229
229
 
230
- If Paperclip-managed secrets are not available, the worker can read a local fallback file at `${PAPERCLIP_HOME:-~/.paperclip}/plugins/github-sync/config.json`:
230
+ Paperclip-managed, company-scoped secret refs are the normal path on Paperclip `2026.831` and newer. If they are not available, the worker can read a local fallback file at `${PAPERCLIP_HOME:-~/.paperclip}/plugins/github-sync/config.json`:
231
231
 
232
232
  ```json
233
233
  {
@@ -245,7 +245,7 @@ Notes:
245
245
 
246
246
  - This file is read by the worker only.
247
247
  - The raw token is never persisted back into plugin state or plugin config.
248
- - A GitHub token secret saved through the settings UI is the primary source. If the current Paperclip host rejects plugin secret-ref resolution while company-scoped plugin config is unavailable, GitHub Sync stores the validated token in `githubTokensByCompanyId` as a worker-local compatibility fallback.
248
+ - A GitHub token secret saved through the settings UI is the primary source. Only if the Paperclip host cannot resolve that secret ref for the plugin worker (older hosts that rejected plugin secret refs, or a ref that is not bound to the plugin for that company) does GitHub Sync store the validated token in `githubTokensByCompanyId` as a worker-local compatibility fallback.
249
249
  - A Paperclip board access secret saved through the settings UI is also the primary source. If the host cannot resolve it for plugin workers, reconnecting board access stores the approved board token in `paperclipBoardApiTokensByCompanyId` as a worker-local compatibility fallback for direct Paperclip REST calls.
250
250
 
251
251
  ### Worker-facing Paperclip API URL
@@ -311,8 +311,18 @@ curl -X POST "${PAPERCLIP_API_URL%/}/api/plugins/paperclip-github-plugin/api/com
311
311
 
312
312
  The worker deduplicates repeated PR events by preferring the pull request URL, then `repository + pullRequestNumber`, before falling back to the explicit `eventKey`. When `paperclipIssueId` is present, the worker verifies the live pull request and persists the same PR-link metadata used by scheduled/manual status syncs.
313
313
 
314
+ ### Paperclip 2026.831 compatibility boundary
314
315
 
315
- Paperclip `2026.626.0` adds external object references and task watchdogs, both relevant to GitHub URLs and long-running PR follow-up. GitHub issue and pull request URLs in synced descriptions, comments, and status-transition annotations can be recognized by Paperclip's built-in GitHub external-object provider, so GitHub Sync retires its plugin comment-annotation slot instead of continuing to render a duplicate GitHub-link annotation on comments. GitHub Sync also does **not** register a separate `external.objects.*` provider in this release: the host now owns generic GitHub URL detection and liveness snapshots, while GitHub Sync continues to own repository mappings, issue/PR sync, project PR dashboards, KPI attribution, and mutating GitHub agent tools. A future product PR can connect core external-object mentions back to GitHub Sync entities if operators need richer cross-filtering, but status routing must keep GitHub Sync as the source of truth for mapped/linked work.
316
+ GitHub Sync targets Paperclip `2026.831.1` and adopts the host changes that matter for a multi-company connector:
317
+
318
+ - **Company-scoped plugin config.** The host now stores one GitHub Sync config row per company and replays each of them to the worker after startup instead of passing a bootstrap config. The worker declares `multiCompanyConfig: true`, keys the delivered config by company, and passes the company id to every config read. Scheduled sync and other proactive paths only get host access for companies that have a saved GitHub Sync config; a company that has mappings but no saved config shows a sync error asking you to open GitHub Sync settings in that company and save once.
319
+ - **Secret refs re-enabled.** Company-scoped secret refs are the normal path again. The settings UI mirrors GitHub tokens and board access tokens into plugin config as `{ "type": "secret_ref", "secretId": "<uuid>" }` bindings, and the worker resolves them with the company id and config path. The worker-local token file remains a compatibility fallback only.
320
+ - **Tool gateway.** Agent tool discovery and execution now run through the host tool gateway, which applies each company's tool-access policy before a GitHub Sync tool runs. Tool names are unchanged (`<pluginId>:<tool>`); if a tool is missing for an agent, check the company's tool-access policy before suspecting the plugin.
321
+ - **Optional capabilities not adopted.** `2026.831` adds `issue.interactions.read`, `issue.attachments.read`, `approvals.read`, `issue.comments.create_human_attributed`, `issue.interactions.respond`, and `approvals.respond`. GitHub Sync does not use those host surfaces, so it does not declare them; it keeps its existing capability set.
322
+ - **No strict host-version gate.** The manifest still relies on declared capabilities and runtime fallbacks instead of `minimumHostVersion`, because latest/development hosts can report `0.0.0` during plugin upgrade.
323
+ - **Project sidebar item has no mount point.** `2026.831` made the streamlined main sidebar mandatory (PAP-12472) and no longer renders the per-project list that hosted `projectSidebarItem` contributions. GitHub Sync keeps declaring the slot for hosts that render it, but on `2026.831` the **Pull Requests** entry does not appear; the queue page itself is unaffected and opens at `/<company-prefix>/github-pull-requests?projectId=<project id>`. The e2e harness verifies the sidebar link only when the host renders it and always opens the page by route.
324
+
325
+ The boundaries adopted with Paperclip `2026.626.0` still apply. Paperclip `2026.626.0` adds external object references and task watchdogs, both relevant to GitHub URLs and long-running PR follow-up. GitHub issue and pull request URLs in synced descriptions, comments, and status-transition annotations can be recognized by Paperclip's built-in GitHub external-object provider, so GitHub Sync retires its plugin comment-annotation slot instead of continuing to render a duplicate GitHub-link annotation on comments. GitHub Sync also does **not** register a separate `external.objects.*` provider in this release: the host now owns generic GitHub URL detection and liveness snapshots, while GitHub Sync continues to own repository mappings, issue/PR sync, project PR dashboards, KPI attribution, and mutating GitHub agent tools. A future product PR can connect core external-object mentions back to GitHub Sync entities if operators need richer cross-filtering, but status routing must keep GitHub Sync as the source of truth for mapped/linked work.
316
326
 
317
327
  Task watchdogs are also deliberately not used as a replacement for GitHub Sync's scheduled/manual refresh loop. A watched issue tree that is merely waiting on GitHub CI, mergeability, review threads, or maintainer approval can look "stopped" to Paperclip's generic task-watchdog classifier because there may be no live Paperclip run or wake request while GitHub is the active external system. GitHub Sync should keep encoding those states through issue/PR links, sync comments, status transitions, assignee/execution-policy handoffs, and scheduled sync. Use task watchdogs only for Paperclip-owned delegated task trees; do not use them to poll GitHub PR state or to infer that GitHub Sync should wake an executor.
318
328
 
@@ -365,14 +375,16 @@ Example tool payload:
365
375
  - If an older GitHub Sync build fails upgrade with `requires host version 2026.427.0 or newer, but this server is running 0.0.0`, upgrade to a build that removes the strict manifest host-version gate. The host is reporting a development-version sentinel, so the plugin now relies on declared capabilities and runtime fallbacks instead.
366
376
  - If setup is reported as incomplete, confirm that a GitHub token has been saved or that `${PAPERCLIP_HOME:-~/.paperclip}/plugins/github-sync/config.json` contains `githubToken`, and make sure at least one mapping has a created Paperclip project or at least one Paperclip issue has been linked to GitHub.
367
377
  - If Paperclip says board access is required, open plugin settings inside the affected company and complete the Paperclip board access flow before retrying sync.
368
- - If GitHub Sync agent tools fail on `/api/plugins/tools` or `/api/plugins/tools/execute`, confirm the Paperclip host is `2026.626.0` or newer and that the tool request includes the agent run context required by Paperclip.
378
+ - If GitHub Sync agent tools fail on `/api/plugins/tools` or `/api/plugins/tools/execute`, confirm the Paperclip host is `2026.831.1` or newer, that the tool request includes the agent run context required by Paperclip, and that the company's tool-access policy allows the `paperclip-github-plugin:*` tools for that agent.
379
+ - If the worker logs `Secret is not bound to plugin` or `Invalid secret reference for plugin`, that company's plugin config still holds a pre-`2026.831` bare secret id. Open GitHub Sync settings inside that company so the UI re-mirrors the ref as a `secret_ref` binding, or reconnect the token; until then the worker uses the worker-local fallback copy if one exists.
380
+ - If a scheduled sync reports that Paperclip denied worker access for a company, that company has GitHub Sync mappings but no saved plugin config row. Open GitHub Sync settings inside that company and save settings once so the host registers it.
369
381
  - If a KPI API route call is rejected, make sure the request includes `Authorization: Bearer ${PAPERCLIP_API_KEY}`, that the token is still valid for the current run, and that any `companyId` in the payload matches the calling agent's company.
370
382
  - If the worker reaches an authenticated HTML page instead of the Paperclip API JSON responses it expects, connect Paperclip board access for that company or set **Worker Paperclip API URL** in GitHub Sync settings to a worker-accessible Paperclip API origin.
371
383
  - If a Paperclip API fetch fails before any HTTP response is returned, the saved diagnostics include the method, URL, primary error, nested cause, and cause code when Node exposes them.
372
384
  - If a sync run finishes with partial failures, open the saved troubleshooting panel in GitHub Sync to inspect the repository, issue number, raw error, and suggested fix for each recorded failure.
373
385
  - If sync says the Paperclip API URL is not trusted, set **Worker Paperclip API URL** in GitHub Sync settings to the worker-accessible Paperclip API origin and retry.
374
386
  - If a pull request comment or review action is rejected, read the full toast message. Fine-grained GitHub tokens need write access to that repository, and GitHub requires a review summary when requesting changes.
375
- - If a GitHub-linked project does not show the **Pull requests** sidebar entry, reopen the plugin settings and re-save the mapping. The project pull request surfaces also recover older mappings when saved ids are missing, and they can fall back to the active project's bound GitHub repository when the project already has a GitHub workspace configured.
387
+ - If a GitHub-linked project does not show the **Pull requests** sidebar entry on Paperclip `2026.831`, that is expected: the streamlined sidebar has no `projectSidebarItem` mount point, so open `/<company-prefix>/github-pull-requests?projectId=<project id>` directly. On hosts that still render project sidebar items, reopen the plugin settings and re-save the mapping. The project pull request surfaces also recover older mappings when saved ids are missing, and they can fall back to the active project's bound GitHub repository when the project already has a GitHub workspace configured.
376
388
  - If GitHub rate limiting is hit, the plugin pauses sync until the reported reset time instead of retrying pointlessly.
377
389
  - If a manual sync takes longer than the host action window, it continues in the background and updates the UI when it finishes or when a cancellation request stops it.
378
390
  - If a sync shows `running` after the worker has restarted, the next settings read, toolbar read, cancel action, or scheduler tick will reconcile that stale run into an interrupted error or a cancelled result so you can retry cleanly.
@@ -391,10 +403,10 @@ Useful scripts:
391
403
 
392
404
  - `pnpm dev` watches the manifest, worker, and UI bundles and rebuilds them into `dist/`
393
405
  - `pnpm dev:ui` starts a local Paperclip plugin UI dev server from `dist/ui` on port `4177`
394
- - `pnpm test:e2e` builds the plugin, boots an isolated Paperclip `2026.626.0` instance, installs the plugin, and verifies the hosted settings page renders
395
- - `pnpm verify:manual` builds the plugin, boots a local-trusted Paperclip `2026.626.0` instance for manual inspection, seeds a `Dummy Company` with a mapped review project and a `CEO` agent on the Codex local adapter using model `gpt-5.4`, installs the plugin, and opens the company dashboard without seeding KPI history.
406
+ - `pnpm test:e2e` builds the plugin, boots an isolated Paperclip `2026.831.1` instance, installs the plugin, and verifies the hosted settings page renders
407
+ - `pnpm verify:manual` builds the plugin, boots a local-trusted Paperclip `2026.831.1` instance for manual inspection, seeds a `Dummy Company` with a mapped review project and a `CEO` agent on the Codex local adapter using model `gpt-5.4`, installs the plugin, and opens the company dashboard without seeding KPI history.
396
408
 
397
- The disposable Paperclip harnesses run `paperclipai@2026.626.0` under `node@24`, matching the release's Docker baseline and avoiding Node 20's missing `node:sqlite` runtime module.
409
+ The disposable Paperclip harnesses run `paperclipai@2026.831.1` under `node@24`, matching the release's Docker baseline and avoiding Node 20's missing `node:sqlite` runtime module.
398
410
 
399
411
  For fast hosted UI iteration, run `pnpm dev` in one terminal and `pnpm dev:ui` in another.
400
412
 
package/dist/manifest.js CHANGED
@@ -691,7 +691,21 @@ var COMPANY_METRIC_API_ROUTE_URL_PATH = `/api/plugins/${GITHUB_SYNC_PLUGIN_ID}/a
691
691
  var require2 = createRequire(import.meta.url);
692
692
  var packageJson = require2("../package.json");
693
693
  var SCHEDULE_TICK_CRON = "* * * * *";
694
- var MANIFEST_VERSION = "0.16.1"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
694
+ var MANIFEST_VERSION = "0.17.1"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
695
+ var COMPANY_SECRET_REF_VALUE_SCHEMA = {
696
+ anyOf: [
697
+ { type: "string" },
698
+ {
699
+ type: "object",
700
+ properties: {
701
+ type: { const: "secret_ref" },
702
+ secretId: { type: "string" },
703
+ version: { anyOf: [{ type: "string" }, { type: "integer" }] }
704
+ },
705
+ required: ["type", "secretId"]
706
+ }
707
+ ]
708
+ };
695
709
  var manifest = {
696
710
  id: GITHUB_SYNC_PLUGIN_ID,
697
711
  apiVersion: 1,
@@ -732,16 +746,14 @@ var manifest = {
732
746
  githubTokenRefs: {
733
747
  type: "object",
734
748
  title: "GitHub Token Secrets",
735
- additionalProperties: {
736
- type: "string"
737
- }
749
+ description: "Company id to Paperclip secret reference for the GitHub token.",
750
+ additionalProperties: COMPANY_SECRET_REF_VALUE_SCHEMA
738
751
  },
739
752
  paperclipBoardApiTokenRefs: {
740
753
  type: "object",
741
754
  title: "Paperclip Board Token Secrets",
742
- additionalProperties: {
743
- type: "string"
744
- }
755
+ description: "Company id to Paperclip secret reference for the board access token.",
756
+ additionalProperties: COMPANY_SECRET_REF_VALUE_SCHEMA
745
757
  },
746
758
  paperclipApiBaseUrl: {
747
759
  type: "string",
package/dist/ui/index.js CHANGED
@@ -276,7 +276,7 @@ var require_extend = __commonJS({
276
276
  "use strict";
277
277
  var hasOwn = Object.prototype.hasOwnProperty;
278
278
  var toStr = Object.prototype.toString;
279
- var defineProperty = Object.defineProperty;
279
+ var defineProperty2 = Object.defineProperty;
280
280
  var gOPD = Object.getOwnPropertyDescriptor;
281
281
  var isArray = function isArray2(arr) {
282
282
  if (typeof Array.isArray === "function") {
@@ -299,8 +299,8 @@ var require_extend = __commonJS({
299
299
  return typeof key === "undefined" || hasOwn.call(obj, key);
300
300
  };
301
301
  var setProperty = function setProperty2(target, options) {
302
- if (defineProperty && options.name === "__proto__") {
303
- defineProperty(target, options.name, {
302
+ if (defineProperty2 && options.name === "__proto__") {
303
+ defineProperty2(target, options.name, {
304
304
  enumerable: true,
305
305
  configurable: true,
306
306
  value: options.newValue,
@@ -370,7 +370,7 @@ import {
370
370
  usePluginToast
371
371
  } from "@paperclipai/plugin-sdk/ui";
372
372
 
373
- // node_modules/.pnpm/@ungap+structured-clone@1.3.3/node_modules/@ungap/structured-clone/esm/types.js
373
+ // node_modules/.pnpm/@ungap+structured-clone@1.4.0/node_modules/@ungap/structured-clone/esm/types.js
374
374
  var VOID = -1;
375
375
  var PRIMITIVE = 0;
376
376
  var ARRAY = 1;
@@ -382,7 +382,8 @@ var SET = 6;
382
382
  var ERROR = 7;
383
383
  var BIGINT = 8;
384
384
 
385
- // node_modules/.pnpm/@ungap+structured-clone@1.3.3/node_modules/@ungap/structured-clone/esm/deserialize.js
385
+ // node_modules/.pnpm/@ungap+structured-clone@1.4.0/node_modules/@ungap/structured-clone/esm/deserialize.js
386
+ var { defineProperty } = Object;
386
387
  var env = typeof self === "object" ? self : globalThis;
387
388
  var guard = (name2, init) => {
388
389
  switch (name2) {
@@ -417,8 +418,16 @@ var deserializer = ($2, _) => {
417
418
  }
418
419
  case OBJECT: {
419
420
  const object = as({}, index2);
420
- for (const [key, index3] of value)
421
- object[unpair(key)] = unpair(index3);
421
+ for (const [key, index3] of value) {
422
+ const k = unpair(key), value2 = unpair(index3);
423
+ if (k === "__proto__") defineProperty(object, k, {
424
+ value: value2,
425
+ configurable: true,
426
+ enumerable: true,
427
+ writable: true
428
+ });
429
+ else object[k] = value2;
430
+ }
422
431
  return object;
423
432
  }
424
433
  case DATE:
@@ -456,6 +465,8 @@ var deserializer = ($2, _) => {
456
465
  const { buffer } = new Uint8Array(value);
457
466
  return as(new DataView(buffer), value);
458
467
  }
468
+ case "-0":
469
+ return -0;
459
470
  }
460
471
  return as(guard(type, value), index2);
461
472
  };
@@ -463,10 +474,10 @@ var deserializer = ($2, _) => {
463
474
  };
464
475
  var deserialize = (serialized) => deserializer(/* @__PURE__ */ new Map(), serialized)(0);
465
476
 
466
- // node_modules/.pnpm/@ungap+structured-clone@1.3.3/node_modules/@ungap/structured-clone/esm/serialize.js
477
+ // node_modules/.pnpm/@ungap+structured-clone@1.4.0/node_modules/@ungap/structured-clone/esm/serialize.js
467
478
  var EMPTY = "";
468
479
  var { toString } = {};
469
- var { keys } = Object;
480
+ var { keys, is } = Object;
470
481
  var typeOf = (value) => {
471
482
  const type = typeof value;
472
483
  if (type !== "object" || !value)
@@ -513,6 +524,10 @@ var serializer = (strict, json, $2, _) => {
513
524
  TYPE = BIGINT;
514
525
  entry = value.toString();
515
526
  break;
527
+ case "number":
528
+ if (!value && is(value, -0))
529
+ return _.push(["-0"]) - 1;
530
+ break;
516
531
  case "function":
517
532
  case "symbol":
518
533
  if (strict)
@@ -596,7 +611,7 @@ var serialize = (value, { json, lossy } = {}) => {
596
611
  return serializer(!(json || lossy), !!json, /* @__PURE__ */ new Map(), _)(value), _;
597
612
  };
598
613
 
599
- // node_modules/.pnpm/@ungap+structured-clone@1.3.3/node_modules/@ungap/structured-clone/esm/index.js
614
+ // node_modules/.pnpm/@ungap+structured-clone@1.4.0/node_modules/@ungap/structured-clone/esm/index.js
600
615
  var esm_default = typeof structuredClone === "function" ? (
601
616
  /* c8 ignore start */
602
617
  (any, options) => options && ("json" in options || "lossy" in options) ? deserialize(serialize(any, options)) : structuredClone(any)
@@ -10576,7 +10591,7 @@ function visitParents(tree, test, visitor, reverse) {
10576
10591
  } else {
10577
10592
  check = test;
10578
10593
  }
10579
- const is2 = convert(check);
10594
+ const is3 = convert(check);
10580
10595
  const step = reverse ? -1 : 1;
10581
10596
  factory(tree, void 0, [])();
10582
10597
  function factory(node2, index2, parents) {
@@ -10602,7 +10617,7 @@ function visitParents(tree, test, visitor, reverse) {
10602
10617
  let subresult;
10603
10618
  let offset;
10604
10619
  let grandparents;
10605
- if (!test || is2(node2, index2, parents[parents.length - 1] || void 0)) {
10620
+ if (!test || is3(node2, index2, parents[parents.length - 1] || void 0)) {
10606
10621
  result = toResult(visitor(node2, parents));
10607
10622
  if (result[0] === EXIT) {
10608
10623
  return result;
@@ -12015,7 +12030,7 @@ var urlAttributes = {
12015
12030
  ]
12016
12031
  };
12017
12032
 
12018
- // node_modules/.pnpm/react-markdown@10.1.0_@types+react@19.2.17_react@19.2.7/node_modules/react-markdown/lib/index.js
12033
+ // node_modules/.pnpm/react-markdown@10.1.0_@types+react@19.3.0_react@19.3.0/node_modules/react-markdown/lib/index.js
12019
12034
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12020
12035
  import { useEffect, useState } from "react";
12021
12036
 
@@ -19171,7 +19186,7 @@ function isUint8Array2(value) {
19171
19186
  );
19172
19187
  }
19173
19188
 
19174
- // node_modules/.pnpm/react-markdown@10.1.0_@types+react@19.2.17_react@19.2.7/node_modules/react-markdown/lib/index.js
19189
+ // node_modules/.pnpm/react-markdown@10.1.0_@types+react@19.3.0_react@19.3.0/node_modules/react-markdown/lib/index.js
19175
19190
  var changelog = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md";
19176
19191
  var emptyPlugins = [];
19177
19192
  var emptyRemarkRehypeOptions = { allowDangerousHtml: true };
@@ -21773,21 +21788,26 @@ function gfmStrikethrough(options) {
21773
21788
  }
21774
21789
  }
21775
21790
 
21776
- // node_modules/.pnpm/micromark-extension-gfm-table@2.1.1/node_modules/micromark-extension-gfm-table/lib/edit-map.js
21791
+ // node_modules/.pnpm/micromark-extension-gfm-table@2.1.2/node_modules/micromark-extension-gfm-table/lib/edit-map.js
21777
21792
  var EditMap = class {
21778
21793
  /**
21779
21794
  * Create a new edit map.
21780
21795
  */
21781
21796
  constructor() {
21782
21797
  this.map = [];
21798
+ this.index = /* @__PURE__ */ new Map();
21783
21799
  }
21784
21800
  /**
21785
21801
  * Create an edit: a remove and/or add at a certain place.
21786
21802
  *
21787
21803
  * @param {number} index
21804
+ * Index at which to apply the edit.
21788
21805
  * @param {number} remove
21806
+ * Count of items to remove at the index.
21789
21807
  * @param {Array<Event>} add
21808
+ * Items to add at the index.
21790
21809
  * @returns {undefined}
21810
+ * Nothing.
21791
21811
  */
21792
21812
  add(index2, remove, add) {
21793
21813
  addImplementation(this, index2, remove, add);
@@ -21808,7 +21828,9 @@ var EditMap = class {
21808
21828
  * Done, change the events.
21809
21829
  *
21810
21830
  * @param {Array<Event>} events
21831
+ * List of events to apply the edits to.
21811
21832
  * @returns {undefined}
21833
+ * Nothing.
21812
21834
  */
21813
21835
  consume(events) {
21814
21836
  this.map.sort(function(a, b) {
@@ -21834,25 +21856,25 @@ var EditMap = class {
21834
21856
  slice = vecs.pop();
21835
21857
  }
21836
21858
  this.map.length = 0;
21859
+ this.index.clear();
21837
21860
  }
21838
21861
  };
21839
21862
  function addImplementation(editMap, at, remove, add) {
21840
- let index2 = 0;
21841
21863
  if (remove === 0 && add.length === 0) {
21842
21864
  return;
21843
21865
  }
21844
- while (index2 < editMap.map.length) {
21845
- if (editMap.map[index2][0] === at) {
21846
- editMap.map[index2][1] += remove;
21847
- editMap.map[index2][2].push(...add);
21848
- return;
21849
- }
21850
- index2 += 1;
21866
+ const existing = editMap.index.get(at);
21867
+ if (existing) {
21868
+ existing[1] += remove;
21869
+ existing[2].push(...add);
21870
+ return;
21851
21871
  }
21852
- editMap.map.push([at, remove, add]);
21872
+ const change = [at, remove, add];
21873
+ editMap.map.push(change);
21874
+ editMap.index.set(at, change);
21853
21875
  }
21854
21876
 
21855
- // node_modules/.pnpm/micromark-extension-gfm-table@2.1.1/node_modules/micromark-extension-gfm-table/lib/infer.js
21877
+ // node_modules/.pnpm/micromark-extension-gfm-table@2.1.2/node_modules/micromark-extension-gfm-table/lib/infer.js
21856
21878
  function gfmTableAlign(events, index2) {
21857
21879
  let inDelimiterRow = false;
21858
21880
  const align = [];
@@ -21879,7 +21901,7 @@ function gfmTableAlign(events, index2) {
21879
21901
  return align;
21880
21902
  }
21881
21903
 
21882
- // node_modules/.pnpm/micromark-extension-gfm-table@2.1.1/node_modules/micromark-extension-gfm-table/lib/syntax.js
21904
+ // node_modules/.pnpm/micromark-extension-gfm-table@2.1.2/node_modules/micromark-extension-gfm-table/lib/syntax.js
21883
21905
  function gfmTable() {
21884
21906
  return {
21885
21907
  flow: {
@@ -21900,10 +21922,15 @@ function tokenizeTable(effects, ok3, nok) {
21900
21922
  function start2(code4) {
21901
21923
  let index2 = self2.events.length - 1;
21902
21924
  while (index2 > -1) {
21903
- const type = self2.events[index2][1].type;
21925
+ const {
21926
+ type
21927
+ } = self2.events[index2][1];
21904
21928
  if (type === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
21905
- type === "linePrefix") index2--;
21906
- else break;
21929
+ type === "linePrefix") {
21930
+ index2--;
21931
+ } else {
21932
+ break;
21933
+ }
21907
21934
  }
21908
21935
  const tail = index2 > -1 ? self2.events[index2][1].type : null;
21909
21936
  const next2 = tail === "tableHead" || tail === "tableRow" ? bodyRowStart : headRowBefore;
@@ -22671,6 +22698,24 @@ function resolvePluginSettingsHref(records) {
22671
22698
  function normalizeOptionalString2(value) {
22672
22699
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
22673
22700
  }
22701
+ function isPlainRecord(value) {
22702
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
22703
+ }
22704
+ function isPluginSecretRefBinding(value) {
22705
+ return isPlainRecord(value) && value.type === "secret_ref" && typeof value.secretId === "string" && Boolean(value.secretId.trim());
22706
+ }
22707
+ function normalizePluginSecretRefBinding(value) {
22708
+ if (isPluginSecretRefBinding(value)) {
22709
+ const version = value.version;
22710
+ return {
22711
+ type: "secret_ref",
22712
+ secretId: value.secretId.trim(),
22713
+ ...version === "latest" || typeof version === "number" && Number.isInteger(version) && version > 0 ? { version } : {}
22714
+ };
22715
+ }
22716
+ const secretId = normalizeOptionalString2(value);
22717
+ return secretId ? { type: "secret_ref", secretId } : void 0;
22718
+ }
22674
22719
  function normalizePaperclipApiBaseUrl(value) {
22675
22720
  const normalizedValue = normalizeOptionalString2(value);
22676
22721
  if (!normalizedValue) {
@@ -22682,13 +22727,13 @@ function normalizePaperclipApiBaseUrl(value) {
22682
22727
  return void 0;
22683
22728
  }
22684
22729
  }
22685
- function normalizePluginConfigBoardTokenRefs(value) {
22686
- if (!value || typeof value !== "object") {
22730
+ function normalizeCompanySecretRefMap(value) {
22731
+ if (!isPlainRecord(value)) {
22687
22732
  return void 0;
22688
22733
  }
22689
22734
  const entries = Object.entries(value).map(([companyId, secretRef]) => {
22690
22735
  const normalizedCompanyId = normalizeOptionalString2(companyId);
22691
- const normalizedSecretRef = normalizeOptionalString2(secretRef);
22736
+ const normalizedSecretRef = normalizePluginSecretRefBinding(secretRef);
22692
22737
  return normalizedCompanyId && normalizedSecretRef ? [normalizedCompanyId, normalizedSecretRef] : null;
22693
22738
  }).filter((entry) => Boolean(entry));
22694
22739
  if (entries.length === 0) {
@@ -22696,22 +22741,14 @@ function normalizePluginConfigBoardTokenRefs(value) {
22696
22741
  }
22697
22742
  return Object.fromEntries(entries);
22698
22743
  }
22744
+ function normalizePluginConfigBoardTokenRefs(value) {
22745
+ return normalizeCompanySecretRefMap(value);
22746
+ }
22699
22747
  function normalizePluginConfigGitHubTokenRefs(value) {
22700
- if (!value || typeof value !== "object") {
22701
- return void 0;
22702
- }
22703
- const entries = Object.entries(value).map(([companyId, secretRef]) => {
22704
- const normalizedCompanyId = normalizeOptionalString2(companyId);
22705
- const normalizedSecretRef = normalizeOptionalString2(secretRef);
22706
- return normalizedCompanyId && normalizedSecretRef ? [normalizedCompanyId, normalizedSecretRef] : null;
22707
- }).filter((entry) => Boolean(entry));
22708
- if (entries.length === 0) {
22709
- return void 0;
22710
- }
22711
- return Object.fromEntries(entries);
22748
+ return normalizeCompanySecretRefMap(value);
22712
22749
  }
22713
22750
  function normalizePluginConfig(value) {
22714
- if (!value || typeof value !== "object") {
22751
+ if (!isPlainRecord(value)) {
22715
22752
  return {};
22716
22753
  }
22717
22754
  const record = { ...value };
@@ -27527,15 +27564,21 @@ async function fetchPluginDataResult(params) {
27527
27564
  });
27528
27565
  return response.data;
27529
27566
  }
27530
- async function syncTrustedPaperclipApiBaseUrl(pluginId) {
27567
+ function buildPluginConfigUrl(pluginId, companyId) {
27568
+ return `/api/plugins/${pluginId}/config?companyId=${encodeURIComponent(companyId)}`;
27569
+ }
27570
+ async function readPluginConfig(pluginId, companyId) {
27571
+ const currentConfigResponse = await fetchJson(buildPluginConfigUrl(pluginId, companyId));
27572
+ return normalizePluginConfig(currentConfigResponse?.configJson);
27573
+ }
27574
+ async function syncTrustedPaperclipApiBaseUrl(pluginId, companyId) {
27531
27575
  const resolvedPluginId = await resolveCurrentPluginId(pluginId);
27532
27576
  if (!resolvedPluginId) {
27533
27577
  throw new Error(
27534
27578
  "Unable to sync the trusted Paperclip API origin because the plugin ID is missing. Reload the plugin and try again before saving or syncing."
27535
27579
  );
27536
27580
  }
27537
- const currentConfigResponse = await fetchJson(`/api/plugins/${resolvedPluginId}/config`);
27538
- const currentConfig = normalizePluginConfig(currentConfigResponse?.configJson);
27581
+ const currentConfig = companyId ? await readPluginConfig(resolvedPluginId, companyId) : {};
27539
27582
  const paperclipApiBaseUrl = resolvePaperclipApiBaseUrlForPluginAction(currentConfig, getPaperclipApiBrowserOrigin());
27540
27583
  if (!paperclipApiBaseUrl) {
27541
27584
  return void 0;
@@ -28328,23 +28371,26 @@ function stripPluginSecretRefValue(value) {
28328
28371
  function stripPluginSecretRefConfig(config) {
28329
28372
  return stripPluginSecretRefValue(config);
28330
28373
  }
28331
- async function writePluginConfig(pluginId, config) {
28374
+ async function writePluginConfig(pluginId, companyId, config) {
28332
28375
  await fetchJson(`/api/plugins/${pluginId}/config`, {
28333
28376
  method: "POST",
28334
28377
  body: JSON.stringify({
28378
+ companyId,
28335
28379
  configJson: config
28336
28380
  })
28337
28381
  });
28338
28382
  }
28339
- async function patchPluginConfig(pluginId, patch5) {
28340
- const currentConfigResponse = await fetchJson(`/api/plugins/${pluginId}/config`);
28341
- const currentConfig = normalizePluginConfig(currentConfigResponse?.configJson);
28383
+ async function patchPluginConfig(pluginId, companyId, patch5) {
28384
+ if (!companyId) {
28385
+ throw new Error("Company context is required to save GitHub Sync plugin config.");
28386
+ }
28387
+ const currentConfig = await readPluginConfig(pluginId, companyId);
28342
28388
  const nextConfig = mergePluginConfig(currentConfig, patch5);
28343
28389
  if (JSON.stringify(nextConfig) === JSON.stringify(currentConfig)) {
28344
28390
  return;
28345
28391
  }
28346
28392
  try {
28347
- await writePluginConfig(pluginId, nextConfig);
28393
+ await writePluginConfig(pluginId, companyId, nextConfig);
28348
28394
  } catch (error) {
28349
28395
  if (!isPluginSecretReferencesDisabledError(error)) {
28350
28396
  throw error;
@@ -28353,7 +28399,7 @@ async function patchPluginConfig(pluginId, patch5) {
28353
28399
  if (JSON.stringify(safeConfig) === JSON.stringify(nextConfig)) {
28354
28400
  throw error;
28355
28401
  }
28356
- await writePluginConfig(pluginId, safeConfig);
28402
+ await writePluginConfig(pluginId, companyId, safeConfig);
28357
28403
  }
28358
28404
  }
28359
28405
  function normalizeCliAuthPollIntervalMs(value) {
@@ -31971,7 +32017,7 @@ function GitHubSyncSettingsPage() {
31971
32017
  if (!pluginId) {
31972
32018
  throw new Error("Plugin id is required to finish syncing the GitHub token into plugin config.");
31973
32019
  }
31974
- await patchPluginConfig(pluginId, {
32020
+ await patchPluginConfig(pluginId, companyId, {
31975
32021
  githubTokenRefs: {
31976
32022
  [companyId]: secretRef
31977
32023
  }
@@ -32032,7 +32078,7 @@ function GitHubSyncSettingsPage() {
32032
32078
  if (!pluginId) {
32033
32079
  throw new Error("Plugin id is required to finish syncing Paperclip board access into plugin config.");
32034
32080
  }
32035
- await patchPluginConfig(pluginId, {
32081
+ await patchPluginConfig(pluginId, companyId, {
32036
32082
  paperclipBoardApiTokenRefs: {
32037
32083
  [companyId]: secretRef
32038
32084
  }
@@ -32430,7 +32476,7 @@ function GitHubSyncSettingsPage() {
32430
32476
  const trimmedToken = tokenDraft.trim();
32431
32477
  const secretName = `github_sync_${companyId.replace(/[^a-z0-9]+/gi, "_").toLowerCase()}`;
32432
32478
  const secret = await resolveOrCreateCompanySecret(companyId, secretName, trimmedToken);
32433
- await patchPluginConfig(pluginId, {
32479
+ await patchPluginConfig(pluginId, companyId, {
32434
32480
  githubTokenRefs: {
32435
32481
  [companyId]: secret.id
32436
32482
  }
@@ -32524,7 +32570,7 @@ function GitHubSyncSettingsPage() {
32524
32570
  const boardIdentity = await fetchBoardAccessIdentity(boardApiToken);
32525
32571
  const secretName = `paperclip_board_api_${companyId.replace(/[^a-z0-9]+/gi, "_").toLowerCase()}`;
32526
32572
  const secret = await resolveOrCreateCompanySecret(companyId, secretName, boardApiToken);
32527
- await patchPluginConfig(pluginId, {
32573
+ await patchPluginConfig(pluginId, companyId, {
32528
32574
  paperclipBoardApiTokenRefs: {
32529
32575
  [companyId]: secret.id
32530
32576
  }
@@ -32621,7 +32667,7 @@ function GitHubSyncSettingsPage() {
32621
32667
  throw new Error("Could not resolve the current browser origin for Paperclip API calls.");
32622
32668
  }
32623
32669
  const nextConfiguredPaperclipApiBaseUrl = trustedPaperclipApiBaseUrl;
32624
- await patchPluginConfig(pluginId, {
32670
+ await patchPluginConfig(pluginId, companyId, {
32625
32671
  paperclipApiBaseUrl: nextConfiguredPaperclipApiBaseUrl
32626
32672
  });
32627
32673
  const result = await saveRegistration({
@@ -32673,7 +32719,7 @@ function GitHubSyncSettingsPage() {
32673
32719
  if (!syncUnlocked) {
32674
32720
  throw new Error(syncSetupMessage);
32675
32721
  }
32676
- const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation);
32722
+ const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation, hostContext.companyId);
32677
32723
  const result = await runSyncNow({
32678
32724
  waitForCompletion: true,
32679
32725
  ...hostContext.companyId ? { companyId: hostContext.companyId } : {},
@@ -33601,7 +33647,7 @@ function GitHubSyncDashboardWidget() {
33601
33647
  if (!syncUnlocked) {
33602
33648
  throw new Error(syncSetupMessage);
33603
33649
  }
33604
- const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation);
33650
+ const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation, hostContext.companyId);
33605
33651
  const result = await runSyncNow({
33606
33652
  waitForCompletion: true,
33607
33653
  ...hostContext.companyId ? { companyId: hostContext.companyId } : {},
@@ -34419,7 +34465,7 @@ function useGitHubSyncButtonController(props) {
34419
34465
  throw new Error(effectiveMessage ?? "Unable to run GitHub sync.");
34420
34466
  }
34421
34467
  setRunningSync(true);
34422
- const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation);
34468
+ const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation, props.companyId);
34423
34469
  const result = await runSyncNow({
34424
34470
  waitForCompletion: true,
34425
34471
  ...props.companyId ? { companyId: props.companyId } : {},