experimental-a2 0.3.0 → 0.5.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.
- package/CHANGELOG.md +207 -0
- package/dist/ai-CFNeCrRl.d.ts +334 -0
- package/dist/ai-CFNeCrRl.d.ts.map +1 -0
- package/dist/ai-server.browser.js +2 -0
- package/dist/ai-server.browser.js.map +1 -0
- package/dist/ai-server.d.ts +49 -9
- package/dist/ai-server.d.ts.map +1 -0
- package/dist/ai-server.js +123 -49
- package/dist/ai-server.js.map +1 -0
- package/dist/ai.d.ts +2 -303
- package/dist/ai.js +233 -86
- package/dist/ai.js.map +1 -0
- package/dist/cli-B3VuxoDe.js +599 -0
- package/dist/cli-B3VuxoDe.js.map +1 -0
- package/dist/cli-bin.d.ts +1 -0
- package/dist/cli-bin.js +7 -0
- package/dist/cli-bin.js.map +1 -0
- package/dist/cli.d.ts +20 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +2 -0
- package/dist/client-BKlyLiOU.js +1008 -0
- package/dist/client-BKlyLiOU.js.map +1 -0
- package/dist/client-D7mvIXrF.d.ts +191 -0
- package/dist/client-D7mvIXrF.d.ts.map +1 -0
- package/dist/client.d.ts +2 -90
- package/dist/client.js +1 -409
- package/dist/{contract-CG_adnu_.js → contract-48bUMgcL.js} +12 -2
- package/dist/contract-48bUMgcL.js.map +1 -0
- package/dist/{contract-C_3dIIEU.d.ts → contract-jIfaR085.d.ts} +63 -8
- package/dist/contract-jIfaR085.d.ts.map +1 -0
- package/dist/devtools-J_jZ2vQf.d.ts +152 -0
- package/dist/devtools-J_jZ2vQf.d.ts.map +1 -0
- package/dist/devtools-kJJaORn-.js +340 -0
- package/dist/devtools-kJJaORn-.js.map +1 -0
- package/dist/devtools-server.browser.js +3 -1
- package/dist/devtools-server.browser.js.map +1 -0
- package/dist/devtools-server.d.ts +4 -3
- package/dist/devtools-server.d.ts.map +1 -0
- package/dist/devtools-server.js +226 -43
- package/dist/devtools-server.js.map +1 -0
- package/dist/devtools.d.ts +2 -0
- package/dist/devtools.js +2 -0
- package/dist/{errors-BJRMd-h6.js → errors-BQuJpe82.js} +6 -4
- package/dist/errors-BQuJpe82.js.map +1 -0
- package/dist/{errors-xL_JTXsY.d.ts → errors-W6nwJ-fm.d.ts} +3 -2
- package/dist/errors-W6nwJ-fm.d.ts.map +1 -0
- package/dist/http.d.ts +135 -28
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +647 -61
- package/dist/http.js.map +1 -0
- package/dist/{idempotent-replay-BMyHrP0L.js → idempotent-replay-DuqEkYA7.js} +4 -2
- package/dist/idempotent-replay-DuqEkYA7.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/{inspection-E7qbD0Xj.js → inspection-DaxB5jM2.js} +4 -1
- package/dist/inspection-DaxB5jM2.js.map +1 -0
- package/dist/internal-DstsI6Re.js +211 -0
- package/dist/internal-DstsI6Re.js.map +1 -0
- package/dist/otel.d.ts +3 -2
- package/dist/otel.d.ts.map +1 -0
- package/dist/otel.js +2 -0
- package/dist/otel.js.map +1 -0
- package/dist/platform-B4TnJtWu.js +34 -0
- package/dist/platform-B4TnJtWu.js.map +1 -0
- package/dist/react.d.ts +47 -15
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +30 -15
- package/dist/react.js.map +1 -0
- package/dist/retryable-lazy-DZWmHpii.js +2 -0
- package/dist/retryable-lazy-DZWmHpii.js.map +1 -0
- package/dist/scheduler-qstash.d.ts +79 -0
- package/dist/scheduler-qstash.d.ts.map +1 -0
- package/dist/scheduler-qstash.js +501 -0
- package/dist/scheduler-qstash.js.map +1 -0
- package/dist/scheduler-task-BpzhPnRS.js +56 -0
- package/dist/scheduler-task-BpzhPnRS.js.map +1 -0
- package/dist/{recovery-vercel.d.ts → scheduler-vercel.d.ts} +18 -24
- package/dist/scheduler-vercel.d.ts.map +1 -0
- package/dist/scheduler-vercel.js +228 -0
- package/dist/scheduler-vercel.js.map +1 -0
- package/dist/server-C72KOw51.js +1457 -0
- package/dist/server-C72KOw51.js.map +1 -0
- package/dist/server-DUF9pjsx.d.ts +261 -0
- package/dist/server-DUF9pjsx.d.ts.map +1 -0
- package/dist/server.browser.js +2 -0
- package/dist/server.browser.js.map +1 -0
- package/dist/server.d.ts +4 -155
- package/dist/server.js +2 -2
- package/dist/{log-ldf5g8Cx.d.ts → store-DysUkTH3.d.ts} +120 -35
- package/dist/store-DysUkTH3.d.ts.map +1 -0
- package/dist/{log-yJbXUf72.js → store-N8PXxDAS.js} +3 -1
- package/dist/store-N8PXxDAS.js.map +1 -0
- package/dist/store-codec-DTG0Ftek.js +10 -0
- package/dist/store-codec-DTG0Ftek.js.map +1 -0
- package/dist/store-memory.d.ts +12 -0
- package/dist/store-memory.d.ts.map +1 -0
- package/dist/{log-memory.js → store-memory.js} +145 -34
- package/dist/store-memory.js.map +1 -0
- package/dist/{log-polling-DZ1MiKLg.js → store-polling-dSeLxzfb.js} +7 -5
- package/dist/store-polling-dSeLxzfb.js.map +1 -0
- package/dist/{log-postgres.d.ts → store-postgres.d.ts} +7 -6
- package/dist/store-postgres.d.ts.map +1 -0
- package/dist/{log-postgres.js → store-postgres.js} +214 -24
- package/dist/store-postgres.js.map +1 -0
- package/dist/{log-redis-core-CyJ5L8yR.js → store-redis-core-BFLwz0Wj.js} +271 -66
- package/dist/store-redis-core-BFLwz0Wj.js.map +1 -0
- package/dist/{log-redis-http.d.ts → store-redis-http.d.ts} +8 -7
- package/dist/store-redis-http.d.ts.map +1 -0
- package/dist/{log-redis-http.js → store-redis-http.js} +22 -12
- package/dist/store-redis-http.js.map +1 -0
- package/dist/{log-redis.d.ts → store-redis.d.ts} +7 -6
- package/dist/store-redis.d.ts.map +1 -0
- package/dist/{log-redis.js → store-redis.js} +101 -39
- package/dist/store-redis.js.map +1 -0
- package/dist/{log-sqlite.d.ts → store-sqlite.d.ts} +7 -6
- package/dist/store-sqlite.d.ts.map +1 -0
- package/dist/{log-sqlite.js → store-sqlite.js} +118 -22
- package/dist/store-sqlite.js.map +1 -0
- package/dist/{telemetry-Cso0qyHQ.d.ts → telemetry-BjYHTfh2.d.ts} +3 -2
- package/dist/telemetry-BjYHTfh2.d.ts.map +1 -0
- package/dist/testing.browser.d.ts +1 -0
- package/dist/testing.browser.js +6 -0
- package/dist/testing.browser.js.map +1 -0
- package/dist/testing.d.ts +32 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +103 -0
- package/dist/testing.js.map +1 -0
- package/dist/validate-XKT4FSNn.js +2 -0
- package/dist/validate-XKT4FSNn.js.map +1 -0
- package/dist/wire-BFQmSJ-9.js +284 -0
- package/dist/wire-BFQmSJ-9.js.map +1 -0
- package/docs/01-quickstart.mdx +3 -3
- package/docs/concepts/01-contracts.mdx +18 -13
- package/docs/concepts/02-handlers.mdx +7 -7
- package/docs/concepts/03-durability.mdx +21 -21
- package/docs/concepts/04-state.mdx +18 -21
- package/docs/guides/01-timers.mdx +154 -49
- package/docs/guides/02-cancellation.mdx +30 -4
- package/docs/guides/03-react.mdx +76 -57
- package/docs/guides/04-local-first.mdx +1 -1
- package/docs/guides/05-production.mdx +310 -61
- package/docs/guides/06-ai-agents.mdx +252 -74
- package/docs/guides/07-devtools.mdx +137 -12
- package/docs/guides/08-application-data.mdx +1 -1
- package/docs/guides/09-presence.mdx +263 -0
- package/docs/guides/10-transports.mdx +140 -0
- package/docs/index.mdx +18 -14
- package/docs/reference/01-api.mdx +839 -110
- package/docs/reference/02-errors.mdx +13 -6
- package/package.json +24 -7
- package/src/ai-coordinator.ts +358 -0
- package/src/ai-projector.ts +524 -0
- package/src/ai-sdk-step.ts +261 -0
- package/src/ai-server.browser.ts +5 -0
- package/src/ai-server.ts +1719 -0
- package/src/ai.ts +2155 -0
- package/src/cache-indexeddb.ts +10 -0
- package/src/cli-bin.ts +5 -0
- package/src/cli.ts +1046 -0
- package/src/client.ts +1826 -0
- package/src/contract.ts +206 -0
- package/src/deterministic-id.ts +72 -0
- package/src/devtools-app.ts +989 -0
- package/src/devtools-server.browser.ts +5 -0
- package/src/devtools-server.ts +604 -0
- package/src/devtools.ts +716 -0
- package/src/errors.ts +50 -0
- package/src/http.ts +394 -0
- package/src/idempotent-replay.ts +53 -0
- package/src/index.ts +37 -0
- package/src/inspection.ts +39 -0
- package/src/internal.ts +426 -0
- package/src/otel.ts +59 -0
- package/src/platform.ts +60 -0
- package/src/push-envelope.ts +137 -0
- package/src/react.ts +284 -0
- package/src/reducer.ts +108 -0
- package/src/retryable-lazy.ts +27 -0
- package/src/scheduler-qstash.ts +915 -0
- package/src/scheduler-task.ts +106 -0
- package/src/scheduler-vercel.ts +437 -0
- package/src/server.browser.ts +12 -0
- package/src/server.ts +2700 -0
- package/src/session-socket.ts +548 -0
- package/src/sse.ts +141 -0
- package/src/standard-schema.ts +77 -0
- package/src/store-codec.ts +10 -0
- package/src/store-memory.ts +788 -0
- package/src/store-polling.ts +102 -0
- package/src/store-postgres.ts +1212 -0
- package/src/store-redis-core.ts +1494 -0
- package/src/store-redis-http.ts +116 -0
- package/src/store-redis.ts +458 -0
- package/src/store-sqlite.ts +1108 -0
- package/src/store.ts +385 -0
- package/src/telemetry.ts +47 -0
- package/src/testing.browser.ts +5 -0
- package/src/testing.ts +185 -0
- package/src/validate.ts +39 -0
- package/src/wire.ts +454 -0
- package/dist/internal-gCd5qMry.js +0 -44
- package/dist/log-memory.d.ts +0 -11
- package/dist/recovery-vercel.js +0 -119
- package/dist/server-BcLa4RFL.js +0 -877
- package/dist/wire-BVsgR8o9.js +0 -62
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as Clock } from "./
|
|
2
|
-
import {
|
|
3
|
-
//#region src/
|
|
1
|
+
import { i as Clock } from "./store-DysUkTH3.js";
|
|
2
|
+
import { D as SchedulerTask, t as A2Scheduler } from "./server-DUF9pjsx.js";
|
|
3
|
+
//#region src/scheduler-vercel.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The "not settled yet" signal for a stalled handler — an expected state,
|
|
6
6
|
* not a transport failure. The default transport classifies it in
|
|
@@ -10,51 +10,45 @@ import { A2Recovery } from "./server.js";
|
|
|
10
10
|
* fresh watchdog instead. Custom transports should treat this class the
|
|
11
11
|
* same way when their protocol has a polite reschedule.
|
|
12
12
|
*/
|
|
13
|
-
declare class
|
|
14
|
-
/** The message a2 puts on the queue. Application state lives in the log. */
|
|
15
|
-
type RecoveryMessage = {
|
|
16
|
-
contract: string;
|
|
17
|
-
sessionId: string;
|
|
18
|
-
/** Whole-second epoch time this watchdog was scheduled to become visible. */
|
|
19
|
-
dueAt?: number;
|
|
20
|
-
};
|
|
13
|
+
declare class DrainUnsettled extends Error {}
|
|
21
14
|
type QueueDeliveryMetadata = {
|
|
22
15
|
messageId: string;
|
|
23
16
|
deliveryCount: number;
|
|
24
17
|
};
|
|
25
|
-
/**
|
|
26
|
-
* What this module needs from a queue — `@vercel/queue`'s `send` and
|
|
27
|
-
* `handleCallback` match it structurally.
|
|
28
|
-
*/
|
|
18
|
+
/** What this module needs from a Vercel Queues-compatible transport. */
|
|
29
19
|
type QueueTransport = {
|
|
30
|
-
send(topic: string, message:
|
|
20
|
+
send(topic: string, message: SchedulerTask, options?: {
|
|
31
21
|
delaySeconds?: number;
|
|
32
22
|
idempotencyKey?: string;
|
|
23
|
+
retentionSeconds?: number;
|
|
24
|
+
}, routing?: {
|
|
25
|
+
deployment: "deployment" | "deploymentless";
|
|
33
26
|
}): Promise<unknown>;
|
|
34
27
|
/**
|
|
35
28
|
* Wrap the delivery handler into a route. The handler throws
|
|
36
|
-
* `
|
|
29
|
+
* `DrainUnsettled` when the session needs redelivery — transports
|
|
37
30
|
* with a polite reschedule (visibility change) should use it there
|
|
38
31
|
* instead of surfacing an error; anything else thrown is a genuine
|
|
39
32
|
* failure and should stay loud.
|
|
40
33
|
*/
|
|
41
|
-
handleCallback(handler: (message:
|
|
34
|
+
handleCallback(handler: (message: unknown, metadata: QueueDeliveryMetadata) => Promise<void>): (req: Request) => Promise<Response>;
|
|
42
35
|
/** Is this send error the idempotency-key collision? (= success) */
|
|
43
36
|
isDuplicate(error: unknown): boolean;
|
|
44
37
|
};
|
|
45
38
|
type VercelQueuesOptions = {
|
|
46
|
-
/** Queue topic
|
|
39
|
+
/** Queue topic matching `[A-Za-z0-9_-]+`. Default `'a2'`. */
|
|
47
40
|
topic?: string;
|
|
48
41
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
42
|
+
* Deployment affinity for scheduled append tasks. Recovery drain tasks
|
|
43
|
+
* always target the publishing deployment. Default `'deployment'`.
|
|
51
44
|
*/
|
|
52
|
-
|
|
45
|
+
scheduledAppends?: "deployment" | "deploymentless";
|
|
53
46
|
/** Injectable transport (tests). Default: `@vercel/queue`. */
|
|
54
47
|
transport?: QueueTransport;
|
|
55
48
|
/** Injectable clock for due-time calculations (tests). */
|
|
56
49
|
clock?: Clock;
|
|
57
50
|
};
|
|
58
|
-
declare function vercelQueues(options?: VercelQueuesOptions):
|
|
51
|
+
declare function vercelQueues(options?: VercelQueuesOptions): A2Scheduler;
|
|
59
52
|
//#endregion
|
|
60
|
-
export { QueueDeliveryMetadata, QueueTransport,
|
|
53
|
+
export { DrainUnsettled, QueueDeliveryMetadata, QueueTransport, VercelQueuesOptions, vercelQueues };
|
|
54
|
+
//# sourceMappingURL=scheduler-vercel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler-vercel.d.ts","names":[],"sources":["../src/scheduler-vercel.ts"],"mappings":";;;;;;;;;;;;cAqDa,uBAAuB;KAExB;EACV;EACA;;;KAYU;EACV,KACE,eACA,SAAS,eACT;IACE;IACA;IACA;KAGF;IACE;MAED;;;;;;;;EAQH,eACE,UACE,kBACA,UAAU,0BACP,iBACH,KAAK,YAAY,QAAQ;;EAE7B,YAAY;;KAGF;;EAEV;;;;;EAKA;;EAEA,YAAY;;EAEZ,QAAQ;;iBA+JM,aAAa,UAAS,sBAA2B"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { f as classifySchedulerSendFailure, t as DRAIN_TIMINGS, u as assertSchedulerTargets, v as serverInternals } from "./internal-DstsI6Re.js";
|
|
2
|
+
import { n as deliverSchedulerAppend } from "./server-C72KOw51.js";
|
|
3
|
+
import { t as retryableLazy } from "./retryable-lazy-DZWmHpii.js";
|
|
4
|
+
import { n as SYSTEM_CLOCK } from "./store-N8PXxDAS.js";
|
|
5
|
+
import { t as normalizeSchedulerTask } from "./scheduler-task-BpzhPnRS.js";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
//#region src/scheduler-vercel.ts
|
|
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
|
+
* They target the publishing deployment unless explicitly configured
|
|
21
|
+
* as deploymentless. Drain tasks always remain deployment-scoped.
|
|
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 arms a later watchdog before acking; handler failure keeps
|
|
25
|
+
* the current message and redelivers with backoff.
|
|
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 stalled handler — an expected state,
|
|
33
|
+
* not a transport failure. The default transport classifies it in
|
|
34
|
+
* `@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 deliveries use a
|
|
37
|
+
* 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 and delivery delay. */
|
|
44
|
+
const MAX_RETENTION_SECONDS = 604800;
|
|
45
|
+
/** Leave the final retention day for delivery and retries. */
|
|
46
|
+
const MAX_DELAY_SECONDS = 518400;
|
|
47
|
+
const TOPIC_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
48
|
+
const RETRYABLE_HTTP_CLIENT_STATUSES = /* @__PURE__ */ new Set([
|
|
49
|
+
408,
|
|
50
|
+
409,
|
|
51
|
+
425,
|
|
52
|
+
429
|
|
53
|
+
]);
|
|
54
|
+
/** The SDK's send path maps these statuses to name-only error instances. */
|
|
55
|
+
const TERMINAL_VERCEL_SEND_ERROR_NAMES = /* @__PURE__ */ new Set([
|
|
56
|
+
"BadRequestError",
|
|
57
|
+
"UnauthorizedError",
|
|
58
|
+
"ForbiddenError"
|
|
59
|
+
]);
|
|
60
|
+
const recordOf = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
61
|
+
const httpStatusOf = (error) => {
|
|
62
|
+
try {
|
|
63
|
+
const record = recordOf(error);
|
|
64
|
+
if (!record) return void 0;
|
|
65
|
+
const response = recordOf(record["response"]);
|
|
66
|
+
const statuses = [
|
|
67
|
+
record["status"],
|
|
68
|
+
record["statusCode"],
|
|
69
|
+
response?.["status"]
|
|
70
|
+
].filter((value) => typeof value === "number" && Number.isInteger(value) && value >= 100 && value <= 599);
|
|
71
|
+
const [status] = statuses;
|
|
72
|
+
if (status === void 0) return void 0;
|
|
73
|
+
return statuses.every((candidate) => candidate === status) ? status : void 0;
|
|
74
|
+
} catch {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const errorNameOf = (error) => {
|
|
79
|
+
try {
|
|
80
|
+
const name = recordOf(error)?.["name"];
|
|
81
|
+
return typeof name === "string" ? name : void 0;
|
|
82
|
+
} catch {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const classifyVercelSendFailure = (error) => {
|
|
87
|
+
const status = httpStatusOf(error);
|
|
88
|
+
const terminal = status === void 0 ? TERMINAL_VERCEL_SEND_ERROR_NAMES.has(errorNameOf(error) ?? "") : status >= 400 && status < 500 && !RETRYABLE_HTTP_CLIENT_STATUSES.has(status);
|
|
89
|
+
return classifySchedulerSendFailure(error, terminal ? "terminal" : "retryable");
|
|
90
|
+
};
|
|
91
|
+
const digestId = (parts) => `a2_${createHash("sha256").update(JSON.stringify(parts)).digest("hex")}`;
|
|
92
|
+
/** Base of the unsettled redelivery backoff, doubled per delivery. */
|
|
93
|
+
const UNSETTLED_BACKOFF_BASE_SECONDS = 5;
|
|
94
|
+
/** Redelivery backoff for retry states: base, 2×, 4×… bounded. */
|
|
95
|
+
const unsettledBackoffSeconds = (deliveryCount) => Math.min(Math.max(UNSETTLED_BACKOFF_BASE_SECONDS * 2 ** Math.max(deliveryCount - 1, 0), MIN_VISIBILITY_SECONDS), 60);
|
|
96
|
+
const vercelQueueTransport = async () => {
|
|
97
|
+
const queue = await import("@vercel/queue").catch(() => {
|
|
98
|
+
throw classifySchedulerSendFailure(/* @__PURE__ */ new Error("experimental-a2/scheduler-vercel needs the '@vercel/queue' package (optional peer dependency) — install it, or inject a transport"), "terminal");
|
|
99
|
+
});
|
|
100
|
+
const deploymentClient = new queue.QueueClient();
|
|
101
|
+
const deploymentlessClient = new queue.QueueClient({ deploymentId: null });
|
|
102
|
+
return {
|
|
103
|
+
send: (topic, message, options, routing) => {
|
|
104
|
+
const deployment = routing?.deployment ?? "deployment";
|
|
105
|
+
const body = {
|
|
106
|
+
...message,
|
|
107
|
+
_a2Vercel: {
|
|
108
|
+
version: 1,
|
|
109
|
+
deployment
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return (deployment === "deploymentless" ? deploymentlessClient : deploymentClient).send(topic, body, options);
|
|
113
|
+
},
|
|
114
|
+
handleCallback: (handler) => {
|
|
115
|
+
const callbackOptions = {
|
|
116
|
+
visibilityTimeoutSeconds: MIN_VISIBILITY_SECONDS,
|
|
117
|
+
retry: (error, metadata) => error instanceof DrainUnsettled ? { afterSeconds: unsettledBackoffSeconds(metadata.deliveryCount) } : void 0
|
|
118
|
+
};
|
|
119
|
+
const deploymentHandler = deploymentClient.handleCallback(handler, callbackOptions);
|
|
120
|
+
const deploymentlessHandler = deploymentlessClient.handleCallback(handler, callbackOptions);
|
|
121
|
+
return async (req) => {
|
|
122
|
+
let delivered;
|
|
123
|
+
try {
|
|
124
|
+
delivered = await req.clone().json();
|
|
125
|
+
} catch {
|
|
126
|
+
return deploymentlessHandler(req);
|
|
127
|
+
}
|
|
128
|
+
const metadata = recordOf(recordOf(delivered)?.["_a2Vercel"]);
|
|
129
|
+
return (metadata?.["version"] === 1 ? metadata["deployment"] : void 0) === "deployment" ? deploymentHandler(req) : deploymentlessHandler(req);
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
isDuplicate: (error) => error instanceof queue.DuplicateMessageError
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
function vercelQueues(options = {}) {
|
|
136
|
+
const topic = options.topic ?? "a2";
|
|
137
|
+
if (typeof topic !== "string" || !TOPIC_PATTERN.test(topic)) throw new TypeError("vercelQueues() topic must match [A-Za-z0-9_-]+");
|
|
138
|
+
const scheduledAppends = options.scheduledAppends ?? "deployment";
|
|
139
|
+
if (scheduledAppends !== "deployment" && scheduledAppends !== "deploymentless") throw new TypeError("vercelQueues() scheduledAppends must be 'deployment' or 'deploymentless'");
|
|
140
|
+
const clock = options.clock ?? SYSTEM_CLOCK;
|
|
141
|
+
const transport = retryableLazy(() => options.transport ? Promise.resolve(options.transport) : vercelQueueTransport()).get;
|
|
142
|
+
const sendTask = async (task) => {
|
|
143
|
+
const nowMs = clock.now().getTime();
|
|
144
|
+
const requestedDueAt = task.dueAt;
|
|
145
|
+
if (!Number.isFinite(requestedDueAt)) throw classifySchedulerSendFailure(/* @__PURE__ */ new TypeError("vercel scheduler dueAt must be a finite number"), "terminal");
|
|
146
|
+
const dueAt = requestedDueAt <= nowMs ? Math.floor(nowMs / 1e3) * 1e3 : Math.ceil(requestedDueAt / 1e3) * 1e3;
|
|
147
|
+
const deliveryTargetAt = task.kind === "append" ? requestedDueAt : dueAt;
|
|
148
|
+
const deliveryDelaySeconds = Math.max(0, Math.ceil((deliveryTargetAt - nowMs) / 1e3));
|
|
149
|
+
if (deliveryDelaySeconds > MAX_DELAY_SECONDS) throw classifySchedulerSendFailure(/* @__PURE__ */ new RangeError("vercelQueues() tasks cannot be delayed more than 6 days"), "terminal");
|
|
150
|
+
const deployment = task.kind === "append" ? scheduledAppends : "deployment";
|
|
151
|
+
const message = {
|
|
152
|
+
...task,
|
|
153
|
+
dueAt
|
|
154
|
+
};
|
|
155
|
+
const idempotencyKey = task.kind === "drain" ? digestId([
|
|
156
|
+
"a2:scheduler-vercel:drain:v1",
|
|
157
|
+
topic,
|
|
158
|
+
task.contract,
|
|
159
|
+
task.sessionId,
|
|
160
|
+
String(dueAt)
|
|
161
|
+
]) : digestId([
|
|
162
|
+
"a2:scheduler-vercel:append:v1",
|
|
163
|
+
topic,
|
|
164
|
+
task.id
|
|
165
|
+
]);
|
|
166
|
+
const t = await transport();
|
|
167
|
+
try {
|
|
168
|
+
await t.send(topic, message, {
|
|
169
|
+
delaySeconds: deliveryDelaySeconds,
|
|
170
|
+
idempotencyKey,
|
|
171
|
+
retentionSeconds: MAX_RETENTION_SECONDS
|
|
172
|
+
}, { deployment });
|
|
173
|
+
} catch (err) {
|
|
174
|
+
if (t.isDuplicate(err)) return;
|
|
175
|
+
throw classifyVercelSendFailure(err);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const successorDueAt = (message) => {
|
|
179
|
+
const minimumDueAt = clock.now().getTime() + DRAIN_TIMINGS.claimTtlMs + DRAIN_TIMINGS.watchdogGraceMs;
|
|
180
|
+
const beats = Math.max(1, Math.ceil((minimumDueAt - message.dueAt) / DRAIN_TIMINGS.claimHeartbeatMs));
|
|
181
|
+
return message.dueAt + beats * DRAIN_TIMINGS.claimHeartbeatMs;
|
|
182
|
+
};
|
|
183
|
+
return {
|
|
184
|
+
async schedule(task) {
|
|
185
|
+
await sendTask(task);
|
|
186
|
+
},
|
|
187
|
+
handler(...servers) {
|
|
188
|
+
assertSchedulerTargets(servers, { allowStructural: true });
|
|
189
|
+
const byContract = /* @__PURE__ */ new Map();
|
|
190
|
+
for (const server of servers) byContract.set(server.contract.name, server);
|
|
191
|
+
return async (req) => {
|
|
192
|
+
return (await transport()).handleCallback(async (delivered) => {
|
|
193
|
+
const task = normalizeSchedulerTask(delivered);
|
|
194
|
+
if (!task) throw new TypeError("a2 scheduler received an invalid task");
|
|
195
|
+
const server = byContract.get(task.contract);
|
|
196
|
+
if (!server) throw new Error(`a2 scheduler: no server for contract '${task.contract}' — pass it to schedulerHandler(...)`);
|
|
197
|
+
const internals = serverInternals.get(server);
|
|
198
|
+
if (task.kind === "append") {
|
|
199
|
+
await deliverSchedulerAppend(server, task);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const nextDueAt = successorDueAt(task);
|
|
203
|
+
const result = internals ? await internals.schedulerDrain(task.sessionId, { watchdogDueAt: nextDueAt }) : {
|
|
204
|
+
...await server.drain(task.sessionId),
|
|
205
|
+
outcome: "unknown"
|
|
206
|
+
};
|
|
207
|
+
if (result.settled) return;
|
|
208
|
+
if (result.outcome === "busy") {
|
|
209
|
+
if (result.schedulerArm) await result.schedulerArm;
|
|
210
|
+
else await sendTask({
|
|
211
|
+
version: 1,
|
|
212
|
+
kind: "drain",
|
|
213
|
+
contract: task.contract,
|
|
214
|
+
sessionId: task.sessionId,
|
|
215
|
+
dueAt: nextDueAt
|
|
216
|
+
});
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
throw new DrainUnsettled(`a2 scheduler: session '${task.sessionId}' of '${task.contract}' not settled yet (${result.outcome}) — rescheduled for redelivery`);
|
|
220
|
+
})(req);
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
export { DrainUnsettled, vercelQueues };
|
|
227
|
+
|
|
228
|
+
//# sourceMappingURL=scheduler-vercel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler-vercel.js","names":[],"sources":["../src/scheduler-vercel.ts"],"sourcesContent":["/**\n * experimental-a2/scheduler-vercel — queue-backed scheduler over Vercel Queues.\n *\n * `vercelQueues()` returns an `A2Scheduler` (a2-implementation.md §9):\n *\n * - drain tasks round the requested watchdog time up to a one-second slot.\n * One message per `(topic, contract, session, dueAt)` coalesces appends,\n * claim renewals and racing callbacks. `DuplicateMessageError` is\n * success because that due-time slot is already durable.\n * - append tasks hash their stable task id with the topic for provider\n * deduplication. Their six-day maximum delay leaves a full day for\n * delivery and retries inside the provider's seven-day retention.\n * They target the publishing deployment unless explicitly configured\n * as deploymentless. Drain tasks always remain deployment-scoped.\n * - `handler(...servers)` is the delivery route: look up the server for\n * the contract named in the message and drain it. Settled drains ack;\n * contention arms a later watchdog before acking; handler failure keeps\n * the current message and redelivers with backoff.\n *\n * `@vercel/queue` is an optional peer dependency, imported lazily. The\n * `transport` option is the injection seam — tests run a real little\n * in-memory queue through the same interface.\n */\n\nimport { createHash } from 'node:crypto'\nimport { SYSTEM_CLOCK, type Clock } from './store.ts'\nimport {\n assertSchedulerTargets,\n classifySchedulerSendFailure,\n DRAIN_TIMINGS,\n serverInternals,\n} from './internal.ts'\nimport { retryableLazy } from './retryable-lazy.ts'\nimport {\n normalizeSchedulerTask,\n type SchedulerDrainTask,\n type SchedulerTask,\n} from './scheduler-task.ts'\nimport {\n deliverSchedulerAppend,\n type A2Scheduler,\n type DrainableServer,\n} from './server.ts'\n\n/**\n * The \"not settled yet\" signal for a stalled handler — an expected state,\n * not a transport failure. The default transport classifies it in\n * `@vercel/queue`'s `retry` option and reschedules the delivery quietly\n * (`{ afterSeconds }` → visibility change → 200 response, no error log)\n * instead of letting it surface as a thrown 500. Busy deliveries use a\n * fresh watchdog instead. Custom transports should treat this class the\n * same way when their protocol has a polite reschedule.\n */\nexport class DrainUnsettled extends Error {}\n\nexport type QueueDeliveryMetadata = {\n messageId: string\n deliveryCount: number\n}\n\ntype VercelQueueMessage = SchedulerTask & {\n /** Provider-private state used to address callback lease operations. */\n _a2Vercel?: {\n version: 1\n deployment: 'deployment' | 'deploymentless'\n }\n}\n\n/** What this module needs from a Vercel Queues-compatible transport. */\nexport type QueueTransport = {\n send(\n topic: string,\n message: SchedulerTask,\n options?: {\n delaySeconds?: number\n idempotencyKey?: string\n retentionSeconds?: number\n },\n /** Resolved A2 affinity. Custom transports own its provider mapping. */\n routing?: {\n deployment: 'deployment' | 'deploymentless'\n },\n ): Promise<unknown>\n /**\n * Wrap the delivery handler into a route. The handler throws\n * `DrainUnsettled` when the session needs redelivery — transports\n * with a polite reschedule (visibility change) should use it there\n * instead of surfacing an error; anything else thrown is a genuine\n * failure and should stay loud.\n */\n handleCallback(\n handler: (\n message: unknown,\n metadata: QueueDeliveryMetadata,\n ) => Promise<void>,\n ): (req: Request) => Promise<Response>\n /** Is this send error the idempotency-key collision? (= success) */\n isDuplicate(error: unknown): boolean\n}\n\nexport type VercelQueuesOptions = {\n /** Queue topic matching `[A-Za-z0-9_-]+`. Default `'a2'`. */\n topic?: string\n /**\n * Deployment affinity for scheduled append tasks. Recovery drain tasks\n * always target the publishing deployment. Default `'deployment'`.\n */\n scheduledAppends?: 'deployment' | 'deploymentless'\n /** Injectable transport (tests). Default: `@vercel/queue`. */\n transport?: QueueTransport\n /** Injectable clock for due-time calculations (tests). */\n clock?: Clock\n}\n\n/** Vercel Queues rejects shorter visibility changes. */\nconst MIN_VISIBILITY_SECONDS = 30\n\n/** Vercel Queues' maximum message retention and delivery delay. */\nconst MAX_RETENTION_SECONDS = 7 * 24 * 60 * 60\n\n/** Leave the final retention day for delivery and retries. */\nconst MAX_DELAY_SECONDS = 6 * 24 * 60 * 60\n\nconst TOPIC_PATTERN = /^[A-Za-z0-9_-]+$/\nconst RETRYABLE_HTTP_CLIENT_STATUSES = new Set([408, 409, 425, 429])\n/** The SDK's send path maps these statuses to name-only error instances. */\nconst TERMINAL_VERCEL_SEND_ERROR_NAMES = new Set([\n 'BadRequestError',\n 'UnauthorizedError',\n 'ForbiddenError',\n])\n\nconst recordOf = (value: unknown): Record<string, unknown> | null =>\n value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : null\n\nconst httpStatusOf = (error: unknown): number | undefined => {\n try {\n const record = recordOf(error)\n if (!record) return undefined\n const response = recordOf(record['response'])\n const statuses = [\n record['status'],\n record['statusCode'],\n response?.['status'],\n ].filter(\n (value): value is number =>\n typeof value === 'number' &&\n Number.isInteger(value) &&\n value >= 100 &&\n value <= 599,\n )\n const [status] = statuses\n if (status === undefined) return undefined\n return statuses.every((candidate) => candidate === status)\n ? status\n : undefined\n } catch {\n return undefined\n }\n}\n\nconst errorNameOf = (error: unknown): string | undefined => {\n try {\n const name = recordOf(error)?.['name']\n return typeof name === 'string' ? name : undefined\n } catch {\n return undefined\n }\n}\n\nconst classifyVercelSendFailure = (error: unknown): unknown => {\n const status = httpStatusOf(error)\n const terminal =\n status === undefined\n ? TERMINAL_VERCEL_SEND_ERROR_NAMES.has(errorNameOf(error) ?? '')\n : status >= 400 &&\n status < 500 &&\n !RETRYABLE_HTTP_CLIENT_STATUSES.has(status)\n return classifySchedulerSendFailure(\n error,\n terminal ? 'terminal' : 'retryable',\n )\n}\n\nconst digestId = (parts: readonly string[]): string =>\n `a2_${createHash('sha256').update(JSON.stringify(parts)).digest('hex')}`\n\n/** Base of the unsettled redelivery backoff, doubled per delivery. */\nconst UNSETTLED_BACKOFF_BASE_SECONDS = 5\n\n/** Redelivery backoff for retry states: base, 2×, 4×… bounded. */\nconst unsettledBackoffSeconds = (deliveryCount: number): number =>\n Math.min(\n Math.max(\n UNSETTLED_BACKOFF_BASE_SECONDS * 2 ** Math.max(deliveryCount - 1, 0),\n MIN_VISIBILITY_SECONDS,\n ),\n 60,\n )\n\nconst vercelQueueTransport = async (): Promise<QueueTransport> => {\n const queue = await import('@vercel/queue').catch(() => {\n throw classifySchedulerSendFailure(\n new Error(\n \"experimental-a2/scheduler-vercel needs the '@vercel/queue' package (optional peer dependency) — install it, or inject a transport\",\n ),\n 'terminal',\n )\n })\n const deploymentClient = new queue.QueueClient()\n const deploymentlessClient = new queue.QueueClient({ deploymentId: null })\n return {\n send: (topic, message, options, routing) => {\n const deployment = routing?.deployment ?? 'deployment'\n const body: VercelQueueMessage = {\n ...message,\n _a2Vercel: { version: 1, deployment },\n }\n return (\n deployment === 'deploymentless'\n ? deploymentlessClient\n : deploymentClient\n ).send(topic, body, options)\n },\n handleCallback: (handler) => {\n const callbackOptions = {\n // A hard-killed callback normally has a fresh claim watchdog. If\n // its successor send also failed, make the old unacked delivery's\n // fallback as prompt as Vercel Queues permits.\n visibilityTimeoutSeconds: MIN_VISIBILITY_SECONDS,\n // Not-settled-yet is an expected state: reschedule the (still\n // unacked) delivery via a visibility change — 200, no error\n // log. Everything else returns undefined → the SDK's default\n // throw path, which is loud on purpose.\n retry: (error: unknown, metadata: QueueDeliveryMetadata) =>\n error instanceof DrainUnsettled\n ? {\n afterSeconds: unsettledBackoffSeconds(metadata.deliveryCount),\n }\n : undefined,\n }\n const deploymentHandler = deploymentClient.handleCallback(\n handler,\n callbackOptions,\n ) as (req: Request) => Promise<Response>\n const deploymentlessHandler = deploymentlessClient.handleCallback(\n handler,\n callbackOptions,\n ) as (req: Request) => Promise<Response>\n return async (req: Request): Promise<Response> => {\n let delivered: unknown\n try {\n delivered = await req.clone().json()\n } catch {\n return deploymentlessHandler(req)\n }\n const metadata = recordOf(recordOf(delivered)?.['_a2Vercel'])\n const routing =\n metadata?.['version'] === 1 ? metadata['deployment'] : undefined\n return routing === 'deployment'\n ? deploymentHandler(req)\n : deploymentlessHandler(req)\n }\n },\n isDuplicate: (error) => error instanceof queue.DuplicateMessageError,\n }\n}\n\nexport function vercelQueues(options: VercelQueuesOptions = {}): A2Scheduler {\n const topic = options.topic ?? 'a2'\n if (typeof topic !== 'string' || !TOPIC_PATTERN.test(topic)) {\n throw new TypeError('vercelQueues() topic must match [A-Za-z0-9_-]+')\n }\n const scheduledAppends = options.scheduledAppends ?? 'deployment'\n if (\n scheduledAppends !== 'deployment' &&\n scheduledAppends !== 'deploymentless'\n ) {\n throw new TypeError(\n \"vercelQueues() scheduledAppends must be 'deployment' or 'deploymentless'\",\n )\n }\n const clock = options.clock ?? SYSTEM_CLOCK\n\n // Lazy: constructing the scheduler value does no I/O and works without\n // the peer dep until the first task or delivery.\n const transport = retryableLazy(() =>\n options.transport\n ? Promise.resolve(options.transport)\n : vercelQueueTransport(),\n ).get\n\n const sendTask = async (task: SchedulerTask): Promise<void> => {\n const nowMs = clock.now().getTime()\n const requestedDueAt = task.dueAt\n if (!Number.isFinite(requestedDueAt)) {\n throw classifySchedulerSendFailure(\n new TypeError('vercel scheduler dueAt must be a finite number'),\n 'terminal',\n )\n }\n const dueAt =\n requestedDueAt <= nowMs\n ? Math.floor(nowMs / 1_000) * 1_000\n : Math.ceil(requestedDueAt / 1_000) * 1_000\n const deliveryTargetAt = task.kind === 'append' ? requestedDueAt : dueAt\n const deliveryDelaySeconds = Math.max(\n 0,\n Math.ceil((deliveryTargetAt - nowMs) / 1_000),\n )\n if (deliveryDelaySeconds > MAX_DELAY_SECONDS) {\n throw classifySchedulerSendFailure(\n new RangeError(\n 'vercelQueues() tasks cannot be delayed more than 6 days',\n ),\n 'terminal',\n )\n }\n const deployment = task.kind === 'append' ? scheduledAppends : 'deployment'\n const message: SchedulerTask = { ...task, dueAt }\n const idempotencyKey =\n task.kind === 'drain'\n ? digestId([\n 'a2:scheduler-vercel:drain:v1',\n topic,\n task.contract,\n task.sessionId,\n String(dueAt),\n ])\n : digestId(['a2:scheduler-vercel:append:v1', topic, task.id])\n const t = await transport()\n try {\n await t.send(\n topic,\n message,\n {\n delaySeconds: deliveryDelaySeconds,\n idempotencyKey,\n retentionSeconds: MAX_RETENTION_SECONDS,\n },\n { deployment },\n )\n } catch (err) {\n if (t.isDuplicate(err)) return\n throw classifyVercelSendFailure(err)\n }\n }\n\n const successorDueAt = (message: SchedulerDrainTask): number => {\n const minimumDueAt =\n clock.now().getTime() +\n DRAIN_TIMINGS.claimTtlMs +\n DRAIN_TIMINGS.watchdogGraceMs\n const beats = Math.max(\n 1,\n Math.ceil(\n (minimumDueAt - message.dueAt) / DRAIN_TIMINGS.claimHeartbeatMs,\n ),\n )\n return message.dueAt + beats * DRAIN_TIMINGS.claimHeartbeatMs\n }\n\n return {\n async schedule(task) {\n await sendTask(task)\n },\n\n handler(...servers: DrainableServer[]) {\n assertSchedulerTargets(servers, { allowStructural: true })\n const byContract = new Map<string, DrainableServer>()\n for (const server of servers) {\n byContract.set(server.contract.name, server)\n }\n return async (req: Request): Promise<Response> => {\n const t = await transport()\n return t.handleCallback(async (delivered) => {\n const task = normalizeSchedulerTask(delivered)\n if (!task) {\n throw new TypeError('a2 scheduler received an invalid task')\n }\n const server = byContract.get(task.contract)\n if (!server) {\n // A message for a contract this route doesn't serve is a\n // wiring bug — throw so it redelivers and stays visible in\n // queue observability instead of vanishing on an ack.\n throw new Error(\n `a2 scheduler: no server for contract '${task.contract}' — pass it to schedulerHandler(...)`,\n )\n }\n const internals = serverInternals.get(server)\n if (task.kind === 'append') {\n await deliverSchedulerAppend(server, task)\n return\n }\n\n const nextDueAt = successorDueAt(task)\n const result = internals\n ? await internals.schedulerDrain(task.sessionId, {\n watchdogDueAt: nextDueAt,\n })\n : {\n ...(await server.drain(task.sessionId)),\n outcome: 'unknown' as const,\n }\n if (result.settled) return\n\n if (result.outcome === 'busy') {\n // The live owner normally arms its own claim windows.\n // Ensure a later slot here as well before relinquishing this\n // durable delivery. If the queue is down, the throw leaves the\n // current message unacked for visibility-timeout redelivery.\n if (result.schedulerArm) await result.schedulerArm\n else {\n await sendTask({\n version: 1,\n kind: 'drain',\n contract: task.contract,\n sessionId: task.sessionId,\n dueAt: nextDueAt,\n })\n }\n return\n }\n\n // Handler failure keeps the current durable message and uses the\n // transport retry path. Dead-lettered sessions count as settled\n // above, so retries stop there.\n throw new DrainUnsettled(\n `a2 scheduler: session '${task.sessionId}' of '${task.contract}' not settled yet (${result.outcome}) — rescheduled for redelivery`,\n )\n })(req)\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,IAAa,iBAAb,cAAoC,MAAM,CAAC;;AA8D3C,MAAM,yBAAyB;;AAG/B,MAAM,wBAAwB;;AAG9B,MAAM,oBAAoB;AAE1B,MAAM,gBAAgB;AACtB,MAAM,iDAAiC,IAAI,IAAI;CAAC;CAAK;CAAK;CAAK;AAAG,CAAC;;AAEnE,MAAM,mDAAmC,IAAI,IAAI;CAC/C;CACA;CACA;AACF,CAAC;AAED,MAAM,YAAY,UAChB,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAC9D,QACD;AAEN,MAAM,gBAAgB,UAAuC;CAC3D,IAAI;EACF,MAAM,SAAS,SAAS,KAAK;EAC7B,IAAI,CAAC,QAAQ,OAAO,KAAA;EACpB,MAAM,WAAW,SAAS,OAAO,WAAW;EAC5C,MAAM,WAAW;GACf,OAAO;GACP,OAA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