spur-board 0.27.0 → 0.29.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/dist/cli.mjs +3 -3
- package/dist/{client-BCurPuLJ.mjs → client-BHnD83EW.mjs} +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{config-B1u34Kr8.mjs → config-CoUN_LCM.mjs} +2 -2
- package/dist/daemon.mjs +313 -86
- package/dist/mcp.mjs +3 -3
- package/dist/{src-C356blas.mjs → src-XNs3RhSm.mjs} +11 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as
|
|
2
|
-
import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-
|
|
1
|
+
import { G as configSchema, K as requiredSecretKeys, P as ERRORS, l as roleCanUseOperation, q as SLACK_BOT_SCOPES, r as SYSTEMD_SERVICE_SETTINGS, u as OPERATIONS } from "./src-XNs3RhSm.mjs";
|
|
2
|
+
import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-BHnD83EW.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-CoUN_LCM.mjs";
|
|
4
4
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
5
5
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
6
6
|
import { homedir, hostname, userInfo } from "node:os";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { I as errorContextSchema, L as errorEnvelopeSchema, P as ERRORS, f as renderJsonError, z as successEnvelopeSchema } from "./src-XNs3RhSm.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-BHnD83EW.mjs";
|
|
2
2
|
export { fetchCatalogVersion, requestOperation, requestTokenEnrollment };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as CliError, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { G as configSchema, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-XNs3RhSm.mjs";
|
|
2
|
+
import { i as CliError, t as fetchCatalogVersion } from "./client-BHnD83EW.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|
package/dist/daemon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as errorCodeOf, C as SESSION_STATUSES, D as ticketFactsSchema, E as sessionFactsSchema,
|
|
1
|
+
import { A as errorCodeOf, C as SESSION_STATUSES, D as ticketFactsSchema, E as sessionFactsSchema, F as err, G as configSchema, K as requiredSecretKeys, M as parseRef$1, N as taskKeySchema, O as actorIdSchema, P as ERRORS, R as ok, S as SESSION_HEALTH_STATES, T as prRefSchema, U as DEFAULT_SLACK_COMMAND, V as DEFAULT_LINK, W as RESERVED_PROJECT, _ as interactionRefSchema, a as batchSchema, b as EVENT_KINDS, c as buildCatalogSnapshot, d as renderHttpProblem, g as inboundEventSchema, h as conversationRefSchema, i as AdapterError, j as parseActorId, k as encodeActorId, l as roleCanUseOperation, m as SPACE_IDS, n as BOARD_TICK_MS, o as entityRefSchema, q as SLACK_BOT_SCOPES, s as sourceCursorSchema, t as assertNever, u as OPERATIONS, v as messageRefSchema, w as prFactsSchema, x as eventPayloadSchemas, y as userIdSchema, z as successEnvelopeSchema } from "./src-XNs3RhSm.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { closeSync, existsSync, fstatSync, fsyncSync, ftruncateSync, linkSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeSync } from "node:fs";
|
|
@@ -43,6 +43,7 @@ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
|
43
43
|
//#region ../contracts/src/gateway/gateway.ts
|
|
44
44
|
const PERSONA_ROLES = [
|
|
45
45
|
"orchestrator",
|
|
46
|
+
"curator",
|
|
46
47
|
"worker",
|
|
47
48
|
"board"
|
|
48
49
|
];
|
|
@@ -14451,6 +14452,15 @@ function githubSources(config, options) {
|
|
|
14451
14452
|
client,
|
|
14452
14453
|
now: options.now,
|
|
14453
14454
|
ctx
|
|
14455
|
+
}),
|
|
14456
|
+
pollPr: (ref, ctx) => pollOnePr({
|
|
14457
|
+
id,
|
|
14458
|
+
repo,
|
|
14459
|
+
keys,
|
|
14460
|
+
client,
|
|
14461
|
+
now: options.now,
|
|
14462
|
+
ref,
|
|
14463
|
+
signal: ctx.signal
|
|
14454
14464
|
})
|
|
14455
14465
|
}
|
|
14456
14466
|
});
|
|
@@ -14557,6 +14567,82 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
|
|
|
14557
14567
|
pr
|
|
14558
14568
|
};
|
|
14559
14569
|
}
|
|
14570
|
+
function accumulator(complete, budget) {
|
|
14571
|
+
return {
|
|
14572
|
+
complete,
|
|
14573
|
+
entities: [],
|
|
14574
|
+
items: [],
|
|
14575
|
+
budget,
|
|
14576
|
+
parseError: void 0,
|
|
14577
|
+
parseFailedRefs: 0
|
|
14578
|
+
};
|
|
14579
|
+
}
|
|
14580
|
+
function malformed(acc, error, ref) {
|
|
14581
|
+
acc.parseError ??= error;
|
|
14582
|
+
acc.complete = false;
|
|
14583
|
+
if (ref) {
|
|
14584
|
+
acc.entities.push({
|
|
14585
|
+
ref,
|
|
14586
|
+
status: "no_access"
|
|
14587
|
+
});
|
|
14588
|
+
acc.parseFailedRefs += 1;
|
|
14589
|
+
}
|
|
14590
|
+
return false;
|
|
14591
|
+
}
|
|
14592
|
+
async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
14593
|
+
const errors = withoutDeniedReferences(scopedErrors);
|
|
14594
|
+
requireCheckAccess(errors);
|
|
14595
|
+
const error = errors[0];
|
|
14596
|
+
if (error !== void 0) {
|
|
14597
|
+
const direct = error.path === void 0 || error.path.length <= 2;
|
|
14598
|
+
if (!ref || !direct || error.type !== "NOT_FOUND" && error.type !== "FORBIDDEN") acc.complete = false;
|
|
14599
|
+
if (ref) acc.entities.push({
|
|
14600
|
+
ref,
|
|
14601
|
+
status: direct ? status(error) : "no_access"
|
|
14602
|
+
});
|
|
14603
|
+
return false;
|
|
14604
|
+
}
|
|
14605
|
+
const root = content(() => parseWire(aliasWire, data[alias], MALFORMED$2, ["data", alias]));
|
|
14606
|
+
if (root instanceof AdapterError) return malformed(acc, root, ref);
|
|
14607
|
+
const wire = root?.pullRequest;
|
|
14608
|
+
if (wire === null || wire === void 0) {
|
|
14609
|
+
if (ref) acc.entities.push({
|
|
14610
|
+
ref,
|
|
14611
|
+
status: "not_found"
|
|
14612
|
+
});
|
|
14613
|
+
else acc.complete = false;
|
|
14614
|
+
return false;
|
|
14615
|
+
}
|
|
14616
|
+
const full = await fullPr(scope.client, wire, scope.owner, scope.name, number, scope.signal, (next) => {
|
|
14617
|
+
acc.budget = next;
|
|
14618
|
+
});
|
|
14619
|
+
if (full.status === "denied") {
|
|
14620
|
+
acc.complete = false;
|
|
14621
|
+
if (ref) acc.entities.push({
|
|
14622
|
+
ref,
|
|
14623
|
+
status: "no_access"
|
|
14624
|
+
});
|
|
14625
|
+
return false;
|
|
14626
|
+
}
|
|
14627
|
+
if (full.status === "malformed") return malformed(acc, full.error, ref);
|
|
14628
|
+
const facts = content(() => normalizePr(ref?.repo ?? scope.repo, full.pr, scope.keys));
|
|
14629
|
+
if (facts instanceof AdapterError) return malformed(acc, facts, ref);
|
|
14630
|
+
acc.items.push({
|
|
14631
|
+
kind: "pr",
|
|
14632
|
+
facts
|
|
14633
|
+
});
|
|
14634
|
+
if (ref) acc.entities.push({
|
|
14635
|
+
ref,
|
|
14636
|
+
status: "ok"
|
|
14637
|
+
});
|
|
14638
|
+
return true;
|
|
14639
|
+
}
|
|
14640
|
+
function closingSelected(keys) {
|
|
14641
|
+
return keys.type === "issues" && keys.sources.includes("closing");
|
|
14642
|
+
}
|
|
14643
|
+
function rethrowLoneParseFailure(acc) {
|
|
14644
|
+
if (acc.parseError !== void 0 && acc.items.length === 0 && acc.entities.length === acc.parseFailedRefs) throw acc.parseError;
|
|
14645
|
+
}
|
|
14560
14646
|
async function pollRepository({ id, repo, login, keys, client, now, ctx }) {
|
|
14561
14647
|
const observedAt = sourceCursorSchema.parse(new Date(now()).toISOString());
|
|
14562
14648
|
const bootstrap = ctx.cursor === void 0;
|
|
@@ -14565,17 +14651,14 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx }) {
|
|
|
14565
14651
|
const requested = ctx.observe.prs.filter((ref) => ref.repo.toLowerCase() === repo.toLowerCase());
|
|
14566
14652
|
const byNumber = new Map(requested.map((ref) => [ref.number, ref]));
|
|
14567
14653
|
const numbers = [...byNumber.keys()];
|
|
14568
|
-
const closing = keys
|
|
14654
|
+
const closing = closingSelected(keys);
|
|
14569
14655
|
const response = await client.query(initialQuery(numbers, bootstrap, closing), {
|
|
14570
14656
|
owner,
|
|
14571
14657
|
repo: name
|
|
14572
14658
|
}, ctx.signal);
|
|
14573
|
-
|
|
14574
|
-
let complete = true;
|
|
14659
|
+
const acc = accumulator(true, response.budget);
|
|
14575
14660
|
const roots = ["repository", ...numbers.map((_, i) => `pr${String(i)}`)];
|
|
14576
14661
|
rejectUnscoped(response.errors, roots);
|
|
14577
|
-
const entities = [];
|
|
14578
|
-
const items = [];
|
|
14579
14662
|
let discoveryOk = scoped(response.errors, "repository").length === 0;
|
|
14580
14663
|
const first = discoveryOk ? parseWire(discoveryRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).pullRequests : void 0;
|
|
14581
14664
|
const nodes = first === void 0 ? [] : [...first.nodes];
|
|
@@ -14589,7 +14672,7 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx }) {
|
|
|
14589
14672
|
repo: name,
|
|
14590
14673
|
after: cursor
|
|
14591
14674
|
}, ctx.signal);
|
|
14592
|
-
budget = page.budget;
|
|
14675
|
+
acc.budget = page.budget;
|
|
14593
14676
|
rejectUnscoped(page.errors, ["repository"]);
|
|
14594
14677
|
if (page.errors.length > 0) {
|
|
14595
14678
|
discoveryOk = false;
|
|
@@ -14599,76 +14682,22 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx }) {
|
|
|
14599
14682
|
nodes.push(...connection.nodes);
|
|
14600
14683
|
cursor = pastCursor(connection.nodes, ctx.cursor) ? void 0 : nextPage(connection);
|
|
14601
14684
|
}
|
|
14602
|
-
if (!discoveryOk) complete = false;
|
|
14685
|
+
if (!discoveryOk) acc.complete = false;
|
|
14603
14686
|
const found = discover(nodes, ctx.cursor, login);
|
|
14604
14687
|
const bootstrapCursor = bootstrap && discoveryOk ? latestUpdatedAt(parseWire(baselineRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).mergedBaseline.nodes, found.cursor) ?? sourceCursorSchema.parse("1970-01-01T00:00:00.000Z") : void 0;
|
|
14605
|
-
|
|
14606
|
-
|
|
14607
|
-
|
|
14608
|
-
|
|
14609
|
-
|
|
14610
|
-
|
|
14611
|
-
|
|
14612
|
-
ref,
|
|
14613
|
-
status: "no_access"
|
|
14614
|
-
});
|
|
14615
|
-
parseFailedRefs += 1;
|
|
14616
|
-
}
|
|
14617
|
-
return false;
|
|
14618
|
-
};
|
|
14619
|
-
const process = async (number, alias, data, scopedErrors, ref) => {
|
|
14620
|
-
const errors = withoutDeniedReferences(scopedErrors);
|
|
14621
|
-
requireCheckAccess(errors);
|
|
14622
|
-
const error = errors[0];
|
|
14623
|
-
if (error !== void 0) {
|
|
14624
|
-
const direct = error.path === void 0 || error.path.length <= 2;
|
|
14625
|
-
if (!ref || !direct || error.type !== "NOT_FOUND" && error.type !== "FORBIDDEN") complete = false;
|
|
14626
|
-
if (ref) entities.push({
|
|
14627
|
-
ref,
|
|
14628
|
-
status: direct ? status(error) : "no_access"
|
|
14629
|
-
});
|
|
14630
|
-
return false;
|
|
14631
|
-
}
|
|
14632
|
-
const root = content(() => parseWire(aliasWire, data[alias], MALFORMED$2, ["data", alias]));
|
|
14633
|
-
if (root instanceof AdapterError) return malformed(root, ref);
|
|
14634
|
-
const wire = root?.pullRequest;
|
|
14635
|
-
if (wire === null || wire === void 0) {
|
|
14636
|
-
if (ref) entities.push({
|
|
14637
|
-
ref,
|
|
14638
|
-
status: "not_found"
|
|
14639
|
-
});
|
|
14640
|
-
else complete = false;
|
|
14641
|
-
return false;
|
|
14642
|
-
}
|
|
14643
|
-
const full = await fullPr(client, wire, owner, name, number, ctx.signal, (next) => {
|
|
14644
|
-
budget = next;
|
|
14645
|
-
});
|
|
14646
|
-
if (full.status === "denied") {
|
|
14647
|
-
complete = false;
|
|
14648
|
-
if (ref) entities.push({
|
|
14649
|
-
ref,
|
|
14650
|
-
status: "no_access"
|
|
14651
|
-
});
|
|
14652
|
-
return false;
|
|
14653
|
-
}
|
|
14654
|
-
if (full.status === "malformed") return malformed(full.error, ref);
|
|
14655
|
-
const facts = content(() => normalizePr(ref?.repo ?? repo, full.pr, keys));
|
|
14656
|
-
if (facts instanceof AdapterError) return malformed(facts, ref);
|
|
14657
|
-
items.push({
|
|
14658
|
-
kind: "pr",
|
|
14659
|
-
facts
|
|
14660
|
-
});
|
|
14661
|
-
if (ref) entities.push({
|
|
14662
|
-
ref,
|
|
14663
|
-
status: "ok"
|
|
14664
|
-
});
|
|
14665
|
-
return true;
|
|
14688
|
+
const scope = {
|
|
14689
|
+
client,
|
|
14690
|
+
repo,
|
|
14691
|
+
owner,
|
|
14692
|
+
name,
|
|
14693
|
+
keys,
|
|
14694
|
+
signal: ctx.signal
|
|
14666
14695
|
};
|
|
14667
14696
|
let discoveredOk = true;
|
|
14668
14697
|
for (const [i, number] of numbers.entries()) {
|
|
14669
14698
|
const alias = `pr${String(i)}`;
|
|
14670
14699
|
const errors = scoped(response.errors, alias);
|
|
14671
|
-
if (!await
|
|
14700
|
+
if (!await processPr(scope, acc, number, alias, response.data, errors, byNumber.get(number)) && found.numbers.includes(number)) discoveredOk = false;
|
|
14672
14701
|
}
|
|
14673
14702
|
const discovered = found.numbers.filter((number) => !byNumber.has(number));
|
|
14674
14703
|
for (let offset = 0; offset < discovered.length; offset += 50) {
|
|
@@ -14677,24 +14706,53 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx }) {
|
|
|
14677
14706
|
owner,
|
|
14678
14707
|
repo: name
|
|
14679
14708
|
}, ctx.signal);
|
|
14680
|
-
budget = detail.budget;
|
|
14709
|
+
acc.budget = detail.budget;
|
|
14681
14710
|
rejectUnscoped(detail.errors, chunk.map((_, i) => `pr${String(i)}`));
|
|
14682
14711
|
for (const [i, number] of chunk.entries()) {
|
|
14683
14712
|
const alias = `pr${String(i)}`;
|
|
14684
|
-
if (!await
|
|
14713
|
+
if (!await processPr(scope, acc, number, alias, detail.data, scoped(detail.errors, alias))) discoveredOk = false;
|
|
14685
14714
|
}
|
|
14686
14715
|
}
|
|
14687
14716
|
if (ctx.signal.aborted) throw new AdapterError("transient", "GitHub poll aborted");
|
|
14688
|
-
|
|
14717
|
+
rethrowLoneParseFailure(acc);
|
|
14689
14718
|
const nextCursor = bootstrap ? bootstrapCursor : found.cursor;
|
|
14690
14719
|
return {
|
|
14691
14720
|
source: id,
|
|
14692
14721
|
observedAt,
|
|
14693
|
-
complete,
|
|
14694
|
-
items,
|
|
14695
|
-
entities,
|
|
14722
|
+
complete: acc.complete,
|
|
14723
|
+
items: acc.items,
|
|
14724
|
+
entities: acc.entities,
|
|
14696
14725
|
...discoveryOk && discoveredOk ? nextCursor === void 0 ? {} : { cursor: nextCursor } : ctx.cursor === void 0 ? {} : { cursor: ctx.cursor },
|
|
14697
|
-
budget
|
|
14726
|
+
budget: acc.budget
|
|
14727
|
+
};
|
|
14728
|
+
}
|
|
14729
|
+
async function pollOnePr({ id, repo, keys, client, now, ref, signal }) {
|
|
14730
|
+
const observedAt = new Date(now()).toISOString();
|
|
14731
|
+
const [owner, name] = repo.split("/");
|
|
14732
|
+
if (!owner || !name) throw new AdapterError("config", "Invalid repository");
|
|
14733
|
+
const response = await client.query(detailQuery([ref.number], closingSelected(keys)), {
|
|
14734
|
+
owner,
|
|
14735
|
+
repo: name
|
|
14736
|
+
}, signal);
|
|
14737
|
+
rejectUnscoped(response.errors, ["pr0"]);
|
|
14738
|
+
const acc = accumulator(false, response.budget);
|
|
14739
|
+
await processPr({
|
|
14740
|
+
client,
|
|
14741
|
+
repo,
|
|
14742
|
+
owner,
|
|
14743
|
+
name,
|
|
14744
|
+
keys,
|
|
14745
|
+
signal
|
|
14746
|
+
}, acc, ref.number, "pr0", response.data, scoped(response.errors, "pr0"), ref);
|
|
14747
|
+
if (signal.aborted) throw new AdapterError("transient", "GitHub poll aborted");
|
|
14748
|
+
rethrowLoneParseFailure(acc);
|
|
14749
|
+
return {
|
|
14750
|
+
source: id,
|
|
14751
|
+
observedAt,
|
|
14752
|
+
complete: false,
|
|
14753
|
+
items: acc.items,
|
|
14754
|
+
entities: acc.entities,
|
|
14755
|
+
budget: acc.budget
|
|
14698
14756
|
};
|
|
14699
14757
|
}
|
|
14700
14758
|
//#endregion
|
|
@@ -15278,6 +15336,12 @@ function budgetPause(budget, reserveRemaining, intervalMs, now) {
|
|
|
15278
15336
|
if (budget.remaining >= reserveRemaining) return void 0;
|
|
15279
15337
|
return Math.max(Date.parse(budget.resetAt) - now, intervalMs);
|
|
15280
15338
|
}
|
|
15339
|
+
/** When a `throttled` error lets the source be called again; undefined without a valid time. */
|
|
15340
|
+
function throttledRetryAt(error) {
|
|
15341
|
+
if (!(error instanceof AdapterError) || error.kind !== "throttled") return void 0;
|
|
15342
|
+
const retryAt = error.retryAt?.getTime();
|
|
15343
|
+
return retryAt === void 0 || Number.isNaN(retryAt) ? void 0 : retryAt;
|
|
15344
|
+
}
|
|
15281
15345
|
/** The wait before the next poll and the new failure count. */
|
|
15282
15346
|
function nextDelay(input) {
|
|
15283
15347
|
const { outcome, intervalMs, failures, now } = input;
|
|
@@ -15291,8 +15355,8 @@ function nextDelay(input) {
|
|
|
15291
15355
|
delayMs: jitter(input.authRetryMs),
|
|
15292
15356
|
failures
|
|
15293
15357
|
};
|
|
15294
|
-
const retryAt = error
|
|
15295
|
-
if (
|
|
15358
|
+
const retryAt = throttledRetryAt(error);
|
|
15359
|
+
if (retryAt !== void 0) return {
|
|
15296
15360
|
delayMs: Math.max(retryAt - now, intervalMs),
|
|
15297
15361
|
failures
|
|
15298
15362
|
};
|
|
@@ -15375,16 +15439,30 @@ function applyEntityOutcomes(input) {
|
|
|
15375
15439
|
function startRunner(options) {
|
|
15376
15440
|
const startedAt = options.now();
|
|
15377
15441
|
const sources = options.entries.map((entry) => runSource(entry, options, startedAt));
|
|
15442
|
+
const byId = new Map(sources.map((source) => [source.id, source]));
|
|
15378
15443
|
return {
|
|
15379
15444
|
firstAttempts: Promise.all(sources.map(async (source) => ({
|
|
15380
15445
|
source: source.id,
|
|
15381
15446
|
outcome: await source.firstAttempt
|
|
15382
15447
|
}))),
|
|
15448
|
+
pollPr(source, ref, { timeoutMs }) {
|
|
15449
|
+
const found = byId.get(source);
|
|
15450
|
+
if (found === void 0) return Promise.resolve(err({
|
|
15451
|
+
kind: "unknown_source",
|
|
15452
|
+
message: `No source with id ${source}`
|
|
15453
|
+
}));
|
|
15454
|
+
return found.pollPr(ref, timeoutMs);
|
|
15455
|
+
},
|
|
15383
15456
|
async stop() {
|
|
15384
15457
|
await Promise.all(sources.map((source) => source.stop()));
|
|
15385
15458
|
}
|
|
15386
15459
|
};
|
|
15387
15460
|
}
|
|
15461
|
+
const noop = () => void 0;
|
|
15462
|
+
const stoppedError = {
|
|
15463
|
+
kind: "stopped",
|
|
15464
|
+
message: "The adapter runner is stopping"
|
|
15465
|
+
};
|
|
15388
15466
|
function runSource(entry, options, runnerStartMs) {
|
|
15389
15467
|
const { adapter, reserveRemaining } = entry;
|
|
15390
15468
|
const { core, config } = options;
|
|
@@ -15415,9 +15493,14 @@ function runSource(entry, options, runnerStartMs) {
|
|
|
15415
15493
|
let counts = /* @__PURE__ */ new Map();
|
|
15416
15494
|
let hydrated = false;
|
|
15417
15495
|
let gone = [];
|
|
15418
|
-
/** Set while a poll is in flight. */
|
|
15496
|
+
/** Set while a regular poll is in flight. */
|
|
15419
15497
|
let controller;
|
|
15420
|
-
|
|
15498
|
+
/** Unsettled on-demand requests; each entry resolves its request as stopped unless observing. */
|
|
15499
|
+
const pending = /* @__PURE__ */ new Set();
|
|
15500
|
+
/** Until when a regular throttled failure forbids calling the source. */
|
|
15501
|
+
let throttledUntilMs;
|
|
15502
|
+
/** Tail of the single-flight chain: regular polls and on-demand requests, one at a time. */
|
|
15503
|
+
let chain = Promise.resolve();
|
|
15421
15504
|
let pollTimer;
|
|
15422
15505
|
let deadlineTimer;
|
|
15423
15506
|
let hardBoundTimer;
|
|
@@ -15467,14 +15550,21 @@ function runSource(entry, options, runnerStartMs) {
|
|
|
15467
15550
|
hardBoundTimer = void 0;
|
|
15468
15551
|
report();
|
|
15469
15552
|
}
|
|
15553
|
+
/** Runs `task` after every task queued before it has settled. */
|
|
15554
|
+
function run(task) {
|
|
15555
|
+
const result = chain.then(task);
|
|
15556
|
+
chain = result.then(noop, noop);
|
|
15557
|
+
return result;
|
|
15558
|
+
}
|
|
15470
15559
|
function schedule(delayMs) {
|
|
15471
15560
|
if (stopping) return;
|
|
15472
15561
|
pollTimer = setTimeout(() => {
|
|
15473
15562
|
pollTimer = void 0;
|
|
15474
|
-
|
|
15563
|
+
run(poll);
|
|
15475
15564
|
}, delayMs);
|
|
15476
15565
|
}
|
|
15477
15566
|
async function poll() {
|
|
15567
|
+
if (stopping) return;
|
|
15478
15568
|
const abort = new AbortController();
|
|
15479
15569
|
const aborted = () => abort.signal.aborted;
|
|
15480
15570
|
controller = abort;
|
|
@@ -15581,17 +15671,136 @@ function runSource(entry, options, runnerStartMs) {
|
|
|
15581
15671
|
now: now()
|
|
15582
15672
|
});
|
|
15583
15673
|
failures = delay.failures;
|
|
15674
|
+
throttledUntilMs = outcome.kind === "failed" ? throttledRetryAt(outcome.error) : void 0;
|
|
15584
15675
|
if (!options.oneShot) armDeadline();
|
|
15585
15676
|
await report();
|
|
15586
15677
|
if (!options.oneShot) schedule(delay.delayMs);
|
|
15587
15678
|
return outcome;
|
|
15588
15679
|
}
|
|
15680
|
+
/** One on-demand request at its turn on the chain; `live` is false once its caller left. */
|
|
15681
|
+
async function demandTurn(ref, abort, live, observing) {
|
|
15682
|
+
if (stopping) return err(stoppedError);
|
|
15683
|
+
if (!live()) return;
|
|
15684
|
+
const startMs = now();
|
|
15685
|
+
const blind = state().blind;
|
|
15686
|
+
if (blind !== void 0) return err({
|
|
15687
|
+
kind: "blind",
|
|
15688
|
+
reason: blind.reason,
|
|
15689
|
+
message: blind.message
|
|
15690
|
+
});
|
|
15691
|
+
if (adapter.pollPr === void 0) return err({
|
|
15692
|
+
kind: "unsupported",
|
|
15693
|
+
message: "The source does not poll one PR on demand"
|
|
15694
|
+
});
|
|
15695
|
+
if (throttledUntilMs !== void 0 && startMs < throttledUntilMs) return err({
|
|
15696
|
+
kind: "failed",
|
|
15697
|
+
adapterKind: "throttled",
|
|
15698
|
+
retryAt: iso$1(throttledUntilMs),
|
|
15699
|
+
message: "The source is throttled until retryAt"
|
|
15700
|
+
});
|
|
15701
|
+
const aborted = () => abort.signal.aborted;
|
|
15702
|
+
let step = "poll";
|
|
15703
|
+
try {
|
|
15704
|
+
const batch = await untilAborted(adapter.pollPr(ref, { signal: abort.signal }), abort.signal);
|
|
15705
|
+
if (aborted()) return err(stoppedError);
|
|
15706
|
+
step = "batch";
|
|
15707
|
+
const observedAt = iso$1(startMs);
|
|
15708
|
+
const parsed = batchSchema.safeParse({
|
|
15709
|
+
...batch,
|
|
15710
|
+
observedAt
|
|
15711
|
+
});
|
|
15712
|
+
const value = parsed.success ? demandValue(parsed.data, observedAt) : void 0;
|
|
15713
|
+
const invalid = !parsed.success ? void 0 : parsed.data.source !== source ? "names another source" : !answersRequest({
|
|
15714
|
+
prs: [ref],
|
|
15715
|
+
tickets: [],
|
|
15716
|
+
sessions: []
|
|
15717
|
+
}, parsed.data.entities) ? "does not answer the request" : parsed.data.complete ? "is marked complete" : parsed.data.cursor !== void 0 ? "carries a cursor" : value === void 0 ? "carries another item" : void 0;
|
|
15718
|
+
if (!parsed.success || invalid !== void 0 || value === void 0) {
|
|
15719
|
+
const error = new AdapterError("transient", `Invalid batch: ${invalid ?? "fails the batch schema"}`);
|
|
15720
|
+
fail("batch", error, parsed.error?.issues.map((issue) => ({
|
|
15721
|
+
path: issue.path.map(String).join("."),
|
|
15722
|
+
code: issue.code,
|
|
15723
|
+
message: issue.message
|
|
15724
|
+
})));
|
|
15725
|
+
return err({
|
|
15726
|
+
kind: "failed",
|
|
15727
|
+
adapterKind: "transient",
|
|
15728
|
+
message: error.message
|
|
15729
|
+
});
|
|
15730
|
+
}
|
|
15731
|
+
step = "observe";
|
|
15732
|
+
const accepted = reports.then(async () => {
|
|
15733
|
+
if (!live()) return;
|
|
15734
|
+
if (stopping) return err(stoppedError);
|
|
15735
|
+
observing();
|
|
15736
|
+
const committed = state();
|
|
15737
|
+
await core.observe(source, {
|
|
15738
|
+
batch: parsed.data,
|
|
15739
|
+
effectiveComplete: false,
|
|
15740
|
+
state: committed,
|
|
15741
|
+
outcomes: []
|
|
15742
|
+
});
|
|
15743
|
+
lastReported = JSON.stringify(committed);
|
|
15744
|
+
return ok(value);
|
|
15745
|
+
});
|
|
15746
|
+
reports = accepted.then(noop, noop);
|
|
15747
|
+
return await accepted;
|
|
15748
|
+
} catch (error) {
|
|
15749
|
+
if (aborted()) return err(stoppedError);
|
|
15750
|
+
fail(step, error);
|
|
15751
|
+
const retryAt = throttledRetryAt(error);
|
|
15752
|
+
return err({
|
|
15753
|
+
kind: "failed",
|
|
15754
|
+
adapterKind: error instanceof AdapterError ? error.kind : "unexpected",
|
|
15755
|
+
...retryAt === void 0 ? {} : { retryAt: iso$1(retryAt) },
|
|
15756
|
+
message: error instanceof AdapterError ? error.message : `The ${step} step failed`
|
|
15757
|
+
});
|
|
15758
|
+
}
|
|
15759
|
+
}
|
|
15760
|
+
function pollPr(ref, timeoutMs) {
|
|
15761
|
+
if (entry.repo !== void 0 && ref.repo.toLowerCase() !== entry.repo.toLowerCase()) return Promise.resolve(err({
|
|
15762
|
+
kind: "unknown_source",
|
|
15763
|
+
message: `The source does not own ${ref.repo}`
|
|
15764
|
+
}));
|
|
15765
|
+
if (stopping) return Promise.resolve(err(stoppedError));
|
|
15766
|
+
return new Promise((resolve) => {
|
|
15767
|
+
const abort = new AbortController();
|
|
15768
|
+
let settled = false;
|
|
15769
|
+
let observing = false;
|
|
15770
|
+
const settle = (result) => {
|
|
15771
|
+
if (settled) return;
|
|
15772
|
+
settled = true;
|
|
15773
|
+
clearTimeout(timer);
|
|
15774
|
+
pending.delete(cancel);
|
|
15775
|
+
resolve(result);
|
|
15776
|
+
};
|
|
15777
|
+
const cancel = () => {
|
|
15778
|
+
if (observing) return;
|
|
15779
|
+
settle(err(stoppedError));
|
|
15780
|
+
abort.abort();
|
|
15781
|
+
};
|
|
15782
|
+
pending.add(cancel);
|
|
15783
|
+
const timer = setTimeout(() => {
|
|
15784
|
+
if (observing) return;
|
|
15785
|
+
settle(err({
|
|
15786
|
+
kind: "timeout",
|
|
15787
|
+
message: "The on-demand poll timed out"
|
|
15788
|
+
}));
|
|
15789
|
+
abort.abort();
|
|
15790
|
+
}, timeoutMs);
|
|
15791
|
+
run(async () => {
|
|
15792
|
+
const result = await demandTurn(ref, abort, () => !settled, () => {
|
|
15793
|
+
observing = true;
|
|
15794
|
+
});
|
|
15795
|
+
if (result !== void 0) settle(result);
|
|
15796
|
+
});
|
|
15797
|
+
});
|
|
15798
|
+
}
|
|
15589
15799
|
if (!options.oneShot) armDeadline();
|
|
15590
|
-
const firstAttempt = poll();
|
|
15591
|
-
current = firstAttempt.then(() => void 0);
|
|
15592
15800
|
return {
|
|
15593
15801
|
id: source,
|
|
15594
|
-
firstAttempt,
|
|
15802
|
+
firstAttempt: run(poll),
|
|
15803
|
+
pollPr,
|
|
15595
15804
|
async stop() {
|
|
15596
15805
|
stopping = true;
|
|
15597
15806
|
clearTimeout(pollTimer);
|
|
@@ -15599,11 +15808,27 @@ function runSource(entry, options, runnerStartMs) {
|
|
|
15599
15808
|
clearTimeout(hardBoundTimer);
|
|
15600
15809
|
pollTimer = deadlineTimer = hardBoundTimer = void 0;
|
|
15601
15810
|
controller?.abort();
|
|
15602
|
-
|
|
15811
|
+
for (const cancel of [...pending]) cancel();
|
|
15812
|
+
await chain;
|
|
15603
15813
|
await reports;
|
|
15604
15814
|
}
|
|
15605
15815
|
};
|
|
15606
15816
|
}
|
|
15817
|
+
/** The answer of an A9 batch: its one entity and at most that PR's own item; else undefined. */
|
|
15818
|
+
function demandValue(batch, observedAt) {
|
|
15819
|
+
const [entity] = batch.entities;
|
|
15820
|
+
const [item, ...rest] = batch.items;
|
|
15821
|
+
if (entity === void 0) return void 0;
|
|
15822
|
+
if (entity.status !== "ok") return item === void 0 ? {
|
|
15823
|
+
status: entity.status,
|
|
15824
|
+
observedAt
|
|
15825
|
+
} : void 0;
|
|
15826
|
+
return item?.kind === "pr" && rest.length === 0 ? {
|
|
15827
|
+
status: "ok",
|
|
15828
|
+
facts: item.facts,
|
|
15829
|
+
observedAt
|
|
15830
|
+
} : void 0;
|
|
15831
|
+
}
|
|
15607
15832
|
/**
|
|
15608
15833
|
* Settles with `work`, or with undefined as soon as `signal` aborts, so `stop()` never waits
|
|
15609
15834
|
* for an adapter that ignores its signal. A late result or rejection is dropped. The abort
|
|
@@ -15954,6 +16179,7 @@ function startAdapters(config, core, options) {
|
|
|
15954
16179
|
});
|
|
15955
16180
|
return {
|
|
15956
16181
|
firstAttempts: runner.firstAttempts,
|
|
16182
|
+
pollPr: runner.pollPr,
|
|
15957
16183
|
async stop() {
|
|
15958
16184
|
await runner.stop();
|
|
15959
16185
|
await Promise.allSettled([...notices]);
|
|
@@ -16123,6 +16349,7 @@ const MARKER_PREFIX = "spur:";
|
|
|
16123
16349
|
const ORIGIN_PREFIX = "spur-origin:";
|
|
16124
16350
|
const roleIcons = {
|
|
16125
16351
|
orchestrator: ":compass:",
|
|
16352
|
+
curator: ":classical_building:",
|
|
16126
16353
|
worker: ":hammer:",
|
|
16127
16354
|
board: ":clipboard:"
|
|
16128
16355
|
};
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ERRORS, p as renderMcpError, u as OPERATIONS } from "./src-
|
|
2
|
-
import { i as CliError, n as requestOperation } from "./client-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-
|
|
1
|
+
import { P as ERRORS, p as renderMcpError, u as OPERATIONS } from "./src-XNs3RhSm.mjs";
|
|
2
|
+
import { i as CliError, n as requestOperation } from "./client-BHnD83EW.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-CoUN_LCM.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -25,6 +25,16 @@ const COLUMNS = [
|
|
|
25
25
|
name: "Review",
|
|
26
26
|
required: false
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
id: "product-review",
|
|
30
|
+
name: "Product Review",
|
|
31
|
+
required: false
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "external-review",
|
|
35
|
+
name: "External Review",
|
|
36
|
+
required: false
|
|
37
|
+
},
|
|
28
38
|
{
|
|
29
39
|
id: "qa",
|
|
30
40
|
name: "QA",
|
|
@@ -2958,4 +2968,4 @@ function assertNever(value) {
|
|
|
2958
2968
|
throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
|
|
2959
2969
|
}
|
|
2960
2970
|
//#endregion
|
|
2961
|
-
export { errorCodeOf as A,
|
|
2971
|
+
export { errorCodeOf as A, DEFAULT_HTTP_PORT as B, SESSION_STATUSES as C, ticketFactsSchema as D, sessionFactsSchema as E, err as F, configSchema as G, DEFAULT_SLACK_APP_NAME as H, errorContextSchema as I, requiredSecretKeys as K, errorEnvelopeSchema as L, parseRef as M, taskKeySchema as N, actorIdSchema as O, ERRORS as P, ok as R, SESSION_HEALTH_STATES as S, prRefSchema as T, DEFAULT_SLACK_COMMAND as U, DEFAULT_LINK as V, RESERVED_PROJECT as W, interactionRefSchema as _, batchSchema as a, EVENT_KINDS as b, buildCatalogSnapshot as c, renderHttpProblem as d, renderJsonError as f, inboundEventSchema as g, conversationRefSchema as h, AdapterError as i, parseActorId as j, encodeActorId as k, roleCanUseOperation as l, SPACE_IDS as m, BOARD_TICK_MS as n, entityRefSchema as o, renderMcpError as p, SLACK_BOT_SCOPES as q, SYSTEMD_SERVICE_SETTINGS as r, sourceCursorSchema as s, assertNever as t, OPERATIONS as u, messageRefSchema as v, prFactsSchema as w, eventPayloadSchemas as x, userIdSchema as y, successEnvelopeSchema as z };
|