@workflow/core 5.7.2 → 5.8.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/dist/global.d.ts +17 -1
- package/dist/global.js +19 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/rate-limit.d.ts +88 -0
- package/dist/rate-limit.js +43 -0
- package/dist/replay-divergence.d.ts +3 -3
- package/dist/replay-divergence.js +6 -4
- package/dist/runtime/constants.d.ts +8 -0
- package/dist/runtime/constants.js +9 -1
- package/dist/runtime/quickjs-pending-ops.d.ts +5 -0
- package/dist/runtime/quickjs-pending-ops.js +61 -3
- package/dist/runtime/quickjs-runtime.d.ts +25 -1
- package/dist/runtime/quickjs-runtime.js +179 -5
- package/dist/runtime/quickjs-serde.js +62 -1
- package/dist/runtime/run-spec-version.d.ts +8 -6
- package/dist/runtime/run-spec-version.js +9 -7
- package/dist/runtime/settle-all.d.ts +17 -0
- package/dist/runtime/settle-all.js +45 -0
- package/dist/runtime/spec8/quickjs-entrypoint.js +27 -11
- package/dist/runtime/spec9/creator-rules.d.ts +4 -1
- package/dist/runtime/spec9/creator-rules.js +25 -7
- package/dist/runtime/spec9/delivery.js +226 -42
- package/dist/runtime/spec9/in-band-writer.d.ts +32 -0
- package/dist/runtime/spec9/in-band-writer.js +168 -9
- package/dist/runtime/spec9/live-feed.d.ts +34 -0
- package/dist/runtime/spec9/live-feed.js +44 -1
- package/dist/runtime/spec9/log-state.d.ts +16 -2
- package/dist/runtime/spec9/log-state.js +42 -10
- package/dist/runtime/spec9/quickjs-entrypoint.js +311 -64
- package/dist/runtime/spec9/step-message.js +3 -5
- package/dist/runtime/spec9/suspension-handler.d.ts +18 -1
- package/dist/runtime/spec9/suspension-handler.js +66 -3
- package/dist/runtime/spec9/wait-timer.d.ts +18 -0
- package/dist/runtime/spec9/wait-timer.js +21 -1
- package/dist/runtime/start.d.ts +4 -2
- package/dist/runtime/start.js +17 -5
- package/dist/runtime/vm-mode.d.ts +19 -0
- package/dist/runtime/vm-mode.js +35 -1
- package/dist/runtime/world-compatibility.d.ts +7 -0
- package/dist/runtime/world-compatibility.js +20 -3
- package/dist/serialization/reducers/common-vm.js +39 -1
- package/dist/serialization/reducers/common.js +28 -2
- package/dist/serialization/types.d.ts +7 -0
- package/dist/serialization.d.ts +7 -0
- package/dist/symbols.d.ts +1 -0
- package/dist/symbols.js +2 -1
- package/dist/test-support/append-only-world.d.ts +72 -1
- package/dist/test-support/append-only-world.js +239 -9
- package/dist/test-support/orchestrator-harness.d.ts +84 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workflow/index.d.ts +1 -0
- package/dist/workflow/index.js +2 -1
- package/dist/workflow/rate-limit-call.d.ts +16 -0
- package/dist/workflow/rate-limit-call.js +62 -0
- package/dist/workflow/rate-limit.d.ts +16 -0
- package/dist/workflow/rate-limit.js +102 -0
- package/dist/workflow.js +6 -2
- package/docs/api-reference/fetch.mdx +1 -1
- package/docs/api-reference/index.mdx +3 -0
- package/docs/api-reference/rate-limit.mdx +114 -0
- package/docs/foundations/errors-and-retries.mdx +2 -0
- package/docs/foundations/meta.json +1 -0
- package/docs/foundations/rate-limits.mdx +181 -0
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CreateEventParams, type Event, type ListEventsParams, type WorkflowRun, type World } from '@workflow/world';
|
|
1
|
+
import { type CreateEventParams, type CreateEventRequest, type Event, type ListEventsParams, type WorkflowRun, type World } from '@workflow/world';
|
|
2
2
|
/**
|
|
3
3
|
* The limits world-vercel puts on one `createBatch` call, the World this fake
|
|
4
4
|
* models: at most 100 events, and at most 768 KiB of frame meta and payloads.
|
|
@@ -122,6 +122,12 @@ export declare class AppendOnlyWorld {
|
|
|
122
122
|
* milliseconds late, after committing, as a remote World's round trip.
|
|
123
123
|
*/
|
|
124
124
|
createDelayMs?: number;
|
|
125
|
+
/**
|
|
126
|
+
* Answer every `queue` call this many milliseconds late, as a remote
|
|
127
|
+
* queue's round trip. {@link AppendOnlyWorld.maxQueueInFlight} records
|
|
128
|
+
* how many overlapped.
|
|
129
|
+
*/
|
|
130
|
+
queueDelayMs?: number;
|
|
125
131
|
/**
|
|
126
132
|
* Push each event to the live feed this many milliseconds after it
|
|
127
133
|
* committed (in commit order), as on a World whose push travels apart
|
|
@@ -143,6 +149,24 @@ export declare class AppendOnlyWorld {
|
|
|
143
149
|
* does.
|
|
144
150
|
*/
|
|
145
151
|
takenHookTokens?: readonly string[];
|
|
152
|
+
/** The spec version the seeded run is stamped with (default 9). */
|
|
153
|
+
runSpecVersion?: number;
|
|
154
|
+
/**
|
|
155
|
+
* Declare `capabilities.rateEventsInBatch` and decide rate events in a
|
|
156
|
+
* batch as a single write does. Without it a batch carrying one is
|
|
157
|
+
* refused whole, as a World without the capability refuses it.
|
|
158
|
+
*/
|
|
159
|
+
rateEventsInBatch?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Refuses a rate event in a batch before deciding it, reserving
|
|
162
|
+
* nothing, when this returns a refusal: as the backend answers one it
|
|
163
|
+
* had no time to decide (503 `rate-batch-deferred`), or one too early
|
|
164
|
+
* by its clock (425). `index` is the item's position in the batch.
|
|
165
|
+
*/
|
|
166
|
+
refuseBatchedRate?: (event: CreateEventRequest, index: number) => {
|
|
167
|
+
status: number;
|
|
168
|
+
error: string;
|
|
169
|
+
} | undefined;
|
|
146
170
|
/**
|
|
147
171
|
* Honor `resolveData: 'skip-step-inputs'` on replay pages (list pages
|
|
148
172
|
* and skipped-slot reports): `step_created` and `step_started` are
|
|
@@ -232,6 +256,18 @@ export declare class AppendOnlyWorld {
|
|
|
232
256
|
readonly events: Event[];
|
|
233
257
|
readonly creates: RecordedCreate[];
|
|
234
258
|
readonly queueCalls: RecordedQueueCall[];
|
|
259
|
+
/** `queue` calls in flight, with {@link options.queueDelayMs}. */
|
|
260
|
+
queueInFlight: number;
|
|
261
|
+
/** The most `queue` calls in flight at once, with `queueDelayMs`. */
|
|
262
|
+
maxQueueInFlight: number;
|
|
263
|
+
/**
|
|
264
|
+
* `queue` calls still in flight as each delivery ended, with
|
|
265
|
+
* `queueDelayMs`: a delivery acknowledges or hands off only once every
|
|
266
|
+
* message it owes is out.
|
|
267
|
+
*/
|
|
268
|
+
readonly queueInFlightAtDeliveryEnd: number[];
|
|
269
|
+
/** Wait timer messages whose `queue` call has returned: out in the queue. */
|
|
270
|
+
waitTimersOut: number;
|
|
235
271
|
/** Messages enqueued and not yet acknowledged. */
|
|
236
272
|
readonly held: HeldMessage[];
|
|
237
273
|
readonly deliveries: RecordedDelivery[];
|
|
@@ -267,6 +303,8 @@ export declare class AppendOnlyWorld {
|
|
|
267
303
|
private handler;
|
|
268
304
|
seq: number;
|
|
269
305
|
seqInBand: number;
|
|
306
|
+
/** Each rate limit key's next free slot (epoch µs), as `world-local` keeps. */
|
|
307
|
+
readonly rateTats: Map<string, number>;
|
|
270
308
|
private readonly subscribers;
|
|
271
309
|
/** Delayed live-feed pushes, in commit order (`subscribeDelayMs`). */
|
|
272
310
|
private pushes;
|
|
@@ -328,6 +366,12 @@ export declare class AppendOnlyWorld {
|
|
|
328
366
|
* milliseconds late, after committing, as a remote World's round trip.
|
|
329
367
|
*/
|
|
330
368
|
createDelayMs?: number;
|
|
369
|
+
/**
|
|
370
|
+
* Answer every `queue` call this many milliseconds late, as a remote
|
|
371
|
+
* queue's round trip. {@link AppendOnlyWorld.maxQueueInFlight} records
|
|
372
|
+
* how many overlapped.
|
|
373
|
+
*/
|
|
374
|
+
queueDelayMs?: number;
|
|
331
375
|
/**
|
|
332
376
|
* Push each event to the live feed this many milliseconds after it
|
|
333
377
|
* committed (in commit order), as on a World whose push travels apart
|
|
@@ -349,6 +393,24 @@ export declare class AppendOnlyWorld {
|
|
|
349
393
|
* does.
|
|
350
394
|
*/
|
|
351
395
|
takenHookTokens?: readonly string[];
|
|
396
|
+
/** The spec version the seeded run is stamped with (default 9). */
|
|
397
|
+
runSpecVersion?: number;
|
|
398
|
+
/**
|
|
399
|
+
* Declare `capabilities.rateEventsInBatch` and decide rate events in a
|
|
400
|
+
* batch as a single write does. Without it a batch carrying one is
|
|
401
|
+
* refused whole, as a World without the capability refuses it.
|
|
402
|
+
*/
|
|
403
|
+
rateEventsInBatch?: boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Refuses a rate event in a batch before deciding it, reserving
|
|
406
|
+
* nothing, when this returns a refusal: as the backend answers one it
|
|
407
|
+
* had no time to decide (503 `rate-batch-deferred`), or one too early
|
|
408
|
+
* by its clock (425). `index` is the item's position in the batch.
|
|
409
|
+
*/
|
|
410
|
+
refuseBatchedRate?: (event: CreateEventRequest, index: number) => {
|
|
411
|
+
status: number;
|
|
412
|
+
error: string;
|
|
413
|
+
} | undefined;
|
|
352
414
|
/**
|
|
353
415
|
* Honor `resolveData: 'skip-step-inputs'` on replay pages (list pages
|
|
354
416
|
* and skipped-slot reports): `step_created` and `step_started` are
|
|
@@ -471,6 +533,15 @@ export declare class AppendOnlyWorld {
|
|
|
471
533
|
private served;
|
|
472
534
|
/** The event a `hook_created` create commits. */
|
|
473
535
|
private committedHook;
|
|
536
|
+
/**
|
|
537
|
+
* The event a rate limit write commits, as a World declaring `rateLimits`
|
|
538
|
+
* decides it (see `world-local`): a `rate_created` reserves its slot and
|
|
539
|
+
* becomes `rate_acquired`, `rate_created` with `acquireAt`, or
|
|
540
|
+
* `rate_failed`; a `rate_acquired` must name its own `rate_created`, once,
|
|
541
|
+
* after its `acquireAt`. `reserve` stores the reservation; the caller runs
|
|
542
|
+
* it only once the write is accepted.
|
|
543
|
+
*/
|
|
544
|
+
private committedRate;
|
|
474
545
|
/**
|
|
475
546
|
* Deliver one held message to the registered queue handler, the way a
|
|
476
547
|
* queue would: a `{ timeoutSeconds }` result keeps the same message (same
|