@valerypopoff/rivet2-core 2.1.2 → 2.1.3
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.
- package/dist/cjs/bundle.cjs +904 -434
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/esm/api/processSettings.js +5 -0
- package/dist/esm/exports.js +2 -0
- package/dist/esm/model/GraphProcessor.js +24 -45
- package/dist/esm/model/GraphRunLifecycle.js +67 -0
- package/dist/esm/model/MarkdownSanitizationPolicy.js +38 -0
- package/dist/esm/model/UiGraph.js +57 -0
- package/dist/esm/model/UiGraphRendererStyles.js +82 -0
- package/dist/esm/model/UiGraphRuntimeModel.js +71 -0
- package/dist/esm/model/chat-v2/aiSdkBridge.js +1 -1
- package/dist/esm/model/chat-v2/chatV2EditorCache.js +2 -2
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +35 -48
- package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +98 -0
- package/dist/esm/model/chat-v2/chatV2RequestPlan.js +64 -0
- package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +11 -39
- package/dist/esm/model/chat-v2/index.js +2 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeData.js +1 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +31 -11
- package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +21 -9
- package/dist/esm/model/chat-v2/providerOptions.js +9 -35
- package/dist/esm/model/nodes/LLMChatV2Node.js +3 -3
- package/dist/esm/plugins/autoevals/AutoEvalsNode.js +3 -1
- package/dist/esm/plugins/gentrace/gentraceSdk.js +8 -0
- package/dist/esm/plugins/gentrace/plugin.js +5 -4
- package/dist/esm/plugins/google/google.js +9 -7
- package/dist/esm/utils/pQueueCompat.js +1 -1
- package/dist/esm/utils/serialization/serializationUtils.js +35 -0
- package/dist/esm/utils/serialization/serialization_v4.js +5 -4
- package/dist/esm/webAppRuntime.js +2 -0
- package/dist/types/api/createProcessor.d.ts +1 -1
- package/dist/types/api/processSettings.d.ts +3 -4
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/model/GraphRunLifecycle.d.ts +22 -0
- package/dist/types/model/MarkdownSanitizationPolicy.d.ts +9 -0
- package/dist/types/model/ProcessContext.d.ts +2 -2
- package/dist/types/model/Settings.d.ts +1 -0
- package/dist/types/model/UiGraph.d.ts +12 -0
- package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
- package/dist/types/model/UiGraphRuntimeModel.d.ts +52 -0
- package/dist/types/model/chat-v2/chatV2ProviderProfile.d.ts +46 -0
- package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +42 -0
- package/dist/types/model/chat-v2/chatV2Types.d.ts +1 -0
- package/dist/types/model/chat-v2/index.d.ts +2 -0
- package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +1 -0
- package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +2 -0
- package/dist/types/model/chat-v2/providerOptions.d.ts +2 -2
- package/dist/types/plugins/gentrace/gentraceSdk.d.ts +5 -0
- package/dist/types/plugins/gentrace/plugin.d.ts +1 -1
- package/dist/types/utils/pQueueCompat.d.ts +1 -1
- package/dist/types/webAppRuntime.d.ts +4 -0
- package/package.json +15 -9
package/dist/cjs/bundle.cjs
CHANGED
|
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
33
|
AbortGraphNodeImpl: () => AbortGraphNodeImpl,
|
|
34
34
|
AppendToDatasetNodeImpl: () => AppendToDatasetNodeImpl,
|
|
35
35
|
ArrayNodeImpl: () => ArrayNodeImpl,
|
|
@@ -118,6 +118,10 @@ __export(src_exports, {
|
|
|
118
118
|
PluginNodeImplClass: () => PluginNodeImplClass,
|
|
119
119
|
PopNodeImpl: () => PopNodeImpl,
|
|
120
120
|
PromptNodeImpl: () => PromptNodeImpl,
|
|
121
|
+
RIVET_MARKDOWN_ALLOWED_ATTRIBUTES: () => RIVET_MARKDOWN_ALLOWED_ATTRIBUTES,
|
|
122
|
+
RIVET_MARKDOWN_ALLOWED_TAGS: () => RIVET_MARKDOWN_ALLOWED_TAGS,
|
|
123
|
+
RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE: () => RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE,
|
|
124
|
+
RIVET_MARKDOWN_SANITIZER_POLICY: () => RIVET_MARKDOWN_SANITIZER_POLICY,
|
|
121
125
|
RIVET_WEB_APP_DOCUMENT_CSS: () => RIVET_WEB_APP_DOCUMENT_CSS,
|
|
122
126
|
RIVET_WEB_APP_RENDERER_CSS: () => RIVET_WEB_APP_RENDERER_CSS,
|
|
123
127
|
RaceInputsNodeImpl: () => RaceInputsNodeImpl,
|
|
@@ -153,6 +157,7 @@ __export(src_exports, {
|
|
|
153
157
|
anthropicPlugin: () => anthropic_default,
|
|
154
158
|
anthropicThinkingModeOptions: () => anthropicThinkingModeOptions,
|
|
155
159
|
appendToDatasetNode: () => appendToDatasetNode,
|
|
160
|
+
applyUiGraphStatePatch: () => applyUiGraphStatePatch,
|
|
156
161
|
arrayNode: () => arrayNode,
|
|
157
162
|
arrayTypeToScalarType: () => arrayTypeToScalarType,
|
|
158
163
|
arrayizeDataValue: () => arrayizeDataValue,
|
|
@@ -166,6 +171,7 @@ __export(src_exports, {
|
|
|
166
171
|
base64ToUint8Array: () => base64ToUint8Array,
|
|
167
172
|
baseDirs: () => baseDirs,
|
|
168
173
|
booleanNode: () => booleanNode,
|
|
174
|
+
buildChatV2RequestPlan: () => buildChatV2RequestPlan,
|
|
169
175
|
buildLLMChatV2EditorCacheKey: () => buildLLMChatV2EditorCacheKey,
|
|
170
176
|
buildLegacyOrderedPortIds: () => buildLegacyOrderedPortIds,
|
|
171
177
|
calculateChatV2Cost: () => calculateChatV2Cost,
|
|
@@ -206,6 +212,7 @@ __export(src_exports, {
|
|
|
206
212
|
createDefaultUiGraph: () => createDefaultUiGraph,
|
|
207
213
|
createFrozenNodeOutputResolver: () => createFrozenNodeOutputResolver,
|
|
208
214
|
createInterpolationInputDefinition: () => createInterpolationInputDefinition,
|
|
215
|
+
createResolvedChatV2Provider: () => createResolvedChatV2Provider,
|
|
209
216
|
createsLLMChatV2ToolResponseFormatConflictForEdit: () => createsLLMChatV2ToolResponseFormatConflictForEdit,
|
|
210
217
|
cronNode: () => cronNode,
|
|
211
218
|
dataTypeDisplayNames: () => dataTypeDisplayNames,
|
|
@@ -237,6 +244,7 @@ __export(src_exports, {
|
|
|
237
244
|
extractYamlNode: () => extractYamlNode,
|
|
238
245
|
filterNode: () => filterNode,
|
|
239
246
|
findInterpolationTokenSpans: () => findInterpolationTokenSpans,
|
|
247
|
+
formatUiGraphDownloadDateTime: () => formatUiGraphDownloadDateTime,
|
|
240
248
|
functionTypeToScalarType: () => functionTypeToScalarType,
|
|
241
249
|
generateChatV2: () => generateChatV2,
|
|
242
250
|
gentracePlugin: () => gentrace_default,
|
|
@@ -275,7 +283,12 @@ __export(src_exports, {
|
|
|
275
283
|
getUiGraphActionComponent: () => getUiGraphActionComponent,
|
|
276
284
|
getUiGraphActionInputBindings: () => getUiGraphActionInputBindings,
|
|
277
285
|
getUiGraphActionOutputBindings: () => getUiGraphActionOutputBindings,
|
|
286
|
+
getUiGraphActionState: () => getUiGraphActionState,
|
|
287
|
+
getUiGraphComponentLabel: () => getUiGraphComponentLabel,
|
|
288
|
+
getUiGraphComponentRenderModel: () => getUiGraphComponentRenderModel,
|
|
278
289
|
getUiGraphInitialState: () => getUiGraphInitialState,
|
|
290
|
+
getUiGraphJsonOutputFilename: () => getUiGraphJsonOutputFilename,
|
|
291
|
+
getUiGraphOutputRenderModel: () => getUiGraphOutputRenderModel,
|
|
279
292
|
getWarnings: () => getWarnings,
|
|
280
293
|
globalRivetNodeRegistry: () => globalRivetNodeRegistry,
|
|
281
294
|
googlePlugin: () => googlePlugin,
|
|
@@ -287,7 +300,9 @@ __export(src_exports, {
|
|
|
287
300
|
handleEscapeCharacters: () => handleEscapeCharacters,
|
|
288
301
|
hasFrozenNodeOutputs: () => hasFrozenNodeOutputs,
|
|
289
302
|
hasLLMChatV2ToolResponseFormatConflict: () => hasLLMChatV2ToolResponseFormatConflict,
|
|
303
|
+
hasUiGraphStateValue: () => hasUiGraphStateValue,
|
|
290
304
|
hasValidStoredOrderedPortIds: () => hasValidStoredOrderedPortIds,
|
|
305
|
+
hasValidUiGraphComponentIds: () => hasValidUiGraphComponentIds,
|
|
291
306
|
hashNode: () => hashNode,
|
|
292
307
|
httpCallNode: () => httpCallNode,
|
|
293
308
|
huggingFacePlugin: () => huggingFacePlugin,
|
|
@@ -341,6 +356,7 @@ __export(src_exports, {
|
|
|
341
356
|
newId: () => newId,
|
|
342
357
|
nodeDefinition: () => nodeDefinition,
|
|
343
358
|
nodePrefabInstanceNode: () => nodePrefabInstanceNode,
|
|
359
|
+
normalizeUiGraphComponentIds: () => normalizeUiGraphComponentIds,
|
|
344
360
|
numberNode: () => numberNode,
|
|
345
361
|
objectNode: () => objectNode,
|
|
346
362
|
openAICompatibleEndpointToBaseURL: () => openAICompatibleEndpointToBaseURL,
|
|
@@ -367,10 +383,12 @@ __export(src_exports, {
|
|
|
367
383
|
registerBuiltInNodes: () => registerBuiltInNodes,
|
|
368
384
|
registerIntegration: () => registerIntegration,
|
|
369
385
|
registerPluginsIntoRegistry: () => registerPluginsIntoRegistry,
|
|
386
|
+
renderUiGraphOutputValue: () => renderUiGraphOutputValue,
|
|
370
387
|
replaceDatasetNode: () => replaceDatasetNode,
|
|
371
388
|
replaceGlobalRivetNodeRegistry: () => replaceGlobalRivetNodeRegistry,
|
|
372
389
|
resetGlobalRivetNodeRegistry: () => resetGlobalRivetNodeRegistry,
|
|
373
390
|
resolveBuiltInPlugin: () => resolveBuiltInPlugin,
|
|
391
|
+
resolveChatV2Credential: () => resolveChatV2Credential,
|
|
374
392
|
resolveChatV2ProviderConfig: () => resolveChatV2ProviderConfig,
|
|
375
393
|
resolveChatV2ResponseFormatParameters: () => resolveChatV2ResponseFormatParameters,
|
|
376
394
|
resolveLLMChatV2RuntimeProviderOptions: () => resolveLLMChatV2RuntimeProviderOptions,
|
|
@@ -397,7 +415,9 @@ __export(src_exports, {
|
|
|
397
415
|
sliceNode: () => sliceNode,
|
|
398
416
|
splitNode: () => splitNode,
|
|
399
417
|
streamChatV2: () => streamChatV2,
|
|
418
|
+
stringifyUiGraphValue: () => stringifyUiGraphValue,
|
|
400
419
|
subGraphNode: () => subGraphNode,
|
|
420
|
+
summarizeChatV2RequestPlan: () => summarizeChatV2RequestPlan,
|
|
401
421
|
summarizeDataValueForLog: () => summarizeDataValueForLog,
|
|
402
422
|
summarizeErrorForLog: () => summarizeErrorForLog,
|
|
403
423
|
summarizePortMapForLog: () => summarizePortMapForLog,
|
|
@@ -419,7 +439,7 @@ __export(src_exports, {
|
|
|
419
439
|
waitForEventNode: () => waitForEventNode,
|
|
420
440
|
yamlProblem: () => yamlProblem
|
|
421
441
|
});
|
|
422
|
-
module.exports = __toCommonJS(
|
|
442
|
+
module.exports = __toCommonJS(index_exports);
|
|
423
443
|
|
|
424
444
|
// src/exports.ts
|
|
425
445
|
var exports_exports = {};
|
|
@@ -512,6 +532,10 @@ __export(exports_exports, {
|
|
|
512
532
|
PluginNodeImplClass: () => PluginNodeImplClass,
|
|
513
533
|
PopNodeImpl: () => PopNodeImpl,
|
|
514
534
|
PromptNodeImpl: () => PromptNodeImpl,
|
|
535
|
+
RIVET_MARKDOWN_ALLOWED_ATTRIBUTES: () => RIVET_MARKDOWN_ALLOWED_ATTRIBUTES,
|
|
536
|
+
RIVET_MARKDOWN_ALLOWED_TAGS: () => RIVET_MARKDOWN_ALLOWED_TAGS,
|
|
537
|
+
RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE: () => RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE,
|
|
538
|
+
RIVET_MARKDOWN_SANITIZER_POLICY: () => RIVET_MARKDOWN_SANITIZER_POLICY,
|
|
515
539
|
RIVET_WEB_APP_DOCUMENT_CSS: () => RIVET_WEB_APP_DOCUMENT_CSS,
|
|
516
540
|
RIVET_WEB_APP_RENDERER_CSS: () => RIVET_WEB_APP_RENDERER_CSS,
|
|
517
541
|
RaceInputsNodeImpl: () => RaceInputsNodeImpl,
|
|
@@ -546,6 +570,7 @@ __export(exports_exports, {
|
|
|
546
570
|
anthropicPlugin: () => anthropic_default,
|
|
547
571
|
anthropicThinkingModeOptions: () => anthropicThinkingModeOptions,
|
|
548
572
|
appendToDatasetNode: () => appendToDatasetNode,
|
|
573
|
+
applyUiGraphStatePatch: () => applyUiGraphStatePatch,
|
|
549
574
|
arrayNode: () => arrayNode,
|
|
550
575
|
arrayTypeToScalarType: () => arrayTypeToScalarType,
|
|
551
576
|
arrayizeDataValue: () => arrayizeDataValue,
|
|
@@ -559,6 +584,7 @@ __export(exports_exports, {
|
|
|
559
584
|
base64ToUint8Array: () => base64ToUint8Array,
|
|
560
585
|
baseDirs: () => baseDirs,
|
|
561
586
|
booleanNode: () => booleanNode,
|
|
587
|
+
buildChatV2RequestPlan: () => buildChatV2RequestPlan,
|
|
562
588
|
buildLLMChatV2EditorCacheKey: () => buildLLMChatV2EditorCacheKey,
|
|
563
589
|
buildLegacyOrderedPortIds: () => buildLegacyOrderedPortIds,
|
|
564
590
|
calculateChatV2Cost: () => calculateChatV2Cost,
|
|
@@ -599,6 +625,7 @@ __export(exports_exports, {
|
|
|
599
625
|
createDefaultUiGraph: () => createDefaultUiGraph,
|
|
600
626
|
createFrozenNodeOutputResolver: () => createFrozenNodeOutputResolver,
|
|
601
627
|
createInterpolationInputDefinition: () => createInterpolationInputDefinition,
|
|
628
|
+
createResolvedChatV2Provider: () => createResolvedChatV2Provider,
|
|
602
629
|
createsLLMChatV2ToolResponseFormatConflictForEdit: () => createsLLMChatV2ToolResponseFormatConflictForEdit,
|
|
603
630
|
cronNode: () => cronNode,
|
|
604
631
|
dataTypeDisplayNames: () => dataTypeDisplayNames,
|
|
@@ -630,6 +657,7 @@ __export(exports_exports, {
|
|
|
630
657
|
extractYamlNode: () => extractYamlNode,
|
|
631
658
|
filterNode: () => filterNode,
|
|
632
659
|
findInterpolationTokenSpans: () => findInterpolationTokenSpans,
|
|
660
|
+
formatUiGraphDownloadDateTime: () => formatUiGraphDownloadDateTime,
|
|
633
661
|
functionTypeToScalarType: () => functionTypeToScalarType,
|
|
634
662
|
generateChatV2: () => generateChatV2,
|
|
635
663
|
gentracePlugin: () => gentrace_default,
|
|
@@ -668,7 +696,12 @@ __export(exports_exports, {
|
|
|
668
696
|
getUiGraphActionComponent: () => getUiGraphActionComponent,
|
|
669
697
|
getUiGraphActionInputBindings: () => getUiGraphActionInputBindings,
|
|
670
698
|
getUiGraphActionOutputBindings: () => getUiGraphActionOutputBindings,
|
|
699
|
+
getUiGraphActionState: () => getUiGraphActionState,
|
|
700
|
+
getUiGraphComponentLabel: () => getUiGraphComponentLabel,
|
|
701
|
+
getUiGraphComponentRenderModel: () => getUiGraphComponentRenderModel,
|
|
671
702
|
getUiGraphInitialState: () => getUiGraphInitialState,
|
|
703
|
+
getUiGraphJsonOutputFilename: () => getUiGraphJsonOutputFilename,
|
|
704
|
+
getUiGraphOutputRenderModel: () => getUiGraphOutputRenderModel,
|
|
672
705
|
getWarnings: () => getWarnings,
|
|
673
706
|
globalRivetNodeRegistry: () => globalRivetNodeRegistry,
|
|
674
707
|
googlePlugin: () => googlePlugin,
|
|
@@ -680,7 +713,9 @@ __export(exports_exports, {
|
|
|
680
713
|
handleEscapeCharacters: () => handleEscapeCharacters,
|
|
681
714
|
hasFrozenNodeOutputs: () => hasFrozenNodeOutputs,
|
|
682
715
|
hasLLMChatV2ToolResponseFormatConflict: () => hasLLMChatV2ToolResponseFormatConflict,
|
|
716
|
+
hasUiGraphStateValue: () => hasUiGraphStateValue,
|
|
683
717
|
hasValidStoredOrderedPortIds: () => hasValidStoredOrderedPortIds,
|
|
718
|
+
hasValidUiGraphComponentIds: () => hasValidUiGraphComponentIds,
|
|
684
719
|
hashNode: () => hashNode,
|
|
685
720
|
httpCallNode: () => httpCallNode,
|
|
686
721
|
huggingFacePlugin: () => huggingFacePlugin,
|
|
@@ -734,6 +769,7 @@ __export(exports_exports, {
|
|
|
734
769
|
newId: () => newId,
|
|
735
770
|
nodeDefinition: () => nodeDefinition,
|
|
736
771
|
nodePrefabInstanceNode: () => nodePrefabInstanceNode,
|
|
772
|
+
normalizeUiGraphComponentIds: () => normalizeUiGraphComponentIds,
|
|
737
773
|
numberNode: () => numberNode,
|
|
738
774
|
objectNode: () => objectNode,
|
|
739
775
|
openAICompatibleEndpointToBaseURL: () => openAICompatibleEndpointToBaseURL,
|
|
@@ -760,10 +796,12 @@ __export(exports_exports, {
|
|
|
760
796
|
registerBuiltInNodes: () => registerBuiltInNodes,
|
|
761
797
|
registerIntegration: () => registerIntegration,
|
|
762
798
|
registerPluginsIntoRegistry: () => registerPluginsIntoRegistry,
|
|
799
|
+
renderUiGraphOutputValue: () => renderUiGraphOutputValue,
|
|
763
800
|
replaceDatasetNode: () => replaceDatasetNode,
|
|
764
801
|
replaceGlobalRivetNodeRegistry: () => replaceGlobalRivetNodeRegistry,
|
|
765
802
|
resetGlobalRivetNodeRegistry: () => resetGlobalRivetNodeRegistry,
|
|
766
803
|
resolveBuiltInPlugin: () => resolveBuiltInPlugin,
|
|
804
|
+
resolveChatV2Credential: () => resolveChatV2Credential,
|
|
767
805
|
resolveChatV2ProviderConfig: () => resolveChatV2ProviderConfig,
|
|
768
806
|
resolveChatV2ResponseFormatParameters: () => resolveChatV2ResponseFormatParameters,
|
|
769
807
|
resolveLLMChatV2RuntimeProviderOptions: () => resolveLLMChatV2RuntimeProviderOptions,
|
|
@@ -790,7 +828,9 @@ __export(exports_exports, {
|
|
|
790
828
|
sliceNode: () => sliceNode,
|
|
791
829
|
splitNode: () => splitNode,
|
|
792
830
|
streamChatV2: () => streamChatV2,
|
|
831
|
+
stringifyUiGraphValue: () => stringifyUiGraphValue,
|
|
793
832
|
subGraphNode: () => subGraphNode,
|
|
833
|
+
summarizeChatV2RequestPlan: () => summarizeChatV2RequestPlan,
|
|
794
834
|
summarizeDataValueForLog: () => summarizeDataValueForLog,
|
|
795
835
|
summarizeErrorForLog: () => summarizeErrorForLog,
|
|
796
836
|
summarizePortMapForLog: () => summarizePortMapForLog,
|
|
@@ -1090,7 +1130,7 @@ function getDefaultValue(type) {
|
|
|
1090
1130
|
return [];
|
|
1091
1131
|
}
|
|
1092
1132
|
if (isFunctionDataType(type)) {
|
|
1093
|
-
return () => scalarDefaults[getScalarTypeOf(type)];
|
|
1133
|
+
return (() => scalarDefaults[getScalarTypeOf(type)]);
|
|
1094
1134
|
}
|
|
1095
1135
|
return scalarDefaults[getScalarTypeOf(type)];
|
|
1096
1136
|
}
|
|
@@ -1104,7 +1144,7 @@ function expectType(value, type) {
|
|
|
1104
1144
|
return value == null ? void 0 : value.value;
|
|
1105
1145
|
}
|
|
1106
1146
|
if (isFunctionDataType(type) && (value == null ? void 0 : value.type) === `fn<${type}>` || type === "fn<any>") {
|
|
1107
|
-
return () => value.value;
|
|
1147
|
+
return (() => value.value);
|
|
1108
1148
|
}
|
|
1109
1149
|
if ((value == null ? void 0 : value.type) !== type) {
|
|
1110
1150
|
throw new Error(`Expected value of type ${type} but got ${value == null ? void 0 : value.type}`);
|
|
@@ -1495,10 +1535,8 @@ function validateProject(project) {
|
|
|
1495
1535
|
errors.push("Missing project metadata");
|
|
1496
1536
|
} else {
|
|
1497
1537
|
const meta = p.metadata;
|
|
1498
|
-
if (!meta.id)
|
|
1499
|
-
|
|
1500
|
-
if (!meta.title)
|
|
1501
|
-
errors.push("Missing project metadata.title");
|
|
1538
|
+
if (!meta.id) errors.push("Missing project metadata.id");
|
|
1539
|
+
if (!meta.title) errors.push("Missing project metadata.title");
|
|
1502
1540
|
}
|
|
1503
1541
|
if (!p.graphs || typeof p.graphs !== "object") {
|
|
1504
1542
|
errors.push("Missing or invalid project graphs");
|
|
@@ -1519,10 +1557,8 @@ function validateProject(project) {
|
|
|
1519
1557
|
errors.push(`Graph "${graphId}": node at index ${i} is not an object`);
|
|
1520
1558
|
continue;
|
|
1521
1559
|
}
|
|
1522
|
-
if (!node.id)
|
|
1523
|
-
|
|
1524
|
-
if (!node.type)
|
|
1525
|
-
errors.push(`Graph "${graphId}": node "${node.id ?? i}" missing type`);
|
|
1560
|
+
if (!node.id) errors.push(`Graph "${graphId}": node at index ${i} missing id`);
|
|
1561
|
+
if (!node.type) errors.push(`Graph "${graphId}": node "${node.id ?? i}" missing type`);
|
|
1526
1562
|
}
|
|
1527
1563
|
}
|
|
1528
1564
|
if (!Array.isArray(g.connections)) {
|
|
@@ -1541,8 +1577,39 @@ function validateProject(project) {
|
|
|
1541
1577
|
}
|
|
1542
1578
|
}
|
|
1543
1579
|
}
|
|
1580
|
+
if (p.uiGraphs != null) {
|
|
1581
|
+
validateUiGraphs(p.uiGraphs, errors);
|
|
1582
|
+
}
|
|
1544
1583
|
return { valid: errors.length === 0, errors, warnings };
|
|
1545
1584
|
}
|
|
1585
|
+
function validateUiGraphs(uiGraphs, errors) {
|
|
1586
|
+
if (!uiGraphs || typeof uiGraphs !== "object" || Array.isArray(uiGraphs)) {
|
|
1587
|
+
errors.push("Project uiGraphs is not an object");
|
|
1588
|
+
return;
|
|
1589
|
+
}
|
|
1590
|
+
for (const [uiGraphId, uiGraph] of Object.entries(uiGraphs)) {
|
|
1591
|
+
if (!uiGraph || typeof uiGraph !== "object" || Array.isArray(uiGraph)) {
|
|
1592
|
+
errors.push(`UI graph "${uiGraphId}" is not an object`);
|
|
1593
|
+
continue;
|
|
1594
|
+
}
|
|
1595
|
+
const components = uiGraph.components;
|
|
1596
|
+
if (!Array.isArray(components)) {
|
|
1597
|
+
errors.push(`UI graph "${uiGraphId}" components is not an array`);
|
|
1598
|
+
continue;
|
|
1599
|
+
}
|
|
1600
|
+
const componentIds = /* @__PURE__ */ new Set();
|
|
1601
|
+
for (const [index, component] of components.entries()) {
|
|
1602
|
+
const componentId = component && typeof component === "object" && !Array.isArray(component) ? component.id : void 0;
|
|
1603
|
+
if (typeof componentId !== "string" || !componentId.trim()) {
|
|
1604
|
+
errors.push(`UI graph "${uiGraphId}" component at index ${index} missing id`);
|
|
1605
|
+
} else if (componentIds.has(componentId)) {
|
|
1606
|
+
errors.push(`UI graph "${uiGraphId}" component "${componentId}" has a duplicate id`);
|
|
1607
|
+
} else {
|
|
1608
|
+
componentIds.add(componentId);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1546
1613
|
function doubleCheckProject(project) {
|
|
1547
1614
|
const result = validateProject(project);
|
|
1548
1615
|
if (!result.valid) {
|
|
@@ -1740,6 +1807,177 @@ function emptyNodeGraph() {
|
|
|
1740
1807
|
};
|
|
1741
1808
|
}
|
|
1742
1809
|
|
|
1810
|
+
// src/utils/newId.ts
|
|
1811
|
+
var import_non_secure2 = require("nanoid/non-secure");
|
|
1812
|
+
function newId() {
|
|
1813
|
+
return (0, import_non_secure2.nanoid)();
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
// src/model/UiGraph.ts
|
|
1817
|
+
function hasValidUiGraphComponentIds(uiGraph) {
|
|
1818
|
+
const componentIds = /* @__PURE__ */ new Set();
|
|
1819
|
+
for (const component of uiGraph.components) {
|
|
1820
|
+
const componentId = typeof component.id === "string" ? component.id : "";
|
|
1821
|
+
if (!componentId.trim() || componentIds.has(componentId)) {
|
|
1822
|
+
return false;
|
|
1823
|
+
}
|
|
1824
|
+
componentIds.add(componentId);
|
|
1825
|
+
}
|
|
1826
|
+
return true;
|
|
1827
|
+
}
|
|
1828
|
+
function normalizeUiGraphComponentIds(uiGraph) {
|
|
1829
|
+
if (hasValidUiGraphComponentIds(uiGraph)) {
|
|
1830
|
+
return uiGraph;
|
|
1831
|
+
}
|
|
1832
|
+
const reservedIds = new Set(
|
|
1833
|
+
uiGraph.components.map((component) => typeof component.id === "string" ? component.id : "").filter((componentId) => Boolean(componentId.trim()))
|
|
1834
|
+
);
|
|
1835
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
1836
|
+
const graphId = typeof uiGraph.id === "string" && uiGraph.id.trim() ? uiGraph.id : "ui-graph";
|
|
1837
|
+
const components = uiGraph.components.map((component, index) => {
|
|
1838
|
+
const componentId = typeof component.id === "string" ? component.id : "";
|
|
1839
|
+
if (componentId.trim() && !usedIds.has(componentId)) {
|
|
1840
|
+
usedIds.add(componentId);
|
|
1841
|
+
return component;
|
|
1842
|
+
}
|
|
1843
|
+
const repairedId = getRepairedUiGraphComponentId(graphId, index, reservedIds, usedIds);
|
|
1844
|
+
usedIds.add(repairedId);
|
|
1845
|
+
return { ...component, id: repairedId };
|
|
1846
|
+
});
|
|
1847
|
+
return { ...uiGraph, components };
|
|
1848
|
+
}
|
|
1849
|
+
function getRepairedUiGraphComponentId(graphId, componentIndex, reservedIds, usedIds) {
|
|
1850
|
+
const baseId = `${graphId}-component-${componentIndex + 1}`;
|
|
1851
|
+
let repairedId = baseId;
|
|
1852
|
+
let suffix = 2;
|
|
1853
|
+
while (reservedIds.has(repairedId) || usedIds.has(repairedId)) {
|
|
1854
|
+
repairedId = `${baseId}-${suffix}`;
|
|
1855
|
+
suffix += 1;
|
|
1856
|
+
}
|
|
1857
|
+
return repairedId;
|
|
1858
|
+
}
|
|
1859
|
+
function createDefaultUiGraph(options2 = {}) {
|
|
1860
|
+
const promptStateKey = "input";
|
|
1861
|
+
const resultStateKey = "result";
|
|
1862
|
+
return {
|
|
1863
|
+
id: newId(),
|
|
1864
|
+
name: options2.name ?? "Untitled web app",
|
|
1865
|
+
components: [
|
|
1866
|
+
{
|
|
1867
|
+
id: newId(),
|
|
1868
|
+
type: "markdown",
|
|
1869
|
+
markdown: "## New Rivet web app\n\nEnter a value and run a graph."
|
|
1870
|
+
},
|
|
1871
|
+
{
|
|
1872
|
+
id: newId(),
|
|
1873
|
+
type: "textarea",
|
|
1874
|
+
label: "Input",
|
|
1875
|
+
stateKey: promptStateKey,
|
|
1876
|
+
placeholder: "Type something..."
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
id: newId(),
|
|
1880
|
+
type: "button",
|
|
1881
|
+
label: "Run graph",
|
|
1882
|
+
action: {
|
|
1883
|
+
type: "runGraph",
|
|
1884
|
+
graphId: options2.graphId,
|
|
1885
|
+
inputMappings: [{ inputKey: "input", stateKey: promptStateKey }],
|
|
1886
|
+
outputs: [{ stateKey: resultStateKey }]
|
|
1887
|
+
}
|
|
1888
|
+
},
|
|
1889
|
+
{
|
|
1890
|
+
id: newId(),
|
|
1891
|
+
type: "output",
|
|
1892
|
+
label: "Result",
|
|
1893
|
+
stateKey: resultStateKey,
|
|
1894
|
+
renderAs: "json"
|
|
1895
|
+
}
|
|
1896
|
+
]
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
function getUiGraphInitialState(uiGraph) {
|
|
1900
|
+
const state = {};
|
|
1901
|
+
for (const component of uiGraph.components) {
|
|
1902
|
+
if (component.type === "input" || component.type === "textarea") {
|
|
1903
|
+
state[component.stateKey] = component.defaultValue ?? "";
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
return state;
|
|
1907
|
+
}
|
|
1908
|
+
function getUiGraphActionComponent(uiGraph, componentId) {
|
|
1909
|
+
return uiGraph.components.find(
|
|
1910
|
+
(component) => component.id === componentId && component.type === "button"
|
|
1911
|
+
);
|
|
1912
|
+
}
|
|
1913
|
+
function resolveUiGraphActionInputs(action, state) {
|
|
1914
|
+
const inputs = {};
|
|
1915
|
+
if (action.inputMappings) {
|
|
1916
|
+
for (const binding of action.inputMappings) {
|
|
1917
|
+
if (binding.inputKey) {
|
|
1918
|
+
inputs[binding.inputKey] = state[binding.stateKey];
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
return inputs;
|
|
1922
|
+
}
|
|
1923
|
+
for (const [inputId, binding] of Object.entries(action.inputs ?? {})) {
|
|
1924
|
+
inputs[inputId] = binding.type === "state" ? state[binding.key] : binding.value;
|
|
1925
|
+
}
|
|
1926
|
+
return inputs;
|
|
1927
|
+
}
|
|
1928
|
+
function getUiGraphActionState(action, state) {
|
|
1929
|
+
return Object.fromEntries(
|
|
1930
|
+
[...new Set(getUiGraphActionInputBindings(action).map((binding) => binding.stateKey))].filter(Boolean).filter((stateKey) => Object.prototype.hasOwnProperty.call(state, stateKey)).map((stateKey) => [stateKey, state[stateKey]])
|
|
1931
|
+
);
|
|
1932
|
+
}
|
|
1933
|
+
function resolveUiGraphActionOutputStateValue(action, outputs) {
|
|
1934
|
+
var _a;
|
|
1935
|
+
if (!action.outputKey) {
|
|
1936
|
+
return outputs;
|
|
1937
|
+
}
|
|
1938
|
+
if (!Object.prototype.hasOwnProperty.call(outputs, action.outputKey)) {
|
|
1939
|
+
throw new Error(`Graph output "${action.outputKey}" was not returned by the target graph.`);
|
|
1940
|
+
}
|
|
1941
|
+
return (_a = outputs[action.outputKey]) == null ? void 0 : _a.value;
|
|
1942
|
+
}
|
|
1943
|
+
function resolveUiGraphActionOutputStatePatch(action, outputs) {
|
|
1944
|
+
const bindings = getUiGraphActionOutputBindings(action);
|
|
1945
|
+
const statePatch = {};
|
|
1946
|
+
for (const binding of bindings) {
|
|
1947
|
+
const stateKey = binding.stateKey.trim();
|
|
1948
|
+
if (!stateKey) {
|
|
1949
|
+
continue;
|
|
1950
|
+
}
|
|
1951
|
+
statePatch[stateKey] = resolveUiGraphOutputBindingValue(binding, outputs);
|
|
1952
|
+
}
|
|
1953
|
+
return statePatch;
|
|
1954
|
+
}
|
|
1955
|
+
function getUiGraphActionOutputBindings(action) {
|
|
1956
|
+
if (action.outputs) {
|
|
1957
|
+
return action.outputs;
|
|
1958
|
+
}
|
|
1959
|
+
return action.outputStateKey ? [{ outputKey: action.outputKey, stateKey: action.outputStateKey }] : [];
|
|
1960
|
+
}
|
|
1961
|
+
function getUiGraphActionInputBindings(action) {
|
|
1962
|
+
if (action.inputMappings) {
|
|
1963
|
+
return action.inputMappings;
|
|
1964
|
+
}
|
|
1965
|
+
return Object.entries(action.inputs ?? {}).map(([inputKey, binding]) => ({
|
|
1966
|
+
inputKey,
|
|
1967
|
+
stateKey: binding.type === "state" ? binding.key : ""
|
|
1968
|
+
}));
|
|
1969
|
+
}
|
|
1970
|
+
function resolveUiGraphOutputBindingValue(binding, outputs) {
|
|
1971
|
+
var _a;
|
|
1972
|
+
if (!binding.outputKey) {
|
|
1973
|
+
return outputs;
|
|
1974
|
+
}
|
|
1975
|
+
if (!Object.prototype.hasOwnProperty.call(outputs, binding.outputKey)) {
|
|
1976
|
+
throw new Error(`Graph output "${binding.outputKey}" was not returned by the target graph.`);
|
|
1977
|
+
}
|
|
1978
|
+
return (_a = outputs[binding.outputKey]) == null ? void 0 : _a.value;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1743
1981
|
// src/utils/serialization/serialization_v4.ts
|
|
1744
1982
|
function projectV4Deserializer(data) {
|
|
1745
1983
|
const serializedProject = unwrapYamlEnvelope(data, 4, "Project v4");
|
|
@@ -1769,11 +2007,12 @@ function toSerializedProject(project, attachedData) {
|
|
|
1769
2007
|
id: prefab.id,
|
|
1770
2008
|
sourceNode: toSerializedIsolatedNode(prefab.sourceNode)
|
|
1771
2009
|
}));
|
|
2010
|
+
const uiGraphs = (0, import_lodash_es2.mapValues)(project.uiGraphs ?? {}, normalizeUiGraphComponentIds);
|
|
1772
2011
|
return {
|
|
1773
2012
|
metadata: project.metadata,
|
|
1774
2013
|
graphs: (0, import_lodash_es2.mapValues)(project.graphs, (graph) => toSerializedGraph(graph)),
|
|
1775
2014
|
nodePrefabs: Object.keys(nodePrefabs).length > 0 ? nodePrefabs : void 0,
|
|
1776
|
-
uiGraphs:
|
|
2015
|
+
uiGraphs: Object.keys(uiGraphs).length > 0 ? uiGraphs : void 0,
|
|
1777
2016
|
attachedData,
|
|
1778
2017
|
plugins: project.plugins ?? [],
|
|
1779
2018
|
references: project.references ?? []
|
|
@@ -1784,12 +2023,13 @@ function fromSerializedProject2(serializedProject) {
|
|
|
1784
2023
|
id: prefab.id,
|
|
1785
2024
|
sourceNode: fromSerializedIsolatedNode(prefab.sourceNode)
|
|
1786
2025
|
}));
|
|
2026
|
+
const uiGraphs = (0, import_lodash_es2.mapValues)(serializedProject.uiGraphs ?? {}, normalizeUiGraphComponentIds);
|
|
1787
2027
|
return [
|
|
1788
2028
|
{
|
|
1789
2029
|
metadata: serializedProject.metadata,
|
|
1790
2030
|
graphs: (0, import_lodash_es2.mapValues)(serializedProject.graphs, (graph) => fromSerializedGraph2(graph)),
|
|
1791
2031
|
nodePrefabs: Object.keys(nodePrefabs).length > 0 ? nodePrefabs : void 0,
|
|
1792
|
-
uiGraphs:
|
|
2032
|
+
uiGraphs: Object.keys(uiGraphs).length > 0 ? uiGraphs : void 0,
|
|
1793
2033
|
plugins: serializedProject.plugins ?? [],
|
|
1794
2034
|
references: serializedProject.references ?? []
|
|
1795
2035
|
},
|
|
@@ -2166,12 +2406,6 @@ function getPluginConfig(plugin, settings, name) {
|
|
|
2166
2406
|
return void 0;
|
|
2167
2407
|
}
|
|
2168
2408
|
|
|
2169
|
-
// src/utils/newId.ts
|
|
2170
|
-
var import_non_secure2 = require("nanoid/non-secure");
|
|
2171
|
-
function newId() {
|
|
2172
|
-
return (0, import_non_secure2.nanoid)();
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
2409
|
// src/utils/handleEscapeCharacters.ts
|
|
2176
2410
|
function handleEscapeCharacters(inputString) {
|
|
2177
2411
|
return inputString.replace(/([^\\]|^)\\n/g, "$1\n").replace(/([^\\]|^)\\t/g, "$1 ").replace(/([^\\]|^)\\r/g, "$1\r").replace(/([^\\]|^)\\f/g, "$1\f").replace(/([^\\]|^)\\b/g, "$1\b").replace(/([^\\]|^)\\v/g, "$1\v");
|
|
@@ -2533,12 +2767,9 @@ function getComparableNodeData(node, data) {
|
|
|
2533
2767
|
// src/utils/projectComparison/summaries.ts
|
|
2534
2768
|
function summarizeProjectComparison(graphs, nodePrefabs = {}, uiGraphs = {}) {
|
|
2535
2769
|
const summary = Object.values(graphs).reduce((acc, graph) => {
|
|
2536
|
-
if (graph.kind === "added")
|
|
2537
|
-
|
|
2538
|
-
if (graph.kind === "
|
|
2539
|
-
acc.removedGraphs += 1;
|
|
2540
|
-
if (graph.kind === "changed")
|
|
2541
|
-
acc.changedGraphs += 1;
|
|
2770
|
+
if (graph.kind === "added") acc.addedGraphs += 1;
|
|
2771
|
+
if (graph.kind === "removed") acc.removedGraphs += 1;
|
|
2772
|
+
if (graph.kind === "changed") acc.changedGraphs += 1;
|
|
2542
2773
|
acc.addedNodes += graph.summary.addedNodes;
|
|
2543
2774
|
acc.removedNodes += graph.summary.removedNodes;
|
|
2544
2775
|
acc.changedNodes += graph.summary.changedNodes;
|
|
@@ -2548,20 +2779,14 @@ function summarizeProjectComparison(graphs, nodePrefabs = {}, uiGraphs = {}) {
|
|
|
2548
2779
|
return acc;
|
|
2549
2780
|
}, createEmptyProjectSummary());
|
|
2550
2781
|
for (const prefab of Object.values(nodePrefabs)) {
|
|
2551
|
-
if (prefab.kind === "added")
|
|
2552
|
-
|
|
2553
|
-
if (prefab.kind === "
|
|
2554
|
-
summary.removedNodePrefabs = (summary.removedNodePrefabs ?? 0) + 1;
|
|
2555
|
-
if (prefab.kind === "changed")
|
|
2556
|
-
summary.changedNodePrefabs = (summary.changedNodePrefabs ?? 0) + 1;
|
|
2782
|
+
if (prefab.kind === "added") summary.addedNodePrefabs = (summary.addedNodePrefabs ?? 0) + 1;
|
|
2783
|
+
if (prefab.kind === "removed") summary.removedNodePrefabs = (summary.removedNodePrefabs ?? 0) + 1;
|
|
2784
|
+
if (prefab.kind === "changed") summary.changedNodePrefabs = (summary.changedNodePrefabs ?? 0) + 1;
|
|
2557
2785
|
}
|
|
2558
2786
|
for (const uiGraph of Object.values(uiGraphs)) {
|
|
2559
|
-
if (uiGraph.kind === "added")
|
|
2560
|
-
|
|
2561
|
-
if (uiGraph.kind === "
|
|
2562
|
-
summary.removedUiGraphs = (summary.removedUiGraphs ?? 0) + 1;
|
|
2563
|
-
if (uiGraph.kind === "changed")
|
|
2564
|
-
summary.changedUiGraphs = (summary.changedUiGraphs ?? 0) + 1;
|
|
2787
|
+
if (uiGraph.kind === "added") summary.addedUiGraphs = (summary.addedUiGraphs ?? 0) + 1;
|
|
2788
|
+
if (uiGraph.kind === "removed") summary.removedUiGraphs = (summary.removedUiGraphs ?? 0) + 1;
|
|
2789
|
+
if (uiGraph.kind === "changed") summary.changedUiGraphs = (summary.changedUiGraphs ?? 0) + 1;
|
|
2565
2790
|
}
|
|
2566
2791
|
return summary;
|
|
2567
2792
|
}
|
|
@@ -4183,6 +4408,71 @@ function wireSubprocessorLifecycle(processor, options2) {
|
|
|
4183
4408
|
unsubscribers.push(subscribeOwnGraphRunLifecycle(processor, cleanup));
|
|
4184
4409
|
}
|
|
4185
4410
|
|
|
4411
|
+
// src/model/GraphRunLifecycle.ts
|
|
4412
|
+
var GraphRunLifecycle = class {
|
|
4413
|
+
#phase = "idle";
|
|
4414
|
+
#paused = false;
|
|
4415
|
+
#abort;
|
|
4416
|
+
#finishClaimed = false;
|
|
4417
|
+
get phase() {
|
|
4418
|
+
return this.#phase;
|
|
4419
|
+
}
|
|
4420
|
+
get isRunning() {
|
|
4421
|
+
return this.#phase === "running" || this.#phase === "aborting";
|
|
4422
|
+
}
|
|
4423
|
+
get isPaused() {
|
|
4424
|
+
return this.#paused;
|
|
4425
|
+
}
|
|
4426
|
+
get isAborted() {
|
|
4427
|
+
return this.#abort != null;
|
|
4428
|
+
}
|
|
4429
|
+
get abortSuccessful() {
|
|
4430
|
+
var _a;
|
|
4431
|
+
return ((_a = this.#abort) == null ? void 0 : _a.successful) ?? false;
|
|
4432
|
+
}
|
|
4433
|
+
get abortError() {
|
|
4434
|
+
var _a;
|
|
4435
|
+
return (_a = this.#abort) == null ? void 0 : _a.error;
|
|
4436
|
+
}
|
|
4437
|
+
begin() {
|
|
4438
|
+
if (this.isRunning) {
|
|
4439
|
+
throw new Error("Cannot process graph while already processing");
|
|
4440
|
+
}
|
|
4441
|
+
this.#phase = "running";
|
|
4442
|
+
this.#abort = void 0;
|
|
4443
|
+
this.#finishClaimed = false;
|
|
4444
|
+
}
|
|
4445
|
+
complete() {
|
|
4446
|
+
if (this.#phase !== "idle") this.#phase = "finished";
|
|
4447
|
+
}
|
|
4448
|
+
requestAbort(successful, error) {
|
|
4449
|
+
if (!this.isRunning || this.#abort) return void 0;
|
|
4450
|
+
this.#phase = "aborting";
|
|
4451
|
+
this.#abort = { successful, error };
|
|
4452
|
+
return this.#abort;
|
|
4453
|
+
}
|
|
4454
|
+
pause() {
|
|
4455
|
+
if (this.#paused) return false;
|
|
4456
|
+
this.#paused = true;
|
|
4457
|
+
return true;
|
|
4458
|
+
}
|
|
4459
|
+
resume() {
|
|
4460
|
+
if (!this.#paused) return false;
|
|
4461
|
+
this.#paused = false;
|
|
4462
|
+
return true;
|
|
4463
|
+
}
|
|
4464
|
+
claimRootFinish(isSubProcessor) {
|
|
4465
|
+
if (isSubProcessor || this.#finishClaimed) return false;
|
|
4466
|
+
this.#finishClaimed = true;
|
|
4467
|
+
return true;
|
|
4468
|
+
}
|
|
4469
|
+
getAbortError() {
|
|
4470
|
+
var _a, _b;
|
|
4471
|
+
if (typeof ((_a = this.#abort) == null ? void 0 : _a.error) === "string") return new Error(this.#abort.error);
|
|
4472
|
+
return ((_b = this.#abort) == null ? void 0 : _b.error) ?? new Error("Processing aborted");
|
|
4473
|
+
}
|
|
4474
|
+
};
|
|
4475
|
+
|
|
4186
4476
|
// src/model/NodeExclusionPolicy.ts
|
|
4187
4477
|
var nodesAllowedToConsumeExcludedValue = /* @__PURE__ */ new Set([
|
|
4188
4478
|
"if",
|
|
@@ -4397,11 +4687,10 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4397
4687
|
#nodeInstances;
|
|
4398
4688
|
#connections;
|
|
4399
4689
|
#emitter = new import_emittery.default();
|
|
4400
|
-
#
|
|
4690
|
+
#lifecycle = new GraphRunLifecycle();
|
|
4401
4691
|
#isSubProcessor = false;
|
|
4402
4692
|
#externalFunctions = {};
|
|
4403
4693
|
slowMode = false;
|
|
4404
|
-
#isPaused = false;
|
|
4405
4694
|
#parent;
|
|
4406
4695
|
#registry;
|
|
4407
4696
|
#concurrency;
|
|
@@ -4447,9 +4736,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4447
4736
|
#contextValues = void 0;
|
|
4448
4737
|
#globals = void 0;
|
|
4449
4738
|
#attachedNodeData = void 0;
|
|
4450
|
-
#aborted = false;
|
|
4451
|
-
#abortSuccessfully = false;
|
|
4452
|
-
#abortError = void 0;
|
|
4453
4739
|
#successfulAbortTerminalProcessIds = void 0;
|
|
4454
4740
|
#totalCost = 0;
|
|
4455
4741
|
#ignoreNodes = void 0;
|
|
@@ -4465,10 +4751,9 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4465
4751
|
#graphInputNodeValues = {};
|
|
4466
4752
|
/** User input nodes that are pending user input. */
|
|
4467
4753
|
#pendingUserInputs = void 0;
|
|
4468
|
-
#finishEmitted = false;
|
|
4469
4754
|
#unsubscribeTokenizerError;
|
|
4470
4755
|
get isRunning() {
|
|
4471
|
-
return this.#
|
|
4756
|
+
return this.#lifecycle.isRunning;
|
|
4472
4757
|
}
|
|
4473
4758
|
#startNodeTiming() {
|
|
4474
4759
|
return this.#captureNodeTimings ? getMonotonicTimeMs() : void 0;
|
|
@@ -4677,11 +4962,9 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4677
4962
|
this.#externalFunctions[name] = fn;
|
|
4678
4963
|
}
|
|
4679
4964
|
async abort(successful = false, error) {
|
|
4680
|
-
if (!this.#
|
|
4965
|
+
if (!this.#lifecycle.requestAbort(successful, error)) {
|
|
4681
4966
|
return Promise.resolve();
|
|
4682
4967
|
}
|
|
4683
|
-
this.#abortSuccessfully = successful;
|
|
4684
|
-
this.#abortError = error;
|
|
4685
4968
|
const abortReason = createGraphAbortReason(successful, error);
|
|
4686
4969
|
this.#abortController.abort(abortReason);
|
|
4687
4970
|
this.#abortActiveNodeControllers(abortReason);
|
|
@@ -4692,14 +4975,12 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4692
4975
|
await this.#processingQueue.onIdle();
|
|
4693
4976
|
}
|
|
4694
4977
|
pause() {
|
|
4695
|
-
if (this.#
|
|
4696
|
-
this.#isPaused = true;
|
|
4978
|
+
if (this.#lifecycle.pause()) {
|
|
4697
4979
|
emitDetached(this.#emitter, "pause", void 0);
|
|
4698
4980
|
}
|
|
4699
4981
|
}
|
|
4700
4982
|
resume() {
|
|
4701
|
-
if (this.#
|
|
4702
|
-
this.#isPaused = false;
|
|
4983
|
+
if (this.#lifecycle.resume()) {
|
|
4703
4984
|
emitDetached(this.#emitter, "resume", void 0);
|
|
4704
4985
|
}
|
|
4705
4986
|
}
|
|
@@ -4707,16 +4988,16 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4707
4988
|
this.slowMode = slowMode;
|
|
4708
4989
|
}
|
|
4709
4990
|
async #waitUntilUnpaused() {
|
|
4710
|
-
if (!this.#isPaused) {
|
|
4991
|
+
if (!this.#lifecycle.isPaused) {
|
|
4711
4992
|
return;
|
|
4712
4993
|
}
|
|
4713
4994
|
if (this.#abortController.signal.aborted) {
|
|
4714
|
-
throw this.#getAbortError();
|
|
4995
|
+
throw this.#lifecycle.getAbortError();
|
|
4715
4996
|
}
|
|
4716
4997
|
await new Promise((resolve, reject) => {
|
|
4717
4998
|
const abortListener = () => {
|
|
4718
4999
|
cleanup();
|
|
4719
|
-
reject(this.#getAbortError());
|
|
5000
|
+
reject(this.#lifecycle.getAbortError());
|
|
4720
5001
|
};
|
|
4721
5002
|
const unsubscribeResume = this.#emitter.on("resume", () => {
|
|
4722
5003
|
cleanup();
|
|
@@ -4729,12 +5010,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4729
5010
|
this.#abortController.signal.addEventListener("abort", abortListener, { once: true });
|
|
4730
5011
|
});
|
|
4731
5012
|
}
|
|
4732
|
-
#getAbortError() {
|
|
4733
|
-
if (typeof this.#abortError === "string") {
|
|
4734
|
-
return new Error(this.#abortError);
|
|
4735
|
-
}
|
|
4736
|
-
return this.#abortError ?? new Error("Processing aborted");
|
|
4737
|
-
}
|
|
4738
5013
|
async *events() {
|
|
4739
5014
|
for await (const [event, data] of this.#emitter.anyEvent()) {
|
|
4740
5015
|
yield {
|
|
@@ -4799,7 +5074,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4799
5074
|
erroredNodes: this.#erroredNodes,
|
|
4800
5075
|
graphInputs: this.#graphInputs,
|
|
4801
5076
|
graphOutputs: this.#graphOutputs,
|
|
4802
|
-
isAborted: () => this.#
|
|
5077
|
+
isAborted: () => this.#lifecycle.isAborted,
|
|
4803
5078
|
nodeResults: this.#nodeResults,
|
|
4804
5079
|
project: this.#project,
|
|
4805
5080
|
recorder,
|
|
@@ -4814,7 +5089,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4814
5089
|
this.#graphOutputs = graphOutputs;
|
|
4815
5090
|
},
|
|
4816
5091
|
setRunning: (running) => {
|
|
4817
|
-
this.#
|
|
5092
|
+
if (!running) this.#lifecycle.complete();
|
|
4818
5093
|
},
|
|
4819
5094
|
visitedNodes: this.#visitedNodes,
|
|
4820
5095
|
waitUntilUnpaused: () => this.#waitUntilUnpaused()
|
|
@@ -4823,8 +5098,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4823
5098
|
}
|
|
4824
5099
|
#initProcessState() {
|
|
4825
5100
|
var _a, _b;
|
|
4826
|
-
this.#
|
|
4827
|
-
this.#finishEmitted = false;
|
|
5101
|
+
this.#lifecycle.begin();
|
|
4828
5102
|
if (!this.#hasPreloadedData) {
|
|
4829
5103
|
this.#nodeResults = /* @__PURE__ */ new Map();
|
|
4830
5104
|
this.#visitedNodes = /* @__PURE__ */ new Set();
|
|
@@ -4848,12 +5122,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4848
5122
|
this.#nodeProcessContextBase = void 0;
|
|
4849
5123
|
this.#runToRelevantNodeIds = void 0;
|
|
4850
5124
|
this.#abortController = this.#newAbortController();
|
|
4851
|
-
this.#abortController.signal.addEventListener("abort", () => {
|
|
4852
|
-
this.#aborted = true;
|
|
4853
|
-
});
|
|
4854
|
-
this.#aborted = false;
|
|
4855
|
-
this.#abortError = void 0;
|
|
4856
|
-
this.#abortSuccessfully = false;
|
|
4857
5125
|
this.#successfulAbortTerminalProcessIds = /* @__PURE__ */ new Set();
|
|
4858
5126
|
this.#nodeAbortControllers = /* @__PURE__ */ new Map();
|
|
4859
5127
|
this.#loadedProjects = this.#cacheLoadedProjects && ((_a = this.#runtimeCache) == null ? void 0 : _a.loadedProjects) ? { ...this.#runtimeCache.loadedProjects } : {};
|
|
@@ -4866,7 +5134,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4866
5134
|
}
|
|
4867
5135
|
/** Main function for running a graph. Runs a graph and returns the outputs from the output nodes of the graph. */
|
|
4868
5136
|
async processGraph(context, inputs = {}, contextValues = {}) {
|
|
4869
|
-
if (this.#
|
|
5137
|
+
if (this.#lifecycle.isRunning) {
|
|
4870
5138
|
throw new Error("Cannot process graph while already processing");
|
|
4871
5139
|
}
|
|
4872
5140
|
try {
|
|
@@ -4889,16 +5157,15 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4889
5157
|
await this.#profileRuntimeAsync("throwIfGraphErrored", () => this.#throwIfGraphErrored());
|
|
4890
5158
|
return await this.#profileRuntimeAsync("finalizeGraphRun", () => this.#finalizeGraphRun());
|
|
4891
5159
|
} finally {
|
|
4892
|
-
this.#
|
|
5160
|
+
this.#lifecycle.complete();
|
|
4893
5161
|
this.#cleanupTokenizerErrorListener();
|
|
4894
5162
|
await this.#profileRuntimeAsync("emitFinish", () => this.#emitFinishIfNeeded());
|
|
4895
5163
|
}
|
|
4896
5164
|
}
|
|
4897
5165
|
async #emitFinishIfNeeded() {
|
|
4898
|
-
if (this.#
|
|
5166
|
+
if (!this.#lifecycle.claimRootFinish(this.#isSubProcessor)) {
|
|
4899
5167
|
return;
|
|
4900
5168
|
}
|
|
4901
|
-
this.#finishEmitted = true;
|
|
4902
5169
|
await this.#emitter.emit("finish", void 0);
|
|
4903
5170
|
}
|
|
4904
5171
|
#initializeGraphRun(context, inputs, contextValues) {
|
|
@@ -5127,8 +5394,8 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
5127
5394
|
});
|
|
5128
5395
|
}
|
|
5129
5396
|
#createGraphError(erroredNodes) {
|
|
5130
|
-
if (this.#abortError) {
|
|
5131
|
-
return this.#getAbortError();
|
|
5397
|
+
if (this.#lifecycle.abortError) {
|
|
5398
|
+
return this.#lifecycle.getAbortError();
|
|
5132
5399
|
}
|
|
5133
5400
|
const message = `Graph ${this.#graph.metadata.name} (${this.#graph.metadata.id}) failed to process due to errors in nodes:
|
|
5134
5401
|
${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})`).join("\n")}`;
|
|
@@ -5143,7 +5410,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5143
5410
|
}
|
|
5144
5411
|
async #throwIfGraphErrored() {
|
|
5145
5412
|
const erroredNodes = this.#getUnhandledErroredNodes();
|
|
5146
|
-
if (!erroredNodes.length || this.#
|
|
5413
|
+
if (!erroredNodes.length || this.#lifecycle.abortSuccessful) {
|
|
5147
5414
|
return;
|
|
5148
5415
|
}
|
|
5149
5416
|
const error = this.#createGraphError(erroredNodes);
|
|
@@ -5156,7 +5423,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5156
5423
|
async #finalizeGraphRun() {
|
|
5157
5424
|
ensureGraphCostOutput(this.#graphOutputs, this.#totalCost);
|
|
5158
5425
|
const outputValues = this.#graphOutputs;
|
|
5159
|
-
this.#
|
|
5426
|
+
this.#lifecycle.complete();
|
|
5160
5427
|
await this.#emitter.emit("graphFinish", this.#withExecution({ graph: this.#graph, outputs: outputValues }));
|
|
5161
5428
|
if (!this.#isSubProcessor) {
|
|
5162
5429
|
await this.#emitter.emit("done", { results: outputValues });
|
|
@@ -5528,7 +5795,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5528
5795
|
setNodeResults: (nodeId, outputs) => this.#nodeResults.set(nodeId, outputs),
|
|
5529
5796
|
markNodeVisited: (nodeId) => this.#visitedNodes.add(nodeId),
|
|
5530
5797
|
nodeErrored: (n, err, pid, durationMs, splitRunDurationMs) => this.#nodeErrored(n, err, pid, durationMs, splitRunDurationMs),
|
|
5531
|
-
isAborted: () => this.#
|
|
5798
|
+
isAborted: () => this.#lifecycle.isAborted,
|
|
5532
5799
|
getAbortError: () => createGraphAbortErrorFromSignal(this.#abortController.signal),
|
|
5533
5800
|
emit: (event, data) => {
|
|
5534
5801
|
if (event === "partialOutput") {
|
|
@@ -5649,8 +5916,8 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5649
5916
|
this.#successfulAbortTerminalProcessIds.add(processId);
|
|
5650
5917
|
return SUCCESSFUL_GRAPH_ABORT_EXCLUSION_REASON;
|
|
5651
5918
|
}
|
|
5652
|
-
if (this.#
|
|
5653
|
-
const exclusionReason = this.#abortError === RACE_LOSER_EXCLUSION_REASON ? RACE_LOSER_EXCLUSION_REASON : SUCCESSFUL_GRAPH_ABORT_EXCLUSION_REASON;
|
|
5919
|
+
if (this.#lifecycle.abortSuccessful && isAbortLikeError(error)) {
|
|
5920
|
+
const exclusionReason = this.#lifecycle.abortError === RACE_LOSER_EXCLUSION_REASON ? RACE_LOSER_EXCLUSION_REASON : SUCCESSFUL_GRAPH_ABORT_EXCLUSION_REASON;
|
|
5654
5921
|
if (exclusionReason === SUCCESSFUL_GRAPH_ABORT_EXCLUSION_REASON) {
|
|
5655
5922
|
this.#successfulAbortTerminalProcessIds.add(processId);
|
|
5656
5923
|
}
|
|
@@ -5906,7 +6173,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5906
6173
|
const wireEventsProfileStart = this.#startRuntimeProfile();
|
|
5907
6174
|
try {
|
|
5908
6175
|
wireSubprocessorEvents(processor, this.#emitter, {
|
|
5909
|
-
isPaused: () => this.#isPaused,
|
|
6176
|
+
isPaused: () => this.#lifecycle.isPaused,
|
|
5910
6177
|
pause: () => {
|
|
5911
6178
|
void this.pause();
|
|
5912
6179
|
},
|
|
@@ -6042,124 +6309,76 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
6042
6309
|
visitedNodes: this.#visitedNodes
|
|
6043
6310
|
};
|
|
6044
6311
|
}
|
|
6045
|
-
};
|
|
6046
|
-
|
|
6047
|
-
// src/model/
|
|
6048
|
-
function
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
type: "
|
|
6070
|
-
|
|
6071
|
-
action: {
|
|
6072
|
-
type: "runGraph",
|
|
6073
|
-
graphId: options2.graphId,
|
|
6074
|
-
inputMappings: [{ inputKey: "input", stateKey: promptStateKey }],
|
|
6075
|
-
outputs: [{ stateKey: resultStateKey }]
|
|
6076
|
-
}
|
|
6077
|
-
},
|
|
6078
|
-
{
|
|
6079
|
-
id: newId(),
|
|
6080
|
-
type: "output",
|
|
6081
|
-
label: "Result",
|
|
6082
|
-
stateKey: resultStateKey,
|
|
6083
|
-
renderAs: "json"
|
|
6084
|
-
}
|
|
6085
|
-
]
|
|
6086
|
-
};
|
|
6087
|
-
}
|
|
6088
|
-
function getUiGraphInitialState(uiGraph) {
|
|
6089
|
-
const state = {};
|
|
6090
|
-
for (const component of uiGraph.components) {
|
|
6091
|
-
if (component.type === "input" || component.type === "textarea") {
|
|
6092
|
-
state[component.stateKey] = component.defaultValue ?? "";
|
|
6093
|
-
}
|
|
6094
|
-
}
|
|
6095
|
-
return state;
|
|
6096
|
-
}
|
|
6097
|
-
function getUiGraphActionComponent(uiGraph, componentId) {
|
|
6098
|
-
return uiGraph.components.find(
|
|
6099
|
-
(component) => component.id === componentId && component.type === "button"
|
|
6100
|
-
);
|
|
6101
|
-
}
|
|
6102
|
-
function resolveUiGraphActionInputs(action, state) {
|
|
6103
|
-
const inputs = {};
|
|
6104
|
-
if (action.inputMappings) {
|
|
6105
|
-
for (const binding of action.inputMappings) {
|
|
6106
|
-
if (binding.inputKey) {
|
|
6107
|
-
inputs[binding.inputKey] = state[binding.stateKey];
|
|
6108
|
-
}
|
|
6109
|
-
}
|
|
6110
|
-
return inputs;
|
|
6111
|
-
}
|
|
6112
|
-
for (const [inputId, binding] of Object.entries(action.inputs ?? {})) {
|
|
6113
|
-
inputs[inputId] = binding.type === "state" ? state[binding.key] : binding.value;
|
|
6114
|
-
}
|
|
6115
|
-
return inputs;
|
|
6116
|
-
}
|
|
6117
|
-
function resolveUiGraphActionOutputStateValue(action, outputs) {
|
|
6118
|
-
var _a;
|
|
6119
|
-
if (!action.outputKey) {
|
|
6120
|
-
return outputs;
|
|
6121
|
-
}
|
|
6122
|
-
if (!Object.prototype.hasOwnProperty.call(outputs, action.outputKey)) {
|
|
6123
|
-
throw new Error(`Graph output "${action.outputKey}" was not returned by the target graph.`);
|
|
6124
|
-
}
|
|
6125
|
-
return (_a = outputs[action.outputKey]) == null ? void 0 : _a.value;
|
|
6126
|
-
}
|
|
6127
|
-
function resolveUiGraphActionOutputStatePatch(action, outputs) {
|
|
6128
|
-
const bindings = getUiGraphActionOutputBindings(action);
|
|
6129
|
-
const statePatch = {};
|
|
6130
|
-
for (const binding of bindings) {
|
|
6131
|
-
const stateKey = binding.stateKey.trim();
|
|
6132
|
-
if (!stateKey) {
|
|
6133
|
-
continue;
|
|
6134
|
-
}
|
|
6135
|
-
statePatch[stateKey] = resolveUiGraphOutputBindingValue(binding, outputs);
|
|
6312
|
+
};
|
|
6313
|
+
|
|
6314
|
+
// src/model/UiGraphRuntimeModel.ts
|
|
6315
|
+
function getUiGraphComponentRenderModel(component, state) {
|
|
6316
|
+
switch (component.type) {
|
|
6317
|
+
case "text":
|
|
6318
|
+
return { component, text: component.text, type: "text" };
|
|
6319
|
+
case "markdown":
|
|
6320
|
+
return { component, markdown: component.markdown, type: "markdown" };
|
|
6321
|
+
case "input":
|
|
6322
|
+
case "textarea":
|
|
6323
|
+
return {
|
|
6324
|
+
component,
|
|
6325
|
+
label: getUiGraphComponentLabel(component),
|
|
6326
|
+
type: component.type,
|
|
6327
|
+
value: `${state[component.stateKey] ?? component.defaultValue ?? ""}`
|
|
6328
|
+
};
|
|
6329
|
+
case "button":
|
|
6330
|
+
return { component, label: component.label, type: "button" };
|
|
6331
|
+
case "output":
|
|
6332
|
+
return {
|
|
6333
|
+
component,
|
|
6334
|
+
label: getUiGraphComponentLabel(component),
|
|
6335
|
+
output: getUiGraphOutputRenderModel(state, component.stateKey, component.renderAs ?? "text"),
|
|
6336
|
+
type: "output"
|
|
6337
|
+
};
|
|
6136
6338
|
}
|
|
6137
|
-
return statePatch;
|
|
6138
6339
|
}
|
|
6139
|
-
function
|
|
6140
|
-
|
|
6141
|
-
return action.outputs;
|
|
6142
|
-
}
|
|
6143
|
-
return action.outputStateKey ? [{ outputKey: action.outputKey, stateKey: action.outputStateKey }] : [];
|
|
6340
|
+
function getUiGraphComponentLabel(component) {
|
|
6341
|
+
return component.label || component.stateKey;
|
|
6144
6342
|
}
|
|
6145
|
-
function
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
return
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6343
|
+
function getUiGraphOutputRenderModel(state, stateKey, renderAs) {
|
|
6344
|
+
const value = state[stateKey];
|
|
6345
|
+
const hasValue = hasUiGraphStateValue(state, stateKey);
|
|
6346
|
+
const renderedValue = renderUiGraphOutputValue(value, renderAs);
|
|
6347
|
+
return {
|
|
6348
|
+
hasValue,
|
|
6349
|
+
...hasValue && renderAs === "json" ? { jsonDownloadValue: stringifyUiGraphValue(value) } : {},
|
|
6350
|
+
renderedValue,
|
|
6351
|
+
renderAs
|
|
6352
|
+
};
|
|
6153
6353
|
}
|
|
6154
|
-
function
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6354
|
+
function hasUiGraphStateValue(state, key) {
|
|
6355
|
+
return Object.prototype.hasOwnProperty.call(state, key) && state[key] !== void 0;
|
|
6356
|
+
}
|
|
6357
|
+
function renderUiGraphOutputValue(value, renderAs) {
|
|
6358
|
+
if (renderAs === "json") {
|
|
6359
|
+
return stringifyUiGraphValue(value) ?? "";
|
|
6158
6360
|
}
|
|
6159
|
-
|
|
6160
|
-
|
|
6361
|
+
return typeof value === "string" ? value : value == null ? "" : stringifyUiGraphValue(value) ?? "";
|
|
6362
|
+
}
|
|
6363
|
+
function stringifyUiGraphValue(value) {
|
|
6364
|
+
try {
|
|
6365
|
+
return JSON.stringify(value, null, 2);
|
|
6366
|
+
} catch {
|
|
6367
|
+
return "[Unserializable value]";
|
|
6161
6368
|
}
|
|
6162
|
-
|
|
6369
|
+
}
|
|
6370
|
+
function getUiGraphJsonOutputFilename(appName, date = /* @__PURE__ */ new Date()) {
|
|
6371
|
+
const safeName = appName.trim().replace(/[<>:"/\\|?*\u0000-\u001F]/g, "-").replace(/\s+/g, " ").slice(0, 80);
|
|
6372
|
+
return `${safeName || "Rivet web app"} ${formatUiGraphDownloadDateTime(date)}.json`;
|
|
6373
|
+
}
|
|
6374
|
+
function formatUiGraphDownloadDateTime(date) {
|
|
6375
|
+
const pad = (value) => `${value}`.padStart(2, "0");
|
|
6376
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}-${pad(
|
|
6377
|
+
date.getMinutes()
|
|
6378
|
+
)}-${pad(date.getSeconds())}`;
|
|
6379
|
+
}
|
|
6380
|
+
function applyUiGraphStatePatch(state, statePatch) {
|
|
6381
|
+
return statePatch ? { ...state, ...statePatch } : state;
|
|
6163
6382
|
}
|
|
6164
6383
|
|
|
6165
6384
|
// src/model/UiGraphRendererStyles.ts
|
|
@@ -6266,11 +6485,93 @@ var RIVET_WEB_APP_RENDERER_CSS = `
|
|
|
6266
6485
|
.rivet-web-app-output {
|
|
6267
6486
|
display: grid;
|
|
6268
6487
|
gap: 8px;
|
|
6488
|
+
position: relative;
|
|
6269
6489
|
}
|
|
6270
6490
|
|
|
6271
6491
|
.rivet-web-app-output-title {
|
|
6272
6492
|
color: var(--rivet-web-app-output-title);
|
|
6273
6493
|
font-weight: 700;
|
|
6494
|
+
padding-right: 32px;
|
|
6495
|
+
}
|
|
6496
|
+
|
|
6497
|
+
.rivet-web-app-output-has-download .rivet-web-app-output-title {
|
|
6498
|
+
padding-right: 64px;
|
|
6499
|
+
}
|
|
6500
|
+
|
|
6501
|
+
.rivet-web-app-output-action-button {
|
|
6502
|
+
position: absolute;
|
|
6503
|
+
top: 11px;
|
|
6504
|
+
width: 24px;
|
|
6505
|
+
height: 24px;
|
|
6506
|
+
border: 0;
|
|
6507
|
+
border-radius: 5px;
|
|
6508
|
+
background: transparent;
|
|
6509
|
+
color: color-mix(in srgb, var(--rivet-web-app-foreground) 68%, transparent);
|
|
6510
|
+
cursor: pointer;
|
|
6511
|
+
padding: 0;
|
|
6512
|
+
}
|
|
6513
|
+
|
|
6514
|
+
.rivet-web-app-output-copy-button {
|
|
6515
|
+
right: 11px;
|
|
6516
|
+
}
|
|
6517
|
+
|
|
6518
|
+
.rivet-web-app-output-download-button {
|
|
6519
|
+
right: 39px;
|
|
6520
|
+
}
|
|
6521
|
+
|
|
6522
|
+
.rivet-web-app-output-copy-button::before,
|
|
6523
|
+
.rivet-web-app-output-copy-button::after {
|
|
6524
|
+
content: "";
|
|
6525
|
+
position: absolute;
|
|
6526
|
+
width: 10px;
|
|
6527
|
+
height: 12px;
|
|
6528
|
+
border: 1.5px solid currentColor;
|
|
6529
|
+
border-radius: 2px;
|
|
6530
|
+
}
|
|
6531
|
+
|
|
6532
|
+
.rivet-web-app-output-copy-button::before {
|
|
6533
|
+
top: 5px;
|
|
6534
|
+
left: 8px;
|
|
6535
|
+
}
|
|
6536
|
+
|
|
6537
|
+
.rivet-web-app-output-copy-button::after {
|
|
6538
|
+
top: 8px;
|
|
6539
|
+
left: 5px;
|
|
6540
|
+
background: var(--rivet-web-app-card-background);
|
|
6541
|
+
}
|
|
6542
|
+
|
|
6543
|
+
.rivet-web-app-output-download-button::before,
|
|
6544
|
+
.rivet-web-app-output-download-button::after {
|
|
6545
|
+
content: "";
|
|
6546
|
+
position: absolute;
|
|
6547
|
+
}
|
|
6548
|
+
|
|
6549
|
+
.rivet-web-app-output-download-button::before {
|
|
6550
|
+
top: 5px;
|
|
6551
|
+
left: 8px;
|
|
6552
|
+
width: 8px;
|
|
6553
|
+
height: 8px;
|
|
6554
|
+
border-right: 1.5px solid currentColor;
|
|
6555
|
+
border-bottom: 1.5px solid currentColor;
|
|
6556
|
+
transform: rotate(45deg);
|
|
6557
|
+
}
|
|
6558
|
+
|
|
6559
|
+
.rivet-web-app-output-download-button::after {
|
|
6560
|
+
top: 16px;
|
|
6561
|
+
left: 6px;
|
|
6562
|
+
width: 12px;
|
|
6563
|
+
height: 4px;
|
|
6564
|
+
border-right: 1.5px solid currentColor;
|
|
6565
|
+
border-bottom: 1.5px solid currentColor;
|
|
6566
|
+
border-left: 1.5px solid currentColor;
|
|
6567
|
+
border-radius: 0 0 2px 2px;
|
|
6568
|
+
}
|
|
6569
|
+
|
|
6570
|
+
.rivet-web-app-output-action-button:hover,
|
|
6571
|
+
.rivet-web-app-output-action-button:focus-visible {
|
|
6572
|
+
color: var(--primary, #ff9e2c);
|
|
6573
|
+
outline: none;
|
|
6574
|
+
background: color-mix(in srgb, var(--rivet-web-app-foreground) 8%, transparent);
|
|
6274
6575
|
}
|
|
6275
6576
|
|
|
6276
6577
|
.rivet-web-app-output pre {
|
|
@@ -6405,6 +6706,44 @@ body {
|
|
|
6405
6706
|
}
|
|
6406
6707
|
`;
|
|
6407
6708
|
|
|
6709
|
+
// src/model/MarkdownSanitizationPolicy.ts
|
|
6710
|
+
var RIVET_MARKDOWN_ALLOWED_TAGS = [
|
|
6711
|
+
"a",
|
|
6712
|
+
"blockquote",
|
|
6713
|
+
"br",
|
|
6714
|
+
"code",
|
|
6715
|
+
"del",
|
|
6716
|
+
"em",
|
|
6717
|
+
"h1",
|
|
6718
|
+
"h2",
|
|
6719
|
+
"h3",
|
|
6720
|
+
"h4",
|
|
6721
|
+
"h5",
|
|
6722
|
+
"h6",
|
|
6723
|
+
"hr",
|
|
6724
|
+
"li",
|
|
6725
|
+
"ol",
|
|
6726
|
+
"p",
|
|
6727
|
+
"pre",
|
|
6728
|
+
"strong",
|
|
6729
|
+
"sub",
|
|
6730
|
+
"sup",
|
|
6731
|
+
"table",
|
|
6732
|
+
"tbody",
|
|
6733
|
+
"td",
|
|
6734
|
+
"th",
|
|
6735
|
+
"thead",
|
|
6736
|
+
"tr",
|
|
6737
|
+
"ul"
|
|
6738
|
+
];
|
|
6739
|
+
var RIVET_MARKDOWN_ALLOWED_ATTRIBUTES = ["class", "href", "title"];
|
|
6740
|
+
var RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE = "^(?:https?:|mailto:|#|\\?(?:[^/]|$)|/(?!/)|\\.{1,2}/|[a-z0-9._~-]+(?:[/?#]|$))";
|
|
6741
|
+
var RIVET_MARKDOWN_SANITIZER_POLICY = Object.freeze({
|
|
6742
|
+
allowedAttributes: RIVET_MARKDOWN_ALLOWED_ATTRIBUTES,
|
|
6743
|
+
allowedTags: RIVET_MARKDOWN_ALLOWED_TAGS,
|
|
6744
|
+
allowedUriRegExpSource: RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE
|
|
6745
|
+
});
|
|
6746
|
+
|
|
6408
6747
|
// src/model/NodeImpl.ts
|
|
6409
6748
|
var NodeImpl = class {
|
|
6410
6749
|
chartNode;
|
|
@@ -6760,8 +7099,7 @@ var processingFunctions = {
|
|
|
6760
7099
|
return input.trim();
|
|
6761
7100
|
},
|
|
6762
7101
|
truncate: (input, length = 50) => {
|
|
6763
|
-
if (input.length <= length)
|
|
6764
|
-
return input;
|
|
7102
|
+
if (input.length <= length) return input;
|
|
6765
7103
|
return input.slice(0, length) + "...";
|
|
6766
7104
|
},
|
|
6767
7105
|
list: (input, level = 1) => {
|
|
@@ -9890,17 +10228,17 @@ async function* streamChatCompletions3({
|
|
|
9890
10228
|
top_k,
|
|
9891
10229
|
prompt
|
|
9892
10230
|
}) {
|
|
9893
|
-
var _a, _b
|
|
10231
|
+
var _a, _b;
|
|
9894
10232
|
const { VertexAI } = await import("@google-cloud/vertexai");
|
|
9895
10233
|
process.env.GOOGLE_APPLICATION_CREDENTIALS = applicationCredentials;
|
|
9896
10234
|
const vertexAi = new VertexAI({ project, location });
|
|
9897
10235
|
const generativeModel = vertexAi.preview.getGenerativeModel({
|
|
9898
10236
|
model,
|
|
9899
|
-
|
|
9900
|
-
max_output_tokens,
|
|
10237
|
+
generationConfig: {
|
|
10238
|
+
maxOutputTokens: max_output_tokens,
|
|
9901
10239
|
temperature,
|
|
9902
|
-
top_p,
|
|
9903
|
-
top_k
|
|
10240
|
+
topP: top_p,
|
|
10241
|
+
topK: top_k
|
|
9904
10242
|
}
|
|
9905
10243
|
});
|
|
9906
10244
|
const response = await generativeModel.generateContentStream({
|
|
@@ -9909,10 +10247,12 @@ async function* streamChatCompletions3({
|
|
|
9909
10247
|
let hadChunks = false;
|
|
9910
10248
|
for await (const chunk of response.stream) {
|
|
9911
10249
|
hadChunks = true;
|
|
9912
|
-
|
|
10250
|
+
const candidate = (_a = chunk.candidates) == null ? void 0 : _a[0];
|
|
10251
|
+
const completion = (_b = candidate == null ? void 0 : candidate.content.parts[0]) == null ? void 0 : _b.text;
|
|
10252
|
+
if (!(signal == null ? void 0 : signal.aborted) && completion) {
|
|
9913
10253
|
yield {
|
|
9914
|
-
completion
|
|
9915
|
-
finish_reason:
|
|
10254
|
+
completion,
|
|
10255
|
+
finish_reason: candidate.finishReason,
|
|
9916
10256
|
model
|
|
9917
10257
|
};
|
|
9918
10258
|
} else {
|
|
@@ -10040,16 +10380,6 @@ function openAIEndpointToBaseURL(endpoint) {
|
|
|
10040
10380
|
function openAICompatibleEndpointToBaseURL(endpoint) {
|
|
10041
10381
|
return openAIEndpointToBaseURL(endpoint);
|
|
10042
10382
|
}
|
|
10043
|
-
function openAIBaseURLToEndpoint(baseURL) {
|
|
10044
|
-
const normalizedBaseURL = removeTrailingSlash(baseURL);
|
|
10045
|
-
try {
|
|
10046
|
-
const url = new URL(normalizedBaseURL);
|
|
10047
|
-
url.pathname = `${url.pathname.replace(/\/$/, "")}/chat/completions`;
|
|
10048
|
-
return url.toString();
|
|
10049
|
-
} catch {
|
|
10050
|
-
return `${normalizedBaseURL}/chat/completions`;
|
|
10051
|
-
}
|
|
10052
|
-
}
|
|
10053
10383
|
function parseBodyText(text) {
|
|
10054
10384
|
try {
|
|
10055
10385
|
return JSON.parse(text);
|
|
@@ -10101,38 +10431,26 @@ function createRequestBodyCapturingFetch(onRequestBody) {
|
|
|
10101
10431
|
function maybeCreateRequestBodyCapturingFetch(options2) {
|
|
10102
10432
|
return options2.onRequestBody == null ? void 0 : createRequestBodyCapturingFetch(options2.onRequestBody);
|
|
10103
10433
|
}
|
|
10104
|
-
async function resolveChatV2ProviderConfig(provider,
|
|
10434
|
+
async function resolveChatV2ProviderConfig(provider, _modelId, context, options2 = {}) {
|
|
10105
10435
|
var _a;
|
|
10106
10436
|
const headers = cleanHeaders({
|
|
10107
10437
|
...context.settings.chatNodeHeaders,
|
|
10108
10438
|
...options2.headers
|
|
10109
10439
|
});
|
|
10110
10440
|
switch (provider) {
|
|
10111
|
-
case "openai":
|
|
10112
|
-
const configuredBaseURL = options2.baseURL ? options2.baseURL : openAIEndpointToBaseURL(context.settings.openAiEndpoint || DEFAULT_CHAT_ENDPOINT);
|
|
10113
|
-
if (context.getChatNodeEndpoint == null) {
|
|
10114
|
-
return {
|
|
10115
|
-
baseURL: configuredBaseURL,
|
|
10116
|
-
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
10117
|
-
};
|
|
10118
|
-
}
|
|
10119
|
-
const resolved = await context.getChatNodeEndpoint(openAIBaseURLToEndpoint(configuredBaseURL), modelId);
|
|
10441
|
+
case "openai":
|
|
10120
10442
|
return {
|
|
10121
|
-
baseURL:
|
|
10122
|
-
headers:
|
|
10123
|
-
...headers,
|
|
10124
|
-
...resolved.headers
|
|
10125
|
-
})
|
|
10443
|
+
baseURL: void 0,
|
|
10444
|
+
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
10126
10445
|
};
|
|
10127
|
-
}
|
|
10128
10446
|
case "anthropic":
|
|
10129
10447
|
return {
|
|
10130
|
-
baseURL:
|
|
10448
|
+
baseURL: void 0,
|
|
10131
10449
|
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
10132
10450
|
};
|
|
10133
10451
|
case "google":
|
|
10134
10452
|
return {
|
|
10135
|
-
baseURL:
|
|
10453
|
+
baseURL: void 0,
|
|
10136
10454
|
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
10137
10455
|
};
|
|
10138
10456
|
case "custom": {
|
|
@@ -10153,7 +10471,7 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
|
|
|
10153
10471
|
const providerInstance = (0, import_openai3.createOpenAI)({
|
|
10154
10472
|
apiKey: options2.apiKey || context.settings.openAiApiKey || context.settings.openAiKey || void 0,
|
|
10155
10473
|
organization: context.settings.openAiOrganization || void 0,
|
|
10156
|
-
baseURL:
|
|
10474
|
+
baseURL: void 0,
|
|
10157
10475
|
headers: options2.headers,
|
|
10158
10476
|
fetch: maybeCreateRequestBodyCapturingFetch(options2)
|
|
10159
10477
|
});
|
|
@@ -10162,7 +10480,7 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
|
|
|
10162
10480
|
case "anthropic": {
|
|
10163
10481
|
const providerInstance = (0, import_anthropic2.createAnthropic)({
|
|
10164
10482
|
apiKey: options2.apiKey || context.settings.anthropicApiKey || context.getPluginConfig("anthropicApiKey") || void 0,
|
|
10165
|
-
baseURL:
|
|
10483
|
+
baseURL: void 0,
|
|
10166
10484
|
headers: options2.headers,
|
|
10167
10485
|
fetch: maybeCreateRequestBodyCapturingFetch(options2)
|
|
10168
10486
|
});
|
|
@@ -10171,7 +10489,7 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
|
|
|
10171
10489
|
case "google": {
|
|
10172
10490
|
const providerInstance = (0, import_google2.createGoogleGenerativeAI)({
|
|
10173
10491
|
apiKey: options2.apiKey || context.settings.googleApiKey || context.getPluginConfig("googleApiKey") || void 0,
|
|
10174
|
-
baseURL:
|
|
10492
|
+
baseURL: void 0,
|
|
10175
10493
|
headers: options2.headers,
|
|
10176
10494
|
fetch: maybeCreateRequestBodyCapturingFetch(options2)
|
|
10177
10495
|
});
|
|
@@ -10222,6 +10540,25 @@ async function getResolvedModelOptions(data, context) {
|
|
|
10222
10540
|
const modelOptions = await ((_a = context.getChatModelOptions) == null ? void 0 : _a.call(context, data.provider).catch(() => void 0)) ?? getChatV2ModelOptions(data.provider);
|
|
10223
10541
|
return modelOptions.some((option) => option.value === data.model) ? modelOptions : [{ value: data.model, label: `${data.model} (Current)` }, ...modelOptions];
|
|
10224
10542
|
}
|
|
10543
|
+
function getApiKeySourceHelperMessage(data) {
|
|
10544
|
+
var _a, _b;
|
|
10545
|
+
if (data.apiKeySource === "input") {
|
|
10546
|
+
return "Uses the API Key input port instead of a configured provider key.";
|
|
10547
|
+
}
|
|
10548
|
+
switch (data.provider) {
|
|
10549
|
+
case "openai":
|
|
10550
|
+
return "Configured key uses Settings > LLM > OpenAI API Key in the Rivet editor, with OPENAI_API_KEY as a desktop/Node fallback. Programmatic runs can pass openAiApiKey or set OPENAI_API_KEY.";
|
|
10551
|
+
case "anthropic":
|
|
10552
|
+
return "Configured key uses Settings > LLM > Anthropic API Key in the Rivet editor, with ANTHROPIC_API_KEY as a desktop/Node fallback. Programmatic runs can pass anthropicApiKey or set ANTHROPIC_API_KEY.";
|
|
10553
|
+
case "google":
|
|
10554
|
+
return "Configured key uses Settings > LLM > Google API Key in the Rivet editor, with GOOGLE_GENERATIVE_AI_API_KEY as a desktop/Node fallback. Programmatic runs can pass googleApiKey or set GOOGLE_GENERATIVE_AI_API_KEY.";
|
|
10555
|
+
case "custom": {
|
|
10556
|
+
const programmaticName = (_a = data.customProviderApiKeyProgrammaticName) == null ? void 0 : _a.trim();
|
|
10557
|
+
const envVarName = ((_b = data.customProviderApiKeyEnvVarName) == null ? void 0 : _b.trim()) || "CUSTOM_PROVIDER_API_KEY";
|
|
10558
|
+
return programmaticName ? `Configured key checks ${programmaticName}, then ${envVarName} env var, then Settings > LLM > Custom provider API key.` : `Configured key checks ${envVarName} env var, then Settings > LLM > Custom provider API key. Programmatic runs can pass the shared customAiApiKey.`;
|
|
10559
|
+
}
|
|
10560
|
+
}
|
|
10561
|
+
}
|
|
10225
10562
|
function getModelEditors(modelOptions) {
|
|
10226
10563
|
return group(
|
|
10227
10564
|
"Model",
|
|
@@ -10259,14 +10596,22 @@ function getModelEditors(modelOptions) {
|
|
|
10259
10596
|
{ value: "environment", label: "Configured key" },
|
|
10260
10597
|
{ value: "input", label: "Input port" }
|
|
10261
10598
|
],
|
|
10262
|
-
helperMessage:
|
|
10599
|
+
helperMessage: getApiKeySourceHelperMessage
|
|
10600
|
+
},
|
|
10601
|
+
{
|
|
10602
|
+
type: "string",
|
|
10603
|
+
label: "Alternative programmatic key name",
|
|
10604
|
+
dataKey: "customProviderApiKeyProgrammaticName",
|
|
10605
|
+
placeholder: "cerebrasApiKey",
|
|
10606
|
+
helperMessage: "If set, programmatic runs read this named run option instead of the shared customAiApiKey.",
|
|
10607
|
+
hideIf: (data) => data.provider !== "custom" || data.apiKeySource === "input"
|
|
10263
10608
|
},
|
|
10264
10609
|
{
|
|
10265
10610
|
type: "string",
|
|
10266
|
-
label: "API key env var
|
|
10611
|
+
label: "Alternative API key env var",
|
|
10267
10612
|
dataKey: "customProviderApiKeyEnvVarName",
|
|
10268
10613
|
placeholder: "CUSTOM_PROVIDER_API_KEY",
|
|
10269
|
-
helperMessage: "
|
|
10614
|
+
helperMessage: "If set, this env var is used instead of CUSTOM_PROVIDER_API_KEY.",
|
|
10270
10615
|
hideIf: (data) => data.provider !== "custom" || data.apiKeySource === "input"
|
|
10271
10616
|
}
|
|
10272
10617
|
],
|
|
@@ -10599,14 +10944,6 @@ function getOutputEditors() {
|
|
|
10599
10944
|
}
|
|
10600
10945
|
function getProviderAdvancedEditors() {
|
|
10601
10946
|
return group("Provider Advanced", [
|
|
10602
|
-
{
|
|
10603
|
-
type: "string",
|
|
10604
|
-
label: "Base URL",
|
|
10605
|
-
dataKey: "baseURL",
|
|
10606
|
-
useInputToggleDataKey: "useBaseURLInput",
|
|
10607
|
-
placeholder: "Optional provider base URL override",
|
|
10608
|
-
hideIf: (data) => data.provider === "custom"
|
|
10609
|
-
},
|
|
10610
10947
|
{
|
|
10611
10948
|
type: "keyValuePair",
|
|
10612
10949
|
label: "Headers",
|
|
@@ -10686,6 +11023,7 @@ function createLLMChatV2NodeData() {
|
|
|
10686
11023
|
}),
|
|
10687
11024
|
provider: "openai",
|
|
10688
11025
|
apiKeySource: "environment",
|
|
11026
|
+
customProviderApiKeyProgrammaticName: "",
|
|
10689
11027
|
customProviderApiKeyEnvVarName: "CUSTOM_PROVIDER_API_KEY",
|
|
10690
11028
|
customProviderBaseURL: "",
|
|
10691
11029
|
useCustomProviderBaseURLInput: false,
|
|
@@ -10886,6 +11224,102 @@ function createsLLMChatV2ToolResponseFormatConflictForEdit(previousData, nextDat
|
|
|
10886
11224
|
return hasLLMChatV2ToolResponseFormatConflict(nextData) && !hasLLMChatV2ToolResponseFormatConflict(previousData);
|
|
10887
11225
|
}
|
|
10888
11226
|
|
|
11227
|
+
// src/model/chat-v2/chatV2ProviderProfile.ts
|
|
11228
|
+
function getStringSetting(settings, key) {
|
|
11229
|
+
const value = settings[key];
|
|
11230
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
11231
|
+
}
|
|
11232
|
+
function resolveConfiguredCredential(provider, context, options2) {
|
|
11233
|
+
var _a, _b, _c, _d, _e;
|
|
11234
|
+
switch (provider) {
|
|
11235
|
+
case "openai": {
|
|
11236
|
+
const value = context.settings.openAiApiKey || context.settings.openAiKey || void 0;
|
|
11237
|
+
return { value, reference: { source: value ? "settings" : "none" } };
|
|
11238
|
+
}
|
|
11239
|
+
case "anthropic": {
|
|
11240
|
+
const settingsValue = context.settings.anthropicApiKey || void 0;
|
|
11241
|
+
if (settingsValue) return { value: settingsValue, reference: { source: "settings" } };
|
|
11242
|
+
const pluginValue = context.getPluginConfig("anthropicApiKey") || void 0;
|
|
11243
|
+
return { value: pluginValue, reference: { source: pluginValue ? "plugin" : "none" } };
|
|
11244
|
+
}
|
|
11245
|
+
case "google": {
|
|
11246
|
+
const settingsValue = context.settings.googleApiKey || void 0;
|
|
11247
|
+
if (settingsValue) return { value: settingsValue, reference: { source: "settings" } };
|
|
11248
|
+
const pluginValue = context.getPluginConfig("googleApiKey") || void 0;
|
|
11249
|
+
return { value: pluginValue, reference: { source: pluginValue ? "plugin" : "none" } };
|
|
11250
|
+
}
|
|
11251
|
+
case "custom": {
|
|
11252
|
+
const programmaticName = (_a = options2.customProgrammaticName) == null ? void 0 : _a.trim();
|
|
11253
|
+
const environmentName = (_b = options2.customEnvironmentName) == null ? void 0 : _b.trim();
|
|
11254
|
+
const programmaticValue = programmaticName ? getStringSetting(context.settings, programmaticName) : void 0;
|
|
11255
|
+
if (programmaticValue) {
|
|
11256
|
+
return {
|
|
11257
|
+
value: programmaticValue,
|
|
11258
|
+
reference: { source: "programmatic", name: programmaticName }
|
|
11259
|
+
};
|
|
11260
|
+
}
|
|
11261
|
+
if (environmentName) {
|
|
11262
|
+
const pluginEnvValue = (_c = context.settings.pluginEnv) == null ? void 0 : _c[environmentName];
|
|
11263
|
+
if (pluginEnvValue) {
|
|
11264
|
+
return { value: pluginEnvValue, reference: { source: "environment", name: environmentName } };
|
|
11265
|
+
}
|
|
11266
|
+
const processValue = (_e = (_d = globalThis.process) == null ? void 0 : _d.env) == null ? void 0 : _e[environmentName];
|
|
11267
|
+
if (processValue) {
|
|
11268
|
+
return { value: processValue, reference: { source: "environment", name: environmentName } };
|
|
11269
|
+
}
|
|
11270
|
+
}
|
|
11271
|
+
const value = context.settings.customAiApiKey || void 0;
|
|
11272
|
+
if (value) return { value, reference: { source: "settings" } };
|
|
11273
|
+
const missing = [
|
|
11274
|
+
programmaticName ? `programmatic key ${programmaticName}` : void 0,
|
|
11275
|
+
environmentName ? `env var ${environmentName}` : void 0
|
|
11276
|
+
].filter(Boolean);
|
|
11277
|
+
if (missing.length > 0) {
|
|
11278
|
+
const hint = programmaticName ? `pass ${programmaticName}` : "set Alternative programmatic key name and pass that named run option";
|
|
11279
|
+
throw new Error(
|
|
11280
|
+
`Custom provider API key ${missing.join(" and ")} is not set. Use Input port, configure Settings > LLM, ${hint}, or configure the environment variable.`
|
|
11281
|
+
);
|
|
11282
|
+
}
|
|
11283
|
+
return { reference: { source: "none" } };
|
|
11284
|
+
}
|
|
11285
|
+
}
|
|
11286
|
+
}
|
|
11287
|
+
function resolveChatV2Credential(options2) {
|
|
11288
|
+
var _a, _b;
|
|
11289
|
+
if (options2.apiKeySource === "input") {
|
|
11290
|
+
const value = (_b = coerceTypeOptional((_a = options2.inputs) == null ? void 0 : _a["apiKey"], "string")) == null ? void 0 : _b.trim();
|
|
11291
|
+
if (!value) throw new Error("API Key input is required when API key source is Input port.");
|
|
11292
|
+
return { value, reference: { source: "input" } };
|
|
11293
|
+
}
|
|
11294
|
+
return resolveConfiguredCredential(options2.provider, options2.context, options2);
|
|
11295
|
+
}
|
|
11296
|
+
async function createResolvedChatV2Provider(options2) {
|
|
11297
|
+
const config = await resolveChatV2ProviderConfig(options2.provider, options2.modelId, options2.context, {
|
|
11298
|
+
baseURL: options2.baseURL,
|
|
11299
|
+
headers: options2.headers
|
|
11300
|
+
});
|
|
11301
|
+
const model = createChatV2Model(options2.provider, options2.modelId, options2.context, {
|
|
11302
|
+
...config,
|
|
11303
|
+
apiKey: options2.credential.value,
|
|
11304
|
+
onRequestBody: options2.onRequestBody
|
|
11305
|
+
});
|
|
11306
|
+
return {
|
|
11307
|
+
profile: {
|
|
11308
|
+
provider: options2.provider,
|
|
11309
|
+
modelId: options2.modelId,
|
|
11310
|
+
baseURL: config.baseURL,
|
|
11311
|
+
hasCustomHeaders: Object.keys(config.headers ?? {}).length > 0,
|
|
11312
|
+
credential: options2.credential.reference,
|
|
11313
|
+
capabilities: {
|
|
11314
|
+
builtInTools: options2.provider === "openai" || options2.provider === "google",
|
|
11315
|
+
structuredOutput: true
|
|
11316
|
+
}
|
|
11317
|
+
},
|
|
11318
|
+
model,
|
|
11319
|
+
config
|
|
11320
|
+
};
|
|
11321
|
+
}
|
|
11322
|
+
|
|
10889
11323
|
// src/model/chat-v2/chatV2EditorCache.ts
|
|
10890
11324
|
var import_safe_stable_stringify4 = __toESM(require("safe-stable-stringify"), 1);
|
|
10891
11325
|
function buildLLMChatV2EditorCacheKey(parts) {
|
|
@@ -10950,8 +11384,8 @@ function fingerprintNodeDataForCache(data) {
|
|
|
10950
11384
|
const isCustomProvider = data.provider === "custom";
|
|
10951
11385
|
return {
|
|
10952
11386
|
...data,
|
|
10953
|
-
baseURL:
|
|
10954
|
-
useBaseURLInput:
|
|
11387
|
+
baseURL: "",
|
|
11388
|
+
useBaseURLInput: false,
|
|
10955
11389
|
customProviderBaseURL: isCustomProvider ? data.customProviderBaseURL : "",
|
|
10956
11390
|
useCustomProviderBaseURLInput: isCustomProvider ? data.useCustomProviderBaseURLInput : false,
|
|
10957
11391
|
extraProviderOptions: data.useExtraProviderOptionsInput ? "" : fingerprintSecret(data.extraProviderOptions) ?? "",
|
|
@@ -11001,48 +11435,6 @@ function resolveLLMChatV2Headers(data, inputs) {
|
|
|
11001
11435
|
const cleaned = cleanHeaders(resolvedHeaders ?? {});
|
|
11002
11436
|
return Object.keys(cleaned).length > 0 ? cleaned : void 0;
|
|
11003
11437
|
}
|
|
11004
|
-
function resolveConfiguredProviderApiKey(data, context) {
|
|
11005
|
-
var _a, _b, _c;
|
|
11006
|
-
switch (data.provider) {
|
|
11007
|
-
case "openai":
|
|
11008
|
-
return context.settings.openAiApiKey || context.settings.openAiKey || void 0;
|
|
11009
|
-
case "anthropic":
|
|
11010
|
-
return context.settings.anthropicApiKey || context.getPluginConfig("anthropicApiKey") || void 0;
|
|
11011
|
-
case "google":
|
|
11012
|
-
return context.settings.googleApiKey || context.getPluginConfig("googleApiKey") || void 0;
|
|
11013
|
-
case "custom": {
|
|
11014
|
-
const envVarName = (_a = data.customProviderApiKeyEnvVarName) == null ? void 0 : _a.trim();
|
|
11015
|
-
if (envVarName) {
|
|
11016
|
-
const pluginEnvValue = (_b = context.settings.pluginEnv) == null ? void 0 : _b[envVarName];
|
|
11017
|
-
const processEnv = (_c = globalThis.process) == null ? void 0 : _c.env;
|
|
11018
|
-
const apiKey = pluginEnvValue || (processEnv == null ? void 0 : processEnv[envVarName]);
|
|
11019
|
-
if (apiKey) {
|
|
11020
|
-
return apiKey;
|
|
11021
|
-
}
|
|
11022
|
-
}
|
|
11023
|
-
if (context.settings.customAiApiKey) {
|
|
11024
|
-
return context.settings.customAiApiKey;
|
|
11025
|
-
}
|
|
11026
|
-
if (envVarName) {
|
|
11027
|
-
throw new Error(
|
|
11028
|
-
`Custom provider API key env var ${envVarName} is not set. Use Input port, configure Settings > LLM, or configure the environment variable.`
|
|
11029
|
-
);
|
|
11030
|
-
}
|
|
11031
|
-
return void 0;
|
|
11032
|
-
}
|
|
11033
|
-
}
|
|
11034
|
-
}
|
|
11035
|
-
function resolveLLMChatV2ApiKey(data, inputs, context) {
|
|
11036
|
-
var _a;
|
|
11037
|
-
if (data.apiKeySource !== "input") {
|
|
11038
|
-
return resolveConfiguredProviderApiKey(data, context);
|
|
11039
|
-
}
|
|
11040
|
-
const apiKey = (_a = coerceTypeOptional(inputs["apiKey"], "string")) == null ? void 0 : _a.trim();
|
|
11041
|
-
if (!apiKey) {
|
|
11042
|
-
throw new Error("API Key input is required when API key source is Input port.");
|
|
11043
|
-
}
|
|
11044
|
-
return apiKey;
|
|
11045
|
-
}
|
|
11046
11438
|
function parseExtraProviderOptionsText(rawText) {
|
|
11047
11439
|
const raw = rawText.trim();
|
|
11048
11440
|
if (!raw) {
|
|
@@ -11188,7 +11580,7 @@ function resolveLLMChatV2BuiltInTools(data, context, config, apiKey) {
|
|
|
11188
11580
|
const provider = (0, import_openai4.createOpenAI)({
|
|
11189
11581
|
apiKey: apiKey || context.settings.openAiApiKey || context.settings.openAiKey || void 0,
|
|
11190
11582
|
organization: context.settings.openAiOrganization || void 0,
|
|
11191
|
-
baseURL:
|
|
11583
|
+
baseURL: void 0,
|
|
11192
11584
|
headers: config.headers
|
|
11193
11585
|
});
|
|
11194
11586
|
const tools = {};
|
|
@@ -11208,7 +11600,7 @@ function resolveLLMChatV2BuiltInTools(data, context, config, apiKey) {
|
|
|
11208
11600
|
}
|
|
11209
11601
|
const provider = (0, import_google3.createGoogleGenerativeAI)({
|
|
11210
11602
|
apiKey: apiKey || context.settings.googleApiKey || context.getPluginConfig("googleApiKey") || void 0,
|
|
11211
|
-
baseURL:
|
|
11603
|
+
baseURL: void 0,
|
|
11212
11604
|
headers: config.headers
|
|
11213
11605
|
});
|
|
11214
11606
|
const tools = {};
|
|
@@ -11229,8 +11621,8 @@ function resolveLLMChatV2BuiltInTools(data, context, config, apiKey) {
|
|
|
11229
11621
|
|
|
11230
11622
|
// src/model/chat-v2/llmChatV2NodeRuntime.ts
|
|
11231
11623
|
function resolveLLMChatV2BaseURL(data, inputs) {
|
|
11232
|
-
var _a
|
|
11233
|
-
return data.provider === "custom" ? ((_a = getInputOrData(data, inputs, "customProviderBaseURL", "string", "useCustomProviderBaseURLInput")) == null ? void 0 : _a.trim()) || void 0 :
|
|
11624
|
+
var _a;
|
|
11625
|
+
return data.provider === "custom" ? ((_a = getInputOrData(data, inputs, "customProviderBaseURL", "string", "useCustomProviderBaseURLInput")) == null ? void 0 : _a.trim()) || void 0 : void 0;
|
|
11234
11626
|
}
|
|
11235
11627
|
async function resolveLLMChatV2RuntimeConfig(params) {
|
|
11236
11628
|
const { data, nodeId, inputs, context } = params;
|
|
@@ -11241,17 +11633,27 @@ async function resolveLLMChatV2RuntimeConfig(params) {
|
|
|
11241
11633
|
const modelId = getInputOrData(data, inputs, "model", "string");
|
|
11242
11634
|
const baseURL = resolveLLMChatV2BaseURL(data, inputs);
|
|
11243
11635
|
const nodeHeaders = resolveLLMChatV2Headers(data, inputs);
|
|
11244
|
-
const
|
|
11636
|
+
const credential = resolveChatV2Credential({
|
|
11637
|
+
provider,
|
|
11638
|
+
context,
|
|
11639
|
+
apiKeySource: data.apiKeySource === "input" ? "input" : "configured",
|
|
11640
|
+
inputs,
|
|
11641
|
+
customProgrammaticName: data.customProviderApiKeyProgrammaticName,
|
|
11642
|
+
customEnvironmentName: data.customProviderApiKeyEnvVarName
|
|
11643
|
+
});
|
|
11644
|
+
const apiKey = credential.value;
|
|
11245
11645
|
const requestBodies = data.outputRequestStatus ? [] : void 0;
|
|
11246
|
-
const
|
|
11646
|
+
const resolvedProvider = await createResolvedChatV2Provider({
|
|
11647
|
+
provider,
|
|
11648
|
+
modelId,
|
|
11649
|
+
context,
|
|
11247
11650
|
baseURL,
|
|
11248
|
-
headers: nodeHeaders
|
|
11249
|
-
|
|
11250
|
-
const model = createChatV2Model(provider, modelId, context, {
|
|
11251
|
-
...providerConfig,
|
|
11252
|
-
apiKey,
|
|
11651
|
+
headers: nodeHeaders,
|
|
11652
|
+
credential,
|
|
11253
11653
|
onRequestBody: requestBodies == null ? void 0 : (body) => requestBodies.push(body)
|
|
11254
11654
|
});
|
|
11655
|
+
const providerConfig = resolvedProvider.config;
|
|
11656
|
+
const model = resolvedProvider.model;
|
|
11255
11657
|
const prompt = inputs["prompt"];
|
|
11256
11658
|
const systemPrompt = inputs["systemPrompt"];
|
|
11257
11659
|
const functions = data.useToolCalling && inputs["functions"] != null ? coerceTypeOptional(inputs["functions"], "gpt-function[]") : void 0;
|
|
@@ -11306,6 +11708,7 @@ async function resolveLLMChatV2RuntimeConfig(params) {
|
|
|
11306
11708
|
toolChoice
|
|
11307
11709
|
});
|
|
11308
11710
|
return {
|
|
11711
|
+
providerProfile: resolvedProvider.profile,
|
|
11309
11712
|
runOptions,
|
|
11310
11713
|
functions,
|
|
11311
11714
|
cacheKey,
|
|
@@ -11494,34 +11897,21 @@ function buildTextArgs(options2) {
|
|
|
11494
11897
|
const args = {
|
|
11495
11898
|
model: options2.model,
|
|
11496
11899
|
messages: options2.messages,
|
|
11497
|
-
maxRetries: 0
|
|
11900
|
+
maxRetries: options2.maxRetries ?? 0
|
|
11498
11901
|
};
|
|
11499
|
-
if (options2.tools !== void 0)
|
|
11500
|
-
|
|
11501
|
-
if (options2.
|
|
11502
|
-
|
|
11503
|
-
if (options2.
|
|
11504
|
-
|
|
11505
|
-
if (options2.
|
|
11506
|
-
|
|
11507
|
-
if (options2.
|
|
11508
|
-
|
|
11509
|
-
if (options2.
|
|
11510
|
-
|
|
11511
|
-
if (options2.
|
|
11512
|
-
args.frequencyPenalty = options2.frequencyPenalty;
|
|
11513
|
-
if (options2.stopSequences !== void 0)
|
|
11514
|
-
args.stopSequences = options2.stopSequences;
|
|
11515
|
-
if (options2.seed !== void 0)
|
|
11516
|
-
args.seed = options2.seed;
|
|
11517
|
-
if (options2.responseOutput !== void 0)
|
|
11518
|
-
args.output = options2.responseOutput;
|
|
11519
|
-
if (options2.providerOptions !== void 0)
|
|
11520
|
-
args.providerOptions = options2.providerOptions;
|
|
11521
|
-
if (options2.toolChoice !== void 0)
|
|
11522
|
-
args.toolChoice = options2.toolChoice;
|
|
11523
|
-
if (options2.abortSignal !== void 0)
|
|
11524
|
-
args.abortSignal = options2.abortSignal;
|
|
11902
|
+
if (options2.tools !== void 0) args.tools = options2.tools;
|
|
11903
|
+
if (options2.maxTokens !== void 0) args.maxOutputTokens = options2.maxTokens;
|
|
11904
|
+
if (options2.temperature !== void 0) args.temperature = options2.temperature;
|
|
11905
|
+
if (options2.topP !== void 0) args.topP = options2.topP;
|
|
11906
|
+
if (options2.topK !== void 0) args.topK = options2.topK;
|
|
11907
|
+
if (options2.presencePenalty !== void 0) args.presencePenalty = options2.presencePenalty;
|
|
11908
|
+
if (options2.frequencyPenalty !== void 0) args.frequencyPenalty = options2.frequencyPenalty;
|
|
11909
|
+
if (options2.stopSequences !== void 0) args.stopSequences = options2.stopSequences;
|
|
11910
|
+
if (options2.seed !== void 0) args.seed = options2.seed;
|
|
11911
|
+
if (options2.responseOutput !== void 0) args.output = options2.responseOutput;
|
|
11912
|
+
if (options2.providerOptions !== void 0) args.providerOptions = options2.providerOptions;
|
|
11913
|
+
if (options2.toolChoice !== void 0) args.toolChoice = options2.toolChoice;
|
|
11914
|
+
if (options2.abortSignal !== void 0) args.abortSignal = options2.abortSignal;
|
|
11525
11915
|
return args;
|
|
11526
11916
|
}
|
|
11527
11917
|
function toStreamedFunctionCalls(toolCalls) {
|
|
@@ -11682,8 +12072,7 @@ async function partToUserContent(part, options2) {
|
|
|
11682
12072
|
function stringifyParts(parts) {
|
|
11683
12073
|
const arr = Array.isArray(parts) ? parts : [parts];
|
|
11684
12074
|
return arr.map((p) => {
|
|
11685
|
-
if (typeof p === "string")
|
|
11686
|
-
return p;
|
|
12075
|
+
if (typeof p === "string") return p;
|
|
11687
12076
|
throw new Error(`Expected string content, got ${p.type}`);
|
|
11688
12077
|
}).join("\n\n");
|
|
11689
12078
|
}
|
|
@@ -11809,6 +12198,69 @@ function chatV2ToolsToAiSdk(functions) {
|
|
|
11809
12198
|
return rivetToolsToAiSdk(functions);
|
|
11810
12199
|
}
|
|
11811
12200
|
|
|
12201
|
+
// src/model/chat-v2/chatV2RequestPlan.ts
|
|
12202
|
+
function buildChatV2RequestPlan(options2) {
|
|
12203
|
+
const shouldStream = options2.emitPartialOutputs !== false;
|
|
12204
|
+
return {
|
|
12205
|
+
provider: options2.provider,
|
|
12206
|
+
modelId: options2.modelId,
|
|
12207
|
+
transportMode: shouldStream ? "stream" : "generate",
|
|
12208
|
+
retry: {
|
|
12209
|
+
enabled: options2.retryOnNon200 === true,
|
|
12210
|
+
repeatTimes: options2.retryOnNon200 ? normalizeLLMChatV2RetryCount(options2.retryOnNon200RepeatTimes) : 0,
|
|
12211
|
+
cooldownMs: normalizeLLMChatV2RetryCooldownMs(options2.retryOnNon200CooldownMs)
|
|
12212
|
+
},
|
|
12213
|
+
request: {
|
|
12214
|
+
model: options2.model,
|
|
12215
|
+
messages: options2.messages,
|
|
12216
|
+
maxRetries: 0,
|
|
12217
|
+
tools: options2.tools,
|
|
12218
|
+
maxTokens: options2.maxTokens,
|
|
12219
|
+
temperature: options2.temperature,
|
|
12220
|
+
topP: options2.topP,
|
|
12221
|
+
topK: options2.topK,
|
|
12222
|
+
presencePenalty: options2.presencePenalty,
|
|
12223
|
+
frequencyPenalty: options2.frequencyPenalty,
|
|
12224
|
+
stopSequences: options2.stopSequences,
|
|
12225
|
+
seed: options2.seed,
|
|
12226
|
+
responseOutput: options2.responseOutput,
|
|
12227
|
+
responseFormat: options2.responseFormat,
|
|
12228
|
+
providerOptions: options2.providerOptions,
|
|
12229
|
+
toolChoice: options2.toolChoice
|
|
12230
|
+
},
|
|
12231
|
+
output: {
|
|
12232
|
+
outputUsage: options2.outputUsage,
|
|
12233
|
+
outputReasoning: options2.outputReasoning,
|
|
12234
|
+
outputRequestStatus: options2.outputRequestStatus,
|
|
12235
|
+
includeFunctionCalls: options2.includeFunctionCalls,
|
|
12236
|
+
functionCallMode: options2.functionCallMode
|
|
12237
|
+
}
|
|
12238
|
+
};
|
|
12239
|
+
}
|
|
12240
|
+
function summarizeChatV2RequestPlan(plan) {
|
|
12241
|
+
return {
|
|
12242
|
+
provider: plan.provider,
|
|
12243
|
+
modelId: plan.modelId,
|
|
12244
|
+
transportMode: plan.transportMode,
|
|
12245
|
+
sdkMaxRetries: plan.request.maxRetries ?? 0,
|
|
12246
|
+
retry: { ...plan.retry },
|
|
12247
|
+
messageCount: plan.request.messages.length,
|
|
12248
|
+
toolNames: Object.keys(plan.request.tools ?? {}).sort(),
|
|
12249
|
+
responseFormat: plan.request.responseFormat,
|
|
12250
|
+
generation: {
|
|
12251
|
+
maxTokens: plan.request.maxTokens,
|
|
12252
|
+
temperature: plan.request.temperature,
|
|
12253
|
+
topP: plan.request.topP,
|
|
12254
|
+
topK: plan.request.topK,
|
|
12255
|
+
presencePenalty: plan.request.presencePenalty,
|
|
12256
|
+
frequencyPenalty: plan.request.frequencyPenalty,
|
|
12257
|
+
stopSequences: plan.request.stopSequences,
|
|
12258
|
+
seed: plan.request.seed
|
|
12259
|
+
},
|
|
12260
|
+
output: { ...plan.output }
|
|
12261
|
+
};
|
|
12262
|
+
}
|
|
12263
|
+
|
|
11812
12264
|
// src/model/chat-v2/chatV2Errors.ts
|
|
11813
12265
|
var STATUS_TEXT = {
|
|
11814
12266
|
400: "Bad Request",
|
|
@@ -12290,43 +12742,41 @@ function normalizeProviderFailureMessage(error, options2) {
|
|
|
12290
12742
|
function normalizeProviderFailureMessages(errors, options2) {
|
|
12291
12743
|
return errors.map((error) => normalizeProviderFailureMessage(error, options2));
|
|
12292
12744
|
}
|
|
12293
|
-
async function runChatV2WithRetry(chatOptions,
|
|
12294
|
-
const repeatTimes = retryOptions.retryOnNon200 ? normalizeLLMChatV2RetryCount(retryOptions.retryOnNon200RepeatTimes) : 0;
|
|
12295
|
-
const cooldownMs = normalizeLLMChatV2RetryCooldownMs(retryOptions.retryOnNon200CooldownMs);
|
|
12745
|
+
async function runChatV2WithRetry(chatOptions, retryPlan, signal, transportMode) {
|
|
12296
12746
|
const requestStatuses = [];
|
|
12297
12747
|
const requestErrors = [];
|
|
12298
12748
|
for (let attempt = 0; ; attempt++) {
|
|
12299
12749
|
try {
|
|
12300
12750
|
const result = transportMode === "generate" ? await generateChatV2(chatOptions) : await streamChatV2(chatOptions);
|
|
12301
12751
|
const statusCode = result.requestStatus ?? 200;
|
|
12302
|
-
if (
|
|
12752
|
+
if (retryPlan.enabled) {
|
|
12303
12753
|
requestStatuses.push(statusCode);
|
|
12304
12754
|
}
|
|
12305
|
-
if (!
|
|
12755
|
+
if (!retryPlan.enabled || statusCode === 200) {
|
|
12306
12756
|
return { result, requestStatuses, requestErrors };
|
|
12307
12757
|
}
|
|
12308
12758
|
const responseError = buildNon200StatusError(statusCode);
|
|
12309
12759
|
requestErrors.push(responseError);
|
|
12310
|
-
if (attempt >= repeatTimes) {
|
|
12760
|
+
if (attempt >= retryPlan.repeatTimes) {
|
|
12311
12761
|
return { result, requestStatuses, requestErrors, responseError };
|
|
12312
12762
|
}
|
|
12313
|
-
await waitForLLMChatV2RetryCooldown(cooldownMs,
|
|
12763
|
+
await waitForLLMChatV2RetryCooldown(retryPlan.cooldownMs, signal);
|
|
12314
12764
|
} catch (error) {
|
|
12315
12765
|
const statusCode = getChatV2ProviderErrorStatusCode(error);
|
|
12316
|
-
if (!
|
|
12766
|
+
if (!retryPlan.enabled || statusCode == null || statusCode === 200) {
|
|
12317
12767
|
throw error;
|
|
12318
12768
|
}
|
|
12319
12769
|
requestStatuses.push(statusCode);
|
|
12320
12770
|
requestErrors.push(error);
|
|
12321
|
-
if (attempt >= repeatTimes) {
|
|
12771
|
+
if (attempt >= retryPlan.repeatTimes) {
|
|
12322
12772
|
throw new ChatV2RetryFailure(error, requestStatuses, requestErrors);
|
|
12323
12773
|
}
|
|
12324
|
-
await waitForLLMChatV2RetryCooldown(cooldownMs,
|
|
12774
|
+
await waitForLLMChatV2RetryCooldown(retryPlan.cooldownMs, signal);
|
|
12325
12775
|
}
|
|
12326
12776
|
}
|
|
12327
12777
|
}
|
|
12328
|
-
function buildProviderFailureResult(requestMessages, options2, normalizedError, rawError, requestStatuses, requestErrors) {
|
|
12329
|
-
if (!
|
|
12778
|
+
function buildProviderFailureResult(requestMessages, options2, plan, normalizedError, rawError, requestStatuses, requestErrors) {
|
|
12779
|
+
if (!plan.output.outputRequestStatus) {
|
|
12330
12780
|
return void 0;
|
|
12331
12781
|
}
|
|
12332
12782
|
const statusCode = getChatV2ProviderErrorStatusCode(normalizedError);
|
|
@@ -12334,8 +12784,8 @@ function buildProviderFailureResult(requestMessages, options2, normalizedError,
|
|
|
12334
12784
|
return void 0;
|
|
12335
12785
|
}
|
|
12336
12786
|
const responseError = getProviderFailureMessage(normalizedError);
|
|
12337
|
-
const retryRequestStatuses =
|
|
12338
|
-
const retryRequestErrors =
|
|
12787
|
+
const retryRequestStatuses = plan.retry.enabled ? requestStatuses.length > 0 ? requestStatuses : statusCode == null ? [] : [statusCode] : [];
|
|
12788
|
+
const retryRequestErrors = plan.retry.enabled ? requestErrors.length > 0 ? requestErrors : [responseError] : [];
|
|
12339
12789
|
const commonOutputs = createChatV2ProviderFailureOutputs({
|
|
12340
12790
|
requestMessages,
|
|
12341
12791
|
responseStatus: statusCode,
|
|
@@ -12343,10 +12793,10 @@ function buildProviderFailureResult(requestMessages, options2, normalizedError,
|
|
|
12343
12793
|
requestStatuses: retryRequestStatuses,
|
|
12344
12794
|
requestErrors: retryRequestErrors,
|
|
12345
12795
|
requestBodies: options2.requestBodies,
|
|
12346
|
-
outputUsage:
|
|
12347
|
-
outputReasoning:
|
|
12348
|
-
includeFunctionCalls:
|
|
12349
|
-
retryOnNon200:
|
|
12796
|
+
outputUsage: plan.output.outputUsage,
|
|
12797
|
+
outputReasoning: plan.output.outputReasoning,
|
|
12798
|
+
includeFunctionCalls: plan.output.includeFunctionCalls,
|
|
12799
|
+
retryOnNon200: plan.retry.enabled
|
|
12350
12800
|
});
|
|
12351
12801
|
const allMessagesOutput = commonOutputs["all-messages"];
|
|
12352
12802
|
if ((allMessagesOutput == null ? void 0 : allMessagesOutput.type) !== "chat-message[]") {
|
|
@@ -12377,25 +12827,15 @@ async function runChatV2Pipeline(options2) {
|
|
|
12377
12827
|
});
|
|
12378
12828
|
const functionTools = options2.functions != null && options2.functions.length > 0 ? chatV2ToolsToAiSdk(options2.functions) : void 0;
|
|
12379
12829
|
const tools = functionTools == null ? options2.additionalTools : options2.additionalTools == null ? functionTools : { ...functionTools, ...options2.additionalTools };
|
|
12380
|
-
const
|
|
12381
|
-
|
|
12830
|
+
const plan = buildChatV2RequestPlan({
|
|
12831
|
+
...options2,
|
|
12832
|
+
messages: modelMessages,
|
|
12833
|
+
tools
|
|
12834
|
+
});
|
|
12835
|
+
const shouldStreamResponse = plan.transportMode === "stream";
|
|
12382
12836
|
const chatResponse = await runChatV2WithRetry(
|
|
12383
12837
|
{
|
|
12384
|
-
|
|
12385
|
-
messages: modelMessages,
|
|
12386
|
-
tools,
|
|
12387
|
-
maxTokens: options2.maxTokens,
|
|
12388
|
-
temperature: options2.temperature,
|
|
12389
|
-
topP: options2.topP,
|
|
12390
|
-
topK: options2.topK,
|
|
12391
|
-
presencePenalty: options2.presencePenalty,
|
|
12392
|
-
frequencyPenalty: options2.frequencyPenalty,
|
|
12393
|
-
stopSequences: options2.stopSequences,
|
|
12394
|
-
seed: options2.seed,
|
|
12395
|
-
responseOutput: options2.responseOutput,
|
|
12396
|
-
responseFormat: options2.responseFormat,
|
|
12397
|
-
providerOptions: options2.providerOptions,
|
|
12398
|
-
toolChoice: options2.toolChoice,
|
|
12838
|
+
...plan.request,
|
|
12399
12839
|
abortSignal: options2.context.signal,
|
|
12400
12840
|
executeStream: options2.executeStream,
|
|
12401
12841
|
executeGenerate: options2.executeGenerate,
|
|
@@ -12418,16 +12858,17 @@ async function runChatV2Pipeline(options2) {
|
|
|
12418
12858
|
outputUsage: false,
|
|
12419
12859
|
outputReasoning: false,
|
|
12420
12860
|
outputRequestStatus: false,
|
|
12421
|
-
includeFunctionCalls:
|
|
12422
|
-
functionCallMode:
|
|
12861
|
+
includeFunctionCalls: plan.output.includeFunctionCalls,
|
|
12862
|
+
functionCallMode: plan.output.functionCallMode,
|
|
12423
12863
|
retryOnNon200: false,
|
|
12424
12864
|
responseFormat: void 0
|
|
12425
12865
|
})
|
|
12426
12866
|
);
|
|
12427
12867
|
}
|
|
12428
12868
|
},
|
|
12429
|
-
|
|
12430
|
-
|
|
12869
|
+
plan.retry,
|
|
12870
|
+
options2.context.signal,
|
|
12871
|
+
plan.transportMode
|
|
12431
12872
|
).catch((caughtError) => {
|
|
12432
12873
|
const retryFailure = isChatV2RetryFailure(caughtError) ? caughtError : void 0;
|
|
12433
12874
|
const rawError = (retryFailure == null ? void 0 : retryFailure.error) ?? caughtError;
|
|
@@ -12440,6 +12881,7 @@ async function runChatV2Pipeline(options2) {
|
|
|
12440
12881
|
const failureResult = buildProviderFailureResult(
|
|
12441
12882
|
requestMessages,
|
|
12442
12883
|
options2,
|
|
12884
|
+
plan,
|
|
12443
12885
|
normalizedError,
|
|
12444
12886
|
rawError,
|
|
12445
12887
|
requestStatuses2,
|
|
@@ -12470,13 +12912,13 @@ async function runChatV2Pipeline(options2) {
|
|
|
12470
12912
|
requestStatuses,
|
|
12471
12913
|
requestErrors,
|
|
12472
12914
|
requestBodies: options2.requestBodies,
|
|
12473
|
-
outputUsage:
|
|
12474
|
-
outputReasoning:
|
|
12475
|
-
outputRequestStatus:
|
|
12476
|
-
includeFunctionCalls:
|
|
12477
|
-
functionCallMode:
|
|
12478
|
-
retryOnNon200:
|
|
12479
|
-
responseFormat:
|
|
12915
|
+
outputUsage: plan.output.outputUsage,
|
|
12916
|
+
outputReasoning: plan.output.outputReasoning,
|
|
12917
|
+
outputRequestStatus: plan.output.outputRequestStatus,
|
|
12918
|
+
includeFunctionCalls: plan.output.includeFunctionCalls,
|
|
12919
|
+
functionCallMode: plan.output.functionCallMode,
|
|
12920
|
+
retryOnNon200: plan.retry.enabled,
|
|
12921
|
+
responseFormat: plan.request.responseFormat
|
|
12480
12922
|
});
|
|
12481
12923
|
const allMessagesOutput = commonOutputs["all-messages"];
|
|
12482
12924
|
if ((allMessagesOutput == null ? void 0 : allMessagesOutput.type) !== "chat-message[]") {
|
|
@@ -12756,7 +13198,7 @@ async function delegateToolCall(rawFunctionCall, context, config) {
|
|
|
12756
13198
|
|
|
12757
13199
|
// src/model/nodes/LLMChatV2Node.ts
|
|
12758
13200
|
function usesBaseURLInput(data) {
|
|
12759
|
-
return data.provider === "custom"
|
|
13201
|
+
return data.provider === "custom" && data.useCustomProviderBaseURLInput;
|
|
12760
13202
|
}
|
|
12761
13203
|
function getCustomProviderBaseURLBodyValue(data) {
|
|
12762
13204
|
if (data.provider !== "custom") {
|
|
@@ -12834,8 +13276,8 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
12834
13276
|
}
|
|
12835
13277
|
if (usesBaseURLInput(this.data)) {
|
|
12836
13278
|
inputs.unshift({
|
|
12837
|
-
id:
|
|
12838
|
-
title:
|
|
13279
|
+
id: "customProviderBaseURL",
|
|
13280
|
+
title: "Provider base URL",
|
|
12839
13281
|
dataType: "string",
|
|
12840
13282
|
required: false
|
|
12841
13283
|
});
|
|
@@ -23446,10 +23888,8 @@ var ToMarkdownTableNodeImpl = class extends NodeImpl {
|
|
|
23446
23888
|
}
|
|
23447
23889
|
getBody() {
|
|
23448
23890
|
const parts = [];
|
|
23449
|
-
if (this.data.includeHeaders)
|
|
23450
|
-
|
|
23451
|
-
if (this.data.alignPipes)
|
|
23452
|
-
parts.push("Pipes Aligned");
|
|
23891
|
+
if (this.data.includeHeaders) parts.push("With Header Row");
|
|
23892
|
+
if (this.data.alignPipes) parts.push("Pipes Aligned");
|
|
23453
23893
|
return parts.length > 0 ? parts.join(", ") : void 0;
|
|
23454
23894
|
}
|
|
23455
23895
|
static getUIData() {
|
|
@@ -23832,8 +24272,7 @@ var ToTreeNodeImpl = class extends NodeImpl {
|
|
|
23832
24272
|
};
|
|
23833
24273
|
}
|
|
23834
24274
|
buildTree(objects, parentPath = "", level = 0, isLast = true) {
|
|
23835
|
-
if (!Array.isArray(objects) || objects.length === 0)
|
|
23836
|
-
return "";
|
|
24275
|
+
if (!Array.isArray(objects) || objects.length === 0) return "";
|
|
23837
24276
|
let result = "";
|
|
23838
24277
|
const sortedObjects = this.data.useSortAlphabetically ? (0, import_lodash_es16.sortBy)(objects, (obj) => String((0, import_lodash_es16.get)(obj, "path", ""))) : objects;
|
|
23839
24278
|
sortedObjects.forEach((obj, index) => {
|
|
@@ -24098,10 +24537,8 @@ var getServerOptions = async (context) => {
|
|
|
24098
24537
|
return [];
|
|
24099
24538
|
};
|
|
24100
24539
|
var getServerHelperMessage = (context, optionsLength) => {
|
|
24101
|
-
if (optionsLength > 0)
|
|
24102
|
-
|
|
24103
|
-
if (context.executor !== "nodejs")
|
|
24104
|
-
return "MCP nodes require Node Executor";
|
|
24540
|
+
if (optionsLength > 0) return "Select an MCP server from local configuration located in the Project tab";
|
|
24541
|
+
if (context.executor !== "nodejs") return "MCP nodes require Node Executor";
|
|
24105
24542
|
return "No MCP servers found in config";
|
|
24106
24543
|
};
|
|
24107
24544
|
|
|
@@ -26500,7 +26937,9 @@ var AutoEvalsNodeImpl = {
|
|
|
26500
26937
|
return {
|
|
26501
26938
|
["score"]: {
|
|
26502
26939
|
type: "number",
|
|
26503
|
-
|
|
26940
|
+
// Newer AutoEvals versions represent unavailable scores as null, while
|
|
26941
|
+
// this node's declared port remains numeric.
|
|
26942
|
+
value: result.score ?? 0
|
|
26504
26943
|
},
|
|
26505
26944
|
["rationale"]: {
|
|
26506
26945
|
type: "string",
|
|
@@ -26535,8 +26974,7 @@ var import_ts_dedent78 = require("ts-dedent");
|
|
|
26535
26974
|
var import_assemblyai = require("assemblyai");
|
|
26536
26975
|
function getTranscriptIds(inputs) {
|
|
26537
26976
|
const input = inputs["transcript_ids"];
|
|
26538
|
-
if (!input)
|
|
26539
|
-
return void 0;
|
|
26977
|
+
if (!input) return void 0;
|
|
26540
26978
|
if (input.type === "string" || input.type === "any" && typeof input.value === "string") {
|
|
26541
26979
|
return [coerceType(input, "string")];
|
|
26542
26980
|
} else if (input.type === "string[]" || input.type === "any[]" || input.type === "any" && Array.isArray(input.value)) {
|
|
@@ -26739,8 +27177,7 @@ var LemurQaNodeImpl = {
|
|
|
26739
27177
|
};
|
|
26740
27178
|
function getQuestions(inputs) {
|
|
26741
27179
|
const input = inputs["questions"];
|
|
26742
|
-
if (!input)
|
|
26743
|
-
throw new Error("Questions are required.");
|
|
27180
|
+
if (!input) throw new Error("Questions are required.");
|
|
26744
27181
|
if (input.type === "string") {
|
|
26745
27182
|
return [
|
|
26746
27183
|
{
|
|
@@ -26858,8 +27295,7 @@ var TranscribeAudioNodeImpl = {
|
|
|
26858
27295
|
},
|
|
26859
27296
|
async process(data, inputs, context) {
|
|
26860
27297
|
const input = inputs["audio"];
|
|
26861
|
-
if (!input)
|
|
26862
|
-
throw new Error("Audio input is required.");
|
|
27298
|
+
if (!input) throw new Error("Audio input is required.");
|
|
26863
27299
|
const client = getClient(context);
|
|
26864
27300
|
let audioUrl;
|
|
26865
27301
|
if (input.type === "audio") {
|
|
@@ -27053,8 +27489,7 @@ var LemurTaskNodeImpl = {
|
|
|
27053
27489
|
prompt: coerceTypeOptional(inputs["prompt"], "string") || data.prompt || "",
|
|
27054
27490
|
...getLemurParams(inputs, data)
|
|
27055
27491
|
};
|
|
27056
|
-
if (!params.prompt)
|
|
27057
|
-
throw new Error("Prompt must be provided.");
|
|
27492
|
+
if (!params.prompt) throw new Error("Prompt must be provided.");
|
|
27058
27493
|
const { response } = await client.lemur.task(params);
|
|
27059
27494
|
return {
|
|
27060
27495
|
["response"]: {
|
|
@@ -27728,8 +28163,14 @@ var pineconePlugin = {
|
|
|
27728
28163
|
// src/plugins/pinecone/index.ts
|
|
27729
28164
|
var pinecone_default = pineconePlugin;
|
|
27730
28165
|
|
|
28166
|
+
// src/plugins/gentrace/gentraceSdk.ts
|
|
28167
|
+
var import_init = require("@gentrace/core/dist/providers/init.mjs");
|
|
28168
|
+
var import_pipeline_methods = require("@gentrace/core/dist/providers/pipeline-methods.mjs");
|
|
28169
|
+
var import_pipeline = require("@gentrace/core/dist/providers/pipeline.mjs");
|
|
28170
|
+
var import_run_test = require("@gentrace/core/dist/providers/run-test.mjs");
|
|
28171
|
+
var import_step_run = require("@gentrace/core/dist/providers/step-run.mjs");
|
|
28172
|
+
|
|
27731
28173
|
// src/plugins/gentrace/plugin.ts
|
|
27732
|
-
var import_core = require("@gentrace/core");
|
|
27733
28174
|
var import_lodash_es18 = require("lodash");
|
|
27734
28175
|
|
|
27735
28176
|
// src/integrations/GptTokenizerTokenizer.ts
|
|
@@ -27799,6 +28240,35 @@ ${parameterName}?: ${Array.isArray(value == null ? void 0 : value.type) ? value.
|
|
|
27799
28240
|
}
|
|
27800
28241
|
};
|
|
27801
28242
|
|
|
28243
|
+
// src/api/processSettings.ts
|
|
28244
|
+
function definedRuntimeSettings(settings) {
|
|
28245
|
+
return Object.fromEntries(
|
|
28246
|
+
Object.entries(settings).filter(([, value]) => value !== void 0 && value !== "")
|
|
28247
|
+
);
|
|
28248
|
+
}
|
|
28249
|
+
function resolveProcessSettings(settings = {}, fallbacks = {}) {
|
|
28250
|
+
const openAiApiKey = settings.openAiApiKey || settings.openAiKey || fallbacks.openAiApiKey || fallbacks.openAiKey || "";
|
|
28251
|
+
return {
|
|
28252
|
+
...fallbacks,
|
|
28253
|
+
...definedRuntimeSettings(settings),
|
|
28254
|
+
openAiApiKey,
|
|
28255
|
+
openAiKey: openAiApiKey,
|
|
28256
|
+
anthropicApiKey: settings.anthropicApiKey || fallbacks.anthropicApiKey || "",
|
|
28257
|
+
googleApiKey: settings.googleApiKey || fallbacks.googleApiKey || "",
|
|
28258
|
+
customAiApiKey: settings.customAiApiKey || fallbacks.customAiApiKey || "",
|
|
28259
|
+
openAiOrganization: settings.openAiOrganization ?? fallbacks.openAiOrganization ?? "",
|
|
28260
|
+
openAiEndpoint: settings.openAiEndpoint ?? fallbacks.openAiEndpoint ?? "",
|
|
28261
|
+
pluginEnv: settings.pluginEnv ?? fallbacks.pluginEnv ?? {},
|
|
28262
|
+
pluginSettings: settings.pluginSettings ?? {},
|
|
28263
|
+
recordingPlaybackLatency: settings.recordingPlaybackLatency ?? 1e3,
|
|
28264
|
+
defaultNodeColors: settings.defaultNodeColors ?? false,
|
|
28265
|
+
openNodeSettingsOnCreate: settings.openNodeSettingsOnCreate ?? true,
|
|
28266
|
+
chatNodeHeaders: settings.chatNodeHeaders ?? {},
|
|
28267
|
+
chatNodeTimeout: settings.chatNodeTimeout ?? DEFAULT_CHAT_NODE_TIMEOUT,
|
|
28268
|
+
throttleChatNode: settings.throttleChatNode ?? 100
|
|
28269
|
+
};
|
|
28270
|
+
}
|
|
28271
|
+
|
|
27802
28272
|
// src/plugins/gentrace/plugin.ts
|
|
27803
28273
|
var apiKeyConfigSpec = {
|
|
27804
28274
|
type: "secret",
|
|
@@ -27808,7 +28278,7 @@ var apiKeyConfigSpec = {
|
|
|
27808
28278
|
helperText: "Create at https://gentrace.ai/settings/api-keys"
|
|
27809
28279
|
};
|
|
27810
28280
|
function initializeGentrace(gentraceApiKey) {
|
|
27811
|
-
(0,
|
|
28281
|
+
(0, import_init.init)({
|
|
27812
28282
|
apiKey: gentraceApiKey
|
|
27813
28283
|
});
|
|
27814
28284
|
}
|
|
@@ -27823,8 +28293,8 @@ var runGentraceTests = async (gentracePipelineSlug, settings, project, graph, na
|
|
|
27823
28293
|
throw new Error("Graph ID not set.");
|
|
27824
28294
|
}
|
|
27825
28295
|
initializeGentrace(gentraceApiKey);
|
|
27826
|
-
const response = await (0,
|
|
27827
|
-
const pipeline = new
|
|
28296
|
+
const response = await (0, import_run_test.runTest)(gentracePipelineSlug, async (testCase) => {
|
|
28297
|
+
const pipeline = new import_pipeline.Pipeline({
|
|
27828
28298
|
slug: gentracePipelineSlug
|
|
27829
28299
|
});
|
|
27830
28300
|
const runner = pipeline.start();
|
|
@@ -27843,7 +28313,7 @@ var runGentraceTests = async (gentracePipelineSlug, settings, project, graph, na
|
|
|
27843
28313
|
const runContextValues = (0, import_lodash_es18.cloneDeep)(contextValues);
|
|
27844
28314
|
await processor.processGraph(
|
|
27845
28315
|
{
|
|
27846
|
-
settings,
|
|
28316
|
+
settings: resolveProcessSettings(settings),
|
|
27847
28317
|
nativeApi,
|
|
27848
28318
|
tokenizer: new GptTokenizerTokenizer()
|
|
27849
28319
|
},
|
|
@@ -27873,8 +28343,8 @@ var runRemoteGentraceTests = async (gentracePipelineSlug, settings, project, gra
|
|
|
27873
28343
|
throw new Error("Graph ID not set.");
|
|
27874
28344
|
}
|
|
27875
28345
|
initializeGentrace(gentraceApiKey);
|
|
27876
|
-
const response = await (0,
|
|
27877
|
-
const pipeline = new
|
|
28346
|
+
const response = await (0, import_run_test.runTest)(gentracePipelineSlug, async (testCase) => {
|
|
28347
|
+
const pipeline = new import_pipeline.Pipeline({
|
|
27878
28348
|
slug: gentracePipelineSlug
|
|
27879
28349
|
});
|
|
27880
28350
|
const runner = pipeline.start();
|
|
@@ -27972,7 +28442,7 @@ function convertRecordingToStepRuns(recording, project, graphId) {
|
|
|
27972
28442
|
};
|
|
27973
28443
|
});
|
|
27974
28444
|
stepRuns.push(
|
|
27975
|
-
new
|
|
28445
|
+
new import_step_run.StepRun(
|
|
27976
28446
|
"openai",
|
|
27977
28447
|
"openai_createChatCompletion",
|
|
27978
28448
|
pair.end - pair.start,
|
|
@@ -27981,14 +28451,15 @@ function convertRecordingToStepRuns(recording, project, graphId) {
|
|
|
27981
28451
|
gentraceOpenAIInputs,
|
|
27982
28452
|
gentraceOpenAIModelParams,
|
|
27983
28453
|
gentraceOpenAIOutputs,
|
|
27984
|
-
{}
|
|
28454
|
+
{},
|
|
28455
|
+
void 0
|
|
27985
28456
|
)
|
|
27986
28457
|
);
|
|
27987
28458
|
continue;
|
|
27988
28459
|
}
|
|
27989
28460
|
}
|
|
27990
28461
|
stepRuns.push(
|
|
27991
|
-
new
|
|
28462
|
+
new import_step_run.StepRun(
|
|
27992
28463
|
"rivet",
|
|
27993
28464
|
nodeType ? `rivet_operation_${nodeType}` : "rivet_operation",
|
|
27994
28465
|
pair.end - pair.start,
|
|
@@ -27997,7 +28468,8 @@ function convertRecordingToStepRuns(recording, project, graphId) {
|
|
|
27997
28468
|
pair.inputs,
|
|
27998
28469
|
pair.modelParams,
|
|
27999
28470
|
pair.outputs,
|
|
28000
|
-
{}
|
|
28471
|
+
{},
|
|
28472
|
+
void 0
|
|
28001
28473
|
)
|
|
28002
28474
|
);
|
|
28003
28475
|
}
|
|
@@ -28005,7 +28477,7 @@ function convertRecordingToStepRuns(recording, project, graphId) {
|
|
|
28005
28477
|
}
|
|
28006
28478
|
var getGentracePipelines = async (gentraceApiKey) => {
|
|
28007
28479
|
initializeGentrace(gentraceApiKey);
|
|
28008
|
-
return await (0,
|
|
28480
|
+
return await (0, import_pipeline_methods.getPipelines)();
|
|
28009
28481
|
};
|
|
28010
28482
|
var gentracePlugin = {
|
|
28011
28483
|
id: "gentrace",
|
|
@@ -31575,28 +32047,6 @@ function getSingleNodeStream(processor, nodeIdOrTitle) {
|
|
|
31575
32047
|
});
|
|
31576
32048
|
}
|
|
31577
32049
|
|
|
31578
|
-
// src/api/processSettings.ts
|
|
31579
|
-
function resolveProcessSettings(settings = {}, fallbacks = {}) {
|
|
31580
|
-
const openAiApiKey = settings.openAiApiKey || settings.openAiKey || fallbacks.openAiApiKey || fallbacks.openAiKey || "";
|
|
31581
|
-
return {
|
|
31582
|
-
openAiApiKey,
|
|
31583
|
-
openAiKey: openAiApiKey,
|
|
31584
|
-
anthropicApiKey: settings.anthropicApiKey || fallbacks.anthropicApiKey || "",
|
|
31585
|
-
googleApiKey: settings.googleApiKey || fallbacks.googleApiKey || "",
|
|
31586
|
-
customAiApiKey: settings.customAiApiKey || fallbacks.customAiApiKey || "",
|
|
31587
|
-
openAiOrganization: settings.openAiOrganization ?? fallbacks.openAiOrganization ?? "",
|
|
31588
|
-
openAiEndpoint: settings.openAiEndpoint ?? fallbacks.openAiEndpoint ?? "",
|
|
31589
|
-
pluginEnv: settings.pluginEnv ?? fallbacks.pluginEnv ?? {},
|
|
31590
|
-
pluginSettings: settings.pluginSettings ?? {},
|
|
31591
|
-
recordingPlaybackLatency: settings.recordingPlaybackLatency ?? 1e3,
|
|
31592
|
-
defaultNodeColors: settings.defaultNodeColors ?? false,
|
|
31593
|
-
openNodeSettingsOnCreate: settings.openNodeSettingsOnCreate ?? true,
|
|
31594
|
-
chatNodeHeaders: settings.chatNodeHeaders ?? {},
|
|
31595
|
-
chatNodeTimeout: settings.chatNodeTimeout ?? DEFAULT_CHAT_NODE_TIMEOUT,
|
|
31596
|
-
throttleChatNode: settings.throttleChatNode ?? 100
|
|
31597
|
-
};
|
|
31598
|
-
}
|
|
31599
|
-
|
|
31600
32050
|
// src/api/createProcessor.ts
|
|
31601
32051
|
function coreCreateProcessor(project, options2, internalOptions = {}) {
|
|
31602
32052
|
var _a, _b, _c;
|
|
@@ -31816,6 +32266,10 @@ var Rivet = void 0;
|
|
|
31816
32266
|
PluginNodeImplClass,
|
|
31817
32267
|
PopNodeImpl,
|
|
31818
32268
|
PromptNodeImpl,
|
|
32269
|
+
RIVET_MARKDOWN_ALLOWED_ATTRIBUTES,
|
|
32270
|
+
RIVET_MARKDOWN_ALLOWED_TAGS,
|
|
32271
|
+
RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE,
|
|
32272
|
+
RIVET_MARKDOWN_SANITIZER_POLICY,
|
|
31819
32273
|
RIVET_WEB_APP_DOCUMENT_CSS,
|
|
31820
32274
|
RIVET_WEB_APP_RENDERER_CSS,
|
|
31821
32275
|
RaceInputsNodeImpl,
|
|
@@ -31851,6 +32305,7 @@ var Rivet = void 0;
|
|
|
31851
32305
|
anthropicPlugin,
|
|
31852
32306
|
anthropicThinkingModeOptions,
|
|
31853
32307
|
appendToDatasetNode,
|
|
32308
|
+
applyUiGraphStatePatch,
|
|
31854
32309
|
arrayNode,
|
|
31855
32310
|
arrayTypeToScalarType,
|
|
31856
32311
|
arrayizeDataValue,
|
|
@@ -31864,6 +32319,7 @@ var Rivet = void 0;
|
|
|
31864
32319
|
base64ToUint8Array,
|
|
31865
32320
|
baseDirs,
|
|
31866
32321
|
booleanNode,
|
|
32322
|
+
buildChatV2RequestPlan,
|
|
31867
32323
|
buildLLMChatV2EditorCacheKey,
|
|
31868
32324
|
buildLegacyOrderedPortIds,
|
|
31869
32325
|
calculateChatV2Cost,
|
|
@@ -31904,6 +32360,7 @@ var Rivet = void 0;
|
|
|
31904
32360
|
createDefaultUiGraph,
|
|
31905
32361
|
createFrozenNodeOutputResolver,
|
|
31906
32362
|
createInterpolationInputDefinition,
|
|
32363
|
+
createResolvedChatV2Provider,
|
|
31907
32364
|
createsLLMChatV2ToolResponseFormatConflictForEdit,
|
|
31908
32365
|
cronNode,
|
|
31909
32366
|
dataTypeDisplayNames,
|
|
@@ -31935,6 +32392,7 @@ var Rivet = void 0;
|
|
|
31935
32392
|
extractYamlNode,
|
|
31936
32393
|
filterNode,
|
|
31937
32394
|
findInterpolationTokenSpans,
|
|
32395
|
+
formatUiGraphDownloadDateTime,
|
|
31938
32396
|
functionTypeToScalarType,
|
|
31939
32397
|
generateChatV2,
|
|
31940
32398
|
gentracePlugin,
|
|
@@ -31973,7 +32431,12 @@ var Rivet = void 0;
|
|
|
31973
32431
|
getUiGraphActionComponent,
|
|
31974
32432
|
getUiGraphActionInputBindings,
|
|
31975
32433
|
getUiGraphActionOutputBindings,
|
|
32434
|
+
getUiGraphActionState,
|
|
32435
|
+
getUiGraphComponentLabel,
|
|
32436
|
+
getUiGraphComponentRenderModel,
|
|
31976
32437
|
getUiGraphInitialState,
|
|
32438
|
+
getUiGraphJsonOutputFilename,
|
|
32439
|
+
getUiGraphOutputRenderModel,
|
|
31977
32440
|
getWarnings,
|
|
31978
32441
|
globalRivetNodeRegistry,
|
|
31979
32442
|
googlePlugin,
|
|
@@ -31985,7 +32448,9 @@ var Rivet = void 0;
|
|
|
31985
32448
|
handleEscapeCharacters,
|
|
31986
32449
|
hasFrozenNodeOutputs,
|
|
31987
32450
|
hasLLMChatV2ToolResponseFormatConflict,
|
|
32451
|
+
hasUiGraphStateValue,
|
|
31988
32452
|
hasValidStoredOrderedPortIds,
|
|
32453
|
+
hasValidUiGraphComponentIds,
|
|
31989
32454
|
hashNode,
|
|
31990
32455
|
httpCallNode,
|
|
31991
32456
|
huggingFacePlugin,
|
|
@@ -32039,6 +32504,7 @@ var Rivet = void 0;
|
|
|
32039
32504
|
newId,
|
|
32040
32505
|
nodeDefinition,
|
|
32041
32506
|
nodePrefabInstanceNode,
|
|
32507
|
+
normalizeUiGraphComponentIds,
|
|
32042
32508
|
numberNode,
|
|
32043
32509
|
objectNode,
|
|
32044
32510
|
openAICompatibleEndpointToBaseURL,
|
|
@@ -32065,10 +32531,12 @@ var Rivet = void 0;
|
|
|
32065
32531
|
registerBuiltInNodes,
|
|
32066
32532
|
registerIntegration,
|
|
32067
32533
|
registerPluginsIntoRegistry,
|
|
32534
|
+
renderUiGraphOutputValue,
|
|
32068
32535
|
replaceDatasetNode,
|
|
32069
32536
|
replaceGlobalRivetNodeRegistry,
|
|
32070
32537
|
resetGlobalRivetNodeRegistry,
|
|
32071
32538
|
resolveBuiltInPlugin,
|
|
32539
|
+
resolveChatV2Credential,
|
|
32072
32540
|
resolveChatV2ProviderConfig,
|
|
32073
32541
|
resolveChatV2ResponseFormatParameters,
|
|
32074
32542
|
resolveLLMChatV2RuntimeProviderOptions,
|
|
@@ -32095,7 +32563,9 @@ var Rivet = void 0;
|
|
|
32095
32563
|
sliceNode,
|
|
32096
32564
|
splitNode,
|
|
32097
32565
|
streamChatV2,
|
|
32566
|
+
stringifyUiGraphValue,
|
|
32098
32567
|
subGraphNode,
|
|
32568
|
+
summarizeChatV2RequestPlan,
|
|
32099
32569
|
summarizeDataValueForLog,
|
|
32100
32570
|
summarizeErrorForLog,
|
|
32101
32571
|
summarizePortMapForLog,
|