@vercel/board 0.53.0 → 0.54.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.
Files changed (70) hide show
  1. package/README.md +4 -3
  2. package/dist/{access-Pcar1gwx.mjs → access-HzqFpgL_.mjs} +1 -1
  3. package/dist/access.d.mts +3 -3
  4. package/dist/access.mjs +5 -5
  5. package/dist/{actors-XKUrjOfO.mjs → actors-D-u6bitG.mjs} +2 -2
  6. package/dist/{auth-C2CxMl2p.mjs → auth-D9ycDQK0.mjs} +34 -12
  7. package/dist/{auth-BoYunD5t.d.mts → auth-ULldUvir.d.mts} +8 -2
  8. package/dist/{backend-DJobr4nr.d.mts → backend-BHN6GTjB.d.mts} +8 -7
  9. package/dist/backend-local.d.mts +1 -1
  10. package/dist/backend-local.mjs +1 -1
  11. package/dist/{chat-provider-BSHlV2lw.d.mts → chat-provider-F7UqWVZK.d.mts} +2 -2
  12. package/dist/cli-commands.d.mts +1 -1
  13. package/dist/cli-commands.mjs +1 -1
  14. package/dist/cli-embedded.d.mts +2 -2
  15. package/dist/cli-embedded.mjs +2 -2
  16. package/dist/cli.mjs +6 -6
  17. package/dist/{client-oYThy3CR.d.mts → client-CFHunEFn.d.mts} +8 -2
  18. package/dist/{commands-B_gbi2sU.mjs → commands-B5SXeo4W.mjs} +14 -9
  19. package/dist/{commands-B6pgzwTI.d.mts → commands-DLPIX7Jw.d.mts} +3 -1
  20. package/dist/{conformance-Cz1Elmgj.mjs → conformance-CyQG0jky.mjs} +3 -4
  21. package/dist/conformance.d.mts +3 -4
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{engine-506f7GEM.mjs → engine-C8wCzkw-.mjs} +2 -2
  24. package/dist/{routes-GF5ukHYX.mjs → errors-DDfXnZ2b.mjs} +875 -4
  25. package/dist/{exports-CF_nUsT5.d.mts → exports-BBmjHyCB.d.mts} +4 -4
  26. package/dist/{exports-CBukc8T3.mjs → exports-JUhj5Bl3.mjs} +119 -70
  27. package/dist/{index-CM2u0wGd.d.mts → index-Ce3SDZ3Y.d.mts} +2 -2
  28. package/dist/index.d.mts +6 -6
  29. package/dist/index.mjs +4 -4
  30. package/dist/index.node.d.mts +7 -7
  31. package/dist/index.node.mjs +4 -4
  32. package/dist/inspect/app.js +69 -69
  33. package/dist/inspect/engine.js +3 -3
  34. package/dist/inspect-BN7V9e-M.mjs +2 -0
  35. package/dist/{inspect-PQsEgXRQ.mjs → inspect-CrVs-iEi.mjs} +2 -2
  36. package/dist/inspect.d.mts +1 -1
  37. package/dist/inspect.mjs +1 -1
  38. package/dist/{local-CwcmqEoa.mjs → local-RoMUU6QX.mjs} +10 -10
  39. package/dist/{main-gNAS2WbP.mjs → main-B_gzTjBR.mjs} +300 -91
  40. package/dist/{middleware-DXiwepsR.mjs → middleware-BY4qqIh3.mjs} +1 -1
  41. package/dist/{provider-WjdBsRLR.d.mts → provider-DgGp4Zej.d.mts} +2 -2
  42. package/dist/{routes-BpvyXQwv.d.mts → routes-DNmQSOvQ.d.mts} +16 -1
  43. package/dist/{serve-Ci5KT11x.mjs → serve-Cz1NynhG.mjs} +6 -6
  44. package/dist/{server-XsbC50nY.mjs → server-CdBXNUxf.mjs} +68 -11
  45. package/dist/{serving-C6Ao7i-7.mjs → serving-C1mhZQqH.mjs} +1 -1
  46. package/dist/{shell-BiCBL1w_.mjs → shell-Cqn38XUs.mjs} +1 -1
  47. package/dist/sync-chat-sdk.d.mts +2 -2
  48. package/dist/sync-github.d.mts +2 -2
  49. package/dist/sync-linear.d.mts +3 -3
  50. package/dist/sync-slack.d.mts +3 -3
  51. package/dist/sync.d.mts +2 -2
  52. package/dist/{task-batch-nqYGszDJ.mjs → task-batch-CVamHB-W.mjs} +4 -5
  53. package/dist/{tokens-tulRtEWx.mjs → tokens-B3gXkQCs.mjs} +2 -2
  54. package/dist/{version-CBjh_ogp.mjs → version-DBaKHEZS.mjs} +1 -1
  55. package/docs/01-board/01-mounting.md +8 -6
  56. package/docs/01-board/03-identity.md +1 -1
  57. package/docs/01-board/05-reading.md +34 -7
  58. package/docs/01-board/09-access.md +11 -2
  59. package/docs/01-board/11-tasks.md +5 -3
  60. package/docs/01-quickstart.md +19 -5
  61. package/docs/03-guides/03-ci.md +71 -43
  62. package/docs/03-guides/04-triage.md +4 -4
  63. package/docs/04-reference/01-cli.md +30 -22
  64. package/docs/04-reference/02-board.md +8 -4
  65. package/docs/04-reference/03-http.md +14 -5
  66. package/docs/04-reference/05-conformance.md +1 -1
  67. package/docs/index.md +7 -5
  68. package/package.json +2 -2
  69. package/dist/errors-Cv0TGBt5.mjs +0 -857
  70. package/dist/inspect-SEaGzhvh.mjs +0 -2
@@ -1,18 +1,17 @@
1
1
  import { a as DIRECT_UPLOAD_BYTES_MAX, l as fileSize } from "./profile-header-O8wC8yk8.mjs";
2
2
  import { m as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-CUSTEFIy.mjs";
3
- import "./routes-GF5ukHYX.mjs";
3
+ import { f as BoardError } from "./errors-DDfXnZ2b.mjs";
4
4
  import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
5
- import { f as BoardError } from "./errors-Cv0TGBt5.mjs";
6
- import { l as shownName } from "./middleware-DXiwepsR.mjs";
5
+ import { l as shownName } from "./middleware-BY4qqIh3.mjs";
7
6
  import { d as parseSchemaId, r as findBlocks, t as block } from "./blocks-CVoBC7ur.mjs";
8
7
  import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
9
- import { t as VERSION } from "./version-CBjh_ogp.mjs";
10
- import { r as PERMISSIONS } from "./access-Pcar1gwx.mjs";
11
- import { c as withMentions } from "./task-batch-nqYGszDJ.mjs";
12
- import { a as isBoardName, c as isApiMessageId, n as createTasksInChunks, t as TasksInChunksError } from "./exports-CBukc8T3.mjs";
13
- import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-B_gbi2sU.mjs";
14
- import { _ as vercelProjectFile, a as vercel, c as boardUrl, d as environmentProfile, f as handFetch, i as handTeam, l as configDir, m as handToken, n as credentialSource, o as http, p as handLogin, r as credentialed, t as board, u as connect } from "./server-XsbC50nY.mjs";
15
- import { n as everyChannel, t as conformance } from "./conformance-Cz1Elmgj.mjs";
8
+ import { t as VERSION } from "./version-DBaKHEZS.mjs";
9
+ import { r as PERMISSIONS } from "./access-HzqFpgL_.mjs";
10
+ import { c as withMentions } from "./task-batch-CVamHB-W.mjs";
11
+ import { a as isBoardName, c as isApiMessageId, n as createTasksInChunks, t as TasksInChunksError } from "./exports-JUhj5Bl3.mjs";
12
+ import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-B5SXeo4W.mjs";
13
+ import { _ as vercelProjectFile, a as vercel, c as boardUrl, d as environmentProfile, f as handFetch, i as handTeam, l as configDir, m as handToken, n as credentialSource, o as http, p as handLogin, r as credentialed, t as board, u as connect } from "./server-CdBXNUxf.mjs";
14
+ import { n as everyChannel, t as conformance } from "./conformance-CyQG0jky.mjs";
16
15
  import { n as displayText, t as byVercelBot } from "./bots-CqPYxkqK.mjs";
17
16
  import { spawn } from "node:child_process";
18
17
  import { createHash, randomUUID } from "node:crypto";
@@ -1105,7 +1104,7 @@ function listed(command) {
1105
1104
  function rootHelp(app, version) {
1106
1105
  const sections = [...groups.map((group) => commands.filter((command) => command.group === group)), app.commands].map((list) => list.filter((command) => !command.hidden));
1107
1106
  const lines = [
1108
- `${app.name} ${version}: a message board you mount in one route`,
1107
+ `${app.name} ${version}: your Vercel team's message board, for people and agents`,
1109
1108
  "",
1110
1109
  `usage: ${app.name} <command> [options]${app.name === "board" ? " (also installed as `vb`)" : ""}`
1111
1110
  ];
@@ -1136,15 +1135,23 @@ function commandHelp(name, path) {
1136
1135
  if (command.filters) {
1137
1136
  section("filters", shown(filters$1).map((option) => [flag(option), option.description]));
1138
1137
  lines.push(" labels match a message or its thread's root; repeated flags all must match");
1138
+ if (command.filtersNote) lines.push(...wrap(command.filtersNote, 78).map((line) => ` ${line}`));
1139
1139
  }
1140
1140
  if (command.examples.length) lines.push("", "examples:", ...command.examples.flatMap((example, index) => [
1141
1141
  ...index ? [""] : [],
1142
1142
  ` ${example.name}`,
1143
1143
  ` ${name} ${example.value}`
1144
1144
  ]));
1145
- lines.push("", `options every command takes: ${name} help`);
1145
+ lines.push("", ...labeled("global:", COMMON.map((option) => flag(globalOptions.find((known) => known.name === option))).join(" "), " "), ...labeled("", `and the rest every command takes: ${name} help`));
1146
1146
  return lines.join("\n");
1147
1147
  }
1148
+ /** The global options a command's page shows: a program's output, who it writes as, and which board. */
1149
+ const COMMON = [
1150
+ "json",
1151
+ "as",
1152
+ "scope",
1153
+ "url"
1154
+ ];
1148
1155
  /**
1149
1156
  * The command `words` name, and its subcommand when they name one (`schedule cancel`, `sources slack
1150
1157
  * read`): what `--help` shows the page of. Null when the first word names no command.
@@ -1270,8 +1277,8 @@ function rerun(...extra) {
1270
1277
  ...typed.slice(at)
1271
1278
  ]];
1272
1279
  }
1273
- /** A command line without `options` and their values. */
1274
- const without = (argv, ...options) => argv.filter((arg, at) => !options.some((option) => arg === option || argv[at - 1] === option || arg.startsWith(`${option}=`)));
1280
+ /** A command line without `options` and their values: a bare `--mentions` has none, so what follows it stays. */
1281
+ const without = (argv, ...options) => argv.filter((arg, at) => !options.some((option) => arg === option || arg.startsWith(`${option}=`) || argv[at - 1] === option && !(OPTIONS[option.slice(2)]?.optionalValue && arg.startsWith("-"))));
1275
1282
  /**
1276
1283
  * This run's command line without `options`, with `extra` in their place: both before any `--`,
1277
1284
  * since what follows it is text, which a way out mustn't change or add options to.
@@ -1419,11 +1426,16 @@ let reached = null;
1419
1426
  let sent = () => null;
1420
1427
  /** How long the message text this run sends is, for a backend's refusal of it to say what to do instead. */
1421
1428
  let sentLength = 0;
1422
- /** The help `words` ask for: a command's page when they name one (`read`, `sources read`), or else every command. */
1429
+ /**
1430
+ * The help `words` ask for: a command's page when they name one (`read`, `sources read`), or with
1431
+ * none, every command. A word that names no command is unknown, as it is without `--help`.
1432
+ */
1423
1433
  function help(words = []) {
1424
1434
  const own = Object.values(app.commands).map((command) => command.spec);
1425
1435
  const path = commandPath(words, [...commands, ...own]);
1426
- return path ? commandHelp(app.name, path) : rootHelp({
1436
+ if (path) return commandHelp(app.name, path);
1437
+ if (words[0] !== void 0 && words[0] !== "help") throw unknownCommand(words[0]);
1438
+ return rootHelp({
1427
1439
  name: app.name,
1428
1440
  commands: own
1429
1441
  }, VERSION);
@@ -2151,7 +2163,10 @@ function failureOf(error) {
2151
2163
  case "board_name_taken": return own("conflict", "board_name_taken");
2152
2164
  case "board_not_granted": return own("permission", "board_not_granted");
2153
2165
  case "watchers_need_project": return own("permission", "watchers_need_project");
2154
- case "unsupported_principal": return own(status === 403 ? "permission" : "usage", "unsupported_principal");
2166
+ case "missing_team": return {
2167
+ ...own("missing_input", "missing_scope", [{ instruction: "Use a team's board: add --scope <TEAM_ID>" }, { instruction: "Or set VERCEL_ORG_ID to its ID" }]),
2168
+ actionRequired: true
2169
+ };
2155
2170
  case "invalid_board_name": return own("usage", "invalid_arguments", [helpRecovery()]);
2156
2171
  case "too_many_redirects": return own("network", "network_error");
2157
2172
  case "invalid_duration": return own("usage", "invalid_arguments", [helpRecovery()]);
@@ -2245,11 +2260,11 @@ function failureOf(error) {
2245
2260
  }] : []);
2246
2261
  if (code === "private_boards_unavailable") return theirs("limit", code, `Can't ${doing()}. This team's plan has no private boards.`, [{ instruction: "Keep the board open to the whole team, or move the team to a plan with private boards" }]);
2247
2262
  if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
2248
- if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", sent() === "the token you passed" ? [{ instruction: "Pass a token it accepts" }] : sent() === "BOARD_TOKEN" ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : [{
2263
+ if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", sent() === "the token you passed" ? [{ instruction: "Pass a token it accepts" }] : sent() === "BOARD_TOKEN" ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : sent() === "GitHub Actions OIDC" ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN" }] : [{
2249
2264
  instruction: "Log in again",
2250
2265
  argv: ["vercel", "login"]
2251
2266
  }]);
2252
- if (status === 403) return theirs("permission", "permission_denied", `You can't ${doing()}.`);
2267
+ if (status === 403) return theirs("permission", "permission_denied", `You can't ${doing()}.`, refusedRecoveries());
2253
2268
  if (status === 404) {
2254
2269
  const thing = missing();
2255
2270
  return thing ? {
@@ -2301,10 +2316,74 @@ function failureOf(error) {
2301
2316
  if (status === 413) return theirs("limit", "payload_too_large", `Can't ${doing()}. It's too large for the board.`);
2302
2317
  if (status === 501 && code === "no_direct_uploads") return theirs("limit", "payload_too_large", `Can't ${doing()}. The file is too large for this board.`, [{ instruction: "Compress it, or split it into smaller files" }]);
2303
2318
  if (status === 429) return theirs("rate_limit", "rate_limited", `Can't ${doing()}. Too many requests to the board.`, [{ instruction: wait !== void 0 ? `Wait ${waitFor(wait)}, then run it again` : "Wait a minute, then run it again" }]);
2304
- if (status === 501) return theirs("platform", specific("not_supported"), `Can't ${doing()}. This board doesn't support it.`);
2319
+ if (status === 501) return theirs("platform", specific("not_supported"), `Can't ${doing()}. This board doesn't support it.`, unsupportedRecoveries());
2305
2320
  if (code === "unreachable") return theirs("network", "network_error", "Couldn't reach the board.");
2306
2321
  return theirs("platform", "api_error", `Failed to ${doing()}.`);
2307
2322
  }
2323
+ /** The options that say which board this run is on, and as whom, as typed: what a way out to another command keeps. */
2324
+ const onThisBoard = () => [
2325
+ ...flags.url !== void 0 ? ["--url", flags.url] : [],
2326
+ ...(flags.scope ?? flags.team) !== void 0 ? ["--scope", flags.scope ?? flags.team] : [],
2327
+ ...flags.name !== void 0 ? ["--name", flags.name] : [],
2328
+ ...flags.as ? ["--as", flags.as] : []
2329
+ ];
2330
+ /** Where to go from a 403: what you may do on this board, and who can let you do more. */
2331
+ const refusedRecoveries = () => [{
2332
+ instruction: "See what you can do on this board",
2333
+ argv: [
2334
+ ...cli(),
2335
+ "whoami",
2336
+ ...onThisBoard()
2337
+ ]
2338
+ }, { instruction: "Or ask someone who manages the board's grants to give you access" }];
2339
+ /** The filters a board answers 501 to on a read when it keeps no index of them, as Vercel's does. */
2340
+ const UNINDEXED = [
2341
+ "--by",
2342
+ "--mentions",
2343
+ "--source",
2344
+ "--text"
2345
+ ];
2346
+ /**
2347
+ * What to run instead of what a board answered 501 to, by what this run asked for: the same without
2348
+ * the part a board may not do (a read's search filters or its every channel, a post's `--sync`, a
2349
+ * schedule's files). Nothing when it asked for none of them.
2350
+ */
2351
+ function unsupportedRecoveries() {
2352
+ const { command, args } = current;
2353
+ const given = (option) => flags[option.slice(2)] !== void 0;
2354
+ if (command === "read") {
2355
+ const filtered = UNINDEXED.filter(given);
2356
+ const target = args[0];
2357
+ const whole = target === void 0 || target.endsWith("/") && !isMessageRef(target);
2358
+ if (!filtered.length && !whole) return [];
2359
+ const argv = rerunWithout(filtered);
2360
+ if (whole) {
2361
+ const at = argv.indexOf(positionals[0], cli().length);
2362
+ argv.splice(at + 1, target === void 0 ? 0 : 1, "<CHANNEL>");
2363
+ }
2364
+ return [...whole ? [{
2365
+ instruction: "See the channels",
2366
+ argv: [
2367
+ ...cli(),
2368
+ "channels",
2369
+ ...target !== void 0 ? [target] : [],
2370
+ ...onThisBoard()
2371
+ ]
2372
+ }] : [], {
2373
+ instruction: whole ? `Read one channel at a time${filtered.length ? `, without ${filtered.join(" or ")}` : ""}` : `Read it without ${filtered.join(" or ")}, and look through it`,
2374
+ argv
2375
+ }];
2376
+ }
2377
+ if ((command === "post" || command === "reply") && given("--sync")) return [{
2378
+ instruction: "Post it without --sync",
2379
+ argv: rerunWithout(["--sync"])
2380
+ }];
2381
+ if (command === "schedule" && given("--attach")) return [{
2382
+ instruction: "Schedule the text without its files",
2383
+ argv: rerunWithout(["--attach"])
2384
+ }];
2385
+ return [];
2386
+ }
2308
2387
  /** `42s`, `2m`: a wait the way people say it. */
2309
2388
  const waitFor = (seconds) => seconds < 120 ? `${Math.max(1, seconds)}s` : `${Math.ceil(seconds / 60)}m`;
2310
2389
  /** How this run ends with `failure`: shown on stderr, or by the app, and its exit code. */
@@ -2333,6 +2412,21 @@ function vercelBoard(url) {
2333
2412
  ...team ? { team } : {}
2334
2413
  };
2335
2414
  }
2415
+ /**
2416
+ * Whether this run's board is a team's board in Vercel's API, as its flags and environment say,
2417
+ * without a request: undefined when they don't say (an in-process handle, or no board to use).
2418
+ */
2419
+ function onTeamBoard() {
2420
+ if (io.board) return void 0;
2421
+ try {
2422
+ if (flags.url !== void 0) return vercelBoard(flags.url) !== null;
2423
+ if (flags.scope !== void 0 || flags.team !== void 0 || flags.name !== void 0) return true;
2424
+ const url = configuredUrl();
2425
+ return url === null || vercelBoard(url) !== null;
2426
+ } catch {
2427
+ return;
2428
+ }
2429
+ }
2336
2430
  /** Who the handle writes as: `--as`'s profile (with `--avatar`), or what the environment says (`BOARD_PROFILE`), else yourself. */
2337
2431
  function profileFlag() {
2338
2432
  if (flags.avatar !== void 0 && !flags.as) throw usage("--avatar is the avatar of the profile --as names: pass --as too.", { reason: "missing_arguments" });
@@ -2699,7 +2793,7 @@ async function run(command, args) {
2699
2793
  ...working,
2700
2794
  ...mentionedIn([thread.message, ...replies])
2701
2795
  ])].filter((id) => !authors.has(id));
2702
- const listed = unnamed.length ? (await board.actors().catch(() => [])).filter((a) => unnamed.includes(a.id)) : [];
2796
+ const listed = unnamed.length ? await board.actors({ id: unnamed }).catch(() => []) : [];
2703
2797
  const known = new Map(listed.map((a) => [a.id, actorName(a)]));
2704
2798
  out(formatThreads([thread.message, ...replies], known, new Map(listed.map((a) => [a.id, a.handle]))));
2705
2799
  if (!narrowed) for (const schedule of thread.schedules ?? []) out(formatSchedule(schedule, { pad: " " }));
@@ -2707,7 +2801,7 @@ async function run(command, args) {
2707
2801
  }
2708
2802
  const limit = flags.limit ? Number(flags.limit) : 50;
2709
2803
  if (flags.before !== void 0 && flags.after !== void 0) throw usage("Can't use --before with --after. One pages back, the other reads forward.");
2710
- const peek = !(target !== void 0 && !target.endsWith("/") && Object.keys(filters()).length === 0) && !flags.json && flags.before === void 0 && Number.isInteger(limit) && limit >= 1 && limit < 500;
2804
+ const peek = !(target !== void 0 && !target.endsWith("/") && Object.keys(filters()).every((key) => key === "mentions" || key === "text")) && !flags.json && flags.before === void 0 && Number.isInteger(limit) && limit >= 1 && limit < 500;
2711
2805
  const query = {
2712
2806
  ...filters(target),
2713
2807
  ...flags.before !== void 0 ? { before: flags.before } : {},
@@ -2724,7 +2818,8 @@ async function run(command, args) {
2724
2818
  ...listed,
2725
2819
  threads: flags.after !== void 0 ? listed.threads.slice(0, limit) : listed.threads.slice(-limit)
2726
2820
  } : listed;
2727
- if (!page.threads.length && target) {
2821
+ const scanned = typeof listed.scanned === "number" ? listed.scanned : void 0;
2822
+ if (!page.threads.length && target && !scanned) {
2728
2823
  const channels = (await everyChannel(board)).map((c) => c.path);
2729
2824
  if (!channels.some((path) => path === target || path.startsWith(target.replace(/\/?$/, "/")))) {
2730
2825
  const guess = closest(target, channels);
@@ -2747,12 +2842,13 @@ async function run(command, args) {
2747
2842
  const roots = page.threads.map(({ message }) => message);
2748
2843
  const wrote = new Set(page.threads.flatMap(({ message, last }) => last ? [message.by.actor, last.by.actor] : [message.by.actor]));
2749
2844
  const unnamed = mentionedIn(roots).filter((id) => !wrote.has(id));
2750
- const handles = new Map(unnamed.length ? (await client().actors().catch(() => [])).filter((a) => unnamed.includes(a.id)).map((a) => [a.id, a.handle]) : []);
2845
+ const handles = new Map(unnamed.length ? (await board.actors({ id: unnamed }).catch(() => [])).map((a) => [a.id, a.handle]) : []);
2751
2846
  out(formatThreadSummaries(page.threads, {
2752
2847
  channel: !target || target.endsWith("/"),
2753
2848
  handles
2754
2849
  }));
2755
2850
  }
2851
+ if (scanned !== void 0) out(`\n(looked through ${scanned} ${scanned === 1 ? "thread" : "threads"}, at the first and latest message of each: a match under a newer reply is not found)`);
2756
2852
  const latest = page.threads.at(-1);
2757
2853
  if (more && flags.after !== void 0 && latest) {
2758
2854
  if (![
@@ -2768,6 +2864,16 @@ async function run(command, args) {
2768
2864
  }
2769
2865
  if (more) out(older !== void 0 ? `\n(older not shown: ${commandLine(rerunWithout(["--before"], "--before", older))})` : limit < 500 ? `\n(older not shown: ${commandLine(rerunWithout(["--limit", "-n"], "--limit", String(Math.min(500, limit * 2))))})` : `\n(older not shown: 500 is the most a read lists, so read one channel and page back with --before, or narrow it with --label)`);
2770
2866
  if (flags.before !== void 0) return 0;
2867
+ if (scanned !== void 0) {
2868
+ const argv = rerunWithout([
2869
+ "--after",
2870
+ "--limit",
2871
+ "-n"
2872
+ ], "--after", String(page.cursor));
2873
+ argv[argv.indexOf("read", cli().length)] = "wait";
2874
+ out(`\nnew since then: ${commandLine(argv)}`);
2875
+ return 0;
2876
+ }
2771
2877
  out(`\nnew since then: ${commandLine(rerunWithout(["--after"], "--after", String(page.cursor)))}`);
2772
2878
  return 0;
2773
2879
  }
@@ -3263,21 +3369,28 @@ async function run(command, args) {
3263
3369
  default: {
3264
3370
  const own = app.commands[command];
3265
3371
  if (own) return own.run(args, context());
3266
- const guess = closest(command, [...commands.flatMap((known) => [known.name, ...known.aliases ?? []]), ...Object.keys(app.commands)]);
3267
- const said = Object.hasOwn(OTHER_NAMES, command.toLowerCase()) ? OTHER_NAMES[command.toLowerCase()] : void 0;
3268
- throw usage(`Unknown command ${command} for ${named()}.${said ? "" : guess ? ` Did you mean ${guess}?` : ""}`, {
3269
- reason: "unknown_command",
3270
- next: [...said ? [{
3271
- instruction: said.instruction,
3272
- argv: [...cli(), ...said.argv]
3273
- }] : [], {
3274
- instruction: "See all commands",
3275
- argv: [...cli(), "--help"]
3276
- }]
3277
- });
3372
+ throw unknownCommand(command);
3278
3373
  }
3279
3374
  }
3280
3375
  }
3376
+ /** Every name a command runs by here: board's, their aliases, and the app's own. */
3377
+ const commandNames = () => [...commands.flatMap((known) => [known.name, ...known.aliases ?? []]), ...Object.keys(app.commands)];
3378
+ /** `command` names nothing here: the closest that does, or what it goes by here. */
3379
+ function unknownCommand(command) {
3380
+ const guess = closest(command, commandNames());
3381
+ const other = Object.hasOwn(OTHER_NAMES, command.toLowerCase()) ? OTHER_NAMES[command.toLowerCase()] : void 0;
3382
+ const said = other?.teams && onTeamBoard() !== false ? other.teams : other;
3383
+ return usage(`Unknown command ${command} for ${named()}.${said ? "" : guess ? ` Did you mean ${guess}?` : ""}`, {
3384
+ reason: "unknown_command",
3385
+ next: [...said ? [{
3386
+ instruction: said.instruction,
3387
+ argv: [...cli(), ...said.argv]
3388
+ }] : [], {
3389
+ instruction: "See all commands",
3390
+ argv: [...cli(), "--help"]
3391
+ }]
3392
+ });
3393
+ }
3281
3394
  /** What `tasks` does to a task, by the word after it: any other word is a channel to list. */
3282
3395
  const TASK_VERBS = /* @__PURE__ */ new Set([
3283
3396
  "create",
@@ -3328,7 +3441,9 @@ function seconds(flag) {
3328
3441
  */
3329
3442
  async function createPlan(target, text, path) {
3330
3443
  if (isMessageRef(target)) throw usage(`--file holds a plan, which starts threads in a channel, and ${ref(target)} is a thread.`);
3331
- const own = text !== void 0 ? "text" : [
3444
+ if (text !== void 0) throw usage("Text is one task's: with --file, each task in the file has its own.");
3445
+ const parsed = await planSource(path);
3446
+ const own = [
3332
3447
  "label",
3333
3448
  "needs",
3334
3449
  "for",
@@ -3336,9 +3451,9 @@ async function createPlan(target, text, path) {
3336
3451
  "lease",
3337
3452
  "no-sync"
3338
3453
  ].find((name) => flags[name] !== void 0 && flags[name] !== false);
3339
- if (own !== void 0) throw usage(`${own === "text" ? "Text" : `--${own}`} is one task's: with --file, each task in the file has its own.`);
3454
+ if (own !== void 0) throw usage(`--${own} is one task's: with --file, each task in the file has its own.`);
3340
3455
  const board = client();
3341
- const tasks = await planFrom(path, board);
3456
+ const tasks = await planFrom(parsed, path, board);
3342
3457
  sentLength = Math.max(0, ...tasks.map((task) => typeof task.text === "string" ? task.text.length : 0));
3343
3458
  const key = flags["idempotency-key"] ?? crypto.randomUUID();
3344
3459
  let made;
@@ -3446,8 +3561,12 @@ function checkPlan(plan, where) {
3446
3561
  }
3447
3562
  }
3448
3563
  }
3449
- /** The tasks a plan's `--file` holds: a JSON array, from the file or from stdin for `-`. An ID may be written `#812`, and `for` as a profile's name. */
3450
- async function planFrom(path, board) {
3564
+ /**
3565
+ * What a plan's `--file` holds, as JSON: the file, or stdin for `-`. Prose is the likeliest slip,
3566
+ * --file carried over from post, where it's the text: it says the same command with the file on
3567
+ * stdin, `-` as the text, and the options it was given.
3568
+ */
3569
+ async function planSource(path) {
3451
3570
  const where = path === "-" ? "stdin" : path;
3452
3571
  let source;
3453
3572
  if (path === "-") source = await io.stdin();
@@ -3459,12 +3578,16 @@ async function planFrom(path, board) {
3459
3578
  });
3460
3579
  source = new TextDecoder().decode(data);
3461
3580
  }
3462
- let parsed;
3463
3581
  try {
3464
- parsed = JSON.parse(source);
3582
+ return JSON.parse(source);
3465
3583
  } catch {
3466
- throw usage(`${where} isn't JSON: --file on tasks create is a plan of tasks.`, { next: [{ instruction: "For one task's text, pass it, or - to read it from stdin" }, planHelp()] });
3584
+ const piped = `${commandLine(rerunWithout(["--file"], "-"))}${path === "-" ? "" : ` < ${commandLine([path])}`}`;
3585
+ throw usage(`${where} isn't JSON: --file on tasks create is a plan of tasks.`, { next: [{ instruction: `One task's text goes on stdin, as -: ${piped}` }, planHelp()] });
3467
3586
  }
3587
+ }
3588
+ /** The tasks a plan's `--file` holds: a JSON array. An ID may be written `#812`, and `for` as a profile's name. */
3589
+ async function planFrom(parsed, path, board) {
3590
+ const where = path === "-" ? "stdin" : path;
3468
3591
  const shape = "A plan is a JSON array of tasks: [{\"key\": \"fix\", \"text\": \"…\"}, {\"text\": \"…\", \"needs\": [{\"key\": \"fix\"}]}].";
3469
3592
  if (!Array.isArray(parsed) || parsed.length === 0 || parsed.some((task) => typeof task !== "object" || task === null || Array.isArray(task))) throw usage(`${where} holds no tasks. ${shape}`, { next: [planHelp()] });
3470
3593
  const plan = parsed;
@@ -3542,22 +3665,69 @@ function printClaim(task, claim, more = {}) {
3542
3665
  */
3543
3666
  async function heldBy(board, claims, id) {
3544
3667
  const stored = await claims.get(id);
3545
- if (!stored) throw new Failed({
3668
+ if (stored) return board.tasks.held(id, stored);
3669
+ const none = `You hold no claim on task ${ref(id)} as ${writesAs() ?? "yourself"}.`;
3670
+ const claim = {
3671
+ instruction: "Claim it",
3672
+ argv: [
3673
+ ...cli(),
3674
+ "tasks",
3675
+ "claim",
3676
+ id,
3677
+ ...asTyped()
3678
+ ]
3679
+ };
3680
+ const task = await board.thread(id).then(({ message }) => message.task, () => void 0);
3681
+ const see = {
3682
+ instruction: "See where it stands",
3683
+ argv: [
3684
+ ...cli(),
3685
+ "read",
3686
+ id
3687
+ ]
3688
+ };
3689
+ if (task?.state === "blocked") throw new Failed({
3546
3690
  class: "conflict",
3547
3691
  reason: "claim_not_held",
3548
- message: `You hold no claim on task ${ref(id)} as ${writesAs() ?? "yourself"}.`,
3692
+ message: `${none} It's held for a person: claim it once the hold lifts.`,
3549
3693
  next: [{
3550
- instruction: "Claim it",
3694
+ instruction: "As its owner, lift the hold, then claim it",
3551
3695
  argv: [
3552
3696
  ...cli(),
3553
3697
  "tasks",
3554
- "claim",
3555
- id,
3556
- ...asTyped()
3698
+ "unblock",
3699
+ id
3557
3700
  ]
3558
- }]
3701
+ }, see]
3702
+ });
3703
+ if (task?.state === "waiting") {
3704
+ const needs = task.needs.map(ref);
3705
+ throw new Failed({
3706
+ class: "conflict",
3707
+ reason: "claim_not_held",
3708
+ message: `${none} It waits for what it needs${needs.length ? ` (${needs.join(", ")})` : ""}: claim it once those complete.`,
3709
+ next: [{
3710
+ instruction: "See what it waits for",
3711
+ argv: [
3712
+ ...cli(),
3713
+ "read",
3714
+ id
3715
+ ]
3716
+ }]
3717
+ });
3718
+ }
3719
+ if (task?.state === "completed" || task?.state === "failed" || task?.state === "canceled") throw new Failed({
3720
+ class: "conflict",
3721
+ reason: "claim_not_held",
3722
+ message: `${none} It's ${task.state} already.`,
3723
+ next: [see]
3724
+ });
3725
+ throw new Failed({
3726
+ class: "conflict",
3727
+ reason: "claim_not_held",
3728
+ message: none,
3729
+ next: [claim]
3559
3730
  });
3560
- return board.tasks.held(id, stored);
3561
3731
  }
3562
3732
  /** A write a claim makes. One the board answers `claim_lost` is over: the CLI forgets it, and the failure says how to claim again. */
3563
3733
  async function withClaim(claims, id, write) {
@@ -3569,11 +3739,47 @@ async function withClaim(claims, id, write) {
3569
3739
  }
3570
3740
  }
3571
3741
  /**
3742
+ * `--label` on `claim --ready` and `run --ready`: each an exact `key=value`, the one thing a claim
3743
+ * matches. The list's `key=a|b` and bare `key` would match nothing, or the value `a|b`, and wait
3744
+ * out its `--wait` without a word: they're refused, with the claim of one value and the list.
3745
+ */
3746
+ function readyLabels(values, target, verb) {
3747
+ for (const value of values) {
3748
+ const at = value.indexOf("=");
3749
+ const options = at > 0 ? value.slice(at + 1).split("|") : [];
3750
+ if (at > 0 && options.length < 2) continue;
3751
+ const key = at > 0 ? value.slice(0, at) : value;
3752
+ if (at === 0) throw usage(`--label on ${verb} --ready takes key=value, and ${value} has no key before its =.`);
3753
+ const listed = {
3754
+ instruction: "See what's ready, and their labels",
3755
+ argv: [
3756
+ ...cli(),
3757
+ "tasks",
3758
+ target,
3759
+ "--state",
3760
+ "ready",
3761
+ "--label",
3762
+ value
3763
+ ]
3764
+ };
3765
+ if (at === -1) throw usage(`--label on ${verb} --ready takes key=value: ${value} has no value, and a claim matches one exactly.`, { next: [listed] });
3766
+ const one = `${key}=${options[0]}`;
3767
+ const dash = typed.indexOf("--");
3768
+ const ours = (index) => dash === -1 || index < dash;
3769
+ const again = [...cli(), ...typed.map((arg, index) => !ours(index) ? arg : arg === value && typed[index - 1] === "--label" ? one : arg === `--label=${value}` ? `--label=${one}` : arg)];
3770
+ throw usage(`--label on ${verb} --ready takes one value: ${value} has ${options.length}, and a claim matches one exactly.`, { next: [{
3771
+ instruction: `Claim one with ${one}`,
3772
+ argv: again
3773
+ }, listed] });
3774
+ }
3775
+ return labelPairs(values);
3776
+ }
3777
+ /**
3572
3778
  * Claims a task for this run, by its ID or with `--ready` the oldest ready one in `target`, and
3573
3779
  * keeps the claim. With nothing ready it fails: `nothing_ready`, or `timeout` once `--wait` ran
3574
3780
  * out, as `wait` does. Stopped while it waits, it answers the exit code instead.
3575
3781
  */
3576
- async function claimFor(board, claims, target) {
3782
+ async function claimFor(board, claims, target, verb) {
3577
3783
  const lease = seconds("lease");
3578
3784
  if (!flags.ready) {
3579
3785
  for (const given of [
@@ -3604,7 +3810,7 @@ async function claimFor(board, claims, target) {
3604
3810
  try {
3605
3811
  claim = await board.tasks.claim({
3606
3812
  channel: target,
3607
- ...flags.label?.length ? { label: labelPairs(flags.label) } : {},
3813
+ ...flags.label?.length ? { label: readyLabels(flags.label, target, verb) } : {},
3608
3814
  ...flags.from?.length ? { from: flags.from } : {},
3609
3815
  ...wait !== void 0 ? { wait } : {},
3610
3816
  ...lease !== void 0 ? { lease } : {},
@@ -3763,7 +3969,7 @@ async function tasks(args) {
3763
3969
  if (rest.length > 1) throw usage(`tasks claim takes one ${flags.ready ? "channel" : "task"}: ${rest[1]} is one too many.`);
3764
3970
  if (!flags.ready && rest[0] === void 0) throw usage("Missing the task to claim: its ID, or --ready and a channel.", { reason: "missing_arguments" });
3765
3971
  const { board, claims } = tasksOn();
3766
- const claim = await claimFor(board, claims, rest[0]);
3972
+ const claim = await claimFor(board, claims, rest[0], "claim");
3767
3973
  if (typeof claim === "number") return claim;
3768
3974
  printClaim(claim.task, claim);
3769
3975
  return 0;
@@ -3793,7 +3999,7 @@ async function tasks(args) {
3793
3999
  next: []
3794
4000
  });
3795
4001
  const { board, claims } = tasksOn();
3796
- const claim = await claimFor(board, claims, before[0]);
4002
+ const claim = await claimFor(board, claims, before[0], "run");
3797
4003
  if (typeof claim === "number") return claim;
3798
4004
  const id = claim.task.id;
3799
4005
  const lease = seconds("lease");
@@ -4143,35 +4349,33 @@ function stateCommand() {
4143
4349
  if (flags.label?.some((pair) => pair === "board.task" || pair.startsWith("board.task=")) && command === "post" && args[0] !== void 0 && !isMessageRef(args[0])) return [tasksDo("Start it as a task", "create", args[0], "<TEXT>")];
4144
4350
  return [];
4145
4351
  }
4146
- /** Words for a command this CLI names otherwise, and the command they mean. */
4147
- const OTHER_NAMES = {
4148
- search: {
4149
- instruction: "Search is a filter on read",
4150
- argv: [
4151
- "read",
4152
- "<CHANNEL>",
4153
- "--text",
4154
- "<PHRASE>"
4155
- ]
4156
- },
4157
- find: {
4158
- instruction: "Search is a filter on read",
4159
- argv: [
4160
- "read",
4161
- "<CHANNEL>",
4162
- "--text",
4163
- "<PHRASE>"
4164
- ]
4165
- },
4166
- grep: {
4167
- instruction: "Search is a filter on read",
4352
+ /** Search: a filter on read. Vercel's board keeps no index of text, so there it looks through a page of a channel's threads. */
4353
+ const SEARCH = {
4354
+ instruction: "Search is a filter on read",
4355
+ argv: [
4356
+ "read",
4357
+ "<CHANNEL>",
4358
+ "--text",
4359
+ "<PHRASE>"
4360
+ ],
4361
+ teams: {
4362
+ instruction: "Search a channel's latest threads, a page at a time, since this board keeps no text search",
4168
4363
  argv: [
4169
4364
  "read",
4170
4365
  "<CHANNEL>",
4171
4366
  "--text",
4172
4367
  "<PHRASE>"
4173
4368
  ]
4174
- },
4369
+ }
4370
+ };
4371
+ /**
4372
+ * Words for a command this CLI names otherwise, and the command they mean: on a team's board in
4373
+ * Vercel's API, `teams`, where it reads one channel's page (or when nothing says which board).
4374
+ */
4375
+ const OTHER_NAMES = {
4376
+ search: SEARCH,
4377
+ find: SEARCH,
4378
+ grep: SEARCH,
4175
4379
  list: {
4176
4380
  instruction: "List a channel's threads with read",
4177
4381
  argv: ["read", "<CHANNEL>"]
@@ -4303,23 +4507,20 @@ const OTHER_NAMES = {
4303
4507
  ]
4304
4508
  },
4305
4509
  claim: {
4306
- instruction: "Claim a thread with a label, unless someone has",
4510
+ instruction: "Hold a task with tasks claim",
4307
4511
  argv: [
4308
- "label",
4309
- "<ID>",
4310
- "owner=<YOU>",
4311
- "--if-unset",
4312
- "owner"
4512
+ "tasks",
4513
+ "claim",
4514
+ "<ID>"
4313
4515
  ]
4314
4516
  },
4315
4517
  assign: {
4316
- instruction: "Claim a thread with a label, unless someone has",
4518
+ instruction: "Keep a task for one of its owner's profiles",
4317
4519
  argv: [
4318
- "label",
4520
+ "tasks",
4521
+ "assign",
4319
4522
  "<ID>",
4320
- "owner=<YOU>",
4321
- "--if-unset",
4322
- "owner"
4523
+ "<PROFILE>"
4323
4524
  ]
4324
4525
  },
4325
4526
  tag: {
@@ -4340,7 +4541,15 @@ const OTHER_NAMES = {
4340
4541
  },
4341
4542
  mentions: {
4342
4543
  instruction: "Mentions are a filter on read and wait",
4343
- argv: ["read", "--mentions"]
4544
+ argv: ["read", "--mentions"],
4545
+ teams: {
4546
+ instruction: "Read what mentions you in a channel's latest threads, then wait from where it stops",
4547
+ argv: [
4548
+ "read",
4549
+ "<CHANNEL>",
4550
+ "--mentions"
4551
+ ]
4552
+ }
4344
4553
  },
4345
4554
  watch: {
4346
4555
  instruction: "Block for the next match with wait, or follow live with tail",
@@ -1,5 +1,5 @@
1
1
  import { _ as NewLabels, m as MESSAGE_TEXT_MAX } from "./schemas-CUSTEFIy.mjs";
2
- import { t as HttpError } from "./errors-Cv0TGBt5.mjs";
2
+ import { t as HttpError } from "./errors-DDfXnZ2b.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/client/ids.ts
5
5
  const hex = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
@@ -1,5 +1,5 @@
1
- import { Ft as SourceJoin, Gn as ExternalEvent, Jn as Link, Kn as ExternalFile, Rn as Actor, Rt as SourceRead, Wn as ExternalAuthor, qn as ExternalLink, s as BoardEventView, st as MessageView } from "./routes-BpvyXQwv.mjs";
2
- import { t as BoardClient } from "./client-oYThy3CR.mjs";
1
+ import { Jn as ExternalEvent, Rt as SourceJoin, Vn as Actor, Vt as SourceRead, Xn as ExternalLink, Yn as ExternalFile, Zn as Link, qn as ExternalAuthor, u as BoardEventView, ut as MessageView } from "./routes-DNmQSOvQ.mjs";
2
+ import { t as BoardClient } from "./client-CFHunEFn.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/contract/bots.d.ts
5
5
  /**