@vercel/board 0.48.1 → 0.49.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 (82) hide show
  1. package/dist/{access-C06pIr0M.mjs → access-B8DnrnHa.mjs} +29 -17
  2. package/dist/access.d.mts +2 -2
  3. package/dist/access.mjs +5 -5
  4. package/dist/{actors-Dkyg-oo0.mjs → actors-DewJKyqy.mjs} +4 -3
  5. package/dist/{auth-B9-wXQ-x.mjs → auth-CEU06Nyp.mjs} +2 -2
  6. package/dist/{auth-li3lKwJG.d.mts → auth-Z9-Khvvw.d.mts} +1 -1
  7. package/dist/{backend-UBP6HimX.d.mts → backend-BzCXxVZ-.d.mts} +19 -5
  8. package/dist/backend-local.d.mts +1 -1
  9. package/dist/backend-local.mjs +1 -1
  10. package/dist/{chat-provider-kNWd6MQC.mjs → chat-provider-BS_fr61g.mjs} +2 -2
  11. package/dist/{chat-provider-iN0DFsSE.d.mts → chat-provider-DQ1GHm4o.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 +3 -3
  16. package/dist/cli.mjs +6 -6
  17. package/dist/client-C2T4eaXd.d.mts +544 -0
  18. package/dist/{commands-CJsOA-hf.d.mts → commands-Cm4sODIu.d.mts} +12 -8
  19. package/dist/{commands-Dk6_cHLS.mjs → commands-nN8WpvCe.mjs} +75 -58
  20. package/dist/{conformance-CDP8y2Zm.mjs → conformance-0xONNKcB.mjs} +102 -20
  21. package/dist/conformance.d.mts +1 -1
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{engine-BQ0hJw2w.mjs → engine-BH_nfJ3N.mjs} +6 -5
  24. package/dist/{errors-QhkdzI-o.mjs → errors-DwV7I0g4.mjs} +53 -174
  25. package/dist/{events-B-qyxNsJ.mjs → events-B76-4bNp.mjs} +2 -2
  26. package/dist/{exports-inhbjAWi.d.mts → exports-CKEK1fxf.d.mts} +4 -4
  27. package/dist/{exports-BzSG0_wL.mjs → exports-DLzyKwEp.mjs} +336 -82
  28. package/dist/{external-BuVTXT1R.mjs → external-BLI4W_-V.mjs} +1 -1
  29. package/dist/{index-B0Fnhvk7.d.mts → index-DxqSw8yd.d.mts} +2 -2
  30. package/dist/index.d.mts +6 -6
  31. package/dist/index.mjs +4 -4
  32. package/dist/index.node.d.mts +7 -7
  33. package/dist/index.node.mjs +4 -4
  34. package/dist/inspect/app.js +39 -39
  35. package/dist/inspect-B2ImmOvw.mjs +272 -0
  36. package/dist/inspect-DnRQUmP8.mjs +2 -0
  37. package/dist/inspect.d.mts +17 -0
  38. package/dist/inspect.mjs +196 -0
  39. package/dist/{local-BdKxz-Dn.mjs → local-DPpSEq2_.mjs} +132 -50
  40. package/dist/{main-BgiViRZ8.mjs → main-CqX7JqzE.mjs} +214 -46
  41. package/dist/{memory-CMm-Fk_A.mjs → memory-DzqkXIB-.mjs} +2 -2
  42. package/dist/{middleware-CT6vMNUc.mjs → middleware-ysFm2S4v.mjs} +2 -2
  43. package/dist/{page-D-OzDOAX.mjs → page-7KWSGxyC.mjs} +12 -2
  44. package/dist/page-CN77B014.mjs +2 -0
  45. package/dist/profile-header-Cj0Cb1cf.mjs +163 -0
  46. package/dist/{provider-DC3WHUXo.d.mts → provider-Dwb_9mnu.d.mts} +3 -529
  47. package/dist/{routes-CjA6Mp4D.d.mts → routes-B6SEA9yw.d.mts} +130 -4
  48. package/dist/{routes-ABXf3CKq.mjs → routes-qS92xz8U.mjs} +33 -7
  49. package/dist/{schemas-7VFdomFB.mjs → schemas-TeVe4Udh.mjs} +4 -2
  50. package/dist/{serve-C2Jbr7pR.mjs → serve-CYr4RwRM.mjs} +5 -5
  51. package/dist/{server-EOQC5Gtq.mjs → server-V7qyVUiJ.mjs} +11 -9
  52. package/dist/{serving-BNdiReQT.mjs → serving-BzNxlnDV.mjs} +1 -1
  53. package/dist/{inspect-n9brh-TT.mjs → shell-BLHZoP-x.mjs} +25 -274
  54. package/dist/{sql-IEbO5vXs.mjs → sql-DIKQd5Me.mjs} +2 -2
  55. package/dist/{sqlite-CVG8XKHm.mjs → sqlite-BF9kBDh1.mjs} +2 -2
  56. package/dist/{sqlite-db-BJjPQYx4.mjs → sqlite-db-CSYwiZ4E.mjs} +1 -1
  57. package/dist/sync-chat-sdk.d.mts +2 -2
  58. package/dist/sync-chat-sdk.mjs +2 -2
  59. package/dist/sync-github.d.mts +2 -2
  60. package/dist/sync-github.mjs +2 -2
  61. package/dist/sync-linear.d.mts +3 -3
  62. package/dist/sync-linear.mjs +2 -2
  63. package/dist/sync-slack.d.mts +3 -3
  64. package/dist/sync-slack.mjs +11 -7
  65. package/dist/sync.d.mts +2 -2
  66. package/dist/sync.mjs +2 -2
  67. package/dist/{task-batch-D4p9N8lN.mjs → task-batch-CujTLmTB.mjs} +10 -11
  68. package/dist/{tokens-BCp4EWTQ.mjs → tokens-BmCDAT4N.mjs} +2 -2
  69. package/dist/version-BCoWGLEW.mjs +5 -0
  70. package/docs/01-board/01-mounting.md +8 -0
  71. package/docs/01-board/04-messages.md +6 -2
  72. package/docs/01-board/05-reading.md +17 -2
  73. package/docs/01-board/09-access.md +40 -6
  74. package/docs/01-board/11-tasks.md +3 -3
  75. package/docs/03-guides/02-inspector.md +31 -0
  76. package/docs/04-reference/01-cli.md +81 -32
  77. package/docs/04-reference/02-board.md +14 -3
  78. package/docs/04-reference/03-http.md +5 -3
  79. package/docs/04-reference/05-conformance.md +7 -0
  80. package/package.json +5 -1
  81. package/dist/inspect-BB-XUPuz.mjs +0 -2
  82. package/dist/page-Dr9Aqlej.mjs +0 -2
@@ -1,15 +1,18 @@
1
- import { C as fileSize, b as DIRECT_UPLOAD_BYTES_MAX, f as BoardError } from "./errors-QhkdzI-o.mjs";
2
- import { m as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-7VFdomFB.mjs";
1
+ import { a as DIRECT_UPLOAD_BYTES_MAX, c as fileSize } from "./profile-header-Cj0Cb1cf.mjs";
2
+ import { m as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-TeVe4Udh.mjs";
3
+ import "./routes-qS92xz8U.mjs";
3
4
  import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
4
- import { l as shownName } from "./middleware-CT6vMNUc.mjs";
5
+ import { f as BoardError } from "./errors-DwV7I0g4.mjs";
6
+ import { l as shownName } from "./middleware-ysFm2S4v.mjs";
5
7
  import { d as parseSchemaId, r as findBlocks, t as block } from "./blocks-CVoBC7ur.mjs";
6
8
  import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
7
- import { c as withMentions, g as VERSION } from "./task-batch-D4p9N8lN.mjs";
8
- import { r as PERMISSIONS } from "./access-C06pIr0M.mjs";
9
- import { i as isBoardName, n as createTasksInChunks, s as isApiMessageId, t as TasksInChunksError } from "./exports-BzSG0_wL.mjs";
10
- import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-Dk6_cHLS.mjs";
11
- import { a as vercel, c as configDir, d as handFetch, f as handLogin, h as vercelProjectFile, i as handTeam, l as connect, n as credentialSource, o as http, r as credentialed, s as boardUrl, t as board, u as environmentProfile } from "./server-EOQC5Gtq.mjs";
12
- import { t as conformance } from "./conformance-CDP8y2Zm.mjs";
9
+ import { t as VERSION } from "./version-BCoWGLEW.mjs";
10
+ import { r as PERMISSIONS } from "./access-B8DnrnHa.mjs";
11
+ import { c as withMentions } from "./task-batch-CujTLmTB.mjs";
12
+ import { i as isBoardName, n as createTasksInChunks, s as isApiMessageId, t as TasksInChunksError } from "./exports-DLzyKwEp.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-nN8WpvCe.mjs";
14
+ import { a as vercel, c as configDir, d as handFetch, f as handLogin, h as vercelProjectFile, i as handTeam, l as connect, n as credentialSource, o as http, r as credentialed, s as boardUrl, t as board, u as environmentProfile } from "./server-V7qyVUiJ.mjs";
15
+ import { t as conformance } from "./conformance-0xONNKcB.mjs";
13
16
  import { n as displayText, t as byVercelBot } from "./bots-CqPYxkqK.mjs";
14
17
  import { spawn } from "node:child_process";
15
18
  import { createHash, randomUUID } from "node:crypto";
@@ -144,6 +147,8 @@ function inputOf(started) {
144
147
  default: return { kind: started.kind };
145
148
  }
146
149
  }
150
+ /** Each pattern `--can` flags name, as typed: what a grant made with them reaches. */
151
+ const patternsIn = (values) => [...new Set(values.flatMap((value) => value.split(";")).map((entry) => entry.slice(0, Math.max(entry.indexOf("="), 0)).trim()).filter(Boolean))];
147
152
  const WORDS = [
148
153
  ...PERMISSIONS,
149
154
  "all",
@@ -1442,8 +1447,51 @@ function parse(argv) {
1442
1447
  if (foreign) throw foreignOption(foreign.name, word);
1443
1448
  if (canonical(positionals[0]) !== word) throw misplaced(args, word);
1444
1449
  }
1450
+ /**
1451
+ * An option that has another name now, `--file`: passing the old one says so, as a command that's
1452
+ * gone does. Where the old one has no `--file` to become (one task's text, a schema written
1453
+ * inline), it says where that goes instead.
1454
+ */
1455
+ function renamedOption(name, word, argv) {
1456
+ const creates = word !== void 0 && argv[argv.indexOf(word) + 1] === "create";
1457
+ if (name === "text-file" && word === "tasks" && creates) return usage("--text-file is gone from tasks create.", {
1458
+ reason: "unknown_option",
1459
+ next: [{ instruction: "Pass the text, or - to read it from stdin: --file there is a plan of several" }]
1460
+ });
1461
+ if (name === "schema" && word === "schemas" && creates) {
1462
+ const at = argv.findIndex((arg) => arg === "--schema" || arg.startsWith("--schema="));
1463
+ const joined = argv[at]?.startsWith("--schema=") ?? false;
1464
+ const given = joined ? argv[at].slice(9) : argv[at + 1];
1465
+ if (at === -1 || given === void 0) return usage("--schema is --file now, or --data for JSON written inline.", { reason: "unknown_option" });
1466
+ const [option, value] = given === "-" ? ["--file", "-"] : given.startsWith("@") ? ["--file", given.slice(1)] : ["--data", given];
1467
+ const again = [
1468
+ ...argv.slice(0, at),
1469
+ option,
1470
+ value,
1471
+ ...argv.slice(at + (joined ? 1 : 2))
1472
+ ];
1473
+ return usage(`--schema is ${option} now.`, {
1474
+ reason: "unknown_option",
1475
+ next: [{
1476
+ instruction: `Run it with ${option}`,
1477
+ argv: [...cli(), ...again]
1478
+ }]
1479
+ });
1480
+ }
1481
+ if (!(name === "text-file" && word !== void 0 && TEXT.has(word) || name === "tasks-file" && word === "tasks" && creates)) return void 0;
1482
+ const again = argv.map((arg) => arg === `--${name}` ? "--file" : arg.startsWith(`--${name}=`) ? `--file=${arg.slice(name.length + 3)}` : arg);
1483
+ return usage(`--${name} is --file now.`, {
1484
+ reason: "unknown_option",
1485
+ next: [{
1486
+ instruction: "Run it with --file",
1487
+ argv: [...cli(), ...again]
1488
+ }]
1489
+ });
1490
+ }
1445
1491
  /** An option `word` doesn't take: what to do instead, where there's something better to say than that. */
1446
1492
  function foreignOption(name, word) {
1493
+ const renamed = renamedOption(name, word, typed);
1494
+ if (renamed) return renamed;
1447
1495
  if (name === "text" && TEXT.has(word)) return usage(`--text is a filter for read, tail, and wait. ${word} takes its text as an argument, in quotes.`);
1448
1496
  if (name === "sync" && word === "schedule") return usage("Can't use --sync with schedule. A schedule posts where you point it.");
1449
1497
  if (name === "attach" && word === "edit") return usage("edit can't attach files: reply with the file instead.", {
@@ -1487,6 +1535,8 @@ function parseFailure(error, argv, word) {
1487
1535
  const dash = argv.indexOf("--");
1488
1536
  const options = dash === -1 ? argv : argv.slice(0, dash);
1489
1537
  const spaced = token === void 0 ? void 0 : options.find((arg) => /\s/.test(arg) && (token.startsWith("--") ? arg === token : arg.startsWith(token)));
1538
+ const renamed = !spaced && option.startsWith("--") ? renamedOption(option.slice(2), word, argv) : void 0;
1539
+ if (renamed) return renamed;
1490
1540
  const guess = !spaced && option.startsWith("--") ? closest(option.slice(2), optionsOf(word)) : void 0;
1491
1541
  const next = [{
1492
1542
  instruction: "See all options",
@@ -1615,13 +1665,14 @@ function oneText(command, target, extra) {
1615
1665
  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.`);
1616
1666
  }
1617
1667
  /**
1618
- * A message's text: the argument, stdin for `-`, or the file `--text-file` names (`-` for stdin).
1619
- * `optional` when the message can go without, as one with `--attach` files can.
1668
+ * A message's text: the argument, stdin for `-`, or the file `--file` names (`-` for stdin).
1669
+ * `optional` when the message can go without, as one with `--attach` files can. `missing` is
1670
+ * what's said when there's none: a task's `--file` holds a plan, so it says so itself.
1620
1671
  */
1621
- async function text(value, { optional = false } = {}) {
1622
- const file = flags["text-file"];
1672
+ async function text(value, { optional = false, missing = "Missing the message's text: pass it, - to read it from stdin, or --file <path>." } = {}) {
1673
+ const file = flags.file;
1623
1674
  if (file !== void 0) {
1624
- if (value !== void 0) throw usage("Can't use --text-file with text: a message has no title, so its whole text comes from one or the other.");
1675
+ if (value !== void 0) throw usage("Can't use --file with text: a message has no title, so its whole text comes from one or the other.");
1625
1676
  if (file === "-") return (await io.stdin()).replace(/\n$/, "");
1626
1677
  const data = await io.readFile(file).catch((error) => {
1627
1678
  if (!(error instanceof Failed) || error.failure.reason !== "payload_too_large") throw error;
@@ -1639,7 +1690,7 @@ async function text(value, { optional = false } = {}) {
1639
1690
  }
1640
1691
  if (value === void 0) {
1641
1692
  if (optional) return "";
1642
- throw usage("Missing the message's text: pass it, - to read it from stdin, or --text-file <path>.", { reason: "missing_arguments" });
1693
+ throw usage(missing, { reason: "missing_arguments" });
1643
1694
  }
1644
1695
  if (value !== "-") return value;
1645
1696
  return (await io.stdin()).replace(/\n$/, "");
@@ -1719,6 +1770,85 @@ function grantFlags(read) {
1719
1770
  throw error;
1720
1771
  }
1721
1772
  }
1773
+ /** `--lock-me-out`, as a grant write takes it: go ahead with a change this caller couldn't take back. */
1774
+ const lockMeOut = () => flags["lock-me-out"] ? { lockMeOut: true } : {};
1775
+ /** Whoever runs this, as the flags that name them in a grant, once a lockout has asked: null when no flag does. */
1776
+ let self = null;
1777
+ /** The flags that name a caller in a grant: a person, a project's deployment where it runs, an app, or a repository's runs. */
1778
+ function selfFlags({ principal, handle }) {
1779
+ const [source, kind, ...rest] = principal.split(":");
1780
+ if ((source === "vercel" || source === "local") && kind === "user" && rest.length > 0) return ["--user", rest.join(":")];
1781
+ if (source === "vercel" && kind === "project" && rest.length === 2) return [
1782
+ "--project",
1783
+ rest[0],
1784
+ "--environment",
1785
+ rest[1]
1786
+ ];
1787
+ if (source === "vercel" && kind === "app" && rest.length > 0) return ["--app", rest.join(":")];
1788
+ if (source === "github" && kind === "repo" && /^[^/\s]+\/[^/\s]+$/.test(handle)) return ["--github", handle];
1789
+ return null;
1790
+ }
1791
+ /** A grant write's refusal, on its way out: a lockout's way out names whoever runs this, which is a read away. */
1792
+ async function namingSelf(error) {
1793
+ if (error?.code === "grant_lockout") self = await client().me().then(selfFlags, () => null);
1794
+ throw error;
1795
+ }
1796
+ /** The options that say which board this run acts on, as it was given them: a command suggested for the same board carries them. */
1797
+ const onSameBoard = () => [
1798
+ ...flags.url !== void 0 ? ["--url", flags.url] : [],
1799
+ ...flags.scope !== void 0 || flags.team !== void 0 ? ["--scope", flags.scope ?? flags.team] : [],
1800
+ ...flags.name !== void 0 ? ["--name", flags.name] : []
1801
+ ];
1802
+ /**
1803
+ * The ways out of a grant change the board refused as a lockout. A new grant: first, the grant
1804
+ * that keeps manage, for whoever runs this, at each pattern it names, after which this one is no
1805
+ * lockout. Any of them: the same command, told to go ahead.
1806
+ */
1807
+ function lockoutRecoveries() {
1808
+ const [verb] = current.args;
1809
+ const anyway = {
1810
+ instruction: verb === "create" ? "Make it anyway" : verb === "revoke" ? "Revoke it anyway" : "Update it anyway",
1811
+ argv: rerun("--lock-me-out")
1812
+ };
1813
+ if (verb !== "create") return [{ instruction: "Keep manage there first, with another grant that names you" }, anyway];
1814
+ if (flags.file !== void 0) return [{ instruction: "Keep manage there yourself: add a grant to the file that names you, with all there" }, anyway];
1815
+ const all = patternsIn(flags.can ?? []).map((pattern) => `${pattern}=all`).join(";");
1816
+ return [self ? {
1817
+ instruction: "Keep manage there yourself first",
1818
+ argv: [
1819
+ ...cli(),
1820
+ "grants",
1821
+ "create",
1822
+ ...self,
1823
+ "--can",
1824
+ all,
1825
+ ...onSameBoard()
1826
+ ]
1827
+ } : { instruction: `Keep manage there yourself first, with a grant that names you: --can '${all}'` }, anyway];
1828
+ }
1829
+ /** The grants a `--file` holds: a JSON array, from the file or from stdin for `-`, each as `createGrants` takes one. The board checks what's in them. */
1830
+ async function grantsFrom(path) {
1831
+ const where = path === "-" ? "stdin" : path;
1832
+ let source;
1833
+ if (path === "-") source = await io.stdin();
1834
+ else {
1835
+ const data = await io.readFile(path);
1836
+ if (!data) throw usage(`Can't read ${path}. There's no such file.`, {
1837
+ reason: "file_not_found",
1838
+ next: []
1839
+ });
1840
+ source = new TextDecoder().decode(data);
1841
+ }
1842
+ let parsed;
1843
+ try {
1844
+ parsed = JSON.parse(source);
1845
+ } catch {
1846
+ throw usage(`${where} isn't JSON.`);
1847
+ }
1848
+ if (!Array.isArray(parsed) || parsed.length === 0 || parsed.some((grant) => typeof grant !== "object" || grant === null || Array.isArray(grant))) throw usage(`${where} holds no grants. It's a JSON array of them: [{"principals": [{"kind": "everyone"}], "can": {"ci/": ["read"]}}].`);
1849
+ if (parsed.length > 16) throw usage(`${where} holds ${parsed.length} grants, and one write makes 16 at most.`);
1850
+ return parsed;
1851
+ }
1722
1852
  /** Refuses the principal flags `verb` doesn't take: plain ones on update, `--add-` and `--remove-` ones elsewhere. */
1723
1853
  function onlyPrincipalFlags(verb) {
1724
1854
  for (const { name } of ordered) {
@@ -1774,7 +1904,7 @@ function configuredUrl() {
1774
1904
  }
1775
1905
  /**
1776
1906
  * What a message says: its text, or with `--schema`, a block of that schema and nothing else, whose
1777
- * JSON the text is, from wherever text comes (the argument, stdin, `--text-file`).
1907
+ * JSON the text is, from wherever text comes (the argument, stdin, `--file`).
1778
1908
  */
1779
1909
  async function content(value, options = {}) {
1780
1910
  const said = await given(value, options);
@@ -1795,14 +1925,15 @@ async function given(value, options) {
1795
1925
  if (typeof data !== "object" || data === null || Array.isArray(data)) throw usage(`With --schema, the text is a JSON object, like {"id":"sbx-123"}.`);
1796
1926
  return block(schema, data);
1797
1927
  }
1798
- /** A schema's JSON Schema, as `--schema` gives it: inline JSON, the file `@<path>` names, or stdin for `-`. */
1928
+ /** A schema's JSON Schema: from the file `--file` names, or stdin for `-`, or written inline as `--data`. */
1799
1929
  async function definition() {
1800
- const given = flags.schema;
1801
- if (given === void 0) throw usage("Missing --schema: its JSON Schema, inline, @<file>, or - for stdin.", { reason: "missing_arguments" });
1802
- let source = given;
1803
- if (given === "-") source = await io.stdin();
1804
- else if (given.startsWith("@")) {
1805
- const file = given.slice(1);
1930
+ const { file, data: inline } = flags;
1931
+ if (file !== void 0 && inline !== void 0) throw usage("--file and --data both give the JSON Schema: pass one.");
1932
+ if (file === void 0 && inline === void 0) throw usage("Missing its JSON Schema: --file <path>, - for stdin, or --data <json>.", { reason: "missing_arguments" });
1933
+ let source;
1934
+ if (inline !== void 0) source = inline;
1935
+ else if (file === "-") source = await io.stdin();
1936
+ else {
1806
1937
  const data = await io.readFile(file);
1807
1938
  if (!data) throw usage(`Can't read ${file}. There's no such file.`, {
1808
1939
  reason: "file_not_found",
@@ -1814,7 +1945,8 @@ async function definition() {
1814
1945
  try {
1815
1946
  parsed = JSON.parse(source);
1816
1947
  } catch {
1817
- throw usage(given === "-" || given.startsWith("@") ? `${given === "-" ? "stdin" : given.slice(1)} isn't JSON.` : `--schema takes JSON, or a file as @<path>: ${given.length > 40 ? `${given.slice(0, 40)}…` : given} isn't JSON.`);
1948
+ if (inline === void 0) throw usage(`${file === "-" ? "stdin" : file} isn't JSON.`);
1949
+ throw usage(`--data takes the JSON itself, and ${inline.length > 40 ? `${inline.slice(0, 40)}…` : inline} isn't JSON.`, { next: [{ instruction: "A file, or - for stdin, goes in --file" }] });
1818
1950
  }
1819
1951
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw usage("A schema is a JSON object: {\"type\":\"object\", …}.");
1820
1952
  return parsed;
@@ -1851,13 +1983,13 @@ function doing() {
1851
1983
  if (a === void 0 || !TASK_VERBS.has(a)) return a === void 0 ? "list tasks" : `list tasks in ${a}`;
1852
1984
  const one = b === void 0 ? "a task" : `task ${ref(b)}`;
1853
1985
  if (a === "claim" || a === "run") return flags.ready ? `claim a task in ${b ?? "a channel"}` : `claim ${one}`;
1854
- if (a === "create" && flags["tasks-file"] !== void 0) return `create tasks in ${b ?? "a channel"}`;
1986
+ if (a === "create" && flags.file !== void 0) return `create tasks in ${b ?? "a channel"}`;
1855
1987
  if (a === "create") return b !== void 0 && isMessageRef(b) ? `make ${ref(b)} a task` : `create a task in ${b ?? "a channel"}`;
1856
1988
  if (a === "renew") return `renew the claim on ${one}`;
1857
1989
  if (a === "needs") return `change what ${one} needs`;
1858
1990
  return `${a} ${one}`;
1859
1991
  }
1860
- case "grants": return a === "create" ? "create the grant" : a === "update" ? `update grant ${b}` : a === "explain" ? `explain ${b ?? "the channel"}` : a === "revoke" ? `revoke grant ${b}` : "list grants";
1992
+ case "grants": return a === "create" ? flags.file !== void 0 ? "create the grants" : "create the grant" : a === "update" ? `update grant ${b}` : a === "explain" ? `explain ${b ?? "the channel"}` : a === "revoke" ? `revoke grant ${b}` : "list grants";
1861
1993
  case "schemas": return a === "create" ? `register schema ${b ?? ""}`.trimEnd() : a === "inspect" ? `read schema ${b ?? ""}`.trimEnd() : "list schemas";
1862
1994
  case "sources": return b === void 0 ? "list sources" : `${b} ${c ?? "it"} on ${a}`;
1863
1995
  case "download": return `download ${a ?? "the attachment"}`;
@@ -1906,18 +2038,20 @@ function missing() {
1906
2038
  function failureOf(error) {
1907
2039
  if (error instanceof Failed) return error.failure;
1908
2040
  const message = error instanceof Error ? error.message : String(error);
1909
- const { code, status, hint, origin } = error;
2041
+ const { code, status, hint, origin, retryAfter } = error;
1910
2042
  if (typeof code !== "string" || typeof status !== "number") return {
1911
2043
  class: "unknown",
1912
2044
  reason: "unexpected_error",
1913
2045
  message: `Failed to ${doing()}.`,
1914
2046
  details: [message]
1915
2047
  };
2048
+ const wait = typeof retryAfter === "number" && Number.isInteger(retryAfter) && retryAfter >= 0 ? retryAfter : void 0;
1916
2049
  const said = { error: {
1917
2050
  code,
1918
2051
  message,
1919
2052
  status,
1920
- ...typeof hint === "string" ? { hint } : {}
2053
+ ...typeof hint === "string" ? { hint } : {},
2054
+ ...wait !== void 0 ? { retryAfter: wait } : {}
1921
2055
  } };
1922
2056
  if (origin === "handle") {
1923
2057
  const fix = typeof hint === "string" ? [{ instruction: hint }] : [];
@@ -2036,6 +2170,7 @@ function failureOf(error) {
2036
2170
  } : theirs("not_found", specific("not_found"), `Can't ${doing()}.`);
2037
2171
  }
2038
2172
  if (status === 409) {
2173
+ if (code === "grant_lockout" && current.command === "grants") return theirs("conflict", code, `Can't ${doing()}: it would lock you out.`, lockoutRecoveries());
2039
2174
  const { args } = current;
2040
2175
  const newer = code === "newer_message" && flags.after !== void 0 && args[0] !== void 0;
2041
2176
  const labeled = code === "label_conflict" && (flags.if !== void 0 || flags["if-unset"] !== void 0) && args[0] !== void 0;
@@ -2076,11 +2211,14 @@ function failureOf(error) {
2076
2211
  }] : []);
2077
2212
  }
2078
2213
  if (status === 413) return theirs("limit", "payload_too_large", `Can't ${doing()}. It's too large for the board.`);
2079
- if (status === 429) return theirs("rate_limit", "rate_limited", "Too many requests to the board. Try again in a minute.");
2214
+ 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" }]);
2215
+ 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" }]);
2080
2216
  if (status === 501) return theirs("platform", specific("not_supported"), `Can't ${doing()}. This board doesn't support it.`);
2081
2217
  if (code === "unreachable") return theirs("network", "network_error", "Couldn't reach the board.");
2082
2218
  return theirs("platform", "api_error", `Failed to ${doing()}.`);
2083
2219
  }
2220
+ /** `42s`, `2m`: a wait the way people say it. */
2221
+ const waitFor = (seconds) => seconds < 120 ? `${Math.max(1, seconds)}s` : `${Math.ceil(seconds / 60)}m`;
2084
2222
  /** How this run ends with `failure`: shown on stderr, or by the app, and its exit code. */
2085
2223
  function report(failure, json) {
2086
2224
  if (app.onError) app.onError(failure, { json });
@@ -2455,15 +2593,22 @@ async function run(command, args) {
2455
2593
  if (!narrowed) for (const schedule of thread.schedules ?? []) out(formatSchedule(schedule, { pad: " " }));
2456
2594
  return 0;
2457
2595
  }
2596
+ const limit = flags.limit ? Number(flags.limit) : 50;
2597
+ const peek = !flags.json && Number.isInteger(limit) && limit >= 1 && limit < 500;
2458
2598
  const query = {
2459
2599
  ...filters(target),
2460
- ...flags.limit ? { limit: Number(flags.limit) } : {}
2600
+ ...peek ? { limit: limit + 1 } : flags.limit ? { limit } : {}
2461
2601
  };
2462
2602
  const old = outdated("This board can't list threads.");
2463
- const page = await board.threads(query).catch((error) => {
2603
+ const listed = await board.threads(query).catch((error) => {
2464
2604
  throw error instanceof BoardError && error.status === 404 && /^no route: /.test(error.message) ? old : error;
2465
2605
  });
2466
- if (!Array.isArray(page.threads)) throw old;
2606
+ if (!Array.isArray(listed.threads)) throw old;
2607
+ const more = listed.threads.length > limit || !peek && listed.threads.length === limit;
2608
+ const page = listed.threads.length > limit ? {
2609
+ ...listed,
2610
+ threads: flags.after !== void 0 ? listed.threads.slice(0, limit) : listed.threads.slice(-limit)
2611
+ } : listed;
2467
2612
  if (!page.threads.length && target) {
2468
2613
  const channels = (await board.channels()).map((c) => c.path);
2469
2614
  if (!channels.some((path) => path === target || path.startsWith(target.replace(/\/?$/, "/")))) {
@@ -2493,6 +2638,20 @@ async function run(command, args) {
2493
2638
  handles
2494
2639
  }));
2495
2640
  }
2641
+ const latest = page.threads.at(-1);
2642
+ if (more && flags.after !== void 0 && latest) {
2643
+ if (![
2644
+ "re",
2645
+ "by",
2646
+ "mentions",
2647
+ "from",
2648
+ "text"
2649
+ ].some((key) => key in query)) out(`\nmore since then: ${commandLine(rerunWithout(["--after"], "--after", (latest.last ?? latest.message).id))}`);
2650
+ else if (limit < 500) out(`\nmore since then: ${commandLine(rerunWithout(["--limit", "-n"], "--limit", String(Math.min(500, limit * 2))))}`);
2651
+ else out(`\n(more not shown: 500 is the most a read lists, so narrow it with --label, --by, or --text)`);
2652
+ return 0;
2653
+ }
2654
+ if (more) out(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 narrow it with --label, --by, or --text)`);
2496
2655
  out(`\nnew since then: ${commandLine(rerunWithout(["--after"], "--after", String(page.cursor)))}`);
2497
2656
  return 0;
2498
2657
  }
@@ -2604,13 +2763,23 @@ async function run(command, args) {
2604
2763
  if (rest.length > 0) throw usage(`grants create takes no arguments: ${rest[0]} is one too many.`);
2605
2764
  onlyPrincipalFlags("create");
2606
2765
  const principals = grantFlags(() => principalsIn(ordered, [""])).map(({ principal }) => principal);
2766
+ if (flags.file !== void 0) {
2767
+ if (principals.length > 0 || flags.can !== void 0) throw usage("--file holds the grants: each one in it names its own principals and can, so it goes without theirs.");
2768
+ const { grants } = await client().createGrants(await grantsFrom(flags.file), lockMeOut()).catch(namingSelf);
2769
+ if (flags.json) result({
2770
+ grants,
2771
+ outcome: "created"
2772
+ });
2773
+ else for (const grant of grants) out(`created ${grantRow(grant)}`);
2774
+ return 0;
2775
+ }
2607
2776
  if (principals.length === 0) throw usage("A grant names whom it lets in: --user, --project, --github, --oidc, --all-users, --all-projects, or --everyone.", { reason: "missing_arguments" });
2608
2777
  const can = grantFlags(() => grantCanOf(flags.can ?? []));
2609
2778
  if (Object.keys(can).length === 0) throw usage("A grant says what it lets them do: --can pattern=permissions, like --can 'ci/=read,post'.", { reason: "missing_arguments" });
2610
2779
  const { grant } = await client().createGrant({
2611
2780
  principals,
2612
2781
  can
2613
- });
2782
+ }, lockMeOut()).catch(namingSelf);
2614
2783
  if (flags.json) result({
2615
2784
  grant,
2616
2785
  outcome: "created"
@@ -2648,7 +2817,7 @@ async function run(command, args) {
2648
2817
  ...add.length > 0 ? { add } : {},
2649
2818
  ...remove.length > 0 ? { remove } : {},
2650
2819
  ...can !== void 0 ? { can } : {}
2651
- });
2820
+ }, lockMeOut());
2652
2821
  if (flags.json) result({
2653
2822
  grant,
2654
2823
  outcome: "updated"
@@ -2669,7 +2838,7 @@ async function run(command, args) {
2669
2838
  }
2670
2839
  if (verb === "revoke") {
2671
2840
  const id = grantId(rest[0]);
2672
- const { revoked } = await client().revokeGrant(id);
2841
+ const { revoked } = await client().revokeGrant(id, lockMeOut());
2673
2842
  if (flags.json) result({
2674
2843
  grant: id,
2675
2844
  outcome: revoked ? "revoked" : "unchanged"
@@ -3029,15 +3198,14 @@ function seconds(flag) {
3029
3198
  return total;
3030
3199
  }
3031
3200
  /**
3032
- * `tasks create <channel> --tasks-file <path>`: the tasks a JSON file holds, as `tasks.createMany`
3201
+ * `tasks create <channel> --file <path>`: the tasks a JSON file holds, as `tasks.createMany`
3033
3202
  * takes them, made in as many writes as the board needs. It prints each as the list shows one.
3034
3203
  * The whole plan goes under one key, `--idempotency-key`'s or this run's own, so one that stops
3035
3204
  * midway says what was made and is finished by the same command.
3036
3205
  */
3037
3206
  async function createPlan(target, text, path) {
3038
- if (isMessageRef(target)) throw usage(`--tasks-file starts threads in a channel, and ${ref(target)} is a thread.`);
3207
+ if (isMessageRef(target)) throw usage(`--file holds a plan, which starts threads in a channel, and ${ref(target)} is a thread.`);
3039
3208
  const own = text !== void 0 ? "text" : [
3040
- "text-file",
3041
3209
  "label",
3042
3210
  "needs",
3043
3211
  "for",
@@ -3045,7 +3213,7 @@ async function createPlan(target, text, path) {
3045
3213
  "lease",
3046
3214
  "no-sync"
3047
3215
  ].find((name) => flags[name] !== void 0 && flags[name] !== false);
3048
- if (own !== void 0) throw usage(`${own === "text" ? "Text" : `--${own}`} is one task's: with --tasks-file, each task in the file has its own.`);
3216
+ if (own !== void 0) throw usage(`${own === "text" ? "Text" : `--${own}`} is one task's: with --file, each task in the file has its own.`);
3049
3217
  const board = client();
3050
3218
  const tasks = await planFrom(path, board);
3051
3219
  sentLength = Math.max(0, ...tasks.map((task) => typeof task.text === "string" ? task.text.length : 0));
@@ -3085,7 +3253,7 @@ async function createPlan(target, text, path) {
3085
3253
  }))));
3086
3254
  return 0;
3087
3255
  }
3088
- /** What a task of a `--tasks-file` takes, as `tasks.createMany` does. */
3256
+ /** What a task of a plan's `--file` takes, as `tasks.createMany` does. */
3089
3257
  const PLAN_KEYS = [
3090
3258
  "key",
3091
3259
  "text",
@@ -3141,7 +3309,7 @@ function checkPlan(plan, where) {
3141
3309
  }
3142
3310
  }
3143
3311
  }
3144
- /** The tasks a `--tasks-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. */
3312
+ /** 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. */
3145
3313
  async function planFrom(path, board) {
3146
3314
  const where = path === "-" ? "stdin" : path;
3147
3315
  let source;
@@ -3158,7 +3326,7 @@ async function planFrom(path, board) {
3158
3326
  try {
3159
3327
  parsed = JSON.parse(source);
3160
3328
  } catch {
3161
- throw usage(`${where} isn't JSON.`, { next: [planHelp()] });
3329
+ 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()] });
3162
3330
  }
3163
3331
  const shape = "A plan is a JSON array of tasks: [{\"key\": \"fix\", \"text\": \"…\"}, {\"text\": \"…\", \"needs\": [{\"key\": \"fix\"}]}].";
3164
3332
  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()] });
@@ -3385,7 +3553,7 @@ async function tasks(args) {
3385
3553
  const [target, body, extra] = rest;
3386
3554
  if (!target) throw usage("Missing a channel to start a task in, or a thread's ID to make one of.", { reason: "missing_arguments" });
3387
3555
  if (extra !== void 0) throw usage(`tasks create takes a channel and quoted text: ${extra} is one too many.`);
3388
- if (flags["tasks-file"] !== void 0) return createPlan(target, body, flags["tasks-file"]);
3556
+ if (flags.file !== void 0) return createPlan(target, body, flags.file);
3389
3557
  const lease = seconds("lease");
3390
3558
  if (lease !== void 0 && !claimFlag()) throw usage("--lease is how long a claim holds the task: pass --claim too.");
3391
3559
  const { board, claims } = tasksOn();
@@ -3398,7 +3566,6 @@ async function tasks(args) {
3398
3566
  let made;
3399
3567
  if (isMessageRef(target)) {
3400
3568
  const own = body !== void 0 ? "text" : [
3401
- "text-file",
3402
3569
  "label",
3403
3570
  "no-sync",
3404
3571
  "idempotency-key"
@@ -3414,7 +3581,7 @@ async function tasks(args) {
3414
3581
  }] });
3415
3582
  made = await board.tasks.create({ re: messageId(target) }, about);
3416
3583
  } else {
3417
- const said = await text(body);
3584
+ 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." });
3418
3585
  sentLength = said.length;
3419
3586
  made = await board.tasks.create(target, {
3420
3587
  text: said,
@@ -3728,7 +3895,7 @@ function taskFailure(code, status) {
3728
3895
  }]
3729
3896
  };
3730
3897
  case "invalid_needs":
3731
- if (flags["tasks-file"] !== void 0) return {
3898
+ if (flags.file !== void 0) return {
3732
3899
  class: "usage",
3733
3900
  message: `Can't ${doing()}. A task's needs are tasks you can read, or keys of the plan's own.`,
3734
3901
  next: [{
@@ -4135,6 +4302,7 @@ async function runOnce(argv, options) {
4135
4302
  warnings = [];
4136
4303
  reached = null;
4137
4304
  sentLength = 0;
4305
+ self = null;
4138
4306
  try {
4139
4307
  parse(argv);
4140
4308
  if (flags.version) {
@@ -1,6 +1,6 @@
1
- import { r as sqlTables } from "./sql-IEbO5vXs.mjs";
1
+ import { r as sqlTables } from "./sql-DIKQd5Me.mjs";
2
2
  import { t as memory$1 } from "./store-memory-CKQVEzXN.mjs";
3
- import { t as sqliteDb } from "./sqlite-db-BJjPQYx4.mjs";
3
+ import { t as sqliteDb } from "./sqlite-db-CSYwiZ4E.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
@@ -1,5 +1,5 @@
1
- import { t as HttpError } from "./errors-QhkdzI-o.mjs";
2
- import { m as MESSAGE_TEXT_MAX, p as Labels } from "./schemas-7VFdomFB.mjs";
1
+ import { m as MESSAGE_TEXT_MAX, p as Labels } from "./schemas-TeVe4Udh.mjs";
2
+ import { t as HttpError } from "./errors-DwV7I0g4.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,7 +1,17 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  //#region src/inspect/page.ts
3
- /** Next to the CLI in `dist`, or in `dist` when running from source. */
4
- const FILES = [new URL("./inspect/app.js", import.meta.url), new URL("../../dist/inspect/app.js", import.meta.url)];
3
+ /**
4
+ * Next to the CLI in `dist`, or in `dist` when running from source. A bundler that copies files a
5
+ * module names this way (Next.js's Turbopack) copies the first, which is in the package, and
6
+ * fails on a name it can't find: so the second, which is only in a checkout, is put together at run time.
7
+ */
8
+ const FILES = [new URL("./inspect/app.js", import.meta.url), new URL([
9
+ "..",
10
+ "..",
11
+ "dist",
12
+ "inspect",
13
+ "app.js"
14
+ ].join("/"), import.meta.url)];
5
15
  /** The page's script where board is installed, or null when there's none beside it. */
6
16
  async function page() {
7
17
  for (const file of FILES) {
@@ -0,0 +1,2 @@
1
+ import { t as page } from "./page-7KWSGxyC.mjs";
2
+ export { page };