@valerypopoff/rivet2-core 2.4.0 → 2.6.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 +1800 -753
- 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.map +2 -2
- package/dist/esm/exports.js +2 -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 +8 -3
- 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 +177 -50
- package/dist/esm/model/ProcessContextBuilder.js +4 -1
- package/dist/esm/model/RecordingPlayer.js +46 -14
- package/dist/esm/model/SplitRunProcessor.js +37 -16
- package/dist/esm/model/StoredValueStore.js +4 -3
- package/dist/esm/model/UiGraphRendererStyles.js +20 -0
- package/dist/esm/model/chat/aiSdkStreaming.js +3 -2
- package/dist/esm/model/chat-v2/aiSdkBridge.js +63 -5
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +66 -3
- package/dist/esm/model/chat-v2/llmInvocationResultProjector.js +20 -7
- package/dist/esm/model/chat-v2/llmProfileFallback.js +12 -4
- 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 +30 -4
- 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 +55 -23
- 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/types/exports.d.ts +3 -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 +2 -0
- package/dist/types/model/ExecutorProtocol.d.ts +4 -0
- 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 +12 -3
- package/dist/types/model/ProcessContext.d.ts +9 -2
- package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
- package/dist/types/model/SplitRunProcessor.d.ts +2 -1
- package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
- package/dist/types/model/chat/aiSdkStreaming.d.ts +1 -1
- package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +1 -1
- package/dist/types/model/chat-v2/chatV2Types.d.ts +29 -0
- package/dist/types/model/chat-v2/llmInvocationResultProjector.d.ts +5 -1
- 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/ExecutionRecorder.d.ts +6 -1
- package/dist/types/recording/RecordedEvents.d.ts +2 -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/package.json +11 -1
package/dist/cjs/bundle.cjs
CHANGED
|
@@ -316,6 +316,7 @@ __export(src_exports, {
|
|
|
316
316
|
doubleCheckProject: () => doubleCheckProject,
|
|
317
317
|
emptyNodeGraph: () => emptyNodeGraph,
|
|
318
318
|
encodeRivetWebAppStorageBinaryFrame: () => encodeRivetWebAppStorageBinaryFrame,
|
|
319
|
+
evaluateJsonPath: () => evaluateJsonPath,
|
|
319
320
|
evaluateNode: () => evaluateNode,
|
|
320
321
|
executeLLMInvocation: () => executeLLMInvocation,
|
|
321
322
|
expectType: () => expectType,
|
|
@@ -323,6 +324,7 @@ __export(src_exports, {
|
|
|
323
324
|
exportGentraceEvaluationRun: () => exportGentraceEvaluationRun,
|
|
324
325
|
expressionNode: () => expressionNode,
|
|
325
326
|
externalCallNode: () => externalCallNode,
|
|
327
|
+
extractInterpolationVariableReferences: () => extractInterpolationVariableReferences,
|
|
326
328
|
extractInterpolationVariables: () => extractInterpolationVariables,
|
|
327
329
|
extractJsonNode: () => extractJsonNode,
|
|
328
330
|
extractMarkdownCodeBlocksNode: () => extractMarkdownCodeBlocksNode,
|
|
@@ -374,6 +376,7 @@ __export(src_exports, {
|
|
|
374
376
|
getIntegration: () => getIntegration,
|
|
375
377
|
getInterpolationInputDefinitionData: () => getInterpolationInputDefinitionData,
|
|
376
378
|
getInterpolationTokenName: () => getInterpolationTokenName,
|
|
379
|
+
getInterpolationTokenReference: () => getInterpolationTokenReference,
|
|
377
380
|
getKnowledgeSourceStatusNode: () => getKnowledgeSourceStatusNode,
|
|
378
381
|
getKnowledgeStoreProvider: () => getKnowledgeStoreProvider,
|
|
379
382
|
getKnowledgeStoreProviders: () => getKnowledgeStoreProviders,
|
|
@@ -392,6 +395,7 @@ __export(src_exports, {
|
|
|
392
395
|
getScalarTypeOf: () => getScalarTypeOf,
|
|
393
396
|
getSingleNodeStream: () => getSingleNodeStream,
|
|
394
397
|
getStoredValueNode: () => getStoredValueNode,
|
|
398
|
+
getToolNodeBodyPreview: () => getToolNodeBodyPreview,
|
|
395
399
|
getUiGraphActionComponent: () => getUiGraphActionComponent,
|
|
396
400
|
getUiGraphActionInputBindings: () => getUiGraphActionInputBindings,
|
|
397
401
|
getUiGraphActionOutputBindings: () => getUiGraphActionOutputBindings,
|
|
@@ -456,6 +460,8 @@ __export(src_exports, {
|
|
|
456
460
|
isFunctionDataType: () => isFunctionDataType,
|
|
457
461
|
isFunctionDataValue: () => isFunctionDataValue,
|
|
458
462
|
isInterpolationInputDefinition: () => isInterpolationInputDefinition,
|
|
463
|
+
isInterpolationRegexLiteralStart: () => isInterpolationRegexLiteralStart,
|
|
464
|
+
isInterpolationSyntaxCharacterEscaped: () => isInterpolationSyntaxCharacterEscaped,
|
|
459
465
|
isKnowledgeDocument: () => isKnowledgeDocument,
|
|
460
466
|
isKnowledgeEvidence: () => isKnowledgeEvidence,
|
|
461
467
|
isKnowledgeSourceReference: () => isKnowledgeSourceReference,
|
|
@@ -506,6 +512,7 @@ __export(src_exports, {
|
|
|
506
512
|
normalizeChatV2CredentialNames: () => normalizeChatV2CredentialNames,
|
|
507
513
|
normalizeChatV2CredentialNamesByProvider: () => normalizeChatV2CredentialNamesByProvider,
|
|
508
514
|
normalizeGraphProgress: () => normalizeGraphProgress,
|
|
515
|
+
normalizeJsonPathExpression: () => normalizeJsonPathExpression,
|
|
509
516
|
normalizeKnowledgeConnectionId: () => normalizeKnowledgeConnectionId,
|
|
510
517
|
normalizeKnowledgeDocument: () => normalizeKnowledgeDocument,
|
|
511
518
|
normalizeKnowledgeEvidence: () => normalizeKnowledgeEvidence,
|
|
@@ -539,6 +546,8 @@ __export(src_exports, {
|
|
|
539
546
|
parseChatV2Provider: () => parseChatV2Provider,
|
|
540
547
|
parseCustomProviderApi: () => parseCustomProviderApi,
|
|
541
548
|
parseDataBusChannelIndex: () => parseDataBusChannelIndex,
|
|
549
|
+
parseInterpolationExpression: () => parseInterpolationExpression,
|
|
550
|
+
parseInterpolationTemplate: () => parseInterpolationTemplate,
|
|
542
551
|
parseProviderJsonChunk: () => parseProviderJsonChunk,
|
|
543
552
|
parseRivetWebAppBrowserStorageClientMessage: () => parseRivetWebAppBrowserStorageClientMessage,
|
|
544
553
|
parseRivetWebAppBrowserStorageServerMessage: () => parseRivetWebAppBrowserStorageServerMessage,
|
|
@@ -582,6 +591,9 @@ __export(src_exports, {
|
|
|
582
591
|
resolveChatV2Credential: () => resolveChatV2Credential,
|
|
583
592
|
resolveChatV2ProviderConfig: () => resolveChatV2ProviderConfig,
|
|
584
593
|
resolveChatV2ResponseFormatParameters: () => resolveChatV2ResponseFormatParameters,
|
|
594
|
+
resolveCodeInterpolationExpression: () => resolveCodeInterpolationExpression,
|
|
595
|
+
resolveInterpolationExpressionRawValue: () => resolveInterpolationExpressionRawValue,
|
|
596
|
+
resolveInterpolationTokenRawValue: () => resolveInterpolationTokenRawValue,
|
|
585
597
|
resolveLLMChatV2RuntimeProviderOptions: () => resolveLLMChatV2RuntimeProviderOptions,
|
|
586
598
|
resolveNodePrefabInstance: () => resolveNodePrefabInstance,
|
|
587
599
|
resolveNodePrefabInstances: () => resolveNodePrefabInstances,
|
|
@@ -604,6 +616,7 @@ __export(src_exports, {
|
|
|
604
616
|
sanitizeIdentifierPortValue: () => sanitizeIdentifierPortValue,
|
|
605
617
|
scalarDefaults: () => scalarDefaults,
|
|
606
618
|
scalarTypes: () => scalarTypes,
|
|
619
|
+
scanInterpolationTokenSpans: () => scanInterpolationTokenSpans,
|
|
607
620
|
searchKnowledgeNode: () => searchKnowledgeNode,
|
|
608
621
|
serializeDatasets: () => serializeDatasets,
|
|
609
622
|
serializeGraph: () => serializeGraph,
|
|
@@ -621,6 +634,7 @@ __export(src_exports, {
|
|
|
621
634
|
splitRivetWebAppStorageTransfer: () => splitRivetWebAppStorageTransfer,
|
|
622
635
|
startBackgroundBranchNode: () => startBackgroundBranchNode,
|
|
623
636
|
streamChatV2: () => streamChatV2,
|
|
637
|
+
stringifyInterpolationSourceValue: () => stringifyInterpolationSourceValue,
|
|
624
638
|
stringifyToolResult: () => stringifyToolResult,
|
|
625
639
|
stringifyUiGraphValue: () => stringifyUiGraphValue,
|
|
626
640
|
subGraphNode: () => subGraphNode,
|
|
@@ -943,6 +957,7 @@ __export(exports_exports, {
|
|
|
943
957
|
doubleCheckProject: () => doubleCheckProject,
|
|
944
958
|
emptyNodeGraph: () => emptyNodeGraph,
|
|
945
959
|
encodeRivetWebAppStorageBinaryFrame: () => encodeRivetWebAppStorageBinaryFrame,
|
|
960
|
+
evaluateJsonPath: () => evaluateJsonPath,
|
|
946
961
|
evaluateNode: () => evaluateNode,
|
|
947
962
|
executeLLMInvocation: () => executeLLMInvocation,
|
|
948
963
|
expectType: () => expectType,
|
|
@@ -950,6 +965,7 @@ __export(exports_exports, {
|
|
|
950
965
|
exportGentraceEvaluationRun: () => exportGentraceEvaluationRun,
|
|
951
966
|
expressionNode: () => expressionNode,
|
|
952
967
|
externalCallNode: () => externalCallNode,
|
|
968
|
+
extractInterpolationVariableReferences: () => extractInterpolationVariableReferences,
|
|
953
969
|
extractInterpolationVariables: () => extractInterpolationVariables,
|
|
954
970
|
extractJsonNode: () => extractJsonNode,
|
|
955
971
|
extractMarkdownCodeBlocksNode: () => extractMarkdownCodeBlocksNode,
|
|
@@ -1001,6 +1017,7 @@ __export(exports_exports, {
|
|
|
1001
1017
|
getIntegration: () => getIntegration,
|
|
1002
1018
|
getInterpolationInputDefinitionData: () => getInterpolationInputDefinitionData,
|
|
1003
1019
|
getInterpolationTokenName: () => getInterpolationTokenName,
|
|
1020
|
+
getInterpolationTokenReference: () => getInterpolationTokenReference,
|
|
1004
1021
|
getKnowledgeSourceStatusNode: () => getKnowledgeSourceStatusNode,
|
|
1005
1022
|
getKnowledgeStoreProvider: () => getKnowledgeStoreProvider,
|
|
1006
1023
|
getKnowledgeStoreProviders: () => getKnowledgeStoreProviders,
|
|
@@ -1019,6 +1036,7 @@ __export(exports_exports, {
|
|
|
1019
1036
|
getScalarTypeOf: () => getScalarTypeOf,
|
|
1020
1037
|
getSingleNodeStream: () => getSingleNodeStream,
|
|
1021
1038
|
getStoredValueNode: () => getStoredValueNode,
|
|
1039
|
+
getToolNodeBodyPreview: () => getToolNodeBodyPreview,
|
|
1022
1040
|
getUiGraphActionComponent: () => getUiGraphActionComponent,
|
|
1023
1041
|
getUiGraphActionInputBindings: () => getUiGraphActionInputBindings,
|
|
1024
1042
|
getUiGraphActionOutputBindings: () => getUiGraphActionOutputBindings,
|
|
@@ -1083,6 +1101,8 @@ __export(exports_exports, {
|
|
|
1083
1101
|
isFunctionDataType: () => isFunctionDataType,
|
|
1084
1102
|
isFunctionDataValue: () => isFunctionDataValue,
|
|
1085
1103
|
isInterpolationInputDefinition: () => isInterpolationInputDefinition,
|
|
1104
|
+
isInterpolationRegexLiteralStart: () => isInterpolationRegexLiteralStart,
|
|
1105
|
+
isInterpolationSyntaxCharacterEscaped: () => isInterpolationSyntaxCharacterEscaped,
|
|
1086
1106
|
isKnowledgeDocument: () => isKnowledgeDocument,
|
|
1087
1107
|
isKnowledgeEvidence: () => isKnowledgeEvidence,
|
|
1088
1108
|
isKnowledgeSourceReference: () => isKnowledgeSourceReference,
|
|
@@ -1133,6 +1153,7 @@ __export(exports_exports, {
|
|
|
1133
1153
|
normalizeChatV2CredentialNames: () => normalizeChatV2CredentialNames,
|
|
1134
1154
|
normalizeChatV2CredentialNamesByProvider: () => normalizeChatV2CredentialNamesByProvider,
|
|
1135
1155
|
normalizeGraphProgress: () => normalizeGraphProgress,
|
|
1156
|
+
normalizeJsonPathExpression: () => normalizeJsonPathExpression,
|
|
1136
1157
|
normalizeKnowledgeConnectionId: () => normalizeKnowledgeConnectionId,
|
|
1137
1158
|
normalizeKnowledgeDocument: () => normalizeKnowledgeDocument,
|
|
1138
1159
|
normalizeKnowledgeEvidence: () => normalizeKnowledgeEvidence,
|
|
@@ -1166,6 +1187,8 @@ __export(exports_exports, {
|
|
|
1166
1187
|
parseChatV2Provider: () => parseChatV2Provider,
|
|
1167
1188
|
parseCustomProviderApi: () => parseCustomProviderApi,
|
|
1168
1189
|
parseDataBusChannelIndex: () => parseDataBusChannelIndex,
|
|
1190
|
+
parseInterpolationExpression: () => parseInterpolationExpression,
|
|
1191
|
+
parseInterpolationTemplate: () => parseInterpolationTemplate,
|
|
1169
1192
|
parseProviderJsonChunk: () => parseProviderJsonChunk,
|
|
1170
1193
|
parseRivetWebAppBrowserStorageClientMessage: () => parseRivetWebAppBrowserStorageClientMessage,
|
|
1171
1194
|
parseRivetWebAppBrowserStorageServerMessage: () => parseRivetWebAppBrowserStorageServerMessage,
|
|
@@ -1209,6 +1232,9 @@ __export(exports_exports, {
|
|
|
1209
1232
|
resolveChatV2Credential: () => resolveChatV2Credential,
|
|
1210
1233
|
resolveChatV2ProviderConfig: () => resolveChatV2ProviderConfig,
|
|
1211
1234
|
resolveChatV2ResponseFormatParameters: () => resolveChatV2ResponseFormatParameters,
|
|
1235
|
+
resolveCodeInterpolationExpression: () => resolveCodeInterpolationExpression,
|
|
1236
|
+
resolveInterpolationExpressionRawValue: () => resolveInterpolationExpressionRawValue,
|
|
1237
|
+
resolveInterpolationTokenRawValue: () => resolveInterpolationTokenRawValue,
|
|
1212
1238
|
resolveLLMChatV2RuntimeProviderOptions: () => resolveLLMChatV2RuntimeProviderOptions,
|
|
1213
1239
|
resolveNodePrefabInstance: () => resolveNodePrefabInstance,
|
|
1214
1240
|
resolveNodePrefabInstances: () => resolveNodePrefabInstances,
|
|
@@ -1231,6 +1257,7 @@ __export(exports_exports, {
|
|
|
1231
1257
|
sanitizeIdentifierPortValue: () => sanitizeIdentifierPortValue,
|
|
1232
1258
|
scalarDefaults: () => scalarDefaults,
|
|
1233
1259
|
scalarTypes: () => scalarTypes,
|
|
1260
|
+
scanInterpolationTokenSpans: () => scanInterpolationTokenSpans,
|
|
1234
1261
|
searchKnowledgeNode: () => searchKnowledgeNode,
|
|
1235
1262
|
serializeDatasets: () => serializeDatasets,
|
|
1236
1263
|
serializeGraph: () => serializeGraph,
|
|
@@ -1248,6 +1275,7 @@ __export(exports_exports, {
|
|
|
1248
1275
|
splitRivetWebAppStorageTransfer: () => splitRivetWebAppStorageTransfer,
|
|
1249
1276
|
startBackgroundBranchNode: () => startBackgroundBranchNode,
|
|
1250
1277
|
streamChatV2: () => streamChatV2,
|
|
1278
|
+
stringifyInterpolationSourceValue: () => stringifyInterpolationSourceValue,
|
|
1251
1279
|
stringifyToolResult: () => stringifyToolResult,
|
|
1252
1280
|
stringifyUiGraphValue: () => stringifyUiGraphValue,
|
|
1253
1281
|
subGraphNode: () => subGraphNode,
|
|
@@ -5601,6 +5629,269 @@ function isRecord4(value) {
|
|
|
5601
5629
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
5602
5630
|
}
|
|
5603
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
|
+
|
|
5604
5895
|
// src/utils/pQueueCompat.ts
|
|
5605
5896
|
var import_p_queue = __toESM(require("p-queue-6"), 1);
|
|
5606
5897
|
var PQueue = typeof import_p_queue.default === "function" ? import_p_queue.default : import_p_queue.default.default;
|
|
@@ -6289,7 +6580,6 @@ function buildGraphExecutionPlan(options2) {
|
|
|
6289
6580
|
}
|
|
6290
6581
|
|
|
6291
6582
|
// src/model/GraphBoundaryCache.ts
|
|
6292
|
-
var GRAPH_BOUNDARY_OUTPUT_DEMAND_OPTIMIZATION_ENABLED = false;
|
|
6293
6583
|
function getGraphBoundary(project, graphId2, cache4) {
|
|
6294
6584
|
if (!graphId2) {
|
|
6295
6585
|
return void 0;
|
|
@@ -6377,9 +6667,6 @@ function buildExcludedGraphBoundaryOutputs(boundary) {
|
|
|
6377
6667
|
}
|
|
6378
6668
|
return outputs;
|
|
6379
6669
|
}
|
|
6380
|
-
function getRequestedGraphOutputNodeIds(boundary, requestedOutputPortIds) {
|
|
6381
|
-
return boundary.outputs.filter((output) => requestedOutputPortIds.has(output.portId)).map((output) => output.nodeId);
|
|
6382
|
-
}
|
|
6383
6670
|
function deriveGraphBoundary(graph) {
|
|
6384
6671
|
const inputsById = /* @__PURE__ */ new Map();
|
|
6385
6672
|
const outputsById = /* @__PURE__ */ new Map();
|
|
@@ -6411,6 +6698,98 @@ function getBoundaryNodeId(node) {
|
|
|
6411
6698
|
return node.data.id;
|
|
6412
6699
|
}
|
|
6413
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
|
+
|
|
6414
6793
|
// src/model/GraphBoundaryEffects.ts
|
|
6415
6794
|
function ensureGraphCostOutput(graphOutputs, totalCost) {
|
|
6416
6795
|
const costPort = "cost";
|
|
@@ -6422,11 +6801,11 @@ function ensureGraphCostOutput(graphOutputs, totalCost) {
|
|
|
6422
6801
|
}
|
|
6423
6802
|
}
|
|
6424
6803
|
function applyFrozenGraphBoundaryEffects(graphOutputs, node, outputValues) {
|
|
6425
|
-
var _a;
|
|
6804
|
+
var _a, _b;
|
|
6426
6805
|
if (node.type === "graphOutput") {
|
|
6427
6806
|
const outputId = (_a = node.data) == null ? void 0 : _a.id;
|
|
6428
6807
|
const valueOutput = outputValues["valueOutput"];
|
|
6429
|
-
if (outputId && valueOutput) {
|
|
6808
|
+
if (outputId && valueOutput && (graphOutputs[outputId] == null || ((_b = graphOutputs[outputId]) == null ? void 0 : _b.type) === "control-flow-excluded")) {
|
|
6430
6809
|
graphOutputs[outputId] = valueOutput;
|
|
6431
6810
|
}
|
|
6432
6811
|
return void 0;
|
|
@@ -6481,7 +6860,7 @@ function withReplayRecordedAt(data, replayRecordedAt) {
|
|
|
6481
6860
|
}
|
|
6482
6861
|
return { ...data, replayRecordedAt };
|
|
6483
6862
|
}
|
|
6484
|
-
var
|
|
6863
|
+
var REPLAY_TIMED_EVENTS = /* @__PURE__ */ new Set([
|
|
6485
6864
|
"start",
|
|
6486
6865
|
"graphStart",
|
|
6487
6866
|
"graphOutputsReady",
|
|
@@ -6495,14 +6874,19 @@ var REPLAY_TIMED_LIFECYCLE_EVENTS = /* @__PURE__ */ new Set([
|
|
|
6495
6874
|
"nodeFinish",
|
|
6496
6875
|
"nodeError",
|
|
6497
6876
|
"nodeExcluded",
|
|
6498
|
-
"nodeOutputsCleared"
|
|
6877
|
+
"nodeOutputsCleared",
|
|
6878
|
+
// These records retain their own physical call timestamps, but the replay
|
|
6879
|
+
// timestamp lets observers keep them on the same historical recording
|
|
6880
|
+
// timeline without borrowing a provider timestamp as a node lifecycle time.
|
|
6881
|
+
"llmCallFinished",
|
|
6882
|
+
"llmProfileAttempt",
|
|
6883
|
+
"toolCallFinished"
|
|
6499
6884
|
]);
|
|
6500
6885
|
async function replayExecutionRecording(options2) {
|
|
6501
6886
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
6502
6887
|
const {
|
|
6503
6888
|
emitter,
|
|
6504
6889
|
erroredNodes,
|
|
6505
|
-
graphOutputs,
|
|
6506
6890
|
fallbackGraphId,
|
|
6507
6891
|
initialReplayExecution,
|
|
6508
6892
|
project,
|
|
@@ -6517,6 +6901,7 @@ async function replayExecutionRecording(options2) {
|
|
|
6517
6901
|
nodeResults,
|
|
6518
6902
|
isAborted
|
|
6519
6903
|
} = options2;
|
|
6904
|
+
let graphOutputs = options2.graphOutputs;
|
|
6520
6905
|
const nodesByIdAllGraphs = {};
|
|
6521
6906
|
const graphIdByNodeId = {};
|
|
6522
6907
|
for (const graph of Object.values(project.graphs)) {
|
|
@@ -6535,7 +6920,7 @@ async function replayExecutionRecording(options2) {
|
|
|
6535
6920
|
};
|
|
6536
6921
|
const emitReplayExecutionEvent = (event, data) => {
|
|
6537
6922
|
hasEmittedRunActivityExecution = true;
|
|
6538
|
-
const payload =
|
|
6923
|
+
const payload = REPLAY_TIMED_EVENTS.has(event) ? withReplayRecordedAt(data, currentReplayRecordedAt) : data;
|
|
6539
6924
|
emitDetached(emitter, event, payload);
|
|
6540
6925
|
};
|
|
6541
6926
|
const emitReplayTerminalEvent = (event, data) => {
|
|
@@ -6625,13 +7010,13 @@ async function replayExecutionRecording(options2) {
|
|
|
6625
7010
|
replayRootRunId = replayRootRunIds.size === 0 && initialReplayExecution ? initialReplayExecution.rootRunId : (0, import_non_secure4.nanoid)();
|
|
6626
7011
|
replayRootRunIds.set(recordedExecution.rootRunId, replayRootRunId);
|
|
6627
7012
|
}
|
|
6628
|
-
const getReplayGraphRunId = (recordedGraphRunId) => {
|
|
7013
|
+
const getReplayGraphRunId = (recordedGraphRunId, initialGraphRunId) => {
|
|
6629
7014
|
let graphRunIds = replayGraphRunIdsByRoot.get(recordedExecution.rootRunId);
|
|
6630
7015
|
if (graphRunIds == null) {
|
|
6631
7016
|
graphRunIds = /* @__PURE__ */ new Map();
|
|
6632
7017
|
replayGraphRunIdsByRoot.set(recordedExecution.rootRunId, graphRunIds);
|
|
6633
7018
|
}
|
|
6634
|
-
const replayGraphRunId = graphRunIds.get(recordedGraphRunId) ?? (0, import_non_secure4.nanoid)();
|
|
7019
|
+
const replayGraphRunId = initialGraphRunId ?? graphRunIds.get(recordedGraphRunId) ?? (0, import_non_secure4.nanoid)();
|
|
6635
7020
|
graphRunIds.set(recordedGraphRunId, replayGraphRunId);
|
|
6636
7021
|
return replayGraphRunId;
|
|
6637
7022
|
};
|
|
@@ -6640,17 +7025,25 @@ async function replayExecutionRecording(options2) {
|
|
|
6640
7025
|
return {
|
|
6641
7026
|
...rest,
|
|
6642
7027
|
rootRunId: replayRootRunId,
|
|
6643
|
-
|
|
7028
|
+
// Seed the root mapping too, so child parentGraphRunId references resolve
|
|
7029
|
+
// to the same identity already allocated by the playback processor.
|
|
7030
|
+
graphRunId: getReplayGraphRunId(
|
|
7031
|
+
graphRunId,
|
|
7032
|
+
isInitialRootGraph ? initialReplayExecution.graphRunId : void 0
|
|
7033
|
+
),
|
|
6644
7034
|
...parentGraphRunId == null ? {} : { parentGraphRunId: getReplayGraphRunId(parentGraphRunId) }
|
|
6645
7035
|
};
|
|
6646
7036
|
};
|
|
6647
7037
|
const getNodeRunKey = (execution, nodeId, processId) => `${execution.rootRunId}:${execution.graphRunId}:${nodeId}:${processId}`;
|
|
6648
7038
|
const getRecordedDuration = (recordedDuration, execution, nodeId, processId, terminalTs) => {
|
|
6649
|
-
if (recordedDuration
|
|
7039
|
+
if (isValidRecordedDuration(recordedDuration)) {
|
|
6650
7040
|
return recordedDuration;
|
|
6651
7041
|
}
|
|
6652
7042
|
const startedAt = nodeStartTimestamps.get(getNodeRunKey(execution, nodeId, processId));
|
|
6653
|
-
|
|
7043
|
+
if (!isValidRecordedTimestamp(startedAt) || !isValidRecordedTimestamp(terminalTs) || terminalTs < startedAt) {
|
|
7044
|
+
return void 0;
|
|
7045
|
+
}
|
|
7046
|
+
return terminalTs - startedAt;
|
|
6654
7047
|
};
|
|
6655
7048
|
for (const event of recorder.events) {
|
|
6656
7049
|
if (isAborted()) {
|
|
@@ -6687,9 +7080,9 @@ async function replayExecutionRecording(options2) {
|
|
|
6687
7080
|
}
|
|
6688
7081
|
case "done": {
|
|
6689
7082
|
emitFallbackRootTerminal("completed", { outputs: event.data.results });
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
7083
|
+
await emitter.emit("done", withReplayRecordedAt(event.data, currentReplayRecordedAt));
|
|
7084
|
+
graphOutputs = event.data.results;
|
|
7085
|
+
setGraphOutputs(graphOutputs);
|
|
6693
7086
|
break;
|
|
6694
7087
|
}
|
|
6695
7088
|
case "error": {
|
|
@@ -6814,6 +7207,8 @@ async function replayExecutionRecording(options2) {
|
|
|
6814
7207
|
node,
|
|
6815
7208
|
error: data.error,
|
|
6816
7209
|
processId: data.processId,
|
|
7210
|
+
...data.outputs === void 0 ? {} : { outputs: data.outputs },
|
|
7211
|
+
...data.splitOutputs === void 0 ? {} : { splitOutputs: data.splitOutputs },
|
|
6817
7212
|
...data.resultOrigin === void 0 ? {} : { resultOrigin: data.resultOrigin },
|
|
6818
7213
|
execution
|
|
6819
7214
|
},
|
|
@@ -6930,7 +7325,6 @@ async function replayExecutionRecording(options2) {
|
|
|
6930
7325
|
break;
|
|
6931
7326
|
}
|
|
6932
7327
|
case "finish": {
|
|
6933
|
-
emitDetached(emitter, "finish", void 0);
|
|
6934
7328
|
break;
|
|
6935
7329
|
}
|
|
6936
7330
|
default: {
|
|
@@ -6959,9 +7353,16 @@ async function replayExecutionRecording(options2) {
|
|
|
6959
7353
|
emitReplayTerminalEvent("error", { error: replayError });
|
|
6960
7354
|
} finally {
|
|
6961
7355
|
setRunning(false);
|
|
7356
|
+
emitDetached(emitter, "finish", void 0);
|
|
6962
7357
|
}
|
|
6963
7358
|
return graphOutputs;
|
|
6964
7359
|
}
|
|
7360
|
+
function isValidRecordedTimestamp(value) {
|
|
7361
|
+
return value != null && Number.isFinite(value) && value >= 0;
|
|
7362
|
+
}
|
|
7363
|
+
function isValidRecordedDuration(value) {
|
|
7364
|
+
return value != null && Number.isFinite(value) && value >= 0;
|
|
7365
|
+
}
|
|
6965
7366
|
|
|
6966
7367
|
// src/model/loopControllerBreak.ts
|
|
6967
7368
|
var LOOP_NOT_BROKEN_SENTINEL = "loop-not-broken";
|
|
@@ -6984,6 +7385,7 @@ function buildNodeProcessContext(options2) {
|
|
|
6984
7385
|
node,
|
|
6985
7386
|
nodeAbortController,
|
|
6986
7387
|
onPartialOutputs,
|
|
7388
|
+
setFailureOutputs,
|
|
6987
7389
|
processId,
|
|
6988
7390
|
requestUserInput,
|
|
6989
7391
|
reportProgress,
|
|
@@ -7001,8 +7403,11 @@ function buildNodeProcessContext(options2) {
|
|
|
7001
7403
|
isDirectRunTarget,
|
|
7002
7404
|
markResultAsEditorCacheHit,
|
|
7003
7405
|
waitEvent,
|
|
7406
|
+
waitForGlobal: (id, signal = nodeAbortController.signal) => base.waitForGlobal(id, signal),
|
|
7407
|
+
waitForStoredValue: (key, signal = nodeAbortController.signal) => base.waitForStoredValue(key, signal),
|
|
7004
7408
|
externalFunctions: { ...externalFunctions },
|
|
7005
7409
|
onPartialOutputs,
|
|
7410
|
+
setFailureOutputs,
|
|
7006
7411
|
signal: nodeAbortController.signal,
|
|
7007
7412
|
processId,
|
|
7008
7413
|
splitIndex,
|
|
@@ -7118,15 +7523,13 @@ async function processSplitRunNode(node, processId, deps) {
|
|
|
7118
7523
|
resultOrigin: "executed"
|
|
7119
7524
|
});
|
|
7120
7525
|
const timingStart = (_a = deps.startNodeTiming) == null ? void 0 : _a.call(deps);
|
|
7121
|
-
|
|
7122
|
-
let results = [];
|
|
7526
|
+
const results = [];
|
|
7123
7527
|
try {
|
|
7124
7528
|
if (node.isSplitSequential) {
|
|
7125
|
-
|
|
7529
|
+
await runSequential(node, inputValues, inputDefinitionsById, splittingAmount, processId, deps, results);
|
|
7126
7530
|
} else {
|
|
7127
|
-
results
|
|
7531
|
+
results.push(...await runParallel(node, inputValues, inputDefinitionsById, splittingAmount, processId, deps));
|
|
7128
7532
|
}
|
|
7129
|
-
splitRunDurationMs = getSplitRunDurationMs(results);
|
|
7130
7533
|
const errors = results.filter((r) => r.type === "error").map((r) => r.error);
|
|
7131
7534
|
if (errors.length === 1) {
|
|
7132
7535
|
throw errors[0];
|
|
@@ -7136,7 +7539,7 @@ async function processSplitRunNode(node, processId, deps) {
|
|
|
7136
7539
|
}
|
|
7137
7540
|
throw new AggregateError(errors);
|
|
7138
7541
|
}
|
|
7139
|
-
const aggregateResults = aggregateOutputs(results);
|
|
7542
|
+
const aggregateResults = aggregateOutputs(results.filter(isSplitOutputResult));
|
|
7140
7543
|
deps.setNodeResults(node.id, aggregateResults);
|
|
7141
7544
|
deps.markNodeVisited(node.id);
|
|
7142
7545
|
await deps.emit(
|
|
@@ -7149,7 +7552,7 @@ async function processSplitRunNode(node, processId, deps) {
|
|
|
7149
7552
|
resultOrigin: getSplitRunResultOrigin(results)
|
|
7150
7553
|
},
|
|
7151
7554
|
(_b = deps.finishNodeTiming) == null ? void 0 : _b.call(deps, timingStart),
|
|
7152
|
-
|
|
7555
|
+
getSplitRunDurationMs(results)
|
|
7153
7556
|
)
|
|
7154
7557
|
);
|
|
7155
7558
|
} catch (error) {
|
|
@@ -7158,14 +7561,14 @@ async function processSplitRunNode(node, processId, deps) {
|
|
|
7158
7561
|
error,
|
|
7159
7562
|
processId,
|
|
7160
7563
|
(_c = deps.finishNodeTiming) == null ? void 0 : _c.call(deps, timingStart),
|
|
7161
|
-
|
|
7162
|
-
getSplitRunResultOrigin(results)
|
|
7564
|
+
getSplitRunDurationMs(results),
|
|
7565
|
+
getSplitRunResultOrigin(results),
|
|
7566
|
+
getSplitTerminalOutputs(results)
|
|
7163
7567
|
);
|
|
7164
7568
|
}
|
|
7165
7569
|
}
|
|
7166
|
-
async function runSequential(node, inputValues, inputDefinitionsById, splittingAmount, processId, deps) {
|
|
7570
|
+
async function runSequential(node, inputValues, inputDefinitionsById, splittingAmount, processId, deps, results) {
|
|
7167
7571
|
var _a, _b, _c;
|
|
7168
|
-
const results = [];
|
|
7169
7572
|
for (let i = 0; i < splittingAmount; i++) {
|
|
7170
7573
|
if (deps.isAborted()) {
|
|
7171
7574
|
throw deps.getAbortError();
|
|
@@ -7193,17 +7596,18 @@ async function runSequential(node, inputValues, inputDefinitionsById, splittingA
|
|
|
7193
7596
|
}
|
|
7194
7597
|
);
|
|
7195
7598
|
deps.accumulateCost(output);
|
|
7196
|
-
results.push({ type: "output", output, resultOrigin, durationMs: (_b = deps.finishNodeTiming) == null ? void 0 : _b.call(deps, splitTimingStart) });
|
|
7599
|
+
results.push({ type: "output", index: i, output, resultOrigin, durationMs: (_b = deps.finishNodeTiming) == null ? void 0 : _b.call(deps, splitTimingStart) });
|
|
7197
7600
|
} catch (error) {
|
|
7198
7601
|
results.push({
|
|
7199
7602
|
type: "error",
|
|
7200
7603
|
error: getError(error),
|
|
7604
|
+
index: i,
|
|
7201
7605
|
resultOrigin,
|
|
7202
|
-
durationMs: (_c = deps.finishNodeTiming) == null ? void 0 : _c.call(deps, splitTimingStart)
|
|
7606
|
+
durationMs: (_c = deps.finishNodeTiming) == null ? void 0 : _c.call(deps, splitTimingStart),
|
|
7607
|
+
failureOutputs: deps.takeFailureOutputs(processId, i)
|
|
7203
7608
|
});
|
|
7204
7609
|
}
|
|
7205
7610
|
}
|
|
7206
|
-
return results;
|
|
7207
7611
|
}
|
|
7208
7612
|
async function runParallel(node, inputValues, inputDefinitionsById, splittingAmount, processId, deps) {
|
|
7209
7613
|
const queue = new pQueueCompat_default({ concurrency: getParallelSplitRunConcurrency(node, deps.splitRunConcurrency) });
|
|
@@ -7211,12 +7615,13 @@ async function runParallel(node, inputValues, inputDefinitionsById, splittingAmo
|
|
|
7211
7615
|
(0, import_lodash_es3.range)(0, splittingAmount).map(async (i) => {
|
|
7212
7616
|
const result = await queue.add(async () => {
|
|
7213
7617
|
var _a, _b, _c;
|
|
7214
|
-
const splitTimingStart = (_a = deps.startNodeTiming) == null ? void 0 : _a.call(deps);
|
|
7215
7618
|
let resultOrigin = "executed";
|
|
7619
|
+
let splitTimingStart;
|
|
7216
7620
|
try {
|
|
7217
7621
|
if (deps.isAborted()) {
|
|
7218
7622
|
throw deps.getAbortError();
|
|
7219
7623
|
}
|
|
7624
|
+
splitTimingStart = (_a = deps.startNodeTiming) == null ? void 0 : _a.call(deps);
|
|
7220
7625
|
const inputs = splitInputsAtIndex(inputValues, inputDefinitionsById, i);
|
|
7221
7626
|
const output = await deps.processNodeWithInputData(
|
|
7222
7627
|
node,
|
|
@@ -7239,6 +7644,7 @@ async function runParallel(node, inputValues, inputDefinitionsById, splittingAmo
|
|
|
7239
7644
|
deps.accumulateCost(output);
|
|
7240
7645
|
return {
|
|
7241
7646
|
type: "output",
|
|
7647
|
+
index: i,
|
|
7242
7648
|
output,
|
|
7243
7649
|
resultOrigin,
|
|
7244
7650
|
durationMs: (_b = deps.finishNodeTiming) == null ? void 0 : _b.call(deps, splitTimingStart)
|
|
@@ -7247,8 +7653,10 @@ async function runParallel(node, inputValues, inputDefinitionsById, splittingAmo
|
|
|
7247
7653
|
return {
|
|
7248
7654
|
type: "error",
|
|
7249
7655
|
error: getError(error),
|
|
7656
|
+
index: i,
|
|
7250
7657
|
resultOrigin,
|
|
7251
|
-
durationMs: (_c = deps.finishNodeTiming) == null ? void 0 : _c.call(deps, splitTimingStart)
|
|
7658
|
+
durationMs: splitTimingStart === void 0 ? void 0 : (_c = deps.finishNodeTiming) == null ? void 0 : _c.call(deps, splitTimingStart),
|
|
7659
|
+
failureOutputs: deps.takeFailureOutputs(processId, i)
|
|
7252
7660
|
};
|
|
7253
7661
|
}
|
|
7254
7662
|
});
|
|
@@ -7262,6 +7670,14 @@ async function runParallel(node, inputValues, inputDefinitionsById, splittingAmo
|
|
|
7262
7670
|
function getSplitRunResultOrigin(results) {
|
|
7263
7671
|
return results.length > 0 && results.every((result) => result.resultOrigin === "editor-cache") ? "editor-cache" : "executed";
|
|
7264
7672
|
}
|
|
7673
|
+
function getSplitTerminalOutputs(results) {
|
|
7674
|
+
const outputs = Object.fromEntries(
|
|
7675
|
+
results.flatMap(
|
|
7676
|
+
(result) => result.type === "output" ? [[result.index, result.output]] : result.failureOutputs !== void 0 ? [[result.index, result.failureOutputs]] : []
|
|
7677
|
+
)
|
|
7678
|
+
);
|
|
7679
|
+
return Object.keys(outputs).length === 0 ? void 0 : outputs;
|
|
7680
|
+
}
|
|
7265
7681
|
function getParallelSplitRunConcurrency(node, defaultConcurrency) {
|
|
7266
7682
|
const value = node.splitRunConcurrency;
|
|
7267
7683
|
return typeof value === "number" && Number.isFinite(value) && value >= 2 ? Math.floor(value) : defaultConcurrency;
|
|
@@ -7286,11 +7702,14 @@ function aggregateOutputs(results) {
|
|
|
7286
7702
|
return acc;
|
|
7287
7703
|
}, {});
|
|
7288
7704
|
}
|
|
7705
|
+
function isSplitOutputResult(result) {
|
|
7706
|
+
return result.type === "output";
|
|
7707
|
+
}
|
|
7289
7708
|
function getSplitRunDurationMs(results) {
|
|
7290
7709
|
const durations = {};
|
|
7291
|
-
for (const
|
|
7710
|
+
for (const result of results) {
|
|
7292
7711
|
if (result.durationMs !== void 0) {
|
|
7293
|
-
durations[index] = result.durationMs;
|
|
7712
|
+
durations[result.index] = result.durationMs;
|
|
7294
7713
|
}
|
|
7295
7714
|
}
|
|
7296
7715
|
return Object.keys(durations).length > 0 ? durations : void 0;
|
|
@@ -7741,9 +8160,9 @@ var RivetStoredValueController = class {
|
|
|
7741
8160
|
}
|
|
7742
8161
|
});
|
|
7743
8162
|
});
|
|
8163
|
+
const value = waiterPromise === void 0 ? immediateValue : await waiterPromise;
|
|
7744
8164
|
signal == null ? void 0 : signal.throwIfAborted();
|
|
7745
|
-
|
|
7746
|
-
return await waiterPromise;
|
|
8165
|
+
return value;
|
|
7747
8166
|
}
|
|
7748
8167
|
async #getUnlocked(key) {
|
|
7749
8168
|
var _a;
|
|
@@ -7937,67 +8356,6 @@ function createExcludedNodeOutputs(node, outputDefinitions) {
|
|
|
7937
8356
|
return outputs;
|
|
7938
8357
|
}
|
|
7939
8358
|
|
|
7940
|
-
// src/model/chat-v2/toolContinuationConnection.ts
|
|
7941
|
-
var LLM_CHAT_V2_TOOL_CALLS_OUTPUT_ID = "function-calls";
|
|
7942
|
-
var DELEGATE_TOOL_CALL_INPUT_ID = "function-call";
|
|
7943
|
-
function resolveToolContinuationConnections(graph) {
|
|
7944
|
-
const nodesById = new Map(graph.nodes.map((node) => [node.id, node]));
|
|
7945
|
-
const firstConnectionByInput = /* @__PURE__ */ new Map();
|
|
7946
|
-
for (const connection of graph.connections) {
|
|
7947
|
-
if (!nodesById.has(connection.outputNodeId) || !nodesById.has(connection.inputNodeId)) {
|
|
7948
|
-
continue;
|
|
7949
|
-
}
|
|
7950
|
-
const inputKey = `${connection.inputNodeId}\0${connection.inputId}`;
|
|
7951
|
-
if (!firstConnectionByInput.has(inputKey)) {
|
|
7952
|
-
firstConnectionByInput.set(inputKey, connection);
|
|
7953
|
-
}
|
|
7954
|
-
}
|
|
7955
|
-
const candidatesByLLMNodeId = /* @__PURE__ */ new Map();
|
|
7956
|
-
for (const connection of graph.connections) {
|
|
7957
|
-
if (connection.outputId !== LLM_CHAT_V2_TOOL_CALLS_OUTPUT_ID || connection.inputId !== DELEGATE_TOOL_CALL_INPUT_ID) {
|
|
7958
|
-
continue;
|
|
7959
|
-
}
|
|
7960
|
-
const llmNode = nodesById.get(connection.outputNodeId);
|
|
7961
|
-
const delegateNode = nodesById.get(connection.inputNodeId);
|
|
7962
|
-
if (!isEligibleLLMChatV2Node(llmNode) || !isEligibleDelegateToolCallNode(delegateNode)) {
|
|
7963
|
-
continue;
|
|
7964
|
-
}
|
|
7965
|
-
const inputKey = `${connection.inputNodeId}\0${connection.inputId}`;
|
|
7966
|
-
if (firstConnectionByInput.get(inputKey) !== connection) {
|
|
7967
|
-
continue;
|
|
7968
|
-
}
|
|
7969
|
-
const candidates = candidatesByLLMNodeId.get(llmNode.id);
|
|
7970
|
-
const candidate = { connection, delegateNode };
|
|
7971
|
-
if (candidates) {
|
|
7972
|
-
candidates.push(candidate);
|
|
7973
|
-
} else {
|
|
7974
|
-
candidatesByLLMNodeId.set(llmNode.id, [candidate]);
|
|
7975
|
-
}
|
|
7976
|
-
}
|
|
7977
|
-
const resolutions = /* @__PURE__ */ new Map();
|
|
7978
|
-
for (const [llmNodeId, candidates] of candidatesByLLMNodeId) {
|
|
7979
|
-
if (candidates.length === 1) {
|
|
7980
|
-
resolutions.set(llmNodeId, { kind: "connected", ...candidates[0] });
|
|
7981
|
-
} else {
|
|
7982
|
-
resolutions.set(llmNodeId, { kind: "ambiguous", candidates });
|
|
7983
|
-
}
|
|
7984
|
-
}
|
|
7985
|
-
return resolutions;
|
|
7986
|
-
}
|
|
7987
|
-
function resolveToolContinuationConnection(graph, llmNodeId) {
|
|
7988
|
-
return resolveToolContinuationConnections(graph).get(llmNodeId) ?? { kind: "none" };
|
|
7989
|
-
}
|
|
7990
|
-
function isEligibleLLMChatV2Node(node) {
|
|
7991
|
-
if (!node || node.disabled || node.isSplitRun || node.type !== "llmChatV2") {
|
|
7992
|
-
return false;
|
|
7993
|
-
}
|
|
7994
|
-
const data = node.data;
|
|
7995
|
-
return data.useToolCalling === true && data.autoContinueToolCalls === true;
|
|
7996
|
-
}
|
|
7997
|
-
function isEligibleDelegateToolCallNode(node) {
|
|
7998
|
-
return (node == null ? void 0 : node.type) === "delegateFunctionCall" && !node.disabled;
|
|
7999
|
-
}
|
|
8000
|
-
|
|
8001
8359
|
// src/model/nodes/toolCallDelegation.ts
|
|
8002
8360
|
var import_lodash_es4 = require("lodash");
|
|
8003
8361
|
|
|
@@ -9180,6 +9538,495 @@ var ConnectedToolContinuationHost = class {
|
|
|
9180
9538
|
}
|
|
9181
9539
|
};
|
|
9182
9540
|
|
|
9541
|
+
// src/utils/interpolation.ts
|
|
9542
|
+
var ESCAPED_TOKEN_REGEX = /\{\{\{([^}]+?)\}\}\}/g;
|
|
9543
|
+
var ESCAPED_ESCAPED_TOKEN_REGEX = /\\\{\\\{([^}]+?)\\\}\\\}/g;
|
|
9544
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_ENTRIES = 2048;
|
|
9545
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_LENGTH = 64 * 1024;
|
|
9546
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_CHARS = 1024 * 1024;
|
|
9547
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_STORAGE_CHARS = 2 * 1024 * 1024;
|
|
9548
|
+
var INTERPOLATION_EXPRESSION_CACHE_MAX_ENTRIES = 512;
|
|
9549
|
+
var INTERPOLATION_EXPRESSION_CACHE_MAX_EXPRESSION_LENGTH = 4 * 1024;
|
|
9550
|
+
var INTERPOLATION_EXPRESSION_CACHE_MAX_CHARS = 128 * 1024;
|
|
9551
|
+
var interpolationTemplateCache = /* @__PURE__ */ new Map();
|
|
9552
|
+
var cachedInterpolationTemplateChars = 0;
|
|
9553
|
+
var cachedInterpolationTemplateStorageChars = 0;
|
|
9554
|
+
var lastUncachedInterpolationTemplate;
|
|
9555
|
+
var interpolationExpressionCache = /* @__PURE__ */ new Map();
|
|
9556
|
+
var cachedInterpolationExpressionChars = 0;
|
|
9557
|
+
var dataValueTypeSet = new Set(dataTypes);
|
|
9558
|
+
var processingFunctions = {
|
|
9559
|
+
indent: (input, spaces = 0) => {
|
|
9560
|
+
const indent = " ".repeat(spaces);
|
|
9561
|
+
return input.split("\n").map((line) => `${indent}${line}`).join("\n");
|
|
9562
|
+
},
|
|
9563
|
+
quote: (input, level = 1) => {
|
|
9564
|
+
const quotePrefix = "> ".repeat(level);
|
|
9565
|
+
return input.split("\n").map((line) => `${quotePrefix}${line}`).join("\n");
|
|
9566
|
+
},
|
|
9567
|
+
uppercase: (input) => input.toUpperCase(),
|
|
9568
|
+
lowercase: (input) => input.toLowerCase(),
|
|
9569
|
+
trim: (input) => input.trim(),
|
|
9570
|
+
truncate: (input, length = 50) => {
|
|
9571
|
+
if (input.length <= length) return input;
|
|
9572
|
+
return input.slice(0, length) + "...";
|
|
9573
|
+
},
|
|
9574
|
+
list: (input, level = 1) => {
|
|
9575
|
+
const indent = " ".repeat(level - 1);
|
|
9576
|
+
return input.split("\n").map((line) => `${indent}- ${line}`).join("\n");
|
|
9577
|
+
},
|
|
9578
|
+
sort: (input) => input.split("\n").sort().join("\n"),
|
|
9579
|
+
dedent: (input) => (0, import_ts_dedent.dedent)(input),
|
|
9580
|
+
wrap: (input, width = 80) => {
|
|
9581
|
+
const words = input.split(/\s+/);
|
|
9582
|
+
const lines = [];
|
|
9583
|
+
let currentLine = "";
|
|
9584
|
+
for (const word of words) {
|
|
9585
|
+
if (currentLine.length + word.length + 1 <= width) {
|
|
9586
|
+
currentLine += (currentLine ? " " : "") + word;
|
|
9587
|
+
} else {
|
|
9588
|
+
lines.push(currentLine);
|
|
9589
|
+
currentLine = word;
|
|
9590
|
+
}
|
|
9591
|
+
}
|
|
9592
|
+
if (currentLine) {
|
|
9593
|
+
lines.push(currentLine);
|
|
9594
|
+
}
|
|
9595
|
+
return lines.join("\n");
|
|
9596
|
+
}
|
|
9597
|
+
};
|
|
9598
|
+
function unwrapPotentialDataValue(value) {
|
|
9599
|
+
if (isRivetDataValue(value)) {
|
|
9600
|
+
return value.value;
|
|
9601
|
+
}
|
|
9602
|
+
return value;
|
|
9603
|
+
}
|
|
9604
|
+
function isRivetDataValue(value) {
|
|
9605
|
+
return typeof value === "object" && value !== null && typeof value.type === "string" && dataValueTypeSet.has(value.type) && Object.prototype.hasOwnProperty.call(value, "value");
|
|
9606
|
+
}
|
|
9607
|
+
function stringifyInterpolationSourceValue(value, {
|
|
9608
|
+
coerceDataValueToString = false,
|
|
9609
|
+
unwrapDataValue: unwrapDataValue2 = true
|
|
9610
|
+
} = {}) {
|
|
9611
|
+
try {
|
|
9612
|
+
if (coerceDataValueToString && unwrapDataValue2 && isRivetDataValue(value)) {
|
|
9613
|
+
return coerceTypeOptional(value, "string") ?? "";
|
|
9614
|
+
}
|
|
9615
|
+
return String((unwrapDataValue2 ? unwrapPotentialDataValue(value) : value) ?? "");
|
|
9616
|
+
} catch {
|
|
9617
|
+
return "[object Object]";
|
|
9618
|
+
}
|
|
9619
|
+
}
|
|
9620
|
+
function findTopLevelProcessorSeparator(rawInner) {
|
|
9621
|
+
let quote;
|
|
9622
|
+
let regex = false;
|
|
9623
|
+
let regexCharacterClass = false;
|
|
9624
|
+
let bracketDepth = 0;
|
|
9625
|
+
let parenthesisDepth = 0;
|
|
9626
|
+
let braceDepth = 0;
|
|
9627
|
+
for (let cursor = 0; cursor < rawInner.length; cursor++) {
|
|
9628
|
+
const character = rawInner[cursor];
|
|
9629
|
+
if (regex) {
|
|
9630
|
+
if (character === "[" && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9631
|
+
regexCharacterClass = true;
|
|
9632
|
+
} else if (character === "]" && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9633
|
+
regexCharacterClass = false;
|
|
9634
|
+
} else if (character === "/" && !regexCharacterClass && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9635
|
+
regex = false;
|
|
9636
|
+
}
|
|
9637
|
+
continue;
|
|
9638
|
+
}
|
|
9639
|
+
if (quote) {
|
|
9640
|
+
if (character === quote && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9641
|
+
quote = void 0;
|
|
9642
|
+
}
|
|
9643
|
+
continue;
|
|
9644
|
+
}
|
|
9645
|
+
if (character === "/" && isInterpolationRegexLiteralStart(rawInner, cursor)) {
|
|
9646
|
+
regex = true;
|
|
9647
|
+
regexCharacterClass = false;
|
|
9648
|
+
continue;
|
|
9649
|
+
}
|
|
9650
|
+
if (character === '"' || character === "'" || character === "`") {
|
|
9651
|
+
quote = character;
|
|
9652
|
+
continue;
|
|
9653
|
+
}
|
|
9654
|
+
if (character === "[") {
|
|
9655
|
+
bracketDepth += 1;
|
|
9656
|
+
continue;
|
|
9657
|
+
}
|
|
9658
|
+
if (character === "]" && bracketDepth > 0) {
|
|
9659
|
+
bracketDepth -= 1;
|
|
9660
|
+
continue;
|
|
9661
|
+
}
|
|
9662
|
+
if (character === "(") {
|
|
9663
|
+
parenthesisDepth += 1;
|
|
9664
|
+
continue;
|
|
9665
|
+
}
|
|
9666
|
+
if (character === ")" && parenthesisDepth > 0) {
|
|
9667
|
+
parenthesisDepth -= 1;
|
|
9668
|
+
continue;
|
|
9669
|
+
}
|
|
9670
|
+
if (character === "{") {
|
|
9671
|
+
braceDepth += 1;
|
|
9672
|
+
continue;
|
|
9673
|
+
}
|
|
9674
|
+
if (character === "}" && braceDepth > 0) {
|
|
9675
|
+
braceDepth -= 1;
|
|
9676
|
+
continue;
|
|
9677
|
+
}
|
|
9678
|
+
if (character === "|" && bracketDepth === 0 && parenthesisDepth === 0 && braceDepth === 0) {
|
|
9679
|
+
return cursor;
|
|
9680
|
+
}
|
|
9681
|
+
}
|
|
9682
|
+
return void 0;
|
|
9683
|
+
}
|
|
9684
|
+
function findQuotedStringEnd(value, start) {
|
|
9685
|
+
const quote = value[start];
|
|
9686
|
+
for (let cursor = start + 1; cursor < value.length; cursor++) {
|
|
9687
|
+
if (value[cursor] === quote && !isInterpolationSyntaxCharacterEscaped(value, cursor)) {
|
|
9688
|
+
return cursor;
|
|
9689
|
+
}
|
|
9690
|
+
}
|
|
9691
|
+
return void 0;
|
|
9692
|
+
}
|
|
9693
|
+
function parseQuotedBaseReference(expression) {
|
|
9694
|
+
if (expression[0] !== "[") {
|
|
9695
|
+
return void 0;
|
|
9696
|
+
}
|
|
9697
|
+
let cursor = 1;
|
|
9698
|
+
while (expression[cursor] === " ") {
|
|
9699
|
+
cursor += 1;
|
|
9700
|
+
}
|
|
9701
|
+
const quote = expression[cursor];
|
|
9702
|
+
if (quote !== '"' && quote !== "'") {
|
|
9703
|
+
return void 0;
|
|
9704
|
+
}
|
|
9705
|
+
const quoteEnd = findQuotedStringEnd(expression, cursor);
|
|
9706
|
+
if (quoteEnd === void 0) {
|
|
9707
|
+
return void 0;
|
|
9708
|
+
}
|
|
9709
|
+
const baseName = expression.slice(cursor + 1, quoteEnd);
|
|
9710
|
+
if (!baseName) {
|
|
9711
|
+
return void 0;
|
|
9712
|
+
}
|
|
9713
|
+
cursor = quoteEnd + 1;
|
|
9714
|
+
while (expression[cursor] === " ") {
|
|
9715
|
+
cursor += 1;
|
|
9716
|
+
}
|
|
9717
|
+
if (expression[cursor] !== "]") {
|
|
9718
|
+
return void 0;
|
|
9719
|
+
}
|
|
9720
|
+
const suffix = expression.slice(cursor + 1).trimStart();
|
|
9721
|
+
if (suffix !== "" && !suffix.startsWith(".") && !suffix.startsWith("[")) {
|
|
9722
|
+
return void 0;
|
|
9723
|
+
}
|
|
9724
|
+
return { baseName, suffix: suffix || void 0 };
|
|
9725
|
+
}
|
|
9726
|
+
function parseBaseReference(expression, source) {
|
|
9727
|
+
const trimmedExpression = expression.trim();
|
|
9728
|
+
if (!trimmedExpression) {
|
|
9729
|
+
return void 0;
|
|
9730
|
+
}
|
|
9731
|
+
const quotedReference = parseQuotedBaseReference(trimmedExpression);
|
|
9732
|
+
if (quotedReference) {
|
|
9733
|
+
return {
|
|
9734
|
+
source,
|
|
9735
|
+
baseName: quotedReference.baseName,
|
|
9736
|
+
jsonPath: quotedReference.suffix ? normalizeJsonPathExpression(`$${quotedReference.suffix}`) : void 0
|
|
9737
|
+
};
|
|
9738
|
+
}
|
|
9739
|
+
let suffixStart = -1;
|
|
9740
|
+
for (let cursor = 0; cursor < trimmedExpression.length; cursor++) {
|
|
9741
|
+
const character = trimmedExpression[cursor];
|
|
9742
|
+
if (character === "." || character === "[") {
|
|
9743
|
+
suffixStart = cursor;
|
|
9744
|
+
break;
|
|
9745
|
+
}
|
|
9746
|
+
}
|
|
9747
|
+
if (suffixStart === -1) {
|
|
9748
|
+
return {
|
|
9749
|
+
source,
|
|
9750
|
+
baseName: trimmedExpression,
|
|
9751
|
+
jsonPath: void 0
|
|
9752
|
+
};
|
|
9753
|
+
}
|
|
9754
|
+
const baseName = trimmedExpression.slice(0, suffixStart).trim();
|
|
9755
|
+
const suffix = normalizeJsonPathExpression(trimmedExpression.slice(suffixStart));
|
|
9756
|
+
if (!baseName || !suffix.startsWith(".") && !suffix.startsWith("[")) {
|
|
9757
|
+
return void 0;
|
|
9758
|
+
}
|
|
9759
|
+
return {
|
|
9760
|
+
source,
|
|
9761
|
+
baseName,
|
|
9762
|
+
jsonPath: `$${suffix}`
|
|
9763
|
+
};
|
|
9764
|
+
}
|
|
9765
|
+
function parseInterpolationExpressionUncached(trimmedExpression) {
|
|
9766
|
+
for (const [prefix, source] of [
|
|
9767
|
+
["@graphInputs", "graphInputs"],
|
|
9768
|
+
["@context", "context"]
|
|
9769
|
+
]) {
|
|
9770
|
+
if (trimmedExpression.startsWith(`${prefix}.`)) {
|
|
9771
|
+
return parseBaseReference(trimmedExpression.slice(prefix.length + 1), source);
|
|
9772
|
+
}
|
|
9773
|
+
if (trimmedExpression.startsWith(`${prefix}[`)) {
|
|
9774
|
+
return parseBaseReference(trimmedExpression.slice(prefix.length), source);
|
|
9775
|
+
}
|
|
9776
|
+
}
|
|
9777
|
+
return parseBaseReference(trimmedExpression, "variable");
|
|
9778
|
+
}
|
|
9779
|
+
function getCachedInterpolationExpression(expression) {
|
|
9780
|
+
const trimmedExpression = expression.trim();
|
|
9781
|
+
if (interpolationExpressionCache.has(trimmedExpression)) {
|
|
9782
|
+
return interpolationExpressionCache.get(trimmedExpression);
|
|
9783
|
+
}
|
|
9784
|
+
const parsed = parseInterpolationExpressionUncached(trimmedExpression);
|
|
9785
|
+
if (trimmedExpression.length > INTERPOLATION_EXPRESSION_CACHE_MAX_EXPRESSION_LENGTH) {
|
|
9786
|
+
return parsed;
|
|
9787
|
+
}
|
|
9788
|
+
if (interpolationExpressionCache.size >= INTERPOLATION_EXPRESSION_CACHE_MAX_ENTRIES || cachedInterpolationExpressionChars + trimmedExpression.length > INTERPOLATION_EXPRESSION_CACHE_MAX_CHARS) {
|
|
9789
|
+
interpolationExpressionCache.clear();
|
|
9790
|
+
cachedInterpolationExpressionChars = 0;
|
|
9791
|
+
}
|
|
9792
|
+
const immutableParsed = parsed ? Object.freeze({ ...parsed }) : void 0;
|
|
9793
|
+
interpolationExpressionCache.set(trimmedExpression, immutableParsed);
|
|
9794
|
+
cachedInterpolationExpressionChars += trimmedExpression.length;
|
|
9795
|
+
return immutableParsed;
|
|
9796
|
+
}
|
|
9797
|
+
function parseInterpolationExpression(expression) {
|
|
9798
|
+
const parsed = getCachedInterpolationExpression(expression);
|
|
9799
|
+
return parsed ? { ...parsed } : void 0;
|
|
9800
|
+
}
|
|
9801
|
+
function parseInterpolationToken(rawInner) {
|
|
9802
|
+
const processorSeparator = findTopLevelProcessorSeparator(rawInner);
|
|
9803
|
+
const tokenName = (processorSeparator === void 0 ? rawInner : rawInner.slice(0, processorSeparator)).trim() || void 0;
|
|
9804
|
+
const processingChain = processorSeparator === void 0 ? void 0 : rawInner.slice(processorSeparator + 1).trim() || void 0;
|
|
9805
|
+
return {
|
|
9806
|
+
rawInner,
|
|
9807
|
+
tokenName,
|
|
9808
|
+
processingChain,
|
|
9809
|
+
reference: tokenName ? parseInterpolationExpression(tokenName) : void 0
|
|
9810
|
+
};
|
|
9811
|
+
}
|
|
9812
|
+
function freezeReference(reference) {
|
|
9813
|
+
return reference ? Object.freeze({ ...reference }) : void 0;
|
|
9814
|
+
}
|
|
9815
|
+
function parseInterpolationTemplateUncached(template) {
|
|
9816
|
+
const tokens = scanInterpolationTokenSpans(template).map((span) => {
|
|
9817
|
+
const parsedToken = parseInterpolationToken(span.rawInner);
|
|
9818
|
+
return Object.freeze({
|
|
9819
|
+
...parsedToken,
|
|
9820
|
+
span: Object.freeze({ ...span }),
|
|
9821
|
+
reference: freezeReference(parsedToken.reference)
|
|
9822
|
+
});
|
|
9823
|
+
});
|
|
9824
|
+
return Object.freeze({
|
|
9825
|
+
template,
|
|
9826
|
+
tokens: Object.freeze(tokens)
|
|
9827
|
+
});
|
|
9828
|
+
}
|
|
9829
|
+
function getTemplateStorageChars(template, parsed) {
|
|
9830
|
+
return template.length + parsed.tokens.reduce(
|
|
9831
|
+
(total, token) => {
|
|
9832
|
+
var _a;
|
|
9833
|
+
return total + token.rawInner.length + (((_a = token.tokenName) == null ? void 0 : _a.length) ?? 0);
|
|
9834
|
+
},
|
|
9835
|
+
parsed.tokens.length * 48
|
|
9836
|
+
);
|
|
9837
|
+
}
|
|
9838
|
+
function cacheInterpolationTemplate(template, parsed) {
|
|
9839
|
+
if (template.length > INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_LENGTH) {
|
|
9840
|
+
return;
|
|
9841
|
+
}
|
|
9842
|
+
const storageChars = getTemplateStorageChars(template, parsed);
|
|
9843
|
+
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;
|
|
9844
|
+
if (reachesCapacity) {
|
|
9845
|
+
if (lastUncachedInterpolationTemplate !== template) {
|
|
9846
|
+
lastUncachedInterpolationTemplate = template;
|
|
9847
|
+
return;
|
|
9848
|
+
}
|
|
9849
|
+
interpolationTemplateCache.clear();
|
|
9850
|
+
cachedInterpolationTemplateChars = 0;
|
|
9851
|
+
cachedInterpolationTemplateStorageChars = 0;
|
|
9852
|
+
}
|
|
9853
|
+
lastUncachedInterpolationTemplate = void 0;
|
|
9854
|
+
interpolationTemplateCache.set(template, {
|
|
9855
|
+
templateChars: template.length,
|
|
9856
|
+
storageChars,
|
|
9857
|
+
parsed
|
|
9858
|
+
});
|
|
9859
|
+
cachedInterpolationTemplateChars += template.length;
|
|
9860
|
+
cachedInterpolationTemplateStorageChars += storageChars;
|
|
9861
|
+
}
|
|
9862
|
+
function parseInterpolationTemplate(template) {
|
|
9863
|
+
const cached = interpolationTemplateCache.get(template);
|
|
9864
|
+
if (cached) {
|
|
9865
|
+
return cached.parsed;
|
|
9866
|
+
}
|
|
9867
|
+
const parsed = parseInterpolationTemplateUncached(template);
|
|
9868
|
+
if (template.includes("{{")) {
|
|
9869
|
+
cacheInterpolationTemplate(template, parsed);
|
|
9870
|
+
}
|
|
9871
|
+
return parsed;
|
|
9872
|
+
}
|
|
9873
|
+
function protectEscapedInterpolationTokens(template) {
|
|
9874
|
+
return template.replace(ESCAPED_TOKEN_REGEX, (_match, expression) => `\\{\\{${expression}\\}\\}`);
|
|
9875
|
+
}
|
|
9876
|
+
function restoreEscapedInterpolationTokens(template) {
|
|
9877
|
+
return template.replace(ESCAPED_ESCAPED_TOKEN_REGEX, (_match, expression) => `{{${expression}}}`).replace(ESCAPED_TOKEN_REGEX, (_match, expression) => `{{${expression}}}`);
|
|
9878
|
+
}
|
|
9879
|
+
function findInterpolationTokenSpans(template) {
|
|
9880
|
+
return parseInterpolationTemplate(template).tokens.map((token) => ({ ...token.span }));
|
|
9881
|
+
}
|
|
9882
|
+
function getInterpolationTokenName(rawInner) {
|
|
9883
|
+
return parseInterpolationToken(rawInner).tokenName;
|
|
9884
|
+
}
|
|
9885
|
+
function getInterpolationTokenReference(rawInner) {
|
|
9886
|
+
return parseInterpolationToken(rawInner).reference;
|
|
9887
|
+
}
|
|
9888
|
+
function replaceInterpolationTokens(template, getReplacement, options2 = {}) {
|
|
9889
|
+
const parsedTemplate = parseInterpolationTemplate(template);
|
|
9890
|
+
if (parsedTemplate.tokens.length === 0) {
|
|
9891
|
+
const restoredTemplate = restoreEscapedInterpolationTokens(template);
|
|
9892
|
+
return options2.trim ? restoredTemplate.trim() : restoredTemplate;
|
|
9893
|
+
}
|
|
9894
|
+
let result = "";
|
|
9895
|
+
let cursor = 0;
|
|
9896
|
+
for (const token of parsedTemplate.tokens) {
|
|
9897
|
+
result += restoreEscapedInterpolationTokens(template.slice(cursor, token.span.start));
|
|
9898
|
+
result += getReplacement({
|
|
9899
|
+
rawInner: token.rawInner,
|
|
9900
|
+
span: { ...token.span },
|
|
9901
|
+
tokenName: token.tokenName,
|
|
9902
|
+
processingChain: token.processingChain,
|
|
9903
|
+
reference: token.reference ? { ...token.reference } : void 0
|
|
9904
|
+
});
|
|
9905
|
+
cursor = token.span.end;
|
|
9906
|
+
}
|
|
9907
|
+
result += restoreEscapedInterpolationTokens(template.slice(cursor));
|
|
9908
|
+
return options2.trim ? result.trim() : result;
|
|
9909
|
+
}
|
|
9910
|
+
function extractInterpolationVariableReferences(template) {
|
|
9911
|
+
if (!template.includes("{{")) {
|
|
9912
|
+
return [];
|
|
9913
|
+
}
|
|
9914
|
+
const discovered = /* @__PURE__ */ new Map();
|
|
9915
|
+
for (const token of parseInterpolationTemplate(template).tokens) {
|
|
9916
|
+
const reference = token.reference;
|
|
9917
|
+
if (!reference || reference.source !== "variable") {
|
|
9918
|
+
continue;
|
|
9919
|
+
}
|
|
9920
|
+
const existing = discovered.get(reference.baseName);
|
|
9921
|
+
if (existing) {
|
|
9922
|
+
existing.hasPath ||= reference.jsonPath !== void 0;
|
|
9923
|
+
continue;
|
|
9924
|
+
}
|
|
9925
|
+
discovered.set(reference.baseName, {
|
|
9926
|
+
baseName: reference.baseName,
|
|
9927
|
+
hasPath: reference.jsonPath !== void 0
|
|
9928
|
+
});
|
|
9929
|
+
}
|
|
9930
|
+
return Array.from(discovered.values(), (reference) => ({ ...reference }));
|
|
9931
|
+
}
|
|
9932
|
+
function extractInterpolationVariables(template) {
|
|
9933
|
+
return extractInterpolationVariableReferences(template).map((reference) => reference.baseName);
|
|
9934
|
+
}
|
|
9935
|
+
function getInterpolationSource(reference, sources) {
|
|
9936
|
+
switch (reference.source) {
|
|
9937
|
+
case "variable":
|
|
9938
|
+
return sources.variables;
|
|
9939
|
+
case "graphInputs":
|
|
9940
|
+
return sources.graphInputValues;
|
|
9941
|
+
case "context":
|
|
9942
|
+
return sources.contextValues;
|
|
9943
|
+
}
|
|
9944
|
+
}
|
|
9945
|
+
function resolveInterpolationExpressionRawValue(expression, sources) {
|
|
9946
|
+
const reference = typeof expression === "string" ? getCachedInterpolationExpression(expression) : expression;
|
|
9947
|
+
if (!reference) {
|
|
9948
|
+
return void 0;
|
|
9949
|
+
}
|
|
9950
|
+
const source = getInterpolationSource(reference, sources);
|
|
9951
|
+
if (!source || !Object.prototype.hasOwnProperty.call(source, reference.baseName)) {
|
|
9952
|
+
return void 0;
|
|
9953
|
+
}
|
|
9954
|
+
const shouldUnwrapDataValue = reference.source !== "variable" || sources.unwrapVariableDataValues !== false;
|
|
9955
|
+
const baseValue = shouldUnwrapDataValue ? unwrapPotentialDataValue(source[reference.baseName]) : source[reference.baseName];
|
|
9956
|
+
if (reference.jsonPath === void 0) {
|
|
9957
|
+
return baseValue;
|
|
9958
|
+
}
|
|
9959
|
+
try {
|
|
9960
|
+
return evaluateJsonPath(baseValue, reference.jsonPath, false);
|
|
9961
|
+
} catch {
|
|
9962
|
+
return void 0;
|
|
9963
|
+
}
|
|
9964
|
+
}
|
|
9965
|
+
function resolveInterpolationTokenRawValue(rawInner, sources) {
|
|
9966
|
+
const reference = parseInterpolationToken(rawInner).reference;
|
|
9967
|
+
return reference ? resolveInterpolationExpressionRawValue(reference, sources) : void 0;
|
|
9968
|
+
}
|
|
9969
|
+
function stringifyInterpolationValue(value) {
|
|
9970
|
+
if (typeof value === "object" && value !== null) {
|
|
9971
|
+
try {
|
|
9972
|
+
return JSON.stringify(value);
|
|
9973
|
+
} catch (error) {
|
|
9974
|
+
console.warn("Error stringifying an interpolation value:", error);
|
|
9975
|
+
return "[object Object]";
|
|
9976
|
+
}
|
|
9977
|
+
}
|
|
9978
|
+
return String(value);
|
|
9979
|
+
}
|
|
9980
|
+
function parseProcessing(instruction) {
|
|
9981
|
+
const parts = instruction.trim().split(/\s+/);
|
|
9982
|
+
return {
|
|
9983
|
+
func: parts[0],
|
|
9984
|
+
param: parts[1] ? Number.parseInt(parts[1], 10) : void 0
|
|
9985
|
+
};
|
|
9986
|
+
}
|
|
9987
|
+
function applyProcessing(value, processingChain) {
|
|
9988
|
+
const instructions = processingChain.split("|").map((instruction) => instruction.trim()).filter((instruction) => instruction !== "");
|
|
9989
|
+
return instructions.reduce((result, instruction) => {
|
|
9990
|
+
const { func, param } = parseProcessing(instruction);
|
|
9991
|
+
const processingFunc = processingFunctions[func];
|
|
9992
|
+
if (!processingFunc) {
|
|
9993
|
+
console.warn(`Unknown processing function: ${func}`);
|
|
9994
|
+
return result;
|
|
9995
|
+
}
|
|
9996
|
+
return processingFunc(result, param);
|
|
9997
|
+
}, value);
|
|
9998
|
+
}
|
|
9999
|
+
function interpolate(template, variables, graphInputValues, contextValues, options2 = {}) {
|
|
10000
|
+
return replaceInterpolationTokens(template, (token) => {
|
|
10001
|
+
if (!token.reference) {
|
|
10002
|
+
return "";
|
|
10003
|
+
}
|
|
10004
|
+
const resolvedValue = resolveInterpolationExpressionRawValue(token.reference, {
|
|
10005
|
+
variables,
|
|
10006
|
+
graphInputValues,
|
|
10007
|
+
contextValues,
|
|
10008
|
+
unwrapVariableDataValues: options2.unwrapVariableDataValues
|
|
10009
|
+
});
|
|
10010
|
+
if (resolvedValue === void 0) {
|
|
10011
|
+
console.warn(`Interpolation variable or path "${token.tokenName}" not found or resolved to undefined.`);
|
|
10012
|
+
return "";
|
|
10013
|
+
}
|
|
10014
|
+
const isBareOrdinaryVariable = token.reference.source === "variable" && token.reference.jsonPath === void 0;
|
|
10015
|
+
const stringValue = isBareOrdinaryVariable ? stringifyInterpolationSourceValue(variables[token.reference.baseName], {
|
|
10016
|
+
coerceDataValueToString: options2.coerceBareVariableDataValues,
|
|
10017
|
+
unwrapDataValue: options2.unwrapVariableDataValues !== false
|
|
10018
|
+
}) : stringifyInterpolationValue(resolvedValue);
|
|
10019
|
+
return token.processingChain ? applyProcessing(stringValue, token.processingChain) : stringValue;
|
|
10020
|
+
});
|
|
10021
|
+
}
|
|
10022
|
+
function resolveCodeInterpolationExpression(inputs, expression, graphInputValues, contextValues) {
|
|
10023
|
+
return resolveInterpolationExpressionRawValue(expression, {
|
|
10024
|
+
variables: inputs,
|
|
10025
|
+
graphInputValues,
|
|
10026
|
+
contextValues
|
|
10027
|
+
});
|
|
10028
|
+
}
|
|
10029
|
+
|
|
9183
10030
|
// src/integrations/CodeRunnerOptions.ts
|
|
9184
10031
|
var ALL_CODE_RUNNER_OPTIONS = Object.freeze({
|
|
9185
10032
|
includeRequire: true,
|
|
@@ -9214,6 +10061,10 @@ var IsomorphicCodeRunner = class {
|
|
|
9214
10061
|
argNames.push("context");
|
|
9215
10062
|
args.push(contextValues);
|
|
9216
10063
|
}
|
|
10064
|
+
if (options2.interpolationHelperIdentifier) {
|
|
10065
|
+
argNames.push(options2.interpolationHelperIdentifier);
|
|
10066
|
+
args.push(resolveCodeInterpolationExpression);
|
|
10067
|
+
}
|
|
9217
10068
|
argNames.push(code);
|
|
9218
10069
|
const AsyncFunction = async function() {
|
|
9219
10070
|
}.constructor;
|
|
@@ -9387,6 +10238,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9387
10238
|
// Per-process state
|
|
9388
10239
|
#erroredNodes = void 0;
|
|
9389
10240
|
// Values are strings in recordings
|
|
10241
|
+
#failureOutputsByProcessId = void 0;
|
|
9390
10242
|
#remainingNodes = void 0;
|
|
9391
10243
|
#visitedNodes = void 0;
|
|
9392
10244
|
#currentlyProcessing = void 0;
|
|
@@ -9415,6 +10267,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9415
10267
|
#graphExecutionPlan;
|
|
9416
10268
|
#nodeProcessContextBase = void 0;
|
|
9417
10269
|
#runToRelevantNodeIds;
|
|
10270
|
+
#graphOutputSelection;
|
|
9418
10271
|
#managedAsyncBranches;
|
|
9419
10272
|
#managedAsyncBranchFailures = [];
|
|
9420
10273
|
#runCompletionPromise;
|
|
@@ -9636,7 +10489,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9636
10489
|
const pending = this.#pendingUserInputs[nodeId];
|
|
9637
10490
|
if (pending) {
|
|
9638
10491
|
pending.resolve(values2);
|
|
9639
|
-
delete this.#pendingUserInputs[nodeId];
|
|
9640
10492
|
}
|
|
9641
10493
|
for (const processor of this.#subprocessors) {
|
|
9642
10494
|
processor.userInput(nodeId, values2);
|
|
@@ -9737,7 +10589,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9737
10589
|
}
|
|
9738
10590
|
this.#preloadedNodeResults.set(nodeId, data);
|
|
9739
10591
|
this.#hasPreloadedData = true;
|
|
9740
|
-
if (this.#lifecycle.isRunning) {
|
|
10592
|
+
if (this.#lifecycle.isRunning && this.#isNodeSelected(nodeId)) {
|
|
9741
10593
|
this.#nodeResults.set(nodeId, data);
|
|
9742
10594
|
this.#visitedNodes.add(nodeId);
|
|
9743
10595
|
}
|
|
@@ -9787,9 +10639,12 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9787
10639
|
}
|
|
9788
10640
|
}
|
|
9789
10641
|
async replayRecording(recorder) {
|
|
10642
|
+
if (this.#lifecycle.isRunning) {
|
|
10643
|
+
throw new Error("Cannot process graph while already processing");
|
|
10644
|
+
}
|
|
9790
10645
|
this.#initializeExecutionIdentity();
|
|
9791
10646
|
this.#initProcessState();
|
|
9792
|
-
|
|
10647
|
+
return await replayExecutionRecording({
|
|
9793
10648
|
emitter: this.#emitter,
|
|
9794
10649
|
erroredNodes: this.#erroredNodes,
|
|
9795
10650
|
graphInputs: this.#graphInputs,
|
|
@@ -9816,7 +10671,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9816
10671
|
visitedNodes: this.#visitedNodes,
|
|
9817
10672
|
waitUntilUnpaused: () => this.#waitUntilUnpaused()
|
|
9818
10673
|
});
|
|
9819
|
-
return this.#graphOutputs;
|
|
9820
10674
|
}
|
|
9821
10675
|
#initProcessState() {
|
|
9822
10676
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -9825,6 +10679,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9825
10679
|
this.#visitedNodes = new Set(this.#preloadedNodeResults.keys());
|
|
9826
10680
|
this.#hasPreloadedData = this.#preloadedNodeResults.size > 0;
|
|
9827
10681
|
this.#erroredNodes = /* @__PURE__ */ new Map();
|
|
10682
|
+
this.#failureOutputsByProcessId = /* @__PURE__ */ new Map();
|
|
9828
10683
|
this.#currentlyProcessing = /* @__PURE__ */ new Set();
|
|
9829
10684
|
this.#remainingNodes = new Set(((_a = this.#seededExecutionPlanForNextRun()) == null ? void 0 : _a.nodeIds) ?? []);
|
|
9830
10685
|
this.#pendingUserInputs = {};
|
|
@@ -9847,6 +10702,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9847
10702
|
this.#ignoreNodes = /* @__PURE__ */ new Set();
|
|
9848
10703
|
this.#nodeProcessContextBase = void 0;
|
|
9849
10704
|
this.#runToRelevantNodeIds = void 0;
|
|
10705
|
+
this.#graphOutputSelection = void 0;
|
|
9850
10706
|
if (!this.#isSubProcessor) {
|
|
9851
10707
|
this.#managedAsyncBranches = new ManagedAsyncBranches();
|
|
9852
10708
|
this.#managedAsyncBranchFailures = [];
|
|
@@ -9865,9 +10721,11 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9865
10721
|
}
|
|
9866
10722
|
/** Main function for running a graph. Runs a graph and returns the outputs from the output nodes of the graph. */
|
|
9867
10723
|
async processGraph(context, inputs = {}, contextValues = {}, options2 = {}) {
|
|
10724
|
+
var _a;
|
|
9868
10725
|
if (this.#lifecycle.isRunning) {
|
|
9869
10726
|
throw new Error("Cannot process graph while already processing");
|
|
9870
10727
|
}
|
|
10728
|
+
const requestedGraphOutputIds = (_a = options2.requestedGraphOutputIds) == null ? void 0 : _a.slice();
|
|
9871
10729
|
let resolveOutputsReady;
|
|
9872
10730
|
let rejectOutputsReady;
|
|
9873
10731
|
const outputsReadyPromise = options2.returnWhenGraphOutputsReady === true ? new Promise((resolve, reject) => {
|
|
@@ -9876,7 +10734,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9876
10734
|
}) : void 0;
|
|
9877
10735
|
let outputsWerePublishedEarly = false;
|
|
9878
10736
|
const completionPromise = (async () => {
|
|
9879
|
-
var
|
|
10737
|
+
var _a2;
|
|
9880
10738
|
try {
|
|
9881
10739
|
try {
|
|
9882
10740
|
this.#profileRuntimeSync(
|
|
@@ -9891,6 +10749,22 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9891
10749
|
this.#preprocessGraph();
|
|
9892
10750
|
}
|
|
9893
10751
|
this.#assertNoDataBusRunTargets();
|
|
10752
|
+
if (requestedGraphOutputIds !== void 0) {
|
|
10753
|
+
if (this.runToNodeIds !== void 0) {
|
|
10754
|
+
throw new Error("requestedGraphOutputIds cannot be combined with runToNodeIds");
|
|
10755
|
+
}
|
|
10756
|
+
this.#graphOutputSelection = createGraphOutputSelection(
|
|
10757
|
+
{ nodes: this.#executionGraphNodes, connections: this.#getEffectiveConnections() },
|
|
10758
|
+
requestedGraphOutputIds,
|
|
10759
|
+
(node) => getInputNodesTo(this.#executionState, node)
|
|
10760
|
+
);
|
|
10761
|
+
for (const nodeId of this.#nodeResults.keys()) {
|
|
10762
|
+
if (!this.#isNodeSelected(nodeId)) {
|
|
10763
|
+
this.#nodeResults.delete(nodeId);
|
|
10764
|
+
this.#visitedNodes.delete(nodeId);
|
|
10765
|
+
}
|
|
10766
|
+
}
|
|
10767
|
+
}
|
|
9894
10768
|
this.#prepareAsyncBranchTopology();
|
|
9895
10769
|
} catch (error) {
|
|
9896
10770
|
const normalizedError = getError(error);
|
|
@@ -9923,7 +10797,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9923
10797
|
return await this.#profileRuntimeAsync("finalizeGraphRun", () => this.#finalizeGraphRun());
|
|
9924
10798
|
} finally {
|
|
9925
10799
|
if (!this.#isSubProcessor) {
|
|
9926
|
-
await ((
|
|
10800
|
+
await ((_a2 = this.#managedAsyncBranches) == null ? void 0 : _a2.drain());
|
|
9927
10801
|
}
|
|
9928
10802
|
this.#lifecycle.complete();
|
|
9929
10803
|
this.#cleanupTokenizerErrorListener();
|
|
@@ -10045,12 +10919,31 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10045
10919
|
this.#emitTraceEvent(message);
|
|
10046
10920
|
},
|
|
10047
10921
|
setStoredValue: (key, value) => this.#storedValueController.set(key, value),
|
|
10048
|
-
waitForGlobal: async (id) => {
|
|
10922
|
+
waitForGlobal: async (id, signal = this.#abortController.signal) => {
|
|
10923
|
+
if (signal.aborted) {
|
|
10924
|
+
throw createGraphAbortErrorFromSignal(signal);
|
|
10925
|
+
}
|
|
10049
10926
|
if (this.#globals.has(id)) {
|
|
10050
10927
|
return this.#globals.get(id);
|
|
10051
10928
|
}
|
|
10052
|
-
await
|
|
10053
|
-
|
|
10929
|
+
return await new Promise((resolve, reject) => {
|
|
10930
|
+
const abortListener = () => {
|
|
10931
|
+
cleanup();
|
|
10932
|
+
reject(createGraphAbortErrorFromSignal(signal));
|
|
10933
|
+
};
|
|
10934
|
+
const unsubscribe = this.getRootProcessor().#emitter.on(`globalSet:${id}`, () => {
|
|
10935
|
+
cleanup();
|
|
10936
|
+
resolve(this.#globals.get(id));
|
|
10937
|
+
});
|
|
10938
|
+
const cleanup = () => {
|
|
10939
|
+
unsubscribe();
|
|
10940
|
+
signal.removeEventListener("abort", abortListener);
|
|
10941
|
+
};
|
|
10942
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
10943
|
+
if (signal.aborted) {
|
|
10944
|
+
abortListener();
|
|
10945
|
+
}
|
|
10946
|
+
});
|
|
10054
10947
|
},
|
|
10055
10948
|
waitForStoredValue: (key, signal) => this.#storedValueController.waitForSet(key, signal)
|
|
10056
10949
|
};
|
|
@@ -10086,7 +10979,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10086
10979
|
return;
|
|
10087
10980
|
}
|
|
10088
10981
|
for (const node of this.#executionGraphNodes) {
|
|
10089
|
-
if (!this.#nodeResults.has(node.id)) {
|
|
10982
|
+
if (!this.#isNodeSelected(node.id) || !this.#nodeResults.has(node.id)) {
|
|
10090
10983
|
continue;
|
|
10091
10984
|
}
|
|
10092
10985
|
if (this.#suppressedPreloadedNodeIds.has(node.id)) {
|
|
@@ -10121,7 +11014,10 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10121
11014
|
}
|
|
10122
11015
|
}
|
|
10123
11016
|
async #processCompatibleGraph() {
|
|
10124
|
-
|
|
11017
|
+
var _a;
|
|
11018
|
+
await this.#queueStartNodes(
|
|
11019
|
+
((_a = this.#graphOutputSelection) == null ? void 0 : _a.startNodes) ?? getStartNodes(this.#executionState, this.#executionGraphNodes, this.runToNodeIds)
|
|
11020
|
+
);
|
|
10125
11021
|
await this.#processingQueue.onIdle();
|
|
10126
11022
|
this.#markUnqueuedNodesIgnored();
|
|
10127
11023
|
}
|
|
@@ -10129,7 +11025,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10129
11025
|
if (this.#scheduler !== "fast-acyclic") {
|
|
10130
11026
|
return false;
|
|
10131
11027
|
}
|
|
10132
|
-
if (this.#hasPreloadedData || this.runToNodeIds || this.slowMode || this.#includeTrace) {
|
|
11028
|
+
if (this.#graphOutputSelection || this.#hasPreloadedData || this.runToNodeIds || this.slowMode || this.#includeTrace) {
|
|
10133
11029
|
return false;
|
|
10134
11030
|
}
|
|
10135
11031
|
if (this.#nodesNotInCycle.length !== this.#executionGraphNodes.length) {
|
|
@@ -10278,7 +11174,6 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10278
11174
|
}
|
|
10279
11175
|
async #finalizeGraphRun() {
|
|
10280
11176
|
const outputValues = this.#graphOutputs;
|
|
10281
|
-
this.#lifecycle.complete();
|
|
10282
11177
|
if (this.#suppressGraphLifecycleEvents) {
|
|
10283
11178
|
return outputValues;
|
|
10284
11179
|
}
|
|
@@ -10286,7 +11181,6 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10286
11181
|
await this.#emitter.emit("graphFinish", this.#withExecution({ graph: this.#graph, outputs: outputValues }));
|
|
10287
11182
|
if (!this.#isSubProcessor) {
|
|
10288
11183
|
await this.#emitter.emit("done", { results: outputValues });
|
|
10289
|
-
await this.#emitFinishIfNeeded();
|
|
10290
11184
|
}
|
|
10291
11185
|
return outputValues;
|
|
10292
11186
|
}
|
|
@@ -10344,6 +11238,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10344
11238
|
}
|
|
10345
11239
|
async #fetchNodeDataAndProcessNode(node) {
|
|
10346
11240
|
var _a;
|
|
11241
|
+
if (!this.#isNodeSelected(node.id)) return;
|
|
10347
11242
|
const profileStart = this.#startRuntimeProfile();
|
|
10348
11243
|
try {
|
|
10349
11244
|
if (this.#currentlyProcessing.has(node.id)) {
|
|
@@ -10396,6 +11291,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10396
11291
|
}
|
|
10397
11292
|
/** If all inputs are present, all conditions met, processes the node. */
|
|
10398
11293
|
async #processNodeIfAllInputsAvailable(node, options2 = {}) {
|
|
11294
|
+
if (!this.#isNodeSelected(node.id)) return [];
|
|
10399
11295
|
const { queueOutputNodes = true } = options2;
|
|
10400
11296
|
const builtInNode = node;
|
|
10401
11297
|
const inputNodesProfileStart = this.#startRuntimeProfile();
|
|
@@ -10639,8 +11535,9 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10639
11535
|
}
|
|
10640
11536
|
}
|
|
10641
11537
|
#queueOutputNodes(node, outputNodes) {
|
|
11538
|
+
const selectedOutputs = this.#graphOutputSelection ? outputNodes.filter((outputNode) => this.#isNodeSelected(outputNode.id)) : outputNodes;
|
|
10642
11539
|
void this.#processingQueue.addAll(
|
|
10643
|
-
|
|
11540
|
+
selectedOutputs.map((outputNode) => async () => {
|
|
10644
11541
|
this.#emitTraceEvent(`Trying to run output node from ${node.title}: ${outputNode.title} (${outputNode.id})`);
|
|
10645
11542
|
await this.#processNodeIfAllInputsAvailable(outputNode);
|
|
10646
11543
|
})
|
|
@@ -10845,7 +11742,8 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10845
11742
|
accumulateCost: (output) => this.#accumulateCost(output),
|
|
10846
11743
|
setNodeResults: (nodeId, outputs) => this.#nodeResults.set(nodeId, outputs),
|
|
10847
11744
|
markNodeVisited: (nodeId) => this.#visitedNodes.add(nodeId),
|
|
10848
|
-
nodeErrored: (n, err, pid, durationMs, splitRunDurationMs, resultOrigin) => this.#nodeErrored(n, err, pid, durationMs, splitRunDurationMs, resultOrigin),
|
|
11745
|
+
nodeErrored: (n, err, pid, durationMs, splitRunDurationMs, resultOrigin, splitOutputs) => this.#nodeErrored(n, err, pid, durationMs, splitRunDurationMs, resultOrigin, void 0, splitOutputs),
|
|
11746
|
+
takeFailureOutputs: (pid, index) => this.#takeFailureOutputs(pid, index),
|
|
10849
11747
|
isAborted: () => this.#lifecycle.isAborted,
|
|
10850
11748
|
getAbortError: () => createGraphAbortErrorFromSignal(this.#abortController.signal),
|
|
10851
11749
|
emit: (event, data) => {
|
|
@@ -10958,11 +11856,20 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10958
11856
|
)
|
|
10959
11857
|
);
|
|
10960
11858
|
} catch (error) {
|
|
10961
|
-
await this.#nodeErrored(
|
|
11859
|
+
await this.#nodeErrored(
|
|
11860
|
+
node,
|
|
11861
|
+
error,
|
|
11862
|
+
processId,
|
|
11863
|
+
this.#finishNodeTiming(timingStart),
|
|
11864
|
+
void 0,
|
|
11865
|
+
resultOrigin,
|
|
11866
|
+
this.#takeFailureOutputs(processId, 0)
|
|
11867
|
+
);
|
|
10962
11868
|
}
|
|
10963
11869
|
}
|
|
10964
|
-
async #nodeErrored(node, e, processId, durationMs, splitRunDurationMs, resultOrigin = "executed") {
|
|
11870
|
+
async #nodeErrored(node, e, processId, durationMs, splitRunDurationMs, resultOrigin = "executed", outputs, splitOutputs) {
|
|
10965
11871
|
const error = getError(e);
|
|
11872
|
+
const retainedOutputs = splitOutputs === void 0 ? outputs ?? this.#takeFailureOutputs(processId, 0) : outputs;
|
|
10966
11873
|
const exclusionReason = this.#getErrorExclusionReason(node, error, processId);
|
|
10967
11874
|
if (exclusionReason) {
|
|
10968
11875
|
await this.#emitNodeExcluded(node, processId, this.#getInputValuesForNode(node), exclusionReason, resultOrigin);
|
|
@@ -10973,7 +11880,18 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10973
11880
|
await this.#emitter.emit(
|
|
10974
11881
|
"nodeError",
|
|
10975
11882
|
this.#withExecution(
|
|
10976
|
-
withOptionalDuration3(
|
|
11883
|
+
withOptionalDuration3(
|
|
11884
|
+
{
|
|
11885
|
+
node,
|
|
11886
|
+
error,
|
|
11887
|
+
processId,
|
|
11888
|
+
resultOrigin,
|
|
11889
|
+
...retainedOutputs === void 0 ? {} : { outputs: retainedOutputs },
|
|
11890
|
+
...splitOutputs === void 0 ? {} : { splitOutputs }
|
|
11891
|
+
},
|
|
11892
|
+
durationMs,
|
|
11893
|
+
splitRunDurationMs
|
|
11894
|
+
)
|
|
10977
11895
|
)
|
|
10978
11896
|
);
|
|
10979
11897
|
this.#emitTraceEvent(`Node ${node.title} (${node.id}-${processId}) errored: ${error.stack}`);
|
|
@@ -10985,6 +11903,26 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10985
11903
|
this.#withExecution({ node, outputs, index, processId, resultOrigin: "executed" })
|
|
10986
11904
|
);
|
|
10987
11905
|
}
|
|
11906
|
+
#setFailureOutputs(processId, index, outputs) {
|
|
11907
|
+
let outputsByIndex = this.#failureOutputsByProcessId.get(processId);
|
|
11908
|
+
if (!outputsByIndex) {
|
|
11909
|
+
outputsByIndex = /* @__PURE__ */ new Map();
|
|
11910
|
+
this.#failureOutputsByProcessId.set(processId, outputsByIndex);
|
|
11911
|
+
}
|
|
11912
|
+
outputsByIndex.set(index, outputs);
|
|
11913
|
+
}
|
|
11914
|
+
#takeFailureOutputs(processId, index) {
|
|
11915
|
+
const outputsByIndex = this.#failureOutputsByProcessId.get(processId);
|
|
11916
|
+
const outputs = outputsByIndex == null ? void 0 : outputsByIndex.get(index);
|
|
11917
|
+
outputsByIndex == null ? void 0 : outputsByIndex.delete(index);
|
|
11918
|
+
if ((outputsByIndex == null ? void 0 : outputsByIndex.size) === 0) {
|
|
11919
|
+
this.#failureOutputsByProcessId.delete(processId);
|
|
11920
|
+
}
|
|
11921
|
+
return outputs;
|
|
11922
|
+
}
|
|
11923
|
+
#discardFailureOutputs(processId, index) {
|
|
11924
|
+
this.#takeFailureOutputs(processId, index);
|
|
11925
|
+
}
|
|
10988
11926
|
#getErrorExclusionReason(node, error, processId) {
|
|
10989
11927
|
var _a;
|
|
10990
11928
|
if ((_a = this.#getAttachedDataTo(node).races) == null ? void 0 : _a.completed) {
|
|
@@ -11085,6 +12023,9 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11085
12023
|
}
|
|
11086
12024
|
}
|
|
11087
12025
|
async #processNodeWithInputData(node, inputValues, index, processId, partialOutput, markResultAsEditorCacheHit) {
|
|
12026
|
+
if (this.#shouldSkipCompletedRaceNode(node, this.#getAttachedDataTo(node))) {
|
|
12027
|
+
throw createGraphAbortError(createGraphAbortReason(true, RACE_LOSER_EXCLUSION_REASON));
|
|
12028
|
+
}
|
|
11088
12029
|
const instance = this.#nodeInstances[node.id];
|
|
11089
12030
|
const nodeAbortController = this.#newAbortController();
|
|
11090
12031
|
this.#registerNodeAbortController(node.id, nodeAbortController);
|
|
@@ -11110,6 +12051,9 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11110
12051
|
this.#finishRuntimeProfile("createNodeProcessContext", createContextProfileStart);
|
|
11111
12052
|
}
|
|
11112
12053
|
await this.#waitUntilUnpaused();
|
|
12054
|
+
if (nodeAbortController.signal.aborted) {
|
|
12055
|
+
throw createGraphAbortErrorFromSignal(nodeAbortController.signal);
|
|
12056
|
+
}
|
|
11113
12057
|
const implementationProfileStart = this.#startRuntimeProfile();
|
|
11114
12058
|
let results;
|
|
11115
12059
|
try {
|
|
@@ -11121,6 +12065,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11121
12065
|
if (nodeAbortController.signal.aborted) {
|
|
11122
12066
|
if (isSuccessfulNonRaceGraphAbortReason(abortReason)) {
|
|
11123
12067
|
this.#successfulAbortTerminalProcessIds.add(processId);
|
|
12068
|
+
this.#discardFailureOutputs(processId, index);
|
|
11124
12069
|
return results;
|
|
11125
12070
|
} else {
|
|
11126
12071
|
throw createGraphAbortError(abortReason, "Aborted");
|
|
@@ -11128,6 +12073,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11128
12073
|
}
|
|
11129
12074
|
this.#finalizeToolCallContinuation(processId, index, results);
|
|
11130
12075
|
continuationFinalized = true;
|
|
12076
|
+
this.#discardFailureOutputs(processId, index);
|
|
11131
12077
|
return results;
|
|
11132
12078
|
} finally {
|
|
11133
12079
|
if (!continuationFinalized) {
|
|
@@ -11164,8 +12110,9 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11164
12110
|
partialOutput == null ? void 0 : partialOutput(node, partialOutputs, index);
|
|
11165
12111
|
this.#emitGraphPartialOutputIfNeeded(node, partialOutputs);
|
|
11166
12112
|
},
|
|
12113
|
+
setFailureOutputs: (outputs) => this.#setFailureOutputs(processId, index, outputs),
|
|
11167
12114
|
processId,
|
|
11168
|
-
requestUserInput: async (inputStrings, renderingType) => this.#requestUserInput(node, inputStrings, inputValues, renderingType, processId),
|
|
12115
|
+
requestUserInput: async (inputStrings, renderingType) => this.#requestUserInput(node, inputStrings, inputValues, renderingType, processId, nodeAbortController.signal),
|
|
11169
12116
|
reportProgress: (progress) => {
|
|
11170
12117
|
const normalized = normalizeGraphProgress(progress);
|
|
11171
12118
|
if (normalized) {
|
|
@@ -11180,14 +12127,27 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11180
12127
|
toolCallContinuation,
|
|
11181
12128
|
toolCallTraceSource,
|
|
11182
12129
|
waitEvent: async (event) => {
|
|
12130
|
+
const signal = nodeAbortController.signal;
|
|
12131
|
+
if (signal.aborted) {
|
|
12132
|
+
throw createGraphAbortErrorFromSignal(signal, "Process aborted");
|
|
12133
|
+
}
|
|
11183
12134
|
return new Promise((resolve, reject) => {
|
|
11184
12135
|
const abortListener = () => {
|
|
11185
|
-
|
|
12136
|
+
cleanup();
|
|
12137
|
+
reject(createGraphAbortErrorFromSignal(signal, "Process aborted"));
|
|
11186
12138
|
};
|
|
11187
|
-
this.#emitter.
|
|
11188
|
-
|
|
12139
|
+
const unsubscribe = this.#emitter.on(`userEvent:${event}`, (data) => {
|
|
12140
|
+
cleanup();
|
|
12141
|
+
resolve(data);
|
|
11189
12142
|
});
|
|
11190
|
-
|
|
12143
|
+
const cleanup = () => {
|
|
12144
|
+
unsubscribe();
|
|
12145
|
+
signal.removeEventListener("abort", abortListener);
|
|
12146
|
+
};
|
|
12147
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
12148
|
+
if (signal.aborted) {
|
|
12149
|
+
abortListener();
|
|
12150
|
+
}
|
|
11191
12151
|
});
|
|
11192
12152
|
}
|
|
11193
12153
|
});
|
|
@@ -11492,7 +12452,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11492
12452
|
state: {
|
|
11493
12453
|
erroredNodeIds: new Set(this.#erroredNodes.keys()),
|
|
11494
12454
|
nodeOutputs: this.#nodeResults,
|
|
11495
|
-
runToRelevantNodeIds: this.#
|
|
12455
|
+
runToRelevantNodeIds: this.#getExecutionRelevantNodeIds(),
|
|
11496
12456
|
visitedNodeIds: this.#visitedNodes
|
|
11497
12457
|
}
|
|
11498
12458
|
});
|
|
@@ -11554,8 +12514,8 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11554
12514
|
);
|
|
11555
12515
|
const outgoingByNodeId = /* @__PURE__ */ new Map();
|
|
11556
12516
|
const incomingByNodeId = /* @__PURE__ */ new Map();
|
|
11557
|
-
const
|
|
11558
|
-
const
|
|
12517
|
+
const relevantNodeIds = this.#getExecutionRelevantNodeIds();
|
|
12518
|
+
const isRelevant = (nodeId) => !relevantNodeIds || relevantNodeIds.has(nodeId);
|
|
11559
12519
|
for (const connection of connections) {
|
|
11560
12520
|
const outgoing = outgoingByNodeId.get(connection.outputNodeId) ?? [];
|
|
11561
12521
|
outgoing.push(connection);
|
|
@@ -11565,7 +12525,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11565
12525
|
incomingByNodeId.set(connection.inputNodeId, incoming);
|
|
11566
12526
|
}
|
|
11567
12527
|
for (const triggerNode of Object.values(this.#nodesById)) {
|
|
11568
|
-
if (triggerNode.type !== "startBackgroundBranch" || triggerNode.disabled || !
|
|
12528
|
+
if (triggerNode.type !== "startBackgroundBranch" || triggerNode.disabled || !isRelevant(triggerNode.id)) {
|
|
11569
12529
|
continue;
|
|
11570
12530
|
}
|
|
11571
12531
|
if (triggerNode.id !== this.#consumedAsyncBranchTriggerNodeId && this.#nodeResults.has(triggerNode.id)) {
|
|
@@ -11574,7 +12534,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11574
12534
|
);
|
|
11575
12535
|
}
|
|
11576
12536
|
const nodeIds = /* @__PURE__ */ new Set();
|
|
11577
|
-
const pendingNodeIds = (outgoingByNodeId.get(triggerNode.id) ?? []).map((connection) => connection.inputNodeId).filter(
|
|
12537
|
+
const pendingNodeIds = (outgoingByNodeId.get(triggerNode.id) ?? []).map((connection) => connection.inputNodeId).filter(isRelevant);
|
|
11578
12538
|
while (pendingNodeIds.length > 0) {
|
|
11579
12539
|
const nodeId = pendingNodeIds.pop();
|
|
11580
12540
|
if (nodeId === triggerNode.id) {
|
|
@@ -11599,7 +12559,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11599
12559
|
}
|
|
11600
12560
|
nodeIds.add(nodeId);
|
|
11601
12561
|
for (const connection of outgoingByNodeId.get(nodeId) ?? []) {
|
|
11602
|
-
if (
|
|
12562
|
+
if (isRelevant(connection.inputNodeId)) {
|
|
11603
12563
|
pendingNodeIds.push(connection.inputNodeId);
|
|
11604
12564
|
}
|
|
11605
12565
|
}
|
|
@@ -11700,17 +12660,19 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11700
12660
|
if (outputConnections.length === 0) {
|
|
11701
12661
|
return /* @__PURE__ */ new Set();
|
|
11702
12662
|
}
|
|
11703
|
-
const
|
|
12663
|
+
const relevantNodeIds = this.#getExecutionRelevantNodeIds();
|
|
11704
12664
|
const activeOutputPortIds = /* @__PURE__ */ new Set();
|
|
11705
12665
|
for (const { node: outputNode, connections } of outputConnections) {
|
|
11706
12666
|
if (outputNode.disabled) {
|
|
11707
12667
|
continue;
|
|
11708
12668
|
}
|
|
11709
|
-
if (
|
|
12669
|
+
if (relevantNodeIds && !relevantNodeIds.has(outputNode.id)) {
|
|
11710
12670
|
continue;
|
|
11711
12671
|
}
|
|
11712
12672
|
for (const connection of connections) {
|
|
11713
|
-
|
|
12673
|
+
if (this.#isDefinitionValidConnection(connection)) {
|
|
12674
|
+
activeOutputPortIds.add(connection.outputId);
|
|
12675
|
+
}
|
|
11714
12676
|
}
|
|
11715
12677
|
}
|
|
11716
12678
|
return activeOutputPortIds;
|
|
@@ -11728,6 +12690,16 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11728
12690
|
}
|
|
11729
12691
|
}
|
|
11730
12692
|
}
|
|
12693
|
+
#isNodeSelected(nodeId) {
|
|
12694
|
+
return !this.#graphOutputSelection || this.#graphOutputSelection.nodeIds.has(nodeId);
|
|
12695
|
+
}
|
|
12696
|
+
#getExecutionRelevantNodeIds() {
|
|
12697
|
+
var _a;
|
|
12698
|
+
if (this.#sameGraphRunOwnerOverride) {
|
|
12699
|
+
return this.#sameGraphRunOwnerOverride.#getExecutionRelevantNodeIds();
|
|
12700
|
+
}
|
|
12701
|
+
return ((_a = this.#graphOutputSelection) == null ? void 0 : _a.nodeIds) ?? this.#getRunToRelevantNodeIds();
|
|
12702
|
+
}
|
|
11731
12703
|
#getRunToRelevantNodeIds() {
|
|
11732
12704
|
if (!this.runToNodeIds) {
|
|
11733
12705
|
return void 0;
|
|
@@ -11845,17 +12817,37 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11845
12817
|
}
|
|
11846
12818
|
return processor;
|
|
11847
12819
|
}
|
|
11848
|
-
async #requestUserInput(node, inputStrings, inputValues, renderingType, processId) {
|
|
12820
|
+
async #requestUserInput(node, inputStrings, inputValues, renderingType, processId, signal) {
|
|
12821
|
+
if (signal.aborted) {
|
|
12822
|
+
throw createGraphAbortErrorFromSignal(signal);
|
|
12823
|
+
}
|
|
11849
12824
|
return await new Promise((resolve, reject) => {
|
|
12825
|
+
let settled = false;
|
|
12826
|
+
const cleanup = () => {
|
|
12827
|
+
signal.removeEventListener("abort", abortListener);
|
|
12828
|
+
if (this.#pendingUserInputs[node.id] === pending) {
|
|
12829
|
+
delete this.#pendingUserInputs[node.id];
|
|
12830
|
+
}
|
|
12831
|
+
};
|
|
11850
12832
|
const abortListener = () => {
|
|
11851
|
-
|
|
11852
|
-
|
|
12833
|
+
if (settled) return;
|
|
12834
|
+
settled = true;
|
|
12835
|
+
cleanup();
|
|
12836
|
+
reject(createGraphAbortErrorFromSignal(signal));
|
|
11853
12837
|
};
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
12838
|
+
const respond = (results) => {
|
|
12839
|
+
if (settled) return;
|
|
12840
|
+
settled = true;
|
|
12841
|
+
cleanup();
|
|
12842
|
+
resolve(results);
|
|
11857
12843
|
};
|
|
11858
|
-
|
|
12844
|
+
const pending = { resolve: respond };
|
|
12845
|
+
this.#pendingUserInputs[node.id] = pending;
|
|
12846
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
12847
|
+
if (signal.aborted) {
|
|
12848
|
+
abortListener();
|
|
12849
|
+
return;
|
|
12850
|
+
}
|
|
11859
12851
|
emitDetached(
|
|
11860
12852
|
this.#emitter,
|
|
11861
12853
|
"userInput",
|
|
@@ -11864,11 +12856,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11864
12856
|
inputStrings,
|
|
11865
12857
|
inputs: inputValues,
|
|
11866
12858
|
renderingType,
|
|
11867
|
-
callback:
|
|
11868
|
-
this.#abortController.signal.removeEventListener("abort", abortListener);
|
|
11869
|
-
resolve(results);
|
|
11870
|
-
delete this.#pendingUserInputs[node.id];
|
|
11871
|
-
},
|
|
12859
|
+
callback: respond,
|
|
11872
12860
|
processId
|
|
11873
12861
|
})
|
|
11874
12862
|
);
|
|
@@ -13196,6 +14184,7 @@ function buildAgentResponseTrace(options2) {
|
|
|
13196
14184
|
).map(toToolCallTrace);
|
|
13197
14185
|
const summary = summarizeAgentCalls(allModelCalls, allProfileAttempts, allToolCalls);
|
|
13198
14186
|
const terminalAt = options2.responseReadyAt ?? options2.finishedAt;
|
|
14187
|
+
const durationMs = options2.scope === "llm-invocation" && isNonNegativeFiniteNumber(options2.invocationDurationMs) ? options2.invocationDurationMs : isNonNegativeFiniteNumber(options2.startedAt) && isNonNegativeFiniteNumber(terminalAt) && terminalAt >= options2.startedAt ? terminalAt - options2.startedAt : void 0;
|
|
13199
14188
|
return {
|
|
13200
14189
|
schemaVersion: AGENT_RESPONSE_TRACE_SCHEMA_VERSION,
|
|
13201
14190
|
traceId: options2.execution.rootRunId,
|
|
@@ -13208,7 +14197,7 @@ function buildAgentResponseTrace(options2) {
|
|
|
13208
14197
|
...options2.startedAt == null ? {} : { startedAt: options2.startedAt },
|
|
13209
14198
|
...options2.responseReadyAt == null ? {} : { responseReadyAt: options2.responseReadyAt },
|
|
13210
14199
|
...options2.finishedAt == null ? {} : { finishedAt: options2.finishedAt },
|
|
13211
|
-
...
|
|
14200
|
+
...durationMs === void 0 ? {} : { durationMs },
|
|
13212
14201
|
status: options2.status,
|
|
13213
14202
|
...options2.backgroundWorkPending == null ? {} : { backgroundWorkPending: options2.backgroundWorkPending },
|
|
13214
14203
|
summary,
|
|
@@ -14377,6 +15366,7 @@ var RIVET_WEB_APP_RENDERER_CSS = `
|
|
|
14377
15366
|
|
|
14378
15367
|
.rivet-web-app-chat-pins-button,
|
|
14379
15368
|
.rivet-web-app-chat-search-button,
|
|
15369
|
+
.rivet-web-app-chat-new-button,
|
|
14380
15370
|
.rivet-web-app-chat-menu-button,
|
|
14381
15371
|
.rivet-web-app-chat-search-close-button,
|
|
14382
15372
|
.rivet-web-app-chat-search-navigation-button {
|
|
@@ -14402,6 +15392,18 @@ var RIVET_WEB_APP_RENDERER_CSS = `
|
|
|
14402
15392
|
border-radius: 10px;
|
|
14403
15393
|
}
|
|
14404
15394
|
|
|
15395
|
+
.rivet-web-app-chat-new-button {
|
|
15396
|
+
min-height: 30px;
|
|
15397
|
+
padding: 0 9px;
|
|
15398
|
+
border: 1px solid var(--rivet-web-app-control-border);
|
|
15399
|
+
border-radius: 7px;
|
|
15400
|
+
background: var(--rivet-web-app-control-background);
|
|
15401
|
+
color: var(--rivet-web-app-foreground);
|
|
15402
|
+
font-size: 0.875em;
|
|
15403
|
+
line-height: 1;
|
|
15404
|
+
white-space: nowrap;
|
|
15405
|
+
}
|
|
15406
|
+
|
|
14405
15407
|
.rivet-web-app-chat-pins-button {
|
|
14406
15408
|
display: inline-flex;
|
|
14407
15409
|
align-items: center;
|
|
@@ -14447,6 +15449,13 @@ var RIVET_WEB_APP_RENDERER_CSS = `
|
|
|
14447
15449
|
outline: none;
|
|
14448
15450
|
}
|
|
14449
15451
|
|
|
15452
|
+
.rivet-web-app-chat-new-button:hover,
|
|
15453
|
+
.rivet-web-app-chat-new-button:focus-visible {
|
|
15454
|
+
background: var(--rivet-web-app-control-hover-background);
|
|
15455
|
+
color: var(--rivet-web-app-foreground);
|
|
15456
|
+
outline: none;
|
|
15457
|
+
}
|
|
15458
|
+
|
|
14450
15459
|
.rivet-web-app-chat-menu {
|
|
14451
15460
|
position: absolute;
|
|
14452
15461
|
top: calc(100% + 4px);
|
|
@@ -15999,284 +17008,6 @@ var userInputNode = nodeDefinition(UserInputNodeImpl, "User Input");
|
|
|
15999
17008
|
var import_non_secure8 = require("nanoid/non-secure");
|
|
16000
17009
|
var import_ts_dedent3 = require("ts-dedent");
|
|
16001
17010
|
|
|
16002
|
-
// src/utils/interpolation.ts
|
|
16003
|
-
var import_lodash_es6 = require("lodash");
|
|
16004
|
-
var ESCAPED_TOKEN_REGEX = /\{\{\{([^}]+?)\}\}\}/g;
|
|
16005
|
-
var ESCAPED_ESCAPED_TOKEN_REGEX = /\\\{\\\{([^}]+?)\\\}\\\}/g;
|
|
16006
|
-
var EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_ENTRIES = 2048;
|
|
16007
|
-
var EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_TEMPLATE_LENGTH = 64 * 1024;
|
|
16008
|
-
var EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_TEMPLATE_CHARS = 1024 * 1024;
|
|
16009
|
-
var extractedInterpolationVariablesCache = /* @__PURE__ */ new Map();
|
|
16010
|
-
var extractedInterpolationVariablesCacheTemplateChars = 0;
|
|
16011
|
-
var lastUncachedInterpolationVariableTemplate;
|
|
16012
|
-
var processingFunctions = {
|
|
16013
|
-
indent: (input, spaces = 0) => {
|
|
16014
|
-
const indent = " ".repeat(spaces);
|
|
16015
|
-
return input.split("\n").map((line) => `${indent}${line}`).join("\n");
|
|
16016
|
-
},
|
|
16017
|
-
quote: (input, level = 1) => {
|
|
16018
|
-
const quotePrefix = "> ".repeat(level);
|
|
16019
|
-
return input.split("\n").map((line) => `${quotePrefix}${line}`).join("\n");
|
|
16020
|
-
},
|
|
16021
|
-
uppercase: (input) => {
|
|
16022
|
-
return input.toUpperCase();
|
|
16023
|
-
},
|
|
16024
|
-
lowercase: (input) => {
|
|
16025
|
-
return input.toLowerCase();
|
|
16026
|
-
},
|
|
16027
|
-
trim: (input) => {
|
|
16028
|
-
return input.trim();
|
|
16029
|
-
},
|
|
16030
|
-
truncate: (input, length = 50) => {
|
|
16031
|
-
if (input.length <= length) return input;
|
|
16032
|
-
return input.slice(0, length) + "...";
|
|
16033
|
-
},
|
|
16034
|
-
list: (input, level = 1) => {
|
|
16035
|
-
const indent = " ".repeat(level - 1);
|
|
16036
|
-
return input.split("\n").map((line) => `${indent}- ${line}`).join("\n");
|
|
16037
|
-
},
|
|
16038
|
-
sort: (input) => {
|
|
16039
|
-
return input.split("\n").sort().join("\n");
|
|
16040
|
-
},
|
|
16041
|
-
dedent: (input) => {
|
|
16042
|
-
return (0, import_ts_dedent.dedent)(input);
|
|
16043
|
-
},
|
|
16044
|
-
wrap: (input, width = 80) => {
|
|
16045
|
-
const words = input.split(/\s+/);
|
|
16046
|
-
const lines = [];
|
|
16047
|
-
let currentLine = "";
|
|
16048
|
-
for (const word of words) {
|
|
16049
|
-
if (currentLine.length + word.length + 1 <= width) {
|
|
16050
|
-
currentLine += (currentLine ? " " : "") + word;
|
|
16051
|
-
} else {
|
|
16052
|
-
lines.push(currentLine);
|
|
16053
|
-
currentLine = word;
|
|
16054
|
-
}
|
|
16055
|
-
}
|
|
16056
|
-
if (currentLine) {
|
|
16057
|
-
lines.push(currentLine);
|
|
16058
|
-
}
|
|
16059
|
-
return lines.join("\n");
|
|
16060
|
-
}
|
|
16061
|
-
};
|
|
16062
|
-
function unwrapPotentialDataValue(value) {
|
|
16063
|
-
if (typeof value === "object" && value !== null && typeof value.type === "string" && Object.prototype.hasOwnProperty.call(value, "value")) {
|
|
16064
|
-
return value.value;
|
|
16065
|
-
}
|
|
16066
|
-
return value;
|
|
16067
|
-
}
|
|
16068
|
-
function resolveExpressionRawValue(source, expression, sourceType) {
|
|
16069
|
-
if (!source) {
|
|
16070
|
-
return void 0;
|
|
16071
|
-
}
|
|
16072
|
-
const match9 = expression.trim().match(/^([^[.\s]+)\s*(.*)$/);
|
|
16073
|
-
let key;
|
|
16074
|
-
let path;
|
|
16075
|
-
if (match9 && typeof match9[1] === "string") {
|
|
16076
|
-
key = match9[1];
|
|
16077
|
-
const rawPath = match9[2];
|
|
16078
|
-
if (rawPath) {
|
|
16079
|
-
path = rawPath.trim().replace(/\s*(\.|\[|\])\s*/g, "$1");
|
|
16080
|
-
} else {
|
|
16081
|
-
path = void 0;
|
|
16082
|
-
}
|
|
16083
|
-
} else {
|
|
16084
|
-
key = expression.trim();
|
|
16085
|
-
path = void 0;
|
|
16086
|
-
}
|
|
16087
|
-
if (!key) {
|
|
16088
|
-
return void 0;
|
|
16089
|
-
}
|
|
16090
|
-
const topLevelValue = source[key];
|
|
16091
|
-
if (topLevelValue === void 0) {
|
|
16092
|
-
return void 0;
|
|
16093
|
-
}
|
|
16094
|
-
const baseValue = unwrapPotentialDataValue(topLevelValue);
|
|
16095
|
-
let finalValue;
|
|
16096
|
-
if (path) {
|
|
16097
|
-
try {
|
|
16098
|
-
finalValue = (0, import_lodash_es6.get)(baseValue, path);
|
|
16099
|
-
finalValue = unwrapPotentialDataValue(finalValue);
|
|
16100
|
-
} catch (error) {
|
|
16101
|
-
console.warn(`Error accessing path "${path}" in ${sourceType} value for key "${key}":`, error);
|
|
16102
|
-
return void 0;
|
|
16103
|
-
}
|
|
16104
|
-
} else {
|
|
16105
|
-
finalValue = baseValue;
|
|
16106
|
-
}
|
|
16107
|
-
return finalValue;
|
|
16108
|
-
}
|
|
16109
|
-
function resolveExpressionToString(source, expression, sourceType) {
|
|
16110
|
-
const finalValue = resolveExpressionRawValue(source, expression, sourceType);
|
|
16111
|
-
if (finalValue === void 0) {
|
|
16112
|
-
return void 0;
|
|
16113
|
-
}
|
|
16114
|
-
if (typeof finalValue === "object" && finalValue !== null) {
|
|
16115
|
-
try {
|
|
16116
|
-
return JSON.stringify(finalValue);
|
|
16117
|
-
} catch (error) {
|
|
16118
|
-
console.warn(`Error stringifying object/array in ${sourceType} for expression "${expression}":`, error);
|
|
16119
|
-
return "[object Object]";
|
|
16120
|
-
}
|
|
16121
|
-
}
|
|
16122
|
-
return String(finalValue);
|
|
16123
|
-
}
|
|
16124
|
-
function parseProcessing(instruction) {
|
|
16125
|
-
const parts = instruction.trim().split(/\s+/);
|
|
16126
|
-
return {
|
|
16127
|
-
func: parts[0],
|
|
16128
|
-
param: parts[1] ? parseInt(parts[1], 10) : void 0
|
|
16129
|
-
};
|
|
16130
|
-
}
|
|
16131
|
-
function applyProcessing(value, processingChain) {
|
|
16132
|
-
const instructions = processingChain.split("|").map((instruction) => instruction.trim()).filter((instruction) => instruction !== "");
|
|
16133
|
-
return instructions.reduce((result, instruction) => {
|
|
16134
|
-
const { func, param } = parseProcessing(instruction);
|
|
16135
|
-
const processingFunc = processingFunctions[func];
|
|
16136
|
-
if (!processingFunc) {
|
|
16137
|
-
console.warn(`Unknown processing function: ${func}`);
|
|
16138
|
-
return result;
|
|
16139
|
-
}
|
|
16140
|
-
return processingFunc(result, param);
|
|
16141
|
-
}, value);
|
|
16142
|
-
}
|
|
16143
|
-
function protectEscapedInterpolationTokens(template) {
|
|
16144
|
-
return template.replace(ESCAPED_TOKEN_REGEX, (_match, expression) => `\\{\\{${expression}\\}\\}`);
|
|
16145
|
-
}
|
|
16146
|
-
function restoreEscapedInterpolationTokens(template) {
|
|
16147
|
-
return template.replace(ESCAPED_ESCAPED_TOKEN_REGEX, (_match, expression) => `{{${expression}}}`);
|
|
16148
|
-
}
|
|
16149
|
-
function findInterpolationTokenSpans(template) {
|
|
16150
|
-
const spans = [];
|
|
16151
|
-
let searchIndex = 0;
|
|
16152
|
-
while (searchIndex < template.length) {
|
|
16153
|
-
const openIndex = template.indexOf("{{", searchIndex);
|
|
16154
|
-
if (openIndex === -1) {
|
|
16155
|
-
break;
|
|
16156
|
-
}
|
|
16157
|
-
const closeIndex = template.indexOf("}}", openIndex + 2);
|
|
16158
|
-
if (closeIndex === -1) {
|
|
16159
|
-
break;
|
|
16160
|
-
}
|
|
16161
|
-
const nestedOpenIndex = template.indexOf("{{", openIndex + 2);
|
|
16162
|
-
if (nestedOpenIndex !== -1 && nestedOpenIndex < closeIndex) {
|
|
16163
|
-
searchIndex = nestedOpenIndex;
|
|
16164
|
-
continue;
|
|
16165
|
-
}
|
|
16166
|
-
spans.push({
|
|
16167
|
-
start: openIndex,
|
|
16168
|
-
end: closeIndex + 2,
|
|
16169
|
-
rawInner: template.slice(openIndex + 2, closeIndex)
|
|
16170
|
-
});
|
|
16171
|
-
searchIndex = closeIndex + 2;
|
|
16172
|
-
}
|
|
16173
|
-
return spans;
|
|
16174
|
-
}
|
|
16175
|
-
function getInterpolationTokenName(rawInner) {
|
|
16176
|
-
const [tokenPart] = rawInner.split("|");
|
|
16177
|
-
if (!tokenPart) {
|
|
16178
|
-
return void 0;
|
|
16179
|
-
}
|
|
16180
|
-
const token = tokenPart.trim();
|
|
16181
|
-
return token === "" ? void 0 : token;
|
|
16182
|
-
}
|
|
16183
|
-
function replaceInterpolationTokens(template, getReplacement, options2 = {}) {
|
|
16184
|
-
const protectedTemplate = protectEscapedInterpolationTokens(template);
|
|
16185
|
-
const tokenSpans = findInterpolationTokenSpans(protectedTemplate);
|
|
16186
|
-
if (tokenSpans.length === 0) {
|
|
16187
|
-
const restoredTemplate = restoreEscapedInterpolationTokens(protectedTemplate);
|
|
16188
|
-
return options2.trim ? restoredTemplate.trim() : restoredTemplate;
|
|
16189
|
-
}
|
|
16190
|
-
let result = "";
|
|
16191
|
-
let cursor = 0;
|
|
16192
|
-
for (const tokenSpan of tokenSpans) {
|
|
16193
|
-
result += protectedTemplate.slice(cursor, tokenSpan.start);
|
|
16194
|
-
result += getReplacement({
|
|
16195
|
-
rawInner: tokenSpan.rawInner,
|
|
16196
|
-
span: tokenSpan,
|
|
16197
|
-
tokenName: getInterpolationTokenName(tokenSpan.rawInner)
|
|
16198
|
-
});
|
|
16199
|
-
cursor = tokenSpan.end;
|
|
16200
|
-
}
|
|
16201
|
-
result += protectedTemplate.slice(cursor);
|
|
16202
|
-
const restoredResult = restoreEscapedInterpolationTokens(result);
|
|
16203
|
-
return options2.trim ? restoredResult.trim() : restoredResult;
|
|
16204
|
-
}
|
|
16205
|
-
function interpolate(template, variables, graphInputValues, contextValues) {
|
|
16206
|
-
return replaceInterpolationTokens(template, ({ rawInner }) => {
|
|
16207
|
-
const parts = rawInner.split("|").map((s) => s.trim());
|
|
16208
|
-
const expression = parts[0];
|
|
16209
|
-
const processingChain = parts.slice(1).join("|");
|
|
16210
|
-
let resolvedValue;
|
|
16211
|
-
if (expression.startsWith("@graphInputs.")) {
|
|
16212
|
-
resolvedValue = resolveExpressionToString(
|
|
16213
|
-
graphInputValues,
|
|
16214
|
-
expression.substring("@graphInputs.".length),
|
|
16215
|
-
"graphInputs"
|
|
16216
|
-
);
|
|
16217
|
-
} else if (expression.startsWith("@context.")) {
|
|
16218
|
-
resolvedValue = resolveExpressionToString(contextValues, expression.substring("@context.".length), "context");
|
|
16219
|
-
} else {
|
|
16220
|
-
const simpleVar = variables[expression];
|
|
16221
|
-
if (simpleVar !== void 0) {
|
|
16222
|
-
resolvedValue = String(unwrapPotentialDataValue(simpleVar) ?? "");
|
|
16223
|
-
} else {
|
|
16224
|
-
resolvedValue = void 0;
|
|
16225
|
-
}
|
|
16226
|
-
}
|
|
16227
|
-
if (resolvedValue === void 0) {
|
|
16228
|
-
console.warn(`Interpolation variable or path "${expression}" not found or resolved to undefined.`);
|
|
16229
|
-
return "";
|
|
16230
|
-
} else if (processingChain) {
|
|
16231
|
-
return applyProcessing(resolvedValue, processingChain);
|
|
16232
|
-
}
|
|
16233
|
-
return resolvedValue;
|
|
16234
|
-
});
|
|
16235
|
-
}
|
|
16236
|
-
function extractInterpolationVariables(template) {
|
|
16237
|
-
if (!template.includes("{{")) {
|
|
16238
|
-
return [];
|
|
16239
|
-
}
|
|
16240
|
-
const cachedVariables = getCachedInterpolationVariables(template);
|
|
16241
|
-
if (cachedVariables) {
|
|
16242
|
-
return [...cachedVariables];
|
|
16243
|
-
}
|
|
16244
|
-
const protectedTemplate = protectEscapedInterpolationTokens(template);
|
|
16245
|
-
const variables = /* @__PURE__ */ new Set();
|
|
16246
|
-
for (const match9 of findInterpolationTokenSpans(protectedTemplate)) {
|
|
16247
|
-
const token = getInterpolationTokenName(match9.rawInner);
|
|
16248
|
-
if (token && !token.startsWith("@graphInputs.") && !token.startsWith("@context.")) {
|
|
16249
|
-
variables.add(token);
|
|
16250
|
-
}
|
|
16251
|
-
}
|
|
16252
|
-
const extractedVariables = Array.from(variables);
|
|
16253
|
-
cacheInterpolationVariables(template, extractedVariables);
|
|
16254
|
-
return extractedVariables;
|
|
16255
|
-
}
|
|
16256
|
-
function getCachedInterpolationVariables(template) {
|
|
16257
|
-
var _a;
|
|
16258
|
-
return (_a = extractedInterpolationVariablesCache.get(template)) == null ? void 0 : _a.variables;
|
|
16259
|
-
}
|
|
16260
|
-
function cacheInterpolationVariables(template, variables) {
|
|
16261
|
-
if (template.length > EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_TEMPLATE_LENGTH) {
|
|
16262
|
-
return;
|
|
16263
|
-
}
|
|
16264
|
-
if (extractedInterpolationVariablesCache.size >= EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_ENTRIES || extractedInterpolationVariablesCacheTemplateChars + template.length > EXTRACT_INTERPOLATION_VARIABLES_CACHE_MAX_TEMPLATE_CHARS) {
|
|
16265
|
-
if (lastUncachedInterpolationVariableTemplate !== template) {
|
|
16266
|
-
lastUncachedInterpolationVariableTemplate = template;
|
|
16267
|
-
return;
|
|
16268
|
-
}
|
|
16269
|
-
extractedInterpolationVariablesCache.clear();
|
|
16270
|
-
extractedInterpolationVariablesCacheTemplateChars = 0;
|
|
16271
|
-
}
|
|
16272
|
-
lastUncachedInterpolationVariableTemplate = void 0;
|
|
16273
|
-
extractedInterpolationVariablesCache.set(template, {
|
|
16274
|
-
templateLength: template.length,
|
|
16275
|
-
variables: Object.freeze([...variables])
|
|
16276
|
-
});
|
|
16277
|
-
extractedInterpolationVariablesCacheTemplateChars += template.length;
|
|
16278
|
-
}
|
|
16279
|
-
|
|
16280
17011
|
// src/model/interpolationInputDefinition.ts
|
|
16281
17012
|
var INTERPOLATION_INPUT_DEFINITION_KIND = "interpolation-input";
|
|
16282
17013
|
function createInterpolationInputDefinition({
|
|
@@ -16320,16 +17051,16 @@ function isInterpolationInputDefinition(inputDefinition) {
|
|
|
16320
17051
|
return getInterpolationInputDefinitionData(inputDefinition) != null;
|
|
16321
17052
|
}
|
|
16322
17053
|
|
|
16323
|
-
// src/model/nodes/
|
|
17054
|
+
// src/model/nodes/nodeBodyPreview.ts
|
|
16324
17055
|
var MAX_BODY_PREVIEW_LINES = 15;
|
|
16325
17056
|
var MAX_BODY_PREVIEW_LINE_LENGTH = 240;
|
|
16326
17057
|
var MAX_BODY_PREVIEW_CHARS = 3e3;
|
|
16327
|
-
function
|
|
17058
|
+
function buildNodeBodyPreview(text, maximumLines = MAX_BODY_PREVIEW_LINES) {
|
|
16328
17059
|
const allLines = text.split("\n");
|
|
16329
|
-
const previewLines = allLines.slice(0,
|
|
17060
|
+
const previewLines = allLines.slice(0, maximumLines).map(
|
|
16330
17061
|
(line) => line.length > MAX_BODY_PREVIEW_LINE_LENGTH ? `${line.slice(0, MAX_BODY_PREVIEW_LINE_LENGTH)}...` : line
|
|
16331
17062
|
);
|
|
16332
|
-
const omittedLines = allLines.length >
|
|
17063
|
+
const omittedLines = allLines.length > maximumLines;
|
|
16333
17064
|
let previewText = previewLines.join("\n").trim();
|
|
16334
17065
|
if (previewText.length > MAX_BODY_PREVIEW_CHARS) {
|
|
16335
17066
|
previewText = previewText.slice(0, MAX_BODY_PREVIEW_CHARS).trimEnd();
|
|
@@ -16342,6 +17073,8 @@ function buildTextNodeBodyPreview(text) {
|
|
|
16342
17073
|
}
|
|
16343
17074
|
return previewText;
|
|
16344
17075
|
}
|
|
17076
|
+
|
|
17077
|
+
// src/model/nodes/TextNode.ts
|
|
16345
17078
|
var TextNodeImpl = class extends NodeImpl {
|
|
16346
17079
|
static create() {
|
|
16347
17080
|
const chartNode = {
|
|
@@ -16362,14 +17095,14 @@ var TextNodeImpl = class extends NodeImpl {
|
|
|
16362
17095
|
return chartNode;
|
|
16363
17096
|
}
|
|
16364
17097
|
getInputDefinitions() {
|
|
16365
|
-
const
|
|
16366
|
-
return
|
|
16367
|
-
(
|
|
16368
|
-
interpolationName:
|
|
16369
|
-
dataType: "string",
|
|
17098
|
+
const inputReferences = extractInterpolationVariableReferences(this.data.text);
|
|
17099
|
+
return inputReferences.map(
|
|
17100
|
+
({ baseName, hasPath }) => createInterpolationInputDefinition({
|
|
17101
|
+
interpolationName: baseName,
|
|
17102
|
+
dataType: hasPath ? "any" : "string",
|
|
16370
17103
|
required: false
|
|
16371
17104
|
})
|
|
16372
|
-
)
|
|
17105
|
+
);
|
|
16373
17106
|
}
|
|
16374
17107
|
getOutputDefinitions() {
|
|
16375
17108
|
return [
|
|
@@ -16408,25 +17141,18 @@ var TextNodeImpl = class extends NodeImpl {
|
|
|
16408
17141
|
type: "colorized",
|
|
16409
17142
|
language: "prompt-interpolation-markdown",
|
|
16410
17143
|
theme: "prompt-interpolation",
|
|
16411
|
-
text:
|
|
17144
|
+
text: buildNodeBodyPreview(this.data.text)
|
|
16412
17145
|
};
|
|
16413
17146
|
}
|
|
16414
17147
|
async process(inputs, context) {
|
|
16415
|
-
const inputMap = Object.keys(inputs).reduce(
|
|
16416
|
-
(acc, key) => {
|
|
16417
|
-
const stringValue = coerceTypeOptional(inputs[key], "string") ?? "";
|
|
16418
|
-
acc[key] = stringValue;
|
|
16419
|
-
return acc;
|
|
16420
|
-
},
|
|
16421
|
-
{}
|
|
16422
|
-
);
|
|
16423
17148
|
let outputValue = interpolate(
|
|
16424
17149
|
this.chartNode.data.text,
|
|
16425
|
-
|
|
17150
|
+
inputs,
|
|
16426
17151
|
context.graphInputNodeValues,
|
|
16427
17152
|
// Pass graph inputs
|
|
16428
|
-
context.contextValues
|
|
17153
|
+
context.contextValues,
|
|
16429
17154
|
// Pass context values
|
|
17155
|
+
{ coerceBareVariableDataValues: true }
|
|
16430
17156
|
);
|
|
16431
17157
|
if (this.chartNode.data.normalizeLineEndings) {
|
|
16432
17158
|
outputValue = outputValue.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
@@ -16469,7 +17195,7 @@ __export(openai_exports, {
|
|
|
16469
17195
|
openaiModels: () => openaiModels,
|
|
16470
17196
|
streamChatCompletions: () => streamChatCompletions
|
|
16471
17197
|
});
|
|
16472
|
-
var
|
|
17198
|
+
var import_lodash_es6 = require("lodash");
|
|
16473
17199
|
|
|
16474
17200
|
// src/utils/fetchEventSource.ts
|
|
16475
17201
|
var EventSourceResponse = class extends Response {
|
|
@@ -16775,7 +17501,7 @@ var openaiModels = {
|
|
|
16775
17501
|
displayName: "Local Model"
|
|
16776
17502
|
}
|
|
16777
17503
|
};
|
|
16778
|
-
var openAiModelOptions = (0,
|
|
17504
|
+
var openAiModelOptions = (0, import_lodash_es6.orderBy)(
|
|
16779
17505
|
Object.entries(openaiModels).map(([id, { displayName }]) => ({
|
|
16780
17506
|
value: id,
|
|
16781
17507
|
label: displayName
|
|
@@ -20439,11 +21165,12 @@ async function consumeAiSdkStream(fullStream, onPartialOutputs, options2 = {}) {
|
|
|
20439
21165
|
case "text-delta": {
|
|
20440
21166
|
textBlocks.set(part.id, `${textBlocks.get(part.id) ?? ""}${part.text}`);
|
|
20441
21167
|
responseText = buildResponseText(textBlocks, !!options2.dedupeDuplicateTextBlocks);
|
|
20442
|
-
onPartialOutputs(responseText, functionCalls);
|
|
21168
|
+
onPartialOutputs(responseText, functionCalls, reasoning);
|
|
20443
21169
|
break;
|
|
20444
21170
|
}
|
|
20445
21171
|
case "reasoning-delta": {
|
|
20446
21172
|
reasoning += part.text;
|
|
21173
|
+
onPartialOutputs(responseText, functionCalls, reasoning);
|
|
20447
21174
|
break;
|
|
20448
21175
|
}
|
|
20449
21176
|
case "tool-call": {
|
|
@@ -20454,7 +21181,7 @@ async function consumeAiSdkStream(fullStream, onPartialOutputs, options2 = {}) {
|
|
|
20454
21181
|
arguments: JSON.stringify(part.input),
|
|
20455
21182
|
lastParsedArguments: part.input
|
|
20456
21183
|
});
|
|
20457
|
-
onPartialOutputs(responseText, functionCalls);
|
|
21184
|
+
onPartialOutputs(responseText, functionCalls, reasoning);
|
|
20458
21185
|
break;
|
|
20459
21186
|
}
|
|
20460
21187
|
case "finish": {
|
|
@@ -20734,8 +21461,23 @@ async function resolveGenerateReasoning(result) {
|
|
|
20734
21461
|
}
|
|
20735
21462
|
return ((_a = await resolveOptionalValue(result.reasoning)) == null ? void 0 : _a.map((part) => part.text).join("")) ?? "";
|
|
20736
21463
|
}
|
|
21464
|
+
async function resolveGenerateUsage(result) {
|
|
21465
|
+
return await resolveOptionalValue(result.totalUsage) ?? await resolveOptionalValue(result.usage);
|
|
21466
|
+
}
|
|
21467
|
+
function notifyResponseReceived(options2, response) {
|
|
21468
|
+
var _a;
|
|
21469
|
+
try {
|
|
21470
|
+
(_a = options2.onResponseReceived) == null ? void 0 : _a.call(options2, response);
|
|
21471
|
+
} catch {
|
|
21472
|
+
}
|
|
21473
|
+
}
|
|
20737
21474
|
async function executeStream(options2, executor) {
|
|
21475
|
+
var _a;
|
|
20738
21476
|
const args = buildTextArgs(options2);
|
|
21477
|
+
try {
|
|
21478
|
+
(_a = options2.onRequestStarted) == null ? void 0 : _a.call(options2);
|
|
21479
|
+
} catch {
|
|
21480
|
+
}
|
|
20739
21481
|
const firstOutputStartedAt = Date.now();
|
|
20740
21482
|
const handlePromise = Promise.resolve(executor(args));
|
|
20741
21483
|
const handleTimeout = options2.firstOutputTimeoutMs == null ? void 0 : timeoutPromise(options2.firstOutputTimeoutMs, "first-output", options2.onTimeout);
|
|
@@ -20753,11 +21495,12 @@ async function executeStream(options2, executor) {
|
|
|
20753
21495
|
const isStructuredOutput = isChatV2StructuredResponseFormat(options2.responseFormat);
|
|
20754
21496
|
const streamed = await consumeAiSdkStream(
|
|
20755
21497
|
streamWithDeadlines(handle.fullStream, options2, firstOutputStartedAt),
|
|
20756
|
-
(text, functionCalls) => {
|
|
20757
|
-
var
|
|
20758
|
-
(
|
|
21498
|
+
(text, functionCalls, reasoning) => {
|
|
21499
|
+
var _a2;
|
|
21500
|
+
(_a2 = options2.onPartialOutput) == null ? void 0 : _a2.call(options2, {
|
|
20759
21501
|
text: isStructuredOutput ? collapseRepeatedStructuredJsonText(text) : text,
|
|
20760
|
-
functionCalls
|
|
21502
|
+
functionCalls,
|
|
21503
|
+
reasoning
|
|
20761
21504
|
});
|
|
20762
21505
|
},
|
|
20763
21506
|
{
|
|
@@ -20765,10 +21508,26 @@ async function executeStream(options2, executor) {
|
|
|
20765
21508
|
}
|
|
20766
21509
|
);
|
|
20767
21510
|
const responseText = isStructuredOutput ? collapseRepeatedStructuredJsonText(streamed.responseText) : streamed.responseText;
|
|
21511
|
+
const usagePromise = streamed.usage != null ? Promise.resolve(streamed.usage) : resolveOptionalValue(handle.usage);
|
|
21512
|
+
let evidence = {
|
|
21513
|
+
text: responseText,
|
|
21514
|
+
functionCalls: streamed.functionCalls,
|
|
21515
|
+
reasoning: streamed.reasoning,
|
|
21516
|
+
usage: streamed.usage
|
|
21517
|
+
};
|
|
21518
|
+
const notifyCurrentResponseEvidence = () => notifyResponseReceived(options2, evidence);
|
|
21519
|
+
notifyCurrentResponseEvidence();
|
|
21520
|
+
void usagePromise.then(
|
|
21521
|
+
(usage2) => {
|
|
21522
|
+
evidence = { ...evidence, usage: usage2 };
|
|
21523
|
+
notifyCurrentResponseEvidence();
|
|
21524
|
+
},
|
|
21525
|
+
() => void 0
|
|
21526
|
+
);
|
|
20768
21527
|
const [structuredOutput, usage, finishReason, providerMetadata, requestStatus] = await waitForPostResponseFinalization(
|
|
20769
21528
|
Promise.all([
|
|
20770
21529
|
options2.responseOutput != null ? resolveOptionalStructuredOutput(handle.output) : void 0,
|
|
20771
|
-
|
|
21530
|
+
usagePromise,
|
|
20772
21531
|
resolveOptionalValue(handle.finishReason),
|
|
20773
21532
|
resolveOptionalValue(handle.providerMetadata),
|
|
20774
21533
|
resolveOptionalValue(handle.requestStatus)
|
|
@@ -20790,8 +21549,13 @@ async function streamChatV2(options2) {
|
|
|
20790
21549
|
return executeStream(options2, options2.executeStream ?? defaultStreamExecutor);
|
|
20791
21550
|
}
|
|
20792
21551
|
async function generateChatV2(options2) {
|
|
21552
|
+
var _a;
|
|
20793
21553
|
const args = buildTextArgs(options2);
|
|
20794
21554
|
const stepToolCalls = attachGenerateStepToolCallCollector(args);
|
|
21555
|
+
try {
|
|
21556
|
+
(_a = options2.onRequestStarted) == null ? void 0 : _a.call(options2);
|
|
21557
|
+
} catch {
|
|
21558
|
+
}
|
|
20795
21559
|
let result;
|
|
20796
21560
|
try {
|
|
20797
21561
|
result = await waitForGeneratedResponse(
|
|
@@ -20807,13 +21571,35 @@ async function generateChatV2(options2) {
|
|
|
20807
21571
|
}
|
|
20808
21572
|
const isStructuredOutput = isChatV2StructuredResponseFormat(options2.responseFormat);
|
|
20809
21573
|
const responseText = isStructuredOutput ? collapseRepeatedStructuredJsonText(result.text) : result.text;
|
|
21574
|
+
const functionCalls = toStreamedFunctionCalls(
|
|
21575
|
+
result.toolCalls != null && result.toolCalls.length > 0 ? result.toolCalls : stepToolCalls
|
|
21576
|
+
);
|
|
21577
|
+
const reasoningPromise = resolveGenerateReasoning(result);
|
|
21578
|
+
const usagePromise = resolveGenerateUsage(result);
|
|
21579
|
+
let evidence = { text: responseText, functionCalls, reasoning: "" };
|
|
21580
|
+
const notifyCurrentResponseEvidence = () => notifyResponseReceived(options2, evidence);
|
|
21581
|
+
notifyCurrentResponseEvidence();
|
|
21582
|
+
void reasoningPromise.then(
|
|
21583
|
+
(reasoning2) => {
|
|
21584
|
+
evidence = { ...evidence, reasoning: reasoning2 };
|
|
21585
|
+
notifyCurrentResponseEvidence();
|
|
21586
|
+
},
|
|
21587
|
+
() => void 0
|
|
21588
|
+
);
|
|
21589
|
+
void usagePromise.then(
|
|
21590
|
+
(usage2) => {
|
|
21591
|
+
evidence = { ...evidence, usage: usage2 };
|
|
21592
|
+
notifyCurrentResponseEvidence();
|
|
21593
|
+
},
|
|
21594
|
+
() => void 0
|
|
21595
|
+
);
|
|
20810
21596
|
const [finishReason, structuredOutput, usage, reasoning, providerMetadata, requestStatus] = await waitForPostResponseFinalization(
|
|
20811
21597
|
(async () => {
|
|
20812
21598
|
const finishReason2 = await resolveOptionalValue(result.finishReason);
|
|
20813
21599
|
const [structuredOutput2, usage2, reasoning2, providerMetadata2, requestStatus2] = await Promise.all([
|
|
20814
21600
|
resolveGenerateStructuredOutput(result, options2.responseOutput, finishReason2),
|
|
20815
|
-
|
|
20816
|
-
|
|
21601
|
+
usagePromise,
|
|
21602
|
+
reasoningPromise,
|
|
20817
21603
|
resolveOptionalValue(result.providerMetadata),
|
|
20818
21604
|
resolveOptionalValue(result.requestStatus)
|
|
20819
21605
|
]);
|
|
@@ -20824,9 +21610,7 @@ async function generateChatV2(options2) {
|
|
|
20824
21610
|
return {
|
|
20825
21611
|
responseText,
|
|
20826
21612
|
structuredOutput,
|
|
20827
|
-
functionCalls
|
|
20828
|
-
result.toolCalls != null && result.toolCalls.length > 0 ? result.toolCalls : stepToolCalls
|
|
20829
|
-
),
|
|
21613
|
+
functionCalls,
|
|
20830
21614
|
usage,
|
|
20831
21615
|
reasoning,
|
|
20832
21616
|
finishReason,
|
|
@@ -21768,6 +22552,28 @@ async function runChatV2WithRetry(options2, chatOptions, retryPlan, signal, tran
|
|
|
21768
22552
|
const callId = createObservedChatV2CallId(options2);
|
|
21769
22553
|
const callStartedAt = Date.now();
|
|
21770
22554
|
let callWasObserved = false;
|
|
22555
|
+
let acceptsResponseEvidence = true;
|
|
22556
|
+
const retireResponseEvidence = () => {
|
|
22557
|
+
acceptsResponseEvidence = false;
|
|
22558
|
+
};
|
|
22559
|
+
let latestResponseEvidence;
|
|
22560
|
+
const reportResponseEvidence = (response) => {
|
|
22561
|
+
var _a2;
|
|
22562
|
+
if (!acceptsResponseEvidence) {
|
|
22563
|
+
return;
|
|
22564
|
+
}
|
|
22565
|
+
latestResponseEvidence = response;
|
|
22566
|
+
try {
|
|
22567
|
+
(_a2 = chatOptions.onResponseReceived) == null ? void 0 : _a2.call(chatOptions, response);
|
|
22568
|
+
} catch {
|
|
22569
|
+
}
|
|
22570
|
+
};
|
|
22571
|
+
const publishAndRetireResponseEvidence = () => {
|
|
22572
|
+
if (latestResponseEvidence != null) {
|
|
22573
|
+
reportResponseEvidence(latestResponseEvidence);
|
|
22574
|
+
}
|
|
22575
|
+
retireResponseEvidence();
|
|
22576
|
+
};
|
|
21771
22577
|
const attemptController = new AbortController();
|
|
21772
22578
|
const abortAttemptFromCaller = () => attemptController.abort(signal.reason);
|
|
21773
22579
|
if (signal.aborted) {
|
|
@@ -21782,10 +22588,12 @@ async function runChatV2WithRetry(options2, chatOptions, retryPlan, signal, tran
|
|
|
21782
22588
|
firstOutputTimeoutMs: options2.firstOutputTimeoutMs,
|
|
21783
22589
|
streamInactivityTimeoutMs: options2.streamInactivityTimeoutMs,
|
|
21784
22590
|
onStreamActivity: options2.onStreamActivity,
|
|
21785
|
-
onTimeout: (error) => attemptController.abort(error)
|
|
22591
|
+
onTimeout: (error) => attemptController.abort(error),
|
|
22592
|
+
onResponseReceived: reportResponseEvidence
|
|
21786
22593
|
};
|
|
21787
22594
|
const result = transportMode === "generate" ? await generateChatV2(attemptChatOptions) : await streamChatV2(attemptChatOptions);
|
|
21788
22595
|
await ((_a = options2.responseBodyCapture) == null ? void 0 : _a.flush());
|
|
22596
|
+
publishAndRetireResponseEvidence();
|
|
21789
22597
|
const statusCode = result.requestStatus ?? 200;
|
|
21790
22598
|
notifyChatV2CallFinished(options2, {
|
|
21791
22599
|
callId,
|
|
@@ -21816,6 +22624,7 @@ async function runChatV2WithRetry(options2, chatOptions, retryPlan, signal, tran
|
|
|
21816
22624
|
await ((_b = options2.responseBodyCapture) == null ? void 0 : _b.flush({
|
|
21817
22625
|
waitForPending: !signal.aborted && !isChatV2ProviderTimeoutError(error)
|
|
21818
22626
|
}));
|
|
22627
|
+
publishAndRetireResponseEvidence();
|
|
21819
22628
|
if (!callWasObserved) {
|
|
21820
22629
|
notifyChatV2CallFinished(options2, {
|
|
21821
22630
|
callId,
|
|
@@ -21845,6 +22654,7 @@ async function runChatV2WithRetry(options2, chatOptions, retryPlan, signal, tran
|
|
|
21845
22654
|
await prepareProviderRetry();
|
|
21846
22655
|
await waitForLLMChatV2RetryCooldown(retryPlan.cooldownMs, signal);
|
|
21847
22656
|
} finally {
|
|
22657
|
+
retireResponseEvidence();
|
|
21848
22658
|
signal.removeEventListener("abort", abortAttemptFromCaller);
|
|
21849
22659
|
}
|
|
21850
22660
|
}
|
|
@@ -21866,6 +22676,35 @@ async function runChatV2PipelineExecution(options2) {
|
|
|
21866
22676
|
tools
|
|
21867
22677
|
});
|
|
21868
22678
|
const shouldStreamResponse = plan.transportMode === "stream";
|
|
22679
|
+
const emitFailureCheckpoint = (partial) => {
|
|
22680
|
+
if (options2.onFailureCheckpoint == null) {
|
|
22681
|
+
return;
|
|
22682
|
+
}
|
|
22683
|
+
try {
|
|
22684
|
+
options2.onFailureCheckpoint(
|
|
22685
|
+
createChatV2CommonOutputs({
|
|
22686
|
+
requestMessages,
|
|
22687
|
+
response: partial.text,
|
|
22688
|
+
structuredOutput: void 0,
|
|
22689
|
+
functionCalls: partial.functionCalls,
|
|
22690
|
+
usage: normalizeChatV2Usage(partial.usage, options2),
|
|
22691
|
+
reasoning: partial.reasoning,
|
|
22692
|
+
requestBodies: options2.requestBodies,
|
|
22693
|
+
responseBodies: options2.responseBodies,
|
|
22694
|
+
outputUsage: plan.output.outputUsage,
|
|
22695
|
+
outputReasoning: plan.output.outputReasoning,
|
|
22696
|
+
outputRequestBody: plan.output.outputRequestBody,
|
|
22697
|
+
outputResponseBody: plan.output.outputResponseBody,
|
|
22698
|
+
includeFunctionCalls: plan.output.includeFunctionCalls,
|
|
22699
|
+
functionCallMode: plan.output.functionCallMode,
|
|
22700
|
+
// An incomplete structured reply is still useful diagnostic text,
|
|
22701
|
+
// not a schema-valid graph result.
|
|
22702
|
+
responseFormat: void 0
|
|
22703
|
+
})
|
|
22704
|
+
);
|
|
22705
|
+
} catch {
|
|
22706
|
+
}
|
|
22707
|
+
};
|
|
21869
22708
|
let chatResponse;
|
|
21870
22709
|
try {
|
|
21871
22710
|
chatResponse = await runChatV2WithRetry(
|
|
@@ -21875,8 +22714,11 @@ async function runChatV2PipelineExecution(options2) {
|
|
|
21875
22714
|
abortSignal: options2.context.signal,
|
|
21876
22715
|
executeStream: options2.executeStream,
|
|
21877
22716
|
executeGenerate: options2.executeGenerate,
|
|
21878
|
-
|
|
22717
|
+
onRequestStarted: () => emitFailureCheckpoint({ text: "", functionCalls: [], reasoning: "" }),
|
|
22718
|
+
onResponseReceived: emitFailureCheckpoint,
|
|
22719
|
+
onPartialOutput: !shouldStreamResponse ? void 0 : ({ text, functionCalls, reasoning }) => {
|
|
21879
22720
|
var _a, _b;
|
|
22721
|
+
emitFailureCheckpoint({ text, functionCalls, reasoning });
|
|
21880
22722
|
(_b = (_a = options2.context).onPartialOutputs) == null ? void 0 : _b.call(
|
|
21881
22723
|
_a,
|
|
21882
22724
|
createChatV2CommonOutputs({
|
|
@@ -21885,11 +22727,11 @@ async function runChatV2PipelineExecution(options2) {
|
|
|
21885
22727
|
structuredOutput: void 0,
|
|
21886
22728
|
functionCalls,
|
|
21887
22729
|
usage: void 0,
|
|
21888
|
-
reasoning
|
|
22730
|
+
reasoning,
|
|
21889
22731
|
requestBodies: void 0,
|
|
21890
22732
|
responseBodies: void 0,
|
|
21891
22733
|
outputUsage: false,
|
|
21892
|
-
outputReasoning:
|
|
22734
|
+
outputReasoning: plan.output.outputReasoning,
|
|
21893
22735
|
outputRequestBody: false,
|
|
21894
22736
|
outputResponseBody: false,
|
|
21895
22737
|
includeFunctionCalls: plan.output.includeFunctionCalls,
|
|
@@ -22299,6 +23141,8 @@ function projectLLMInvocationUsage(events) {
|
|
|
22299
23141
|
function projectLLMInvocationDiagnostics({
|
|
22300
23142
|
runOptions,
|
|
22301
23143
|
outputLLMAttempts,
|
|
23144
|
+
modelCalls,
|
|
23145
|
+
outputUsage,
|
|
22302
23146
|
llmAttempts,
|
|
22303
23147
|
profileSummary
|
|
22304
23148
|
}) {
|
|
@@ -22307,9 +23151,13 @@ function projectLLMInvocationDiagnostics({
|
|
|
22307
23151
|
...Object.fromEntries(
|
|
22308
23152
|
Object.entries(capturedBodies).filter(([, output]) => (output == null ? void 0 : output.type) !== "control-flow-excluded")
|
|
22309
23153
|
),
|
|
23154
|
+
...projectLLMInvocationUsageOutput({ modelCalls, outputUsage }),
|
|
22310
23155
|
...projectLLMInvocationMetadata({ outputLLMAttempts, llmAttempts, profileSummary })
|
|
22311
23156
|
};
|
|
22312
23157
|
}
|
|
23158
|
+
function mergeLLMInvocationFailureOutputs(partialOutputs, diagnostics) {
|
|
23159
|
+
return { ...partialOutputs, ...diagnostics };
|
|
23160
|
+
}
|
|
22313
23161
|
function projectLLMInvocationMetadata(params) {
|
|
22314
23162
|
const { outputLLMAttempts, llmAttempts, profileSummary } = params;
|
|
22315
23163
|
const outputs = {};
|
|
@@ -22329,12 +23177,10 @@ function projectLLMInvocationMetadata(params) {
|
|
|
22329
23177
|
}
|
|
22330
23178
|
function projectLLMInvocationResult(params) {
|
|
22331
23179
|
const { result, modelCalls, outputUsage, outputLLMAttempts, llmAttempts, profileSummary } = params;
|
|
22332
|
-
|
|
22333
|
-
|
|
22334
|
-
|
|
22335
|
-
|
|
22336
|
-
result.commonOutputs["usage"] = { type: "object", value: physicalUsage };
|
|
22337
|
-
}
|
|
23180
|
+
const usage = getLLMInvocationUsage({ modelCalls, outputUsage });
|
|
23181
|
+
if (usage != null) {
|
|
23182
|
+
result.usage = usage;
|
|
23183
|
+
result.commonOutputs["usage"] = { type: "object", value: usage };
|
|
22338
23184
|
}
|
|
22339
23185
|
Object.assign(
|
|
22340
23186
|
result.commonOutputs,
|
|
@@ -22346,6 +23192,22 @@ function projectLLMInvocationResult(params) {
|
|
|
22346
23192
|
);
|
|
22347
23193
|
return result.commonOutputs;
|
|
22348
23194
|
}
|
|
23195
|
+
function projectLLMInvocationUsageOutput({
|
|
23196
|
+
modelCalls,
|
|
23197
|
+
outputUsage
|
|
23198
|
+
}) {
|
|
23199
|
+
const usage = getLLMInvocationUsage({ modelCalls, outputUsage });
|
|
23200
|
+
return usage == null ? {} : { ["usage"]: { type: "object", value: usage } };
|
|
23201
|
+
}
|
|
23202
|
+
function getLLMInvocationUsage({
|
|
23203
|
+
modelCalls,
|
|
23204
|
+
outputUsage
|
|
23205
|
+
}) {
|
|
23206
|
+
if (!outputUsage || modelCalls.length === 0) {
|
|
23207
|
+
return void 0;
|
|
23208
|
+
}
|
|
23209
|
+
return projectLLMInvocationUsage(modelCalls) ?? void 0;
|
|
23210
|
+
}
|
|
22349
23211
|
|
|
22350
23212
|
// src/model/chat-v2/llmProfileFallback.ts
|
|
22351
23213
|
var DEFAULT_LLM_PROFILE_HEALTH_OPERATION_TIMEOUT_MS = 2e3;
|
|
@@ -22762,7 +23624,9 @@ function createLLMProfileFallbackRunner(params) {
|
|
|
22762
23624
|
healthDisposition: "deny",
|
|
22763
23625
|
...begin.retryAt == null ? {} : { retryAt: begin.retryAt }
|
|
22764
23626
|
});
|
|
22765
|
-
|
|
23627
|
+
if (profileIndex + 1 < params.candidates.length) {
|
|
23628
|
+
clearPartialResponse(roundOptions);
|
|
23629
|
+
}
|
|
22766
23630
|
continue;
|
|
22767
23631
|
}
|
|
22768
23632
|
const permitId = begin.permitId;
|
|
@@ -22834,7 +23698,9 @@ function createLLMProfileFallbackRunner(params) {
|
|
|
22834
23698
|
outcome: "failure",
|
|
22835
23699
|
error: getLLMAttemptErrorMessage(error)
|
|
22836
23700
|
});
|
|
22837
|
-
|
|
23701
|
+
if (profileIndex + 1 < params.candidates.length) {
|
|
23702
|
+
clearPartialResponse(roundOptions);
|
|
23703
|
+
}
|
|
22838
23704
|
await (healthPermit == null ? void 0 : healthPermit.finish("ignored"));
|
|
22839
23705
|
continue;
|
|
22840
23706
|
}
|
|
@@ -22899,7 +23765,9 @@ function createLLMProfileFallbackRunner(params) {
|
|
|
22899
23765
|
outcome: "failure",
|
|
22900
23766
|
error: getLLMAttemptErrorMessage(error)
|
|
22901
23767
|
});
|
|
22902
|
-
|
|
23768
|
+
if (profileIndex + 1 < params.candidates.length) {
|
|
23769
|
+
clearPartialResponse(roundOptions);
|
|
23770
|
+
}
|
|
22903
23771
|
await (healthPermit == null ? void 0 : healthPermit.finish("ignored"));
|
|
22904
23772
|
continue;
|
|
22905
23773
|
}
|
|
@@ -22913,7 +23781,9 @@ function createLLMProfileFallbackRunner(params) {
|
|
|
22913
23781
|
await (healthPermit == null ? void 0 : healthPermit.finish(
|
|
22914
23782
|
isUnhealthyLLMProfileProviderFailure(execution.failure.normalizedError) ? "unhealthy" : "ignored"
|
|
22915
23783
|
));
|
|
22916
|
-
|
|
23784
|
+
if (profileIndex + 1 < params.candidates.length) {
|
|
23785
|
+
clearPartialResponse(roundOptions);
|
|
23786
|
+
}
|
|
22917
23787
|
}
|
|
22918
23788
|
exhausted = true;
|
|
22919
23789
|
if (params.candidates.length === 1 && lastError !== void 0) {
|
|
@@ -24051,6 +24921,7 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
24051
24921
|
var _a, _b, _c, _d, _e;
|
|
24052
24922
|
const invocationJournal = new LLMInvocationJournal();
|
|
24053
24923
|
let profileAttemptSequence = 0;
|
|
24924
|
+
let latestFailureEvidence;
|
|
24054
24925
|
const usageTrackingContext = {
|
|
24055
24926
|
...context,
|
|
24056
24927
|
onChatV2CallFinished: (event) => {
|
|
@@ -24089,7 +24960,15 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
24089
24960
|
invocation = await executeLLMInvocation({
|
|
24090
24961
|
context,
|
|
24091
24962
|
journal: invocationJournal,
|
|
24092
|
-
runtime
|
|
24963
|
+
runtime: {
|
|
24964
|
+
...runtime,
|
|
24965
|
+
runOptions: {
|
|
24966
|
+
...runtime.runOptions,
|
|
24967
|
+
onFailureCheckpoint: (outputs) => {
|
|
24968
|
+
latestFailureEvidence = cloneLLMChatV2Outputs(outputs);
|
|
24969
|
+
}
|
|
24970
|
+
}
|
|
24971
|
+
},
|
|
24093
24972
|
toolCallContinuation
|
|
24094
24973
|
});
|
|
24095
24974
|
} catch (error) {
|
|
@@ -24097,11 +24976,18 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
24097
24976
|
const diagnostics = projectLLMInvocationDiagnostics({
|
|
24098
24977
|
runOptions: runtime.runOptions,
|
|
24099
24978
|
outputLLMAttempts: this.data.outputLLMAttempts,
|
|
24979
|
+
modelCalls: invocationJournal.modelCalls,
|
|
24980
|
+
outputUsage: this.data.outputUsage,
|
|
24100
24981
|
llmAttempts: invocationJournal.llmAttempts,
|
|
24101
24982
|
profileSummary: (_b = runtime.getProfileSummary) == null ? void 0 : _b.call(runtime)
|
|
24102
24983
|
});
|
|
24103
|
-
|
|
24104
|
-
|
|
24984
|
+
const failureOutputs = mergeLLMInvocationFailureOutputs(latestFailureEvidence, diagnostics);
|
|
24985
|
+
if (Object.keys(failureOutputs).length > 0) {
|
|
24986
|
+
if (context.setFailureOutputs) {
|
|
24987
|
+
context.setFailureOutputs(failureOutputs);
|
|
24988
|
+
} else {
|
|
24989
|
+
(_c = context.onPartialOutputs) == null ? void 0 : _c.call(context, failureOutputs);
|
|
24990
|
+
}
|
|
24105
24991
|
}
|
|
24106
24992
|
} catch {
|
|
24107
24993
|
}
|
|
@@ -24578,16 +25464,17 @@ var PromptNodeImpl = class extends NodeImpl {
|
|
|
24578
25464
|
dataType: "boolean"
|
|
24579
25465
|
});
|
|
24580
25466
|
}
|
|
24581
|
-
const
|
|
25467
|
+
const inputReferences = extractInterpolationVariableReferences(this.data.promptText);
|
|
25468
|
+
const fixedInputIds = new Set(inputs.map((input) => input.id));
|
|
24582
25469
|
inputs = [
|
|
24583
25470
|
...inputs,
|
|
24584
|
-
...(
|
|
25471
|
+
...inputReferences.filter(({ baseName }) => !fixedInputIds.has(baseName)).map(({ baseName, hasPath }) => {
|
|
24585
25472
|
return createInterpolationInputDefinition({
|
|
24586
|
-
interpolationName:
|
|
24587
|
-
dataType: "string",
|
|
25473
|
+
interpolationName: baseName,
|
|
25474
|
+
dataType: hasPath ? "any" : "string",
|
|
24588
25475
|
required: false
|
|
24589
25476
|
});
|
|
24590
|
-
})
|
|
25477
|
+
})
|
|
24591
25478
|
];
|
|
24592
25479
|
return inputs;
|
|
24593
25480
|
}
|
|
@@ -24698,18 +25585,12 @@ var PromptNodeImpl = class extends NodeImpl {
|
|
|
24698
25585
|
};
|
|
24699
25586
|
}
|
|
24700
25587
|
async process(inputs, context) {
|
|
24701
|
-
const inputMap = Object.keys(inputs).reduce(
|
|
24702
|
-
(acc, key) => {
|
|
24703
|
-
acc[key] = coerceTypeOptional(inputs[key], "string") ?? "";
|
|
24704
|
-
return acc;
|
|
24705
|
-
},
|
|
24706
|
-
{}
|
|
24707
|
-
);
|
|
24708
25588
|
let outputValue = interpolate(
|
|
24709
25589
|
this.chartNode.data.promptText,
|
|
24710
|
-
|
|
25590
|
+
inputs,
|
|
24711
25591
|
context.graphInputNodeValues,
|
|
24712
|
-
context.contextValues
|
|
25592
|
+
context.contextValues,
|
|
25593
|
+
{ coerceBareVariableDataValues: true }
|
|
24713
25594
|
);
|
|
24714
25595
|
outputValue = outputValue.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
24715
25596
|
const type = getInputOrData(this.data, inputs, "type", "string");
|
|
@@ -25258,6 +26139,7 @@ var import_ts_dedent10 = require("ts-dedent");
|
|
|
25258
26139
|
|
|
25259
26140
|
// src/model/nodes/jsValueInterpolation.ts
|
|
25260
26141
|
var import_ts_dedent9 = require("ts-dedent");
|
|
26142
|
+
var MISSING_INTERPOLATION_HELPER_MESSAGE = "This CodeRunner must honor CodeRunnerOptions.interpolationHelperIdentifier to resolve JSONPath or @graphInputs/@context interpolation.";
|
|
25261
26143
|
function escapeRegExp2(value) {
|
|
25262
26144
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25263
26145
|
}
|
|
@@ -25276,34 +26158,39 @@ function getSafeJsValueInterpolationIdentifier(source, baseIdentifier) {
|
|
|
25276
26158
|
function buildJsValuePreview(source, maxLines) {
|
|
25277
26159
|
return source.split("\n").slice(0, maxLines).join("\n").trim();
|
|
25278
26160
|
}
|
|
25279
|
-
function isSpecialReference(inputName) {
|
|
25280
|
-
return inputName.startsWith("@graphInputs.") || inputName.startsWith("@context.");
|
|
25281
|
-
}
|
|
25282
26161
|
function isSimpleIdentifier(value) {
|
|
25283
26162
|
return /^[A-Za-z_$][\w$]*$/.test(value);
|
|
25284
26163
|
}
|
|
25285
26164
|
function getUserFacingInputName(inputName) {
|
|
25286
26165
|
return isSimpleIdentifier(inputName) ? inputName : `{{${inputName}}}`;
|
|
25287
26166
|
}
|
|
25288
|
-
function buildJsValueReference(
|
|
25289
|
-
var _a;
|
|
25290
|
-
if (!
|
|
26167
|
+
function buildJsValueReference(token, interpolationContext, options2) {
|
|
26168
|
+
var _a, _b;
|
|
26169
|
+
if (!token.tokenName || !token.reference) {
|
|
25291
26170
|
return "undefined";
|
|
25292
26171
|
}
|
|
25293
|
-
|
|
25294
|
-
|
|
26172
|
+
const isBareVariableReference = token.reference.source === "variable" && token.reference.jsonPath === void 0;
|
|
26173
|
+
if (isBareVariableReference) {
|
|
26174
|
+
return ((_a = options2.localIdentifiers) == null ? void 0 : _a.has(token.reference.baseName)) ? token.reference.baseName : `${interpolationContext.inputsIdentifier}[${JSON.stringify(token.reference.baseName)}].value`;
|
|
25295
26175
|
}
|
|
25296
|
-
|
|
26176
|
+
const isLocalReference = token.reference.source === "variable" && ((_b = options2.localIdentifiers) == null ? void 0 : _b.has(token.reference.baseName));
|
|
26177
|
+
const sourceInputs = isLocalReference ? `{ ${JSON.stringify(token.reference.baseName)}: { type: 'any', value: ${token.reference.baseName} } }` : interpolationContext.inputsIdentifier;
|
|
26178
|
+
const resolveExpression = `${interpolationContext.interpolationHelperIdentifier}(${sourceInputs}, ${JSON.stringify(
|
|
26179
|
+
token.tokenName
|
|
26180
|
+
)}, ${interpolationContext.graphInputsIdentifier}, ${interpolationContext.contextIdentifier})`;
|
|
26181
|
+
return `(typeof ${interpolationContext.interpolationHelperIdentifier} === 'function'
|
|
26182
|
+
? ${resolveExpression}
|
|
26183
|
+
: (() => { throw new Error(${JSON.stringify(MISSING_INTERPOLATION_HELPER_MESSAGE)}); })())`;
|
|
25297
26184
|
}
|
|
25298
|
-
function formatJsValuePreviewValue(
|
|
25299
|
-
var _a
|
|
25300
|
-
if (!
|
|
26185
|
+
function formatJsValuePreviewValue(token, inputs, options2) {
|
|
26186
|
+
var _a;
|
|
26187
|
+
if (!token.tokenName || !token.reference || token.reference.source !== "variable") {
|
|
25301
26188
|
return "undefined";
|
|
25302
26189
|
}
|
|
25303
|
-
if ((_a = options2.localIdentifiers) == null ? void 0 : _a.has(
|
|
25304
|
-
return
|
|
26190
|
+
if ((_a = options2.localIdentifiers) == null ? void 0 : _a.has(token.reference.baseName)) {
|
|
26191
|
+
return token.reference.jsonPath ? `{{${token.tokenName}}}` : token.reference.baseName;
|
|
25305
26192
|
}
|
|
25306
|
-
const value = (
|
|
26193
|
+
const value = resolveInterpolationExpressionRawValue(token.tokenName, { variables: inputs });
|
|
25307
26194
|
if (value === void 0) {
|
|
25308
26195
|
return "undefined";
|
|
25309
26196
|
}
|
|
@@ -25316,7 +26203,7 @@ function formatJsValuePreviewValue(inputName, inputs, options2) {
|
|
|
25316
26203
|
if (typeof value === "number" || typeof value === "boolean") {
|
|
25317
26204
|
return String(value);
|
|
25318
26205
|
}
|
|
25319
|
-
return getUserFacingInputName(
|
|
26206
|
+
return getUserFacingInputName(token.tokenName);
|
|
25320
26207
|
}
|
|
25321
26208
|
function getJsValueInterpolationInputNames(template, options2 = {}) {
|
|
25322
26209
|
return extractInterpolationVariables(template).filter((inputName) => {
|
|
@@ -25334,22 +26221,53 @@ function getJsValueInterpolationInputDefinitions(template, options2 = {}) {
|
|
|
25334
26221
|
);
|
|
25335
26222
|
}
|
|
25336
26223
|
function getJsValueInterpolationRuntimeContext(template, baseInputsIdentifier, options2 = {}) {
|
|
26224
|
+
const inputsIdentifier = getSafeJsValueInterpolationIdentifier(template, baseInputsIdentifier);
|
|
26225
|
+
const interpolationHelperIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
26226
|
+
`${template}
|
|
26227
|
+
${inputsIdentifier}`,
|
|
26228
|
+
`${baseInputsIdentifier}ResolveInterpolation`
|
|
26229
|
+
);
|
|
26230
|
+
const cloneCacheIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
26231
|
+
`${template}
|
|
26232
|
+
${inputsIdentifier}
|
|
26233
|
+
${interpolationHelperIdentifier}`,
|
|
26234
|
+
`${baseInputsIdentifier}CloneCache`
|
|
26235
|
+
);
|
|
26236
|
+
const graphInputsIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
26237
|
+
`${template}
|
|
26238
|
+
${inputsIdentifier}
|
|
26239
|
+
${interpolationHelperIdentifier}
|
|
26240
|
+
${cloneCacheIdentifier}`,
|
|
26241
|
+
`${baseInputsIdentifier}GraphInputs`
|
|
26242
|
+
);
|
|
26243
|
+
const contextIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
26244
|
+
`${template}
|
|
26245
|
+
${inputsIdentifier}
|
|
26246
|
+
${interpolationHelperIdentifier}
|
|
26247
|
+
${cloneCacheIdentifier}
|
|
26248
|
+
${graphInputsIdentifier}`,
|
|
26249
|
+
`${baseInputsIdentifier}Context`
|
|
26250
|
+
);
|
|
26251
|
+
const parsedTemplate = parseInterpolationTemplate(template);
|
|
25337
26252
|
return {
|
|
25338
26253
|
inputNames: getJsValueInterpolationInputNames(template, options2),
|
|
25339
|
-
inputsIdentifier
|
|
26254
|
+
inputsIdentifier,
|
|
26255
|
+
interpolationHelperIdentifier,
|
|
26256
|
+
cloneCacheIdentifier,
|
|
26257
|
+
graphInputsIdentifier,
|
|
26258
|
+
contextIdentifier,
|
|
26259
|
+
requiresInterpolationHelper: parsedTemplate.tokens.some(
|
|
26260
|
+
(token) => token.reference !== void 0 && (token.reference.source !== "variable" || token.reference.jsonPath !== void 0)
|
|
26261
|
+
)
|
|
25340
26262
|
};
|
|
25341
26263
|
}
|
|
25342
|
-
function buildJsValueInterpolatedSource(template,
|
|
25343
|
-
return replaceInterpolationTokens(
|
|
25344
|
-
|
|
25345
|
-
|
|
25346
|
-
{
|
|
25347
|
-
trim: options2.trim ?? true
|
|
25348
|
-
}
|
|
25349
|
-
);
|
|
26264
|
+
function buildJsValueInterpolatedSource(template, interpolationContext, options2 = {}) {
|
|
26265
|
+
return replaceInterpolationTokens(template, (token) => buildJsValueReference(token, interpolationContext, options2), {
|
|
26266
|
+
trim: options2.trim ?? true
|
|
26267
|
+
});
|
|
25350
26268
|
}
|
|
25351
26269
|
function interpolateJsValuePreviewSource(template, inputs, options2 = {}) {
|
|
25352
|
-
return replaceInterpolationTokens(template, (token) => formatJsValuePreviewValue(token
|
|
26270
|
+
return replaceInterpolationTokens(template, (token) => formatJsValuePreviewValue(token, inputs, options2), {
|
|
25353
26271
|
trim: options2.trim ?? true
|
|
25354
26272
|
});
|
|
25355
26273
|
}
|
|
@@ -25445,50 +26363,86 @@ function buildCloneJsInputValueFunction() {
|
|
|
25445
26363
|
}
|
|
25446
26364
|
function buildClonedInputValueAssignments(inputNames, targetIdentifier, cacheIdentifier) {
|
|
25447
26365
|
return inputNames.map(
|
|
25448
|
-
(inputName) => `${targetIdentifier}[${JSON.stringify(inputName)}] =
|
|
25449
|
-
|
|
25450
|
-
|
|
26366
|
+
(inputName) => `${targetIdentifier}[${JSON.stringify(inputName)}] = (() => {
|
|
26367
|
+
const sourceDataValue = inputs[${JSON.stringify(inputName)}];
|
|
26368
|
+
return sourceDataValue == null
|
|
26369
|
+
? { type: 'any', value: undefined }
|
|
26370
|
+
: { ...sourceDataValue, value: cloneJsInputValue(sourceDataValue.value, ${cacheIdentifier}) };
|
|
26371
|
+
})();`
|
|
25451
26372
|
).join("\n");
|
|
25452
26373
|
}
|
|
25453
26374
|
function buildJsValueInputClonePreamble({
|
|
25454
26375
|
cacheIdentifier,
|
|
26376
|
+
contextIdentifier,
|
|
26377
|
+
graphInputsIdentifier,
|
|
25455
26378
|
inputsIdentifier
|
|
25456
26379
|
}) {
|
|
25457
26380
|
return import_ts_dedent9.dedent`
|
|
25458
26381
|
${buildCloneJsInputValueFunction()}
|
|
25459
26382
|
const ${inputsIdentifier} = Object.create(null);
|
|
25460
26383
|
const ${cacheIdentifier} = new WeakMap();
|
|
26384
|
+
const ${graphInputsIdentifier} = typeof graphInputs === 'undefined'
|
|
26385
|
+
? Object.create(null)
|
|
26386
|
+
: cloneJsInputValue(graphInputs, ${cacheIdentifier});
|
|
26387
|
+
const ${contextIdentifier} = typeof context === 'undefined'
|
|
26388
|
+
? Object.create(null)
|
|
26389
|
+
: cloneJsInputValue(context, ${cacheIdentifier});
|
|
25461
26390
|
`;
|
|
25462
26391
|
}
|
|
25463
26392
|
function buildJsValueInputsInitializer({
|
|
25464
|
-
|
|
25465
|
-
inputNames,
|
|
25466
|
-
inputsIdentifier
|
|
26393
|
+
interpolationContext
|
|
25467
26394
|
}) {
|
|
26395
|
+
const { cloneCacheIdentifier, contextIdentifier, graphInputsIdentifier, inputNames, inputsIdentifier } = interpolationContext;
|
|
25468
26396
|
return import_ts_dedent9.dedent`
|
|
25469
|
-
${buildJsValueInputClonePreamble({
|
|
25470
|
-
|
|
26397
|
+
${buildJsValueInputClonePreamble({
|
|
26398
|
+
cacheIdentifier: cloneCacheIdentifier,
|
|
26399
|
+
contextIdentifier,
|
|
26400
|
+
graphInputsIdentifier,
|
|
26401
|
+
inputsIdentifier
|
|
26402
|
+
})}
|
|
26403
|
+
${buildClonedInputValueAssignments(inputNames, inputsIdentifier, cloneCacheIdentifier)}
|
|
25471
26404
|
`;
|
|
25472
26405
|
}
|
|
25473
|
-
function
|
|
26406
|
+
function getJsValueInterpolationCodeRunnerOptions(options2, interpolationContext) {
|
|
26407
|
+
if (!interpolationContext.requiresInterpolationHelper) {
|
|
26408
|
+
return options2;
|
|
26409
|
+
}
|
|
26410
|
+
return {
|
|
26411
|
+
...options2,
|
|
26412
|
+
interpolationHelperIdentifier: interpolationContext.interpolationHelperIdentifier
|
|
26413
|
+
};
|
|
26414
|
+
}
|
|
26415
|
+
function sanitizeGeneratedJsValueText(text, inputNames, targetIdentifier, fallbackLabel, generatedIdentifiers = []) {
|
|
25474
26416
|
if (!text) {
|
|
25475
26417
|
return text;
|
|
25476
26418
|
}
|
|
25477
26419
|
let sanitized = text;
|
|
26420
|
+
const generatedFallbackLabel = inputNames.length === 1 ? `${fallbackLabel} ${getUserFacingInputName(inputNames[0])}` : fallbackLabel;
|
|
25478
26421
|
for (const inputName of inputNames) {
|
|
25479
26422
|
const userFacingInputName = getUserFacingInputName(inputName);
|
|
25480
26423
|
sanitized = sanitized.replaceAll(`${targetIdentifier}[${JSON.stringify(inputName)}]`, userFacingInputName).replaceAll(`${targetIdentifier}.${inputName}`, userFacingInputName);
|
|
25481
26424
|
}
|
|
25482
|
-
|
|
26425
|
+
for (const identifier of [...generatedIdentifiers].sort((left, right) => right.length - left.length)) {
|
|
26426
|
+
sanitized = sanitized.replaceAll(identifier, generatedFallbackLabel);
|
|
26427
|
+
}
|
|
26428
|
+
sanitized = sanitized.replaceAll(targetIdentifier, fallbackLabel);
|
|
26429
|
+
return sanitized;
|
|
25483
26430
|
}
|
|
25484
|
-
function sanitizeGeneratedJsValueError(error, inputNames, targetIdentifier, fallbackLabel) {
|
|
26431
|
+
function sanitizeGeneratedJsValueError(error, inputNames, targetIdentifier, fallbackLabel, generatedIdentifiers = []) {
|
|
25485
26432
|
const jsValueError = getError(error);
|
|
25486
|
-
jsValueError.message = sanitizeGeneratedJsValueText(
|
|
26433
|
+
jsValueError.message = sanitizeGeneratedJsValueText(
|
|
26434
|
+
jsValueError.message,
|
|
26435
|
+
inputNames,
|
|
26436
|
+
targetIdentifier,
|
|
26437
|
+
fallbackLabel,
|
|
26438
|
+
generatedIdentifiers
|
|
26439
|
+
) ?? jsValueError.message;
|
|
25487
26440
|
jsValueError.stack = sanitizeGeneratedJsValueText(
|
|
25488
26441
|
jsValueError.stack,
|
|
25489
26442
|
inputNames,
|
|
25490
26443
|
targetIdentifier,
|
|
25491
|
-
fallbackLabel
|
|
26444
|
+
fallbackLabel,
|
|
26445
|
+
generatedIdentifiers
|
|
25492
26446
|
);
|
|
25493
26447
|
return jsValueError;
|
|
25494
26448
|
}
|
|
@@ -25504,31 +26458,38 @@ var DEFAULT_CODE_NEW = import_ts_dedent10.dedent`
|
|
|
25504
26458
|
`;
|
|
25505
26459
|
var MAX_BODY_PREVIEW_LINES2 = 15;
|
|
25506
26460
|
var CODE_NEW_INPUTS_IDENTIFIER = "__codeNewInputs";
|
|
25507
|
-
var CODE_NEW_INPUT_CLONE_CACHE_IDENTIFIER = "codeNewInputCloneCache";
|
|
25508
26461
|
var CODE_NEW_OUTPUT_PORT_ID = "output";
|
|
25509
26462
|
function buildCodeNewPreview(code) {
|
|
25510
26463
|
return buildJsValuePreview(code, MAX_BODY_PREVIEW_LINES2);
|
|
25511
26464
|
}
|
|
25512
|
-
function buildCodeNewRuntimeSource(code,
|
|
25513
|
-
return buildJsValueInterpolatedSource(code,
|
|
26465
|
+
function buildCodeNewRuntimeSource(code, interpolationContext) {
|
|
26466
|
+
return buildJsValueInterpolatedSource(code, interpolationContext, { trim: false });
|
|
25514
26467
|
}
|
|
25515
|
-
function buildCodeNewInputsInitializer(
|
|
26468
|
+
function buildCodeNewInputsInitializer(interpolationContext) {
|
|
25516
26469
|
return buildJsValueInputsInitializer({
|
|
25517
|
-
|
|
25518
|
-
inputNames,
|
|
25519
|
-
inputsIdentifier
|
|
26470
|
+
interpolationContext
|
|
25520
26471
|
});
|
|
25521
26472
|
}
|
|
25522
26473
|
function interpolateCodeNewSource(code, inputs) {
|
|
25523
26474
|
return interpolateJsValuePreviewSource(code, inputs, { trim: false });
|
|
25524
26475
|
}
|
|
25525
|
-
function sanitizeCodeNewError(error,
|
|
25526
|
-
return sanitizeGeneratedJsValueError(
|
|
26476
|
+
function sanitizeCodeNewError(error, interpolationContext) {
|
|
26477
|
+
return sanitizeGeneratedJsValueError(
|
|
26478
|
+
error,
|
|
26479
|
+
interpolationContext.inputNames,
|
|
26480
|
+
interpolationContext.inputsIdentifier,
|
|
26481
|
+
"code input",
|
|
26482
|
+
[
|
|
26483
|
+
interpolationContext.cloneCacheIdentifier,
|
|
26484
|
+
interpolationContext.contextIdentifier,
|
|
26485
|
+
interpolationContext.graphInputsIdentifier,
|
|
26486
|
+
interpolationContext.interpolationHelperIdentifier
|
|
26487
|
+
]
|
|
26488
|
+
);
|
|
25527
26489
|
}
|
|
25528
26490
|
function buildCodeNewWrapper(code, interpolationContext) {
|
|
25529
|
-
const { inputNames, inputsIdentifier } = interpolationContext;
|
|
25530
26491
|
const beforeUserCodeLines = [
|
|
25531
|
-
...buildCodeNewInputsInitializer(
|
|
26492
|
+
...buildCodeNewInputsInitializer(interpolationContext).split(/\r?\n/),
|
|
25532
26493
|
"",
|
|
25533
26494
|
"const __codeNewResult = await (async () => {"
|
|
25534
26495
|
];
|
|
@@ -25543,7 +26504,7 @@ function buildCodeNewWrapper(code, interpolationContext) {
|
|
|
25543
26504
|
"};"
|
|
25544
26505
|
];
|
|
25545
26506
|
return {
|
|
25546
|
-
source: [...beforeUserCodeLines, buildCodeNewRuntimeSource(code,
|
|
26507
|
+
source: [...beforeUserCodeLines, buildCodeNewRuntimeSource(code, interpolationContext), ...afterUserCodeLines].join(
|
|
25547
26508
|
"\n"
|
|
25548
26509
|
),
|
|
25549
26510
|
userCodeLineOffset: beforeUserCodeLines.length
|
|
@@ -25628,13 +26589,12 @@ var CodeNewNodeImpl = class extends NodeImpl {
|
|
|
25628
26589
|
async process(inputs, context) {
|
|
25629
26590
|
const sourceUrl = buildCodeNodeSourceUrl(this.chartNode.id);
|
|
25630
26591
|
const interpolationContext = getJsValueInterpolationRuntimeContext(this.data.code, CODE_NEW_INPUTS_IDENTIFIER);
|
|
25631
|
-
const { inputNames, inputsIdentifier } = interpolationContext;
|
|
25632
26592
|
const { source, userCodeLineOffset } = buildCodeNewWrapper(this.data.code, interpolationContext);
|
|
25633
26593
|
try {
|
|
25634
26594
|
const outputs = await context.codeRunner.runCode(
|
|
25635
26595
|
appendCodeNodeSourceUrl(source, sourceUrl),
|
|
25636
26596
|
inputs,
|
|
25637
|
-
ALL_CODE_RUNNER_OPTIONS,
|
|
26597
|
+
getJsValueInterpolationCodeRunnerOptions(ALL_CODE_RUNNER_OPTIONS, interpolationContext),
|
|
25638
26598
|
context.graphInputNodeValues,
|
|
25639
26599
|
context.contextValues
|
|
25640
26600
|
);
|
|
@@ -25648,7 +26608,7 @@ var CodeNewNodeImpl = class extends NodeImpl {
|
|
|
25648
26608
|
sourceUrl,
|
|
25649
26609
|
userCodeLineOffset
|
|
25650
26610
|
});
|
|
25651
|
-
throw sanitizeCodeNewError(enrichedError,
|
|
26611
|
+
throw sanitizeCodeNewError(enrichedError, interpolationContext);
|
|
25652
26612
|
}
|
|
25653
26613
|
}
|
|
25654
26614
|
};
|
|
@@ -25661,32 +26621,39 @@ var CODE_RUNTIME_HELPER_MESSAGE3 = 'Node execution also provides "require" and "
|
|
|
25661
26621
|
var DEFAULT_EXPRESSION = '{{a}} == "123" ? {{b}} : {{c}}';
|
|
25662
26622
|
var MAX_BODY_PREVIEW_LINES3 = 15;
|
|
25663
26623
|
var EXPRESSION_INPUTS_IDENTIFIER = "__expressionInputs";
|
|
25664
|
-
var EXPRESSION_INPUT_CLONE_CACHE_IDENTIFIER = "expressionInputCloneCache";
|
|
25665
26624
|
var EXPRESSION_OUTPUT_PORT_ID = "output";
|
|
25666
26625
|
function buildExpressionPreview(expression) {
|
|
25667
26626
|
return buildJsValuePreview(expression, MAX_BODY_PREVIEW_LINES3);
|
|
25668
26627
|
}
|
|
25669
|
-
function buildExpressionRuntimeSource(expression,
|
|
25670
|
-
return buildJsValueInterpolatedSource(expression,
|
|
26628
|
+
function buildExpressionRuntimeSource(expression, interpolationContext) {
|
|
26629
|
+
return buildJsValueInterpolatedSource(expression, interpolationContext);
|
|
25671
26630
|
}
|
|
25672
|
-
function buildExpressionInputsInitializer(
|
|
26631
|
+
function buildExpressionInputsInitializer(interpolationContext) {
|
|
25673
26632
|
return buildJsValueInputsInitializer({
|
|
25674
|
-
|
|
25675
|
-
inputNames,
|
|
25676
|
-
inputsIdentifier
|
|
26633
|
+
interpolationContext
|
|
25677
26634
|
});
|
|
25678
26635
|
}
|
|
25679
26636
|
function interpolateExpressionSource(expression, inputs) {
|
|
25680
26637
|
return interpolateJsValuePreviewSource(expression, inputs);
|
|
25681
26638
|
}
|
|
25682
|
-
function sanitizeExpressionError(error,
|
|
25683
|
-
return sanitizeGeneratedJsValueError(
|
|
26639
|
+
function sanitizeExpressionError(error, interpolationContext) {
|
|
26640
|
+
return sanitizeGeneratedJsValueError(
|
|
26641
|
+
error,
|
|
26642
|
+
interpolationContext.inputNames,
|
|
26643
|
+
interpolationContext.inputsIdentifier,
|
|
26644
|
+
"expression input",
|
|
26645
|
+
[
|
|
26646
|
+
interpolationContext.cloneCacheIdentifier,
|
|
26647
|
+
interpolationContext.contextIdentifier,
|
|
26648
|
+
interpolationContext.graphInputsIdentifier,
|
|
26649
|
+
interpolationContext.interpolationHelperIdentifier
|
|
26650
|
+
]
|
|
26651
|
+
);
|
|
25684
26652
|
}
|
|
25685
26653
|
function buildExpressionWrapper(expression, interpolationContext) {
|
|
25686
|
-
const
|
|
25687
|
-
const expressionSource = buildExpressionRuntimeSource(expression, inputsIdentifier);
|
|
26654
|
+
const expressionSource = buildExpressionRuntimeSource(expression, interpolationContext);
|
|
25688
26655
|
return import_ts_dedent11.dedent`
|
|
25689
|
-
${buildExpressionInputsInitializer(
|
|
26656
|
+
${buildExpressionInputsInitializer(interpolationContext)}
|
|
25690
26657
|
|
|
25691
26658
|
return {
|
|
25692
26659
|
output: {
|
|
@@ -25764,18 +26731,17 @@ var ExpressionNodeImpl = class extends NodeImpl {
|
|
|
25764
26731
|
this.data.expression,
|
|
25765
26732
|
EXPRESSION_INPUTS_IDENTIFIER
|
|
25766
26733
|
);
|
|
25767
|
-
const { inputNames, inputsIdentifier } = interpolationContext;
|
|
25768
26734
|
const source = buildExpressionWrapper(this.data.expression, interpolationContext);
|
|
25769
26735
|
try {
|
|
25770
26736
|
return await context.codeRunner.runCode(
|
|
25771
26737
|
source,
|
|
25772
26738
|
inputs,
|
|
25773
|
-
ALL_CODE_RUNNER_OPTIONS,
|
|
26739
|
+
getJsValueInterpolationCodeRunnerOptions(ALL_CODE_RUNNER_OPTIONS, interpolationContext),
|
|
25774
26740
|
context.graphInputNodeValues,
|
|
25775
26741
|
context.contextValues
|
|
25776
26742
|
);
|
|
25777
26743
|
} catch (error) {
|
|
25778
|
-
throw sanitizeExpressionError(error,
|
|
26744
|
+
throw sanitizeExpressionError(error, interpolationContext);
|
|
25779
26745
|
}
|
|
25780
26746
|
}
|
|
25781
26747
|
};
|
|
@@ -26998,7 +27964,8 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
26998
27964
|
data: {
|
|
26999
27965
|
graphId: "",
|
|
27000
27966
|
useErrorOutput: false,
|
|
27001
|
-
useAsGraphPartialOutput: false
|
|
27967
|
+
useAsGraphPartialOutput: false,
|
|
27968
|
+
skipUnusedOutputs: false
|
|
27002
27969
|
}
|
|
27003
27970
|
};
|
|
27004
27971
|
return chartNode;
|
|
@@ -27037,6 +28004,12 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
27037
28004
|
type: "toggle",
|
|
27038
28005
|
label: "Use Error Output",
|
|
27039
28006
|
dataKey: "useErrorOutput"
|
|
28007
|
+
},
|
|
28008
|
+
{
|
|
28009
|
+
type: "toggle",
|
|
28010
|
+
label: "Skip unused outputs",
|
|
28011
|
+
dataKey: "skipUnusedOutputs",
|
|
28012
|
+
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."
|
|
27040
28013
|
}
|
|
27041
28014
|
];
|
|
27042
28015
|
if (this.data.graphId) {
|
|
@@ -27078,27 +28051,31 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
27078
28051
|
}
|
|
27079
28052
|
const boundary = ((_a = context.getGraphBoundary) == null ? void 0 : _a.call(context, project, this.data.graphId)) ?? getGraphBoundary(project, this.data.graphId);
|
|
27080
28053
|
const inputData = buildGraphBoundaryInputData(boundary, inputs, this.data.inputData);
|
|
27081
|
-
const shouldRunWholeGraph =
|
|
27082
|
-
const
|
|
27083
|
-
if (
|
|
27084
|
-
return
|
|
28054
|
+
const shouldRunWholeGraph = this.data.skipUnusedOutputs !== true || context.isDirectRunTarget || this.data.useAsGraphPartialOutput === true || this.data.useErrorOutput === true && context.activeOutputPortIds.has("error");
|
|
28055
|
+
const requestedGraphOutputIds = shouldRunWholeGraph ? void 0 : boundary.outputs.filter((output) => context.activeOutputPortIds.has(output.portId)).map((output) => output.id);
|
|
28056
|
+
if ((requestedGraphOutputIds == null ? void 0 : requestedGraphOutputIds.length) === 0) {
|
|
28057
|
+
return buildOptimizedSubgraphOutputs(boundary, [], {}, 0, this.data.useErrorOutput);
|
|
27085
28058
|
}
|
|
27086
28059
|
const subGraphProcessor = context.createSubProcessor(this.data.graphId, { signal: context.signal });
|
|
27087
|
-
if (!shouldRunWholeGraph) {
|
|
27088
|
-
subGraphProcessor.runToNodeIds = requestedGraphOutputNodeIds;
|
|
27089
|
-
}
|
|
27090
28060
|
try {
|
|
27091
28061
|
const startTime = Date.now();
|
|
27092
28062
|
const graphOutputs = await subGraphProcessor.processGraph(
|
|
27093
28063
|
context,
|
|
27094
28064
|
inputData,
|
|
27095
|
-
context.contextValues
|
|
28065
|
+
context.contextValues,
|
|
28066
|
+
requestedGraphOutputIds ? { requestedGraphOutputIds } : void 0
|
|
27096
28067
|
);
|
|
27097
|
-
const outputs = shouldRunWholeGraph ? graphOutputs : {
|
|
27098
|
-
...buildExcludedGraphBoundaryOutputs(boundary),
|
|
27099
|
-
...graphOutputs
|
|
27100
|
-
};
|
|
27101
28068
|
const duration = Date.now() - startTime;
|
|
28069
|
+
if (requestedGraphOutputIds) {
|
|
28070
|
+
return buildOptimizedSubgraphOutputs(
|
|
28071
|
+
boundary,
|
|
28072
|
+
requestedGraphOutputIds,
|
|
28073
|
+
graphOutputs,
|
|
28074
|
+
duration,
|
|
28075
|
+
this.data.useErrorOutput
|
|
28076
|
+
);
|
|
28077
|
+
}
|
|
28078
|
+
const outputs = graphOutputs;
|
|
27102
28079
|
if (this.data.useErrorOutput) {
|
|
27103
28080
|
outputs["error"] = {
|
|
27104
28081
|
type: "control-flow-excluded",
|
|
@@ -27126,28 +28103,33 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
27126
28103
|
}
|
|
27127
28104
|
};
|
|
27128
28105
|
var subGraphNode = nodeDefinition(SubGraphNodeImpl, "Subgraph");
|
|
27129
|
-
function
|
|
28106
|
+
function buildOptimizedSubgraphOutputs(boundary, requestedOutputIds, graphOutputs, duration, useErrorOutput) {
|
|
27130
28107
|
const outputs = buildExcludedGraphBoundaryOutputs(boundary);
|
|
28108
|
+
for (const outputId of requestedOutputIds) {
|
|
28109
|
+
if (Object.hasOwn(graphOutputs, outputId)) {
|
|
28110
|
+
outputs[outputId] = graphOutputs[outputId];
|
|
28111
|
+
} else {
|
|
28112
|
+
delete outputs[outputId];
|
|
28113
|
+
}
|
|
28114
|
+
}
|
|
27131
28115
|
if (useErrorOutput) {
|
|
27132
28116
|
outputs["error"] = {
|
|
27133
28117
|
type: "control-flow-excluded",
|
|
27134
28118
|
value: void 0
|
|
27135
28119
|
};
|
|
27136
28120
|
}
|
|
27137
|
-
outputs
|
|
27138
|
-
type: "number",
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
|
|
27142
|
-
|
|
27143
|
-
value: 0
|
|
27144
|
-
};
|
|
28121
|
+
if (!boundary.outputs.some((output) => output.id === "cost")) {
|
|
28122
|
+
outputs["cost"] = graphOutputs["cost"] ?? { type: "number", value: 0 };
|
|
28123
|
+
}
|
|
28124
|
+
if (!boundary.outputs.some((output) => output.id === "duration")) {
|
|
28125
|
+
outputs["duration"] = { type: "number", value: duration };
|
|
28126
|
+
}
|
|
27145
28127
|
return outputs;
|
|
27146
28128
|
}
|
|
27147
28129
|
|
|
27148
28130
|
// src/model/nodes/ArrayNode.ts
|
|
27149
28131
|
var import_non_secure27 = require("nanoid/non-secure");
|
|
27150
|
-
var
|
|
28132
|
+
var import_lodash_es7 = require("lodash");
|
|
27151
28133
|
var import_ts_dedent21 = require("ts-dedent");
|
|
27152
28134
|
|
|
27153
28135
|
// src/model/nodes/variadicPortIndex.ts
|
|
@@ -27275,7 +28257,7 @@ var ArrayNodeImpl = class extends NodeImpl {
|
|
|
27275
28257
|
if (Array.isArray(input == null ? void 0 : input.value)) {
|
|
27276
28258
|
for (const value of (input == null ? void 0 : input.value) ?? []) {
|
|
27277
28259
|
if (this.data.flattenDeep) {
|
|
27278
|
-
outputArray.push(...Array.isArray(value) ? (0,
|
|
28260
|
+
outputArray.push(...Array.isArray(value) ? (0, import_lodash_es7.flattenDeep)(value) : [value]);
|
|
27279
28261
|
} else {
|
|
27280
28262
|
outputArray.push(value);
|
|
27281
28263
|
}
|
|
@@ -27432,7 +28414,7 @@ function createMatchedOutput(value) {
|
|
|
27432
28414
|
|
|
27433
28415
|
// src/model/nodes/AssemblePromptNode.ts
|
|
27434
28416
|
var import_non_secure29 = require("nanoid/non-secure");
|
|
27435
|
-
var
|
|
28417
|
+
var import_lodash_es8 = require("lodash");
|
|
27436
28418
|
var import_ts_dedent23 = require("ts-dedent");
|
|
27437
28419
|
var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
27438
28420
|
static create() {
|
|
@@ -27525,7 +28507,7 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
27525
28507
|
const output = {};
|
|
27526
28508
|
const isLastMessageCacheBreakpoint = getInputOrData(this.data, inputs, "isLastMessageCacheBreakpoint", "boolean");
|
|
27527
28509
|
const outMessages = [];
|
|
27528
|
-
const inputMessages = (0,
|
|
28510
|
+
const inputMessages = (0, import_lodash_es8.orderBy)(
|
|
27529
28511
|
Object.entries(inputs).filter(([key]) => key.startsWith("message")),
|
|
27530
28512
|
([key]) => key,
|
|
27531
28513
|
"asc"
|
|
@@ -27570,7 +28552,6 @@ var assemblePromptNode = nodeDefinition(AssemblePromptNodeImpl, "Assemble Prompt
|
|
|
27570
28552
|
// src/model/nodes/ExtractYamlNode.ts
|
|
27571
28553
|
var import_non_secure30 = require("nanoid/non-secure");
|
|
27572
28554
|
var import_yaml = __toESM(require("yaml"), 1);
|
|
27573
|
-
var import_jsonpath_plus = require("jsonpath-plus");
|
|
27574
28555
|
var import_ts_dedent24 = require("ts-dedent");
|
|
27575
28556
|
var ExtractYamlNodeImpl = class extends NodeImpl {
|
|
27576
28557
|
static create() {
|
|
@@ -27719,9 +28700,9 @@ var ExtractYamlNodeImpl = class extends NodeImpl {
|
|
|
27719
28700
|
let matches = [];
|
|
27720
28701
|
if (objectPath) {
|
|
27721
28702
|
try {
|
|
27722
|
-
const extractedValue = (
|
|
27723
|
-
matches = extractedValue;
|
|
27724
|
-
yamlObject =
|
|
28703
|
+
const extractedValue = evaluateJsonPath(yamlObject, objectPath, true);
|
|
28704
|
+
matches = extractedValue == null ? [] : extractedValue;
|
|
28705
|
+
yamlObject = matches.length > 0 ? matches[0] : void 0;
|
|
27725
28706
|
} catch (err) {
|
|
27726
28707
|
return {
|
|
27727
28708
|
["noMatch"]: {
|
|
@@ -27743,7 +28724,7 @@ var ExtractYamlNodeImpl = class extends NodeImpl {
|
|
|
27743
28724
|
["output"]: yamlObject === void 0 ? {
|
|
27744
28725
|
type: "control-flow-excluded",
|
|
27745
28726
|
value: void 0
|
|
27746
|
-
} :
|
|
28727
|
+
} : objectPath ? {
|
|
27747
28728
|
type: "any",
|
|
27748
28729
|
value: yamlObject
|
|
27749
28730
|
} : {
|
|
@@ -28065,7 +29046,7 @@ var trimChatMessagesNode = nodeDefinition(TrimChatMessagesNodeImpl, "Trim Chat M
|
|
|
28065
29046
|
|
|
28066
29047
|
// src/model/nodes/ExternalCallNode.ts
|
|
28067
29048
|
var import_non_secure33 = require("nanoid/non-secure");
|
|
28068
|
-
var
|
|
29049
|
+
var import_lodash_es9 = require("lodash");
|
|
28069
29050
|
var import_ts_dedent27 = require("ts-dedent");
|
|
28070
29051
|
var ExternalCallNodeImpl = class extends NodeImpl {
|
|
28071
29052
|
static create() {
|
|
@@ -28160,7 +29141,7 @@ var ExternalCallNodeImpl = class extends NodeImpl {
|
|
|
28160
29141
|
}
|
|
28161
29142
|
}
|
|
28162
29143
|
const fn = context.externalFunctions[functionName];
|
|
28163
|
-
const externalContext = (0,
|
|
29144
|
+
const externalContext = (0, import_lodash_es9.omit)(context, ["setGlobal"]);
|
|
28164
29145
|
if (!fn) {
|
|
28165
29146
|
if (this.data.useErrorOutput) {
|
|
28166
29147
|
return {
|
|
@@ -28214,7 +29195,6 @@ var externalCallNode = nodeDefinition(ExternalCallNodeImpl, "External Call");
|
|
|
28214
29195
|
|
|
28215
29196
|
// src/model/nodes/ExtractObjectPathNode.ts
|
|
28216
29197
|
var import_non_secure34 = require("nanoid/non-secure");
|
|
28217
|
-
var import_jsonpath_plus2 = require("jsonpath-plus");
|
|
28218
29198
|
var import_ts_dedent28 = require("ts-dedent");
|
|
28219
29199
|
var RESERVED_INPUT_IDS = /* @__PURE__ */ new Set(["object"]);
|
|
28220
29200
|
function getExtractObjectPathInterpolationInputNames(path) {
|
|
@@ -28336,7 +29316,7 @@ var ExtractObjectPathNodeImpl = class extends NodeImpl {
|
|
|
28336
29316
|
const inputPath = usePathInput ? rawPath.trim() : interpolateExtractObjectPathSource(rawPath, inputs, context.graphInputNodeValues, context.contextValues);
|
|
28337
29317
|
let matches;
|
|
28338
29318
|
try {
|
|
28339
|
-
const match9 = (
|
|
29319
|
+
const match9 = evaluateJsonPath(inputObject, inputPath, true);
|
|
28340
29320
|
matches = match9 == null ? [] : match9;
|
|
28341
29321
|
} catch (err) {
|
|
28342
29322
|
matches = [];
|
|
@@ -29684,6 +30664,18 @@ var waitForEventNode = nodeDefinition(WaitForEventNodeImpl, "Wait For Event");
|
|
|
29684
30664
|
// src/model/nodes/ToolNode.ts
|
|
29685
30665
|
var import_non_secure49 = require("nanoid/non-secure");
|
|
29686
30666
|
var import_ts_dedent41 = require("ts-dedent");
|
|
30667
|
+
var TOOL_NODE_BODY_PREVIEW_MAX_LINES = 14;
|
|
30668
|
+
function getToolNodeBodyPreview(data) {
|
|
30669
|
+
const [name = "", ...descriptionLines] = buildNodeBodyPreview(
|
|
30670
|
+
`${data.name}
|
|
30671
|
+
${data.description}`,
|
|
30672
|
+
TOOL_NODE_BODY_PREVIEW_MAX_LINES
|
|
30673
|
+
).split("\n");
|
|
30674
|
+
return {
|
|
30675
|
+
name,
|
|
30676
|
+
description: descriptionLines.join("\n")
|
|
30677
|
+
};
|
|
30678
|
+
}
|
|
29687
30679
|
var GptFunctionNodeImpl = class extends NodeImpl {
|
|
29688
30680
|
static create() {
|
|
29689
30681
|
const chartNode = {
|
|
@@ -29734,17 +30726,17 @@ var GptFunctionNodeImpl = class extends NodeImpl {
|
|
|
29734
30726
|
description: "The schema of the tool that the LLM will see as available to call"
|
|
29735
30727
|
});
|
|
29736
30728
|
}
|
|
29737
|
-
const
|
|
30729
|
+
const inputReferences = this.data.useSchemaInput ? [] : extractInterpolationVariableReferences(this.data.schema);
|
|
29738
30730
|
inputs = [
|
|
29739
30731
|
...inputs,
|
|
29740
|
-
...(
|
|
30732
|
+
...inputReferences.map(({ baseName, hasPath }) => {
|
|
29741
30733
|
return createInterpolationInputDefinition({
|
|
29742
|
-
id: `input-${
|
|
29743
|
-
interpolationName:
|
|
29744
|
-
dataType: "string",
|
|
29745
|
-
description: `An interpolated value in the schema named '${
|
|
30734
|
+
id: `input-${baseName}`,
|
|
30735
|
+
interpolationName: baseName,
|
|
30736
|
+
dataType: hasPath ? "any" : "string",
|
|
30737
|
+
description: `An interpolated value in the schema named '${baseName}'`
|
|
29746
30738
|
});
|
|
29747
|
-
})
|
|
30739
|
+
})
|
|
29748
30740
|
];
|
|
29749
30741
|
return inputs;
|
|
29750
30742
|
}
|
|
@@ -29816,10 +30808,12 @@ var GptFunctionNodeImpl = class extends NodeImpl {
|
|
|
29816
30808
|
];
|
|
29817
30809
|
}
|
|
29818
30810
|
getBody() {
|
|
30811
|
+
const preview = getToolNodeBodyPreview(this.data);
|
|
29819
30812
|
return {
|
|
29820
|
-
type: "
|
|
29821
|
-
|
|
29822
|
-
|
|
30813
|
+
type: "colorized",
|
|
30814
|
+
language: "prompt-interpolation-markdown",
|
|
30815
|
+
theme: "prompt-interpolation",
|
|
30816
|
+
text: [preview.name, preview.description].filter(Boolean).join("\n")
|
|
29823
30817
|
};
|
|
29824
30818
|
}
|
|
29825
30819
|
static getUIData() {
|
|
@@ -29832,7 +30826,7 @@ ${this.data.description}`
|
|
|
29832
30826
|
group: ["AI"]
|
|
29833
30827
|
};
|
|
29834
30828
|
}
|
|
29835
|
-
async process(inputs) {
|
|
30829
|
+
async process(inputs, context) {
|
|
29836
30830
|
const name = getInputOrData(this.data, inputs, "name");
|
|
29837
30831
|
const description = getInputOrData(this.data, inputs, "description");
|
|
29838
30832
|
const resultHandling = this.data.resultHandling === "return-direct" ? "return-direct" : "continue";
|
|
@@ -29840,16 +30834,21 @@ ${this.data.description}`
|
|
|
29840
30834
|
if (this.data.useSchemaInput) {
|
|
29841
30835
|
schema = coerceType(inputs["schema"], "object");
|
|
29842
30836
|
} else {
|
|
29843
|
-
const inputMap = keys(inputs).filter((key) => key.startsWith("input")).reduce(
|
|
30837
|
+
const inputMap = keys(inputs).filter((key) => key.startsWith("input-")).reduce(
|
|
29844
30838
|
(acc, key) => {
|
|
29845
|
-
const stringValue = coerceTypeOptional(inputs[key], "string") ?? "";
|
|
29846
30839
|
const interpolationKey = key.slice("input-".length);
|
|
29847
|
-
acc[interpolationKey] =
|
|
30840
|
+
acc[interpolationKey] = inputs[key];
|
|
29848
30841
|
return acc;
|
|
29849
30842
|
},
|
|
29850
30843
|
{}
|
|
29851
30844
|
);
|
|
29852
|
-
const interpolated = interpolate(
|
|
30845
|
+
const interpolated = interpolate(
|
|
30846
|
+
this.data.schema,
|
|
30847
|
+
inputMap,
|
|
30848
|
+
context == null ? void 0 : context.graphInputNodeValues,
|
|
30849
|
+
context == null ? void 0 : context.contextValues,
|
|
30850
|
+
{ coerceBareVariableDataValues: true }
|
|
30851
|
+
);
|
|
29853
30852
|
schema = JSON.parse(interpolated);
|
|
29854
30853
|
}
|
|
29855
30854
|
return {
|
|
@@ -31426,7 +32425,7 @@ var joinNode = nodeDefinition(JoinNodeImpl, "Coalesce");
|
|
|
31426
32425
|
|
|
31427
32426
|
// src/model/nodes/FilterNode.ts
|
|
31428
32427
|
var import_non_secure65 = require("nanoid/non-secure");
|
|
31429
|
-
var
|
|
32428
|
+
var import_lodash_es10 = require("lodash");
|
|
31430
32429
|
var import_ts_dedent56 = require("ts-dedent");
|
|
31431
32430
|
var FilterNodeImpl = class extends NodeImpl {
|
|
31432
32431
|
static create() {
|
|
@@ -31482,7 +32481,7 @@ var FilterNodeImpl = class extends NodeImpl {
|
|
|
31482
32481
|
var _a;
|
|
31483
32482
|
const array = coerceType(inputs["array"], "any[]");
|
|
31484
32483
|
const include = coerceType(inputs["include"], "boolean[]");
|
|
31485
|
-
const zipped = (0,
|
|
32484
|
+
const zipped = (0, import_lodash_es10.zip)(array, include);
|
|
31486
32485
|
const filtered = zipped.filter(([_, include2]) => include2).map(([value, _]) => value);
|
|
31487
32486
|
return {
|
|
31488
32487
|
["filtered"]: {
|
|
@@ -31504,7 +32503,6 @@ var MAX_CALLBACK_PREVIEW_BODY_LINES = 13;
|
|
|
31504
32503
|
var JS_LIST_CALLBACK_SIGNATURE = "(item, index, array)";
|
|
31505
32504
|
var JS_LIST_CALLBACK_LOCAL_NAMES = /* @__PURE__ */ new Set(["item", "index", "array"]);
|
|
31506
32505
|
var JS_LIST_INPUTS_IDENTIFIER = "__jsListInputs";
|
|
31507
|
-
var JS_LIST_INPUT_CLONE_CACHE_IDENTIFIER = "jsListInputCloneCache";
|
|
31508
32506
|
var JS_LIST_CODE_RUNNER_OPTIONS = {
|
|
31509
32507
|
includeFetch: false,
|
|
31510
32508
|
includeRequire: false,
|
|
@@ -31529,31 +32527,43 @@ function buildJSListRuntimePreamble(interpolationContext) {
|
|
|
31529
32527
|
return import_ts_dedent57.dedent`
|
|
31530
32528
|
const assertSynchronousCallbackResult = ${assertSynchronousCallbackResult.toString()};
|
|
31531
32529
|
${buildJsValueInputClonePreamble({
|
|
31532
|
-
cacheIdentifier:
|
|
32530
|
+
cacheIdentifier: interpolationContext.cloneCacheIdentifier,
|
|
32531
|
+
contextIdentifier: interpolationContext.contextIdentifier,
|
|
32532
|
+
graphInputsIdentifier: interpolationContext.graphInputsIdentifier,
|
|
31533
32533
|
inputsIdentifier: interpolationContext.inputsIdentifier
|
|
31534
32534
|
})}
|
|
31535
|
-
const array = cloneJsInputValue(inputs.array?.value, ${
|
|
32535
|
+
const array = cloneJsInputValue(inputs.array?.value, ${interpolationContext.cloneCacheIdentifier});
|
|
31536
32536
|
${buildClonedInputValueAssignments(
|
|
31537
32537
|
interpolationContext.inputNames,
|
|
31538
32538
|
interpolationContext.inputsIdentifier,
|
|
31539
|
-
|
|
32539
|
+
interpolationContext.cloneCacheIdentifier
|
|
31540
32540
|
)}
|
|
31541
32541
|
`;
|
|
31542
32542
|
}
|
|
31543
|
-
function buildJSListCallbackRuntimeSource(callbackBody,
|
|
31544
|
-
return buildJsValueInterpolatedSource(callbackBody,
|
|
32543
|
+
function buildJSListCallbackRuntimeSource(callbackBody, interpolationContext) {
|
|
32544
|
+
return buildJsValueInterpolatedSource(callbackBody, interpolationContext, {
|
|
31545
32545
|
localIdentifiers: JS_LIST_CALLBACK_LOCAL_NAMES
|
|
31546
32546
|
});
|
|
31547
32547
|
}
|
|
31548
32548
|
function sanitizeJSListError(error, callbackBody, nodeName) {
|
|
31549
|
-
const
|
|
32549
|
+
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
31550
32550
|
const fallbackLabel = `${nodeName} input`;
|
|
31551
|
-
return sanitizeGeneratedJsValueError(
|
|
32551
|
+
return sanitizeGeneratedJsValueError(
|
|
32552
|
+
error,
|
|
32553
|
+
interpolationContext.inputNames,
|
|
32554
|
+
interpolationContext.inputsIdentifier,
|
|
32555
|
+
fallbackLabel,
|
|
32556
|
+
[
|
|
32557
|
+
interpolationContext.cloneCacheIdentifier,
|
|
32558
|
+
interpolationContext.contextIdentifier,
|
|
32559
|
+
interpolationContext.graphInputsIdentifier,
|
|
32560
|
+
interpolationContext.interpolationHelperIdentifier
|
|
32561
|
+
]
|
|
32562
|
+
);
|
|
31552
32563
|
}
|
|
31553
32564
|
function buildJSFilterWrapper(callbackBody) {
|
|
31554
32565
|
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
31555
|
-
const
|
|
31556
|
-
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, inputsIdentifier);
|
|
32566
|
+
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, interpolationContext);
|
|
31557
32567
|
return import_ts_dedent57.dedent`
|
|
31558
32568
|
${buildJSListRuntimePreamble(interpolationContext)}
|
|
31559
32569
|
|
|
@@ -31589,8 +32599,7 @@ function buildJSFilterWrapper(callbackBody) {
|
|
|
31589
32599
|
}
|
|
31590
32600
|
function buildJSMapWrapper(callbackBody) {
|
|
31591
32601
|
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
31592
|
-
const
|
|
31593
|
-
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, inputsIdentifier);
|
|
32602
|
+
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, interpolationContext);
|
|
31594
32603
|
return import_ts_dedent57.dedent`
|
|
31595
32604
|
${buildJSListRuntimePreamble(interpolationContext)}
|
|
31596
32605
|
|
|
@@ -31643,7 +32652,7 @@ function getJSListEditors() {
|
|
|
31643
32652
|
type: "code",
|
|
31644
32653
|
label: "Callback Body",
|
|
31645
32654
|
helperMessage: "(item, index, array) => {",
|
|
31646
|
-
postEditorHelperMessage: "};\n\n//Use {{var}} to create input ports
|
|
32655
|
+
postEditorHelperMessage: "};\n\n//Use {{var}} to create input ports. {{config.limit.max}} creates only config; {{item.name}} and {{array[0]}} use callback locals.",
|
|
31647
32656
|
dataKey: "callbackBody",
|
|
31648
32657
|
language: "javascript",
|
|
31649
32658
|
interpolationSyntax: "js-value",
|
|
@@ -31690,7 +32699,10 @@ async function runJSListNodeCode({
|
|
|
31690
32699
|
const outputs = await context.codeRunner.runCode(
|
|
31691
32700
|
buildWrapper(callbackBody),
|
|
31692
32701
|
inputs,
|
|
31693
|
-
|
|
32702
|
+
getJsValueInterpolationCodeRunnerOptions(
|
|
32703
|
+
JS_LIST_CODE_RUNNER_OPTIONS,
|
|
32704
|
+
getJSListInterpolationContext(callbackBody)
|
|
32705
|
+
),
|
|
31694
32706
|
context.graphInputNodeValues,
|
|
31695
32707
|
context.contextValues
|
|
31696
32708
|
);
|
|
@@ -31745,7 +32757,9 @@ var JSFilterNodeImpl = class extends NodeImpl {
|
|
|
31745
32757
|
|
|
31746
32758
|
Available callback parameters are <code>item</code>, <code>index</code>, and <code>array</code>.
|
|
31747
32759
|
Write only the callback body and still use <code>return</code> to decide whether each item is included.
|
|
31748
|
-
Use <code>{{var}}</code> to add input ports that evaluate as connected values.
|
|
32760
|
+
Use <code>{{var}}</code> to add input ports that evaluate as connected values. A path such as
|
|
32761
|
+
<code>{{config.limit.max}}</code> creates only <code>config</code>; <code>{{item.name}}</code> and
|
|
32762
|
+
<code>{{array[0]}}</code> use callback locals and do not add ports.
|
|
31749
32763
|
`,
|
|
31750
32764
|
infoBoxTitle: "JS Filter Node",
|
|
31751
32765
|
contextMenuTitle: "JS Filter",
|
|
@@ -31811,7 +32825,9 @@ var JSMapNodeImpl = class extends NodeImpl {
|
|
|
31811
32825
|
|
|
31812
32826
|
Available callback parameters are <code>item</code>, <code>index</code>, and <code>array</code>.
|
|
31813
32827
|
Write only the callback body and still use <code>return</code> to produce each mapped item.
|
|
31814
|
-
Use <code>{{var}}</code> to add input ports that evaluate as connected values.
|
|
32828
|
+
Use <code>{{var}}</code> to add input ports that evaluate as connected values. A path such as
|
|
32829
|
+
<code>{{config.limit.max}}</code> creates only <code>config</code>; <code>{{item.name}}</code> and
|
|
32830
|
+
<code>{{array[0]}}</code> use callback locals and do not add ports.
|
|
31815
32831
|
`,
|
|
31816
32832
|
infoBoxTitle: "JS Map Node",
|
|
31817
32833
|
contextMenuTitle: "JS Map",
|
|
@@ -31945,33 +32961,25 @@ var ObjectNodeImpl = class extends NodeImpl {
|
|
|
31945
32961
|
}
|
|
31946
32962
|
interpolate(baseString, values2, graphInputNodeValues, contextValues) {
|
|
31947
32963
|
const protectedBaseString = protectEscapedInterpolationTokens(baseString);
|
|
31948
|
-
const
|
|
31949
|
-
if (
|
|
32964
|
+
const parsedTemplate = parseInterpolationTemplate(protectedBaseString);
|
|
32965
|
+
if (parsedTemplate.tokens.length === 0) {
|
|
31950
32966
|
return restoreEscapedInterpolationTokens(protectedBaseString);
|
|
31951
32967
|
}
|
|
31952
32968
|
let result = "";
|
|
31953
32969
|
let cursor = 0;
|
|
31954
|
-
for (const
|
|
32970
|
+
for (const token of parsedTemplate.tokens) {
|
|
32971
|
+
const tokenSpan = token.span;
|
|
31955
32972
|
const isInsideString = isInsideJsonString(protectedBaseString, tokenSpan.start);
|
|
31956
32973
|
const isWholeQuotedToken = isInsideString && isUnescapedQuoteAt(protectedBaseString, tokenSpan.start - 1) && isUnescapedQuoteAt(protectedBaseString, tokenSpan.end);
|
|
31957
32974
|
const replacementStart = isWholeQuotedToken ? tokenSpan.start - 1 : tokenSpan.start;
|
|
31958
32975
|
const replacementEnd = isWholeQuotedToken ? tokenSpan.end + 1 : tokenSpan.end;
|
|
31959
|
-
const
|
|
31960
|
-
|
|
31961
|
-
|
|
31962
|
-
|
|
31963
|
-
|
|
31964
|
-
|
|
31965
|
-
|
|
31966
|
-
trimmedKey.substring(graphInputPrefix.length),
|
|
31967
|
-
"graphInputs"
|
|
31968
|
-
);
|
|
31969
|
-
} else if (trimmedKey.startsWith(contextPrefix) && contextValues) {
|
|
31970
|
-
value = resolveExpressionRawValue(contextValues, trimmedKey.substring(contextPrefix.length), "context");
|
|
31971
|
-
} else {
|
|
31972
|
-
value = values2[trimmedKey];
|
|
31973
|
-
}
|
|
31974
|
-
result += protectedBaseString.slice(cursor, replacementStart);
|
|
32976
|
+
const value = token.reference ? resolveInterpolationExpressionRawValue(token.reference, {
|
|
32977
|
+
variables: values2,
|
|
32978
|
+
graphInputValues: graphInputNodeValues,
|
|
32979
|
+
contextValues,
|
|
32980
|
+
unwrapVariableDataValues: false
|
|
32981
|
+
}) : void 0;
|
|
32982
|
+
result += restoreEscapedInterpolationTokens(protectedBaseString.slice(cursor, replacementStart));
|
|
31975
32983
|
if (isInsideString && !isWholeQuotedToken) {
|
|
31976
32984
|
result += stringifyEmbeddedJsonStringFragment(value);
|
|
31977
32985
|
} else if (isWholeQuotedToken) {
|
|
@@ -31981,8 +32989,8 @@ var ObjectNodeImpl = class extends NodeImpl {
|
|
|
31981
32989
|
}
|
|
31982
32990
|
cursor = replacementEnd;
|
|
31983
32991
|
}
|
|
31984
|
-
result += protectedBaseString.slice(cursor);
|
|
31985
|
-
return
|
|
32992
|
+
result += restoreEscapedInterpolationTokens(protectedBaseString.slice(cursor));
|
|
32993
|
+
return result;
|
|
31986
32994
|
}
|
|
31987
32995
|
async process(inputs, context) {
|
|
31988
32996
|
const inputMap = Object.keys(inputs).reduce(
|
|
@@ -32085,7 +33093,7 @@ var booleanNode = nodeDefinition(BooleanNodeImpl, "Boolean");
|
|
|
32085
33093
|
|
|
32086
33094
|
// src/model/nodes/CompareNode.ts
|
|
32087
33095
|
var import_non_secure70 = require("nanoid/non-secure");
|
|
32088
|
-
var
|
|
33096
|
+
var import_lodash_es11 = require("lodash");
|
|
32089
33097
|
var import_ts_pattern4 = require("ts-pattern");
|
|
32090
33098
|
var import_ts_dedent62 = require("ts-dedent");
|
|
32091
33099
|
var compareNodeComparisonFunctionOptions = [
|
|
@@ -32199,7 +33207,7 @@ var CompareNodeImpl = class extends NodeImpl {
|
|
|
32199
33207
|
return {
|
|
32200
33208
|
["output"]: {
|
|
32201
33209
|
type: "boolean",
|
|
32202
|
-
value: (0, import_ts_pattern4.match)(comparisonFunction).with("==", () => (0,
|
|
33210
|
+
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()
|
|
32203
33211
|
}
|
|
32204
33212
|
};
|
|
32205
33213
|
}
|
|
@@ -32519,7 +33527,7 @@ var randomNumberNode = nodeDefinition(RandomNumberNodeImpl, "Random number");
|
|
|
32519
33527
|
|
|
32520
33528
|
// src/model/nodes/ShuffleNode.ts
|
|
32521
33529
|
var import_non_secure74 = require("nanoid/non-secure");
|
|
32522
|
-
var
|
|
33530
|
+
var import_lodash_es12 = require("lodash");
|
|
32523
33531
|
var import_ts_dedent66 = require("ts-dedent");
|
|
32524
33532
|
var ShuffleNodeImpl = class extends NodeImpl {
|
|
32525
33533
|
static create() {
|
|
@@ -32568,7 +33576,7 @@ var ShuffleNodeImpl = class extends NodeImpl {
|
|
|
32568
33576
|
var _a;
|
|
32569
33577
|
const input = inputs["array"];
|
|
32570
33578
|
const items = input ? isArrayDataValue(input) ? input.value : [input.value] : [];
|
|
32571
|
-
const shuffled = (0,
|
|
33579
|
+
const shuffled = (0, import_lodash_es12.shuffle)(items);
|
|
32572
33580
|
return {
|
|
32573
33581
|
["shuffled"]: {
|
|
32574
33582
|
type: ((_a = inputs["array"]) == null ? void 0 : _a.type) ?? "any[]",
|
|
@@ -34308,7 +35316,7 @@ var extractMarkdownCodeBlocksNode = nodeDefinition(
|
|
|
34308
35316
|
|
|
34309
35317
|
// src/model/nodes/AssembleMessageNode.ts
|
|
34310
35318
|
var import_non_secure83 = require("nanoid/non-secure");
|
|
34311
|
-
var
|
|
35319
|
+
var import_lodash_es13 = require("lodash");
|
|
34312
35320
|
var import_ts_pattern6 = require("ts-pattern");
|
|
34313
35321
|
var messageTypeToTitle = {
|
|
34314
35322
|
assistant: "Assistant",
|
|
@@ -34459,7 +35467,7 @@ var AssembleMessageNodeImpl = class extends NodeImpl {
|
|
|
34459
35467
|
).otherwise(() => {
|
|
34460
35468
|
throw new Error(`Invalid type: ${type}`);
|
|
34461
35469
|
});
|
|
34462
|
-
const inputParts = (0,
|
|
35470
|
+
const inputParts = (0, import_lodash_es13.orderBy)(
|
|
34463
35471
|
Object.entries(inputs).filter(([key]) => key.startsWith("part")),
|
|
34464
35472
|
([key]) => key,
|
|
34465
35473
|
"asc"
|
|
@@ -34588,7 +35596,6 @@ var urlReferenceNode = nodeDefinition(UrlReferenceNodeImpl, "URL Reference");
|
|
|
34588
35596
|
|
|
34589
35597
|
// src/model/nodes/DestructureNode.ts
|
|
34590
35598
|
var import_non_secure85 = require("nanoid/non-secure");
|
|
34591
|
-
var import_jsonpath_plus3 = require("jsonpath-plus");
|
|
34592
35599
|
var import_ts_dedent72 = require("ts-dedent");
|
|
34593
35600
|
var DestructureNodeImpl = class extends NodeImpl {
|
|
34594
35601
|
static create() {
|
|
@@ -34676,7 +35683,7 @@ var DestructureNodeImpl = class extends NodeImpl {
|
|
|
34676
35683
|
this.data.paths.forEach((path, index) => {
|
|
34677
35684
|
let match9;
|
|
34678
35685
|
try {
|
|
34679
|
-
match9 = (
|
|
35686
|
+
match9 = evaluateJsonPath(inputObject, path, false);
|
|
34680
35687
|
} catch (err) {
|
|
34681
35688
|
match9 = void 0;
|
|
34682
35689
|
}
|
|
@@ -34993,9 +36000,9 @@ var import_non_secure88 = require("nanoid/non-secure");
|
|
|
34993
36000
|
var import_ts_dedent75 = require("ts-dedent");
|
|
34994
36001
|
|
|
34995
36002
|
// src/api/looseDataValue.ts
|
|
34996
|
-
var
|
|
36003
|
+
var import_lodash_es14 = require("lodash");
|
|
34997
36004
|
function looseDataValuesToDataValues(values2) {
|
|
34998
|
-
return (0,
|
|
36005
|
+
return (0, import_lodash_es14.mapValues)(values2, (val) => looseDataValueToDataValue(val));
|
|
34999
36006
|
}
|
|
35000
36007
|
function looseDataValueToDataValue(value) {
|
|
35001
36008
|
if (typeof value === "string") {
|
|
@@ -36230,7 +37237,7 @@ var cronNode = nodeDefinition(CronNodeImpl, "Cron");
|
|
|
36230
37237
|
// src/model/nodes/ToTreeNode.ts
|
|
36231
37238
|
var import_non_secure94 = require("nanoid/non-secure");
|
|
36232
37239
|
var import_ts_dedent81 = require("ts-dedent");
|
|
36233
|
-
var
|
|
37240
|
+
var import_lodash_es15 = require("lodash");
|
|
36234
37241
|
var ToTreeNodeImpl = class extends NodeImpl {
|
|
36235
37242
|
static create() {
|
|
36236
37243
|
const chartNode = {
|
|
@@ -36312,36 +37319,33 @@ var ToTreeNodeImpl = class extends NodeImpl {
|
|
|
36312
37319
|
group: ["Text"]
|
|
36313
37320
|
};
|
|
36314
37321
|
}
|
|
36315
|
-
buildTree(objects, parentPath = "", level = 0, isLast = true) {
|
|
37322
|
+
buildTree(objects, parentPath = "", level = 0, isLast = true, interpolationContext) {
|
|
36316
37323
|
if (!Array.isArray(objects) || objects.length === 0) return "";
|
|
36317
37324
|
let result = "";
|
|
36318
|
-
const sortedObjects = this.data.useSortAlphabetically ? (0,
|
|
37325
|
+
const sortedObjects = this.data.useSortAlphabetically ? (0, import_lodash_es15.sortBy)(objects, (obj) => String((0, import_lodash_es15.get)(obj, "path", ""))) : objects;
|
|
36319
37326
|
sortedObjects.forEach((obj, index) => {
|
|
36320
37327
|
const isLastItem = index === sortedObjects.length - 1;
|
|
36321
37328
|
const prefix = level === 0 ? "" : isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
36322
37329
|
const indent = level === 0 ? "" : " ".repeat(level - 1) + (isLast ? " " : "\u2502 ");
|
|
36323
|
-
const
|
|
36324
|
-
|
|
36325
|
-
|
|
36326
|
-
|
|
36327
|
-
|
|
36328
|
-
|
|
36329
|
-
},
|
|
36330
|
-
{}
|
|
37330
|
+
const formattedNode = interpolate(
|
|
37331
|
+
this.data.format,
|
|
37332
|
+
obj != null && typeof obj === "object" ? obj : {},
|
|
37333
|
+
interpolationContext == null ? void 0 : interpolationContext.graphInputNodeValues,
|
|
37334
|
+
interpolationContext == null ? void 0 : interpolationContext.contextValues,
|
|
37335
|
+
{ unwrapVariableDataValues: false }
|
|
36331
37336
|
);
|
|
36332
|
-
const formattedNode = interpolate(this.data.format, interpolationVars);
|
|
36333
37337
|
result += indent + prefix + formattedNode + "\n";
|
|
36334
|
-
const children = (0,
|
|
37338
|
+
const children = (0, import_lodash_es15.get)(obj, this.data.childrenProperty);
|
|
36335
37339
|
if (Array.isArray(children) && children.length > 0) {
|
|
36336
37340
|
const newPath = parentPath ? `${parentPath}/${formattedNode}` : formattedNode;
|
|
36337
|
-
result += this.buildTree(children, newPath, level + 1, isLastItem);
|
|
37341
|
+
result += this.buildTree(children, newPath, level + 1, isLastItem, interpolationContext);
|
|
36338
37342
|
}
|
|
36339
37343
|
});
|
|
36340
37344
|
return result;
|
|
36341
37345
|
}
|
|
36342
|
-
async process(inputs) {
|
|
37346
|
+
async process(inputs, context) {
|
|
36343
37347
|
const objects = coerceTypeOptional(inputs["objects"], "object[]") ?? [];
|
|
36344
|
-
const treeOutput = this.buildTree(objects);
|
|
37348
|
+
const treeOutput = this.buildTree(objects, "", 0, true, context);
|
|
36345
37349
|
return {
|
|
36346
37350
|
["tree"]: {
|
|
36347
37351
|
type: "string",
|
|
@@ -36713,14 +37717,26 @@ async function resolveMCPServer(data, inputs, context) {
|
|
|
36713
37717
|
}
|
|
36714
37718
|
return void 0;
|
|
36715
37719
|
}
|
|
36716
|
-
function interpolateMCPArgumentTemplate(template, inputs) {
|
|
37720
|
+
function interpolateMCPArgumentTemplate(template, inputs, graphInputValues, contextValues) {
|
|
36717
37721
|
const values2 = {};
|
|
36718
37722
|
for (const key of keys(inputs)) {
|
|
36719
|
-
if (key.startsWith("input")) {
|
|
36720
|
-
values2[key.slice("input-".length)] =
|
|
37723
|
+
if (key.startsWith("input-")) {
|
|
37724
|
+
values2[key.slice("input-".length)] = inputs[key];
|
|
36721
37725
|
}
|
|
36722
37726
|
}
|
|
36723
|
-
return interpolate(template, values2
|
|
37727
|
+
return interpolate(template, values2, graphInputValues, contextValues, {
|
|
37728
|
+
coerceBareVariableDataValues: true
|
|
37729
|
+
});
|
|
37730
|
+
}
|
|
37731
|
+
function getMCPArgumentTemplateInputs(template) {
|
|
37732
|
+
return extractInterpolationVariables(template ?? "").map(
|
|
37733
|
+
(interpolationName) => createInterpolationInputDefinition({
|
|
37734
|
+
id: `input-${interpolationName}`,
|
|
37735
|
+
interpolationName,
|
|
37736
|
+
dataType: "any",
|
|
37737
|
+
required: false
|
|
37738
|
+
})
|
|
37739
|
+
);
|
|
36724
37740
|
}
|
|
36725
37741
|
|
|
36726
37742
|
// src/model/nodes/MCPDiscoveryNode.ts
|
|
@@ -36905,6 +37921,8 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
|
|
|
36905
37921
|
id: "toolArguments",
|
|
36906
37922
|
title: "Tool Arguments"
|
|
36907
37923
|
});
|
|
37924
|
+
} else {
|
|
37925
|
+
inputs.push(...getMCPArgumentTemplateInputs(this.data.toolArguments));
|
|
36908
37926
|
}
|
|
36909
37927
|
if (this.data.useToolCallIdInput) {
|
|
36910
37928
|
inputs.push({
|
|
@@ -36946,6 +37964,7 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
|
|
|
36946
37964
|
label: "Tool Arguments",
|
|
36947
37965
|
dataKey: "toolArguments",
|
|
36948
37966
|
language: "json",
|
|
37967
|
+
interpolationSyntax: "json-template",
|
|
36949
37968
|
useInputToggleDataKey: "useToolArgumentsInput",
|
|
36950
37969
|
enableFolding: true
|
|
36951
37970
|
},
|
|
@@ -36983,7 +38002,14 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
|
|
|
36983
38002
|
throw new MCPError("INVALID_SCHEMA" /* INVALID_SCHEMA */, "Cannot parse tool argument with input toggle on");
|
|
36984
38003
|
}
|
|
36985
38004
|
} else {
|
|
36986
|
-
toolArguments = JSON.parse(
|
|
38005
|
+
toolArguments = JSON.parse(
|
|
38006
|
+
interpolateMCPArgumentTemplate(
|
|
38007
|
+
this.data.toolArguments ?? "",
|
|
38008
|
+
inputs,
|
|
38009
|
+
context.graphInputNodeValues,
|
|
38010
|
+
context.contextValues
|
|
38011
|
+
)
|
|
38012
|
+
);
|
|
36987
38013
|
}
|
|
36988
38014
|
const toolCall = {
|
|
36989
38015
|
name: toolName,
|
|
@@ -37067,6 +38093,8 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
|
|
|
37067
38093
|
id: "promptArguments",
|
|
37068
38094
|
title: "Prompt Arguments"
|
|
37069
38095
|
});
|
|
38096
|
+
} else {
|
|
38097
|
+
inputs.push(...getMCPArgumentTemplateInputs(this.data.promptArguments));
|
|
37070
38098
|
}
|
|
37071
38099
|
return inputs;
|
|
37072
38100
|
}
|
|
@@ -37096,6 +38124,7 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
|
|
|
37096
38124
|
dataKey: "promptArguments",
|
|
37097
38125
|
useInputToggleDataKey: "usePromptArgumentsInput",
|
|
37098
38126
|
language: "json",
|
|
38127
|
+
interpolationSyntax: "json-template",
|
|
37099
38128
|
helperMessage: "Arguments to provide the prompt",
|
|
37100
38129
|
enableFolding: true
|
|
37101
38130
|
}
|
|
@@ -37125,7 +38154,14 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
|
|
|
37125
38154
|
throw new MCPError("INVALID_SCHEMA" /* INVALID_SCHEMA */, "Cannot parse tool argument with input toggle on");
|
|
37126
38155
|
}
|
|
37127
38156
|
} else {
|
|
37128
|
-
promptArguments = JSON.parse(
|
|
38157
|
+
promptArguments = JSON.parse(
|
|
38158
|
+
interpolateMCPArgumentTemplate(
|
|
38159
|
+
this.data.promptArguments ?? "",
|
|
38160
|
+
inputs,
|
|
38161
|
+
context.graphInputNodeValues,
|
|
38162
|
+
context.contextValues
|
|
38163
|
+
)
|
|
38164
|
+
);
|
|
37129
38165
|
}
|
|
37130
38166
|
const getPromptRequest = {
|
|
37131
38167
|
name: promptName,
|
|
@@ -37279,29 +38315,17 @@ var ReferencedGraphAliasNodeImpl = class extends NodeImpl {
|
|
|
37279
38315
|
}
|
|
37280
38316
|
const boundary = ((_a = context.getGraphBoundary) == null ? void 0 : _a.call(context, referencedProject, this.data.graphId)) ?? getGraphBoundary(referencedProject, this.data.graphId);
|
|
37281
38317
|
const inputData = buildGraphBoundaryInputData(boundary, inputs, this.data.inputData);
|
|
37282
|
-
const shouldRunWholeGraph = !GRAPH_BOUNDARY_OUTPUT_DEMAND_OPTIMIZATION_ENABLED || context.isDirectRunTarget || this.data.useErrorOutput === true && context.activeOutputPortIds.has("error");
|
|
37283
|
-
const requestedGraphOutputNodeIds = shouldRunWholeGraph ? [] : getRequestedGraphOutputNodeIds(boundary, context.activeOutputPortIds);
|
|
37284
|
-
if (!shouldRunWholeGraph && requestedGraphOutputNodeIds.length === 0) {
|
|
37285
|
-
return buildSkippedReferencedGraphOutputs(boundary, this.data.useErrorOutput, this.data.outputCostDuration);
|
|
37286
|
-
}
|
|
37287
38318
|
const subGraphProcessor = context.createSubProcessor(this.data.graphId, {
|
|
37288
38319
|
signal: context.signal,
|
|
37289
38320
|
project: referencedProject
|
|
37290
38321
|
});
|
|
37291
|
-
if (!shouldRunWholeGraph) {
|
|
37292
|
-
subGraphProcessor.runToNodeIds = requestedGraphOutputNodeIds;
|
|
37293
|
-
}
|
|
37294
38322
|
try {
|
|
37295
38323
|
const startTime = Date.now();
|
|
37296
|
-
const
|
|
38324
|
+
const outputs = await subGraphProcessor.processGraph(
|
|
37297
38325
|
context,
|
|
37298
38326
|
inputData,
|
|
37299
38327
|
context.contextValues
|
|
37300
38328
|
);
|
|
37301
|
-
const outputs = shouldRunWholeGraph ? graphOutputs : {
|
|
37302
|
-
...buildExcludedGraphBoundaryOutputs(boundary),
|
|
37303
|
-
...graphOutputs
|
|
37304
|
-
};
|
|
37305
38329
|
const duration = Date.now() - startTime;
|
|
37306
38330
|
if (this.data.useErrorOutput) {
|
|
37307
38331
|
outputs["error"] = {
|
|
@@ -37330,26 +38354,6 @@ var ReferencedGraphAliasNodeImpl = class extends NodeImpl {
|
|
|
37330
38354
|
}
|
|
37331
38355
|
};
|
|
37332
38356
|
var referencedGraphAliasNode = nodeDefinition(ReferencedGraphAliasNodeImpl, "Referenced Graph Alias");
|
|
37333
|
-
function buildSkippedReferencedGraphOutputs(boundary, useErrorOutput, outputCostDuration) {
|
|
37334
|
-
const outputs = buildExcludedGraphBoundaryOutputs(boundary);
|
|
37335
|
-
if (useErrorOutput) {
|
|
37336
|
-
outputs["error"] = {
|
|
37337
|
-
type: "control-flow-excluded",
|
|
37338
|
-
value: void 0
|
|
37339
|
-
};
|
|
37340
|
-
}
|
|
37341
|
-
if (outputCostDuration) {
|
|
37342
|
-
outputs["cost"] = {
|
|
37343
|
-
type: "number",
|
|
37344
|
-
value: 0
|
|
37345
|
-
};
|
|
37346
|
-
outputs["duration"] = {
|
|
37347
|
-
type: "number",
|
|
37348
|
-
value: 0
|
|
37349
|
-
};
|
|
37350
|
-
}
|
|
37351
|
-
return applyMetricOutputSetting(outputs, outputCostDuration);
|
|
37352
|
-
}
|
|
37353
38357
|
function applyMetricOutputSetting(outputs, outputCostDuration) {
|
|
37354
38358
|
if (outputCostDuration) {
|
|
37355
38359
|
return outputs;
|
|
@@ -38082,7 +39086,7 @@ function isRecord9(value) {
|
|
|
38082
39086
|
// src/recording/ExecutionRecorder.ts
|
|
38083
39087
|
var import_non_secure100 = require("nanoid/non-secure");
|
|
38084
39088
|
var import_emittery2 = __toESM(require("emittery-0-13"), 1);
|
|
38085
|
-
var
|
|
39089
|
+
var import_lodash_es16 = require("lodash");
|
|
38086
39090
|
var import_json_stream_es = require("json-stream-es");
|
|
38087
39091
|
|
|
38088
39092
|
// src/vendor/fnv1a.js
|
|
@@ -38190,12 +39194,14 @@ var toRecordedEventMap = {
|
|
|
38190
39194
|
),
|
|
38191
39195
|
execution
|
|
38192
39196
|
),
|
|
38193
|
-
nodeError: ({ node, error, processId, resultOrigin, durationMs, splitRunDurationMs, execution }) => withExecution(
|
|
39197
|
+
nodeError: ({ node, error, processId, outputs, splitOutputs, resultOrigin, durationMs, splitRunDurationMs, execution }) => withExecution(
|
|
38194
39198
|
withDuration(
|
|
38195
39199
|
{
|
|
38196
39200
|
nodeId: node.id,
|
|
38197
39201
|
error: typeof error === "string" ? error : error.stack,
|
|
38198
39202
|
processId,
|
|
39203
|
+
...outputs === void 0 ? {} : { outputs },
|
|
39204
|
+
...splitOutputs === void 0 ? {} : { splitOutputs },
|
|
38199
39205
|
...resultOrigin === void 0 ? {} : { resultOrigin }
|
|
38200
39206
|
},
|
|
38201
39207
|
durationMs,
|
|
@@ -38203,7 +39209,14 @@ var toRecordedEventMap = {
|
|
|
38203
39209
|
),
|
|
38204
39210
|
execution
|
|
38205
39211
|
),
|
|
38206
|
-
|
|
39212
|
+
// Older debugger servers sent a null abort payload. Preserve that evidence
|
|
39213
|
+
// instead of letting a malformed legacy transport message abort the whole
|
|
39214
|
+
// recording. An unknown payload is deliberately treated as unsuccessful;
|
|
39215
|
+
// it must never be mistaken for a completed graph run during replay.
|
|
39216
|
+
abort: (data) => {
|
|
39217
|
+
const { successful, error } = data ?? {};
|
|
39218
|
+
return { successful: successful === true, error: typeof error === "string" ? error : error == null ? void 0 : error.stack };
|
|
39219
|
+
},
|
|
38207
39220
|
graphAbort: ({ successful, error, graph, execution }) => withExecution(
|
|
38208
39221
|
{
|
|
38209
39222
|
successful,
|
|
@@ -38316,19 +39329,20 @@ function omitReplayRecordedAt(data) {
|
|
|
38316
39329
|
function isRecordableProcessEvent(message) {
|
|
38317
39330
|
return message in toRecordedEventMap || isPrefix(message, "globalSet:") || isPrefix(message, "userEvent:");
|
|
38318
39331
|
}
|
|
39332
|
+
var CLOSED_WEBSOCKET_READY_STATE = 3;
|
|
38319
39333
|
function mapValuesDeep(obj, fn) {
|
|
38320
39334
|
if (Array.isArray(obj)) {
|
|
38321
39335
|
return obj.map((value) => {
|
|
38322
|
-
if ((0,
|
|
39336
|
+
if ((0, import_lodash_es16.isPlainObject)(value) || Array.isArray(value)) {
|
|
38323
39337
|
return mapValuesDeep(value, fn);
|
|
38324
39338
|
}
|
|
38325
39339
|
return fn(value);
|
|
38326
39340
|
});
|
|
38327
39341
|
}
|
|
38328
|
-
if ((0,
|
|
39342
|
+
if ((0, import_lodash_es16.isPlainObject)(obj)) {
|
|
38329
39343
|
return Object.fromEntries(
|
|
38330
39344
|
Object.entries(obj).map(([key, value]) => {
|
|
38331
|
-
if ((0,
|
|
39345
|
+
if ((0, import_lodash_es16.isPlainObject)(value) || Array.isArray(value)) {
|
|
38332
39346
|
return [key, mapValuesDeep(value, fn)];
|
|
38333
39347
|
}
|
|
38334
39348
|
return [key, fn(value)];
|
|
@@ -38411,14 +39425,22 @@ var ExecutionRecorder = class _ExecutionRecorder {
|
|
|
38411
39425
|
var _a, _b;
|
|
38412
39426
|
this.recordingId = (0, import_non_secure100.nanoid)();
|
|
38413
39427
|
let settled = false;
|
|
38414
|
-
const finish = () => {
|
|
39428
|
+
const finish = (emitFinishedRecording) => {
|
|
38415
39429
|
var _a2;
|
|
38416
39430
|
if (settled) return;
|
|
38417
39431
|
settled = true;
|
|
38418
39432
|
channel.removeEventListener("message", listener);
|
|
38419
|
-
|
|
39433
|
+
channel.removeEventListener("close", onClose);
|
|
39434
|
+
(_a2 = options2.signal) == null ? void 0 : _a2.removeEventListener("abort", onOwnerDisposed);
|
|
39435
|
+
if (emitFinishedRecording) {
|
|
39436
|
+
emitDetached(this.#emitter, "finish", {
|
|
39437
|
+
recording: this.getRecording()
|
|
39438
|
+
});
|
|
39439
|
+
}
|
|
38420
39440
|
resolve();
|
|
38421
39441
|
};
|
|
39442
|
+
const onClose = () => finish(false);
|
|
39443
|
+
const onOwnerDisposed = () => finish(false);
|
|
38422
39444
|
const listener = (event) => {
|
|
38423
39445
|
let payload;
|
|
38424
39446
|
try {
|
|
@@ -38440,24 +39462,38 @@ var ExecutionRecorder = class _ExecutionRecorder {
|
|
|
38440
39462
|
return;
|
|
38441
39463
|
}
|
|
38442
39464
|
this.#events.push(toRecordedEvent(message, data));
|
|
38443
|
-
if (
|
|
38444
|
-
|
|
38445
|
-
recording: this.getRecording()
|
|
38446
|
-
});
|
|
38447
|
-
finish();
|
|
39465
|
+
if (isSocketRecordingTerminalEvent(message)) {
|
|
39466
|
+
finish(true);
|
|
38448
39467
|
}
|
|
38449
39468
|
};
|
|
38450
39469
|
if ((_a = options2.signal) == null ? void 0 : _a.aborted) {
|
|
38451
|
-
|
|
39470
|
+
onOwnerDisposed();
|
|
38452
39471
|
return;
|
|
38453
39472
|
}
|
|
38454
39473
|
channel.addEventListener("message", listener);
|
|
38455
|
-
|
|
39474
|
+
channel.addEventListener("close", onClose, { once: true });
|
|
39475
|
+
(_b = options2.signal) == null ? void 0 : _b.addEventListener("abort", onOwnerDisposed, { once: true });
|
|
39476
|
+
if (channel.readyState === CLOSED_WEBSOCKET_READY_STATE) {
|
|
39477
|
+
onClose();
|
|
39478
|
+
}
|
|
38456
39479
|
});
|
|
38457
39480
|
}
|
|
38458
39481
|
record(processor) {
|
|
38459
39482
|
this.recordingId = (0, import_non_secure100.nanoid)();
|
|
38460
|
-
|
|
39483
|
+
let settled = false;
|
|
39484
|
+
const finish = () => {
|
|
39485
|
+
if (settled) return;
|
|
39486
|
+
settled = true;
|
|
39487
|
+
unsubscribeAny();
|
|
39488
|
+
unsubscribeFinish();
|
|
39489
|
+
emitDetached(this.#emitter, "finish", {
|
|
39490
|
+
recording: this.getRecording()
|
|
39491
|
+
});
|
|
39492
|
+
};
|
|
39493
|
+
const unsubscribeAny = processor.onAny((event, data) => {
|
|
39494
|
+
if (settled || event === "finish") {
|
|
39495
|
+
return;
|
|
39496
|
+
}
|
|
38461
39497
|
if (this.#includePartialOutputs === false && event === "partialOutput") {
|
|
38462
39498
|
return;
|
|
38463
39499
|
}
|
|
@@ -38465,18 +39501,17 @@ var ExecutionRecorder = class _ExecutionRecorder {
|
|
|
38465
39501
|
return;
|
|
38466
39502
|
}
|
|
38467
39503
|
this.#events.push(toRecordedEvent(event, data));
|
|
38468
|
-
if (isRecordingTerminalEvent(event, data)) {
|
|
38469
|
-
emitDetached(this.#emitter, "finish", {
|
|
38470
|
-
recording: this.getRecording()
|
|
38471
|
-
});
|
|
38472
|
-
}
|
|
38473
39504
|
});
|
|
39505
|
+
const unsubscribeFinish = processor.on("finish", finish);
|
|
38474
39506
|
}
|
|
38475
39507
|
getRecording() {
|
|
38476
39508
|
var _a, _b;
|
|
38477
39509
|
return {
|
|
38478
39510
|
recordingId: this.recordingId,
|
|
38479
|
-
|
|
39511
|
+
// Callers persist and replay recordings asynchronously. Returning the
|
|
39512
|
+
// live backing array would let a later event mutate an already-finished
|
|
39513
|
+
// recording snapshot.
|
|
39514
|
+
events: [...this.#events],
|
|
38480
39515
|
startTs: ((_a = this.#events[0]) == null ? void 0 : _a.ts) ?? 0,
|
|
38481
39516
|
finishTs: ((_b = this.#events[this.#events.length - 1]) == null ? void 0 : _b.ts) ?? 0
|
|
38482
39517
|
};
|
|
@@ -38510,11 +39545,8 @@ var ExecutionRecorder = class _ExecutionRecorder {
|
|
|
38510
39545
|
return (0, import_json_stream_es.stringifyJsonStream)(serializeToObject(this.getRecording()));
|
|
38511
39546
|
}
|
|
38512
39547
|
};
|
|
38513
|
-
function
|
|
38514
|
-
|
|
38515
|
-
return true;
|
|
38516
|
-
}
|
|
38517
|
-
return event === "abort" && data.successful !== true;
|
|
39548
|
+
function isSocketRecordingTerminalEvent(event) {
|
|
39549
|
+
return event === "done" || event === "error";
|
|
38518
39550
|
}
|
|
38519
39551
|
|
|
38520
39552
|
// src/plugins/anthropic/nodes/ChatAnthropicNode.ts
|
|
@@ -43887,7 +44919,6 @@ ${additional.join("\n")}`;
|
|
|
43887
44919
|
var runThreadNode = pluginNodeDefinition(RunThreadNodeImpl, "Run Thread");
|
|
43888
44920
|
|
|
43889
44921
|
// src/plugins/openai/nodes/ThreadMessageNode.ts
|
|
43890
|
-
var import_lodash_es18 = require("lodash");
|
|
43891
44922
|
var ThreadMessageNodeImpl = {
|
|
43892
44923
|
create() {
|
|
43893
44924
|
return {
|
|
@@ -43940,16 +44971,17 @@ var ThreadMessageNodeImpl = {
|
|
|
43940
44971
|
required: false
|
|
43941
44972
|
});
|
|
43942
44973
|
}
|
|
43943
|
-
const
|
|
44974
|
+
const inputReferences = extractInterpolationVariableReferences(data.text);
|
|
44975
|
+
const fixedInputIds = new Set(inputs.map((input) => input.id));
|
|
43944
44976
|
inputs = [
|
|
43945
44977
|
...inputs,
|
|
43946
|
-
...(
|
|
44978
|
+
...inputReferences.filter(({ baseName }) => !fixedInputIds.has(baseName)).map(({ baseName, hasPath }) => {
|
|
43947
44979
|
return createInterpolationInputDefinition({
|
|
43948
|
-
interpolationName:
|
|
43949
|
-
dataType: "string",
|
|
44980
|
+
interpolationName: baseName,
|
|
44981
|
+
dataType: hasPath ? "any" : "string",
|
|
43950
44982
|
required: false
|
|
43951
44983
|
});
|
|
43952
|
-
})
|
|
44984
|
+
})
|
|
43953
44985
|
];
|
|
43954
44986
|
return inputs;
|
|
43955
44987
|
},
|
|
@@ -43997,7 +45029,7 @@ var ThreadMessageNodeImpl = {
|
|
|
43997
45029
|
theme: "prompt-interpolation"
|
|
43998
45030
|
};
|
|
43999
45031
|
},
|
|
44000
|
-
async process(data, inputData) {
|
|
45032
|
+
async process(data, inputData, context) {
|
|
44001
45033
|
const text = getInputOrData(data, inputData, "text", "string");
|
|
44002
45034
|
const fileIds = getInputOrData(data, inputData, "fileIds", "string[]") ?? [];
|
|
44003
45035
|
let metadata = data.metadata.reduce(
|
|
@@ -44010,8 +45042,9 @@ var ThreadMessageNodeImpl = {
|
|
|
44010
45042
|
if (data.useMetadataInput && inputData["metadata"]) {
|
|
44011
45043
|
metadata = coerceTypeOptional(inputData["metadata"], "object");
|
|
44012
45044
|
}
|
|
44013
|
-
const
|
|
44014
|
-
|
|
45045
|
+
const interpolated = interpolate(text, inputData, context == null ? void 0 : context.graphInputNodeValues, context == null ? void 0 : context.contextValues, {
|
|
45046
|
+
coerceBareVariableDataValues: true
|
|
45047
|
+
});
|
|
44015
45048
|
return {
|
|
44016
45049
|
["message"]: {
|
|
44017
45050
|
type: "object",
|
|
@@ -44063,7 +45096,7 @@ var import_ts_dedent93 = require("ts-dedent");
|
|
|
44063
45096
|
var import_p_retry3 = __toESM(require("p-retry-4"), 1);
|
|
44064
45097
|
var import_ts_pattern8 = require("ts-pattern");
|
|
44065
45098
|
var import_genai2 = require("@google/genai");
|
|
44066
|
-
var
|
|
45099
|
+
var import_lodash_es17 = require("lodash");
|
|
44067
45100
|
function toGoogleSchemaType(type) {
|
|
44068
45101
|
switch (type) {
|
|
44069
45102
|
case "string":
|
|
@@ -44434,7 +45467,7 @@ var ChatGoogleNodeImpl = {
|
|
|
44434
45467
|
description: tool.description,
|
|
44435
45468
|
parameters: Object.keys(parameters.properties ?? {}).length === 0 ? void 0 : {
|
|
44436
45469
|
type: import_genai2.Type.OBJECT,
|
|
44437
|
-
properties: (0,
|
|
45470
|
+
properties: (0, import_lodash_es17.mapValues)(parameters.properties ?? {}, (property) => ({
|
|
44438
45471
|
// gemini doesn't support union property types, it uses openapi style not jsonschema, what a mess
|
|
44439
45472
|
type: toGoogleSchemaType(
|
|
44440
45473
|
Array.isArray(property.type) ? property.type.find((type) => type !== "null") : property.type
|
|
@@ -44728,7 +45761,7 @@ async function assembleRegistry(specs, loadPlugin) {
|
|
|
44728
45761
|
}
|
|
44729
45762
|
|
|
44730
45763
|
// src/integrations/DatasetProvider.ts
|
|
44731
|
-
var
|
|
45764
|
+
var import_lodash_es18 = require("lodash");
|
|
44732
45765
|
var InMemoryDatasetProvider = class {
|
|
44733
45766
|
#datasets;
|
|
44734
45767
|
constructor(datasets) {
|
|
@@ -44808,7 +45841,7 @@ var InMemoryDatasetProvider = class {
|
|
|
44808
45841
|
return sorted.slice(0, k).map((r) => ({ ...r.row, distance: r.similarity }));
|
|
44809
45842
|
}
|
|
44810
45843
|
async exportDatasetsForProject(_projectId) {
|
|
44811
|
-
return (0,
|
|
45844
|
+
return (0, import_lodash_es18.cloneDeep)(this.#datasets);
|
|
44812
45845
|
}
|
|
44813
45846
|
};
|
|
44814
45847
|
var dotProductSimilarity = (a, b) => {
|
|
@@ -45482,6 +46515,7 @@ var Rivet = void 0;
|
|
|
45482
46515
|
doubleCheckProject,
|
|
45483
46516
|
emptyNodeGraph,
|
|
45484
46517
|
encodeRivetWebAppStorageBinaryFrame,
|
|
46518
|
+
evaluateJsonPath,
|
|
45485
46519
|
evaluateNode,
|
|
45486
46520
|
executeLLMInvocation,
|
|
45487
46521
|
expectType,
|
|
@@ -45489,6 +46523,7 @@ var Rivet = void 0;
|
|
|
45489
46523
|
exportGentraceEvaluationRun,
|
|
45490
46524
|
expressionNode,
|
|
45491
46525
|
externalCallNode,
|
|
46526
|
+
extractInterpolationVariableReferences,
|
|
45492
46527
|
extractInterpolationVariables,
|
|
45493
46528
|
extractJsonNode,
|
|
45494
46529
|
extractMarkdownCodeBlocksNode,
|
|
@@ -45540,6 +46575,7 @@ var Rivet = void 0;
|
|
|
45540
46575
|
getIntegration,
|
|
45541
46576
|
getInterpolationInputDefinitionData,
|
|
45542
46577
|
getInterpolationTokenName,
|
|
46578
|
+
getInterpolationTokenReference,
|
|
45543
46579
|
getKnowledgeSourceStatusNode,
|
|
45544
46580
|
getKnowledgeStoreProvider,
|
|
45545
46581
|
getKnowledgeStoreProviders,
|
|
@@ -45558,6 +46594,7 @@ var Rivet = void 0;
|
|
|
45558
46594
|
getScalarTypeOf,
|
|
45559
46595
|
getSingleNodeStream,
|
|
45560
46596
|
getStoredValueNode,
|
|
46597
|
+
getToolNodeBodyPreview,
|
|
45561
46598
|
getUiGraphActionComponent,
|
|
45562
46599
|
getUiGraphActionInputBindings,
|
|
45563
46600
|
getUiGraphActionOutputBindings,
|
|
@@ -45622,6 +46659,8 @@ var Rivet = void 0;
|
|
|
45622
46659
|
isFunctionDataType,
|
|
45623
46660
|
isFunctionDataValue,
|
|
45624
46661
|
isInterpolationInputDefinition,
|
|
46662
|
+
isInterpolationRegexLiteralStart,
|
|
46663
|
+
isInterpolationSyntaxCharacterEscaped,
|
|
45625
46664
|
isKnowledgeDocument,
|
|
45626
46665
|
isKnowledgeEvidence,
|
|
45627
46666
|
isKnowledgeSourceReference,
|
|
@@ -45672,6 +46711,7 @@ var Rivet = void 0;
|
|
|
45672
46711
|
normalizeChatV2CredentialNames,
|
|
45673
46712
|
normalizeChatV2CredentialNamesByProvider,
|
|
45674
46713
|
normalizeGraphProgress,
|
|
46714
|
+
normalizeJsonPathExpression,
|
|
45675
46715
|
normalizeKnowledgeConnectionId,
|
|
45676
46716
|
normalizeKnowledgeDocument,
|
|
45677
46717
|
normalizeKnowledgeEvidence,
|
|
@@ -45705,6 +46745,8 @@ var Rivet = void 0;
|
|
|
45705
46745
|
parseChatV2Provider,
|
|
45706
46746
|
parseCustomProviderApi,
|
|
45707
46747
|
parseDataBusChannelIndex,
|
|
46748
|
+
parseInterpolationExpression,
|
|
46749
|
+
parseInterpolationTemplate,
|
|
45708
46750
|
parseProviderJsonChunk,
|
|
45709
46751
|
parseRivetWebAppBrowserStorageClientMessage,
|
|
45710
46752
|
parseRivetWebAppBrowserStorageServerMessage,
|
|
@@ -45748,6 +46790,9 @@ var Rivet = void 0;
|
|
|
45748
46790
|
resolveChatV2Credential,
|
|
45749
46791
|
resolveChatV2ProviderConfig,
|
|
45750
46792
|
resolveChatV2ResponseFormatParameters,
|
|
46793
|
+
resolveCodeInterpolationExpression,
|
|
46794
|
+
resolveInterpolationExpressionRawValue,
|
|
46795
|
+
resolveInterpolationTokenRawValue,
|
|
45751
46796
|
resolveLLMChatV2RuntimeProviderOptions,
|
|
45752
46797
|
resolveNodePrefabInstance,
|
|
45753
46798
|
resolveNodePrefabInstances,
|
|
@@ -45770,6 +46815,7 @@ var Rivet = void 0;
|
|
|
45770
46815
|
sanitizeIdentifierPortValue,
|
|
45771
46816
|
scalarDefaults,
|
|
45772
46817
|
scalarTypes,
|
|
46818
|
+
scanInterpolationTokenSpans,
|
|
45773
46819
|
searchKnowledgeNode,
|
|
45774
46820
|
serializeDatasets,
|
|
45775
46821
|
serializeGraph,
|
|
@@ -45787,6 +46833,7 @@ var Rivet = void 0;
|
|
|
45787
46833
|
splitRivetWebAppStorageTransfer,
|
|
45788
46834
|
startBackgroundBranchNode,
|
|
45789
46835
|
streamChatV2,
|
|
46836
|
+
stringifyInterpolationSourceValue,
|
|
45790
46837
|
stringifyToolResult,
|
|
45791
46838
|
stringifyUiGraphValue,
|
|
45792
46839
|
subGraphNode,
|