@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
@@ -1,13 +1,23 @@
1
1
  import { nanoid } from 'nanoid/non-secure';
2
2
  import { nodeDefinition } from '../NodeDefinition.js';
3
3
  import { NodeImpl } from '../NodeImpl.js';
4
+ import { createExcludedNodeOutputs } from '../NodeExclusionPolicy.js';
4
5
  import { formatNodeBodyMarkdownField, formatNodeBodyMarkdownSeparator } from '../nodeBodyMarkdown.js';
6
+ import { createCaughtRunFailureOutputs, getRunFailureOutputDefinitions, shouldCatchRunFailure, withRunSuccessOutputs, } from '../nodeRunFailure.js';
5
7
  import { getNextVariadicPortIndex } from './variadicPortIndex.js';
6
- import { resolveClassifierApiKey, } from '../classifier/credentials.js';
7
- import { assertClassifierEntry, assertClassifierInstructions } from '../classifier/questionHelpers.js';
8
- import { calculateClassifierUsageCost, classifierProviders, DEFAULT_CLASSIFIER_RETRY_ON_NON_200_COOLDOWN_MS, DEFAULT_CLASSIFIER_RETRY_ON_NON_200_REPEAT_TIMES, getClassifierProvider, normalizeClassifierNon200RetryCooldownMs, normalizeClassifierNon200RetryCount, } from '../classifier/providers.js';
8
+ import { resolveClassifierApiKey } from '../classifier/credentials.js';
9
+ import { classifierArrayValues, classifierInputDataValue } from '../classifier/json.js';
10
+ import { normalizeClassifierState } from '../classifier/state.js';
11
+ import { CLASSIFIER_LIMITS, classifierPreparationCheck, ClassifierValueBudget } from '../classifier/limits.js';
12
+ import { calculateClassifierUsageCost, classifierFailureKind, classifierProviders, DEFAULT_CLASSIFIER_RETRY_ON_NON_200_COOLDOWN_MS, DEFAULT_CLASSIFIER_RETRY_ON_NON_200_REPEAT_TIMES, getClassifierProvider, normalizeClassifierNon200RetryCooldownMs, normalizeClassifierNon200RetryCount, } from '../classifier/providers.js';
13
+ import { normalizeClassifierProfiles } from '../classifier/profile.js';
14
+ import { classifierProfileSummary, ClassifierProfileExhaustedError, runClassifierProfiles, } from '../classifier/profileExecution.js';
15
+ import { prepareClassifierQuestion } from '../classifier/questions.js';
9
16
  const QUESTION_TYPES = ['object', 'object[]', 'any', 'any[]'];
10
17
  export class ClassifierEvaluateNodeImpl extends NodeImpl {
18
+ getRunActivityDescriptor() {
19
+ return { category: 'model', primaryOutputPortId: 'answers' };
20
+ }
11
21
  static create() {
12
22
  return {
13
23
  type: 'classifierEvaluate',
@@ -17,7 +27,7 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
17
27
  // Keep the default model in the provider descriptor rather than
18
28
  // serializing Jev's model into every new node. A future provider then
19
29
  // receives its own default when an author changes the Provider field.
20
- data: { provider: 'jev', timeoutMs: 30_000 },
30
+ data: { provider: 'jev', timeoutMs: 30_000, errorOnNon200: true, catchRequestFailed: false },
21
31
  };
22
32
  }
23
33
  getInputDefinitions(connections) {
@@ -25,15 +35,38 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
25
35
  {
26
36
  id: 'state',
27
37
  title: 'State',
28
- dataType: ['string', 'object', 'object[]', 'any', 'any[]'],
29
- required: true,
38
+ dataType: [
39
+ 'string',
40
+ 'string[]',
41
+ 'image',
42
+ 'image[]',
43
+ 'chat-message',
44
+ 'chat-message[]',
45
+ 'object',
46
+ 'object[]',
47
+ 'any',
48
+ 'any[]',
49
+ ],
50
+ description: 'Shared text, images, or assembled user messages for every question. Image bytes and base64 images are encoded automatically. JSON objects remain structured state.',
51
+ required: false,
30
52
  splitRunBehavior: 'preserve-array',
31
53
  },
32
54
  ];
33
- if (this.data.useModelInput) {
55
+ if (this.data.configurationMode === 'profile') {
56
+ inputs.unshift({
57
+ id: 'classifierProfile',
58
+ title: 'Classifier Profiles',
59
+ dataType: ['classifier-config', 'classifier-config[]'],
60
+ required: true,
61
+ coerced: true,
62
+ splitRunBehavior: 'preserve-array',
63
+ description: 'One Classifier Profile or an ordered fallback chain.',
64
+ });
65
+ }
66
+ if (this.data.configurationMode !== 'profile' && this.data.useModelInput) {
34
67
  inputs.push({ id: 'model', title: 'Model', dataType: 'string', required: true });
35
68
  }
36
- if (this.data.apiKeySource === 'input') {
69
+ if (this.data.configurationMode !== 'profile' && this.data.apiKeySource === 'input') {
37
70
  inputs.push({ id: 'apiKey', title: 'API Key', dataType: 'string', required: true });
38
71
  }
39
72
  const count = getNextVariadicPortIndex(connections, this.chartNode.id, 'question', 'strict-positive');
@@ -52,49 +85,33 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
52
85
  const outputs = [
53
86
  { id: 'answers', title: 'Answers', dataType: 'object' },
54
87
  { id: 'usage', title: 'Usage', dataType: 'object' },
88
+ {
89
+ id: 'cost',
90
+ title: 'Cost',
91
+ dataType: 'number',
92
+ description: 'Estimated USD cost for this successful evaluation. Excluded when pricing cannot be calculated.',
93
+ },
55
94
  ];
56
95
  if (this.data.outputRequestBody === true) {
57
- outputs.push({ id: 'requestBody', title: 'Classifier request body', dataType: 'object' });
96
+ outputs.push({ id: 'requestBody', title: 'Request body', dataType: 'object' });
58
97
  }
59
98
  if (this.data.outputResponseBody === true) {
60
- outputs.push({ id: 'responseBody', title: 'Classifier response body', dataType: 'object' });
99
+ outputs.push({ id: 'responseBody', title: 'Response body', dataType: 'object' });
61
100
  }
62
- return outputs;
101
+ if (this.data.outputClassifierAttempts)
102
+ outputs.push({ id: 'classifierAttempts', title: 'Classifier Attempts', dataType: 'object[]' });
103
+ if (this.data.configurationMode === 'profile' && this.data.outputClassifierProfileSummary)
104
+ outputs.push({
105
+ id: 'classifierProfileSummary',
106
+ title: 'Classifier Profile Summary',
107
+ dataType: 'string',
108
+ });
109
+ return [...outputs, ...getRunFailureOutputDefinitions({ catchRequestFailed: this.data.catchRequestFailed })];
63
110
  }
64
111
  getEditors() {
65
112
  return [
66
- {
67
- type: 'dropdown',
68
- label: 'Provider',
69
- dataKey: 'provider',
70
- defaultValue: 'jev',
71
- options: classifierProviders.map((provider) => ({ value: provider.id, label: provider.label })),
72
- },
73
- {
74
- type: 'string',
75
- label: 'Model',
76
- dataKey: 'model',
77
- useInputToggleDataKey: 'useModelInput',
78
- placeholder: 'jev-latest',
79
- },
80
- {
81
- type: 'segmented',
82
- label: 'API key source',
83
- ariaLabel: 'API key source',
84
- dataKey: 'apiKeySource',
85
- defaultValue: 'configured',
86
- options: [
87
- { value: 'configured', label: 'Configured key' },
88
- { value: 'input', label: 'Input port' },
89
- ],
90
- helperMessage: getApiKeySourceHelperMessage,
91
- },
92
- {
93
- type: 'custom',
94
- label: 'Configured API key names',
95
- customEditorId: 'ClassifierCredentialNames',
96
- hideIf: (data) => data.apiKeySource === 'input',
97
- },
113
+ { type: 'custom', label: 'Configuration', customEditorId: 'ClassifierConfiguration' },
114
+ { ...getClassifierModelEditor(this.data), hideIf: (data) => data.configurationMode === 'profile' },
98
115
  {
99
116
  type: 'group',
100
117
  label: 'Outputs',
@@ -103,7 +120,7 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
103
120
  type: 'toggle',
104
121
  label: 'Output usage details',
105
122
  dataKey: 'outputUsage',
106
- helperMessage: 'Adds totalCost to Usage when the selected provider has fixed token pricing. Jev input tokens cost $0.042 / MTok; output tokens are free.',
123
+ helperMessage: 'Adds estimated totalCost to Usage only for recognized requested/returned models. Unknown pricing is omitted. Provider-specific premiums are not included.',
107
124
  },
108
125
  {
109
126
  type: 'toggle',
@@ -115,7 +132,14 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
115
132
  type: 'toggle',
116
133
  label: 'Output response body',
117
134
  dataKey: 'outputResponseBody',
118
- helperMessage: 'Adds the complete classifier JSON response returned by the provider after validation. Rivet does not redact or truncate captured content.',
135
+ helperMessage: 'Shows the provider response, including rejected or invalid responses. Non-JSON responses appear as raw text. Captured content may contain sensitive input.',
136
+ },
137
+ { type: 'toggle', label: 'Output classifier attempts', dataKey: 'outputClassifierAttempts' },
138
+ {
139
+ type: 'toggle',
140
+ label: 'Output classifier profile summary',
141
+ dataKey: 'outputClassifierProfileSummary',
142
+ hideIf: (data) => data.configurationMode !== 'profile',
119
143
  },
120
144
  ],
121
145
  },
@@ -126,12 +150,12 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
126
150
  {
127
151
  type: 'number',
128
152
  label: 'Overall timeout (seconds)',
129
- dataKey: 'timeoutMs',
130
- defaultValue: 30,
153
+ dataKey: this.data.configurationMode === 'profile' ? 'profileChainTimeoutMs' : 'timeoutMs',
154
+ defaultValue: this.data.configurationMode === 'profile' ? 180_000 : 30_000,
131
155
  storageMultiplier: 1000,
132
- min: 1,
133
- max: 600,
134
- step: 1,
156
+ min: 1_000,
157
+ max: 600_000,
158
+ step: 1_000,
135
159
  },
136
160
  ],
137
161
  },
@@ -139,11 +163,24 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
139
163
  type: 'group',
140
164
  label: 'Error behavior',
141
165
  editors: [
166
+ {
167
+ type: 'toggle',
168
+ label: 'Fail on non-2XX status code',
169
+ dataKey: 'errorOnNon200',
170
+ defaultValue: true,
171
+ helperMessage: 'After retries, throw on a rejected HTTP request. When disabled, unavailable outputs are excluded. Run failed and Run error are available only when Catch all failures is enabled.',
172
+ },
173
+ {
174
+ type: 'toggle',
175
+ label: 'Catch all failures',
176
+ dataKey: 'catchRequestFailed',
177
+ helperMessage: 'Return any node execution failure through Run failed and Run error instead of stopping the graph. Explicit graph cancellation is never caught.',
178
+ },
142
179
  {
143
180
  type: 'toggle',
144
181
  label: 'Retry on non-200',
145
182
  dataKey: 'retryOnNon200',
146
- helperMessage: 'Retries non-authentication, non-validation provider HTTP responses. Jev rate-limit retries remain automatic.',
183
+ helperMessage: 'Retries non-authentication, non-validation provider HTTP responses. Provider rate-limit retries remain automatic.',
147
184
  },
148
185
  {
149
186
  type: 'number',
@@ -188,11 +225,89 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
188
225
  return {
189
226
  contextMenuTitle: 'Classifier Evaluate',
190
227
  infoBoxTitle: 'Classifier Evaluate',
191
- infoBoxBody: 'Evaluates one shared state against a batch of independent typed classifier questions in one request.',
228
+ infoBoxBody: 'Evaluates shared state and optional images against typed classifier questions. Images are shared evidence for every question.',
192
229
  group: ['Classifier'],
193
230
  };
194
231
  }
195
232
  async process(inputs, context) {
233
+ const attempts = [];
234
+ const bodies = {};
235
+ let getRequestBody;
236
+ const diagnostics = {
237
+ ...(this.data.outputRequestBody || this.data.outputResponseBody
238
+ ? {
239
+ onRequestBody: (getBody) => {
240
+ // Pair the last prepared request with its response, never bodies from different candidates.
241
+ delete bodies['responseBody'];
242
+ if (this.data.outputRequestBody)
243
+ getRequestBody = getBody;
244
+ },
245
+ }
246
+ : {}),
247
+ ...(this.data.outputResponseBody
248
+ ? {
249
+ onResponseBody: (body) => {
250
+ bodies['responseBody'] = {
251
+ type: 'object',
252
+ value: body !== null && typeof body === 'object' && !Array.isArray(body)
253
+ ? body
254
+ : { raw: body },
255
+ };
256
+ },
257
+ }
258
+ : {}),
259
+ };
260
+ try {
261
+ context.signal.throwIfAborted();
262
+ const outputs = await this.processRun(inputs, context, attempts, diagnostics);
263
+ context.signal.throwIfAborted();
264
+ return withRunSuccessOutputs({ catchRequestFailed: this.data.catchRequestFailed }, outputs);
265
+ }
266
+ catch (error) {
267
+ try {
268
+ if (getRequestBody)
269
+ bodies['requestBody'] = { type: 'object', value: getRequestBody() };
270
+ }
271
+ catch {
272
+ /* Request diagnostics cannot replace the execution failure. */
273
+ }
274
+ const evidence = {
275
+ ...bodies,
276
+ ...this.profileEvidence(attempts, error instanceof ClassifierProfileExhaustedError ? error.summary : undefined),
277
+ };
278
+ const failure = error instanceof ClassifierProfileExhaustedError ? { statusCode: error.statusCode } : error;
279
+ if (!shouldCatchRunFailure(this.data, failure, context.signal)) {
280
+ try {
281
+ if (Object.keys(evidence).length) {
282
+ if (context.setFailureOutputs)
283
+ context.setFailureOutputs(evidence);
284
+ else
285
+ context.onPartialOutputs?.(evidence);
286
+ }
287
+ }
288
+ catch {
289
+ /* Diagnostics must not replace the original failure. */
290
+ }
291
+ throw error;
292
+ }
293
+ return this.data.catchRequestFailed === true
294
+ ? createCaughtRunFailureOutputs(this.getOutputDefinitions(), error, evidence)
295
+ : { ...createExcludedNodeOutputs(this.chartNode, this.getOutputDefinitions()), ...evidence };
296
+ }
297
+ }
298
+ async processRun(inputs, context, attempts, diagnostics) {
299
+ if (this.data.configurationMode !== undefined &&
300
+ this.data.configurationMode !== 'inline' &&
301
+ this.data.configurationMode !== 'profile')
302
+ throw new Error('Unknown classifier configuration mode.');
303
+ const timeoutMs = this.data.configurationMode === 'profile'
304
+ ? normalizeTimeout(this.data.profileChainTimeoutMs ?? 180_000)
305
+ : normalizeTimeout(this.data.timeoutMs);
306
+ const deadline = Date.now() + timeoutMs;
307
+ const checkPreparation = classifierPreparationCheck(context.signal, deadline, timeoutMs);
308
+ checkPreparation();
309
+ if (this.data.configurationMode === 'profile')
310
+ return this.processProfiles(inputs, context, deadline, checkPreparation, attempts, diagnostics);
196
311
  const provider = getClassifierProvider(this.data.provider);
197
312
  if (!provider.browserExecutionSupported && context.executor === 'browser') {
198
313
  throw new Error(`${provider.label} cannot run in the Browser executor. Select the Node executor, or run through Studio Server or remote debugging.`);
@@ -205,31 +320,42 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
205
320
  inputs,
206
321
  providerId: provider.id,
207
322
  });
208
- const state = inputs['state']?.value;
209
- assertClassifierState(state);
323
+ const graph = context.project?.graphs[context.execution?.graphId];
324
+ if (classifierInputDataValue(inputs, 'images') !== undefined ||
325
+ graph?.connections.some((connection) => connection.inputNodeId === this.id && connection.inputId === 'images')) {
326
+ throw new Error('The separate Images input has been removed. Connect images or an assembled user message to State.');
327
+ }
328
+ const stateInput = classifierInputDataValue(inputs, 'state');
329
+ // First-party providers prepare the Rivet wrapper at their common boundary.
330
+ // Existing custom descriptors still receive the legacy normalized State contract.
331
+ const state = provider.evaluateInput
332
+ ? { state: '', stateInput }
333
+ : normalizeClassifierState(stateInput, checkPreparation, provider.maxRequestBytes);
334
+ const legacyBudget = provider.evaluateInput
335
+ ? undefined
336
+ : new ClassifierValueBudget(checkPreparation, provider.maxRequestBytes);
337
+ legacyBudget?.inspect(state);
210
338
  const modelValue = this.data.useModelInput
211
- ? inputs['model']?.value
339
+ ? classifierInputDataValue(inputs, 'model')?.value
212
340
  : getStaticModel(this.data.model, provider.defaultModel);
213
341
  if (typeof modelValue !== 'string' || modelValue.trim() === '') {
214
342
  throw new Error(`${provider.label} model is required.`);
215
343
  }
344
+ legacyBudget?.inspect(modelValue);
216
345
  const questions = [];
217
- const questionInputs = Object.entries(inputs).filter(([portId]) => /^question\d+$/.test(portId));
218
- for (const [, input] of questionInputs.sort(compareQuestionPorts)) {
219
- if (input)
220
- flattenQuestions(input.value, questions);
346
+ const flattenWork = { values: 0 };
347
+ const questionInputs = Object.keys(inputs).filter((portId) => /^question\d+$/.test(portId));
348
+ for (const port of questionInputs.sort(compareQuestionPorts)) {
349
+ const input = classifierInputDataValue(inputs, port);
350
+ if (input) {
351
+ // Legacy descriptors do not own the shared preparation boundary.
352
+ legacyBudget?.inspect(input.value);
353
+ flattenQuestions(input.value, questions, checkPreparation, new Set(), 0, flattenWork);
354
+ }
221
355
  }
222
356
  if (questions.length === 0)
223
357
  throw new Error('Classifier Evaluate requires at least one question.');
224
- const ids = new Set();
225
- for (const question of questions) {
226
- validateQuestion(question);
227
- if (ids.has(question.questionId)) {
228
- throw new Error(`Question ID '${question.questionId}' is duplicated in this evaluation.`);
229
- }
230
- ids.add(question.questionId);
231
- }
232
- const result = await provider.evaluate({
358
+ const result = await (provider.evaluateInput ?? provider.evaluate).call(provider, {
233
359
  apiKey,
234
360
  model: modelValue,
235
361
  questions,
@@ -237,26 +363,171 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
237
363
  retryOnNon200CooldownMs: this.data.retryOnNon200CooldownMs,
238
364
  retryOnNon200RepeatTimes: this.data.retryOnNon200RepeatTimes,
239
365
  signal: context.signal,
240
- state,
241
- timeoutMs: normalizeTimeout(this.data.timeoutMs),
366
+ ...state,
367
+ timeoutMs,
368
+ deadline,
369
+ ...diagnostics,
370
+ onAttempt: ({ kind, ...attempt }) => {
371
+ const event = {
372
+ ...attempt,
373
+ family: 'classifier',
374
+ roundIndex: 0,
375
+ provider: provider.id,
376
+ model: modelValue,
377
+ stage: kind === 'response-validation' || kind === 'response-parsing' ? 'response-validation' : 'request',
378
+ failureKind: kind ? classifierFailureKind(kind, attempt.status) : undefined,
379
+ timeoutKind: kind === 'timeout' ? 'response' : undefined,
380
+ };
381
+ attempts.push(event);
382
+ context.onLLMProfileAttempt?.({
383
+ ...structuredClone(event),
384
+ eventId: nanoid(),
385
+ nodeId: this.chartNode.id,
386
+ processId: context.processId,
387
+ });
388
+ },
389
+ });
390
+ // Custom providers still own their asynchronous transport, but no late
391
+ // result may become a successful node output after the original deadline.
392
+ checkPreparation();
393
+ return { ...this.projectResult(provider, modelValue, result, checkPreparation), ...this.profileEvidence(attempts) };
394
+ }
395
+ projectResult(provider, modelValue, result, checkPreparation) {
396
+ const totalCost = calculateClassifierUsageCost(provider, result.response.usage, {
397
+ requestedModel: modelValue,
398
+ responseModel: result.response.model,
242
399
  });
243
- const totalCost = this.data.outputUsage ? calculateClassifierUsageCost(provider, result.response.usage) : undefined;
244
400
  // The provider's parsed response may also be exposed verbatim through the
245
401
  // diagnostic output. Do not mutate its Usage object while adding Rivet's
246
402
  // calculated accounting detail.
247
- const usage = totalCost === undefined ? result.response.usage : { ...result.response.usage, totalCost };
403
+ const usage = !this.data.outputUsage || totalCost === undefined
404
+ ? result.response.usage
405
+ : { ...result.response.usage, totalCost };
248
406
  const outputs = {
249
407
  ['answers']: { type: 'object', value: result.response.answers },
250
408
  ['usage']: { type: 'object', value: usage },
409
+ ['cost']: totalCost === undefined
410
+ ? { type: 'control-flow-excluded', value: undefined }
411
+ : { type: 'number', value: totalCost },
251
412
  };
252
413
  if (this.data.outputRequestBody === true) {
414
+ checkPreparation();
253
415
  outputs['requestBody'] = { type: 'object', value: result.requestBody };
416
+ checkPreparation();
254
417
  }
255
418
  if (this.data.outputResponseBody === true) {
256
419
  outputs['responseBody'] = { type: 'object', value: result.responseBody };
257
420
  }
258
421
  return outputs;
259
422
  }
423
+ profileEvidence(attempts, summary) {
424
+ return {
425
+ ...(this.data.outputClassifierAttempts
426
+ ? { ['classifierAttempts']: { type: 'object[]', value: attempts } }
427
+ : {}),
428
+ ...(this.data.configurationMode === 'profile' && this.data.outputClassifierProfileSummary && summary !== undefined
429
+ ? { ['classifierProfileSummary']: { type: 'string', value: summary } }
430
+ : {}),
431
+ };
432
+ }
433
+ async processProfiles(inputs, context, deadline, check, attempts, diagnostics) {
434
+ const profiles = normalizeClassifierProfiles(classifierInputDataValue(inputs, 'classifierProfile')?.value, check);
435
+ const graph = context.project?.graphs[context.execution?.graphId];
436
+ if (classifierInputDataValue(inputs, 'images') !== undefined ||
437
+ graph?.connections.some((connection) => connection.inputNodeId === this.id && connection.inputId === 'images'))
438
+ throw new Error('The separate Images input has been removed. Connect images or an assembled user message to State.');
439
+ const state = normalizeClassifierState(classifierInputDataValue(inputs, 'state'), check);
440
+ const budget = new ClassifierValueBudget(check);
441
+ budget.inspect(state);
442
+ const values = [];
443
+ const work = { values: 0 };
444
+ for (const port of Object.keys(inputs)
445
+ .filter((id) => /^question\d+$/.test(id))
446
+ .sort(compareQuestionPorts)) {
447
+ const input = classifierInputDataValue(inputs, port);
448
+ if (input)
449
+ flattenQuestions(input.value, values, check, new Set(), 0, work);
450
+ }
451
+ if (!values.length)
452
+ throw new Error('Classifier Evaluate requires at least one question.');
453
+ const ids = new Set();
454
+ const questions = values.map((value) => {
455
+ const question = prepareClassifierQuestion(value, budget);
456
+ if (ids.has(question.questionId))
457
+ throw new Error(`Question ID '${question.questionId}' is duplicated in this evaluation.`);
458
+ ids.add(question.questionId);
459
+ return question;
460
+ });
461
+ const selected = await runClassifierProfiles({
462
+ profiles,
463
+ state,
464
+ questions,
465
+ context,
466
+ nodeId: this.chartNode.id,
467
+ deadline,
468
+ retryOnNon200: this.data.retryOnNon200,
469
+ retryOnNon200RepeatTimes: this.data.retryOnNon200RepeatTimes,
470
+ retryOnNon200CooldownMs: this.data.retryOnNon200CooldownMs,
471
+ ...diagnostics,
472
+ onAttempt: (attempt) => {
473
+ attempts.push(attempt);
474
+ context.onLLMProfileAttempt?.({
475
+ ...structuredClone(attempt),
476
+ eventId: nanoid(),
477
+ nodeId: this.chartNode.id,
478
+ processId: context.processId,
479
+ });
480
+ },
481
+ });
482
+ check();
483
+ return {
484
+ ...this.projectResult(selected.provider, selected.model, selected.result, check),
485
+ ...this.profileEvidence(attempts, classifierProfileSummary(profiles, attempts)),
486
+ };
487
+ }
488
+ }
489
+ /** Shared settings definition; constructing an unrelated node is unnecessary. */
490
+ export function getClassifierModelEditor(data) {
491
+ return {
492
+ type: 'group',
493
+ label: 'Model',
494
+ defaultOpen: true,
495
+ editors: [
496
+ {
497
+ type: 'dropdown',
498
+ label: 'Provider',
499
+ dataKey: 'provider',
500
+ defaultValue: 'jev',
501
+ options: classifierProviders.map((provider) => ({ value: provider.id, label: provider.label })),
502
+ },
503
+ {
504
+ type: 'string',
505
+ label: 'Model',
506
+ dataKey: 'model',
507
+ useInputToggleDataKey: 'useModelInput',
508
+ placeholder: getProviderForDisplay(data.provider).defaultModel,
509
+ },
510
+ {
511
+ type: 'segmented',
512
+ label: 'API key source',
513
+ ariaLabel: 'API key source',
514
+ dataKey: 'apiKeySource',
515
+ defaultValue: 'configured',
516
+ options: [
517
+ { value: 'configured', label: 'Automatic' },
518
+ { value: 'classifier-settings', label: 'Classifier settings' },
519
+ { value: 'input', label: 'Input port' },
520
+ ],
521
+ helperMessage: getApiKeySourceHelperMessage,
522
+ },
523
+ {
524
+ type: 'custom',
525
+ label: 'Configured API key names',
526
+ customEditorId: 'ClassifierCredentialNames',
527
+ hideIf: (data) => data.apiKeySource === 'input' || data.apiKeySource === 'classifier-settings',
528
+ },
529
+ ],
530
+ };
260
531
  }
261
532
  function getProviderForDisplay(id) {
262
533
  try {
@@ -276,114 +547,74 @@ export function getClassifierEvaluateBodySections(data) {
276
547
  {
277
548
  id: 'configuration',
278
549
  fields: [
279
- { label: 'Provider', value: provider.label },
280
- { label: 'Model', value: data.useModelInput ? 'input' : getStaticModel(data.model, provider.defaultModel) },
550
+ ...(data.configurationMode === 'profile'
551
+ ? [{ label: 'Configuration', value: 'From profile' }]
552
+ : [
553
+ { label: 'Provider', value: provider.label },
554
+ {
555
+ label: 'Model',
556
+ value: data.useModelInput ? 'input' : getStaticModel(data.model, provider.defaultModel),
557
+ },
558
+ ]),
281
559
  ],
282
560
  },
283
561
  ];
284
- if (data.retryOnNon200) {
562
+ if (data.errorOnNon200 !== false || data.catchRequestFailed || data.retryOnNon200) {
285
563
  sections.push({
286
564
  id: 'error-behavior',
287
565
  fields: [
288
- { label: 'Retry on non-200', value: 'Enabled' },
289
- { label: 'Repeat times', value: `${normalizeClassifierNon200RetryCount(data.retryOnNon200RepeatTimes)}` },
290
- { label: 'Cooldown, ms', value: `${normalizeClassifierNon200RetryCooldownMs(data.retryOnNon200CooldownMs)}` },
566
+ ...(data.errorOnNon200 !== false ? [{ label: 'Throw on non-2XX', value: 'Enabled' }] : []),
567
+ ...(data.catchRequestFailed ? [{ label: 'Catch all failures', value: 'Enabled' }] : []),
568
+ ...(data.retryOnNon200
569
+ ? [
570
+ { label: 'Retry on non-200', value: 'Enabled' },
571
+ { label: 'Repeat times', value: `${normalizeClassifierNon200RetryCount(data.retryOnNon200RepeatTimes)}` },
572
+ {
573
+ label: 'Cooldown, ms',
574
+ value: `${normalizeClassifierNon200RetryCooldownMs(data.retryOnNon200CooldownMs)}`,
575
+ },
576
+ ]
577
+ : []),
291
578
  ],
292
579
  });
293
580
  }
294
581
  return sections;
295
582
  }
296
- function compareQuestionPorts([left], [right]) {
583
+ function compareQuestionPorts(left, right) {
297
584
  return Number(left.slice('question'.length)) - Number(right.slice('question'.length));
298
585
  }
299
586
  function getApiKeySourceHelperMessage(data) {
300
587
  if (data.apiKeySource === 'input')
301
588
  return 'Uses the API Key input port instead of a configured provider key.';
302
589
  const provider = getProviderForDisplay(data.provider);
303
- return data.apiKeyNamesByProvider?.[provider.id] == null && data.apiKeyNames == null
304
- ? `Configured key checks ${provider.credentialNames.programmaticName} or ${provider.credentialNames.environmentVariableName}, including Settings > Classifier > ${provider.label} API Key.`
305
- : 'Configured key checks the named programmatic setting first, then the named environment variable.';
590
+ if (data.apiKeySource === 'classifier-settings')
591
+ return `Uses only Settings > Classifier > ${provider.label} API Key on the executor. Does not fall back to named or environment credentials.`;
592
+ return 'Automatic checks the named programmatic setting, then the named environment variable, then the saved Classifier key (default names only). OpenAI also accepts its legacy general key; Jev accepts its legacy plugin key last. Resolution happens on the executor, not in this editor.';
306
593
  }
307
- function flattenQuestions(value, target) {
594
+ function flattenQuestions(value, target, check, seen = new Set(), depth = 0, work = { values: 0 }) {
595
+ check();
596
+ if (++work.values > CLASSIFIER_LIMITS.values)
597
+ throw new Error('Question inputs have too many expanded values.');
598
+ if (depth > CLASSIFIER_LIMITS.depth)
599
+ throw new Error('Question inputs exceed the maximum nesting depth of 64.');
308
600
  if (Array.isArray(value)) {
309
- for (const item of value)
310
- flattenQuestions(item, target);
601
+ if (seen.has(value))
602
+ throw new Error('Question inputs must not contain circular arrays.');
603
+ seen.add(value);
604
+ if (value.length > CLASSIFIER_LIMITS.questions)
605
+ throw new Error('Classifier Evaluate supports at most 1000 questions.');
606
+ for (const item of classifierArrayValues(value, 'Questions'))
607
+ flattenQuestions(item, target, check, seen, depth + 1, work);
608
+ seen.delete(value);
311
609
  return;
312
610
  }
313
611
  if (typeof value !== 'object' || value === null) {
314
612
  throw new Error('Question inputs must contain question definition objects or nested arrays of definitions.');
315
613
  }
614
+ if (target.length >= CLASSIFIER_LIMITS.questions)
615
+ throw new Error('Classifier Evaluate supports at most 1000 questions.');
316
616
  target.push(value);
317
617
  }
318
- function validateQuestion(question) {
319
- if (typeof question.questionId !== 'string' || question.questionId.trim() === '') {
320
- throw new Error('Every classifier question must have a non-empty Question ID.');
321
- }
322
- if (!['choice', 'score', 'noul'].includes(question.type)) {
323
- throw new Error(`Question '${question.questionId}' has an unsupported type.`);
324
- }
325
- assertClassifierInstructions(question.instructions, `Question '${question.questionId}' instructions`);
326
- if (question.type === 'choice') {
327
- const criteria = question.criteria;
328
- if (typeof criteria !== 'object' || criteria === null || Array.isArray(criteria)) {
329
- throw new Error(`Choice question '${question.questionId}' requires object criteria.`);
330
- }
331
- const keys = Object.keys(criteria);
332
- if (keys.length < 2 || keys.length > 255) {
333
- throw new Error(`Choice question '${question.questionId}' requires 2 to 255 options.`);
334
- }
335
- for (const key of keys)
336
- assertClassifierEntry(criteria[key], `Question '${question.questionId}' criteria.${key}`);
337
- }
338
- else if (question.type === 'score') {
339
- const criteria = question.criteria;
340
- if (!Array.isArray(criteria) || criteria.length < 2 || criteria.length > 10) {
341
- throw new Error(`Score question '${question.questionId}' requires 2 to 10 levels.`);
342
- }
343
- criteria.forEach((entry, index) => assertClassifierEntry(entry, `Question '${question.questionId}' criteria[${index}]`));
344
- }
345
- else {
346
- const criteria = question.criteria;
347
- if (criteria !== undefined) {
348
- if (typeof criteria !== 'object' ||
349
- criteria === null ||
350
- Array.isArray(criteria) ||
351
- !Object.prototype.hasOwnProperty.call(criteria, 'true') ||
352
- !Object.prototype.hasOwnProperty.call(criteria, 'false')) {
353
- throw new Error(`Noul question '${question.questionId}' criteria must contain true and false entries.`);
354
- }
355
- assertClassifierEntry(criteria.true, `Question '${question.questionId}' criteria.true`);
356
- assertClassifierEntry(criteria.false, `Question '${question.questionId}' criteria.false`);
357
- }
358
- }
359
- }
360
- function assertClassifierState(value) {
361
- if (typeof value === 'string')
362
- return;
363
- if (typeof value !== 'object' || value === null)
364
- throw new Error('State must be a string, JSON object, or JSON array.');
365
- assertJsonCompatible(value, 'State', new Set());
366
- }
367
- function assertJsonCompatible(value, label, seen) {
368
- if (value === null || typeof value === 'string' || typeof value === 'boolean')
369
- return;
370
- if (typeof value === 'number') {
371
- if (!Number.isFinite(value))
372
- throw new Error(`${label} contains a non-finite number.`);
373
- return;
374
- }
375
- if (typeof value !== 'object')
376
- throw new Error(`${label} is not JSON-compatible.`);
377
- if (seen.has(value))
378
- throw new Error(`${label} contains a circular reference.`);
379
- seen.add(value);
380
- if (Array.isArray(value))
381
- value.forEach((item, index) => assertJsonCompatible(item, `${label}[${index}]`, seen));
382
- else
383
- for (const [key, item] of Object.entries(value))
384
- assertJsonCompatible(item, `${label}.${key}`, seen);
385
- seen.delete(value);
386
- }
387
618
  function normalizeTimeout(timeoutMs) {
388
619
  return typeof timeoutMs === 'number' && Number.isFinite(timeoutMs) && timeoutMs > 0
389
620
  ? Math.min(timeoutMs, 600_000)