@vercel/board 0.15.0 → 0.17.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 (130) hide show
  1. package/README.md +27 -27
  2. package/dist/{a2-DYGYankn.mjs → a2-Bck5x1Kh.mjs} +969 -25
  3. package/dist/access.d.mts +5 -4
  4. package/dist/access.mjs +3 -3
  5. package/dist/{actors-rdN4dDTU.mjs → actors-BOamkEuz.mjs} +7 -76
  6. package/dist/attempts-CLG840Oj.mjs +20 -0
  7. package/dist/{auth-wHFcAte3.d.mts → auth-CU56Q2Xh.d.mts} +2 -1
  8. package/dist/{auth-COzc09sn.mjs → auth-Drg9FiC2.mjs} +225 -2
  9. package/dist/backend-B-SJ7p6p.d.mts +680 -0
  10. package/dist/backend-a2/contract.d.mts +873 -2
  11. package/dist/backend-a2/contract.mjs +2 -2
  12. package/dist/backend-a2/scheduler-local.d.mts +1 -1
  13. package/dist/backend-a2/scheduler-local.mjs +1 -1
  14. package/dist/backend-a2/scheduler-qstash.d.mts +78 -1
  15. package/dist/backend-a2/scheduler-qstash.mjs +521 -1
  16. package/dist/backend-a2/scheduler-vercel.d.mts +37 -1
  17. package/dist/backend-a2/scheduler-vercel.mjs +203 -1
  18. package/dist/backend-a2/store-memory.d.mts +2 -2
  19. package/dist/backend-a2/store-memory.mjs +3 -3
  20. package/dist/backend-a2/store-postgres.d.mts +1 -1
  21. package/dist/backend-a2/store-postgres.mjs +2850 -2
  22. package/dist/backend-a2/store-redis-http.d.mts +1 -1
  23. package/dist/backend-a2/store-redis-http.mjs +490 -2
  24. package/dist/backend-a2/store-redis.d.mts +10 -2
  25. package/dist/backend-a2/store-redis.mjs +51 -2
  26. package/dist/backend-a2/store-sqlite.d.mts +1 -1
  27. package/dist/backend-a2/store-sqlite.mjs +3 -3
  28. package/dist/backend-a2.d.mts +2706 -3
  29. package/dist/backend-a2.mjs +1 -1
  30. package/dist/{backend-http-8ex5g7Wv.d.mts → backend-http-7cNb8nJI.d.mts} +10 -3
  31. package/dist/{backend-http-BsDSgmeo.mjs → backend-http-C5I7Wfdw.mjs} +2 -2
  32. package/dist/{backend-http-Cv6xbEy9.mjs → backend-http-CuUIACCs.mjs} +32 -3
  33. package/dist/backend-http.d.mts +1 -1
  34. package/dist/backend-http.mjs +1 -1
  35. package/dist/backend-http.node.d.mts +1 -1
  36. package/dist/backend-http.node.mjs +1 -1
  37. package/dist/{chat-provider-XCnQlxq6.d.mts → chat-provider-DNJQyajS.d.mts} +16 -4
  38. package/dist/{chat-provider-jFSeyNmB.mjs → chat-provider-YHy-WbrB.mjs} +15 -9
  39. package/dist/cli.mjs +30 -10
  40. package/dist/{client-DGDPaN7U.mjs → client-BA-J7usH.mjs} +10 -2
  41. package/dist/{conformance-DRR23YNy.mjs → conformance-CT5EeHeC.mjs} +5 -2
  42. package/dist/conformance.d.mts +1 -1
  43. package/dist/conformance.mjs +1 -1
  44. package/dist/{engine-3EvQ8idk.mjs → engine-D0oBUBEK.mjs} +249 -163
  45. package/dist/events-CewD4kw7.mjs +75 -0
  46. package/dist/{exports-CyY3_FjZ.mjs → exports-DOdA7KhF.mjs} +35 -32
  47. package/dist/exports-ZsgjzEnM.d.mts +4 -0
  48. package/dist/external-BV_cUncs.mjs +151 -0
  49. package/dist/folds-CRYY14kc.d.mts +534 -0
  50. package/dist/{reducers-mUPFuFJV.mjs → folds-Dyjput8M.mjs} +6 -73
  51. package/dist/ids-C6AYo1bu.mjs +31 -0
  52. package/dist/index.d.mts +5 -5
  53. package/dist/{index.default-BZ3lItjH.mjs → index.default-n4qKN7EL.mjs} +1 -1
  54. package/dist/index.mjs +5 -5
  55. package/dist/index.node.d.mts +5 -5
  56. package/dist/index.node.mjs +3 -3
  57. package/dist/inspect/app.js +31 -31
  58. package/dist/inspect/engine.js +5 -5
  59. package/dist/internal-CvsrprnU-CRY89I-b.mjs +203 -0
  60. package/dist/{local-Cr_dSjvs.mjs → local-DhkrAqPP.mjs} +1 -1
  61. package/dist/mentions-CB6ShY4R.mjs +72 -0
  62. package/dist/{targets-ojFEXEyN.mjs → middleware-CqaCwucP.mjs} +1 -33
  63. package/dist/platform-B4TnJtWu-CwcTyKg2.mjs +32 -0
  64. package/dist/{project-CFiArraX.mjs → project-DMDST9kl.mjs} +1 -1
  65. package/dist/{provider-BGjz-mDa.d.mts → provider-B0b9Qxw4.d.mts} +170 -40
  66. package/dist/provider-B3DpYSDq.mjs +220 -0
  67. package/dist/redis-tables-DN9PfIDi.mjs +3897 -0
  68. package/dist/reducer-CYPHsSmd-BQIfozGi.d.mts +170 -0
  69. package/dist/reducer-CjmvZSAb-D_OSISmj.mjs +74 -0
  70. package/dist/{contract-CuJmlrhw.mjs → reducers-BFmIXilu.mjs} +260 -287
  71. package/dist/retryable-lazy-DZWmHpii-Bye-W8q7.mjs +19 -0
  72. package/dist/scheduler-task-X1SToDjP-BVoWuInI.mjs +69 -0
  73. package/dist/{serve-Ccbb2LSb.mjs → serve-CNYvA4pT.mjs} +5 -5
  74. package/dist/server-DtFrWxi3-Boa6gdWO.mjs +3602 -0
  75. package/dist/server-qgez0Xny-D5mLfqFQ.d.mts +385 -0
  76. package/dist/{server-Cxey38B-.mjs → server-snYFkITb.mjs} +4 -4
  77. package/dist/{serving-BNbzc96L.mjs → serving-CNkgUPW1.mjs} +1 -1
  78. package/dist/session-clear-wHd5GCpZ-BnKSxReK.mjs +51 -0
  79. package/dist/{sql-DbiEnqM0.mjs → sql-U9WTxrwJ.mjs} +2 -2
  80. package/dist/{sqlite-db-Cbj03vmp.mjs → sqlite-db-Ds4majtT.mjs} +1 -1
  81. package/dist/store-D0MhBvg6-4Z2L0Kqd.d.mts +530 -0
  82. package/dist/store-N8PXxDAS-BWBgzBHp.mjs +5 -0
  83. package/dist/store-codec-DwrWlgQx-CYxGW0aD.mjs +61 -0
  84. package/dist/store-memory-Bas9Uq5C.mjs +872 -0
  85. package/dist/store-memory-ZLiZbH3R.mjs +2 -0
  86. package/dist/store-polling-BZt2Rf3D-BiEM6_HB.mjs +148 -0
  87. package/dist/store-presence-polling-JuAy2Ck2-CYpuK75X.mjs +109 -0
  88. package/dist/store-sqlite-BmwL3pUR.mjs +2 -0
  89. package/dist/store-sqlite-CxxPCcCT.mjs +1053 -0
  90. package/dist/stream-buffer-DrTyiIuo-BKy-vI14.mjs +53 -0
  91. package/dist/sync-github.d.mts +24 -17
  92. package/dist/sync-github.mjs +89 -22
  93. package/dist/sync-kapso.d.mts +15 -13
  94. package/dist/sync-kapso.mjs +17 -14
  95. package/dist/sync-slack.d.mts +12 -17
  96. package/dist/sync-slack.mjs +54 -42
  97. package/dist/sync.chat.d.mts +1 -1
  98. package/dist/sync.chat.mjs +1 -1
  99. package/dist/sync.d.mts +3 -3
  100. package/dist/sync.mjs +5 -4
  101. package/dist/targets-C-wdR5wP.mjs +33 -0
  102. package/dist/{tokens-DKLn5P9B.mjs → tokens-DhuzKzAl.mjs} +1 -1
  103. package/dist/{types-BHCjTZdB.d.mts → types-8yq2VnKI.d.mts} +2 -2
  104. package/dist/{users-Dls7_ANV.mjs → users-yryHKFMo.mjs} +2 -2
  105. package/dist/{watch-spec-W0c7ypHJ.mjs → watchers-hash-DojIuoFg.mjs} +233 -28
  106. package/docs/01-board/01-mounting.md +1 -1
  107. package/docs/01-board/03-identity.md +3 -1
  108. package/docs/01-board/09-access.md +4 -2
  109. package/docs/02-sync/01-overview.md +69 -47
  110. package/docs/02-sync/02-functions.md +395 -0
  111. package/docs/02-sync/03-slack.md +30 -25
  112. package/docs/02-sync/04-github.md +62 -26
  113. package/docs/02-sync/05-whatsapp.md +23 -19
  114. package/docs/02-sync/06-providers.md +58 -26
  115. package/docs/03-guides/04-triage.md +1 -1
  116. package/docs/04-reference/01-cli.md +26 -6
  117. package/docs/04-reference/02-board.md +18 -5
  118. package/docs/04-reference/03-http.md +6 -3
  119. package/docs/04-reference/05-conformance.md +1 -1
  120. package/docs/index.md +5 -10
  121. package/package.json +22 -6
  122. package/dist/a2-5EG8FkZ8.d.mts +0 -3359
  123. package/dist/access-CJU2-vaa.mjs +0 -226
  124. package/dist/attempts-BQUp9MKO.mjs +0 -919
  125. package/dist/exports-BpgyEdh6.d.mts +0 -4
  126. package/dist/provider-CuewcDNZ.mjs +0 -205
  127. package/dist/redis-tables-B35vv4CZ.mjs +0 -842
  128. package/dist/reducers-B_vUGQRp.d.mts +0 -1172
  129. package/dist/watchers-hash-D9hbHLKB.mjs +0 -225
  130. package/docs/02-sync/02-callbacks.md +0 -265
@@ -1,2 +1,204 @@
1
- import { vercelQueues } from "experimental-a2/scheduler-vercel";
1
+ import { i as deliverSchedulerClear, r as deliverSchedulerAppend } from "../server-DtFrWxi3-Boa6gdWO.mjs";
2
+ import { _ as serverInternals, l as assertSchedulerTargets, t as DRAIN_TIMINGS, u as classifySchedulerSendFailure } from "../internal-CvsrprnU-CRY89I-b.mjs";
3
+ import { t as retryableLazy } from "../retryable-lazy-DZWmHpii-Bye-W8q7.mjs";
4
+ import { n as SYSTEM_CLOCK } from "../store-N8PXxDAS-BWBgzBHp.mjs";
5
+ import { t as normalizeSchedulerTask } from "../scheduler-task-X1SToDjP-BVoWuInI.mjs";
6
+ import { createHash } from "node:crypto";
7
+ //#region ../../node_modules/.pnpm/experimental-a2@0.22.0_@upstash+qstash@2.12.0_@vercel+queue@0.7.0_ai@7.0.130_zod@4.6.5__52060f00b21aecfab049c27fa3abd2f9/node_modules/experimental-a2/dist/scheduler-vercel.js
8
+ /**
9
+ * experimental-a2/scheduler-vercel — queue-backed scheduler over Vercel Queues.
10
+ *
11
+ * `vercelQueues()` returns an `A2Scheduler` (a2-implementation.md §9):
12
+ *
13
+ * - drain tasks round the requested watchdog time up to a one-second slot.
14
+ * One message per `(topic, contract, session, dueAt)` coalesces appends,
15
+ * claim renewals and racing callbacks. `DuplicateMessageError` is
16
+ * success because that due-time slot is already durable.
17
+ * - append tasks hash their stable task id with the topic for provider
18
+ * deduplication. Their six-day maximum delay leaves a full day for
19
+ * delivery and retries inside the provider's seven-day retention.
20
+ * Clear tasks follow the same identity and delay rules. All tasks use
21
+ * the configured deployment scope for sending and receiving.
22
+ * - `handler(...servers)` is the delivery route: look up the server for
23
+ * the contract named in the message and drain it. Settled drains ack;
24
+ * contention, consumer failure, and a drain that throws after arming its
25
+ * successor all ack once a later watchdog is durable.
26
+ *
27
+ * `@vercel/queue` is an optional peer dependency, imported lazily. The
28
+ * `transport` option is the injection seam — tests run a real little
29
+ * in-memory queue through the same interface.
30
+ */
31
+ /**
32
+ * The "not settled yet" signal for a drain whose outcome is unknown — an
33
+ * expected state, not a transport failure. The default transport classifies
34
+ * it in `@vercel/queue`'s `retry` option and reschedules the delivery quietly
35
+ * (`{ afterSeconds }` → visibility change → 200 response, no error log)
36
+ * instead of letting it surface as a thrown 500. Busy and stalled deliveries
37
+ * use a fresh watchdog instead. Custom transports should treat this class the
38
+ * same way when their protocol has a polite reschedule.
39
+ */
40
+ var DrainUnsettled = class extends Error {};
41
+ /** Vercel Queues rejects shorter visibility changes. */
42
+ const MIN_VISIBILITY_SECONDS = 30;
43
+ /** Vercel Queues' maximum message retention; its default is a day. */
44
+ const MAX_RETENTION_SECONDS = 604800;
45
+ const TOPIC_PATTERN = /^[A-Za-z0-9_-]+$/;
46
+ const RETRYABLE_HTTP_CLIENT_STATUSES = /* @__PURE__ */ new Set([
47
+ 408,
48
+ 409,
49
+ 425,
50
+ 429
51
+ ]);
52
+ /** The SDK's send path maps these statuses to name-only error instances. */
53
+ const TERMINAL_VERCEL_SEND_ERROR_NAMES = /* @__PURE__ */ new Set([
54
+ "BadRequestError",
55
+ "UnauthorizedError",
56
+ "ForbiddenError"
57
+ ]);
58
+ const recordOf = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
59
+ const httpStatusOf = (error) => {
60
+ try {
61
+ const record = recordOf(error);
62
+ if (!record) return void 0;
63
+ const response = recordOf(record["response"]);
64
+ const statuses = [
65
+ record["status"],
66
+ record["statusCode"],
67
+ response?.["status"]
68
+ ].filter((value) => typeof value === "number" && Number.isInteger(value) && value >= 100 && value <= 599);
69
+ const [status] = statuses;
70
+ if (status === void 0) return void 0;
71
+ return statuses.every((candidate) => candidate === status) ? status : void 0;
72
+ } catch {
73
+ return;
74
+ }
75
+ };
76
+ const errorNameOf = (error) => {
77
+ try {
78
+ const name = recordOf(error)?.["name"];
79
+ return typeof name === "string" ? name : void 0;
80
+ } catch {
81
+ return;
82
+ }
83
+ };
84
+ const classifyVercelSendFailure = (error) => {
85
+ const status = httpStatusOf(error);
86
+ const terminal = status === void 0 ? TERMINAL_VERCEL_SEND_ERROR_NAMES.has(errorNameOf(error) ?? "") : status >= 400 && status < 500 && !RETRYABLE_HTTP_CLIENT_STATUSES.has(status);
87
+ return classifySchedulerSendFailure(error, terminal ? "terminal" : "retryable");
88
+ };
89
+ const digestId = (parts) => `a2_${createHash("sha256").update(JSON.stringify(parts)).digest("hex")}`;
90
+ /** Base of the unsettled redelivery backoff, doubled per delivery. */
91
+ const UNSETTLED_BACKOFF_BASE_SECONDS = 5;
92
+ /** Redelivery backoff for retry states: base, 2×, 4×… bounded. */
93
+ const unsettledBackoffSeconds = (deliveryCount) => Math.min(Math.max(UNSETTLED_BACKOFF_BASE_SECONDS * 2 ** Math.max(deliveryCount - 1, 0), MIN_VISIBILITY_SECONDS), 60);
94
+ const vercelQueueTransport = async (clientOptions) => {
95
+ const queue = await import("@vercel/queue").catch(() => {
96
+ throw classifySchedulerSendFailure(/* @__PURE__ */ new Error("experimental-a2/scheduler-vercel needs the '@vercel/queue' package (optional peer dependency) — install it, or inject a transport"), "terminal");
97
+ });
98
+ const client = new queue.QueueClient(clientOptions);
99
+ return {
100
+ send: (topic, message, options) => client.send(topic, message, options),
101
+ handleCallback: (handler) => client.handleCallback(handler, {
102
+ visibilityTimeoutSeconds: MIN_VISIBILITY_SECONDS,
103
+ retry: (error, metadata) => error instanceof DrainUnsettled ? { afterSeconds: unsettledBackoffSeconds(metadata.deliveryCount) } : void 0
104
+ }),
105
+ isDuplicate: (error) => error instanceof queue.DuplicateMessageError
106
+ };
107
+ };
108
+ function vercelQueues(options = {}) {
109
+ const topic = options.topic ?? "a2";
110
+ if (typeof topic !== "string" || !TOPIC_PATTERN.test(topic)) throw new TypeError("vercelQueues() topic must match [A-Za-z0-9_-]+");
111
+ const clock = options.clock ?? SYSTEM_CLOCK;
112
+ const clientOptions = options.deploymentId === void 0 ? {} : { deploymentId: options.deploymentId };
113
+ const transport = retryableLazy(() => options.transport ? Promise.resolve(options.transport) : vercelQueueTransport(clientOptions)).get;
114
+ const sendTask = async (task) => {
115
+ const nowMs = clock.now().getTime();
116
+ const requestedDueAt = task.dueAt;
117
+ if (!Number.isFinite(requestedDueAt)) throw classifySchedulerSendFailure(/* @__PURE__ */ new TypeError("vercel scheduler dueAt must be a finite number"), "terminal");
118
+ const dueAt = requestedDueAt <= nowMs ? Math.floor(nowMs / 1e3) * 1e3 : Math.ceil(requestedDueAt / 1e3) * 1e3;
119
+ const deliveryTargetAt = task.kind === "drain" ? dueAt : requestedDueAt;
120
+ const deliveryDelaySeconds = Math.max(0, Math.ceil((deliveryTargetAt - nowMs) / 1e3));
121
+ const message = {
122
+ ...task,
123
+ dueAt
124
+ };
125
+ const idempotencyKey = task.kind === "drain" ? digestId([
126
+ "a2:scheduler-vercel:drain:v1",
127
+ topic,
128
+ task.contract,
129
+ task.sessionId,
130
+ String(dueAt)
131
+ ]) : task.kind === "append" ? digestId([
132
+ "a2:scheduler-vercel:append:v1",
133
+ topic,
134
+ task.id
135
+ ]) : digestId([
136
+ "a2:scheduler-vercel:clear:v1",
137
+ topic,
138
+ task.id
139
+ ]);
140
+ const t = await transport();
141
+ try {
142
+ await t.send(topic, message, {
143
+ delaySeconds: deliveryDelaySeconds,
144
+ idempotencyKey,
145
+ retentionSeconds: MAX_RETENTION_SECONDS
146
+ });
147
+ } catch (err) {
148
+ if (t.isDuplicate(err)) return;
149
+ throw classifyVercelSendFailure(err);
150
+ }
151
+ };
152
+ const successorDueAt = (message) => {
153
+ const minimumDueAt = clock.now().getTime() + DRAIN_TIMINGS.claimTtlMs + DRAIN_TIMINGS.watchdogGraceMs;
154
+ const beats = Math.max(1, Math.ceil((minimumDueAt - message.dueAt) / DRAIN_TIMINGS.claimHeartbeatMs));
155
+ return message.dueAt + beats * DRAIN_TIMINGS.claimHeartbeatMs;
156
+ };
157
+ return {
158
+ async schedule(task) {
159
+ await sendTask(task);
160
+ },
161
+ handler(...servers) {
162
+ assertSchedulerTargets(servers);
163
+ const byContract = /* @__PURE__ */ new Map();
164
+ for (const server of servers) byContract.set(server.contract.name, server);
165
+ return async (req) => {
166
+ return (await transport()).handleCallback(async (delivered) => {
167
+ const task = normalizeSchedulerTask(delivered);
168
+ if (!task) throw new TypeError("a2 scheduler received an invalid task");
169
+ const server = byContract.get(task.contract);
170
+ if (!server) throw new Error(`a2 scheduler: no server for contract '${task.contract}' — pass it to scheduler.handler(...)`);
171
+ const internals = serverInternals.get(server);
172
+ if (task.kind === "append") {
173
+ await deliverSchedulerAppend(server, task);
174
+ return;
175
+ }
176
+ if (task.kind === "clear") {
177
+ await deliverSchedulerClear(server, task);
178
+ return;
179
+ }
180
+ const nextDueAt = successorDueAt(task);
181
+ const result = internals ? await internals.schedulerDrain(task.sessionId, { watchdogDueAt: nextDueAt }) : {
182
+ ...await server.drain(task.sessionId),
183
+ outcome: "unknown"
184
+ };
185
+ if (result.settled) return;
186
+ if (result.outcome === "busy" || result.outcome === "stalled" || result.outcome === "failed") {
187
+ if (result.schedulerArm) await result.schedulerArm;
188
+ else await sendTask({
189
+ version: 1,
190
+ kind: "drain",
191
+ contract: task.contract,
192
+ sessionId: task.sessionId,
193
+ dueAt: nextDueAt
194
+ });
195
+ return;
196
+ }
197
+ throw new DrainUnsettled(`a2 scheduler: session '${task.sessionId}' of '${task.contract}' not settled yet (${result.outcome}) — rescheduled for redelivery`);
198
+ })(req);
199
+ };
200
+ }
201
+ };
202
+ }
203
+ //#endregion
2
204
  export { vercelQueues };
@@ -1,5 +1,5 @@
1
- import { t as BoardStore } from "../types-BHCjTZdB.mjs";
2
- import { Clock } from "experimental-a2/server";
1
+ import { n as Clock } from "../store-D0MhBvg6-4Z2L0Kqd.mjs";
2
+ import { t as BoardStore } from "../types-8yq2VnKI.mjs";
3
3
  //#region src/store/memory.d.ts
4
4
  /**
5
5
  * A board that lives in memory, for tests: its log in A2's memory store, its
@@ -1,6 +1,6 @@
1
- import { r as sqlTables } from "../sql-DbiEnqM0.mjs";
2
- import { t as sqliteDb } from "../sqlite-db-Cbj03vmp.mjs";
3
- import { memory as memory$1 } from "experimental-a2/store-memory";
1
+ import { r as sqlTables } from "../sql-U9WTxrwJ.mjs";
2
+ import { t as sqliteDb } from "../sqlite-db-Ds4majtT.mjs";
3
+ import { t as memory$1 } from "../store-memory-Bas9Uq5C.mjs";
4
4
  //#region src/store/memory.ts
5
5
  /**
6
6
  * A board that lives in memory, for tests: its log in A2's memory store, its
@@ -1,4 +1,4 @@
1
- import { t as BoardStore } from "../types-BHCjTZdB.mjs";
1
+ import { t as BoardStore } from "../types-8yq2VnKI.mjs";
2
2
  //#region src/store/postgres-db.d.ts
3
3
  /** What the tables need of a `pg` Pool, or of anything shaped like one. */
4
4
  type PgQueryable = {