@valerypopoff/rivet2-core 2.1.1 → 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 +925 -433
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/esm/api/processSettings.js +11 -1
- 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 +13 -36
- 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 +12 -38
- 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/getPluginConfig.js +15 -3
- 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 +5 -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
|
},
|
|
@@ -2129,6 +2369,15 @@ function cleanHeaders(headers) {
|
|
|
2129
2369
|
var import_ts_dedent = require("ts-dedent");
|
|
2130
2370
|
|
|
2131
2371
|
// src/utils/getPluginConfig.ts
|
|
2372
|
+
function getSharedLlmPluginConfig(plugin, settings, name) {
|
|
2373
|
+
if (plugin.id === "anthropic" && name === "anthropicApiKey") {
|
|
2374
|
+
return settings.anthropicApiKey;
|
|
2375
|
+
}
|
|
2376
|
+
if (plugin.id === "google" && name === "googleApiKey") {
|
|
2377
|
+
return settings.googleApiKey;
|
|
2378
|
+
}
|
|
2379
|
+
return void 0;
|
|
2380
|
+
}
|
|
2132
2381
|
function getPluginConfig(plugin, settings, name) {
|
|
2133
2382
|
var _a, _b, _c;
|
|
2134
2383
|
if (!plugin) {
|
|
@@ -2141,10 +2390,13 @@ function getPluginConfig(plugin, settings, name) {
|
|
|
2141
2390
|
const pluginSettings = (_b = settings.pluginSettings) == null ? void 0 : _b[plugin.id];
|
|
2142
2391
|
if (pluginSettings) {
|
|
2143
2392
|
const value = pluginSettings[name];
|
|
2144
|
-
if (
|
|
2145
|
-
return
|
|
2393
|
+
if (value && typeof value === "string") {
|
|
2394
|
+
return value;
|
|
2146
2395
|
}
|
|
2147
|
-
|
|
2396
|
+
}
|
|
2397
|
+
const sharedLlmValue = getSharedLlmPluginConfig(plugin, settings, name);
|
|
2398
|
+
if (sharedLlmValue) {
|
|
2399
|
+
return sharedLlmValue;
|
|
2148
2400
|
}
|
|
2149
2401
|
const envFallback = configSpec.pullEnvironmentVariable;
|
|
2150
2402
|
const envFallbackName = envFallback === true ? name : envFallback;
|
|
@@ -2154,12 +2406,6 @@ function getPluginConfig(plugin, settings, name) {
|
|
|
2154
2406
|
return void 0;
|
|
2155
2407
|
}
|
|
2156
2408
|
|
|
2157
|
-
// src/utils/newId.ts
|
|
2158
|
-
var import_non_secure2 = require("nanoid/non-secure");
|
|
2159
|
-
function newId() {
|
|
2160
|
-
return (0, import_non_secure2.nanoid)();
|
|
2161
|
-
}
|
|
2162
|
-
|
|
2163
2409
|
// src/utils/handleEscapeCharacters.ts
|
|
2164
2410
|
function handleEscapeCharacters(inputString) {
|
|
2165
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");
|
|
@@ -2521,12 +2767,9 @@ function getComparableNodeData(node, data) {
|
|
|
2521
2767
|
// src/utils/projectComparison/summaries.ts
|
|
2522
2768
|
function summarizeProjectComparison(graphs, nodePrefabs = {}, uiGraphs = {}) {
|
|
2523
2769
|
const summary = Object.values(graphs).reduce((acc, graph) => {
|
|
2524
|
-
if (graph.kind === "added")
|
|
2525
|
-
|
|
2526
|
-
if (graph.kind === "
|
|
2527
|
-
acc.removedGraphs += 1;
|
|
2528
|
-
if (graph.kind === "changed")
|
|
2529
|
-
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;
|
|
2530
2773
|
acc.addedNodes += graph.summary.addedNodes;
|
|
2531
2774
|
acc.removedNodes += graph.summary.removedNodes;
|
|
2532
2775
|
acc.changedNodes += graph.summary.changedNodes;
|
|
@@ -2536,20 +2779,14 @@ function summarizeProjectComparison(graphs, nodePrefabs = {}, uiGraphs = {}) {
|
|
|
2536
2779
|
return acc;
|
|
2537
2780
|
}, createEmptyProjectSummary());
|
|
2538
2781
|
for (const prefab of Object.values(nodePrefabs)) {
|
|
2539
|
-
if (prefab.kind === "added")
|
|
2540
|
-
|
|
2541
|
-
if (prefab.kind === "
|
|
2542
|
-
summary.removedNodePrefabs = (summary.removedNodePrefabs ?? 0) + 1;
|
|
2543
|
-
if (prefab.kind === "changed")
|
|
2544
|
-
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;
|
|
2545
2785
|
}
|
|
2546
2786
|
for (const uiGraph of Object.values(uiGraphs)) {
|
|
2547
|
-
if (uiGraph.kind === "added")
|
|
2548
|
-
|
|
2549
|
-
if (uiGraph.kind === "
|
|
2550
|
-
summary.removedUiGraphs = (summary.removedUiGraphs ?? 0) + 1;
|
|
2551
|
-
if (uiGraph.kind === "changed")
|
|
2552
|
-
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;
|
|
2553
2790
|
}
|
|
2554
2791
|
return summary;
|
|
2555
2792
|
}
|
|
@@ -4171,6 +4408,71 @@ function wireSubprocessorLifecycle(processor, options2) {
|
|
|
4171
4408
|
unsubscribers.push(subscribeOwnGraphRunLifecycle(processor, cleanup));
|
|
4172
4409
|
}
|
|
4173
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
|
+
|
|
4174
4476
|
// src/model/NodeExclusionPolicy.ts
|
|
4175
4477
|
var nodesAllowedToConsumeExcludedValue = /* @__PURE__ */ new Set([
|
|
4176
4478
|
"if",
|
|
@@ -4385,11 +4687,10 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4385
4687
|
#nodeInstances;
|
|
4386
4688
|
#connections;
|
|
4387
4689
|
#emitter = new import_emittery.default();
|
|
4388
|
-
#
|
|
4690
|
+
#lifecycle = new GraphRunLifecycle();
|
|
4389
4691
|
#isSubProcessor = false;
|
|
4390
4692
|
#externalFunctions = {};
|
|
4391
4693
|
slowMode = false;
|
|
4392
|
-
#isPaused = false;
|
|
4393
4694
|
#parent;
|
|
4394
4695
|
#registry;
|
|
4395
4696
|
#concurrency;
|
|
@@ -4435,9 +4736,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4435
4736
|
#contextValues = void 0;
|
|
4436
4737
|
#globals = void 0;
|
|
4437
4738
|
#attachedNodeData = void 0;
|
|
4438
|
-
#aborted = false;
|
|
4439
|
-
#abortSuccessfully = false;
|
|
4440
|
-
#abortError = void 0;
|
|
4441
4739
|
#successfulAbortTerminalProcessIds = void 0;
|
|
4442
4740
|
#totalCost = 0;
|
|
4443
4741
|
#ignoreNodes = void 0;
|
|
@@ -4453,10 +4751,9 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4453
4751
|
#graphInputNodeValues = {};
|
|
4454
4752
|
/** User input nodes that are pending user input. */
|
|
4455
4753
|
#pendingUserInputs = void 0;
|
|
4456
|
-
#finishEmitted = false;
|
|
4457
4754
|
#unsubscribeTokenizerError;
|
|
4458
4755
|
get isRunning() {
|
|
4459
|
-
return this.#
|
|
4756
|
+
return this.#lifecycle.isRunning;
|
|
4460
4757
|
}
|
|
4461
4758
|
#startNodeTiming() {
|
|
4462
4759
|
return this.#captureNodeTimings ? getMonotonicTimeMs() : void 0;
|
|
@@ -4665,11 +4962,9 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4665
4962
|
this.#externalFunctions[name] = fn;
|
|
4666
4963
|
}
|
|
4667
4964
|
async abort(successful = false, error) {
|
|
4668
|
-
if (!this.#
|
|
4965
|
+
if (!this.#lifecycle.requestAbort(successful, error)) {
|
|
4669
4966
|
return Promise.resolve();
|
|
4670
4967
|
}
|
|
4671
|
-
this.#abortSuccessfully = successful;
|
|
4672
|
-
this.#abortError = error;
|
|
4673
4968
|
const abortReason = createGraphAbortReason(successful, error);
|
|
4674
4969
|
this.#abortController.abort(abortReason);
|
|
4675
4970
|
this.#abortActiveNodeControllers(abortReason);
|
|
@@ -4680,14 +4975,12 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4680
4975
|
await this.#processingQueue.onIdle();
|
|
4681
4976
|
}
|
|
4682
4977
|
pause() {
|
|
4683
|
-
if (this.#
|
|
4684
|
-
this.#isPaused = true;
|
|
4978
|
+
if (this.#lifecycle.pause()) {
|
|
4685
4979
|
emitDetached(this.#emitter, "pause", void 0);
|
|
4686
4980
|
}
|
|
4687
4981
|
}
|
|
4688
4982
|
resume() {
|
|
4689
|
-
if (this.#
|
|
4690
|
-
this.#isPaused = false;
|
|
4983
|
+
if (this.#lifecycle.resume()) {
|
|
4691
4984
|
emitDetached(this.#emitter, "resume", void 0);
|
|
4692
4985
|
}
|
|
4693
4986
|
}
|
|
@@ -4695,16 +4988,16 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4695
4988
|
this.slowMode = slowMode;
|
|
4696
4989
|
}
|
|
4697
4990
|
async #waitUntilUnpaused() {
|
|
4698
|
-
if (!this.#isPaused) {
|
|
4991
|
+
if (!this.#lifecycle.isPaused) {
|
|
4699
4992
|
return;
|
|
4700
4993
|
}
|
|
4701
4994
|
if (this.#abortController.signal.aborted) {
|
|
4702
|
-
throw this.#getAbortError();
|
|
4995
|
+
throw this.#lifecycle.getAbortError();
|
|
4703
4996
|
}
|
|
4704
4997
|
await new Promise((resolve, reject) => {
|
|
4705
4998
|
const abortListener = () => {
|
|
4706
4999
|
cleanup();
|
|
4707
|
-
reject(this.#getAbortError());
|
|
5000
|
+
reject(this.#lifecycle.getAbortError());
|
|
4708
5001
|
};
|
|
4709
5002
|
const unsubscribeResume = this.#emitter.on("resume", () => {
|
|
4710
5003
|
cleanup();
|
|
@@ -4717,12 +5010,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4717
5010
|
this.#abortController.signal.addEventListener("abort", abortListener, { once: true });
|
|
4718
5011
|
});
|
|
4719
5012
|
}
|
|
4720
|
-
#getAbortError() {
|
|
4721
|
-
if (typeof this.#abortError === "string") {
|
|
4722
|
-
return new Error(this.#abortError);
|
|
4723
|
-
}
|
|
4724
|
-
return this.#abortError ?? new Error("Processing aborted");
|
|
4725
|
-
}
|
|
4726
5013
|
async *events() {
|
|
4727
5014
|
for await (const [event, data] of this.#emitter.anyEvent()) {
|
|
4728
5015
|
yield {
|
|
@@ -4787,7 +5074,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4787
5074
|
erroredNodes: this.#erroredNodes,
|
|
4788
5075
|
graphInputs: this.#graphInputs,
|
|
4789
5076
|
graphOutputs: this.#graphOutputs,
|
|
4790
|
-
isAborted: () => this.#
|
|
5077
|
+
isAborted: () => this.#lifecycle.isAborted,
|
|
4791
5078
|
nodeResults: this.#nodeResults,
|
|
4792
5079
|
project: this.#project,
|
|
4793
5080
|
recorder,
|
|
@@ -4802,7 +5089,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4802
5089
|
this.#graphOutputs = graphOutputs;
|
|
4803
5090
|
},
|
|
4804
5091
|
setRunning: (running) => {
|
|
4805
|
-
this.#
|
|
5092
|
+
if (!running) this.#lifecycle.complete();
|
|
4806
5093
|
},
|
|
4807
5094
|
visitedNodes: this.#visitedNodes,
|
|
4808
5095
|
waitUntilUnpaused: () => this.#waitUntilUnpaused()
|
|
@@ -4811,8 +5098,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4811
5098
|
}
|
|
4812
5099
|
#initProcessState() {
|
|
4813
5100
|
var _a, _b;
|
|
4814
|
-
this.#
|
|
4815
|
-
this.#finishEmitted = false;
|
|
5101
|
+
this.#lifecycle.begin();
|
|
4816
5102
|
if (!this.#hasPreloadedData) {
|
|
4817
5103
|
this.#nodeResults = /* @__PURE__ */ new Map();
|
|
4818
5104
|
this.#visitedNodes = /* @__PURE__ */ new Set();
|
|
@@ -4836,12 +5122,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4836
5122
|
this.#nodeProcessContextBase = void 0;
|
|
4837
5123
|
this.#runToRelevantNodeIds = void 0;
|
|
4838
5124
|
this.#abortController = this.#newAbortController();
|
|
4839
|
-
this.#abortController.signal.addEventListener("abort", () => {
|
|
4840
|
-
this.#aborted = true;
|
|
4841
|
-
});
|
|
4842
|
-
this.#aborted = false;
|
|
4843
|
-
this.#abortError = void 0;
|
|
4844
|
-
this.#abortSuccessfully = false;
|
|
4845
5125
|
this.#successfulAbortTerminalProcessIds = /* @__PURE__ */ new Set();
|
|
4846
5126
|
this.#nodeAbortControllers = /* @__PURE__ */ new Map();
|
|
4847
5127
|
this.#loadedProjects = this.#cacheLoadedProjects && ((_a = this.#runtimeCache) == null ? void 0 : _a.loadedProjects) ? { ...this.#runtimeCache.loadedProjects } : {};
|
|
@@ -4854,7 +5134,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4854
5134
|
}
|
|
4855
5135
|
/** Main function for running a graph. Runs a graph and returns the outputs from the output nodes of the graph. */
|
|
4856
5136
|
async processGraph(context, inputs = {}, contextValues = {}) {
|
|
4857
|
-
if (this.#
|
|
5137
|
+
if (this.#lifecycle.isRunning) {
|
|
4858
5138
|
throw new Error("Cannot process graph while already processing");
|
|
4859
5139
|
}
|
|
4860
5140
|
try {
|
|
@@ -4877,16 +5157,15 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4877
5157
|
await this.#profileRuntimeAsync("throwIfGraphErrored", () => this.#throwIfGraphErrored());
|
|
4878
5158
|
return await this.#profileRuntimeAsync("finalizeGraphRun", () => this.#finalizeGraphRun());
|
|
4879
5159
|
} finally {
|
|
4880
|
-
this.#
|
|
5160
|
+
this.#lifecycle.complete();
|
|
4881
5161
|
this.#cleanupTokenizerErrorListener();
|
|
4882
5162
|
await this.#profileRuntimeAsync("emitFinish", () => this.#emitFinishIfNeeded());
|
|
4883
5163
|
}
|
|
4884
5164
|
}
|
|
4885
5165
|
async #emitFinishIfNeeded() {
|
|
4886
|
-
if (this.#
|
|
5166
|
+
if (!this.#lifecycle.claimRootFinish(this.#isSubProcessor)) {
|
|
4887
5167
|
return;
|
|
4888
5168
|
}
|
|
4889
|
-
this.#finishEmitted = true;
|
|
4890
5169
|
await this.#emitter.emit("finish", void 0);
|
|
4891
5170
|
}
|
|
4892
5171
|
#initializeGraphRun(context, inputs, contextValues) {
|
|
@@ -5115,8 +5394,8 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
5115
5394
|
});
|
|
5116
5395
|
}
|
|
5117
5396
|
#createGraphError(erroredNodes) {
|
|
5118
|
-
if (this.#abortError) {
|
|
5119
|
-
return this.#getAbortError();
|
|
5397
|
+
if (this.#lifecycle.abortError) {
|
|
5398
|
+
return this.#lifecycle.getAbortError();
|
|
5120
5399
|
}
|
|
5121
5400
|
const message = `Graph ${this.#graph.metadata.name} (${this.#graph.metadata.id}) failed to process due to errors in nodes:
|
|
5122
5401
|
${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})`).join("\n")}`;
|
|
@@ -5131,7 +5410,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5131
5410
|
}
|
|
5132
5411
|
async #throwIfGraphErrored() {
|
|
5133
5412
|
const erroredNodes = this.#getUnhandledErroredNodes();
|
|
5134
|
-
if (!erroredNodes.length || this.#
|
|
5413
|
+
if (!erroredNodes.length || this.#lifecycle.abortSuccessful) {
|
|
5135
5414
|
return;
|
|
5136
5415
|
}
|
|
5137
5416
|
const error = this.#createGraphError(erroredNodes);
|
|
@@ -5144,7 +5423,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5144
5423
|
async #finalizeGraphRun() {
|
|
5145
5424
|
ensureGraphCostOutput(this.#graphOutputs, this.#totalCost);
|
|
5146
5425
|
const outputValues = this.#graphOutputs;
|
|
5147
|
-
this.#
|
|
5426
|
+
this.#lifecycle.complete();
|
|
5148
5427
|
await this.#emitter.emit("graphFinish", this.#withExecution({ graph: this.#graph, outputs: outputValues }));
|
|
5149
5428
|
if (!this.#isSubProcessor) {
|
|
5150
5429
|
await this.#emitter.emit("done", { results: outputValues });
|
|
@@ -5516,7 +5795,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5516
5795
|
setNodeResults: (nodeId, outputs) => this.#nodeResults.set(nodeId, outputs),
|
|
5517
5796
|
markNodeVisited: (nodeId) => this.#visitedNodes.add(nodeId),
|
|
5518
5797
|
nodeErrored: (n, err, pid, durationMs, splitRunDurationMs) => this.#nodeErrored(n, err, pid, durationMs, splitRunDurationMs),
|
|
5519
|
-
isAborted: () => this.#
|
|
5798
|
+
isAborted: () => this.#lifecycle.isAborted,
|
|
5520
5799
|
getAbortError: () => createGraphAbortErrorFromSignal(this.#abortController.signal),
|
|
5521
5800
|
emit: (event, data) => {
|
|
5522
5801
|
if (event === "partialOutput") {
|
|
@@ -5637,8 +5916,8 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5637
5916
|
this.#successfulAbortTerminalProcessIds.add(processId);
|
|
5638
5917
|
return SUCCESSFUL_GRAPH_ABORT_EXCLUSION_REASON;
|
|
5639
5918
|
}
|
|
5640
|
-
if (this.#
|
|
5641
|
-
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;
|
|
5642
5921
|
if (exclusionReason === SUCCESSFUL_GRAPH_ABORT_EXCLUSION_REASON) {
|
|
5643
5922
|
this.#successfulAbortTerminalProcessIds.add(processId);
|
|
5644
5923
|
}
|
|
@@ -5894,7 +6173,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5894
6173
|
const wireEventsProfileStart = this.#startRuntimeProfile();
|
|
5895
6174
|
try {
|
|
5896
6175
|
wireSubprocessorEvents(processor, this.#emitter, {
|
|
5897
|
-
isPaused: () => this.#isPaused,
|
|
6176
|
+
isPaused: () => this.#lifecycle.isPaused,
|
|
5898
6177
|
pause: () => {
|
|
5899
6178
|
void this.pause();
|
|
5900
6179
|
},
|
|
@@ -6027,127 +6306,79 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
6027
6306
|
loopControllersSeen: this.#loopControllersSeen,
|
|
6028
6307
|
nodesById: this.#nodesById,
|
|
6029
6308
|
stronglyConnectedComponents: this.#scc,
|
|
6030
|
-
visitedNodes: this.#visitedNodes
|
|
6031
|
-
};
|
|
6032
|
-
}
|
|
6033
|
-
};
|
|
6034
|
-
|
|
6035
|
-
// src/model/UiGraph.ts
|
|
6036
|
-
function createDefaultUiGraph(options2 = {}) {
|
|
6037
|
-
const promptStateKey = "input";
|
|
6038
|
-
const resultStateKey = "result";
|
|
6039
|
-
return {
|
|
6040
|
-
id: newId(),
|
|
6041
|
-
name: options2.name ?? "Untitled web app",
|
|
6042
|
-
components: [
|
|
6043
|
-
{
|
|
6044
|
-
id: newId(),
|
|
6045
|
-
type: "markdown",
|
|
6046
|
-
markdown: "## New Rivet web app\n\nEnter a value and run a graph."
|
|
6047
|
-
},
|
|
6048
|
-
{
|
|
6049
|
-
id: newId(),
|
|
6050
|
-
type: "textarea",
|
|
6051
|
-
label: "Input",
|
|
6052
|
-
stateKey: promptStateKey,
|
|
6053
|
-
placeholder: "Type something..."
|
|
6054
|
-
},
|
|
6055
|
-
{
|
|
6056
|
-
id: newId(),
|
|
6057
|
-
type: "button",
|
|
6058
|
-
label: "Run graph",
|
|
6059
|
-
action: {
|
|
6060
|
-
type: "runGraph",
|
|
6061
|
-
graphId: options2.graphId,
|
|
6062
|
-
inputMappings: [{ inputKey: "input", stateKey: promptStateKey }],
|
|
6063
|
-
outputs: [{ stateKey: resultStateKey }]
|
|
6064
|
-
}
|
|
6065
|
-
},
|
|
6066
|
-
{
|
|
6067
|
-
id: newId(),
|
|
6068
|
-
type: "output",
|
|
6069
|
-
label: "Result",
|
|
6070
|
-
stateKey: resultStateKey,
|
|
6071
|
-
renderAs: "json"
|
|
6072
|
-
}
|
|
6073
|
-
]
|
|
6074
|
-
};
|
|
6075
|
-
}
|
|
6076
|
-
function getUiGraphInitialState(uiGraph) {
|
|
6077
|
-
const state = {};
|
|
6078
|
-
for (const component of uiGraph.components) {
|
|
6079
|
-
if (component.type === "input" || component.type === "textarea") {
|
|
6080
|
-
state[component.stateKey] = component.defaultValue ?? "";
|
|
6081
|
-
}
|
|
6082
|
-
}
|
|
6083
|
-
return state;
|
|
6084
|
-
}
|
|
6085
|
-
function getUiGraphActionComponent(uiGraph, componentId) {
|
|
6086
|
-
return uiGraph.components.find(
|
|
6087
|
-
(component) => component.id === componentId && component.type === "button"
|
|
6088
|
-
);
|
|
6089
|
-
}
|
|
6090
|
-
function resolveUiGraphActionInputs(action, state) {
|
|
6091
|
-
const inputs = {};
|
|
6092
|
-
if (action.inputMappings) {
|
|
6093
|
-
for (const binding of action.inputMappings) {
|
|
6094
|
-
if (binding.inputKey) {
|
|
6095
|
-
inputs[binding.inputKey] = state[binding.stateKey];
|
|
6096
|
-
}
|
|
6097
|
-
}
|
|
6098
|
-
return inputs;
|
|
6099
|
-
}
|
|
6100
|
-
for (const [inputId, binding] of Object.entries(action.inputs ?? {})) {
|
|
6101
|
-
inputs[inputId] = binding.type === "state" ? state[binding.key] : binding.value;
|
|
6102
|
-
}
|
|
6103
|
-
return inputs;
|
|
6104
|
-
}
|
|
6105
|
-
function resolveUiGraphActionOutputStateValue(action, outputs) {
|
|
6106
|
-
var _a;
|
|
6107
|
-
if (!action.outputKey) {
|
|
6108
|
-
return outputs;
|
|
6309
|
+
visitedNodes: this.#visitedNodes
|
|
6310
|
+
};
|
|
6109
6311
|
}
|
|
6110
|
-
|
|
6111
|
-
|
|
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
|
+
};
|
|
6112
6338
|
}
|
|
6113
|
-
return (_a = outputs[action.outputKey]) == null ? void 0 : _a.value;
|
|
6114
6339
|
}
|
|
6115
|
-
function
|
|
6116
|
-
|
|
6117
|
-
const statePatch = {};
|
|
6118
|
-
for (const binding of bindings) {
|
|
6119
|
-
const stateKey = binding.stateKey.trim();
|
|
6120
|
-
if (!stateKey) {
|
|
6121
|
-
continue;
|
|
6122
|
-
}
|
|
6123
|
-
statePatch[stateKey] = resolveUiGraphOutputBindingValue(binding, outputs);
|
|
6124
|
-
}
|
|
6125
|
-
return statePatch;
|
|
6340
|
+
function getUiGraphComponentLabel(component) {
|
|
6341
|
+
return component.label || component.stateKey;
|
|
6126
6342
|
}
|
|
6127
|
-
function
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
return
|
|
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
|
+
};
|
|
6132
6353
|
}
|
|
6133
|
-
function
|
|
6134
|
-
|
|
6135
|
-
return action.inputMappings;
|
|
6136
|
-
}
|
|
6137
|
-
return Object.entries(action.inputs ?? {}).map(([inputKey, binding]) => ({
|
|
6138
|
-
inputKey,
|
|
6139
|
-
stateKey: binding.type === "state" ? binding.key : ""
|
|
6140
|
-
}));
|
|
6354
|
+
function hasUiGraphStateValue(state, key) {
|
|
6355
|
+
return Object.prototype.hasOwnProperty.call(state, key) && state[key] !== void 0;
|
|
6141
6356
|
}
|
|
6142
|
-
function
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
return outputs;
|
|
6357
|
+
function renderUiGraphOutputValue(value, renderAs) {
|
|
6358
|
+
if (renderAs === "json") {
|
|
6359
|
+
return stringifyUiGraphValue(value) ?? "";
|
|
6146
6360
|
}
|
|
6147
|
-
|
|
6148
|
-
|
|
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]";
|
|
6149
6368
|
}
|
|
6150
|
-
|
|
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;
|
|
6151
6382
|
}
|
|
6152
6383
|
|
|
6153
6384
|
// src/model/UiGraphRendererStyles.ts
|
|
@@ -6254,11 +6485,93 @@ var RIVET_WEB_APP_RENDERER_CSS = `
|
|
|
6254
6485
|
.rivet-web-app-output {
|
|
6255
6486
|
display: grid;
|
|
6256
6487
|
gap: 8px;
|
|
6488
|
+
position: relative;
|
|
6257
6489
|
}
|
|
6258
6490
|
|
|
6259
6491
|
.rivet-web-app-output-title {
|
|
6260
6492
|
color: var(--rivet-web-app-output-title);
|
|
6261
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);
|
|
6262
6575
|
}
|
|
6263
6576
|
|
|
6264
6577
|
.rivet-web-app-output pre {
|
|
@@ -6393,6 +6706,44 @@ body {
|
|
|
6393
6706
|
}
|
|
6394
6707
|
`;
|
|
6395
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
|
+
|
|
6396
6747
|
// src/model/NodeImpl.ts
|
|
6397
6748
|
var NodeImpl = class {
|
|
6398
6749
|
chartNode;
|
|
@@ -6748,8 +7099,7 @@ var processingFunctions = {
|
|
|
6748
7099
|
return input.trim();
|
|
6749
7100
|
},
|
|
6750
7101
|
truncate: (input, length = 50) => {
|
|
6751
|
-
if (input.length <= length)
|
|
6752
|
-
return input;
|
|
7102
|
+
if (input.length <= length) return input;
|
|
6753
7103
|
return input.slice(0, length) + "...";
|
|
6754
7104
|
},
|
|
6755
7105
|
list: (input, level = 1) => {
|
|
@@ -9878,17 +10228,17 @@ async function* streamChatCompletions3({
|
|
|
9878
10228
|
top_k,
|
|
9879
10229
|
prompt
|
|
9880
10230
|
}) {
|
|
9881
|
-
var _a, _b
|
|
10231
|
+
var _a, _b;
|
|
9882
10232
|
const { VertexAI } = await import("@google-cloud/vertexai");
|
|
9883
10233
|
process.env.GOOGLE_APPLICATION_CREDENTIALS = applicationCredentials;
|
|
9884
10234
|
const vertexAi = new VertexAI({ project, location });
|
|
9885
10235
|
const generativeModel = vertexAi.preview.getGenerativeModel({
|
|
9886
10236
|
model,
|
|
9887
|
-
|
|
9888
|
-
max_output_tokens,
|
|
10237
|
+
generationConfig: {
|
|
10238
|
+
maxOutputTokens: max_output_tokens,
|
|
9889
10239
|
temperature,
|
|
9890
|
-
top_p,
|
|
9891
|
-
top_k
|
|
10240
|
+
topP: top_p,
|
|
10241
|
+
topK: top_k
|
|
9892
10242
|
}
|
|
9893
10243
|
});
|
|
9894
10244
|
const response = await generativeModel.generateContentStream({
|
|
@@ -9897,10 +10247,12 @@ async function* streamChatCompletions3({
|
|
|
9897
10247
|
let hadChunks = false;
|
|
9898
10248
|
for await (const chunk of response.stream) {
|
|
9899
10249
|
hadChunks = true;
|
|
9900
|
-
|
|
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) {
|
|
9901
10253
|
yield {
|
|
9902
|
-
completion
|
|
9903
|
-
finish_reason:
|
|
10254
|
+
completion,
|
|
10255
|
+
finish_reason: candidate.finishReason,
|
|
9904
10256
|
model
|
|
9905
10257
|
};
|
|
9906
10258
|
} else {
|
|
@@ -10028,16 +10380,6 @@ function openAIEndpointToBaseURL(endpoint) {
|
|
|
10028
10380
|
function openAICompatibleEndpointToBaseURL(endpoint) {
|
|
10029
10381
|
return openAIEndpointToBaseURL(endpoint);
|
|
10030
10382
|
}
|
|
10031
|
-
function openAIBaseURLToEndpoint(baseURL) {
|
|
10032
|
-
const normalizedBaseURL = removeTrailingSlash(baseURL);
|
|
10033
|
-
try {
|
|
10034
|
-
const url = new URL(normalizedBaseURL);
|
|
10035
|
-
url.pathname = `${url.pathname.replace(/\/$/, "")}/chat/completions`;
|
|
10036
|
-
return url.toString();
|
|
10037
|
-
} catch {
|
|
10038
|
-
return `${normalizedBaseURL}/chat/completions`;
|
|
10039
|
-
}
|
|
10040
|
-
}
|
|
10041
10383
|
function parseBodyText(text) {
|
|
10042
10384
|
try {
|
|
10043
10385
|
return JSON.parse(text);
|
|
@@ -10089,38 +10431,26 @@ function createRequestBodyCapturingFetch(onRequestBody) {
|
|
|
10089
10431
|
function maybeCreateRequestBodyCapturingFetch(options2) {
|
|
10090
10432
|
return options2.onRequestBody == null ? void 0 : createRequestBodyCapturingFetch(options2.onRequestBody);
|
|
10091
10433
|
}
|
|
10092
|
-
async function resolveChatV2ProviderConfig(provider,
|
|
10434
|
+
async function resolveChatV2ProviderConfig(provider, _modelId, context, options2 = {}) {
|
|
10093
10435
|
var _a;
|
|
10094
10436
|
const headers = cleanHeaders({
|
|
10095
10437
|
...context.settings.chatNodeHeaders,
|
|
10096
10438
|
...options2.headers
|
|
10097
10439
|
});
|
|
10098
10440
|
switch (provider) {
|
|
10099
|
-
case "openai":
|
|
10100
|
-
const configuredBaseURL = options2.baseURL ? options2.baseURL : openAIEndpointToBaseURL(context.settings.openAiEndpoint || DEFAULT_CHAT_ENDPOINT);
|
|
10101
|
-
if (context.getChatNodeEndpoint == null) {
|
|
10102
|
-
return {
|
|
10103
|
-
baseURL: configuredBaseURL,
|
|
10104
|
-
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
10105
|
-
};
|
|
10106
|
-
}
|
|
10107
|
-
const resolved = await context.getChatNodeEndpoint(openAIBaseURLToEndpoint(configuredBaseURL), modelId);
|
|
10441
|
+
case "openai":
|
|
10108
10442
|
return {
|
|
10109
|
-
baseURL:
|
|
10110
|
-
headers:
|
|
10111
|
-
...headers,
|
|
10112
|
-
...resolved.headers
|
|
10113
|
-
})
|
|
10443
|
+
baseURL: void 0,
|
|
10444
|
+
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
10114
10445
|
};
|
|
10115
|
-
}
|
|
10116
10446
|
case "anthropic":
|
|
10117
10447
|
return {
|
|
10118
|
-
baseURL:
|
|
10448
|
+
baseURL: void 0,
|
|
10119
10449
|
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
10120
10450
|
};
|
|
10121
10451
|
case "google":
|
|
10122
10452
|
return {
|
|
10123
|
-
baseURL:
|
|
10453
|
+
baseURL: void 0,
|
|
10124
10454
|
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
10125
10455
|
};
|
|
10126
10456
|
case "custom": {
|
|
@@ -10139,9 +10469,9 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
|
|
|
10139
10469
|
switch (provider) {
|
|
10140
10470
|
case "openai": {
|
|
10141
10471
|
const providerInstance = (0, import_openai3.createOpenAI)({
|
|
10142
|
-
apiKey: options2.apiKey || context.settings.openAiKey || void 0,
|
|
10472
|
+
apiKey: options2.apiKey || context.settings.openAiApiKey || context.settings.openAiKey || void 0,
|
|
10143
10473
|
organization: context.settings.openAiOrganization || void 0,
|
|
10144
|
-
baseURL:
|
|
10474
|
+
baseURL: void 0,
|
|
10145
10475
|
headers: options2.headers,
|
|
10146
10476
|
fetch: maybeCreateRequestBodyCapturingFetch(options2)
|
|
10147
10477
|
});
|
|
@@ -10149,8 +10479,8 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
|
|
|
10149
10479
|
}
|
|
10150
10480
|
case "anthropic": {
|
|
10151
10481
|
const providerInstance = (0, import_anthropic2.createAnthropic)({
|
|
10152
|
-
apiKey: options2.apiKey || context.getPluginConfig("anthropicApiKey") || void 0,
|
|
10153
|
-
baseURL:
|
|
10482
|
+
apiKey: options2.apiKey || context.settings.anthropicApiKey || context.getPluginConfig("anthropicApiKey") || void 0,
|
|
10483
|
+
baseURL: void 0,
|
|
10154
10484
|
headers: options2.headers,
|
|
10155
10485
|
fetch: maybeCreateRequestBodyCapturingFetch(options2)
|
|
10156
10486
|
});
|
|
@@ -10158,8 +10488,8 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
|
|
|
10158
10488
|
}
|
|
10159
10489
|
case "google": {
|
|
10160
10490
|
const providerInstance = (0, import_google2.createGoogleGenerativeAI)({
|
|
10161
|
-
apiKey: options2.apiKey || context.getPluginConfig("googleApiKey") || void 0,
|
|
10162
|
-
baseURL:
|
|
10491
|
+
apiKey: options2.apiKey || context.settings.googleApiKey || context.getPluginConfig("googleApiKey") || void 0,
|
|
10492
|
+
baseURL: void 0,
|
|
10163
10493
|
headers: options2.headers,
|
|
10164
10494
|
fetch: maybeCreateRequestBodyCapturingFetch(options2)
|
|
10165
10495
|
});
|
|
@@ -10210,6 +10540,25 @@ async function getResolvedModelOptions(data, context) {
|
|
|
10210
10540
|
const modelOptions = await ((_a = context.getChatModelOptions) == null ? void 0 : _a.call(context, data.provider).catch(() => void 0)) ?? getChatV2ModelOptions(data.provider);
|
|
10211
10541
|
return modelOptions.some((option) => option.value === data.model) ? modelOptions : [{ value: data.model, label: `${data.model} (Current)` }, ...modelOptions];
|
|
10212
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
|
+
}
|
|
10213
10562
|
function getModelEditors(modelOptions) {
|
|
10214
10563
|
return group(
|
|
10215
10564
|
"Model",
|
|
@@ -10247,14 +10596,22 @@ function getModelEditors(modelOptions) {
|
|
|
10247
10596
|
{ value: "environment", label: "Configured key" },
|
|
10248
10597
|
{ value: "input", label: "Input port" }
|
|
10249
10598
|
],
|
|
10250
|
-
helperMessage:
|
|
10599
|
+
helperMessage: getApiKeySourceHelperMessage
|
|
10251
10600
|
},
|
|
10252
10601
|
{
|
|
10253
10602
|
type: "string",
|
|
10254
|
-
label: "
|
|
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"
|
|
10608
|
+
},
|
|
10609
|
+
{
|
|
10610
|
+
type: "string",
|
|
10611
|
+
label: "Alternative API key env var",
|
|
10255
10612
|
dataKey: "customProviderApiKeyEnvVarName",
|
|
10256
10613
|
placeholder: "CUSTOM_PROVIDER_API_KEY",
|
|
10257
|
-
helperMessage: "
|
|
10614
|
+
helperMessage: "If set, this env var is used instead of CUSTOM_PROVIDER_API_KEY.",
|
|
10258
10615
|
hideIf: (data) => data.provider !== "custom" || data.apiKeySource === "input"
|
|
10259
10616
|
}
|
|
10260
10617
|
],
|
|
@@ -10587,14 +10944,6 @@ function getOutputEditors() {
|
|
|
10587
10944
|
}
|
|
10588
10945
|
function getProviderAdvancedEditors() {
|
|
10589
10946
|
return group("Provider Advanced", [
|
|
10590
|
-
{
|
|
10591
|
-
type: "string",
|
|
10592
|
-
label: "Base URL",
|
|
10593
|
-
dataKey: "baseURL",
|
|
10594
|
-
useInputToggleDataKey: "useBaseURLInput",
|
|
10595
|
-
placeholder: "Optional provider base URL override",
|
|
10596
|
-
hideIf: (data) => data.provider === "custom"
|
|
10597
|
-
},
|
|
10598
10947
|
{
|
|
10599
10948
|
type: "keyValuePair",
|
|
10600
10949
|
label: "Headers",
|
|
@@ -10674,6 +11023,7 @@ function createLLMChatV2NodeData() {
|
|
|
10674
11023
|
}),
|
|
10675
11024
|
provider: "openai",
|
|
10676
11025
|
apiKeySource: "environment",
|
|
11026
|
+
customProviderApiKeyProgrammaticName: "",
|
|
10677
11027
|
customProviderApiKeyEnvVarName: "CUSTOM_PROVIDER_API_KEY",
|
|
10678
11028
|
customProviderBaseURL: "",
|
|
10679
11029
|
useCustomProviderBaseURLInput: false,
|
|
@@ -10874,6 +11224,102 @@ function createsLLMChatV2ToolResponseFormatConflictForEdit(previousData, nextDat
|
|
|
10874
11224
|
return hasLLMChatV2ToolResponseFormatConflict(nextData) && !hasLLMChatV2ToolResponseFormatConflict(previousData);
|
|
10875
11225
|
}
|
|
10876
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
|
+
|
|
10877
11323
|
// src/model/chat-v2/chatV2EditorCache.ts
|
|
10878
11324
|
var import_safe_stable_stringify4 = __toESM(require("safe-stable-stringify"), 1);
|
|
10879
11325
|
function buildLLMChatV2EditorCacheKey(parts) {
|
|
@@ -10938,8 +11384,8 @@ function fingerprintNodeDataForCache(data) {
|
|
|
10938
11384
|
const isCustomProvider = data.provider === "custom";
|
|
10939
11385
|
return {
|
|
10940
11386
|
...data,
|
|
10941
|
-
baseURL:
|
|
10942
|
-
useBaseURLInput:
|
|
11387
|
+
baseURL: "",
|
|
11388
|
+
useBaseURLInput: false,
|
|
10943
11389
|
customProviderBaseURL: isCustomProvider ? data.customProviderBaseURL : "",
|
|
10944
11390
|
useCustomProviderBaseURLInput: isCustomProvider ? data.useCustomProviderBaseURLInput : false,
|
|
10945
11391
|
extraProviderOptions: data.useExtraProviderOptionsInput ? "" : fingerprintSecret(data.extraProviderOptions) ?? "",
|
|
@@ -10989,43 +11435,6 @@ function resolveLLMChatV2Headers(data, inputs) {
|
|
|
10989
11435
|
const cleaned = cleanHeaders(resolvedHeaders ?? {});
|
|
10990
11436
|
return Object.keys(cleaned).length > 0 ? cleaned : void 0;
|
|
10991
11437
|
}
|
|
10992
|
-
function resolveConfiguredProviderApiKey(data, context) {
|
|
10993
|
-
var _a, _b, _c;
|
|
10994
|
-
switch (data.provider) {
|
|
10995
|
-
case "openai":
|
|
10996
|
-
return context.settings.openAiKey || void 0;
|
|
10997
|
-
case "anthropic":
|
|
10998
|
-
return context.getPluginConfig("anthropicApiKey") || void 0;
|
|
10999
|
-
case "google":
|
|
11000
|
-
return context.getPluginConfig("googleApiKey") || void 0;
|
|
11001
|
-
case "custom": {
|
|
11002
|
-
const envVarName = (_a = data.customProviderApiKeyEnvVarName) == null ? void 0 : _a.trim();
|
|
11003
|
-
if (!envVarName) {
|
|
11004
|
-
return void 0;
|
|
11005
|
-
}
|
|
11006
|
-
const pluginEnvValue = (_b = context.settings.pluginEnv) == null ? void 0 : _b[envVarName];
|
|
11007
|
-
const processEnv = (_c = globalThis.process) == null ? void 0 : _c.env;
|
|
11008
|
-
const apiKey = pluginEnvValue || (processEnv == null ? void 0 : processEnv[envVarName]);
|
|
11009
|
-
if (!apiKey) {
|
|
11010
|
-
throw new Error(
|
|
11011
|
-
`Custom provider API key env var ${envVarName} is not set. Use Input port or configure the environment variable.`
|
|
11012
|
-
);
|
|
11013
|
-
}
|
|
11014
|
-
return apiKey;
|
|
11015
|
-
}
|
|
11016
|
-
}
|
|
11017
|
-
}
|
|
11018
|
-
function resolveLLMChatV2ApiKey(data, inputs, context) {
|
|
11019
|
-
var _a;
|
|
11020
|
-
if (data.apiKeySource !== "input") {
|
|
11021
|
-
return resolveConfiguredProviderApiKey(data, context);
|
|
11022
|
-
}
|
|
11023
|
-
const apiKey = (_a = coerceTypeOptional(inputs["apiKey"], "string")) == null ? void 0 : _a.trim();
|
|
11024
|
-
if (!apiKey) {
|
|
11025
|
-
throw new Error("API Key input is required when API key source is Input port.");
|
|
11026
|
-
}
|
|
11027
|
-
return apiKey;
|
|
11028
|
-
}
|
|
11029
11438
|
function parseExtraProviderOptionsText(rawText) {
|
|
11030
11439
|
const raw = rawText.trim();
|
|
11031
11440
|
if (!raw) {
|
|
@@ -11169,9 +11578,9 @@ function resolveLLMChatV2BuiltInTools(data, context, config, apiKey) {
|
|
|
11169
11578
|
return void 0;
|
|
11170
11579
|
}
|
|
11171
11580
|
const provider = (0, import_openai4.createOpenAI)({
|
|
11172
|
-
apiKey: apiKey || context.settings.openAiKey || void 0,
|
|
11581
|
+
apiKey: apiKey || context.settings.openAiApiKey || context.settings.openAiKey || void 0,
|
|
11173
11582
|
organization: context.settings.openAiOrganization || void 0,
|
|
11174
|
-
baseURL:
|
|
11583
|
+
baseURL: void 0,
|
|
11175
11584
|
headers: config.headers
|
|
11176
11585
|
});
|
|
11177
11586
|
const tools = {};
|
|
@@ -11190,8 +11599,8 @@ function resolveLLMChatV2BuiltInTools(data, context, config, apiKey) {
|
|
|
11190
11599
|
return void 0;
|
|
11191
11600
|
}
|
|
11192
11601
|
const provider = (0, import_google3.createGoogleGenerativeAI)({
|
|
11193
|
-
apiKey: apiKey || context.getPluginConfig("googleApiKey") || void 0,
|
|
11194
|
-
baseURL:
|
|
11602
|
+
apiKey: apiKey || context.settings.googleApiKey || context.getPluginConfig("googleApiKey") || void 0,
|
|
11603
|
+
baseURL: void 0,
|
|
11195
11604
|
headers: config.headers
|
|
11196
11605
|
});
|
|
11197
11606
|
const tools = {};
|
|
@@ -11212,8 +11621,8 @@ function resolveLLMChatV2BuiltInTools(data, context, config, apiKey) {
|
|
|
11212
11621
|
|
|
11213
11622
|
// src/model/chat-v2/llmChatV2NodeRuntime.ts
|
|
11214
11623
|
function resolveLLMChatV2BaseURL(data, inputs) {
|
|
11215
|
-
var _a
|
|
11216
|
-
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;
|
|
11217
11626
|
}
|
|
11218
11627
|
async function resolveLLMChatV2RuntimeConfig(params) {
|
|
11219
11628
|
const { data, nodeId, inputs, context } = params;
|
|
@@ -11224,17 +11633,27 @@ async function resolveLLMChatV2RuntimeConfig(params) {
|
|
|
11224
11633
|
const modelId = getInputOrData(data, inputs, "model", "string");
|
|
11225
11634
|
const baseURL = resolveLLMChatV2BaseURL(data, inputs);
|
|
11226
11635
|
const nodeHeaders = resolveLLMChatV2Headers(data, inputs);
|
|
11227
|
-
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;
|
|
11228
11645
|
const requestBodies = data.outputRequestStatus ? [] : void 0;
|
|
11229
|
-
const
|
|
11646
|
+
const resolvedProvider = await createResolvedChatV2Provider({
|
|
11647
|
+
provider,
|
|
11648
|
+
modelId,
|
|
11649
|
+
context,
|
|
11230
11650
|
baseURL,
|
|
11231
|
-
headers: nodeHeaders
|
|
11232
|
-
|
|
11233
|
-
const model = createChatV2Model(provider, modelId, context, {
|
|
11234
|
-
...providerConfig,
|
|
11235
|
-
apiKey,
|
|
11651
|
+
headers: nodeHeaders,
|
|
11652
|
+
credential,
|
|
11236
11653
|
onRequestBody: requestBodies == null ? void 0 : (body) => requestBodies.push(body)
|
|
11237
11654
|
});
|
|
11655
|
+
const providerConfig = resolvedProvider.config;
|
|
11656
|
+
const model = resolvedProvider.model;
|
|
11238
11657
|
const prompt = inputs["prompt"];
|
|
11239
11658
|
const systemPrompt = inputs["systemPrompt"];
|
|
11240
11659
|
const functions = data.useToolCalling && inputs["functions"] != null ? coerceTypeOptional(inputs["functions"], "gpt-function[]") : void 0;
|
|
@@ -11289,6 +11708,7 @@ async function resolveLLMChatV2RuntimeConfig(params) {
|
|
|
11289
11708
|
toolChoice
|
|
11290
11709
|
});
|
|
11291
11710
|
return {
|
|
11711
|
+
providerProfile: resolvedProvider.profile,
|
|
11292
11712
|
runOptions,
|
|
11293
11713
|
functions,
|
|
11294
11714
|
cacheKey,
|
|
@@ -11477,34 +11897,21 @@ function buildTextArgs(options2) {
|
|
|
11477
11897
|
const args = {
|
|
11478
11898
|
model: options2.model,
|
|
11479
11899
|
messages: options2.messages,
|
|
11480
|
-
maxRetries: 0
|
|
11900
|
+
maxRetries: options2.maxRetries ?? 0
|
|
11481
11901
|
};
|
|
11482
|
-
if (options2.tools !== void 0)
|
|
11483
|
-
|
|
11484
|
-
if (options2.
|
|
11485
|
-
|
|
11486
|
-
if (options2.
|
|
11487
|
-
|
|
11488
|
-
if (options2.
|
|
11489
|
-
|
|
11490
|
-
if (options2.
|
|
11491
|
-
|
|
11492
|
-
if (options2.
|
|
11493
|
-
|
|
11494
|
-
if (options2.
|
|
11495
|
-
args.frequencyPenalty = options2.frequencyPenalty;
|
|
11496
|
-
if (options2.stopSequences !== void 0)
|
|
11497
|
-
args.stopSequences = options2.stopSequences;
|
|
11498
|
-
if (options2.seed !== void 0)
|
|
11499
|
-
args.seed = options2.seed;
|
|
11500
|
-
if (options2.responseOutput !== void 0)
|
|
11501
|
-
args.output = options2.responseOutput;
|
|
11502
|
-
if (options2.providerOptions !== void 0)
|
|
11503
|
-
args.providerOptions = options2.providerOptions;
|
|
11504
|
-
if (options2.toolChoice !== void 0)
|
|
11505
|
-
args.toolChoice = options2.toolChoice;
|
|
11506
|
-
if (options2.abortSignal !== void 0)
|
|
11507
|
-
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;
|
|
11508
11915
|
return args;
|
|
11509
11916
|
}
|
|
11510
11917
|
function toStreamedFunctionCalls(toolCalls) {
|
|
@@ -11665,8 +12072,7 @@ async function partToUserContent(part, options2) {
|
|
|
11665
12072
|
function stringifyParts(parts) {
|
|
11666
12073
|
const arr = Array.isArray(parts) ? parts : [parts];
|
|
11667
12074
|
return arr.map((p) => {
|
|
11668
|
-
if (typeof p === "string")
|
|
11669
|
-
return p;
|
|
12075
|
+
if (typeof p === "string") return p;
|
|
11670
12076
|
throw new Error(`Expected string content, got ${p.type}`);
|
|
11671
12077
|
}).join("\n\n");
|
|
11672
12078
|
}
|
|
@@ -11792,6 +12198,69 @@ function chatV2ToolsToAiSdk(functions) {
|
|
|
11792
12198
|
return rivetToolsToAiSdk(functions);
|
|
11793
12199
|
}
|
|
11794
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
|
+
|
|
11795
12264
|
// src/model/chat-v2/chatV2Errors.ts
|
|
11796
12265
|
var STATUS_TEXT = {
|
|
11797
12266
|
400: "Bad Request",
|
|
@@ -12273,43 +12742,41 @@ function normalizeProviderFailureMessage(error, options2) {
|
|
|
12273
12742
|
function normalizeProviderFailureMessages(errors, options2) {
|
|
12274
12743
|
return errors.map((error) => normalizeProviderFailureMessage(error, options2));
|
|
12275
12744
|
}
|
|
12276
|
-
async function runChatV2WithRetry(chatOptions,
|
|
12277
|
-
const repeatTimes = retryOptions.retryOnNon200 ? normalizeLLMChatV2RetryCount(retryOptions.retryOnNon200RepeatTimes) : 0;
|
|
12278
|
-
const cooldownMs = normalizeLLMChatV2RetryCooldownMs(retryOptions.retryOnNon200CooldownMs);
|
|
12745
|
+
async function runChatV2WithRetry(chatOptions, retryPlan, signal, transportMode) {
|
|
12279
12746
|
const requestStatuses = [];
|
|
12280
12747
|
const requestErrors = [];
|
|
12281
12748
|
for (let attempt = 0; ; attempt++) {
|
|
12282
12749
|
try {
|
|
12283
12750
|
const result = transportMode === "generate" ? await generateChatV2(chatOptions) : await streamChatV2(chatOptions);
|
|
12284
12751
|
const statusCode = result.requestStatus ?? 200;
|
|
12285
|
-
if (
|
|
12752
|
+
if (retryPlan.enabled) {
|
|
12286
12753
|
requestStatuses.push(statusCode);
|
|
12287
12754
|
}
|
|
12288
|
-
if (!
|
|
12755
|
+
if (!retryPlan.enabled || statusCode === 200) {
|
|
12289
12756
|
return { result, requestStatuses, requestErrors };
|
|
12290
12757
|
}
|
|
12291
12758
|
const responseError = buildNon200StatusError(statusCode);
|
|
12292
12759
|
requestErrors.push(responseError);
|
|
12293
|
-
if (attempt >= repeatTimes) {
|
|
12760
|
+
if (attempt >= retryPlan.repeatTimes) {
|
|
12294
12761
|
return { result, requestStatuses, requestErrors, responseError };
|
|
12295
12762
|
}
|
|
12296
|
-
await waitForLLMChatV2RetryCooldown(cooldownMs,
|
|
12763
|
+
await waitForLLMChatV2RetryCooldown(retryPlan.cooldownMs, signal);
|
|
12297
12764
|
} catch (error) {
|
|
12298
12765
|
const statusCode = getChatV2ProviderErrorStatusCode(error);
|
|
12299
|
-
if (!
|
|
12766
|
+
if (!retryPlan.enabled || statusCode == null || statusCode === 200) {
|
|
12300
12767
|
throw error;
|
|
12301
12768
|
}
|
|
12302
12769
|
requestStatuses.push(statusCode);
|
|
12303
12770
|
requestErrors.push(error);
|
|
12304
|
-
if (attempt >= repeatTimes) {
|
|
12771
|
+
if (attempt >= retryPlan.repeatTimes) {
|
|
12305
12772
|
throw new ChatV2RetryFailure(error, requestStatuses, requestErrors);
|
|
12306
12773
|
}
|
|
12307
|
-
await waitForLLMChatV2RetryCooldown(cooldownMs,
|
|
12774
|
+
await waitForLLMChatV2RetryCooldown(retryPlan.cooldownMs, signal);
|
|
12308
12775
|
}
|
|
12309
12776
|
}
|
|
12310
12777
|
}
|
|
12311
|
-
function buildProviderFailureResult(requestMessages, options2, normalizedError, rawError, requestStatuses, requestErrors) {
|
|
12312
|
-
if (!
|
|
12778
|
+
function buildProviderFailureResult(requestMessages, options2, plan, normalizedError, rawError, requestStatuses, requestErrors) {
|
|
12779
|
+
if (!plan.output.outputRequestStatus) {
|
|
12313
12780
|
return void 0;
|
|
12314
12781
|
}
|
|
12315
12782
|
const statusCode = getChatV2ProviderErrorStatusCode(normalizedError);
|
|
@@ -12317,8 +12784,8 @@ function buildProviderFailureResult(requestMessages, options2, normalizedError,
|
|
|
12317
12784
|
return void 0;
|
|
12318
12785
|
}
|
|
12319
12786
|
const responseError = getProviderFailureMessage(normalizedError);
|
|
12320
|
-
const retryRequestStatuses =
|
|
12321
|
-
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] : [];
|
|
12322
12789
|
const commonOutputs = createChatV2ProviderFailureOutputs({
|
|
12323
12790
|
requestMessages,
|
|
12324
12791
|
responseStatus: statusCode,
|
|
@@ -12326,10 +12793,10 @@ function buildProviderFailureResult(requestMessages, options2, normalizedError,
|
|
|
12326
12793
|
requestStatuses: retryRequestStatuses,
|
|
12327
12794
|
requestErrors: retryRequestErrors,
|
|
12328
12795
|
requestBodies: options2.requestBodies,
|
|
12329
|
-
outputUsage:
|
|
12330
|
-
outputReasoning:
|
|
12331
|
-
includeFunctionCalls:
|
|
12332
|
-
retryOnNon200:
|
|
12796
|
+
outputUsage: plan.output.outputUsage,
|
|
12797
|
+
outputReasoning: plan.output.outputReasoning,
|
|
12798
|
+
includeFunctionCalls: plan.output.includeFunctionCalls,
|
|
12799
|
+
retryOnNon200: plan.retry.enabled
|
|
12333
12800
|
});
|
|
12334
12801
|
const allMessagesOutput = commonOutputs["all-messages"];
|
|
12335
12802
|
if ((allMessagesOutput == null ? void 0 : allMessagesOutput.type) !== "chat-message[]") {
|
|
@@ -12360,25 +12827,15 @@ async function runChatV2Pipeline(options2) {
|
|
|
12360
12827
|
});
|
|
12361
12828
|
const functionTools = options2.functions != null && options2.functions.length > 0 ? chatV2ToolsToAiSdk(options2.functions) : void 0;
|
|
12362
12829
|
const tools = functionTools == null ? options2.additionalTools : options2.additionalTools == null ? functionTools : { ...functionTools, ...options2.additionalTools };
|
|
12363
|
-
const
|
|
12364
|
-
|
|
12830
|
+
const plan = buildChatV2RequestPlan({
|
|
12831
|
+
...options2,
|
|
12832
|
+
messages: modelMessages,
|
|
12833
|
+
tools
|
|
12834
|
+
});
|
|
12835
|
+
const shouldStreamResponse = plan.transportMode === "stream";
|
|
12365
12836
|
const chatResponse = await runChatV2WithRetry(
|
|
12366
12837
|
{
|
|
12367
|
-
|
|
12368
|
-
messages: modelMessages,
|
|
12369
|
-
tools,
|
|
12370
|
-
maxTokens: options2.maxTokens,
|
|
12371
|
-
temperature: options2.temperature,
|
|
12372
|
-
topP: options2.topP,
|
|
12373
|
-
topK: options2.topK,
|
|
12374
|
-
presencePenalty: options2.presencePenalty,
|
|
12375
|
-
frequencyPenalty: options2.frequencyPenalty,
|
|
12376
|
-
stopSequences: options2.stopSequences,
|
|
12377
|
-
seed: options2.seed,
|
|
12378
|
-
responseOutput: options2.responseOutput,
|
|
12379
|
-
responseFormat: options2.responseFormat,
|
|
12380
|
-
providerOptions: options2.providerOptions,
|
|
12381
|
-
toolChoice: options2.toolChoice,
|
|
12838
|
+
...plan.request,
|
|
12382
12839
|
abortSignal: options2.context.signal,
|
|
12383
12840
|
executeStream: options2.executeStream,
|
|
12384
12841
|
executeGenerate: options2.executeGenerate,
|
|
@@ -12401,16 +12858,17 @@ async function runChatV2Pipeline(options2) {
|
|
|
12401
12858
|
outputUsage: false,
|
|
12402
12859
|
outputReasoning: false,
|
|
12403
12860
|
outputRequestStatus: false,
|
|
12404
|
-
includeFunctionCalls:
|
|
12405
|
-
functionCallMode:
|
|
12861
|
+
includeFunctionCalls: plan.output.includeFunctionCalls,
|
|
12862
|
+
functionCallMode: plan.output.functionCallMode,
|
|
12406
12863
|
retryOnNon200: false,
|
|
12407
12864
|
responseFormat: void 0
|
|
12408
12865
|
})
|
|
12409
12866
|
);
|
|
12410
12867
|
}
|
|
12411
12868
|
},
|
|
12412
|
-
|
|
12413
|
-
|
|
12869
|
+
plan.retry,
|
|
12870
|
+
options2.context.signal,
|
|
12871
|
+
plan.transportMode
|
|
12414
12872
|
).catch((caughtError) => {
|
|
12415
12873
|
const retryFailure = isChatV2RetryFailure(caughtError) ? caughtError : void 0;
|
|
12416
12874
|
const rawError = (retryFailure == null ? void 0 : retryFailure.error) ?? caughtError;
|
|
@@ -12423,6 +12881,7 @@ async function runChatV2Pipeline(options2) {
|
|
|
12423
12881
|
const failureResult = buildProviderFailureResult(
|
|
12424
12882
|
requestMessages,
|
|
12425
12883
|
options2,
|
|
12884
|
+
plan,
|
|
12426
12885
|
normalizedError,
|
|
12427
12886
|
rawError,
|
|
12428
12887
|
requestStatuses2,
|
|
@@ -12453,13 +12912,13 @@ async function runChatV2Pipeline(options2) {
|
|
|
12453
12912
|
requestStatuses,
|
|
12454
12913
|
requestErrors,
|
|
12455
12914
|
requestBodies: options2.requestBodies,
|
|
12456
|
-
outputUsage:
|
|
12457
|
-
outputReasoning:
|
|
12458
|
-
outputRequestStatus:
|
|
12459
|
-
includeFunctionCalls:
|
|
12460
|
-
functionCallMode:
|
|
12461
|
-
retryOnNon200:
|
|
12462
|
-
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
|
|
12463
12922
|
});
|
|
12464
12923
|
const allMessagesOutput = commonOutputs["all-messages"];
|
|
12465
12924
|
if ((allMessagesOutput == null ? void 0 : allMessagesOutput.type) !== "chat-message[]") {
|
|
@@ -12739,7 +13198,7 @@ async function delegateToolCall(rawFunctionCall, context, config) {
|
|
|
12739
13198
|
|
|
12740
13199
|
// src/model/nodes/LLMChatV2Node.ts
|
|
12741
13200
|
function usesBaseURLInput(data) {
|
|
12742
|
-
return data.provider === "custom"
|
|
13201
|
+
return data.provider === "custom" && data.useCustomProviderBaseURLInput;
|
|
12743
13202
|
}
|
|
12744
13203
|
function getCustomProviderBaseURLBodyValue(data) {
|
|
12745
13204
|
if (data.provider !== "custom") {
|
|
@@ -12817,8 +13276,8 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
12817
13276
|
}
|
|
12818
13277
|
if (usesBaseURLInput(this.data)) {
|
|
12819
13278
|
inputs.unshift({
|
|
12820
|
-
id:
|
|
12821
|
-
title:
|
|
13279
|
+
id: "customProviderBaseURL",
|
|
13280
|
+
title: "Provider base URL",
|
|
12822
13281
|
dataType: "string",
|
|
12823
13282
|
required: false
|
|
12824
13283
|
});
|
|
@@ -23429,10 +23888,8 @@ var ToMarkdownTableNodeImpl = class extends NodeImpl {
|
|
|
23429
23888
|
}
|
|
23430
23889
|
getBody() {
|
|
23431
23890
|
const parts = [];
|
|
23432
|
-
if (this.data.includeHeaders)
|
|
23433
|
-
|
|
23434
|
-
if (this.data.alignPipes)
|
|
23435
|
-
parts.push("Pipes Aligned");
|
|
23891
|
+
if (this.data.includeHeaders) parts.push("With Header Row");
|
|
23892
|
+
if (this.data.alignPipes) parts.push("Pipes Aligned");
|
|
23436
23893
|
return parts.length > 0 ? parts.join(", ") : void 0;
|
|
23437
23894
|
}
|
|
23438
23895
|
static getUIData() {
|
|
@@ -23815,8 +24272,7 @@ var ToTreeNodeImpl = class extends NodeImpl {
|
|
|
23815
24272
|
};
|
|
23816
24273
|
}
|
|
23817
24274
|
buildTree(objects, parentPath = "", level = 0, isLast = true) {
|
|
23818
|
-
if (!Array.isArray(objects) || objects.length === 0)
|
|
23819
|
-
return "";
|
|
24275
|
+
if (!Array.isArray(objects) || objects.length === 0) return "";
|
|
23820
24276
|
let result = "";
|
|
23821
24277
|
const sortedObjects = this.data.useSortAlphabetically ? (0, import_lodash_es16.sortBy)(objects, (obj) => String((0, import_lodash_es16.get)(obj, "path", ""))) : objects;
|
|
23822
24278
|
sortedObjects.forEach((obj, index) => {
|
|
@@ -24081,10 +24537,8 @@ var getServerOptions = async (context) => {
|
|
|
24081
24537
|
return [];
|
|
24082
24538
|
};
|
|
24083
24539
|
var getServerHelperMessage = (context, optionsLength) => {
|
|
24084
|
-
if (optionsLength > 0)
|
|
24085
|
-
|
|
24086
|
-
if (context.executor !== "nodejs")
|
|
24087
|
-
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";
|
|
24088
24542
|
return "No MCP servers found in config";
|
|
24089
24543
|
};
|
|
24090
24544
|
|
|
@@ -26483,7 +26937,9 @@ var AutoEvalsNodeImpl = {
|
|
|
26483
26937
|
return {
|
|
26484
26938
|
["score"]: {
|
|
26485
26939
|
type: "number",
|
|
26486
|
-
|
|
26940
|
+
// Newer AutoEvals versions represent unavailable scores as null, while
|
|
26941
|
+
// this node's declared port remains numeric.
|
|
26942
|
+
value: result.score ?? 0
|
|
26487
26943
|
},
|
|
26488
26944
|
["rationale"]: {
|
|
26489
26945
|
type: "string",
|
|
@@ -26518,8 +26974,7 @@ var import_ts_dedent78 = require("ts-dedent");
|
|
|
26518
26974
|
var import_assemblyai = require("assemblyai");
|
|
26519
26975
|
function getTranscriptIds(inputs) {
|
|
26520
26976
|
const input = inputs["transcript_ids"];
|
|
26521
|
-
if (!input)
|
|
26522
|
-
return void 0;
|
|
26977
|
+
if (!input) return void 0;
|
|
26523
26978
|
if (input.type === "string" || input.type === "any" && typeof input.value === "string") {
|
|
26524
26979
|
return [coerceType(input, "string")];
|
|
26525
26980
|
} else if (input.type === "string[]" || input.type === "any[]" || input.type === "any" && Array.isArray(input.value)) {
|
|
@@ -26722,8 +27177,7 @@ var LemurQaNodeImpl = {
|
|
|
26722
27177
|
};
|
|
26723
27178
|
function getQuestions(inputs) {
|
|
26724
27179
|
const input = inputs["questions"];
|
|
26725
|
-
if (!input)
|
|
26726
|
-
throw new Error("Questions are required.");
|
|
27180
|
+
if (!input) throw new Error("Questions are required.");
|
|
26727
27181
|
if (input.type === "string") {
|
|
26728
27182
|
return [
|
|
26729
27183
|
{
|
|
@@ -26841,8 +27295,7 @@ var TranscribeAudioNodeImpl = {
|
|
|
26841
27295
|
},
|
|
26842
27296
|
async process(data, inputs, context) {
|
|
26843
27297
|
const input = inputs["audio"];
|
|
26844
|
-
if (!input)
|
|
26845
|
-
throw new Error("Audio input is required.");
|
|
27298
|
+
if (!input) throw new Error("Audio input is required.");
|
|
26846
27299
|
const client = getClient(context);
|
|
26847
27300
|
let audioUrl;
|
|
26848
27301
|
if (input.type === "audio") {
|
|
@@ -27036,8 +27489,7 @@ var LemurTaskNodeImpl = {
|
|
|
27036
27489
|
prompt: coerceTypeOptional(inputs["prompt"], "string") || data.prompt || "",
|
|
27037
27490
|
...getLemurParams(inputs, data)
|
|
27038
27491
|
};
|
|
27039
|
-
if (!params.prompt)
|
|
27040
|
-
throw new Error("Prompt must be provided.");
|
|
27492
|
+
if (!params.prompt) throw new Error("Prompt must be provided.");
|
|
27041
27493
|
const { response } = await client.lemur.task(params);
|
|
27042
27494
|
return {
|
|
27043
27495
|
["response"]: {
|
|
@@ -27711,8 +28163,14 @@ var pineconePlugin = {
|
|
|
27711
28163
|
// src/plugins/pinecone/index.ts
|
|
27712
28164
|
var pinecone_default = pineconePlugin;
|
|
27713
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
|
+
|
|
27714
28173
|
// src/plugins/gentrace/plugin.ts
|
|
27715
|
-
var import_core = require("@gentrace/core");
|
|
27716
28174
|
var import_lodash_es18 = require("lodash");
|
|
27717
28175
|
|
|
27718
28176
|
// src/integrations/GptTokenizerTokenizer.ts
|
|
@@ -27782,6 +28240,35 @@ ${parameterName}?: ${Array.isArray(value == null ? void 0 : value.type) ? value.
|
|
|
27782
28240
|
}
|
|
27783
28241
|
};
|
|
27784
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
|
+
|
|
27785
28272
|
// src/plugins/gentrace/plugin.ts
|
|
27786
28273
|
var apiKeyConfigSpec = {
|
|
27787
28274
|
type: "secret",
|
|
@@ -27791,7 +28278,7 @@ var apiKeyConfigSpec = {
|
|
|
27791
28278
|
helperText: "Create at https://gentrace.ai/settings/api-keys"
|
|
27792
28279
|
};
|
|
27793
28280
|
function initializeGentrace(gentraceApiKey) {
|
|
27794
|
-
(0,
|
|
28281
|
+
(0, import_init.init)({
|
|
27795
28282
|
apiKey: gentraceApiKey
|
|
27796
28283
|
});
|
|
27797
28284
|
}
|
|
@@ -27806,8 +28293,8 @@ var runGentraceTests = async (gentracePipelineSlug, settings, project, graph, na
|
|
|
27806
28293
|
throw new Error("Graph ID not set.");
|
|
27807
28294
|
}
|
|
27808
28295
|
initializeGentrace(gentraceApiKey);
|
|
27809
|
-
const response = await (0,
|
|
27810
|
-
const pipeline = new
|
|
28296
|
+
const response = await (0, import_run_test.runTest)(gentracePipelineSlug, async (testCase) => {
|
|
28297
|
+
const pipeline = new import_pipeline.Pipeline({
|
|
27811
28298
|
slug: gentracePipelineSlug
|
|
27812
28299
|
});
|
|
27813
28300
|
const runner = pipeline.start();
|
|
@@ -27826,7 +28313,7 @@ var runGentraceTests = async (gentracePipelineSlug, settings, project, graph, na
|
|
|
27826
28313
|
const runContextValues = (0, import_lodash_es18.cloneDeep)(contextValues);
|
|
27827
28314
|
await processor.processGraph(
|
|
27828
28315
|
{
|
|
27829
|
-
settings,
|
|
28316
|
+
settings: resolveProcessSettings(settings),
|
|
27830
28317
|
nativeApi,
|
|
27831
28318
|
tokenizer: new GptTokenizerTokenizer()
|
|
27832
28319
|
},
|
|
@@ -27856,8 +28343,8 @@ var runRemoteGentraceTests = async (gentracePipelineSlug, settings, project, gra
|
|
|
27856
28343
|
throw new Error("Graph ID not set.");
|
|
27857
28344
|
}
|
|
27858
28345
|
initializeGentrace(gentraceApiKey);
|
|
27859
|
-
const response = await (0,
|
|
27860
|
-
const pipeline = new
|
|
28346
|
+
const response = await (0, import_run_test.runTest)(gentracePipelineSlug, async (testCase) => {
|
|
28347
|
+
const pipeline = new import_pipeline.Pipeline({
|
|
27861
28348
|
slug: gentracePipelineSlug
|
|
27862
28349
|
});
|
|
27863
28350
|
const runner = pipeline.start();
|
|
@@ -27955,7 +28442,7 @@ function convertRecordingToStepRuns(recording, project, graphId) {
|
|
|
27955
28442
|
};
|
|
27956
28443
|
});
|
|
27957
28444
|
stepRuns.push(
|
|
27958
|
-
new
|
|
28445
|
+
new import_step_run.StepRun(
|
|
27959
28446
|
"openai",
|
|
27960
28447
|
"openai_createChatCompletion",
|
|
27961
28448
|
pair.end - pair.start,
|
|
@@ -27964,14 +28451,15 @@ function convertRecordingToStepRuns(recording, project, graphId) {
|
|
|
27964
28451
|
gentraceOpenAIInputs,
|
|
27965
28452
|
gentraceOpenAIModelParams,
|
|
27966
28453
|
gentraceOpenAIOutputs,
|
|
27967
|
-
{}
|
|
28454
|
+
{},
|
|
28455
|
+
void 0
|
|
27968
28456
|
)
|
|
27969
28457
|
);
|
|
27970
28458
|
continue;
|
|
27971
28459
|
}
|
|
27972
28460
|
}
|
|
27973
28461
|
stepRuns.push(
|
|
27974
|
-
new
|
|
28462
|
+
new import_step_run.StepRun(
|
|
27975
28463
|
"rivet",
|
|
27976
28464
|
nodeType ? `rivet_operation_${nodeType}` : "rivet_operation",
|
|
27977
28465
|
pair.end - pair.start,
|
|
@@ -27980,7 +28468,8 @@ function convertRecordingToStepRuns(recording, project, graphId) {
|
|
|
27980
28468
|
pair.inputs,
|
|
27981
28469
|
pair.modelParams,
|
|
27982
28470
|
pair.outputs,
|
|
27983
|
-
{}
|
|
28471
|
+
{},
|
|
28472
|
+
void 0
|
|
27984
28473
|
)
|
|
27985
28474
|
);
|
|
27986
28475
|
}
|
|
@@ -27988,7 +28477,7 @@ function convertRecordingToStepRuns(recording, project, graphId) {
|
|
|
27988
28477
|
}
|
|
27989
28478
|
var getGentracePipelines = async (gentraceApiKey) => {
|
|
27990
28479
|
initializeGentrace(gentraceApiKey);
|
|
27991
|
-
return await (0,
|
|
28480
|
+
return await (0, import_pipeline_methods.getPipelines)();
|
|
27992
28481
|
};
|
|
27993
28482
|
var gentracePlugin = {
|
|
27994
28483
|
id: "gentrace",
|
|
@@ -31558,23 +32047,6 @@ function getSingleNodeStream(processor, nodeIdOrTitle) {
|
|
|
31558
32047
|
});
|
|
31559
32048
|
}
|
|
31560
32049
|
|
|
31561
|
-
// src/api/processSettings.ts
|
|
31562
|
-
function resolveProcessSettings(settings = {}, fallbacks = {}) {
|
|
31563
|
-
return {
|
|
31564
|
-
openAiKey: settings.openAiKey ?? fallbacks.openAiKey ?? "",
|
|
31565
|
-
openAiOrganization: settings.openAiOrganization ?? fallbacks.openAiOrganization ?? "",
|
|
31566
|
-
openAiEndpoint: settings.openAiEndpoint ?? fallbacks.openAiEndpoint ?? "",
|
|
31567
|
-
pluginEnv: settings.pluginEnv ?? fallbacks.pluginEnv ?? {},
|
|
31568
|
-
pluginSettings: settings.pluginSettings ?? {},
|
|
31569
|
-
recordingPlaybackLatency: settings.recordingPlaybackLatency ?? 1e3,
|
|
31570
|
-
defaultNodeColors: settings.defaultNodeColors ?? false,
|
|
31571
|
-
openNodeSettingsOnCreate: settings.openNodeSettingsOnCreate ?? true,
|
|
31572
|
-
chatNodeHeaders: settings.chatNodeHeaders ?? {},
|
|
31573
|
-
chatNodeTimeout: settings.chatNodeTimeout ?? DEFAULT_CHAT_NODE_TIMEOUT,
|
|
31574
|
-
throttleChatNode: settings.throttleChatNode ?? 100
|
|
31575
|
-
};
|
|
31576
|
-
}
|
|
31577
|
-
|
|
31578
32050
|
// src/api/createProcessor.ts
|
|
31579
32051
|
function coreCreateProcessor(project, options2, internalOptions = {}) {
|
|
31580
32052
|
var _a, _b, _c;
|
|
@@ -31794,6 +32266,10 @@ var Rivet = void 0;
|
|
|
31794
32266
|
PluginNodeImplClass,
|
|
31795
32267
|
PopNodeImpl,
|
|
31796
32268
|
PromptNodeImpl,
|
|
32269
|
+
RIVET_MARKDOWN_ALLOWED_ATTRIBUTES,
|
|
32270
|
+
RIVET_MARKDOWN_ALLOWED_TAGS,
|
|
32271
|
+
RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE,
|
|
32272
|
+
RIVET_MARKDOWN_SANITIZER_POLICY,
|
|
31797
32273
|
RIVET_WEB_APP_DOCUMENT_CSS,
|
|
31798
32274
|
RIVET_WEB_APP_RENDERER_CSS,
|
|
31799
32275
|
RaceInputsNodeImpl,
|
|
@@ -31829,6 +32305,7 @@ var Rivet = void 0;
|
|
|
31829
32305
|
anthropicPlugin,
|
|
31830
32306
|
anthropicThinkingModeOptions,
|
|
31831
32307
|
appendToDatasetNode,
|
|
32308
|
+
applyUiGraphStatePatch,
|
|
31832
32309
|
arrayNode,
|
|
31833
32310
|
arrayTypeToScalarType,
|
|
31834
32311
|
arrayizeDataValue,
|
|
@@ -31842,6 +32319,7 @@ var Rivet = void 0;
|
|
|
31842
32319
|
base64ToUint8Array,
|
|
31843
32320
|
baseDirs,
|
|
31844
32321
|
booleanNode,
|
|
32322
|
+
buildChatV2RequestPlan,
|
|
31845
32323
|
buildLLMChatV2EditorCacheKey,
|
|
31846
32324
|
buildLegacyOrderedPortIds,
|
|
31847
32325
|
calculateChatV2Cost,
|
|
@@ -31882,6 +32360,7 @@ var Rivet = void 0;
|
|
|
31882
32360
|
createDefaultUiGraph,
|
|
31883
32361
|
createFrozenNodeOutputResolver,
|
|
31884
32362
|
createInterpolationInputDefinition,
|
|
32363
|
+
createResolvedChatV2Provider,
|
|
31885
32364
|
createsLLMChatV2ToolResponseFormatConflictForEdit,
|
|
31886
32365
|
cronNode,
|
|
31887
32366
|
dataTypeDisplayNames,
|
|
@@ -31913,6 +32392,7 @@ var Rivet = void 0;
|
|
|
31913
32392
|
extractYamlNode,
|
|
31914
32393
|
filterNode,
|
|
31915
32394
|
findInterpolationTokenSpans,
|
|
32395
|
+
formatUiGraphDownloadDateTime,
|
|
31916
32396
|
functionTypeToScalarType,
|
|
31917
32397
|
generateChatV2,
|
|
31918
32398
|
gentracePlugin,
|
|
@@ -31951,7 +32431,12 @@ var Rivet = void 0;
|
|
|
31951
32431
|
getUiGraphActionComponent,
|
|
31952
32432
|
getUiGraphActionInputBindings,
|
|
31953
32433
|
getUiGraphActionOutputBindings,
|
|
32434
|
+
getUiGraphActionState,
|
|
32435
|
+
getUiGraphComponentLabel,
|
|
32436
|
+
getUiGraphComponentRenderModel,
|
|
31954
32437
|
getUiGraphInitialState,
|
|
32438
|
+
getUiGraphJsonOutputFilename,
|
|
32439
|
+
getUiGraphOutputRenderModel,
|
|
31955
32440
|
getWarnings,
|
|
31956
32441
|
globalRivetNodeRegistry,
|
|
31957
32442
|
googlePlugin,
|
|
@@ -31963,7 +32448,9 @@ var Rivet = void 0;
|
|
|
31963
32448
|
handleEscapeCharacters,
|
|
31964
32449
|
hasFrozenNodeOutputs,
|
|
31965
32450
|
hasLLMChatV2ToolResponseFormatConflict,
|
|
32451
|
+
hasUiGraphStateValue,
|
|
31966
32452
|
hasValidStoredOrderedPortIds,
|
|
32453
|
+
hasValidUiGraphComponentIds,
|
|
31967
32454
|
hashNode,
|
|
31968
32455
|
httpCallNode,
|
|
31969
32456
|
huggingFacePlugin,
|
|
@@ -32017,6 +32504,7 @@ var Rivet = void 0;
|
|
|
32017
32504
|
newId,
|
|
32018
32505
|
nodeDefinition,
|
|
32019
32506
|
nodePrefabInstanceNode,
|
|
32507
|
+
normalizeUiGraphComponentIds,
|
|
32020
32508
|
numberNode,
|
|
32021
32509
|
objectNode,
|
|
32022
32510
|
openAICompatibleEndpointToBaseURL,
|
|
@@ -32043,10 +32531,12 @@ var Rivet = void 0;
|
|
|
32043
32531
|
registerBuiltInNodes,
|
|
32044
32532
|
registerIntegration,
|
|
32045
32533
|
registerPluginsIntoRegistry,
|
|
32534
|
+
renderUiGraphOutputValue,
|
|
32046
32535
|
replaceDatasetNode,
|
|
32047
32536
|
replaceGlobalRivetNodeRegistry,
|
|
32048
32537
|
resetGlobalRivetNodeRegistry,
|
|
32049
32538
|
resolveBuiltInPlugin,
|
|
32539
|
+
resolveChatV2Credential,
|
|
32050
32540
|
resolveChatV2ProviderConfig,
|
|
32051
32541
|
resolveChatV2ResponseFormatParameters,
|
|
32052
32542
|
resolveLLMChatV2RuntimeProviderOptions,
|
|
@@ -32073,7 +32563,9 @@ var Rivet = void 0;
|
|
|
32073
32563
|
sliceNode,
|
|
32074
32564
|
splitNode,
|
|
32075
32565
|
streamChatV2,
|
|
32566
|
+
stringifyUiGraphValue,
|
|
32076
32567
|
subGraphNode,
|
|
32568
|
+
summarizeChatV2RequestPlan,
|
|
32077
32569
|
summarizeDataValueForLog,
|
|
32078
32570
|
summarizeErrorForLog,
|
|
32079
32571
|
summarizePortMapForLog,
|