@upstash/workflow 0.2.16 → 0.2.18

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.
@@ -620,7 +620,7 @@ type MultiAgentTaskParams = TaskParams & {
620
620
  background?: string;
621
621
  };
622
622
  type ModelParams = Parameters<ReturnType<typeof createOpenAI>>;
623
- type AgentCallParams = Pick<CallSettings, "flowControl" | "retries" | "timeout">;
623
+ type AgentCallParams = Pick<CallSettings, "flowControl" | "retries" | "timeout" | "retryDelay">;
624
624
  type CustomModelSettings = ModelParams["1"] & {
625
625
  baseURL?: string;
626
626
  apiKey?: string;
@@ -747,9 +747,7 @@ declare class WorkflowAgents {
747
747
  context: WorkflowContext;
748
748
  provider: TProvider;
749
749
  providerParams?: Omit<Required<Parameters<TProvider>>[0], "fetch">;
750
- agentCallParams? /**
751
- * creates an openai model for agents
752
- */: AgentCallParams;
750
+ agentCallParams?: AgentCallParams;
753
751
  }) => ReturnType<TProvider>;
754
752
  }
755
753
 
@@ -879,12 +877,59 @@ declare class WorkflowContext<TInitialPayload = unknown> {
879
877
  * Number of retries
880
878
  */
881
879
  readonly retries: number;
880
+ /**
881
+ * Delay between retries.
882
+ *
883
+ * By default, the `retryDelay` is exponential backoff.
884
+ * More details can be found in: https://upstash.com/docs/qstash/features/retry.
885
+ *
886
+ * The `retryDelay` option allows you to customize the delay (in milliseconds) between retry attempts when message delivery fails.
887
+ *
888
+ * You can use mathematical expressions and the following built-in functions to calculate the delay dynamically.
889
+ * The special variable `retried` represents the current retry attempt count (starting from 0).
890
+ *
891
+ * Supported functions:
892
+ * - `pow`
893
+ * - `sqrt`
894
+ * - `abs`
895
+ * - `exp`
896
+ * - `floor`
897
+ * - `ceil`
898
+ * - `round`
899
+ * - `min`
900
+ * - `max`
901
+ *
902
+ * Examples of valid `retryDelay` values:
903
+ * ```ts
904
+ * 1000 // 1 second
905
+ * 1000 * (1 + retried) // 1 second multiplied by the current retry attempt
906
+ * pow(2, retried) // 2 to the power of the current retry attempt
907
+ * max(10, pow(2, retried)) // The greater of 10 or 2^retried
908
+ * ```
909
+ */
910
+ readonly retryDelay?: string;
882
911
  /**
883
912
  * Settings for controlling the number of active requests
884
913
  * and number of requests per second with the same key.
885
914
  */
886
915
  readonly flowControl?: FlowControl;
887
- constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, telemetry, invokeCount, flowControl, }: {
916
+ /**
917
+ * Label to apply to the workflow run.
918
+ *
919
+ * Can be used to filter the workflow run logs.
920
+ *
921
+ * Can be set by passing a `label` parameter when triggering the workflow
922
+ * with `client.trigger`:
923
+ *
924
+ * ```ts
925
+ * await client.trigger({
926
+ * url: "https://workflow-endpoint.com",
927
+ * label: "my-label"
928
+ * });
929
+ * ```
930
+ */
931
+ readonly label?: string;
932
+ constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, retryDelay, telemetry, invokeCount, flowControl, label, }: {
888
933
  qstashClient: WorkflowClient;
889
934
  workflowRunId: string;
890
935
  headers: Headers;
@@ -895,9 +940,11 @@ declare class WorkflowContext<TInitialPayload = unknown> {
895
940
  initialPayload: TInitialPayload;
896
941
  env?: Record<string, string | undefined>;
897
942
  retries?: number;
943
+ retryDelay?: string;
898
944
  telemetry?: Telemetry;
899
945
  invokeCount?: number;
900
946
  flowControl?: FlowControl;
947
+ label?: string;
901
948
  });
902
949
  /**
903
950
  * Executes a workflow step
@@ -977,6 +1024,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
977
1024
  * @param body call body
978
1025
  * @param headers call headers
979
1026
  * @param retries number of call retries. 0 by default
1027
+ * @param retryDelay delay / time gap between retries.
980
1028
  * @param timeout max duration to wait for the endpoint to respond. in seconds.
981
1029
  * @returns call result as {
982
1030
  * status: number;
@@ -994,7 +1042,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
994
1042
  * Pauses workflow execution until a specific event occurs or a timeout is reached.
995
1043
  *
996
1044
  *```ts
997
- * const result = await workflow.waitForEvent("payment-confirmed", {
1045
+ * const result = await workflow.waitForEvent("payment-confirmed", "payment.confirmed", {
998
1046
  * timeout: "5m"
999
1047
  * });
1000
1048
  *```
@@ -1020,11 +1068,11 @@ declare class WorkflowContext<TInitialPayload = unknown> {
1020
1068
  * @param stepName
1021
1069
  * @param eventId - Unique identifier for the event to wait for
1022
1070
  * @param options - Configuration options.
1023
- * @returns `{ timeout: boolean, eventData: unknown }`.
1071
+ * @returns `{ timeout: boolean, eventData: TEventData }`.
1024
1072
  * The `timeout` property specifies if the workflow has timed out. The `eventData`
1025
1073
  * is the data passed when notifying this workflow of an event.
1026
1074
  */
1027
- waitForEvent(stepName: string, eventId: string, options?: WaitEventOptions): Promise<WaitStepResponse>;
1075
+ waitForEvent<TEventData = unknown>(stepName: string, eventId: string, options?: WaitEventOptions): Promise<WaitStepResponse<TEventData>>;
1028
1076
  /**
1029
1077
  * Notify workflow runs waiting for an event
1030
1078
  *
@@ -1169,6 +1217,16 @@ type StepFunction<TResult> = AsyncStepFunction<TResult> | SyncStepFunction<TResu
1169
1217
  type ParallelCallState = "first" | "partial" | "discard" | "last";
1170
1218
  type RouteFunction<TInitialPayload, TResult = unknown> = (context: WorkflowContext<TInitialPayload>) => Promise<TResult>;
1171
1219
  type FinishCondition = "success" | "duplicate-step" | "fromCallback" | "auth-fail" | "failure-callback" | "workflow-already-ended" | WorkflowNonRetryableError;
1220
+ type DetailedFinishCondition = {
1221
+ condition: Exclude<FinishCondition, WorkflowNonRetryableError | "failure-callback">;
1222
+ result?: never;
1223
+ } | {
1224
+ condition: "non-retryable-error";
1225
+ result: WorkflowNonRetryableError;
1226
+ } | {
1227
+ condition: "failure-callback";
1228
+ result: string | void;
1229
+ };
1172
1230
  type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload = unknown> = ValidationOptions<TInitialPayload> & {
1173
1231
  /**
1174
1232
  * QStash client
@@ -1180,7 +1238,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
1180
1238
  * @param workflowRunId
1181
1239
  * @returns response
1182
1240
  */
1183
- onStepFinish?: (workflowRunId: string, finishCondition: FinishCondition) => TResponse;
1241
+ onStepFinish?: (workflowRunId: string, finishCondition: FinishCondition, detailedFinishCondition?: DetailedFinishCondition) => TResponse;
1184
1242
  /**
1185
1243
  * Url of the endpoint where the workflow is set up.
1186
1244
  *
@@ -1228,7 +1286,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
1228
1286
  failStatus: number;
1229
1287
  failResponse: string;
1230
1288
  failHeaders: Record<string, string[]>;
1231
- }) => Promise<void> | void;
1289
+ }) => Promise<void | string> | void | string;
1232
1290
  /**
1233
1291
  * Base Url of the workflow endpoint
1234
1292
  *
@@ -1255,6 +1313,37 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
1255
1313
  * @default 3
1256
1314
  */
1257
1315
  retries?: number;
1316
+ /**
1317
+ * Delay between retries.
1318
+ *
1319
+ * By default, the `retryDelay` is exponential backoff.
1320
+ * More details can be found in: https://upstash.com/docs/qstash/features/retry.
1321
+ *
1322
+ * The `retryDelay` option allows you to customize the delay (in milliseconds) between retry attempts when message delivery fails.
1323
+ *
1324
+ * You can use mathematical expressions and the following built-in functions to calculate the delay dynamically.
1325
+ * The special variable `retried` represents the current retry attempt count (starting from 0).
1326
+ *
1327
+ * Supported functions:
1328
+ * - `pow`
1329
+ * - `sqrt`
1330
+ * - `abs`
1331
+ * - `exp`
1332
+ * - `floor`
1333
+ * - `ceil`
1334
+ * - `round`
1335
+ * - `min`
1336
+ * - `max`
1337
+ *
1338
+ * Examples of valid `retryDelay` values:
1339
+ * ```ts
1340
+ * 1000 // 1 second
1341
+ * 1000 * (1 + retried) // 1 second multiplied by the current retry attempt
1342
+ * pow(2, retried) // 2 to the power of the current retry attempt
1343
+ * max(10, pow(2, retried)) // The greater of 10 or 2^retried
1344
+ * ```
1345
+ */
1346
+ retryDelay?: string;
1258
1347
  /**
1259
1348
  * Whether the framework should use `content-type: application/json`
1260
1349
  * in `triggerFirstInvocation`.
@@ -1340,7 +1429,7 @@ type WaitRequest = {
1340
1429
  timeoutBody?: string;
1341
1430
  timeoutHeaders?: Record<string, string[]>;
1342
1431
  };
1343
- type WaitStepResponse = {
1432
+ type WaitStepResponse<TEventData = unknown> = {
1344
1433
  /**
1345
1434
  * whether the wait for event step timed out. false if
1346
1435
  * the step is notified
@@ -1349,7 +1438,7 @@ type WaitStepResponse = {
1349
1438
  /**
1350
1439
  * body passed in notify request
1351
1440
  */
1352
- eventData: unknown;
1441
+ eventData: TEventData;
1353
1442
  };
1354
1443
  type NotifyStepResponse = {
1355
1444
  /**
@@ -1393,6 +1482,7 @@ type CallSettings<TBody = unknown> = {
1393
1482
  body?: TBody;
1394
1483
  headers?: Record<string, string>;
1395
1484
  retries?: number;
1485
+ retryDelay?: string;
1396
1486
  timeout?: Duration | number;
1397
1487
  flowControl?: FlowControl;
1398
1488
  };
@@ -1421,6 +1511,10 @@ type HeaderParams = {
1421
1511
  * retry setting of requests except context.call
1422
1512
  */
1423
1513
  retries?: number;
1514
+ /**
1515
+ * retry delay to include in headers.
1516
+ */
1517
+ retryDelay?: string;
1424
1518
  /**
1425
1519
  * telemetry to include in timeoutHeaders.
1426
1520
  *
@@ -1445,6 +1539,10 @@ type HeaderParams = {
1445
1539
  * number of retries in context.call
1446
1540
  */
1447
1541
  callRetries?: number;
1542
+ /**
1543
+ * retry delay to include in headers.
1544
+ */
1545
+ callRetryDelay?: string;
1448
1546
  /**
1449
1547
  * timeout duration in context.call
1450
1548
  */
@@ -1468,6 +1566,12 @@ type HeaderParams = {
1468
1566
  * set to never because this is not a context.call step
1469
1567
  */
1470
1568
  callRetries?: never;
1569
+ /**
1570
+ * retry delay to include in headers.
1571
+ *
1572
+ * set to never because this is not a context.call step
1573
+ */
1574
+ callRetryDelay?: never;
1471
1575
  /**
1472
1576
  * timeout duration in context.call
1473
1577
  *
@@ -1493,7 +1597,7 @@ type LazyInvokeStepParams<TInitiaPayload, TResult> = {
1493
1597
  workflow: Pick<InvokableWorkflow<TInitiaPayload, TResult>, "routeFunction" | "workflowId" | "options">;
1494
1598
  body: TInitiaPayload;
1495
1599
  workflowRunId?: string;
1496
- } & Pick<CallSettings, "retries" | "headers" | "flowControl">;
1600
+ } & Pick<CallSettings, "retries" | "headers" | "flowControl" | "retryDelay">;
1497
1601
  type InvokeStepResponse<TBody> = {
1498
1602
  body: TBody;
1499
1603
  isCanceled?: boolean;
@@ -1505,4 +1609,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
1505
1609
  workflowId?: string;
1506
1610
  };
1507
1611
 
1508
- export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type InvokeWorkflowRequest as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, WorkflowError as c, WorkflowAbort as d, WorkflowNonRetryableError as e, WorkflowTool as f, WorkflowContext as g, type WorkflowClient as h, type WorkflowReceiver as i, StepTypes as j, type Step as k, type SyncStepFunction as l, type StepFunction as m, type PublicServeOptions as n, type FailureFunctionPayload as o, type RequiredExceptFields as p, type WaitRequest as q, type WaitStepResponse as r, type NotifyStepResponse as s, type WaitEventOptions as t, type CallSettings as u, type InvokeStepResponse as v, type InvokableWorkflow as w, type LogLevel as x, type WorkflowLoggerOptions as y, WorkflowLogger as z };
1612
+ export { type AsyncStepFunction as A, WorkflowLogger as B, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type InvokeWorkflowRequest as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, WorkflowError as c, WorkflowAbort as d, WorkflowNonRetryableError as e, WorkflowTool as f, WorkflowContext as g, type WorkflowClient as h, type WorkflowReceiver as i, StepTypes as j, type Step as k, type SyncStepFunction as l, type StepFunction as m, type PublicServeOptions as n, type FailureFunctionPayload as o, type RequiredExceptFields as p, type WaitRequest as q, type WaitStepResponse as r, type NotifyStepResponse as s, type Duration as t, type WaitEventOptions as u, type CallSettings as v, type InvokeStepResponse as w, type InvokableWorkflow as x, type LogLevel as y, type WorkflowLoggerOptions as z };
@@ -620,7 +620,7 @@ type MultiAgentTaskParams = TaskParams & {
620
620
  background?: string;
621
621
  };
622
622
  type ModelParams = Parameters<ReturnType<typeof createOpenAI>>;
623
- type AgentCallParams = Pick<CallSettings, "flowControl" | "retries" | "timeout">;
623
+ type AgentCallParams = Pick<CallSettings, "flowControl" | "retries" | "timeout" | "retryDelay">;
624
624
  type CustomModelSettings = ModelParams["1"] & {
625
625
  baseURL?: string;
626
626
  apiKey?: string;
@@ -747,9 +747,7 @@ declare class WorkflowAgents {
747
747
  context: WorkflowContext;
748
748
  provider: TProvider;
749
749
  providerParams?: Omit<Required<Parameters<TProvider>>[0], "fetch">;
750
- agentCallParams? /**
751
- * creates an openai model for agents
752
- */: AgentCallParams;
750
+ agentCallParams?: AgentCallParams;
753
751
  }) => ReturnType<TProvider>;
754
752
  }
755
753
 
@@ -879,12 +877,59 @@ declare class WorkflowContext<TInitialPayload = unknown> {
879
877
  * Number of retries
880
878
  */
881
879
  readonly retries: number;
880
+ /**
881
+ * Delay between retries.
882
+ *
883
+ * By default, the `retryDelay` is exponential backoff.
884
+ * More details can be found in: https://upstash.com/docs/qstash/features/retry.
885
+ *
886
+ * The `retryDelay` option allows you to customize the delay (in milliseconds) between retry attempts when message delivery fails.
887
+ *
888
+ * You can use mathematical expressions and the following built-in functions to calculate the delay dynamically.
889
+ * The special variable `retried` represents the current retry attempt count (starting from 0).
890
+ *
891
+ * Supported functions:
892
+ * - `pow`
893
+ * - `sqrt`
894
+ * - `abs`
895
+ * - `exp`
896
+ * - `floor`
897
+ * - `ceil`
898
+ * - `round`
899
+ * - `min`
900
+ * - `max`
901
+ *
902
+ * Examples of valid `retryDelay` values:
903
+ * ```ts
904
+ * 1000 // 1 second
905
+ * 1000 * (1 + retried) // 1 second multiplied by the current retry attempt
906
+ * pow(2, retried) // 2 to the power of the current retry attempt
907
+ * max(10, pow(2, retried)) // The greater of 10 or 2^retried
908
+ * ```
909
+ */
910
+ readonly retryDelay?: string;
882
911
  /**
883
912
  * Settings for controlling the number of active requests
884
913
  * and number of requests per second with the same key.
885
914
  */
886
915
  readonly flowControl?: FlowControl;
887
- constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, telemetry, invokeCount, flowControl, }: {
916
+ /**
917
+ * Label to apply to the workflow run.
918
+ *
919
+ * Can be used to filter the workflow run logs.
920
+ *
921
+ * Can be set by passing a `label` parameter when triggering the workflow
922
+ * with `client.trigger`:
923
+ *
924
+ * ```ts
925
+ * await client.trigger({
926
+ * url: "https://workflow-endpoint.com",
927
+ * label: "my-label"
928
+ * });
929
+ * ```
930
+ */
931
+ readonly label?: string;
932
+ constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, retryDelay, telemetry, invokeCount, flowControl, label, }: {
888
933
  qstashClient: WorkflowClient;
889
934
  workflowRunId: string;
890
935
  headers: Headers;
@@ -895,9 +940,11 @@ declare class WorkflowContext<TInitialPayload = unknown> {
895
940
  initialPayload: TInitialPayload;
896
941
  env?: Record<string, string | undefined>;
897
942
  retries?: number;
943
+ retryDelay?: string;
898
944
  telemetry?: Telemetry;
899
945
  invokeCount?: number;
900
946
  flowControl?: FlowControl;
947
+ label?: string;
901
948
  });
902
949
  /**
903
950
  * Executes a workflow step
@@ -977,6 +1024,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
977
1024
  * @param body call body
978
1025
  * @param headers call headers
979
1026
  * @param retries number of call retries. 0 by default
1027
+ * @param retryDelay delay / time gap between retries.
980
1028
  * @param timeout max duration to wait for the endpoint to respond. in seconds.
981
1029
  * @returns call result as {
982
1030
  * status: number;
@@ -994,7 +1042,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
994
1042
  * Pauses workflow execution until a specific event occurs or a timeout is reached.
995
1043
  *
996
1044
  *```ts
997
- * const result = await workflow.waitForEvent("payment-confirmed", {
1045
+ * const result = await workflow.waitForEvent("payment-confirmed", "payment.confirmed", {
998
1046
  * timeout: "5m"
999
1047
  * });
1000
1048
  *```
@@ -1020,11 +1068,11 @@ declare class WorkflowContext<TInitialPayload = unknown> {
1020
1068
  * @param stepName
1021
1069
  * @param eventId - Unique identifier for the event to wait for
1022
1070
  * @param options - Configuration options.
1023
- * @returns `{ timeout: boolean, eventData: unknown }`.
1071
+ * @returns `{ timeout: boolean, eventData: TEventData }`.
1024
1072
  * The `timeout` property specifies if the workflow has timed out. The `eventData`
1025
1073
  * is the data passed when notifying this workflow of an event.
1026
1074
  */
1027
- waitForEvent(stepName: string, eventId: string, options?: WaitEventOptions): Promise<WaitStepResponse>;
1075
+ waitForEvent<TEventData = unknown>(stepName: string, eventId: string, options?: WaitEventOptions): Promise<WaitStepResponse<TEventData>>;
1028
1076
  /**
1029
1077
  * Notify workflow runs waiting for an event
1030
1078
  *
@@ -1169,6 +1217,16 @@ type StepFunction<TResult> = AsyncStepFunction<TResult> | SyncStepFunction<TResu
1169
1217
  type ParallelCallState = "first" | "partial" | "discard" | "last";
1170
1218
  type RouteFunction<TInitialPayload, TResult = unknown> = (context: WorkflowContext<TInitialPayload>) => Promise<TResult>;
1171
1219
  type FinishCondition = "success" | "duplicate-step" | "fromCallback" | "auth-fail" | "failure-callback" | "workflow-already-ended" | WorkflowNonRetryableError;
1220
+ type DetailedFinishCondition = {
1221
+ condition: Exclude<FinishCondition, WorkflowNonRetryableError | "failure-callback">;
1222
+ result?: never;
1223
+ } | {
1224
+ condition: "non-retryable-error";
1225
+ result: WorkflowNonRetryableError;
1226
+ } | {
1227
+ condition: "failure-callback";
1228
+ result: string | void;
1229
+ };
1172
1230
  type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload = unknown> = ValidationOptions<TInitialPayload> & {
1173
1231
  /**
1174
1232
  * QStash client
@@ -1180,7 +1238,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
1180
1238
  * @param workflowRunId
1181
1239
  * @returns response
1182
1240
  */
1183
- onStepFinish?: (workflowRunId: string, finishCondition: FinishCondition) => TResponse;
1241
+ onStepFinish?: (workflowRunId: string, finishCondition: FinishCondition, detailedFinishCondition?: DetailedFinishCondition) => TResponse;
1184
1242
  /**
1185
1243
  * Url of the endpoint where the workflow is set up.
1186
1244
  *
@@ -1228,7 +1286,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
1228
1286
  failStatus: number;
1229
1287
  failResponse: string;
1230
1288
  failHeaders: Record<string, string[]>;
1231
- }) => Promise<void> | void;
1289
+ }) => Promise<void | string> | void | string;
1232
1290
  /**
1233
1291
  * Base Url of the workflow endpoint
1234
1292
  *
@@ -1255,6 +1313,37 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
1255
1313
  * @default 3
1256
1314
  */
1257
1315
  retries?: number;
1316
+ /**
1317
+ * Delay between retries.
1318
+ *
1319
+ * By default, the `retryDelay` is exponential backoff.
1320
+ * More details can be found in: https://upstash.com/docs/qstash/features/retry.
1321
+ *
1322
+ * The `retryDelay` option allows you to customize the delay (in milliseconds) between retry attempts when message delivery fails.
1323
+ *
1324
+ * You can use mathematical expressions and the following built-in functions to calculate the delay dynamically.
1325
+ * The special variable `retried` represents the current retry attempt count (starting from 0).
1326
+ *
1327
+ * Supported functions:
1328
+ * - `pow`
1329
+ * - `sqrt`
1330
+ * - `abs`
1331
+ * - `exp`
1332
+ * - `floor`
1333
+ * - `ceil`
1334
+ * - `round`
1335
+ * - `min`
1336
+ * - `max`
1337
+ *
1338
+ * Examples of valid `retryDelay` values:
1339
+ * ```ts
1340
+ * 1000 // 1 second
1341
+ * 1000 * (1 + retried) // 1 second multiplied by the current retry attempt
1342
+ * pow(2, retried) // 2 to the power of the current retry attempt
1343
+ * max(10, pow(2, retried)) // The greater of 10 or 2^retried
1344
+ * ```
1345
+ */
1346
+ retryDelay?: string;
1258
1347
  /**
1259
1348
  * Whether the framework should use `content-type: application/json`
1260
1349
  * in `triggerFirstInvocation`.
@@ -1340,7 +1429,7 @@ type WaitRequest = {
1340
1429
  timeoutBody?: string;
1341
1430
  timeoutHeaders?: Record<string, string[]>;
1342
1431
  };
1343
- type WaitStepResponse = {
1432
+ type WaitStepResponse<TEventData = unknown> = {
1344
1433
  /**
1345
1434
  * whether the wait for event step timed out. false if
1346
1435
  * the step is notified
@@ -1349,7 +1438,7 @@ type WaitStepResponse = {
1349
1438
  /**
1350
1439
  * body passed in notify request
1351
1440
  */
1352
- eventData: unknown;
1441
+ eventData: TEventData;
1353
1442
  };
1354
1443
  type NotifyStepResponse = {
1355
1444
  /**
@@ -1393,6 +1482,7 @@ type CallSettings<TBody = unknown> = {
1393
1482
  body?: TBody;
1394
1483
  headers?: Record<string, string>;
1395
1484
  retries?: number;
1485
+ retryDelay?: string;
1396
1486
  timeout?: Duration | number;
1397
1487
  flowControl?: FlowControl;
1398
1488
  };
@@ -1421,6 +1511,10 @@ type HeaderParams = {
1421
1511
  * retry setting of requests except context.call
1422
1512
  */
1423
1513
  retries?: number;
1514
+ /**
1515
+ * retry delay to include in headers.
1516
+ */
1517
+ retryDelay?: string;
1424
1518
  /**
1425
1519
  * telemetry to include in timeoutHeaders.
1426
1520
  *
@@ -1445,6 +1539,10 @@ type HeaderParams = {
1445
1539
  * number of retries in context.call
1446
1540
  */
1447
1541
  callRetries?: number;
1542
+ /**
1543
+ * retry delay to include in headers.
1544
+ */
1545
+ callRetryDelay?: string;
1448
1546
  /**
1449
1547
  * timeout duration in context.call
1450
1548
  */
@@ -1468,6 +1566,12 @@ type HeaderParams = {
1468
1566
  * set to never because this is not a context.call step
1469
1567
  */
1470
1568
  callRetries?: never;
1569
+ /**
1570
+ * retry delay to include in headers.
1571
+ *
1572
+ * set to never because this is not a context.call step
1573
+ */
1574
+ callRetryDelay?: never;
1471
1575
  /**
1472
1576
  * timeout duration in context.call
1473
1577
  *
@@ -1493,7 +1597,7 @@ type LazyInvokeStepParams<TInitiaPayload, TResult> = {
1493
1597
  workflow: Pick<InvokableWorkflow<TInitiaPayload, TResult>, "routeFunction" | "workflowId" | "options">;
1494
1598
  body: TInitiaPayload;
1495
1599
  workflowRunId?: string;
1496
- } & Pick<CallSettings, "retries" | "headers" | "flowControl">;
1600
+ } & Pick<CallSettings, "retries" | "headers" | "flowControl" | "retryDelay">;
1497
1601
  type InvokeStepResponse<TBody> = {
1498
1602
  body: TBody;
1499
1603
  isCanceled?: boolean;
@@ -1505,4 +1609,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
1505
1609
  workflowId?: string;
1506
1610
  };
1507
1611
 
1508
- export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type InvokeWorkflowRequest as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, WorkflowError as c, WorkflowAbort as d, WorkflowNonRetryableError as e, WorkflowTool as f, WorkflowContext as g, type WorkflowClient as h, type WorkflowReceiver as i, StepTypes as j, type Step as k, type SyncStepFunction as l, type StepFunction as m, type PublicServeOptions as n, type FailureFunctionPayload as o, type RequiredExceptFields as p, type WaitRequest as q, type WaitStepResponse as r, type NotifyStepResponse as s, type WaitEventOptions as t, type CallSettings as u, type InvokeStepResponse as v, type InvokableWorkflow as w, type LogLevel as x, type WorkflowLoggerOptions as y, WorkflowLogger as z };
1612
+ export { type AsyncStepFunction as A, WorkflowLogger as B, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type InvokeWorkflowRequest as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, WorkflowError as c, WorkflowAbort as d, WorkflowNonRetryableError as e, WorkflowTool as f, WorkflowContext as g, type WorkflowClient as h, type WorkflowReceiver as i, StepTypes as j, type Step as k, type SyncStepFunction as l, type StepFunction as m, type PublicServeOptions as n, type FailureFunctionPayload as o, type RequiredExceptFields as p, type WaitRequest as q, type WaitStepResponse as r, type NotifyStepResponse as s, type Duration as t, type WaitEventOptions as u, type CallSettings as v, type InvokeStepResponse as w, type InvokableWorkflow as x, type LogLevel as y, type WorkflowLoggerOptions as z };