spur-board 0.46.0 → 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-DYURByVi.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-BAwxhgyr.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-C0nYXJX4.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-DYURByVi.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-BAwxhgyr.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-DYURByVi.mjs";
2
- import { a as CliError, t as fetchCatalogVersion } from "./client-BAwxhgyr.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-DYURByVi.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,
@@ -16636,8 +16653,9 @@ const INDEX_FIELDS = `number updatedAt state isDraft mergeable mergeStateStatus
16636
16653
  function aliases(numbers, fields) {
16637
16654
  return numbers.map((number, i) => `pr${String(i)}: repository(owner: $owner, name: $repo) { pullRequest(number: ${String(number)}) { ${fields(number)} } }`).join("\n");
16638
16655
  }
16656
+ const discoveryStates = (bootstrap) => bootstrap ? "OPEN" : "OPEN, MERGED, CLOSED";
16639
16657
  function discoveryQuery(bootstrap = false) {
16640
- return `query PrBatch($owner: String!, $repo: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, states: [${bootstrap ? "OPEN" : "OPEN, MERGED"}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} }${bootstrap ? " mergedBaseline: pullRequests(first: 1, states: [MERGED], orderBy: {field: UPDATED_AT, direction: DESC}) { nodes { updatedAt } }" : ""} } }`;
16658
+ return `query PrBatch($owner: String!, $repo: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, states: [${discoveryStates(bootstrap)}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} }${bootstrap ? " mergedBaseline: pullRequests(first: 1, states: [MERGED, CLOSED], orderBy: {field: UPDATED_AT, direction: DESC}) { nodes { updatedAt } }" : ""} } }`;
16641
16659
  }
16642
16660
  function indexQuery(numbers) {
16643
16661
  return `query PrIndex($owner: String!, $repo: String!) { rateLimit { remaining resetAt } ${aliases(numbers, () => INDEX_FIELDS)} }`;
@@ -16647,7 +16665,7 @@ function detailQuery(numbers, closing = false) {
16647
16665
  }
16648
16666
  function pageQuery(connection, bootstrap = false) {
16649
16667
  if (connection === "comments") return `query PrPage($owner: String!, $repo: String!, $number: Int!, $before: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { comments(last: 100, before: $before) { ${COMMENT_FIELDS} } } } }`;
16650
- if (connection === "pullRequests") return `query DiscoveryPage($owner: String!, $repo: String!, $after: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, after: $after, states: [${bootstrap ? "OPEN" : "OPEN, MERGED"}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} } } }`;
16668
+ if (connection === "pullRequests") return `query DiscoveryPage($owner: String!, $repo: String!, $after: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, after: $after, states: [${discoveryStates(bootstrap)}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} } } }`;
16651
16669
  return `query PrPage($owner: String!, $repo: String!, $number: Int!, $after: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { ${connection === "closingIssuesReferences" ? `closingIssuesReferences(first: 100, after: $after) { ${CLOSING_FIELDS} }` : connection === "contexts" ? `statusCheckRollup { contexts(first: 100, after: $after) { nodes { ... on CheckRun { __typename name status conclusion startedAt completedAt checkSuite { createdAt } isRequired(pullRequestNumber: $number) } ... on StatusContext { __typename context state createdAt isRequired(pullRequestNumber: $number) } } pageInfo { hasNextPage endCursor } } }` : `${connection}(first: 100, after: $after) { nodes { ${connection === "reviews" ? REVIEW_FIELDS : connection === "reviewThreads" ? "isResolved" : REVIEWER_FIELDS} } pageInfo { hasNextPage endCursor } }`} } } }`;
16652
16670
  }
16653
16671
  var GithubClient = class {
@@ -21241,6 +21259,7 @@ function createDaemonModules(ctxFor, ports = {}) {
21241
21259
  }
21242
21260
  });
21243
21261
  const commands = ctxFor("commands");
21262
+ const tokenRequests = ctxFor("token-requests");
21244
21263
  const entries = [{
21245
21264
  name: "commands",
21246
21265
  stopStage: "final",
@@ -21252,6 +21271,17 @@ function createDaemonModules(ctxFor, ports = {}) {
21252
21271
  commands.log.error({ err }, "command purge failed");
21253
21272
  }
21254
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
+ })
21255
21285
  }];
21256
21286
  const boardModules = createBoardModules(ctxFor, {
21257
21287
  core,
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { m as renderMcpError, u as OPERATIONS, z as ERRORS } from "./src-DYURByVi.mjs";
2
- import { a as CliError, r as requestOperation } from "./client-BAwxhgyr.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-C0nYXJX4.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";
@@ -396,7 +396,12 @@ function isTimeZone(tz) {
396
396
  return false;
397
397
  }
398
398
  }
399
- /** A session belongs to one board project, so a Spur project can be listed under only one. */
399
+ /**
400
+ * A Spur project can be listed under only one board project (#245). A session's actor is
401
+ * `agent:<spur project>/<session>`, with no board project in it; its roles are looked up by Spur
402
+ * project, and a curator ring picks a session by Spur project. The config is refused here rather
403
+ * than resolving roles per board project, so every session has one owning board project.
404
+ */
400
405
  function rejectSharedSpurProjects(items, ctx) {
401
406
  const owners = /* @__PURE__ */ new Map();
402
407
  items.forEach((project, i) => {
@@ -924,8 +929,14 @@ const EXAMPLES = {
924
929
  turn: "T4",
925
930
  task: "PROJ-123, owner/repo#42 or repo#42"
926
931
  };
927
- function refSchema(kind, description) {
928
- 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) => {
929
940
  const result = parseRef(value, kind);
930
941
  if (result.ok) return;
931
942
  ctx.addIssue({
@@ -935,11 +946,14 @@ function refSchema(kind, description) {
935
946
  });
936
947
  }).meta({ pattern: PATTERNS[kind] }).describe(description);
937
948
  }
938
- const blockIdSchema = refSchema("block", "Block ID: B followed by a number, e.g. B12.");
939
- const commentIdSchema = refSchema("comment", "Comment ID: C followed by a number, e.g. C3.");
940
- const itemIdSchema = refSchema("item", "Item ID: I followed by a number, e.g. I7.");
941
- const turnIdSchema = refSchema("turn", "Turn ID: T followed by a number, e.g. T4.");
942
- 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);
943
957
  /** The error code for a failed parse: `wrong_id_kind` when an ID of another kind was given. */
944
958
  function errorCodeOf(error) {
945
959
  return error.issues.some((issue) => issue.code === "custom" && issue.params?.["code"] === "wrong_id_kind") ? "wrong_id_kind" : "usage";
@@ -1991,27 +2005,37 @@ const schemaGetOutputSchema = z.strictObject({
1991
2005
  }).describe("The operation catalog.");
1992
2006
  //#endregion
1993
2007
  //#region ../contracts/src/ops/catalog.ts
1994
- const project = z.string().min(1).optional().describe("Project to limit the answer to; absent means every project the caller may see.");
1995
- const text = (what) => z.string().min(1).describe(what);
1996
- 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.");
1997
2021
  const linkInput = z.discriminatedUnion("mode", [
1998
2022
  z.strictObject({
1999
2023
  mode: z.literal("pr").describe("Link a pull request."),
2000
- task: taskKeySchema,
2001
- pr: z.url({ protocol: /^https?$/ }).describe("Pull request URL."),
2002
- 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)
2003
2027
  }),
2004
2028
  z.strictObject({
2005
2029
  mode: z.literal("session").describe("Link a spur session."),
2006
- task: taskKeySchema,
2007
- session: text("Spur session ID."),
2008
- 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)
2009
2033
  }),
2010
2034
  z.strictObject({
2011
2035
  mode: z.literal("ticket").describe("Link an additional tracker ticket."),
2012
- task: taskKeySchema,
2013
- ticket: taskKeySchema,
2014
- 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)
2015
2039
  })
2016
2040
  ]);
2017
2041
  const linkModes = [
@@ -2198,7 +2222,7 @@ const tokenStatus = z.enum([
2198
2222
  "expired",
2199
2223
  "revoked"
2200
2224
  ]).describe("Current token state.");
2201
- const tokenName = text("Unique name of the operator token.");
2225
+ const tokenName = z.string().min(1).describe("Unique name of the operator token.");
2202
2226
  /** The M1 operations. CLI, MCP and the daemon route are generated from this list. */
2203
2227
  const OPERATIONS = [
2204
2228
  defineOperation({
@@ -2301,7 +2325,7 @@ const OPERATIONS = [
2301
2325
  whenNotToUse: "Use task_history for past events."
2302
2326
  },
2303
2327
  input: z.strictObject({
2304
- task: taskKeySchema,
2328
+ task: taskKeyInputSchema,
2305
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.")
2306
2330
  }),
2307
2331
  output: z.strictObject({
@@ -2380,7 +2404,7 @@ const OPERATIONS = [
2380
2404
  whenToUse: "Trace changes to one task.",
2381
2405
  whenNotToUse: "Use task_get for current state."
2382
2406
  },
2383
- input: z.strictObject({ task: taskKeySchema }),
2407
+ input: z.strictObject({ task: taskKeyInputSchema }),
2384
2408
  output: z.strictObject({
2385
2409
  task: taskViewSchema,
2386
2410
  events: z.array(z.strictObject({
@@ -2521,7 +2545,7 @@ const OPERATIONS = [
2521
2545
  }),
2522
2546
  z.strictObject({ id: blockIdSchema }),
2523
2547
  z.strictObject({ id: turnIdSchema })
2524
- ])).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.") }),
2525
2549
  output: z.strictObject({ acked: z.array(z.union([
2526
2550
  commentIdSchema,
2527
2551
  blockIdSchema,
@@ -2570,7 +2594,7 @@ const OPERATIONS = [
2570
2594
  input: z.strictObject({}),
2571
2595
  output: z.strictObject({ tokens: z.array(z.strictObject({
2572
2596
  name: tokenName,
2573
- folder: text("Folder where the token file was created."),
2597
+ folder: z.string().min(1).describe("Folder where the token file was created."),
2574
2598
  status: tokenStatus
2575
2599
  })).describe("Named tokens in creation order.") }),
2576
2600
  grants: operatorOnly,
@@ -2598,7 +2622,7 @@ const OPERATIONS = [
2598
2622
  whenToUse: "Disable a named operator token immediately.",
2599
2623
  whenNotToUse: "Use token_list to inspect tokens without changing them."
2600
2624
  },
2601
- input: z.strictObject({ name: tokenName }),
2625
+ input: z.strictObject({ name: tokenName.max(LEGACY_TOKEN_NAME_MAX) }),
2602
2626
  output: z.strictObject({
2603
2627
  name: tokenName,
2604
2628
  status: tokenStatus
@@ -2627,7 +2651,7 @@ const OPERATIONS = [
2627
2651
  whenToUse: "Add a task to the board.",
2628
2652
  whenNotToUse: "Use task_get if it already exists."
2629
2653
  },
2630
- input: z.strictObject({ task: taskKeySchema }),
2654
+ input: z.strictObject({ task: taskKeyInputSchema }),
2631
2655
  output: taskOutput,
2632
2656
  grants: operatorOnly,
2633
2657
  errors: ["wrong_id_kind", "not_found"],
@@ -2650,7 +2674,7 @@ const OPERATIONS = [
2650
2674
  whenToUse: "Remove a task from active view.",
2651
2675
  whenNotToUse: "Use task_get to inspect its current state."
2652
2676
  },
2653
- input: z.strictObject({ task: taskKeySchema }),
2677
+ input: z.strictObject({ task: taskKeyInputSchema }),
2654
2678
  output: taskOutput,
2655
2679
  grants: operatorOnly,
2656
2680
  errors: [
@@ -2816,8 +2840,8 @@ const OPERATIONS = [
2816
2840
  destructive: false
2817
2841
  },
2818
2842
  input: z.strictObject({
2819
- task: taskKeySchema,
2820
- text: text("The question.")
2843
+ task: taskKeyInputSchema,
2844
+ text: text("The question.", TEXT_MAX)
2821
2845
  }),
2822
2846
  output: blockOutput,
2823
2847
  grants: [{ grant: "project-agent" }],
@@ -2850,9 +2874,9 @@ const OPERATIONS = [
2850
2874
  destructive: false
2851
2875
  },
2852
2876
  input: z.strictObject({
2853
- task: taskKeySchema,
2877
+ task: taskKeyInputSchema,
2854
2878
  block: blockIdSchema.optional().describe("Block conversation to join, if any."),
2855
- text: text("Comment text.")
2879
+ text: text("Comment text.", TEXT_MAX)
2856
2880
  }),
2857
2881
  output: z.strictObject({ comment: commentSchema }),
2858
2882
  grants: [{ grant: "project-agent" }, { grant: "operator" }],
@@ -2888,7 +2912,7 @@ const OPERATIONS = [
2888
2912
  },
2889
2913
  input: z.strictObject({
2890
2914
  comment: commentIdSchema,
2891
- text: text("Replacement comment text.")
2915
+ text: text("Replacement comment text.", TEXT_MAX)
2892
2916
  }),
2893
2917
  output: z.strictObject({ comment: commentSchema }),
2894
2918
  grants: [{ grant: "project-agent" }, { grant: "operator" }],
@@ -2925,9 +2949,9 @@ const OPERATIONS = [
2925
2949
  destructive: false
2926
2950
  },
2927
2951
  input: z.strictObject({
2928
- task: taskKeySchema,
2952
+ task: taskKeyInputSchema,
2929
2953
  type: z.enum(BLOCK_TYPES).extract(["dependency", "external"]).describe("Block type."),
2930
- reason: text("What the task waits for.")
2954
+ reason: text("What the task waits for.", TEXT_MAX)
2931
2955
  }),
2932
2956
  output: blockOutput,
2933
2957
  grants: [{ grant: "column-orchestrator" }, { grant: "operator" }],
@@ -2967,7 +2991,7 @@ const OPERATIONS = [
2967
2991
  },
2968
2992
  input: z.strictObject({
2969
2993
  block: blockIdSchema,
2970
- 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.")
2971
2995
  }),
2972
2996
  output: blockOutput,
2973
2997
  grants: [{ grant: "block-addressee" }],
@@ -3011,7 +3035,7 @@ const OPERATIONS = [
3011
3035
  },
3012
3036
  input: z.strictObject({
3013
3037
  block: blockIdSchema,
3014
- text: text("The answer.")
3038
+ text: text("The answer.", TEXT_MAX)
3015
3039
  }),
3016
3040
  output: z.strictObject({
3017
3041
  block: blockViewSchema,
@@ -3061,17 +3085,17 @@ const OPERATIONS = [
3061
3085
  z.strictObject({
3062
3086
  mode: z.literal("done").describe("The blocking work is done."),
3063
3087
  block: blockIdSchema,
3064
- 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()
3065
3089
  }).describe("Unblock because the work is done."),
3066
3090
  z.strictObject({
3067
3091
  mode: z.literal("reason").describe("Unblock with an explanation."),
3068
3092
  block: blockIdSchema,
3069
- reason: text("Why the block no longer applies.")
3093
+ reason: text("Why the block no longer applies.", TEXT_MAX)
3070
3094
  }).describe("Unblock with a reason."),
3071
3095
  z.strictObject({
3072
3096
  mode: z.literal("withdraw").describe("The author takes their own question back (needs_input only)."),
3073
3097
  block: blockIdSchema,
3074
- 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)
3075
3099
  }).describe("Withdraw the block.")
3076
3100
  ]),
3077
3101
  output: blockOutput,
@@ -3188,8 +3212,8 @@ const OPERATIONS = [
3188
3212
  whenNotToUse: "Use task_return to send the task back to Dev instead."
3189
3213
  },
3190
3214
  input: z.strictObject({
3191
- turn: z.union([turnIdSchema, taskKeySchema]).describe("Turn ID you took (T4); while the project dispatcher is in shadow mode, the task key instead."),
3192
- 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.")
3193
3217
  }),
3194
3218
  output: z.strictObject({
3195
3219
  task: taskViewSchema,
@@ -3251,7 +3275,7 @@ const OPERATIONS = [
3251
3275
  },
3252
3276
  input: z.strictObject({
3253
3277
  turn: turnIdSchema,
3254
- 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)
3255
3279
  }),
3256
3280
  output: z.strictObject({
3257
3281
  task: taskViewSchema,
@@ -3298,9 +3322,9 @@ const OPERATIONS = [
3298
3322
  },
3299
3323
  input: z.discriminatedUnion("mode", [z.strictObject({
3300
3324
  mode: z.literal("correct").describe("Correct a wrong column by hand."),
3301
- task: taskKeySchema,
3325
+ task: taskKeyInputSchema,
3302
3326
  column: z.enum(COLUMN_IDS).exclude(["done"]).describe("Enabled column to put the task in; Done is reached only from the facts."),
3303
- 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)
3304
3328
  })]),
3305
3329
  output: z.strictObject({
3306
3330
  task: taskViewSchema,
@@ -3609,10 +3633,34 @@ const SYSTEMD_SERVICE_SETTINGS = [
3609
3633
  "UMask=0077"
3610
3634
  ];
3611
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
3612
3660
  //#region ../contracts/src/index.ts
3613
3661
  /** Exhaustiveness check: call it in the `default` branch of a switch over a union. */
3614
3662
  function assertNever(value) {
3615
3663
  throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
3616
3664
  }
3617
3665
  //#endregion
3618
- 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.0",
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