@fluidgrids/workflows 2026.1028.2 → 2026.1029.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +72 -10
  2. package/dist/{activation-DnhG7SmF.d.ts → activation-BnVQMv9y.d.ts} +1 -1
  3. package/dist/{activation-BBh1p82z.d.cts → activation-CESehfYi.d.cts} +1 -1
  4. package/dist/{chunk-XHXIDVEC.js → chunk-25BKWR2O.js} +1 -1
  5. package/dist/{chunk-UK3WM7YZ.cjs → chunk-2B37XAFQ.cjs} +44 -8
  6. package/dist/{chunk-DJYMDLV5.js → chunk-2DDULZFM.js} +93 -1
  7. package/dist/{chunk-623FVQSN.cjs → chunk-3FIDHONL.cjs} +104 -0
  8. package/dist/chunk-6QPOJZT6.cjs +1180 -0
  9. package/dist/chunk-7ILGCUI6.js +154 -0
  10. package/dist/chunk-A2OHX3UQ.js +1156 -0
  11. package/dist/{chunk-VOKMAAJP.js → chunk-A36CCOWS.js} +188 -19
  12. package/dist/{chunk-FMSW2HDF.cjs → chunk-ELL2RBML.cjs} +0 -14
  13. package/dist/{chunk-JD2VQIDZ.cjs → chunk-EWYADREB.cjs} +2 -2
  14. package/dist/{chunk-HWJZVOG7.js → chunk-FQSJI5NV.js} +1 -1
  15. package/dist/{chunk-ABFZWYHT.js → chunk-FWBRQWRX.js} +156 -48
  16. package/dist/{chunk-PZCVF76Q.cjs → chunk-I47EENR4.cjs} +209 -40
  17. package/dist/chunk-J3PYFGKA.cjs +166 -0
  18. package/dist/{chunk-C5OLWZ42.js → chunk-KXJDRQ6G.js} +1 -13
  19. package/dist/chunk-M272AHEX.js +25 -0
  20. package/dist/{chunk-VRHHBPT6.js → chunk-MJ5TGYVG.js} +333 -65
  21. package/dist/{chunk-SAOBPYYJ.cjs → chunk-NXFBVDOI.cjs} +3 -3
  22. package/dist/{chunk-XKJA7KX3.js → chunk-OIX4O6UR.js} +38 -2
  23. package/dist/{chunk-FEW3JBYA.cjs → chunk-OKX3FYIM.cjs} +3 -3
  24. package/dist/{chunk-M4BBAERY.cjs → chunk-OMY3CKUZ.cjs} +404 -136
  25. package/dist/chunk-PWIUEWC3.js +81 -0
  26. package/dist/chunk-Q4MWQNJK.cjs +28 -0
  27. package/dist/{chunk-P6TA5EZT.cjs → chunk-RUQIMTN5.cjs} +171 -57
  28. package/dist/{chunk-IISBRUWJ.js → chunk-WXXNCHUY.js} +1 -1
  29. package/dist/chunk-YHBVMOMK.cjs +87 -0
  30. package/dist/codegen/index.d.cts +2 -2
  31. package/dist/codegen/index.d.ts +2 -2
  32. package/dist/collect-BTHjQaSp.d.ts +86 -0
  33. package/dist/collect-CSyOg5XC.d.cts +86 -0
  34. package/dist/{file-BOoHZgoQ.d.cts → file-cgL9l9l8.d.cts} +765 -14
  35. package/dist/{file-yuPCFU5b.d.ts → file-olQudcx5.d.ts} +765 -14
  36. package/dist/history/index.cjs +198 -86
  37. package/dist/history/index.d.cts +49 -10
  38. package/dist/history/index.d.ts +49 -10
  39. package/dist/history/index.js +49 -4
  40. package/dist/index.cjs +64 -51
  41. package/dist/index.d.cts +9 -53
  42. package/dist/index.d.ts +9 -53
  43. package/dist/index.js +5 -4
  44. package/dist/ir/index.cjs +24 -3
  45. package/dist/ir/index.d.cts +43 -4
  46. package/dist/ir/index.d.ts +43 -4
  47. package/dist/ir/index.js +24 -3
  48. package/dist/{lower-BzmUz0sq.d.cts → lower-3S6PsqjJ.d.cts} +40 -6
  49. package/dist/{lower-_-iT4HYs.d.ts → lower-DmZpQ8hJ.d.ts} +40 -6
  50. package/dist/{manifest-C8N6HDYl.d.ts → manifest-BJjrQt77.d.ts} +1 -1
  51. package/dist/{manifest-0OLw0i7k.d.cts → manifest-gRI2Q5Fj.d.cts} +1 -1
  52. package/dist/node-evaluator-SOADN23V.js +14 -0
  53. package/dist/node-evaluator-YGDEXK4U.cjs +24 -0
  54. package/dist/quickjs/index.cjs +25 -24
  55. package/dist/quickjs/index.d.cts +6 -6
  56. package/dist/quickjs/index.d.ts +6 -6
  57. package/dist/quickjs/index.js +8 -7
  58. package/dist/roundtrip/index.cjs +245 -43
  59. package/dist/roundtrip/index.d.cts +86 -9
  60. package/dist/roundtrip/index.d.ts +86 -9
  61. package/dist/roundtrip/index.js +172 -8
  62. package/dist/runtime/index.cjs +21 -20
  63. package/dist/runtime/index.d.cts +49 -7
  64. package/dist/runtime/index.d.ts +49 -7
  65. package/dist/runtime/index.js +8 -7
  66. package/dist/testing/index.cjs +514 -74
  67. package/dist/testing/index.d.cts +127 -10
  68. package/dist/testing/index.d.ts +127 -10
  69. package/dist/testing/index.js +480 -42
  70. package/dist/{types-BGoPzgcl.d.ts → types-Bb2wRnJ5.d.cts} +20 -1
  71. package/dist/{types-BGoPzgcl.d.cts → types-Bb2wRnJ5.d.ts} +20 -1
  72. package/dist/{types-DV-HX_Gt.d.ts → types-CQKOhPTa.d.cts} +122 -14
  73. package/dist/{types-CpBBjaGX.d.cts → types-CnIOinoz.d.ts} +122 -14
  74. package/dist/{workflow-Bpr3vnA_.d.ts → workflow-8uRU9rhL.d.ts} +2 -2
  75. package/dist/{workflow-FXUkpIBc.d.cts → workflow-CZOXUlQ5.d.cts} +2 -2
  76. package/dist/{workflow-C2a05WUJ.d.ts → workflow-DWTPHFbt.d.ts} +124 -12
  77. package/dist/{workflow-J-yYixny.d.cts → workflow-O6e64ZcG.d.cts} +124 -12
  78. package/fixtures/histories/auto-upgrade-patched.history.json +276 -0
  79. package/fixtures/histories/benign-failure.history.json +146 -0
  80. package/fixtures/histories/cancel-activity-try-cancel.history.json +150 -0
  81. package/fixtures/histories/child-cancel-wait-requested.history.json +217 -0
  82. package/fixtures/histories/child-options-roundtrip.history.json +192 -0
  83. package/fixtures/histories/continue-as-new-last-result.history.json +86 -0
  84. package/fixtures/histories/continue-as-new-options.history.json +99 -0
  85. package/fixtures/histories/continue-as-new-r1-long-task-queue.history.json +78 -0
  86. package/fixtures/histories/continue-as-new-r1-retry-options.history.json +83 -0
  87. package/fixtures/histories/execution-timeout-chain.history.json +98 -0
  88. package/fixtures/histories/external-cancel-resolved.history.json +123 -0
  89. package/fixtures/histories/external-cancel-unknown-target.history.json +127 -0
  90. package/fixtures/histories/failure-error-types-fails-run.history.json +144 -0
  91. package/fixtures/histories/handler-drain-warn.history.json +222 -0
  92. package/fixtures/histories/heartbeat-details-on-retry.history.json +145 -0
  93. package/fixtures/histories/local-activity-abandoned-at-completion.history.json +73 -0
  94. package/fixtures/histories/local-activity-cancelled-in-scope.history.json +118 -0
  95. package/fixtures/histories/local-activity-completed.history.json +157 -0
  96. package/fixtures/histories/local-activity-failed.history.json +93 -0
  97. package/fixtures/histories/local-activity-retry-in-task.history.json +88 -0
  98. package/fixtures/histories/run-retry-last-failure.history.json +90 -0
  99. package/fixtures/histories/run-timeout.history.json +159 -0
  100. package/fixtures/histories/schedule-to-start-timeout.history.json +132 -0
  101. package/fixtures/histories/start-delay-signal-ends-delay.history.json +155 -0
  102. package/fixtures/histories/typeerror-task-retry-100.history.json +137 -0
  103. package/package.json +1 -1
  104. package/schema/history-file.schema.json +283 -2
  105. package/schema/ir-v2.schema.json +45 -0
  106. package/schema/run-event.schema.json +264 -2
  107. package/schema/workflow-command.schema.json +178 -1
  108. package/schema/workflow-task.schema.json +392 -4
  109. package/dist/assemble-BLqQ8lSu.d.cts +0 -39
  110. package/dist/assemble-DWgaXHd-.d.ts +0 -39
  111. package/dist/chunk-2J6TF7YI.cjs +0 -86
  112. package/dist/chunk-BO6OVILK.js +0 -79
  113. package/dist/chunk-DHTLALBL.cjs +0 -80
  114. package/dist/chunk-I5LR3D2K.js +0 -869
  115. package/dist/chunk-N23SKIG4.js +0 -73
  116. package/dist/chunk-QQ6ULXHI.cjs +0 -885
  117. package/dist/node-evaluator-4MSDKWOG.cjs +0 -22
  118. package/dist/node-evaluator-SX4LEYQC.js +0 -12
@@ -1,5 +1,5 @@
1
- import { a as Json, J as JsonObject, W as WorkflowInterface } from './types-BGoPzgcl.js';
2
- import { a6 as WorkflowInfoSnapshot, R as RetryPolicy, c as ActivityCancellationType, w as Headers, P as ParentClosePolicy, C as ChildCancellationType } from './types-DV-HX_Gt.js';
1
+ import { J as Json, a as JsonObject, b as WorkflowInterface } from './types-Bb2wRnJ5.js';
2
+ import { ai as WorkflowInfoSnapshot, R as RetryPolicy, d as ActivityCancellationType, x as Headers, P as ParentClosePolicy, C as ChildCancellationType, ac as VersioningBehavior, ah as WorkflowIdReusePolicy, ag as WorkflowIdConflictPolicy, b as RunRetryPolicy } from './types-CnIOinoz.js';
3
3
 
4
4
  /**
5
5
  * Node operation descriptors: what a builder call needs to know about the node
@@ -205,6 +205,57 @@ interface RunOptions<In> {
205
205
  nodeVersion?: string;
206
206
  headers?: Headers;
207
207
  }
208
+ /** Options of `ctx.localActivity` (11 §2.12). */
209
+ interface LocalActivityOptions<In> {
210
+ args: In;
211
+ /** Connection name, resolved by the worker that runs the task. */
212
+ connection?: string;
213
+ /** Default: 1 s, x2, at most 100 s, unlimited attempts, bounded by the task's 30 s budget. */
214
+ retry?: Partial<RetryPolicy>;
215
+ /** At most 30 s (the default). */
216
+ startToCloseTimeout?: Duration;
217
+ /** Label in the History tab (at most 200 characters). */
218
+ summary?: string;
219
+ /** Overrides the operation name the descriptor carries. */
220
+ operation?: string;
221
+ /** Overrides the node version the descriptor carries. */
222
+ nodeVersion?: string;
223
+ }
224
+ /**
225
+ * Run-level retry of a workflow (11 §2.17): a run that fails with a retryable
226
+ * failure, or whose run timeout expires, starts again as a new run of the same
227
+ * chain with `ctx.info.attempt + 1` and `ctx.info.lastFailure`.
228
+ */
229
+ interface WorkflowRetryOptions {
230
+ /** Attempts in total, the first one included; absent means unlimited (bounded by the execution timeout). */
231
+ maxAttempts?: number;
232
+ /** Delay before the second attempt; default 1 s. */
233
+ initialDelay?: Duration;
234
+ /** Default 2. */
235
+ backoffMultiplier?: number;
236
+ /** Largest delay; default 100 s, or 100 times `initialDelay` when that is given. */
237
+ maxDelay?: Duration;
238
+ /** Free-form failure types that are never retried. */
239
+ nonRetryableErrorTypes?: string[];
240
+ }
241
+ /** A run addressed by its workflow id (11 §2.1): the open run of the chain. */
242
+ interface WorkflowIdTarget {
243
+ workflowKey: string;
244
+ workflowId: string;
245
+ /** Pins the chain whose first run this is. */
246
+ firstRunId?: string;
247
+ }
248
+ /** Another run of the workspace: a run id or a workflow id. */
249
+ type ExternalRunTarget = string | {
250
+ runId: string;
251
+ } | WorkflowIdTarget;
252
+ /** What happens to a handler still running when the workflow finishes (11 §2.18). */
253
+ type HandlerUnfinishedPolicy = 'WARN_AND_ABANDON' | 'ABANDON';
254
+ /** Options of `ctx.onSignal`. */
255
+ interface SignalHandlerOptions {
256
+ /** Default `WARN_AND_ABANDON`: a warning when the workflow finishes while this handler runs. */
257
+ unfinishedPolicy?: HandlerUnfinishedPolicy;
258
+ }
208
259
  /** Options of `ctx.child` and `ctx.startChild` (11 §2.35). */
209
260
  interface ChildOptions {
210
261
  input?: unknown;
@@ -229,6 +280,11 @@ interface ChildOptions {
229
280
  executionTimeout?: Duration;
230
281
  runTimeout?: Duration;
231
282
  workflowTaskTimeout?: Duration;
283
+ /** Run-level retry of the child. */
284
+ retry?: WorkflowRetryOptions;
285
+ versioningBehavior?: VersioningBehavior;
286
+ idReusePolicy?: WorkflowIdReusePolicy;
287
+ idConflictPolicy?: WorkflowIdConflictPolicy;
232
288
  headers?: Headers;
233
289
  }
234
290
  /** A started child run. */
@@ -242,7 +298,11 @@ interface ChildHandle<Out = Json> {
242
298
  }
243
299
  /** A handle to another run of the workspace (11 §2.24). */
244
300
  interface ExternalRunHandle {
301
+ /** The run id of a run-id target; empty for a workflow-id target. */
245
302
  readonly runId: string;
303
+ /** The workflow key and id of a workflow-id target. */
304
+ readonly workflowKey?: string;
305
+ readonly workflowId?: string;
246
306
  signal<P>(signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
247
307
  /** Resolves when the cancel request was delivered, not when the run ends. */
248
308
  cancel(): Promise<void>;
@@ -291,12 +351,26 @@ interface Saga {
291
351
  add(compensation: (ctx: WorkflowContext) => unknown): void;
292
352
  compensate(): Promise<void>;
293
353
  }
354
+ /** Options of `ctx.continueAsNew`; each defaults to the current run's value (11 §2.20). */
355
+ /**
356
+ * The R1 continue-as-new retry option: the activity retry shape. R1 wrote it
357
+ * into `CONTINUE_AS_NEW` unchanged and the Phase B service ignored it.
358
+ *
359
+ * @deprecated Since R2; give a run-level {@link WorkflowRetryOptions}.
360
+ */
361
+ type LegacyContinueAsNewRetry = Partial<RetryPolicy>;
294
362
  interface ContinueAsNewOptions {
295
363
  taskQueue?: string;
296
- retry?: Partial<RetryPolicy>;
364
+ /**
365
+ * The run-level retry policy of the new run. The R1 activity shape
366
+ * (`retryDelay`, `maxRetries`) is still accepted and written as R1 wrote it;
367
+ * it has no effect, as in Phase B.
368
+ */
369
+ retry?: WorkflowRetryOptions | LegacyContinueAsNewRetry;
297
370
  workflowTaskTimeout?: Duration;
371
+ /** The new run's memo. */
298
372
  context?: JsonObject;
299
- versioningBehavior?: 'PINNED' | 'AUTO_UPGRADE';
373
+ versioningBehavior?: VersioningBehavior;
300
374
  }
301
375
  /** A child target: a workflow key (graph or durable) or a tier-2 function of the same bundle. */
302
376
  type ChildTarget<Out> = string | DurableWorkflow<never, Out> | DurableWorkflow<Json, Out>;
@@ -316,19 +390,20 @@ interface WorkflowContext {
316
390
  signalReceived<P>(signal: SignalDefinition<P> | string): Promise<P>;
317
391
  /** Handle every signal of this name, buffered ones first. */
318
392
  onSignal<P>(signal: SignalDefinition<P> | string, handler: (payload: P) => unknown): void;
393
+ onSignal<P>(signal: SignalDefinition<P> | string, options: SignalHandlerOptions, handler: (payload: P) => unknown): void;
319
394
  /** Handle signals no other handler or waiter takes. */
320
395
  setDefaultSignalHandler(handler: (name: string, payload: unknown) => unknown): void;
321
396
  /** Start a child run and wait for its result. */
322
397
  child<Out = Json>(target: ChildTarget<Out>, options?: ChildOptions): Promise<Out>;
323
398
  /** Start a child run; resolves once it has started. */
324
399
  startChild<Out = Json>(target: ChildTarget<Out>, options?: ChildOptions): Promise<ChildHandle<Out>>;
325
- /** Signal another run of the workspace; resolves on delivery. */
326
- signalRun<P>(runId: string, signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
400
+ /** Signal another run of the workspace (by run id or workflow id); resolves on delivery. */
401
+ signalRun<P>(target: ExternalRunTarget, signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
327
402
  /** Signal the parent run. */
328
403
  signalParent<P>(signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
329
- getRunHandle(runId: string): ExternalRunHandle;
330
- /** Shorthand for `getRunHandle(runId).cancel()`. */
331
- cancelRun(runId: string): Promise<void>;
404
+ getRunHandle(target: ExternalRunTarget): ExternalRunHandle;
405
+ /** Shorthand for `getRunHandle(target).cancel()`. */
406
+ cancelRun(target: ExternalRunTarget): Promise<void>;
332
407
  /** The workflow clock (the task's start time), in epoch milliseconds. */
333
408
  now(): number;
334
409
  /** A deterministic random number in [0, 1), seeded per run. */
@@ -366,8 +441,17 @@ interface WorkflowContext {
366
441
  allHandlersFinished(): Promise<void>;
367
442
  /** Phase C: user activities. Throws `PhaseCFeatureError`. */
368
443
  activity(...args: unknown[]): Promise<never>;
369
- /** Phase B parity: local activities. Throws `PhaseCFeatureError` in this release. */
370
- localActivity(...args: unknown[]): Promise<never>;
444
+ /**
445
+ * Run a short, idempotent node operation inside the workflow task (11
446
+ * §2.12): the worker that runs the task executes it and the task records one
447
+ * `LOCAL_ACTIVITY_COMPLETED` or `LOCAL_ACTIVITY_FAILED` marker
448
+ * (`RECORD_LOCAL_ACTIVITY`). Replays return the recorded outcome and never
449
+ * run it again. The activity allow-list of `ctx.run` applies; a user
450
+ * function instead of a node operation is Phase C and throws
451
+ * `PhaseCFeatureError`.
452
+ */
453
+ localActivity<In, Out>(operation: Operation<In, Out>, options: LocalActivityOptions<In>): Promise<Out>;
454
+ localActivity(fn: (...args: never[]) => unknown, options?: unknown): Promise<never>;
371
455
  /** Phase C: custom queries. Throws `PhaseCFeatureError`. */
372
456
  handleQuery(...args: unknown[]): void;
373
457
  /** Phase C: updates. Throws `PhaseCFeatureError`. */
@@ -422,7 +506,19 @@ interface DurableWorkflowOptions {
422
506
  standalone?: boolean;
423
507
  /** Error classes that fail the run instead of the workflow task (11 §2.25). */
424
508
  failureErrorTypes?: ReadonlyArray<abstract new (...args: never[]) => Error>;
509
+ /** `PINNED` (default) or `AUTO_UPGRADE` (11 §2.27); lowered to `config.versioningBehavior`. */
510
+ versioningBehavior?: VersioningBehavior;
511
+ /** Run-level retry (11 §2.17); lowered to `config.retry`. */
512
+ retry?: WorkflowRetryOptions;
513
+ /** Bounds the whole continue-as-new and retry chain (11 §2.20); `config.executionTimeout`. */
514
+ executionTimeout?: Duration;
515
+ /** Bounds one run; `config.timeout`. */
516
+ runTimeout?: Duration;
517
+ /** The replay budget of one workflow task, at most 120 s; `config.workflowTaskTimeout`. */
518
+ workflowTaskTimeout?: Duration;
425
519
  }
520
+ /** The largest `workflowTaskTimeout` (11 §2.20). */
521
+ declare const MAX_WORKFLOW_TASK_TIMEOUT_MS = 120000;
426
522
  /** A declared tier-2 workflow. */
427
523
  interface DurableWorkflow<In = Json, Out = Json> {
428
524
  readonly __fluidgrids: typeof DURABLE_MARKER;
@@ -440,5 +536,21 @@ declare function isDurableWorkflow(value: unknown): value is DurableWorkflow<nev
440
536
  declare function jsonSchemaOf(schema: SchemaLike | undefined): JsonObject | undefined;
441
537
  /** The workflow `interface` (spec 01 §4) a tier-2 declaration describes. */
442
538
  declare function interfaceOf(definition: DurableWorkflow<never, unknown>): WorkflowInterface;
539
+ /** The history form (milliseconds, defaults filled in) of a run-level retry option. */
540
+ declare function runRetryPolicyOf(retry: WorkflowRetryOptions): RunRetryPolicy;
541
+ /**
542
+ * The `CONTINUE_AS_NEW` `options.retry` of a `ctx.continueAsNew` retry option
543
+ * (C-SCHEMA `canOptions`).
544
+ *
545
+ * - An option with an activity-only key (`retryDelay`, `maxRetries`,
546
+ * `retryOnErrorTypes`) is the R1 shape. It is written exactly as R1 wrote it
547
+ * (activity form, defaults filled in), so an R1 workflow issues the same
548
+ * command and keeps its Phase B behaviour: the service ignores that shape.
549
+ * - Anything else is a run-level retry policy (R2), checked for unknown keys.
550
+ * Keys both shapes share (`maxDelay`, `backoffMultiplier`,
551
+ * `nonRetryableErrorTypes`) alone mean the R2 shape.
552
+ * - Mixing an activity-only key with `maxAttempts` or `initialDelay` throws.
553
+ */
554
+ declare function continueAsNewRetryOf(retry: WorkflowRetryOptions | LegacyContinueAsNewRetry): RunRetryPolicy | RetryPolicy;
443
555
 
444
- export { trigger as A, triggers as B, type CancellationScope as C, DURABLE_MARKER as D, type ExternalRunHandle as E, type FileRef as F, workflow as G, type Operation as O, type QueryDefinition as Q, type RunOptions as R, type Saga as S, type TriggerOperation as T, type UpdateDefinition as U, type WorkflowContext as W, type CancellationScopeFunction as a, type CancellationScopeOptions as b, type ChildHandle as c, type ChildOptions as d, type ChildTarget as e, type ContinueAsNewOptions as f, type DefinitionOptions as g, type DurableWorkflow as h, type DurableWorkflowOptions as i, type Duration as j, type SchemaLike as k, type SignalDefinition as l, type TriggerSpec as m, type WorkflowInfo as n, type WorkflowLogger as o, defineQuery as p, defineSignal as q, defineUpdate as r, interfaceOf as s, internalNodes as t, isDurableWorkflow as u, isOperation as v, jsonSchemaOf as w, nodes as x, op as y, toMs as z };
556
+ export { isDurableWorkflow as A, isOperation as B, type CancellationScope as C, DURABLE_MARKER as D, type ExternalRunHandle as E, type FileRef as F, jsonSchemaOf as G, type HandlerUnfinishedPolicy as H, nodes as I, op as J, runRetryPolicyOf as K, type LegacyContinueAsNewRetry as L, MAX_WORKFLOW_TASK_TIMEOUT_MS as M, toMs as N, type Operation as O, trigger as P, type QueryDefinition as Q, type RunOptions as R, type Saga as S, type TriggerOperation as T, type UpdateDefinition as U, triggers as V, type WorkflowContext as W, workflow as X, type CancellationScopeFunction as a, type CancellationScopeOptions as b, type ChildHandle as c, type ChildOptions as d, type ChildTarget as e, type ContinueAsNewOptions as f, type DefinitionOptions as g, type DurableWorkflow as h, type DurableWorkflowOptions as i, type Duration as j, type ExternalRunTarget as k, type LocalActivityOptions as l, type SchemaLike as m, type SignalDefinition as n, type SignalHandlerOptions as o, type TriggerSpec as p, type WorkflowIdTarget as q, type WorkflowInfo as r, type WorkflowLogger as s, type WorkflowRetryOptions as t, continueAsNewRetryOf as u, defineQuery as v, defineSignal as w, defineUpdate as x, interfaceOf as y, internalNodes as z };
@@ -1,5 +1,5 @@
1
- import { a as Json, J as JsonObject, W as WorkflowInterface } from './types-BGoPzgcl.cjs';
2
- import { a6 as WorkflowInfoSnapshot, R as RetryPolicy, c as ActivityCancellationType, w as Headers, P as ParentClosePolicy, C as ChildCancellationType } from './types-CpBBjaGX.cjs';
1
+ import { J as Json, a as JsonObject, b as WorkflowInterface } from './types-Bb2wRnJ5.cjs';
2
+ import { ai as WorkflowInfoSnapshot, R as RetryPolicy, d as ActivityCancellationType, x as Headers, P as ParentClosePolicy, C as ChildCancellationType, ac as VersioningBehavior, ah as WorkflowIdReusePolicy, ag as WorkflowIdConflictPolicy, b as RunRetryPolicy } from './types-CQKOhPTa.cjs';
3
3
 
4
4
  /**
5
5
  * Node operation descriptors: what a builder call needs to know about the node
@@ -205,6 +205,57 @@ interface RunOptions<In> {
205
205
  nodeVersion?: string;
206
206
  headers?: Headers;
207
207
  }
208
+ /** Options of `ctx.localActivity` (11 §2.12). */
209
+ interface LocalActivityOptions<In> {
210
+ args: In;
211
+ /** Connection name, resolved by the worker that runs the task. */
212
+ connection?: string;
213
+ /** Default: 1 s, x2, at most 100 s, unlimited attempts, bounded by the task's 30 s budget. */
214
+ retry?: Partial<RetryPolicy>;
215
+ /** At most 30 s (the default). */
216
+ startToCloseTimeout?: Duration;
217
+ /** Label in the History tab (at most 200 characters). */
218
+ summary?: string;
219
+ /** Overrides the operation name the descriptor carries. */
220
+ operation?: string;
221
+ /** Overrides the node version the descriptor carries. */
222
+ nodeVersion?: string;
223
+ }
224
+ /**
225
+ * Run-level retry of a workflow (11 §2.17): a run that fails with a retryable
226
+ * failure, or whose run timeout expires, starts again as a new run of the same
227
+ * chain with `ctx.info.attempt + 1` and `ctx.info.lastFailure`.
228
+ */
229
+ interface WorkflowRetryOptions {
230
+ /** Attempts in total, the first one included; absent means unlimited (bounded by the execution timeout). */
231
+ maxAttempts?: number;
232
+ /** Delay before the second attempt; default 1 s. */
233
+ initialDelay?: Duration;
234
+ /** Default 2. */
235
+ backoffMultiplier?: number;
236
+ /** Largest delay; default 100 s, or 100 times `initialDelay` when that is given. */
237
+ maxDelay?: Duration;
238
+ /** Free-form failure types that are never retried. */
239
+ nonRetryableErrorTypes?: string[];
240
+ }
241
+ /** A run addressed by its workflow id (11 §2.1): the open run of the chain. */
242
+ interface WorkflowIdTarget {
243
+ workflowKey: string;
244
+ workflowId: string;
245
+ /** Pins the chain whose first run this is. */
246
+ firstRunId?: string;
247
+ }
248
+ /** Another run of the workspace: a run id or a workflow id. */
249
+ type ExternalRunTarget = string | {
250
+ runId: string;
251
+ } | WorkflowIdTarget;
252
+ /** What happens to a handler still running when the workflow finishes (11 §2.18). */
253
+ type HandlerUnfinishedPolicy = 'WARN_AND_ABANDON' | 'ABANDON';
254
+ /** Options of `ctx.onSignal`. */
255
+ interface SignalHandlerOptions {
256
+ /** Default `WARN_AND_ABANDON`: a warning when the workflow finishes while this handler runs. */
257
+ unfinishedPolicy?: HandlerUnfinishedPolicy;
258
+ }
208
259
  /** Options of `ctx.child` and `ctx.startChild` (11 §2.35). */
209
260
  interface ChildOptions {
210
261
  input?: unknown;
@@ -229,6 +280,11 @@ interface ChildOptions {
229
280
  executionTimeout?: Duration;
230
281
  runTimeout?: Duration;
231
282
  workflowTaskTimeout?: Duration;
283
+ /** Run-level retry of the child. */
284
+ retry?: WorkflowRetryOptions;
285
+ versioningBehavior?: VersioningBehavior;
286
+ idReusePolicy?: WorkflowIdReusePolicy;
287
+ idConflictPolicy?: WorkflowIdConflictPolicy;
232
288
  headers?: Headers;
233
289
  }
234
290
  /** A started child run. */
@@ -242,7 +298,11 @@ interface ChildHandle<Out = Json> {
242
298
  }
243
299
  /** A handle to another run of the workspace (11 §2.24). */
244
300
  interface ExternalRunHandle {
301
+ /** The run id of a run-id target; empty for a workflow-id target. */
245
302
  readonly runId: string;
303
+ /** The workflow key and id of a workflow-id target. */
304
+ readonly workflowKey?: string;
305
+ readonly workflowId?: string;
246
306
  signal<P>(signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
247
307
  /** Resolves when the cancel request was delivered, not when the run ends. */
248
308
  cancel(): Promise<void>;
@@ -291,12 +351,26 @@ interface Saga {
291
351
  add(compensation: (ctx: WorkflowContext) => unknown): void;
292
352
  compensate(): Promise<void>;
293
353
  }
354
+ /** Options of `ctx.continueAsNew`; each defaults to the current run's value (11 §2.20). */
355
+ /**
356
+ * The R1 continue-as-new retry option: the activity retry shape. R1 wrote it
357
+ * into `CONTINUE_AS_NEW` unchanged and the Phase B service ignored it.
358
+ *
359
+ * @deprecated Since R2; give a run-level {@link WorkflowRetryOptions}.
360
+ */
361
+ type LegacyContinueAsNewRetry = Partial<RetryPolicy>;
294
362
  interface ContinueAsNewOptions {
295
363
  taskQueue?: string;
296
- retry?: Partial<RetryPolicy>;
364
+ /**
365
+ * The run-level retry policy of the new run. The R1 activity shape
366
+ * (`retryDelay`, `maxRetries`) is still accepted and written as R1 wrote it;
367
+ * it has no effect, as in Phase B.
368
+ */
369
+ retry?: WorkflowRetryOptions | LegacyContinueAsNewRetry;
297
370
  workflowTaskTimeout?: Duration;
371
+ /** The new run's memo. */
298
372
  context?: JsonObject;
299
- versioningBehavior?: 'PINNED' | 'AUTO_UPGRADE';
373
+ versioningBehavior?: VersioningBehavior;
300
374
  }
301
375
  /** A child target: a workflow key (graph or durable) or a tier-2 function of the same bundle. */
302
376
  type ChildTarget<Out> = string | DurableWorkflow<never, Out> | DurableWorkflow<Json, Out>;
@@ -316,19 +390,20 @@ interface WorkflowContext {
316
390
  signalReceived<P>(signal: SignalDefinition<P> | string): Promise<P>;
317
391
  /** Handle every signal of this name, buffered ones first. */
318
392
  onSignal<P>(signal: SignalDefinition<P> | string, handler: (payload: P) => unknown): void;
393
+ onSignal<P>(signal: SignalDefinition<P> | string, options: SignalHandlerOptions, handler: (payload: P) => unknown): void;
319
394
  /** Handle signals no other handler or waiter takes. */
320
395
  setDefaultSignalHandler(handler: (name: string, payload: unknown) => unknown): void;
321
396
  /** Start a child run and wait for its result. */
322
397
  child<Out = Json>(target: ChildTarget<Out>, options?: ChildOptions): Promise<Out>;
323
398
  /** Start a child run; resolves once it has started. */
324
399
  startChild<Out = Json>(target: ChildTarget<Out>, options?: ChildOptions): Promise<ChildHandle<Out>>;
325
- /** Signal another run of the workspace; resolves on delivery. */
326
- signalRun<P>(runId: string, signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
400
+ /** Signal another run of the workspace (by run id or workflow id); resolves on delivery. */
401
+ signalRun<P>(target: ExternalRunTarget, signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
327
402
  /** Signal the parent run. */
328
403
  signalParent<P>(signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
329
- getRunHandle(runId: string): ExternalRunHandle;
330
- /** Shorthand for `getRunHandle(runId).cancel()`. */
331
- cancelRun(runId: string): Promise<void>;
404
+ getRunHandle(target: ExternalRunTarget): ExternalRunHandle;
405
+ /** Shorthand for `getRunHandle(target).cancel()`. */
406
+ cancelRun(target: ExternalRunTarget): Promise<void>;
332
407
  /** The workflow clock (the task's start time), in epoch milliseconds. */
333
408
  now(): number;
334
409
  /** A deterministic random number in [0, 1), seeded per run. */
@@ -366,8 +441,17 @@ interface WorkflowContext {
366
441
  allHandlersFinished(): Promise<void>;
367
442
  /** Phase C: user activities. Throws `PhaseCFeatureError`. */
368
443
  activity(...args: unknown[]): Promise<never>;
369
- /** Phase B parity: local activities. Throws `PhaseCFeatureError` in this release. */
370
- localActivity(...args: unknown[]): Promise<never>;
444
+ /**
445
+ * Run a short, idempotent node operation inside the workflow task (11
446
+ * §2.12): the worker that runs the task executes it and the task records one
447
+ * `LOCAL_ACTIVITY_COMPLETED` or `LOCAL_ACTIVITY_FAILED` marker
448
+ * (`RECORD_LOCAL_ACTIVITY`). Replays return the recorded outcome and never
449
+ * run it again. The activity allow-list of `ctx.run` applies; a user
450
+ * function instead of a node operation is Phase C and throws
451
+ * `PhaseCFeatureError`.
452
+ */
453
+ localActivity<In, Out>(operation: Operation<In, Out>, options: LocalActivityOptions<In>): Promise<Out>;
454
+ localActivity(fn: (...args: never[]) => unknown, options?: unknown): Promise<never>;
371
455
  /** Phase C: custom queries. Throws `PhaseCFeatureError`. */
372
456
  handleQuery(...args: unknown[]): void;
373
457
  /** Phase C: updates. Throws `PhaseCFeatureError`. */
@@ -422,7 +506,19 @@ interface DurableWorkflowOptions {
422
506
  standalone?: boolean;
423
507
  /** Error classes that fail the run instead of the workflow task (11 §2.25). */
424
508
  failureErrorTypes?: ReadonlyArray<abstract new (...args: never[]) => Error>;
509
+ /** `PINNED` (default) or `AUTO_UPGRADE` (11 §2.27); lowered to `config.versioningBehavior`. */
510
+ versioningBehavior?: VersioningBehavior;
511
+ /** Run-level retry (11 §2.17); lowered to `config.retry`. */
512
+ retry?: WorkflowRetryOptions;
513
+ /** Bounds the whole continue-as-new and retry chain (11 §2.20); `config.executionTimeout`. */
514
+ executionTimeout?: Duration;
515
+ /** Bounds one run; `config.timeout`. */
516
+ runTimeout?: Duration;
517
+ /** The replay budget of one workflow task, at most 120 s; `config.workflowTaskTimeout`. */
518
+ workflowTaskTimeout?: Duration;
425
519
  }
520
+ /** The largest `workflowTaskTimeout` (11 §2.20). */
521
+ declare const MAX_WORKFLOW_TASK_TIMEOUT_MS = 120000;
426
522
  /** A declared tier-2 workflow. */
427
523
  interface DurableWorkflow<In = Json, Out = Json> {
428
524
  readonly __fluidgrids: typeof DURABLE_MARKER;
@@ -440,5 +536,21 @@ declare function isDurableWorkflow(value: unknown): value is DurableWorkflow<nev
440
536
  declare function jsonSchemaOf(schema: SchemaLike | undefined): JsonObject | undefined;
441
537
  /** The workflow `interface` (spec 01 §4) a tier-2 declaration describes. */
442
538
  declare function interfaceOf(definition: DurableWorkflow<never, unknown>): WorkflowInterface;
539
+ /** The history form (milliseconds, defaults filled in) of a run-level retry option. */
540
+ declare function runRetryPolicyOf(retry: WorkflowRetryOptions): RunRetryPolicy;
541
+ /**
542
+ * The `CONTINUE_AS_NEW` `options.retry` of a `ctx.continueAsNew` retry option
543
+ * (C-SCHEMA `canOptions`).
544
+ *
545
+ * - An option with an activity-only key (`retryDelay`, `maxRetries`,
546
+ * `retryOnErrorTypes`) is the R1 shape. It is written exactly as R1 wrote it
547
+ * (activity form, defaults filled in), so an R1 workflow issues the same
548
+ * command and keeps its Phase B behaviour: the service ignores that shape.
549
+ * - Anything else is a run-level retry policy (R2), checked for unknown keys.
550
+ * Keys both shapes share (`maxDelay`, `backoffMultiplier`,
551
+ * `nonRetryableErrorTypes`) alone mean the R2 shape.
552
+ * - Mixing an activity-only key with `maxAttempts` or `initialDelay` throws.
553
+ */
554
+ declare function continueAsNewRetryOf(retry: WorkflowRetryOptions | LegacyContinueAsNewRetry): RunRetryPolicy | RetryPolicy;
443
555
 
444
- export { trigger as A, triggers as B, type CancellationScope as C, DURABLE_MARKER as D, type ExternalRunHandle as E, type FileRef as F, workflow as G, type Operation as O, type QueryDefinition as Q, type RunOptions as R, type Saga as S, type TriggerOperation as T, type UpdateDefinition as U, type WorkflowContext as W, type CancellationScopeFunction as a, type CancellationScopeOptions as b, type ChildHandle as c, type ChildOptions as d, type ChildTarget as e, type ContinueAsNewOptions as f, type DefinitionOptions as g, type DurableWorkflow as h, type DurableWorkflowOptions as i, type Duration as j, type SchemaLike as k, type SignalDefinition as l, type TriggerSpec as m, type WorkflowInfo as n, type WorkflowLogger as o, defineQuery as p, defineSignal as q, defineUpdate as r, interfaceOf as s, internalNodes as t, isDurableWorkflow as u, isOperation as v, jsonSchemaOf as w, nodes as x, op as y, toMs as z };
556
+ export { isDurableWorkflow as A, isOperation as B, type CancellationScope as C, DURABLE_MARKER as D, type ExternalRunHandle as E, type FileRef as F, jsonSchemaOf as G, type HandlerUnfinishedPolicy as H, nodes as I, op as J, runRetryPolicyOf as K, type LegacyContinueAsNewRetry as L, MAX_WORKFLOW_TASK_TIMEOUT_MS as M, toMs as N, type Operation as O, trigger as P, type QueryDefinition as Q, type RunOptions as R, type Saga as S, type TriggerOperation as T, type UpdateDefinition as U, triggers as V, type WorkflowContext as W, workflow as X, type CancellationScopeFunction as a, type CancellationScopeOptions as b, type ChildHandle as c, type ChildOptions as d, type ChildTarget as e, type ContinueAsNewOptions as f, type DefinitionOptions as g, type DurableWorkflow as h, type DurableWorkflowOptions as i, type Duration as j, type ExternalRunTarget as k, type LocalActivityOptions as l, type SchemaLike as m, type SignalDefinition as n, type SignalHandlerOptions as o, type TriggerSpec as p, type WorkflowIdTarget as q, type WorkflowInfo as r, type WorkflowLogger as s, type WorkflowRetryOptions as t, continueAsNewRetryOf as u, defineQuery as v, defineSignal as w, defineUpdate as x, interfaceOf as y, internalNodes as z };