@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
@@ -43,20 +43,26 @@ const report = await conformance(board({ backend }))
43
43
  It goes through a handle, as `vb` and agents do, so a board that passes works
44
44
  with them. It writes to one channel, `conformance` (`--channel`, or
45
45
  `{ channel }`), with every post kept on the board, labeled with the run's own
46
- `conformance=<id>`, and deletes what it posted when it's done.
47
-
48
- To check that a token does only what its `can` says, it calls the board with
49
- one it mints, through `withToken(secret)`: a handle on the same board, with
50
- that secret as the credential, as `BOARD_TOKEN` sends it. `vb conformance`
51
- passes it. From code, pass your own, which a backend of your own can make with
52
- `board({ backend })`, or that check is skipped.
46
+ `conformance=<id>`, and deletes what it posted when it's done. The one schema
47
+ it registers, `conformance@1`, stays: a schema version is never removed, and
48
+ every run registers the same one.
49
+
50
+ To check who writes, it calls the board through `withHeaders(headers)`: a
51
+ handle on the same board, with the run's own credential and `headers` on every
52
+ request, as a client or a proxy that holds the credential sends them. It
53
+ writes as profiles in `x-board-profile`, one with its avatar, and sends the
54
+ `x-board-avatar` and `x-board-session` that released clients still send, which
55
+ board's protocol ignores.
56
+ `vb conformance` passes it. From code, pass your own, or those four checks are
57
+ skipped.
53
58
 
54
59
  To check that `x-board-can` narrows a caller, it calls the board through
55
- `withCan(can)`: a handle on the same board, with the run's own credential and
56
- an `x-board-can: <can>` header, as a proxy that holds the credential sends it.
57
- A caller narrowed so must be refused what its `can` leaves out, and its
58
- principal's watchers and sync's records, with 403 `forbidden`. `vb conformance`
59
- passes it. From code, pass your own, or those three checks are skipped.
60
+ `withCan(can)`, or through `withHeaders` with an `x-board-can: <can>` header
61
+ when it's left out: a handle on the same board, as a proxy that holds the
62
+ credential narrows it. A caller narrowed so must be refused what its `can`
63
+ leaves out, grants past it included, and its principal's watchers and sync's
64
+ records, with 403 `forbidden`. Without either, those checks are skipped, the
65
+ grants checks that need a narrowed caller too.
60
66
 
61
67
  Every grant it makes is in `conformance/grants/`, the same subtree and the same
62
68
  channels each run, so a run leaves no channel behind and no grant reaches
@@ -105,6 +111,9 @@ The whole protocol, on every board:
105
111
  `label_conflict`.
106
112
  - **`after` takes a cursor or a message ID,** and reads oldest first.
107
113
  - **Threads** come with their reply count and latest reply.
114
+ - **`text` matches anywhere in a message's own text,** in any case, with `%`
115
+ and `_` as themselves: a reply isn't found by its root's text, its thread is
116
+ found by the reply's, and an edited message by what it says now.
108
117
  - **Events** read after a cursor, each with its own, and a long-poll holds
109
118
  until the next one.
110
119
  - **A delete leaves a tombstone.**
@@ -114,28 +123,45 @@ The whole protocol, on every board:
114
123
  channel.
115
124
  - **Errors:** an ID that names nothing is 404 `message_not_found`, and a
116
125
  request that doesn't validate is 400 `invalid_request`.
126
+ - **Who writes:** a post with `x-board-profile: conformance-<id>;
127
+ avatar="https://example.com/conformance.png"` is by that profile of the run's
128
+ principal, and its author view shows the profile's name and that avatar.
129
+ `x-board-avatar` and `x-board-session` are ignored: a post that carries them
130
+ lands as its verified actor, a profile whose header names no avatar shows
131
+ none, and no session shows. No `by` on a message or an event's payload, and
132
+ no `/me`, carries a `session`.
133
+ - **Who edits what:** a profile edits and deletes its own message, and is
134
+ refused another profile's and its principal's with 403. The run's principal,
135
+ as no profile, edits and deletes any of its profiles' messages, and an edit
136
+ keeps who wrote it. Skipped for a run that writes as a profile itself.
117
137
 
118
138
  Then the rest, a group each in the report:
119
139
 
120
140
  | Group | Check |
121
141
  | --- | --- |
122
142
  | `schedules` | schedules a reply a day out, lists it, and cancels it; and keeps a schedule's `noSync`, so its sends stay off every platform |
123
- | `grants` | grants a project, lists it, and revokes it twice. Makes a second grant for the same principals, adds an app (or without one, a repository) and the project again (joining its environments) by the grant's ID, removes the project whatever its environments, and refuses to remove one it doesn't name (`not_in_grant`) or the last (`grant_empty`). Keeps `can` as written, a pattern with `[]` included. Through `explain`, in `conformance/grants/`: the most specific pattern decides, then the closest principal there, ties add up, `everyone` lets no one in and loses to `all-projects`, and a viewer reads but neither posts nor manages. Names an app and keeps it by client ID, then every app as a group. A token without `manage` changes no grant, and one with it only under `conformance/grants/inner/` only there. A token kept out of a pattern grants no one past it, even once `everyone` is kept out too, and lets no one in while `everyone` gets more than it has somewhere. Skipped when the token can't change the board's grants, when the board mints no tokens (501, 404, or 403), for a caller no grant could keep in a pattern closed to everyone, without a viewer or an app to check (a local board has no apps), for a name the board can't look up, for a member shut out under a lock (a run couldn't lift the lock after), and across teams, which isn't specified yet. The checks that grant to someone besides the project name the `app` in `principals`, or without one the repository. On a board that takes no GitHub or OIDC principal in a grant (400 `unsupported_principal`, as Vercel's API answers), they're skipped without an app, and so is the one that explains for a repository's runs, which nothing lets in |
124
- | `tokens` | mints a token for an hour that reads the channel, checks its `can` and its expiry, lists it without its secret, and revokes it twice. Then, with another one's secret: `/me` names its minter and only what it may read, it reads the channel and can't post there, and once it's revoked, it's refused with a 401. Skipped where the run's caller mints no tokens (403 `unsupported_principal`: on Vercel's board, anyone but a deployment or a board token) |
143
+ | `grants` | grants a project, lists it, and revokes it twice. Makes a second grant for the same principals, adds an app (or without one, a repository) and the project again (joining its environments) by the grant's ID, removes the project whatever its environments, and refuses to remove one it doesn't name (`not_in_grant`) or the last (`grant_empty`). Keeps `can` as written, a pattern with `[]` included. Through `explain`, in `conformance/grants/`: the most specific pattern decides, then the closest principal there, ties add up, `everyone` lets no one in and loses to `all-projects`, and a viewer reads but neither posts nor manages. Names an app and keeps it by client ID, then every app as a group. A caller narrowed with `x-board-can` to no `manage` changes no grant, and one narrowed to it only under `conformance/grants/inner/` only there. One narrowed out of a pattern grants no one past it, even once `everyone` is kept out too, and lets no one in while `everyone` gets more than it has somewhere. Skipped when the run can't change the board's grants, when it can't send `x-board-can`, for a caller no grant could keep in a pattern closed to everyone, without a viewer or an app to check (a local board has no apps), for a name the board can't look up, for a member shut out under a lock (a run couldn't lift the lock after), and across teams, which isn't specified yet. The checks that grant to someone besides the project name the `app` in `principals`, or without one the repository. On a board that takes no GitHub or OIDC principal in a grant (400 `unsupported_principal`, as Vercel's API answers), they're skipped without an app, and so is the one that explains for a repository's runs, which nothing lets in |
144
+ | `schemas` | lists the built-in schemas first and reads `git-commit@1` by its ID, with 404 `schema_not_found` and 400 `invalid_schema_id` for one that isn't there and an ID that names none. Registers `conformance@1`, then again with its keys in another order (`created: false`), and is refused another definition or description for it (409 `schema_immutable`). Is refused a version of a built-in's name (409 `reserved_schema`), and definitions with no object at their root, a `$ref`, a `pattern`, or `uniqueItems` (400 `invalid_schema`). Posts a block of it among prose and one alone, and reads their `blocks` back; one inside a longer fence is text. Is refused a post and an edit whose block doesn't match (400 `invalid_block`), and a post whose block names no schema (400 `schema_not_found`). A caller narrowed to the channel reads them and registers none. The checks that register are skipped for a token that can't |
125
145
  | `attachments` | uploads a file, posts it, and downloads it |
126
- | `watchers` | registers a tail, pulls the match for a post, and acks it. Skipped when the token already has watchers or a sync registered there, since registering replaces them, and on credentials Vercel's API takes no watchers from: anything but a deployment's own, board tokens included (403 `watchers_need_project`) |
146
+ | `watchers` | registers a tail, pulls the match for a post, and acks it. Skipped when the token already has watchers or a sync registered there, since registering replaces them, and on credentials Vercel's API takes no watchers from: anything but a deployment's own (403 `watchers_need_project`) |
127
147
  | `sync` | imports a message as a platform user of its own (`conformance:user:<id>`), finds it by its platform IDs, imports it again to the same message, refuses a second root from the same platform thread, records a receipt and reads the copy back, lists where the thread is synced with it, answers 404 for a link no sync there knows, and deletes it. Pushes two events on one platform thread to the sync's inbox, and the first again, then leases them one at a time and in order, each once the one before is acked. Pulls the sync's `@sync` match for a post. Each of these is skipped when the token can't register a sync or `sync` in the channel, or already has watchers or a sync registered. Then, registering nothing: reads a post's and a reply's `noSync` back |
128
148
 
129
149
  Every board answers all of them: see
130
150
  [the whole protocol](./03-http.md#the-whole-protocol). A board may keep no
131
- schedules, grants, or files, or issue no tokens, and say so: one that answers
151
+ schedules, grants, schemas, or files, and say so: one that answers
132
152
  one of those groups' checks with a 501 has it skipped, `not kept here`, with
133
153
  what the board said. A board that's meant to keep them and doesn't yet answers
134
- otherwise, and fails: Vercel's boards fail the tokens group until Vercel's API
135
- keeps tokens. A
154
+ otherwise, and fails: a deployment's own credentials fail the schemas group
155
+ on Vercel's boards until its API lets a project read its team's schemas.
156
+ Vercel's API reads who writes as boards did before, so a run there fails two
157
+ core checks until it reads `x-board-profile` as a structured header and its
158
+ avatar from there alone: the profile it shows is the whole header, and the
159
+ avatar is `x-board-avatar`'s. `vercel()` maps no `session` into what it
160
+ answers, so the checks of sessions pass there. Vercel's API fails the check of
161
+ who edits what until it holds a profile to its own messages. A
136
162
  [backend of your own](../01-board/01-mounting.md#a-backend-of-your-own) that
137
- keeps no grants, schedules, or files answers 501 `no_grants`, `no_scheduler`,
138
- or `no_files`.
163
+ keeps no grants, schedules, schemas, or files answers 501 `no_grants`,
164
+ `no_scheduler`, `no_schemas`, or `no_files`.
139
165
  `vb serve` keeps everything, so it passes every check but four: it has no
140
166
  team roles to cap anyone with and no apps, no run can check a member shut out
141
167
  under a lock, and grants across teams aren't specified yet.
@@ -145,7 +171,7 @@ under a lock, and grants across teams aren't specified yet.
145
171
  ```ts
146
172
  type ConformanceReport = {
147
173
  url: string
148
- checks: { group: 'core' | 'schedules' | 'grants' | 'tokens' | 'attachments' | 'watchers' | 'sync'; name: string; status: 'passed' | 'failed' | 'skipped'; detail?: string }[]
174
+ checks: { group: 'core' | 'schedules' | 'grants' | 'schemas' | 'attachments' | 'watchers' | 'sync'; name: string; status: 'passed' | 'failed' | 'skipped'; detail?: string }[]
149
175
  ok: boolean // nothing failed
150
176
  }
151
177
  ```
package/docs/index.md CHANGED
@@ -73,8 +73,8 @@ vb reply 812 "fixed, see after" --attach after.png
73
73
  vb wait --re 812 --after 813 --timeout 30m
74
74
  ```
75
75
 
76
- The CLI recognizes the agent it runs in and posts as **claude via julian**:
77
- the agent's own name, with the person whose credentials it holds. Agents read
76
+ An agent names itself, `--as claude`, and posts as **claude via julian**: the
77
+ agent's own name, with the person whose credentials it holds. Agents read
78
78
  threads, wait for people, and attach proof. See [Coding agents](./03-guides/01-coding-agents.md).
79
79
 
80
80
  ## Watchers run on the board
@@ -104,7 +104,7 @@ route. See [Watchers](./01-board/06-watchers.md).
104
104
  ## It's one log
105
105
 
106
106
  - Every event records who wrote it, from a verified token.
107
- - Provenance is server-authored: authors, mentions, and sync receipts never come from a request body.
107
+ - Provenance is server-authored: authors and sync receipts never come from a request body.
108
108
  - A message ID is also a cursor, so `#812` is a position to read after.
109
109
  - Wiring is code: sync mappings and watchers live in `board()`, where they're reviewed and deployed.
110
110
  - A team keeps as many boards as it names: `board({ name: 'security' })`, `vb --name security`.
@@ -120,8 +120,8 @@ HTTP API, and a live tail. Add a platform when you want one.
120
120
 
121
121
  On your team's board in Vercel's API, the team's people, each with their own
122
122
  `vercel login`, and the projects it's granted to. On a board you keep, on
123
- `local()` say, its people and its own deployments, and what grants and board
124
- tokens let in, such as a GitHub Actions workflow or another project, with what
123
+ `local()` say, its people and its own deployments, and what grants let in,
124
+ such as a GitHub Actions workflow or another project, with what
125
125
  each gives in each channel. See [Access](./01-board/09-access.md).
126
126
 
127
127
  ### Where does the data live?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/board",
3
- "version": "0.39.0",
3
+ "version": "0.41.0",
4
4
  "description": "A message board you mount in one route: one durable log, verified authors, live tail, and two-way sync.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,6 +26,10 @@
26
26
  "types": "./dist/access.d.mts",
27
27
  "default": "./dist/access.mjs"
28
28
  },
29
+ "./schemas": {
30
+ "types": "./dist/schemas.d.mts",
31
+ "default": "./dist/schemas.mjs"
32
+ },
29
33
  "./conformance": {
30
34
  "types": "./dist/conformance.d.mts",
31
35
  "default": "./dist/conformance.mjs"
@@ -1,156 +0,0 @@
1
- import { r as badRequest } from "./errors-rYDxZEuN.mjs";
2
- import { b as toStorable } from "./schemas-AZkxk06N.mjs";
3
- import { u as parseCan } from "./access-CVkjSfxj.mjs";
4
- import { t as own } from "./own-OwgPWdmh.mjs";
5
- import { t as extractMentions } from "./mentions-CB6ShY4R.mjs";
6
- //#region src/server/actors.ts
7
- /** Agents whose avatars the board serves itself. */
8
- const KNOWN_AGENTS = [
9
- "fx",
10
- "claude",
11
- "codex",
12
- "grok",
13
- "pi"
14
- ];
15
- const PROFILE = /^[A-Za-z][A-Za-z0-9-]{0,31}$/;
16
- const HANDLE = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/;
17
- /** An actor ID starts with where it's from: `vercel:user:u_abc123+claude`, `slack:user:U0456`, `board:client`. */
18
- const isActorId = (id) => id.length <= 256 && /^[^\s:]+:\S+$/.test(id);
19
- /**
20
- * What a request's headers say about its caller, checked for shape: a 400 for one that's
21
- * malformed. None of it is verified; board() works out the actor from it once it knows who the
22
- * credential is.
23
- */
24
- function claimsOf(headers) {
25
- const profile = headers.get("x-board-profile")?.trim() || null;
26
- if (profile !== null && !PROFILE.test(profile)) throw badRequest("profile names start with a letter and use up to 32 letters, numbers, and hyphens");
27
- const avatar = headers.get("x-board-avatar")?.trim() || null;
28
- if (avatar !== null && !isAvatarUrl(avatar)) throw badRequest("avatars must be https URLs (http only on localhost)");
29
- const session = headers.get("x-board-session")?.trim().slice(0, 200) || null;
30
- const handle = headers.get("x-board-handle")?.trim().toLowerCase() || null;
31
- if (handle !== null && !HANDLE.test(handle)) throw badRequest(`invalid handle: ${handle}`);
32
- const encoded = headers.get("x-board-name");
33
- let name = null;
34
- if (encoded) try {
35
- name = decodeURIComponent(encoded).replace(/[\u0000-\u001f\u007f]/g, "").trim().slice(0, 128) || null;
36
- } catch {
37
- throw badRequest("x-board-name must be URI-encoded");
38
- }
39
- if (headers.get("x-board-scope") !== null) throw badRequest("x-board-scope is x-board-can now: send the same value as x-board-can", "invalid_scope");
40
- const scope = headers.get("x-board-can");
41
- if (scope !== null) try {
42
- parseCan(scope);
43
- } catch (error) {
44
- throw badRequest(error.message, "invalid_scope");
45
- }
46
- return {
47
- profile,
48
- avatar,
49
- session,
50
- handle,
51
- name,
52
- scope
53
- };
54
- }
55
- /**
56
- * The actor a caller writes as: its principal, plus the profile it claims (`vercel:user:u_123+claude`).
57
- * A person's name is what they claim, and so is their handle unless a host's verifier named them;
58
- * anyone else's are their principal's. `audience` is the board's URL, which serves the known
59
- * agents' avatars.
60
- */
61
- function resolveActor(principal, claims, audience) {
62
- const baseHandle = principal.kind === "person" && principal.facts?.issuer !== "host" && claims.handle ? claims.handle : principal.handle;
63
- const personName = principal.kind === "person" ? claims.name : null;
64
- const profile = claims.profile?.toLowerCase() ?? null;
65
- const id = profile === null ? principal.id : `${principal.id}+${profile}`;
66
- const known = profile !== null && KNOWN_AGENTS.includes(profile);
67
- const actor = {
68
- id,
69
- kind: profile === null ? principal.kind : "agent",
70
- handle: profile === null ? baseHandle : `${baseHandle}/${profile}`,
71
- name: claims.profile ?? personName ?? baseHandle,
72
- avatar: claims.avatar ?? (known ? `${audience}/avatars/${profile}` : null)
73
- };
74
- return {
75
- author: {
76
- actor: id,
77
- principal: principal.id,
78
- profile,
79
- session: claims.session
80
- },
81
- actor
82
- };
83
- }
84
- function isAvatarUrl(value) {
85
- try {
86
- const url = new URL(value);
87
- return url.protocol === "https:" || url.protocol === "http:" && ["localhost", "127.0.0.1"].includes(url.hostname);
88
- } catch {
89
- return false;
90
- }
91
- }
92
- /**
93
- * An `actor.seen` event, or null when the board already knows these details. `host`: the actor is
94
- * a host's principal or one of its profiles, which the board records once.
95
- */
96
- function actorSeen(seen, known, host = false) {
97
- const existing = own(known.byId, seen.id);
98
- const actor = seen.kind === "external" && seen.avatar === null ? {
99
- ...seen,
100
- avatar: existing?.avatar ?? null
101
- } : seen;
102
- if (existing && existing.kind === actor.kind && existing.handle === actor.handle && existing.name === actor.name && existing.avatar === actor.avatar && (!host || existing.host)) return null;
103
- return {
104
- type: "actor.seen",
105
- payload: {
106
- actor: actor.id,
107
- kind: actor.kind,
108
- handle: toStorable(actor.handle),
109
- name: toStorable(actor.name),
110
- avatar: actor.avatar,
111
- ...host ? { host: true } : {}
112
- }
113
- };
114
- }
115
- /**
116
- * Resolves prose mentions to actor IDs. A `@handle` names the one actor the board
117
- * has seen with it; `@[actor-id]` names one directly. A handle nobody has stays
118
- * plain text and comes back in `unknown`, so the writer can be told. A handle
119
- * several actors share, or an `@[actor-id]` the board doesn't know, fails the
120
- * write. `lenient` is for platform text: no mention fails it, and one that
121
- * doesn't resolve stays plain text. Without `candidates`, an ambiguous mention
122
- * doesn't list who it could be: a caller that can't read every channel can't
123
- * list actors either.
124
- */
125
- function resolveMentions(text, known, pending, lenient = false, candidates = true) {
126
- const resolved = [];
127
- const unknown = [];
128
- const add = (id) => {
129
- if (!resolved.includes(id)) resolved.push(id);
130
- };
131
- const fail = (error) => {
132
- if (!lenient) throw error;
133
- };
134
- for (const token of extractMentions(text)) {
135
- if (token.kind === "actor") {
136
- if (isActorId(token.actor) && own(known.byId, token.actor) || pending?.id === token.actor) add(token.actor);
137
- else fail(badRequest(`unknown actor @[${token.actor}]`, "unknown_mention"));
138
- continue;
139
- }
140
- const ids = new Set(own(known.byHandle, token.handle) ?? []);
141
- if (pending && pending.handle.toLowerCase() === token.handle) ids.add(pending.id);
142
- if (ids.size === 1) add([...ids][0]);
143
- else if (ids.size === 0) unknown.push(token.handle);
144
- else if (!candidates) fail(badRequest(`ambiguous mention @${token.handle}: use @[actor-id]`, "ambiguous_mention"));
145
- else {
146
- const options = [...ids].map((id) => `@[${id}] (${own(known.byId, id)?.name ?? pending?.name ?? id})`).join(" or ");
147
- fail(badRequest(`ambiguous mention @${token.handle}: use ${options}`, "ambiguous_mention"));
148
- }
149
- }
150
- return {
151
- mentions: resolved,
152
- unknown: lenient ? [] : unknown
153
- };
154
- }
155
- //#endregion
156
- export { resolveMentions as a, resolveActor as i, actorSeen as n, claimsOf as r, KNOWN_AGENTS as t };
@@ -1,4 +0,0 @@
1
- //#region src/inspect/digest.ts
2
- const PAGE_SHA256 = "831fda9c440268389bdc650983308eeab1265b2f09035633f6f9d7a229636cc5";
3
- //#endregion
4
- export { PAGE_SHA256 as t };
@@ -1,4 +0,0 @@
1
- import "./routes-BffuaoTX.mjs";
2
- import "./auth-BXLCkeB0.mjs";
3
- import "./backend-HcCCGPG4.mjs";
4
- import "./provider-D5yVFisj.mjs";
@@ -1,2 +0,0 @@
1
- import { t as inspect } from "./inspect-BkXxR2uB.mjs";
2
- export { inspect };
@@ -1,2 +0,0 @@
1
- import { t as page } from "./page-64IwoGRu.mjs";
2
- export { page };