@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,10 +1,10 @@
1
- import { C as fileSize, T as typeOf, c as notFound, r as badRequest, t as HttpError, x as IMPORT_BYTES_MAX, y as ATTACHMENT_BYTES_MAX } from "./errors-DZ1tbwSM.mjs";
1
+ import { C as fileSize, T as typeOf, c as notFound, r as badRequest, t as HttpError, x as IMPORT_BYTES_MAX, y as ATTACHMENT_BYTES_MAX } from "./errors-QhkdzI-o.mjs";
2
2
  import { N as toStorable, m as MESSAGE_TEXT_MAX, s as ChannelPath } from "./schemas-7VFdomFB.mjs";
3
- import { l as isThreadTarget, s as channelOf } from "./external-BVr1Sq0y.mjs";
3
+ import { l as isThreadTarget, s as channelOf } from "./external-BuVTXT1R.mjs";
4
4
  import { t as canonicalEmoji } from "./emoji-CTLpvH-A.mjs";
5
- import { a as waitUntil, c as platformProfile, f as viaText, i as afterRetry, l as shownName, m as derivedId, o as actorParts, t as DroppedError } from "./middleware-BKsTcMAv.mjs";
6
- import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-DfZGp3B-.mjs";
7
- import { a as immutable, d as opensBlock, f as routesFor, l as UnreadableError, n as SyncOverrides, o as ReceivedEvent, s as ResolvedTarget, u as channelMissing } from "./events-mGuhF4i5.mjs";
5
+ import { a as waitUntil, c as platformProfile, f as viaText, i as afterRetry, l as shownName, m as derivedId, o as actorParts, t as DroppedError } from "./middleware-CT6vMNUc.mjs";
6
+ import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
7
+ import { a as immutable, d as opensBlock, f as routesFor, l as UnreadableError, n as SyncOverrides, o as ReceivedEvent, s as ResolvedTarget, u as channelMissing } from "./events-B-qyxNsJ.mjs";
8
8
  import { i as vercelDeployments, n as displayText } from "./bots-CLKKMgYf.mjs";
9
9
  //#region src/sync/engine.ts
10
10
  /** `files`: a message with files may have no text. */
@@ -87,15 +87,37 @@ function keyedId(key, platform, id) {
87
87
  if (id.startsWith(`${key}:`)) return id;
88
88
  return `${key}:${id.startsWith(`${platform}:`) ? id.slice(platform.length + 1) : id}`;
89
89
  }
90
- /** A platform event with its author named under `key`. */
90
+ /**
91
+ * A platform's text, each of its users it mentions by ID (`@[slack:user:U0456]`, as a provider
92
+ * writes one) named under `key`: a mention by the platform's name would be of another sync's user.
93
+ */
94
+ function keyedText(key, platform, text) {
95
+ if (key === platform) return text;
96
+ return replaceMentions(text, (token) => token.kind === "actor" && token.actor.startsWith(`${platform}:`) ? `@[${keyedId(key, platform, token.actor)}]` : null);
97
+ }
98
+ /**
99
+ * A platform event with its author named under `key`, and every user its text mentions there too:
100
+ * the ones `mentioned` describes, and any it has no room for.
101
+ */
91
102
  function keyedEvent(key, platform, event) {
92
- return "author" in event ? {
103
+ if (!("author" in event)) return event;
104
+ const author = {
105
+ ...event.author,
106
+ id: keyedId(key, platform, event.author.id)
107
+ };
108
+ if (event.kind !== "message" && event.kind !== "edited" || key === platform) return {
93
109
  ...event,
94
- author: {
95
- ...event.author,
96
- id: keyedId(key, platform, event.author.id)
97
- }
98
- } : event;
110
+ author
111
+ };
112
+ return {
113
+ ...event,
114
+ author,
115
+ ...event.mentioned ? { mentioned: event.mentioned.map((user) => ({
116
+ ...user,
117
+ id: keyedId(key, platform, user.id)
118
+ })) } : {},
119
+ text: keyedText(key, platform, event.text)
120
+ };
99
121
  }
100
122
  /**
101
123
  * Two-way sync between a board and its platforms, run by board(): webhooks come in through its
@@ -698,6 +720,7 @@ function createSyncEngine(entries) {
698
720
  }, synced?.channel ?? channel);
699
721
  const base = {
700
722
  ...links.length ? { links } : {},
723
+ ...event.mentioned?.length ? { mentioned: event.mentioned } : {},
701
724
  author: event.author,
702
725
  text: clampText(withNotes(overrides.text ?? event.text, notes), attachments.length > 0),
703
726
  ...attachments.length ? { attachments } : {},
@@ -794,13 +817,15 @@ function createSyncEngine(entries) {
794
817
  else if (event.kind === "edited") {
795
818
  const stored = await messageOf(id);
796
819
  const text = clampText(withNotes(overrides.text ?? event.text, stored ? notesIn(stored.text) : []), (stored?.attachments.length ?? 0) > 0);
820
+ const mentioned = event.mentioned?.length ? { mentioned: event.mentioned } : {};
797
821
  if (stored && !event.linksOnly && stored.text !== text) await screened(await call("syncImport", {
798
822
  op: "edit",
799
823
  author,
800
824
  from: key,
801
825
  origin,
802
826
  text,
803
- source: from
827
+ source: from,
828
+ ...mentioned
804
829
  }));
805
830
  const links = stored ? await resolveLinks(platform, event.links ?? [], origin, stored.channel, stored.links) : [];
806
831
  if (stored && !sameLinks(links, stored.links)) await call("syncImport", {
@@ -917,52 +942,39 @@ function createSyncEngine(entries) {
917
942
  }
918
943
  }
919
944
  /**
920
- * A message's text for a platform, through entry `key`, its mentions resolved as it posts and only
921
- * against that entry's own users. An `@handle` reads natively when one of them has it, or of
922
- * several, the one who wrote in the thread: `@support/malte` names one of support's users, and
923
- * `@malte` is short for whichever of this sync's users that is, under its principal's name. An `@[actor-id]` reads natively when it's one of them (`@[slack:user:U0456]` also naming this sync's own profile of them),
924
- * and as the actor's name otherwise; an `@[email]`, as whoever the platform finds with it, or as
925
- * the email. The rest go as written.
945
+ * A message's text for a platform, through entry `key`. A mention is `@[actor-id]`, settled when
946
+ * the message was written: it reads natively when the actor is one of this entry's own users
947
+ * (`@[slack:user:U0456]` also naming this sync's own profile of them), and as the actor's name
948
+ * otherwise. An `@[email]` is whoever the platform finds with it, or the email. Everything else
949
+ * is text and goes as written, an `@handle` included: no sync reads one as a mention.
926
950
  */
927
- async function textFor(key, message, actors, text) {
928
- const tokens = extractMentions(text);
929
- if (tokens.length === 0) return text;
951
+ async function textFor(key, actors, text) {
952
+ const exact = extractMentions(text).flatMap((token) => token.kind === "actor" ? [token.actor] : []);
953
+ if (exact.length === 0) return text;
930
954
  const found = /* @__PURE__ */ new Map();
931
- for (const token of tokens) if (token.kind === "actor" && !actors.byId[token.actor] && isEmail(token.actor)) found.set(token.actor, await emailMention(key, token.actor));
932
- const users = /* @__PURE__ */ new Map();
933
- for (const token of tokens) {
934
- if (token.kind !== "handle") continue;
935
- const theirs = Object.values(actors.byId).filter((actor) => {
936
- const handle = actor.handle.toLowerCase();
937
- return handle === token.handle || !token.handle.includes("/") && handle.slice(handle.indexOf("/") + 1) === token.handle;
938
- });
939
- users.set(token.handle, theirs.flatMap((actor) => {
940
- const mention = nativeMention(key, actor.id, actors);
941
- return mention === null ? [] : [{
942
- id: actor.id,
943
- mention
944
- }];
945
- }));
946
- }
947
- const writers = [...users.values()].some((theirs) => new Set(theirs.map((user) => user.mention)).size > 1) ? new Set((await threadOf(message.re ?? message.id)).map((written) => written.by.actor)) : null;
948
- const one = (theirs) => {
949
- const mentions = new Set(theirs.map((user) => user.mention));
950
- return mentions.size === 1 ? [...mentions][0] : null;
951
- };
955
+ for (const named of exact) if (!actors.byId[named] && isEmail(named)) found.set(named, await emailMention(key, named));
952
956
  return replaceMentions(text, (token) => {
953
- if (token.kind === "handle") {
954
- const theirs = users.get(token.handle) ?? [];
955
- return one(theirs) ?? (writers ? one(theirs.filter((user) => writers.has(user.id))) : null);
956
- }
957
+ if (token.kind === "handle") return null;
957
958
  if (found.has(token.actor)) return found.get(token.actor) ?? token.actor;
958
959
  const actor = actorNamed(token.actor, actors);
959
- return actor ? nativeMention(key, actor.id, actors) ?? actor.name : null;
960
+ return actor ? nativeMention(key, actor.id, actors) ?? actor.name : unmetMention(key, token.actor, actors);
960
961
  });
961
962
  }
962
963
  /**
964
+ * How entry `key`'s platform mentions one of its users the board has no actor for, by the ID
965
+ * they'd have (`@[slack:user:U0456]`, or this sync's `<principal>+slack:user:U0456`): where an ID
966
+ * is all the platform needs. Null for anyone else's user, and on a platform whose mention needs
967
+ * more, so the text goes as written.
968
+ */
969
+ function unmetMention(key, id, actors) {
970
+ const user = userOf(key, id, actors);
971
+ if (user === null) return null;
972
+ const platform = platformOf(key);
973
+ return platform.mentionById(`${platform.platform}:${user}`);
974
+ }
975
+ /**
963
976
  * The actor an `@[actor-id]` names: that actor, or, when the board has none by that ID, this
964
- * sync's own profile of it (`@[slack:user:U0456]` for `<principal>+slack:user:U0456`), as plain
965
- * `@malte` is short for this sync's `<principal>/malte`.
977
+ * sync's own profile of it (`@[slack:user:U0456]` for `<principal>+slack:user:U0456`).
966
978
  */
967
979
  function actorNamed(id, actors) {
968
980
  return actors.byId[id] ?? (actors.principal ? actors.byId[`${actors.principal}+${id}`] : void 0) ?? null;
@@ -1010,7 +1022,7 @@ function createSyncEngine(entries) {
1010
1022
  }));
1011
1023
  if (typeof body !== "string") throw badRequest("a provider renderer must return markdown");
1012
1024
  const labeled = `**${name}**: `;
1013
- const markdown = await textFor(key, message, actors, body.startsWith(labeled) && opensBlock(body.slice(labeled.length)) ? `**${name}**:\n\n${body.slice(labeled.length)}` : body);
1025
+ const markdown = await textFor(key, actors, body.startsWith(labeled) && opensBlock(body.slice(labeled.length)) ? `**${name}**:\n\n${body.slice(labeled.length)}` : body);
1014
1026
  const deployments = message.by.actor === "github:user:35613825" ? vercelDeployments(message.text) : null;
1015
1027
  return {
1016
1028
  markdown,
@@ -1457,10 +1469,17 @@ function createSyncEngine(entries) {
1457
1469
  async function readSource(key, target, limit, after) {
1458
1470
  const platform = platformOf(key);
1459
1471
  try {
1460
- return await platform.read(target, {
1472
+ const read = await platform.read(target, {
1461
1473
  limit,
1462
1474
  after
1463
1475
  });
1476
+ return {
1477
+ ...read,
1478
+ messages: read.messages.map((message) => ({
1479
+ ...message,
1480
+ text: keyedText(key, platform.platform, message.text)
1481
+ }))
1482
+ };
1464
1483
  } catch (error) {
1465
1484
  if (error instanceof UnreadableError) throw new HttpError(unreadableStatus(error.code), error.code, error.message);
1466
1485
  throw badRequest(`can't read ${target} from ${key}: ${describe(error)}`, "platform_error");
@@ -401,13 +401,14 @@ function createBoardClient(options) {
401
401
  ...input,
402
402
  attachments: input.attachments.map((file) => typeof file === "string" ? file : file.id)
403
403
  } : input;
404
- const { task, claim } = await call("POST", "/tasks", { body: {
404
+ const { task, claim, mentions } = await call("POST", "/tasks", { body: {
405
405
  ...where,
406
406
  ...made
407
407
  } });
408
408
  return {
409
409
  task,
410
- ...claim ? { claim: claimed(task, claim) } : {}
410
+ ...claim ? { claim: claimed(task, claim) } : {},
411
+ ...mentions ? { mentions } : {}
411
412
  };
412
413
  }
413
414
  /**
@@ -540,17 +541,31 @@ function createBoardClient(options) {
540
541
  posted: async (id) => (await call("GET", `/posts/${path(id)}`)).message,
541
542
  /** 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`. */
542
543
  threads: (query = {}) => call("GET", `/threads${queryString(query)}`),
544
+ /**
545
+ * Starts a thread. An `@handle` in the text that names exactly one actor you can see is stored as
546
+ * `@[actor-id]`, a mention of them; one that names none or several stays as typed, a mention of
547
+ * no one. `mentions` on what comes back says what became of each, when the text typed any.
548
+ */
543
549
  async post(channel, input) {
544
- return (await call("POST", "/messages", { body: {
550
+ const { message, mentions } = await call("POST", "/messages", { body: {
545
551
  channel,
546
552
  ...messageBody(input)
547
- } })).message;
553
+ } });
554
+ return mentions ? {
555
+ ...message,
556
+ mentions
557
+ } : message;
548
558
  },
559
+ /** 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. */
549
560
  async reply(id, input) {
550
- return (await call("POST", "/messages", { body: {
561
+ const { message, mentions } = await call("POST", "/messages", { body: {
551
562
  re: id,
552
563
  ...messageBody(input)
553
- } })).message;
564
+ } });
565
+ return mentions ? {
566
+ ...message,
567
+ mentions
568
+ } : message;
554
569
  },
555
570
  /**
556
571
  * Posts later, as you: a new thread when `target` is a channel, a reply when it's
@@ -558,10 +573,14 @@ function createBoardClient(options) {
558
573
  * `schedule: { id, n }`. Needs a board with a scheduler.
559
574
  */
560
575
  async schedule(target, input) {
561
- return (await call("POST", "/schedules", { body: {
576
+ const { schedule, mentions } = await call("POST", "/schedules", { body: {
562
577
  ...typeof target === "string" ? { channel: target } : { re: target.re },
563
578
  ...scheduleBody(input)
564
- } })).schedule;
579
+ } });
580
+ return mentions ? {
581
+ ...schedule,
582
+ mentions
583
+ } : schedule;
565
584
  },
566
585
  /** Pending schedules (`all` for done and canceled too), oldest first. `re` is any message in a thread. */
567
586
  schedules: async (query = {}) => (await call("GET", `/schedules${queryString(query)}`)).schedules,
@@ -1,5 +1,5 @@
1
1
  import { d as LabelKey, p as Labels } from "./schemas-7VFdomFB.mjs";
2
- import { n as ExternalEvent, r as ExternalLocation } from "./external-BVr1Sq0y.mjs";
2
+ import { n as ExternalEvent, r as ExternalLocation } from "./external-BuVTXT1R.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/sync/fn.ts
5
5
  const ROUTES = Symbol.for("board.syncRoutes");
@@ -156,6 +156,14 @@ var SyncProvider = class {
156
156
  mention(_actor) {
157
157
  return null;
158
158
  }
159
+ /**
160
+ * How this platform mentions one of its users by their ID alone (`slack:user:U0456` as
161
+ * `<@U0456>`), for one the board hasn't met. Null where a mention needs more than an ID, as
162
+ * GitHub's needs a login, and for anything that isn't a user's ID.
163
+ */
164
+ mentionById(_id) {
165
+ return null;
166
+ }
159
167
  async fetchRoot(_thread) {
160
168
  return null;
161
169
  }