@valerypopoff/rivet2-core 2.15.0 → 2.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.
Files changed (187) hide show
  1. package/dist/cjs/bundle.cjs +7906 -3980
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/cjs/interpolationRuntime.cjs +62 -7
  4. package/dist/cjs/interpolationRuntime.cjs.map +3 -3
  5. package/dist/cjs/interpolationSyntax.cjs +9 -5
  6. package/dist/cjs/interpolationSyntax.cjs.map +2 -2
  7. package/dist/cjs/serialization.cjs +1880 -0
  8. package/dist/cjs/serialization.cjs.map +7 -0
  9. package/dist/cjs/webAppRuntime.cjs +168 -6
  10. package/dist/cjs/webAppRuntime.cjs.map +3 -3
  11. package/dist/esm/api/createProcessor.js +5 -2
  12. package/dist/esm/api/processSettings.js +1 -0
  13. package/dist/esm/exports.js +4 -0
  14. package/dist/esm/model/AgentResponseTrace.js +99 -34
  15. package/dist/esm/model/AgentResponseTracePresentation.js +130 -0
  16. package/dist/esm/model/DataValue.js +11 -2
  17. package/dist/esm/model/GlobalVariables.js +2 -1
  18. package/dist/esm/model/GraphBoundaryCache.js +2 -1
  19. package/dist/esm/model/GraphBoundaryEffects.js +38 -1
  20. package/dist/esm/model/GraphExecutionState.js +81 -0
  21. package/dist/esm/model/GraphProcessor.js +825 -884
  22. package/dist/esm/model/GraphSchedulerBoundaryState.js +64 -0
  23. package/dist/esm/model/Nodes.js +15 -0
  24. package/dist/esm/model/ProjectBundle.js +248 -0
  25. package/dist/esm/model/ProjectBundleRuntime.js +54 -0
  26. package/dist/esm/model/SchedulerBoundaryPlanner.js +233 -0
  27. package/dist/esm/model/SplitRunProcessor.js +28 -7
  28. package/dist/esm/model/StreamingWatchTopology.js +118 -8
  29. package/dist/esm/model/SubgraphProjectTarget.js +7 -0
  30. package/dist/esm/model/SubprocessorBridge.js +125 -87
  31. package/dist/esm/model/ToolCallContinuationCoordinator.js +1 -1
  32. package/dist/esm/model/chat-v2/aiSdkBridge.js +22 -17
  33. package/dist/esm/model/chat-v2/chatV2CallObserver.js +2 -4
  34. package/dist/esm/model/chat-v2/chatV2CredentialNames.js +5 -1
  35. package/dist/esm/model/chat-v2/chatV2Outputs.js +2 -2
  36. package/dist/esm/model/chat-v2/chatV2Pipeline.js +24 -9
  37. package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +3 -2
  38. package/dist/esm/model/chat-v2/chatV2ProviderRegistry.js +46 -6
  39. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +26 -1
  40. package/dist/esm/model/chat-v2/chatV2Shared.js +2 -1
  41. package/dist/esm/model/chat-v2/chatV2UsageAccounting.js +10 -0
  42. package/dist/esm/model/chat-v2/llmChatV2Body.js +13 -10
  43. package/dist/esm/model/chat-v2/llmChatV2CacheBoundary.js +5 -2
  44. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +3 -0
  45. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +33 -9
  46. package/dist/esm/model/chat-v2/llmChatV2NodeMigration.js +22 -2
  47. package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +10 -2
  48. package/dist/esm/model/chat-v2/llmInvocationResultProjector.js +17 -0
  49. package/dist/esm/model/chat-v2/llmModelCandidate.js +2 -1
  50. package/dist/esm/model/chat-v2/llmProfile.js +5 -1
  51. package/dist/esm/model/chat-v2/llmProfileBody.js +11 -2
  52. package/dist/esm/model/chat-v2/llmProfileFallback.js +7 -4
  53. package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +2 -1
  54. package/dist/esm/model/chat-v2/llmProfileHealthStore.js +16 -3
  55. package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +1 -1
  56. package/dist/esm/model/chat-v2/messageConverter.js +18 -16
  57. package/dist/esm/model/chat-v2/modelRegistry.js +14 -4
  58. package/dist/esm/model/chat-v2/openRouterModel.js +73 -0
  59. package/dist/esm/model/chat-v2/parallelToolCalls.js +2 -0
  60. package/dist/esm/model/chat-v2/providerOptions.js +30 -25
  61. package/dist/esm/model/chat-v2/temperature.js +9 -0
  62. package/dist/esm/model/classifier/credentials.js +42 -6
  63. package/dist/esm/model/classifier/images.js +176 -0
  64. package/dist/esm/model/classifier/json.js +57 -0
  65. package/dist/esm/model/classifier/limits.js +300 -0
  66. package/dist/esm/model/classifier/openai.js +118 -0
  67. package/dist/esm/model/classifier/perplexity.js +63 -0
  68. package/dist/esm/model/classifier/preparation.js +74 -0
  69. package/dist/esm/model/classifier/profile.js +151 -0
  70. package/dist/esm/model/classifier/profileExecution.js +294 -0
  71. package/dist/esm/model/classifier/providers.js +454 -192
  72. package/dist/esm/model/classifier/questionHelpers.js +29 -45
  73. package/dist/esm/model/classifier/questions.js +53 -0
  74. package/dist/esm/model/classifier/response.js +75 -0
  75. package/dist/esm/model/classifier/state.js +207 -0
  76. package/dist/esm/model/classifier/types.js +11 -1
  77. package/dist/esm/model/nodeRunFailure.js +54 -0
  78. package/dist/esm/model/nodes/CallGraphNode.js +6 -0
  79. package/dist/esm/model/nodes/CatchStreamingChunksNode.js +42 -0
  80. package/dist/esm/model/nodes/ClassifierEvaluateNode.js +385 -154
  81. package/dist/esm/model/nodes/ClassifierProfileNode.js +133 -0
  82. package/dist/esm/model/nodes/ClassifierQuestionNode.js +59 -15
  83. package/dist/esm/model/nodes/DelegateFunctionCallNode.js +1 -1
  84. package/dist/esm/model/nodes/GetGlobalNode.js +2 -2
  85. package/dist/esm/model/nodes/HttpCallNode.js +44 -75
  86. package/dist/esm/model/nodes/ImageNode.js +44 -3
  87. package/dist/esm/model/nodes/LLMChatV2Node.js +26 -4
  88. package/dist/esm/model/nodes/ObjectNode.js +29 -18
  89. package/dist/esm/model/nodes/PromptNode.js +2 -1
  90. package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +4 -1
  91. package/dist/esm/model/nodes/SetGlobalNode.js +5 -3
  92. package/dist/esm/model/nodes/StopWatchingStreamingOutputNode.js +8 -8
  93. package/dist/esm/model/nodes/StreamValueNode.js +38 -0
  94. package/dist/esm/model/nodes/SubGraphNode.js +199 -35
  95. package/dist/esm/model/nodes/ToBase64Node.js +106 -0
  96. package/dist/esm/model/nodes/WatchStreamingOutputNode.js +7 -7
  97. package/dist/esm/model/nodes/toolCallDelegation.js +5 -1
  98. package/dist/esm/model/profileSuspensionHints.js +8 -0
  99. package/dist/esm/recording/ExecutionRecorder.js +26 -0
  100. package/dist/esm/serialization.js +2 -0
  101. package/dist/esm/utils/base64.js +18 -15
  102. package/dist/esm/utils/coerceType.js +11 -1
  103. package/dist/esm/utils/errors.js +41 -0
  104. package/dist/esm/utils/interpolation.js +44 -22
  105. package/dist/esm/utils/interpolationSyntax.js +15 -6
  106. package/dist/esm/utils/serialization/serialization.js +3 -2
  107. package/dist/esm/utils/serialization/serializationUtils.js +6 -0
  108. package/dist/esm/utils/serialization/serialization_v4.js +15 -3
  109. package/dist/esm/webAppRuntime.js +1 -0
  110. package/dist/types/api/createProcessor.d.ts +7 -1
  111. package/dist/types/exports.d.ts +4 -0
  112. package/dist/types/model/AgentResponseTrace.d.ts +15 -4
  113. package/dist/types/model/AgentResponseTracePresentation.d.ts +15 -0
  114. package/dist/types/model/CycleDetector.d.ts +1 -2
  115. package/dist/types/model/DataValue.d.ts +12 -8
  116. package/dist/types/model/ExecutorProtocol.d.ts +9 -0
  117. package/dist/types/model/GraphBoundaryCache.d.ts +2 -0
  118. package/dist/types/model/GraphBoundaryEffects.d.ts +10 -1
  119. package/dist/types/model/GraphExecutionState.d.ts +68 -0
  120. package/dist/types/model/GraphProcessor.d.ts +2 -0
  121. package/dist/types/model/GraphSchedulerBoundaryState.d.ts +96 -0
  122. package/dist/types/model/Nodes.d.ts +11 -4
  123. package/dist/types/model/ProcessContext.d.ts +24 -3
  124. package/dist/types/model/ProjectBundle.d.ts +59 -0
  125. package/dist/types/model/ProjectBundleRuntime.d.ts +24 -0
  126. package/dist/types/model/ProjectReferenceLoader.d.ts +3 -0
  127. package/dist/types/model/RivetUIContext.d.ts +1 -1
  128. package/dist/types/model/SchedulerBoundaryPlanner.d.ts +42 -0
  129. package/dist/types/model/Settings.d.ts +1 -0
  130. package/dist/types/model/StreamingWatchTopology.d.ts +11 -1
  131. package/dist/types/model/SubgraphProjectTarget.d.ts +38 -0
  132. package/dist/types/model/SubprocessorBridge.d.ts +2 -0
  133. package/dist/types/model/chat-v2/chatV2CredentialNames.d.ts +4 -0
  134. package/dist/types/model/chat-v2/chatV2Outputs.d.ts +1 -1
  135. package/dist/types/model/chat-v2/chatV2ProviderRegistry.d.ts +79 -1
  136. package/dist/types/model/chat-v2/chatV2ProviderTypes.d.ts +1 -1
  137. package/dist/types/model/chat-v2/chatV2Shared.d.ts +1 -1
  138. package/dist/types/model/chat-v2/chatV2UsageAccounting.d.ts +2 -0
  139. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +4 -1
  140. package/dist/types/model/chat-v2/llmChatV2NodeMigration.d.ts +3 -1
  141. package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +2 -0
  142. package/dist/types/model/chat-v2/llmInvocationResultProjector.d.ts +2 -0
  143. package/dist/types/model/chat-v2/llmProfileFallback.d.ts +51 -3
  144. package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +10 -7
  145. package/dist/types/model/chat-v2/llmProfileHealthStore.d.ts +6 -2
  146. package/dist/types/model/chat-v2/modelRegistry.d.ts +5 -4
  147. package/dist/types/model/chat-v2/openRouterModel.d.ts +2 -0
  148. package/dist/types/model/chat-v2/providerOptions.d.ts +2 -13
  149. package/dist/types/model/chat-v2/temperature.d.ts +2 -0
  150. package/dist/types/model/classifier/credentials.d.ts +7 -1
  151. package/dist/types/model/classifier/images.d.ts +18 -0
  152. package/dist/types/model/classifier/json.d.ts +19 -0
  153. package/dist/types/model/classifier/limits.d.ts +45 -0
  154. package/dist/types/model/classifier/openai.d.ts +5 -0
  155. package/dist/types/model/classifier/perplexity.d.ts +7 -0
  156. package/dist/types/model/classifier/preparation.d.ts +16 -0
  157. package/dist/types/model/classifier/profile.d.ts +46 -0
  158. package/dist/types/model/classifier/profileExecution.d.ts +32 -0
  159. package/dist/types/model/classifier/providers.d.ts +98 -9
  160. package/dist/types/model/classifier/questionHelpers.d.ts +6 -4
  161. package/dist/types/model/classifier/questions.d.ts +4 -0
  162. package/dist/types/model/classifier/response.d.ts +4 -0
  163. package/dist/types/model/classifier/state.d.ts +37 -0
  164. package/dist/types/model/classifier/types.d.ts +11 -0
  165. package/dist/types/model/nodeRunFailure.d.ts +13 -0
  166. package/dist/types/model/nodes/CatchStreamingChunksNode.d.ts +20 -0
  167. package/dist/types/model/nodes/ClassifierEvaluateNode.d.ts +17 -12
  168. package/dist/types/model/nodes/ClassifierProfileNode.d.ts +20 -0
  169. package/dist/types/model/nodes/GetGlobalNode.d.ts +7 -0
  170. package/dist/types/model/nodes/ImageNode.d.ts +4 -0
  171. package/dist/types/model/nodes/LLMChatV2Node.d.ts +1 -0
  172. package/dist/types/model/nodes/ObjectNode.d.ts +2 -1
  173. package/dist/types/model/nodes/StreamValueNode.d.ts +14 -0
  174. package/dist/types/model/nodes/SubGraphNode.d.ts +21 -2
  175. package/dist/types/model/nodes/ToBase64Node.d.ts +12 -0
  176. package/dist/types/model/nodes/toolCallDelegation.d.ts +3 -1
  177. package/dist/types/model/profileSuspensionHints.d.ts +8 -0
  178. package/dist/types/recording/ExecutionRecorder.d.ts +8 -2
  179. package/dist/types/serialization.d.ts +2 -0
  180. package/dist/types/utils/base64.d.ts +1 -1
  181. package/dist/types/utils/errors.d.ts +4 -0
  182. package/dist/types/utils/interpolation.d.ts +13 -2
  183. package/dist/types/utils/interpolationSyntax.d.ts +1 -1
  184. package/dist/types/utils/serialization/serialization.d.ts +3 -1
  185. package/dist/types/utils/serialization/serializationUtils.d.ts +1 -0
  186. package/dist/types/webAppRuntime.d.ts +1 -0
  187. package/package.json +7 -1
@@ -0,0 +1,133 @@
1
+ import { nanoid } from 'nanoid/non-secure';
2
+ import { NodeImpl } from '../NodeImpl.js';
3
+ import { nodeDefinition } from '../NodeDefinition.js';
4
+ import { resolveClassifierProfile, DEFAULT_CLASSIFIER_PROFILE_RESPONSE_TIMEOUT_MS, DEFAULT_CLASSIFIER_PROFILE_FAILURE_THRESHOLD, DEFAULT_CLASSIFIER_PROFILE_FAILURE_WINDOW_MS, DEFAULT_CLASSIFIER_PROFILE_OPEN_DURATION_MS, } from '../classifier/profile.js';
5
+ import { getClassifierModelEditor, getClassifierEvaluateBodySections } from './ClassifierEvaluateNode.js';
6
+ import { formatNodeBodyMarkdownField } from '../nodeBodyMarkdown.js';
7
+ import { profileSuspensionHints } from '../profileSuspensionHints.js';
8
+ export class ClassifierProfileNodeImpl extends NodeImpl {
9
+ static create() {
10
+ return {
11
+ type: 'classifierProfile',
12
+ title: 'Classifier Profile',
13
+ id: nanoid(),
14
+ visualData: { x: 0, y: 0, width: 260 },
15
+ data: { provider: 'jev', responseTimeoutMs: DEFAULT_CLASSIFIER_PROFILE_RESPONSE_TIMEOUT_MS },
16
+ };
17
+ }
18
+ getInputDefinitions() {
19
+ return [
20
+ ...(this.data.useModelInput
21
+ ? [{ id: 'model', title: 'Model', dataType: 'string', required: true }]
22
+ : []),
23
+ ...(this.data.apiKeySource === 'input'
24
+ ? [{ id: 'apiKey', title: 'API Key', dataType: 'string', required: false }]
25
+ : []),
26
+ ];
27
+ }
28
+ getOutputDefinitions() {
29
+ return [
30
+ {
31
+ id: 'profile',
32
+ title: 'Profile',
33
+ dataType: 'classifier-config',
34
+ description: 'Sensitive resolved classifier configuration. Combine profiles with Array for ordered fallback.',
35
+ },
36
+ ];
37
+ }
38
+ getEditors() {
39
+ return [
40
+ getClassifierModelEditor(this.data),
41
+ {
42
+ type: 'group',
43
+ label: 'Classifier profile suspension',
44
+ editors: [
45
+ {
46
+ type: 'info',
47
+ label: "It's a hosted runtime capability",
48
+ helperMessage: profileSuspensionHints.host,
49
+ },
50
+ {
51
+ type: 'toggle',
52
+ label: 'Enable automatic suspension',
53
+ dataKey: 'enableCircuitBreaker',
54
+ helperMessage: profileSuspensionHints.enable,
55
+ },
56
+ {
57
+ type: 'number',
58
+ label: 'Response timeout, seconds',
59
+ dataKey: 'responseTimeoutMs',
60
+ defaultValue: DEFAULT_CLASSIFIER_PROFILE_RESPONSE_TIMEOUT_MS,
61
+ storageMultiplier: 1_000,
62
+ min: 1,
63
+ max: 600_000,
64
+ step: 1,
65
+ helperMessage: 'Batch time limit, including retries and retry waits. Minimum 0.001 s.',
66
+ hideIf: (data) => data.enableCircuitBreaker !== true,
67
+ },
68
+ {
69
+ type: 'number',
70
+ label: 'Failures before suspension',
71
+ dataKey: 'circuitBreakerFailureThreshold',
72
+ defaultValue: DEFAULT_CLASSIFIER_PROFILE_FAILURE_THRESHOLD,
73
+ min: 1,
74
+ max: 1000,
75
+ step: 1,
76
+ helperMessage: profileSuspensionHints.threshold,
77
+ hideIf: (data) => data.enableCircuitBreaker !== true,
78
+ },
79
+ {
80
+ type: 'number',
81
+ label: 'Failure window, seconds',
82
+ dataKey: 'circuitBreakerFailureWindowMs',
83
+ defaultValue: DEFAULT_CLASSIFIER_PROFILE_FAILURE_WINDOW_MS,
84
+ storageMultiplier: 1_000,
85
+ min: 1_000,
86
+ max: 86_400_000,
87
+ step: 1_000,
88
+ helperMessage: profileSuspensionHints.window,
89
+ hideIf: (data) => data.enableCircuitBreaker !== true,
90
+ },
91
+ {
92
+ type: 'number',
93
+ label: 'Suspension duration, seconds',
94
+ dataKey: 'circuitBreakerOpenDurationMs',
95
+ defaultValue: DEFAULT_CLASSIFIER_PROFILE_OPEN_DURATION_MS,
96
+ storageMultiplier: 1_000,
97
+ min: 1_000,
98
+ max: 86_400_000,
99
+ step: 1_000,
100
+ helperMessage: profileSuspensionHints.duration,
101
+ hideIf: (data) => data.enableCircuitBreaker !== true,
102
+ },
103
+ ],
104
+ },
105
+ ];
106
+ }
107
+ getBody() {
108
+ return {
109
+ type: 'markdown',
110
+ text: getClassifierEvaluateBodySections(this.data)
111
+ .filter((section) => section.id === 'configuration')
112
+ .flatMap((section) => section.fields)
113
+ .map((field) => formatNodeBodyMarkdownField(field.label, field.value))
114
+ .join('') +
115
+ formatNodeBodyMarkdownField('Automatic suspension', this.data.enableCircuitBreaker ? 'Enabled' : 'Disabled'),
116
+ };
117
+ }
118
+ static getUIData() {
119
+ return {
120
+ contextMenuTitle: 'Classifier Profile',
121
+ infoBoxTitle: 'Classifier Profile',
122
+ infoBoxBody: 'Reusable classifier provider/model/credential configuration. Combine profiles with Array for ordered fallback.',
123
+ group: ['Classifier'],
124
+ };
125
+ }
126
+ async process(inputs, context) {
127
+ context.signal.throwIfAborted();
128
+ return {
129
+ ['profile']: { type: 'classifier-config', value: resolveClassifierProfile(this.data, inputs, context) },
130
+ };
131
+ }
132
+ }
133
+ export const classifierProfileNode = nodeDefinition(ClassifierProfileNodeImpl, 'Classifier Profile');
@@ -2,8 +2,13 @@ import { nanoid } from 'nanoid/non-secure';
2
2
  import { nodeDefinition } from '../NodeDefinition.js';
3
3
  import { NodeImpl } from '../NodeImpl.js';
4
4
  import { formatNodeBodyMarkdownField, formatNodeBodyMarkdownSeparator, formatNodeBodyMarkdownTextRow, } from '../nodeBodyMarkdown.js';
5
- import { abbreviate, assertClassifierEntry, assertClassifierInstructions, getCriteriaInputDefinition, getInstructionsInputDefinition, getInterpolationInputDefinitions, getStringInput, getStructuredInput, interpolateQuestionText, requireQuestionId, resolveAuthoredClassifierEntry, } from '../classifier/questionHelpers.js';
6
- const defaultOptions = () => [{ key: '', value: '' }, { key: '', value: '' }];
5
+ import { ClassifierQuestionPreparation } from '../classifier/preparation.js';
6
+ import { assertClassifierJson } from '../classifier/json.js';
7
+ import { abbreviate, assertClassifierEntry, assertClassifierInstructions, getCriteriaInputDefinition, getInstructionsInputDefinition, getInterpolationInputDefinitions, getQuestionInputValue, getStringInput, getStructuredInput, interpolateQuestionText, requireQuestionId, resolveAuthoredClassifierEntry, } from '../classifier/questionHelpers.js';
8
+ const defaultOptions = () => [
9
+ { key: '', value: '' },
10
+ { key: '', value: '' },
11
+ ];
7
12
  const defaultLevels = () => ['', ''];
8
13
  const defaultScoreCriteria = () => [createScoreCriterion(), createScoreCriterion()];
9
14
  const entryTypeOptions = [
@@ -59,7 +64,9 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
59
64
  if (data.useNoulFalseCriteriaInput)
60
65
  inputs.push(getNoulCriteriaInputDefinition('criteriaFalse', 'false', criteriaType));
61
66
  }
62
- const templates = data.useInstructionsInput ? [] : getEntryTemplates(data.instructionsType, data.instructions, data.instructionsLines, data.instructionsObjectTemplate);
67
+ const templates = data.useInstructionsInput
68
+ ? []
69
+ : getEntryTemplates(data.instructionsType, data.instructions, data.instructionsLines, data.instructionsObjectTemplate);
63
70
  if (!data.useCriteriaInput) {
64
71
  if (data.questionType === 'choice') {
65
72
  if (getCriteriaType(data) === 'text')
@@ -298,7 +305,33 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
298
305
  };
299
306
  }
300
307
  async process(inputs, context) {
308
+ const preparation = new ClassifierQuestionPreparation(context);
301
309
  const data = this.data;
310
+ preparation.capture(data.questionId);
311
+ // Reject impossible cardinalities before resolving even Instructions.
312
+ const criteria = data.useCriteriaInput ? getQuestionInputValue(inputs, 'criteria', 'Criteria') : undefined;
313
+ if (data.questionType === 'score') {
314
+ const count = data.useCriteriaInput
315
+ ? Array.isArray(criteria)
316
+ ? criteria.length
317
+ : 0
318
+ : (data.scoreCriteria ?? data.levels ?? defaultLevels()).length;
319
+ if (count < 2 || count > 10)
320
+ throw new Error('Score questions require 2 to 10 levels.');
321
+ }
322
+ else if (data.questionType === 'choice') {
323
+ const count = data.useCriteriaInput
324
+ ? criteria && typeof criteria === 'object' && !Array.isArray(criteria)
325
+ ? Object.keys(criteria).length
326
+ : 0
327
+ : (getCriteriaType(data) === 'text'
328
+ ? data.options ?? defaultOptions()
329
+ : data.choiceCriteria ?? data.options ?? defaultOptions()).length;
330
+ if (count < 2 || count > 255)
331
+ throw new Error('Choice questions require 2 to 255 options.');
332
+ }
333
+ if (data.useInstructionsInput)
334
+ preparation.capture(getQuestionInputValue(inputs, 'instructions', 'Instructions'));
302
335
  const questionId = requireQuestionId(data.questionId);
303
336
  const instructions = data.useInstructionsInput
304
337
  ? getStructuredInput(inputs, 'instructions', 'Instructions')
@@ -310,9 +343,12 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
310
343
  inputs,
311
344
  context,
312
345
  label: 'Instructions',
346
+ preparation,
313
347
  });
314
348
  assertClassifierInstructions(instructions);
315
- const question = createQuestionDefinition(data, inputs, context, questionId, instructions);
349
+ const question = createQuestionDefinition(data, inputs, context, questionId, instructions, preparation);
350
+ assertClassifierJson(question, 'Question', false, preparation.check);
351
+ preparation.check();
316
352
  return { ['question']: { type: 'object', value: question } };
317
353
  }
318
354
  }
@@ -377,18 +413,19 @@ function getInstructionsBodySection(data) {
377
413
  return { id: 'instructions', fields: [{ label: 'Instructions', value: 'object' }] };
378
414
  return { id: 'instructions', fields: [], summary: abbreviate(data.instructions) || '(required)' };
379
415
  }
380
- function createQuestionDefinition(data, inputs, context, questionId, instructions) {
416
+ function createQuestionDefinition(data, inputs, context, questionId, instructions, preparation) {
381
417
  if (data.questionType === 'choice') {
382
- return createChoiceQuestion(data, inputs, context, questionId, instructions);
418
+ return createChoiceQuestion(data, inputs, context, questionId, instructions, preparation);
383
419
  }
384
420
  if (data.questionType === 'score') {
385
- return createScoreQuestion(data, inputs, context, questionId, instructions);
421
+ return createScoreQuestion(data, inputs, context, questionId, instructions, preparation);
386
422
  }
387
- return createNoulQuestion(data, inputs, context, questionId, instructions);
423
+ return createNoulQuestion(data, inputs, context, questionId, instructions, preparation);
388
424
  }
389
- function createChoiceQuestion(data, inputs, context, questionId, instructions) {
425
+ function createChoiceQuestion(data, inputs, context, questionId, instructions, preparation) {
390
426
  let criteria;
391
427
  if (data.useCriteriaInput) {
428
+ preparation.capture(getQuestionInputValue(inputs, 'criteria', 'Criteria'));
392
429
  const value = getStructuredInput(inputs, 'criteria', 'Criteria');
393
430
  if (value === null || Array.isArray(value) || typeof value !== 'object') {
394
431
  throw new Error('Choice criteria must be an object.');
@@ -405,6 +442,7 @@ function createChoiceQuestion(data, inputs, context, questionId, instructions) {
405
442
  throw new Error('Choice questions require 2 to 255 options.');
406
443
  criteria = Object.create(null);
407
444
  for (const option of options) {
445
+ preparation.capture(option.key);
408
446
  if (option.key.trim() === '')
409
447
  throw new Error('Choice criterion names must not be empty.');
410
448
  if (Object.prototype.hasOwnProperty.call(criteria, option.key)) {
@@ -413,7 +451,7 @@ function createChoiceQuestion(data, inputs, context, questionId, instructions) {
413
451
  Object.defineProperty(criteria, option.key, {
414
452
  enumerable: true,
415
453
  value: criteriaType === 'text'
416
- ? interpolateQuestionText(option.value, inputs, context) || null
454
+ ? interpolateQuestionText(option.value, inputs, context, preparation) || null
417
455
  : resolveAuthoredClassifierEntry({
418
456
  type: criteriaType,
419
457
  text: option.text,
@@ -422,6 +460,7 @@ function createChoiceQuestion(data, inputs, context, questionId, instructions) {
422
460
  inputs,
423
461
  context,
424
462
  label: `Criteria.${option.key}`,
463
+ preparation,
425
464
  }),
426
465
  });
427
466
  }
@@ -433,9 +472,10 @@ function createChoiceQuestion(data, inputs, context, questionId, instructions) {
433
472
  assertClassifierEntry(entry, `Criteria.${key}`);
434
473
  return { questionId, type: 'choice', instructions, criteria };
435
474
  }
436
- function createScoreQuestion(data, inputs, context, questionId, instructions) {
475
+ function createScoreQuestion(data, inputs, context, questionId, instructions, preparation) {
437
476
  let criteria;
438
477
  if (data.useCriteriaInput) {
478
+ preparation.capture(getQuestionInputValue(inputs, 'criteria', 'Criteria'));
439
479
  const value = getStructuredInput(inputs, 'criteria', 'Criteria');
440
480
  if (!Array.isArray(value))
441
481
  throw new Error('Score criteria must be an array.');
@@ -450,6 +490,7 @@ function createScoreQuestion(data, inputs, context, questionId, instructions) {
450
490
  inputs,
451
491
  context,
452
492
  label: `Criteria[${index}]`,
493
+ preparation,
453
494
  }));
454
495
  }
455
496
  if (criteria.length < 2 || criteria.length > 10)
@@ -457,9 +498,10 @@ function createScoreQuestion(data, inputs, context, questionId, instructions) {
457
498
  criteria.forEach((entry, index) => assertClassifierEntry(entry, `Criteria[${index}]`));
458
499
  return { questionId, type: 'score', instructions, criteria };
459
500
  }
460
- function createNoulQuestion(data, inputs, context, questionId, instructions) {
501
+ function createNoulQuestion(data, inputs, context, questionId, instructions, preparation) {
461
502
  let criteria;
462
503
  if (data.useCriteriaInput) {
504
+ preparation.capture(getQuestionInputValue(inputs, 'criteria', 'Criteria'));
463
505
  const value = getStructuredInput(inputs, 'criteria', 'Criteria');
464
506
  if (value === null ||
465
507
  Array.isArray(value) ||
@@ -471,8 +513,8 @@ function createNoulQuestion(data, inputs, context, questionId, instructions) {
471
513
  criteria = { true: value.true, false: value.false };
472
514
  }
473
515
  else {
474
- const trueCriteria = resolveNoulCriteria(data, 'true', inputs, context);
475
- const falseCriteria = resolveNoulCriteria(data, 'false', inputs, context);
516
+ const trueCriteria = resolveNoulCriteria(data, 'true', inputs, context, preparation);
517
+ const falseCriteria = resolveNoulCriteria(data, 'false', inputs, context, preparation);
476
518
  if (hasClassifierCriteriaValue(trueCriteria) || hasClassifierCriteriaValue(falseCriteria)) {
477
519
  if (!hasClassifierCriteriaValue(trueCriteria) || !hasClassifierCriteriaValue(falseCriteria)) {
478
520
  throw new Error('Provide both true and false criteria, or neither.');
@@ -537,10 +579,11 @@ function hasAuthoredNoulCriteria(data, truthValue) {
537
579
  }
538
580
  return (truthValue === 'true' ? getNoulTrueCriteria(data) : getNoulFalseCriteria(data)).trim() !== '';
539
581
  }
540
- function resolveNoulCriteria(data, truthValue, inputs, context) {
582
+ function resolveNoulCriteria(data, truthValue, inputs, context, preparation) {
541
583
  const useInput = truthValue === 'true' ? data.useNoulTrueCriteriaInput : data.useNoulFalseCriteriaInput;
542
584
  const label = `${truthValue} criteria`;
543
585
  if (useInput) {
586
+ preparation.capture(getQuestionInputValue(inputs, `criteria${truthValue === 'true' ? 'True' : 'False'}`, label));
544
587
  return getCriteriaType(data) === 'text'
545
588
  ? getStringInput(inputs, `criteria${truthValue === 'true' ? 'True' : 'False'}`, label)
546
589
  : getStructuredInput(inputs, `criteria${truthValue === 'true' ? 'True' : 'False'}`, label);
@@ -553,6 +596,7 @@ function resolveNoulCriteria(data, truthValue, inputs, context) {
553
596
  inputs,
554
597
  context,
555
598
  label,
599
+ preparation,
556
600
  });
557
601
  }
558
602
  function hasClassifierCriteriaValue(value) {
@@ -160,7 +160,7 @@ export class DelegateFunctionCallNodeImpl extends NodeImpl {
160
160
  return buildDelegatedToolCallOutputs(delegatedRecords);
161
161
  }
162
162
  const result = await delegateToolCall(functionCallInput, context, this.data);
163
- return buildDelegatedToolCallOutputs([result.record], undefined, result.cost);
163
+ return buildDelegatedToolCallOutputs([result.record], undefined, result.cost, result.costBreakdown);
164
164
  }
165
165
  }
166
166
  function getDelegatedToolCallRecords(input) {
@@ -42,11 +42,11 @@ export class GetGlobalNodeImpl extends NodeImpl {
42
42
  return [];
43
43
  }
44
44
  getOutputDefinitions() {
45
- const { onDemand, dataType } = this.chartNode.data;
45
+ const { id, useIdInput, onDemand, dataType } = this.chartNode.data;
46
46
  return [
47
47
  {
48
48
  id: 'value',
49
- title: 'Value',
49
+ title: !useIdInput && typeof id === 'string' && id.trim() ? id : 'Value',
50
50
  dataType: onDemand ? `fn<${dataType}>` : dataType,
51
51
  },
52
52
  {
@@ -5,53 +5,16 @@ import { nodeDefinition } from '../NodeDefinition.js';
5
5
  import {} from '../GraphProcessor.js';
6
6
  import {} from '../../index.js';
7
7
  import { coerceType, dedent, getInputOrData } from '../../utils/index.js';
8
- import { getError } from '../../utils/errors.js';
8
+ import { getError, isAbortError, formatCaughtRunError as formatCaughtRequestFailureError } from '../../utils/errors.js';
9
9
  const REQUEST_FAILED_OUTPUT_ID = 'requestFailed';
10
10
  const REQUEST_ERROR_OUTPUT_ID = 'requestError';
11
11
  const STATUS_CODE_OUTPUT_ID = 'statusCode';
12
12
  const RESPONSE_HEADERS_OUTPUT_ID = 'res_headers';
13
13
  const DEFAULT_RETRY_ON_NON_200_REPEAT_TIMES = 1;
14
14
  const DEFAULT_RETRY_ON_NON_200_COOLDOWN_MS = 0;
15
- function isAbortError(error, signal) {
16
- return signal.aborted || getError(error).name === 'AbortError';
17
- }
18
15
  function buildNon2xxStatusCodeError(statusCode) {
19
16
  return new Error(`HTTP call returned non-2XX status code: ${statusCode}`);
20
17
  }
21
- function stringifyNonErrorValue(value) {
22
- if (value == null) {
23
- return String(value);
24
- }
25
- if (typeof value === 'string') {
26
- return value;
27
- }
28
- if (typeof value !== 'object') {
29
- return String(value);
30
- }
31
- try {
32
- return JSON.stringify(value, null, 2) ?? String(value);
33
- }
34
- catch (_error) {
35
- return String(value);
36
- }
37
- }
38
- function formatCaughtRequestFailureError(error, seen = new Set()) {
39
- if (error && typeof error === 'object') {
40
- if (seen.has(error)) {
41
- return '[Circular error reference]';
42
- }
43
- seen.add(error);
44
- }
45
- if (error instanceof Error) {
46
- const errorText = error.stack?.trim() || `${error.name}: ${error.message}`.trim();
47
- const cause = error.cause;
48
- if (cause == null) {
49
- return errorText;
50
- }
51
- return `${errorText}\n\nCaused by: ${formatCaughtRequestFailureError(cause, seen)}`;
52
- }
53
- return stringifyNonErrorValue(error);
54
- }
55
18
  function createHttpCallRequestAttempts() {
56
19
  return {
57
20
  statusCodeValues: [],
@@ -396,52 +359,58 @@ export class HttpCallNodeImpl extends NodeImpl {
396
359
  language: 'json',
397
360
  enableFolding: true,
398
361
  },
362
+ {
363
+ type: 'toggle',
364
+ label: 'Binary Output',
365
+ dataKey: 'isBinaryOutput',
366
+ helperMessage: 'Toggle on if the response is expected to be binary data',
367
+ },
399
368
  {
400
369
  type: 'group',
401
- label: 'Retry on non-200',
402
- toggleDataKey: 'retryOnNon200',
370
+ label: 'Error behavior',
403
371
  editors: [
404
372
  {
405
- type: 'number',
406
- label: 'Repeat times',
407
- dataKey: 'retryOnNon200RepeatTimes',
408
- defaultValue: DEFAULT_RETRY_ON_NON_200_REPEAT_TIMES,
409
- min: 1,
410
- step: 1,
411
- layout: 'inline',
412
- helperMessage: 'Times to repeat after the initial request',
373
+ type: 'group',
374
+ label: 'Retry on non-200',
375
+ toggleDataKey: 'retryOnNon200',
376
+ editors: [
377
+ {
378
+ type: 'number',
379
+ label: 'Repeat times',
380
+ dataKey: 'retryOnNon200RepeatTimes',
381
+ defaultValue: DEFAULT_RETRY_ON_NON_200_REPEAT_TIMES,
382
+ min: 1,
383
+ step: 1,
384
+ layout: 'inline',
385
+ helperMessage: 'Times to repeat after the initial request',
386
+ },
387
+ {
388
+ type: 'number',
389
+ label: 'Cooldown, ms',
390
+ dataKey: 'retryOnNon200CooldownMs',
391
+ defaultValue: DEFAULT_RETRY_ON_NON_200_COOLDOWN_MS,
392
+ min: 0,
393
+ step: 1,
394
+ layout: 'inline',
395
+ helperMessage: 'Milliseconds to wait between repeats',
396
+ },
397
+ ],
398
+ },
399
+ {
400
+ type: 'toggle',
401
+ label: 'Fail on non-2XX status code',
402
+ dataKey: 'errorOnNon200',
403
+ helperMessage: (data) => data.retryOnNon200
404
+ ? 'With Retry on non-200 enabled, only the final response after all retries is checked.'
405
+ : undefined,
413
406
  },
414
407
  {
415
- type: 'number',
416
- label: 'Cooldown, ms',
417
- dataKey: 'retryOnNon200CooldownMs',
418
- defaultValue: DEFAULT_RETRY_ON_NON_200_COOLDOWN_MS,
419
- min: 0,
420
- step: 1,
421
- layout: 'inline',
422
- helperMessage: 'Milliseconds to wait between repeats',
408
+ type: 'toggle',
409
+ label: 'Catch all request failures',
410
+ dataKey: 'catchRequestFailed',
423
411
  },
424
412
  ],
425
413
  },
426
- {
427
- type: 'toggle',
428
- label: 'Binary Output',
429
- dataKey: 'isBinaryOutput',
430
- helperMessage: 'Toggle on if the response is expected to be binary data',
431
- },
432
- {
433
- type: 'toggle',
434
- label: 'Fail on non-2XX status code',
435
- dataKey: 'errorOnNon200',
436
- helperMessage: (data) => data.retryOnNon200
437
- ? 'With Retry on non-200 enabled, only the final response after all retries is checked.'
438
- : undefined,
439
- },
440
- {
441
- type: 'toggle',
442
- label: 'Catch all request failures',
443
- dataKey: 'catchRequestFailed',
444
- },
445
414
  ];
446
415
  }
447
416
  getBody() {
@@ -13,7 +13,10 @@ export class ImageNodeImpl extends NodeImpl {
13
13
  title: 'Image',
14
14
  visualData: { x: 0, y: 0, width: 250 },
15
15
  data: {
16
+ sourceType: 'binary',
16
17
  useDataInput: false,
18
+ base64: '',
19
+ useBase64Input: false,
17
20
  mediaType: 'image/png',
18
21
  useMediaTypeInput: false,
19
22
  },
@@ -21,7 +24,15 @@ export class ImageNodeImpl extends NodeImpl {
21
24
  }
22
25
  getInputDefinitions() {
23
26
  const inputDefinitions = [];
24
- if (this.chartNode.data.useDataInput) {
27
+ if (this.chartNode.data.sourceType === 'base64' && this.chartNode.data.useBase64Input) {
28
+ inputDefinitions.push({
29
+ id: 'base64',
30
+ title: 'Base64',
31
+ dataType: 'string',
32
+ coerced: false,
33
+ });
34
+ }
35
+ else if (this.chartNode.data.sourceType !== 'base64' && this.chartNode.data.useDataInput) {
25
36
  inputDefinitions.push({
26
37
  id: 'data',
27
38
  title: 'Data',
@@ -49,6 +60,16 @@ export class ImageNodeImpl extends NodeImpl {
49
60
  }
50
61
  getEditors() {
51
62
  return [
63
+ {
64
+ type: 'segmented',
65
+ label: 'Image source',
66
+ dataKey: 'sourceType',
67
+ defaultValue: 'binary',
68
+ options: [
69
+ { value: 'binary', label: 'Binary data' },
70
+ { value: 'base64', label: 'Base64' },
71
+ ],
72
+ },
52
73
  {
53
74
  type: 'dropdown',
54
75
  label: 'Media Type',
@@ -66,6 +87,17 @@ export class ImageNodeImpl extends NodeImpl {
66
87
  dataKey: 'data',
67
88
  useInputToggleDataKey: 'useDataInput',
68
89
  mediaTypeDataKey: 'mediaType',
90
+ hideIf: (data) => data.sourceType === 'base64',
91
+ },
92
+ {
93
+ type: 'code',
94
+ label: 'Base64',
95
+ dataKey: 'base64',
96
+ defaultValue: '',
97
+ language: 'plaintext',
98
+ useInputToggleDataKey: 'useBase64Input',
99
+ hideIf: (data) => data.sourceType !== 'base64',
100
+ helperMessage: 'Raw base64-encoded image bytes. The Media Type setting describes the decoded image.',
69
101
  },
70
102
  ];
71
103
  }
@@ -74,12 +106,21 @@ export class ImageNodeImpl extends NodeImpl {
74
106
  contextMenuTitle: 'Image',
75
107
  group: 'Data',
76
108
  infoBoxTitle: 'Image Node',
77
- infoBoxBody: 'Defines a static image for use with other nodes. Can convert a binary type into an image type.',
109
+ infoBoxBody: 'Defines an image from a file, binary input, or base64 text. Media Type describes the resulting image.',
78
110
  };
79
111
  }
80
112
  async process(inputData, context) {
81
113
  let data;
82
- if (this.chartNode.data.useDataInput) {
114
+ if (this.chartNode.data.sourceType === 'base64') {
115
+ const encodedData = this.chartNode.data.useBase64Input
116
+ ? expectType(inputData['base64'], 'string')
117
+ : this.data.base64;
118
+ if (!encodedData?.trim()) {
119
+ throw new Error('No base64 image data');
120
+ }
121
+ data = base64ToUint8Array(encodedData.trim());
122
+ }
123
+ else if (this.chartNode.data.useDataInput) {
83
124
  data = expectType(inputData['data'], 'binary');
84
125
  }
85
126
  else {