paperclip-github-plugin 0.17.1 → 0.17.3
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 +131 -1
- package/dist/manifest.js +1 -1
- package/dist/ui/index.js +246 -81
- package/dist/ui/index.js.map +4 -4
- package/dist/worker.js +237 -66
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -1075,6 +1075,7 @@ var ISSUE_INTERACTION_REASON_CODES = /* @__PURE__ */ new Set([
|
|
|
1075
1075
|
"github_sync_status_decision"
|
|
1076
1076
|
]);
|
|
1077
1077
|
var ISSUE_INTERACTION_MAX_SCAN_ROWS = 5e3;
|
|
1078
|
+
var ISSUE_INTERACTION_MAX_LIST_ROWS = 2e4;
|
|
1078
1079
|
var ISSUE_INTERACTION_MAX_REPEATED_ACTIONS = 10;
|
|
1079
1080
|
var SOURCES = /* @__PURE__ */ new Set(["agent_tool", "sync", "api_route", "operator_action", "backfill"]);
|
|
1080
1081
|
var OUTCOMES = /* @__PURE__ */ new Set(["observed", "changed", "noop", "failed"]);
|
|
@@ -9184,6 +9185,12 @@ function getPaperclipHealthEndpoint(baseUrl) {
|
|
|
9184
9185
|
function getPaperclipAgentWakeupEndpoint(baseUrl, agentId) {
|
|
9185
9186
|
return new URL(`/api/agents/${agentId}/wakeup`, baseUrl).toString();
|
|
9186
9187
|
}
|
|
9188
|
+
function getPaperclipEffectiveAgentToolProfilesEndpoint(baseUrl, companyId, agentId) {
|
|
9189
|
+
return new URL(
|
|
9190
|
+
`/api/companies/${encodeURIComponent(companyId)}/tools/profiles/effective/agents/${encodeURIComponent(agentId)}`,
|
|
9191
|
+
baseUrl
|
|
9192
|
+
).toString();
|
|
9193
|
+
}
|
|
9187
9194
|
function getActivePaperclipApiAuthToken(companyId) {
|
|
9188
9195
|
if (!companyId) {
|
|
9189
9196
|
return void 0;
|
|
@@ -11230,7 +11237,7 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
|
|
|
11230
11237
|
importedIssue.remoteActionFingerprint = remoteActionFingerprint;
|
|
11231
11238
|
importedIssue.selectedPullRequestGate = effectiveGate ? { repositoryUrl: effectiveGate.repositoryUrl, number: effectiveGate.number } : void 0;
|
|
11232
11239
|
if (pendingWake2) importedIssue.pendingRemoteActionWake = pendingWake2;
|
|
11233
|
-
|
|
11240
|
+
delete importedIssue.activationPending;
|
|
11234
11241
|
await persistImportRegistry();
|
|
11235
11242
|
};
|
|
11236
11243
|
if (paperclipIssue.status === nextStatus) {
|
|
@@ -11248,24 +11255,28 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
|
|
|
11248
11255
|
}, createWakeFingerprint) : void 0;
|
|
11249
11256
|
if (pendingWake2) importedIssue.pendingRemoteActionWake = pendingWake2;
|
|
11250
11257
|
if (pendingWake2 || isPendingInitialActivation) await persistImportRegistry();
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11258
|
+
const shouldClearExecutionPolicy = (shouldPreserveMaintainerWaitRouting || shouldClearCompletedExecutionPolicy) && Boolean(paperclipIssueSyncContext.executionPolicy);
|
|
11259
|
+
const hasStatusMutation = nextAssigneeChanged || shouldClearTransitionAssignee || shouldClearExecutionPolicy;
|
|
11260
|
+
if (hasStatusMutation) {
|
|
11261
|
+
updateSyncFailureContext(syncFailureContext, {
|
|
11262
|
+
phase: "updating_paperclip_status",
|
|
11263
|
+
repositoryUrl: repository.url,
|
|
11264
|
+
githubIssueNumber: githubIssue.number
|
|
11265
|
+
});
|
|
11266
|
+
await updatePaperclipIssueState(ctx, {
|
|
11267
|
+
companyId: mapping.companyId,
|
|
11268
|
+
issueId: importedIssue.paperclipIssueId,
|
|
11269
|
+
currentStatus: paperclipIssue.status,
|
|
11270
|
+
syncContext: paperclipIssueSyncContext,
|
|
11271
|
+
nextStatus,
|
|
11272
|
+
...nextAssigneeChanged && nextTransitionAssignee ? { nextAssignee: nextTransitionAssignee.principal } : {},
|
|
11273
|
+
...shouldClearTransitionAssignee ? { clearAssignee: true } : {},
|
|
11274
|
+
...shouldClearExecutionPolicy ? { clearExecutionPolicy: true } : {},
|
|
11275
|
+
transitionComment: "",
|
|
11276
|
+
actionFingerprint: actionJournalFingerprint,
|
|
11277
|
+
paperclipApiBaseUrl
|
|
11278
|
+
});
|
|
11279
|
+
}
|
|
11269
11280
|
if (pendingWake2) {
|
|
11270
11281
|
await persistObservedRemoteState(pendingWake2);
|
|
11271
11282
|
queuedIssueWakeups.push({
|
|
@@ -11795,7 +11806,7 @@ function mergeRememberedTrustedConfig() {
|
|
|
11795
11806
|
}
|
|
11796
11807
|
return merged;
|
|
11797
11808
|
}
|
|
11798
|
-
async function readTrustedConfig(ctx, companyId) {
|
|
11809
|
+
async function readTrustedConfig(ctx, companyId, options = {}) {
|
|
11799
11810
|
const normalizedCompanyId = normalizeCompanyId(companyId);
|
|
11800
11811
|
try {
|
|
11801
11812
|
const value = await ctx.config.get(normalizedCompanyId);
|
|
@@ -11806,6 +11817,9 @@ async function readTrustedConfig(ctx, companyId) {
|
|
|
11806
11817
|
return record;
|
|
11807
11818
|
} catch (error) {
|
|
11808
11819
|
const remembered = normalizedCompanyId ? rememberedTrustedConfigByCompanyId.get(normalizedCompanyId) : mergeRememberedTrustedConfig();
|
|
11820
|
+
if (options.requireCompanyScope && normalizedCompanyId && !remembered && isCompanyScopeDeniedError(error)) {
|
|
11821
|
+
throw error;
|
|
11822
|
+
}
|
|
11809
11823
|
const warningKey = `${normalizedCompanyId ?? "<instance>"}:${getErrorMessage(error)}`;
|
|
11810
11824
|
if (!reportedTrustedConfigReadFailures.has(warningKey)) {
|
|
11811
11825
|
reportedTrustedConfigReadFailures.add(warningKey);
|
|
@@ -11821,9 +11835,9 @@ async function readTrustedConfig(ctx, companyId) {
|
|
|
11821
11835
|
return remembered ?? {};
|
|
11822
11836
|
}
|
|
11823
11837
|
}
|
|
11824
|
-
async function getResolvedConfig(ctx, companyId) {
|
|
11838
|
+
async function getResolvedConfig(ctx, companyId, options = {}) {
|
|
11825
11839
|
const [savedConfig, externalConfig] = await Promise.all([
|
|
11826
|
-
readTrustedConfig(ctx, companyId),
|
|
11840
|
+
readTrustedConfig(ctx, companyId, options),
|
|
11827
11841
|
readExternalConfig(ctx)
|
|
11828
11842
|
]);
|
|
11829
11843
|
return {
|
|
@@ -11925,53 +11939,56 @@ async function resolvePaperclipApiAuthTokens(ctx, settings, config, mappings) {
|
|
|
11925
11939
|
];
|
|
11926
11940
|
const tokensByCompanyId = /* @__PURE__ */ new Map();
|
|
11927
11941
|
for (const companyId of companyIds) {
|
|
11928
|
-
const
|
|
11929
|
-
|
|
11930
|
-
|
|
11931
|
-
const secretRef = configuredSecretRef ?? savedSecretRef;
|
|
11932
|
-
if (!secretRef) {
|
|
11933
|
-
continue;
|
|
11942
|
+
const token = await resolvePaperclipApiAuthTokenForCompany(ctx, settings, config, companyId);
|
|
11943
|
+
if (token) {
|
|
11944
|
+
tokensByCompanyId.set(companyId, token);
|
|
11934
11945
|
}
|
|
11935
|
-
|
|
11936
|
-
|
|
11937
|
-
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
|
|
11943
|
-
|
|
11944
|
-
|
|
11945
|
-
|
|
11946
|
-
|
|
11947
|
-
|
|
11946
|
+
}
|
|
11947
|
+
return tokensByCompanyId;
|
|
11948
|
+
}
|
|
11949
|
+
async function resolvePaperclipApiAuthTokenForCompany(ctx, settings, config, companyId) {
|
|
11950
|
+
const configuredSecretRef = getConfiguredPaperclipBoardApiTokenRef(config, companyId);
|
|
11951
|
+
const savedSecretRef = getSavedPaperclipBoardApiTokenRef(settings, companyId);
|
|
11952
|
+
const fallbackToken = normalizeGitHubToken(config.paperclipBoardApiTokensByCompanyId?.[companyId]);
|
|
11953
|
+
const secretRef = configuredSecretRef ?? savedSecretRef;
|
|
11954
|
+
if (!secretRef) {
|
|
11955
|
+
return null;
|
|
11956
|
+
}
|
|
11957
|
+
if (!configuredSecretRef && savedSecretRef) {
|
|
11958
|
+
if (fallbackToken) {
|
|
11959
|
+
return fallbackToken;
|
|
11948
11960
|
}
|
|
11949
|
-
|
|
11950
|
-
|
|
11961
|
+
ctx.logger.warn(
|
|
11962
|
+
"Paperclip board access is saved in plugin state but has not been mirrored into plugin config yet. Open plugin settings to finish migrating it, or reconnect board access, before retrying sync.",
|
|
11963
|
+
{
|
|
11951
11964
|
companyId,
|
|
11952
|
-
|
|
11953
|
-
})).trim();
|
|
11954
|
-
if (token) {
|
|
11955
|
-
tokensByCompanyId.set(companyId, token);
|
|
11965
|
+
secretRef: savedSecretRef
|
|
11956
11966
|
}
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
|
|
11967
|
-
|
|
11967
|
+
);
|
|
11968
|
+
return null;
|
|
11969
|
+
}
|
|
11970
|
+
try {
|
|
11971
|
+
const token = (await resolvePluginSecret(ctx, secretRef, {
|
|
11972
|
+
companyId,
|
|
11973
|
+
configPath: getPaperclipBoardApiTokenRefConfigPath(companyId)
|
|
11974
|
+
})).trim();
|
|
11975
|
+
return token ? token : null;
|
|
11976
|
+
} catch (error) {
|
|
11977
|
+
if (fallbackToken && isPluginSecretReferenceUnavailableError(error)) {
|
|
11978
|
+
ctx.logger.warn("GitHub Sync is using a worker-local Paperclip board token fallback because plugin secret refs are unavailable in this host.", {
|
|
11968
11979
|
companyId,
|
|
11969
11980
|
secretRef,
|
|
11970
11981
|
error: getErrorMessage(error)
|
|
11971
11982
|
});
|
|
11983
|
+
return fallbackToken;
|
|
11972
11984
|
}
|
|
11985
|
+
ctx.logger.warn("Unable to resolve the saved Paperclip board API token. Direct REST calls will continue without it.", {
|
|
11986
|
+
companyId,
|
|
11987
|
+
secretRef,
|
|
11988
|
+
error: getErrorMessage(error)
|
|
11989
|
+
});
|
|
11990
|
+
return null;
|
|
11973
11991
|
}
|
|
11974
|
-
return tokensByCompanyId;
|
|
11975
11992
|
}
|
|
11976
11993
|
async function resolveGithubToken(ctx, options = {}) {
|
|
11977
11994
|
const settings = options.settings ?? normalizeSettings(await ctx.state.get(SETTINGS_SCOPE));
|
|
@@ -14537,6 +14554,138 @@ async function buildProjectPullRequestCountData(ctx, input) {
|
|
|
14537
14554
|
};
|
|
14538
14555
|
}
|
|
14539
14556
|
}
|
|
14557
|
+
var AGENT_TOOL_ACCESS_CACHE_TTL_MS = 12e4;
|
|
14558
|
+
var GITHUB_SYNC_AGENT_TOOL_NAME_PREFIX = `${GITHUB_SYNC_PLUGIN_ID}:`;
|
|
14559
|
+
var AGENT_TOOL_ACCESS_CHECKABLE_AGENT_STATUSES = /* @__PURE__ */ new Set(["active", "idle", "running", "error"]);
|
|
14560
|
+
var agentToolAccessSummaryCache = /* @__PURE__ */ new Map();
|
|
14561
|
+
function clearAgentToolAccessSummaryCache(companyId) {
|
|
14562
|
+
if (companyId) {
|
|
14563
|
+
agentToolAccessSummaryCache.delete(companyId);
|
|
14564
|
+
return;
|
|
14565
|
+
}
|
|
14566
|
+
agentToolAccessSummaryCache.clear();
|
|
14567
|
+
}
|
|
14568
|
+
function buildUnavailableAgentToolAccessSummary(status) {
|
|
14569
|
+
return {
|
|
14570
|
+
status,
|
|
14571
|
+
toolsVisibleToAgents: null,
|
|
14572
|
+
totalToolCount: GITHUB_AGENT_TOOLS.length
|
|
14573
|
+
};
|
|
14574
|
+
}
|
|
14575
|
+
function countGitHubSyncToolNames(value) {
|
|
14576
|
+
if (!Array.isArray(value)) {
|
|
14577
|
+
return 0;
|
|
14578
|
+
}
|
|
14579
|
+
return new Set(
|
|
14580
|
+
value.filter((entry) => typeof entry === "string" && entry.startsWith(GITHUB_SYNC_AGENT_TOOL_NAME_PREFIX))
|
|
14581
|
+
).size;
|
|
14582
|
+
}
|
|
14583
|
+
function effectiveToolProfilesGrantUnnamedTools(payload) {
|
|
14584
|
+
const profiles = Array.isArray(payload.profiles) ? payload.profiles : [];
|
|
14585
|
+
if (profiles.some((profile) => isPlainRecord(profile) && profile.defaultAction === "allow")) {
|
|
14586
|
+
return true;
|
|
14587
|
+
}
|
|
14588
|
+
const entries = Array.isArray(payload.entries) ? payload.entries : [];
|
|
14589
|
+
return entries.some((entry) => isPlainRecord(entry) && entry.selectorType === "risk_level" && entry.effect === "include");
|
|
14590
|
+
}
|
|
14591
|
+
async function selectAgentForToolAccessCheck(ctx, companyId) {
|
|
14592
|
+
const agents = await ctx.agents.list({
|
|
14593
|
+
companyId,
|
|
14594
|
+
limit: 500
|
|
14595
|
+
});
|
|
14596
|
+
const checkableAgents = agents.filter((agent) => !agent.status || AGENT_TOOL_ACCESS_CHECKABLE_AGENT_STATUSES.has(agent.status));
|
|
14597
|
+
const preferredAgent = checkableAgents.find((agent) => agent.status === "active") ?? checkableAgents[0];
|
|
14598
|
+
return {
|
|
14599
|
+
agent: preferredAgent ? { id: preferredAgent.id, name: preferredAgent.name } : null,
|
|
14600
|
+
checkableAgentCount: checkableAgents.length
|
|
14601
|
+
};
|
|
14602
|
+
}
|
|
14603
|
+
async function buildAgentToolAccessSummary(ctx, companyId, settings, config) {
|
|
14604
|
+
const cached = agentToolAccessSummaryCache.get(companyId);
|
|
14605
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
14606
|
+
return cached.summary;
|
|
14607
|
+
}
|
|
14608
|
+
const summary = await loadAgentToolAccessSummary(ctx, companyId, settings, config);
|
|
14609
|
+
agentToolAccessSummaryCache.set(companyId, {
|
|
14610
|
+
expiresAt: Date.now() + AGENT_TOOL_ACCESS_CACHE_TTL_MS,
|
|
14611
|
+
summary
|
|
14612
|
+
});
|
|
14613
|
+
return summary;
|
|
14614
|
+
}
|
|
14615
|
+
async function loadAgentToolAccessSummary(ctx, companyId, settings, config) {
|
|
14616
|
+
const paperclipApiBaseUrl = getConfiguredPaperclipApiBaseUrl(settings, config, companyId);
|
|
14617
|
+
if (!paperclipApiBaseUrl) {
|
|
14618
|
+
return buildUnavailableAgentToolAccessSummary("not_checked");
|
|
14619
|
+
}
|
|
14620
|
+
const boardApiToken = await resolvePaperclipApiAuthTokenForCompany(ctx, settings, config, companyId);
|
|
14621
|
+
if (!boardApiToken) {
|
|
14622
|
+
return buildUnavailableAgentToolAccessSummary("not_checked");
|
|
14623
|
+
}
|
|
14624
|
+
let sample;
|
|
14625
|
+
try {
|
|
14626
|
+
sample = await selectAgentForToolAccessCheck(ctx, companyId);
|
|
14627
|
+
} catch (error) {
|
|
14628
|
+
ctx.logger.debug("GitHub Sync could not list company agents for the tool-access check.", {
|
|
14629
|
+
companyId,
|
|
14630
|
+
error: getErrorMessage(error)
|
|
14631
|
+
});
|
|
14632
|
+
return buildUnavailableAgentToolAccessSummary("unavailable");
|
|
14633
|
+
}
|
|
14634
|
+
if (!sample.agent) {
|
|
14635
|
+
return buildUnavailableAgentToolAccessSummary("no_agents");
|
|
14636
|
+
}
|
|
14637
|
+
const agentId = sample.agent.id;
|
|
14638
|
+
try {
|
|
14639
|
+
const response = await fetchPaperclipApi(
|
|
14640
|
+
getPaperclipEffectiveAgentToolProfilesEndpoint(paperclipApiBaseUrl, companyId, agentId),
|
|
14641
|
+
{
|
|
14642
|
+
method: "GET",
|
|
14643
|
+
headers: {
|
|
14644
|
+
accept: "application/json",
|
|
14645
|
+
authorization: `Bearer ${boardApiToken}`
|
|
14646
|
+
}
|
|
14647
|
+
},
|
|
14648
|
+
{
|
|
14649
|
+
companyId
|
|
14650
|
+
}
|
|
14651
|
+
);
|
|
14652
|
+
const payloadResult = await readPaperclipApiJsonResponse(response, {
|
|
14653
|
+
operationLabel: "agent tool access"
|
|
14654
|
+
});
|
|
14655
|
+
if (payloadResult.failure || !isPlainRecord(payloadResult.data)) {
|
|
14656
|
+
ctx.logger.debug("GitHub Sync could not read effective agent tool profiles.", {
|
|
14657
|
+
companyId,
|
|
14658
|
+
agentId,
|
|
14659
|
+
...payloadResult.failure?.status !== void 0 ? { status: payloadResult.failure.status } : {}
|
|
14660
|
+
});
|
|
14661
|
+
return buildUnavailableAgentToolAccessSummary("unavailable");
|
|
14662
|
+
}
|
|
14663
|
+
const sampleFields = {
|
|
14664
|
+
checkedAgentId: agentId,
|
|
14665
|
+
checkedAgentName: sample.agent.name,
|
|
14666
|
+
checkableAgentCount: sample.checkableAgentCount
|
|
14667
|
+
};
|
|
14668
|
+
if (effectiveToolProfilesGrantUnnamedTools(payloadResult.data)) {
|
|
14669
|
+
return {
|
|
14670
|
+
...buildUnavailableAgentToolAccessSummary("ready"),
|
|
14671
|
+
...sampleFields
|
|
14672
|
+
};
|
|
14673
|
+
}
|
|
14674
|
+
return {
|
|
14675
|
+
status: "ready",
|
|
14676
|
+
toolsVisibleToAgents: countGitHubSyncToolNames(payloadResult.data.allowedToolNames),
|
|
14677
|
+
totalToolCount: GITHUB_AGENT_TOOLS.length,
|
|
14678
|
+
...sampleFields
|
|
14679
|
+
};
|
|
14680
|
+
} catch (error) {
|
|
14681
|
+
ctx.logger.debug("GitHub Sync could not reach the effective agent tool profile route.", {
|
|
14682
|
+
companyId,
|
|
14683
|
+
agentId,
|
|
14684
|
+
error: getErrorMessage(error)
|
|
14685
|
+
});
|
|
14686
|
+
return buildUnavailableAgentToolAccessSummary("unavailable");
|
|
14687
|
+
}
|
|
14688
|
+
}
|
|
14540
14689
|
async function buildSettingsTokenPermissionAuditData(ctx, input) {
|
|
14541
14690
|
const requestedCompanyId = normalizeCompanyId(input.companyId);
|
|
14542
14691
|
if (!requestedCompanyId) {
|
|
@@ -16457,10 +16606,19 @@ async function startSync(ctx, trigger, options = {}) {
|
|
|
16457
16606
|
}
|
|
16458
16607
|
await reconcileOrphanedRunningSyncState(ctx, options.target?.companyId);
|
|
16459
16608
|
const targetCompanyId = normalizeCompanyId(options.target?.companyId);
|
|
16460
|
-
|
|
16461
|
-
|
|
16462
|
-
|
|
16463
|
-
|
|
16609
|
+
let config;
|
|
16610
|
+
let persistedSettings;
|
|
16611
|
+
try {
|
|
16612
|
+
[config, persistedSettings] = await Promise.all([
|
|
16613
|
+
getResolvedConfig(ctx, targetCompanyId, { requireCompanyScope: true }),
|
|
16614
|
+
ctx.state.get(SETTINGS_SCOPE).then((value) => normalizeSettings(value))
|
|
16615
|
+
]);
|
|
16616
|
+
} catch (error) {
|
|
16617
|
+
if (!isCompanyScopeDeniedError(error)) {
|
|
16618
|
+
throw error;
|
|
16619
|
+
}
|
|
16620
|
+
return createUnexpectedSyncErrorResult(ctx, trigger, error, targetCompanyId);
|
|
16621
|
+
}
|
|
16464
16622
|
const token = await resolveGithubToken(ctx, {
|
|
16465
16623
|
companyId: targetCompanyId,
|
|
16466
16624
|
config,
|
|
@@ -16578,6 +16736,7 @@ async function listIssueInteractionEvents(ctx, companyId, paperclipIssueId, rang
|
|
|
16578
16736
|
let ledgerStartedAt = null;
|
|
16579
16737
|
const fromMs = Date.parse(range.from);
|
|
16580
16738
|
const toMs = Date.parse(range.to);
|
|
16739
|
+
let listedRows = 0;
|
|
16581
16740
|
outer: for (let offset = 0; ; ) {
|
|
16582
16741
|
const page = await ctx.entities.list({
|
|
16583
16742
|
entityType: ISSUE_INTERACTION_ENTITY_TYPE,
|
|
@@ -16587,14 +16746,19 @@ async function listIssueInteractionEvents(ctx, companyId, paperclipIssueId, rang
|
|
|
16587
16746
|
offset
|
|
16588
16747
|
});
|
|
16589
16748
|
for (const entry of page) {
|
|
16590
|
-
|
|
16749
|
+
listedRows += 1;
|
|
16750
|
+
if (listedRows > ISSUE_INTERACTION_MAX_LIST_ROWS) {
|
|
16591
16751
|
scanTruncated = true;
|
|
16592
16752
|
break outer;
|
|
16593
16753
|
}
|
|
16594
|
-
scannedRows += 1;
|
|
16595
16754
|
if (entry.scopeKind !== "issue" || entry.scopeId !== paperclipIssueId) continue;
|
|
16596
16755
|
const raw = entry.data;
|
|
16597
16756
|
if (raw?.companyId !== companyId || raw?.paperclipIssueId !== paperclipIssueId) continue;
|
|
16757
|
+
if (scannedRows >= ISSUE_INTERACTION_MAX_SCAN_ROWS) {
|
|
16758
|
+
scanTruncated = true;
|
|
16759
|
+
break outer;
|
|
16760
|
+
}
|
|
16761
|
+
scannedRows += 1;
|
|
16598
16762
|
try {
|
|
16599
16763
|
const event = sanitizeIssueInteractionEvent(raw);
|
|
16600
16764
|
if (ledgerStartedAt === null || event.occurredAt < ledgerStartedAt) ledgerStartedAt = event.occurredAt;
|
|
@@ -17896,6 +18060,7 @@ function shouldStartWorkerHost(moduleUrl, entry = process.argv[1]) {
|
|
|
17896
18060
|
}
|
|
17897
18061
|
}
|
|
17898
18062
|
var __testing = {
|
|
18063
|
+
listIssueInteractionEvents,
|
|
17899
18064
|
buildDirectPullRequestActionFingerprint,
|
|
17900
18065
|
buildRemoteActionFingerprint,
|
|
17901
18066
|
canReservePendingWake,
|
|
@@ -17938,6 +18103,7 @@ var plugin = definePlugin({
|
|
|
17938
18103
|
const companyId = normalizeCompanyId(context?.companyId) ?? null;
|
|
17939
18104
|
rememberTrustedConfig(companyId, newConfig);
|
|
17940
18105
|
clearGitHubRepositoryTokenCapabilityAudits();
|
|
18106
|
+
clearAgentToolAccessSummaryCache(companyId);
|
|
17941
18107
|
pluginRuntimeContext?.logger.debug("GitHub Sync received company-scoped plugin config.", {
|
|
17942
18108
|
companyId,
|
|
17943
18109
|
configKeys: Object.keys(isPlainRecord(newConfig) ? newConfig : {})
|
|
@@ -17945,6 +18111,7 @@ var plugin = definePlugin({
|
|
|
17945
18111
|
},
|
|
17946
18112
|
async setup(ctx) {
|
|
17947
18113
|
pluginRuntimeContext = ctx;
|
|
18114
|
+
clearAgentToolAccessSummaryCache();
|
|
17948
18115
|
ctx.data.register("settings.registration", async (input) => {
|
|
17949
18116
|
const record = input && typeof input === "object" ? input : {};
|
|
17950
18117
|
const requestedCompanyId = normalizeCompanyId(record.companyId);
|
|
@@ -17982,11 +18149,15 @@ var plugin = definePlugin({
|
|
|
17982
18149
|
await saveSettingsSyncState(ctx, normalizedSettings, settingsForResponse.syncState, requestedCompanyId);
|
|
17983
18150
|
}
|
|
17984
18151
|
const scopedMappings = filterMappingsByCompany(settingsForResponse.mappings, requestedCompanyId);
|
|
17985
|
-
const availableAssignees =
|
|
18152
|
+
const [availableAssignees, agentToolAccess] = await Promise.all([
|
|
18153
|
+
includeAssignees && requestedCompanyId ? listAvailableAssignees(ctx, requestedCompanyId, settingsForResponse) : Promise.resolve([]),
|
|
18154
|
+
requestedCompanyId ? buildAgentToolAccessSummary(ctx, requestedCompanyId, normalizedSettings, config) : Promise.resolve(buildUnavailableAgentToolAccessSummary("not_checked"))
|
|
18155
|
+
]);
|
|
17986
18156
|
return {
|
|
17987
18157
|
...getPublicSettingsForScope(settingsForResponse, requestedCompanyId),
|
|
17988
18158
|
...includeAssignees ? { availableAssignees } : {},
|
|
17989
18159
|
totalSyncedIssuesCount: countImportedIssuesForMappings(importRegistry, scopedMappings),
|
|
18160
|
+
agentToolAccess,
|
|
17990
18161
|
paperclipApiBaseUrlConfigured: Boolean(normalizePaperclipApiBaseUrl(config.paperclipApiBaseUrl)),
|
|
17991
18162
|
githubTokenConfigured,
|
|
17992
18163
|
paperclipBoardAccessConfigured: requestedCompanyId ? hasConfiguredPaperclipBoardAccess(settingsForResponse, config, requestedCompanyId) : hasConfiguredPaperclipBoardAccessForMappings(settingsForResponse, config, scopedMappings),
|