@valerypopoff/rivet2-core 2.1.6 → 2.1.8

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 (79) hide show
  1. package/dist/cjs/bundle.cjs +3436 -1831
  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 +163 -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/ToolCallContinuationBranchPlanner.js +165 -0
  17. package/dist/esm/model/ToolCallContinuationCoordinator.js +201 -0
  18. package/dist/esm/model/chat-v2/chatV2CallObserver.js +140 -0
  19. package/dist/esm/model/chat-v2/chatV2Errors.js +23 -6
  20. package/dist/esm/model/chat-v2/chatV2Pipeline.js +47 -14
  21. package/dist/esm/model/chat-v2/chatV2ProviderTypes.js +1 -0
  22. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +2 -2
  23. package/dist/esm/model/chat-v2/index.js +1 -0
  24. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +52 -0
  25. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +38 -13
  26. package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +42 -34
  27. package/dist/esm/model/chat-v2/llmProfile.js +191 -0
  28. package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +73 -0
  29. package/dist/esm/model/chat-v2/llmProfileTypes.js +45 -0
  30. package/dist/esm/model/nodes/DataBusNode.js +81 -0
  31. package/dist/esm/model/nodes/GetGlobalNode.js +7 -11
  32. package/dist/esm/model/nodes/GetKnowledgeSourceStatusNode.js +1 -1
  33. package/dist/esm/model/nodes/LLMChatV2Node.js +44 -10
  34. package/dist/esm/model/nodes/LLMProfileNode.js +132 -0
  35. package/dist/esm/model/nodes/PassthroughNode.js +26 -8
  36. package/dist/esm/model/nodes/SearchKnowledgeNode.js +1 -1
  37. package/dist/esm/model/nodes/SetGlobalNode.js +6 -6
  38. package/dist/esm/model/nodes/SyncKnowledgeSourceNode.js +0 -1
  39. package/dist/esm/model/nodes/toolCallDelegation.js +13 -2
  40. package/dist/esm/plugins/pinecone/PineconeKnowledgeStore.js +0 -4
  41. package/dist/esm/plugins/pinecone/plugin.js +1 -1
  42. package/dist/esm/utils/coerceType.js +84 -41
  43. package/dist/esm/utils/expectType.js +45 -8
  44. package/dist/esm/utils/fetchEventSource.js +18 -0
  45. package/dist/esm/utils/serialization/serialization.js +18 -7
  46. package/dist/esm/vendor/fnv1a.js +6 -3
  47. package/dist/types/api/createProcessor.d.ts +2 -0
  48. package/dist/types/exports.d.ts +2 -0
  49. package/dist/types/integrations/KnowledgeStore.d.ts +0 -2
  50. package/dist/types/integrations/KnowledgeStoreFieldPolicy.d.ts +38 -0
  51. package/dist/types/integrations/KnowledgeStoreProvider.d.ts +6 -3
  52. package/dist/types/model/DataBusPorts.d.ts +6 -0
  53. package/dist/types/model/DataBusTopology.d.ts +16 -0
  54. package/dist/types/model/DataValue.d.ts +15 -5
  55. package/dist/types/model/GraphPreprocessor.d.ts +2 -1
  56. package/dist/types/model/GraphProcessor.d.ts +4 -3
  57. package/dist/types/model/NodeIO.d.ts +5 -0
  58. package/dist/types/model/NodePrefabResolver.d.ts +9 -0
  59. package/dist/types/model/Nodes.d.ts +5 -2
  60. package/dist/types/model/ProcessContext.d.ts +60 -0
  61. package/dist/types/model/ToolCallContinuationBranchPlanner.d.ts +43 -0
  62. package/dist/types/model/ToolCallContinuationCoordinator.d.ts +70 -0
  63. package/dist/types/model/chat-v2/chatV2CallObserver.d.ts +10 -0
  64. package/dist/types/model/chat-v2/chatV2ProviderTypes.d.ts +1 -0
  65. package/dist/types/model/chat-v2/chatV2RuntimeOptions.d.ts +8 -0
  66. package/dist/types/model/chat-v2/chatV2Types.d.ts +3 -3
  67. package/dist/types/model/chat-v2/index.d.ts +1 -0
  68. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +6 -0
  69. package/dist/types/model/chat-v2/llmChatV2NodeEditors.d.ts +5 -1
  70. package/dist/types/model/chat-v2/llmProfile.d.ts +3 -0
  71. package/dist/types/model/chat-v2/llmProfileNodeRuntime.d.ts +9 -0
  72. package/dist/types/model/chat-v2/llmProfileTypes.d.ts +18 -0
  73. package/dist/types/model/nodes/DataBusNode.d.ts +19 -0
  74. package/dist/types/model/nodes/LLMProfileNode.d.ts +20 -0
  75. package/dist/types/model/nodes/PassthroughNode.d.ts +3 -2
  76. package/dist/types/model/nodes/SetGlobalNode.d.ts +2 -2
  77. package/dist/types/model/nodes/toolCallDelegation.d.ts +9 -0
  78. package/dist/types/vendor/fnv1a.d.ts +5 -5
  79. package/package.json +1 -1
@@ -0,0 +1,73 @@
1
+ import { coerceTypeOptional } from '../../utils/coerceType.js';
2
+ import { getInputOrData } from '../../utils/inputs.js';
3
+ import { resolveChatV2Credential } from './chatV2ProviderProfile.js';
4
+ import { resolveLLMChatV2ExtraProviderOptions, resolveLLMChatV2GenerationParameters, resolveLLMChatV2Headers, } from './chatV2RuntimeOptions.js';
5
+ import { LLM_PROFILE_VALUE_VERSION } from './llmProfileTypes.js';
6
+ export function resolveLLMProfileNodeValue(params) {
7
+ const { data, inputs, context } = params;
8
+ const runtimeData = data;
9
+ const generation = resolveLLMChatV2GenerationParameters(runtimeData, inputs);
10
+ const headers = resolveLLMChatV2Headers(runtimeData, inputs);
11
+ const extraProviderOptions = resolveLLMChatV2ExtraProviderOptions(runtimeData, inputs);
12
+ const model = getInputOrData(runtimeData, inputs, 'model', 'string')?.trim();
13
+ if (!model) {
14
+ throw new Error('LLM Profile model must be a non-empty string.');
15
+ }
16
+ const customProviderBaseURL = data.provider === 'custom'
17
+ ? getInputOrData(runtimeData, inputs, 'customProviderBaseURL', 'string', 'useCustomProviderBaseURLInput')?.trim() ?? ''
18
+ : '';
19
+ const openAIPreviousResponseId = data.provider === 'openai' && data.useOpenAIPreviousResponseIdInput
20
+ ? coerceTypeOptional(inputs['previousResponseId'], 'string') ?? data.openAIPreviousResponseId ?? ''
21
+ : data.openAIPreviousResponseId ?? '';
22
+ const anthropicThinkingBudget = data.provider === 'anthropic' && data.useAnthropicThinkingBudgetInput
23
+ ? coerceTypeOptional(inputs['anthropicThinkingBudget'], 'number') ?? data.anthropicThinkingBudget
24
+ : data.anthropicThinkingBudget;
25
+ const googleThinkingBudget = data.provider === 'google' && data.useGoogleThinkingBudgetInput
26
+ ? coerceTypeOptional(inputs['googleThinkingBudget'], 'number') ?? data.googleThinkingBudget
27
+ : data.googleThinkingBudget;
28
+ const credential = resolveChatV2Credential({
29
+ provider: data.provider,
30
+ context,
31
+ apiKeySource: data.apiKeySource === 'input' ? 'input' : 'configured',
32
+ inputs,
33
+ customProgrammaticName: data.customProviderApiKeyProgrammaticName,
34
+ customEnvironmentName: data.customProviderApiKeyEnvVarName,
35
+ });
36
+ return {
37
+ version: LLM_PROFILE_VALUE_VERSION,
38
+ credential,
39
+ configuration: {
40
+ ...data,
41
+ model,
42
+ useModelInput: false,
43
+ temperature: generation.temperature ?? data.temperature,
44
+ useTemperatureInput: false,
45
+ maxTokens: generation.maxTokens ?? data.maxTokens,
46
+ useMaxTokensInput: false,
47
+ topP: generation.topP,
48
+ useTopPInput: false,
49
+ topK: generation.topK,
50
+ useTopKInput: false,
51
+ presencePenalty: generation.presencePenalty,
52
+ usePresencePenaltyInput: false,
53
+ frequencyPenalty: generation.frequencyPenalty,
54
+ useFrequencyPenaltyInput: false,
55
+ stopSequences: generation.stopSequences ?? [],
56
+ useStopSequencesInput: false,
57
+ seed: generation.seed,
58
+ useSeedInput: false,
59
+ customProviderBaseURL,
60
+ useCustomProviderBaseURLInput: false,
61
+ openAIPreviousResponseId,
62
+ useOpenAIPreviousResponseIdInput: false,
63
+ headers: Object.entries(headers ?? {}).map(([key, value]) => ({ key, value })),
64
+ useHeadersInput: false,
65
+ extraProviderOptions: extraProviderOptions == null ? '' : JSON.stringify(extraProviderOptions),
66
+ useExtraProviderOptionsInput: false,
67
+ anthropicThinkingBudget,
68
+ useAnthropicThinkingBudgetInput: false,
69
+ googleThinkingBudget,
70
+ useGoogleThinkingBudgetInput: false,
71
+ },
72
+ };
73
+ }
@@ -0,0 +1,45 @@
1
+ import { createLLMChatV2NodeData, llmChatV2ProfileDataKeys, } from './llmChatV2NodeData.js';
2
+ export const LLM_PROFILE_VALUE_VERSION = 1;
3
+ /**
4
+ * Every input port owned by an LLM Profile, including ports that are hidden
5
+ * until their matching provider or input toggle is enabled. This lets editor
6
+ * operations preserve recoverable connections across configuration changes.
7
+ */
8
+ export const llmProfileInputIds = [
9
+ 'model',
10
+ 'apiKey',
11
+ 'customProviderBaseURL',
12
+ 'previousResponseId',
13
+ 'temperature',
14
+ 'maxTokens',
15
+ 'topP',
16
+ 'topK',
17
+ 'presencePenalty',
18
+ 'frequencyPenalty',
19
+ 'stopSequences',
20
+ 'seed',
21
+ 'headers',
22
+ 'extraProviderOptions',
23
+ 'anthropicThinkingBudget',
24
+ 'googleThinkingBudget',
25
+ ];
26
+ export function createLLMProfileNodeData() {
27
+ return pickLLMChatV2ProfileData(createLLMChatV2NodeData());
28
+ }
29
+ export function createDefaultLLMProfileValue() {
30
+ return {
31
+ version: LLM_PROFILE_VALUE_VERSION,
32
+ configuration: createLLMProfileNodeData(),
33
+ credential: { reference: { source: 'none' } },
34
+ };
35
+ }
36
+ export function pickLLMChatV2ProfileData(data) {
37
+ return Object.fromEntries(llmChatV2ProfileDataKeys.map((key) => [key, data[key]]));
38
+ }
39
+ export function applyLLMProfileToNodeData(data, profile) {
40
+ return {
41
+ ...data,
42
+ ...profile.configuration,
43
+ configurationMode: 'profile',
44
+ };
45
+ }
@@ -0,0 +1,81 @@
1
+ import { NodeImpl } from '../NodeImpl.js';
2
+ import { nodeDefinition } from '../NodeDefinition.js';
3
+ import {} from '../NodeBase.js';
4
+ import { nanoid } from 'nanoid/non-secure';
5
+ import {} from '../GraphProcessor.js';
6
+ import { dedent } from 'ts-dedent';
7
+ import { getDataBusInputPortId, getDataBusOutputPortId, MAX_DATA_BUS_CHANNEL_INDEX, parseDataBusChannelIndex, } from '../DataBusPorts.js';
8
+ export { getDataBusInputPortId, getDataBusOutputPortId, MAX_DATA_BUS_CHANNEL_INDEX, parseDataBusChannelIndex, } from '../DataBusPorts.js';
9
+ function getConnectedChannelIndices(connections, nodeId) {
10
+ const channelIndices = new Set();
11
+ for (const connection of connections) {
12
+ const inputIndex = connection.inputNodeId === nodeId ? parseDataBusChannelIndex(connection.inputId, true) : undefined;
13
+ const outputIndex = connection.outputNodeId === nodeId ? parseDataBusChannelIndex(connection.outputId, false) : undefined;
14
+ if (inputIndex != null) {
15
+ channelIndices.add(inputIndex);
16
+ }
17
+ if (outputIndex != null) {
18
+ channelIndices.add(outputIndex);
19
+ }
20
+ }
21
+ return [...channelIndices].sort((left, right) => left - right);
22
+ }
23
+ function getFirstAvailableChannelIndex(connectedChannelIndices) {
24
+ let availableIndex = 1;
25
+ for (const channelIndex of connectedChannelIndices) {
26
+ if (channelIndex !== availableIndex) {
27
+ break;
28
+ }
29
+ availableIndex += 1;
30
+ }
31
+ return availableIndex <= MAX_DATA_BUS_CHANNEL_INDEX ? availableIndex : undefined;
32
+ }
33
+ export function isDataBusNode(node) {
34
+ return node?.type === 'dataBus';
35
+ }
36
+ export class DataBusNodeImpl extends NodeImpl {
37
+ static create = () => ({
38
+ type: 'dataBus',
39
+ title: 'Data Bus',
40
+ id: nanoid(),
41
+ data: {},
42
+ visualData: {
43
+ x: 0,
44
+ y: 0,
45
+ width: 175,
46
+ },
47
+ });
48
+ getInputDefinitions(connections) {
49
+ const connectedChannelIndices = getConnectedChannelIndices(connections, this.chartNode.id);
50
+ const availableChannelIndex = getFirstAvailableChannelIndex(connectedChannelIndices);
51
+ const channelIndices = availableChannelIndex == null ? connectedChannelIndices : [...connectedChannelIndices, availableChannelIndex];
52
+ return channelIndices.map((channelIndex) => ({
53
+ dataType: 'any',
54
+ id: getDataBusInputPortId(channelIndex),
55
+ title: `Input ${channelIndex}`,
56
+ }));
57
+ }
58
+ getOutputDefinitions(connections) {
59
+ const connectedChannelIndices = getConnectedChannelIndices(connections, this.chartNode.id);
60
+ return connectedChannelIndices.map((channelIndex) => ({
61
+ dataType: 'any',
62
+ id: getDataBusOutputPortId(channelIndex),
63
+ title: `Output ${channelIndex}`,
64
+ }));
65
+ }
66
+ static getUIData() {
67
+ return {
68
+ infoBoxBody: dedent `
69
+ Organizes independent connections in a compact rail at the top of the
70
+ canvas. Data Bus channels are wiring topology, not executable nodes.
71
+ `,
72
+ infoBoxTitle: 'Data Bus',
73
+ contextMenuTitle: 'Data Bus',
74
+ group: ['Logic'],
75
+ };
76
+ }
77
+ async process(_inputData) {
78
+ throw new Error('Data Bus nodes are topology-only and must be compiled out before graph execution.');
79
+ }
80
+ }
81
+ export const dataBusNode = nodeDefinition(DataBusNodeImpl, 'Data Bus');
@@ -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,7 +4,7 @@ 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
9
  import { getChatV2ModelInfo } from '../chat-v2/modelRegistry.js';
10
10
  import { buildLLMChatV2EditorCacheKey, cloneLLMChatV2EditorCacheOutputs, resolveLLMChatV2RuntimeConfig, resolveLLMChatV2RuntimeProviderOptions, } from '../chat-v2/llmChatV2NodeRuntime.js';
@@ -87,10 +87,33 @@ export class LLMChatV2NodeImpl extends NodeImpl {
87
87
  };
88
88
  }
89
89
  getInputDefinitions() {
90
- const inputs = getCommonChatV2Inputs(this.data, {
90
+ const usesProfile = this.data.configurationMode === 'profile';
91
+ const commonInputData = usesProfile
92
+ ? {
93
+ ...this.data,
94
+ useModelInput: false,
95
+ useTemperatureInput: false,
96
+ useTopPInput: false,
97
+ useTopKInput: false,
98
+ usePresencePenaltyInput: false,
99
+ useFrequencyPenaltyInput: false,
100
+ useStopSequencesInput: false,
101
+ useSeedInput: false,
102
+ useMaxTokensInput: false,
103
+ }
104
+ : this.data;
105
+ const inputs = getCommonChatV2Inputs(commonInputData, {
91
106
  includeFunctions: this.data.useToolCalling,
92
107
  });
93
- if (this.data.apiKeySource === 'input') {
108
+ if (usesProfile) {
109
+ inputs.unshift({
110
+ id: 'llmProfile',
111
+ title: 'LLM Profile',
112
+ dataType: 'llm-config',
113
+ required: true,
114
+ });
115
+ }
116
+ if (!usesProfile && this.data.apiKeySource === 'input') {
94
117
  inputs.push({
95
118
  id: 'apiKey',
96
119
  title: 'API Key',
@@ -98,7 +121,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
98
121
  required: false,
99
122
  });
100
123
  }
101
- if (usesBaseURLInput(this.data)) {
124
+ if (!usesProfile && usesBaseURLInput(this.data)) {
102
125
  inputs.unshift({
103
126
  id: 'customProviderBaseURL',
104
127
  title: 'Provider base URL',
@@ -106,7 +129,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
106
129
  required: false,
107
130
  });
108
131
  }
109
- if (this.data.useHeadersInput) {
132
+ if (!usesProfile && this.data.useHeadersInput) {
110
133
  inputs.push({
111
134
  id: 'headers',
112
135
  title: 'Headers',
@@ -114,7 +137,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
114
137
  required: false,
115
138
  });
116
139
  }
117
- if (this.data.useExtraProviderOptionsInput) {
140
+ if (!usesProfile && this.data.useExtraProviderOptionsInput) {
118
141
  inputs.push({
119
142
  id: 'extraProviderOptions',
120
143
  title: 'Extra Provider Options',
@@ -123,7 +146,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
123
146
  coerced: true,
124
147
  });
125
148
  }
126
- if (this.data.provider === 'openai' && this.data.useOpenAIPreviousResponseIdInput) {
149
+ if (!usesProfile && this.data.useOpenAIPreviousResponseIdInput && this.data.provider === 'openai') {
127
150
  inputs.push({
128
151
  id: 'previousResponseId',
129
152
  title: 'Previous Response ID',
@@ -131,7 +154,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
131
154
  required: false,
132
155
  });
133
156
  }
134
- if (this.data.provider === 'anthropic' && this.data.useAnthropicThinkingBudgetInput) {
157
+ if (!usesProfile && this.data.provider === 'anthropic' && this.data.useAnthropicThinkingBudgetInput) {
135
158
  inputs.push({
136
159
  id: 'anthropicThinkingBudget',
137
160
  title: 'Thinking Budget',
@@ -139,7 +162,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
139
162
  required: false,
140
163
  });
141
164
  }
142
- if (this.data.provider === 'google' && this.data.useGoogleThinkingBudgetInput) {
165
+ if (!usesProfile && this.data.provider === 'google' && this.data.useGoogleThinkingBudgetInput) {
143
166
  inputs.push({
144
167
  id: 'googleThinkingBudget',
145
168
  title: 'Thinking Budget',
@@ -178,7 +201,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
178
201
  }
179
202
  getOutputDefinitions() {
180
203
  const outputs = getCommonChatV2Outputs(this.data, {
181
- includeFunctionCalls: this.data.useToolCalling || hasLLMChatV2BuiltInToolsEnabled(this.data),
204
+ includeFunctionCalls: shouldIncludeLLMChatV2ToolCalls(this.data),
182
205
  includeUsage: this.data.outputUsage,
183
206
  includeReasoning: this.data.outputReasoning,
184
207
  });
@@ -231,6 +254,17 @@ export class LLMChatV2NodeImpl extends NodeImpl {
231
254
  return getLLMChatV2Editors(this.data, context);
232
255
  }
233
256
  getBody() {
257
+ if (this.data.configurationMode === 'profile') {
258
+ return {
259
+ type: 'markdown',
260
+ disableLinks: true,
261
+ text: [
262
+ getBodyLine('Configuration', 'From LLM Profile input'),
263
+ ...(this.data.useToolCalling ? [getBodyLine('Tools', 'Enabled')] : []),
264
+ ...(this.data.responseFormat ? [getBodyLine('Response format', this.data.responseFormat)] : []),
265
+ ].join('\n'),
266
+ };
267
+ }
234
268
  const modelInfo = getChatV2ModelInfo(this.data.provider, this.data.model);
235
269
  const providerLabel = getProviderBodyLabel(this.data);
236
270
  const baseURLValue = getCustomProviderBaseURLBodyValue(this.data);
@@ -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');
@@ -4,7 +4,24 @@ import {} from '../NodeBase.js';
4
4
  import { nanoid } from 'nanoid/non-secure';
5
5
  import {} from '../GraphProcessor.js';
6
6
  import { dedent } from 'ts-dedent';
7
- import { getNextVariadicPortIndex } from './variadicPortIndex.js';
7
+ const INPUT_PORT_PATTERN = /^input(\d+)$/;
8
+ const OUTPUT_PORT_PATTERN = /^output(\d+)$/;
9
+ /** @deprecated Use MAX_DATA_BUS_CHANNEL_INDEX for Data Bus channels. */
10
+ export const MAX_PASSTHROUGH_PORT_INDEX = 10_000;
11
+ function parsePositivePortIndex(portId, pattern) {
12
+ const match = pattern.exec(portId);
13
+ const index = match ? Number(match[1]) : Number.NaN;
14
+ return Number.isSafeInteger(index) && index > 0 && index <= MAX_PASSTHROUGH_PORT_INDEX ? index : undefined;
15
+ }
16
+ function getHighestConnectedSlotIndex(connections, nodeId) {
17
+ let highestIndex = 0;
18
+ for (const connection of connections) {
19
+ const inputIndex = connection.inputNodeId === nodeId ? parsePositivePortIndex(connection.inputId, INPUT_PORT_PATTERN) : undefined;
20
+ const outputIndex = connection.outputNodeId === nodeId ? parsePositivePortIndex(connection.outputId, OUTPUT_PORT_PATTERN) : undefined;
21
+ highestIndex = Math.max(highestIndex, inputIndex ?? 0, outputIndex ?? 0);
22
+ }
23
+ return highestIndex;
24
+ }
8
25
  export class PassthroughNodeImpl extends NodeImpl {
9
26
  static create = () => {
10
27
  const chartNode = {
@@ -22,7 +39,7 @@ export class PassthroughNodeImpl extends NodeImpl {
22
39
  };
23
40
  getInputDefinitions(connections) {
24
41
  const inputs = [];
25
- const inputCount = getNextVariadicPortIndex(connections, this.chartNode.id, 'input', 'decimal');
42
+ const inputCount = Math.min(getHighestConnectedSlotIndex(connections, this.chartNode.id) + 1, MAX_PASSTHROUGH_PORT_INDEX);
26
43
  for (let i = 1; i <= inputCount; i++) {
27
44
  inputs.push({
28
45
  dataType: 'any',
@@ -34,8 +51,8 @@ export class PassthroughNodeImpl extends NodeImpl {
34
51
  }
35
52
  getOutputDefinitions(connections) {
36
53
  const outputs = [];
37
- const inputCount = getNextVariadicPortIndex(connections, this.chartNode.id, 'input', 'decimal');
38
- for (let i = 1; i <= inputCount - 1; i++) {
54
+ const outputCount = getHighestConnectedSlotIndex(connections, this.chartNode.id);
55
+ for (let i = 1; i <= outputCount; i++) {
39
56
  outputs.push({
40
57
  dataType: 'any',
41
58
  id: `output${i}`,
@@ -55,11 +72,12 @@ export class PassthroughNodeImpl extends NodeImpl {
55
72
  };
56
73
  }
57
74
  async process(inputData) {
58
- const inputCount = Object.keys(inputData).filter((key) => key.startsWith('input')).length;
59
75
  const outputs = {};
60
- for (let i = 1; i <= inputCount; i++) {
61
- const input = inputData[`input${i}`];
62
- outputs[`output${i}`] = input;
76
+ for (const [portId, input] of Object.entries(inputData)) {
77
+ const index = parsePositivePortIndex(portId, INPUT_PORT_PATTERN);
78
+ if (index != null) {
79
+ outputs[`output${index}`] = input;
80
+ }
63
81
  }
64
82
  return outputs;
65
83
  }
@@ -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;
@@ -123,8 +135,7 @@ export async function delegateToolCall(rawFunctionCall, context, config) {
123
135
  let handler;
124
136
  if (config.autoDelegate) {
125
137
  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));
138
+ const matchingGraph = findAutoDelegateGraphCandidate(graphs, functionCall.name, (graph) => graph.metadata?.name);
128
139
  if (matchingGraph) {
129
140
  handler = { key: undefined, value: matchingGraph.metadata.id };
130
141
  }
@@ -100,10 +100,6 @@ class PineconeKnowledgeStoreDriver {
100
100
  const records = chunks.map((chunk) => this.#chunkRecord(sourceId, version, chunk));
101
101
  const batches = batchNdjson(records, 32, 1_500_000);
102
102
  for (let index = 0; index < batches.length; index += 1) {
103
- context.reportProgress?.({
104
- message: `Uploading knowledge batch ${index + 1} of ${batches.length}.`,
105
- percent: 15 + Math.round(((index + 1) / batches.length) * 70),
106
- });
107
103
  const response = await this.#request(`${this.config.indexHost}/records/namespaces/${encodeURIComponent(namespace)}/upsert`, { method: 'POST', body: batches[index], headers: { 'Content-Type': 'application/x-ndjson' } }, context);
108
104
  await response.text();
109
105
  }