spur-board 0.11.1 → 0.11.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/dist/cli.mjs +21 -4
- package/dist/{client-DbeVLW2G.mjs → client-B3aIcQ5T.mjs} +2 -2
- package/dist/client.mjs +1 -1
- package/dist/{config-B1OeBAM-.mjs → config-DWp8J6RP.mjs} +6 -3
- package/dist/daemon.mjs +57 -54
- package/dist/mcp.mjs +3 -3
- package/dist/{src-Dl5c0sRb.mjs → src-CjlXSUX-.mjs} +7 -0
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as requiredSecretKeys, N as ERRORS, U as SLACK_BOT_SCOPES, V as configSchema, l as OPERATIONS, n as SYSTEMD_SERVICE_SETTINGS } 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 loadEnrollmentConfig, i as fileVerdictCache, l as resolveDaemonAddress, n as cliPackageVersion, o as configFile, s as loadClientConfig, t as checkCatalog } from "./config-
|
|
1
|
+
import { H as requiredSecretKeys, N as ERRORS, U as SLACK_BOT_SCOPES, V as configSchema, c as roleCanUseOperation, l as OPERATIONS, n as SYSTEMD_SERVICE_SETTINGS } from "./src-CjlXSUX-.mjs";
|
|
2
|
+
import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-B3aIcQ5T.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadEnrollmentConfig, i as fileVerdictCache, l as resolveDaemonAddress, n as cliPackageVersion, o as configFile, s as loadClientConfig, t as checkCatalog } from "./config-DWp8J6RP.mjs";
|
|
4
4
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
5
5
|
import { chmodSync, closeSync, constants, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { homedir, hostname, userInfo } from "node:os";
|
|
@@ -236,6 +236,7 @@ const remoteBaseIds = [
|
|
|
236
236
|
"jira.credentials",
|
|
237
237
|
"github.credentials",
|
|
238
238
|
"spur.api",
|
|
239
|
+
"spur.send",
|
|
239
240
|
"operator.path"
|
|
240
241
|
];
|
|
241
242
|
const remoteSlackIds = [
|
|
@@ -880,6 +881,22 @@ function shellValue(value) {
|
|
|
880
881
|
const text = String(value);
|
|
881
882
|
return /^[A-Za-z0-9_./#:@-]+$/.test(text) ? text : JSON.stringify(text);
|
|
882
883
|
}
|
|
884
|
+
/** The identity an operation in the selected input mode needs, when only one kind of caller can run it. */
|
|
885
|
+
function identityHint(op, mode) {
|
|
886
|
+
const flag = op.cli.modes?.find((item) => item.mode === mode)?.flag;
|
|
887
|
+
const command = `\`board ${op.cli.command}${flag ? ` ${flag}` : ""}\``;
|
|
888
|
+
if (!roleCanUseOperation(op, "worker", mode) && !roleCanUseOperation(op, "orchestrator", mode)) return `${command} needs operator identity: run it in a Spur session of a project whose spurProjects role is operator, or run \`board token create --name <name> --into <folder>\` and ask the operator to approve the request in Slack.`;
|
|
889
|
+
if (!roleCanUseOperation(op, "operator", mode)) return `${command} needs an agent identity: run it in a Spur session of a project listed in config.yaml.`;
|
|
890
|
+
}
|
|
891
|
+
function loadOperationConfig(op, input, env) {
|
|
892
|
+
try {
|
|
893
|
+
return loadClientConfig(env);
|
|
894
|
+
} catch (error) {
|
|
895
|
+
const hint = identityHint(op, typeof input === "object" && input !== null && "mode" in input && typeof input.mode === "string" ? input.mode : void 0);
|
|
896
|
+
if (error instanceof CliError && error.code === "identity_missing" && hint) throw new CliError(error.code, error.context, error.requestId, hint);
|
|
897
|
+
throw error;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
883
900
|
function exampleCommand(op, input) {
|
|
884
901
|
const words = ["board", op.cli.command];
|
|
885
902
|
for (const arg of op.cli.args) {
|
|
@@ -1076,7 +1093,7 @@ function createProgram(options = {}) {
|
|
|
1076
1093
|
if (keyOption === "") throw new CliError("usage");
|
|
1077
1094
|
if (keyOption !== void 0 && escapeTerminalControls(keyOption) !== keyOption) throw new CliError("usage", void 0, void 0, "The idempotency key must contain only printable characters.");
|
|
1078
1095
|
if (op.kind === "mutation" && env["SPUR_SESSION"] && !keyOption) throw new CliError("usage");
|
|
1079
|
-
const config = options.clientConfig ??
|
|
1096
|
+
const config = options.clientConfig ?? loadOperationConfig(op, input, env);
|
|
1080
1097
|
const key = op.kind === "mutation" ? keyOption || randomUUID() : void 0;
|
|
1081
1098
|
if (key) io.stderr(`key: ${escapeTerminalControls(key)}\n`);
|
|
1082
1099
|
let instance;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as errorEnvelopeSchema, I as successEnvelopeSchema, N as ERRORS, P as errorContextSchema, d as renderJsonError } from "./src-
|
|
1
|
+
import { F as errorEnvelopeSchema, I as successEnvelopeSchema, N as ERRORS, P as errorContextSchema, d as renderJsonError } from "./src-CjlXSUX-.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
|
@@ -153,7 +153,7 @@ function send({ method, path, body, config, anonymous, decode, observe }) {
|
|
|
153
153
|
}
|
|
154
154
|
/** Shared daemon HTTP client. The CLI owns output; this module owns transport and wire parsing. */
|
|
155
155
|
async function requestOperation(op, input, key, config, observe) {
|
|
156
|
-
if (!config.session && !config.token) throw new CliError("
|
|
156
|
+
if (!config.session && !config.token) throw new CliError("identity_missing");
|
|
157
157
|
return send({
|
|
158
158
|
method: "POST",
|
|
159
159
|
path: `/v1/ops/${encodeURIComponent(op.id)}`,
|
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-B3aIcQ5T.mjs";
|
|
2
2
|
export { fetchCatalogVersion, requestOperation, requestTokenEnrollment };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as configSchema, l as OPERATIONS, s as buildCatalogSnapshot } from "./src-
|
|
2
|
-
import { i as CliError, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { V as configSchema, l as OPERATIONS, s as buildCatalogSnapshot } from "./src-CjlXSUX-.mjs";
|
|
2
|
+
import { i as CliError, t as fetchCatalogVersion } from "./client-B3aIcQ5T.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";
|
|
@@ -90,7 +90,10 @@ function loadClientConfig(env = process.env, paths = {
|
|
|
90
90
|
const address = resolveDaemonAddress(env, paths.home);
|
|
91
91
|
const session = env["SPUR_SESSION"] || void 0;
|
|
92
92
|
const token = session ? void 0 : env["BOARD_TOKEN"] === void 0 ? findTokenFile(paths.cwd, paths.home) : env["BOARD_TOKEN"];
|
|
93
|
-
if (!session && !token)
|
|
93
|
+
if (!session && !token) {
|
|
94
|
+
if (env["BOARD_TOKEN"] === "") throw new CliError("config", { environmentVariable: "BOARD_TOKEN" });
|
|
95
|
+
throw new CliError("identity_missing");
|
|
96
|
+
}
|
|
94
97
|
return {
|
|
95
98
|
address,
|
|
96
99
|
session,
|
package/dist/daemon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as parseActorId, B as RESERVED_PROJECT, C as prFactsSchema, D as actorIdSchema, E as ticketFactsSchema, H as requiredSecretKeys, I as successEnvelopeSchema, M as taskKeySchema, N as ERRORS, O as encodeActorId, S as SESSION_STATUSES, T as sessionFactsSchema, U as SLACK_BOT_SCOPES, V as configSchema, _ as messageRefSchema, a as entityRefSchema, b as eventPayloadSchemas, c as roleCanUseOperation, g as interactionRefSchema, h as inboundEventSchema, i as batchSchema, j as parseRef$1, k as errorCodeOf, l as OPERATIONS, m as conversationRefSchema, o as sourceCursorSchema, p as SPACE_IDS, r as AdapterError, s as buildCatalogSnapshot, t as BOARD_TICK_MS, u as renderHttpProblem, v as userIdSchema, w as prRefSchema, x as SESSION_HEALTH_STATES, y as EVENT_KINDS, z as DEFAULT_SLACK_COMMAND } from "./src-
|
|
1
|
+
import { A as parseActorId, B as RESERVED_PROJECT, C as prFactsSchema, D as actorIdSchema, E as ticketFactsSchema, H as requiredSecretKeys, I as successEnvelopeSchema, M as taskKeySchema, N as ERRORS, O as encodeActorId, S as SESSION_STATUSES, T as sessionFactsSchema, U as SLACK_BOT_SCOPES, V as configSchema, _ as messageRefSchema, a as entityRefSchema, b as eventPayloadSchemas, c as roleCanUseOperation, g as interactionRefSchema, h as inboundEventSchema, i as batchSchema, j as parseRef$1, k as errorCodeOf, l as OPERATIONS, m as conversationRefSchema, o as sourceCursorSchema, p as SPACE_IDS, r as AdapterError, s as buildCatalogSnapshot, t as BOARD_TICK_MS, u as renderHttpProblem, v as userIdSchema, w as prRefSchema, x as SESSION_HEALTH_STATES, y as EVENT_KINDS, z as DEFAULT_SLACK_COMMAND } from "./src-CjlXSUX-.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { closeSync, existsSync, fstatSync, ftruncateSync, mkdirSync, openSync, readFileSync, readdirSync, writeSync } from "node:fs";
|
|
@@ -16044,8 +16044,58 @@ function createBoardModules(ctxFor, options = {}) {
|
|
|
16044
16044
|
}];
|
|
16045
16045
|
}
|
|
16046
16046
|
//#endregion
|
|
16047
|
+
//#region ../daemon/src/spur-port.ts
|
|
16048
|
+
const SEND_TIMEOUT_MS = 8e3;
|
|
16049
|
+
const ERROR_TEXT_LIMIT = 200;
|
|
16050
|
+
/** The request Spur's own `spur send` makes; the doctor probe sends the same one. */
|
|
16051
|
+
function spurSendRequest(baseUrl, session, text) {
|
|
16052
|
+
return {
|
|
16053
|
+
url: new URL(`sessions/${encodeURIComponent(session)}/send`, new URL(`${baseUrl.replace(/\/$/, "")}/`)),
|
|
16054
|
+
init: {
|
|
16055
|
+
method: "POST",
|
|
16056
|
+
headers: { "Content-Type": "application/json" },
|
|
16057
|
+
body: JSON.stringify({ message: text })
|
|
16058
|
+
}
|
|
16059
|
+
};
|
|
16060
|
+
}
|
|
16061
|
+
/** The `error` string of a Spur error body, cut to a bounded length; null when unreadable. */
|
|
16062
|
+
async function spurErrorText(response) {
|
|
16063
|
+
try {
|
|
16064
|
+
const value = await response.json();
|
|
16065
|
+
if (value === null || typeof value !== "object" || !("error" in value)) return null;
|
|
16066
|
+
return typeof value.error === "string" ? value.error.slice(0, ERROR_TEXT_LIMIT) : null;
|
|
16067
|
+
} catch {
|
|
16068
|
+
return null;
|
|
16069
|
+
}
|
|
16070
|
+
}
|
|
16071
|
+
/** Send a doorbell through the Spur HTTP API; runs no executable, so PATH does not matter. */
|
|
16072
|
+
function createSpurPort(options) {
|
|
16073
|
+
return { async send(session, text) {
|
|
16074
|
+
const { url, init } = spurSendRequest(options.baseUrl, session, text);
|
|
16075
|
+
let response;
|
|
16076
|
+
try {
|
|
16077
|
+
response = await fetch(url, {
|
|
16078
|
+
...init,
|
|
16079
|
+
signal: AbortSignal.timeout(options.timeoutMs ?? SEND_TIMEOUT_MS)
|
|
16080
|
+
});
|
|
16081
|
+
} catch (cause) {
|
|
16082
|
+
if (cause instanceof Error && cause.name === "TimeoutError") throw new Error("Spur send timed out", { cause });
|
|
16083
|
+
throw new Error("Spur API unreachable", { cause });
|
|
16084
|
+
}
|
|
16085
|
+
if (response.ok) {
|
|
16086
|
+
await response.body?.cancel().catch(() => void 0);
|
|
16087
|
+
return;
|
|
16088
|
+
}
|
|
16089
|
+
const error = await spurErrorText(response);
|
|
16090
|
+
throw new Error(`Spur send failed with HTTP ${String(response.status)}${error === null ? "" : `: ${error}`}`);
|
|
16091
|
+
} };
|
|
16092
|
+
}
|
|
16093
|
+
//#endregion
|
|
16047
16094
|
//#region ../daemon/src/doctor.ts
|
|
16048
16095
|
const TIMEOUT_MS = 5e3;
|
|
16096
|
+
const SPUR_PROBE_SESSION = "spur-board-doctor-probe";
|
|
16097
|
+
const SPUR_SEND_UNREACHABLE_FIX = "Start Spur or correct adapters.spur.baseUrl in config.yaml, then restart the service; the daemon sends doorbells to that Spur API.";
|
|
16098
|
+
const SPUR_SEND_FIX = "The Spur API at adapters.spur.baseUrl did not accept a doorbell send; update Spur or point adapters.spur.baseUrl at the Spur daemon.";
|
|
16049
16099
|
const GITHUB_FIX = "Check the GitHub token and repository access.";
|
|
16050
16100
|
const GITHUB_CHECKS_FIX = "Use a classic GitHub personal access token with the repo scope, authorized for organization SSO where required, to read check runs.";
|
|
16051
16101
|
const GITHUB_TEAMS_FIX = "Use a classic GitHub personal access token with the repo and read:org scopes to read requested review teams.";
|
|
@@ -16218,8 +16268,12 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch) {
|
|
|
16218
16268
|
return null;
|
|
16219
16269
|
}))).find((failure) => failure !== null) ?? null;
|
|
16220
16270
|
checks.push(check("github.credentials", githubFailure === null, githubFailure ?? GITHUB_FIX));
|
|
16221
|
-
const
|
|
16271
|
+
const probe = spurSendRequest(config.adapters.spur.baseUrl, SPUR_PROBE_SESSION, "spur-board doctor probe");
|
|
16272
|
+
const [spur, spurSend] = await Promise.all([request(ctx, fetcher, "spur", new URL("sessions", `${config.adapters.spur.baseUrl.replace(/\/$/, "")}/`)), request(ctx, fetcher, "spur.send", probe.url, probe.init)]);
|
|
16222
16273
|
checks.push(check("spur.api", spur?.ok === true, "Start or correct the configured Spur API."));
|
|
16274
|
+
const spurSendOk = spurSend?.status === 404 && ((await spurErrorText(spurSend))?.startsWith("Session not found") ?? false);
|
|
16275
|
+
if (spurSend !== null && spurSend.status !== 404) await spurSend.body?.cancel().catch(() => void 0);
|
|
16276
|
+
checks.push(check("spur.send", spurSendOk, spurSend === null ? SPUR_SEND_UNREACHABLE_FIX : SPUR_SEND_FIX));
|
|
16223
16277
|
if (!slackConfigured) checks.push(warning("slack.configured", "Slack is not configured: questions addressed to you are only visible through board inbox. Run the spur-board-setup skill to configure slack.channels."));
|
|
16224
16278
|
else {
|
|
16225
16279
|
const botToken = secrets["SLACK_BOT_TOKEN"];
|
|
@@ -16381,57 +16435,6 @@ function createInboundModule(ctx, gateway, registry = {}) {
|
|
|
16381
16435
|
};
|
|
16382
16436
|
}
|
|
16383
16437
|
//#endregion
|
|
16384
|
-
//#region ../daemon/src/spur-port.ts
|
|
16385
|
-
const SEND_TIMEOUT_MS = 8e3;
|
|
16386
|
-
const KILL_GRACE_MS = 200;
|
|
16387
|
-
/** Send a doorbell through Spur without invoking a shell. */
|
|
16388
|
-
function createSpurPort(options = {}) {
|
|
16389
|
-
return { send(session, text) {
|
|
16390
|
-
return new Promise((resolve, reject) => {
|
|
16391
|
-
const child = spawn("spur", [
|
|
16392
|
-
"send",
|
|
16393
|
-
session,
|
|
16394
|
-
text
|
|
16395
|
-
], {
|
|
16396
|
-
stdio: [
|
|
16397
|
-
"ignore",
|
|
16398
|
-
"ignore",
|
|
16399
|
-
"pipe"
|
|
16400
|
-
],
|
|
16401
|
-
...options.env === void 0 ? {} : { env: options.env }
|
|
16402
|
-
});
|
|
16403
|
-
let stderr = "";
|
|
16404
|
-
let timedOut = false;
|
|
16405
|
-
let killTimer;
|
|
16406
|
-
const timeout = setTimeout(() => {
|
|
16407
|
-
timedOut = true;
|
|
16408
|
-
child.kill("SIGTERM");
|
|
16409
|
-
killTimer = setTimeout(() => {
|
|
16410
|
-
child.kill("SIGKILL");
|
|
16411
|
-
}, options.killGraceMs ?? KILL_GRACE_MS);
|
|
16412
|
-
}, options.timeoutMs ?? SEND_TIMEOUT_MS);
|
|
16413
|
-
child.stderr.on("data", (chunk) => {
|
|
16414
|
-
stderr = (stderr + chunk.toString()).slice(-1024);
|
|
16415
|
-
});
|
|
16416
|
-
child.once("error", () => {
|
|
16417
|
-
clearTimeout(timeout);
|
|
16418
|
-
if (killTimer !== void 0) clearTimeout(killTimer);
|
|
16419
|
-
reject(/* @__PURE__ */ new Error("spur send failed to start"));
|
|
16420
|
-
});
|
|
16421
|
-
child.once("close", (code) => {
|
|
16422
|
-
clearTimeout(timeout);
|
|
16423
|
-
if (killTimer !== void 0) clearTimeout(killTimer);
|
|
16424
|
-
if (timedOut) {
|
|
16425
|
-
reject(/* @__PURE__ */ new Error("spur send timed out"));
|
|
16426
|
-
return;
|
|
16427
|
-
}
|
|
16428
|
-
if (code === 0) resolve();
|
|
16429
|
-
else reject(/* @__PURE__ */ new Error(`spur send failed (${String(code)}): ${stderr.trim()}`));
|
|
16430
|
-
});
|
|
16431
|
-
});
|
|
16432
|
-
} };
|
|
16433
|
-
}
|
|
16434
|
-
//#endregion
|
|
16435
16438
|
//#region ../daemon/src/outbox-module.ts
|
|
16436
16439
|
const TICK_MS = 1e3;
|
|
16437
16440
|
const TICK_JITTER_MS = 100;
|
|
@@ -16475,7 +16478,7 @@ function slackSettings(config, secrets) {
|
|
|
16475
16478
|
* closes.
|
|
16476
16479
|
*/
|
|
16477
16480
|
function createOutboxModule(ctx, gateway, options = {}) {
|
|
16478
|
-
const spur = options.spur ?? createSpurPort();
|
|
16481
|
+
const spur = options.spur ?? createSpurPort({ baseUrl: ctx.config.adapters.spur.baseUrl });
|
|
16479
16482
|
const sender = createSender({
|
|
16480
16483
|
store: ctx.store,
|
|
16481
16484
|
...gateway === void 0 ? {} : { gateway },
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { N as ERRORS, f as renderMcpError, l as OPERATIONS } from "./src-
|
|
2
|
-
import { i as CliError, n as requestOperation } from "./client-
|
|
3
|
-
import { a as memoryVerdictCache, r as compareCatalogs, s as loadClientConfig, t as checkCatalog } from "./config-
|
|
1
|
+
import { N as ERRORS, f as renderMcpError, l as OPERATIONS } from "./src-CjlXSUX-.mjs";
|
|
2
|
+
import { i as CliError, n as requestOperation } from "./client-B3aIcQ5T.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, r as compareCatalogs, s as loadClientConfig, t as checkCatalog } from "./config-DWp8J6RP.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -551,6 +551,13 @@ const ERRORS = {
|
|
|
551
551
|
hint: "Fix the configuration file named in the error, then run the command again.",
|
|
552
552
|
recovery: noRetry("Fix the named configuration file and retry.")
|
|
553
553
|
}),
|
|
554
|
+
identity_missing: spec("identity_missing", {
|
|
555
|
+
status: null,
|
|
556
|
+
exit: EXIT_CODES.config,
|
|
557
|
+
message: "No caller identity was found: this is not a Spur session and no .spur-board/token was found walking up from the current folder.",
|
|
558
|
+
hint: "Run the command in a Spur session of a project listed in config.yaml, or run `board token create --name <name> --into <folder>` and ask the operator to approve the request in Slack.",
|
|
559
|
+
recovery: noRetry("Get a caller identity as the fix says, then run the command again.")
|
|
560
|
+
}),
|
|
554
561
|
outcome_unknown: spec("outcome_unknown", {
|
|
555
562
|
status: null,
|
|
556
563
|
exit: EXIT_CODES.outcomeUnknown,
|