@valerypopoff/rivet2-core 2.1.9 → 2.3.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 (188) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/bundle.cjs +5618 -2533
  3. package/dist/cjs/bundle.cjs.map +4 -4
  4. package/dist/cjs/webAppRuntime.cjs +333 -22
  5. package/dist/cjs/webAppRuntime.cjs.map +4 -4
  6. package/dist/esm/api/createProcessor.js +2 -0
  7. package/dist/esm/exports.js +1 -0
  8. package/dist/esm/integrations/CodeRunner.js +2 -7
  9. package/dist/esm/integrations/CodeRunnerOptions.js +7 -0
  10. package/dist/esm/model/AgentResponseTrace.js +558 -0
  11. package/dist/esm/model/ConnectedToolContinuationHost.js +33 -0
  12. package/dist/esm/model/GraphProcessor.js +165 -74
  13. package/dist/esm/model/NodeImpl.js +6 -0
  14. package/dist/esm/model/ProcessContextBuilder.js +3 -1
  15. package/dist/esm/model/RecordingPlayer.js +212 -25
  16. package/dist/esm/model/SplitRunProcessor.js +49 -8
  17. package/dist/esm/model/SubprocessorBridge.js +3 -0
  18. package/dist/esm/model/ToolCallContinuationCoordinator.js +7 -3
  19. package/dist/esm/model/UiGraph.js +21 -0
  20. package/dist/esm/model/UiGraphActionProtocol.js +3 -0
  21. package/dist/esm/model/UiGraphBrowserRuntime.js +133 -4
  22. package/dist/esm/model/UiGraphRendererStyles.js +221 -0
  23. package/dist/esm/model/UiGraphRuntimeModel.js +9 -3
  24. package/dist/esm/model/UiGraphSchema.js +7 -1
  25. package/dist/esm/model/chat/aiSdkTools.js +3 -2
  26. package/dist/esm/model/chat-v2/aiSdkBridge.js +146 -14
  27. package/dist/esm/model/chat-v2/chatV2CallObserver.js +11 -5
  28. package/dist/esm/model/chat-v2/chatV2CredentialNames.js +93 -0
  29. package/dist/esm/model/chat-v2/chatV2EditorCache.js +47 -20
  30. package/dist/esm/model/chat-v2/chatV2Errors.js +7 -19
  31. package/dist/esm/model/chat-v2/chatV2FeatureCompatibility.js +1 -1
  32. package/dist/esm/model/chat-v2/chatV2Outputs.js +48 -108
  33. package/dist/esm/model/chat-v2/chatV2Pipeline.js +101 -149
  34. package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +39 -4
  35. package/dist/esm/model/chat-v2/chatV2ProviderRegistry.js +9 -0
  36. package/dist/esm/model/chat-v2/chatV2RequestPlan.js +2 -3
  37. package/dist/esm/model/chat-v2/chatV2ResponseBodyCapture.js +63 -0
  38. package/dist/esm/model/chat-v2/chatV2ResponseFormat.js +8 -4
  39. package/dist/esm/model/chat-v2/chatV2Retry.js +4 -3
  40. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +7 -7
  41. package/dist/esm/model/chat-v2/chatV2Shared.js +1 -1
  42. package/dist/esm/model/chat-v2/chatV2Types.js +20 -8
  43. package/dist/esm/model/chat-v2/chatV2UsageAccounting.js +78 -0
  44. package/dist/esm/model/chat-v2/customProviderApi.js +40 -0
  45. package/dist/esm/model/chat-v2/index.js +15 -0
  46. package/dist/esm/model/chat-v2/llmChatV2Body.js +289 -0
  47. package/dist/esm/model/chat-v2/llmChatV2CacheBoundary.js +32 -0
  48. package/dist/esm/model/chat-v2/llmChatV2CachePolicy.js +25 -0
  49. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +13 -50
  50. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +117 -24
  51. package/dist/esm/model/chat-v2/llmChatV2NodeMigration.js +24 -0
  52. package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +150 -199
  53. package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +60 -0
  54. package/dist/esm/model/chat-v2/llmInvocationDecision.js +11 -0
  55. package/dist/esm/model/chat-v2/llmInvocationJournal.js +43 -0
  56. package/dist/esm/model/chat-v2/llmInvocationPlan.js +68 -0
  57. package/dist/esm/model/chat-v2/llmInvocationProjections.js +5 -0
  58. package/dist/esm/model/chat-v2/llmInvocationResultProjector.js +48 -0
  59. package/dist/esm/model/chat-v2/llmModelCandidate.js +79 -0
  60. package/dist/esm/model/chat-v2/llmProfile.js +52 -65
  61. package/dist/esm/model/chat-v2/llmProfileBody.js +193 -0
  62. package/dist/esm/model/chat-v2/llmProfileFallback.js +442 -100
  63. package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +74 -0
  64. package/dist/esm/model/chat-v2/llmProfileHealthStore.js +326 -0
  65. package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +55 -33
  66. package/dist/esm/model/chat-v2/llmProfileTypes.js +1 -18
  67. package/dist/esm/model/chat-v2/llmResponseMaterializer.js +42 -0
  68. package/dist/esm/model/chat-v2/modelRegistry.js +54 -4
  69. package/dist/esm/model/chat-v2/parallelToolCalls.js +9 -2
  70. package/dist/esm/model/chat-v2/providerOptions.js +116 -24
  71. package/dist/esm/model/chat-v2/rivetToolRegistry.js +9 -0
  72. package/dist/esm/model/chat-v2/toolCallCodec.js +52 -0
  73. package/dist/esm/model/chat-v2/toolContinuation.js +72 -35
  74. package/dist/esm/model/chat-v2/toolHandlerResolver.js +23 -0
  75. package/dist/esm/model/chat-v2/toolRoundExecutor.js +12 -0
  76. package/dist/esm/model/nodes/ChatNode.js +6 -0
  77. package/dist/esm/model/nodes/ChatNodeBase.js +1 -0
  78. package/dist/esm/model/nodes/CodeNewNode.js +5 -47
  79. package/dist/esm/model/nodes/CodeNode.js +4 -46
  80. package/dist/esm/model/nodes/DelegateFunctionCallNode.js +19 -6
  81. package/dist/esm/model/nodes/ExpressionNode.js +5 -8
  82. package/dist/esm/model/nodes/LLMChatV2Node.js +121 -229
  83. package/dist/esm/model/nodes/LLMProfileNode.js +27 -8
  84. package/dist/esm/model/nodes/MatchNode.js +86 -41
  85. package/dist/esm/model/nodes/PromptNode.js +7 -0
  86. package/dist/esm/model/nodes/ToolNode.js +7 -0
  87. package/dist/esm/model/nodes/toolCallDelegation.js +177 -110
  88. package/dist/esm/plugins/anthropic/anthropic.js +4 -4
  89. package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +7 -0
  90. package/dist/esm/plugins/gentrace/gentraceSdk.js +0 -1
  91. package/dist/esm/plugins/gentrace/index.js +0 -1
  92. package/dist/esm/plugins/gentrace/plugin.js +61 -179
  93. package/dist/esm/plugins/google/google.js +5 -9
  94. package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +4 -1
  95. package/dist/esm/plugins.js +1 -2
  96. package/dist/esm/recording/ExecutionRecorder.js +62 -13
  97. package/dist/esm/utils/emitDetached.js +6 -3
  98. package/dist/esm/utils/openai.js +60 -16
  99. package/dist/esm/utils/serialization/serialization.js +2 -19
  100. package/dist/esm/webAppRuntime.js +3 -2
  101. package/dist/types/api/createProcessor.d.ts +3 -0
  102. package/dist/types/exports.d.ts +1 -0
  103. package/dist/types/integrations/CodeRunner.d.ts +10 -7
  104. package/dist/types/integrations/CodeRunnerOptions.d.ts +15 -0
  105. package/dist/types/model/AgentResponseTrace.d.ts +123 -0
  106. package/dist/types/model/ConnectedToolContinuationHost.d.ts +34 -0
  107. package/dist/types/model/EditorDefinition.d.ts +16 -0
  108. package/dist/types/model/ExecutorProtocol.d.ts +32 -11
  109. package/dist/types/model/GraphProcessor.d.ts +41 -9
  110. package/dist/types/model/NodeBase.d.ts +0 -10
  111. package/dist/types/model/NodeImpl.d.ts +18 -1
  112. package/dist/types/model/Nodes.d.ts +2 -2
  113. package/dist/types/model/ProcessContext.d.ts +99 -0
  114. package/dist/types/model/ProcessContextBuilder.d.ts +3 -1
  115. package/dist/types/model/RecordingPlayer.d.ts +6 -0
  116. package/dist/types/model/SplitRunProcessor.d.ts +10 -3
  117. package/dist/types/model/UiGraph.d.ts +8 -0
  118. package/dist/types/model/UiGraphActionProtocol.d.ts +3 -0
  119. package/dist/types/model/UiGraphBrowserRuntime.d.ts +11 -2
  120. package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
  121. package/dist/types/model/UiGraphRuntimeModel.d.ts +2 -0
  122. package/dist/types/model/UiGraphSchema.d.ts +1 -0
  123. package/dist/types/model/chat-v2/chatV2CallObserver.d.ts +2 -0
  124. package/dist/types/model/chat-v2/chatV2CredentialNames.d.ts +30 -0
  125. package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +2 -3
  126. package/dist/types/model/chat-v2/chatV2Outputs.d.ts +6 -16
  127. package/dist/types/model/chat-v2/chatV2Pipeline.d.ts +13 -17
  128. package/dist/types/model/chat-v2/chatV2ProviderProfile.d.ts +7 -0
  129. package/dist/types/model/chat-v2/chatV2ProviderRegistry.d.ts +8 -0
  130. package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +2 -2
  131. package/dist/types/model/chat-v2/chatV2ResponseBodyCapture.d.ts +25 -0
  132. package/dist/types/model/chat-v2/chatV2ResponseFormat.d.ts +3 -2
  133. package/dist/types/model/chat-v2/chatV2Retry.d.ts +2 -0
  134. package/dist/types/model/chat-v2/chatV2RuntimeOptions.d.ts +3 -8
  135. package/dist/types/model/chat-v2/chatV2Types.d.ts +44 -10
  136. package/dist/types/model/chat-v2/chatV2UsageAccounting.d.ts +14 -0
  137. package/dist/types/model/chat-v2/customProviderApi.d.ts +22 -0
  138. package/dist/types/model/chat-v2/index.d.ts +15 -0
  139. package/dist/types/model/chat-v2/llmChatV2Body.d.ts +24 -0
  140. package/dist/types/model/chat-v2/llmChatV2CacheBoundary.d.ts +10 -0
  141. package/dist/types/model/chat-v2/llmChatV2CachePolicy.d.ts +13 -0
  142. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +19 -3
  143. package/dist/types/model/chat-v2/llmChatV2NodeMigration.d.ts +8 -0
  144. package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +14 -16
  145. package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +16 -0
  146. package/dist/types/model/chat-v2/llmInvocationDecision.d.ts +21 -0
  147. package/dist/types/model/chat-v2/llmInvocationJournal.d.ts +38 -0
  148. package/dist/types/model/chat-v2/llmInvocationPlan.d.ts +41 -0
  149. package/dist/types/model/chat-v2/llmInvocationProjections.d.ts +3 -0
  150. package/dist/types/model/chat-v2/llmInvocationResultProjector.d.ts +26 -0
  151. package/dist/types/model/chat-v2/llmModelCandidate.d.ts +20 -0
  152. package/dist/types/model/chat-v2/llmProfile.d.ts +14 -0
  153. package/dist/types/model/chat-v2/llmProfileBody.d.ts +20 -0
  154. package/dist/types/model/chat-v2/llmProfileFallback.d.ts +36 -49
  155. package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +209 -0
  156. package/dist/types/model/chat-v2/llmProfileHealthStore.d.ts +111 -0
  157. package/dist/types/model/chat-v2/llmProfileNodeRuntime.d.ts +1 -1
  158. package/dist/types/model/chat-v2/llmProfileTypes.d.ts +4 -1
  159. package/dist/types/model/chat-v2/llmResponseMaterializer.d.ts +20 -0
  160. package/dist/types/model/chat-v2/modelRegistry.d.ts +17 -187
  161. package/dist/types/model/chat-v2/parallelToolCalls.d.ts +3 -1
  162. package/dist/types/model/chat-v2/providerOptions.d.ts +12 -0
  163. package/dist/types/model/chat-v2/rivetToolRegistry.d.ts +11 -0
  164. package/dist/types/model/chat-v2/toolCallCodec.d.ts +7 -0
  165. package/dist/types/model/chat-v2/toolContinuation.d.ts +3 -3
  166. package/dist/types/model/chat-v2/toolHandlerResolver.d.ts +25 -0
  167. package/dist/types/model/chat-v2/toolRoundExecutor.d.ts +18 -0
  168. package/dist/types/model/nodes/ChatNode.d.ts +2 -1
  169. package/dist/types/model/nodes/CodeNewNode.d.ts +0 -5
  170. package/dist/types/model/nodes/CodeNode.d.ts +0 -5
  171. package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +2 -1
  172. package/dist/types/model/nodes/LLMChatV2Node.d.ts +2 -1
  173. package/dist/types/model/nodes/LLMProfileNode.d.ts +2 -1
  174. package/dist/types/model/nodes/MatchNode.d.ts +6 -0
  175. package/dist/types/model/nodes/PromptNode.d.ts +4 -1
  176. package/dist/types/model/nodes/ToolNode.d.ts +2 -1
  177. package/dist/types/model/nodes/toolCallDelegation.d.ts +10 -3
  178. package/dist/types/plugins/anthropic/anthropic.d.ts +1 -0
  179. package/dist/types/plugins/gentrace/gentraceSdk.d.ts +0 -1
  180. package/dist/types/plugins/gentrace/plugin.d.ts +55 -9
  181. package/dist/types/plugins/google/google.d.ts +2 -8
  182. package/dist/types/plugins.d.ts +1 -1
  183. package/dist/types/recording/ExecutionRecorder.d.ts +7 -1
  184. package/dist/types/recording/RecordedEvents.d.ts +6 -0
  185. package/dist/types/utils/emitDetached.d.ts +3 -2
  186. package/dist/types/utils/openai.d.ts +49 -0
  187. package/dist/types/webAppRuntime.d.ts +4 -2
  188. package/package.json +2 -2
@@ -0,0 +1,289 @@
1
+ import { DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_COOLDOWN_MS, DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_REPEAT_TIMES, } from './chatV2Retry.js';
2
+ import { getNonDefaultChatV2CredentialNames } from './chatV2CredentialNames.js';
3
+ import { getChatV2ModelInfo } from './modelRegistry.js';
4
+ import { anthropicCacheControlTtlOptions, anthropicEffortOptions, anthropicThinkingModeOptions, getChatV2ProviderLabel, getCustomProviderApiContract, googleThinkingLevelOptions, openAIReasoningEffortOptions, openAIWebSearchContextSizeOptions, } from './providerOptions.js';
5
+ function getOptionLabel(options, value) {
6
+ const optionValue = typeof value === 'string' ? value : '';
7
+ return options.find((option) => option.value === optionValue)?.label ?? (optionValue || 'Default');
8
+ }
9
+ function getProviderBodyLabel(data) {
10
+ return data.provider === 'custom' ? 'Custom' : getChatV2ProviderLabel(data.provider);
11
+ }
12
+ function getModelBodyValue(data) {
13
+ if (data.useModelInput) {
14
+ return '(Using Input)';
15
+ }
16
+ try {
17
+ return getChatV2ModelInfo(data.provider, data.model)?.displayName ?? data.model;
18
+ }
19
+ catch {
20
+ // Hand-authored/corrupt projects should remain inspectable on the canvas.
21
+ return data.model;
22
+ }
23
+ }
24
+ function getCustomProviderBaseURLBodyValue(data) {
25
+ if (data.provider !== 'custom') {
26
+ return undefined;
27
+ }
28
+ if (data.useCustomProviderBaseURLInput) {
29
+ return '(Using Input)';
30
+ }
31
+ const baseURL = typeof data.customProviderBaseURL === 'string' ? data.customProviderBaseURL.trim() : '';
32
+ return baseURL || undefined;
33
+ }
34
+ function getCustomProviderApiBodyField(data) {
35
+ if (data.provider !== 'custom') {
36
+ return undefined;
37
+ }
38
+ try {
39
+ const api = getCustomProviderApiContract(data.customProviderApi);
40
+ return api.api === 'completions' ? undefined : { label: 'API', value: api.label };
41
+ }
42
+ catch {
43
+ return { label: 'API', value: `Unsupported (${String(data.customProviderApi)})` };
44
+ }
45
+ }
46
+ function getOptionalNumberBodyField(label, value, usesInput) {
47
+ if (usesInput) {
48
+ return { label, value: '(Using Input)' };
49
+ }
50
+ return value === undefined ? undefined : { label, value: `${value}` };
51
+ }
52
+ function getOptionalStringBodyField(label, value, usesInput) {
53
+ if (usesInput) {
54
+ return { label, value: '(Using Input)' };
55
+ }
56
+ return typeof value === 'string' && value.trim().length > 0 ? { label, value } : undefined;
57
+ }
58
+ function getStopSequencesBodyField(data) {
59
+ if (data.useStopSequencesInput) {
60
+ return { label: 'Stop sequences', value: '(Using Input)' };
61
+ }
62
+ const stopSequences = Array.isArray(data.stopSequences)
63
+ ? data.stopSequences.filter((sequence) => typeof sequence === 'string' && sequence.length > 0)
64
+ : [];
65
+ return stopSequences.length === 0
66
+ ? undefined
67
+ : { label: 'Stop sequences', value: stopSequences.map((sequence) => JSON.stringify(sequence)).join(', ') };
68
+ }
69
+ function getHeadersBodyField(data) {
70
+ if (data.useHeadersInput) {
71
+ return { label: 'Headers', value: '(Using Input)' };
72
+ }
73
+ const headers = Array.isArray(data.headers)
74
+ ? data.headers.filter((header) => typeof header?.key === 'string' && header.key.trim().length > 0 && typeof header.value === 'string')
75
+ : [];
76
+ return headers.length > 0
77
+ ? { label: 'Headers', value: headers.map(({ key, value }) => `${key}: ${value}`).join(', ') }
78
+ : undefined;
79
+ }
80
+ function getProviderBodyFields(data) {
81
+ switch (data.provider) {
82
+ case 'openai':
83
+ return [
84
+ getOptionalStringBodyField('Previous response ID', data.openAIPreviousResponseId, data.useOpenAIPreviousResponseIdInput),
85
+ ...(data.openAIReasoningSummary ? [{ label: 'Reasoning summary', value: data.openAIReasoningSummary }] : []),
86
+ ...(data.enableOpenAIWebSearch
87
+ ? [
88
+ {
89
+ label: 'Web search',
90
+ value: `Enabled (${getOptionLabel(openAIWebSearchContextSizeOptions, data.openAIWebSearchContextSize)})`,
91
+ },
92
+ ]
93
+ : []),
94
+ ...(data.enableOpenAICodeInterpreter ? [{ label: 'Code interpreter', value: 'Enabled' }] : []),
95
+ ].filter((field) => field !== undefined);
96
+ case 'anthropic':
97
+ return [
98
+ ...(data.anthropicThinkingMode
99
+ ? [
100
+ {
101
+ label: 'Thinking mode',
102
+ value: getOptionLabel(anthropicThinkingModeOptions, data.anthropicThinkingMode),
103
+ },
104
+ ]
105
+ : []),
106
+ getOptionalNumberBodyField('Thinking budget', data.anthropicThinkingBudget, data.useAnthropicThinkingBudgetInput),
107
+ ...(data.anthropicCacheControlTtl
108
+ ? [
109
+ {
110
+ label: 'Cache breakpoint TTL',
111
+ value: getOptionLabel(anthropicCacheControlTtlOptions, data.anthropicCacheControlTtl),
112
+ },
113
+ ]
114
+ : []),
115
+ ].filter((field) => field !== undefined);
116
+ case 'google':
117
+ return [
118
+ getOptionalNumberBodyField('Thinking budget', data.googleThinkingBudget, data.useGoogleThinkingBudgetInput),
119
+ ...(data.googleIncludeThoughts ? [{ label: 'Include thoughts', value: 'Enabled' }] : []),
120
+ ...(data.enableGoogleSearchGrounding ? [{ label: 'Google search grounding', value: 'Enabled' }] : []),
121
+ ...(data.enableGoogleUrlContext ? [{ label: 'URL context', value: 'Enabled' }] : []),
122
+ ].filter((field) => field !== undefined);
123
+ case 'custom':
124
+ default:
125
+ return [];
126
+ }
127
+ }
128
+ function getResponseFormatBodyFields(data) {
129
+ if (!data.responseFormat) {
130
+ return [];
131
+ }
132
+ const responseFormatLabel = data.responseFormat === 'json_schema' ? 'JSON schema' : data.responseFormat === 'json' ? 'JSON object' : 'Text';
133
+ const hasSchemaMetadata = data.responseFormat === 'json' || data.responseFormat === 'json_schema';
134
+ return [
135
+ { label: 'Response format', value: responseFormatLabel },
136
+ ...(hasSchemaMetadata
137
+ ? [
138
+ getOptionalStringBodyField('Schema name', data.responseSchemaName, !!data.useResponseSchemaNameInput),
139
+ getOptionalStringBodyField('Schema description', data.responseSchemaDescription, !!data.useResponseSchemaDescriptionInput),
140
+ ]
141
+ : []),
142
+ ].filter((field) => field !== undefined);
143
+ }
144
+ function getToolBodyFields(data) {
145
+ if (!data.useToolCalling) {
146
+ return [];
147
+ }
148
+ return [
149
+ { label: 'Tool use', value: 'Enabled' },
150
+ ...(data.toolChoice
151
+ ? [
152
+ {
153
+ label: 'Tool choice',
154
+ value: data.toolChoice === 'function'
155
+ ? data.toolChoiceFunction?.trim()
156
+ ? `Specific tool (${data.toolChoiceFunction})`
157
+ : 'Specific tool'
158
+ : data.toolChoice === 'required'
159
+ ? 'Required'
160
+ : 'Auto',
161
+ },
162
+ ]
163
+ : []),
164
+ ...(data.parallelToolCalls ? [{ label: 'Parallel toolcalls', value: 'Enabled' }] : []),
165
+ ...(data.autoContinueToolCalls
166
+ ? [
167
+ { label: 'Auto-continue toolcalls', value: 'Enabled' },
168
+ { label: 'Maximum tool rounds', value: `${data.maxToolRounds ?? 3}` },
169
+ ]
170
+ : []),
171
+ ];
172
+ }
173
+ function getBehaviorBodyFields(data) {
174
+ return [
175
+ ...(data.useAsGraphPartialOutput ? [{ label: 'Stream response', value: 'Enabled' }] : []),
176
+ ...(data.cache ? [{ label: 'Editor cache (legacy)', value: 'Enabled' }] : []),
177
+ ];
178
+ }
179
+ function getErrorBodyFields(data) {
180
+ if (!data.retryOnNon200) {
181
+ return [];
182
+ }
183
+ const repeatTimes = data.retryOnNon200RepeatTimes ?? DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_REPEAT_TIMES;
184
+ const cooldownMs = data.retryOnNon200CooldownMs ?? DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_COOLDOWN_MS;
185
+ return [
186
+ { label: 'Retry on non-200', value: 'Enabled' },
187
+ { label: 'Repeat times', value: `${repeatTimes}` },
188
+ { label: 'Cooldown, ms', value: `${cooldownMs}` },
189
+ ];
190
+ }
191
+ function getAdvancedBodySection(data) {
192
+ const extraProviderOptions = !data.useExtraProviderOptionsInput &&
193
+ typeof data.extraProviderOptions === 'string' &&
194
+ data.extraProviderOptions.trim().length > 0
195
+ ? { label: 'Extra provider options', text: data.extraProviderOptions }
196
+ : undefined;
197
+ return {
198
+ id: 'advanced',
199
+ fields: [
200
+ getHeadersBodyField(data),
201
+ ...(data.useExtraProviderOptionsInput ? [{ label: 'Extra provider options', value: '(Using Input)' }] : []),
202
+ ].filter((field) => field !== undefined),
203
+ snippet: extraProviderOptions,
204
+ };
205
+ }
206
+ function getInlineModelBodyFields(data) {
207
+ const customBaseURL = getCustomProviderBaseURLBodyValue(data);
208
+ const credentialNames = getNonDefaultChatV2CredentialNames(data.provider, data.providerApiKeyNames);
209
+ return [
210
+ { label: 'Provider', value: getProviderBodyLabel(data) },
211
+ getCustomProviderApiBodyField(data),
212
+ customBaseURL ? { label: 'Base URL', value: customBaseURL } : undefined,
213
+ { label: 'Model', value: getModelBodyValue(data) },
214
+ ...(data.apiKeySource === 'input' ? [{ label: 'API key source', value: 'Input port' }] : []),
215
+ ...(credentialNames != null && data.apiKeySource !== 'input'
216
+ ? [
217
+ { label: 'Programmatic API key name', value: credentialNames.programmaticName },
218
+ { label: 'API key environment variable', value: credentialNames.environmentVariableName },
219
+ ]
220
+ : []),
221
+ ...(data.provider === 'custom' && data.apiKeySource !== 'input'
222
+ ? [
223
+ data.customProviderApiKeyProgrammaticName?.trim()
224
+ ? { label: 'Alternative programmatic key', value: data.customProviderApiKeyProgrammaticName }
225
+ : undefined,
226
+ data.customProviderApiKeyEnvVarName?.trim() &&
227
+ data.customProviderApiKeyEnvVarName !== 'CUSTOM_PROVIDER_API_KEY'
228
+ ? { label: 'Alternative API key env var', value: data.customProviderApiKeyEnvVarName }
229
+ : undefined,
230
+ ]
231
+ : []),
232
+ ].filter((field) => field !== undefined);
233
+ }
234
+ function getParameterBodyFields(data) {
235
+ const reasoningEffort = data.provider === 'openai'
236
+ ? getOptionLabel(openAIReasoningEffortOptions, data.openAIReasoningEffort)
237
+ : data.provider === 'anthropic'
238
+ ? getOptionLabel(anthropicEffortOptions, data.anthropicEffort)
239
+ : data.provider === 'google'
240
+ ? getOptionLabel(googleThinkingLevelOptions, data.googleThinkingLevel)
241
+ : undefined;
242
+ return [
243
+ ...(reasoningEffort ? [{ label: 'Reasoning effort', value: reasoningEffort }] : []),
244
+ { label: 'Temperature', value: data.useTemperatureInput ? '(Using Input)' : `${data.temperature}` },
245
+ { label: 'Max output tokens', value: data.useMaxTokensInput ? '(Using Input)' : `${data.maxTokens}` },
246
+ getOptionalNumberBodyField('Top P', data.topP, data.useTopPInput),
247
+ getOptionalNumberBodyField('Top K', data.topK, data.useTopKInput),
248
+ getOptionalNumberBodyField('Presence penalty', data.presencePenalty, data.usePresencePenaltyInput),
249
+ getOptionalNumberBodyField('Frequency penalty', data.frequencyPenalty, data.useFrequencyPenaltyInput),
250
+ getStopSequencesBodyField(data),
251
+ getOptionalNumberBodyField('Seed', data.seed, data.useSeedInput),
252
+ ].filter((field) => field !== undefined);
253
+ }
254
+ function getInvocationSections(data) {
255
+ const sections = [
256
+ { id: 'response-format', fields: getResponseFormatBodyFields(data) },
257
+ { id: 'tools', fields: getToolBodyFields(data) },
258
+ { id: 'behavior', fields: getBehaviorBodyFields(data) },
259
+ { id: 'error', fields: getErrorBodyFields(data) },
260
+ ];
261
+ return sections.filter((section) => section.fields.length > 0);
262
+ }
263
+ /**
264
+ * Stable canvas presentation data for LLM Chat configuration.
265
+ *
266
+ * Inline mode exposes its local model/provider settings plus every active
267
+ * invocation setting. Profile mode deliberately exposes only invocation-owned
268
+ * settings because provider configuration comes from the connected LLM Profile
269
+ * value at runtime. Output toggles are intentionally omitted: their ports are
270
+ * already the canonical canvas indication that an output is enabled.
271
+ */
272
+ export function getLLMChatV2BodySections(data) {
273
+ if (data.configurationMode === 'profile') {
274
+ const sections = [
275
+ { id: 'configuration', fields: [{ label: 'Configuration', value: 'From LLM Profiles input' }] },
276
+ ...getInvocationSections(data),
277
+ ];
278
+ return sections;
279
+ }
280
+ const advancedSection = getAdvancedBodySection(data);
281
+ const sections = [
282
+ { id: 'model', fields: getInlineModelBodyFields(data) },
283
+ { id: 'parameters', fields: getParameterBodyFields(data) },
284
+ { id: 'provider', fields: getProviderBodyFields(data) },
285
+ ...getInvocationSections(data),
286
+ advancedSection,
287
+ ];
288
+ return sections.filter((section) => section.fields.length > 0 || section.snippet !== undefined);
289
+ }
@@ -0,0 +1,32 @@
1
+ import { isChatV2PipelineProviderFailureResult } from './chatV2Pipeline.js';
2
+ import { cloneLLMChatV2EditorCacheOutputs } from './chatV2EditorCache.js';
3
+ /** Projects cache hits as current-run output without inventing provider work. */
4
+ export function projectLLMChatV2EditorCacheHit(runtime) {
5
+ const outputs = runtime.cachedOutputs;
6
+ if (outputs == null)
7
+ return undefined;
8
+ if (runtime.getProfileSummary != null) {
9
+ outputs['llmProfileSummary'] = {
10
+ type: 'string',
11
+ value: 'Editor cache hit — no LLM Profile calls were made for this run.',
12
+ };
13
+ }
14
+ if (runtime.outputLLMAttempts) {
15
+ outputs['llmAttempts'] = { type: 'object[]', value: [] };
16
+ }
17
+ return outputs;
18
+ }
19
+ /** Caches only final model answers; failed invocations never reach this boundary. */
20
+ export function writeLLMChatV2EditorCache(params) {
21
+ const { runtime, result } = params;
22
+ if (runtime.cacheKey == null ||
23
+ runtime.editorCache == null ||
24
+ runtime.isProfileFallbackExhausted() ||
25
+ isChatV2PipelineProviderFailureResult(result)) {
26
+ return;
27
+ }
28
+ const cacheOutputs = cloneLLMChatV2EditorCacheOutputs(result.commonOutputs);
29
+ delete cacheOutputs['llmAttempts'];
30
+ delete cacheOutputs['llmProfileSummary'];
31
+ runtime.editorCache.set(runtime.cacheKey, cacheOutputs);
32
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Editor-cache replay is safe only for ordinary deterministic model calls.
3
+ * Tool-capable calls can have side effects or live Delegate run shapes that a
4
+ * cached final output cannot reproduce.
5
+ */
6
+ export function getLLMChatV2EditorCacheEligibility(data) {
7
+ if (!data.cache) {
8
+ return { eligible: false, reason: 'disabled' };
9
+ }
10
+ if (data.enableCircuitBreaker === true) {
11
+ // Cross-run provider health is mutable external state. Replaying a cached
12
+ // response would bypass the health gate and make recovery diagnostics lie.
13
+ return { eligible: false, reason: 'circuit-breaker' };
14
+ }
15
+ if (data.useToolCalling) {
16
+ return { eligible: false, reason: 'rivet-tools' };
17
+ }
18
+ if (data.enableOpenAIWebSearch ||
19
+ data.enableOpenAICodeInterpreter ||
20
+ data.enableGoogleSearchGrounding ||
21
+ data.enableGoogleUrlContext) {
22
+ return { eligible: false, reason: 'provider-native-tools' };
23
+ }
24
+ return { eligible: true };
25
+ }
@@ -1,53 +1,9 @@
1
1
  import { createChatV2CommonNodeData } from './chatV2Shared.js';
2
2
  import { DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_COOLDOWN_MS, DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_REPEAT_TIMES, } from './chatV2Retry.js';
3
- export const llmChatV2ProfileDataKeys = [
4
- 'model',
5
- 'useModelInput',
6
- 'temperature',
7
- 'useTemperatureInput',
8
- 'topP',
9
- 'useTopPInput',
10
- 'topK',
11
- 'useTopKInput',
12
- 'presencePenalty',
13
- 'usePresencePenaltyInput',
14
- 'frequencyPenalty',
15
- 'useFrequencyPenaltyInput',
16
- 'stopSequences',
17
- 'useStopSequencesInput',
18
- 'seed',
19
- 'useSeedInput',
20
- 'maxTokens',
21
- 'useMaxTokensInput',
22
- 'provider',
23
- 'apiKeySource',
24
- 'customProviderApiKeyProgrammaticName',
25
- 'customProviderApiKeyEnvVarName',
26
- 'customProviderBaseURL',
27
- 'useCustomProviderBaseURLInput',
28
- 'headers',
29
- 'useHeadersInput',
30
- 'extraProviderOptions',
31
- 'useExtraProviderOptionsInput',
32
- 'openAIReasoningEffort',
33
- 'openAIReasoningSummary',
34
- 'openAIPreviousResponseId',
35
- 'useOpenAIPreviousResponseIdInput',
36
- 'enableOpenAIWebSearch',
37
- 'openAIWebSearchContextSize',
38
- 'enableOpenAICodeInterpreter',
39
- 'anthropicThinkingMode',
40
- 'anthropicThinkingBudget',
41
- 'useAnthropicThinkingBudgetInput',
42
- 'anthropicEffort',
43
- 'anthropicCacheControlTtl',
44
- 'googleThinkingBudget',
45
- 'useGoogleThinkingBudgetInput',
46
- 'googleThinkingLevel',
47
- 'googleIncludeThoughts',
48
- 'enableGoogleSearchGrounding',
49
- 'enableGoogleUrlContext',
50
- ];
3
+ import { llmProfileDataKeys } from './llmProfileFieldRegistry.js';
4
+ import { DEFAULT_LLM_PROFILE_CIRCUIT_FAILURE_THRESHOLD, DEFAULT_LLM_PROFILE_CIRCUIT_FAILURE_WINDOW_MS, DEFAULT_LLM_PROFILE_CIRCUIT_OPEN_DURATION_MS, DEFAULT_LLM_PROFILE_FIRST_OUTPUT_TIMEOUT_MS, DEFAULT_LLM_PROFILE_STREAM_INACTIVITY_TIMEOUT_MS, } from './llmProfileHealthStore.js';
5
+ /** @deprecated Use llmProfileDataKeys from llmProfileFieldRegistry instead. */
6
+ export const llmChatV2ProfileDataKeys = llmProfileDataKeys;
51
7
  export function createLLMChatV2NodeData() {
52
8
  return {
53
9
  ...createChatV2CommonNodeData({
@@ -60,6 +16,7 @@ export function createLLMChatV2NodeData() {
60
16
  customProviderApiKeyEnvVarName: 'CUSTOM_PROVIDER_API_KEY',
61
17
  customProviderBaseURL: '',
62
18
  useCustomProviderBaseURLInput: false,
19
+ customProviderApi: 'completions',
63
20
  baseURL: '',
64
21
  useBaseURLInput: false,
65
22
  headers: [],
@@ -84,6 +41,12 @@ export function createLLMChatV2NodeData() {
84
41
  googleIncludeThoughts: false,
85
42
  enableGoogleSearchGrounding: false,
86
43
  enableGoogleUrlContext: false,
44
+ enableCircuitBreaker: false,
45
+ firstOutputTimeoutMs: DEFAULT_LLM_PROFILE_FIRST_OUTPUT_TIMEOUT_MS,
46
+ streamInactivityTimeoutMs: DEFAULT_LLM_PROFILE_STREAM_INACTIVITY_TIMEOUT_MS,
47
+ circuitBreakerFailureThreshold: DEFAULT_LLM_PROFILE_CIRCUIT_FAILURE_THRESHOLD,
48
+ circuitBreakerFailureWindowMs: DEFAULT_LLM_PROFILE_CIRCUIT_FAILURE_WINDOW_MS,
49
+ circuitBreakerOpenDurationMs: DEFAULT_LLM_PROFILE_CIRCUIT_OPEN_DURATION_MS,
87
50
  responseFormat: '',
88
51
  responseSchemaName: '',
89
52
  useResponseSchemaNameInput: false,
@@ -97,9 +60,9 @@ export function createLLMChatV2NodeData() {
97
60
  retryOnNon200: false,
98
61
  retryOnNon200RepeatTimes: DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_REPEAT_TIMES,
99
62
  retryOnNon200CooldownMs: DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_COOLDOWN_MS,
100
- outputRequestStatus: false,
101
- outputRequestError: false,
63
+ outputLLMAttempts: false,
102
64
  outputRequestBody: false,
65
+ outputResponseBody: false,
103
66
  };
104
67
  }
105
68
  export function shouldIncludeLLMChatV2ToolCalls(data) {