paperclip-github-plugin 0.12.0 → 0.14.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 +26 -18
- package/dist/manifest.js +12 -13
- package/dist/ui/index.js +10 -426
- package/dist/ui/index.js.map +3 -3
- package/dist/worker.js +442 -59
- package/package.json +3 -3
package/dist/ui/index.js
CHANGED
|
@@ -22435,8 +22435,7 @@ function resolvePaperclipAuthControlsPolicy(value) {
|
|
|
22435
22435
|
const health = normalizePaperclipHealthResponse(value);
|
|
22436
22436
|
return {
|
|
22437
22437
|
boardAccessRequired: requiresPaperclipBoardAccessForHealth(health),
|
|
22438
|
-
boardAccessSettingsVisible: shouldShowPaperclipBoardAccessSettingsForHealth(health)
|
|
22439
|
-
githubTokenPropagationSettingsVisible: true
|
|
22438
|
+
boardAccessSettingsVisible: shouldShowPaperclipBoardAccessSettingsForHealth(health)
|
|
22440
22439
|
};
|
|
22441
22440
|
}
|
|
22442
22441
|
|
|
@@ -23128,8 +23127,7 @@ function usePaperclipBoardAccessRequirement() {
|
|
|
23128
23127
|
const [state, setState] = useState2({
|
|
23129
23128
|
status: "loading",
|
|
23130
23129
|
required: false,
|
|
23131
|
-
settingsVisible: false
|
|
23132
|
-
githubTokenPropagationSettingsVisible: true
|
|
23130
|
+
settingsVisible: false
|
|
23133
23131
|
});
|
|
23134
23132
|
useEffect2(() => {
|
|
23135
23133
|
let cancelled = false;
|
|
@@ -23143,8 +23141,7 @@ function usePaperclipBoardAccessRequirement() {
|
|
|
23143
23141
|
setState({
|
|
23144
23142
|
status: "unknown",
|
|
23145
23143
|
required: policy2.boardAccessRequired,
|
|
23146
|
-
settingsVisible: policy2.boardAccessSettingsVisible
|
|
23147
|
-
githubTokenPropagationSettingsVisible: policy2.githubTokenPropagationSettingsVisible
|
|
23144
|
+
settingsVisible: policy2.boardAccessSettingsVisible
|
|
23148
23145
|
});
|
|
23149
23146
|
return;
|
|
23150
23147
|
}
|
|
@@ -23152,8 +23149,7 @@ function usePaperclipBoardAccessRequirement() {
|
|
|
23152
23149
|
setState({
|
|
23153
23150
|
status: policy.boardAccessRequired ? "required" : "not_required",
|
|
23154
23151
|
required: policy.boardAccessRequired,
|
|
23155
|
-
settingsVisible: policy.boardAccessSettingsVisible
|
|
23156
|
-
githubTokenPropagationSettingsVisible: policy.githubTokenPropagationSettingsVisible
|
|
23152
|
+
settingsVisible: policy.boardAccessSettingsVisible
|
|
23157
23153
|
});
|
|
23158
23154
|
})();
|
|
23159
23155
|
return () => {
|
|
@@ -26978,12 +26974,6 @@ function normalizeIgnoredIssueAuthorUsernames(value) {
|
|
|
26978
26974
|
rawEntries.map((entry) => typeof entry === "string" ? normalizeGitHubUsername(entry) : null).filter((entry) => Boolean(entry))
|
|
26979
26975
|
)];
|
|
26980
26976
|
}
|
|
26981
|
-
function normalizeAgentIds(value) {
|
|
26982
|
-
const rawEntries = Array.isArray(value) ? value : [];
|
|
26983
|
-
return [...new Set(
|
|
26984
|
-
rawEntries.map((entry) => typeof entry === "string" && entry.trim() ? entry.trim() : null).filter((entry) => Boolean(entry))
|
|
26985
|
-
)].sort((left, right) => left.localeCompare(right));
|
|
26986
|
-
}
|
|
26987
26977
|
function normalizeAdvancedSettingsAssigneeOverride(record, keys2) {
|
|
26988
26978
|
const rawUserId = record[keys2.userId];
|
|
26989
26979
|
const userId = typeof rawUserId === "string" && rawUserId.trim() ? rawUserId.trim() : void 0;
|
|
@@ -27024,8 +27014,7 @@ function normalizeAdvancedSettings(value) {
|
|
|
27024
27014
|
userId: "approverAssigneeUserId"
|
|
27025
27015
|
}),
|
|
27026
27016
|
defaultStatus: normalizePaperclipIssueStatus(record.defaultStatus),
|
|
27027
|
-
ignoredIssueAuthorUsernames: "ignoredIssueAuthorUsernames" in record ? normalizeIgnoredIssueAuthorUsernames(record.ignoredIssueAuthorUsernames) : DEFAULT_ADVANCED_SETTINGS.ignoredIssueAuthorUsernames
|
|
27028
|
-
...normalizeAgentIds(record.githubTokenPropagationAgentIds).length > 0 ? { githubTokenPropagationAgentIds: normalizeAgentIds(record.githubTokenPropagationAgentIds) } : {}
|
|
27017
|
+
ignoredIssueAuthorUsernames: "ignoredIssueAuthorUsernames" in record ? normalizeIgnoredIssueAuthorUsernames(record.ignoredIssueAuthorUsernames) : DEFAULT_ADVANCED_SETTINGS.ignoredIssueAuthorUsernames
|
|
27029
27018
|
};
|
|
27030
27019
|
}
|
|
27031
27020
|
function getComparableMappings(mappings) {
|
|
@@ -27049,8 +27038,7 @@ function getComparableAdvancedSettings(value) {
|
|
|
27049
27038
|
...settings.approverAssigneeAgentId ? { approverAssigneeAgentId: settings.approverAssigneeAgentId } : {},
|
|
27050
27039
|
...settings.approverAssigneeUserId ? { approverAssigneeUserId: settings.approverAssigneeUserId } : {},
|
|
27051
27040
|
defaultStatus: settings.defaultStatus,
|
|
27052
|
-
ignoredIssueAuthorUsernames: [...settings.ignoredIssueAuthorUsernames].sort((left, right) => left.localeCompare(right))
|
|
27053
|
-
...settings.githubTokenPropagationAgentIds?.length ? { githubTokenPropagationAgentIds: [...settings.githubTokenPropagationAgentIds].sort((left, right) => left.localeCompare(right)) } : {}
|
|
27041
|
+
ignoredIssueAuthorUsernames: [...settings.ignoredIssueAuthorUsernames].sort((left, right) => left.localeCompare(right))
|
|
27054
27042
|
};
|
|
27055
27043
|
}
|
|
27056
27044
|
function formatAssigneeOptionLabel(option) {
|
|
@@ -27141,21 +27129,7 @@ function getAvailableAssigneeOptions(options, selectedAssignees) {
|
|
|
27141
27129
|
}
|
|
27142
27130
|
return normalizedOptions.sort(compareAssigneeOptions);
|
|
27143
27131
|
}
|
|
27144
|
-
function
|
|
27145
|
-
const normalizedOptions = [...(options ?? []).filter((option) => option.kind === "agent")];
|
|
27146
|
-
const selectedIds = normalizeAgentIds(selectedAgentIds);
|
|
27147
|
-
for (const selectedAgentId of selectedIds) {
|
|
27148
|
-
if (!normalizedOptions.some((option) => option.id === selectedAgentId)) {
|
|
27149
|
-
normalizedOptions.push({
|
|
27150
|
-
kind: "agent",
|
|
27151
|
-
id: selectedAgentId,
|
|
27152
|
-
name: "Unavailable agent"
|
|
27153
|
-
});
|
|
27154
|
-
}
|
|
27155
|
-
}
|
|
27156
|
-
return normalizedOptions.sort(compareAssigneeOptions);
|
|
27157
|
-
}
|
|
27158
|
-
function formatAdvancedSettingsSummary(advancedSettings, availableAssignees, options) {
|
|
27132
|
+
function formatAdvancedSettingsSummary(advancedSettings, availableAssignees) {
|
|
27159
27133
|
const resolveAssigneeLabel = (principal, fallbackLabel = "None") => {
|
|
27160
27134
|
return principal ? formatAssigneeOptionLabel(
|
|
27161
27135
|
availableAssignees.find((option) => getAssigneeOptionKey(option) === getAssigneeOptionKey(principal)) ?? {
|
|
@@ -27172,10 +27146,6 @@ function formatAdvancedSettingsSummary(advancedSettings, availableAssignees, opt
|
|
|
27172
27146
|
const statusLabel = PAPERCLIP_STATUS_OPTIONS.find((option) => option.value === advancedSettings.defaultStatus)?.label ?? "Backlog";
|
|
27173
27147
|
const ignoredAuthorsLabel = advancedSettings.ignoredIssueAuthorUsernames.length > 0 ? advancedSettings.ignoredIssueAuthorUsernames.join(", ") : "none";
|
|
27174
27148
|
const handoffLabel = `Back to work: ${executorLabel} \xB7 Review: ${reviewerLabel} \xB7 Approval: ${approverLabel}`;
|
|
27175
|
-
if (options?.includePropagation) {
|
|
27176
|
-
const propagatedAgentsLabel = advancedSettings.githubTokenPropagationAgentIds?.length ? `${advancedSettings.githubTokenPropagationAgentIds.length} selected` : "none";
|
|
27177
|
-
return `Import: ${assigneeLabel} \xB7 ${handoffLabel} \xB7 Status: ${statusLabel} \xB7 Ignore: ${ignoredAuthorsLabel} \xB7 Propagate: ${propagatedAgentsLabel}`;
|
|
27178
|
-
}
|
|
27179
27149
|
return `Import: ${assigneeLabel} \xB7 ${handoffLabel} \xB7 Status: ${statusLabel} \xB7 Ignore: ${ignoredAuthorsLabel}`;
|
|
27180
27150
|
}
|
|
27181
27151
|
function resolveSavedTokenUiState(params) {
|
|
@@ -27194,19 +27164,6 @@ function resolveSavedTokenUiState(params) {
|
|
|
27194
27164
|
validatedLogin: null
|
|
27195
27165
|
};
|
|
27196
27166
|
}
|
|
27197
|
-
function formatAgentMultiSelectionLabel(values, options) {
|
|
27198
|
-
if (values.length === 0) {
|
|
27199
|
-
return "No agents selected";
|
|
27200
|
-
}
|
|
27201
|
-
const labels = values.map((value) => options.find((option) => option.value === value)?.label ?? "Unavailable agent").filter((label) => label.trim().length > 0);
|
|
27202
|
-
if (labels.length === 0) {
|
|
27203
|
-
return "No agents selected";
|
|
27204
|
-
}
|
|
27205
|
-
if (labels.length <= 2) {
|
|
27206
|
-
return labels.join(", ");
|
|
27207
|
-
}
|
|
27208
|
-
return `${labels.length} agents selected`;
|
|
27209
|
-
}
|
|
27210
27167
|
function PickerChevronIcon() {
|
|
27211
27168
|
return /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("path", { d: "M4 6.5L8 10.5L12 6.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
27212
27169
|
}
|
|
@@ -27384,122 +27341,6 @@ function SettingsAssigneePicker(props) {
|
|
|
27384
27341
|
] }) : null
|
|
27385
27342
|
] });
|
|
27386
27343
|
}
|
|
27387
|
-
function SettingsAgentMultiPicker(props) {
|
|
27388
|
-
const { id, values, options, disabled, onChange } = props;
|
|
27389
|
-
const [open, setOpen] = useState2(false);
|
|
27390
|
-
const [query, setQuery] = useState2("");
|
|
27391
|
-
const rootRef = useRef(null);
|
|
27392
|
-
const searchInputRef = useRef(null);
|
|
27393
|
-
const selectedValues = normalizeAgentIds(values);
|
|
27394
|
-
const selectedValueSet = new Set(selectedValues);
|
|
27395
|
-
const normalizedQuery = query.trim().toLowerCase();
|
|
27396
|
-
const filteredOptions = normalizedQuery ? options.filter((option) => option.label.toLowerCase().includes(normalizedQuery)) : options;
|
|
27397
|
-
const selectedLabel = formatAgentMultiSelectionLabel(selectedValues, options);
|
|
27398
|
-
useEffect2(() => {
|
|
27399
|
-
if (!open) {
|
|
27400
|
-
setQuery("");
|
|
27401
|
-
return;
|
|
27402
|
-
}
|
|
27403
|
-
const handlePointerDown = (event) => {
|
|
27404
|
-
const target = event.target;
|
|
27405
|
-
if (target instanceof Node && rootRef.current?.contains(target)) {
|
|
27406
|
-
return;
|
|
27407
|
-
}
|
|
27408
|
-
setOpen(false);
|
|
27409
|
-
};
|
|
27410
|
-
const handleKeyDown = (event) => {
|
|
27411
|
-
if (event.key === "Escape") {
|
|
27412
|
-
setOpen(false);
|
|
27413
|
-
}
|
|
27414
|
-
};
|
|
27415
|
-
document.addEventListener("pointerdown", handlePointerDown);
|
|
27416
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
27417
|
-
globalThis.setTimeout(() => {
|
|
27418
|
-
searchInputRef.current?.focus();
|
|
27419
|
-
searchInputRef.current?.select();
|
|
27420
|
-
}, 0);
|
|
27421
|
-
return () => {
|
|
27422
|
-
document.removeEventListener("pointerdown", handlePointerDown);
|
|
27423
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
27424
|
-
};
|
|
27425
|
-
}, [open]);
|
|
27426
|
-
useEffect2(() => {
|
|
27427
|
-
if (disabled && open) {
|
|
27428
|
-
setOpen(false);
|
|
27429
|
-
}
|
|
27430
|
-
}, [disabled, open]);
|
|
27431
|
-
return /* @__PURE__ */ jsxs2("div", { className: "ghsync__picker ghsync__picker--full", ref: rootRef, children: [
|
|
27432
|
-
/* @__PURE__ */ jsxs2(
|
|
27433
|
-
"button",
|
|
27434
|
-
{
|
|
27435
|
-
id,
|
|
27436
|
-
type: "button",
|
|
27437
|
-
className: "ghsync__picker-trigger ghsync__picker-trigger--assignee",
|
|
27438
|
-
disabled,
|
|
27439
|
-
"aria-haspopup": "dialog",
|
|
27440
|
-
"aria-expanded": open,
|
|
27441
|
-
onClick: () => {
|
|
27442
|
-
if (disabled) {
|
|
27443
|
-
return;
|
|
27444
|
-
}
|
|
27445
|
-
setOpen((current) => !current);
|
|
27446
|
-
},
|
|
27447
|
-
children: [
|
|
27448
|
-
/* @__PURE__ */ jsxs2("span", { className: "ghsync__picker-trigger-main", children: [
|
|
27449
|
-
/* @__PURE__ */ jsx2("span", { className: "ghsync__picker-agent-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(AgentIcon, {}) }),
|
|
27450
|
-
/* @__PURE__ */ jsx2("span", { className: "ghsync__picker-trigger-label", children: selectedLabel })
|
|
27451
|
-
] }),
|
|
27452
|
-
/* @__PURE__ */ jsx2("span", { className: "ghsync__picker-trigger-icon", children: /* @__PURE__ */ jsx2(PickerChevronIcon, {}) })
|
|
27453
|
-
]
|
|
27454
|
-
}
|
|
27455
|
-
),
|
|
27456
|
-
open ? /* @__PURE__ */ jsxs2("div", { className: "ghsync__picker-panel ghsync__picker-panel--assignee", role: "dialog", "aria-label": "Choose agents", children: [
|
|
27457
|
-
/* @__PURE__ */ jsx2("div", { className: "ghsync__picker-search", children: /* @__PURE__ */ jsx2(
|
|
27458
|
-
"input",
|
|
27459
|
-
{
|
|
27460
|
-
ref: searchInputRef,
|
|
27461
|
-
type: "text",
|
|
27462
|
-
className: "ghsync__picker-search-input",
|
|
27463
|
-
placeholder: "Search agents...",
|
|
27464
|
-
value: query,
|
|
27465
|
-
onChange: (event) => {
|
|
27466
|
-
setQuery(event.currentTarget.value);
|
|
27467
|
-
},
|
|
27468
|
-
onKeyDown: (event) => {
|
|
27469
|
-
if (event.key === "Escape") {
|
|
27470
|
-
event.preventDefault();
|
|
27471
|
-
setOpen(false);
|
|
27472
|
-
}
|
|
27473
|
-
}
|
|
27474
|
-
}
|
|
27475
|
-
) }),
|
|
27476
|
-
/* @__PURE__ */ jsx2("div", { className: "ghsync__picker-list", role: "listbox", "aria-labelledby": id, "aria-multiselectable": "true", children: filteredOptions.length > 0 ? filteredOptions.map((option) => {
|
|
27477
|
-
const selected = selectedValueSet.has(option.value);
|
|
27478
|
-
return /* @__PURE__ */ jsxs2(
|
|
27479
|
-
"button",
|
|
27480
|
-
{
|
|
27481
|
-
type: "button",
|
|
27482
|
-
role: "option",
|
|
27483
|
-
"aria-selected": selected,
|
|
27484
|
-
className: `ghsync__picker-option${selected ? " ghsync__picker-option--selected" : ""}`,
|
|
27485
|
-
onClick: () => {
|
|
27486
|
-
const nextValues = selected ? selectedValues.filter((value) => value !== option.value) : normalizeAgentIds([...selectedValues, option.value]);
|
|
27487
|
-
onChange(nextValues);
|
|
27488
|
-
},
|
|
27489
|
-
children: [
|
|
27490
|
-
/* @__PURE__ */ jsxs2("span", { className: "ghsync__picker-trigger-main", children: [
|
|
27491
|
-
option.icon ? /* @__PURE__ */ jsx2("span", { className: "ghsync__picker-agent-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(SettingsSelectIcon, { icon: option.icon }) }) : null,
|
|
27492
|
-
/* @__PURE__ */ jsx2("span", { className: "ghsync__picker-option-label", children: option.label })
|
|
27493
|
-
] }),
|
|
27494
|
-
/* @__PURE__ */ jsx2("span", { className: "ghsync__picker-option-check", "aria-hidden": "true", children: selected ? /* @__PURE__ */ jsx2(PickerCheckIcon, {}) : null })
|
|
27495
|
-
]
|
|
27496
|
-
},
|
|
27497
|
-
option.value
|
|
27498
|
-
);
|
|
27499
|
-
}) : /* @__PURE__ */ jsx2("div", { className: "ghsync__picker-empty", children: "No agents match." }) })
|
|
27500
|
-
] }) : null
|
|
27501
|
-
] });
|
|
27502
|
-
}
|
|
27503
27344
|
function SettingsStatusPicker(props) {
|
|
27504
27345
|
const { id, value, options, disabled, onChange } = props;
|
|
27505
27346
|
const [open, setOpen] = useState2(false);
|
|
@@ -28512,137 +28353,6 @@ async function patchPluginConfig(pluginId, patch5) {
|
|
|
28512
28353
|
await writePluginConfig(pluginId, safeConfig);
|
|
28513
28354
|
}
|
|
28514
28355
|
}
|
|
28515
|
-
var GITHUB_TOKEN_PROPAGATION_CONCURRENCY_LIMIT = 4;
|
|
28516
|
-
function normalizeAgentAdapterConfig(value) {
|
|
28517
|
-
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : {};
|
|
28518
|
-
}
|
|
28519
|
-
function normalizeAgentEnvBindings(value) {
|
|
28520
|
-
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : {};
|
|
28521
|
-
}
|
|
28522
|
-
function isMatchingSecretRefEnvBinding(value, secretId) {
|
|
28523
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
28524
|
-
return false;
|
|
28525
|
-
}
|
|
28526
|
-
const record = value;
|
|
28527
|
-
return record.type === "secret_ref" && record.secretId === secretId;
|
|
28528
|
-
}
|
|
28529
|
-
function getAgentPropagationPatch(params) {
|
|
28530
|
-
const adapterConfig = normalizeAgentAdapterConfig(params.adapterConfig);
|
|
28531
|
-
const currentEnv = normalizeAgentEnvBindings(adapterConfig.env);
|
|
28532
|
-
if (params.mode === "ensure") {
|
|
28533
|
-
const nextEnv2 = {
|
|
28534
|
-
...currentEnv,
|
|
28535
|
-
GITHUB_TOKEN: {
|
|
28536
|
-
type: "secret_ref",
|
|
28537
|
-
secretId: params.githubTokenSecretRef,
|
|
28538
|
-
version: "latest"
|
|
28539
|
-
}
|
|
28540
|
-
};
|
|
28541
|
-
if (JSON.stringify(nextEnv2) === JSON.stringify(currentEnv)) {
|
|
28542
|
-
return null;
|
|
28543
|
-
}
|
|
28544
|
-
return {
|
|
28545
|
-
...adapterConfig,
|
|
28546
|
-
env: nextEnv2
|
|
28547
|
-
};
|
|
28548
|
-
}
|
|
28549
|
-
if (!isMatchingSecretRefEnvBinding(currentEnv.GITHUB_TOKEN, params.githubTokenSecretRef)) {
|
|
28550
|
-
return null;
|
|
28551
|
-
}
|
|
28552
|
-
const nextEnv = { ...currentEnv };
|
|
28553
|
-
delete nextEnv.GITHUB_TOKEN;
|
|
28554
|
-
const nextAdapterConfig = {
|
|
28555
|
-
...adapterConfig
|
|
28556
|
-
};
|
|
28557
|
-
if (Object.keys(nextEnv).length > 0) {
|
|
28558
|
-
nextAdapterConfig.env = nextEnv;
|
|
28559
|
-
} else {
|
|
28560
|
-
delete nextAdapterConfig.env;
|
|
28561
|
-
}
|
|
28562
|
-
return nextAdapterConfig;
|
|
28563
|
-
}
|
|
28564
|
-
async function runWithConcurrencyLimit(items, concurrencyLimit, worker) {
|
|
28565
|
-
if (items.length === 0) {
|
|
28566
|
-
return;
|
|
28567
|
-
}
|
|
28568
|
-
let nextIndex = 0;
|
|
28569
|
-
const runnerCount = Math.min(concurrencyLimit, items.length);
|
|
28570
|
-
await Promise.all(
|
|
28571
|
-
Array.from({ length: runnerCount }, async () => {
|
|
28572
|
-
while (nextIndex < items.length) {
|
|
28573
|
-
const currentIndex = nextIndex;
|
|
28574
|
-
nextIndex += 1;
|
|
28575
|
-
await worker(items[currentIndex]);
|
|
28576
|
-
}
|
|
28577
|
-
})
|
|
28578
|
-
);
|
|
28579
|
-
}
|
|
28580
|
-
async function applyGitHubTokenPropagationUpdate(params) {
|
|
28581
|
-
const agent = await fetchJson(`/api/agents/${params.agentId}`);
|
|
28582
|
-
const nextAdapterConfig = getAgentPropagationPatch({
|
|
28583
|
-
adapterConfig: agent?.adapterConfig,
|
|
28584
|
-
githubTokenSecretRef: params.githubTokenSecretRef,
|
|
28585
|
-
mode: params.mode
|
|
28586
|
-
});
|
|
28587
|
-
if (!nextAdapterConfig) {
|
|
28588
|
-
return;
|
|
28589
|
-
}
|
|
28590
|
-
await fetchJson(`/api/agents/${params.agentId}`, {
|
|
28591
|
-
method: "PATCH",
|
|
28592
|
-
body: JSON.stringify({
|
|
28593
|
-
adapterConfig: nextAdapterConfig,
|
|
28594
|
-
replaceAdapterConfig: true
|
|
28595
|
-
})
|
|
28596
|
-
});
|
|
28597
|
-
}
|
|
28598
|
-
async function syncGitHubTokenPropagationForAgents(params) {
|
|
28599
|
-
const selectedAgentIds = normalizeAgentIds(params.selectedAgentIds);
|
|
28600
|
-
const selectedAgentIdSet = new Set(selectedAgentIds);
|
|
28601
|
-
const previousAgentIds = normalizeAgentIds(params.previousAgentIds);
|
|
28602
|
-
const failures = /* @__PURE__ */ new Set();
|
|
28603
|
-
const operations = [
|
|
28604
|
-
...selectedAgentIds.map((agentId) => ({ agentId, mode: "ensure" })),
|
|
28605
|
-
...previousAgentIds.filter((agentId) => !selectedAgentIdSet.has(agentId)).map((agentId) => ({ agentId, mode: "remove" }))
|
|
28606
|
-
];
|
|
28607
|
-
await runWithConcurrencyLimit(
|
|
28608
|
-
operations,
|
|
28609
|
-
GITHUB_TOKEN_PROPAGATION_CONCURRENCY_LIMIT,
|
|
28610
|
-
async (operation) => {
|
|
28611
|
-
try {
|
|
28612
|
-
await applyGitHubTokenPropagationUpdate({
|
|
28613
|
-
agentId: operation.agentId,
|
|
28614
|
-
githubTokenSecretRef: params.githubTokenSecretRef,
|
|
28615
|
-
mode: operation.mode
|
|
28616
|
-
});
|
|
28617
|
-
} catch {
|
|
28618
|
-
failures.add(operation.agentId);
|
|
28619
|
-
}
|
|
28620
|
-
}
|
|
28621
|
-
);
|
|
28622
|
-
if (failures.size > 0) {
|
|
28623
|
-
throw new Error(
|
|
28624
|
-
`GitHub token propagation could not update these agents: ${[...failures].join(", ")}.`
|
|
28625
|
-
);
|
|
28626
|
-
}
|
|
28627
|
-
}
|
|
28628
|
-
function normalizeTrimmedString(value) {
|
|
28629
|
-
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
28630
|
-
}
|
|
28631
|
-
function resolveGitHubTokenSecretRefForPropagation(params) {
|
|
28632
|
-
const explicitSecretRef = normalizeTrimmedString(params.explicitSecretRef);
|
|
28633
|
-
if (explicitSecretRef) {
|
|
28634
|
-
return explicitSecretRef;
|
|
28635
|
-
}
|
|
28636
|
-
const settingsSecretRef = normalizeTrimmedString(params.settingsSecretRef);
|
|
28637
|
-
if (settingsSecretRef) {
|
|
28638
|
-
return settingsSecretRef;
|
|
28639
|
-
}
|
|
28640
|
-
const companyId = normalizeTrimmedString(params.companyId);
|
|
28641
|
-
if (!companyId || !params.pluginConfig) {
|
|
28642
|
-
return void 0;
|
|
28643
|
-
}
|
|
28644
|
-
return normalizePluginConfig(params.pluginConfig).githubTokenRefs?.[companyId];
|
|
28645
|
-
}
|
|
28646
28356
|
function normalizeCliAuthPollIntervalMs(value) {
|
|
28647
28357
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
28648
28358
|
return CLI_AUTH_POLL_INTERVAL_FALLBACK_MS;
|
|
@@ -32263,14 +31973,6 @@ function GitHubSyncSettingsPage() {
|
|
|
32263
31973
|
[companyId]: secretRef
|
|
32264
31974
|
}
|
|
32265
31975
|
});
|
|
32266
|
-
const selectedAgentIds = normalizeAgentIds(settings.data?.advancedSettings?.githubTokenPropagationAgentIds);
|
|
32267
|
-
if (selectedAgentIds.length > 0) {
|
|
32268
|
-
await propagateGitHubTokenToSelectedAgents({
|
|
32269
|
-
selectedAgentIds,
|
|
32270
|
-
previousAgentIds: selectedAgentIds,
|
|
32271
|
-
githubTokenSecretRef: secretRef
|
|
32272
|
-
});
|
|
32273
|
-
}
|
|
32274
31976
|
if (cancelled) {
|
|
32275
31977
|
return;
|
|
32276
31978
|
}
|
|
@@ -32304,7 +32006,6 @@ function GitHubSyncSettingsPage() {
|
|
|
32304
32006
|
}, [
|
|
32305
32007
|
hostContext.companyId,
|
|
32306
32008
|
pluginIdFromLocation,
|
|
32307
|
-
settings.data?.advancedSettings?.githubTokenPropagationAgentIds,
|
|
32308
32009
|
settings.data?.githubTokenNeedsConfigSync,
|
|
32309
32010
|
settings.data?.githubTokenConfigSyncRef,
|
|
32310
32011
|
settings.refresh,
|
|
@@ -32438,7 +32139,6 @@ function GitHubSyncSettingsPage() {
|
|
|
32438
32139
|
const boardAccessConfigured = Boolean(form.paperclipBoardAccessConfigured);
|
|
32439
32140
|
const boardAccessRequired = boardAccessRequirement.required;
|
|
32440
32141
|
const boardAccessSettingsVisible = boardAccessRequirement.settingsVisible;
|
|
32441
|
-
const githubTokenPropagationSettingsVisible = boardAccessRequirement.githubTokenPropagationSettingsVisible;
|
|
32442
32142
|
const boardAccessReady = !boardAccessRequired || hasCompanyContext && boardAccessConfigured;
|
|
32443
32143
|
const tokenStatus = tokenStatusOverride ?? (hasSavedToken ? "valid" : "required");
|
|
32444
32144
|
const tokenTone = tokenStatus === "valid" ? "success" : tokenStatus === "invalid" ? "danger" : "warning";
|
|
@@ -32466,10 +32166,6 @@ function GitHubSyncSettingsPage() {
|
|
|
32466
32166
|
getAdvancedSettingsAssigneePrincipal(form.advancedSettings, "approver")
|
|
32467
32167
|
]
|
|
32468
32168
|
);
|
|
32469
|
-
const propagationAgents = getAvailablePropagationAgentOptions(
|
|
32470
|
-
(currentSettings?.availableAssignees?.length ? currentSettings.availableAssignees : null) ?? (form.availableAssignees?.length ? form.availableAssignees : null) ?? browserAvailableAssignees,
|
|
32471
|
-
form.advancedSettings.githubTokenPropagationAgentIds
|
|
32472
|
-
);
|
|
32473
32169
|
const savedMappingsSource = currentSettings ? currentSettings.mappings ?? [] : form.mappings;
|
|
32474
32170
|
const savedMappings = getComparableMappings(savedMappingsSource);
|
|
32475
32171
|
const draftMappings = getComparableMappings(form.mappings);
|
|
@@ -32546,9 +32242,7 @@ function GitHubSyncSettingsPage() {
|
|
|
32546
32242
|
const manualSyncScopePillClass = hasCompanyContext ? "ghsync__scope-pill ghsync__scope-pill--company" : "ghsync__scope-pill ghsync__scope-pill--mixed";
|
|
32547
32243
|
const manualSyncScopePillLabel = hasCompanyContext ? "This company" : "All companies";
|
|
32548
32244
|
const manualSyncButtonLabel = hasCompanyContext ? "Run sync for this company" : "Run sync across all companies";
|
|
32549
|
-
const advancedSettingsSummary = formatAdvancedSettingsSummary(form.advancedSettings, availableAssignees
|
|
32550
|
-
includePropagation: githubTokenPropagationSettingsVisible
|
|
32551
|
-
});
|
|
32245
|
+
const advancedSettingsSummary = formatAdvancedSettingsSummary(form.advancedSettings, availableAssignees);
|
|
32552
32246
|
const assigneeSelectOptions = [
|
|
32553
32247
|
{ value: "", label: "Unassigned" },
|
|
32554
32248
|
...availableAssignees.map((option) => ({
|
|
@@ -32565,11 +32259,6 @@ function GitHubSyncSettingsPage() {
|
|
|
32565
32259
|
icon: option.kind
|
|
32566
32260
|
}))
|
|
32567
32261
|
];
|
|
32568
|
-
const propagationAgentOptions = propagationAgents.map((option) => ({
|
|
32569
|
-
value: option.id,
|
|
32570
|
-
label: formatAssigneeOptionLabel(option),
|
|
32571
|
-
icon: "agent"
|
|
32572
|
-
}));
|
|
32573
32262
|
const statusSelectOptions = PAPERCLIP_STATUS_OPTIONS.map((option) => ({
|
|
32574
32263
|
value: option.value,
|
|
32575
32264
|
label: option.label,
|
|
@@ -32700,41 +32389,6 @@ function GitHubSyncSettingsPage() {
|
|
|
32700
32389
|
};
|
|
32701
32390
|
});
|
|
32702
32391
|
}
|
|
32703
|
-
async function propagateGitHubTokenToSelectedAgents(options) {
|
|
32704
|
-
const selectedAgentIds = normalizeAgentIds(options.selectedAgentIds);
|
|
32705
|
-
const previousAgentIds = normalizeAgentIds(options.previousAgentIds);
|
|
32706
|
-
if (selectedAgentIds.length === 0 && previousAgentIds.length === 0) {
|
|
32707
|
-
return;
|
|
32708
|
-
}
|
|
32709
|
-
const companyId = hostContext.companyId;
|
|
32710
|
-
let githubTokenSecretRef = resolveGitHubTokenSecretRefForPropagation({
|
|
32711
|
-
explicitSecretRef: options.githubTokenSecretRef,
|
|
32712
|
-
settingsSecretRef: currentSettings?.githubTokenConfigSyncRef ?? settings.data?.githubTokenConfigSyncRef,
|
|
32713
|
-
companyId
|
|
32714
|
-
});
|
|
32715
|
-
if (!githubTokenSecretRef) {
|
|
32716
|
-
if (!companyId) {
|
|
32717
|
-
throw new Error("Company context is required to propagate the GitHub token.");
|
|
32718
|
-
}
|
|
32719
|
-
const pluginId = await resolveCurrentPluginId(pluginIdFromLocation);
|
|
32720
|
-
if (!pluginId) {
|
|
32721
|
-
throw new Error("Plugin id is required to propagate the GitHub token to selected agents.");
|
|
32722
|
-
}
|
|
32723
|
-
const currentConfigResponse = await fetchJson(`/api/plugins/${pluginId}/config`);
|
|
32724
|
-
githubTokenSecretRef = resolveGitHubTokenSecretRefForPropagation({
|
|
32725
|
-
companyId,
|
|
32726
|
-
pluginConfig: normalizePluginConfig(currentConfigResponse?.configJson)
|
|
32727
|
-
});
|
|
32728
|
-
}
|
|
32729
|
-
if (!githubTokenSecretRef) {
|
|
32730
|
-
throw new Error("GitHub token propagation requires a GitHub token saved through this settings page.");
|
|
32731
|
-
}
|
|
32732
|
-
await syncGitHubTokenPropagationForAgents({
|
|
32733
|
-
githubTokenSecretRef,
|
|
32734
|
-
selectedAgentIds,
|
|
32735
|
-
previousAgentIds
|
|
32736
|
-
});
|
|
32737
|
-
}
|
|
32738
32392
|
async function handleSaveToken(event) {
|
|
32739
32393
|
event.preventDefault();
|
|
32740
32394
|
setSubmittingToken(true);
|
|
@@ -32795,17 +32449,6 @@ function GitHubSyncSettingsPage() {
|
|
|
32795
32449
|
} catch (error) {
|
|
32796
32450
|
availabilityWarning = error;
|
|
32797
32451
|
}
|
|
32798
|
-
const selectedAgentIds = normalizeAgentIds(currentSettings?.advancedSettings?.githubTokenPropagationAgentIds);
|
|
32799
|
-
let propagationError = null;
|
|
32800
|
-
try {
|
|
32801
|
-
await propagateGitHubTokenToSelectedAgents({
|
|
32802
|
-
selectedAgentIds,
|
|
32803
|
-
previousAgentIds: selectedAgentIds,
|
|
32804
|
-
githubTokenSecretRef: secret.id
|
|
32805
|
-
});
|
|
32806
|
-
} catch (error) {
|
|
32807
|
-
propagationError = error;
|
|
32808
|
-
}
|
|
32809
32452
|
setForm((current) => ({
|
|
32810
32453
|
...current,
|
|
32811
32454
|
githubTokenConfigured: true
|
|
@@ -32820,16 +32463,6 @@ function GitHubSyncSettingsPage() {
|
|
|
32820
32463
|
body: "Token saved.",
|
|
32821
32464
|
tone: "success"
|
|
32822
32465
|
});
|
|
32823
|
-
if (propagationError) {
|
|
32824
|
-
toast({
|
|
32825
|
-
title: "GitHub token saved, but agent propagation needs attention",
|
|
32826
|
-
body: getActionErrorMessage(
|
|
32827
|
-
propagationError,
|
|
32828
|
-
"GitHub Sync could not update the selected agents with the saved token."
|
|
32829
|
-
),
|
|
32830
|
-
tone: "error"
|
|
32831
|
-
});
|
|
32832
|
-
}
|
|
32833
32466
|
if (availabilityWarning) {
|
|
32834
32467
|
toast({
|
|
32835
32468
|
title: "GitHub token saved, but worker token access needs attention",
|
|
@@ -32992,21 +32625,6 @@ function GitHubSyncSettingsPage() {
|
|
|
32992
32625
|
scheduleFrequencyMinutes,
|
|
32993
32626
|
...trustedPaperclipApiBaseUrl ? { paperclipApiBaseUrl: trustedPaperclipApiBaseUrl } : {}
|
|
32994
32627
|
});
|
|
32995
|
-
let propagationError = null;
|
|
32996
|
-
try {
|
|
32997
|
-
const githubTokenSecretRef = resolveGitHubTokenSecretRefForPropagation({
|
|
32998
|
-
explicitSecretRef: result.githubTokenConfigSyncRef,
|
|
32999
|
-
settingsSecretRef: currentSettings?.githubTokenConfigSyncRef ?? settings.data?.githubTokenConfigSyncRef,
|
|
33000
|
-
companyId
|
|
33001
|
-
});
|
|
33002
|
-
await propagateGitHubTokenToSelectedAgents({
|
|
33003
|
-
selectedAgentIds: normalizeAgentIds(normalizeAdvancedSettings(result.advancedSettings).githubTokenPropagationAgentIds),
|
|
33004
|
-
previousAgentIds: normalizeAgentIds(currentSettings?.advancedSettings?.githubTokenPropagationAgentIds),
|
|
33005
|
-
githubTokenSecretRef
|
|
33006
|
-
});
|
|
33007
|
-
} catch (error) {
|
|
33008
|
-
propagationError = error;
|
|
33009
|
-
}
|
|
33010
32628
|
setForm((current) => ({
|
|
33011
32629
|
...current,
|
|
33012
32630
|
mappings: result.mappings.length > 0 ? result.mappings : [createEmptyMapping(0)],
|
|
@@ -33025,16 +32643,6 @@ function GitHubSyncSettingsPage() {
|
|
|
33025
32643
|
body: `Advanced defaults, mappings, and automatic sync are saved for ${currentCompanyName}.`,
|
|
33026
32644
|
tone: "success"
|
|
33027
32645
|
});
|
|
33028
|
-
if (propagationError) {
|
|
33029
|
-
toast({
|
|
33030
|
-
title: "Settings saved, but agent propagation needs attention",
|
|
33031
|
-
body: getActionErrorMessage(
|
|
33032
|
-
propagationError,
|
|
33033
|
-
"GitHub Sync could not apply the selected agent token propagation updates."
|
|
33034
|
-
),
|
|
33035
|
-
tone: "error"
|
|
33036
|
-
});
|
|
33037
|
-
}
|
|
33038
32646
|
notifyGitHubSyncSettingsChanged();
|
|
33039
32647
|
try {
|
|
33040
32648
|
await settings.refresh();
|
|
@@ -33617,29 +33225,7 @@ function GitHubSyncSettingsPage() {
|
|
|
33617
33225
|
}
|
|
33618
33226
|
),
|
|
33619
33227
|
/* @__PURE__ */ jsx2("p", { className: "ghsync__hint", children: "Comma or newline separated." })
|
|
33620
|
-
] })
|
|
33621
|
-
githubTokenPropagationSettingsVisible ? /* @__PURE__ */ jsxs2("div", { className: "ghsync__field", children: [
|
|
33622
|
-
/* @__PURE__ */ jsx2("label", { htmlFor: "advanced-token-propagation", children: "Propagate GitHub token to agents" }),
|
|
33623
|
-
/* @__PURE__ */ jsx2(
|
|
33624
|
-
SettingsAgentMultiPicker,
|
|
33625
|
-
{
|
|
33626
|
-
id: "advanced-token-propagation",
|
|
33627
|
-
values: form.advancedSettings.githubTokenPropagationAgentIds ?? [],
|
|
33628
|
-
options: propagationAgentOptions,
|
|
33629
|
-
disabled: settingsMutationsLocked || tokenStatus !== "valid",
|
|
33630
|
-
onChange: (nextValues) => {
|
|
33631
|
-
setForm((current) => ({
|
|
33632
|
-
...current,
|
|
33633
|
-
advancedSettings: {
|
|
33634
|
-
...current.advancedSettings,
|
|
33635
|
-
...nextValues.length > 0 ? { githubTokenPropagationAgentIds: nextValues } : { githubTokenPropagationAgentIds: void 0 }
|
|
33636
|
-
}
|
|
33637
|
-
}));
|
|
33638
|
-
}
|
|
33639
|
-
}
|
|
33640
|
-
),
|
|
33641
|
-
/* @__PURE__ */ jsx2("p", { className: "ghsync__hint", children: tokenStatus === "valid" ? "Selected agents receive `GITHUB_TOKEN` from the saved GitHub secret when you save settings." : "Save a valid GitHub token before choosing agents to propagate it to." })
|
|
33642
|
-
] }) : null
|
|
33228
|
+
] })
|
|
33643
33229
|
] }) : null
|
|
33644
33230
|
] }),
|
|
33645
33231
|
/* @__PURE__ */ jsxs2("section", { className: "ghsync__section", children: [
|
|
@@ -35451,12 +35037,10 @@ export {
|
|
|
35451
35037
|
patchPluginConfig,
|
|
35452
35038
|
resolveGitHubIssueDetailTabState,
|
|
35453
35039
|
resolveGitHubIssueTaskDetailContext,
|
|
35454
|
-
resolveGitHubTokenSecretRefForPropagation,
|
|
35455
35040
|
resolveOrCreateProject,
|
|
35456
35041
|
resolvePreviewPersonLabels,
|
|
35457
35042
|
resolveSavedTokenUiState,
|
|
35458
35043
|
resolveToolbarButtonState,
|
|
35459
|
-
shouldExpectGitHubIssueTaskDetailContext
|
|
35460
|
-
syncGitHubTokenPropagationForAgents
|
|
35044
|
+
shouldExpectGitHubIssueTaskDetailContext
|
|
35461
35045
|
};
|
|
35462
35046
|
//# sourceMappingURL=index.js.map
|