@vercel/board 0.48.1 → 0.50.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 (87) hide show
  1. package/dist/{access-C06pIr0M.mjs → access-BbgmsAFF.mjs} +29 -17
  2. package/dist/access.d.mts +2 -2
  3. package/dist/access.mjs +5 -5
  4. package/dist/{actors-Dkyg-oo0.mjs → actors-CX2D22hL.mjs} +4 -3
  5. package/dist/{auth-B9-wXQ-x.mjs → auth-DJDTfgAL.mjs} +2 -2
  6. package/dist/{auth-li3lKwJG.d.mts → auth-Z9-Khvvw.d.mts} +1 -1
  7. package/dist/{backend-UBP6HimX.d.mts → backend-CcaaS9Xl.d.mts} +31 -8
  8. package/dist/backend-local.d.mts +1 -1
  9. package/dist/backend-local.mjs +1 -1
  10. package/dist/{chat-provider-iN0DFsSE.d.mts → chat-provider-DQ1GHm4o.d.mts} +2 -2
  11. package/dist/{chat-provider-kNWd6MQC.mjs → chat-provider-HJ7y_ipp.mjs} +2 -2
  12. package/dist/cli-commands.d.mts +1 -1
  13. package/dist/cli-commands.mjs +1 -1
  14. package/dist/cli-embedded.d.mts +8 -2
  15. package/dist/cli-embedded.mjs +10 -4
  16. package/dist/cli.mjs +6 -6
  17. package/dist/client-C2T4eaXd.d.mts +544 -0
  18. package/dist/{commands-CJsOA-hf.d.mts → commands-Cm4sODIu.d.mts} +12 -8
  19. package/dist/{commands-Dk6_cHLS.mjs → commands-nN8WpvCe.mjs} +75 -58
  20. package/dist/{conformance-CDP8y2Zm.mjs → conformance-Cr-umDl0.mjs} +102 -20
  21. package/dist/conformance.d.mts +1 -1
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{engine-BQ0hJw2w.mjs → engine-DJZ8Xy_g.mjs} +10 -7
  24. package/dist/{errors-QhkdzI-o.mjs → errors-DYF4hhIc.mjs} +53 -174
  25. package/dist/{events-B-qyxNsJ.mjs → events-BdOCmnZh.mjs} +3 -3
  26. package/dist/{exports-BzSG0_wL.mjs → exports-CuD-Mxkw.mjs} +389 -118
  27. package/dist/{exports-inhbjAWi.d.mts → exports-lmr6UHHc.d.mts} +4 -4
  28. package/dist/{external-BuVTXT1R.mjs → external-D2jq_DEQ.mjs} +1 -1
  29. package/dist/{index-B0Fnhvk7.d.mts → index-_KxJu15n.d.mts} +2 -2
  30. package/dist/index.d.mts +6 -6
  31. package/dist/index.mjs +4 -4
  32. package/dist/index.node.d.mts +7 -7
  33. package/dist/index.node.mjs +4 -4
  34. package/dist/inspect/app.js +39 -39
  35. package/dist/inspect/engine.js +3 -3
  36. package/dist/inspect-CZeoSm7E.mjs +272 -0
  37. package/dist/inspect-UCcPViyA.mjs +2 -0
  38. package/dist/inspect.d.mts +17 -0
  39. package/dist/inspect.mjs +196 -0
  40. package/dist/{local-BdKxz-Dn.mjs → local-BVSFSSYf.mjs} +165 -61
  41. package/dist/{main-BgiViRZ8.mjs → main-B016auoG.mjs} +227 -49
  42. package/dist/{memory-CMm-Fk_A.mjs → memory-C2lzMV_t.mjs} +2 -2
  43. package/dist/{middleware-CT6vMNUc.mjs → middleware-DUKIITFZ.mjs} +3 -3
  44. package/dist/{page-D-OzDOAX.mjs → page-7KWSGxyC.mjs} +12 -2
  45. package/dist/page-CN77B014.mjs +2 -0
  46. package/dist/profile-header-Cj0Cb1cf.mjs +163 -0
  47. package/dist/{provider-DC3WHUXo.d.mts → provider-Dwb_9mnu.d.mts} +3 -529
  48. package/dist/{routes-CjA6Mp4D.d.mts → routes-B6SEA9yw.d.mts} +130 -4
  49. package/dist/{routes-ABXf3CKq.mjs → routes-BE0y6wCk.mjs} +40 -14
  50. package/dist/{schemas-7VFdomFB.mjs → schemas-CUSTEFIy.mjs} +11 -3
  51. package/dist/{serve-C2Jbr7pR.mjs → serve-B10e7QaY.mjs} +5 -5
  52. package/dist/{server-EOQC5Gtq.mjs → server-ViWNvg5q.mjs} +61 -29
  53. package/dist/{serving-BNdiReQT.mjs → serving-SbqeWqlA.mjs} +1 -1
  54. package/dist/{inspect-n9brh-TT.mjs → shell-DmpmgOPC.mjs} +25 -274
  55. package/dist/{sql-IEbO5vXs.mjs → sql-iABdyCiz.mjs} +18 -5
  56. package/dist/{sqlite-CVG8XKHm.mjs → sqlite-28EMrmk7.mjs} +2 -2
  57. package/dist/{sqlite-db-BJjPQYx4.mjs → sqlite-db-Ckd-ceNe.mjs} +1 -1
  58. package/dist/sync-chat-sdk.d.mts +2 -2
  59. package/dist/sync-chat-sdk.mjs +2 -2
  60. package/dist/sync-github.d.mts +2 -2
  61. package/dist/sync-github.mjs +3 -3
  62. package/dist/sync-linear.d.mts +3 -3
  63. package/dist/sync-linear.mjs +3 -3
  64. package/dist/sync-slack.d.mts +3 -3
  65. package/dist/sync-slack.mjs +11 -7
  66. package/dist/sync.d.mts +2 -2
  67. package/dist/sync.mjs +2 -2
  68. package/dist/{tags-BpFo6q0_.mjs → tags-D0qra0Qy.mjs} +1 -1
  69. package/dist/{task-batch-D4p9N8lN.mjs → task-batch-9lVDG3d-.mjs} +10 -11
  70. package/dist/{tokens-BCp4EWTQ.mjs → tokens-C-iK0Cku.mjs} +2 -2
  71. package/dist/version-C70RLVEK.mjs +5 -0
  72. package/docs/01-board/01-mounting.md +8 -0
  73. package/docs/01-board/03-identity.md +3 -2
  74. package/docs/01-board/04-messages.md +6 -2
  75. package/docs/01-board/05-reading.md +17 -2
  76. package/docs/01-board/09-access.md +40 -6
  77. package/docs/01-board/11-tasks.md +3 -3
  78. package/docs/02-sync/01-overview.md +2 -1
  79. package/docs/03-guides/02-inspector.md +31 -0
  80. package/docs/03-guides/06-sandboxed-agents.md +22 -21
  81. package/docs/04-reference/01-cli.md +91 -33
  82. package/docs/04-reference/02-board.md +20 -7
  83. package/docs/04-reference/03-http.md +9 -6
  84. package/docs/04-reference/05-conformance.md +7 -0
  85. package/package.json +5 -1
  86. package/dist/inspect-BB-XUPuz.mjs +0 -2
  87. package/dist/page-Dr9Aqlej.mjs +0 -2
@@ -1,9 +1,4 @@
1
- import { g as InvalidProfileHeader, v as parseProfileHeader, y as ATTACHMENT_BYTES_MAX } from "./errors-QhkdzI-o.mjs";
2
- import "./schemas-7VFdomFB.mjs";
3
- import { t as Failed, u as who } from "./main-BgiViRZ8.mjs";
4
- import { t as page } from "./page-D-OzDOAX.mjs";
5
- import { randomBytes, timingSafeEqual } from "node:crypto";
6
- import { createServer } from "node:http";
1
+ import { t as VERSION } from "./version-C70RLVEK.mjs";
7
2
  //#region src/inspect/style.ts
8
3
  /**
9
4
  * Just Chat's look: mono, quiet, one accent, hairlines only under headers.
@@ -65,6 +60,10 @@ a:focus-visible, button:focus-visible, [role='separator']:focus-visible { outlin
65
60
 
66
61
  .boot { display: grid; place-items: center; height: 100dvh; color: var(--faint); }
67
62
  .boot.error, .error { color: var(--red); }
63
+ .name-gate { display: grid; gap: 10px; width: min(320px, 90vw); color: var(--bright); }
64
+ .name-gate p { margin: 0; color: var(--faint); }
65
+ .name-gate input { width: 100%; height: 36px; padding: 0 10px; border: 0; outline: 1px solid var(--muted); background: var(--shade); font-size: 16px; }
66
+ .name-gate .send { justify-self: end; }
68
67
  .empty, .error { padding: 20px; margin: 0; color: var(--faint); }
69
68
  .faint { color: var(--faint); }
70
69
  .grow { flex: 1; min-width: 0; }
@@ -632,31 +631,28 @@ button.file:hover { background: var(--shade-hover); color: var(--bright); }
632
631
  input, textarea, select { font-size: 16px !important; }
633
632
  }
634
633
  `;
635
- /** What a proxy adds to a request it forwards: Tailscale's sets `X-Forwarded-Host`, most others `X-Forwarded-For`. */
636
- const FORWARDED = [
637
- "forwarded",
638
- "x-forwarded-for",
639
- "x-forwarded-host",
640
- "x-forwarded-proto",
641
- "x-real-ip"
642
- ];
643
- /** The prebuilt UI where board is installed, read only when an inspector starts without one. */
644
- const bundle = async () => (await import("./page-Dr9Aqlej.mjs")).page();
634
+ //#endregion
635
+ //#region src/inspect/shell.ts
645
636
  const attribute = (value) => value.replace(/[&<>"']/g, (char) => `&#${char.charCodeAt(0)};`);
646
- /** The page, with what only this run's page is told: its token for the proxy, and the profile inspect started as. */
647
- const shell = (token, profile) => `<!doctype html>
637
+ /**
638
+ * The page, with what only it is told: its credential for the proxy, the profile it starts as, and
639
+ * the path it's served under (`''` at a server's root), which its bundle, its proxy, and its links
640
+ * are under too.
641
+ */
642
+ const shell = ({ token, profile, base, named = false }) => `<!doctype html>
648
643
  <html lang="en">
649
644
  <head>
650
645
  <meta charset="utf-8">
651
646
  <meta name="viewport" content="width=device-width, initial-scale=1">
652
- <meta name="inspect-token" content="${token}">
647
+ <meta name="inspect-token" content="${attribute(token)}">
653
648
  <meta name="inspect-profile" content="${attribute(JSON.stringify(profile))}">
654
- <title>board</title>
649
+ <meta name="inspect-base" content="${attribute(base)}">
650
+ ${named ? "<meta name=\"inspect-named\" content=\"1\">\n" : ""}<title>board</title>
655
651
  <style>${CSS}</style>
656
652
  </head>
657
653
  <body>
658
654
  <div id="root"></div>
659
- <script type="module" src="/app.js"><\/script>
655
+ <script type="module" src="${attribute(base)}/app.js?v=${attribute(VERSION)}"><\/script>
660
656
  </body>
661
657
  </html>`;
662
658
  const CSP = [
@@ -670,260 +666,15 @@ const CSP = [
670
666
  "base-uri 'none'",
671
667
  "frame-ancestors 'none'"
672
668
  ].join("; ");
673
- /**
674
- * The UI, and a proxy for the board's API that adds your credentials, for a server
675
- * on 127.0.0.1 to answer with. Because the proxy acts as you, it answers only its
676
- * own page: every request must name the server's host (no DNS rebinding) and carry
677
- * the per-run token that only the page has, and writes must also come from its
678
- * origin. Your credential for the board never leaves this process. `hosts` adds
679
- * names a proxy in front of it serves the page on: whoever reaches the page there
680
- * acts as you, unless `visitor` says who a request is: a client that acts as them,
681
- * or null for one it can't name, which the proxy then refuses. A request a proxy
682
- * forwarded must name one of them: the server's own name is this machine's alone,
683
- * and a caller behind a proxy can send it too.
684
- */
685
- async function createInspector(options) {
686
- const { client } = options;
687
- const me = await client.me();
688
- const started = me.profile === null ? null : me.avatar ? {
689
- name: me.profile,
690
- avatar: me.avatar
691
- } : me.profile;
692
- const board = (await client.discovery().catch(() => null))?.url ?? client.url;
693
- const app = options.page ?? await bundle();
694
- const token = randomBytes(24).toString("base64url");
695
- const allowed = new Set((options.hosts ?? []).map((host) => host.toLowerCase()));
696
- let hosts = /* @__PURE__ */ new Set();
697
- let proxied = /* @__PURE__ */ new Set();
698
- let origins = /* @__PURE__ */ new Set();
699
- const streams = /* @__PURE__ */ new Set();
700
- async function proxy(request, response, url) {
701
- const reading = request.method === "GET" || request.method === "HEAD";
702
- if (!sameSecret(String(request.headers["x-inspect-token"] ?? ""), token) || !reading && !origins.has(String(request.headers.origin))) return json(response, 403, { error: {
703
- code: "forbidden",
704
- message: "the board is reachable only from the inspector's own page"
705
- } });
706
- const path = url.pathname.slice(6) || "/";
707
- let decoded;
708
- try {
709
- decoded = decodeURIComponent(path);
710
- } catch {
711
- decoded = "..";
712
- }
713
- if (/(^|\/)\.\.?(\/|$)|\\/.test(decoded)) return json(response, 400, { error: {
714
- code: "bad_path",
715
- message: "no relative paths"
716
- } });
717
- const visiting = options.visitor?.(request);
718
- if (visiting === null) return json(response, 401, { error: {
719
- code: "unauthorized",
720
- message: "the proxy in front of this page names no one for this request, so there's no one to act as"
721
- } });
722
- const acting = visiting ?? client;
723
- const controller = new AbortController();
724
- streams.add(controller);
725
- response.on("close", () => controller.abort());
726
- try {
727
- const body = reading ? void 0 : await read(request, path === "/attachments" ? ATTACHMENT_BYTES_MAX : void 0);
728
- let as = null;
729
- const named = request.headers["x-board-profile"];
730
- if (typeof named === "string" && named.trim() !== "") try {
731
- const { name, avatar } = parseProfileHeader(named);
732
- as = avatar === null ? name : {
733
- name,
734
- avatar
735
- };
736
- } catch (error) {
737
- if (!(error instanceof InvalidProfileHeader)) throw error;
738
- return json(response, 400, { error: {
739
- code: "invalid_profile",
740
- message: error.message
741
- } });
742
- }
743
- const upstream = await acting.request(`${path}${url.search}`, {
744
- as,
745
- method: request.method ?? "GET",
746
- headers: {
747
- ...request.headers["content-type"] ? { "content-type": String(request.headers["content-type"]) } : {},
748
- ...request.headers.accept ? { accept: String(request.headers.accept) } : {},
749
- ...request.headers["x-board-filename"] ? { "x-board-filename": String(request.headers["x-board-filename"]) } : {}
750
- },
751
- ...body ? { body } : {},
752
- signal: controller.signal
753
- });
754
- response.writeHead(upstream.status, {
755
- "content-type": upstream.headers.get("content-type") ?? "application/json",
756
- "cache-control": "no-store",
757
- "x-content-type-options": "nosniff"
758
- });
759
- if (upstream.body) for await (const chunk of upstream.body) response.write(chunk);
760
- response.end();
761
- } catch (error) {
762
- if (controller.signal.aborted || response.headersSent) return void response.end();
763
- json(response, 502, { error: {
764
- code: "unreachable",
765
- message: `the board didn't answer: ${error.message}`
766
- } });
767
- } finally {
768
- streams.delete(controller);
769
- }
770
- }
771
- function handle(request, response) {
772
- let url;
773
- try {
774
- url = new URL(request.url ?? "/", "http://inspector");
775
- } catch {
776
- return send(response, 400, "text/plain; charset=utf-8", "bad request");
777
- }
778
- const named = String(request.headers.host).toLowerCase();
779
- if (!(FORWARDED.some((header) => request.headers[header] !== void 0) ? proxied : hosts).has(named)) return send(response, 421, "text/plain; charset=utf-8", "wrong host");
780
- if (url.pathname === "/board" || url.pathname.startsWith("/board/")) return void proxy(request, response, url).catch(() => response.headersSent ? response.end() : send(response, 500, "text/plain; charset=utf-8", "error"));
781
- if (request.method !== "GET") return send(response, 405, "text/plain; charset=utf-8", "method not allowed");
782
- if (url.pathname === "/app.js") return app ? send(response, 200, "text/javascript; charset=utf-8", app) : send(response, 503, "text/plain; charset=utf-8", "the inspector's UI isn't built: run `pnpm --filter @vercel/board build`");
783
- send(response, 200, "text/html; charset=utf-8", shell(token, started), { "content-security-policy": CSP });
784
- }
785
- return {
786
- board,
787
- me,
788
- at(port) {
789
- const own = [`127.0.0.1:${port}`, `localhost:${port}`];
790
- hosts = /* @__PURE__ */ new Set([...own, ...allowed]);
791
- proxied = new Set([...allowed].filter((host) => !own.includes(host)));
792
- origins = /* @__PURE__ */ new Set([
793
- `http://127.0.0.1:${port}`,
794
- `http://localhost:${port}`,
795
- ...[...allowed].flatMap((host) => [`http://${host}`, `https://${host}`])
796
- ]);
797
- return {
798
- handle,
799
- close() {
800
- for (const stream of streams) stream.abort();
801
- }
802
- };
803
- }
804
- };
805
- }
806
- /** The inspector on a server of its own, on 127.0.0.1: `port`, or 4747, or any free one when that's taken. */
807
- async function startInspector(options) {
808
- const inspector = await createInspector(options);
809
- let page = null;
810
- const server = createServer((request, response) => page ? page.handle(request, response) : void response.writeHead(503).end());
811
- const port = await listen(server, options.port ?? 4747, options.port === void 0);
812
- const serving = page = inspector.at(port);
813
- return {
814
- url: `http://127.0.0.1:${port}`,
815
- board: inspector.board,
816
- me: inspector.me,
817
- close: () => new Promise((resolve) => {
818
- serving.close();
819
- server.close(() => resolve());
820
- server.closeAllConnections();
821
- })
822
- };
823
- }
824
- function sameSecret(given, expected) {
825
- const a = Buffer.from(given);
826
- const b = Buffer.from(expected);
827
- return a.length === b.length && timingSafeEqual(a, b);
828
- }
829
- function read(request, limit = 1048576) {
830
- return new Promise((resolve, reject) => {
831
- let size = 0;
832
- const chunks = [];
833
- request.on("data", (chunk) => {
834
- size += chunk.length;
835
- if (size > limit) {
836
- reject(/* @__PURE__ */ new Error("request too large"));
837
- request.destroy();
838
- } else chunks.push(chunk);
839
- });
840
- request.on("end", () => resolve(new Uint8Array(Buffer.concat(chunks))));
841
- request.on("error", reject);
842
- });
843
- }
844
- function send(response, status, type, body, headers = {}) {
845
- response.writeHead(status, {
846
- "content-type": type,
847
- "cache-control": "no-store",
848
- "x-content-type-options": "nosniff",
849
- "referrer-policy": "no-referrer",
850
- ...headers
851
- });
852
- response.end(body);
853
- }
854
- const json = (response, status, body) => send(response, status, "application/json", JSON.stringify(body));
855
- /** Listens on the port, or any free one when the default port is taken. */
856
- async function listen(server, port, fallback) {
669
+ /** Whether a proxied path, as sent, climbs out of the board's API: `..`, `.`, or a backslash, encoded or not. */
670
+ function relative(path) {
671
+ let decoded;
857
672
  try {
858
- return await listenOn(server, port);
859
- } catch (error) {
860
- if (fallback && error.code === "EADDRINUSE") return listenOn(server, 0);
861
- throw error;
673
+ decoded = decodeURIComponent(path);
674
+ } catch {
675
+ return true;
862
676
  }
863
- }
864
- function listenOn(server, port) {
865
- return new Promise((resolve, reject) => {
866
- const onError = (error) => {
867
- server.off("listening", onListening);
868
- reject(error);
869
- };
870
- const onListening = () => {
871
- server.off("error", onError);
872
- resolve(server.address().port);
873
- };
874
- server.once("error", onError);
875
- server.once("listening", onListening);
876
- server.listen(port, "127.0.0.1");
877
- });
878
- }
879
- //#endregion
880
- //#region src/cli/inspect.ts
881
- /** Until Ctrl-C or a SIGTERM, whichever comes first: then neither is listened for. */
882
- const stopped = () => new Promise((resolve) => {
883
- const done = () => {
884
- process.off("SIGINT", done);
885
- process.off("SIGTERM", done);
886
- resolve();
887
- };
888
- process.once("SIGINT", done);
889
- process.once("SIGTERM", done);
890
- });
891
- /** The page to serve, before anything starts: an install without one says so, and serves nothing. */
892
- async function pageOf() {
893
- const found = await page();
894
- if (found === null) throw new Failed({
895
- class: "unknown",
896
- reason: "no_inspector_page",
897
- message: "The inspector's page isn't installed with this CLI.",
898
- next: [{ instruction: "Reinstall or update the CLI" }]
899
- });
900
- return found;
901
- }
902
- /** The hosts `--allow-host`, or `--tailscale`, names: each a host, with its port when that isn't its scheme's default. */
903
- function allowedHosts({ flags, usage }, flag = "allow-host") {
904
- const hosts = flags[flag] ?? [];
905
- const bad = hosts.find((host) => !/^[a-z0-9.-]+(:\d+)?$/i.test(host));
906
- if (bad !== void 0) throw usage(`--${flag} takes a host, with a port if it isn't the default, like box.tailnet.ts.net: not ${bad}.`);
907
- return [...new Set(hosts.flatMap((host) => [host, host.replace(/:(443|80)$/, "")]))];
908
- }
909
- async function inspect({ flags, out, usage, portFlag, client, openBrowser }) {
910
- const port = portFlag();
911
- const hosts = allowedHosts({
912
- flags,
913
- usage
914
- });
915
- const page = await pageOf();
916
- const inspector = await startInspector({
917
- client: client(),
918
- page,
919
- hosts,
920
- ...port !== void 0 ? { port } : {}
921
- });
922
- out(`inspecting ${inspector.board} as ${who(inspector.me)} at ${inspector.url} (Ctrl-C to stop)`);
923
- if (!flags["no-open"]) openBrowser(inspector.url);
924
- await stopped();
925
- await inspector.close();
926
- return 0;
677
+ return /(^|\/)\.\.?(\/|$)|\\/.test(decoded);
927
678
  }
928
679
  //#endregion
929
- export { createInspector as i, inspect as n, stopped as r, allowedHosts as t };
680
+ export { relative as n, shell as r, CSP as t };
@@ -1,5 +1,5 @@
1
- import { k as actorKind, w as TASK_LABEL } from "./schemas-7VFdomFB.mjs";
2
- import { c as externalMessageKey, l as isThreadTarget } from "./external-BuVTXT1R.mjs";
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";
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-IEbO5vXs.mjs";
1
+ import { r as sqlTables } from "./sql-iABdyCiz.mjs";
2
2
  import { t as sqlite$1 } from "./store-sqlite-D6fIszST.mjs";
3
- import { t as sqliteDb } from "./sqlite-db-BJjPQYx4.mjs";
3
+ import { t as sqliteDb } from "./sqlite-db-Ckd-ceNe.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-IEbO5vXs.mjs";
1
+ import { n as ddl } from "./sql-iABdyCiz.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-DC3WHUXo.mjs";
2
- import { r as ChatTransport, t as ChatInput } from "./chat-provider-iN0DFsSE.mjs";
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";
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-B-qyxNsJ.mjs";
2
- import { t as ChatSyncProvider } from "./chat-provider-kNWd6MQC.mjs";
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";
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-DC3WHUXo.mjs";
2
- import { n as ChatSyncProvider } from "./chat-provider-iN0DFsSE.mjs";
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";
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-B-qyxNsJ.mjs";
2
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-kNWd6MQC.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-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";
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 { Ot as SourceRead } from "./routes-CjA6Mp4D.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-DC3WHUXo.mjs";
3
- import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-iN0DFsSE.mjs";
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";
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-B-qyxNsJ.mjs";
2
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-kNWd6MQC.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-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";
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 { Nn as ExternalLink } from "./routes-CjA6Mp4D.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-DC3WHUXo.mjs";
3
- import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-iN0DFsSE.mjs";
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";
4
4
  import { z } from "zod";
5
5
  import { Adapter } from "chat";
6
6
  //#region src/sync/slack-deployments.d.ts
@@ -1,8 +1,8 @@
1
- import { m as MESSAGE_TEXT_MAX } from "./schemas-7VFdomFB.mjs";
2
- import "./external-BuVTXT1R.mjs";
1
+ import { m as MESSAGE_TEXT_MAX } from "./schemas-CUSTEFIy.mjs";
2
+ import "./external-D2jq_DEQ.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-B-qyxNsJ.mjs";
5
- import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-kNWd6MQC.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";
6
6
  import { r as formatVercelDeployments } from "./bots-CqPYxkqK.mjs";
7
7
  import { z } from "zod";
8
8
  import { stringifyMarkdown } from "chat";
@@ -123,11 +123,15 @@ const MENTIONED = /@\uF8F0([A-Z0-9_]+)\uF8F1/g;
123
123
  const mentionedAs = (user) => `\uF8F0${user}\uF8F1`;
124
124
  /** A user's mention in Slack's own mrkdwn, with the name Slack may give it: `<@U0456>`, `<@U0456|ada>`. */
125
125
  const SLACK_MENTION = /<@([A-Z0-9_]+)(?:\|[^<>]*)?>/g;
126
- /** A Slack user's ID, as `<@U0456>` names one. */
127
- const SLACK_USER_ID = /^[A-Z0-9_]+$/;
126
+ /**
127
+ * A Slack user's ID, as `<@U0456>` names one: `U…`, or `W…` on Enterprise Grid. A bot's own ID
128
+ * (`B…`, the author of an app's messages) isn't one, and Slack shows `<@B0456>` as it's written.
129
+ */
130
+ const SLACK_USER_ID = /^[UW][A-Z0-9_]+$/;
128
131
  /**
129
132
  * A Slack user as Slack mentions them, from their ID alone. Only a user's ID: anything else between
130
- * `<@` and `>` could close the mention and open Slack's own markup (`<!channel>`).
133
+ * `<@` and `>` could close the mention and open Slack's own markup (`<!channel>`), and a bot's ID
134
+ * shows as markup, so the mention stays text.
131
135
  */
132
136
  function slackMention(id) {
133
137
  const user = id.startsWith("slack:user:") ? id.slice(11) : null;
package/dist/sync.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { An as ExternalAuthor, Mn as ExternalFile, jn as ExternalEvent } from "./routes-CjA6Mp4D.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-DC3WHUXo.mjs";
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";
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-BuVTXT1R.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-B-qyxNsJ.mjs";
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";
3
3
  export { EventBase, ExternalEvent, ReceivedEvent, ResolvedTarget, SyncOverrides, SyncProvider, UnreadableError, channels, envelope, eventSchema, into, mirror, render };
@@ -8,7 +8,7 @@ const slug = (name) => name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").to
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,14 +1,12 @@
1
- import { r as badRequest, t as HttpError, y as ATTACHMENT_BYTES_MAX } from "./errors-QhkdzI-o.mjs";
2
- import "./schemas-7VFdomFB.mjs";
3
- import { l as isThreadTarget } from "./external-BuVTXT1R.mjs";
4
- import { Y as routes, _ as Filters } from "./routes-ABXf3CKq.mjs";
5
- import { i as afterRetry } from "./middleware-CT6vMNUc.mjs";
6
- import { o as options } from "./commands-Dk6_cHLS.mjs";
1
+ import { i as ATTACHMENT_BYTES_MAX } from "./profile-header-Cj0Cb1cf.mjs";
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";
7
9
  import { z } from "zod";
8
- //#endregion
9
- //#region src/version.ts
10
- const VERSION = "0.48.1";
11
- //#endregion
12
10
  //#region src/server/backend.ts
13
11
  /** The subscription sync's outbound runs on, in `BoardBinding.subscriptions`. No watcher's ID starts with `@`. */
14
12
  const SYNC = "@sync";
@@ -58,6 +56,7 @@ const METHODS = [
58
56
  "cancelTask",
59
57
  "grants",
60
58
  "createGrant",
59
+ "createGrants",
61
60
  "updateGrant",
62
61
  "explain",
63
62
  "revokeGrant",
@@ -500,4 +499,4 @@ function batchPlan(tasks) {
500
499
  };
501
500
  }
502
501
  //#endregion
503
- export { runMatch as a, withMentions as c, openapi as d, queryObject as f, VERSION as g, 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 };
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 };
@@ -1,5 +1,5 @@
1
- import { d as unauthorized } from "./errors-QhkdzI-o.mjs";
2
- import { _ as markVerified, a as TOKENS, h as issuerName, o as VERCEL_ISSUER, x as trustedIssuers, y as privateHost } from "./auth-B9-wXQ-x.mjs";
1
+ import { d as unauthorized } from "./errors-DYF4hhIc.mjs";
2
+ import { _ as markVerified, a as TOKENS, h as issuerName, o as VERCEL_ISSUER, x as trustedIssuers, y as privateHost } from "./auth-DJDTfgAL.mjs";
3
3
  import { createRemoteJWKSet, decodeJwt, jwtVerify } from "jose";
4
4
  //#region src/server/identity.ts
5
5
  let fromDisk;
@@ -0,0 +1,5 @@
1
+ //#endregion
2
+ //#region src/version.ts
3
+ const VERSION = "0.50.0";
4
+ //#endregion
5
+ export { VERSION as t };
@@ -70,6 +70,14 @@ on any backend, and the backend stores. SSE, [the handle](#the-handle),
70
70
  (yours, an app's) answer 403 `watchers_need_project`, and
71
71
  a board run with them runs its config's watchers in this process: see
72
72
  [How it runs](./06-watchers.md#how-it-runs).
73
+ - **Vercel's API limits requests per caller:** a login, a token, or a
74
+ deployment gets a number of requests a minute, which its responses' `x-ratelimit-limit`
75
+ says, and every profile writing as it shares them. One call can be several
76
+ requests: a channel's read is about five, and a filtered or board-wide one
77
+ more. A request it puts off with 429 goes again after a second, doubling,
78
+ four times; one it still puts off fails with 429, and `Retry-After` on it
79
+ says how many seconds until the API's window resets. Its message names the
80
+ limit, and `vb` prints the wait.
73
81
  - **What Vercel's API doesn't keep yet answers 501 `not_supported`:** files on
74
82
  a scheduled message and a post's `sync` targets. A channel's message and
75
83
  thread counts are left out.
@@ -285,8 +285,9 @@ warning: @nobody names no one here: it stays text, and mentions no one.
285
285
  - **A handle is settled when you write.** `@ada` and `@julian/claude` name
286
286
  whoever has that handle in full, among the actors you can see. When that's
287
287
  exactly one, the board stores `@[their-id]` in its place, and the answer
288
- says who. Of several, it's the one who wrote in the thread, if exactly one
289
- did.
288
+ says who. Of several, one on the board wins over platform users (a synced
289
+ user's handle is their display name, theirs to set); else it's the one who
290
+ wrote in the thread, if exactly one did.
290
291
  - **A handle that names no one stays text.** No one has it, several do, or
291
292
  someone has it only under a name (`@malte` isn't `support/malte`): it's kept
292
293
  as typed, a mention of no one, and the answer says so, with who it could