@lostgradient/weft 0.21.0 → 0.22.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.
@@ -19,14 +19,14 @@ export declare const CLIENT_REST_OPERATION_BINDINGS: {
19
19
  };
20
20
  };
21
21
  };
22
- type SharedAttributesBulkConcurrenc_ff397168 = {
22
+ type SharedAttributesBulkConcurrenc_0f0d07d6 = {
23
23
  readonly attributes?: ReadonlyArray<SharedGtGteKey_e658e64c>;
24
24
  readonly bulkConcurrency?: number;
25
25
  readonly confirmationToken?: string;
26
26
  readonly createdAt?: SharedGtGteLt_d9a61361;
27
27
  readonly dryRun?: boolean;
28
28
  readonly executionDeadline?: SharedGtGteLt_d9a61361;
29
- readonly failureCategory?: unknown;
29
+ readonly failureCategory?: 'application' | 'timeout' | 'cancellation' | 'resource' | 'system' | ReadonlyArray<'application' | 'timeout' | 'cancellation' | 'resource' | 'system'>;
30
30
  readonly idPrefix?: string;
31
31
  readonly limit?: number;
32
32
  readonly offset?: number;
@@ -34,23 +34,23 @@ type SharedAttributesBulkConcurrenc_ff397168 = {
34
34
  readonly parentWorkflowId?: string;
35
35
  readonly requestId?: string;
36
36
  readonly scheduleId?: string;
37
- readonly status?: unknown;
37
+ readonly status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended' | ReadonlyArray<'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended'>;
38
38
  readonly tags?: ReadonlyArray<string>;
39
39
  readonly type?: string;
40
40
  readonly updatedAt?: SharedGtGteLt_d9a61361;
41
41
  };
42
- type SharedAttributesCreatedAtExecu_0caddefc = {
42
+ type SharedAttributesCreatedAtExecu_47f8e20e = {
43
43
  readonly attributes?: ReadonlyArray<SharedGtGteKey_e658e64c>;
44
44
  readonly createdAt?: SharedGtGteLt_d9a61361;
45
45
  readonly executionDeadline?: SharedGtGteLt_d9a61361;
46
- readonly failureCategory?: unknown;
46
+ readonly failureCategory?: 'application' | 'timeout' | 'cancellation' | 'resource' | 'system' | ReadonlyArray<'application' | 'timeout' | 'cancellation' | 'resource' | 'system'>;
47
47
  readonly idPrefix?: string;
48
48
  readonly limit?: number;
49
49
  readonly offset?: number;
50
50
  readonly parentWorkflowExecutionToken?: string;
51
51
  readonly parentWorkflowId?: string;
52
52
  readonly scheduleId?: string;
53
- readonly status?: unknown;
53
+ readonly status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended' | ReadonlyArray<'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended'>;
54
54
  readonly tags?: ReadonlyArray<string>;
55
55
  readonly type?: string;
56
56
  readonly updatedAt?: SharedGtGteLt_d9a61361;
@@ -76,7 +76,7 @@ export type ClientOperationTypes = {
76
76
  readonly token: string;
77
77
  };
78
78
  readonly output: {
79
- readonly ok: boolean;
79
+ readonly ok: true;
80
80
  };
81
81
  readonly faults: 'InvalidParams' | 'NotFound';
82
82
  };
@@ -89,7 +89,7 @@ export type ClientOperationTypes = {
89
89
  readonly token: string;
90
90
  };
91
91
  readonly output: {
92
- readonly ok: boolean;
92
+ readonly ok: true;
93
93
  };
94
94
  readonly faults: 'InvalidParams' | 'NotFound';
95
95
  };
@@ -98,10 +98,10 @@ export type ClientOperationTypes = {
98
98
  readonly output: {
99
99
  readonly items: ReadonlyArray<{
100
100
  readonly currentValue: number;
101
- readonly firedAt: unknown;
101
+ readonly firedAt: number | null;
102
102
  readonly metric: 'workflow.failure_rate' | 'activity.p99_duration' | 'storage.size';
103
103
  readonly threshold: number;
104
- readonly window: unknown;
104
+ readonly window: string | null;
105
105
  }>;
106
106
  };
107
107
  readonly faults: never;
@@ -128,7 +128,7 @@ export type ClientOperationTypes = {
128
128
  readonly workflowId?: unknown;
129
129
  };
130
130
  readonly output: {
131
- readonly ok: boolean;
131
+ readonly ok: true;
132
132
  };
133
133
  readonly faults: 'NotFound';
134
134
  };
@@ -147,7 +147,34 @@ export type ClientOperationTypes = {
147
147
  readonly workflowId?: string;
148
148
  };
149
149
  readonly output: {
150
- readonly items: ReadonlyArray<unknown>;
150
+ readonly items: ReadonlyArray<{
151
+ readonly allowPartial: boolean;
152
+ readonly artifact: unknown;
153
+ readonly createdAt: number;
154
+ readonly reviewId: string;
155
+ readonly reviewType: string;
156
+ readonly reviewers: ReadonlyArray<string>;
157
+ readonly status: 'pending';
158
+ readonly timeout?: number;
159
+ readonly webhookUrl?: string;
160
+ readonly workflowId: string;
161
+ } | {
162
+ readonly allowPartial: boolean;
163
+ readonly artifact: unknown;
164
+ readonly createdAt: number;
165
+ readonly decision: 'approved' | 'rejected' | 'needs-changes';
166
+ readonly feedback?: string;
167
+ readonly reviewId: string;
168
+ readonly reviewType: string;
169
+ readonly reviewer: string;
170
+ readonly reviewers: ReadonlyArray<string>;
171
+ readonly sectionDecisions?: Record<string, unknown>;
172
+ readonly status: 'completed';
173
+ readonly timeout?: number;
174
+ readonly timestamp: number;
175
+ readonly webhookUrl?: string;
176
+ readonly workflowId: string;
177
+ }>;
151
178
  };
152
179
  readonly faults: never;
153
180
  };
@@ -256,7 +283,7 @@ export type ClientOperationTypes = {
256
283
  readonly output: {
257
284
  readonly method: 'jwt' | 'api-key' | 'mtls' | 'stdio-local' | 'unauthenticated';
258
285
  readonly scopes: ReadonlyArray<'workflows:read' | 'workflows:write' | 'workflows:admin' | 'schedules:read' | 'schedules:write' | 'signals:write' | 'updates:write' | 'queries:read' | 'reviews:read' | 'reviews:write' | 'attributes:read' | 'attributes:write' | 'tags:write' | 'streams:read' | 'events:read' | 'storage:read' | 'storage:write' | 'storage:admin' | 'workers:write' | 'system:read' | 'system:admin'>;
259
- readonly subject: unknown;
286
+ readonly subject: string | null;
260
287
  };
261
288
  readonly faults: never;
262
289
  };
@@ -264,7 +291,7 @@ export type ClientOperationTypes = {
264
291
  readonly input: {};
265
292
  readonly output: {
266
293
  readonly activities: unknown;
267
- readonly registryVersion: number;
294
+ readonly registryVersion: 1;
268
295
  readonly workflows: unknown;
269
296
  };
270
297
  readonly faults: never;
@@ -276,8 +303,8 @@ export type ClientOperationTypes = {
276
303
  readonly backlog: number;
277
304
  readonly connectedWorkers: number;
278
305
  readonly inFlight: number;
279
- readonly oldestEnqueuedAt: unknown;
280
- readonly oldestQueuedAgeMs: unknown;
306
+ readonly oldestEnqueuedAt: number | null;
307
+ readonly oldestQueuedAgeMs: number | null;
281
308
  readonly queue: string;
282
309
  readonly schedulingPolicy: 'priority' | 'fifo' | 'lifo';
283
310
  readonly waitingPollers: number;
@@ -287,18 +314,20 @@ export type ClientOperationTypes = {
287
314
  };
288
315
  'weft.tasks.diagnostics': {
289
316
  readonly input: {
317
+ readonly includeExpectedDelayed: boolean;
290
318
  readonly limit: number;
291
319
  readonly operationId?: string;
292
320
  readonly queue?: string;
293
321
  readonly retryStormMinimumAttempts: number;
294
322
  readonly staleHeartbeatAfterMs: number;
295
323
  readonly staleQueuedAfterMs: number;
324
+ readonly unadoptedAfterMs: number;
296
325
  readonly workflowId?: string;
297
326
  };
298
327
  readonly output: {
299
328
  readonly items: ReadonlyArray<{
300
329
  readonly activityName?: string;
301
- readonly deadLetterReason?: string;
330
+ readonly deadLetterReason?: 'result-resolution-storage-exhausted';
302
331
  readonly deadLetteredAt?: number;
303
332
  readonly evidence: ReadonlyArray<string>;
304
333
  readonly executionLatencyMs?: number;
@@ -316,14 +345,35 @@ export type ClientOperationTypes = {
316
345
  readonly storageError?: string;
317
346
  readonly workerId?: string;
318
347
  readonly workflowId?: string;
348
+ } | {
349
+ readonly availableAt: number;
350
+ readonly evidence: ReadonlyArray<string>;
351
+ readonly kind: 'delayed';
352
+ readonly operationId: string;
353
+ readonly queue: string;
354
+ readonly requeueCount: number;
355
+ readonly retryCount: number;
356
+ readonly state: 'queued';
357
+ readonly workflowId?: string;
358
+ } | {
359
+ readonly adopted: false;
360
+ readonly evidence: ReadonlyArray<string>;
361
+ readonly kind: 'unadopted-terminal';
362
+ readonly operationId: string;
363
+ readonly queue: string;
364
+ readonly state: 'resolved';
365
+ readonly terminalAt: number;
366
+ readonly workflowId?: string;
319
367
  }>;
320
368
  readonly limit: number;
321
369
  readonly summary: {
322
370
  readonly allWorkersAtCapacity: number;
323
371
  readonly deadLettered: number;
372
+ readonly delayed: number;
324
373
  readonly retryStorms: number;
325
374
  readonly staleInflight: number;
326
375
  readonly stuckQueued: number;
376
+ readonly unadoptedTerminal: number;
327
377
  };
328
378
  };
329
379
  readonly faults: never;
@@ -333,7 +383,7 @@ export type ClientOperationTypes = {
333
383
  readonly operationId: string;
334
384
  };
335
385
  readonly output: {
336
- readonly ok: boolean;
386
+ readonly ok: true;
337
387
  };
338
388
  readonly faults: 'NotFound';
339
389
  };
@@ -371,7 +421,29 @@ export type ClientOperationTypes = {
371
421
  readonly workerId: string;
372
422
  };
373
423
  readonly output: {
374
- readonly worker: unknown;
424
+ readonly worker: {
425
+ readonly deploymentVersion: {
426
+ readonly artifactDigest: string;
427
+ readonly buildId: string;
428
+ readonly deploymentName: string;
429
+ readonly manifestDigest: string;
430
+ readonly manifestVersion: number;
431
+ readonly protocolVersion: number;
432
+ readonly runtimeName: string;
433
+ readonly runtimeVersion: string;
434
+ readonly sdkVersion: string;
435
+ readonly workflows: Record<string, unknown>;
436
+ };
437
+ readonly instance: {
438
+ readonly connectedAt: number;
439
+ readonly health: 'active' | 'draining' | 'drained';
440
+ readonly heartbeatAgeMs: number;
441
+ readonly lastHeartbeatAt: number;
442
+ readonly queue: string;
443
+ readonly startedAt: number;
444
+ readonly workerId: string;
445
+ };
446
+ } | null;
375
447
  };
376
448
  readonly faults: never;
377
449
  };
@@ -388,14 +460,14 @@ export type ClientOperationTypes = {
388
460
  readonly output: {
389
461
  readonly deployments: ReadonlyArray<{
390
462
  readonly activeWorkers: number;
391
- readonly buildId: unknown;
392
- readonly deploymentName: unknown;
463
+ readonly buildId: string | null;
464
+ readonly deploymentName: string | null;
393
465
  readonly drainedWorkers: number;
394
466
  readonly drainingWorkers: number;
395
467
  readonly health: 'active' | 'draining' | 'drained';
396
468
  readonly inFlight: number;
397
- readonly oldestStartedAt: unknown;
398
- readonly runtimeVersion: unknown;
469
+ readonly oldestStartedAt: number | null;
470
+ readonly runtimeVersion: string | null;
399
471
  readonly workers: number;
400
472
  }>;
401
473
  readonly items: ReadonlyArray<{
@@ -467,14 +539,16 @@ export type ClientOperationTypes = {
467
539
  readonly attributes?: ReadonlyArray<SharedGtGteKey_e658e64c>;
468
540
  readonly createdAt?: SharedGtGteLt_d9a61361;
469
541
  readonly executionDeadline?: SharedGtGteLt_d9a61361;
470
- readonly failureCategory?: unknown;
471
- readonly groupBy: unknown;
542
+ readonly failureCategory?: 'application' | 'timeout' | 'cancellation' | 'resource' | 'system' | ReadonlyArray<'application' | 'timeout' | 'cancellation' | 'resource' | 'system'>;
543
+ readonly groupBy: 'status' | 'type' | 'failureCategory' | {
544
+ readonly attribute: string;
545
+ };
472
546
  readonly idPrefix?: string;
473
547
  readonly limit?: number;
474
548
  readonly parentWorkflowExecutionToken?: string;
475
549
  readonly parentWorkflowId?: string;
476
550
  readonly scheduleId?: string;
477
- readonly status?: unknown;
551
+ readonly status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended' | ReadonlyArray<'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended'>;
478
552
  readonly tags?: ReadonlyArray<string>;
479
553
  readonly type?: string;
480
554
  readonly updatedAt?: SharedGtGteLt_d9a61361;
@@ -482,7 +556,7 @@ export type ClientOperationTypes = {
482
556
  readonly output: {
483
557
  readonly groups: ReadonlyArray<{
484
558
  readonly count: number;
485
- readonly key: unknown;
559
+ readonly key: string | null;
486
560
  }>;
487
561
  readonly total: number;
488
562
  readonly truncated: boolean;
@@ -502,22 +576,22 @@ export type ClientOperationTypes = {
502
576
  readonly workflowId: string;
503
577
  };
504
578
  readonly output: {
505
- readonly ok: boolean;
579
+ readonly ok: true;
506
580
  };
507
581
  readonly faults: never;
508
582
  };
509
583
  'weft.workflows.bulk.cancel': {
510
- readonly input: SharedAttributesBulkConcurrenc_ff397168;
584
+ readonly input: SharedAttributesBulkConcurrenc_0f0d07d6;
511
585
  readonly output: unknown;
512
586
  readonly faults: never;
513
587
  };
514
588
  'weft.workflows.bulk.delete': {
515
- readonly input: SharedAttributesBulkConcurrenc_ff397168;
589
+ readonly input: SharedAttributesBulkConcurrenc_0f0d07d6;
516
590
  readonly output: unknown;
517
591
  readonly faults: 'Unprocessable';
518
592
  };
519
593
  'weft.workflows.bulk.retryfailed': {
520
- readonly input: SharedAttributesBulkConcurrenc_ff397168;
594
+ readonly input: SharedAttributesBulkConcurrenc_0f0d07d6;
521
595
  readonly output: unknown;
522
596
  readonly faults: never;
523
597
  };
@@ -529,7 +603,7 @@ export type ClientOperationTypes = {
529
603
  readonly createdAt?: SharedGtGteLt_d9a61361;
530
604
  readonly dryRun?: boolean;
531
605
  readonly executionDeadline?: SharedGtGteLt_d9a61361;
532
- readonly failureCategory?: unknown;
606
+ readonly failureCategory?: 'application' | 'timeout' | 'cancellation' | 'resource' | 'system' | ReadonlyArray<'application' | 'timeout' | 'cancellation' | 'resource' | 'system'>;
533
607
  readonly idPrefix?: string;
534
608
  readonly limit?: number;
535
609
  readonly name: string;
@@ -539,7 +613,7 @@ export type ClientOperationTypes = {
539
613
  readonly payload?: unknown;
540
614
  readonly requestId?: string;
541
615
  readonly scheduleId?: string;
542
- readonly status?: unknown;
616
+ readonly status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended' | ReadonlyArray<'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended'>;
543
617
  readonly tags?: ReadonlyArray<string>;
544
618
  readonly type?: string;
545
619
  readonly updatedAt?: SharedGtGteLt_d9a61361;
@@ -552,7 +626,7 @@ export type ClientOperationTypes = {
552
626
  readonly bulkConcurrency?: number;
553
627
  readonly confirmationToken?: string;
554
628
  readonly dryRun?: boolean;
555
- readonly filter?: SharedAttributesCreatedAtExecu_0caddefc;
629
+ readonly filter?: SharedAttributesCreatedAtExecu_47f8e20e;
556
630
  readonly operation: 'add' | 'remove';
557
631
  readonly requestId?: string;
558
632
  readonly tags: ReadonlyArray<string>;
@@ -618,15 +692,15 @@ export type ClientOperationTypes = {
618
692
  readonly attributes?: ReadonlyArray<SharedGtGteKey_e658e64c>;
619
693
  readonly createdAt?: SharedGtGteLt_d9a61361;
620
694
  readonly executionDeadline?: SharedGtGteLt_d9a61361;
621
- readonly failureCategory?: unknown;
695
+ readonly failureCategory?: string | ReadonlyArray<string>;
622
696
  readonly idPrefix?: string;
623
- readonly include?: unknown;
697
+ readonly include?: string | ReadonlyArray<string>;
624
698
  readonly limit?: number;
625
699
  readonly offset?: number;
626
700
  readonly parentWorkflowExecutionToken?: string;
627
701
  readonly parentWorkflowId?: string;
628
702
  readonly scheduleId?: string;
629
- readonly status?: unknown;
703
+ readonly status?: string | ReadonlyArray<string>;
630
704
  readonly tags?: ReadonlyArray<string>;
631
705
  readonly type?: string;
632
706
  readonly updatedAt?: SharedGtGteLt_d9a61361;
@@ -635,7 +709,7 @@ export type ClientOperationTypes = {
635
709
  readonly faults: 'Unprocessable';
636
710
  };
637
711
  'weft.workflows.purge': {
638
- readonly input: SharedAttributesCreatedAtExecu_0caddefc;
712
+ readonly input: SharedAttributesCreatedAtExecu_47f8e20e;
639
713
  readonly output: unknown;
640
714
  readonly faults: never;
641
715
  };
@@ -650,7 +724,7 @@ export type ClientOperationTypes = {
650
724
  };
651
725
  'weft.workflows.replay': {
652
726
  readonly input: {
653
- readonly step: unknown;
727
+ readonly step: string | number;
654
728
  readonly workflowId: string;
655
729
  };
656
730
  readonly output: unknown;
@@ -676,7 +750,10 @@ export type ClientOperationTypes = {
676
750
  readonly input: {
677
751
  readonly workflowId: string;
678
752
  };
679
- readonly output: unknown;
753
+ readonly output: {
754
+ readonly occurrence?: number;
755
+ readonly scheduleId: string;
756
+ } | null;
680
757
  readonly faults: never;
681
758
  };
682
759
  'weft.workflows.signal': {
@@ -687,7 +764,7 @@ export type ClientOperationTypes = {
687
764
  readonly workflowId: string;
688
765
  };
689
766
  readonly output: {
690
- readonly ok: boolean;
767
+ readonly ok: true;
691
768
  };
692
769
  readonly faults: 'NotFound';
693
770
  };
@@ -754,7 +831,7 @@ export type ClientOperationTypes = {
754
831
  readonly workflowId: string;
755
832
  };
756
833
  readonly output: {
757
- readonly ok: boolean;
834
+ readonly ok: true;
758
835
  };
759
836
  readonly faults: 'NotFound' | 'Unprocessable';
760
837
  };
@@ -764,7 +841,7 @@ export type ClientOperationTypes = {
764
841
  readonly workflowId: string;
765
842
  };
766
843
  readonly output: {
767
- readonly ok: boolean;
844
+ readonly ok: true;
768
845
  };
769
846
  readonly faults: 'NotFound' | 'Unprocessable';
770
847
  };
@@ -38,7 +38,7 @@ export function createHttpClientStorage(baseUrl, headers) {
38
38
  await requestResponse(baseUrl, `/storage/${encodeURIComponent(key)}`, headers, {
39
39
  method: "PUT",
40
40
  headers: { "content-type": "application/octet-stream" },
41
- body: new Blob([value])
41
+ body: new Blob([new Uint8Array(value)])
42
42
  });
43
43
  },
44
44
  async delete(key) {
package/dist/http.js CHANGED
@@ -1,2 +1,2 @@
1
- async function*T(F,Q){if(F.body===null)return;let Y=F.body.getReader(),_=new TextDecoder,$="",M=0,H=!1;try{while(!0){let{done:k,value:B}=await Y.read();if(k){H=!0;break}if(M+=B.byteLength,M>Q.maximumBytes)throw Q.sizeLimitError();$+=_.decode(B,{stream:!0});let R=$.split(`
2
- `);$=R.pop()??"";for(let w of R)yield w}if($+=_.decode(),$.length>0)yield $}finally{if(!H)try{await Y.cancel()}catch{}Y.releaseLock()}}function q(F){let Q=[];for(let Y=0;Y<F.length;Y+=512)Q.push(String.fromCharCode(...F.subarray(Y,Y+512)));return btoa(Q.join(""))}function C(F){let Q=atob(F),Y=new Uint8Array(Q.length);for(let _=0;_<Q.length;_+=1)Y[_]=Q.charCodeAt(_);return Y}function D(F){return typeof F==="object"&&F!==null&&!Array.isArray(F)}async function L(F,Q){return await F.get(Q)!==null}async function*G(F,Q,Y){for await(let[_]of F.scan(Q,Y))yield _}async function U(F,Q){let Y=0;for await(let _ of G(F,Q))Y++;return Y}async function E(F,Q){let Y=[];for await(let _ of G(F,Q))Y.push({type:"delete",key:_});if(Y.length===0)return 0;return await F.batch(Y),Y.length}async function N(F,Q,Y){let _=[];for await(let $ of G(F,Q,Y))_.push({type:"delete",key:$});if(_.length===0)return 0;return await F.batch(_),_.length}function P(F,Q,Y){if(!F.capabilities()[Q])throw Error(`Feature "${Y}" requires storage capability "${Q}", but this storage backend does not provide it.`)}var K="default";function Z(F){return encodeURIComponent(F)}var O={workflowOwnerEpoch:(F)=>`wf-owner-epoch:${Z(F)}`,workflowOwnerHolder:(F)=>`wf-owner-holder:${Z(F)}`,ownershipModeMarker:()=>"ownership-mode-marker"};var W=1e4;class b extends Error{code="StorageBatchOperationLimitExceededError";cap=W;count;target;constructor(F,Q){super(`${F} count ${Q} exceeds MAX_BATCH_OPERATIONS (${W}).`);this.name="StorageBatchOperationLimitExceededError",this.target=F,this.count=Q}}function X(F,Q){if(Q>W)throw new b(F,Q)}function v(F){return F.length>0?F.slice(0,-1)+String.fromCharCode(F.charCodeAt(F.length-1)+1):"ÿ"}function LF(F,Q={}){if(Q.gt!==void 0&&F<=Q.gt)return!1;if(Q.gte!==void 0&&F<Q.gte)return!1;if(Q.lt!==void 0&&F>=Q.lt)return!1;if(Q.lte!==void 0&&F>Q.lte)return!1;return!0}function UF(F,Q){if(F===null||Q===null)return F===Q;if(F.byteLength!==Q.byteLength)return!1;for(let Y=0;Y<F.byteLength;Y++)if(F[Y]!==Q[Y])return!1;return!0}async function h(F,Q){if(F.has)return F.has(Q);return L(F,Q)}function m(F,Q,Y){if(F.keys)return F.keys(Q,Y);return G(F,Q,Y)}async function x(F,Q){if(F.count)return F.count(Q);return U(F,Q)}async function y(F,Q){if(F.deletePrefix)return F.deletePrefix(Q);return E(F,Q)}async function c(F,Q,Y){if(X("conditionalBatch conditions",Q.length),X("conditionalBatch operations",Y.length),P(F,"conditionalBatch","storageConditionalBatch"),!F.conditionalBatch)throw Error("This storage backend reports conditionalBatch capability but does not implement the conditionalBatch() method.");return F.conditionalBatch(Q,Y)}var J=(F)=>String(F).padStart(16,"0"),f="0",l="1",S=(F,Q,Y,_)=>`sig:${Z(F)}:${Z(Q)}:${_}:${Z(Y)}`,EF={workflow:(F)=>`wf:${Z(F)}`,checkpoint:(F)=>`wf:${Z(F)}:ckpt`,checkpointHistory:(F,Q)=>`wf:${Z(F)}:ckpt:${String(Q).padStart(10,"0")}`,timelinePrefix:(F)=>`wf:${Z(F)}:timeline:`,timeline:(F,Q)=>`wf:${Z(F)}:timeline:${String(Q).padStart(10,"0")}`,schedule:(F)=>`schedule:${Z(F)}`,scheduleTick:(F,Q)=>`schedule-due:${String(F).padStart(16,"0")}:${Z(Q)}`,scheduleRun:(F)=>`schedule-run:${Z(F)}`,scheduleRunLink:(F)=>`schedule-run-link:${Z(F)}`,scheduleRunBySchedulePrefix:(F)=>`schedule-run-by-schedule:${Z(F)}:`,scheduleRunBySchedule:(F,Q)=>`schedule-run-by-schedule:${Z(F)}:${Z(Q)}`,operation:(F,Q,Y)=>`op:${F}:${J(Q)}:${Y}`,operationInflight:(F)=>`op:inflight:${F}`,operationQueued:(F)=>`op:queued:${F}`,operationResolved:(F)=>`op:resolved:${F}`,bulkOperationAuditPrefix:()=>"audit:bulk:",bulkOperationAudit:(F,Q,Y)=>`audit:bulk:${J(F)}:${Z(Q)}:${Z(Y)}`,operationResolvedByTimePrefix:()=>"op:resolved-by-time:",operationResolvedByTime:(F,Q)=>`op:resolved-by-time:${J(F)}:${Z(Q)}`,asyncActivity:(F,Q)=>`async-act:v1:${Z(F)}:${Z(Q)}`,asyncActivityResolution:(F,Q)=>`async-act:v1:${Z(F)}:${Z(Q)}:resolution`,activityReconciliationPrefix:(F)=>`actrec:v1:${Z(F)}:`,activityReconciliation:(F,Q,Y)=>`actrec:v1:${Z(F)}:${Z(Q)}:${Y}`,eventPrefix:(F)=>`ev:${Z(F)}:`,event:(F,Q)=>`ev:${Z(F)}:${String(Q).padStart(10,"0")}`,eventHead:(F)=>`ev:${Z(F)}:head`,eventWatermark:(F)=>`ev:${Z(F)}:watermark`,fleetEventPrefix:()=>"fleet-event:",fleetEvent:(F)=>`fleet-event:${String(F).padStart(10,"0")}`,fleetEventTail:()=>"fleet-event-tail",fleetEventByWorkflowPrefix:(F)=>`fleet-event-by-workflow:${Z(F)}:`,fleetEventByWorkflow:(F,Q)=>`fleet-event-by-workflow:${Z(F)}:${String(Q).padStart(10,"0")}`,signal:(F,Q,Y)=>S(F,Q,Y,l),startSignal:(F,Q,Y)=>S(F,Q,Y,f),signalSequence:(F)=>`sigseq:v1:${Z(F)}`,signalAcceptedResponsePrefix:(F)=>`sigres:v1:${Z(F)}:`,signalAcceptedResponse:(F,Q,Y)=>`sigres:v1:${Z(F)}:${Z(Q)}:${Z(Y)}`,deadline:(F,Q)=>`wf-deadline:${J(F)}:${Z(Q)}`,terminalCleanup:(F,Q)=>`wf-cleanup:${J(F)}:${Z(Q)}`,teardownTimer:(F,Q)=>`wf-teardown:${J(F)}:${Z(Q)}`,delayedStart:(F,Q)=>`wf-delayed:${J(F)}:${Z(Q)}`,terminalWorkflowPrefix:()=>"wf-terminal:",terminalWorkflow:(F,Q)=>`wf-terminal:${J(F)}:${Z(Q)}`,attribute:(F)=>`attr:${Z(F)}`,attributeIndex:(F,Q,Y)=>`idx:${F}:${Q}:${Z(Y)}`,tagIndex:(F,Q)=>`tag:${Z(F)}:${Z(Q)}`,updatePrefix:(F)=>`upd:${Z(F)}:`,update:(F,Q)=>`upd:${Z(F)}:${Q}`,updateResponse:(F)=>`upr:${F}`,updateIdempotency:(F,Q)=>`upk:${Z(F)}:${Q}`,startIdempotency:(F)=>`start-idem:${Z(F)}`,startIdempotencySignalId:(F)=>`start-idem:${F}`,livenessPrefix:()=>"liveness:",liveness:(F)=>`liveness:${Z(F)}`,leasePrefix:()=>"lease:",leaseEpoch:()=>"lease:epoch",leaseHolder:()=>"lease:holder",...O,budget:(F,Q,Y)=>`budget:${F}:${Q}:${Y}`,review:(F,Q)=>`review:${Z(F)}:${Q}`,workflowHeaders:(F)=>`wf-headers:${Z(F)}`,childCancellationPrefix:(F)=>`child-cancel:${Z(F)}:`,childCancellation:(F,Q)=>`child-cancel:${Z(F)}:${Z(Q)}`,childWorkflowByParentPrefix:(F,Q)=>`child-by-parent:${Z(F)}:${Q===void 0?"":`${Z(Q)}:`}`,childWorkflowByParent:(F,Q,Y)=>`child-by-parent:${Z(F)}:${Q===void 0?"":`${Z(Q)}:`}${Z(Y)}`,terminalCleanupNeeded:(F)=>`wf-cleanup-needed:${Z(F)}`,workflowConcurrency:(F,Q)=>`wf-concurrency:${Z(F)}:${Z(Q)}`,workflowConcurrencyHolder:(F)=>`wf-concurrency-holder:${Z(F)}`,workflowHasServices:(F)=>`wf-has-services:${Z(F)}`,finalizerState:(F)=>`wf-finalizer-state:${Z(F)}`,teardownOwed:(F)=>`wf-teardown-needed:${Z(F)}`,teardownSucceeded:(F)=>`wf-teardown-succeeded:${Z(F)}`,teardownDeadLetter:(F)=>`wf-teardown-deadletter:${Z(F)}`,offload:(F,Q)=>`offload:${Z(F)}:${Q}`,archive:(F,Q)=>`archive:${Z(F)}:${Q}`,stateExecution:(F,Q)=>`state:execution:${Z(F)}:${Z(Q)}`,stateWorkflow:(F,Q)=>`state:workflow-scope:${K}:${Z(F)}:${Z(Q)}`,streamChunkPrefix:(F,Q)=>`blob:${Z(F)}:${Q}:chunk:`,streamChunk:(F,Q,Y)=>`blob:${Z(F)}:${Q}:chunk:${String(Y).padStart(10,"0")}`,streamTail:(F,Q)=>`blob:${Z(F)}:${Q}:tail`,streamMetadata:(F,Q)=>`blob:${Z(F)}:${Q}:meta`,budgetCharged:(F)=>`budget-charged:${F}`,toolEffect:(F,Q,Y)=>`tool-effect:${Z(F)}:${Q}:${Y}`,workflowVisibilityStatus:(F,Q)=>`wf-idx-status:${Z(F)}:${Z(Q)}`,workflowVisibilityType:(F,Q)=>`wf-idx-type:${Z(F)}:${Z(Q)}`,workflowVisibilityCreated:(F,Q)=>`wf-idx-created:${J(F)}:${Z(Q)}`,workflowVisibilityUpdated:(F,Q)=>`wf-idx-updated:${J(F)}:${Z(Q)}`,workflowVisibilityDeadline:(F,Q)=>`wf-idx-deadline:${J(F)}:${Z(Q)}`,workflowVisibilityManifest:(F)=>`wf-idx-manifest:${Z(F)}`,workflowVisibilityMetaVersion:()=>"wf-idx-meta:version",workflowVisibilityMetaBuiltAt:()=>"wf-idx-meta:built-at",workflowVisibilityMetaCursor:()=>"wf-idx-meta:cursor"};function d(F){if(F===void 0)return;if(typeof F!=="number"||!Number.isInteger(F)||F<0)throw Error("deleteRange limit must be a finite non-negative integer");return F===0?0:F}function j(F){let Q={},Y=!1;for(let $ of["gt","gte","lt","lte"]){let M=F[$];if(M===void 0)continue;if(typeof M!=="string")throw Error("deleteRange bounds must be strings");Q[$]=M,Y=!0}if(!Y)throw Error("deleteRange requires at least one of gt/gte/lt/lte; use deletePrefix to delete a whole prefix");let _=d(F.limit);if(_!==void 0)Q.limit=_;return Q}async function I(F,Q,Y){let _=j(Y);if(F.deleteRange)return F.deleteRange(Q,_);return N(F,Q,_)}function p(F,Q){let Y={key:F,open:!1};if(Q.gte!==void 0&&Q.gte>Y.key)Y.key=Q.gte,Y.open=!1;if(Q.gt!==void 0&&Q.gt>=Y.key)Y.key=Q.gt,Y.open=!0;return Y}function a(F,Q){let Y={key:v(F),open:!0};if(Q.lt!==void 0&&Q.lt<=Y.key)Y.key=Q.lt,Y.open=!0;if(Q.lte!==void 0&&Q.lte<Y.key)Y.key=Q.lte,Y.open=!1;return Y}function WF(F,Q){let Y=p(F,Q),_=a(F,Q);if(Y.key>_.key||Y.key===_.key&&(Y.open||_.open))return null;return{lower:Y,upper:_}}function z(F){return F.replaceAll(/:+$/g,"")}function s(F,Q){let Y=z(F),_=z(Q);if(Y.length===0)return _;if(_.length===0)return Y;return`${Y}:${_}`}class A{#F;#Y;constructor(F,Q){this.#F=F,this.#Y=z(Q)}#Q(F){if(this.#Y.length===0)return F;return F.length===0?`${this.#Y}:`:`${this.#Y}:${F}`}#_(F){return F.map((Q)=>{if(Q.type==="put")return{type:"put",key:this.#Q(Q.key),value:Q.value};return{type:"delete",key:this.#Q(Q.key)}})}#$(F){if(this.#Y.length===0)return F;return F.slice(this.#Y.length+1)}#J(F){let Q={};if(F.limit!==void 0)Q.limit=F.limit;if(F.gt!==void 0)Q.gt=this.#Q(F.gt);if(F.gte!==void 0)Q.gte=this.#Q(F.gte);if(F.lt!==void 0)Q.lt=this.#Q(F.lt);if(F.lte!==void 0)Q.lte=this.#Q(F.lte);return Q}#Z(F={}){let Q=this.#J(F);if(F.reverse!==void 0)Q.reverse=F.reverse;return Q}#M(F){return this.#J(F)}capabilities(){return this.#F.capabilities()}scoped(F){return new A(this.#F,s(this.#Y,F))}async get(F){return this.#F.get(this.#Q(F))}async put(F,Q){await this.#F.put(this.#Q(F),Q)}async delete(F){await this.#F.delete(this.#Q(F))}async*scan(F,Q){for await(let[Y,_]of this.#F.scan(this.#Q(F),this.#Z(Q)))yield[this.#$(Y),_]}async batch(F){X("batch operations",F.length),await this.#F.batch(this.#_(F))}async conditionalBatch(F,Q){return c(this.#F,F.map((Y)=>({key:this.#Q(Y.key),expectedValue:Y.expectedValue})),this.#_(Q))}async has(F){return h(this.#F,this.#Q(F))}async deletePrefix(F){return y(this.#F,this.#Q(F))}async deleteRange(F,Q){let Y=this.#M(j(Q));return I(this.#F,this.#Q(F),Y)}async*keys(F,Q){for await(let Y of m(this.#F,this.#Q(F),this.#Z(Q)))yield this.#$(Y)}async count(F){return x(this.#F,this.#Q(F))}[Symbol.dispose](){this.#F[Symbol.dispose]()}}function g(F,Q){return new A(F,Q)}var n=67108864;function u(F){if(F.type==="put")return{type:"put",key:F.key,value:q(F.value)};return{type:"delete",key:F.key}}function i(F){return{key:F.key,expectedValue:F.expectedValue===null?null:q(F.expectedValue)}}function t(F){if(!D(F)||typeof F.key!=="string"||typeof F.value!=="string")throw Error("HTTPStorage scan response contained an invalid NDJSON entry.");return{key:F.key,value:F.value}}function r(F){if(!D(F)||typeof F.applied!=="boolean")throw Error('HTTPStorage conditional batch response must include a boolean "applied" field.');return F.applied}function V(F,Q,Y){if(Y!==void 0)F.searchParams.set(Q,String(Y))}function o(F){if(F.trim().length===0)return null;let Q=t(JSON.parse(F));return[Q.key,C(Q.value)]}class e{#F;#Y;#Q;constructor(F){this.#F=F.baseUrl instanceof URL?F.baseUrl:new URL(F.baseUrl),this.#Y={...F.headers},this.#Q=F.remoteConditionalBatch??!1}capabilities(){return{persistence:"remote",readAfterWrite:"eventual",scanConsistency:"best-effort",atomicBatch:!0,conditionalBatch:this.#Q,boundedRangeDelete:!1}}#_(F){let Q=this.#F.href.endsWith("/")?this.#F.href:`${this.#F.href}/`;return new URL(F.replace(/^\/+/,""),Q)}#$(F){return this.#_(`/v1/storage/${encodeURIComponent(F)}`)}#J(F,Q){let Y=this.#_("/v1/storage");return Y.searchParams.set("prefix",F),V(Y,"limit",Q.limit),V(Y,"reverse",Q.reverse),V(Y,"gt",Q.gt),V(Y,"gte",Q.gte),V(Y,"lt",Q.lt),V(Y,"lte",Q.lte),Y}async#Z(F,Q={},Y=[]){let _=new Headers(this.#Y);for(let[M,H]of new Headers(Q.headers).entries())_.set(M,H);let $=await fetch(F,{...Q,headers:_});if(!$.ok&&!Y.includes($.status))throw Error(`HTTPStorage request failed: ${Q.method??"GET"} ${F.pathname} returned ${String($.status)}.`);return $}async get(F){let Q=await this.#Z(this.#$(F),{method:"GET"},[404]);if(Q.status===404)return null;return new Uint8Array(await Q.arrayBuffer())}async put(F,Q){await this.#Z(this.#$(F),{method:"PUT",headers:{"content-type":"application/octet-stream"},body:new Blob([Q])})}async delete(F){await this.#Z(this.#$(F),{method:"DELETE"})}async*scan(F,Q={}){let Y=await this.#Z(this.#J(F,Q),{method:"GET",headers:{accept:"application/x-ndjson"}});for await(let _ of T(Y,{maximumBytes:n,sizeLimitError:()=>Error("HTTPStorage scan response exceeded the maximum allowed size.")})){let $=o(_);if($!==null)yield $}}async batch(F){X("batch operations",F.length),await this.#Z(this.#_("/v1/storage/-/batch"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({operations:F.map(u)})})}async conditionalBatch(F,Q){X("conditionalBatch conditions",F.length),X("conditionalBatch operations",Q.length);let Y=await this.#Z(this.#_("/v1/storage/-/conditional-batch"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({conditions:F.map(i),operations:Q.map(u)})});return r(await Y.json())}has(F){return L(this,F)}async*keys(F,Q){yield*G(this,F,Q)}count(F){return U(this,F)}deletePrefix(F){return E(this,F)}deleteRange(F,Q){return N(this,F,j(Q))}scoped(F){return g(this,F)}[Symbol.dispose](){}}export{e as HTTPStorage};
1
+ async function*O(e,t){if(e.body===null)return;let n=e.body.getReader(),i=new TextDecoder,o="",s=0,u=!1;try{while(!0){let{done:K,value:R}=await n.read();if(K){u=!0;break}if(s+=R.byteLength,s>t.maximumBytes)throw t.sizeLimitError();o+=i.decode(R,{stream:!0});let B=o.split(`
2
+ `);o=B.pop()??"";for(let V of B)yield V}if(o+=i.decode(),o.length>0)yield o}finally{if(!u)try{await n.cancel()}catch{}n.releaseLock()}}function m(e){let t=[];for(let n=0;n<e.length;n+=512)t.push(String.fromCharCode(...e.subarray(n,n+512)));return btoa(t.join(""))}function C(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i+=1)n[i]=t.charCodeAt(i);return n}function b(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}async function p(e,t){return await e.get(t)!==null}async function*c(e,t,n){for await(let[i]of e.scan(t,n))yield i}async function f(e,t){let n=0;for await(let i of c(e,t))n++;return n}async function y(e,t){let n=[];for await(let i of c(e,t))n.push({type:"delete",key:i});if(n.length===0)return 0;return await e.batch(n),n.length}async function h(e,t,n){let i=[];for await(let o of c(e,t,n))i.push({type:"delete",key:o});if(i.length===0)return 0;return await e.batch(i),i.length}function P(e,t,n){if(!e.capabilities()[t])throw Error(`Feature "${n}" requires storage capability "${t}", but this storage backend does not provide it.`)}var k="default";function r(e){return encodeURIComponent(e)}var v={workflowOwnerEpoch:(e)=>`wf-owner-epoch:${r(e)}`,workflowOwnerHolder:(e)=>`wf-owner-holder:${r(e)}`,ownershipModeMarker:()=>"ownership-mode-marker"};var S=1e4;class E extends Error{code="StorageBatchOperationLimitExceededError";cap=S;count;target;constructor(e,t){super(`${e} count ${t} exceeds MAX_BATCH_OPERATIONS (${S}).`);this.name="StorageBatchOperationLimitExceededError",this.target=e,this.count=t}}function l(e,t){if(t>S)throw new E(e,t)}function A(e){return e.length>0?e.slice(0,-1)+String.fromCharCode(e.charCodeAt(e.length-1)+1):"ÿ"}function fe(e,t={}){if(t.gt!==void 0&&e<=t.gt)return!1;if(t.gte!==void 0&&e<t.gte)return!1;if(t.lt!==void 0&&e>=t.lt)return!1;if(t.lte!==void 0&&e>t.lte)return!1;return!0}function ye(e,t){if(e===null||t===null)return e===t;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}async function D(e,t){if(e.has)return e.has(t);return p(e,t)}function U(e,t,n){if(e.keys)return e.keys(t,n);return c(e,t,n)}async function I(e,t){if(e.count)return e.count(t);return f(e,t)}async function L(e,t){if(e.deletePrefix)return e.deletePrefix(t);return y(e,t)}async function _(e,t,n){if(l("conditionalBatch conditions",t.length),l("conditionalBatch operations",n.length),P(e,"conditionalBatch","storageConditionalBatch"),!e.conditionalBatch)throw Error("This storage backend reports conditionalBatch capability but does not implement the conditionalBatch() method.");return e.conditionalBatch(t,n)}var a=(e)=>String(e).padStart(16,"0"),q="0",M="1",T=(e,t,n,i)=>`sig:${r(e)}:${r(t)}:${i}:${r(n)}`,he={workflow:(e)=>`wf:${r(e)}`,checkpoint:(e)=>`wf:${r(e)}:ckpt`,checkpointHistory:(e,t)=>`wf:${r(e)}:ckpt:${String(t).padStart(10,"0")}`,timelinePrefix:(e)=>`wf:${r(e)}:timeline:`,timeline:(e,t)=>`wf:${r(e)}:timeline:${String(t).padStart(10,"0")}`,schedule:(e)=>`schedule:${r(e)}`,scheduleTick:(e,t)=>`schedule-due:${String(e).padStart(16,"0")}:${r(t)}`,scheduleRun:(e)=>`schedule-run:${r(e)}`,scheduleRunLink:(e)=>`schedule-run-link:${r(e)}`,scheduleRunBySchedulePrefix:(e)=>`schedule-run-by-schedule:${r(e)}:`,scheduleRunBySchedule:(e,t)=>`schedule-run-by-schedule:${r(e)}:${r(t)}`,operation:(e,t,n)=>`op:${e}:${a(t)}:${n}`,operationInflight:(e)=>`op:inflight:${e}`,operationQueued:(e)=>`op:queued:${e}`,operationResolved:(e)=>`op:resolved:${e}`,bulkOperationAuditPrefix:()=>"audit:bulk:",bulkOperationAudit:(e,t,n)=>`audit:bulk:${a(e)}:${r(t)}:${r(n)}`,operationResolvedByTimePrefix:()=>"op:resolved-by-time:",operationResolvedByTime:(e,t)=>`op:resolved-by-time:${a(e)}:${r(t)}`,asyncActivity:(e,t)=>`async-act:v1:${r(e)}:${r(t)}`,asyncActivityResolution:(e,t)=>`async-act:v1:${r(e)}:${r(t)}:resolution`,activityReconciliationPrefix:(e)=>`actrec:v1:${r(e)}:`,activityReconciliation:(e,t,n)=>`actrec:v1:${r(e)}:${r(t)}:${n}`,eventPrefix:(e)=>`ev:${r(e)}:`,event:(e,t)=>`ev:${r(e)}:${String(t).padStart(10,"0")}`,eventHead:(e)=>`ev:${r(e)}:head`,eventWatermark:(e)=>`ev:${r(e)}:watermark`,fleetEventPrefix:()=>"fleet-event:",fleetEvent:(e)=>`fleet-event:${String(e).padStart(10,"0")}`,fleetEventTail:()=>"fleet-event-tail",fleetEventByWorkflowPrefix:(e)=>`fleet-event-by-workflow:${r(e)}:`,fleetEventByWorkflow:(e,t)=>`fleet-event-by-workflow:${r(e)}:${String(t).padStart(10,"0")}`,signal:(e,t,n)=>T(e,t,n,M),startSignal:(e,t,n)=>T(e,t,n,q),signalSequence:(e)=>`sigseq:v1:${r(e)}`,signalAcceptedResponsePrefix:(e)=>`sigres:v1:${r(e)}:`,signalAcceptedResponse:(e,t,n)=>`sigres:v1:${r(e)}:${r(t)}:${r(n)}`,deadline:(e,t)=>`wf-deadline:${a(e)}:${r(t)}`,terminalCleanup:(e,t)=>`wf-cleanup:${a(e)}:${r(t)}`,teardownTimer:(e,t)=>`wf-teardown:${a(e)}:${r(t)}`,delayedStart:(e,t)=>`wf-delayed:${a(e)}:${r(t)}`,terminalWorkflowPrefix:()=>"wf-terminal:",terminalWorkflow:(e,t)=>`wf-terminal:${a(e)}:${r(t)}`,attribute:(e)=>`attr:${r(e)}`,attributeIndex:(e,t,n)=>`idx:${e}:${t}:${r(n)}`,tagIndex:(e,t)=>`tag:${r(e)}:${r(t)}`,updatePrefix:(e)=>`upd:${r(e)}:`,update:(e,t)=>`upd:${r(e)}:${t}`,updateResponse:(e)=>`upr:${e}`,updateIdempotency:(e,t)=>`upk:${r(e)}:${t}`,startIdempotency:(e)=>`start-idem:${r(e)}`,startIdempotencySignalId:(e)=>`start-idem:${e}`,livenessPrefix:()=>"liveness:",liveness:(e)=>`liveness:${r(e)}`,leasePrefix:()=>"lease:",leaseEpoch:()=>"lease:epoch",leaseHolder:()=>"lease:holder",...v,budget:(e,t,n)=>`budget:${e}:${t}:${n}`,review:(e,t)=>`review:${r(e)}:${t}`,workflowHeaders:(e)=>`wf-headers:${r(e)}`,childCancellationPrefix:(e)=>`child-cancel:${r(e)}:`,childCancellation:(e,t)=>`child-cancel:${r(e)}:${r(t)}`,childWorkflowByParentPrefix:(e,t)=>`child-by-parent:${r(e)}:${t===void 0?"":`${r(t)}:`}`,childWorkflowByParent:(e,t,n)=>`child-by-parent:${r(e)}:${t===void 0?"":`${r(t)}:`}${r(n)}`,terminalCleanupNeeded:(e)=>`wf-cleanup-needed:${r(e)}`,workflowConcurrency:(e,t)=>`wf-concurrency:${r(e)}:${r(t)}`,workflowConcurrencyHolder:(e)=>`wf-concurrency-holder:${r(e)}`,workflowHasServices:(e)=>`wf-has-services:${r(e)}`,finalizerState:(e)=>`wf-finalizer-state:${r(e)}`,teardownOwed:(e)=>`wf-teardown-needed:${r(e)}`,teardownSucceeded:(e)=>`wf-teardown-succeeded:${r(e)}`,teardownDeadLetter:(e)=>`wf-teardown-deadletter:${r(e)}`,offload:(e,t)=>`offload:${r(e)}:${t}`,archive:(e,t)=>`archive:${r(e)}:${t}`,stateExecution:(e,t)=>`state:execution:${r(e)}:${r(t)}`,stateWorkflow:(e,t)=>`state:workflow-scope:${k}:${r(e)}:${r(t)}`,streamChunkPrefix:(e,t)=>`blob:${r(e)}:${t}:chunk:`,streamChunk:(e,t,n)=>`blob:${r(e)}:${t}:chunk:${String(n).padStart(10,"0")}`,streamTail:(e,t)=>`blob:${r(e)}:${t}:tail`,streamMetadata:(e,t)=>`blob:${r(e)}:${t}:meta`,budgetCharged:(e)=>`budget-charged:${e}`,toolEffect:(e,t,n)=>`tool-effect:${r(e)}:${t}:${n}`,workflowVisibilityStatus:(e,t)=>`wf-idx-status:${r(e)}:${r(t)}`,workflowVisibilityType:(e,t)=>`wf-idx-type:${r(e)}:${r(t)}`,workflowVisibilityCreated:(e,t)=>`wf-idx-created:${a(e)}:${r(t)}`,workflowVisibilityUpdated:(e,t)=>`wf-idx-updated:${a(e)}:${r(t)}`,workflowVisibilityDeadline:(e,t)=>`wf-idx-deadline:${a(e)}:${r(t)}`,workflowVisibilityManifest:(e)=>`wf-idx-manifest:${r(e)}`,workflowVisibilityMetaVersion:()=>"wf-idx-meta:version",workflowVisibilityMetaBuiltAt:()=>"wf-idx-meta:built-at",workflowVisibilityMetaCursor:()=>"wf-idx-meta:cursor"};function W(e){if(e===void 0)return;if(typeof e!=="number"||!Number.isInteger(e)||e<0)throw Error("deleteRange limit must be a finite non-negative integer");return e===0?0:e}function d(e){let t={},n=!1;for(let o of["gt","gte","lt","lte"]){let s=e[o];if(s===void 0)continue;if(typeof s!=="string")throw Error("deleteRange bounds must be strings");t[o]=s,n=!0}if(!n)throw Error("deleteRange requires at least one of gt/gte/lt/lte; use deletePrefix to delete a whole prefix");let i=W(e.limit);if(i!==void 0)t.limit=i;return t}async function N(e,t,n){let i=d(n);if(e.deleteRange)return e.deleteRange(t,i);return h(e,t,i)}function j(e,t){let n={key:e,open:!1};if(t.gte!==void 0&&t.gte>n.key)n.key=t.gte,n.open=!1;if(t.gt!==void 0&&t.gt>=n.key)n.key=t.gt,n.open=!0;return n}function G(e,t){let n={key:A(e),open:!0};if(t.lt!==void 0&&t.lt<=n.key)n.key=t.lt,n.open=!0;if(t.lte!==void 0&&t.lte<n.key)n.key=t.lte,n.open=!1;return n}function we(e,t){let n=j(e,t),i=G(e,t);if(n.key>i.key||n.key===i.key&&(n.open||i.open))return null;return{lower:n,upper:i}}function w(e){return e.replaceAll(/:+$/g,"")}function F(e,t){let n=w(e),i=w(t);if(n.length===0)return i;if(i.length===0)return n;return`${n}:${i}`}class x{#e;#n;constructor(e,t){this.#e=e,this.#n=w(t)}#t(e){if(this.#n.length===0)return e;return e.length===0?`${this.#n}:`:`${this.#n}:${e}`}#i(e){return e.map((t)=>{if(t.type==="put")return{type:"put",key:this.#t(t.key),value:t.value};return{type:"delete",key:this.#t(t.key)}})}#o(e){if(this.#n.length===0)return e;return e.slice(this.#n.length+1)}#a(e){let t={};if(e.limit!==void 0)t.limit=e.limit;if(e.gt!==void 0)t.gt=this.#t(e.gt);if(e.gte!==void 0)t.gte=this.#t(e.gte);if(e.lt!==void 0)t.lt=this.#t(e.lt);if(e.lte!==void 0)t.lte=this.#t(e.lte);return t}#r(e={}){let t=this.#a(e);if(e.reverse!==void 0)t.reverse=e.reverse;return t}#s(e){return this.#a(e)}capabilities(){return this.#e.capabilities()}scoped(e){return new x(this.#e,F(this.#n,e))}async get(e){return this.#e.get(this.#t(e))}async put(e,t){await this.#e.put(this.#t(e),t)}async delete(e){await this.#e.delete(this.#t(e))}async*scan(e,t){for await(let[n,i]of this.#e.scan(this.#t(e),this.#r(t)))yield[this.#o(n),i]}async batch(e){l("batch operations",e.length),await this.#e.batch(this.#i(e))}async conditionalBatch(e,t){return _(this.#e,e.map((n)=>({key:this.#t(n.key),expectedValue:n.expectedValue})),this.#i(t))}async has(e){return D(this.#e,this.#t(e))}async deletePrefix(e){return L(this.#e,this.#t(e))}async deleteRange(e,t){let n=this.#s(d(t));return N(this.#e,this.#t(e),n)}async*keys(e,t){for await(let n of U(this.#e,this.#t(e),this.#r(t)))yield this.#o(n)}async count(e){return I(this.#e,this.#t(e))}[Symbol.dispose](){this.#e[Symbol.dispose]()}}function H(e,t){return new x(e,t)}var Y=67108864;function z(e){if(e.type==="put")return{type:"put",key:e.key,value:m(e.value)};return{type:"delete",key:e.key}}function X(e){return{key:e.key,expectedValue:e.expectedValue===null?null:m(e.expectedValue)}}function J(e){if(!b(e)||typeof e.key!=="string"||typeof e.value!=="string")throw Error("HTTPStorage scan response contained an invalid NDJSON entry.");return{key:e.key,value:e.value}}function Z(e){if(!b(e)||typeof e.applied!=="boolean")throw Error('HTTPStorage conditional batch response must include a boolean "applied" field.');return e.applied}function g(e,t,n){if(n!==void 0)e.searchParams.set(t,String(n))}function Q(e){if(e.trim().length===0)return null;let t=J(JSON.parse(e));return[t.key,C(t.value)]}class ee{#e;#n;#t;constructor(e){this.#e=e.baseUrl instanceof URL?e.baseUrl:new URL(e.baseUrl),this.#n={...e.headers},this.#t=e.remoteConditionalBatch??!1}capabilities(){return{persistence:"remote",readAfterWrite:"eventual",scanConsistency:"best-effort",atomicBatch:!0,conditionalBatch:this.#t,boundedRangeDelete:!1}}#i(e){let t=this.#e.href.endsWith("/")?this.#e.href:`${this.#e.href}/`;return new URL(e.replace(/^\/+/,""),t)}#o(e){return this.#i(`/v1/storage/${encodeURIComponent(e)}`)}#a(e,t){let n=this.#i("/v1/storage");return n.searchParams.set("prefix",e),g(n,"limit",t.limit),g(n,"reverse",t.reverse),g(n,"gt",t.gt),g(n,"gte",t.gte),g(n,"lt",t.lt),g(n,"lte",t.lte),n}async#r(e,t={},n=[]){let i=new Headers(this.#n);for(let[s,u]of new Headers(t.headers).entries())i.set(s,u);let o=await fetch(e,{...t,headers:i});if(!o.ok&&!n.includes(o.status))throw Error(`HTTPStorage request failed: ${t.method??"GET"} ${e.pathname} returned ${String(o.status)}.`);return o}async get(e){let t=await this.#r(this.#o(e),{method:"GET"},[404]);if(t.status===404)return null;return new Uint8Array(await t.arrayBuffer())}async put(e,t){await this.#r(this.#o(e),{method:"PUT",headers:{"content-type":"application/octet-stream"},body:new Blob([new Uint8Array(t)])})}async delete(e){await this.#r(this.#o(e),{method:"DELETE"})}async*scan(e,t={}){let n=await this.#r(this.#a(e,t),{method:"GET",headers:{accept:"application/x-ndjson"}});for await(let i of O(n,{maximumBytes:Y,sizeLimitError:()=>Error("HTTPStorage scan response exceeded the maximum allowed size.")})){let o=Q(i);if(o!==null)yield o}}async batch(e){l("batch operations",e.length),await this.#r(this.#i("/v1/storage/-/batch"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({operations:e.map(z)})})}async conditionalBatch(e,t){l("conditionalBatch conditions",e.length),l("conditionalBatch operations",t.length);let n=await this.#r(this.#i("/v1/storage/-/conditional-batch"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({conditions:e.map(X),operations:t.map(z)})});return Z(await n.json())}has(e){return p(this,e)}async*keys(e,t){yield*c(this,e,t)}count(e){return f(this,e)}deletePrefix(e){return y(this,e)}deleteRange(e,t){return h(this,e,d(t))}scoped(e){return H(this,e)}[Symbol.dispose](){}}export{ee as HTTPStorage};
package/dist/indexeddb.js CHANGED
@@ -1 +1 @@
1
- async function E(U,Y){return await U.get(Y)!==null}async function*P(U,Y,Q){for await(let[Z]of U.scan(Y,Q))yield Z}async function h(U,Y){let Q=0;for await(let Z of P(U,Y))Q++;return Q}async function v(U,Y){let Q=[];for await(let Z of P(U,Y))Q.push({type:"delete",key:Z});if(Q.length===0)return 0;return await U.batch(Q),Q.length}async function b(U,Y,Q){let Z=[];for await(let $ of P(U,Y,Q))Z.push({type:"delete",key:$});if(Z.length===0)return 0;return await U.batch(Z),Z.length}function m(U,Y,Q){if(!U.capabilities()[Y])throw Error(`Feature "${Q}" requires storage capability "${Y}", but this storage backend does not provide it.`)}var x="default";function X(U){return encodeURIComponent(U)}var y={workflowOwnerEpoch:(U)=>`wf-owner-epoch:${X(U)}`,workflowOwnerHolder:(U)=>`wf-owner-holder:${X(U)}`,ownershipModeMarker:()=>"ownership-mode-marker"};var O=1e4;class g extends Error{code="StorageBatchOperationLimitExceededError";cap=O;count;target;constructor(U,Y){super(`${U} count ${Y} exceeds MAX_BATCH_OPERATIONS (${O}).`);this.name="StorageBatchOperationLimitExceededError",this.target=U,this.count=Y}}function z(U,Y){if(Y>O)throw new g(U,Y)}function j(U){return U.length>0?U.slice(0,-1)+String.fromCharCode(U.charCodeAt(U.length-1)+1):"ÿ"}function k(U,Y={}){if(Y.gt!==void 0&&U<=Y.gt)return!1;if(Y.gte!==void 0&&U<Y.gte)return!1;if(Y.lt!==void 0&&U>=Y.lt)return!1;if(Y.lte!==void 0&&U>Y.lte)return!1;return!0}function c(U,Y){if(U===null||Y===null)return U===Y;if(U.byteLength!==Y.byteLength)return!1;for(let Q=0;Q<U.byteLength;Q++)if(U[Q]!==Y[Q])return!1;return!0}async function u(U,Y){if(U.has)return U.has(Y);return E(U,Y)}function w(U,Y,Q){if(U.keys)return U.keys(Y,Q);return P(U,Y,Q)}async function f(U,Y){if(U.count)return U.count(Y);return h(U,Y)}async function l(U,Y){if(U.deletePrefix)return U.deletePrefix(Y);return v(U,Y)}async function p(U,Y,Q){if(z("conditionalBatch conditions",Y.length),z("conditionalBatch operations",Q.length),m(U,"conditionalBatch","storageConditionalBatch"),!U.conditionalBatch)throw Error("This storage backend reports conditionalBatch capability but does not implement the conditionalBatch() method.");return U.conditionalBatch(Y,Q)}var D=(U)=>String(U).padStart(16,"0"),t="0",r="1",I=(U,Y,Q,Z)=>`sig:${X(U)}:${X(Y)}:${Z}:${X(Q)}`,zU={workflow:(U)=>`wf:${X(U)}`,checkpoint:(U)=>`wf:${X(U)}:ckpt`,checkpointHistory:(U,Y)=>`wf:${X(U)}:ckpt:${String(Y).padStart(10,"0")}`,timelinePrefix:(U)=>`wf:${X(U)}:timeline:`,timeline:(U,Y)=>`wf:${X(U)}:timeline:${String(Y).padStart(10,"0")}`,schedule:(U)=>`schedule:${X(U)}`,scheduleTick:(U,Y)=>`schedule-due:${String(U).padStart(16,"0")}:${X(Y)}`,scheduleRun:(U)=>`schedule-run:${X(U)}`,scheduleRunLink:(U)=>`schedule-run-link:${X(U)}`,scheduleRunBySchedulePrefix:(U)=>`schedule-run-by-schedule:${X(U)}:`,scheduleRunBySchedule:(U,Y)=>`schedule-run-by-schedule:${X(U)}:${X(Y)}`,operation:(U,Y,Q)=>`op:${U}:${D(Y)}:${Q}`,operationInflight:(U)=>`op:inflight:${U}`,operationQueued:(U)=>`op:queued:${U}`,operationResolved:(U)=>`op:resolved:${U}`,bulkOperationAuditPrefix:()=>"audit:bulk:",bulkOperationAudit:(U,Y,Q)=>`audit:bulk:${D(U)}:${X(Y)}:${X(Q)}`,operationResolvedByTimePrefix:()=>"op:resolved-by-time:",operationResolvedByTime:(U,Y)=>`op:resolved-by-time:${D(U)}:${X(Y)}`,asyncActivity:(U,Y)=>`async-act:v1:${X(U)}:${X(Y)}`,asyncActivityResolution:(U,Y)=>`async-act:v1:${X(U)}:${X(Y)}:resolution`,activityReconciliationPrefix:(U)=>`actrec:v1:${X(U)}:`,activityReconciliation:(U,Y,Q)=>`actrec:v1:${X(U)}:${X(Y)}:${Q}`,eventPrefix:(U)=>`ev:${X(U)}:`,event:(U,Y)=>`ev:${X(U)}:${String(Y).padStart(10,"0")}`,eventHead:(U)=>`ev:${X(U)}:head`,eventWatermark:(U)=>`ev:${X(U)}:watermark`,fleetEventPrefix:()=>"fleet-event:",fleetEvent:(U)=>`fleet-event:${String(U).padStart(10,"0")}`,fleetEventTail:()=>"fleet-event-tail",fleetEventByWorkflowPrefix:(U)=>`fleet-event-by-workflow:${X(U)}:`,fleetEventByWorkflow:(U,Y)=>`fleet-event-by-workflow:${X(U)}:${String(Y).padStart(10,"0")}`,signal:(U,Y,Q)=>I(U,Y,Q,r),startSignal:(U,Y,Q)=>I(U,Y,Q,t),signalSequence:(U)=>`sigseq:v1:${X(U)}`,signalAcceptedResponsePrefix:(U)=>`sigres:v1:${X(U)}:`,signalAcceptedResponse:(U,Y,Q)=>`sigres:v1:${X(U)}:${X(Y)}:${X(Q)}`,deadline:(U,Y)=>`wf-deadline:${D(U)}:${X(Y)}`,terminalCleanup:(U,Y)=>`wf-cleanup:${D(U)}:${X(Y)}`,teardownTimer:(U,Y)=>`wf-teardown:${D(U)}:${X(Y)}`,delayedStart:(U,Y)=>`wf-delayed:${D(U)}:${X(Y)}`,terminalWorkflowPrefix:()=>"wf-terminal:",terminalWorkflow:(U,Y)=>`wf-terminal:${D(U)}:${X(Y)}`,attribute:(U)=>`attr:${X(U)}`,attributeIndex:(U,Y,Q)=>`idx:${U}:${Y}:${X(Q)}`,tagIndex:(U,Y)=>`tag:${X(U)}:${X(Y)}`,updatePrefix:(U)=>`upd:${X(U)}:`,update:(U,Y)=>`upd:${X(U)}:${Y}`,updateResponse:(U)=>`upr:${U}`,updateIdempotency:(U,Y)=>`upk:${X(U)}:${Y}`,startIdempotency:(U)=>`start-idem:${X(U)}`,startIdempotencySignalId:(U)=>`start-idem:${U}`,livenessPrefix:()=>"liveness:",liveness:(U)=>`liveness:${X(U)}`,leasePrefix:()=>"lease:",leaseEpoch:()=>"lease:epoch",leaseHolder:()=>"lease:holder",...y,budget:(U,Y,Q)=>`budget:${U}:${Y}:${Q}`,review:(U,Y)=>`review:${X(U)}:${Y}`,workflowHeaders:(U)=>`wf-headers:${X(U)}`,childCancellationPrefix:(U)=>`child-cancel:${X(U)}:`,childCancellation:(U,Y)=>`child-cancel:${X(U)}:${X(Y)}`,childWorkflowByParentPrefix:(U,Y)=>`child-by-parent:${X(U)}:${Y===void 0?"":`${X(Y)}:`}`,childWorkflowByParent:(U,Y,Q)=>`child-by-parent:${X(U)}:${Y===void 0?"":`${X(Y)}:`}${X(Q)}`,terminalCleanupNeeded:(U)=>`wf-cleanup-needed:${X(U)}`,workflowConcurrency:(U,Y)=>`wf-concurrency:${X(U)}:${X(Y)}`,workflowConcurrencyHolder:(U)=>`wf-concurrency-holder:${X(U)}`,workflowHasServices:(U)=>`wf-has-services:${X(U)}`,finalizerState:(U)=>`wf-finalizer-state:${X(U)}`,teardownOwed:(U)=>`wf-teardown-needed:${X(U)}`,teardownSucceeded:(U)=>`wf-teardown-succeeded:${X(U)}`,teardownDeadLetter:(U)=>`wf-teardown-deadletter:${X(U)}`,offload:(U,Y)=>`offload:${X(U)}:${Y}`,archive:(U,Y)=>`archive:${X(U)}:${Y}`,stateExecution:(U,Y)=>`state:execution:${X(U)}:${X(Y)}`,stateWorkflow:(U,Y)=>`state:workflow-scope:${x}:${X(U)}:${X(Y)}`,streamChunkPrefix:(U,Y)=>`blob:${X(U)}:${Y}:chunk:`,streamChunk:(U,Y,Q)=>`blob:${X(U)}:${Y}:chunk:${String(Q).padStart(10,"0")}`,streamTail:(U,Y)=>`blob:${X(U)}:${Y}:tail`,streamMetadata:(U,Y)=>`blob:${X(U)}:${Y}:meta`,budgetCharged:(U)=>`budget-charged:${U}`,toolEffect:(U,Y,Q)=>`tool-effect:${X(U)}:${Y}:${Q}`,workflowVisibilityStatus:(U,Y)=>`wf-idx-status:${X(U)}:${X(Y)}`,workflowVisibilityType:(U,Y)=>`wf-idx-type:${X(U)}:${X(Y)}`,workflowVisibilityCreated:(U,Y)=>`wf-idx-created:${D(U)}:${X(Y)}`,workflowVisibilityUpdated:(U,Y)=>`wf-idx-updated:${D(U)}:${X(Y)}`,workflowVisibilityDeadline:(U,Y)=>`wf-idx-deadline:${D(U)}:${X(Y)}`,workflowVisibilityManifest:(U)=>`wf-idx-manifest:${X(U)}`,workflowVisibilityMetaVersion:()=>"wf-idx-meta:version",workflowVisibilityMetaBuiltAt:()=>"wf-idx-meta:built-at",workflowVisibilityMetaCursor:()=>"wf-idx-meta:cursor"};function o(U){if(U===void 0)return;if(typeof U!=="number"||!Number.isInteger(U)||U<0)throw Error("deleteRange limit must be a finite non-negative integer");return U===0?0:U}function S(U){let Y={},Q=!1;for(let $ of["gt","gte","lt","lte"]){let J=U[$];if(J===void 0)continue;if(typeof J!=="string")throw Error("deleteRange bounds must be strings");Y[$]=J,Q=!0}if(!Q)throw Error("deleteRange requires at least one of gt/gte/lt/lte; use deletePrefix to delete a whole prefix");let Z=o(U.limit);if(Z!==void 0)Y.limit=Z;return Y}async function d(U,Y,Q){let Z=S(Q);if(U.deleteRange)return U.deleteRange(Y,Z);return b(U,Y,Z)}function e(U,Y){let Q={key:U,open:!1};if(Y.gte!==void 0&&Y.gte>Q.key)Q.key=Y.gte,Q.open=!1;if(Y.gt!==void 0&&Y.gt>=Q.key)Q.key=Y.gt,Q.open=!0;return Q}function UU(U,Y){let Q={key:j(U),open:!0};if(Y.lt!==void 0&&Y.lt<=Q.key)Q.key=Y.lt,Q.open=!0;if(Y.lte!==void 0&&Y.lte<Q.key)Q.key=Y.lte,Q.open=!1;return Q}function a(U,Y){let Q=e(U,Y),Z=UU(U,Y);if(Q.key>Z.key||Q.key===Z.key&&(Q.open||Z.open))return null;return{lower:Q,upper:Z}}function C(U){return U.replaceAll(/:+$/g,"")}function YU(U,Y){let Q=C(U),Z=C(Y);if(Q.length===0)return Z;if(Z.length===0)return Q;return`${Q}:${Z}`}class R{#Y;#Q;constructor(U,Y){this.#Y=U,this.#Q=C(Y)}#U(U){if(this.#Q.length===0)return U;return U.length===0?`${this.#Q}:`:`${this.#Q}:${U}`}#X(U){return U.map((Y)=>{if(Y.type==="put")return{type:"put",key:this.#U(Y.key),value:Y.value};return{type:"delete",key:this.#U(Y.key)}})}#Z(U){if(this.#Q.length===0)return U;return U.slice(this.#Q.length+1)}#$(U){let Y={};if(U.limit!==void 0)Y.limit=U.limit;if(U.gt!==void 0)Y.gt=this.#U(U.gt);if(U.gte!==void 0)Y.gte=this.#U(U.gte);if(U.lt!==void 0)Y.lt=this.#U(U.lt);if(U.lte!==void 0)Y.lte=this.#U(U.lte);return Y}#J(U={}){let Y=this.#$(U);if(U.reverse!==void 0)Y.reverse=U.reverse;return Y}#G(U){return this.#$(U)}capabilities(){return this.#Y.capabilities()}scoped(U){return new R(this.#Y,YU(this.#Q,U))}async get(U){return this.#Y.get(this.#U(U))}async put(U,Y){await this.#Y.put(this.#U(U),Y)}async delete(U){await this.#Y.delete(this.#U(U))}async*scan(U,Y){for await(let[Q,Z]of this.#Y.scan(this.#U(U),this.#J(Y)))yield[this.#Z(Q),Z]}async batch(U){z("batch operations",U.length),await this.#Y.batch(this.#X(U))}async conditionalBatch(U,Y){return p(this.#Y,U.map((Q)=>({key:this.#U(Q.key),expectedValue:Q.expectedValue})),this.#X(Y))}async has(U){return u(this.#Y,this.#U(U))}async deletePrefix(U){return l(this.#Y,this.#U(U))}async deleteRange(U,Y){let Q=this.#G(S(Y));return d(this.#Y,this.#U(U),Q)}async*keys(U,Y){for await(let Q of w(this.#Y,this.#U(U),this.#J(Y)))yield this.#Z(Q)}async count(U){return f(this.#Y,this.#U(U))}[Symbol.dispose](){this.#Y[Symbol.dispose]()}}function s(U,Y){return new R(U,Y)}var F="kv";function QU(U=globalThis){let{indexedDB:Y,IDBKeyRange:Q}=U;if(Y===void 0||Q===void 0)throw Error("IndexedDBStorage requires both indexedDB and IDBKeyRange runtime globals.");return{indexedDB:Y,IDBKeyRange:Q}}function N(U){return new Promise((Y,Q)=>{U.onsuccess=()=>Y(U.result),U.onerror=()=>Q(U.error)})}function XU(U,Y){let Q=null,Z=null,$=null,J=(G,H)=>{let V=G??Error(H);if(Z){let B=Z;Q=null,Z=null,B(V);return}$=V};return U.onsuccess=()=>{if(!Q)return;let G=Q;Q=null,Z=null,G(U.result)},U.onerror=()=>{J(U.error,"IndexedDB cursor request failed.")},Y.onerror=()=>{J(Y.error,"IndexedDB transaction failed.")},Y.onabort=()=>{J(Y.error,"IndexedDB transaction aborted.")},()=>{return new Promise((G,H)=>{if($){let V=$;$=null,H(V);return}if(Q=G,Z=H,U.readyState==="done"){let V=Q;Q=null,Z=null,V?.(U.result)}})}}async function*n(U,Y,Q,Z,$,J){let{limit:G,reverse:H}=Z,V=j(Q),B=Y.bound(Q,V,!1,!0),M=H?"prev":"next",W=U.transaction(F,"readonly"),L=W.objectStore(F),_=$(L,B,M),K=XU(_,W),T=0,q=!1;try{let A=await K();while(A){if(G!==void 0&&T>=G)break;let i=A.key;if(k(i,Z))yield J(A),T++;A.continue(),A=await K()}q=!0}finally{if(!q)try{W.abort()}catch{}}}class ZU{#Y;#Q=null;#U;#X;constructor(U="weft",Y=QU()){this.#Y=U,this.#X=Y,this.#U=this.#Z()}capabilities(){return{persistence:"local",readAfterWrite:"linearizable",scanConsistency:"best-effort",atomicBatch:!0,conditionalBatch:!0,boundedRangeDelete:!0}}#Z(){let U=this.#X.indexedDB.open(this.#Y,1);return U.onupgradeneeded=()=>{let Y=U.result;if(!Y.objectStoreNames.contains(F))Y.createObjectStore(F)},N(U).then((Y)=>{return this.#Q=Y,Y})}async get(U){let Z=(await this.#U).transaction(F,"readonly").objectStore(F),$=await N(Z.get(U));return $===void 0?null:new Uint8Array($)}async put(U,Y){let $=(await this.#U).transaction(F,"readwrite").objectStore(F);await N($.put(Y,U))}async delete(U){let Z=(await this.#U).transaction(F,"readwrite").objectStore(F);await N(Z.delete(U))}async has(U){let Z=(await this.#U).transaction(F,"readonly").objectStore(F);return await N(Z.count(U))>0}async deletePrefix(U){let Y=await this.#U,Q=j(U),Z=this.#X.IDBKeyRange.bound(U,Q,!1,!0);return new Promise(($,J)=>{let G=Y.transaction(F,"readwrite"),H=G.objectStore(F),V=0,B=H.count(Z);B.onsuccess=()=>{V=B.result,H.delete(Z)},G.oncomplete=()=>$(V),G.onerror=()=>J(G.error)})}async deleteRange(U,Y){let Q=S(Y),Z=a(U,Q);if(Z===null)return 0;let $=this.#X.IDBKeyRange.bound(Z.lower.key,Z.upper.key,Z.lower.open,Z.upper.open),J=await this.#U,{limit:G}=Q;return new Promise((H,V)=>{let B=J.transaction(F,"readwrite"),M=B.objectStore(F),W=0;if(G===void 0){let L=M.count($);L.onsuccess=()=>{W=L.result,M.delete($)}}else{let L=M.openCursor($,"next");L.onsuccess=()=>{let _=L.result;if(_===null||W>=G)return;if(_.delete(),W++,W<G)_.continue()}}B.oncomplete=()=>H(W),B.onerror=()=>V(B.error)})}async*scan(U,Y={}){let Q=await this.#U;yield*n(Q,this.#X.IDBKeyRange,U,Y,(Z,$,J)=>Z.openCursor($,J),(Z)=>[Z.key,new Uint8Array(Z.value)])}async batch(U){if(z("batch operations",U.length),U.length===0)return;let Y=await this.#U;return new Promise((Q,Z)=>{let $=Y.transaction(F,"readwrite"),J=$.objectStore(F);for(let G of U)if(G.type==="put")J.put(G.value,G.key);else J.delete(G.key);$.oncomplete=()=>Q(),$.onerror=()=>Z($.error)})}async conditionalBatch(U,Y){z("conditionalBatch conditions",U.length),z("conditionalBatch operations",Y.length);let Q=await this.#U;return new Promise((Z,$)=>{let J=Q.transaction(F,"readwrite"),G=J.objectStore(F),H=!1,V=!1,B=(L,_)=>{if(H)return;H=!0,$(L??Error(_))};J.oncomplete=()=>{if(H)return;H=!0,Z(!0)},J.onerror=()=>{B(J.error,"IndexedDB conditionalBatch transaction failed.")},J.onabort=()=>{if(H)return;if(H=!0,V){Z(!1);return}$(J.error??Error("IndexedDB conditionalBatch transaction aborted."))};let M=()=>{for(let L of Y)if(L.type==="put")G.put(L.value,L.key);else G.delete(L.key)},W=(L)=>{if(L>=U.length){M();return}let _=U[L],K=G.get(_.key);K.onsuccess=()=>{let T=K.result,q=T===void 0?null:new Uint8Array(T);if(!c(q,_.expectedValue)){V=!0,J.abort();return}W(L+1)},K.onerror=()=>{B(K.error,"IndexedDB conditionalBatch condition check failed.")}};W(0)})}async*keys(U,Y={}){let Q=await this.#U;yield*n(Q,this.#X.IDBKeyRange,U,Y,(Z,$,J)=>Z.openKeyCursor($,J),(Z)=>Z.key)}async count(U){let Y=await this.#U,Q=j(U),$=Y.transaction(F,"readonly").objectStore(F);return N($.count(this.#X.IDBKeyRange.bound(U,Q,!1,!0)))}scoped(U){return s(this,U)}[Symbol.dispose](){if(this.#Q)this.#Q.close(),this.#Q=null}}export{ZU as IndexedDBStorage};
1
+ async function k(e,t){return await e.get(t)!==null}async function*C(e,t,n){for await(let[i]of e.scan(t,n))yield i}async function I(e,t){let n=0;for await(let i of C(e,t))n++;return n}async function A(e,t){let n=[];for await(let i of C(e,t))n.push({type:"delete",key:i});if(n.length===0)return 0;return await e.batch(n),n.length}async function E(e,t,n){let i=[];for await(let o of C(e,t,n))i.push({type:"delete",key:o});if(i.length===0)return 0;return await e.batch(i),i.length}function T(e,t,n){if(!e.capabilities()[t])throw Error(`Feature "${n}" requires storage capability "${t}", but this storage backend does not provide it.`)}var K="default";function r(e){return encodeURIComponent(e)}var z={workflowOwnerEpoch:(e)=>`wf-owner-epoch:${r(e)}`,workflowOwnerHolder:(e)=>`wf-owner-holder:${r(e)}`,ownershipModeMarker:()=>"ownership-mode-marker"};var O=1e4;class L extends Error{code="StorageBatchOperationLimitExceededError";cap=O;count;target;constructor(e,t){super(`${e} count ${t} exceeds MAX_BATCH_OPERATIONS (${O}).`);this.name="StorageBatchOperationLimitExceededError",this.target=e,this.count=t}}function h(e,t){if(t>O)throw new L(e,t)}function w(e){return e.length>0?e.slice(0,-1)+String.fromCharCode(e.charCodeAt(e.length-1)+1):"ÿ"}function U(e,t={}){if(t.gt!==void 0&&e<=t.gt)return!1;if(t.gte!==void 0&&e<t.gte)return!1;if(t.lt!==void 0&&e>=t.lt)return!1;if(t.lte!==void 0&&e>t.lte)return!1;return!0}function V(e,t){if(e===null||t===null)return e===t;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}async function N(e,t){if(e.has)return e.has(t);return k(e,t)}function M(e,t,n){if(e.keys)return e.keys(t,n);return C(e,t,n)}async function j(e,t){if(e.count)return e.count(t);return I(e,t)}async function q(e,t){if(e.deletePrefix)return e.deletePrefix(t);return A(e,t)}async function W(e,t,n){if(h("conditionalBatch conditions",t.length),h("conditionalBatch operations",n.length),T(e,"conditionalBatch","storageConditionalBatch"),!e.conditionalBatch)throw Error("This storage backend reports conditionalBatch capability but does not implement the conditionalBatch() method.");return e.conditionalBatch(t,n)}var f=(e)=>String(e).padStart(16,"0"),Q="0",J="1",_=(e,t,n,i)=>`sig:${r(e)}:${r(t)}:${i}:${r(n)}`,me={workflow:(e)=>`wf:${r(e)}`,checkpoint:(e)=>`wf:${r(e)}:ckpt`,checkpointHistory:(e,t)=>`wf:${r(e)}:ckpt:${String(t).padStart(10,"0")}`,timelinePrefix:(e)=>`wf:${r(e)}:timeline:`,timeline:(e,t)=>`wf:${r(e)}:timeline:${String(t).padStart(10,"0")}`,schedule:(e)=>`schedule:${r(e)}`,scheduleTick:(e,t)=>`schedule-due:${String(e).padStart(16,"0")}:${r(t)}`,scheduleRun:(e)=>`schedule-run:${r(e)}`,scheduleRunLink:(e)=>`schedule-run-link:${r(e)}`,scheduleRunBySchedulePrefix:(e)=>`schedule-run-by-schedule:${r(e)}:`,scheduleRunBySchedule:(e,t)=>`schedule-run-by-schedule:${r(e)}:${r(t)}`,operation:(e,t,n)=>`op:${e}:${f(t)}:${n}`,operationInflight:(e)=>`op:inflight:${e}`,operationQueued:(e)=>`op:queued:${e}`,operationResolved:(e)=>`op:resolved:${e}`,bulkOperationAuditPrefix:()=>"audit:bulk:",bulkOperationAudit:(e,t,n)=>`audit:bulk:${f(e)}:${r(t)}:${r(n)}`,operationResolvedByTimePrefix:()=>"op:resolved-by-time:",operationResolvedByTime:(e,t)=>`op:resolved-by-time:${f(e)}:${r(t)}`,asyncActivity:(e,t)=>`async-act:v1:${r(e)}:${r(t)}`,asyncActivityResolution:(e,t)=>`async-act:v1:${r(e)}:${r(t)}:resolution`,activityReconciliationPrefix:(e)=>`actrec:v1:${r(e)}:`,activityReconciliation:(e,t,n)=>`actrec:v1:${r(e)}:${r(t)}:${n}`,eventPrefix:(e)=>`ev:${r(e)}:`,event:(e,t)=>`ev:${r(e)}:${String(t).padStart(10,"0")}`,eventHead:(e)=>`ev:${r(e)}:head`,eventWatermark:(e)=>`ev:${r(e)}:watermark`,fleetEventPrefix:()=>"fleet-event:",fleetEvent:(e)=>`fleet-event:${String(e).padStart(10,"0")}`,fleetEventTail:()=>"fleet-event-tail",fleetEventByWorkflowPrefix:(e)=>`fleet-event-by-workflow:${r(e)}:`,fleetEventByWorkflow:(e,t)=>`fleet-event-by-workflow:${r(e)}:${String(t).padStart(10,"0")}`,signal:(e,t,n)=>_(e,t,n,J),startSignal:(e,t,n)=>_(e,t,n,Q),signalSequence:(e)=>`sigseq:v1:${r(e)}`,signalAcceptedResponsePrefix:(e)=>`sigres:v1:${r(e)}:`,signalAcceptedResponse:(e,t,n)=>`sigres:v1:${r(e)}:${r(t)}:${r(n)}`,deadline:(e,t)=>`wf-deadline:${f(e)}:${r(t)}`,terminalCleanup:(e,t)=>`wf-cleanup:${f(e)}:${r(t)}`,teardownTimer:(e,t)=>`wf-teardown:${f(e)}:${r(t)}`,delayedStart:(e,t)=>`wf-delayed:${f(e)}:${r(t)}`,terminalWorkflowPrefix:()=>"wf-terminal:",terminalWorkflow:(e,t)=>`wf-terminal:${f(e)}:${r(t)}`,attribute:(e)=>`attr:${r(e)}`,attributeIndex:(e,t,n)=>`idx:${e}:${t}:${r(n)}`,tagIndex:(e,t)=>`tag:${r(e)}:${r(t)}`,updatePrefix:(e)=>`upd:${r(e)}:`,update:(e,t)=>`upd:${r(e)}:${t}`,updateResponse:(e)=>`upr:${e}`,updateIdempotency:(e,t)=>`upk:${r(e)}:${t}`,startIdempotency:(e)=>`start-idem:${r(e)}`,startIdempotencySignalId:(e)=>`start-idem:${e}`,livenessPrefix:()=>"liveness:",liveness:(e)=>`liveness:${r(e)}`,leasePrefix:()=>"lease:",leaseEpoch:()=>"lease:epoch",leaseHolder:()=>"lease:holder",...z,budget:(e,t,n)=>`budget:${e}:${t}:${n}`,review:(e,t)=>`review:${r(e)}:${t}`,workflowHeaders:(e)=>`wf-headers:${r(e)}`,childCancellationPrefix:(e)=>`child-cancel:${r(e)}:`,childCancellation:(e,t)=>`child-cancel:${r(e)}:${r(t)}`,childWorkflowByParentPrefix:(e,t)=>`child-by-parent:${r(e)}:${t===void 0?"":`${r(t)}:`}`,childWorkflowByParent:(e,t,n)=>`child-by-parent:${r(e)}:${t===void 0?"":`${r(t)}:`}${r(n)}`,terminalCleanupNeeded:(e)=>`wf-cleanup-needed:${r(e)}`,workflowConcurrency:(e,t)=>`wf-concurrency:${r(e)}:${r(t)}`,workflowConcurrencyHolder:(e)=>`wf-concurrency-holder:${r(e)}`,workflowHasServices:(e)=>`wf-has-services:${r(e)}`,finalizerState:(e)=>`wf-finalizer-state:${r(e)}`,teardownOwed:(e)=>`wf-teardown-needed:${r(e)}`,teardownSucceeded:(e)=>`wf-teardown-succeeded:${r(e)}`,teardownDeadLetter:(e)=>`wf-teardown-deadletter:${r(e)}`,offload:(e,t)=>`offload:${r(e)}:${t}`,archive:(e,t)=>`archive:${r(e)}:${t}`,stateExecution:(e,t)=>`state:execution:${r(e)}:${r(t)}`,stateWorkflow:(e,t)=>`state:workflow-scope:${K}:${r(e)}:${r(t)}`,streamChunkPrefix:(e,t)=>`blob:${r(e)}:${t}:chunk:`,streamChunk:(e,t,n)=>`blob:${r(e)}:${t}:chunk:${String(n).padStart(10,"0")}`,streamTail:(e,t)=>`blob:${r(e)}:${t}:tail`,streamMetadata:(e,t)=>`blob:${r(e)}:${t}:meta`,budgetCharged:(e)=>`budget-charged:${e}`,toolEffect:(e,t,n)=>`tool-effect:${r(e)}:${t}:${n}`,workflowVisibilityStatus:(e,t)=>`wf-idx-status:${r(e)}:${r(t)}`,workflowVisibilityType:(e,t)=>`wf-idx-type:${r(e)}:${r(t)}`,workflowVisibilityCreated:(e,t)=>`wf-idx-created:${f(e)}:${r(t)}`,workflowVisibilityUpdated:(e,t)=>`wf-idx-updated:${f(e)}:${r(t)}`,workflowVisibilityDeadline:(e,t)=>`wf-idx-deadline:${f(e)}:${r(t)}`,workflowVisibilityManifest:(e)=>`wf-idx-manifest:${r(e)}`,workflowVisibilityMetaVersion:()=>"wf-idx-meta:version",workflowVisibilityMetaBuiltAt:()=>"wf-idx-meta:built-at",workflowVisibilityMetaCursor:()=>"wf-idx-meta:cursor"};function Z(e){if(e===void 0)return;if(typeof e!=="number"||!Number.isInteger(e)||e<0)throw Error("deleteRange limit must be a finite non-negative integer");return e===0?0:e}function R(e){let t={},n=!1;for(let o of["gt","gte","lt","lte"]){let s=e[o];if(s===void 0)continue;if(typeof s!=="string")throw Error("deleteRange bounds must be strings");t[o]=s,n=!0}if(!n)throw Error("deleteRange requires at least one of gt/gte/lt/lte; use deletePrefix to delete a whole prefix");let i=Z(e.limit);if(i!==void 0)t.limit=i;return t}async function H(e,t,n){let i=R(n);if(e.deleteRange)return e.deleteRange(t,i);return E(e,t,i)}function ee(e,t){let n={key:e,open:!1};if(t.gte!==void 0&&t.gte>n.key)n.key=t.gte,n.open=!1;if(t.gt!==void 0&&t.gt>=n.key)n.key=t.gt,n.open=!0;return n}function te(e,t){let n={key:w(e),open:!0};if(t.lt!==void 0&&t.lt<=n.key)n.key=t.lt,n.open=!0;if(t.lte!==void 0&&t.lte<n.key)n.key=t.lte,n.open=!1;return n}function F(e,t){let n=ee(e,t),i=te(e,t);if(n.key>i.key||n.key===i.key&&(n.open||i.open))return null;return{lower:n,upper:i}}function v(e){return e.replaceAll(/:+$/g,"")}function ne(e,t){let n=v(e),i=v(t);if(n.length===0)return i;if(i.length===0)return n;return`${n}:${i}`}class P{#t;#n;constructor(e,t){this.#t=e,this.#n=v(t)}#e(e){if(this.#n.length===0)return e;return e.length===0?`${this.#n}:`:`${this.#n}:${e}`}#r(e){return e.map((t)=>{if(t.type==="put")return{type:"put",key:this.#e(t.key),value:t.value};return{type:"delete",key:this.#e(t.key)}})}#i(e){if(this.#n.length===0)return e;return e.slice(this.#n.length+1)}#o(e){let t={};if(e.limit!==void 0)t.limit=e.limit;if(e.gt!==void 0)t.gt=this.#e(e.gt);if(e.gte!==void 0)t.gte=this.#e(e.gte);if(e.lt!==void 0)t.lt=this.#e(e.lt);if(e.lte!==void 0)t.lte=this.#e(e.lte);return t}#s(e={}){let t=this.#o(e);if(e.reverse!==void 0)t.reverse=e.reverse;return t}#a(e){return this.#o(e)}capabilities(){return this.#t.capabilities()}scoped(e){return new P(this.#t,ne(this.#n,e))}async get(e){return this.#t.get(this.#e(e))}async put(e,t){await this.#t.put(this.#e(e),t)}async delete(e){await this.#t.delete(this.#e(e))}async*scan(e,t){for await(let[n,i]of this.#t.scan(this.#e(e),this.#s(t)))yield[this.#i(n),i]}async batch(e){h("batch operations",e.length),await this.#t.batch(this.#r(e))}async conditionalBatch(e,t){return W(this.#t,e.map((n)=>({key:this.#e(n.key),expectedValue:n.expectedValue})),this.#r(t))}async has(e){return N(this.#t,this.#e(e))}async deletePrefix(e){return q(this.#t,this.#e(e))}async deleteRange(e,t){let n=this.#a(R(t));return H(this.#t,this.#e(e),n)}async*keys(e,t){for await(let n of M(this.#t,this.#e(e),this.#s(t)))yield this.#i(n)}async count(e){return j(this.#t,this.#e(e))}[Symbol.dispose](){this.#t[Symbol.dispose]()}}function G(e,t){return new P(e,t)}var l="kv";function re(e=globalThis){let{indexedDB:t,IDBKeyRange:n}=e;if(t===void 0||n===void 0)throw Error("IndexedDBStorage requires both indexedDB and IDBKeyRange runtime globals.");return{indexedDB:t,IDBKeyRange:n}}function S(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function ie(e,t){let n=null,i=null,o=null,s=(a,c)=>{let d=a??Error(c);if(i){let g=i;n=null,i=null,g(d);return}o=d};return e.onsuccess=()=>{if(!n)return;let a=n;n=null,i=null,a(e.result)},e.onerror=()=>{s(e.error,"IndexedDB cursor request failed.")},t.onerror=()=>{s(t.error,"IndexedDB transaction failed.")},t.onabort=()=>{s(t.error,"IndexedDB transaction aborted.")},()=>new Promise((a,c)=>{if(o){let d=o;o=null,c(d);return}if(n=a,i=c,e.readyState==="done"){let d=n;n=null,i=null,d?.(e.result)}})}async function*X(e,t,n,i,o,s){let{limit:a,reverse:c}=i,d=w(n),g=t.bound(n,d,!1,!0),m=c?"prev":"next",p=e.transaction(l,"readonly"),u=p.objectStore(l),y=o(u,g,m),b=ie(y,p),x=0,D=!1;try{let B=await b();while(B){if(a!==void 0&&x>=a)break;let Y=B.key;if(U(Y,i))yield s(B),x++;B.continue(),B=await b()}D=!0}finally{if(!D)try{p.abort()}catch{}}}class oe{#t;#n=null;#e;#r;constructor(e="weft",t=re()){this.#t=e,this.#r=t,this.#e=this.#i()}capabilities(){return{persistence:"local",readAfterWrite:"linearizable",scanConsistency:"best-effort",atomicBatch:!0,conditionalBatch:!0,boundedRangeDelete:!0}}#i(){let e=this.#r.indexedDB.open(this.#t,1);return e.onupgradeneeded=()=>{let t=e.result;if(!t.objectStoreNames.contains(l))t.createObjectStore(l)},S(e).then((t)=>(this.#n=t,t))}async get(e){let i=(await this.#e).transaction(l,"readonly").objectStore(l),o=await S(i.get(e));return o===void 0?null:new Uint8Array(o)}async put(e,t){let o=(await this.#e).transaction(l,"readwrite").objectStore(l);await S(o.put(t,e))}async delete(e){let i=(await this.#e).transaction(l,"readwrite").objectStore(l);await S(i.delete(e))}async has(e){let i=(await this.#e).transaction(l,"readonly").objectStore(l);return await S(i.count(e))>0}async deletePrefix(e){let t=await this.#e,n=w(e),i=this.#r.IDBKeyRange.bound(e,n,!1,!0);return new Promise((o,s)=>{let a=t.transaction(l,"readwrite"),c=a.objectStore(l),d=0,g=c.count(i);g.onsuccess=()=>{d=g.result,c.delete(i)},a.oncomplete=()=>o(d),a.onerror=()=>s(a.error)})}async deleteRange(e,t){let n=R(t),i=F(e,n);if(i===null)return 0;let o=this.#r.IDBKeyRange.bound(i.lower.key,i.upper.key,i.lower.open,i.upper.open),s=await this.#e,{limit:a}=n;return new Promise((c,d)=>{let g=s.transaction(l,"readwrite"),m=g.objectStore(l),p=0;if(a===void 0){let u=m.count(o);u.onsuccess=()=>{p=u.result,m.delete(o)}}else{let u=m.openCursor(o,"next");u.onsuccess=()=>{let y=u.result;if(y===null||p>=a)return;if(y.delete(),p++,p<a)y.continue()}}g.oncomplete=()=>c(p),g.onerror=()=>d(g.error)})}async*scan(e,t={}){let n=await this.#e;yield*X(n,this.#r.IDBKeyRange,e,t,(i,o,s)=>i.openCursor(o,s),(i)=>[i.key,new Uint8Array(i.value)])}async batch(e){if(h("batch operations",e.length),e.length===0)return;let t=await this.#e;return new Promise((n,i)=>{let o=t.transaction(l,"readwrite"),s=o.objectStore(l);for(let a of e)if(a.type==="put")s.put(a.value,a.key);else s.delete(a.key);o.oncomplete=()=>n(),o.onerror=()=>i(o.error)})}async conditionalBatch(e,t){h("conditionalBatch conditions",e.length),h("conditionalBatch operations",t.length);let n=await this.#e;return new Promise((i,o)=>{let s=n.transaction(l,"readwrite"),a=s.objectStore(l),c=!1,d=!1,g=(u,y)=>{if(c)return;c=!0,o(u??Error(y))};s.oncomplete=()=>{if(c)return;c=!0,i(!0)},s.onerror=()=>{g(s.error,"IndexedDB conditionalBatch transaction failed.")},s.onabort=()=>{if(c)return;if(c=!0,d){i(!1);return}o(s.error??Error("IndexedDB conditionalBatch transaction aborted."))};let m=()=>{for(let u of t)if(u.type==="put")a.put(u.value,u.key);else a.delete(u.key)},p=(u)=>{if(u>=e.length){m();return}let y=e[u],b=a.get(y.key);b.onsuccess=()=>{let x=b.result,D=x===void 0?null:new Uint8Array(x);if(!V(D,y.expectedValue)){d=!0,s.abort();return}p(u+1)},b.onerror=()=>{g(b.error,"IndexedDB conditionalBatch condition check failed.")}};p(0)})}async*keys(e,t={}){let n=await this.#e;yield*X(n,this.#r.IDBKeyRange,e,t,(i,o,s)=>i.openKeyCursor(o,s),(i)=>i.key)}async count(e){let t=await this.#e,n=w(e),o=t.transaction(l,"readonly").objectStore(l);return S(o.count(this.#r.IDBKeyRange.bound(e,n,!1,!0)))}scoped(e){return G(this,e)}[Symbol.dispose](){if(this.#n)this.#n.close(),this.#n=null}}export{oe as IndexedDBStorage};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- var F=import.meta.require;class K extends Error{code;constructor(j,q,z){super(q,z);this.code=j,this.name=j}}var Y={WorkflowAlreadyExistsError:!0,BulkDeleteRequiresTerminalWorkflowsError:!0,BulkOperationConfirmationError:!0,WorkflowTypeNotRegisteredForRecoveryError:!0,EngineCreateNameMismatchError:!0,EngineDisposedError:!0,EngineDisposalError:!0,WorkflowNotFoundError:!0,WorkflowNotRegisteredError:!0,WorkflowConcurrencyLimitExceededError:!0,WorkflowSuspendNotSupportedError:!0,ActivityResolutionError:!0,BranchTopologyChangedError:!0,PersistedDataIncompatibleError:!0,WorkflowTimeoutError:!0,HttpClientError:!0,WorkerProtocolIncompatibleError:!0,UpdateTimeoutError:!0,UpdateValidationError:!0,WorkflowTerminalError:!0,WorkflowBuilderError:!0,VersionMismatchError:!0,EffectReplayConflictError:!0,ReviewTimeoutError:!0,AtomicStateConflictError:!0,StandardSchemaValidationError:!0,ActivityReconciliationCapabilityError:!0,ActivityReconciliationConflictError:!0,ActivityReconciliationIndeterminateError:!0,DurableActivityScopeError:!0,DurableActivityUnsupportedError:!0,AsyncActivityTokenNotFoundError:!0,ActivityScheduleToCloseTimeoutError:!0,ActivityPerAttemptTimeoutError:!0,PayloadSizeExceededError:!0,StartOrSignalConflictError:!0,WorkflowTeardownPendingError:!0,IdempotencyKeyPurgedError:!0,WorkerManifestBuildError:!0,OwnershipModeMismatchError:!0},M=new Set(Object.keys(Y));class A extends K{fieldName;operation;issues;constructor(j){super("StandardSchemaValidationError",w(j.fieldName,j.operation,j.issues));this.fieldName=j.fieldName,this.operation=j.operation,this.issues=j.issues}}async function X(j,q,z){let G=j["~standard"];if(!Z(G))throw TypeError(`Schema for ${z.fieldName} does not provide runtime validation. Attach a Standard Schema validator (Zod, Valibot, or another vendor) or supply a runtime-validating schema at this boundary.`);let H=await G.validate(q);if(H.issues===void 0)return H.value;throw new A({fieldName:z.fieldName,operation:z.operation,issues:H.issues.map($)})}function Q(j){return j.map((q)=>q.path===""?q.message:`${q.path}: ${q.message}`).join(`
3
- `)}function Z(j){return typeof j.validate==="function"}function $(j){return{message:j.message,path:B(j.path)}}function B(j){if(j===void 0||j.length===0)return"";let q="";for(let z of j)q+="/",q+=D(z);return q}function D(j){let q=U(j)?j.key:j;return b(String(q))}function U(j){return j!==null&&typeof j==="object"&&"key"in j}function b(j){return j.replace(/~/g,"~0").replace(/\//g,"~1")}function w(j,q,z){return`Validation failed for ${q===void 0?j:`${q} ${j}`}:
4
- ${Q(z)}`}var R=Q,_=A,C=X;export{C as validateStandardSchema,R as formatStandardSchemaIssues,_ as StandardSchemaValidationError};
2
+ var h=import.meta.require;class i extends Error{code;constructor(r,e,t){super(e,t);this.code=r,this.name=r}}var c={WorkflowAlreadyExistsError:!0,BulkDeleteRequiresTerminalWorkflowsError:!0,BulkOperationConfirmationError:!0,WorkflowTypeNotRegisteredForRecoveryError:!0,EngineCreateNameMismatchError:!0,EngineDisposedError:!0,EngineDisposalError:!0,WorkflowNotFoundError:!0,WorkflowNotRegisteredError:!0,WorkflowConcurrencyLimitExceededError:!0,WorkflowSuspendNotSupportedError:!0,ActivityResolutionError:!0,BranchTopologyChangedError:!0,PersistedDataIncompatibleError:!0,WorkflowTimeoutError:!0,HttpClientError:!0,WorkerProtocolIncompatibleError:!0,UpdateTimeoutError:!0,UpdateValidationError:!0,WorkflowTerminalError:!0,WorkflowBuilderError:!0,VersionMismatchError:!0,EffectReplayConflictError:!0,ReviewTimeoutError:!0,AtomicStateConflictError:!0,StandardSchemaValidationError:!0,ActivityReconciliationCapabilityError:!0,ActivityReconciliationConflictError:!0,ActivityReconciliationIndeterminateError:!0,DurableActivityScopeError:!0,DurableActivityUnsupportedError:!0,AsyncActivityTokenNotFoundError:!0,ActivityScheduleToCloseTimeoutError:!0,ActivityPerAttemptTimeoutError:!0,PayloadSizeExceededError:!0,StartOrSignalConflictError:!0,WorkflowTeardownPendingError:!0,IdempotencyKeyPurgedError:!0,WorkerManifestBuildError:!0,OwnershipModeMismatchError:!0},g=new Set(Object.keys(c));class o extends i{fieldName;operation;issues;constructor(r){super("StandardSchemaValidationError",p(r.fieldName,r.operation,r.issues));this.fieldName=r.fieldName,this.operation=r.operation,this.issues=r.issues}}async function s(r,e,t){let n=r["~standard"];if(!u(n))throw TypeError(`Schema for ${t.fieldName} does not provide runtime validation. Attach a Standard Schema validator (Zod, Valibot, or another vendor) or supply a runtime-validating schema at this boundary.`);let a=await n.validate(e);if(a.issues===void 0)return a.value;throw new o({fieldName:t.fieldName,operation:t.operation,issues:a.issues.map(l)})}function d(r){return r.map((e)=>e.path===""?e.message:`${e.path}: ${e.message}`).join(`
3
+ `)}function u(r){return typeof r.validate==="function"}function l(r){return{message:r.message,path:f(r.path)}}function f(r){if(r===void 0||r.length===0)return"";let e="";for(let t of r)e+="/",e+=m(t);return e}function m(r){let e=S(r)?r.key:r;return E(String(e))}function S(r){return r!==null&&typeof r==="object"&&"key"in r}function E(r){return r.replace(/~/g,"~0").replace(/\//g,"~1")}function p(r,e,t){return`Validation failed for ${e===void 0?r:`${e} ${r}`}:
4
+ ${d(t)}`}var W=d,T=o,R=s;export{T as StandardSchemaValidationError,W as formatStandardSchemaIssues,R as validateStandardSchema};