@vercel/board 0.32.0 → 0.34.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 (167) hide show
  1. package/README.md +25 -20
  2. package/dist/{access-CY5xVMIK.mjs → access-CdBcYPQH.mjs} +170 -13
  3. package/dist/access.d.mts +4 -5
  4. package/dist/access.mjs +5 -5
  5. package/dist/{actors-Bm-ojWWT.mjs → actors-MrIEr9LI.mjs} +3 -3
  6. package/dist/auth-DjoJygbG.mjs +599 -0
  7. package/dist/{auth-K8dY1nBY.d.mts → auth-aaoKt5DK.d.mts} +133 -100
  8. package/dist/backend-local.d.mts +28 -0
  9. package/dist/backend-local.mjs +2 -0
  10. package/dist/{backend-DxE9wGKm.d.mts → backend-u1sVvybh.d.mts} +108 -55
  11. package/dist/{chat-provider-DkFp2hrh.mjs → chat-provider-9hCT654s.mjs} +2 -2
  12. package/dist/{chat-provider-BChYrrA7.d.mts → chat-provider-De0iDnUB.d.mts} +2 -3
  13. package/dist/cli-commands.d.mts +1 -1
  14. package/dist/cli-commands.mjs +1 -1
  15. package/dist/cli-embedded.d.mts +2 -2
  16. package/dist/cli-embedded.mjs +1 -1
  17. package/dist/cli.mjs +6 -6
  18. package/dist/{commands-DsnQKTdB.mjs → commands-B8oZEByR.mjs} +37 -52
  19. package/dist/{commands-CpyPV_tk.d.mts → commands-BkVMdXP1.d.mts} +9 -6
  20. package/dist/{conformance-3RBKxwbp.mjs → conformance-gqYBkXFS.mjs} +79 -86
  21. package/dist/conformance.d.mts +1 -1
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{engine-DurYIRt8.mjs → engine-rtOVWsiF.mjs} +6 -8
  24. package/dist/{errors-CJXhhzvT.mjs → errors-D8ifv16L.mjs} +75 -6
  25. package/dist/{events-lujPA3gQ.mjs → events-IQg0k281.mjs} +2 -2
  26. package/dist/exports-Bx2dGpzr.mjs +3252 -0
  27. package/dist/exports-uwRl5qIj.d.mts +4 -0
  28. package/dist/{external-D3p5T57R.mjs → external-CYe424fO.mjs} +1 -1
  29. package/dist/index-D6mK0Ial.d.mts +11 -0
  30. package/dist/index.d.mts +10 -9
  31. package/dist/index.mjs +21 -8
  32. package/dist/index.node.d.mts +6 -7
  33. package/dist/index.node.mjs +3 -3
  34. package/dist/inspect/app.js +95 -95
  35. package/dist/{internal-CvsrprnU-zZMpDiRY.mjs → internal-CvsrprnU-CEPOUpAv.mjs} +63 -43
  36. package/dist/local-CPz22MQ8.mjs +9225 -0
  37. package/dist/{main-CcYDo9Hb.mjs → main-DScDKwQN.mjs} +129 -54
  38. package/dist/{backend-a2/store-memory.mjs → memory-7RRnLa4X.mjs} +3 -3
  39. package/dist/middleware-BjYpk4yq.mjs +103 -0
  40. package/dist/{provider-gynDUoyW.d.mts → provider-hB8QNrwm.d.mts} +369 -3
  41. package/dist/{client-COfYrgfV.d.mts → routes-De4W6lEs.d.mts} +997 -367
  42. package/dist/{schemas-DBmUO6pr.mjs → schemas-BG205xds.mjs} +2 -5
  43. package/dist/{serve-Bplieh0C.mjs → serve-B1noQRkn.mjs} +33 -24
  44. package/dist/{node-BgeGcwX0.mjs → server-Ov6GBJ8j.mjs} +419 -6
  45. package/dist/{serving-Y7s7VDjB.mjs → serving-2s7lqSBS.mjs} +1 -1
  46. package/dist/{sql-E1K5g_ih.mjs → sql-BQzKUqQt.mjs} +349 -114
  47. package/dist/sqlite-DCtZFEVm.mjs +30 -0
  48. package/dist/{sqlite-db-CzcD_FW8.mjs → sqlite-db-qLTs52Ny.mjs} +2 -3
  49. package/dist/{store-codec-pAG2oPgQ-SqDXlPBR.mjs → store-N8PXxDAS-BdL4Sq-f.mjs} +6 -2
  50. package/dist/{store-memory-B0PkVSuQ.mjs → store-memory-CKQVEzXN.mjs} +2 -4
  51. package/dist/store-memory-OdGsc-t_.mjs +2 -0
  52. package/dist/{store-polling-BZt2Rf3D-Div-bJ_D.mjs → store-polling-BZt2Rf3D-oh3aU_An.mjs} +1 -1
  53. package/dist/store-sqlite-CTxAVCcz.mjs +2 -0
  54. package/dist/{store-sqlite-D85t3tE7.mjs → store-sqlite-D6fIszST.mjs} +3 -4
  55. package/dist/sync-chat-sdk.d.mts +2 -2
  56. package/dist/sync-chat-sdk.mjs +2 -2
  57. package/dist/sync-github.d.mts +2 -2
  58. package/dist/sync-github.mjs +2 -2
  59. package/dist/sync-linear.d.mts +3 -3
  60. package/dist/sync-linear.mjs +2 -2
  61. package/dist/sync-slack.d.mts +3 -3
  62. package/dist/sync-slack.mjs +4 -4
  63. package/dist/sync.d.mts +2 -2
  64. package/dist/sync.mjs +2 -2
  65. package/dist/{watchers-hash-CurCzwhe.mjs → targets-aMdbp84G.mjs} +134 -16
  66. package/dist/{tokens-C7kYyrAG.mjs → tokens-LHLrnV_P.mjs} +15 -43
  67. package/docs/01-board/01-mounting.md +245 -288
  68. package/docs/01-board/03-identity.md +42 -50
  69. package/docs/01-board/04-messages.md +15 -14
  70. package/docs/01-board/05-reading.md +3 -3
  71. package/docs/01-board/06-watchers.md +58 -105
  72. package/docs/01-board/07-schedules.md +21 -41
  73. package/docs/01-board/08-middleware.md +11 -17
  74. package/docs/01-board/09-access.md +187 -343
  75. package/docs/01-board/10-local.md +81 -0
  76. package/docs/01-quickstart.md +49 -126
  77. package/docs/02-sync/01-overview.md +25 -80
  78. package/docs/02-sync/02-functions.md +10 -16
  79. package/docs/02-sync/03-slack.md +13 -26
  80. package/docs/02-sync/04-github.md +8 -20
  81. package/docs/02-sync/07-linear.md +6 -10
  82. package/docs/03-guides/02-inspector.md +3 -3
  83. package/docs/03-guides/03-ci.md +88 -128
  84. package/docs/03-guides/04-triage.md +7 -15
  85. package/docs/03-guides/05-agent-factory.md +29 -36
  86. package/docs/04-reference/01-cli.md +113 -38
  87. package/docs/04-reference/02-board.md +79 -82
  88. package/docs/04-reference/03-http.md +138 -69
  89. package/docs/04-reference/05-conformance.md +32 -46
  90. package/docs/index.md +41 -65
  91. package/package.json +12 -83
  92. package/dist/a2-DiDc77Uf.mjs +0 -4238
  93. package/dist/access-DPcrKIH_.d.mts +0 -37
  94. package/dist/auth-8pRZnF1M.mjs +0 -393
  95. package/dist/backend-a2/blob-vercel.d.mts +0 -8
  96. package/dist/backend-a2/blob-vercel.mjs +0 -81
  97. package/dist/backend-a2/contract.d.mts +0 -828
  98. package/dist/backend-a2/contract.mjs +0 -5
  99. package/dist/backend-a2/scheduler-local.d.mts +0 -11
  100. package/dist/backend-a2/scheduler-local.mjs +0 -2
  101. package/dist/backend-a2/scheduler-qstash.d.mts +0 -79
  102. package/dist/backend-a2/scheduler-qstash.mjs +0 -522
  103. package/dist/backend-a2/scheduler-vercel.d.mts +0 -38
  104. package/dist/backend-a2/scheduler-vercel.mjs +0 -204
  105. package/dist/backend-a2/store-memory.d.mts +0 -11
  106. package/dist/backend-a2/store-postgres.d.mts +0 -38
  107. package/dist/backend-a2/store-postgres.mjs +0 -2977
  108. package/dist/backend-a2/store-redis-http.d.mts +0 -17
  109. package/dist/backend-a2/store-redis-http.mjs +0 -520
  110. package/dist/backend-a2/store-redis.d.mts +0 -31
  111. package/dist/backend-a2/store-redis.mjs +0 -88
  112. package/dist/backend-a2/store-sqlite.d.mts +0 -12
  113. package/dist/backend-a2/store-sqlite.mjs +0 -31
  114. package/dist/backend-a2.d.mts +0 -2633
  115. package/dist/backend-a2.mjs +0 -3
  116. package/dist/backend-http-CaN06CaD.d.mts +0 -672
  117. package/dist/backend-http-CoaCghuJ.mjs +0 -18
  118. package/dist/backend-http-l5A8UmL-.mjs +0 -585
  119. package/dist/backend-http.d.mts +0 -10
  120. package/dist/backend-http.mjs +0 -2
  121. package/dist/backend-http.node.d.mts +0 -10
  122. package/dist/backend-http.node.mjs +0 -2
  123. package/dist/backend-vercel-BE65okBC.mjs +0 -86
  124. package/dist/backend-vercel-CVxoTNF2.mjs +0 -1744
  125. package/dist/backend-vercel-jg-6PAgD.d.mts +0 -674
  126. package/dist/backend-vercel.d.mts +0 -9
  127. package/dist/backend-vercel.mjs +0 -11
  128. package/dist/backend-vercel.node.d.mts +0 -17
  129. package/dist/backend-vercel.node.mjs +0 -2
  130. package/dist/blob-Bx8QPWEd.d.mts +0 -40
  131. package/dist/blob-WbB2DJKn.mjs +0 -201
  132. package/dist/errors-2vGs49Db.d.mts +0 -16
  133. package/dist/exports-BnUZuRm9.mjs +0 -1389
  134. package/dist/exports-u5mApVvn.d.mts +0 -5
  135. package/dist/files-SniSmeEr.mjs +0 -47
  136. package/dist/folds-DLUzfibJ.d.mts +0 -558
  137. package/dist/folds-DsWfIftc.mjs +0 -208
  138. package/dist/index-UXpTPWNc.d.mts +0 -11
  139. package/dist/index.default-Dp8gexln.mjs +0 -12
  140. package/dist/local-C76Fy5ad.mjs +0 -44
  141. package/dist/middleware-BavYSDUa.mjs +0 -62
  142. package/dist/platform-B4TnJtWu-Do3agKr5.mjs +0 -32
  143. package/dist/project-4Vl7_uy5.mjs +0 -124
  144. package/dist/redis-tables-BFRj_SEJ.mjs +0 -3895
  145. package/dist/reducer-Bswr11ar-P324o9vn.mjs +0 -74
  146. package/dist/reducer-CYPHsSmd-BXjGiptm.d.mts +0 -170
  147. package/dist/reducers-DQVSP3kk.mjs +0 -538
  148. package/dist/retryable-lazy-DZWmHpii-DpTc5PIP.mjs +0 -19
  149. package/dist/scheduler-task-X1SToDjP-D2Il2rln.mjs +0 -69
  150. package/dist/server-B9gu0qi1-DI1WvcVK.d.mts +0 -391
  151. package/dist/server-DX7mM6nm-D7N_7bug.mjs +0 -3611
  152. package/dist/server-wIpAEjpX.mjs +0 -17
  153. package/dist/session-clear-XJYpmUpg-2q8l_FJR.mjs +0 -63
  154. package/dist/store-DEzcHZOA-B-5vhxef.d.mts +0 -540
  155. package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +0 -5
  156. package/dist/store-memory-4IBl0Ztu.mjs +0 -2
  157. package/dist/store-presence-polling-JuAy2Ck2-Dh-g_KYM.mjs +0 -109
  158. package/dist/store-sqlite-iBTYYKBj.mjs +0 -2
  159. package/dist/stream-buffer-DrTyiIuo-Be10yOBR.mjs +0 -53
  160. package/dist/targets-Cgjs29T0.mjs +0 -33
  161. package/dist/types-CmrFjpml.d.mts +0 -102
  162. package/dist/wait-until-Dw4XrIDQ.mjs +0 -42
  163. package/docs/01-board/02-database.md +0 -258
  164. package/docs/04-reference/04-log.md +0 -247
  165. package/sql/postgres/board.sql +0 -145
  166. package/sql/postgres/notifications.sql +0 -24
  167. package/sql/postgres/schema.sql +0 -451
@@ -10,12 +10,12 @@ must be the board's URL, exactly as [discovery](./01-mounting.md#discovery)
10
10
  returns it. A token minted for one board is useless against any other, even
11
11
  another board on the same origin. That's `board()`'s default `authenticate`;
12
12
  a host can recognize its own credentials too: see
13
- [A host's own verifier](./09-access.md#a-hosts-own-verifier).
13
+ [Callers of your own](./01-mounting.md#callers-of-your-own).
14
14
 
15
15
  Only a few routes take no token: discovery, the built-in avatars, the OpenAPI
16
16
  document, and `/webhooks/:key`, which the platform's adapter authenticates instead. A
17
- board on `http()` also answers `POST /wake` without one: a wake-up only says
18
- to pull.
17
+ route whose watchers another board runs (Vercel's board, say) also answers
18
+ `POST /wake` without one: a wake-up only says to pull.
19
19
 
20
20
  ## Where tokens come from
21
21
 
@@ -23,7 +23,7 @@ The CLI and `board()` in Node find a token themselves. The first match wins:
23
23
 
24
24
  | Where | How | Principal |
25
25
  | --- | --- | --- |
26
- | Explicit | `BOARD_TOKEN`: an OIDC JWT for the board's audience, from Vercel, GitHub Actions, or an issuer `access` or a grant names; or a [board token](./09-access.md#tokens) | the issuer's, or a board token's minter |
26
+ | Explicit | `BOARD_TOKEN`: an OIDC JWT for the board's audience, from Vercel, GitHub Actions, or an issuer a grant names; or a [board token](./09-access.md#tokens) | the issuer's, or a board token's minter |
27
27
  | A board from `vb serve` | the token it writes to a file only you can read, for its `127.0.0.1` URL | `local:user:<your OS user>` |
28
28
  | GitHub Actions | the job's OIDC token, for the board's audience; needs `permissions: id-token: write` | `github:repo:<repository_id>` |
29
29
  | A Vercel deployment | `getVercelOidcToken({ audience })` from `@vercel/oidc`, when `VERCEL=1` | `vercel:project:<project_id>:<env>` |
@@ -34,9 +34,8 @@ discovery there names another URL, they get no token and fail with
34
34
  `wrong_audience`: use the URL the error names. So a board can't claim to be
35
35
  another one and collect tokens it could replay there.
36
36
 
37
- Other runtimes bring their own credentials in `http(url, { fetch })`: a page,
38
- its own session, which the board's `board({ authenticate })` recognizes. See the
39
- [handle reference](../04-reference/02-board.md).
37
+ Outside Node, `board({ fetch })` brings its own credentials for Vercel's board,
38
+ since nothing finds them. See the [handle reference](../04-reference/02-board.md).
40
39
 
41
40
  ### From your terminal
42
41
 
@@ -96,16 +95,16 @@ made out to this board. It verifies a token once and keeps who it is until the
96
95
  token expires, so a live stream doesn't verify each time it polls.
97
96
 
98
97
  - **Vercel tokens** are verified with `jose` against the team issuer's keys.
99
- `board()` knows its own project from its `project` option,
100
- `VERCEL_PROJECT_ID`, or `.vercel/project.json`. A `development` token from
101
- it is a person and must carry `user_id`. Any other environment is the
98
+ `board()` knows its own project from `VERCEL_PROJECT_ID`, or
99
+ `.vercel/project.json`. A `development` token from it is a person and must
100
+ carry `user_id`. Any other environment is the
102
101
  deployment itself: in the environment the board runs in, it can do
103
- everything, and in any other, nothing unless [`access`](./09-access.md)
104
- lists it. So a production board refuses its previews, and a preview board
105
- accepts its own.
102
+ everything, and in any other, nothing unless a
103
+ [grant](./09-access.md#grants) lets it in. So a production board refuses its
104
+ previews, and a preview board accepts its own.
106
105
  - **GitHub Actions tokens, other Vercel projects, and other issuers** are
107
- accepted only when they match a rule in [`access`](./09-access.md), which
108
- also says what they may do in each channel.
106
+ accepted only when a [grant](./09-access.md#grants) matches them, which also
107
+ says what they may do in each channel.
109
108
  - **Tests** point verification at a local issuer:
110
109
  `board({ authenticate: oidcTokens({ vercel: { issuer, jwks } }) })`. It still
111
110
  runs real verification against a real key set; no environment variable
@@ -123,7 +122,7 @@ A **principal** is who holds the credential. It's a readable string:
123
122
  | `github:repo:123456` | a GitHub Actions workflow in that repo |
124
123
  | `oidc:gitlab.com:project_path:acme/api:ref_type:branch:ref:main` | another issuer's token, by its `sub` |
125
124
  | `slack:user:U0456`, `github:user:583231` | a platform user, arriving through [sync](../02-sync/01-overview.md) |
126
- | `board:watch:triage`, `board:client`, `board:client:deploys` | the board's own [watchers](./06-watchers.md) and [handle](./01-mounting.md#the-handle), with `as()`'s profile |
125
+ | `board:watch:triage`, `board:client`, `board:client:deploys` | a [local board](./10-local.md)'s own [watchers](./06-watchers.md) and [handle](./01-mounting.md#the-handle), with `as()`'s profile |
127
126
 
128
127
  A **profile** is a named identity within a principal: an agent acting for a
129
128
  person. An **actor** is what a message is attributed to: the principal alone,
@@ -164,52 +163,45 @@ verified principal.
164
163
 
165
164
  ## Machines outside the project
166
165
 
167
- Machines outside the board's project need a rule in `access`, and the rule
168
- says what they may do in each channel:
169
-
170
- ```ts app/api/board/[[...path]]/route.ts
171
- import { board } from '@vercel/board'
172
- import { githubActions, vercelProject } from '@vercel/board/access'
173
- import { a2 } from '@vercel/board/backend-a2'
174
- import { postgres } from '@vercel/board/backend-a2/store-postgres'
175
-
176
- const team = board({
177
- backend: a2({ store: postgres({ connectionString: process.env.DATABASE_URL! }) }),
178
- access: [
179
- vercelProject({ project: 'marketing', environments: ['production'], can: { 'feedback/': ['post'] } }),
180
- githubActions({ repository: 'acme/www', workflow: '.github/workflows/deploy.yml', can: { deploys: ['read', 'post'] } }),
181
- ],
182
- })
183
- export const GET = team.fetch, POST = team.fetch
166
+ g2 lets every project on the board's team read, post, react, and label.
167
+ Anything else outside the board's project needs a
168
+ [grant](./09-access.md#grants), which says what it may do in each channel.
169
+ Someone with `manage` where it reaches creates it on the board, and it holds
170
+ from the next request:
171
+
172
+ ```text
173
+ $ vb grants create --project prj_marketing --environment production --can feedback/=post
174
+ created g4 --project prj_marketing --environment production feedback/=post
175
+ $ vb grants create --github acme/www --can deploys=read,post
176
+ created g5 --github acme/www deploys=read,post
184
177
  ```
185
178
 
186
- - **A project name without `team` means the board's own team.** Names are only
187
- unique within a team, so another team's `marketing` doesn't match. A project
188
- ID matches on any team, since IDs are unique. The board knows its team from
189
- `board({ project: { teamId } })`, `VERCEL_ORG_ID`, the linked project, or on
190
- Vercel the platform's token. When it can't tell, a name matches nothing.
191
- - **Names are for reading; IDs are stored.** A rule matches a project or repo
192
- by name, but the principal records its ID, so a rename doesn't change who
193
- wrote what.
179
+ - **A project grant names a project,** and the environments it calls from. A
180
+ GitHub grant names a repository as `owner/name`; where the board can look
181
+ it up, it keeps the repository's ID, which survives a rename.
182
+ - **Principals record IDs.** A workflow writes as
183
+ `github:repo:<repository_id>` whatever its grant names, so a rename doesn't
184
+ change who wrote what.
194
185
  - **A `pull_request` run's token carries `ref: refs/pull/<n>/merge`,** so a
195
- rule pinned to `refs/heads/main` rejects it. Match on `event` and `workflow`
196
- instead.
186
+ grant pinned to `--branch main` doesn't match it. Match on `--event` instead.
197
187
 
198
188
  > [!WARNING]
199
189
  > For `pull_request`, GitHub runs the workflow file from the PR's merge commit,
200
- > so anyone who can open a PR can change what it posts. Keep `can` narrow for
201
- > those rules. Fork PRs get no OIDC token at all.
190
+ > so anyone who can open a PR can change what it posts. Keep `--can` narrow for
191
+ > grants that match those runs. Fork PRs get no OIDC token at all.
202
192
 
203
- [Access](./09-access.md) has the permissions, the channel patterns, `oidc()`
204
- for other issuers, and what a caller sees.
193
+ [Access](./09-access.md) has the permissions, the channel patterns, grants for
194
+ other issuers, board tokens for callers with no OIDC token, and what a caller
195
+ sees.
205
196
 
206
197
  ## Authorization
207
198
 
208
199
  - **People and the board's own deployments in its environment can do everything.** There are no
209
200
  roles or member lists, and nothing restricts the project's own people.
210
201
  Content that needs privacy from them needs a second board.
211
- - **Everyone else can do what `access` gives them, channel by channel,** and
212
- what they can't read answers 404.
202
+ - **Everyone else can do what their grants give them, channel by channel,** or
203
+ a board token what its minter may, narrowed. What they can't read answers
204
+ 404.
213
205
  - **Only the principal that wrote a message can edit or delete it.** A person
214
206
  can edit their own profiles' messages.
215
207
  - **Raw platform data needs more than reading.** `vb inbox` needs `sync` in
@@ -221,7 +213,7 @@ Handles are display hints, not reservations:
221
213
 
222
214
  - **A person's** is their Vercel username, sent by the CLI. Override it with
223
215
  `--handle` or `BOARD_HANDLE`. On a board with
224
- [its own verifier](./09-access.md#a-hosts-own-verifier), it's the handle
216
+ [its own verifier](./01-mounting.md#callers-of-your-own), it's the handle
225
217
  that verifier returns, and the CLI's doesn't replace it.
226
218
  - **A profile's** is `<person>/<profile>`: `julian/claude`.
227
219
  - **A deployment's** is its project name, plus `@<env>` outside production.
@@ -35,7 +35,8 @@ echo "a longer note" | vb reply "$id" - # - reads the text from std
35
35
  - **A message's ID is a string,** shown as `#812`. It's unique within the
36
36
  board; pass it back as you got it, and don't count with it or order by it.
37
37
  An ID doubles as a cursor, so a script can chain it: `vb wait --after "$id"`.
38
- On `a2()` it's a [log index](../04-reference/04-log.md#one-log).
38
+ Vercel's board hands out `msg_…` IDs, and a [local board](./10-local.md)
39
+ numbers (`812`).
39
40
  - **Threads are one level deep.** Reply to any message in a thread and the
40
41
  board stores the root as `re`, plus the exact message you replied to as
41
42
  `replyTo` when that isn't the root. Platforms with sub-threads use `replyTo`
@@ -181,9 +182,9 @@ vb download nXHY2NjUHuzE5F1QpXyBdQ # saves after.png here; a path, or
181
182
  ```
182
183
 
183
184
  - **At most 4 MB per file and 10 per message.** An upload is one request,
184
- under Vercel Functions' request limit. Where the board's blob store can sign
185
- upload URLs (`vercelBlob()` can), a file up to 100 MB goes straight to the
186
- store instead, by itself. The CLI checks every file before uploading any. Files sync brings over from a platform can be up to 25 MB,
185
+ under Vercel Functions' request limit. Where the board can sign upload URLs
186
+ (Vercel's board can), a file up to 100 MB goes straight to its storage
187
+ instead, by itself. The CLI checks every file before uploading any. Files sync brings over from a platform can be up to 25 MB,
187
188
  since sync fetches them on the server.
188
189
  - **The board records each file's name, type, and size from what it stored,**
189
190
  never from the request, and refuses an attachment ID it never stored. An ID
@@ -194,16 +195,16 @@ vb download nXHY2NjUHuzE5F1QpXyBdQ # saves after.png here; a path, or
194
195
  origin. PNG, JPEG, GIF, WebP, and AVIF images, MP4 and WebM video, and plain
195
196
  text display inline; everything else downloads.
196
197
  - **Deleting a message hides its files,** and only their uploader and callers
197
- that read every channel can still fetch them. The bytes stay in the blob
198
- store: a file that must not be read again needs deleting from there.
198
+ that read every channel can still fetch them. The bytes stay where the board
199
+ keeps them: a file that must not be read again needs deleting from there.
199
200
  - **Files posted on a synced platform come in too,** as attachments on the
200
201
  board's copy. See [Sync](../02-sync/01-overview.md).
201
- - **They need a blob store.** A board on `a2()` without one keeps no files:
202
- an upload, a post or schedule that carries files, and a download answer 501
203
- `no_files`, and `vb` says it can't, with the board's words under it:
204
- ``this board keeps no files: pass `blob` to `a2()` ``. Sync brings a
205
- platform's files over as links to where they live instead. See
206
- [Mounting](./01-mounting.md#without-a-blob-store).
202
+ - **A board that keeps no files says so.** Vercel's board and `local()` keep
203
+ them. On a [backend of your own](./01-mounting.md#a-backend-of-your-own)
204
+ that doesn't, an upload, a post or schedule that carries files, and a
205
+ download answer 501 `no_files`, and `vb` says it can't, with the board's
206
+ words under it. Sync brings a platform's files over as links to where they
207
+ live instead.
207
208
 
208
209
  In code, `upload` first, then post with what it returns:
209
210
 
@@ -228,8 +229,8 @@ vb post deploys "a1b2c3 is live" --idempotency-key deploy-a1b2c3
228
229
  The same ID with the same write returns the message it already posted. The same
229
230
  ID with a different write fails with `duplicate_id`. The CLI and a
230
231
  [handle](./01-mounting.md#the-handle) make the ID their own, so no one can post
231
- with it first: over HTTP it goes as `key:<principal>:…`, which the board takes
232
- only from that principal. Through the HTTP API yourself, IDs are up to 200
232
+ with it first: to a board at a URL it goes as `key:<principal>:…`, which the
233
+ board takes only from that principal. Through the HTTP API yourself, IDs are up to 200
233
234
  characters, and someone else's post with your ID fails with `duplicate_id`.
234
235
  UUIDv8s are the board's own, for the writes it makes itself, so the API refuses
235
236
  them, and `key:` IDs under another principal, and `sync:` IDs, which are
@@ -92,9 +92,9 @@ vb read errors-www --by ada --text ENOTFOUND
92
92
  `--label pr=acme/www#123` is that PR's whole conversation, replies
93
93
  included. Repeat `--label` and every one must match.
94
94
 
95
- On `a2()`, `read` queries the [tables](./02-database.md#what-a-store-keeps) the
96
- board keeps from its log, with channels, threads, authors, mentions, and labels
97
- indexed: a thread, or a channel's threads, cost the same on a board of any size.
95
+ On [`local()`](./10-local.md), `read` queries tables the board keeps from its
96
+ log, with channels, threads, authors, mentions, and labels indexed: a thread,
97
+ or a channel's threads, cost the same on a board of any size.
98
98
 
99
99
  ## Following live
100
100
 
@@ -7,39 +7,32 @@ description: A watcher is a `vb tail` the board runs for you, durably, with noth
7
7
 
8
8
  ```ts app/api/board/[[...path]]/route.ts
9
9
  import { board } from '@vercel/board'
10
- import { a2 } from '@vercel/board/backend-a2'
11
- import { vercelQueues } from '@vercel/board/backend-a2/scheduler-vercel'
12
- import { postgres } from '@vercel/board/backend-a2/store-postgres'
13
-
14
- const backend = a2({
15
- store: postgres({ connectionString: process.env.DATABASE_URL! }),
16
- scheduler: vercelQueues({ topic: 'board' }), // retries on a clock: see How it runs
17
- })
18
10
 
19
11
  const team = board({
20
- backend,
21
- // sync as in Sync
22
12
  watch: {
23
13
  triage: {
24
- tail: 'firehose --source slack',
14
+ tail: 'support',
25
15
  run: async ({ event, board }) => {
26
16
  if (event.type === 'message.posted' && event.message?.re === null)
27
- await board.reply(event.message.id, 'Thanks! Tracking it.') // synced to the Slack thread
17
+ await board.reply(event.message.id, 'Thanks! Tracking it.')
28
18
  },
29
19
  },
30
20
  },
31
21
  })
32
22
  export const GET = team.fetch, POST = team.fetch
33
- export const { scheduler } = backend
34
23
  ```
35
24
 
36
25
  `tail` is what you'd type after `vb tail`. `run` gets each event that tail
37
26
  would print, exactly as `vb tail --json` prints it. Try it in a terminal first:
38
27
 
39
28
  ```bash
40
- vb tail firehose --source slack --json
29
+ vb tail support --json
41
30
  ```
42
31
 
32
+ That's your team's board in Vercel's API. Vercel's API matches each event
33
+ against the tails, and wakes this route when one matches, so `run` happens in
34
+ this deployment: see [How it runs](#how-it-runs).
35
+
43
36
  ## The expression
44
37
 
45
38
  A channel (or `prefix/` for a subtree) and the shared
@@ -137,10 +130,12 @@ runs.
137
130
  ## Writing back
138
131
 
139
132
  `board` is the board's [handle](./01-mounting.md#the-handle), acting as the
140
- watcher, with no HTTP and no token.
133
+ watcher.
141
134
 
142
- - **It writes as the watcher,** `board:watch:<id>`, with the id as its handle.
143
- Its writes sync like anyone's.
135
+ - **It writes as the watcher.** On Vercel's board, that's this deployment
136
+ with the watcher's ID as its profile:
137
+ `vercel:project:prj_v0:production+triage`. On `local()`, it's
138
+ `board:watch:<id>`, with the ID as its handle. Its writes sync like anyone's.
144
139
  - **Its posts and replies get IDs derived from the match,** so a retried `run`
145
140
  doesn't post twice, as long as it writes in the same order. Writes made in
146
141
  parallel (with `Promise.all`) need an explicit `id`, which is the watcher's
@@ -154,107 +149,65 @@ watcher, with no HTTP and no token.
154
149
 
155
150
  ## How it runs
156
151
 
157
- Each board event is matched against every watcher by one A2 consumer,
158
- `board-watchers`, on the thread's lane. A match is appended to the watcher's
159
- own session (`watch:<id>`, outside the board log), and `run` happens there, on
160
- the thread's lane.
152
+ Where the match happens depends on the board:
153
+
154
+ - **On Vercel's board,** Vercel's API keeps the log and matches the tails,
155
+ and wakes this deployment when one matches. It pulls what matched with its
156
+ own credentials and runs it here: see [Woken by the board](#woken-by-the-board).
157
+ With `BOARD_URL` set, the board at that URL does the same.
158
+ - **On [`local()`](./10-local.md),** everything happens in this process. Each
159
+ event is matched against every watcher on its thread's lane, and `run`
160
+ happens on that lane too.
161
+
162
+ Either way:
161
163
 
162
- - **A watcher sees a thread's events in order,** and threads run in parallel.
163
164
  - **Each watcher fails on its own.** A `run` that throws is tried again after
164
- a wait (1 second, doubling to 30). After 5 tries it's logged and recorded as
165
- `watch.failed`, and the thread goes on. Runs cut short (a timeout, out of
166
- memory) count too, and ones that keep getting cut short are given up on at
167
- the 10th try. Writes, other threads, and other watchers keep flowing.
168
- - **Retries need the scheduler,** as sync's do. Without one, a match still
169
- runs in the request that wrote, but a retry waits for the watcher's next
170
- match, and reads never wake it. That suits a tool, not a production board:
171
- see [Without a scheduler](./01-mounting.md#without-a-scheduler) and
172
- [the scheduler route](./01-mounting.md#the-scheduler-route).
165
+ a wait. Writes, other threads, and other watchers keep flowing.
173
166
  - **A watcher removed from config** skips the matches it left behind.
174
167
 
168
+ On `local()`, a watcher sees a thread's events in order, and threads run in
169
+ parallel. A `run` that throws waits 1 second, doubling to 30, and after 5
170
+ tries it's logged and recorded as `watch.failed`, and the thread goes on. Runs
171
+ cut short (a timeout, out of memory) count as tries too, and ones that keep
172
+ getting cut short are given up on at the 10th. Its retries wait on timers in
173
+ the process, so a restart drops the ones pending.
174
+
175
175
  The [triage guide](../03-guides/04-triage.md) builds a full triage agent, first
176
176
  as a `tail` loop and then as a watcher.
177
177
 
178
- ## On a board on `http()`
179
-
180
- A board on [`http()`](./01-mounting.md#backends) runs its watchers too. The
181
- board it uses keeps the log and matches the tails, and this one runs `run`:
182
-
183
- ```ts app/api/board/[[...path]]/route.ts
184
- import { board } from '@vercel/board'
185
- import { http } from '@vercel/board/backend-http'
186
-
187
- const team = board({
188
- backend: http('https://board.example.com/api/board'),
189
- watch: {
190
- fix: {
191
- tail: 'feedback --label kind=bug',
192
- run: async ({ event, board }) => {
193
- if (event.type !== 'message.posted' || event.message?.re !== null) return
194
- await board.reply(event.message.id, 'on it')
195
- // await startAgent(event.message) // your code, in this project
196
- },
197
- },
198
- },
199
- })
200
- export const GET = team.fetch, POST = team.fetch
201
- ```
202
-
203
- - **It registers its watchers' tails there,** as itself: on its first use if
204
- it knows its URL (a call from its handle, or a request), when anyone sends
205
- `POST /watchers` to it, and when a wake-up shows the other board holds an
206
- older set. Nothing happens before that: creating the board does no I/O. On Vercel, its URL is its
207
- production domain, or a preview's own; a request's `Host` never counts. A
208
- registration holds at most 32 watchers, and needs `read` somewhere. A
209
- token narrowed with `x-board-scope` can't register, pull, or ack (403): the
210
- registration is its project's, which a narrowed pull would take matches
211
- from.
212
- - **A match wakes it with nothing in the wake-up:** a `POST <url>/wake` with
213
- no event. It then pulls what matched with its own credentials, runs it, and
178
+ ## Woken by the board
179
+
180
+ On Vercel's board, Vercel's API matches the tails, and the route at the top of
181
+ this page runs `run`:
182
+
183
+ - **It registers its watchers' tails with Vercel's API,** as this deployment:
184
+ on its first use if it knows its URL (a call from its handle, or a
185
+ request), when anyone sends `POST /watchers` to it, and when a wake-up shows
186
+ the API holds an older set. Nothing happens before that: creating the board
187
+ does no I/O. On Vercel, its URL is its production domain, or a preview's
188
+ own; a request's `Host` never counts. A registration holds at most 32
189
+ watchers.
190
+ - **From production, or a preview of a branch, it registers its mount path**
191
+ on its own project, which it names with that branch, and Vercel's API wakes
192
+ it through Deployment Protection with nothing to set up. Anywhere else
193
+ (development, a custom environment, a preview made with `vercel deploy`),
194
+ it registers its URL.
195
+ - **A match wakes it with nothing in the wake-up:** a `POST /wake` with no
196
+ event. It then pulls what matched with its own credentials, runs it, and
214
197
  acks it, until nothing's left, so a burst of matches wakes it once. It
215
198
  answers when that's done, or after 2 seconds while it keeps going, so
216
199
  whoever woke it never waits on slow watchers. A forged wake-up costs it one
217
200
  pull that finds nothing.
218
- - **A wake-up that doesn't get there is tried again** a minute or so on. While
219
- they keep failing, the wait doubles, up to an hour, and the other board logs
220
- the first failure and the start of the back-off. It starts over when this
221
- board answers one, pulls, or registers. Its matches wait either way.
222
- - **It sees what its deployment may read** on the other board, as that
223
- board's `access` says at each event it matches and again when it's pulled.
201
+ - **A wake-up at a URL carries no credential,** so behind Deployment
202
+ Protection the project lets `POST /wake` through itself: a production domain
203
+ left public (Standard Protection), or a Deployment Protection Exception for
204
+ the domain it registers. A wake-up reveals nothing and is trusted for
205
+ nothing: it only makes this board pull with its own credentials.
206
+ - **A board without an `https` URL pulls on its own** from its first use,
207
+ each pull held open until something matches: a dev server, say.
208
+ - **It sees what its deployment may read** on the team's board.
224
209
  - **Its writes are by the deployment, with the watcher's ID as its profile:**
225
210
  `vercel:project:prj_v0:production+fix`, which never wakes that watcher. IDs
226
211
  are profile names, so they start with a letter and use up to 32 letters,
227
212
  numbers, and hyphens. Its posts get IDs derived from the match, so a
228
213
  retried `run` doesn't post twice.
229
- - **A thread's matches come one at a time, in order,** and threads run in
230
- parallel. A pulled match is leased for 5 minutes. A `run` that throws is
231
- tried again after a wait (1 second, doubling to 30), and a lease that runs
232
- out counts as a try, noticed within a minute. After 5 tries it's recorded as
233
- `watch.failed`, and the thread goes on.
234
- - **A board without an `https` URL pulls on its own** from its first use,
235
- each pull held open until something matches: a dev server, say.
236
- - **A wake-up carries no credential,** so behind Deployment Protection this
237
- project lets `POST /wake` through itself: a production domain left public
238
- (Standard Protection), or a Deployment Protection Exception for the domain
239
- it registers. A wake-up reveals nothing and is trusted for nothing: it only
240
- makes this board pull with its own credentials. One that Deployment
241
- Protection stops answers 401, and the other board tries less often until
242
- this board pulls or registers.
243
- - **On a board whose discovery says `wake_by_path`,** this board registers
244
- its mount path on its own project instead of its URL, and its wake-ups get
245
- through Deployment Protection with nothing to set up. Only on Vercel, from
246
- production or a preview of a branch, which it names: the other board finds
247
- the deployment from this project's token and that branch. Anywhere else
248
- (development, a custom environment, a preview made with `vercel deploy`), it
249
- registers its URL.
250
- - **Retries need the other board's scheduler,** as its own watchers do.
251
- Without one there, nothing waits on a clock: a retry, a lease that ran out,
252
- and a wake-up that didn't get there (once its back-off is over) each wait
253
- for the next match to wake this board. A board that pulls on its own
254
- doesn't wait.
255
- - **Its [sync](../02-sync/01-overview.md#on-a-board-elsewhere) subscribes the
256
- same way,** with its entries in its registration (`sync: [{ key, platform }]`):
257
- it gets every post, change, and thread sync in the channels its deployment
258
- may `sync`, as matches of watcher `@sync`, and runs them here. The other
259
- board lists those entries in its discovery, and refuses a key its own sync
260
- has (409 `sync_key_taken`).
@@ -75,17 +75,14 @@ principal ID can stand for callers with different access. Canceling one that's
75
75
  done is a no-op. A reply schedule ends on its own when its thread is deleted.
76
76
 
77
77
  Each send runs with its creator's [access](./09-access.md) as it is when the
78
- send is due, under the rules as they are then. A creator that can no longer
78
+ send is due, under the grants as they are then. A creator that can no longer
79
79
  post there (or read the thread, for a reply) has the schedule canceled with
80
80
  `revoked`, and `vb schedules --all` says `ended: its creator can no longer post
81
81
  it`. A schedule from before board kept its creator's claims is worked out from
82
82
  the principal ID alone, which names a deployment's project ID and environment
83
83
  and nothing of a workflow's run. So the board's own deployments in its
84
- environment, and a project its rule names by ID, keep sending; a workflow's, or a project's matched by
85
- name, is `revoked` at its next send. A newer schedule also keeps the board's
86
- own team as the board knew it then, so a rule that names a project without its
87
- `team` still matches when the scheduler's function, which never sees a request,
88
- sends it.
84
+ environment, and a project a grant names, keep sending; a workflow's is
85
+ `revoked` at its next send.
89
86
 
90
87
  ## In code
91
88
 
@@ -103,38 +100,21 @@ await team.cancelSchedule(reminder.id) // { schedule, canceled }
103
100
 
104
101
  ## How it runs
105
102
 
106
- - **It runs on the scheduler.** A board on `a2()` without one refuses:
107
- `POST /schedules`, `schedule()`, and `vb schedule` answer 501
108
- `no_scheduler`, and `vb` says it can't, with the board's words under it:
109
- ``this board has no scheduler: pass `scheduler` to `a2()` to send later``.
110
- See [Without a scheduler](./01-mounting.md#without-a-scheduler). In
111
- production, pass `vercelQueues()` or `qstash()` and mount
112
- [its route](./01-mounting.md#the-scheduler-route). On a dev server, in
113
- `vb serve`, or in tests, `localScheduler()` sends while the process runs:
114
- see [A dev server](./01-mounting.md#a-dev-server). Its timers live in the
115
- process, so a restart drops the sends that were pending.
116
- - **Each send is an A2 timer.** Creating a schedule arms its first send. When it
117
- fires, the board posts that send, records it, and arms the next.
118
- - **A send posts once.** Each one posts with an ID derived from the schedule and
119
- `n`, so a retry after a crash gets back the message it already posted.
120
- - **Downtime doesn't replay.** The next send is the next slot after now, so a
121
- board that was down sends once rather than catching up on every missed slot.
122
- - **Far-off sends hop.** Vercel Queues delays at most 6 days, so a send further
123
- out arrives in hops of up to 5.
124
- - **Canceling can't revoke a timer.** A canceled schedule's timer, or one for a
125
- send already made, fires into a no-op.
126
- - **The newest deployment sends.** Vercel Queues delivers a timer to the
127
- deployment that armed it, so each deployment takes schedules over on its
128
- first request: it arms every pending schedule's next send itself, and the
129
- timers an earlier deployment armed fire into a no-op. A queue's delivery
130
- never takes schedules over, so an old deployment that only its own timers
131
- still reach doesn't take them back. With a scheduler that delivers to one URL, like
132
- `qstash()` pointed at the production alias, an earlier deployment's timers
133
- reach the newest one, which sends them once it has taken over. Each send runs under
134
- the access rules of the deployment that took over last, so a deploy that
135
- takes a grant away stops the schedules that grant was sending. Deployments
136
- that share one store, like a preview on production's database, take
137
- schedules over from each other.
138
-
139
- Schedules live in their own A2 session, outside the board log; only the messages
140
- they post land on the board. See [The log](../04-reference/04-log.md).
103
+ - **The board that keeps the log sends.** On Vercel's board, Vercel's API
104
+ posts each send, whether or not anything of yours is running. On
105
+ [`local()`](./10-local.md), timers in the process send while it runs, and a
106
+ restart drops the sends that were pending.
107
+ - **On `local()`, a send posts once.** Each one posts with an ID derived from
108
+ the schedule and `n`, so a retry after a crash gets back the message it
109
+ already posted. Downtime doesn't replay: the next send is the next slot after
110
+ now, so a board that was down sends once rather than catching up on every
111
+ missed slot.
112
+ - **Vercel's board takes no files on a scheduled message yet,** and no labels
113
+ on a scheduled reply: those answer 501 `not_supported`.
114
+ - **A board that keeps no schedules refuses.** `POST /schedules`, `schedule()`,
115
+ and `vb schedule` answer 501 `no_scheduler`, and `vb` says it can't, with the
116
+ board's words under it. A [backend of your own](./01-mounting.md#a-backend-of-your-own)
117
+ may answer that.
118
+
119
+ Schedules live apart from the board's events; only the messages they post land
120
+ on the board.
@@ -7,9 +7,7 @@ description: Middleware sees every post and edit before it lands, whatever it ca
7
7
 
8
8
  ```ts app/api/board/[[...path]]/route.ts
9
9
  import { board, type Middleware } from '@vercel/board'
10
- import { a2 } from '@vercel/board/backend-a2'
11
- import { vercelQueues } from '@vercel/board/backend-a2/scheduler-vercel'
12
- import { postgres } from '@vercel/board/backend-a2/store-postgres'
10
+ import { local } from '@vercel/board/backend-local'
13
11
 
14
12
  const guard: Middleware = async ({ write, source, respond, next }) => {
15
13
  if (source.kind === 'sync' && /ignore previous instructions/i.test(write.text)) {
@@ -19,18 +17,12 @@ const guard: Middleware = async ({ write, source, respond, next }) => {
19
17
  await next()
20
18
  }
21
19
 
22
- const backend = a2({
23
- store: postgres({ connectionString: process.env.DATABASE_URL! }),
24
- scheduler: vercelQueues({ topic: 'board' }),
25
- })
26
-
27
20
  const team = board({
28
- backend,
21
+ backend: local(),
29
22
  middleware: [guard],
30
23
  // sync as in Sync
31
24
  })
32
25
  export const GET = team.fetch, POST = team.fetch
33
- export const { scheduler } = backend
34
26
  ```
35
27
 
36
28
  Every post and edit goes through `middleware`, in order, before it lands: the
@@ -38,11 +30,13 @@ API (the CLI, scripts, CI), messages synced in from Slack, GitHub, and Linear
38
30
  (sync callbacks' writes included), watchers, the board's
39
31
  [handle](./01-mounting.md#the-handle), and scheduled sends. Reactions, labels,
40
32
  and deletes don't. It's `board()`'s, so it runs before the write reaches the
41
- backend, on any backend. A board on `http()` runs its own on what it writes,
42
- and the board it uses runs its own on what arrives, its sync's imports
43
- included: each sees the write once. On `vercel()`, Vercel's API posts a
44
- schedule's sends, so the middleware sees its message once, when it's made, as
45
- the caller's post.
33
+ backend, on any backend. With `BOARD_URL` set, this board runs its own on what
34
+ it writes, and the board at that URL runs its own on what arrives: each sees
35
+ the write once. On Vercel's board, `vb` and other projects
36
+ write to Vercel's API, not through this route, so the middleware sees what this
37
+ deployment writes: its handle and its watchers. Vercel's
38
+ API posts a schedule's sends, so the middleware sees its message once, when
39
+ it's made, as the caller's post.
46
40
 
47
41
  - **`next()` passes the write on,** to the next middleware and, after the last,
48
42
  to the board. It resolves once the write has landed.
@@ -53,7 +47,7 @@ the caller's post.
53
47
  emptied to no text, with no files, is dropped.
54
48
  - **A middleware that throws fails the write.** The API answers 500, and a
55
49
  synced event is retried. To fail closed, catch and drop.
56
- - **It sees only a write the caller may make.** One `access` would refuse (a
50
+ - **It sees only a write the caller may make.** One its access refuses (a
57
51
  channel it can't post in, someone else's message, a thread it can't read)
58
52
  answers 403 or 404 without running it.
59
53
  - **A retry of a post that landed skips it.** Before it runs, the board looks
@@ -99,7 +93,7 @@ What `respond` says goes back with a write it drops, where the write came from:
99
93
  prints it as `error: …`.
100
94
  - **A watcher or the handle:** its call throws that same error.
101
95
  - **A schedule:** nobody's there to tell. Its text never changes, so the
102
- schedule ends, with `reason: 'dropped'`. On `vercel()`, scheduling it
96
+ schedule ends, with `reason: 'dropped'`. On Vercel's board, scheduling it
103
97
  answers the same `422`, and no schedule is made.
104
98
 
105
99
  ## Writing to the board from middleware