@runtypelabs/sdk 1.18.0 → 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
@@ -376,7 +376,8 @@ interface Tool {
376
376
  }
377
377
  type ToolConfig = FlowToolConfig | CustomToolConfig | ExternalToolConfig | LocalToolConfig | SubagentToolConfig;
378
378
  interface FlowToolConfig {
379
- flowId: string;
379
+ flowId?: string;
380
+ toolId?: string;
380
381
  parameterMapping: Record<string, string>;
381
382
  outputMapping?: string;
382
383
  }
@@ -596,7 +597,8 @@ interface RuntimeLocalToolConfig {
596
597
  [key: string]: JsonValue;
597
598
  }
598
599
  interface RuntimeFlowToolConfig {
599
- flowId: string;
600
+ flowId?: string;
601
+ toolId?: string;
600
602
  parameterMapping?: Record<string, string>;
601
603
  outputMapping?: string;
602
604
  }
@@ -958,6 +960,8 @@ interface PromptStepConfig$1 {
958
960
  /** Error handling configuration - supports simple mode or fallback chains */
959
961
  errorHandling?: ErrorHandlingMode | PromptErrorHandling;
960
962
  enabled?: boolean;
963
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
964
+ when?: string;
961
965
  }
962
966
  interface FetchUrlStepConfig$1 {
963
967
  name: string;
@@ -977,6 +981,8 @@ interface FetchUrlStepConfig$1 {
977
981
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
978
982
  streamOutput?: boolean;
979
983
  enabled?: boolean;
984
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
985
+ when?: string;
980
986
  }
981
987
  interface CrawlStepConfig {
982
988
  name: string;
@@ -1004,6 +1010,8 @@ interface CrawlStepConfig {
1004
1010
  pollIntervalMs?: number;
1005
1011
  completionTimeoutMs?: number;
1006
1012
  enabled?: boolean;
1013
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1014
+ when?: string;
1007
1015
  }
1008
1016
  interface TransformDataStepConfig$1 {
1009
1017
  name: string;
@@ -1012,12 +1020,16 @@ interface TransformDataStepConfig$1 {
1012
1020
  sandboxProvider?: 'quickjs' | 'daytona' | 'cloudflare-worker';
1013
1021
  streamOutput?: boolean;
1014
1022
  enabled?: boolean;
1023
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1024
+ when?: string;
1015
1025
  }
1016
1026
  interface SetVariableStepConfig$1 {
1017
1027
  name: string;
1018
1028
  variableName: string;
1019
1029
  value: string | number | boolean | object;
1020
1030
  enabled?: boolean;
1031
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1032
+ when?: string;
1021
1033
  }
1022
1034
  interface ConditionalStepConfig$1 {
1023
1035
  name: string;
@@ -1025,6 +1037,8 @@ interface ConditionalStepConfig$1 {
1025
1037
  trueSteps?: any[];
1026
1038
  falseSteps?: any[];
1027
1039
  enabled?: boolean;
1040
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1041
+ when?: string;
1028
1042
  }
1029
1043
  interface SearchStepConfig$1 {
1030
1044
  name: string;
@@ -1037,6 +1051,8 @@ interface SearchStepConfig$1 {
1037
1051
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1038
1052
  streamOutput?: boolean;
1039
1053
  enabled?: boolean;
1054
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1055
+ when?: string;
1040
1056
  }
1041
1057
  interface SendEmailStepConfig$1 {
1042
1058
  name: string;
@@ -1049,11 +1065,15 @@ interface SendEmailStepConfig$1 {
1049
1065
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1050
1066
  streamOutput?: boolean;
1051
1067
  enabled?: boolean;
1068
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1069
+ when?: string;
1052
1070
  }
1053
1071
  interface SendStreamStepConfig$1 {
1054
1072
  name: string;
1055
1073
  message: string;
1056
1074
  enabled?: boolean;
1075
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1076
+ when?: string;
1057
1077
  }
1058
1078
  interface RetrieveRecordStepConfig$1 {
1059
1079
  name: string;
@@ -1064,6 +1084,8 @@ interface RetrieveRecordStepConfig$1 {
1064
1084
  outputVariable?: string;
1065
1085
  streamOutput?: boolean;
1066
1086
  enabled?: boolean;
1087
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1088
+ when?: string;
1067
1089
  }
1068
1090
  interface UpsertRecordStepConfig$1 {
1069
1091
  name: string;
@@ -1076,6 +1098,8 @@ interface UpsertRecordStepConfig$1 {
1076
1098
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1077
1099
  streamOutput?: boolean;
1078
1100
  enabled?: boolean;
1101
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1102
+ when?: string;
1079
1103
  }
1080
1104
  interface VectorSearchStepConfig$1 {
1081
1105
  name: string;
@@ -1087,6 +1111,8 @@ interface VectorSearchStepConfig$1 {
1087
1111
  outputVariable?: string;
1088
1112
  streamOutput?: boolean;
1089
1113
  enabled?: boolean;
1114
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1115
+ when?: string;
1090
1116
  }
1091
1117
  interface GenerateEmbeddingStepConfig$1 {
1092
1118
  name: string;
@@ -1096,6 +1122,8 @@ interface GenerateEmbeddingStepConfig$1 {
1096
1122
  outputVariable?: string;
1097
1123
  streamOutput?: boolean;
1098
1124
  enabled?: boolean;
1125
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1126
+ when?: string;
1099
1127
  }
1100
1128
  interface WaitUntilStepConfig$1 {
1101
1129
  name: string;
@@ -1112,6 +1140,8 @@ interface WaitUntilStepConfig$1 {
1112
1140
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1113
1141
  streamOutput?: boolean;
1114
1142
  enabled?: boolean;
1143
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1144
+ when?: string;
1115
1145
  }
1116
1146
  interface SendEventStepConfig$1 {
1117
1147
  name: string;
@@ -1123,6 +1153,8 @@ interface SendEventStepConfig$1 {
1123
1153
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1124
1154
  streamOutput?: boolean;
1125
1155
  enabled?: boolean;
1156
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1157
+ when?: string;
1126
1158
  }
1127
1159
  interface SendTextStepConfig$1 {
1128
1160
  name: string;
@@ -1134,6 +1166,8 @@ interface SendTextStepConfig$1 {
1134
1166
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1135
1167
  streamOutput?: boolean;
1136
1168
  enabled?: boolean;
1169
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1170
+ when?: string;
1137
1171
  }
1138
1172
  interface FetchGitHubStepConfig$1 {
1139
1173
  name: string;
@@ -1143,6 +1177,8 @@ interface FetchGitHubStepConfig$1 {
1143
1177
  outputVariable?: string;
1144
1178
  streamOutput?: boolean;
1145
1179
  enabled?: boolean;
1180
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1181
+ when?: string;
1146
1182
  }
1147
1183
  interface FlowConfig$1 {
1148
1184
  name: string;
@@ -1598,6 +1634,20 @@ declare class FlowBuilder {
1598
1634
  * ```
1599
1635
  */
1600
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;
1601
1651
  private addStep;
1602
1652
  }
1603
1653
  /**
package/dist/index.d.ts CHANGED
@@ -376,7 +376,8 @@ interface Tool {
376
376
  }
377
377
  type ToolConfig = FlowToolConfig | CustomToolConfig | ExternalToolConfig | LocalToolConfig | SubagentToolConfig;
378
378
  interface FlowToolConfig {
379
- flowId: string;
379
+ flowId?: string;
380
+ toolId?: string;
380
381
  parameterMapping: Record<string, string>;
381
382
  outputMapping?: string;
382
383
  }
@@ -596,7 +597,8 @@ interface RuntimeLocalToolConfig {
596
597
  [key: string]: JsonValue;
597
598
  }
598
599
  interface RuntimeFlowToolConfig {
599
- flowId: string;
600
+ flowId?: string;
601
+ toolId?: string;
600
602
  parameterMapping?: Record<string, string>;
601
603
  outputMapping?: string;
602
604
  }
@@ -958,6 +960,8 @@ interface PromptStepConfig$1 {
958
960
  /** Error handling configuration - supports simple mode or fallback chains */
959
961
  errorHandling?: ErrorHandlingMode | PromptErrorHandling;
960
962
  enabled?: boolean;
963
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
964
+ when?: string;
961
965
  }
962
966
  interface FetchUrlStepConfig$1 {
963
967
  name: string;
@@ -977,6 +981,8 @@ interface FetchUrlStepConfig$1 {
977
981
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
978
982
  streamOutput?: boolean;
979
983
  enabled?: boolean;
984
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
985
+ when?: string;
980
986
  }
981
987
  interface CrawlStepConfig {
982
988
  name: string;
@@ -1004,6 +1010,8 @@ interface CrawlStepConfig {
1004
1010
  pollIntervalMs?: number;
1005
1011
  completionTimeoutMs?: number;
1006
1012
  enabled?: boolean;
1013
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1014
+ when?: string;
1007
1015
  }
1008
1016
  interface TransformDataStepConfig$1 {
1009
1017
  name: string;
@@ -1012,12 +1020,16 @@ interface TransformDataStepConfig$1 {
1012
1020
  sandboxProvider?: 'quickjs' | 'daytona' | 'cloudflare-worker';
1013
1021
  streamOutput?: boolean;
1014
1022
  enabled?: boolean;
1023
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1024
+ when?: string;
1015
1025
  }
1016
1026
  interface SetVariableStepConfig$1 {
1017
1027
  name: string;
1018
1028
  variableName: string;
1019
1029
  value: string | number | boolean | object;
1020
1030
  enabled?: boolean;
1031
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1032
+ when?: string;
1021
1033
  }
1022
1034
  interface ConditionalStepConfig$1 {
1023
1035
  name: string;
@@ -1025,6 +1037,8 @@ interface ConditionalStepConfig$1 {
1025
1037
  trueSteps?: any[];
1026
1038
  falseSteps?: any[];
1027
1039
  enabled?: boolean;
1040
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1041
+ when?: string;
1028
1042
  }
1029
1043
  interface SearchStepConfig$1 {
1030
1044
  name: string;
@@ -1037,6 +1051,8 @@ interface SearchStepConfig$1 {
1037
1051
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1038
1052
  streamOutput?: boolean;
1039
1053
  enabled?: boolean;
1054
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1055
+ when?: string;
1040
1056
  }
1041
1057
  interface SendEmailStepConfig$1 {
1042
1058
  name: string;
@@ -1049,11 +1065,15 @@ interface SendEmailStepConfig$1 {
1049
1065
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1050
1066
  streamOutput?: boolean;
1051
1067
  enabled?: boolean;
1068
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1069
+ when?: string;
1052
1070
  }
1053
1071
  interface SendStreamStepConfig$1 {
1054
1072
  name: string;
1055
1073
  message: string;
1056
1074
  enabled?: boolean;
1075
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1076
+ when?: string;
1057
1077
  }
1058
1078
  interface RetrieveRecordStepConfig$1 {
1059
1079
  name: string;
@@ -1064,6 +1084,8 @@ interface RetrieveRecordStepConfig$1 {
1064
1084
  outputVariable?: string;
1065
1085
  streamOutput?: boolean;
1066
1086
  enabled?: boolean;
1087
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1088
+ when?: string;
1067
1089
  }
1068
1090
  interface UpsertRecordStepConfig$1 {
1069
1091
  name: string;
@@ -1076,6 +1098,8 @@ interface UpsertRecordStepConfig$1 {
1076
1098
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1077
1099
  streamOutput?: boolean;
1078
1100
  enabled?: boolean;
1101
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1102
+ when?: string;
1079
1103
  }
1080
1104
  interface VectorSearchStepConfig$1 {
1081
1105
  name: string;
@@ -1087,6 +1111,8 @@ interface VectorSearchStepConfig$1 {
1087
1111
  outputVariable?: string;
1088
1112
  streamOutput?: boolean;
1089
1113
  enabled?: boolean;
1114
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1115
+ when?: string;
1090
1116
  }
1091
1117
  interface GenerateEmbeddingStepConfig$1 {
1092
1118
  name: string;
@@ -1096,6 +1122,8 @@ interface GenerateEmbeddingStepConfig$1 {
1096
1122
  outputVariable?: string;
1097
1123
  streamOutput?: boolean;
1098
1124
  enabled?: boolean;
1125
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1126
+ when?: string;
1099
1127
  }
1100
1128
  interface WaitUntilStepConfig$1 {
1101
1129
  name: string;
@@ -1112,6 +1140,8 @@ interface WaitUntilStepConfig$1 {
1112
1140
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1113
1141
  streamOutput?: boolean;
1114
1142
  enabled?: boolean;
1143
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1144
+ when?: string;
1115
1145
  }
1116
1146
  interface SendEventStepConfig$1 {
1117
1147
  name: string;
@@ -1123,6 +1153,8 @@ interface SendEventStepConfig$1 {
1123
1153
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1124
1154
  streamOutput?: boolean;
1125
1155
  enabled?: boolean;
1156
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1157
+ when?: string;
1126
1158
  }
1127
1159
  interface SendTextStepConfig$1 {
1128
1160
  name: string;
@@ -1134,6 +1166,8 @@ interface SendTextStepConfig$1 {
1134
1166
  errorHandling?: ErrorHandlingMode | ContextErrorHandling;
1135
1167
  streamOutput?: boolean;
1136
1168
  enabled?: boolean;
1169
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1170
+ when?: string;
1137
1171
  }
1138
1172
  interface FetchGitHubStepConfig$1 {
1139
1173
  name: string;
@@ -1143,6 +1177,8 @@ interface FetchGitHubStepConfig$1 {
1143
1177
  outputVariable?: string;
1144
1178
  streamOutput?: boolean;
1145
1179
  enabled?: boolean;
1180
+ /** JavaScript predicate evaluated at runtime. If falsy, the step is skipped. */
1181
+ when?: string;
1146
1182
  }
1147
1183
  interface FlowConfig$1 {
1148
1184
  name: string;
@@ -1598,6 +1634,20 @@ declare class FlowBuilder {
1598
1634
  * ```
1599
1635
  */
1600
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;
1601
1651
  private addStep;
1602
1652
  }
1603
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.0",
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",