paperclip-github-plugin 0.16.0 → 0.17.0
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 +28 -16
- package/dist/manifest.js +19 -7
- package/dist/ui/index.js +62 -40
- package/dist/ui/index.js.map +3 -3
- package/dist/worker.js +294 -56
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/paperclip-github-plugin)
|
|
4
4
|
[](https://github.com/alvarosanchez/paperclip-github-plugin/actions/workflows/ci.yml)
|
|
5
|
-
[](https://www.npmjs.com/package/paperclip-github-plugin)
|
|
6
6
|
[](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
|
|
132
|
-
- a Paperclip host with plugin installation enabled. GitHub Sync is built and tested against Paperclip `2026.
|
|
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
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
395
|
-
- `pnpm verify:manual` builds the plugin, boots a local-trusted Paperclip `2026.
|
|
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.
|
|
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.
|
|
694
|
+
var MANIFEST_VERSION = "0.17.0"?.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
|
-
|
|
736
|
-
|
|
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
|
-
|
|
743
|
-
|
|
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
|
@@ -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.
|
|
373
|
+
// node_modules/.pnpm/@ungap+structured-clone@1.3.3/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,7 @@ var SET = 6;
|
|
|
382
382
|
var ERROR = 7;
|
|
383
383
|
var BIGINT = 8;
|
|
384
384
|
|
|
385
|
-
// node_modules/.pnpm/@ungap+structured-clone@1.3.
|
|
385
|
+
// node_modules/.pnpm/@ungap+structured-clone@1.3.3/node_modules/@ungap/structured-clone/esm/deserialize.js
|
|
386
386
|
var env = typeof self === "object" ? self : globalThis;
|
|
387
387
|
var guard = (name2, init) => {
|
|
388
388
|
switch (name2) {
|
|
@@ -441,7 +441,10 @@ var deserializer = ($2, _) => {
|
|
|
441
441
|
}
|
|
442
442
|
case ERROR: {
|
|
443
443
|
const { name: name2, message } = value;
|
|
444
|
-
return as(
|
|
444
|
+
return as(
|
|
445
|
+
typeof env[name2] === "function" ? guard(name2, message) : new Error(message),
|
|
446
|
+
index2
|
|
447
|
+
);
|
|
445
448
|
}
|
|
446
449
|
case BIGINT:
|
|
447
450
|
return as(BigInt(value), index2);
|
|
@@ -460,7 +463,7 @@ var deserializer = ($2, _) => {
|
|
|
460
463
|
};
|
|
461
464
|
var deserialize = (serialized) => deserializer(/* @__PURE__ */ new Map(), serialized)(0);
|
|
462
465
|
|
|
463
|
-
// node_modules/.pnpm/@ungap+structured-clone@1.3.
|
|
466
|
+
// node_modules/.pnpm/@ungap+structured-clone@1.3.3/node_modules/@ungap/structured-clone/esm/serialize.js
|
|
464
467
|
var EMPTY = "";
|
|
465
468
|
var { toString } = {};
|
|
466
469
|
var { keys } = Object;
|
|
@@ -487,8 +490,8 @@ var typeOf = (value) => {
|
|
|
487
490
|
}
|
|
488
491
|
if (asString.includes("Array"))
|
|
489
492
|
return [ARRAY, asString];
|
|
490
|
-
if (
|
|
491
|
-
return [ERROR,
|
|
493
|
+
if (value instanceof Error)
|
|
494
|
+
return [ERROR, value.name || "Error"];
|
|
492
495
|
return [OBJECT, asString];
|
|
493
496
|
};
|
|
494
497
|
var shouldSkip = ([TYPE, type]) => TYPE === PRIMITIVE && (type === "function" || type === "symbol");
|
|
@@ -593,7 +596,7 @@ var serialize = (value, { json, lossy } = {}) => {
|
|
|
593
596
|
return serializer(!(json || lossy), !!json, /* @__PURE__ */ new Map(), _)(value), _;
|
|
594
597
|
};
|
|
595
598
|
|
|
596
|
-
// node_modules/.pnpm/@ungap+structured-clone@1.3.
|
|
599
|
+
// node_modules/.pnpm/@ungap+structured-clone@1.3.3/node_modules/@ungap/structured-clone/esm/index.js
|
|
597
600
|
var esm_default = typeof structuredClone === "function" ? (
|
|
598
601
|
/* c8 ignore start */
|
|
599
602
|
(any, options) => options && ("json" in options || "lossy" in options) ? deserialize(serialize(any, options)) : structuredClone(any)
|
|
@@ -22668,6 +22671,24 @@ function resolvePluginSettingsHref(records) {
|
|
|
22668
22671
|
function normalizeOptionalString2(value) {
|
|
22669
22672
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
22670
22673
|
}
|
|
22674
|
+
function isPlainRecord(value) {
|
|
22675
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
22676
|
+
}
|
|
22677
|
+
function isPluginSecretRefBinding(value) {
|
|
22678
|
+
return isPlainRecord(value) && value.type === "secret_ref" && typeof value.secretId === "string" && Boolean(value.secretId.trim());
|
|
22679
|
+
}
|
|
22680
|
+
function normalizePluginSecretRefBinding(value) {
|
|
22681
|
+
if (isPluginSecretRefBinding(value)) {
|
|
22682
|
+
const version = value.version;
|
|
22683
|
+
return {
|
|
22684
|
+
type: "secret_ref",
|
|
22685
|
+
secretId: value.secretId.trim(),
|
|
22686
|
+
...version === "latest" || typeof version === "number" && Number.isInteger(version) && version > 0 ? { version } : {}
|
|
22687
|
+
};
|
|
22688
|
+
}
|
|
22689
|
+
const secretId = normalizeOptionalString2(value);
|
|
22690
|
+
return secretId ? { type: "secret_ref", secretId } : void 0;
|
|
22691
|
+
}
|
|
22671
22692
|
function normalizePaperclipApiBaseUrl(value) {
|
|
22672
22693
|
const normalizedValue = normalizeOptionalString2(value);
|
|
22673
22694
|
if (!normalizedValue) {
|
|
@@ -22679,13 +22700,13 @@ function normalizePaperclipApiBaseUrl(value) {
|
|
|
22679
22700
|
return void 0;
|
|
22680
22701
|
}
|
|
22681
22702
|
}
|
|
22682
|
-
function
|
|
22683
|
-
if (!value
|
|
22703
|
+
function normalizeCompanySecretRefMap(value) {
|
|
22704
|
+
if (!isPlainRecord(value)) {
|
|
22684
22705
|
return void 0;
|
|
22685
22706
|
}
|
|
22686
22707
|
const entries = Object.entries(value).map(([companyId, secretRef]) => {
|
|
22687
22708
|
const normalizedCompanyId = normalizeOptionalString2(companyId);
|
|
22688
|
-
const normalizedSecretRef =
|
|
22709
|
+
const normalizedSecretRef = normalizePluginSecretRefBinding(secretRef);
|
|
22689
22710
|
return normalizedCompanyId && normalizedSecretRef ? [normalizedCompanyId, normalizedSecretRef] : null;
|
|
22690
22711
|
}).filter((entry) => Boolean(entry));
|
|
22691
22712
|
if (entries.length === 0) {
|
|
@@ -22693,22 +22714,14 @@ function normalizePluginConfigBoardTokenRefs(value) {
|
|
|
22693
22714
|
}
|
|
22694
22715
|
return Object.fromEntries(entries);
|
|
22695
22716
|
}
|
|
22717
|
+
function normalizePluginConfigBoardTokenRefs(value) {
|
|
22718
|
+
return normalizeCompanySecretRefMap(value);
|
|
22719
|
+
}
|
|
22696
22720
|
function normalizePluginConfigGitHubTokenRefs(value) {
|
|
22697
|
-
|
|
22698
|
-
return void 0;
|
|
22699
|
-
}
|
|
22700
|
-
const entries = Object.entries(value).map(([companyId, secretRef]) => {
|
|
22701
|
-
const normalizedCompanyId = normalizeOptionalString2(companyId);
|
|
22702
|
-
const normalizedSecretRef = normalizeOptionalString2(secretRef);
|
|
22703
|
-
return normalizedCompanyId && normalizedSecretRef ? [normalizedCompanyId, normalizedSecretRef] : null;
|
|
22704
|
-
}).filter((entry) => Boolean(entry));
|
|
22705
|
-
if (entries.length === 0) {
|
|
22706
|
-
return void 0;
|
|
22707
|
-
}
|
|
22708
|
-
return Object.fromEntries(entries);
|
|
22721
|
+
return normalizeCompanySecretRefMap(value);
|
|
22709
22722
|
}
|
|
22710
22723
|
function normalizePluginConfig(value) {
|
|
22711
|
-
if (!value
|
|
22724
|
+
if (!isPlainRecord(value)) {
|
|
22712
22725
|
return {};
|
|
22713
22726
|
}
|
|
22714
22727
|
const record = { ...value };
|
|
@@ -27524,15 +27537,21 @@ async function fetchPluginDataResult(params) {
|
|
|
27524
27537
|
});
|
|
27525
27538
|
return response.data;
|
|
27526
27539
|
}
|
|
27527
|
-
|
|
27540
|
+
function buildPluginConfigUrl(pluginId, companyId) {
|
|
27541
|
+
return `/api/plugins/${pluginId}/config?companyId=${encodeURIComponent(companyId)}`;
|
|
27542
|
+
}
|
|
27543
|
+
async function readPluginConfig(pluginId, companyId) {
|
|
27544
|
+
const currentConfigResponse = await fetchJson(buildPluginConfigUrl(pluginId, companyId));
|
|
27545
|
+
return normalizePluginConfig(currentConfigResponse?.configJson);
|
|
27546
|
+
}
|
|
27547
|
+
async function syncTrustedPaperclipApiBaseUrl(pluginId, companyId) {
|
|
27528
27548
|
const resolvedPluginId = await resolveCurrentPluginId(pluginId);
|
|
27529
27549
|
if (!resolvedPluginId) {
|
|
27530
27550
|
throw new Error(
|
|
27531
27551
|
"Unable to sync the trusted Paperclip API origin because the plugin ID is missing. Reload the plugin and try again before saving or syncing."
|
|
27532
27552
|
);
|
|
27533
27553
|
}
|
|
27534
|
-
const
|
|
27535
|
-
const currentConfig = normalizePluginConfig(currentConfigResponse?.configJson);
|
|
27554
|
+
const currentConfig = companyId ? await readPluginConfig(resolvedPluginId, companyId) : {};
|
|
27536
27555
|
const paperclipApiBaseUrl = resolvePaperclipApiBaseUrlForPluginAction(currentConfig, getPaperclipApiBrowserOrigin());
|
|
27537
27556
|
if (!paperclipApiBaseUrl) {
|
|
27538
27557
|
return void 0;
|
|
@@ -28325,23 +28344,26 @@ function stripPluginSecretRefValue(value) {
|
|
|
28325
28344
|
function stripPluginSecretRefConfig(config) {
|
|
28326
28345
|
return stripPluginSecretRefValue(config);
|
|
28327
28346
|
}
|
|
28328
|
-
async function writePluginConfig(pluginId, config) {
|
|
28347
|
+
async function writePluginConfig(pluginId, companyId, config) {
|
|
28329
28348
|
await fetchJson(`/api/plugins/${pluginId}/config`, {
|
|
28330
28349
|
method: "POST",
|
|
28331
28350
|
body: JSON.stringify({
|
|
28351
|
+
companyId,
|
|
28332
28352
|
configJson: config
|
|
28333
28353
|
})
|
|
28334
28354
|
});
|
|
28335
28355
|
}
|
|
28336
|
-
async function patchPluginConfig(pluginId, patch5) {
|
|
28337
|
-
|
|
28338
|
-
|
|
28356
|
+
async function patchPluginConfig(pluginId, companyId, patch5) {
|
|
28357
|
+
if (!companyId) {
|
|
28358
|
+
throw new Error("Company context is required to save GitHub Sync plugin config.");
|
|
28359
|
+
}
|
|
28360
|
+
const currentConfig = await readPluginConfig(pluginId, companyId);
|
|
28339
28361
|
const nextConfig = mergePluginConfig(currentConfig, patch5);
|
|
28340
28362
|
if (JSON.stringify(nextConfig) === JSON.stringify(currentConfig)) {
|
|
28341
28363
|
return;
|
|
28342
28364
|
}
|
|
28343
28365
|
try {
|
|
28344
|
-
await writePluginConfig(pluginId, nextConfig);
|
|
28366
|
+
await writePluginConfig(pluginId, companyId, nextConfig);
|
|
28345
28367
|
} catch (error) {
|
|
28346
28368
|
if (!isPluginSecretReferencesDisabledError(error)) {
|
|
28347
28369
|
throw error;
|
|
@@ -28350,7 +28372,7 @@ async function patchPluginConfig(pluginId, patch5) {
|
|
|
28350
28372
|
if (JSON.stringify(safeConfig) === JSON.stringify(nextConfig)) {
|
|
28351
28373
|
throw error;
|
|
28352
28374
|
}
|
|
28353
|
-
await writePluginConfig(pluginId, safeConfig);
|
|
28375
|
+
await writePluginConfig(pluginId, companyId, safeConfig);
|
|
28354
28376
|
}
|
|
28355
28377
|
}
|
|
28356
28378
|
function normalizeCliAuthPollIntervalMs(value) {
|
|
@@ -31968,7 +31990,7 @@ function GitHubSyncSettingsPage() {
|
|
|
31968
31990
|
if (!pluginId) {
|
|
31969
31991
|
throw new Error("Plugin id is required to finish syncing the GitHub token into plugin config.");
|
|
31970
31992
|
}
|
|
31971
|
-
await patchPluginConfig(pluginId, {
|
|
31993
|
+
await patchPluginConfig(pluginId, companyId, {
|
|
31972
31994
|
githubTokenRefs: {
|
|
31973
31995
|
[companyId]: secretRef
|
|
31974
31996
|
}
|
|
@@ -32029,7 +32051,7 @@ function GitHubSyncSettingsPage() {
|
|
|
32029
32051
|
if (!pluginId) {
|
|
32030
32052
|
throw new Error("Plugin id is required to finish syncing Paperclip board access into plugin config.");
|
|
32031
32053
|
}
|
|
32032
|
-
await patchPluginConfig(pluginId, {
|
|
32054
|
+
await patchPluginConfig(pluginId, companyId, {
|
|
32033
32055
|
paperclipBoardApiTokenRefs: {
|
|
32034
32056
|
[companyId]: secretRef
|
|
32035
32057
|
}
|
|
@@ -32427,7 +32449,7 @@ function GitHubSyncSettingsPage() {
|
|
|
32427
32449
|
const trimmedToken = tokenDraft.trim();
|
|
32428
32450
|
const secretName = `github_sync_${companyId.replace(/[^a-z0-9]+/gi, "_").toLowerCase()}`;
|
|
32429
32451
|
const secret = await resolveOrCreateCompanySecret(companyId, secretName, trimmedToken);
|
|
32430
|
-
await patchPluginConfig(pluginId, {
|
|
32452
|
+
await patchPluginConfig(pluginId, companyId, {
|
|
32431
32453
|
githubTokenRefs: {
|
|
32432
32454
|
[companyId]: secret.id
|
|
32433
32455
|
}
|
|
@@ -32521,7 +32543,7 @@ function GitHubSyncSettingsPage() {
|
|
|
32521
32543
|
const boardIdentity = await fetchBoardAccessIdentity(boardApiToken);
|
|
32522
32544
|
const secretName = `paperclip_board_api_${companyId.replace(/[^a-z0-9]+/gi, "_").toLowerCase()}`;
|
|
32523
32545
|
const secret = await resolveOrCreateCompanySecret(companyId, secretName, boardApiToken);
|
|
32524
|
-
await patchPluginConfig(pluginId, {
|
|
32546
|
+
await patchPluginConfig(pluginId, companyId, {
|
|
32525
32547
|
paperclipBoardApiTokenRefs: {
|
|
32526
32548
|
[companyId]: secret.id
|
|
32527
32549
|
}
|
|
@@ -32618,7 +32640,7 @@ function GitHubSyncSettingsPage() {
|
|
|
32618
32640
|
throw new Error("Could not resolve the current browser origin for Paperclip API calls.");
|
|
32619
32641
|
}
|
|
32620
32642
|
const nextConfiguredPaperclipApiBaseUrl = trustedPaperclipApiBaseUrl;
|
|
32621
|
-
await patchPluginConfig(pluginId, {
|
|
32643
|
+
await patchPluginConfig(pluginId, companyId, {
|
|
32622
32644
|
paperclipApiBaseUrl: nextConfiguredPaperclipApiBaseUrl
|
|
32623
32645
|
});
|
|
32624
32646
|
const result = await saveRegistration({
|
|
@@ -32670,7 +32692,7 @@ function GitHubSyncSettingsPage() {
|
|
|
32670
32692
|
if (!syncUnlocked) {
|
|
32671
32693
|
throw new Error(syncSetupMessage);
|
|
32672
32694
|
}
|
|
32673
|
-
const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation);
|
|
32695
|
+
const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation, hostContext.companyId);
|
|
32674
32696
|
const result = await runSyncNow({
|
|
32675
32697
|
waitForCompletion: true,
|
|
32676
32698
|
...hostContext.companyId ? { companyId: hostContext.companyId } : {},
|
|
@@ -33598,7 +33620,7 @@ function GitHubSyncDashboardWidget() {
|
|
|
33598
33620
|
if (!syncUnlocked) {
|
|
33599
33621
|
throw new Error(syncSetupMessage);
|
|
33600
33622
|
}
|
|
33601
|
-
const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation);
|
|
33623
|
+
const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation, hostContext.companyId);
|
|
33602
33624
|
const result = await runSyncNow({
|
|
33603
33625
|
waitForCompletion: true,
|
|
33604
33626
|
...hostContext.companyId ? { companyId: hostContext.companyId } : {},
|
|
@@ -34416,7 +34438,7 @@ function useGitHubSyncButtonController(props) {
|
|
|
34416
34438
|
throw new Error(effectiveMessage ?? "Unable to run GitHub sync.");
|
|
34417
34439
|
}
|
|
34418
34440
|
setRunningSync(true);
|
|
34419
|
-
const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation);
|
|
34441
|
+
const trustedPaperclipApiBaseUrl = await syncTrustedPaperclipApiBaseUrl(pluginIdFromLocation, props.companyId);
|
|
34420
34442
|
const result = await runSyncNow({
|
|
34421
34443
|
waitForCompletion: true,
|
|
34422
34444
|
...props.companyId ? { companyId: props.companyId } : {},
|