@valerypopoff/rivet2-core 2.3.0 → 2.4.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 +517 -96
- package/dist/cjs/bundle.cjs.map +4 -4
- 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 +2 -0
- package/dist/esm/model/AgentResponseTrace.js +16 -0
- package/dist/esm/model/GraphProcessor.js +14 -0
- package/dist/esm/model/NodeExclusionPolicy.js +9 -1
- package/dist/esm/model/ProcessContextBuilder.js +2 -1
- package/dist/esm/model/RecordingPlayer.js +8 -0
- 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/LLMChatV2Node.js +21 -2
- package/dist/esm/recording/ExecutionRecorder.js +1 -0
- package/dist/esm/webAppRuntime.js +5 -2
- package/dist/types/api/createProcessor.d.ts +2 -0
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/model/AgentResponseTrace.d.ts +1 -0
- package/dist/types/model/ExecutorProtocol.d.ts +9 -1
- package/dist/types/model/GraphProcessor.d.ts +3 -1
- package/dist/types/model/NodeExclusionPolicy.d.ts +6 -0
- package/dist/types/model/ProcessContext.d.ts +33 -0
- 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/recording/RecordedEvents.d.ts +11 -0
- package/dist/types/webAppRuntime.d.ts +8 -2
- package/package.json +1 -1
|
@@ -138,7 +138,9 @@ export function coreCreateProcessor(project, options, internalOptions = {}) {
|
|
|
138
138
|
settings: resolveProcessSettings(options),
|
|
139
139
|
getChatNodeEndpoint: options.getChatNodeEndpoint,
|
|
140
140
|
onChatV2CallFinished: options.onChatV2CallFinished,
|
|
141
|
+
onLLMChatOutputSnapshot: options.onLLMChatOutputSnapshot,
|
|
141
142
|
llmProfileHealthStore: options.llmProfileHealthStore,
|
|
143
|
+
llmProfileHealthExecutionCorrelationId: options.llmProfileHealthExecutionCorrelationId,
|
|
142
144
|
evaluation: options.evaluation,
|
|
143
145
|
}, resolvedInputs, resolvedContextValues, { returnWhenGraphOutputsReady: options.returnWhenGraphOutputsReady });
|
|
144
146
|
if (abortSignal?.aborted) {
|
package/dist/esm/exports.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './utils/index.js';
|
|
2
2
|
// eslint-disable-next-line import/no-cycle -- GraphProcessor depends on CodeRunner, which exposes the top-level Rivet export surface.
|
|
3
3
|
export * from './model/GraphProcessor.js';
|
|
4
|
+
export { canConsumeControlFlowExcludedInput } from './model/NodeExclusionPolicy.js';
|
|
4
5
|
export * from './model/DataValue.js';
|
|
5
6
|
export * from './model/NodeBase.js';
|
|
6
7
|
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';
|
|
@@ -103,6 +103,9 @@ export function mergeAgentTraceEvent(existing, incoming) {
|
|
|
103
103
|
if (existing.type === 'llm-call-finished' && incoming.type === 'llm-call-finished') {
|
|
104
104
|
return {
|
|
105
105
|
...incoming,
|
|
106
|
+
...(incoming.profileName == null && existing.profileName != null
|
|
107
|
+
? { profileName: existing.profileName }
|
|
108
|
+
: {}),
|
|
106
109
|
...(incoming.profileHealthKey == null && existing.profileHealthKey != null
|
|
107
110
|
? { profileHealthKey: existing.profileHealthKey }
|
|
108
111
|
: {}),
|
|
@@ -111,6 +114,14 @@ export function mergeAgentTraceEvent(existing, incoming) {
|
|
|
111
114
|
: {}),
|
|
112
115
|
};
|
|
113
116
|
}
|
|
117
|
+
if (existing.type === 'llm-profile-attempt' && incoming.type === 'llm-profile-attempt') {
|
|
118
|
+
return {
|
|
119
|
+
...incoming,
|
|
120
|
+
...(incoming.profileName == null && existing.profileName != null
|
|
121
|
+
? { profileName: existing.profileName }
|
|
122
|
+
: {}),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
114
125
|
if (existing.type === 'tool-call-finished' &&
|
|
115
126
|
incoming.type === 'tool-call-finished' &&
|
|
116
127
|
existing.resultOwner != null &&
|
|
@@ -131,6 +142,7 @@ function toModelCallTrace(event) {
|
|
|
131
142
|
outcome: event.outcome,
|
|
132
143
|
attemptIndex: event.attemptIndex,
|
|
133
144
|
...(event.profileIndex == null ? {} : { profileIndex: event.profileIndex }),
|
|
145
|
+
...(event.profileName == null ? {} : { profileName: event.profileName }),
|
|
134
146
|
...(event.profileHealthKey == null ? {} : { profileHealthKey: event.profileHealthKey }),
|
|
135
147
|
...(event.profileHealthState == null ? {} : { profileHealthState: event.profileHealthState }),
|
|
136
148
|
...(event.roundIndex == null ? {} : { roundIndex: event.roundIndex }),
|
|
@@ -360,6 +372,7 @@ function isAgentModelCallTrace(value) {
|
|
|
360
372
|
'outcome',
|
|
361
373
|
'attemptIndex',
|
|
362
374
|
'profileIndex',
|
|
375
|
+
'profileName',
|
|
363
376
|
'profileHealthKey',
|
|
364
377
|
'profileHealthState',
|
|
365
378
|
'roundIndex',
|
|
@@ -380,6 +393,7 @@ function isAgentModelCallTrace(value) {
|
|
|
380
393
|
(value.outcome === 'success' || value.outcome === 'provider-failure' || value.outcome === 'aborted') &&
|
|
381
394
|
isNonNegativeInteger(value.attemptIndex) &&
|
|
382
395
|
isOptionalNonNegativeInteger(value.profileIndex) &&
|
|
396
|
+
isOptionalString(value.profileName) &&
|
|
383
397
|
isOptionalString(value.profileHealthKey) &&
|
|
384
398
|
(value.profileHealthState === undefined ||
|
|
385
399
|
value.profileHealthState === 'closed' ||
|
|
@@ -398,6 +412,7 @@ function isAgentLLMProfileAttemptTrace(value) {
|
|
|
398
412
|
'eventId',
|
|
399
413
|
'roundIndex',
|
|
400
414
|
'profileIndex',
|
|
415
|
+
'profileName',
|
|
401
416
|
'nodeId',
|
|
402
417
|
'processId',
|
|
403
418
|
'provider',
|
|
@@ -418,6 +433,7 @@ function isAgentLLMProfileAttemptTrace(value) {
|
|
|
418
433
|
typeof value.eventId === 'string' &&
|
|
419
434
|
isNonNegativeInteger(value.roundIndex) &&
|
|
420
435
|
isOptionalNonNegativeInteger(value.profileIndex) &&
|
|
436
|
+
isOptionalString(value.profileName) &&
|
|
421
437
|
typeof value.nodeId === 'string' &&
|
|
422
438
|
typeof value.processId === 'string' &&
|
|
423
439
|
typeof value.provider === 'string' &&
|
|
@@ -825,6 +825,7 @@ export class GraphProcessor {
|
|
|
825
825
|
// observer from the root run so nested LLM calls are not emitted once by
|
|
826
826
|
// every ancestor before their own event is bridged to the root emitter.
|
|
827
827
|
const hostChatV2Observer = this.getRootProcessor().#context.onChatV2CallFinished;
|
|
828
|
+
const hostLLMChatOutputSnapshotObserver = this.getRootProcessor().#context.onLLMChatOutputSnapshot;
|
|
828
829
|
const hostLLMProfileAttemptObserver = this.getRootProcessor().#context.onLLMProfileAttempt;
|
|
829
830
|
this.#nodeProcessContextBase = {
|
|
830
831
|
...this.#context,
|
|
@@ -860,6 +861,18 @@ export class GraphProcessor {
|
|
|
860
861
|
const { rawUsage: _rawUsage, ...traceEvent } = event;
|
|
861
862
|
emitDetached(this.#emitter, 'llmCallFinished', this.#withExecution(traceEvent));
|
|
862
863
|
},
|
|
864
|
+
onLLMChatOutputSnapshot: (event) => {
|
|
865
|
+
try {
|
|
866
|
+
const observerResult = hostLLMChatOutputSnapshotObserver?.(event);
|
|
867
|
+
if (observerResult != null && typeof observerResult.then === 'function') {
|
|
868
|
+
void Promise.resolve(observerResult).catch(() => undefined);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
catch {
|
|
872
|
+
// Snapshot observers are display-only and must never affect execution.
|
|
873
|
+
}
|
|
874
|
+
emitDetached(this.#emitter, 'llmChatOutputSnapshot', this.#withExecution(event));
|
|
875
|
+
},
|
|
863
876
|
onLLMProfileAttempt: (event) => {
|
|
864
877
|
try {
|
|
865
878
|
const observerResult = hostLLMProfileAttemptObserver?.(event);
|
|
@@ -1919,6 +1932,7 @@ export class GraphProcessor {
|
|
|
1919
1932
|
emitDetached(this.#emitter, 'progress', this.#withExecution({ node, processId, progress: normalized }));
|
|
1920
1933
|
}
|
|
1921
1934
|
},
|
|
1935
|
+
splitIndex: node.isSplitRun ? index : 0,
|
|
1922
1936
|
setGlobal: (id, value) => {
|
|
1923
1937
|
this.#globals.set(id, value);
|
|
1924
1938
|
emitDetached(this.#emitter, 'globalSet', this.#withExecution({ id, value, processId }));
|
|
@@ -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,
|
|
@@ -12,6 +12,7 @@ export function buildNodeProcessContext(options) {
|
|
|
12
12
|
onPartialOutputs,
|
|
13
13
|
signal: nodeAbortController.signal,
|
|
14
14
|
processId,
|
|
15
|
+
splitIndex,
|
|
15
16
|
setGlobal,
|
|
16
17
|
createSubProcessor: createSubProcessor,
|
|
17
18
|
getPluginConfig,
|
|
@@ -414,6 +414,14 @@ export async function replayExecutionRecording(options) {
|
|
|
414
414
|
});
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
|
+
case 'llmChatOutputSnapshot': {
|
|
418
|
+
const { data } = event;
|
|
419
|
+
emitReplayExecutionEvent('llmChatOutputSnapshot', {
|
|
420
|
+
...data,
|
|
421
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
422
|
+
});
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
417
425
|
case 'llmProfileAttempt': {
|
|
418
426
|
const { data } = event;
|
|
419
427
|
emitReplayExecutionEvent('llmProfileAttempt', {
|
|
@@ -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 = {};
|