@valerypopoff/rivet2-core 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cjs/bundle.cjs +1430 -669
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/cjs/interpolationRuntime.cjs +1578 -0
  4. package/dist/cjs/interpolationRuntime.cjs.map +7 -0
  5. package/dist/cjs/interpolationSyntax.cjs +186 -0
  6. package/dist/cjs/interpolationSyntax.cjs.map +7 -0
  7. package/dist/cjs/webAppRuntime.cjs.map +2 -2
  8. package/dist/esm/exports.js +2 -1
  9. package/dist/esm/integrations/CodeRunner.js +5 -0
  10. package/dist/esm/integrations/mcp/MCPBase.js +16 -6
  11. package/dist/esm/interpolationRuntime.js +5 -0
  12. package/dist/esm/model/GraphBoundaryCache.js +0 -6
  13. package/dist/esm/model/GraphBoundaryEffects.js +5 -1
  14. package/dist/esm/model/GraphOutputSelection.js +34 -0
  15. package/dist/esm/model/GraphProcessor.js +136 -44
  16. package/dist/esm/model/ProcessContextBuilder.js +2 -0
  17. package/dist/esm/model/RecordingPlayer.js +11 -6
  18. package/dist/esm/model/StoredValueStore.js +4 -3
  19. package/dist/esm/model/nodes/CodeNewNode.js +16 -16
  20. package/dist/esm/model/nodes/DestructureNode.js +2 -2
  21. package/dist/esm/model/nodes/ExpressionNode.js +16 -16
  22. package/dist/esm/model/nodes/ExtractObjectPathNode.js +2 -2
  23. package/dist/esm/model/nodes/ExtractYamlNode.js +5 -5
  24. package/dist/esm/model/nodes/JSFilterNode.js +3 -1
  25. package/dist/esm/model/nodes/JSMapNode.js +3 -1
  26. package/dist/esm/model/nodes/MCPGetPromptNode.js +6 -2
  27. package/dist/esm/model/nodes/MCPToolCallNode.js +6 -2
  28. package/dist/esm/model/nodes/ObjectNode.js +19 -20
  29. package/dist/esm/model/nodes/PromptNode.js +10 -11
  30. package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +2 -40
  31. package/dist/esm/model/nodes/SubGraphNode.js +40 -26
  32. package/dist/esm/model/nodes/TextNode.js +11 -32
  33. package/dist/esm/model/nodes/ToTreeNode.js +6 -13
  34. package/dist/esm/model/nodes/ToolNode.js +33 -16
  35. package/dist/esm/model/nodes/jsListCallbackHelpers.js +19 -15
  36. package/dist/esm/model/nodes/jsValueInterpolation.js +83 -30
  37. package/dist/esm/model/nodes/nodeBodyPreview.js +23 -0
  38. package/dist/esm/plugins/openai/nodes/ThreadMessageNode.js +14 -11
  39. package/dist/esm/utils/index.js +2 -0
  40. package/dist/esm/utils/interpolation.js +478 -221
  41. package/dist/esm/utils/interpolationSyntax.js +175 -0
  42. package/dist/esm/utils/jsonPath.js +129 -0
  43. package/dist/types/exports.d.ts +3 -1
  44. package/dist/types/integrations/CodeRunnerOptions.d.ts +9 -0
  45. package/dist/types/integrations/mcp/MCPBase.d.ts +3 -1
  46. package/dist/types/interpolationRuntime.d.ts +5 -0
  47. package/dist/types/model/GraphBoundaryCache.d.ts +0 -2
  48. package/dist/types/model/GraphOutputSelection.d.ts +8 -0
  49. package/dist/types/model/GraphProcessor.d.ts +4 -3
  50. package/dist/types/model/ProcessContext.d.ts +3 -2
  51. package/dist/types/model/nodes/ObjectNode.d.ts +1 -1
  52. package/dist/types/model/nodes/SubGraphNode.d.ts +2 -0
  53. package/dist/types/model/nodes/ToTreeNode.d.ts +5 -2
  54. package/dist/types/model/nodes/ToolNode.d.ts +13 -1
  55. package/dist/types/model/nodes/jsValueInterpolation.d.ts +16 -8
  56. package/dist/types/model/nodes/nodeBodyPreview.d.ts +7 -0
  57. package/dist/types/utils/index.d.ts +2 -0
  58. package/dist/types/utils/interpolation.d.ts +93 -8
  59. package/dist/types/utils/interpolationSyntax.d.ts +21 -0
  60. package/dist/types/utils/jsonPath.d.ts +15 -0
  61. package/package.json +11 -1
@@ -0,0 +1,175 @@
1
+ const REGEX_LITERAL_PREFIX_CHARACTERS = new Set([
2
+ '(',
3
+ '[',
4
+ '{',
5
+ ':',
6
+ ';',
7
+ ',',
8
+ '=',
9
+ '!',
10
+ '~',
11
+ '?',
12
+ '&',
13
+ '|',
14
+ '+',
15
+ '-',
16
+ '*',
17
+ '%',
18
+ '^',
19
+ '<',
20
+ '>',
21
+ ]);
22
+ export function isInterpolationSyntaxCharacterEscaped(value, index) {
23
+ let backslashCount = 0;
24
+ for (let cursor = index - 1; cursor >= 0 && value[cursor] === '\\'; cursor -= 1) {
25
+ backslashCount += 1;
26
+ }
27
+ return backslashCount % 2 === 1;
28
+ }
29
+ /**
30
+ * JSONPath filters can contain JavaScript regex literals. Treat their contents
31
+ * as opaque while looking for an interpolation terminator or processor pipe;
32
+ * otherwise a `]` or `|` inside the regex can be mistaken for JSONPath syntax.
33
+ */
34
+ export function isInterpolationRegexLiteralStart(value, index) {
35
+ if (value[index] !== '/') {
36
+ return false;
37
+ }
38
+ let previousIndex = index - 1;
39
+ while (previousIndex >= 0 && /\s/.test(value[previousIndex])) {
40
+ previousIndex -= 1;
41
+ }
42
+ return previousIndex < 0 || REGEX_LITERAL_PREFIX_CHARACTERS.has(value[previousIndex]);
43
+ }
44
+ function getEscapedTripleTokenEnd(template, start) {
45
+ for (let cursor = start + 3; cursor < template.length - 2; cursor += 1) {
46
+ if (template[cursor] === '}' && template[cursor + 1] === '}' && template[cursor + 2] === '}') {
47
+ return cursor + 3;
48
+ }
49
+ }
50
+ return undefined;
51
+ }
52
+ /** Finds a matching `}}` while allowing JSONPath filters, quotes, and braces. */
53
+ function scanInterpolationToken(template, start) {
54
+ let quote;
55
+ let regex = false;
56
+ let regexCharacterClass = false;
57
+ let bracketDepth = 0;
58
+ let parenthesisDepth = 0;
59
+ let braceDepth = 0;
60
+ for (let cursor = start + 2; cursor < template.length; cursor += 1) {
61
+ const character = template[cursor];
62
+ if (regex) {
63
+ if (character === '[' && !isInterpolationSyntaxCharacterEscaped(template, cursor)) {
64
+ regexCharacterClass = true;
65
+ }
66
+ else if (character === ']' && !isInterpolationSyntaxCharacterEscaped(template, cursor)) {
67
+ regexCharacterClass = false;
68
+ }
69
+ else if (character === '/' && !regexCharacterClass && !isInterpolationSyntaxCharacterEscaped(template, cursor)) {
70
+ regex = false;
71
+ }
72
+ continue;
73
+ }
74
+ if (quote) {
75
+ if (character === quote && !isInterpolationSyntaxCharacterEscaped(template, cursor)) {
76
+ quote = undefined;
77
+ }
78
+ continue;
79
+ }
80
+ if (character === '/' && isInterpolationRegexLiteralStart(template, cursor)) {
81
+ regex = true;
82
+ regexCharacterClass = false;
83
+ continue;
84
+ }
85
+ if (character === '"' || character === "'" || character === '`') {
86
+ quote = character;
87
+ continue;
88
+ }
89
+ // A second opener always starts recovery outside quoted or regex syntax.
90
+ // JSONPath object literals use single `{` characters; a literal `{{` is
91
+ // not valid JSONPath syntax and should not swallow a later valid token.
92
+ if (character === '{' && template[cursor + 1] === '{') {
93
+ return { kind: 'nested', start: cursor };
94
+ }
95
+ if (character === '[') {
96
+ bracketDepth += 1;
97
+ continue;
98
+ }
99
+ if (character === ']' && bracketDepth > 0) {
100
+ bracketDepth -= 1;
101
+ continue;
102
+ }
103
+ if (character === '(') {
104
+ parenthesisDepth += 1;
105
+ continue;
106
+ }
107
+ if (character === ')' && parenthesisDepth > 0) {
108
+ parenthesisDepth -= 1;
109
+ continue;
110
+ }
111
+ if (character === '{') {
112
+ braceDepth += 1;
113
+ continue;
114
+ }
115
+ if (character === '}') {
116
+ if (braceDepth > 0) {
117
+ braceDepth -= 1;
118
+ continue;
119
+ }
120
+ if (template[cursor + 1] === '}' && bracketDepth === 0 && parenthesisDepth === 0) {
121
+ return { kind: 'closed', end: cursor + 2 };
122
+ }
123
+ }
124
+ }
125
+ return { kind: 'unclosed' };
126
+ }
127
+ /**
128
+ * Scans token boundaries without parsing expressions or resolving values.
129
+ *
130
+ * This deliberately has no evaluator dependencies, so editor-only surfaces
131
+ * can share Core's malformed-token recovery rules without loading JSONPath or
132
+ * the rest of the execution runtime. The returned spans are fresh data and
133
+ * exclude escaped triple-brace tokens.
134
+ */
135
+ export function scanInterpolationTokenSpans(template) {
136
+ const spans = [];
137
+ let searchIndex = 0;
138
+ while (searchIndex < template.length) {
139
+ const start = template.indexOf('{{', searchIndex);
140
+ if (start === -1) {
141
+ break;
142
+ }
143
+ if (template[start + 2] === '{') {
144
+ const escapedEnd = getEscapedTripleTokenEnd(template, start);
145
+ if (escapedEnd !== undefined) {
146
+ searchIndex = escapedEnd;
147
+ continue;
148
+ }
149
+ }
150
+ const scanResult = scanInterpolationToken(template, start);
151
+ if (scanResult.kind === 'nested') {
152
+ searchIndex = scanResult.start;
153
+ continue;
154
+ }
155
+ if (scanResult.kind === 'unclosed') {
156
+ // A malformed outer token can leave the scanner inside an unterminated
157
+ // quote or filter. Resume at a later opener so a valid following token
158
+ // is still discovered. Properly closed outer tokens return above, so
159
+ // valid quoted `{{` content remains part of that outer token.
160
+ const nextStart = template.indexOf('{{', start + 2);
161
+ if (nextStart === -1) {
162
+ break;
163
+ }
164
+ searchIndex = nextStart;
165
+ continue;
166
+ }
167
+ spans.push({
168
+ start,
169
+ end: scanResult.end,
170
+ rawInner: template.slice(start + 2, scanResult.end - 2),
171
+ });
172
+ searchIndex = scanResult.end;
173
+ }
174
+ return spans;
175
+ }
@@ -0,0 +1,129 @@
1
+ import { JSONPath } from 'jsonpath-plus';
2
+ import { isInterpolationRegexLiteralStart, isInterpolationSyntaxCharacterEscaped } from './interpolationSyntax.js';
3
+ function getNextNonWhitespaceCharacter(value, index) {
4
+ for (let cursor = index; cursor < value.length; cursor++) {
5
+ if (!/\s/.test(value[cursor])) {
6
+ return value[cursor];
7
+ }
8
+ }
9
+ return undefined;
10
+ }
11
+ function getWhitespaceRunEnd(value, index) {
12
+ let cursor = index;
13
+ while (cursor < value.length && /\s/.test(value[cursor])) {
14
+ cursor += 1;
15
+ }
16
+ return cursor;
17
+ }
18
+ /**
19
+ * Normalizes Rivet's historically accepted convenience whitespace around
20
+ * JSONPath structural separators. Quoted values, regular expressions, filter
21
+ * expressions, and object literals keep their authored contents unchanged.
22
+ *
23
+ * All runtime JSONPath consumers must pass through this helper so stored node
24
+ * paths and interpolation suffixes accept the same path language.
25
+ */
26
+ export function normalizeJsonPathExpression(path) {
27
+ const trimmedPath = path.trim();
28
+ if (!/\s/.test(trimmedPath)) {
29
+ return trimmedPath;
30
+ }
31
+ const result = [];
32
+ let lastResultCharacter;
33
+ let quote;
34
+ let regex = false;
35
+ let regexCharacterClass = false;
36
+ const filterBrackets = [];
37
+ let filterDepth = 0;
38
+ const append = (value) => {
39
+ if (value === '') {
40
+ return;
41
+ }
42
+ result.push(value);
43
+ lastResultCharacter = value.at(-1);
44
+ };
45
+ for (let cursor = 0; cursor < trimmedPath.length; cursor++) {
46
+ const character = trimmedPath[cursor];
47
+ if (regex) {
48
+ if (character === '[' && !isInterpolationSyntaxCharacterEscaped(trimmedPath, cursor)) {
49
+ regexCharacterClass = true;
50
+ }
51
+ else if (character === ']' && !isInterpolationSyntaxCharacterEscaped(trimmedPath, cursor)) {
52
+ regexCharacterClass = false;
53
+ }
54
+ else if (character === '/' &&
55
+ !regexCharacterClass &&
56
+ !isInterpolationSyntaxCharacterEscaped(trimmedPath, cursor)) {
57
+ regex = false;
58
+ }
59
+ append(character);
60
+ continue;
61
+ }
62
+ if (quote) {
63
+ if (character === quote && !isInterpolationSyntaxCharacterEscaped(trimmedPath, cursor)) {
64
+ quote = undefined;
65
+ }
66
+ append(character);
67
+ continue;
68
+ }
69
+ if (character === '"' || character === "'" || character === '`') {
70
+ quote = character;
71
+ append(character);
72
+ continue;
73
+ }
74
+ if (character === '/' && isInterpolationRegexLiteralStart(trimmedPath, cursor)) {
75
+ regex = true;
76
+ regexCharacterClass = false;
77
+ append(character);
78
+ continue;
79
+ }
80
+ const insideFilter = filterDepth > 0;
81
+ if (/\s/.test(character)) {
82
+ const whitespaceEnd = getWhitespaceRunEnd(trimmedPath, cursor);
83
+ const previousCharacter = lastResultCharacter;
84
+ const nextCharacter = trimmedPath[whitespaceEnd];
85
+ // jsonpath-plus rejects whitespace immediately inside either bracket.
86
+ // Preserve other filter whitespace because it may separate JavaScript
87
+ // tokens or be meaningful inside filter expressions.
88
+ const shouldRemoveWhitespace = previousCharacter === '[' ||
89
+ nextCharacter === ']' ||
90
+ nextCharacter === '[' ||
91
+ (!insideFilter && (previousCharacter === '.' || previousCharacter === ']' || nextCharacter === '.'));
92
+ if (!shouldRemoveWhitespace) {
93
+ append(trimmedPath.slice(cursor, whitespaceEnd));
94
+ }
95
+ cursor = whitespaceEnd - 1;
96
+ continue;
97
+ }
98
+ if (character === '[') {
99
+ const opensFilter = getNextNonWhitespaceCharacter(trimmedPath, cursor + 1) === '?';
100
+ filterBrackets.push(opensFilter);
101
+ if (opensFilter) {
102
+ filterDepth += 1;
103
+ }
104
+ append(character);
105
+ continue;
106
+ }
107
+ if (character === ']') {
108
+ if (filterBrackets.pop()) {
109
+ filterDepth -= 1;
110
+ }
111
+ append(character);
112
+ continue;
113
+ }
114
+ append(character);
115
+ }
116
+ return result.join('').trim();
117
+ }
118
+ /**
119
+ * Evaluates a JSONPath expression with the same engine and options used by the
120
+ * object-path nodes. Callers retain ownership of their no-match and error
121
+ * policy; this helper deliberately lets JSONPath errors propagate.
122
+ */
123
+ export function evaluateJsonPath(value, path, wrap = false) {
124
+ return JSONPath({
125
+ json: value ?? null,
126
+ path: normalizeJsonPathExpression(path),
127
+ wrap,
128
+ });
129
+ }
@@ -68,7 +68,9 @@ export * from './integrations/Tokenizer.js';
68
68
  export * from './integrations/GptTokenizerTokenizer.js';
69
69
  export { JS_LIST_CALLBACK_LOCAL_NAMES, interpolateJSListCallbackBody } from './model/nodes/jsListCallbackHelpers.js';
70
70
  export { findAutoDelegateGraphCandidate } from './model/nodes/toolCallDelegation.js';
71
- export { extractInterpolationVariables, findInterpolationTokenSpans, getInterpolationTokenName, interpolate, protectEscapedInterpolationTokens, restoreEscapedInterpolationTokens, } from './utils/interpolation.js';
71
+ export { extractInterpolationVariables, extractInterpolationVariableReferences, findInterpolationTokenSpans, getInterpolationTokenReference, getInterpolationTokenName, interpolate, parseInterpolationExpression, parseInterpolationTemplate, protectEscapedInterpolationTokens, resolveCodeInterpolationExpression, resolveInterpolationExpressionRawValue, resolveInterpolationTokenRawValue, restoreEscapedInterpolationTokens, stringifyInterpolationSourceValue, } from './utils/interpolation.js';
72
+ export type { InterpolateOptions, InterpolationReferenceSource, InterpolationTokenReplacementInfo, InterpolationTokenSpan, InterpolationValueSources, InterpolationVariableReference, ParsedInterpolationExpression, ParsedInterpolationTemplate, ParsedInterpolationToken, ReplaceInterpolationTokensOptions, } from './utils/interpolation.js';
73
+ export { scanInterpolationTokenSpans } from './utils/interpolationSyntax.js';
72
74
  export { WarningsPort } from './utils/symbols.js';
73
75
  import * as openai from './utils/openai.js';
74
76
  export { openai };
@@ -11,5 +11,14 @@ export interface CodeRunnerOptions {
11
11
  includeRivet: boolean;
12
12
  includeProcess: boolean;
13
13
  includeConsole: boolean;
14
+ /**
15
+ * The collision-safe name of the narrow interpolation resolver injected for
16
+ * generated Code-family wrappers. Runners only add the resolver when this
17
+ * is present, so ordinary authored code keeps its established argument
18
+ * shape and capability cost. A runner that accepts this option must inject
19
+ * a resolver compatible with `resolveCodeInterpolationExpression`; paths
20
+ * and @graphInputs/@context references depend on that contract.
21
+ */
22
+ interpolationHelperIdentifier?: string;
14
23
  }
15
24
  export declare const ALL_CODE_RUNNER_OPTIONS: CodeRunnerOptions;
@@ -1,4 +1,5 @@
1
1
  import type { EditorDefinition } from '../../model/EditorDefinition.js';
2
+ import type { DataValue } from '../../model/DataValue.js';
2
3
  import type { Inputs } from '../../model/GraphProcessor.js';
3
4
  import type { ChartNode, NodeInputDefinition } from '../../model/NodeBase.js';
4
5
  import type { InternalProcessContext } from '../../model/ProcessContext.js';
@@ -38,4 +39,5 @@ export declare function getMCPServerEditors<T extends ChartNode<string, MCPBaseN
38
39
  export declare function getMCPBaseBody(data: MCPBaseNodeData, context: RivetUIContext): string;
39
40
  export declare function requireMCPProvider(context: InternalProcessContext): MCPProvider;
40
41
  export declare function resolveMCPServer(data: MCPBaseNodeData, inputs: Inputs, context: InternalProcessContext): Promise<MCPResolvedServer | undefined>;
41
- export declare function interpolateMCPArgumentTemplate(template: string, inputs: Inputs): string;
42
+ export declare function interpolateMCPArgumentTemplate(template: string, inputs: Inputs, graphInputValues?: Record<string, DataValue>, contextValues?: Record<string, DataValue>): string;
43
+ export declare function getMCPArgumentTemplateInputs(template: string | undefined): NodeInputDefinition[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Narrow runtime entrypoint for JavaScript executors. Build tooling can bundle
3
+ * this module into isolated workers without exposing the complete Core API.
4
+ */
5
+ export { resolveCodeInterpolationExpression } from './utils/interpolation.js';
@@ -4,7 +4,6 @@ import type { NodeId, NodeInputDefinition, NodeOutputDefinition, PortId } from '
4
4
  import type { GraphId, NodeGraph } from './NodeGraph.js';
5
5
  import type { Project } from './Project.js';
6
6
  import type { DynamicEditorEditor } from './EditorDefinition.js';
7
- export declare const GRAPH_BOUNDARY_OUTPUT_DEMAND_OPTIMIZATION_ENABLED = false;
8
7
  export type GraphBoundaryInput = {
9
8
  dataType: DataType;
10
9
  editor?: DynamicEditorEditor;
@@ -30,4 +29,3 @@ export declare function getGraphBoundaryInputDefinitions(boundary: GraphBoundary
30
29
  export declare function getGraphBoundaryOutputDefinitions(boundary: GraphBoundary, outputPortOrder?: readonly string[]): NodeOutputDefinition[];
31
30
  export declare function buildGraphBoundaryInputData(boundary: GraphBoundary, inputs: Inputs, defaults: Record<string, DataValue> | undefined): Inputs;
32
31
  export declare function buildExcludedGraphBoundaryOutputs(boundary: GraphBoundary): Outputs;
33
- export declare function getRequestedGraphOutputNodeIds(boundary: GraphBoundary, requestedOutputPortIds: ReadonlySet<PortId>): NodeId[];
@@ -0,0 +1,8 @@
1
+ import type { ChartNode, NodeId } from './NodeBase.js';
2
+ import type { NodeGraph } from './NodeGraph.js';
3
+ export type GraphOutputSelection = {
4
+ startNodes: ChartNode[];
5
+ nodeIds: ReadonlySet<NodeId>;
6
+ };
7
+ /** Invocation-local selection over compiled topology, never a mutation of the reusable graph plan. */
8
+ export declare function createGraphOutputSelection(graph: Pick<NodeGraph, 'nodes' | 'connections'>, requestedOutputIds: readonly string[], getInputNodes: (node: ChartNode) => readonly ChartNode[]): GraphOutputSelection;
@@ -298,10 +298,11 @@ export declare class GraphProcessor {
298
298
  /** Inputs to the main graph. You should pass all inputs required by the GraphInputNodes of the graph. */
299
299
  inputs?: Record<string, DataValue>,
300
300
  /** Contextual data available to all graphs and subgraphs. Kind of like react context, avoids drilling down data into subgraphs. Be careful when using it. */
301
- contextValues?: Record<string, DataValue>,
302
- /** Allows callers such as web apps to receive root outputs while managed async branches continue settling. */
303
- options?: {
301
+ contextValues?: Record<string, DataValue>, options?: {
302
+ /** Allows web apps to receive root outputs while managed async branches continue settling. */
304
303
  returnWhenGraphOutputsReady?: boolean;
304
+ /** Restrict this invocation to named graph outputs and their prerequisites. Cannot be combined with runToNodeIds. */
305
+ requestedGraphOutputIds?: readonly string[];
305
306
  }): Promise<GraphOutputs>;
306
307
  getRootProcessor(): GraphProcessor;
307
308
  /** Raise a user event on the processor, all subprocessors, and their children. */
@@ -310,14 +310,15 @@ export type InternalProcessContext<T extends ChartNode = ChartNode> = ProcessCon
310
310
  getGlobal: (id: string) => ScalarOrArrayDataValue | undefined;
311
311
  /** Like context, but variables that are set during the run of the graph and can be read during the graph. Shared among all graphs and subgraphs. */
312
312
  setGlobal: (id: string, value: ScalarOrArrayDataValue) => void;
313
- waitForGlobal: (id: string) => Promise<ScalarOrArrayDataValue>;
313
+ /** Waits for a global value; by default the current node's cancellation stops the wait. */
314
+ waitForGlobal: (id: string, signal?: AbortSignal) => Promise<ScalarOrArrayDataValue>;
314
315
  /** Reads through the root run's stored-value cache and optional persistence store. */
315
316
  getStoredValue: (key: string) => Promise<RivetStoredValueReadResult>;
316
317
  /** Returns only the current root run's synchronous stored-value cache state. */
317
318
  getCachedStoredValue: (key: string) => RivetStoredValueCacheResult;
318
319
  /** Writes through the root run's cache and optional persistence store. */
319
320
  setStoredValue: (key: string, value: RivetStoredValue) => Promise<RivetStoredValueSetResult>;
320
- /** Waits only for a successful Set Stored Value in this root run. */
321
+ /** Waits only for a successful Set Stored Value in this root run; defaults to the current node's abort signal. */
321
322
  waitForStoredValue: (key: string, signal?: AbortSignal) => Promise<RivetStoredValue>;
322
323
  /** Resolves a named project or host-provided knowledge store for this execution. */
323
324
  getKnowledgeStore: (connectionId: KnowledgeStoreConnectionId) => Promise<RivetKnowledgeStore>;
@@ -13,7 +13,7 @@ export declare class ObjectNodeImpl extends NodeImpl<ObjectNode> {
13
13
  getOutputDefinitions(): NodeOutputDefinition[];
14
14
  getEditors(): EditorDefinition<ObjectNode>[];
15
15
  static getUIData(): NodeUIData;
16
- interpolate(baseString: string, values: Record<string, any>, graphInputNodeValues?: Record<string, DataValue>, contextValues?: Record<string, DataValue>): string;
16
+ interpolate(baseString: string, values: Record<string, unknown>, graphInputNodeValues?: Record<string, DataValue>, contextValues?: Record<string, DataValue>): string;
17
17
  process(inputs: Record<string, DataValue>, context: InternalProcessContext): Promise<Record<string, DataValue>>;
18
18
  }
19
19
  export declare const objectNode: import("../NodeDefinition.js").NodeDefinition<ObjectNode>;
@@ -13,6 +13,8 @@ export type SubGraphNode = ChartNode & {
13
13
  graphId: GraphId;
14
14
  useErrorOutput?: boolean;
15
15
  useAsGraphPartialOutput?: boolean;
16
+ /** Only execute child branches needed by actively connected output ports. */
17
+ skipUnusedOutputs?: boolean;
16
18
  /** Data for each of the inputs of the subgraph */
17
19
  inputData?: Record<string, DataValue>;
18
20
  inputPortOrder?: string[];
@@ -2,12 +2,14 @@ import { type ChartNode, type NodeInputDefinition, type PortId, type NodeOutputD
2
2
  import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
3
3
  import { type DataValue } from '../DataValue.js';
4
4
  import { type EditorDefinition } from '../EditorDefinition.js';
5
+ import type { InternalProcessContext } from '../ProcessContext.js';
5
6
  export type ToTreeNode = ChartNode<'toTree', ToTreeNodeData>;
6
7
  export type ToTreeNodeData = {
7
8
  format: string;
8
9
  childrenProperty: string;
9
10
  useSortAlphabetically: boolean;
10
11
  };
12
+ type ToTreeInterpolationContext = Pick<InternalProcessContext, 'graphInputNodeValues' | 'contextValues'>;
11
13
  export declare class ToTreeNodeImpl extends NodeImpl<ToTreeNode> {
12
14
  static create(): ToTreeNode;
13
15
  getInputDefinitions(): NodeInputDefinition[];
@@ -15,7 +17,8 @@ export declare class ToTreeNodeImpl extends NodeImpl<ToTreeNode> {
15
17
  getEditors(): EditorDefinition<ToTreeNode>[];
16
18
  getBody(): string;
17
19
  static getUIData(): NodeUIData;
18
- buildTree(objects: unknown[], parentPath?: string, level?: number, isLast?: boolean): string;
19
- process(inputs: Record<PortId, DataValue>): Promise<Record<PortId, DataValue>>;
20
+ buildTree(objects: unknown[], parentPath?: string, level?: number, isLast?: boolean, interpolationContext?: ToTreeInterpolationContext): string;
21
+ process(inputs: Record<PortId, DataValue>, context?: InternalProcessContext): Promise<Record<PortId, DataValue>>;
20
22
  }
21
23
  export declare const toTreeNode: import("../NodeDefinition.js").NodeDefinition<ToTreeNode>;
24
+ export {};
@@ -3,6 +3,7 @@ import { NodeImpl, type NodeRunActivityDescriptor, type NodeUIData } from '../No
3
3
  import { type EditorDefinition } from '../EditorDefinition.js';
4
4
  import { type NodeBodySpec } from '../NodeBodySpec.js';
5
5
  import type { Inputs, Outputs } from '../GraphProcessor.js';
6
+ import type { InternalProcessContext } from '../ProcessContext.js';
6
7
  import type { GptFunctionResultHandling } from '../DataValue.js';
7
8
  export type GptFunctionNode = ChartNode<'gptFunction', GptFunctionNodeData>;
8
9
  export type GptFunctionNodeData = {
@@ -15,6 +16,17 @@ export type GptFunctionNodeData = {
15
16
  useSchemaInput?: boolean;
16
17
  strict?: boolean;
17
18
  };
19
+ export type ToolNodeBodyPreview = Readonly<{
20
+ name: string;
21
+ description: string;
22
+ }>;
23
+ /**
24
+ * Splits Tool's bounded canvas preview into its label/value row and its text body.
25
+ *
26
+ * The combined source preview deliberately uses one fewer line than Text to
27
+ * compensate for the custom header's visual separator.
28
+ */
29
+ export declare function getToolNodeBodyPreview(data: Pick<GptFunctionNodeData, 'name' | 'description'>): ToolNodeBodyPreview;
18
30
  export declare class GptFunctionNodeImpl extends NodeImpl<GptFunctionNode> {
19
31
  static create(): GptFunctionNode;
20
32
  getInputDefinitions(): NodeInputDefinition[];
@@ -23,6 +35,6 @@ export declare class GptFunctionNodeImpl extends NodeImpl<GptFunctionNode> {
23
35
  getEditors(): EditorDefinition<GptFunctionNode>[];
24
36
  getBody(): string | NodeBodySpec | undefined;
25
37
  static getUIData(): NodeUIData;
26
- process(inputs: Inputs): Promise<Outputs>;
38
+ process(inputs: Inputs, context?: InternalProcessContext): Promise<Outputs>;
27
39
  }
28
40
  export declare const gptFunctionNode: import("../NodeDefinition.js").NodeDefinition<GptFunctionNode>;
@@ -1,5 +1,6 @@
1
1
  import type { Inputs } from '../GraphProcessor.js';
2
2
  import type { NodeInputDefinition } from '../NodeBase.js';
3
+ import type { CodeRunnerOptions } from '../../integrations/CodeRunnerOptions.js';
3
4
  type JsValueInterpolationOptions = {
4
5
  localIdentifiers?: ReadonlySet<string>;
5
6
  trim?: boolean;
@@ -7,25 +8,32 @@ type JsValueInterpolationOptions = {
7
8
  export type JsValueInterpolationRuntimeContext = {
8
9
  inputNames: string[];
9
10
  inputsIdentifier: string;
11
+ interpolationHelperIdentifier: string;
12
+ cloneCacheIdentifier: string;
13
+ graphInputsIdentifier: string;
14
+ contextIdentifier: string;
15
+ /** True when generated source needs a runner-provided path/special resolver. */
16
+ requiresInterpolationHelper: boolean;
10
17
  };
11
18
  export declare function getSafeJsValueInterpolationIdentifier(source: string, baseIdentifier: string): string;
12
19
  export declare function buildJsValuePreview(source: string, maxLines: number): string;
13
20
  export declare function getJsValueInterpolationInputNames(template: string, options?: JsValueInterpolationOptions): string[];
14
21
  export declare function getJsValueInterpolationInputDefinitions(template: string, options?: JsValueInterpolationOptions): NodeInputDefinition[];
15
22
  export declare function getJsValueInterpolationRuntimeContext(template: string, baseInputsIdentifier: string, options?: JsValueInterpolationOptions): JsValueInterpolationRuntimeContext;
16
- export declare function buildJsValueInterpolatedSource(template: string, targetIdentifier: string, options?: JsValueInterpolationOptions): string;
23
+ export declare function buildJsValueInterpolatedSource(template: string, interpolationContext: JsValueInterpolationRuntimeContext, options?: JsValueInterpolationOptions): string;
17
24
  export declare function interpolateJsValuePreviewSource(template: string, inputs: Inputs, options?: JsValueInterpolationOptions): string;
18
25
  export declare function buildCloneJsInputValueFunction(): string;
19
26
  export declare function buildClonedInputValueAssignments(inputNames: string[], targetIdentifier: string, cacheIdentifier: string): string;
20
- export declare function buildJsValueInputClonePreamble({ cacheIdentifier, inputsIdentifier, }: {
27
+ export declare function buildJsValueInputClonePreamble({ cacheIdentifier, contextIdentifier, graphInputsIdentifier, inputsIdentifier, }: {
21
28
  cacheIdentifier: string;
29
+ contextIdentifier: string;
30
+ graphInputsIdentifier: string;
22
31
  inputsIdentifier: string;
23
32
  }): string;
24
- export declare function buildJsValueInputsInitializer({ cacheIdentifier, inputNames, inputsIdentifier, }: {
25
- cacheIdentifier: string;
26
- inputNames: string[];
27
- inputsIdentifier: string;
33
+ export declare function buildJsValueInputsInitializer({ interpolationContext, }: {
34
+ interpolationContext: JsValueInterpolationRuntimeContext;
28
35
  }): string;
29
- export declare function sanitizeGeneratedJsValueText(text: string | undefined, inputNames: string[], targetIdentifier: string, fallbackLabel: string): string | undefined;
30
- export declare function sanitizeGeneratedJsValueError(error: unknown, inputNames: string[], targetIdentifier: string, fallbackLabel: string): Error;
36
+ export declare function getJsValueInterpolationCodeRunnerOptions(options: CodeRunnerOptions, interpolationContext: JsValueInterpolationRuntimeContext): CodeRunnerOptions;
37
+ export declare function sanitizeGeneratedJsValueText(text: string | undefined, inputNames: string[], targetIdentifier: string, fallbackLabel: string, generatedIdentifiers?: readonly string[]): string | undefined;
38
+ export declare function sanitizeGeneratedJsValueError(error: unknown, inputNames: string[], targetIdentifier: string, fallbackLabel: string, generatedIdentifiers?: readonly string[]): Error;
31
39
  export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Bounds node-card previews without changing the full value persisted in node data.
3
+ *
4
+ * The limits are intentionally shared by text-like node bodies so one long field
5
+ * cannot make its canvas card taller than the familiar Text-node preview.
6
+ */
7
+ export declare function buildNodeBodyPreview(text: string, maximumLines?: number): string;
@@ -17,3 +17,5 @@ export * from './runtimeLogging.js';
17
17
  export * from './providerStreamParsing.js';
18
18
  export * from './projectComparison.js';
19
19
  export * from './jsonValueToDataValue.js';
20
+ export * from './jsonPath.js';
21
+ export * from './interpolationSyntax.js';