@valerypopoff/rivet2-core 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bundle.cjs +1947 -765
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/interpolationRuntime.cjs +1578 -0
- package/dist/cjs/interpolationRuntime.cjs.map +7 -0
- package/dist/cjs/interpolationSyntax.cjs +186 -0
- package/dist/cjs/interpolationSyntax.cjs.map +7 -0
- package/dist/cjs/webAppRuntime.cjs +1537 -121
- package/dist/cjs/webAppRuntime.cjs.map +4 -4
- package/dist/esm/api/createProcessor.js +2 -0
- package/dist/esm/exports.js +4 -1
- package/dist/esm/integrations/CodeRunner.js +5 -0
- package/dist/esm/integrations/mcp/MCPBase.js +16 -6
- package/dist/esm/interpolationRuntime.js +5 -0
- package/dist/esm/model/AgentResponseTrace.js +16 -0
- package/dist/esm/model/GraphBoundaryCache.js +0 -6
- package/dist/esm/model/GraphBoundaryEffects.js +5 -1
- package/dist/esm/model/GraphOutputSelection.js +34 -0
- package/dist/esm/model/GraphProcessor.js +150 -44
- package/dist/esm/model/NodeExclusionPolicy.js +9 -1
- package/dist/esm/model/ProcessContextBuilder.js +4 -1
- package/dist/esm/model/RecordingPlayer.js +19 -6
- package/dist/esm/model/StoredValueStore.js +4 -3
- package/dist/esm/model/SubprocessorBridge.js +1 -0
- package/dist/esm/model/UiGraphActionProtocol.js +46 -4
- package/dist/esm/model/UiGraphBrowserRuntime.js +15 -1
- package/dist/esm/model/UiGraphIndexedDbPersistence.js +523 -0
- package/dist/esm/model/UiGraphRendererStyles.js +14 -0
- package/dist/esm/model/WebAppBrowserStorage.js +653 -0
- package/dist/esm/model/WebAppBrowserStorageRpc.js +200 -0
- package/dist/esm/model/chat-v2/chatV2CallObserver.js +1 -0
- package/dist/esm/model/chat-v2/chatV2EditorCache.js +2 -33
- package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +1 -0
- package/dist/esm/model/chat-v2/llmChatV2OutputClone.js +42 -0
- package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +31 -2
- package/dist/esm/model/chat-v2/llmProfile.js +17 -1
- package/dist/esm/model/chat-v2/llmProfileFallback.js +17 -5
- package/dist/esm/model/chat-v2/llmProfileHealthStore.js +2 -0
- package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +4 -0
- package/dist/esm/model/chat-v2/toolContinuation.js +27 -1
- package/dist/esm/model/nodes/CodeNewNode.js +16 -16
- package/dist/esm/model/nodes/DestructureNode.js +2 -2
- package/dist/esm/model/nodes/ExpressionNode.js +16 -16
- package/dist/esm/model/nodes/ExtractObjectPathNode.js +2 -2
- package/dist/esm/model/nodes/ExtractYamlNode.js +5 -5
- package/dist/esm/model/nodes/JSFilterNode.js +3 -1
- package/dist/esm/model/nodes/JSMapNode.js +3 -1
- package/dist/esm/model/nodes/LLMChatV2Node.js +21 -2
- package/dist/esm/model/nodes/MCPGetPromptNode.js +6 -2
- package/dist/esm/model/nodes/MCPToolCallNode.js +6 -2
- package/dist/esm/model/nodes/ObjectNode.js +19 -20
- package/dist/esm/model/nodes/PromptNode.js +10 -11
- package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +2 -40
- package/dist/esm/model/nodes/SubGraphNode.js +40 -26
- package/dist/esm/model/nodes/TextNode.js +11 -32
- package/dist/esm/model/nodes/ToTreeNode.js +6 -13
- package/dist/esm/model/nodes/ToolNode.js +33 -16
- package/dist/esm/model/nodes/jsListCallbackHelpers.js +19 -15
- package/dist/esm/model/nodes/jsValueInterpolation.js +83 -30
- package/dist/esm/model/nodes/nodeBodyPreview.js +23 -0
- package/dist/esm/plugins/openai/nodes/ThreadMessageNode.js +14 -11
- package/dist/esm/recording/ExecutionRecorder.js +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/interpolation.js +478 -221
- package/dist/esm/utils/interpolationSyntax.js +175 -0
- package/dist/esm/utils/jsonPath.js +129 -0
- package/dist/esm/webAppRuntime.js +5 -2
- package/dist/types/api/createProcessor.d.ts +2 -0
- package/dist/types/exports.d.ts +5 -1
- package/dist/types/integrations/CodeRunnerOptions.d.ts +9 -0
- package/dist/types/integrations/mcp/MCPBase.d.ts +3 -1
- package/dist/types/interpolationRuntime.d.ts +5 -0
- package/dist/types/model/AgentResponseTrace.d.ts +1 -0
- package/dist/types/model/ExecutorProtocol.d.ts +9 -1
- package/dist/types/model/GraphBoundaryCache.d.ts +0 -2
- package/dist/types/model/GraphOutputSelection.d.ts +8 -0
- package/dist/types/model/GraphProcessor.d.ts +7 -4
- package/dist/types/model/NodeExclusionPolicy.d.ts +6 -0
- package/dist/types/model/ProcessContext.d.ts +36 -2
- package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
- package/dist/types/model/UiGraphActionProtocol.d.ts +8 -3
- package/dist/types/model/UiGraphBrowserRuntime.d.ts +6 -0
- package/dist/types/model/UiGraphIndexedDbPersistence.d.ts +50 -0
- package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
- package/dist/types/model/WebAppBrowserStorage.d.ts +90 -0
- package/dist/types/model/WebAppBrowserStorageRpc.d.ts +85 -0
- package/dist/types/model/chat-v2/chatV2Types.d.ts +3 -1
- package/dist/types/model/chat-v2/llmChatV2OutputClone.d.ts +3 -0
- package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +5 -1
- package/dist/types/model/chat-v2/llmProfileFallback.d.ts +4 -0
- package/dist/types/model/chat-v2/llmProfileHealthStore.d.ts +10 -0
- package/dist/types/model/chat-v2/llmProfileTypes.d.ts +6 -0
- package/dist/types/model/chat-v2/toolContinuation.d.ts +14 -0
- package/dist/types/model/nodes/ObjectNode.d.ts +1 -1
- package/dist/types/model/nodes/SubGraphNode.d.ts +2 -0
- package/dist/types/model/nodes/ToTreeNode.d.ts +5 -2
- package/dist/types/model/nodes/ToolNode.d.ts +13 -1
- package/dist/types/model/nodes/jsValueInterpolation.d.ts +16 -8
- package/dist/types/model/nodes/nodeBodyPreview.d.ts +7 -0
- package/dist/types/recording/RecordedEvents.d.ts +11 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/interpolation.d.ts +93 -8
- package/dist/types/utils/interpolationSyntax.d.ts +21 -0
- package/dist/types/utils/jsonPath.d.ts +15 -0
- package/dist/types/webAppRuntime.d.ts +8 -2
- package/package.json +11 -1
package/dist/cjs/bundle.cjs
CHANGED
|
@@ -153,6 +153,15 @@ __export(src_exports, {
|
|
|
153
153
|
RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE: () => RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE,
|
|
154
154
|
RIVET_MARKDOWN_SANITIZER_POLICY: () => RIVET_MARKDOWN_SANITIZER_POLICY,
|
|
155
155
|
RIVET_WEB_APP_ACTION_PROTOCOL_VERSION: () => RIVET_WEB_APP_ACTION_PROTOCOL_VERSION,
|
|
156
|
+
RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES,
|
|
157
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTION_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTION_BYTES,
|
|
158
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTIVE_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTIVE_BYTES,
|
|
159
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_VALUE_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_VALUE_BYTES,
|
|
160
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_TRANSFER_TIMEOUT_MS: () => RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_TRANSFER_TIMEOUT_MS,
|
|
161
|
+
RIVET_WEB_APP_BROWSER_STORAGE_RPC_CAPABILITY: () => RIVET_WEB_APP_BROWSER_STORAGE_RPC_CAPABILITY,
|
|
162
|
+
RIVET_WEB_APP_BROWSER_STORAGE_RPC_VERSION: () => RIVET_WEB_APP_BROWSER_STORAGE_RPC_VERSION,
|
|
163
|
+
RIVET_WEB_APP_BROWSER_STORAGE_SAFE_FALLBACK_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_SAFE_FALLBACK_BYTES,
|
|
164
|
+
RIVET_WEB_APP_BROWSER_STORAGE_TRANSFER_CHUNK_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_TRANSFER_CHUNK_BYTES,
|
|
156
165
|
RIVET_WEB_APP_DOCUMENT_CSS: () => RIVET_WEB_APP_DOCUMENT_CSS,
|
|
157
166
|
RIVET_WEB_APP_RENDERER_CSS: () => RIVET_WEB_APP_RENDERER_CSS,
|
|
158
167
|
RIVET_WEB_APP_STATUS_FUNCTION_NAME: () => RIVET_WEB_APP_STATUS_FUNCTION_NAME,
|
|
@@ -225,6 +234,7 @@ __export(src_exports, {
|
|
|
225
234
|
callGraphNode: () => callGraphNode,
|
|
226
235
|
canBeCoerced: () => canBeCoerced,
|
|
227
236
|
canBeCoercedAny: () => canBeCoercedAny,
|
|
237
|
+
canConsumeControlFlowExcludedInput: () => canConsumeControlFlowExcludedInput,
|
|
228
238
|
canRenderDataBusNode: () => canRenderDataBusNode,
|
|
229
239
|
canUseNodeAsPrefabSource: () => canUseNodeAsPrefabSource,
|
|
230
240
|
chatLoopNode: () => chatLoopNode,
|
|
@@ -289,12 +299,15 @@ __export(src_exports, {
|
|
|
289
299
|
datasetNearestNeighborsNode: () => datasetNearestNeighborsNode,
|
|
290
300
|
decideLLMInvocationRound: () => decideLLMInvocationRound,
|
|
291
301
|
decodeDebuggerTransportSentinels: () => decodeDebuggerTransportSentinels,
|
|
302
|
+
decodeRivetWebAppStorageBinaryFrame: () => decodeRivetWebAppStorageBinaryFrame,
|
|
292
303
|
dedent: () => import_ts_dedent.dedent,
|
|
293
304
|
delayNode: () => delayNode,
|
|
294
305
|
delegateFunctionCallNode: () => delegateFunctionCallNode,
|
|
295
306
|
deserializeDatasets: () => deserializeDatasets,
|
|
296
307
|
deserializeGraph: () => deserializeGraph,
|
|
297
308
|
deserializeProject: () => deserializeProject,
|
|
309
|
+
deserializeRivetWebAppStoredValue: () => deserializeRivetWebAppStoredValue,
|
|
310
|
+
deserializeRivetWebAppStoredValuePatch: () => deserializeRivetWebAppStoredValuePatch,
|
|
298
311
|
destructureNode: () => destructureNode,
|
|
299
312
|
detachNodePrefabInstance: () => detachNodePrefabInstance,
|
|
300
313
|
detectSerializationVersion: () => detectSerializationVersion,
|
|
@@ -302,6 +315,8 @@ __export(src_exports, {
|
|
|
302
315
|
documentNode: () => documentNode,
|
|
303
316
|
doubleCheckProject: () => doubleCheckProject,
|
|
304
317
|
emptyNodeGraph: () => emptyNodeGraph,
|
|
318
|
+
encodeRivetWebAppStorageBinaryFrame: () => encodeRivetWebAppStorageBinaryFrame,
|
|
319
|
+
evaluateJsonPath: () => evaluateJsonPath,
|
|
305
320
|
evaluateNode: () => evaluateNode,
|
|
306
321
|
executeLLMInvocation: () => executeLLMInvocation,
|
|
307
322
|
expectType: () => expectType,
|
|
@@ -309,6 +324,7 @@ __export(src_exports, {
|
|
|
309
324
|
exportGentraceEvaluationRun: () => exportGentraceEvaluationRun,
|
|
310
325
|
expressionNode: () => expressionNode,
|
|
311
326
|
externalCallNode: () => externalCallNode,
|
|
327
|
+
extractInterpolationVariableReferences: () => extractInterpolationVariableReferences,
|
|
312
328
|
extractInterpolationVariables: () => extractInterpolationVariables,
|
|
313
329
|
extractJsonNode: () => extractJsonNode,
|
|
314
330
|
extractMarkdownCodeBlocksNode: () => extractMarkdownCodeBlocksNode,
|
|
@@ -360,6 +376,7 @@ __export(src_exports, {
|
|
|
360
376
|
getIntegration: () => getIntegration,
|
|
361
377
|
getInterpolationInputDefinitionData: () => getInterpolationInputDefinitionData,
|
|
362
378
|
getInterpolationTokenName: () => getInterpolationTokenName,
|
|
379
|
+
getInterpolationTokenReference: () => getInterpolationTokenReference,
|
|
363
380
|
getKnowledgeSourceStatusNode: () => getKnowledgeSourceStatusNode,
|
|
364
381
|
getKnowledgeStoreProvider: () => getKnowledgeStoreProvider,
|
|
365
382
|
getKnowledgeStoreProviders: () => getKnowledgeStoreProviders,
|
|
@@ -378,6 +395,7 @@ __export(src_exports, {
|
|
|
378
395
|
getScalarTypeOf: () => getScalarTypeOf,
|
|
379
396
|
getSingleNodeStream: () => getSingleNodeStream,
|
|
380
397
|
getStoredValueNode: () => getStoredValueNode,
|
|
398
|
+
getToolNodeBodyPreview: () => getToolNodeBodyPreview,
|
|
381
399
|
getUiGraphActionComponent: () => getUiGraphActionComponent,
|
|
382
400
|
getUiGraphActionInputBindings: () => getUiGraphActionInputBindings,
|
|
383
401
|
getUiGraphActionOutputBindings: () => getUiGraphActionOutputBindings,
|
|
@@ -442,6 +460,8 @@ __export(src_exports, {
|
|
|
442
460
|
isFunctionDataType: () => isFunctionDataType,
|
|
443
461
|
isFunctionDataValue: () => isFunctionDataValue,
|
|
444
462
|
isInterpolationInputDefinition: () => isInterpolationInputDefinition,
|
|
463
|
+
isInterpolationRegexLiteralStart: () => isInterpolationRegexLiteralStart,
|
|
464
|
+
isInterpolationSyntaxCharacterEscaped: () => isInterpolationSyntaxCharacterEscaped,
|
|
445
465
|
isKnowledgeDocument: () => isKnowledgeDocument,
|
|
446
466
|
isKnowledgeEvidence: () => isKnowledgeEvidence,
|
|
447
467
|
isKnowledgeSourceReference: () => isKnowledgeSourceReference,
|
|
@@ -492,6 +512,7 @@ __export(src_exports, {
|
|
|
492
512
|
normalizeChatV2CredentialNames: () => normalizeChatV2CredentialNames,
|
|
493
513
|
normalizeChatV2CredentialNamesByProvider: () => normalizeChatV2CredentialNamesByProvider,
|
|
494
514
|
normalizeGraphProgress: () => normalizeGraphProgress,
|
|
515
|
+
normalizeJsonPathExpression: () => normalizeJsonPathExpression,
|
|
495
516
|
normalizeKnowledgeConnectionId: () => normalizeKnowledgeConnectionId,
|
|
496
517
|
normalizeKnowledgeDocument: () => normalizeKnowledgeDocument,
|
|
497
518
|
normalizeKnowledgeEvidence: () => normalizeKnowledgeEvidence,
|
|
@@ -525,7 +546,11 @@ __export(src_exports, {
|
|
|
525
546
|
parseChatV2Provider: () => parseChatV2Provider,
|
|
526
547
|
parseCustomProviderApi: () => parseCustomProviderApi,
|
|
527
548
|
parseDataBusChannelIndex: () => parseDataBusChannelIndex,
|
|
549
|
+
parseInterpolationExpression: () => parseInterpolationExpression,
|
|
550
|
+
parseInterpolationTemplate: () => parseInterpolationTemplate,
|
|
528
551
|
parseProviderJsonChunk: () => parseProviderJsonChunk,
|
|
552
|
+
parseRivetWebAppBrowserStorageClientMessage: () => parseRivetWebAppBrowserStorageClientMessage,
|
|
553
|
+
parseRivetWebAppBrowserStorageServerMessage: () => parseRivetWebAppBrowserStorageServerMessage,
|
|
529
554
|
parseRivetWebAppClientMessage: () => parseRivetWebAppClientMessage,
|
|
530
555
|
parseRivetWebAppServerMessage: () => parseRivetWebAppServerMessage,
|
|
531
556
|
passthroughNode: () => passthroughNode,
|
|
@@ -566,6 +591,9 @@ __export(src_exports, {
|
|
|
566
591
|
resolveChatV2Credential: () => resolveChatV2Credential,
|
|
567
592
|
resolveChatV2ProviderConfig: () => resolveChatV2ProviderConfig,
|
|
568
593
|
resolveChatV2ResponseFormatParameters: () => resolveChatV2ResponseFormatParameters,
|
|
594
|
+
resolveCodeInterpolationExpression: () => resolveCodeInterpolationExpression,
|
|
595
|
+
resolveInterpolationExpressionRawValue: () => resolveInterpolationExpressionRawValue,
|
|
596
|
+
resolveInterpolationTokenRawValue: () => resolveInterpolationTokenRawValue,
|
|
569
597
|
resolveLLMChatV2RuntimeProviderOptions: () => resolveLLMChatV2RuntimeProviderOptions,
|
|
570
598
|
resolveNodePrefabInstance: () => resolveNodePrefabInstance,
|
|
571
599
|
resolveNodePrefabInstances: () => resolveNodePrefabInstances,
|
|
@@ -588,10 +616,13 @@ __export(src_exports, {
|
|
|
588
616
|
sanitizeIdentifierPortValue: () => sanitizeIdentifierPortValue,
|
|
589
617
|
scalarDefaults: () => scalarDefaults,
|
|
590
618
|
scalarTypes: () => scalarTypes,
|
|
619
|
+
scanInterpolationTokenSpans: () => scanInterpolationTokenSpans,
|
|
591
620
|
searchKnowledgeNode: () => searchKnowledgeNode,
|
|
592
621
|
serializeDatasets: () => serializeDatasets,
|
|
593
622
|
serializeGraph: () => serializeGraph,
|
|
594
623
|
serializeProject: () => serializeProject,
|
|
624
|
+
serializeRivetWebAppStoredValue: () => serializeRivetWebAppStoredValue,
|
|
625
|
+
serializeRivetWebAppStoredValuePatch: () => serializeRivetWebAppStoredValuePatch,
|
|
595
626
|
setGlobalNode: () => setGlobalNode,
|
|
596
627
|
setStoredValueNode: () => setStoredValueNode,
|
|
597
628
|
shouldIncludeLLMChatV2ToolCalls: () => shouldIncludeLLMChatV2ToolCalls,
|
|
@@ -600,8 +631,10 @@ __export(src_exports, {
|
|
|
600
631
|
shuffleNode: () => shuffleNode,
|
|
601
632
|
sliceNode: () => sliceNode,
|
|
602
633
|
splitNode: () => splitNode,
|
|
634
|
+
splitRivetWebAppStorageTransfer: () => splitRivetWebAppStorageTransfer,
|
|
603
635
|
startBackgroundBranchNode: () => startBackgroundBranchNode,
|
|
604
636
|
streamChatV2: () => streamChatV2,
|
|
637
|
+
stringifyInterpolationSourceValue: () => stringifyInterpolationSourceValue,
|
|
605
638
|
stringifyToolResult: () => stringifyToolResult,
|
|
606
639
|
stringifyUiGraphValue: () => stringifyUiGraphValue,
|
|
607
640
|
subGraphNode: () => subGraphNode,
|
|
@@ -762,6 +795,15 @@ __export(exports_exports, {
|
|
|
762
795
|
RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE: () => RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE,
|
|
763
796
|
RIVET_MARKDOWN_SANITIZER_POLICY: () => RIVET_MARKDOWN_SANITIZER_POLICY,
|
|
764
797
|
RIVET_WEB_APP_ACTION_PROTOCOL_VERSION: () => RIVET_WEB_APP_ACTION_PROTOCOL_VERSION,
|
|
798
|
+
RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES,
|
|
799
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTION_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTION_BYTES,
|
|
800
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTIVE_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTIVE_BYTES,
|
|
801
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_VALUE_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_VALUE_BYTES,
|
|
802
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_TRANSFER_TIMEOUT_MS: () => RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_TRANSFER_TIMEOUT_MS,
|
|
803
|
+
RIVET_WEB_APP_BROWSER_STORAGE_RPC_CAPABILITY: () => RIVET_WEB_APP_BROWSER_STORAGE_RPC_CAPABILITY,
|
|
804
|
+
RIVET_WEB_APP_BROWSER_STORAGE_RPC_VERSION: () => RIVET_WEB_APP_BROWSER_STORAGE_RPC_VERSION,
|
|
805
|
+
RIVET_WEB_APP_BROWSER_STORAGE_SAFE_FALLBACK_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_SAFE_FALLBACK_BYTES,
|
|
806
|
+
RIVET_WEB_APP_BROWSER_STORAGE_TRANSFER_CHUNK_BYTES: () => RIVET_WEB_APP_BROWSER_STORAGE_TRANSFER_CHUNK_BYTES,
|
|
765
807
|
RIVET_WEB_APP_DOCUMENT_CSS: () => RIVET_WEB_APP_DOCUMENT_CSS,
|
|
766
808
|
RIVET_WEB_APP_RENDERER_CSS: () => RIVET_WEB_APP_RENDERER_CSS,
|
|
767
809
|
RIVET_WEB_APP_STATUS_FUNCTION_NAME: () => RIVET_WEB_APP_STATUS_FUNCTION_NAME,
|
|
@@ -833,6 +875,7 @@ __export(exports_exports, {
|
|
|
833
875
|
callGraphNode: () => callGraphNode,
|
|
834
876
|
canBeCoerced: () => canBeCoerced,
|
|
835
877
|
canBeCoercedAny: () => canBeCoercedAny,
|
|
878
|
+
canConsumeControlFlowExcludedInput: () => canConsumeControlFlowExcludedInput,
|
|
836
879
|
canRenderDataBusNode: () => canRenderDataBusNode,
|
|
837
880
|
canUseNodeAsPrefabSource: () => canUseNodeAsPrefabSource,
|
|
838
881
|
chatLoopNode: () => chatLoopNode,
|
|
@@ -897,12 +940,15 @@ __export(exports_exports, {
|
|
|
897
940
|
datasetNearestNeighborsNode: () => datasetNearestNeighborsNode,
|
|
898
941
|
decideLLMInvocationRound: () => decideLLMInvocationRound,
|
|
899
942
|
decodeDebuggerTransportSentinels: () => decodeDebuggerTransportSentinels,
|
|
943
|
+
decodeRivetWebAppStorageBinaryFrame: () => decodeRivetWebAppStorageBinaryFrame,
|
|
900
944
|
dedent: () => import_ts_dedent.dedent,
|
|
901
945
|
delayNode: () => delayNode,
|
|
902
946
|
delegateFunctionCallNode: () => delegateFunctionCallNode,
|
|
903
947
|
deserializeDatasets: () => deserializeDatasets,
|
|
904
948
|
deserializeGraph: () => deserializeGraph,
|
|
905
949
|
deserializeProject: () => deserializeProject,
|
|
950
|
+
deserializeRivetWebAppStoredValue: () => deserializeRivetWebAppStoredValue,
|
|
951
|
+
deserializeRivetWebAppStoredValuePatch: () => deserializeRivetWebAppStoredValuePatch,
|
|
906
952
|
destructureNode: () => destructureNode,
|
|
907
953
|
detachNodePrefabInstance: () => detachNodePrefabInstance,
|
|
908
954
|
detectSerializationVersion: () => detectSerializationVersion,
|
|
@@ -910,6 +956,8 @@ __export(exports_exports, {
|
|
|
910
956
|
documentNode: () => documentNode,
|
|
911
957
|
doubleCheckProject: () => doubleCheckProject,
|
|
912
958
|
emptyNodeGraph: () => emptyNodeGraph,
|
|
959
|
+
encodeRivetWebAppStorageBinaryFrame: () => encodeRivetWebAppStorageBinaryFrame,
|
|
960
|
+
evaluateJsonPath: () => evaluateJsonPath,
|
|
913
961
|
evaluateNode: () => evaluateNode,
|
|
914
962
|
executeLLMInvocation: () => executeLLMInvocation,
|
|
915
963
|
expectType: () => expectType,
|
|
@@ -917,6 +965,7 @@ __export(exports_exports, {
|
|
|
917
965
|
exportGentraceEvaluationRun: () => exportGentraceEvaluationRun,
|
|
918
966
|
expressionNode: () => expressionNode,
|
|
919
967
|
externalCallNode: () => externalCallNode,
|
|
968
|
+
extractInterpolationVariableReferences: () => extractInterpolationVariableReferences,
|
|
920
969
|
extractInterpolationVariables: () => extractInterpolationVariables,
|
|
921
970
|
extractJsonNode: () => extractJsonNode,
|
|
922
971
|
extractMarkdownCodeBlocksNode: () => extractMarkdownCodeBlocksNode,
|
|
@@ -968,6 +1017,7 @@ __export(exports_exports, {
|
|
|
968
1017
|
getIntegration: () => getIntegration,
|
|
969
1018
|
getInterpolationInputDefinitionData: () => getInterpolationInputDefinitionData,
|
|
970
1019
|
getInterpolationTokenName: () => getInterpolationTokenName,
|
|
1020
|
+
getInterpolationTokenReference: () => getInterpolationTokenReference,
|
|
971
1021
|
getKnowledgeSourceStatusNode: () => getKnowledgeSourceStatusNode,
|
|
972
1022
|
getKnowledgeStoreProvider: () => getKnowledgeStoreProvider,
|
|
973
1023
|
getKnowledgeStoreProviders: () => getKnowledgeStoreProviders,
|
|
@@ -986,6 +1036,7 @@ __export(exports_exports, {
|
|
|
986
1036
|
getScalarTypeOf: () => getScalarTypeOf,
|
|
987
1037
|
getSingleNodeStream: () => getSingleNodeStream,
|
|
988
1038
|
getStoredValueNode: () => getStoredValueNode,
|
|
1039
|
+
getToolNodeBodyPreview: () => getToolNodeBodyPreview,
|
|
989
1040
|
getUiGraphActionComponent: () => getUiGraphActionComponent,
|
|
990
1041
|
getUiGraphActionInputBindings: () => getUiGraphActionInputBindings,
|
|
991
1042
|
getUiGraphActionOutputBindings: () => getUiGraphActionOutputBindings,
|
|
@@ -1050,6 +1101,8 @@ __export(exports_exports, {
|
|
|
1050
1101
|
isFunctionDataType: () => isFunctionDataType,
|
|
1051
1102
|
isFunctionDataValue: () => isFunctionDataValue,
|
|
1052
1103
|
isInterpolationInputDefinition: () => isInterpolationInputDefinition,
|
|
1104
|
+
isInterpolationRegexLiteralStart: () => isInterpolationRegexLiteralStart,
|
|
1105
|
+
isInterpolationSyntaxCharacterEscaped: () => isInterpolationSyntaxCharacterEscaped,
|
|
1053
1106
|
isKnowledgeDocument: () => isKnowledgeDocument,
|
|
1054
1107
|
isKnowledgeEvidence: () => isKnowledgeEvidence,
|
|
1055
1108
|
isKnowledgeSourceReference: () => isKnowledgeSourceReference,
|
|
@@ -1100,6 +1153,7 @@ __export(exports_exports, {
|
|
|
1100
1153
|
normalizeChatV2CredentialNames: () => normalizeChatV2CredentialNames,
|
|
1101
1154
|
normalizeChatV2CredentialNamesByProvider: () => normalizeChatV2CredentialNamesByProvider,
|
|
1102
1155
|
normalizeGraphProgress: () => normalizeGraphProgress,
|
|
1156
|
+
normalizeJsonPathExpression: () => normalizeJsonPathExpression,
|
|
1103
1157
|
normalizeKnowledgeConnectionId: () => normalizeKnowledgeConnectionId,
|
|
1104
1158
|
normalizeKnowledgeDocument: () => normalizeKnowledgeDocument,
|
|
1105
1159
|
normalizeKnowledgeEvidence: () => normalizeKnowledgeEvidence,
|
|
@@ -1133,7 +1187,11 @@ __export(exports_exports, {
|
|
|
1133
1187
|
parseChatV2Provider: () => parseChatV2Provider,
|
|
1134
1188
|
parseCustomProviderApi: () => parseCustomProviderApi,
|
|
1135
1189
|
parseDataBusChannelIndex: () => parseDataBusChannelIndex,
|
|
1190
|
+
parseInterpolationExpression: () => parseInterpolationExpression,
|
|
1191
|
+
parseInterpolationTemplate: () => parseInterpolationTemplate,
|
|
1136
1192
|
parseProviderJsonChunk: () => parseProviderJsonChunk,
|
|
1193
|
+
parseRivetWebAppBrowserStorageClientMessage: () => parseRivetWebAppBrowserStorageClientMessage,
|
|
1194
|
+
parseRivetWebAppBrowserStorageServerMessage: () => parseRivetWebAppBrowserStorageServerMessage,
|
|
1137
1195
|
parseRivetWebAppClientMessage: () => parseRivetWebAppClientMessage,
|
|
1138
1196
|
parseRivetWebAppServerMessage: () => parseRivetWebAppServerMessage,
|
|
1139
1197
|
passthroughNode: () => passthroughNode,
|
|
@@ -1174,6 +1232,9 @@ __export(exports_exports, {
|
|
|
1174
1232
|
resolveChatV2Credential: () => resolveChatV2Credential,
|
|
1175
1233
|
resolveChatV2ProviderConfig: () => resolveChatV2ProviderConfig,
|
|
1176
1234
|
resolveChatV2ResponseFormatParameters: () => resolveChatV2ResponseFormatParameters,
|
|
1235
|
+
resolveCodeInterpolationExpression: () => resolveCodeInterpolationExpression,
|
|
1236
|
+
resolveInterpolationExpressionRawValue: () => resolveInterpolationExpressionRawValue,
|
|
1237
|
+
resolveInterpolationTokenRawValue: () => resolveInterpolationTokenRawValue,
|
|
1177
1238
|
resolveLLMChatV2RuntimeProviderOptions: () => resolveLLMChatV2RuntimeProviderOptions,
|
|
1178
1239
|
resolveNodePrefabInstance: () => resolveNodePrefabInstance,
|
|
1179
1240
|
resolveNodePrefabInstances: () => resolveNodePrefabInstances,
|
|
@@ -1196,10 +1257,13 @@ __export(exports_exports, {
|
|
|
1196
1257
|
sanitizeIdentifierPortValue: () => sanitizeIdentifierPortValue,
|
|
1197
1258
|
scalarDefaults: () => scalarDefaults,
|
|
1198
1259
|
scalarTypes: () => scalarTypes,
|
|
1260
|
+
scanInterpolationTokenSpans: () => scanInterpolationTokenSpans,
|
|
1199
1261
|
searchKnowledgeNode: () => searchKnowledgeNode,
|
|
1200
1262
|
serializeDatasets: () => serializeDatasets,
|
|
1201
1263
|
serializeGraph: () => serializeGraph,
|
|
1202
1264
|
serializeProject: () => serializeProject,
|
|
1265
|
+
serializeRivetWebAppStoredValue: () => serializeRivetWebAppStoredValue,
|
|
1266
|
+
serializeRivetWebAppStoredValuePatch: () => serializeRivetWebAppStoredValuePatch,
|
|
1203
1267
|
setGlobalNode: () => setGlobalNode,
|
|
1204
1268
|
setStoredValueNode: () => setStoredValueNode,
|
|
1205
1269
|
shouldIncludeLLMChatV2ToolCalls: () => shouldIncludeLLMChatV2ToolCalls,
|
|
@@ -1208,8 +1272,10 @@ __export(exports_exports, {
|
|
|
1208
1272
|
shuffleNode: () => shuffleNode,
|
|
1209
1273
|
sliceNode: () => sliceNode,
|
|
1210
1274
|
splitNode: () => splitNode,
|
|
1275
|
+
splitRivetWebAppStorageTransfer: () => splitRivetWebAppStorageTransfer,
|
|
1211
1276
|
startBackgroundBranchNode: () => startBackgroundBranchNode,
|
|
1212
1277
|
streamChatV2: () => streamChatV2,
|
|
1278
|
+
stringifyInterpolationSourceValue: () => stringifyInterpolationSourceValue,
|
|
1213
1279
|
stringifyToolResult: () => stringifyToolResult,
|
|
1214
1280
|
stringifyUiGraphValue: () => stringifyUiGraphValue,
|
|
1215
1281
|
subGraphNode: () => subGraphNode,
|
|
@@ -1723,6 +1789,8 @@ function sha256(value) {
|
|
|
1723
1789
|
return `sha256:${import_crypto_js.default.SHA256(value).toString(import_crypto_js.default.enc.Hex)}`;
|
|
1724
1790
|
}
|
|
1725
1791
|
function createRivetLLMProfileHealthIdentity(params) {
|
|
1792
|
+
var _a;
|
|
1793
|
+
const profileName = (_a = params.profileName) == null ? void 0 : _a.trim();
|
|
1726
1794
|
const routingConfiguration = {
|
|
1727
1795
|
provider: params.configuration.provider,
|
|
1728
1796
|
model: params.configuration.model,
|
|
@@ -1751,6 +1819,7 @@ function createRivetLLMProfileHealthIdentity(params) {
|
|
|
1751
1819
|
key: `llm-profile:${key}`,
|
|
1752
1820
|
...params.projectId == null ? {} : { projectId: params.projectId },
|
|
1753
1821
|
...params.profileNodeId == null ? {} : { profileNodeId: params.profileNodeId },
|
|
1822
|
+
...profileName === "" || profileName == null ? {} : { profileName },
|
|
1754
1823
|
provider: params.configuration.provider,
|
|
1755
1824
|
model: params.configuration.model,
|
|
1756
1825
|
...params.configuration.provider !== "custom" ? {} : { customProviderApi: params.configuration.customProviderApi ?? "completions" },
|
|
@@ -2995,14 +3064,17 @@ function normalizeLLMProfileValue(value) {
|
|
|
2995
3064
|
model: model.trim()
|
|
2996
3065
|
});
|
|
2997
3066
|
const sourceIdentity = normalizeSourceIdentity(value.healthIdentity);
|
|
3067
|
+
const profileName = normalizeProfileName(value.profileName) ?? sourceIdentity.profileName;
|
|
2998
3068
|
return {
|
|
2999
3069
|
version: LLM_PROFILE_VALUE_VERSION,
|
|
3000
3070
|
configuration,
|
|
3001
3071
|
credential,
|
|
3072
|
+
...profileName == null ? {} : { profileName },
|
|
3002
3073
|
healthIdentity: createRivetLLMProfileHealthIdentity({
|
|
3003
3074
|
configuration,
|
|
3004
3075
|
credential,
|
|
3005
|
-
...sourceIdentity
|
|
3076
|
+
...sourceIdentity,
|
|
3077
|
+
...profileName == null ? {} : { profileName }
|
|
3006
3078
|
})
|
|
3007
3079
|
};
|
|
3008
3080
|
}
|
|
@@ -3021,20 +3093,23 @@ function normalizeLLMProfileChainInput(value) {
|
|
|
3021
3093
|
});
|
|
3022
3094
|
}
|
|
3023
3095
|
function scopeLLMProfileHealthIdentity(profile, fallback) {
|
|
3024
|
-
var _a, _b;
|
|
3096
|
+
var _a, _b, _c, _d;
|
|
3025
3097
|
const profileNodeId = ((_a = profile.healthIdentity) == null ? void 0 : _a.profileNodeId) ?? fallback.profileNodeId;
|
|
3098
|
+
const profileName = normalizeProfileName(profile.profileName) ?? normalizeProfileName((_b = profile.healthIdentity) == null ? void 0 : _b.profileName);
|
|
3026
3099
|
const healthIdentity = createRivetLLMProfileHealthIdentity({
|
|
3027
3100
|
configuration: profile.configuration,
|
|
3028
3101
|
credential: profile.credential,
|
|
3029
3102
|
chatNodeHeaders: fallback.chatNodeHeaders,
|
|
3030
3103
|
projectId: fallback.projectId,
|
|
3031
|
-
profileNodeId
|
|
3104
|
+
profileNodeId,
|
|
3105
|
+
...profileName == null ? {} : { profileName }
|
|
3032
3106
|
});
|
|
3033
|
-
if (((
|
|
3107
|
+
if (((_c = profile.healthIdentity) == null ? void 0 : _c.key) === healthIdentity.key && profile.profileName === profileName && ((_d = profile.healthIdentity) == null ? void 0 : _d.profileName) === profileName) {
|
|
3034
3108
|
return profile;
|
|
3035
3109
|
}
|
|
3036
3110
|
return {
|
|
3037
3111
|
...profile,
|
|
3112
|
+
...profileName == null ? {} : { profileName },
|
|
3038
3113
|
healthIdentity
|
|
3039
3114
|
};
|
|
3040
3115
|
}
|
|
@@ -3129,11 +3204,18 @@ function normalizeSourceIdentity(value) {
|
|
|
3129
3204
|
if (!isRecord2(value)) {
|
|
3130
3205
|
return {};
|
|
3131
3206
|
}
|
|
3207
|
+
const profileName = normalizeProfileName(value.profileName);
|
|
3132
3208
|
return {
|
|
3133
3209
|
...typeof value.projectId === "string" ? { projectId: value.projectId } : {},
|
|
3134
|
-
...typeof value.profileNodeId === "string" ? { profileNodeId: value.profileNodeId } : {}
|
|
3210
|
+
...typeof value.profileNodeId === "string" ? { profileNodeId: value.profileNodeId } : {},
|
|
3211
|
+
...profileName == null ? {} : { profileName }
|
|
3135
3212
|
};
|
|
3136
3213
|
}
|
|
3214
|
+
function normalizeProfileName(value) {
|
|
3215
|
+
if (typeof value !== "string") return void 0;
|
|
3216
|
+
const normalized = value.trim();
|
|
3217
|
+
return normalized === "" ? void 0 : normalized;
|
|
3218
|
+
}
|
|
3137
3219
|
function isRecord2(value) {
|
|
3138
3220
|
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
3139
3221
|
}
|
|
@@ -5547,6 +5629,269 @@ function isRecord4(value) {
|
|
|
5547
5629
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
5548
5630
|
}
|
|
5549
5631
|
|
|
5632
|
+
// src/utils/jsonPath.ts
|
|
5633
|
+
var import_jsonpath_plus = require("jsonpath-plus");
|
|
5634
|
+
|
|
5635
|
+
// src/utils/interpolationSyntax.ts
|
|
5636
|
+
var REGEX_LITERAL_PREFIX_CHARACTERS = /* @__PURE__ */ new Set([
|
|
5637
|
+
"(",
|
|
5638
|
+
"[",
|
|
5639
|
+
"{",
|
|
5640
|
+
":",
|
|
5641
|
+
";",
|
|
5642
|
+
",",
|
|
5643
|
+
"=",
|
|
5644
|
+
"!",
|
|
5645
|
+
"~",
|
|
5646
|
+
"?",
|
|
5647
|
+
"&",
|
|
5648
|
+
"|",
|
|
5649
|
+
"+",
|
|
5650
|
+
"-",
|
|
5651
|
+
"*",
|
|
5652
|
+
"%",
|
|
5653
|
+
"^",
|
|
5654
|
+
"<",
|
|
5655
|
+
">"
|
|
5656
|
+
]);
|
|
5657
|
+
function isInterpolationSyntaxCharacterEscaped(value, index) {
|
|
5658
|
+
let backslashCount = 0;
|
|
5659
|
+
for (let cursor = index - 1; cursor >= 0 && value[cursor] === "\\"; cursor -= 1) {
|
|
5660
|
+
backslashCount += 1;
|
|
5661
|
+
}
|
|
5662
|
+
return backslashCount % 2 === 1;
|
|
5663
|
+
}
|
|
5664
|
+
function isInterpolationRegexLiteralStart(value, index) {
|
|
5665
|
+
if (value[index] !== "/") {
|
|
5666
|
+
return false;
|
|
5667
|
+
}
|
|
5668
|
+
let previousIndex = index - 1;
|
|
5669
|
+
while (previousIndex >= 0 && /\s/.test(value[previousIndex])) {
|
|
5670
|
+
previousIndex -= 1;
|
|
5671
|
+
}
|
|
5672
|
+
return previousIndex < 0 || REGEX_LITERAL_PREFIX_CHARACTERS.has(value[previousIndex]);
|
|
5673
|
+
}
|
|
5674
|
+
function getEscapedTripleTokenEnd(template, start) {
|
|
5675
|
+
for (let cursor = start + 3; cursor < template.length - 2; cursor += 1) {
|
|
5676
|
+
if (template[cursor] === "}" && template[cursor + 1] === "}" && template[cursor + 2] === "}") {
|
|
5677
|
+
return cursor + 3;
|
|
5678
|
+
}
|
|
5679
|
+
}
|
|
5680
|
+
return void 0;
|
|
5681
|
+
}
|
|
5682
|
+
function scanInterpolationToken(template, start) {
|
|
5683
|
+
let quote;
|
|
5684
|
+
let regex = false;
|
|
5685
|
+
let regexCharacterClass = false;
|
|
5686
|
+
let bracketDepth = 0;
|
|
5687
|
+
let parenthesisDepth = 0;
|
|
5688
|
+
let braceDepth = 0;
|
|
5689
|
+
for (let cursor = start + 2; cursor < template.length; cursor += 1) {
|
|
5690
|
+
const character = template[cursor];
|
|
5691
|
+
if (regex) {
|
|
5692
|
+
if (character === "[" && !isInterpolationSyntaxCharacterEscaped(template, cursor)) {
|
|
5693
|
+
regexCharacterClass = true;
|
|
5694
|
+
} else if (character === "]" && !isInterpolationSyntaxCharacterEscaped(template, cursor)) {
|
|
5695
|
+
regexCharacterClass = false;
|
|
5696
|
+
} else if (character === "/" && !regexCharacterClass && !isInterpolationSyntaxCharacterEscaped(template, cursor)) {
|
|
5697
|
+
regex = false;
|
|
5698
|
+
}
|
|
5699
|
+
continue;
|
|
5700
|
+
}
|
|
5701
|
+
if (quote) {
|
|
5702
|
+
if (character === quote && !isInterpolationSyntaxCharacterEscaped(template, cursor)) {
|
|
5703
|
+
quote = void 0;
|
|
5704
|
+
}
|
|
5705
|
+
continue;
|
|
5706
|
+
}
|
|
5707
|
+
if (character === "/" && isInterpolationRegexLiteralStart(template, cursor)) {
|
|
5708
|
+
regex = true;
|
|
5709
|
+
regexCharacterClass = false;
|
|
5710
|
+
continue;
|
|
5711
|
+
}
|
|
5712
|
+
if (character === '"' || character === "'" || character === "`") {
|
|
5713
|
+
quote = character;
|
|
5714
|
+
continue;
|
|
5715
|
+
}
|
|
5716
|
+
if (character === "{" && template[cursor + 1] === "{") {
|
|
5717
|
+
return { kind: "nested", start: cursor };
|
|
5718
|
+
}
|
|
5719
|
+
if (character === "[") {
|
|
5720
|
+
bracketDepth += 1;
|
|
5721
|
+
continue;
|
|
5722
|
+
}
|
|
5723
|
+
if (character === "]" && bracketDepth > 0) {
|
|
5724
|
+
bracketDepth -= 1;
|
|
5725
|
+
continue;
|
|
5726
|
+
}
|
|
5727
|
+
if (character === "(") {
|
|
5728
|
+
parenthesisDepth += 1;
|
|
5729
|
+
continue;
|
|
5730
|
+
}
|
|
5731
|
+
if (character === ")" && parenthesisDepth > 0) {
|
|
5732
|
+
parenthesisDepth -= 1;
|
|
5733
|
+
continue;
|
|
5734
|
+
}
|
|
5735
|
+
if (character === "{") {
|
|
5736
|
+
braceDepth += 1;
|
|
5737
|
+
continue;
|
|
5738
|
+
}
|
|
5739
|
+
if (character === "}") {
|
|
5740
|
+
if (braceDepth > 0) {
|
|
5741
|
+
braceDepth -= 1;
|
|
5742
|
+
continue;
|
|
5743
|
+
}
|
|
5744
|
+
if (template[cursor + 1] === "}" && bracketDepth === 0 && parenthesisDepth === 0) {
|
|
5745
|
+
return { kind: "closed", end: cursor + 2 };
|
|
5746
|
+
}
|
|
5747
|
+
}
|
|
5748
|
+
}
|
|
5749
|
+
return { kind: "unclosed" };
|
|
5750
|
+
}
|
|
5751
|
+
function scanInterpolationTokenSpans(template) {
|
|
5752
|
+
const spans = [];
|
|
5753
|
+
let searchIndex = 0;
|
|
5754
|
+
while (searchIndex < template.length) {
|
|
5755
|
+
const start = template.indexOf("{{", searchIndex);
|
|
5756
|
+
if (start === -1) {
|
|
5757
|
+
break;
|
|
5758
|
+
}
|
|
5759
|
+
if (template[start + 2] === "{") {
|
|
5760
|
+
const escapedEnd = getEscapedTripleTokenEnd(template, start);
|
|
5761
|
+
if (escapedEnd !== void 0) {
|
|
5762
|
+
searchIndex = escapedEnd;
|
|
5763
|
+
continue;
|
|
5764
|
+
}
|
|
5765
|
+
}
|
|
5766
|
+
const scanResult = scanInterpolationToken(template, start);
|
|
5767
|
+
if (scanResult.kind === "nested") {
|
|
5768
|
+
searchIndex = scanResult.start;
|
|
5769
|
+
continue;
|
|
5770
|
+
}
|
|
5771
|
+
if (scanResult.kind === "unclosed") {
|
|
5772
|
+
const nextStart = template.indexOf("{{", start + 2);
|
|
5773
|
+
if (nextStart === -1) {
|
|
5774
|
+
break;
|
|
5775
|
+
}
|
|
5776
|
+
searchIndex = nextStart;
|
|
5777
|
+
continue;
|
|
5778
|
+
}
|
|
5779
|
+
spans.push({
|
|
5780
|
+
start,
|
|
5781
|
+
end: scanResult.end,
|
|
5782
|
+
rawInner: template.slice(start + 2, scanResult.end - 2)
|
|
5783
|
+
});
|
|
5784
|
+
searchIndex = scanResult.end;
|
|
5785
|
+
}
|
|
5786
|
+
return spans;
|
|
5787
|
+
}
|
|
5788
|
+
|
|
5789
|
+
// src/utils/jsonPath.ts
|
|
5790
|
+
function getNextNonWhitespaceCharacter(value, index) {
|
|
5791
|
+
for (let cursor = index; cursor < value.length; cursor++) {
|
|
5792
|
+
if (!/\s/.test(value[cursor])) {
|
|
5793
|
+
return value[cursor];
|
|
5794
|
+
}
|
|
5795
|
+
}
|
|
5796
|
+
return void 0;
|
|
5797
|
+
}
|
|
5798
|
+
function getWhitespaceRunEnd(value, index) {
|
|
5799
|
+
let cursor = index;
|
|
5800
|
+
while (cursor < value.length && /\s/.test(value[cursor])) {
|
|
5801
|
+
cursor += 1;
|
|
5802
|
+
}
|
|
5803
|
+
return cursor;
|
|
5804
|
+
}
|
|
5805
|
+
function normalizeJsonPathExpression(path) {
|
|
5806
|
+
const trimmedPath = path.trim();
|
|
5807
|
+
if (!/\s/.test(trimmedPath)) {
|
|
5808
|
+
return trimmedPath;
|
|
5809
|
+
}
|
|
5810
|
+
const result = [];
|
|
5811
|
+
let lastResultCharacter;
|
|
5812
|
+
let quote;
|
|
5813
|
+
let regex = false;
|
|
5814
|
+
let regexCharacterClass = false;
|
|
5815
|
+
const filterBrackets = [];
|
|
5816
|
+
let filterDepth = 0;
|
|
5817
|
+
const append = (value) => {
|
|
5818
|
+
if (value === "") {
|
|
5819
|
+
return;
|
|
5820
|
+
}
|
|
5821
|
+
result.push(value);
|
|
5822
|
+
lastResultCharacter = value.at(-1);
|
|
5823
|
+
};
|
|
5824
|
+
for (let cursor = 0; cursor < trimmedPath.length; cursor++) {
|
|
5825
|
+
const character = trimmedPath[cursor];
|
|
5826
|
+
if (regex) {
|
|
5827
|
+
if (character === "[" && !isInterpolationSyntaxCharacterEscaped(trimmedPath, cursor)) {
|
|
5828
|
+
regexCharacterClass = true;
|
|
5829
|
+
} else if (character === "]" && !isInterpolationSyntaxCharacterEscaped(trimmedPath, cursor)) {
|
|
5830
|
+
regexCharacterClass = false;
|
|
5831
|
+
} else if (character === "/" && !regexCharacterClass && !isInterpolationSyntaxCharacterEscaped(trimmedPath, cursor)) {
|
|
5832
|
+
regex = false;
|
|
5833
|
+
}
|
|
5834
|
+
append(character);
|
|
5835
|
+
continue;
|
|
5836
|
+
}
|
|
5837
|
+
if (quote) {
|
|
5838
|
+
if (character === quote && !isInterpolationSyntaxCharacterEscaped(trimmedPath, cursor)) {
|
|
5839
|
+
quote = void 0;
|
|
5840
|
+
}
|
|
5841
|
+
append(character);
|
|
5842
|
+
continue;
|
|
5843
|
+
}
|
|
5844
|
+
if (character === '"' || character === "'" || character === "`") {
|
|
5845
|
+
quote = character;
|
|
5846
|
+
append(character);
|
|
5847
|
+
continue;
|
|
5848
|
+
}
|
|
5849
|
+
if (character === "/" && isInterpolationRegexLiteralStart(trimmedPath, cursor)) {
|
|
5850
|
+
regex = true;
|
|
5851
|
+
regexCharacterClass = false;
|
|
5852
|
+
append(character);
|
|
5853
|
+
continue;
|
|
5854
|
+
}
|
|
5855
|
+
const insideFilter = filterDepth > 0;
|
|
5856
|
+
if (/\s/.test(character)) {
|
|
5857
|
+
const whitespaceEnd = getWhitespaceRunEnd(trimmedPath, cursor);
|
|
5858
|
+
const previousCharacter = lastResultCharacter;
|
|
5859
|
+
const nextCharacter = trimmedPath[whitespaceEnd];
|
|
5860
|
+
const shouldRemoveWhitespace = previousCharacter === "[" || nextCharacter === "]" || nextCharacter === "[" || !insideFilter && (previousCharacter === "." || previousCharacter === "]" || nextCharacter === ".");
|
|
5861
|
+
if (!shouldRemoveWhitespace) {
|
|
5862
|
+
append(trimmedPath.slice(cursor, whitespaceEnd));
|
|
5863
|
+
}
|
|
5864
|
+
cursor = whitespaceEnd - 1;
|
|
5865
|
+
continue;
|
|
5866
|
+
}
|
|
5867
|
+
if (character === "[") {
|
|
5868
|
+
const opensFilter = getNextNonWhitespaceCharacter(trimmedPath, cursor + 1) === "?";
|
|
5869
|
+
filterBrackets.push(opensFilter);
|
|
5870
|
+
if (opensFilter) {
|
|
5871
|
+
filterDepth += 1;
|
|
5872
|
+
}
|
|
5873
|
+
append(character);
|
|
5874
|
+
continue;
|
|
5875
|
+
}
|
|
5876
|
+
if (character === "]") {
|
|
5877
|
+
if (filterBrackets.pop()) {
|
|
5878
|
+
filterDepth -= 1;
|
|
5879
|
+
}
|
|
5880
|
+
append(character);
|
|
5881
|
+
continue;
|
|
5882
|
+
}
|
|
5883
|
+
append(character);
|
|
5884
|
+
}
|
|
5885
|
+
return result.join("").trim();
|
|
5886
|
+
}
|
|
5887
|
+
function evaluateJsonPath(value, path, wrap = false) {
|
|
5888
|
+
return (0, import_jsonpath_plus.JSONPath)({
|
|
5889
|
+
json: value ?? null,
|
|
5890
|
+
path: normalizeJsonPathExpression(path),
|
|
5891
|
+
wrap
|
|
5892
|
+
});
|
|
5893
|
+
}
|
|
5894
|
+
|
|
5550
5895
|
// src/utils/pQueueCompat.ts
|
|
5551
5896
|
var import_p_queue = __toESM(require("p-queue-6"), 1);
|
|
5552
5897
|
var PQueue = typeof import_p_queue.default === "function" ? import_p_queue.default : import_p_queue.default.default;
|
|
@@ -6235,7 +6580,6 @@ function buildGraphExecutionPlan(options2) {
|
|
|
6235
6580
|
}
|
|
6236
6581
|
|
|
6237
6582
|
// src/model/GraphBoundaryCache.ts
|
|
6238
|
-
var GRAPH_BOUNDARY_OUTPUT_DEMAND_OPTIMIZATION_ENABLED = false;
|
|
6239
6583
|
function getGraphBoundary(project, graphId2, cache4) {
|
|
6240
6584
|
if (!graphId2) {
|
|
6241
6585
|
return void 0;
|
|
@@ -6323,9 +6667,6 @@ function buildExcludedGraphBoundaryOutputs(boundary) {
|
|
|
6323
6667
|
}
|
|
6324
6668
|
return outputs;
|
|
6325
6669
|
}
|
|
6326
|
-
function getRequestedGraphOutputNodeIds(boundary, requestedOutputPortIds) {
|
|
6327
|
-
return boundary.outputs.filter((output) => requestedOutputPortIds.has(output.portId)).map((output) => output.nodeId);
|
|
6328
|
-
}
|
|
6329
6670
|
function deriveGraphBoundary(graph) {
|
|
6330
6671
|
const inputsById = /* @__PURE__ */ new Map();
|
|
6331
6672
|
const outputsById = /* @__PURE__ */ new Map();
|
|
@@ -6357,6 +6698,98 @@ function getBoundaryNodeId(node) {
|
|
|
6357
6698
|
return node.data.id;
|
|
6358
6699
|
}
|
|
6359
6700
|
|
|
6701
|
+
// src/model/chat-v2/toolContinuationConnection.ts
|
|
6702
|
+
var LLM_CHAT_V2_TOOL_CALLS_OUTPUT_ID = "function-calls";
|
|
6703
|
+
var DELEGATE_TOOL_CALL_INPUT_ID = "function-call";
|
|
6704
|
+
function resolveToolContinuationConnections(graph) {
|
|
6705
|
+
const nodesById = new Map(graph.nodes.map((node) => [node.id, node]));
|
|
6706
|
+
const firstConnectionByInput = /* @__PURE__ */ new Map();
|
|
6707
|
+
for (const connection of graph.connections) {
|
|
6708
|
+
if (!nodesById.has(connection.outputNodeId) || !nodesById.has(connection.inputNodeId)) {
|
|
6709
|
+
continue;
|
|
6710
|
+
}
|
|
6711
|
+
const inputKey = `${connection.inputNodeId}\0${connection.inputId}`;
|
|
6712
|
+
if (!firstConnectionByInput.has(inputKey)) {
|
|
6713
|
+
firstConnectionByInput.set(inputKey, connection);
|
|
6714
|
+
}
|
|
6715
|
+
}
|
|
6716
|
+
const candidatesByLLMNodeId = /* @__PURE__ */ new Map();
|
|
6717
|
+
for (const connection of graph.connections) {
|
|
6718
|
+
if (connection.outputId !== LLM_CHAT_V2_TOOL_CALLS_OUTPUT_ID || connection.inputId !== DELEGATE_TOOL_CALL_INPUT_ID) {
|
|
6719
|
+
continue;
|
|
6720
|
+
}
|
|
6721
|
+
const llmNode = nodesById.get(connection.outputNodeId);
|
|
6722
|
+
const delegateNode = nodesById.get(connection.inputNodeId);
|
|
6723
|
+
if (!isEligibleLLMChatV2Node(llmNode) || !isEligibleDelegateToolCallNode(delegateNode)) {
|
|
6724
|
+
continue;
|
|
6725
|
+
}
|
|
6726
|
+
const inputKey = `${connection.inputNodeId}\0${connection.inputId}`;
|
|
6727
|
+
if (firstConnectionByInput.get(inputKey) !== connection) {
|
|
6728
|
+
continue;
|
|
6729
|
+
}
|
|
6730
|
+
const candidates = candidatesByLLMNodeId.get(llmNode.id);
|
|
6731
|
+
const candidate = { connection, delegateNode };
|
|
6732
|
+
if (candidates) {
|
|
6733
|
+
candidates.push(candidate);
|
|
6734
|
+
} else {
|
|
6735
|
+
candidatesByLLMNodeId.set(llmNode.id, [candidate]);
|
|
6736
|
+
}
|
|
6737
|
+
}
|
|
6738
|
+
const resolutions = /* @__PURE__ */ new Map();
|
|
6739
|
+
for (const [llmNodeId, candidates] of candidatesByLLMNodeId) {
|
|
6740
|
+
if (candidates.length === 1) {
|
|
6741
|
+
resolutions.set(llmNodeId, { kind: "connected", ...candidates[0] });
|
|
6742
|
+
} else {
|
|
6743
|
+
resolutions.set(llmNodeId, { kind: "ambiguous", candidates });
|
|
6744
|
+
}
|
|
6745
|
+
}
|
|
6746
|
+
return resolutions;
|
|
6747
|
+
}
|
|
6748
|
+
function resolveToolContinuationConnection(graph, llmNodeId) {
|
|
6749
|
+
return resolveToolContinuationConnections(graph).get(llmNodeId) ?? { kind: "none" };
|
|
6750
|
+
}
|
|
6751
|
+
function isEligibleLLMChatV2Node(node) {
|
|
6752
|
+
if (!node || node.disabled || node.isSplitRun || node.type !== "llmChatV2") {
|
|
6753
|
+
return false;
|
|
6754
|
+
}
|
|
6755
|
+
const data = node.data;
|
|
6756
|
+
return data.useToolCalling === true && data.autoContinueToolCalls === true;
|
|
6757
|
+
}
|
|
6758
|
+
function isEligibleDelegateToolCallNode(node) {
|
|
6759
|
+
return (node == null ? void 0 : node.type) === "delegateFunctionCall" && !node.disabled;
|
|
6760
|
+
}
|
|
6761
|
+
|
|
6762
|
+
// src/model/GraphOutputSelection.ts
|
|
6763
|
+
function createGraphOutputSelection(graph, requestedOutputIds, getInputNodes) {
|
|
6764
|
+
const requestedIds = new Set(requestedOutputIds);
|
|
6765
|
+
const missingIds = new Set(requestedIds);
|
|
6766
|
+
const startNodes = graph.nodes.filter((node) => {
|
|
6767
|
+
if (node.type !== "graphOutput") return false;
|
|
6768
|
+
const outputId = node.data.id;
|
|
6769
|
+
missingIds.delete(outputId);
|
|
6770
|
+
return requestedIds.has(outputId);
|
|
6771
|
+
});
|
|
6772
|
+
if (missingIds.size > 0) {
|
|
6773
|
+
throw new Error(
|
|
6774
|
+
`Unknown requested graph output IDs: ${[...missingIds].map((id) => JSON.stringify(id)).join(", ")}`
|
|
6775
|
+
);
|
|
6776
|
+
}
|
|
6777
|
+
const continuations = resolveToolContinuationConnections(graph);
|
|
6778
|
+
const nodeIds = /* @__PURE__ */ new Set();
|
|
6779
|
+
const pendingNodes = [...startNodes];
|
|
6780
|
+
for (let index = 0; index < pendingNodes.length; index++) {
|
|
6781
|
+
const node = pendingNodes[index];
|
|
6782
|
+
if (nodeIds.has(node.id)) continue;
|
|
6783
|
+
nodeIds.add(node.id);
|
|
6784
|
+
pendingNodes.push(...getInputNodes(node));
|
|
6785
|
+
const continuation = continuations.get(node.id);
|
|
6786
|
+
if ((continuation == null ? void 0 : continuation.kind) === "connected") {
|
|
6787
|
+
pendingNodes.push(continuation.delegateNode);
|
|
6788
|
+
}
|
|
6789
|
+
}
|
|
6790
|
+
return { startNodes, nodeIds };
|
|
6791
|
+
}
|
|
6792
|
+
|
|
6360
6793
|
// src/model/GraphBoundaryEffects.ts
|
|
6361
6794
|
function ensureGraphCostOutput(graphOutputs, totalCost) {
|
|
6362
6795
|
const costPort = "cost";
|
|
@@ -6368,11 +6801,11 @@ function ensureGraphCostOutput(graphOutputs, totalCost) {
|
|
|
6368
6801
|
}
|
|
6369
6802
|
}
|
|
6370
6803
|
function applyFrozenGraphBoundaryEffects(graphOutputs, node, outputValues) {
|
|
6371
|
-
var _a;
|
|
6804
|
+
var _a, _b;
|
|
6372
6805
|
if (node.type === "graphOutput") {
|
|
6373
6806
|
const outputId = (_a = node.data) == null ? void 0 : _a.id;
|
|
6374
6807
|
const valueOutput = outputValues["valueOutput"];
|
|
6375
|
-
if (outputId && valueOutput) {
|
|
6808
|
+
if (outputId && valueOutput && (graphOutputs[outputId] == null || ((_b = graphOutputs[outputId]) == null ? void 0 : _b.type) === "control-flow-excluded")) {
|
|
6376
6809
|
graphOutputs[outputId] = valueOutput;
|
|
6377
6810
|
}
|
|
6378
6811
|
return void 0;
|
|
@@ -6444,11 +6877,10 @@ var REPLAY_TIMED_LIFECYCLE_EVENTS = /* @__PURE__ */ new Set([
|
|
|
6444
6877
|
"nodeOutputsCleared"
|
|
6445
6878
|
]);
|
|
6446
6879
|
async function replayExecutionRecording(options2) {
|
|
6447
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
6880
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
6448
6881
|
const {
|
|
6449
6882
|
emitter,
|
|
6450
6883
|
erroredNodes,
|
|
6451
|
-
graphOutputs,
|
|
6452
6884
|
fallbackGraphId,
|
|
6453
6885
|
initialReplayExecution,
|
|
6454
6886
|
project,
|
|
@@ -6463,6 +6895,7 @@ async function replayExecutionRecording(options2) {
|
|
|
6463
6895
|
nodeResults,
|
|
6464
6896
|
isAborted
|
|
6465
6897
|
} = options2;
|
|
6898
|
+
let graphOutputs = options2.graphOutputs;
|
|
6466
6899
|
const nodesByIdAllGraphs = {};
|
|
6467
6900
|
const graphIdByNodeId = {};
|
|
6468
6901
|
for (const graph of Object.values(project.graphs)) {
|
|
@@ -6571,13 +7004,13 @@ async function replayExecutionRecording(options2) {
|
|
|
6571
7004
|
replayRootRunId = replayRootRunIds.size === 0 && initialReplayExecution ? initialReplayExecution.rootRunId : (0, import_non_secure4.nanoid)();
|
|
6572
7005
|
replayRootRunIds.set(recordedExecution.rootRunId, replayRootRunId);
|
|
6573
7006
|
}
|
|
6574
|
-
const getReplayGraphRunId = (recordedGraphRunId) => {
|
|
7007
|
+
const getReplayGraphRunId = (recordedGraphRunId, initialGraphRunId) => {
|
|
6575
7008
|
let graphRunIds = replayGraphRunIdsByRoot.get(recordedExecution.rootRunId);
|
|
6576
7009
|
if (graphRunIds == null) {
|
|
6577
7010
|
graphRunIds = /* @__PURE__ */ new Map();
|
|
6578
7011
|
replayGraphRunIdsByRoot.set(recordedExecution.rootRunId, graphRunIds);
|
|
6579
7012
|
}
|
|
6580
|
-
const replayGraphRunId = graphRunIds.get(recordedGraphRunId) ?? (0, import_non_secure4.nanoid)();
|
|
7013
|
+
const replayGraphRunId = initialGraphRunId ?? graphRunIds.get(recordedGraphRunId) ?? (0, import_non_secure4.nanoid)();
|
|
6581
7014
|
graphRunIds.set(recordedGraphRunId, replayGraphRunId);
|
|
6582
7015
|
return replayGraphRunId;
|
|
6583
7016
|
};
|
|
@@ -6586,7 +7019,12 @@ async function replayExecutionRecording(options2) {
|
|
|
6586
7019
|
return {
|
|
6587
7020
|
...rest,
|
|
6588
7021
|
rootRunId: replayRootRunId,
|
|
6589
|
-
|
|
7022
|
+
// Seed the root mapping too, so child parentGraphRunId references resolve
|
|
7023
|
+
// to the same identity already allocated by the playback processor.
|
|
7024
|
+
graphRunId: getReplayGraphRunId(
|
|
7025
|
+
graphRunId,
|
|
7026
|
+
isInitialRootGraph ? initialReplayExecution.graphRunId : void 0
|
|
7027
|
+
),
|
|
6590
7028
|
...parentGraphRunId == null ? {} : { parentGraphRunId: getReplayGraphRunId(parentGraphRunId) }
|
|
6591
7029
|
};
|
|
6592
7030
|
};
|
|
@@ -6634,8 +7072,8 @@ async function replayExecutionRecording(options2) {
|
|
|
6634
7072
|
case "done": {
|
|
6635
7073
|
emitFallbackRootTerminal("completed", { outputs: event.data.results });
|
|
6636
7074
|
emitReplayTerminalEvent("done", event.data);
|
|
6637
|
-
|
|
6638
|
-
|
|
7075
|
+
graphOutputs = event.data.results;
|
|
7076
|
+
setGraphOutputs(graphOutputs);
|
|
6639
7077
|
break;
|
|
6640
7078
|
}
|
|
6641
7079
|
case "error": {
|
|
@@ -6830,11 +7268,19 @@ async function replayExecutionRecording(options2) {
|
|
|
6830
7268
|
});
|
|
6831
7269
|
break;
|
|
6832
7270
|
}
|
|
7271
|
+
case "llmChatOutputSnapshot": {
|
|
7272
|
+
const { data } = event;
|
|
7273
|
+
emitReplayExecutionEvent("llmChatOutputSnapshot", {
|
|
7274
|
+
...data,
|
|
7275
|
+
execution: getExecution(((_l = data.execution) == null ? void 0 : _l.graphId) ?? getGraphIdForNode(data.nodeId), data.execution)
|
|
7276
|
+
});
|
|
7277
|
+
break;
|
|
7278
|
+
}
|
|
6833
7279
|
case "llmProfileAttempt": {
|
|
6834
7280
|
const { data } = event;
|
|
6835
7281
|
emitReplayExecutionEvent("llmProfileAttempt", {
|
|
6836
7282
|
...data,
|
|
6837
|
-
execution: getExecution(((
|
|
7283
|
+
execution: getExecution(((_m = data.execution) == null ? void 0 : _m.graphId) ?? getGraphIdForNode(data.nodeId), data.execution)
|
|
6838
7284
|
});
|
|
6839
7285
|
break;
|
|
6840
7286
|
}
|
|
@@ -6842,7 +7288,7 @@ async function replayExecutionRecording(options2) {
|
|
|
6842
7288
|
const { data } = event;
|
|
6843
7289
|
emitReplayExecutionEvent("toolCallFinished", {
|
|
6844
7290
|
...data,
|
|
6845
|
-
execution: getExecution(((
|
|
7291
|
+
execution: getExecution(((_n = data.execution) == null ? void 0 : _n.graphId) ?? getGraphIdForNode(data.sourceNodeId), data.execution)
|
|
6846
7292
|
});
|
|
6847
7293
|
break;
|
|
6848
7294
|
}
|
|
@@ -6860,7 +7306,7 @@ async function replayExecutionRecording(options2) {
|
|
|
6860
7306
|
node,
|
|
6861
7307
|
processId: data.processId,
|
|
6862
7308
|
renderingType: data.renderingType,
|
|
6863
|
-
execution: getExecution(((
|
|
7309
|
+
execution: getExecution(((_o = data.execution) == null ? void 0 : _o.graphId) ?? getGraphIdForNode(data.nodeId), data.execution)
|
|
6864
7310
|
});
|
|
6865
7311
|
break;
|
|
6866
7312
|
}
|
|
@@ -6926,6 +7372,7 @@ function buildNodeProcessContext(options2) {
|
|
|
6926
7372
|
requestUserInput,
|
|
6927
7373
|
reportProgress,
|
|
6928
7374
|
setGlobal,
|
|
7375
|
+
splitIndex,
|
|
6929
7376
|
toolCallContinuation,
|
|
6930
7377
|
toolCallTraceSource,
|
|
6931
7378
|
waitEvent
|
|
@@ -6938,10 +7385,13 @@ function buildNodeProcessContext(options2) {
|
|
|
6938
7385
|
isDirectRunTarget,
|
|
6939
7386
|
markResultAsEditorCacheHit,
|
|
6940
7387
|
waitEvent,
|
|
7388
|
+
waitForGlobal: (id, signal = nodeAbortController.signal) => base.waitForGlobal(id, signal),
|
|
7389
|
+
waitForStoredValue: (key, signal = nodeAbortController.signal) => base.waitForStoredValue(key, signal),
|
|
6941
7390
|
externalFunctions: { ...externalFunctions },
|
|
6942
7391
|
onPartialOutputs,
|
|
6943
7392
|
signal: nodeAbortController.signal,
|
|
6944
7393
|
processId,
|
|
7394
|
+
splitIndex,
|
|
6945
7395
|
setGlobal,
|
|
6946
7396
|
createSubProcessor,
|
|
6947
7397
|
getPluginConfig: getPluginConfig2,
|
|
@@ -7394,6 +7844,7 @@ function wireSubprocessorEvents(processor, parentEmitter, parentState) {
|
|
|
7394
7844
|
processor.on("partialOutput", (event) => parentEmitter.emit("partialOutput", event)),
|
|
7395
7845
|
processor.on("progress", (event) => parentEmitter.emit("progress", event)),
|
|
7396
7846
|
processor.on("llmCallFinished", (event) => parentEmitter.emit("llmCallFinished", event)),
|
|
7847
|
+
processor.on("llmChatOutputSnapshot", (event) => parentEmitter.emit("llmChatOutputSnapshot", event)),
|
|
7397
7848
|
processor.on("llmProfileAttempt", (event) => parentEmitter.emit("llmProfileAttempt", event)),
|
|
7398
7849
|
processor.on("toolCallFinished", (event) => parentEmitter.emit("toolCallFinished", event)),
|
|
7399
7850
|
processor.on("nodeExcluded", (event) => parentEmitter.emit("nodeExcluded", event)),
|
|
@@ -7676,9 +8127,9 @@ var RivetStoredValueController = class {
|
|
|
7676
8127
|
}
|
|
7677
8128
|
});
|
|
7678
8129
|
});
|
|
8130
|
+
const value = waiterPromise === void 0 ? immediateValue : await waiterPromise;
|
|
7679
8131
|
signal == null ? void 0 : signal.throwIfAborted();
|
|
7680
|
-
|
|
7681
|
-
return await waiterPromise;
|
|
8132
|
+
return value;
|
|
7682
8133
|
}
|
|
7683
8134
|
async #getUnlocked(key) {
|
|
7684
8135
|
var _a;
|
|
@@ -7807,6 +8258,9 @@ var nodesAllowedToConsumeExcludedValue = /* @__PURE__ */ new Set([
|
|
|
7807
8258
|
"raceInputs",
|
|
7808
8259
|
"loopController"
|
|
7809
8260
|
]);
|
|
8261
|
+
function canConsumeControlFlowExcludedInput(node) {
|
|
8262
|
+
return nodesAllowedToConsumeExcludedValue.has(node.type);
|
|
8263
|
+
}
|
|
7810
8264
|
function isControlFlowExcluded2(value) {
|
|
7811
8265
|
return value != null && getScalarTypeOf(value.type) === "control-flow-excluded";
|
|
7812
8266
|
}
|
|
@@ -7837,7 +8291,7 @@ function getControlFlowExclusionDecision({
|
|
|
7837
8291
|
([, value]) => isControlFlowExcluded2(value) && (typeOfExclusion === void 0 || value.value === typeOfExclusion)
|
|
7838
8292
|
);
|
|
7839
8293
|
const isWaitingForLoop = controlFlowExcludedValues.some(([, value]) => (value == null ? void 0 : value.value) === LOOP_NOT_BROKEN_SENTINEL);
|
|
7840
|
-
const allowedToConsumeExcludedValue =
|
|
8294
|
+
const allowedToConsumeExcludedValue = canConsumeControlFlowExcludedInput(node) && !isWaitingForLoop;
|
|
7841
8295
|
if (controlFlowExcludedValues.length === 0 || allowedToConsumeExcludedValue) {
|
|
7842
8296
|
return { action: "continue" };
|
|
7843
8297
|
}
|
|
@@ -7869,67 +8323,6 @@ function createExcludedNodeOutputs(node, outputDefinitions) {
|
|
|
7869
8323
|
return outputs;
|
|
7870
8324
|
}
|
|
7871
8325
|
|
|
7872
|
-
// src/model/chat-v2/toolContinuationConnection.ts
|
|
7873
|
-
var LLM_CHAT_V2_TOOL_CALLS_OUTPUT_ID = "function-calls";
|
|
7874
|
-
var DELEGATE_TOOL_CALL_INPUT_ID = "function-call";
|
|
7875
|
-
function resolveToolContinuationConnections(graph) {
|
|
7876
|
-
const nodesById = new Map(graph.nodes.map((node) => [node.id, node]));
|
|
7877
|
-
const firstConnectionByInput = /* @__PURE__ */ new Map();
|
|
7878
|
-
for (const connection of graph.connections) {
|
|
7879
|
-
if (!nodesById.has(connection.outputNodeId) || !nodesById.has(connection.inputNodeId)) {
|
|
7880
|
-
continue;
|
|
7881
|
-
}
|
|
7882
|
-
const inputKey = `${connection.inputNodeId}\0${connection.inputId}`;
|
|
7883
|
-
if (!firstConnectionByInput.has(inputKey)) {
|
|
7884
|
-
firstConnectionByInput.set(inputKey, connection);
|
|
7885
|
-
}
|
|
7886
|
-
}
|
|
7887
|
-
const candidatesByLLMNodeId = /* @__PURE__ */ new Map();
|
|
7888
|
-
for (const connection of graph.connections) {
|
|
7889
|
-
if (connection.outputId !== LLM_CHAT_V2_TOOL_CALLS_OUTPUT_ID || connection.inputId !== DELEGATE_TOOL_CALL_INPUT_ID) {
|
|
7890
|
-
continue;
|
|
7891
|
-
}
|
|
7892
|
-
const llmNode = nodesById.get(connection.outputNodeId);
|
|
7893
|
-
const delegateNode = nodesById.get(connection.inputNodeId);
|
|
7894
|
-
if (!isEligibleLLMChatV2Node(llmNode) || !isEligibleDelegateToolCallNode(delegateNode)) {
|
|
7895
|
-
continue;
|
|
7896
|
-
}
|
|
7897
|
-
const inputKey = `${connection.inputNodeId}\0${connection.inputId}`;
|
|
7898
|
-
if (firstConnectionByInput.get(inputKey) !== connection) {
|
|
7899
|
-
continue;
|
|
7900
|
-
}
|
|
7901
|
-
const candidates = candidatesByLLMNodeId.get(llmNode.id);
|
|
7902
|
-
const candidate = { connection, delegateNode };
|
|
7903
|
-
if (candidates) {
|
|
7904
|
-
candidates.push(candidate);
|
|
7905
|
-
} else {
|
|
7906
|
-
candidatesByLLMNodeId.set(llmNode.id, [candidate]);
|
|
7907
|
-
}
|
|
7908
|
-
}
|
|
7909
|
-
const resolutions = /* @__PURE__ */ new Map();
|
|
7910
|
-
for (const [llmNodeId, candidates] of candidatesByLLMNodeId) {
|
|
7911
|
-
if (candidates.length === 1) {
|
|
7912
|
-
resolutions.set(llmNodeId, { kind: "connected", ...candidates[0] });
|
|
7913
|
-
} else {
|
|
7914
|
-
resolutions.set(llmNodeId, { kind: "ambiguous", candidates });
|
|
7915
|
-
}
|
|
7916
|
-
}
|
|
7917
|
-
return resolutions;
|
|
7918
|
-
}
|
|
7919
|
-
function resolveToolContinuationConnection(graph, llmNodeId) {
|
|
7920
|
-
return resolveToolContinuationConnections(graph).get(llmNodeId) ?? { kind: "none" };
|
|
7921
|
-
}
|
|
7922
|
-
function isEligibleLLMChatV2Node(node) {
|
|
7923
|
-
if (!node || node.disabled || node.isSplitRun || node.type !== "llmChatV2") {
|
|
7924
|
-
return false;
|
|
7925
|
-
}
|
|
7926
|
-
const data = node.data;
|
|
7927
|
-
return data.useToolCalling === true && data.autoContinueToolCalls === true;
|
|
7928
|
-
}
|
|
7929
|
-
function isEligibleDelegateToolCallNode(node) {
|
|
7930
|
-
return (node == null ? void 0 : node.type) === "delegateFunctionCall" && !node.disabled;
|
|
7931
|
-
}
|
|
7932
|
-
|
|
7933
8326
|
// src/model/nodes/toolCallDelegation.ts
|
|
7934
8327
|
var import_lodash_es4 = require("lodash");
|
|
7935
8328
|
|
|
@@ -9112,6 +9505,495 @@ var ConnectedToolContinuationHost = class {
|
|
|
9112
9505
|
}
|
|
9113
9506
|
};
|
|
9114
9507
|
|
|
9508
|
+
// src/utils/interpolation.ts
|
|
9509
|
+
var ESCAPED_TOKEN_REGEX = /\{\{\{([^}]+?)\}\}\}/g;
|
|
9510
|
+
var ESCAPED_ESCAPED_TOKEN_REGEX = /\\\{\\\{([^}]+?)\\\}\\\}/g;
|
|
9511
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_ENTRIES = 2048;
|
|
9512
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_LENGTH = 64 * 1024;
|
|
9513
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_CHARS = 1024 * 1024;
|
|
9514
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_STORAGE_CHARS = 2 * 1024 * 1024;
|
|
9515
|
+
var INTERPOLATION_EXPRESSION_CACHE_MAX_ENTRIES = 512;
|
|
9516
|
+
var INTERPOLATION_EXPRESSION_CACHE_MAX_EXPRESSION_LENGTH = 4 * 1024;
|
|
9517
|
+
var INTERPOLATION_EXPRESSION_CACHE_MAX_CHARS = 128 * 1024;
|
|
9518
|
+
var interpolationTemplateCache = /* @__PURE__ */ new Map();
|
|
9519
|
+
var cachedInterpolationTemplateChars = 0;
|
|
9520
|
+
var cachedInterpolationTemplateStorageChars = 0;
|
|
9521
|
+
var lastUncachedInterpolationTemplate;
|
|
9522
|
+
var interpolationExpressionCache = /* @__PURE__ */ new Map();
|
|
9523
|
+
var cachedInterpolationExpressionChars = 0;
|
|
9524
|
+
var dataValueTypeSet = new Set(dataTypes);
|
|
9525
|
+
var processingFunctions = {
|
|
9526
|
+
indent: (input, spaces = 0) => {
|
|
9527
|
+
const indent = " ".repeat(spaces);
|
|
9528
|
+
return input.split("\n").map((line) => `${indent}${line}`).join("\n");
|
|
9529
|
+
},
|
|
9530
|
+
quote: (input, level = 1) => {
|
|
9531
|
+
const quotePrefix = "> ".repeat(level);
|
|
9532
|
+
return input.split("\n").map((line) => `${quotePrefix}${line}`).join("\n");
|
|
9533
|
+
},
|
|
9534
|
+
uppercase: (input) => input.toUpperCase(),
|
|
9535
|
+
lowercase: (input) => input.toLowerCase(),
|
|
9536
|
+
trim: (input) => input.trim(),
|
|
9537
|
+
truncate: (input, length = 50) => {
|
|
9538
|
+
if (input.length <= length) return input;
|
|
9539
|
+
return input.slice(0, length) + "...";
|
|
9540
|
+
},
|
|
9541
|
+
list: (input, level = 1) => {
|
|
9542
|
+
const indent = " ".repeat(level - 1);
|
|
9543
|
+
return input.split("\n").map((line) => `${indent}- ${line}`).join("\n");
|
|
9544
|
+
},
|
|
9545
|
+
sort: (input) => input.split("\n").sort().join("\n"),
|
|
9546
|
+
dedent: (input) => (0, import_ts_dedent.dedent)(input),
|
|
9547
|
+
wrap: (input, width = 80) => {
|
|
9548
|
+
const words = input.split(/\s+/);
|
|
9549
|
+
const lines = [];
|
|
9550
|
+
let currentLine = "";
|
|
9551
|
+
for (const word of words) {
|
|
9552
|
+
if (currentLine.length + word.length + 1 <= width) {
|
|
9553
|
+
currentLine += (currentLine ? " " : "") + word;
|
|
9554
|
+
} else {
|
|
9555
|
+
lines.push(currentLine);
|
|
9556
|
+
currentLine = word;
|
|
9557
|
+
}
|
|
9558
|
+
}
|
|
9559
|
+
if (currentLine) {
|
|
9560
|
+
lines.push(currentLine);
|
|
9561
|
+
}
|
|
9562
|
+
return lines.join("\n");
|
|
9563
|
+
}
|
|
9564
|
+
};
|
|
9565
|
+
function unwrapPotentialDataValue(value) {
|
|
9566
|
+
if (isRivetDataValue(value)) {
|
|
9567
|
+
return value.value;
|
|
9568
|
+
}
|
|
9569
|
+
return value;
|
|
9570
|
+
}
|
|
9571
|
+
function isRivetDataValue(value) {
|
|
9572
|
+
return typeof value === "object" && value !== null && typeof value.type === "string" && dataValueTypeSet.has(value.type) && Object.prototype.hasOwnProperty.call(value, "value");
|
|
9573
|
+
}
|
|
9574
|
+
function stringifyInterpolationSourceValue(value, {
|
|
9575
|
+
coerceDataValueToString = false,
|
|
9576
|
+
unwrapDataValue: unwrapDataValue2 = true
|
|
9577
|
+
} = {}) {
|
|
9578
|
+
try {
|
|
9579
|
+
if (coerceDataValueToString && unwrapDataValue2 && isRivetDataValue(value)) {
|
|
9580
|
+
return coerceTypeOptional(value, "string") ?? "";
|
|
9581
|
+
}
|
|
9582
|
+
return String((unwrapDataValue2 ? unwrapPotentialDataValue(value) : value) ?? "");
|
|
9583
|
+
} catch {
|
|
9584
|
+
return "[object Object]";
|
|
9585
|
+
}
|
|
9586
|
+
}
|
|
9587
|
+
function findTopLevelProcessorSeparator(rawInner) {
|
|
9588
|
+
let quote;
|
|
9589
|
+
let regex = false;
|
|
9590
|
+
let regexCharacterClass = false;
|
|
9591
|
+
let bracketDepth = 0;
|
|
9592
|
+
let parenthesisDepth = 0;
|
|
9593
|
+
let braceDepth = 0;
|
|
9594
|
+
for (let cursor = 0; cursor < rawInner.length; cursor++) {
|
|
9595
|
+
const character = rawInner[cursor];
|
|
9596
|
+
if (regex) {
|
|
9597
|
+
if (character === "[" && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9598
|
+
regexCharacterClass = true;
|
|
9599
|
+
} else if (character === "]" && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9600
|
+
regexCharacterClass = false;
|
|
9601
|
+
} else if (character === "/" && !regexCharacterClass && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9602
|
+
regex = false;
|
|
9603
|
+
}
|
|
9604
|
+
continue;
|
|
9605
|
+
}
|
|
9606
|
+
if (quote) {
|
|
9607
|
+
if (character === quote && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9608
|
+
quote = void 0;
|
|
9609
|
+
}
|
|
9610
|
+
continue;
|
|
9611
|
+
}
|
|
9612
|
+
if (character === "/" && isInterpolationRegexLiteralStart(rawInner, cursor)) {
|
|
9613
|
+
regex = true;
|
|
9614
|
+
regexCharacterClass = false;
|
|
9615
|
+
continue;
|
|
9616
|
+
}
|
|
9617
|
+
if (character === '"' || character === "'" || character === "`") {
|
|
9618
|
+
quote = character;
|
|
9619
|
+
continue;
|
|
9620
|
+
}
|
|
9621
|
+
if (character === "[") {
|
|
9622
|
+
bracketDepth += 1;
|
|
9623
|
+
continue;
|
|
9624
|
+
}
|
|
9625
|
+
if (character === "]" && bracketDepth > 0) {
|
|
9626
|
+
bracketDepth -= 1;
|
|
9627
|
+
continue;
|
|
9628
|
+
}
|
|
9629
|
+
if (character === "(") {
|
|
9630
|
+
parenthesisDepth += 1;
|
|
9631
|
+
continue;
|
|
9632
|
+
}
|
|
9633
|
+
if (character === ")" && parenthesisDepth > 0) {
|
|
9634
|
+
parenthesisDepth -= 1;
|
|
9635
|
+
continue;
|
|
9636
|
+
}
|
|
9637
|
+
if (character === "{") {
|
|
9638
|
+
braceDepth += 1;
|
|
9639
|
+
continue;
|
|
9640
|
+
}
|
|
9641
|
+
if (character === "}" && braceDepth > 0) {
|
|
9642
|
+
braceDepth -= 1;
|
|
9643
|
+
continue;
|
|
9644
|
+
}
|
|
9645
|
+
if (character === "|" && bracketDepth === 0 && parenthesisDepth === 0 && braceDepth === 0) {
|
|
9646
|
+
return cursor;
|
|
9647
|
+
}
|
|
9648
|
+
}
|
|
9649
|
+
return void 0;
|
|
9650
|
+
}
|
|
9651
|
+
function findQuotedStringEnd(value, start) {
|
|
9652
|
+
const quote = value[start];
|
|
9653
|
+
for (let cursor = start + 1; cursor < value.length; cursor++) {
|
|
9654
|
+
if (value[cursor] === quote && !isInterpolationSyntaxCharacterEscaped(value, cursor)) {
|
|
9655
|
+
return cursor;
|
|
9656
|
+
}
|
|
9657
|
+
}
|
|
9658
|
+
return void 0;
|
|
9659
|
+
}
|
|
9660
|
+
function parseQuotedBaseReference(expression) {
|
|
9661
|
+
if (expression[0] !== "[") {
|
|
9662
|
+
return void 0;
|
|
9663
|
+
}
|
|
9664
|
+
let cursor = 1;
|
|
9665
|
+
while (expression[cursor] === " ") {
|
|
9666
|
+
cursor += 1;
|
|
9667
|
+
}
|
|
9668
|
+
const quote = expression[cursor];
|
|
9669
|
+
if (quote !== '"' && quote !== "'") {
|
|
9670
|
+
return void 0;
|
|
9671
|
+
}
|
|
9672
|
+
const quoteEnd = findQuotedStringEnd(expression, cursor);
|
|
9673
|
+
if (quoteEnd === void 0) {
|
|
9674
|
+
return void 0;
|
|
9675
|
+
}
|
|
9676
|
+
const baseName = expression.slice(cursor + 1, quoteEnd);
|
|
9677
|
+
if (!baseName) {
|
|
9678
|
+
return void 0;
|
|
9679
|
+
}
|
|
9680
|
+
cursor = quoteEnd + 1;
|
|
9681
|
+
while (expression[cursor] === " ") {
|
|
9682
|
+
cursor += 1;
|
|
9683
|
+
}
|
|
9684
|
+
if (expression[cursor] !== "]") {
|
|
9685
|
+
return void 0;
|
|
9686
|
+
}
|
|
9687
|
+
const suffix = expression.slice(cursor + 1).trimStart();
|
|
9688
|
+
if (suffix !== "" && !suffix.startsWith(".") && !suffix.startsWith("[")) {
|
|
9689
|
+
return void 0;
|
|
9690
|
+
}
|
|
9691
|
+
return { baseName, suffix: suffix || void 0 };
|
|
9692
|
+
}
|
|
9693
|
+
function parseBaseReference(expression, source) {
|
|
9694
|
+
const trimmedExpression = expression.trim();
|
|
9695
|
+
if (!trimmedExpression) {
|
|
9696
|
+
return void 0;
|
|
9697
|
+
}
|
|
9698
|
+
const quotedReference = parseQuotedBaseReference(trimmedExpression);
|
|
9699
|
+
if (quotedReference) {
|
|
9700
|
+
return {
|
|
9701
|
+
source,
|
|
9702
|
+
baseName: quotedReference.baseName,
|
|
9703
|
+
jsonPath: quotedReference.suffix ? normalizeJsonPathExpression(`$${quotedReference.suffix}`) : void 0
|
|
9704
|
+
};
|
|
9705
|
+
}
|
|
9706
|
+
let suffixStart = -1;
|
|
9707
|
+
for (let cursor = 0; cursor < trimmedExpression.length; cursor++) {
|
|
9708
|
+
const character = trimmedExpression[cursor];
|
|
9709
|
+
if (character === "." || character === "[") {
|
|
9710
|
+
suffixStart = cursor;
|
|
9711
|
+
break;
|
|
9712
|
+
}
|
|
9713
|
+
}
|
|
9714
|
+
if (suffixStart === -1) {
|
|
9715
|
+
return {
|
|
9716
|
+
source,
|
|
9717
|
+
baseName: trimmedExpression,
|
|
9718
|
+
jsonPath: void 0
|
|
9719
|
+
};
|
|
9720
|
+
}
|
|
9721
|
+
const baseName = trimmedExpression.slice(0, suffixStart).trim();
|
|
9722
|
+
const suffix = normalizeJsonPathExpression(trimmedExpression.slice(suffixStart));
|
|
9723
|
+
if (!baseName || !suffix.startsWith(".") && !suffix.startsWith("[")) {
|
|
9724
|
+
return void 0;
|
|
9725
|
+
}
|
|
9726
|
+
return {
|
|
9727
|
+
source,
|
|
9728
|
+
baseName,
|
|
9729
|
+
jsonPath: `$${suffix}`
|
|
9730
|
+
};
|
|
9731
|
+
}
|
|
9732
|
+
function parseInterpolationExpressionUncached(trimmedExpression) {
|
|
9733
|
+
for (const [prefix, source] of [
|
|
9734
|
+
["@graphInputs", "graphInputs"],
|
|
9735
|
+
["@context", "context"]
|
|
9736
|
+
]) {
|
|
9737
|
+
if (trimmedExpression.startsWith(`${prefix}.`)) {
|
|
9738
|
+
return parseBaseReference(trimmedExpression.slice(prefix.length + 1), source);
|
|
9739
|
+
}
|
|
9740
|
+
if (trimmedExpression.startsWith(`${prefix}[`)) {
|
|
9741
|
+
return parseBaseReference(trimmedExpression.slice(prefix.length), source);
|
|
9742
|
+
}
|
|
9743
|
+
}
|
|
9744
|
+
return parseBaseReference(trimmedExpression, "variable");
|
|
9745
|
+
}
|
|
9746
|
+
function getCachedInterpolationExpression(expression) {
|
|
9747
|
+
const trimmedExpression = expression.trim();
|
|
9748
|
+
if (interpolationExpressionCache.has(trimmedExpression)) {
|
|
9749
|
+
return interpolationExpressionCache.get(trimmedExpression);
|
|
9750
|
+
}
|
|
9751
|
+
const parsed = parseInterpolationExpressionUncached(trimmedExpression);
|
|
9752
|
+
if (trimmedExpression.length > INTERPOLATION_EXPRESSION_CACHE_MAX_EXPRESSION_LENGTH) {
|
|
9753
|
+
return parsed;
|
|
9754
|
+
}
|
|
9755
|
+
if (interpolationExpressionCache.size >= INTERPOLATION_EXPRESSION_CACHE_MAX_ENTRIES || cachedInterpolationExpressionChars + trimmedExpression.length > INTERPOLATION_EXPRESSION_CACHE_MAX_CHARS) {
|
|
9756
|
+
interpolationExpressionCache.clear();
|
|
9757
|
+
cachedInterpolationExpressionChars = 0;
|
|
9758
|
+
}
|
|
9759
|
+
const immutableParsed = parsed ? Object.freeze({ ...parsed }) : void 0;
|
|
9760
|
+
interpolationExpressionCache.set(trimmedExpression, immutableParsed);
|
|
9761
|
+
cachedInterpolationExpressionChars += trimmedExpression.length;
|
|
9762
|
+
return immutableParsed;
|
|
9763
|
+
}
|
|
9764
|
+
function parseInterpolationExpression(expression) {
|
|
9765
|
+
const parsed = getCachedInterpolationExpression(expression);
|
|
9766
|
+
return parsed ? { ...parsed } : void 0;
|
|
9767
|
+
}
|
|
9768
|
+
function parseInterpolationToken(rawInner) {
|
|
9769
|
+
const processorSeparator = findTopLevelProcessorSeparator(rawInner);
|
|
9770
|
+
const tokenName = (processorSeparator === void 0 ? rawInner : rawInner.slice(0, processorSeparator)).trim() || void 0;
|
|
9771
|
+
const processingChain = processorSeparator === void 0 ? void 0 : rawInner.slice(processorSeparator + 1).trim() || void 0;
|
|
9772
|
+
return {
|
|
9773
|
+
rawInner,
|
|
9774
|
+
tokenName,
|
|
9775
|
+
processingChain,
|
|
9776
|
+
reference: tokenName ? parseInterpolationExpression(tokenName) : void 0
|
|
9777
|
+
};
|
|
9778
|
+
}
|
|
9779
|
+
function freezeReference(reference) {
|
|
9780
|
+
return reference ? Object.freeze({ ...reference }) : void 0;
|
|
9781
|
+
}
|
|
9782
|
+
function parseInterpolationTemplateUncached(template) {
|
|
9783
|
+
const tokens = scanInterpolationTokenSpans(template).map((span) => {
|
|
9784
|
+
const parsedToken = parseInterpolationToken(span.rawInner);
|
|
9785
|
+
return Object.freeze({
|
|
9786
|
+
...parsedToken,
|
|
9787
|
+
span: Object.freeze({ ...span }),
|
|
9788
|
+
reference: freezeReference(parsedToken.reference)
|
|
9789
|
+
});
|
|
9790
|
+
});
|
|
9791
|
+
return Object.freeze({
|
|
9792
|
+
template,
|
|
9793
|
+
tokens: Object.freeze(tokens)
|
|
9794
|
+
});
|
|
9795
|
+
}
|
|
9796
|
+
function getTemplateStorageChars(template, parsed) {
|
|
9797
|
+
return template.length + parsed.tokens.reduce(
|
|
9798
|
+
(total, token) => {
|
|
9799
|
+
var _a;
|
|
9800
|
+
return total + token.rawInner.length + (((_a = token.tokenName) == null ? void 0 : _a.length) ?? 0);
|
|
9801
|
+
},
|
|
9802
|
+
parsed.tokens.length * 48
|
|
9803
|
+
);
|
|
9804
|
+
}
|
|
9805
|
+
function cacheInterpolationTemplate(template, parsed) {
|
|
9806
|
+
if (template.length > INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_LENGTH) {
|
|
9807
|
+
return;
|
|
9808
|
+
}
|
|
9809
|
+
const storageChars = getTemplateStorageChars(template, parsed);
|
|
9810
|
+
const reachesCapacity = interpolationTemplateCache.size >= INTERPOLATION_TEMPLATE_CACHE_MAX_ENTRIES || cachedInterpolationTemplateChars + template.length > INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_CHARS || cachedInterpolationTemplateStorageChars + storageChars > INTERPOLATION_TEMPLATE_CACHE_MAX_STORAGE_CHARS;
|
|
9811
|
+
if (reachesCapacity) {
|
|
9812
|
+
if (lastUncachedInterpolationTemplate !== template) {
|
|
9813
|
+
lastUncachedInterpolationTemplate = template;
|
|
9814
|
+
return;
|
|
9815
|
+
}
|
|
9816
|
+
interpolationTemplateCache.clear();
|
|
9817
|
+
cachedInterpolationTemplateChars = 0;
|
|
9818
|
+
cachedInterpolationTemplateStorageChars = 0;
|
|
9819
|
+
}
|
|
9820
|
+
lastUncachedInterpolationTemplate = void 0;
|
|
9821
|
+
interpolationTemplateCache.set(template, {
|
|
9822
|
+
templateChars: template.length,
|
|
9823
|
+
storageChars,
|
|
9824
|
+
parsed
|
|
9825
|
+
});
|
|
9826
|
+
cachedInterpolationTemplateChars += template.length;
|
|
9827
|
+
cachedInterpolationTemplateStorageChars += storageChars;
|
|
9828
|
+
}
|
|
9829
|
+
function parseInterpolationTemplate(template) {
|
|
9830
|
+
const cached = interpolationTemplateCache.get(template);
|
|
9831
|
+
if (cached) {
|
|
9832
|
+
return cached.parsed;
|
|
9833
|
+
}
|
|
9834
|
+
const parsed = parseInterpolationTemplateUncached(template);
|
|
9835
|
+
if (template.includes("{{")) {
|
|
9836
|
+
cacheInterpolationTemplate(template, parsed);
|
|
9837
|
+
}
|
|
9838
|
+
return parsed;
|
|
9839
|
+
}
|
|
9840
|
+
function protectEscapedInterpolationTokens(template) {
|
|
9841
|
+
return template.replace(ESCAPED_TOKEN_REGEX, (_match, expression) => `\\{\\{${expression}\\}\\}`);
|
|
9842
|
+
}
|
|
9843
|
+
function restoreEscapedInterpolationTokens(template) {
|
|
9844
|
+
return template.replace(ESCAPED_ESCAPED_TOKEN_REGEX, (_match, expression) => `{{${expression}}}`).replace(ESCAPED_TOKEN_REGEX, (_match, expression) => `{{${expression}}}`);
|
|
9845
|
+
}
|
|
9846
|
+
function findInterpolationTokenSpans(template) {
|
|
9847
|
+
return parseInterpolationTemplate(template).tokens.map((token) => ({ ...token.span }));
|
|
9848
|
+
}
|
|
9849
|
+
function getInterpolationTokenName(rawInner) {
|
|
9850
|
+
return parseInterpolationToken(rawInner).tokenName;
|
|
9851
|
+
}
|
|
9852
|
+
function getInterpolationTokenReference(rawInner) {
|
|
9853
|
+
return parseInterpolationToken(rawInner).reference;
|
|
9854
|
+
}
|
|
9855
|
+
function replaceInterpolationTokens(template, getReplacement, options2 = {}) {
|
|
9856
|
+
const parsedTemplate = parseInterpolationTemplate(template);
|
|
9857
|
+
if (parsedTemplate.tokens.length === 0) {
|
|
9858
|
+
const restoredTemplate = restoreEscapedInterpolationTokens(template);
|
|
9859
|
+
return options2.trim ? restoredTemplate.trim() : restoredTemplate;
|
|
9860
|
+
}
|
|
9861
|
+
let result = "";
|
|
9862
|
+
let cursor = 0;
|
|
9863
|
+
for (const token of parsedTemplate.tokens) {
|
|
9864
|
+
result += restoreEscapedInterpolationTokens(template.slice(cursor, token.span.start));
|
|
9865
|
+
result += getReplacement({
|
|
9866
|
+
rawInner: token.rawInner,
|
|
9867
|
+
span: { ...token.span },
|
|
9868
|
+
tokenName: token.tokenName,
|
|
9869
|
+
processingChain: token.processingChain,
|
|
9870
|
+
reference: token.reference ? { ...token.reference } : void 0
|
|
9871
|
+
});
|
|
9872
|
+
cursor = token.span.end;
|
|
9873
|
+
}
|
|
9874
|
+
result += restoreEscapedInterpolationTokens(template.slice(cursor));
|
|
9875
|
+
return options2.trim ? result.trim() : result;
|
|
9876
|
+
}
|
|
9877
|
+
function extractInterpolationVariableReferences(template) {
|
|
9878
|
+
if (!template.includes("{{")) {
|
|
9879
|
+
return [];
|
|
9880
|
+
}
|
|
9881
|
+
const discovered = /* @__PURE__ */ new Map();
|
|
9882
|
+
for (const token of parseInterpolationTemplate(template).tokens) {
|
|
9883
|
+
const reference = token.reference;
|
|
9884
|
+
if (!reference || reference.source !== "variable") {
|
|
9885
|
+
continue;
|
|
9886
|
+
}
|
|
9887
|
+
const existing = discovered.get(reference.baseName);
|
|
9888
|
+
if (existing) {
|
|
9889
|
+
existing.hasPath ||= reference.jsonPath !== void 0;
|
|
9890
|
+
continue;
|
|
9891
|
+
}
|
|
9892
|
+
discovered.set(reference.baseName, {
|
|
9893
|
+
baseName: reference.baseName,
|
|
9894
|
+
hasPath: reference.jsonPath !== void 0
|
|
9895
|
+
});
|
|
9896
|
+
}
|
|
9897
|
+
return Array.from(discovered.values(), (reference) => ({ ...reference }));
|
|
9898
|
+
}
|
|
9899
|
+
function extractInterpolationVariables(template) {
|
|
9900
|
+
return extractInterpolationVariableReferences(template).map((reference) => reference.baseName);
|
|
9901
|
+
}
|
|
9902
|
+
function getInterpolationSource(reference, sources) {
|
|
9903
|
+
switch (reference.source) {
|
|
9904
|
+
case "variable":
|
|
9905
|
+
return sources.variables;
|
|
9906
|
+
case "graphInputs":
|
|
9907
|
+
return sources.graphInputValues;
|
|
9908
|
+
case "context":
|
|
9909
|
+
return sources.contextValues;
|
|
9910
|
+
}
|
|
9911
|
+
}
|
|
9912
|
+
function resolveInterpolationExpressionRawValue(expression, sources) {
|
|
9913
|
+
const reference = typeof expression === "string" ? getCachedInterpolationExpression(expression) : expression;
|
|
9914
|
+
if (!reference) {
|
|
9915
|
+
return void 0;
|
|
9916
|
+
}
|
|
9917
|
+
const source = getInterpolationSource(reference, sources);
|
|
9918
|
+
if (!source || !Object.prototype.hasOwnProperty.call(source, reference.baseName)) {
|
|
9919
|
+
return void 0;
|
|
9920
|
+
}
|
|
9921
|
+
const shouldUnwrapDataValue = reference.source !== "variable" || sources.unwrapVariableDataValues !== false;
|
|
9922
|
+
const baseValue = shouldUnwrapDataValue ? unwrapPotentialDataValue(source[reference.baseName]) : source[reference.baseName];
|
|
9923
|
+
if (reference.jsonPath === void 0) {
|
|
9924
|
+
return baseValue;
|
|
9925
|
+
}
|
|
9926
|
+
try {
|
|
9927
|
+
return evaluateJsonPath(baseValue, reference.jsonPath, false);
|
|
9928
|
+
} catch {
|
|
9929
|
+
return void 0;
|
|
9930
|
+
}
|
|
9931
|
+
}
|
|
9932
|
+
function resolveInterpolationTokenRawValue(rawInner, sources) {
|
|
9933
|
+
const reference = parseInterpolationToken(rawInner).reference;
|
|
9934
|
+
return reference ? resolveInterpolationExpressionRawValue(reference, sources) : void 0;
|
|
9935
|
+
}
|
|
9936
|
+
function stringifyInterpolationValue(value) {
|
|
9937
|
+
if (typeof value === "object" && value !== null) {
|
|
9938
|
+
try {
|
|
9939
|
+
return JSON.stringify(value);
|
|
9940
|
+
} catch (error) {
|
|
9941
|
+
console.warn("Error stringifying an interpolation value:", error);
|
|
9942
|
+
return "[object Object]";
|
|
9943
|
+
}
|
|
9944
|
+
}
|
|
9945
|
+
return String(value);
|
|
9946
|
+
}
|
|
9947
|
+
function parseProcessing(instruction) {
|
|
9948
|
+
const parts = instruction.trim().split(/\s+/);
|
|
9949
|
+
return {
|
|
9950
|
+
func: parts[0],
|
|
9951
|
+
param: parts[1] ? Number.parseInt(parts[1], 10) : void 0
|
|
9952
|
+
};
|
|
9953
|
+
}
|
|
9954
|
+
function applyProcessing(value, processingChain) {
|
|
9955
|
+
const instructions = processingChain.split("|").map((instruction) => instruction.trim()).filter((instruction) => instruction !== "");
|
|
9956
|
+
return instructions.reduce((result, instruction) => {
|
|
9957
|
+
const { func, param } = parseProcessing(instruction);
|
|
9958
|
+
const processingFunc = processingFunctions[func];
|
|
9959
|
+
if (!processingFunc) {
|
|
9960
|
+
console.warn(`Unknown processing function: ${func}`);
|
|
9961
|
+
return result;
|
|
9962
|
+
}
|
|
9963
|
+
return processingFunc(result, param);
|
|
9964
|
+
}, value);
|
|
9965
|
+
}
|
|
9966
|
+
function interpolate(template, variables, graphInputValues, contextValues, options2 = {}) {
|
|
9967
|
+
return replaceInterpolationTokens(template, (token) => {
|
|
9968
|
+
if (!token.reference) {
|
|
9969
|
+
return "";
|
|
9970
|
+
}
|
|
9971
|
+
const resolvedValue = resolveInterpolationExpressionRawValue(token.reference, {
|
|
9972
|
+
variables,
|
|
9973
|
+
graphInputValues,
|
|
9974
|
+
contextValues,
|
|
9975
|
+
unwrapVariableDataValues: options2.unwrapVariableDataValues
|
|
9976
|
+
});
|
|
9977
|
+
if (resolvedValue === void 0) {
|
|
9978
|
+
console.warn(`Interpolation variable or path "${token.tokenName}" not found or resolved to undefined.`);
|
|
9979
|
+
return "";
|
|
9980
|
+
}
|
|
9981
|
+
const isBareOrdinaryVariable = token.reference.source === "variable" && token.reference.jsonPath === void 0;
|
|
9982
|
+
const stringValue = isBareOrdinaryVariable ? stringifyInterpolationSourceValue(variables[token.reference.baseName], {
|
|
9983
|
+
coerceDataValueToString: options2.coerceBareVariableDataValues,
|
|
9984
|
+
unwrapDataValue: options2.unwrapVariableDataValues !== false
|
|
9985
|
+
}) : stringifyInterpolationValue(resolvedValue);
|
|
9986
|
+
return token.processingChain ? applyProcessing(stringValue, token.processingChain) : stringValue;
|
|
9987
|
+
});
|
|
9988
|
+
}
|
|
9989
|
+
function resolveCodeInterpolationExpression(inputs, expression, graphInputValues, contextValues) {
|
|
9990
|
+
return resolveInterpolationExpressionRawValue(expression, {
|
|
9991
|
+
variables: inputs,
|
|
9992
|
+
graphInputValues,
|
|
9993
|
+
contextValues
|
|
9994
|
+
});
|
|
9995
|
+
}
|
|
9996
|
+
|
|
9115
9997
|
// src/integrations/CodeRunnerOptions.ts
|
|
9116
9998
|
var ALL_CODE_RUNNER_OPTIONS = Object.freeze({
|
|
9117
9999
|
includeRequire: true,
|
|
@@ -9146,6 +10028,10 @@ var IsomorphicCodeRunner = class {
|
|
|
9146
10028
|
argNames.push("context");
|
|
9147
10029
|
args.push(contextValues);
|
|
9148
10030
|
}
|
|
10031
|
+
if (options2.interpolationHelperIdentifier) {
|
|
10032
|
+
argNames.push(options2.interpolationHelperIdentifier);
|
|
10033
|
+
args.push(resolveCodeInterpolationExpression);
|
|
10034
|
+
}
|
|
9149
10035
|
argNames.push(code);
|
|
9150
10036
|
const AsyncFunction = async function() {
|
|
9151
10037
|
}.constructor;
|
|
@@ -9347,6 +10233,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9347
10233
|
#graphExecutionPlan;
|
|
9348
10234
|
#nodeProcessContextBase = void 0;
|
|
9349
10235
|
#runToRelevantNodeIds;
|
|
10236
|
+
#graphOutputSelection;
|
|
9350
10237
|
#managedAsyncBranches;
|
|
9351
10238
|
#managedAsyncBranchFailures = [];
|
|
9352
10239
|
#runCompletionPromise;
|
|
@@ -9568,7 +10455,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9568
10455
|
const pending = this.#pendingUserInputs[nodeId];
|
|
9569
10456
|
if (pending) {
|
|
9570
10457
|
pending.resolve(values2);
|
|
9571
|
-
delete this.#pendingUserInputs[nodeId];
|
|
9572
10458
|
}
|
|
9573
10459
|
for (const processor of this.#subprocessors) {
|
|
9574
10460
|
processor.userInput(nodeId, values2);
|
|
@@ -9669,7 +10555,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9669
10555
|
}
|
|
9670
10556
|
this.#preloadedNodeResults.set(nodeId, data);
|
|
9671
10557
|
this.#hasPreloadedData = true;
|
|
9672
|
-
if (this.#lifecycle.isRunning) {
|
|
10558
|
+
if (this.#lifecycle.isRunning && this.#isNodeSelected(nodeId)) {
|
|
9673
10559
|
this.#nodeResults.set(nodeId, data);
|
|
9674
10560
|
this.#visitedNodes.add(nodeId);
|
|
9675
10561
|
}
|
|
@@ -9719,9 +10605,12 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9719
10605
|
}
|
|
9720
10606
|
}
|
|
9721
10607
|
async replayRecording(recorder) {
|
|
10608
|
+
if (this.#lifecycle.isRunning) {
|
|
10609
|
+
throw new Error("Cannot process graph while already processing");
|
|
10610
|
+
}
|
|
9722
10611
|
this.#initializeExecutionIdentity();
|
|
9723
10612
|
this.#initProcessState();
|
|
9724
|
-
|
|
10613
|
+
return await replayExecutionRecording({
|
|
9725
10614
|
emitter: this.#emitter,
|
|
9726
10615
|
erroredNodes: this.#erroredNodes,
|
|
9727
10616
|
graphInputs: this.#graphInputs,
|
|
@@ -9748,7 +10637,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9748
10637
|
visitedNodes: this.#visitedNodes,
|
|
9749
10638
|
waitUntilUnpaused: () => this.#waitUntilUnpaused()
|
|
9750
10639
|
});
|
|
9751
|
-
return this.#graphOutputs;
|
|
9752
10640
|
}
|
|
9753
10641
|
#initProcessState() {
|
|
9754
10642
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -9779,6 +10667,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9779
10667
|
this.#ignoreNodes = /* @__PURE__ */ new Set();
|
|
9780
10668
|
this.#nodeProcessContextBase = void 0;
|
|
9781
10669
|
this.#runToRelevantNodeIds = void 0;
|
|
10670
|
+
this.#graphOutputSelection = void 0;
|
|
9782
10671
|
if (!this.#isSubProcessor) {
|
|
9783
10672
|
this.#managedAsyncBranches = new ManagedAsyncBranches();
|
|
9784
10673
|
this.#managedAsyncBranchFailures = [];
|
|
@@ -9797,9 +10686,11 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9797
10686
|
}
|
|
9798
10687
|
/** Main function for running a graph. Runs a graph and returns the outputs from the output nodes of the graph. */
|
|
9799
10688
|
async processGraph(context, inputs = {}, contextValues = {}, options2 = {}) {
|
|
10689
|
+
var _a;
|
|
9800
10690
|
if (this.#lifecycle.isRunning) {
|
|
9801
10691
|
throw new Error("Cannot process graph while already processing");
|
|
9802
10692
|
}
|
|
10693
|
+
const requestedGraphOutputIds = (_a = options2.requestedGraphOutputIds) == null ? void 0 : _a.slice();
|
|
9803
10694
|
let resolveOutputsReady;
|
|
9804
10695
|
let rejectOutputsReady;
|
|
9805
10696
|
const outputsReadyPromise = options2.returnWhenGraphOutputsReady === true ? new Promise((resolve, reject) => {
|
|
@@ -9808,7 +10699,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9808
10699
|
}) : void 0;
|
|
9809
10700
|
let outputsWerePublishedEarly = false;
|
|
9810
10701
|
const completionPromise = (async () => {
|
|
9811
|
-
var
|
|
10702
|
+
var _a2;
|
|
9812
10703
|
try {
|
|
9813
10704
|
try {
|
|
9814
10705
|
this.#profileRuntimeSync(
|
|
@@ -9823,6 +10714,22 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9823
10714
|
this.#preprocessGraph();
|
|
9824
10715
|
}
|
|
9825
10716
|
this.#assertNoDataBusRunTargets();
|
|
10717
|
+
if (requestedGraphOutputIds !== void 0) {
|
|
10718
|
+
if (this.runToNodeIds !== void 0) {
|
|
10719
|
+
throw new Error("requestedGraphOutputIds cannot be combined with runToNodeIds");
|
|
10720
|
+
}
|
|
10721
|
+
this.#graphOutputSelection = createGraphOutputSelection(
|
|
10722
|
+
{ nodes: this.#executionGraphNodes, connections: this.#getEffectiveConnections() },
|
|
10723
|
+
requestedGraphOutputIds,
|
|
10724
|
+
(node) => getInputNodesTo(this.#executionState, node)
|
|
10725
|
+
);
|
|
10726
|
+
for (const nodeId of this.#nodeResults.keys()) {
|
|
10727
|
+
if (!this.#isNodeSelected(nodeId)) {
|
|
10728
|
+
this.#nodeResults.delete(nodeId);
|
|
10729
|
+
this.#visitedNodes.delete(nodeId);
|
|
10730
|
+
}
|
|
10731
|
+
}
|
|
10732
|
+
}
|
|
9826
10733
|
this.#prepareAsyncBranchTopology();
|
|
9827
10734
|
} catch (error) {
|
|
9828
10735
|
const normalizedError = getError(error);
|
|
@@ -9855,7 +10762,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9855
10762
|
return await this.#profileRuntimeAsync("finalizeGraphRun", () => this.#finalizeGraphRun());
|
|
9856
10763
|
} finally {
|
|
9857
10764
|
if (!this.#isSubProcessor) {
|
|
9858
|
-
await ((
|
|
10765
|
+
await ((_a2 = this.#managedAsyncBranches) == null ? void 0 : _a2.drain());
|
|
9859
10766
|
}
|
|
9860
10767
|
this.#lifecycle.complete();
|
|
9861
10768
|
this.#cleanupTokenizerErrorListener();
|
|
@@ -9914,6 +10821,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9914
10821
|
}
|
|
9915
10822
|
#prepareNodeProcessContextBase() {
|
|
9916
10823
|
const hostChatV2Observer = this.getRootProcessor().#context.onChatV2CallFinished;
|
|
10824
|
+
const hostLLMChatOutputSnapshotObserver = this.getRootProcessor().#context.onLLMChatOutputSnapshot;
|
|
9917
10825
|
const hostLLMProfileAttemptObserver = this.getRootProcessor().#context.onLLMProfileAttempt;
|
|
9918
10826
|
this.#nodeProcessContextBase = {
|
|
9919
10827
|
...this.#context,
|
|
@@ -9943,6 +10851,16 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9943
10851
|
const { rawUsage: _rawUsage, ...traceEvent } = event;
|
|
9944
10852
|
emitDetached(this.#emitter, "llmCallFinished", this.#withExecution(traceEvent));
|
|
9945
10853
|
},
|
|
10854
|
+
onLLMChatOutputSnapshot: (event) => {
|
|
10855
|
+
try {
|
|
10856
|
+
const observerResult = hostLLMChatOutputSnapshotObserver == null ? void 0 : hostLLMChatOutputSnapshotObserver(event);
|
|
10857
|
+
if (observerResult != null && typeof observerResult.then === "function") {
|
|
10858
|
+
void Promise.resolve(observerResult).catch(() => void 0);
|
|
10859
|
+
}
|
|
10860
|
+
} catch {
|
|
10861
|
+
}
|
|
10862
|
+
emitDetached(this.#emitter, "llmChatOutputSnapshot", this.#withExecution(event));
|
|
10863
|
+
},
|
|
9946
10864
|
onLLMProfileAttempt: (event) => {
|
|
9947
10865
|
try {
|
|
9948
10866
|
const observerResult = hostLLMProfileAttemptObserver == null ? void 0 : hostLLMProfileAttemptObserver(event);
|
|
@@ -9966,12 +10884,31 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9966
10884
|
this.#emitTraceEvent(message);
|
|
9967
10885
|
},
|
|
9968
10886
|
setStoredValue: (key, value) => this.#storedValueController.set(key, value),
|
|
9969
|
-
waitForGlobal: async (id) => {
|
|
10887
|
+
waitForGlobal: async (id, signal = this.#abortController.signal) => {
|
|
10888
|
+
if (signal.aborted) {
|
|
10889
|
+
throw createGraphAbortErrorFromSignal(signal);
|
|
10890
|
+
}
|
|
9970
10891
|
if (this.#globals.has(id)) {
|
|
9971
10892
|
return this.#globals.get(id);
|
|
9972
10893
|
}
|
|
9973
|
-
await
|
|
9974
|
-
|
|
10894
|
+
return await new Promise((resolve, reject) => {
|
|
10895
|
+
const abortListener = () => {
|
|
10896
|
+
cleanup();
|
|
10897
|
+
reject(createGraphAbortErrorFromSignal(signal));
|
|
10898
|
+
};
|
|
10899
|
+
const unsubscribe = this.getRootProcessor().#emitter.on(`globalSet:${id}`, () => {
|
|
10900
|
+
cleanup();
|
|
10901
|
+
resolve(this.#globals.get(id));
|
|
10902
|
+
});
|
|
10903
|
+
const cleanup = () => {
|
|
10904
|
+
unsubscribe();
|
|
10905
|
+
signal.removeEventListener("abort", abortListener);
|
|
10906
|
+
};
|
|
10907
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
10908
|
+
if (signal.aborted) {
|
|
10909
|
+
abortListener();
|
|
10910
|
+
}
|
|
10911
|
+
});
|
|
9975
10912
|
},
|
|
9976
10913
|
waitForStoredValue: (key, signal) => this.#storedValueController.waitForSet(key, signal)
|
|
9977
10914
|
};
|
|
@@ -10007,7 +10944,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10007
10944
|
return;
|
|
10008
10945
|
}
|
|
10009
10946
|
for (const node of this.#executionGraphNodes) {
|
|
10010
|
-
if (!this.#nodeResults.has(node.id)) {
|
|
10947
|
+
if (!this.#isNodeSelected(node.id) || !this.#nodeResults.has(node.id)) {
|
|
10011
10948
|
continue;
|
|
10012
10949
|
}
|
|
10013
10950
|
if (this.#suppressedPreloadedNodeIds.has(node.id)) {
|
|
@@ -10042,7 +10979,10 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10042
10979
|
}
|
|
10043
10980
|
}
|
|
10044
10981
|
async #processCompatibleGraph() {
|
|
10045
|
-
|
|
10982
|
+
var _a;
|
|
10983
|
+
await this.#queueStartNodes(
|
|
10984
|
+
((_a = this.#graphOutputSelection) == null ? void 0 : _a.startNodes) ?? getStartNodes(this.#executionState, this.#executionGraphNodes, this.runToNodeIds)
|
|
10985
|
+
);
|
|
10046
10986
|
await this.#processingQueue.onIdle();
|
|
10047
10987
|
this.#markUnqueuedNodesIgnored();
|
|
10048
10988
|
}
|
|
@@ -10050,7 +10990,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10050
10990
|
if (this.#scheduler !== "fast-acyclic") {
|
|
10051
10991
|
return false;
|
|
10052
10992
|
}
|
|
10053
|
-
if (this.#hasPreloadedData || this.runToNodeIds || this.slowMode || this.#includeTrace) {
|
|
10993
|
+
if (this.#graphOutputSelection || this.#hasPreloadedData || this.runToNodeIds || this.slowMode || this.#includeTrace) {
|
|
10054
10994
|
return false;
|
|
10055
10995
|
}
|
|
10056
10996
|
if (this.#nodesNotInCycle.length !== this.#executionGraphNodes.length) {
|
|
@@ -10265,6 +11205,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10265
11205
|
}
|
|
10266
11206
|
async #fetchNodeDataAndProcessNode(node) {
|
|
10267
11207
|
var _a;
|
|
11208
|
+
if (!this.#isNodeSelected(node.id)) return;
|
|
10268
11209
|
const profileStart = this.#startRuntimeProfile();
|
|
10269
11210
|
try {
|
|
10270
11211
|
if (this.#currentlyProcessing.has(node.id)) {
|
|
@@ -10317,6 +11258,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10317
11258
|
}
|
|
10318
11259
|
/** If all inputs are present, all conditions met, processes the node. */
|
|
10319
11260
|
async #processNodeIfAllInputsAvailable(node, options2 = {}) {
|
|
11261
|
+
if (!this.#isNodeSelected(node.id)) return [];
|
|
10320
11262
|
const { queueOutputNodes = true } = options2;
|
|
10321
11263
|
const builtInNode = node;
|
|
10322
11264
|
const inputNodesProfileStart = this.#startRuntimeProfile();
|
|
@@ -10560,8 +11502,9 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10560
11502
|
}
|
|
10561
11503
|
}
|
|
10562
11504
|
#queueOutputNodes(node, outputNodes) {
|
|
11505
|
+
const selectedOutputs = this.#graphOutputSelection ? outputNodes.filter((outputNode) => this.#isNodeSelected(outputNode.id)) : outputNodes;
|
|
10563
11506
|
void this.#processingQueue.addAll(
|
|
10564
|
-
|
|
11507
|
+
selectedOutputs.map((outputNode) => async () => {
|
|
10565
11508
|
this.#emitTraceEvent(`Trying to run output node from ${node.title}: ${outputNode.title} (${outputNode.id})`);
|
|
10566
11509
|
await this.#processNodeIfAllInputsAvailable(outputNode);
|
|
10567
11510
|
})
|
|
@@ -11006,6 +11949,9 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11006
11949
|
}
|
|
11007
11950
|
}
|
|
11008
11951
|
async #processNodeWithInputData(node, inputValues, index, processId, partialOutput, markResultAsEditorCacheHit) {
|
|
11952
|
+
if (this.#shouldSkipCompletedRaceNode(node, this.#getAttachedDataTo(node))) {
|
|
11953
|
+
throw createGraphAbortError(createGraphAbortReason(true, RACE_LOSER_EXCLUSION_REASON));
|
|
11954
|
+
}
|
|
11009
11955
|
const instance = this.#nodeInstances[node.id];
|
|
11010
11956
|
const nodeAbortController = this.#newAbortController();
|
|
11011
11957
|
this.#registerNodeAbortController(node.id, nodeAbortController);
|
|
@@ -11031,6 +11977,9 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11031
11977
|
this.#finishRuntimeProfile("createNodeProcessContext", createContextProfileStart);
|
|
11032
11978
|
}
|
|
11033
11979
|
await this.#waitUntilUnpaused();
|
|
11980
|
+
if (nodeAbortController.signal.aborted) {
|
|
11981
|
+
throw createGraphAbortErrorFromSignal(nodeAbortController.signal);
|
|
11982
|
+
}
|
|
11034
11983
|
const implementationProfileStart = this.#startRuntimeProfile();
|
|
11035
11984
|
let results;
|
|
11036
11985
|
try {
|
|
@@ -11086,13 +12035,14 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11086
12035
|
this.#emitGraphPartialOutputIfNeeded(node, partialOutputs);
|
|
11087
12036
|
},
|
|
11088
12037
|
processId,
|
|
11089
|
-
requestUserInput: async (inputStrings, renderingType) => this.#requestUserInput(node, inputStrings, inputValues, renderingType, processId),
|
|
12038
|
+
requestUserInput: async (inputStrings, renderingType) => this.#requestUserInput(node, inputStrings, inputValues, renderingType, processId, nodeAbortController.signal),
|
|
11090
12039
|
reportProgress: (progress) => {
|
|
11091
12040
|
const normalized = normalizeGraphProgress(progress);
|
|
11092
12041
|
if (normalized) {
|
|
11093
12042
|
emitDetached(this.#emitter, "progress", this.#withExecution({ node, processId, progress: normalized }));
|
|
11094
12043
|
}
|
|
11095
12044
|
},
|
|
12045
|
+
splitIndex: node.isSplitRun ? index : 0,
|
|
11096
12046
|
setGlobal: (id, value) => {
|
|
11097
12047
|
this.#globals.set(id, value);
|
|
11098
12048
|
emitDetached(this.#emitter, "globalSet", this.#withExecution({ id, value, processId }));
|
|
@@ -11100,14 +12050,27 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11100
12050
|
toolCallContinuation,
|
|
11101
12051
|
toolCallTraceSource,
|
|
11102
12052
|
waitEvent: async (event) => {
|
|
12053
|
+
const signal = nodeAbortController.signal;
|
|
12054
|
+
if (signal.aborted) {
|
|
12055
|
+
throw createGraphAbortErrorFromSignal(signal, "Process aborted");
|
|
12056
|
+
}
|
|
11103
12057
|
return new Promise((resolve, reject) => {
|
|
11104
12058
|
const abortListener = () => {
|
|
11105
|
-
|
|
12059
|
+
cleanup();
|
|
12060
|
+
reject(createGraphAbortErrorFromSignal(signal, "Process aborted"));
|
|
11106
12061
|
};
|
|
11107
|
-
this.#emitter.
|
|
11108
|
-
|
|
12062
|
+
const unsubscribe = this.#emitter.on(`userEvent:${event}`, (data) => {
|
|
12063
|
+
cleanup();
|
|
12064
|
+
resolve(data);
|
|
11109
12065
|
});
|
|
11110
|
-
|
|
12066
|
+
const cleanup = () => {
|
|
12067
|
+
unsubscribe();
|
|
12068
|
+
signal.removeEventListener("abort", abortListener);
|
|
12069
|
+
};
|
|
12070
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
12071
|
+
if (signal.aborted) {
|
|
12072
|
+
abortListener();
|
|
12073
|
+
}
|
|
11111
12074
|
});
|
|
11112
12075
|
}
|
|
11113
12076
|
});
|
|
@@ -11412,7 +12375,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11412
12375
|
state: {
|
|
11413
12376
|
erroredNodeIds: new Set(this.#erroredNodes.keys()),
|
|
11414
12377
|
nodeOutputs: this.#nodeResults,
|
|
11415
|
-
runToRelevantNodeIds: this.#
|
|
12378
|
+
runToRelevantNodeIds: this.#getExecutionRelevantNodeIds(),
|
|
11416
12379
|
visitedNodeIds: this.#visitedNodes
|
|
11417
12380
|
}
|
|
11418
12381
|
});
|
|
@@ -11474,8 +12437,8 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11474
12437
|
);
|
|
11475
12438
|
const outgoingByNodeId = /* @__PURE__ */ new Map();
|
|
11476
12439
|
const incomingByNodeId = /* @__PURE__ */ new Map();
|
|
11477
|
-
const
|
|
11478
|
-
const
|
|
12440
|
+
const relevantNodeIds = this.#getExecutionRelevantNodeIds();
|
|
12441
|
+
const isRelevant = (nodeId) => !relevantNodeIds || relevantNodeIds.has(nodeId);
|
|
11479
12442
|
for (const connection of connections) {
|
|
11480
12443
|
const outgoing = outgoingByNodeId.get(connection.outputNodeId) ?? [];
|
|
11481
12444
|
outgoing.push(connection);
|
|
@@ -11485,7 +12448,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11485
12448
|
incomingByNodeId.set(connection.inputNodeId, incoming);
|
|
11486
12449
|
}
|
|
11487
12450
|
for (const triggerNode of Object.values(this.#nodesById)) {
|
|
11488
|
-
if (triggerNode.type !== "startBackgroundBranch" || triggerNode.disabled || !
|
|
12451
|
+
if (triggerNode.type !== "startBackgroundBranch" || triggerNode.disabled || !isRelevant(triggerNode.id)) {
|
|
11489
12452
|
continue;
|
|
11490
12453
|
}
|
|
11491
12454
|
if (triggerNode.id !== this.#consumedAsyncBranchTriggerNodeId && this.#nodeResults.has(triggerNode.id)) {
|
|
@@ -11494,7 +12457,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11494
12457
|
);
|
|
11495
12458
|
}
|
|
11496
12459
|
const nodeIds = /* @__PURE__ */ new Set();
|
|
11497
|
-
const pendingNodeIds = (outgoingByNodeId.get(triggerNode.id) ?? []).map((connection) => connection.inputNodeId).filter(
|
|
12460
|
+
const pendingNodeIds = (outgoingByNodeId.get(triggerNode.id) ?? []).map((connection) => connection.inputNodeId).filter(isRelevant);
|
|
11498
12461
|
while (pendingNodeIds.length > 0) {
|
|
11499
12462
|
const nodeId = pendingNodeIds.pop();
|
|
11500
12463
|
if (nodeId === triggerNode.id) {
|
|
@@ -11519,7 +12482,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11519
12482
|
}
|
|
11520
12483
|
nodeIds.add(nodeId);
|
|
11521
12484
|
for (const connection of outgoingByNodeId.get(nodeId) ?? []) {
|
|
11522
|
-
if (
|
|
12485
|
+
if (isRelevant(connection.inputNodeId)) {
|
|
11523
12486
|
pendingNodeIds.push(connection.inputNodeId);
|
|
11524
12487
|
}
|
|
11525
12488
|
}
|
|
@@ -11620,17 +12583,19 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11620
12583
|
if (outputConnections.length === 0) {
|
|
11621
12584
|
return /* @__PURE__ */ new Set();
|
|
11622
12585
|
}
|
|
11623
|
-
const
|
|
12586
|
+
const relevantNodeIds = this.#getExecutionRelevantNodeIds();
|
|
11624
12587
|
const activeOutputPortIds = /* @__PURE__ */ new Set();
|
|
11625
12588
|
for (const { node: outputNode, connections } of outputConnections) {
|
|
11626
12589
|
if (outputNode.disabled) {
|
|
11627
12590
|
continue;
|
|
11628
12591
|
}
|
|
11629
|
-
if (
|
|
12592
|
+
if (relevantNodeIds && !relevantNodeIds.has(outputNode.id)) {
|
|
11630
12593
|
continue;
|
|
11631
12594
|
}
|
|
11632
12595
|
for (const connection of connections) {
|
|
11633
|
-
|
|
12596
|
+
if (this.#isDefinitionValidConnection(connection)) {
|
|
12597
|
+
activeOutputPortIds.add(connection.outputId);
|
|
12598
|
+
}
|
|
11634
12599
|
}
|
|
11635
12600
|
}
|
|
11636
12601
|
return activeOutputPortIds;
|
|
@@ -11648,6 +12613,16 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11648
12613
|
}
|
|
11649
12614
|
}
|
|
11650
12615
|
}
|
|
12616
|
+
#isNodeSelected(nodeId) {
|
|
12617
|
+
return !this.#graphOutputSelection || this.#graphOutputSelection.nodeIds.has(nodeId);
|
|
12618
|
+
}
|
|
12619
|
+
#getExecutionRelevantNodeIds() {
|
|
12620
|
+
var _a;
|
|
12621
|
+
if (this.#sameGraphRunOwnerOverride) {
|
|
12622
|
+
return this.#sameGraphRunOwnerOverride.#getExecutionRelevantNodeIds();
|
|
12623
|
+
}
|
|
12624
|
+
return ((_a = this.#graphOutputSelection) == null ? void 0 : _a.nodeIds) ?? this.#getRunToRelevantNodeIds();
|
|
12625
|
+
}
|
|
11651
12626
|
#getRunToRelevantNodeIds() {
|
|
11652
12627
|
if (!this.runToNodeIds) {
|
|
11653
12628
|
return void 0;
|
|
@@ -11765,17 +12740,37 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11765
12740
|
}
|
|
11766
12741
|
return processor;
|
|
11767
12742
|
}
|
|
11768
|
-
async #requestUserInput(node, inputStrings, inputValues, renderingType, processId) {
|
|
12743
|
+
async #requestUserInput(node, inputStrings, inputValues, renderingType, processId, signal) {
|
|
12744
|
+
if (signal.aborted) {
|
|
12745
|
+
throw createGraphAbortErrorFromSignal(signal);
|
|
12746
|
+
}
|
|
11769
12747
|
return await new Promise((resolve, reject) => {
|
|
12748
|
+
let settled = false;
|
|
12749
|
+
const cleanup = () => {
|
|
12750
|
+
signal.removeEventListener("abort", abortListener);
|
|
12751
|
+
if (this.#pendingUserInputs[node.id] === pending) {
|
|
12752
|
+
delete this.#pendingUserInputs[node.id];
|
|
12753
|
+
}
|
|
12754
|
+
};
|
|
11770
12755
|
const abortListener = () => {
|
|
11771
|
-
|
|
11772
|
-
|
|
12756
|
+
if (settled) return;
|
|
12757
|
+
settled = true;
|
|
12758
|
+
cleanup();
|
|
12759
|
+
reject(createGraphAbortErrorFromSignal(signal));
|
|
11773
12760
|
};
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
12761
|
+
const respond = (results) => {
|
|
12762
|
+
if (settled) return;
|
|
12763
|
+
settled = true;
|
|
12764
|
+
cleanup();
|
|
12765
|
+
resolve(results);
|
|
11777
12766
|
};
|
|
11778
|
-
|
|
12767
|
+
const pending = { resolve: respond };
|
|
12768
|
+
this.#pendingUserInputs[node.id] = pending;
|
|
12769
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
12770
|
+
if (signal.aborted) {
|
|
12771
|
+
abortListener();
|
|
12772
|
+
return;
|
|
12773
|
+
}
|
|
11779
12774
|
emitDetached(
|
|
11780
12775
|
this.#emitter,
|
|
11781
12776
|
"userInput",
|
|
@@ -11784,11 +12779,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11784
12779
|
inputStrings,
|
|
11785
12780
|
inputs: inputValues,
|
|
11786
12781
|
renderingType,
|
|
11787
|
-
callback:
|
|
11788
|
-
this.#abortController.signal.removeEventListener("abort", abortListener);
|
|
11789
|
-
resolve(results);
|
|
11790
|
-
delete this.#pendingUserInputs[node.id];
|
|
11791
|
-
},
|
|
12782
|
+
callback: respond,
|
|
11792
12783
|
processId
|
|
11793
12784
|
})
|
|
11794
12785
|
);
|
|
@@ -13175,10 +14166,17 @@ function mergeAgentTraceEvent(existing, incoming) {
|
|
|
13175
14166
|
if (existing.type === "llm-call-finished" && incoming.type === "llm-call-finished") {
|
|
13176
14167
|
return {
|
|
13177
14168
|
...incoming,
|
|
14169
|
+
...incoming.profileName == null && existing.profileName != null ? { profileName: existing.profileName } : {},
|
|
13178
14170
|
...incoming.profileHealthKey == null && existing.profileHealthKey != null ? { profileHealthKey: existing.profileHealthKey } : {},
|
|
13179
14171
|
...incoming.profileHealthState == null && existing.profileHealthState != null ? { profileHealthState: existing.profileHealthState } : {}
|
|
13180
14172
|
};
|
|
13181
14173
|
}
|
|
14174
|
+
if (existing.type === "llm-profile-attempt" && incoming.type === "llm-profile-attempt") {
|
|
14175
|
+
return {
|
|
14176
|
+
...incoming,
|
|
14177
|
+
...incoming.profileName == null && existing.profileName != null ? { profileName: existing.profileName } : {}
|
|
14178
|
+
};
|
|
14179
|
+
}
|
|
13182
14180
|
if (existing.type === "tool-call-finished" && incoming.type === "tool-call-finished" && existing.resultOwner != null && incoming.resultOwner == null && isAgentToolResultOutcome(incoming.outcome)) {
|
|
13183
14181
|
return { ...incoming, resultOwner: existing.resultOwner };
|
|
13184
14182
|
}
|
|
@@ -13195,6 +14193,7 @@ function toModelCallTrace(event) {
|
|
|
13195
14193
|
outcome: event.outcome,
|
|
13196
14194
|
attemptIndex: event.attemptIndex,
|
|
13197
14195
|
...event.profileIndex == null ? {} : { profileIndex: event.profileIndex },
|
|
14196
|
+
...event.profileName == null ? {} : { profileName: event.profileName },
|
|
13198
14197
|
...event.profileHealthKey == null ? {} : { profileHealthKey: event.profileHealthKey },
|
|
13199
14198
|
...event.profileHealthState == null ? {} : { profileHealthState: event.profileHealthState },
|
|
13200
14199
|
...event.roundIndex == null ? {} : { roundIndex: event.roundIndex },
|
|
@@ -13392,6 +14391,7 @@ function isAgentModelCallTrace(value) {
|
|
|
13392
14391
|
"outcome",
|
|
13393
14392
|
"attemptIndex",
|
|
13394
14393
|
"profileIndex",
|
|
14394
|
+
"profileName",
|
|
13395
14395
|
"profileHealthKey",
|
|
13396
14396
|
"profileHealthState",
|
|
13397
14397
|
"roundIndex",
|
|
@@ -13400,13 +14400,14 @@ function isAgentModelCallTrace(value) {
|
|
|
13400
14400
|
"finishReason",
|
|
13401
14401
|
"usage",
|
|
13402
14402
|
"pricing"
|
|
13403
|
-
]) && typeof value.callId === "string" && typeof value.nodeId === "string" && typeof value.processId === "string" && typeof value.provider === "string" && typeof value.model === "string" && (value.customProviderApi === void 0 || value.customProviderApi === "completions" || value.customProviderApi === "responses") && (value.outcome === "success" || value.outcome === "provider-failure" || value.outcome === "aborted") && isNonNegativeInteger(value.attemptIndex) && isOptionalNonNegativeInteger(value.profileIndex) && isOptionalString(value.profileHealthKey) && (value.profileHealthState === void 0 || value.profileHealthState === "closed" || value.profileHealthState === "open" || value.profileHealthState === "half-open") && isOptionalNonNegativeInteger(value.roundIndex) && isOptionalNonNegativeFiniteNumber(value.startedAt) && isOptionalNonNegativeFiniteNumber(value.durationMs) && isOptionalString(value.finishReason) && (value.usage === void 0 || isAgentTraceUsage(value.usage)) && isAgentTracePricing(value.pricing);
|
|
14403
|
+
]) && typeof value.callId === "string" && typeof value.nodeId === "string" && typeof value.processId === "string" && typeof value.provider === "string" && typeof value.model === "string" && (value.customProviderApi === void 0 || value.customProviderApi === "completions" || value.customProviderApi === "responses") && (value.outcome === "success" || value.outcome === "provider-failure" || value.outcome === "aborted") && isNonNegativeInteger(value.attemptIndex) && isOptionalNonNegativeInteger(value.profileIndex) && isOptionalString(value.profileName) && isOptionalString(value.profileHealthKey) && (value.profileHealthState === void 0 || value.profileHealthState === "closed" || value.profileHealthState === "open" || value.profileHealthState === "half-open") && isOptionalNonNegativeInteger(value.roundIndex) && isOptionalNonNegativeFiniteNumber(value.startedAt) && isOptionalNonNegativeFiniteNumber(value.durationMs) && isOptionalString(value.finishReason) && (value.usage === void 0 || isAgentTraceUsage(value.usage)) && isAgentTracePricing(value.pricing);
|
|
13404
14404
|
}
|
|
13405
14405
|
function isAgentLLMProfileAttemptTrace(value) {
|
|
13406
14406
|
return isRecord5(value) && hasOnlyKeys(value, [
|
|
13407
14407
|
"eventId",
|
|
13408
14408
|
"roundIndex",
|
|
13409
14409
|
"profileIndex",
|
|
14410
|
+
"profileName",
|
|
13410
14411
|
"nodeId",
|
|
13411
14412
|
"processId",
|
|
13412
14413
|
"provider",
|
|
@@ -13423,7 +14424,7 @@ function isAgentLLMProfileAttemptTrace(value) {
|
|
|
13423
14424
|
"healthOutcome",
|
|
13424
14425
|
"retryAt",
|
|
13425
14426
|
"timeoutKind"
|
|
13426
|
-
]) && typeof value.eventId === "string" && isNonNegativeInteger(value.roundIndex) && isOptionalNonNegativeInteger(value.profileIndex) && typeof value.nodeId === "string" && typeof value.processId === "string" && typeof value.provider === "string" && typeof value.model === "string" && (value.customProviderApi === void 0 || value.customProviderApi === "completions" || value.customProviderApi === "responses") && ["configuration", "request", "response-validation", "health-gate", "health-update"].includes(
|
|
14427
|
+
]) && typeof value.eventId === "string" && isNonNegativeInteger(value.roundIndex) && isOptionalNonNegativeInteger(value.profileIndex) && isOptionalString(value.profileName) && typeof value.nodeId === "string" && typeof value.processId === "string" && typeof value.provider === "string" && typeof value.model === "string" && (value.customProviderApi === void 0 || value.customProviderApi === "completions" || value.customProviderApi === "responses") && ["configuration", "request", "response-validation", "health-gate", "health-update"].includes(
|
|
13427
14428
|
String(value.stage)
|
|
13428
14429
|
) && ["success", "failure", "aborted", "skipped"].includes(String(value.outcome)) && isOptionalNonNegativeInteger(value.attemptIndex) && isOptionalNonNegativeFiniteNumber(value.status) && isOptionalString(value.error) && isOptionalString(value.profileHealthKey) && (value.healthState === void 0 || value.healthState === "closed" || value.healthState === "open" || value.healthState === "half-open") && (value.healthDisposition === void 0 || value.healthDisposition === "allow" || value.healthDisposition === "deny" || value.healthDisposition === "fail-open") && (value.healthOutcome === void 0 || value.healthOutcome === "healthy" || value.healthOutcome === "unhealthy" || value.healthOutcome === "ignored") && isOptionalNonNegativeFiniteNumber(value.retryAt) && (value.timeoutKind === void 0 || value.timeoutKind === "first-output" || value.timeoutKind === "stream-inactivity");
|
|
13429
14430
|
}
|
|
@@ -13499,38 +14500,232 @@ function isRecord5(value) {
|
|
|
13499
14500
|
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
13500
14501
|
}
|
|
13501
14502
|
|
|
14503
|
+
// src/model/WebAppBrowserStorageRpc.ts
|
|
14504
|
+
var RIVET_WEB_APP_BROWSER_STORAGE_RPC_CAPABILITY = "browser-storage-rpc-v2";
|
|
14505
|
+
var RIVET_WEB_APP_BROWSER_STORAGE_RPC_VERSION = 2;
|
|
14506
|
+
var RIVET_WEB_APP_BROWSER_STORAGE_SAFE_FALLBACK_BYTES = 4 * 1024 * 1024;
|
|
14507
|
+
var RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_VALUE_BYTES = 256 * 1024 * 1024;
|
|
14508
|
+
var RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTION_BYTES = 512 * 1024 * 1024;
|
|
14509
|
+
var RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTIVE_BYTES = 512 * 1024 * 1024;
|
|
14510
|
+
var RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_TRANSFER_TIMEOUT_MS = 6e4;
|
|
14511
|
+
var RIVET_WEB_APP_BROWSER_STORAGE_TRANSFER_CHUNK_BYTES = 256 * 1024;
|
|
14512
|
+
var RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES = 40;
|
|
14513
|
+
var FRAME_MAGIC = new Uint8Array([82, 86, 66, 83]);
|
|
14514
|
+
function parseRivetWebAppBrowserStorageClientMessage(value) {
|
|
14515
|
+
if (!isRecord6(value) || !hasActionIds(value) || typeof value.type !== "string") return void 0;
|
|
14516
|
+
if (!isUuid(value.storageSessionId)) return void 0;
|
|
14517
|
+
if (value.type === "storage.transfer.start") {
|
|
14518
|
+
return isNonEmptyString(value.storageRequestId) && isUuid(value.transferId) && isSafeByteLength(value.byteLength) && isSafeChunkCount(value.chunkCount) && typeof value.found === "boolean" ? {
|
|
14519
|
+
type: value.type,
|
|
14520
|
+
requestId: value.requestId,
|
|
14521
|
+
runId: value.runId,
|
|
14522
|
+
storageSessionId: value.storageSessionId,
|
|
14523
|
+
storageRequestId: value.storageRequestId,
|
|
14524
|
+
transferId: value.transferId,
|
|
14525
|
+
byteLength: value.byteLength,
|
|
14526
|
+
chunkCount: value.chunkCount,
|
|
14527
|
+
found: value.found
|
|
14528
|
+
} : void 0;
|
|
14529
|
+
}
|
|
14530
|
+
if (value.type === "storage.commit.ack") {
|
|
14531
|
+
return isUuid(value.transferId) ? {
|
|
14532
|
+
type: value.type,
|
|
14533
|
+
requestId: value.requestId,
|
|
14534
|
+
runId: value.runId,
|
|
14535
|
+
storageSessionId: value.storageSessionId,
|
|
14536
|
+
transferId: value.transferId
|
|
14537
|
+
} : void 0;
|
|
14538
|
+
}
|
|
14539
|
+
if (value.type === "storage.error") return parseStorageError(value);
|
|
14540
|
+
return void 0;
|
|
14541
|
+
}
|
|
14542
|
+
function parseRivetWebAppBrowserStorageServerMessage(value) {
|
|
14543
|
+
if (!isRecord6(value) || !hasActionIds(value) || typeof value.type !== "string") return void 0;
|
|
14544
|
+
if (!isUuid(value.storageSessionId)) return void 0;
|
|
14545
|
+
if (value.type === "storage.get") {
|
|
14546
|
+
return isNonEmptyString(value.storageRequestId) && typeof value.key === "string" && value.key.length > 0 ? {
|
|
14547
|
+
type: value.type,
|
|
14548
|
+
requestId: value.requestId,
|
|
14549
|
+
runId: value.runId,
|
|
14550
|
+
storageSessionId: value.storageSessionId,
|
|
14551
|
+
storageRequestId: value.storageRequestId,
|
|
14552
|
+
key: value.key
|
|
14553
|
+
} : void 0;
|
|
14554
|
+
}
|
|
14555
|
+
if (value.type === "storage.transfer.ack") {
|
|
14556
|
+
return isNonEmptyString(value.storageRequestId) && isUuid(value.transferId) ? {
|
|
14557
|
+
type: value.type,
|
|
14558
|
+
requestId: value.requestId,
|
|
14559
|
+
runId: value.runId,
|
|
14560
|
+
storageSessionId: value.storageSessionId,
|
|
14561
|
+
storageRequestId: value.storageRequestId,
|
|
14562
|
+
transferId: value.transferId
|
|
14563
|
+
} : void 0;
|
|
14564
|
+
}
|
|
14565
|
+
if (value.type === "storage.commit.start") {
|
|
14566
|
+
return isUuid(value.transferId) && isSafeByteLength(value.byteLength) && isSafeChunkCount(value.chunkCount) ? {
|
|
14567
|
+
type: value.type,
|
|
14568
|
+
requestId: value.requestId,
|
|
14569
|
+
runId: value.runId,
|
|
14570
|
+
storageSessionId: value.storageSessionId,
|
|
14571
|
+
transferId: value.transferId,
|
|
14572
|
+
byteLength: value.byteLength,
|
|
14573
|
+
chunkCount: value.chunkCount
|
|
14574
|
+
} : void 0;
|
|
14575
|
+
}
|
|
14576
|
+
if (value.type === "storage.error") return parseStorageError(value);
|
|
14577
|
+
return void 0;
|
|
14578
|
+
}
|
|
14579
|
+
function serializeRivetWebAppStoredValue(value) {
|
|
14580
|
+
return new TextEncoder().encode(JSON.stringify(value));
|
|
14581
|
+
}
|
|
14582
|
+
function deserializeRivetWebAppStoredValue(bytes) {
|
|
14583
|
+
return cloneRivetStoredValue(JSON.parse(new TextDecoder().decode(bytes)), "Browser Stored Value transfer");
|
|
14584
|
+
}
|
|
14585
|
+
function serializeRivetWebAppStoredValuePatch(patch) {
|
|
14586
|
+
return new TextEncoder().encode(JSON.stringify(patch));
|
|
14587
|
+
}
|
|
14588
|
+
function deserializeRivetWebAppStoredValuePatch(bytes) {
|
|
14589
|
+
return cloneRivetStoredValueRecord(
|
|
14590
|
+
JSON.parse(new TextDecoder().decode(bytes)),
|
|
14591
|
+
"Browser Stored Value commit"
|
|
14592
|
+
);
|
|
14593
|
+
}
|
|
14594
|
+
function splitRivetWebAppStorageTransfer(bytes) {
|
|
14595
|
+
if (bytes.byteLength === 0) return [];
|
|
14596
|
+
const chunks = [];
|
|
14597
|
+
for (let offset = 0; offset < bytes.byteLength; offset += RIVET_WEB_APP_BROWSER_STORAGE_TRANSFER_CHUNK_BYTES) {
|
|
14598
|
+
chunks.push(
|
|
14599
|
+
bytes.slice(offset, Math.min(bytes.byteLength, offset + RIVET_WEB_APP_BROWSER_STORAGE_TRANSFER_CHUNK_BYTES))
|
|
14600
|
+
);
|
|
14601
|
+
}
|
|
14602
|
+
return chunks;
|
|
14603
|
+
}
|
|
14604
|
+
function encodeRivetWebAppStorageBinaryFrame(storageSessionId, transferId, chunkIndex, bytes) {
|
|
14605
|
+
const sessionUuid = uuidToBytes(storageSessionId);
|
|
14606
|
+
const transferUuid = uuidToBytes(transferId);
|
|
14607
|
+
if (!Number.isSafeInteger(chunkIndex) || chunkIndex < 0 || chunkIndex > 4294967295) {
|
|
14608
|
+
throw new RangeError("Storage transfer chunk index is invalid.");
|
|
14609
|
+
}
|
|
14610
|
+
const frame = new Uint8Array(RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES + bytes.byteLength);
|
|
14611
|
+
frame.set(FRAME_MAGIC, 0);
|
|
14612
|
+
frame.set(sessionUuid, 4);
|
|
14613
|
+
frame.set(transferUuid, 20);
|
|
14614
|
+
new DataView(frame.buffer).setUint32(36, chunkIndex, false);
|
|
14615
|
+
frame.set(bytes, RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES);
|
|
14616
|
+
return frame;
|
|
14617
|
+
}
|
|
14618
|
+
function decodeRivetWebAppStorageBinaryFrame(frame) {
|
|
14619
|
+
const source = frame instanceof ArrayBuffer ? new Uint8Array(frame) : new Uint8Array(frame.buffer, frame.byteOffset, frame.byteLength);
|
|
14620
|
+
if (source.byteLength < RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES) return void 0;
|
|
14621
|
+
for (let index = 0; index < FRAME_MAGIC.length; index += 1) {
|
|
14622
|
+
if (source[index] !== FRAME_MAGIC[index]) return void 0;
|
|
14623
|
+
}
|
|
14624
|
+
return {
|
|
14625
|
+
storageSessionId: bytesToUuid(source.slice(4, 20)),
|
|
14626
|
+
transferId: bytesToUuid(source.slice(20, 36)),
|
|
14627
|
+
chunkIndex: new DataView(
|
|
14628
|
+
source.buffer,
|
|
14629
|
+
source.byteOffset,
|
|
14630
|
+
RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES
|
|
14631
|
+
).getUint32(36, false),
|
|
14632
|
+
bytes: source.slice(RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES)
|
|
14633
|
+
};
|
|
14634
|
+
}
|
|
14635
|
+
function parseStorageError(value) {
|
|
14636
|
+
return isStorageErrorCode(value.code) && typeof value.error === "string" && typeof value.retryable === "boolean" ? {
|
|
14637
|
+
type: "storage.error",
|
|
14638
|
+
requestId: value.requestId,
|
|
14639
|
+
runId: value.runId,
|
|
14640
|
+
storageSessionId: value.storageSessionId,
|
|
14641
|
+
code: value.code,
|
|
14642
|
+
error: value.error,
|
|
14643
|
+
retryable: value.retryable,
|
|
14644
|
+
...isNonEmptyString(value.storageRequestId) ? { storageRequestId: value.storageRequestId } : {},
|
|
14645
|
+
...isUuid(value.transferId) ? { transferId: value.transferId } : {}
|
|
14646
|
+
} : void 0;
|
|
14647
|
+
}
|
|
14648
|
+
function hasActionIds(value) {
|
|
14649
|
+
return isNonEmptyString(value.requestId) && isNonEmptyString(value.runId);
|
|
14650
|
+
}
|
|
14651
|
+
function isStorageErrorCode(value) {
|
|
14652
|
+
return value === "storage_unavailable" || value === "storage_invalid" || value === "storage_too_large" || value === "storage_capacity";
|
|
14653
|
+
}
|
|
14654
|
+
function isSafeByteLength(value) {
|
|
14655
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
14656
|
+
}
|
|
14657
|
+
function isSafeChunkCount(value) {
|
|
14658
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
14659
|
+
}
|
|
14660
|
+
function isUuid(value) {
|
|
14661
|
+
return typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
|
|
14662
|
+
}
|
|
14663
|
+
function uuidToBytes(value) {
|
|
14664
|
+
if (!isUuid(value)) throw new Error("Storage transfer ID must be a UUID.");
|
|
14665
|
+
return Uint8Array.from(
|
|
14666
|
+
value.replaceAll("-", "").match(/.{2}/g).map((part) => Number.parseInt(part, 16))
|
|
14667
|
+
);
|
|
14668
|
+
}
|
|
14669
|
+
function bytesToUuid(value) {
|
|
14670
|
+
const hex = [...value].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
14671
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
14672
|
+
}
|
|
14673
|
+
function isRecord6(value) {
|
|
14674
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14675
|
+
}
|
|
14676
|
+
function isNonEmptyString(value) {
|
|
14677
|
+
return typeof value === "string" && value.length > 0;
|
|
14678
|
+
}
|
|
14679
|
+
|
|
13502
14680
|
// src/model/UiGraphActionProtocol.ts
|
|
13503
14681
|
var RIVET_WEB_APP_ACTION_PROTOCOL_VERSION = 1;
|
|
13504
14682
|
function parseRivetWebAppClientMessage(value) {
|
|
13505
|
-
if (!
|
|
14683
|
+
if (!isRecord7(value) || typeof value.type !== "string") return void 0;
|
|
14684
|
+
const storageMessage = parseRivetWebAppBrowserStorageClientMessage(value);
|
|
14685
|
+
if (storageMessage) return storageMessage;
|
|
13506
14686
|
switch (value.type) {
|
|
13507
14687
|
case "client.hello":
|
|
13508
|
-
return value.protocolVersion === RIVET_WEB_APP_ACTION_PROTOCOL_VERSION ? {
|
|
14688
|
+
return value.protocolVersion === RIVET_WEB_APP_ACTION_PROTOCOL_VERSION ? {
|
|
14689
|
+
type: value.type,
|
|
14690
|
+
protocolVersion: value.protocolVersion,
|
|
14691
|
+
...isStringArray(value.capabilities) ? { capabilities: value.capabilities } : {}
|
|
14692
|
+
} : void 0;
|
|
13509
14693
|
case "action.start":
|
|
13510
|
-
return
|
|
14694
|
+
return isNonEmptyString2(value.requestId) && isNonEmptyString2(value.componentId) && isRecord7(value.state) && (value.storage == null || isRecord7(value.storage)) && (value.revisionKey == null || typeof value.revisionKey === "string") ? {
|
|
13511
14695
|
type: value.type,
|
|
13512
14696
|
requestId: value.requestId,
|
|
13513
14697
|
componentId: value.componentId,
|
|
13514
14698
|
state: value.state,
|
|
13515
|
-
...
|
|
13516
|
-
...typeof value.revisionKey === "string" ? { revisionKey: value.revisionKey } : {}
|
|
14699
|
+
...isRecord7(value.storage) ? { storage: value.storage } : {},
|
|
14700
|
+
...typeof value.revisionKey === "string" ? { revisionKey: value.revisionKey } : {},
|
|
14701
|
+
...value.storageRpcVersion === 2 ? { storageRpcVersion: 2 } : {}
|
|
13517
14702
|
} : void 0;
|
|
13518
14703
|
case "action.cancel":
|
|
13519
|
-
return
|
|
14704
|
+
return isNonEmptyString2(value.runId) ? { type: value.type, runId: value.runId } : void 0;
|
|
13520
14705
|
case "run.resume":
|
|
13521
|
-
return
|
|
14706
|
+
return isNonEmptyString2(value.runId) && typeof value.lastSequence === "number" && Number.isSafeInteger(value.lastSequence) && value.lastSequence >= 0 ? { type: value.type, runId: value.runId, lastSequence: value.lastSequence } : void 0;
|
|
13522
14707
|
default:
|
|
13523
14708
|
return void 0;
|
|
13524
14709
|
}
|
|
13525
14710
|
}
|
|
13526
14711
|
function parseRivetWebAppServerMessage(value) {
|
|
13527
|
-
if (!
|
|
14712
|
+
if (!isRecord7(value) || typeof value.type !== "string") return void 0;
|
|
14713
|
+
const storageMessage = parseRivetWebAppBrowserStorageServerMessage(value);
|
|
14714
|
+
if (storageMessage) return storageMessage;
|
|
13528
14715
|
if (value.type === "server.ready") {
|
|
13529
|
-
|
|
14716
|
+
if (value.protocolVersion !== RIVET_WEB_APP_ACTION_PROTOCOL_VERSION) return void 0;
|
|
14717
|
+
const browserStorageRpcLimits = parseBrowserStorageRpcLimits(value.browserStorageRpcLimits);
|
|
14718
|
+
if (value.browserStorageRpcLimits != null && !browserStorageRpcLimits) return void 0;
|
|
14719
|
+
return {
|
|
14720
|
+
type: value.type,
|
|
14721
|
+
protocolVersion: value.protocolVersion,
|
|
14722
|
+
...isStringArray(value.capabilities) ? { capabilities: value.capabilities } : {},
|
|
14723
|
+
...browserStorageRpcLimits ? { browserStorageRpcLimits } : {}
|
|
14724
|
+
};
|
|
13530
14725
|
}
|
|
13531
14726
|
if (value.type === "server.draining") return { type: value.type };
|
|
13532
14727
|
if (value.type === "action.rejected") {
|
|
13533
|
-
return
|
|
14728
|
+
return isNonEmptyString2(value.requestId) && isNonEmptyString2(value.error) ? {
|
|
13534
14729
|
type: value.type,
|
|
13535
14730
|
requestId: value.requestId,
|
|
13536
14731
|
error: value.error,
|
|
@@ -13538,7 +14733,7 @@ function parseRivetWebAppServerMessage(value) {
|
|
|
13538
14733
|
} : void 0;
|
|
13539
14734
|
}
|
|
13540
14735
|
if (value.type === "run.rejected") {
|
|
13541
|
-
return
|
|
14736
|
+
return isNonEmptyString2(value.runId) && isNonEmptyString2(value.error) ? {
|
|
13542
14737
|
type: value.type,
|
|
13543
14738
|
runId: value.runId,
|
|
13544
14739
|
error: value.error,
|
|
@@ -13556,7 +14751,7 @@ function parseRivetWebAppServerMessage(value) {
|
|
|
13556
14751
|
case "action.cancelled":
|
|
13557
14752
|
return { type: value.type, ...base };
|
|
13558
14753
|
case "action.progress": {
|
|
13559
|
-
if (!
|
|
14754
|
+
if (!isRecord7(value.progress)) return void 0;
|
|
13560
14755
|
const progress = normalizeGraphProgress({
|
|
13561
14756
|
message: typeof value.progress.message === "string" ? value.progress.message : void 0,
|
|
13562
14757
|
percent: typeof value.progress.percent === "number" ? value.progress.percent : void 0
|
|
@@ -13564,15 +14759,15 @@ function parseRivetWebAppServerMessage(value) {
|
|
|
13564
14759
|
return progress ? { type: value.type, ...base, progress } : void 0;
|
|
13565
14760
|
}
|
|
13566
14761
|
case "action.completed":
|
|
13567
|
-
return
|
|
14762
|
+
return isRecord7(value.statePatch) && (value.storagePatch == null || isRecord7(value.storagePatch)) ? {
|
|
13568
14763
|
type: value.type,
|
|
13569
14764
|
...base,
|
|
13570
14765
|
statePatch: value.statePatch,
|
|
13571
|
-
...
|
|
14766
|
+
...isRecord7(value.storagePatch) ? { storagePatch: value.storagePatch } : {},
|
|
13572
14767
|
...isAgentResponseTrace(value.responseTrace) ? { responseTrace: value.responseTrace } : {}
|
|
13573
14768
|
} : void 0;
|
|
13574
14769
|
case "action.failed":
|
|
13575
|
-
return
|
|
14770
|
+
return isNonEmptyString2(value.error) ? {
|
|
13576
14771
|
type: value.type,
|
|
13577
14772
|
...base,
|
|
13578
14773
|
error: value.error,
|
|
@@ -13580,7 +14775,7 @@ function parseRivetWebAppServerMessage(value) {
|
|
|
13580
14775
|
...isAgentResponseTrace(value.responseTrace) ? { responseTrace: value.responseTrace } : {}
|
|
13581
14776
|
} : void 0;
|
|
13582
14777
|
case "action.interrupted":
|
|
13583
|
-
return
|
|
14778
|
+
return isNonEmptyString2(value.error) ? { type: value.type, ...base, error: value.error } : void 0;
|
|
13584
14779
|
default:
|
|
13585
14780
|
return void 0;
|
|
13586
14781
|
}
|
|
@@ -13589,14 +14784,32 @@ function isRivetWebAppRunTerminalEvent(event) {
|
|
|
13589
14784
|
return event.type === "action.completed" || event.type === "action.failed" || event.type === "action.cancelled" || event.type === "action.interrupted";
|
|
13590
14785
|
}
|
|
13591
14786
|
function hasRunEventBase(value) {
|
|
13592
|
-
return
|
|
14787
|
+
return isNonEmptyString2(value.requestId) && isNonEmptyString2(value.runId) && typeof value.sequence === "number" && Number.isSafeInteger(value.sequence) && value.sequence > 0;
|
|
13593
14788
|
}
|
|
13594
|
-
function
|
|
14789
|
+
function isRecord7(value) {
|
|
13595
14790
|
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
13596
14791
|
}
|
|
13597
|
-
function
|
|
14792
|
+
function parseBrowserStorageRpcLimits(value) {
|
|
14793
|
+
if (!isRecord7(value)) return void 0;
|
|
14794
|
+
if (!isPositiveSafeInteger(value.maxActionBytes) || !isPositiveSafeInteger(value.maxValueBytes) || value.maxValueBytes > value.maxActionBytes) {
|
|
14795
|
+
return void 0;
|
|
14796
|
+
}
|
|
14797
|
+
if (value.transferTimeoutMs != null && !isPositiveSafeInteger(value.transferTimeoutMs)) return void 0;
|
|
14798
|
+
return {
|
|
14799
|
+
maxActionBytes: value.maxActionBytes,
|
|
14800
|
+
maxValueBytes: value.maxValueBytes,
|
|
14801
|
+
transferTimeoutMs: value.transferTimeoutMs ?? RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_TRANSFER_TIMEOUT_MS
|
|
14802
|
+
};
|
|
14803
|
+
}
|
|
14804
|
+
function isPositiveSafeInteger(value) {
|
|
14805
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
14806
|
+
}
|
|
14807
|
+
function isNonEmptyString2(value) {
|
|
13598
14808
|
return typeof value === "string" && value.length > 0;
|
|
13599
14809
|
}
|
|
14810
|
+
function isStringArray(value) {
|
|
14811
|
+
return Array.isArray(value) && value.length <= 16 && value.every((item) => typeof item === "string" && item.length <= 100);
|
|
14812
|
+
}
|
|
13600
14813
|
|
|
13601
14814
|
// src/model/UiGraphRendererStyles.ts
|
|
13602
14815
|
var RIVET_WEB_APP_RENDERER_CSS = `
|
|
@@ -15061,6 +16274,20 @@ button.rivet-web-app-output-header:focus-visible {
|
|
|
15061
16274
|
margin-bottom: 0;
|
|
15062
16275
|
}
|
|
15063
16276
|
|
|
16277
|
+
.rivet-web-app-loading,
|
|
16278
|
+
.rivet-web-app-storage-warning {
|
|
16279
|
+
border: 1px solid color-mix(in srgb, var(--rivet-web-app-error-color) 52%, transparent);
|
|
16280
|
+
border-radius: 10px;
|
|
16281
|
+
background: color-mix(in srgb, var(--rivet-web-app-error-color) 10%, var(--rivet-web-app-card-background));
|
|
16282
|
+
color: var(--rivet-web-app-foreground);
|
|
16283
|
+
padding: 12px 14px;
|
|
16284
|
+
}
|
|
16285
|
+
|
|
16286
|
+
.rivet-web-app-loading {
|
|
16287
|
+
margin: 24px auto;
|
|
16288
|
+
max-width: 720px;
|
|
16289
|
+
}
|
|
16290
|
+
|
|
15064
16291
|
.rivet-web-app-error {
|
|
15065
16292
|
color: var(--rivet-web-app-error-color);
|
|
15066
16293
|
font-weight: 700;
|
|
@@ -15683,284 +16910,6 @@ var userInputNode = nodeDefinition(UserInputNodeImpl, "User Input");
|
|
|
15683
16910
|
var import_non_secure8 = require("nanoid/non-secure");
|
|
15684
16911
|
var import_ts_dedent3 = require("ts-dedent");
|
|
15685
16912
|
|
|
15686
|
-
// src/utils/interpolation.ts
|
|
15687
|
-
var import_lodash_es6 = require("lodash");
|
|
15688
|
-
var ESCAPED_TOKEN_REGEX = /\{\{\{([^}]+?)\}\}\}/g;
|
|
15689
|
-
var ESCAPED_ESCAPED_TOKEN_REGEX = /\\\{\\\{([^}]+?)\\\}\\\}/g;
|
|
15690
|
-
var EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_ENTRIES = 2048;
|
|
15691
|
-
var EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_TEMPLATE_LENGTH = 64 * 1024;
|
|
15692
|
-
var EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_TEMPLATE_CHARS = 1024 * 1024;
|
|
15693
|
-
var extractedInterpolationVariablesCache = /* @__PURE__ */ new Map();
|
|
15694
|
-
var extractedInterpolationVariablesCacheTemplateChars = 0;
|
|
15695
|
-
var lastUncachedInterpolationVariableTemplate;
|
|
15696
|
-
var processingFunctions = {
|
|
15697
|
-
indent: (input, spaces = 0) => {
|
|
15698
|
-
const indent = " ".repeat(spaces);
|
|
15699
|
-
return input.split("\n").map((line) => `${indent}${line}`).join("\n");
|
|
15700
|
-
},
|
|
15701
|
-
quote: (input, level = 1) => {
|
|
15702
|
-
const quotePrefix = "> ".repeat(level);
|
|
15703
|
-
return input.split("\n").map((line) => `${quotePrefix}${line}`).join("\n");
|
|
15704
|
-
},
|
|
15705
|
-
uppercase: (input) => {
|
|
15706
|
-
return input.toUpperCase();
|
|
15707
|
-
},
|
|
15708
|
-
lowercase: (input) => {
|
|
15709
|
-
return input.toLowerCase();
|
|
15710
|
-
},
|
|
15711
|
-
trim: (input) => {
|
|
15712
|
-
return input.trim();
|
|
15713
|
-
},
|
|
15714
|
-
truncate: (input, length = 50) => {
|
|
15715
|
-
if (input.length <= length) return input;
|
|
15716
|
-
return input.slice(0, length) + "...";
|
|
15717
|
-
},
|
|
15718
|
-
list: (input, level = 1) => {
|
|
15719
|
-
const indent = " ".repeat(level - 1);
|
|
15720
|
-
return input.split("\n").map((line) => `${indent}- ${line}`).join("\n");
|
|
15721
|
-
},
|
|
15722
|
-
sort: (input) => {
|
|
15723
|
-
return input.split("\n").sort().join("\n");
|
|
15724
|
-
},
|
|
15725
|
-
dedent: (input) => {
|
|
15726
|
-
return (0, import_ts_dedent.dedent)(input);
|
|
15727
|
-
},
|
|
15728
|
-
wrap: (input, width = 80) => {
|
|
15729
|
-
const words = input.split(/\s+/);
|
|
15730
|
-
const lines = [];
|
|
15731
|
-
let currentLine = "";
|
|
15732
|
-
for (const word of words) {
|
|
15733
|
-
if (currentLine.length + word.length + 1 <= width) {
|
|
15734
|
-
currentLine += (currentLine ? " " : "") + word;
|
|
15735
|
-
} else {
|
|
15736
|
-
lines.push(currentLine);
|
|
15737
|
-
currentLine = word;
|
|
15738
|
-
}
|
|
15739
|
-
}
|
|
15740
|
-
if (currentLine) {
|
|
15741
|
-
lines.push(currentLine);
|
|
15742
|
-
}
|
|
15743
|
-
return lines.join("\n");
|
|
15744
|
-
}
|
|
15745
|
-
};
|
|
15746
|
-
function unwrapPotentialDataValue(value) {
|
|
15747
|
-
if (typeof value === "object" && value !== null && typeof value.type === "string" && Object.prototype.hasOwnProperty.call(value, "value")) {
|
|
15748
|
-
return value.value;
|
|
15749
|
-
}
|
|
15750
|
-
return value;
|
|
15751
|
-
}
|
|
15752
|
-
function resolveExpressionRawValue(source, expression, sourceType) {
|
|
15753
|
-
if (!source) {
|
|
15754
|
-
return void 0;
|
|
15755
|
-
}
|
|
15756
|
-
const match9 = expression.trim().match(/^([^[.\s]+)\s*(.*)$/);
|
|
15757
|
-
let key;
|
|
15758
|
-
let path;
|
|
15759
|
-
if (match9 && typeof match9[1] === "string") {
|
|
15760
|
-
key = match9[1];
|
|
15761
|
-
const rawPath = match9[2];
|
|
15762
|
-
if (rawPath) {
|
|
15763
|
-
path = rawPath.trim().replace(/\s*(\.|\[|\])\s*/g, "$1");
|
|
15764
|
-
} else {
|
|
15765
|
-
path = void 0;
|
|
15766
|
-
}
|
|
15767
|
-
} else {
|
|
15768
|
-
key = expression.trim();
|
|
15769
|
-
path = void 0;
|
|
15770
|
-
}
|
|
15771
|
-
if (!key) {
|
|
15772
|
-
return void 0;
|
|
15773
|
-
}
|
|
15774
|
-
const topLevelValue = source[key];
|
|
15775
|
-
if (topLevelValue === void 0) {
|
|
15776
|
-
return void 0;
|
|
15777
|
-
}
|
|
15778
|
-
const baseValue = unwrapPotentialDataValue(topLevelValue);
|
|
15779
|
-
let finalValue;
|
|
15780
|
-
if (path) {
|
|
15781
|
-
try {
|
|
15782
|
-
finalValue = (0, import_lodash_es6.get)(baseValue, path);
|
|
15783
|
-
finalValue = unwrapPotentialDataValue(finalValue);
|
|
15784
|
-
} catch (error) {
|
|
15785
|
-
console.warn(`Error accessing path "${path}" in ${sourceType} value for key "${key}":`, error);
|
|
15786
|
-
return void 0;
|
|
15787
|
-
}
|
|
15788
|
-
} else {
|
|
15789
|
-
finalValue = baseValue;
|
|
15790
|
-
}
|
|
15791
|
-
return finalValue;
|
|
15792
|
-
}
|
|
15793
|
-
function resolveExpressionToString(source, expression, sourceType) {
|
|
15794
|
-
const finalValue = resolveExpressionRawValue(source, expression, sourceType);
|
|
15795
|
-
if (finalValue === void 0) {
|
|
15796
|
-
return void 0;
|
|
15797
|
-
}
|
|
15798
|
-
if (typeof finalValue === "object" && finalValue !== null) {
|
|
15799
|
-
try {
|
|
15800
|
-
return JSON.stringify(finalValue);
|
|
15801
|
-
} catch (error) {
|
|
15802
|
-
console.warn(`Error stringifying object/array in ${sourceType} for expression "${expression}":`, error);
|
|
15803
|
-
return "[object Object]";
|
|
15804
|
-
}
|
|
15805
|
-
}
|
|
15806
|
-
return String(finalValue);
|
|
15807
|
-
}
|
|
15808
|
-
function parseProcessing(instruction) {
|
|
15809
|
-
const parts = instruction.trim().split(/\s+/);
|
|
15810
|
-
return {
|
|
15811
|
-
func: parts[0],
|
|
15812
|
-
param: parts[1] ? parseInt(parts[1], 10) : void 0
|
|
15813
|
-
};
|
|
15814
|
-
}
|
|
15815
|
-
function applyProcessing(value, processingChain) {
|
|
15816
|
-
const instructions = processingChain.split("|").map((instruction) => instruction.trim()).filter((instruction) => instruction !== "");
|
|
15817
|
-
return instructions.reduce((result, instruction) => {
|
|
15818
|
-
const { func, param } = parseProcessing(instruction);
|
|
15819
|
-
const processingFunc = processingFunctions[func];
|
|
15820
|
-
if (!processingFunc) {
|
|
15821
|
-
console.warn(`Unknown processing function: ${func}`);
|
|
15822
|
-
return result;
|
|
15823
|
-
}
|
|
15824
|
-
return processingFunc(result, param);
|
|
15825
|
-
}, value);
|
|
15826
|
-
}
|
|
15827
|
-
function protectEscapedInterpolationTokens(template) {
|
|
15828
|
-
return template.replace(ESCAPED_TOKEN_REGEX, (_match, expression) => `\\{\\{${expression}\\}\\}`);
|
|
15829
|
-
}
|
|
15830
|
-
function restoreEscapedInterpolationTokens(template) {
|
|
15831
|
-
return template.replace(ESCAPED_ESCAPED_TOKEN_REGEX, (_match, expression) => `{{${expression}}}`);
|
|
15832
|
-
}
|
|
15833
|
-
function findInterpolationTokenSpans(template) {
|
|
15834
|
-
const spans = [];
|
|
15835
|
-
let searchIndex = 0;
|
|
15836
|
-
while (searchIndex < template.length) {
|
|
15837
|
-
const openIndex = template.indexOf("{{", searchIndex);
|
|
15838
|
-
if (openIndex === -1) {
|
|
15839
|
-
break;
|
|
15840
|
-
}
|
|
15841
|
-
const closeIndex = template.indexOf("}}", openIndex + 2);
|
|
15842
|
-
if (closeIndex === -1) {
|
|
15843
|
-
break;
|
|
15844
|
-
}
|
|
15845
|
-
const nestedOpenIndex = template.indexOf("{{", openIndex + 2);
|
|
15846
|
-
if (nestedOpenIndex !== -1 && nestedOpenIndex < closeIndex) {
|
|
15847
|
-
searchIndex = nestedOpenIndex;
|
|
15848
|
-
continue;
|
|
15849
|
-
}
|
|
15850
|
-
spans.push({
|
|
15851
|
-
start: openIndex,
|
|
15852
|
-
end: closeIndex + 2,
|
|
15853
|
-
rawInner: template.slice(openIndex + 2, closeIndex)
|
|
15854
|
-
});
|
|
15855
|
-
searchIndex = closeIndex + 2;
|
|
15856
|
-
}
|
|
15857
|
-
return spans;
|
|
15858
|
-
}
|
|
15859
|
-
function getInterpolationTokenName(rawInner) {
|
|
15860
|
-
const [tokenPart] = rawInner.split("|");
|
|
15861
|
-
if (!tokenPart) {
|
|
15862
|
-
return void 0;
|
|
15863
|
-
}
|
|
15864
|
-
const token = tokenPart.trim();
|
|
15865
|
-
return token === "" ? void 0 : token;
|
|
15866
|
-
}
|
|
15867
|
-
function replaceInterpolationTokens(template, getReplacement, options2 = {}) {
|
|
15868
|
-
const protectedTemplate = protectEscapedInterpolationTokens(template);
|
|
15869
|
-
const tokenSpans = findInterpolationTokenSpans(protectedTemplate);
|
|
15870
|
-
if (tokenSpans.length === 0) {
|
|
15871
|
-
const restoredTemplate = restoreEscapedInterpolationTokens(protectedTemplate);
|
|
15872
|
-
return options2.trim ? restoredTemplate.trim() : restoredTemplate;
|
|
15873
|
-
}
|
|
15874
|
-
let result = "";
|
|
15875
|
-
let cursor = 0;
|
|
15876
|
-
for (const tokenSpan of tokenSpans) {
|
|
15877
|
-
result += protectedTemplate.slice(cursor, tokenSpan.start);
|
|
15878
|
-
result += getReplacement({
|
|
15879
|
-
rawInner: tokenSpan.rawInner,
|
|
15880
|
-
span: tokenSpan,
|
|
15881
|
-
tokenName: getInterpolationTokenName(tokenSpan.rawInner)
|
|
15882
|
-
});
|
|
15883
|
-
cursor = tokenSpan.end;
|
|
15884
|
-
}
|
|
15885
|
-
result += protectedTemplate.slice(cursor);
|
|
15886
|
-
const restoredResult = restoreEscapedInterpolationTokens(result);
|
|
15887
|
-
return options2.trim ? restoredResult.trim() : restoredResult;
|
|
15888
|
-
}
|
|
15889
|
-
function interpolate(template, variables, graphInputValues, contextValues) {
|
|
15890
|
-
return replaceInterpolationTokens(template, ({ rawInner }) => {
|
|
15891
|
-
const parts = rawInner.split("|").map((s) => s.trim());
|
|
15892
|
-
const expression = parts[0];
|
|
15893
|
-
const processingChain = parts.slice(1).join("|");
|
|
15894
|
-
let resolvedValue;
|
|
15895
|
-
if (expression.startsWith("@graphInputs.")) {
|
|
15896
|
-
resolvedValue = resolveExpressionToString(
|
|
15897
|
-
graphInputValues,
|
|
15898
|
-
expression.substring("@graphInputs.".length),
|
|
15899
|
-
"graphInputs"
|
|
15900
|
-
);
|
|
15901
|
-
} else if (expression.startsWith("@context.")) {
|
|
15902
|
-
resolvedValue = resolveExpressionToString(contextValues, expression.substring("@context.".length), "context");
|
|
15903
|
-
} else {
|
|
15904
|
-
const simpleVar = variables[expression];
|
|
15905
|
-
if (simpleVar !== void 0) {
|
|
15906
|
-
resolvedValue = String(unwrapPotentialDataValue(simpleVar) ?? "");
|
|
15907
|
-
} else {
|
|
15908
|
-
resolvedValue = void 0;
|
|
15909
|
-
}
|
|
15910
|
-
}
|
|
15911
|
-
if (resolvedValue === void 0) {
|
|
15912
|
-
console.warn(`Interpolation variable or path "${expression}" not found or resolved to undefined.`);
|
|
15913
|
-
return "";
|
|
15914
|
-
} else if (processingChain) {
|
|
15915
|
-
return applyProcessing(resolvedValue, processingChain);
|
|
15916
|
-
}
|
|
15917
|
-
return resolvedValue;
|
|
15918
|
-
});
|
|
15919
|
-
}
|
|
15920
|
-
function extractInterpolationVariables(template) {
|
|
15921
|
-
if (!template.includes("{{")) {
|
|
15922
|
-
return [];
|
|
15923
|
-
}
|
|
15924
|
-
const cachedVariables = getCachedInterpolationVariables(template);
|
|
15925
|
-
if (cachedVariables) {
|
|
15926
|
-
return [...cachedVariables];
|
|
15927
|
-
}
|
|
15928
|
-
const protectedTemplate = protectEscapedInterpolationTokens(template);
|
|
15929
|
-
const variables = /* @__PURE__ */ new Set();
|
|
15930
|
-
for (const match9 of findInterpolationTokenSpans(protectedTemplate)) {
|
|
15931
|
-
const token = getInterpolationTokenName(match9.rawInner);
|
|
15932
|
-
if (token && !token.startsWith("@graphInputs.") && !token.startsWith("@context.")) {
|
|
15933
|
-
variables.add(token);
|
|
15934
|
-
}
|
|
15935
|
-
}
|
|
15936
|
-
const extractedVariables = Array.from(variables);
|
|
15937
|
-
cacheInterpolationVariables(template, extractedVariables);
|
|
15938
|
-
return extractedVariables;
|
|
15939
|
-
}
|
|
15940
|
-
function getCachedInterpolationVariables(template) {
|
|
15941
|
-
var _a;
|
|
15942
|
-
return (_a = extractedInterpolationVariablesCache.get(template)) == null ? void 0 : _a.variables;
|
|
15943
|
-
}
|
|
15944
|
-
function cacheInterpolationVariables(template, variables) {
|
|
15945
|
-
if (template.length > EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_TEMPLATE_LENGTH) {
|
|
15946
|
-
return;
|
|
15947
|
-
}
|
|
15948
|
-
if (extractedInterpolationVariablesCache.size >= EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_ENTRIES || extractedInterpolationVariablesCacheTemplateChars + template.length > EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_TEMPLATE_CHARS) {
|
|
15949
|
-
if (lastUncachedInterpolationVariableTemplate !== template) {
|
|
15950
|
-
lastUncachedInterpolationVariableTemplate = template;
|
|
15951
|
-
return;
|
|
15952
|
-
}
|
|
15953
|
-
extractedInterpolationVariablesCache.clear();
|
|
15954
|
-
extractedInterpolationVariablesCacheTemplateChars = 0;
|
|
15955
|
-
}
|
|
15956
|
-
lastUncachedInterpolationVariableTemplate = void 0;
|
|
15957
|
-
extractedInterpolationVariablesCache.set(template, {
|
|
15958
|
-
templateLength: template.length,
|
|
15959
|
-
variables: Object.freeze([...variables])
|
|
15960
|
-
});
|
|
15961
|
-
extractedInterpolationVariablesCacheTemplateChars += template.length;
|
|
15962
|
-
}
|
|
15963
|
-
|
|
15964
16913
|
// src/model/interpolationInputDefinition.ts
|
|
15965
16914
|
var INTERPOLATION_INPUT_DEFINITION_KIND = "interpolation-input";
|
|
15966
16915
|
function createInterpolationInputDefinition({
|
|
@@ -16004,16 +16953,16 @@ function isInterpolationInputDefinition(inputDefinition) {
|
|
|
16004
16953
|
return getInterpolationInputDefinitionData(inputDefinition) != null;
|
|
16005
16954
|
}
|
|
16006
16955
|
|
|
16007
|
-
// src/model/nodes/
|
|
16956
|
+
// src/model/nodes/nodeBodyPreview.ts
|
|
16008
16957
|
var MAX_BODY_PREVIEW_LINES = 15;
|
|
16009
16958
|
var MAX_BODY_PREVIEW_LINE_LENGTH = 240;
|
|
16010
16959
|
var MAX_BODY_PREVIEW_CHARS = 3e3;
|
|
16011
|
-
function
|
|
16960
|
+
function buildNodeBodyPreview(text, maximumLines = MAX_BODY_PREVIEW_LINES) {
|
|
16012
16961
|
const allLines = text.split("\n");
|
|
16013
|
-
const previewLines = allLines.slice(0,
|
|
16962
|
+
const previewLines = allLines.slice(0, maximumLines).map(
|
|
16014
16963
|
(line) => line.length > MAX_BODY_PREVIEW_LINE_LENGTH ? `${line.slice(0, MAX_BODY_PREVIEW_LINE_LENGTH)}...` : line
|
|
16015
16964
|
);
|
|
16016
|
-
const omittedLines = allLines.length >
|
|
16965
|
+
const omittedLines = allLines.length > maximumLines;
|
|
16017
16966
|
let previewText = previewLines.join("\n").trim();
|
|
16018
16967
|
if (previewText.length > MAX_BODY_PREVIEW_CHARS) {
|
|
16019
16968
|
previewText = previewText.slice(0, MAX_BODY_PREVIEW_CHARS).trimEnd();
|
|
@@ -16026,6 +16975,8 @@ function buildTextNodeBodyPreview(text) {
|
|
|
16026
16975
|
}
|
|
16027
16976
|
return previewText;
|
|
16028
16977
|
}
|
|
16978
|
+
|
|
16979
|
+
// src/model/nodes/TextNode.ts
|
|
16029
16980
|
var TextNodeImpl = class extends NodeImpl {
|
|
16030
16981
|
static create() {
|
|
16031
16982
|
const chartNode = {
|
|
@@ -16046,14 +16997,14 @@ var TextNodeImpl = class extends NodeImpl {
|
|
|
16046
16997
|
return chartNode;
|
|
16047
16998
|
}
|
|
16048
16999
|
getInputDefinitions() {
|
|
16049
|
-
const
|
|
16050
|
-
return
|
|
16051
|
-
(
|
|
16052
|
-
interpolationName:
|
|
16053
|
-
dataType: "string",
|
|
17000
|
+
const inputReferences = extractInterpolationVariableReferences(this.data.text);
|
|
17001
|
+
return inputReferences.map(
|
|
17002
|
+
({ baseName, hasPath }) => createInterpolationInputDefinition({
|
|
17003
|
+
interpolationName: baseName,
|
|
17004
|
+
dataType: hasPath ? "any" : "string",
|
|
16054
17005
|
required: false
|
|
16055
17006
|
})
|
|
16056
|
-
)
|
|
17007
|
+
);
|
|
16057
17008
|
}
|
|
16058
17009
|
getOutputDefinitions() {
|
|
16059
17010
|
return [
|
|
@@ -16092,25 +17043,18 @@ var TextNodeImpl = class extends NodeImpl {
|
|
|
16092
17043
|
type: "colorized",
|
|
16093
17044
|
language: "prompt-interpolation-markdown",
|
|
16094
17045
|
theme: "prompt-interpolation",
|
|
16095
|
-
text:
|
|
17046
|
+
text: buildNodeBodyPreview(this.data.text)
|
|
16096
17047
|
};
|
|
16097
17048
|
}
|
|
16098
17049
|
async process(inputs, context) {
|
|
16099
|
-
const inputMap = Object.keys(inputs).reduce(
|
|
16100
|
-
(acc, key) => {
|
|
16101
|
-
const stringValue = coerceTypeOptional(inputs[key], "string") ?? "";
|
|
16102
|
-
acc[key] = stringValue;
|
|
16103
|
-
return acc;
|
|
16104
|
-
},
|
|
16105
|
-
{}
|
|
16106
|
-
);
|
|
16107
17050
|
let outputValue = interpolate(
|
|
16108
17051
|
this.chartNode.data.text,
|
|
16109
|
-
|
|
17052
|
+
inputs,
|
|
16110
17053
|
context.graphInputNodeValues,
|
|
16111
17054
|
// Pass graph inputs
|
|
16112
|
-
context.contextValues
|
|
17055
|
+
context.contextValues,
|
|
16113
17056
|
// Pass context values
|
|
17057
|
+
{ coerceBareVariableDataValues: true }
|
|
16114
17058
|
);
|
|
16115
17059
|
if (this.chartNode.data.normalizeLineEndings) {
|
|
16116
17060
|
outputValue = outputValue.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
@@ -16153,7 +17097,7 @@ __export(openai_exports, {
|
|
|
16153
17097
|
openaiModels: () => openaiModels,
|
|
16154
17098
|
streamChatCompletions: () => streamChatCompletions
|
|
16155
17099
|
});
|
|
16156
|
-
var
|
|
17100
|
+
var import_lodash_es6 = require("lodash");
|
|
16157
17101
|
|
|
16158
17102
|
// src/utils/fetchEventSource.ts
|
|
16159
17103
|
var EventSourceResponse = class extends Response {
|
|
@@ -16459,7 +17403,7 @@ var openaiModels = {
|
|
|
16459
17403
|
displayName: "Local Model"
|
|
16460
17404
|
}
|
|
16461
17405
|
};
|
|
16462
|
-
var openAiModelOptions = (0,
|
|
17406
|
+
var openAiModelOptions = (0, import_lodash_es6.orderBy)(
|
|
16463
17407
|
Object.entries(openaiModels).map(([id, { displayName }]) => ({
|
|
16464
17408
|
value: id,
|
|
16465
17409
|
label: displayName
|
|
@@ -20639,6 +21583,7 @@ function notifyChatV2CallFinished(options2, params) {
|
|
|
20639
21583
|
callId: params.callId,
|
|
20640
21584
|
attemptIndex: params.attemptIndex,
|
|
20641
21585
|
...options2.profileIndex == null ? {} : { profileIndex: options2.profileIndex },
|
|
21586
|
+
...options2.profileName == null ? {} : { profileName: options2.profileName },
|
|
20642
21587
|
...options2.profileHealthKey == null ? {} : { profileHealthKey: options2.profileHealthKey },
|
|
20643
21588
|
...options2.profileHealthState == null ? {} : { profileHealthState: options2.profileHealthState },
|
|
20644
21589
|
...options2.roundIndex == null ? {} : { roundIndex: options2.roundIndex },
|
|
@@ -20944,7 +21889,7 @@ var STATUS_TEXT = {
|
|
|
20944
21889
|
422: "Unprocessable Entity",
|
|
20945
21890
|
429: "Rate Limited"
|
|
20946
21891
|
};
|
|
20947
|
-
function
|
|
21892
|
+
function isRecord8(value) {
|
|
20948
21893
|
if (value == null || typeof value !== "object") {
|
|
20949
21894
|
return false;
|
|
20950
21895
|
}
|
|
@@ -20978,7 +21923,7 @@ function stringifyProviderValue(value) {
|
|
|
20978
21923
|
}
|
|
20979
21924
|
}
|
|
20980
21925
|
function findProviderMessage(value) {
|
|
20981
|
-
if (!
|
|
21926
|
+
if (!isRecord8(value)) {
|
|
20982
21927
|
return stringifyProviderValue(value);
|
|
20983
21928
|
}
|
|
20984
21929
|
const direct = value.message ?? value.error_description ?? value.detail;
|
|
@@ -21002,7 +21947,7 @@ function parseResponseBodyMessage(responseBody) {
|
|
|
21002
21947
|
}
|
|
21003
21948
|
}
|
|
21004
21949
|
function getProviderMessage(error, seen = /* @__PURE__ */ new Set()) {
|
|
21005
|
-
if (!
|
|
21950
|
+
if (!isRecord8(error) || seen.has(error)) {
|
|
21006
21951
|
return void 0;
|
|
21007
21952
|
}
|
|
21008
21953
|
seen.add(error);
|
|
@@ -21011,7 +21956,7 @@ function getProviderMessage(error, seen = /* @__PURE__ */ new Set()) {
|
|
|
21011
21956
|
return responseBodyMessage;
|
|
21012
21957
|
}
|
|
21013
21958
|
const response = error.response;
|
|
21014
|
-
if (
|
|
21959
|
+
if (isRecord8(response)) {
|
|
21015
21960
|
const nestedResponseBody = typeof response.responseBody === "string" ? response.responseBody : typeof response.body === "string" ? response.body : void 0;
|
|
21016
21961
|
const nestedResponseMessage = parseResponseBodyMessage(nestedResponseBody) ?? findProviderMessage(response.data) ?? findProviderMessage(response);
|
|
21017
21962
|
if (nestedResponseMessage) {
|
|
@@ -21086,7 +22031,7 @@ function getRecordStatusCode(record) {
|
|
|
21086
22031
|
return coerceHttpStatusCode(getRecordProperty(record, "statusCode")) ?? coerceHttpStatusCode(getRecordProperty(record, "status"));
|
|
21087
22032
|
}
|
|
21088
22033
|
function getChatV2ProviderErrorStatusCode(error, seen = /* @__PURE__ */ new Set()) {
|
|
21089
|
-
if (!
|
|
22034
|
+
if (!isRecord8(error)) {
|
|
21090
22035
|
return void 0;
|
|
21091
22036
|
}
|
|
21092
22037
|
if (seen.has(error)) {
|
|
@@ -21098,20 +22043,20 @@ function getChatV2ProviderErrorStatusCode(error, seen = /* @__PURE__ */ new Set(
|
|
|
21098
22043
|
return directStatusCode;
|
|
21099
22044
|
}
|
|
21100
22045
|
const response = getRecordProperty(error, "response");
|
|
21101
|
-
if (
|
|
22046
|
+
if (isRecord8(response)) {
|
|
21102
22047
|
const responseStatusCode = getRecordStatusCode(response);
|
|
21103
22048
|
if (responseStatusCode != null) {
|
|
21104
22049
|
return responseStatusCode;
|
|
21105
22050
|
}
|
|
21106
22051
|
}
|
|
21107
22052
|
const data = getRecordProperty(error, "data");
|
|
21108
|
-
if (
|
|
22053
|
+
if (isRecord8(data)) {
|
|
21109
22054
|
const dataStatusCode = getRecordStatusCode(data);
|
|
21110
22055
|
if (dataStatusCode != null) {
|
|
21111
22056
|
return dataStatusCode;
|
|
21112
22057
|
}
|
|
21113
22058
|
const dataError = getRecordProperty(data, "error");
|
|
21114
|
-
if (
|
|
22059
|
+
if (isRecord8(dataError)) {
|
|
21115
22060
|
const dataErrorStatusCode = getRecordStatusCode(dataError);
|
|
21116
22061
|
if (dataErrorStatusCode != null) {
|
|
21117
22062
|
return dataErrorStatusCode;
|
|
@@ -21665,6 +22610,41 @@ async function runChatV2Pipeline(options2) {
|
|
|
21665
22610
|
return execution.outcome === "success" ? execution.result : materializeChatV2PipelineFailure(execution.failure);
|
|
21666
22611
|
}
|
|
21667
22612
|
|
|
22613
|
+
// src/model/chat-v2/llmChatV2OutputClone.ts
|
|
22614
|
+
function cloneOutputValue(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
22615
|
+
if (value == null || typeof value !== "object") {
|
|
22616
|
+
return value;
|
|
22617
|
+
}
|
|
22618
|
+
if (value instanceof Uint8Array) {
|
|
22619
|
+
return new Uint8Array(value);
|
|
22620
|
+
}
|
|
22621
|
+
const existing = seen.get(value);
|
|
22622
|
+
if (existing != null) {
|
|
22623
|
+
return existing;
|
|
22624
|
+
}
|
|
22625
|
+
if (Array.isArray(value)) {
|
|
22626
|
+
const clone2 = [];
|
|
22627
|
+
seen.set(value, clone2);
|
|
22628
|
+
clone2.push(...value.map((item) => cloneOutputValue(item, seen)));
|
|
22629
|
+
return clone2;
|
|
22630
|
+
}
|
|
22631
|
+
const clone = {};
|
|
22632
|
+
seen.set(value, clone);
|
|
22633
|
+
for (const [key, item] of Object.entries(value)) {
|
|
22634
|
+
clone[key] = cloneOutputValue(item, seen);
|
|
22635
|
+
}
|
|
22636
|
+
return clone;
|
|
22637
|
+
}
|
|
22638
|
+
function cloneLLMChatV2Outputs(outputs) {
|
|
22639
|
+
if (typeof structuredClone === "function") {
|
|
22640
|
+
try {
|
|
22641
|
+
return structuredClone(outputs);
|
|
22642
|
+
} catch {
|
|
22643
|
+
}
|
|
22644
|
+
}
|
|
22645
|
+
return cloneOutputValue(outputs);
|
|
22646
|
+
}
|
|
22647
|
+
|
|
21668
22648
|
// src/model/chat-v2/toolContinuation.ts
|
|
21669
22649
|
function shouldReturnToolResultDirectly(functionCalls, registry) {
|
|
21670
22650
|
var _a;
|
|
@@ -21742,6 +22722,8 @@ async function runChatV2PipelineWithToolContinuation(options2) {
|
|
|
21742
22722
|
functions,
|
|
21743
22723
|
delegateToolCall: delegateToolCall2,
|
|
21744
22724
|
delegateToolCallRound,
|
|
22725
|
+
onCompletedModelRound,
|
|
22726
|
+
onTerminalRound,
|
|
21745
22727
|
runPipeline,
|
|
21746
22728
|
...pipelineOptions
|
|
21747
22729
|
} = options2;
|
|
@@ -21792,8 +22774,21 @@ async function runChatV2PipelineWithToolContinuation(options2) {
|
|
|
21792
22774
|
outputReasoning: pipelineOptions.outputReasoning,
|
|
21793
22775
|
includeFunctionCalls: pipelineOptions.includeFunctionCalls
|
|
21794
22776
|
});
|
|
22777
|
+
onTerminalRound == null ? void 0 : onTerminalRound({
|
|
22778
|
+
entryId: `model-round:${completedRounds}`,
|
|
22779
|
+
roundIndex: completedRounds,
|
|
22780
|
+
kind: "model-round",
|
|
22781
|
+
outcome: decision.kind === "final-model-answer" ? "final-answer" : decision.kind === "release-unresolved-calls" ? "unresolved-tool-calls" : "max-rounds"
|
|
22782
|
+
});
|
|
21795
22783
|
return result;
|
|
21796
22784
|
}
|
|
22785
|
+
onCompletedModelRound == null ? void 0 : onCompletedModelRound({
|
|
22786
|
+
entryId: `model-round:${completedRounds}`,
|
|
22787
|
+
roundIndex: completedRounds,
|
|
22788
|
+
kind: "model-round",
|
|
22789
|
+
outcome: "tool-calls",
|
|
22790
|
+
outputs: cloneLLMChatV2Outputs(result.commonOutputs)
|
|
22791
|
+
});
|
|
21797
22792
|
const toolResultMessages = await toolRoundExecutor.executeRound({
|
|
21798
22793
|
calls: result.functionCalls,
|
|
21799
22794
|
assistantMessage: result.response
|
|
@@ -21837,6 +22832,12 @@ A direct tool result is terminal and is not retried or sent to another LLM profi
|
|
|
21837
22832
|
}
|
|
21838
22833
|
applyAccumulatedUsage(result, accumulatedUsage, pipelineOptions.outputUsage);
|
|
21839
22834
|
applyAccumulatedReasoning(result, reasoningRounds, pipelineOptions.outputReasoning);
|
|
22835
|
+
onTerminalRound == null ? void 0 : onTerminalRound({
|
|
22836
|
+
entryId: `direct-tool-result:${completedRounds}`,
|
|
22837
|
+
roundIndex: completedRounds,
|
|
22838
|
+
kind: "direct-tool-result",
|
|
22839
|
+
outcome: "direct-tool-result"
|
|
22840
|
+
});
|
|
21840
22841
|
return result;
|
|
21841
22842
|
}
|
|
21842
22843
|
currentPrompt = {
|
|
@@ -21851,6 +22852,7 @@ A direct tool result is terminal and is not retried or sent to another LLM profi
|
|
|
21851
22852
|
async function executeLLMInvocation(params) {
|
|
21852
22853
|
const { context, journal, runtime, toolCallContinuation } = params;
|
|
21853
22854
|
try {
|
|
22855
|
+
let terminalSnapshot;
|
|
21854
22856
|
const result = runtime.shouldAutoContinueToolCalls ? await runChatV2PipelineWithToolContinuation({
|
|
21855
22857
|
...runtime.runOptions,
|
|
21856
22858
|
autoContinue: true,
|
|
@@ -21880,12 +22882,36 @@ async function executeLLMInvocation(params) {
|
|
|
21880
22882
|
delegatedToolCall: delegated.record
|
|
21881
22883
|
};
|
|
21882
22884
|
},
|
|
21883
|
-
runPipeline: runtime.runPipeline
|
|
22885
|
+
runPipeline: runtime.runPipeline,
|
|
22886
|
+
onCompletedModelRound: (snapshot) => {
|
|
22887
|
+
var _a;
|
|
22888
|
+
try {
|
|
22889
|
+
const observerResult = (_a = context.onLLMChatOutputSnapshot) == null ? void 0 : _a.call(context, {
|
|
22890
|
+
...snapshot,
|
|
22891
|
+
nodeId: context.node.id,
|
|
22892
|
+
processId: context.processId,
|
|
22893
|
+
splitIndex: context.splitIndex ?? 0
|
|
22894
|
+
});
|
|
22895
|
+
void Promise.resolve(observerResult).catch(() => void 0);
|
|
22896
|
+
} catch {
|
|
22897
|
+
}
|
|
22898
|
+
},
|
|
22899
|
+
onTerminalRound: (snapshot) => {
|
|
22900
|
+
terminalSnapshot = snapshot;
|
|
22901
|
+
}
|
|
21884
22902
|
}) : await runtime.runPipeline(runtime.runOptions);
|
|
22903
|
+
if (!runtime.shouldAutoContinueToolCalls && !isChatV2PipelineProviderFailureResult(result)) {
|
|
22904
|
+
terminalSnapshot = {
|
|
22905
|
+
entryId: "model-round:0",
|
|
22906
|
+
roundIndex: 0,
|
|
22907
|
+
kind: "model-round",
|
|
22908
|
+
outcome: result.functionCalls.length > 0 ? "unresolved-tool-calls" : "final-answer"
|
|
22909
|
+
};
|
|
22910
|
+
}
|
|
21885
22911
|
journal.recordTerminal({
|
|
21886
22912
|
kind: isChatV2PipelineProviderFailureResult(result) ? "failed" : result.functionCalls.length > 0 ? "released-unresolved-calls" : "final-model-answer"
|
|
21887
22913
|
});
|
|
21888
|
-
return result;
|
|
22914
|
+
return { result, terminalSnapshot };
|
|
21889
22915
|
} catch (error) {
|
|
21890
22916
|
journal.recordTerminal({ kind: context.signal.aborted ? "cancelled" : "failed" });
|
|
21891
22917
|
throw error;
|
|
@@ -22028,12 +23054,18 @@ function getLLMAttemptErrorMessage(error) {
|
|
|
22028
23054
|
return "Provider request failed with unreadable error metadata.";
|
|
22029
23055
|
}
|
|
22030
23056
|
}
|
|
23057
|
+
function formatCandidateProfileIdentity(candidate, profileIndex) {
|
|
23058
|
+
var _a;
|
|
23059
|
+
const profileName = (_a = candidate.profileName) == null ? void 0 : _a.trim();
|
|
23060
|
+
const identity = formatCandidateIdentity(candidate);
|
|
23061
|
+
return profileName ? `${profileName} (profile ${profileIndex + 1}; ${identity})` : `Profile ${profileIndex + 1} (${identity})`;
|
|
23062
|
+
}
|
|
22031
23063
|
function buildExhaustedMessage(attempts) {
|
|
22032
23064
|
const details = attempts.map((attempt) => {
|
|
22033
23065
|
const stage = attempt.stage === "request" ? `request${attempt.attemptIndex == null ? "" : ` attempt ${attempt.attemptIndex}`}` : attempt.stage === "response-validation" ? "response validation" : attempt.stage === "health-gate" ? "reliability check" : attempt.stage === "health-update" ? "reliability update" : "configuration";
|
|
22034
23066
|
const status = attempt.status == null ? "" : ` (${attempt.status})`;
|
|
22035
23067
|
const error = attempt.error ? `: ${attempt.error.replace(/\r\n|\r|\n/g, "\n ")}` : "";
|
|
22036
|
-
return
|
|
23068
|
+
return `${formatCandidateProfileIdentity(attempt, attempt.profileIndex ?? 0)}, round ${attempt.roundIndex + 1}, ${stage} ${attempt.outcome}${status}${error}`;
|
|
22037
23069
|
}).join("\n");
|
|
22038
23070
|
return details ? `LLM Profile fallback chain exhausted.
|
|
22039
23071
|
${details}` : "LLM Profile fallback chain exhausted before a provider request could be made.";
|
|
@@ -22045,7 +23077,7 @@ function buildLLMProfileFallbackSummary(candidates, attempts) {
|
|
|
22045
23077
|
return candidates.map((candidate, profileIndex) => {
|
|
22046
23078
|
var _a;
|
|
22047
23079
|
const profileAttempts = attempts.filter((attempt) => attempt.profileIndex === profileIndex);
|
|
22048
|
-
const identity =
|
|
23080
|
+
const identity = formatCandidateProfileIdentity(candidate, profileIndex);
|
|
22049
23081
|
if (profileAttempts.length === 0) {
|
|
22050
23082
|
return `${identity}: not attempted.`;
|
|
22051
23083
|
}
|
|
@@ -22186,6 +23218,7 @@ function createHealthPermit(params) {
|
|
|
22186
23218
|
roundIndex,
|
|
22187
23219
|
profileIndex,
|
|
22188
23220
|
operationTimeoutMs,
|
|
23221
|
+
executionCorrelationId,
|
|
22189
23222
|
signal,
|
|
22190
23223
|
recordAttempt
|
|
22191
23224
|
} = params;
|
|
@@ -22260,7 +23293,8 @@ function createHealthPermit(params) {
|
|
|
22260
23293
|
identity: candidate.health.identity,
|
|
22261
23294
|
policy: candidate.health.policy,
|
|
22262
23295
|
permitId,
|
|
22263
|
-
outcome
|
|
23296
|
+
outcome,
|
|
23297
|
+
...executionCorrelationId == null ? {} : { executionCorrelationId }
|
|
22264
23298
|
})
|
|
22265
23299
|
});
|
|
22266
23300
|
recordAttempt({
|
|
@@ -22293,9 +23327,11 @@ function createLLMProfileFallbackRunner(params) {
|
|
|
22293
23327
|
const attempts = [];
|
|
22294
23328
|
const recordAttempt = (attempt) => {
|
|
22295
23329
|
var _a;
|
|
22296
|
-
|
|
23330
|
+
const candidate = attempt.profileIndex == null ? void 0 : params.candidates[attempt.profileIndex];
|
|
23331
|
+
const completedAttempt = attempt.profileName == null && (candidate == null ? void 0 : candidate.profileName) != null ? { ...attempt, profileName: candidate.profileName } : attempt;
|
|
23332
|
+
attempts.push(completedAttempt);
|
|
22297
23333
|
try {
|
|
22298
|
-
(_a = params.onAttempt) == null ? void 0 : _a.call(params,
|
|
23334
|
+
(_a = params.onAttempt) == null ? void 0 : _a.call(params, completedAttempt);
|
|
22299
23335
|
} catch {
|
|
22300
23336
|
}
|
|
22301
23337
|
};
|
|
@@ -22381,6 +23417,7 @@ function createLLMProfileFallbackRunner(params) {
|
|
|
22381
23417
|
roundIndex,
|
|
22382
23418
|
profileIndex,
|
|
22383
23419
|
operationTimeoutMs: healthOperationTimeoutMs,
|
|
23420
|
+
executionCorrelationId: roundOptions.context.llmProfileHealthExecutionCorrelationId,
|
|
22384
23421
|
signal: roundOptions.context.signal,
|
|
22385
23422
|
recordAttempt
|
|
22386
23423
|
});
|
|
@@ -22439,6 +23476,7 @@ function createLLMProfileFallbackRunner(params) {
|
|
|
22439
23476
|
...candidateOptions,
|
|
22440
23477
|
profileIndex,
|
|
22441
23478
|
roundIndex,
|
|
23479
|
+
...candidate.profileName == null ? {} : { profileName: candidate.profileName },
|
|
22442
23480
|
...activeHealth == null ? {} : {
|
|
22443
23481
|
profileHealthKey: activeHealth.identity.key,
|
|
22444
23482
|
...healthPermit == null ? {} : { profileHealthState: healthPermit.state }
|
|
@@ -23082,38 +24120,8 @@ function buildLLMChatV2EditorCacheKey(parts) {
|
|
|
23082
24120
|
const { cacheVersion = 3, ...keyParts } = parts;
|
|
23083
24121
|
return (0, import_safe_stable_stringify5.default)({ cacheVersion, ...keyParts }) ?? "";
|
|
23084
24122
|
}
|
|
23085
|
-
function cloneEditorCacheValue(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
23086
|
-
if (value == null || typeof value !== "object") {
|
|
23087
|
-
return value;
|
|
23088
|
-
}
|
|
23089
|
-
if (value instanceof Uint8Array) {
|
|
23090
|
-
return new Uint8Array(value);
|
|
23091
|
-
}
|
|
23092
|
-
const existing = seen.get(value);
|
|
23093
|
-
if (existing != null) {
|
|
23094
|
-
return existing;
|
|
23095
|
-
}
|
|
23096
|
-
if (Array.isArray(value)) {
|
|
23097
|
-
const clone2 = [];
|
|
23098
|
-
seen.set(value, clone2);
|
|
23099
|
-
clone2.push(...value.map((item) => cloneEditorCacheValue(item, seen)));
|
|
23100
|
-
return clone2;
|
|
23101
|
-
}
|
|
23102
|
-
const clone = {};
|
|
23103
|
-
seen.set(value, clone);
|
|
23104
|
-
for (const [key, item] of Object.entries(value)) {
|
|
23105
|
-
clone[key] = cloneEditorCacheValue(item, seen);
|
|
23106
|
-
}
|
|
23107
|
-
return clone;
|
|
23108
|
-
}
|
|
23109
24123
|
function cloneLLMChatV2EditorCacheOutputs(outputs) {
|
|
23110
|
-
|
|
23111
|
-
try {
|
|
23112
|
-
return structuredClone(outputs);
|
|
23113
|
-
} catch {
|
|
23114
|
-
}
|
|
23115
|
-
}
|
|
23116
|
-
return cloneEditorCacheValue(outputs);
|
|
24124
|
+
return cloneLLMChatV2Outputs(outputs);
|
|
23117
24125
|
}
|
|
23118
24126
|
function fingerprintSecret(secret) {
|
|
23119
24127
|
if (!secret) {
|
|
@@ -23351,6 +24359,7 @@ async function resolveLLMChatV2RuntimeConfig(params) {
|
|
|
23351
24359
|
return {
|
|
23352
24360
|
provider: parseChatV2Provider(profile.configuration.provider),
|
|
23353
24361
|
model: profile.configuration.model,
|
|
24362
|
+
...profile.profileName == null ? {} : { profileName: profile.profileName },
|
|
23354
24363
|
...profile.configuration.provider === "custom" ? { customProviderApi: parseCustomProviderApi(profile.configuration.customProviderApi) } : {},
|
|
23355
24364
|
...policy == null ? {} : {
|
|
23356
24365
|
health: {
|
|
@@ -23667,7 +24676,7 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
23667
24676
|
};
|
|
23668
24677
|
}
|
|
23669
24678
|
async process(inputs, context) {
|
|
23670
|
-
var _a, _b, _c, _d;
|
|
24679
|
+
var _a, _b, _c, _d, _e;
|
|
23671
24680
|
const invocationJournal = new LLMInvocationJournal();
|
|
23672
24681
|
let profileAttemptSequence = 0;
|
|
23673
24682
|
const usageTrackingContext = {
|
|
@@ -23703,9 +24712,9 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
23703
24712
|
(_a = context.markResultAsEditorCacheHit) == null ? void 0 : _a.call(context);
|
|
23704
24713
|
return cacheHit;
|
|
23705
24714
|
}
|
|
23706
|
-
let
|
|
24715
|
+
let invocation;
|
|
23707
24716
|
try {
|
|
23708
|
-
|
|
24717
|
+
invocation = await executeLLMInvocation({
|
|
23709
24718
|
context,
|
|
23710
24719
|
journal: invocationJournal,
|
|
23711
24720
|
runtime,
|
|
@@ -23726,6 +24735,7 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
23726
24735
|
}
|
|
23727
24736
|
throw error;
|
|
23728
24737
|
}
|
|
24738
|
+
const { result, terminalSnapshot } = invocation;
|
|
23729
24739
|
projectLLMInvocationResult({
|
|
23730
24740
|
result,
|
|
23731
24741
|
modelCalls: invocationJournal.modelCalls,
|
|
@@ -23734,6 +24744,19 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
23734
24744
|
llmAttempts: invocationJournal.llmAttempts,
|
|
23735
24745
|
profileSummary: (_d = runtime.getProfileSummary) == null ? void 0 : _d.call(runtime)
|
|
23736
24746
|
});
|
|
24747
|
+
if (terminalSnapshot != null) {
|
|
24748
|
+
try {
|
|
24749
|
+
const observerResult = (_e = context.onLLMChatOutputSnapshot) == null ? void 0 : _e.call(context, {
|
|
24750
|
+
...terminalSnapshot,
|
|
24751
|
+
nodeId: context.node.id,
|
|
24752
|
+
processId: context.processId,
|
|
24753
|
+
splitIndex: context.splitIndex ?? 0,
|
|
24754
|
+
outputs: cloneLLMChatV2Outputs(result.commonOutputs)
|
|
24755
|
+
});
|
|
24756
|
+
void Promise.resolve(observerResult).catch(() => void 0);
|
|
24757
|
+
} catch {
|
|
24758
|
+
}
|
|
24759
|
+
}
|
|
23737
24760
|
if (toolCallContinuation && !isChatV2PipelineProviderFailureResult(result) && result.functionCalls.length > 0) {
|
|
23738
24761
|
toolCallContinuation.release();
|
|
23739
24762
|
}
|
|
@@ -23908,7 +24931,7 @@ function getLLMProfileBodySections(data) {
|
|
|
23908
24931
|
|
|
23909
24932
|
// src/model/chat-v2/llmProfileNodeRuntime.ts
|
|
23910
24933
|
function resolveLLMProfileNodeValue(params) {
|
|
23911
|
-
var _a, _b, _c, _d;
|
|
24934
|
+
var _a, _b, _c, _d, _e;
|
|
23912
24935
|
const { data, inputs, context } = params;
|
|
23913
24936
|
const runtimeData = data;
|
|
23914
24937
|
const generation = resolveLLMChatV2GenerationParameters(runtimeData, inputs);
|
|
@@ -23973,17 +24996,21 @@ function resolveLLMProfileNodeValue(params) {
|
|
|
23973
24996
|
useGoogleThinkingBudgetInput: false
|
|
23974
24997
|
};
|
|
23975
24998
|
const projectId = (_d = (_c = context.project) == null ? void 0 : _c.metadata) == null ? void 0 : _d.id;
|
|
24999
|
+
const profileTitle = (_e = context.node) == null ? void 0 : _e.title;
|
|
25000
|
+
const profileName = typeof profileTitle === "string" ? profileTitle.trim() : "";
|
|
23976
25001
|
return {
|
|
23977
25002
|
version: LLM_PROFILE_VALUE_VERSION,
|
|
23978
25003
|
credential,
|
|
23979
25004
|
configuration,
|
|
25005
|
+
...profileName === "" ? {} : { profileName },
|
|
23980
25006
|
...projectId == null ? {} : {
|
|
23981
25007
|
healthIdentity: createRivetLLMProfileHealthIdentity({
|
|
23982
25008
|
configuration,
|
|
23983
25009
|
credential,
|
|
23984
25010
|
chatNodeHeaders: context.settings.chatNodeHeaders,
|
|
23985
25011
|
projectId,
|
|
23986
|
-
profileNodeId: context.node.id
|
|
25012
|
+
profileNodeId: context.node.id,
|
|
25013
|
+
...profileName === "" ? {} : { profileName }
|
|
23987
25014
|
})
|
|
23988
25015
|
}
|
|
23989
25016
|
};
|
|
@@ -24179,16 +25206,17 @@ var PromptNodeImpl = class extends NodeImpl {
|
|
|
24179
25206
|
dataType: "boolean"
|
|
24180
25207
|
});
|
|
24181
25208
|
}
|
|
24182
|
-
const
|
|
25209
|
+
const inputReferences = extractInterpolationVariableReferences(this.data.promptText);
|
|
25210
|
+
const fixedInputIds = new Set(inputs.map((input) => input.id));
|
|
24183
25211
|
inputs = [
|
|
24184
25212
|
...inputs,
|
|
24185
|
-
...(
|
|
25213
|
+
...inputReferences.filter(({ baseName }) => !fixedInputIds.has(baseName)).map(({ baseName, hasPath }) => {
|
|
24186
25214
|
return createInterpolationInputDefinition({
|
|
24187
|
-
interpolationName:
|
|
24188
|
-
dataType: "string",
|
|
25215
|
+
interpolationName: baseName,
|
|
25216
|
+
dataType: hasPath ? "any" : "string",
|
|
24189
25217
|
required: false
|
|
24190
25218
|
});
|
|
24191
|
-
})
|
|
25219
|
+
})
|
|
24192
25220
|
];
|
|
24193
25221
|
return inputs;
|
|
24194
25222
|
}
|
|
@@ -24299,18 +25327,12 @@ var PromptNodeImpl = class extends NodeImpl {
|
|
|
24299
25327
|
};
|
|
24300
25328
|
}
|
|
24301
25329
|
async process(inputs, context) {
|
|
24302
|
-
const inputMap = Object.keys(inputs).reduce(
|
|
24303
|
-
(acc, key) => {
|
|
24304
|
-
acc[key] = coerceTypeOptional(inputs[key], "string") ?? "";
|
|
24305
|
-
return acc;
|
|
24306
|
-
},
|
|
24307
|
-
{}
|
|
24308
|
-
);
|
|
24309
25330
|
let outputValue = interpolate(
|
|
24310
25331
|
this.chartNode.data.promptText,
|
|
24311
|
-
|
|
25332
|
+
inputs,
|
|
24312
25333
|
context.graphInputNodeValues,
|
|
24313
|
-
context.contextValues
|
|
25334
|
+
context.contextValues,
|
|
25335
|
+
{ coerceBareVariableDataValues: true }
|
|
24314
25336
|
);
|
|
24315
25337
|
outputValue = outputValue.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
24316
25338
|
const type = getInputOrData(this.data, inputs, "type", "string");
|
|
@@ -24859,6 +25881,7 @@ var import_ts_dedent10 = require("ts-dedent");
|
|
|
24859
25881
|
|
|
24860
25882
|
// src/model/nodes/jsValueInterpolation.ts
|
|
24861
25883
|
var import_ts_dedent9 = require("ts-dedent");
|
|
25884
|
+
var MISSING_INTERPOLATION_HELPER_MESSAGE = "This CodeRunner must honor CodeRunnerOptions.interpolationHelperIdentifier to resolve JSONPath or @graphInputs/@context interpolation.";
|
|
24862
25885
|
function escapeRegExp2(value) {
|
|
24863
25886
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
24864
25887
|
}
|
|
@@ -24877,34 +25900,39 @@ function getSafeJsValueInterpolationIdentifier(source, baseIdentifier) {
|
|
|
24877
25900
|
function buildJsValuePreview(source, maxLines) {
|
|
24878
25901
|
return source.split("\n").slice(0, maxLines).join("\n").trim();
|
|
24879
25902
|
}
|
|
24880
|
-
function isSpecialReference(inputName) {
|
|
24881
|
-
return inputName.startsWith("@graphInputs.") || inputName.startsWith("@context.");
|
|
24882
|
-
}
|
|
24883
25903
|
function isSimpleIdentifier(value) {
|
|
24884
25904
|
return /^[A-Za-z_$][\w$]*$/.test(value);
|
|
24885
25905
|
}
|
|
24886
25906
|
function getUserFacingInputName(inputName) {
|
|
24887
25907
|
return isSimpleIdentifier(inputName) ? inputName : `{{${inputName}}}`;
|
|
24888
25908
|
}
|
|
24889
|
-
function buildJsValueReference(
|
|
24890
|
-
var _a;
|
|
24891
|
-
if (!
|
|
25909
|
+
function buildJsValueReference(token, interpolationContext, options2) {
|
|
25910
|
+
var _a, _b;
|
|
25911
|
+
if (!token.tokenName || !token.reference) {
|
|
24892
25912
|
return "undefined";
|
|
24893
25913
|
}
|
|
24894
|
-
|
|
24895
|
-
|
|
25914
|
+
const isBareVariableReference = token.reference.source === "variable" && token.reference.jsonPath === void 0;
|
|
25915
|
+
if (isBareVariableReference) {
|
|
25916
|
+
return ((_a = options2.localIdentifiers) == null ? void 0 : _a.has(token.reference.baseName)) ? token.reference.baseName : `${interpolationContext.inputsIdentifier}[${JSON.stringify(token.reference.baseName)}].value`;
|
|
24896
25917
|
}
|
|
24897
|
-
|
|
25918
|
+
const isLocalReference = token.reference.source === "variable" && ((_b = options2.localIdentifiers) == null ? void 0 : _b.has(token.reference.baseName));
|
|
25919
|
+
const sourceInputs = isLocalReference ? `{ ${JSON.stringify(token.reference.baseName)}: { type: 'any', value: ${token.reference.baseName} } }` : interpolationContext.inputsIdentifier;
|
|
25920
|
+
const resolveExpression = `${interpolationContext.interpolationHelperIdentifier}(${sourceInputs}, ${JSON.stringify(
|
|
25921
|
+
token.tokenName
|
|
25922
|
+
)}, ${interpolationContext.graphInputsIdentifier}, ${interpolationContext.contextIdentifier})`;
|
|
25923
|
+
return `(typeof ${interpolationContext.interpolationHelperIdentifier} === 'function'
|
|
25924
|
+
? ${resolveExpression}
|
|
25925
|
+
: (() => { throw new Error(${JSON.stringify(MISSING_INTERPOLATION_HELPER_MESSAGE)}); })())`;
|
|
24898
25926
|
}
|
|
24899
|
-
function formatJsValuePreviewValue(
|
|
24900
|
-
var _a
|
|
24901
|
-
if (!
|
|
25927
|
+
function formatJsValuePreviewValue(token, inputs, options2) {
|
|
25928
|
+
var _a;
|
|
25929
|
+
if (!token.tokenName || !token.reference || token.reference.source !== "variable") {
|
|
24902
25930
|
return "undefined";
|
|
24903
25931
|
}
|
|
24904
|
-
if ((_a = options2.localIdentifiers) == null ? void 0 : _a.has(
|
|
24905
|
-
return
|
|
25932
|
+
if ((_a = options2.localIdentifiers) == null ? void 0 : _a.has(token.reference.baseName)) {
|
|
25933
|
+
return token.reference.jsonPath ? `{{${token.tokenName}}}` : token.reference.baseName;
|
|
24906
25934
|
}
|
|
24907
|
-
const value = (
|
|
25935
|
+
const value = resolveInterpolationExpressionRawValue(token.tokenName, { variables: inputs });
|
|
24908
25936
|
if (value === void 0) {
|
|
24909
25937
|
return "undefined";
|
|
24910
25938
|
}
|
|
@@ -24917,7 +25945,7 @@ function formatJsValuePreviewValue(inputName, inputs, options2) {
|
|
|
24917
25945
|
if (typeof value === "number" || typeof value === "boolean") {
|
|
24918
25946
|
return String(value);
|
|
24919
25947
|
}
|
|
24920
|
-
return getUserFacingInputName(
|
|
25948
|
+
return getUserFacingInputName(token.tokenName);
|
|
24921
25949
|
}
|
|
24922
25950
|
function getJsValueInterpolationInputNames(template, options2 = {}) {
|
|
24923
25951
|
return extractInterpolationVariables(template).filter((inputName) => {
|
|
@@ -24935,22 +25963,53 @@ function getJsValueInterpolationInputDefinitions(template, options2 = {}) {
|
|
|
24935
25963
|
);
|
|
24936
25964
|
}
|
|
24937
25965
|
function getJsValueInterpolationRuntimeContext(template, baseInputsIdentifier, options2 = {}) {
|
|
25966
|
+
const inputsIdentifier = getSafeJsValueInterpolationIdentifier(template, baseInputsIdentifier);
|
|
25967
|
+
const interpolationHelperIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
25968
|
+
`${template}
|
|
25969
|
+
${inputsIdentifier}`,
|
|
25970
|
+
`${baseInputsIdentifier}ResolveInterpolation`
|
|
25971
|
+
);
|
|
25972
|
+
const cloneCacheIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
25973
|
+
`${template}
|
|
25974
|
+
${inputsIdentifier}
|
|
25975
|
+
${interpolationHelperIdentifier}`,
|
|
25976
|
+
`${baseInputsIdentifier}CloneCache`
|
|
25977
|
+
);
|
|
25978
|
+
const graphInputsIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
25979
|
+
`${template}
|
|
25980
|
+
${inputsIdentifier}
|
|
25981
|
+
${interpolationHelperIdentifier}
|
|
25982
|
+
${cloneCacheIdentifier}`,
|
|
25983
|
+
`${baseInputsIdentifier}GraphInputs`
|
|
25984
|
+
);
|
|
25985
|
+
const contextIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
25986
|
+
`${template}
|
|
25987
|
+
${inputsIdentifier}
|
|
25988
|
+
${interpolationHelperIdentifier}
|
|
25989
|
+
${cloneCacheIdentifier}
|
|
25990
|
+
${graphInputsIdentifier}`,
|
|
25991
|
+
`${baseInputsIdentifier}Context`
|
|
25992
|
+
);
|
|
25993
|
+
const parsedTemplate = parseInterpolationTemplate(template);
|
|
24938
25994
|
return {
|
|
24939
25995
|
inputNames: getJsValueInterpolationInputNames(template, options2),
|
|
24940
|
-
inputsIdentifier
|
|
25996
|
+
inputsIdentifier,
|
|
25997
|
+
interpolationHelperIdentifier,
|
|
25998
|
+
cloneCacheIdentifier,
|
|
25999
|
+
graphInputsIdentifier,
|
|
26000
|
+
contextIdentifier,
|
|
26001
|
+
requiresInterpolationHelper: parsedTemplate.tokens.some(
|
|
26002
|
+
(token) => token.reference !== void 0 && (token.reference.source !== "variable" || token.reference.jsonPath !== void 0)
|
|
26003
|
+
)
|
|
24941
26004
|
};
|
|
24942
26005
|
}
|
|
24943
|
-
function buildJsValueInterpolatedSource(template,
|
|
24944
|
-
return replaceInterpolationTokens(
|
|
24945
|
-
|
|
24946
|
-
|
|
24947
|
-
{
|
|
24948
|
-
trim: options2.trim ?? true
|
|
24949
|
-
}
|
|
24950
|
-
);
|
|
26006
|
+
function buildJsValueInterpolatedSource(template, interpolationContext, options2 = {}) {
|
|
26007
|
+
return replaceInterpolationTokens(template, (token) => buildJsValueReference(token, interpolationContext, options2), {
|
|
26008
|
+
trim: options2.trim ?? true
|
|
26009
|
+
});
|
|
24951
26010
|
}
|
|
24952
26011
|
function interpolateJsValuePreviewSource(template, inputs, options2 = {}) {
|
|
24953
|
-
return replaceInterpolationTokens(template, (token) => formatJsValuePreviewValue(token
|
|
26012
|
+
return replaceInterpolationTokens(template, (token) => formatJsValuePreviewValue(token, inputs, options2), {
|
|
24954
26013
|
trim: options2.trim ?? true
|
|
24955
26014
|
});
|
|
24956
26015
|
}
|
|
@@ -25046,50 +26105,86 @@ function buildCloneJsInputValueFunction() {
|
|
|
25046
26105
|
}
|
|
25047
26106
|
function buildClonedInputValueAssignments(inputNames, targetIdentifier, cacheIdentifier) {
|
|
25048
26107
|
return inputNames.map(
|
|
25049
|
-
(inputName) => `${targetIdentifier}[${JSON.stringify(inputName)}] =
|
|
25050
|
-
|
|
25051
|
-
|
|
26108
|
+
(inputName) => `${targetIdentifier}[${JSON.stringify(inputName)}] = (() => {
|
|
26109
|
+
const sourceDataValue = inputs[${JSON.stringify(inputName)}];
|
|
26110
|
+
return sourceDataValue == null
|
|
26111
|
+
? { type: 'any', value: undefined }
|
|
26112
|
+
: { ...sourceDataValue, value: cloneJsInputValue(sourceDataValue.value, ${cacheIdentifier}) };
|
|
26113
|
+
})();`
|
|
25052
26114
|
).join("\n");
|
|
25053
26115
|
}
|
|
25054
26116
|
function buildJsValueInputClonePreamble({
|
|
25055
26117
|
cacheIdentifier,
|
|
26118
|
+
contextIdentifier,
|
|
26119
|
+
graphInputsIdentifier,
|
|
25056
26120
|
inputsIdentifier
|
|
25057
26121
|
}) {
|
|
25058
26122
|
return import_ts_dedent9.dedent`
|
|
25059
26123
|
${buildCloneJsInputValueFunction()}
|
|
25060
26124
|
const ${inputsIdentifier} = Object.create(null);
|
|
25061
26125
|
const ${cacheIdentifier} = new WeakMap();
|
|
26126
|
+
const ${graphInputsIdentifier} = typeof graphInputs === 'undefined'
|
|
26127
|
+
? Object.create(null)
|
|
26128
|
+
: cloneJsInputValue(graphInputs, ${cacheIdentifier});
|
|
26129
|
+
const ${contextIdentifier} = typeof context === 'undefined'
|
|
26130
|
+
? Object.create(null)
|
|
26131
|
+
: cloneJsInputValue(context, ${cacheIdentifier});
|
|
25062
26132
|
`;
|
|
25063
26133
|
}
|
|
25064
26134
|
function buildJsValueInputsInitializer({
|
|
25065
|
-
|
|
25066
|
-
inputNames,
|
|
25067
|
-
inputsIdentifier
|
|
26135
|
+
interpolationContext
|
|
25068
26136
|
}) {
|
|
26137
|
+
const { cloneCacheIdentifier, contextIdentifier, graphInputsIdentifier, inputNames, inputsIdentifier } = interpolationContext;
|
|
25069
26138
|
return import_ts_dedent9.dedent`
|
|
25070
|
-
${buildJsValueInputClonePreamble({
|
|
25071
|
-
|
|
26139
|
+
${buildJsValueInputClonePreamble({
|
|
26140
|
+
cacheIdentifier: cloneCacheIdentifier,
|
|
26141
|
+
contextIdentifier,
|
|
26142
|
+
graphInputsIdentifier,
|
|
26143
|
+
inputsIdentifier
|
|
26144
|
+
})}
|
|
26145
|
+
${buildClonedInputValueAssignments(inputNames, inputsIdentifier, cloneCacheIdentifier)}
|
|
25072
26146
|
`;
|
|
25073
26147
|
}
|
|
25074
|
-
function
|
|
26148
|
+
function getJsValueInterpolationCodeRunnerOptions(options2, interpolationContext) {
|
|
26149
|
+
if (!interpolationContext.requiresInterpolationHelper) {
|
|
26150
|
+
return options2;
|
|
26151
|
+
}
|
|
26152
|
+
return {
|
|
26153
|
+
...options2,
|
|
26154
|
+
interpolationHelperIdentifier: interpolationContext.interpolationHelperIdentifier
|
|
26155
|
+
};
|
|
26156
|
+
}
|
|
26157
|
+
function sanitizeGeneratedJsValueText(text, inputNames, targetIdentifier, fallbackLabel, generatedIdentifiers = []) {
|
|
25075
26158
|
if (!text) {
|
|
25076
26159
|
return text;
|
|
25077
26160
|
}
|
|
25078
26161
|
let sanitized = text;
|
|
26162
|
+
const generatedFallbackLabel = inputNames.length === 1 ? `${fallbackLabel} ${getUserFacingInputName(inputNames[0])}` : fallbackLabel;
|
|
25079
26163
|
for (const inputName of inputNames) {
|
|
25080
26164
|
const userFacingInputName = getUserFacingInputName(inputName);
|
|
25081
26165
|
sanitized = sanitized.replaceAll(`${targetIdentifier}[${JSON.stringify(inputName)}]`, userFacingInputName).replaceAll(`${targetIdentifier}.${inputName}`, userFacingInputName);
|
|
25082
26166
|
}
|
|
25083
|
-
|
|
26167
|
+
for (const identifier of [...generatedIdentifiers].sort((left, right) => right.length - left.length)) {
|
|
26168
|
+
sanitized = sanitized.replaceAll(identifier, generatedFallbackLabel);
|
|
26169
|
+
}
|
|
26170
|
+
sanitized = sanitized.replaceAll(targetIdentifier, fallbackLabel);
|
|
26171
|
+
return sanitized;
|
|
25084
26172
|
}
|
|
25085
|
-
function sanitizeGeneratedJsValueError(error, inputNames, targetIdentifier, fallbackLabel) {
|
|
26173
|
+
function sanitizeGeneratedJsValueError(error, inputNames, targetIdentifier, fallbackLabel, generatedIdentifiers = []) {
|
|
25086
26174
|
const jsValueError = getError(error);
|
|
25087
|
-
jsValueError.message = sanitizeGeneratedJsValueText(
|
|
26175
|
+
jsValueError.message = sanitizeGeneratedJsValueText(
|
|
26176
|
+
jsValueError.message,
|
|
26177
|
+
inputNames,
|
|
26178
|
+
targetIdentifier,
|
|
26179
|
+
fallbackLabel,
|
|
26180
|
+
generatedIdentifiers
|
|
26181
|
+
) ?? jsValueError.message;
|
|
25088
26182
|
jsValueError.stack = sanitizeGeneratedJsValueText(
|
|
25089
26183
|
jsValueError.stack,
|
|
25090
26184
|
inputNames,
|
|
25091
26185
|
targetIdentifier,
|
|
25092
|
-
fallbackLabel
|
|
26186
|
+
fallbackLabel,
|
|
26187
|
+
generatedIdentifiers
|
|
25093
26188
|
);
|
|
25094
26189
|
return jsValueError;
|
|
25095
26190
|
}
|
|
@@ -25105,31 +26200,38 @@ var DEFAULT_CODE_NEW = import_ts_dedent10.dedent`
|
|
|
25105
26200
|
`;
|
|
25106
26201
|
var MAX_BODY_PREVIEW_LINES2 = 15;
|
|
25107
26202
|
var CODE_NEW_INPUTS_IDENTIFIER = "__codeNewInputs";
|
|
25108
|
-
var CODE_NEW_INPUT_CLONE_CACHE_IDENTIFIER = "codeNewInputCloneCache";
|
|
25109
26203
|
var CODE_NEW_OUTPUT_PORT_ID = "output";
|
|
25110
26204
|
function buildCodeNewPreview(code) {
|
|
25111
26205
|
return buildJsValuePreview(code, MAX_BODY_PREVIEW_LINES2);
|
|
25112
26206
|
}
|
|
25113
|
-
function buildCodeNewRuntimeSource(code,
|
|
25114
|
-
return buildJsValueInterpolatedSource(code,
|
|
26207
|
+
function buildCodeNewRuntimeSource(code, interpolationContext) {
|
|
26208
|
+
return buildJsValueInterpolatedSource(code, interpolationContext, { trim: false });
|
|
25115
26209
|
}
|
|
25116
|
-
function buildCodeNewInputsInitializer(
|
|
26210
|
+
function buildCodeNewInputsInitializer(interpolationContext) {
|
|
25117
26211
|
return buildJsValueInputsInitializer({
|
|
25118
|
-
|
|
25119
|
-
inputNames,
|
|
25120
|
-
inputsIdentifier
|
|
26212
|
+
interpolationContext
|
|
25121
26213
|
});
|
|
25122
26214
|
}
|
|
25123
26215
|
function interpolateCodeNewSource(code, inputs) {
|
|
25124
26216
|
return interpolateJsValuePreviewSource(code, inputs, { trim: false });
|
|
25125
26217
|
}
|
|
25126
|
-
function sanitizeCodeNewError(error,
|
|
25127
|
-
return sanitizeGeneratedJsValueError(
|
|
26218
|
+
function sanitizeCodeNewError(error, interpolationContext) {
|
|
26219
|
+
return sanitizeGeneratedJsValueError(
|
|
26220
|
+
error,
|
|
26221
|
+
interpolationContext.inputNames,
|
|
26222
|
+
interpolationContext.inputsIdentifier,
|
|
26223
|
+
"code input",
|
|
26224
|
+
[
|
|
26225
|
+
interpolationContext.cloneCacheIdentifier,
|
|
26226
|
+
interpolationContext.contextIdentifier,
|
|
26227
|
+
interpolationContext.graphInputsIdentifier,
|
|
26228
|
+
interpolationContext.interpolationHelperIdentifier
|
|
26229
|
+
]
|
|
26230
|
+
);
|
|
25128
26231
|
}
|
|
25129
26232
|
function buildCodeNewWrapper(code, interpolationContext) {
|
|
25130
|
-
const { inputNames, inputsIdentifier } = interpolationContext;
|
|
25131
26233
|
const beforeUserCodeLines = [
|
|
25132
|
-
...buildCodeNewInputsInitializer(
|
|
26234
|
+
...buildCodeNewInputsInitializer(interpolationContext).split(/\r?\n/),
|
|
25133
26235
|
"",
|
|
25134
26236
|
"const __codeNewResult = await (async () => {"
|
|
25135
26237
|
];
|
|
@@ -25144,7 +26246,7 @@ function buildCodeNewWrapper(code, interpolationContext) {
|
|
|
25144
26246
|
"};"
|
|
25145
26247
|
];
|
|
25146
26248
|
return {
|
|
25147
|
-
source: [...beforeUserCodeLines, buildCodeNewRuntimeSource(code,
|
|
26249
|
+
source: [...beforeUserCodeLines, buildCodeNewRuntimeSource(code, interpolationContext), ...afterUserCodeLines].join(
|
|
25148
26250
|
"\n"
|
|
25149
26251
|
),
|
|
25150
26252
|
userCodeLineOffset: beforeUserCodeLines.length
|
|
@@ -25229,13 +26331,12 @@ var CodeNewNodeImpl = class extends NodeImpl {
|
|
|
25229
26331
|
async process(inputs, context) {
|
|
25230
26332
|
const sourceUrl = buildCodeNodeSourceUrl(this.chartNode.id);
|
|
25231
26333
|
const interpolationContext = getJsValueInterpolationRuntimeContext(this.data.code, CODE_NEW_INPUTS_IDENTIFIER);
|
|
25232
|
-
const { inputNames, inputsIdentifier } = interpolationContext;
|
|
25233
26334
|
const { source, userCodeLineOffset } = buildCodeNewWrapper(this.data.code, interpolationContext);
|
|
25234
26335
|
try {
|
|
25235
26336
|
const outputs = await context.codeRunner.runCode(
|
|
25236
26337
|
appendCodeNodeSourceUrl(source, sourceUrl),
|
|
25237
26338
|
inputs,
|
|
25238
|
-
ALL_CODE_RUNNER_OPTIONS,
|
|
26339
|
+
getJsValueInterpolationCodeRunnerOptions(ALL_CODE_RUNNER_OPTIONS, interpolationContext),
|
|
25239
26340
|
context.graphInputNodeValues,
|
|
25240
26341
|
context.contextValues
|
|
25241
26342
|
);
|
|
@@ -25249,7 +26350,7 @@ var CodeNewNodeImpl = class extends NodeImpl {
|
|
|
25249
26350
|
sourceUrl,
|
|
25250
26351
|
userCodeLineOffset
|
|
25251
26352
|
});
|
|
25252
|
-
throw sanitizeCodeNewError(enrichedError,
|
|
26353
|
+
throw sanitizeCodeNewError(enrichedError, interpolationContext);
|
|
25253
26354
|
}
|
|
25254
26355
|
}
|
|
25255
26356
|
};
|
|
@@ -25262,32 +26363,39 @@ var CODE_RUNTIME_HELPER_MESSAGE3 = 'Node execution also provides "require" and "
|
|
|
25262
26363
|
var DEFAULT_EXPRESSION = '{{a}} == "123" ? {{b}} : {{c}}';
|
|
25263
26364
|
var MAX_BODY_PREVIEW_LINES3 = 15;
|
|
25264
26365
|
var EXPRESSION_INPUTS_IDENTIFIER = "__expressionInputs";
|
|
25265
|
-
var EXPRESSION_INPUT_CLONE_CACHE_IDENTIFIER = "expressionInputCloneCache";
|
|
25266
26366
|
var EXPRESSION_OUTPUT_PORT_ID = "output";
|
|
25267
26367
|
function buildExpressionPreview(expression) {
|
|
25268
26368
|
return buildJsValuePreview(expression, MAX_BODY_PREVIEW_LINES3);
|
|
25269
26369
|
}
|
|
25270
|
-
function buildExpressionRuntimeSource(expression,
|
|
25271
|
-
return buildJsValueInterpolatedSource(expression,
|
|
26370
|
+
function buildExpressionRuntimeSource(expression, interpolationContext) {
|
|
26371
|
+
return buildJsValueInterpolatedSource(expression, interpolationContext);
|
|
25272
26372
|
}
|
|
25273
|
-
function buildExpressionInputsInitializer(
|
|
26373
|
+
function buildExpressionInputsInitializer(interpolationContext) {
|
|
25274
26374
|
return buildJsValueInputsInitializer({
|
|
25275
|
-
|
|
25276
|
-
inputNames,
|
|
25277
|
-
inputsIdentifier
|
|
26375
|
+
interpolationContext
|
|
25278
26376
|
});
|
|
25279
26377
|
}
|
|
25280
26378
|
function interpolateExpressionSource(expression, inputs) {
|
|
25281
26379
|
return interpolateJsValuePreviewSource(expression, inputs);
|
|
25282
26380
|
}
|
|
25283
|
-
function sanitizeExpressionError(error,
|
|
25284
|
-
return sanitizeGeneratedJsValueError(
|
|
26381
|
+
function sanitizeExpressionError(error, interpolationContext) {
|
|
26382
|
+
return sanitizeGeneratedJsValueError(
|
|
26383
|
+
error,
|
|
26384
|
+
interpolationContext.inputNames,
|
|
26385
|
+
interpolationContext.inputsIdentifier,
|
|
26386
|
+
"expression input",
|
|
26387
|
+
[
|
|
26388
|
+
interpolationContext.cloneCacheIdentifier,
|
|
26389
|
+
interpolationContext.contextIdentifier,
|
|
26390
|
+
interpolationContext.graphInputsIdentifier,
|
|
26391
|
+
interpolationContext.interpolationHelperIdentifier
|
|
26392
|
+
]
|
|
26393
|
+
);
|
|
25285
26394
|
}
|
|
25286
26395
|
function buildExpressionWrapper(expression, interpolationContext) {
|
|
25287
|
-
const
|
|
25288
|
-
const expressionSource = buildExpressionRuntimeSource(expression, inputsIdentifier);
|
|
26396
|
+
const expressionSource = buildExpressionRuntimeSource(expression, interpolationContext);
|
|
25289
26397
|
return import_ts_dedent11.dedent`
|
|
25290
|
-
${buildExpressionInputsInitializer(
|
|
26398
|
+
${buildExpressionInputsInitializer(interpolationContext)}
|
|
25291
26399
|
|
|
25292
26400
|
return {
|
|
25293
26401
|
output: {
|
|
@@ -25365,18 +26473,17 @@ var ExpressionNodeImpl = class extends NodeImpl {
|
|
|
25365
26473
|
this.data.expression,
|
|
25366
26474
|
EXPRESSION_INPUTS_IDENTIFIER
|
|
25367
26475
|
);
|
|
25368
|
-
const { inputNames, inputsIdentifier } = interpolationContext;
|
|
25369
26476
|
const source = buildExpressionWrapper(this.data.expression, interpolationContext);
|
|
25370
26477
|
try {
|
|
25371
26478
|
return await context.codeRunner.runCode(
|
|
25372
26479
|
source,
|
|
25373
26480
|
inputs,
|
|
25374
|
-
ALL_CODE_RUNNER_OPTIONS,
|
|
26481
|
+
getJsValueInterpolationCodeRunnerOptions(ALL_CODE_RUNNER_OPTIONS, interpolationContext),
|
|
25375
26482
|
context.graphInputNodeValues,
|
|
25376
26483
|
context.contextValues
|
|
25377
26484
|
);
|
|
25378
26485
|
} catch (error) {
|
|
25379
|
-
throw sanitizeExpressionError(error,
|
|
26486
|
+
throw sanitizeExpressionError(error, interpolationContext);
|
|
25380
26487
|
}
|
|
25381
26488
|
}
|
|
25382
26489
|
};
|
|
@@ -26599,7 +27706,8 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
26599
27706
|
data: {
|
|
26600
27707
|
graphId: "",
|
|
26601
27708
|
useErrorOutput: false,
|
|
26602
|
-
useAsGraphPartialOutput: false
|
|
27709
|
+
useAsGraphPartialOutput: false,
|
|
27710
|
+
skipUnusedOutputs: false
|
|
26603
27711
|
}
|
|
26604
27712
|
};
|
|
26605
27713
|
return chartNode;
|
|
@@ -26638,6 +27746,12 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
26638
27746
|
type: "toggle",
|
|
26639
27747
|
label: "Use Error Output",
|
|
26640
27748
|
dataKey: "useErrorOutput"
|
|
27749
|
+
},
|
|
27750
|
+
{
|
|
27751
|
+
type: "toggle",
|
|
27752
|
+
label: "Skip unused outputs",
|
|
27753
|
+
dataKey: "skipUnusedOutputs",
|
|
27754
|
+
helperMessage: "Only run branches needed by connected outputs. Skipped branches also skip their side effects and errors. Runs the full subgraph for Run to here, partial-output forwarding, or a connected Error output."
|
|
26641
27755
|
}
|
|
26642
27756
|
];
|
|
26643
27757
|
if (this.data.graphId) {
|
|
@@ -26679,27 +27793,31 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
26679
27793
|
}
|
|
26680
27794
|
const boundary = ((_a = context.getGraphBoundary) == null ? void 0 : _a.call(context, project, this.data.graphId)) ?? getGraphBoundary(project, this.data.graphId);
|
|
26681
27795
|
const inputData = buildGraphBoundaryInputData(boundary, inputs, this.data.inputData);
|
|
26682
|
-
const shouldRunWholeGraph =
|
|
26683
|
-
const
|
|
26684
|
-
if (
|
|
26685
|
-
return
|
|
27796
|
+
const shouldRunWholeGraph = this.data.skipUnusedOutputs !== true || context.isDirectRunTarget || this.data.useAsGraphPartialOutput === true || this.data.useErrorOutput === true && context.activeOutputPortIds.has("error");
|
|
27797
|
+
const requestedGraphOutputIds = shouldRunWholeGraph ? void 0 : boundary.outputs.filter((output) => context.activeOutputPortIds.has(output.portId)).map((output) => output.id);
|
|
27798
|
+
if ((requestedGraphOutputIds == null ? void 0 : requestedGraphOutputIds.length) === 0) {
|
|
27799
|
+
return buildOptimizedSubgraphOutputs(boundary, [], {}, 0, this.data.useErrorOutput);
|
|
26686
27800
|
}
|
|
26687
27801
|
const subGraphProcessor = context.createSubProcessor(this.data.graphId, { signal: context.signal });
|
|
26688
|
-
if (!shouldRunWholeGraph) {
|
|
26689
|
-
subGraphProcessor.runToNodeIds = requestedGraphOutputNodeIds;
|
|
26690
|
-
}
|
|
26691
27802
|
try {
|
|
26692
27803
|
const startTime = Date.now();
|
|
26693
27804
|
const graphOutputs = await subGraphProcessor.processGraph(
|
|
26694
27805
|
context,
|
|
26695
27806
|
inputData,
|
|
26696
|
-
context.contextValues
|
|
27807
|
+
context.contextValues,
|
|
27808
|
+
requestedGraphOutputIds ? { requestedGraphOutputIds } : void 0
|
|
26697
27809
|
);
|
|
26698
|
-
const outputs = shouldRunWholeGraph ? graphOutputs : {
|
|
26699
|
-
...buildExcludedGraphBoundaryOutputs(boundary),
|
|
26700
|
-
...graphOutputs
|
|
26701
|
-
};
|
|
26702
27810
|
const duration = Date.now() - startTime;
|
|
27811
|
+
if (requestedGraphOutputIds) {
|
|
27812
|
+
return buildOptimizedSubgraphOutputs(
|
|
27813
|
+
boundary,
|
|
27814
|
+
requestedGraphOutputIds,
|
|
27815
|
+
graphOutputs,
|
|
27816
|
+
duration,
|
|
27817
|
+
this.data.useErrorOutput
|
|
27818
|
+
);
|
|
27819
|
+
}
|
|
27820
|
+
const outputs = graphOutputs;
|
|
26703
27821
|
if (this.data.useErrorOutput) {
|
|
26704
27822
|
outputs["error"] = {
|
|
26705
27823
|
type: "control-flow-excluded",
|
|
@@ -26727,28 +27845,33 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
26727
27845
|
}
|
|
26728
27846
|
};
|
|
26729
27847
|
var subGraphNode = nodeDefinition(SubGraphNodeImpl, "Subgraph");
|
|
26730
|
-
function
|
|
27848
|
+
function buildOptimizedSubgraphOutputs(boundary, requestedOutputIds, graphOutputs, duration, useErrorOutput) {
|
|
26731
27849
|
const outputs = buildExcludedGraphBoundaryOutputs(boundary);
|
|
27850
|
+
for (const outputId of requestedOutputIds) {
|
|
27851
|
+
if (Object.hasOwn(graphOutputs, outputId)) {
|
|
27852
|
+
outputs[outputId] = graphOutputs[outputId];
|
|
27853
|
+
} else {
|
|
27854
|
+
delete outputs[outputId];
|
|
27855
|
+
}
|
|
27856
|
+
}
|
|
26732
27857
|
if (useErrorOutput) {
|
|
26733
27858
|
outputs["error"] = {
|
|
26734
27859
|
type: "control-flow-excluded",
|
|
26735
27860
|
value: void 0
|
|
26736
27861
|
};
|
|
26737
27862
|
}
|
|
26738
|
-
outputs
|
|
26739
|
-
type: "number",
|
|
26740
|
-
|
|
26741
|
-
|
|
26742
|
-
|
|
26743
|
-
|
|
26744
|
-
value: 0
|
|
26745
|
-
};
|
|
27863
|
+
if (!boundary.outputs.some((output) => output.id === "cost")) {
|
|
27864
|
+
outputs["cost"] = graphOutputs["cost"] ?? { type: "number", value: 0 };
|
|
27865
|
+
}
|
|
27866
|
+
if (!boundary.outputs.some((output) => output.id === "duration")) {
|
|
27867
|
+
outputs["duration"] = { type: "number", value: duration };
|
|
27868
|
+
}
|
|
26746
27869
|
return outputs;
|
|
26747
27870
|
}
|
|
26748
27871
|
|
|
26749
27872
|
// src/model/nodes/ArrayNode.ts
|
|
26750
27873
|
var import_non_secure27 = require("nanoid/non-secure");
|
|
26751
|
-
var
|
|
27874
|
+
var import_lodash_es7 = require("lodash");
|
|
26752
27875
|
var import_ts_dedent21 = require("ts-dedent");
|
|
26753
27876
|
|
|
26754
27877
|
// src/model/nodes/variadicPortIndex.ts
|
|
@@ -26876,7 +27999,7 @@ var ArrayNodeImpl = class extends NodeImpl {
|
|
|
26876
27999
|
if (Array.isArray(input == null ? void 0 : input.value)) {
|
|
26877
28000
|
for (const value of (input == null ? void 0 : input.value) ?? []) {
|
|
26878
28001
|
if (this.data.flattenDeep) {
|
|
26879
|
-
outputArray.push(...Array.isArray(value) ? (0,
|
|
28002
|
+
outputArray.push(...Array.isArray(value) ? (0, import_lodash_es7.flattenDeep)(value) : [value]);
|
|
26880
28003
|
} else {
|
|
26881
28004
|
outputArray.push(value);
|
|
26882
28005
|
}
|
|
@@ -27033,7 +28156,7 @@ function createMatchedOutput(value) {
|
|
|
27033
28156
|
|
|
27034
28157
|
// src/model/nodes/AssemblePromptNode.ts
|
|
27035
28158
|
var import_non_secure29 = require("nanoid/non-secure");
|
|
27036
|
-
var
|
|
28159
|
+
var import_lodash_es8 = require("lodash");
|
|
27037
28160
|
var import_ts_dedent23 = require("ts-dedent");
|
|
27038
28161
|
var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
27039
28162
|
static create() {
|
|
@@ -27126,7 +28249,7 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
27126
28249
|
const output = {};
|
|
27127
28250
|
const isLastMessageCacheBreakpoint = getInputOrData(this.data, inputs, "isLastMessageCacheBreakpoint", "boolean");
|
|
27128
28251
|
const outMessages = [];
|
|
27129
|
-
const inputMessages = (0,
|
|
28252
|
+
const inputMessages = (0, import_lodash_es8.orderBy)(
|
|
27130
28253
|
Object.entries(inputs).filter(([key]) => key.startsWith("message")),
|
|
27131
28254
|
([key]) => key,
|
|
27132
28255
|
"asc"
|
|
@@ -27171,7 +28294,6 @@ var assemblePromptNode = nodeDefinition(AssemblePromptNodeImpl, "Assemble Prompt
|
|
|
27171
28294
|
// src/model/nodes/ExtractYamlNode.ts
|
|
27172
28295
|
var import_non_secure30 = require("nanoid/non-secure");
|
|
27173
28296
|
var import_yaml = __toESM(require("yaml"), 1);
|
|
27174
|
-
var import_jsonpath_plus = require("jsonpath-plus");
|
|
27175
28297
|
var import_ts_dedent24 = require("ts-dedent");
|
|
27176
28298
|
var ExtractYamlNodeImpl = class extends NodeImpl {
|
|
27177
28299
|
static create() {
|
|
@@ -27320,9 +28442,9 @@ var ExtractYamlNodeImpl = class extends NodeImpl {
|
|
|
27320
28442
|
let matches = [];
|
|
27321
28443
|
if (objectPath) {
|
|
27322
28444
|
try {
|
|
27323
|
-
const extractedValue = (
|
|
27324
|
-
matches = extractedValue;
|
|
27325
|
-
yamlObject =
|
|
28445
|
+
const extractedValue = evaluateJsonPath(yamlObject, objectPath, true);
|
|
28446
|
+
matches = extractedValue == null ? [] : extractedValue;
|
|
28447
|
+
yamlObject = matches.length > 0 ? matches[0] : void 0;
|
|
27326
28448
|
} catch (err) {
|
|
27327
28449
|
return {
|
|
27328
28450
|
["noMatch"]: {
|
|
@@ -27344,7 +28466,7 @@ var ExtractYamlNodeImpl = class extends NodeImpl {
|
|
|
27344
28466
|
["output"]: yamlObject === void 0 ? {
|
|
27345
28467
|
type: "control-flow-excluded",
|
|
27346
28468
|
value: void 0
|
|
27347
|
-
} :
|
|
28469
|
+
} : objectPath ? {
|
|
27348
28470
|
type: "any",
|
|
27349
28471
|
value: yamlObject
|
|
27350
28472
|
} : {
|
|
@@ -27666,7 +28788,7 @@ var trimChatMessagesNode = nodeDefinition(TrimChatMessagesNodeImpl, "Trim Chat M
|
|
|
27666
28788
|
|
|
27667
28789
|
// src/model/nodes/ExternalCallNode.ts
|
|
27668
28790
|
var import_non_secure33 = require("nanoid/non-secure");
|
|
27669
|
-
var
|
|
28791
|
+
var import_lodash_es9 = require("lodash");
|
|
27670
28792
|
var import_ts_dedent27 = require("ts-dedent");
|
|
27671
28793
|
var ExternalCallNodeImpl = class extends NodeImpl {
|
|
27672
28794
|
static create() {
|
|
@@ -27761,7 +28883,7 @@ var ExternalCallNodeImpl = class extends NodeImpl {
|
|
|
27761
28883
|
}
|
|
27762
28884
|
}
|
|
27763
28885
|
const fn = context.externalFunctions[functionName];
|
|
27764
|
-
const externalContext = (0,
|
|
28886
|
+
const externalContext = (0, import_lodash_es9.omit)(context, ["setGlobal"]);
|
|
27765
28887
|
if (!fn) {
|
|
27766
28888
|
if (this.data.useErrorOutput) {
|
|
27767
28889
|
return {
|
|
@@ -27815,7 +28937,6 @@ var externalCallNode = nodeDefinition(ExternalCallNodeImpl, "External Call");
|
|
|
27815
28937
|
|
|
27816
28938
|
// src/model/nodes/ExtractObjectPathNode.ts
|
|
27817
28939
|
var import_non_secure34 = require("nanoid/non-secure");
|
|
27818
|
-
var import_jsonpath_plus2 = require("jsonpath-plus");
|
|
27819
28940
|
var import_ts_dedent28 = require("ts-dedent");
|
|
27820
28941
|
var RESERVED_INPUT_IDS = /* @__PURE__ */ new Set(["object"]);
|
|
27821
28942
|
function getExtractObjectPathInterpolationInputNames(path) {
|
|
@@ -27937,7 +29058,7 @@ var ExtractObjectPathNodeImpl = class extends NodeImpl {
|
|
|
27937
29058
|
const inputPath = usePathInput ? rawPath.trim() : interpolateExtractObjectPathSource(rawPath, inputs, context.graphInputNodeValues, context.contextValues);
|
|
27938
29059
|
let matches;
|
|
27939
29060
|
try {
|
|
27940
|
-
const match9 = (
|
|
29061
|
+
const match9 = evaluateJsonPath(inputObject, inputPath, true);
|
|
27941
29062
|
matches = match9 == null ? [] : match9;
|
|
27942
29063
|
} catch (err) {
|
|
27943
29064
|
matches = [];
|
|
@@ -29285,6 +30406,18 @@ var waitForEventNode = nodeDefinition(WaitForEventNodeImpl, "Wait For Event");
|
|
|
29285
30406
|
// src/model/nodes/ToolNode.ts
|
|
29286
30407
|
var import_non_secure49 = require("nanoid/non-secure");
|
|
29287
30408
|
var import_ts_dedent41 = require("ts-dedent");
|
|
30409
|
+
var TOOL_NODE_BODY_PREVIEW_MAX_LINES = 14;
|
|
30410
|
+
function getToolNodeBodyPreview(data) {
|
|
30411
|
+
const [name = "", ...descriptionLines] = buildNodeBodyPreview(
|
|
30412
|
+
`${data.name}
|
|
30413
|
+
${data.description}`,
|
|
30414
|
+
TOOL_NODE_BODY_PREVIEW_MAX_LINES
|
|
30415
|
+
).split("\n");
|
|
30416
|
+
return {
|
|
30417
|
+
name,
|
|
30418
|
+
description: descriptionLines.join("\n")
|
|
30419
|
+
};
|
|
30420
|
+
}
|
|
29288
30421
|
var GptFunctionNodeImpl = class extends NodeImpl {
|
|
29289
30422
|
static create() {
|
|
29290
30423
|
const chartNode = {
|
|
@@ -29335,17 +30468,17 @@ var GptFunctionNodeImpl = class extends NodeImpl {
|
|
|
29335
30468
|
description: "The schema of the tool that the LLM will see as available to call"
|
|
29336
30469
|
});
|
|
29337
30470
|
}
|
|
29338
|
-
const
|
|
30471
|
+
const inputReferences = this.data.useSchemaInput ? [] : extractInterpolationVariableReferences(this.data.schema);
|
|
29339
30472
|
inputs = [
|
|
29340
30473
|
...inputs,
|
|
29341
|
-
...(
|
|
30474
|
+
...inputReferences.map(({ baseName, hasPath }) => {
|
|
29342
30475
|
return createInterpolationInputDefinition({
|
|
29343
|
-
id: `input-${
|
|
29344
|
-
interpolationName:
|
|
29345
|
-
dataType: "string",
|
|
29346
|
-
description: `An interpolated value in the schema named '${
|
|
30476
|
+
id: `input-${baseName}`,
|
|
30477
|
+
interpolationName: baseName,
|
|
30478
|
+
dataType: hasPath ? "any" : "string",
|
|
30479
|
+
description: `An interpolated value in the schema named '${baseName}'`
|
|
29347
30480
|
});
|
|
29348
|
-
})
|
|
30481
|
+
})
|
|
29349
30482
|
];
|
|
29350
30483
|
return inputs;
|
|
29351
30484
|
}
|
|
@@ -29417,10 +30550,12 @@ var GptFunctionNodeImpl = class extends NodeImpl {
|
|
|
29417
30550
|
];
|
|
29418
30551
|
}
|
|
29419
30552
|
getBody() {
|
|
30553
|
+
const preview = getToolNodeBodyPreview(this.data);
|
|
29420
30554
|
return {
|
|
29421
|
-
type: "
|
|
29422
|
-
|
|
29423
|
-
|
|
30555
|
+
type: "colorized",
|
|
30556
|
+
language: "prompt-interpolation-markdown",
|
|
30557
|
+
theme: "prompt-interpolation",
|
|
30558
|
+
text: [preview.name, preview.description].filter(Boolean).join("\n")
|
|
29424
30559
|
};
|
|
29425
30560
|
}
|
|
29426
30561
|
static getUIData() {
|
|
@@ -29433,7 +30568,7 @@ ${this.data.description}`
|
|
|
29433
30568
|
group: ["AI"]
|
|
29434
30569
|
};
|
|
29435
30570
|
}
|
|
29436
|
-
async process(inputs) {
|
|
30571
|
+
async process(inputs, context) {
|
|
29437
30572
|
const name = getInputOrData(this.data, inputs, "name");
|
|
29438
30573
|
const description = getInputOrData(this.data, inputs, "description");
|
|
29439
30574
|
const resultHandling = this.data.resultHandling === "return-direct" ? "return-direct" : "continue";
|
|
@@ -29441,16 +30576,21 @@ ${this.data.description}`
|
|
|
29441
30576
|
if (this.data.useSchemaInput) {
|
|
29442
30577
|
schema = coerceType(inputs["schema"], "object");
|
|
29443
30578
|
} else {
|
|
29444
|
-
const inputMap = keys(inputs).filter((key) => key.startsWith("input")).reduce(
|
|
30579
|
+
const inputMap = keys(inputs).filter((key) => key.startsWith("input-")).reduce(
|
|
29445
30580
|
(acc, key) => {
|
|
29446
|
-
const stringValue = coerceTypeOptional(inputs[key], "string") ?? "";
|
|
29447
30581
|
const interpolationKey = key.slice("input-".length);
|
|
29448
|
-
acc[interpolationKey] =
|
|
30582
|
+
acc[interpolationKey] = inputs[key];
|
|
29449
30583
|
return acc;
|
|
29450
30584
|
},
|
|
29451
30585
|
{}
|
|
29452
30586
|
);
|
|
29453
|
-
const interpolated = interpolate(
|
|
30587
|
+
const interpolated = interpolate(
|
|
30588
|
+
this.data.schema,
|
|
30589
|
+
inputMap,
|
|
30590
|
+
context == null ? void 0 : context.graphInputNodeValues,
|
|
30591
|
+
context == null ? void 0 : context.contextValues,
|
|
30592
|
+
{ coerceBareVariableDataValues: true }
|
|
30593
|
+
);
|
|
29454
30594
|
schema = JSON.parse(interpolated);
|
|
29455
30595
|
}
|
|
29456
30596
|
return {
|
|
@@ -31027,7 +32167,7 @@ var joinNode = nodeDefinition(JoinNodeImpl, "Coalesce");
|
|
|
31027
32167
|
|
|
31028
32168
|
// src/model/nodes/FilterNode.ts
|
|
31029
32169
|
var import_non_secure65 = require("nanoid/non-secure");
|
|
31030
|
-
var
|
|
32170
|
+
var import_lodash_es10 = require("lodash");
|
|
31031
32171
|
var import_ts_dedent56 = require("ts-dedent");
|
|
31032
32172
|
var FilterNodeImpl = class extends NodeImpl {
|
|
31033
32173
|
static create() {
|
|
@@ -31083,7 +32223,7 @@ var FilterNodeImpl = class extends NodeImpl {
|
|
|
31083
32223
|
var _a;
|
|
31084
32224
|
const array = coerceType(inputs["array"], "any[]");
|
|
31085
32225
|
const include = coerceType(inputs["include"], "boolean[]");
|
|
31086
|
-
const zipped = (0,
|
|
32226
|
+
const zipped = (0, import_lodash_es10.zip)(array, include);
|
|
31087
32227
|
const filtered = zipped.filter(([_, include2]) => include2).map(([value, _]) => value);
|
|
31088
32228
|
return {
|
|
31089
32229
|
["filtered"]: {
|
|
@@ -31105,7 +32245,6 @@ var MAX_CALLBACK_PREVIEW_BODY_LINES = 13;
|
|
|
31105
32245
|
var JS_LIST_CALLBACK_SIGNATURE = "(item, index, array)";
|
|
31106
32246
|
var JS_LIST_CALLBACK_LOCAL_NAMES = /* @__PURE__ */ new Set(["item", "index", "array"]);
|
|
31107
32247
|
var JS_LIST_INPUTS_IDENTIFIER = "__jsListInputs";
|
|
31108
|
-
var JS_LIST_INPUT_CLONE_CACHE_IDENTIFIER = "jsListInputCloneCache";
|
|
31109
32248
|
var JS_LIST_CODE_RUNNER_OPTIONS = {
|
|
31110
32249
|
includeFetch: false,
|
|
31111
32250
|
includeRequire: false,
|
|
@@ -31130,31 +32269,43 @@ function buildJSListRuntimePreamble(interpolationContext) {
|
|
|
31130
32269
|
return import_ts_dedent57.dedent`
|
|
31131
32270
|
const assertSynchronousCallbackResult = ${assertSynchronousCallbackResult.toString()};
|
|
31132
32271
|
${buildJsValueInputClonePreamble({
|
|
31133
|
-
cacheIdentifier:
|
|
32272
|
+
cacheIdentifier: interpolationContext.cloneCacheIdentifier,
|
|
32273
|
+
contextIdentifier: interpolationContext.contextIdentifier,
|
|
32274
|
+
graphInputsIdentifier: interpolationContext.graphInputsIdentifier,
|
|
31134
32275
|
inputsIdentifier: interpolationContext.inputsIdentifier
|
|
31135
32276
|
})}
|
|
31136
|
-
const array = cloneJsInputValue(inputs.array?.value, ${
|
|
32277
|
+
const array = cloneJsInputValue(inputs.array?.value, ${interpolationContext.cloneCacheIdentifier});
|
|
31137
32278
|
${buildClonedInputValueAssignments(
|
|
31138
32279
|
interpolationContext.inputNames,
|
|
31139
32280
|
interpolationContext.inputsIdentifier,
|
|
31140
|
-
|
|
32281
|
+
interpolationContext.cloneCacheIdentifier
|
|
31141
32282
|
)}
|
|
31142
32283
|
`;
|
|
31143
32284
|
}
|
|
31144
|
-
function buildJSListCallbackRuntimeSource(callbackBody,
|
|
31145
|
-
return buildJsValueInterpolatedSource(callbackBody,
|
|
32285
|
+
function buildJSListCallbackRuntimeSource(callbackBody, interpolationContext) {
|
|
32286
|
+
return buildJsValueInterpolatedSource(callbackBody, interpolationContext, {
|
|
31146
32287
|
localIdentifiers: JS_LIST_CALLBACK_LOCAL_NAMES
|
|
31147
32288
|
});
|
|
31148
32289
|
}
|
|
31149
32290
|
function sanitizeJSListError(error, callbackBody, nodeName) {
|
|
31150
|
-
const
|
|
32291
|
+
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
31151
32292
|
const fallbackLabel = `${nodeName} input`;
|
|
31152
|
-
return sanitizeGeneratedJsValueError(
|
|
32293
|
+
return sanitizeGeneratedJsValueError(
|
|
32294
|
+
error,
|
|
32295
|
+
interpolationContext.inputNames,
|
|
32296
|
+
interpolationContext.inputsIdentifier,
|
|
32297
|
+
fallbackLabel,
|
|
32298
|
+
[
|
|
32299
|
+
interpolationContext.cloneCacheIdentifier,
|
|
32300
|
+
interpolationContext.contextIdentifier,
|
|
32301
|
+
interpolationContext.graphInputsIdentifier,
|
|
32302
|
+
interpolationContext.interpolationHelperIdentifier
|
|
32303
|
+
]
|
|
32304
|
+
);
|
|
31153
32305
|
}
|
|
31154
32306
|
function buildJSFilterWrapper(callbackBody) {
|
|
31155
32307
|
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
31156
|
-
const
|
|
31157
|
-
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, inputsIdentifier);
|
|
32308
|
+
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, interpolationContext);
|
|
31158
32309
|
return import_ts_dedent57.dedent`
|
|
31159
32310
|
${buildJSListRuntimePreamble(interpolationContext)}
|
|
31160
32311
|
|
|
@@ -31190,8 +32341,7 @@ function buildJSFilterWrapper(callbackBody) {
|
|
|
31190
32341
|
}
|
|
31191
32342
|
function buildJSMapWrapper(callbackBody) {
|
|
31192
32343
|
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
31193
|
-
const
|
|
31194
|
-
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, inputsIdentifier);
|
|
32344
|
+
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, interpolationContext);
|
|
31195
32345
|
return import_ts_dedent57.dedent`
|
|
31196
32346
|
${buildJSListRuntimePreamble(interpolationContext)}
|
|
31197
32347
|
|
|
@@ -31244,7 +32394,7 @@ function getJSListEditors() {
|
|
|
31244
32394
|
type: "code",
|
|
31245
32395
|
label: "Callback Body",
|
|
31246
32396
|
helperMessage: "(item, index, array) => {",
|
|
31247
|
-
postEditorHelperMessage: "};\n\n//Use {{var}} to create input ports
|
|
32397
|
+
postEditorHelperMessage: "};\n\n//Use {{var}} to create input ports. {{config.limit.max}} creates only config; {{item.name}} and {{array[0]}} use callback locals.",
|
|
31248
32398
|
dataKey: "callbackBody",
|
|
31249
32399
|
language: "javascript",
|
|
31250
32400
|
interpolationSyntax: "js-value",
|
|
@@ -31291,7 +32441,10 @@ async function runJSListNodeCode({
|
|
|
31291
32441
|
const outputs = await context.codeRunner.runCode(
|
|
31292
32442
|
buildWrapper(callbackBody),
|
|
31293
32443
|
inputs,
|
|
31294
|
-
|
|
32444
|
+
getJsValueInterpolationCodeRunnerOptions(
|
|
32445
|
+
JS_LIST_CODE_RUNNER_OPTIONS,
|
|
32446
|
+
getJSListInterpolationContext(callbackBody)
|
|
32447
|
+
),
|
|
31295
32448
|
context.graphInputNodeValues,
|
|
31296
32449
|
context.contextValues
|
|
31297
32450
|
);
|
|
@@ -31346,7 +32499,9 @@ var JSFilterNodeImpl = class extends NodeImpl {
|
|
|
31346
32499
|
|
|
31347
32500
|
Available callback parameters are <code>item</code>, <code>index</code>, and <code>array</code>.
|
|
31348
32501
|
Write only the callback body and still use <code>return</code> to decide whether each item is included.
|
|
31349
|
-
Use <code>{{var}}</code> to add input ports that evaluate as connected values.
|
|
32502
|
+
Use <code>{{var}}</code> to add input ports that evaluate as connected values. A path such as
|
|
32503
|
+
<code>{{config.limit.max}}</code> creates only <code>config</code>; <code>{{item.name}}</code> and
|
|
32504
|
+
<code>{{array[0]}}</code> use callback locals and do not add ports.
|
|
31350
32505
|
`,
|
|
31351
32506
|
infoBoxTitle: "JS Filter Node",
|
|
31352
32507
|
contextMenuTitle: "JS Filter",
|
|
@@ -31412,7 +32567,9 @@ var JSMapNodeImpl = class extends NodeImpl {
|
|
|
31412
32567
|
|
|
31413
32568
|
Available callback parameters are <code>item</code>, <code>index</code>, and <code>array</code>.
|
|
31414
32569
|
Write only the callback body and still use <code>return</code> to produce each mapped item.
|
|
31415
|
-
Use <code>{{var}}</code> to add input ports that evaluate as connected values.
|
|
32570
|
+
Use <code>{{var}}</code> to add input ports that evaluate as connected values. A path such as
|
|
32571
|
+
<code>{{config.limit.max}}</code> creates only <code>config</code>; <code>{{item.name}}</code> and
|
|
32572
|
+
<code>{{array[0]}}</code> use callback locals and do not add ports.
|
|
31416
32573
|
`,
|
|
31417
32574
|
infoBoxTitle: "JS Map Node",
|
|
31418
32575
|
contextMenuTitle: "JS Map",
|
|
@@ -31546,33 +32703,25 @@ var ObjectNodeImpl = class extends NodeImpl {
|
|
|
31546
32703
|
}
|
|
31547
32704
|
interpolate(baseString, values2, graphInputNodeValues, contextValues) {
|
|
31548
32705
|
const protectedBaseString = protectEscapedInterpolationTokens(baseString);
|
|
31549
|
-
const
|
|
31550
|
-
if (
|
|
32706
|
+
const parsedTemplate = parseInterpolationTemplate(protectedBaseString);
|
|
32707
|
+
if (parsedTemplate.tokens.length === 0) {
|
|
31551
32708
|
return restoreEscapedInterpolationTokens(protectedBaseString);
|
|
31552
32709
|
}
|
|
31553
32710
|
let result = "";
|
|
31554
32711
|
let cursor = 0;
|
|
31555
|
-
for (const
|
|
32712
|
+
for (const token of parsedTemplate.tokens) {
|
|
32713
|
+
const tokenSpan = token.span;
|
|
31556
32714
|
const isInsideString = isInsideJsonString(protectedBaseString, tokenSpan.start);
|
|
31557
32715
|
const isWholeQuotedToken = isInsideString && isUnescapedQuoteAt(protectedBaseString, tokenSpan.start - 1) && isUnescapedQuoteAt(protectedBaseString, tokenSpan.end);
|
|
31558
32716
|
const replacementStart = isWholeQuotedToken ? tokenSpan.start - 1 : tokenSpan.start;
|
|
31559
32717
|
const replacementEnd = isWholeQuotedToken ? tokenSpan.end + 1 : tokenSpan.end;
|
|
31560
|
-
const
|
|
31561
|
-
|
|
31562
|
-
|
|
31563
|
-
|
|
31564
|
-
|
|
31565
|
-
|
|
31566
|
-
|
|
31567
|
-
trimmedKey.substring(graphInputPrefix.length),
|
|
31568
|
-
"graphInputs"
|
|
31569
|
-
);
|
|
31570
|
-
} else if (trimmedKey.startsWith(contextPrefix) && contextValues) {
|
|
31571
|
-
value = resolveExpressionRawValue(contextValues, trimmedKey.substring(contextPrefix.length), "context");
|
|
31572
|
-
} else {
|
|
31573
|
-
value = values2[trimmedKey];
|
|
31574
|
-
}
|
|
31575
|
-
result += protectedBaseString.slice(cursor, replacementStart);
|
|
32718
|
+
const value = token.reference ? resolveInterpolationExpressionRawValue(token.reference, {
|
|
32719
|
+
variables: values2,
|
|
32720
|
+
graphInputValues: graphInputNodeValues,
|
|
32721
|
+
contextValues,
|
|
32722
|
+
unwrapVariableDataValues: false
|
|
32723
|
+
}) : void 0;
|
|
32724
|
+
result += restoreEscapedInterpolationTokens(protectedBaseString.slice(cursor, replacementStart));
|
|
31576
32725
|
if (isInsideString && !isWholeQuotedToken) {
|
|
31577
32726
|
result += stringifyEmbeddedJsonStringFragment(value);
|
|
31578
32727
|
} else if (isWholeQuotedToken) {
|
|
@@ -31582,8 +32731,8 @@ var ObjectNodeImpl = class extends NodeImpl {
|
|
|
31582
32731
|
}
|
|
31583
32732
|
cursor = replacementEnd;
|
|
31584
32733
|
}
|
|
31585
|
-
result += protectedBaseString.slice(cursor);
|
|
31586
|
-
return
|
|
32734
|
+
result += restoreEscapedInterpolationTokens(protectedBaseString.slice(cursor));
|
|
32735
|
+
return result;
|
|
31587
32736
|
}
|
|
31588
32737
|
async process(inputs, context) {
|
|
31589
32738
|
const inputMap = Object.keys(inputs).reduce(
|
|
@@ -31686,7 +32835,7 @@ var booleanNode = nodeDefinition(BooleanNodeImpl, "Boolean");
|
|
|
31686
32835
|
|
|
31687
32836
|
// src/model/nodes/CompareNode.ts
|
|
31688
32837
|
var import_non_secure70 = require("nanoid/non-secure");
|
|
31689
|
-
var
|
|
32838
|
+
var import_lodash_es11 = require("lodash");
|
|
31690
32839
|
var import_ts_pattern4 = require("ts-pattern");
|
|
31691
32840
|
var import_ts_dedent62 = require("ts-dedent");
|
|
31692
32841
|
var compareNodeComparisonFunctionOptions = [
|
|
@@ -31800,7 +32949,7 @@ var CompareNodeImpl = class extends NodeImpl {
|
|
|
31800
32949
|
return {
|
|
31801
32950
|
["output"]: {
|
|
31802
32951
|
type: "boolean",
|
|
31803
|
-
value: (0, import_ts_pattern4.match)(comparisonFunction).with("==", () => (0,
|
|
32952
|
+
value: (0, import_ts_pattern4.match)(comparisonFunction).with("==", () => (0, import_lodash_es11.isEqual)(value1, value2)).with("!=", () => !(0, import_lodash_es11.isEqual)(value1, value2)).with("<", () => compareValues(value1, value2)["<"]).with(">", () => compareValues(value1, value2)[">"]).with("<=", () => compareValues(value1, value2)["<="]).with(">=", () => compareValues(value1, value2)[">="]).with("and", () => !!(value1 && value2)).with("or", () => !!(value1 || value2)).with("xor", () => !!(value1 ? !value2 : value2)).with("nand", () => !(value1 && value2)).with("nor", () => !(value1 || value2)).with("xnor", () => !(value1 ? !value2 : value2)).exhaustive()
|
|
31804
32953
|
}
|
|
31805
32954
|
};
|
|
31806
32955
|
}
|
|
@@ -32120,7 +33269,7 @@ var randomNumberNode = nodeDefinition(RandomNumberNodeImpl, "Random number");
|
|
|
32120
33269
|
|
|
32121
33270
|
// src/model/nodes/ShuffleNode.ts
|
|
32122
33271
|
var import_non_secure74 = require("nanoid/non-secure");
|
|
32123
|
-
var
|
|
33272
|
+
var import_lodash_es12 = require("lodash");
|
|
32124
33273
|
var import_ts_dedent66 = require("ts-dedent");
|
|
32125
33274
|
var ShuffleNodeImpl = class extends NodeImpl {
|
|
32126
33275
|
static create() {
|
|
@@ -32169,7 +33318,7 @@ var ShuffleNodeImpl = class extends NodeImpl {
|
|
|
32169
33318
|
var _a;
|
|
32170
33319
|
const input = inputs["array"];
|
|
32171
33320
|
const items = input ? isArrayDataValue(input) ? input.value : [input.value] : [];
|
|
32172
|
-
const shuffled = (0,
|
|
33321
|
+
const shuffled = (0, import_lodash_es12.shuffle)(items);
|
|
32173
33322
|
return {
|
|
32174
33323
|
["shuffled"]: {
|
|
32175
33324
|
type: ((_a = inputs["array"]) == null ? void 0 : _a.type) ?? "any[]",
|
|
@@ -33909,7 +35058,7 @@ var extractMarkdownCodeBlocksNode = nodeDefinition(
|
|
|
33909
35058
|
|
|
33910
35059
|
// src/model/nodes/AssembleMessageNode.ts
|
|
33911
35060
|
var import_non_secure83 = require("nanoid/non-secure");
|
|
33912
|
-
var
|
|
35061
|
+
var import_lodash_es13 = require("lodash");
|
|
33913
35062
|
var import_ts_pattern6 = require("ts-pattern");
|
|
33914
35063
|
var messageTypeToTitle = {
|
|
33915
35064
|
assistant: "Assistant",
|
|
@@ -34060,7 +35209,7 @@ var AssembleMessageNodeImpl = class extends NodeImpl {
|
|
|
34060
35209
|
).otherwise(() => {
|
|
34061
35210
|
throw new Error(`Invalid type: ${type}`);
|
|
34062
35211
|
});
|
|
34063
|
-
const inputParts = (0,
|
|
35212
|
+
const inputParts = (0, import_lodash_es13.orderBy)(
|
|
34064
35213
|
Object.entries(inputs).filter(([key]) => key.startsWith("part")),
|
|
34065
35214
|
([key]) => key,
|
|
34066
35215
|
"asc"
|
|
@@ -34189,7 +35338,6 @@ var urlReferenceNode = nodeDefinition(UrlReferenceNodeImpl, "URL Reference");
|
|
|
34189
35338
|
|
|
34190
35339
|
// src/model/nodes/DestructureNode.ts
|
|
34191
35340
|
var import_non_secure85 = require("nanoid/non-secure");
|
|
34192
|
-
var import_jsonpath_plus3 = require("jsonpath-plus");
|
|
34193
35341
|
var import_ts_dedent72 = require("ts-dedent");
|
|
34194
35342
|
var DestructureNodeImpl = class extends NodeImpl {
|
|
34195
35343
|
static create() {
|
|
@@ -34277,7 +35425,7 @@ var DestructureNodeImpl = class extends NodeImpl {
|
|
|
34277
35425
|
this.data.paths.forEach((path, index) => {
|
|
34278
35426
|
let match9;
|
|
34279
35427
|
try {
|
|
34280
|
-
match9 = (
|
|
35428
|
+
match9 = evaluateJsonPath(inputObject, path, false);
|
|
34281
35429
|
} catch (err) {
|
|
34282
35430
|
match9 = void 0;
|
|
34283
35431
|
}
|
|
@@ -34594,9 +35742,9 @@ var import_non_secure88 = require("nanoid/non-secure");
|
|
|
34594
35742
|
var import_ts_dedent75 = require("ts-dedent");
|
|
34595
35743
|
|
|
34596
35744
|
// src/api/looseDataValue.ts
|
|
34597
|
-
var
|
|
35745
|
+
var import_lodash_es14 = require("lodash");
|
|
34598
35746
|
function looseDataValuesToDataValues(values2) {
|
|
34599
|
-
return (0,
|
|
35747
|
+
return (0, import_lodash_es14.mapValues)(values2, (val) => looseDataValueToDataValue(val));
|
|
34600
35748
|
}
|
|
34601
35749
|
function looseDataValueToDataValue(value) {
|
|
34602
35750
|
if (typeof value === "string") {
|
|
@@ -35831,7 +36979,7 @@ var cronNode = nodeDefinition(CronNodeImpl, "Cron");
|
|
|
35831
36979
|
// src/model/nodes/ToTreeNode.ts
|
|
35832
36980
|
var import_non_secure94 = require("nanoid/non-secure");
|
|
35833
36981
|
var import_ts_dedent81 = require("ts-dedent");
|
|
35834
|
-
var
|
|
36982
|
+
var import_lodash_es15 = require("lodash");
|
|
35835
36983
|
var ToTreeNodeImpl = class extends NodeImpl {
|
|
35836
36984
|
static create() {
|
|
35837
36985
|
const chartNode = {
|
|
@@ -35913,36 +37061,33 @@ var ToTreeNodeImpl = class extends NodeImpl {
|
|
|
35913
37061
|
group: ["Text"]
|
|
35914
37062
|
};
|
|
35915
37063
|
}
|
|
35916
|
-
buildTree(objects, parentPath = "", level = 0, isLast = true) {
|
|
37064
|
+
buildTree(objects, parentPath = "", level = 0, isLast = true, interpolationContext) {
|
|
35917
37065
|
if (!Array.isArray(objects) || objects.length === 0) return "";
|
|
35918
37066
|
let result = "";
|
|
35919
|
-
const sortedObjects = this.data.useSortAlphabetically ? (0,
|
|
37067
|
+
const sortedObjects = this.data.useSortAlphabetically ? (0, import_lodash_es15.sortBy)(objects, (obj) => String((0, import_lodash_es15.get)(obj, "path", ""))) : objects;
|
|
35920
37068
|
sortedObjects.forEach((obj, index) => {
|
|
35921
37069
|
const isLastItem = index === sortedObjects.length - 1;
|
|
35922
37070
|
const prefix = level === 0 ? "" : isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
35923
37071
|
const indent = level === 0 ? "" : " ".repeat(level - 1) + (isLast ? " " : "\u2502 ");
|
|
35924
|
-
const
|
|
35925
|
-
|
|
35926
|
-
|
|
35927
|
-
|
|
35928
|
-
|
|
35929
|
-
|
|
35930
|
-
},
|
|
35931
|
-
{}
|
|
37072
|
+
const formattedNode = interpolate(
|
|
37073
|
+
this.data.format,
|
|
37074
|
+
obj != null && typeof obj === "object" ? obj : {},
|
|
37075
|
+
interpolationContext == null ? void 0 : interpolationContext.graphInputNodeValues,
|
|
37076
|
+
interpolationContext == null ? void 0 : interpolationContext.contextValues,
|
|
37077
|
+
{ unwrapVariableDataValues: false }
|
|
35932
37078
|
);
|
|
35933
|
-
const formattedNode = interpolate(this.data.format, interpolationVars);
|
|
35934
37079
|
result += indent + prefix + formattedNode + "\n";
|
|
35935
|
-
const children = (0,
|
|
37080
|
+
const children = (0, import_lodash_es15.get)(obj, this.data.childrenProperty);
|
|
35936
37081
|
if (Array.isArray(children) && children.length > 0) {
|
|
35937
37082
|
const newPath = parentPath ? `${parentPath}/${formattedNode}` : formattedNode;
|
|
35938
|
-
result += this.buildTree(children, newPath, level + 1, isLastItem);
|
|
37083
|
+
result += this.buildTree(children, newPath, level + 1, isLastItem, interpolationContext);
|
|
35939
37084
|
}
|
|
35940
37085
|
});
|
|
35941
37086
|
return result;
|
|
35942
37087
|
}
|
|
35943
|
-
async process(inputs) {
|
|
37088
|
+
async process(inputs, context) {
|
|
35944
37089
|
const objects = coerceTypeOptional(inputs["objects"], "object[]") ?? [];
|
|
35945
|
-
const treeOutput = this.buildTree(objects);
|
|
37090
|
+
const treeOutput = this.buildTree(objects, "", 0, true, context);
|
|
35946
37091
|
return {
|
|
35947
37092
|
["tree"]: {
|
|
35948
37093
|
type: "string",
|
|
@@ -36314,14 +37459,26 @@ async function resolveMCPServer(data, inputs, context) {
|
|
|
36314
37459
|
}
|
|
36315
37460
|
return void 0;
|
|
36316
37461
|
}
|
|
36317
|
-
function interpolateMCPArgumentTemplate(template, inputs) {
|
|
37462
|
+
function interpolateMCPArgumentTemplate(template, inputs, graphInputValues, contextValues) {
|
|
36318
37463
|
const values2 = {};
|
|
36319
37464
|
for (const key of keys(inputs)) {
|
|
36320
|
-
if (key.startsWith("input")) {
|
|
36321
|
-
values2[key.slice("input-".length)] =
|
|
37465
|
+
if (key.startsWith("input-")) {
|
|
37466
|
+
values2[key.slice("input-".length)] = inputs[key];
|
|
36322
37467
|
}
|
|
36323
37468
|
}
|
|
36324
|
-
return interpolate(template, values2
|
|
37469
|
+
return interpolate(template, values2, graphInputValues, contextValues, {
|
|
37470
|
+
coerceBareVariableDataValues: true
|
|
37471
|
+
});
|
|
37472
|
+
}
|
|
37473
|
+
function getMCPArgumentTemplateInputs(template) {
|
|
37474
|
+
return extractInterpolationVariables(template ?? "").map(
|
|
37475
|
+
(interpolationName) => createInterpolationInputDefinition({
|
|
37476
|
+
id: `input-${interpolationName}`,
|
|
37477
|
+
interpolationName,
|
|
37478
|
+
dataType: "any",
|
|
37479
|
+
required: false
|
|
37480
|
+
})
|
|
37481
|
+
);
|
|
36325
37482
|
}
|
|
36326
37483
|
|
|
36327
37484
|
// src/model/nodes/MCPDiscoveryNode.ts
|
|
@@ -36506,6 +37663,8 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
|
|
|
36506
37663
|
id: "toolArguments",
|
|
36507
37664
|
title: "Tool Arguments"
|
|
36508
37665
|
});
|
|
37666
|
+
} else {
|
|
37667
|
+
inputs.push(...getMCPArgumentTemplateInputs(this.data.toolArguments));
|
|
36509
37668
|
}
|
|
36510
37669
|
if (this.data.useToolCallIdInput) {
|
|
36511
37670
|
inputs.push({
|
|
@@ -36547,6 +37706,7 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
|
|
|
36547
37706
|
label: "Tool Arguments",
|
|
36548
37707
|
dataKey: "toolArguments",
|
|
36549
37708
|
language: "json",
|
|
37709
|
+
interpolationSyntax: "json-template",
|
|
36550
37710
|
useInputToggleDataKey: "useToolArgumentsInput",
|
|
36551
37711
|
enableFolding: true
|
|
36552
37712
|
},
|
|
@@ -36584,7 +37744,14 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
|
|
|
36584
37744
|
throw new MCPError("INVALID_SCHEMA" /* INVALID_SCHEMA */, "Cannot parse tool argument with input toggle on");
|
|
36585
37745
|
}
|
|
36586
37746
|
} else {
|
|
36587
|
-
toolArguments = JSON.parse(
|
|
37747
|
+
toolArguments = JSON.parse(
|
|
37748
|
+
interpolateMCPArgumentTemplate(
|
|
37749
|
+
this.data.toolArguments ?? "",
|
|
37750
|
+
inputs,
|
|
37751
|
+
context.graphInputNodeValues,
|
|
37752
|
+
context.contextValues
|
|
37753
|
+
)
|
|
37754
|
+
);
|
|
36588
37755
|
}
|
|
36589
37756
|
const toolCall = {
|
|
36590
37757
|
name: toolName,
|
|
@@ -36668,6 +37835,8 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
|
|
|
36668
37835
|
id: "promptArguments",
|
|
36669
37836
|
title: "Prompt Arguments"
|
|
36670
37837
|
});
|
|
37838
|
+
} else {
|
|
37839
|
+
inputs.push(...getMCPArgumentTemplateInputs(this.data.promptArguments));
|
|
36671
37840
|
}
|
|
36672
37841
|
return inputs;
|
|
36673
37842
|
}
|
|
@@ -36697,6 +37866,7 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
|
|
|
36697
37866
|
dataKey: "promptArguments",
|
|
36698
37867
|
useInputToggleDataKey: "usePromptArgumentsInput",
|
|
36699
37868
|
language: "json",
|
|
37869
|
+
interpolationSyntax: "json-template",
|
|
36700
37870
|
helperMessage: "Arguments to provide the prompt",
|
|
36701
37871
|
enableFolding: true
|
|
36702
37872
|
}
|
|
@@ -36726,7 +37896,14 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
|
|
|
36726
37896
|
throw new MCPError("INVALID_SCHEMA" /* INVALID_SCHEMA */, "Cannot parse tool argument with input toggle on");
|
|
36727
37897
|
}
|
|
36728
37898
|
} else {
|
|
36729
|
-
promptArguments = JSON.parse(
|
|
37899
|
+
promptArguments = JSON.parse(
|
|
37900
|
+
interpolateMCPArgumentTemplate(
|
|
37901
|
+
this.data.promptArguments ?? "",
|
|
37902
|
+
inputs,
|
|
37903
|
+
context.graphInputNodeValues,
|
|
37904
|
+
context.contextValues
|
|
37905
|
+
)
|
|
37906
|
+
);
|
|
36730
37907
|
}
|
|
36731
37908
|
const getPromptRequest = {
|
|
36732
37909
|
name: promptName,
|
|
@@ -36880,29 +38057,17 @@ var ReferencedGraphAliasNodeImpl = class extends NodeImpl {
|
|
|
36880
38057
|
}
|
|
36881
38058
|
const boundary = ((_a = context.getGraphBoundary) == null ? void 0 : _a.call(context, referencedProject, this.data.graphId)) ?? getGraphBoundary(referencedProject, this.data.graphId);
|
|
36882
38059
|
const inputData = buildGraphBoundaryInputData(boundary, inputs, this.data.inputData);
|
|
36883
|
-
const shouldRunWholeGraph = !GRAPH_BOUNDARY_OUTPUT_DEMAND_OPTIMIZATION_ENABLED || context.isDirectRunTarget || this.data.useErrorOutput === true && context.activeOutputPortIds.has("error");
|
|
36884
|
-
const requestedGraphOutputNodeIds = shouldRunWholeGraph ? [] : getRequestedGraphOutputNodeIds(boundary, context.activeOutputPortIds);
|
|
36885
|
-
if (!shouldRunWholeGraph && requestedGraphOutputNodeIds.length === 0) {
|
|
36886
|
-
return buildSkippedReferencedGraphOutputs(boundary, this.data.useErrorOutput, this.data.outputCostDuration);
|
|
36887
|
-
}
|
|
36888
38060
|
const subGraphProcessor = context.createSubProcessor(this.data.graphId, {
|
|
36889
38061
|
signal: context.signal,
|
|
36890
38062
|
project: referencedProject
|
|
36891
38063
|
});
|
|
36892
|
-
if (!shouldRunWholeGraph) {
|
|
36893
|
-
subGraphProcessor.runToNodeIds = requestedGraphOutputNodeIds;
|
|
36894
|
-
}
|
|
36895
38064
|
try {
|
|
36896
38065
|
const startTime = Date.now();
|
|
36897
|
-
const
|
|
38066
|
+
const outputs = await subGraphProcessor.processGraph(
|
|
36898
38067
|
context,
|
|
36899
38068
|
inputData,
|
|
36900
38069
|
context.contextValues
|
|
36901
38070
|
);
|
|
36902
|
-
const outputs = shouldRunWholeGraph ? graphOutputs : {
|
|
36903
|
-
...buildExcludedGraphBoundaryOutputs(boundary),
|
|
36904
|
-
...graphOutputs
|
|
36905
|
-
};
|
|
36906
38071
|
const duration = Date.now() - startTime;
|
|
36907
38072
|
if (this.data.useErrorOutput) {
|
|
36908
38073
|
outputs["error"] = {
|
|
@@ -36931,26 +38096,6 @@ var ReferencedGraphAliasNodeImpl = class extends NodeImpl {
|
|
|
36931
38096
|
}
|
|
36932
38097
|
};
|
|
36933
38098
|
var referencedGraphAliasNode = nodeDefinition(ReferencedGraphAliasNodeImpl, "Referenced Graph Alias");
|
|
36934
|
-
function buildSkippedReferencedGraphOutputs(boundary, useErrorOutput, outputCostDuration) {
|
|
36935
|
-
const outputs = buildExcludedGraphBoundaryOutputs(boundary);
|
|
36936
|
-
if (useErrorOutput) {
|
|
36937
|
-
outputs["error"] = {
|
|
36938
|
-
type: "control-flow-excluded",
|
|
36939
|
-
value: void 0
|
|
36940
|
-
};
|
|
36941
|
-
}
|
|
36942
|
-
if (outputCostDuration) {
|
|
36943
|
-
outputs["cost"] = {
|
|
36944
|
-
type: "number",
|
|
36945
|
-
value: 0
|
|
36946
|
-
};
|
|
36947
|
-
outputs["duration"] = {
|
|
36948
|
-
type: "number",
|
|
36949
|
-
value: 0
|
|
36950
|
-
};
|
|
36951
|
-
}
|
|
36952
|
-
return applyMetricOutputSetting(outputs, outputCostDuration);
|
|
36953
|
-
}
|
|
36954
38099
|
function applyMetricOutputSetting(outputs, outputCostDuration) {
|
|
36955
38100
|
if (outputCostDuration) {
|
|
36956
38101
|
return outputs;
|
|
@@ -37405,7 +38550,7 @@ function removeEmptySharedSourceOperations(scope, operations) {
|
|
|
37405
38550
|
}
|
|
37406
38551
|
}
|
|
37407
38552
|
function normalizeKnowledgeSourceManifest(value, expectedSourceId) {
|
|
37408
|
-
if (!
|
|
38553
|
+
if (!isRecord9(value)) throw new Error(`Knowledge manifest for source "${expectedSourceId}" must be an object.`);
|
|
37409
38554
|
if (value.schemaVersion !== MANAGED_SCHEMA_VERSION) {
|
|
37410
38555
|
throw new Error(
|
|
37411
38556
|
`Knowledge manifest for source "${expectedSourceId}" uses unsupported schema version "${String(value.schemaVersion)}".`
|
|
@@ -37674,7 +38819,7 @@ function throwIfAborted2(signal) {
|
|
|
37674
38819
|
function errorMessage(error) {
|
|
37675
38820
|
return error instanceof Error ? error.message : String(error);
|
|
37676
38821
|
}
|
|
37677
|
-
function
|
|
38822
|
+
function isRecord9(value) {
|
|
37678
38823
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
37679
38824
|
const prototype = Object.getPrototypeOf(value);
|
|
37680
38825
|
return prototype === Object.prototype || prototype === null;
|
|
@@ -37683,7 +38828,7 @@ function isRecord8(value) {
|
|
|
37683
38828
|
// src/recording/ExecutionRecorder.ts
|
|
37684
38829
|
var import_non_secure100 = require("nanoid/non-secure");
|
|
37685
38830
|
var import_emittery2 = __toESM(require("emittery-0-13"), 1);
|
|
37686
|
-
var
|
|
38831
|
+
var import_lodash_es16 = require("lodash");
|
|
37687
38832
|
var import_json_stream_es = require("json-stream-es");
|
|
37688
38833
|
|
|
37689
38834
|
// src/vendor/fnv1a.js
|
|
@@ -37854,6 +38999,7 @@ var toRecordedEventMap = {
|
|
|
37854
38999
|
execution
|
|
37855
39000
|
),
|
|
37856
39001
|
llmCallFinished: ({ execution, ...event }) => ({ ...event, execution }),
|
|
39002
|
+
llmChatOutputSnapshot: ({ execution, ...event }) => withExecution(event, execution),
|
|
37857
39003
|
llmProfileAttempt: ({ execution, ...event }) => ({ ...event, execution }),
|
|
37858
39004
|
toolCallFinished: ({ execution, ...event }) => ({ ...event, execution }),
|
|
37859
39005
|
nodeOutputsCleared: ({ node, processId, execution }) => withExecution(
|
|
@@ -37919,16 +39065,16 @@ function isRecordableProcessEvent(message) {
|
|
|
37919
39065
|
function mapValuesDeep(obj, fn) {
|
|
37920
39066
|
if (Array.isArray(obj)) {
|
|
37921
39067
|
return obj.map((value) => {
|
|
37922
|
-
if ((0,
|
|
39068
|
+
if ((0, import_lodash_es16.isPlainObject)(value) || Array.isArray(value)) {
|
|
37923
39069
|
return mapValuesDeep(value, fn);
|
|
37924
39070
|
}
|
|
37925
39071
|
return fn(value);
|
|
37926
39072
|
});
|
|
37927
39073
|
}
|
|
37928
|
-
if ((0,
|
|
39074
|
+
if ((0, import_lodash_es16.isPlainObject)(obj)) {
|
|
37929
39075
|
return Object.fromEntries(
|
|
37930
39076
|
Object.entries(obj).map(([key, value]) => {
|
|
37931
|
-
if ((0,
|
|
39077
|
+
if ((0, import_lodash_es16.isPlainObject)(value) || Array.isArray(value)) {
|
|
37932
39078
|
return [key, mapValuesDeep(value, fn)];
|
|
37933
39079
|
}
|
|
37934
39080
|
return [key, fn(value)];
|
|
@@ -40321,7 +41467,7 @@ async function testPineconeKnowledgeConnection(definition, credentials, signal,
|
|
|
40321
41467
|
throw createProviderError(response.status, response.statusText, body);
|
|
40322
41468
|
}
|
|
40323
41469
|
const payload = await parseJsonResponse(response, "testing the knowledge-store connection");
|
|
40324
|
-
if (!
|
|
41470
|
+
if (!isRecord10(payload)) throw new Error("Pinecone connection test returned a malformed successful response.");
|
|
40325
41471
|
}
|
|
40326
41472
|
var PineconeKnowledgeStoreDriver = class {
|
|
40327
41473
|
constructor(config, apiKey) {
|
|
@@ -40344,19 +41490,19 @@ var PineconeKnowledgeStoreDriver = class {
|
|
|
40344
41490
|
const response = await this.#request(url, { method: "GET" }, context);
|
|
40345
41491
|
const indexedLsn = readPineconeLsn(response.headers, "x-pinecone-max-indexed-lsn");
|
|
40346
41492
|
const payload = await parseJsonResponse(response, "fetching the knowledge-source manifest");
|
|
40347
|
-
if (!
|
|
41493
|
+
if (!isRecord10(payload)) {
|
|
40348
41494
|
throw new Error("Pinecone returned an invalid manifest fetch response.");
|
|
40349
41495
|
}
|
|
40350
41496
|
const vectors = payload.vectors;
|
|
40351
|
-
if (!
|
|
41497
|
+
if (!isRecord10(vectors)) {
|
|
40352
41498
|
throw new Error("Pinecone manifest fetch response is missing its vectors map.");
|
|
40353
41499
|
}
|
|
40354
41500
|
const manifestRecord = vectors[MANIFEST_RECORD_ID];
|
|
40355
|
-
if (manifestRecord != null && !
|
|
41501
|
+
if (manifestRecord != null && !isRecord10(manifestRecord)) {
|
|
40356
41502
|
throw new Error(`Pinecone manifest record for source "${sourceId}" is malformed.`);
|
|
40357
41503
|
}
|
|
40358
|
-
if (!
|
|
40359
|
-
const fields =
|
|
41504
|
+
if (!isRecord10(manifestRecord)) return { ...indexedLsn == null ? {} : { indexedLsn } };
|
|
41505
|
+
const fields = isRecord10(manifestRecord.fields) ? manifestRecord.fields : isRecord10(manifestRecord.metadata) ? manifestRecord.metadata : {};
|
|
40360
41506
|
const encodedManifest = fields.rivet_manifest_json;
|
|
40361
41507
|
if (typeof encodedManifest !== "string") {
|
|
40362
41508
|
throw new Error(`Pinecone manifest for source "${sourceId}" is missing Rivet manifest metadata.`);
|
|
@@ -40446,11 +41592,11 @@ var PineconeKnowledgeStoreDriver = class {
|
|
|
40446
41592
|
context
|
|
40447
41593
|
);
|
|
40448
41594
|
const payload = await parseJsonResponse(response, "searching knowledge");
|
|
40449
|
-
if (!
|
|
41595
|
+
if (!isRecord10(payload) || !isRecord10(payload.result) || !Array.isArray(payload.result.hits)) {
|
|
40450
41596
|
throw new Error("Pinecone returned an invalid knowledge search response.");
|
|
40451
41597
|
}
|
|
40452
41598
|
return payload.result.hits.map((hit, index) => {
|
|
40453
|
-
if (!
|
|
41599
|
+
if (!isRecord10(hit) || !isRecord10(hit.fields)) {
|
|
40454
41600
|
throw new Error(`Pinecone knowledge search hit ${index + 1} is malformed.`);
|
|
40455
41601
|
}
|
|
40456
41602
|
const fields = hit.fields;
|
|
@@ -40692,8 +41838,8 @@ function createProviderError(status, statusText, body) {
|
|
|
40692
41838
|
let providerMessage = body.trim();
|
|
40693
41839
|
try {
|
|
40694
41840
|
const parsed = JSON.parse(body);
|
|
40695
|
-
if (
|
|
40696
|
-
const error =
|
|
41841
|
+
if (isRecord10(parsed)) {
|
|
41842
|
+
const error = isRecord10(parsed.error) ? parsed.error : void 0;
|
|
40697
41843
|
providerMessage = stringConfig(error == null ? void 0 : error.message) || stringConfig(parsed.message) || stringConfig(parsed.error) || providerMessage;
|
|
40698
41844
|
}
|
|
40699
41845
|
} catch {
|
|
@@ -40719,7 +41865,7 @@ function extractUserMetadata(fields, textField) {
|
|
|
40719
41865
|
return Object.keys(metadata).length ? metadata : void 0;
|
|
40720
41866
|
}
|
|
40721
41867
|
function recordId(value) {
|
|
40722
|
-
if (!
|
|
41868
|
+
if (!isRecord10(value)) return "";
|
|
40723
41869
|
return stringConfig(value._id) || stringConfig(value.id);
|
|
40724
41870
|
}
|
|
40725
41871
|
function stringConfig(value) {
|
|
@@ -40769,7 +41915,7 @@ function validatePineconeFilterComparison(filter) {
|
|
|
40769
41915
|
throw new Error(`Pinecone filter operator "${filter.operator}" requires an array of strings or numbers.`);
|
|
40770
41916
|
}
|
|
40771
41917
|
}
|
|
40772
|
-
function
|
|
41918
|
+
function isRecord10(value) {
|
|
40773
41919
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
40774
41920
|
}
|
|
40775
41921
|
function isRetryableStatus(status) {
|
|
@@ -43487,7 +44633,6 @@ ${additional.join("\n")}`;
|
|
|
43487
44633
|
var runThreadNode = pluginNodeDefinition(RunThreadNodeImpl, "Run Thread");
|
|
43488
44634
|
|
|
43489
44635
|
// src/plugins/openai/nodes/ThreadMessageNode.ts
|
|
43490
|
-
var import_lodash_es18 = require("lodash");
|
|
43491
44636
|
var ThreadMessageNodeImpl = {
|
|
43492
44637
|
create() {
|
|
43493
44638
|
return {
|
|
@@ -43540,16 +44685,17 @@ var ThreadMessageNodeImpl = {
|
|
|
43540
44685
|
required: false
|
|
43541
44686
|
});
|
|
43542
44687
|
}
|
|
43543
|
-
const
|
|
44688
|
+
const inputReferences = extractInterpolationVariableReferences(data.text);
|
|
44689
|
+
const fixedInputIds = new Set(inputs.map((input) => input.id));
|
|
43544
44690
|
inputs = [
|
|
43545
44691
|
...inputs,
|
|
43546
|
-
...(
|
|
44692
|
+
...inputReferences.filter(({ baseName }) => !fixedInputIds.has(baseName)).map(({ baseName, hasPath }) => {
|
|
43547
44693
|
return createInterpolationInputDefinition({
|
|
43548
|
-
interpolationName:
|
|
43549
|
-
dataType: "string",
|
|
44694
|
+
interpolationName: baseName,
|
|
44695
|
+
dataType: hasPath ? "any" : "string",
|
|
43550
44696
|
required: false
|
|
43551
44697
|
});
|
|
43552
|
-
})
|
|
44698
|
+
})
|
|
43553
44699
|
];
|
|
43554
44700
|
return inputs;
|
|
43555
44701
|
},
|
|
@@ -43597,7 +44743,7 @@ var ThreadMessageNodeImpl = {
|
|
|
43597
44743
|
theme: "prompt-interpolation"
|
|
43598
44744
|
};
|
|
43599
44745
|
},
|
|
43600
|
-
async process(data, inputData) {
|
|
44746
|
+
async process(data, inputData, context) {
|
|
43601
44747
|
const text = getInputOrData(data, inputData, "text", "string");
|
|
43602
44748
|
const fileIds = getInputOrData(data, inputData, "fileIds", "string[]") ?? [];
|
|
43603
44749
|
let metadata = data.metadata.reduce(
|
|
@@ -43610,8 +44756,9 @@ var ThreadMessageNodeImpl = {
|
|
|
43610
44756
|
if (data.useMetadataInput && inputData["metadata"]) {
|
|
43611
44757
|
metadata = coerceTypeOptional(inputData["metadata"], "object");
|
|
43612
44758
|
}
|
|
43613
|
-
const
|
|
43614
|
-
|
|
44759
|
+
const interpolated = interpolate(text, inputData, context == null ? void 0 : context.graphInputNodeValues, context == null ? void 0 : context.contextValues, {
|
|
44760
|
+
coerceBareVariableDataValues: true
|
|
44761
|
+
});
|
|
43615
44762
|
return {
|
|
43616
44763
|
["message"]: {
|
|
43617
44764
|
type: "object",
|
|
@@ -43663,7 +44810,7 @@ var import_ts_dedent93 = require("ts-dedent");
|
|
|
43663
44810
|
var import_p_retry3 = __toESM(require("p-retry-4"), 1);
|
|
43664
44811
|
var import_ts_pattern8 = require("ts-pattern");
|
|
43665
44812
|
var import_genai2 = require("@google/genai");
|
|
43666
|
-
var
|
|
44813
|
+
var import_lodash_es17 = require("lodash");
|
|
43667
44814
|
function toGoogleSchemaType(type) {
|
|
43668
44815
|
switch (type) {
|
|
43669
44816
|
case "string":
|
|
@@ -44034,7 +45181,7 @@ var ChatGoogleNodeImpl = {
|
|
|
44034
45181
|
description: tool.description,
|
|
44035
45182
|
parameters: Object.keys(parameters.properties ?? {}).length === 0 ? void 0 : {
|
|
44036
45183
|
type: import_genai2.Type.OBJECT,
|
|
44037
|
-
properties: (0,
|
|
45184
|
+
properties: (0, import_lodash_es17.mapValues)(parameters.properties ?? {}, (property) => ({
|
|
44038
45185
|
// gemini doesn't support union property types, it uses openapi style not jsonschema, what a mess
|
|
44039
45186
|
type: toGoogleSchemaType(
|
|
44040
45187
|
Array.isArray(property.type) ? property.type.find((type) => type !== "null") : property.type
|
|
@@ -44328,7 +45475,7 @@ async function assembleRegistry(specs, loadPlugin) {
|
|
|
44328
45475
|
}
|
|
44329
45476
|
|
|
44330
45477
|
// src/integrations/DatasetProvider.ts
|
|
44331
|
-
var
|
|
45478
|
+
var import_lodash_es18 = require("lodash");
|
|
44332
45479
|
var InMemoryDatasetProvider = class {
|
|
44333
45480
|
#datasets;
|
|
44334
45481
|
constructor(datasets) {
|
|
@@ -44408,7 +45555,7 @@ var InMemoryDatasetProvider = class {
|
|
|
44408
45555
|
return sorted.slice(0, k).map((r) => ({ ...r.row, distance: r.similarity }));
|
|
44409
45556
|
}
|
|
44410
45557
|
async exportDatasetsForProject(_projectId) {
|
|
44411
|
-
return (0,
|
|
45558
|
+
return (0, import_lodash_es18.cloneDeep)(this.#datasets);
|
|
44412
45559
|
}
|
|
44413
45560
|
};
|
|
44414
45561
|
var dotProductSimilarity = (a, b) => {
|
|
@@ -44754,7 +45901,9 @@ function coreCreateProcessor(project, options2, internalOptions = {}) {
|
|
|
44754
45901
|
settings: resolveProcessSettings(options2),
|
|
44755
45902
|
getChatNodeEndpoint: options2.getChatNodeEndpoint,
|
|
44756
45903
|
onChatV2CallFinished: options2.onChatV2CallFinished,
|
|
45904
|
+
onLLMChatOutputSnapshot: options2.onLLMChatOutputSnapshot,
|
|
44757
45905
|
llmProfileHealthStore: options2.llmProfileHealthStore,
|
|
45906
|
+
llmProfileHealthExecutionCorrelationId: options2.llmProfileHealthExecutionCorrelationId,
|
|
44758
45907
|
evaluation: options2.evaluation
|
|
44759
45908
|
},
|
|
44760
45909
|
resolvedInputs,
|
|
@@ -44917,6 +46066,15 @@ var Rivet = void 0;
|
|
|
44917
46066
|
RIVET_MARKDOWN_ALLOWED_URI_REGEXP_SOURCE,
|
|
44918
46067
|
RIVET_MARKDOWN_SANITIZER_POLICY,
|
|
44919
46068
|
RIVET_WEB_APP_ACTION_PROTOCOL_VERSION,
|
|
46069
|
+
RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES,
|
|
46070
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTION_BYTES,
|
|
46071
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTIVE_BYTES,
|
|
46072
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_VALUE_BYTES,
|
|
46073
|
+
RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_TRANSFER_TIMEOUT_MS,
|
|
46074
|
+
RIVET_WEB_APP_BROWSER_STORAGE_RPC_CAPABILITY,
|
|
46075
|
+
RIVET_WEB_APP_BROWSER_STORAGE_RPC_VERSION,
|
|
46076
|
+
RIVET_WEB_APP_BROWSER_STORAGE_SAFE_FALLBACK_BYTES,
|
|
46077
|
+
RIVET_WEB_APP_BROWSER_STORAGE_TRANSFER_CHUNK_BYTES,
|
|
44920
46078
|
RIVET_WEB_APP_DOCUMENT_CSS,
|
|
44921
46079
|
RIVET_WEB_APP_RENDERER_CSS,
|
|
44922
46080
|
RIVET_WEB_APP_STATUS_FUNCTION_NAME,
|
|
@@ -44989,6 +46147,7 @@ var Rivet = void 0;
|
|
|
44989
46147
|
callGraphNode,
|
|
44990
46148
|
canBeCoerced,
|
|
44991
46149
|
canBeCoercedAny,
|
|
46150
|
+
canConsumeControlFlowExcludedInput,
|
|
44992
46151
|
canRenderDataBusNode,
|
|
44993
46152
|
canUseNodeAsPrefabSource,
|
|
44994
46153
|
chatLoopNode,
|
|
@@ -45053,12 +46212,15 @@ var Rivet = void 0;
|
|
|
45053
46212
|
datasetNearestNeighborsNode,
|
|
45054
46213
|
decideLLMInvocationRound,
|
|
45055
46214
|
decodeDebuggerTransportSentinels,
|
|
46215
|
+
decodeRivetWebAppStorageBinaryFrame,
|
|
45056
46216
|
dedent,
|
|
45057
46217
|
delayNode,
|
|
45058
46218
|
delegateFunctionCallNode,
|
|
45059
46219
|
deserializeDatasets,
|
|
45060
46220
|
deserializeGraph,
|
|
45061
46221
|
deserializeProject,
|
|
46222
|
+
deserializeRivetWebAppStoredValue,
|
|
46223
|
+
deserializeRivetWebAppStoredValuePatch,
|
|
45062
46224
|
destructureNode,
|
|
45063
46225
|
detachNodePrefabInstance,
|
|
45064
46226
|
detectSerializationVersion,
|
|
@@ -45066,6 +46228,8 @@ var Rivet = void 0;
|
|
|
45066
46228
|
documentNode,
|
|
45067
46229
|
doubleCheckProject,
|
|
45068
46230
|
emptyNodeGraph,
|
|
46231
|
+
encodeRivetWebAppStorageBinaryFrame,
|
|
46232
|
+
evaluateJsonPath,
|
|
45069
46233
|
evaluateNode,
|
|
45070
46234
|
executeLLMInvocation,
|
|
45071
46235
|
expectType,
|
|
@@ -45073,6 +46237,7 @@ var Rivet = void 0;
|
|
|
45073
46237
|
exportGentraceEvaluationRun,
|
|
45074
46238
|
expressionNode,
|
|
45075
46239
|
externalCallNode,
|
|
46240
|
+
extractInterpolationVariableReferences,
|
|
45076
46241
|
extractInterpolationVariables,
|
|
45077
46242
|
extractJsonNode,
|
|
45078
46243
|
extractMarkdownCodeBlocksNode,
|
|
@@ -45124,6 +46289,7 @@ var Rivet = void 0;
|
|
|
45124
46289
|
getIntegration,
|
|
45125
46290
|
getInterpolationInputDefinitionData,
|
|
45126
46291
|
getInterpolationTokenName,
|
|
46292
|
+
getInterpolationTokenReference,
|
|
45127
46293
|
getKnowledgeSourceStatusNode,
|
|
45128
46294
|
getKnowledgeStoreProvider,
|
|
45129
46295
|
getKnowledgeStoreProviders,
|
|
@@ -45142,6 +46308,7 @@ var Rivet = void 0;
|
|
|
45142
46308
|
getScalarTypeOf,
|
|
45143
46309
|
getSingleNodeStream,
|
|
45144
46310
|
getStoredValueNode,
|
|
46311
|
+
getToolNodeBodyPreview,
|
|
45145
46312
|
getUiGraphActionComponent,
|
|
45146
46313
|
getUiGraphActionInputBindings,
|
|
45147
46314
|
getUiGraphActionOutputBindings,
|
|
@@ -45206,6 +46373,8 @@ var Rivet = void 0;
|
|
|
45206
46373
|
isFunctionDataType,
|
|
45207
46374
|
isFunctionDataValue,
|
|
45208
46375
|
isInterpolationInputDefinition,
|
|
46376
|
+
isInterpolationRegexLiteralStart,
|
|
46377
|
+
isInterpolationSyntaxCharacterEscaped,
|
|
45209
46378
|
isKnowledgeDocument,
|
|
45210
46379
|
isKnowledgeEvidence,
|
|
45211
46380
|
isKnowledgeSourceReference,
|
|
@@ -45256,6 +46425,7 @@ var Rivet = void 0;
|
|
|
45256
46425
|
normalizeChatV2CredentialNames,
|
|
45257
46426
|
normalizeChatV2CredentialNamesByProvider,
|
|
45258
46427
|
normalizeGraphProgress,
|
|
46428
|
+
normalizeJsonPathExpression,
|
|
45259
46429
|
normalizeKnowledgeConnectionId,
|
|
45260
46430
|
normalizeKnowledgeDocument,
|
|
45261
46431
|
normalizeKnowledgeEvidence,
|
|
@@ -45289,7 +46459,11 @@ var Rivet = void 0;
|
|
|
45289
46459
|
parseChatV2Provider,
|
|
45290
46460
|
parseCustomProviderApi,
|
|
45291
46461
|
parseDataBusChannelIndex,
|
|
46462
|
+
parseInterpolationExpression,
|
|
46463
|
+
parseInterpolationTemplate,
|
|
45292
46464
|
parseProviderJsonChunk,
|
|
46465
|
+
parseRivetWebAppBrowserStorageClientMessage,
|
|
46466
|
+
parseRivetWebAppBrowserStorageServerMessage,
|
|
45293
46467
|
parseRivetWebAppClientMessage,
|
|
45294
46468
|
parseRivetWebAppServerMessage,
|
|
45295
46469
|
passthroughNode,
|
|
@@ -45330,6 +46504,9 @@ var Rivet = void 0;
|
|
|
45330
46504
|
resolveChatV2Credential,
|
|
45331
46505
|
resolveChatV2ProviderConfig,
|
|
45332
46506
|
resolveChatV2ResponseFormatParameters,
|
|
46507
|
+
resolveCodeInterpolationExpression,
|
|
46508
|
+
resolveInterpolationExpressionRawValue,
|
|
46509
|
+
resolveInterpolationTokenRawValue,
|
|
45333
46510
|
resolveLLMChatV2RuntimeProviderOptions,
|
|
45334
46511
|
resolveNodePrefabInstance,
|
|
45335
46512
|
resolveNodePrefabInstances,
|
|
@@ -45352,10 +46529,13 @@ var Rivet = void 0;
|
|
|
45352
46529
|
sanitizeIdentifierPortValue,
|
|
45353
46530
|
scalarDefaults,
|
|
45354
46531
|
scalarTypes,
|
|
46532
|
+
scanInterpolationTokenSpans,
|
|
45355
46533
|
searchKnowledgeNode,
|
|
45356
46534
|
serializeDatasets,
|
|
45357
46535
|
serializeGraph,
|
|
45358
46536
|
serializeProject,
|
|
46537
|
+
serializeRivetWebAppStoredValue,
|
|
46538
|
+
serializeRivetWebAppStoredValuePatch,
|
|
45359
46539
|
setGlobalNode,
|
|
45360
46540
|
setStoredValueNode,
|
|
45361
46541
|
shouldIncludeLLMChatV2ToolCalls,
|
|
@@ -45364,8 +46544,10 @@ var Rivet = void 0;
|
|
|
45364
46544
|
shuffleNode,
|
|
45365
46545
|
sliceNode,
|
|
45366
46546
|
splitNode,
|
|
46547
|
+
splitRivetWebAppStorageTransfer,
|
|
45367
46548
|
startBackgroundBranchNode,
|
|
45368
46549
|
streamChatV2,
|
|
46550
|
+
stringifyInterpolationSourceValue,
|
|
45369
46551
|
stringifyToolResult,
|
|
45370
46552
|
stringifyUiGraphValue,
|
|
45371
46553
|
subGraphNode,
|