@vercel/board 0.55.0 → 0.57.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 (90) hide show
  1. package/dist/{access-HzqFpgL_.mjs → access-CIj7v_Dr.mjs} +1 -1
  2. package/dist/access.d.mts +2 -2
  3. package/dist/access.mjs +4 -4
  4. package/dist/{actors-D-u6bitG.mjs → actors-DVDTqjm7.mjs} +2 -2
  5. package/dist/{auth-D9ycDQK0.mjs → auth-BDWGvFWl.mjs} +2 -2
  6. package/dist/{auth-ULldUvir.d.mts → auth-C0Mla9OU.d.mts} +1 -1
  7. package/dist/{backend-BHN6GTjB.d.mts → backend-BuqwQbb4.d.mts} +6 -22
  8. package/dist/backend-local.d.mts +1 -1
  9. package/dist/backend-local.mjs +1 -1
  10. package/dist/backend-postgres/blob-vercel.d.mts +8 -0
  11. package/dist/backend-postgres/blob-vercel.mjs +81 -0
  12. package/dist/backend-postgres/scheduler-vercel.d.mts +2 -0
  13. package/dist/backend-postgres/scheduler-vercel.mjs +2 -0
  14. package/dist/backend-postgres.d.mts +74 -0
  15. package/dist/backend-postgres.mjs +3229 -0
  16. package/dist/blob-DjS53D1A.d.mts +35 -0
  17. package/dist/{chat-provider-F7UqWVZK.d.mts → chat-provider-CpYdXEpI.d.mts} +2 -2
  18. package/dist/cli-commands.mjs +1 -1
  19. package/dist/cli-embedded.d.mts +2 -2
  20. package/dist/cli-embedded.mjs +2 -2
  21. package/dist/cli.mjs +6 -6
  22. package/dist/{client-CFHunEFn.d.mts → client-B0DGOt7P.d.mts} +1 -1
  23. package/dist/{commands-CZUxX6HF.mjs → commands-7FY_8p92.mjs} +4 -15
  24. package/dist/{conformance-BNiLcKra.mjs → conformance-FiQ68adg.mjs} +2 -2
  25. package/dist/conformance.d.mts +1 -1
  26. package/dist/conformance.mjs +1 -1
  27. package/dist/{engine-C8wCzkw-.mjs → engine-B_CjnE3G.mjs} +3 -3
  28. package/dist/{errors-DDfXnZ2b.mjs → errors-BfMR39F0.mjs} +60 -17
  29. package/dist/errors-DBZtbfph.d.mts +19 -0
  30. package/dist/{exports-BBmjHyCB.d.mts → exports-BvJTIorX.d.mts} +5 -4
  31. package/dist/{exports-FRbxGU5M.mjs → exports-x-ioAfbp.mjs} +23 -14
  32. package/dist/{index-Ce3SDZ3Y.d.mts → index-DuibwQf9.d.mts} +2 -2
  33. package/dist/index.d.mts +6 -5
  34. package/dist/index.mjs +4 -4
  35. package/dist/index.node.d.mts +7 -6
  36. package/dist/index.node.mjs +4 -4
  37. package/dist/inspect/app.js +35 -35
  38. package/dist/{inspect-Aomn2jXK.mjs → inspect-BFnDSdsq.mjs} +2 -2
  39. package/dist/inspect-BuNsu2z6.mjs +2 -0
  40. package/dist/inspect.d.mts +1 -1
  41. package/dist/inspect.mjs +1 -1
  42. package/dist/{internal-CvsrprnU-CEPOUpAv.mjs → internal-CvsrprnU-DhZF6sZK.mjs} +43 -1
  43. package/dist/{local-Dn0vv-1e.mjs → local-Bt1-jA9A.mjs} +129 -3956
  44. package/dist/local-Gp8pqHSu.mjs +98 -0
  45. package/dist/{main-CSuYOx6C.mjs → main-Du-mKQZn.mjs} +128 -32
  46. package/dist/{memory-wmUDblhm.mjs → memory-74hyK6eH.mjs} +3 -3
  47. package/dist/{mentions-CnWt9Z5b.mjs → mentions-DBGmqkr2.mjs} +5 -1
  48. package/dist/{middleware-BY4qqIh3.mjs → middleware-bIABV895.mjs} +1 -1
  49. package/dist/{provider-DgGp4Zej.d.mts → provider-BNVyVKtH.d.mts} +2 -2
  50. package/dist/{routes-DNmQSOvQ.d.mts → routes-CSnxZyyb.d.mts} +2 -2
  51. package/dist/{serve-_qRPIp-J.mjs → serve-xOoxwq7T.mjs} +6 -6
  52. package/dist/{server-24oEf9i9.mjs → server-BSexF7Bk.mjs} +8 -8
  53. package/dist/server-DX7mM6nm-Cq1xPyqJ.mjs +3769 -0
  54. package/dist/{serving-C1mhZQqH.mjs → serving-ByD4TOOU.mjs} +1 -1
  55. package/dist/{shell-DB4WVhfU.mjs → shell-0nWQEqh3.mjs} +5 -1
  56. package/dist/{sql-D0MqINA6.mjs → sql-CvBbb5Ui.mjs} +33 -22
  57. package/dist/{sqlite-Dj2ZEtgy.mjs → sqlite-DtfrT_EP.mjs} +3 -3
  58. package/dist/{sqlite-db-DjbTlUwN.mjs → sqlite-db-DSVlzQjv.mjs} +2 -2
  59. package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +5 -0
  60. package/dist/{store-N8PXxDAS-BdL4Sq-f.mjs → store-codec-pAG2oPgQ-DbEYfF5Y.mjs} +2 -6
  61. package/dist/{store-memory-CKQVEzXN.mjs → store-memory-DOMraCLN.mjs} +3 -2
  62. package/dist/store-memory-XNDFHASI.mjs +2 -0
  63. package/dist/{store-polling-BZt2Rf3D-oh3aU_An.mjs → store-polling-BZt2Rf3D-nlZUQLz2.mjs} +1 -1
  64. package/dist/store-sqlite-Cs8dH9EX.mjs +2 -0
  65. package/dist/{store-sqlite-D6fIszST.mjs → store-sqlite-DUdQnX_6.mjs} +4 -3
  66. package/dist/sync-chat-sdk.d.mts +2 -2
  67. package/dist/sync-github.d.mts +2 -2
  68. package/dist/sync-linear.d.mts +3 -3
  69. package/dist/sync-slack.d.mts +3 -3
  70. package/dist/sync-slack.mjs +1 -1
  71. package/dist/sync.d.mts +2 -2
  72. package/dist/{task-batch-BSJ3ihpF.mjs → task-batch-DgyfK9qx.mjs} +5 -5
  73. package/dist/{tokens-B3gXkQCs.mjs → tokens-_1X8JNLT.mjs} +2 -2
  74. package/dist/vercel-B5FM4uS8.d.mts +21 -0
  75. package/dist/vercel-BUb8II-P.mjs +305 -0
  76. package/dist/{version-1dDjcBkK.mjs → version-CZT5WmZs.mjs} +1 -1
  77. package/docs/01-board/01-mounting.md +1 -0
  78. package/docs/01-board/03-identity.md +2 -2
  79. package/docs/01-board/06-watchers.md +2 -1
  80. package/docs/01-board/12-postgres.md +222 -0
  81. package/docs/03-guides/02-inspector.md +33 -0
  82. package/docs/03-guides/07-build-a-ui.md +8 -4
  83. package/docs/04-reference/01-cli.md +7 -6
  84. package/docs/04-reference/03-http.md +1 -1
  85. package/docs/index.md +4 -1
  86. package/package.json +31 -2
  87. package/sql/postgres/schema.sql +389 -0
  88. package/dist/inspect-CGLv6b5v.mjs +0 -2
  89. package/dist/store-memory-OdGsc-t_.mjs +0 -2
  90. package/dist/store-sqlite-CTxAVCcz.mjs +0 -2
@@ -0,0 +1,98 @@
1
+ import { t as HttpError } from "./errors-BfMR39F0.mjs";
2
+ import { u as METHODS } from "./task-batch-DgyfK9qx.mjs";
3
+ import { i as memoryBlob, n as a2, r as fsBlob, t as localScheduler } from "./local-Bt1-jA9A.mjs";
4
+ import { createHash } from "node:crypto";
5
+ import { join, resolve } from "node:path";
6
+ //#region src/server/local.ts
7
+ /** A board's name that is its own file's: lowercase letters, digits, `_`, and `-`, and no device name Windows keeps. */
8
+ const PLAIN = /^[a-z0-9][a-z0-9_-]{0,63}$/;
9
+ const RESERVED = /^(con|prn|aux|nul|com\d|lpt\d)$/;
10
+ /**
11
+ * The file a board keeps, without its extension, from its name alone: `local` for the default
12
+ * board, a plain name as it is (whatever its case: names match that way), and any other name,
13
+ * `Security Team` say, as letters and dashes, a `.`, and a hash of it. No plain name has a `.`,
14
+ * and the hash is long enough that no one finds two names that share it, so no two names
15
+ * share a file, and none is `local`'s.
16
+ */
17
+ function localFile(name) {
18
+ if (name === null) return "local";
19
+ const lower = name.toLowerCase();
20
+ if (PLAIN.test(lower) && lower !== "local" && !RESERVED.test(lower)) return lower;
21
+ return `${lower.replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48) || "board"}.${createHash("sha256").update(lower).digest("hex").slice(0, 32)}`;
22
+ }
23
+ /** Why a file couldn't be opened, in a few words. */
24
+ function unwritable(error) {
25
+ const { code, message } = error;
26
+ if (code === "EROFS" || code === "EACCES" || code === "EPERM" || /unable to open database|readonly database/i.test(String(message))) return "this filesystem isn't writable here";
27
+ return String(message ?? error).split("\n")[0];
28
+ }
29
+ /**
30
+ * A board kept in this process: in SQLite under `.board/` (or `dir`), one file per board's name
31
+ * (whatever `board({ team })` says: there's one team here),
32
+ * its attachments next to it, and a scheduler whose timers run here, so schedules send, and
33
+ * watchers and sync retry, while the process runs. `memory` keeps it all in memory, for tests.
34
+ * A restart drops pending timers, so it's for development, `vb serve`, tests, and working offline,
35
+ * never serverless functions.
36
+ */
37
+ function local(options = {}) {
38
+ const dir = resolve(options.dir ?? ".board");
39
+ let binding = null;
40
+ let opening = null;
41
+ /** The board, opened on its first use: binding does no I/O. One that didn't open is tried again on the next call. */
42
+ function open() {
43
+ if (!binding) throw new Error("local: this backend isn't serving a board yet: pass it to board({ backend })");
44
+ const bound = binding;
45
+ opening ??= (async () => {
46
+ const file = localFile(bound.name);
47
+ let store;
48
+ if (options.memory) store = (await import("./memory-74hyK6eH.mjs")).memory();
49
+ else {
50
+ const { mkdir } = await import("node:fs/promises");
51
+ const { sqlite } = await import("./sqlite-DtfrT_EP.mjs");
52
+ const path = join(dir, `${file}.db`);
53
+ try {
54
+ await mkdir(dir, {
55
+ recursive: true,
56
+ mode: 448
57
+ });
58
+ store = sqlite({ path });
59
+ } catch (error) {
60
+ throw new HttpError(500, "no_store", `can't open the board at ${path}: ${unwritable(error)}`);
61
+ }
62
+ }
63
+ const scheduler = localScheduler();
64
+ const backend = a2({
65
+ store,
66
+ scheduler,
67
+ blob: options.memory ? memoryBlob() : fsBlob(join(dir, file))
68
+ });
69
+ backend.bind(bound);
70
+ return {
71
+ backend,
72
+ store,
73
+ scheduler
74
+ };
75
+ })();
76
+ opening.catch(() => opening = null);
77
+ return opening;
78
+ }
79
+ return {
80
+ ...Object.fromEntries(METHODS.map((name) => [name, async (caller, input, signal) => (await open()).backend[name](caller, input, signal)])),
81
+ routes: [],
82
+ keeps: true,
83
+ trust: { grants: async () => (await open()).backend.trust.grants() },
84
+ bind(given) {
85
+ if (binding) throw new Error("local: this backend already serves a board: create one local() per board()");
86
+ binding = given;
87
+ },
88
+ async close() {
89
+ const opened = opening;
90
+ opening = null;
91
+ const board = opened && await opened.catch(() => null);
92
+ board?.scheduler.stop();
93
+ await board?.store.close();
94
+ }
95
+ };
96
+ }
97
+ //#endregion
98
+ export { local as t };
@@ -1,17 +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 { f as BoardError } from "./errors-DDfXnZ2b.mjs";
3
+ import { f as BoardError } from "./errors-BfMR39F0.mjs";
4
4
  import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
5
- import { l as shownName } from "./middleware-BY4qqIh3.mjs";
5
+ import { l as shownName } from "./middleware-bIABV895.mjs";
6
6
  import { d as parseSchemaId, r as findBlocks, t as block } from "./blocks-CVoBC7ur.mjs";
7
- import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
8
- import { t as VERSION } from "./version-1dDjcBkK.mjs";
9
- import { r as PERMISSIONS } from "./access-HzqFpgL_.mjs";
10
- import { c as withMentions } from "./task-batch-BSJ3ihpF.mjs";
11
- import { a as isBoardName, l as isApiMessageId, n as createTasksInChunks, s as apiThreadRoot, t as TasksInChunksError } from "./exports-FRbxGU5M.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-CZUxX6HF.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-24oEf9i9.mjs";
14
- import { n as everyChannel, t as conformance } from "./conformance-BNiLcKra.mjs";
7
+ import { n as isEmail, s as replaceMentions, t as extractMentions } from "./mentions-DBGmqkr2.mjs";
8
+ import { t as VERSION } from "./version-CZT5WmZs.mjs";
9
+ import { r as PERMISSIONS } from "./access-CIj7v_Dr.mjs";
10
+ import { c as mentionValue, l as withMentions } from "./task-batch-DgyfK9qx.mjs";
11
+ import { a as isBoardName, l as isApiMessageId, n as createTasksInChunks, s as apiThreadRoot, t as TasksInChunksError } from "./exports-x-ioAfbp.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-7FY_8p92.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-BSexF7Bk.mjs";
14
+ import { n as everyChannel, t as conformance } from "./conformance-FiQ68adg.mjs";
15
15
  import { n as displayText, t as byVercelBot } from "./bots-CqPYxkqK.mjs";
16
16
  import { spawn } from "node:child_process";
17
17
  import { createHash, randomUUID } from "node:crypto";
@@ -1435,8 +1435,12 @@ let current = {
1435
1435
  let typed = [];
1436
1436
  /** What this run's writes had to say, for its JSON result. */
1437
1437
  let warnings = [];
1438
+ /** The word a bare `--mentions` came before, when it isn't the command: a warning says how it reads. */
1439
+ let bareMentions;
1438
1440
  /** The board this run reached by its URL, for a failure to name. */
1439
1441
  let reached = null;
1442
+ /** The task `tasks run` holds, once it's claimed one: with --ready, the command line names only its channel. */
1443
+ let runTask;
1440
1444
  /** The team whose default board this run reached, nothing naming one of its boards: `--scope`'s, or the one the environment finds. */
1441
1445
  let teamDefault = null;
1442
1446
  /** Where the credential this run sent came from, as `whoami` says it, for a refusal to say which to replace. */
@@ -1466,6 +1470,17 @@ const TEXT = /* @__PURE__ */ new Set([
1466
1470
  "edit",
1467
1471
  "schedule"
1468
1472
  ]);
1473
+ /**
1474
+ * The word a bare `--mentions` came before, when it isn't the command: `--mentions ada` means
1475
+ * mentions of you, with `ada` a channel or ID, since only `me` or a word with an `@` is its value.
1476
+ */
1477
+ function bareMentionsWord(argv, word) {
1478
+ const end = argv.includes("--") ? argv.indexOf("--") : argv.length;
1479
+ for (let at = 0; at < end - 1; at++) {
1480
+ const next = argv[at + 1];
1481
+ if (argv[at] === "--mentions" && !mentionValue(next) && !next.startsWith("-") && canonical(next) !== word) return next;
1482
+ }
1483
+ }
1469
1484
  /** Parses `argv` for this run, or throws what's wrong with it. */
1470
1485
  function parse(argv) {
1471
1486
  const args = withMentions(argv);
@@ -1494,12 +1509,32 @@ function parse(argv) {
1494
1509
  }] : []);
1495
1510
  flags = parsed.values;
1496
1511
  positionals = parsed.positionals.map((arg) => arg.startsWith(MARK) ? arg.slice(1) : arg);
1512
+ bareMentions = bareMentionsWord(argv, word);
1497
1513
  } catch (error) {
1498
1514
  throw parseFailure(error, argv, word);
1499
1515
  }
1500
1516
  const known = specOf(word) && new Set(optionsOf(word));
1501
1517
  const foreign = known && ordered.find((option) => !known.has(option.name));
1502
1518
  if (foreign) throw foreignOption(foreign.name, word);
1519
+ const sub = word === "tasks" ? subcommandOf(word) : void 0;
1520
+ const theirs = sub && new Set([
1521
+ ...sub.options,
1522
+ ...sub.filters ? filters$1 : [],
1523
+ ...globalOptions
1524
+ ].map((option) => option.name));
1525
+ const elsewhere = theirs && ordered.find((option) => !theirs.has(option.name));
1526
+ if (elsewhere) throw usage(`Unknown option --${elsewhere.name} for ${named()} ${word} ${sub.name}.`, {
1527
+ reason: "unknown_option",
1528
+ next: [{
1529
+ instruction: "See all options",
1530
+ argv: [
1531
+ ...cli(),
1532
+ word,
1533
+ sub.name,
1534
+ "--help"
1535
+ ]
1536
+ }]
1537
+ });
1503
1538
  if (canonical(positionals[0]) !== word) throw misplaced(args, word);
1504
1539
  }
1505
1540
  /**
@@ -1632,6 +1667,13 @@ function parseFailure(error, argv, word) {
1632
1667
  /** The options `word`'s command takes, its subcommands' and the filters included, and the ones every command takes. */
1633
1668
  /** The command `word` names, board's or the app's, as help shows it. */
1634
1669
  const specOf = (word) => word === void 0 ? void 0 : [...commands, ...Object.values(app.commands).map((own) => own.spec)].find((known) => known.name === word);
1670
+ /** The subcommand of `word`'s command this run names, right after the command, by its name or an alias. */
1671
+ function subcommandOf(word) {
1672
+ const command = specOf(word);
1673
+ if (!command?.subcommands || command.argumentsBeforeSubcommand) return void 0;
1674
+ const named = positionals[1];
1675
+ return command.subcommands.find((sub) => sub.name === named || (sub.aliases ?? []).includes(named ?? ""));
1676
+ }
1635
1677
  function optionsOf(word) {
1636
1678
  const command = specOf(word);
1637
1679
  return [...command ? [command, ...command.subcommands ?? []].flatMap((c) => [...c.options, ...c.filters ? filters$1 : []]) : [], ...globalOptions].map((option) => option.name);
@@ -2083,8 +2125,8 @@ function doing() {
2083
2125
  case "schedule": return a === "cancel" ? `cancel schedule ${b}` : `schedule a message in ${message ? ref(a) : a ?? "a channel"}`;
2084
2126
  case "channels": return a === "create" ? `create ${b ?? "the channel"}` : "list channels";
2085
2127
  case "schedules":
2086
- case "actors":
2087
- case "boards": return `list ${command}`;
2128
+ case "actors": return `list ${command}`;
2129
+ case "list": return "list the team's boards";
2088
2130
  case "tasks": {
2089
2131
  if (a === void 0 || !TASK_VERBS.has(a)) return a === void 0 ? "list tasks" : `list tasks in ${a}`;
2090
2132
  const one = b === void 0 ? "a task" : `task ${ref(b)}`;
@@ -2275,6 +2317,8 @@ function failureOf(error) {
2275
2317
  ...theirs("limit", "payload_too_large", `Can't ${doing()}. A message's text is at most ${MESSAGE_TEXT_MAX.toLocaleString("en-US")} characters.`, [{ instruction: current.command === "edit" ? "Keep the edit short, and reply with the long part in a file with --attach" : current.command === "tasks" ? "Keep it short, and reply to the task with the long part in a file with --attach" : "Put the long part in a file and --attach it, with a short summary as the text" }]),
2276
2318
  details: []
2277
2319
  };
2320
+ const note = status === 400 ? taskNoteTooLong(message) : null;
2321
+ if (note) return { ...theirs("limit", "payload_too_large", `Can't ${doing()}. Its ${note} is too long for the board.`, note === "result" ? noteRecovery("report") : noteRecovery("detail")) };
2278
2322
  if (code === "too_many_boards") return theirs("limit", code, `Can't ${doing()}. The team has all the boards it can.`, current.command === "conformance" ? [{
2279
2323
  instruction: "Check a board by its URL, such as one from vb serve",
2280
2324
  argv: [
@@ -2297,11 +2341,10 @@ function failureOf(error) {
2297
2341
  argv: rerunWithout([]).filter((arg) => arg !== "--ensure")
2298
2342
  }] : []);
2299
2343
  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" }]);
2344
+ if (status === 400 && code === "invalid_profile") return theirs("usage", code, `Can't ${doing()}. The board doesn't take that profile.`);
2300
2345
  if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
2301
- 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" }] : [{
2302
- instruction: "Log in again",
2303
- argv: ["vercel", "login"]
2304
- }]);
2346
+ if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", loginRecoveries());
2347
+ if (status === 403 && code === "reauthentication_required") return theirs("auth", "login_required", "Your team needs you to log in again.", loginRecoveries());
2305
2348
  if (status === 403) return theirs("permission", "permission_denied", `You can't ${doing()}.`, refusedRecoveries());
2306
2349
  if (status === 404) {
2307
2350
  const thing = missing();
@@ -2365,6 +2408,14 @@ const onThisBoard = () => [
2365
2408
  ...flags.name !== void 0 ? ["--name", flags.name] : [],
2366
2409
  ...flags.as ? ["--as", flags.as] : []
2367
2410
  ];
2411
+ /**
2412
+ * Where to go when the board won't take the credential sent: a token you passed is yours to replace, and so is
2413
+ * BOARD_TOKEN: logging in changes nothing while either is the one sent, or a workflow's own, where there's no login.
2414
+ */
2415
+ const loginRecoveries = () => 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" }] : [{
2416
+ instruction: "Log in again",
2417
+ argv: ["vercel", "login"]
2418
+ }];
2368
2419
  /** Where to go from a 403: what you may do on this board, and who can let you do more. */
2369
2420
  const refusedRecoveries = () => [{
2370
2421
  instruction: "See what you can do on this board",
@@ -2424,10 +2475,13 @@ function unsupportedRecoveries() {
2424
2475
  }
2425
2476
  /** `42s`, `2m`: a wait the way people say it. */
2426
2477
  const waitFor = (seconds) => seconds < 120 ? `${Math.max(1, seconds)}s` : `${Math.ceil(seconds / 60)}m`;
2427
- /** How this run ends with `failure`: shown on stderr, or by the app, and its exit code. */
2478
+ /** How this run ends with `failure`: shown on stderr, or by the app, and its exit code. With `--json`, its document carries the run's warnings, which may say why it failed. */
2428
2479
  function report(failure, json) {
2429
2480
  if (app.onError) app.onError(failure, { json });
2430
- else if (json) io.error(`${JSON.stringify(failureDocument(failure))}\n`);
2481
+ else if (json) io.error(`${JSON.stringify(warnings.length ? {
2482
+ ...failureDocument(failure),
2483
+ warnings
2484
+ } : failureDocument(failure))}\n`);
2431
2485
  else io.error(`${terminalText(formatFailure(failure))}\n`);
2432
2486
  return exitCode(failure);
2433
2487
  }
@@ -2541,17 +2595,17 @@ function connection(url = flags.url, options = {}) {
2541
2595
  * deployment's) is one board, with no team's to list.
2542
2596
  */
2543
2597
  async function teamBoards() {
2544
- if (io.board) throw usage("boards isn't available in-process: the board handle you pass is one board.", {
2598
+ if (io.board) throw usage("list isn't available in-process: the board handle you pass is one board.", {
2545
2599
  reason: "not_available",
2546
2600
  next: []
2547
2601
  });
2548
- if (flags.name !== void 0 || flags.ensure) throw usage(`boards lists every board of the team, and --${flags.name !== void 0 ? "name" : "ensure"} picks one: leave it out.`, { reason: "conflicting_options" });
2602
+ if (flags.name !== void 0 || flags.ensure) throw usage(`list lists every board of the team, and --${flags.name !== void 0 ? "name" : "ensure"} picks one: leave it out.`, { reason: "conflicting_options" });
2549
2603
  let team = flags.scope ?? flags.team;
2550
2604
  if (team !== void 0 && flags.url !== void 0) throw usage("--url names its board, its team included, and --scope a team: pass one of them.", { reason: "conflicting_options" });
2551
2605
  const url = flags.url ?? (team === void 0 ? configuredUrl() : null);
2552
2606
  if (url !== null && url !== void 0) {
2553
2607
  const onVercel = vercelBoard(url.replace(/\/+$/, ""));
2554
- if (!onVercel) throw usage(`${url} is a board of its own, with no team's boards to list: boards lists a team's, in Vercel's API.`, {
2608
+ if (!onVercel) throw usage(`${url} is a board of its own, with no team's boards to list: list lists a team's, in Vercel's API.`, {
2555
2609
  reason: "not_available",
2556
2610
  next: [{
2557
2611
  instruction: "List a team's boards",
@@ -2823,10 +2877,8 @@ async function run(command, args) {
2823
2877
  if (listed.next !== null) out(`\n(more not shown: ${commandLine(rerunWithout(["--after"], "--after", listed.next))})`);
2824
2878
  return 0;
2825
2879
  }
2826
- case "boards": {
2827
- const [sub, extra] = args;
2828
- if (sub !== void 0 && sub !== "list") throw usage(`Unknown command ${sub} for ${named()} boards.`, { reason: "unknown_command" });
2829
- if (extra !== void 0) throw usage(`boards list takes no arguments: ${extra} is one too many.`);
2880
+ case "list": {
2881
+ if (args[0] !== void 0) throw usage(`list takes no arguments: ${args[0]} is one too many.`);
2830
2882
  const listed = await teamBoards();
2831
2883
  if (flags.json) return result(listed), 0;
2832
2884
  if (listed.boards.length === 0) return out("no boards you can use on this team yet"), 0;
@@ -4098,6 +4150,7 @@ async function tasks(args) {
4098
4150
  const claim = await claimFor(board, claims, before[0], "run");
4099
4151
  if (typeof claim === "number") return claim;
4100
4152
  const id = claim.task.id;
4153
+ runTask = id;
4101
4154
  const lease = seconds("lease");
4102
4155
  const ran = await runCommand(command, {
4103
4156
  env: {
@@ -4265,6 +4318,47 @@ async function tasks(args) {
4265
4318
  }
4266
4319
  }
4267
4320
  }
4321
+ /** Which note a board refused as too long, from its words: `result: a task's result is at most 1,000 characters` here, `result should NOT be longer than 1000 characters` on Vercel's. Null for anything else, and off a task's settling. */
4322
+ function taskNoteTooLong(said) {
4323
+ const { command, args } = current;
4324
+ if (command !== "tasks" || ![
4325
+ "run",
4326
+ "complete",
4327
+ "fail",
4328
+ "block",
4329
+ "cancel"
4330
+ ].includes(args[0] ?? "")) return null;
4331
+ const what = /^\s*(result|reason)\b/i.exec(said)?.[1]?.toLowerCase();
4332
+ if (what !== "result" && what !== "reason" || !/(at most|longer than|too long)/i.test(said)) return null;
4333
+ return what;
4334
+ }
4335
+ /** Where a too-long task note goes: the whole of it in a reply in the task's thread, then the settling again with a line or two. */
4336
+ function noteRecovery(whole) {
4337
+ const { args } = current;
4338
+ const named = args[1] !== void 0 && isMessageRef(args[1]) ? messageId(args[1]) : "<ID>";
4339
+ const id = args[0] === "run" ? runTask ?? named : named;
4340
+ const verb = args[0] === "run" ? "complete" : args[0];
4341
+ return [{
4342
+ instruction: `Reply the full ${whole} in the task's thread`,
4343
+ argv: [
4344
+ ...cli(),
4345
+ "reply",
4346
+ id,
4347
+ "-",
4348
+ ...onThisBoard()
4349
+ ]
4350
+ }, {
4351
+ instruction: `Then ${verb} it with a line or two`,
4352
+ argv: [
4353
+ ...cli(),
4354
+ "tasks",
4355
+ verb,
4356
+ id,
4357
+ "<A LINE OR TWO>",
4358
+ ...onThisBoard()
4359
+ ]
4360
+ }];
4361
+ }
4268
4362
  /** How a board's own word about a task reads from here: the headline, and the way on. Null for any other code. */
4269
4363
  function taskFailure(code, status) {
4270
4364
  const { command, args } = current;
@@ -4472,13 +4566,9 @@ const OTHER_NAMES = {
4472
4566
  search: SEARCH,
4473
4567
  find: SEARCH,
4474
4568
  grep: SEARCH,
4475
- list: {
4476
- instruction: "List a channel's threads with read",
4477
- argv: ["read", "<CHANNEL>"]
4478
- },
4479
- ls: {
4480
- instruction: "List a channel's threads with read",
4481
- argv: ["read", "<CHANNEL>"]
4569
+ boards: {
4570
+ instruction: "List the team's boards",
4571
+ argv: ["list"]
4482
4572
  },
4483
4573
  threads: {
4484
4574
  instruction: "List a channel's threads with read",
@@ -4754,10 +4844,12 @@ async function runOnce(argv, options) {
4754
4844
  flags = {};
4755
4845
  positionals = [];
4756
4846
  warnings = [];
4847
+ bareMentions = void 0;
4757
4848
  reached = null;
4758
4849
  teamDefault = null;
4759
4850
  sent = () => null;
4760
4851
  sentLength = 0;
4852
+ runTask = void 0;
4761
4853
  self = null;
4762
4854
  try {
4763
4855
  parse(argv);
@@ -4776,6 +4868,10 @@ async function runOnce(argv, options) {
4776
4868
  command,
4777
4869
  args
4778
4870
  };
4871
+ if (bareMentions !== void 0) warn({
4872
+ reason: "bare_mentions",
4873
+ message: `--mentions ${bareMentions} means mentions of you, with ${bareMentions} as a channel or ID: for mentions of ${bareMentions}, write --mentions @${bareMentions}.`
4874
+ });
4779
4875
  if (io.board) {
4780
4876
  const given = flags.url ? "url" : flags.name !== void 0 ? "name" : flags.ensure ? "ensure" : null;
4781
4877
  if (given) throw usage(`--${given} doesn't apply in-process: the board handle you pass says which board and who.`, { next: [] });
@@ -1,6 +1,6 @@
1
- import { r as sqlTables } from "./sql-D0MqINA6.mjs";
2
- import { t as memory$1 } from "./store-memory-CKQVEzXN.mjs";
3
- import { t as sqliteDb } from "./sqlite-db-DjbTlUwN.mjs";
1
+ import { r as sqlTables } from "./sql-CvBbb5Ui.mjs";
2
+ import { t as memory$1 } from "./store-memory-DOMraCLN.mjs";
3
+ import { t as sqliteDb } from "./sqlite-db-DSVlzQjv.mjs";
4
4
  //#region src/store/memory.ts
5
5
  /**
6
6
  * A board that lives in memory, for tests: its log in A2's memory store, its
@@ -49,6 +49,10 @@ const isEmail = (value) => /^[^\s@:]+@[^\s@:]+$/.test(value);
49
49
  const mentionTerm = (name) => name.includes(":") ? name : name.toLowerCase();
50
50
  /** What `text` mentions, as filters match it: each `@handle` and `@[…]`, as `mentionTerm` has it. */
51
51
  const mentionTerms = (text) => [...new Set(extractMentions(text).map((token) => mentionTerm(token.kind === "handle" ? token.handle : token.actor)))];
52
+ /** What `--mentions me` matches: the caller's actor ID and handle, where it has one, and none of their profiles. */
53
+ const meTerms = (me) => [me.id, ...me.handle ? [mentionTerm(me.handle)] : []];
54
+ /** Whether `text` mentions what a `--mentions` filter matches. */
55
+ const mentionsIn = (text, match) => mentionTerms(text).some((term) => match.terms.includes(term) || match.prefixes.some((prefix) => term.startsWith(prefix)));
52
56
  /**
53
57
  * Rewrites each mention in prose with `replace`, which also gets the mention as
54
58
  * written; one it returns null for stays as written.
@@ -116,4 +120,4 @@ function settleMentions(text, actors, prefer = () => null) {
116
120
  };
117
121
  }
118
122
  //#endregion
119
- export { replaceMentions as a, mentionTerms as i, isEmail as n, settleMentions as o, mentionTerm as r, extractMentions as t };
123
+ export { mentionTerms as a, settleMentions as c, mentionTerm as i, isEmail as n, mentionsIn as o, meTerms as r, replaceMentions as s, extractMentions as t };
@@ -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-DDfXnZ2b.mjs";
2
+ import { t as HttpError } from "./errors-BfMR39F0.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 { 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";
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-CSnxZyyb.mjs";
2
+ import { t as BoardClient } from "./client-B0DGOt7P.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/contract/bots.d.ts
5
5
  /**
@@ -2829,8 +2829,8 @@ declare const routes: {
2829
2829
  }, z.core.$strict>;
2830
2830
  };
2831
2831
  readonly updateGrant: {
2832
- readonly method: 'PATCH';
2833
- readonly path: '/grants/:id';
2832
+ readonly method: 'POST';
2833
+ readonly path: '/grants/:id/update';
2834
2834
  readonly body: z.ZodObject<{
2835
2835
  add: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2836
2836
  kind: z.ZodLiteral<"user">;
@@ -1,9 +1,9 @@
1
- import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-DDfXnZ2b.mjs";
2
- import { i as hostCheckedBy } from "./exports-FRbxGU5M.mjs";
3
- import { i as LOGINS, r as LOGIN } from "./auth-D9ycDQK0.mjs";
4
- import { h as localTokenFile, t as board } from "./server-24oEf9i9.mjs";
5
- import { t as oidcTokens } from "./tokens-B3gXkQCs.mjs";
6
- import { t as local } from "./local-Dn0vv-1e.mjs";
1
+ import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-BfMR39F0.mjs";
2
+ import { i as hostCheckedBy } from "./exports-x-ioAfbp.mjs";
3
+ import { i as LOGINS, r as LOGIN } from "./auth-BDWGvFWl.mjs";
4
+ import { h as localTokenFile, t as board } from "./server-BSexF7Bk.mjs";
5
+ import { t as oidcTokens } from "./tokens-_1X8JNLT.mjs";
6
+ import { t as local } from "./local-Gp8pqHSu.mjs";
7
7
  import { mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
8
8
  import { userInfo } from "node:os";
9
9
  import { dirname, join, resolve } from "node:path";
@@ -1,9 +1,9 @@
1
1
  import { n as formatProfileHeader } from "./profile-header-O8wC8yk8.mjs";
2
2
  import "./schemas-CUSTEFIy.mjs";
3
- import { f as BoardError, ht as routes, p as createBoardClient, t as HttpError } from "./errors-DDfXnZ2b.mjs";
4
- import { g as keyId, p as DERIVED_ID } from "./middleware-BY4qqIh3.mjs";
5
- import { l as METHODS, o as compileWatcher } from "./task-batch-BSJ3ihpF.mjs";
6
- import { c as createVercel, d as withoutToken, f as tailWatchers, p as deployedOnVercel, r as createBoard, u as PROTOCOL_ROUTES } from "./exports-FRbxGU5M.mjs";
3
+ import { f as BoardError, g as refusalCode, gt as routes, p as createBoardClient, t as HttpError } from "./errors-BfMR39F0.mjs";
4
+ import { g as keyId, p as DERIVED_ID } from "./middleware-bIABV895.mjs";
5
+ import { o as compileWatcher, u as METHODS } from "./task-batch-DgyfK9qx.mjs";
6
+ import { c as createVercel, d as withoutToken, f as tailWatchers, p as deployedOnVercel, r as createBoard, u as PROTOCOL_ROUTES } from "./exports-x-ioAfbp.mjs";
7
7
  import { execFile } from "node:child_process";
8
8
  import { createHash } from "node:crypto";
9
9
  import { mkdir, readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
@@ -770,7 +770,7 @@ function createHttp(url, options, environment) {
770
770
  const profiles = /* @__PURE__ */ new Map();
771
771
  /** This deployment as `profile`: a watcher's ID, or the middleware. */
772
772
  function asProfile(profile) {
773
- if (!PROFILE.test(profile)) throw new HttpError(400, "invalid_request", `as: ${profile}: profiles start with a letter and use up to 32 letters, numbers, and hyphens`);
773
+ if (!PROFILE.test(profile)) throw new HttpError(400, "invalid_profile", `as: ${profile}: profiles start with a letter and use up to 32 letters, numbers, and hyphens`);
774
774
  let client = profiles.get(profile);
775
775
  if (!client) profiles.set(profile, client = sdk(profile));
776
776
  return client;
@@ -855,7 +855,7 @@ function createHttp(url, options, environment) {
855
855
  if (response.ok) return response;
856
856
  try {
857
857
  const body = await response.json();
858
- if (body.error?.message) throw new HttpError(response.status, body.error.code ?? "error", body.error.message, typeof body.error.hint === "string" ? { hint: body.error.hint } : {});
858
+ if (body.error?.message) throw new HttpError(response.status, refusalCode(response.status, body.error) ?? "error", body.error.message, typeof body.error.hint === "string" ? { hint: body.error.hint } : {});
859
859
  } catch (error) {
860
860
  if (error instanceof HttpError) throw error;
861
861
  }
@@ -1114,8 +1114,8 @@ function vercel(options = {}) {
1114
1114
  function board(options = {}) {
1115
1115
  return createBoard(options, {
1116
1116
  backend: (fetch) => process.env.BOARD_URL?.trim() ? http() : vercel(fetch ? { fetch } : {}),
1117
- sync: () => import("./engine-C8wCzkw-.mjs"),
1118
- serving: () => import("./serving-C1mhZQqH.mjs"),
1117
+ sync: () => import("./engine-B_CjnE3G.mjs"),
1118
+ serving: () => import("./serving-ByD4TOOU.mjs"),
1119
1119
  sandbox: (url, token) => sandboxHeaders(url, url, token)
1120
1120
  });
1121
1121
  }