spur-board 0.21.0 → 0.22.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 +6 -6
- package/dist/{client-DPui_SJQ.mjs → client-B4JXkdZu.mjs} +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{config-5V7e_pTh.mjs → config-CreYUbFe.mjs} +21 -5
- package/dist/daemon.mjs +260 -185
- package/dist/mcp.mjs +3 -3
- package/dist/{src-21T39XXT.mjs → src-C6fOCG5L.mjs} +5 -1
- package/package.json +1 -1
- package/skills/setup/SKILL.md +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-C6fOCG5L.mjs";
|
|
2
|
+
import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-B4JXkdZu.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-CreYUbFe.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";
|
|
@@ -669,7 +669,7 @@ async function installService(options = {}) {
|
|
|
669
669
|
const paths = servicePaths(options);
|
|
670
670
|
await preflight(paths);
|
|
671
671
|
const runner = options.runner ?? runCommand;
|
|
672
|
-
const fix = await checkHttpPort(readConfiguredPort(options.env ?? process.env, resolve(options.home ?? homedir())), {
|
|
672
|
+
const fix = await checkHttpPort(readConfiguredPort(options.env ?? process.env, resolve(options.home ?? homedir())) ?? 4777, {
|
|
673
673
|
bind: options.bind ?? bindLoopback,
|
|
674
674
|
run: runner
|
|
675
675
|
});
|
|
@@ -2160,9 +2160,9 @@ function registerSetupCommands(program, options, io, env) {
|
|
|
2160
2160
|
commandFor(program, "mcp").summary("Start the MCP server for an agent on standard input and output.").description([
|
|
2161
2161
|
"Start the MCP server for an agent on standard input and output. Stdout carries only JSON-RPC.",
|
|
2162
2162
|
"",
|
|
2163
|
-
"Each tool call finds the caller: `SPUR_SESSION` inside a Spur session, otherwise `BOARD_TOKEN`, otherwise the first `.spur-board/token` found walking upward from the directory the agent starts it in, stopping at home.",
|
|
2163
|
+
"Each tool call finds the caller: `SPUR_SESSION` inside a Spur session, otherwise `BOARD_TOKEN`, otherwise the first `.spur-board/token` found walking upward from the directory the agent starts it in, stopping at the root of its git worktree, or at home outside git; home itself is never searched.",
|
|
2164
2164
|
"",
|
|
2165
|
-
"It reaches the daemon at `BOARD_DAEMON_URL`, otherwise at `http.port` from `config.yaml
|
|
2165
|
+
"It reaches the daemon at `BOARD_DAEMON_URL`, otherwise at `http.port` from `config.yaml`; with neither set nor a valid config, each call fails with `config` before any request.",
|
|
2166
2166
|
"",
|
|
2167
2167
|
"A `version_mismatch` answer means the server and the daemon have different catalogs: restart the agent session so `board mcp` loads the daemon's catalog; if it remains, run `board service restart`.",
|
|
2168
2168
|
"",
|
|
@@ -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-C6fOCG5L.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-B4JXkdZu.mjs";
|
|
2
2
|
export { fetchCatalogVersion, requestOperation, requestTokenEnrollment };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as CliError, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { U as configSchema, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-C6fOCG5L.mjs";
|
|
2
|
+
import { i as CliError, t as fetchCatalogVersion } from "./client-B4JXkdZu.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";
|
|
@@ -27,7 +27,7 @@ function dataDirectory(env, home, cwd = process.cwd()) {
|
|
|
27
27
|
const xdg = env["XDG_DATA_HOME"];
|
|
28
28
|
return join(xdg && isAbsolute(xdg) ? xdg : join(home, ".local", "share"), "spur-board");
|
|
29
29
|
}
|
|
30
|
-
/** The http.port in config.yaml, or
|
|
30
|
+
/** The http.port in config.yaml, or undefined when the file is missing or invalid. */
|
|
31
31
|
function readConfiguredPort(env, home) {
|
|
32
32
|
try {
|
|
33
33
|
const parsed = YAML.parseDocument(readFileSync(configFile(env, home), "utf8"));
|
|
@@ -36,13 +36,19 @@ function readConfiguredPort(env, home) {
|
|
|
36
36
|
if (config.success) return config.data.http.port;
|
|
37
37
|
}
|
|
38
38
|
} catch {}
|
|
39
|
-
return DEFAULT_HTTP_PORT;
|
|
40
39
|
}
|
|
41
40
|
function resolveDaemonAddress(env = process.env, home = homedir(), configuredPort) {
|
|
42
41
|
const rawAddress = env["BOARD_DAEMON_URL"];
|
|
43
42
|
if (rawAddress === void 0) {
|
|
44
43
|
const port = configuredPort ?? readConfiguredPort(env, home);
|
|
45
|
-
if (port === 0) throw new CliError("config",
|
|
44
|
+
if (port === void 0) throw new CliError("config", {
|
|
45
|
+
environmentVariable: "BOARD_DAEMON_URL",
|
|
46
|
+
configPath: configFile(env, home)
|
|
47
|
+
}, void 0, "Set BOARD_DAEMON_URL to the daemon address, or make config.yaml valid and set http.port in it; `board doctor --offline` names what is wrong.");
|
|
48
|
+
if (port === 0) throw new CliError("config", {
|
|
49
|
+
environmentVariable: "BOARD_DAEMON_URL",
|
|
50
|
+
configPath: configFile(env, home)
|
|
51
|
+
}, void 0, "http.port: 0 assigns a runtime port that clients cannot discover. Set BOARD_DAEMON_URL to the daemon listening address.");
|
|
46
52
|
return new URL(`http://127.0.0.1:${String(port)}`);
|
|
47
53
|
}
|
|
48
54
|
let address;
|
|
@@ -78,6 +84,15 @@ function tokenInFolder(folder, warn) {
|
|
|
78
84
|
return;
|
|
79
85
|
}
|
|
80
86
|
}
|
|
87
|
+
/** A `.git` file or directory marks the worktree root; an unreadable entry counts as one. */
|
|
88
|
+
function isWorktreeRoot(folder) {
|
|
89
|
+
try {
|
|
90
|
+
lstatSync(join(folder, ".git"));
|
|
91
|
+
return true;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return !(error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
81
96
|
function findTokenFile(cwd, home, warn = (message) => {
|
|
82
97
|
process.stderr.write(message);
|
|
83
98
|
}) {
|
|
@@ -94,6 +109,7 @@ function findTokenFile(cwd, home, warn = (message) => {
|
|
|
94
109
|
}
|
|
95
110
|
const token = tokenInFolder(folder, warn);
|
|
96
111
|
if (token !== void 0) return token;
|
|
112
|
+
if (isWorktreeRoot(folder)) break;
|
|
97
113
|
const parent = dirname(folder);
|
|
98
114
|
if (parent === folder) break;
|
|
99
115
|
folder = parent;
|
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-C6fOCG5L.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";
|
|
@@ -7609,6 +7609,7 @@ const creator = {
|
|
|
7609
7609
|
const MAX_STRINGS = 4096;
|
|
7610
7610
|
const MAX_PASSES = 32;
|
|
7611
7611
|
const receipts = new AsyncLocalStorage();
|
|
7612
|
+
secretLintProfiler.setEnabled(false);
|
|
7612
7613
|
const SCAN_PENDING = Symbol("gateway scan pending");
|
|
7613
7614
|
const scannerRules = rules.filter((rule) => rule.meta.id !== "@secretlint/secretlint-rule-filter-comments");
|
|
7614
7615
|
const scannerPreset = {
|
|
@@ -7719,9 +7720,11 @@ function checkGatewayStrings(strings) {
|
|
|
7719
7720
|
}
|
|
7720
7721
|
/**
|
|
7721
7722
|
* Replays database-only work after scanning exact strings outside the write transaction.
|
|
7722
|
-
* `fn` must build the same gateway strings on every pass
|
|
7723
|
-
* an outbox payload, before the call,
|
|
7724
|
-
*
|
|
7723
|
+
* `fn` must build the same gateway strings on every pass. Read a time that lands in one, such as
|
|
7724
|
+
* an outbox payload, before the call, or capture it once on the first pass, after the write lock,
|
|
7725
|
+
* and reuse it on every replay, as `runTick` in `sender.ts` does with the send-time token expiry.
|
|
7726
|
+
* A fresh time read on each pass makes a new string each pass and the replay never ends. A time
|
|
7727
|
+
* kept only in the database may be read inside.
|
|
7725
7728
|
*/
|
|
7726
7729
|
async function scanTransaction(store, config, fn) {
|
|
7727
7730
|
const known = /* @__PURE__ */ new Map();
|
|
@@ -7873,7 +7876,7 @@ async function writeDeniedEvent(trx, denial) {
|
|
|
7873
7876
|
}
|
|
7874
7877
|
//#endregion
|
|
7875
7878
|
//#region ../core/src/app/commands.ts
|
|
7876
|
-
const DAY_MS = 864e5;
|
|
7879
|
+
const DAY_MS$1 = 864e5;
|
|
7877
7880
|
const TASKLESS = [
|
|
7878
7881
|
"task.add",
|
|
7879
7882
|
"item.retry",
|
|
@@ -7996,32 +7999,12 @@ function createApply(deps) {
|
|
|
7996
7999
|
return result;
|
|
7997
8000
|
};
|
|
7998
8001
|
}
|
|
7999
|
-
/**
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
let timer;
|
|
8006
|
-
let running = Promise.resolve();
|
|
8007
|
-
const run = async () => {
|
|
8008
|
-
const cutoff = (/* @__PURE__ */ new Date(clock.now() - retentionDays * DAY_MS)).toISOString();
|
|
8009
|
-
await store.transaction(async (trx) => {
|
|
8010
|
-
await trx.deleteFrom("command").where("at", "<", cutoff).execute();
|
|
8011
|
-
});
|
|
8012
|
-
};
|
|
8013
|
-
return {
|
|
8014
|
-
async start() {
|
|
8015
|
-
await run();
|
|
8016
|
-
timer = setInterval(() => {
|
|
8017
|
-
running = run().catch(onError);
|
|
8018
|
-
}, DAY_MS);
|
|
8019
|
-
},
|
|
8020
|
-
async stop() {
|
|
8021
|
-
clearInterval(timer);
|
|
8022
|
-
await running;
|
|
8023
|
-
}
|
|
8024
|
-
};
|
|
8002
|
+
/** Deletes command keys older than `retentionDays`; a key exactly at the cutoff stays. */
|
|
8003
|
+
async function purgeExpiredCommands(store, clock, retentionDays) {
|
|
8004
|
+
const cutoff = (/* @__PURE__ */ new Date(clock.now() - retentionDays * DAY_MS$1)).toISOString();
|
|
8005
|
+
await store.transaction(async (trx) => {
|
|
8006
|
+
await trx.deleteFrom("command").where("at", "<", cutoff).execute();
|
|
8007
|
+
});
|
|
8025
8008
|
}
|
|
8026
8009
|
//#endregion
|
|
8027
8010
|
//#region ../core/src/app/queries.ts
|
|
@@ -8737,6 +8720,18 @@ async function expireToken(trx, row, at) {
|
|
|
8737
8720
|
await journalToken(trx, "token_expired", row.name, at);
|
|
8738
8721
|
await clearItem(trx, row.item_id, at);
|
|
8739
8722
|
}
|
|
8723
|
+
/**
|
|
8724
|
+
* Lapses the pending request whose approval item is `itemId` once it has expired at `at`. The
|
|
8725
|
+
* sender calls it before posting the approval line, so a late or failing sweep cannot post it.
|
|
8726
|
+
*/
|
|
8727
|
+
async function expireTokenOfItem(trx, itemId, at) {
|
|
8728
|
+
const row = await trx.selectFrom("operator_token").select([
|
|
8729
|
+
"id",
|
|
8730
|
+
"name",
|
|
8731
|
+
"item_id"
|
|
8732
|
+
]).where("item_id", "=", itemId).where("status", "=", "pending").where("expires_at", "<=", at.toISOString()).executeTakeFirst();
|
|
8733
|
+
if (row !== void 0) await expireToken(trx, row, at);
|
|
8734
|
+
}
|
|
8740
8735
|
/** Register a hash and its approval item together. The raw file secret never reaches this app. */
|
|
8741
8736
|
async function requestToken(store, config, input, at) {
|
|
8742
8737
|
if (!/^[0-9a-f]{64}$/.test(input.hash) || input.name.trim() === "" || input.folder.trim() === "") throw new CommandError("usage", "Provide a name, folder and SHA-256 token hash.");
|
|
@@ -9230,8 +9225,9 @@ async function restartNotification(trx, sourceKey, at) {
|
|
|
9230
9225
|
/**
|
|
9231
9226
|
* Ends a ring Spur will not take (a permanent rejection, or no answer for the retry window): its
|
|
9232
9227
|
* notification stops ringing, the operator gets an item and `doorbell_undelivered` is journalled.
|
|
9233
|
-
* The operator's Retry on the item restarts the series (`restartNotification`).
|
|
9234
|
-
*
|
|
9228
|
+
* The operator's Retry on the item restarts the series (`restartNotification`). A ring that is no
|
|
9229
|
+
* longer its notification's last row (the recipient changed while it was in flight) ends alone. An
|
|
9230
|
+
* inbound author ring has no notification: it ends like an author found unavailable at enqueue.
|
|
9235
9231
|
*/
|
|
9236
9232
|
async function ringUndelivered(trx, input) {
|
|
9237
9233
|
const { at, reason } = input;
|
|
@@ -9254,7 +9250,7 @@ async function ringUndelivered(trx, input) {
|
|
|
9254
9250
|
return;
|
|
9255
9251
|
}
|
|
9256
9252
|
const n = await trx.selectFrom("notification").selectAll().where("id", "=", input.notificationId).executeTakeFirst();
|
|
9257
|
-
if (n === void 0 || n.acked_at !== null || n.exhausted_at !== null) return;
|
|
9253
|
+
if (n === void 0 || n.acked_at !== null || n.exhausted_at !== null || n.last_outbox_id !== input.outboxId) return;
|
|
9258
9254
|
const task = await trx.selectFrom("task").selectAll().where("id", "=", n.task_id).executeTakeFirstOrThrow();
|
|
9259
9255
|
await trx.updateTable("notification").set({ exhausted_at: at.toISOString() }).where("id", "=", n.id).execute();
|
|
9260
9256
|
await raiseItem(trx, {
|
|
@@ -9271,9 +9267,21 @@ async function ringUndelivered(trx, input) {
|
|
|
9271
9267
|
reason
|
|
9272
9268
|
}, at);
|
|
9273
9269
|
}
|
|
9274
|
-
/**
|
|
9270
|
+
/** Notifications reconcile looks at: unacked, not exhausted, due, on a task not archived. */
|
|
9271
|
+
function dueNotifications(db, at) {
|
|
9272
|
+
return db.selectFrom("notification").innerJoin("task", "task.id", "notification.task_id").where("task.membership", "!=", "archived").where("notification.acked_at", "is", null).where("notification.exhausted_at", "is", null).where("notification.next_at", "<=", at.toISOString());
|
|
9273
|
+
}
|
|
9274
|
+
/**
|
|
9275
|
+
* Reconciles due notifications in their own transaction. With none due it opens no transaction;
|
|
9276
|
+
* a due notification waiting on a working recipient or an unsent ring still opens one.
|
|
9277
|
+
*/
|
|
9278
|
+
async function reconcileDueDoorbells(store, config, at) {
|
|
9279
|
+
if (await dueNotifications(store.db, at).select("notification.id").executeTakeFirst() === void 0) return;
|
|
9280
|
+
await scanTransaction(store, config, (trx) => reconcileDoorbells(trx, at, config));
|
|
9281
|
+
}
|
|
9282
|
+
/** Reconcile due semantic notifications in the caller's transaction. */
|
|
9275
9283
|
async function reconcileDoorbells(trx, at, config) {
|
|
9276
|
-
const due = await trx
|
|
9284
|
+
const due = await dueNotifications(trx, at).selectAll("notification").orderBy("notification.id").execute();
|
|
9277
9285
|
for (const n of due) {
|
|
9278
9286
|
const session = await selectNotificationRecipient(trx, n);
|
|
9279
9287
|
if (session === void 0) {
|
|
@@ -10301,7 +10309,6 @@ function createSender(options) {
|
|
|
10301
10309
|
async function claim(trx, at) {
|
|
10302
10310
|
const nowIso = new Date(at).toISOString();
|
|
10303
10311
|
await releaseOrphans(trx, nowIso);
|
|
10304
|
-
await reconcileDoorbells(trx, new Date(at), options.config);
|
|
10305
10312
|
const rows = await trx.selectFrom("outbox").selectAll().where("state", "in", ["pending", "post_failed"]).orderBy("id").execute();
|
|
10306
10313
|
const bodies = /* @__PURE__ */ new Map();
|
|
10307
10314
|
for (const row of rows) {
|
|
@@ -10395,11 +10402,15 @@ function createSender(options) {
|
|
|
10395
10402
|
* Stamps the start of a send, just before its IO: the row's retry window if none is open and,
|
|
10396
10403
|
* for a space, the slot of the next send and, under a health row, the probe clock. A slow
|
|
10397
10404
|
* earlier send in the tick does not age them. The clock is read here, once the write lock is
|
|
10398
|
-
* held, so waiting for the lock does not age them either. Returns the stamp.
|
|
10405
|
+
* held, so waiting for the lock does not age them either. Returns the stamp. `expiredAt` is
|
|
10406
|
+
* read once, on the first pass after the lock is held, and reused on replays: token expiry
|
|
10407
|
+
* writes it into a feed edit, a gateway string, so a fresh read per pass would change it on
|
|
10408
|
+
* every scan replay, and a read before the lock would miss a request that lapses meanwhile.
|
|
10399
10409
|
*/
|
|
10400
|
-
async function start(trx, c) {
|
|
10410
|
+
async function start(trx, c, expiredAt) {
|
|
10401
10411
|
const at = now().getTime();
|
|
10402
10412
|
const sentAtIso = new Date(at).toISOString();
|
|
10413
|
+
if (c.body.kind === "feed.line" && c.body.payload.itemId !== void 0) await expireTokenOfItem(trx, c.body.payload.itemId, expiredAt);
|
|
10403
10414
|
if (c.body.kind === "feed.line" && c.body.payload.itemId !== void 0 && !c.maybeSent) {
|
|
10404
10415
|
const item = await trx.selectFrom("operator_item").select("cleared_at").where("id", "=", c.body.payload.itemId).executeTakeFirst();
|
|
10405
10416
|
if (item !== void 0 && item.cleared_at !== null) {
|
|
@@ -10542,6 +10553,7 @@ function createSender(options) {
|
|
|
10542
10553
|
if (body.kind !== "doorbell") return;
|
|
10543
10554
|
await ringUndelivered(trx, {
|
|
10544
10555
|
notificationId: body.payload.notificationId,
|
|
10556
|
+
outboxId: c.id,
|
|
10545
10557
|
dedupeKey: c.key,
|
|
10546
10558
|
session: body.payload.session,
|
|
10547
10559
|
reason,
|
|
@@ -10668,7 +10680,8 @@ function createSender(options) {
|
|
|
10668
10680
|
})).where("id", "in", ids).where("state", "=", "in_flight").execute());
|
|
10669
10681
|
return;
|
|
10670
10682
|
}
|
|
10671
|
-
|
|
10683
|
+
let expiredAt;
|
|
10684
|
+
const started = await scanTransaction(store, options.config, (trx) => start(trx, c, expiredAt ??= now()));
|
|
10672
10685
|
if (started.skip) continue;
|
|
10673
10686
|
const { outcome, error } = await attempt(c, started.firstDeliveryAt);
|
|
10674
10687
|
const at = now().getTime();
|
|
@@ -12465,10 +12478,23 @@ function createObservationCore(deps) {
|
|
|
12465
12478
|
};
|
|
12466
12479
|
}
|
|
12467
12480
|
//#endregion
|
|
12468
|
-
//#region ../core/src/
|
|
12469
|
-
|
|
12481
|
+
//#region ../core/src/domain/slot.ts
|
|
12482
|
+
const WEEKDAYS = [
|
|
12483
|
+
"sunday",
|
|
12484
|
+
"monday",
|
|
12485
|
+
"tuesday",
|
|
12486
|
+
"wednesday",
|
|
12487
|
+
"thursday",
|
|
12488
|
+
"friday",
|
|
12489
|
+
"saturday"
|
|
12490
|
+
];
|
|
12491
|
+
/**
|
|
12492
|
+
* The UTC instant of local midnight on the latest `weekday` at or before `now` in `tz`.
|
|
12493
|
+
* A day that starts at `now` counts as today.
|
|
12494
|
+
*/
|
|
12495
|
+
function lastLocalSlot(now, tz, weekday) {
|
|
12470
12496
|
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
12471
|
-
timeZone:
|
|
12497
|
+
timeZone: tz,
|
|
12472
12498
|
year: "numeric",
|
|
12473
12499
|
month: "2-digit",
|
|
12474
12500
|
day: "2-digit"
|
|
@@ -12483,15 +12509,7 @@ function lastArchiveSlot(now, config) {
|
|
|
12483
12509
|
};
|
|
12484
12510
|
const [year = 0, month = 0, day = 0] = localDate(now).split("-").map(Number);
|
|
12485
12511
|
const localMidnight = Date.UTC(year, month - 1, day);
|
|
12486
|
-
const targetUtcDate = localMidnight - (new Date(localMidnight).getUTCDay() -
|
|
12487
|
-
"sunday",
|
|
12488
|
-
"monday",
|
|
12489
|
-
"tuesday",
|
|
12490
|
-
"wednesday",
|
|
12491
|
-
"thursday",
|
|
12492
|
-
"friday",
|
|
12493
|
-
"saturday"
|
|
12494
|
-
].indexOf(config.archive.doneWeekday) + 7) % 7 * 864e5;
|
|
12512
|
+
const targetUtcDate = localMidnight - (new Date(localMidnight).getUTCDay() - WEEKDAYS.indexOf(weekday) + 7) % 7 * 864e5;
|
|
12495
12513
|
const targetDate = new Date(targetUtcDate).toISOString().slice(0, 10);
|
|
12496
12514
|
let lower = targetUtcDate - 2 * 864e5;
|
|
12497
12515
|
let upper = targetUtcDate + 2 * 864e5;
|
|
@@ -12502,12 +12520,14 @@ function lastArchiveSlot(now, config) {
|
|
|
12502
12520
|
}
|
|
12503
12521
|
return lower;
|
|
12504
12522
|
}
|
|
12523
|
+
//#endregion
|
|
12524
|
+
//#region ../core/src/app/tick.ts
|
|
12505
12525
|
/** One board tick, including an archive slot missed during downtime. */
|
|
12506
12526
|
async function tickBoard(deps) {
|
|
12507
12527
|
const { store, config, clock, completeSince } = deps;
|
|
12508
12528
|
const now = clock.now();
|
|
12509
12529
|
const at = new Date(now).toISOString();
|
|
12510
|
-
const slot = new Date(
|
|
12530
|
+
const slot = new Date(lastLocalSlot(now, config.digest.tz, config.archive.doneWeekday)).toISOString();
|
|
12511
12531
|
await scanTransaction(store, config, async (trx) => {
|
|
12512
12532
|
const sourceStates = await trx.selectFrom("source_state").select(["source", "blind_reason"]).execute();
|
|
12513
12533
|
const blind = new Set(sourceStates.filter((source) => source.blind_reason !== null).map((source) => source.source));
|
|
@@ -13741,9 +13761,11 @@ function pageQuery(connection, bootstrap = false) {
|
|
|
13741
13761
|
}
|
|
13742
13762
|
var GithubClient = class {
|
|
13743
13763
|
token;
|
|
13764
|
+
now;
|
|
13744
13765
|
fetcher;
|
|
13745
|
-
constructor(token, fetcher = fetch) {
|
|
13766
|
+
constructor(token, now, fetcher = fetch) {
|
|
13746
13767
|
this.token = token;
|
|
13768
|
+
this.now = now;
|
|
13747
13769
|
this.fetcher = fetcher;
|
|
13748
13770
|
}
|
|
13749
13771
|
async query(query, variables, signal) {
|
|
@@ -13770,7 +13792,7 @@ var GithubClient = class {
|
|
|
13770
13792
|
status: response.status,
|
|
13771
13793
|
headers: response.headers,
|
|
13772
13794
|
body: await response.text()
|
|
13773
|
-
},
|
|
13795
|
+
}, this.now());
|
|
13774
13796
|
let body;
|
|
13775
13797
|
try {
|
|
13776
13798
|
body = await response.json();
|
|
@@ -13782,7 +13804,7 @@ var GithubClient = class {
|
|
|
13782
13804
|
if (errors.some((error) => error.type === "RATE_LIMITED" || /rate limit/i.test(error.message))) throw classifyHttpFailure({
|
|
13783
13805
|
status: 429,
|
|
13784
13806
|
headers: response.headers
|
|
13785
|
-
},
|
|
13807
|
+
}, this.now());
|
|
13786
13808
|
if (errors.some((error) => teamScopeDenied(error, query))) throw new AdapterError("auth", "GitHub token needs read:org for team review requests");
|
|
13787
13809
|
if (errors.some((error) => error.type === "INSUFFICIENT_SCOPES")) throw new AdapterError("auth", "GitHub token lacks a required GraphQL read scope");
|
|
13788
13810
|
const data = parseWire(dataWire, wire.data, MALFORMED$3, ["data"]);
|
|
@@ -14169,7 +14191,7 @@ function githubSources(config, options) {
|
|
|
14169
14191
|
if (seen.has(normalized)) throw new AdapterError("config", "Duplicate GitHub repository in project");
|
|
14170
14192
|
seen.add(normalized);
|
|
14171
14193
|
const id = sourceId(project.id, repo);
|
|
14172
|
-
const client = new GithubClient(options.token, options.fetch);
|
|
14194
|
+
const client = new GithubClient(options.token, options.now, options.fetch);
|
|
14173
14195
|
const keys = projectKeyRule(project.tracker, project.link, repo);
|
|
14174
14196
|
sources.push({
|
|
14175
14197
|
repo,
|
|
@@ -14183,6 +14205,7 @@ function githubSources(config, options) {
|
|
|
14183
14205
|
login: project.operatorGithubLogin,
|
|
14184
14206
|
keys,
|
|
14185
14207
|
client,
|
|
14208
|
+
now: options.now,
|
|
14186
14209
|
ctx
|
|
14187
14210
|
})
|
|
14188
14211
|
}
|
|
@@ -14290,8 +14313,8 @@ async function fullPr(client, first, owner, name, number, signal, budget) {
|
|
|
14290
14313
|
pr
|
|
14291
14314
|
};
|
|
14292
14315
|
}
|
|
14293
|
-
async function pollRepository({ id, repo, login, keys, client, ctx }) {
|
|
14294
|
-
const observedAt = sourceCursorSchema.parse(
|
|
14316
|
+
async function pollRepository({ id, repo, login, keys, client, now, ctx }) {
|
|
14317
|
+
const observedAt = sourceCursorSchema.parse(new Date(now()).toISOString());
|
|
14295
14318
|
const bootstrap = ctx.cursor === void 0;
|
|
14296
14319
|
const [owner, name] = repo.split("/");
|
|
14297
14320
|
if (!owner || !name) throw new AdapterError("config", "Invalid repository");
|
|
@@ -14515,7 +14538,7 @@ function createGithubIssuesAdapter(options) {
|
|
|
14515
14538
|
status: response.status,
|
|
14516
14539
|
headers: response.headers,
|
|
14517
14540
|
body: await response.text()
|
|
14518
|
-
},
|
|
14541
|
+
}, options.now());
|
|
14519
14542
|
throw new GithubIssuesHttpError(response.status, failure);
|
|
14520
14543
|
}
|
|
14521
14544
|
let value;
|
|
@@ -14602,7 +14625,7 @@ function createGithubIssuesAdapter(options) {
|
|
|
14602
14625
|
id: options.id,
|
|
14603
14626
|
intervalMs: options.intervalMs,
|
|
14604
14627
|
async poll(ctx) {
|
|
14605
|
-
const observedAt =
|
|
14628
|
+
const observedAt = new Date(options.now()).toISOString();
|
|
14606
14629
|
const milestone = await milestoneNumber(ctx.signal);
|
|
14607
14630
|
const filter = new URL(`${root}/issues`);
|
|
14608
14631
|
filter.searchParams.set("state", "open");
|
|
@@ -14803,7 +14826,7 @@ function createJiraAdapter(options) {
|
|
|
14803
14826
|
if (!response.ok) throw new JiraHttpError(response.status, classifyHttpFailure({
|
|
14804
14827
|
status: response.status,
|
|
14805
14828
|
headers: response.headers
|
|
14806
|
-
},
|
|
14829
|
+
}, options.now()));
|
|
14807
14830
|
try {
|
|
14808
14831
|
return await response.json();
|
|
14809
14832
|
} catch {
|
|
@@ -14923,7 +14946,7 @@ function createJiraAdapter(options) {
|
|
|
14923
14946
|
if (fallbackRequests >= FALLBACK_REQUEST_LIMIT) throw new AdapterError("transient", "Jira key lookup fallback request limit reached");
|
|
14924
14947
|
fallbackRequests += 1;
|
|
14925
14948
|
};
|
|
14926
|
-
const observedAt =
|
|
14949
|
+
const observedAt = new Date(options.now()).toISOString();
|
|
14927
14950
|
const tracker = options.tracker();
|
|
14928
14951
|
await validate(tracker, ctx.signal);
|
|
14929
14952
|
const sprintField = await findSprintField(tracker, ctx.signal);
|
|
@@ -15106,7 +15129,7 @@ function applyEntityOutcomes(input) {
|
|
|
15106
15129
|
//#endregion
|
|
15107
15130
|
//#region ../adapters/src/runner/runner.ts
|
|
15108
15131
|
function startRunner(options) {
|
|
15109
|
-
const startedAt =
|
|
15132
|
+
const startedAt = options.now();
|
|
15110
15133
|
const sources = options.entries.map((entry) => runSource(entry, options, startedAt));
|
|
15111
15134
|
return {
|
|
15112
15135
|
firstAttempts: Promise.all(sources.map(async (source) => ({
|
|
@@ -15121,7 +15144,7 @@ function startRunner(options) {
|
|
|
15121
15144
|
function runSource(entry, options, runnerStartMs) {
|
|
15122
15145
|
const { adapter, reserveRemaining } = entry;
|
|
15123
15146
|
const { core, config } = options;
|
|
15124
|
-
const now = options
|
|
15147
|
+
const { now } = options;
|
|
15125
15148
|
const source = adapter.id;
|
|
15126
15149
|
const { intervalMs } = adapter;
|
|
15127
15150
|
const { staleMultiplier } = config.thresholds;
|
|
@@ -15478,12 +15501,12 @@ function createSpurAdapter(options) {
|
|
|
15478
15501
|
id: "spur",
|
|
15479
15502
|
intervalMs: options.intervalMs,
|
|
15480
15503
|
async poll(ctx) {
|
|
15481
|
-
const observedAt =
|
|
15504
|
+
const observedAt = new Date(options.now()).toISOString();
|
|
15482
15505
|
const { response: listResponse, body: listBody } = await request("sessions", ctx.signal);
|
|
15483
15506
|
if (!listResponse.ok) throw classifyHttpFailure({
|
|
15484
15507
|
status: listResponse.status,
|
|
15485
15508
|
headers: listResponse.headers
|
|
15486
|
-
},
|
|
15509
|
+
}, options.now());
|
|
15487
15510
|
const listed = parseWire(z.array(sessionWire), listBody, "Invalid Spur response");
|
|
15488
15511
|
const byId = new Map(listed.map((wire) => [wire.id, wire]));
|
|
15489
15512
|
const detail = /* @__PURE__ */ new Map();
|
|
@@ -15497,7 +15520,7 @@ function createSpurAdapter(options) {
|
|
|
15497
15520
|
if (!response.ok) throw classifyHttpFailure({
|
|
15498
15521
|
status: response.status,
|
|
15499
15522
|
headers: response.headers
|
|
15500
|
-
},
|
|
15523
|
+
}, options.now());
|
|
15501
15524
|
const wire = parseWire(sessionWire, body, "Invalid Spur response");
|
|
15502
15525
|
if (wire.id !== ref.id) throw new AdapterError("transient", "Unresolved Spur session detail");
|
|
15503
15526
|
detail.set(ref.id, wire);
|
|
@@ -15590,12 +15613,12 @@ function sampleQuery(closing) {
|
|
|
15590
15613
|
* reference is dropped, as the poller does; any other GraphQL error rejects with a transient
|
|
15591
15614
|
* `AdapterError`.
|
|
15592
15615
|
*/
|
|
15593
|
-
async function sampleLinkRules({ repo, login, tracker, link }, { token, fetch: fetcher, signal }) {
|
|
15616
|
+
async function sampleLinkRules({ repo, login, tracker, link }, { token, now, fetch: fetcher, signal }) {
|
|
15594
15617
|
const [owner, name] = repo.split("/");
|
|
15595
15618
|
if (!owner || !name) throw new AdapterError("config", "Invalid repository");
|
|
15596
15619
|
const rule = projectKeyRule(tracker, link, repo);
|
|
15597
15620
|
const closing = rule.type === "issues" && rule.sources.includes("closing");
|
|
15598
|
-
const response = await new GithubClient(token, fetcher).query(sampleQuery(closing), {
|
|
15621
|
+
const response = await new GithubClient(token, now, fetcher).query(sampleQuery(closing), {
|
|
15599
15622
|
owner,
|
|
15600
15623
|
repo: name
|
|
15601
15624
|
}, signal);
|
|
@@ -15621,7 +15644,7 @@ function blindSource(id, intervalMs, message) {
|
|
|
15621
15644
|
};
|
|
15622
15645
|
}
|
|
15623
15646
|
/** Starts polling each configured source. */
|
|
15624
|
-
function startAdapters(config, core, options
|
|
15647
|
+
function startAdapters(config, core, options) {
|
|
15625
15648
|
const secrets = options.secrets ?? {};
|
|
15626
15649
|
const githubToken = secrets["GITHUB_TOKEN"];
|
|
15627
15650
|
const entries = [];
|
|
@@ -15637,6 +15660,7 @@ function startAdapters(config, core, options = {}) {
|
|
|
15637
15660
|
email,
|
|
15638
15661
|
token
|
|
15639
15662
|
},
|
|
15663
|
+
now: options.now,
|
|
15640
15664
|
intervalMs: config.adapters.jira.intervalMs,
|
|
15641
15665
|
...options.fetch === void 0 ? {} : { fetch: options.fetch },
|
|
15642
15666
|
warn: options.warn ?? (() => void 0),
|
|
@@ -15648,12 +15672,14 @@ function startAdapters(config, core, options = {}) {
|
|
|
15648
15672
|
id,
|
|
15649
15673
|
tracker: project.tracker,
|
|
15650
15674
|
token: githubToken,
|
|
15675
|
+
now: options.now,
|
|
15651
15676
|
intervalMs: config.adapters.github.intervalMs,
|
|
15652
15677
|
...options.fetch === void 0 ? {} : { fetch: options.fetch }
|
|
15653
15678
|
}) : blindSource(id, config.adapters.github.intervalMs, "GitHub credential is missing") });
|
|
15654
15679
|
}
|
|
15655
15680
|
if (githubToken) entries.push(...githubSources(config, {
|
|
15656
15681
|
token: githubToken,
|
|
15682
|
+
now: options.now,
|
|
15657
15683
|
...options.fetch === void 0 ? {} : { fetch: options.fetch }
|
|
15658
15684
|
}).map(({ adapter, reserveRemaining, repo }) => ({
|
|
15659
15685
|
adapter,
|
|
@@ -15667,6 +15693,7 @@ function startAdapters(config, core, options = {}) {
|
|
|
15667
15693
|
baseUrl: config.adapters.spur.baseUrl,
|
|
15668
15694
|
intervalMs: config.adapters.spur.intervalMs,
|
|
15669
15695
|
flipSmoothingMs: config.health.flipSmoothingMs,
|
|
15696
|
+
now: options.now,
|
|
15670
15697
|
...options.fetch === void 0 ? {} : { fetch: options.fetch },
|
|
15671
15698
|
onNotice: (notice) => {
|
|
15672
15699
|
const pending = Promise.resolve().then(() => options.onSpurNotice?.(notice));
|
|
@@ -15677,7 +15704,7 @@ function startAdapters(config, core, options = {}) {
|
|
|
15677
15704
|
}) }],
|
|
15678
15705
|
core,
|
|
15679
15706
|
config,
|
|
15680
|
-
|
|
15707
|
+
now: options.now,
|
|
15681
15708
|
...options.oneShot === void 0 ? {} : { oneShot: options.oneShot },
|
|
15682
15709
|
onFailure: options.onPollFailure
|
|
15683
15710
|
});
|
|
@@ -16468,9 +16495,19 @@ function record(value) {
|
|
|
16468
16495
|
function string(value) {
|
|
16469
16496
|
return typeof value === "string" ? value : void 0;
|
|
16470
16497
|
}
|
|
16498
|
+
/** Milliseconds of a Slack ts, read from its digits so float error cannot shift the millisecond. */
|
|
16499
|
+
function tsMillis(ts) {
|
|
16500
|
+
const [seconds = "", fraction = ""] = ts.split(".");
|
|
16501
|
+
if (!/^\d+$/.test(seconds) || !/^\d*$/.test(fraction)) return NaN;
|
|
16502
|
+
return Number(seconds) * 1e3 + Number(fraction.padEnd(3, "0").slice(0, 3));
|
|
16503
|
+
}
|
|
16504
|
+
/**
|
|
16505
|
+
* The bounds are clock readings in whole milliseconds, so a message counts by its millisecond:
|
|
16506
|
+
* one posted later within the millisecond `until` was read in is still inside the window.
|
|
16507
|
+
*/
|
|
16471
16508
|
function inInterval(ts, from, until) {
|
|
16472
16509
|
if (ts === void 0) return false;
|
|
16473
|
-
const at =
|
|
16510
|
+
const at = tsMillis(ts);
|
|
16474
16511
|
return Number.isFinite(at) && at >= from && at <= until;
|
|
16475
16512
|
}
|
|
16476
16513
|
async function readThread(client, channel, threadTs) {
|
|
@@ -16493,8 +16530,8 @@ function gap(conversation) {
|
|
|
16493
16530
|
};
|
|
16494
16531
|
}
|
|
16495
16532
|
/** A scan is driven solely by its request; the core owns cursors and deduplication. */
|
|
16496
|
-
async function* recoverThreads(client, request, botIdentity) {
|
|
16497
|
-
const until =
|
|
16533
|
+
async function* recoverThreads(client, request, botIdentity, now) {
|
|
16534
|
+
const until = now();
|
|
16498
16535
|
const from = request.since.getTime();
|
|
16499
16536
|
if (!Number.isFinite(from) || from > until) return;
|
|
16500
16537
|
const bot = await botIdentity();
|
|
@@ -16693,7 +16730,7 @@ function createSlackGateway(config) {
|
|
|
16693
16730
|
return {
|
|
16694
16731
|
...delivery,
|
|
16695
16732
|
...socket,
|
|
16696
|
-
recover: (request) => recoverThreads(api, request, botIdentity),
|
|
16733
|
+
recover: (request) => recoverThreads(api, request, botIdentity, config.now),
|
|
16697
16734
|
async respond(interaction, text, options) {
|
|
16698
16735
|
const addressed = parseInteractionRef(interaction);
|
|
16699
16736
|
const rendered = renderResponse(text, options.cliHint);
|
|
@@ -16720,6 +16757,62 @@ function createSlackGateway(config) {
|
|
|
16720
16757
|
};
|
|
16721
16758
|
}
|
|
16722
16759
|
//#endregion
|
|
16760
|
+
//#region ../daemon/src/scheduler.ts
|
|
16761
|
+
/**
|
|
16762
|
+
* One recurring job: a `setTimeout` chain armed `intervalMs` plus under `jitterMs` after each
|
|
16763
|
+
* timer run settles. Runs never overlap; `trigger` queues behind the active run. A failed run goes
|
|
16764
|
+
* to `onError`, except a failed `first: 'await'` run, which rejects `start` and arms no timer. A
|
|
16765
|
+
* failing `onError` is dropped, so the chain keeps running.
|
|
16766
|
+
* `stop` clears the timer and awaits the active run; after it, and once the start signal aborts,
|
|
16767
|
+
* nothing new runs. Uses the global timers so `vi.useFakeTimers` controls it.
|
|
16768
|
+
*/
|
|
16769
|
+
function createJob(options) {
|
|
16770
|
+
const { run, intervalMs, jitterMs = 0, first = "background", onError } = options;
|
|
16771
|
+
let timer;
|
|
16772
|
+
let active = Promise.resolve();
|
|
16773
|
+
let stopped = false;
|
|
16774
|
+
let signal;
|
|
16775
|
+
const idle = () => stopped || signal === void 0 || signal.aborted;
|
|
16776
|
+
const enqueue = () => {
|
|
16777
|
+
if (idle()) return active;
|
|
16778
|
+
active = active.then(async () => {
|
|
16779
|
+
if (signal !== void 0 && !idle()) await run(signal);
|
|
16780
|
+
}).catch(async (err) => {
|
|
16781
|
+
await onError(err);
|
|
16782
|
+
}).catch(() => void 0);
|
|
16783
|
+
return active;
|
|
16784
|
+
};
|
|
16785
|
+
const schedule = () => {
|
|
16786
|
+
if (idle()) return;
|
|
16787
|
+
const delay = intervalMs + Math.floor(Math.random() * jitterMs);
|
|
16788
|
+
timer = setTimeout(() => {
|
|
16789
|
+
timer = void 0;
|
|
16790
|
+
enqueue().then(schedule);
|
|
16791
|
+
}, delay);
|
|
16792
|
+
};
|
|
16793
|
+
return {
|
|
16794
|
+
async start(startSignal) {
|
|
16795
|
+
signal = startSignal;
|
|
16796
|
+
if (first === "background") {
|
|
16797
|
+
enqueue().then(schedule);
|
|
16798
|
+
return;
|
|
16799
|
+
}
|
|
16800
|
+
if (idle()) return;
|
|
16801
|
+
const firstRun = run(startSignal);
|
|
16802
|
+
active = firstRun.then(() => void 0, () => void 0);
|
|
16803
|
+
await firstRun;
|
|
16804
|
+
schedule();
|
|
16805
|
+
},
|
|
16806
|
+
async stop() {
|
|
16807
|
+
stopped = true;
|
|
16808
|
+
clearTimeout(timer);
|
|
16809
|
+
await active;
|
|
16810
|
+
},
|
|
16811
|
+
trigger: enqueue,
|
|
16812
|
+
settled: () => active
|
|
16813
|
+
};
|
|
16814
|
+
}
|
|
16815
|
+
//#endregion
|
|
16723
16816
|
//#region ../daemon/src/board-modules.ts
|
|
16724
16817
|
/** Compose the board's timer and adapter runner without adding lifecycle state to main. */
|
|
16725
16818
|
function createBoardModules(ctxFor, options = {}) {
|
|
@@ -16730,45 +16823,27 @@ function createBoardModules(ctxFor, options = {}) {
|
|
|
16730
16823
|
config: coreCtx.config,
|
|
16731
16824
|
clock: coreCtx.clock
|
|
16732
16825
|
});
|
|
16733
|
-
let timer;
|
|
16734
|
-
let active = Promise.resolve();
|
|
16735
|
-
let stopped = false;
|
|
16736
|
-
let signal;
|
|
16737
16826
|
const tick = options.tick ?? tickBoard;
|
|
16738
|
-
const
|
|
16739
|
-
|
|
16740
|
-
|
|
16741
|
-
|
|
16742
|
-
|
|
16743
|
-
|
|
16744
|
-
|
|
16745
|
-
|
|
16746
|
-
|
|
16747
|
-
|
|
16748
|
-
|
|
16749
|
-
|
|
16750
|
-
clock: coreCtx.clock,
|
|
16751
|
-
completeSince: core.completeSince
|
|
16752
|
-
})).then(() => options.onTick?.()).catch((err) => {
|
|
16827
|
+
const boardCore = createJob({
|
|
16828
|
+
run: async () => {
|
|
16829
|
+
await tick({
|
|
16830
|
+
store: coreCtx.store,
|
|
16831
|
+
config: coreCtx.config,
|
|
16832
|
+
clock: coreCtx.clock,
|
|
16833
|
+
completeSince: core.completeSince
|
|
16834
|
+
});
|
|
16835
|
+
options.onTick?.();
|
|
16836
|
+
},
|
|
16837
|
+
intervalMs: BOARD_TICK_MS,
|
|
16838
|
+
onError: (err) => {
|
|
16753
16839
|
coreCtx.log.error({ err }, "board tick failed");
|
|
16754
|
-
}
|
|
16755
|
-
};
|
|
16840
|
+
}
|
|
16841
|
+
});
|
|
16756
16842
|
let runner;
|
|
16757
16843
|
return [{
|
|
16758
16844
|
name: "board-core",
|
|
16759
16845
|
stopStage: "final",
|
|
16760
|
-
module:
|
|
16761
|
-
start(startSignal) {
|
|
16762
|
-
signal = startSignal;
|
|
16763
|
-
runTick();
|
|
16764
|
-
return Promise.resolve();
|
|
16765
|
-
},
|
|
16766
|
-
async stop() {
|
|
16767
|
-
stopped = true;
|
|
16768
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
16769
|
-
await active;
|
|
16770
|
-
}
|
|
16771
|
-
}
|
|
16846
|
+
module: boardCore
|
|
16772
16847
|
}, {
|
|
16773
16848
|
name: "board-adapters",
|
|
16774
16849
|
stopStage: "pollers",
|
|
@@ -16863,7 +16938,7 @@ function createSpurPort(options) {
|
|
|
16863
16938
|
}
|
|
16864
16939
|
//#endregion
|
|
16865
16940
|
//#region ../daemon/src/doctor.ts
|
|
16866
|
-
const
|
|
16941
|
+
const DEADLINE_MS = 5e3;
|
|
16867
16942
|
const SPUR_PROBE_SESSION = "spur-board-doctor-probe";
|
|
16868
16943
|
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.";
|
|
16869
16944
|
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.";
|
|
@@ -16900,11 +16975,11 @@ function scopedGithubError(value) {
|
|
|
16900
16975
|
if (error?.["type"] === "INSUFFICIENT_SCOPES" && fields.includes("reviewRequests") && fields.includes("requestedReviewer") && fields.includes("slug")) return GITHUB_TEAMS_FIX;
|
|
16901
16976
|
return null;
|
|
16902
16977
|
}
|
|
16903
|
-
async function deadlineCall(ctx, name, failure, call) {
|
|
16978
|
+
async function deadlineCall(ctx, deadlineMs, name, failure, call) {
|
|
16904
16979
|
const controller = new AbortController();
|
|
16905
16980
|
const deadline = setTimeout(() => {
|
|
16906
16981
|
controller.abort();
|
|
16907
|
-
},
|
|
16982
|
+
}, deadlineMs);
|
|
16908
16983
|
const aborted = new Promise((_resolve, reject) => {
|
|
16909
16984
|
controller.signal.addEventListener("abort", () => {
|
|
16910
16985
|
reject(/* @__PURE__ */ new Error(`${failure}: timed out`));
|
|
@@ -16924,10 +16999,10 @@ async function deadlineCall(ctx, name, failure, call) {
|
|
|
16924
16999
|
clearTimeout(deadline);
|
|
16925
17000
|
}
|
|
16926
17001
|
}
|
|
16927
|
-
async function githubGraphql(ctx, fetcher, token, repo) {
|
|
17002
|
+
async function githubGraphql(ctx, fetcher, deadlineMs, token, repo) {
|
|
16928
17003
|
const [owner, name] = repo.split("/");
|
|
16929
17004
|
if (!owner || !name) return null;
|
|
16930
|
-
return deadlineCall(ctx, "doctor.github", "GitHub doctor probe failed", async (signal) => {
|
|
17005
|
+
return deadlineCall(ctx, deadlineMs, "doctor.github", "GitHub doctor probe failed", async (signal) => {
|
|
16931
17006
|
const response = await fetcher("https://api.github.com/graphql", {
|
|
16932
17007
|
method: "POST",
|
|
16933
17008
|
headers: {
|
|
@@ -16955,19 +17030,20 @@ const BRANCH_MAX = 40;
|
|
|
16955
17030
|
const NAMED_PRS = 3;
|
|
16956
17031
|
const LINK_RULES_TAIL = "Change projects[].link to the repo's branch and PR title rules.";
|
|
16957
17032
|
const LINK_RULES_TOKEN_FIX = "Add GITHUB_TOKEN to secrets.env, then rerun board doctor to compare projects[].link with recent PRs.";
|
|
16958
|
-
function sampleProject(ctx, fetcher, token, project, repo) {
|
|
16959
|
-
return deadlineCall(ctx, "doctor.link_rules", "GitHub link sample failed", (signal) => sampleLinkRules({
|
|
17033
|
+
function sampleProject(ctx, fetcher, deadlineMs, token, project, repo) {
|
|
17034
|
+
return deadlineCall(ctx, deadlineMs, "doctor.link_rules", "GitHub link sample failed", (signal) => sampleLinkRules({
|
|
16960
17035
|
repo,
|
|
16961
17036
|
login: project.operatorGithubLogin,
|
|
16962
17037
|
tracker: project.tracker,
|
|
16963
17038
|
link: project.link
|
|
16964
17039
|
}, {
|
|
16965
17040
|
token,
|
|
17041
|
+
now: () => ctx.clock.now(),
|
|
16966
17042
|
fetch: fetcher,
|
|
16967
17043
|
signal
|
|
16968
17044
|
}));
|
|
16969
17045
|
}
|
|
16970
|
-
function sampleLinks(ctx, fetcher, token) {
|
|
17046
|
+
function sampleLinks(ctx, fetcher, deadlineMs, token) {
|
|
16971
17047
|
const projects = ctx.config.projects.flatMap((project) => project.tracker.type === "github-issues" ? [{
|
|
16972
17048
|
project,
|
|
16973
17049
|
repo: project.tracker.repo
|
|
@@ -16982,7 +17058,7 @@ function sampleLinks(ctx, fetcher, token) {
|
|
|
16982
17058
|
project,
|
|
16983
17059
|
repo,
|
|
16984
17060
|
polled,
|
|
16985
|
-
sample: await sampleProject(ctx, fetcher, token, project, repo)
|
|
17061
|
+
sample: await sampleProject(ctx, fetcher, deadlineMs, token, project, repo)
|
|
16986
17062
|
} : {
|
|
16987
17063
|
project,
|
|
16988
17064
|
repo,
|
|
@@ -17059,11 +17135,11 @@ function warning(id, fix) {
|
|
|
17059
17135
|
fix
|
|
17060
17136
|
};
|
|
17061
17137
|
}
|
|
17062
|
-
async function request(ctx, fetcher, id, url, init = {}) {
|
|
17138
|
+
async function request(ctx, fetcher, deadlineMs, id, url, init = {}) {
|
|
17063
17139
|
try {
|
|
17064
17140
|
return await ctx.logCall(`doctor.${id}`, () => fetcher(url, {
|
|
17065
17141
|
...init,
|
|
17066
|
-
signal: AbortSignal.timeout(
|
|
17142
|
+
signal: AbortSignal.timeout(deadlineMs)
|
|
17067
17143
|
}));
|
|
17068
17144
|
} catch {
|
|
17069
17145
|
return null;
|
|
@@ -17090,12 +17166,12 @@ async function slackMember(response) {
|
|
|
17090
17166
|
}
|
|
17091
17167
|
}
|
|
17092
17168
|
/** Bounded daemon-side checks; no response body or exception text leaves this module. */
|
|
17093
|
-
async function runDaemonDoctor(ctx, productVersion, fetcher = fetch) {
|
|
17169
|
+
async function runDaemonDoctor(ctx, productVersion, fetcher = fetch, { deadlineMs = DEADLINE_MS } = {}) {
|
|
17094
17170
|
const { config, secrets } = ctx;
|
|
17095
17171
|
const checks = [];
|
|
17096
17172
|
const jiraTrackers = config.projects.flatMap((project) => project.tracker.type === "jira" ? [project.tracker] : []);
|
|
17097
17173
|
const slackConfigured = Boolean(config.slack.channels.feed || config.slack.channels.orchestrators);
|
|
17098
|
-
const linkSamples = sampleLinks(ctx, fetcher, secrets["GITHUB_TOKEN"]);
|
|
17174
|
+
const linkSamples = sampleLinks(ctx, fetcher, deadlineMs, secrets["GITHUB_TOKEN"]);
|
|
17099
17175
|
const missing = requiredSecretKeys(config).filter((name) => !secrets[name]);
|
|
17100
17176
|
checks.push(check("secrets", missing.length === 0, `Add ${missing.join(", ")} to the private secrets.env file.`));
|
|
17101
17177
|
const jiraEmail = secrets["JIRA_EMAIL"];
|
|
@@ -17104,7 +17180,7 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch) {
|
|
|
17104
17180
|
if (jiraTrackers.length > 0 && jiraEmail && jiraToken) {
|
|
17105
17181
|
const credentials = Buffer.from(`${jiraEmail}:${jiraToken}`).toString("base64");
|
|
17106
17182
|
jiraOk = (await Promise.all(jiraTrackers.map(async (tracker) => {
|
|
17107
|
-
return (await request(ctx, fetcher, "jira", new URL("/rest/api/3/myself", tracker.baseUrl), { headers: {
|
|
17183
|
+
return (await request(ctx, fetcher, deadlineMs, "jira", new URL("/rest/api/3/myself", tracker.baseUrl), { headers: {
|
|
17108
17184
|
Authorization: `Basic ${credentials}`,
|
|
17109
17185
|
Accept: "application/json"
|
|
17110
17186
|
} }))?.ok === true;
|
|
@@ -17114,12 +17190,12 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch) {
|
|
|
17114
17190
|
const githubToken = secrets["GITHUB_TOKEN"];
|
|
17115
17191
|
const githubRepos = new Set(config.projects.flatMap((project) => project.repos));
|
|
17116
17192
|
const githubFailure = (githubToken === void 0 ? [GITHUB_FIX] : await Promise.all([...githubRepos].map(async (repo) => {
|
|
17117
|
-
const response = await request(ctx, fetcher, "github", `https://api.github.com/repos/${repo}`, { headers: {
|
|
17193
|
+
const response = await request(ctx, fetcher, deadlineMs, "github", `https://api.github.com/repos/${repo}`, { headers: {
|
|
17118
17194
|
Authorization: `Bearer ${githubToken}`,
|
|
17119
17195
|
Accept: "application/vnd.github+json"
|
|
17120
17196
|
} });
|
|
17121
17197
|
if (response?.ok !== true) return GITHUB_FIX;
|
|
17122
|
-
const probe = await githubGraphql(ctx, fetcher, githubToken, repo);
|
|
17198
|
+
const probe = await githubGraphql(ctx, fetcher, deadlineMs, githubToken, repo);
|
|
17123
17199
|
if (probe?.response.ok !== true) return GITHUB_FIX;
|
|
17124
17200
|
const payload = object(probe.body);
|
|
17125
17201
|
const errors = payload?.["errors"];
|
|
@@ -17138,7 +17214,7 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch) {
|
|
|
17138
17214
|
checks.push(check("github.credentials", githubFailure === null, githubFailure ?? GITHUB_FIX));
|
|
17139
17215
|
checks.push(linkRulesCheck(await linkSamples));
|
|
17140
17216
|
const probe = spurSendRequest(config.adapters.spur.baseUrl, SPUR_PROBE_SESSION, "spur-board doctor probe");
|
|
17141
|
-
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)]);
|
|
17217
|
+
const [spur, spurSend] = await Promise.all([request(ctx, fetcher, deadlineMs, "spur", new URL("sessions", `${config.adapters.spur.baseUrl.replace(/\/$/, "")}/`)), request(ctx, fetcher, deadlineMs, "spur.send", probe.url, probe.init)]);
|
|
17142
17218
|
checks.push(check("spur.api", spur?.ok === true, "Start or correct the configured Spur API."));
|
|
17143
17219
|
const spurSendOk = spurSend?.status === 404 && ((await spurErrorText(spurSend))?.startsWith("Session not found") ?? false);
|
|
17144
17220
|
if (spurSend !== null && spurSend.status !== 404) await spurSend.body?.cancel().catch(() => void 0);
|
|
@@ -17148,7 +17224,7 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch) {
|
|
|
17148
17224
|
const botToken = secrets["SLACK_BOT_TOKEN"];
|
|
17149
17225
|
const slackHeaders = botToken ? { Authorization: `Bearer ${botToken}` } : {};
|
|
17150
17226
|
const slackBase = `${(secrets["SLACK_API_URL"] || "https://slack.com/api/").replace(/\/$/, "")}/`;
|
|
17151
|
-
const auth = botToken ? await request(ctx, fetcher, "slack.auth", new URL("auth.test", slackBase), {
|
|
17227
|
+
const auth = botToken ? await request(ctx, fetcher, deadlineMs, "slack.auth", new URL("auth.test", slackBase), {
|
|
17152
17228
|
method: "POST",
|
|
17153
17229
|
headers: slackHeaders
|
|
17154
17230
|
}) : null;
|
|
@@ -17157,13 +17233,13 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch) {
|
|
|
17157
17233
|
const missingScopes = SLACK_BOT_SCOPES.filter((scope) => !granted.has(scope));
|
|
17158
17234
|
checks.push(check("slack.auth", authorized && missingScopes.length === 0, authorized ? `Add ${missingScopes.join(", ")} to the Slack app and reinstall it.` : "Check the Slack bot token."));
|
|
17159
17235
|
for (const [id, channel] of [["slack.orchestrators_member", config.slack.channels.orchestrators], ["slack.feed_member", config.slack.channels.feed]]) {
|
|
17160
|
-
const response = botToken && channel ? await request(ctx, fetcher, id, new URL(`conversations.info?channel=${encodeURIComponent(channel)}`, slackBase), { headers: slackHeaders }) : null;
|
|
17236
|
+
const response = botToken && channel ? await request(ctx, fetcher, deadlineMs, id, new URL(`conversations.info?channel=${encodeURIComponent(channel)}`, slackBase), { headers: slackHeaders }) : null;
|
|
17161
17237
|
checks.push(check(id, await slackMember(response), "Invite the bot to the configured channel ID."));
|
|
17162
17238
|
}
|
|
17163
17239
|
const configToken = secrets["SLACK_APP_CONFIG_TOKEN"];
|
|
17164
17240
|
if (!configToken || !config.slack.appId) checks.push(warning("slack.command", "Verify the installed Slack slash command against slack.command manually, or provide SLACK_APP_CONFIG_TOKEN and slack.appId."));
|
|
17165
17241
|
else {
|
|
17166
|
-
const response = await request(ctx, fetcher, "slack.command", new URL("apps.manifest.export", slackBase), {
|
|
17242
|
+
const response = await request(ctx, fetcher, deadlineMs, "slack.command", new URL("apps.manifest.export", slackBase), {
|
|
17167
17243
|
method: "POST",
|
|
17168
17244
|
headers: {
|
|
17169
17245
|
Authorization: `Bearer ${configToken}`,
|
|
@@ -17270,36 +17346,20 @@ function createInboundModule(ctx, gateway, registry = {}) {
|
|
|
17270
17346
|
clock: ctx.clock,
|
|
17271
17347
|
registry
|
|
17272
17348
|
});
|
|
17273
|
-
|
|
17274
|
-
|
|
17275
|
-
|
|
17276
|
-
|
|
17277
|
-
const schedule = () => {
|
|
17278
|
-
if (stopped || signal?.aborted) return;
|
|
17279
|
-
timer = setTimeout(() => {
|
|
17280
|
-
timer = void 0;
|
|
17281
|
-
tick();
|
|
17282
|
-
}, RECOVERY_MS);
|
|
17283
|
-
};
|
|
17284
|
-
const tick = () => {
|
|
17285
|
-
if (stopped || signal?.aborted) return;
|
|
17286
|
-
active = ctx.logCall("inbound.recover", () => inbound.recover()).catch((err) => {
|
|
17349
|
+
const recovery = createJob({
|
|
17350
|
+
run: () => ctx.logCall("inbound.recover", () => inbound.recover()),
|
|
17351
|
+
intervalMs: RECOVERY_MS,
|
|
17352
|
+
onError: (err) => {
|
|
17287
17353
|
ctx.log.error({ err }, "inbound recovery failed");
|
|
17288
|
-
}
|
|
17289
|
-
};
|
|
17354
|
+
}
|
|
17355
|
+
});
|
|
17290
17356
|
return {
|
|
17291
17357
|
sink: (event) => inbound.sink(event),
|
|
17292
17358
|
reapply: inbound.reapply,
|
|
17293
|
-
awaitRecovery: () =>
|
|
17294
|
-
start(
|
|
17295
|
-
signal = startSignal;
|
|
17296
|
-
tick();
|
|
17297
|
-
return Promise.resolve();
|
|
17298
|
-
},
|
|
17359
|
+
awaitRecovery: () => recovery.settled(),
|
|
17360
|
+
start: (signal) => recovery.start(signal),
|
|
17299
17361
|
async stop() {
|
|
17300
|
-
|
|
17301
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
17302
|
-
await active;
|
|
17362
|
+
await recovery.stop();
|
|
17303
17363
|
await inbound.stop();
|
|
17304
17364
|
}
|
|
17305
17365
|
};
|
|
@@ -17344,8 +17404,8 @@ function slackSettings(config, secrets) {
|
|
|
17344
17404
|
};
|
|
17345
17405
|
}
|
|
17346
17406
|
/**
|
|
17347
|
-
* Own the
|
|
17348
|
-
* closes.
|
|
17407
|
+
* Own the outbox, token-expiry and doorbell jobs, each logging its own failure, and wait for
|
|
17408
|
+
* their active runs and every queued connection update before the store closes.
|
|
17349
17409
|
*/
|
|
17350
17410
|
function createOutboxModule(ctx, gateway, options = {}) {
|
|
17351
17411
|
const spur = options.spur ?? createSpurPort({ baseUrl: ctx.config.adapters.spur.baseUrl });
|
|
@@ -17356,40 +17416,51 @@ function createOutboxModule(ctx, gateway, options = {}) {
|
|
|
17356
17416
|
spur: { send: (session, text) => ctx.logCall("spur.send", () => spur.send(session, text)) },
|
|
17357
17417
|
now: () => new Date(ctx.clock.now())
|
|
17358
17418
|
});
|
|
17359
|
-
|
|
17360
|
-
|
|
17419
|
+
const every = {
|
|
17420
|
+
intervalMs: options.tickMs ?? TICK_MS,
|
|
17421
|
+
jitterMs: options.jitterMs ?? TICK_JITTER_MS
|
|
17422
|
+
};
|
|
17423
|
+
const outbox = createJob({
|
|
17424
|
+
...every,
|
|
17425
|
+
run: (signal) => ctx.logCall("outbox.tick", () => sender.tick(signal)),
|
|
17426
|
+
onError: () => void 0
|
|
17427
|
+
});
|
|
17428
|
+
const tokens = createJob({
|
|
17429
|
+
...every,
|
|
17430
|
+
run: () => expirePendingTokens(ctx.store, ctx.config, new Date(ctx.clock.now())),
|
|
17431
|
+
onError: (err) => {
|
|
17432
|
+
ctx.log.error({ err }, "token expiry failed");
|
|
17433
|
+
}
|
|
17434
|
+
});
|
|
17435
|
+
const doorbells = createJob({
|
|
17436
|
+
...every,
|
|
17437
|
+
run: () => reconcileDueDoorbells(ctx.store, ctx.config, new Date(ctx.clock.now())),
|
|
17438
|
+
onError: (err) => {
|
|
17439
|
+
ctx.log.error({ err }, "doorbell reconcile failed");
|
|
17440
|
+
}
|
|
17441
|
+
});
|
|
17442
|
+
const jobs = [
|
|
17443
|
+
tokens,
|
|
17444
|
+
doorbells,
|
|
17445
|
+
outbox
|
|
17446
|
+
];
|
|
17361
17447
|
let updating = Promise.resolve();
|
|
17362
17448
|
let stopped = false;
|
|
17363
|
-
let signal;
|
|
17364
|
-
const schedule = () => {
|
|
17365
|
-
if (stopped || signal?.aborted) return;
|
|
17366
|
-
timer = setTimeout(() => {
|
|
17367
|
-
timer = void 0;
|
|
17368
|
-
tick().then(schedule);
|
|
17369
|
-
}, TICK_MS + Math.floor(Math.random() * TICK_JITTER_MS));
|
|
17370
|
-
};
|
|
17371
|
-
const tick = () => {
|
|
17372
|
-
if (stopped || signal?.aborted) return active;
|
|
17373
|
-
active = active.then(() => ctx.logCall("outbox.tick", async () => {
|
|
17374
|
-
await expirePendingTokens(ctx.store, ctx.config, new Date(ctx.clock.now()));
|
|
17375
|
-
if (!signal?.aborted) await sender.tick(signal);
|
|
17376
|
-
})).catch(() => void 0);
|
|
17377
|
-
return active;
|
|
17378
|
-
};
|
|
17379
17449
|
return {
|
|
17380
|
-
async start(
|
|
17381
|
-
signal = startSignal;
|
|
17450
|
+
async start(signal) {
|
|
17382
17451
|
await sender.recover();
|
|
17383
17452
|
if (signal.aborted) return;
|
|
17384
|
-
|
|
17453
|
+
await Promise.all(jobs.map((job) => job.start(signal)));
|
|
17385
17454
|
},
|
|
17386
17455
|
async stop() {
|
|
17387
17456
|
stopped = true;
|
|
17388
|
-
|
|
17389
|
-
await active;
|
|
17457
|
+
await Promise.all(jobs.map((job) => job.stop()));
|
|
17390
17458
|
await updating;
|
|
17391
17459
|
},
|
|
17392
|
-
pulse
|
|
17460
|
+
async pulse() {
|
|
17461
|
+
await doorbells.trigger();
|
|
17462
|
+
await outbox.trigger();
|
|
17463
|
+
},
|
|
17393
17464
|
connection(state) {
|
|
17394
17465
|
if (stopped) return Promise.resolve();
|
|
17395
17466
|
const update = sender.recordConnection(state, new Date(ctx.clock.now())).catch((err) => {
|
|
@@ -17506,6 +17577,7 @@ function createSystemdModule(notifier) {
|
|
|
17506
17577
|
}
|
|
17507
17578
|
//#endregion
|
|
17508
17579
|
//#region ../daemon/src/composition.ts
|
|
17580
|
+
const DAY_MS = 864e5;
|
|
17509
17581
|
/** The production module graph, with replaceable external ports for in-process tests. */
|
|
17510
17582
|
function createDaemonModules(ctxFor, ports = {}) {
|
|
17511
17583
|
const board = ctxFor("board-core");
|
|
@@ -17517,7 +17589,10 @@ function createDaemonModules(ctxFor, ports = {}) {
|
|
|
17517
17589
|
});
|
|
17518
17590
|
const ctx = ctxFor("gateway-slack");
|
|
17519
17591
|
const settings = slackSettings(ctx.config, ctx.secrets);
|
|
17520
|
-
const gateway = ports.gateway ?? (settings === null ? void 0 : createSlackGateway(
|
|
17592
|
+
const gateway = ports.gateway ?? (settings === null ? void 0 : createSlackGateway({
|
|
17593
|
+
...settings,
|
|
17594
|
+
now: () => ctx.clock.now()
|
|
17595
|
+
}));
|
|
17521
17596
|
const registry = createOperationRegistry({
|
|
17522
17597
|
config: board.config,
|
|
17523
17598
|
clock: board.clock,
|
|
@@ -17536,10 +17611,10 @@ function createDaemonModules(ctxFor, ports = {}) {
|
|
|
17536
17611
|
const entries = [{
|
|
17537
17612
|
name: "commands",
|
|
17538
17613
|
stopStage: "final",
|
|
17539
|
-
module:
|
|
17540
|
-
|
|
17541
|
-
|
|
17542
|
-
|
|
17614
|
+
module: createJob({
|
|
17615
|
+
run: () => purgeExpiredCommands(commands.store, commands.clock, commands.config.commands.retentionDays),
|
|
17616
|
+
intervalMs: DAY_MS,
|
|
17617
|
+
first: "await",
|
|
17543
17618
|
onError: (err) => {
|
|
17544
17619
|
commands.log.error({ err }, "command purge failed");
|
|
17545
17620
|
}
|
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-C6fOCG5L.mjs";
|
|
2
|
+
import { i as CliError, n as requestOperation } from "./client-B4JXkdZu.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-CreYUbFe.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -601,7 +601,11 @@ const ERRORS = {
|
|
|
601
601
|
exit: EXIT_CODES.config,
|
|
602
602
|
message: "The configuration is missing or invalid.",
|
|
603
603
|
hint: "Fix the configuration file named in the error, then run the command again.",
|
|
604
|
-
recovery: noRetry("Fix the named configuration file and retry.")
|
|
604
|
+
recovery: noRetry("Fix the named configuration file and retry."),
|
|
605
|
+
mcp: {
|
|
606
|
+
hint: "Fix the variable named in `context.environmentVariable` where `board mcp` starts. Only when `context.configPath` is also present, making that config.yaml valid with an `http.port` works instead; `board doctor --offline` names what is wrong in it.",
|
|
607
|
+
recovery: noRetry("Fix the named variable or config.yaml, restarting your agent session after a variable change, then retry the tool call.")
|
|
608
|
+
}
|
|
605
609
|
}),
|
|
606
610
|
identity_missing: spec("identity_missing", {
|
|
607
611
|
status: null,
|
package/package.json
CHANGED
package/skills/setup/SKILL.md
CHANGED
|
@@ -30,7 +30,7 @@ Ask one question at a time, only when current state cannot answer it. Check befo
|
|
|
30
30
|
## 4. Start service and grant access
|
|
31
31
|
|
|
32
32
|
- Check `board service status`; if absent, run `board service install`. Ask before enabling user lingering, which keeps the service running after logout.
|
|
33
|
-
- If operator access is unset, ask whether the operator will use a Spur project marked `operator
|
|
33
|
+
- If operator access is unset, ask whether the operator will use a Spur project marked `operator`, which needs no token, or a session outside Spur rooted in a chosen folder, inside its git worktree if any, not above the root. Check for an existing valid token; only if absent run `board token create --name <name> --into <folder>`, then ask the operator to approve it in Slack. Check existing agent registration before registering `board mcp`.
|
|
34
34
|
- Check installed skill stamps and content. If absent or older, ask before writing skill folders, run `board skills install`, then verify both Claude Code and Codex copies.
|
|
35
35
|
- For a Spur project used by Codex, check `.agents/skills/spur-board/SKILL.md` in a fresh session. If missing, ask before touching the project's main checkout. In that checkout, link the path to the installed product skill, for example `ln -s "$HOME/.codex/skills/spur-board" .agents/skills/spur-board`. Add `/.agents/skills/spur-board` to the Git exclude file resolved by `git rev-parse --git-path info/exclude`. Add `.agents/skills/spur-board` to that project's `symlinks` in `spur.yaml` and reload Spur config. Start a new session and verify the injected SKILL.md resolves.
|
|
36
36
|
|