@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.
- package/dist/cjs/bundle.cjs +1947 -765
- 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 +1537 -121
- package/dist/cjs/webAppRuntime.cjs.map +4 -4
- package/dist/esm/api/createProcessor.js +2 -0
- package/dist/esm/exports.js +4 -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/AgentResponseTrace.js +16 -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 +150 -44
- package/dist/esm/model/NodeExclusionPolicy.js +9 -1
- package/dist/esm/model/ProcessContextBuilder.js +4 -1
- package/dist/esm/model/RecordingPlayer.js +19 -6
- package/dist/esm/model/StoredValueStore.js +4 -3
- package/dist/esm/model/SubprocessorBridge.js +1 -0
- package/dist/esm/model/UiGraphActionProtocol.js +46 -4
- package/dist/esm/model/UiGraphBrowserRuntime.js +15 -1
- package/dist/esm/model/UiGraphIndexedDbPersistence.js +523 -0
- package/dist/esm/model/UiGraphRendererStyles.js +14 -0
- package/dist/esm/model/WebAppBrowserStorage.js +653 -0
- package/dist/esm/model/WebAppBrowserStorageRpc.js +200 -0
- package/dist/esm/model/chat-v2/chatV2CallObserver.js +1 -0
- package/dist/esm/model/chat-v2/chatV2EditorCache.js +2 -33
- package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +1 -0
- package/dist/esm/model/chat-v2/llmChatV2OutputClone.js +42 -0
- package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +31 -2
- package/dist/esm/model/chat-v2/llmProfile.js +17 -1
- package/dist/esm/model/chat-v2/llmProfileFallback.js +17 -5
- package/dist/esm/model/chat-v2/llmProfileHealthStore.js +2 -0
- package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +4 -0
- package/dist/esm/model/chat-v2/toolContinuation.js +27 -1
- 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/LLMChatV2Node.js +21 -2
- 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/recording/ExecutionRecorder.js +1 -0
- 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/esm/webAppRuntime.js +5 -2
- package/dist/types/api/createProcessor.d.ts +2 -0
- package/dist/types/exports.d.ts +5 -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/AgentResponseTrace.d.ts +1 -0
- package/dist/types/model/ExecutorProtocol.d.ts +9 -1
- 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 +7 -4
- package/dist/types/model/NodeExclusionPolicy.d.ts +6 -0
- package/dist/types/model/ProcessContext.d.ts +36 -2
- package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
- package/dist/types/model/UiGraphActionProtocol.d.ts +8 -3
- package/dist/types/model/UiGraphBrowserRuntime.d.ts +6 -0
- package/dist/types/model/UiGraphIndexedDbPersistence.d.ts +50 -0
- package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
- package/dist/types/model/WebAppBrowserStorage.d.ts +90 -0
- package/dist/types/model/WebAppBrowserStorageRpc.d.ts +85 -0
- package/dist/types/model/chat-v2/chatV2Types.d.ts +3 -1
- package/dist/types/model/chat-v2/llmChatV2OutputClone.d.ts +3 -0
- package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +5 -1
- package/dist/types/model/chat-v2/llmProfileFallback.d.ts +4 -0
- package/dist/types/model/chat-v2/llmProfileHealthStore.d.ts +10 -0
- package/dist/types/model/chat-v2/llmProfileTypes.d.ts +6 -0
- package/dist/types/model/chat-v2/toolContinuation.d.ts +14 -0
- 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/recording/RecordedEvents.d.ts +11 -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/dist/types/webAppRuntime.d.ts +8 -2
- package/package.json +11 -1
|
@@ -11,6 +11,14 @@ const nodesAllowedToConsumeExcludedValue = new Set([
|
|
|
11
11
|
'raceInputs',
|
|
12
12
|
'loopController',
|
|
13
13
|
]);
|
|
14
|
+
/**
|
|
15
|
+
* Whether a node intentionally handles an input that was excluded by control
|
|
16
|
+
* flow. Most nodes are excluded themselves in that situation; these nodes
|
|
17
|
+
* implement their own fallback, branching, or aggregation behavior instead.
|
|
18
|
+
*/
|
|
19
|
+
export function canConsumeControlFlowExcludedInput(node) {
|
|
20
|
+
return nodesAllowedToConsumeExcludedValue.has(node.type);
|
|
21
|
+
}
|
|
14
22
|
function isControlFlowExcluded(value) {
|
|
15
23
|
return value != null && getScalarTypeOf(value.type) === 'control-flow-excluded';
|
|
16
24
|
}
|
|
@@ -34,7 +42,7 @@ export function getControlFlowExclusionDecision({ inputValues, node, typeOfExclu
|
|
|
34
42
|
}
|
|
35
43
|
const controlFlowExcludedValues = entries(inputValues).filter(([, value]) => isControlFlowExcluded(value) && (typeOfExclusion === undefined || value.value === typeOfExclusion));
|
|
36
44
|
const isWaitingForLoop = controlFlowExcludedValues.some(([, value]) => value?.value === LOOP_NOT_BROKEN_SENTINEL);
|
|
37
|
-
const allowedToConsumeExcludedValue =
|
|
45
|
+
const allowedToConsumeExcludedValue = canConsumeControlFlowExcludedInput(node) && !isWaitingForLoop;
|
|
38
46
|
if (controlFlowExcludedValues.length === 0 || allowedToConsumeExcludedValue) {
|
|
39
47
|
return { action: 'continue' };
|
|
40
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function buildNodeProcessContext(options) {
|
|
2
|
-
const { attachedData, activeOutputPortIds, base, createSubProcessor, execution, externalFunctions, getPluginConfig, isDirectRunTarget, markResultAsEditorCacheHit, node, nodeAbortController, onPartialOutputs, processId, requestUserInput, reportProgress, setGlobal, toolCallContinuation, toolCallTraceSource, waitEvent, } = options;
|
|
2
|
+
const { attachedData, activeOutputPortIds, base, createSubProcessor, execution, externalFunctions, getPluginConfig, isDirectRunTarget, markResultAsEditorCacheHit, node, nodeAbortController, onPartialOutputs, processId, requestUserInput, reportProgress, setGlobal, splitIndex, toolCallContinuation, toolCallTraceSource, waitEvent, } = options;
|
|
3
3
|
return {
|
|
4
4
|
...base,
|
|
5
5
|
node,
|
|
@@ -8,10 +8,13 @@ export function buildNodeProcessContext(options) {
|
|
|
8
8
|
isDirectRunTarget,
|
|
9
9
|
markResultAsEditorCacheHit,
|
|
10
10
|
waitEvent,
|
|
11
|
+
waitForGlobal: (id, signal = nodeAbortController.signal) => base.waitForGlobal(id, signal),
|
|
12
|
+
waitForStoredValue: (key, signal = nodeAbortController.signal) => base.waitForStoredValue(key, signal),
|
|
11
13
|
externalFunctions: { ...externalFunctions },
|
|
12
14
|
onPartialOutputs,
|
|
13
15
|
signal: nodeAbortController.signal,
|
|
14
16
|
processId,
|
|
17
|
+
splitIndex,
|
|
15
18
|
setGlobal,
|
|
16
19
|
createSubProcessor: createSubProcessor,
|
|
17
20
|
getPluginConfig,
|
|
@@ -34,7 +34,8 @@ const REPLAY_TIMED_LIFECYCLE_EVENTS = new Set([
|
|
|
34
34
|
'nodeOutputsCleared',
|
|
35
35
|
]);
|
|
36
36
|
export async function replayExecutionRecording(options) {
|
|
37
|
-
const { emitter, erroredNodes,
|
|
37
|
+
const { emitter, erroredNodes, fallbackGraphId, initialReplayExecution, project, recorder, recordingPlaybackChatLatency, setContextValues, setGraphInputs, setGraphOutputs, setRunning, visitedNodes, waitUntilUnpaused, nodeResults, isAborted, } = options;
|
|
38
|
+
let graphOutputs = options.graphOutputs;
|
|
38
39
|
const nodesByIdAllGraphs = {};
|
|
39
40
|
const graphIdByNodeId = {};
|
|
40
41
|
for (const graph of Object.values(project.graphs)) {
|
|
@@ -165,13 +166,13 @@ export async function replayExecutionRecording(options) {
|
|
|
165
166
|
: nanoid();
|
|
166
167
|
replayRootRunIds.set(recordedExecution.rootRunId, replayRootRunId);
|
|
167
168
|
}
|
|
168
|
-
const getReplayGraphRunId = (recordedGraphRunId) => {
|
|
169
|
+
const getReplayGraphRunId = (recordedGraphRunId, initialGraphRunId) => {
|
|
169
170
|
let graphRunIds = replayGraphRunIdsByRoot.get(recordedExecution.rootRunId);
|
|
170
171
|
if (graphRunIds == null) {
|
|
171
172
|
graphRunIds = new Map();
|
|
172
173
|
replayGraphRunIdsByRoot.set(recordedExecution.rootRunId, graphRunIds);
|
|
173
174
|
}
|
|
174
|
-
const replayGraphRunId = graphRunIds.get(recordedGraphRunId) ?? nanoid();
|
|
175
|
+
const replayGraphRunId = initialGraphRunId ?? graphRunIds.get(recordedGraphRunId) ?? nanoid();
|
|
175
176
|
graphRunIds.set(recordedGraphRunId, replayGraphRunId);
|
|
176
177
|
return replayGraphRunId;
|
|
177
178
|
};
|
|
@@ -183,7 +184,9 @@ export async function replayExecutionRecording(options) {
|
|
|
183
184
|
return {
|
|
184
185
|
...rest,
|
|
185
186
|
rootRunId: replayRootRunId,
|
|
186
|
-
|
|
187
|
+
// Seed the root mapping too, so child parentGraphRunId references resolve
|
|
188
|
+
// to the same identity already allocated by the playback processor.
|
|
189
|
+
graphRunId: getReplayGraphRunId(graphRunId, isInitialRootGraph ? initialReplayExecution.graphRunId : undefined),
|
|
187
190
|
...(parentGraphRunId == null ? {} : { parentGraphRunId: getReplayGraphRunId(parentGraphRunId) }),
|
|
188
191
|
};
|
|
189
192
|
};
|
|
@@ -234,8 +237,10 @@ export async function replayExecutionRecording(options) {
|
|
|
234
237
|
case 'done': {
|
|
235
238
|
emitFallbackRootTerminal('completed', { outputs: event.data.results });
|
|
236
239
|
emitReplayTerminalEvent('done', event.data);
|
|
237
|
-
|
|
238
|
-
|
|
240
|
+
graphOutputs = event.data.results;
|
|
241
|
+
setGraphOutputs(graphOutputs);
|
|
242
|
+
// Keep ownership until playback drains, just like a live graph run.
|
|
243
|
+
// A done listener must not start work that final cleanup could clobber.
|
|
239
244
|
break;
|
|
240
245
|
}
|
|
241
246
|
case 'error': {
|
|
@@ -414,6 +419,14 @@ export async function replayExecutionRecording(options) {
|
|
|
414
419
|
});
|
|
415
420
|
break;
|
|
416
421
|
}
|
|
422
|
+
case 'llmChatOutputSnapshot': {
|
|
423
|
+
const { data } = event;
|
|
424
|
+
emitReplayExecutionEvent('llmChatOutputSnapshot', {
|
|
425
|
+
...data,
|
|
426
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
427
|
+
});
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
417
430
|
case 'llmProfileAttempt': {
|
|
418
431
|
const { data } = event;
|
|
419
432
|
emitReplayExecutionEvent('llmProfileAttempt', {
|
|
@@ -87,10 +87,11 @@ export class RivetStoredValueController {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
|
+
// Observe the registered wait before checking cancellation again, or an
|
|
91
|
+
// abort while the key lock releases can orphan its rejected promise.
|
|
92
|
+
const value = waiterPromise === undefined ? immediateValue : await waiterPromise;
|
|
90
93
|
signal?.throwIfAborted();
|
|
91
|
-
|
|
92
|
-
return immediateValue;
|
|
93
|
-
return await waiterPromise;
|
|
94
|
+
return value;
|
|
94
95
|
}
|
|
95
96
|
async #getUnlocked(key) {
|
|
96
97
|
const cached = this.#cache.get(key);
|
|
@@ -30,6 +30,7 @@ export function wireSubprocessorEvents(processor, parentEmitter, parentState) {
|
|
|
30
30
|
processor.on('partialOutput', (event) => parentEmitter.emit('partialOutput', event)),
|
|
31
31
|
processor.on('progress', (event) => parentEmitter.emit('progress', event)),
|
|
32
32
|
processor.on('llmCallFinished', (event) => parentEmitter.emit('llmCallFinished', event)),
|
|
33
|
+
processor.on('llmChatOutputSnapshot', (event) => parentEmitter.emit('llmChatOutputSnapshot', event)),
|
|
33
34
|
processor.on('llmProfileAttempt', (event) => parentEmitter.emit('llmProfileAttempt', event)),
|
|
34
35
|
processor.on('toolCallFinished', (event) => parentEmitter.emit('toolCallFinished', event)),
|
|
35
36
|
processor.on('nodeExcluded', (event) => parentEmitter.emit('nodeExcluded', event)),
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { normalizeGraphProgress } from './GraphProgress.js';
|
|
2
2
|
import { isAgentResponseTrace } from './AgentResponseTrace.js';
|
|
3
|
+
import { RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_TRANSFER_TIMEOUT_MS, parseRivetWebAppBrowserStorageClientMessage, parseRivetWebAppBrowserStorageServerMessage, } from './WebAppBrowserStorageRpc.js';
|
|
3
4
|
export const RIVET_WEB_APP_ACTION_PROTOCOL_VERSION = 1;
|
|
4
5
|
export function parseRivetWebAppClientMessage(value) {
|
|
5
6
|
if (!isRecord(value) || typeof value.type !== 'string')
|
|
6
7
|
return undefined;
|
|
8
|
+
const storageMessage = parseRivetWebAppBrowserStorageClientMessage(value);
|
|
9
|
+
if (storageMessage)
|
|
10
|
+
return storageMessage;
|
|
7
11
|
switch (value.type) {
|
|
8
12
|
case 'client.hello':
|
|
9
13
|
return value.protocolVersion === RIVET_WEB_APP_ACTION_PROTOCOL_VERSION
|
|
10
|
-
? {
|
|
14
|
+
? {
|
|
15
|
+
type: value.type,
|
|
16
|
+
protocolVersion: value.protocolVersion,
|
|
17
|
+
...(isStringArray(value.capabilities) ? { capabilities: value.capabilities } : {}),
|
|
18
|
+
}
|
|
11
19
|
: undefined;
|
|
12
20
|
case 'action.start':
|
|
13
21
|
return isNonEmptyString(value.requestId) &&
|
|
@@ -22,6 +30,7 @@ export function parseRivetWebAppClientMessage(value) {
|
|
|
22
30
|
state: value.state,
|
|
23
31
|
...(isRecord(value.storage) ? { storage: value.storage } : {}),
|
|
24
32
|
...(typeof value.revisionKey === 'string' ? { revisionKey: value.revisionKey } : {}),
|
|
33
|
+
...(value.storageRpcVersion === 2 ? { storageRpcVersion: 2 } : {}),
|
|
25
34
|
}
|
|
26
35
|
: undefined;
|
|
27
36
|
case 'action.cancel':
|
|
@@ -40,10 +49,21 @@ export function parseRivetWebAppClientMessage(value) {
|
|
|
40
49
|
export function parseRivetWebAppServerMessage(value) {
|
|
41
50
|
if (!isRecord(value) || typeof value.type !== 'string')
|
|
42
51
|
return undefined;
|
|
52
|
+
const storageMessage = parseRivetWebAppBrowserStorageServerMessage(value);
|
|
53
|
+
if (storageMessage)
|
|
54
|
+
return storageMessage;
|
|
43
55
|
if (value.type === 'server.ready') {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
if (value.protocolVersion !== RIVET_WEB_APP_ACTION_PROTOCOL_VERSION)
|
|
57
|
+
return undefined;
|
|
58
|
+
const browserStorageRpcLimits = parseBrowserStorageRpcLimits(value.browserStorageRpcLimits);
|
|
59
|
+
if (value.browserStorageRpcLimits != null && !browserStorageRpcLimits)
|
|
60
|
+
return undefined;
|
|
61
|
+
return {
|
|
62
|
+
type: value.type,
|
|
63
|
+
protocolVersion: value.protocolVersion,
|
|
64
|
+
...(isStringArray(value.capabilities) ? { capabilities: value.capabilities } : {}),
|
|
65
|
+
...(browserStorageRpcLimits ? { browserStorageRpcLimits } : {}),
|
|
66
|
+
};
|
|
47
67
|
}
|
|
48
68
|
if (value.type === 'server.draining')
|
|
49
69
|
return { type: value.type };
|
|
@@ -129,6 +149,28 @@ function hasRunEventBase(value) {
|
|
|
129
149
|
function isRecord(value) {
|
|
130
150
|
return typeof value === 'object' && value != null && !Array.isArray(value);
|
|
131
151
|
}
|
|
152
|
+
function parseBrowserStorageRpcLimits(value) {
|
|
153
|
+
if (!isRecord(value))
|
|
154
|
+
return undefined;
|
|
155
|
+
if (!isPositiveSafeInteger(value.maxActionBytes) ||
|
|
156
|
+
!isPositiveSafeInteger(value.maxValueBytes) ||
|
|
157
|
+
value.maxValueBytes > value.maxActionBytes) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
if (value.transferTimeoutMs != null && !isPositiveSafeInteger(value.transferTimeoutMs))
|
|
161
|
+
return undefined;
|
|
162
|
+
return {
|
|
163
|
+
maxActionBytes: value.maxActionBytes,
|
|
164
|
+
maxValueBytes: value.maxValueBytes,
|
|
165
|
+
transferTimeoutMs: value.transferTimeoutMs ?? RIVET_WEB_APP_BROWSER_STORAGE_DEFAULT_TRANSFER_TIMEOUT_MS,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function isPositiveSafeInteger(value) {
|
|
169
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value > 0;
|
|
170
|
+
}
|
|
132
171
|
function isNonEmptyString(value) {
|
|
133
172
|
return typeof value === 'string' && value.length > 0;
|
|
134
173
|
}
|
|
174
|
+
function isStringArray(value) {
|
|
175
|
+
return (Array.isArray(value) && value.length <= 16 && value.every((item) => typeof item === 'string' && item.length <= 100));
|
|
176
|
+
}
|
|
@@ -144,7 +144,7 @@ export function getUiGraphWebAppStorageKey(uiGraph, location = getDefaultUiGraph
|
|
|
144
144
|
encodeURIComponent(uiGraph.id),
|
|
145
145
|
].join(':');
|
|
146
146
|
}
|
|
147
|
-
function getUiGraphResponseTraceStorageKey(uiGraph, componentId, location = getDefaultUiGraphStorageLocation()) {
|
|
147
|
+
export function getUiGraphResponseTraceStorageKey(uiGraph, componentId, location = getDefaultUiGraphStorageLocation()) {
|
|
148
148
|
if (!location?.origin)
|
|
149
149
|
return undefined;
|
|
150
150
|
const pathname = location.pathname.replace(/\/+$/, '') || '/';
|
|
@@ -296,6 +296,20 @@ export function applyUiGraphWebAppStorageActionPatch(patch, actionNumber, applie
|
|
|
296
296
|
appliedActionByKey.set(key, actionNumber);
|
|
297
297
|
return applicablePatch;
|
|
298
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Async equivalent used by IndexedDB-backed clients. Ordering metadata is
|
|
301
|
+
* advanced only after the durable commit succeeds.
|
|
302
|
+
*/
|
|
303
|
+
export async function applyUiGraphWebAppStorageActionPatchAsync(patch, actionNumber, appliedActionByKey, persist) {
|
|
304
|
+
const applicablePatch = Object.fromEntries(Object.entries(patch).filter(([key]) => actionNumber >= (appliedActionByKey.get(key) ?? 0)));
|
|
305
|
+
const applicableKeys = Object.keys(applicablePatch);
|
|
306
|
+
if (applicableKeys.length === 0)
|
|
307
|
+
return applicablePatch;
|
|
308
|
+
await persist(applicablePatch);
|
|
309
|
+
for (const key of applicableKeys)
|
|
310
|
+
appliedActionByKey.set(key, actionNumber);
|
|
311
|
+
return applicablePatch;
|
|
312
|
+
}
|
|
299
313
|
/** Selects and validates the private browser-persisted state of Chat components only. */
|
|
300
314
|
export function getUiGraphChatPersistentState(uiGraph, state) {
|
|
301
315
|
const persistentState = {};
|