@runtypelabs/sdk 1.18.1 → 1.19.0

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
@@ -960,6 +960,8 @@ interface PromptStepConfig$1 {
960
960
  /** Error handling configuration - supports simple mode or fallback chains */
961
961
  errorHandling?: ErrorHandlingMode | PromptErrorHandling;
962
962
  enabled?: boolean;
963
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
964
+ when?: string;
963
965
  }
964
966
  interface FetchUrlStepConfig$1 {
965
967
  name: string;
@@ -979,6 +981,8 @@ interface FetchUrlStepConfig$1 {
979
981
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
980
982
  streamOutput?: boolean;
981
983
  enabled?: boolean;
984
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
985
+ when?: string;
982
986
  }
983
987
  interface CrawlStepConfig {
984
988
  name: string;
@@ -1006,6 +1010,8 @@ interface CrawlStepConfig {
1006
1010
  pollIntervalMs?: number;
1007
1011
  completionTimeoutMs?: number;
1008
1012
  enabled?: boolean;
1013
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1014
+ when?: string;
1009
1015
  }
1010
1016
  interface TransformDataStepConfig$1 {
1011
1017
  name: string;
@@ -1014,12 +1020,16 @@ interface TransformDataStepConfig$1 {
1014
1020
  sandboxProvider?: 'quickjs' | 'daytona' | 'cloudflare-worker';
1015
1021
  streamOutput?: boolean;
1016
1022
  enabled?: boolean;
1023
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1024
+ when?: string;
1017
1025
  }
1018
1026
  interface SetVariableStepConfig$1 {
1019
1027
  name: string;
1020
1028
  variableName: string;
1021
1029
  value: string | number | boolean | object;
1022
1030
  enabled?: boolean;
1031
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1032
+ when?: string;
1023
1033
  }
1024
1034
  interface ConditionalStepConfig$1 {
1025
1035
  name: string;
@@ -1027,6 +1037,8 @@ interface ConditionalStepConfig$1 {
1027
1037
  trueSteps?: any[];
1028
1038
  falseSteps?: any[];
1029
1039
  enabled?: boolean;
1040
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1041
+ when?: string;
1030
1042
  }
1031
1043
  interface SearchStepConfig$1 {
1032
1044
  name: string;
@@ -1039,6 +1051,8 @@ interface SearchStepConfig$1 {
1039
1051
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1040
1052
  streamOutput?: boolean;
1041
1053
  enabled?: boolean;
1054
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1055
+ when?: string;
1042
1056
  }
1043
1057
  interface SendEmailStepConfig$1 {
1044
1058
  name: string;
@@ -1051,11 +1065,15 @@ interface SendEmailStepConfig$1 {
1051
1065
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1052
1066
  streamOutput?: boolean;
1053
1067
  enabled?: boolean;
1068
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1069
+ when?: string;
1054
1070
  }
1055
1071
  interface SendStreamStepConfig$1 {
1056
1072
  name: string;
1057
1073
  message: string;
1058
1074
  enabled?: boolean;
1075
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1076
+ when?: string;
1059
1077
  }
1060
1078
  interface RetrieveRecordStepConfig$1 {
1061
1079
  name: string;
@@ -1066,6 +1084,8 @@ interface RetrieveRecordStepConfig$1 {
1066
1084
  outputVariable?: string;
1067
1085
  streamOutput?: boolean;
1068
1086
  enabled?: boolean;
1087
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1088
+ when?: string;
1069
1089
  }
1070
1090
  interface UpsertRecordStepConfig$1 {
1071
1091
  name: string;
@@ -1078,6 +1098,8 @@ interface UpsertRecordStepConfig$1 {
1078
1098
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1079
1099
  streamOutput?: boolean;
1080
1100
  enabled?: boolean;
1101
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1102
+ when?: string;
1081
1103
  }
1082
1104
  interface VectorSearchStepConfig$1 {
1083
1105
  name: string;
@@ -1089,6 +1111,8 @@ interface VectorSearchStepConfig$1 {
1089
1111
  outputVariable?: string;
1090
1112
  streamOutput?: boolean;
1091
1113
  enabled?: boolean;
1114
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1115
+ when?: string;
1092
1116
  }
1093
1117
  interface GenerateEmbeddingStepConfig$1 {
1094
1118
  name: string;
@@ -1098,6 +1122,8 @@ interface GenerateEmbeddingStepConfig$1 {
1098
1122
  outputVariable?: string;
1099
1123
  streamOutput?: boolean;
1100
1124
  enabled?: boolean;
1125
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1126
+ when?: string;
1101
1127
  }
1102
1128
  interface WaitUntilStepConfig$1 {
1103
1129
  name: string;
@@ -1114,6 +1140,8 @@ interface WaitUntilStepConfig$1 {
1114
1140
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1115
1141
  streamOutput?: boolean;
1116
1142
  enabled?: boolean;
1143
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1144
+ when?: string;
1117
1145
  }
1118
1146
  interface SendEventStepConfig$1 {
1119
1147
  name: string;
@@ -1125,6 +1153,8 @@ interface SendEventStepConfig$1 {
1125
1153
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1126
1154
  streamOutput?: boolean;
1127
1155
  enabled?: boolean;
1156
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1157
+ when?: string;
1128
1158
  }
1129
1159
  interface SendTextStepConfig$1 {
1130
1160
  name: string;
@@ -1136,6 +1166,8 @@ interface SendTextStepConfig$1 {
1136
1166
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1137
1167
  streamOutput?: boolean;
1138
1168
  enabled?: boolean;
1169
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1170
+ when?: string;
1139
1171
  }
1140
1172
  interface FetchGitHubStepConfig$1 {
1141
1173
  name: string;
@@ -1145,6 +1177,8 @@ interface FetchGitHubStepConfig$1 {
1145
1177
  outputVariable?: string;
1146
1178
  streamOutput?: boolean;
1147
1179
  enabled?: boolean;
1180
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1181
+ when?: string;
1148
1182
  }
1149
1183
  interface FlowConfig$1 {
1150
1184
  name: string;
@@ -1600,6 +1634,20 @@ declare class FlowBuilder {
1600
1634
  * ```
1601
1635
  */
1602
1636
  run(client: DispatchClient, options: DispatchOptions$1, callbacks: StreamCallbacks): Promise<FlowSummary>;
1637
+ /**
1638
+ * Set a run condition (when predicate) on the last added step.
1639
+ * If the expression evaluates to falsy at runtime, the step is skipped.
1640
+ *
1641
+ * @example
1642
+ * ```typescript
1643
+ * new FlowBuilder()
1644
+ * .createFlow({ name: 'Conditional' })
1645
+ * .prompt({ name: 'Summarize', model: 'gpt-4', userPrompt: '...' })
1646
+ * .when('data.length > 0')
1647
+ * .build()
1648
+ * ```
1649
+ */
1650
+ when(expression: string): this;
1603
1651
  private addStep;
1604
1652
  }
1605
1653
  /**
package/dist/index.d.ts CHANGED
@@ -960,6 +960,8 @@ interface PromptStepConfig$1 {
960
960
  /** Error handling configuration - supports simple mode or fallback chains */
961
961
  errorHandling?: ErrorHandlingMode | PromptErrorHandling;
962
962
  enabled?: boolean;
963
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
964
+ when?: string;
963
965
  }
964
966
  interface FetchUrlStepConfig$1 {
965
967
  name: string;
@@ -979,6 +981,8 @@ interface FetchUrlStepConfig$1 {
979
981
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
980
982
  streamOutput?: boolean;
981
983
  enabled?: boolean;
984
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
985
+ when?: string;
982
986
  }
983
987
  interface CrawlStepConfig {
984
988
  name: string;
@@ -1006,6 +1010,8 @@ interface CrawlStepConfig {
1006
1010
  pollIntervalMs?: number;
1007
1011
  completionTimeoutMs?: number;
1008
1012
  enabled?: boolean;
1013
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1014
+ when?: string;
1009
1015
  }
1010
1016
  interface TransformDataStepConfig$1 {
1011
1017
  name: string;
@@ -1014,12 +1020,16 @@ interface TransformDataStepConfig$1 {
1014
1020
  sandboxProvider?: 'quickjs' | 'daytona' | 'cloudflare-worker';
1015
1021
  streamOutput?: boolean;
1016
1022
  enabled?: boolean;
1023
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1024
+ when?: string;
1017
1025
  }
1018
1026
  interface SetVariableStepConfig$1 {
1019
1027
  name: string;
1020
1028
  variableName: string;
1021
1029
  value: string | number | boolean | object;
1022
1030
  enabled?: boolean;
1031
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1032
+ when?: string;
1023
1033
  }
1024
1034
  interface ConditionalStepConfig$1 {
1025
1035
  name: string;
@@ -1027,6 +1037,8 @@ interface ConditionalStepConfig$1 {
1027
1037
  trueSteps?: any[];
1028
1038
  falseSteps?: any[];
1029
1039
  enabled?: boolean;
1040
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1041
+ when?: string;
1030
1042
  }
1031
1043
  interface SearchStepConfig$1 {
1032
1044
  name: string;
@@ -1039,6 +1051,8 @@ interface SearchStepConfig$1 {
1039
1051
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1040
1052
  streamOutput?: boolean;
1041
1053
  enabled?: boolean;
1054
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1055
+ when?: string;
1042
1056
  }
1043
1057
  interface SendEmailStepConfig$1 {
1044
1058
  name: string;
@@ -1051,11 +1065,15 @@ interface SendEmailStepConfig$1 {
1051
1065
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1052
1066
  streamOutput?: boolean;
1053
1067
  enabled?: boolean;
1068
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1069
+ when?: string;
1054
1070
  }
1055
1071
  interface SendStreamStepConfig$1 {
1056
1072
  name: string;
1057
1073
  message: string;
1058
1074
  enabled?: boolean;
1075
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1076
+ when?: string;
1059
1077
  }
1060
1078
  interface RetrieveRecordStepConfig$1 {
1061
1079
  name: string;
@@ -1066,6 +1084,8 @@ interface RetrieveRecordStepConfig$1 {
1066
1084
  outputVariable?: string;
1067
1085
  streamOutput?: boolean;
1068
1086
  enabled?: boolean;
1087
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1088
+ when?: string;
1069
1089
  }
1070
1090
  interface UpsertRecordStepConfig$1 {
1071
1091
  name: string;
@@ -1078,6 +1098,8 @@ interface UpsertRecordStepConfig$1 {
1078
1098
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1079
1099
  streamOutput?: boolean;
1080
1100
  enabled?: boolean;
1101
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1102
+ when?: string;
1081
1103
  }
1082
1104
  interface VectorSearchStepConfig$1 {
1083
1105
  name: string;
@@ -1089,6 +1111,8 @@ interface VectorSearchStepConfig$1 {
1089
1111
  outputVariable?: string;
1090
1112
  streamOutput?: boolean;
1091
1113
  enabled?: boolean;
1114
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1115
+ when?: string;
1092
1116
  }
1093
1117
  interface GenerateEmbeddingStepConfig$1 {
1094
1118
  name: string;
@@ -1098,6 +1122,8 @@ interface GenerateEmbeddingStepConfig$1 {
1098
1122
  outputVariable?: string;
1099
1123
  streamOutput?: boolean;
1100
1124
  enabled?: boolean;
1125
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1126
+ when?: string;
1101
1127
  }
1102
1128
  interface WaitUntilStepConfig$1 {
1103
1129
  name: string;
@@ -1114,6 +1140,8 @@ interface WaitUntilStepConfig$1 {
1114
1140
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1115
1141
  streamOutput?: boolean;
1116
1142
  enabled?: boolean;
1143
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1144
+ when?: string;
1117
1145
  }
1118
1146
  interface SendEventStepConfig$1 {
1119
1147
  name: string;
@@ -1125,6 +1153,8 @@ interface SendEventStepConfig$1 {
1125
1153
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1126
1154
  streamOutput?: boolean;
1127
1155
  enabled?: boolean;
1156
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1157
+ when?: string;
1128
1158
  }
1129
1159
  interface SendTextStepConfig$1 {
1130
1160
  name: string;
@@ -1136,6 +1166,8 @@ interface SendTextStepConfig$1 {
1136
1166
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1137
1167
  streamOutput?: boolean;
1138
1168
  enabled?: boolean;
1169
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1170
+ when?: string;
1139
1171
  }
1140
1172
  interface FetchGitHubStepConfig$1 {
1141
1173
  name: string;
@@ -1145,6 +1177,8 @@ interface FetchGitHubStepConfig$1 {
1145
1177
  outputVariable?: string;
1146
1178
  streamOutput?: boolean;
1147
1179
  enabled?: boolean;
1180
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1181
+ when?: string;
1148
1182
  }
1149
1183
  interface FlowConfig$1 {
1150
1184
  name: string;
@@ -1600,6 +1634,20 @@ declare class FlowBuilder {
1600
1634
  * ```
1601
1635
  */
1602
1636
  run(client: DispatchClient, options: DispatchOptions$1, callbacks: StreamCallbacks): Promise<FlowSummary>;
1637
+ /**
1638
+ * Set a run condition (when predicate) on the last added step.
1639
+ * If the expression evaluates to falsy at runtime, the step is skipped.
1640
+ *
1641
+ * @example
1642
+ * ```typescript
1643
+ * new FlowBuilder()
1644
+ * .createFlow({ name: 'Conditional' })
1645
+ * .prompt({ name: 'Summarize', model: 'gpt-4', userPrompt: '...' })
1646
+ * .when('data.length > 0')
1647
+ * .build()
1648
+ * ```
1649
+ */
1650
+ when(expression: string): this;
1603
1651
  private addStep;
1604
1652
  }
1605
1653
  /**
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.0",
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",