spur-board 0.46.1 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { Q as requiredSecretKeys, X as configSchema, l as roleCanUseOperation, r as SYSTEMD_SERVICE_SETTINGS, tt as SLACK_BOT_SCOPES, u as OPERATIONS, z as ERRORS } from "./src-DfgP2kkK.mjs";
2
- import { a as CliError, c as escapeTerminalControls, i as requestTokenEnrollment, n as fetchTokenStatus, o as errorExitCode, r as requestOperation, s as renderCliError } from "./client-Rpyht8rc.mjs";
3
- 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 "./config-RyoKekR8.mjs";
1
+ import { $ as configSchema, H as ERRORS, f as roleCanUseOperation, it as SLACK_BOT_SCOPES, o as SYSTEMD_SERVICE_SETTINGS, p as OPERATIONS, r as requestHashOf, tt as requiredSecretKeys } from "./src-DGT9Wspi.mjs";
2
+ import { a as CliError, c as escapeTerminalControls, i as requestTokenEnrollment, n as fetchTokenStatus, o as errorExitCode, r as requestOperation, s as renderCliError } from "./client-D8BEfeGz.mjs";
3
+ 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 "./config-Chv5ZHE8.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";
@@ -2262,7 +2262,7 @@ function createProgram(options = {}) {
2262
2262
  }
2263
2263
  const create = commandFor(program, "token create");
2264
2264
  create.description("Request approval for a new token in a chosen folder.");
2265
- create.requiredOption("--name <name>", "Unique token name.");
2265
+ create.requiredOption("--name <name>", "Unique token name: 1-64 letters, digits, \".\", \"_\" or \"-\".");
2266
2266
  create.requiredOption("--into <dir>", "Existing folder to hold the token file.");
2267
2267
  create.option("--json", "Print JSON output or a JSON error.");
2268
2268
  create.action(async (...parts) => {
@@ -2322,13 +2322,17 @@ function createProgram(options = {}) {
2322
2322
  }
2323
2323
  throw exclusiveFailure();
2324
2324
  }
2325
+ const hash = createHash("sha256").update(secret).digest("hex");
2325
2326
  try {
2326
- const result = await requestTokenEnrollment({
2327
- name,
2328
- folder,
2329
- host: hostname(),
2330
- hash: createHash("sha256").update(secret).digest("hex")
2331
- }, config);
2327
+ const result = {
2328
+ ...await requestTokenEnrollment({
2329
+ name,
2330
+ folder,
2331
+ host: hostname(),
2332
+ hash
2333
+ }, config),
2334
+ requestHash: requestHashOf(hash)
2335
+ };
2332
2336
  io.stdout(`${json || !io.isTTY ? JSON.stringify(result) : formatHuman(result)}\n`);
2333
2337
  } catch (error) {
2334
2338
  if (error instanceof CliError && error.code === "outcome_unknown") throw new CliError("outcome_unknown", void 0, error.requestId, "The request may have reached the daemon. Keep the new token file and check the approval request before retrying.");
@@ -2369,7 +2373,7 @@ async function replaceStaleToken(file, token, config) {
2369
2373
  case "approved": throw refuse(`${file} holds an approved token. Use it from this folder, or ask the operator to revoke it with \`board token revoke\`, then delete the file and run again; or choose another --into folder.`);
2370
2374
  case "pending": throw refuse(`${file} holds a token request still awaiting approval. Ask the operator to approve or deny it, or wait until it expires, then run again; or choose another --into folder.`);
2371
2375
  case "revoked": throw refuse(`${file} holds a revoked token. Delete the file, then run again with another --name.`);
2372
- case "unknown": throw refuse(`This daemon does not know the token in ${file}; it may belong to another board. Check BOARD_DAEMON_URL (or http.port in config.yaml) first; if it names this board, delete the file and run again.`);
2376
+ case "unknown": throw refuse(`This daemon does not know the token in ${file}; it may belong to another board, or its request ended over 7 days ago and was deleted. Check BOARD_DAEMON_URL (or http.port in config.yaml) first; if it names this board, delete the file and run again.`);
2373
2377
  }
2374
2378
  }
2375
2379
  async function runCli(argv, options = {}) {
@@ -1,4 +1,4 @@
1
- import { H as errorEnvelopeSchema, V as errorContextSchema, W as successEnvelopeSchema, p as renderJsonError, z as ERRORS } from "./src-DfgP2kkK.mjs";
1
+ import { G as errorEnvelopeSchema, H as ERRORS, W as errorContextSchema, g as renderJsonError, q as successEnvelopeSchema } from "./src-DGT9Wspi.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 { i as requestTokenEnrollment, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./client-Rpyht8rc.mjs";
1
+ import { i as requestTokenEnrollment, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./client-D8BEfeGz.mjs";
2
2
  export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestTokenEnrollment };
@@ -1,5 +1,5 @@
1
- import { X as configSchema, Z as plainHttpAllowed, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-DfgP2kkK.mjs";
2
- import { a as CliError, t as fetchCatalogVersion } from "./client-Rpyht8rc.mjs";
1
+ import { $ as configSchema, d as buildCatalogSnapshot, et as plainHttpAllowed, p as OPERATIONS } from "./src-DGT9Wspi.mjs";
2
+ import { a as CliError, t as fetchCatalogVersion } from "./client-D8BEfeGz.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/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as COLUMN_IDS, A as ringMarker, B as err, C as REVIEW_STATES, D as parseRingMarker, E as isExternalAuthor, F as errorCodeOf, I as parseActorId, J as DEFAULT_SLACK_COMMAND, K as DEFAULT_LINK, L as parseRef$1, M as ticketFactsSchema, N as actorIdSchema, O as prFactsSchema, P as encodeActorId, Q as requiredSecretKeys, R as taskKeySchema, S as eventPayloadSchemas, T as SESSION_STATUSES, U as ok, W as successEnvelopeSchema, X as configSchema, Y as RESERVED_PROJECT, Z as plainHttpAllowed, _ as inboundEventSchema, a as batchSchema, b as userIdSchema, c as buildCatalogSnapshot, d as turnHandedSchema, et as DISPATCHER_MODES, f as renderHttpProblem, g as conversationRefSchema, h as SPACE_IDS, i as AdapterError, j as sessionFactsSchema, k as prRefSchema, l as roleCanUseOperation, n as BOARD_TICK_MS, o as entityRefSchema, s as sourceCursorSchema, t as assertNever, tt as SLACK_BOT_SCOPES, u as OPERATIONS, v as interactionRefSchema, w as SESSION_HEALTH_STATES, x as EVENT_KINDS, y as messageRefSchema, z as ERRORS } from "./src-DfgP2kkK.mjs";
1
+ import { $ as configSchema, A as parseRingMarker, B as parseRef$1, C as userIdSchema, D as SESSION_HEALTH_STATES, E as REVIEW_STATES, F as ticketFactsSchema, H as ERRORS, I as actorIdSchema, K as ok, L as encodeActorId, M as prRefSchema, N as ringMarker, O as SESSION_STATUSES, P as sessionFactsSchema, Q as RESERVED_PROJECT, R as errorCodeOf, S as messageRefSchema, T as eventPayloadSchemas, U as err, V as taskKeySchema, Y as DEFAULT_LINK, Z as DEFAULT_SLACK_COMMAND, a as BOARD_TICK_MS, b as inboundEventSchema, c as batchSchema, d as buildCatalogSnapshot, et as plainHttpAllowed, f as roleCanUseOperation, h as renderHttpProblem, i as tokenRequestSchema, it as SLACK_BOT_SCOPES, j as prFactsSchema, k as isExternalAuthor, l as entityRefSchema, m as turnHandedSchema, n as TOKEN_REQUEST_LIMITS, nt as COLUMN_IDS, p as OPERATIONS, q as successEnvelopeSchema, r as requestHashOf, rt as DISPATCHER_MODES, s as AdapterError, t as assertNever, tt as requiredSecretKeys, u as sourceCursorSchema, v as SPACE_IDS, w as EVENT_KINDS, x as interactionRefSchema, y as conversationRefSchema, z as parseActorId } from "./src-DGT9Wspi.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import { chmodSync, closeSync, existsSync, fchmodSync, fstatSync, fsyncSync, ftruncateSync, linkSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeSync } from "node:fs";
@@ -8175,7 +8175,7 @@ async function writeDeniedEvent(trx, denial) {
8175
8175
  }
8176
8176
  //#endregion
8177
8177
  //#region ../core/src/app/commands.ts
8178
- const DAY_MS$1 = 864e5;
8178
+ const DAY_MS$2 = 864e5;
8179
8179
  const TASKLESS = [
8180
8180
  "task.add",
8181
8181
  "item.retry",
@@ -8335,7 +8335,7 @@ function createApply(deps) {
8335
8335
  }
8336
8336
  /** Deletes command keys older than `retentionDays`; a key exactly at the cutoff stays. */
8337
8337
  async function purgeExpiredCommands(store, clock, retentionDays) {
8338
- const cutoff = (/* @__PURE__ */ new Date(clock.now() - retentionDays * DAY_MS$1)).toISOString();
8338
+ const cutoff = (/* @__PURE__ */ new Date(clock.now() - retentionDays * DAY_MS$2)).toISOString();
8339
8339
  await store.transaction(async (trx) => {
8340
8340
  await trx.deleteFrom("command").where("at", "<", cutoff).execute();
8341
8341
  });
@@ -9209,6 +9209,9 @@ function resolvedFeedBody(payload, config) {
9209
9209
  //#region ../core/src/app/tokens.ts
9210
9210
  const REQUEST_LIFETIME_MS = 900 * 1e3;
9211
9211
  const MAX_PENDING_REQUESTS = 10;
9212
+ /** Days an expired or denied request stays after its decision before the daily purge drops it. */
9213
+ const TOKEN_REQUEST_RETENTION_DAYS = 7;
9214
+ const DAY_MS$1 = 864e5;
9212
9215
  function effectiveStatus(row, at) {
9213
9216
  return row.status === "pending" && row.expires_at <= at.toISOString() ? "expired" : row.status;
9214
9217
  }
@@ -9236,9 +9239,21 @@ async function expireTokenOfItem(trx, itemId, at) {
9236
9239
  ]).where("item_id", "=", itemId).where("status", "=", "pending").where("expires_at", "<=", at.toISOString()).executeTakeFirst();
9237
9240
  if (row !== void 0) await expireToken(trx, row, at);
9238
9241
  }
9242
+ /** Fixed per-field text: the hint never echoes the value or an unknown key. */
9243
+ const REQUEST_FIELD_HINTS = {
9244
+ name: `Fix \`name\`: use 1-${String(TOKEN_REQUEST_LIMITS.name)} characters, each a letter, digit, ".", "_" or "-".`,
9245
+ folder: `Fix \`folder\`: use 1-${String(TOKEN_REQUEST_LIMITS.folder)} characters, not only spaces, with no control or format characters.`,
9246
+ host: `Fix \`host\`: use 1-${String(TOKEN_REQUEST_LIMITS.host)} characters with no control or format characters.`,
9247
+ hash: "Fix `hash`: send the 64-character lowercase hex SHA-256 of the token."
9248
+ };
9239
9249
  /** Register a hash and its approval item together. The raw file secret never reaches this app. */
9240
- async function requestToken(store, config, input, at) {
9241
- 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.");
9250
+ async function requestToken(store, config, body, at) {
9251
+ const parsed = tokenRequestSchema.safeParse(body);
9252
+ if (!parsed.success) {
9253
+ const field = parsed.error.issues[0]?.path[0];
9254
+ throw new CommandError("usage", (typeof field === "string" ? REQUEST_FIELD_HINTS[field] : void 0) ?? "Send a JSON object with only name, folder, host and hash.");
9255
+ }
9256
+ const input = parsed.data;
9242
9257
  const expiresAt = new Date(at.getTime() + REQUEST_LIFETIME_MS).toISOString();
9243
9258
  return scanTransaction(store, config, async (trx) => {
9244
9259
  const existing = await trx.selectFrom("operator_token").selectAll().where("name", "=", input.name).executeTakeFirst();
@@ -9249,7 +9264,7 @@ async function requestToken(store, config, input, at) {
9249
9264
  const item = await raiseItem(trx, {
9250
9265
  itemKey: `token:${input.name}`,
9251
9266
  kind: "token_request",
9252
- text: `Approve operator token ${input.name} for ${input.folder} on ${input.host}, requested ${at.toISOString()}?`,
9267
+ text: `Approve operator token ${input.name} (request ${requestHashOf(input.hash)}) for ${input.folder} on ${input.host}, requested ${at.toISOString()}?`,
9253
9268
  url: "",
9254
9269
  taskId: null,
9255
9270
  blockId: null,
@@ -9316,6 +9331,17 @@ async function expirePendingTokens(store, config, at) {
9316
9331
  return rows.length;
9317
9332
  });
9318
9333
  }
9334
+ /**
9335
+ * Deletes expired and denied requests decided more than the retention period before `at`; a row
9336
+ * exactly at the cutoff stays. Approved, revoked and pending rows and every approval item stay.
9337
+ */
9338
+ async function purgeEndedTokenRequests(store, at) {
9339
+ const cutoff = (/* @__PURE__ */ new Date(at.getTime() - TOKEN_REQUEST_RETENTION_DAYS * DAY_MS$1)).toISOString();
9340
+ return store.transaction(async (trx) => {
9341
+ const deleted = await trx.deleteFrom("operator_token").where("status", "in", ["expired", "denied"]).where("decided_at", "<", cutoff).executeTakeFirst();
9342
+ return Number(deleted.numDeletedRows);
9343
+ });
9344
+ }
9319
9345
  /** Hash lookup uses the unique index and checks durable state on every call. */
9320
9346
  async function verifyOperatorToken(store, token) {
9321
9347
  const hash = createHash("sha256").update(token).digest("hex");
@@ -9426,14 +9452,7 @@ const doctorReportSchema = z.strictObject({
9426
9452
  fix: z.string().max(300).nullable()
9427
9453
  })).max(30)
9428
9454
  });
9429
- const tokenHash = z.string().regex(/^[0-9a-f]{64}$/);
9430
- const tokenRequestSchema = z.strictObject({
9431
- name: z.string().min(1),
9432
- folder: z.string().min(1),
9433
- host: z.string().min(1),
9434
- hash: tokenHash
9435
- });
9436
- const tokenStatusSchema = z.strictObject({ hash: tokenHash });
9455
+ const tokenStatusSchema = z.strictObject({ hash: tokenRequestSchema.shape.hash });
9437
9456
  function header(value) {
9438
9457
  return Array.isArray(value) ? void 0 : value;
9439
9458
  }
@@ -9537,9 +9556,7 @@ async function createApiServer(options) {
9537
9556
  });
9538
9557
  app.post("/v1/tokens/requests", async (request, reply) => {
9539
9558
  if (!options.ready()) throw notReady();
9540
- const parsed = tokenRequestSchema.safeParse(request.body);
9541
- if (!parsed.success) throw new CommandError("usage", "Provide a name, folder, host and token hash.");
9542
- const result = await requestToken(options.store, options.config, parsed.data, new Date(options.clock.now()));
9559
+ const result = await requestToken(options.store, options.config, request.body, new Date(options.clock.now()));
9543
9560
  return reply.send(successEnvelopeSchema.parse({
9544
9561
  ok: true,
9545
9562
  requestId: request.id,
@@ -21242,6 +21259,7 @@ function createDaemonModules(ctxFor, ports = {}) {
21242
21259
  }
21243
21260
  });
21244
21261
  const commands = ctxFor("commands");
21262
+ const tokenRequests = ctxFor("token-requests");
21245
21263
  const entries = [{
21246
21264
  name: "commands",
21247
21265
  stopStage: "final",
@@ -21253,6 +21271,17 @@ function createDaemonModules(ctxFor, ports = {}) {
21253
21271
  commands.log.error({ err }, "command purge failed");
21254
21272
  }
21255
21273
  })
21274
+ }, {
21275
+ name: "token-requests",
21276
+ stopStage: "final",
21277
+ module: createJob({
21278
+ run: () => purgeEndedTokenRequests(tokenRequests.store, new Date(tokenRequests.clock.now())),
21279
+ intervalMs: DAY_MS,
21280
+ first: "background",
21281
+ onError: (err) => {
21282
+ tokenRequests.log.error({ err }, "token request purge failed");
21283
+ }
21284
+ })
21256
21285
  }];
21257
21286
  const boardModules = createBoardModules(ctxFor, {
21258
21287
  core,
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { m as renderMcpError, u as OPERATIONS, z as ERRORS } from "./src-DfgP2kkK.mjs";
2
- import { a as CliError, r as requestOperation } from "./client-Rpyht8rc.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-RyoKekR8.mjs";
1
+ import { H as ERRORS, _ as renderMcpError, p as OPERATIONS } from "./src-DGT9Wspi.mjs";
2
+ import { a as CliError, r as requestOperation } from "./client-D8BEfeGz.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-Chv5ZHE8.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -929,8 +929,14 @@ const EXAMPLES = {
929
929
  turn: "T4",
930
930
  task: "PROJ-123, owner/repo#42 or repo#42"
931
931
  };
932
- function refSchema(kind, description) {
933
- return z.string().superRefine((value, ctx) => {
932
+ /** A numbered ID is a letter and at most 15 digits, so never longer than 16 characters. */
933
+ const NUMBERED_ID_MAX = 16;
934
+ /** Longest task key an operation input takes. Stored and reported keys have no length cap. */
935
+ const TASK_KEY_INPUT_MAX = 300;
936
+ /** `max` goes on the base string before the refinement, so the JSON Schema keeps `pattern`. */
937
+ function refSchema(kind, description, max) {
938
+ const base = z.string();
939
+ return (max === void 0 ? base : base.max(max)).superRefine((value, ctx) => {
934
940
  const result = parseRef(value, kind);
935
941
  if (result.ok) return;
936
942
  ctx.addIssue({
@@ -940,11 +946,14 @@ function refSchema(kind, description) {
940
946
  });
941
947
  }).meta({ pattern: PATTERNS[kind] }).describe(description);
942
948
  }
943
- const blockIdSchema = refSchema("block", "Block ID: B followed by a number, e.g. B12.");
944
- const commentIdSchema = refSchema("comment", "Comment ID: C followed by a number, e.g. C3.");
945
- const itemIdSchema = refSchema("item", "Item ID: I followed by a number, e.g. I7.");
946
- const turnIdSchema = refSchema("turn", "Turn ID: T followed by a number, e.g. T4.");
947
- const taskKeySchema = refSchema("task", "Task key: a Jira key (PROJ-123) or a GitHub issue (owner/repo#42, or repo#42).");
949
+ const blockIdSchema = refSchema("block", "Block ID: B followed by a number, e.g. B12.", NUMBERED_ID_MAX);
950
+ const commentIdSchema = refSchema("comment", "Comment ID: C followed by a number, e.g. C3.", NUMBERED_ID_MAX);
951
+ const itemIdSchema = refSchema("item", "Item ID: I followed by a number, e.g. I7.", NUMBERED_ID_MAX);
952
+ const turnIdSchema = refSchema("turn", "Turn ID: T followed by a number, e.g. T4.", NUMBERED_ID_MAX);
953
+ const TASK_KEY_DESCRIPTION = "Task key: a Jira key (PROJ-123) or a GitHub issue (owner/repo#42, or repo#42).";
954
+ const taskKeySchema = refSchema("task", TASK_KEY_DESCRIPTION);
955
+ /** The task key an operation input takes: `taskKeySchema` with a length cap. */
956
+ const taskKeyInputSchema = refSchema("task", TASK_KEY_DESCRIPTION, TASK_KEY_INPUT_MAX);
948
957
  /** The error code for a failed parse: `wrong_id_kind` when an ID of another kind was given. */
949
958
  function errorCodeOf(error) {
950
959
  return error.issues.some((issue) => issue.code === "custom" && issue.params?.["code"] === "wrong_id_kind") ? "wrong_id_kind" : "usage";
@@ -1996,27 +2005,37 @@ const schemaGetOutputSchema = z.strictObject({
1996
2005
  }).describe("The operation catalog.");
1997
2006
  //#endregion
1998
2007
  //#region ../contracts/src/ops/catalog.ts
1999
- const project = z.string().min(1).optional().describe("Project to limit the answer to; absent means every project the caller may see.");
2000
- const text = (what) => z.string().min(1).describe(what);
2001
- const target = text("Pull request, session, or ticket linked to the task.");
2008
+ /** Longest free text an input takes: comments, questions, answers and reasons. */
2009
+ const TEXT_MAX = 2e4;
2010
+ /** Longest project, session or token name an input takes. */
2011
+ const NAME_MAX = 256;
2012
+ /** Names were limited only by the old 1 MiB request body before #242, so revoke must accept any of them. */
2013
+ const LEGACY_TOKEN_NAME_MAX = 1048576;
2014
+ /** Longest pull request URL or unblock reference an input takes. */
2015
+ const REF_MAX = 2048;
2016
+ /** Most entries one `inbox.ack` call acknowledges. */
2017
+ const ACK_ENTRIES_MAX = 100;
2018
+ const project = z.string().min(1).max(NAME_MAX).optional().describe("Project to limit the answer to; absent means every project the caller may see.");
2019
+ const text = (what, max) => z.string().min(1).max(max).describe(what);
2020
+ const target = z.string().min(1).describe("Pull request, session, or ticket linked to the task.");
2002
2021
  const linkInput = z.discriminatedUnion("mode", [
2003
2022
  z.strictObject({
2004
2023
  mode: z.literal("pr").describe("Link a pull request."),
2005
- task: taskKeySchema,
2006
- pr: z.url({ protocol: /^https?$/ }).describe("Pull request URL."),
2007
- reason: text("Why this link is being changed.")
2024
+ task: taskKeyInputSchema,
2025
+ pr: z.url({ protocol: /^https?$/ }).max(REF_MAX).describe("Pull request URL."),
2026
+ reason: text("Why this link is being changed.", TEXT_MAX)
2008
2027
  }),
2009
2028
  z.strictObject({
2010
2029
  mode: z.literal("session").describe("Link a spur session."),
2011
- task: taskKeySchema,
2012
- session: text("Spur session ID."),
2013
- reason: text("Why this link is being changed.")
2030
+ task: taskKeyInputSchema,
2031
+ session: text("Spur session ID.", NAME_MAX),
2032
+ reason: text("Why this link is being changed.", TEXT_MAX)
2014
2033
  }),
2015
2034
  z.strictObject({
2016
2035
  mode: z.literal("ticket").describe("Link an additional tracker ticket."),
2017
- task: taskKeySchema,
2018
- ticket: taskKeySchema,
2019
- reason: text("Why this link is being changed.")
2036
+ task: taskKeyInputSchema,
2037
+ ticket: taskKeyInputSchema,
2038
+ reason: text("Why this link is being changed.", TEXT_MAX)
2020
2039
  })
2021
2040
  ]);
2022
2041
  const linkModes = [
@@ -2203,7 +2222,7 @@ const tokenStatus = z.enum([
2203
2222
  "expired",
2204
2223
  "revoked"
2205
2224
  ]).describe("Current token state.");
2206
- const tokenName = text("Unique name of the operator token.");
2225
+ const tokenName = z.string().min(1).describe("Unique name of the operator token.");
2207
2226
  /** The M1 operations. CLI, MCP and the daemon route are generated from this list. */
2208
2227
  const OPERATIONS = [
2209
2228
  defineOperation({
@@ -2306,7 +2325,7 @@ const OPERATIONS = [
2306
2325
  whenNotToUse: "Use task_history for past events."
2307
2326
  },
2308
2327
  input: z.strictObject({
2309
- task: taskKeySchema,
2328
+ task: taskKeyInputSchema,
2310
2329
  why: z.boolean().optional().describe("Explain why the task is in its column: gates, holds, the open turn and the last moves; absent means no explanation.")
2311
2330
  }),
2312
2331
  output: z.strictObject({
@@ -2385,7 +2404,7 @@ const OPERATIONS = [
2385
2404
  whenToUse: "Trace changes to one task.",
2386
2405
  whenNotToUse: "Use task_get for current state."
2387
2406
  },
2388
- input: z.strictObject({ task: taskKeySchema }),
2407
+ input: z.strictObject({ task: taskKeyInputSchema }),
2389
2408
  output: z.strictObject({
2390
2409
  task: taskViewSchema,
2391
2410
  events: z.array(z.strictObject({
@@ -2526,7 +2545,7 @@ const OPERATIONS = [
2526
2545
  }),
2527
2546
  z.strictObject({ id: blockIdSchema }),
2528
2547
  z.strictObject({ id: turnIdSchema })
2529
- ])).min(1).describe("Comment revisions, blocks and turns to acknowledge.") }),
2548
+ ])).min(1).max(ACK_ENTRIES_MAX).describe("Comment revisions, blocks and turns to acknowledge.") }),
2530
2549
  output: z.strictObject({ acked: z.array(z.union([
2531
2550
  commentIdSchema,
2532
2551
  blockIdSchema,
@@ -2575,7 +2594,7 @@ const OPERATIONS = [
2575
2594
  input: z.strictObject({}),
2576
2595
  output: z.strictObject({ tokens: z.array(z.strictObject({
2577
2596
  name: tokenName,
2578
- folder: text("Folder where the token file was created."),
2597
+ folder: z.string().min(1).describe("Folder where the token file was created."),
2579
2598
  status: tokenStatus
2580
2599
  })).describe("Named tokens in creation order.") }),
2581
2600
  grants: operatorOnly,
@@ -2603,7 +2622,7 @@ const OPERATIONS = [
2603
2622
  whenToUse: "Disable a named operator token immediately.",
2604
2623
  whenNotToUse: "Use token_list to inspect tokens without changing them."
2605
2624
  },
2606
- input: z.strictObject({ name: tokenName }),
2625
+ input: z.strictObject({ name: tokenName.max(LEGACY_TOKEN_NAME_MAX) }),
2607
2626
  output: z.strictObject({
2608
2627
  name: tokenName,
2609
2628
  status: tokenStatus
@@ -2632,7 +2651,7 @@ const OPERATIONS = [
2632
2651
  whenToUse: "Add a task to the board.",
2633
2652
  whenNotToUse: "Use task_get if it already exists."
2634
2653
  },
2635
- input: z.strictObject({ task: taskKeySchema }),
2654
+ input: z.strictObject({ task: taskKeyInputSchema }),
2636
2655
  output: taskOutput,
2637
2656
  grants: operatorOnly,
2638
2657
  errors: ["wrong_id_kind", "not_found"],
@@ -2655,7 +2674,7 @@ const OPERATIONS = [
2655
2674
  whenToUse: "Remove a task from active view.",
2656
2675
  whenNotToUse: "Use task_get to inspect its current state."
2657
2676
  },
2658
- input: z.strictObject({ task: taskKeySchema }),
2677
+ input: z.strictObject({ task: taskKeyInputSchema }),
2659
2678
  output: taskOutput,
2660
2679
  grants: operatorOnly,
2661
2680
  errors: [
@@ -2821,8 +2840,8 @@ const OPERATIONS = [
2821
2840
  destructive: false
2822
2841
  },
2823
2842
  input: z.strictObject({
2824
- task: taskKeySchema,
2825
- text: text("The question.")
2843
+ task: taskKeyInputSchema,
2844
+ text: text("The question.", TEXT_MAX)
2826
2845
  }),
2827
2846
  output: blockOutput,
2828
2847
  grants: [{ grant: "project-agent" }],
@@ -2855,9 +2874,9 @@ const OPERATIONS = [
2855
2874
  destructive: false
2856
2875
  },
2857
2876
  input: z.strictObject({
2858
- task: taskKeySchema,
2877
+ task: taskKeyInputSchema,
2859
2878
  block: blockIdSchema.optional().describe("Block conversation to join, if any."),
2860
- text: text("Comment text.")
2879
+ text: text("Comment text.", TEXT_MAX)
2861
2880
  }),
2862
2881
  output: z.strictObject({ comment: commentSchema }),
2863
2882
  grants: [{ grant: "project-agent" }, { grant: "operator" }],
@@ -2893,7 +2912,7 @@ const OPERATIONS = [
2893
2912
  },
2894
2913
  input: z.strictObject({
2895
2914
  comment: commentIdSchema,
2896
- text: text("Replacement comment text.")
2915
+ text: text("Replacement comment text.", TEXT_MAX)
2897
2916
  }),
2898
2917
  output: z.strictObject({ comment: commentSchema }),
2899
2918
  grants: [{ grant: "project-agent" }, { grant: "operator" }],
@@ -2930,9 +2949,9 @@ const OPERATIONS = [
2930
2949
  destructive: false
2931
2950
  },
2932
2951
  input: z.strictObject({
2933
- task: taskKeySchema,
2952
+ task: taskKeyInputSchema,
2934
2953
  type: z.enum(BLOCK_TYPES).extract(["dependency", "external"]).describe("Block type."),
2935
- reason: text("What the task waits for.")
2954
+ reason: text("What the task waits for.", TEXT_MAX)
2936
2955
  }),
2937
2956
  output: blockOutput,
2938
2957
  grants: [{ grant: "column-orchestrator" }, { grant: "operator" }],
@@ -2972,7 +2991,7 @@ const OPERATIONS = [
2972
2991
  },
2973
2992
  input: z.strictObject({
2974
2993
  block: blockIdSchema,
2975
- note: z.string().min(1).optional().describe("Context for the next addressee, posted after the original text.")
2994
+ note: z.string().min(1).max(TEXT_MAX).optional().describe("Context for the next addressee, posted after the original text.")
2976
2995
  }),
2977
2996
  output: blockOutput,
2978
2997
  grants: [{ grant: "block-addressee" }],
@@ -3016,7 +3035,7 @@ const OPERATIONS = [
3016
3035
  },
3017
3036
  input: z.strictObject({
3018
3037
  block: blockIdSchema,
3019
- text: text("The answer.")
3038
+ text: text("The answer.", TEXT_MAX)
3020
3039
  }),
3021
3040
  output: z.strictObject({
3022
3041
  block: blockViewSchema,
@@ -3066,17 +3085,17 @@ const OPERATIONS = [
3066
3085
  z.strictObject({
3067
3086
  mode: z.literal("done").describe("The blocking work is done."),
3068
3087
  block: blockIdSchema,
3069
- ref: text("What resolved the block, e.g. a commit SHA or a pull request.").optional()
3088
+ ref: text("What resolved the block, e.g. a commit SHA or a pull request.", REF_MAX).optional()
3070
3089
  }).describe("Unblock because the work is done."),
3071
3090
  z.strictObject({
3072
3091
  mode: z.literal("reason").describe("Unblock with an explanation."),
3073
3092
  block: blockIdSchema,
3074
- reason: text("Why the block no longer applies.")
3093
+ reason: text("Why the block no longer applies.", TEXT_MAX)
3075
3094
  }).describe("Unblock with a reason."),
3076
3095
  z.strictObject({
3077
3096
  mode: z.literal("withdraw").describe("The author takes their own question back (needs_input only)."),
3078
3097
  block: blockIdSchema,
3079
- answer: text("Why it is withdrawn, e.g. the answer received outside the board.")
3098
+ answer: text("Why it is withdrawn, e.g. the answer received outside the board.", TEXT_MAX)
3080
3099
  }).describe("Withdraw the block.")
3081
3100
  ]),
3082
3101
  output: blockOutput,
@@ -3193,8 +3212,8 @@ const OPERATIONS = [
3193
3212
  whenNotToUse: "Use task_return to send the task back to Dev instead."
3194
3213
  },
3195
3214
  input: z.strictObject({
3196
- turn: z.union([turnIdSchema, taskKeySchema]).describe("Turn ID you took (T4); while the project dispatcher is in shadow mode, the task key instead."),
3197
- sha: commitShaSchema.describe("Full commit SHA at the head of the pull request, lowercase.")
3215
+ turn: z.union([turnIdSchema, taskKeyInputSchema]).describe("Turn ID you took (T4); while the project dispatcher is in shadow mode, the task key instead."),
3216
+ sha: commitShaSchema.max(64).describe("Full commit SHA at the head of the pull request, lowercase.")
3198
3217
  }),
3199
3218
  output: z.strictObject({
3200
3219
  task: taskViewSchema,
@@ -3256,7 +3275,7 @@ const OPERATIONS = [
3256
3275
  },
3257
3276
  input: z.strictObject({
3258
3277
  turn: turnIdSchema,
3259
- reason: text("What the worker must change, sent to the worker as a code block.")
3278
+ reason: text("What the worker must change, sent to the worker as a code block.", TEXT_MAX)
3260
3279
  }),
3261
3280
  output: z.strictObject({
3262
3281
  task: taskViewSchema,
@@ -3303,9 +3322,9 @@ const OPERATIONS = [
3303
3322
  },
3304
3323
  input: z.discriminatedUnion("mode", [z.strictObject({
3305
3324
  mode: z.literal("correct").describe("Correct a wrong column by hand."),
3306
- task: taskKeySchema,
3325
+ task: taskKeyInputSchema,
3307
3326
  column: z.enum(COLUMN_IDS).exclude(["done"]).describe("Enabled column to put the task in; Done is reached only from the facts."),
3308
- reason: text("Why the column is corrected, kept in the journal.")
3327
+ reason: text("Why the column is corrected, kept in the journal.", TEXT_MAX)
3309
3328
  })]),
3310
3329
  output: z.strictObject({
3311
3330
  task: taskViewSchema,
@@ -3614,10 +3633,34 @@ const SYSTEMD_SERVICE_SETTINGS = [
3614
3633
  "UMask=0077"
3615
3634
  ];
3616
3635
  //#endregion
3636
+ //#region ../contracts/src/tokens.ts
3637
+ /** Longest value each field of an operator token request takes, in characters. */
3638
+ const TOKEN_REQUEST_LIMITS = {
3639
+ name: 64,
3640
+ folder: 1024,
3641
+ host: 253
3642
+ };
3643
+ /** Control, format and line or paragraph separator characters: they can disguise a prompt. */
3644
+ const PLAIN_TEXT = /^[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}]*$/u;
3645
+ /** The body of `POST /v1/tokens/requests`: what the operator is asked to approve in Slack. */
3646
+ const tokenRequestSchema = z.strictObject({
3647
+ name: z.string().min(1).max(TOKEN_REQUEST_LIMITS.name).regex(/^[A-Za-z0-9._-]+$/),
3648
+ folder: z.string().min(1).max(TOKEN_REQUEST_LIMITS.folder).regex(PLAIN_TEXT).refine((value) => value.trim() !== ""),
3649
+ host: z.string().min(1).max(TOKEN_REQUEST_LIMITS.host).regex(PLAIN_TEXT),
3650
+ hash: z.string().regex(/^[0-9a-f]{64}$/)
3651
+ });
3652
+ /**
3653
+ * The short request hash the approval prompt and `board token create` both show, so the
3654
+ * operator can match the request they approve to the one they made.
3655
+ */
3656
+ function requestHashOf(hash) {
3657
+ return hash.slice(0, 10);
3658
+ }
3659
+ //#endregion
3617
3660
  //#region ../contracts/src/index.ts
3618
3661
  /** Exhaustiveness check: call it in the `default` branch of a switch over a union. */
3619
3662
  function assertNever(value) {
3620
3663
  throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
3621
3664
  }
3622
3665
  //#endregion
3623
- export { COLUMN_IDS as $, ringMarker as A, err as B, REVIEW_STATES as C, parseRingMarker as D, isExternalAuthor as E, errorCodeOf as F, DEFAULT_HTTP_PORT as G, errorEnvelopeSchema as H, parseActorId as I, DEFAULT_SLACK_COMMAND as J, DEFAULT_LINK as K, parseRef as L, ticketFactsSchema as M, actorIdSchema as N, prFactsSchema as O, encodeActorId as P, requiredSecretKeys as Q, taskKeySchema as R, eventPayloadSchemas as S, SESSION_STATUSES as T, ok as U, errorContextSchema as V, successEnvelopeSchema as W, configSchema as X, RESERVED_PROJECT as Y, plainHttpAllowed as Z, inboundEventSchema as _, batchSchema as a, userIdSchema as b, buildCatalogSnapshot as c, turnHandedSchema as d, DISPATCHER_MODES as et, renderHttpProblem as f, conversationRefSchema as g, SPACE_IDS as h, AdapterError as i, sessionFactsSchema as j, prRefSchema as k, roleCanUseOperation as l, renderMcpError as m, BOARD_TICK_MS as n, entityRefSchema as o, renderJsonError as p, DEFAULT_SLACK_APP_NAME as q, SYSTEMD_SERVICE_SETTINGS as r, sourceCursorSchema as s, assertNever as t, SLACK_BOT_SCOPES as tt, OPERATIONS as u, interactionRefSchema as v, SESSION_HEALTH_STATES as w, EVENT_KINDS as x, messageRefSchema as y, ERRORS as z };
3666
+ export { configSchema as $, parseRingMarker as A, parseRef as B, userIdSchema as C, SESSION_HEALTH_STATES as D, REVIEW_STATES as E, ticketFactsSchema as F, errorEnvelopeSchema as G, ERRORS as H, actorIdSchema as I, DEFAULT_HTTP_PORT as J, ok as K, encodeActorId as L, prRefSchema as M, ringMarker as N, SESSION_STATUSES as O, sessionFactsSchema as P, RESERVED_PROJECT as Q, errorCodeOf as R, messageRefSchema as S, eventPayloadSchemas as T, err as U, taskKeySchema as V, errorContextSchema as W, DEFAULT_SLACK_APP_NAME as X, DEFAULT_LINK as Y, DEFAULT_SLACK_COMMAND as Z, renderMcpError as _, BOARD_TICK_MS as a, inboundEventSchema as b, batchSchema as c, buildCatalogSnapshot as d, plainHttpAllowed as et, roleCanUseOperation as f, renderJsonError as g, renderHttpProblem as h, tokenRequestSchema as i, SLACK_BOT_SCOPES as it, prFactsSchema as j, isExternalAuthor as k, entityRefSchema as l, turnHandedSchema as m, TOKEN_REQUEST_LIMITS as n, COLUMN_IDS as nt, SYSTEMD_SERVICE_SETTINGS as o, OPERATIONS as p, successEnvelopeSchema as q, requestHashOf as r, DISPATCHER_MODES as rt, AdapterError as s, assertNever as t, requiredSecretKeys as tt, sourceCursorSchema as u, SPACE_IDS as v, EVENT_KINDS as w, interactionRefSchema as x, conversationRefSchema as y, parseActorId as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.46.1",
3
+ "version": "0.47.0",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"
@@ -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`, 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`.
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. 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
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