spur-board 0.25.0 → 0.26.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 +5 -4
- package/dist/{client-D3vmFo39.mjs → client-DEwzucXx.mjs} +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{config-CYLh25BZ.mjs → config-B8ZBFd_9.mjs} +2 -2
- package/dist/daemon.mjs +63 -12
- package/dist/mcp.mjs +4 -4
- package/dist/{src-Ron2NABC.mjs → src-7fzumMWU.mjs} +29 -3
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as SLACK_BOT_SCOPES, P as ERRORS, U as configSchema, W as requiredSecretKeys, l as roleCanUseOperation, r as SYSTEMD_SERVICE_SETTINGS, u as OPERATIONS } from "./src-
|
|
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 SLACK_BOT_SCOPES, P as ERRORS, U as configSchema, W as requiredSecretKeys, l as roleCanUseOperation, r as SYSTEMD_SERVICE_SETTINGS, u as OPERATIONS } from "./src-7fzumMWU.mjs";
|
|
2
|
+
import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-DEwzucXx.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-B8ZBFd_9.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";
|
|
@@ -308,7 +308,8 @@ const remoteBaseIds = [
|
|
|
308
308
|
"link.rules",
|
|
309
309
|
"spur.api",
|
|
310
310
|
"spur.send",
|
|
311
|
-
"operator.path"
|
|
311
|
+
"operator.path",
|
|
312
|
+
"curator.sessions"
|
|
312
313
|
];
|
|
313
314
|
const remoteSlackIds = [
|
|
314
315
|
"slack.auth",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as errorContextSchema, I as errorEnvelopeSchema, L as successEnvelopeSchema, P as ERRORS, f as renderJsonError } from "./src-
|
|
1
|
+
import { F as errorContextSchema, I as errorEnvelopeSchema, L as successEnvelopeSchema, P as ERRORS, f as renderJsonError } from "./src-7fzumMWU.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-DEwzucXx.mjs";
|
|
2
2
|
export { fetchCatalogVersion, requestOperation, requestTokenEnrollment };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { U as configSchema, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-
|
|
2
|
-
import { i as CliError, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { U as configSchema, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-7fzumMWU.mjs";
|
|
2
|
+
import { i as CliError, t as fetchCatalogVersion } from "./client-DEwzucXx.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, G as SLACK_BOT_SCOPES, H as RESERVED_PROJECT, L as successEnvelopeSchema, M as parseRef$1, N as taskKeySchema, O as actorIdSchema, P as ERRORS, S as SESSION_HEALTH_STATES, T as prRefSchema, U as configSchema, V as DEFAULT_SLACK_COMMAND, W as requiredSecretKeys, _ 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, s as sourceCursorSchema, t as assertNever, u as OPERATIONS, v as messageRefSchema, w as prFactsSchema, x as eventPayloadSchemas, y as userIdSchema, z as DEFAULT_LINK } from "./src-
|
|
1
|
+
import { A as errorCodeOf, C as SESSION_STATUSES, D as ticketFactsSchema, E as sessionFactsSchema, G as SLACK_BOT_SCOPES, H as RESERVED_PROJECT, L as successEnvelopeSchema, M as parseRef$1, N as taskKeySchema, O as actorIdSchema, P as ERRORS, S as SESSION_HEALTH_STATES, T as prRefSchema, U as configSchema, V as DEFAULT_SLACK_COMMAND, W as requiredSecretKeys, _ 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, s as sourceCursorSchema, t as assertNever, u as OPERATIONS, v as messageRefSchema, w as prFactsSchema, x as eventPayloadSchemas, y as userIdSchema, z as DEFAULT_LINK } from "./src-7fzumMWU.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";
|
|
@@ -8935,9 +8935,11 @@ const tokenRevokeMutation = {
|
|
|
8935
8935
|
//#endregion
|
|
8936
8936
|
//#region ../core/src/api/identity.ts
|
|
8937
8937
|
function sessionActor(project, session, config) {
|
|
8938
|
-
if (config.projects.filter((entry) => entry.spurProjects.some((spur) => spur.name === project)).length !== 1) throw new CommandError("forbidden", "Unknown session project.");
|
|
8939
8938
|
const actor = actorIdSchema.safeParse(`agent:${project}/${session}`);
|
|
8940
8939
|
if (!actor.success) throw new CommandError("forbidden", "Invalid session identity.");
|
|
8940
|
+
const matches = config.projects.filter((entry) => entry.spurProjects.some((spur) => spur.name === project));
|
|
8941
|
+
if (matches.length === 0) throw new CommandError("forbidden", `Spur project "${project}" is not listed in any spurProjects in the Board's config.yaml (not Spur's spur.yaml), and inside a Spur session a token is not used. Ask the operator to add it under projects[].spurProjects there and restart the Board daemon, or run the command outside a Spur session.`);
|
|
8942
|
+
if (matches.length > 1) throw new CommandError("forbidden", `Spur project "${project}" is listed under several Board projects: ${matches.map((entry) => entry.id).join(", ")}. Ask the operator to keep it under one of them in the Board's config.yaml (not Spur's spur.yaml) and restart the Board daemon.`);
|
|
8941
8943
|
return actor.data;
|
|
8942
8944
|
}
|
|
8943
8945
|
/** Resolve the caller at the HTTP boundary; a session header always outranks a token. */
|
|
@@ -9331,19 +9333,35 @@ function resolvedByProject(role) {
|
|
|
9331
9333
|
const { kind } = parseAddressee(role);
|
|
9332
9334
|
return kind === "curator" || kind === "orchestrator";
|
|
9333
9335
|
}
|
|
9334
|
-
/**
|
|
9336
|
+
/**
|
|
9337
|
+
* Milliseconds of a stored time, or null for a missing or unreadable one. `Date.parse`, not text
|
|
9338
|
+
* order: ISO values with different fractions do not sort as text.
|
|
9339
|
+
*/
|
|
9340
|
+
function instant(value) {
|
|
9341
|
+
if (typeof value !== "string") return null;
|
|
9342
|
+
const ms = Date.parse(value);
|
|
9343
|
+
return Number.isNaN(ms) ? null : ms;
|
|
9344
|
+
}
|
|
9345
|
+
/** Orders later times first and missing times last. Compared, never subtracted. */
|
|
9335
9346
|
function laterFirst(left, right) {
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
return right - left;
|
|
9347
|
+
const a = left ?? -Infinity;
|
|
9348
|
+
const b = right ?? -Infinity;
|
|
9349
|
+
return a > b ? -1 : a < b ? 1 : 0;
|
|
9340
9350
|
}
|
|
9341
|
-
/**
|
|
9351
|
+
/**
|
|
9352
|
+
* The newest live session of a Spur project, then the most recently active, then by id. A row
|
|
9353
|
+
* with an unreadable time or detail stays eligible and sorts last on that time.
|
|
9354
|
+
*/
|
|
9342
9355
|
async function bestProjectSession(trx, project) {
|
|
9343
9356
|
if (project === null) return void 0;
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9357
|
+
return (await trx.selectFrom("session_snapshot").selectAll().select(sql`CASE WHEN json_valid(detail) THEN json_extract(detail, '$.lastActivityAt') END`.as("last_activity")).where("spur_project", "=", project).where("ended_at", "is", null).where("absent_since", "is", null).where("state", "not in", FINISHED_STATES).execute()).sort((left, right) => laterFirst(instant(left.first_seen), instant(right.first_seen)) || laterFirst(instant(left.last_activity), instant(right.last_activity)) || (left.id < right.id ? -1 : 1))[0];
|
|
9358
|
+
}
|
|
9359
|
+
/**
|
|
9360
|
+
* The live session that a curator block on a board project rings, or undefined when the project
|
|
9361
|
+
* has no curator or the curator has no live session. `board doctor` reports the same choice.
|
|
9362
|
+
*/
|
|
9363
|
+
async function curatorSession(trx, config, projectId) {
|
|
9364
|
+
return bestProjectSession(trx, curatorProject(config, projectId));
|
|
9347
9365
|
}
|
|
9348
9366
|
/** The newest live session linked to a task in a role. */
|
|
9349
9367
|
async function linkedSession(trx, taskId, role) {
|
|
@@ -9366,7 +9384,7 @@ function columnOrchestratorProject(config, projectId, column) {
|
|
|
9366
9384
|
async function selectNotificationRecipient(trx, n, config) {
|
|
9367
9385
|
const addressee = parseAddressee(n.role);
|
|
9368
9386
|
switch (addressee.kind) {
|
|
9369
|
-
case "curator": return
|
|
9387
|
+
case "curator": return curatorSession(trx, config, await taskProject(trx, n.task_id));
|
|
9370
9388
|
case "orchestrator": {
|
|
9371
9389
|
const author = n.author_session === null ? void 0 : await sessionById(trx, n.author_session);
|
|
9372
9390
|
if (author !== void 0 && liveInProject(author)) return author;
|
|
@@ -11732,6 +11750,20 @@ async function firstPollDone(db, config, completeSince) {
|
|
|
11732
11750
|
return [...doctorSources(config)].every((source) => blind.has(source) || completeSince.has(source));
|
|
11733
11751
|
}
|
|
11734
11752
|
/**
|
|
11753
|
+
* The curator of each board project and the live session its curator blocks ring, in config
|
|
11754
|
+
* order. It asks the doorbells for their choice rather than keeping a copy, so the doctor cannot
|
|
11755
|
+
* name one session while the rings go to another.
|
|
11756
|
+
*/
|
|
11757
|
+
async function curatorSessions(db, config) {
|
|
11758
|
+
const entries = [];
|
|
11759
|
+
for (const project of config.projects) entries.push({
|
|
11760
|
+
project: project.id,
|
|
11761
|
+
curator: curatorProject(config, project.id),
|
|
11762
|
+
session: (await curatorSession(db, config, project.id))?.id ?? null
|
|
11763
|
+
});
|
|
11764
|
+
return entries;
|
|
11765
|
+
}
|
|
11766
|
+
/**
|
|
11735
11767
|
* Called from an accepted observation's transaction after board and item reconciliation.
|
|
11736
11768
|
* The version marker and feed row share that transaction with the source-state update.
|
|
11737
11769
|
*/
|
|
@@ -17303,6 +17335,24 @@ function linkRulesCheck(outcomes) {
|
|
|
17303
17335
|
};
|
|
17304
17336
|
return warning(id, fitFix(problems, problems.some((segment) => segment.unmatched) ? ` ${LINK_RULES_TAIL}` : "", `link rules miss recent PRs in ${String(problems.length)} projects; change projects[].link to the repo's branch and PR title rules.`));
|
|
17305
17337
|
}
|
|
17338
|
+
const CURATOR_TAIL = "Start a Spur session of each curator with no live session.";
|
|
17339
|
+
function curatorSessionsCheck(entries) {
|
|
17340
|
+
const id = "curator.sessions";
|
|
17341
|
+
const segment = (text, problem) => ({
|
|
17342
|
+
problem,
|
|
17343
|
+
unmatched: false,
|
|
17344
|
+
text: () => text
|
|
17345
|
+
});
|
|
17346
|
+
const segments = entries.map(({ project, curator, session }) => curator === null ? segment(`${project}: no curator configured`, false) : session === null ? segment(`${project}: curator ${curator}, no live session`, true) : segment(`${project}: curator ${curator}, session ${session}`, false));
|
|
17347
|
+
const missing = segments.filter((entry) => entry.problem).length;
|
|
17348
|
+
if (missing === 0) return {
|
|
17349
|
+
id,
|
|
17350
|
+
status: "pass",
|
|
17351
|
+
blocking: false,
|
|
17352
|
+
fix: fitFix(segments, "", `Every configured curator has a live session in ${String(segments.length)} projects.`)
|
|
17353
|
+
};
|
|
17354
|
+
return warning(id, fitFix([...segments.filter((entry) => entry.problem), ...segments.filter((entry) => !entry.problem)], ` ${CURATOR_TAIL}`, `${String(missing)} curators have no live session. Start a Spur session of each.`));
|
|
17355
|
+
}
|
|
17306
17356
|
function check(id, ok, fix) {
|
|
17307
17357
|
return {
|
|
17308
17358
|
id,
|
|
@@ -17447,6 +17497,7 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch, { deadlineM
|
|
|
17447
17497
|
const operatorProject = config.projects.some((project) => project.spurProjects.some((spurProject) => spurProject.role === "operator"));
|
|
17448
17498
|
const token = operatorProject ? void 0 : await ctx.store.db.selectFrom("operator_token").select("id").where("status", "=", "approved").executeTakeFirst();
|
|
17449
17499
|
checks.push(check("operator.path", operatorProject || token !== void 0, "Configure a Spur project with the operator role or approve a named operator token."));
|
|
17500
|
+
checks.push(curatorSessionsCheck(await curatorSessions(ctx.store.db, config)));
|
|
17450
17501
|
return {
|
|
17451
17502
|
version: productVersion,
|
|
17452
17503
|
checks
|
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-7fzumMWU.mjs";
|
|
2
|
+
import { i as CliError, n as requestOperation } from "./client-DEwzucXx.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-B8ZBFd_9.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -159,7 +159,7 @@ function createMcpServer(env = process.env, loadConfig = loadClientConfig) {
|
|
|
159
159
|
...error.context,
|
|
160
160
|
...key && ERRORS[error.code].exit === 5 ? { idempotencyKey: key } : {}
|
|
161
161
|
} } : {}
|
|
162
|
-
});
|
|
162
|
+
}, error.code === "forbidden" ? error.hint : void 0);
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
return server;
|
|
@@ -205,7 +205,7 @@ const githubIssuesTracker = z.strictObject({
|
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
207
|
const spurProject = z.strictObject({
|
|
208
|
-
name: nonEmpty,
|
|
208
|
+
name: nonEmpty.describe("The name of the project in Spur. A Spur project can be listed under only one board project."),
|
|
209
209
|
role: z.enum([
|
|
210
210
|
"worker",
|
|
211
211
|
"operator",
|
|
@@ -318,10 +318,31 @@ function isTimeZone(tz) {
|
|
|
318
318
|
return false;
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
+
/** A session belongs to one board project, so a Spur project can be listed under only one. */
|
|
322
|
+
function rejectSharedSpurProjects(items, ctx) {
|
|
323
|
+
const owners = /* @__PURE__ */ new Map();
|
|
324
|
+
items.forEach((project, i) => {
|
|
325
|
+
project.spurProjects.forEach(({ name }, j) => {
|
|
326
|
+
const owner = owners.get(name);
|
|
327
|
+
if (owner === void 0) owners.set(name, project.id);
|
|
328
|
+
else if (owner !== project.id) ctx.addIssue({
|
|
329
|
+
code: "custom",
|
|
330
|
+
path: [
|
|
331
|
+
i,
|
|
332
|
+
"spurProjects",
|
|
333
|
+
j,
|
|
334
|
+
"name"
|
|
335
|
+
],
|
|
336
|
+
message: `Spur project ${JSON.stringify(name)} is listed under board projects ${JSON.stringify(owner)} and ${JSON.stringify(project.id)}: list it under only one`
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
}
|
|
321
341
|
/** The board config file. Every object rejects unknown keys; no key holds a secret. */
|
|
322
342
|
const configSchema = z.strictObject({
|
|
323
343
|
projects: z.array(projectSchema).min(1).superRefine((items, ctx) => {
|
|
324
344
|
rejectDuplicates(items, "id", "project id", ctx);
|
|
345
|
+
rejectSharedSpurProjects(items, ctx);
|
|
325
346
|
}),
|
|
326
347
|
operator: z.strictObject({ slack: nonEmpty }),
|
|
327
348
|
slack: z.strictObject({
|
|
@@ -1415,8 +1436,13 @@ function renderHttpProblem(input) {
|
|
|
1415
1436
|
}
|
|
1416
1437
|
};
|
|
1417
1438
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1439
|
+
/** `hint` replaces the catalog hint for one call; `errorInputSchema` stays hint-free. */
|
|
1440
|
+
function renderMcpError(input, hint) {
|
|
1441
|
+
const rendered = fields(input, "mcp");
|
|
1442
|
+
const content = hint === void 0 ? rendered : {
|
|
1443
|
+
...rendered,
|
|
1444
|
+
hint
|
|
1445
|
+
};
|
|
1420
1446
|
return {
|
|
1421
1447
|
isError: true,
|
|
1422
1448
|
content: [{
|