@valerypopoff/rivet2-core 2.12.0 → 2.13.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 +781 -245
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/esm/exports.js +1 -0
- package/dist/esm/model/GraphInputStream.js +70 -0
- package/dist/esm/model/GraphProcessor.js +257 -16
- package/dist/esm/model/NodeExecutionPlanner.js +4 -4
- package/dist/esm/model/Nodes.js +3 -0
- package/dist/esm/model/ProcessContextBuilder.js +2 -1
- package/dist/esm/model/StreamingOutputWatch.js +5 -0
- package/dist/esm/model/StreamingWatchTopology.js +191 -0
- package/dist/esm/model/nodes/AssembleMessageNode.js +2 -2
- package/dist/esm/model/nodes/AssemblePromptNode.js +46 -17
- package/dist/esm/model/nodes/GraphInputNode.js +15 -19
- package/dist/esm/model/nodes/MatchCaseNode.js +2 -2
- package/dist/esm/model/nodes/ProjectNameNode.js +37 -0
- package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +1 -0
- package/dist/esm/model/nodes/SubGraphNode.js +1 -0
- package/dist/esm/model/nodes/variadicPortIndex.js +1 -1
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/model/GraphInputStream.d.ts +23 -0
- package/dist/types/model/GraphProcessor.d.ts +3 -0
- package/dist/types/model/NodeExecutionPlanner.d.ts +1 -1
- package/dist/types/model/Nodes.d.ts +3 -2
- package/dist/types/model/ProcessContext.d.ts +3 -0
- package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
- package/dist/types/model/StreamingOutputWatch.d.ts +2 -0
- package/dist/types/model/StreamingWatchTopology.d.ts +20 -0
- package/dist/types/model/nodes/AssemblePromptNode.d.ts +4 -3
- package/dist/types/model/nodes/GraphInputNode.d.ts +2 -0
- package/dist/types/model/nodes/MatchCaseNode.d.ts +1 -1
- package/dist/types/model/nodes/ProjectNameNode.d.ts +12 -0
- package/dist/types/model/nodes/variadicPortIndex.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/bundle.cjs
CHANGED
|
@@ -149,6 +149,7 @@ __export(src_exports, {
|
|
|
149
149
|
PlayAudioNodeImpl: () => PlayAudioNodeImpl,
|
|
150
150
|
PluginNodeImplClass: () => PluginNodeImplClass,
|
|
151
151
|
PopNodeImpl: () => PopNodeImpl,
|
|
152
|
+
ProjectNameNodeImpl: () => ProjectNameNodeImpl,
|
|
152
153
|
ProjectValidationError: () => ProjectValidationError,
|
|
153
154
|
PromptNodeImpl: () => PromptNodeImpl,
|
|
154
155
|
RIVET_MARKDOWN_ALLOWED_ATTRIBUTES: () => RIVET_MARKDOWN_ALLOWED_ATTRIBUTES,
|
|
@@ -242,6 +243,8 @@ __export(src_exports, {
|
|
|
242
243
|
canBeCoercedAny: () => canBeCoercedAny,
|
|
243
244
|
canConsumeControlFlowExcludedInput: () => canConsumeControlFlowExcludedInput,
|
|
244
245
|
canRenderDataBusNode: () => canRenderDataBusNode,
|
|
246
|
+
canStreamThroughGraphCaller: () => canStreamThroughGraphCaller,
|
|
247
|
+
canStreamThroughGraphInput: () => canStreamThroughGraphInput,
|
|
245
248
|
canUseNodeAsPrefabSource: () => canUseNodeAsPrefabSource,
|
|
246
249
|
chatLoopLegacyDisplayName: () => chatLoopLegacyDisplayName,
|
|
247
250
|
chatLoopNode: () => chatLoopNode,
|
|
@@ -404,6 +407,7 @@ __export(src_exports, {
|
|
|
404
407
|
getProjectConnectionComparisonKey: () => getProjectConnectionComparisonKey,
|
|
405
408
|
getProjectGlobalVariableIds: () => getProjectGlobalVariableIds,
|
|
406
409
|
getProjectNodeFieldComparisons: () => getProjectNodeFieldComparisons,
|
|
410
|
+
getProjectStreamingOutputWatchConnections: () => getProjectStreamingOutputWatchConnections,
|
|
407
411
|
getReconciledUiGraphActionInputBindings: () => getReconciledUiGraphActionInputBindings,
|
|
408
412
|
getReconciledUiGraphActionOutputBindings: () => getReconciledUiGraphActionOutputBindings,
|
|
409
413
|
getScalarTypeOf: () => getScalarTypeOf,
|
|
@@ -580,6 +584,7 @@ __export(src_exports, {
|
|
|
580
584
|
popNode: () => popNode,
|
|
581
585
|
projectLLMChatV2EditorCacheHit: () => projectLLMChatV2EditorCacheHit,
|
|
582
586
|
projectLLMInvocationUsage: () => projectLLMInvocationUsage,
|
|
587
|
+
projectNameNode: () => projectNameNode,
|
|
583
588
|
promptNode: () => promptNode,
|
|
584
589
|
protectEscapedInterpolationTokens: () => protectEscapedInterpolationTokens,
|
|
585
590
|
raceInputsNode: () => raceInputsNode,
|
|
@@ -611,6 +616,7 @@ __export(src_exports, {
|
|
|
611
616
|
resolveChatV2ProviderConfig: () => resolveChatV2ProviderConfig,
|
|
612
617
|
resolveChatV2ResponseFormatParameters: () => resolveChatV2ResponseFormatParameters,
|
|
613
618
|
resolveCodeInterpolationExpression: () => resolveCodeInterpolationExpression,
|
|
619
|
+
resolveGraphInputValue: () => resolveGraphInputValue,
|
|
614
620
|
resolveInterpolationExpressionRawValue: () => resolveInterpolationExpressionRawValue,
|
|
615
621
|
resolveInterpolationTokenRawValue: () => resolveInterpolationTokenRawValue,
|
|
616
622
|
resolveLLMChatV2RuntimeProviderOptions: () => resolveLLMChatV2RuntimeProviderOptions,
|
|
@@ -814,6 +820,7 @@ __export(exports_exports, {
|
|
|
814
820
|
PlayAudioNodeImpl: () => PlayAudioNodeImpl,
|
|
815
821
|
PluginNodeImplClass: () => PluginNodeImplClass,
|
|
816
822
|
PopNodeImpl: () => PopNodeImpl,
|
|
823
|
+
ProjectNameNodeImpl: () => ProjectNameNodeImpl,
|
|
817
824
|
ProjectValidationError: () => ProjectValidationError,
|
|
818
825
|
PromptNodeImpl: () => PromptNodeImpl,
|
|
819
826
|
RIVET_MARKDOWN_ALLOWED_ATTRIBUTES: () => RIVET_MARKDOWN_ALLOWED_ATTRIBUTES,
|
|
@@ -906,6 +913,8 @@ __export(exports_exports, {
|
|
|
906
913
|
canBeCoercedAny: () => canBeCoercedAny,
|
|
907
914
|
canConsumeControlFlowExcludedInput: () => canConsumeControlFlowExcludedInput,
|
|
908
915
|
canRenderDataBusNode: () => canRenderDataBusNode,
|
|
916
|
+
canStreamThroughGraphCaller: () => canStreamThroughGraphCaller,
|
|
917
|
+
canStreamThroughGraphInput: () => canStreamThroughGraphInput,
|
|
909
918
|
canUseNodeAsPrefabSource: () => canUseNodeAsPrefabSource,
|
|
910
919
|
chatLoopLegacyDisplayName: () => chatLoopLegacyDisplayName,
|
|
911
920
|
chatLoopNode: () => chatLoopNode,
|
|
@@ -1068,6 +1077,7 @@ __export(exports_exports, {
|
|
|
1068
1077
|
getProjectConnectionComparisonKey: () => getProjectConnectionComparisonKey,
|
|
1069
1078
|
getProjectGlobalVariableIds: () => getProjectGlobalVariableIds,
|
|
1070
1079
|
getProjectNodeFieldComparisons: () => getProjectNodeFieldComparisons,
|
|
1080
|
+
getProjectStreamingOutputWatchConnections: () => getProjectStreamingOutputWatchConnections,
|
|
1071
1081
|
getReconciledUiGraphActionInputBindings: () => getReconciledUiGraphActionInputBindings,
|
|
1072
1082
|
getReconciledUiGraphActionOutputBindings: () => getReconciledUiGraphActionOutputBindings,
|
|
1073
1083
|
getScalarTypeOf: () => getScalarTypeOf,
|
|
@@ -1244,6 +1254,7 @@ __export(exports_exports, {
|
|
|
1244
1254
|
popNode: () => popNode,
|
|
1245
1255
|
projectLLMChatV2EditorCacheHit: () => projectLLMChatV2EditorCacheHit,
|
|
1246
1256
|
projectLLMInvocationUsage: () => projectLLMInvocationUsage,
|
|
1257
|
+
projectNameNode: () => projectNameNode,
|
|
1247
1258
|
promptNode: () => promptNode,
|
|
1248
1259
|
protectEscapedInterpolationTokens: () => protectEscapedInterpolationTokens,
|
|
1249
1260
|
raceInputsNode: () => raceInputsNode,
|
|
@@ -1275,6 +1286,7 @@ __export(exports_exports, {
|
|
|
1275
1286
|
resolveChatV2ProviderConfig: () => resolveChatV2ProviderConfig,
|
|
1276
1287
|
resolveChatV2ResponseFormatParameters: () => resolveChatV2ResponseFormatParameters,
|
|
1277
1288
|
resolveCodeInterpolationExpression: () => resolveCodeInterpolationExpression,
|
|
1289
|
+
resolveGraphInputValue: () => resolveGraphInputValue,
|
|
1278
1290
|
resolveInterpolationExpressionRawValue: () => resolveInterpolationExpressionRawValue,
|
|
1279
1291
|
resolveInterpolationTokenRawValue: () => resolveInterpolationTokenRawValue,
|
|
1280
1292
|
resolveLLMChatV2RuntimeProviderOptions: () => resolveLLMChatV2RuntimeProviderOptions,
|
|
@@ -6335,7 +6347,7 @@ var pQueueCompat_default = PQueue;
|
|
|
6335
6347
|
|
|
6336
6348
|
// src/model/GraphProcessor.ts
|
|
6337
6349
|
var import_emittery = __toESM(require("emittery-0-13"), 1);
|
|
6338
|
-
var
|
|
6350
|
+
var import_non_secure8 = require("nanoid/non-secure");
|
|
6339
6351
|
|
|
6340
6352
|
// src/model/CycleDetector.ts
|
|
6341
6353
|
function findStronglyConnectedComponents(nodes, getAdjacentNodes) {
|
|
@@ -8088,6 +8100,7 @@ function buildNodeProcessContext(options2) {
|
|
|
8088
8100
|
node,
|
|
8089
8101
|
nodeAbortController,
|
|
8090
8102
|
onGraphOutputPartial,
|
|
8103
|
+
graphInputStreams,
|
|
8091
8104
|
onPartialOutputs,
|
|
8092
8105
|
setFailureOutputs,
|
|
8093
8106
|
processId,
|
|
@@ -8112,6 +8125,7 @@ function buildNodeProcessContext(options2) {
|
|
|
8112
8125
|
waitForStoredValue: (key, signal = nodeAbortController.signal) => base.waitForStoredValue(key, signal),
|
|
8113
8126
|
externalFunctions: { ...externalFunctions },
|
|
8114
8127
|
onGraphOutputPartial,
|
|
8128
|
+
graphInputStreams,
|
|
8115
8129
|
onPartialOutputs,
|
|
8116
8130
|
setFailureOutputs,
|
|
8117
8131
|
signal: nodeAbortController.signal,
|
|
@@ -8525,18 +8539,18 @@ function getMissingRequiredInputs(state, node) {
|
|
|
8525
8539
|
});
|
|
8526
8540
|
}
|
|
8527
8541
|
function getWaitingForInputNode(state, node, inputNodes, inputValues) {
|
|
8528
|
-
let waitingForInputNode
|
|
8542
|
+
let waitingForInputNode;
|
|
8529
8543
|
const anyInputIsValid = Object.values(inputValues).some((value) => value && !isControlFlowExcluded(value));
|
|
8530
8544
|
for (const inputNode of inputNodes) {
|
|
8531
8545
|
if (node.type === "loopController" && !state.loopControllersSeen.has(node.id) && nodesAreInSameCycle(state, node.id, inputNode.id)) {
|
|
8532
8546
|
continue;
|
|
8533
8547
|
}
|
|
8534
8548
|
if (node.type === "raceInputs" && state.visitedNodes.has(inputNode.id) && anyInputIsValid) {
|
|
8535
|
-
waitingForInputNode =
|
|
8549
|
+
waitingForInputNode = void 0;
|
|
8536
8550
|
break;
|
|
8537
8551
|
}
|
|
8538
|
-
if (waitingForInputNode ===
|
|
8539
|
-
waitingForInputNode = inputNode
|
|
8552
|
+
if (waitingForInputNode === void 0 && state.visitedNodes.has(inputNode.id) === false) {
|
|
8553
|
+
waitingForInputNode = inputNode;
|
|
8540
8554
|
}
|
|
8541
8555
|
}
|
|
8542
8556
|
return waitingForInputNode;
|
|
@@ -9868,6 +9882,11 @@ var StreamingOutputWatch = class {
|
|
|
9868
9882
|
this.#run = run;
|
|
9869
9883
|
this.#onFailure = onFailure;
|
|
9870
9884
|
}
|
|
9885
|
+
/** Updates superseded before the receiving graph could start. */
|
|
9886
|
+
accountCoalescedUpdates(count) {
|
|
9887
|
+
this.#receivedUpdates += count;
|
|
9888
|
+
this.#coalescedUpdates += count;
|
|
9889
|
+
}
|
|
9871
9890
|
get hasPending() {
|
|
9872
9891
|
return this.#activeRuns.size > 0 || !this.#stopped && (this.#queue.length > 0 || this.#timer != null);
|
|
9873
9892
|
}
|
|
@@ -10220,6 +10239,353 @@ function withEventOccurredAt(data, eventOccurredAt) {
|
|
|
10220
10239
|
return { ...data, eventOccurredAt };
|
|
10221
10240
|
}
|
|
10222
10241
|
|
|
10242
|
+
// src/model/GraphInputStream.ts
|
|
10243
|
+
var GraphInputStreamRelay = class {
|
|
10244
|
+
result;
|
|
10245
|
+
settled;
|
|
10246
|
+
#resolve;
|
|
10247
|
+
#listener;
|
|
10248
|
+
#latest;
|
|
10249
|
+
#coalesced = 0;
|
|
10250
|
+
#disposed = false;
|
|
10251
|
+
constructor() {
|
|
10252
|
+
this.settled = new Promise((resolve) => {
|
|
10253
|
+
this.#resolve = resolve;
|
|
10254
|
+
});
|
|
10255
|
+
}
|
|
10256
|
+
publish(value, coalesced = 0) {
|
|
10257
|
+
if (this.result || this.#disposed) return;
|
|
10258
|
+
const snapshot = cloneExecutionOutputs({ ["value"]: value })["value"];
|
|
10259
|
+
if (this.#listener) this.#listener(snapshot, coalesced);
|
|
10260
|
+
else {
|
|
10261
|
+
this.#coalesced += coalesced;
|
|
10262
|
+
if (this.#latest) this.#coalesced++;
|
|
10263
|
+
this.#latest = snapshot;
|
|
10264
|
+
}
|
|
10265
|
+
}
|
|
10266
|
+
finish(result) {
|
|
10267
|
+
var _a;
|
|
10268
|
+
if (this.result) return;
|
|
10269
|
+
this.result = result.error ? result : {
|
|
10270
|
+
value: cloneExecutionOutputs({ ["value"]: result.value })["value"]
|
|
10271
|
+
};
|
|
10272
|
+
if (result.error || ((_a = result.value) == null ? void 0 : _a.type) === "control-flow-excluded") {
|
|
10273
|
+
this.#latest = void 0;
|
|
10274
|
+
this.#coalesced = 0;
|
|
10275
|
+
}
|
|
10276
|
+
this.#resolve(this.result);
|
|
10277
|
+
}
|
|
10278
|
+
subscribe(listener) {
|
|
10279
|
+
if (this.#disposed) return () => {
|
|
10280
|
+
};
|
|
10281
|
+
if (this.#listener) throw new Error("Graph input stream already has a subscriber");
|
|
10282
|
+
this.#listener = listener;
|
|
10283
|
+
const dispose = () => {
|
|
10284
|
+
if (this.#listener !== listener) return;
|
|
10285
|
+
this.#listener = void 0;
|
|
10286
|
+
this.#disposed = true;
|
|
10287
|
+
this.#latest = void 0;
|
|
10288
|
+
};
|
|
10289
|
+
try {
|
|
10290
|
+
if (this.#latest) listener(this.#latest, this.#coalesced);
|
|
10291
|
+
return dispose;
|
|
10292
|
+
} catch (error) {
|
|
10293
|
+
dispose();
|
|
10294
|
+
throw error;
|
|
10295
|
+
} finally {
|
|
10296
|
+
this.#latest = void 0;
|
|
10297
|
+
this.#coalesced = 0;
|
|
10298
|
+
}
|
|
10299
|
+
}
|
|
10300
|
+
};
|
|
10301
|
+
|
|
10302
|
+
// src/model/StreamingWatchTopology.ts
|
|
10303
|
+
function canStreamThroughGraphCaller(node) {
|
|
10304
|
+
return (node.type === "subGraph" || node.type === "referencedGraphAlias") && !node.disabled && !node.isConditional && !node.isSplitRun && !node.data.useErrorOutput;
|
|
10305
|
+
}
|
|
10306
|
+
function canStreamThroughGraphInput(node) {
|
|
10307
|
+
return node.type === "graphInput" && !node.disabled && !node.isConditional && !node.isSplitRun && !node.data.useDefaultValueInput;
|
|
10308
|
+
}
|
|
10309
|
+
function getProjectStreamingOutputWatchConnections({
|
|
10310
|
+
project,
|
|
10311
|
+
graph,
|
|
10312
|
+
referencedProjects,
|
|
10313
|
+
registry,
|
|
10314
|
+
frozenNodeOutputs = {},
|
|
10315
|
+
isNodeFrozen,
|
|
10316
|
+
fullGraphCallers
|
|
10317
|
+
}) {
|
|
10318
|
+
var _a, _b, _c, _d;
|
|
10319
|
+
const currentProject = {
|
|
10320
|
+
...project,
|
|
10321
|
+
graphs: { ...project.graphs, ...((_a = graph.metadata) == null ? void 0 : _a.id) ? { [graph.metadata.id]: graph } : {} }
|
|
10322
|
+
};
|
|
10323
|
+
const projects = { ...referencedProjects, [project.metadata.id]: currentProject };
|
|
10324
|
+
const contexts = /* @__PURE__ */ new Map();
|
|
10325
|
+
const isFrozen = (owner, candidate, node) => {
|
|
10326
|
+
var _a2, _b2, _c2;
|
|
10327
|
+
return (isNodeFrozen == null ? void 0 : isNodeFrozen(owner, candidate, node)) ?? (owner === currentProject && !!(((_a2 = candidate.metadata) == null ? void 0 : _a2.id) && ((_c2 = (_b2 = frozenNodeOutputs[candidate.metadata.id]) == null ? void 0 : _b2[node.id]) == null ? void 0 : _c2.length)));
|
|
10328
|
+
};
|
|
10329
|
+
for (const owner of Object.values(projects)) {
|
|
10330
|
+
for (const candidate of Object.values(owner.graphs)) {
|
|
10331
|
+
const nodes = Object.fromEntries(
|
|
10332
|
+
candidate.nodes.map((node) => [node.id, resolveNodePrefabInstance(owner, node)])
|
|
10333
|
+
);
|
|
10334
|
+
const connectionsByNode = /* @__PURE__ */ new Map();
|
|
10335
|
+
for (const edge of candidate.connections) {
|
|
10336
|
+
for (const id of /* @__PURE__ */ new Set([edge.inputNodeId, edge.outputNodeId])) {
|
|
10337
|
+
const edges = connectionsByNode.get(id) ?? [];
|
|
10338
|
+
edges.push(edge);
|
|
10339
|
+
connectionsByNode.set(id, edges);
|
|
10340
|
+
}
|
|
10341
|
+
}
|
|
10342
|
+
const ports = /* @__PURE__ */ new Map();
|
|
10343
|
+
const getPorts = (nodeId) => {
|
|
10344
|
+
const cached = ports.get(nodeId);
|
|
10345
|
+
if (cached) return cached;
|
|
10346
|
+
const node = nodes[nodeId];
|
|
10347
|
+
let definitions = { inputs: /* @__PURE__ */ new Set(), outputs: /* @__PURE__ */ new Set() };
|
|
10348
|
+
try {
|
|
10349
|
+
if (!node) return definitions;
|
|
10350
|
+
const impl = registry.createDynamicImpl(node);
|
|
10351
|
+
const connections = connectionsByNode.get(node.id) ?? [];
|
|
10352
|
+
definitions = {
|
|
10353
|
+
inputs: new Set(
|
|
10354
|
+
impl.getInputDefinitionsIncludingBuiltIn(connections, nodes, owner, projects).map((port) => port.id)
|
|
10355
|
+
),
|
|
10356
|
+
outputs: new Set(impl.getOutputDefinitions(connections, nodes, owner, projects).map((port) => port.id))
|
|
10357
|
+
};
|
|
10358
|
+
} catch {
|
|
10359
|
+
}
|
|
10360
|
+
ports.set(nodeId, definitions);
|
|
10361
|
+
return definitions;
|
|
10362
|
+
};
|
|
10363
|
+
const incomingByNode = /* @__PURE__ */ new Map();
|
|
10364
|
+
const incoming = (nodeId) => {
|
|
10365
|
+
let edges = incomingByNode.get(nodeId);
|
|
10366
|
+
if (!edges) {
|
|
10367
|
+
edges = (connectionsByNode.get(nodeId) ?? []).filter(
|
|
10368
|
+
(edge) => edge.inputNodeId === nodeId && getPorts(nodeId).inputs.has(edge.inputId) && getPorts(edge.outputNodeId).outputs.has(edge.outputId)
|
|
10369
|
+
);
|
|
10370
|
+
incomingByNode.set(nodeId, edges);
|
|
10371
|
+
}
|
|
10372
|
+
return edges;
|
|
10373
|
+
};
|
|
10374
|
+
contexts.set(candidate, { project: owner, nodes, incoming, marked: /* @__PURE__ */ new Set() });
|
|
10375
|
+
}
|
|
10376
|
+
}
|
|
10377
|
+
const callers = /* @__PURE__ */ new Map();
|
|
10378
|
+
for (const [parent, context] of contexts) {
|
|
10379
|
+
for (const node of Object.values(context.nodes)) {
|
|
10380
|
+
if (node.disabled || isFrozen(context.project, parent, node) || !canStreamThroughGraphCaller(node)) continue;
|
|
10381
|
+
const caller = node;
|
|
10382
|
+
const owner = caller.type === "subGraph" ? context.project : projects[caller.data.projectId];
|
|
10383
|
+
const child = owner == null ? void 0 : owner.graphs[caller.data.graphId];
|
|
10384
|
+
if (!child) continue;
|
|
10385
|
+
let selected;
|
|
10386
|
+
if (caller.type === "subGraph" && caller.data.skipUnusedOutputs && !caller.data.useAsGraphPartialOutput && !(parent === graph && (fullGraphCallers == null ? void 0 : fullGraphCallers.has(caller.id)))) {
|
|
10387
|
+
const childContext = contexts.get(child);
|
|
10388
|
+
const outputNames = new Set(
|
|
10389
|
+
Object.values(childContext.nodes).filter((node2) => node2.type === "graphOutput").map((node2) => node2.data.id)
|
|
10390
|
+
);
|
|
10391
|
+
const outputs = parent.connections.filter((edge) => edge.outputNodeId === caller.id).map((edge) => edge.outputId).filter((id) => outputNames.has(id));
|
|
10392
|
+
try {
|
|
10393
|
+
selected = createGraphOutputSelection(
|
|
10394
|
+
{ ...child, nodes: Object.values(childContext.nodes) },
|
|
10395
|
+
outputs,
|
|
10396
|
+
(node2) => childContext.incoming(node2.id).map((edge) => childContext.nodes[edge.outputNodeId])
|
|
10397
|
+
).nodeIds;
|
|
10398
|
+
} catch {
|
|
10399
|
+
continue;
|
|
10400
|
+
}
|
|
10401
|
+
}
|
|
10402
|
+
const entries2 = callers.get(child) ?? [];
|
|
10403
|
+
entries2.push({ graph: parent, node, selected });
|
|
10404
|
+
callers.set(child, entries2);
|
|
10405
|
+
}
|
|
10406
|
+
}
|
|
10407
|
+
const pending = [];
|
|
10408
|
+
for (const [candidate, context] of contexts) {
|
|
10409
|
+
for (const node of Object.values(context.nodes)) {
|
|
10410
|
+
if (node.type !== "watchStreamingOutput" || node.disabled || isFrozen(context.project, candidate, node)) continue;
|
|
10411
|
+
const inputs = context.incoming(node.id).filter((edge) => edge.inputId === "stream");
|
|
10412
|
+
if (inputs.length === 1) pending.push({ graph: candidate, edge: inputs[0] });
|
|
10413
|
+
}
|
|
10414
|
+
}
|
|
10415
|
+
while (pending.length) {
|
|
10416
|
+
const { graph: candidate, edge } = pending.pop();
|
|
10417
|
+
const context = contexts.get(candidate);
|
|
10418
|
+
if (context.marked.has(edge)) continue;
|
|
10419
|
+
const route = /* @__PURE__ */ new Set([edge]);
|
|
10420
|
+
let producerEdge = edge;
|
|
10421
|
+
let source = context.nodes[producerEdge.outputNodeId];
|
|
10422
|
+
while (source && canRenderDataBusNode(source)) {
|
|
10423
|
+
const channel = getDataBusOutputChannelIndex(producerEdge.outputId);
|
|
10424
|
+
const providers2 = context.incoming(source.id).filter((input) => getDataBusInputChannelIndex(input.inputId) === channel);
|
|
10425
|
+
if (channel == null || providers2.length !== 1 || route.has(providers2[0])) {
|
|
10426
|
+
source = void 0;
|
|
10427
|
+
break;
|
|
10428
|
+
}
|
|
10429
|
+
producerEdge = providers2[0];
|
|
10430
|
+
route.add(producerEdge);
|
|
10431
|
+
source = context.nodes[producerEdge.outputNodeId];
|
|
10432
|
+
}
|
|
10433
|
+
if (!source || source.disabled || source.type === "dataBus") continue;
|
|
10434
|
+
if (((_b = context.nodes[edge.inputNodeId]) == null ? void 0 : _b.type) === "graphOutput" && source.isSplitRun) continue;
|
|
10435
|
+
for (const segment of route) context.marked.add(segment);
|
|
10436
|
+
if (source.isSplitRun || isFrozen(context.project, candidate, source)) continue;
|
|
10437
|
+
if (source.type === "graphInput" && producerEdge.outputId === "data") {
|
|
10438
|
+
if (!canStreamThroughGraphInput(source)) continue;
|
|
10439
|
+
const inputName = source.data.id;
|
|
10440
|
+
for (const parent of callers.get(candidate) ?? []) {
|
|
10441
|
+
if (parent.selected && !parent.selected.has(edge.inputNodeId)) continue;
|
|
10442
|
+
for (const input of contexts.get(parent.graph).incoming(parent.node.id)) {
|
|
10443
|
+
if (input.inputId === inputName) pending.push({ graph: parent.graph, edge: input });
|
|
10444
|
+
}
|
|
10445
|
+
}
|
|
10446
|
+
continue;
|
|
10447
|
+
}
|
|
10448
|
+
if (!canStreamThroughGraphCaller(source)) continue;
|
|
10449
|
+
const caller = source;
|
|
10450
|
+
const childProject = caller.type === "subGraph" ? context.project : projects[caller.data.projectId];
|
|
10451
|
+
const child = childProject == null ? void 0 : childProject.graphs[caller.data.graphId];
|
|
10452
|
+
const childContext = child && contexts.get(child);
|
|
10453
|
+
if (!child || !childContext) continue;
|
|
10454
|
+
const outputs = Object.values(childContext.nodes).filter(
|
|
10455
|
+
(node) => node.type === "graphOutput" && !node.disabled && node.data.id === producerEdge.outputId
|
|
10456
|
+
);
|
|
10457
|
+
if (outputs.length !== 1) continue;
|
|
10458
|
+
const output = outputs[0];
|
|
10459
|
+
if (output.isConditional || output.isSplitRun || isFrozen(childProject, child, output)) continue;
|
|
10460
|
+
for (const input of childContext.incoming(output.id)) {
|
|
10461
|
+
if (input.inputId === "value" && !((_c = childContext.nodes[input.outputNodeId]) == null ? void 0 : _c.isSplitRun)) {
|
|
10462
|
+
pending.push({ graph: child, edge: input });
|
|
10463
|
+
}
|
|
10464
|
+
}
|
|
10465
|
+
}
|
|
10466
|
+
return ((_d = contexts.get(graph)) == null ? void 0 : _d.marked) ?? /* @__PURE__ */ new Set();
|
|
10467
|
+
}
|
|
10468
|
+
|
|
10469
|
+
// src/model/nodes/GraphInputNode.ts
|
|
10470
|
+
var import_non_secure7 = require("nanoid/non-secure");
|
|
10471
|
+
var import_ts_dedent3 = require("ts-dedent");
|
|
10472
|
+
var GraphInputNodeImpl = class extends NodeImpl {
|
|
10473
|
+
static create() {
|
|
10474
|
+
const chartNode = {
|
|
10475
|
+
type: "graphInput",
|
|
10476
|
+
title: "Graph Input",
|
|
10477
|
+
id: (0, import_non_secure7.nanoid)(),
|
|
10478
|
+
visualData: {
|
|
10479
|
+
x: 0,
|
|
10480
|
+
y: 0,
|
|
10481
|
+
width: 300
|
|
10482
|
+
},
|
|
10483
|
+
data: {
|
|
10484
|
+
id: "input",
|
|
10485
|
+
dataType: "string",
|
|
10486
|
+
defaultValue: void 0,
|
|
10487
|
+
useDefaultValueInput: false
|
|
10488
|
+
}
|
|
10489
|
+
};
|
|
10490
|
+
return chartNode;
|
|
10491
|
+
}
|
|
10492
|
+
getInputDefinitions() {
|
|
10493
|
+
if (this.data.useDefaultValueInput) {
|
|
10494
|
+
return [
|
|
10495
|
+
{
|
|
10496
|
+
id: "default",
|
|
10497
|
+
title: "Default Value",
|
|
10498
|
+
dataType: this.chartNode.data.dataType
|
|
10499
|
+
}
|
|
10500
|
+
];
|
|
10501
|
+
}
|
|
10502
|
+
return [];
|
|
10503
|
+
}
|
|
10504
|
+
getOutputDefinitions() {
|
|
10505
|
+
return [
|
|
10506
|
+
{
|
|
10507
|
+
id: "data",
|
|
10508
|
+
title: this.data.id,
|
|
10509
|
+
dataType: this.chartNode.data.dataType
|
|
10510
|
+
}
|
|
10511
|
+
];
|
|
10512
|
+
}
|
|
10513
|
+
getEditors() {
|
|
10514
|
+
return [
|
|
10515
|
+
{
|
|
10516
|
+
type: "string",
|
|
10517
|
+
label: "ID",
|
|
10518
|
+
dataKey: "id"
|
|
10519
|
+
},
|
|
10520
|
+
{
|
|
10521
|
+
type: "dataTypeSelector",
|
|
10522
|
+
label: "Data Type",
|
|
10523
|
+
dataKey: "dataType"
|
|
10524
|
+
},
|
|
10525
|
+
{
|
|
10526
|
+
type: "anyData",
|
|
10527
|
+
label: "Default Value",
|
|
10528
|
+
dataKey: "defaultValue",
|
|
10529
|
+
useInputToggleDataKey: "useDefaultValueInput"
|
|
10530
|
+
},
|
|
10531
|
+
{
|
|
10532
|
+
type: "dropdown",
|
|
10533
|
+
label: "Editor",
|
|
10534
|
+
dataKey: "editor",
|
|
10535
|
+
defaultValue: "auto",
|
|
10536
|
+
options: [
|
|
10537
|
+
{ label: "None", value: "none" },
|
|
10538
|
+
{ label: "Auto", value: "auto" },
|
|
10539
|
+
{ label: "String", value: "string" },
|
|
10540
|
+
{ label: "Number", value: "number" },
|
|
10541
|
+
{ label: "Code", value: "code" },
|
|
10542
|
+
{ label: "Data Type", value: "dataTypeSelector" },
|
|
10543
|
+
{ label: "String List", value: "stringList" },
|
|
10544
|
+
{ label: "Key Value Pairs", value: "keyValuePair" },
|
|
10545
|
+
{ label: "Toggle", value: "toggle" }
|
|
10546
|
+
],
|
|
10547
|
+
helperMessage: "The editor to use when editing this value in the UI. Make sure this matches the data type."
|
|
10548
|
+
}
|
|
10549
|
+
];
|
|
10550
|
+
}
|
|
10551
|
+
getBody() {
|
|
10552
|
+
return import_ts_dedent3.dedent`
|
|
10553
|
+
${this.data.id}
|
|
10554
|
+
Type: ${this.data.dataType}
|
|
10555
|
+
${this.data.defaultValue == null ? "" : `Default: ${this.data.defaultValue}`}
|
|
10556
|
+
`;
|
|
10557
|
+
}
|
|
10558
|
+
static getUIData() {
|
|
10559
|
+
return {
|
|
10560
|
+
infoBoxBody: import_ts_dedent3.dedent`
|
|
10561
|
+
Defines an input for the graph which can be passed in when the graph is called, or defines one of the input ports when the graph is a subgraph.
|
|
10562
|
+
`,
|
|
10563
|
+
infoBoxTitle: "Graph Input Node",
|
|
10564
|
+
contextMenuTitle: "Graph Input",
|
|
10565
|
+
group: ["Input/Output"]
|
|
10566
|
+
};
|
|
10567
|
+
}
|
|
10568
|
+
async process(inputs, context) {
|
|
10569
|
+
const value = resolveGraphInputValue(this.data, context.graphInputs[this.data.id], inputs);
|
|
10570
|
+
context.graphInputNodeValues[this.data.id] = value;
|
|
10571
|
+
return { ["data"]: value };
|
|
10572
|
+
}
|
|
10573
|
+
};
|
|
10574
|
+
function resolveGraphInputValue(data, input, inputs = {}) {
|
|
10575
|
+
let inputValue = input == null ? void 0 : coerceTypeOptional(input, data.dataType);
|
|
10576
|
+
if (inputValue == null && data.useDefaultValueInput) {
|
|
10577
|
+
inputValue = coerceTypeOptional(inputs["default"], data.dataType);
|
|
10578
|
+
}
|
|
10579
|
+
if (inputValue == null) {
|
|
10580
|
+
inputValue = coerceTypeOptional(inferType(data.defaultValue), data.dataType) || getDefaultValue(data.dataType);
|
|
10581
|
+
}
|
|
10582
|
+
if (inputValue == null && isArrayDataType(data.dataType)) {
|
|
10583
|
+
inputValue = { type: data.dataType, value: [] };
|
|
10584
|
+
}
|
|
10585
|
+
return { type: data.dataType, value: inputValue };
|
|
10586
|
+
}
|
|
10587
|
+
var graphInputNode = nodeDefinition(GraphInputNodeImpl, "Graph Input");
|
|
10588
|
+
|
|
10223
10589
|
// src/integrations/KnowledgeStoreFieldPolicy.ts
|
|
10224
10590
|
function createKnowledgeStoreFieldDraftDefaults(fields) {
|
|
10225
10591
|
return Object.fromEntries(
|
|
@@ -11269,9 +11635,6 @@ var graphProcessorGraphOverride = Symbol("graphProcessorGraphOverride");
|
|
|
11269
11635
|
var consumedAsyncBranchTriggerOverride = Symbol("consumedAsyncBranchTriggerOverride");
|
|
11270
11636
|
var asyncBranchInputAnchorsOverride = Symbol("asyncBranchInputAnchorsOverride");
|
|
11271
11637
|
var consumedStreamingWatchNodeOverride = Symbol("consumedStreamingWatchNodeOverride");
|
|
11272
|
-
function isNamedGraphBoundaryCaller(node) {
|
|
11273
|
-
return node.type === "subGraph" || node.type === "referencedGraphAlias";
|
|
11274
|
-
}
|
|
11275
11638
|
function createGraphOutputsOverlay(parent) {
|
|
11276
11639
|
const writes = {};
|
|
11277
11640
|
const view = new Proxy(writes, {
|
|
@@ -11414,6 +11777,12 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
11414
11777
|
#graphOutputPartialListener;
|
|
11415
11778
|
#consumedStreamingWatchNodeId;
|
|
11416
11779
|
#streamingWatchInvocation;
|
|
11780
|
+
#graphInputStreams = {};
|
|
11781
|
+
#callerInputStreams = /* @__PURE__ */ new Map();
|
|
11782
|
+
#inputStreamRoutes = /* @__PURE__ */ new Map();
|
|
11783
|
+
#streamCallerTasks = /* @__PURE__ */ new Set();
|
|
11784
|
+
#inputStreamDisposers = [];
|
|
11785
|
+
#pendingGraphInputFinals = /* @__PURE__ */ new Map();
|
|
11417
11786
|
#registry;
|
|
11418
11787
|
#concurrency;
|
|
11419
11788
|
#executionPlanCacheMode;
|
|
@@ -11426,7 +11795,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
11426
11795
|
#storedValueStore;
|
|
11427
11796
|
#knowledgeStores;
|
|
11428
11797
|
#useSeededExecutionPlanOnNextRun = false;
|
|
11429
|
-
id = (0,
|
|
11798
|
+
id = (0, import_non_secure8.nanoid)();
|
|
11430
11799
|
#includeTrace = true;
|
|
11431
11800
|
executor;
|
|
11432
11801
|
/** If set, specifies the node(s) that the graph will run TO, instead of the nodes without any dependents. */
|
|
@@ -11971,6 +12340,12 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
11971
12340
|
"initializeGraphRun",
|
|
11972
12341
|
() => this.#initializeGraphRun(context, inputs, contextValues)
|
|
11973
12342
|
);
|
|
12343
|
+
this.#graphInputStreams = options2.graphInputStreams ?? {};
|
|
12344
|
+
this.#callerInputStreams = /* @__PURE__ */ new Map();
|
|
12345
|
+
this.#inputStreamRoutes = /* @__PURE__ */ new Map();
|
|
12346
|
+
this.#streamCallerTasks = /* @__PURE__ */ new Set();
|
|
12347
|
+
this.#inputStreamDisposers = [];
|
|
12348
|
+
this.#pendingGraphInputFinals = /* @__PURE__ */ new Map();
|
|
11974
12349
|
await this.#profileRuntimeAsync("loadProjectReferences", () => this.#loadProjectReferences());
|
|
11975
12350
|
this.#profileRuntimeSync(
|
|
11976
12351
|
"initializeProjectGlobalVariables",
|
|
@@ -12002,12 +12377,14 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
12002
12377
|
this.#prepareAsyncBranchTopology();
|
|
12003
12378
|
this.#prepareStreamingWatchTopology();
|
|
12004
12379
|
this.#prepareGraphOutputPartialTopology();
|
|
12380
|
+
this.#prepareGraphInputStreamRoutes();
|
|
12005
12381
|
} catch (error) {
|
|
12006
12382
|
const normalizedError = getError(error);
|
|
12007
12383
|
await this.#emitRootStartupError(normalizedError);
|
|
12008
12384
|
throw normalizedError;
|
|
12009
12385
|
}
|
|
12010
12386
|
await this.#profileRuntimeAsync("emitGraphStart", () => this.#emitGraphStart());
|
|
12387
|
+
this.#subscribeGraphInputStreams();
|
|
12011
12388
|
await this.#profileRuntimeAsync(
|
|
12012
12389
|
"emitInitialProjectGlobalVariables",
|
|
12013
12390
|
() => this.#emitInitialProjectGlobalVariables()
|
|
@@ -12034,6 +12411,12 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
12034
12411
|
await this.#profileRuntimeAsync("throwIfGraphErrored", () => this.#throwIfGraphErrored());
|
|
12035
12412
|
return await this.#profileRuntimeAsync("finalizeGraphRun", () => this.#finalizeGraphRun());
|
|
12036
12413
|
} finally {
|
|
12414
|
+
for (const dispose of this.#inputStreamDisposers) dispose();
|
|
12415
|
+
this.#pendingGraphInputFinals.clear();
|
|
12416
|
+
for (const streams of this.#callerInputStreams.values()) {
|
|
12417
|
+
for (const relay of Object.values(streams))
|
|
12418
|
+
relay.finish({ error: new Error("Graph input stream owner finished") });
|
|
12419
|
+
}
|
|
12037
12420
|
await this.#drainSchedulerBoundaries();
|
|
12038
12421
|
this.#graphOutputPartialListener = void 0;
|
|
12039
12422
|
this.#lifecycle.complete();
|
|
@@ -12092,8 +12475,8 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
12092
12475
|
this.#graphRunId = this.#executionIdentityOverride.graphRunId;
|
|
12093
12476
|
this.#parentGraphRunId = this.#executionIdentityOverride.parentGraphRunId;
|
|
12094
12477
|
} else {
|
|
12095
|
-
this.#rootRunId = this.#parent ? this.#parent.#rootRunId : (0,
|
|
12096
|
-
this.#graphRunId = (0,
|
|
12478
|
+
this.#rootRunId = this.#parent ? this.#parent.#rootRunId : (0, import_non_secure8.nanoid)();
|
|
12479
|
+
this.#graphRunId = (0, import_non_secure8.nanoid)();
|
|
12097
12480
|
this.#parentGraphRunId = this.#parent ? this.#parent.#graphRunId : void 0;
|
|
12098
12481
|
}
|
|
12099
12482
|
}
|
|
@@ -12282,13 +12665,37 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
12282
12665
|
((_a = this.#graphOutputSelection) == null ? void 0 : _a.startNodes) ?? getStartNodes(this.#executionState, this.#executionGraphNodes, this.runToNodeIds)
|
|
12283
12666
|
);
|
|
12284
12667
|
await this.#processingQueue.onIdle();
|
|
12668
|
+
if (Object.keys(this.#graphInputStreams).length) {
|
|
12669
|
+
await this.#waitForGraphInputStreams();
|
|
12670
|
+
for (const [nodeId, outputs] of this.#pendingGraphInputFinals) {
|
|
12671
|
+
this.#finishStreamingOutputWatches(this.#nodesById[nodeId], outputs);
|
|
12672
|
+
}
|
|
12673
|
+
this.#pendingGraphInputFinals.clear();
|
|
12674
|
+
for (const node of this.#executionGraphNodes) {
|
|
12675
|
+
if (!this.#isNodeSelected(node.id)) continue;
|
|
12676
|
+
void this.#processingQueue.add(() => this.#processNodeIfAllInputsAvailable(node));
|
|
12677
|
+
}
|
|
12678
|
+
await this.#processingQueue.onIdle();
|
|
12679
|
+
}
|
|
12680
|
+
while (this.#streamCallerTasks.size) {
|
|
12681
|
+
for (const [sourceId, routes] of this.#inputStreamRoutes) {
|
|
12682
|
+
if (this.#currentlyProcessing.has(sourceId) || routes.every(({ relay }) => relay.result)) continue;
|
|
12683
|
+
const failedDependency = this.getDependencyNodesDeep(sourceId).find((id) => this.#erroredNodes.has(id));
|
|
12684
|
+
if (failedDependency) {
|
|
12685
|
+
const error = getError(this.#erroredNodes.get(failedDependency));
|
|
12686
|
+
for (const { relay } of routes) relay.finish({ error });
|
|
12687
|
+
}
|
|
12688
|
+
}
|
|
12689
|
+
await Promise.race(this.#streamCallerTasks);
|
|
12690
|
+
await this.#processingQueue.onIdle();
|
|
12691
|
+
}
|
|
12285
12692
|
this.#markUnqueuedNodesIgnored();
|
|
12286
12693
|
}
|
|
12287
12694
|
#canUseFastAcyclicScheduler() {
|
|
12288
12695
|
if (this.#scheduler !== "fast-acyclic") {
|
|
12289
12696
|
return false;
|
|
12290
12697
|
}
|
|
12291
|
-
if (this.#graphOutputSelection || this.#hasPreloadedData || this.runToNodeIds || this.slowMode || this.#includeTrace) {
|
|
12698
|
+
if (this.#graphOutputSelection || this.#callerInputStreams.size > 0 || Object.keys(this.#graphInputStreams).length > 0 || this.#hasPreloadedData || this.runToNodeIds || this.slowMode || this.#includeTrace) {
|
|
12292
12699
|
return false;
|
|
12293
12700
|
}
|
|
12294
12701
|
if (this.#nodesNotInCycle.length !== this.#executionGraphNodes.length) {
|
|
@@ -12549,6 +12956,17 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
12549
12956
|
/** If all inputs are present, all conditions met, processes the node. */
|
|
12550
12957
|
async #processNodeIfAllInputsAvailable(node, options2 = {}) {
|
|
12551
12958
|
if (!this.#isNodeSelected(node.id)) return [];
|
|
12959
|
+
if (this.#callerInputStreams.has(node.id) && !options2.streamingDispatch) {
|
|
12960
|
+
const task = this.#processNodeIfAllInputsAvailable(node, { ...options2, streamingDispatch: true }).catch(
|
|
12961
|
+
(error) => this.#nodeErrored(node, error, (0, import_non_secure8.nanoid)())
|
|
12962
|
+
);
|
|
12963
|
+
this.#streamCallerTasks.add(task);
|
|
12964
|
+
void task.then(
|
|
12965
|
+
() => this.#streamCallerTasks.delete(task),
|
|
12966
|
+
() => this.#streamCallerTasks.delete(task)
|
|
12967
|
+
);
|
|
12968
|
+
return [];
|
|
12969
|
+
}
|
|
12552
12970
|
const { queueOutputNodes = true } = options2;
|
|
12553
12971
|
const builtInNode = node;
|
|
12554
12972
|
const inputNodesProfileStart = this.#startRuntimeProfile();
|
|
@@ -12561,6 +12979,31 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
12561
12979
|
if (this.#shouldSkipNodeProcessing(node, inputNodes)) {
|
|
12562
12980
|
return [];
|
|
12563
12981
|
}
|
|
12982
|
+
const namedInput = node.type === "graphInput" ? node.data.id : void 0;
|
|
12983
|
+
const inputStream = namedInput != null && Object.hasOwn(this.#graphInputStreams, namedInput) ? this.#graphInputStreams[namedInput] : void 0;
|
|
12984
|
+
if (inputStream) {
|
|
12985
|
+
const terminals = Object.values(this.#graphInputStreams).map((stream) => stream.result);
|
|
12986
|
+
const terminal = terminals.find((result) => result == null ? void 0 : result.error) ?? terminals.find((result) => {
|
|
12987
|
+
var _a;
|
|
12988
|
+
return ((_a = result == null ? void 0 : result.value) == null ? void 0 : _a.type) === "control-flow-excluded";
|
|
12989
|
+
}) ?? inputStream.result;
|
|
12990
|
+
if (!terminal) return [];
|
|
12991
|
+
if (terminal.error) {
|
|
12992
|
+
await this.#nodeErrored(node, terminal.error, (0, import_non_secure8.nanoid)());
|
|
12993
|
+
return [];
|
|
12994
|
+
}
|
|
12995
|
+
if (terminal.value.type === "control-flow-excluded") {
|
|
12996
|
+
return this.#excludeNode(node, (0, import_non_secure8.nanoid)(), {}, "streamed input is excluded", { queueOutputNodes });
|
|
12997
|
+
}
|
|
12998
|
+
if (terminals.some((result) => !result)) return [];
|
|
12999
|
+
} else if (node.type !== "graphInput" && !this.#callerInputStreams.has(node.id) && Object.values(this.#graphInputStreams).some(
|
|
13000
|
+
(stream) => {
|
|
13001
|
+
var _a;
|
|
13002
|
+
return !stream.result || stream.result.error || ((_a = stream.result.value) == null ? void 0 : _a.type) === "control-flow-excluded";
|
|
13003
|
+
}
|
|
13004
|
+
)) {
|
|
13005
|
+
return [];
|
|
13006
|
+
}
|
|
12564
13007
|
const attachedData = this.#getAttachedDataTo(node);
|
|
12565
13008
|
if (this.#shouldSkipCompletedRaceNode(node, attachedData)) {
|
|
12566
13009
|
return [];
|
|
@@ -12571,7 +13014,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
12571
13014
|
const loopExclusion = this.#excludedDueToControlFlow(
|
|
12572
13015
|
node,
|
|
12573
13016
|
inputValues,
|
|
12574
|
-
(0,
|
|
13017
|
+
(0, import_non_secure8.nanoid)(),
|
|
12575
13018
|
LOOP_NOT_BROKEN_SENTINEL,
|
|
12576
13019
|
{ queueOutputNodes }
|
|
12577
13020
|
);
|
|
@@ -12579,12 +13022,20 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
12579
13022
|
this.#emitTraceEvent(`Node ${node.title} is excluded due to control flow`);
|
|
12580
13023
|
return loopExclusion === true ? [] : loopExclusion;
|
|
12581
13024
|
}
|
|
12582
|
-
const
|
|
13025
|
+
const streamedInputs = this.#callerInputStreams.get(node.id);
|
|
13026
|
+
const blockingInputNodes = streamedInputs ? inputNodes.filter(
|
|
13027
|
+
(inputNode) => this.#getInputConnectionsForNode(node).some(
|
|
13028
|
+
(edge) => edge.outputNodeId === inputNode.id && !streamedInputs[edge.inputId]
|
|
13029
|
+
)
|
|
13030
|
+
) : inputNodes;
|
|
13031
|
+
const waitingForInputNode = getWaitingForInputNode(this.#executionState, node, blockingInputNodes, inputValues);
|
|
12583
13032
|
if (waitingForInputNode) {
|
|
12584
|
-
this.#emitTraceEvent(
|
|
13033
|
+
this.#emitTraceEvent(
|
|
13034
|
+
`Node ${node.title} is waiting for input node ${waitingForInputNode.title || waitingForInputNode.id}`
|
|
13035
|
+
);
|
|
12585
13036
|
return [];
|
|
12586
13037
|
}
|
|
12587
|
-
const exclusion = this.#excludedDueToControlFlow(node, inputValues, (0,
|
|
13038
|
+
const exclusion = this.#excludedDueToControlFlow(node, inputValues, (0, import_non_secure8.nanoid)(), void 0, {
|
|
12588
13039
|
queueOutputNodes
|
|
12589
13040
|
});
|
|
12590
13041
|
if (exclusion) {
|
|
@@ -12597,7 +13048,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
12597
13048
|
}
|
|
12598
13049
|
const managedAsyncBranchWatchViolation = node.type === "startBackgroundBranch" && this.#getActiveOutputPortIds(node).size > 0 ? this.#getManagedAsyncBranchWatchViolation(node) : void 0;
|
|
12599
13050
|
if (managedAsyncBranchWatchViolation) {
|
|
12600
|
-
await this.#nodeErrored(node, managedAsyncBranchWatchViolation, (0,
|
|
13051
|
+
await this.#nodeErrored(node, managedAsyncBranchWatchViolation, (0, import_non_secure8.nanoid)());
|
|
12601
13052
|
return [];
|
|
12602
13053
|
}
|
|
12603
13054
|
if (this.#beginNodeProcessing(node, attachedData) === false) {
|
|
@@ -12686,7 +13137,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
12686
13137
|
}
|
|
12687
13138
|
#excludeNodeWithMissingRequiredInputs(node, inputValues, missingRequiredInputs, options2 = {}) {
|
|
12688
13139
|
const exclusion = getMissingRequiredInputExclusion(node, missingRequiredInputs);
|
|
12689
|
-
const processId = (0,
|
|
13140
|
+
const processId = (0, import_non_secure8.nanoid)();
|
|
12690
13141
|
this.#emitTraceEvent(exclusion.traceMessage);
|
|
12691
13142
|
return this.#excludeNode(node, processId, inputValues, exclusion.reason, options2);
|
|
12692
13143
|
}
|
|
@@ -12913,7 +13364,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
12913
13364
|
parentGraphRunId: this.#parentGraphRunId
|
|
12914
13365
|
} : {
|
|
12915
13366
|
rootRunId: root.#rootRunId,
|
|
12916
|
-
graphRunId: (0,
|
|
13367
|
+
graphRunId: (0, import_non_secure8.nanoid)(),
|
|
12917
13368
|
parentGraphRunId: sameGraphOwner.#graphRunId
|
|
12918
13369
|
};
|
|
12919
13370
|
processor.preloadNodeData(triggerNode.id, triggerOutputs);
|
|
@@ -12994,7 +13445,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
12994
13445
|
return nodeData;
|
|
12995
13446
|
}
|
|
12996
13447
|
async #processNode(node, inputValues) {
|
|
12997
|
-
const processId = (0,
|
|
13448
|
+
const processId = (0, import_non_secure8.nanoid)();
|
|
12998
13449
|
if (this.#abortController.signal.aborted) {
|
|
12999
13450
|
await this.#nodeErrored(node, createGraphAbortErrorFromSignal(this.#abortController.signal), processId);
|
|
13000
13451
|
this.#successfulAbortTerminalProcessIds.delete(processId);
|
|
@@ -13181,6 +13632,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
13181
13632
|
}
|
|
13182
13633
|
async #nodeErrored(node, e, processId, durationMs, splitRunDurationMs, resultOrigin = "executed", outputs, splitOutputs) {
|
|
13183
13634
|
const error = getError(e);
|
|
13635
|
+
for (const route of this.#inputStreamRoutes.get(node.id) ?? []) route.relay.finish({ error });
|
|
13184
13636
|
const retainedOutputs = splitOutputs === void 0 ? outputs ?? this.#takeFailureOutputs(processId, 0) : outputs;
|
|
13185
13637
|
const exclusionReason = this.#getErrorExclusionReason(node, error, processId);
|
|
13186
13638
|
if (exclusionReason) {
|
|
@@ -13420,9 +13872,16 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
13420
13872
|
#createNodeProcessContext(node, inputValues, index, processId, nodeAbortController, partialOutput, toolCallTraceSource, markResultAsEditorCacheHit) {
|
|
13421
13873
|
var _a, _b;
|
|
13422
13874
|
const plugin = this.#registry.getPluginFor(node.type);
|
|
13423
|
-
const
|
|
13875
|
+
const acceptsPartialOutputs = () => {
|
|
13876
|
+
if (nodeAbortController.signal.aborted) return false;
|
|
13877
|
+
const active = this.#nodeAbortControllers.get(node.id);
|
|
13878
|
+
return active === nodeAbortController || active instanceof Set && active.has(nodeAbortController);
|
|
13879
|
+
};
|
|
13880
|
+
const onGraphOutputPartial = canStreamThroughGraphCaller(node) && (this.#streamingWatchPlansBySourceNodeId.has(node.id) || this.#inputStreamRoutes.has(node.id) || this.#graphOutputPartialBindingsBySourceNodeId.has(node.id)) ? (partialOutputs) => {
|
|
13881
|
+
if (!acceptsPartialOutputs()) return;
|
|
13424
13882
|
this.#publishStreamingOutputWatchPartial(node, partialOutputs);
|
|
13425
13883
|
this.#publishGraphOutputPartial(node, partialOutputs);
|
|
13884
|
+
this.#publishGraphInputStreamPartial(node, partialOutputs);
|
|
13426
13885
|
} : void 0;
|
|
13427
13886
|
const toolCallContinuation = this.#getToolCallContinuationContext(
|
|
13428
13887
|
node,
|
|
@@ -13443,9 +13902,12 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
13443
13902
|
node,
|
|
13444
13903
|
nodeAbortController,
|
|
13445
13904
|
onGraphOutputPartial,
|
|
13905
|
+
graphInputStreams: this.#callerInputStreams.get(node.id),
|
|
13446
13906
|
onPartialOutputs: (partialOutputs) => {
|
|
13907
|
+
if (!acceptsPartialOutputs()) return;
|
|
13447
13908
|
partialOutput == null ? void 0 : partialOutput(node, partialOutputs, index);
|
|
13448
13909
|
this.#publishStreamingOutputWatchPartial(node, partialOutputs);
|
|
13910
|
+
this.#publishGraphInputStreamPartial(node, partialOutputs);
|
|
13449
13911
|
this.#publishGraphOutputPartial(node, partialOutputs);
|
|
13450
13912
|
this.#emitGraphPartialOutputIfNeeded(node, partialOutputs);
|
|
13451
13913
|
},
|
|
@@ -14079,7 +14541,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
14079
14541
|
}
|
|
14080
14542
|
}
|
|
14081
14543
|
}
|
|
14082
|
-
#publishStreamingOutputWatchPartial(node, partialOutputs) {
|
|
14544
|
+
#publishStreamingOutputWatchPartial(node, partialOutputs, coalesced = 0) {
|
|
14083
14545
|
for (const plan of this.#streamingWatchPlansBySourceNodeId.get(node.id) ?? []) {
|
|
14084
14546
|
const value = partialOutputs[plan.sourceOutputId];
|
|
14085
14547
|
if (value == null || value.type === "control-flow-excluded") {
|
|
@@ -14089,10 +14551,109 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
14089
14551
|
if (!watch || watch.stopped) {
|
|
14090
14552
|
continue;
|
|
14091
14553
|
}
|
|
14554
|
+
watch.accountCoalescedUpdates(coalesced);
|
|
14555
|
+
plan.nextUpdateIndex += coalesced;
|
|
14092
14556
|
const updateIndex = this.#nextStreamingWatchUpdateIndex(plan);
|
|
14093
14557
|
watch.publish(this.#createStreamingOutputWatchSnapshot(plan, value, updateIndex, false));
|
|
14094
14558
|
}
|
|
14095
14559
|
}
|
|
14560
|
+
#prepareGraphInputStreamRoutes() {
|
|
14561
|
+
var _a;
|
|
14562
|
+
if (!this.#executionGraphNodes.some((node) => canStreamThroughGraphCaller(node) && this.#isNodeSelected(node.id)))
|
|
14563
|
+
return;
|
|
14564
|
+
const marked = getProjectStreamingOutputWatchConnections({
|
|
14565
|
+
project: this.#project,
|
|
14566
|
+
graph: this.#graph,
|
|
14567
|
+
referencedProjects: this.#loadedProjects,
|
|
14568
|
+
registry: this.#registry,
|
|
14569
|
+
fullGraphCallers: new Set(this.runToNodeIds ?? []),
|
|
14570
|
+
isNodeFrozen: (_owner, candidate, node) => {
|
|
14571
|
+
var _a2, _b;
|
|
14572
|
+
return this.#frozenNodeOutputResolver != null && ((_b = (_a2 = this.#frozenNodeOutputResolver).hasFrozenNodeOutput) == null ? void 0 : _b.call(_a2, { graphId: candidate.metadata.id, node })) !== false;
|
|
14573
|
+
}
|
|
14574
|
+
});
|
|
14575
|
+
const inputKeys = /* @__PURE__ */ new Map();
|
|
14576
|
+
for (const edge of marked) {
|
|
14577
|
+
const ports = inputKeys.get(edge.inputNodeId) ?? /* @__PURE__ */ new Set();
|
|
14578
|
+
ports.add(edge.inputId);
|
|
14579
|
+
inputKeys.set(edge.inputNodeId, ports);
|
|
14580
|
+
}
|
|
14581
|
+
for (const node of this.#executionGraphNodes) {
|
|
14582
|
+
if (!this.#isNodeSelected(node.id) || !canStreamThroughGraphCaller(node) || this.#hasFrozenNodeOutputOrUnknownResolver(node))
|
|
14583
|
+
continue;
|
|
14584
|
+
const streams = /* @__PURE__ */ Object.create(null);
|
|
14585
|
+
const incoming = this.#getInputConnectionsForNode(node).filter((edge) => this.#isDefinitionValidConnection(edge));
|
|
14586
|
+
for (const edge of incoming) {
|
|
14587
|
+
const source = this.#nodesById[edge.outputNodeId];
|
|
14588
|
+
if (!((_a = inputKeys.get(node.id)) == null ? void 0 : _a.has(edge.inputId)) || !source || source.disabled || source.isSplitRun || incoming.filter((other) => other.inputId === edge.inputId).length !== 1)
|
|
14589
|
+
continue;
|
|
14590
|
+
const relay = new GraphInputStreamRelay();
|
|
14591
|
+
streams[edge.inputId] = relay;
|
|
14592
|
+
const routes = this.#inputStreamRoutes.get(source.id) ?? [];
|
|
14593
|
+
routes.push({ port: edge.outputId, relay });
|
|
14594
|
+
this.#inputStreamRoutes.set(source.id, routes);
|
|
14595
|
+
}
|
|
14596
|
+
if (Object.keys(streams).length) this.#callerInputStreams.set(node.id, streams);
|
|
14597
|
+
}
|
|
14598
|
+
const abort = () => {
|
|
14599
|
+
const error = createGraphAbortErrorFromSignal(this.#abortController.signal);
|
|
14600
|
+
for (const streams of this.#callerInputStreams.values()) {
|
|
14601
|
+
for (const relay of Object.values(streams)) relay.finish({ error });
|
|
14602
|
+
}
|
|
14603
|
+
};
|
|
14604
|
+
this.#abortController.signal.addEventListener("abort", abort, { once: true });
|
|
14605
|
+
this.#inputStreamDisposers.push(() => this.#abortController.signal.removeEventListener("abort", abort));
|
|
14606
|
+
}
|
|
14607
|
+
#publishGraphInputStreamPartial(node, outputs, coalesced = 0) {
|
|
14608
|
+
for (const { port, relay } of this.#inputStreamRoutes.get(node.id) ?? []) {
|
|
14609
|
+
const value = outputs[port];
|
|
14610
|
+
if (value && value.type !== "control-flow-excluded") relay.publish(value, coalesced);
|
|
14611
|
+
}
|
|
14612
|
+
}
|
|
14613
|
+
#subscribeGraphInputStreams() {
|
|
14614
|
+
for (const [name, stream] of Object.entries(this.#graphInputStreams)) {
|
|
14615
|
+
const inputs = this.#executionGraphNodes.filter(
|
|
14616
|
+
(node) => node.type === "graphInput" && node.data.id === name && !node.disabled && this.#isNodeSelected(node.id)
|
|
14617
|
+
);
|
|
14618
|
+
let active = true;
|
|
14619
|
+
const unsubscribe = stream.subscribe((value, coalesced) => {
|
|
14620
|
+
if (!active || this.#abortController.signal.aborted) return;
|
|
14621
|
+
for (const node of inputs) {
|
|
14622
|
+
if (!canStreamThroughGraphInput(node) || this.#hasFrozenNodeOutputOrUnknownResolver(node)) continue;
|
|
14623
|
+
const output = {
|
|
14624
|
+
["data"]: resolveGraphInputValue(node.data, value)
|
|
14625
|
+
};
|
|
14626
|
+
this.#publishStreamingOutputWatchPartial(node, output, coalesced);
|
|
14627
|
+
this.#publishGraphInputStreamPartial(node, output, coalesced);
|
|
14628
|
+
}
|
|
14629
|
+
});
|
|
14630
|
+
this.#inputStreamDisposers.push(() => {
|
|
14631
|
+
active = false;
|
|
14632
|
+
unsubscribe();
|
|
14633
|
+
});
|
|
14634
|
+
void stream.settled.then((result) => {
|
|
14635
|
+
if (!active || this.#abortController.signal.aborted) return;
|
|
14636
|
+
if (result.value) this.#graphInputs[name] = result.value;
|
|
14637
|
+
for (const node of inputs) void this.#processingQueue.add(() => this.#processNodeIfAllInputsAvailable(node));
|
|
14638
|
+
});
|
|
14639
|
+
}
|
|
14640
|
+
}
|
|
14641
|
+
async #waitForGraphInputStreams() {
|
|
14642
|
+
const signal = this.#abortController.signal;
|
|
14643
|
+
if (signal.aborted) throw createGraphAbortErrorFromSignal(signal);
|
|
14644
|
+
let abort;
|
|
14645
|
+
try {
|
|
14646
|
+
await Promise.race([
|
|
14647
|
+
Promise.all(Object.values(this.#graphInputStreams).map((stream) => stream.settled)),
|
|
14648
|
+
new Promise((_resolve, reject) => {
|
|
14649
|
+
abort = () => reject(createGraphAbortErrorFromSignal(signal));
|
|
14650
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
14651
|
+
})
|
|
14652
|
+
]);
|
|
14653
|
+
} finally {
|
|
14654
|
+
signal.removeEventListener("abort", abort);
|
|
14655
|
+
}
|
|
14656
|
+
}
|
|
14096
14657
|
#prepareGraphOutputPartialTopology() {
|
|
14097
14658
|
if (!this.#graphOutputPartialListener) {
|
|
14098
14659
|
return;
|
|
@@ -14176,6 +14737,31 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
14176
14737
|
}
|
|
14177
14738
|
}
|
|
14178
14739
|
#finishStreamingOutputWatches(node, outputs) {
|
|
14740
|
+
if (node.type === "graphInput") {
|
|
14741
|
+
const terminals = Object.values(this.#graphInputStreams).map((stream) => stream.result);
|
|
14742
|
+
if (terminals.some((result) => !result)) {
|
|
14743
|
+
this.#pendingGraphInputFinals.set(node.id, cloneExecutionOutputs(outputs));
|
|
14744
|
+
return;
|
|
14745
|
+
}
|
|
14746
|
+
const failure = terminals.find((result) => result == null ? void 0 : result.error);
|
|
14747
|
+
if (failure == null ? void 0 : failure.error) {
|
|
14748
|
+
for (const route of this.#inputStreamRoutes.get(node.id) ?? []) route.relay.finish({ error: failure.error });
|
|
14749
|
+
this.#cancelStreamingOutputWatchesForSource(node.id);
|
|
14750
|
+
return;
|
|
14751
|
+
}
|
|
14752
|
+
if (terminals.some((result) => {
|
|
14753
|
+
var _a;
|
|
14754
|
+
return ((_a = result == null ? void 0 : result.value) == null ? void 0 : _a.type) === "control-flow-excluded";
|
|
14755
|
+
})) {
|
|
14756
|
+
outputs = Object.fromEntries(
|
|
14757
|
+
Object.keys(outputs).map((port) => [port, { type: "control-flow-excluded", value: void 0 }])
|
|
14758
|
+
);
|
|
14759
|
+
}
|
|
14760
|
+
}
|
|
14761
|
+
for (const { port, relay } of this.#inputStreamRoutes.get(node.id) ?? []) {
|
|
14762
|
+
const value = outputs[port];
|
|
14763
|
+
relay.finish(value ? { value } : { error: new Error(`Missing final streamed output ${port}`) });
|
|
14764
|
+
}
|
|
14179
14765
|
for (const plan of this.#streamingWatchPlansBySourceNodeId.get(node.id) ?? []) {
|
|
14180
14766
|
const value = outputs[plan.sourceOutputId];
|
|
14181
14767
|
const watch = this.#streamingOutputWatches.get(plan.watchNode.id);
|
|
@@ -14188,7 +14774,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
14188
14774
|
if (value.type === "control-flow-excluded") {
|
|
14189
14775
|
watch.stop();
|
|
14190
14776
|
if (plan.stopNodeId) {
|
|
14191
|
-
this.#excludeNode(this.#nodesById[plan.stopNodeId], (0,
|
|
14777
|
+
this.#excludeNode(this.#nodesById[plan.stopNodeId], (0, import_non_secure8.nanoid)(), {}, "watched output is excluded");
|
|
14192
14778
|
}
|
|
14193
14779
|
continue;
|
|
14194
14780
|
}
|
|
@@ -14266,7 +14852,7 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
14266
14852
|
if (!graphId2) {
|
|
14267
14853
|
throw new Error("Cannot start a streaming watch branch because the current graph has no ID.");
|
|
14268
14854
|
}
|
|
14269
|
-
const historyIteration = plan.history.start((0,
|
|
14855
|
+
const historyIteration = plan.history.start((0, import_non_secure8.nanoid)(), snapshot.updateIndex);
|
|
14270
14856
|
const branchRuntimeCache = {
|
|
14271
14857
|
...this.#runtimeCache,
|
|
14272
14858
|
graphBoundaries: void 0,
|
|
@@ -14486,12 +15072,14 @@ ${errors.map(({ node }) => `- ${node.title} (${node.id})`).join("\n")}`;
|
|
|
14486
15072
|
}
|
|
14487
15073
|
const stopNode = this.#nodesById[plan.stopNodeId];
|
|
14488
15074
|
if (!stopNode) {
|
|
14489
|
-
throw new Error(
|
|
15075
|
+
throw new Error(
|
|
15076
|
+
`Watch Streaming Output "${plan.watchNode.title}" lost its Stop Watching Streaming Output node.`
|
|
15077
|
+
);
|
|
14490
15078
|
}
|
|
14491
15079
|
plan.unmatchedStopResolved = true;
|
|
14492
15080
|
this.#excludeNode(
|
|
14493
15081
|
stopNode,
|
|
14494
|
-
(0,
|
|
15082
|
+
(0, import_non_secure8.nanoid)(),
|
|
14495
15083
|
{},
|
|
14496
15084
|
"stream completed without Stop Watching Streaming Output accepting a value"
|
|
14497
15085
|
);
|
|
@@ -18832,15 +19420,15 @@ var NodeRegistration = class {
|
|
|
18832
19420
|
};
|
|
18833
19421
|
|
|
18834
19422
|
// src/model/nodes/UserInputNode.ts
|
|
18835
|
-
var
|
|
19423
|
+
var import_non_secure9 = require("nanoid/non-secure");
|
|
18836
19424
|
var import_lodash_es5 = require("lodash");
|
|
18837
|
-
var
|
|
19425
|
+
var import_ts_dedent4 = require("ts-dedent");
|
|
18838
19426
|
var UserInputNodeImpl = class extends NodeImpl {
|
|
18839
19427
|
static create() {
|
|
18840
19428
|
const chartNode = {
|
|
18841
19429
|
type: "userInput",
|
|
18842
19430
|
title: "User Input",
|
|
18843
|
-
id: (0,
|
|
19431
|
+
id: (0, import_non_secure9.nanoid)(),
|
|
18844
19432
|
visualData: {
|
|
18845
19433
|
x: 0,
|
|
18846
19434
|
y: 0,
|
|
@@ -18911,7 +19499,7 @@ var UserInputNodeImpl = class extends NodeImpl {
|
|
|
18911
19499
|
}
|
|
18912
19500
|
static getUIData() {
|
|
18913
19501
|
return {
|
|
18914
|
-
infoBoxBody:
|
|
19502
|
+
infoBoxBody: import_ts_dedent4.dedent`
|
|
18915
19503
|
Prompts the user for input during the execution of the graph. The user's response becomes the output of this node.
|
|
18916
19504
|
`,
|
|
18917
19505
|
infoBoxTitle: "User Input Node",
|
|
@@ -18939,8 +19527,8 @@ ${a}`)
|
|
|
18939
19527
|
var userInputNode = nodeDefinition(UserInputNodeImpl, "User Input");
|
|
18940
19528
|
|
|
18941
19529
|
// src/model/nodes/TextNode.ts
|
|
18942
|
-
var
|
|
18943
|
-
var
|
|
19530
|
+
var import_non_secure10 = require("nanoid/non-secure");
|
|
19531
|
+
var import_ts_dedent5 = require("ts-dedent");
|
|
18944
19532
|
|
|
18945
19533
|
// src/model/interpolationInputDefinition.ts
|
|
18946
19534
|
var INTERPOLATION_INPUT_DEFINITION_KIND = "interpolation-input";
|
|
@@ -19014,7 +19602,7 @@ var TextNodeImpl = class extends NodeImpl {
|
|
|
19014
19602
|
const chartNode = {
|
|
19015
19603
|
type: "text",
|
|
19016
19604
|
title: "Text",
|
|
19017
|
-
id: (0,
|
|
19605
|
+
id: (0, import_non_secure10.nanoid)(),
|
|
19018
19606
|
visualData: {
|
|
19019
19607
|
x: 0,
|
|
19020
19608
|
y: 0,
|
|
@@ -19103,7 +19691,7 @@ var TextNodeImpl = class extends NodeImpl {
|
|
|
19103
19691
|
}
|
|
19104
19692
|
static getUIData() {
|
|
19105
19693
|
return {
|
|
19106
|
-
infoBoxBody:
|
|
19694
|
+
infoBoxBody: import_ts_dedent5.dedent`
|
|
19107
19695
|
Outputs a string of text. It can also interpolate values using <span style="color: var(--primary)">{{tags}}</span>.
|
|
19108
19696
|
|
|
19109
19697
|
The inputs are dynamic based on the interpolation tags.
|
|
@@ -19117,8 +19705,8 @@ var TextNodeImpl = class extends NodeImpl {
|
|
|
19117
19705
|
var textNode = nodeDefinition(TextNodeImpl, "Text");
|
|
19118
19706
|
|
|
19119
19707
|
// src/model/nodes/ChatNode.ts
|
|
19120
|
-
var
|
|
19121
|
-
var
|
|
19708
|
+
var import_non_secure11 = require("nanoid/non-secure");
|
|
19709
|
+
var import_ts_dedent6 = require("ts-dedent");
|
|
19122
19710
|
|
|
19123
19711
|
// src/utils/openai.ts
|
|
19124
19712
|
var openai_exports = {};
|
|
@@ -21073,7 +21661,7 @@ var ChatNodeImpl = class extends NodeImpl {
|
|
|
21073
21661
|
const chartNode = {
|
|
21074
21662
|
type: "chat",
|
|
21075
21663
|
title: "Chat (Legacy)",
|
|
21076
|
-
id: (0,
|
|
21664
|
+
id: (0, import_non_secure11.nanoid)(),
|
|
21077
21665
|
visualData: {
|
|
21078
21666
|
x: 0,
|
|
21079
21667
|
y: 0,
|
|
@@ -21097,7 +21685,7 @@ var ChatNodeImpl = class extends NodeImpl {
|
|
|
21097
21685
|
}
|
|
21098
21686
|
static getUIData() {
|
|
21099
21687
|
return {
|
|
21100
|
-
infoBoxBody:
|
|
21688
|
+
infoBoxBody: import_ts_dedent6.dedent`
|
|
21101
21689
|
Legacy OpenAI-compatible chat node.
|
|
21102
21690
|
|
|
21103
21691
|
For new work, prefer \`LLM Chat\`, which provides a shared vendor-agnostic chat experience across OpenAI, Anthropic, and Google.
|
|
@@ -21124,8 +21712,8 @@ var ChatNodeImpl = class extends NodeImpl {
|
|
|
21124
21712
|
var chatNode = nodeDefinition(ChatNodeImpl, "Chat (Legacy)");
|
|
21125
21713
|
|
|
21126
21714
|
// src/model/nodes/LLMChatV2Node.ts
|
|
21127
|
-
var
|
|
21128
|
-
var
|
|
21715
|
+
var import_non_secure13 = require("nanoid/non-secure");
|
|
21716
|
+
var import_ts_dedent7 = require("ts-dedent");
|
|
21129
21717
|
|
|
21130
21718
|
// src/model/chat-v2/providerOptions.ts
|
|
21131
21719
|
var import_anthropic2 = require("@ai-sdk/anthropic");
|
|
@@ -23578,7 +24166,7 @@ async function generateChatV2(options2) {
|
|
|
23578
24166
|
}
|
|
23579
24167
|
|
|
23580
24168
|
// src/model/chat-v2/chatV2CallObserver.ts
|
|
23581
|
-
var
|
|
24169
|
+
var import_non_secure12 = require("nanoid/non-secure");
|
|
23582
24170
|
function toUsageNumber(value) {
|
|
23583
24171
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
23584
24172
|
}
|
|
@@ -23668,7 +24256,7 @@ function isUsage(value) {
|
|
|
23668
24256
|
}
|
|
23669
24257
|
function createObservedChatV2CallId(options2) {
|
|
23670
24258
|
var _a;
|
|
23671
|
-
return options2.context.onChatV2CallFinished != null && ((_a = options2.context.node) == null ? void 0 : _a.id) != null && options2.context.processId != null ? (0,
|
|
24259
|
+
return options2.context.onChatV2CallFinished != null && ((_a = options2.context.node) == null ? void 0 : _a.id) != null && options2.context.processId != null ? (0, import_non_secure12.nanoid)() : void 0;
|
|
23672
24260
|
}
|
|
23673
24261
|
function notifyChatV2CallFinished(options2, params) {
|
|
23674
24262
|
var _a;
|
|
@@ -26637,7 +27225,7 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
26637
27225
|
return {
|
|
26638
27226
|
type: "llmChatV2",
|
|
26639
27227
|
title: "LLM Chat",
|
|
26640
|
-
id: (0,
|
|
27228
|
+
id: (0, import_non_secure13.nanoid)(),
|
|
26641
27229
|
visualData: {
|
|
26642
27230
|
x: 0,
|
|
26643
27231
|
y: 0,
|
|
@@ -26819,7 +27407,7 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
26819
27407
|
}
|
|
26820
27408
|
static getUIData() {
|
|
26821
27409
|
return {
|
|
26822
|
-
infoBoxBody:
|
|
27410
|
+
infoBoxBody: import_ts_dedent7.dedent`
|
|
26823
27411
|
Vendor-agnostic chat node built on the Vercel AI SDK.
|
|
26824
27412
|
|
|
26825
27413
|
Choose OpenAI, Anthropic, Google, or a custom OpenAI-compatible provider inside the node without rewiring the graph.
|
|
@@ -26948,7 +27536,7 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
26948
27536
|
var llmChatV2Node = nodeDefinition(LLMChatV2NodeImpl, "LLM Chat");
|
|
26949
27537
|
|
|
26950
27538
|
// src/model/nodes/LLMProfileNode.ts
|
|
26951
|
-
var
|
|
27539
|
+
var import_non_secure14 = require("nanoid/non-secure");
|
|
26952
27540
|
|
|
26953
27541
|
// src/model/chat-v2/llmProfileBody.ts
|
|
26954
27542
|
function getOptionLabel2(options2, value) {
|
|
@@ -27209,7 +27797,7 @@ var LLMProfileNodeImpl = class extends NodeImpl {
|
|
|
27209
27797
|
return {
|
|
27210
27798
|
type: "llmProfile",
|
|
27211
27799
|
title: "LLM Profile",
|
|
27212
|
-
id: (0,
|
|
27800
|
+
id: (0, import_non_secure14.nanoid)(),
|
|
27213
27801
|
visualData: {
|
|
27214
27802
|
x: 0,
|
|
27215
27803
|
y: 0,
|
|
@@ -27334,15 +27922,15 @@ ${escapeMarkdownInline2(section.snippet.text)}` : void 0;
|
|
|
27334
27922
|
var llmProfileNode = nodeDefinition(LLMProfileNodeImpl, "LLM Profile");
|
|
27335
27923
|
|
|
27336
27924
|
// src/model/nodes/PromptNode.ts
|
|
27337
|
-
var
|
|
27338
|
-
var
|
|
27925
|
+
var import_non_secure15 = require("nanoid/non-secure");
|
|
27926
|
+
var import_ts_dedent8 = require("ts-dedent");
|
|
27339
27927
|
var import_ts_pattern2 = require("ts-pattern");
|
|
27340
27928
|
var PromptNodeImpl = class extends NodeImpl {
|
|
27341
27929
|
static create() {
|
|
27342
27930
|
const chartNode = {
|
|
27343
27931
|
type: "prompt",
|
|
27344
27932
|
title: "Prompt",
|
|
27345
|
-
id: (0,
|
|
27933
|
+
id: (0, import_non_secure15.nanoid)(),
|
|
27346
27934
|
visualData: {
|
|
27347
27935
|
x: 0,
|
|
27348
27936
|
y: 0,
|
|
@@ -27495,7 +28083,7 @@ var PromptNodeImpl = class extends NodeImpl {
|
|
|
27495
28083
|
}
|
|
27496
28084
|
static getUIData() {
|
|
27497
28085
|
return {
|
|
27498
|
-
infoBoxBody:
|
|
28086
|
+
infoBoxBody: import_ts_dedent8.dedent`
|
|
27499
28087
|
Outputs a chat message, which is a string of text with an attached "type" saying who sent the message (User, Assistant, System, Developer) and optionally an attached "name".
|
|
27500
28088
|
|
|
27501
28089
|
Also provides the same <span style="color: var(--primary)">{{interpolation}}</span> capabilities as a Text node.
|
|
@@ -27599,14 +28187,14 @@ var typeDisplay = {
|
|
|
27599
28187
|
};
|
|
27600
28188
|
|
|
27601
28189
|
// src/model/nodes/ExtractRegexNode.ts
|
|
27602
|
-
var
|
|
27603
|
-
var
|
|
28190
|
+
var import_non_secure16 = require("nanoid/non-secure");
|
|
28191
|
+
var import_ts_dedent9 = require("ts-dedent");
|
|
27604
28192
|
var ExtractRegexNodeImpl = class extends NodeImpl {
|
|
27605
28193
|
static create() {
|
|
27606
28194
|
const chartNode = {
|
|
27607
28195
|
type: "extractRegex",
|
|
27608
28196
|
title: "Extract Regex",
|
|
27609
|
-
id: (0,
|
|
28197
|
+
id: (0, import_non_secure16.nanoid)(),
|
|
27610
28198
|
visualData: {
|
|
27611
28199
|
x: 0,
|
|
27612
28200
|
y: 0,
|
|
@@ -27707,7 +28295,7 @@ var ExtractRegexNodeImpl = class extends NodeImpl {
|
|
|
27707
28295
|
}
|
|
27708
28296
|
static getUIData() {
|
|
27709
28297
|
return {
|
|
27710
|
-
infoBoxBody:
|
|
28298
|
+
infoBoxBody: import_ts_dedent9.dedent`
|
|
27711
28299
|
Extracts data from the input text using the configured regular expression. The regular expression can contain capture groups to extract specific parts of the text.
|
|
27712
28300
|
|
|
27713
28301
|
Each capture group corresponds to an output port of the node.
|
|
@@ -27794,8 +28382,8 @@ function countCaptureGroups(regex) {
|
|
|
27794
28382
|
var extractRegexNode = nodeDefinition(ExtractRegexNodeImpl, "Extract Regex");
|
|
27795
28383
|
|
|
27796
28384
|
// src/model/nodes/CodeNode.ts
|
|
27797
|
-
var
|
|
27798
|
-
var
|
|
28385
|
+
var import_non_secure17 = require("nanoid/non-secure");
|
|
28386
|
+
var import_ts_dedent10 = require("ts-dedent");
|
|
27799
28387
|
|
|
27800
28388
|
// src/model/nodes/codeNodeErrorDiagnostics.ts
|
|
27801
28389
|
var ASYNC_FUNCTION_LINE_OFFSET = 2;
|
|
@@ -27921,13 +28509,13 @@ var CodeNodeImpl = class extends NodeImpl {
|
|
|
27921
28509
|
const chartNode = {
|
|
27922
28510
|
type: "code",
|
|
27923
28511
|
title: "Code (legacy)",
|
|
27924
|
-
id: (0,
|
|
28512
|
+
id: (0, import_non_secure17.nanoid)(),
|
|
27925
28513
|
visualData: {
|
|
27926
28514
|
x: 0,
|
|
27927
28515
|
y: 0
|
|
27928
28516
|
},
|
|
27929
28517
|
data: {
|
|
27930
|
-
code:
|
|
28518
|
+
code: import_ts_dedent10.dedent`
|
|
27931
28519
|
// This is a Code (legacy) node. Write JavaScript here and it will be executed.
|
|
27932
28520
|
// Inputs are accessible via an object \`inputs\` and data is typed (i.e. inputs.foo.type, inputs.foo.value)
|
|
27933
28521
|
// Return an object with named outputs that match the output names specified in the node's config.
|
|
@@ -28018,7 +28606,7 @@ var CodeNodeImpl = class extends NodeImpl {
|
|
|
28018
28606
|
}
|
|
28019
28607
|
static getUIData() {
|
|
28020
28608
|
return {
|
|
28021
|
-
infoBoxBody:
|
|
28609
|
+
infoBoxBody: import_ts_dedent10.dedent`
|
|
28022
28610
|
Executes legacy JavaScript code with manually configured inputs and outputs.
|
|
28023
28611
|
`,
|
|
28024
28612
|
infoBoxTitle: "Code (legacy) Node",
|
|
@@ -28060,11 +28648,11 @@ var CodeNodeImpl = class extends NodeImpl {
|
|
|
28060
28648
|
var codeNode = nodeDefinition(CodeNodeImpl, "Code (legacy)");
|
|
28061
28649
|
|
|
28062
28650
|
// src/model/nodes/CodeNewNode.ts
|
|
28063
|
-
var
|
|
28064
|
-
var
|
|
28651
|
+
var import_non_secure18 = require("nanoid/non-secure");
|
|
28652
|
+
var import_ts_dedent12 = require("ts-dedent");
|
|
28065
28653
|
|
|
28066
28654
|
// src/model/nodes/jsValueInterpolation.ts
|
|
28067
|
-
var
|
|
28655
|
+
var import_ts_dedent11 = require("ts-dedent");
|
|
28068
28656
|
var MISSING_INTERPOLATION_HELPER_MESSAGE = "This CodeRunner must honor CodeRunnerOptions.interpolationHelperIdentifier to resolve JSONPath or @graphInputs/@context/@globals interpolation.";
|
|
28069
28657
|
var MISSING_GLOBAL_VALUES_MESSAGE = "This CodeRunner must honor CodeRunnerOptions.globalValuesIdentifier to resolve @globals interpolation.";
|
|
28070
28658
|
function escapeRegExp2(value) {
|
|
@@ -28224,7 +28812,7 @@ function interpolateJsValuePreviewSource(template, inputs, options2 = {}) {
|
|
|
28224
28812
|
});
|
|
28225
28813
|
}
|
|
28226
28814
|
function buildCloneJsInputValueFunction() {
|
|
28227
|
-
return
|
|
28815
|
+
return import_ts_dedent11.dedent`
|
|
28228
28816
|
const cloneJsInputValue = (value, seen = new WeakMap()) => {
|
|
28229
28817
|
if (value == null || (typeof value !== 'object' && typeof value !== 'function')) {
|
|
28230
28818
|
return value;
|
|
@@ -28332,7 +28920,7 @@ function buildJsValueInputClonePreamble({
|
|
|
28332
28920
|
usesGlobalValues,
|
|
28333
28921
|
inputsIdentifier
|
|
28334
28922
|
}) {
|
|
28335
|
-
return
|
|
28923
|
+
return import_ts_dedent11.dedent`
|
|
28336
28924
|
${buildCloneJsInputValueFunction()}
|
|
28337
28925
|
const ${inputsIdentifier} = Object.create(null);
|
|
28338
28926
|
const ${cacheIdentifier} = new WeakMap();
|
|
@@ -28359,7 +28947,7 @@ function buildJsValueInputsInitializer({
|
|
|
28359
28947
|
inputNames,
|
|
28360
28948
|
inputsIdentifier
|
|
28361
28949
|
} = interpolationContext;
|
|
28362
|
-
return
|
|
28950
|
+
return import_ts_dedent11.dedent`
|
|
28363
28951
|
${buildJsValueInputClonePreamble({
|
|
28364
28952
|
cacheIdentifier: cloneCacheIdentifier,
|
|
28365
28953
|
contextIdentifier,
|
|
@@ -28419,7 +29007,7 @@ function sanitizeGeneratedJsValueError(error, inputNames, targetIdentifier, fall
|
|
|
28419
29007
|
|
|
28420
29008
|
// src/model/nodes/CodeNewNode.ts
|
|
28421
29009
|
var CODE_RUNTIME_HELPER_MESSAGE2 = 'Node execution also provides "require" and "process". Browser execution provides "fetch", "console", and "Rivet".';
|
|
28422
|
-
var DEFAULT_CODE_NEW =
|
|
29010
|
+
var DEFAULT_CODE_NEW = import_ts_dedent12.dedent`
|
|
28423
29011
|
// This is a Code node. Write JavaScript here and return one value.
|
|
28424
29012
|
// Interpolation tokens create input ports and evaluate as connected values.
|
|
28425
29013
|
// The returned value becomes the node's single output.
|
|
@@ -28503,7 +29091,7 @@ var CodeNewNodeImpl = class extends NodeImpl {
|
|
|
28503
29091
|
return {
|
|
28504
29092
|
type: "codeNew",
|
|
28505
29093
|
title: "Code",
|
|
28506
|
-
id: (0,
|
|
29094
|
+
id: (0, import_non_secure18.nanoid)(),
|
|
28507
29095
|
visualData: {
|
|
28508
29096
|
x: 0,
|
|
28509
29097
|
y: 0,
|
|
@@ -28550,7 +29138,7 @@ var CodeNewNodeImpl = class extends NodeImpl {
|
|
|
28550
29138
|
}
|
|
28551
29139
|
static getUIData() {
|
|
28552
29140
|
return {
|
|
28553
|
-
infoBoxBody:
|
|
29141
|
+
infoBoxBody: import_ts_dedent12.dedent`
|
|
28554
29142
|
Runs JavaScript code that can use interpolation-created input ports and emits the returned value as the node output.
|
|
28555
29143
|
`,
|
|
28556
29144
|
infoBoxTitle: "Code Node",
|
|
@@ -28588,8 +29176,8 @@ var CodeNewNodeImpl = class extends NodeImpl {
|
|
|
28588
29176
|
var codeNewNode = nodeDefinition(CodeNewNodeImpl, "Code");
|
|
28589
29177
|
|
|
28590
29178
|
// src/model/nodes/ExpressionNode.ts
|
|
28591
|
-
var
|
|
28592
|
-
var
|
|
29179
|
+
var import_non_secure19 = require("nanoid/non-secure");
|
|
29180
|
+
var import_ts_dedent13 = require("ts-dedent");
|
|
28593
29181
|
var CODE_RUNTIME_HELPER_MESSAGE3 = 'Node execution also provides "require" and "process". Browser execution provides "fetch", "console", and "Rivet".';
|
|
28594
29182
|
var DEFAULT_EXPRESSION = '{{a}} == "123" ? {{b}} : {{c}}';
|
|
28595
29183
|
var MAX_BODY_PREVIEW_LINES3 = 15;
|
|
@@ -28627,7 +29215,7 @@ function sanitizeExpressionError(error, interpolationContext) {
|
|
|
28627
29215
|
}
|
|
28628
29216
|
function buildExpressionWrapper(expression, interpolationContext) {
|
|
28629
29217
|
const expressionSource = buildExpressionRuntimeSource(expression, interpolationContext);
|
|
28630
|
-
return
|
|
29218
|
+
return import_ts_dedent13.dedent`
|
|
28631
29219
|
${buildExpressionInputsInitializer(interpolationContext)}
|
|
28632
29220
|
|
|
28633
29221
|
return {
|
|
@@ -28643,7 +29231,7 @@ var ExpressionNodeImpl = class extends NodeImpl {
|
|
|
28643
29231
|
const chartNode = {
|
|
28644
29232
|
type: "expression",
|
|
28645
29233
|
title: "Expression",
|
|
28646
|
-
id: (0,
|
|
29234
|
+
id: (0, import_non_secure19.nanoid)(),
|
|
28647
29235
|
visualData: {
|
|
28648
29236
|
x: 0,
|
|
28649
29237
|
y: 0,
|
|
@@ -28691,7 +29279,7 @@ var ExpressionNodeImpl = class extends NodeImpl {
|
|
|
28691
29279
|
}
|
|
28692
29280
|
static getUIData() {
|
|
28693
29281
|
return {
|
|
28694
|
-
infoBoxBody:
|
|
29282
|
+
infoBoxBody: import_ts_dedent13.dedent`
|
|
28695
29283
|
Evaluates a single JavaScript expression and returns the resulting value.
|
|
28696
29284
|
|
|
28697
29285
|
<code>{{interpolation}}</code> creates dynamic input ports. Interpolated variables evaluate as connected values, so arrays, objects, strings, numbers, and booleans can be used directly.
|
|
@@ -28724,8 +29312,8 @@ var ExpressionNodeImpl = class extends NodeImpl {
|
|
|
28724
29312
|
var expressionNode = nodeDefinition(ExpressionNodeImpl, "Expression");
|
|
28725
29313
|
|
|
28726
29314
|
// src/model/nodes/MatchNode.ts
|
|
28727
|
-
var
|
|
28728
|
-
var
|
|
29315
|
+
var import_non_secure20 = require("nanoid/non-secure");
|
|
29316
|
+
var import_ts_dedent14 = require("ts-dedent");
|
|
28729
29317
|
|
|
28730
29318
|
// src/model/nodes/MatchCaseNodeBase.ts
|
|
28731
29319
|
var MatchCaseNodeBase = class extends NodeImpl {
|
|
@@ -28953,7 +29541,7 @@ var MatchNodeImpl = class extends MatchCaseNodeBase {
|
|
|
28953
29541
|
return {
|
|
28954
29542
|
type: "match",
|
|
28955
29543
|
title: regexMatchLegacyDisplayName,
|
|
28956
|
-
id: (0,
|
|
29544
|
+
id: (0, import_non_secure20.nanoid)(),
|
|
28957
29545
|
visualData: {
|
|
28958
29546
|
x: 0,
|
|
28959
29547
|
y: 0,
|
|
@@ -28961,7 +29549,7 @@ var MatchNodeImpl = class extends MatchCaseNodeBase {
|
|
|
28961
29549
|
},
|
|
28962
29550
|
data: {
|
|
28963
29551
|
cases: ["YES", "NO"],
|
|
28964
|
-
casePortIds: [(0,
|
|
29552
|
+
casePortIds: [(0, import_non_secure20.nanoid)(), (0, import_non_secure20.nanoid)()],
|
|
28965
29553
|
valueInputMode: "shared"
|
|
28966
29554
|
}
|
|
28967
29555
|
};
|
|
@@ -28977,7 +29565,7 @@ var MatchNodeImpl = class extends MatchCaseNodeBase {
|
|
|
28977
29565
|
}
|
|
28978
29566
|
static getUIData() {
|
|
28979
29567
|
return {
|
|
28980
|
-
infoBoxBody:
|
|
29568
|
+
infoBoxBody: import_ts_dedent14.dedent`
|
|
28981
29569
|
Legacy regex-only routing node. Existing graphs keep their current behavior.
|
|
28982
29570
|
|
|
28983
29571
|
For new graphs, use Match case. It supports exact plain-text cases by default and optional regular-expression matching.
|
|
@@ -28991,8 +29579,8 @@ var MatchNodeImpl = class extends MatchCaseNodeBase {
|
|
|
28991
29579
|
var matchNode = nodeDefinition(MatchNodeImpl, regexMatchLegacyDisplayName);
|
|
28992
29580
|
|
|
28993
29581
|
// src/model/nodes/MatchCaseNode.ts
|
|
28994
|
-
var
|
|
28995
|
-
var
|
|
29582
|
+
var import_non_secure21 = require("nanoid/non-secure");
|
|
29583
|
+
var import_ts_dedent15 = require("ts-dedent");
|
|
28996
29584
|
var MatchCaseNodeImpl = class extends MatchCaseNodeBase {
|
|
28997
29585
|
caseEditorLabel = "Cases";
|
|
28998
29586
|
caseEditorPlaceholder = "Case";
|
|
@@ -29005,13 +29593,13 @@ var MatchCaseNodeImpl = class extends MatchCaseNodeBase {
|
|
|
29005
29593
|
{ value: true, label: "First matching case" },
|
|
29006
29594
|
{ value: false, label: "All matching cases" }
|
|
29007
29595
|
];
|
|
29008
|
-
sharedCustomValueInputTitle = "
|
|
29596
|
+
sharedCustomValueInputTitle = "Output value";
|
|
29009
29597
|
triggerEditorLabel = "Trigger";
|
|
29010
29598
|
static create() {
|
|
29011
29599
|
return {
|
|
29012
29600
|
type: "matchCase",
|
|
29013
29601
|
title: "Match case",
|
|
29014
|
-
id: (0,
|
|
29602
|
+
id: (0, import_non_secure21.nanoid)(),
|
|
29015
29603
|
visualData: {
|
|
29016
29604
|
x: 0,
|
|
29017
29605
|
y: 0,
|
|
@@ -29019,7 +29607,7 @@ var MatchCaseNodeImpl = class extends MatchCaseNodeBase {
|
|
|
29019
29607
|
},
|
|
29020
29608
|
data: {
|
|
29021
29609
|
cases: ["YES", "NO"],
|
|
29022
|
-
casePortIds: [(0,
|
|
29610
|
+
casePortIds: [(0, import_non_secure21.nanoid)(), (0, import_non_secure21.nanoid)()],
|
|
29023
29611
|
valueInputMode: "shared",
|
|
29024
29612
|
matchMode: "plainText",
|
|
29025
29613
|
caseSensitive: true,
|
|
@@ -29091,10 +29679,10 @@ var MatchCaseNodeImpl = class extends MatchCaseNodeBase {
|
|
|
29091
29679
|
}
|
|
29092
29680
|
static getUIData() {
|
|
29093
29681
|
return {
|
|
29094
|
-
infoBoxBody:
|
|
29682
|
+
infoBoxBody: import_ts_dedent15.dedent`
|
|
29095
29683
|
Routes an Input value to matching case outputs. Plain text cases use exact, case-sensitive equality by default; turn off Case sensitive to ignore letter case. Choose Regular expression to use the existing JavaScript RegExp pattern behavior; the Case sensitive switch does not apply in that mode.
|
|
29096
29684
|
|
|
29097
|
-
Choose First matching case to trigger only the first matching output, or All matching cases to trigger every matching output. Active outputs return True by default. They can instead return the Input value, or a custom value supplied through one shared
|
|
29685
|
+
Choose First matching case to trigger only the first matching output, or All matching cases to trigger every matching output. Active outputs return True by default. They can instead return the Input value, or a custom value supplied through one shared Output value input or separate Output values inputs for every case and Unmatched.
|
|
29098
29686
|
`,
|
|
29099
29687
|
infoBoxTitle: "Match case Node",
|
|
29100
29688
|
contextMenuTitle: "Match case",
|
|
@@ -29111,14 +29699,14 @@ var MatchCaseNodeImpl = class extends MatchCaseNodeBase {
|
|
|
29111
29699
|
var matchCaseNode = nodeDefinition(MatchCaseNodeImpl, "Match case");
|
|
29112
29700
|
|
|
29113
29701
|
// src/model/nodes/IfNode.ts
|
|
29114
|
-
var
|
|
29115
|
-
var
|
|
29702
|
+
var import_non_secure22 = require("nanoid/non-secure");
|
|
29703
|
+
var import_ts_dedent16 = require("ts-dedent");
|
|
29116
29704
|
var IfNodeImpl = class extends NodeImpl {
|
|
29117
29705
|
static create = () => {
|
|
29118
29706
|
const chartNode = {
|
|
29119
29707
|
type: "if",
|
|
29120
29708
|
title: "If",
|
|
29121
|
-
id: (0,
|
|
29709
|
+
id: (0, import_non_secure22.nanoid)(),
|
|
29122
29710
|
data: {
|
|
29123
29711
|
// Legacy behavior is false
|
|
29124
29712
|
unconnectedControlFlowExcluded: true
|
|
@@ -29165,7 +29753,7 @@ var IfNodeImpl = class extends NodeImpl {
|
|
|
29165
29753
|
}
|
|
29166
29754
|
static getUIData() {
|
|
29167
29755
|
return {
|
|
29168
|
-
infoBoxBody:
|
|
29756
|
+
infoBoxBody: import_ts_dedent16.dedent`
|
|
29169
29757
|
Takes in a condition and a value. If the condition is truthy, the value is passed through the True port, and the False port is not ran.
|
|
29170
29758
|
If the condition is falsy, the value is passed through the False port, and the True port is not ran.
|
|
29171
29759
|
`,
|
|
@@ -29235,8 +29823,8 @@ var IfNodeImpl = class extends NodeImpl {
|
|
|
29235
29823
|
var ifNode = nodeDefinition(IfNodeImpl, "If");
|
|
29236
29824
|
|
|
29237
29825
|
// src/model/nodes/ReadDirectoryNode.ts
|
|
29238
|
-
var
|
|
29239
|
-
var
|
|
29826
|
+
var import_non_secure23 = require("nanoid/non-secure");
|
|
29827
|
+
var import_ts_dedent17 = require("ts-dedent");
|
|
29240
29828
|
|
|
29241
29829
|
// src/utils/paths.ts
|
|
29242
29830
|
function createTreeFromPaths(paths, rootPath) {
|
|
@@ -29311,7 +29899,7 @@ function createTreeFromPaths(paths, rootPath) {
|
|
|
29311
29899
|
var ReadDirectoryNodeImpl = class extends NodeImpl {
|
|
29312
29900
|
static create() {
|
|
29313
29901
|
return {
|
|
29314
|
-
id: (0,
|
|
29902
|
+
id: (0, import_non_secure23.nanoid)(),
|
|
29315
29903
|
type: "readDirectory",
|
|
29316
29904
|
title: "Read Directory",
|
|
29317
29905
|
visualData: { x: 0, y: 0 },
|
|
@@ -29400,7 +29988,7 @@ var ReadDirectoryNodeImpl = class extends NodeImpl {
|
|
|
29400
29988
|
];
|
|
29401
29989
|
}
|
|
29402
29990
|
getBody() {
|
|
29403
|
-
return
|
|
29991
|
+
return import_ts_dedent17.dedent`
|
|
29404
29992
|
Path: ${this.data.usePathInput ? "(Input)" : this.data.path}
|
|
29405
29993
|
Recursive: ${this.data.useRecursiveInput ? "(Input)" : this.data.recursive}
|
|
29406
29994
|
Include Directories: ${this.data.useIncludeDirectoriesInput ? "(Input)" : this.data.includeDirectories}
|
|
@@ -29410,7 +29998,7 @@ var ReadDirectoryNodeImpl = class extends NodeImpl {
|
|
|
29410
29998
|
}
|
|
29411
29999
|
static getUIData() {
|
|
29412
30000
|
return {
|
|
29413
|
-
infoBoxBody:
|
|
30001
|
+
infoBoxBody: import_ts_dedent17.dedent`
|
|
29414
30002
|
Reads the contents of the specified directory and outputs:
|
|
29415
30003
|
1. An array of filenames
|
|
29416
30004
|
2. The root path of the search
|
|
@@ -29466,12 +30054,12 @@ var ReadDirectoryNodeImpl = class extends NodeImpl {
|
|
|
29466
30054
|
var readDirectoryNode = nodeDefinition(ReadDirectoryNodeImpl, "Read Directory");
|
|
29467
30055
|
|
|
29468
30056
|
// src/model/nodes/ReadFileNode.ts
|
|
29469
|
-
var
|
|
29470
|
-
var
|
|
30057
|
+
var import_non_secure24 = require("nanoid/non-secure");
|
|
30058
|
+
var import_ts_dedent18 = require("ts-dedent");
|
|
29471
30059
|
var ReadFileNodeImpl = class extends NodeImpl {
|
|
29472
30060
|
static create() {
|
|
29473
30061
|
return {
|
|
29474
|
-
id: (0,
|
|
30062
|
+
id: (0, import_non_secure24.nanoid)(),
|
|
29475
30063
|
type: "readFile",
|
|
29476
30064
|
title: "Read File",
|
|
29477
30065
|
visualData: { x: 0, y: 0, width: 250 },
|
|
@@ -29506,7 +30094,7 @@ var ReadFileNodeImpl = class extends NodeImpl {
|
|
|
29506
30094
|
}
|
|
29507
30095
|
static getUIData() {
|
|
29508
30096
|
return {
|
|
29509
|
-
infoBoxBody:
|
|
30097
|
+
infoBoxBody: import_ts_dedent18.dedent`
|
|
29510
30098
|
Reads the contents of the specified file and outputs it as a string.
|
|
29511
30099
|
`,
|
|
29512
30100
|
infoBoxTitle: "Read File Node",
|
|
@@ -29535,7 +30123,7 @@ var ReadFileNodeImpl = class extends NodeImpl {
|
|
|
29535
30123
|
];
|
|
29536
30124
|
}
|
|
29537
30125
|
getBody() {
|
|
29538
|
-
return
|
|
30126
|
+
return import_ts_dedent18.dedent`
|
|
29539
30127
|
${this.data.asBinary ? "Read as Binary" : "Read as Text"}
|
|
29540
30128
|
${this.data.usePathInput ? "" : `Path: ${this.data.path}`}
|
|
29541
30129
|
`;
|
|
@@ -29573,14 +30161,14 @@ var ReadFileNodeImpl = class extends NodeImpl {
|
|
|
29573
30161
|
var readFileNode = nodeDefinition(ReadFileNodeImpl, "Read File");
|
|
29574
30162
|
|
|
29575
30163
|
// src/model/nodes/IfElseNode.ts
|
|
29576
|
-
var
|
|
29577
|
-
var
|
|
30164
|
+
var import_non_secure25 = require("nanoid/non-secure");
|
|
30165
|
+
var import_ts_dedent19 = require("ts-dedent");
|
|
29578
30166
|
var IfElseNodeImpl = class extends NodeImpl {
|
|
29579
30167
|
static create = () => {
|
|
29580
30168
|
const chartNode = {
|
|
29581
30169
|
type: "ifElse",
|
|
29582
30170
|
title: "If/Else",
|
|
29583
|
-
id: (0,
|
|
30171
|
+
id: (0, import_non_secure25.nanoid)(),
|
|
29584
30172
|
data: {
|
|
29585
30173
|
// Legacy behavior is false
|
|
29586
30174
|
unconnectedControlFlowExcluded: true
|
|
@@ -29627,7 +30215,7 @@ var IfElseNodeImpl = class extends NodeImpl {
|
|
|
29627
30215
|
}
|
|
29628
30216
|
static getUIData() {
|
|
29629
30217
|
return {
|
|
29630
|
-
infoBoxBody:
|
|
30218
|
+
infoBoxBody: import_ts_dedent19.dedent`
|
|
29631
30219
|
Takes in three inputs: a condition, a true value, and a false value. If the condition is truthy, the true value is passed through the output port. If the condition is not truthy, the false value is passed through the output port.
|
|
29632
30220
|
|
|
29633
30221
|
This node can "consume" a \`Not Ran\` to continue a graph from that point.
|
|
@@ -29706,14 +30294,14 @@ var IfElseNodeImpl = class extends NodeImpl {
|
|
|
29706
30294
|
var ifElseNode = nodeDefinition(IfElseNodeImpl, "If/Else");
|
|
29707
30295
|
|
|
29708
30296
|
// src/model/nodes/ChunkNode.ts
|
|
29709
|
-
var
|
|
29710
|
-
var
|
|
30297
|
+
var import_non_secure26 = require("nanoid/non-secure");
|
|
30298
|
+
var import_ts_dedent20 = require("ts-dedent");
|
|
29711
30299
|
var ChunkNodeImpl = class extends NodeImpl {
|
|
29712
30300
|
static create() {
|
|
29713
30301
|
const chartNode = {
|
|
29714
30302
|
type: "chunk",
|
|
29715
30303
|
title: "Chunk",
|
|
29716
|
-
id: (0,
|
|
30304
|
+
id: (0, import_non_secure26.nanoid)(),
|
|
29717
30305
|
visualData: {
|
|
29718
30306
|
x: 0,
|
|
29719
30307
|
y: 0,
|
|
@@ -29802,7 +30390,7 @@ var ChunkNodeImpl = class extends NodeImpl {
|
|
|
29802
30390
|
];
|
|
29803
30391
|
}
|
|
29804
30392
|
getBody() {
|
|
29805
|
-
return
|
|
30393
|
+
return import_ts_dedent20.dedent`
|
|
29806
30394
|
Model: ${this.data.model}
|
|
29807
30395
|
Token Count: ${this.data.numTokensPerChunk.toLocaleString()}
|
|
29808
30396
|
${this.data.overlap ? `Overlap: ${this.data.overlap}%` : ""}
|
|
@@ -29810,7 +30398,7 @@ var ChunkNodeImpl = class extends NodeImpl {
|
|
|
29810
30398
|
}
|
|
29811
30399
|
static getUIData() {
|
|
29812
30400
|
return {
|
|
29813
|
-
infoBoxBody:
|
|
30401
|
+
infoBoxBody: import_ts_dedent20.dedent`
|
|
29814
30402
|
Splits the input text into an array of chunks based on an approximate GPT token count per chunk.
|
|
29815
30403
|
|
|
29816
30404
|
The "overlap" setting allows you to partially overlap the chunks for redundancy.
|
|
@@ -29875,126 +30463,6 @@ async function chunkStringByTokenCount(tokenizer, tokenizerInfo, input, targetTo
|
|
|
29875
30463
|
return chunks;
|
|
29876
30464
|
}
|
|
29877
30465
|
|
|
29878
|
-
// src/model/nodes/GraphInputNode.ts
|
|
29879
|
-
var import_non_secure26 = require("nanoid/non-secure");
|
|
29880
|
-
var import_ts_dedent20 = require("ts-dedent");
|
|
29881
|
-
var GraphInputNodeImpl = class extends NodeImpl {
|
|
29882
|
-
static create() {
|
|
29883
|
-
const chartNode = {
|
|
29884
|
-
type: "graphInput",
|
|
29885
|
-
title: "Graph Input",
|
|
29886
|
-
id: (0, import_non_secure26.nanoid)(),
|
|
29887
|
-
visualData: {
|
|
29888
|
-
x: 0,
|
|
29889
|
-
y: 0,
|
|
29890
|
-
width: 300
|
|
29891
|
-
},
|
|
29892
|
-
data: {
|
|
29893
|
-
id: "input",
|
|
29894
|
-
dataType: "string",
|
|
29895
|
-
defaultValue: void 0,
|
|
29896
|
-
useDefaultValueInput: false
|
|
29897
|
-
}
|
|
29898
|
-
};
|
|
29899
|
-
return chartNode;
|
|
29900
|
-
}
|
|
29901
|
-
getInputDefinitions() {
|
|
29902
|
-
if (this.data.useDefaultValueInput) {
|
|
29903
|
-
return [
|
|
29904
|
-
{
|
|
29905
|
-
id: "default",
|
|
29906
|
-
title: "Default Value",
|
|
29907
|
-
dataType: this.chartNode.data.dataType
|
|
29908
|
-
}
|
|
29909
|
-
];
|
|
29910
|
-
}
|
|
29911
|
-
return [];
|
|
29912
|
-
}
|
|
29913
|
-
getOutputDefinitions() {
|
|
29914
|
-
return [
|
|
29915
|
-
{
|
|
29916
|
-
id: "data",
|
|
29917
|
-
title: this.data.id,
|
|
29918
|
-
dataType: this.chartNode.data.dataType
|
|
29919
|
-
}
|
|
29920
|
-
];
|
|
29921
|
-
}
|
|
29922
|
-
getEditors() {
|
|
29923
|
-
return [
|
|
29924
|
-
{
|
|
29925
|
-
type: "string",
|
|
29926
|
-
label: "ID",
|
|
29927
|
-
dataKey: "id"
|
|
29928
|
-
},
|
|
29929
|
-
{
|
|
29930
|
-
type: "dataTypeSelector",
|
|
29931
|
-
label: "Data Type",
|
|
29932
|
-
dataKey: "dataType"
|
|
29933
|
-
},
|
|
29934
|
-
{
|
|
29935
|
-
type: "anyData",
|
|
29936
|
-
label: "Default Value",
|
|
29937
|
-
dataKey: "defaultValue",
|
|
29938
|
-
useInputToggleDataKey: "useDefaultValueInput"
|
|
29939
|
-
},
|
|
29940
|
-
{
|
|
29941
|
-
type: "dropdown",
|
|
29942
|
-
label: "Editor",
|
|
29943
|
-
dataKey: "editor",
|
|
29944
|
-
defaultValue: "auto",
|
|
29945
|
-
options: [
|
|
29946
|
-
{ label: "None", value: "none" },
|
|
29947
|
-
{ label: "Auto", value: "auto" },
|
|
29948
|
-
{ label: "String", value: "string" },
|
|
29949
|
-
{ label: "Number", value: "number" },
|
|
29950
|
-
{ label: "Code", value: "code" },
|
|
29951
|
-
{ label: "Data Type", value: "dataTypeSelector" },
|
|
29952
|
-
{ label: "String List", value: "stringList" },
|
|
29953
|
-
{ label: "Key Value Pairs", value: "keyValuePair" },
|
|
29954
|
-
{ label: "Toggle", value: "toggle" }
|
|
29955
|
-
],
|
|
29956
|
-
helperMessage: "The editor to use when editing this value in the UI. Make sure this matches the data type."
|
|
29957
|
-
}
|
|
29958
|
-
];
|
|
29959
|
-
}
|
|
29960
|
-
getBody() {
|
|
29961
|
-
return import_ts_dedent20.dedent`
|
|
29962
|
-
${this.data.id}
|
|
29963
|
-
Type: ${this.data.dataType}
|
|
29964
|
-
${this.data.defaultValue == null ? "" : `Default: ${this.data.defaultValue}`}
|
|
29965
|
-
`;
|
|
29966
|
-
}
|
|
29967
|
-
static getUIData() {
|
|
29968
|
-
return {
|
|
29969
|
-
infoBoxBody: import_ts_dedent20.dedent`
|
|
29970
|
-
Defines an input for the graph which can be passed in when the graph is called, or defines one of the input ports when the graph is a subgraph.
|
|
29971
|
-
`,
|
|
29972
|
-
infoBoxTitle: "Graph Input Node",
|
|
29973
|
-
contextMenuTitle: "Graph Input",
|
|
29974
|
-
group: ["Input/Output"]
|
|
29975
|
-
};
|
|
29976
|
-
}
|
|
29977
|
-
async process(inputs, context) {
|
|
29978
|
-
let inputValue = context.graphInputs[this.data.id] == null ? void 0 : coerceTypeOptional(context.graphInputs[this.data.id], this.data.dataType);
|
|
29979
|
-
if (inputValue == null && this.data.useDefaultValueInput) {
|
|
29980
|
-
inputValue = coerceTypeOptional(inputs["default"], this.data.dataType);
|
|
29981
|
-
}
|
|
29982
|
-
if (inputValue == null) {
|
|
29983
|
-
inputValue = coerceTypeOptional(inferType(this.data.defaultValue), this.data.dataType) || getDefaultValue(this.data.dataType);
|
|
29984
|
-
}
|
|
29985
|
-
if (inputValue == null && isArrayDataType(this.data.dataType)) {
|
|
29986
|
-
inputValue = { type: this.data.dataType, value: [] };
|
|
29987
|
-
}
|
|
29988
|
-
const value = {
|
|
29989
|
-
type: this.data.dataType,
|
|
29990
|
-
value: inputValue
|
|
29991
|
-
};
|
|
29992
|
-
context.graphInputNodeValues[this.data.id] = value;
|
|
29993
|
-
return { ["data"]: value };
|
|
29994
|
-
}
|
|
29995
|
-
};
|
|
29996
|
-
var graphInputNode = nodeDefinition(GraphInputNodeImpl, "Graph Input");
|
|
29997
|
-
|
|
29998
30466
|
// src/model/nodes/SubGraphNode.ts
|
|
29999
30467
|
var import_non_secure27 = require("nanoid/non-secure");
|
|
30000
30468
|
var import_ts_dedent21 = require("ts-dedent");
|
|
@@ -30113,6 +30581,7 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
30113
30581
|
context.contextValues,
|
|
30114
30582
|
{
|
|
30115
30583
|
...requestedGraphOutputIds ? { requestedGraphOutputIds } : {},
|
|
30584
|
+
graphInputStreams: context.graphInputStreams,
|
|
30116
30585
|
// A child Graph Output can relay a direct producer's partial value
|
|
30117
30586
|
// under the public boundary port ID. An Error-output Subgraph may
|
|
30118
30587
|
// later replace that same normal output with an exclusion, so it is
|
|
@@ -30472,6 +30941,17 @@ function createMatchedOutput(value) {
|
|
|
30472
30941
|
var import_non_secure30 = require("nanoid/non-secure");
|
|
30473
30942
|
var import_lodash_es8 = require("lodash");
|
|
30474
30943
|
var import_ts_dedent24 = require("ts-dedent");
|
|
30944
|
+
function isEmptyPromptMessage(message) {
|
|
30945
|
+
var _a;
|
|
30946
|
+
if (message.type === "function") {
|
|
30947
|
+
return false;
|
|
30948
|
+
}
|
|
30949
|
+
if (message.type === "assistant" && (message.function_call != null || (((_a = message.function_calls) == null ? void 0 : _a.length) ?? 0) > 0)) {
|
|
30950
|
+
return false;
|
|
30951
|
+
}
|
|
30952
|
+
const parts = Array.isArray(message.message) ? message.message : [message.message];
|
|
30953
|
+
return !parts.some((part) => typeof part !== "string" || part.trim().length > 0);
|
|
30954
|
+
}
|
|
30475
30955
|
var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
30476
30956
|
static create() {
|
|
30477
30957
|
const chartNode = {
|
|
@@ -30483,7 +30963,9 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
30483
30963
|
y: 0,
|
|
30484
30964
|
width: 250
|
|
30485
30965
|
},
|
|
30486
|
-
data: {
|
|
30966
|
+
data: {
|
|
30967
|
+
filterEmptyPrompts: false
|
|
30968
|
+
}
|
|
30487
30969
|
};
|
|
30488
30970
|
return chartNode;
|
|
30489
30971
|
}
|
|
@@ -30495,7 +30977,7 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
30495
30977
|
dataType: "boolean",
|
|
30496
30978
|
id: "isLastMessageCacheBreakpoint",
|
|
30497
30979
|
title: "Is Last Message Cache Breakpoint",
|
|
30498
|
-
description: "Whether the last message in
|
|
30980
|
+
description: "Whether the last message in a multi-message prompt should be a cache breakpoint."
|
|
30499
30981
|
});
|
|
30500
30982
|
}
|
|
30501
30983
|
for (let i = 1; i <= messageCount; i++) {
|
|
@@ -30541,23 +31023,34 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
30541
31023
|
group: ["AI"]
|
|
30542
31024
|
};
|
|
30543
31025
|
}
|
|
30544
|
-
getEditors(
|
|
31026
|
+
getEditors() {
|
|
30545
31027
|
return [
|
|
30546
31028
|
{
|
|
30547
31029
|
type: "toggle",
|
|
30548
31030
|
label: "Compute Token Count",
|
|
30549
31031
|
dataKey: "computeTokenCount"
|
|
30550
31032
|
},
|
|
31033
|
+
{
|
|
31034
|
+
type: "toggle",
|
|
31035
|
+
label: "Filter empty prompts",
|
|
31036
|
+
dataKey: "filterEmptyPrompts",
|
|
31037
|
+
defaultValue: false,
|
|
31038
|
+
helperMessage: "Removes text-only messages whose content is empty or whitespace. Rich-content and tool-protocol messages are preserved."
|
|
31039
|
+
},
|
|
30551
31040
|
{
|
|
30552
31041
|
type: "toggle",
|
|
30553
31042
|
label: "Is Last Message Cache Breakpoint",
|
|
30554
31043
|
dataKey: "isLastMessageCacheBreakpoint",
|
|
30555
|
-
|
|
31044
|
+
useInputToggleDataKey: "useIsLastMessageCacheBreakpointInput",
|
|
31045
|
+
helperMessage: "For Anthropic, marks the last message in a prompt containing at least two messages as a cache breakpoint. This message and every message before it will be cached using Prompt Caching."
|
|
30556
31046
|
}
|
|
30557
31047
|
];
|
|
30558
31048
|
}
|
|
30559
|
-
getBody(
|
|
30560
|
-
return
|
|
31049
|
+
getBody() {
|
|
31050
|
+
return [
|
|
31051
|
+
this.data.filterEmptyPrompts ? "Filter empty prompts: Enabled" : "",
|
|
31052
|
+
this.data.useIsLastMessageCacheBreakpointInput ? "Last message cache breakpoint: From input" : this.data.isLastMessageCacheBreakpoint ? "Last message is cache breakpoint" : ""
|
|
31053
|
+
].filter(Boolean).join("\n");
|
|
30561
31054
|
}
|
|
30562
31055
|
async process(inputs, context) {
|
|
30563
31056
|
const output = {};
|
|
@@ -30565,7 +31058,7 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
30565
31058
|
const outMessages = [];
|
|
30566
31059
|
const inputMessages = (0, import_lodash_es8.orderBy)(
|
|
30567
31060
|
Object.entries(inputs).filter(([key]) => key.startsWith("message")),
|
|
30568
|
-
([key]) => key,
|
|
31061
|
+
([key]) => parseVariadicPortIndex(key, "message", "legacy"),
|
|
30569
31062
|
"asc"
|
|
30570
31063
|
);
|
|
30571
31064
|
for (const [, inputMessage] of inputMessages) {
|
|
@@ -30574,18 +31067,18 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
30574
31067
|
}
|
|
30575
31068
|
const inMessages = arrayizeDataValue(unwrapDataValue(inputMessage));
|
|
30576
31069
|
for (const message of inMessages) {
|
|
30577
|
-
|
|
30578
|
-
|
|
30579
|
-
|
|
30580
|
-
const coerced = coerceType(message, "chat-message");
|
|
30581
|
-
if (coerced) {
|
|
30582
|
-
outMessages.push(coerced);
|
|
30583
|
-
}
|
|
31070
|
+
const outMessage = message.type === "chat-message" ? message.value : coerceType(message, "chat-message");
|
|
31071
|
+
if (this.data.filterEmptyPrompts && isEmptyPromptMessage(outMessage)) {
|
|
31072
|
+
continue;
|
|
30584
31073
|
}
|
|
31074
|
+
outMessages.push(outMessage);
|
|
30585
31075
|
}
|
|
30586
31076
|
}
|
|
30587
31077
|
if (isLastMessageCacheBreakpoint && outMessages.length > 1) {
|
|
30588
|
-
outMessages.
|
|
31078
|
+
outMessages[outMessages.length - 1] = {
|
|
31079
|
+
...outMessages[outMessages.length - 1],
|
|
31080
|
+
isCacheBreakpoint: true
|
|
31081
|
+
};
|
|
30589
31082
|
}
|
|
30590
31083
|
output["prompt"] = {
|
|
30591
31084
|
type: "chat-message[]",
|
|
@@ -31676,6 +32169,42 @@ var GraphCallPathNodeImpl = class extends NodeImpl {
|
|
|
31676
32169
|
};
|
|
31677
32170
|
var graphCallPathNode = nodeDefinition(GraphCallPathNodeImpl, "Graph Call Path");
|
|
31678
32171
|
|
|
32172
|
+
// src/model/nodes/ProjectNameNode.ts
|
|
32173
|
+
var ProjectNameNodeImpl = class extends NodeImpl {
|
|
32174
|
+
static create() {
|
|
32175
|
+
return {
|
|
32176
|
+
id: newId(),
|
|
32177
|
+
type: "projectName",
|
|
32178
|
+
title: "Project Name",
|
|
32179
|
+
visualData: { x: 0, y: 0, width: 250 },
|
|
32180
|
+
data: {}
|
|
32181
|
+
};
|
|
32182
|
+
}
|
|
32183
|
+
getInputDefinitions() {
|
|
32184
|
+
return [];
|
|
32185
|
+
}
|
|
32186
|
+
getOutputDefinitions() {
|
|
32187
|
+
return [{ id: "projectName", title: "Project Name", dataType: "string" }];
|
|
32188
|
+
}
|
|
32189
|
+
getEditors() {
|
|
32190
|
+
return [];
|
|
32191
|
+
}
|
|
32192
|
+
static getUIData() {
|
|
32193
|
+
return {
|
|
32194
|
+
contextMenuTitle: "Project Name",
|
|
32195
|
+
infoBoxTitle: "Project Name",
|
|
32196
|
+
infoBoxBody: "Returns the name of the project that owns the graph currently being executed. A graph called from a referenced project returns that referenced project's name.",
|
|
32197
|
+
group: ["Debug"]
|
|
32198
|
+
};
|
|
32199
|
+
}
|
|
32200
|
+
async process(_inputs, context) {
|
|
32201
|
+
return {
|
|
32202
|
+
["projectName"]: { type: "string", value: context.project.metadata.title }
|
|
32203
|
+
};
|
|
32204
|
+
}
|
|
32205
|
+
};
|
|
32206
|
+
var projectNameNode = nodeDefinition(ProjectNameNodeImpl, "Project Name");
|
|
32207
|
+
|
|
31679
32208
|
// src/model/nodes/CoalesceNode.ts
|
|
31680
32209
|
var import_ts_dedent32 = require("ts-dedent");
|
|
31681
32210
|
|
|
@@ -37805,7 +38334,7 @@ var AssembleMessageNodeImpl = class extends NodeImpl {
|
|
|
37805
38334
|
});
|
|
37806
38335
|
const inputParts = (0, import_lodash_es13.orderBy)(
|
|
37807
38336
|
Object.entries(inputs).filter(([key]) => key.startsWith("part")),
|
|
37808
|
-
([key]) => key,
|
|
38337
|
+
([key]) => parseVariadicPortIndex(key, "part", "legacy"),
|
|
37809
38338
|
"asc"
|
|
37810
38339
|
);
|
|
37811
38340
|
for (const [, inputPart] of inputParts) {
|
|
@@ -40673,6 +41202,7 @@ var ReferencedGraphAliasNodeImpl = class extends NodeImpl {
|
|
|
40673
41202
|
inputData,
|
|
40674
41203
|
context.contextValues,
|
|
40675
41204
|
{
|
|
41205
|
+
graphInputStreams: context.graphInputStreams,
|
|
40676
41206
|
// This node preserves the referenced graph's named boundary ports,
|
|
40677
41207
|
// so it may relay their direct producer partials to a parent Watch.
|
|
40678
41208
|
// An Error-output alias can replace normal ports with exclusions,
|
|
@@ -40755,7 +41285,7 @@ var nodePrefabInstanceNode = nodeDefinition(NodePrefabInstanceNodeImpl, "Linked
|
|
|
40755
41285
|
|
|
40756
41286
|
// src/model/Nodes.ts
|
|
40757
41287
|
var registerBuiltInNodes = (registry) => {
|
|
40758
|
-
return registry.register(toYamlNode).register(userInputNode).register(textNode).register(llmChatV2Node).register(llmProfileNode).register(chatNode).register(promptNode).register(extractRegexNode).register(codeNode).register(codeNewNode).register(expressionNode).register(matchNode).register(matchCaseNode).register(ifNode).register(readDirectoryNode).register(readFileNode).register(ifElseNode).register(chunkNode).register(graphInputNode).register(graphOutputNode).register(subGraphNode).register(arrayNode).register(extractJsonNode).register(assemblePromptNode).register(loopControllerNode).register(trimChatMessagesNode).register(extractYamlNode).register(externalCallNode).register(extractObjectPathNode).register(raiseEventNode).register(reportProgressNode).register(contextNode).register(graphCallPathNode).register(coalesceNode).register(coalesceNewNode).register(didRunNode).register(passthroughNode).register(dataBusNode).register(startBackgroundBranchNode).register(watchStreamingOutputNode).register(stopWatchingStreamingOutputNode).register(popNode).register(setGlobalNode).register(getGlobalNode).register(setStoredValueNode).register(getStoredValueNode).register(waitForEventNode).register(gptFunctionNode).register(getEmbeddingNode).register(vectorStoreNode).register(vectorNearestNeighborsNode).register(knowledgeSourceNode).register(knowledgeDocumentNode).register(syncKnowledgeSourceNode).register(getKnowledgeSourceStatusNode).register(searchKnowledgeNode).register(buildKnowledgeContextNode).register(hashNode).register(abortGraphNode).register(raceInputsNode).register(toJsonNode).register(joinNode).register(filterNode).register(jsFilterNode).register(jsMapNode).register(objectNode).register(booleanNode).register(compareNode).register(evaluateNode).register(numberNode).register(randomNumberNode).register(shuffleNode).register(commentNode).register(imageNode).register(audioNode).register(httpCallNode).register(delayNode).register(appendToDatasetNode).register(createDatasetNode).register(loadDatasetNode).register(getAllDatasetsNode).register(splitNode).register(datasetNearestNeighborsNode).register(getDatasetRowNode).register(sliceNode).register(extractMarkdownCodeBlocksNode).register(assembleMessageNode).register(urlReferenceNode).register(destructureNode).register(replaceDatasetNode).register(listGraphsNode).register(graphReferenceNode).register(callGraphNode).register(delegateFunctionCallNode).register(playAudioNode).register(documentNode).register(chatLoopNode).register(readAllFilesNode).register(toMarkdownTableNode).register(cronNode).register(toTreeNode).register(loopUntilNode).register(mcpDiscoveryNode).register(mcpToolCallNode).register(mcpGetPromptNode).register(referencedGraphAliasNode).register(nodePrefabInstanceNode);
|
|
41288
|
+
return registry.register(toYamlNode).register(userInputNode).register(textNode).register(llmChatV2Node).register(llmProfileNode).register(chatNode).register(promptNode).register(extractRegexNode).register(codeNode).register(codeNewNode).register(expressionNode).register(matchNode).register(matchCaseNode).register(ifNode).register(readDirectoryNode).register(readFileNode).register(ifElseNode).register(chunkNode).register(graphInputNode).register(graphOutputNode).register(subGraphNode).register(arrayNode).register(extractJsonNode).register(assemblePromptNode).register(loopControllerNode).register(trimChatMessagesNode).register(extractYamlNode).register(externalCallNode).register(extractObjectPathNode).register(raiseEventNode).register(reportProgressNode).register(contextNode).register(graphCallPathNode).register(projectNameNode).register(coalesceNode).register(coalesceNewNode).register(didRunNode).register(passthroughNode).register(dataBusNode).register(startBackgroundBranchNode).register(watchStreamingOutputNode).register(stopWatchingStreamingOutputNode).register(popNode).register(setGlobalNode).register(getGlobalNode).register(setStoredValueNode).register(getStoredValueNode).register(waitForEventNode).register(gptFunctionNode).register(getEmbeddingNode).register(vectorStoreNode).register(vectorNearestNeighborsNode).register(knowledgeSourceNode).register(knowledgeDocumentNode).register(syncKnowledgeSourceNode).register(getKnowledgeSourceStatusNode).register(searchKnowledgeNode).register(buildKnowledgeContextNode).register(hashNode).register(abortGraphNode).register(raceInputsNode).register(toJsonNode).register(joinNode).register(filterNode).register(jsFilterNode).register(jsMapNode).register(objectNode).register(booleanNode).register(compareNode).register(evaluateNode).register(numberNode).register(randomNumberNode).register(shuffleNode).register(commentNode).register(imageNode).register(audioNode).register(httpCallNode).register(delayNode).register(appendToDatasetNode).register(createDatasetNode).register(loadDatasetNode).register(getAllDatasetsNode).register(splitNode).register(datasetNearestNeighborsNode).register(getDatasetRowNode).register(sliceNode).register(extractMarkdownCodeBlocksNode).register(assembleMessageNode).register(urlReferenceNode).register(destructureNode).register(replaceDatasetNode).register(listGraphsNode).register(graphReferenceNode).register(callGraphNode).register(delegateFunctionCallNode).register(playAudioNode).register(documentNode).register(chatLoopNode).register(readAllFilesNode).register(toMarkdownTableNode).register(cronNode).register(toTreeNode).register(loopUntilNode).register(mcpDiscoveryNode).register(mcpToolCallNode).register(mcpGetPromptNode).register(referencedGraphAliasNode).register(nodePrefabInstanceNode);
|
|
40759
41289
|
};
|
|
40760
41290
|
var globalRivetNodeRegistry = registerBuiltInNodes(new NodeRegistration());
|
|
40761
41291
|
function resetGlobalRivetNodeRegistry() {
|
|
@@ -48733,6 +49263,7 @@ var Rivet = void 0;
|
|
|
48733
49263
|
PlayAudioNodeImpl,
|
|
48734
49264
|
PluginNodeImplClass,
|
|
48735
49265
|
PopNodeImpl,
|
|
49266
|
+
ProjectNameNodeImpl,
|
|
48736
49267
|
ProjectValidationError,
|
|
48737
49268
|
PromptNodeImpl,
|
|
48738
49269
|
RIVET_MARKDOWN_ALLOWED_ATTRIBUTES,
|
|
@@ -48826,6 +49357,8 @@ var Rivet = void 0;
|
|
|
48826
49357
|
canBeCoercedAny,
|
|
48827
49358
|
canConsumeControlFlowExcludedInput,
|
|
48828
49359
|
canRenderDataBusNode,
|
|
49360
|
+
canStreamThroughGraphCaller,
|
|
49361
|
+
canStreamThroughGraphInput,
|
|
48829
49362
|
canUseNodeAsPrefabSource,
|
|
48830
49363
|
chatLoopLegacyDisplayName,
|
|
48831
49364
|
chatLoopNode,
|
|
@@ -48988,6 +49521,7 @@ var Rivet = void 0;
|
|
|
48988
49521
|
getProjectConnectionComparisonKey,
|
|
48989
49522
|
getProjectGlobalVariableIds,
|
|
48990
49523
|
getProjectNodeFieldComparisons,
|
|
49524
|
+
getProjectStreamingOutputWatchConnections,
|
|
48991
49525
|
getReconciledUiGraphActionInputBindings,
|
|
48992
49526
|
getReconciledUiGraphActionOutputBindings,
|
|
48993
49527
|
getScalarTypeOf,
|
|
@@ -49164,6 +49698,7 @@ var Rivet = void 0;
|
|
|
49164
49698
|
popNode,
|
|
49165
49699
|
projectLLMChatV2EditorCacheHit,
|
|
49166
49700
|
projectLLMInvocationUsage,
|
|
49701
|
+
projectNameNode,
|
|
49167
49702
|
promptNode,
|
|
49168
49703
|
protectEscapedInterpolationTokens,
|
|
49169
49704
|
raceInputsNode,
|
|
@@ -49195,6 +49730,7 @@ var Rivet = void 0;
|
|
|
49195
49730
|
resolveChatV2ProviderConfig,
|
|
49196
49731
|
resolveChatV2ResponseFormatParameters,
|
|
49197
49732
|
resolveCodeInterpolationExpression,
|
|
49733
|
+
resolveGraphInputValue,
|
|
49198
49734
|
resolveInterpolationExpressionRawValue,
|
|
49199
49735
|
resolveInterpolationTokenRawValue,
|
|
49200
49736
|
resolveLLMChatV2RuntimeProviderOptions,
|