@valerypopoff/rivet2-core 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bundle.cjs +1430 -669
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/interpolationRuntime.cjs +1578 -0
- package/dist/cjs/interpolationRuntime.cjs.map +7 -0
- package/dist/cjs/interpolationSyntax.cjs +186 -0
- package/dist/cjs/interpolationSyntax.cjs.map +7 -0
- package/dist/cjs/webAppRuntime.cjs.map +2 -2
- package/dist/esm/exports.js +2 -1
- package/dist/esm/integrations/CodeRunner.js +5 -0
- package/dist/esm/integrations/mcp/MCPBase.js +16 -6
- package/dist/esm/interpolationRuntime.js +5 -0
- package/dist/esm/model/GraphBoundaryCache.js +0 -6
- package/dist/esm/model/GraphBoundaryEffects.js +5 -1
- package/dist/esm/model/GraphOutputSelection.js +34 -0
- package/dist/esm/model/GraphProcessor.js +136 -44
- package/dist/esm/model/ProcessContextBuilder.js +2 -0
- package/dist/esm/model/RecordingPlayer.js +11 -6
- package/dist/esm/model/StoredValueStore.js +4 -3
- package/dist/esm/model/nodes/CodeNewNode.js +16 -16
- package/dist/esm/model/nodes/DestructureNode.js +2 -2
- package/dist/esm/model/nodes/ExpressionNode.js +16 -16
- package/dist/esm/model/nodes/ExtractObjectPathNode.js +2 -2
- package/dist/esm/model/nodes/ExtractYamlNode.js +5 -5
- package/dist/esm/model/nodes/JSFilterNode.js +3 -1
- package/dist/esm/model/nodes/JSMapNode.js +3 -1
- package/dist/esm/model/nodes/MCPGetPromptNode.js +6 -2
- package/dist/esm/model/nodes/MCPToolCallNode.js +6 -2
- package/dist/esm/model/nodes/ObjectNode.js +19 -20
- package/dist/esm/model/nodes/PromptNode.js +10 -11
- package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +2 -40
- package/dist/esm/model/nodes/SubGraphNode.js +40 -26
- package/dist/esm/model/nodes/TextNode.js +11 -32
- package/dist/esm/model/nodes/ToTreeNode.js +6 -13
- package/dist/esm/model/nodes/ToolNode.js +33 -16
- package/dist/esm/model/nodes/jsListCallbackHelpers.js +19 -15
- package/dist/esm/model/nodes/jsValueInterpolation.js +83 -30
- package/dist/esm/model/nodes/nodeBodyPreview.js +23 -0
- package/dist/esm/plugins/openai/nodes/ThreadMessageNode.js +14 -11
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/interpolation.js +478 -221
- package/dist/esm/utils/interpolationSyntax.js +175 -0
- package/dist/esm/utils/jsonPath.js +129 -0
- package/dist/types/exports.d.ts +3 -1
- package/dist/types/integrations/CodeRunnerOptions.d.ts +9 -0
- package/dist/types/integrations/mcp/MCPBase.d.ts +3 -1
- package/dist/types/interpolationRuntime.d.ts +5 -0
- package/dist/types/model/GraphBoundaryCache.d.ts +0 -2
- package/dist/types/model/GraphOutputSelection.d.ts +8 -0
- package/dist/types/model/GraphProcessor.d.ts +4 -3
- package/dist/types/model/ProcessContext.d.ts +3 -2
- package/dist/types/model/nodes/ObjectNode.d.ts +1 -1
- package/dist/types/model/nodes/SubGraphNode.d.ts +2 -0
- package/dist/types/model/nodes/ToTreeNode.d.ts +5 -2
- package/dist/types/model/nodes/ToolNode.d.ts +13 -1
- package/dist/types/model/nodes/jsValueInterpolation.d.ts +16 -8
- package/dist/types/model/nodes/nodeBodyPreview.d.ts +7 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/interpolation.d.ts +93 -8
- package/dist/types/utils/interpolationSyntax.d.ts +21 -0
- package/dist/types/utils/jsonPath.d.ts +15 -0
- package/package.json +11 -1
|
@@ -1,26 +1,111 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DataValue } from '../model/DataValue.js';
|
|
2
|
+
import { type InterpolationTokenSpan } from './interpolationSyntax.js';
|
|
2
3
|
export declare const ESCAPED_TOKEN_REGEX: RegExp;
|
|
3
4
|
export declare const ESCAPED_ESCAPED_TOKEN_REGEX: RegExp;
|
|
4
|
-
export type InterpolationTokenSpan
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export type { InterpolationTokenSpan } from './interpolationSyntax.js';
|
|
6
|
+
export type InterpolationReferenceSource = 'variable' | 'graphInputs' | 'context';
|
|
7
|
+
/** A base value and, optionally, a JSONPath evaluated against that value. */
|
|
8
|
+
export type ParsedInterpolationExpression = {
|
|
9
|
+
source: InterpolationReferenceSource;
|
|
10
|
+
baseName: string;
|
|
11
|
+
/** A JSONPath beginning with `$`, evaluated with `wrap: false`. */
|
|
12
|
+
jsonPath: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type ParsedInterpolationToken = {
|
|
15
|
+
span: InterpolationTokenSpan;
|
|
7
16
|
rawInner: string;
|
|
17
|
+
/** The interpolation expression before its optional processor chain. */
|
|
18
|
+
tokenName: string | undefined;
|
|
19
|
+
processingChain: string | undefined;
|
|
20
|
+
reference: ParsedInterpolationExpression | undefined;
|
|
21
|
+
};
|
|
22
|
+
export type ParsedInterpolationTemplate = {
|
|
23
|
+
template: string;
|
|
24
|
+
tokens: readonly ParsedInterpolationToken[];
|
|
25
|
+
};
|
|
26
|
+
export type InterpolationVariableReference = {
|
|
27
|
+
baseName: string;
|
|
28
|
+
/** True when any occurrence of this input navigates into its value with JSONPath. */
|
|
29
|
+
hasPath: boolean;
|
|
8
30
|
};
|
|
9
31
|
export type InterpolationTokenReplacementInfo = {
|
|
10
32
|
rawInner: string;
|
|
11
33
|
span: InterpolationTokenSpan;
|
|
12
34
|
tokenName: string | undefined;
|
|
35
|
+
processingChain: string | undefined;
|
|
36
|
+
reference: ParsedInterpolationExpression | undefined;
|
|
13
37
|
};
|
|
14
38
|
export type ReplaceInterpolationTokensOptions = {
|
|
15
39
|
trim?: boolean;
|
|
16
40
|
};
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
41
|
+
export type InterpolateOptions = {
|
|
42
|
+
/** Set false when ordinary interpolation variables are raw JSON. */
|
|
43
|
+
unwrapVariableDataValues?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Use the historical text-template DataValue coercion for bare ordinary
|
|
46
|
+
* variables. Paths still select raw JSON and use JSON serialization.
|
|
47
|
+
*/
|
|
48
|
+
coerceBareVariableDataValues?: boolean;
|
|
49
|
+
};
|
|
50
|
+
export type InterpolationValueSources = {
|
|
51
|
+
variables?: Record<string, unknown>;
|
|
52
|
+
graphInputValues?: Record<string, unknown>;
|
|
53
|
+
contextValues?: Record<string, unknown>;
|
|
54
|
+
/** Set false when `variables` are already raw JSON rather than DataValues. */
|
|
55
|
+
unwrapVariableDataValues?: boolean;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Unwrap a Rivet DataValue at an interpolation source boundary. Callers must
|
|
59
|
+
* not recursively apply this to selected JSON properties: an ordinary object
|
|
60
|
+
* inside the value may legitimately have `type` and `value` properties.
|
|
61
|
+
*/
|
|
62
|
+
export declare function unwrapPotentialDataValue(value: unknown): unknown;
|
|
63
|
+
/**
|
|
64
|
+
* Renders a whole interpolation input with the legacy generic interpolation
|
|
65
|
+
* behavior. Text-oriented callers can opt into DataValue string coercion.
|
|
66
|
+
*/
|
|
67
|
+
export declare function stringifyInterpolationSourceValue(value: unknown, { coerceDataValueToString, unwrapDataValue, }?: {
|
|
68
|
+
coerceDataValueToString?: boolean;
|
|
69
|
+
unwrapDataValue?: boolean;
|
|
70
|
+
}): string;
|
|
71
|
+
/**
|
|
72
|
+
* Parses a public interpolation expression. Return a fresh record so callers
|
|
73
|
+
* can safely mutate it without corrupting the internal syntax cache.
|
|
74
|
+
*/
|
|
75
|
+
export declare function parseInterpolationExpression(expression: string): ParsedInterpolationExpression | undefined;
|
|
76
|
+
/** Splits an interpolation token into its expression, processor chain, and parsed reference. */
|
|
77
|
+
export declare function parseInterpolationToken(rawInner: string): Omit<ParsedInterpolationToken, 'span'>;
|
|
78
|
+
/** Returns an immutable, cached syntax representation. It never evaluates values. */
|
|
79
|
+
export declare function parseInterpolationTemplate(template: string): ParsedInterpolationTemplate;
|
|
20
80
|
export declare function protectEscapedInterpolationTokens(template: string): string;
|
|
21
81
|
export declare function restoreEscapedInterpolationTokens(template: string): string;
|
|
22
82
|
export declare function findInterpolationTokenSpans(template: string): InterpolationTokenSpan[];
|
|
83
|
+
/** Returns the pre-processor expression, retaining its authored path syntax. */
|
|
23
84
|
export declare function getInterpolationTokenName(rawInner: string): string | undefined;
|
|
85
|
+
export declare function getInterpolationTokenReference(rawInner: string): ParsedInterpolationExpression | undefined;
|
|
24
86
|
export declare function replaceInterpolationTokens(template: string, getReplacement: (token: InterpolationTokenReplacementInfo) => string, options?: ReplaceInterpolationTokensOptions): string;
|
|
25
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Discovers connectable interpolation bases in first-occurrence order. Special
|
|
89
|
+
* graph/context references are intentionally omitted because they do not make ports.
|
|
90
|
+
*/
|
|
91
|
+
export declare function extractInterpolationVariableReferences(template: string): InterpolationVariableReference[];
|
|
92
|
+
/** Extracts base port names only. Prefer `extractInterpolationVariableReferences` when type selection matters. */
|
|
26
93
|
export declare function extractInterpolationVariables(template: string): string[];
|
|
94
|
+
/**
|
|
95
|
+
* Resolves one parsed interpolation expression from raw values. JSONPath uses
|
|
96
|
+
* `wrap: false`, matching Destructure exactly; callers decide how to render a
|
|
97
|
+
* missing value or a selected object.
|
|
98
|
+
*/
|
|
99
|
+
export declare function resolveInterpolationExpressionRawValue(expression: string | ParsedInterpolationExpression, sources: InterpolationValueSources): unknown | undefined;
|
|
100
|
+
export declare function resolveInterpolationTokenRawValue(rawInner: string, sources: InterpolationValueSources): unknown | undefined;
|
|
101
|
+
/** Backward-compatible special-reference resolver used by existing nodes. */
|
|
102
|
+
export declare function resolveExpressionRawValue(source: Record<string, unknown> | undefined, expression: string, sourceType: 'graphInputs' | 'context'): unknown | undefined;
|
|
103
|
+
export declare function resolveExpressionToString(source: Record<string, unknown> | undefined, expression: string, sourceType: 'graphInputs' | 'context'): string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Resolves text interpolation. Bare ordinary variables keep the historical
|
|
106
|
+
* string coercion; path-bearing references select raw data first and serialize
|
|
107
|
+
* selected objects/arrays as JSON.
|
|
108
|
+
*/
|
|
109
|
+
export declare function interpolate(template: string, variables: Record<string, unknown>, graphInputValues?: Record<string, DataValue>, contextValues?: Record<string, DataValue>, options?: InterpolateOptions): string;
|
|
110
|
+
/** Runtime helper injected into JavaScript runners without exposing the whole Rivet API. */
|
|
111
|
+
export declare function resolveCodeInterpolationExpression(inputs: Record<string, DataValue | undefined>, expression: string, graphInputValues?: Record<string, DataValue>, contextValues?: Record<string, DataValue>): unknown | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type InterpolationTokenSpan = {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
rawInner: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function isInterpolationSyntaxCharacterEscaped(value: string, index: number): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* JSONPath filters can contain JavaScript regex literals. Treat their contents
|
|
9
|
+
* as opaque while looking for an interpolation terminator or processor pipe;
|
|
10
|
+
* otherwise a `]` or `|` inside the regex can be mistaken for JSONPath syntax.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isInterpolationRegexLiteralStart(value: string, index: number): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Scans token boundaries without parsing expressions or resolving values.
|
|
15
|
+
*
|
|
16
|
+
* This deliberately has no evaluator dependencies, so editor-only surfaces
|
|
17
|
+
* can share Core's malformed-token recovery rules without loading JSONPath or
|
|
18
|
+
* the rest of the execution runtime. The returned spans are fresh data and
|
|
19
|
+
* exclude escaped triple-brace tokens.
|
|
20
|
+
*/
|
|
21
|
+
export declare function scanInterpolationTokenSpans(template: string): InterpolationTokenSpan[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes Rivet's historically accepted convenience whitespace around
|
|
3
|
+
* JSONPath structural separators. Quoted values, regular expressions, filter
|
|
4
|
+
* expressions, and object literals keep their authored contents unchanged.
|
|
5
|
+
*
|
|
6
|
+
* All runtime JSONPath consumers must pass through this helper so stored node
|
|
7
|
+
* paths and interpolation suffixes accept the same path language.
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeJsonPathExpression(path: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Evaluates a JSONPath expression with the same engine and options used by the
|
|
12
|
+
* object-path nodes. Callers retain ownership of their no-match and error
|
|
13
|
+
* policy; this helper deliberately lets JSONPath errors propagate.
|
|
14
|
+
*/
|
|
15
|
+
export declare function evaluateJsonPath<T = unknown>(value: unknown, path: string, wrap?: boolean): T | T[] | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valerypopoff/rivet2-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/cjs/bundle.cjs",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -28,6 +28,16 @@
|
|
|
28
28
|
"types": "./dist/types/webAppRuntime.d.ts",
|
|
29
29
|
"import": "./dist/esm/webAppRuntime.js",
|
|
30
30
|
"require": "./dist/cjs/webAppRuntime.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./interpolation-runtime": {
|
|
33
|
+
"types": "./dist/types/interpolationRuntime.d.ts",
|
|
34
|
+
"import": "./dist/esm/interpolationRuntime.js",
|
|
35
|
+
"require": "./dist/cjs/interpolationRuntime.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./interpolation-syntax": {
|
|
38
|
+
"types": "./dist/types/utils/interpolationSyntax.d.ts",
|
|
39
|
+
"import": "./dist/esm/utils/interpolationSyntax.js",
|
|
40
|
+
"require": "./dist/cjs/interpolationSyntax.cjs"
|
|
31
41
|
}
|
|
32
42
|
},
|
|
33
43
|
"files": [
|