@runtypelabs/sdk 1.18.1 → 1.19.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.
package/dist/index.cjs CHANGED
@@ -7578,6 +7578,24 @@ var FlowBuilder = class {
7578
7578
  }
7579
7579
  return new FlowResult(response);
7580
7580
  }
7581
+ /**
7582
+ * Set a run condition (when predicate) on the last added step.
7583
+ * If the expression evaluates to falsy at runtime, the step is skipped.
7584
+ *
7585
+ * @example
7586
+ * ```typescript
7587
+ * new FlowBuilder()
7588
+ * .createFlow({ name: 'Conditional' })
7589
+ * .prompt({ name: 'Summarize', model: 'gpt-4', userPrompt: '...' })
7590
+ * .when('data.length > 0')
7591
+ * .build()
7592
+ * ```
7593
+ */
7594
+ when(expression) {
7595
+ const lastStep = this.steps[this.steps.length - 1];
7596
+ if (lastStep) lastStep.when = expression;
7597
+ return this;
7598
+ }
7581
7599
  // ============================================================================
7582
7600
  // Private Helpers
7583
7601
  // ============================================================================
package/dist/index.d.cts CHANGED
@@ -341,6 +341,8 @@ interface DispatchRequest {
341
341
  versionNotes?: string;
342
342
  flowVersionId?: string;
343
343
  upsertOptions?: UpsertOptions$2;
344
+ flowTimeoutMs?: number;
345
+ stepTimeoutMs?: number;
344
346
  };
345
347
  }
346
348
  interface ListParams {
@@ -960,6 +962,8 @@ interface PromptStepConfig$1 {
960
962
  /** Error handling configuration - supports simple mode or fallback chains */
961
963
  errorHandling?: ErrorHandlingMode | PromptErrorHandling;
962
964
  enabled?: boolean;
965
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
966
+ when?: string;
963
967
  }
964
968
  interface FetchUrlStepConfig$1 {
965
969
  name: string;
@@ -979,6 +983,8 @@ interface FetchUrlStepConfig$1 {
979
983
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
980
984
  streamOutput?: boolean;
981
985
  enabled?: boolean;
986
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
987
+ when?: string;
982
988
  }
983
989
  interface CrawlStepConfig {
984
990
  name: string;
@@ -1006,6 +1012,8 @@ interface CrawlStepConfig {
1006
1012
  pollIntervalMs?: number;
1007
1013
  completionTimeoutMs?: number;
1008
1014
  enabled?: boolean;
1015
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1016
+ when?: string;
1009
1017
  }
1010
1018
  interface TransformDataStepConfig$1 {
1011
1019
  name: string;
@@ -1014,12 +1022,16 @@ interface TransformDataStepConfig$1 {
1014
1022
  sandboxProvider?: 'quickjs' | 'daytona' | 'cloudflare-worker';
1015
1023
  streamOutput?: boolean;
1016
1024
  enabled?: boolean;
1025
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1026
+ when?: string;
1017
1027
  }
1018
1028
  interface SetVariableStepConfig$1 {
1019
1029
  name: string;
1020
1030
  variableName: string;
1021
1031
  value: string | number | boolean | object;
1022
1032
  enabled?: boolean;
1033
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1034
+ when?: string;
1023
1035
  }
1024
1036
  interface ConditionalStepConfig$1 {
1025
1037
  name: string;
@@ -1027,6 +1039,8 @@ interface ConditionalStepConfig$1 {
1027
1039
  trueSteps?: any[];
1028
1040
  falseSteps?: any[];
1029
1041
  enabled?: boolean;
1042
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1043
+ when?: string;
1030
1044
  }
1031
1045
  interface SearchStepConfig$1 {
1032
1046
  name: string;
@@ -1039,6 +1053,8 @@ interface SearchStepConfig$1 {
1039
1053
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1040
1054
  streamOutput?: boolean;
1041
1055
  enabled?: boolean;
1056
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1057
+ when?: string;
1042
1058
  }
1043
1059
  interface SendEmailStepConfig$1 {
1044
1060
  name: string;
@@ -1051,11 +1067,15 @@ interface SendEmailStepConfig$1 {
1051
1067
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1052
1068
  streamOutput?: boolean;
1053
1069
  enabled?: boolean;
1070
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1071
+ when?: string;
1054
1072
  }
1055
1073
  interface SendStreamStepConfig$1 {
1056
1074
  name: string;
1057
1075
  message: string;
1058
1076
  enabled?: boolean;
1077
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1078
+ when?: string;
1059
1079
  }
1060
1080
  interface RetrieveRecordStepConfig$1 {
1061
1081
  name: string;
@@ -1066,6 +1086,8 @@ interface RetrieveRecordStepConfig$1 {
1066
1086
  outputVariable?: string;
1067
1087
  streamOutput?: boolean;
1068
1088
  enabled?: boolean;
1089
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1090
+ when?: string;
1069
1091
  }
1070
1092
  interface UpsertRecordStepConfig$1 {
1071
1093
  name: string;
@@ -1078,6 +1100,8 @@ interface UpsertRecordStepConfig$1 {
1078
1100
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1079
1101
  streamOutput?: boolean;
1080
1102
  enabled?: boolean;
1103
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1104
+ when?: string;
1081
1105
  }
1082
1106
  interface VectorSearchStepConfig$1 {
1083
1107
  name: string;
@@ -1089,6 +1113,8 @@ interface VectorSearchStepConfig$1 {
1089
1113
  outputVariable?: string;
1090
1114
  streamOutput?: boolean;
1091
1115
  enabled?: boolean;
1116
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1117
+ when?: string;
1092
1118
  }
1093
1119
  interface GenerateEmbeddingStepConfig$1 {
1094
1120
  name: string;
@@ -1098,6 +1124,8 @@ interface GenerateEmbeddingStepConfig$1 {
1098
1124
  outputVariable?: string;
1099
1125
  streamOutput?: boolean;
1100
1126
  enabled?: boolean;
1127
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1128
+ when?: string;
1101
1129
  }
1102
1130
  interface WaitUntilStepConfig$1 {
1103
1131
  name: string;
@@ -1114,6 +1142,8 @@ interface WaitUntilStepConfig$1 {
1114
1142
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1115
1143
  streamOutput?: boolean;
1116
1144
  enabled?: boolean;
1145
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1146
+ when?: string;
1117
1147
  }
1118
1148
  interface SendEventStepConfig$1 {
1119
1149
  name: string;
@@ -1125,6 +1155,8 @@ interface SendEventStepConfig$1 {
1125
1155
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1126
1156
  streamOutput?: boolean;
1127
1157
  enabled?: boolean;
1158
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1159
+ when?: string;
1128
1160
  }
1129
1161
  interface SendTextStepConfig$1 {
1130
1162
  name: string;
@@ -1136,6 +1168,8 @@ interface SendTextStepConfig$1 {
1136
1168
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1137
1169
  streamOutput?: boolean;
1138
1170
  enabled?: boolean;
1171
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1172
+ when?: string;
1139
1173
  }
1140
1174
  interface FetchGitHubStepConfig$1 {
1141
1175
  name: string;
@@ -1145,6 +1179,8 @@ interface FetchGitHubStepConfig$1 {
1145
1179
  outputVariable?: string;
1146
1180
  streamOutput?: boolean;
1147
1181
  enabled?: boolean;
1182
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1183
+ when?: string;
1148
1184
  }
1149
1185
  interface FlowConfig$1 {
1150
1186
  name: string;
@@ -1189,6 +1225,8 @@ interface DispatchOptions$1 {
1189
1225
  flowVersionId?: string;
1190
1226
  /** Options for upsert mode (only used when flowMode is 'upsert') */
1191
1227
  upsertOptions?: UpsertOptions$1;
1228
+ flowTimeoutMs?: number;
1229
+ stepTimeoutMs?: number;
1192
1230
  }
1193
1231
  interface Message$1 {
1194
1232
  role: 'system' | 'user' | 'assistant';
@@ -1600,6 +1638,20 @@ declare class FlowBuilder {
1600
1638
  * ```
1601
1639
  */
1602
1640
  run(client: DispatchClient, options: DispatchOptions$1, callbacks: StreamCallbacks): Promise<FlowSummary>;
1641
+ /**
1642
+ * Set a run condition (when predicate) on the last added step.
1643
+ * If the expression evaluates to falsy at runtime, the step is skipped.
1644
+ *
1645
+ * @example
1646
+ * ```typescript
1647
+ * new FlowBuilder()
1648
+ * .createFlow({ name: 'Conditional' })
1649
+ * .prompt({ name: 'Summarize', model: 'gpt-4', userPrompt: '...' })
1650
+ * .when('data.length > 0')
1651
+ * .build()
1652
+ * ```
1653
+ */
1654
+ when(expression: string): this;
1603
1655
  private addStep;
1604
1656
  }
1605
1657
  /**
package/dist/index.d.ts CHANGED
@@ -341,6 +341,8 @@ interface DispatchRequest {
341
341
  versionNotes?: string;
342
342
  flowVersionId?: string;
343
343
  upsertOptions?: UpsertOptions$2;
344
+ flowTimeoutMs?: number;
345
+ stepTimeoutMs?: number;
344
346
  };
345
347
  }
346
348
  interface ListParams {
@@ -960,6 +962,8 @@ interface PromptStepConfig$1 {
960
962
  /** Error handling configuration - supports simple mode or fallback chains */
961
963
  errorHandling?: ErrorHandlingMode | PromptErrorHandling;
962
964
  enabled?: boolean;
965
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
966
+ when?: string;
963
967
  }
964
968
  interface FetchUrlStepConfig$1 {
965
969
  name: string;
@@ -979,6 +983,8 @@ interface FetchUrlStepConfig$1 {
979
983
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
980
984
  streamOutput?: boolean;
981
985
  enabled?: boolean;
986
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
987
+ when?: string;
982
988
  }
983
989
  interface CrawlStepConfig {
984
990
  name: string;
@@ -1006,6 +1012,8 @@ interface CrawlStepConfig {
1006
1012
  pollIntervalMs?: number;
1007
1013
  completionTimeoutMs?: number;
1008
1014
  enabled?: boolean;
1015
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1016
+ when?: string;
1009
1017
  }
1010
1018
  interface TransformDataStepConfig$1 {
1011
1019
  name: string;
@@ -1014,12 +1022,16 @@ interface TransformDataStepConfig$1 {
1014
1022
  sandboxProvider?: 'quickjs' | 'daytona' | 'cloudflare-worker';
1015
1023
  streamOutput?: boolean;
1016
1024
  enabled?: boolean;
1025
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1026
+ when?: string;
1017
1027
  }
1018
1028
  interface SetVariableStepConfig$1 {
1019
1029
  name: string;
1020
1030
  variableName: string;
1021
1031
  value: string | number | boolean | object;
1022
1032
  enabled?: boolean;
1033
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1034
+ when?: string;
1023
1035
  }
1024
1036
  interface ConditionalStepConfig$1 {
1025
1037
  name: string;
@@ -1027,6 +1039,8 @@ interface ConditionalStepConfig$1 {
1027
1039
  trueSteps?: any[];
1028
1040
  falseSteps?: any[];
1029
1041
  enabled?: boolean;
1042
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1043
+ when?: string;
1030
1044
  }
1031
1045
  interface SearchStepConfig$1 {
1032
1046
  name: string;
@@ -1039,6 +1053,8 @@ interface SearchStepConfig$1 {
1039
1053
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1040
1054
  streamOutput?: boolean;
1041
1055
  enabled?: boolean;
1056
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1057
+ when?: string;
1042
1058
  }
1043
1059
  interface SendEmailStepConfig$1 {
1044
1060
  name: string;
@@ -1051,11 +1067,15 @@ interface SendEmailStepConfig$1 {
1051
1067
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1052
1068
  streamOutput?: boolean;
1053
1069
  enabled?: boolean;
1070
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1071
+ when?: string;
1054
1072
  }
1055
1073
  interface SendStreamStepConfig$1 {
1056
1074
  name: string;
1057
1075
  message: string;
1058
1076
  enabled?: boolean;
1077
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1078
+ when?: string;
1059
1079
  }
1060
1080
  interface RetrieveRecordStepConfig$1 {
1061
1081
  name: string;
@@ -1066,6 +1086,8 @@ interface RetrieveRecordStepConfig$1 {
1066
1086
  outputVariable?: string;
1067
1087
  streamOutput?: boolean;
1068
1088
  enabled?: boolean;
1089
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1090
+ when?: string;
1069
1091
  }
1070
1092
  interface UpsertRecordStepConfig$1 {
1071
1093
  name: string;
@@ -1078,6 +1100,8 @@ interface UpsertRecordStepConfig$1 {
1078
1100
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1079
1101
  streamOutput?: boolean;
1080
1102
  enabled?: boolean;
1103
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1104
+ when?: string;
1081
1105
  }
1082
1106
  interface VectorSearchStepConfig$1 {
1083
1107
  name: string;
@@ -1089,6 +1113,8 @@ interface VectorSearchStepConfig$1 {
1089
1113
  outputVariable?: string;
1090
1114
  streamOutput?: boolean;
1091
1115
  enabled?: boolean;
1116
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1117
+ when?: string;
1092
1118
  }
1093
1119
  interface GenerateEmbeddingStepConfig$1 {
1094
1120
  name: string;
@@ -1098,6 +1124,8 @@ interface GenerateEmbeddingStepConfig$1 {
1098
1124
  outputVariable?: string;
1099
1125
  streamOutput?: boolean;
1100
1126
  enabled?: boolean;
1127
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1128
+ when?: string;
1101
1129
  }
1102
1130
  interface WaitUntilStepConfig$1 {
1103
1131
  name: string;
@@ -1114,6 +1142,8 @@ interface WaitUntilStepConfig$1 {
1114
1142
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1115
1143
  streamOutput?: boolean;
1116
1144
  enabled?: boolean;
1145
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1146
+ when?: string;
1117
1147
  }
1118
1148
  interface SendEventStepConfig$1 {
1119
1149
  name: string;
@@ -1125,6 +1155,8 @@ interface SendEventStepConfig$1 {
1125
1155
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1126
1156
  streamOutput?: boolean;
1127
1157
  enabled?: boolean;
1158
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1159
+ when?: string;
1128
1160
  }
1129
1161
  interface SendTextStepConfig$1 {
1130
1162
  name: string;
@@ -1136,6 +1168,8 @@ interface SendTextStepConfig$1 {
1136
1168
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1137
1169
  streamOutput?: boolean;
1138
1170
  enabled?: boolean;
1171
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1172
+ when?: string;
1139
1173
  }
1140
1174
  interface FetchGitHubStepConfig$1 {
1141
1175
  name: string;
@@ -1145,6 +1179,8 @@ interface FetchGitHubStepConfig$1 {
1145
1179
  outputVariable?: string;
1146
1180
  streamOutput?: boolean;
1147
1181
  enabled?: boolean;
1182
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1183
+ when?: string;
1148
1184
  }
1149
1185
  interface FlowConfig$1 {
1150
1186
  name: string;
@@ -1189,6 +1225,8 @@ interface DispatchOptions$1 {
1189
1225
  flowVersionId?: string;
1190
1226
  /** Options for upsert mode (only used when flowMode is 'upsert') */
1191
1227
  upsertOptions?: UpsertOptions$1;
1228
+ flowTimeoutMs?: number;
1229
+ stepTimeoutMs?: number;
1192
1230
  }
1193
1231
  interface Message$1 {
1194
1232
  role: 'system' | 'user' | 'assistant';
@@ -1600,6 +1638,20 @@ declare class FlowBuilder {
1600
1638
  * ```
1601
1639
  */
1602
1640
  run(client: DispatchClient, options: DispatchOptions$1, callbacks: StreamCallbacks): Promise<FlowSummary>;
1641
+ /**
1642
+ * Set a run condition (when predicate) on the last added step.
1643
+ * If the expression evaluates to falsy at runtime, the step is skipped.
1644
+ *
1645
+ * @example
1646
+ * ```typescript
1647
+ * new FlowBuilder()
1648
+ * .createFlow({ name: 'Conditional' })
1649
+ * .prompt({ name: 'Summarize', model: 'gpt-4', userPrompt: '...' })
1650
+ * .when('data.length > 0')
1651
+ * .build()
1652
+ * ```
1653
+ */
1654
+ when(expression: string): this;
1603
1655
  private addStep;
1604
1656
  }
1605
1657
  /**
package/dist/index.mjs CHANGED
@@ -7508,6 +7508,24 @@ var FlowBuilder = class {
7508
7508
  }
7509
7509
  return new FlowResult(response);
7510
7510
  }
7511
+ /**
7512
+ * Set a run condition (when predicate) on the last added step.
7513
+ * If the expression evaluates to falsy at runtime, the step is skipped.
7514
+ *
7515
+ * @example
7516
+ * ```typescript
7517
+ * new FlowBuilder()
7518
+ * .createFlow({ name: 'Conditional' })
7519
+ * .prompt({ name: 'Summarize', model: 'gpt-4', userPrompt: '...' })
7520
+ * .when('data.length > 0')
7521
+ * .build()
7522
+ * ```
7523
+ */
7524
+ when(expression) {
7525
+ const lastStep = this.steps[this.steps.length - 1];
7526
+ if (lastStep) lastStep.when = expression;
7527
+ return this;
7528
+ }
7511
7529
  // ============================================================================
7512
7530
  // Private Helpers
7513
7531
  // ============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/sdk",
3
- "version": "1.18.1",
3
+ "version": "1.19.1",
4
4
  "type": "module",
5
5
  "description": "TypeScript SDK for the Runtype API with fluent methods. Use it to quickly realize AI products, agents, and workflows.",
6
6
  "main": "dist/index.cjs",