@nagi-js/core 0.1.1-rc.18 → 0.1.1-rc.19

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/index.d.ts CHANGED
@@ -1,851 +1,5 @@
1
- type StepRunStatus = StepStatus;
2
- interface RunView {
3
- readonly runId: RunId$1;
4
- readonly flowId: string;
5
- readonly flowHash: string;
6
- readonly status: RunStatus;
7
- readonly startedAt: Date;
8
- readonly completedAt?: Date;
9
- readonly input: Json;
10
- readonly output?: Json;
11
- readonly error?: Json;
12
- readonly canceledByRunId?: RunId$1;
13
- readonly concurrencyKey?: string;
14
- readonly parent?: {
15
- readonly runId: RunId$1;
16
- readonly stepId: StepId;
17
- };
18
- readonly children: readonly RunId$1[];
19
- }
20
- interface StepView {
21
- readonly stepId: StepId;
22
- readonly attempt: AttemptNumber;
23
- readonly status: StepRunStatus;
24
- readonly startedAt?: Date;
25
- readonly completedAt?: Date;
26
- readonly output?: Json;
27
- readonly error?: Json;
28
- readonly lease?: {
29
- readonly expiresAt: Date;
30
- };
31
- }
32
- type RunDescription = {
33
- readonly run: RunView;
34
- readonly steps: readonly StepView[];
35
- } | null;
36
-
37
- type ReaperDecision = {
38
- readonly tag: "skip";
39
- readonly reason: "terminal" | "still-live" | "child-active";
40
- } | {
41
- readonly tag: "reap";
42
- readonly nextAttempt: AttemptNumber;
43
- readonly backoffMs: Millis;
44
- };
45
- declare function decideExpiredLeaseAction(args: {
46
- readonly lease: {
47
- readonly runId: RunId$1;
48
- readonly stepId: StepId;
49
- readonly attempt: AttemptNumber;
50
- readonly expiresAt: Date;
51
- };
52
- readonly stepStatus: StepRunStatus;
53
- readonly childActive: boolean;
54
- readonly now: Date;
55
- }): ReaperDecision;
56
- interface ReapedLease {
57
- readonly runId: RunId$1;
58
- readonly stepId: StepId;
59
- readonly attempt: AttemptNumber;
60
- readonly nextAttempt: AttemptNumber;
61
- }
62
- declare const DEFAULT_REAPER_INTERVAL_MS: Millis;
63
-
64
- type SkipReason = "when-false" | "transitive" | "manual";
65
- type StepCancelCause = {
66
- readonly kind: "run-canceled";
67
- } | {
68
- readonly kind: "aborted";
69
- readonly error?: SerializedError;
70
- };
71
- type RunCancelCause = {
72
- readonly kind: "concurrency";
73
- readonly canceledByRunId: RunId$1;
74
- readonly concurrencyKey: string;
75
- } | {
76
- readonly kind: "explicit";
77
- readonly reason: string;
78
- readonly note?: string;
79
- } | {
80
- readonly kind: "operator";
81
- readonly actor: string;
82
- readonly reason: string;
83
- readonly note?: string;
84
- };
85
- type StepState = {
86
- readonly tag: "pending";
87
- } | {
88
- readonly tag: "running";
89
- readonly attempt: AttemptNumber;
90
- } | {
91
- readonly tag: "awaitingSignal";
92
- readonly attempt: AttemptNumber;
93
- } | {
94
- readonly tag: "awaitingChild";
95
- readonly attempt: AttemptNumber;
96
- } | {
97
- readonly tag: "backoff";
98
- readonly failedAttempt: AttemptNumber;
99
- readonly retryAt: Date;
100
- readonly error: SerializedError;
101
- } | {
102
- readonly tag: "aborting";
103
- readonly attempt: AttemptNumber;
104
- } | {
105
- readonly tag: "completed";
106
- readonly attempt: AttemptNumber;
107
- readonly output: Json;
108
- } | {
109
- readonly tag: "failed";
110
- readonly attempt: AttemptNumber;
111
- readonly error: SerializedError;
112
- } | {
113
- readonly tag: "skipped";
114
- readonly reason: SkipReason;
115
- } | {
116
- readonly tag: "canceled";
117
- readonly cause: StepCancelCause;
118
- };
119
- type Resolved<T = Json> = {
120
- readonly tag: "value";
121
- readonly value: T;
122
- } | {
123
- readonly tag: "skipped";
124
- };
125
- type RunPhase = {
126
- readonly tag: "pending";
127
- } | {
128
- readonly tag: "running";
129
- } | {
130
- readonly tag: "completed";
131
- readonly output: Json;
132
- } | {
133
- readonly tag: "failed";
134
- readonly error: SerializedError;
135
- } | {
136
- readonly tag: "canceled";
137
- readonly cause: RunCancelCause;
138
- };
139
- interface Anomaly {
140
- readonly at: Date;
141
- readonly stepId?: StepId;
142
- readonly from: string;
143
- readonly fact: Fact["kind"];
144
- }
145
- interface RunState {
146
- readonly runId: RunId$1;
147
- readonly flowId: string;
148
- readonly input: Json;
149
- readonly phase: RunPhase;
150
- readonly steps: Readonly<Record<StepId, StepState>>;
151
- readonly selectedArms: Readonly<Record<StepId, string>>;
152
- readonly bufferedSignals: Readonly<Record<StepId, {
153
- readonly payload: Json;
154
- readonly signalName?: string;
155
- }>>;
156
- readonly anomalies: readonly Anomaly[];
157
- readonly facts: readonly Fact[];
158
- readonly parent?: ParentLink;
159
- readonly flowHash?: string;
160
- readonly codeVersion?: string;
161
- }
162
- declare function stepStateOf(runState: RunState, stepId: StepId): StepState;
163
- declare function runStatusOf(state: RunState): RunStatus;
164
- declare function stepStatusOf(s: StepState): StepStatus;
165
- declare function outputOf(s: StepState): Json | null;
166
- declare function errorOf(s: StepState): SerializedError | undefined;
167
- declare function attemptOf(s: StepState): AttemptNumber;
168
- declare function resolvedOf(s: StepState): Resolved;
169
- declare function unwrap<T>(r: Resolved<T>): T;
170
- declare function isTerminalRun(state: RunState): boolean;
171
- declare function isStepTerminal(s: StepState): boolean;
172
- declare function foldRun(runId: RunId$1, facts: readonly Fact[]): RunState;
173
-
174
- type Json = string | number | boolean | null | Json[] | {
175
- [key: string]: Json;
176
- };
177
- type Millis = number;
178
- type RunId$1 = string & {
179
- readonly __brand: "RunId";
180
- };
181
- type StepId = string;
182
- type AttemptNumber = number;
183
- interface StandardSchemaV1<Input = unknown, Output = Input> {
184
- readonly "~standard": StandardSchemaV1.Props<Input, Output>;
185
- }
186
- declare namespace StandardSchemaV1 {
187
- interface Props<Input = unknown, Output = Input> {
188
- readonly version: 1;
189
- readonly vendor: string;
190
- readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
191
- readonly types?: Types<Input, Output>;
192
- }
193
- type Result<Output> = SuccessResult<Output> | FailureResult;
194
- interface SuccessResult<Output> {
195
- readonly value: Output;
196
- readonly issues?: undefined;
197
- }
198
- interface FailureResult {
199
- readonly issues: ReadonlyArray<Issue>;
200
- }
201
- interface Issue {
202
- readonly message: string;
203
- readonly path?: ReadonlyArray<PropertyKey | PathSegment>;
204
- }
205
- interface PathSegment {
206
- readonly key: PropertyKey;
207
- }
208
- interface Types<Input = unknown, Output = Input> {
209
- readonly input: Input;
210
- readonly output: Output;
211
- }
212
- }
213
- type InferSchemaInput<S> = S extends StandardSchemaV1<infer I, unknown> ? I : never;
214
- type InferSchemaOutput<S> = S extends StandardSchemaV1<unknown, infer O> ? O : never;
215
- interface Register {
216
- }
217
- type Tx = Register extends {
218
- tx: infer T;
219
- } ? T : unknown;
220
- type StepKind = "task" | "activity" | "signal" | "match" | "subflow" | "streaming";
221
- interface Step<Output = unknown> {
222
- readonly kind: StepKind;
223
- readonly id: StepId;
224
- readonly __output?: Output;
225
- }
226
- type StepOutput<S> = S extends Step<infer O> ? O : never;
227
- type StepMap = Readonly<Record<string, Step<unknown>>>;
228
- interface Optional<S extends Step = Step> {
229
- readonly __optional: S;
230
- }
231
- type NeedRef = Step | Optional<Step>;
232
- type NeedsMap = Readonly<Record<string, NeedRef>>;
233
- type NeedsOutputs<N extends NeedsMap> = {
234
- readonly [K in keyof N]: StepOutput<N[K]>;
235
- };
236
- type ResolvedNeeds<N extends NeedsMap> = {
237
- readonly [K in keyof N]: N[K] extends Optional<infer S> ? Resolved<StepOutput<S>> : N[K] extends Step ? StepOutput<N[K]> : never;
238
- };
239
- type LogLevel = "debug" | "info" | "warn" | "error";
240
- interface LogEntry {
241
- readonly level: LogLevel;
242
- readonly msg: string;
243
- readonly attrs?: Record<string, unknown>;
244
- }
245
- interface Logger {
246
- debug(message: string, attrs?: Record<string, unknown>): void;
247
- info(message: string, attrs?: Record<string, unknown>): void;
248
- warn(message: string, attrs?: Record<string, unknown>): void;
249
- error(message: string, attrs?: Record<string, unknown>): void;
250
- }
251
- interface StepCtx<Input = unknown> {
252
- readonly input: Input;
253
- readonly tx: Tx;
254
- readonly runId: RunId$1;
255
- readonly stepId: StepId;
256
- readonly attempt: AttemptNumber;
257
- readonly signal: AbortSignal;
258
- readonly now: () => Date;
259
- readonly logger: Logger;
260
- once<T extends Json>(scope: string, fn: () => Promise<T>): Promise<T>;
261
- idempotencyKey(scope: string): string;
262
- }
263
- type ActivityCtx<Input = unknown> = Omit<StepCtx<Input>, "tx">;
264
- type StreamEvent<C = Json> = {
265
- readonly kind: "chunk";
266
- readonly chunk: C;
267
- } | {
268
- readonly kind: "dropped";
269
- readonly count: number;
270
- } | {
271
- readonly kind: "retry";
272
- readonly attempt: AttemptNumber;
273
- } | {
274
- readonly kind: "error";
275
- readonly error: SerializedError;
276
- };
277
- interface StreamingStepCtx<Input = unknown, Chunk = Json> extends StepCtx<Input> {
278
- readonly emit: (chunk: Chunk) => Promise<void>;
279
- }
280
- type BackoffStrategy = "exponential" | "linear" | "fixed";
281
- interface RetryPolicy {
282
- readonly maxAttempts: number;
283
- readonly backoff: BackoffStrategy;
284
- readonly initialDelayMs?: Millis;
285
- readonly maxDelayMs?: Millis;
286
- readonly retryOn?: (error: unknown) => boolean;
287
- }
288
- interface StepConfigBase<Input, N extends NeedsMap> {
289
- readonly needs?: N;
290
- readonly when?: (args: {
291
- readonly input: NoInfer<Input>;
292
- readonly needs: NoInfer<ResolvedNeeds<N>>;
293
- }) => boolean;
294
- }
295
- interface StepLifecycleHooks<Output> {
296
- readonly onStart?: (event: StepStartEvent) => void | Promise<void>;
297
- readonly onComplete?: (event: StepCompleteEvent & {
298
- readonly output: NoInfer<Output>;
299
- }) => void | Promise<void>;
300
- readonly onError?: (event: StepErrorEvent) => void | Promise<void>;
301
- readonly onRetry?: (event: StepRetryEvent) => void | Promise<void>;
302
- }
303
- interface TaskConfig<Input, N extends NeedsMap, Output> extends StepConfigBase<Input, N>, StepLifecycleHooks<Output> {
304
- readonly retry?: RetryPolicy;
305
- readonly run: (args: {
306
- readonly input: NoInfer<Input>;
307
- readonly needs: NoInfer<ResolvedNeeds<N>>;
308
- readonly ctx: StepCtx<NoInfer<Input>>;
309
- }) => Promise<Output>;
310
- }
311
- interface ActivityConfig<Input, N extends NeedsMap, Output> extends StepConfigBase<Input, N>, StepLifecycleHooks<Output> {
312
- readonly retry?: RetryPolicy;
313
- readonly run: (args: {
314
- readonly input: NoInfer<Input>;
315
- readonly needs: NoInfer<ResolvedNeeds<N>>;
316
- readonly ctx: ActivityCtx<NoInfer<Input>>;
317
- }) => Promise<Output>;
318
- }
319
- interface StreamingTaskConfig<Input, N extends NeedsMap, Output, Chunk> extends StepConfigBase<Input, N>, StepLifecycleHooks<Output> {
320
- readonly retry?: RetryPolicy;
321
- readonly run: (args: {
322
- readonly input: NoInfer<Input>;
323
- readonly needs: NoInfer<ResolvedNeeds<N>>;
324
- readonly ctx: StreamingStepCtx<NoInfer<Input>, Chunk>;
325
- }) => Promise<Output>;
326
- }
327
- interface SignalConfig<Input, N extends NeedsMap, Schema extends StandardSchemaV1> extends StepConfigBase<Input, N> {
328
- readonly schema: Schema;
329
- readonly names?: readonly [string, ...string[]];
330
- readonly timeoutMs: Millis | "unbounded";
331
- }
332
- interface MatchArmGuard<Input, N extends NeedsMap, M extends StepMap> {
333
- readonly when: (args: {
334
- readonly input: NoInfer<Input>;
335
- readonly needs: NoInfer<ResolvedNeeds<N>>;
336
- }) => boolean;
337
- readonly otherwise?: never;
338
- readonly build: (b: Builder<Input>) => M;
339
- }
340
- interface MatchArmOtherwise<Input, M extends StepMap> {
341
- readonly otherwise: true;
342
- readonly when?: never;
343
- readonly build: (b: Builder<Input>) => M;
344
- }
345
- type MatchArm<Input, N extends NeedsMap, M extends StepMap> = MatchArmGuard<Input, N, M> | MatchArmOtherwise<Input, M>;
346
- type MatchArmShape<Input, N extends NeedsMap> = {
347
- readonly when: (args: {
348
- readonly input: NoInfer<Input>;
349
- readonly needs: NoInfer<ResolvedNeeds<N>>;
350
- }) => boolean;
351
- readonly otherwise?: never;
352
- readonly build: (b: Builder<Input>) => StepMap;
353
- } | {
354
- readonly otherwise: true;
355
- readonly when?: never;
356
- readonly build: (b: Builder<Input>) => StepMap;
357
- };
358
- interface MatchGuardConfig<Input, N extends NeedsMap, M extends StepMap> {
359
- readonly needs?: N;
360
- readonly arms: ReadonlyArray<MatchArm<Input, N, M>>;
361
- }
362
- type MatchArmOutput<M extends StepMap> = {
363
- readonly [K in keyof M]: StepOutput<M[K]>;
364
- };
365
- interface SubflowConfig<Input, N extends NeedsMap, Child extends Flow> extends StepConfigBase<Input, N> {
366
- readonly input: (args: {
367
- readonly input: NoInfer<Input>;
368
- readonly needs: NoInfer<ResolvedNeeds<N>>;
369
- }) => FlowInput<Child>;
370
- }
371
- interface SubflowStepOutput<ChildOutput> {
372
- readonly childRunId: RunId$1;
373
- readonly output: ChildOutput;
374
- }
375
- interface Builder<Input = unknown> {
376
- task<N extends NeedsMap, Output>(config: TaskConfig<Input, N, Output>): Step<Output>;
377
- activity<N extends NeedsMap, Output>(config: ActivityConfig<Input, N, Output>): Step<Output>;
378
- streamingTask<N extends NeedsMap, O, C = Json>(config: StreamingTaskConfig<Input, N, O, C>): Step<O>;
379
- signal<N extends NeedsMap, S extends StandardSchemaV1>(config: SignalConfig<Input, N, S>): Step<InferSchemaOutput<S>>;
380
- subflow<N extends NeedsMap, Child extends Flow>(child: Child, config: SubflowConfig<Input, N, Child>): Step<SubflowStepOutput<FlowOutput<Child>>>;
381
- match<N extends NeedsMap, Arms extends ReadonlyArray<MatchArmShape<Input, N>>>(config: {
382
- readonly needs?: N;
383
- readonly arms: Arms;
384
- }): Step<MatchArmOutput<ReturnType<Arms[number]["build"]>>>;
385
- }
386
- type ConcurrencyMode = "cancel-in-progress";
387
- type StringKeyOf<Input> = {
388
- [K in keyof Input]-?: Input[K] extends string ? K : never;
389
- }[keyof Input];
390
- type FlowConcurrency<Input = Json> = StringKeyOf<Input> | {
391
- readonly keyFn: (input: Input) => string;
392
- readonly mode?: ConcurrencyMode;
393
- };
394
- interface ResolvedConcurrency {
395
- readonly keyFn: (input: Json) => string;
396
- readonly mode: ConcurrencyMode;
397
- }
398
- interface FlowConfig<Id extends string, InputSchema extends StandardSchemaV1, R extends StepMap, Output = unknown> {
399
- readonly id: Id;
400
- readonly input: InputSchema;
401
- readonly build: (b: Builder<InferSchemaOutput<InputSchema>>) => R;
402
- output?(steps: NeedsOutputs<R>): Output;
403
- readonly concurrency?: FlowConcurrency<InferSchemaOutput<InputSchema>>;
404
- readonly onStart?: (event: FlowStartEvent) => void | Promise<void>;
405
- readonly onComplete?: (event: FlowCompleteEvent & {
406
- readonly output: NoInfer<Output>;
407
- }) => void | Promise<void>;
408
- readonly onError?: (event: FlowErrorEvent) => void | Promise<void>;
409
- }
410
- interface Flow<Id extends string = string, InputSchema extends StandardSchemaV1 = StandardSchemaV1, M extends StepMap = StepMap, Output = unknown> {
411
- readonly id: Id;
412
- readonly input: InputSchema;
413
- readonly steps: M;
414
- output?(steps: NeedsOutputs<M>): Output;
415
- readonly onStart?: (event: FlowStartEvent) => void | Promise<void>;
416
- readonly onComplete?: (event: FlowCompleteEvent) => void | Promise<void>;
417
- readonly onError?: (event: FlowErrorEvent) => void | Promise<void>;
418
- readonly concurrency?: ResolvedConcurrency;
419
- }
420
- type FlowInput<F> = F extends Flow<string, infer S, StepMap, unknown> ? InferSchemaOutput<S> : never;
421
- type FlowOutput<F> = F extends Flow<string, StandardSchemaV1, StepMap, infer O> ? O : never;
422
- type FlowIdOf<T extends ReadonlyArray<Flow>> = T[number] extends Flow<infer Id> ? Id : never;
423
- interface ParentLink {
424
- readonly runId: RunId$1;
425
- readonly stepId: StepId;
426
- }
427
- interface ParentRef extends ParentLink {
428
- readonly attempt: AttemptNumber;
429
- }
430
- interface FlowEvent {
431
- readonly runId: RunId$1;
432
- readonly flowId: string;
433
- readonly at: Date;
434
- }
435
- interface FlowStartEvent extends FlowEvent {
436
- readonly input: Json;
437
- readonly parent?: ParentRef;
438
- }
439
- interface FlowCompleteEvent extends FlowEvent {
440
- readonly output: Json;
441
- }
442
- interface FlowErrorEvent extends FlowEvent {
443
- readonly error: SerializedError;
444
- }
445
- interface StepEvent extends FlowEvent {
446
- readonly stepId: StepId;
447
- readonly attempt: AttemptNumber;
448
- readonly kind: StepKind;
449
- }
450
- interface StepStartEvent extends StepEvent {
451
- readonly input: Json;
452
- }
453
- interface StepCompleteEvent extends StepEvent {
454
- readonly output: Json;
455
- readonly durationMs?: Millis;
456
- }
457
- interface StepErrorEvent extends StepEvent {
458
- readonly error: SerializedError;
459
- }
460
- interface StepRetryEvent extends StepEvent {
461
- readonly error: SerializedError;
462
- readonly nextAttemptAt: Date;
463
- }
464
- interface SignalSentEvent extends StepEvent {
465
- readonly payload: Json;
466
- }
467
- interface SignalReceivedEvent extends StepEvent {
468
- readonly payload: Json;
469
- }
470
- interface FlowHooks {
471
- readonly onFlowStart?: (event: FlowStartEvent) => void | Promise<void>;
472
- readonly onFlowComplete?: (event: FlowCompleteEvent) => void | Promise<void>;
473
- readonly onFlowError?: (event: FlowErrorEvent) => void | Promise<void>;
474
- readonly onStepStart?: (event: StepStartEvent) => void | Promise<void>;
475
- readonly onStepComplete?: (event: StepCompleteEvent) => void | Promise<void>;
476
- readonly onStepError?: (event: StepErrorEvent) => void | Promise<void>;
477
- readonly onStepRetry?: (event: StepRetryEvent) => void | Promise<void>;
478
- readonly onSignalSent?: (event: SignalSentEvent) => void | Promise<void>;
479
- readonly onSignalReceived?: (event: SignalReceivedEvent) => void | Promise<void>;
480
- }
481
- interface WorkerConfig {
482
- readonly concurrency?: number;
483
- readonly pollIntervalMs?: Millis;
484
- readonly signal?: AbortSignal;
485
- readonly timerSweepIntervalMs?: Millis;
486
- readonly snapshotGonePolicy?: SnapshotGonePolicy;
487
- readonly maxConcurrencyPerFlow?: number;
488
- }
489
- type SnapshotGoneDisposition = {
490
- readonly action: "retry";
491
- readonly delayMs: Millis;
492
- } | {
493
- readonly action: "fail";
494
- };
495
- type SnapshotGonePolicy = (readCount: number) => SnapshotGoneDisposition;
496
- interface WorkerRunOnceOpts {
497
- readonly maxSteps?: number;
498
- }
499
- interface WorkerRunUntilEmptyOpts {
500
- readonly deadline?: number;
501
- }
502
- interface WorkerRunResult {
503
- readonly processed: number;
504
- }
505
- interface Worker {
506
- run(): Promise<void>;
507
- runOnce(opts?: WorkerRunOnceOpts): Promise<WorkerRunResult>;
508
- runUntilEmpty(opts?: WorkerRunUntilEmptyOpts): Promise<WorkerRunResult>;
509
- }
510
- type ClaimToken = string & {
511
- readonly __brand: "ClaimToken";
512
- };
513
- interface SerializedError {
514
- readonly name: string;
515
- readonly message: string;
516
- readonly stack?: string;
517
- readonly cause?: Json;
518
- }
519
- type SettleSignalResult = {
520
- readonly tag: "delivered";
521
- readonly attempt: AttemptNumber;
522
- readonly payload: Json;
523
- readonly signalName?: string;
524
- } | {
525
- readonly tag: "buffered";
526
- } | {
527
- readonly tag: "noop";
528
- };
529
- interface TimedOutSignal {
530
- readonly runId: RunId$1;
531
- readonly stepId: StepId;
532
- readonly attempt: AttemptNumber;
533
- readonly fireAt: Date;
534
- }
535
- interface Store {
536
- appendFact(runId: RunId$1, fact: Fact): Promise<void>;
537
- loadRunState(runId: RunId$1): Promise<RunState>;
538
- settleSignal(args: {
539
- readonly runId: RunId$1;
540
- readonly stepId: StepId;
541
- readonly at: Date;
542
- readonly incoming?: {
543
- readonly payload: Json;
544
- readonly signalName?: string;
545
- };
546
- }): Promise<SettleSignalResult>;
547
- tryStartRun(runId: RunId$1, fact: FlowStartedFact, concurrency?: {
548
- readonly key: string;
549
- readonly mode: ConcurrencyMode;
550
- }): Promise<{
551
- readonly started: boolean;
552
- readonly canceled: ReadonlyArray<{
553
- readonly runId: RunId$1;
554
- readonly fact: FlowCanceledByConcurrencyFact;
555
- }>;
556
- }>;
557
- tryStartRunOnTx(tx: Tx, runId: RunId$1, fact: FlowStartedFact, concurrency?: {
558
- readonly key: string;
559
- readonly mode: ConcurrencyMode;
560
- }): Promise<{
561
- readonly started: boolean;
562
- readonly canceled: ReadonlyArray<{
563
- readonly runId: RunId$1;
564
- readonly fact: FlowCanceledByConcurrencyFact;
565
- }>;
566
- }>;
567
- claimStep(runId: RunId$1, stepId: StepId, attempt: AttemptNumber): Promise<ClaimToken | null>;
568
- extendLease(runId: RunId$1, stepId: StepId, attempt: AttemptNumber, leaseMs: Millis): Promise<void>;
569
- sweepLeases(args: {
570
- readonly now: Date;
571
- readonly queue: Queue;
572
- readonly limit?: number;
573
- }): Promise<readonly ReapedLease[]>;
574
- upsertTimer(runId: RunId$1, stepId: StepId, fireAt: Date): Promise<void>;
575
- sweepSignalTimeouts(args: {
576
- readonly now: Date;
577
- readonly limit?: number;
578
- }): Promise<readonly TimedOutSignal[]>;
579
- settleStep(runId: RunId$1, stepId: StepId, fact: StepCompletedFact | StepFailedFact): Promise<void>;
580
- recordOnce(runId: RunId$1, stepId: StepId, scope: string, value: Json): Promise<void>;
581
- getOnce(runId: RunId$1, stepId: StepId, scope: string): Promise<Json | null>;
582
- runStep<T extends Json>(runId: RunId$1, stepId: StepId, attempt: AttemptNumber, body: (tx: Tx) => Promise<{
583
- readonly output: T;
584
- readonly fact: StepCompletedFact | StepFailedFact | StepCanceledFact;
585
- }>): Promise<T>;
586
- upsertSnapshot(args: {
587
- readonly flowHash: string;
588
- readonly flowId: string;
589
- readonly dag: Json;
590
- }): Promise<void>;
591
- getRef(flowId: string): Promise<string | null>;
592
- setRef(flowId: string, flowHash: string): Promise<void>;
593
- loadSnapshot(flowHash: string): Promise<{
594
- readonly flowId: string;
595
- readonly dag: Json;
596
- } | null>;
597
- appendGlobalFact(fact: GlobalFact): Promise<void>;
598
- queryRuns(opts: QueryRunsOpts): Promise<QueryRunsResult>;
599
- describe(runId: RunId$1): Promise<RunDescription>;
600
- listChildren(parentRunId: RunId$1): Promise<ReadonlyArray<RunId$1>>;
601
- pruneFacts(opts: Required<PruneOpts>): Promise<PruneResult>;
602
- }
603
- interface StreamTransport {
604
- subscribeStream(runId: RunId$1, stepId: StepId, opts?: {
605
- readonly replayBuffered?: boolean;
606
- }): AsyncIterable<StreamEvent<Json>>;
607
- publishChunk(runId: RunId$1, stepId: StepId, chunk: Json): void;
608
- }
609
- interface QueryRunsWhere<FlowId extends string = string> {
610
- readonly flowId?: FlowId;
611
- readonly status?: ReadonlyArray<RunStatus>;
612
- readonly input?: Record<string, Json>;
613
- }
614
- type QueryRunsOpts<FlowId extends string = string> = {
615
- readonly where?: QueryRunsWhere<FlowId>;
616
- readonly latest: true;
617
- readonly limit?: never;
618
- readonly cursor?: never;
619
- } | {
620
- readonly where?: QueryRunsWhere<FlowId>;
621
- readonly latest?: false;
622
- readonly limit?: number;
623
- readonly cursor?: string;
624
- };
625
- interface RunSummary<FlowId extends string = string> {
626
- readonly runId: RunId$1;
627
- readonly flowId: FlowId;
628
- readonly status: RunStatus;
629
- readonly startedAt: Date;
630
- readonly completedAt: Date | null;
631
- readonly input: Json;
632
- }
633
- interface QueryRunsResult<FlowId extends string = string> {
634
- readonly runs: ReadonlyArray<RunSummary<FlowId>>;
635
- readonly cursor: string | null;
636
- }
637
- type PrunableStatus = Extract<RunStatus, "completed" | "failed" | "canceled">;
638
- interface PruneOpts {
639
- readonly olderThan: Date;
640
- readonly statuses?: ReadonlyArray<PrunableStatus>;
641
- readonly batchSize?: number;
642
- readonly keepSummary?: boolean;
643
- }
644
- interface PruneResult {
645
- readonly runsPruned: number;
646
- readonly factsPruned: number;
647
- }
648
- interface QueueMessage {
649
- readonly receipt: string;
650
- readonly runId: RunId$1;
651
- readonly stepId: StepId;
652
- readonly payload: Json;
653
- readonly attempt: AttemptNumber;
654
- readonly readCount: number;
655
- readonly flowId?: string;
656
- }
657
- interface QueueDequeueOpts {
658
- readonly count: number;
659
- }
660
- interface QueueEnqueueOpts {
661
- readonly attempt?: AttemptNumber;
662
- readonly delayMs?: Millis;
663
- readonly payload?: Json;
664
- readonly flowId?: string;
665
- }
666
- interface QueueInspectEntry {
667
- readonly stepId: StepId;
668
- readonly attempt: AttemptNumber;
669
- readonly readCount: number;
670
- readonly visibleAt: Date;
671
- }
672
- interface Queue {
673
- enqueue(runId: RunId$1, stepId: StepId, opts?: QueueEnqueueOpts): Promise<void>;
674
- dequeue(opts: QueueDequeueOpts): Promise<readonly QueueMessage[]>;
675
- ack(receipt: string): Promise<void>;
676
- nack(receipt: string, opts?: {
677
- delayMs?: Millis;
678
- }): Promise<void>;
679
- extend(receipt: string, leaseMs: Millis): Promise<void>;
680
- ensureSchema?(): Promise<void>;
681
- inspect?(runId: RunId$1): Promise<readonly QueueInspectEntry[]>;
682
- }
683
- interface Clock {
684
- now(): Date;
685
- sleep(ms: Millis, signal?: AbortSignal): Promise<void>;
686
- schedule(at: Date, runId: RunId$1, stepId: StepId): Promise<void>;
687
- }
688
- interface Trigger {
689
- subscribe(handler: (runId: RunId$1) => void): () => void;
690
- }
691
- type FactKind = "flow.started" | "flow.completed" | "flow.failed" | "flow.canceled" | "step.started" | "step.completed" | "step.failed" | "step.canceled" | "step.retried" | "step.skipped" | "step.reset" | "step.abort-requested" | "signal.sent" | "signal.received" | "signal.buffered" | "once.recorded" | "match.arm-selected" | "lease.reaped";
692
- interface FactBase {
693
- readonly runId: RunId$1;
694
- readonly at: Date;
695
- }
696
- interface FlowStartedFact extends FactBase {
697
- readonly kind: "flow.started";
698
- readonly flowId: string;
699
- readonly input: Json;
700
- readonly flowHash?: string;
701
- readonly codeVersion?: string;
702
- readonly parent?: ParentLink;
703
- }
704
- interface FlowRefUpdatedFact {
705
- readonly kind: "flow_ref.updated";
706
- readonly flowId: string;
707
- readonly from: string | null;
708
- readonly to: string;
709
- readonly at: Date;
710
- }
711
- type GlobalFact = FlowRefUpdatedFact;
712
- interface FlowCompletedFact extends FactBase {
713
- readonly kind: "flow.completed";
714
- readonly output: Json;
715
- }
716
- interface FlowFailedFact extends FactBase {
717
- readonly kind: "flow.failed";
718
- readonly error: SerializedError;
719
- }
720
- interface FlowCanceledByConcurrencyFact extends FactBase {
721
- readonly kind: "flow.canceled";
722
- readonly cause: "concurrency";
723
- readonly canceledByRunId: RunId$1;
724
- readonly concurrencyKey: string;
725
- }
726
- interface FlowCanceledExplicitlyFact extends FactBase {
727
- readonly kind: "flow.canceled";
728
- readonly cause: "explicit";
729
- readonly reason: string;
730
- readonly note?: string;
731
- }
732
- interface FlowCanceledByOperatorFact extends FactBase {
733
- readonly kind: "flow.canceled";
734
- readonly cause: "operator";
735
- readonly actor: string;
736
- readonly reason: string;
737
- readonly note?: string;
738
- }
739
- type FlowCanceledFact = FlowCanceledByConcurrencyFact | FlowCanceledExplicitlyFact | FlowCanceledByOperatorFact;
740
- type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
741
- type CancelArgs = DistributiveOmit<FlowCanceledExplicitlyFact | FlowCanceledByOperatorFact, "kind" | "runId" | "at">;
742
- interface StepStartedFact extends FactBase {
743
- readonly kind: "step.started";
744
- readonly stepId: StepId;
745
- readonly attempt: AttemptNumber;
746
- readonly stepKind: StepKind;
747
- }
748
- interface StepCompletedFact extends FactBase {
749
- readonly kind: "step.completed";
750
- readonly stepId: StepId;
751
- readonly attempt: AttemptNumber;
752
- readonly output: Json;
753
- }
754
- interface StepFailedFact extends FactBase {
755
- readonly kind: "step.failed";
756
- readonly stepId: StepId;
757
- readonly attempt: AttemptNumber;
758
- readonly error: SerializedError;
759
- }
760
- interface StepCanceledFact extends FactBase {
761
- readonly kind: "step.canceled";
762
- readonly stepId: StepId;
763
- readonly attempt: AttemptNumber;
764
- readonly error?: SerializedError;
765
- }
766
- interface StepRetriedFact extends FactBase {
767
- readonly kind: "step.retried";
768
- readonly stepId: StepId;
769
- readonly attempt: AttemptNumber;
770
- readonly nextAttemptAt: Date;
771
- readonly error: SerializedError;
772
- }
773
- interface StepSkippedFact extends FactBase {
774
- readonly kind: "step.skipped";
775
- readonly stepId: StepId;
776
- readonly reason: "when-false" | "transitive" | "manual";
777
- readonly actor?: string;
778
- readonly note?: string;
779
- }
780
- interface SignalSentFact extends FactBase {
781
- readonly kind: "signal.sent";
782
- readonly stepId: StepId;
783
- readonly payload: Json;
784
- }
785
- interface SignalReceivedFact extends FactBase {
786
- readonly kind: "signal.received";
787
- readonly stepId: StepId;
788
- readonly payload: Json;
789
- readonly signalName?: string;
790
- }
791
- interface SignalBufferedFact extends FactBase {
792
- readonly kind: "signal.buffered";
793
- readonly stepId: StepId;
794
- readonly payload: Json;
795
- readonly signalName?: string;
796
- }
797
- interface OnceRecordedFact extends FactBase {
798
- readonly kind: "once.recorded";
799
- readonly stepId: StepId;
800
- readonly scope: string;
801
- readonly value: Json;
802
- }
803
- interface MatchArmSelectedFact extends FactBase {
804
- readonly kind: "match.arm-selected";
805
- readonly stepId: StepId;
806
- readonly arm: string;
807
- }
808
- interface LeaseReapedFact extends FactBase {
809
- readonly kind: "lease.reaped";
810
- readonly stepId: StepId;
811
- readonly attempt: AttemptNumber;
812
- readonly reapedAt: Date;
813
- readonly reason: "expired";
814
- }
815
- interface StepResetFact extends FactBase {
816
- readonly kind: "step.reset";
817
- readonly stepId: StepId;
818
- readonly cascadedFrom?: StepId;
819
- readonly actor?: string;
820
- readonly note?: string;
821
- }
822
- interface StepAbortRequestedFact extends FactBase {
823
- readonly kind: "step.abort-requested";
824
- readonly stepId: StepId;
825
- readonly attempt: AttemptNumber;
826
- readonly actor: string;
827
- readonly note?: string;
828
- }
829
- type Fact = FlowStartedFact | FlowCompletedFact | FlowFailedFact | FlowCanceledFact | StepStartedFact | StepCompletedFact | StepFailedFact | StepCanceledFact | StepRetriedFact | StepSkippedFact | StepResetFact | StepAbortRequestedFact | SignalSentFact | SignalReceivedFact | SignalBufferedFact | OnceRecordedFact | MatchArmSelectedFact | LeaseReapedFact;
830
- type RunStatus = "pending" | "running" | "completed" | "failed" | "canceled";
831
- type StepStatus = "pending" | "running" | "completed" | "failed" | "canceled" | "skipped";
832
-
833
- type ReplayMode = "inspect" | "continue";
834
- interface ReplayOpts {
835
- readonly mode: ReplayMode;
836
- readonly allowDrift?: boolean;
837
- readonly fireHooks?: boolean;
838
- readonly from?: StepId;
839
- }
840
- interface OperatorAuditOpts {
841
- readonly actor: string;
842
- readonly note?: string;
843
- }
844
- interface Operator {
845
- skip(runId: RunId$1, stepId: StepId, opts: OperatorAuditOpts): Promise<void>;
846
- retry(runId: RunId$1, stepId: StepId, opts: OperatorAuditOpts): Promise<void>;
847
- abort(runId: RunId$1, opts: OperatorAuditOpts): Promise<void>;
848
- }
1
+ import { aC as StandardSchemaV1, aP as StepMap, n as FlowConfig, f as Flow, aD as Step, Z as Optional, aN as StepId, aO as StepKind, B as BackoffStrategy, S as Millis, an as RunId$1, c as Clock, a6 as Queue, a8 as QueueEnqueueOpts, a7 as QueueDequeueOpts, aa as QueueMessage, a9 as QueueInspectEntry, a$ as Store, F as Fact, x as FlowStartedFact, d as ConcurrencyMode, g as FlowCanceledByConcurrencyFact, b9 as Tx, ap as RunState, A as AttemptNumber, b as ClaimToken, ab as ReapedLease, aI as StepCompletedFact, aM as StepFailedFact, J as Json, au as SettleSignalResult, b8 as TimedOutSignal, aG as StepCanceledFact, G as GlobalFact, a3 as QueryRunsOpts, a4 as QueryRunsResult, am as RunDescription, a1 as PruneOpts, a2 as PruneResult, b1 as StreamTransport, aB as SnapshotGonePolicy, r as FlowHooks, z as LogEntry, aj as RetryPolicy, bb as WorkerConfig, t as FlowInput, ba as Worker, af as ReplayOpts, s as FlowIdOf, b0 as StreamEvent, X as Operator, av as SignalBufferedFact, ay as SignalReceivedFact, aq as RunStatus, a0 as PrunableStatus } from './types-DfxwD2MH.js';
2
+ export { a as Builder, C as CancelArgs, D as DEFAULT_REAPER_INTERVAL_MS, e as FactKind, h as FlowCanceledByOperatorFact, i as FlowCanceledExplicitlyFact, j as FlowCanceledFact, k as FlowCompleteEvent, l as FlowCompletedFact, m as FlowConcurrency, o as FlowErrorEvent, p as FlowEvent, q as FlowFailedFact, u as FlowOutput, v as FlowRefUpdatedFact, w as FlowStartEvent, I as InferSchemaInput, y as InferSchemaOutput, L as LeaseReapedFact, E as LogLevel, H as Logger, M as MatchArm, K as MatchArmGuard, N as MatchArmOtherwise, O as MatchArmOutput, P as MatchArmSelectedFact, Q as MatchArmShape, R as MatchGuardConfig, T as NeedRef, U as NeedsMap, V as NeedsOutputs, W as OnceRecordedFact, Y as OperatorAuditOpts, _ as ParentLink, $ as ParentRef, a5 as QueryRunsWhere, ac as ReaperDecision, ad as Register, ae as ReplayMode, ag as Resolved, ah as ResolvedConcurrency, ai as ResolvedNeeds, ak as RowDelta, al as RunCancelCause, ao as RunPhase, ar as RunSummary, as as RunView, at as SerializedError, aw as SignalConfig, ax as SignalReceivedEvent, az as SkipReason, aA as SnapshotGoneDisposition, aE as StepAbortRequestedFact, aF as StepCancelCause, aH as StepCompleteEvent, aJ as StepCtx, aK as StepErrorEvent, aL as StepEvent, aQ as StepOutput, aR as StepResetFact, aS as StepRetriedFact, aT as StepRetryEvent, aU as StepRunStatus, aV as StepSkippedFact, aW as StepStartEvent, aX as StepStartedFact, aY as StepState, aZ as StepStatus, a_ as StepView, b2 as StreamingStepCtx, b3 as StreamingTaskConfig, b4 as StringKeyOf, b5 as SubflowConfig, b6 as SubflowStepOutput, b7 as TaskConfig, bc as WorkerRunOnceOpts, bd as WorkerRunResult, be as WorkerRunUntilEmptyOpts, bf as attemptOf, bg as decideExpiredLeaseAction, bh as errorOf, bj as isStepTerminal, bk as isTerminalRun, bl as outputOf, bi as projectRunState, bm as resolvedOf, bn as rowDeltaOf, bo as runStatusOf, bp as stepStateOf, bq as stepStatusOf, br as unwrap } from './types-DfxwD2MH.js';
849
3
 
850
4
  declare function flow<const Id extends string, InputSchema extends StandardSchemaV1, R extends StepMap, Output = unknown>(config: FlowConfig<Id, InputSchema, R, Output>): Flow<Id, InputSchema, R, Output>;
851
5
  declare function optional<S extends Step>(step: S): Optional<S>;
@@ -976,7 +130,7 @@ declare class NagiSnapshotDriftError extends Error {
976
130
  interface InMemoryStoreOpts {
977
131
  readonly leaseMs?: Millis;
978
132
  }
979
- declare class InMemoryStore implements Store, StreamTransport {
133
+ declare class InMemoryStore implements Store {
980
134
  private readonly facts;
981
135
  private readonly onces;
982
136
  private readonly leases;
@@ -993,6 +147,7 @@ declare class InMemoryStore implements Store, StreamTransport {
993
147
  private readonly leaseMs;
994
148
  constructor(opts?: InMemoryStoreOpts);
995
149
  appendFact(runId: RunId$1, fact: Fact): Promise<void>;
150
+ private releaseLeases;
996
151
  tryStartRun(runId: RunId$1, fact: FlowStartedFact, concurrency?: {
997
152
  readonly key: string;
998
153
  readonly mode: ConcurrencyMode;
@@ -1059,11 +214,10 @@ declare class InMemoryStore implements Store, StreamTransport {
1059
214
  readGlobalFacts(): ReadonlyArray<GlobalFact>;
1060
215
  queryRuns(opts: QueryRunsOpts): Promise<QueryRunsResult>;
1061
216
  describe(runId: RunId$1): Promise<RunDescription>;
217
+ private describeSummary;
1062
218
  pruneFacts(opts: Required<PruneOpts>): Promise<PruneResult>;
1063
- subscribeStream(runId: RunId$1, stepId: StepId, opts?: {
1064
- readonly replayBuffered?: boolean;
1065
- }): AsyncIterable<StreamEvent<Json>>;
1066
- publishChunk(runId: RunId$1, stepId: StepId, chunk: Json): void;
219
+ private pruneCandidates;
220
+ readonly stream: StreamTransport;
1067
221
  }
1068
222
 
1069
223
  interface InMemoryQueueOpts {
@@ -1083,24 +237,13 @@ declare class InMemoryQueue implements Queue {
1083
237
  extend(receipt: string, leaseMs: Millis): Promise<void>;
1084
238
  inspect(runId: RunId$1): Promise<readonly QueueInspectEntry[]>;
1085
239
  }
1086
- interface InMemoryClockOpts {
1087
- readonly trigger?: InMemoryTrigger;
1088
- }
1089
240
  declare class InMemoryClock implements Clock {
1090
- private readonly timers;
1091
- private readonly trigger;
1092
- constructor(opts?: InMemoryClockOpts);
1093
241
  now(): Date;
1094
242
  sleep(ms: Millis, signal?: AbortSignal): Promise<void>;
1095
- schedule(at: Date, runId: RunId$1, stepId: StepId): Promise<void>;
1096
- dispose(): void;
1097
- }
1098
- declare class InMemoryTrigger implements Trigger {
1099
- private handlers;
1100
- subscribe(handler: (runId: RunId$1) => void): () => void;
1101
- fire(runId: RunId$1): void;
1102
243
  }
1103
244
 
245
+ declare const defaultSnapshotGonePolicy: SnapshotGonePolicy;
246
+
1104
247
  type RunId = RunId$1;
1105
248
  declare const RunId: {
1106
249
  readonly parse: (s: string) => RunId;
@@ -1110,10 +253,8 @@ declare const RunId: {
1110
253
  interface NagiConfig {
1111
254
  readonly flows: ReadonlyArray<Flow>;
1112
255
  readonly store: Store;
1113
- readonly streamTransport?: StreamTransport;
1114
256
  readonly queue: Queue;
1115
257
  readonly clock?: Clock;
1116
- readonly trigger?: Trigger;
1117
258
  readonly hooks?: FlowHooks;
1118
259
  readonly onLog?: (entry: LogEntry) => void;
1119
260
  readonly defaultRetry?: RetryPolicy;
@@ -1221,6 +362,43 @@ declare class NagiAbortError extends Error {
1221
362
  constructor(runId: RunId$1, kind: "run" | "step");
1222
363
  }
1223
364
 
1224
- declare const defaultSnapshotGonePolicy: SnapshotGonePolicy;
365
+ declare const QUERY_RUNS_DEFAULT_LIMIT = 50;
366
+ declare const QUERY_RUNS_MAX_LIMIT = 500;
367
+ declare function clampQueryLimit(limit: number | undefined): number;
368
+ interface RunCursor {
369
+ readonly startedAt: Date;
370
+ readonly runId: RunId$1;
371
+ }
372
+ declare function compareRunOrder(a: RunCursor, b: RunCursor): number;
373
+ declare function isPastCursor(row: RunCursor, cursor: RunCursor): boolean;
374
+ declare function encodeRunCursor(c: RunCursor): string;
375
+ declare function decodeRunCursor(s: string): RunCursor;
376
+ declare function jsonContains(haystack: Json, needle: Json): boolean;
377
+ declare const DEFAULT_SWEEP_LIMIT = 100;
378
+ declare function selectExpired<T>(items: Iterable<T>, args: {
379
+ readonly now: Date;
380
+ readonly limit: number;
381
+ readonly deadline: (item: T) => Date;
382
+ }): T[];
383
+ interface PruneCandidate {
384
+ readonly runId: RunId$1;
385
+ readonly status: RunStatus;
386
+ readonly completedAt: Date | null;
387
+ }
388
+ declare function selectPruneBatch<T extends PruneCandidate>(candidates: Iterable<T>, opts: {
389
+ readonly olderThan: Date;
390
+ readonly statuses: ReadonlyArray<PrunableStatus>;
391
+ readonly batchSize: number;
392
+ }): T[];
393
+ type FactEffects = {
394
+ readonly tag: "none";
395
+ } | {
396
+ readonly tag: "release-step";
397
+ readonly stepId: StepId;
398
+ readonly timer: boolean;
399
+ } | {
400
+ readonly tag: "release-run";
401
+ };
402
+ declare function factEffects(fact: Fact): FactEffects;
1225
403
 
1226
- export { type Anomaly, type AttemptNumber, type BackoffStrategy, type Builder, type CancelArgs, type CanonicalDag, type CanonicalMatchArm, type CanonicalRetryPolicy, type CanonicalSchema, type CanonicalStep, type ClaimToken, type Clock, type ConcurrencyMode, DEFAULT_REAPER_INTERVAL_MS, type Fact, type FactKind, type Flow, type FlowCanceledByConcurrencyFact, type FlowCanceledByOperatorFact, type FlowCanceledExplicitlyFact, type FlowCanceledFact, type FlowCompleteEvent, type FlowCompletedFact, type FlowConcurrency, type FlowConfig, type FlowErrorEvent, type FlowEvent, type FlowFailedFact, type FlowHooks, type FlowIdOf, type FlowInput, type FlowOutput, type FlowRefUpdatedFact, type FlowStartEvent, type FlowStartedFact, type GlobalFact, InMemoryClock, InMemoryQueue, InMemoryStore, InMemoryTrigger, type InferSchemaInput, type InferSchemaOutput, type Json, type LeaseReapedFact, type LogEntry, type LogLevel, type Logger, type MatchArm, type MatchArmGuard, type MatchArmOtherwise, type MatchArmOutput, type MatchArmSelectedFact, type MatchArmShape, type MatchGuardConfig, type Millis, NagiAbortError, NagiCanceledError, NagiConcurrencyConflictError, type NagiConfig, NagiFlowSnapshotGoneError, NagiNonRetryableError, type NagiRunConfig, NagiRuntimeError, NagiSignalTimeoutError, NagiSnapshotDriftError, NagiValidationError, type NeedRef, type NeedsMap, type NeedsOutputs, type OnceRecordedFact, type Operator, type OperatorAuditOpts, type Optional, type ParentLink, type ParentRef, type PrunableStatus, type PruneOpts, type PruneResult, type QueryRunsOpts, type QueryRunsResult, type QueryRunsWhere, type Queue, type QueueDequeueOpts, type QueueEnqueueOpts, type QueueInspectEntry, type QueueMessage, type ReapedLease, type ReaperDecision, type Register, type ReplayMode, type ReplayOpts, type Resolved, type ResolvedConcurrency, type ResolvedNeeds, type RetryPolicy, type RunCancelCause, type RunDescription, RunId, type RunPhase, type RunState, type RunStatus, type RunSummary, type RunView, type RuntimeHandle, type SerializedError, type SettleSignalResult, type SignalBufferedFact, type SignalConfig, type SignalDecision, type SignalReceivedEvent, type SignalReceivedFact, type SignalSentEvent, type SignalSentFact, type SkipReason, type SnapshotChangedEdge, type SnapshotChangedField, type SnapshotDiff, type SnapshotGoneDisposition, type SnapshotGonePolicy, StandardSchemaV1, type StartOpts, type StartStagedOpts, type StartStagedResult, type Step, type StepAbortRequestedFact, type StepCancelCause, type StepCanceledFact, type StepCompleteEvent, type StepCompletedFact, type StepCtx, type StepErrorEvent, type StepEvent, type StepFailedFact, type StepId, type StepKind, type StepMap, type StepOutput, type StepResetFact, type StepRetriedFact, type StepRetryEvent, type StepRunStatus, type StepSkippedFact, type StepStartEvent, type StepStartedFact, type StepState, type StepStatus, type StepView, type Store, type StreamEvent, type StreamTransport, type StreamingStepCtx, type StreamingTaskConfig, type StringKeyOf, type SubflowConfig, type SubflowStepOutput, type TaskConfig, type TimedOutSignal, type TimeoutDecision, type Trigger, type Tx, type Wf, type Worker, type WorkerConfig, type WorkerRunOnceOpts, type WorkerRunResult, type WorkerRunUntilEmptyOpts, attemptOf, canonicalize, decideExpiredLeaseAction, decideSignal, decideTimeout, defaultSnapshotGonePolicy, diffSnapshots, errorOf, fingerprintFlows, flow, isStepTerminal, isTerminalRun, nagi, optional, outputOf, foldRun as projectRunState, resolvedOf, runStatusOf, sha256Canonical, stepStateOf, stepStatusOf, unwrap };
404
+ export { AttemptNumber, BackoffStrategy, type CanonicalDag, type CanonicalMatchArm, type CanonicalRetryPolicy, type CanonicalSchema, type CanonicalStep, ClaimToken, Clock, ConcurrencyMode, DEFAULT_SWEEP_LIMIT, Fact, type FactEffects, Flow, FlowCanceledByConcurrencyFact, FlowConfig, FlowHooks, FlowIdOf, FlowInput, FlowStartedFact, GlobalFact, InMemoryClock, InMemoryQueue, InMemoryStore, Json, LogEntry, Millis, NagiAbortError, NagiCanceledError, NagiConcurrencyConflictError, type NagiConfig, NagiFlowSnapshotGoneError, NagiNonRetryableError, type NagiRunConfig, NagiRuntimeError, NagiSignalTimeoutError, NagiSnapshotDriftError, NagiValidationError, Operator, Optional, PrunableStatus, type PruneCandidate, PruneOpts, PruneResult, QUERY_RUNS_DEFAULT_LIMIT, QUERY_RUNS_MAX_LIMIT, QueryRunsOpts, QueryRunsResult, Queue, QueueDequeueOpts, QueueEnqueueOpts, QueueInspectEntry, QueueMessage, ReapedLease, ReplayOpts, RetryPolicy, type RunCursor, RunDescription, RunId, RunState, RunStatus, type RuntimeHandle, SettleSignalResult, SignalBufferedFact, type SignalDecision, SignalReceivedFact, type SnapshotChangedEdge, type SnapshotChangedField, type SnapshotDiff, SnapshotGonePolicy, StandardSchemaV1, type StartOpts, type StartStagedOpts, type StartStagedResult, Step, StepCanceledFact, StepCompletedFact, StepFailedFact, StepId, StepKind, StepMap, Store, StreamEvent, StreamTransport, TimedOutSignal, type TimeoutDecision, Tx, type Wf, Worker, WorkerConfig, canonicalize, clampQueryLimit, compareRunOrder, decideSignal, decideTimeout, decodeRunCursor, defaultSnapshotGonePolicy, diffSnapshots, encodeRunCursor, factEffects, fingerprintFlows, flow, isPastCursor, jsonContains, nagi, optional, selectExpired, selectPruneBatch, sha256Canonical };