@valerypopoff/rivet2-core 2.1.7 → 2.1.9

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 (115) hide show
  1. package/dist/cjs/bundle.cjs +4911 -2546
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/esm/api/createProcessor.js +45 -4
  4. package/dist/esm/exports.js +2 -0
  5. package/dist/esm/integrations/KnowledgeStoreFieldPolicy.js +216 -0
  6. package/dist/esm/integrations/KnowledgeStoreProvider.js +14 -90
  7. package/dist/esm/integrations/ManagedKnowledgeStore.js +0 -8
  8. package/dist/esm/model/DataBusPorts.js +26 -0
  9. package/dist/esm/model/DataBusTopology.js +207 -0
  10. package/dist/esm/model/DataValue.js +22 -7
  11. package/dist/esm/model/GraphPreprocessor.js +9 -3
  12. package/dist/esm/model/GraphProcessor.js +164 -366
  13. package/dist/esm/model/NodeIO.js +1 -0
  14. package/dist/esm/model/NodePrefabResolver.js +16 -0
  15. package/dist/esm/model/Nodes.js +7 -0
  16. package/dist/esm/model/SplitRunProcessor.js +19 -10
  17. package/dist/esm/model/ToolCallContinuationBranchPlanner.js +165 -0
  18. package/dist/esm/model/ToolCallContinuationCoordinator.js +206 -0
  19. package/dist/esm/model/chat/aiSdkMessages.js +8 -0
  20. package/dist/esm/model/chat-v2/chatV2CallObserver.js +142 -0
  21. package/dist/esm/model/chat-v2/chatV2EditorCache.js +22 -0
  22. package/dist/esm/model/chat-v2/chatV2Errors.js +23 -6
  23. package/dist/esm/model/chat-v2/chatV2Outputs.js +41 -31
  24. package/dist/esm/model/chat-v2/chatV2Pipeline.js +167 -56
  25. package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +1 -0
  26. package/dist/esm/model/chat-v2/chatV2ProviderTypes.js +1 -0
  27. package/dist/esm/model/chat-v2/chatV2RequestPlan.js +6 -5
  28. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +2 -2
  29. package/dist/esm/model/chat-v2/chatV2Shared.js +1 -6
  30. package/dist/esm/model/chat-v2/chatV2Types.js +11 -1
  31. package/dist/esm/model/chat-v2/developerMessageRoles.js +45 -0
  32. package/dist/esm/model/chat-v2/index.js +1 -0
  33. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +53 -3
  34. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +53 -19
  35. package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +232 -68
  36. package/dist/esm/model/chat-v2/llmProfile.js +212 -0
  37. package/dist/esm/model/chat-v2/llmProfileFallback.js +288 -0
  38. package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +73 -0
  39. package/dist/esm/model/chat-v2/llmProfileTypes.js +45 -0
  40. package/dist/esm/model/chat-v2/messageConverter.js +14 -0
  41. package/dist/esm/model/chat-v2/providerOptions.js +44 -11
  42. package/dist/esm/model/chat-v2/toolContinuation.js +0 -4
  43. package/dist/esm/model/nodes/AssembleMessageNode.js +6 -0
  44. package/dist/esm/model/nodes/DataBusNode.js +81 -0
  45. package/dist/esm/model/nodes/DelegateFunctionCallNode.js +12 -0
  46. package/dist/esm/model/nodes/GetGlobalNode.js +7 -11
  47. package/dist/esm/model/nodes/GetKnowledgeSourceStatusNode.js +1 -1
  48. package/dist/esm/model/nodes/LLMChatV2Node.js +156 -18
  49. package/dist/esm/model/nodes/LLMProfileNode.js +132 -0
  50. package/dist/esm/model/nodes/PassthroughNode.js +1 -11
  51. package/dist/esm/model/nodes/PromptNode.js +9 -2
  52. package/dist/esm/model/nodes/SearchKnowledgeNode.js +1 -1
  53. package/dist/esm/model/nodes/SetGlobalNode.js +6 -6
  54. package/dist/esm/model/nodes/SyncKnowledgeSourceNode.js +0 -1
  55. package/dist/esm/model/nodes/toolCallDelegation.js +31 -4
  56. package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +22 -28
  57. package/dist/esm/plugins/google/google.js +20 -9
  58. package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +17 -6
  59. package/dist/esm/plugins/pinecone/PineconeKnowledgeStore.js +0 -4
  60. package/dist/esm/plugins/pinecone/plugin.js +1 -1
  61. package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +4 -0
  62. package/dist/esm/utils/coerceType.js +84 -41
  63. package/dist/esm/utils/expectType.js +45 -8
  64. package/dist/esm/utils/fetchEventSource.js +18 -0
  65. package/dist/esm/utils/serialization/serialization.js +37 -7
  66. package/dist/esm/vendor/fnv1a.js +6 -3
  67. package/dist/types/api/createProcessor.d.ts +2 -0
  68. package/dist/types/exports.d.ts +2 -0
  69. package/dist/types/integrations/KnowledgeStore.d.ts +0 -2
  70. package/dist/types/integrations/KnowledgeStoreFieldPolicy.d.ts +38 -0
  71. package/dist/types/integrations/KnowledgeStoreProvider.d.ts +6 -3
  72. package/dist/types/model/DataBusPorts.d.ts +6 -0
  73. package/dist/types/model/DataBusTopology.d.ts +16 -0
  74. package/dist/types/model/DataValue.d.ts +22 -6
  75. package/dist/types/model/GraphPreprocessor.d.ts +2 -1
  76. package/dist/types/model/GraphProcessor.d.ts +4 -3
  77. package/dist/types/model/NodeBase.d.ts +6 -0
  78. package/dist/types/model/NodeIO.d.ts +5 -0
  79. package/dist/types/model/NodePrefabResolver.d.ts +9 -0
  80. package/dist/types/model/Nodes.d.ts +5 -2
  81. package/dist/types/model/ProcessContext.d.ts +64 -0
  82. package/dist/types/model/SplitRunProcessor.d.ts +2 -1
  83. package/dist/types/model/ToolCallContinuationBranchPlanner.d.ts +43 -0
  84. package/dist/types/model/ToolCallContinuationCoordinator.d.ts +70 -0
  85. package/dist/types/model/chat-v2/chatV2CallObserver.d.ts +10 -0
  86. package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +4 -0
  87. package/dist/types/model/chat-v2/chatV2Outputs.d.ts +5 -5
  88. package/dist/types/model/chat-v2/chatV2Pipeline.d.ts +33 -0
  89. package/dist/types/model/chat-v2/chatV2ProviderProfile.d.ts +1 -0
  90. package/dist/types/model/chat-v2/chatV2ProviderTypes.d.ts +1 -0
  91. package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +2 -2
  92. package/dist/types/model/chat-v2/chatV2RuntimeOptions.d.ts +8 -0
  93. package/dist/types/model/chat-v2/chatV2Shared.d.ts +0 -1
  94. package/dist/types/model/chat-v2/chatV2Types.d.ts +27 -3
  95. package/dist/types/model/chat-v2/developerMessageRoles.d.ts +10 -0
  96. package/dist/types/model/chat-v2/index.d.ts +1 -0
  97. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +10 -1
  98. package/dist/types/model/chat-v2/llmChatV2NodeEditors.d.ts +5 -1
  99. package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +18 -2
  100. package/dist/types/model/chat-v2/llmProfile.d.ts +10 -0
  101. package/dist/types/model/chat-v2/llmProfileFallback.d.ts +79 -0
  102. package/dist/types/model/chat-v2/llmProfileNodeRuntime.d.ts +9 -0
  103. package/dist/types/model/chat-v2/llmProfileTypes.d.ts +18 -0
  104. package/dist/types/model/chat-v2/providerOptions.d.ts +1 -0
  105. package/dist/types/model/nodes/AssembleMessageNode.d.ts +2 -1
  106. package/dist/types/model/nodes/DataBusNode.d.ts +19 -0
  107. package/dist/types/model/nodes/LLMProfileNode.d.ts +20 -0
  108. package/dist/types/model/nodes/PassthroughNode.d.ts +2 -15
  109. package/dist/types/model/nodes/PromptNode.d.ts +2 -2
  110. package/dist/types/model/nodes/SetGlobalNode.d.ts +2 -2
  111. package/dist/types/model/nodes/toolCallDelegation.d.ts +9 -0
  112. package/dist/types/plugins/google/google.d.ts +12 -1
  113. package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +2 -1
  114. package/dist/types/vendor/fnv1a.d.ts +5 -5
  115. package/package.json +1 -1
@@ -2,7 +2,7 @@ import {} from '../NodeBase.js';
2
2
  import { nanoid } from 'nanoid/non-secure';
3
3
  import { NodeImpl } from '../NodeImpl.js';
4
4
  import { nodeDefinition } from '../NodeDefinition.js';
5
- import { isArrayDataType, isScalarDataType, scalarDefaults, } from '../DataValue.js';
5
+ import { getDefaultValue, } from '../DataValue.js';
6
6
  import {} from '../GraphProcessor.js';
7
7
  import { coerceType } from '../../utils/coerceType.js';
8
8
  import {} from '../ProcessContext.js';
@@ -121,11 +121,7 @@ export class GetGlobalNodeImpl extends NodeImpl {
121
121
  if (value) {
122
122
  return value.value;
123
123
  }
124
- // Have some useful defaults before the value is set
125
- if (isArrayDataType(this.data.dataType)) {
126
- return [];
127
- }
128
- return scalarDefaults[this.data.dataType];
124
+ return getDefaultValue(this.data.dataType);
129
125
  },
130
126
  },
131
127
  ['variable_id_out']: { type: 'string', value: id },
@@ -134,11 +130,11 @@ export class GetGlobalNodeImpl extends NodeImpl {
134
130
  const id = this.data.useIdInput ? coerceType(inputs['id'], 'string') : this.data.id;
135
131
  let value = this.data.wait ? await context.waitForGlobal(id) : context.getGlobal(id);
136
132
  // Have some useful defaults before the value is set
137
- if (!value && isArrayDataType(this.data.dataType)) {
138
- value = { type: this.data.dataType, value: [] };
139
- }
140
- if (!value && isScalarDataType(this.data.dataType)) {
141
- value = { type: this.data.dataType, value: scalarDefaults[this.data.dataType] };
133
+ if (!value) {
134
+ value = {
135
+ type: this.data.dataType,
136
+ value: getDefaultValue(this.data.dataType),
137
+ };
142
138
  }
143
139
  return {
144
140
  ['value']: value,
@@ -62,7 +62,7 @@ export class GetKnowledgeSourceStatusNodeImpl extends NodeImpl {
62
62
  ? normalizeKnowledgeSourceReference({ ...source, version: expectedVersion }).version
63
63
  : undefined;
64
64
  const store = await context.getKnowledgeStore(source.connectionId);
65
- const result = normalizeKnowledgeSourceStatusResult(await store.getSourceStatus({ source, ...(normalizedExpectedVersion ? { expectedVersion: normalizedExpectedVersion } : {}) }, { signal: context.signal, reportProgress: context.reportProgress }), source, normalizedExpectedVersion);
65
+ const result = normalizeKnowledgeSourceStatusResult(await store.getSourceStatus({ source, ...(normalizedExpectedVersion ? { expectedVersion: normalizedExpectedVersion } : {}) }, { signal: context.signal }), source, normalizedExpectedVersion);
66
66
  return {
67
67
  ['source']: { type: 'knowledge-source', value: result.source },
68
68
  ['exists']: { type: 'boolean', value: result.exists },
@@ -4,12 +4,13 @@ import { nodeDefinition } from '../NodeDefinition.js';
4
4
  import { NodeImpl } from '../NodeImpl.js';
5
5
  import { getCommonChatV2Inputs, getCommonChatV2Outputs } from '../chat-v2/chatV2Shared.js';
6
6
  import { getLLMChatV2Editors } from '../chat-v2/llmChatV2NodeEditors.js';
7
- import { createLLMChatV2NodeData, hasLLMChatV2BuiltInToolsEnabled, } from '../chat-v2/llmChatV2NodeData.js';
7
+ import { createLLMChatV2NodeData, shouldIncludeLLMChatV2ToolCalls, } from '../chat-v2/llmChatV2NodeData.js';
8
8
  import { isLLMChatV2StructuredResponseFormat } from '../chat-v2/chatV2FeatureCompatibility.js';
9
+ import { buildLLMProfileRequestDiagnostics, compactLLMProfileRequestErrors, compactLLMProfileRequestStatuses, } from '../chat-v2/llmProfileFallback.js';
9
10
  import { getChatV2ModelInfo } from '../chat-v2/modelRegistry.js';
11
+ import { shouldOutputChatV2RequestBody, shouldOutputChatV2RequestError } from '../chat-v2/chatV2Types.js';
10
12
  import { buildLLMChatV2EditorCacheKey, cloneLLMChatV2EditorCacheOutputs, resolveLLMChatV2RuntimeConfig, resolveLLMChatV2RuntimeProviderOptions, } from '../chat-v2/llmChatV2NodeRuntime.js';
11
13
  import { anthropicEffortOptions, getChatV2ProviderLabel, googleThinkingLevelOptions, openAIReasoningEffortOptions, } from '../chat-v2/providerOptions.js';
12
- import { runChatV2Pipeline } from '../chat-v2/chatV2Pipeline.js';
13
14
  import { runChatV2PipelineWithToolContinuation } from '../chat-v2/toolContinuation.js';
14
15
  import { delegateToolCall } from './toolCallDelegation.js';
15
16
  export { buildLLMChatV2EditorCacheKey, resolveLLMChatV2RuntimeProviderOptions };
@@ -87,10 +88,36 @@ export class LLMChatV2NodeImpl extends NodeImpl {
87
88
  };
88
89
  }
89
90
  getInputDefinitions() {
90
- const inputs = getCommonChatV2Inputs(this.data, {
91
+ const usesProfile = this.data.configurationMode === 'profile';
92
+ const commonInputData = usesProfile
93
+ ? {
94
+ ...this.data,
95
+ useModelInput: false,
96
+ useTemperatureInput: false,
97
+ useTopPInput: false,
98
+ useTopKInput: false,
99
+ usePresencePenaltyInput: false,
100
+ useFrequencyPenaltyInput: false,
101
+ useStopSequencesInput: false,
102
+ useSeedInput: false,
103
+ useMaxTokensInput: false,
104
+ }
105
+ : this.data;
106
+ const inputs = getCommonChatV2Inputs(commonInputData, {
91
107
  includeFunctions: this.data.useToolCalling,
92
108
  });
93
- if (this.data.apiKeySource === 'input') {
109
+ if (usesProfile) {
110
+ inputs.unshift({
111
+ id: 'llmProfile',
112
+ title: 'LLM Profiles',
113
+ dataType: ['llm-config', 'llm-config[]'],
114
+ required: true,
115
+ coerced: true,
116
+ splitRunBehavior: 'preserve-array',
117
+ description: 'One LLM Profile or an ordered fallback chain. Profiles are tried left to right.',
118
+ });
119
+ }
120
+ if (!usesProfile && this.data.apiKeySource === 'input') {
94
121
  inputs.push({
95
122
  id: 'apiKey',
96
123
  title: 'API Key',
@@ -98,7 +125,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
98
125
  required: false,
99
126
  });
100
127
  }
101
- if (usesBaseURLInput(this.data)) {
128
+ if (!usesProfile && usesBaseURLInput(this.data)) {
102
129
  inputs.unshift({
103
130
  id: 'customProviderBaseURL',
104
131
  title: 'Provider base URL',
@@ -106,7 +133,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
106
133
  required: false,
107
134
  });
108
135
  }
109
- if (this.data.useHeadersInput) {
136
+ if (!usesProfile && this.data.useHeadersInput) {
110
137
  inputs.push({
111
138
  id: 'headers',
112
139
  title: 'Headers',
@@ -114,7 +141,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
114
141
  required: false,
115
142
  });
116
143
  }
117
- if (this.data.useExtraProviderOptionsInput) {
144
+ if (!usesProfile && this.data.useExtraProviderOptionsInput) {
118
145
  inputs.push({
119
146
  id: 'extraProviderOptions',
120
147
  title: 'Extra Provider Options',
@@ -123,7 +150,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
123
150
  coerced: true,
124
151
  });
125
152
  }
126
- if (this.data.provider === 'openai' && this.data.useOpenAIPreviousResponseIdInput) {
153
+ if (!usesProfile && this.data.useOpenAIPreviousResponseIdInput && this.data.provider === 'openai') {
127
154
  inputs.push({
128
155
  id: 'previousResponseId',
129
156
  title: 'Previous Response ID',
@@ -131,7 +158,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
131
158
  required: false,
132
159
  });
133
160
  }
134
- if (this.data.provider === 'anthropic' && this.data.useAnthropicThinkingBudgetInput) {
161
+ if (!usesProfile && this.data.provider === 'anthropic' && this.data.useAnthropicThinkingBudgetInput) {
135
162
  inputs.push({
136
163
  id: 'anthropicThinkingBudget',
137
164
  title: 'Thinking Budget',
@@ -139,7 +166,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
139
166
  required: false,
140
167
  });
141
168
  }
142
- if (this.data.provider === 'google' && this.data.useGoogleThinkingBudgetInput) {
169
+ if (!usesProfile && this.data.provider === 'google' && this.data.useGoogleThinkingBudgetInput) {
143
170
  inputs.push({
144
171
  id: 'googleThinkingBudget',
145
172
  title: 'Thinking Budget',
@@ -178,7 +205,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
178
205
  }
179
206
  getOutputDefinitions() {
180
207
  const outputs = getCommonChatV2Outputs(this.data, {
181
- includeFunctionCalls: this.data.useToolCalling || hasLLMChatV2BuiltInToolsEnabled(this.data),
208
+ includeFunctionCalls: shouldIncludeLLMChatV2ToolCalls(this.data),
182
209
  includeUsage: this.data.outputUsage,
183
210
  includeReasoning: this.data.outputReasoning,
184
211
  });
@@ -198,20 +225,59 @@ export class LLMChatV2NodeImpl extends NodeImpl {
198
225
  ];
199
226
  }
200
227
  if (this.data.outputRequestStatus) {
228
+ const profileArrayRequestDetails = this.data.configurationMode === 'profile'
229
+ ? ['number', 'number[]', 'any']
230
+ : this.data.retryOnNon200
231
+ ? 'number[]'
232
+ : 'number';
201
233
  outputs.push({
202
234
  id: 'requestStatus',
203
235
  title: 'Response Status',
204
- dataType: this.data.retryOnNon200 ? 'number[]' : 'number',
205
- }, {
236
+ dataType: profileArrayRequestDetails,
237
+ ...(this.data.configurationMode === 'profile'
238
+ ? {
239
+ description: 'A scalar profile keeps the normal status shape. An LLM Profile array groups values by profile: one request is a number, retries are a number array.',
240
+ }
241
+ : {}),
242
+ });
243
+ }
244
+ if (shouldOutputChatV2RequestError(this.data)) {
245
+ const profileArrayRequestErrors = this.data.configurationMode === 'profile'
246
+ ? ['string', 'string[]', 'any']
247
+ : this.data.retryOnNon200
248
+ ? 'string[]'
249
+ : 'string';
250
+ outputs.push({
206
251
  id: 'requestError',
207
252
  title: 'Response Error',
208
- dataType: this.data.retryOnNon200 ? 'string[]' : 'string',
209
- }, {
253
+ dataType: profileArrayRequestErrors,
254
+ ...(this.data.configurationMode === 'profile'
255
+ ? {
256
+ description: 'A scalar profile keeps the normal error shape. An LLM Profile array keeps profile positions when errors occur: one error is a string and retries are an array.',
257
+ }
258
+ : {}),
259
+ });
260
+ }
261
+ if (shouldOutputChatV2RequestBody(this.data)) {
262
+ outputs.push({
210
263
  id: 'requestBody',
211
264
  title: 'LLM request body',
212
265
  dataType: ['object', 'object[]', 'string', 'string[]', 'any', 'any[]'],
213
266
  });
214
267
  }
268
+ if (this.data.configurationMode === 'profile') {
269
+ outputs.push({
270
+ id: 'llmProfileSummary',
271
+ title: 'LLM Profile Summary',
272
+ dataType: 'string',
273
+ description: 'Human-readable profile fallback outcome for this LLM Chat run.',
274
+ }, {
275
+ id: 'llmProfileAttempts',
276
+ title: 'LLM Profile Attempts',
277
+ dataType: 'object[]',
278
+ description: 'Chronological provider/profile attempts for this LLM Chat run.',
279
+ });
280
+ }
215
281
  return outputs;
216
282
  }
217
283
  static getUIData() {
@@ -231,6 +297,17 @@ export class LLMChatV2NodeImpl extends NodeImpl {
231
297
  return getLLMChatV2Editors(this.data, context);
232
298
  }
233
299
  getBody() {
300
+ if (this.data.configurationMode === 'profile') {
301
+ return {
302
+ type: 'markdown',
303
+ disableLinks: true,
304
+ text: [
305
+ getBodyLine('Configuration', 'From LLM Profiles input'),
306
+ ...(this.data.useToolCalling ? [getBodyLine('Tools', 'Enabled')] : []),
307
+ ...(this.data.responseFormat ? [getBodyLine('Response format', this.data.responseFormat)] : []),
308
+ ].join('\n'),
309
+ };
310
+ }
234
311
  const modelInfo = getChatV2ModelInfo(this.data.provider, this.data.model);
235
312
  const providerLabel = getProviderBodyLabel(this.data);
236
313
  const baseURLValue = getCustomProviderBaseURLBodyValue(this.data);
@@ -269,6 +346,31 @@ export class LLMChatV2NodeImpl extends NodeImpl {
269
346
  });
270
347
  const toolCallContinuation = context.toolCallContinuation;
271
348
  if (runtime.cachedOutputs != null) {
349
+ if (runtime.profileChainUsesArray && this.data.outputRequestStatus) {
350
+ const cachedStatus = runtime.cachedOutputs['requestStatus'];
351
+ if (cachedStatus?.type === 'any' && Array.isArray(cachedStatus.value)) {
352
+ cachedStatus.value = compactLLMProfileRequestStatuses(cachedStatus.value);
353
+ }
354
+ }
355
+ if (runtime.profileChainUsesArray && shouldOutputChatV2RequestError(this.data)) {
356
+ const cachedError = runtime.cachedOutputs['requestError'];
357
+ if (cachedError?.type === 'any' && Array.isArray(cachedError.value)) {
358
+ cachedError.value = compactLLMProfileRequestErrors(cachedError.value);
359
+ }
360
+ }
361
+ // Cached provider output belongs to an earlier invocation, whereas this
362
+ // port is an observability record for physical profile attempts made by
363
+ // the current one. A cache hit made no such attempt.
364
+ if (runtime.profileAttempts != null) {
365
+ runtime.cachedOutputs['llmProfileAttempts'] = {
366
+ type: 'object[]',
367
+ value: [],
368
+ };
369
+ runtime.cachedOutputs['llmProfileSummary'] = {
370
+ type: 'string',
371
+ value: 'Editor cache hit — no LLM Profile calls were made for this run.',
372
+ };
373
+ }
272
374
  return runtime.cachedOutputs;
273
375
  }
274
376
  const result = runtime.shouldAutoContinueToolCalls
@@ -301,13 +403,49 @@ export class LLMChatV2NodeImpl extends NodeImpl {
301
403
  delegatedToolCall: delegated.record,
302
404
  };
303
405
  },
406
+ runPipeline: runtime.runPipeline,
304
407
  })
305
- : await runChatV2Pipeline(runtime.runOptions);
408
+ : await runtime.runPipeline(runtime.runOptions);
409
+ if (runtime.profileAttempts != null) {
410
+ result.commonOutputs['llmProfileAttempts'] = {
411
+ type: 'object[]',
412
+ value: runtime.profileAttempts,
413
+ };
414
+ result.commonOutputs['llmProfileSummary'] = {
415
+ type: 'string',
416
+ value: runtime.getProfileSummary(),
417
+ };
418
+ if (runtime.profileChainUsesArray && runtime.profileChainLength != null) {
419
+ const diagnostics = buildLLMProfileRequestDiagnostics(runtime.profileChainLength, runtime.profileAttempts);
420
+ // Rivet has scalar and one-dimensional array Data Values, but no
421
+ // nested-array Data Type. Keep profile/retry grouping as portable JSON
422
+ // inside Any values. One request or error stays scalar when doing so
423
+ // preserves useful diagnostic information.
424
+ if (this.data.outputRequestStatus) {
425
+ result.commonOutputs['requestStatus'] = {
426
+ type: 'any',
427
+ value: diagnostics.statuses,
428
+ };
429
+ }
430
+ if (shouldOutputChatV2RequestError(this.data)) {
431
+ result.commonOutputs['requestError'] = {
432
+ type: 'any',
433
+ value: diagnostics.errors,
434
+ };
435
+ }
436
+ }
437
+ }
306
438
  if (toolCallContinuation && result.functionCalls.length > 0) {
307
439
  toolCallContinuation.release();
308
440
  }
309
- if (runtime.cacheKey != null && runtime.editorCache != null) {
310
- runtime.editorCache.set(runtime.cacheKey, cloneLLMChatV2EditorCacheOutputs(result.commonOutputs));
441
+ if (runtime.cacheKey != null && runtime.editorCache != null && !runtime.isProfileFallbackExhausted()) {
442
+ const cacheOutputs = cloneLLMChatV2EditorCacheOutputs(result.commonOutputs);
443
+ // Attempt history is specific to this execution. Rebuild it as an empty
444
+ // observability value on a later cache hit instead of presenting stale
445
+ // provider calls as if they happened again.
446
+ delete cacheOutputs['llmProfileAttempts'];
447
+ delete cacheOutputs['llmProfileSummary'];
448
+ runtime.editorCache.set(runtime.cacheKey, cacheOutputs);
311
449
  }
312
450
  return result.commonOutputs;
313
451
  }
@@ -0,0 +1,132 @@
1
+ import { nanoid } from 'nanoid/non-secure';
2
+ import { dedent } from 'ts-dedent';
3
+ import { nodeDefinition } from '../NodeDefinition.js';
4
+ import { NodeImpl } from '../NodeImpl.js';
5
+ import { getLLMProfileEditors } from '../chat-v2/llmChatV2NodeEditors.js';
6
+ import { resolveLLMProfileNodeValue } from '../chat-v2/llmProfileNodeRuntime.js';
7
+ import { createLLMProfileNodeData } from '../chat-v2/llmProfileTypes.js';
8
+ import { getChatV2ProviderLabel } from '../chat-v2/providerOptions.js';
9
+ export class LLMProfileNodeImpl extends NodeImpl {
10
+ static create() {
11
+ return {
12
+ type: 'llmProfile',
13
+ title: 'LLM Profile',
14
+ id: nanoid(),
15
+ visualData: {
16
+ x: 0,
17
+ y: 0,
18
+ width: 260,
19
+ },
20
+ data: createLLMProfileNodeData(),
21
+ };
22
+ }
23
+ getInputDefinitions() {
24
+ const inputs = [];
25
+ if (this.data.useModelInput) {
26
+ inputs.push({ id: 'model', title: 'Model', dataType: 'string', required: false });
27
+ }
28
+ if (this.data.apiKeySource === 'input') {
29
+ inputs.push({ id: 'apiKey', title: 'API Key', dataType: 'string', required: true });
30
+ }
31
+ if (this.data.provider === 'custom' && this.data.useCustomProviderBaseURLInput) {
32
+ inputs.push({
33
+ id: 'customProviderBaseURL',
34
+ title: 'Provider base URL',
35
+ dataType: 'string',
36
+ required: false,
37
+ });
38
+ }
39
+ if (this.data.provider === 'openai' && this.data.useOpenAIPreviousResponseIdInput) {
40
+ inputs.push({
41
+ id: 'previousResponseId',
42
+ title: 'Previous Response ID',
43
+ dataType: 'string',
44
+ required: false,
45
+ });
46
+ }
47
+ if (this.data.useTemperatureInput) {
48
+ inputs.push({ id: 'temperature', title: 'Temperature', dataType: 'number' });
49
+ }
50
+ if (this.data.useMaxTokensInput) {
51
+ inputs.push({ id: 'maxTokens', title: 'Max output tokens', dataType: 'number' });
52
+ }
53
+ if (this.data.useTopPInput) {
54
+ inputs.push({ id: 'topP', title: 'Top P', dataType: 'number' });
55
+ }
56
+ if (this.data.useTopKInput) {
57
+ inputs.push({ id: 'topK', title: 'Top K', dataType: 'number' });
58
+ }
59
+ if (this.data.usePresencePenaltyInput) {
60
+ inputs.push({ id: 'presencePenalty', title: 'Presence Penalty', dataType: 'number' });
61
+ }
62
+ if (this.data.useFrequencyPenaltyInput) {
63
+ inputs.push({ id: 'frequencyPenalty', title: 'Frequency Penalty', dataType: 'number' });
64
+ }
65
+ if (this.data.useStopSequencesInput) {
66
+ inputs.push({
67
+ id: 'stopSequences',
68
+ title: 'Stop Sequences',
69
+ dataType: ['string', 'string[]'],
70
+ required: false,
71
+ coerced: true,
72
+ });
73
+ }
74
+ if (this.data.useSeedInput) {
75
+ inputs.push({ id: 'seed', title: 'Seed', dataType: 'number' });
76
+ }
77
+ if (this.data.useHeadersInput) {
78
+ inputs.push({ id: 'headers', title: 'Headers', dataType: 'object', required: false });
79
+ }
80
+ if (this.data.useExtraProviderOptionsInput) {
81
+ inputs.push({
82
+ id: 'extraProviderOptions',
83
+ title: 'Extra Provider Options',
84
+ dataType: ['string', 'object'],
85
+ required: false,
86
+ coerced: true,
87
+ });
88
+ }
89
+ if (this.data.provider === 'anthropic' && this.data.useAnthropicThinkingBudgetInput) {
90
+ inputs.push({ id: 'anthropicThinkingBudget', title: 'Thinking Budget', dataType: 'number' });
91
+ }
92
+ if (this.data.provider === 'google' && this.data.useGoogleThinkingBudgetInput) {
93
+ inputs.push({ id: 'googleThinkingBudget', title: 'Thinking Budget', dataType: 'number' });
94
+ }
95
+ return inputs;
96
+ }
97
+ getOutputDefinitions() {
98
+ return [{ id: 'profile', title: 'Profile', dataType: 'llm-config' }];
99
+ }
100
+ async getEditors(context) {
101
+ return await getLLMProfileEditors(this.data, context);
102
+ }
103
+ getBody() {
104
+ return dedent `
105
+ Provider: ${getChatV2ProviderLabel(this.data.provider)}
106
+ Model: ${this.data.useModelInput ? '(from input)' : this.data.model}
107
+ Temperature: ${this.data.useTemperatureInput ? '(from input)' : this.data.temperature}
108
+ Max output tokens: ${this.data.useMaxTokensInput ? '(from input)' : this.data.maxTokens}
109
+ `;
110
+ }
111
+ static getUIData() {
112
+ return {
113
+ infoBoxBody: 'Creates a reusable LLM provider, model, credential, generation, reasoning, and provider-capability profile for LLM Chat.',
114
+ contextMenuTitle: 'LLM Profile',
115
+ infoBoxTitle: 'LLM Profile Node',
116
+ group: ['Common', 'AI'],
117
+ };
118
+ }
119
+ async process(inputs, context) {
120
+ return {
121
+ ['profile']: {
122
+ type: 'llm-config',
123
+ value: resolveLLMProfileNodeValue({
124
+ data: this.data,
125
+ inputs,
126
+ context,
127
+ }),
128
+ },
129
+ };
130
+ }
131
+ }
132
+ export const llmProfileNode = nodeDefinition(LLMProfileNodeImpl, 'LLM Profile');
@@ -6,6 +6,7 @@ import {} from '../GraphProcessor.js';
6
6
  import { dedent } from 'ts-dedent';
7
7
  const INPUT_PORT_PATTERN = /^input(\d+)$/;
8
8
  const OUTPUT_PORT_PATTERN = /^output(\d+)$/;
9
+ /** @deprecated Use MAX_DATA_BUS_CHANNEL_INDEX for Data Bus channels. */
9
10
  export const MAX_PASSTHROUGH_PORT_INDEX = 10_000;
10
11
  function parsePositivePortIndex(portId, pattern) {
11
12
  const match = pattern.exec(portId);
@@ -21,17 +22,6 @@ function getHighestConnectedSlotIndex(connections, nodeId) {
21
22
  }
22
23
  return highestIndex;
23
24
  }
24
- export function isPassthroughDataBusNode(node) {
25
- return node?.type === 'passthrough' && node.data?.renderAsDataBus === true;
26
- }
27
- /**
28
- * Conditional and split-run Passthrough nodes have execution semantics that a
29
- * hidden canvas rail cannot communicate. Malformed or hand-edited combinations
30
- * therefore fall back to the normal visible node until the conflict is removed.
31
- */
32
- export function canRenderPassthroughAsDataBus(node) {
33
- return isPassthroughDataBusNode(node) && !node.isConditional && !node.isSplitRun;
34
- }
35
25
  export class PassthroughNodeImpl extends NodeImpl {
36
26
  static create = () => {
37
27
  const chartNode = {
@@ -102,6 +102,7 @@ export class PromptNodeImpl extends NodeImpl {
102
102
  label: 'Type',
103
103
  options: [
104
104
  { value: 'system', label: 'System' },
105
+ { value: 'developer', label: 'Developer' },
105
106
  { value: 'user', label: 'User' },
106
107
  { value: 'assistant', label: 'Assistant' },
107
108
  { value: 'function', label: 'Function' },
@@ -162,7 +163,7 @@ export class PromptNodeImpl extends NodeImpl {
162
163
  static getUIData() {
163
164
  return {
164
165
  infoBoxBody: dedent `
165
- Outputs a chat message, which is a string of text with an attached "type" saying who sent the message (User, Assistant, System) and optionally an attached "name".
166
+ Outputs a chat message, which is a string of text with an attached "type" saying who sent the message (User, Assistant, System, Developer) and optionally an attached "name".
166
167
 
167
168
  Also provides the same <span style="color: var(--primary)">{{interpolation}}</span> capabilities as a Text node.
168
169
 
@@ -182,7 +183,7 @@ export class PromptNodeImpl extends NodeImpl {
182
183
  outputValue = outputValue.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
183
184
  const type = getInputOrData(this.data, inputs, 'type', 'string');
184
185
  const isCacheBreakpoint = getInputOrData(this.data, inputs, 'isCacheBreakpoint', 'boolean');
185
- if (['assistant', 'system', 'user', 'function'].includes(type) === false) {
186
+ if (['assistant', 'system', 'developer', 'user', 'function'].includes(type) === false) {
186
187
  throw new Error(`Invalid type: ${type}`);
187
188
  }
188
189
  const message = match(type)
@@ -190,6 +191,11 @@ export class PromptNodeImpl extends NodeImpl {
190
191
  type,
191
192
  message: outputValue,
192
193
  isCacheBreakpoint,
194
+ }))
195
+ .with('developer', (type) => ({
196
+ type,
197
+ message: outputValue,
198
+ isCacheBreakpoint,
193
199
  }))
194
200
  .with('user', (type) => ({
195
201
  type,
@@ -246,6 +252,7 @@ export class PromptNodeImpl extends NodeImpl {
246
252
  export const promptNode = nodeDefinition(PromptNodeImpl, 'Prompt');
247
253
  const typeDisplay = {
248
254
  assistant: 'Assistant',
255
+ developer: 'Developer',
249
256
  system: 'System',
250
257
  user: 'User',
251
258
  function: 'Function',
@@ -108,7 +108,7 @@ export class SearchKnowledgeNodeImpl extends NodeImpl {
108
108
  finalResultCount: this.data.finalResultCount,
109
109
  filter,
110
110
  rerank,
111
- }, { signal: context.signal, reportProgress: context.reportProgress }), source, queries);
111
+ }, { signal: context.signal }), source, queries);
112
112
  return {
113
113
  ['evidence']: { type: 'knowledge-evidence[]', value: result.evidence },
114
114
  ['source']: { type: 'knowledge-source', value: result.source },
@@ -2,7 +2,7 @@ import {} from '../NodeBase.js';
2
2
  import { nanoid } from 'nanoid/non-secure';
3
3
  import { NodeImpl } from '../NodeImpl.js';
4
4
  import { nodeDefinition } from '../NodeDefinition.js';
5
- import { isArrayDataType, isScalarDataType, scalarDefaults, unwrapDataValue, } from '../DataValue.js';
5
+ import { getDefaultValue, unwrapDataValue, } from '../DataValue.js';
6
6
  import {} from '../GraphProcessor.js';
7
7
  import { coerceType } from '../../utils/coerceType.js';
8
8
  import {} from '../ProcessContext.js';
@@ -107,11 +107,11 @@ export class SetGlobalNodeImpl extends NodeImpl {
107
107
  throw new Error('Missing variable ID');
108
108
  }
109
109
  let previousValue = context.getGlobal(id);
110
- if (!previousValue && isArrayDataType(this.data.dataType)) {
111
- previousValue = { type: this.data.dataType, value: [] };
112
- }
113
- else if (!previousValue && isScalarDataType(this.data.dataType)) {
114
- previousValue = { type: this.data.dataType, value: scalarDefaults[this.data.dataType] };
110
+ if (!previousValue) {
111
+ previousValue = {
112
+ type: this.data.dataType,
113
+ value: getDefaultValue(this.data.dataType),
114
+ };
115
115
  }
116
116
  const value = unwrapDataValue(rawValue);
117
117
  context.setGlobal(id, value);
@@ -120,7 +120,6 @@ export class SyncKnowledgeSourceNodeImpl extends NodeImpl {
120
120
  },
121
121
  }, {
122
122
  signal: context.signal,
123
- reportProgress: context.reportProgress,
124
123
  getTokenCount: (text) => context.tokenizer.getTokenCountForString(text, { node: context.node }),
125
124
  }), source);
126
125
  return {
@@ -1,6 +1,18 @@
1
1
  import { omit } from 'lodash-es';
2
2
  import { coerceTypeOptional } from '../../utils/coerceType.js';
3
3
  import { getError } from '../../utils/errors.js';
4
+ /**
5
+ * Finds an Auto Delegate handler from an ordered set of graph-like candidates.
6
+ *
7
+ * Candidate identity belongs to the caller. Runtime execution passes graph
8
+ * objects and uses their metadata IDs; editor analysis passes project-map
9
+ * entries and uses their map keys. Keeping that distinction here preserves the
10
+ * existing behavior for malformed projects where those identities disagree.
11
+ */
12
+ export function findAutoDelegateGraphCandidate(candidates, toolName, getGraphName) {
13
+ return (candidates.find((candidate) => getGraphName(candidate) === toolName) ??
14
+ candidates.find((candidate) => getGraphName(candidate)?.includes(toolName)));
15
+ }
4
16
  export function isDelegatedToolCallRecord(input) {
5
17
  const maybeRecord = input;
6
18
  const maybeMessage = maybeRecord?.message;
@@ -31,6 +43,15 @@ export function buildDelegatedToolCallOutputs(records, preToolMessage, cost) {
31
43
  };
32
44
  const outputs = records.length === 1
33
45
  ? {
46
+ ['assistant-message']: preToolMessageOutput,
47
+ ['tool-name']: {
48
+ type: 'string',
49
+ value: records[0].name,
50
+ },
51
+ ['tool-arguments']: {
52
+ type: 'object',
53
+ value: records[0].arguments,
54
+ },
34
55
  ['output']: {
35
56
  type: 'string',
36
57
  value: records[0].output,
@@ -39,9 +60,17 @@ export function buildDelegatedToolCallOutputs(records, preToolMessage, cost) {
39
60
  type: 'chat-message',
40
61
  value: records[0].message,
41
62
  },
42
- ['assistant-message']: preToolMessageOutput,
43
63
  }
44
64
  : {
65
+ ['assistant-message']: preToolMessageOutput,
66
+ ['tool-name']: {
67
+ type: 'string[]',
68
+ value: records.map((record) => record.name),
69
+ },
70
+ ['tool-arguments']: {
71
+ type: 'object[]',
72
+ value: records.map((record) => record.arguments),
73
+ },
45
74
  ['output']: {
46
75
  type: 'string[]',
47
76
  value: records.map((record) => record.output),
@@ -50,7 +79,6 @@ export function buildDelegatedToolCallOutputs(records, preToolMessage, cost) {
50
79
  type: 'chat-message[]',
51
80
  value: records.map((record) => record.message),
52
81
  },
53
- ['assistant-message']: preToolMessageOutput,
54
82
  };
55
83
  if (cost != null) {
56
84
  outputs['cost'] = { type: 'number', value: cost };
@@ -123,8 +151,7 @@ export async function delegateToolCall(rawFunctionCall, context, config) {
123
151
  let handler;
124
152
  if (config.autoDelegate) {
125
153
  const graphs = Object.values(context.project.graphs);
126
- const matchingGraph = graphs.find((graph) => graph.metadata?.name === functionCall.name) ??
127
- graphs.find((graph) => graph.metadata?.name?.includes(functionCall.name));
154
+ const matchingGraph = findAutoDelegateGraphCandidate(graphs, functionCall.name, (graph) => graph.metadata?.name);
128
155
  if (matchingGraph) {
129
156
  handler = { key: undefined, value: matchingGraph.metadata.id };
130
157
  }