@vercel/board 0.32.0 → 0.33.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 (166) hide show
  1. package/README.md +25 -20
  2. package/dist/{access-CY5xVMIK.mjs → access-N3XmkKXg.mjs} +3 -3
  3. package/dist/access.d.mts +4 -5
  4. package/dist/access.mjs +5 -5
  5. package/dist/{actors-Bm-ojWWT.mjs → actors-ihyN47OV.mjs} +3 -3
  6. package/dist/{auth-K8dY1nBY.d.mts → auth-D6z3rMNj.d.mts} +7 -93
  7. package/dist/{auth-8pRZnF1M.mjs → auth-r-_PeZyw.mjs} +32 -148
  8. package/dist/{backend-DxE9wGKm.d.mts → backend-CWpyR1A7.d.mts} +81 -51
  9. package/dist/backend-local.d.mts +28 -0
  10. package/dist/backend-local.mjs +2 -0
  11. package/dist/{chat-provider-DkFp2hrh.mjs → chat-provider-9hCT654s.mjs} +2 -2
  12. package/dist/{chat-provider-BChYrrA7.d.mts → chat-provider-DJpFUaFv.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-CpyPV_tk.d.mts → commands-BOBQHVqM.d.mts} +9 -0
  19. package/dist/{commands-DsnQKTdB.mjs → commands-CHoMl06v.mjs} +12 -1
  20. package/dist/{conformance-3RBKxwbp.mjs → conformance-qKmGLTAT.mjs} +5 -5
  21. package/dist/conformance.d.mts +1 -1
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{engine-DurYIRt8.mjs → engine-JxgZiikU.mjs} +6 -8
  24. package/dist/{errors-CJXhhzvT.mjs → errors-Pk0XV1hK.mjs} +56 -2
  25. package/dist/{events-lujPA3gQ.mjs → events-IQg0k281.mjs} +2 -2
  26. package/dist/exports-BuKjVq2t.d.mts +4 -0
  27. package/dist/exports-gHDHlg0i.mjs +3207 -0
  28. package/dist/{external-D3p5T57R.mjs → external-CYe424fO.mjs} +1 -1
  29. package/dist/{folds-DLUzfibJ.d.mts → folds-DjFTiqIM.d.mts} +38 -44
  30. package/dist/index-CXvvYNYj.d.mts +11 -0
  31. package/dist/index.d.mts +9 -8
  32. package/dist/index.mjs +21 -8
  33. package/dist/index.node.d.mts +5 -6
  34. package/dist/index.node.mjs +3 -3
  35. package/dist/inspect/app.js +95 -95
  36. package/dist/{internal-CvsrprnU-zZMpDiRY.mjs → internal-CvsrprnU-CEPOUpAv.mjs} +63 -43
  37. package/dist/local-BbLjA5vI.mjs +8818 -0
  38. package/dist/{main-CcYDo9Hb.mjs → main-CQpCZJFw.mjs} +91 -23
  39. package/dist/{backend-a2/store-memory.mjs → memory-7RRnLa4X.mjs} +3 -3
  40. package/dist/middleware-BU7rVi9F.mjs +103 -0
  41. package/dist/{client-COfYrgfV.d.mts → provider-BlzUvcM9.d.mts} +665 -5
  42. package/dist/{schemas-DBmUO6pr.mjs → schemas-BG205xds.mjs} +2 -5
  43. package/dist/{serve-Bplieh0C.mjs → serve-D8_W4UN6.mjs} +33 -24
  44. package/dist/{node-BgeGcwX0.mjs → server-BiIUXWbU.mjs} +419 -6
  45. package/dist/{serving-Y7s7VDjB.mjs → serving-D7rcUtSC.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 +2 -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-CknPGGVi.mjs} +40 -10
  66. package/dist/{tokens-C7kYyrAG.mjs → tokens-DPKjl3jf.mjs} +15 -43
  67. package/docs/01-board/01-mounting.md +243 -288
  68. package/docs/01-board/03-identity.md +41 -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 +76 -313
  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 +30 -36
  86. package/docs/04-reference/01-cli.md +104 -22
  87. package/docs/04-reference/02-board.md +60 -74
  88. package/docs/04-reference/03-http.md +119 -57
  89. package/docs/04-reference/05-conformance.md +31 -45
  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/backend-a2/blob-vercel.d.mts +0 -8
  95. package/dist/backend-a2/blob-vercel.mjs +0 -81
  96. package/dist/backend-a2/contract.d.mts +0 -828
  97. package/dist/backend-a2/contract.mjs +0 -5
  98. package/dist/backend-a2/scheduler-local.d.mts +0 -11
  99. package/dist/backend-a2/scheduler-local.mjs +0 -2
  100. package/dist/backend-a2/scheduler-qstash.d.mts +0 -79
  101. package/dist/backend-a2/scheduler-qstash.mjs +0 -522
  102. package/dist/backend-a2/scheduler-vercel.d.mts +0 -38
  103. package/dist/backend-a2/scheduler-vercel.mjs +0 -204
  104. package/dist/backend-a2/store-memory.d.mts +0 -11
  105. package/dist/backend-a2/store-postgres.d.mts +0 -38
  106. package/dist/backend-a2/store-postgres.mjs +0 -2977
  107. package/dist/backend-a2/store-redis-http.d.mts +0 -17
  108. package/dist/backend-a2/store-redis-http.mjs +0 -520
  109. package/dist/backend-a2/store-redis.d.mts +0 -31
  110. package/dist/backend-a2/store-redis.mjs +0 -88
  111. package/dist/backend-a2/store-sqlite.d.mts +0 -12
  112. package/dist/backend-a2/store-sqlite.mjs +0 -31
  113. package/dist/backend-a2.d.mts +0 -2633
  114. package/dist/backend-a2.mjs +0 -3
  115. package/dist/backend-http-CaN06CaD.d.mts +0 -672
  116. package/dist/backend-http-CoaCghuJ.mjs +0 -18
  117. package/dist/backend-http-l5A8UmL-.mjs +0 -585
  118. package/dist/backend-http.d.mts +0 -10
  119. package/dist/backend-http.mjs +0 -2
  120. package/dist/backend-http.node.d.mts +0 -10
  121. package/dist/backend-http.node.mjs +0 -2
  122. package/dist/backend-vercel-BE65okBC.mjs +0 -86
  123. package/dist/backend-vercel-CVxoTNF2.mjs +0 -1744
  124. package/dist/backend-vercel-jg-6PAgD.d.mts +0 -674
  125. package/dist/backend-vercel.d.mts +0 -9
  126. package/dist/backend-vercel.mjs +0 -11
  127. package/dist/backend-vercel.node.d.mts +0 -17
  128. package/dist/backend-vercel.node.mjs +0 -2
  129. package/dist/blob-Bx8QPWEd.d.mts +0 -40
  130. package/dist/blob-WbB2DJKn.mjs +0 -201
  131. package/dist/errors-2vGs49Db.d.mts +0 -16
  132. package/dist/exports-BnUZuRm9.mjs +0 -1389
  133. package/dist/exports-u5mApVvn.d.mts +0 -5
  134. package/dist/files-SniSmeEr.mjs +0 -47
  135. package/dist/folds-DsWfIftc.mjs +0 -208
  136. package/dist/index-UXpTPWNc.d.mts +0 -11
  137. package/dist/index.default-Dp8gexln.mjs +0 -12
  138. package/dist/local-C76Fy5ad.mjs +0 -44
  139. package/dist/middleware-BavYSDUa.mjs +0 -62
  140. package/dist/platform-B4TnJtWu-Do3agKr5.mjs +0 -32
  141. package/dist/project-4Vl7_uy5.mjs +0 -124
  142. package/dist/provider-gynDUoyW.d.mts +0 -665
  143. package/dist/redis-tables-BFRj_SEJ.mjs +0 -3895
  144. package/dist/reducer-Bswr11ar-P324o9vn.mjs +0 -74
  145. package/dist/reducer-CYPHsSmd-BXjGiptm.d.mts +0 -170
  146. package/dist/reducers-DQVSP3kk.mjs +0 -538
  147. package/dist/retryable-lazy-DZWmHpii-DpTc5PIP.mjs +0 -19
  148. package/dist/scheduler-task-X1SToDjP-D2Il2rln.mjs +0 -69
  149. package/dist/server-B9gu0qi1-DI1WvcVK.d.mts +0 -391
  150. package/dist/server-DX7mM6nm-D7N_7bug.mjs +0 -3611
  151. package/dist/server-wIpAEjpX.mjs +0 -17
  152. package/dist/session-clear-XJYpmUpg-2q8l_FJR.mjs +0 -63
  153. package/dist/store-DEzcHZOA-B-5vhxef.d.mts +0 -540
  154. package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +0 -5
  155. package/dist/store-memory-4IBl0Ztu.mjs +0 -2
  156. package/dist/store-presence-polling-JuAy2Ck2-Dh-g_KYM.mjs +0 -109
  157. package/dist/store-sqlite-iBTYYKBj.mjs +0 -2
  158. package/dist/stream-buffer-DrTyiIuo-Be10yOBR.mjs +0 -53
  159. package/dist/targets-Cgjs29T0.mjs +0 -33
  160. package/dist/types-CmrFjpml.d.mts +0 -102
  161. package/dist/wait-until-Dw4XrIDQ.mjs +0 -42
  162. package/docs/01-board/02-database.md +0 -258
  163. package/docs/04-reference/04-log.md +0 -247
  164. package/sql/postgres/board.sql +0 -145
  165. package/sql/postgres/notifications.sql +0 -24
  166. package/sql/postgres/schema.sql +0 -451
@@ -1,17 +0,0 @@
1
- import { t as createBoard } from "./exports-BnUZuRm9.mjs";
2
- import { t as http } from "./backend-http-CoaCghuJ.mjs";
3
- //#region src/server/index.ts
4
- /**
5
- * The handle on a board. With a `backend`, the board lives there: `a2()` keeps it in this
6
- * deployment, `http(url)` uses another. Without one, it's `http()` to the board the environment
7
- * points at: `BOARD_URL`.
8
- */
9
- function board(options = {}) {
10
- return createBoard(options, {
11
- http: () => http(),
12
- sync: () => import("./engine-DurYIRt8.mjs"),
13
- serving: () => import("./serving-Y7s7VDjB.mjs")
14
- });
15
- }
16
- //#endregion
17
- export { board as t };
@@ -1,63 +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/session-clear-XJYpmUpg.js
2
- var A2Error = class extends Error {
3
- code;
4
- /** e.g. the Standard Schema issues for INVALID_PAYLOAD */
5
- details;
6
- constructor(code, message, options) {
7
- super(message, options && "cause" in options ? { cause: options.cause } : void 0);
8
- this.name = "A2Error";
9
- this.code = code;
10
- this.details = options?.details;
11
- }
12
- };
13
- /** A consumer write whose attempt no longer owns its triggering event. */
14
- function supersededAttemptError(sessionId, cause) {
15
- const of = cause.consumer === void 0 ? "" : ` for consumer '${cause.consumer}'`;
16
- return new A2Error("SUPERSEDED_ATTEMPT", `attempt ${cause.attempt} no longer owns event ${cause.index}${of} in session '${sessionId}'`);
17
- }
18
- /** A conditional append whose `ifLastIndex` is not the session's head. */
19
- function lastIndexMismatchError(sessionId, ifLastIndex, head) {
20
- return new A2Error("LAST_INDEX_MISMATCH", `session '${sessionId}' is at index ${head}, not ${ifLastIndex}`, { details: { index: head } });
21
- }
22
- /**
23
- * A batch whose ids conflict with committed events. In a conditional append
24
- * whose head moved, the condition failed first, as when another writer's
25
- * batch took those ids, so the conflict reports the head instead.
26
- */
27
- function duplicateBatchError(message, conditional) {
28
- return conditional && conditional.head !== conditional.ifLastIndex ? lastIndexMismatchError(conditional.sessionId, conditional.ifLastIndex, conditional.head) : new A2Error("PARTIAL_DUPLICATE_BATCH", message);
29
- }
30
- /**
31
- * Wrap an arbitrary thrown value as STORE_UNAVAILABLE, preserving the
32
- * original as `cause`. A2Errors pass through untouched — they already
33
- * carry their own meaning.
34
- */
35
- function asStoreUnavailable(err) {
36
- if (err instanceof A2Error) return err;
37
- return new A2Error("STORE_UNAVAILABLE", "the store backend failed", { cause: err });
38
- }
39
- /**
40
- * Throw from a consumer to reject retrying: the failure is adjudicated
41
- * terminal immediately (dead-lettered on the first throw) instead of
42
- * consuming the ten-failure retry budget. For deterministic failures —
43
- * a guard that will refuse identically on every attempt — retrying is
44
- * waste and dead-lettering is the honest outcome. Matched by
45
- * `instanceof`, so subclasses carry domain meaning.
46
- */
47
- var NonRetriableError = class extends Error {
48
- constructor(message, options) {
49
- super(message, options);
50
- this.name = "NonRetriableError";
51
- }
52
- };
53
- /** Reserved type of the marker a clear appends. */
54
- const CLEAR_EVENT_TYPE = "a2.cleared";
55
- /** Accepts any stream item, including presence patches and snapshots. */
56
- function isSessionCleared(item) {
57
- return item.type === CLEAR_EVENT_TYPE;
58
- }
59
- function sessionClearedError(message) {
60
- return new A2Error("SESSION_CLEARED", message);
61
- }
62
- //#endregion
63
- export { duplicateBatchError as a, sessionClearedError as c, asStoreUnavailable as i, supersededAttemptError as l, CLEAR_EVENT_TYPE as n, isSessionCleared as o, NonRetriableError as r, lastIndexMismatchError as s, A2Error as t };
@@ -1,540 +0,0 @@
1
- import { s as PresencePatch } from "./reducer-CYPHsSmd-BXjGiptm.mjs";
2
- //#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/store-DEzcHZOA.d.ts
3
- //#region src/store.d.ts
4
- /** A stored event, as the public API exposes it. */
5
- type Event = {
6
- id: string;
7
- type: string;
8
- payload: unknown;
9
- /** Position in the session's event log, from 1. */
10
- index: number;
11
- sessionId: string;
12
- createdAt: Date;
13
- };
14
- /** The consumer attempt whose append first persisted a child event. */
15
- type EventCause = {
16
- consumer: string;
17
- /** The cursor's lane; null for a concurrent consumer's cursor of one event. */
18
- lane: string | null;
19
- index: number;
20
- attempt: number;
21
- /** Size of one named consumer append, used to reject truncated retries. */
22
- batchSize?: number;
23
- };
24
- /** What the store persists: immutable event history and its causal edge. */
25
- type StoredEvent = Event & {
26
- /** Same-session consumer attempt that appended this event; null means root. */
27
- cause: EventCause | null;
28
- };
29
- /**
30
- * Where a consumer's cursor stands on its head event. A cursor is one record
31
- * per (session, consumer, lane): a log cursor for a consumer with one string
32
- * lane, a lane cursor per lane for a lane function, and a cursor per event
33
- * (lane null) for a concurrent consumer. Its attempt and failure fields
34
- * describe the current head and reset when the cursor moves past it.
35
- */
36
- type HeadDispatch = {
37
- consumer: string;
38
- lane: string | null;
39
- /** Adapter clock time recorded by the first durable claim of this head. */
40
- firstClaimedAt: Date | null;
41
- /** Adapter clock time recorded by the most recent durable claim of this head. */
42
- lastClaimedAt: Date | null;
43
- /** Durable claims of this head, including claims abandoned by hard kills. */
44
- attemptCount: number;
45
- /** Current holder; null when the head is not claimed. */
46
- claimHolder: string | null;
47
- /**
48
- * Adapter clock expiry for the current claim, or, with no holder, the end
49
- * of a failed attempt's retry hold.
50
- */
51
- claimExpiresAt: Date | null;
52
- /**
53
- * Failed attempts on this head: caught failures, and lapsed claims a later
54
- * claim took over. This alone drives dead-lettering.
55
- */
56
- failureCount: number;
57
- /** Adapter clock time recorded by the most recent caught failure. */
58
- lastFailedAt: Date | null;
59
- /** Attempt that produced the most recent caught failure. */
60
- lastFailedAttempt: number | null;
61
- /** The last failure, stringified. */
62
- lastError: string | null;
63
- /** Adapter clock time recorded when dead-lettered; null otherwise. */
64
- failedAt: Date | null;
65
- };
66
- /** Where one cursor stands: its position, its head, and the head's dispatch state. */
67
- type StoredCursor = HeadDispatch & {
68
- /** The last index this cursor finished; a log cursor counts from the latest clear marker. */
69
- position: number;
70
- /** The event it runs next; null when it has nothing to run. */
71
- head: number | null;
72
- };
73
- /** A cursor's head event together with its dispatch state. */
74
- type HeadEvent = StoredEvent & HeadDispatch & {
75
- /** Latest clear marker, on claimed heads of a cleared session. */
76
- clearIndex?: number;
77
- };
78
- /** Names one cursor head: the consumer, its lane, and the head's index. */
79
- type HeadRef = {
80
- consumer: string;
81
- lane: string | null;
82
- index: number;
83
- };
84
- /**
85
- * A consumer the caller serves. Work for consumers it does not name is
86
- * neither pending nor claimed, so a removed consumer's cursors wait for its
87
- * name to return.
88
- */
89
- type StoreConsumer = {
90
- name: string;
91
- /**
92
- * Set for a consumer with one string lane. Its cursor keeps one position
93
- * over the log and runs the next event whose type is in `types` (null:
94
- * every type). A missing cursor is created by the first append that
95
- * carries one of those types: at the start of the log with `backfill`,
96
- * otherwise just before that append.
97
- */
98
- log?: {
99
- lane: string;
100
- types: readonly string[] | null;
101
- backfill: boolean;
102
- };
103
- };
104
- /**
105
- * One live presence value, as `A2Store.presence.read` returns it. The
106
- * row is the LWW unit — one participant's one field. `at` is the
107
- * sender's stamp, the LWW comparator. `expiresAt` is the storage's
108
- * own clock at the applied set plus its `ttlMs` — never derived from
109
- * the sender stamp; a row is live strictly before it.
110
- */
111
- type PresenceRow = {
112
- participant: string;
113
- field: string;
114
- value: unknown;
115
- seen: number;
116
- at: Date;
117
- expiresAt: Date;
118
- };
119
- /** One consistent cache-plus-tail read for a reducer fold. */
120
- type StoreStateRead = {
121
- /** The current head checkpoint, even when an older historical snapshot is selected. */
122
- headIndex: number | null;
123
- /** The greatest cached fold at or before the requested snapshot frontier. */
124
- snapshot: {
125
- index: number;
126
- state: unknown;
127
- } | null;
128
- /** Immutable events strictly after `snapshot.index`, or the full log on a miss. */
129
- events: Event[];
130
- /** Latest clear marker; omitted when the session was never cleared. */
131
- clearIndex?: number;
132
- };
133
- type StoreSnapshotWrite = {
134
- index: number;
135
- state: unknown;
136
- /** Unfinished cursor heads that durably retain this exact checkpoint. */
137
- pins?: readonly HeadRef[];
138
- };
139
- type StoreStateReadRequest = {
140
- sessionId: string;
141
- throughIndex?: number;
142
- snapshotThroughIndex?: number;
143
- };
144
- /** The result of atomically claiming every currently eligible head. */
145
- type StoreClaimAvailableResult = {
146
- outcome: "claimed";
147
- events: HeadEvent[];
148
- /** The session's head when the claim was made: how far behind each event is. */
149
- head?: number;
150
- } | {
151
- outcome: "busy";
152
- retryAt: Date;
153
- } | {
154
- outcome: "settled";
155
- };
156
- /** A completion may lose to a newer claim or an earlier completion. */
157
- type CompleteAttemptResult = {
158
- outcome: "completed";
159
- events: StoredEvent[];
160
- } | {
161
- outcome: "superseded";
162
- };
163
- /** The result of one claim-renewal heartbeat, both lists in head order. */
164
- type RenewClaimsResult = {
165
- /** Listed claims that remain owned by the holder. */
166
- renewed: HeadRef[];
167
- /** Listed claims a newer attempt has durably taken, or whose cursor moved on. */
168
- superseded: HeadRef[];
169
- };
170
- /** The result of atomically recording a caught failure. */
171
- type FailAttemptResult = {
172
- outcome: "failed" | "dead_lettered" | "superseded";
173
- failureCount: number;
174
- };
175
- /** A consumer an appended event starts work for, with its resolved lane. */
176
- type EventTarget = {
177
- consumer: string;
178
- /** The lane a lane function resolved; null runs the event concurrently. */
179
- lane: string | null;
180
- };
181
- /** Input to `A2Store.append` — already validated by the machine. */
182
- type AppendEvent = {
183
- type: string;
184
- payload: unknown;
185
- /** Caller-supplied idempotency key; generated when absent. */
186
- id?: string;
187
- /** Internal causal edge supplied atomically by consumer `session.append`. */
188
- cause?: EventCause;
189
- /**
190
- * Lane-function and concurrent consumers this event starts work for,
191
- * resolved before persistence. Log-cursor consumers are matched by type
192
- * from `StoreConsumer.log` instead.
193
- */
194
- targets?: readonly EventTarget[];
195
- };
196
- /** A consumer-returned event with the deterministic id retries require. */
197
- type ReturnedEvent = AppendEvent & {
198
- id: string;
199
- };
200
- /** The rows written by an append and the session's pending state. */
201
- type StoreAppendResult = {
202
- events: StoredEvent[];
203
- /**
204
- * Whether a served consumer has a live head in this session: one that is
205
- * not dead-lettered. An append whose own batch starts work for a served
206
- * consumer may report true without checking that work is runnable.
207
- */
208
- hasPending: boolean;
209
- };
210
- type StoreClearOptions = {
211
- sessionId: string;
212
- ifLastIndex?: number;
213
- /** The clearing consumer's attempt, fenced like a consumer append. */
214
- cause?: EventCause;
215
- };
216
- type StoreClearResult = {
217
- cleared: boolean;
218
- /** The head after the operation. */
219
- index: number;
220
- /** The latest clear marker after the operation, or 0. */
221
- clearIndex: number;
222
- };
223
- type StoreReclaimResult = {
224
- deleted: number;
225
- done: boolean;
226
- };
227
- type StoreRedriveOptions = {
228
- sessionId: string;
229
- consumer: string;
230
- index: number;
231
- /** `retry` clears the dead letter; `skip` moves the cursor past it. */
232
- action: "retry" | "skip";
233
- consumers?: readonly StoreConsumer[];
234
- };
235
- type StoreRedriveResult = {
236
- /** Whether the head was dead-lettered and this operation resolved it. */
237
- redriven: boolean;
238
- /** Whether a served consumer has a live head in this session: one that is not dead-lettered. */
239
- hasPending: boolean;
240
- };
241
- /**
242
- * An injectable clock. Adapters take one so tests can drive claim
243
- * expiry, failure timestamps, and (later) stuck-session detection
244
- * deterministically — against real storage, no mocking.
245
- */
246
- type Clock = {
247
- now(): Date;
248
- };
249
- /**
250
- * Cursor rules every operation shares:
251
- *
252
- * - `consumers` names the consumers the caller serves. Omitted, every cursor
253
- * counts and no log cursor is created or advanced by type.
254
- * - A cursor's head is the next event it runs: the lowest unfinished event of
255
- * its lane, the event itself for a concurrent cursor, or for a log cursor
256
- * the next event after its position whose type it takes. The clear marker
257
- * is never a head.
258
- * - A head is eligible when no live claim or retry hold owns it, it is not
259
- * dead-lettered, and it lies above the latest clear marker.
260
- * - Moving a cursor past its head resets the head's attempt and failure
261
- * fields and releases snapshot pins on it.
262
- */
263
- interface A2Store {
264
- /**
265
- * Accepts a batch; the batch is atomic — one transaction, consecutive
266
- * `index`es, all-or-nothing. The idempotency key covers the whole
267
- * operation, not each item: if *every* event's `id` already exists in
268
- * this session, this is a retry of a committed batch whose ack was
269
- * lost — return the existing rows as success. If only *some* ids
270
- * exist, the caller mixed an already-sent batch with fresh events —
271
- * always a caller bug — so throw `A2Error('PARTIAL_DUPLICATE_BATCH')`.
272
- * Ids are unique per session: the same id in another session names a
273
- * different event and plays no part in these checks.
274
- *
275
- * In the same atomic operation, each event's `targets` start cursor work:
276
- * a lane target queues the event in that consumer's lane, a null lane
277
- * creates a cursor for that event alone. Each log consumer in `consumers`
278
- * whose types the batch carries gets its cursor created or, when idle, a
279
- * head: the next event after its position that it takes, which may
280
- * precede the batch when an appender that doesn't serve it wrote in
281
- * between. `hasPending` reflects the whole session for the served consumers,
282
- * including older work and idempotent retries.
283
- *
284
- * An event carrying `cause` is a consumer append, fenced by attempt
285
- * currency: accept it only while the cause's cursor still has
286
- * `cause.index` as its head, `cause.attempt` is that head's latest
287
- * attempt, and the head is not dead-lettered; otherwise throw
288
- * `A2Error('SUPERSEDED_ATTEMPT')` and write nothing. The check is part of
289
- * this atomic operation and must serialize against a concurrent
290
- * `claimAvailable` — an unlocked read of the cursor admits write skew. The
291
- * idempotent-replay path runs first, so a batch whose ids all exist
292
- * replays regardless of the current attempt.
293
- *
294
- * Clearing stores (a2-implementation.md §17.2) fence one level earlier:
295
- * a `cause` at or below the latest clear marker throws
296
- * `SUPERSEDED_ATTEMPT`, an `originIndex` there throws `SESSION_CLEARED`,
297
- * and ids whose rows lie below the marker are free to reuse.
298
- *
299
- * `ifLastIndex` conditions a non-empty batch on the session's head, the
300
- * last index including any clear marker: when the head is anything else,
301
- * throw `lastIndexMismatchError` carrying the head and write nothing. It is
302
- * checked last, after the replay path and both fences, inside the same
303
- * atomic operation, never as a read before it. A conditional batch whose
304
- * ids conflict (mixed, or not matching their rows) reports that head
305
- * instead of `PARTIAL_DUPLICATE_BATCH` when it isn't `ifLastIndex`
306
- * (`duplicateBatchError`).
307
- */
308
- append(sessionId: string, events: AppendEvent[], options?: {
309
- originIndex?: number;
310
- ifLastIndex?: number;
311
- consumers?: readonly StoreConsumer[];
312
- }): Promise<StoreAppendResult>;
313
- /**
314
- * Optional with `reclaim`. Serialized with `append`: checks
315
- * `ifLastIndex` against the head and the latest marker, then appends a
316
- * clear marker at the next index without touching existing rows.
317
- * Afterwards every event at or below the marker is superseded: no head
318
- * lies there, and every log cursor's position counts from the marker.
319
- */
320
- clear?(options: StoreClearOptions): Promise<StoreClearResult>;
321
- /**
322
- * Deletes one bounded batch of rows below the latest clear marker, with
323
- * their cursor records, id records, and cached folds. `done` once nothing
324
- * remains below it. Never waits on a lock that other operations hold.
325
- */
326
- reclaim?(sessionId: string): Promise<StoreReclaimResult>;
327
- /**
328
- * Optional with `redrive`. The session's dead-lettered heads above the
329
- * latest clear marker, in event order, then by consumer name.
330
- */
331
- deadLetters?(sessionId: string): Promise<HeadEvent[]>;
332
- /**
333
- * Optional with `deadLetters`. Atomically resolves the consumer's
334
- * dead-lettered head at `index` above the latest clear marker; anything
335
- * else is untouched and reports `redriven: false`. `retry` clears
336
- * `failedAt` and `failureCount`, so the head is claimable again with a
337
- * fresh failure budget, keeping its claim history and last failure. `skip`
338
- * moves the cursor past the head with no completion. Both serialize with
339
- * `claimAvailable` and the consumer-append fence. `hasPending` is read in
340
- * the same step.
341
- */
342
- redrive?(options: StoreRedriveOptions): Promise<StoreRedriveResult>;
343
- /**
344
- * Brings one log consumer's cursor up to date without an append, for
345
- * `session.consume()`. A missing cursor is created: with `backfill`, at
346
- * the latest clear marker, taking the first event of its types after it;
347
- * otherwise at the head, with nothing to run. When the session has nothing
348
- * after its latest clear (or was never written), a missing cursor stays
349
- * missing: nothing is written, and the cursor comes back idle at the
350
- * marker, so a consume of an unknown session leaves no trace. That is
351
- * exact with `backfill`; without it, the consumer starts at the first
352
- * consume or serving append that finds events. An
353
- * idle cursor takes the next event of its types after its position, so it
354
- * finds events appended by deployments that don't serve it. A cursor with
355
- * a head, claimed or not, is left as it is. Records the consumer's types,
356
- * as an append would, and returns the cursor and the session's head.
357
- */
358
- wakeLog(options: {
359
- sessionId: string;
360
- consumer: StoreConsumer & {
361
- log: NonNullable<StoreConsumer["log"]>;
362
- };
363
- }): Promise<{
364
- cursor: StoredCursor;
365
- head: number;
366
- }>;
367
- /**
368
- * The session's cursors: every log and lane cursor, and every concurrent
369
- * cursor that still has a head, by consumer, then lane (concurrent cursors
370
- * last, by head). Lane and concurrent cursors whose work lies at or below
371
- * the latest clear marker are not listed.
372
- */
373
- cursors(sessionId: string): Promise<StoredCursor[]>;
374
- /** Events for one session, oldest first. Bounds form `(afterIndex, throughIndex]`. */
375
- read(sessionId: string, opts?: {
376
- afterIndex?: number;
377
- throughIndex?: number;
378
- }): Promise<StoredEvent[]>;
379
- /** Public history without causal edges; core falls back to read when absent. */
380
- readHistory?(sessionId: string, opts?: {
381
- afterIndex?: number;
382
- throughIndex?: number;
383
- }): Promise<Event[]>;
384
- /**
385
- * Atomically claims every eligible head of the served consumers. A live
386
- * claim or retry hold produces `busy` only when it is the sole remaining
387
- * obstacle to actionable work. Claimed heads are returned in event order,
388
- * then by consumer name. Excluded heads stay unclaimed and keep blocking
389
- * their lane.
390
- */
391
- claimAvailable(options: {
392
- sessionId: string;
393
- holder: string;
394
- ttlMs: number;
395
- expiresAtMs?: number;
396
- exclude?: readonly HeadRef[];
397
- consumers?: readonly StoreConsumer[];
398
- /**
399
- * Taking over a lapsed claim (one whose holder is still recorded, never
400
- * completed or failed) adds one to `failureCount`. When that reaches
401
- * `maxFailures`, the head dead-letters instead of being claimed: it
402
- * comes back in `events` with `failedAt` set and no claim. Its
403
- * `attemptCount` still advances, fencing the lapsed attempt, and its
404
- * `lastFailedAttempt` is unchanged.
405
- */
406
- maxFailures?: number;
407
- /**
408
- * Claims only heads at or below this index: a head past it is neither
409
- * claimed nor reported `busy`, and stays claimable without it.
410
- */
411
- through?: number;
412
- }): Promise<StoreClaimAvailableResult>;
413
- /**
414
- * Renews the listed live claims still owned by `holder`. Each listed claim
415
- * carries the attempt the holder owns. `renewed` lists the claims that
416
- * remain owned after the operation; `superseded` lists the claims whose
417
- * head a newer attempt has durably taken, or whose cursor has moved past
418
- * it. An expired claim no successor has taken appears in neither list — its
419
- * attempt may still complete (`completeAttempt` is the fence), so it is
420
- * not reported as lost. Renewal never revives an expired claim.
421
- */
422
- renewClaims(options: {
423
- sessionId: string;
424
- holder: string;
425
- claims: readonly (HeadRef & {
426
- attempt: number;
427
- })[];
428
- ttlMs: number;
429
- expiresAtMs?: number;
430
- }): Promise<RenewClaimsResult>;
431
- /**
432
- * Atomically completes one current attempt: appends its returned events
433
- * (with their own targets, waking the served log consumers) and moves the
434
- * cursor past its head. Retrying a committed completion with the same
435
- * attempt and deterministic child ids returns the existing children. A
436
- * stale attempt never appends.
437
- */
438
- completeAttempt(options: {
439
- sessionId: string;
440
- consumer: string;
441
- lane: string | null;
442
- index: number;
443
- attempt: number;
444
- events: ReturnedEvent[];
445
- consumers?: readonly StoreConsumer[];
446
- }): Promise<CompleteAttemptResult>;
447
- /**
448
- * Atomically records a caught failure for one claimed attempt. A stale
449
- * attempt cannot poison a finished head or a newer attempt. Accepted
450
- * failures record the operation's clock time. A failure that does not
451
- * dead-letter releases the claim and, with `retryAfterMs`, keeps the head
452
- * unclaimable for that long: its claim expiry is set with no holder, so
453
- * `claimAvailable` reports it `busy` until then.
454
- */
455
- failAttempt(options: {
456
- sessionId: string;
457
- consumer: string;
458
- lane: string | null;
459
- index: number;
460
- attempt: number;
461
- error: string;
462
- maxFailures: number;
463
- retryAfterMs?: number;
464
- }): Promise<FailAttemptResult>;
465
- /**
466
- * Reads a reducer snapshot and its event tail as one consistent adapter
467
- * operation. On a cache miss, `snapshot` is null and `events` is the full
468
- * log. The snapshot is untrusted; core may reject it and issue a full
469
- * `read()` when its state schema no longer accepts the cached value.
470
- * Operational failures propagate without falling back to a full-log read.
471
- */
472
- readState(sessionId: string, reducerName: string, options?: {
473
- throughIndex?: number;
474
- snapshotThroughIndex?: number;
475
- }): Promise<StoreStateRead>;
476
- /**
477
- * Optional batched `readState` — one consistent snapshot-plus-tail read
478
- * per session id, aligned positionally with the input (duplicates
479
- * allowed). Each element has its own frontier; the batch makes no
480
- * cross-session consistency claim. Core falls back to parallel
481
- * `readState` calls when absent.
482
- */
483
- readStates?(requests: readonly StoreStateReadRequest[], reducerName: string): Promise<StoreStateRead[]>;
484
- /**
485
- * Atomically writes disposable reducer checkpoints. The greatest index
486
- * advances the head cache. Older checkpoints survive only while at least
487
- * one listed cursor head is still unfinished; moving that cursor past it
488
- * or dead-lettering it releases the pin and collects unreferenced
489
- * historical checkpoints.
490
- */
491
- putSnapshots(sessionId: string, reducerName: string, snapshots: readonly StoreSnapshotWrite[]): Promise<void>;
492
- /**
493
- * Optional ephemeral-plane capability (specs/a2-implementation.md
494
- * §15.1) — optional like snapshots are. Values arrive already
495
- * validated by core; adapters store them opaquely. Presence never
496
- * touches the event log: no index, no history row, no recovery arm.
497
- */
498
- presence?: {
499
- /**
500
- * Field-wise last-writer-wins merge of one participant's values:
501
- * a field whose unexpired entry has a strictly newer `at` (the
502
- * sender's stamp) is left untouched. `null` deletes the value but
503
- * keeps a tombstone with its `at`, which takes part in the merge
504
- * like a value until it expires, so a set older than the delete
505
- * still loses when it arrives later. Every applied write, value or
506
- * tombstone, refreshes that field's expiry to the storage's own
507
- * clock plus `ttlMs` — the sender stamp orders writes but never
508
- * anchors their lifetime. `subscribe` delivers applied writes only,
509
- * a delete as `null`.
510
- */
511
- set(ns: string, participant: string, values: Record<string, unknown | null>, meta: {
512
- seen: number;
513
- at: Date;
514
- ttlMs: number;
515
- }): Promise<void>;
516
- /**
517
- * The current map, pruned of rows at or past their `expiresAt`.
518
- * Tombstones never appear.
519
- */
520
- read(ns: string): Promise<PresenceRow[]>;
521
- /**
522
- * Adapter-managed patch delivery. Without it, live feeds re-read
523
- * presence on their poll cadence. HTTP Redis uses adaptive polling
524
- * here when its endpoint does not support subscriptions.
525
- */
526
- subscribe?(ns: string, onPatch: (patch: PresencePatch) => void): () => void;
527
- };
528
- /**
529
- * A live feed of one session's events, starting after `startAfter`
530
- * (exclusive). Transport is the backend's choice — in-process pub/sub,
531
- * polling, LISTEN/NOTIFY — callers never branch on which. The iterable
532
- * ends when the consumer calls `return()` (e.g. a disconnecting SSE
533
- * client) and must deliver events appended after subscription.
534
- */
535
- stream(sessionId: string, opts?: {
536
- startAfter?: number;
537
- }): AsyncIterable<Event>;
538
- }
539
- //#endregion
540
- export { Clock as n, Event as r, A2Store as t };
@@ -1,5 +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/store-N8PXxDAS.js
2
- const SYSTEM_CLOCK = { now: () => /* @__PURE__ */ new Date() };
3
- const RANDOM_IDS = () => crypto.randomUUID();
4
- //#endregion
5
- export { SYSTEM_CLOCK as n, RANDOM_IDS as t };
@@ -1,2 +0,0 @@
1
- import { t as memory } from "./store-memory-B0PkVSuQ.mjs";
2
- export { memory };