@vercel/board 0.56.1 → 0.57.1

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 (96) hide show
  1. package/README.md +1 -1
  2. package/dist/{access-HzqFpgL_.mjs → access-CZ419Vho.mjs} +1 -1
  3. package/dist/access.d.mts +2 -2
  4. package/dist/access.mjs +4 -4
  5. package/dist/{actors-D-u6bitG.mjs → actors-CXMWplob.mjs} +2 -2
  6. package/dist/{auth-D9ycDQK0.mjs → auth-AwZJQpCO.mjs} +2 -2
  7. package/dist/{auth-ULldUvir.d.mts → auth-C0Mla9OU.d.mts} +1 -1
  8. package/dist/{backend-BHN6GTjB.d.mts → backend-BuqwQbb4.d.mts} +6 -22
  9. package/dist/backend-local.d.mts +1 -1
  10. package/dist/backend-local.mjs +1 -1
  11. package/dist/backend-postgres/blob-vercel.d.mts +8 -0
  12. package/dist/backend-postgres/blob-vercel.mjs +81 -0
  13. package/dist/backend-postgres/scheduler-vercel.d.mts +2 -0
  14. package/dist/backend-postgres/scheduler-vercel.mjs +2 -0
  15. package/dist/backend-postgres.d.mts +74 -0
  16. package/dist/backend-postgres.mjs +3229 -0
  17. package/dist/blob-DjS53D1A.d.mts +35 -0
  18. package/dist/{chat-provider-F7UqWVZK.d.mts → chat-provider-CpYdXEpI.d.mts} +2 -2
  19. package/dist/cli-commands.d.mts +1 -1
  20. package/dist/cli-commands.mjs +1 -1
  21. package/dist/cli-embedded.d.mts +2 -2
  22. package/dist/cli-embedded.mjs +2 -2
  23. package/dist/cli.mjs +6 -6
  24. package/dist/{client-CFHunEFn.d.mts → client-B0DGOt7P.d.mts} +1 -1
  25. package/dist/{commands-DLPIX7Jw.d.mts → commands-Dcm4_pc1.d.mts} +3 -3
  26. package/dist/{commands-7FY_8p92.mjs → commands-DeYAQUcP.mjs} +10 -5
  27. package/dist/{conformance-BNiLcKra.mjs → conformance-EtEq22w1.mjs} +2 -2
  28. package/dist/conformance.d.mts +1 -1
  29. package/dist/conformance.mjs +1 -1
  30. package/dist/{engine-C8wCzkw-.mjs → engine-CfVTyEeo.mjs} +3 -3
  31. package/dist/errors-DBZtbfph.d.mts +19 -0
  32. package/dist/{errors-DDfXnZ2b.mjs → errors-DjatfYjl.mjs} +220 -18
  33. package/dist/{exports-DSX-CI5c.mjs → exports-B_UGnrnN.mjs} +187 -62
  34. package/dist/{exports-BBmjHyCB.d.mts → exports-BvJTIorX.d.mts} +5 -4
  35. package/dist/{index-Ce3SDZ3Y.d.mts → index-DuibwQf9.d.mts} +2 -2
  36. package/dist/index.d.mts +6 -5
  37. package/dist/index.mjs +4 -4
  38. package/dist/index.node.d.mts +7 -6
  39. package/dist/index.node.mjs +4 -4
  40. package/dist/inspect/app.js +126 -146
  41. package/dist/inspect/engine.js +3 -3
  42. package/dist/inspect/sheet-presentation.js +1 -0
  43. package/dist/{inspect-C-vDnB_n.mjs → inspect-DfJzHFiE.mjs} +2 -2
  44. package/dist/inspect-H1MISWwN.mjs +2 -0
  45. package/dist/inspect.d.mts +1 -1
  46. package/dist/inspect.mjs +1 -1
  47. package/dist/{internal-CvsrprnU-CEPOUpAv.mjs → internal-CvsrprnU-DhZF6sZK.mjs} +43 -1
  48. package/dist/local-BiG1WJk0.mjs +98 -0
  49. package/dist/{local-B5aZcAwj.mjs → local-D2i5sxuY.mjs} +141 -3957
  50. package/dist/{main-DSlpMoBN.mjs → main-Bbqg3Unf.mjs} +167 -38
  51. package/dist/{memory-wmUDblhm.mjs → memory-BmsyKyHu.mjs} +3 -3
  52. package/dist/{mentions-CnWt9Z5b.mjs → mentions-DBGmqkr2.mjs} +5 -1
  53. package/dist/{middleware-BY4qqIh3.mjs → middleware-D2AGrGj7.mjs} +2 -32
  54. package/dist/{provider-DgGp4Zej.d.mts → provider-BNVyVKtH.d.mts} +2 -2
  55. package/dist/{routes-DNmQSOvQ.d.mts → routes-CSnxZyyb.d.mts} +2 -2
  56. package/dist/{serve-CI3kvpx_.mjs → serve-D06-DMej.mjs} +6 -6
  57. package/dist/{server-55vryxAl.mjs → server-BXbcS-n9.mjs} +27 -12
  58. package/dist/server-DX7mM6nm-Cq1xPyqJ.mjs +3769 -0
  59. package/dist/{serving-C1mhZQqH.mjs → serving-B2BNr4PR.mjs} +1 -1
  60. package/dist/{shell-7nGyF--f.mjs → shell-C8EowDEz.mjs} +15 -7
  61. package/dist/{sql-D0MqINA6.mjs → sql-CvBbb5Ui.mjs} +33 -22
  62. package/dist/{sqlite-Dj2ZEtgy.mjs → sqlite-B9ZLSDUT.mjs} +3 -3
  63. package/dist/{sqlite-db-DjbTlUwN.mjs → sqlite-db-DawFxCk6.mjs} +22 -7
  64. package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +5 -0
  65. package/dist/{store-N8PXxDAS-BdL4Sq-f.mjs → store-codec-pAG2oPgQ-DbEYfF5Y.mjs} +2 -6
  66. package/dist/{store-memory-CKQVEzXN.mjs → store-memory-DOMraCLN.mjs} +3 -2
  67. package/dist/store-memory-XNDFHASI.mjs +2 -0
  68. package/dist/{store-polling-BZt2Rf3D-oh3aU_An.mjs → store-polling-BZt2Rf3D-nlZUQLz2.mjs} +1 -1
  69. package/dist/store-sqlite-Cs8dH9EX.mjs +2 -0
  70. package/dist/{store-sqlite-D6fIszST.mjs → store-sqlite-DUdQnX_6.mjs} +4 -3
  71. package/dist/sync-chat-sdk.d.mts +2 -2
  72. package/dist/sync-github.d.mts +2 -2
  73. package/dist/sync-linear.d.mts +3 -3
  74. package/dist/sync-slack.d.mts +3 -3
  75. package/dist/sync-slack.mjs +1 -1
  76. package/dist/sync.d.mts +2 -2
  77. package/dist/{task-batch-iecHMssy.mjs → task-batch-YMVr_c5R.mjs} +4 -4
  78. package/dist/{tokens-B3gXkQCs.mjs → tokens-CaEPmiG1.mjs} +2 -2
  79. package/dist/vercel-B5FM4uS8.d.mts +21 -0
  80. package/dist/vercel-BUb8II-P.mjs +305 -0
  81. package/dist/{version-gbihG3ui.mjs → version-BRR9FkLa.mjs} +1 -1
  82. package/docs/01-board/01-mounting.md +10 -0
  83. package/docs/01-board/05-reading.md +2 -1
  84. package/docs/01-board/09-access.md +8 -4
  85. package/docs/01-board/11-tasks.md +1 -1
  86. package/docs/01-board/12-postgres.md +222 -0
  87. package/docs/03-guides/02-inspector.md +34 -1
  88. package/docs/03-guides/07-build-a-ui.md +8 -4
  89. package/docs/04-reference/01-cli.md +1 -1
  90. package/docs/04-reference/03-http.md +2 -1
  91. package/docs/index.md +4 -1
  92. package/package.json +32 -3
  93. package/sql/postgres/schema.sql +389 -0
  94. package/dist/inspect-CJ8osLQ-.mjs +0 -2
  95. package/dist/store-memory-OdGsc-t_.mjs +0 -2
  96. package/dist/store-sqlite-CTxAVCcz.mjs +0 -2
@@ -1,17 +1,17 @@
1
- import { a as DIRECT_UPLOAD_BYTES_MAX, l as fileSize } from "./profile-header-O8wC8yk8.mjs";
1
+ import { a as DIRECT_UPLOAD_BYTES_MAX, f as typeOf, 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-DjatfYjl.mjs";
4
4
  import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
5
- import { l as shownName } from "./middleware-BY4qqIh3.mjs";
6
5
  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-gbihG3ui.mjs";
9
- import { r as PERMISSIONS } from "./access-HzqFpgL_.mjs";
10
- import { c as mentionValue, l as withMentions } from "./task-batch-iecHMssy.mjs";
11
- import { a as isBoardName, l as isApiMessageId, n as createTasksInChunks, s as apiThreadRoot, t as TasksInChunksError } from "./exports-DSX-CI5c.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-55vryxAl.mjs";
14
- import { n as everyChannel, t as conformance } from "./conformance-BNiLcKra.mjs";
6
+ import { n as isEmail, s as replaceMentions, t as extractMentions } from "./mentions-DBGmqkr2.mjs";
7
+ import { l as shownName } from "./middleware-D2AGrGj7.mjs";
8
+ import { t as VERSION } from "./version-BRR9FkLa.mjs";
9
+ import { r as PERMISSIONS } from "./access-CZ419Vho.mjs";
10
+ import { c as mentionValue, l as withMentions } from "./task-batch-YMVr_c5R.mjs";
11
+ import { a as isBoardName, l as isApiMessageId, n as createTasksInChunks, s as apiThreadRoot, t as TasksInChunksError } from "./exports-B_UGnrnN.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-DeYAQUcP.mjs";
13
+ import { a as handTeam, d as connect, f as environmentProfile, h as handToken, i as handProgram, l as boardUrl, m as handLogin, n as credentialSource, o as vercel, p as handFetch, r as credentialed, s as http, t as board, u as configDir, v as vercelProjectFile } from "./server-BXbcS-n9.mjs";
14
+ import { n as everyChannel, t as conformance } from "./conformance-EtEq22w1.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";
@@ -58,7 +58,7 @@ function principalsIn(tokens, prefixes, removal) {
58
58
  const prefix = prefixes.find((candidate) => KINDS.includes(name.slice(candidate.length)) && name.startsWith(candidate));
59
59
  if (prefix !== void 0) {
60
60
  const kind = name.slice(prefix.length);
61
- if (kind === "github" && !/^[^/\s]+\/[^/\s]+$/.test(value ?? "")) throw new GrantMisuse(`--${name} takes owner/repo, like acme/web: got ${value}.`);
61
+ if (kind === "github" && !/^([^/\s]+\/[^/\s]+|\d+)$/.test(value ?? "")) throw new GrantMisuse(`--${name} takes owner/repo or the repository's ID, like acme/web or 700001: got ${value}.`);
62
62
  started.push({
63
63
  prefix,
64
64
  kind,
@@ -1439,6 +1439,8 @@ let warnings = [];
1439
1439
  let bareMentions;
1440
1440
  /** The board this run reached by its URL, for a failure to name. */
1441
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;
1442
1444
  /** The team whose default board this run reached, nothing naming one of its boards: `--scope`'s, or the one the environment finds. */
1443
1445
  let teamDefault = null;
1444
1446
  /** Where the credential this run sent came from, as `whoami` says it, for a refusal to say which to replace. */
@@ -1514,6 +1516,25 @@ function parse(argv) {
1514
1516
  const known = specOf(word) && new Set(optionsOf(word));
1515
1517
  const foreign = known && ordered.find((option) => !known.has(option.name));
1516
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
+ });
1517
1538
  if (canonical(positionals[0]) !== word) throw misplaced(args, word);
1518
1539
  }
1519
1540
  /**
@@ -1646,6 +1667,13 @@ function parseFailure(error, argv, word) {
1646
1667
  /** The options `word`'s command takes, its subcommands' and the filters included, and the ones every command takes. */
1647
1668
  /** The command `word` names, board's or the app's, as help shows it. */
1648
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
+ }
1649
1677
  function optionsOf(word) {
1650
1678
  const command = specOf(word);
1651
1679
  return [...command ? [command, ...command.subcommands ?? []].flatMap((c) => [...c.options, ...c.filters ? filters$1 : []]) : [], ...globalOptions].map((option) => option.name);
@@ -1763,23 +1791,34 @@ function labelPairs(values, wrong = "Labels look like key=value, and {value} isn
1763
1791
  return pairs;
1764
1792
  }
1765
1793
  /**
1766
- * A post or reply takes one text. What follows it was meant to be part of the message, or a label,
1794
+ * A post, reply, edit, or schedule takes one text. What follows it was meant to be part of the message, or a label,
1767
1795
  * and would be dropped without a word: say so, and how each is written.
1768
1796
  */
1769
1797
  function oneText(command, target, extra) {
1770
1798
  const [first] = extra;
1771
1799
  if (first === void 0) return;
1772
- if (/^[\w.-]+=/.test(first)) throw usage(`${first} looks like a label, and ${command} takes labels with --label.`, { next: [{
1773
- instruction: "Label it as you post it",
1774
- argv: [
1775
- ...cli(),
1776
- command,
1777
- target,
1778
- "<TEXT>",
1779
- "--label",
1780
- first
1781
- ]
1782
- }] });
1800
+ if (/^[\w.-]+=/.test(first)) {
1801
+ if (command === "edit") throw usage(`${first} looks like a label, and edit changes only the text.`, { next: [{
1802
+ instruction: "Label the message",
1803
+ argv: [
1804
+ ...cli(),
1805
+ "label",
1806
+ target,
1807
+ first
1808
+ ]
1809
+ }] });
1810
+ throw usage(`${first} looks like a label, and ${command} takes labels with --label.`, { next: [{
1811
+ instruction: "Label it as you post it",
1812
+ argv: [
1813
+ ...cli(),
1814
+ command,
1815
+ target,
1816
+ "<TEXT>",
1817
+ "--label",
1818
+ first
1819
+ ]
1820
+ }] });
1821
+ }
1783
1822
  if (flags.schema !== void 0 && first !== "-") throw usage(`With --schema, the text is ${flags.schema}'s JSON alone, and ${first.length > 40 ? `${first.slice(0, 40)}…` : first} is one too many. To say something with the data, leave out --schema and put the JSON in the text in a \`\`\`json#${flags.schema} fence.`);
1784
1823
  throw usage(first === "-" ? `${command} takes one text, and - (stdin) is a second. For a long message, pass - alone as the text: it has no title.` : `${command} takes one text, and ${first.length > 40 ? `${first.slice(0, 40)}…` : first} is one too many. Quote the whole message as one argument: it has no title.`);
1785
1824
  }
@@ -1857,12 +1896,25 @@ async function attachments(board) {
1857
1896
  });
1858
1897
  }
1859
1898
  const uploaded = [];
1860
- for (const { path, data } of files) uploaded.push(await board.upload({
1861
- data: new Uint8Array(data),
1862
- name: basename(path)
1863
- }));
1899
+ for (const { path, data } of files) try {
1900
+ uploaded.push(await board.upload({
1901
+ data: new Uint8Array(data),
1902
+ name: basename(path)
1903
+ }));
1904
+ } catch (error) {
1905
+ throw error instanceof BoardError && error.code === "attachment_type_mismatch" ? mismatched(path) : error;
1906
+ }
1864
1907
  return uploaded;
1865
1908
  }
1909
+ /** A file a board refused because its bytes aren't the type its name says. */
1910
+ function mismatched(path) {
1911
+ return new Failed({
1912
+ class: "usage",
1913
+ reason: "attachment_type_mismatch",
1914
+ message: `Can't attach ${path}. Its name says ${typeOf(basename(path))}, but its bytes aren't that type.`,
1915
+ next: [{ instruction: "Give it the extension of the format it holds, or save it as a real one, and attach it again" }]
1916
+ });
1917
+ }
1866
1918
  /**
1867
1919
  * Whether `value` is a schedule's own ID and not a message's: `s12` on a local board, `sch_…` on
1868
1920
  * Vercel's. A message's is a number or `msg_…`, so neither is ever one.
@@ -2289,6 +2341,8 @@ function failureOf(error) {
2289
2341
  ...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" }]),
2290
2342
  details: []
2291
2343
  };
2344
+ const note = status === 400 ? taskNoteTooLong(message) : null;
2345
+ 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")) };
2292
2346
  if (code === "too_many_boards") return theirs("limit", code, `Can't ${doing()}. The team has all the boards it can.`, current.command === "conformance" ? [{
2293
2347
  instruction: "Check a board by its URL, such as one from vb serve",
2294
2348
  argv: [
@@ -2311,11 +2365,11 @@ function failureOf(error) {
2311
2365
  argv: rerunWithout([]).filter((arg) => arg !== "--ensure")
2312
2366
  }] : []);
2313
2367
  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" }]);
2368
+ if (status === 400 && code === "invalid_profile") return theirs("usage", code, `Can't ${doing()}. The board doesn't take that profile.`);
2314
2369
  if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
2315
- 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" }] : [{
2316
- instruction: "Log in again",
2317
- argv: ["vercel", "login"]
2318
- }]);
2370
+ if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", loginRecoveries());
2371
+ if (status === 403 && code === "reauthentication_required") return theirs("auth", "login_required", "Your team needs you to log in again.", loginRecoveries());
2372
+ if (status === 403 && code === "invalid_token") return theirs("auth", "login_required", "The board didn't accept your credentials: they expired or were revoked.", loginRecoveries());
2319
2373
  if (status === 403) return theirs("permission", "permission_denied", `You can't ${doing()}.`, refusedRecoveries());
2320
2374
  if (status === 404) {
2321
2375
  const thing = missing();
@@ -2379,6 +2433,14 @@ const onThisBoard = () => [
2379
2433
  ...flags.name !== void 0 ? ["--name", flags.name] : [],
2380
2434
  ...flags.as ? ["--as", flags.as] : []
2381
2435
  ];
2436
+ /**
2437
+ * Where to go when the board won't take the credential sent: a token you passed is yours to replace, and so is
2438
+ * BOARD_TOKEN: logging in changes nothing while either is the one sent, or a workflow's own, where there's no login.
2439
+ */
2440
+ 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" }] : [{
2441
+ instruction: "Log in again",
2442
+ argv: ["vercel", "login"]
2443
+ }];
2382
2444
  /** Where to go from a 403: what you may do on this board, and who can let you do more. */
2383
2445
  const refusedRecoveries = () => [{
2384
2446
  instruction: "See what you can do on this board",
@@ -2871,9 +2933,13 @@ async function run(command, args) {
2871
2933
  "re",
2872
2934
  "before"
2873
2935
  ].find((name) => flags[name] !== void 0);
2874
- if (across !== void 0) throw usage(`Can't use --${across} on one thread. It's read whole: --after and --label narrow its replies.`);
2936
+ if (across !== void 0) throw usage(`Can't use --${across} on one thread. It's read whole: --after, --limit, and --label narrow its replies.`);
2937
+ if (link && flags.limit !== void 0) throw usage("Can't use --limit with a link. Read the thread by its ID to page its replies.");
2875
2938
  const after = !link && flags.after !== void 0 ? flags.after.replace(/^#/, "") : void 0;
2876
- const thread = link ? await board.linked(target) : await board.thread(messageId(target), after !== void 0 && isMessageRef(after) ? { after: messageId(after) } : {}).catch((error) => {
2939
+ const thread = link ? await board.linked(target) : await board.thread(messageId(target), {
2940
+ ...after !== void 0 && isMessageRef(after) ? { after: messageId(after) } : {},
2941
+ ...flags.limit !== void 0 ? { limit: flags.limit } : {}
2942
+ }).catch((error) => {
2877
2943
  if (error instanceof BoardError && error.status === 400 && /isn't a message of this thread/.test(error.message)) throw usage(`--after ${flags.after} isn't a message of this thread. On one thread, it takes one of its messages.`);
2878
2944
  throw error;
2879
2945
  });
@@ -3051,6 +3117,7 @@ async function run(command, args) {
3051
3117
  }
3052
3118
  const [target, body] = args;
3053
3119
  if (!target) throw usage("Missing the channel or message to schedule a message in.", { reason: "missing_arguments" });
3120
+ oneText("schedule", target, args.slice(2));
3054
3121
  if (!flags.in && !flags.at && !flags.every) throw usage("Can't schedule a message without a time: pass --in 1d, --at <time>, or --every 30m.", { reason: "missing_arguments" });
3055
3122
  const times = flags.times === void 0 ? void 0 : Number(flags.times);
3056
3123
  if (times !== void 0 && !(Number.isInteger(times) && times > 0)) throw usage(`--times takes a count, and ${flags.times} isn't one.`);
@@ -3283,6 +3350,7 @@ async function run(command, args) {
3283
3350
  case "hook": return 0;
3284
3351
  case "edit": {
3285
3352
  const id = messageId(args[0]);
3353
+ oneText("edit", args[0], args.slice(2));
3286
3354
  const { mentions } = await client().edit(id, await content(args[1]), ifRevision());
3287
3355
  printDone(id, "edited", mentions);
3288
3356
  return 0;
@@ -3559,12 +3627,18 @@ async function createPlan(target, text, path) {
3559
3627
  "needs",
3560
3628
  "for",
3561
3629
  "claim",
3562
- "lease",
3563
- "no-sync"
3630
+ "lease"
3564
3631
  ].find((name) => flags[name] !== void 0 && flags[name] !== false);
3565
- if (own !== void 0) throw usage(`--${own} is one task's: with --file, each task in the file has its own.`);
3632
+ if (own !== void 0) {
3633
+ const key = PLAN_KEY_OF_FLAG[own];
3634
+ if (key === void 0) throw usage(`--${own} is one task's: with --file, each task in the file has its own.`);
3635
+ throw usage(`--${own} is one task's: with --file, set ${key} on each task in the file.`);
3636
+ }
3566
3637
  const board = client();
3567
- const tasks = await planFrom(parsed, path, board);
3638
+ const tasks = (await planFrom(parsed, path, board)).map((task) => flags["no-sync"] && task.noSync === void 0 ? {
3639
+ ...task,
3640
+ noSync: true
3641
+ } : task);
3568
3642
  sentLength = Math.max(0, ...tasks.map((task) => typeof task.text === "string" ? task.text.length : 0));
3569
3643
  const key = flags["idempotency-key"] ?? crypto.randomUUID();
3570
3644
  let made;
@@ -3612,6 +3686,12 @@ const PLAN_KEYS = [
3612
3686
  "noSync",
3613
3687
  "attachments"
3614
3688
  ];
3689
+ /** The key of a plan's task that says what a task's own option does, as the error naming it shows it. */
3690
+ const PLAN_KEY_OF_FLAG = {
3691
+ label: "\"labels\": {…}",
3692
+ needs: "\"needs\": […]",
3693
+ for: "\"for\": \"…\""
3694
+ };
3615
3695
  /** The help page that says what a plan holds. */
3616
3696
  const planHelp = () => ({
3617
3697
  instruction: "See what a plan takes",
@@ -4016,6 +4096,7 @@ async function tasks(args) {
4016
4096
  const [target, body, extra] = rest;
4017
4097
  if (!target) throw usage("Missing a channel to start a task in, or a thread's ID to make one of.", { reason: "missing_arguments" });
4018
4098
  if (extra !== void 0) throw usage(`tasks create takes a channel and quoted text: ${extra} is one too many.`);
4099
+ if (flags.file !== void 0 && flags.attach?.length) throw usage("Can't use --attach with --file: a plan's tasks take their files as attachments, by ID.", { next: [planHelp()] });
4019
4100
  if (flags.file !== void 0) return createPlan(target, body, flags.file);
4020
4101
  const lease = seconds("lease");
4021
4102
  if (lease !== void 0 && !claimFlag()) throw usage("--lease is how long a claim holds the task: pass --claim too.");
@@ -4031,6 +4112,7 @@ async function tasks(args) {
4031
4112
  if (isMessageRef(target)) {
4032
4113
  const own = body !== void 0 ? "text" : [
4033
4114
  "label",
4115
+ "attach",
4034
4116
  "no-sync",
4035
4117
  "idempotency-key"
4036
4118
  ].find((name) => flags[name] !== void 0 && flags[name] !== false);
@@ -4047,8 +4129,10 @@ async function tasks(args) {
4047
4129
  } else {
4048
4130
  const said = await text(body, { missing: "Missing the task's text: pass it, or - to read it from stdin. --file takes a plan of several." });
4049
4131
  sentLength = said.length;
4132
+ const files = await attachments(board);
4050
4133
  made = await board.tasks.create(target, {
4051
4134
  text: said,
4135
+ ...files.length ? { attachments: files } : {},
4052
4136
  ...flags.label?.length ? { labels: labelPairs(flags.label) } : {},
4053
4137
  ...flags["no-sync"] ? { noSync: true } : {},
4054
4138
  ...flags["idempotency-key"] ? { id: flags["idempotency-key"] } : {},
@@ -4113,6 +4197,7 @@ async function tasks(args) {
4113
4197
  const claim = await claimFor(board, claims, before[0], "run");
4114
4198
  if (typeof claim === "number") return claim;
4115
4199
  const id = claim.task.id;
4200
+ runTask = id;
4116
4201
  const lease = seconds("lease");
4117
4202
  const ran = await runCommand(command, {
4118
4203
  env: {
@@ -4280,6 +4365,47 @@ async function tasks(args) {
4280
4365
  }
4281
4366
  }
4282
4367
  }
4368
+ /** 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. */
4369
+ function taskNoteTooLong(said) {
4370
+ const { command, args } = current;
4371
+ if (command !== "tasks" || ![
4372
+ "run",
4373
+ "complete",
4374
+ "fail",
4375
+ "block",
4376
+ "cancel"
4377
+ ].includes(args[0] ?? "")) return null;
4378
+ const what = /^\s*(result|reason)\b/i.exec(said)?.[1]?.toLowerCase();
4379
+ if (what !== "result" && what !== "reason" || !/(at most|longer than|too long)/i.test(said)) return null;
4380
+ return what;
4381
+ }
4382
+ /** 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. */
4383
+ function noteRecovery(whole) {
4384
+ const { args } = current;
4385
+ const named = args[1] !== void 0 && isMessageRef(args[1]) ? messageId(args[1]) : "<ID>";
4386
+ const id = args[0] === "run" ? runTask ?? named : named;
4387
+ const verb = args[0] === "run" ? "complete" : args[0];
4388
+ return [{
4389
+ instruction: `Reply the full ${whole} in the task's thread`,
4390
+ argv: [
4391
+ ...cli(),
4392
+ "reply",
4393
+ id,
4394
+ "-",
4395
+ ...onThisBoard()
4396
+ ]
4397
+ }, {
4398
+ instruction: `Then ${verb} it with a line or two`,
4399
+ argv: [
4400
+ ...cli(),
4401
+ "tasks",
4402
+ verb,
4403
+ id,
4404
+ "<A LINE OR TWO>",
4405
+ ...onThisBoard()
4406
+ ]
4407
+ }];
4408
+ }
4283
4409
  /** How a board's own word about a task reads from here: the headline, and the way on. Null for any other code. */
4284
4410
  function taskFailure(code, status) {
4285
4411
  const { command, args } = current;
@@ -4750,6 +4876,7 @@ async function main(argv, options) {
4750
4876
  handToken(options.token ?? null);
4751
4877
  handTeam(options.team ?? null);
4752
4878
  handFetch(options.fetch ?? null);
4879
+ handProgram("cli");
4753
4880
  try {
4754
4881
  return await runOnce(argv, options);
4755
4882
  } finally {
@@ -4757,6 +4884,7 @@ async function main(argv, options) {
4757
4884
  handToken(null);
4758
4885
  handTeam(null);
4759
4886
  handFetch(null);
4887
+ handProgram(null);
4760
4888
  }
4761
4889
  }
4762
4890
  async function runOnce(argv, options) {
@@ -4770,6 +4898,7 @@ async function runOnce(argv, options) {
4770
4898
  teamDefault = null;
4771
4899
  sent = () => null;
4772
4900
  sentLength = 0;
4901
+ runTask = void 0;
4773
4902
  self = null;
4774
4903
  try {
4775
4904
  parse(argv);
@@ -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-DawFxCk6.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,36 +1,6 @@
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-DjatfYjl.mjs";
3
3
  import { z } from "zod";
4
- //#region src/client/ids.ts
5
- const hex = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
6
- /** SHA-256 of `text`, in hex. */
7
- async function sha256(text) {
8
- return hex(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text))));
9
- }
10
- /**
11
- * A UUIDv8 from `parts`, exactly as A2's `idempotentId` makes one: the IDs a board derives for the
12
- * writes its own code makes, which no request may post with.
13
- */
14
- async function derivedId(...parts) {
15
- const bytes = new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(parts)))).slice(0, 16);
16
- bytes[6] = bytes[6] & 15 | 128;
17
- bytes[8] = bytes[8] & 63 | 128;
18
- const text = hex(bytes);
19
- return `${text.slice(0, 8)}-${text.slice(8, 12)}-${text.slice(12, 16)}-${text.slice(16, 20)}-${text.slice(20, 32)}`;
20
- }
21
- /** A derived ID's shape. */
22
- const DERIVED_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-8[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
23
- /**
24
- * A post's ID, from one derived for it, under `principal`: a board takes a `key:<principal>:` ID
25
- * only from that principal, so no one else can post with it first.
26
- */
27
- const keyId = async (principal, derived) => `key:${principal}:${(await sha256(`board-key\u001f${derived}`)).slice(0, 32)}`;
28
- /**
29
- * Whether `id` is exactly the shape `keyId` makes for `principal`. A prefix check isn't enough:
30
- * a principal's ID can be the start of another's (`oidc:gitlab.com:acme` and `oidc:gitlab.com:acme:ci`).
31
- */
32
- const isKeyIdOf = (id, principal) => id.startsWith(`key:${principal}:`) && /^[0-9a-f]{32}$/.test(id.slice(`key:${principal}:`.length));
33
- //#endregion
34
4
  //#region src/contract/profiles.ts
35
5
  /**
36
6
  * What an actor's profile is, when it's a platform user a principal's sync speaks for: `slack:user:U0456`
@@ -176,4 +146,4 @@ async function runMiddleware(middleware, input, commit) {
176
146
  return committed.value;
177
147
  }
178
148
  //#endregion
179
- export { sha256 as _, waitUntil as a, platformProfile as c, userIdOf as d, viaText as f, keyId as g, isKeyIdOf as h, afterRetry as i, shownName as l, derivedId as m, MIDDLEWARE_ACTOR as n, actorParts as o, DERIVED_ID as p, runMiddleware as r, importedHandle as s, DroppedError as t, underPrincipal as u };
149
+ export { waitUntil as a, platformProfile as c, userIdOf as d, viaText as f, afterRetry as i, shownName as l, MIDDLEWARE_ACTOR as n, actorParts as o, runMiddleware as r, importedHandle as s, DroppedError as t, underPrincipal as u };
@@ -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-DSX-CI5c.mjs";
3
- import { i as LOGINS, r as LOGIN } from "./auth-D9ycDQK0.mjs";
4
- import { h as localTokenFile, t as board } from "./server-55vryxAl.mjs";
5
- import { t as oidcTokens } from "./tokens-B3gXkQCs.mjs";
6
- import { t as local } from "./local-B5aZcAwj.mjs";
1
+ import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-DjatfYjl.mjs";
2
+ import { i as hostCheckedBy } from "./exports-B_UGnrnN.mjs";
3
+ import { i as LOGINS, r as LOGIN } from "./auth-AwZJQpCO.mjs";
4
+ import { g as localTokenFile, t as board } from "./server-BXbcS-n9.mjs";
5
+ import { t as oidcTokens } from "./tokens-CaEPmiG1.mjs";
6
+ import { t as local } from "./local-BiG1WJk0.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 { o as compileWatcher, u as METHODS } from "./task-batch-iecHMssy.mjs";
6
- import { c as createVercel, d as withoutToken, f as tailWatchers, p as deployedOnVercel, r as createBoard, u as PROTOCOL_ROUTES } from "./exports-DSX-CI5c.mjs";
3
+ import { _ as DERIVED_ID, b as keyId, f as BoardError, g as refusalCode, p as createBoardClient, t as HttpError, xt as routes } from "./errors-DjatfYjl.mjs";
4
+ import { t as VERSION } from "./version-BRR9FkLa.mjs";
5
+ import { o as compileWatcher, u as METHODS } from "./task-batch-YMVr_c5R.mjs";
6
+ import { c as createVercel, d as withoutToken, f as tailWatchers, p as deployedOnVercel, r as createBoard, u as PROTOCOL_ROUTES } from "./exports-B_UGnrnN.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
  }
@@ -958,6 +958,14 @@ function http(url, options = {}) {
958
958
  }
959
959
  //#endregion
960
960
  //#region src/backend-vercel/index.ts
961
+ /** What sends board's requests: its CLI, while it runs a command, or else its SDK, in someone's code. */
962
+ let program = "sdk";
963
+ /** Hands board the program it runs in: `cli` while board's CLI runs a command. Null takes it back. */
964
+ function handProgram(name) {
965
+ program = name ?? "sdk";
966
+ }
967
+ /** The user agent board's requests to Vercel's API send: board, its version, and whether its CLI or its SDK sent them. */
968
+ const userAgent = () => `@vercel/board/${VERSION} (${program})`;
961
969
  /**
962
970
  * Whether this deployment's own token is what goes: on Vercel, or with its OIDC token pulled
963
971
  * (`vercel env pull`), a deployment acts as its project. Never under an app that runs board's CLI
@@ -1080,10 +1088,17 @@ async function withGithubActions(input, init) {
1080
1088
  }
1081
1089
  const environment = {
1082
1090
  fetch: () => async (input, init = {}) => {
1083
- if (asGithubActions()) return withGithubActions(input, init);
1084
- const credential = await token();
1085
- if (asLogin()) return asYou(input, init, credential);
1086
1091
  const headers = new Headers(init.headers);
1092
+ headers.set("user-agent", userAgent());
1093
+ if (asGithubActions()) return withGithubActions(input, {
1094
+ ...init,
1095
+ headers
1096
+ });
1097
+ const credential = await token();
1098
+ if (asLogin()) return asYou(input, {
1099
+ ...init,
1100
+ headers
1101
+ }, credential);
1087
1102
  headers.set("authorization", `Bearer ${credential}`);
1088
1103
  return globalThis.fetch(input, {
1089
1104
  ...init,
@@ -1114,10 +1129,10 @@ function vercel(options = {}) {
1114
1129
  function board(options = {}) {
1115
1130
  return createBoard(options, {
1116
1131
  backend: (fetch) => process.env.BOARD_URL?.trim() ? http() : vercel(fetch ? { fetch } : {}),
1117
- sync: () => import("./engine-C8wCzkw-.mjs"),
1118
- serving: () => import("./serving-C1mhZQqH.mjs"),
1132
+ sync: () => import("./engine-CfVTyEeo.mjs"),
1133
+ serving: () => import("./serving-B2BNr4PR.mjs"),
1119
1134
  sandbox: (url, token) => sandboxHeaders(url, url, token)
1120
1135
  });
1121
1136
  }
1122
1137
  //#endregion
1123
- export { vercelProjectFile as _, vercel as a, boardUrl as c, environmentProfile as d, handFetch as f, projectDir as g, localTokenFile as h, handTeam as i, configDir as l, handToken as m, credentialSource as n, http as o, handLogin as p, credentialed as r, PASSED as s, board as t, connect as u };
1138
+ export { projectDir as _, handTeam as a, PASSED as c, connect as d, environmentProfile as f, localTokenFile as g, handToken as h, handProgram as i, boardUrl as l, handLogin as m, credentialSource as n, vercel as o, handFetch as p, credentialed as r, http as s, board as t, configDir as u, vercelProjectFile as v };