@valerypopoff/rivet2-core 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bundle.cjs +1430 -669
- 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/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 +136 -44
- package/dist/esm/model/ProcessContextBuilder.js +2 -0
- package/dist/esm/model/RecordingPlayer.js +11 -6
- package/dist/esm/model/StoredValueStore.js +4 -3
- 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/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/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/GraphBoundaryCache.d.ts +0 -2
- package/dist/types/model/GraphOutputSelection.d.ts +8 -0
- package/dist/types/model/GraphProcessor.d.ts +4 -3
- package/dist/types/model/ProcessContext.d.ts +3 -2
- 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/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;
|
|
@@ -6502,7 +6881,6 @@ async function replayExecutionRecording(options2) {
|
|
|
6502
6881
|
const {
|
|
6503
6882
|
emitter,
|
|
6504
6883
|
erroredNodes,
|
|
6505
|
-
graphOutputs,
|
|
6506
6884
|
fallbackGraphId,
|
|
6507
6885
|
initialReplayExecution,
|
|
6508
6886
|
project,
|
|
@@ -6517,6 +6895,7 @@ async function replayExecutionRecording(options2) {
|
|
|
6517
6895
|
nodeResults,
|
|
6518
6896
|
isAborted
|
|
6519
6897
|
} = options2;
|
|
6898
|
+
let graphOutputs = options2.graphOutputs;
|
|
6520
6899
|
const nodesByIdAllGraphs = {};
|
|
6521
6900
|
const graphIdByNodeId = {};
|
|
6522
6901
|
for (const graph of Object.values(project.graphs)) {
|
|
@@ -6625,13 +7004,13 @@ async function replayExecutionRecording(options2) {
|
|
|
6625
7004
|
replayRootRunId = replayRootRunIds.size === 0 && initialReplayExecution ? initialReplayExecution.rootRunId : (0, import_non_secure4.nanoid)();
|
|
6626
7005
|
replayRootRunIds.set(recordedExecution.rootRunId, replayRootRunId);
|
|
6627
7006
|
}
|
|
6628
|
-
const getReplayGraphRunId = (recordedGraphRunId) => {
|
|
7007
|
+
const getReplayGraphRunId = (recordedGraphRunId, initialGraphRunId) => {
|
|
6629
7008
|
let graphRunIds = replayGraphRunIdsByRoot.get(recordedExecution.rootRunId);
|
|
6630
7009
|
if (graphRunIds == null) {
|
|
6631
7010
|
graphRunIds = /* @__PURE__ */ new Map();
|
|
6632
7011
|
replayGraphRunIdsByRoot.set(recordedExecution.rootRunId, graphRunIds);
|
|
6633
7012
|
}
|
|
6634
|
-
const replayGraphRunId = graphRunIds.get(recordedGraphRunId) ?? (0, import_non_secure4.nanoid)();
|
|
7013
|
+
const replayGraphRunId = initialGraphRunId ?? graphRunIds.get(recordedGraphRunId) ?? (0, import_non_secure4.nanoid)();
|
|
6635
7014
|
graphRunIds.set(recordedGraphRunId, replayGraphRunId);
|
|
6636
7015
|
return replayGraphRunId;
|
|
6637
7016
|
};
|
|
@@ -6640,7 +7019,12 @@ async function replayExecutionRecording(options2) {
|
|
|
6640
7019
|
return {
|
|
6641
7020
|
...rest,
|
|
6642
7021
|
rootRunId: replayRootRunId,
|
|
6643
|
-
|
|
7022
|
+
// Seed the root mapping too, so child parentGraphRunId references resolve
|
|
7023
|
+
// to the same identity already allocated by the playback processor.
|
|
7024
|
+
graphRunId: getReplayGraphRunId(
|
|
7025
|
+
graphRunId,
|
|
7026
|
+
isInitialRootGraph ? initialReplayExecution.graphRunId : void 0
|
|
7027
|
+
),
|
|
6644
7028
|
...parentGraphRunId == null ? {} : { parentGraphRunId: getReplayGraphRunId(parentGraphRunId) }
|
|
6645
7029
|
};
|
|
6646
7030
|
};
|
|
@@ -6688,8 +7072,8 @@ async function replayExecutionRecording(options2) {
|
|
|
6688
7072
|
case "done": {
|
|
6689
7073
|
emitFallbackRootTerminal("completed", { outputs: event.data.results });
|
|
6690
7074
|
emitReplayTerminalEvent("done", event.data);
|
|
6691
|
-
|
|
6692
|
-
|
|
7075
|
+
graphOutputs = event.data.results;
|
|
7076
|
+
setGraphOutputs(graphOutputs);
|
|
6693
7077
|
break;
|
|
6694
7078
|
}
|
|
6695
7079
|
case "error": {
|
|
@@ -7001,6 +7385,8 @@ function buildNodeProcessContext(options2) {
|
|
|
7001
7385
|
isDirectRunTarget,
|
|
7002
7386
|
markResultAsEditorCacheHit,
|
|
7003
7387
|
waitEvent,
|
|
7388
|
+
waitForGlobal: (id, signal = nodeAbortController.signal) => base.waitForGlobal(id, signal),
|
|
7389
|
+
waitForStoredValue: (key, signal = nodeAbortController.signal) => base.waitForStoredValue(key, signal),
|
|
7004
7390
|
externalFunctions: { ...externalFunctions },
|
|
7005
7391
|
onPartialOutputs,
|
|
7006
7392
|
signal: nodeAbortController.signal,
|
|
@@ -7741,9 +8127,9 @@ var RivetStoredValueController = class {
|
|
|
7741
8127
|
}
|
|
7742
8128
|
});
|
|
7743
8129
|
});
|
|
8130
|
+
const value = waiterPromise === void 0 ? immediateValue : await waiterPromise;
|
|
7744
8131
|
signal == null ? void 0 : signal.throwIfAborted();
|
|
7745
|
-
|
|
7746
|
-
return await waiterPromise;
|
|
8132
|
+
return value;
|
|
7747
8133
|
}
|
|
7748
8134
|
async #getUnlocked(key) {
|
|
7749
8135
|
var _a;
|
|
@@ -7937,67 +8323,6 @@ function createExcludedNodeOutputs(node, outputDefinitions) {
|
|
|
7937
8323
|
return outputs;
|
|
7938
8324
|
}
|
|
7939
8325
|
|
|
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
8326
|
// src/model/nodes/toolCallDelegation.ts
|
|
8002
8327
|
var import_lodash_es4 = require("lodash");
|
|
8003
8328
|
|
|
@@ -9180,6 +9505,495 @@ var ConnectedToolContinuationHost = class {
|
|
|
9180
9505
|
}
|
|
9181
9506
|
};
|
|
9182
9507
|
|
|
9508
|
+
// src/utils/interpolation.ts
|
|
9509
|
+
var ESCAPED_TOKEN_REGEX = /\{\{\{([^}]+?)\}\}\}/g;
|
|
9510
|
+
var ESCAPED_ESCAPED_TOKEN_REGEX = /\\\{\\\{([^}]+?)\\\}\\\}/g;
|
|
9511
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_ENTRIES = 2048;
|
|
9512
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_LENGTH = 64 * 1024;
|
|
9513
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_CHARS = 1024 * 1024;
|
|
9514
|
+
var INTERPOLATION_TEMPLATE_CACHE_MAX_STORAGE_CHARS = 2 * 1024 * 1024;
|
|
9515
|
+
var INTERPOLATION_EXPRESSION_CACHE_MAX_ENTRIES = 512;
|
|
9516
|
+
var INTERPOLATION_EXPRESSION_CACHE_MAX_EXPRESSION_LENGTH = 4 * 1024;
|
|
9517
|
+
var INTERPOLATION_EXPRESSION_CACHE_MAX_CHARS = 128 * 1024;
|
|
9518
|
+
var interpolationTemplateCache = /* @__PURE__ */ new Map();
|
|
9519
|
+
var cachedInterpolationTemplateChars = 0;
|
|
9520
|
+
var cachedInterpolationTemplateStorageChars = 0;
|
|
9521
|
+
var lastUncachedInterpolationTemplate;
|
|
9522
|
+
var interpolationExpressionCache = /* @__PURE__ */ new Map();
|
|
9523
|
+
var cachedInterpolationExpressionChars = 0;
|
|
9524
|
+
var dataValueTypeSet = new Set(dataTypes);
|
|
9525
|
+
var processingFunctions = {
|
|
9526
|
+
indent: (input, spaces = 0) => {
|
|
9527
|
+
const indent = " ".repeat(spaces);
|
|
9528
|
+
return input.split("\n").map((line) => `${indent}${line}`).join("\n");
|
|
9529
|
+
},
|
|
9530
|
+
quote: (input, level = 1) => {
|
|
9531
|
+
const quotePrefix = "> ".repeat(level);
|
|
9532
|
+
return input.split("\n").map((line) => `${quotePrefix}${line}`).join("\n");
|
|
9533
|
+
},
|
|
9534
|
+
uppercase: (input) => input.toUpperCase(),
|
|
9535
|
+
lowercase: (input) => input.toLowerCase(),
|
|
9536
|
+
trim: (input) => input.trim(),
|
|
9537
|
+
truncate: (input, length = 50) => {
|
|
9538
|
+
if (input.length <= length) return input;
|
|
9539
|
+
return input.slice(0, length) + "...";
|
|
9540
|
+
},
|
|
9541
|
+
list: (input, level = 1) => {
|
|
9542
|
+
const indent = " ".repeat(level - 1);
|
|
9543
|
+
return input.split("\n").map((line) => `${indent}- ${line}`).join("\n");
|
|
9544
|
+
},
|
|
9545
|
+
sort: (input) => input.split("\n").sort().join("\n"),
|
|
9546
|
+
dedent: (input) => (0, import_ts_dedent.dedent)(input),
|
|
9547
|
+
wrap: (input, width = 80) => {
|
|
9548
|
+
const words = input.split(/\s+/);
|
|
9549
|
+
const lines = [];
|
|
9550
|
+
let currentLine = "";
|
|
9551
|
+
for (const word of words) {
|
|
9552
|
+
if (currentLine.length + word.length + 1 <= width) {
|
|
9553
|
+
currentLine += (currentLine ? " " : "") + word;
|
|
9554
|
+
} else {
|
|
9555
|
+
lines.push(currentLine);
|
|
9556
|
+
currentLine = word;
|
|
9557
|
+
}
|
|
9558
|
+
}
|
|
9559
|
+
if (currentLine) {
|
|
9560
|
+
lines.push(currentLine);
|
|
9561
|
+
}
|
|
9562
|
+
return lines.join("\n");
|
|
9563
|
+
}
|
|
9564
|
+
};
|
|
9565
|
+
function unwrapPotentialDataValue(value) {
|
|
9566
|
+
if (isRivetDataValue(value)) {
|
|
9567
|
+
return value.value;
|
|
9568
|
+
}
|
|
9569
|
+
return value;
|
|
9570
|
+
}
|
|
9571
|
+
function isRivetDataValue(value) {
|
|
9572
|
+
return typeof value === "object" && value !== null && typeof value.type === "string" && dataValueTypeSet.has(value.type) && Object.prototype.hasOwnProperty.call(value, "value");
|
|
9573
|
+
}
|
|
9574
|
+
function stringifyInterpolationSourceValue(value, {
|
|
9575
|
+
coerceDataValueToString = false,
|
|
9576
|
+
unwrapDataValue: unwrapDataValue2 = true
|
|
9577
|
+
} = {}) {
|
|
9578
|
+
try {
|
|
9579
|
+
if (coerceDataValueToString && unwrapDataValue2 && isRivetDataValue(value)) {
|
|
9580
|
+
return coerceTypeOptional(value, "string") ?? "";
|
|
9581
|
+
}
|
|
9582
|
+
return String((unwrapDataValue2 ? unwrapPotentialDataValue(value) : value) ?? "");
|
|
9583
|
+
} catch {
|
|
9584
|
+
return "[object Object]";
|
|
9585
|
+
}
|
|
9586
|
+
}
|
|
9587
|
+
function findTopLevelProcessorSeparator(rawInner) {
|
|
9588
|
+
let quote;
|
|
9589
|
+
let regex = false;
|
|
9590
|
+
let regexCharacterClass = false;
|
|
9591
|
+
let bracketDepth = 0;
|
|
9592
|
+
let parenthesisDepth = 0;
|
|
9593
|
+
let braceDepth = 0;
|
|
9594
|
+
for (let cursor = 0; cursor < rawInner.length; cursor++) {
|
|
9595
|
+
const character = rawInner[cursor];
|
|
9596
|
+
if (regex) {
|
|
9597
|
+
if (character === "[" && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9598
|
+
regexCharacterClass = true;
|
|
9599
|
+
} else if (character === "]" && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9600
|
+
regexCharacterClass = false;
|
|
9601
|
+
} else if (character === "/" && !regexCharacterClass && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9602
|
+
regex = false;
|
|
9603
|
+
}
|
|
9604
|
+
continue;
|
|
9605
|
+
}
|
|
9606
|
+
if (quote) {
|
|
9607
|
+
if (character === quote && !isInterpolationSyntaxCharacterEscaped(rawInner, cursor)) {
|
|
9608
|
+
quote = void 0;
|
|
9609
|
+
}
|
|
9610
|
+
continue;
|
|
9611
|
+
}
|
|
9612
|
+
if (character === "/" && isInterpolationRegexLiteralStart(rawInner, cursor)) {
|
|
9613
|
+
regex = true;
|
|
9614
|
+
regexCharacterClass = false;
|
|
9615
|
+
continue;
|
|
9616
|
+
}
|
|
9617
|
+
if (character === '"' || character === "'" || character === "`") {
|
|
9618
|
+
quote = character;
|
|
9619
|
+
continue;
|
|
9620
|
+
}
|
|
9621
|
+
if (character === "[") {
|
|
9622
|
+
bracketDepth += 1;
|
|
9623
|
+
continue;
|
|
9624
|
+
}
|
|
9625
|
+
if (character === "]" && bracketDepth > 0) {
|
|
9626
|
+
bracketDepth -= 1;
|
|
9627
|
+
continue;
|
|
9628
|
+
}
|
|
9629
|
+
if (character === "(") {
|
|
9630
|
+
parenthesisDepth += 1;
|
|
9631
|
+
continue;
|
|
9632
|
+
}
|
|
9633
|
+
if (character === ")" && parenthesisDepth > 0) {
|
|
9634
|
+
parenthesisDepth -= 1;
|
|
9635
|
+
continue;
|
|
9636
|
+
}
|
|
9637
|
+
if (character === "{") {
|
|
9638
|
+
braceDepth += 1;
|
|
9639
|
+
continue;
|
|
9640
|
+
}
|
|
9641
|
+
if (character === "}" && braceDepth > 0) {
|
|
9642
|
+
braceDepth -= 1;
|
|
9643
|
+
continue;
|
|
9644
|
+
}
|
|
9645
|
+
if (character === "|" && bracketDepth === 0 && parenthesisDepth === 0 && braceDepth === 0) {
|
|
9646
|
+
return cursor;
|
|
9647
|
+
}
|
|
9648
|
+
}
|
|
9649
|
+
return void 0;
|
|
9650
|
+
}
|
|
9651
|
+
function findQuotedStringEnd(value, start) {
|
|
9652
|
+
const quote = value[start];
|
|
9653
|
+
for (let cursor = start + 1; cursor < value.length; cursor++) {
|
|
9654
|
+
if (value[cursor] === quote && !isInterpolationSyntaxCharacterEscaped(value, cursor)) {
|
|
9655
|
+
return cursor;
|
|
9656
|
+
}
|
|
9657
|
+
}
|
|
9658
|
+
return void 0;
|
|
9659
|
+
}
|
|
9660
|
+
function parseQuotedBaseReference(expression) {
|
|
9661
|
+
if (expression[0] !== "[") {
|
|
9662
|
+
return void 0;
|
|
9663
|
+
}
|
|
9664
|
+
let cursor = 1;
|
|
9665
|
+
while (expression[cursor] === " ") {
|
|
9666
|
+
cursor += 1;
|
|
9667
|
+
}
|
|
9668
|
+
const quote = expression[cursor];
|
|
9669
|
+
if (quote !== '"' && quote !== "'") {
|
|
9670
|
+
return void 0;
|
|
9671
|
+
}
|
|
9672
|
+
const quoteEnd = findQuotedStringEnd(expression, cursor);
|
|
9673
|
+
if (quoteEnd === void 0) {
|
|
9674
|
+
return void 0;
|
|
9675
|
+
}
|
|
9676
|
+
const baseName = expression.slice(cursor + 1, quoteEnd);
|
|
9677
|
+
if (!baseName) {
|
|
9678
|
+
return void 0;
|
|
9679
|
+
}
|
|
9680
|
+
cursor = quoteEnd + 1;
|
|
9681
|
+
while (expression[cursor] === " ") {
|
|
9682
|
+
cursor += 1;
|
|
9683
|
+
}
|
|
9684
|
+
if (expression[cursor] !== "]") {
|
|
9685
|
+
return void 0;
|
|
9686
|
+
}
|
|
9687
|
+
const suffix = expression.slice(cursor + 1).trimStart();
|
|
9688
|
+
if (suffix !== "" && !suffix.startsWith(".") && !suffix.startsWith("[")) {
|
|
9689
|
+
return void 0;
|
|
9690
|
+
}
|
|
9691
|
+
return { baseName, suffix: suffix || void 0 };
|
|
9692
|
+
}
|
|
9693
|
+
function parseBaseReference(expression, source) {
|
|
9694
|
+
const trimmedExpression = expression.trim();
|
|
9695
|
+
if (!trimmedExpression) {
|
|
9696
|
+
return void 0;
|
|
9697
|
+
}
|
|
9698
|
+
const quotedReference = parseQuotedBaseReference(trimmedExpression);
|
|
9699
|
+
if (quotedReference) {
|
|
9700
|
+
return {
|
|
9701
|
+
source,
|
|
9702
|
+
baseName: quotedReference.baseName,
|
|
9703
|
+
jsonPath: quotedReference.suffix ? normalizeJsonPathExpression(`$${quotedReference.suffix}`) : void 0
|
|
9704
|
+
};
|
|
9705
|
+
}
|
|
9706
|
+
let suffixStart = -1;
|
|
9707
|
+
for (let cursor = 0; cursor < trimmedExpression.length; cursor++) {
|
|
9708
|
+
const character = trimmedExpression[cursor];
|
|
9709
|
+
if (character === "." || character === "[") {
|
|
9710
|
+
suffixStart = cursor;
|
|
9711
|
+
break;
|
|
9712
|
+
}
|
|
9713
|
+
}
|
|
9714
|
+
if (suffixStart === -1) {
|
|
9715
|
+
return {
|
|
9716
|
+
source,
|
|
9717
|
+
baseName: trimmedExpression,
|
|
9718
|
+
jsonPath: void 0
|
|
9719
|
+
};
|
|
9720
|
+
}
|
|
9721
|
+
const baseName = trimmedExpression.slice(0, suffixStart).trim();
|
|
9722
|
+
const suffix = normalizeJsonPathExpression(trimmedExpression.slice(suffixStart));
|
|
9723
|
+
if (!baseName || !suffix.startsWith(".") && !suffix.startsWith("[")) {
|
|
9724
|
+
return void 0;
|
|
9725
|
+
}
|
|
9726
|
+
return {
|
|
9727
|
+
source,
|
|
9728
|
+
baseName,
|
|
9729
|
+
jsonPath: `$${suffix}`
|
|
9730
|
+
};
|
|
9731
|
+
}
|
|
9732
|
+
function parseInterpolationExpressionUncached(trimmedExpression) {
|
|
9733
|
+
for (const [prefix, source] of [
|
|
9734
|
+
["@graphInputs", "graphInputs"],
|
|
9735
|
+
["@context", "context"]
|
|
9736
|
+
]) {
|
|
9737
|
+
if (trimmedExpression.startsWith(`${prefix}.`)) {
|
|
9738
|
+
return parseBaseReference(trimmedExpression.slice(prefix.length + 1), source);
|
|
9739
|
+
}
|
|
9740
|
+
if (trimmedExpression.startsWith(`${prefix}[`)) {
|
|
9741
|
+
return parseBaseReference(trimmedExpression.slice(prefix.length), source);
|
|
9742
|
+
}
|
|
9743
|
+
}
|
|
9744
|
+
return parseBaseReference(trimmedExpression, "variable");
|
|
9745
|
+
}
|
|
9746
|
+
function getCachedInterpolationExpression(expression) {
|
|
9747
|
+
const trimmedExpression = expression.trim();
|
|
9748
|
+
if (interpolationExpressionCache.has(trimmedExpression)) {
|
|
9749
|
+
return interpolationExpressionCache.get(trimmedExpression);
|
|
9750
|
+
}
|
|
9751
|
+
const parsed = parseInterpolationExpressionUncached(trimmedExpression);
|
|
9752
|
+
if (trimmedExpression.length > INTERPOLATION_EXPRESSION_CACHE_MAX_EXPRESSION_LENGTH) {
|
|
9753
|
+
return parsed;
|
|
9754
|
+
}
|
|
9755
|
+
if (interpolationExpressionCache.size >= INTERPOLATION_EXPRESSION_CACHE_MAX_ENTRIES || cachedInterpolationExpressionChars + trimmedExpression.length > INTERPOLATION_EXPRESSION_CACHE_MAX_CHARS) {
|
|
9756
|
+
interpolationExpressionCache.clear();
|
|
9757
|
+
cachedInterpolationExpressionChars = 0;
|
|
9758
|
+
}
|
|
9759
|
+
const immutableParsed = parsed ? Object.freeze({ ...parsed }) : void 0;
|
|
9760
|
+
interpolationExpressionCache.set(trimmedExpression, immutableParsed);
|
|
9761
|
+
cachedInterpolationExpressionChars += trimmedExpression.length;
|
|
9762
|
+
return immutableParsed;
|
|
9763
|
+
}
|
|
9764
|
+
function parseInterpolationExpression(expression) {
|
|
9765
|
+
const parsed = getCachedInterpolationExpression(expression);
|
|
9766
|
+
return parsed ? { ...parsed } : void 0;
|
|
9767
|
+
}
|
|
9768
|
+
function parseInterpolationToken(rawInner) {
|
|
9769
|
+
const processorSeparator = findTopLevelProcessorSeparator(rawInner);
|
|
9770
|
+
const tokenName = (processorSeparator === void 0 ? rawInner : rawInner.slice(0, processorSeparator)).trim() || void 0;
|
|
9771
|
+
const processingChain = processorSeparator === void 0 ? void 0 : rawInner.slice(processorSeparator + 1).trim() || void 0;
|
|
9772
|
+
return {
|
|
9773
|
+
rawInner,
|
|
9774
|
+
tokenName,
|
|
9775
|
+
processingChain,
|
|
9776
|
+
reference: tokenName ? parseInterpolationExpression(tokenName) : void 0
|
|
9777
|
+
};
|
|
9778
|
+
}
|
|
9779
|
+
function freezeReference(reference) {
|
|
9780
|
+
return reference ? Object.freeze({ ...reference }) : void 0;
|
|
9781
|
+
}
|
|
9782
|
+
function parseInterpolationTemplateUncached(template) {
|
|
9783
|
+
const tokens = scanInterpolationTokenSpans(template).map((span) => {
|
|
9784
|
+
const parsedToken = parseInterpolationToken(span.rawInner);
|
|
9785
|
+
return Object.freeze({
|
|
9786
|
+
...parsedToken,
|
|
9787
|
+
span: Object.freeze({ ...span }),
|
|
9788
|
+
reference: freezeReference(parsedToken.reference)
|
|
9789
|
+
});
|
|
9790
|
+
});
|
|
9791
|
+
return Object.freeze({
|
|
9792
|
+
template,
|
|
9793
|
+
tokens: Object.freeze(tokens)
|
|
9794
|
+
});
|
|
9795
|
+
}
|
|
9796
|
+
function getTemplateStorageChars(template, parsed) {
|
|
9797
|
+
return template.length + parsed.tokens.reduce(
|
|
9798
|
+
(total, token) => {
|
|
9799
|
+
var _a;
|
|
9800
|
+
return total + token.rawInner.length + (((_a = token.tokenName) == null ? void 0 : _a.length) ?? 0);
|
|
9801
|
+
},
|
|
9802
|
+
parsed.tokens.length * 48
|
|
9803
|
+
);
|
|
9804
|
+
}
|
|
9805
|
+
function cacheInterpolationTemplate(template, parsed) {
|
|
9806
|
+
if (template.length > INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_LENGTH) {
|
|
9807
|
+
return;
|
|
9808
|
+
}
|
|
9809
|
+
const storageChars = getTemplateStorageChars(template, parsed);
|
|
9810
|
+
const reachesCapacity = interpolationTemplateCache.size >= INTERPOLATION_TEMPLATE_CACHE_MAX_ENTRIES || cachedInterpolationTemplateChars + template.length > INTERPOLATION_TEMPLATE_CACHE_MAX_TEMPLATE_CHARS || cachedInterpolationTemplateStorageChars + storageChars > INTERPOLATION_TEMPLATE_CACHE_MAX_STORAGE_CHARS;
|
|
9811
|
+
if (reachesCapacity) {
|
|
9812
|
+
if (lastUncachedInterpolationTemplate !== template) {
|
|
9813
|
+
lastUncachedInterpolationTemplate = template;
|
|
9814
|
+
return;
|
|
9815
|
+
}
|
|
9816
|
+
interpolationTemplateCache.clear();
|
|
9817
|
+
cachedInterpolationTemplateChars = 0;
|
|
9818
|
+
cachedInterpolationTemplateStorageChars = 0;
|
|
9819
|
+
}
|
|
9820
|
+
lastUncachedInterpolationTemplate = void 0;
|
|
9821
|
+
interpolationTemplateCache.set(template, {
|
|
9822
|
+
templateChars: template.length,
|
|
9823
|
+
storageChars,
|
|
9824
|
+
parsed
|
|
9825
|
+
});
|
|
9826
|
+
cachedInterpolationTemplateChars += template.length;
|
|
9827
|
+
cachedInterpolationTemplateStorageChars += storageChars;
|
|
9828
|
+
}
|
|
9829
|
+
function parseInterpolationTemplate(template) {
|
|
9830
|
+
const cached = interpolationTemplateCache.get(template);
|
|
9831
|
+
if (cached) {
|
|
9832
|
+
return cached.parsed;
|
|
9833
|
+
}
|
|
9834
|
+
const parsed = parseInterpolationTemplateUncached(template);
|
|
9835
|
+
if (template.includes("{{")) {
|
|
9836
|
+
cacheInterpolationTemplate(template, parsed);
|
|
9837
|
+
}
|
|
9838
|
+
return parsed;
|
|
9839
|
+
}
|
|
9840
|
+
function protectEscapedInterpolationTokens(template) {
|
|
9841
|
+
return template.replace(ESCAPED_TOKEN_REGEX, (_match, expression) => `\\{\\{${expression}\\}\\}`);
|
|
9842
|
+
}
|
|
9843
|
+
function restoreEscapedInterpolationTokens(template) {
|
|
9844
|
+
return template.replace(ESCAPED_ESCAPED_TOKEN_REGEX, (_match, expression) => `{{${expression}}}`).replace(ESCAPED_TOKEN_REGEX, (_match, expression) => `{{${expression}}}`);
|
|
9845
|
+
}
|
|
9846
|
+
function findInterpolationTokenSpans(template) {
|
|
9847
|
+
return parseInterpolationTemplate(template).tokens.map((token) => ({ ...token.span }));
|
|
9848
|
+
}
|
|
9849
|
+
function getInterpolationTokenName(rawInner) {
|
|
9850
|
+
return parseInterpolationToken(rawInner).tokenName;
|
|
9851
|
+
}
|
|
9852
|
+
function getInterpolationTokenReference(rawInner) {
|
|
9853
|
+
return parseInterpolationToken(rawInner).reference;
|
|
9854
|
+
}
|
|
9855
|
+
function replaceInterpolationTokens(template, getReplacement, options2 = {}) {
|
|
9856
|
+
const parsedTemplate = parseInterpolationTemplate(template);
|
|
9857
|
+
if (parsedTemplate.tokens.length === 0) {
|
|
9858
|
+
const restoredTemplate = restoreEscapedInterpolationTokens(template);
|
|
9859
|
+
return options2.trim ? restoredTemplate.trim() : restoredTemplate;
|
|
9860
|
+
}
|
|
9861
|
+
let result = "";
|
|
9862
|
+
let cursor = 0;
|
|
9863
|
+
for (const token of parsedTemplate.tokens) {
|
|
9864
|
+
result += restoreEscapedInterpolationTokens(template.slice(cursor, token.span.start));
|
|
9865
|
+
result += getReplacement({
|
|
9866
|
+
rawInner: token.rawInner,
|
|
9867
|
+
span: { ...token.span },
|
|
9868
|
+
tokenName: token.tokenName,
|
|
9869
|
+
processingChain: token.processingChain,
|
|
9870
|
+
reference: token.reference ? { ...token.reference } : void 0
|
|
9871
|
+
});
|
|
9872
|
+
cursor = token.span.end;
|
|
9873
|
+
}
|
|
9874
|
+
result += restoreEscapedInterpolationTokens(template.slice(cursor));
|
|
9875
|
+
return options2.trim ? result.trim() : result;
|
|
9876
|
+
}
|
|
9877
|
+
function extractInterpolationVariableReferences(template) {
|
|
9878
|
+
if (!template.includes("{{")) {
|
|
9879
|
+
return [];
|
|
9880
|
+
}
|
|
9881
|
+
const discovered = /* @__PURE__ */ new Map();
|
|
9882
|
+
for (const token of parseInterpolationTemplate(template).tokens) {
|
|
9883
|
+
const reference = token.reference;
|
|
9884
|
+
if (!reference || reference.source !== "variable") {
|
|
9885
|
+
continue;
|
|
9886
|
+
}
|
|
9887
|
+
const existing = discovered.get(reference.baseName);
|
|
9888
|
+
if (existing) {
|
|
9889
|
+
existing.hasPath ||= reference.jsonPath !== void 0;
|
|
9890
|
+
continue;
|
|
9891
|
+
}
|
|
9892
|
+
discovered.set(reference.baseName, {
|
|
9893
|
+
baseName: reference.baseName,
|
|
9894
|
+
hasPath: reference.jsonPath !== void 0
|
|
9895
|
+
});
|
|
9896
|
+
}
|
|
9897
|
+
return Array.from(discovered.values(), (reference) => ({ ...reference }));
|
|
9898
|
+
}
|
|
9899
|
+
function extractInterpolationVariables(template) {
|
|
9900
|
+
return extractInterpolationVariableReferences(template).map((reference) => reference.baseName);
|
|
9901
|
+
}
|
|
9902
|
+
function getInterpolationSource(reference, sources) {
|
|
9903
|
+
switch (reference.source) {
|
|
9904
|
+
case "variable":
|
|
9905
|
+
return sources.variables;
|
|
9906
|
+
case "graphInputs":
|
|
9907
|
+
return sources.graphInputValues;
|
|
9908
|
+
case "context":
|
|
9909
|
+
return sources.contextValues;
|
|
9910
|
+
}
|
|
9911
|
+
}
|
|
9912
|
+
function resolveInterpolationExpressionRawValue(expression, sources) {
|
|
9913
|
+
const reference = typeof expression === "string" ? getCachedInterpolationExpression(expression) : expression;
|
|
9914
|
+
if (!reference) {
|
|
9915
|
+
return void 0;
|
|
9916
|
+
}
|
|
9917
|
+
const source = getInterpolationSource(reference, sources);
|
|
9918
|
+
if (!source || !Object.prototype.hasOwnProperty.call(source, reference.baseName)) {
|
|
9919
|
+
return void 0;
|
|
9920
|
+
}
|
|
9921
|
+
const shouldUnwrapDataValue = reference.source !== "variable" || sources.unwrapVariableDataValues !== false;
|
|
9922
|
+
const baseValue = shouldUnwrapDataValue ? unwrapPotentialDataValue(source[reference.baseName]) : source[reference.baseName];
|
|
9923
|
+
if (reference.jsonPath === void 0) {
|
|
9924
|
+
return baseValue;
|
|
9925
|
+
}
|
|
9926
|
+
try {
|
|
9927
|
+
return evaluateJsonPath(baseValue, reference.jsonPath, false);
|
|
9928
|
+
} catch {
|
|
9929
|
+
return void 0;
|
|
9930
|
+
}
|
|
9931
|
+
}
|
|
9932
|
+
function resolveInterpolationTokenRawValue(rawInner, sources) {
|
|
9933
|
+
const reference = parseInterpolationToken(rawInner).reference;
|
|
9934
|
+
return reference ? resolveInterpolationExpressionRawValue(reference, sources) : void 0;
|
|
9935
|
+
}
|
|
9936
|
+
function stringifyInterpolationValue(value) {
|
|
9937
|
+
if (typeof value === "object" && value !== null) {
|
|
9938
|
+
try {
|
|
9939
|
+
return JSON.stringify(value);
|
|
9940
|
+
} catch (error) {
|
|
9941
|
+
console.warn("Error stringifying an interpolation value:", error);
|
|
9942
|
+
return "[object Object]";
|
|
9943
|
+
}
|
|
9944
|
+
}
|
|
9945
|
+
return String(value);
|
|
9946
|
+
}
|
|
9947
|
+
function parseProcessing(instruction) {
|
|
9948
|
+
const parts = instruction.trim().split(/\s+/);
|
|
9949
|
+
return {
|
|
9950
|
+
func: parts[0],
|
|
9951
|
+
param: parts[1] ? Number.parseInt(parts[1], 10) : void 0
|
|
9952
|
+
};
|
|
9953
|
+
}
|
|
9954
|
+
function applyProcessing(value, processingChain) {
|
|
9955
|
+
const instructions = processingChain.split("|").map((instruction) => instruction.trim()).filter((instruction) => instruction !== "");
|
|
9956
|
+
return instructions.reduce((result, instruction) => {
|
|
9957
|
+
const { func, param } = parseProcessing(instruction);
|
|
9958
|
+
const processingFunc = processingFunctions[func];
|
|
9959
|
+
if (!processingFunc) {
|
|
9960
|
+
console.warn(`Unknown processing function: ${func}`);
|
|
9961
|
+
return result;
|
|
9962
|
+
}
|
|
9963
|
+
return processingFunc(result, param);
|
|
9964
|
+
}, value);
|
|
9965
|
+
}
|
|
9966
|
+
function interpolate(template, variables, graphInputValues, contextValues, options2 = {}) {
|
|
9967
|
+
return replaceInterpolationTokens(template, (token) => {
|
|
9968
|
+
if (!token.reference) {
|
|
9969
|
+
return "";
|
|
9970
|
+
}
|
|
9971
|
+
const resolvedValue = resolveInterpolationExpressionRawValue(token.reference, {
|
|
9972
|
+
variables,
|
|
9973
|
+
graphInputValues,
|
|
9974
|
+
contextValues,
|
|
9975
|
+
unwrapVariableDataValues: options2.unwrapVariableDataValues
|
|
9976
|
+
});
|
|
9977
|
+
if (resolvedValue === void 0) {
|
|
9978
|
+
console.warn(`Interpolation variable or path "${token.tokenName}" not found or resolved to undefined.`);
|
|
9979
|
+
return "";
|
|
9980
|
+
}
|
|
9981
|
+
const isBareOrdinaryVariable = token.reference.source === "variable" && token.reference.jsonPath === void 0;
|
|
9982
|
+
const stringValue = isBareOrdinaryVariable ? stringifyInterpolationSourceValue(variables[token.reference.baseName], {
|
|
9983
|
+
coerceDataValueToString: options2.coerceBareVariableDataValues,
|
|
9984
|
+
unwrapDataValue: options2.unwrapVariableDataValues !== false
|
|
9985
|
+
}) : stringifyInterpolationValue(resolvedValue);
|
|
9986
|
+
return token.processingChain ? applyProcessing(stringValue, token.processingChain) : stringValue;
|
|
9987
|
+
});
|
|
9988
|
+
}
|
|
9989
|
+
function resolveCodeInterpolationExpression(inputs, expression, graphInputValues, contextValues) {
|
|
9990
|
+
return resolveInterpolationExpressionRawValue(expression, {
|
|
9991
|
+
variables: inputs,
|
|
9992
|
+
graphInputValues,
|
|
9993
|
+
contextValues
|
|
9994
|
+
});
|
|
9995
|
+
}
|
|
9996
|
+
|
|
9183
9997
|
// src/integrations/CodeRunnerOptions.ts
|
|
9184
9998
|
var ALL_CODE_RUNNER_OPTIONS = Object.freeze({
|
|
9185
9999
|
includeRequire: true,
|
|
@@ -9214,6 +10028,10 @@ var IsomorphicCodeRunner = class {
|
|
|
9214
10028
|
argNames.push("context");
|
|
9215
10029
|
args.push(contextValues);
|
|
9216
10030
|
}
|
|
10031
|
+
if (options2.interpolationHelperIdentifier) {
|
|
10032
|
+
argNames.push(options2.interpolationHelperIdentifier);
|
|
10033
|
+
args.push(resolveCodeInterpolationExpression);
|
|
10034
|
+
}
|
|
9217
10035
|
argNames.push(code);
|
|
9218
10036
|
const AsyncFunction = async function() {
|
|
9219
10037
|
}.constructor;
|
|
@@ -9415,6 +10233,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9415
10233
|
#graphExecutionPlan;
|
|
9416
10234
|
#nodeProcessContextBase = void 0;
|
|
9417
10235
|
#runToRelevantNodeIds;
|
|
10236
|
+
#graphOutputSelection;
|
|
9418
10237
|
#managedAsyncBranches;
|
|
9419
10238
|
#managedAsyncBranchFailures = [];
|
|
9420
10239
|
#runCompletionPromise;
|
|
@@ -9636,7 +10455,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9636
10455
|
const pending = this.#pendingUserInputs[nodeId];
|
|
9637
10456
|
if (pending) {
|
|
9638
10457
|
pending.resolve(values2);
|
|
9639
|
-
delete this.#pendingUserInputs[nodeId];
|
|
9640
10458
|
}
|
|
9641
10459
|
for (const processor of this.#subprocessors) {
|
|
9642
10460
|
processor.userInput(nodeId, values2);
|
|
@@ -9737,7 +10555,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9737
10555
|
}
|
|
9738
10556
|
this.#preloadedNodeResults.set(nodeId, data);
|
|
9739
10557
|
this.#hasPreloadedData = true;
|
|
9740
|
-
if (this.#lifecycle.isRunning) {
|
|
10558
|
+
if (this.#lifecycle.isRunning && this.#isNodeSelected(nodeId)) {
|
|
9741
10559
|
this.#nodeResults.set(nodeId, data);
|
|
9742
10560
|
this.#visitedNodes.add(nodeId);
|
|
9743
10561
|
}
|
|
@@ -9787,9 +10605,12 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9787
10605
|
}
|
|
9788
10606
|
}
|
|
9789
10607
|
async replayRecording(recorder) {
|
|
10608
|
+
if (this.#lifecycle.isRunning) {
|
|
10609
|
+
throw new Error("Cannot process graph while already processing");
|
|
10610
|
+
}
|
|
9790
10611
|
this.#initializeExecutionIdentity();
|
|
9791
10612
|
this.#initProcessState();
|
|
9792
|
-
|
|
10613
|
+
return await replayExecutionRecording({
|
|
9793
10614
|
emitter: this.#emitter,
|
|
9794
10615
|
erroredNodes: this.#erroredNodes,
|
|
9795
10616
|
graphInputs: this.#graphInputs,
|
|
@@ -9816,7 +10637,6 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9816
10637
|
visitedNodes: this.#visitedNodes,
|
|
9817
10638
|
waitUntilUnpaused: () => this.#waitUntilUnpaused()
|
|
9818
10639
|
});
|
|
9819
|
-
return this.#graphOutputs;
|
|
9820
10640
|
}
|
|
9821
10641
|
#initProcessState() {
|
|
9822
10642
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -9847,6 +10667,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9847
10667
|
this.#ignoreNodes = /* @__PURE__ */ new Set();
|
|
9848
10668
|
this.#nodeProcessContextBase = void 0;
|
|
9849
10669
|
this.#runToRelevantNodeIds = void 0;
|
|
10670
|
+
this.#graphOutputSelection = void 0;
|
|
9850
10671
|
if (!this.#isSubProcessor) {
|
|
9851
10672
|
this.#managedAsyncBranches = new ManagedAsyncBranches();
|
|
9852
10673
|
this.#managedAsyncBranchFailures = [];
|
|
@@ -9865,9 +10686,11 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9865
10686
|
}
|
|
9866
10687
|
/** Main function for running a graph. Runs a graph and returns the outputs from the output nodes of the graph. */
|
|
9867
10688
|
async processGraph(context, inputs = {}, contextValues = {}, options2 = {}) {
|
|
10689
|
+
var _a;
|
|
9868
10690
|
if (this.#lifecycle.isRunning) {
|
|
9869
10691
|
throw new Error("Cannot process graph while already processing");
|
|
9870
10692
|
}
|
|
10693
|
+
const requestedGraphOutputIds = (_a = options2.requestedGraphOutputIds) == null ? void 0 : _a.slice();
|
|
9871
10694
|
let resolveOutputsReady;
|
|
9872
10695
|
let rejectOutputsReady;
|
|
9873
10696
|
const outputsReadyPromise = options2.returnWhenGraphOutputsReady === true ? new Promise((resolve, reject) => {
|
|
@@ -9876,7 +10699,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9876
10699
|
}) : void 0;
|
|
9877
10700
|
let outputsWerePublishedEarly = false;
|
|
9878
10701
|
const completionPromise = (async () => {
|
|
9879
|
-
var
|
|
10702
|
+
var _a2;
|
|
9880
10703
|
try {
|
|
9881
10704
|
try {
|
|
9882
10705
|
this.#profileRuntimeSync(
|
|
@@ -9891,6 +10714,22 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9891
10714
|
this.#preprocessGraph();
|
|
9892
10715
|
}
|
|
9893
10716
|
this.#assertNoDataBusRunTargets();
|
|
10717
|
+
if (requestedGraphOutputIds !== void 0) {
|
|
10718
|
+
if (this.runToNodeIds !== void 0) {
|
|
10719
|
+
throw new Error("requestedGraphOutputIds cannot be combined with runToNodeIds");
|
|
10720
|
+
}
|
|
10721
|
+
this.#graphOutputSelection = createGraphOutputSelection(
|
|
10722
|
+
{ nodes: this.#executionGraphNodes, connections: this.#getEffectiveConnections() },
|
|
10723
|
+
requestedGraphOutputIds,
|
|
10724
|
+
(node) => getInputNodesTo(this.#executionState, node)
|
|
10725
|
+
);
|
|
10726
|
+
for (const nodeId of this.#nodeResults.keys()) {
|
|
10727
|
+
if (!this.#isNodeSelected(nodeId)) {
|
|
10728
|
+
this.#nodeResults.delete(nodeId);
|
|
10729
|
+
this.#visitedNodes.delete(nodeId);
|
|
10730
|
+
}
|
|
10731
|
+
}
|
|
10732
|
+
}
|
|
9894
10733
|
this.#prepareAsyncBranchTopology();
|
|
9895
10734
|
} catch (error) {
|
|
9896
10735
|
const normalizedError = getError(error);
|
|
@@ -9923,7 +10762,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
9923
10762
|
return await this.#profileRuntimeAsync("finalizeGraphRun", () => this.#finalizeGraphRun());
|
|
9924
10763
|
} finally {
|
|
9925
10764
|
if (!this.#isSubProcessor) {
|
|
9926
|
-
await ((
|
|
10765
|
+
await ((_a2 = this.#managedAsyncBranches) == null ? void 0 : _a2.drain());
|
|
9927
10766
|
}
|
|
9928
10767
|
this.#lifecycle.complete();
|
|
9929
10768
|
this.#cleanupTokenizerErrorListener();
|
|
@@ -10045,12 +10884,31 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10045
10884
|
this.#emitTraceEvent(message);
|
|
10046
10885
|
},
|
|
10047
10886
|
setStoredValue: (key, value) => this.#storedValueController.set(key, value),
|
|
10048
|
-
waitForGlobal: async (id) => {
|
|
10887
|
+
waitForGlobal: async (id, signal = this.#abortController.signal) => {
|
|
10888
|
+
if (signal.aborted) {
|
|
10889
|
+
throw createGraphAbortErrorFromSignal(signal);
|
|
10890
|
+
}
|
|
10049
10891
|
if (this.#globals.has(id)) {
|
|
10050
10892
|
return this.#globals.get(id);
|
|
10051
10893
|
}
|
|
10052
|
-
await
|
|
10053
|
-
|
|
10894
|
+
return await new Promise((resolve, reject) => {
|
|
10895
|
+
const abortListener = () => {
|
|
10896
|
+
cleanup();
|
|
10897
|
+
reject(createGraphAbortErrorFromSignal(signal));
|
|
10898
|
+
};
|
|
10899
|
+
const unsubscribe = this.getRootProcessor().#emitter.on(`globalSet:${id}`, () => {
|
|
10900
|
+
cleanup();
|
|
10901
|
+
resolve(this.#globals.get(id));
|
|
10902
|
+
});
|
|
10903
|
+
const cleanup = () => {
|
|
10904
|
+
unsubscribe();
|
|
10905
|
+
signal.removeEventListener("abort", abortListener);
|
|
10906
|
+
};
|
|
10907
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
10908
|
+
if (signal.aborted) {
|
|
10909
|
+
abortListener();
|
|
10910
|
+
}
|
|
10911
|
+
});
|
|
10054
10912
|
},
|
|
10055
10913
|
waitForStoredValue: (key, signal) => this.#storedValueController.waitForSet(key, signal)
|
|
10056
10914
|
};
|
|
@@ -10086,7 +10944,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10086
10944
|
return;
|
|
10087
10945
|
}
|
|
10088
10946
|
for (const node of this.#executionGraphNodes) {
|
|
10089
|
-
if (!this.#nodeResults.has(node.id)) {
|
|
10947
|
+
if (!this.#isNodeSelected(node.id) || !this.#nodeResults.has(node.id)) {
|
|
10090
10948
|
continue;
|
|
10091
10949
|
}
|
|
10092
10950
|
if (this.#suppressedPreloadedNodeIds.has(node.id)) {
|
|
@@ -10121,7 +10979,10 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10121
10979
|
}
|
|
10122
10980
|
}
|
|
10123
10981
|
async #processCompatibleGraph() {
|
|
10124
|
-
|
|
10982
|
+
var _a;
|
|
10983
|
+
await this.#queueStartNodes(
|
|
10984
|
+
((_a = this.#graphOutputSelection) == null ? void 0 : _a.startNodes) ?? getStartNodes(this.#executionState, this.#executionGraphNodes, this.runToNodeIds)
|
|
10985
|
+
);
|
|
10125
10986
|
await this.#processingQueue.onIdle();
|
|
10126
10987
|
this.#markUnqueuedNodesIgnored();
|
|
10127
10988
|
}
|
|
@@ -10129,7 +10990,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
10129
10990
|
if (this.#scheduler !== "fast-acyclic") {
|
|
10130
10991
|
return false;
|
|
10131
10992
|
}
|
|
10132
|
-
if (this.#hasPreloadedData || this.runToNodeIds || this.slowMode || this.#includeTrace) {
|
|
10993
|
+
if (this.#graphOutputSelection || this.#hasPreloadedData || this.runToNodeIds || this.slowMode || this.#includeTrace) {
|
|
10133
10994
|
return false;
|
|
10134
10995
|
}
|
|
10135
10996
|
if (this.#nodesNotInCycle.length !== this.#executionGraphNodes.length) {
|
|
@@ -10344,6 +11205,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10344
11205
|
}
|
|
10345
11206
|
async #fetchNodeDataAndProcessNode(node) {
|
|
10346
11207
|
var _a;
|
|
11208
|
+
if (!this.#isNodeSelected(node.id)) return;
|
|
10347
11209
|
const profileStart = this.#startRuntimeProfile();
|
|
10348
11210
|
try {
|
|
10349
11211
|
if (this.#currentlyProcessing.has(node.id)) {
|
|
@@ -10396,6 +11258,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10396
11258
|
}
|
|
10397
11259
|
/** If all inputs are present, all conditions met, processes the node. */
|
|
10398
11260
|
async #processNodeIfAllInputsAvailable(node, options2 = {}) {
|
|
11261
|
+
if (!this.#isNodeSelected(node.id)) return [];
|
|
10399
11262
|
const { queueOutputNodes = true } = options2;
|
|
10400
11263
|
const builtInNode = node;
|
|
10401
11264
|
const inputNodesProfileStart = this.#startRuntimeProfile();
|
|
@@ -10639,8 +11502,9 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
10639
11502
|
}
|
|
10640
11503
|
}
|
|
10641
11504
|
#queueOutputNodes(node, outputNodes) {
|
|
11505
|
+
const selectedOutputs = this.#graphOutputSelection ? outputNodes.filter((outputNode) => this.#isNodeSelected(outputNode.id)) : outputNodes;
|
|
10642
11506
|
void this.#processingQueue.addAll(
|
|
10643
|
-
|
|
11507
|
+
selectedOutputs.map((outputNode) => async () => {
|
|
10644
11508
|
this.#emitTraceEvent(`Trying to run output node from ${node.title}: ${outputNode.title} (${outputNode.id})`);
|
|
10645
11509
|
await this.#processNodeIfAllInputsAvailable(outputNode);
|
|
10646
11510
|
})
|
|
@@ -11085,6 +11949,9 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11085
11949
|
}
|
|
11086
11950
|
}
|
|
11087
11951
|
async #processNodeWithInputData(node, inputValues, index, processId, partialOutput, markResultAsEditorCacheHit) {
|
|
11952
|
+
if (this.#shouldSkipCompletedRaceNode(node, this.#getAttachedDataTo(node))) {
|
|
11953
|
+
throw createGraphAbortError(createGraphAbortReason(true, RACE_LOSER_EXCLUSION_REASON));
|
|
11954
|
+
}
|
|
11088
11955
|
const instance = this.#nodeInstances[node.id];
|
|
11089
11956
|
const nodeAbortController = this.#newAbortController();
|
|
11090
11957
|
this.#registerNodeAbortController(node.id, nodeAbortController);
|
|
@@ -11110,6 +11977,9 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11110
11977
|
this.#finishRuntimeProfile("createNodeProcessContext", createContextProfileStart);
|
|
11111
11978
|
}
|
|
11112
11979
|
await this.#waitUntilUnpaused();
|
|
11980
|
+
if (nodeAbortController.signal.aborted) {
|
|
11981
|
+
throw createGraphAbortErrorFromSignal(nodeAbortController.signal);
|
|
11982
|
+
}
|
|
11113
11983
|
const implementationProfileStart = this.#startRuntimeProfile();
|
|
11114
11984
|
let results;
|
|
11115
11985
|
try {
|
|
@@ -11165,7 +12035,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11165
12035
|
this.#emitGraphPartialOutputIfNeeded(node, partialOutputs);
|
|
11166
12036
|
},
|
|
11167
12037
|
processId,
|
|
11168
|
-
requestUserInput: async (inputStrings, renderingType) => this.#requestUserInput(node, inputStrings, inputValues, renderingType, processId),
|
|
12038
|
+
requestUserInput: async (inputStrings, renderingType) => this.#requestUserInput(node, inputStrings, inputValues, renderingType, processId, nodeAbortController.signal),
|
|
11169
12039
|
reportProgress: (progress) => {
|
|
11170
12040
|
const normalized = normalizeGraphProgress(progress);
|
|
11171
12041
|
if (normalized) {
|
|
@@ -11180,14 +12050,27 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11180
12050
|
toolCallContinuation,
|
|
11181
12051
|
toolCallTraceSource,
|
|
11182
12052
|
waitEvent: async (event) => {
|
|
12053
|
+
const signal = nodeAbortController.signal;
|
|
12054
|
+
if (signal.aborted) {
|
|
12055
|
+
throw createGraphAbortErrorFromSignal(signal, "Process aborted");
|
|
12056
|
+
}
|
|
11183
12057
|
return new Promise((resolve, reject) => {
|
|
11184
12058
|
const abortListener = () => {
|
|
11185
|
-
|
|
12059
|
+
cleanup();
|
|
12060
|
+
reject(createGraphAbortErrorFromSignal(signal, "Process aborted"));
|
|
11186
12061
|
};
|
|
11187
|
-
this.#emitter.
|
|
11188
|
-
|
|
12062
|
+
const unsubscribe = this.#emitter.on(`userEvent:${event}`, (data) => {
|
|
12063
|
+
cleanup();
|
|
12064
|
+
resolve(data);
|
|
11189
12065
|
});
|
|
11190
|
-
|
|
12066
|
+
const cleanup = () => {
|
|
12067
|
+
unsubscribe();
|
|
12068
|
+
signal.removeEventListener("abort", abortListener);
|
|
12069
|
+
};
|
|
12070
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
12071
|
+
if (signal.aborted) {
|
|
12072
|
+
abortListener();
|
|
12073
|
+
}
|
|
11191
12074
|
});
|
|
11192
12075
|
}
|
|
11193
12076
|
});
|
|
@@ -11492,7 +12375,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11492
12375
|
state: {
|
|
11493
12376
|
erroredNodeIds: new Set(this.#erroredNodes.keys()),
|
|
11494
12377
|
nodeOutputs: this.#nodeResults,
|
|
11495
|
-
runToRelevantNodeIds: this.#
|
|
12378
|
+
runToRelevantNodeIds: this.#getExecutionRelevantNodeIds(),
|
|
11496
12379
|
visitedNodeIds: this.#visitedNodes
|
|
11497
12380
|
}
|
|
11498
12381
|
});
|
|
@@ -11554,8 +12437,8 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11554
12437
|
);
|
|
11555
12438
|
const outgoingByNodeId = /* @__PURE__ */ new Map();
|
|
11556
12439
|
const incomingByNodeId = /* @__PURE__ */ new Map();
|
|
11557
|
-
const
|
|
11558
|
-
const
|
|
12440
|
+
const relevantNodeIds = this.#getExecutionRelevantNodeIds();
|
|
12441
|
+
const isRelevant = (nodeId) => !relevantNodeIds || relevantNodeIds.has(nodeId);
|
|
11559
12442
|
for (const connection of connections) {
|
|
11560
12443
|
const outgoing = outgoingByNodeId.get(connection.outputNodeId) ?? [];
|
|
11561
12444
|
outgoing.push(connection);
|
|
@@ -11565,7 +12448,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11565
12448
|
incomingByNodeId.set(connection.inputNodeId, incoming);
|
|
11566
12449
|
}
|
|
11567
12450
|
for (const triggerNode of Object.values(this.#nodesById)) {
|
|
11568
|
-
if (triggerNode.type !== "startBackgroundBranch" || triggerNode.disabled || !
|
|
12451
|
+
if (triggerNode.type !== "startBackgroundBranch" || triggerNode.disabled || !isRelevant(triggerNode.id)) {
|
|
11569
12452
|
continue;
|
|
11570
12453
|
}
|
|
11571
12454
|
if (triggerNode.id !== this.#consumedAsyncBranchTriggerNodeId && this.#nodeResults.has(triggerNode.id)) {
|
|
@@ -11574,7 +12457,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11574
12457
|
);
|
|
11575
12458
|
}
|
|
11576
12459
|
const nodeIds = /* @__PURE__ */ new Set();
|
|
11577
|
-
const pendingNodeIds = (outgoingByNodeId.get(triggerNode.id) ?? []).map((connection) => connection.inputNodeId).filter(
|
|
12460
|
+
const pendingNodeIds = (outgoingByNodeId.get(triggerNode.id) ?? []).map((connection) => connection.inputNodeId).filter(isRelevant);
|
|
11578
12461
|
while (pendingNodeIds.length > 0) {
|
|
11579
12462
|
const nodeId = pendingNodeIds.pop();
|
|
11580
12463
|
if (nodeId === triggerNode.id) {
|
|
@@ -11599,7 +12482,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11599
12482
|
}
|
|
11600
12483
|
nodeIds.add(nodeId);
|
|
11601
12484
|
for (const connection of outgoingByNodeId.get(nodeId) ?? []) {
|
|
11602
|
-
if (
|
|
12485
|
+
if (isRelevant(connection.inputNodeId)) {
|
|
11603
12486
|
pendingNodeIds.push(connection.inputNodeId);
|
|
11604
12487
|
}
|
|
11605
12488
|
}
|
|
@@ -11700,17 +12583,19 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11700
12583
|
if (outputConnections.length === 0) {
|
|
11701
12584
|
return /* @__PURE__ */ new Set();
|
|
11702
12585
|
}
|
|
11703
|
-
const
|
|
12586
|
+
const relevantNodeIds = this.#getExecutionRelevantNodeIds();
|
|
11704
12587
|
const activeOutputPortIds = /* @__PURE__ */ new Set();
|
|
11705
12588
|
for (const { node: outputNode, connections } of outputConnections) {
|
|
11706
12589
|
if (outputNode.disabled) {
|
|
11707
12590
|
continue;
|
|
11708
12591
|
}
|
|
11709
|
-
if (
|
|
12592
|
+
if (relevantNodeIds && !relevantNodeIds.has(outputNode.id)) {
|
|
11710
12593
|
continue;
|
|
11711
12594
|
}
|
|
11712
12595
|
for (const connection of connections) {
|
|
11713
|
-
|
|
12596
|
+
if (this.#isDefinitionValidConnection(connection)) {
|
|
12597
|
+
activeOutputPortIds.add(connection.outputId);
|
|
12598
|
+
}
|
|
11714
12599
|
}
|
|
11715
12600
|
}
|
|
11716
12601
|
return activeOutputPortIds;
|
|
@@ -11728,6 +12613,16 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11728
12613
|
}
|
|
11729
12614
|
}
|
|
11730
12615
|
}
|
|
12616
|
+
#isNodeSelected(nodeId) {
|
|
12617
|
+
return !this.#graphOutputSelection || this.#graphOutputSelection.nodeIds.has(nodeId);
|
|
12618
|
+
}
|
|
12619
|
+
#getExecutionRelevantNodeIds() {
|
|
12620
|
+
var _a;
|
|
12621
|
+
if (this.#sameGraphRunOwnerOverride) {
|
|
12622
|
+
return this.#sameGraphRunOwnerOverride.#getExecutionRelevantNodeIds();
|
|
12623
|
+
}
|
|
12624
|
+
return ((_a = this.#graphOutputSelection) == null ? void 0 : _a.nodeIds) ?? this.#getRunToRelevantNodeIds();
|
|
12625
|
+
}
|
|
11731
12626
|
#getRunToRelevantNodeIds() {
|
|
11732
12627
|
if (!this.runToNodeIds) {
|
|
11733
12628
|
return void 0;
|
|
@@ -11845,17 +12740,37 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11845
12740
|
}
|
|
11846
12741
|
return processor;
|
|
11847
12742
|
}
|
|
11848
|
-
async #requestUserInput(node, inputStrings, inputValues, renderingType, processId) {
|
|
12743
|
+
async #requestUserInput(node, inputStrings, inputValues, renderingType, processId, signal) {
|
|
12744
|
+
if (signal.aborted) {
|
|
12745
|
+
throw createGraphAbortErrorFromSignal(signal);
|
|
12746
|
+
}
|
|
11849
12747
|
return await new Promise((resolve, reject) => {
|
|
12748
|
+
let settled = false;
|
|
12749
|
+
const cleanup = () => {
|
|
12750
|
+
signal.removeEventListener("abort", abortListener);
|
|
12751
|
+
if (this.#pendingUserInputs[node.id] === pending) {
|
|
12752
|
+
delete this.#pendingUserInputs[node.id];
|
|
12753
|
+
}
|
|
12754
|
+
};
|
|
11850
12755
|
const abortListener = () => {
|
|
11851
|
-
|
|
11852
|
-
|
|
12756
|
+
if (settled) return;
|
|
12757
|
+
settled = true;
|
|
12758
|
+
cleanup();
|
|
12759
|
+
reject(createGraphAbortErrorFromSignal(signal));
|
|
11853
12760
|
};
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
12761
|
+
const respond = (results) => {
|
|
12762
|
+
if (settled) return;
|
|
12763
|
+
settled = true;
|
|
12764
|
+
cleanup();
|
|
12765
|
+
resolve(results);
|
|
11857
12766
|
};
|
|
11858
|
-
|
|
12767
|
+
const pending = { resolve: respond };
|
|
12768
|
+
this.#pendingUserInputs[node.id] = pending;
|
|
12769
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
12770
|
+
if (signal.aborted) {
|
|
12771
|
+
abortListener();
|
|
12772
|
+
return;
|
|
12773
|
+
}
|
|
11859
12774
|
emitDetached(
|
|
11860
12775
|
this.#emitter,
|
|
11861
12776
|
"userInput",
|
|
@@ -11864,11 +12779,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
11864
12779
|
inputStrings,
|
|
11865
12780
|
inputs: inputValues,
|
|
11866
12781
|
renderingType,
|
|
11867
|
-
callback:
|
|
11868
|
-
this.#abortController.signal.removeEventListener("abort", abortListener);
|
|
11869
|
-
resolve(results);
|
|
11870
|
-
delete this.#pendingUserInputs[node.id];
|
|
11871
|
-
},
|
|
12782
|
+
callback: respond,
|
|
11872
12783
|
processId
|
|
11873
12784
|
})
|
|
11874
12785
|
);
|
|
@@ -15999,284 +16910,6 @@ var userInputNode = nodeDefinition(UserInputNodeImpl, "User Input");
|
|
|
15999
16910
|
var import_non_secure8 = require("nanoid/non-secure");
|
|
16000
16911
|
var import_ts_dedent3 = require("ts-dedent");
|
|
16001
16912
|
|
|
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
16913
|
// src/model/interpolationInputDefinition.ts
|
|
16281
16914
|
var INTERPOLATION_INPUT_DEFINITION_KIND = "interpolation-input";
|
|
16282
16915
|
function createInterpolationInputDefinition({
|
|
@@ -16320,16 +16953,16 @@ function isInterpolationInputDefinition(inputDefinition) {
|
|
|
16320
16953
|
return getInterpolationInputDefinitionData(inputDefinition) != null;
|
|
16321
16954
|
}
|
|
16322
16955
|
|
|
16323
|
-
// src/model/nodes/
|
|
16956
|
+
// src/model/nodes/nodeBodyPreview.ts
|
|
16324
16957
|
var MAX_BODY_PREVIEW_LINES = 15;
|
|
16325
16958
|
var MAX_BODY_PREVIEW_LINE_LENGTH = 240;
|
|
16326
16959
|
var MAX_BODY_PREVIEW_CHARS = 3e3;
|
|
16327
|
-
function
|
|
16960
|
+
function buildNodeBodyPreview(text, maximumLines = MAX_BODY_PREVIEW_LINES) {
|
|
16328
16961
|
const allLines = text.split("\n");
|
|
16329
|
-
const previewLines = allLines.slice(0,
|
|
16962
|
+
const previewLines = allLines.slice(0, maximumLines).map(
|
|
16330
16963
|
(line) => line.length > MAX_BODY_PREVIEW_LINE_LENGTH ? `${line.slice(0, MAX_BODY_PREVIEW_LINE_LENGTH)}...` : line
|
|
16331
16964
|
);
|
|
16332
|
-
const omittedLines = allLines.length >
|
|
16965
|
+
const omittedLines = allLines.length > maximumLines;
|
|
16333
16966
|
let previewText = previewLines.join("\n").trim();
|
|
16334
16967
|
if (previewText.length > MAX_BODY_PREVIEW_CHARS) {
|
|
16335
16968
|
previewText = previewText.slice(0, MAX_BODY_PREVIEW_CHARS).trimEnd();
|
|
@@ -16342,6 +16975,8 @@ function buildTextNodeBodyPreview(text) {
|
|
|
16342
16975
|
}
|
|
16343
16976
|
return previewText;
|
|
16344
16977
|
}
|
|
16978
|
+
|
|
16979
|
+
// src/model/nodes/TextNode.ts
|
|
16345
16980
|
var TextNodeImpl = class extends NodeImpl {
|
|
16346
16981
|
static create() {
|
|
16347
16982
|
const chartNode = {
|
|
@@ -16362,14 +16997,14 @@ var TextNodeImpl = class extends NodeImpl {
|
|
|
16362
16997
|
return chartNode;
|
|
16363
16998
|
}
|
|
16364
16999
|
getInputDefinitions() {
|
|
16365
|
-
const
|
|
16366
|
-
return
|
|
16367
|
-
(
|
|
16368
|
-
interpolationName:
|
|
16369
|
-
dataType: "string",
|
|
17000
|
+
const inputReferences = extractInterpolationVariableReferences(this.data.text);
|
|
17001
|
+
return inputReferences.map(
|
|
17002
|
+
({ baseName, hasPath }) => createInterpolationInputDefinition({
|
|
17003
|
+
interpolationName: baseName,
|
|
17004
|
+
dataType: hasPath ? "any" : "string",
|
|
16370
17005
|
required: false
|
|
16371
17006
|
})
|
|
16372
|
-
)
|
|
17007
|
+
);
|
|
16373
17008
|
}
|
|
16374
17009
|
getOutputDefinitions() {
|
|
16375
17010
|
return [
|
|
@@ -16408,25 +17043,18 @@ var TextNodeImpl = class extends NodeImpl {
|
|
|
16408
17043
|
type: "colorized",
|
|
16409
17044
|
language: "prompt-interpolation-markdown",
|
|
16410
17045
|
theme: "prompt-interpolation",
|
|
16411
|
-
text:
|
|
17046
|
+
text: buildNodeBodyPreview(this.data.text)
|
|
16412
17047
|
};
|
|
16413
17048
|
}
|
|
16414
17049
|
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
17050
|
let outputValue = interpolate(
|
|
16424
17051
|
this.chartNode.data.text,
|
|
16425
|
-
|
|
17052
|
+
inputs,
|
|
16426
17053
|
context.graphInputNodeValues,
|
|
16427
17054
|
// Pass graph inputs
|
|
16428
|
-
context.contextValues
|
|
17055
|
+
context.contextValues,
|
|
16429
17056
|
// Pass context values
|
|
17057
|
+
{ coerceBareVariableDataValues: true }
|
|
16430
17058
|
);
|
|
16431
17059
|
if (this.chartNode.data.normalizeLineEndings) {
|
|
16432
17060
|
outputValue = outputValue.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
@@ -16469,7 +17097,7 @@ __export(openai_exports, {
|
|
|
16469
17097
|
openaiModels: () => openaiModels,
|
|
16470
17098
|
streamChatCompletions: () => streamChatCompletions
|
|
16471
17099
|
});
|
|
16472
|
-
var
|
|
17100
|
+
var import_lodash_es6 = require("lodash");
|
|
16473
17101
|
|
|
16474
17102
|
// src/utils/fetchEventSource.ts
|
|
16475
17103
|
var EventSourceResponse = class extends Response {
|
|
@@ -16775,7 +17403,7 @@ var openaiModels = {
|
|
|
16775
17403
|
displayName: "Local Model"
|
|
16776
17404
|
}
|
|
16777
17405
|
};
|
|
16778
|
-
var openAiModelOptions = (0,
|
|
17406
|
+
var openAiModelOptions = (0, import_lodash_es6.orderBy)(
|
|
16779
17407
|
Object.entries(openaiModels).map(([id, { displayName }]) => ({
|
|
16780
17408
|
value: id,
|
|
16781
17409
|
label: displayName
|
|
@@ -24578,16 +25206,17 @@ var PromptNodeImpl = class extends NodeImpl {
|
|
|
24578
25206
|
dataType: "boolean"
|
|
24579
25207
|
});
|
|
24580
25208
|
}
|
|
24581
|
-
const
|
|
25209
|
+
const inputReferences = extractInterpolationVariableReferences(this.data.promptText);
|
|
25210
|
+
const fixedInputIds = new Set(inputs.map((input) => input.id));
|
|
24582
25211
|
inputs = [
|
|
24583
25212
|
...inputs,
|
|
24584
|
-
...(
|
|
25213
|
+
...inputReferences.filter(({ baseName }) => !fixedInputIds.has(baseName)).map(({ baseName, hasPath }) => {
|
|
24585
25214
|
return createInterpolationInputDefinition({
|
|
24586
|
-
interpolationName:
|
|
24587
|
-
dataType: "string",
|
|
25215
|
+
interpolationName: baseName,
|
|
25216
|
+
dataType: hasPath ? "any" : "string",
|
|
24588
25217
|
required: false
|
|
24589
25218
|
});
|
|
24590
|
-
})
|
|
25219
|
+
})
|
|
24591
25220
|
];
|
|
24592
25221
|
return inputs;
|
|
24593
25222
|
}
|
|
@@ -24698,18 +25327,12 @@ var PromptNodeImpl = class extends NodeImpl {
|
|
|
24698
25327
|
};
|
|
24699
25328
|
}
|
|
24700
25329
|
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
25330
|
let outputValue = interpolate(
|
|
24709
25331
|
this.chartNode.data.promptText,
|
|
24710
|
-
|
|
25332
|
+
inputs,
|
|
24711
25333
|
context.graphInputNodeValues,
|
|
24712
|
-
context.contextValues
|
|
25334
|
+
context.contextValues,
|
|
25335
|
+
{ coerceBareVariableDataValues: true }
|
|
24713
25336
|
);
|
|
24714
25337
|
outputValue = outputValue.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
24715
25338
|
const type = getInputOrData(this.data, inputs, "type", "string");
|
|
@@ -25258,6 +25881,7 @@ var import_ts_dedent10 = require("ts-dedent");
|
|
|
25258
25881
|
|
|
25259
25882
|
// src/model/nodes/jsValueInterpolation.ts
|
|
25260
25883
|
var import_ts_dedent9 = require("ts-dedent");
|
|
25884
|
+
var MISSING_INTERPOLATION_HELPER_MESSAGE = "This CodeRunner must honor CodeRunnerOptions.interpolationHelperIdentifier to resolve JSONPath or @graphInputs/@context interpolation.";
|
|
25261
25885
|
function escapeRegExp2(value) {
|
|
25262
25886
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25263
25887
|
}
|
|
@@ -25276,34 +25900,39 @@ function getSafeJsValueInterpolationIdentifier(source, baseIdentifier) {
|
|
|
25276
25900
|
function buildJsValuePreview(source, maxLines) {
|
|
25277
25901
|
return source.split("\n").slice(0, maxLines).join("\n").trim();
|
|
25278
25902
|
}
|
|
25279
|
-
function isSpecialReference(inputName) {
|
|
25280
|
-
return inputName.startsWith("@graphInputs.") || inputName.startsWith("@context.");
|
|
25281
|
-
}
|
|
25282
25903
|
function isSimpleIdentifier(value) {
|
|
25283
25904
|
return /^[A-Za-z_$][\w$]*$/.test(value);
|
|
25284
25905
|
}
|
|
25285
25906
|
function getUserFacingInputName(inputName) {
|
|
25286
25907
|
return isSimpleIdentifier(inputName) ? inputName : `{{${inputName}}}`;
|
|
25287
25908
|
}
|
|
25288
|
-
function buildJsValueReference(
|
|
25289
|
-
var _a;
|
|
25290
|
-
if (!
|
|
25909
|
+
function buildJsValueReference(token, interpolationContext, options2) {
|
|
25910
|
+
var _a, _b;
|
|
25911
|
+
if (!token.tokenName || !token.reference) {
|
|
25291
25912
|
return "undefined";
|
|
25292
25913
|
}
|
|
25293
|
-
|
|
25294
|
-
|
|
25914
|
+
const isBareVariableReference = token.reference.source === "variable" && token.reference.jsonPath === void 0;
|
|
25915
|
+
if (isBareVariableReference) {
|
|
25916
|
+
return ((_a = options2.localIdentifiers) == null ? void 0 : _a.has(token.reference.baseName)) ? token.reference.baseName : `${interpolationContext.inputsIdentifier}[${JSON.stringify(token.reference.baseName)}].value`;
|
|
25295
25917
|
}
|
|
25296
|
-
|
|
25918
|
+
const isLocalReference = token.reference.source === "variable" && ((_b = options2.localIdentifiers) == null ? void 0 : _b.has(token.reference.baseName));
|
|
25919
|
+
const sourceInputs = isLocalReference ? `{ ${JSON.stringify(token.reference.baseName)}: { type: 'any', value: ${token.reference.baseName} } }` : interpolationContext.inputsIdentifier;
|
|
25920
|
+
const resolveExpression = `${interpolationContext.interpolationHelperIdentifier}(${sourceInputs}, ${JSON.stringify(
|
|
25921
|
+
token.tokenName
|
|
25922
|
+
)}, ${interpolationContext.graphInputsIdentifier}, ${interpolationContext.contextIdentifier})`;
|
|
25923
|
+
return `(typeof ${interpolationContext.interpolationHelperIdentifier} === 'function'
|
|
25924
|
+
? ${resolveExpression}
|
|
25925
|
+
: (() => { throw new Error(${JSON.stringify(MISSING_INTERPOLATION_HELPER_MESSAGE)}); })())`;
|
|
25297
25926
|
}
|
|
25298
|
-
function formatJsValuePreviewValue(
|
|
25299
|
-
var _a
|
|
25300
|
-
if (!
|
|
25927
|
+
function formatJsValuePreviewValue(token, inputs, options2) {
|
|
25928
|
+
var _a;
|
|
25929
|
+
if (!token.tokenName || !token.reference || token.reference.source !== "variable") {
|
|
25301
25930
|
return "undefined";
|
|
25302
25931
|
}
|
|
25303
|
-
if ((_a = options2.localIdentifiers) == null ? void 0 : _a.has(
|
|
25304
|
-
return
|
|
25932
|
+
if ((_a = options2.localIdentifiers) == null ? void 0 : _a.has(token.reference.baseName)) {
|
|
25933
|
+
return token.reference.jsonPath ? `{{${token.tokenName}}}` : token.reference.baseName;
|
|
25305
25934
|
}
|
|
25306
|
-
const value = (
|
|
25935
|
+
const value = resolveInterpolationExpressionRawValue(token.tokenName, { variables: inputs });
|
|
25307
25936
|
if (value === void 0) {
|
|
25308
25937
|
return "undefined";
|
|
25309
25938
|
}
|
|
@@ -25316,7 +25945,7 @@ function formatJsValuePreviewValue(inputName, inputs, options2) {
|
|
|
25316
25945
|
if (typeof value === "number" || typeof value === "boolean") {
|
|
25317
25946
|
return String(value);
|
|
25318
25947
|
}
|
|
25319
|
-
return getUserFacingInputName(
|
|
25948
|
+
return getUserFacingInputName(token.tokenName);
|
|
25320
25949
|
}
|
|
25321
25950
|
function getJsValueInterpolationInputNames(template, options2 = {}) {
|
|
25322
25951
|
return extractInterpolationVariables(template).filter((inputName) => {
|
|
@@ -25334,22 +25963,53 @@ function getJsValueInterpolationInputDefinitions(template, options2 = {}) {
|
|
|
25334
25963
|
);
|
|
25335
25964
|
}
|
|
25336
25965
|
function getJsValueInterpolationRuntimeContext(template, baseInputsIdentifier, options2 = {}) {
|
|
25966
|
+
const inputsIdentifier = getSafeJsValueInterpolationIdentifier(template, baseInputsIdentifier);
|
|
25967
|
+
const interpolationHelperIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
25968
|
+
`${template}
|
|
25969
|
+
${inputsIdentifier}`,
|
|
25970
|
+
`${baseInputsIdentifier}ResolveInterpolation`
|
|
25971
|
+
);
|
|
25972
|
+
const cloneCacheIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
25973
|
+
`${template}
|
|
25974
|
+
${inputsIdentifier}
|
|
25975
|
+
${interpolationHelperIdentifier}`,
|
|
25976
|
+
`${baseInputsIdentifier}CloneCache`
|
|
25977
|
+
);
|
|
25978
|
+
const graphInputsIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
25979
|
+
`${template}
|
|
25980
|
+
${inputsIdentifier}
|
|
25981
|
+
${interpolationHelperIdentifier}
|
|
25982
|
+
${cloneCacheIdentifier}`,
|
|
25983
|
+
`${baseInputsIdentifier}GraphInputs`
|
|
25984
|
+
);
|
|
25985
|
+
const contextIdentifier = getSafeJsValueInterpolationIdentifier(
|
|
25986
|
+
`${template}
|
|
25987
|
+
${inputsIdentifier}
|
|
25988
|
+
${interpolationHelperIdentifier}
|
|
25989
|
+
${cloneCacheIdentifier}
|
|
25990
|
+
${graphInputsIdentifier}`,
|
|
25991
|
+
`${baseInputsIdentifier}Context`
|
|
25992
|
+
);
|
|
25993
|
+
const parsedTemplate = parseInterpolationTemplate(template);
|
|
25337
25994
|
return {
|
|
25338
25995
|
inputNames: getJsValueInterpolationInputNames(template, options2),
|
|
25339
|
-
inputsIdentifier
|
|
25996
|
+
inputsIdentifier,
|
|
25997
|
+
interpolationHelperIdentifier,
|
|
25998
|
+
cloneCacheIdentifier,
|
|
25999
|
+
graphInputsIdentifier,
|
|
26000
|
+
contextIdentifier,
|
|
26001
|
+
requiresInterpolationHelper: parsedTemplate.tokens.some(
|
|
26002
|
+
(token) => token.reference !== void 0 && (token.reference.source !== "variable" || token.reference.jsonPath !== void 0)
|
|
26003
|
+
)
|
|
25340
26004
|
};
|
|
25341
26005
|
}
|
|
25342
|
-
function buildJsValueInterpolatedSource(template,
|
|
25343
|
-
return replaceInterpolationTokens(
|
|
25344
|
-
|
|
25345
|
-
|
|
25346
|
-
{
|
|
25347
|
-
trim: options2.trim ?? true
|
|
25348
|
-
}
|
|
25349
|
-
);
|
|
26006
|
+
function buildJsValueInterpolatedSource(template, interpolationContext, options2 = {}) {
|
|
26007
|
+
return replaceInterpolationTokens(template, (token) => buildJsValueReference(token, interpolationContext, options2), {
|
|
26008
|
+
trim: options2.trim ?? true
|
|
26009
|
+
});
|
|
25350
26010
|
}
|
|
25351
26011
|
function interpolateJsValuePreviewSource(template, inputs, options2 = {}) {
|
|
25352
|
-
return replaceInterpolationTokens(template, (token) => formatJsValuePreviewValue(token
|
|
26012
|
+
return replaceInterpolationTokens(template, (token) => formatJsValuePreviewValue(token, inputs, options2), {
|
|
25353
26013
|
trim: options2.trim ?? true
|
|
25354
26014
|
});
|
|
25355
26015
|
}
|
|
@@ -25445,50 +26105,86 @@ function buildCloneJsInputValueFunction() {
|
|
|
25445
26105
|
}
|
|
25446
26106
|
function buildClonedInputValueAssignments(inputNames, targetIdentifier, cacheIdentifier) {
|
|
25447
26107
|
return inputNames.map(
|
|
25448
|
-
(inputName) => `${targetIdentifier}[${JSON.stringify(inputName)}] =
|
|
25449
|
-
|
|
25450
|
-
|
|
26108
|
+
(inputName) => `${targetIdentifier}[${JSON.stringify(inputName)}] = (() => {
|
|
26109
|
+
const sourceDataValue = inputs[${JSON.stringify(inputName)}];
|
|
26110
|
+
return sourceDataValue == null
|
|
26111
|
+
? { type: 'any', value: undefined }
|
|
26112
|
+
: { ...sourceDataValue, value: cloneJsInputValue(sourceDataValue.value, ${cacheIdentifier}) };
|
|
26113
|
+
})();`
|
|
25451
26114
|
).join("\n");
|
|
25452
26115
|
}
|
|
25453
26116
|
function buildJsValueInputClonePreamble({
|
|
25454
26117
|
cacheIdentifier,
|
|
26118
|
+
contextIdentifier,
|
|
26119
|
+
graphInputsIdentifier,
|
|
25455
26120
|
inputsIdentifier
|
|
25456
26121
|
}) {
|
|
25457
26122
|
return import_ts_dedent9.dedent`
|
|
25458
26123
|
${buildCloneJsInputValueFunction()}
|
|
25459
26124
|
const ${inputsIdentifier} = Object.create(null);
|
|
25460
26125
|
const ${cacheIdentifier} = new WeakMap();
|
|
26126
|
+
const ${graphInputsIdentifier} = typeof graphInputs === 'undefined'
|
|
26127
|
+
? Object.create(null)
|
|
26128
|
+
: cloneJsInputValue(graphInputs, ${cacheIdentifier});
|
|
26129
|
+
const ${contextIdentifier} = typeof context === 'undefined'
|
|
26130
|
+
? Object.create(null)
|
|
26131
|
+
: cloneJsInputValue(context, ${cacheIdentifier});
|
|
25461
26132
|
`;
|
|
25462
26133
|
}
|
|
25463
26134
|
function buildJsValueInputsInitializer({
|
|
25464
|
-
|
|
25465
|
-
inputNames,
|
|
25466
|
-
inputsIdentifier
|
|
26135
|
+
interpolationContext
|
|
25467
26136
|
}) {
|
|
26137
|
+
const { cloneCacheIdentifier, contextIdentifier, graphInputsIdentifier, inputNames, inputsIdentifier } = interpolationContext;
|
|
25468
26138
|
return import_ts_dedent9.dedent`
|
|
25469
|
-
${buildJsValueInputClonePreamble({
|
|
25470
|
-
|
|
26139
|
+
${buildJsValueInputClonePreamble({
|
|
26140
|
+
cacheIdentifier: cloneCacheIdentifier,
|
|
26141
|
+
contextIdentifier,
|
|
26142
|
+
graphInputsIdentifier,
|
|
26143
|
+
inputsIdentifier
|
|
26144
|
+
})}
|
|
26145
|
+
${buildClonedInputValueAssignments(inputNames, inputsIdentifier, cloneCacheIdentifier)}
|
|
25471
26146
|
`;
|
|
25472
26147
|
}
|
|
25473
|
-
function
|
|
26148
|
+
function getJsValueInterpolationCodeRunnerOptions(options2, interpolationContext) {
|
|
26149
|
+
if (!interpolationContext.requiresInterpolationHelper) {
|
|
26150
|
+
return options2;
|
|
26151
|
+
}
|
|
26152
|
+
return {
|
|
26153
|
+
...options2,
|
|
26154
|
+
interpolationHelperIdentifier: interpolationContext.interpolationHelperIdentifier
|
|
26155
|
+
};
|
|
26156
|
+
}
|
|
26157
|
+
function sanitizeGeneratedJsValueText(text, inputNames, targetIdentifier, fallbackLabel, generatedIdentifiers = []) {
|
|
25474
26158
|
if (!text) {
|
|
25475
26159
|
return text;
|
|
25476
26160
|
}
|
|
25477
26161
|
let sanitized = text;
|
|
26162
|
+
const generatedFallbackLabel = inputNames.length === 1 ? `${fallbackLabel} ${getUserFacingInputName(inputNames[0])}` : fallbackLabel;
|
|
25478
26163
|
for (const inputName of inputNames) {
|
|
25479
26164
|
const userFacingInputName = getUserFacingInputName(inputName);
|
|
25480
26165
|
sanitized = sanitized.replaceAll(`${targetIdentifier}[${JSON.stringify(inputName)}]`, userFacingInputName).replaceAll(`${targetIdentifier}.${inputName}`, userFacingInputName);
|
|
25481
26166
|
}
|
|
25482
|
-
|
|
26167
|
+
for (const identifier of [...generatedIdentifiers].sort((left, right) => right.length - left.length)) {
|
|
26168
|
+
sanitized = sanitized.replaceAll(identifier, generatedFallbackLabel);
|
|
26169
|
+
}
|
|
26170
|
+
sanitized = sanitized.replaceAll(targetIdentifier, fallbackLabel);
|
|
26171
|
+
return sanitized;
|
|
25483
26172
|
}
|
|
25484
|
-
function sanitizeGeneratedJsValueError(error, inputNames, targetIdentifier, fallbackLabel) {
|
|
26173
|
+
function sanitizeGeneratedJsValueError(error, inputNames, targetIdentifier, fallbackLabel, generatedIdentifiers = []) {
|
|
25485
26174
|
const jsValueError = getError(error);
|
|
25486
|
-
jsValueError.message = sanitizeGeneratedJsValueText(
|
|
26175
|
+
jsValueError.message = sanitizeGeneratedJsValueText(
|
|
26176
|
+
jsValueError.message,
|
|
26177
|
+
inputNames,
|
|
26178
|
+
targetIdentifier,
|
|
26179
|
+
fallbackLabel,
|
|
26180
|
+
generatedIdentifiers
|
|
26181
|
+
) ?? jsValueError.message;
|
|
25487
26182
|
jsValueError.stack = sanitizeGeneratedJsValueText(
|
|
25488
26183
|
jsValueError.stack,
|
|
25489
26184
|
inputNames,
|
|
25490
26185
|
targetIdentifier,
|
|
25491
|
-
fallbackLabel
|
|
26186
|
+
fallbackLabel,
|
|
26187
|
+
generatedIdentifiers
|
|
25492
26188
|
);
|
|
25493
26189
|
return jsValueError;
|
|
25494
26190
|
}
|
|
@@ -25504,31 +26200,38 @@ var DEFAULT_CODE_NEW = import_ts_dedent10.dedent`
|
|
|
25504
26200
|
`;
|
|
25505
26201
|
var MAX_BODY_PREVIEW_LINES2 = 15;
|
|
25506
26202
|
var CODE_NEW_INPUTS_IDENTIFIER = "__codeNewInputs";
|
|
25507
|
-
var CODE_NEW_INPUT_CLONE_CACHE_IDENTIFIER = "codeNewInputCloneCache";
|
|
25508
26203
|
var CODE_NEW_OUTPUT_PORT_ID = "output";
|
|
25509
26204
|
function buildCodeNewPreview(code) {
|
|
25510
26205
|
return buildJsValuePreview(code, MAX_BODY_PREVIEW_LINES2);
|
|
25511
26206
|
}
|
|
25512
|
-
function buildCodeNewRuntimeSource(code,
|
|
25513
|
-
return buildJsValueInterpolatedSource(code,
|
|
26207
|
+
function buildCodeNewRuntimeSource(code, interpolationContext) {
|
|
26208
|
+
return buildJsValueInterpolatedSource(code, interpolationContext, { trim: false });
|
|
25514
26209
|
}
|
|
25515
|
-
function buildCodeNewInputsInitializer(
|
|
26210
|
+
function buildCodeNewInputsInitializer(interpolationContext) {
|
|
25516
26211
|
return buildJsValueInputsInitializer({
|
|
25517
|
-
|
|
25518
|
-
inputNames,
|
|
25519
|
-
inputsIdentifier
|
|
26212
|
+
interpolationContext
|
|
25520
26213
|
});
|
|
25521
26214
|
}
|
|
25522
26215
|
function interpolateCodeNewSource(code, inputs) {
|
|
25523
26216
|
return interpolateJsValuePreviewSource(code, inputs, { trim: false });
|
|
25524
26217
|
}
|
|
25525
|
-
function sanitizeCodeNewError(error,
|
|
25526
|
-
return sanitizeGeneratedJsValueError(
|
|
26218
|
+
function sanitizeCodeNewError(error, interpolationContext) {
|
|
26219
|
+
return sanitizeGeneratedJsValueError(
|
|
26220
|
+
error,
|
|
26221
|
+
interpolationContext.inputNames,
|
|
26222
|
+
interpolationContext.inputsIdentifier,
|
|
26223
|
+
"code input",
|
|
26224
|
+
[
|
|
26225
|
+
interpolationContext.cloneCacheIdentifier,
|
|
26226
|
+
interpolationContext.contextIdentifier,
|
|
26227
|
+
interpolationContext.graphInputsIdentifier,
|
|
26228
|
+
interpolationContext.interpolationHelperIdentifier
|
|
26229
|
+
]
|
|
26230
|
+
);
|
|
25527
26231
|
}
|
|
25528
26232
|
function buildCodeNewWrapper(code, interpolationContext) {
|
|
25529
|
-
const { inputNames, inputsIdentifier } = interpolationContext;
|
|
25530
26233
|
const beforeUserCodeLines = [
|
|
25531
|
-
...buildCodeNewInputsInitializer(
|
|
26234
|
+
...buildCodeNewInputsInitializer(interpolationContext).split(/\r?\n/),
|
|
25532
26235
|
"",
|
|
25533
26236
|
"const __codeNewResult = await (async () => {"
|
|
25534
26237
|
];
|
|
@@ -25543,7 +26246,7 @@ function buildCodeNewWrapper(code, interpolationContext) {
|
|
|
25543
26246
|
"};"
|
|
25544
26247
|
];
|
|
25545
26248
|
return {
|
|
25546
|
-
source: [...beforeUserCodeLines, buildCodeNewRuntimeSource(code,
|
|
26249
|
+
source: [...beforeUserCodeLines, buildCodeNewRuntimeSource(code, interpolationContext), ...afterUserCodeLines].join(
|
|
25547
26250
|
"\n"
|
|
25548
26251
|
),
|
|
25549
26252
|
userCodeLineOffset: beforeUserCodeLines.length
|
|
@@ -25628,13 +26331,12 @@ var CodeNewNodeImpl = class extends NodeImpl {
|
|
|
25628
26331
|
async process(inputs, context) {
|
|
25629
26332
|
const sourceUrl = buildCodeNodeSourceUrl(this.chartNode.id);
|
|
25630
26333
|
const interpolationContext = getJsValueInterpolationRuntimeContext(this.data.code, CODE_NEW_INPUTS_IDENTIFIER);
|
|
25631
|
-
const { inputNames, inputsIdentifier } = interpolationContext;
|
|
25632
26334
|
const { source, userCodeLineOffset } = buildCodeNewWrapper(this.data.code, interpolationContext);
|
|
25633
26335
|
try {
|
|
25634
26336
|
const outputs = await context.codeRunner.runCode(
|
|
25635
26337
|
appendCodeNodeSourceUrl(source, sourceUrl),
|
|
25636
26338
|
inputs,
|
|
25637
|
-
ALL_CODE_RUNNER_OPTIONS,
|
|
26339
|
+
getJsValueInterpolationCodeRunnerOptions(ALL_CODE_RUNNER_OPTIONS, interpolationContext),
|
|
25638
26340
|
context.graphInputNodeValues,
|
|
25639
26341
|
context.contextValues
|
|
25640
26342
|
);
|
|
@@ -25648,7 +26350,7 @@ var CodeNewNodeImpl = class extends NodeImpl {
|
|
|
25648
26350
|
sourceUrl,
|
|
25649
26351
|
userCodeLineOffset
|
|
25650
26352
|
});
|
|
25651
|
-
throw sanitizeCodeNewError(enrichedError,
|
|
26353
|
+
throw sanitizeCodeNewError(enrichedError, interpolationContext);
|
|
25652
26354
|
}
|
|
25653
26355
|
}
|
|
25654
26356
|
};
|
|
@@ -25661,32 +26363,39 @@ var CODE_RUNTIME_HELPER_MESSAGE3 = 'Node execution also provides "require" and "
|
|
|
25661
26363
|
var DEFAULT_EXPRESSION = '{{a}} == "123" ? {{b}} : {{c}}';
|
|
25662
26364
|
var MAX_BODY_PREVIEW_LINES3 = 15;
|
|
25663
26365
|
var EXPRESSION_INPUTS_IDENTIFIER = "__expressionInputs";
|
|
25664
|
-
var EXPRESSION_INPUT_CLONE_CACHE_IDENTIFIER = "expressionInputCloneCache";
|
|
25665
26366
|
var EXPRESSION_OUTPUT_PORT_ID = "output";
|
|
25666
26367
|
function buildExpressionPreview(expression) {
|
|
25667
26368
|
return buildJsValuePreview(expression, MAX_BODY_PREVIEW_LINES3);
|
|
25668
26369
|
}
|
|
25669
|
-
function buildExpressionRuntimeSource(expression,
|
|
25670
|
-
return buildJsValueInterpolatedSource(expression,
|
|
26370
|
+
function buildExpressionRuntimeSource(expression, interpolationContext) {
|
|
26371
|
+
return buildJsValueInterpolatedSource(expression, interpolationContext);
|
|
25671
26372
|
}
|
|
25672
|
-
function buildExpressionInputsInitializer(
|
|
26373
|
+
function buildExpressionInputsInitializer(interpolationContext) {
|
|
25673
26374
|
return buildJsValueInputsInitializer({
|
|
25674
|
-
|
|
25675
|
-
inputNames,
|
|
25676
|
-
inputsIdentifier
|
|
26375
|
+
interpolationContext
|
|
25677
26376
|
});
|
|
25678
26377
|
}
|
|
25679
26378
|
function interpolateExpressionSource(expression, inputs) {
|
|
25680
26379
|
return interpolateJsValuePreviewSource(expression, inputs);
|
|
25681
26380
|
}
|
|
25682
|
-
function sanitizeExpressionError(error,
|
|
25683
|
-
return sanitizeGeneratedJsValueError(
|
|
26381
|
+
function sanitizeExpressionError(error, interpolationContext) {
|
|
26382
|
+
return sanitizeGeneratedJsValueError(
|
|
26383
|
+
error,
|
|
26384
|
+
interpolationContext.inputNames,
|
|
26385
|
+
interpolationContext.inputsIdentifier,
|
|
26386
|
+
"expression input",
|
|
26387
|
+
[
|
|
26388
|
+
interpolationContext.cloneCacheIdentifier,
|
|
26389
|
+
interpolationContext.contextIdentifier,
|
|
26390
|
+
interpolationContext.graphInputsIdentifier,
|
|
26391
|
+
interpolationContext.interpolationHelperIdentifier
|
|
26392
|
+
]
|
|
26393
|
+
);
|
|
25684
26394
|
}
|
|
25685
26395
|
function buildExpressionWrapper(expression, interpolationContext) {
|
|
25686
|
-
const
|
|
25687
|
-
const expressionSource = buildExpressionRuntimeSource(expression, inputsIdentifier);
|
|
26396
|
+
const expressionSource = buildExpressionRuntimeSource(expression, interpolationContext);
|
|
25688
26397
|
return import_ts_dedent11.dedent`
|
|
25689
|
-
${buildExpressionInputsInitializer(
|
|
26398
|
+
${buildExpressionInputsInitializer(interpolationContext)}
|
|
25690
26399
|
|
|
25691
26400
|
return {
|
|
25692
26401
|
output: {
|
|
@@ -25764,18 +26473,17 @@ var ExpressionNodeImpl = class extends NodeImpl {
|
|
|
25764
26473
|
this.data.expression,
|
|
25765
26474
|
EXPRESSION_INPUTS_IDENTIFIER
|
|
25766
26475
|
);
|
|
25767
|
-
const { inputNames, inputsIdentifier } = interpolationContext;
|
|
25768
26476
|
const source = buildExpressionWrapper(this.data.expression, interpolationContext);
|
|
25769
26477
|
try {
|
|
25770
26478
|
return await context.codeRunner.runCode(
|
|
25771
26479
|
source,
|
|
25772
26480
|
inputs,
|
|
25773
|
-
ALL_CODE_RUNNER_OPTIONS,
|
|
26481
|
+
getJsValueInterpolationCodeRunnerOptions(ALL_CODE_RUNNER_OPTIONS, interpolationContext),
|
|
25774
26482
|
context.graphInputNodeValues,
|
|
25775
26483
|
context.contextValues
|
|
25776
26484
|
);
|
|
25777
26485
|
} catch (error) {
|
|
25778
|
-
throw sanitizeExpressionError(error,
|
|
26486
|
+
throw sanitizeExpressionError(error, interpolationContext);
|
|
25779
26487
|
}
|
|
25780
26488
|
}
|
|
25781
26489
|
};
|
|
@@ -26998,7 +27706,8 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
26998
27706
|
data: {
|
|
26999
27707
|
graphId: "",
|
|
27000
27708
|
useErrorOutput: false,
|
|
27001
|
-
useAsGraphPartialOutput: false
|
|
27709
|
+
useAsGraphPartialOutput: false,
|
|
27710
|
+
skipUnusedOutputs: false
|
|
27002
27711
|
}
|
|
27003
27712
|
};
|
|
27004
27713
|
return chartNode;
|
|
@@ -27037,6 +27746,12 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
27037
27746
|
type: "toggle",
|
|
27038
27747
|
label: "Use Error Output",
|
|
27039
27748
|
dataKey: "useErrorOutput"
|
|
27749
|
+
},
|
|
27750
|
+
{
|
|
27751
|
+
type: "toggle",
|
|
27752
|
+
label: "Skip unused outputs",
|
|
27753
|
+
dataKey: "skipUnusedOutputs",
|
|
27754
|
+
helperMessage: "Only run branches needed by connected outputs. Skipped branches also skip their side effects and errors. Runs the full subgraph for Run to here, partial-output forwarding, or a connected Error output."
|
|
27040
27755
|
}
|
|
27041
27756
|
];
|
|
27042
27757
|
if (this.data.graphId) {
|
|
@@ -27078,27 +27793,31 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
27078
27793
|
}
|
|
27079
27794
|
const boundary = ((_a = context.getGraphBoundary) == null ? void 0 : _a.call(context, project, this.data.graphId)) ?? getGraphBoundary(project, this.data.graphId);
|
|
27080
27795
|
const inputData = buildGraphBoundaryInputData(boundary, inputs, this.data.inputData);
|
|
27081
|
-
const shouldRunWholeGraph =
|
|
27082
|
-
const
|
|
27083
|
-
if (
|
|
27084
|
-
return
|
|
27796
|
+
const shouldRunWholeGraph = this.data.skipUnusedOutputs !== true || context.isDirectRunTarget || this.data.useAsGraphPartialOutput === true || this.data.useErrorOutput === true && context.activeOutputPortIds.has("error");
|
|
27797
|
+
const requestedGraphOutputIds = shouldRunWholeGraph ? void 0 : boundary.outputs.filter((output) => context.activeOutputPortIds.has(output.portId)).map((output) => output.id);
|
|
27798
|
+
if ((requestedGraphOutputIds == null ? void 0 : requestedGraphOutputIds.length) === 0) {
|
|
27799
|
+
return buildOptimizedSubgraphOutputs(boundary, [], {}, 0, this.data.useErrorOutput);
|
|
27085
27800
|
}
|
|
27086
27801
|
const subGraphProcessor = context.createSubProcessor(this.data.graphId, { signal: context.signal });
|
|
27087
|
-
if (!shouldRunWholeGraph) {
|
|
27088
|
-
subGraphProcessor.runToNodeIds = requestedGraphOutputNodeIds;
|
|
27089
|
-
}
|
|
27090
27802
|
try {
|
|
27091
27803
|
const startTime = Date.now();
|
|
27092
27804
|
const graphOutputs = await subGraphProcessor.processGraph(
|
|
27093
27805
|
context,
|
|
27094
27806
|
inputData,
|
|
27095
|
-
context.contextValues
|
|
27807
|
+
context.contextValues,
|
|
27808
|
+
requestedGraphOutputIds ? { requestedGraphOutputIds } : void 0
|
|
27096
27809
|
);
|
|
27097
|
-
const outputs = shouldRunWholeGraph ? graphOutputs : {
|
|
27098
|
-
...buildExcludedGraphBoundaryOutputs(boundary),
|
|
27099
|
-
...graphOutputs
|
|
27100
|
-
};
|
|
27101
27810
|
const duration = Date.now() - startTime;
|
|
27811
|
+
if (requestedGraphOutputIds) {
|
|
27812
|
+
return buildOptimizedSubgraphOutputs(
|
|
27813
|
+
boundary,
|
|
27814
|
+
requestedGraphOutputIds,
|
|
27815
|
+
graphOutputs,
|
|
27816
|
+
duration,
|
|
27817
|
+
this.data.useErrorOutput
|
|
27818
|
+
);
|
|
27819
|
+
}
|
|
27820
|
+
const outputs = graphOutputs;
|
|
27102
27821
|
if (this.data.useErrorOutput) {
|
|
27103
27822
|
outputs["error"] = {
|
|
27104
27823
|
type: "control-flow-excluded",
|
|
@@ -27126,28 +27845,33 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
27126
27845
|
}
|
|
27127
27846
|
};
|
|
27128
27847
|
var subGraphNode = nodeDefinition(SubGraphNodeImpl, "Subgraph");
|
|
27129
|
-
function
|
|
27848
|
+
function buildOptimizedSubgraphOutputs(boundary, requestedOutputIds, graphOutputs, duration, useErrorOutput) {
|
|
27130
27849
|
const outputs = buildExcludedGraphBoundaryOutputs(boundary);
|
|
27850
|
+
for (const outputId of requestedOutputIds) {
|
|
27851
|
+
if (Object.hasOwn(graphOutputs, outputId)) {
|
|
27852
|
+
outputs[outputId] = graphOutputs[outputId];
|
|
27853
|
+
} else {
|
|
27854
|
+
delete outputs[outputId];
|
|
27855
|
+
}
|
|
27856
|
+
}
|
|
27131
27857
|
if (useErrorOutput) {
|
|
27132
27858
|
outputs["error"] = {
|
|
27133
27859
|
type: "control-flow-excluded",
|
|
27134
27860
|
value: void 0
|
|
27135
27861
|
};
|
|
27136
27862
|
}
|
|
27137
|
-
outputs
|
|
27138
|
-
type: "number",
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
|
|
27142
|
-
|
|
27143
|
-
value: 0
|
|
27144
|
-
};
|
|
27863
|
+
if (!boundary.outputs.some((output) => output.id === "cost")) {
|
|
27864
|
+
outputs["cost"] = graphOutputs["cost"] ?? { type: "number", value: 0 };
|
|
27865
|
+
}
|
|
27866
|
+
if (!boundary.outputs.some((output) => output.id === "duration")) {
|
|
27867
|
+
outputs["duration"] = { type: "number", value: duration };
|
|
27868
|
+
}
|
|
27145
27869
|
return outputs;
|
|
27146
27870
|
}
|
|
27147
27871
|
|
|
27148
27872
|
// src/model/nodes/ArrayNode.ts
|
|
27149
27873
|
var import_non_secure27 = require("nanoid/non-secure");
|
|
27150
|
-
var
|
|
27874
|
+
var import_lodash_es7 = require("lodash");
|
|
27151
27875
|
var import_ts_dedent21 = require("ts-dedent");
|
|
27152
27876
|
|
|
27153
27877
|
// src/model/nodes/variadicPortIndex.ts
|
|
@@ -27275,7 +27999,7 @@ var ArrayNodeImpl = class extends NodeImpl {
|
|
|
27275
27999
|
if (Array.isArray(input == null ? void 0 : input.value)) {
|
|
27276
28000
|
for (const value of (input == null ? void 0 : input.value) ?? []) {
|
|
27277
28001
|
if (this.data.flattenDeep) {
|
|
27278
|
-
outputArray.push(...Array.isArray(value) ? (0,
|
|
28002
|
+
outputArray.push(...Array.isArray(value) ? (0, import_lodash_es7.flattenDeep)(value) : [value]);
|
|
27279
28003
|
} else {
|
|
27280
28004
|
outputArray.push(value);
|
|
27281
28005
|
}
|
|
@@ -27432,7 +28156,7 @@ function createMatchedOutput(value) {
|
|
|
27432
28156
|
|
|
27433
28157
|
// src/model/nodes/AssemblePromptNode.ts
|
|
27434
28158
|
var import_non_secure29 = require("nanoid/non-secure");
|
|
27435
|
-
var
|
|
28159
|
+
var import_lodash_es8 = require("lodash");
|
|
27436
28160
|
var import_ts_dedent23 = require("ts-dedent");
|
|
27437
28161
|
var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
27438
28162
|
static create() {
|
|
@@ -27525,7 +28249,7 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
27525
28249
|
const output = {};
|
|
27526
28250
|
const isLastMessageCacheBreakpoint = getInputOrData(this.data, inputs, "isLastMessageCacheBreakpoint", "boolean");
|
|
27527
28251
|
const outMessages = [];
|
|
27528
|
-
const inputMessages = (0,
|
|
28252
|
+
const inputMessages = (0, import_lodash_es8.orderBy)(
|
|
27529
28253
|
Object.entries(inputs).filter(([key]) => key.startsWith("message")),
|
|
27530
28254
|
([key]) => key,
|
|
27531
28255
|
"asc"
|
|
@@ -27570,7 +28294,6 @@ var assemblePromptNode = nodeDefinition(AssemblePromptNodeImpl, "Assemble Prompt
|
|
|
27570
28294
|
// src/model/nodes/ExtractYamlNode.ts
|
|
27571
28295
|
var import_non_secure30 = require("nanoid/non-secure");
|
|
27572
28296
|
var import_yaml = __toESM(require("yaml"), 1);
|
|
27573
|
-
var import_jsonpath_plus = require("jsonpath-plus");
|
|
27574
28297
|
var import_ts_dedent24 = require("ts-dedent");
|
|
27575
28298
|
var ExtractYamlNodeImpl = class extends NodeImpl {
|
|
27576
28299
|
static create() {
|
|
@@ -27719,9 +28442,9 @@ var ExtractYamlNodeImpl = class extends NodeImpl {
|
|
|
27719
28442
|
let matches = [];
|
|
27720
28443
|
if (objectPath) {
|
|
27721
28444
|
try {
|
|
27722
|
-
const extractedValue = (
|
|
27723
|
-
matches = extractedValue;
|
|
27724
|
-
yamlObject =
|
|
28445
|
+
const extractedValue = evaluateJsonPath(yamlObject, objectPath, true);
|
|
28446
|
+
matches = extractedValue == null ? [] : extractedValue;
|
|
28447
|
+
yamlObject = matches.length > 0 ? matches[0] : void 0;
|
|
27725
28448
|
} catch (err) {
|
|
27726
28449
|
return {
|
|
27727
28450
|
["noMatch"]: {
|
|
@@ -27743,7 +28466,7 @@ var ExtractYamlNodeImpl = class extends NodeImpl {
|
|
|
27743
28466
|
["output"]: yamlObject === void 0 ? {
|
|
27744
28467
|
type: "control-flow-excluded",
|
|
27745
28468
|
value: void 0
|
|
27746
|
-
} :
|
|
28469
|
+
} : objectPath ? {
|
|
27747
28470
|
type: "any",
|
|
27748
28471
|
value: yamlObject
|
|
27749
28472
|
} : {
|
|
@@ -28065,7 +28788,7 @@ var trimChatMessagesNode = nodeDefinition(TrimChatMessagesNodeImpl, "Trim Chat M
|
|
|
28065
28788
|
|
|
28066
28789
|
// src/model/nodes/ExternalCallNode.ts
|
|
28067
28790
|
var import_non_secure33 = require("nanoid/non-secure");
|
|
28068
|
-
var
|
|
28791
|
+
var import_lodash_es9 = require("lodash");
|
|
28069
28792
|
var import_ts_dedent27 = require("ts-dedent");
|
|
28070
28793
|
var ExternalCallNodeImpl = class extends NodeImpl {
|
|
28071
28794
|
static create() {
|
|
@@ -28160,7 +28883,7 @@ var ExternalCallNodeImpl = class extends NodeImpl {
|
|
|
28160
28883
|
}
|
|
28161
28884
|
}
|
|
28162
28885
|
const fn = context.externalFunctions[functionName];
|
|
28163
|
-
const externalContext = (0,
|
|
28886
|
+
const externalContext = (0, import_lodash_es9.omit)(context, ["setGlobal"]);
|
|
28164
28887
|
if (!fn) {
|
|
28165
28888
|
if (this.data.useErrorOutput) {
|
|
28166
28889
|
return {
|
|
@@ -28214,7 +28937,6 @@ var externalCallNode = nodeDefinition(ExternalCallNodeImpl, "External Call");
|
|
|
28214
28937
|
|
|
28215
28938
|
// src/model/nodes/ExtractObjectPathNode.ts
|
|
28216
28939
|
var import_non_secure34 = require("nanoid/non-secure");
|
|
28217
|
-
var import_jsonpath_plus2 = require("jsonpath-plus");
|
|
28218
28940
|
var import_ts_dedent28 = require("ts-dedent");
|
|
28219
28941
|
var RESERVED_INPUT_IDS = /* @__PURE__ */ new Set(["object"]);
|
|
28220
28942
|
function getExtractObjectPathInterpolationInputNames(path) {
|
|
@@ -28336,7 +29058,7 @@ var ExtractObjectPathNodeImpl = class extends NodeImpl {
|
|
|
28336
29058
|
const inputPath = usePathInput ? rawPath.trim() : interpolateExtractObjectPathSource(rawPath, inputs, context.graphInputNodeValues, context.contextValues);
|
|
28337
29059
|
let matches;
|
|
28338
29060
|
try {
|
|
28339
|
-
const match9 = (
|
|
29061
|
+
const match9 = evaluateJsonPath(inputObject, inputPath, true);
|
|
28340
29062
|
matches = match9 == null ? [] : match9;
|
|
28341
29063
|
} catch (err) {
|
|
28342
29064
|
matches = [];
|
|
@@ -29684,6 +30406,18 @@ var waitForEventNode = nodeDefinition(WaitForEventNodeImpl, "Wait For Event");
|
|
|
29684
30406
|
// src/model/nodes/ToolNode.ts
|
|
29685
30407
|
var import_non_secure49 = require("nanoid/non-secure");
|
|
29686
30408
|
var import_ts_dedent41 = require("ts-dedent");
|
|
30409
|
+
var TOOL_NODE_BODY_PREVIEW_MAX_LINES = 14;
|
|
30410
|
+
function getToolNodeBodyPreview(data) {
|
|
30411
|
+
const [name = "", ...descriptionLines] = buildNodeBodyPreview(
|
|
30412
|
+
`${data.name}
|
|
30413
|
+
${data.description}`,
|
|
30414
|
+
TOOL_NODE_BODY_PREVIEW_MAX_LINES
|
|
30415
|
+
).split("\n");
|
|
30416
|
+
return {
|
|
30417
|
+
name,
|
|
30418
|
+
description: descriptionLines.join("\n")
|
|
30419
|
+
};
|
|
30420
|
+
}
|
|
29687
30421
|
var GptFunctionNodeImpl = class extends NodeImpl {
|
|
29688
30422
|
static create() {
|
|
29689
30423
|
const chartNode = {
|
|
@@ -29734,17 +30468,17 @@ var GptFunctionNodeImpl = class extends NodeImpl {
|
|
|
29734
30468
|
description: "The schema of the tool that the LLM will see as available to call"
|
|
29735
30469
|
});
|
|
29736
30470
|
}
|
|
29737
|
-
const
|
|
30471
|
+
const inputReferences = this.data.useSchemaInput ? [] : extractInterpolationVariableReferences(this.data.schema);
|
|
29738
30472
|
inputs = [
|
|
29739
30473
|
...inputs,
|
|
29740
|
-
...(
|
|
30474
|
+
...inputReferences.map(({ baseName, hasPath }) => {
|
|
29741
30475
|
return createInterpolationInputDefinition({
|
|
29742
|
-
id: `input-${
|
|
29743
|
-
interpolationName:
|
|
29744
|
-
dataType: "string",
|
|
29745
|
-
description: `An interpolated value in the schema named '${
|
|
30476
|
+
id: `input-${baseName}`,
|
|
30477
|
+
interpolationName: baseName,
|
|
30478
|
+
dataType: hasPath ? "any" : "string",
|
|
30479
|
+
description: `An interpolated value in the schema named '${baseName}'`
|
|
29746
30480
|
});
|
|
29747
|
-
})
|
|
30481
|
+
})
|
|
29748
30482
|
];
|
|
29749
30483
|
return inputs;
|
|
29750
30484
|
}
|
|
@@ -29816,10 +30550,12 @@ var GptFunctionNodeImpl = class extends NodeImpl {
|
|
|
29816
30550
|
];
|
|
29817
30551
|
}
|
|
29818
30552
|
getBody() {
|
|
30553
|
+
const preview = getToolNodeBodyPreview(this.data);
|
|
29819
30554
|
return {
|
|
29820
|
-
type: "
|
|
29821
|
-
|
|
29822
|
-
|
|
30555
|
+
type: "colorized",
|
|
30556
|
+
language: "prompt-interpolation-markdown",
|
|
30557
|
+
theme: "prompt-interpolation",
|
|
30558
|
+
text: [preview.name, preview.description].filter(Boolean).join("\n")
|
|
29823
30559
|
};
|
|
29824
30560
|
}
|
|
29825
30561
|
static getUIData() {
|
|
@@ -29832,7 +30568,7 @@ ${this.data.description}`
|
|
|
29832
30568
|
group: ["AI"]
|
|
29833
30569
|
};
|
|
29834
30570
|
}
|
|
29835
|
-
async process(inputs) {
|
|
30571
|
+
async process(inputs, context) {
|
|
29836
30572
|
const name = getInputOrData(this.data, inputs, "name");
|
|
29837
30573
|
const description = getInputOrData(this.data, inputs, "description");
|
|
29838
30574
|
const resultHandling = this.data.resultHandling === "return-direct" ? "return-direct" : "continue";
|
|
@@ -29840,16 +30576,21 @@ ${this.data.description}`
|
|
|
29840
30576
|
if (this.data.useSchemaInput) {
|
|
29841
30577
|
schema = coerceType(inputs["schema"], "object");
|
|
29842
30578
|
} else {
|
|
29843
|
-
const inputMap = keys(inputs).filter((key) => key.startsWith("input")).reduce(
|
|
30579
|
+
const inputMap = keys(inputs).filter((key) => key.startsWith("input-")).reduce(
|
|
29844
30580
|
(acc, key) => {
|
|
29845
|
-
const stringValue = coerceTypeOptional(inputs[key], "string") ?? "";
|
|
29846
30581
|
const interpolationKey = key.slice("input-".length);
|
|
29847
|
-
acc[interpolationKey] =
|
|
30582
|
+
acc[interpolationKey] = inputs[key];
|
|
29848
30583
|
return acc;
|
|
29849
30584
|
},
|
|
29850
30585
|
{}
|
|
29851
30586
|
);
|
|
29852
|
-
const interpolated = interpolate(
|
|
30587
|
+
const interpolated = interpolate(
|
|
30588
|
+
this.data.schema,
|
|
30589
|
+
inputMap,
|
|
30590
|
+
context == null ? void 0 : context.graphInputNodeValues,
|
|
30591
|
+
context == null ? void 0 : context.contextValues,
|
|
30592
|
+
{ coerceBareVariableDataValues: true }
|
|
30593
|
+
);
|
|
29853
30594
|
schema = JSON.parse(interpolated);
|
|
29854
30595
|
}
|
|
29855
30596
|
return {
|
|
@@ -31426,7 +32167,7 @@ var joinNode = nodeDefinition(JoinNodeImpl, "Coalesce");
|
|
|
31426
32167
|
|
|
31427
32168
|
// src/model/nodes/FilterNode.ts
|
|
31428
32169
|
var import_non_secure65 = require("nanoid/non-secure");
|
|
31429
|
-
var
|
|
32170
|
+
var import_lodash_es10 = require("lodash");
|
|
31430
32171
|
var import_ts_dedent56 = require("ts-dedent");
|
|
31431
32172
|
var FilterNodeImpl = class extends NodeImpl {
|
|
31432
32173
|
static create() {
|
|
@@ -31482,7 +32223,7 @@ var FilterNodeImpl = class extends NodeImpl {
|
|
|
31482
32223
|
var _a;
|
|
31483
32224
|
const array = coerceType(inputs["array"], "any[]");
|
|
31484
32225
|
const include = coerceType(inputs["include"], "boolean[]");
|
|
31485
|
-
const zipped = (0,
|
|
32226
|
+
const zipped = (0, import_lodash_es10.zip)(array, include);
|
|
31486
32227
|
const filtered = zipped.filter(([_, include2]) => include2).map(([value, _]) => value);
|
|
31487
32228
|
return {
|
|
31488
32229
|
["filtered"]: {
|
|
@@ -31504,7 +32245,6 @@ var MAX_CALLBACK_PREVIEW_BODY_LINES = 13;
|
|
|
31504
32245
|
var JS_LIST_CALLBACK_SIGNATURE = "(item, index, array)";
|
|
31505
32246
|
var JS_LIST_CALLBACK_LOCAL_NAMES = /* @__PURE__ */ new Set(["item", "index", "array"]);
|
|
31506
32247
|
var JS_LIST_INPUTS_IDENTIFIER = "__jsListInputs";
|
|
31507
|
-
var JS_LIST_INPUT_CLONE_CACHE_IDENTIFIER = "jsListInputCloneCache";
|
|
31508
32248
|
var JS_LIST_CODE_RUNNER_OPTIONS = {
|
|
31509
32249
|
includeFetch: false,
|
|
31510
32250
|
includeRequire: false,
|
|
@@ -31529,31 +32269,43 @@ function buildJSListRuntimePreamble(interpolationContext) {
|
|
|
31529
32269
|
return import_ts_dedent57.dedent`
|
|
31530
32270
|
const assertSynchronousCallbackResult = ${assertSynchronousCallbackResult.toString()};
|
|
31531
32271
|
${buildJsValueInputClonePreamble({
|
|
31532
|
-
cacheIdentifier:
|
|
32272
|
+
cacheIdentifier: interpolationContext.cloneCacheIdentifier,
|
|
32273
|
+
contextIdentifier: interpolationContext.contextIdentifier,
|
|
32274
|
+
graphInputsIdentifier: interpolationContext.graphInputsIdentifier,
|
|
31533
32275
|
inputsIdentifier: interpolationContext.inputsIdentifier
|
|
31534
32276
|
})}
|
|
31535
|
-
const array = cloneJsInputValue(inputs.array?.value, ${
|
|
32277
|
+
const array = cloneJsInputValue(inputs.array?.value, ${interpolationContext.cloneCacheIdentifier});
|
|
31536
32278
|
${buildClonedInputValueAssignments(
|
|
31537
32279
|
interpolationContext.inputNames,
|
|
31538
32280
|
interpolationContext.inputsIdentifier,
|
|
31539
|
-
|
|
32281
|
+
interpolationContext.cloneCacheIdentifier
|
|
31540
32282
|
)}
|
|
31541
32283
|
`;
|
|
31542
32284
|
}
|
|
31543
|
-
function buildJSListCallbackRuntimeSource(callbackBody,
|
|
31544
|
-
return buildJsValueInterpolatedSource(callbackBody,
|
|
32285
|
+
function buildJSListCallbackRuntimeSource(callbackBody, interpolationContext) {
|
|
32286
|
+
return buildJsValueInterpolatedSource(callbackBody, interpolationContext, {
|
|
31545
32287
|
localIdentifiers: JS_LIST_CALLBACK_LOCAL_NAMES
|
|
31546
32288
|
});
|
|
31547
32289
|
}
|
|
31548
32290
|
function sanitizeJSListError(error, callbackBody, nodeName) {
|
|
31549
|
-
const
|
|
32291
|
+
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
31550
32292
|
const fallbackLabel = `${nodeName} input`;
|
|
31551
|
-
return sanitizeGeneratedJsValueError(
|
|
32293
|
+
return sanitizeGeneratedJsValueError(
|
|
32294
|
+
error,
|
|
32295
|
+
interpolationContext.inputNames,
|
|
32296
|
+
interpolationContext.inputsIdentifier,
|
|
32297
|
+
fallbackLabel,
|
|
32298
|
+
[
|
|
32299
|
+
interpolationContext.cloneCacheIdentifier,
|
|
32300
|
+
interpolationContext.contextIdentifier,
|
|
32301
|
+
interpolationContext.graphInputsIdentifier,
|
|
32302
|
+
interpolationContext.interpolationHelperIdentifier
|
|
32303
|
+
]
|
|
32304
|
+
);
|
|
31552
32305
|
}
|
|
31553
32306
|
function buildJSFilterWrapper(callbackBody) {
|
|
31554
32307
|
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
31555
|
-
const
|
|
31556
|
-
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, inputsIdentifier);
|
|
32308
|
+
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, interpolationContext);
|
|
31557
32309
|
return import_ts_dedent57.dedent`
|
|
31558
32310
|
${buildJSListRuntimePreamble(interpolationContext)}
|
|
31559
32311
|
|
|
@@ -31589,8 +32341,7 @@ function buildJSFilterWrapper(callbackBody) {
|
|
|
31589
32341
|
}
|
|
31590
32342
|
function buildJSMapWrapper(callbackBody) {
|
|
31591
32343
|
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
31592
|
-
const
|
|
31593
|
-
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, inputsIdentifier);
|
|
32344
|
+
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, interpolationContext);
|
|
31594
32345
|
return import_ts_dedent57.dedent`
|
|
31595
32346
|
${buildJSListRuntimePreamble(interpolationContext)}
|
|
31596
32347
|
|
|
@@ -31643,7 +32394,7 @@ function getJSListEditors() {
|
|
|
31643
32394
|
type: "code",
|
|
31644
32395
|
label: "Callback Body",
|
|
31645
32396
|
helperMessage: "(item, index, array) => {",
|
|
31646
|
-
postEditorHelperMessage: "};\n\n//Use {{var}} to create input ports
|
|
32397
|
+
postEditorHelperMessage: "};\n\n//Use {{var}} to create input ports. {{config.limit.max}} creates only config; {{item.name}} and {{array[0]}} use callback locals.",
|
|
31647
32398
|
dataKey: "callbackBody",
|
|
31648
32399
|
language: "javascript",
|
|
31649
32400
|
interpolationSyntax: "js-value",
|
|
@@ -31690,7 +32441,10 @@ async function runJSListNodeCode({
|
|
|
31690
32441
|
const outputs = await context.codeRunner.runCode(
|
|
31691
32442
|
buildWrapper(callbackBody),
|
|
31692
32443
|
inputs,
|
|
31693
|
-
|
|
32444
|
+
getJsValueInterpolationCodeRunnerOptions(
|
|
32445
|
+
JS_LIST_CODE_RUNNER_OPTIONS,
|
|
32446
|
+
getJSListInterpolationContext(callbackBody)
|
|
32447
|
+
),
|
|
31694
32448
|
context.graphInputNodeValues,
|
|
31695
32449
|
context.contextValues
|
|
31696
32450
|
);
|
|
@@ -31745,7 +32499,9 @@ var JSFilterNodeImpl = class extends NodeImpl {
|
|
|
31745
32499
|
|
|
31746
32500
|
Available callback parameters are <code>item</code>, <code>index</code>, and <code>array</code>.
|
|
31747
32501
|
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.
|
|
32502
|
+
Use <code>{{var}}</code> to add input ports that evaluate as connected values. A path such as
|
|
32503
|
+
<code>{{config.limit.max}}</code> creates only <code>config</code>; <code>{{item.name}}</code> and
|
|
32504
|
+
<code>{{array[0]}}</code> use callback locals and do not add ports.
|
|
31749
32505
|
`,
|
|
31750
32506
|
infoBoxTitle: "JS Filter Node",
|
|
31751
32507
|
contextMenuTitle: "JS Filter",
|
|
@@ -31811,7 +32567,9 @@ var JSMapNodeImpl = class extends NodeImpl {
|
|
|
31811
32567
|
|
|
31812
32568
|
Available callback parameters are <code>item</code>, <code>index</code>, and <code>array</code>.
|
|
31813
32569
|
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.
|
|
32570
|
+
Use <code>{{var}}</code> to add input ports that evaluate as connected values. A path such as
|
|
32571
|
+
<code>{{config.limit.max}}</code> creates only <code>config</code>; <code>{{item.name}}</code> and
|
|
32572
|
+
<code>{{array[0]}}</code> use callback locals and do not add ports.
|
|
31815
32573
|
`,
|
|
31816
32574
|
infoBoxTitle: "JS Map Node",
|
|
31817
32575
|
contextMenuTitle: "JS Map",
|
|
@@ -31945,33 +32703,25 @@ var ObjectNodeImpl = class extends NodeImpl {
|
|
|
31945
32703
|
}
|
|
31946
32704
|
interpolate(baseString, values2, graphInputNodeValues, contextValues) {
|
|
31947
32705
|
const protectedBaseString = protectEscapedInterpolationTokens(baseString);
|
|
31948
|
-
const
|
|
31949
|
-
if (
|
|
32706
|
+
const parsedTemplate = parseInterpolationTemplate(protectedBaseString);
|
|
32707
|
+
if (parsedTemplate.tokens.length === 0) {
|
|
31950
32708
|
return restoreEscapedInterpolationTokens(protectedBaseString);
|
|
31951
32709
|
}
|
|
31952
32710
|
let result = "";
|
|
31953
32711
|
let cursor = 0;
|
|
31954
|
-
for (const
|
|
32712
|
+
for (const token of parsedTemplate.tokens) {
|
|
32713
|
+
const tokenSpan = token.span;
|
|
31955
32714
|
const isInsideString = isInsideJsonString(protectedBaseString, tokenSpan.start);
|
|
31956
32715
|
const isWholeQuotedToken = isInsideString && isUnescapedQuoteAt(protectedBaseString, tokenSpan.start - 1) && isUnescapedQuoteAt(protectedBaseString, tokenSpan.end);
|
|
31957
32716
|
const replacementStart = isWholeQuotedToken ? tokenSpan.start - 1 : tokenSpan.start;
|
|
31958
32717
|
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);
|
|
32718
|
+
const value = token.reference ? resolveInterpolationExpressionRawValue(token.reference, {
|
|
32719
|
+
variables: values2,
|
|
32720
|
+
graphInputValues: graphInputNodeValues,
|
|
32721
|
+
contextValues,
|
|
32722
|
+
unwrapVariableDataValues: false
|
|
32723
|
+
}) : void 0;
|
|
32724
|
+
result += restoreEscapedInterpolationTokens(protectedBaseString.slice(cursor, replacementStart));
|
|
31975
32725
|
if (isInsideString && !isWholeQuotedToken) {
|
|
31976
32726
|
result += stringifyEmbeddedJsonStringFragment(value);
|
|
31977
32727
|
} else if (isWholeQuotedToken) {
|
|
@@ -31981,8 +32731,8 @@ var ObjectNodeImpl = class extends NodeImpl {
|
|
|
31981
32731
|
}
|
|
31982
32732
|
cursor = replacementEnd;
|
|
31983
32733
|
}
|
|
31984
|
-
result += protectedBaseString.slice(cursor);
|
|
31985
|
-
return
|
|
32734
|
+
result += restoreEscapedInterpolationTokens(protectedBaseString.slice(cursor));
|
|
32735
|
+
return result;
|
|
31986
32736
|
}
|
|
31987
32737
|
async process(inputs, context) {
|
|
31988
32738
|
const inputMap = Object.keys(inputs).reduce(
|
|
@@ -32085,7 +32835,7 @@ var booleanNode = nodeDefinition(BooleanNodeImpl, "Boolean");
|
|
|
32085
32835
|
|
|
32086
32836
|
// src/model/nodes/CompareNode.ts
|
|
32087
32837
|
var import_non_secure70 = require("nanoid/non-secure");
|
|
32088
|
-
var
|
|
32838
|
+
var import_lodash_es11 = require("lodash");
|
|
32089
32839
|
var import_ts_pattern4 = require("ts-pattern");
|
|
32090
32840
|
var import_ts_dedent62 = require("ts-dedent");
|
|
32091
32841
|
var compareNodeComparisonFunctionOptions = [
|
|
@@ -32199,7 +32949,7 @@ var CompareNodeImpl = class extends NodeImpl {
|
|
|
32199
32949
|
return {
|
|
32200
32950
|
["output"]: {
|
|
32201
32951
|
type: "boolean",
|
|
32202
|
-
value: (0, import_ts_pattern4.match)(comparisonFunction).with("==", () => (0,
|
|
32952
|
+
value: (0, import_ts_pattern4.match)(comparisonFunction).with("==", () => (0, import_lodash_es11.isEqual)(value1, value2)).with("!=", () => !(0, import_lodash_es11.isEqual)(value1, value2)).with("<", () => compareValues(value1, value2)["<"]).with(">", () => compareValues(value1, value2)[">"]).with("<=", () => compareValues(value1, value2)["<="]).with(">=", () => compareValues(value1, value2)[">="]).with("and", () => !!(value1 && value2)).with("or", () => !!(value1 || value2)).with("xor", () => !!(value1 ? !value2 : value2)).with("nand", () => !(value1 && value2)).with("nor", () => !(value1 || value2)).with("xnor", () => !(value1 ? !value2 : value2)).exhaustive()
|
|
32203
32953
|
}
|
|
32204
32954
|
};
|
|
32205
32955
|
}
|
|
@@ -32519,7 +33269,7 @@ var randomNumberNode = nodeDefinition(RandomNumberNodeImpl, "Random number");
|
|
|
32519
33269
|
|
|
32520
33270
|
// src/model/nodes/ShuffleNode.ts
|
|
32521
33271
|
var import_non_secure74 = require("nanoid/non-secure");
|
|
32522
|
-
var
|
|
33272
|
+
var import_lodash_es12 = require("lodash");
|
|
32523
33273
|
var import_ts_dedent66 = require("ts-dedent");
|
|
32524
33274
|
var ShuffleNodeImpl = class extends NodeImpl {
|
|
32525
33275
|
static create() {
|
|
@@ -32568,7 +33318,7 @@ var ShuffleNodeImpl = class extends NodeImpl {
|
|
|
32568
33318
|
var _a;
|
|
32569
33319
|
const input = inputs["array"];
|
|
32570
33320
|
const items = input ? isArrayDataValue(input) ? input.value : [input.value] : [];
|
|
32571
|
-
const shuffled = (0,
|
|
33321
|
+
const shuffled = (0, import_lodash_es12.shuffle)(items);
|
|
32572
33322
|
return {
|
|
32573
33323
|
["shuffled"]: {
|
|
32574
33324
|
type: ((_a = inputs["array"]) == null ? void 0 : _a.type) ?? "any[]",
|
|
@@ -34308,7 +35058,7 @@ var extractMarkdownCodeBlocksNode = nodeDefinition(
|
|
|
34308
35058
|
|
|
34309
35059
|
// src/model/nodes/AssembleMessageNode.ts
|
|
34310
35060
|
var import_non_secure83 = require("nanoid/non-secure");
|
|
34311
|
-
var
|
|
35061
|
+
var import_lodash_es13 = require("lodash");
|
|
34312
35062
|
var import_ts_pattern6 = require("ts-pattern");
|
|
34313
35063
|
var messageTypeToTitle = {
|
|
34314
35064
|
assistant: "Assistant",
|
|
@@ -34459,7 +35209,7 @@ var AssembleMessageNodeImpl = class extends NodeImpl {
|
|
|
34459
35209
|
).otherwise(() => {
|
|
34460
35210
|
throw new Error(`Invalid type: ${type}`);
|
|
34461
35211
|
});
|
|
34462
|
-
const inputParts = (0,
|
|
35212
|
+
const inputParts = (0, import_lodash_es13.orderBy)(
|
|
34463
35213
|
Object.entries(inputs).filter(([key]) => key.startsWith("part")),
|
|
34464
35214
|
([key]) => key,
|
|
34465
35215
|
"asc"
|
|
@@ -34588,7 +35338,6 @@ var urlReferenceNode = nodeDefinition(UrlReferenceNodeImpl, "URL Reference");
|
|
|
34588
35338
|
|
|
34589
35339
|
// src/model/nodes/DestructureNode.ts
|
|
34590
35340
|
var import_non_secure85 = require("nanoid/non-secure");
|
|
34591
|
-
var import_jsonpath_plus3 = require("jsonpath-plus");
|
|
34592
35341
|
var import_ts_dedent72 = require("ts-dedent");
|
|
34593
35342
|
var DestructureNodeImpl = class extends NodeImpl {
|
|
34594
35343
|
static create() {
|
|
@@ -34676,7 +35425,7 @@ var DestructureNodeImpl = class extends NodeImpl {
|
|
|
34676
35425
|
this.data.paths.forEach((path, index) => {
|
|
34677
35426
|
let match9;
|
|
34678
35427
|
try {
|
|
34679
|
-
match9 = (
|
|
35428
|
+
match9 = evaluateJsonPath(inputObject, path, false);
|
|
34680
35429
|
} catch (err) {
|
|
34681
35430
|
match9 = void 0;
|
|
34682
35431
|
}
|
|
@@ -34993,9 +35742,9 @@ var import_non_secure88 = require("nanoid/non-secure");
|
|
|
34993
35742
|
var import_ts_dedent75 = require("ts-dedent");
|
|
34994
35743
|
|
|
34995
35744
|
// src/api/looseDataValue.ts
|
|
34996
|
-
var
|
|
35745
|
+
var import_lodash_es14 = require("lodash");
|
|
34997
35746
|
function looseDataValuesToDataValues(values2) {
|
|
34998
|
-
return (0,
|
|
35747
|
+
return (0, import_lodash_es14.mapValues)(values2, (val) => looseDataValueToDataValue(val));
|
|
34999
35748
|
}
|
|
35000
35749
|
function looseDataValueToDataValue(value) {
|
|
35001
35750
|
if (typeof value === "string") {
|
|
@@ -36230,7 +36979,7 @@ var cronNode = nodeDefinition(CronNodeImpl, "Cron");
|
|
|
36230
36979
|
// src/model/nodes/ToTreeNode.ts
|
|
36231
36980
|
var import_non_secure94 = require("nanoid/non-secure");
|
|
36232
36981
|
var import_ts_dedent81 = require("ts-dedent");
|
|
36233
|
-
var
|
|
36982
|
+
var import_lodash_es15 = require("lodash");
|
|
36234
36983
|
var ToTreeNodeImpl = class extends NodeImpl {
|
|
36235
36984
|
static create() {
|
|
36236
36985
|
const chartNode = {
|
|
@@ -36312,36 +37061,33 @@ var ToTreeNodeImpl = class extends NodeImpl {
|
|
|
36312
37061
|
group: ["Text"]
|
|
36313
37062
|
};
|
|
36314
37063
|
}
|
|
36315
|
-
buildTree(objects, parentPath = "", level = 0, isLast = true) {
|
|
37064
|
+
buildTree(objects, parentPath = "", level = 0, isLast = true, interpolationContext) {
|
|
36316
37065
|
if (!Array.isArray(objects) || objects.length === 0) return "";
|
|
36317
37066
|
let result = "";
|
|
36318
|
-
const sortedObjects = this.data.useSortAlphabetically ? (0,
|
|
37067
|
+
const sortedObjects = this.data.useSortAlphabetically ? (0, import_lodash_es15.sortBy)(objects, (obj) => String((0, import_lodash_es15.get)(obj, "path", ""))) : objects;
|
|
36319
37068
|
sortedObjects.forEach((obj, index) => {
|
|
36320
37069
|
const isLastItem = index === sortedObjects.length - 1;
|
|
36321
37070
|
const prefix = level === 0 ? "" : isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
36322
37071
|
const indent = level === 0 ? "" : " ".repeat(level - 1) + (isLast ? " " : "\u2502 ");
|
|
36323
|
-
const
|
|
36324
|
-
|
|
36325
|
-
|
|
36326
|
-
|
|
36327
|
-
|
|
36328
|
-
|
|
36329
|
-
},
|
|
36330
|
-
{}
|
|
37072
|
+
const formattedNode = interpolate(
|
|
37073
|
+
this.data.format,
|
|
37074
|
+
obj != null && typeof obj === "object" ? obj : {},
|
|
37075
|
+
interpolationContext == null ? void 0 : interpolationContext.graphInputNodeValues,
|
|
37076
|
+
interpolationContext == null ? void 0 : interpolationContext.contextValues,
|
|
37077
|
+
{ unwrapVariableDataValues: false }
|
|
36331
37078
|
);
|
|
36332
|
-
const formattedNode = interpolate(this.data.format, interpolationVars);
|
|
36333
37079
|
result += indent + prefix + formattedNode + "\n";
|
|
36334
|
-
const children = (0,
|
|
37080
|
+
const children = (0, import_lodash_es15.get)(obj, this.data.childrenProperty);
|
|
36335
37081
|
if (Array.isArray(children) && children.length > 0) {
|
|
36336
37082
|
const newPath = parentPath ? `${parentPath}/${formattedNode}` : formattedNode;
|
|
36337
|
-
result += this.buildTree(children, newPath, level + 1, isLastItem);
|
|
37083
|
+
result += this.buildTree(children, newPath, level + 1, isLastItem, interpolationContext);
|
|
36338
37084
|
}
|
|
36339
37085
|
});
|
|
36340
37086
|
return result;
|
|
36341
37087
|
}
|
|
36342
|
-
async process(inputs) {
|
|
37088
|
+
async process(inputs, context) {
|
|
36343
37089
|
const objects = coerceTypeOptional(inputs["objects"], "object[]") ?? [];
|
|
36344
|
-
const treeOutput = this.buildTree(objects);
|
|
37090
|
+
const treeOutput = this.buildTree(objects, "", 0, true, context);
|
|
36345
37091
|
return {
|
|
36346
37092
|
["tree"]: {
|
|
36347
37093
|
type: "string",
|
|
@@ -36713,14 +37459,26 @@ async function resolveMCPServer(data, inputs, context) {
|
|
|
36713
37459
|
}
|
|
36714
37460
|
return void 0;
|
|
36715
37461
|
}
|
|
36716
|
-
function interpolateMCPArgumentTemplate(template, inputs) {
|
|
37462
|
+
function interpolateMCPArgumentTemplate(template, inputs, graphInputValues, contextValues) {
|
|
36717
37463
|
const values2 = {};
|
|
36718
37464
|
for (const key of keys(inputs)) {
|
|
36719
|
-
if (key.startsWith("input")) {
|
|
36720
|
-
values2[key.slice("input-".length)] =
|
|
37465
|
+
if (key.startsWith("input-")) {
|
|
37466
|
+
values2[key.slice("input-".length)] = inputs[key];
|
|
36721
37467
|
}
|
|
36722
37468
|
}
|
|
36723
|
-
return interpolate(template, values2
|
|
37469
|
+
return interpolate(template, values2, graphInputValues, contextValues, {
|
|
37470
|
+
coerceBareVariableDataValues: true
|
|
37471
|
+
});
|
|
37472
|
+
}
|
|
37473
|
+
function getMCPArgumentTemplateInputs(template) {
|
|
37474
|
+
return extractInterpolationVariables(template ?? "").map(
|
|
37475
|
+
(interpolationName) => createInterpolationInputDefinition({
|
|
37476
|
+
id: `input-${interpolationName}`,
|
|
37477
|
+
interpolationName,
|
|
37478
|
+
dataType: "any",
|
|
37479
|
+
required: false
|
|
37480
|
+
})
|
|
37481
|
+
);
|
|
36724
37482
|
}
|
|
36725
37483
|
|
|
36726
37484
|
// src/model/nodes/MCPDiscoveryNode.ts
|
|
@@ -36905,6 +37663,8 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
|
|
|
36905
37663
|
id: "toolArguments",
|
|
36906
37664
|
title: "Tool Arguments"
|
|
36907
37665
|
});
|
|
37666
|
+
} else {
|
|
37667
|
+
inputs.push(...getMCPArgumentTemplateInputs(this.data.toolArguments));
|
|
36908
37668
|
}
|
|
36909
37669
|
if (this.data.useToolCallIdInput) {
|
|
36910
37670
|
inputs.push({
|
|
@@ -36946,6 +37706,7 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
|
|
|
36946
37706
|
label: "Tool Arguments",
|
|
36947
37707
|
dataKey: "toolArguments",
|
|
36948
37708
|
language: "json",
|
|
37709
|
+
interpolationSyntax: "json-template",
|
|
36949
37710
|
useInputToggleDataKey: "useToolArgumentsInput",
|
|
36950
37711
|
enableFolding: true
|
|
36951
37712
|
},
|
|
@@ -36983,7 +37744,14 @@ var MCPToolCallNodeImpl = class extends NodeImpl {
|
|
|
36983
37744
|
throw new MCPError("INVALID_SCHEMA" /* INVALID_SCHEMA */, "Cannot parse tool argument with input toggle on");
|
|
36984
37745
|
}
|
|
36985
37746
|
} else {
|
|
36986
|
-
toolArguments = JSON.parse(
|
|
37747
|
+
toolArguments = JSON.parse(
|
|
37748
|
+
interpolateMCPArgumentTemplate(
|
|
37749
|
+
this.data.toolArguments ?? "",
|
|
37750
|
+
inputs,
|
|
37751
|
+
context.graphInputNodeValues,
|
|
37752
|
+
context.contextValues
|
|
37753
|
+
)
|
|
37754
|
+
);
|
|
36987
37755
|
}
|
|
36988
37756
|
const toolCall = {
|
|
36989
37757
|
name: toolName,
|
|
@@ -37067,6 +37835,8 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
|
|
|
37067
37835
|
id: "promptArguments",
|
|
37068
37836
|
title: "Prompt Arguments"
|
|
37069
37837
|
});
|
|
37838
|
+
} else {
|
|
37839
|
+
inputs.push(...getMCPArgumentTemplateInputs(this.data.promptArguments));
|
|
37070
37840
|
}
|
|
37071
37841
|
return inputs;
|
|
37072
37842
|
}
|
|
@@ -37096,6 +37866,7 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
|
|
|
37096
37866
|
dataKey: "promptArguments",
|
|
37097
37867
|
useInputToggleDataKey: "usePromptArgumentsInput",
|
|
37098
37868
|
language: "json",
|
|
37869
|
+
interpolationSyntax: "json-template",
|
|
37099
37870
|
helperMessage: "Arguments to provide the prompt",
|
|
37100
37871
|
enableFolding: true
|
|
37101
37872
|
}
|
|
@@ -37125,7 +37896,14 @@ var MCPGetPromptNodeImpl = class extends NodeImpl {
|
|
|
37125
37896
|
throw new MCPError("INVALID_SCHEMA" /* INVALID_SCHEMA */, "Cannot parse tool argument with input toggle on");
|
|
37126
37897
|
}
|
|
37127
37898
|
} else {
|
|
37128
|
-
promptArguments = JSON.parse(
|
|
37899
|
+
promptArguments = JSON.parse(
|
|
37900
|
+
interpolateMCPArgumentTemplate(
|
|
37901
|
+
this.data.promptArguments ?? "",
|
|
37902
|
+
inputs,
|
|
37903
|
+
context.graphInputNodeValues,
|
|
37904
|
+
context.contextValues
|
|
37905
|
+
)
|
|
37906
|
+
);
|
|
37129
37907
|
}
|
|
37130
37908
|
const getPromptRequest = {
|
|
37131
37909
|
name: promptName,
|
|
@@ -37279,29 +38057,17 @@ var ReferencedGraphAliasNodeImpl = class extends NodeImpl {
|
|
|
37279
38057
|
}
|
|
37280
38058
|
const boundary = ((_a = context.getGraphBoundary) == null ? void 0 : _a.call(context, referencedProject, this.data.graphId)) ?? getGraphBoundary(referencedProject, this.data.graphId);
|
|
37281
38059
|
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
38060
|
const subGraphProcessor = context.createSubProcessor(this.data.graphId, {
|
|
37288
38061
|
signal: context.signal,
|
|
37289
38062
|
project: referencedProject
|
|
37290
38063
|
});
|
|
37291
|
-
if (!shouldRunWholeGraph) {
|
|
37292
|
-
subGraphProcessor.runToNodeIds = requestedGraphOutputNodeIds;
|
|
37293
|
-
}
|
|
37294
38064
|
try {
|
|
37295
38065
|
const startTime = Date.now();
|
|
37296
|
-
const
|
|
38066
|
+
const outputs = await subGraphProcessor.processGraph(
|
|
37297
38067
|
context,
|
|
37298
38068
|
inputData,
|
|
37299
38069
|
context.contextValues
|
|
37300
38070
|
);
|
|
37301
|
-
const outputs = shouldRunWholeGraph ? graphOutputs : {
|
|
37302
|
-
...buildExcludedGraphBoundaryOutputs(boundary),
|
|
37303
|
-
...graphOutputs
|
|
37304
|
-
};
|
|
37305
38071
|
const duration = Date.now() - startTime;
|
|
37306
38072
|
if (this.data.useErrorOutput) {
|
|
37307
38073
|
outputs["error"] = {
|
|
@@ -37330,26 +38096,6 @@ var ReferencedGraphAliasNodeImpl = class extends NodeImpl {
|
|
|
37330
38096
|
}
|
|
37331
38097
|
};
|
|
37332
38098
|
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
38099
|
function applyMetricOutputSetting(outputs, outputCostDuration) {
|
|
37354
38100
|
if (outputCostDuration) {
|
|
37355
38101
|
return outputs;
|
|
@@ -38082,7 +38828,7 @@ function isRecord9(value) {
|
|
|
38082
38828
|
// src/recording/ExecutionRecorder.ts
|
|
38083
38829
|
var import_non_secure100 = require("nanoid/non-secure");
|
|
38084
38830
|
var import_emittery2 = __toESM(require("emittery-0-13"), 1);
|
|
38085
|
-
var
|
|
38831
|
+
var import_lodash_es16 = require("lodash");
|
|
38086
38832
|
var import_json_stream_es = require("json-stream-es");
|
|
38087
38833
|
|
|
38088
38834
|
// src/vendor/fnv1a.js
|
|
@@ -38319,16 +39065,16 @@ function isRecordableProcessEvent(message) {
|
|
|
38319
39065
|
function mapValuesDeep(obj, fn) {
|
|
38320
39066
|
if (Array.isArray(obj)) {
|
|
38321
39067
|
return obj.map((value) => {
|
|
38322
|
-
if ((0,
|
|
39068
|
+
if ((0, import_lodash_es16.isPlainObject)(value) || Array.isArray(value)) {
|
|
38323
39069
|
return mapValuesDeep(value, fn);
|
|
38324
39070
|
}
|
|
38325
39071
|
return fn(value);
|
|
38326
39072
|
});
|
|
38327
39073
|
}
|
|
38328
|
-
if ((0,
|
|
39074
|
+
if ((0, import_lodash_es16.isPlainObject)(obj)) {
|
|
38329
39075
|
return Object.fromEntries(
|
|
38330
39076
|
Object.entries(obj).map(([key, value]) => {
|
|
38331
|
-
if ((0,
|
|
39077
|
+
if ((0, import_lodash_es16.isPlainObject)(value) || Array.isArray(value)) {
|
|
38332
39078
|
return [key, mapValuesDeep(value, fn)];
|
|
38333
39079
|
}
|
|
38334
39080
|
return [key, fn(value)];
|
|
@@ -43887,7 +44633,6 @@ ${additional.join("\n")}`;
|
|
|
43887
44633
|
var runThreadNode = pluginNodeDefinition(RunThreadNodeImpl, "Run Thread");
|
|
43888
44634
|
|
|
43889
44635
|
// src/plugins/openai/nodes/ThreadMessageNode.ts
|
|
43890
|
-
var import_lodash_es18 = require("lodash");
|
|
43891
44636
|
var ThreadMessageNodeImpl = {
|
|
43892
44637
|
create() {
|
|
43893
44638
|
return {
|
|
@@ -43940,16 +44685,17 @@ var ThreadMessageNodeImpl = {
|
|
|
43940
44685
|
required: false
|
|
43941
44686
|
});
|
|
43942
44687
|
}
|
|
43943
|
-
const
|
|
44688
|
+
const inputReferences = extractInterpolationVariableReferences(data.text);
|
|
44689
|
+
const fixedInputIds = new Set(inputs.map((input) => input.id));
|
|
43944
44690
|
inputs = [
|
|
43945
44691
|
...inputs,
|
|
43946
|
-
...(
|
|
44692
|
+
...inputReferences.filter(({ baseName }) => !fixedInputIds.has(baseName)).map(({ baseName, hasPath }) => {
|
|
43947
44693
|
return createInterpolationInputDefinition({
|
|
43948
|
-
interpolationName:
|
|
43949
|
-
dataType: "string",
|
|
44694
|
+
interpolationName: baseName,
|
|
44695
|
+
dataType: hasPath ? "any" : "string",
|
|
43950
44696
|
required: false
|
|
43951
44697
|
});
|
|
43952
|
-
})
|
|
44698
|
+
})
|
|
43953
44699
|
];
|
|
43954
44700
|
return inputs;
|
|
43955
44701
|
},
|
|
@@ -43997,7 +44743,7 @@ var ThreadMessageNodeImpl = {
|
|
|
43997
44743
|
theme: "prompt-interpolation"
|
|
43998
44744
|
};
|
|
43999
44745
|
},
|
|
44000
|
-
async process(data, inputData) {
|
|
44746
|
+
async process(data, inputData, context) {
|
|
44001
44747
|
const text = getInputOrData(data, inputData, "text", "string");
|
|
44002
44748
|
const fileIds = getInputOrData(data, inputData, "fileIds", "string[]") ?? [];
|
|
44003
44749
|
let metadata = data.metadata.reduce(
|
|
@@ -44010,8 +44756,9 @@ var ThreadMessageNodeImpl = {
|
|
|
44010
44756
|
if (data.useMetadataInput && inputData["metadata"]) {
|
|
44011
44757
|
metadata = coerceTypeOptional(inputData["metadata"], "object");
|
|
44012
44758
|
}
|
|
44013
|
-
const
|
|
44014
|
-
|
|
44759
|
+
const interpolated = interpolate(text, inputData, context == null ? void 0 : context.graphInputNodeValues, context == null ? void 0 : context.contextValues, {
|
|
44760
|
+
coerceBareVariableDataValues: true
|
|
44761
|
+
});
|
|
44015
44762
|
return {
|
|
44016
44763
|
["message"]: {
|
|
44017
44764
|
type: "object",
|
|
@@ -44063,7 +44810,7 @@ var import_ts_dedent93 = require("ts-dedent");
|
|
|
44063
44810
|
var import_p_retry3 = __toESM(require("p-retry-4"), 1);
|
|
44064
44811
|
var import_ts_pattern8 = require("ts-pattern");
|
|
44065
44812
|
var import_genai2 = require("@google/genai");
|
|
44066
|
-
var
|
|
44813
|
+
var import_lodash_es17 = require("lodash");
|
|
44067
44814
|
function toGoogleSchemaType(type) {
|
|
44068
44815
|
switch (type) {
|
|
44069
44816
|
case "string":
|
|
@@ -44434,7 +45181,7 @@ var ChatGoogleNodeImpl = {
|
|
|
44434
45181
|
description: tool.description,
|
|
44435
45182
|
parameters: Object.keys(parameters.properties ?? {}).length === 0 ? void 0 : {
|
|
44436
45183
|
type: import_genai2.Type.OBJECT,
|
|
44437
|
-
properties: (0,
|
|
45184
|
+
properties: (0, import_lodash_es17.mapValues)(parameters.properties ?? {}, (property) => ({
|
|
44438
45185
|
// gemini doesn't support union property types, it uses openapi style not jsonschema, what a mess
|
|
44439
45186
|
type: toGoogleSchemaType(
|
|
44440
45187
|
Array.isArray(property.type) ? property.type.find((type) => type !== "null") : property.type
|
|
@@ -44728,7 +45475,7 @@ async function assembleRegistry(specs, loadPlugin) {
|
|
|
44728
45475
|
}
|
|
44729
45476
|
|
|
44730
45477
|
// src/integrations/DatasetProvider.ts
|
|
44731
|
-
var
|
|
45478
|
+
var import_lodash_es18 = require("lodash");
|
|
44732
45479
|
var InMemoryDatasetProvider = class {
|
|
44733
45480
|
#datasets;
|
|
44734
45481
|
constructor(datasets) {
|
|
@@ -44808,7 +45555,7 @@ var InMemoryDatasetProvider = class {
|
|
|
44808
45555
|
return sorted.slice(0, k).map((r) => ({ ...r.row, distance: r.similarity }));
|
|
44809
45556
|
}
|
|
44810
45557
|
async exportDatasetsForProject(_projectId) {
|
|
44811
|
-
return (0,
|
|
45558
|
+
return (0, import_lodash_es18.cloneDeep)(this.#datasets);
|
|
44812
45559
|
}
|
|
44813
45560
|
};
|
|
44814
45561
|
var dotProductSimilarity = (a, b) => {
|
|
@@ -45482,6 +46229,7 @@ var Rivet = void 0;
|
|
|
45482
46229
|
doubleCheckProject,
|
|
45483
46230
|
emptyNodeGraph,
|
|
45484
46231
|
encodeRivetWebAppStorageBinaryFrame,
|
|
46232
|
+
evaluateJsonPath,
|
|
45485
46233
|
evaluateNode,
|
|
45486
46234
|
executeLLMInvocation,
|
|
45487
46235
|
expectType,
|
|
@@ -45489,6 +46237,7 @@ var Rivet = void 0;
|
|
|
45489
46237
|
exportGentraceEvaluationRun,
|
|
45490
46238
|
expressionNode,
|
|
45491
46239
|
externalCallNode,
|
|
46240
|
+
extractInterpolationVariableReferences,
|
|
45492
46241
|
extractInterpolationVariables,
|
|
45493
46242
|
extractJsonNode,
|
|
45494
46243
|
extractMarkdownCodeBlocksNode,
|
|
@@ -45540,6 +46289,7 @@ var Rivet = void 0;
|
|
|
45540
46289
|
getIntegration,
|
|
45541
46290
|
getInterpolationInputDefinitionData,
|
|
45542
46291
|
getInterpolationTokenName,
|
|
46292
|
+
getInterpolationTokenReference,
|
|
45543
46293
|
getKnowledgeSourceStatusNode,
|
|
45544
46294
|
getKnowledgeStoreProvider,
|
|
45545
46295
|
getKnowledgeStoreProviders,
|
|
@@ -45558,6 +46308,7 @@ var Rivet = void 0;
|
|
|
45558
46308
|
getScalarTypeOf,
|
|
45559
46309
|
getSingleNodeStream,
|
|
45560
46310
|
getStoredValueNode,
|
|
46311
|
+
getToolNodeBodyPreview,
|
|
45561
46312
|
getUiGraphActionComponent,
|
|
45562
46313
|
getUiGraphActionInputBindings,
|
|
45563
46314
|
getUiGraphActionOutputBindings,
|
|
@@ -45622,6 +46373,8 @@ var Rivet = void 0;
|
|
|
45622
46373
|
isFunctionDataType,
|
|
45623
46374
|
isFunctionDataValue,
|
|
45624
46375
|
isInterpolationInputDefinition,
|
|
46376
|
+
isInterpolationRegexLiteralStart,
|
|
46377
|
+
isInterpolationSyntaxCharacterEscaped,
|
|
45625
46378
|
isKnowledgeDocument,
|
|
45626
46379
|
isKnowledgeEvidence,
|
|
45627
46380
|
isKnowledgeSourceReference,
|
|
@@ -45672,6 +46425,7 @@ var Rivet = void 0;
|
|
|
45672
46425
|
normalizeChatV2CredentialNames,
|
|
45673
46426
|
normalizeChatV2CredentialNamesByProvider,
|
|
45674
46427
|
normalizeGraphProgress,
|
|
46428
|
+
normalizeJsonPathExpression,
|
|
45675
46429
|
normalizeKnowledgeConnectionId,
|
|
45676
46430
|
normalizeKnowledgeDocument,
|
|
45677
46431
|
normalizeKnowledgeEvidence,
|
|
@@ -45705,6 +46459,8 @@ var Rivet = void 0;
|
|
|
45705
46459
|
parseChatV2Provider,
|
|
45706
46460
|
parseCustomProviderApi,
|
|
45707
46461
|
parseDataBusChannelIndex,
|
|
46462
|
+
parseInterpolationExpression,
|
|
46463
|
+
parseInterpolationTemplate,
|
|
45708
46464
|
parseProviderJsonChunk,
|
|
45709
46465
|
parseRivetWebAppBrowserStorageClientMessage,
|
|
45710
46466
|
parseRivetWebAppBrowserStorageServerMessage,
|
|
@@ -45748,6 +46504,9 @@ var Rivet = void 0;
|
|
|
45748
46504
|
resolveChatV2Credential,
|
|
45749
46505
|
resolveChatV2ProviderConfig,
|
|
45750
46506
|
resolveChatV2ResponseFormatParameters,
|
|
46507
|
+
resolveCodeInterpolationExpression,
|
|
46508
|
+
resolveInterpolationExpressionRawValue,
|
|
46509
|
+
resolveInterpolationTokenRawValue,
|
|
45751
46510
|
resolveLLMChatV2RuntimeProviderOptions,
|
|
45752
46511
|
resolveNodePrefabInstance,
|
|
45753
46512
|
resolveNodePrefabInstances,
|
|
@@ -45770,6 +46529,7 @@ var Rivet = void 0;
|
|
|
45770
46529
|
sanitizeIdentifierPortValue,
|
|
45771
46530
|
scalarDefaults,
|
|
45772
46531
|
scalarTypes,
|
|
46532
|
+
scanInterpolationTokenSpans,
|
|
45773
46533
|
searchKnowledgeNode,
|
|
45774
46534
|
serializeDatasets,
|
|
45775
46535
|
serializeGraph,
|
|
@@ -45787,6 +46547,7 @@ var Rivet = void 0;
|
|
|
45787
46547
|
splitRivetWebAppStorageTransfer,
|
|
45788
46548
|
startBackgroundBranchNode,
|
|
45789
46549
|
streamChatV2,
|
|
46550
|
+
stringifyInterpolationSourceValue,
|
|
45790
46551
|
stringifyToolResult,
|
|
45791
46552
|
stringifyUiGraphValue,
|
|
45792
46553
|
subGraphNode,
|