@vercel/board 0.39.0 → 0.40.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 (85) hide show
  1. package/README.md +5 -3
  2. package/dist/{access-CVkjSfxj.mjs → access-Bl_k_Hpa.mjs} +1 -1
  3. package/dist/access.d.mts +2 -2
  4. package/dist/access.mjs +4 -4
  5. package/dist/{actors-kfMejhaw.mjs → actors-yBRWTpt5.mjs} +38 -53
  6. package/dist/{auth-B3bBYOqf.mjs → auth-C8URZHLx.mjs} +2 -2
  7. package/dist/{auth-BXLCkeB0.d.mts → auth-DtmZzlHm.d.mts} +5 -2
  8. package/dist/{backend-HcCCGPG4.d.mts → backend-BW5NbBsp.d.mts} +36 -10
  9. package/dist/backend-local.d.mts +1 -1
  10. package/dist/backend-local.mjs +1 -1
  11. package/dist/blocks-CVoBC7ur.mjs +402 -0
  12. package/dist/blocks-DGvh2alZ.d.mts +33 -0
  13. package/dist/{chat-provider-DyNy5xdC.d.mts → chat-provider-Bbb9JguG.d.mts} +2 -2
  14. package/dist/cli-commands.d.mts +1 -1
  15. package/dist/cli-commands.mjs +1 -1
  16. package/dist/cli-embedded.d.mts +2 -2
  17. package/dist/cli-embedded.mjs +3 -3
  18. package/dist/cli.mjs +5 -5
  19. package/dist/{commands-B5d-lmNN.d.mts → commands-BJLocuXj.d.mts} +10 -0
  20. package/dist/{commands-BLS7erNu.mjs → commands-D6VWegVY.mjs} +88 -8
  21. package/dist/{conformance-D59Py2m2.mjs → conformance-BWhZ0k8T.mjs} +252 -5
  22. package/dist/conformance.d.mts +4 -3
  23. package/dist/conformance.mjs +1 -1
  24. package/dist/data-values-C-Cq80hz.mjs +176 -0
  25. package/dist/digest-D32GV_mX.mjs +4 -0
  26. package/dist/{engine-eUgO5jTM.mjs → engine-Djif8XVk.mjs} +191 -77
  27. package/dist/{errors-rYDxZEuN.mjs → errors-CNRJqUuL.mjs} +16 -14
  28. package/dist/{exports-M5o4PTfO.mjs → exports-C2OWIbLU.mjs} +621 -245
  29. package/dist/exports-FyRBIAMs.d.mts +4 -0
  30. package/dist/{index-rNqqgkyu.d.mts → index-Cuxbz_E0.d.mts} +2 -2
  31. package/dist/index.d.mts +7 -6
  32. package/dist/index.mjs +6 -5
  33. package/dist/index.node.d.mts +7 -6
  34. package/dist/index.node.mjs +5 -4
  35. package/dist/inspect/app.js +110 -109
  36. package/dist/inspect/engine.js +5 -5
  37. package/dist/inspect-CLy6FrOZ.mjs +2 -0
  38. package/dist/{inspect-BkXxR2uB.mjs → inspect-cGcP8ZO9.mjs} +4 -4
  39. package/dist/{local-DvkOWf4U.mjs → local-CsleYuyM.mjs} +373 -177
  40. package/dist/{main-DtV_Po9i.mjs → main-D97xuqWZ.mjs} +177 -59
  41. package/dist/{memory-DkoqhxIH.mjs → memory-BvVoglGv.mjs} +2 -2
  42. package/dist/{mentions-CB6ShY4R.mjs → mentions-CT2bN5eP.mjs} +17 -3
  43. package/dist/{middleware-CPqAuRtp.mjs → middleware-BF9vnPPS.mjs} +70 -2
  44. package/dist/{targets-C1mT3M1N.mjs → origin-DLCmrwmE.mjs} +47 -39
  45. package/dist/{page-64IwoGRu.mjs → page-6BTCZWGY.mjs} +2 -2
  46. package/dist/page-BnY8FhPn.mjs +2 -0
  47. package/dist/{provider-D5yVFisj.d.mts → provider-YqkF1E2k.d.mts} +23 -13
  48. package/dist/{routes-BffuaoTX.d.mts → routes-CAjd5ARa.d.mts} +101 -25
  49. package/dist/schemas.d.mts +37 -0
  50. package/dist/schemas.mjs +3 -0
  51. package/dist/{serve-CX1rqDF_.mjs → serve-Cs-e0Jke.mjs} +4 -4
  52. package/dist/{server-DkYkyarg.mjs → server-CIfMdIt3.mjs} +6 -6
  53. package/dist/{serving-DJMcG0dT.mjs → serving-B4l0nLng.mjs} +1 -1
  54. package/dist/{sql-l3ysn4O5.mjs → sql-Bv-RQu8n.mjs} +73 -10
  55. package/dist/{sqlite-CAwNHbQD.mjs → sqlite-D4mkYihG.mjs} +2 -2
  56. package/dist/{sqlite-db-cm5yhrD-.mjs → sqlite-db-BraLvHtf.mjs} +1 -1
  57. package/dist/sync-chat-sdk.d.mts +2 -2
  58. package/dist/sync-github.d.mts +2 -2
  59. package/dist/sync-linear.d.mts +3 -3
  60. package/dist/sync-slack.d.mts +14 -8
  61. package/dist/sync-slack.mjs +42 -15
  62. package/dist/sync.d.mts +2 -2
  63. package/dist/{tokens-DA9ipsZ-.mjs → tokens-CrrXAVGz.mjs} +2 -2
  64. package/docs/01-board/01-mounting.md +5 -3
  65. package/docs/01-board/03-identity.md +70 -38
  66. package/docs/01-board/04-messages.md +58 -1
  67. package/docs/01-board/05-reading.md +3 -3
  68. package/docs/01-board/06-watchers.md +2 -3
  69. package/docs/01-board/07-schedules.md +2 -4
  70. package/docs/01-board/08-middleware.md +1 -1
  71. package/docs/01-board/09-access.md +24 -21
  72. package/docs/02-sync/01-overview.md +70 -2
  73. package/docs/02-sync/02-functions.md +11 -6
  74. package/docs/02-sync/03-slack.md +40 -16
  75. package/docs/02-sync/06-providers.md +9 -4
  76. package/docs/04-reference/01-cli.md +110 -18
  77. package/docs/04-reference/02-board.md +63 -10
  78. package/docs/04-reference/03-http.md +154 -28
  79. package/docs/04-reference/05-conformance.md +13 -6
  80. package/docs/index.md +1 -1
  81. package/package.json +5 -1
  82. package/dist/digest-krhjNAt4.mjs +0 -4
  83. package/dist/exports-vLQ2Y2Nd.d.mts +0 -4
  84. package/dist/inspect-lnv1sLXM.mjs +0 -2
  85. package/dist/page-BUj8_UZv.mjs +0 -2
@@ -1,12 +1,14 @@
1
- import { _ as fileSize, m as DIRECT_UPLOAD_BYTES_MAX, u as BoardError } from "./errors-rYDxZEuN.mjs";
1
+ import { _ as fileSize, m as DIRECT_UPLOAD_BYTES_MAX, u as BoardError } from "./errors-CNRJqUuL.mjs";
2
2
  import { f as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-AZkxk06N.mjs";
3
- import { c as withMentions, g as VERSION } from "./targets-C1mT3M1N.mjs";
3
+ import { d as parseSchemaId, r as findBlocks, t as block } from "./blocks-CVoBC7ur.mjs";
4
+ import { h as VERSION, s as withMentions } from "./origin-DLCmrwmE.mjs";
4
5
  import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
5
- import { r as PERMISSIONS, u as parseCan } from "./access-CVkjSfxj.mjs";
6
- import { i as isApiMessageId, n as isBoardName } from "./exports-M5o4PTfO.mjs";
7
- import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-BLS7erNu.mjs";
8
- import { a as vercel, c as connect, i as handTeam, l as handFetch, n as credentialSource, o as http, p as vercelProjectFile, r as credentialed, s as boardUrl, t as board, u as handLogin } from "./server-DkYkyarg.mjs";
9
- import { t as conformance } from "./conformance-D59Py2m2.mjs";
6
+ import { l as shownName } from "./middleware-BF9vnPPS.mjs";
7
+ import { r as PERMISSIONS, u as parseCan } from "./access-Bl_k_Hpa.mjs";
8
+ import { i as isApiMessageId, n as isBoardName } from "./exports-C2OWIbLU.mjs";
9
+ import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-D6VWegVY.mjs";
10
+ import { a as vercel, c as connect, i as handTeam, l as handFetch, n as credentialSource, o as http, p as vercelProjectFile, r as credentialed, s as boardUrl, t as board, u as handLogin } from "./server-CIfMdIt3.mjs";
11
+ import { t as conformance } from "./conformance-BWhZ0k8T.mjs";
10
12
  import { t as displayText } from "./bots-CGkO76qH.mjs";
11
13
  import { spawn } from "node:child_process";
12
14
  import { readFile, stat, writeFile } from "node:fs/promises";
@@ -268,7 +270,6 @@ function explanationLine(answer, subject, kind) {
268
270
  }
269
271
  //#endregion
270
272
  //#region src/cli/format.ts
271
- /** "claude via julian" for a profile, the name otherwise. */
272
273
  /**
273
274
  * Text for a terminal. What boards and platforms say can carry control characters, ESC among them,
274
275
  * which starts the sequences that clear the screen, move the cursor, or retitle the window: each
@@ -279,13 +280,15 @@ const terminalText = (text) => text.replace(/\r\n/g, "\n").replace(/[\u0000-\u00
279
280
  const code = char.charCodeAt(0);
280
281
  return code < 32 ? String.fromCharCode(9216 + code) : code === 127 ? "␡" : "�";
281
282
  });
282
- const who = (me) => me.profile !== null && me.handle.includes("/") ? `${me.name} via ${me.handle.slice(0, me.handle.indexOf("/"))}` : me.name;
283
+ /** Who you are, as your messages show you: `claude via julian` with a profile, your name otherwise. */
284
+ const who = (me) => shownName(me);
285
+ /**
286
+ * A message's author as people see them: their name, and who they act through when they have a
287
+ * profile, an agent's person (`claude via julian`) or the principal whose sync imported a
288
+ * platform user (`Malte via www (preview)`).
289
+ */
283
290
  function authorName(message) {
284
- const author = message.author;
285
- if (!author) return message.by.actor;
286
- const slash = author.handle.indexOf("/");
287
- if (message.by.profile !== null && slash !== -1) return `${author.name} via ${author.handle.slice(0, slash)}`;
288
- return author.name;
291
+ return message.author ? shownName(message.author) : message.by.actor;
289
292
  }
290
293
  function ago(iso, now = Date.now()) {
291
294
  const seconds = Math.max(0, Math.round((now - Date.parse(iso)) / 1e3));
@@ -312,9 +315,22 @@ function reactionNames(messages) {
312
315
  return [...new Set(messages.flatMap((m) => Object.values(m.reactions).flatMap((actors) => actors.slice(0, 3))))];
313
316
  }
314
317
  /** An actor's display name from `/actors`, the way a message's author shows: `claude via julian`. */
315
- function actorName(actor) {
316
- const slash = actor.handle.indexOf("/");
317
- return slash === -1 ? actor.name : `${actor.name} via ${actor.handle.slice(0, slash)}`;
318
+ const actorName = (actor) => shownName(actor);
319
+ /**
320
+ * A message's text as a terminal shows it: a bot's in its readable form, and each block as one
321
+ * line, its schema and its data, where its fence was. A message that is only a block is that line.
322
+ */
323
+ function shownText(message) {
324
+ const text = displayText(message.text, message.by.actor);
325
+ if (!message.blocks?.length || text !== message.text) return text;
326
+ let out = "";
327
+ let at = 0;
328
+ for (const found of findBlocks(text)) {
329
+ if (found.data === void 0) continue;
330
+ out += `${text.slice(at, found.start)}data ${found.id} · ${JSON.stringify(found.data)}`;
331
+ at = found.end;
332
+ }
333
+ return out + text.slice(at);
318
334
  }
319
335
  /** Lines of a linked message an embed shows before it trails off. */
320
336
  const EMBED_LINES = 12;
@@ -334,7 +350,7 @@ function embed(link, pad) {
334
350
  function formatMessage(message, options = {}) {
335
351
  const pad = options.reply ? " " : " ";
336
352
  const head = `${options.reply ? " ↳ " : ""}#${message.id} ${authorName(message)} · ${ago(message.createdAt)}${message.editedAt ? " (edited)" : ""}${message.schedule ? ` · scheduled ${message.schedule.id}` : ""}${labels(message)}`;
337
- const body = message.deleted ? `${pad}(message removed)` : indent(displayText(message.text, message.by.actor), pad);
353
+ const body = message.deleted ? `${pad}(message removed)` : indent(shownText(message), pad);
338
354
  const files = (message.attachments ?? []).map((a) => `${pad}file ${a.name} · ${a.type} · ${fileSize(a.size)} · ${a.id}`);
339
355
  const links = message.deleted ? [] : (message.links ?? []).flatMap((link) => embed(link, pad));
340
356
  const reacted = reactions(message, options.names ?? /* @__PURE__ */ new Map());
@@ -371,7 +387,7 @@ function formatThreads(messages, known = /* @__PURE__ */ new Map()) {
371
387
  /** A root's first line, cut to fit 80 columns under its header. */
372
388
  function firstLine(message) {
373
389
  if (message.deleted) return "(message removed)";
374
- const text = displayText(message.text, message.by.actor).trim();
390
+ const text = shownText(message).trim();
375
391
  const files = message.attachments?.length ?? 0;
376
392
  if (!text) return files ? `(${files} ${files === 1 ? "file" : "files"})` : "(no text)";
377
393
  const [line = "", ...rest] = text.split(/\r?\n/);
@@ -521,9 +537,9 @@ function formatEvent(event) {
521
537
  switch (event.type) {
522
538
  case "message.posted": {
523
539
  const files = (message.attachments ?? []).map((a) => ` · file ${a.name}`).join("");
524
- return `#${message.id} ${where} ${who}: ${displayText(message.text, message.by.actor)}${files}`;
540
+ return `#${message.id} ${where} ${who}: ${shownText(message)}${files}`;
525
541
  }
526
- case "message.edited": return `#${message.id} ${where} ${who} (edited): ${displayText(message.text, message.by.actor)}`;
542
+ case "message.edited": return `#${message.id} ${where} ${who} (edited): ${shownText(message)}`;
527
543
  case "message.deleted": return `#${message.id} ${where} (message removed)`;
528
544
  case "message.linked": return `#${message.id} ${where} ↪ links ${(message.links ?? []).map((link) => link.message !== null ? `#${link.message}` : link.url).join(", ") || "nothing"}`;
529
545
  case "reaction.added":
@@ -598,6 +614,33 @@ function formatConformance(report) {
598
614
  return `${blocks.join("\n\n")}\n\n${counts.join(", ")}`;
599
615
  }
600
616
  //#endregion
617
+ //#region src/cli/schemas.ts
618
+ /** How wide a schemas row gets before its description is cut: 80 columns. */
619
+ const WIDTH = 80;
620
+ /** `text` on one line, cut to `width` with an ellipsis. */
621
+ const fitted = (text, width) => {
622
+ const line = text.replace(/\s+/g, " ").trim();
623
+ return line.length <= width ? line : `${line.slice(0, Math.max(0, width - 1)).trimEnd()}…`;
624
+ };
625
+ /** Each schema on a row: its ID, when it was registered (`built in` for the board's own), and what it holds. */
626
+ function formatSchemas(schemas, now = Date.now()) {
627
+ const rows = schemas.map((schema) => [
628
+ schema.id,
629
+ schema.at === null ? "built in" : ago(schema.at, now),
630
+ schema.description ?? ""
631
+ ]);
632
+ const widths = [0, 1].map((column) => Math.max(...rows.map((row) => row[column].length)));
633
+ return rows.map(([id, registered, description]) => {
634
+ const head = `${id.padEnd(widths[0])} ${registered.padEnd(widths[1])}`;
635
+ return description ? `${head} ${fitted(description, WIDTH - head.length - 2)}` : head.trimEnd();
636
+ }).join("\n");
637
+ }
638
+ /** One schema: its ID and what it holds, then its JSON Schema, to paste. */
639
+ function formatSchema(schema) {
640
+ const definition = JSON.stringify(schema.schema, null, 2).replace(/^/gm, " ");
641
+ return `${[schema.id, schema.description].filter(Boolean).join(" ")}\n\n${definition}`;
642
+ }
643
+ //#endregion
601
644
  //#region src/cli/hooks.ts
602
645
  /**
603
646
  * Where each agent keeps hooks, and which of its events run ours. Claude Code
@@ -1373,6 +1416,48 @@ function configuredUrl() {
1373
1416
  });
1374
1417
  }
1375
1418
  }
1419
+ /**
1420
+ * What a message says: its text, or with `--schema`, a block of that schema and nothing else, whose
1421
+ * JSON the text is, from wherever text comes (the argument, stdin, `--text-file`).
1422
+ */
1423
+ async function content(value, options = {}) {
1424
+ const schema = flags.schema;
1425
+ if (schema === void 0) return text(value, options);
1426
+ if (!parseSchemaId(schema)) throw usage(`${schema} doesn't name a schema. One is name@version, like sandbox@1.`);
1427
+ let data;
1428
+ try {
1429
+ data = JSON.parse(await text(value));
1430
+ } catch (error) {
1431
+ if (error instanceof Failed) throw error;
1432
+ throw usage(`With --schema, the text is ${schema}'s JSON, and this isn't JSON.`);
1433
+ }
1434
+ if (typeof data !== "object" || data === null || Array.isArray(data)) throw usage(`With --schema, the text is a JSON object, like {"id":"sbx-123"}.`);
1435
+ return block(schema, data);
1436
+ }
1437
+ /** A schema's JSON Schema, as `--schema` gives it: inline JSON, the file `@<path>` names, or stdin for `-`. */
1438
+ async function definition() {
1439
+ const given = flags.schema;
1440
+ if (given === void 0) throw usage("Missing --schema: its JSON Schema, inline, @<file>, or - for stdin.", { reason: "missing_arguments" });
1441
+ let source = given;
1442
+ if (given === "-") source = await io.stdin();
1443
+ else if (given.startsWith("@")) {
1444
+ const file = given.slice(1);
1445
+ const data = await io.readFile(file);
1446
+ if (!data) throw usage(`Can't read ${file}. There's no such file.`, {
1447
+ reason: "file_not_found",
1448
+ next: []
1449
+ });
1450
+ source = new TextDecoder().decode(data);
1451
+ }
1452
+ let parsed;
1453
+ try {
1454
+ parsed = JSON.parse(source);
1455
+ } catch {
1456
+ 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.`);
1457
+ }
1458
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw usage("A schema is a JSON object: {\"type\":\"object\", …}.");
1459
+ return parsed;
1460
+ }
1376
1461
  /** A board that predates what this run asked of it. */
1377
1462
  const outdated = (message) => new Failed({
1378
1463
  class: "platform",
@@ -1403,6 +1488,7 @@ function doing() {
1403
1488
  case "actors": return `list ${command}`;
1404
1489
  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";
1405
1490
  case "tokens": return a === "create" ? `mint token ${b ?? ""}`.trimEnd() : a === "revoke" ? `revoke token ${b}` : "list tokens";
1491
+ case "schemas": return a === "create" ? `register schema ${b ?? ""}`.trimEnd() : a === "inspect" ? `read schema ${b ?? ""}`.trimEnd() : "list schemas";
1406
1492
  case "sources": return b === void 0 ? "list sources" : `${b} ${c ?? "it"} on ${a}`;
1407
1493
  case "download": return `download ${a ?? "the attachment"}`;
1408
1494
  case "inbox": return `read ${a}'s inbox`;
@@ -1437,6 +1523,7 @@ function missing() {
1437
1523
  ].includes(command) && isMessageRef(a)) return `message ${ref(a)}`;
1438
1524
  if (command === "schedule" && a === "cancel" && b !== void 0) return `schedule ${b}`;
1439
1525
  if ((command === "grants" || command === "tokens") && (a === "revoke" || a === "update") && b !== void 0) return `${command === "grants" ? "grant" : "token"} ${b}`;
1526
+ if (command === "schemas" && a === "inspect" && b !== void 0) return `schema ${b}`;
1440
1527
  if (command === "download") return `attachment ${a}`;
1441
1528
  }
1442
1529
  /**
@@ -1550,6 +1637,19 @@ function failureOf(error) {
1550
1637
  data: said
1551
1638
  });
1552
1639
  const specific = (fallback) => /^[a-z]+(_[a-z]+)+$/.test(code) && code !== "invalid_request" && code !== "remote_error" ? code : fallback;
1640
+ if (status === 400 && code === "invalid_block" && flags.schema !== void 0 && parseSchemaId(flags.schema)) return theirs("usage", code, `Can't ${doing()}.`, [{
1641
+ instruction: `See what ${flags.schema} holds`,
1642
+ argv: [
1643
+ ...cli(),
1644
+ "schemas",
1645
+ "inspect",
1646
+ flags.schema
1647
+ ]
1648
+ }]);
1649
+ if (status === 400 && code === "schema_not_found" && current.command !== "schemas") return theirs("usage", code, `Can't ${doing()}.`, [{
1650
+ instruction: "See the schemas this board has",
1651
+ argv: [...cli(), "schemas"]
1652
+ }]);
1553
1653
  if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
1554
1654
  if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", process.env.BOARD_TOKEN ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : [{
1555
1655
  instruction: "Log in again",
@@ -1568,6 +1668,15 @@ function failureOf(error) {
1568
1668
  const newer = code === "newer_message" && flags.after !== void 0 && args[0] !== void 0;
1569
1669
  const labeled = code === "label_conflict" && (flags.if !== void 0 || flags["if-unset"] !== void 0) && args[0] !== void 0;
1570
1670
  const changed = code === "revision_conflict" && flags["if-revision"] !== void 0 && args[0] !== void 0;
1671
+ if (code === "schema_immutable" && current.command === "schemas" && args[1] !== void 0) return theirs("conflict", code, `Can't ${doing()}.`, [{
1672
+ instruction: "See what it's registered as",
1673
+ argv: [
1674
+ ...cli(),
1675
+ "schemas",
1676
+ "inspect",
1677
+ args[1]
1678
+ ]
1679
+ }]);
1571
1680
  return theirs("conflict", specific("conflict"), `Can't ${doing()}.`, newer ? [{
1572
1681
  instruction: `Read what came after ${ref(flags.after)}`,
1573
1682
  argv: [
@@ -1762,23 +1871,6 @@ function hookAgents(names) {
1762
1871
  for (const name of names) if (!known.includes(name)) throw usage(`Unknown agent ${name}. The agents are ${known.join(", ")}.`);
1763
1872
  return names.length ? names : known;
1764
1873
  }
1765
- /** Says what a write that went through had to say: in its JSON result with `--json`, on stderr otherwise. */
1766
- function warn(warning) {
1767
- if (flags.json) warnings.push(warning);
1768
- else if (app.onWarning) app.onWarning(warning);
1769
- else io.error(`${terminalText(`warning: ${warning.message}`)}\n`);
1770
- }
1771
- /** A write went through, but some handles in it matched no one: they stayed plain text. */
1772
- function warnUnknownMentions(handles) {
1773
- if (!handles?.length) return;
1774
- const names = handles.map((handle) => `@${handle}`);
1775
- const list = names.length === 1 ? names[0] : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
1776
- const one = names.length === 1;
1777
- warn({
1778
- reason: "unknown_mention",
1779
- message: `${list} ${one ? "matches" : "match"} no one on the board, so ${one ? "it stays" : "they stay"} plain text and ${one ? "notifies" : "notify"} no one.`
1780
- });
1781
- }
1782
1874
  /** A post or reply: its ID, or with `--json`, the message. */
1783
1875
  function printMessage(message) {
1784
1876
  if (flags.json) result({
@@ -1845,8 +1937,7 @@ async function run(command, args) {
1845
1937
  });
1846
1938
  return 0;
1847
1939
  }
1848
- const name = me.profile !== null ? `${me.name} via ${me.handle.split("/")[0]}` : me.name;
1849
- out(`${name} (${me.actor})`);
1940
+ out(`${who(me)} (${me.actor})`);
1850
1941
  const rows = [["board", url]];
1851
1942
  if (source) rows.push(["source", source]);
1852
1943
  if (me.expiresAt) {
@@ -1924,7 +2015,7 @@ async function run(command, args) {
1924
2015
  case "actors": {
1925
2016
  const actors = await client().actors();
1926
2017
  if (flags.json) return result({ actors }), 0;
1927
- for (const actor of actors) out(`@${actor.handle} ${actor.name} ${actor.id}`);
2018
+ for (const actor of actors) out(`@${actor.handle} ${actorName(actor)} ${actor.id}`);
1928
2019
  return 0;
1929
2020
  }
1930
2021
  case "read": {
@@ -1997,41 +2088,37 @@ async function run(command, args) {
1997
2088
  if (flags.sync?.length && flags["no-sync"]) throw usage("Can't use --sync with --no-sync.");
1998
2089
  if (re === void 0 && flags.after !== void 0) throw usage("Can't use --after on a new thread. It's for replies: the thread's newest message.");
1999
2090
  const board = client();
2000
- const content = await text(body, { optional: !!flags.attach?.length });
2091
+ const said = await content(body, { optional: !!flags.attach?.length });
2001
2092
  const files = await attachments(board);
2002
2093
  const options = {
2003
- text: content,
2094
+ text: said,
2004
2095
  ...files.length ? { attachments: files } : {},
2005
2096
  ...flags.label?.length ? { labels: labelPairs(flags.label) } : {},
2006
2097
  ...flags["idempotency-key"] ? { id: flags["idempotency-key"] } : {},
2007
2098
  ...flags["no-sync"] ? { noSync: true } : {}
2008
2099
  };
2009
- const message = re === void 0 ? await board.post(target, {
2100
+ printMessage(re === void 0 ? await board.post(target, {
2010
2101
  ...options,
2011
2102
  ...flags.sync?.length ? { sync: flags.sync } : {}
2012
2103
  }) : await board.reply(re, {
2013
2104
  ...options,
2014
2105
  ...flags.after !== void 0 ? { after: messageId(flags.after) } : {}
2015
- });
2016
- warnUnknownMentions(message.unknownMentions);
2017
- printMessage(message);
2106
+ }));
2018
2107
  return 0;
2019
2108
  }
2020
2109
  case "reply": {
2021
2110
  const id = messageId(args[0]);
2022
2111
  const board = client();
2023
- const content = await text(args[1], { optional: !!flags.attach?.length });
2112
+ const said = await content(args[1], { optional: !!flags.attach?.length });
2024
2113
  const files = await attachments(board);
2025
- const message = await board.reply(id, {
2026
- text: content,
2114
+ printMessage(await board.reply(id, {
2115
+ text: said,
2027
2116
  ...files.length ? { attachments: files } : {},
2028
2117
  ...flags.label?.length ? { labels: labelPairs(flags.label) } : {},
2029
2118
  ...flags["idempotency-key"] ? { id: flags["idempotency-key"] } : {},
2030
2119
  ...flags["no-sync"] ? { noSync: true } : {},
2031
2120
  ...flags.after !== void 0 ? { after: messageId(flags.after) } : {}
2032
- });
2033
- warnUnknownMentions(message.unknownMentions);
2034
- printMessage(message);
2121
+ }));
2035
2122
  return 0;
2036
2123
  }
2037
2124
  case "schedule": {
@@ -2051,11 +2138,11 @@ async function run(command, args) {
2051
2138
  const times = flags.times === void 0 ? void 0 : Number(flags.times);
2052
2139
  if (times !== void 0 && !(Number.isInteger(times) && times > 0)) throw usage(`--times takes a count, and ${flags.times} isn't one.`);
2053
2140
  const board = client();
2054
- const content = await text(body, { optional: !!flags.attach?.length });
2141
+ const said = await content(body, { optional: !!flags.attach?.length });
2055
2142
  const files = await attachments(board);
2056
2143
  const where = isMessageRef(target) ? { re: messageId(target) } : target;
2057
2144
  const schedule = await board.schedule(where, {
2058
- text: content,
2145
+ text: said,
2059
2146
  ...files.length ? { attachments: files } : {},
2060
2147
  ...flags.label?.length ? { labels: labelPairs(flags.label) } : {},
2061
2148
  ...flags["no-sync"] ? { noSync: true } : {},
@@ -2066,7 +2153,6 @@ async function run(command, args) {
2066
2153
  ...flags.for ? { for: flags.for } : {},
2067
2154
  ...times !== void 0 ? { times } : {}
2068
2155
  });
2069
- warnUnknownMentions(schedule.unknownMentions);
2070
2156
  if (flags.json) result({
2071
2157
  schedule,
2072
2158
  outcome: "scheduled"
@@ -2199,6 +2285,39 @@ async function run(command, args) {
2199
2285
  else out(secret);
2200
2286
  return 0;
2201
2287
  }
2288
+ case "schemas": {
2289
+ const [verb, ...rest] = args;
2290
+ if (verb === void 0 || verb === "list") {
2291
+ if (rest.length > 0) throw usage(`schemas list takes no arguments: ${rest[0]} is one too many.`);
2292
+ const list = await client().schemas();
2293
+ if (flags.json) return result({ schemas: list }), 0;
2294
+ out(formatSchemas(list));
2295
+ return 0;
2296
+ }
2297
+ if (verb !== "inspect" && verb !== "create") throw usage(`Unknown command ${verb} for ${named()} schemas.`, { reason: "unknown_command" });
2298
+ const [id, extra] = rest;
2299
+ if (id === void 0) throw usage(`Missing the schema to ${verb}: its name and version, like sandbox@1.`, { reason: "missing_arguments" });
2300
+ if (extra !== void 0) throw usage(`schemas ${verb} takes one schema: ${extra} is one too many.`);
2301
+ const wanted = parseSchemaId(id);
2302
+ if (!wanted) throw usage(`${id} doesn't name a schema. One is name@version, like sandbox@1.`);
2303
+ if (verb === "inspect") {
2304
+ const schema = await client().schema(id);
2305
+ if (flags.json) result({ schema });
2306
+ else out(formatSchema(schema));
2307
+ return 0;
2308
+ }
2309
+ const { schema, created } = await client().createSchema({
2310
+ ...wanted,
2311
+ schema: await definition(),
2312
+ ...flags.description !== void 0 ? { description: flags.description } : {}
2313
+ });
2314
+ if (flags.json) result({
2315
+ schema,
2316
+ outcome: created ? "created" : "unchanged"
2317
+ });
2318
+ else out(created ? `created ${schema.id}` : `${schema.id} is already registered`);
2319
+ return 0;
2320
+ }
2202
2321
  case "schedules": {
2203
2322
  const list = await client().schedules({
2204
2323
  ...args[0] ? { re: messageId(args[0]) } : {},
@@ -2250,8 +2369,7 @@ async function run(command, args) {
2250
2369
  case "hook": return 0;
2251
2370
  case "edit": {
2252
2371
  const id = messageId(args[0]);
2253
- const { unknownMentions } = await client().edit(id, await text(args[1]), ifRevision());
2254
- warnUnknownMentions(unknownMentions);
2372
+ await client().edit(id, await content(args[1]), ifRevision());
2255
2373
  printDone(id, "edited");
2256
2374
  return 0;
2257
2375
  }
@@ -2410,7 +2528,7 @@ async function run(command, args) {
2410
2528
  else out(formatEvent(event));
2411
2529
  return 0;
2412
2530
  }
2413
- case "inspect": return (await import("./inspect-lnv1sLXM.mjs")).inspect(context());
2531
+ case "inspect": return (await import("./inspect-CLy6FrOZ.mjs")).inspect(context());
2414
2532
  default: {
2415
2533
  const own = app.commands[command];
2416
2534
  if (own) return own.run(args, context());
@@ -1,6 +1,6 @@
1
- import { r as sqlTables } from "./sql-l3ysn4O5.mjs";
1
+ import { r as sqlTables } from "./sql-Bv-RQu8n.mjs";
2
2
  import { t as memory$1 } from "./store-memory-CKQVEzXN.mjs";
3
- import { t as sqliteDb } from "./sqlite-db-cm5yhrD-.mjs";
3
+ import { t as sqliteDb } from "./sqlite-db-BraLvHtf.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,11 +1,19 @@
1
+ import { r as findBlocks } from "./blocks-CVoBC7ur.mjs";
1
2
  //#region src/contract/mentions.ts
2
3
  const FENCED_CODE = /```[\s\S]*?```/g;
3
4
  const INLINE_CODE = /`[^`\n]*`/g;
4
5
  const NAME = "[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?";
5
6
  const MENTION = new RegExp(`(?<![\\w@.-])@(${NAME}(?:/${NAME})?)(?!:|[a-z0-9_/-]|\\.(?=[a-z0-9]))`, "gi");
6
7
  const EXACT = /(?<![\w@.-])@\[([^\]\s]+)\]/g;
7
- /** Blanks out code so mentions inside it never count. */
8
- const proseOnly = (text) => text.replace(FENCED_CODE, (match) => " ".repeat(match.length)).replace(INLINE_CODE, (match) => " ".repeat(match.length));
8
+ /**
9
+ * Blanks out code so mentions inside it never count. A block's fence is code whatever it's fenced
10
+ * with and whatever its JSON holds, so nothing that reads or rewrites mentions touches its data.
11
+ */
12
+ function proseOnly(text) {
13
+ let prose = text.replace(FENCED_CODE, (match) => " ".repeat(match.length)).replace(INLINE_CODE, (match) => " ".repeat(match.length));
14
+ if (text.includes("json#")) for (const { start, end } of findBlocks(text)) prose = `${prose.slice(0, start)}${" ".repeat(end - start)}${prose.slice(end)}`;
15
+ return prose;
16
+ }
9
17
  /** Mentions in prose order, deduplicated. Handles are lowercased. */
10
18
  function extractMentions(text) {
11
19
  const prose = proseOnly(text);
@@ -35,6 +43,12 @@ function extractMentions(text) {
35
43
  const seen = /* @__PURE__ */ new Set();
36
44
  return found.sort((a, b) => a.index - b.index).filter(({ key }) => !seen.has(key) && seen.add(key)).map(({ token }) => token);
37
45
  }
46
+ /** An email, as `@[ada@vercel.com]` names one: no actor ID has an `@` without a `:`. */
47
+ const isEmail = (value) => /^[^\s@:]+@[^\s@:]+$/.test(value);
48
+ /** A mention as filters match it: an actor ID (it has a colon) as written, anything else (a handle, an email) lowercased. */
49
+ const mentionTerm = (name) => name.includes(":") ? name : name.toLowerCase();
50
+ /** What `text` mentions, as filters match it: each `@handle` and `@[…]`, as `mentionTerm` has it. */
51
+ const mentionTerms = (text) => [...new Set(extractMentions(text).map((token) => mentionTerm(token.kind === "handle" ? token.handle : token.actor)))];
38
52
  /**
39
53
  * Rewrites each mention in prose with `replace`, which also gets the mention as
40
54
  * written; one it returns null for stays as written.
@@ -69,4 +83,4 @@ function replaceMentions(text, replace) {
69
83
  return out + text.slice(at);
70
84
  }
71
85
  //#endregion
72
- export { replaceMentions as n, extractMentions as t };
86
+ export { replaceMentions as a, mentionTerms as i, isEmail as n, mentionTerm as r, extractMentions as t };
@@ -1,4 +1,4 @@
1
- import { t as HttpError } from "./errors-rYDxZEuN.mjs";
1
+ import { t as HttpError } from "./errors-CNRJqUuL.mjs";
2
2
  import { d as Labels, f as MESSAGE_TEXT_MAX } from "./schemas-AZkxk06N.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/client/ids.ts
@@ -31,6 +31,74 @@ const keyId = async (principal, derived) => `key:${principal}:${(await sha256(`b
31
31
  */
32
32
  const isKeyIdOf = (id, principal) => id.startsWith(`key:${principal}:`) && /^[0-9a-f]{32}$/.test(id.slice(`key:${principal}:`.length));
33
33
  //#endregion
34
+ //#region src/contract/profiles.ts
35
+ /**
36
+ * What an actor's profile is, when it's a platform user a principal's sync speaks for: `slack:user:U0456`
37
+ * is user `user:U0456` under sync key `slack`. Null for an agent's profile (`claude`), whose name never
38
+ * has a colon, and for none.
39
+ */
40
+ function platformProfile(profile) {
41
+ const colon = profile?.indexOf(":") ?? -1;
42
+ return profile && colon > 0 ? {
43
+ key: profile.slice(0, colon),
44
+ user: profile.slice(colon + 1)
45
+ } : null;
46
+ }
47
+ /**
48
+ * A platform user's handle as board's mention syntax takes it (`NAME` in `mentions.ts`), so anyone
49
+ * can type it: diacritics taken off (`ü` is `u`), lowercased, each run of anything but `a-z`, `0-9`,
50
+ * `.`, `_`, and `-` as one `-`, and `-`, `.`, and `_` trimmed from the ends. "Jürgen Ubl" is
51
+ * `jurgen-ubl`. One with nothing left is their ID on the platform, without the sync key, the same
52
+ * way: `T_EU:U0MALTE` is `t_eu-u0malte`. Vercel's API names them by the same rule.
53
+ */
54
+ function typableHandle(handle, userId) {
55
+ return typable(handle) || typable(userId);
56
+ }
57
+ /** `typableHandle`'s rule on one value, in a single pass: a trim by regex backtracks on long runs. */
58
+ const typable = (value) => trimmed(value.normalize("NFKD").replace(/\p{M}+/gu, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-"));
59
+ /** `-`, `.`, and `_` off both ends. */
60
+ function trimmed(value) {
61
+ let start = 0;
62
+ let end = value.length;
63
+ while (start < end && "-._".includes(value[start])) start++;
64
+ while (end > start && "-._".includes(value[end - 1])) end--;
65
+ return value.slice(start, end);
66
+ }
67
+ /** The most characters a handle the board stores has (`Handle` in `schemas.ts`). */
68
+ const HANDLE_MAX = 128;
69
+ /**
70
+ * `<principal>/<part>`, at most `HANDLE_MAX` characters: a part too long is cut on whole characters,
71
+ * and its ends trimmed again.
72
+ */
73
+ function underPrincipal(principal, part) {
74
+ const room = HANDLE_MAX - Array.from(principal).length - 1;
75
+ const chars = Array.from(part);
76
+ return `${principal}/${chars.length <= room ? part : trimmed(chars.slice(0, Math.max(room, 1)).join(""))}`;
77
+ }
78
+ /** A platform user's ID there, without the sync key they came through: `T_EU:U0MALTE` of `slack-eu:T_EU:U0MALTE`. */
79
+ const userIdOf = (id) => id.slice(id.indexOf(":") + 1);
80
+ /**
81
+ * A platform user's handle as a principal's sync imported them: the principal's name (a project's,
82
+ * in every environment), then theirs, typable: `support/malte-ubl`, at most 128 characters. `userId`
83
+ * is theirs on the platform, without the sync key.
84
+ */
85
+ const importedHandle = (principal, handle, userId) => underPrincipal(principal, typableHandle(handle, userId));
86
+ /** An actor ID's principal and profile: `vercel:user:u_1+claude` is `vercel:user:u_1` with `claude`. */
87
+ function actorParts(actor) {
88
+ const plus = actor.indexOf("+");
89
+ return plus === -1 ? {
90
+ principal: actor,
91
+ profile: null
92
+ } : {
93
+ principal: actor.slice(0, plus),
94
+ profile: actor.slice(plus + 1)
95
+ };
96
+ }
97
+ /** `via www (preview)`, `via julian`: an environment shows unless it's production. */
98
+ const viaText = (via) => `via ${via.name}${via.environment !== null && via.environment !== "production" ? ` (${via.environment})` : ""}`;
99
+ /** An actor as people see it: `claude via julian`, `Malte via www (preview)`, or just a name for an actor with no profile. */
100
+ const shownName = (actor) => actor.via ? `${actor.name} ${viaText(actor.via)}` : actor.name;
101
+ //#endregion
34
102
  //#region src/server/wait-until.ts
35
103
  /**
36
104
  * Keeps `task` running after the response, where the platform offers it: Vercel's request context, as A2
@@ -108,4 +176,4 @@ async function runMiddleware(middleware, input, commit) {
108
176
  return committed.value;
109
177
  }
110
178
  //#endregion
111
- export { waitUntil as a, isKeyIdOf as c, afterRetry as i, keyId as l, MIDDLEWARE_ACTOR as n, DERIVED_ID as o, runMiddleware as r, derivedId as s, DroppedError as t, sha256 as u };
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 };