@valerypopoff/rivet2-core 2.0.11 → 2.1.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 (66) hide show
  1. package/dist/cjs/bundle.cjs +1555 -172
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/esm/exports.js +4 -0
  4. package/dist/esm/model/GraphBoundaryCache.js +36 -4
  5. package/dist/esm/model/GraphBoundaryEffects.js +32 -0
  6. package/dist/esm/model/GraphPreprocessor.js +6 -4
  7. package/dist/esm/model/GraphProcessor.js +129 -17
  8. package/dist/esm/model/NodeGraph.js +1 -1
  9. package/dist/esm/model/NodePrefabResolver.js +57 -0
  10. package/dist/esm/model/Nodes.js +4 -1
  11. package/dist/esm/model/ProcessContextBuilder.js +3 -1
  12. package/dist/esm/model/UiGraph.js +113 -0
  13. package/dist/esm/model/UiGraphRendererStyles.js +208 -0
  14. package/dist/esm/model/chat/openAIChatRuntime.js +0 -1
  15. package/dist/esm/model/chat-v2/aiSdkBridge.js +100 -2
  16. package/dist/esm/model/chat-v2/chatV2Pipeline.js +35 -31
  17. package/dist/esm/model/chat-v2/chatV2Shared.js +1 -1
  18. package/dist/esm/model/chat-v2/providerOptions.js +5 -1
  19. package/dist/esm/model/nodes/CoalesceNode.js +1 -1
  20. package/dist/esm/model/nodes/CompareNode.js +15 -14
  21. package/dist/esm/model/nodes/GraphOutputNode.js +1 -0
  22. package/dist/esm/model/nodes/LLMChatV2Node.js +62 -17
  23. package/dist/esm/model/nodes/NodePrefabInstanceNode.js +39 -0
  24. package/dist/esm/model/nodes/PromptNode.js +2 -1
  25. package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +49 -7
  26. package/dist/esm/model/nodes/SubGraphNode.js +42 -5
  27. package/dist/esm/utils/index.js +2 -0
  28. package/dist/esm/utils/jsonValueToDataValue.js +48 -0
  29. package/dist/esm/utils/projectComparison/connections.js +57 -0
  30. package/dist/esm/utils/projectComparison/graphs.js +60 -0
  31. package/dist/esm/utils/projectComparison/nodes.js +53 -0
  32. package/dist/esm/utils/projectComparison/summaries.js +60 -0
  33. package/dist/esm/utils/projectComparison/values.js +40 -0
  34. package/dist/esm/utils/projectComparison.js +73 -0
  35. package/dist/esm/utils/serialization/serializationHelpers.js +24 -3
  36. package/dist/esm/utils/serialization/serialization_v4.js +30 -0
  37. package/dist/types/exports.d.ts +5 -0
  38. package/dist/types/model/EditorDefinition.d.ts +1 -0
  39. package/dist/types/model/ExecutorProtocol.d.ts +13 -3
  40. package/dist/types/model/GraphBoundaryCache.d.ts +9 -3
  41. package/dist/types/model/GraphBoundaryEffects.d.ts +9 -0
  42. package/dist/types/model/GraphProcessor.d.ts +15 -0
  43. package/dist/types/model/NodeBase.d.ts +5 -0
  44. package/dist/types/model/NodeBodySpec.d.ts +1 -0
  45. package/dist/types/model/NodePrefabResolver.d.ts +13 -0
  46. package/dist/types/model/Nodes.d.ts +5 -4
  47. package/dist/types/model/ProcessContext.d.ts +5 -1
  48. package/dist/types/model/ProcessContextBuilder.d.ts +4 -2
  49. package/dist/types/model/Project.d.ts +9 -0
  50. package/dist/types/model/UiGraph.d.ts +84 -0
  51. package/dist/types/model/UiGraphRendererStyles.d.ts +2 -0
  52. package/dist/types/model/chat-v2/aiSdkBridge.d.ts +1 -0
  53. package/dist/types/model/chat-v2/chatV2Types.d.ts +23 -1
  54. package/dist/types/model/nodes/CompareNode.d.ts +4 -0
  55. package/dist/types/model/nodes/LLMChatV2Node.d.ts +2 -1
  56. package/dist/types/model/nodes/NodePrefabInstanceNode.d.ts +13 -0
  57. package/dist/types/model/nodes/SubGraphNode.d.ts +2 -0
  58. package/dist/types/utils/index.d.ts +2 -0
  59. package/dist/types/utils/jsonValueToDataValue.d.ts +2 -0
  60. package/dist/types/utils/projectComparison/connections.d.ts +5 -0
  61. package/dist/types/utils/projectComparison/graphs.d.ts +3 -0
  62. package/dist/types/utils/projectComparison/nodes.d.ts +5 -0
  63. package/dist/types/utils/projectComparison/summaries.d.ts +4 -0
  64. package/dist/types/utils/projectComparison/values.d.ts +5 -0
  65. package/dist/types/utils/projectComparison.d.ts +77 -0
  66. package/package.json +1 -1
@@ -0,0 +1,208 @@
1
+ export const RIVET_WEB_APP_RENDERER_CSS = `
2
+ .rivet-web-app-root {
3
+ --rivet-web-app-background: var(--grey-dark-colorish, #1c222b);
4
+ --rivet-web-app-foreground: var(--foreground, #ffffff);
5
+ --rivet-web-app-card-background: color-mix(in srgb, var(--modal-surface-bg, #252b34) 88%, var(--foreground, #ffffff) 4%);
6
+ --rivet-web-app-card-border: var(--foldable-section-border, rgba(255, 255, 255, 0.04));
7
+ --rivet-web-app-control-background: var(--form-control-bg, #20252d);
8
+ --rivet-web-app-control-border: var(--form-control-border, rgba(255, 255, 255, 0.14));
9
+ --rivet-web-app-button-radius: var(--rivet-web-app-host-button-radius, 6px);
10
+ --rivet-web-app-button-background: var(--success, #3ba85b);
11
+ --rivet-web-app-button-foreground: var(--grey-lightest, #ffffff);
12
+ --rivet-web-app-output-title: var(--rivet-web-app-foreground, #ffffff);
13
+ --rivet-web-app-error-color: var(--error, #ff6b5f);
14
+ --rivet-web-app-font-size: var(--rivet-web-app-host-font-size, 15px);
15
+ box-sizing: border-box;
16
+ height: 100%;
17
+ background: var(--rivet-web-app-background);
18
+ color: var(--rivet-web-app-foreground);
19
+ overflow: auto;
20
+ font-family: Inter, system-ui, sans-serif;
21
+ font-size: var(--rivet-web-app-font-size);
22
+ line-height: 1.4;
23
+ }
24
+
25
+ .rivet-web-app-root *,
26
+ .rivet-web-app-root *::before,
27
+ .rivet-web-app-root *::after {
28
+ box-sizing: border-box;
29
+ }
30
+
31
+ .rivet-web-app-surface {
32
+ display: grid;
33
+ gap: 16px;
34
+ margin: 0 auto;
35
+ max-width: 760px;
36
+ padding: 48px 20px;
37
+ }
38
+
39
+ .rivet-web-app-card,
40
+ .rivet-web-app-field {
41
+ border: 1px solid var(--rivet-web-app-card-border);
42
+ border-radius: 10px;
43
+ background: var(--rivet-web-app-card-background);
44
+ padding: 16px;
45
+ }
46
+
47
+ .rivet-web-app-component-frame {
48
+ border-radius: 12px;
49
+ margin: -5px;
50
+ padding: 4px;
51
+ }
52
+
53
+ .rivet-web-app-component-frame.active {
54
+ background: color-mix(in srgb, var(--modal-surface-bg, #252b34) 75%, var(--primary, #ff9e2c) 16%);
55
+ }
56
+
57
+ .rivet-web-app-field {
58
+ display: grid;
59
+ gap: 8px;
60
+ color: var(--rivet-web-app-foreground);
61
+ font-size: inherit;
62
+ font-weight: 600;
63
+ }
64
+
65
+ .rivet-web-app-field input,
66
+ .rivet-web-app-field textarea {
67
+ appearance: none;
68
+ width: 100%;
69
+ box-sizing: border-box;
70
+ border: 1px solid var(--rivet-web-app-control-border);
71
+ border-radius: 8px;
72
+ background: var(--rivet-web-app-control-background);
73
+ color: var(--rivet-web-app-foreground);
74
+ font: inherit;
75
+ font-weight: 400;
76
+ padding: 10px 12px;
77
+ }
78
+
79
+ .rivet-web-app-field textarea {
80
+ min-height: 110px;
81
+ resize: vertical;
82
+ }
83
+
84
+ .rivet-web-app-button {
85
+ width: fit-content;
86
+ border: 0;
87
+ border-radius: var(--rivet-web-app-button-radius);
88
+ background: var(--rivet-web-app-button-background);
89
+ color: var(--rivet-web-app-button-foreground);
90
+ cursor: pointer;
91
+ font: inherit;
92
+ font-weight: 700;
93
+ padding: 10px 16px;
94
+ }
95
+
96
+ .rivet-web-app-button:disabled {
97
+ cursor: wait;
98
+ opacity: 0.72;
99
+ }
100
+
101
+ .rivet-web-app-output {
102
+ display: grid;
103
+ gap: 8px;
104
+ }
105
+
106
+ .rivet-web-app-output-title {
107
+ color: var(--rivet-web-app-output-title);
108
+ font-weight: 700;
109
+ }
110
+
111
+ .rivet-web-app-output pre {
112
+ margin: 0;
113
+ background: transparent;
114
+ border-radius: 0;
115
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
116
+ font-size: inherit;
117
+ padding: 0;
118
+ white-space: pre-wrap;
119
+ word-break: break-word;
120
+ }
121
+
122
+ .rivet-web-app-markdown,
123
+ .rivet-web-app-output-markdown {
124
+ word-break: break-word;
125
+ }
126
+
127
+ .rivet-web-app-markdown.markdown-body {
128
+ background: var(--rivet-web-app-card-background);
129
+ font-family: inherit;
130
+ min-width: 0;
131
+ }
132
+
133
+ .rivet-web-app-output-markdown.markdown-body {
134
+ background: transparent;
135
+ font-family: inherit;
136
+ min-width: 0;
137
+ }
138
+
139
+ .rivet-web-app-markdown h1,
140
+ .rivet-web-app-output-markdown h1 {
141
+ margin: 0 0 12px;
142
+ padding-bottom: 8px;
143
+ border-bottom: 1px solid var(--rivet-web-app-card-border);
144
+ font-size: 24px;
145
+ line-height: 1.22;
146
+ }
147
+
148
+ .rivet-web-app-markdown h2,
149
+ .rivet-web-app-output-markdown h2 {
150
+ margin: 0 0 10px;
151
+ font-size: 20px;
152
+ line-height: 1.25;
153
+ }
154
+
155
+ .rivet-web-app-markdown p,
156
+ .rivet-web-app-output-markdown p,
157
+ .rivet-web-app-markdown ul,
158
+ .rivet-web-app-output-markdown ul {
159
+ margin: 0 0 12px;
160
+ }
161
+
162
+ .rivet-web-app-markdown.markdown-body code,
163
+ .rivet-web-app-output-markdown.markdown-body code {
164
+ border-radius: 4px;
165
+ background: color-mix(in srgb, var(--rivet-web-app-control-background) 70%, var(--rivet-web-app-foreground) 6%);
166
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
167
+ padding: 1px 4px;
168
+ }
169
+
170
+ .rivet-web-app-markdown.markdown-body pre,
171
+ .rivet-web-app-output-markdown.markdown-body pre {
172
+ background: transparent;
173
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
174
+ padding: 0;
175
+ white-space: pre-wrap;
176
+ }
177
+
178
+ .rivet-web-app-markdown > :first-child,
179
+ .rivet-web-app-output-markdown > :first-child {
180
+ margin-top: 0;
181
+ }
182
+
183
+ .rivet-web-app-markdown > :last-child,
184
+ .rivet-web-app-output-markdown > :last-child {
185
+ margin-bottom: 0;
186
+ }
187
+
188
+ .rivet-web-app-error {
189
+ color: var(--rivet-web-app-error-color);
190
+ font-weight: 700;
191
+ }
192
+ `;
193
+ export const RIVET_WEB_APP_DOCUMENT_CSS = `
194
+ html,
195
+ body {
196
+ height: 100%;
197
+ margin: 0;
198
+ }
199
+
200
+ body {
201
+ min-height: 100vh;
202
+ background: #1c222b;
203
+ }
204
+
205
+ #app {
206
+ min-height: 100vh;
207
+ }
208
+ `;
@@ -153,7 +153,6 @@ export async function applyOpenAIStreamingResponse(params) {
153
153
  };
154
154
  }
155
155
  output['cost'] = { type: 'number', value: totalCost };
156
- output['__hidden_token_count'] = { type: 'number', value: inputTokenCount + outputTokenCount };
157
156
  }
158
157
  export function handleOpenAIRetryableFailure(params) {
159
158
  const { originalError, context } = params;
@@ -1,4 +1,4 @@
1
- import { streamText } from 'ai';
1
+ import { generateText, NoObjectGeneratedError, streamText } from 'ai';
2
2
  import { consumeAiSdkStream } from '../chat/aiSdkStreaming.js';
3
3
  import { isChatV2StructuredResponseFormat } from './chatV2ResponseFormat.js';
4
4
  function keepPromiseHandled(value) {
@@ -35,6 +35,9 @@ function defaultStreamExecutor(args) {
35
35
  : undefined,
36
36
  };
37
37
  }
38
+ async function defaultGenerateExecutor(args) {
39
+ return (await generateText(args));
40
+ }
38
41
  async function resolveOptionalValue(value) {
39
42
  return value == null ? undefined : await value;
40
43
  }
@@ -49,6 +52,52 @@ async function resolveOptionalStructuredOutput(value) {
49
52
  return undefined;
50
53
  }
51
54
  }
55
+ async function resolveGenerateStructuredOutput(result, responseOutput, finishReason) {
56
+ if (responseOutput == null || (finishReason != null && finishReason !== 'stop')) {
57
+ return undefined;
58
+ }
59
+ try {
60
+ return await resolveOptionalStructuredOutput(result.output);
61
+ }
62
+ catch {
63
+ return undefined;
64
+ }
65
+ }
66
+ function recoverGenerateStructuredOutputError(error, options, toolCalls) {
67
+ if (options.responseOutput == null || !isChatV2StructuredResponseFormat(options.responseFormat)) {
68
+ return undefined;
69
+ }
70
+ if (!NoObjectGeneratedError.isInstance(error)) {
71
+ return undefined;
72
+ }
73
+ if (typeof error.text !== 'string') {
74
+ return undefined;
75
+ }
76
+ const rawText = error.text;
77
+ const responseText = collapseRepeatedStructuredJsonText(rawText);
78
+ return {
79
+ responseText,
80
+ structuredOutput: undefined,
81
+ functionCalls: toStreamedFunctionCalls(toolCalls),
82
+ usage: error.usage,
83
+ reasoning: '',
84
+ finishReason: error.finishReason == null ? undefined : String(error.finishReason),
85
+ providerMetadata: undefined,
86
+ requestStatus: undefined,
87
+ };
88
+ }
89
+ function attachGenerateStepToolCallCollector(args) {
90
+ const toolCalls = [];
91
+ const previousOnStepFinish = args.onStepFinish;
92
+ args.onStepFinish = async (event) => {
93
+ const stepToolCalls = event.toolCalls;
94
+ if (stepToolCalls != null) {
95
+ toolCalls.push(...stepToolCalls);
96
+ }
97
+ await previousOnStepFinish?.(event);
98
+ };
99
+ return toolCalls;
100
+ }
52
101
  function collapseRepeatedStructuredJsonText(responseText) {
53
102
  if (responseText.length === 0 || responseText.length % 2 !== 0) {
54
103
  return responseText;
@@ -70,10 +119,11 @@ function collapseRepeatedStructuredJsonText(responseText) {
70
119
  return responseText;
71
120
  }
72
121
  }
73
- async function executeStream(options, executor) {
122
+ function buildTextArgs(options) {
74
123
  const args = {
75
124
  model: options.model,
76
125
  messages: options.messages,
126
+ maxRetries: 0,
77
127
  };
78
128
  if (options.tools !== undefined)
79
129
  args.tools = options.tools;
@@ -101,6 +151,26 @@ async function executeStream(options, executor) {
101
151
  args.toolChoice = options.toolChoice;
102
152
  if (options.abortSignal !== undefined)
103
153
  args.abortSignal = options.abortSignal;
154
+ return args;
155
+ }
156
+ function toStreamedFunctionCalls(toolCalls) {
157
+ return (toolCalls ?? []).map((toolCall) => ({
158
+ type: 'function',
159
+ id: toolCall.toolCallId,
160
+ name: toolCall.toolName,
161
+ arguments: JSON.stringify(toolCall.input),
162
+ lastParsedArguments: toolCall.input,
163
+ }));
164
+ }
165
+ async function resolveGenerateReasoning(result) {
166
+ const reasoningText = await resolveOptionalValue(result.reasoningText);
167
+ if (reasoningText != null && reasoningText.trim().length > 0) {
168
+ return reasoningText;
169
+ }
170
+ return (await resolveOptionalValue(result.reasoning))?.map((part) => part.text).join('') ?? '';
171
+ }
172
+ async function executeStream(options, executor) {
173
+ const args = buildTextArgs(options);
104
174
  const handle = await executor(args);
105
175
  markOptionalPromiseHandled(handle.finishReason);
106
176
  markOptionalPromiseHandled(handle.output);
@@ -133,3 +203,31 @@ async function executeStream(options, executor) {
133
203
  export async function streamChatV2(options) {
134
204
  return executeStream(options, options.executeStream ?? defaultStreamExecutor);
135
205
  }
206
+ export async function generateChatV2(options) {
207
+ const args = buildTextArgs(options);
208
+ const stepToolCalls = attachGenerateStepToolCallCollector(args);
209
+ let result;
210
+ try {
211
+ result = await (options.executeGenerate ?? defaultGenerateExecutor)(args);
212
+ }
213
+ catch (error) {
214
+ const recovered = recoverGenerateStructuredOutputError(error, options, stepToolCalls);
215
+ if (recovered != null) {
216
+ return recovered;
217
+ }
218
+ throw error;
219
+ }
220
+ const isStructuredOutput = isChatV2StructuredResponseFormat(options.responseFormat);
221
+ const responseText = isStructuredOutput ? collapseRepeatedStructuredJsonText(result.text) : result.text;
222
+ const finishReason = await resolveOptionalValue(result.finishReason);
223
+ return {
224
+ responseText,
225
+ structuredOutput: await resolveGenerateStructuredOutput(result, options.responseOutput, finishReason),
226
+ functionCalls: toStreamedFunctionCalls(result.toolCalls != null && result.toolCalls.length > 0 ? result.toolCalls : stepToolCalls),
227
+ usage: (await resolveOptionalValue(result.totalUsage)) ?? (await resolveOptionalValue(result.usage)),
228
+ reasoning: await resolveGenerateReasoning(result),
229
+ finishReason,
230
+ providerMetadata: await resolveOptionalValue(result.providerMetadata),
231
+ requestStatus: await resolveOptionalValue(result.requestStatus),
232
+ };
233
+ }
@@ -1,11 +1,11 @@
1
1
  import { coercePromptToChatMessages, prependSystemPrompt } from '../chat/chatMessages.js';
2
- import { streamChatV2 } from './aiSdkBridge.js';
2
+ import { generateChatV2, streamChatV2 } from './aiSdkBridge.js';
3
3
  import { chatMessagesToModelMessages } from './messageConverter.js';
4
4
  import { chatV2ToolsToAiSdk } from './toolConverter.js';
5
5
  import { getChatV2ProviderErrorStatusCode, isChatV2ProviderApiCallError, isChatV2ProviderFetchError, normalizeChatV2ProviderError, } from './chatV2Errors.js';
6
6
  import { normalizeLLMChatV2RetryCooldownMs, normalizeLLMChatV2RetryCount, waitForLLMChatV2RetryCooldown, } from './chatV2Retry.js';
7
7
  import { createChatV2CommonOutputs, createChatV2ProviderFailureOutputs, normalizeChatV2Usage, } from './chatV2Outputs.js';
8
- class StreamChatV2RetryFailure extends Error {
8
+ class ChatV2RetryFailure extends Error {
9
9
  error;
10
10
  requestStatuses;
11
11
  requestErrors;
@@ -14,11 +14,11 @@ class StreamChatV2RetryFailure extends Error {
14
14
  this.error = error;
15
15
  this.requestStatuses = requestStatuses;
16
16
  this.requestErrors = requestErrors;
17
- this.name = 'StreamChatV2RetryFailure';
17
+ this.name = 'ChatV2RetryFailure';
18
18
  }
19
19
  }
20
- function isStreamChatV2RetryFailure(error) {
21
- return error instanceof StreamChatV2RetryFailure;
20
+ function isChatV2RetryFailure(error) {
21
+ return error instanceof ChatV2RetryFailure;
22
22
  }
23
23
  function getProviderFailureMessage(error) {
24
24
  if (error instanceof Error) {
@@ -41,7 +41,7 @@ function normalizeProviderFailureMessage(error, options) {
41
41
  function normalizeProviderFailureMessages(errors, options) {
42
42
  return errors.map((error) => normalizeProviderFailureMessage(error, options));
43
43
  }
44
- async function streamChatV2WithRetry(streamOptions, retryOptions) {
44
+ async function runChatV2WithRetry(chatOptions, retryOptions, transportMode) {
45
45
  const repeatTimes = retryOptions.retryOnNon200
46
46
  ? normalizeLLMChatV2RetryCount(retryOptions.retryOnNon200RepeatTimes)
47
47
  : 0;
@@ -50,7 +50,7 @@ async function streamChatV2WithRetry(streamOptions, retryOptions) {
50
50
  const requestErrors = [];
51
51
  for (let attempt = 0;; attempt++) {
52
52
  try {
53
- const result = await streamChatV2(streamOptions);
53
+ const result = transportMode === 'generate' ? await generateChatV2(chatOptions) : await streamChatV2(chatOptions);
54
54
  const statusCode = result.requestStatus ?? 200;
55
55
  if (retryOptions.retryOnNon200) {
56
56
  requestStatuses.push(statusCode);
@@ -73,7 +73,7 @@ async function streamChatV2WithRetry(streamOptions, retryOptions) {
73
73
  requestStatuses.push(statusCode);
74
74
  requestErrors.push(error);
75
75
  if (attempt >= repeatTimes) {
76
- throw new StreamChatV2RetryFailure(error, requestStatuses, requestErrors);
76
+ throw new ChatV2RetryFailure(error, requestStatuses, requestErrors);
77
77
  }
78
78
  await waitForLLMChatV2RetryCooldown(cooldownMs, retryOptions.context.signal);
79
79
  }
@@ -137,7 +137,9 @@ export async function runChatV2Pipeline(options) {
137
137
  : options.additionalTools == null
138
138
  ? functionTools
139
139
  : { ...functionTools, ...options.additionalTools };
140
- const streamed = await streamChatV2WithRetry({
140
+ const shouldStreamResponse = options.emitPartialOutputs !== false;
141
+ const transportMode = shouldStreamResponse ? 'stream' : 'generate';
142
+ const chatResponse = await runChatV2WithRetry({
141
143
  model: options.model,
142
144
  messages: modelMessages,
143
145
  tools,
@@ -155,7 +157,8 @@ export async function runChatV2Pipeline(options) {
155
157
  toolChoice: options.toolChoice,
156
158
  abortSignal: options.context.signal,
157
159
  executeStream: options.executeStream,
158
- onPartialOutput: options.emitPartialOutputs === false
160
+ executeGenerate: options.executeGenerate,
161
+ onPartialOutput: !shouldStreamResponse
159
162
  ? undefined
160
163
  : ({ text, functionCalls }) => {
161
164
  options.context.onPartialOutputs?.(createChatV2CommonOutputs({
@@ -178,8 +181,8 @@ export async function runChatV2Pipeline(options) {
178
181
  responseFormat: undefined,
179
182
  }));
180
183
  },
181
- }, options).catch((caughtError) => {
182
- const retryFailure = isStreamChatV2RetryFailure(caughtError) ? caughtError : undefined;
184
+ }, options, transportMode).catch((caughtError) => {
185
+ const retryFailure = isChatV2RetryFailure(caughtError) ? caughtError : undefined;
183
186
  const rawError = retryFailure?.error ?? caughtError;
184
187
  const normalizedError = normalizeChatV2ProviderError(rawError, {
185
188
  provider: options.provider,
@@ -193,23 +196,24 @@ export async function runChatV2Pipeline(options) {
193
196
  }
194
197
  throw normalizedError;
195
198
  });
196
- if ('commonOutputs' in streamed) {
197
- return streamed;
199
+ if ('commonOutputs' in chatResponse) {
200
+ return chatResponse;
198
201
  }
199
- const usage = normalizeChatV2Usage(streamed.result.usage, options);
200
- const requestStatuses = streamed.requestStatuses;
201
- const requestErrors = normalizeProviderFailureMessages(streamed.requestErrors, options);
202
- const responseError = streamed.responseError
203
- ? normalizeProviderFailureMessage(streamed.responseError, options)
202
+ const usage = normalizeChatV2Usage(chatResponse.result.usage, options);
203
+ const requestStatuses = chatResponse.requestStatuses;
204
+ const requestStatus = chatResponse.result.requestStatus ?? 200;
205
+ const requestErrors = normalizeProviderFailureMessages(chatResponse.requestErrors, options);
206
+ const responseError = chatResponse.responseError
207
+ ? normalizeProviderFailureMessage(chatResponse.responseError, options)
204
208
  : undefined;
205
209
  const commonOutputs = createChatV2CommonOutputs({
206
210
  requestMessages,
207
- response: streamed.result.responseText,
208
- structuredOutput: streamed.result.structuredOutput,
209
- functionCalls: streamed.result.functionCalls,
211
+ response: chatResponse.result.responseText,
212
+ structuredOutput: chatResponse.result.structuredOutput,
213
+ functionCalls: chatResponse.result.functionCalls,
210
214
  usage,
211
- reasoning: streamed.result.reasoning,
212
- requestStatus: streamed.result.requestStatus,
215
+ reasoning: chatResponse.result.reasoning,
216
+ requestStatus,
213
217
  responseError,
214
218
  requestStatuses,
215
219
  requestErrors,
@@ -229,13 +233,13 @@ export async function runChatV2Pipeline(options) {
229
233
  commonOutputs,
230
234
  requestMessages,
231
235
  allMessages: allMessagesOutput.value,
232
- response: streamed.result.responseText,
233
- functionCalls: streamed.result.functionCalls,
234
- reasoning: streamed.result.reasoning,
236
+ response: chatResponse.result.responseText,
237
+ functionCalls: chatResponse.result.functionCalls,
238
+ reasoning: chatResponse.result.reasoning,
235
239
  usage,
236
- rawUsage: streamed.result.usage,
237
- finishReason: streamed.result.finishReason,
238
- providerMetadata: streamed.result.providerMetadata,
239
- requestStatus: streamed.result.requestStatus ?? 200,
240
+ rawUsage: chatResponse.result.usage,
241
+ finishReason: chatResponse.result.finishReason,
242
+ providerMetadata: chatResponse.result.providerMetadata,
243
+ requestStatus,
240
244
  };
241
245
  }
@@ -147,7 +147,7 @@ export function getCommonChatV2Outputs(data, options = {}) {
147
147
  if (includeFunctionCalls) {
148
148
  outputs.push({
149
149
  id: functionCallsPortId,
150
- title: 'Function Calls',
150
+ title: 'Tool Calls',
151
151
  dataType: 'object[]',
152
152
  });
153
153
  }
@@ -196,7 +196,11 @@ export function createChatV2Model(provider, modelId, context, options = {}) {
196
196
  headers: options.headers,
197
197
  includeUsage: true,
198
198
  });
199
- return providerInstance.chatModel(modelId);
199
+ const model = providerInstance.chatModel(modelId);
200
+ // The installed OpenAI-compatible provider reads this from the model instance,
201
+ // but its factory options do not forward the flag.
202
+ model.supportsStructuredOutputs = true;
203
+ return model;
200
204
  }
201
205
  }
202
206
  }
@@ -22,7 +22,7 @@ export class CoalesceNodeImpl extends NodeImpl {
22
22
  visualData: {
23
23
  x: 0,
24
24
  y: 0,
25
- width: 150,
25
+ width: 190,
26
26
  },
27
27
  };
28
28
  return chartNode;
@@ -8,6 +8,20 @@ import { match } from 'ts-pattern';
8
8
  import { dedent } from 'ts-dedent';
9
9
  import { nodeDefinition } from '../NodeDefinition.js';
10
10
  import { coerceType, coerceTypeOptional } from '../../utils/coerceType.js';
11
+ export const compareNodeComparisonFunctionOptions = [
12
+ { label: '==', value: '==' },
13
+ { label: '!=', value: '!=' },
14
+ { label: '<', value: '<' },
15
+ { label: '<=', value: '<=' },
16
+ { label: '>', value: '>' },
17
+ { label: '>=', value: '>=' },
18
+ { label: 'and', value: 'and' },
19
+ { label: 'or', value: 'or' },
20
+ { label: 'xor', value: 'xor' },
21
+ { label: 'nand', value: 'nand' },
22
+ { label: 'nor', value: 'nor' },
23
+ { label: 'xnor', value: 'xnor' },
24
+ ];
11
25
  export class CompareNodeImpl extends NodeImpl {
12
26
  static create() {
13
27
  const chartNode = {
@@ -62,20 +76,7 @@ export class CompareNodeImpl extends NodeImpl {
62
76
  type: 'dropdown',
63
77
  label: 'Comparison Function',
64
78
  dataKey: 'comparisonFunction',
65
- options: [
66
- { label: '==', value: '==' },
67
- { label: '!=', value: '!=' },
68
- { label: '<', value: '<' },
69
- { label: '<=', value: '<=' },
70
- { label: '>', value: '>' },
71
- { label: '>=', value: '>=' },
72
- { label: 'and', value: 'and' },
73
- { label: 'or', value: 'or' },
74
- { label: 'xor', value: 'xor' },
75
- { label: 'nand', value: 'nand' },
76
- { label: 'nor', value: 'nor' },
77
- { label: 'xnor', value: 'xnor' },
78
- ],
79
+ options: compareNodeComparisonFunctionOptions,
79
80
  useInputToggleDataKey: 'useComparisonFunctionInput',
80
81
  },
81
82
  ];
@@ -78,6 +78,7 @@ export class GraphOutputNodeImpl extends NodeImpl {
78
78
  type: 'string',
79
79
  label: 'ID',
80
80
  dataKey: 'id',
81
+ commitDebounceMs: 300,
81
82
  },
82
83
  {
83
84
  type: 'dataTypeSelector',