spur-board 0.11.2 → 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 CHANGED
@@ -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 = [
package/dist/daemon.mjs CHANGED
@@ -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 spur = await request(ctx, fetcher, "spur", new URL("sessions", `${config.adapters.spur.baseUrl.replace(/\/$/, "")}/`));
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"