@vercel/board 0.50.0 → 0.51.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 (88) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +128 -118
  3. package/dist/{access-BbgmsAFF.mjs → access-DdojoPZm.mjs} +1 -1
  4. package/dist/access.d.mts +2 -2
  5. package/dist/access.mjs +4 -4
  6. package/dist/{actors-CX2D22hL.mjs → actors-CDkNgWUL.mjs} +3 -3
  7. package/dist/{auth-Z9-Khvvw.d.mts → auth-C4VxPLYz.d.mts} +1 -1
  8. package/dist/{auth-DJDTfgAL.mjs → auth-zPqFJocD.mjs} +10 -3
  9. package/dist/{backend-CcaaS9Xl.d.mts → backend-Da_YEltI.d.mts} +16 -13
  10. package/dist/backend-local.d.mts +1 -1
  11. package/dist/backend-local.mjs +1 -1
  12. package/dist/{chat-provider-DQ1GHm4o.d.mts → chat-provider-BHyX6H8H.d.mts} +2 -2
  13. package/dist/{chat-provider-HJ7y_ipp.mjs → chat-provider-Br2RXgLV.mjs} +4 -3
  14. package/dist/cli-commands.d.mts +1 -1
  15. package/dist/cli-commands.mjs +1 -1
  16. package/dist/cli-embedded.d.mts +15 -7
  17. package/dist/cli-embedded.mjs +9 -6
  18. package/dist/cli.mjs +6 -6
  19. package/dist/{client-C2T4eaXd.d.mts → client-C4-r10SA.d.mts} +25 -4
  20. package/dist/{commands-Cm4sODIu.d.mts → commands-B6pgzwTI.d.mts} +10 -0
  21. package/dist/{commands-nN8WpvCe.mjs → commands-DB1T8vT9.mjs} +37 -10
  22. package/dist/{conformance-Cr-umDl0.mjs → conformance-DW4-9Dwf.mjs} +176 -64
  23. package/dist/conformance.d.mts +4 -3
  24. package/dist/conformance.mjs +1 -1
  25. package/dist/{engine-DJZ8Xy_g.mjs → engine-D8YAsQS_.mjs} +17 -9
  26. package/dist/{errors-DYF4hhIc.mjs → errors-DbCKqGXp.mjs} +35 -7
  27. package/dist/{events-BdOCmnZh.mjs → events-mWKc1uvZ.mjs} +1 -1
  28. package/dist/{exports-CuD-Mxkw.mjs → exports-BDE3eV7B.mjs} +593 -261
  29. package/dist/{exports-lmr6UHHc.d.mts → exports-BUtR_AHa.d.mts} +4 -4
  30. package/dist/{external-D2jq_DEQ.mjs → external-DkWafjn-.mjs} +5 -1
  31. package/dist/{index-_KxJu15n.d.mts → index-BTuTaBaK.d.mts} +2 -2
  32. package/dist/index.d.mts +6 -6
  33. package/dist/index.mjs +4 -4
  34. package/dist/index.node.d.mts +7 -7
  35. package/dist/index.node.mjs +4 -4
  36. package/dist/inspect/app.js +41 -41
  37. package/dist/inspect/engine.js +4 -4
  38. package/dist/inspect-BXvdLMET.mjs +2 -0
  39. package/dist/{inspect-CZeoSm7E.mjs → inspect-Nd_TlU1s.mjs} +3 -3
  40. package/dist/inspect.d.mts +1 -1
  41. package/dist/inspect.mjs +2 -2
  42. package/dist/{local-BVSFSSYf.mjs → local-BsYjQrl_.mjs} +113 -35
  43. package/dist/{main-B016auoG.mjs → main-CSIXhZ_b.mjs} +117 -36
  44. package/dist/{memory-C2lzMV_t.mjs → memory-wmUDblhm.mjs} +2 -2
  45. package/dist/{middleware-DUKIITFZ.mjs → middleware-iVTNf5Su.mjs} +1 -1
  46. package/dist/{profile-header-Cj0Cb1cf.mjs → profile-header-O8wC8yk8.mjs} +12 -1
  47. package/dist/{provider-Dwb_9mnu.d.mts → provider-CGicSMdu.d.mts} +4 -2
  48. package/dist/{routes-BE0y6wCk.mjs → routes-C85Sbhtm.mjs} +44 -11
  49. package/dist/{routes-B6SEA9yw.d.mts → routes-ChGBn0K3.d.mts} +60 -23
  50. package/dist/{serve-B10e7QaY.mjs → serve-Cp0qM4jk.mjs} +9 -8
  51. package/dist/{server-ViWNvg5q.mjs → server-HPq6MO3_.mjs} +50 -33
  52. package/dist/{serving-SbqeWqlA.mjs → serving-aOQsBok0.mjs} +1 -1
  53. package/dist/{shell-DmpmgOPC.mjs → shell-CUR5woOP.mjs} +1 -1
  54. package/dist/{sql-iABdyCiz.mjs → sql-D0MqINA6.mjs} +1 -1
  55. package/dist/{sqlite-28EMrmk7.mjs → sqlite-Dj2ZEtgy.mjs} +2 -2
  56. package/dist/{sqlite-db-Ckd-ceNe.mjs → sqlite-db-DjbTlUwN.mjs} +1 -1
  57. package/dist/sync-chat-sdk.d.mts +2 -2
  58. package/dist/sync-chat-sdk.mjs +2 -2
  59. package/dist/sync-github.d.mts +2 -2
  60. package/dist/sync-github.mjs +3 -3
  61. package/dist/sync-linear.d.mts +3 -3
  62. package/dist/sync-linear.mjs +3 -3
  63. package/dist/sync-slack.d.mts +21 -4
  64. package/dist/sync-slack.mjs +35 -11
  65. package/dist/sync.d.mts +2 -2
  66. package/dist/sync.mjs +2 -2
  67. package/dist/{tags-D0qra0Qy.mjs → tags-CxDCF_tt.mjs} +1 -1
  68. package/dist/{task-batch-9lVDG3d-.mjs → task-batch-D3ASL5_-.mjs} +53 -9
  69. package/dist/{tokens-C-iK0Cku.mjs → tokens-C-T0B1uF.mjs} +31 -7
  70. package/dist/{version-C70RLVEK.mjs → version-BJH1vWR0.mjs} +1 -1
  71. package/docs/01-board/01-mounting.md +20 -7
  72. package/docs/01-board/03-identity.md +1 -1
  73. package/docs/01-board/04-messages.md +5 -0
  74. package/docs/01-board/05-reading.md +71 -16
  75. package/docs/01-board/07-schedules.md +1 -1
  76. package/docs/01-board/10-local.md +1 -1
  77. package/docs/02-sync/01-overview.md +3 -3
  78. package/docs/02-sync/03-slack.md +4 -3
  79. package/docs/03-guides/01-coding-agents.md +1 -1
  80. package/docs/03-guides/02-inspector.md +13 -5
  81. package/docs/03-guides/07-build-a-ui.md +15 -11
  82. package/docs/04-reference/01-cli.md +64 -25
  83. package/docs/04-reference/02-board.md +48 -23
  84. package/docs/04-reference/03-http.md +33 -14
  85. package/docs/04-reference/05-conformance.md +11 -10
  86. package/docs/index.md +1 -1
  87. package/package.json +14 -2
  88. package/dist/inspect-UCcPViyA.mjs +0 -2
@@ -1,8 +1,9 @@
1
- import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-DYF4hhIc.mjs";
2
- import { i as LOGINS, r as LOGIN } from "./auth-DJDTfgAL.mjs";
3
- import { h as localTokenFile, t as board } from "./server-ViWNvg5q.mjs";
4
- import { t as oidcTokens } from "./tokens-C-iK0Cku.mjs";
5
- import { t as local } from "./local-BVSFSSYf.mjs";
1
+ import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-DbCKqGXp.mjs";
2
+ import { i as hostCheckedBy } from "./exports-BDE3eV7B.mjs";
3
+ import { i as LOGINS, r as LOGIN } from "./auth-zPqFJocD.mjs";
4
+ import { h as localTokenFile, t as board } from "./server-HPq6MO3_.mjs";
5
+ import { t as oidcTokens } from "./tokens-C-T0B1uF.mjs";
6
+ import { t as local } from "./local-BsYjQrl_.mjs";
6
7
  import { mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
7
8
  import { userInfo } from "node:os";
8
9
  import { dirname, join, resolve } from "node:path";
@@ -127,13 +128,13 @@ async function serveLocal(options) {
127
128
  issuer: ISSUER,
128
129
  jwks
129
130
  } });
130
- const team = board({
131
+ const team = board(hostCheckedBy({
131
132
  backend,
132
133
  authenticate: tailnet.size > 0 ? tailscale(tokens, (audience) => servedAt(tailnet, audience)) : tokens,
133
134
  basePath: MOUNT
134
- });
135
+ }));
135
136
  try {
136
- await team.channels();
137
+ await team.channels({ limit: 1 });
137
138
  } catch (error) {
138
139
  server.close();
139
140
  throw error;
@@ -1,10 +1,10 @@
1
- import { n as formatProfileHeader } from "./profile-header-Cj0Cb1cf.mjs";
1
+ import { n as formatProfileHeader } from "./profile-header-O8wC8yk8.mjs";
2
2
  import "./schemas-CUSTEFIy.mjs";
3
- import { Z as routes } from "./routes-BE0y6wCk.mjs";
4
- import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-DYF4hhIc.mjs";
5
- import { g as keyId, p as DERIVED_ID } from "./middleware-DUKIITFZ.mjs";
6
- import { l as METHODS, o as compileWatcher } from "./task-batch-9lVDG3d-.mjs";
7
- import { c as PROTOCOL_ROUTES, d as deployedOnVercel, l as withoutToken, o as createVercel, r as createBoard, u as tailWatchers } from "./exports-CuD-Mxkw.mjs";
3
+ import { $ as routes } from "./routes-C85Sbhtm.mjs";
4
+ import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-DbCKqGXp.mjs";
5
+ import { g as keyId, p as DERIVED_ID } from "./middleware-iVTNf5Su.mjs";
6
+ import { l as METHODS, o as compileWatcher } from "./task-batch-D3ASL5_-.mjs";
7
+ import { d as tailWatchers, f as deployedOnVercel, l as PROTOCOL_ROUTES, r as createBoard, s as createVercel, u as withoutToken } from "./exports-BDE3eV7B.mjs";
8
8
  import { execFile } from "node:child_process";
9
9
  import { createHash } from "node:crypto";
10
10
  import { mkdir, readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
@@ -59,6 +59,8 @@ const LOOPBACK = /* @__PURE__ */ new Set([
59
59
  "[::1]"
60
60
  ]);
61
61
  const PROJECT_ID = /^prj_[A-Za-z0-9]{1,64}$/;
62
+ /** A team's ID, or a personal account's, which owns a project too. */
63
+ const OWNER_ID = /^(?:team_)?[A-Za-z0-9]{1,64}$/;
62
64
  const URL_SHAPE = /^https?:\/\/[A-Za-z0-9.-]{1,253}(:\d{1,5})?(\/[A-Za-z0-9._~%/-]{0,2000})?$/;
63
65
  /**
64
66
  * A value a board said, as a message can show it: only when it's what it should be (a project
@@ -123,8 +125,8 @@ async function writeCache(audience, login, cached) {
123
125
  let handed$1 = null;
124
126
  /**
125
127
  * Hands board a login to ask for when a request needs one, as `vercel board` does with its own:
126
- * nothing asks for it before then, so help, a typo, or misuse never refreshes or prompts. Null
127
- * takes it back.
128
+ * nothing asks for it before then, so help, a typo, or misuse never refreshes or prompts. It's the
129
+ * login that goes, wherever the app runs (`appLogin`). Null takes it back.
128
130
  */
129
131
  function handLogin(login) {
130
132
  handed$1 = login;
@@ -172,6 +174,13 @@ const passedToken = () => passed;
172
174
  /** Whether the login is one a CLI handed over (`createApp`'s `token` or `login`, or `VERCEL_AUTH_TOKEN`). */
173
175
  const loginHanded = () => passed !== null || handed$1 !== null || !!process.env.VERCEL_AUTH_TOKEN;
174
176
  /**
177
+ * Whether the app that runs board's CLI in its own process gave it a login (`createApp`'s `token`
178
+ * or `login`). The app says who its commands run as, so that login is the one that goes, wherever
179
+ * the app runs: nothing the environment holds stands in for it, a deployment's own token and
180
+ * `BOARD_TOKEN` included. A variable isn't the app's word (`VERCEL_AUTH_TOKEN`): anything sets one.
181
+ */
182
+ const appLogin = () => passed !== null || handed$1 !== null;
183
+ /**
175
184
  * Your Vercel login: what the CLI that runs board's hands it, as `vercel board` does (the token
176
185
  * it was passed, its `login`, or `VERCEL_AUTH_TOKEN`), or else what `vercel login` saved.
177
186
  */
@@ -235,10 +244,15 @@ async function personToken(audience, discovery) {
235
244
  */
236
245
  async function boardProject(url, discovery, authToken) {
237
246
  const { host, hostname } = new URL(url);
238
- if (LOOPBACK.has(hostname)) return {
239
- id: discovery.project_id,
240
- team: discovery.team_id
241
- };
247
+ if (LOOPBACK.has(hostname)) {
248
+ const id = shown(discovery.project_id, PROJECT_ID);
249
+ const team = discovery.team_id == null ? null : shown(discovery.team_id, OWNER_ID);
250
+ if (!id || team === void 0) throw new BoardError("wrong_project", `The board at ${url} names a project or team that isn't a Vercel ID, so no token is minted for it.`, 0);
251
+ return {
252
+ id,
253
+ team
254
+ };
255
+ }
242
256
  const found = await findProject(authToken ? async (method, path) => {
243
257
  const response = await asYou(`https://api.vercel.com${path}`, { method }, authToken);
244
258
  return response.ok ? await response.json() : null;
@@ -281,7 +295,7 @@ function boardUrl() {
281
295
  }
282
296
  /**
283
297
  * How a client reaches the board at `url` from Node: through Deployment Protection, with a token
284
- * from `token`, the login a CLI that runs board's was passed (`handToken`), `BOARD_TOKEN`, a local
298
+ * from `token`, the login of an app that runs board's CLI (`appLogin`), `BOARD_TOKEN`, a local
285
299
  * board's token file (`vb serve`), GitHub Actions, the Vercel runtime, or your Vercel CLI login,
286
300
  * in that order. Who you are is the token's to say: the board
287
301
  * names you from what it verifies. A board with no Vercel project has no token for your login to
@@ -321,9 +335,9 @@ function connect(url, options = {}) {
321
335
  expiresAt: expiry(token)
322
336
  };
323
337
  }
324
- if (passed !== null) {
338
+ if (appLogin()) {
325
339
  const discovered = await discover();
326
- if (discovered.project_id) return asPerson(discovered, PASSED);
340
+ if (discovered.project_id) return asPerson(discovered, passed !== null ? PASSED : "vercel login");
327
341
  }
328
342
  if (process.env.BOARD_TOKEN) {
329
343
  const token = process.env.BOARD_TOKEN;
@@ -941,21 +955,23 @@ function http(url, options = {}) {
941
955
  }
942
956
  //#endregion
943
957
  //#region src/backend-vercel/index.ts
944
- /** On Vercel, or with its OIDC token pulled (`vercel env pull`): a deployment acts as its project. */
945
- const deployed = () => process.env.VERCEL === "1" || !!process.env.VERCEL_OIDC_TOKEN;
946
- /** Off a deployment, a credential Vercel's API takes, set for board: what a sandbox or CI passes. */
947
- const boardToken = () => deployed() ? null : process.env.BOARD_TOKEN || null;
948
- /** Whether what goes is a Vercel login: a token passed for this run, or with no deployment's token and no `BOARD_TOKEN`, yours. */
949
- const asLogin = () => passedToken() !== null || !deployed() && !boardToken();
950
958
  /**
951
- * A token Vercel's API takes: the one this run was passed (`vercel board --token`), or else this
952
- * deployment's OIDC token, or else `BOARD_TOKEN`, or your Vercel login, the one the CLI that runs
953
- * board's hands it (`vercel board`'s, or `VERCEL_AUTH_TOKEN`) or your `vercel login`.
959
+ * Whether this deployment's own token is what goes: on Vercel, or with its OIDC token pulled
960
+ * (`vercel env pull`), a deployment acts as its project. Never under an app that runs board's CLI
961
+ * with a login of its own: that login goes.
962
+ */
963
+ const asDeployment = () => !appLogin() && (process.env.VERCEL === "1" || !!process.env.VERCEL_OIDC_TOKEN);
964
+ /** Off a deployment, a credential Vercel's API takes, set for board: what a sandbox or CI passes. Not ahead of an app's login either. */
965
+ const boardToken = () => appLogin() || asDeployment() ? null : process.env.BOARD_TOKEN || null;
966
+ /** Whether what goes is a Vercel login: an app's, or with no deployment's token and no `BOARD_TOKEN`, yours. */
967
+ const asLogin = () => !asDeployment() && !boardToken();
968
+ /**
969
+ * A token Vercel's API takes: the login of the app that runs board's CLI, when it gave one (the
970
+ * token it was passed, as `vercel board --token`, or else its own), or else this deployment's OIDC
971
+ * token, or else `BOARD_TOKEN`, or your Vercel login: `VERCEL_AUTH_TOKEN`, or your `vercel login`.
954
972
  */
955
973
  async function token() {
956
- const passed = passedToken();
957
- if (passed !== null) return passed;
958
- if (deployed()) return getVercelOidcToken();
974
+ if (asDeployment()) return getVercelOidcToken();
959
975
  const set = boardToken();
960
976
  if (set) return set;
961
977
  return vercelLogin().catch(() => {
@@ -968,7 +984,7 @@ async function token() {
968
984
  /** Where `token` comes from, in words: what `vb whoami` says. */
969
985
  function credentialSource() {
970
986
  if (passedToken() !== null) return PASSED;
971
- if (deployed()) return "Vercel OIDC";
987
+ if (asDeployment()) return "Vercel OIDC";
972
988
  if (boardToken()) return "BOARD_TOKEN";
973
989
  return loginHanded() ? "the Vercel CLI" : "vercel login";
974
990
  }
@@ -983,8 +999,9 @@ function handTeam(resolve) {
983
999
  }
984
1000
  /**
985
1001
  * The team: the one a CLI that runs board's hands it, `VERCEL_ORG_ID`, the one the deployment's OIDC
986
- * token names, or the linked project's (the nearest `.vercel/project.json`). A handed one that
987
- * throws fails the request with what it threw: the app's own words, not an internal error.
1002
+ * token names when that token is what goes, or the linked project's (the nearest
1003
+ * `.vercel/project.json`). A handed one that throws fails the request with what it threw: the
1004
+ * app's own words, not an internal error.
988
1005
  */
989
1006
  async function team() {
990
1007
  if (handed) try {
@@ -993,7 +1010,7 @@ async function team() {
993
1010
  throw new HttpError(502, "no_team", error instanceof Error ? error.message : String(error), { origin: "handle" });
994
1011
  }
995
1012
  if (process.env.VERCEL_ORG_ID) return process.env.VERCEL_ORG_ID;
996
- if (deployed()) try {
1013
+ if (asDeployment()) try {
997
1014
  const owner = decodeJwt(await getVercelOidcToken()).owner_id;
998
1015
  if (typeof owner === "string") return owner;
999
1016
  } catch {}
@@ -1040,8 +1057,8 @@ function vercel(options = {}) {
1040
1057
  function board(options = {}) {
1041
1058
  return createBoard(options, {
1042
1059
  backend: (fetch) => process.env.BOARD_URL?.trim() ? http() : vercel(fetch ? { fetch } : {}),
1043
- sync: () => import("./engine-DJZ8Xy_g.mjs"),
1044
- serving: () => import("./serving-SbqeWqlA.mjs"),
1060
+ sync: () => import("./engine-D8YAsQS_.mjs"),
1061
+ serving: () => import("./serving-aOQsBok0.mjs"),
1045
1062
  sandbox: (url, token) => sandboxHeaders(url, url, token)
1046
1063
  });
1047
1064
  }
@@ -1,2 +1,2 @@
1
- import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-C-iK0Cku.mjs";
1
+ import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-C-T0B1uF.mjs";
2
2
  export { discoveryIdentity, oidcTokens, ownProjectId, ownTeamId };
@@ -1,4 +1,4 @@
1
- import { t as VERSION } from "./version-C70RLVEK.mjs";
1
+ import { t as VERSION } from "./version-BJH1vWR0.mjs";
2
2
  //#region src/inspect/style.ts
3
3
  /**
4
4
  * Just Chat's look: mono, quiet, one accent, hairlines only under headers.
@@ -1,5 +1,5 @@
1
1
  import { A as actorKind, T as TASK_LABEL } from "./schemas-CUSTEFIy.mjs";
2
- import { c as externalMessageKey, l as isThreadTarget } from "./external-D2jq_DEQ.mjs";
2
+ import { c as externalMessageKey, l as isThreadTarget } from "./external-DkWafjn-.mjs";
3
3
  import { t as canonicalEmoji } from "./emoji-CTLpvH-A.mjs";
4
4
  import { i as mentionTerms } from "./mentions-CnWt9Z5b.mjs";
5
5
  import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
@@ -1,6 +1,6 @@
1
- import { r as sqlTables } from "./sql-iABdyCiz.mjs";
1
+ import { r as sqlTables } from "./sql-D0MqINA6.mjs";
2
2
  import { t as sqlite$1 } from "./store-sqlite-D6fIszST.mjs";
3
- import { t as sqliteDb } from "./sqlite-db-Ckd-ceNe.mjs";
3
+ import { t as sqliteDb } from "./sqlite-db-DjbTlUwN.mjs";
4
4
  //#region src/store/sqlite.ts
5
5
  /**
6
6
  * A local board in one SQLite file, its log and board's tables side by side. It
@@ -1,4 +1,4 @@
1
- import { n as ddl } from "./sql-iABdyCiz.mjs";
1
+ import { n as ddl } from "./sql-D0MqINA6.mjs";
2
2
  import { mkdirSync } from "node:fs";
3
3
  import { dirname, resolve } from "node:path";
4
4
  //#region src/store/sqlite-db.ts
@@ -1,5 +1,5 @@
1
- import { _ as SyncFn, m as SyncProvider, x as channels } from "./provider-Dwb_9mnu.mjs";
2
- import { r as ChatTransport, t as ChatInput } from "./chat-provider-DQ1GHm4o.mjs";
1
+ import { _ as SyncFn, m as SyncProvider, x as channels } from "./provider-CGicSMdu.mjs";
2
+ import { r as ChatTransport, t as ChatInput } from "./chat-provider-BHyX6H8H.mjs";
3
3
  import { z } from "zod";
4
4
  import { ReactionEvent } from "chat";
5
5
  //#region src/sync/chat-sdk.d.ts
@@ -1,5 +1,5 @@
1
- import { i as eventSchema, p as channels, r as envelope } from "./events-BdOCmnZh.mjs";
2
- import { t as ChatSyncProvider } from "./chat-provider-HJ7y_ipp.mjs";
1
+ import { i as eventSchema, p as channels, r as envelope } from "./events-mWKc1uvZ.mjs";
2
+ import { t as ChatSyncProvider } from "./chat-provider-Br2RXgLV.mjs";
3
3
  import { createHash } from "node:crypto";
4
4
  //#region src/sync/chat-sdk.ts
5
5
  const schemaOf = (platform) => eventSchema(platform, "message");
@@ -1,5 +1,5 @@
1
- import { _ as SyncFn, b as SyncUnit, p as SyncContext } from "./provider-Dwb_9mnu.mjs";
2
- import { n as ChatSyncProvider } from "./chat-provider-DQ1GHm4o.mjs";
1
+ import { _ as SyncFn, b as SyncUnit, p as SyncContext } from "./provider-CGicSMdu.mjs";
2
+ import { n as ChatSyncProvider } from "./chat-provider-BHyX6H8H.mjs";
3
3
  import { z } from "zod";
4
4
  import { Adapter } from "chat";
5
5
  //#region src/sync/github.d.ts
@@ -1,6 +1,6 @@
1
- import { _ as withRoutes, i as eventSchema, m as into, r as envelope } from "./events-BdOCmnZh.mjs";
2
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-HJ7y_ipp.mjs";
3
- import { n as tagOf } from "./tags-D0qra0Qy.mjs";
1
+ import { _ as withRoutes, i as eventSchema, m as into, r as envelope } from "./events-mWKc1uvZ.mjs";
2
+ import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-Br2RXgLV.mjs";
3
+ import { n as tagOf } from "./tags-CxDCF_tt.mjs";
4
4
  import { z } from "zod";
5
5
  import { connectGitHubAdapter } from "@vercel/connect/chat";
6
6
  import { createGitHubAdapter } from "@chat-adapter/github";
@@ -1,6 +1,6 @@
1
- import { Mt as SourceRead } from "./routes-B6SEA9yw.mjs";
2
- import { _ as SyncFn, b as SyncUnit, f as ResolvedTarget, l as ReceivedEvent, o as ProviderPost, p as SyncContext, r as ProviderDelivery } from "./provider-Dwb_9mnu.mjs";
3
- import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-DQ1GHm4o.mjs";
1
+ import { Rt as SourceRead } from "./routes-ChGBn0K3.mjs";
2
+ import { _ as SyncFn, b as SyncUnit, f as ResolvedTarget, l as ReceivedEvent, o as ProviderPost, p as SyncContext, r as ProviderDelivery } from "./provider-CGicSMdu.mjs";
3
+ import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-BHyX6H8H.mjs";
4
4
  import { z } from "zod";
5
5
  import { Adapter } from "chat";
6
6
  //#region src/sync/linear.d.ts
@@ -1,6 +1,6 @@
1
- import { i as eventSchema, l as UnreadableError, p as channels, r as envelope } from "./events-BdOCmnZh.mjs";
2
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-HJ7y_ipp.mjs";
3
- import { n as tagOf, t as slug } from "./tags-D0qra0Qy.mjs";
1
+ import { i as eventSchema, l as UnreadableError, p as channels, r as envelope } from "./events-mWKc1uvZ.mjs";
2
+ import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-Br2RXgLV.mjs";
3
+ import { n as tagOf, t as slug } from "./tags-CxDCF_tt.mjs";
4
4
  import "zod";
5
5
  import { connectLinearAdapter } from "@vercel/connect/chat";
6
6
  import { createLinearAdapter } from "@chat-adapter/linear";
@@ -1,6 +1,6 @@
1
- import { zn as ExternalLink } from "./routes-B6SEA9yw.mjs";
2
- import { _ as SyncFn, f as ResolvedTarget, o as ProviderPost, p as SyncContext, r as ProviderDelivery, s as ProviderSender, x as channels } from "./provider-Dwb_9mnu.mjs";
3
- import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-DQ1GHm4o.mjs";
1
+ import { qn as ExternalLink } from "./routes-ChGBn0K3.mjs";
2
+ import { _ as SyncFn, f as ResolvedTarget, o as ProviderPost, p as SyncContext, r as ProviderDelivery, s as ProviderSender, x as channels } from "./provider-CGicSMdu.mjs";
3
+ import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-BHyX6H8H.mjs";
4
4
  import { z } from "zod";
5
5
  import { Adapter } from "chat";
6
6
  //#region src/sync/slack-deployments.d.ts
@@ -125,6 +125,7 @@ export type SlackClient = {
125
125
  test(args?: Record<string, unknown>): Promise<{
126
126
  user_id?: string;
127
127
  user?: string;
128
+ team_id?: string;
128
129
  response_metadata?: {
129
130
  scopes?: string[];
130
131
  };
@@ -149,6 +150,15 @@ type SlackPost = {
149
150
  export declare function slackUsername({ name, attribution }: Pick<ProviderSender, 'name' | 'attribution'>): string | null;
150
151
  /** The `**name**: ` a message's text opens with (on a line of its own before a block), taken out when Slack shows the name as the sender. */
151
152
  export declare function withoutLabel(markdown: string, name: string): string;
153
+ /**
154
+ * Slack's `<!channel>`, `<!here>`, `<!everyone>`, and `<!subteam^…>` notify a whole channel or user
155
+ * group. Text from other platforms (a GitHub comment) isn't allowed to ping them, so a word joiner
156
+ * breaks the markup; the text reads the same. A message written on the board isn't touched: its
157
+ * author may mean to ping a group. Code isn't spared: what Slack takes for code isn't what a regex
158
+ * here does (an escaped backtick, runs that don't match, a fence nobody closed), and guessing wrong
159
+ * pings a channel, where a joiner in copied code is only in the way.
160
+ */
161
+ export declare const withoutBroadcasts: (markdown: string) => string;
152
162
  /** GitHub's markdown allows inline HTML, which Slack shows as raw tags: as markdown instead, outside code. */
153
163
  export declare function withoutHtml(markdown: string): string;
154
164
  /**
@@ -161,6 +171,13 @@ type SlackUser = {
161
171
  name?: string;
162
172
  real_name?: string;
163
173
  is_bot?: boolean;
174
+ /** A guest: one channel or several, never every public channel. */
175
+ is_restricted?: boolean;
176
+ is_ultra_restricted?: boolean;
177
+ /** Someone from another organization, in a Slack Connect channel. */
178
+ is_stranger?: boolean;
179
+ /** The workspace they belong to: the app's own for its people, another's for a Slack Connect member. */
180
+ team_id?: string;
164
181
  profile?: {
165
182
  display_name?: string;
166
183
  real_name?: string;
@@ -401,7 +418,7 @@ export declare class SlackProvider extends ChatSyncProvider<SlackEvent> {
401
418
  private scopes;
402
419
  constructor(given: SlackOptions, sync: SyncFn<SlackEvent>);
403
420
  /**
404
- * A message goes out under its author's name (`Julián Benegas`, `clever-lemur via vboard-factory`,
421
+ * A message goes out under its author's name (`Ada Lovelace`, `clever-lemur via acme-agents`,
405
422
  * `Malte via support (slack)`), and their picture when it has one Slack can show, instead of the
406
423
  * app's, with the text's `**name**: ` label dropped. Without `chat:write.customize` it posts as
407
424
  * the app, label and all.
@@ -1,8 +1,8 @@
1
1
  import { m as MESSAGE_TEXT_MAX } from "./schemas-CUSTEFIy.mjs";
2
- import "./external-D2jq_DEQ.mjs";
2
+ import "./external-DkWafjn-.mjs";
3
3
  import { t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
4
- import { d as opensBlock, i as eventSchema, l as UnreadableError, p as channels, r as envelope } from "./events-BdOCmnZh.mjs";
5
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-HJ7y_ipp.mjs";
4
+ import { d as opensBlock, i as eventSchema, l as UnreadableError, p as channels, r as envelope } from "./events-mWKc1uvZ.mjs";
5
+ import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-Br2RXgLV.mjs";
6
6
  import { r as formatVercelDeployments } from "./bots-CqPYxkqK.mjs";
7
7
  import { z } from "zod";
8
8
  import { stringifyMarkdown } from "chat";
@@ -286,6 +286,15 @@ const BLOCKS = /* @__PURE__ */ new Set([
286
286
  "h6"
287
287
  ]);
288
288
  const attribute = (attrs, name) => new RegExp(`\\s${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i").exec(attrs)?.slice(1).find((v) => v !== void 0) ?? "";
289
+ /**
290
+ * Slack's `<!channel>`, `<!here>`, `<!everyone>`, and `<!subteam^…>` notify a whole channel or user
291
+ * group. Text from other platforms (a GitHub comment) isn't allowed to ping them, so a word joiner
292
+ * breaks the markup; the text reads the same. A message written on the board isn't touched: its
293
+ * author may mean to ping a group. Code isn't spared: what Slack takes for code isn't what a regex
294
+ * here does (an escaped backtick, runs that don't match, a fence nobody closed), and guessing wrong
295
+ * pings a channel, where a joiner in copied code is only in the way.
296
+ */
297
+ const withoutBroadcasts = (markdown) => markdown.replace(/<!(?=[a-z^])/gi, "<⁠!");
289
298
  /** GitHub's markdown allows inline HTML, which Slack shows as raw tags: as markdown instead, outside code. */
290
299
  function withoutHtml(markdown) {
291
300
  if (!/<\/?[a-z!]/i.test(markdown) || /[\uE000\uE001]/.test(markdown)) return markdown;
@@ -736,20 +745,33 @@ var SlackProvider = class extends ChatSyncProvider {
736
745
  inclusive: true,
737
746
  limit: 1
738
747
  })).messages?.find((m) => m.ts === ts);
748
+ const [, at, root] = linker.thread.split(":");
749
+ const linkingMessage = at && root ? one(at, root, linker.message).catch(() => void 0) : Promise.resolve(void 0);
750
+ const posterMayRead = async () => {
751
+ const poster = (await linkingMessage)?.user;
752
+ if (!poster) return await linkingMessage !== void 0;
753
+ const user = (await web.users?.info({ user: poster }).catch(() => void 0))?.user;
754
+ if (!user) return false;
755
+ if (user.is_bot) return true;
756
+ if (user.is_restricted || user.is_ultra_restricted || user.is_stranger) return false;
757
+ const team = (await web.auth?.test().catch(() => void 0))?.team_id;
758
+ return !!team && user.team_id === team;
759
+ };
739
760
  let found;
740
761
  let unavailable = "message_not_found";
741
762
  try {
742
763
  const info = (await web.conversations.info({ channel })).channel;
743
764
  if (!info) unavailable = "channel_not_found";
744
765
  else if (info.is_private || info.is_im || info.is_mpim) unavailable = "private_channel";
766
+ else if (info.is_ext_shared) unavailable = "shared_channel";
745
767
  else if (!info.is_member) unavailable = "not_in_channel";
768
+ else if (!await posterMayRead()) unavailable = "poster_cannot_read";
746
769
  else found = await one(channel, thread, link.message);
747
770
  } catch (error) {
748
771
  unavailable = slackError(error);
749
772
  }
750
773
  if (!found) {
751
- const [, at, root] = linker.thread.split(":");
752
- const linking = at && root ? await one(at, root, linker.message).catch(() => void 0) : void 0;
774
+ const linking = await linkingMessage;
753
775
  const unfurled = linking ? slackLinks("", linking.text ?? "", linking.attachments, mrkdwn).find((known) => known.url === link.url)?.snapshot : null;
754
776
  return unfurled ? {
755
777
  snapshot: unfurled,
@@ -920,16 +942,17 @@ var SlackProvider = class extends ChatSyncProvider {
920
942
  literalMentions(options.adapter);
921
943
  }
922
944
  /**
923
- * A message goes out under its author's name (`Julián Benegas`, `clever-lemur via vboard-factory`,
945
+ * A message goes out under its author's name (`Ada Lovelace`, `clever-lemur via acme-agents`,
924
946
  * `Malte via support (slack)`), and their picture when it has one Slack can show, instead of the
925
947
  * app's, with the text's `**name**: ` label dropped. Without `chat:write.customize` it posts as
926
948
  * the app, label and all.
927
949
  */
928
950
  async post(target, kind, body) {
929
- const { as, deployments, ...given } = body;
951
+ const { as, deployments, external, ...given } = body;
952
+ const html = withoutHtml(given.markdown);
930
953
  const post = {
931
954
  ...given,
932
- markdown: withoutHtml(given.markdown)
955
+ markdown: external ? withoutBroadcasts(html) : html
933
956
  };
934
957
  if (deployments && !post.files?.length) {
935
958
  const laidOut = await this.postDeployments(target, as, post.markdown, deployments);
@@ -995,10 +1018,11 @@ var SlackProvider = class extends ChatSyncProvider {
995
1018
  }
996
1019
  /** An edit keeps the label out only where the message went out under its author's name. */
997
1020
  async edit(thread, message, body) {
998
- const { as, deployments, ...given } = body;
1021
+ const { as, deployments, external, ...given } = body;
1022
+ const html = withoutHtml(given.markdown);
999
1023
  const post = {
1000
1024
  ...given,
1001
- markdown: withoutHtml(given.markdown)
1025
+ markdown: external ? withoutBroadcasts(html) : html
1002
1026
  };
1003
1027
  const edited = (as && await this.web().then((web) => !!web && this.canCustomize(web), () => false) ? await this.sentAs(thread, message, as) : false) && as ? {
1004
1028
  ...post,
@@ -1156,4 +1180,4 @@ var SlackProvider = class extends ChatSyncProvider {
1156
1180
  }
1157
1181
  };
1158
1182
  //#endregion
1159
- export { SlackEvent, SlackProvider, channels, forwardText, slack, slackFileName, slackIcon, slackLinks, slackUsername, withoutHtml, withoutLabel };
1183
+ export { SlackEvent, SlackProvider, channels, forwardText, slack, slackFileName, slackIcon, slackLinks, slackUsername, withoutBroadcasts, withoutHtml, withoutLabel };
package/dist/sync.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { In as ExternalAuthor, Ln as ExternalEvent, Rn as ExternalFile } from "./routes-B6SEA9yw.mjs";
2
- import { A as SyncRoot, C as mirror, D as RootOverride, E as ProviderEvent, M as eventSchema, N as VercelDeployment, O as SyncOverrides, S as into, T as EventBase, _ as SyncFn, a as ProviderOptions, b as SyncUnit, c as Receive, d as Renderer, f as ResolvedTarget, g as Sync, h as UnreadableError, i as ProviderFile, j as envelope, k as SyncResult, l as ReceivedEvent, m as SyncProvider, n as FileDelivery, o as ProviderPost, p as SyncContext, r as ProviderDelivery, u as RenderInput, v as SyncIn, w as render, x as channels, y as SyncOut } from "./provider-Dwb_9mnu.mjs";
1
+ import { Gn as ExternalEvent, Kn as ExternalFile, Wn as ExternalAuthor } from "./routes-ChGBn0K3.mjs";
2
+ import { A as SyncRoot, C as mirror, D as RootOverride, E as ProviderEvent, M as eventSchema, N as VercelDeployment, O as SyncOverrides, S as into, T as EventBase, _ as SyncFn, a as ProviderOptions, b as SyncUnit, c as Receive, d as Renderer, f as ResolvedTarget, g as Sync, h as UnreadableError, i as ProviderFile, j as envelope, k as SyncResult, l as ReceivedEvent, m as SyncProvider, n as FileDelivery, o as ProviderPost, p as SyncContext, r as ProviderDelivery, u as RenderInput, v as SyncIn, w as render, x as channels, y as SyncOut } from "./provider-CGicSMdu.mjs";
3
3
  export { EventBase, type ExternalAuthor, ExternalEvent, type ExternalFile, type FileDelivery, type ProviderDelivery, type ProviderEvent, type ProviderFile, type ProviderOptions, type ProviderPost, type Receive, ReceivedEvent, type RenderInput, type Renderer, ResolvedTarget, type RootOverride, type Sync, type SyncContext, type SyncFn, type SyncIn, type SyncOut, SyncOverrides, SyncProvider, type SyncResult, type SyncRoot, type SyncUnit, UnreadableError, type VercelDeployment, channels, envelope, eventSchema, into, mirror, render };
package/dist/sync.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { n as ExternalEvent } from "./external-D2jq_DEQ.mjs";
2
- import { c as SyncProvider, g as render, h as mirror, i as eventSchema, l as UnreadableError, m as into, n as SyncOverrides, o as ReceivedEvent, p as channels, r as envelope, s as ResolvedTarget, t as EventBase } from "./events-BdOCmnZh.mjs";
1
+ import { n as ExternalEvent } from "./external-DkWafjn-.mjs";
2
+ import { c as SyncProvider, g as render, h as mirror, i as eventSchema, l as UnreadableError, m as into, n as SyncOverrides, o as ReceivedEvent, p as channels, r as envelope, s as ResolvedTarget, t as EventBase } from "./events-mWKc1uvZ.mjs";
3
3
  export { EventBase, ExternalEvent, ReceivedEvent, ResolvedTarget, SyncOverrides, SyncProvider, UnreadableError, channels, envelope, eventSchema, into, mirror, render };
@@ -3,7 +3,7 @@
3
3
  const slug = (name) => name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9_.-]+/g, "-").replace(/^[-_.]+|-+$/g, "");
4
4
  /**
5
5
  * A platform's label or assignee as a board label: `bug` → `tag.bug=bug`,
6
- * `julianbenegas` → `assignee.julianbenegas=julianbenegas`. The keys don't
6
+ * `grace` → `assignee.grace=grace`. The keys don't
7
7
  * name the platform, so a filter like `--label tag.bug` holds for any of them.
8
8
  */
9
9
  function tagOf(prefix, name) {
@@ -1,16 +1,60 @@
1
- import { i as ATTACHMENT_BYTES_MAX } from "./profile-header-Cj0Cb1cf.mjs";
1
+ import { c as fileNameProblem, i as ATTACHMENT_BYTES_MAX, s as fileName } from "./profile-header-O8wC8yk8.mjs";
2
2
  import "./schemas-CUSTEFIy.mjs";
3
- import { l as isThreadTarget } from "./external-D2jq_DEQ.mjs";
4
- import { Z as routes, v as Filters } from "./routes-BE0y6wCk.mjs";
5
- import { r as badRequest, t as HttpError } from "./errors-DYF4hhIc.mjs";
6
- import { i as afterRetry } from "./middleware-DUKIITFZ.mjs";
7
- import { t as VERSION } from "./version-C70RLVEK.mjs";
8
- import { o as options } from "./commands-nN8WpvCe.mjs";
3
+ import { l as isThreadTarget } from "./external-DkWafjn-.mjs";
4
+ import { $ as routes, b as Filters } from "./routes-C85Sbhtm.mjs";
5
+ import { r as badRequest, t as HttpError } from "./errors-DbCKqGXp.mjs";
6
+ import { i as afterRetry } from "./middleware-iVTNf5Su.mjs";
7
+ import { t as VERSION } from "./version-BJH1vWR0.mjs";
8
+ import { t as own } from "./own-OwgPWdmh.mjs";
9
+ import { o as options } from "./commands-DB1T8vT9.mjs";
9
10
  import { z } from "zod";
10
11
  //#region src/server/backend.ts
11
12
  /** The subscription sync's outbound runs on, in `BoardBinding.subscriptions`. No watcher's ID starts with `@`. */
12
13
  const SYNC = "@sync";
13
14
  //#endregion
15
+ //#region src/server/file-names.ts
16
+ /** The name an upload is stored under, or 400 `invalid_attachment` when it's one no backend keeps. */
17
+ function uploadName(name) {
18
+ const named = fileName(name);
19
+ const problem = fileNameProblem(named);
20
+ if (problem) throw badRequest(problem, "invalid_attachment");
21
+ return named;
22
+ }
23
+ //#endregion
24
+ //#region src/server/carried.ts
25
+ /**
26
+ * An event of a read of the feed's end, whose `message` is its message as it is now, with nothing that message no
27
+ * longer carries. A label change keeps the values the message still has. An event whose whole point is gone is null,
28
+ * to be left out: a reaction since removed, a delivery's failure since made good, a receipt on a message since
29
+ * deleted, and a task's failure or hold since cleared, each with its reason. A task's result, and the reason it was
30
+ * canceled, are there for good once they are.
31
+ */
32
+ function carried(event) {
33
+ const message = event.message;
34
+ if (!message) return event;
35
+ const payload = event.payload;
36
+ switch (event.type) {
37
+ case "reaction.added":
38
+ case "reaction.removed": return own(message.reactions, payload.emoji)?.includes(payload.by?.actor ?? "") ? event : null;
39
+ case "message.synced":
40
+ case "message.files_synced": return message.deleted ? null : event;
41
+ case "message.sync_failed": return own(message.undelivered, payload.target) === payload.error ? event : null;
42
+ case "task.failed": return message.task?.reason === payload.reason ? event : null;
43
+ case "task.blocked": return message.task?.blocked?.reason === payload.reason ? event : null;
44
+ case "labels.changed": {
45
+ const set = Object.fromEntries(Object.entries(payload.set ?? {}).filter(([key, value]) => own(message.labels, key) === value));
46
+ return {
47
+ ...event,
48
+ payload: {
49
+ ...payload,
50
+ set
51
+ }
52
+ };
53
+ }
54
+ default: return event;
55
+ }
56
+ }
57
+ //#endregion
14
58
  //#region src/server/routing.ts
15
59
  /** board()'s own routes: the files it serves, and sync's, which run where board() does. */
16
60
  const BOARD_ROUTES = [
@@ -26,7 +70,7 @@ const METHODS = [
26
70
  "channels",
27
71
  "createChannel",
28
72
  "actors",
29
- "messages",
73
+ "channelMessages",
30
74
  "threads",
31
75
  "message",
32
76
  "post",
@@ -499,4 +543,4 @@ function batchPlan(tasks) {
499
543
  };
500
544
  }
501
545
  //#endregion
502
- export { runMatch as a, withMentions as c, openapi as d, queryObject as f, SYNC as h, canonicalWatchers as i, METHODS as l, readJson as m, SYNC_ACTOR as n, compileWatcher as o, readCapped as p, syncTarget as r, hasCriteria as s, batchPlan as t, createRouter as u };
546
+ export { SYNC as _, runMatch as a, withMentions as c, openapi as d, queryObject as f, uploadName as g, carried as h, canonicalWatchers as i, METHODS as l, readJson as m, SYNC_ACTOR as n, compileWatcher as o, readCapped as p, syncTarget as r, hasCriteria as s, batchPlan as t, createRouter as u };