@fluidgrids/workflows 2026.1028.2 → 2026.1030.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 (154) hide show
  1. package/README.md +181 -11
  2. package/dist/{activation-BBh1p82z.d.cts → activation-DqUfpHzk.d.cts} +1 -1
  3. package/dist/{activation-DnhG7SmF.d.ts → activation-xpx1oWuo.d.ts} +1 -1
  4. package/dist/{chunk-VRHHBPT6.js → chunk-2D3MYIIF.js} +1212 -128
  5. package/dist/chunk-3U2NU7YC.cjs +124 -0
  6. package/dist/{chunk-NEIUQASE.cjs → chunk-4QKB4ARC.cjs} +3 -3
  7. package/dist/{chunk-GBQ33SIZ.cjs → chunk-54FLQNUM.cjs} +12 -1
  8. package/dist/chunk-5HIVIV53.js +330 -0
  9. package/dist/chunk-5MFVJM76.js +1222 -0
  10. package/dist/{chunk-JD2VQIDZ.cjs → chunk-672KMMBK.cjs} +2 -2
  11. package/dist/{chunk-C5OLWZ42.js → chunk-6A2FGSUS.js} +22 -14
  12. package/dist/{chunk-XKJA7KX3.js → chunk-6OLN6BMB.js} +52 -3
  13. package/dist/{chunk-6FSHT5IL.js → chunk-7EZIANC7.js} +1 -1
  14. package/dist/{chunk-2J6TF7YI.cjs → chunk-A5SXCA62.cjs} +10 -3
  15. package/dist/{chunk-BO6OVILK.js → chunk-AC6ZEXVR.js} +10 -4
  16. package/dist/{chunk-ABFZWYHT.js → chunk-AE5Q6ZAJ.js} +315 -50
  17. package/dist/chunk-C4F5KJTI.js +293 -0
  18. package/dist/{chunk-IISBRUWJ.js → chunk-G5H32GIG.js} +1 -1
  19. package/dist/chunk-GEQDGUGB.cjs +2719 -0
  20. package/dist/{chunk-XHXIDVEC.js → chunk-HCM7ZC7Q.js} +1 -1
  21. package/dist/chunk-HMZUGSMU.cjs +1554 -0
  22. package/dist/{chunk-SAOBPYYJ.cjs → chunk-IQPXHQQQ.cjs} +8 -4
  23. package/dist/{chunk-P6TA5EZT.cjs → chunk-ISOIA7NV.cjs} +335 -58
  24. package/dist/chunk-JSC75O5C.cjs +167 -0
  25. package/dist/chunk-M272AHEX.js +25 -0
  26. package/dist/{chunk-BD7ZPG53.js → chunk-NWQ5WRLE.js} +10 -2
  27. package/dist/chunk-ODZ2IAR2.cjs +1247 -0
  28. package/dist/chunk-Q4MWQNJK.cjs +28 -0
  29. package/dist/{chunk-HWJZVOG7.js → chunk-SR7TR5KX.js} +6 -2
  30. package/dist/{chunk-FEW3JBYA.cjs → chunk-TCTE7DX5.cjs} +3 -3
  31. package/dist/{chunk-623FVQSN.cjs → chunk-TYF56RGB.cjs} +123 -0
  32. package/dist/chunk-VA4OFR72.cjs +324 -0
  33. package/dist/chunk-VU5S5A7V.js +150 -0
  34. package/dist/chunk-YEHR4NNE.js +1522 -0
  35. package/dist/{chunk-FMSW2HDF.cjs → chunk-ZCGKGDCL.cjs} +23 -15
  36. package/dist/codegen/index.d.cts +2 -2
  37. package/dist/codegen/index.d.ts +2 -2
  38. package/dist/collect-6NIEufHd.d.ts +103 -0
  39. package/dist/collect-CcTCKqx6.d.cts +103 -0
  40. package/dist/{file-BOoHZgoQ.d.cts → file-BxYpwjRQ.d.cts} +1007 -21
  41. package/dist/{file-yuPCFU5b.d.ts → file-CFdPQJI9.d.ts} +1007 -21
  42. package/dist/history/index.cjs +375 -86
  43. package/dist/history/index.d.cts +590 -12
  44. package/dist/history/index.d.ts +590 -12
  45. package/dist/history/index.js +50 -4
  46. package/dist/index.cjs +156 -50
  47. package/dist/index.d.cts +38 -58
  48. package/dist/index.d.ts +38 -58
  49. package/dist/index.js +6 -4
  50. package/dist/interceptors-CNcr2dlk.d.ts +159 -0
  51. package/dist/interceptors-CqkNZVfI.d.cts +159 -0
  52. package/dist/ir/index.cjs +362 -38
  53. package/dist/ir/index.d.cts +282 -7
  54. package/dist/ir/index.d.ts +282 -7
  55. package/dist/ir/index.js +329 -23
  56. package/dist/{lower-BzmUz0sq.d.cts → lower-BtRfIW2A.d.cts} +56 -8
  57. package/dist/{lower-_-iT4HYs.d.ts → lower-CpsMFOFX.d.ts} +56 -8
  58. package/dist/{manifest-C8N6HDYl.d.ts → manifest-D-I_twys.d.ts} +1 -1
  59. package/dist/{manifest-0OLw0i7k.d.cts → manifest-DahBQVM8.d.cts} +1 -1
  60. package/dist/node-evaluator-DGQDPSPI.cjs +24 -0
  61. package/dist/node-evaluator-LEEVD7H7.js +14 -0
  62. package/dist/payload-fields-BVRQn2yH.d.cts +122 -0
  63. package/dist/payload-fields-oOBWxDiG.d.ts +122 -0
  64. package/dist/quickjs/index.cjs +28 -27
  65. package/dist/quickjs/index.d.cts +6 -6
  66. package/dist/quickjs/index.d.ts +6 -6
  67. package/dist/quickjs/index.js +10 -9
  68. package/dist/roundtrip/index.cjs +259 -51
  69. package/dist/roundtrip/index.d.cts +100 -9
  70. package/dist/roundtrip/index.d.ts +100 -9
  71. package/dist/roundtrip/index.js +177 -11
  72. package/dist/runtime/index.cjs +21 -20
  73. package/dist/runtime/index.d.cts +184 -15
  74. package/dist/runtime/index.d.ts +184 -15
  75. package/dist/runtime/index.js +8 -7
  76. package/dist/testing/index.cjs +1122 -115
  77. package/dist/testing/index.d.cts +294 -13
  78. package/dist/testing/index.d.ts +294 -13
  79. package/dist/testing/index.js +1086 -84
  80. package/dist/{types-DV-HX_Gt.d.ts → types-Bv2i4cBX.d.cts} +244 -33
  81. package/dist/{types-CpBBjaGX.d.cts → types-DGx-b9eq.d.ts} +244 -33
  82. package/dist/{types-BGoPzgcl.d.ts → types-V7jEEUaL.d.cts} +20 -1
  83. package/dist/{types-BGoPzgcl.d.cts → types-V7jEEUaL.d.ts} +20 -1
  84. package/dist/{workflow-Bpr3vnA_.d.ts → workflow-B18OeF7g.d.ts} +2 -2
  85. package/dist/workflow-BGnv8SS6.d.ts +803 -0
  86. package/dist/{workflow-FXUkpIBc.d.cts → workflow-BJPFv3cp.d.cts} +2 -2
  87. package/dist/workflow-DS32Gtws.d.cts +803 -0
  88. package/fixtures/histories/activity-options-updated.history.json +159 -0
  89. package/fixtures/histories/activity-paused-unpaused.history.json +160 -0
  90. package/fixtures/histories/auto-upgrade-patched.history.json +276 -0
  91. package/fixtures/histories/benign-failure.history.json +146 -0
  92. package/fixtures/histories/cancel-activity-try-cancel.history.json +150 -0
  93. package/fixtures/histories/child-cancel-wait-requested.history.json +217 -0
  94. package/fixtures/histories/child-options-roundtrip.history.json +192 -0
  95. package/fixtures/histories/codec-opaque.history.json +229 -0
  96. package/fixtures/histories/continue-as-new-last-result.history.json +86 -0
  97. package/fixtures/histories/continue-as-new-options.history.json +99 -0
  98. package/fixtures/histories/continue-as-new-r1-long-task-queue.history.json +78 -0
  99. package/fixtures/histories/continue-as-new-r1-retry-options.history.json +83 -0
  100. package/fixtures/histories/dynamic-workflow.history.json +150 -0
  101. package/fixtures/histories/execution-timeout-chain.history.json +98 -0
  102. package/fixtures/histories/external-cancel-resolved.history.json +123 -0
  103. package/fixtures/histories/external-cancel-unknown-target.history.json +127 -0
  104. package/fixtures/histories/failure-error-types-fails-run.history.json +144 -0
  105. package/fixtures/histories/handler-drain-warn.history.json +222 -0
  106. package/fixtures/histories/heartbeat-details-on-retry.history.json +145 -0
  107. package/fixtures/histories/interceptor-headers.history.json +339 -0
  108. package/fixtures/histories/local-activity-abandoned-at-completion.history.json +73 -0
  109. package/fixtures/histories/local-activity-cancelled-in-scope.history.json +118 -0
  110. package/fixtures/histories/local-activity-completed.history.json +157 -0
  111. package/fixtures/histories/local-activity-failed.history.json +93 -0
  112. package/fixtures/histories/local-activity-retry-in-task.history.json +88 -0
  113. package/fixtures/histories/query-custom.history.json +213 -0
  114. package/fixtures/histories/query-default-handler.history.json +120 -0
  115. package/fixtures/histories/reset-forked-reapplied-signals.history.json +239 -0
  116. package/fixtures/histories/reset-reapplied-update-admitted.history.json +228 -0
  117. package/fixtures/histories/run-retry-last-failure.history.json +90 -0
  118. package/fixtures/histories/run-timeout.history.json +159 -0
  119. package/fixtures/histories/schedule-to-start-timeout.history.json +132 -0
  120. package/fixtures/histories/search-attributes-upserted.history.json +177 -0
  121. package/fixtures/histories/start-delay-signal-ends-delay.history.json +155 -0
  122. package/fixtures/histories/typeerror-task-retry-100.history.json +137 -0
  123. package/fixtures/histories/update-accepted-completed.history.json +45 -30
  124. package/fixtures/histories/update-default-handler.history.json +246 -0
  125. package/fixtures/histories/update-handler-awaits-activity.history.json +196 -0
  126. package/fixtures/histories/update-not-handled.history.json +138 -0
  127. package/fixtures/histories/update-rejected-no-event.history.json +190 -0
  128. package/fixtures/histories/update-with-start-admitted.history.json +150 -0
  129. package/fixtures/histories/user-activity-cancel.history.json +149 -0
  130. package/fixtures/histories/user-activity-retry.history.json +143 -0
  131. package/fixtures/histories/user-activity.history.json +149 -0
  132. package/package.json +1 -1
  133. package/schema/bridge-v2.schema.json +1062 -0
  134. package/schema/history-file.schema.json +538 -83
  135. package/schema/ir-v2.schema.json +290 -0
  136. package/schema/payload-fields.json +162 -0
  137. package/schema/run-event.schema.json +503 -82
  138. package/schema/workflow-command.schema.json +372 -69
  139. package/schema/workflow-task.schema.json +924 -171
  140. package/dist/assemble-BLqQ8lSu.d.cts +0 -39
  141. package/dist/assemble-DWgaXHd-.d.ts +0 -39
  142. package/dist/chunk-DHTLALBL.cjs +0 -80
  143. package/dist/chunk-DJYMDLV5.js +0 -227
  144. package/dist/chunk-I5LR3D2K.js +0 -869
  145. package/dist/chunk-M4BBAERY.cjs +0 -1635
  146. package/dist/chunk-N23SKIG4.js +0 -73
  147. package/dist/chunk-PZCVF76Q.cjs +0 -868
  148. package/dist/chunk-QQ6ULXHI.cjs +0 -885
  149. package/dist/chunk-UK3WM7YZ.cjs +0 -75
  150. package/dist/chunk-VOKMAAJP.js +0 -848
  151. package/dist/node-evaluator-4MSDKWOG.cjs +0 -22
  152. package/dist/node-evaluator-SX4LEYQC.js +0 -12
  153. package/dist/workflow-C2a05WUJ.d.ts +0 -444
  154. package/dist/workflow-J-yYixny.d.cts +0 -444
@@ -0,0 +1,803 @@
1
+ import { a as Json, J as JsonObject, b as WorkflowInterface } from './types-V7jEEUaL.js';
2
+ import { M as Headers, e as RetryPolicy, i as ActivityCancellationType, b as WorkflowInfoSnapshot, P as ParentClosePolicy, C as ChildCancellationType, at as VersioningBehavior, ay as WorkflowIdReusePolicy, ax as WorkflowIdConflictPolicy, f as RunRetryPolicy } from './types-DGx-b9eq.js';
3
+
4
+ /**
5
+ * Node operation descriptors: what a builder call needs to know about the node
6
+ * it emits. Generated clients (`.fluidgrids/nodes.ts`) are lists of these;
7
+ * the built-in internal nodes and triggers ship here so `nodes.internal.*` and
8
+ * `triggers.*` work without a registry.
9
+ */
10
+
11
+ /** A file reference in node inputs and outputs. */
12
+ interface FileRef {
13
+ fileId: string;
14
+ name?: string;
15
+ mimeType?: string;
16
+ size?: number;
17
+ }
18
+ declare const OPERATION_TYPES: unique symbol;
19
+ /** One node operation. `In` and `Out` type the arguments and the output. */
20
+ interface Operation<In = Record<string, Json>, Out = Json> {
21
+ readonly kind: 'operation';
22
+ readonly nodeType: string;
23
+ /** Written as the node's `version` unless the call overrides it. */
24
+ readonly version?: string;
25
+ /** Written as the node's `operation_name` unless the call overrides it. */
26
+ readonly operation?: string;
27
+ readonly role?: 'trigger';
28
+ /** Type-level only; never present at run time. */
29
+ readonly [OPERATION_TYPES]?: {
30
+ input: In;
31
+ output: Out;
32
+ };
33
+ }
34
+ /** A trigger operation. */
35
+ type TriggerOperation<In = Record<string, Json>, Out = Json> = Operation<In, Out> & {
36
+ readonly role: 'trigger';
37
+ };
38
+ /** Describe a node operation (generated clients call this). */
39
+ declare function op<In = Record<string, Json>, Out = Json>(nodeType: string, version?: string, operation?: string): Operation<In, Out>;
40
+ /** Describe a trigger operation (generated clients call this). */
41
+ declare function trigger<In = Record<string, Json>, Out = Json>(nodeType: string, version?: string, operation?: string): TriggerOperation<In, Out>;
42
+ /** True for a value made by {@link op} or {@link trigger}. */
43
+ declare function isOperation(value: unknown): value is Operation<unknown, unknown>;
44
+ /** Built-in trigger nodes (`wspace-workflow-svc` `triggers/manifests`). */
45
+ declare const triggers: {
46
+ readonly api: TriggerOperation<Record<string, Json>, Json>;
47
+ readonly manual: TriggerOperation<Record<string, Json>, Json>;
48
+ readonly schedule: TriggerOperation<Record<string, Json>, Json>;
49
+ readonly webhook: TriggerOperation<Record<string, Json>, Json>;
50
+ readonly form: TriggerOperation<Record<string, Json>, Json>;
51
+ readonly errorTrigger: TriggerOperation<Record<string, Json>, Json>;
52
+ readonly workflowCall: TriggerOperation<Record<string, Json>, Json>;
53
+ readonly rssFeed: TriggerOperation<Record<string, Json>, Json>;
54
+ readonly httpPoll: TriggerOperation<Record<string, Json>, Json>;
55
+ readonly databasePoll: TriggerOperation<Record<string, Json>, Json>;
56
+ readonly emailImap: TriggerOperation<Record<string, Json>, Json>;
57
+ readonly fileUpload: TriggerOperation<Record<string, Json>, Json>;
58
+ readonly recordChange: TriggerOperation<Record<string, Json>, Json>;
59
+ readonly stateChange: TriggerOperation<Record<string, Json>, Json>;
60
+ };
61
+ /** Built-in internal nodes (`wspace-workflow-svc` `internalnodes/manifests`, plus the two IR v2 nodes). */
62
+ declare const internalNodes: {
63
+ readonly merge: Operation<Record<string, Json>, Json>;
64
+ readonly if: Operation<Record<string, Json>, Json>;
65
+ readonly switch: Operation<Record<string, Json>, Json>;
66
+ readonly loop: Operation<Record<string, Json>, Json>;
67
+ readonly set: Operation<Record<string, Json>, Json>;
68
+ readonly filter: Operation<Record<string, Json>, Json>;
69
+ readonly aggregate: Operation<Record<string, Json>, Json>;
70
+ readonly wait: Operation<Record<string, Json>, Json>;
71
+ readonly noop: Operation<Record<string, Json>, Json>;
72
+ readonly code: Operation<Record<string, Json>, Json>;
73
+ readonly http: Operation<Record<string, Json>, Json>;
74
+ readonly transform: Operation<Record<string, Json>, Json>;
75
+ readonly validate: Operation<Record<string, Json>, Json>;
76
+ readonly log: Operation<Record<string, Json>, Json>;
77
+ readonly error: Operation<Record<string, Json>, Json>;
78
+ readonly subworkflow: Operation<Record<string, Json>, Json>;
79
+ readonly compareDatasets: Operation<Record<string, Json>, Json>;
80
+ readonly splitOut: Operation<Record<string, Json>, Json>;
81
+ readonly limit: Operation<Record<string, Json>, Json>;
82
+ readonly dedupe: Operation<Record<string, Json>, Json>;
83
+ readonly sort: Operation<Record<string, Json>, Json>;
84
+ readonly dataTable: Operation<Record<string, Json>, Json>;
85
+ readonly respondToWebhook: Operation<Record<string, Json>, Json>;
86
+ readonly sendAndWait: Operation<Record<string, Json>, Json>;
87
+ readonly codeWorkflow: Operation<Record<string, Json>, Json>;
88
+ readonly waitForSignal: Operation<Record<string, Json>, Json>;
89
+ /** Phase C: signal another run (`fluidgrids.run-control`). */
90
+ readonly signalRun: Operation<Record<string, Json>, Json>;
91
+ /** Phase C: upsert the run's search attributes (`fluidgrids.search-attributes`). */
92
+ readonly setSearchAttributes: Operation<Record<string, Json>, Json>;
93
+ };
94
+ /** Node clients that need no registry: the internal nodes and `custom()`. */
95
+ declare const nodes: {
96
+ readonly internal: {
97
+ readonly merge: Operation<Record<string, Json>, Json>;
98
+ readonly if: Operation<Record<string, Json>, Json>;
99
+ readonly switch: Operation<Record<string, Json>, Json>;
100
+ readonly loop: Operation<Record<string, Json>, Json>;
101
+ readonly set: Operation<Record<string, Json>, Json>;
102
+ readonly filter: Operation<Record<string, Json>, Json>;
103
+ readonly aggregate: Operation<Record<string, Json>, Json>;
104
+ readonly wait: Operation<Record<string, Json>, Json>;
105
+ readonly noop: Operation<Record<string, Json>, Json>;
106
+ readonly code: Operation<Record<string, Json>, Json>;
107
+ readonly http: Operation<Record<string, Json>, Json>;
108
+ readonly transform: Operation<Record<string, Json>, Json>;
109
+ readonly validate: Operation<Record<string, Json>, Json>;
110
+ readonly log: Operation<Record<string, Json>, Json>;
111
+ readonly error: Operation<Record<string, Json>, Json>;
112
+ readonly subworkflow: Operation<Record<string, Json>, Json>;
113
+ readonly compareDatasets: Operation<Record<string, Json>, Json>;
114
+ readonly splitOut: Operation<Record<string, Json>, Json>;
115
+ readonly limit: Operation<Record<string, Json>, Json>;
116
+ readonly dedupe: Operation<Record<string, Json>, Json>;
117
+ readonly sort: Operation<Record<string, Json>, Json>;
118
+ readonly dataTable: Operation<Record<string, Json>, Json>;
119
+ readonly respondToWebhook: Operation<Record<string, Json>, Json>;
120
+ readonly sendAndWait: Operation<Record<string, Json>, Json>;
121
+ readonly codeWorkflow: Operation<Record<string, Json>, Json>;
122
+ readonly waitForSignal: Operation<Record<string, Json>, Json>;
123
+ /** Phase C: signal another run (`fluidgrids.run-control`). */
124
+ readonly signalRun: Operation<Record<string, Json>, Json>;
125
+ /** Phase C: upsert the run's search attributes (`fluidgrids.search-attributes`). */
126
+ readonly setSearchAttributes: Operation<Record<string, Json>, Json>;
127
+ };
128
+ /**
129
+ * Any node type, including ones the registry snapshot does not know. Typed
130
+ * as JSON in and out.
131
+ */
132
+ readonly custom: (nodeType: string, operation?: string, version?: string) => Operation<Record<string, Json>, Json>;
133
+ };
134
+
135
+ /**
136
+ * User activities (Phase C, 11 §2.2, §2.29, CWD9): functions a self-hosted
137
+ * worker runs for workflow code.
138
+ *
139
+ * - {@link declareActivity} names an activity and its default task queue. The
140
+ * declaration is all workflow code needs: `ctx.activity(decl, { args })`
141
+ * issues `SCHEDULE_ACTIVITY` of kind `user`.
142
+ * - {@link implementActivity} attaches the function to a declaration, for the
143
+ * worker. {@link defineActivity} does both in one step.
144
+ * - {@link dynamicActivity} handles every activity name the worker has no
145
+ * implementation for.
146
+ *
147
+ * Implementations belong to the worker, not to the workflow bundle: `lower()`
148
+ * reports `durable.activityImplInBundle` when a workflow module pulls one in.
149
+ *
150
+ * Pure JavaScript; declarations run inside the isolate.
151
+ */
152
+
153
+ declare const ACTIVITY_MARKER = "fluidgrids.activity";
154
+ declare const ACTIVITY_IMPL_MARKER = "fluidgrids.activity-impl";
155
+ declare const ACTIVITY_TYPES: unique symbol;
156
+ /** The name `*` a dynamic activity is registered under. */
157
+ declare const DYNAMIC_ACTIVITY_NAME = "*";
158
+ interface ActivityDeclarationOptions {
159
+ /** The task queue the activity runs on unless the call names another; default the workflow's. */
160
+ taskQueue?: string;
161
+ input?: SchemaLike;
162
+ output?: SchemaLike;
163
+ description?: string;
164
+ }
165
+ /** A declared user activity. */
166
+ interface ActivityDefinition<In = Json, Out = Json> {
167
+ readonly __fluidgrids: typeof ACTIVITY_MARKER;
168
+ readonly name: string;
169
+ readonly options: ActivityDeclarationOptions;
170
+ /** Type-level only (functions, so any definition is assignable to the `never`/`unknown` one). */
171
+ readonly [ACTIVITY_TYPES]?: {
172
+ args: (args: In) => void;
173
+ result: () => Out;
174
+ };
175
+ }
176
+ /** What a running activity attempt knows. */
177
+ interface ActivityInfo {
178
+ readonly runId: string;
179
+ readonly workspaceId?: string;
180
+ readonly workflowKey?: string;
181
+ readonly activityId: string;
182
+ /** The activity name (for a dynamic activity, the requested one). */
183
+ readonly activityName: string;
184
+ readonly taskQueue: string;
185
+ /** 1-based. */
186
+ readonly attempt: number;
187
+ /** Details the previous attempt recorded with `heartbeat` (11 §2.4). */
188
+ readonly heartbeatDetails?: Json;
189
+ readonly headers: Headers;
190
+ }
191
+ /** The context an activity function receives. */
192
+ interface ActivityContext {
193
+ readonly info: ActivityInfo;
194
+ /**
195
+ * Record progress (at most 32 KiB of details, kept for the next attempt)
196
+ * and learn whether to stop. When the attempt was paused (`pauseActivity`,
197
+ * 11 §2.28) `paused` is true; the activity should then throw
198
+ * `ActivityPausedError`, which is not retried while the activity is paused.
199
+ */
200
+ heartbeat(details?: unknown): Promise<{
201
+ cancelRequested: boolean;
202
+ paused: boolean;
203
+ }>;
204
+ /** Aborted when the workflow requests cancellation or the worker shuts down. */
205
+ readonly cancellationSignal: AbortSignalLike;
206
+ /**
207
+ * Hand completion to an outside system (11 §2.2): returns a task token and
208
+ * ends this attempt without completing it. The outside system finishes it
209
+ * with `completeActivityAsync(token, result)` or the activity webhook.
210
+ */
211
+ completeAsync(): Promise<string>;
212
+ /** Credentials of a connection the activity declares (H2 rules apply on self-hosted workers). */
213
+ connection(name: string): Promise<Record<string, Json>>;
214
+ }
215
+ /** The part of `AbortSignal` activities may rely on. */
216
+ interface AbortSignalLike {
217
+ readonly aborted: boolean;
218
+ readonly reason?: unknown;
219
+ addEventListener(type: 'abort', listener: () => void): void;
220
+ removeEventListener(type: 'abort', listener: () => void): void;
221
+ }
222
+ type ActivityFunction<In = Json, Out = Json> = (ctx: ActivityContext, args: In) => Out | Promise<Out>;
223
+ /** A user activity's implementation, for a worker. */
224
+ interface ActivityImplementation<In = Json, Out = Json> extends ActivityDefinition<In, Out> {
225
+ readonly implementation: typeof ACTIVITY_IMPL_MARKER;
226
+ readonly fn: ActivityFunction<In, Out>;
227
+ /** True for {@link dynamicActivity}: `fn` receives `(ctx, args)` for any name. */
228
+ readonly dynamic: boolean;
229
+ }
230
+ /** Throw a `TypeError` unless `name` is a valid activity name. */
231
+ declare function checkActivityName(name: string): void;
232
+ /** Throw a `TypeError` unless `queue` is a valid task queue name. */
233
+ declare function checkTaskQueueName(queue: string, what?: string): void;
234
+ /** Declare a user activity for workflow code. */
235
+ declare function declareActivity<In = Json, Out = Json>(name: string, options?: ActivityDeclarationOptions): ActivityDefinition<In, Out>;
236
+ /** Attach the worker-side function to a declaration. */
237
+ declare function implementActivity<In, Out>(definition: ActivityDefinition<In, Out>, fn: ActivityFunction<In, Out>): ActivityImplementation<In, Out>;
238
+ /** Declare and implement a user activity in one step. */
239
+ declare function defineActivity<In = Json, Out = Json>(name: string, options: ActivityDeclarationOptions, fn: ActivityFunction<In, Out>): ActivityImplementation<In, Out>;
240
+ declare function defineActivity<In = Json, Out = Json>(name: string, fn: ActivityFunction<In, Out>): ActivityImplementation<In, Out>;
241
+ /**
242
+ * Handle every activity name the worker has no implementation for (11
243
+ * §2.29); `ctx.info.activityName` is the requested name.
244
+ */
245
+ declare function dynamicActivity<Out = Json>(fn: ActivityFunction<Json, Out>, options?: Pick<ActivityDeclarationOptions, 'taskQueue' | 'description'>): ActivityImplementation<Json, Out>;
246
+ /** True for a value made by {@link declareActivity} (or an implementation). */
247
+ declare function isActivityDefinition(value: unknown): value is ActivityDefinition<never, unknown>;
248
+ /** True for a value made by {@link implementActivity}, {@link defineActivity} or {@link dynamicActivity}. */
249
+ declare function isActivityImplementation(value: unknown): value is ActivityImplementation<never, unknown>;
250
+ /** An activity attempt is about to run its function. */
251
+ interface ActivityExecuteInput {
252
+ args: Json;
253
+ readonly headers: Headers;
254
+ readonly info: ActivityInfo;
255
+ }
256
+ /** Interceptors around an activity's execution, on the worker (11 §2.10). */
257
+ interface ActivityInboundInterceptor {
258
+ execute?(input: ActivityExecuteInput, next: (input: ActivityExecuteInput) => Promise<unknown>): Promise<unknown>;
259
+ }
260
+ /** Interceptors of what an activity issues, on the worker. */
261
+ interface ActivityOutboundInterceptor {
262
+ heartbeat?(details: unknown, next: (details: unknown) => Promise<unknown>): Promise<unknown>;
263
+ getLogAttributes?(input: Record<string, Json>, next: (input: Record<string, Json>) => Record<string, Json>): Record<string, Json>;
264
+ getMetricTags?(input: Record<string, string>, next: (input: Record<string, string>) => Record<string, string>): Record<string, string>;
265
+ }
266
+ /** The implementation that serves `name`: an exact one, else a dynamic one. */
267
+ declare function findActivityImplementation(implementations: readonly ActivityImplementation<never, unknown>[], name: string): ActivityImplementation<never, unknown> | undefined;
268
+ /**
269
+ * Run one activity attempt through the inbound interceptors (first
270
+ * outermost). Workers and the test environment use it.
271
+ */
272
+ declare function executeActivity(implementation: ActivityImplementation<never, unknown>, ctx: ActivityContext, args: Json, interceptors?: readonly ActivityInboundInterceptor[]): Promise<unknown>;
273
+
274
+ /**
275
+ * Signal, query and update definitions (spec 02 §4, 05). Signals work in Phase
276
+ * B; queries and updates can be declared (they appear in the interface) but
277
+ * custom handlers are Phase C.
278
+ */
279
+ declare const PAYLOAD: unique symbol;
280
+ interface SignalDefinition<Payload = unknown> {
281
+ readonly kind: 'signal';
282
+ readonly name: string;
283
+ readonly description?: string;
284
+ /** JSON Schema of the payload, written into the workflow interface. */
285
+ readonly schema?: Record<string, unknown>;
286
+ /** Type-level only. */
287
+ readonly [PAYLOAD]?: Payload;
288
+ }
289
+ interface QueryDefinition<Result = unknown, Args = unknown> {
290
+ readonly kind: 'query';
291
+ readonly name: string;
292
+ readonly description?: string;
293
+ readonly [PAYLOAD]?: {
294
+ result: Result;
295
+ args: Args;
296
+ };
297
+ }
298
+ interface UpdateDefinition<Args = unknown, Result = unknown> {
299
+ readonly kind: 'update';
300
+ readonly name: string;
301
+ readonly description?: string;
302
+ readonly [PAYLOAD]?: {
303
+ result: Result;
304
+ args: Args;
305
+ };
306
+ }
307
+ interface DefinitionOptions {
308
+ description?: string;
309
+ schema?: Record<string, unknown>;
310
+ }
311
+ /** Declare a signal. */
312
+ declare function defineSignal<Payload = unknown>(name: string, options?: DefinitionOptions): SignalDefinition<Payload>;
313
+ /** Declare a query. Handlers are Phase C; the declaration appears in the interface. */
314
+ declare function defineQuery<Result = unknown, Args = unknown>(name: string, options?: {
315
+ description?: string;
316
+ }): QueryDefinition<Result, Args>;
317
+ /** Declare an update. Handlers are Phase C; the declaration appears in the interface. */
318
+ declare function defineUpdate<Args = unknown, Result = unknown>(name: string, options?: {
319
+ description?: string;
320
+ }): UpdateDefinition<Args, Result>;
321
+
322
+ /** A duration: milliseconds, or a string such as `'30s'` or `'PT2H'`. */
323
+ type Duration = number | string;
324
+ /** Milliseconds of `value`; throws a `TypeError` naming `what` when it is not a duration. */
325
+ declare function toMs(value: Duration, what?: string): number;
326
+
327
+ /**
328
+ * The `WorkflowContext` a tier-2 workflow function receives (spec 02 §4). The
329
+ * runtime (`src/runtime/`) implements it; this module is types only.
330
+ */
331
+
332
+ /** Options of `ctx.run`. */
333
+ interface RunOptions<In> {
334
+ args: In;
335
+ /** Connection name, resolved by the service at `SCHEDULE_ACTIVITY`. */
336
+ connection?: string;
337
+ /** Default: 1 s, x2, at most 100 s, unlimited attempts (Temporal's policy). */
338
+ retry?: Partial<RetryPolicy>;
339
+ startToCloseTimeout?: Duration;
340
+ scheduleToCloseTimeout?: Duration;
341
+ scheduleToStartTimeout?: Duration;
342
+ heartbeatTimeout?: Duration;
343
+ cancellationType?: ActivityCancellationType;
344
+ /** 1 (highest) to 5; default 3. */
345
+ priority?: number;
346
+ /** Label in the History tab (at most 200 characters). */
347
+ summary?: string;
348
+ runOn?: string;
349
+ /** Overrides the operation name the descriptor carries. */
350
+ operation?: string;
351
+ /** Overrides the node version the descriptor carries. */
352
+ nodeVersion?: string;
353
+ headers?: Headers;
354
+ /** Fairness within the queue (11 §2.11); default the workspace id. */
355
+ fairnessKey?: string;
356
+ /** 0.1 to 10; default 1. */
357
+ fairnessWeight?: number;
358
+ }
359
+ /**
360
+ * Options of `ctx.activity` (Phase C, user activities). The task queue is
361
+ * the option, else the declaration's, else the workflow's own queue.
362
+ */
363
+ interface ActivityOptions<In> {
364
+ args: In;
365
+ taskQueue?: string;
366
+ /** Default: 1 s, x2, at most 100 s, unlimited attempts (Temporal's policy). */
367
+ retry?: Partial<RetryPolicy>;
368
+ startToCloseTimeout?: Duration;
369
+ scheduleToCloseTimeout?: Duration;
370
+ scheduleToStartTimeout?: Duration;
371
+ heartbeatTimeout?: Duration;
372
+ cancellationType?: ActivityCancellationType;
373
+ /** 1 (highest) to 5; default 3. */
374
+ priority?: number;
375
+ fairnessKey?: string;
376
+ fairnessWeight?: number;
377
+ /** Label in the History tab (at most 200 characters). */
378
+ summary?: string;
379
+ /** Connections the worker may resolve for this activity (at most 16, H2). */
380
+ connections?: string[];
381
+ headers?: Headers;
382
+ }
383
+ /** Options of `ctx.handleUpdate` and `ctx.setDefaultUpdateHandler` (05 §6, 11 §2.39). */
384
+ interface UpdateHandlerOptions<Args> {
385
+ /**
386
+ * Runs before the update is accepted, without changing the run; throw to
387
+ * reject it (nothing is written to history and the caller gets the error).
388
+ * It is skipped when a replay re-delivers an update that history accepted.
389
+ */
390
+ validate?: (args: Args) => void;
391
+ /** Default `WARN_AND_ABANDON`. */
392
+ unfinishedPolicy?: HandlerUnfinishedPolicy;
393
+ description?: string;
394
+ }
395
+ /** Options of `ctx.setDefaultUpdateHandler`. */
396
+ interface DefaultUpdateHandlerOptions {
397
+ validate?: (name: string, args: unknown) => void;
398
+ unfinishedPolicy?: HandlerUnfinishedPolicy;
399
+ }
400
+ /**
401
+ * Fire-and-forget calls to worker-side code (11 §2.31, self-hosted workers):
402
+ * `ctx.sinks.<sink>.<fn>(...args)`. Calls are reported once, when the task
403
+ * completes, never during replay or in a query. Managed runs ignore them.
404
+ */
405
+ type WorkflowSinks = Readonly<Record<string, Readonly<Record<string, (...args: Json[]) => void>>>>;
406
+ /** Options of `ctx.localActivity` (11 §2.12). */
407
+ interface LocalActivityOptions<In> {
408
+ args: In;
409
+ /** Connection name, resolved by the worker that runs the task. */
410
+ connection?: string;
411
+ /** Default: 1 s, x2, at most 100 s, unlimited attempts, bounded by the task's 30 s budget. */
412
+ retry?: Partial<RetryPolicy>;
413
+ /** At most 30 s (the default). */
414
+ startToCloseTimeout?: Duration;
415
+ /** Label in the History tab (at most 200 characters). */
416
+ summary?: string;
417
+ /** Overrides the operation name the descriptor carries. */
418
+ operation?: string;
419
+ /** Overrides the node version the descriptor carries. */
420
+ nodeVersion?: string;
421
+ }
422
+ /**
423
+ * Run-level retry of a workflow (11 §2.17): a run that fails with a retryable
424
+ * failure, or whose run timeout expires, starts again as a new run of the same
425
+ * chain with `ctx.info.attempt + 1` and `ctx.info.lastFailure`.
426
+ */
427
+ interface WorkflowRetryOptions {
428
+ /** Attempts in total, the first one included; absent means unlimited (bounded by the execution timeout). */
429
+ maxAttempts?: number;
430
+ /** Delay before the second attempt; default 1 s. */
431
+ initialDelay?: Duration;
432
+ /** Default 2. */
433
+ backoffMultiplier?: number;
434
+ /** Largest delay; default 100 s, or 100 times `initialDelay` when that is given. */
435
+ maxDelay?: Duration;
436
+ /** Free-form failure types that are never retried. */
437
+ nonRetryableErrorTypes?: string[];
438
+ }
439
+ /** A run addressed by its workflow id (11 §2.1): the open run of the chain. */
440
+ interface WorkflowIdTarget {
441
+ workflowKey: string;
442
+ workflowId: string;
443
+ /** Pins the chain whose first run this is. */
444
+ firstRunId?: string;
445
+ }
446
+ /** Another run of the workspace: a run id or a workflow id. */
447
+ type ExternalRunTarget = string | {
448
+ runId: string;
449
+ } | WorkflowIdTarget;
450
+ /** What happens to a handler still running when the workflow finishes (11 §2.18). */
451
+ type HandlerUnfinishedPolicy = 'WARN_AND_ABANDON' | 'ABANDON';
452
+ /** Options of `ctx.onSignal`. */
453
+ interface SignalHandlerOptions {
454
+ /** Default `WARN_AND_ABANDON`: a warning when the workflow finishes while this handler runs. */
455
+ unfinishedPolicy?: HandlerUnfinishedPolicy;
456
+ }
457
+ /** Options of `ctx.child` and `ctx.startChild` (11 §2.35). */
458
+ interface ChildOptions {
459
+ input?: unknown;
460
+ /** `active` (default), `vN` or `@alias`. */
461
+ version?: string;
462
+ taskQueue?: string;
463
+ /** Default `TERMINATE` for `ctx.child`, `ABANDON` for `ctx.startChild` (DB13). */
464
+ parentClosePolicy?: ParentClosePolicy;
465
+ /**
466
+ * How the awaitable reacts when its scope is cancelled. Unset, it rejects at
467
+ * once and the child is left to the parent-close policy; set, the SDK sends
468
+ * a cancel request to the child (`REQUEST_CANCEL_EXTERNAL_RUN`, a parity
469
+ * command).
470
+ */
471
+ cancellationType?: ChildCancellationType;
472
+ workflowId?: string;
473
+ priority?: number;
474
+ summary?: string;
475
+ details?: string;
476
+ context?: JsonObject;
477
+ startDelay?: Duration;
478
+ executionTimeout?: Duration;
479
+ runTimeout?: Duration;
480
+ workflowTaskTimeout?: Duration;
481
+ /** Run-level retry of the child. */
482
+ retry?: WorkflowRetryOptions;
483
+ versioningBehavior?: VersioningBehavior;
484
+ idReusePolicy?: WorkflowIdReusePolicy;
485
+ idConflictPolicy?: WorkflowIdConflictPolicy;
486
+ headers?: Headers;
487
+ /** Fairness of the child's tasks (11 §2.11). */
488
+ fairnessKey?: string;
489
+ fairnessWeight?: number;
490
+ }
491
+ /** A started child run. */
492
+ interface ChildHandle<Out = Json> {
493
+ readonly childId: string;
494
+ readonly runId: string;
495
+ result(): Promise<Out>;
496
+ signal<P>(signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
497
+ /** Request cancellation of the child (parity command `REQUEST_CANCEL_EXTERNAL_RUN`). */
498
+ cancel(): Promise<void>;
499
+ }
500
+ /** A handle to another run of the workspace (11 §2.24). */
501
+ interface ExternalRunHandle {
502
+ /** The run id of a run-id target; empty for a workflow-id target. */
503
+ readonly runId: string;
504
+ /** The workflow key and id of a workflow-id target. */
505
+ readonly workflowKey?: string;
506
+ readonly workflowId?: string;
507
+ signal<P>(signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
508
+ /** Resolves when the cancel request was delivered, not when the run ends. */
509
+ cancel(): Promise<void>;
510
+ }
511
+ /** A cancellation scope (11 §2.24). */
512
+ interface CancellationScope {
513
+ /** Rejects with `CancelledFailure` when the scope is cancelled. */
514
+ readonly cancelRequested: Promise<never>;
515
+ readonly consideredCancelled: boolean;
516
+ cancel(): void;
517
+ }
518
+ interface CancellationScopeOptions {
519
+ /** A durable timer that cancels the scope when it fires. */
520
+ timeout?: Duration;
521
+ nonCancellable?: boolean;
522
+ }
523
+ /** `ctx.cancellationScope(fn, options)` and `ctx.cancellationScope.current()`. */
524
+ interface CancellationScopeFunction {
525
+ <T>(fn: (ctx: WorkflowContext) => Promise<T>, options?: CancellationScopeOptions): Promise<T>;
526
+ current(): CancellationScope;
527
+ }
528
+ /** What workflow code knows about its run. */
529
+ interface WorkflowInfo extends WorkflowInfoSnapshot {
530
+ readonly workflowFn: string;
531
+ /** Events in the history when the current workflow task started. */
532
+ readonly historyLength: number;
533
+ /** UTF-8 bytes of their payloads. */
534
+ readonly historyBytes: number;
535
+ /** True from 80 % of the history cap; continue as new soon. */
536
+ readonly continueAsNewSuggested: boolean;
537
+ readonly isReplaying: boolean;
538
+ }
539
+ /** Logging from workflow code; lines are emitted once, never during replay. */
540
+ interface WorkflowLogger {
541
+ debug(message: string, data?: Json): void;
542
+ info(message: string, data?: Json): void;
543
+ warn(message: string, data?: Json): void;
544
+ error(message: string, data?: Json): void;
545
+ }
546
+ /**
547
+ * Compensations run in reverse order, each in its own non-cancellable scope,
548
+ * so they still run after a cancel request. A compensation receives that
549
+ * scope's `ctx`; use it for every call after the compensation's first await.
550
+ */
551
+ interface Saga {
552
+ add(compensation: (ctx: WorkflowContext) => unknown): void;
553
+ compensate(): Promise<void>;
554
+ }
555
+ /** Options of `ctx.continueAsNew`; each defaults to the current run's value (11 §2.20). */
556
+ /**
557
+ * The R1 continue-as-new retry option: the activity retry shape. R1 wrote it
558
+ * into `CONTINUE_AS_NEW` unchanged and the Phase B service ignored it.
559
+ *
560
+ * @deprecated Since R2; give a run-level {@link WorkflowRetryOptions}.
561
+ */
562
+ type LegacyContinueAsNewRetry = Partial<RetryPolicy>;
563
+ interface ContinueAsNewOptions {
564
+ taskQueue?: string;
565
+ /**
566
+ * The run-level retry policy of the new run. The R1 activity shape
567
+ * (`retryDelay`, `maxRetries`) is still accepted and written as R1 wrote it;
568
+ * it has no effect, as in Phase B.
569
+ */
570
+ retry?: WorkflowRetryOptions | LegacyContinueAsNewRetry;
571
+ workflowTaskTimeout?: Duration;
572
+ /** The new run's memo. */
573
+ context?: JsonObject;
574
+ versioningBehavior?: VersioningBehavior;
575
+ }
576
+ /** A child target: a workflow key (graph or durable) or a tier-2 function of the same bundle. */
577
+ type ChildTarget<Out> = string | DurableWorkflow<never, Out> | DurableWorkflow<Json, Out>;
578
+ /** The context of a tier-2 workflow function. */
579
+ interface WorkflowContext {
580
+ readonly info: WorkflowInfo;
581
+ readonly log: WorkflowLogger;
582
+ /** Run a canvas node operation as a durable activity (`SCHEDULE_ACTIVITY`, kind `node`). */
583
+ run<In, Out>(operation: Operation<In, Out>, options: RunOptions<In>): Promise<Out>;
584
+ /** A durable timer. */
585
+ sleep(duration: Duration, options?: {
586
+ summary?: string;
587
+ }): Promise<void>;
588
+ /** Resolves `true` once `predicate` holds after an event, or `false` when `timeout` passes first. */
589
+ condition(predicate: () => boolean, timeout?: Duration): Promise<boolean>;
590
+ /** The next signal of this name (buffered signals first). */
591
+ signalReceived<P>(signal: SignalDefinition<P> | string): Promise<P>;
592
+ /** Handle every signal of this name, buffered ones first. */
593
+ onSignal<P>(signal: SignalDefinition<P> | string, handler: (payload: P) => unknown): void;
594
+ onSignal<P>(signal: SignalDefinition<P> | string, options: SignalHandlerOptions, handler: (payload: P) => unknown): void;
595
+ /** Handle signals no other handler or waiter takes. */
596
+ setDefaultSignalHandler(handler: (name: string, payload: unknown) => unknown): void;
597
+ /** Start a child run and wait for its result. */
598
+ child<Out = Json>(target: ChildTarget<Out>, options?: ChildOptions): Promise<Out>;
599
+ /** Start a child run; resolves once it has started. */
600
+ startChild<Out = Json>(target: ChildTarget<Out>, options?: ChildOptions): Promise<ChildHandle<Out>>;
601
+ /** Signal another run of the workspace (by run id or workflow id); resolves on delivery. */
602
+ signalRun<P>(target: ExternalRunTarget, signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
603
+ /** Signal the parent run. */
604
+ signalParent<P>(signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
605
+ getRunHandle(target: ExternalRunTarget): ExternalRunHandle;
606
+ /** Shorthand for `getRunHandle(target).cancel()`. */
607
+ cancelRun(target: ExternalRunTarget): Promise<void>;
608
+ /** The workflow clock (the task's start time), in epoch milliseconds. */
609
+ now(): number;
610
+ /** A deterministic random number in [0, 1), seeded per run. */
611
+ random(): number;
612
+ /** A deterministic version-4 UUID. */
613
+ uuid(): string;
614
+ /** Record a value once (`RECORD_SIDE_EFFECT`); replays return the recorded value. */
615
+ sideEffect<T extends Json>(fn: () => T): T;
616
+ /** In-place versioning (spec 06 §4). */
617
+ patched(patchId: string): boolean;
618
+ deprecatePatch(patchId: string): void;
619
+ /** Live Markdown status for the run page and `__metadata` (at most 20 KiB). */
620
+ setCurrentDetails(markdown: string): void;
621
+ /** Merge keys into the run's context (parity command `UPSERT_CONTEXT`). */
622
+ upsertContext(entries: JsonObject): void;
623
+ /** End this run and start a fresh history (parity command `CONTINUE_AS_NEW`). */
624
+ continueAsNew(input: unknown, options?: ContinueAsNewOptions): Promise<never>;
625
+ /**
626
+ * Run `fn` in a new cancellation scope. `fn` gets a `ctx` bound to the
627
+ * scope: use it inside `fn`. This outer `ctx` joins the scope only while
628
+ * `fn` runs synchronously; after an await it is back in its own scope, so
629
+ * concurrent branches never share a scope by accident.
630
+ */
631
+ readonly cancellationScope: CancellationScopeFunction;
632
+ /** `cancellationScope(fn, { nonCancellable: true })`; the same `ctx` rule applies. */
633
+ nonCancellable<T>(fn: (ctx: WorkflowContext) => Promise<T>): Promise<T>;
634
+ /**
635
+ * Run `fn` when the current scope is cancelled. An error thrown by `fn` is
636
+ * handled like an error thrown by the workflow; the other handlers still run.
637
+ */
638
+ onCancel(fn: () => void): void;
639
+ isCancellation(error: unknown): boolean;
640
+ saga(): Saga;
641
+ /** Resolves when no asynchronous signal or update handler is running; cancellation does not interrupt the wait. */
642
+ allHandlersFinished(): Promise<void>;
643
+ /**
644
+ * Run a user activity on a self-hosted worker (Phase C,
645
+ * `SCHEDULE_ACTIVITY` of kind `user`). Needs `fluidgrids.self-hosted-workers`;
646
+ * the `managed` queue refuses user activities.
647
+ */
648
+ activity<In, Out>(activity: ActivityDefinition<In, Out> | string, options: ActivityOptions<In>): Promise<Out>;
649
+ /**
650
+ * Run a short, idempotent node operation inside the workflow task (11
651
+ * §2.12): the worker that runs the task executes it and the task records one
652
+ * `LOCAL_ACTIVITY_COMPLETED` or `LOCAL_ACTIVITY_FAILED` marker
653
+ * (`RECORD_LOCAL_ACTIVITY`). Replays return the recorded outcome and never
654
+ * run it again. The activity allow-list of `ctx.run` applies; a user
655
+ * function instead of a node operation is Phase C and throws
656
+ * `PhaseCFeatureError`.
657
+ */
658
+ localActivity<In, Out>(operation: Operation<In, Out>, options: LocalActivityOptions<In>): Promise<Out>;
659
+ localActivity(fn: (...args: never[]) => unknown, options?: unknown): Promise<never>;
660
+ /**
661
+ * Answer a custom query (Phase C): `handler` runs after the history is
662
+ * replayed and must return a value without changing the run (commands and
663
+ * sinks throw `QueryHandlerSideEffect`).
664
+ */
665
+ handleQuery<Result, Args>(query: QueryDefinition<Result, Args> | string, handler: (args: Args) => Result): void;
666
+ /** Answer queries no handler takes (Phase C). */
667
+ setDefaultQueryHandler(handler: (name: string, args: unknown) => unknown): void;
668
+ /**
669
+ * Handle an update (Phase C, 05 §6): `validate` may reject it (no history),
670
+ * the handler's result or failure completes it (`UPDATE_COMPLETED`). The
671
+ * handler may await activities, timers and children.
672
+ */
673
+ handleUpdate<Args, Result>(update: UpdateDefinition<Args, Result> | string, handler: (args: Args) => Result | Promise<Result>, options?: UpdateHandlerOptions<Args>): void;
674
+ /** Handle updates no handler takes (Phase C, 11 §2.29). */
675
+ setDefaultUpdateHandler(handler: (name: string, args: unknown) => unknown, options?: DefaultUpdateHandlerOptions): void;
676
+ setDefaultUpdateHandler(options: DefaultUpdateHandlerOptions, handler: (name: string, args: unknown) => unknown): void;
677
+ /**
678
+ * Upsert the run's search attributes (Phase C, 11 §2.8,
679
+ * `UPSERT_SEARCH_ATTRIBUTES`); a null value removes one. The service
680
+ * validates the values against the workspace definitions.
681
+ */
682
+ upsertSearchAttributes(attributes: JsonObject): void;
683
+ /** Worker-side sinks (Phase C, self-hosted workers). */
684
+ readonly sinks: WorkflowSinks;
685
+ }
686
+
687
+ /**
688
+ * `workflow()`: declare a tier-2 durable workflow function (spec 02 §4).
689
+ *
690
+ * The value is inert data plus the function: nothing runs at module load.
691
+ * `lower()` reads it to report `code.exports.workflows[exportName]`, and the
692
+ * runtime (`src/runtime/`) calls the function by export name inside a
693
+ * workflow task.
694
+ */
695
+
696
+ declare const DURABLE_MARKER = "fluidgrids.durable-workflow";
697
+ /**
698
+ * A payload schema: a JSON Schema object, or a schema library value with a
699
+ * `toJSONSchema()` method. Anything else (a zod schema without one, for
700
+ * example) types the code but leaves the interface without that schema.
701
+ */
702
+ type SchemaLike = Record<string, unknown> | {
703
+ toJSONSchema(): unknown;
704
+ };
705
+ /** How a standalone tier-2 workflow starts (lowered to its trigger node). */
706
+ type TriggerSpec = Operation<never, unknown> | Operation<Record<string, Json>, Json> | {
707
+ operation: Operation<never, unknown> | Operation<Record<string, Json>, Json>;
708
+ args?: JsonObject;
709
+ id?: string;
710
+ };
711
+ interface DurableWorkflowOptions {
712
+ /** Display name of the standalone workflow. */
713
+ title?: string;
714
+ description?: string;
715
+ input?: SchemaLike;
716
+ output?: SchemaLike;
717
+ signals?: ReadonlyArray<SignalDefinition<never> | SignalDefinition<unknown>>;
718
+ /** Declared queries; `ctx.handleQuery` answers them (Phase C). */
719
+ queries?: ReadonlyArray<QueryDefinition<unknown, unknown>>;
720
+ /** Declared updates; `ctx.handleUpdate` handles them (Phase C). */
721
+ updates?: ReadonlyArray<UpdateDefinition<unknown, unknown>>;
722
+ /**
723
+ * Accept names the interface does not declare (11 §2.29), written as
724
+ * `interface.open`. `lower()` also sets a kind open when the declaring
725
+ * module registers a default handler for it.
726
+ */
727
+ open?: {
728
+ signals?: boolean;
729
+ queries?: boolean;
730
+ updates?: boolean;
731
+ };
732
+ /** Default `managed`. */
733
+ taskQueue?: string;
734
+ /** Lowers to the trigger node of the standalone workflow (default `internal:api`). */
735
+ trigger?: TriggerSpec;
736
+ /**
737
+ * Whether the function is a workflow of its own (07 §4): by default, when it
738
+ * declares a trigger or nothing in the project embeds it with `wf.codeWorkflow`.
739
+ */
740
+ standalone?: boolean;
741
+ /** Error classes that fail the run instead of the workflow task (11 §2.25). */
742
+ failureErrorTypes?: ReadonlyArray<abstract new (...args: never[]) => Error>;
743
+ /** `PINNED` (default) or `AUTO_UPGRADE` (11 §2.27); lowered to `config.versioningBehavior`. */
744
+ versioningBehavior?: VersioningBehavior;
745
+ /** Run-level retry (11 §2.17); lowered to `config.retry`. */
746
+ retry?: WorkflowRetryOptions;
747
+ /** Bounds the whole continue-as-new and retry chain (11 §2.20); `config.executionTimeout`. */
748
+ executionTimeout?: Duration;
749
+ /** Bounds one run; `config.timeout`. */
750
+ runTimeout?: Duration;
751
+ /** The replay budget of one workflow task, at most 120 s; `config.workflowTaskTimeout`. */
752
+ workflowTaskTimeout?: Duration;
753
+ }
754
+ /** The largest `workflowTaskTimeout` (11 §2.20). */
755
+ declare const MAX_WORKFLOW_TASK_TIMEOUT_MS = 120000;
756
+ /** A declared tier-2 workflow. */
757
+ interface DurableWorkflow<In = Json, Out = Json> {
758
+ readonly __fluidgrids: typeof DURABLE_MARKER;
759
+ /** The workflow key it gets when it is standalone. */
760
+ readonly name: string;
761
+ readonly options: DurableWorkflowOptions;
762
+ readonly fn: (ctx: WorkflowContext, input: In) => Promise<Out>;
763
+ /**
764
+ * True for {@link dynamicWorkflow}: it serves every function name the
765
+ * bundle does not export (`code.exports.workflows["*"]`, 11 §2.29).
766
+ */
767
+ readonly dynamic?: boolean;
768
+ }
769
+ /** Declare a tier-2 workflow. `name` is its workflow key when it is standalone. */
770
+ declare function workflow<In = Json, Out = Json>(name: string, options: DurableWorkflowOptions, fn: (ctx: WorkflowContext, input: In) => Promise<Out>): DurableWorkflow<In, Out>;
771
+ declare function workflow<In = Json, Out = Json>(name: string, fn: (ctx: WorkflowContext, input: In) => Promise<Out>): DurableWorkflow<In, Out>;
772
+ /**
773
+ * Declare a dynamic workflow (Phase C, 11 §2.29): it runs for every
774
+ * `workflowFn` the bundle does not export, and receives the requested name.
775
+ * `lower()` writes it to `code.exports.workflows["*"]`, so a start or a child
776
+ * naming any function of the workflow key reaches it. One per bundle.
777
+ */
778
+ declare function dynamicWorkflow<Out = Json>(name: string, options: DurableWorkflowOptions, fn: (ctx: WorkflowContext, workflowFn: string, input: Json) => Promise<Out>): DurableWorkflow<Json, Out>;
779
+ declare function dynamicWorkflow<Out = Json>(name: string, fn: (ctx: WorkflowContext, workflowFn: string, input: Json) => Promise<Out>): DurableWorkflow<Json, Out>;
780
+ /** True for a value made by {@link workflow}. */
781
+ declare function isDurableWorkflow(value: unknown): value is DurableWorkflow<never, unknown>;
782
+ /** The JSON Schema of a {@link SchemaLike}, or undefined when it has none. */
783
+ declare function jsonSchemaOf(schema: SchemaLike | undefined): JsonObject | undefined;
784
+ /** The workflow `interface` (spec 01 §4) a tier-2 declaration describes. */
785
+ declare function interfaceOf(definition: DurableWorkflow<never, unknown>): WorkflowInterface;
786
+ /** The history form (milliseconds, defaults filled in) of a run-level retry option. */
787
+ declare function runRetryPolicyOf(retry: WorkflowRetryOptions): RunRetryPolicy;
788
+ /**
789
+ * The `CONTINUE_AS_NEW` `options.retry` of a `ctx.continueAsNew` retry option
790
+ * (C-SCHEMA `canOptions`).
791
+ *
792
+ * - An option with an activity-only key (`retryDelay`, `maxRetries`,
793
+ * `retryOnErrorTypes`) is the R1 shape. It is written exactly as R1 wrote it
794
+ * (activity form, defaults filled in), so an R1 workflow issues the same
795
+ * command and keeps its Phase B behaviour: the service ignores that shape.
796
+ * - Anything else is a run-level retry policy (R2), checked for unknown keys.
797
+ * Keys both shapes share (`maxDelay`, `backoffMultiplier`,
798
+ * `nonRetryableErrorTypes`) alone mean the R2 shape.
799
+ * - Mixing an activity-only key with `maxAttempts` or `initialDelay` throws.
800
+ */
801
+ declare function continueAsNewRetryOf(retry: WorkflowRetryOptions | LegacyContinueAsNewRetry): RunRetryPolicy | RetryPolicy;
802
+
803
+ export { continueAsNewRetryOf as $, ACTIVITY_IMPL_MARKER as A, type SchemaLike as B, type CancellationScope as C, DURABLE_MARKER as D, type ExternalRunHandle as E, type FileRef as F, type SignalDefinition as G, type HandlerUnfinishedPolicy as H, type SignalHandlerOptions as I, type TriggerSpec as J, type UpdateHandlerOptions as K, type LegacyContinueAsNewRetry as L, MAX_WORKFLOW_TASK_TIMEOUT_MS as M, type WorkflowIdTarget as N, type Operation as O, type WorkflowInfo as P, type QueryDefinition as Q, type RunOptions as R, type Saga as S, type TriggerOperation as T, type UpdateDefinition as U, type WorkflowLogger as V, type WorkflowContext as W, type WorkflowRetryOptions as X, type WorkflowSinks as Y, checkActivityName as Z, checkTaskQueueName as _, ACTIVITY_MARKER as a, declareActivity as a0, defineActivity as a1, defineQuery as a2, defineSignal as a3, defineUpdate as a4, dynamicActivity as a5, dynamicWorkflow as a6, executeActivity as a7, findActivityImplementation as a8, implementActivity as a9, interfaceOf as aa, internalNodes as ab, isActivityDefinition as ac, isActivityImplementation as ad, isDurableWorkflow as ae, isOperation as af, jsonSchemaOf as ag, nodes as ah, op as ai, runRetryPolicyOf as aj, toMs as ak, trigger as al, triggers as am, workflow as an, type AbortSignalLike as b, type ActivityContext as c, type ActivityDeclarationOptions as d, type ActivityDefinition as e, type ActivityExecuteInput as f, type ActivityFunction as g, type ActivityImplementation as h, type ActivityInboundInterceptor as i, type ActivityInfo as j, type ActivityOptions as k, type ActivityOutboundInterceptor as l, type CancellationScopeFunction as m, type CancellationScopeOptions as n, type ChildHandle as o, type ChildOptions as p, type ChildTarget as q, type ContinueAsNewOptions as r, DYNAMIC_ACTIVITY_NAME as s, type DefaultUpdateHandlerOptions as t, type DefinitionOptions as u, type DurableWorkflow as v, type DurableWorkflowOptions as w, type Duration as x, type ExternalRunTarget as y, type LocalActivityOptions as z };