@vercel/board 0.49.0 → 0.50.2

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 (74) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +6 -2
  3. package/dist/{access-B8DnrnHa.mjs → access-BbgmsAFF.mjs} +2 -2
  4. package/dist/access.mjs +5 -5
  5. package/dist/{actors-DewJKyqy.mjs → actors-CX2D22hL.mjs} +3 -3
  6. package/dist/{auth-CEU06Nyp.mjs → auth-DJDTfgAL.mjs} +2 -2
  7. package/dist/{backend-BzCXxVZ-.d.mts → backend-C2JUnbm5.d.mts} +19 -5
  8. package/dist/backend-local.d.mts +1 -1
  9. package/dist/backend-local.mjs +1 -1
  10. package/dist/{chat-provider-BS_fr61g.mjs → chat-provider-Br2RXgLV.mjs} +4 -3
  11. package/dist/{chat-provider-DQ1GHm4o.d.mts → chat-provider-z4nzV8A-.d.mts} +1 -1
  12. package/dist/cli-embedded.d.mts +11 -2
  13. package/dist/cli-embedded.mjs +12 -3
  14. package/dist/cli.mjs +5 -5
  15. package/dist/{conformance-0xONNKcB.mjs → conformance-jHhuKZe8.mjs} +3 -3
  16. package/dist/conformance.d.mts +1 -1
  17. package/dist/conformance.mjs +1 -1
  18. package/dist/{engine-BH_nfJ3N.mjs → engine-I887QHnP.mjs} +20 -10
  19. package/dist/{errors-DwV7I0g4.mjs → errors-DYF4hhIc.mjs} +1 -1
  20. package/dist/{events-B76-4bNp.mjs → events-mWKc1uvZ.mjs} +3 -3
  21. package/dist/{exports-DLzyKwEp.mjs → exports-DRId1Cks.mjs} +147 -65
  22. package/dist/{exports-CKEK1fxf.d.mts → exports-DkdCh3Zi.d.mts} +1 -1
  23. package/dist/{external-BLI4W_-V.mjs → external-DkWafjn-.mjs} +6 -2
  24. package/dist/{index-DxqSw8yd.d.mts → index-DpuOtt0J.d.mts} +2 -2
  25. package/dist/index.d.mts +2 -2
  26. package/dist/index.mjs +4 -4
  27. package/dist/index.node.d.mts +3 -3
  28. package/dist/index.node.mjs +4 -4
  29. package/dist/inspect/app.js +35 -35
  30. package/dist/inspect/engine.js +3 -3
  31. package/dist/inspect-DLLoYeg7.mjs +2 -0
  32. package/dist/{inspect-B2ImmOvw.mjs → inspect-DSBG5VDl.mjs} +3 -3
  33. package/dist/inspect.mjs +2 -2
  34. package/dist/{local-DPpSEq2_.mjs → local-DjrvtIoE.mjs} +46 -24
  35. package/dist/{main-CqX7JqzE.mjs → main-VTkjxFcG.mjs} +27 -15
  36. package/dist/{memory-DzqkXIB-.mjs → memory-wmUDblhm.mjs} +2 -2
  37. package/dist/{middleware-ysFm2S4v.mjs → middleware-DUKIITFZ.mjs} +3 -3
  38. package/dist/{provider-Dwb_9mnu.d.mts → provider-BgUS6ZpP.d.mts} +2 -0
  39. package/dist/{routes-qS92xz8U.mjs → routes-BSBUdD2X.mjs} +9 -9
  40. package/dist/{schemas-TeVe4Udh.mjs → schemas-CUSTEFIy.mjs} +7 -1
  41. package/dist/{serve-CYr4RwRM.mjs → serve-C2xn_cQV.mjs} +8 -7
  42. package/dist/{server-V7qyVUiJ.mjs → server-BLQxoL0g.mjs} +79 -39
  43. package/dist/{serving-BzNxlnDV.mjs → serving-Bulte-NO.mjs} +1 -1
  44. package/dist/{shell-BLHZoP-x.mjs → shell-Bny3-l_d.mjs} +1 -1
  45. package/dist/{sql-DIKQd5Me.mjs → sql-D0MqINA6.mjs} +18 -5
  46. package/dist/{sqlite-BF9kBDh1.mjs → sqlite-Dj2ZEtgy.mjs} +2 -2
  47. package/dist/{sqlite-db-CSYwiZ4E.mjs → sqlite-db-DjbTlUwN.mjs} +1 -1
  48. package/dist/sync-chat-sdk.d.mts +2 -2
  49. package/dist/sync-chat-sdk.mjs +2 -2
  50. package/dist/sync-github.d.mts +2 -2
  51. package/dist/sync-github.mjs +3 -3
  52. package/dist/sync-linear.d.mts +2 -2
  53. package/dist/sync-linear.mjs +3 -3
  54. package/dist/sync-slack.d.mts +20 -3
  55. package/dist/sync-slack.mjs +36 -12
  56. package/dist/sync.d.mts +1 -1
  57. package/dist/sync.mjs +2 -2
  58. package/dist/{tags-BpFo6q0_.mjs → tags-CxDCF_tt.mjs} +2 -2
  59. package/dist/{task-batch-CujTLmTB.mjs → task-batch-CE6BKnRw.mjs} +6 -6
  60. package/dist/{tokens-BmCDAT4N.mjs → tokens-DnDHSPml.mjs} +30 -7
  61. package/dist/{version-BCoWGLEW.mjs → version-DWvOShz3.mjs} +1 -1
  62. package/docs/01-board/01-mounting.md +1 -1
  63. package/docs/01-board/03-identity.md +3 -2
  64. package/docs/01-board/07-schedules.md +1 -1
  65. package/docs/02-sync/01-overview.md +5 -4
  66. package/docs/02-sync/03-slack.md +4 -3
  67. package/docs/03-guides/01-coding-agents.md +1 -1
  68. package/docs/03-guides/06-sandboxed-agents.md +22 -21
  69. package/docs/04-reference/01-cli.md +24 -10
  70. package/docs/04-reference/02-board.md +6 -4
  71. package/docs/04-reference/03-http.md +4 -3
  72. package/docs/index.md +1 -1
  73. package/package.json +14 -2
  74. package/dist/inspect-DnRQUmP8.mjs +0 -2
@@ -1,10 +1,10 @@
1
1
  import { n as formatProfileHeader } from "./profile-header-Cj0Cb1cf.mjs";
2
- import "./schemas-TeVe4Udh.mjs";
3
- import { Z as routes } from "./routes-qS92xz8U.mjs";
4
- import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-DwV7I0g4.mjs";
5
- import { g as keyId, p as DERIVED_ID } from "./middleware-ysFm2S4v.mjs";
6
- import { l as METHODS, o as compileWatcher } from "./task-batch-CujTLmTB.mjs";
7
- import { c as PROTOCOL_ROUTES, d as deployedOnVercel, l as withoutToken, o as createVercel, r as createBoard, u as tailWatchers } from "./exports-DLzyKwEp.mjs";
2
+ import "./schemas-CUSTEFIy.mjs";
3
+ import { Z as routes } from "./routes-BSBUdD2X.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-CE6BKnRw.mjs";
7
+ import { d as tailWatchers, f as deployedOnVercel, l as PROTOCOL_ROUTES, r as createBoard, s as createVercel, u as withoutToken } from "./exports-DRId1Cks.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";
@@ -123,8 +123,8 @@ async function writeCache(audience, login, cached) {
123
123
  let handed$1 = null;
124
124
  /**
125
125
  * 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.
126
+ * nothing asks for it before then, so help, a typo, or misuse never refreshes or prompts. It's the
127
+ * login that goes, wherever the app runs (`appLogin`). Null takes it back.
128
128
  */
129
129
  function handLogin(login) {
130
130
  handed$1 = login;
@@ -141,10 +141,11 @@ function handFetch(send) {
141
141
  }
142
142
  /**
143
143
  * A request to Vercel's API as you: through the fetch the CLI that runs board's hands it with its
144
- * login, which adds its credentials, or with `login` as a Bearer token, through `send`.
144
+ * login, which adds its credentials, or with `login` as a Bearer token, through `send`. A token
145
+ * the run was passed goes as a Bearer token always: the app's fetch would add its own login's.
145
146
  */
146
147
  function asYou(input, init, login, send = fetch) {
147
- if (handedFetch && loginHanded()) return handedFetch(input, init);
148
+ if (passed === null && handedFetch && loginHanded()) return handedFetch(input, init);
148
149
  const headers = new Headers(input instanceof Request ? input.headers : void 0);
149
150
  new Headers(init.headers).forEach((value, name) => headers.set(name, value));
150
151
  headers.set("authorization", `Bearer ${login}`);
@@ -153,13 +154,35 @@ function asYou(input, init, login, send = fetch) {
153
154
  headers
154
155
  });
155
156
  }
156
- /** Whether the login is one a CLI handed over (`createApp`'s `login`, or `VERCEL_AUTH_TOKEN`). */
157
- const loginHanded = () => handed$1 !== null || !!process.env.VERCEL_AUTH_TOKEN;
157
+ /** The token someone passed the CLI that runs board's for this run (`vercel board --token`), while there is one. */
158
+ let passed = null;
159
+ /** Where `vb whoami` says a passed token came from. */
160
+ const PASSED = "the token you passed";
158
161
  /**
159
- * Your Vercel login: what the CLI that runs board's hands it, as `vercel board` does (its `login`,
160
- * or `VERCEL_AUTH_TOKEN` from its `--token`), or else what `vercel login` saved.
162
+ * Hands board the token someone passed the CLI that runs it, as `vercel board --token` does: the
163
+ * Vercel login for this run, ahead of everything the environment holds, a deployment's own token
164
+ * and `BOARD_TOKEN` included. Whoever passed it said who to be, which no variable does. Board
165
+ * sends it itself, as a Bearer token, never through a handed fetch. Null takes it back.
161
166
  */
162
- const vercelLogin = () => handed$1 ? handed$1() : process.env.VERCEL_AUTH_TOKEN ? Promise.resolve(process.env.VERCEL_AUTH_TOKEN) : getVercelToken();
167
+ function handToken(token) {
168
+ passed = token;
169
+ }
170
+ /** The token this run was passed, or null. */
171
+ const passedToken = () => passed;
172
+ /** Whether the login is one a CLI handed over (`createApp`'s `token` or `login`, or `VERCEL_AUTH_TOKEN`). */
173
+ const loginHanded = () => passed !== null || handed$1 !== null || !!process.env.VERCEL_AUTH_TOKEN;
174
+ /**
175
+ * Whether the app that runs board's CLI in its own process gave it a login (`createApp`'s `token`
176
+ * or `login`). The app says who its commands run as, so that login is the one that goes, wherever
177
+ * the app runs: nothing the environment holds stands in for it, a deployment's own token and
178
+ * `BOARD_TOKEN` included. A variable isn't the app's word (`VERCEL_AUTH_TOKEN`): anything sets one.
179
+ */
180
+ const appLogin = () => passed !== null || handed$1 !== null;
181
+ /**
182
+ * Your Vercel login: what the CLI that runs board's hands it, as `vercel board` does (the token
183
+ * it was passed, its `login`, or `VERCEL_AUTH_TOKEN`), or else what `vercel login` saved.
184
+ */
185
+ const vercelLogin = () => passed !== null ? Promise.resolve(passed) : handed$1 ? handed$1() : process.env.VERCEL_AUTH_TOKEN ? Promise.resolve(process.env.VERCEL_AUTH_TOKEN) : getVercelToken();
163
186
  /**
164
187
  * A handed login's token, which its tokens for boards are cached by: null for `vercel login`'s own. One
165
188
  * that fails fails the request: `vercel login`'s, cached or in the `vercel` on PATH, can be someone
@@ -265,8 +288,9 @@ function boardUrl() {
265
288
  }
266
289
  /**
267
290
  * How a client reaches the board at `url` from Node: through Deployment Protection, with a token
268
- * from `token`, `BOARD_TOKEN`, a local board's token file (`vb serve`), GitHub Actions, the Vercel
269
- * runtime, or your Vercel CLI login, in that order. Who you are is the token's to say: the board
291
+ * from `token`, the login of an app that runs board's CLI (`appLogin`), `BOARD_TOKEN`, a local
292
+ * board's token file (`vb serve`), GitHub Actions, the Vercel runtime, or your Vercel CLI login,
293
+ * in that order. Who you are is the token's to say: the board
270
294
  * names you from what it verifies. A board with no Vercel project has no token for your login to
271
295
  * mint, so a request goes to it with none: what verifies its callers may know you another way, as
272
296
  * a board behind `tailscale serve` does.
@@ -287,6 +311,15 @@ function connect(url, options = {}) {
287
311
  let cached = null;
288
312
  let source = null;
289
313
  let person = null;
314
+ /** A token minted with your Vercel login, which `from` names. */
315
+ const asPerson = async (discovered, from) => {
316
+ person ??= personToken(url, discovered).finally(() => {
317
+ person = null;
318
+ });
319
+ const minted = await person;
320
+ source = from;
321
+ return minted;
322
+ };
290
323
  const mint = async () => {
291
324
  if (options.token !== void 0) {
292
325
  const token = typeof options.token === "function" ? await options.token() : options.token;
@@ -295,6 +328,10 @@ function connect(url, options = {}) {
295
328
  expiresAt: expiry(token)
296
329
  };
297
330
  }
331
+ if (appLogin()) {
332
+ const discovered = await discover();
333
+ if (discovered.project_id) return asPerson(discovered, passed !== null ? PASSED : "vercel login");
334
+ }
298
335
  if (process.env.BOARD_TOKEN) {
299
336
  const token = process.env.BOARD_TOKEN;
300
337
  source = "BOARD_TOKEN";
@@ -332,12 +369,7 @@ function connect(url, options = {}) {
332
369
  token: null,
333
370
  expiresAt: Date.now() + 3e5
334
371
  };
335
- person ??= personToken(url, discovered).finally(() => {
336
- person = null;
337
- });
338
- const minted = await person;
339
- source = "vercel login";
340
- return minted;
372
+ return asPerson(discovered, "vercel login");
341
373
  };
342
374
  const token = async () => {
343
375
  if (options.token !== void 0 || !cached || cached.expiresAt - 6e4 < Date.now()) cached = await mint();
@@ -916,17 +948,23 @@ function http(url, options = {}) {
916
948
  }
917
949
  //#endregion
918
950
  //#region src/backend-vercel/index.ts
919
- /** On Vercel, or with its OIDC token pulled (`vercel env pull`): a deployment acts as its project. */
920
- const deployed = () => process.env.VERCEL === "1" || !!process.env.VERCEL_OIDC_TOKEN;
921
- /** Off a deployment, a credential Vercel's API takes, set for board: what a sandbox or CI passes. */
922
- const boardToken = () => deployed() ? null : process.env.BOARD_TOKEN || null;
923
951
  /**
924
- * A token Vercel's API takes: this deployment's OIDC token, or else `BOARD_TOKEN`, or your Vercel
925
- * login, the one the CLI that runs board's hands it (`vercel board`'s, or `VERCEL_AUTH_TOKEN`) or
926
- * your `vercel login`.
952
+ * Whether this deployment's own token is what goes: on Vercel, or with its OIDC token pulled
953
+ * (`vercel env pull`), a deployment acts as its project. Never under an app that runs board's CLI
954
+ * with a login of its own: that login goes.
955
+ */
956
+ const asDeployment = () => !appLogin() && (process.env.VERCEL === "1" || !!process.env.VERCEL_OIDC_TOKEN);
957
+ /** 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. */
958
+ const boardToken = () => appLogin() || asDeployment() ? null : process.env.BOARD_TOKEN || null;
959
+ /** Whether what goes is a Vercel login: an app's, or with no deployment's token and no `BOARD_TOKEN`, yours. */
960
+ const asLogin = () => !asDeployment() && !boardToken();
961
+ /**
962
+ * A token Vercel's API takes: the login of the app that runs board's CLI, when it gave one (the
963
+ * token it was passed, as `vercel board --token`, or else its own), or else this deployment's OIDC
964
+ * token, or else `BOARD_TOKEN`, or your Vercel login: `VERCEL_AUTH_TOKEN`, or your `vercel login`.
927
965
  */
928
966
  async function token() {
929
- if (deployed()) return getVercelOidcToken();
967
+ if (asDeployment()) return getVercelOidcToken();
930
968
  const set = boardToken();
931
969
  if (set) return set;
932
970
  return vercelLogin().catch(() => {
@@ -938,7 +976,8 @@ async function token() {
938
976
  }
939
977
  /** Where `token` comes from, in words: what `vb whoami` says. */
940
978
  function credentialSource() {
941
- if (deployed()) return "Vercel OIDC";
979
+ if (passedToken() !== null) return PASSED;
980
+ if (asDeployment()) return "Vercel OIDC";
942
981
  if (boardToken()) return "BOARD_TOKEN";
943
982
  return loginHanded() ? "the Vercel CLI" : "vercel login";
944
983
  }
@@ -953,8 +992,9 @@ function handTeam(resolve) {
953
992
  }
954
993
  /**
955
994
  * The team: the one a CLI that runs board's hands it, `VERCEL_ORG_ID`, the one the deployment's OIDC
956
- * token names, or the linked project's (the nearest `.vercel/project.json`). A handed one that
957
- * throws fails the request with what it threw: the app's own words, not an internal error.
995
+ * token names when that token is what goes, or the linked project's (the nearest
996
+ * `.vercel/project.json`). A handed one that throws fails the request with what it threw: the
997
+ * app's own words, not an internal error.
958
998
  */
959
999
  async function team() {
960
1000
  if (handed) try {
@@ -963,7 +1003,7 @@ async function team() {
963
1003
  throw new HttpError(502, "no_team", error instanceof Error ? error.message : String(error), { origin: "handle" });
964
1004
  }
965
1005
  if (process.env.VERCEL_ORG_ID) return process.env.VERCEL_ORG_ID;
966
- if (deployed()) try {
1006
+ if (asDeployment()) try {
967
1007
  const owner = decodeJwt(await getVercelOidcToken()).owner_id;
968
1008
  if (typeof owner === "string") return owner;
969
1009
  } catch {}
@@ -978,7 +1018,7 @@ async function team() {
978
1018
  const environment = {
979
1019
  fetch: () => async (input, init = {}) => {
980
1020
  const credential = await token();
981
- if (!deployed() && !boardToken()) return asYou(input, init, credential);
1021
+ if (asLogin()) return asYou(input, init, credential);
982
1022
  const headers = new Headers(init.headers);
983
1023
  headers.set("authorization", `Bearer ${credential}`);
984
1024
  return globalThis.fetch(input, {
@@ -1010,10 +1050,10 @@ function vercel(options = {}) {
1010
1050
  function board(options = {}) {
1011
1051
  return createBoard(options, {
1012
1052
  backend: (fetch) => process.env.BOARD_URL?.trim() ? http() : vercel(fetch ? { fetch } : {}),
1013
- sync: () => import("./engine-BH_nfJ3N.mjs"),
1014
- serving: () => import("./serving-BzNxlnDV.mjs"),
1053
+ sync: () => import("./engine-I887QHnP.mjs"),
1054
+ serving: () => import("./serving-Bulte-NO.mjs"),
1015
1055
  sandbox: (url, token) => sandboxHeaders(url, url, token)
1016
1056
  });
1017
1057
  }
1018
1058
  //#endregion
1019
- export { vercel as a, configDir as c, handFetch as d, handLogin as f, vercelProjectFile as h, handTeam as i, connect as l, projectDir as m, credentialSource as n, http as o, localTokenFile as p, credentialed as r, boardUrl as s, board as t, environmentProfile as u };
1059
+ export { vercelProjectFile as _, vercel as a, boardUrl as c, environmentProfile as d, handFetch as f, projectDir as g, localTokenFile as h, handTeam as i, configDir as l, handToken as m, credentialSource as n, http as o, handLogin as p, credentialed as r, PASSED as s, board as t, connect as u };
@@ -1,2 +1,2 @@
1
- import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-BmCDAT4N.mjs";
1
+ import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-DnDHSPml.mjs";
2
2
  export { discoveryIdentity, oidcTokens, ownProjectId, ownTeamId };
@@ -1,4 +1,4 @@
1
- import { t as VERSION } from "./version-BCoWGLEW.mjs";
1
+ import { t as VERSION } from "./version-DWvOShz3.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
- import { k as actorKind, w as TASK_LABEL } from "./schemas-TeVe4Udh.mjs";
2
- import { c as externalMessageKey, l as isThreadTarget } from "./external-BLI4W_-V.mjs";
1
+ import { A as actorKind, T as TASK_LABEL } from "./schemas-CUSTEFIy.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";
@@ -298,9 +298,12 @@ function foldSync(state, event) {
298
298
  case "thread.synced": {
299
299
  const thread = own(state.threads, event.payload.thread);
300
300
  if (!thread) return state;
301
+ const claims = (event.payload.kind ?? (isThreadTarget(event.payload.target) ? "thread" : "channel")) === "thread";
302
+ const owner = claims ? own(state.byExternalThread, event.payload.target) : void 0;
303
+ if (owner !== void 0 && owner !== event.payload.thread) return state;
301
304
  addTarget(thread, event.payload.target);
302
305
  if (event.payload.kind) setOwn(thread.kinds ??= {}, event.payload.target, event.payload.kind);
303
- if ((event.payload.kind ?? (isThreadTarget(event.payload.target) ? "thread" : "channel")) === "thread") {
306
+ if (claims) {
304
307
  setOwn(thread.external, event.payload.target, event.payload.target);
305
308
  setOwn(state.byExternalThread, event.payload.target, event.payload.thread);
306
309
  }
@@ -396,7 +399,11 @@ function syncReads(event) {
396
399
  thread: null,
397
400
  copy: null
398
401
  };
399
- case "thread.synced":
402
+ case "thread.synced": return {
403
+ thread: event.payload.thread,
404
+ copy: null,
405
+ external: event.payload.target
406
+ };
400
407
  case "message.synced": return {
401
408
  thread: event.payload.thread,
402
409
  copy: null
@@ -437,13 +444,14 @@ function projectSync(before, event) {
437
444
  if (before.thread) setOwn(state.threads, key, structuredClone(before.thread));
438
445
  const reads = syncReads(event);
439
446
  if (reads.copy && before.copy) state.copies[reads.copy[0]] = { [reads.copy[1]]: structuredClone(before.copy) };
447
+ if (reads.external !== void 0 && before.owner !== void 0) setOwn(state.byExternalThread, reads.external, before.owner);
440
448
  foldSync(state, event);
441
449
  const thread = own(state.threads, key);
442
450
  if (thread && JSON.stringify(thread) !== JSON.stringify(before.thread)) change.thread = {
443
451
  key,
444
452
  data: thread
445
453
  };
446
- for (const [external, owner] of Object.entries(state.byExternalThread)) change.externalThreads.push([external, owner]);
454
+ for (const [external, owner] of Object.entries(state.byExternalThread)) if (!(external === reads.external && owner === before.owner)) change.externalThreads.push([external, owner]);
447
455
  for (const [message, targets] of Object.entries(state.copies)) for (const [target, copy] of Object.entries(targets)) if (!(reads.copy?.[0] === Number(message) && reads.copy[1] === target && JSON.stringify(copy) === JSON.stringify(before.copy))) change.copies.push([
448
456
  Number(message),
449
457
  target,
@@ -696,7 +704,12 @@ function sqlTables(db) {
696
704
  text: "select data from board_copies where message_id = $1 and target = $2",
697
705
  values: [reads.copy[0], clean(reads.copy[1])]
698
706
  });
707
+ const [owner] = reads.external === void 0 ? [] : await db.all({
708
+ text: "select thread from board_external_threads where external = $1",
709
+ values: [clean(reads.external)]
710
+ });
699
711
  return {
712
+ ...owner ? { owner: String(owner.thread) } : {},
700
713
  thread: thread ? JSON.parse(String(thread.data)) : void 0,
701
714
  copy: copy ? JSON.parse(String(copy.data)) : void 0
702
715
  };
@@ -1,6 +1,6 @@
1
- import { r as sqlTables } from "./sql-DIKQd5Me.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-CSYwiZ4E.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-DIKQd5Me.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-BgUS6ZpP.mjs";
2
+ import { r as ChatTransport, t as ChatInput } from "./chat-provider-z4nzV8A-.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-B76-4bNp.mjs";
2
- import { t as ChatSyncProvider } from "./chat-provider-BS_fr61g.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-BgUS6ZpP.mjs";
2
+ import { n as ChatSyncProvider } from "./chat-provider-z4nzV8A-.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-B76-4bNp.mjs";
2
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-BS_fr61g.mjs";
3
- import { n as tagOf } from "./tags-BpFo6q0_.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
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";
2
+ import { _ as SyncFn, b as SyncUnit, f as ResolvedTarget, l as ReceivedEvent, o as ProviderPost, p as SyncContext, r as ProviderDelivery } from "./provider-BgUS6ZpP.mjs";
3
+ import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-z4nzV8A-.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-B76-4bNp.mjs";
2
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-BS_fr61g.mjs";
3
- import { n as tagOf, t as slug } from "./tags-BpFo6q0_.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
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";
2
+ import { _ as SyncFn, f as ResolvedTarget, o as ProviderPost, p as SyncContext, r as ProviderDelivery, s as ProviderSender, x as channels } from "./provider-BgUS6ZpP.mjs";
3
+ import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-z4nzV8A-.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
- import { m as MESSAGE_TEXT_MAX } from "./schemas-TeVe4Udh.mjs";
2
- import "./external-BLI4W_-V.mjs";
1
+ import { m as MESSAGE_TEXT_MAX } from "./schemas-CUSTEFIy.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-B76-4bNp.mjs";
5
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-BS_fr61g.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
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";
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-BgUS6ZpP.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-BLI4W_-V.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-B76-4bNp.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,12 +3,12 @@
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) {
10
10
  const key = name ? slug(name) : "";
11
- return key ? [`${prefix}.${key}`.slice(0, 64), name.slice(0, 256)] : null;
11
+ return key ? [`${prefix}.${key}`.slice(0, 64), name.replace(/\p{Cc}/gu, "").slice(0, 256)] : null;
12
12
  }
13
13
  //#endregion
14
14
  export { tagOf as n, slug as t };
@@ -1,10 +1,10 @@
1
1
  import { i as ATTACHMENT_BYTES_MAX } from "./profile-header-Cj0Cb1cf.mjs";
2
- import "./schemas-TeVe4Udh.mjs";
3
- import { l as isThreadTarget } from "./external-BLI4W_-V.mjs";
4
- import { Z as routes, v as Filters } from "./routes-qS92xz8U.mjs";
5
- import { r as badRequest, t as HttpError } from "./errors-DwV7I0g4.mjs";
6
- import { i as afterRetry } from "./middleware-ysFm2S4v.mjs";
7
- import { t as VERSION } from "./version-BCoWGLEW.mjs";
2
+ import "./schemas-CUSTEFIy.mjs";
3
+ import { l as isThreadTarget } from "./external-DkWafjn-.mjs";
4
+ import { Z as routes, v as Filters } from "./routes-BSBUdD2X.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-DWvOShz3.mjs";
8
8
  import { o as options } from "./commands-nN8WpvCe.mjs";
9
9
  import { z } from "zod";
10
10
  //#region src/server/backend.ts