@valerypopoff/rivet2-core 2.3.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 (105) hide show
  1. package/dist/cjs/bundle.cjs +1947 -765
  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 +1537 -121
  8. package/dist/cjs/webAppRuntime.cjs.map +4 -4
  9. package/dist/esm/api/createProcessor.js +2 -0
  10. package/dist/esm/exports.js +4 -1
  11. package/dist/esm/integrations/CodeRunner.js +5 -0
  12. package/dist/esm/integrations/mcp/MCPBase.js +16 -6
  13. package/dist/esm/interpolationRuntime.js +5 -0
  14. package/dist/esm/model/AgentResponseTrace.js +16 -0
  15. package/dist/esm/model/GraphBoundaryCache.js +0 -6
  16. package/dist/esm/model/GraphBoundaryEffects.js +5 -1
  17. package/dist/esm/model/GraphOutputSelection.js +34 -0
  18. package/dist/esm/model/GraphProcessor.js +150 -44
  19. package/dist/esm/model/NodeExclusionPolicy.js +9 -1
  20. package/dist/esm/model/ProcessContextBuilder.js +4 -1
  21. package/dist/esm/model/RecordingPlayer.js +19 -6
  22. package/dist/esm/model/StoredValueStore.js +4 -3
  23. package/dist/esm/model/SubprocessorBridge.js +1 -0
  24. package/dist/esm/model/UiGraphActionProtocol.js +46 -4
  25. package/dist/esm/model/UiGraphBrowserRuntime.js +15 -1
  26. package/dist/esm/model/UiGraphIndexedDbPersistence.js +523 -0
  27. package/dist/esm/model/UiGraphRendererStyles.js +14 -0
  28. package/dist/esm/model/WebAppBrowserStorage.js +653 -0
  29. package/dist/esm/model/WebAppBrowserStorageRpc.js +200 -0
  30. package/dist/esm/model/chat-v2/chatV2CallObserver.js +1 -0
  31. package/dist/esm/model/chat-v2/chatV2EditorCache.js +2 -33
  32. package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +1 -0
  33. package/dist/esm/model/chat-v2/llmChatV2OutputClone.js +42 -0
  34. package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +31 -2
  35. package/dist/esm/model/chat-v2/llmProfile.js +17 -1
  36. package/dist/esm/model/chat-v2/llmProfileFallback.js +17 -5
  37. package/dist/esm/model/chat-v2/llmProfileHealthStore.js +2 -0
  38. package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +4 -0
  39. package/dist/esm/model/chat-v2/toolContinuation.js +27 -1
  40. package/dist/esm/model/nodes/CodeNewNode.js +16 -16
  41. package/dist/esm/model/nodes/DestructureNode.js +2 -2
  42. package/dist/esm/model/nodes/ExpressionNode.js +16 -16
  43. package/dist/esm/model/nodes/ExtractObjectPathNode.js +2 -2
  44. package/dist/esm/model/nodes/ExtractYamlNode.js +5 -5
  45. package/dist/esm/model/nodes/JSFilterNode.js +3 -1
  46. package/dist/esm/model/nodes/JSMapNode.js +3 -1
  47. package/dist/esm/model/nodes/LLMChatV2Node.js +21 -2
  48. package/dist/esm/model/nodes/MCPGetPromptNode.js +6 -2
  49. package/dist/esm/model/nodes/MCPToolCallNode.js +6 -2
  50. package/dist/esm/model/nodes/ObjectNode.js +19 -20
  51. package/dist/esm/model/nodes/PromptNode.js +10 -11
  52. package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +2 -40
  53. package/dist/esm/model/nodes/SubGraphNode.js +40 -26
  54. package/dist/esm/model/nodes/TextNode.js +11 -32
  55. package/dist/esm/model/nodes/ToTreeNode.js +6 -13
  56. package/dist/esm/model/nodes/ToolNode.js +33 -16
  57. package/dist/esm/model/nodes/jsListCallbackHelpers.js +19 -15
  58. package/dist/esm/model/nodes/jsValueInterpolation.js +83 -30
  59. package/dist/esm/model/nodes/nodeBodyPreview.js +23 -0
  60. package/dist/esm/plugins/openai/nodes/ThreadMessageNode.js +14 -11
  61. package/dist/esm/recording/ExecutionRecorder.js +1 -0
  62. package/dist/esm/utils/index.js +2 -0
  63. package/dist/esm/utils/interpolation.js +478 -221
  64. package/dist/esm/utils/interpolationSyntax.js +175 -0
  65. package/dist/esm/utils/jsonPath.js +129 -0
  66. package/dist/esm/webAppRuntime.js +5 -2
  67. package/dist/types/api/createProcessor.d.ts +2 -0
  68. package/dist/types/exports.d.ts +5 -1
  69. package/dist/types/integrations/CodeRunnerOptions.d.ts +9 -0
  70. package/dist/types/integrations/mcp/MCPBase.d.ts +3 -1
  71. package/dist/types/interpolationRuntime.d.ts +5 -0
  72. package/dist/types/model/AgentResponseTrace.d.ts +1 -0
  73. package/dist/types/model/ExecutorProtocol.d.ts +9 -1
  74. package/dist/types/model/GraphBoundaryCache.d.ts +0 -2
  75. package/dist/types/model/GraphOutputSelection.d.ts +8 -0
  76. package/dist/types/model/GraphProcessor.d.ts +7 -4
  77. package/dist/types/model/NodeExclusionPolicy.d.ts +6 -0
  78. package/dist/types/model/ProcessContext.d.ts +36 -2
  79. package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
  80. package/dist/types/model/UiGraphActionProtocol.d.ts +8 -3
  81. package/dist/types/model/UiGraphBrowserRuntime.d.ts +6 -0
  82. package/dist/types/model/UiGraphIndexedDbPersistence.d.ts +50 -0
  83. package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
  84. package/dist/types/model/WebAppBrowserStorage.d.ts +90 -0
  85. package/dist/types/model/WebAppBrowserStorageRpc.d.ts +85 -0
  86. package/dist/types/model/chat-v2/chatV2Types.d.ts +3 -1
  87. package/dist/types/model/chat-v2/llmChatV2OutputClone.d.ts +3 -0
  88. package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +5 -1
  89. package/dist/types/model/chat-v2/llmProfileFallback.d.ts +4 -0
  90. package/dist/types/model/chat-v2/llmProfileHealthStore.d.ts +10 -0
  91. package/dist/types/model/chat-v2/llmProfileTypes.d.ts +6 -0
  92. package/dist/types/model/chat-v2/toolContinuation.d.ts +14 -0
  93. package/dist/types/model/nodes/ObjectNode.d.ts +1 -1
  94. package/dist/types/model/nodes/SubGraphNode.d.ts +2 -0
  95. package/dist/types/model/nodes/ToTreeNode.d.ts +5 -2
  96. package/dist/types/model/nodes/ToolNode.d.ts +13 -1
  97. package/dist/types/model/nodes/jsValueInterpolation.d.ts +16 -8
  98. package/dist/types/model/nodes/nodeBodyPreview.d.ts +7 -0
  99. package/dist/types/recording/RecordedEvents.d.ts +11 -0
  100. package/dist/types/utils/index.d.ts +2 -0
  101. package/dist/types/utils/interpolation.d.ts +93 -8
  102. package/dist/types/utils/interpolationSyntax.d.ts +21 -0
  103. package/dist/types/utils/jsonPath.d.ts +15 -0
  104. package/dist/types/webAppRuntime.d.ts +8 -2
  105. package/package.json +11 -1
@@ -1,7 +1,15 @@
1
1
  import type { ChatMessageDataValue, GptFunction } from '../DataValue.js';
2
+ import type { Outputs } from '../GraphProcessor.js';
2
3
  import type { ChatV2PipelineResult, ChatV2PipelineRoundOptions } from './chatV2Types.js';
3
4
  import type { StreamedFunctionCall } from '../chat/streamChatResponse.js';
4
5
  import type { DelegatedToolCallRecord } from '../nodes/toolCallDelegation.js';
6
+ import type { LLMChatOutputSnapshotKind, LLMChatOutputSnapshotOutcome } from '../ProcessContext.js';
7
+ export type LLMChatOutputSnapshotDescriptor = {
8
+ entryId: string;
9
+ roundIndex: number;
10
+ kind: LLMChatOutputSnapshotKind;
11
+ outcome: LLMChatOutputSnapshotOutcome;
12
+ };
5
13
  export type ToolContinuationOptions = ChatV2PipelineRoundOptions & {
6
14
  autoContinue: boolean;
7
15
  maxToolRounds: number;
@@ -9,6 +17,12 @@ export type ToolContinuationOptions = ChatV2PipelineRoundOptions & {
9
17
  delegateToolCall: (toolCall: StreamedFunctionCall) => Promise<ToolContinuationToolResult>;
10
18
  delegateToolCallRound?: (toolCalls: StreamedFunctionCall[], preToolMessage: string) => Promise<ToolContinuationToolResult[]>;
11
19
  runPipeline: (options: ChatV2PipelineRoundOptions) => Promise<ChatV2PipelineResult>;
20
+ /** Emits an immutable completed model page before its delegated tools run. */
21
+ onCompletedModelRound?: (snapshot: LLMChatOutputSnapshotDescriptor & {
22
+ outputs: Outputs;
23
+ }) => void;
24
+ /** Describes the terminal page; the node emits it after terminal projection. */
25
+ onTerminalRound?: (snapshot: LLMChatOutputSnapshotDescriptor) => void;
12
26
  };
13
27
  export type ToolContinuationToolResult = ChatMessageDataValue & {
14
28
  delegatedToolCall?: DelegatedToolCallRecord;
@@ -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;
@@ -95,6 +95,17 @@ export type RecordedEventsMap = OverrideProperties<ProcessEvents, {
95
95
  processId: ProcessId;
96
96
  progress: ProcessEvents['progress']['progress'];
97
97
  }>;
98
+ /** Display-only output page for one completed logical LLM Chat round. */
99
+ llmChatOutputSnapshot: WithOptionalExecution<{
100
+ nodeId: NodeId;
101
+ processId: ProcessId;
102
+ entryId: string;
103
+ roundIndex: number;
104
+ splitIndex: number;
105
+ kind: ProcessEvents['llmChatOutputSnapshot']['kind'];
106
+ outcome: ProcessEvents['llmChatOutputSnapshot']['outcome'];
107
+ outputs: Outputs;
108
+ }>;
98
109
  /** Called when the outputs of a node have been cleared entirely. If processId is present, only the one process() should be cleared. */
99
110
  nodeOutputsCleared: WithOptionalExecution<{
100
111
  nodeId: NodeId;
@@ -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';
@@ -1,26 +1,111 @@
1
- import type { DataValue } from '../model/DataValue.js';
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
- start: number;
6
- end: number;
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 declare function unwrapPotentialDataValue(value: any): any;
18
- export declare function resolveExpressionRawValue(source: Record<string, any> | undefined, expression: string, sourceType: 'graphInputs' | 'context'): any | undefined;
19
- export declare function resolveExpressionToString(source: Record<string, any> | undefined, expression: string, sourceType: 'graphInputs' | 'context'): string | undefined;
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
- export declare function interpolate(template: string, variables: Record<string, DataValue | string | undefined>, graphInputValues?: Record<string, DataValue>, contextValues?: Record<string, DataValue>): string;
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;
@@ -4,9 +4,15 @@ export type { RivetWebAppClientMessage, RivetWebAppRunEvent, RivetWebAppServerMe
4
4
  export type { GraphProgress } from './model/GraphProgress.js';
5
5
  export type { AgentResponseTrace } from './model/AgentResponseTrace.js';
6
6
  export { isAgentResponseTrace } from './model/AgentResponseTrace.js';
7
+ export type { WebAppBrowserStorage, WebAppBrowserStorageBatchChange, WebAppBrowserStorageChange, WebAppBrowserStorageCommitResult, WebAppBrowserStorageEstimate, WebAppBrowserStorageMigration, WebAppBrowserStorageNamespace, WebAppBrowserStorageScope, WebAppBrowserStorageStatus, } from './model/WebAppBrowserStorage.js';
8
+ export { IndexedDbWebAppBrowserStorage, RIVET_WEB_APP_BROWSER_STORAGE_CHUNK_BYTES, RIVET_WEB_APP_BROWSER_STORAGE_DATABASE, RIVET_WEB_APP_BROWSER_STORAGE_SCHEMA_VERSION, RIVET_WEB_APP_LEGACY_RETENTION_MS, WebAppBrowserStoragePersistenceError, } from './model/WebAppBrowserStorage.js';
9
+ export type { RivetWebAppBrowserStorageClientMessage, RivetWebAppBrowserStorageRpcAdvertisedLimits, RivetWebAppBrowserStorageServerMessage, RivetWebAppStorageCommitAckMessage, RivetWebAppStorageCommitStartMessage, RivetWebAppStorageErrorMessage, RivetWebAppStorageGetMessage, RivetWebAppStorageTransferAckMessage, RivetWebAppStorageTransferStartMessage, } from './model/WebAppBrowserStorageRpc.js';
10
+ export { decodeRivetWebAppStorageBinaryFrame, deserializeRivetWebAppStoredValue, deserializeRivetWebAppStoredValuePatch, encodeRivetWebAppStorageBinaryFrame, parseRivetWebAppBrowserStorageClientMessage, parseRivetWebAppBrowserStorageServerMessage, RIVET_WEB_APP_BROWSER_STORAGE_BINARY_FRAME_HEADER_BYTES, RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTION_BYTES, RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_ACTIVE_BYTES, RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_MAX_VALUE_BYTES, RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_TRANSFER_TIMEOUT_MS, RIVET_WEB_APP_BROWSER_STORAGE_RPC_CAPABILITY, RIVET_WEB_APP_BROWSER_STORAGE_RPC_VERSION, RIVET_WEB_APP_BROWSER_STORAGE_SAFE_FALLBACK_BYTES, RIVET_WEB_APP_BROWSER_STORAGE_TRANSFER_CHUNK_BYTES, serializeRivetWebAppStoredValue, serializeRivetWebAppStoredValuePatch, splitRivetWebAppStorageTransfer, } from './model/WebAppBrowserStorageRpc.js';
11
+ export type { UiGraphBrowserPersistenceOptions, UiGraphBrowserPersistenceDiagnostic, UiGraphBrowserPersistenceWarning, } from './model/UiGraphIndexedDbPersistence.js';
12
+ export { UiGraphBrowserPersistence } from './model/UiGraphIndexedDbPersistence.js';
7
13
  export type { RivetMarkdownSanitizerPolicy } from './model/MarkdownSanitizationPolicy.js';
8
14
  export type { UiGraphChatMessagePresentation, UiGraphChatMessagePresentationOptions, UiGraphChatMessageTimestampPresentation, } from './model/UiGraphBrowserRuntime.js';
9
- export { createUiGraphChatHistoryFlushStatePatch, createUiGraphChatMessageRemovalStatePatch, createUiGraphChatPinStatePatch, createUiGraphChatSubmissionStatePatch, getUiGraphActionState, getUiGraphChatDraftStateKey, getUiGraphChatMessagesStateKey, } from './model/UiGraph.js';
15
+ export { createUiGraphChatHistoryFlushStatePatch, createUiGraphChatMessageRemovalStatePatch, createUiGraphChatPinStatePatch, createUiGraphChatSubmissionStatePatch, getUiGraphActionState, getUiGraphChatDraftStateKey, getUiGraphChatMessagesStateKey, getUiGraphChatPinsStateKey, } from './model/UiGraph.js';
10
16
  export { applyUiGraphStatePatch, createUiGraphActionExecutionController, createUiGraphInteractionController, getUiGraphComponentRenderModel, getUiGraphJsonOutputFilename, getUiGraphProgressiveJsonOutputChunks, } from './model/UiGraphRuntimeModel.js';
11
17
  export { parseRivetWebAppClientMessage, parseRivetWebAppServerMessage, RIVET_WEB_APP_ACTION_PROTOCOL_VERSION, } from './model/UiGraphActionProtocol.js';
12
- export { copyUiGraphText, applyUiGraphWebAppStorageActionPatch, applyUiGraphWebAppStoragePatch, clearUiGraphChatSearchMatches, downloadUiGraphJsonOutput, enhanceUiGraphChatJsonCodeBlocks, hasUiGraphChatPersistentStateChanged, getUiGraphChatPersistentState, getUiGraphChatMessagePresentations, getUiGraphChatStorageKey, getUiGraphWebAppStorageKey, highlightUiGraphChatSearchMatches, loadUiGraphChatPersistentState, loadUiGraphWebAppStorage, observeUiGraphOutputResizeBounds, revealUiGraphChatElement, revealUiGraphChatSearchMatch, saveUiGraphChatPersistentState, saveUiGraphResponseTrace, loadUiGraphResponseTrace, pruneUiGraphResponseTraces, } from './model/UiGraphBrowserRuntime.js';
18
+ export { copyUiGraphText, applyUiGraphWebAppStorageActionPatch, applyUiGraphWebAppStorageActionPatchAsync, applyUiGraphWebAppStoragePatch, clearUiGraphChatSearchMatches, downloadUiGraphJsonOutput, enhanceUiGraphChatJsonCodeBlocks, hasUiGraphChatPersistentStateChanged, getUiGraphChatPersistentState, getUiGraphChatMessagePresentations, getUiGraphChatStorageKey, getUiGraphResponseTraceStorageKey, getUiGraphWebAppStorageKey, highlightUiGraphChatSearchMatches, loadUiGraphChatPersistentState, loadUiGraphWebAppStorage, observeUiGraphOutputResizeBounds, revealUiGraphChatElement, revealUiGraphChatSearchMatch, saveUiGraphChatPersistentState, saveUiGraphResponseTrace, loadUiGraphResponseTrace, pruneUiGraphResponseTraces, } from './model/UiGraphBrowserRuntime.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerypopoff/rivet2-core",
3
- "version": "2.3.0",
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": [