@valerypopoff/rivet2-core 2.1.8 → 2.1.10

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 (168) hide show
  1. package/dist/cjs/bundle.cjs +4457 -1809
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/cjs/webAppRuntime.cjs +298 -21
  4. package/dist/cjs/webAppRuntime.cjs.map +4 -4
  5. package/dist/esm/exports.js +1 -0
  6. package/dist/esm/model/AgentResponseTrace.js +448 -0
  7. package/dist/esm/model/ConnectedToolContinuationHost.js +33 -0
  8. package/dist/esm/model/GraphProcessor.js +152 -74
  9. package/dist/esm/model/NodeImpl.js +6 -0
  10. package/dist/esm/model/ProcessContextBuilder.js +3 -1
  11. package/dist/esm/model/RecordingPlayer.js +164 -22
  12. package/dist/esm/model/SplitRunProcessor.js +68 -18
  13. package/dist/esm/model/SubprocessorBridge.js +2 -0
  14. package/dist/esm/model/ToolCallContinuationCoordinator.js +13 -4
  15. package/dist/esm/model/UiGraph.js +21 -0
  16. package/dist/esm/model/UiGraphActionProtocol.js +2 -0
  17. package/dist/esm/model/UiGraphBrowserRuntime.js +133 -4
  18. package/dist/esm/model/UiGraphRendererStyles.js +221 -0
  19. package/dist/esm/model/UiGraphRuntimeModel.js +9 -3
  20. package/dist/esm/model/UiGraphSchema.js +7 -1
  21. package/dist/esm/model/chat/aiSdkMessages.js +8 -0
  22. package/dist/esm/model/chat/aiSdkTools.js +3 -2
  23. package/dist/esm/model/chat-v2/chatV2CallObserver.js +11 -5
  24. package/dist/esm/model/chat-v2/chatV2EditorCache.js +58 -10
  25. package/dist/esm/model/chat-v2/chatV2Errors.js +7 -19
  26. package/dist/esm/model/chat-v2/chatV2FeatureCompatibility.js +1 -1
  27. package/dist/esm/model/chat-v2/chatV2Outputs.js +56 -106
  28. package/dist/esm/model/chat-v2/chatV2Pipeline.js +142 -149
  29. package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +9 -2
  30. package/dist/esm/model/chat-v2/chatV2ProviderRegistry.js +9 -0
  31. package/dist/esm/model/chat-v2/chatV2RequestPlan.js +5 -5
  32. package/dist/esm/model/chat-v2/chatV2ResponseBodyCapture.js +55 -0
  33. package/dist/esm/model/chat-v2/chatV2ResponseFormat.js +8 -4
  34. package/dist/esm/model/chat-v2/chatV2Retry.js +4 -3
  35. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +6 -1
  36. package/dist/esm/model/chat-v2/chatV2Shared.js +1 -6
  37. package/dist/esm/model/chat-v2/chatV2Types.js +7 -1
  38. package/dist/esm/model/chat-v2/chatV2UsageAccounting.js +78 -0
  39. package/dist/esm/model/chat-v2/customProviderApi.js +42 -0
  40. package/dist/esm/model/chat-v2/developerMessageRoles.js +45 -0
  41. package/dist/esm/model/chat-v2/index.js +12 -0
  42. package/dist/esm/model/chat-v2/llmChatV2Body.js +281 -0
  43. package/dist/esm/model/chat-v2/llmChatV2CacheBoundary.js +32 -0
  44. package/dist/esm/model/chat-v2/llmChatV2CachePolicy.js +20 -0
  45. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +8 -54
  46. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +41 -20
  47. package/dist/esm/model/chat-v2/llmChatV2NodeMigration.js +24 -0
  48. package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +178 -94
  49. package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +60 -0
  50. package/dist/esm/model/chat-v2/llmInvocationDecision.js +11 -0
  51. package/dist/esm/model/chat-v2/llmInvocationJournal.js +43 -0
  52. package/dist/esm/model/chat-v2/llmInvocationPlan.js +68 -0
  53. package/dist/esm/model/chat-v2/llmInvocationProjections.js +5 -0
  54. package/dist/esm/model/chat-v2/llmInvocationResultProjector.js +48 -0
  55. package/dist/esm/model/chat-v2/llmModelCandidate.js +75 -0
  56. package/dist/esm/model/chat-v2/llmProfile.js +31 -65
  57. package/dist/esm/model/chat-v2/llmProfileBody.js +183 -0
  58. package/dist/esm/model/chat-v2/llmProfileFallback.js +244 -0
  59. package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +67 -0
  60. package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +3 -0
  61. package/dist/esm/model/chat-v2/llmProfileTypes.js +1 -18
  62. package/dist/esm/model/chat-v2/llmResponseMaterializer.js +42 -0
  63. package/dist/esm/model/chat-v2/messageConverter.js +14 -0
  64. package/dist/esm/model/chat-v2/modelRegistry.js +54 -4
  65. package/dist/esm/model/chat-v2/parallelToolCalls.js +9 -2
  66. package/dist/esm/model/chat-v2/providerOptions.js +120 -21
  67. package/dist/esm/model/chat-v2/rivetToolRegistry.js +9 -0
  68. package/dist/esm/model/chat-v2/toolCallCodec.js +52 -0
  69. package/dist/esm/model/chat-v2/toolContinuation.js +72 -39
  70. package/dist/esm/model/chat-v2/toolHandlerResolver.js +23 -0
  71. package/dist/esm/model/chat-v2/toolRoundExecutor.js +12 -0
  72. package/dist/esm/model/nodes/AssembleMessageNode.js +6 -0
  73. package/dist/esm/model/nodes/ChatNode.js +6 -0
  74. package/dist/esm/model/nodes/ChatNodeBase.js +1 -0
  75. package/dist/esm/model/nodes/DelegateFunctionCallNode.js +26 -1
  76. package/dist/esm/model/nodes/LLMChatV2Node.js +131 -144
  77. package/dist/esm/model/nodes/LLMProfileNode.js +27 -8
  78. package/dist/esm/model/nodes/PromptNode.js +16 -2
  79. package/dist/esm/model/nodes/ToolNode.js +7 -0
  80. package/dist/esm/model/nodes/toolCallDelegation.js +193 -110
  81. package/dist/esm/plugins/anthropic/anthropic.js +4 -4
  82. package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +29 -28
  83. package/dist/esm/plugins/google/google.js +25 -18
  84. package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +21 -7
  85. package/dist/esm/recording/ExecutionRecorder.js +13 -5
  86. package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +4 -0
  87. package/dist/esm/utils/emitDetached.js +6 -3
  88. package/dist/esm/utils/openai.js +60 -16
  89. package/dist/esm/utils/serialization/serialization.js +2 -0
  90. package/dist/esm/webAppRuntime.js +3 -2
  91. package/dist/types/exports.d.ts +1 -0
  92. package/dist/types/model/AgentResponseTrace.d.ts +110 -0
  93. package/dist/types/model/ConnectedToolContinuationHost.d.ts +34 -0
  94. package/dist/types/model/DataValue.d.ts +7 -1
  95. package/dist/types/model/ExecutorProtocol.d.ts +25 -7
  96. package/dist/types/model/GraphProcessor.d.ts +27 -5
  97. package/dist/types/model/NodeBase.d.ts +6 -0
  98. package/dist/types/model/NodeImpl.d.ts +18 -1
  99. package/dist/types/model/Nodes.d.ts +2 -2
  100. package/dist/types/model/ProcessContext.d.ts +51 -0
  101. package/dist/types/model/ProcessContextBuilder.d.ts +3 -1
  102. package/dist/types/model/RecordingPlayer.d.ts +6 -0
  103. package/dist/types/model/SplitRunProcessor.d.ts +11 -3
  104. package/dist/types/model/UiGraph.d.ts +8 -0
  105. package/dist/types/model/UiGraphActionProtocol.d.ts +2 -0
  106. package/dist/types/model/UiGraphBrowserRuntime.d.ts +11 -2
  107. package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
  108. package/dist/types/model/UiGraphRuntimeModel.d.ts +2 -0
  109. package/dist/types/model/UiGraphSchema.d.ts +1 -0
  110. package/dist/types/model/chat-v2/chatV2CallObserver.d.ts +2 -0
  111. package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +3 -1
  112. package/dist/types/model/chat-v2/chatV2Outputs.d.ts +7 -17
  113. package/dist/types/model/chat-v2/chatV2Pipeline.d.ts +29 -0
  114. package/dist/types/model/chat-v2/chatV2ProviderProfile.d.ts +5 -0
  115. package/dist/types/model/chat-v2/chatV2ProviderRegistry.d.ts +8 -0
  116. package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +2 -2
  117. package/dist/types/model/chat-v2/chatV2ResponseBodyCapture.d.ts +19 -0
  118. package/dist/types/model/chat-v2/chatV2ResponseFormat.d.ts +3 -2
  119. package/dist/types/model/chat-v2/chatV2Retry.d.ts +2 -0
  120. package/dist/types/model/chat-v2/chatV2Shared.d.ts +0 -1
  121. package/dist/types/model/chat-v2/chatV2Types.d.ts +35 -1
  122. package/dist/types/model/chat-v2/chatV2UsageAccounting.d.ts +14 -0
  123. package/dist/types/model/chat-v2/customProviderApi.d.ts +23 -0
  124. package/dist/types/model/chat-v2/developerMessageRoles.d.ts +10 -0
  125. package/dist/types/model/chat-v2/index.d.ts +12 -0
  126. package/dist/types/model/chat-v2/llmChatV2Body.d.ts +24 -0
  127. package/dist/types/model/chat-v2/llmChatV2CacheBoundary.d.ts +10 -0
  128. package/dist/types/model/chat-v2/llmChatV2CachePolicy.d.ts +13 -0
  129. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +13 -3
  130. package/dist/types/model/chat-v2/llmChatV2NodeMigration.d.ts +8 -0
  131. package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +18 -4
  132. package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +16 -0
  133. package/dist/types/model/chat-v2/llmInvocationDecision.d.ts +21 -0
  134. package/dist/types/model/chat-v2/llmInvocationJournal.d.ts +38 -0
  135. package/dist/types/model/chat-v2/llmInvocationPlan.d.ts +41 -0
  136. package/dist/types/model/chat-v2/llmInvocationProjections.d.ts +3 -0
  137. package/dist/types/model/chat-v2/llmInvocationResultProjector.d.ts +26 -0
  138. package/dist/types/model/chat-v2/llmModelCandidate.d.ts +18 -0
  139. package/dist/types/model/chat-v2/llmProfile.d.ts +7 -0
  140. package/dist/types/model/chat-v2/llmProfileBody.d.ts +20 -0
  141. package/dist/types/model/chat-v2/llmProfileFallback.d.ts +47 -0
  142. package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +189 -0
  143. package/dist/types/model/chat-v2/llmProfileTypes.d.ts +1 -1
  144. package/dist/types/model/chat-v2/llmResponseMaterializer.d.ts +20 -0
  145. package/dist/types/model/chat-v2/modelRegistry.d.ts +17 -187
  146. package/dist/types/model/chat-v2/parallelToolCalls.d.ts +3 -1
  147. package/dist/types/model/chat-v2/providerOptions.d.ts +11 -0
  148. package/dist/types/model/chat-v2/rivetToolRegistry.d.ts +11 -0
  149. package/dist/types/model/chat-v2/toolCallCodec.d.ts +7 -0
  150. package/dist/types/model/chat-v2/toolContinuation.d.ts +3 -3
  151. package/dist/types/model/chat-v2/toolHandlerResolver.d.ts +25 -0
  152. package/dist/types/model/chat-v2/toolRoundExecutor.d.ts +18 -0
  153. package/dist/types/model/nodes/AssembleMessageNode.d.ts +2 -1
  154. package/dist/types/model/nodes/ChatNode.d.ts +2 -1
  155. package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +2 -1
  156. package/dist/types/model/nodes/LLMChatV2Node.d.ts +2 -1
  157. package/dist/types/model/nodes/LLMProfileNode.d.ts +2 -1
  158. package/dist/types/model/nodes/PromptNode.d.ts +6 -3
  159. package/dist/types/model/nodes/ToolNode.d.ts +2 -1
  160. package/dist/types/model/nodes/toolCallDelegation.d.ts +10 -3
  161. package/dist/types/plugins/anthropic/anthropic.d.ts +1 -0
  162. package/dist/types/plugins/google/google.d.ts +14 -9
  163. package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +2 -1
  164. package/dist/types/recording/RecordedEvents.d.ts +6 -0
  165. package/dist/types/utils/emitDetached.d.ts +3 -2
  166. package/dist/types/utils/openai.d.ts +49 -0
  167. package/dist/types/webAppRuntime.d.ts +4 -2
  168. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
1
  import { getUiGraphChatDraftStateKey, getUiGraphChatMessages, getUiGraphChatMessagesStateKey, getUiGraphChatPins, getUiGraphChatPinsStateKey, } from './UiGraph.js';
2
2
  import { getUiGraphJsonOutputFilename } from './UiGraphRuntimeModel.js';
3
+ import { isAgentResponseTrace } from './AgentResponseTrace.js';
3
4
  const OUTPUT_MAX_HEIGHT_PX = 800;
4
5
  const OUTPUT_MAX_VIEWPORT_HEIGHT_RATIO = 0.8;
5
6
  const OUTPUT_RESIZE_MIN_HEIGHT_PROPERTY = '--rivet-web-app-output-resize-min-height';
@@ -8,6 +9,10 @@ const CHAT_SEARCH_MATCH_CLASS = 'rivet-web-app-chat-search-match';
8
9
  const CHAT_SEARCH_ACTIVE_MATCH_CLASS = 'rivet-web-app-chat-search-match-active';
9
10
  const UI_GRAPH_CHAT_STORAGE_PREFIX = 'rivet-web-app-chat-state:v1';
10
11
  const UI_GRAPH_APP_STORAGE_PREFIX = 'rivet-web-app-storage:v1';
12
+ const UI_GRAPH_RESPONSE_TRACE_STORAGE_PREFIX = 'rivet-web-app-response-traces:v1';
13
+ const UI_GRAPH_RESPONSE_TRACE_LIMIT = 100;
14
+ const responseTraceMemoryFallback = new Map();
15
+ const unsyncedResponseTraceKeysByStorage = new WeakMap();
11
16
  const escapeRegularExpression = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
12
17
  const getPixelValue = (value, fallback) => {
13
18
  const parsed = Number.parseFloat(value);
@@ -70,23 +75,43 @@ export function getUiGraphChatMessagePresentations(messages, options = {}) {
70
75
  dateTime: timestamp.toISOString(),
71
76
  dateLabel: dateFormatter.format(timestamp),
72
77
  timeLabel: timeFormatter.format(timestamp),
78
+ timestamp,
73
79
  };
74
80
  });
75
81
  const hasMultipleDates = new Set(entries.flatMap((entry) => (entry ? [entry.dateKey] : []))).size > 1;
76
82
  let previousDateKey;
77
- return entries.map((entry) => {
83
+ let previousUserTimestamp;
84
+ return entries.map((entry, index) => {
85
+ const message = messages[index];
86
+ if (message.role === 'user') {
87
+ previousUserTimestamp = entry?.timestamp;
88
+ }
78
89
  if (!entry)
79
90
  return {};
80
91
  const dateSeparator = hasMultipleDates && previousDateKey != null && previousDateKey !== entry.dateKey
81
92
  ? { dateTime: entry.dateTime, label: entry.dateLabel }
82
93
  : undefined;
83
94
  previousDateKey = entry.dateKey;
95
+ const elapsedSincePreviousUserMessage = message.role === 'assistant' && previousUserTimestamp
96
+ ? formatUiGraphChatElapsedSeconds(entry.timestamp.getTime() - previousUserTimestamp.getTime())
97
+ : undefined;
84
98
  return {
85
99
  ...(dateSeparator ? { dateSeparator } : {}),
86
- timestamp: { dateTime: entry.dateTime, label: entry.timeLabel },
100
+ timestamp: {
101
+ dateTime: entry.dateTime,
102
+ ...(elapsedSincePreviousUserMessage ? { elapsedSincePreviousUserMessage } : {}),
103
+ label: entry.timeLabel,
104
+ },
87
105
  };
88
106
  });
89
107
  }
108
+ /** Formats a browser-observed assistant-response delay without altering stored timestamps. */
109
+ const formatUiGraphChatElapsedSeconds = (elapsedMilliseconds) => {
110
+ if (!Number.isFinite(elapsedMilliseconds) || elapsedMilliseconds < 0)
111
+ return undefined;
112
+ const seconds = Math.round((elapsedMilliseconds / 1_000) * 10) / 10;
113
+ return `${Number.isInteger(seconds) ? seconds : seconds.toFixed(1)} seconds after previous user message`;
114
+ };
90
115
  const parseUiGraphChatTimestamp = (value) => {
91
116
  if (typeof value !== 'string')
92
117
  return undefined;
@@ -119,6 +144,108 @@ export function getUiGraphWebAppStorageKey(uiGraph, location = getDefaultUiGraph
119
144
  encodeURIComponent(uiGraph.id),
120
145
  ].join(':');
121
146
  }
147
+ function getUiGraphResponseTraceStorageKey(uiGraph, componentId, location = getDefaultUiGraphStorageLocation()) {
148
+ if (!location?.origin)
149
+ return undefined;
150
+ const pathname = location.pathname.replace(/\/+$/, '') || '/';
151
+ return [
152
+ UI_GRAPH_RESPONSE_TRACE_STORAGE_PREFIX,
153
+ encodeURIComponent(location.origin),
154
+ encodeURIComponent(pathname),
155
+ encodeURIComponent(uiGraph.id),
156
+ encodeURIComponent(componentId),
157
+ ].join(':');
158
+ }
159
+ const isUiGraphResponseInspectionEnabled = (uiGraph, componentId) => uiGraph.components.some((component) => component.type === 'chat' && component.id === componentId && component.allowResponseInspection === true);
160
+ const removeUiGraphChatResponseTraceIds = (messages) => messages.map((message) => {
161
+ if (message.responseTraceId == null)
162
+ return message;
163
+ const sanitized = { ...message };
164
+ delete sanitized.responseTraceId;
165
+ return sanitized;
166
+ });
167
+ const purgeDisabledUiGraphResponseTraces = (uiGraph, storage, location) => {
168
+ for (const component of uiGraph.components) {
169
+ if (component.type !== 'chat' || component.allowResponseInspection === true)
170
+ continue;
171
+ const key = getUiGraphResponseTraceStorageKey(uiGraph, component.id, location) ?? `memory:${uiGraph.id}:${component.id}`;
172
+ persistUiGraphResponseTraces(key, [], storage);
173
+ }
174
+ };
175
+ /** Persists a validated trace outside Chat history so it never enters model context. */
176
+ export function saveUiGraphResponseTrace(uiGraph, componentId, trace, storage = getDefaultUiGraphBrowserStorage(), location) {
177
+ if (!isAgentResponseTrace(trace))
178
+ return;
179
+ if (!isUiGraphResponseInspectionEnabled(uiGraph, componentId)) {
180
+ const key = getUiGraphResponseTraceStorageKey(uiGraph, componentId, location) ?? `memory:${uiGraph.id}:${componentId}`;
181
+ persistUiGraphResponseTraces(key, [], storage);
182
+ return;
183
+ }
184
+ const key = getUiGraphResponseTraceStorageKey(uiGraph, componentId, location) ?? `memory:${uiGraph.id}:${componentId}`;
185
+ const traces = loadUiGraphResponseTraces(uiGraph, componentId, storage, location).filter((candidate) => candidate.traceId !== trace.traceId);
186
+ traces.push(trace);
187
+ const bounded = traces.slice(-UI_GRAPH_RESPONSE_TRACE_LIMIT);
188
+ persistUiGraphResponseTraces(key, bounded, storage);
189
+ }
190
+ /** Loads one validated response trace from the app/UI-graph-scoped store. */
191
+ export function loadUiGraphResponseTrace(uiGraph, componentId, traceId, storage = getDefaultUiGraphBrowserStorage(), location) {
192
+ if (!isUiGraphResponseInspectionEnabled(uiGraph, componentId))
193
+ return undefined;
194
+ return loadUiGraphResponseTraces(uiGraph, componentId, storage, location).find((trace) => trace.traceId === traceId);
195
+ }
196
+ /** Removes retained traces no longer referenced by Chat messages. */
197
+ export function pruneUiGraphResponseTraces(uiGraph, state, storage = getDefaultUiGraphBrowserStorage(), location) {
198
+ for (const component of uiGraph.components) {
199
+ if (component.type !== 'chat')
200
+ continue;
201
+ const referenced = component.allowResponseInspection === true
202
+ ? new Set(getUiGraphChatMessages(component.id, state).flatMap((message) => typeof message.responseTraceId === 'string' ? [message.responseTraceId] : []))
203
+ : new Set();
204
+ const key = getUiGraphResponseTraceStorageKey(uiGraph, component.id, location) ?? `memory:${uiGraph.id}:${component.id}`;
205
+ const retained = loadUiGraphResponseTraces(uiGraph, component.id, storage, location).filter((trace) => referenced.has(trace.traceId));
206
+ persistUiGraphResponseTraces(key, retained, storage);
207
+ }
208
+ }
209
+ function persistUiGraphResponseTraces(key, traces, storage) {
210
+ responseTraceMemoryFallback.set(key, traces);
211
+ if (!storage || key.startsWith('memory:'))
212
+ return;
213
+ try {
214
+ if (traces.length === 0)
215
+ storage.removeItem(key);
216
+ else
217
+ storage.setItem(key, JSON.stringify(traces));
218
+ unsyncedResponseTraceKeysByStorage.get(storage)?.delete(key);
219
+ }
220
+ catch {
221
+ const unsyncedKeys = unsyncedResponseTraceKeysByStorage.get(storage) ?? new Set();
222
+ unsyncedKeys.add(key);
223
+ unsyncedResponseTraceKeysByStorage.set(storage, unsyncedKeys);
224
+ }
225
+ }
226
+ function loadUiGraphResponseTraces(uiGraph, componentId, storage, location) {
227
+ const key = getUiGraphResponseTraceStorageKey(uiGraph, componentId, location) ?? `memory:${uiGraph.id}:${componentId}`;
228
+ if (storage && unsyncedResponseTraceKeysByStorage.get(storage)?.has(key)) {
229
+ return responseTraceMemoryFallback.get(key) ?? [];
230
+ }
231
+ if (storage && !key.startsWith('memory:')) {
232
+ try {
233
+ const raw = storage.getItem(key);
234
+ if (raw) {
235
+ const parsed = JSON.parse(raw);
236
+ if (Array.isArray(parsed)) {
237
+ const traces = parsed.filter(isAgentResponseTrace).slice(-UI_GRAPH_RESPONSE_TRACE_LIMIT);
238
+ responseTraceMemoryFallback.set(key, traces);
239
+ return traces;
240
+ }
241
+ }
242
+ }
243
+ catch {
244
+ // Fall through to the in-memory copy.
245
+ }
246
+ }
247
+ return responseTraceMemoryFallback.get(key) ?? [];
248
+ }
122
249
  /** Loads the browser snapshot used by Stored Value nodes for this one web app. */
123
250
  export function loadUiGraphWebAppStorage(uiGraph, storage = getDefaultUiGraphBrowserStorage(), location) {
124
251
  const key = getUiGraphWebAppStorageKey(uiGraph, location);
@@ -180,12 +307,13 @@ export function getUiGraphChatPersistentState(uiGraph, state) {
180
307
  const pinsStateKey = getUiGraphChatPinsStateKey(component.id);
181
308
  const draft = state[draftStateKey];
182
309
  const messages = getUiGraphChatMessages(component.id, state);
310
+ const persistedMessages = component.allowResponseInspection === true ? messages : removeUiGraphChatResponseTraceIds(messages);
183
311
  const pins = getUiGraphChatPins(component.id, state).map((pin) => pin.messageIndex);
184
312
  if (typeof draft === 'string' && draft) {
185
313
  persistentState[draftStateKey] = draft;
186
314
  }
187
- if (messages.length > 0) {
188
- persistentState[messagesStateKey] = messages;
315
+ if (persistedMessages.length > 0) {
316
+ persistentState[messagesStateKey] = persistedMessages;
189
317
  }
190
318
  if (pins.length > 0) {
191
319
  persistentState[pinsStateKey] = pins;
@@ -229,6 +357,7 @@ export function loadUiGraphChatPersistentState(uiGraph, storage = getDefaultUiGr
229
357
  }
230
358
  /** Persists only Chat draft, conversation, and pins for the current browser app URL. */
231
359
  export function saveUiGraphChatPersistentState(uiGraph, state, storage = getDefaultUiGraphBrowserStorage(), location) {
360
+ purgeDisabledUiGraphResponseTraces(uiGraph, storage, location);
232
361
  const key = getUiGraphChatStorageKey(uiGraph, location);
233
362
  if (!key || !storage) {
234
363
  return;
@@ -577,6 +577,37 @@ export const RIVET_WEB_APP_RENDERER_CSS = `
577
577
  outline: none;
578
578
  }
579
579
 
580
+ .rivet-web-app-chat-message-context-menu {
581
+ position: fixed;
582
+ z-index: 12;
583
+ min-width: 196px;
584
+ border: 1px solid var(--rivet-web-app-control-border);
585
+ border-radius: 6px;
586
+ background: var(--rivet-web-app-control-background);
587
+ box-shadow: 0 8px 18px rgb(0 0 0 / 24%);
588
+ padding: 4px;
589
+ }
590
+
591
+ .rivet-web-app-chat-message-context-menu button {
592
+ display: block;
593
+ width: 100%;
594
+ border: 0;
595
+ border-radius: 4px;
596
+ background: transparent;
597
+ color: var(--rivet-web-app-foreground);
598
+ cursor: pointer;
599
+ font: inherit;
600
+ padding: 7px 8px;
601
+ text-align: left;
602
+ white-space: nowrap;
603
+ }
604
+
605
+ .rivet-web-app-chat-message-context-menu button:hover,
606
+ .rivet-web-app-chat-message-context-menu button:focus-visible {
607
+ background: var(--rivet-web-app-control-hover-background);
608
+ outline: none;
609
+ }
610
+
580
611
  .rivet-web-app-chat-history {
581
612
  display: grid;
582
613
  grid-template-rows: auto minmax(0, 1fr);
@@ -849,6 +880,11 @@ export const RIVET_WEB_APP_RENDERER_CSS = `
849
880
  border-bottom-left-radius: 0;
850
881
  }
851
882
 
883
+ .rivet-web-app-chat-message-context-selected {
884
+ outline: 1px solid color-mix(in srgb, var(--rivet-web-app-button-background) 70%, var(--rivet-web-app-foreground));
885
+ outline-offset: 1px;
886
+ }
887
+
852
888
  .rivet-web-app-chat-message-row {
853
889
  display: flex;
854
890
  align-items: flex-start;
@@ -1462,6 +1498,191 @@ button.rivet-web-app-output-header:focus-visible {
1462
1498
  justify-self: start;
1463
1499
  }
1464
1500
 
1501
+ .rivet-web-app-chat-reading-view-backdrop {
1502
+ padding: clamp(10px, 3vw, 28px);
1503
+ }
1504
+
1505
+ .rivet-web-app-chat-reading-view {
1506
+ display: grid;
1507
+ grid-template-rows: auto minmax(0, 1fr);
1508
+ width: min(1120px, 100%);
1509
+ height: min(90vh, 920px);
1510
+ min-height: 0;
1511
+ overflow: hidden;
1512
+ border: 1px solid var(--rivet-web-app-control-border);
1513
+ border-radius: 12px;
1514
+ background: var(--rivet-web-app-card-background);
1515
+ box-shadow: 0 22px 70px rgb(0 0 0 / 42%);
1516
+ color: var(--rivet-web-app-foreground);
1517
+ }
1518
+
1519
+ .rivet-web-app-chat-reading-view-header {
1520
+ display: flex;
1521
+ align-items: center;
1522
+ justify-content: space-between;
1523
+ gap: 16px;
1524
+ min-height: 54px;
1525
+ border-bottom: 1px solid var(--rivet-web-app-card-border);
1526
+ padding: 8px 12px 8px 22px;
1527
+ }
1528
+
1529
+ .rivet-web-app-chat-reading-view-header strong {
1530
+ font-size: 16px;
1531
+ }
1532
+
1533
+ .rivet-web-app-chat-reading-view-close {
1534
+ display: inline-grid;
1535
+ place-items: center;
1536
+ width: 36px;
1537
+ height: 36px;
1538
+ flex: 0 0 auto;
1539
+ border: 0;
1540
+ border-radius: 6px;
1541
+ background: transparent;
1542
+ color: var(--rivet-web-app-foreground-muted);
1543
+ cursor: pointer;
1544
+ }
1545
+
1546
+ .rivet-web-app-chat-reading-view-close:hover,
1547
+ .rivet-web-app-chat-reading-view-close:focus-visible {
1548
+ background: var(--rivet-web-app-control-hover-background);
1549
+ color: var(--rivet-web-app-foreground);
1550
+ outline: none;
1551
+ }
1552
+
1553
+ .rivet-web-app-chat-reading-view-close svg {
1554
+ width: 20px;
1555
+ height: 20px;
1556
+ }
1557
+
1558
+ .rivet-web-app-chat-reading-view-markdown.markdown-body {
1559
+ --rivet-web-app-chat-message-foreground: var(--rivet-web-app-foreground);
1560
+ min-width: 0;
1561
+ min-height: 0;
1562
+ overflow: auto;
1563
+ overscroll-behavior: contain;
1564
+ background: transparent;
1565
+ color: inherit;
1566
+ padding: 22px 26px 28px;
1567
+ }
1568
+
1569
+ .rivet-web-app-chat-reading-view-markdown > :first-child {
1570
+ margin-top: 0;
1571
+ }
1572
+
1573
+ .rivet-web-app-chat-reading-view-markdown > :last-child {
1574
+ margin-bottom: 0;
1575
+ }
1576
+
1577
+ .rivet-web-app-chat-reading-view-markdown table {
1578
+ max-width: none;
1579
+ }
1580
+
1581
+ .rivet-agent-response-inspector-backdrop {
1582
+ position: fixed;
1583
+ inset: 0;
1584
+ z-index: 10020;
1585
+ display: grid;
1586
+ place-items: center;
1587
+ padding: 20px;
1588
+ background: rgb(7 10 15 / 72%);
1589
+ }
1590
+
1591
+ .rivet-agent-response-inspector {
1592
+ width: min(920px, 100%);
1593
+ max-height: min(820px, calc(100vh - 40px));
1594
+ display: flex;
1595
+ flex-direction: column;
1596
+ overflow: hidden;
1597
+ border: 1px solid var(--rivet-web-app-card-border);
1598
+ border-radius: 12px;
1599
+ background: var(--rivet-web-app-card-background);
1600
+ color: var(--rivet-web-app-foreground);
1601
+ box-shadow: 0 24px 70px rgb(0 0 0 / 45%);
1602
+ }
1603
+
1604
+ .rivet-agent-response-inspector > header {
1605
+ display: flex;
1606
+ align-items: center;
1607
+ justify-content: space-between;
1608
+ gap: 16px;
1609
+ padding: 16px 18px;
1610
+ border-bottom: 1px solid var(--rivet-web-app-card-border);
1611
+ }
1612
+
1613
+ .rivet-agent-response-inspector > header div { display: grid; gap: 2px; }
1614
+ .rivet-agent-response-inspector > header span { color: var(--rivet-web-app-foreground-muted); font-size: 12px; }
1615
+ .rivet-agent-response-inspector > header button {
1616
+ width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 7px;
1617
+ background: transparent; color: inherit; cursor: pointer; outline: none;
1618
+ }
1619
+ .rivet-agent-response-inspector > header button:hover,
1620
+ .rivet-agent-response-inspector > header button:focus-visible {
1621
+ background: var(--rivet-web-app-control-hover-background);
1622
+ }
1623
+ .rivet-agent-response-inspector > header button:focus-visible {
1624
+ box-shadow: inset 0 0 0 1px var(--rivet-web-app-control-focus-border);
1625
+ }
1626
+ .rivet-agent-response-inspector > header svg { width: 20px; height: 20px; }
1627
+ .rivet-agent-response-inspector-body { display: grid; gap: 18px; min-height: 0; overflow: auto; padding: 20px; }
1628
+ .rivet-agent-response-inspector-unavailable { padding: 28px 18px; }
1629
+ .rivet-agent-response-inspector-unavailable p { margin-bottom: 0; color: var(--rivet-web-app-foreground-muted); }
1630
+ .rivet-agent-response-inspector-metric-group { display: grid; gap: 9px; min-width: 0; }
1631
+ .rivet-agent-response-inspector-group-heading { display: grid; gap: 3px; }
1632
+ .rivet-agent-response-inspector-group-heading h3 { margin: 0; font-size: 14px; }
1633
+ .rivet-agent-response-inspector-group-heading p {
1634
+ margin: 0; color: var(--rivet-web-app-foreground-muted); font-size: 12px; line-height: 1.45;
1635
+ }
1636
+ .rivet-agent-response-inspector-metrics {
1637
+ display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px;
1638
+ margin: 0; padding: 0; width: 100%;
1639
+ }
1640
+ .rivet-agent-response-inspector-metrics > div {
1641
+ min-width: 0;
1642
+ padding: 10px 12px;
1643
+ border-radius: 8px;
1644
+ background: color-mix(
1645
+ in srgb,
1646
+ var(--rivet-web-app-card-background) 92%,
1647
+ var(--rivet-web-app-foreground) 8%
1648
+ );
1649
+ }
1650
+ .rivet-agent-response-inspector-metrics dt { color: var(--rivet-web-app-foreground-muted); font-size: 12px; }
1651
+ .rivet-agent-response-inspector-metrics dd { margin: 3px 0 0; font-weight: 600; }
1652
+ .rivet-agent-response-inspector-timing {
1653
+ display: grid; gap: 4px; margin: 0; padding: 0; color: var(--rivet-web-app-foreground-muted); font-size: 12px;
1654
+ }
1655
+ .rivet-agent-response-inspector-timing > div {
1656
+ display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px;
1657
+ }
1658
+ .rivet-agent-response-inspector-timing dt { font-weight: 600; }
1659
+ .rivet-agent-response-inspector-timing dd { margin: 0; }
1660
+ .rivet-agent-response-inspector-section { border-top: 1px solid var(--rivet-web-app-card-border); padding: 12px 0; }
1661
+ .rivet-agent-response-inspector-section summary { cursor: pointer; font-weight: 600; }
1662
+ .rivet-agent-response-inspector-section article { display: grid; gap: 3px; padding: 10px 0; }
1663
+ .rivet-agent-response-inspector-section article + article { border-top: 1px solid var(--rivet-web-app-card-border); }
1664
+ .rivet-agent-response-inspector-section article span,
1665
+ .rivet-agent-response-inspector-section p { color: var(--rivet-web-app-foreground-muted); font-size: 13px; }
1666
+
1667
+ @media (max-width: 520px) {
1668
+ .rivet-agent-response-inspector-backdrop { padding: 10px; }
1669
+ .rivet-agent-response-inspector { max-height: calc(100vh - 20px); }
1670
+ .rivet-agent-response-inspector-body { padding: 16px; }
1671
+
1672
+ .rivet-web-app-chat-reading-view {
1673
+ height: calc(100vh - 20px);
1674
+ border-radius: 10px;
1675
+ }
1676
+
1677
+ .rivet-web-app-chat-reading-view-header {
1678
+ padding-left: 16px;
1679
+ }
1680
+
1681
+ .rivet-web-app-chat-reading-view-markdown.markdown-body {
1682
+ padding: 18px 16px 22px;
1683
+ }
1684
+ }
1685
+
1465
1686
  .rivet-web-app-clipboard-fallback {
1466
1687
  position: fixed;
1467
1688
  top: 0;
@@ -201,7 +201,7 @@ export function createUiGraphInteractionController(initialUiGraph, options = {})
201
201
  }
202
202
  }
203
203
  };
204
- const stampChatResponseAtBrowserReceipt = (component, statePatch) => {
204
+ const stampChatResponseAtBrowserReceipt = (component, statePatch, responseTrace) => {
205
205
  if (component.type !== 'chat' || !statePatch) {
206
206
  return statePatch;
207
207
  }
@@ -221,7 +221,13 @@ export function createUiGraphInteractionController(initialUiGraph, options = {})
221
221
  ...statePatch,
222
222
  [messagesStateKey]: [
223
223
  ...messages.slice(0, -1),
224
- { ...lastMessage, timestamp: new Date().toISOString() },
224
+ {
225
+ ...lastMessage,
226
+ timestamp: new Date().toISOString(),
227
+ ...(component.allowResponseInspection && responseTrace != null
228
+ ? { responseTraceId: responseTrace.traceId }
229
+ : {}),
230
+ },
225
231
  ],
226
232
  };
227
233
  };
@@ -285,7 +291,7 @@ export function createUiGraphInteractionController(initialUiGraph, options = {})
285
291
  if (!actionController.isCurrent(execution)) {
286
292
  return;
287
293
  }
288
- const statePatch = actionController.resolveStatePatch(execution, stampChatResponseAtBrowserReceipt(component, result.statePatch));
294
+ const statePatch = actionController.resolveStatePatch(execution, stampChatResponseAtBrowserReceipt(component, result.statePatch, result.responseTrace));
289
295
  if (statePatch) {
290
296
  const nextState = applyUiGraphStatePatch(state, statePatch);
291
297
  expandOutputsForUpdatedState(Object.keys(statePatch), nextState);
@@ -70,7 +70,13 @@ export const UI_GRAPH_COMPONENT_SCHEMA = z.discriminatedUnion('type', [
70
70
  }),
71
71
  }, objectOptions),
72
72
  z.object({ id: componentId, type: z.literal('button'), label: requiredString, action: runGraphActionSchema }, objectOptions),
73
- z.object({ id: componentId, type: z.literal('chat'), placeholder: optionalString, action: chatRunGraphActionSchema }, objectOptions),
73
+ z.object({
74
+ id: componentId,
75
+ type: z.literal('chat'),
76
+ placeholder: optionalString,
77
+ allowResponseInspection: z.boolean().optional(),
78
+ action: chatRunGraphActionSchema,
79
+ }, objectOptions),
74
80
  z.object({
75
81
  id: componentId,
76
82
  type: z.literal('output'),
@@ -43,6 +43,14 @@ export async function rivetMessagesToAiSdk(messages) {
43
43
  });
44
44
  break;
45
45
  }
46
+ case 'developer': {
47
+ // ModelMessage has no provider-neutral developer role.
48
+ result.push({
49
+ role: 'system',
50
+ content: stringifyParts(msg.message),
51
+ });
52
+ break;
53
+ }
46
54
  case 'user': {
47
55
  const parts = Array.isArray(msg.message) ? msg.message : [msg.message];
48
56
  if (parts.length === 1 && typeof parts[0] === 'string') {
@@ -1,7 +1,8 @@
1
1
  import { jsonSchema } from 'ai';
2
+ import { createRivetToolRegistry } from '../chat-v2/rivetToolRegistry.js';
2
3
  export function rivetToolsToAiSdk(functions) {
3
- return Object.fromEntries(functions.map((fn) => [
4
- fn.name,
4
+ return Object.fromEntries([...createRivetToolRegistry(functions).byName.entries()].map(([name, fn]) => [
5
+ name,
5
6
  {
6
7
  description: fn.description,
7
8
  inputSchema: jsonSchema(fn.parameters),
@@ -1,5 +1,5 @@
1
1
  import { nanoid } from 'nanoid/non-secure';
2
- import { calculateChatV2Cost, getChatV2ModelInfo } from './modelRegistry.js';
2
+ import { calculateChatV2UsageCost, getChatV2ModelInfo } from './modelRegistry.js';
3
3
  function toUsageNumber(value) {
4
4
  return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined;
5
5
  }
@@ -43,7 +43,7 @@ function normalizeObservedUsage(rawUsage) {
43
43
  (promptTokens != null && completionTokens != null ? promptTokens + completionTokens : undefined);
44
44
  const cacheReadTokens = rawUsage.inputTokenDetails?.cacheReadTokens;
45
45
  const cacheWriteTokens = rawUsage.inputTokenDetails?.cacheWriteTokens;
46
- const cachedTokens = cacheReadTokens != null && cacheWriteTokens != null ? cacheReadTokens + cacheWriteTokens : undefined;
46
+ const cachedTokens = cacheReadTokens == null && cacheWriteTokens == null ? undefined : (cacheReadTokens ?? 0) + (cacheWriteTokens ?? 0);
47
47
  const reasoningTokens = rawUsage.outputTokenDetails?.reasoningTokens;
48
48
  const normalized = {
49
49
  ...(promptTokens == null ? {} : { promptTokens }),
@@ -109,8 +109,9 @@ export function notifyChatV2CallFinished(options, params) {
109
109
  const rawUsage = safelyRead(() => copyRawUsage(resultUsage ?? errorUsage));
110
110
  const normalizedUsage = safelyRead(() => normalizeObservedUsage(rawUsage));
111
111
  const modelInfo = safelyRead(() => getChatV2ModelInfo(options.provider, options.modelId));
112
- const calculatedCost = modelInfo != null && normalizedUsage?.promptTokens != null && normalizedUsage.completionTokens != null
113
- ? safelyRead(() => calculateChatV2Cost(options.provider, options.modelId, normalizedUsage.promptTokens, normalizedUsage.completionTokens))
112
+ const hasKnownPricing = modelInfo?.cost != null;
113
+ const calculatedCost = hasKnownPricing
114
+ ? safelyRead(() => calculateChatV2UsageCost(options.provider, options.modelId, rawUsage))
114
115
  : undefined;
115
116
  const costUsd = toUsageNumber(calculatedCost);
116
117
  const finishReason = safelyRead(() => params.result?.finishReason) ??
@@ -118,18 +119,23 @@ export function notifyChatV2CallFinished(options, params) {
118
119
  const event = {
119
120
  callId: params.callId,
120
121
  attemptIndex: params.attemptIndex,
122
+ ...(options.profileIndex == null ? {} : { profileIndex: options.profileIndex }),
123
+ ...(options.roundIndex == null ? {} : { roundIndex: options.roundIndex }),
121
124
  nodeId,
122
125
  processId,
123
126
  provider: options.provider,
124
127
  model: options.modelId,
128
+ ...(options.customProviderApi == null ? {} : { customProviderApi: options.customProviderApi }),
125
129
  outcome: params.outcome,
126
130
  ...(finishReason == null ? {} : { finishReason }),
127
131
  ...(rawUsage == null ? {} : { rawUsage }),
128
132
  ...(normalizedUsage == null ? {} : { normalizedUsage }),
129
133
  pricing: {
130
- status: modelInfo == null ? 'unknown' : 'known',
134
+ status: hasKnownPricing ? 'known' : 'unknown',
131
135
  ...(costUsd == null ? {} : { costUsd }),
132
136
  },
137
+ ...(params.startedAt == null ? {} : { startedAt: params.startedAt }),
138
+ ...(params.durationMs == null ? {} : { durationMs: params.durationMs }),
133
139
  };
134
140
  try {
135
141
  containUnexpectedObserverPromise(observer(event));
@@ -1,6 +1,10 @@
1
1
  import stableStringify from 'safe-stable-stringify';
2
+ import CryptoJS from 'crypto-js';
3
+ import { normalizeOpenAICompatibleEndpoint } from './providerOptions.js';
4
+ import { parseCustomProviderApi } from './customProviderApi.js';
2
5
  export function buildLLMChatV2EditorCacheKey(parts) {
3
- return stableStringify(parts) ?? '';
6
+ const { cacheVersion = 2, ...keyParts } = parts;
7
+ return stableStringify({ cacheVersion, ...keyParts }) ?? '';
4
8
  }
5
9
  function cloneEditorCacheValue(value, seen = new WeakMap()) {
6
10
  if (value == null || typeof value !== 'object') {
@@ -41,29 +45,56 @@ function fingerprintSecret(secret) {
41
45
  if (!secret) {
42
46
  return undefined;
43
47
  }
44
- let hash = 2166136261;
45
- for (let i = 0; i < secret.length; i++) {
46
- hash ^= secret.charCodeAt(i);
47
- hash = Math.imul(hash, 16777619);
48
- }
49
- return `${secret.length}:${(hash >>> 0).toString(36)}`;
48
+ // Cache keys stay in-memory, but provider credentials and header values must
49
+ // not be recoverable from them. SHA-256 also avoids FNV's easy collisions.
50
+ return `sha256:${CryptoJS.SHA256(secret).toString(CryptoJS.enc.Hex)}`;
50
51
  }
51
52
  function fingerprintProviderConfigForCache(config) {
52
- if (config.headers == null) {
53
+ if (config.headers == null && config.endpointQuery == null) {
53
54
  return config;
54
55
  }
55
56
  return {
56
57
  ...config,
57
- headers: Object.fromEntries(Object.entries(config.headers).map(([key, value]) => [key, fingerprintSecret(value) ?? ''])),
58
+ ...(config.headers == null
59
+ ? {}
60
+ : {
61
+ headers: Object.fromEntries(Object.entries(config.headers).map(([key, value]) => [key, fingerprintSecret(value) ?? ''])),
62
+ }),
63
+ ...(config.endpointQuery == null
64
+ ? {}
65
+ : {
66
+ endpointQuery: config.endpointQuery.map(([key, value]) => [key, fingerprintSecret(value) ?? '']),
67
+ }),
58
68
  };
59
69
  }
70
+ function fingerprintCustomProviderBaseURL(value) {
71
+ if (!value.trim()) {
72
+ return '';
73
+ }
74
+ try {
75
+ const endpoint = normalizeOpenAICompatibleEndpoint(value);
76
+ return (stableStringify({
77
+ baseURL: endpoint.baseURL,
78
+ endpointQuery: endpoint.endpointQuery.map(([key, queryValue]) => [key, fingerprintSecret(queryValue) ?? '']),
79
+ }) ?? '');
80
+ }
81
+ catch {
82
+ // Profile candidates are resolved lazily so a malformed primary URL can
83
+ // fall through to the next profile. Cache fingerprinting must neither
84
+ // pre-empt that recovery nor retain the malformed URL verbatim.
85
+ return `invalid-url:${fingerprintSecret(value)}`;
86
+ }
87
+ }
60
88
  function fingerprintNodeDataForCache(data) {
61
89
  const isCustomProvider = data.provider === 'custom';
62
90
  return {
63
91
  ...data,
64
92
  baseURL: '',
65
93
  useBaseURLInput: false,
66
- customProviderBaseURL: isCustomProvider ? data.customProviderBaseURL : '',
94
+ customProviderApi: isCustomProvider ? parseCustomProviderApi(data.customProviderApi) : 'completions',
95
+ customProviderBaseURL: isCustomProvider && !data.useCustomProviderBaseURLInput
96
+ ? fingerprintCustomProviderBaseURL(data.customProviderBaseURL)
97
+ : '',
67
98
  useCustomProviderBaseURLInput: isCustomProvider ? data.useCustomProviderBaseURLInput : false,
68
99
  extraProviderOptions: data.useExtraProviderOptionsInput ? '' : fingerprintSecret(data.extraProviderOptions) ?? '',
69
100
  headers: (data.headers ?? []).map(({ key, value }) => ({
@@ -78,6 +109,22 @@ function fingerprintProviderOptionsForCache(providerOptions) {
78
109
  }
79
110
  return fingerprintSecret(stableStringify(providerOptions) ?? '');
80
111
  }
112
+ function fingerprintProfileChainForCache(data, profiles) {
113
+ if (profiles == null) {
114
+ return undefined;
115
+ }
116
+ return profiles.map((profile) => ({
117
+ configuration: fingerprintNodeDataForCache({
118
+ ...data,
119
+ ...profile.configuration,
120
+ configurationMode: 'profile',
121
+ }),
122
+ credential: {
123
+ reference: profile.credential.reference,
124
+ value: fingerprintSecret(profile.credential.value),
125
+ },
126
+ }));
127
+ }
81
128
  export function resolveLLMChatV2EditorCache(params) {
82
129
  const { editorCache } = params;
83
130
  if (editorCache == null) {
@@ -97,6 +144,7 @@ export function resolveLLMChatV2EditorCache(params) {
97
144
  responseFormatParameters: params.responseFormatParameters,
98
145
  providerOptions: fingerprintProviderOptionsForCache(params.providerOptions),
99
146
  toolChoice: params.toolChoice,
147
+ profileChain: params.profileChain == null ? undefined : fingerprintProfileChainForCache(params.data, params.profileChain),
100
148
  });
101
149
  return {
102
150
  cacheKey,