spur-board 0.11.2 → 0.12.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 CHANGED
@@ -1,15 +1,17 @@
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";
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-4YeTky_x.mjs";
2
+ import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-BxeRGI6U.mjs";
3
+ import { a as memoryVerdictCache, c as loadEnrollmentConfig, i as fileVerdictCache, l as readConfiguredPort, n as cliPackageVersion, o as configFile, s as loadClientConfig, t as checkCatalog, u as resolveDaemonAddress } from "./config-BkpjmVZh.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";
7
7
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
8
8
  import { Command, CommanderError } from "@commander-js/extra-typings";
9
9
  import { z } from "zod";
10
+ import { get } from "node:http";
10
11
  import YAML from "yaml";
11
12
  import { spawn, spawnSync } from "node:child_process";
12
13
  import { parseEnv } from "node:util";
14
+ import { createServer } from "node:net";
13
15
  import { access, cp, lstat, mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
14
16
  import { fileURLToPath } from "node:url";
15
17
  //#region src/manifest.ts
@@ -62,6 +64,70 @@ function renderSlackManifest(options = {}) {
62
64
  }, { lineWidth: 0 });
63
65
  }
64
66
  //#endregion
67
+ //#region src/port.ts
68
+ /** A private copy of the client's check: client.ts is the published entry, so it exports nothing new. */
69
+ const instanceHeader = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
70
+ /** Bind 127.0.0.1:port as the daemon would and close at once; returns the error code, or null when free. */
71
+ function bindLoopback(port) {
72
+ return new Promise((resolve) => {
73
+ const server = createServer();
74
+ server.once("error", (error) => {
75
+ resolve(error.code ?? "unknown error");
76
+ });
77
+ server.listen({
78
+ port,
79
+ host: "127.0.0.1"
80
+ }, () => {
81
+ server.close(() => {
82
+ resolve(null);
83
+ });
84
+ });
85
+ });
86
+ }
87
+ /**
88
+ * Ask the holder for its board instance header over node:http, the client's transport. fetch would
89
+ * refuse ports on its bad-port list (6000, 6667, ...) that the config allows, and would follow a
90
+ * redirect to a daemon on another port; node:http does neither. The deadline is absolute: a socket
91
+ * timeout would reset on every byte a trickling holder sends.
92
+ */
93
+ function isBoardDaemon(port) {
94
+ return new Promise((resolve) => {
95
+ get({
96
+ host: "127.0.0.1",
97
+ port,
98
+ path: "/v1/schema",
99
+ agent: false,
100
+ signal: AbortSignal.timeout(2e3)
101
+ }, (response) => {
102
+ const value = response.headers["x-board-instance"];
103
+ response.destroy();
104
+ resolve(typeof value === "string" && instanceHeader.test(value));
105
+ }).once("error", () => {
106
+ resolve(false);
107
+ });
108
+ });
109
+ }
110
+ async function holderOf(port, probe) {
111
+ let listed = "";
112
+ try {
113
+ const result = await probe.run("ss", ["-ltnp", `sport = :${String(port)}`]);
114
+ if (result.exitCode === 0) listed = result.stdout;
115
+ } catch {}
116
+ const match = /users:\(\("([^"]*)",pid=(\d+)/.exec(listed);
117
+ if (match?.[1] === void 0 || match[2] === void 0) return "a process not visible to this user";
118
+ return `${escapeTerminalControls(match[1])} (pid ${match[2]})`;
119
+ }
120
+ /** The fix when the daemon could not listen on http.port, or null when it is 0, free or held by a board daemon. */
121
+ async function checkHttpPort(port, probe) {
122
+ if (port === 0) return null;
123
+ const code = await probe.bind(port);
124
+ if (code === null) return null;
125
+ const label = `Port ${String(port)} (http.port)`;
126
+ if (code !== "EADDRINUSE") return `${label} cannot be bound on 127.0.0.1 (${escapeTerminalControls(code)}). Set http.port in config.yaml to a free unprivileged port.`;
127
+ if (await isBoardDaemon(port)) return null;
128
+ return `${label} is held by ${await holderOf(port, probe)}. Stop that process or set http.port in config.yaml to a free port, then start the service again.`;
129
+ }
130
+ //#endregion
65
131
  //#region src/doctor.ts
66
132
  function systemRun(command, args, env) {
67
133
  const result = spawnSync(command, [...args], {
@@ -139,7 +205,8 @@ const defaultPorts = {
139
205
  const value = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
140
206
  if (value && typeof value === "object" && "version" in value && typeof value.version === "string") return value.version;
141
207
  throw new Error("Invalid package version");
142
- }
208
+ },
209
+ bind: bindLoopback
143
210
  };
144
211
  function result(id, ok, fix) {
145
212
  return {
@@ -236,6 +303,7 @@ const remoteBaseIds = [
236
303
  "jira.credentials",
237
304
  "github.credentials",
238
305
  "spur.api",
306
+ "spur.send",
239
307
  "operator.path"
240
308
  ];
241
309
  const remoteSlackIds = [
@@ -338,6 +406,11 @@ async function runDoctor(options = {}) {
338
406
  const unknownStarts = sessions.some((session) => session.startAt === void 0);
339
407
  const staleIds = stale.map((session) => session.id).filter((id) => /^[a-zA-Z0-9_-]+$/.test(id)).slice(0, 10);
340
408
  checks.push(stale.length > 0 || unknownStarts ? warning("sessions.stale", `Restart sessions started before the last skill install${staleIds.length ? `: ${staleIds.join(", ")}` : ""}; verify sessions whose start time is unavailable.`) : result("sessions.stale", true, "Restart older sessions."));
409
+ const portFix = await checkHttpPort(config.http.port, {
410
+ bind: ports.bind,
411
+ run: (command, args) => Promise.resolve(ports.run(command, args))
412
+ });
413
+ checks.push(result("http.port", portFix === null, portFix ?? ""));
341
414
  let remote = null;
342
415
  try {
343
416
  const address = resolveDaemonAddress(env, home, config.http.port);
@@ -480,6 +553,11 @@ async function installService(options = {}) {
480
553
  const paths = servicePaths(options);
481
554
  await preflight(paths);
482
555
  const runner = options.runner ?? runCommand;
556
+ const fix = await checkHttpPort(readConfiguredPort(options.env ?? process.env, resolve(options.home ?? homedir())), {
557
+ bind: options.bind ?? bindLoopback,
558
+ run: runner
559
+ });
560
+ if (fix !== null) throw new Error(fix);
483
561
  const unit = renderUserUnit(paths);
484
562
  const previousUnit = await existingUnit(paths.unitFile);
485
563
  const changed = previousUnit !== unit;
@@ -1,4 +1,4 @@
1
- import { F as errorEnvelopeSchema, I as successEnvelopeSchema, N as ERRORS, P as errorContextSchema, d as renderJsonError } from "./src-CjlXSUX-.mjs";
1
+ import { F as errorEnvelopeSchema, I as successEnvelopeSchema, N as ERRORS, P as errorContextSchema, d as renderJsonError } from "./src-4YeTky_x.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-B3aIcQ5T.mjs";
1
+ import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-BxeRGI6U.mjs";
2
2
  export { fetchCatalogVersion, requestOperation, requestTokenEnrollment };
@@ -1,5 +1,5 @@
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";
1
+ import { L as DEFAULT_HTTP_PORT, V as configSchema, l as OPERATIONS, s as buildCatalogSnapshot } from "./src-4YeTky_x.mjs";
2
+ import { i as CliError, t as fetchCatalogVersion } from "./client-BxeRGI6U.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";
@@ -15,17 +15,21 @@ function configFile(env, home) {
15
15
  const xdg = env["XDG_CONFIG_HOME"];
16
16
  return join(xdg && isAbsolute(xdg) ? xdg : join(home, ".config"), "spur-board", "config.yaml");
17
17
  }
18
+ /** The http.port in config.yaml, or the default when the file is missing or invalid. */
19
+ function readConfiguredPort(env, home) {
20
+ try {
21
+ const parsed = YAML.parseDocument(readFileSync(configFile(env, home), "utf8"));
22
+ if (parsed.errors.length === 0) {
23
+ const config = configSchema.safeParse(parsed.toJS());
24
+ if (config.success) return config.data.http.port;
25
+ }
26
+ } catch {}
27
+ return DEFAULT_HTTP_PORT;
28
+ }
18
29
  function resolveDaemonAddress(env = process.env, home = homedir(), configuredPort) {
19
30
  const rawAddress = env["BOARD_DAEMON_URL"];
20
31
  if (rawAddress === void 0) {
21
- let port = configuredPort ?? 4311;
22
- if (configuredPort === void 0) try {
23
- const parsed = YAML.parseDocument(readFileSync(configFile(env, home), "utf8"));
24
- if (parsed.errors.length === 0) {
25
- const config = configSchema.safeParse(parsed.toJS());
26
- if (config.success) port = config.data.http.port;
27
- }
28
- } catch {}
32
+ const port = configuredPort ?? readConfiguredPort(env, home);
29
33
  if (port === 0) throw new CliError("config", void 0, void 0, "http.port: 0 assigns a runtime port that clients cannot discover. Set BOARD_DAEMON_URL to the daemon listening address.");
30
34
  return new URL(`http://127.0.0.1:${String(port)}`);
31
35
  }
@@ -229,4 +233,4 @@ function fileVerdictCache(path, cliVersion) {
229
233
  } };
230
234
  }
231
235
  //#endregion
232
- export { memoryVerdictCache as a, loadEnrollmentConfig as c, fileVerdictCache as i, resolveDaemonAddress as l, cliPackageVersion as n, configFile as o, compareCatalogs as r, loadClientConfig as s, checkCatalog as t };
236
+ export { memoryVerdictCache as a, loadEnrollmentConfig as c, fileVerdictCache as i, readConfiguredPort as l, cliPackageVersion as n, configFile as o, compareCatalogs as r, loadClientConfig as s, checkCatalog as t, resolveDaemonAddress as u };
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-CjlXSUX-.mjs";
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-4YeTky_x.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";
@@ -13816,6 +13816,8 @@ const milestoneWire = z.object({
13816
13816
  title: z.string(),
13817
13817
  number: z.int().positive()
13818
13818
  });
13819
+ const repositoryWire = z.object({ id: z.int().positive() });
13820
+ const PAGINATION = "Malformed GitHub issue pagination";
13819
13821
  function issueNumber(ref, repo) {
13820
13822
  const match = /^(.+)#([1-9]\d*)$/.exec(ref.key);
13821
13823
  if (match?.[1]?.toLowerCase() !== repo.toLowerCase()) throw new AdapterError("config", "Requested issue is outside its configured repository");
@@ -13878,22 +13880,32 @@ function createGithubIssuesAdapter(options) {
13878
13880
  throw new AdapterError("transient", "Malformed GitHub issue response");
13879
13881
  }
13880
13882
  const next = response.headers.get("link")?.match(/<([^>]+)>;\s*rel="next"/)?.[1];
13881
- if (next !== void 0) {
13882
- let pageUrl;
13883
- try {
13884
- pageUrl = new URL(next);
13885
- } catch {
13886
- throw new AdapterError("transient", "Malformed GitHub issue pagination");
13887
- }
13888
- const issuePath = new URL(root).pathname + "/issues";
13889
- const milestonePath = new URL(root).pathname + "/milestones";
13890
- if (pageUrl.origin !== "https://api.github.com" || pageUrl.pathname !== issuePath && pageUrl.pathname !== milestonePath) throw new AdapterError("transient", "Malformed GitHub issue pagination");
13891
- }
13892
13883
  return {
13893
13884
  value,
13894
13885
  ...next === void 0 ? {} : { next }
13895
13886
  };
13896
13887
  }
13888
+ let repositoryId;
13889
+ /** Rejects a next link outside this repository before any request goes to it. */
13890
+ async function checkNext(next, signal) {
13891
+ let pageUrl;
13892
+ try {
13893
+ pageUrl = new URL(next);
13894
+ } catch {
13895
+ throw new AdapterError("transient", PAGINATION);
13896
+ }
13897
+ const base = new URL(root);
13898
+ if (pageUrl.origin !== base.origin) throw new AdapterError("transient", PAGINATION);
13899
+ if (pageUrl.pathname === base.pathname + "/issues") return;
13900
+ if (pageUrl.pathname === base.pathname + "/milestones") return;
13901
+ const match = /^\/repositories\/([1-9]\d*)\/(?:issues|milestones)$/.exec(pageUrl.pathname);
13902
+ if (match === null) throw new AdapterError("transient", PAGINATION);
13903
+ repositoryId ??= parseWire(repositoryWire, (await request(root, signal)).value, MALFORMED).id;
13904
+ if (Number(match[1]) !== repositoryId) {
13905
+ repositoryId = void 0;
13906
+ throw new AdapterError("transient", PAGINATION);
13907
+ }
13908
+ }
13897
13909
  async function pages(url, signal, allowPartial = false) {
13898
13910
  const results = [];
13899
13911
  const seen = /* @__PURE__ */ new Set();
@@ -13912,6 +13924,15 @@ function createGithubIssuesAdapter(options) {
13912
13924
  throw error;
13913
13925
  }
13914
13926
  results.push(...parseWire(z.array(z.unknown()), page.value, "Malformed GitHub issue listing"));
13927
+ if (page.next !== void 0) try {
13928
+ await checkNext(page.next, signal);
13929
+ } catch (error) {
13930
+ if (allowPartial && error instanceof AdapterError && error.kind === "transient") return {
13931
+ values: results,
13932
+ complete: false
13933
+ };
13934
+ throw error;
13935
+ }
13915
13936
  next = page.next;
13916
13937
  }
13917
13938
  return {
@@ -16044,8 +16065,58 @@ function createBoardModules(ctxFor, options = {}) {
16044
16065
  }];
16045
16066
  }
16046
16067
  //#endregion
16068
+ //#region ../daemon/src/spur-port.ts
16069
+ const SEND_TIMEOUT_MS = 8e3;
16070
+ const ERROR_TEXT_LIMIT = 200;
16071
+ /** The request Spur's own `spur send` makes; the doctor probe sends the same one. */
16072
+ function spurSendRequest(baseUrl, session, text) {
16073
+ return {
16074
+ url: new URL(`sessions/${encodeURIComponent(session)}/send`, new URL(`${baseUrl.replace(/\/$/, "")}/`)),
16075
+ init: {
16076
+ method: "POST",
16077
+ headers: { "Content-Type": "application/json" },
16078
+ body: JSON.stringify({ message: text })
16079
+ }
16080
+ };
16081
+ }
16082
+ /** The `error` string of a Spur error body, cut to a bounded length; null when unreadable. */
16083
+ async function spurErrorText(response) {
16084
+ try {
16085
+ const value = await response.json();
16086
+ if (value === null || typeof value !== "object" || !("error" in value)) return null;
16087
+ return typeof value.error === "string" ? value.error.slice(0, ERROR_TEXT_LIMIT) : null;
16088
+ } catch {
16089
+ return null;
16090
+ }
16091
+ }
16092
+ /** Send a doorbell through the Spur HTTP API; runs no executable, so PATH does not matter. */
16093
+ function createSpurPort(options) {
16094
+ return { async send(session, text) {
16095
+ const { url, init } = spurSendRequest(options.baseUrl, session, text);
16096
+ let response;
16097
+ try {
16098
+ response = await fetch(url, {
16099
+ ...init,
16100
+ signal: AbortSignal.timeout(options.timeoutMs ?? SEND_TIMEOUT_MS)
16101
+ });
16102
+ } catch (cause) {
16103
+ if (cause instanceof Error && cause.name === "TimeoutError") throw new Error("Spur send timed out", { cause });
16104
+ throw new Error("Spur API unreachable", { cause });
16105
+ }
16106
+ if (response.ok) {
16107
+ await response.body?.cancel().catch(() => void 0);
16108
+ return;
16109
+ }
16110
+ const error = await spurErrorText(response);
16111
+ throw new Error(`Spur send failed with HTTP ${String(response.status)}${error === null ? "" : `: ${error}`}`);
16112
+ } };
16113
+ }
16114
+ //#endregion
16047
16115
  //#region ../daemon/src/doctor.ts
16048
16116
  const TIMEOUT_MS = 5e3;
16117
+ const SPUR_PROBE_SESSION = "spur-board-doctor-probe";
16118
+ 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.";
16119
+ 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
16120
  const GITHUB_FIX = "Check the GitHub token and repository access.";
16050
16121
  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
16122
  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 +16289,12 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch) {
16218
16289
  return null;
16219
16290
  }))).find((failure) => failure !== null) ?? null;
16220
16291
  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(/\/$/, "")}/`));
16292
+ const probe = spurSendRequest(config.adapters.spur.baseUrl, SPUR_PROBE_SESSION, "spur-board doctor probe");
16293
+ 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
16294
  checks.push(check("spur.api", spur?.ok === true, "Start or correct the configured Spur API."));
16295
+ const spurSendOk = spurSend?.status === 404 && ((await spurErrorText(spurSend))?.startsWith("Session not found") ?? false);
16296
+ if (spurSend !== null && spurSend.status !== 404) await spurSend.body?.cancel().catch(() => void 0);
16297
+ checks.push(check("spur.send", spurSendOk, spurSend === null ? SPUR_SEND_UNREACHABLE_FIX : SPUR_SEND_FIX));
16223
16298
  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
16299
  else {
16225
16300
  const botToken = secrets["SLACK_BOT_TOKEN"];
@@ -16381,57 +16456,6 @@ function createInboundModule(ctx, gateway, registry = {}) {
16381
16456
  };
16382
16457
  }
16383
16458
  //#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
16459
  //#region ../daemon/src/outbox-module.ts
16436
16460
  const TICK_MS = 1e3;
16437
16461
  const TICK_JITTER_MS = 100;
@@ -16475,7 +16499,7 @@ function slackSettings(config, secrets) {
16475
16499
  * closes.
16476
16500
  */
16477
16501
  function createOutboxModule(ctx, gateway, options = {}) {
16478
- const spur = options.spur ?? createSpurPort();
16502
+ const spur = options.spur ?? createSpurPort({ baseUrl: ctx.config.adapters.spur.baseUrl });
16479
16503
  const sender = createSender({
16480
16504
  store: ctx.store,
16481
16505
  ...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-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";
1
+ import { N as ERRORS, f as renderMcpError, l as OPERATIONS } from "./src-4YeTky_x.mjs";
2
+ import { i as CliError, n as requestOperation } from "./client-BxeRGI6U.mjs";
3
+ import { a as memoryVerdictCache, r as compareCatalogs, s as loadClientConfig, t as checkCatalog } from "./config-BkpjmVZh.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -110,7 +110,13 @@ const SLACK_BOT_SCOPES = [
110
110
  ];
111
111
  //#endregion
112
112
  //#region ../contracts/src/config.ts
113
- const DEFAULT_HTTP_PORT = 4311;
113
+ /**
114
+ * The daemon's default loopback port. It sits above 4310-4399, a margin the board keeps for
115
+ * Spur's server port 4310 and the ports from 4311 upward that Spur's MCP port takes. It also
116
+ * avoids Spur's web UI port 5555, its Playwright sidecars 8730-8799 and the Linux ephemeral
117
+ * range 32768-60999.
118
+ */
119
+ const DEFAULT_HTTP_PORT = 4777;
114
120
  const DEFAULT_SLACK_APP_NAME = "spur-board";
115
121
  const DEFAULT_SLACK_COMMAND = "/board";
116
122
  /**
@@ -289,7 +295,7 @@ const configSchema = z.strictObject({
289
295
  message: "Final unanswered pause must exceed the second retry pause"
290
296
  });
291
297
  }).prefault({}),
292
- http: z.strictObject({ port: z.int().min(0).max(65535).default(DEFAULT_HTTP_PORT).describe("Local HTTP API port (0 assigns a free port).") }).prefault({}),
298
+ http: z.strictObject({ port: z.int().min(0).max(65535).default(DEFAULT_HTTP_PORT).describe("Local HTTP API port (0 assigns a free port). The default 4777 is above 4310-4399, a margin kept for Spur's server port 4310 and the ports from 4311 upward that its MCP port takes, and avoids Spur's ports 5555 and 8730-8799 and the Linux ephemeral range 32768-60999.") }).prefault({}),
293
299
  adapters: z.strictObject({
294
300
  spur: spurAdapterSection,
295
301
  github: adapterSection(6e4),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.11.2",
3
+ "version": "0.12.0",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"