@vercel/board 0.39.0 → 0.41.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 (100) hide show
  1. package/README.md +6 -4
  2. package/dist/{access-CVkjSfxj.mjs → access-C5HaO42b.mjs} +2 -2
  3. package/dist/access.d.mts +6 -6
  4. package/dist/access.mjs +5 -5
  5. package/dist/actors-nrOf7Y7z.mjs +160 -0
  6. package/dist/{auth-BXLCkeB0.d.mts → auth-Bn8J_1F2.d.mts} +14 -29
  7. package/dist/{auth-B3bBYOqf.mjs → auth-DAlYi6TN.mjs} +9 -19
  8. package/dist/{backend-HcCCGPG4.d.mts → backend-CYsTLxtP.d.mts} +139 -43
  9. package/dist/backend-local.d.mts +1 -1
  10. package/dist/backend-local.mjs +1 -1
  11. package/dist/blocks-CVoBC7ur.mjs +402 -0
  12. package/dist/blocks-DGvh2alZ.d.mts +33 -0
  13. package/dist/{chat-provider-1WKsLEnM.mjs → chat-provider-CPZg2MQb.mjs} +2 -2
  14. package/dist/{chat-provider-DyNy5xdC.d.mts → chat-provider-Cgkh9xJw.d.mts} +2 -2
  15. package/dist/cli-commands.d.mts +1 -1
  16. package/dist/cli-commands.mjs +1 -1
  17. package/dist/cli-embedded.d.mts +3 -3
  18. package/dist/cli-embedded.mjs +4 -4
  19. package/dist/cli.mjs +8 -13
  20. package/dist/{commands-B5d-lmNN.d.mts → commands-CrEVjASe.d.mts} +14 -26
  21. package/dist/{commands-BLS7erNu.mjs → commands-QRD0U9AQ.mjs} +114 -105
  22. package/dist/{conformance-D59Py2m2.mjs → conformance-ClxEEZ9C.mjs} +378 -101
  23. package/dist/conformance.d.mts +11 -9
  24. package/dist/conformance.mjs +1 -1
  25. package/dist/data-values-C-Cq80hz.mjs +176 -0
  26. package/dist/digest-Dna1CGa_.mjs +4 -0
  27. package/dist/{engine-eUgO5jTM.mjs → engine-8BcNeckB.mjs} +197 -84
  28. package/dist/{errors-rYDxZEuN.mjs → errors-DcQf5WeM.mjs} +123 -42
  29. package/dist/{events-C6HwB046.mjs → events-BT8y_81j.mjs} +2 -2
  30. package/dist/{exports-M5o4PTfO.mjs → exports-B6udRV_E.mjs} +961 -383
  31. package/dist/exports-C8zsIL1A.d.mts +4 -0
  32. package/dist/{external-CHDxWIVf.mjs → external-DymyhUzl.mjs} +1 -1
  33. package/dist/{index-rNqqgkyu.d.mts → index-fcpEFCTR.d.mts} +2 -2
  34. package/dist/index.d.mts +7 -6
  35. package/dist/index.mjs +8 -6
  36. package/dist/index.node.d.mts +7 -6
  37. package/dist/index.node.mjs +5 -4
  38. package/dist/inspect/app.js +110 -109
  39. package/dist/inspect/engine.js +5 -5
  40. package/dist/inspect-BsF3mYMY.mjs +2 -0
  41. package/dist/{inspect-BkXxR2uB.mjs → inspect-DPRoC_Gg.mjs} +6 -6
  42. package/dist/{local-DvkOWf4U.mjs → local-B9y4p6N7.mjs} +463 -512
  43. package/dist/{main-DtV_Po9i.mjs → main-S0A-c_kP.mjs} +549 -178
  44. package/dist/{memory-DkoqhxIH.mjs → memory-DhduVbUu.mjs} +2 -2
  45. package/dist/{mentions-CB6ShY4R.mjs → mentions-DfZGp3B-.mjs} +18 -4
  46. package/dist/{middleware-CPqAuRtp.mjs → middleware-DHdrxmoc.mjs} +71 -3
  47. package/dist/{targets-C1mT3M1N.mjs → origin-B3m2lnZC.mjs} +43 -64
  48. package/dist/{page-64IwoGRu.mjs → page-2jjHZmIW.mjs} +2 -2
  49. package/dist/page-CAUe4GmQ.mjs +2 -0
  50. package/dist/{provider-D5yVFisj.d.mts → provider-dY54GFNz.d.mts} +20 -34
  51. package/dist/{routes-BffuaoTX.d.mts → routes-By9lmvUD.d.mts} +91 -77
  52. package/dist/{schemas-AZkxk06N.mjs → schemas-DAzSsgWk.mjs} +8 -3
  53. package/dist/schemas.d.mts +37 -0
  54. package/dist/schemas.mjs +3 -0
  55. package/dist/{serve-CX1rqDF_.mjs → serve-B15I2Ibf.mjs} +5 -5
  56. package/dist/{server-DkYkyarg.mjs → server-DgpRZ4Nu.mjs} +74 -127
  57. package/dist/{serving-DJMcG0dT.mjs → serving-CALKWs9K.mjs} +1 -1
  58. package/dist/{sql-l3ysn4O5.mjs → sql-P9g-rLIF.mjs} +75 -12
  59. package/dist/{sqlite-CAwNHbQD.mjs → sqlite-B3rCcIof.mjs} +2 -2
  60. package/dist/{sqlite-db-cm5yhrD-.mjs → sqlite-db-D0Fyju-4.mjs} +1 -1
  61. package/dist/sync-chat-sdk.d.mts +2 -2
  62. package/dist/sync-chat-sdk.mjs +2 -2
  63. package/dist/sync-github.d.mts +2 -2
  64. package/dist/sync-github.mjs +2 -2
  65. package/dist/sync-linear.d.mts +3 -3
  66. package/dist/sync-linear.mjs +2 -2
  67. package/dist/sync-slack.d.mts +14 -8
  68. package/dist/sync-slack.mjs +46 -19
  69. package/dist/sync.d.mts +2 -2
  70. package/dist/sync.mjs +2 -2
  71. package/dist/{tokens-DA9ipsZ-.mjs → tokens-D7_ZIWpX.mjs} +4 -4
  72. package/docs/01-board/01-mounting.md +13 -16
  73. package/docs/01-board/03-identity.md +112 -74
  74. package/docs/01-board/04-messages.md +61 -2
  75. package/docs/01-board/05-reading.md +11 -5
  76. package/docs/01-board/06-watchers.md +17 -13
  77. package/docs/01-board/07-schedules.md +8 -6
  78. package/docs/01-board/08-middleware.md +1 -1
  79. package/docs/01-board/09-access.md +80 -132
  80. package/docs/02-sync/01-overview.md +75 -4
  81. package/docs/02-sync/02-functions.md +11 -6
  82. package/docs/02-sync/03-slack.md +43 -19
  83. package/docs/02-sync/06-providers.md +9 -4
  84. package/docs/03-guides/01-coding-agents.md +18 -22
  85. package/docs/03-guides/02-inspector.md +4 -5
  86. package/docs/03-guides/03-ci.md +7 -26
  87. package/docs/03-guides/04-triage.md +2 -2
  88. package/docs/03-guides/05-agent-factory.md +7 -9
  89. package/docs/03-guides/06-sandboxed-agents.md +149 -0
  90. package/docs/04-reference/01-cli.md +161 -104
  91. package/docs/04-reference/02-board.md +89 -37
  92. package/docs/04-reference/03-http.md +176 -71
  93. package/docs/04-reference/05-conformance.md +47 -21
  94. package/docs/index.md +5 -5
  95. package/package.json +5 -1
  96. package/dist/actors-kfMejhaw.mjs +0 -156
  97. package/dist/digest-krhjNAt4.mjs +0 -4
  98. package/dist/exports-vLQ2Y2Nd.d.mts +0 -4
  99. package/dist/inspect-lnv1sLXM.mjs +0 -2
  100. package/dist/page-BUj8_UZv.mjs +0 -2
@@ -93,6 +93,113 @@ async function* parseSse(body, signal) {
93
93
  }
94
94
  }
95
95
  //#endregion
96
+ //#region src/contract/profile-header.ts
97
+ /** Why a header isn't one: the board's 400 says it. */
98
+ var InvalidProfileHeader = class extends Error {};
99
+ const TOKEN_START = /[A-Za-z*]/;
100
+ const TCHAR = /[!#$%&'*+\-.^_`|~0-9A-Za-z:/]/;
101
+ const KEY_START = /[a-z*]/;
102
+ const KEY_CHAR = /[a-z0-9_\-.*]/;
103
+ /** RFC 8941's other bare items: an integer, a decimal, a boolean, or a byte sequence. */
104
+ const OTHER_ITEM = /^(?:-?\d{1,15}|-?\d{1,12}\.\d{1,3}|\?[01]|:[A-Za-z0-9+/=]*:)$/;
105
+ /** An sf-string: printable ASCII in quotes, with `"` and `\` escaped. */
106
+ function sfString(value) {
107
+ if (!/^[\x20-\x7e]*$/.test(value)) throw new InvalidProfileHeader("an avatar URL is printable ASCII: percent-encode the rest");
108
+ return `"${value.replace(/[\\"]/g, (char) => `\\${char}`)}"`;
109
+ }
110
+ /**
111
+ * The header's value for a profile: `fixer`, or `fixer;avatar="https://example.com/fixer.png"`,
112
+ * serialized as RFC 8941 says. An avatar outside printable ASCII goes as its URL percent-encodes it.
113
+ */
114
+ function formatProfileHeader(profile) {
115
+ if (!profile.avatar) return profile.name;
116
+ const avatar = /^[\x20-\x7e]*$/.test(profile.avatar) ? profile.avatar : URL.parse(profile.avatar)?.href ?? profile.avatar;
117
+ return `${profile.name};avatar=${sfString(avatar)}`;
118
+ }
119
+ /**
120
+ * Reads the header as RFC 8941 parses an Item. Its bare item is the profile's name, a token or a
121
+ * string; `avatar` is a string. A parameter it doesn't know is ignored, as structured fields' are,
122
+ * and the last of a repeated one wins. Anything else throws `InvalidProfileHeader`.
123
+ */
124
+ function parseProfileHeader(value) {
125
+ let at = 0;
126
+ const fail = (why) => {
127
+ throw new InvalidProfileHeader(`x-board-profile is a structured header, like fixer;avatar="https://example.com/fixer.png": ${why}`);
128
+ };
129
+ const spaces = () => {
130
+ while (value[at] === " ") at++;
131
+ };
132
+ const string = () => {
133
+ at++;
134
+ let out = "";
135
+ while (at < value.length) {
136
+ const char = value[at++];
137
+ if (char === "\\") {
138
+ const next = value[at++];
139
+ if (next !== "\"" && next !== "\\") fail("a string escapes only \" and \\");
140
+ out += next;
141
+ } else if (char === "\"") return out;
142
+ else if (char < " " || char > "~") fail("a string is printable ASCII");
143
+ else out += char;
144
+ }
145
+ return fail("a string is missing its closing \"");
146
+ };
147
+ const token = () => {
148
+ const start = at;
149
+ while (at < value.length && TCHAR.test(value[at])) at++;
150
+ return value.slice(start, at);
151
+ };
152
+ /** A bare item: a string, a token, or another of RFC 8941's (a number, a boolean, bytes), which the header names nothing with. */
153
+ const bare = () => {
154
+ const char = value[at];
155
+ if (char === "\"") return {
156
+ kind: "string",
157
+ value: string()
158
+ };
159
+ if (char !== void 0 && TOKEN_START.test(char)) return {
160
+ kind: "token",
161
+ value: token()
162
+ };
163
+ const start = at;
164
+ while (at < value.length && value[at] !== ";" && value[at] !== " ") at++;
165
+ const item = value.slice(start, at);
166
+ if (!OTHER_ITEM.test(item)) fail(item === "" ? "a parameter has no value after its =" : `${item} isn't a value`);
167
+ return {
168
+ kind: "other",
169
+ value: item
170
+ };
171
+ };
172
+ spaces();
173
+ const name = bare();
174
+ if (name.kind === "other") fail(name.value === "" ? "it names no profile" : `${name.value} isn't a profile's name`);
175
+ let avatar = null;
176
+ while (value[at] === ";") {
177
+ at++;
178
+ spaces();
179
+ if (!KEY_START.test(value[at] ?? "")) fail("a parameter starts with a lowercase letter");
180
+ const start = at;
181
+ while (at < value.length && KEY_CHAR.test(value[at])) at++;
182
+ const key = value.slice(start, at);
183
+ let param = {
184
+ kind: "boolean",
185
+ value: "?1"
186
+ };
187
+ if (value[at] === "=") {
188
+ at++;
189
+ param = bare();
190
+ }
191
+ if (key !== "avatar") continue;
192
+ if (param.kind !== "string") fail("avatar is a string, in quotes");
193
+ avatar = param.value;
194
+ }
195
+ spaces();
196
+ if (at < value.length) fail(`${JSON.stringify(value.slice(at, at + 20))} follows the profile`);
197
+ return {
198
+ name: name.value,
199
+ avatar
200
+ };
201
+ }
202
+ //#endregion
96
203
  //#region src/client/client.ts
97
204
  /**
98
205
  * What went wrong: `message` says what and why, `code` is what to branch on, `hint`, when there's
@@ -191,10 +298,6 @@ function creatorOf(me, path) {
191
298
  };
192
299
  throw new BoardError("no_own_principal", `A private channel lets its creator in, as a person or a project's deployment, and ${me.principal} is neither, so ${path} wasn't made.`, 400, { hint: "Make it as a person or a deployment, or make it and its grants yourself." });
193
300
  }
194
- const written = (value, unknownMentions) => unknownMentions?.length ? {
195
- ...value,
196
- unknownMentions
197
- } : value;
198
301
  function createBoardClient(options) {
199
302
  const base = options.url.replace(/\/+$/, "");
200
303
  const doFetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
@@ -204,22 +307,7 @@ function createBoardClient(options) {
204
307
  if (!auth) return out;
205
308
  if (options.token !== void 0) out.authorization = `Bearer ${await resolve(options.token)}`;
206
309
  const profile = as !== void 0 ? as : options.profile === void 0 ? null : await resolve(options.profile);
207
- if (profile !== null) {
208
- const { name, avatar } = typeof profile === "string" ? {
209
- name: profile,
210
- avatar: void 0
211
- } : profile;
212
- out["x-board-profile"] = name;
213
- if (avatar) out["x-board-avatar"] = avatar;
214
- } else {
215
- const person = options.person === void 0 ? null : await resolve(options.person);
216
- if (person?.name) out["x-board-name"] = encodeURIComponent(person.name);
217
- if (person?.avatar) out["x-board-avatar"] = person.avatar;
218
- }
219
- const session = as !== void 0 ? null : options.session === void 0 ? null : await resolve(options.session);
220
- if (session) out["x-board-session"] = session;
221
- const handle = options.handle === void 0 ? null : await resolve(options.handle);
222
- if (handle) out["x-board-handle"] = handle;
310
+ if (profile !== null) out["x-board-profile"] = formatProfileHeader(typeof profile === "string" ? { name: profile } : profile);
223
311
  return out;
224
312
  }
225
313
  async function raw(method, path, init = {}) {
@@ -329,20 +417,17 @@ function createBoardClient(options) {
329
417
  posted: async (id) => (await call("GET", `/posts/${path(id)}`)).message,
330
418
  /** Threads with a matching message, one summary each (root, reply count, latest reply), by latest activity. `limit` counts threads. */
331
419
  threads: (query = {}) => call("GET", `/threads${queryString(query)}`),
332
- /** `unknownMentions` lists the handles that matched nobody: they posted as plain text. */
333
420
  async post(channel, input) {
334
- const { message, unknownMentions } = await call("POST", "/messages", { body: {
421
+ return (await call("POST", "/messages", { body: {
335
422
  channel,
336
423
  ...messageBody(input)
337
- } });
338
- return written(message, unknownMentions);
424
+ } })).message;
339
425
  },
340
426
  async reply(id, input) {
341
- const { message, unknownMentions } = await call("POST", "/messages", { body: {
427
+ return (await call("POST", "/messages", { body: {
342
428
  re: id,
343
429
  ...messageBody(input)
344
- } });
345
- return written(message, unknownMentions);
430
+ } })).message;
346
431
  },
347
432
  /**
348
433
  * Posts later, as you: a new thread when `target` is a channel, a reply when it's
@@ -350,11 +435,10 @@ function createBoardClient(options) {
350
435
  * `schedule: { id, n }`. Needs a board with a scheduler.
351
436
  */
352
437
  async schedule(target, input) {
353
- const { schedule, unknownMentions } = await call("POST", "/schedules", { body: {
438
+ return (await call("POST", "/schedules", { body: {
354
439
  ...typeof target === "string" ? { channel: target } : { re: target.re },
355
440
  ...scheduleBody(input)
356
- } });
357
- return written(schedule, unknownMentions);
441
+ } })).schedule;
358
442
  },
359
443
  /** Pending schedules (`all` for done and canceled too), oldest first. `re` is any message in a thread. */
360
444
  schedules: async (query = {}) => (await call("GET", `/schedules${queryString(query)}`)).schedules,
@@ -392,19 +476,16 @@ function createBoardClient(options) {
392
476
  grants: async () => (await call("GET", "/grants")).grants,
393
477
  /** `revoked` is false when it was already gone. Its principals' next requests are refused. */
394
478
  revokeGrant: (id) => call("POST", `/grants/${path(id)}/revoke`, { body: {} }),
479
+ /** Every schema: the built-ins, then the board's own, by name and version. */
480
+ schemas: async () => (await call("GET", "/schemas")).schemas,
481
+ /** One schema version, by its ID: `sandbox@1`. */
482
+ schema: async (id) => (await call("GET", `/schemas/${path(id)}`)).schema,
395
483
  /**
396
- * A token that acts as you, narrowed to `can`, writing as `profile` and `session` when they're
397
- * given: for a widget, a sandbox, a script. `secret` shows only here. It lives 30 days, or
398
- * `expires`, at most 90.
484
+ * Registers a schema version, for good: `schema` is a JSON Schema for an object, in structural
485
+ * keywords only. Needs manage at `*`. `created` is false for one that's there with the same
486
+ * definition; another definition is refused, since a version never changes.
399
487
  */
400
- createToken: (input) => call("POST", "/tokens", { body: input.can === void 0 ? input : {
401
- ...input,
402
- can: wireCan(input.can)
403
- } }),
404
- /** Your live tokens, or everyone's with manage in every channel. Never their secrets. */
405
- tokens: async () => (await call("GET", "/tokens")).tokens,
406
- /** It and every token minted with it stop. `revoked` is false when it was already revoked. */
407
- revokeToken: (id) => call("POST", `/tokens/${path(id)}/revoke`, { body: {} }),
488
+ createSchema: (input) => call("POST", "/schemas", { body: input }),
408
489
  /**
409
490
  * Stores a file on the board, for a post or reply's `attachments`. Up to 4 MB goes in one
410
491
  * request; bigger, up to 100 MB, goes straight to the board's blob store on a URL the board
@@ -673,4 +754,4 @@ function toErrorResponse(error) {
673
754
  } }, 500);
674
755
  }
675
756
  //#endregion
676
- export { fileSize as _, forbidden as a, toErrorResponse as c, createBoardClient as d, duration as f, fileName as g, IMPORT_BYTES_MAX as h, duplicateId as i, unauthorized as l, DIRECT_UPLOAD_BYTES_MAX as m, RejectedError as n, json as o, ATTACHMENT_BYTES_MAX as p, badRequest as r, notFound as s, HttpError as t, BoardError as u, mediaType as v, typeOf as y };
757
+ export { IMPORT_BYTES_MAX as _, forbidden as a, mediaType as b, toErrorResponse as c, createBoardClient as d, duration as f, DIRECT_UPLOAD_BYTES_MAX as g, ATTACHMENT_BYTES_MAX as h, duplicateId as i, unauthorized as l, parseProfileHeader as m, RejectedError as n, json as o, formatProfileHeader as p, badRequest as r, notFound as s, HttpError as t, BoardError as u, fileName as v, typeOf as x, fileSize as y };
@@ -1,5 +1,5 @@
1
- import { d as Labels, l as LabelKey } from "./schemas-AZkxk06N.mjs";
2
- import { n as ExternalEvent, r as ExternalLocation } from "./external-CHDxWIVf.mjs";
1
+ import { d as Labels, l as LabelKey } from "./schemas-DAzSsgWk.mjs";
2
+ import { n as ExternalEvent, r as ExternalLocation } from "./external-DymyhUzl.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/sync/fn.ts
5
5
  const ROUTES = Symbol.for("board.syncRoutes");