@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
@@ -1,538 +0,0 @@
1
- import { S as storable, _ as RemoteWatcherId, c as ChannelPath, d as LabelKey, g as MessageText, h as MessageId, i as Attachment, l as Emoji, n as ActorId, o as Author, p as Labels, u as Handle, v as SCOPE_MAX, y as SeenActorKind } from "./schemas-DBmUO6pr.mjs";
2
- import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin } from "./external-D3p5T57R.mjs";
3
- import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
4
- import { a as reducer, i as makeReducerBuilder, t as assertSyncSchema } from "./reducer-Bswr11ar-P324o9vn.mjs";
5
- import { n as foldMessages, t as foldActors } from "./folds-DsWfIftc.mjs";
6
- import { z } from "zod";
7
- //#region ../../node_modules/.pnpm/experimental-a2@0.24.0_@upstash+qstash@2.12.0_@vercel+queue@0.7.0_ai@7.0.130_zod@4.6.5__b1e2c243a963f2620a5d202817417c26/node_modules/experimental-a2/dist/contract-DqfBSIqJ.js
8
- function contract(options) {
9
- for (const type of Object.keys(options.events ?? {})) if (type.startsWith("a2.")) throw new TypeError(`contract '${String(options.name)}': event types starting with 'a2.' are reserved`);
10
- return defineContract(options);
11
- }
12
- function defineContract(options) {
13
- const { name } = options;
14
- if (typeof name !== "string" || name.length === 0) throw new TypeError("contract name must be a non-empty string");
15
- if (name.includes("")) throw new TypeError("contract name contains a reserved control character");
16
- const defs = options.events;
17
- for (const [type, schema] of Object.entries(defs)) {
18
- if (typeof schema?.["~standard"]?.validate !== "function") throw new TypeError(`contract '${name}': the value for '${type}' is not a Standard Schema (expected an object with '~standard')`);
19
- assertSyncSchema(schema, `event '${type}'`);
20
- }
21
- const events = Object.freeze({ ...defs });
22
- const presenceDefs = options.presence ?? {};
23
- for (const [field, schema] of Object.entries(presenceDefs)) {
24
- if (typeof schema?.["~standard"]?.validate !== "function") throw new TypeError(`contract '${name}': the value for presence field '${field}' is not a Standard Schema (expected an object with '~standard')`);
25
- assertSyncSchema(schema, `presence field '${field}'`);
26
- }
27
- const presence = Object.freeze({ ...presenceDefs });
28
- return {
29
- name,
30
- events,
31
- presence,
32
- batch: (...items) => items,
33
- reducer: options.reducer === void 0 ? void 0 : {
34
- ...options.reducer,
35
- ...makeReducerBuilder(events, presence, options.reducer).fold(options.reducer.fold)
36
- }
37
- };
38
- }
39
- //#endregion
40
- //#region src/contract/events.ts
41
- /** The sync key a write came from, or null when it was written on the board. */
42
- const From = z.string().nullable();
43
- /** The thread key: the event ID of the thread's root. Lanes and sync state are keyed by it. */
44
- const ThreadKey = z.string().min(1).max(200).refine(storable, "thread key has a NUL character or a lone surrogate");
45
- /** The board's one log. Every board fact is an event in session `board`. */
46
- const boardEvents = {
47
- "message.posted": z.object({
48
- channel: ChannelPath,
49
- /** Empty only when the message has attachments. */
50
- text: z.union([MessageText, z.literal("")]),
51
- /** The thread root, or null for a root. */
52
- re: MessageId.nullable(),
53
- /** The exact message replied to, when it isn't the root. */
54
- replyTo: MessageId.nullable(),
55
- thread: ThreadKey,
56
- labels: Labels,
57
- noSync: z.boolean(),
58
- mentions: z.array(ActorId),
59
- by: Author,
60
- origin: Origin.nullable(),
61
- from: From,
62
- /** Files on the message. Events written before attachments have none. */
63
- attachments: z.array(Attachment).max(10).optional(),
64
- /** Platform messages it links to. Events written before links have none. */
65
- links: z.array(Link).max(10).optional(),
66
- /** (server) Posted by a schedule: its ID and which send this is, from 0. Other messages have none. */
67
- schedule: z.object({
68
- id: z.number().int().positive(),
69
- n: z.number().int().nonnegative()
70
- }).optional(),
71
- /**
72
- * (server) Its author couldn't read the channel it posted in. Where a
73
- * caller can't read, it edits and deletes only these of its own. Events
74
- * from before channel access have none: everyone read everything then.
75
- */
76
- blind: z.literal(true).optional(),
77
- /**
78
- * (server) The principal of the sync elsewhere that imported it, whose copy `origin` names:
79
- * that sync's to act on. None for the board's own sync, or a write on the board.
80
- */
81
- importedBy: ActorId.optional()
82
- }),
83
- /**
84
- * A channel made before anything posted to it. A post makes one too, with no event of its own:
85
- * this is only for one that's empty. It names no message, so it carries no `id`.
86
- */
87
- "channel.created": z.object({
88
- channel: ChannelPath,
89
- by: Author
90
- }),
91
- /** A message's links changed: an edit linked something new, or the platform sent what a link says. */
92
- "message.linked": z.object({
93
- id: MessageId,
94
- thread: ThreadKey,
95
- links: z.array(Link).max(10),
96
- by: Author,
97
- from: From
98
- }),
99
- "message.edited": z.object({
100
- id: MessageId,
101
- thread: ThreadKey,
102
- text: MessageText,
103
- mentions: z.array(ActorId),
104
- by: Author,
105
- from: From
106
- }),
107
- "message.deleted": z.object({
108
- id: MessageId,
109
- thread: ThreadKey,
110
- by: Author,
111
- from: From
112
- }),
113
- "reaction.added": z.object({
114
- id: MessageId,
115
- thread: ThreadKey,
116
- emoji: Emoji,
117
- by: Author,
118
- from: From
119
- }),
120
- "reaction.removed": z.object({
121
- id: MessageId,
122
- thread: ThreadKey,
123
- emoji: Emoji,
124
- by: Author,
125
- from: From
126
- }),
127
- "labels.changed": z.object({
128
- id: MessageId,
129
- thread: ThreadKey,
130
- set: Labels,
131
- unset: z.array(LabelKey),
132
- by: Author
133
- }),
134
- /** A thread is synced with an external channel (start a thread there) or thread (join it). */
135
- "thread.synced": z.object({
136
- thread: ThreadKey,
137
- target: ExternalTarget,
138
- cause: z.enum(["config", "request"]),
139
- kind: z.enum(["channel", "thread"]).optional(),
140
- by: Author
141
- }),
142
- /** An outbound delivery receipt: board message `id` exists on the platform as `external`. */
143
- "message.synced": z.object({
144
- id: MessageId,
145
- thread: ThreadKey,
146
- target: ExternalTarget,
147
- external: z.object({
148
- thread: ExternalTarget,
149
- message: z.string().min(1).max(300)
150
- }),
151
- /**
152
- * (server) The principal of the sync elsewhere that recorded it: its copy is that sync's to
153
- * change. None for the board's own sync.
154
- */
155
- syncedBy: ActorId.optional()
156
- }),
157
- /**
158
- * Board message `id`'s files reached `target` after its text: `files` are the
159
- * platform's IDs for them, or null when the platform refused files and the
160
- * text got a line for each instead.
161
- */
162
- "message.files_synced": z.object({
163
- id: MessageId,
164
- thread: ThreadKey,
165
- target: ExternalTarget,
166
- files: z.array(z.string().min(1).max(300)).max(10).nullable(),
167
- /** (server) As on `message.synced`: only the sync that recorded the copy sets its files. */
168
- syncedBy: ActorId.optional()
169
- }),
170
- /** A delivery that gave up: board message `id` didn't reach `target`, and `error` says why. */
171
- "message.sync_failed": z.object({
172
- id: MessageId,
173
- thread: ThreadKey,
174
- target: ExternalTarget,
175
- error: z.string().min(1).max(500)
176
- }),
177
- "actor.seen": z.object({
178
- actor: ActorId,
179
- kind: SeenActorKind,
180
- handle: Handle,
181
- name: z.string().min(1).max(128).refine(storable, "name has a NUL character or a lone surrogate"),
182
- avatar: z.string().url().nullable(),
183
- /**
184
- * (server) A principal a host's `authenticate` made, or one of its profiles: someone the board
185
- * signs in, whatever its ID or kind, so sync never writes as it. Others have none.
186
- */
187
- host: z.literal(true).optional()
188
- })
189
- };
190
- const BOARD_SESSION = "board";
191
- //#endregion
192
- //#region src/contract/contract.ts
193
- /** The board's one log. Every board fact is an event in session `board`. */
194
- const boardContract = contract({
195
- name: "board",
196
- events: boardEvents
197
- });
198
- /** Raw platform events live outside the board log, one session per external channel. */
199
- const inboxContract = contract({
200
- name: "board-inbox",
201
- events: {
202
- "external.received": z.object({
203
- sync: z.string().min(1),
204
- event: ExternalEvent,
205
- raw: z.unknown()
206
- }),
207
- /** An inbox got its first event: session `inboxes` lists them, so a sync key's inbox lists every channel's. */
208
- "inbox.opened": z.object({ channel: ExternalTarget })
209
- }
210
- });
211
- /** `inbox:slack:C0123ABC`: the inbox session for one external channel. */
212
- const inboxSession = (channel) => `inbox:${channel}`;
213
- /** The session that lists the inboxes: one `inbox.opened` each. */
214
- const INBOXES_SESSION = "inboxes";
215
- /** What watchers matched, outside the board log: one session per watcher, so each fails on its own. */
216
- const MatchId = z.string().min(1).max(200);
217
- const LeaseId = z.string().min(1).max(64);
218
- /** What a queue keeps in order: a board thread's key, or a platform thread for an inbox. */
219
- const QueueLane = z.string().min(1).max(300).refine(storable, "lane has a NUL character or a lone surrogate");
220
- const watchContract = contract({
221
- name: "board-watch",
222
- events: {
223
- "watch.matched": z.object({
224
- /** The board thread, or for an inbox the platform thread: each one's matches go one at a time. */
225
- thread: QueueLane,
226
- /** The board event, as `vb tail --json` prints it, as the watcher may see it, or a platform event for an inbox. */
227
- event: z.unknown(),
228
- /** A registered watcher's ID: its registrant's session holds all of its watchers' matches. */
229
- watcher: RemoteWatcherId.optional(),
230
- /** The registrant's sync, which gets every event it delivers to platforms. */
231
- sync: z.literal(true).optional(),
232
- /** A platform event the registrant pushed to its inbox for this sync key, to pull back and import. */
233
- inbox: z.string().min(1).max(64).optional()
234
- }),
235
- /** The watcher gave up on one match: `run` kept failing, and the thread's later events go on without it. */
236
- "watch.failed": z.object({
237
- /** The `watch.matched` event's ID. */
238
- matched: MatchId,
239
- thread: QueueLane,
240
- error: z.string().min(1).max(500)
241
- }),
242
- /** A registrant pulled a match: it's theirs to run until `until`, or until they ack it. */
243
- "watch.leased": z.object({
244
- matched: MatchId,
245
- lease: LeaseId,
246
- until: z.number().int().nonnegative()
247
- }),
248
- /** The registrant ran it: done, or an error to try again after `retryAt`. A stale lease's ack changes nothing. */
249
- "watch.acked": z.object({
250
- matched: MatchId,
251
- lease: LeaseId,
252
- error: z.string().min(1).max(500).optional(),
253
- retryAt: z.number().int().nonnegative().optional()
254
- }),
255
- /** A lease ran out with no ack: a try that didn't finish. */
256
- "watch.expired": z.object({
257
- matched: MatchId,
258
- lease: LeaseId
259
- }),
260
- /** A match's wait after an error is over: it can be pulled again. */
261
- "watch.retry": z.object({ matched: MatchId }),
262
- /** A match its registrant can't have anymore: it may not read it, or the watcher is gone. */
263
- "watch.skipped": z.object({
264
- matched: MatchId,
265
- reason: z.string().min(1).max(200)
266
- }),
267
- /** A sweep is set for `at`: one timer for every lease that runs out before it, or a wake-up to try again. */
268
- "watch.armed": z.object({ at: z.number().int().nonnegative() }),
269
- /** A timer: an error's wait is over (`matched`), or a sweep (`sweep`). Its consumer decides what it still means. */
270
- "watch.due": z.object({
271
- matched: MatchId.optional(),
272
- retry: z.boolean().optional(),
273
- sweep: z.number().int().nonnegative().optional()
274
- }),
275
- /** A wake-up didn't get there, `failures` in a row: nothing wakes the registrant again before `until`. */
276
- "watch.unreachable": z.object({
277
- failures: z.number().int().positive(),
278
- until: z.number().int().nonnegative(),
279
- /** Its answer's status, or the error. */
280
- why: z.string().min(1).max(200)
281
- }),
282
- /** The registrant's board answered a wake-up, pulled, or registered: its next match wakes it. */
283
- "watch.reachable": z.object({ by: z.enum([
284
- "wake",
285
- "pull",
286
- "registration"
287
- ]) })
288
- }
289
- });
290
- /** `watch:triage`: the session for one watcher, or `watch:@<principal>` for everything a registrant registered. */
291
- const watchSession = (id) => `watch:${id}`;
292
- /**
293
- * A principal as the board keeps it, to work out its access again later under
294
- * the rules as they are then: who it is, and the token facts rules match on.
295
- */
296
- const StoredPrincipal = z.object({
297
- id: z.string().min(1),
298
- kind: z.enum([
299
- "person",
300
- "deployment",
301
- "workflow",
302
- "external"
303
- ]),
304
- handle: Handle,
305
- facts: z.object({
306
- issuer: z.enum([
307
- "vercel",
308
- "github",
309
- "oidc",
310
- "host"
311
- ]),
312
- iss: z.string().max(1e3),
313
- claims: z.record(z.string(), z.union([
314
- z.string().max(1e3),
315
- z.number(),
316
- z.boolean()
317
- ])),
318
- /** The board's own Vercel team, as the board knew it when it verified the token. */
319
- team: z.string().max(200).optional()
320
- }).optional(),
321
- scope: z.string().max(SCOPE_MAX).optional(),
322
- /** The board token it came with: what it stores stops when the token does. */
323
- token: z.string().min(1).max(64).optional()
324
- });
325
- /** A watcher as a board on `http()` registers it: its tail, and when it runs. */
326
- const WatcherSpec = z.object({
327
- tail: z.string().max(1e3),
328
- when: z.enum(["matches", "enters"])
329
- });
330
- /**
331
- * Watchers that boards on `http()` registered with this one, outside the board
332
- * log: one session, `registry`. Each principal has one registration, and its
333
- * newest replaces the last.
334
- */
335
- const registryContract = contract({
336
- name: "board-registry",
337
- events: { "watchers.registered": z.object({
338
- /** The principal that registered, which its watchers' writes are by, with their IDs as profiles. */
339
- owner: z.string().min(1).max(200),
340
- /** It, to work out what it may read at each match: a watcher sees only what its registrant can. */
341
- principal: StoredPrincipal,
342
- /** Where to wake it: `<url>/wake`. Without one, it pulls on its own. */
343
- url: z.string().url().max(500).nullable(),
344
- watch: z.record(RemoteWatcherId, WatcherSpec),
345
- /**
346
- * Its sync entries: with any, its sync subscribes too, to every post, change, and thread sync
347
- * where it may sync. Older registrations have none.
348
- */
349
- sync: z.array(z.object({
350
- key: z.string().min(1).max(64),
351
- platform: z.string().min(1).max(64)
352
- })).max(32).optional(),
353
- /** `watchersHash(watch)`, which every wake-up carries so the board can tell it's stale. */
354
- hash: z.string().min(1).max(100)
355
- }) }
356
- });
357
- const REGISTRY_SESSION = "registry";
358
- /** Epoch milliseconds. */
359
- const Millis = z.number().int().nonnegative();
360
- /**
361
- * Who a schedule posts as: the identity that created it, as the board resolved
362
- * it then. A token's verified claims (`facts`) and the scope it was narrowed by
363
- * let each send work out its access again, under the rules as they are then.
364
- * Schedules from before they were kept have neither.
365
- */
366
- const ScheduleIdentity = z.object({
367
- author: Author,
368
- principal: StoredPrincipal,
369
- actor: z.object({
370
- id: ActorId,
371
- kind: SeenActorKind,
372
- handle: Handle,
373
- name: z.string().min(1).max(128),
374
- avatar: z.string().nullable()
375
- })
376
- });
377
- /**
378
- * Scheduled messages, outside the board log: one session, `schedules`. A schedule's ID is
379
- * its `schedule.created` index. Each send is an A2 timer carrying `schedule.due`; timers
380
- * can't be revoked, so a canceled or superseded one fires into a no-op.
381
- */
382
- const schedulesContract = contract({
383
- name: "board-schedules",
384
- events: {
385
- "schedule.created": z.object({
386
- /** A new root in `channel`, or a reply in the thread rooted at `re`. */
387
- channel: ChannelPath,
388
- re: MessageId.nullable(),
389
- text: z.union([MessageText, z.literal("")]),
390
- labels: Labels,
391
- noSync: z.boolean(),
392
- attachments: z.array(Attachment).max(10).optional(),
393
- /** The first send. */
394
- first: Millis,
395
- /** Repeats this often after the first send, or null for once. */
396
- every: Millis.nullable(),
397
- /** Stops repeating after this time, or after this many sends. Null: never. */
398
- until: Millis.nullable(),
399
- times: z.number().int().positive().nullable(),
400
- as: ScheduleIdentity,
401
- /**
402
- * (server) Its creator couldn't read its channel. Where a caller can't
403
- * read, it sees and cancels only these of its own. Schedules from before
404
- * channel access have none.
405
- */
406
- blind: z.literal(true).optional()
407
- }),
408
- "schedule.canceled": z.object({
409
- id: z.number().int().positive(),
410
- by: Author,
411
- /**
412
- * `canceled`: someone canceled it; `thread_deleted`: the thread it replies in is gone;
413
- * `dropped`: the board's middleware dropped a send, so it would drop the rest;
414
- * `revoked`: its creator can no longer post there.
415
- */
416
- reason: z.enum([
417
- "canceled",
418
- "thread_deleted",
419
- "dropped",
420
- "revoked"
421
- ])
422
- }),
423
- /** (server) A timer: send `n` is due at `at`. */
424
- "schedule.due": z.object({
425
- id: z.number().int().positive(),
426
- n: z.number().int().nonnegative(),
427
- at: Millis
428
- }),
429
- /** (server) Send `n` was posted as `message`; the next is due at `next`, or never. */
430
- "schedule.fired": z.object({
431
- id: z.number().int().positive(),
432
- n: z.number().int().nonnegative(),
433
- message: MessageId,
434
- next: Millis.nullable()
435
- }),
436
- /** (server) The Vercel deployment `deployment` took over every send: an earlier one's timers no longer post. */
437
- "schedule.takeover": z.object({ deployment: z.string().min(1) })
438
- }
439
- });
440
- const SCHEDULES_SESSION = "schedules";
441
- const Grant = z.union([z.literal("all"), z.array(z.string().min(1).max(16)).max(8)]);
442
- /** A `can`, as config writes it: board() checks it before it's kept. */
443
- const Can = z.union([Grant, z.record(z.string().min(1).max(300), Grant)]);
444
- const ClaimValue = z.string().min(1).max(1e3);
445
- /**
446
- * Who the board trusts beside its code's rules, outside the board log: grants, and the tokens it
447
- * issued, of which only a hash is kept. Session `access`. A grant's and a token's ID is the index
448
- * of the event that made it.
449
- */
450
- const accessContract = contract({
451
- name: "board-access",
452
- events: {
453
- /** A grant, or a new `can` for the grant with this issuer and claims. */
454
- "grant.set": z.object({
455
- issuer: z.string().min(1).max(1e3),
456
- claims: z.record(z.string().min(1).max(200), z.union([ClaimValue, z.array(ClaimValue).min(1).max(32)])),
457
- can: Can,
458
- by: ActorId
459
- }),
460
- "grant.revoked": z.object({
461
- id: z.number().int().positive(),
462
- by: ActorId
463
- }),
464
- "token.minted": z.object({
465
- /** The secret's SHA-256, hex. */
466
- hash: z.string().regex(/^[0-9a-f]{64}$/),
467
- name: z.string().min(1).max(64),
468
- /** Who it acts as, its scope narrowed to what the token may do. */
469
- minter: StoredPrincipal,
470
- profile: z.string().min(1).max(32).nullable(),
471
- avatar: z.string().max(2048).nullable(),
472
- session: z.string().min(1).max(128).nullable(),
473
- /** A person's handle and name when they minted it. */
474
- handle: Handle.nullable(),
475
- personName: z.string().min(1).max(128).nullable(),
476
- expiresAt: Millis,
477
- /** The token it was minted with, which it stops with. */
478
- parent: z.number().int().positive().nullable(),
479
- by: ActorId
480
- }),
481
- "token.revoked": z.object({
482
- id: z.number().int().positive(),
483
- by: ActorId
484
- })
485
- }
486
- });
487
- const ACCESS_SESSION = "access";
488
- //#endregion
489
- //#region src/contract/reducers.ts
490
- const messagesReducer = reducer({
491
- contract: boardContract,
492
- name: "board.messages.v5",
493
- initialState: {
494
- byId: {},
495
- replies: {}
496
- }
497
- }).fold(foldMessages);
498
- reducer({
499
- contract: boardContract,
500
- name: "board.posted.v1",
501
- initialState: {}
502
- }).fold((state, event) => {
503
- if (event.type === "message.posted") setOwn(state, event.id, event.index);
504
- return state;
505
- });
506
- const emptyChannel = (path) => ({
507
- path,
508
- lastIndex: 0,
509
- messages: 0,
510
- threads: 0
511
- });
512
- const channelsReducer = reducer({
513
- contract: boardContract,
514
- name: "board.channels.v2",
515
- initialState: {}
516
- }).fold((state, event) => {
517
- if (event.type === "channel.created") {
518
- if (!own(state, event.payload.channel)) setOwn(state, event.payload.channel, emptyChannel(event.payload.channel));
519
- return state;
520
- }
521
- if (event.type !== "message.posted") return state;
522
- const { channel, re } = event.payload;
523
- const entry = own(state, channel) ?? setOwn(state, channel, emptyChannel(channel));
524
- entry.lastIndex = event.index;
525
- entry.messages += 1;
526
- if (re === null) entry.threads += 1;
527
- return state;
528
- });
529
- const actorsReducer = reducer({
530
- contract: boardContract,
531
- name: "board.actors.v2",
532
- initialState: {
533
- byId: {},
534
- byHandle: {}
535
- }
536
- }).fold(foldActors);
537
- //#endregion
538
- export { INBOXES_SESSION as a, accessContract as c, inboxSession as d, registryContract as f, BOARD_SESSION as g, watchSession as h, ACCESS_SESSION as i, boardContract as l, watchContract as m, channelsReducer as n, REGISTRY_SESSION as o, schedulesContract as p, messagesReducer as r, SCHEDULES_SESSION as s, actorsReducer as t, inboxContract as u };
@@ -1,19 +0,0 @@
1
- //#region ../../node_modules/.pnpm/experimental-a2@0.24.0_@upstash+qstash@2.12.0_@vercel+queue@0.7.0_ai@7.0.130_zod@4.6.5__b1e2c243a963f2620a5d202817417c26/node_modules/experimental-a2/dist/retryable-lazy-DZWmHpii.js
2
- const retryableLazy = (initialize) => {
3
- let current = null;
4
- const get = () => {
5
- if (current) return current;
6
- const attempt = Promise.resolve().then(initialize);
7
- current = attempt;
8
- attempt.catch(() => {
9
- if (current === attempt) current = null;
10
- });
11
- return attempt;
12
- };
13
- return {
14
- get,
15
- peek: () => current
16
- };
17
- };
18
- //#endregion
19
- export { retryableLazy as t };
@@ -1,69 +0,0 @@
1
- //#region ../../node_modules/.pnpm/experimental-a2@0.24.0_@upstash+qstash@2.12.0_@vercel+queue@0.7.0_ai@7.0.130_zod@4.6.5__b1e2c243a963f2620a5d202817417c26/node_modules/experimental-a2/dist/scheduler-task-X1SToDjP.js
2
- const recordOf = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
3
- const validName = (value) => typeof value === "string" && value.length > 0;
4
- const validDueAt = (value) => typeof value === "number" && Number.isInteger(value) && value % 1e3 === 0;
5
- const validIndex = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
6
- const baseTask = (record) => Object.hasOwn(record, "contract") && Object.hasOwn(record, "sessionId") && validName(record["contract"]) && validName(record["sessionId"]) ? {
7
- contract: record["contract"],
8
- sessionId: record["sessionId"]
9
- } : null;
10
- /**
11
- * Validate one delivered task.
12
- * Adapters call this only after their transport authentication has succeeded.
13
- */
14
- function normalizeSchedulerTask(value) {
15
- const record = recordOf(value);
16
- if (!record) return null;
17
- const base = baseTask(record);
18
- if (!base) return null;
19
- if (record["version"] !== 1) return null;
20
- if (record["kind"] === "drain") {
21
- const dueAt = record["dueAt"];
22
- if (!validDueAt(dueAt)) return null;
23
- return {
24
- version: 1,
25
- kind: "drain",
26
- ...base,
27
- dueAt
28
- };
29
- }
30
- if (record["kind"] === "clear") {
31
- const { dueAt, id, ifLastIndex } = record;
32
- if (!validName(id) || !validDueAt(dueAt) || !validIndex(ifLastIndex)) return null;
33
- return {
34
- version: 1,
35
- kind: "clear",
36
- id,
37
- ...base,
38
- dueAt,
39
- ifLastIndex
40
- };
41
- }
42
- if (record["kind"] !== "append") return null;
43
- const { dueAt, events, id, originIndex } = record;
44
- if (!validName(id) || !validDueAt(dueAt)) return null;
45
- if (originIndex !== void 0 && (!validIndex(originIndex) || originIndex === 0)) return null;
46
- if (!Array.isArray(events) || events.length === 0) return null;
47
- const parsedEvents = [];
48
- for (const event of events) {
49
- const item = recordOf(event);
50
- if (!item || typeof item["id"] !== "string" || typeof item["type"] !== "string" || !Object.hasOwn(item, "payload")) return null;
51
- parsedEvents.push({
52
- id: item["id"],
53
- type: item["type"],
54
- payload: item["payload"]
55
- });
56
- }
57
- if (new Set(parsedEvents.map((event) => event.id)).size !== parsedEvents.length) return null;
58
- return {
59
- version: 1,
60
- kind: "append",
61
- id,
62
- ...base,
63
- dueAt,
64
- events: parsedEvents,
65
- ...originIndex === void 0 ? {} : { originIndex }
66
- };
67
- }
68
- //#endregion
69
- export { normalizeSchedulerTask as t };