spur-board 0.11.3 → 0.12.1
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 +138 -33
- package/dist/{client-B3aIcQ5T.mjs → client-BOm8yksw.mjs} +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{config-DWp8J6RP.mjs → config-Dl7_gx5z.mjs} +15 -11
- package/dist/daemon.mjs +33 -12
- package/dist/mcp.mjs +3 -3
- package/dist/{src-CjlXSUX-.mjs → src-CYQZCwhN.mjs} +20 -2
- package/package.json +1 -1
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-
|
|
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
|
|
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-CYQZCwhN.mjs";
|
|
2
|
+
import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-BOm8yksw.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-Dl7_gx5z.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 {
|
|
@@ -339,6 +406,11 @@ async function runDoctor(options = {}) {
|
|
|
339
406
|
const unknownStarts = sessions.some((session) => session.startAt === void 0);
|
|
340
407
|
const staleIds = stale.map((session) => session.id).filter((id) => /^[a-zA-Z0-9_-]+$/.test(id)).slice(0, 10);
|
|
341
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 ?? ""));
|
|
342
414
|
let remote = null;
|
|
343
415
|
try {
|
|
344
416
|
const address = resolveDaemonAddress(env, home, config.http.port);
|
|
@@ -441,14 +513,46 @@ async function runCommand(command, args) {
|
|
|
441
513
|
});
|
|
442
514
|
});
|
|
443
515
|
}
|
|
516
|
+
function failureDetail(result) {
|
|
517
|
+
return result.stderr.trim() || result.stdout.trim() || `exit ${String(result.exitCode)}`;
|
|
518
|
+
}
|
|
444
519
|
async function requireSuccess(runner, command, args) {
|
|
445
520
|
const result = await runner(command, args);
|
|
446
|
-
if (result.exitCode !== 0) {
|
|
447
|
-
const detail = result.stderr.trim() || result.stdout.trim() || `exit ${String(result.exitCode)}`;
|
|
448
|
-
throw new Error(`${command} ${args.join(" ")} failed: ${detail}`);
|
|
449
|
-
}
|
|
521
|
+
if (result.exitCode !== 0) throw new Error(`${command} ${args.join(" ")} failed: ${failureDetail(result)}`);
|
|
450
522
|
return result;
|
|
451
523
|
}
|
|
524
|
+
async function unitState(runner) {
|
|
525
|
+
const active = await runner("systemctl", [
|
|
526
|
+
"--user",
|
|
527
|
+
"is-active",
|
|
528
|
+
serviceName
|
|
529
|
+
]);
|
|
530
|
+
const enabled = await runner("systemctl", [
|
|
531
|
+
"--user",
|
|
532
|
+
"is-enabled",
|
|
533
|
+
serviceName
|
|
534
|
+
]);
|
|
535
|
+
return {
|
|
536
|
+
active: active.stdout.trim() || "unknown",
|
|
537
|
+
enabled: enabled.stdout.trim() || "unknown"
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
/** Runs a systemctl command that starts the service; a failure leaves the unit in place. */
|
|
541
|
+
async function requireStart(runner, args, unit) {
|
|
542
|
+
const result = await runner("systemctl", args);
|
|
543
|
+
if (result.exitCode === 0) return;
|
|
544
|
+
const detail = failureDetail(result).replace(/\s*\n\s*/g, " ").replace(/\.$/, "");
|
|
545
|
+
const state = await unitState(runner).catch(() => ({
|
|
546
|
+
active: "unknown",
|
|
547
|
+
enabled: "unknown"
|
|
548
|
+
}));
|
|
549
|
+
const origin = unit.written === void 0 ? "" : unit.written ? " (written by this run)" : " (already in place)";
|
|
550
|
+
throw new CliError("service_start_failed", void 0, void 0, [
|
|
551
|
+
`Unit file ${unit.file}${origin} is ${state.enabled}; the service is ${state.active}.`,
|
|
552
|
+
`systemctl ${args.join(" ")} failed: ${detail}.`,
|
|
553
|
+
"Read why with `journalctl --user -u spur-board.service -n 100` and run `board doctor`."
|
|
554
|
+
].join(" "));
|
|
555
|
+
}
|
|
452
556
|
async function preflight(paths) {
|
|
453
557
|
for (const [label, path] of [["Node executable", paths.nodePath], ["daemon entry", paths.daemonEntry]]) {
|
|
454
558
|
if (!isAbsolute(path)) throw new Error(`${label} path must be absolute: ${path}`);
|
|
@@ -481,6 +585,11 @@ async function installService(options = {}) {
|
|
|
481
585
|
const paths = servicePaths(options);
|
|
482
586
|
await preflight(paths);
|
|
483
587
|
const runner = options.runner ?? runCommand;
|
|
588
|
+
const fix = await checkHttpPort(readConfiguredPort(options.env ?? process.env, resolve(options.home ?? homedir())), {
|
|
589
|
+
bind: options.bind ?? bindLoopback,
|
|
590
|
+
run: runner
|
|
591
|
+
});
|
|
592
|
+
if (fix !== null) throw new Error(fix);
|
|
484
593
|
const unit = renderUserUnit(paths);
|
|
485
594
|
const previousUnit = await existingUnit(paths.unitFile);
|
|
486
595
|
const changed = previousUnit !== unit;
|
|
@@ -498,51 +607,47 @@ async function installService(options = {}) {
|
|
|
498
607
|
wasActive = state.exitCode === 0 && state.stdout.trim() === "active";
|
|
499
608
|
}
|
|
500
609
|
}
|
|
501
|
-
|
|
610
|
+
const unitInfo = {
|
|
611
|
+
file: paths.unitFile,
|
|
612
|
+
written: changed
|
|
613
|
+
};
|
|
614
|
+
await requireStart(runner, [
|
|
502
615
|
"--user",
|
|
503
616
|
"enable",
|
|
504
617
|
"--now",
|
|
505
618
|
serviceName
|
|
506
|
-
]);
|
|
507
|
-
if (wasActive) await
|
|
619
|
+
], unitInfo);
|
|
620
|
+
if (wasActive) await requireStart(runner, [
|
|
508
621
|
"--user",
|
|
509
622
|
"restart",
|
|
510
623
|
serviceName
|
|
511
|
-
]);
|
|
624
|
+
], unitInfo);
|
|
512
625
|
return {
|
|
513
626
|
unitFile: paths.unitFile,
|
|
514
627
|
changed
|
|
515
628
|
};
|
|
516
629
|
}
|
|
517
630
|
async function restartService(options = {}) {
|
|
518
|
-
|
|
631
|
+
const unitFile = servicePaths(options).unitFile;
|
|
632
|
+
if (await existingUnit(unitFile) === void 0) throw new CliError("config", void 0, void 0, `Unit file ${unitFile} is not installed; run \`board service install\` first.`);
|
|
633
|
+
await requireStart(options.runner ?? runCommand, [
|
|
519
634
|
"--user",
|
|
520
635
|
"restart",
|
|
521
636
|
serviceName
|
|
522
|
-
]);
|
|
637
|
+
], { file: unitFile });
|
|
523
638
|
}
|
|
524
639
|
async function statusService(options = {}) {
|
|
525
640
|
const runner = options.runner ?? runCommand;
|
|
526
|
-
const active = await runner
|
|
527
|
-
"--user",
|
|
528
|
-
"is-active",
|
|
529
|
-
serviceName
|
|
530
|
-
]);
|
|
531
|
-
const enabled = await runner("systemctl", [
|
|
532
|
-
"--user",
|
|
533
|
-
"is-enabled",
|
|
534
|
-
serviceName
|
|
535
|
-
]);
|
|
536
|
-
const linger = await requireSuccess(runner, "loginctl", [
|
|
537
|
-
"show-user",
|
|
538
|
-
options.username ?? userInfo().username,
|
|
539
|
-
"--property=Linger",
|
|
540
|
-
"--value"
|
|
541
|
-
]);
|
|
641
|
+
const { active, enabled } = await unitState(runner);
|
|
542
642
|
return {
|
|
543
|
-
active
|
|
544
|
-
enabled
|
|
545
|
-
lingering:
|
|
643
|
+
active,
|
|
644
|
+
enabled,
|
|
645
|
+
lingering: (await requireSuccess(runner, "loginctl", [
|
|
646
|
+
"show-user",
|
|
647
|
+
options.username ?? userInfo().username,
|
|
648
|
+
"--property=Linger",
|
|
649
|
+
"--value"
|
|
650
|
+
])).stdout.trim() === "yes"
|
|
546
651
|
};
|
|
547
652
|
}
|
|
548
653
|
async function uninstallService(options = {}) {
|
|
@@ -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-CYQZCwhN.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-BOm8yksw.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 { L as DEFAULT_HTTP_PORT, V as configSchema, l as OPERATIONS, s as buildCatalogSnapshot } from "./src-CYQZCwhN.mjs";
|
|
2
|
+
import { i as CliError, t as fetchCatalogVersion } from "./client-BOm8yksw.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
|
-
|
|
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,
|
|
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-
|
|
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-CYQZCwhN.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 {
|
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-CYQZCwhN.mjs";
|
|
2
|
+
import { i as CliError, n as requestOperation } from "./client-BOm8yksw.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, r as compareCatalogs, s as loadClientConfig, t as checkCatalog } from "./config-Dl7_gx5z.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
|
-
|
|
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),
|
|
@@ -558,6 +564,18 @@ const ERRORS = {
|
|
|
558
564
|
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
565
|
recovery: noRetry("Get a caller identity as the fix says, then run the command again.")
|
|
560
566
|
}),
|
|
567
|
+
service_start_failed: spec("service_start_failed", {
|
|
568
|
+
status: null,
|
|
569
|
+
exit: EXIT_CODES.config,
|
|
570
|
+
message: "The service unit is installed, but the service did not start.",
|
|
571
|
+
hint: "Read why it failed with `journalctl --user -u spur-board.service -n 100` and run `board doctor`; systemd keeps restarting the service until the cause is fixed.",
|
|
572
|
+
recovery: {
|
|
573
|
+
action: "Fix the cause shown by `journalctl --user -u spur-board.service -n 100` and `board doctor`, then run `board service restart`.",
|
|
574
|
+
sideEffects: "applied",
|
|
575
|
+
maxRetries: 0,
|
|
576
|
+
retryTiming: "After fixing the cause."
|
|
577
|
+
}
|
|
578
|
+
}),
|
|
561
579
|
outcome_unknown: spec("outcome_unknown", {
|
|
562
580
|
status: null,
|
|
563
581
|
exit: EXIT_CODES.outcomeUnknown,
|