@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
@@ -117,6 +117,13 @@ declare const ExternalEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
117
117
  }, z.core.$strip>>;
118
118
  }, z.core.$strip>>;
119
119
  }, z.core.$strip>>>;
120
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
121
+ id: z.ZodString;
122
+ handle: z.ZodString;
123
+ name: z.ZodString;
124
+ avatar: z.ZodNullable<z.ZodString>;
125
+ isBot: z.ZodBoolean;
126
+ }, z.core.$strip>>>;
120
127
  }, z.core.$strip>, z.ZodObject<{
121
128
  channel: z.ZodString;
122
129
  thread: z.ZodString;
@@ -146,6 +153,13 @@ declare const ExternalEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
146
153
  }, z.core.$strip>>;
147
154
  }, z.core.$strip>>>;
148
155
  linksOnly: z.ZodOptional<z.ZodBoolean>;
156
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
157
+ id: z.ZodString;
158
+ handle: z.ZodString;
159
+ name: z.ZodString;
160
+ avatar: z.ZodNullable<z.ZodString>;
161
+ isBot: z.ZodBoolean;
162
+ }, z.core.$strip>>>;
149
163
  }, z.core.$strip>, z.ZodObject<{
150
164
  channel: z.ZodString;
151
165
  thread: z.ZodString;
@@ -1383,6 +1397,13 @@ declare const SyncImportBody: z.ZodDiscriminatedUnion<[z.ZodObject<{
1383
1397
  unavailable: z.ZodNullable<z.ZodString>;
1384
1398
  message: z.ZodNullable<z.ZodString>;
1385
1399
  }, z.core.$strip>>>;
1400
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
1401
+ id: z.ZodString;
1402
+ handle: z.ZodString;
1403
+ name: z.ZodString;
1404
+ isBot: z.ZodBoolean;
1405
+ avatar: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | null, string | null>>;
1406
+ }, z.core.$strip>>>;
1386
1407
  id: z.ZodOptional<z.ZodString>;
1387
1408
  after: z.ZodOptional<z.ZodString>;
1388
1409
  }, z.core.$strip>, z.ZodObject<{
@@ -1407,6 +1428,13 @@ declare const SyncImportBody: z.ZodDiscriminatedUnion<[z.ZodObject<{
1407
1428
  thread: z.ZodString;
1408
1429
  }, z.core.$strip>>;
1409
1430
  revision: z.ZodOptional<z.ZodNumber>;
1431
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
1432
+ id: z.ZodString;
1433
+ handle: z.ZodString;
1434
+ name: z.ZodString;
1435
+ isBot: z.ZodBoolean;
1436
+ avatar: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | null, string | null>>;
1437
+ }, z.core.$strip>>>;
1410
1438
  }, z.core.$strip>, z.ZodObject<{
1411
1439
  author: z.ZodObject<{
1412
1440
  id: z.ZodString;
@@ -1579,6 +1607,13 @@ declare const InboxPushBody: z.ZodObject<{
1579
1607
  }, z.core.$strip>>;
1580
1608
  }, z.core.$strip>>;
1581
1609
  }, z.core.$strip>>>;
1610
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
1611
+ id: z.ZodString;
1612
+ handle: z.ZodString;
1613
+ name: z.ZodString;
1614
+ avatar: z.ZodNullable<z.ZodString>;
1615
+ isBot: z.ZodBoolean;
1616
+ }, z.core.$strip>>>;
1582
1617
  }, z.core.$strip>, z.ZodObject<{
1583
1618
  channel: z.ZodString;
1584
1619
  thread: z.ZodString;
@@ -1608,6 +1643,13 @@ declare const InboxPushBody: z.ZodObject<{
1608
1643
  }, z.core.$strip>>;
1609
1644
  }, z.core.$strip>>>;
1610
1645
  linksOnly: z.ZodOptional<z.ZodBoolean>;
1646
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
1647
+ id: z.ZodString;
1648
+ handle: z.ZodString;
1649
+ name: z.ZodString;
1650
+ avatar: z.ZodNullable<z.ZodString>;
1651
+ isBot: z.ZodBoolean;
1652
+ }, z.core.$strip>>>;
1611
1653
  }, z.core.$strip>, z.ZodObject<{
1612
1654
  channel: z.ZodString;
1613
1655
  thread: z.ZodString;
@@ -2771,6 +2813,13 @@ declare const routes: {
2771
2813
  }, z.core.$strip>>;
2772
2814
  }, z.core.$strip>>;
2773
2815
  }, z.core.$strip>>>;
2816
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
2817
+ id: z.ZodString;
2818
+ handle: z.ZodString;
2819
+ name: z.ZodString;
2820
+ avatar: z.ZodNullable<z.ZodString>;
2821
+ isBot: z.ZodBoolean;
2822
+ }, z.core.$strip>>>;
2774
2823
  }, z.core.$strip>, z.ZodObject<{
2775
2824
  channel: z.ZodString;
2776
2825
  thread: z.ZodString;
@@ -2800,6 +2849,13 @@ declare const routes: {
2800
2849
  }, z.core.$strip>>;
2801
2850
  }, z.core.$strip>>>;
2802
2851
  linksOnly: z.ZodOptional<z.ZodBoolean>;
2852
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
2853
+ id: z.ZodString;
2854
+ handle: z.ZodString;
2855
+ name: z.ZodString;
2856
+ avatar: z.ZodNullable<z.ZodString>;
2857
+ isBot: z.ZodBoolean;
2858
+ }, z.core.$strip>>>;
2803
2859
  }, z.core.$strip>, z.ZodObject<{
2804
2860
  channel: z.ZodString;
2805
2861
  thread: z.ZodString;
@@ -2910,6 +2966,13 @@ declare const routes: {
2910
2966
  unavailable: z.ZodNullable<z.ZodString>;
2911
2967
  message: z.ZodNullable<z.ZodString>;
2912
2968
  }, z.core.$strip>>>;
2969
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
2970
+ id: z.ZodString;
2971
+ handle: z.ZodString;
2972
+ name: z.ZodString;
2973
+ isBot: z.ZodBoolean;
2974
+ avatar: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | null, string | null>>;
2975
+ }, z.core.$strip>>>;
2913
2976
  id: z.ZodOptional<z.ZodString>;
2914
2977
  after: z.ZodOptional<z.ZodString>;
2915
2978
  }, z.core.$strip>, z.ZodObject<{
@@ -2934,6 +2997,13 @@ declare const routes: {
2934
2997
  thread: z.ZodString;
2935
2998
  }, z.core.$strip>>;
2936
2999
  revision: z.ZodOptional<z.ZodNumber>;
3000
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
3001
+ id: z.ZodString;
3002
+ handle: z.ZodString;
3003
+ name: z.ZodString;
3004
+ isBot: z.ZodBoolean;
3005
+ avatar: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | null, string | null>>;
3006
+ }, z.core.$strip>>>;
2937
3007
  }, z.core.$strip>, z.ZodObject<{
2938
3008
  author: z.ZodObject<{
2939
3009
  id: z.ZodString;
@@ -0,0 +1,285 @@
1
+ import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-QhkdzI-o.mjs";
2
+ import { i as LOGINS, r as LOGIN } from "./auth-B9-wXQ-x.mjs";
3
+ import { p as localTokenFile, t as board } from "./server-DmlyIzMj.mjs";
4
+ import { t as oidcTokens } from "./tokens-BCp4EWTQ.mjs";
5
+ import { t as local } from "./local-CKMP4xH3.mjs";
6
+ import { mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
7
+ import { userInfo } from "node:os";
8
+ import { dirname, join, resolve } from "node:path";
9
+ import { SignJWT, createLocalJWKSet, exportJWK, generateKeyPair } from "jose";
10
+ import { createServer } from "node:http";
11
+ //#region src/cli/tailscale.ts
12
+ /**
13
+ * The login Tailscale says a request is from, as its `Tailscale-User-Login` header gives it, in
14
+ * lowercase: `ada@example.com`. Null when it names none, as for a tagged device or a request
15
+ * through Funnel, or one a principal's ID can't hold (a `+`, or what Tailscale had to encode).
16
+ */
17
+ function tailscaleLogin(header) {
18
+ const login = typeof header === "string" ? header.trim().toLowerCase() : "";
19
+ return LOGIN.test(login) ? login : null;
20
+ }
21
+ /**
22
+ * `tokens`, and where `at` says Tailscale serves the board, the people Tailscale says are calling:
23
+ * a request there with no token is `tailscale:user:<login>`, a person, with the handle before the
24
+ * login's `@`. `tailscale serve` drops any `Tailscale-User-Login` its caller sent and sets its own,
25
+ * so the header is Tailscale's word wherever only its proxy and this machine reach the board; it's
26
+ * read nowhere else, since any other sender writes its own.
27
+ *
28
+ * A browser sends a page's requests from its user's place on the tailnet, whatever site the page is
29
+ * from, so a request a browser marks as another site's is no one's: only the board's own origin
30
+ * acts as its visitor.
31
+ */
32
+ function tailscale(tokens, at) {
33
+ const authenticate = (request) => {
34
+ if (request.credential !== null || !at(request.audience)) return tokens(request);
35
+ const login = tailscaleLogin(request.headers.get("tailscale-user-login"));
36
+ if (login === null) return null;
37
+ const site = request.headers.get("sec-fetch-site");
38
+ const origin = request.headers.get("origin");
39
+ if (site !== null && site !== "same-origin" && site !== "none" || origin !== null && origin !== new URL(request.audience).origin) throw new HttpError(403, "forbidden", "a page on another site can't act as you on this board");
40
+ return {
41
+ id: `tailscale:user:${login}`,
42
+ kind: "person",
43
+ handle: login.slice(0, login.indexOf("@"))
44
+ };
45
+ };
46
+ return Object.assign(authenticate, { [LOGINS]: true });
47
+ }
48
+ /** Where the board is mounted on its server: every other path is the inspector's, when it's served. */
49
+ const MOUNT = "/api/board";
50
+ const mounted = (path) => path === MOUNT || path.startsWith(`${MOUNT}/`);
51
+ const ISSUER = "board:local";
52
+ const BODY_MAX = 8388608;
53
+ /** Your OS username as a handle: lowercase letters, digits, `.`, `_`, `-`. */
54
+ function localHandle(name = safeUsername()) {
55
+ return name.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g, "").slice(0, 64).replace(/[^a-z0-9]+$/, "") || "me";
56
+ }
57
+ function safeUsername() {
58
+ try {
59
+ return userInfo().username;
60
+ } catch {
61
+ return process.env.USER || process.env.USERNAME || "me";
62
+ }
63
+ }
64
+ /** What an earlier `vb serve` left under `dir` (`board.db`, `attachments/`), moved to where `local()` keeps the board. */
65
+ async function carryOver(dir) {
66
+ const there = (path) => stat(join(dir, path)).then(() => true, () => false);
67
+ if (!await there("board.db") || await there("local.db")) return;
68
+ for (const suffix of [
69
+ "",
70
+ "-wal",
71
+ "-shm"
72
+ ]) if (await there(`board.db${suffix}`)) await rename(join(dir, `board.db${suffix}`), join(dir, `local.db${suffix}`));
73
+ if (await there("attachments") && !await there("local")) await rename(join(dir, "attachments"), join(dir, "local"));
74
+ }
75
+ /**
76
+ * A board on this machine, for agents and people sharing one computer: `local()` under `dir`, its
77
+ * log in SQLite, attachments next to it, a scheduler in this process, no sync, on 127.0.0.1 only.
78
+ * Its keys live in memory for this run; it signs one token, for you, into a file only you can read
79
+ * (`localTokenFile`), which `vb` on this machine picks up. `hosts` adds names a proxy in front of
80
+ * it serves it on: a request for one reaches the board at that host's URL, which a token must be
81
+ * minted for there, and your token is for its own. Its server answers the board under `/api/board`,
82
+ * and what `page` is given everywhere else. `tailscale` names the hosts `tailscale serve` is the
83
+ * proxy for: they're allowed like `hosts`, and a request for one with no token is the person
84
+ * Tailscale says sent it (`tailscale()`).
85
+ */
86
+ async function serveLocal(options) {
87
+ const dir = resolve(options.dir);
88
+ await mkdir(dir, {
89
+ recursive: true,
90
+ mode: 448
91
+ });
92
+ quietSqliteWarning();
93
+ await carryOver(dir);
94
+ const backend = local({ dir });
95
+ const { publicKey, privateKey } = await generateKeyPair("ES256");
96
+ const jwks = createLocalJWKSet({ keys: [{
97
+ ...await exportJWK(publicKey),
98
+ kid: "local",
99
+ alg: "ES256"
100
+ }] });
101
+ const tailnet = new Set((options.tailscale ?? []).map((host) => host.toLowerCase()));
102
+ const hosts = /* @__PURE__ */ new Set([...(options.hosts ?? []).map((host) => host.toLowerCase()), ...tailnet]);
103
+ let origin = "";
104
+ let handler = null;
105
+ let page = null;
106
+ const server = createServer((request, response) => {
107
+ if (!handler) return void response.writeHead(503).end();
108
+ if (page && !mounted((request.url ?? "/").split("?")[0])) try {
109
+ return page(request, response);
110
+ } catch {
111
+ if (!response.headersSent) response.writeHead(500);
112
+ response.end();
113
+ return;
114
+ }
115
+ forward(handler, originOf(request, origin, hosts), request, response);
116
+ });
117
+ let port;
118
+ try {
119
+ port = await listen(server, options.port ?? 4100);
120
+ } catch (error) {
121
+ if (error.code === "EADDRINUSE") throw new BoardError("port_taken", `Port ${options.port ?? 4100} is taken. Is a board already running there?`, 0);
122
+ throw error;
123
+ }
124
+ origin = `http://127.0.0.1:${port}`;
125
+ const url = `${origin}${MOUNT}`;
126
+ const tokens = oidcTokens({ local: {
127
+ issuer: ISSUER,
128
+ jwks
129
+ } });
130
+ const team = board({
131
+ backend,
132
+ authenticate: tailnet.size > 0 ? tailscale(tokens, (audience) => servedAt(tailnet, audience)) : tokens,
133
+ basePath: MOUNT
134
+ });
135
+ try {
136
+ await team.channels();
137
+ } catch (error) {
138
+ server.close();
139
+ throw error;
140
+ }
141
+ handler = team.fetch;
142
+ const handle = options.handle ?? localHandle();
143
+ const token = await new SignJWT({}).setProtectedHeader({
144
+ alg: "ES256",
145
+ kid: "local"
146
+ }).setIssuer(ISSUER).setAudience(url).setSubject(handle).setIssuedAt().setExpirationTime("30d").sign(privateKey);
147
+ const file = localTokenFile(url);
148
+ await mkdir(dirname(file), {
149
+ recursive: true,
150
+ mode: 448
151
+ });
152
+ await writeFile(file, JSON.stringify({
153
+ url,
154
+ token,
155
+ handle
156
+ }), { mode: 384 });
157
+ const visitors = /* @__PURE__ */ new Map();
158
+ return {
159
+ url,
160
+ port,
161
+ page(handler) {
162
+ page = handler;
163
+ },
164
+ visitor(request) {
165
+ const at = originOf(request, origin, hosts);
166
+ if (at === origin) return void 0;
167
+ if (!servedAt(tailnet, at)) return tailnet.size > 0 ? null : void 0;
168
+ const login = tailscaleLogin(request.headers["tailscale-user-login"]);
169
+ if (login === null) return null;
170
+ const key = `${at} ${login}`;
171
+ const known = visitors.get(key);
172
+ if (known) return known;
173
+ const client = createBoardClient({
174
+ url: `${at}${MOUNT}`,
175
+ fetch: ((input, init) => {
176
+ const sent = new Request(input, init);
177
+ sent.headers.set("tailscale-user-login", login);
178
+ return team.fetch(sent);
179
+ })
180
+ });
181
+ visitors.set(key, client);
182
+ return client;
183
+ },
184
+ principal: `local:user:${handle}`,
185
+ handle,
186
+ token,
187
+ dir,
188
+ async close() {
189
+ await rm(file, { force: true });
190
+ server.closeAllConnections();
191
+ await new Promise((done) => server.close(() => done()));
192
+ await backend.close();
193
+ }
194
+ };
195
+ }
196
+ /** Node flags `node:sqlite` as experimental on stderr, which would be the CLI's only stderr line. */
197
+ function quietSqliteWarning() {
198
+ const emit = process.emitWarning;
199
+ process.emitWarning = ((warning, ...rest) => {
200
+ const text = typeof warning === "string" ? warning : warning.message;
201
+ if (/SQLite is an experimental feature/.test(text)) return;
202
+ return emit.call(process, warning, ...rest);
203
+ });
204
+ }
205
+ function listen(server, port) {
206
+ return new Promise((done, fail) => {
207
+ server.once("error", fail);
208
+ server.listen(port, "127.0.0.1", () => {
209
+ server.off("error", fail);
210
+ done(server.address().port);
211
+ });
212
+ });
213
+ }
214
+ /**
215
+ * Where a request reached this server: at a host you allowed, over `https` when the proxy in front
216
+ * says so (`X-Forwarded-Proto`), and at the server's `own` address for any other. A request's
217
+ * sender chooses its `Host`, so one you didn't allow never names the board.
218
+ */
219
+ function originOf(request, own, hosts) {
220
+ const host = String(request.headers.host ?? "").toLowerCase();
221
+ if (!hosts.has(host)) return own;
222
+ return `${String(request.headers["x-forwarded-proto"] ?? "").split(",")[0].trim().toLowerCase() === "https" ? "https" : "http"}://${host}`;
223
+ }
224
+ /**
225
+ * Whether `url` is at one of `hosts`, however each was written: a URL leaves its scheme's own port
226
+ * out of its host (`box:443` over https is `box`), so each is compared as that URL would write it.
227
+ */
228
+ function servedAt(hosts, url) {
229
+ const { protocol, host } = new URL(url);
230
+ for (const named of hosts) try {
231
+ if (new URL(`${protocol}//${named}`).host === host) return true;
232
+ } catch {}
233
+ return false;
234
+ }
235
+ async function forward(handler, origin, req, res) {
236
+ const controller = new AbortController();
237
+ res.on("close", () => controller.abort());
238
+ try {
239
+ let body;
240
+ if (req.method !== "GET" && req.method !== "HEAD") {
241
+ const chunks = [];
242
+ let size = 0;
243
+ for await (const chunk of req) {
244
+ size += chunk.length;
245
+ if (size > BODY_MAX) {
246
+ res.writeHead(413, { "content-type": "application/json" });
247
+ res.end(JSON.stringify({ error: {
248
+ code: "too_large",
249
+ message: "request too large"
250
+ } }));
251
+ return;
252
+ }
253
+ chunks.push(chunk);
254
+ }
255
+ body = new Uint8Array(Buffer.concat(chunks));
256
+ }
257
+ const headers = new Headers();
258
+ for (const [key, value] of Object.entries(req.headers)) if (typeof value === "string") headers.set(key, value);
259
+ else if (Array.isArray(value)) for (const item of value) headers.append(key, item);
260
+ const response = await handler(new Request(`${origin}${req.url ?? "/"}`, {
261
+ method: req.method ?? "GET",
262
+ headers,
263
+ ...body && body.length > 0 ? { body } : {},
264
+ signal: controller.signal
265
+ }));
266
+ const out = {};
267
+ response.headers.forEach((value, key) => {
268
+ if (key === "set-cookie") return;
269
+ out[key] = value;
270
+ });
271
+ res.writeHead(response.status, out);
272
+ if (response.body) try {
273
+ for await (const chunk of response.body) res.write(chunk);
274
+ } catch {}
275
+ res.end();
276
+ } catch (error) {
277
+ if (!res.headersSent) res.writeHead(500, { "content-type": "application/json" });
278
+ res.end(JSON.stringify({ error: {
279
+ code: "internal",
280
+ message: error.message
281
+ } }));
282
+ }
283
+ }
284
+ //#endregion
285
+ export { serveLocal };
@@ -1,9 +1,9 @@
1
- import { _ as formatProfileHeader, f as BoardError, p as createBoardClient, t as HttpError } from "./errors-DZ1tbwSM.mjs";
1
+ import { _ as formatProfileHeader, f as BoardError, p as createBoardClient, t as HttpError } from "./errors-QhkdzI-o.mjs";
2
2
  import "./schemas-7VFdomFB.mjs";
3
- import { Y as routes } from "./routes-B2HHHD_C.mjs";
4
- import { g as keyId, p as DERIVED_ID } from "./middleware-BKsTcMAv.mjs";
5
- import { l as METHODS, o as compileWatcher } from "./task-batch-BJcLiYe1.mjs";
6
- import { c as PROTOCOL_ROUTES, d as deployedOnVercel, l as withoutToken, o as createVercel, r as createBoard, u as tailWatchers } from "./exports-DQauuHrc.mjs";
3
+ import { Y as routes } from "./routes-ABXf3CKq.mjs";
4
+ import { g as keyId, p as DERIVED_ID } from "./middleware-CT6vMNUc.mjs";
5
+ import { l as METHODS, o as compileWatcher } from "./task-batch-CmKvTLSu.mjs";
6
+ import { c as PROTOCOL_ROUTES, d as deployedOnVercel, l as withoutToken, o as createVercel, r as createBoard, u as tailWatchers } from "./exports-B5xOYHj_.mjs";
7
7
  import { execFile } from "node:child_process";
8
8
  import { createHash } from "node:crypto";
9
9
  import { mkdir, readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
@@ -177,13 +177,13 @@ const apiLogin = async (handed) => handed ?? await getVercelToken().catch(() =>
177
177
  /**
178
178
  * A person's token: their Vercel CLI login mints a development token for the
179
179
  * project the board's host is a deployment of, exchanged so its audience is the
180
- * board's URL. Cached on disk for its 12-hour life.
180
+ * board's URL. Cached on disk for its 12-hour life. For a board whose discovery
181
+ * names a project: one that names none has no token for a login to mint.
181
182
  */
182
183
  async function personToken(audience, discovery) {
183
184
  const login = await handedToken();
184
185
  const cached = await readCache(audience, login);
185
186
  if (cached) return cached;
186
- if (!discovery.project_id) throw new BoardError("no_project", `The board at ${audience} doesn't know its Vercel project, so there's no Vercel login token to mint for it.`, 0, { hint: "Pass a token it accepts in BOARD_TOKEN." });
187
187
  const authToken = await apiLogin(login);
188
188
  const project = await boardProject(audience, discovery, authToken);
189
189
  let development;
@@ -266,7 +266,9 @@ function boardUrl() {
266
266
  * How a client reaches the board at `url` from Node: through Deployment Protection, with a token
267
267
  * from `token`, `BOARD_TOKEN`, a local board's token file (`vb serve`), GitHub Actions, the Vercel
268
268
  * runtime, or your Vercel CLI login, in that order. Who you are is the token's to say: the board
269
- * names you from what it verifies.
269
+ * names you from what it verifies. A board with no Vercel project has no token for your login to
270
+ * mint, so a request goes to it with none: what verifies its callers may know you another way, as
271
+ * a board behind `tailscale serve` does.
270
272
  */
271
273
  function connect(url, options = {}) {
272
274
  url = url.replace(/\/+$/, "");
@@ -325,6 +327,10 @@ function connect(url, options = {}) {
325
327
  expiresAt: expiry(token)
326
328
  };
327
329
  }
330
+ if (!discovered.project_id) return {
331
+ token: null,
332
+ expiresAt: Date.now() + 3e5
333
+ };
328
334
  person ??= personToken(url, discovered).finally(() => {
329
335
  person = null;
330
336
  });
@@ -341,13 +347,21 @@ function connect(url, options = {}) {
341
347
  const method = (init.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
342
348
  const path = (href.startsWith(url) ? href.slice(url.length) : new URL(href).pathname).split("?")[0] || "/";
343
349
  const headers = new Headers(init.headers ?? (input instanceof Request ? input.headers : void 0));
344
- if (!(method === "GET" && path === "/")) {
345
- if (!headers.has("authorization")) headers.set("authorization", `Bearer ${await token()}`);
350
+ let bare = false;
351
+ if (!(method === "GET" && path === "/") && !headers.has("authorization")) {
352
+ const credential = await token();
353
+ if (credential !== null) headers.set("authorization", `Bearer ${credential}`);
354
+ else bare = true;
346
355
  }
347
- return doFetch(input, {
356
+ const response = await doFetch(input, {
348
357
  ...init,
349
358
  headers
350
359
  });
360
+ if (bare && response.status === 401) {
361
+ await response.body?.cancel().catch(() => {});
362
+ throw new BoardError("no_project", `The board at ${url} has no Vercel project to mint you a token for, and doesn't know who you are without one.`, 0, { hint: "Pass a token it accepts in BOARD_TOKEN." });
363
+ }
364
+ return response;
351
365
  });
352
366
  return {
353
367
  fetch: send,
@@ -848,6 +862,7 @@ function createHttp(url, options, environment) {
848
862
  ...methods,
849
863
  routes: [],
850
864
  keeps: false,
865
+ settlesMentions: true,
851
866
  async sandbox({ profile, can, token }) {
852
867
  const credential = environment ? await environment.sandbox(remote, token) : token === void 0 ? withoutToken(remote) : { authorization: `Bearer ${token}` };
853
868
  return {
@@ -901,13 +916,17 @@ function http(url, options = {}) {
901
916
  //#region src/backend-vercel/index.ts
902
917
  /** On Vercel, or with its OIDC token pulled (`vercel env pull`): a deployment acts as its project. */
903
918
  const deployed = () => process.env.VERCEL === "1" || !!process.env.VERCEL_OIDC_TOKEN;
919
+ /** Off a deployment, a credential Vercel's API takes, set for board: what a sandbox or CI passes. */
920
+ const boardToken = () => deployed() ? null : process.env.BOARD_TOKEN || null;
904
921
  /**
905
- * A token Vercel's API takes: `VERCEL_TOKEN`, this deployment's OIDC token, or your Vercel login,
906
- * the one the CLI that runs board's hands it (`vercel board`'s) or your `vercel login`.
922
+ * A token Vercel's API takes: this deployment's OIDC token, or else `BOARD_TOKEN`, or your Vercel
923
+ * login, the one the CLI that runs board's hands it (`vercel board`'s, or `VERCEL_AUTH_TOKEN`) or
924
+ * your `vercel login`.
907
925
  */
908
926
  async function token() {
909
- if (process.env.VERCEL_TOKEN) return process.env.VERCEL_TOKEN;
910
927
  if (deployed()) return getVercelOidcToken();
928
+ const set = boardToken();
929
+ if (set) return set;
911
930
  return vercelLogin().catch(() => {
912
931
  throw new HttpError(401, "not_logged_in", "You're not logged in to Vercel.", {
913
932
  hint: "Run vercel login.",
@@ -917,8 +936,8 @@ async function token() {
917
936
  }
918
937
  /** Where `token` comes from, in words: what `vb whoami` says. */
919
938
  function credentialSource() {
920
- if (process.env.VERCEL_TOKEN) return "VERCEL_TOKEN";
921
939
  if (deployed()) return "Vercel OIDC";
940
+ if (boardToken()) return "BOARD_TOKEN";
922
941
  return loginHanded() ? "the Vercel CLI" : "vercel login";
923
942
  }
924
943
  /** The team a CLI that runs board's resolves itself (`vercel board`'s), while one does. */
@@ -942,7 +961,7 @@ async function team() {
942
961
  throw new HttpError(502, "no_team", error instanceof Error ? error.message : String(error), { origin: "handle" });
943
962
  }
944
963
  if (process.env.VERCEL_ORG_ID) return process.env.VERCEL_ORG_ID;
945
- if (!process.env.VERCEL_TOKEN && deployed()) try {
964
+ if (deployed()) try {
946
965
  const owner = decodeJwt(await getVercelOidcToken()).owner_id;
947
966
  if (typeof owner === "string") return owner;
948
967
  } catch {}
@@ -957,7 +976,7 @@ async function team() {
957
976
  const environment = {
958
977
  fetch: () => async (input, init = {}) => {
959
978
  const credential = await token();
960
- if (!process.env.VERCEL_TOKEN && !deployed()) return asYou(input, init, credential);
979
+ if (!deployed() && !boardToken()) return asYou(input, init, credential);
961
980
  const headers = new Headers(init.headers);
962
981
  headers.set("authorization", `Bearer ${credential}`);
963
982
  return globalThis.fetch(input, {
@@ -989,8 +1008,8 @@ function vercel(options = {}) {
989
1008
  function board(options = {}) {
990
1009
  return createBoard(options, {
991
1010
  backend: (fetch) => process.env.BOARD_URL?.trim() ? http() : vercel(fetch ? { fetch } : {}),
992
- sync: () => import("./engine-C_SlBihU.mjs"),
993
- serving: () => import("./serving-9riPNrHk.mjs"),
1011
+ sync: () => import("./engine-B3Yd0OPc.mjs"),
1012
+ serving: () => import("./serving-BNdiReQT.mjs"),
994
1013
  sandbox: (url, token) => sandboxHeaders(url, url, token)
995
1014
  });
996
1015
  }
@@ -1,2 +1,2 @@
1
- import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-DPKF_cb5.mjs";
1
+ import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-BCp4EWTQ.mjs";
2
2
  export { discoveryIdentity, oidcTokens, ownProjectId, ownTeamId };
@@ -1,7 +1,7 @@
1
1
  import { k as actorKind, w as TASK_LABEL } from "./schemas-7VFdomFB.mjs";
2
- import { c as externalMessageKey, l as isThreadTarget } from "./external-BVr1Sq0y.mjs";
2
+ import { c as externalMessageKey, l as isThreadTarget } from "./external-BuVTXT1R.mjs";
3
3
  import { t as canonicalEmoji } from "./emoji-CTLpvH-A.mjs";
4
- import { i as mentionTerms } from "./mentions-DfZGp3B-.mjs";
4
+ import { i as mentionTerms } from "./mentions-CnWt9Z5b.mjs";
5
5
  import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
6
6
  //#region src/contract/folds.ts
7
7
  const iso = (date) => typeof date === "string" ? date : date.toISOString();
@@ -1,6 +1,6 @@
1
- import { r as sqlTables } from "./sql-Bml29DpM.mjs";
1
+ import { r as sqlTables } from "./sql-IEbO5vXs.mjs";
2
2
  import { t as sqlite$1 } from "./store-sqlite-D6fIszST.mjs";
3
- import { t as sqliteDb } from "./sqlite-db-eVb9v3zc.mjs";
3
+ import { t as sqliteDb } from "./sqlite-db-BJjPQYx4.mjs";
4
4
  //#region src/store/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-Bml29DpM.mjs";
1
+ import { n as ddl } from "./sql-IEbO5vXs.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-D3bfHRHA.mjs";
2
- import { r as ChatTransport, t as ChatInput } from "./chat-provider-Bn33acHd.mjs";
1
+ import { _ as SyncFn, m as SyncProvider, x as channels } from "./provider-DC3WHUXo.mjs";
2
+ import { r as ChatTransport, t as ChatInput } from "./chat-provider-iN0DFsSE.mjs";
3
3
  import { z } from "zod";
4
4
  import { ReactionEvent } from "chat";
5
5
  //#region src/sync/chat-sdk.d.ts
@@ -46,6 +46,13 @@ declare const schemaOf: <P extends string>(platform: P) => z.ZodDiscriminatedUni
46
46
  }, z.core.$strip>>;
47
47
  }, z.core.$strip>>;
48
48
  }, z.core.$strip>>>;
49
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
50
+ id: z.ZodString;
51
+ handle: z.ZodString;
52
+ name: z.ZodString;
53
+ avatar: z.ZodNullable<z.ZodString>;
54
+ isBot: z.ZodBoolean;
55
+ }, z.core.$strip>>>;
49
56
  id: z.ZodString;
50
57
  key: z.ZodString;
51
58
  raw: z.ZodUnknown;
@@ -80,6 +87,13 @@ declare const schemaOf: <P extends string>(platform: P) => z.ZodDiscriminatedUni
80
87
  }, z.core.$strip>>;
81
88
  }, z.core.$strip>>>;
82
89
  linksOnly: z.ZodOptional<z.ZodBoolean>;
90
+ mentioned: z.ZodOptional<z.ZodArray<z.ZodObject<{
91
+ id: z.ZodString;
92
+ handle: z.ZodString;
93
+ name: z.ZodString;
94
+ avatar: z.ZodNullable<z.ZodString>;
95
+ isBot: z.ZodBoolean;
96
+ }, z.core.$strip>>>;
83
97
  id: z.ZodString;
84
98
  key: z.ZodString;
85
99
  raw: z.ZodUnknown;
@@ -1,5 +1,5 @@
1
- import { i as eventSchema, p as channels, r as envelope } from "./events-mGuhF4i5.mjs";
2
- import { t as ChatSyncProvider } from "./chat-provider-1zpY6Qo_.mjs";
1
+ import { i as eventSchema, p as channels, r as envelope } from "./events-B-qyxNsJ.mjs";
2
+ import { t as ChatSyncProvider } from "./chat-provider-kNWd6MQC.mjs";
3
3
  import { createHash } from "node:crypto";
4
4
  //#region src/sync/chat-sdk.ts
5
5
  const schemaOf = (platform) => eventSchema(platform, "message");