spur-board 0.74.0 → 0.76.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/{chunk-By6oaupX.mjs → chunk-BEExLWBt.mjs} +18 -2
- package/dist/{chunk-_sUjmlJS.mjs → chunk-BSs9OrJD.mjs} +1 -1
- package/dist/{chunk-BubGdelE.mjs → chunk-CFvX6Mf9.mjs} +2 -2
- package/dist/cli.mjs +3 -3
- package/dist/client.mjs +1 -1
- package/dist/daemon.mjs +356 -119
- package/dist/mcp.mjs +3 -3
- package/dist/migrations/0024_event_via.sql +2 -0
- package/package.json +1 -1
- package/skills/setup/SKILL.md +6 -5
- package/skills/setup/references/web.md +27 -0
- package/skills/spur-board/references/how-board-works-turns.md +2 -0
- package/skills/spur-board/references/how-board-works.md +16 -0
|
@@ -177,6 +177,12 @@ const ACTORS = [
|
|
|
177
177
|
"agent",
|
|
178
178
|
"system"
|
|
179
179
|
];
|
|
180
|
+
/**
|
|
181
|
+
* The channel a write arrived through, whoever the actor, journaled as `event.via`; a write
|
|
182
|
+
* outside both has none. Named `via` because core keeps platform terms such as "channel" out of
|
|
183
|
+
* its source.
|
|
184
|
+
*/
|
|
185
|
+
const VIAS = ["web", "slack"];
|
|
180
186
|
/** The stored state of an operator token. */
|
|
181
187
|
const TOKEN_STATUSES = [
|
|
182
188
|
"pending",
|
|
@@ -658,7 +664,7 @@ const configObject = z.strictObject({
|
|
|
658
664
|
}).prefault({}),
|
|
659
665
|
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({}),
|
|
660
666
|
web: z.strictObject({
|
|
661
|
-
port: z.int().min(0).max(65535).optional().describe("Optional web listener port (0 assigns a free port); omitted means off. Set together with publicOrigin. Must differ from http.port, including when both are 0.
|
|
667
|
+
port: z.int().min(0).max(65535).optional().describe("Optional web listener port (0 assigns a free port); omitted means off. Set together with publicOrigin. Must differ from http.port, including when both are 0."),
|
|
662
668
|
publicOrigin: z.string().optional().describe("Bare public HTTP/HTTPS origin for the web API; HTTP requires loopback. Set together with port. Every {port} is replaced with the listener port, including in hostnames. No trailing slash. The resolved origin must remain valid and HTTP loopback-only after actual-port substitution; the resolver returns no origin for an invalid actual port or resulting origin."),
|
|
663
669
|
spurUiOrigin: concreteOrigin.optional().describe("Optional concrete bare origin for the Spur UI, independently of the web API. HTTP requires loopback; no placeholders or trailing slash. Omitted means no configured UI origin.")
|
|
664
670
|
}).prefault({}),
|
|
@@ -2478,6 +2484,7 @@ function defineOperation(spec) {
|
|
|
2478
2484
|
])].sort((a, b) => order.indexOf(a) - order.indexOf(b));
|
|
2479
2485
|
return {
|
|
2480
2486
|
...spec,
|
|
2487
|
+
web: spec.web ?? null,
|
|
2481
2488
|
preconditions: spec.preconditions ?? null,
|
|
2482
2489
|
errors,
|
|
2483
2490
|
cli: {
|
|
@@ -3078,6 +3085,7 @@ const tokenName = z.string().min(1).describe("Unique name of the operator token.
|
|
|
3078
3085
|
const OPERATIONS = [
|
|
3079
3086
|
defineOperation({
|
|
3080
3087
|
id: "status.get",
|
|
3088
|
+
web: true,
|
|
3081
3089
|
kind: "query",
|
|
3082
3090
|
description: "List items, freshness and tasks with turns, PR summaries and navigation; detail adds full facts.",
|
|
3083
3091
|
mcp: {
|
|
@@ -3217,6 +3225,7 @@ const OPERATIONS = [
|
|
|
3217
3225
|
}),
|
|
3218
3226
|
defineOperation({
|
|
3219
3227
|
id: "task.get",
|
|
3228
|
+
web: true,
|
|
3220
3229
|
kind: "query",
|
|
3221
3230
|
description: "Show a task; refresh reads GitHub PRs.",
|
|
3222
3231
|
mcp: {
|
|
@@ -3357,6 +3366,7 @@ const OPERATIONS = [
|
|
|
3357
3366
|
}),
|
|
3358
3367
|
defineOperation({
|
|
3359
3368
|
id: "task.history",
|
|
3369
|
+
web: true,
|
|
3360
3370
|
kind: "query",
|
|
3361
3371
|
description: "List what happened to a task, oldest first.",
|
|
3362
3372
|
mcp: {
|
|
@@ -3370,6 +3380,7 @@ const OPERATIONS = [
|
|
|
3370
3380
|
at: z.iso.datetime().describe("When it happened, ISO 8601 UTC."),
|
|
3371
3381
|
kind: z.enum(EVENT_KINDS).describe("Journal event kind."),
|
|
3372
3382
|
actor: actorIdSchema,
|
|
3383
|
+
via: z.enum(VIAS).optional().describe("Channel the write arrived through, web or slack, whoever the actor; absent for CLI, MCP, agent and scheduled writes."),
|
|
3373
3384
|
summary: z.string().describe("What happened, in one line.")
|
|
3374
3385
|
}).describe("One journal event.")).describe("Journal events of the task, oldest first.")
|
|
3375
3386
|
}),
|
|
@@ -3457,6 +3468,7 @@ const OPERATIONS = [
|
|
|
3457
3468
|
}),
|
|
3458
3469
|
defineOperation({
|
|
3459
3470
|
id: "inbox.get",
|
|
3471
|
+
web: true,
|
|
3460
3472
|
kind: "query",
|
|
3461
3473
|
description: "List the comments, blocks and turns addressed to the caller and not yet handled.",
|
|
3462
3474
|
mcp: {
|
|
@@ -3896,6 +3908,7 @@ const OPERATIONS = [
|
|
|
3896
3908
|
}),
|
|
3897
3909
|
defineOperation({
|
|
3898
3910
|
id: "comment.add",
|
|
3911
|
+
web: true,
|
|
3899
3912
|
kind: "mutation",
|
|
3900
3913
|
description: "Comment on a task.",
|
|
3901
3914
|
mcp: {
|
|
@@ -4057,6 +4070,7 @@ const OPERATIONS = [
|
|
|
4057
4070
|
}),
|
|
4058
4071
|
defineOperation({
|
|
4059
4072
|
id: "block.answer",
|
|
4073
|
+
web: true,
|
|
4060
4074
|
kind: "mutation",
|
|
4061
4075
|
description: "Answer a question; the block closes unless it is an operator conversation.",
|
|
4062
4076
|
mcp: {
|
|
@@ -4460,6 +4474,7 @@ const OPERATIONS = [
|
|
|
4460
4474
|
}),
|
|
4461
4475
|
defineOperation({
|
|
4462
4476
|
id: "config.get",
|
|
4477
|
+
web: true,
|
|
4463
4478
|
kind: "query",
|
|
4464
4479
|
description: "Show effective project columns, executors and Spur bindings.",
|
|
4465
4480
|
mcp: {
|
|
@@ -4549,6 +4564,7 @@ function catalogSnapshotBody(operations) {
|
|
|
4549
4564
|
cli: op.cli,
|
|
4550
4565
|
mcp: op.mcp,
|
|
4551
4566
|
slack: op.slack,
|
|
4567
|
+
web: op.web,
|
|
4552
4568
|
examples: op.examples,
|
|
4553
4569
|
input: z.toJSONSchema(op.input, { io: "input" }),
|
|
4554
4570
|
output: z.toJSONSchema(op.output, { io: "output" })
|
|
@@ -4661,4 +4677,4 @@ function assertNever(value) {
|
|
|
4661
4677
|
throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
|
|
4662
4678
|
}
|
|
4663
4679
|
//#endregion
|
|
4664
|
-
export { err as $, prSourceId as A, prFactsSchema as B, userIdSchema as C, AdapterError as D, eventPayloadSchemas as E, REVIEW_STATES as F, JIRA_PROJECT_KEY as G, ringMarker as H, SESSION_HEALTH_STATES as I, encodeActorId as J, REF_NUMBER as K, SESSION_STATUSES as L, sourceCursorSchema as M, trackerSourceId as N, batchSchema as O, PR_STATES as P, ERRORS as Q, isExternalAuthor as R, messageRefSchema as S, GATE_REASONS as T, sessionFactsSchema as U, prRefSchema as V, ticketFactsSchema as W, parseActorId as X, errorCodeOf as Y, parseRef as Z, renderMcpError as _, COLUMN_IDS as _t, requestHashOf as a, DEFAULT_LINK as at, inboundEventSchema as b, TASK_HOLDS as bt, tokenRequestStatusSchema as c, DEFAULT_STAND_PORT_RANGE as ct, buildCatalogSnapshot as d, configBindings as dt, errorContextSchema as et, roleCanUseOperation as f, configSchema as ft, renderJsonError as g, resolveWebOrigin as gt, renderHttpProblem as h, requiredSecretKeys as ht, TOKEN_REQUEST_LIMITS as i, DEFAULT_HTTP_PORT as it, sessionTransitionSchema as j, entityRefSchema as k, BOARD_TICK_MS as l, RESERVED_PROJECT as lt, turnHandedSchema as m, plainHttpAllowed as mt, doctorReportSchema as n, ok as nt, tokenRequestResultSchema as o, DEFAULT_SLACK_APP_NAME as ot, OPERATIONS as p, defaultAddressee as pt, actorIdSchema as q, remoteDoctorReportSchema as r, successEnvelopeSchema as rt, tokenRequestSchema as s, DEFAULT_SLACK_COMMAND as st, assertNever as t, errorEnvelopeSchema as tt, SYSTEMD_SERVICE_SETTINGS as u, boardWideSpurProject as ut, SPACE_IDS as v, DISPATCHER_MODES as vt, EVENT_KINDS as w, interactionRefSchema as x, conversationRefSchema as y, SLACK_BOT_SCOPES as yt, parseRingMarker as z };
|
|
4680
|
+
export { err as $, prSourceId as A, prFactsSchema as B, userIdSchema as C, AdapterError as D, eventPayloadSchemas as E, REVIEW_STATES as F, JIRA_PROJECT_KEY as G, ringMarker as H, SESSION_HEALTH_STATES as I, encodeActorId as J, REF_NUMBER as K, SESSION_STATUSES as L, sourceCursorSchema as M, trackerSourceId as N, batchSchema as O, PR_STATES as P, ERRORS as Q, isExternalAuthor as R, messageRefSchema as S, GATE_REASONS as T, sessionFactsSchema as U, prRefSchema as V, ticketFactsSchema as W, parseActorId as X, errorCodeOf as Y, parseRef as Z, renderMcpError as _, COLUMN_IDS as _t, requestHashOf as a, DEFAULT_LINK as at, inboundEventSchema as b, TASK_HOLDS as bt, tokenRequestStatusSchema as c, DEFAULT_STAND_PORT_RANGE as ct, buildCatalogSnapshot as d, configBindings as dt, errorContextSchema as et, roleCanUseOperation as f, configSchema as ft, renderJsonError as g, resolveWebOrigin as gt, renderHttpProblem as h, requiredSecretKeys as ht, TOKEN_REQUEST_LIMITS as i, DEFAULT_HTTP_PORT as it, sessionTransitionSchema as j, entityRefSchema as k, BOARD_TICK_MS as l, RESERVED_PROJECT as lt, turnHandedSchema as m, plainHttpAllowed as mt, doctorReportSchema as n, ok as nt, tokenRequestResultSchema as o, DEFAULT_SLACK_APP_NAME as ot, OPERATIONS as p, defaultAddressee as pt, actorIdSchema as q, remoteDoctorReportSchema as r, successEnvelopeSchema as rt, tokenRequestSchema as s, DEFAULT_SLACK_COMMAND as st, assertNever as t, errorEnvelopeSchema as tt, SYSTEMD_SERVICE_SETTINGS as u, boardWideSpurProject as ut, SPACE_IDS as v, DISPATCHER_MODES as vt, EVENT_KINDS as w, interactionRefSchema as x, VIAS as xt, conversationRefSchema as y, SLACK_BOT_SCOPES as yt, parseRingMarker as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Q as ERRORS, c as tokenRequestStatusSchema, et as errorContextSchema, g as renderJsonError, o as tokenRequestResultSchema, rt as successEnvelopeSchema, tt as errorEnvelopeSchema } from "./chunk-
|
|
1
|
+
import { Q as ERRORS, c as tokenRequestStatusSchema, et as errorContextSchema, g as renderJsonError, o as tokenRequestResultSchema, rt as successEnvelopeSchema, tt as errorEnvelopeSchema } from "./chunk-BEExLWBt.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as buildCatalogSnapshot, ft as configSchema, mt as plainHttpAllowed, p as OPERATIONS } from "./chunk-
|
|
2
|
-
import { o as CliError, t as fetchCatalogVersion } from "./chunk-
|
|
1
|
+
import { d as buildCatalogSnapshot, ft as configSchema, mt as plainHttpAllowed, p as OPERATIONS } from "./chunk-BEExLWBt.mjs";
|
|
2
|
+
import { o as CliError, t as fetchCatalogVersion } from "./chunk-BSs9OrJD.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";
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Q as ERRORS, a as requestHashOf, ct as DEFAULT_STAND_PORT_RANGE, f as roleCanUseOperation, ft as configSchema, gt as resolveWebOrigin, ht as requiredSecretKeys, p as OPERATIONS, q as actorIdSchema, r as remoteDoctorReportSchema, rt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS, yt as SLACK_BOT_SCOPES } from "./chunk-
|
|
1
|
+
import { Q as ERRORS, a as requestHashOf, ct as DEFAULT_STAND_PORT_RANGE, f as roleCanUseOperation, ft as configSchema, gt as resolveWebOrigin, ht as requiredSecretKeys, p as OPERATIONS, q as actorIdSchema, r as remoteDoctorReportSchema, rt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS, yt as SLACK_BOT_SCOPES } from "./chunk-BEExLWBt.mjs";
|
|
2
2
|
import { t as apiBaseUrl } from "./chunk-DAMwWWmT.mjs";
|
|
3
|
-
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-
|
|
4
|
-
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-
|
|
3
|
+
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-BSs9OrJD.mjs";
|
|
4
|
+
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-CFvX6Mf9.mjs";
|
|
5
5
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
6
6
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
7
7
|
import { homedir, hostname, userInfo } from "node:os";
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-
|
|
1
|
+
import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-BSs9OrJD.mjs";
|
|
2
2
|
export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestSkillReload, requestTokenEnrollment };
|
package/dist/daemon.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { $ as err, A as prSourceId, B as prFactsSchema, C as userIdSchema, D as AdapterError, E as eventPayloadSchemas, F as REVIEW_STATES, G as JIRA_PROJECT_KEY, H as ringMarker, I as SESSION_HEALTH_STATES, J as encodeActorId, K as REF_NUMBER, L as SESSION_STATUSES, M as sourceCursorSchema, N as trackerSourceId, O as batchSchema, P as PR_STATES, Q as ERRORS, R as isExternalAuthor, S as messageRefSchema, T as GATE_REASONS, U as sessionFactsSchema, V as prRefSchema, W as ticketFactsSchema, X as parseActorId, Y as errorCodeOf, Z as parseRef$1, _t as COLUMN_IDS, a as requestHashOf, at as DEFAULT_LINK, b as inboundEventSchema, bt as TASK_HOLDS, c as tokenRequestStatusSchema, d as buildCatalogSnapshot, dt as configBindings, f as roleCanUseOperation, ft as configSchema, h as renderHttpProblem, ht as requiredSecretKeys, i as TOKEN_REQUEST_LIMITS, j as sessionTransitionSchema, k as entityRefSchema, l as BOARD_TICK_MS, lt as RESERVED_PROJECT, m as turnHandedSchema, mt as plainHttpAllowed, n as doctorReportSchema, nt as ok, o as tokenRequestResultSchema, p as OPERATIONS, pt as defaultAddressee, q as actorIdSchema, rt as successEnvelopeSchema, s as tokenRequestSchema, st as DEFAULT_SLACK_COMMAND, t as assertNever, ut as boardWideSpurProject, v as SPACE_IDS, vt as DISPATCHER_MODES, w as EVENT_KINDS, x as interactionRefSchema, y as conversationRefSchema, yt as SLACK_BOT_SCOPES, z as parseRingMarker } from "./chunk-
|
|
1
|
+
import { $ as err, A as prSourceId, B as prFactsSchema, C as userIdSchema, D as AdapterError, E as eventPayloadSchemas, F as REVIEW_STATES, G as JIRA_PROJECT_KEY, H as ringMarker, I as SESSION_HEALTH_STATES, J as encodeActorId, K as REF_NUMBER, L as SESSION_STATUSES, M as sourceCursorSchema, N as trackerSourceId, O as batchSchema, P as PR_STATES, Q as ERRORS, R as isExternalAuthor, S as messageRefSchema, T as GATE_REASONS, U as sessionFactsSchema, V as prRefSchema, W as ticketFactsSchema, X as parseActorId, Y as errorCodeOf, Z as parseRef$1, _t as COLUMN_IDS, a as requestHashOf, at as DEFAULT_LINK, b as inboundEventSchema, bt as TASK_HOLDS, c as tokenRequestStatusSchema, d as buildCatalogSnapshot, dt as configBindings, f as roleCanUseOperation, ft as configSchema, gt as resolveWebOrigin, h as renderHttpProblem, ht as requiredSecretKeys, i as TOKEN_REQUEST_LIMITS, j as sessionTransitionSchema, k as entityRefSchema, l as BOARD_TICK_MS, lt as RESERVED_PROJECT, m as turnHandedSchema, mt as plainHttpAllowed, n as doctorReportSchema, nt as ok, o as tokenRequestResultSchema, p as OPERATIONS, pt as defaultAddressee, q as actorIdSchema, rt as successEnvelopeSchema, s as tokenRequestSchema, st as DEFAULT_SLACK_COMMAND, t as assertNever, ut as boardWideSpurProject, v as SPACE_IDS, vt as DISPATCHER_MODES, w as EVENT_KINDS, x as interactionRefSchema, xt as VIAS, y as conversationRefSchema, yt as SLACK_BOT_SCOPES, z as parseRingMarker } from "./chunk-BEExLWBt.mjs";
|
|
2
2
|
import { t as apiBaseUrl } from "./chunk-DAMwWWmT.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import { chmodSync, closeSync, existsSync, fchmodSync, fstatSync, fsyncSync, ftruncateSync, linkSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeSync } from "node:fs";
|
|
6
6
|
import { homedir, hostname } from "node:os";
|
|
7
|
-
import path, { basename, dirname, isAbsolute, join, normalize, resolve } from "node:path";
|
|
7
|
+
import path, { basename, dirname, extname, isAbsolute, join, normalize, resolve } from "node:path";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import YAML from "yaml";
|
|
10
10
|
import { spawn, spawnSync } from "node:child_process";
|
|
11
11
|
import { parseEnv } from "node:util";
|
|
12
|
-
import { lstat } from "node:fs/promises";
|
|
12
|
+
import { lstat, readFile, readdir } from "node:fs/promises";
|
|
13
13
|
import Database from "better-sqlite3";
|
|
14
14
|
import { Kysely, SqliteDialect, sql } from "kysely";
|
|
15
15
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -8134,7 +8134,20 @@ const commandKeys = new AsyncLocalStorage();
|
|
|
8134
8134
|
function withCommandKey(key, fn) {
|
|
8135
8135
|
return commandKeys.run(key, fn);
|
|
8136
8136
|
}
|
|
8137
|
-
|
|
8137
|
+
const vias = new AsyncLocalStorage();
|
|
8138
|
+
/**
|
|
8139
|
+
* Runs fn in the scope of one write path (`web` or `slack`): every event `emit` writes inside it
|
|
8140
|
+
* carries it in `via`. The innermost scope wins, and it nests independently of `withCommandKey`.
|
|
8141
|
+
* The same rule applies: run only request work inside it, never trigger a job or start detached
|
|
8142
|
+
* work (timers, unawaited promises), or later scheduled runs would carry this `via`.
|
|
8143
|
+
*/
|
|
8144
|
+
function withVia(via, fn) {
|
|
8145
|
+
return vias.run(via, fn);
|
|
8146
|
+
}
|
|
8147
|
+
/**
|
|
8148
|
+
* The only writer of the journal; `request_id` is the key of the enclosing command and `via` the
|
|
8149
|
+
* write path of the enclosing `withVia` scope, each null outside one.
|
|
8150
|
+
*/
|
|
8138
8151
|
async function emit(trx, kind, project, taskId, at, payload, actor = "system") {
|
|
8139
8152
|
const parsed = parseActorId(actor);
|
|
8140
8153
|
if (parsed === null) throw new Error("Invalid journal actor");
|
|
@@ -8147,7 +8160,8 @@ async function emit(trx, kind, project, taskId, at, payload, actor = "system") {
|
|
|
8147
8160
|
actor_ref: parsed.actor === "agent" ? JSON.stringify(parsed.actorRef) : null,
|
|
8148
8161
|
payload: toJson(eventPayloadSchemas[kind], payload),
|
|
8149
8162
|
v: 1,
|
|
8150
|
-
request_id: commandKeys.getStore() ?? null
|
|
8163
|
+
request_id: commandKeys.getStore() ?? null,
|
|
8164
|
+
via: vias.getStore() ?? null
|
|
8151
8165
|
}).execute();
|
|
8152
8166
|
}
|
|
8153
8167
|
const actorRefSchema = z.strictObject({
|
|
@@ -11068,6 +11082,68 @@ function tokenAttentionLine(attention, unusedAfterDays) {
|
|
|
11068
11082
|
return `${head}: ${String(total)} not named`;
|
|
11069
11083
|
}
|
|
11070
11084
|
//#endregion
|
|
11085
|
+
//#region ../core/src/api/ops-route.ts
|
|
11086
|
+
function inputBody(body) {
|
|
11087
|
+
if (body === null || typeof body !== "object" || Array.isArray(body)) throw new CommandError("usage", "Send a JSON object with input and optional key.");
|
|
11088
|
+
const record = body;
|
|
11089
|
+
if (!Object.hasOwn(record, "input") || Object.keys(record).some((name) => name !== "input" && name !== "key") || record["key"] !== void 0 && typeof record["key"] !== "string") throw new CommandError("usage", "Send a JSON object with input and optional key.");
|
|
11090
|
+
return {
|
|
11091
|
+
input: record["input"],
|
|
11092
|
+
key: record["key"]
|
|
11093
|
+
};
|
|
11094
|
+
}
|
|
11095
|
+
function installOperationErrors(app, options) {
|
|
11096
|
+
const handler = (error, request, reply) => {
|
|
11097
|
+
let code = "unexpected";
|
|
11098
|
+
let hint;
|
|
11099
|
+
if (error instanceof CommandError) {
|
|
11100
|
+
code = error.code;
|
|
11101
|
+
hint = error.hint;
|
|
11102
|
+
} else if (error instanceof Error && "statusCode" in error) {
|
|
11103
|
+
if (error.statusCode === 400 || error.statusCode === 413) code = "usage";
|
|
11104
|
+
if (error.statusCode === 413) hint = "Send a smaller JSON body.";
|
|
11105
|
+
}
|
|
11106
|
+
if (code === "unexpected") options.logError?.({
|
|
11107
|
+
requestId: request.id,
|
|
11108
|
+
err: error
|
|
11109
|
+
});
|
|
11110
|
+
const problem = renderHttpProblem({
|
|
11111
|
+
code,
|
|
11112
|
+
requestId: request.id
|
|
11113
|
+
});
|
|
11114
|
+
reply.code(problem.status).type("application/problem+json").send(hint === void 0 ? problem.body : {
|
|
11115
|
+
...problem.body,
|
|
11116
|
+
hint
|
|
11117
|
+
});
|
|
11118
|
+
};
|
|
11119
|
+
app.setErrorHandler(handler);
|
|
11120
|
+
return handler;
|
|
11121
|
+
}
|
|
11122
|
+
function createOpsRoute(app, options, callers = /* @__PURE__ */ new WeakMap()) {
|
|
11123
|
+
const notReady = () => options.stopping?.() === true ? new CommandError("stopping", "Wait until the daemon is running again.") : new CommandError("starting", "Wait until the daemon is ready.");
|
|
11124
|
+
app.post("/v1/ops/:id", { onRequest: async (request) => {
|
|
11125
|
+
if (!options.ready()) throw notReady();
|
|
11126
|
+
callers.set(request, await options.identify(request));
|
|
11127
|
+
} }, async (request, reply) => {
|
|
11128
|
+
const caller = callers.get(request);
|
|
11129
|
+
if (caller === void 0) throw new Error("Operation identity was not resolved.");
|
|
11130
|
+
const operation = OPERATIONS.find((entry) => entry.id === request.params.id);
|
|
11131
|
+
if (operation === void 0) throw new CommandError("version_mismatch", "This daemon does not know the operation. Run `board service restart` to update the daemon, then retry.");
|
|
11132
|
+
if (options.allow?.(operation) === false) throw new CommandError("forbidden", "This operation is not available on the web.");
|
|
11133
|
+
const body = inputBody(request.body);
|
|
11134
|
+
const parsed = operation.input.safeParse(body.input);
|
|
11135
|
+
if (!parsed.success) throw new CommandError(errorCodeOf(parsed.error), "Fix the operation input.");
|
|
11136
|
+
const dispatch = () => dispatchOperation(options, operation.id, parsed.data, caller.actor, body.key);
|
|
11137
|
+
const result = await (options.runOperation === void 0 ? dispatch() : options.runOperation(operation.id, parsed.data, dispatch));
|
|
11138
|
+
await options.afterOperation?.(reply.raw);
|
|
11139
|
+
return reply.send(successEnvelopeSchema.parse({
|
|
11140
|
+
ok: true,
|
|
11141
|
+
requestId: request.id,
|
|
11142
|
+
value: result
|
|
11143
|
+
}));
|
|
11144
|
+
});
|
|
11145
|
+
}
|
|
11146
|
+
//#endregion
|
|
11071
11147
|
//#region ../core/src/api/identity.ts
|
|
11072
11148
|
function sessionActor(project, session, config) {
|
|
11073
11149
|
const actor = actorIdSchema.safeParse(`agent:${project}/${session}`);
|
|
@@ -11126,15 +11202,6 @@ const skillReloadsSchema = z.strictObject({
|
|
|
11126
11202
|
function header(value) {
|
|
11127
11203
|
return Array.isArray(value) ? void 0 : value;
|
|
11128
11204
|
}
|
|
11129
|
-
function inputBody(body) {
|
|
11130
|
-
if (body === null || typeof body !== "object" || Array.isArray(body)) throw new CommandError("usage", "Send a JSON object with input and optional key.");
|
|
11131
|
-
const record = body;
|
|
11132
|
-
if (!Object.hasOwn(record, "input") || Object.keys(record).some((name) => name !== "input" && name !== "key") || record["key"] !== void 0 && typeof record["key"] !== "string") throw new CommandError("usage", "Send a JSON object with input and optional key.");
|
|
11133
|
-
return {
|
|
11134
|
-
input: record["input"],
|
|
11135
|
-
key: record["key"]
|
|
11136
|
-
};
|
|
11137
|
-
}
|
|
11138
11205
|
/** Construct the local HTTP transport; the caller owns listen and close. */
|
|
11139
11206
|
async function createApiServer(options) {
|
|
11140
11207
|
const app = Fastify({
|
|
@@ -11172,29 +11239,7 @@ async function createApiServer(options) {
|
|
|
11172
11239
|
});
|
|
11173
11240
|
done();
|
|
11174
11241
|
});
|
|
11175
|
-
app
|
|
11176
|
-
let code = "unexpected";
|
|
11177
|
-
let hint;
|
|
11178
|
-
if (error instanceof CommandError) {
|
|
11179
|
-
code = error.code;
|
|
11180
|
-
hint = error.hint;
|
|
11181
|
-
} else if (error instanceof Error && "statusCode" in error) {
|
|
11182
|
-
if (error.statusCode === 400 || error.statusCode === 413) code = "usage";
|
|
11183
|
-
if (error.statusCode === 413) hint = "Send a smaller JSON body.";
|
|
11184
|
-
}
|
|
11185
|
-
if (code === "unexpected") options.logError?.({
|
|
11186
|
-
requestId: request.id,
|
|
11187
|
-
err: error
|
|
11188
|
-
});
|
|
11189
|
-
const problem = renderHttpProblem({
|
|
11190
|
-
code,
|
|
11191
|
-
requestId: request.id
|
|
11192
|
-
});
|
|
11193
|
-
reply.code(problem.status).type("application/problem+json").send(hint === void 0 ? problem.body : {
|
|
11194
|
-
...problem.body,
|
|
11195
|
-
hint
|
|
11196
|
-
});
|
|
11197
|
-
});
|
|
11242
|
+
installOperationErrors(app, options);
|
|
11198
11243
|
app.setNotFoundHandler(() => {
|
|
11199
11244
|
throw new CommandError("not_found", "This API route is not available.");
|
|
11200
11245
|
});
|
|
@@ -11279,31 +11324,17 @@ async function createApiServer(options) {
|
|
|
11279
11324
|
}
|
|
11280
11325
|
}));
|
|
11281
11326
|
});
|
|
11282
|
-
app
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
const operation = OPERATIONS.find((entry) => entry.id === request.params.id);
|
|
11294
|
-
if (operation === void 0) throw new CommandError("version_mismatch", "This daemon does not know the operation. Run `board service restart` to update the daemon, then retry.");
|
|
11295
|
-
const body = inputBody(request.body);
|
|
11296
|
-
const parsed = operation.input.safeParse(body.input);
|
|
11297
|
-
if (!parsed.success) throw new CommandError(errorCodeOf(parsed.error), "Fix the operation input.");
|
|
11298
|
-
const dispatch = () => dispatchOperation(options, operation.id, parsed.data, caller.actor, body.key);
|
|
11299
|
-
const result = await (options.runOperation === void 0 ? dispatch() : options.runOperation(operation.id, parsed.data, dispatch));
|
|
11300
|
-
await options.afterOperation?.(reply.raw);
|
|
11301
|
-
return reply.send(successEnvelopeSchema.parse({
|
|
11302
|
-
ok: true,
|
|
11303
|
-
requestId: request.id,
|
|
11304
|
-
value: result
|
|
11305
|
-
}));
|
|
11306
|
-
});
|
|
11327
|
+
createOpsRoute(app, {
|
|
11328
|
+
...options,
|
|
11329
|
+
identify: async (request) => {
|
|
11330
|
+
const sessionHeader = request.headers["x-board-session"];
|
|
11331
|
+
if (Array.isArray(sessionHeader)) throw new CommandError("forbidden", "Use one session identity header.");
|
|
11332
|
+
return identifyCaller(options, {
|
|
11333
|
+
session: sessionHeader,
|
|
11334
|
+
authorization: header(request.headers.authorization)
|
|
11335
|
+
});
|
|
11336
|
+
}
|
|
11337
|
+
}, callers);
|
|
11307
11338
|
return app;
|
|
11308
11339
|
}
|
|
11309
11340
|
/** The only supported listener for the local API. */
|
|
@@ -16674,10 +16705,12 @@ function createTaskQueries(deps) {
|
|
|
16674
16705
|
const events = (await trx.selectFrom("event").selectAll().where("task_id", "=", task.id).orderBy("id").execute()).flatMap((row) => {
|
|
16675
16706
|
const kind = EVENT_KINDS.find((candidate) => candidate === row.kind);
|
|
16676
16707
|
if (kind === void 0) return [];
|
|
16708
|
+
const via = VIAS.find((value) => value === row.via);
|
|
16677
16709
|
return [{
|
|
16678
16710
|
at: row.at,
|
|
16679
16711
|
kind,
|
|
16680
16712
|
actor: eventActor(row),
|
|
16713
|
+
...via === void 0 ? {} : { via },
|
|
16681
16714
|
summary: linkOrEscalationSummary(kind, row.payload) ?? shadowSummary(kind, row.payload) ?? submitSummary(kind, row.payload) ?? turnSummary(kind, row.payload) ?? EVENT_SUMMARIES[kind]
|
|
16682
16715
|
}];
|
|
16683
16716
|
});
|
|
@@ -18766,22 +18799,24 @@ function createInbound(input) {
|
|
|
18766
18799
|
return { status: "applied" };
|
|
18767
18800
|
}
|
|
18768
18801
|
async function reapply(trx, itemId, at) {
|
|
18769
|
-
|
|
18770
|
-
|
|
18771
|
-
|
|
18772
|
-
|
|
18773
|
-
|
|
18774
|
-
|
|
18775
|
-
|
|
18776
|
-
|
|
18777
|
-
|
|
18778
|
-
|
|
18779
|
-
|
|
18780
|
-
|
|
18781
|
-
|
|
18782
|
-
|
|
18783
|
-
|
|
18784
|
-
|
|
18802
|
+
await withVia("slack", async () => {
|
|
18803
|
+
const item = await trx.selectFrom("operator_item").selectAll().where("id", "=", itemId).executeTakeFirst();
|
|
18804
|
+
if (item === void 0 || item.cleared_at !== null || item.inbound_event_json === null) throw new CommandError("retry_not_applicable", "This item has no stored event to retry.");
|
|
18805
|
+
const event = parseJson(inboundEventSchema, item.inbound_event_json);
|
|
18806
|
+
if (event.kind === "gap" || event.kind === "connection") throw new CommandError("retry_not_applicable", "This event cannot be retried.");
|
|
18807
|
+
if (event.kind === "command" || event.kind === "action") {
|
|
18808
|
+
await reapplyInteraction(trx, event, at);
|
|
18809
|
+
return;
|
|
18810
|
+
}
|
|
18811
|
+
await replayOperation(trx, {
|
|
18812
|
+
actor: event.kind === "message_deleted" || event.author === config.operator.slack ? "operator" : "system",
|
|
18813
|
+
key: event.dedupeKey,
|
|
18814
|
+
operation: operationId(event),
|
|
18815
|
+
fingerprintInput: event,
|
|
18816
|
+
output: resultSchema,
|
|
18817
|
+
at,
|
|
18818
|
+
run: () => runUser(trx, event, at)
|
|
18819
|
+
});
|
|
18785
18820
|
});
|
|
18786
18821
|
}
|
|
18787
18822
|
/**
|
|
@@ -19068,46 +19103,50 @@ function createInbound(input) {
|
|
|
19068
19103
|
} catch {}
|
|
19069
19104
|
}
|
|
19070
19105
|
async function applyUser(event) {
|
|
19071
|
-
|
|
19072
|
-
|
|
19073
|
-
|
|
19074
|
-
|
|
19075
|
-
|
|
19076
|
-
|
|
19077
|
-
|
|
19078
|
-
|
|
19079
|
-
|
|
19080
|
-
|
|
19081
|
-
|
|
19082
|
-
|
|
19083
|
-
|
|
19084
|
-
|
|
19085
|
-
|
|
19086
|
-
|
|
19087
|
-
|
|
19088
|
-
|
|
19089
|
-
|
|
19090
|
-
|
|
19091
|
-
|
|
19092
|
-
|
|
19106
|
+
await withVia("slack", async () => {
|
|
19107
|
+
if ((event.kind === "command" || event.kind === "action") && event.author === config.operator.slack && (event.kind !== "command" || event.name === void 0 || event.name === config.slack.command) && (event.kind === "command" || event.sourceSpace !== null)) {
|
|
19108
|
+
await dispatchInteraction(event);
|
|
19109
|
+
return;
|
|
19110
|
+
}
|
|
19111
|
+
const at = new Date(clock.now()).toISOString();
|
|
19112
|
+
const actor = event.kind === "message_deleted" || event.author === config.operator.slack ? "operator" : "system";
|
|
19113
|
+
try {
|
|
19114
|
+
const result = await scanTransaction(store, config, (trx) => replayOperation(trx, {
|
|
19115
|
+
actor,
|
|
19116
|
+
key: event.dedupeKey,
|
|
19117
|
+
operation: operationId(event),
|
|
19118
|
+
fingerprintInput: event,
|
|
19119
|
+
output: resultSchema,
|
|
19120
|
+
at,
|
|
19121
|
+
run: () => runUser(trx, event, at)
|
|
19122
|
+
}));
|
|
19123
|
+
if (result?.response !== void 0 && "interaction" in event) try {
|
|
19124
|
+
await gateway.respond(event.interaction, plain$1(result.response), { private: true });
|
|
19125
|
+
} catch {}
|
|
19126
|
+
} catch (error) {
|
|
19127
|
+
await recordFailure(event, error, at);
|
|
19128
|
+
}
|
|
19129
|
+
});
|
|
19093
19130
|
}
|
|
19094
19131
|
async function applyGap(event) {
|
|
19095
|
-
|
|
19096
|
-
|
|
19097
|
-
|
|
19098
|
-
|
|
19099
|
-
|
|
19100
|
-
|
|
19101
|
-
|
|
19102
|
-
|
|
19103
|
-
|
|
19104
|
-
|
|
19105
|
-
|
|
19106
|
-
|
|
19107
|
-
|
|
19108
|
-
|
|
19109
|
-
|
|
19110
|
-
|
|
19132
|
+
await withVia("slack", async () => {
|
|
19133
|
+
const at = new Date(clock.now()).toISOString();
|
|
19134
|
+
await scanTransaction(store, config, async (trx) => {
|
|
19135
|
+
const context = await taskContext(trx, event, gateway.kind);
|
|
19136
|
+
const conversation = event.conversation === void 0 ? void 0 : await trx.selectFrom("conversation").select(["root_message_ref"]).where("gateway", "=", gateway.kind).where("ref", "=", event.conversation).executeTakeFirst();
|
|
19137
|
+
const opened = conversation === void 0 ? void 0 : await trx.selectFrom("outbox").select(["id", "external_ref"]).where("kind", "=", "conversation.open").where("state", "=", "done").where(sql`json_extract(external_ref, '$.message')`, "=", conversation.root_message_ref).orderBy("id", "desc").executeTakeFirst();
|
|
19138
|
+
const parsed = opened?.external_ref === null || opened?.external_ref === void 0 ? void 0 : deliveredRefSchema.safeParse(JSON.parse(opened.external_ref));
|
|
19139
|
+
if (opened !== void 0 && parsed?.success === false) warnSkipped("outbox", "external_ref", opened.id, parsed.error);
|
|
19140
|
+
const ref = parsed?.data;
|
|
19141
|
+
await raiseInboundItem(trx, {
|
|
19142
|
+
sourceKey: `inbound:gap:${createHash("sha256").update(JSON.stringify([gateway.kind, event.conversation ?? null])).digest("hex")}`,
|
|
19143
|
+
title: "repeat your answer",
|
|
19144
|
+
sourceUrl: ref?.permalink ?? null,
|
|
19145
|
+
event,
|
|
19146
|
+
taskId: context.taskId,
|
|
19147
|
+
at,
|
|
19148
|
+
retry: false
|
|
19149
|
+
});
|
|
19111
19150
|
});
|
|
19112
19151
|
});
|
|
19113
19152
|
}
|
|
@@ -19291,6 +19330,132 @@ function createInbound(input) {
|
|
|
19291
19330
|
};
|
|
19292
19331
|
}
|
|
19293
19332
|
//#endregion
|
|
19333
|
+
//#region ../core/src/api/web-server.ts
|
|
19334
|
+
const mime = {
|
|
19335
|
+
".html": "text/html; charset=utf-8",
|
|
19336
|
+
".js": "text/javascript; charset=utf-8",
|
|
19337
|
+
".css": "text/css; charset=utf-8",
|
|
19338
|
+
".json": "application/json",
|
|
19339
|
+
".svg": "image/svg+xml",
|
|
19340
|
+
".png": "image/png",
|
|
19341
|
+
".ico": "image/x-icon",
|
|
19342
|
+
".woff2": "font/woff2",
|
|
19343
|
+
".webp": "image/webp"
|
|
19344
|
+
};
|
|
19345
|
+
async function loadFiles(root) {
|
|
19346
|
+
const files = /* @__PURE__ */ new Map();
|
|
19347
|
+
async function walk(dir, prefix) {
|
|
19348
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
19349
|
+
const path = typeof dir === "string" ? join(dir, entry.name) : new URL(entry.name + (entry.isDirectory() ? "/" : ""), dir);
|
|
19350
|
+
const key = `${prefix}/${entry.name}`;
|
|
19351
|
+
if (entry.isDirectory()) await walk(path, key);
|
|
19352
|
+
else if (entry.isFile()) files.set(key, await readFile(path));
|
|
19353
|
+
}
|
|
19354
|
+
}
|
|
19355
|
+
try {
|
|
19356
|
+
await walk(root, "");
|
|
19357
|
+
} catch (err) {
|
|
19358
|
+
if (!(err instanceof Error && "code" in err && (err.code === "ENOENT" || err.code === "ENOTDIR"))) throw err;
|
|
19359
|
+
files.clear();
|
|
19360
|
+
}
|
|
19361
|
+
return files;
|
|
19362
|
+
}
|
|
19363
|
+
/** Independent browser transport; the caller owns listening and shutdown. */
|
|
19364
|
+
async function createWebServer(options) {
|
|
19365
|
+
const files = await loadFiles(options.webRoot);
|
|
19366
|
+
const app = Fastify({
|
|
19367
|
+
logger: false,
|
|
19368
|
+
genReqId: () => randomUUID(),
|
|
19369
|
+
trustProxy: false,
|
|
19370
|
+
frameworkErrors(error, request, reply) {
|
|
19371
|
+
secure(reply);
|
|
19372
|
+
reply.raw.once("finish", () => {
|
|
19373
|
+
audit(request, reply);
|
|
19374
|
+
});
|
|
19375
|
+
try {
|
|
19376
|
+
guard(request, reply);
|
|
19377
|
+
} catch (err) {
|
|
19378
|
+
errorHandler(err, request, reply);
|
|
19379
|
+
return;
|
|
19380
|
+
}
|
|
19381
|
+
errorHandler(error.code === "FST_ERR_MAX_PARAM_LENGTH" ? new CommandError("usage", "Use a shorter web path.") : error, request, reply);
|
|
19382
|
+
}
|
|
19383
|
+
});
|
|
19384
|
+
const errorHandler = installOperationErrors(app, options);
|
|
19385
|
+
function guard(request, reply) {
|
|
19386
|
+
reply.header("x-request-id", request.id);
|
|
19387
|
+
const address = app.server.address();
|
|
19388
|
+
const origin = resolveWebOrigin(options.config.web, address !== null && typeof address === "object" ? address.port : void 0);
|
|
19389
|
+
if (origin === void 0 || request.headers.host !== new URL(origin).host) throw new CommandError("forbidden", "Use the configured web host.");
|
|
19390
|
+
if (request.headers["sec-fetch-site"] === "cross-site") throw new CommandError("forbidden", "Cross-site requests are not accepted.");
|
|
19391
|
+
if (request.method !== "GET" && request.method !== "HEAD" && request.headers.origin !== origin) throw new CommandError("forbidden", "Use the configured web origin.");
|
|
19392
|
+
if (request.method === "POST" && request.headers["content-type"]?.split(";", 1)[0]?.trim().toLowerCase() !== "application/json") throw new CommandError("forbidden", "Use application/json.");
|
|
19393
|
+
const rawPath = request.raw.url?.split("?", 1)[0] ?? "";
|
|
19394
|
+
let decoded;
|
|
19395
|
+
try {
|
|
19396
|
+
decoded = decodeURIComponent(rawPath);
|
|
19397
|
+
} catch {
|
|
19398
|
+
throw new CommandError("not_found", "Invalid web path.");
|
|
19399
|
+
}
|
|
19400
|
+
if (decoded.split(/[\\/]/).some((part) => part === ".." || part === ".")) throw new CommandError("not_found", "Invalid web path.");
|
|
19401
|
+
}
|
|
19402
|
+
function secure(reply) {
|
|
19403
|
+
reply.header("content-security-policy", "default-src 'self'; frame-ancestors 'none'");
|
|
19404
|
+
reply.header("x-frame-options", "DENY");
|
|
19405
|
+
reply.header("x-content-type-options", "nosniff");
|
|
19406
|
+
reply.header("referrer-policy", "no-referrer");
|
|
19407
|
+
}
|
|
19408
|
+
function audit(request, reply) {
|
|
19409
|
+
const forwardedFor = request.headers["x-forwarded-for"];
|
|
19410
|
+
const userAgent = request.headers["user-agent"];
|
|
19411
|
+
options.logRequest({
|
|
19412
|
+
requestId: request.id,
|
|
19413
|
+
method: request.method,
|
|
19414
|
+
path: request.url.split("?", 1)[0] ?? "/",
|
|
19415
|
+
status: reply.statusCode,
|
|
19416
|
+
via: "web",
|
|
19417
|
+
...typeof forwardedFor === "string" ? { forwardedFor } : {},
|
|
19418
|
+
...userAgent === void 0 ? {} : { userAgent }
|
|
19419
|
+
});
|
|
19420
|
+
}
|
|
19421
|
+
app.addHook("onRequest", async (request, reply) => {
|
|
19422
|
+
guard(request, reply);
|
|
19423
|
+
});
|
|
19424
|
+
app.addHook("onSend", async (_request, reply) => {
|
|
19425
|
+
secure(reply);
|
|
19426
|
+
});
|
|
19427
|
+
app.addHook("onResponse", (request, reply, done) => {
|
|
19428
|
+
audit(request, reply);
|
|
19429
|
+
done();
|
|
19430
|
+
});
|
|
19431
|
+
createOpsRoute(app, {
|
|
19432
|
+
...options,
|
|
19433
|
+
identify: () => Promise.resolve({ actor: "operator" }),
|
|
19434
|
+
allow: (operation) => operation.web !== null,
|
|
19435
|
+
runOperation: (id, input, run) => withVia("web", () => options.runOperation === void 0 ? run() : options.runOperation(id, input, run))
|
|
19436
|
+
});
|
|
19437
|
+
app.get("/v1/health", async () => {
|
|
19438
|
+
if (!options.ready()) throw new CommandError(options.stopping?.() === true ? "stopping" : "starting", "Wait until the daemon is ready.");
|
|
19439
|
+
if (options.firstPollDone === void 0) throw new CommandError("not_found", "Health is unavailable.");
|
|
19440
|
+
return { firstPollDone: await options.firstPollDone() };
|
|
19441
|
+
});
|
|
19442
|
+
app.setNotFoundHandler(async (request, reply) => {
|
|
19443
|
+
const path = request.url.split("?", 1)[0] ?? "/";
|
|
19444
|
+
if (request.method !== "GET" && request.method !== "HEAD" || path === "/v1" || path.startsWith("/v1/")) throw new CommandError("not_found", "This web route is not available.");
|
|
19445
|
+
const key = path === "/" ? "/index.html" : path;
|
|
19446
|
+
const file = key === "/index.html" || path.startsWith("/assets/") ? files.get(key) : void 0;
|
|
19447
|
+
const fallback = extname(path) === "" ? files.get("/index.html") : void 0;
|
|
19448
|
+
if (file === void 0 && fallback === void 0) {
|
|
19449
|
+
if (!files.has("/index.html")) return reply.code(503).type("text/html").send("UI is not built: run `pnpm --filter @spur-board/web build`");
|
|
19450
|
+
throw new CommandError("not_found", "This web asset is not available.");
|
|
19451
|
+
}
|
|
19452
|
+
const index = key === "/index.html" || file === void 0;
|
|
19453
|
+
reply.header("cache-control", index ? "no-cache" : /[.-][a-z0-9_-]{8,}\.[^.]+$/i.test(key) ? "public, max-age=31536000, immutable" : "no-cache");
|
|
19454
|
+
return reply.type(index ? "text/html; charset=utf-8" : mime[extname(key)] ?? "application/octet-stream").send(request.method === "HEAD" ? void 0 : file ?? fallback);
|
|
19455
|
+
});
|
|
19456
|
+
return app;
|
|
19457
|
+
}
|
|
19458
|
+
//#endregion
|
|
19294
19459
|
//#region ../daemon/src/config.ts
|
|
19295
19460
|
/** A config or secrets file the daemon cannot use. The message is meant for the operator. */
|
|
19296
19461
|
var ConfigError = class extends Error {
|
|
@@ -24531,9 +24696,10 @@ async function slackBody(response, wire) {
|
|
|
24531
24696
|
}
|
|
24532
24697
|
}
|
|
24533
24698
|
/** Bounded daemon-side checks; no response body or exception text leaves this module. */
|
|
24534
|
-
async function runDaemonDoctor(ctx, productVersion, fetcher = fetch, { deadlineMs = DEADLINE_MS } = {}) {
|
|
24699
|
+
async function runDaemonDoctor(ctx, productVersion, fetcher = fetch, { deadlineMs = DEADLINE_MS, webListening } = {}) {
|
|
24535
24700
|
const { config, secrets } = ctx;
|
|
24536
24701
|
const checks = [];
|
|
24702
|
+
if (config.web.port !== void 0) checks.push(check("web.listening", webListening?.() === true, "Free the configured web port and restart the daemon."));
|
|
24537
24703
|
const jiraTrackers = config.projects.flatMap((project) => project.tracker.type === "jira" ? [project.tracker] : []);
|
|
24538
24704
|
const slackConfigured = Boolean(config.slack.channels.feed || config.slack.channels.orchestrators);
|
|
24539
24705
|
const linkSamples = sampleLinks(ctx, fetcher, deadlineMs, secrets["GITHUB_TOKEN"]);
|
|
@@ -24654,7 +24820,7 @@ function createHttpModule(ctx, options = {}) {
|
|
|
24654
24820
|
registry: options.registry ?? {},
|
|
24655
24821
|
...options.afterOperation === void 0 ? {} : { afterOperation: options.afterOperation },
|
|
24656
24822
|
...options.runOperation === void 0 ? {} : { runOperation: options.runOperation },
|
|
24657
|
-
doctor: options.doctor ?? (() => runDaemonDoctor(ctx, options.productVersion ?? "unknown", options.fetcher)),
|
|
24823
|
+
doctor: options.doctor ?? (() => runDaemonDoctor(ctx, options.productVersion ?? "unknown", options.fetcher, { webListening: options.webListening })),
|
|
24658
24824
|
...options.firstPollDone === void 0 ? {} : { firstPollDone: options.firstPollDone },
|
|
24659
24825
|
...options.productVersion === void 0 ? {} : { productVersion: options.productVersion },
|
|
24660
24826
|
logRequest: ({ requestId, method, url, status, tokenName }) => {
|
|
@@ -24692,6 +24858,62 @@ function createHttpModule(ctx, options = {}) {
|
|
|
24692
24858
|
}
|
|
24693
24859
|
};
|
|
24694
24860
|
}
|
|
24861
|
+
/** Optional browser listener: a bind failure must not take down the agent API. */
|
|
24862
|
+
function createWebModule(ctx, options) {
|
|
24863
|
+
let app;
|
|
24864
|
+
return {
|
|
24865
|
+
listening: () => app !== void 0,
|
|
24866
|
+
async start(signal) {
|
|
24867
|
+
const aborted = () => signal.aborted;
|
|
24868
|
+
if (aborted()) return;
|
|
24869
|
+
let server;
|
|
24870
|
+
try {
|
|
24871
|
+
server = await createWebServer({
|
|
24872
|
+
store: ctx.store,
|
|
24873
|
+
config: ctx.config,
|
|
24874
|
+
clock: ctx.clock,
|
|
24875
|
+
registry: options.registry,
|
|
24876
|
+
ready: () => ctx.state() === "ready",
|
|
24877
|
+
stopping: () => ctx.state() === "stopping",
|
|
24878
|
+
...options.runOperation === void 0 ? {} : { runOperation: options.runOperation },
|
|
24879
|
+
...options.afterOperation === void 0 ? {} : { afterOperation: options.afterOperation },
|
|
24880
|
+
...options.firstPollDone === void 0 ? {} : { firstPollDone: options.firstPollDone },
|
|
24881
|
+
webRoot: options.webRoot ?? new URL("./web/", import.meta.url),
|
|
24882
|
+
logRequest: (entry) => {
|
|
24883
|
+
ctx.log.info(entry, "web request");
|
|
24884
|
+
},
|
|
24885
|
+
logError: ({ requestId, err }) => {
|
|
24886
|
+
ctx.log.error({
|
|
24887
|
+
requestId,
|
|
24888
|
+
err
|
|
24889
|
+
}, "web request failed");
|
|
24890
|
+
}
|
|
24891
|
+
});
|
|
24892
|
+
if (aborted()) return;
|
|
24893
|
+
const address = await server.listen({
|
|
24894
|
+
host: "127.0.0.1",
|
|
24895
|
+
port: ctx.config.web.port ?? 0
|
|
24896
|
+
});
|
|
24897
|
+
if (aborted()) return;
|
|
24898
|
+
options.onListening?.(address);
|
|
24899
|
+
app = server;
|
|
24900
|
+
ctx.log.info({ port: Number(new URL(address).port) }, "web listening");
|
|
24901
|
+
} catch (err) {
|
|
24902
|
+
ctx.log.error({
|
|
24903
|
+
err,
|
|
24904
|
+
port: ctx.config.web.port
|
|
24905
|
+
}, "web listener failed");
|
|
24906
|
+
} finally {
|
|
24907
|
+
if (server !== void 0 && app !== server) await server.close();
|
|
24908
|
+
}
|
|
24909
|
+
},
|
|
24910
|
+
async stop() {
|
|
24911
|
+
const server = app;
|
|
24912
|
+
app = void 0;
|
|
24913
|
+
await server?.close();
|
|
24914
|
+
}
|
|
24915
|
+
};
|
|
24916
|
+
}
|
|
24695
24917
|
//#endregion
|
|
24696
24918
|
//#region ../daemon/src/inbound-module.ts
|
|
24697
24919
|
const RECOVERY_MS = 5 * 6e4;
|
|
@@ -25041,12 +25263,27 @@ function createDaemonModules(ctxFor, ports = {}) {
|
|
|
25041
25263
|
stopStage: "outbox",
|
|
25042
25264
|
module: outbox
|
|
25043
25265
|
});
|
|
25266
|
+
const runOperation = (id, input, run) => id === "item.retry" && inbound !== void 0 && isItemInput(input) ? inbound.retrying(input.item, run) : run();
|
|
25267
|
+
const web = board.config.web.port === void 0 ? void 0 : createWebModule(ctxFor("web"), {
|
|
25268
|
+
registry,
|
|
25269
|
+
runOperation,
|
|
25270
|
+
firstPollDone: () => firstPollDone(board.store.db, board.config, core.completeSince),
|
|
25271
|
+
...ports.afterOperation === void 0 ? {} : { afterOperation: ports.afterOperation },
|
|
25272
|
+
...ports.webRoot === void 0 ? {} : { webRoot: ports.webRoot },
|
|
25273
|
+
...ports.onWebListening === void 0 ? {} : { onListening: ports.onWebListening }
|
|
25274
|
+
});
|
|
25275
|
+
if (web !== void 0) entries.push({
|
|
25276
|
+
name: "web",
|
|
25277
|
+
stopStage: "final",
|
|
25278
|
+
module: web
|
|
25279
|
+
});
|
|
25044
25280
|
entries.push({
|
|
25045
25281
|
name: "http",
|
|
25046
25282
|
stopStage: "final",
|
|
25047
25283
|
module: createHttpModule(ctxFor("http"), {
|
|
25048
25284
|
registry,
|
|
25049
|
-
runOperation
|
|
25285
|
+
runOperation,
|
|
25286
|
+
webListening: () => web?.listening() === true,
|
|
25050
25287
|
firstPollDone: () => firstPollDone(board.store.db, board.config, core.completeSince),
|
|
25051
25288
|
...ports.productVersion === void 0 ? {} : { productVersion: ports.productVersion },
|
|
25052
25289
|
...ports.sessionFetcher === void 0 ? {} : { fetcher: ports.sessionFetcher },
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Q as ERRORS, _ as renderMcpError, p as OPERATIONS } from "./chunk-
|
|
2
|
-
import { o as CliError, r as requestOperation } from "./chunk-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-
|
|
1
|
+
import { Q as ERRORS, _ as renderMcpError, p as OPERATIONS } from "./chunk-BEExLWBt.mjs";
|
|
2
|
+
import { o as CliError, r as requestOperation } from "./chunk-BSs9OrJD.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-CFvX6Mf9.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|
package/package.json
CHANGED
package/skills/setup/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ description: Install, configure, check, and update spur-board with an operator.
|
|
|
5
5
|
|
|
6
6
|
# Set up spur-board
|
|
7
7
|
|
|
8
|
-
Ask one question at a time
|
|
8
|
+
Ask one question at a time when inspection cannot answer it. Check before writing. Ask before changing package, config, secret, service, token, skill-folder, or project-checkout state, or enabling lingering. Never show secret values or put them in chat, logs, or shell history. A same-version rerun changes nothing and repeats no answered question. Never uninstall the service or revoke a token without an explicit operator request.
|
|
9
9
|
|
|
10
10
|
## 1. Inspect
|
|
11
11
|
|
|
@@ -17,20 +17,21 @@ Ask one question at a time, only when current state cannot answer it. Check befo
|
|
|
17
17
|
## 2. Install the package
|
|
18
18
|
|
|
19
19
|
- Check whether the required package version and `board` binary are visible on the live session PATH. If current, skip installation.
|
|
20
|
-
- Otherwise choose a user npm prefix
|
|
20
|
+
- Otherwise choose a user npm prefix with `bin` on that PATH, often `$HOME/.local`; use the live session's Node and npm for `npm i -g --prefix <prefix> spur-board`. Verify `board --version` with the session PATH.
|
|
21
21
|
|
|
22
22
|
## 3. Complete missing configuration
|
|
23
23
|
|
|
24
|
-
- Discover repositories, Spur projects, and GitHub logins where possible.
|
|
24
|
+
- Discover repositories, Spur projects, and GitHub logins where possible. Ask and write only unset values: Jira filter and statuses if used, repositories, project names and roles, the GitHub login agents open PRs under per project (PR discovery filters by it; not always the operator's), and the operator's Slack user ID. Preserve settled and unrelated fields; validate against the shipped config schema.
|
|
25
25
|
- If Slack roles are unset, follow [Slack setup](references/slack.md). List channels visible to the bot and ask which serve orchestrators and feed; store their IDs. The bot sees only private channels it joined.
|
|
26
26
|
- Check required secret names and permissions. Follow [secret files](references/secrets.md) for private entry and any existing `slack.env` migration. Write `config.yaml` and a regular mode `0600` `secrets.env` only when needed.
|
|
27
27
|
- For a `github-issues` project, follow [worker links](references/worker-links.md).
|
|
28
|
-
-
|
|
28
|
+
- For browser access, follow [web setup](references/web.md); check `web.listening`.
|
|
29
|
+
- After config edits, run `board doctor --offline` and apply its config fixes. Offline checks do not prove service or integration readiness.
|
|
29
30
|
|
|
30
31
|
## 4. Start service and grant access
|
|
31
32
|
|
|
32
33
|
- 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
|
|
34
|
+
- If operator access is unset, ask whether to use a Spur project marked `operator`, without a token, or an outside-Spur session rooted in a chosen folder inside its git worktree if any, never above it. If no valid token exists, run `board token create --name <name> --into <folder>`, then have the operator approve the Slack prompt with its `requestHash`. Check existing agent registration before registering `board mcp`.
|
|
34
35
|
- 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
36
|
- 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
37
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Optional browser access
|
|
2
|
+
|
|
3
|
+
Web is off by default. Enable it only on a private network limited to the operator's devices.
|
|
4
|
+
Anyone reaching the port can run web-bound reads and the two writes, `comment.add` and
|
|
5
|
+
`block.answer`, as operator without a token. Browser Host/Origin checks do not authenticate
|
|
6
|
+
network members or local OS users.
|
|
7
|
+
|
|
8
|
+
Set `web.port` and `web.publicOrigin` together in config.yaml:
|
|
9
|
+
|
|
10
|
+
```yaml
|
|
11
|
+
web:
|
|
12
|
+
port: 7777
|
|
13
|
+
publicOrigin: https://{port}.local.example
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The listener binds `127.0.0.1`. Configure a reverse proxy to preserve the original Host and
|
|
17
|
+
use the exact resolved public origin. Every `{port}` is replaced with the actual listener port.
|
|
18
|
+
After restarting the daemon, run `board doctor --json`: `web` checks the configuration and
|
|
19
|
+
`web.listening` checks whether the listener bound. A busy port leaves the agent API running;
|
|
20
|
+
free it or choose another web port and restart.
|
|
21
|
+
|
|
22
|
+
A missing UI build returns 503 with
|
|
23
|
+
``UI is not built: run `pnpm --filter @spur-board/web build` ``.
|
|
24
|
+
Run that build when the UI package is available. Health and catalog operations remain usable.
|
|
25
|
+
The listener does not supply the SPA. Request logs record the web channel and untrusted
|
|
26
|
+
forwarded client metadata and user agent. Journal events and history retain `via: web` beside
|
|
27
|
+
the operator actor.
|
|
@@ -23,6 +23,8 @@ a message already accepted by Spur cannot be retracted. Check `board inbox` and
|
|
|
23
23
|
act only on a current turn; reread after `turn_closed`.
|
|
24
24
|
Task history (`board task history <task>`) shows journal events `turn_opened`,
|
|
25
25
|
`turn_taken` and `turn_closed`: executor, taker, outcome.
|
|
26
|
+
Each event names who acted and, for a write that arrived through Slack, its
|
|
27
|
+
channel (`via`); CLI, MCP, agent and scheduled writes have none.
|
|
26
28
|
|
|
27
29
|
Open-turn executors in `needs_input`, `error`, `rate_limited` or `stopped` raise
|
|
28
30
|
one question after `health.turnStallAfterMs` (default 600000): curator unless self, else
|
|
@@ -31,3 +31,19 @@ URLs (also before observation), and effective session IDs. Banned links are excl
|
|
|
31
31
|
session navigation. This replaces the former detail-only association array; use `board task PROJ-123`
|
|
32
32
|
for the detailed association list. `board status --detail` adds full ticket, PR and session facts.
|
|
33
33
|
The catalog version changes with these contracts; restart the daemon and live MCP sessions together.
|
|
34
|
+
|
|
35
|
+
## Browser access
|
|
36
|
+
|
|
37
|
+
With `web.port` and `web.publicOrigin` configured, a second loopback listener serves browser
|
|
38
|
+
assets, health and catalog operations whose `web` binding is enabled. It uses the same registry,
|
|
39
|
+
authorization, idempotency and operation hooks as the agent API, with the operator caller.
|
|
40
|
+
Effective project configuration is available through `config.get`.
|
|
41
|
+
Only `comment.add` and `block.answer` are enabled writes. Token and skill routes stay on the
|
|
42
|
+
agent API. The web listener is off by default and a failed bind does not stop the agent API.
|
|
43
|
+
|
|
44
|
+
A private-network proxy must preserve Host. Exact Origin, Host, JSON and fetch-metadata checks
|
|
45
|
+
reject foreign browser pages; anyone with network or local access can still act as operator.
|
|
46
|
+
Logs include the web channel and untrusted forwarded client/user-agent metadata. Web writes
|
|
47
|
+
persist `via: web` in the journal; history returns `actor: operator` with `via: web`, allowing
|
|
48
|
+
clients to show `operator (web)`.
|
|
49
|
+
Missing UI assets return a 503 build hint while health and operations remain available.
|