@vercel/board 0.46.0 → 0.48.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-Crbvd2Dm.mjs → access-C06pIr0M.mjs} +1 -1
  2. package/dist/access.d.mts +2 -2
  3. package/dist/access.mjs +4 -4
  4. package/dist/{actors-BBphaJ_G.mjs → actors-Dkyg-oo0.mjs} +2 -2
  5. package/dist/{auth-C-pFnJBA.mjs → auth-B9-wXQ-x.mjs} +29 -9
  6. package/dist/{auth-CkNXnQno.d.mts → auth-li3lKwJG.d.mts} +1 -1
  7. package/dist/{backend-D3p8gjba.d.mts → backend-UBP6HimX.d.mts} +21 -4
  8. package/dist/backend-local.d.mts +1 -1
  9. package/dist/backend-local.mjs +1 -1
  10. package/dist/{chat-provider-Bn33acHd.d.mts → chat-provider-iN0DFsSE.d.mts} +7 -2
  11. package/dist/{chat-provider-1zpY6Qo_.mjs → chat-provider-kNWd6MQC.mjs} +10 -4
  12. package/dist/cli-commands.d.mts +1 -1
  13. package/dist/cli-commands.mjs +1 -1
  14. package/dist/cli-embedded.d.mts +2 -2
  15. package/dist/cli-embedded.mjs +2 -2
  16. package/dist/cli.mjs +46 -15
  17. package/dist/{commands-CSZPQ38I.d.mts → commands-CJsOA-hf.d.mts} +6 -0
  18. package/dist/{commands-D0lyo8O8.mjs → commands-Dk6_cHLS.mjs} +6 -0
  19. package/dist/{conformance-Blzd4CXG.mjs → conformance-CDP8y2Zm.mjs} +94 -3
  20. package/dist/conformance.d.mts +1 -1
  21. package/dist/conformance.mjs +1 -1
  22. package/dist/{engine-C_SlBihU.mjs → engine-B3Yd0OPc.mjs} +71 -52
  23. package/dist/{errors-DZ1tbwSM.mjs → errors-QhkdzI-o.mjs} +27 -8
  24. package/dist/{events-mGuhF4i5.mjs → events-B-qyxNsJ.mjs} +9 -1
  25. package/dist/{exports-DQauuHrc.mjs → exports-B5xOYHj_.mjs} +205 -56
  26. package/dist/{exports-DUX_Yzo7.d.mts → exports-inhbjAWi.d.mts} +4 -4
  27. package/dist/{external-BVr1Sq0y.mjs → external-BuVTXT1R.mjs} +6 -2
  28. package/dist/{index-BHXg4Xdo.d.mts → index-B0Fnhvk7.d.mts} +2 -2
  29. package/dist/index.d.mts +6 -6
  30. package/dist/index.mjs +4 -4
  31. package/dist/index.node.d.mts +7 -7
  32. package/dist/index.node.mjs +4 -4
  33. package/dist/inspect/app.js +44 -44
  34. package/dist/inspect/engine.js +1 -1
  35. package/dist/{inspect-2OIjv2lW.mjs → inspect-CAz9PGLf.mjs} +89 -32
  36. package/dist/inspect-CNECs4UG.mjs +2 -0
  37. package/dist/{local-11FMUJrU.mjs → local-CKMP4xH3.mjs} +92 -50
  38. package/dist/{main-BYmbTDgo.mjs → main-DZZQEFVl.mjs} +127 -46
  39. package/dist/{memory-CZBdVNn8.mjs → memory-CMm-Fk_A.mjs} +2 -2
  40. package/dist/{mentions-DfZGp3B-.mjs → mentions-CnWt9Z5b.mjs} +34 -1
  41. package/dist/{middleware-BKsTcMAv.mjs → middleware-CT6vMNUc.mjs} +1 -1
  42. package/dist/{provider-D3bfHRHA.d.mts → provider-DC3WHUXo.d.mts} +88 -5
  43. package/dist/{routes-B2HHHD_C.mjs → routes-ABXf3CKq.mjs} +17 -4
  44. package/dist/{routes-NEc6w3QC.d.mts → routes-CjA6Mp4D.d.mts} +70 -0
  45. package/dist/serve-DBJTP0xd.mjs +285 -0
  46. package/dist/{server-Ch3tuK2k.mjs → server-DmlyIzMj.mjs} +38 -19
  47. package/dist/{serving-9riPNrHk.mjs → serving-BNdiReQT.mjs} +1 -1
  48. package/dist/{sql-Bml29DpM.mjs → sql-IEbO5vXs.mjs} +2 -2
  49. package/dist/{sqlite-4C5u7-ag.mjs → sqlite-CVG8XKHm.mjs} +2 -2
  50. package/dist/{sqlite-db-eVb9v3zc.mjs → sqlite-db-BJjPQYx4.mjs} +1 -1
  51. package/dist/sync-chat-sdk.d.mts +16 -2
  52. package/dist/sync-chat-sdk.mjs +2 -2
  53. package/dist/sync-github.d.mts +16 -2
  54. package/dist/sync-github.mjs +3 -3
  55. package/dist/sync-linear.d.mts +17 -3
  56. package/dist/sync-linear.mjs +2 -2
  57. package/dist/sync-slack.d.mts +17 -3
  58. package/dist/sync-slack.mjs +130 -16
  59. package/dist/sync.d.mts +2 -2
  60. package/dist/sync.mjs +2 -2
  61. package/dist/{task-batch-BJcLiYe1.mjs → task-batch-CmKvTLSu.mjs} +6 -6
  62. package/dist/{tokens-DPKF_cb5.mjs → tokens-BCp4EWTQ.mjs} +2 -2
  63. package/docs/01-board/01-mounting.md +7 -4
  64. package/docs/01-board/03-identity.md +45 -23
  65. package/docs/01-board/04-messages.md +3 -2
  66. package/docs/01-board/06-watchers.md +3 -3
  67. package/docs/01-board/07-schedules.md +2 -2
  68. package/docs/01-board/09-access.md +6 -4
  69. package/docs/01-board/10-local.md +4 -1
  70. package/docs/02-sync/01-overview.md +4 -5
  71. package/docs/02-sync/02-functions.md +2 -2
  72. package/docs/02-sync/03-slack.md +13 -5
  73. package/docs/02-sync/06-providers.md +9 -0
  74. package/docs/03-guides/02-inspector.md +17 -1
  75. package/docs/03-guides/06-sandboxed-agents.md +2 -2
  76. package/docs/03-guides/08-tailnet.md +123 -0
  77. package/docs/04-reference/01-cli.md +56 -15
  78. package/docs/04-reference/02-board.md +10 -5
  79. package/docs/04-reference/03-http.md +24 -3
  80. package/package.json +1 -1
  81. package/dist/inspect-F-b4GPXX.mjs +0 -2
  82. package/dist/serve-DS2T2iWI.mjs +0 -181
@@ -1,14 +1,15 @@
1
- import { C as fileSize, b as DIRECT_UPLOAD_BYTES_MAX, f as BoardError } from "./errors-DZ1tbwSM.mjs";
1
+ import { C as fileSize, b as DIRECT_UPLOAD_BYTES_MAX, f as BoardError } from "./errors-QhkdzI-o.mjs";
2
2
  import { m as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-7VFdomFB.mjs";
3
3
  import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
4
- import { l as shownName } from "./middleware-BKsTcMAv.mjs";
4
+ import { l as shownName } from "./middleware-CT6vMNUc.mjs";
5
5
  import { d as parseSchemaId, r as findBlocks, t as block } from "./blocks-CVoBC7ur.mjs";
6
- import { c as withMentions, g as VERSION } from "./task-batch-BJcLiYe1.mjs";
7
- import { r as PERMISSIONS } from "./access-Crbvd2Dm.mjs";
8
- import { i as isBoardName, n as createTasksInChunks, s as isApiMessageId, t as TasksInChunksError } from "./exports-DQauuHrc.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-D0lyo8O8.mjs";
10
- 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-Ch3tuK2k.mjs";
11
- import { t as conformance } from "./conformance-Blzd4CXG.mjs";
6
+ 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-CmKvTLSu.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-B5xOYHj_.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-DmlyIzMj.mjs";
12
+ import { t as conformance } from "./conformance-CDP8y2Zm.mjs";
12
13
  import { n as displayText } from "./bots-CLKKMgYf.mjs";
13
14
  import { spawn } from "node:child_process";
14
15
  import { createHash, randomUUID } from "node:crypto";
@@ -315,15 +316,22 @@ function reactions(message, names) {
315
316
  function reactionNames(messages) {
316
317
  return [...new Set(messages.flatMap((m) => Object.values(m.reactions).flatMap((actors) => actors.slice(0, 3))))];
317
318
  }
319
+ /** Each author's handle by ID, and those of `more`: who a mention shows as. */
320
+ const handlesOf = (messages, more = /* @__PURE__ */ new Map()) => new Map([...more, ...messages.flatMap((m) => m.author ? [[m.by.actor, m.author.handle]] : [])]);
321
+ /** The actors a thread's texts mention by ID, for looking up the ones who didn't write in it. */
322
+ function mentionedIn(messages) {
323
+ return [...new Set(messages.flatMap((m) => m.deleted ? [] : extractMentions(m.text).flatMap((token) => token.kind === "actor" && !isEmail(token.actor) ? [token.actor] : [])))];
324
+ }
318
325
  /** An actor's display name from `/actors`, the way a message's author shows: `claude via julian`. */
319
326
  const actorName = (actor) => shownName(actor);
320
327
  /**
321
328
  * A message's text as a terminal shows it: a bot's in its readable form, and each block as one
322
329
  * line, its schema and its data, where its fence was. A message that is only a block is that line.
323
330
  */
324
- function shownText(message) {
325
- const text = displayText(message.text, message.by.actor);
326
- if (!message.blocks?.length || text !== message.text) return text;
331
+ function shownText(message, handles = /* @__PURE__ */ new Map()) {
332
+ const said = replaceMentions(message.text, (token) => token.kind === "actor" && handles.has(token.actor) ? `@${handles.get(token.actor)}` : null);
333
+ const text = displayText(said, message.by.actor);
334
+ if (!message.blocks?.length || text !== said) return text;
327
335
  let out = "";
328
336
  let at = 0;
329
337
  for (const found of findBlocks(text)) {
@@ -351,7 +359,7 @@ function embed(link, pad) {
351
359
  function formatMessage(message, options = {}) {
352
360
  const pad = options.reply ? " " : " ";
353
361
  const head = `${options.reply ? " ↳ " : ""}#${message.id} ${authorName(message)} · ${ago(message.createdAt)}${message.editedAt ? " (edited)" : ""}${message.schedule ? ` · scheduled ${message.schedule.id}` : ""}${labels(message)}`;
354
- const body = message.deleted ? `${pad}(message removed)` : indent(shownText(message), pad);
362
+ const body = message.deleted ? `${pad}(message removed)` : indent(shownText(message, options.handles), pad);
355
363
  const task = message.task ? [`${pad}task ${taskState(message, message.task, options.names ?? /* @__PURE__ */ new Map(), options.now ?? Date.now())}`] : [];
356
364
  const files = (message.attachments ?? []).map((a) => `${pad}file ${a.name} · ${a.type} · ${fileSize(a.size)} · ${a.id}`);
357
365
  const links = message.deleted ? [] : (message.links ?? []).flatMap((link) => embed(link, pad));
@@ -433,8 +441,9 @@ function formatTasks(tasks) {
433
441
  return table(rows.map((row, at) => [...row, tasks[at].message.task ? taskNote(tasks[at].message, tasks[at].message.task, room) : ""]));
434
442
  }
435
443
  /** Threads in order, each root followed by its replies. */
436
- function formatThreads(messages, known = /* @__PURE__ */ new Map()) {
444
+ function formatThreads(messages, known = /* @__PURE__ */ new Map(), mentioned = /* @__PURE__ */ new Map()) {
437
445
  const names = new Map([...known, ...messages.map((m) => [m.by.actor, authorName(m)])]);
446
+ const handles = handlesOf(messages, mentioned);
438
447
  const byRoot = /* @__PURE__ */ new Map();
439
448
  const roots = [];
440
449
  const orphans = [];
@@ -442,20 +451,25 @@ function formatThreads(messages, known = /* @__PURE__ */ new Map()) {
442
451
  else (byRoot.get(message.re) ?? byRoot.set(message.re, []).get(message.re)).push(message);
443
452
  const rootIds = new Set(roots.map((r) => r.id));
444
453
  for (const [root, replies] of byRoot) if (!rootIds.has(root)) orphans.push(...replies);
445
- const blocks = roots.map((root) => [formatMessage(root, { names }), ...(byRoot.get(root.id) ?? []).map((r) => formatMessage(r, {
454
+ const blocks = roots.map((root) => [formatMessage(root, {
455
+ names,
456
+ handles
457
+ }), ...(byRoot.get(root.id) ?? []).map((r) => formatMessage(r, {
446
458
  reply: true,
447
- names
459
+ names,
460
+ handles
448
461
  }))].join("\n"));
449
462
  for (const reply of orphans) blocks.push(`(in thread #${reply.re})\n${formatMessage(reply, {
450
463
  reply: true,
451
- names
464
+ names,
465
+ handles
452
466
  })}`);
453
467
  return blocks.join("\n\n");
454
468
  }
455
469
  /** A root's first line, cut to `max` characters: 74 fits 80 columns under its header. */
456
- function firstLine(message, max = 74) {
470
+ function firstLine(message, max = 74, handles) {
457
471
  if (message.deleted) return "(message removed)";
458
- const text = shownText(message).trim();
472
+ const text = shownText(message, handles).trim();
459
473
  const files = message.attachments?.length ?? 0;
460
474
  if (!text) return files ? `(${files} ${files === 1 ? "file" : "files"})` : "(no text)";
461
475
  const [line = "", ...rest] = text.split(/\r?\n/);
@@ -468,6 +482,7 @@ function firstLine(message, max = 74) {
468
482
  */
469
483
  function formatThreadSummaries(threads, options = {}) {
470
484
  const now = options.now ?? Date.now();
485
+ const handles = handlesOf(threads.flatMap(({ message, last }) => last ? [message, last] : [message]), options.handles);
471
486
  return threads.map(({ message, replies, last }) => {
472
487
  const where = options.channel ? `${message.channel} ` : "";
473
488
  const head = `#${message.id} ${where}${authorName(message)} · ${ago(message.createdAt, now)}${labels(message)}`;
@@ -475,7 +490,7 @@ function formatThreadSummaries(threads, options = {}) {
475
490
  const counted = Object.entries(message.reactions).filter(([, actors]) => actors.length > 0).map(([emoji, actors]) => `${displayEmoji(emoji)} ${actors.length}`).join(" ");
476
491
  return [
477
492
  head,
478
- ` ${firstLine(message)}`,
493
+ ` ${firstLine(message, 74, handles)}`,
479
494
  ...counted ? [` ${counted}`] : [],
480
495
  ` ${activity}`
481
496
  ].join("\n");
@@ -2008,7 +2023,7 @@ function failureOf(error) {
2008
2023
  details: []
2009
2024
  };
2010
2025
  if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
2011
- if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", process.env.BOARD_TOKEN && reached && !vercelBoard(reached) ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : [{
2026
+ if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", process.env.BOARD_TOKEN && (reached && !vercelBoard(reached) || credentialSource() === "BOARD_TOKEN") ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : [{
2012
2027
  instruction: "Log in again",
2013
2028
  argv: ["vercel", "login"]
2014
2029
  }]);
@@ -2227,21 +2242,60 @@ function hookAgents(names) {
2227
2242
  for (const name of names) if (!known.includes(name)) throw usage(`Unknown agent ${name}. The agents are ${known.join(", ")}.`);
2228
2243
  return names.length ? names : known;
2229
2244
  }
2230
- /** A post or reply: its ID, or with `--json`, the message. */
2231
- function printMessage(message) {
2232
- if (flags.json) result({
2233
- message,
2234
- outcome: "posted"
2245
+ /** Says what a write that went through had to say: in its JSON result with `--json`, on stderr otherwise. */
2246
+ function warn(warning) {
2247
+ if (flags.json) warnings.push(warning);
2248
+ else if (app.onWarning) app.onWarning(warning);
2249
+ else io.error(`${terminalText(`warning: ${warning.message}`)}\n`);
2250
+ }
2251
+ /**
2252
+ * What became of the `@handle`s a write's text typed: a line for each one that's now a mention, with
2253
+ * who it mentions, and a warning for each that names no one or several, which is still text. With
2254
+ * `--json` the lines are the result's `mentions`.
2255
+ */
2256
+ function sayMentions(mentions) {
2257
+ for (const { written, actor, candidates } of mentions ?? []) if (actor) {
2258
+ if (!flags.json) out(`mentioned ${actor.name} @${actor.handle}`);
2259
+ } else if (candidates.length === 0) warn({
2260
+ reason: "unknown_mention",
2261
+ message: `${written} names no one here: it stays text, and mentions no one.`
2235
2262
  });
2236
- else out(messageRef(message.id));
2263
+ else {
2264
+ const handles = candidates.map(({ handle }) => handle.toLowerCase());
2265
+ warn({
2266
+ reason: "ambiguous_mention",
2267
+ message: `${written} mentions no one here, and stays text: write ${candidates.map(({ id, handle }) => `@${handle}`.toLowerCase() !== written.toLowerCase() && handles.filter((other) => other === handle.toLowerCase()).length === 1 ? `@${handle}` : `@[${id}]`).join(" or ")}.`
2268
+ });
2269
+ }
2270
+ }
2271
+ /** A post or reply: its ID, or with `--json`, the message. Then what became of its mentions. */
2272
+ function printMessage(written) {
2273
+ const { mentions, ...message } = written;
2274
+ if (flags.json) {
2275
+ sayMentions(mentions);
2276
+ result({
2277
+ message,
2278
+ outcome: "posted",
2279
+ ...mentions ? { mentions } : {}
2280
+ });
2281
+ } else {
2282
+ out(messageRef(message.id));
2283
+ sayMentions(mentions);
2284
+ }
2237
2285
  }
2238
2286
  /** A write that answers nothing but that it went through: with `--json`, which message, and what happened to it. */
2239
- function printDone(id, outcome) {
2240
- if (flags.json) result({
2241
- message: { id },
2242
- outcome
2243
- });
2244
- else out(`${outcome} ${messageRef(id)}`);
2287
+ function printDone(id, outcome, mentions) {
2288
+ if (flags.json) {
2289
+ sayMentions(mentions);
2290
+ result({
2291
+ message: { id },
2292
+ outcome,
2293
+ ...mentions ? { mentions } : {}
2294
+ });
2295
+ } else {
2296
+ out(`${outcome} ${messageRef(id)}`);
2297
+ sayMentions(mentions);
2298
+ }
2245
2299
  }
2246
2300
  /** Best-effort: the URL is printed either way. */
2247
2301
  /** `url`, when it's an http or https URL as `new URL` reads it: the only kind the CLI opens, so a board can't hand the opener a flag or another scheme. */
@@ -2390,9 +2444,14 @@ async function run(command, args) {
2390
2444
  const authors = new Set([thread.message, ...replies].map((m) => m.by.actor));
2391
2445
  const { task } = thread.message;
2392
2446
  const working = task ? [...task.claim ? [task.claim.actor] : [], ...task.owner !== thread.message.by.principal ? [task.owner] : []] : [];
2393
- const unnamed = [.../* @__PURE__ */ new Set([...reactionNames([thread.message, ...replies]), ...working])].filter((id) => !authors.has(id));
2394
- const known = unnamed.length ? new Map((await board.actors().catch(() => [])).filter((a) => unnamed.includes(a.id)).map((a) => [a.id, actorName(a)])) : /* @__PURE__ */ new Map();
2395
- out(formatThreads([thread.message, ...replies], known));
2447
+ const unnamed = [.../* @__PURE__ */ new Set([
2448
+ ...reactionNames([thread.message, ...replies]),
2449
+ ...working,
2450
+ ...mentionedIn([thread.message, ...replies])
2451
+ ])].filter((id) => !authors.has(id));
2452
+ const listed = unnamed.length ? (await board.actors().catch(() => [])).filter((a) => unnamed.includes(a.id)) : [];
2453
+ const known = new Map(listed.map((a) => [a.id, actorName(a)]));
2454
+ out(formatThreads([thread.message, ...replies], known, new Map(listed.map((a) => [a.id, a.handle]))));
2396
2455
  if (!narrowed) for (const schedule of thread.schedules ?? []) out(formatSchedule(schedule, { pad: " " }));
2397
2456
  return 0;
2398
2457
  }
@@ -2424,7 +2483,16 @@ async function run(command, args) {
2424
2483
  if (flags.json) return result(page), 0;
2425
2484
  const count = `${page.threads.length} ${page.threads.length === 1 ? "thread" : "threads"}`;
2426
2485
  out(`${target ?? "all channels"} · ${count} · cursor ${page.cursor}${page.threads.length ? "\n" : ""}`);
2427
- if (page.threads.length) out(formatThreadSummaries(page.threads, { channel: !target || target.endsWith("/") }));
2486
+ if (page.threads.length) {
2487
+ const roots = page.threads.map(({ message }) => message);
2488
+ const wrote = new Set(page.threads.flatMap(({ message, last }) => last ? [message.by.actor, last.by.actor] : [message.by.actor]));
2489
+ const unnamed = mentionedIn(roots).filter((id) => !wrote.has(id));
2490
+ const handles = new Map(unnamed.length ? (await client().actors().catch(() => [])).filter((a) => unnamed.includes(a.id)).map((a) => [a.id, a.handle]) : []);
2491
+ out(formatThreadSummaries(page.threads, {
2492
+ channel: !target || target.endsWith("/"),
2493
+ handles
2494
+ }));
2495
+ }
2428
2496
  out(`\nnew since then: ${commandLine(rerunWithout(["--after"], "--after", String(page.cursor)))}`);
2429
2497
  return 0;
2430
2498
  }
@@ -2498,7 +2566,7 @@ async function run(command, args) {
2498
2566
  const said = await content(body, { optional: !!flags.attach?.length });
2499
2567
  const files = await attachments(board);
2500
2568
  const where = isMessageRef(target) ? { re: messageId(target) } : target;
2501
- const schedule = await board.schedule(where, {
2569
+ const { mentions, ...made } = await board.schedule(where, {
2502
2570
  text: said,
2503
2571
  ...files.length ? { attachments: files } : {},
2504
2572
  ...flags.label?.length ? { labels: labelPairs(flags.label) } : {},
@@ -2510,11 +2578,17 @@ async function run(command, args) {
2510
2578
  ...flags.for ? { for: flags.for } : {},
2511
2579
  ...times !== void 0 ? { times } : {}
2512
2580
  });
2513
- if (flags.json) result({
2514
- schedule,
2515
- outcome: "scheduled"
2516
- });
2517
- else out(formatSchedule(schedule));
2581
+ if (flags.json) {
2582
+ sayMentions(mentions);
2583
+ result({
2584
+ schedule: made,
2585
+ outcome: "scheduled",
2586
+ ...mentions ? { mentions } : {}
2587
+ });
2588
+ } else {
2589
+ out(formatSchedule(made));
2590
+ sayMentions(mentions);
2591
+ }
2518
2592
  return 0;
2519
2593
  }
2520
2594
  case "grants": {
@@ -2707,8 +2781,8 @@ async function run(command, args) {
2707
2781
  case "hook": return 0;
2708
2782
  case "edit": {
2709
2783
  const id = messageId(args[0]);
2710
- await client().edit(id, await content(args[1]), ifRevision());
2711
- printDone(id, "edited");
2784
+ const { mentions } = await client().edit(id, await content(args[1]), ifRevision());
2785
+ printDone(id, "edited", mentions);
2712
2786
  return 0;
2713
2787
  }
2714
2788
  case "delete": {
@@ -3350,18 +3424,25 @@ async function tasks(args) {
3350
3424
  ...about
3351
3425
  });
3352
3426
  }
3427
+ const mentions = made.mentions ? { mentions: made.mentions } : {};
3428
+ if (flags.json) sayMentions(made.mentions);
3353
3429
  if (made.claim) {
3354
3430
  await claims.put(made.task.id, {
3355
3431
  epoch: made.claim.epoch,
3356
3432
  token: made.claim.token,
3357
3433
  until: made.claim.until
3358
3434
  });
3359
- printClaim(made.task, made.claim, { outcome: "created" });
3435
+ printClaim(made.task, made.claim, {
3436
+ outcome: "created",
3437
+ ...mentions
3438
+ });
3360
3439
  } else if (flags.json) result({
3361
3440
  task: made.task,
3362
- outcome: "created"
3441
+ outcome: "created",
3442
+ ...mentions
3363
3443
  });
3364
3444
  else out(messageRef(made.task.id));
3445
+ if (!flags.json) sayMentions(made.mentions);
3365
3446
  return 0;
3366
3447
  }
3367
3448
  if (verb === "claim") {
@@ -1,6 +1,6 @@
1
- import { r as sqlTables } from "./sql-Bml29DpM.mjs";
1
+ import { r as sqlTables } from "./sql-IEbO5vXs.mjs";
2
2
  import { t as memory$1 } from "./store-memory-CKQVEzXN.mjs";
3
- import { t as sqliteDb } from "./sqlite-db-eVb9v3zc.mjs";
3
+ import { t as sqliteDb } from "./sqlite-db-BJjPQYx4.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
@@ -82,5 +82,38 @@ function replaceMentions(text, replace) {
82
82
  }
83
83
  return out + text.slice(at);
84
84
  }
85
+ /** An actor ID as `@[…]` can hold it: no space and no `]`. */
86
+ const HOLDABLE = /^[^\]\s]+$/;
87
+ /**
88
+ * Settles the `@handle`s in a text among `actors`, whoever its writer can see: each becomes
89
+ * `@[actor-id]` when exactly one of them has that handle, in full, and stays as typed otherwise.
90
+ * Of several who have it, `prefer` may pick one: board passes the one who wrote in the thread. A
91
+ * handle no one has in full names no one, even when someone has it under a name: `@malte` isn't
92
+ * `support/malte`, whom a project could import to take the name, so they're only a candidate.
93
+ * `@[…]` is exact already, and is left alone.
94
+ */
95
+ function settleMentions(text, actors, prefer = () => null) {
96
+ const found = /* @__PURE__ */ new Map();
97
+ return {
98
+ text: replaceMentions(text, (token, written) => {
99
+ if (token.kind !== "handle") return null;
100
+ let mention = found.get(token.handle);
101
+ if (!mention) {
102
+ const named = (of) => actors.filter((actor) => of(actor.handle.toLowerCase()) === token.handle && HOLDABLE.test(actor.id));
103
+ const full = named((handle) => handle);
104
+ const actor = full.length === 1 ? full[0] : full.length > 1 ? prefer(full) : null;
105
+ const under = full.length > 0 || token.handle.includes("/") ? full : named((handle) => handle.slice(handle.indexOf("/") + 1));
106
+ mention = {
107
+ written,
108
+ actor,
109
+ candidates: actor ? [] : under
110
+ };
111
+ found.set(token.handle, mention);
112
+ }
113
+ return mention.actor ? `@[${mention.actor.id}]` : null;
114
+ }),
115
+ mentions: [...found.values()]
116
+ };
117
+ }
85
118
  //#endregion
86
- export { replaceMentions as a, mentionTerms as i, isEmail as n, mentionTerm as r, extractMentions as t };
119
+ export { replaceMentions as a, mentionTerms as i, isEmail as n, settleMentions as o, mentionTerm as r, extractMentions as t };
@@ -1,4 +1,4 @@
1
- import { t as HttpError } from "./errors-DZ1tbwSM.mjs";
1
+ import { t as HttpError } from "./errors-QhkdzI-o.mjs";
2
2
  import { m as MESSAGE_TEXT_MAX, p as Labels } from "./schemas-7VFdomFB.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/client/ids.ts
@@ -1,5 +1,24 @@
1
- import { $ as MessagesQueryInput, A as FiltersInput, An as ExternalAuthor, Bt as SyncThreadView, Ct as SchemaInput, En as Attachment, Ft as SyncFindView, Gt as TasksPage, Ht as TaskClaim, L as InboxEntry, Lt as SyncImportInput, Mn as ExternalFile, N as GrantInput, Nn as ExternalLink, Nt as SyncFindInput, O as Explanation, Ot as SourceRead, P as GrantView, Pn as Link, Qt as ThreadsQueryInput, R as InboxItem, S as Discovery, Tn as ExternalCopy, Tt as SourceJoin, Vt as SyncedView, X as MessageView, Xt as ThreadsPage, Y as Me, Yt as ThreadView, Z as MessagesPage, bt as SchedulesQueryInput, jn as ExternalEvent, lt as RegisterInput, n as ActorView, nn as UpdateGrantInput, q as MatchView, qt as TasksQueryInput, s as BoardEventView, u as ChannelView, ut as RegistrationView, vt as ScheduleView, w as EventsPage, wn as Actor, wt as SchemaView, zt as SyncReceiptInput } from "./routes-NEc6w3QC.mjs";
1
+ import { $ as MessagesQueryInput, A as FiltersInput, An as ExternalAuthor, Bt as SyncThreadView, Ct as SchemaInput, En as Attachment, Ft as SyncFindView, Gt as TasksPage, Ht as TaskClaim, L as InboxEntry, Lt as SyncImportInput, Mn as ExternalFile, N as GrantInput, Nn as ExternalLink, Nt as SyncFindInput, O as Explanation, Ot as SourceRead, P as GrantView, Pn as Link, Qt as ThreadsQueryInput, R as InboxItem, S as Discovery, Tn as ExternalCopy, Tt as SourceJoin, Vt as SyncedView, X as MessageView, Xt as ThreadsPage, Y as Me, Yt as ThreadView, Z as MessagesPage, bt as SchedulesQueryInput, jn as ExternalEvent, lt as RegisterInput, n as ActorView, nn as UpdateGrantInput, q as MatchView, qt as TasksQueryInput, s as BoardEventView, u as ChannelView, ut as RegistrationView, vt as ScheduleView, w as EventsPage, wn as Actor, wt as SchemaView, zt as SyncReceiptInput } from "./routes-CjA6Mp4D.mjs";
2
2
  import { z } from "zod";
3
+ //#region src/contract/mentions.d.ts
4
+ /** An actor as a write's answer names them. */
5
+ type MentionedActor = {
6
+ id: string;
7
+ handle: string;
8
+ name: string;
9
+ };
10
+ /**
11
+ * What became of an `@handle` a write typed. With `actor`, it named that one actor and the text now
12
+ * has `@[actor-id]` in its place. With `actor: null`, it's still in the text as typed, a mention of
13
+ * no one: `candidates` is who it could have meant, the several who have that handle, or for a handle
14
+ * with no `/`, whoever has it under a name (`support/malte` for `@malte`).
15
+ */
16
+ type Mentioned = {
17
+ written: string;
18
+ actor: MentionedActor | null;
19
+ candidates: MentionedActor[];
20
+ };
21
+ //#endregion
3
22
  //#region src/client/client.d.ts
4
23
  /**
5
24
  * Where an error came from: `handle`, raised by the handle on this machine (no Vercel login,
@@ -43,6 +62,13 @@ type ClientOptions = {
43
62
  */
44
63
  storeFetch?: typeof fetch;
45
64
  };
65
+ /**
66
+ * What a write that took a text answers: what it made, and under `mentions`, what became of each
67
+ * `@handle` the text typed, when it typed any.
68
+ */
69
+ type Written<T> = T & {
70
+ mentions?: Mentioned[];
71
+ };
46
72
  type PostOptions = {
47
73
  text: string;
48
74
  labels?: Record<string, string>;
@@ -218,8 +244,14 @@ declare function createBoardClient(options: ClientOptions): {
218
244
  posted: (id: string) => Promise<MessageView>;
219
245
  /** Threads with a matching message, one summary each (root, reply count, latest reply), by latest activity. `limit` counts threads; `before` takes a page's `older`. */
220
246
  threads: (query?: Filters & Omit<ThreadsQueryInput, keyof FiltersInput>) => Promise<ThreadsPage>;
221
- post(channel: string, input: string | PostOptions): Promise<MessageView>;
222
- reply(id: string, input: string | ReplyOptions): Promise<MessageView>;
247
+ /**
248
+ * Starts a thread. An `@handle` in the text that names exactly one actor you can see is stored as
249
+ * `@[actor-id]`, a mention of them; one that names none or several stays as typed, a mention of
250
+ * no one. `mentions` on what comes back says what became of each, when the text typed any.
251
+ */
252
+ post(channel: string, input: string | PostOptions): Promise<Written<MessageView>>;
253
+ /** Replies in a thread. Its `@handle`s are settled as `post`'s are: of several who share one, it's the one who wrote in the thread. */
254
+ reply(id: string, input: string | ReplyOptions): Promise<Written<MessageView>>;
223
255
  /**
224
256
  * Posts later, as you: a new thread when `target` is a channel, a reply when it's
225
257
  * `{ re }`, any message's ID in the thread. Each message it posts carries
@@ -227,7 +259,7 @@ declare function createBoardClient(options: ClientOptions): {
227
259
  */
228
260
  schedule(target: string | {
229
261
  re: string;
230
- }, input: ScheduleOptions): Promise<ScheduleView>;
262
+ }, input: ScheduleOptions): Promise<Written<ScheduleView>>;
231
263
  /** Pending schedules (`all` for done and canceled too), oldest first. `re` is any message in a thread. */
232
264
  schedules: (query?: Omit<SchedulesQueryInput, 'all'> & {
233
265
  all?: boolean;
@@ -255,12 +287,14 @@ declare function createBoardClient(options: ClientOptions): {
255
287
  (target: string, input: string | NewTaskOptions): Promise<{
256
288
  task: MessageView;
257
289
  claim?: ClaimedTask;
290
+ mentions?: Mentioned[];
258
291
  }>;
259
292
  (target: {
260
293
  re: string;
261
294
  }, input?: TaskOptions): Promise<{
262
295
  task: MessageView;
263
296
  claim?: ClaimedTask;
297
+ mentions?: Mentioned[];
264
298
  }>;
265
299
  };
266
300
  createMany: (channel: string, tasks: TaskInBatch[], opts?: {
@@ -361,6 +395,7 @@ declare function createBoardClient(options: ClientOptions): {
361
395
  revision?: number;
362
396
  }) => Promise<{
363
397
  ok: true;
398
+ mentions?: Mentioned[];
364
399
  }>;
365
400
  delete: (id: string, opts?: {
366
401
  revision?: number;
@@ -565,6 +600,13 @@ declare function envelope(platform: string, key: string, event: ExternalEvent, r
565
600
  }[];
566
601
  } | null;
567
602
  }[] | undefined;
603
+ mentioned?: {
604
+ id: string;
605
+ handle: string;
606
+ name: string;
607
+ avatar: string | null;
608
+ isBot: boolean;
609
+ }[] | undefined;
568
610
  id: string;
569
611
  platform: string;
570
612
  key: string;
@@ -599,6 +641,13 @@ declare function envelope(platform: string, key: string, event: ExternalEvent, r
599
641
  } | null;
600
642
  }[] | undefined;
601
643
  linksOnly?: boolean | undefined;
644
+ mentioned?: {
645
+ id: string;
646
+ handle: string;
647
+ name: string;
648
+ avatar: string | null;
649
+ isBot: boolean;
650
+ }[] | undefined;
602
651
  id: string;
603
652
  platform: string;
604
653
  key: string;
@@ -705,6 +754,13 @@ declare function eventSchema<P extends string, M extends string>(platform: P, me
705
754
  }, z.core.$strip>>;
706
755
  }, z.core.$strip>>;
707
756
  }, z.core.$strip>>>;
757
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
758
+ id: z.ZodString;
759
+ handle: z.ZodString;
760
+ name: z.ZodString;
761
+ avatar: z.ZodNullable<z.ZodString>;
762
+ isBot: z.ZodBoolean;
763
+ }, z.core.$strip>>>;
708
764
  id: z.ZodString;
709
765
  key: z.ZodString;
710
766
  raw: z.ZodUnknown;
@@ -739,6 +795,13 @@ declare function eventSchema<P extends string, M extends string>(platform: P, me
739
795
  }, z.core.$strip>>;
740
796
  }, z.core.$strip>>>;
741
797
  linksOnly: z.ZodOptional<z.ZodBoolean>;
798
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
799
+ id: z.ZodString;
800
+ handle: z.ZodString;
801
+ name: z.ZodString;
802
+ avatar: z.ZodNullable<z.ZodString>;
803
+ isBot: z.ZodBoolean;
804
+ }, z.core.$strip>>>;
742
805
  id: z.ZodString;
743
806
  key: z.ZodString;
744
807
  raw: z.ZodUnknown;
@@ -1037,6 +1100,13 @@ declare const ReceivedEvent: z.ZodObject<{
1037
1100
  }, z.core.$strip>>;
1038
1101
  }, z.core.$strip>>;
1039
1102
  }, z.core.$strip>>>;
1103
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
1104
+ id: z.ZodString;
1105
+ handle: z.ZodString;
1106
+ name: z.ZodString;
1107
+ avatar: z.ZodNullable<z.ZodString>;
1108
+ isBot: z.ZodBoolean;
1109
+ }, z.core.$strip>>>;
1040
1110
  }, z.core.$strip>, z.ZodObject<{
1041
1111
  channel: z.ZodString;
1042
1112
  thread: z.ZodString;
@@ -1066,6 +1136,13 @@ declare const ReceivedEvent: z.ZodObject<{
1066
1136
  }, z.core.$strip>>;
1067
1137
  }, z.core.$strip>>>;
1068
1138
  linksOnly: z.ZodOptional<z.ZodBoolean>;
1139
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
1140
+ id: z.ZodString;
1141
+ handle: z.ZodString;
1142
+ name: z.ZodString;
1143
+ avatar: z.ZodNullable<z.ZodString>;
1144
+ isBot: z.ZodBoolean;
1145
+ }, z.core.$strip>>>;
1069
1146
  }, z.core.$strip>, z.ZodObject<{
1070
1147
  channel: z.ZodString;
1071
1148
  thread: z.ZodString;
@@ -1129,6 +1206,12 @@ declare abstract class SyncProvider<E extends ProviderEvent = ProviderEvent> {
1129
1206
  abstract post(target: string, kind: ResolvedTarget['kind'], body: ProviderPost): Promise<ProviderDelivery>;
1130
1207
  findByEmail(_email: string): Promise<ExternalAuthor | null>;
1131
1208
  mention(_actor: Actor): string | null;
1209
+ /**
1210
+ * How this platform mentions one of its users by their ID alone (`slack:user:U0456` as
1211
+ * `<@U0456>`), for one the board hasn't met. Null where a mention needs more than an ID, as
1212
+ * GitHub's needs a login, and for anything that isn't a user's ID.
1213
+ */
1214
+ mentionById(_id: string): string | null;
1132
1215
  fetchRoot(_thread: string): Promise<SyncRoot | null>;
1133
1216
  fetchFile(_file: ExternalFile): Promise<Uint8Array | null>;
1134
1217
  /** The platform's own link to an event's message, or null when it has none. */
@@ -1183,4 +1266,4 @@ declare abstract class SyncProvider<E extends ProviderEvent = ProviderEvent> {
1183
1266
  render(input: RenderInput): string;
1184
1267
  }
1185
1268
  //#endregion
1186
- export { duration as $, SyncRoot as A, ExplainPrincipal as B, mirror as C, RootOverride as D, ProviderEvent as E, BoardError as F, ProfileOption as G, HeldTask as H, ClaimedTask as I, ScheduleTiming as J, ReplyOptions as K, ErrorOrigin as L, eventSchema as M, VercelDeployment as N, SyncOverrides as O, BoardClient as P, WaitOptions as Q, EventsOptions as R, into as S, EventBase as T, NewTaskOptions as U, Filters as V, PostOptions as W, TaskOptions as X, TaskInBatch as Y, UploadInput as Z, SyncFn as _, ProviderOptions as a, SyncUnit as b, Receive as c, Renderer as d, ResolvedTarget as f, Sync as g, UnreadableError as h, ProviderFile as i, envelope as j, SyncResult as k, ReceivedEvent as l, SyncProvider as m, FileDelivery as n, ProviderPost as o, SyncContext as p, ScheduleOptions as q, ProviderDelivery as r, ProviderSender as s, FetchedLink as t, RenderInput as u, SyncIn as v, render as w, channels as x, SyncOut as y, EventsState as z };
1269
+ export { Written as $, SyncRoot as A, ExplainPrincipal as B, mirror as C, RootOverride as D, ProviderEvent as E, BoardError as F, ProfileOption as G, HeldTask as H, ClaimedTask as I, ScheduleTiming as J, ReplyOptions as K, ErrorOrigin as L, eventSchema as M, VercelDeployment as N, SyncOverrides as O, BoardClient as P, WaitOptions as Q, EventsOptions as R, into as S, EventBase as T, NewTaskOptions as U, Filters as V, PostOptions as W, TaskOptions as X, TaskInBatch as Y, UploadInput as Z, SyncFn as _, ProviderOptions as a, SyncUnit as b, Receive as c, Renderer as d, duration as et, ResolvedTarget as f, Sync as g, UnreadableError as h, ProviderFile as i, envelope as j, SyncResult as k, ReceivedEvent as l, SyncProvider as m, FileDelivery as n, MentionedActor as nt, ProviderPost as o, SyncContext as p, ScheduleOptions as q, ProviderDelivery as r, ProviderSender as s, FetchedLink as t, Mentioned as tt, RenderInput as u, SyncIn as v, render as w, channels as x, SyncOut as y, EventsState as z };
@@ -1,6 +1,6 @@
1
- import { b as DIRECT_UPLOAD_BYTES_MAX } from "./errors-DZ1tbwSM.mjs";
1
+ import { b as DIRECT_UPLOAD_BYTES_MAX } from "./errors-QhkdzI-o.mjs";
2
2
  import { C as SentText, M as storable, O as TaskState, S as SentTaskNote, c as EDITED_HOLD, d as LabelKey, f as LabelValue, g as MessageText, j as platformAvatar, l as Emoji, m as MESSAGE_TEXT_MAX, o as CHANNEL_PATTERN_MAX, p as Labels, r as AttachmentId, s as ChannelPath, t as ActorId, x as SentTaskHoldKind } from "./schemas-7VFdomFB.mjs";
3
- import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin, t as ExternalAuthor } from "./external-BVr1Sq0y.mjs";
3
+ import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin, t as ExternalAuthor } from "./external-BuVTXT1R.mjs";
4
4
  import { z } from "zod";
5
5
  //#region src/api/routes.ts
6
6
  /**
@@ -451,14 +451,25 @@ const ImportOrigin = z.object({
451
451
  /** A link as an import carries it: a board message it names is a ref. */
452
452
  const ImportLink = Link.extend({ message: Ref.nullable() });
453
453
  /**
454
+ * A platform user, as sync names them to the board. Their avatar shows wherever they do, so one
455
+ * that isn't an https URL is dropped, never refused: the write lands without it.
456
+ */
457
+ const PlatformUser = ExternalAuthor.extend({ avatar: z.string().nullable().transform(platformAvatar) });
458
+ /**
454
459
  * Who wrote it on the platform, and the sync key it came through: null for a write a sync callback
455
460
  * makes as that user, which syncs out to every platform like one written on the board.
456
461
  */
457
462
  const Imported = {
458
- author: ExternalAuthor.extend({ avatar: z.string().nullable().transform(platformAvatar) }),
463
+ author: PlatformUser,
459
464
  from: SyncKey.nullable()
460
465
  };
461
466
  /**
467
+ * The platform's users a text mentions as `@[<their id>]`. One the board hasn't met becomes known
468
+ * to it, as one who wrote does: named, and seen where the message is. One the text doesn't mention
469
+ * is left out.
470
+ */
471
+ const Mentioned = z.array(PlatformUser).max(50).optional();
472
+ /**
462
473
  * Where the platform event an import comes from is: its sync entry, platform channel, and thread.
463
474
  * The middleware is told, and answers there when it drops the write.
464
475
  */
@@ -491,6 +502,7 @@ const SyncImportBody = z.discriminatedUnion("op", [
491
502
  noSync: z.boolean().optional(),
492
503
  attachments: z.array(AttachmentId).max(10).optional(),
493
504
  links: z.array(ImportLink).max(10).optional(),
505
+ mentioned: Mentioned,
494
506
  id: z.string().min(1).max(200).refine(storable, "id has a NUL character or a lone surrogate").optional(),
495
507
  /** A reply's precondition, as a post's: a sync callback's reply after the newest message it read. */
496
508
  after: Ref.optional()
@@ -501,7 +513,8 @@ const SyncImportBody = z.discriminatedUnion("op", [
501
513
  ...Changed,
502
514
  text: MessageText,
503
515
  source: ImportSource.optional(),
504
- revision: Revision.optional()
516
+ revision: Revision.optional(),
517
+ mentioned: Mentioned
505
518
  }),
506
519
  z.object({
507
520
  op: z.literal("delete"),