@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
@@ -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
+ }
@@ -1,5 +1,8 @@
1
1
  export { isAgentResponseTrace } from './model/AgentResponseTrace.js';
2
- export { createUiGraphChatHistoryFlushStatePatch, createUiGraphChatMessageRemovalStatePatch, createUiGraphChatPinStatePatch, createUiGraphChatSubmissionStatePatch, getUiGraphActionState, getUiGraphChatDraftStateKey, getUiGraphChatMessagesStateKey, } from './model/UiGraph.js';
2
+ 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';
3
+ 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';
4
+ export { UiGraphBrowserPersistence } from './model/UiGraphIndexedDbPersistence.js';
5
+ export { createUiGraphChatHistoryFlushStatePatch, createUiGraphChatMessageRemovalStatePatch, createUiGraphChatPinStatePatch, createUiGraphChatSubmissionStatePatch, getUiGraphActionState, getUiGraphChatDraftStateKey, getUiGraphChatMessagesStateKey, getUiGraphChatPinsStateKey, } from './model/UiGraph.js';
3
6
  export { applyUiGraphStatePatch, createUiGraphActionExecutionController, createUiGraphInteractionController, getUiGraphComponentRenderModel, getUiGraphJsonOutputFilename, getUiGraphProgressiveJsonOutputChunks, } from './model/UiGraphRuntimeModel.js';
4
7
  export { parseRivetWebAppClientMessage, parseRivetWebAppServerMessage, RIVET_WEB_APP_ACTION_PROTOCOL_VERSION, } from './model/UiGraphActionProtocol.js';
5
- 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';
8
+ 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';
@@ -39,7 +39,9 @@ export type RunGraphOptions = {
39
39
  concurrency?: GraphProcessorConcurrency;
40
40
  getChatNodeEndpoint?: ProcessContext['getChatNodeEndpoint'];
41
41
  onChatV2CallFinished?: ProcessContext['onChatV2CallFinished'];
42
+ onLLMChatOutputSnapshot?: ProcessContext['onLLMChatOutputSnapshot'];
42
43
  llmProfileHealthStore?: RivetLLMProfileHealthStore;
44
+ llmProfileHealthExecutionCorrelationId?: ProcessContext['llmProfileHealthExecutionCorrelationId'];
43
45
  evaluation?: ProcessContext['evaluation'];
44
46
  tokenizer?: Tokenizer;
45
47
  codeRunner?: ProcessContext['codeRunner'];
@@ -1,5 +1,6 @@
1
1
  export * from './utils/index.js';
2
2
  export * from './model/GraphProcessor.js';
3
+ export { canConsumeControlFlowExcludedInput } from './model/NodeExclusionPolicy.js';
3
4
  export * from './model/DataValue.js';
4
5
  export * from './model/NodeBase.js';
5
6
  export * from './model/NodeGraph.js';
@@ -15,6 +16,7 @@ export * from './model/UiGraphWebAppStorage.js';
15
16
  export * from './model/StoredValueStore.js';
16
17
  export * from './model/ToolCallContinuation.js';
17
18
  export * from './model/UiGraphActionProtocol.js';
19
+ export * from './model/WebAppBrowserStorageRpc.js';
18
20
  export * from './model/GraphProgress.js';
19
21
  export * from './model/UiGraphRendererStyles.js';
20
22
  export * from './model/MarkdownSanitizationPolicy.js';
@@ -66,7 +68,9 @@ export * from './integrations/Tokenizer.js';
66
68
  export * from './integrations/GptTokenizerTokenizer.js';
67
69
  export { JS_LIST_CALLBACK_LOCAL_NAMES, interpolateJSListCallbackBody } from './model/nodes/jsListCallbackHelpers.js';
68
70
  export { findAutoDelegateGraphCandidate } from './model/nodes/toolCallDelegation.js';
69
- 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';
70
74
  export { WarningsPort } from './utils/symbols.js';
71
75
  import * as openai from './utils/openai.js';
72
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';
@@ -16,6 +16,7 @@ export type AgentModelCallTrace = {
16
16
  outcome: ChatV2CallTraceEvent['outcome'];
17
17
  attemptIndex: number;
18
18
  profileIndex?: number;
19
+ profileName?: string;
19
20
  profileHealthKey?: string;
20
21
  profileHealthState?: ChatV2CallTraceEvent['profileHealthState'];
21
22
  roundIndex?: number;
@@ -2,7 +2,7 @@ import type { DataValue, ScalarOrArrayDataValue, StringArrayDataValue } from './
2
2
  import type { Dataset, DatasetId, DatasetMetadata, DatasetRow } from './Dataset.js';
3
3
  import type { ChartNode, NodeConnection, NodeId, PortId } from './NodeBase.js';
4
4
  import type { GraphId, NodeGraph } from './NodeGraph.js';
5
- import type { ChatV2CallTraceEvent, EvaluationExecutionMetadata, GraphExecutionMetadata, LLMProfileAttemptTraceEvent, ProcessId, ToolCallFinishedEvent } from './ProcessContext.js';
5
+ import type { ChatV2CallTraceEvent, EvaluationExecutionMetadata, GraphExecutionMetadata, LLMProfileAttemptTraceEvent, LLMChatOutputSnapshotEvent, ProcessId, ToolCallFinishedEvent } from './ProcessContext.js';
6
6
  import type { Project, ProjectId } from './Project.js';
7
7
  import type { Settings } from './Settings.js';
8
8
  import type { FrozenNodeOutputsByGraph, NodeResultOrigin, ReplayEventTiming } from './GraphProcessor.js';
@@ -105,6 +105,7 @@ export type SerializedProcessEventMap = {
105
105
  progress: GraphProgress;
106
106
  }>;
107
107
  llmCallFinished: WithExecution<ChatV2CallTraceEvent>;
108
+ llmChatOutputSnapshot: WithExecution<LLMChatOutputSnapshotEvent>;
108
109
  llmProfileAttempt: WithExecution<LLMProfileAttemptTraceEvent>;
109
110
  toolCallFinished: WithExecution<ToolCallFinishedEvent>;
110
111
  nodeOutputsCleared: WithExecution<{
@@ -162,6 +163,7 @@ export type ProcessEventMessageMap = {
162
163
  partialOutput: SerializedProcessEventMap['partialOutput'];
163
164
  progress: SerializedProcessEventMap['progress'];
164
165
  llmCallFinished: SerializedProcessEventMap['llmCallFinished'];
166
+ llmChatOutputSnapshot: SerializedProcessEventMap['llmChatOutputSnapshot'];
165
167
  llmProfileAttempt: SerializedProcessEventMap['llmProfileAttempt'];
166
168
  toolCallFinished: SerializedProcessEventMap['toolCallFinished'];
167
169
  nodeOutputsCleared: SerializedProcessEventMap['nodeOutputsCleared'];
@@ -241,6 +243,12 @@ export type OutgoingMessageMap = {
241
243
  useEditorCache?: boolean;
242
244
  captureNodeTimings?: boolean;
243
245
  evaluation?: EvaluationExecutionMetadata;
246
+ /**
247
+ * An opaque, host-owned ID that lets a trusted executor join an unhealthy
248
+ * LLM Profile attempt to a recording persisted after this editor run.
249
+ * It is not graph input and is never forwarded to a model provider.
250
+ */
251
+ llmProfileHealthExecutionCorrelationId?: string;
244
252
  returnWhenGraphOutputsReady?: boolean;
245
253
  webAppStorage?: RivetWebAppStorage;
246
254
  };
@@ -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;
@@ -4,7 +4,7 @@ import { type ChartNode, type NodeConnection, type NodeId } from './NodeBase.js'
4
4
  import type { GraphId, NodeGraph } from './NodeGraph.js';
5
5
  import Emittery from 'emittery';
6
6
  import { type ProjectId, type Project } from './Project.js';
7
- import type { GraphExecutionMetadata, InternalProcessContext, ProcessContext, ProcessId, ChatV2CallTraceEvent, LLMProfileAttemptTraceEvent, ToolCallFinishedEvent } from './ProcessContext.js';
7
+ import type { GraphExecutionMetadata, InternalProcessContext, ProcessContext, ProcessId, ChatV2CallTraceEvent, LLMChatOutputSnapshotEvent, LLMProfileAttemptTraceEvent, ToolCallFinishedEvent } from './ProcessContext.js';
8
8
  import type { ExecutionRecorder } from '../recording/ExecutionRecorder.js';
9
9
  import type { Tagged } from 'type-fest';
10
10
  import type { NodeRegistration } from './NodeRegistration.js';
@@ -129,6 +129,8 @@ export type ProcessEvents = {
129
129
  }>;
130
130
  /** Privacy-bounded metadata for one physical LLM provider call. */
131
131
  llmCallFinished: WithExecution<ChatV2CallTraceEvent>;
132
+ /** Display-only output page for one completed logical LLM Chat round. */
133
+ llmChatOutputSnapshot: WithExecution<LLMChatOutputSnapshotEvent>;
132
134
  /** Privacy-bounded metadata for one LLM fallback/profile-health decision. */
133
135
  llmProfileAttempt: WithExecution<LLMProfileAttemptTraceEvent>;
134
136
  /** Privacy-bounded metadata for one delegated tool execution. */
@@ -296,10 +298,11 @@ export declare class GraphProcessor {
296
298
  /** Inputs to the main graph. You should pass all inputs required by the GraphInputNodes of the graph. */
297
299
  inputs?: Record<string, DataValue>,
298
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. */
299
- contextValues?: Record<string, DataValue>,
300
- /** Allows callers such as web apps to receive root outputs while managed async branches continue settling. */
301
- options?: {
301
+ contextValues?: Record<string, DataValue>, options?: {
302
+ /** Allows web apps to receive root outputs while managed async branches continue settling. */
302
303
  returnWhenGraphOutputsReady?: boolean;
304
+ /** Restrict this invocation to named graph outputs and their prerequisites. Cannot be combined with runToNodeIds. */
305
+ requestedGraphOutputIds?: readonly string[];
303
306
  }): Promise<GraphOutputs>;
304
307
  getRootProcessor(): GraphProcessor;
305
308
  /** Raise a user event on the processor, all subprocessors, and their children. */
@@ -9,6 +9,12 @@ export type NodeExclusionDecision = {
9
9
  reason: NodeExclusionReason;
10
10
  traceMessage: string;
11
11
  };
12
+ /**
13
+ * Whether a node intentionally handles an input that was excluded by control
14
+ * flow. Most nodes are excluded themselves in that situation; these nodes
15
+ * implement their own fallback, branching, or aggregation behavior instead.
16
+ */
17
+ export declare function canConsumeControlFlowExcludedInput(node: ChartNode): boolean;
12
18
  export declare function getControlFlowExclusionDecision({ inputValues, node, typeOfExclusion, }: {
13
19
  inputValues: NodePortValues;
14
20
  node: ChartNode;
@@ -56,6 +56,8 @@ export type ChatV2CallFinishedEvent = {
56
56
  attemptIndex: number;
57
57
  /** Zero-based profile index when LLM Chat is using a profile fallback chain. */
58
58
  profileIndex?: number;
59
+ /** User-facing title captured from the source LLM Profile node. */
60
+ profileName?: string;
59
61
  /** Privacy-bounded stable profile health key when circuit breaking is enabled. */
60
62
  profileHealthKey?: string;
61
63
  /** Circuit state observed when this physical call was admitted. */
@@ -79,6 +81,25 @@ export type ChatV2CallFinishedEvent = {
79
81
  durationMs?: number;
80
82
  };
81
83
  export type ChatV2CallFinishedObserver = (event: ChatV2CallFinishedEvent) => void;
84
+ /** A completed logical LLM Chat round, as opposed to one physical provider attempt. */
85
+ export type LLMChatOutputSnapshotKind = 'model-round' | 'direct-tool-result';
86
+ /** The user-visible terminal state represented by one completed logical round. */
87
+ export type LLMChatOutputSnapshotOutcome = 'tool-calls' | 'final-answer' | 'provider-failure' | 'unresolved-tool-calls' | 'max-rounds' | 'direct-tool-result';
88
+ /**
89
+ * Observational output page emitted by LLM Chat after a logical model round.
90
+ * It never changes the node's single graph-semantic terminal output.
91
+ */
92
+ export type LLMChatOutputSnapshotEvent = {
93
+ entryId: string;
94
+ roundIndex: number;
95
+ splitIndex: number;
96
+ kind: LLMChatOutputSnapshotKind;
97
+ outcome: LLMChatOutputSnapshotOutcome;
98
+ nodeId: NodeId;
99
+ processId: ProcessId;
100
+ outputs: Outputs;
101
+ };
102
+ export type LLMChatOutputSnapshotObserver = (event: LLMChatOutputSnapshotEvent) => void | Promise<void>;
82
103
  /**
83
104
  * Portable, privacy-bounded subset of a completed physical Chat V2 call.
84
105
  * Provider-shaped raw usage is intentionally retained only by the host observer
@@ -95,6 +116,8 @@ export type LLMProfileAttemptTraceEvent = {
95
116
  roundIndex: number;
96
117
  /** Present when this attempt belongs to a From profile fallback candidate. */
97
118
  profileIndex?: number;
119
+ /** User-facing title captured from the source LLM Profile node. */
120
+ profileName?: string;
98
121
  nodeId: NodeId;
99
122
  processId: ProcessId;
100
123
  provider: ChatV2Provider;
@@ -162,10 +185,18 @@ export type ProcessContext = {
162
185
  * provider attempt. Observer failures are isolated from graph execution.
163
186
  */
164
187
  onChatV2CallFinished?: ChatV2CallFinishedObserver;
188
+ /** Host-only observer for completed, display-only LLM Chat output pages. */
189
+ onLLMChatOutputSnapshot?: LLMChatOutputSnapshotObserver;
165
190
  /** Host-only observer for profile fallback and circuit-health decisions. */
166
191
  onLLMProfileAttempt?: LLMProfileAttemptObserver;
167
192
  /** Optional shared persistence for cross-run LLM Profile circuit state. */
168
193
  llmProfileHealthStore?: RivetLLMProfileHealthStore;
194
+ /**
195
+ * Host-owned correlation for a runnable execution. It is not a graph input,
196
+ * is never sent to a provider, and lets hosts connect profile suspension
197
+ * evidence to a durable run recording after the run has completed.
198
+ */
199
+ llmProfileHealthExecutionCorrelationId?: string;
169
200
  /** Optional host-owned Evaluation identity propagated into execution events and recordings. */
170
201
  evaluation?: EvaluationExecutionMetadata;
171
202
  /**
@@ -218,6 +249,8 @@ export type InternalProcessContext<T extends ChartNode = ChartNode> = ProcessCon
218
249
  signal: AbortSignal;
219
250
  /** A unique ID for this specific execution of the node. */
220
251
  processId: ProcessId;
252
+ /** Zero-based split item index. GraphProcessor supplies zero for non-split runs. */
253
+ splitIndex?: number;
221
254
  /** Output ports with at least one active immediate downstream consumer in this graph run. */
222
255
  activeOutputPortIds: ReadonlySet<PortId>;
223
256
  /**
@@ -277,14 +310,15 @@ export type InternalProcessContext<T extends ChartNode = ChartNode> = ProcessCon
277
310
  getGlobal: (id: string) => ScalarOrArrayDataValue | undefined;
278
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. */
279
312
  setGlobal: (id: string, value: ScalarOrArrayDataValue) => void;
280
- 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>;
281
315
  /** Reads through the root run's stored-value cache and optional persistence store. */
282
316
  getStoredValue: (key: string) => Promise<RivetStoredValueReadResult>;
283
317
  /** Returns only the current root run's synchronous stored-value cache state. */
284
318
  getCachedStoredValue: (key: string) => RivetStoredValueCacheResult;
285
319
  /** Writes through the root run's cache and optional persistence store. */
286
320
  setStoredValue: (key: string, value: RivetStoredValue) => Promise<RivetStoredValueSetResult>;
287
- /** 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. */
288
322
  waitForStoredValue: (key: string, signal?: AbortSignal) => Promise<RivetStoredValue>;
289
323
  /** Resolves a named project or host-provided knowledge store for this execution. */
290
324
  getKnowledgeStore: (connectionId: KnowledgeStoreConnectionId) => Promise<RivetKnowledgeStore>;
@@ -4,7 +4,7 @@ import type { ChartNode, PortId } from './NodeBase.js';
4
4
  import type { GraphId } from './NodeGraph.js';
5
5
  import type { Project } from './Project.js';
6
6
  import type { AttachedNodeData, ExternalFunction, Outputs } from './GraphProcessor.js';
7
- export type NodeProcessContextBase = Omit<InternalProcessContext, 'attachedData' | 'activeOutputPortIds' | 'createSubProcessor' | 'execution' | 'externalFunctions' | 'getPluginConfig' | 'node' | 'onPartialOutputs' | 'processId' | 'requestUserInput' | 'reportProgress' | 'isDirectRunTarget' | 'markResultAsEditorCacheHit' | 'setGlobal' | 'signal' | 'toolCallContinuation' | 'toolCallTraceSource' | 'waitEvent'>;
7
+ export type NodeProcessContextBase = Omit<InternalProcessContext, 'attachedData' | 'activeOutputPortIds' | 'createSubProcessor' | 'execution' | 'externalFunctions' | 'getPluginConfig' | 'node' | 'onPartialOutputs' | 'processId' | 'requestUserInput' | 'reportProgress' | 'isDirectRunTarget' | 'markResultAsEditorCacheHit' | 'setGlobal' | 'signal' | 'splitIndex' | 'toolCallContinuation' | 'toolCallTraceSource' | 'waitEvent'>;
8
8
  export declare function buildNodeProcessContext(options: {
9
9
  activeOutputPortIds: ReadonlySet<PortId>;
10
10
  base: NodeProcessContextBase;
@@ -25,6 +25,7 @@ export declare function buildNodeProcessContext(options: {
25
25
  requestUserInput: (inputStrings: string[], renderingType: 'text' | 'markdown') => Promise<StringArrayDataValue>;
26
26
  reportProgress: InternalProcessContext['reportProgress'];
27
27
  setGlobal: (id: string, value: ScalarOrArrayDataValue) => void;
28
+ splitIndex: number;
28
29
  toolCallContinuation?: InternalProcessContext['toolCallContinuation'];
29
30
  toolCallTraceSource?: InternalProcessContext['toolCallTraceSource'];
30
31
  waitEvent: (event: string) => Promise<DataValue | undefined>;