@valerypopoff/rivet2-core 2.1.9 → 2.3.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/README.md +1 -1
- package/dist/cjs/bundle.cjs +5618 -2533
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/webAppRuntime.cjs +333 -22
- package/dist/cjs/webAppRuntime.cjs.map +4 -4
- package/dist/esm/api/createProcessor.js +2 -0
- package/dist/esm/exports.js +1 -0
- package/dist/esm/integrations/CodeRunner.js +2 -7
- package/dist/esm/integrations/CodeRunnerOptions.js +7 -0
- package/dist/esm/model/AgentResponseTrace.js +558 -0
- package/dist/esm/model/ConnectedToolContinuationHost.js +33 -0
- package/dist/esm/model/GraphProcessor.js +165 -74
- package/dist/esm/model/NodeImpl.js +6 -0
- package/dist/esm/model/ProcessContextBuilder.js +3 -1
- package/dist/esm/model/RecordingPlayer.js +212 -25
- package/dist/esm/model/SplitRunProcessor.js +49 -8
- package/dist/esm/model/SubprocessorBridge.js +3 -0
- package/dist/esm/model/ToolCallContinuationCoordinator.js +7 -3
- package/dist/esm/model/UiGraph.js +21 -0
- package/dist/esm/model/UiGraphActionProtocol.js +3 -0
- package/dist/esm/model/UiGraphBrowserRuntime.js +133 -4
- package/dist/esm/model/UiGraphRendererStyles.js +221 -0
- package/dist/esm/model/UiGraphRuntimeModel.js +9 -3
- package/dist/esm/model/UiGraphSchema.js +7 -1
- package/dist/esm/model/chat/aiSdkTools.js +3 -2
- package/dist/esm/model/chat-v2/aiSdkBridge.js +146 -14
- package/dist/esm/model/chat-v2/chatV2CallObserver.js +11 -5
- package/dist/esm/model/chat-v2/chatV2CredentialNames.js +93 -0
- package/dist/esm/model/chat-v2/chatV2EditorCache.js +47 -20
- package/dist/esm/model/chat-v2/chatV2Errors.js +7 -19
- package/dist/esm/model/chat-v2/chatV2FeatureCompatibility.js +1 -1
- package/dist/esm/model/chat-v2/chatV2Outputs.js +48 -108
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +101 -149
- package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +39 -4
- package/dist/esm/model/chat-v2/chatV2ProviderRegistry.js +9 -0
- package/dist/esm/model/chat-v2/chatV2RequestPlan.js +2 -3
- package/dist/esm/model/chat-v2/chatV2ResponseBodyCapture.js +63 -0
- package/dist/esm/model/chat-v2/chatV2ResponseFormat.js +8 -4
- package/dist/esm/model/chat-v2/chatV2Retry.js +4 -3
- package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +7 -7
- package/dist/esm/model/chat-v2/chatV2Shared.js +1 -1
- package/dist/esm/model/chat-v2/chatV2Types.js +20 -8
- package/dist/esm/model/chat-v2/chatV2UsageAccounting.js +78 -0
- package/dist/esm/model/chat-v2/customProviderApi.js +40 -0
- package/dist/esm/model/chat-v2/index.js +15 -0
- package/dist/esm/model/chat-v2/llmChatV2Body.js +289 -0
- package/dist/esm/model/chat-v2/llmChatV2CacheBoundary.js +32 -0
- package/dist/esm/model/chat-v2/llmChatV2CachePolicy.js +25 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeData.js +13 -50
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +117 -24
- package/dist/esm/model/chat-v2/llmChatV2NodeMigration.js +24 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +150 -199
- package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +60 -0
- package/dist/esm/model/chat-v2/llmInvocationDecision.js +11 -0
- package/dist/esm/model/chat-v2/llmInvocationJournal.js +43 -0
- package/dist/esm/model/chat-v2/llmInvocationPlan.js +68 -0
- package/dist/esm/model/chat-v2/llmInvocationProjections.js +5 -0
- package/dist/esm/model/chat-v2/llmInvocationResultProjector.js +48 -0
- package/dist/esm/model/chat-v2/llmModelCandidate.js +79 -0
- package/dist/esm/model/chat-v2/llmProfile.js +52 -65
- package/dist/esm/model/chat-v2/llmProfileBody.js +193 -0
- package/dist/esm/model/chat-v2/llmProfileFallback.js +442 -100
- package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +74 -0
- package/dist/esm/model/chat-v2/llmProfileHealthStore.js +326 -0
- package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +55 -33
- package/dist/esm/model/chat-v2/llmProfileTypes.js +1 -18
- package/dist/esm/model/chat-v2/llmResponseMaterializer.js +42 -0
- package/dist/esm/model/chat-v2/modelRegistry.js +54 -4
- package/dist/esm/model/chat-v2/parallelToolCalls.js +9 -2
- package/dist/esm/model/chat-v2/providerOptions.js +116 -24
- package/dist/esm/model/chat-v2/rivetToolRegistry.js +9 -0
- package/dist/esm/model/chat-v2/toolCallCodec.js +52 -0
- package/dist/esm/model/chat-v2/toolContinuation.js +72 -35
- package/dist/esm/model/chat-v2/toolHandlerResolver.js +23 -0
- package/dist/esm/model/chat-v2/toolRoundExecutor.js +12 -0
- package/dist/esm/model/nodes/ChatNode.js +6 -0
- package/dist/esm/model/nodes/ChatNodeBase.js +1 -0
- package/dist/esm/model/nodes/CodeNewNode.js +5 -47
- package/dist/esm/model/nodes/CodeNode.js +4 -46
- package/dist/esm/model/nodes/DelegateFunctionCallNode.js +19 -6
- package/dist/esm/model/nodes/ExpressionNode.js +5 -8
- package/dist/esm/model/nodes/LLMChatV2Node.js +121 -229
- package/dist/esm/model/nodes/LLMProfileNode.js +27 -8
- package/dist/esm/model/nodes/MatchNode.js +86 -41
- package/dist/esm/model/nodes/PromptNode.js +7 -0
- package/dist/esm/model/nodes/ToolNode.js +7 -0
- package/dist/esm/model/nodes/toolCallDelegation.js +177 -110
- package/dist/esm/plugins/anthropic/anthropic.js +4 -4
- package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +7 -0
- package/dist/esm/plugins/gentrace/gentraceSdk.js +0 -1
- package/dist/esm/plugins/gentrace/index.js +0 -1
- package/dist/esm/plugins/gentrace/plugin.js +61 -179
- package/dist/esm/plugins/google/google.js +5 -9
- package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +4 -1
- package/dist/esm/plugins.js +1 -2
- package/dist/esm/recording/ExecutionRecorder.js +62 -13
- package/dist/esm/utils/emitDetached.js +6 -3
- package/dist/esm/utils/openai.js +60 -16
- package/dist/esm/utils/serialization/serialization.js +2 -19
- package/dist/esm/webAppRuntime.js +3 -2
- package/dist/types/api/createProcessor.d.ts +3 -0
- package/dist/types/exports.d.ts +1 -0
- package/dist/types/integrations/CodeRunner.d.ts +10 -7
- package/dist/types/integrations/CodeRunnerOptions.d.ts +15 -0
- package/dist/types/model/AgentResponseTrace.d.ts +123 -0
- package/dist/types/model/ConnectedToolContinuationHost.d.ts +34 -0
- package/dist/types/model/EditorDefinition.d.ts +16 -0
- package/dist/types/model/ExecutorProtocol.d.ts +32 -11
- package/dist/types/model/GraphProcessor.d.ts +41 -9
- package/dist/types/model/NodeBase.d.ts +0 -10
- package/dist/types/model/NodeImpl.d.ts +18 -1
- package/dist/types/model/Nodes.d.ts +2 -2
- package/dist/types/model/ProcessContext.d.ts +99 -0
- package/dist/types/model/ProcessContextBuilder.d.ts +3 -1
- package/dist/types/model/RecordingPlayer.d.ts +6 -0
- package/dist/types/model/SplitRunProcessor.d.ts +10 -3
- package/dist/types/model/UiGraph.d.ts +8 -0
- package/dist/types/model/UiGraphActionProtocol.d.ts +3 -0
- package/dist/types/model/UiGraphBrowserRuntime.d.ts +11 -2
- package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
- package/dist/types/model/UiGraphRuntimeModel.d.ts +2 -0
- package/dist/types/model/UiGraphSchema.d.ts +1 -0
- package/dist/types/model/chat-v2/chatV2CallObserver.d.ts +2 -0
- package/dist/types/model/chat-v2/chatV2CredentialNames.d.ts +30 -0
- package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +2 -3
- package/dist/types/model/chat-v2/chatV2Outputs.d.ts +6 -16
- package/dist/types/model/chat-v2/chatV2Pipeline.d.ts +13 -17
- package/dist/types/model/chat-v2/chatV2ProviderProfile.d.ts +7 -0
- package/dist/types/model/chat-v2/chatV2ProviderRegistry.d.ts +8 -0
- package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +2 -2
- package/dist/types/model/chat-v2/chatV2ResponseBodyCapture.d.ts +25 -0
- package/dist/types/model/chat-v2/chatV2ResponseFormat.d.ts +3 -2
- package/dist/types/model/chat-v2/chatV2Retry.d.ts +2 -0
- package/dist/types/model/chat-v2/chatV2RuntimeOptions.d.ts +3 -8
- package/dist/types/model/chat-v2/chatV2Types.d.ts +44 -10
- package/dist/types/model/chat-v2/chatV2UsageAccounting.d.ts +14 -0
- package/dist/types/model/chat-v2/customProviderApi.d.ts +22 -0
- package/dist/types/model/chat-v2/index.d.ts +15 -0
- package/dist/types/model/chat-v2/llmChatV2Body.d.ts +24 -0
- package/dist/types/model/chat-v2/llmChatV2CacheBoundary.d.ts +10 -0
- package/dist/types/model/chat-v2/llmChatV2CachePolicy.d.ts +13 -0
- package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +19 -3
- package/dist/types/model/chat-v2/llmChatV2NodeMigration.d.ts +8 -0
- package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +14 -16
- package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +16 -0
- package/dist/types/model/chat-v2/llmInvocationDecision.d.ts +21 -0
- package/dist/types/model/chat-v2/llmInvocationJournal.d.ts +38 -0
- package/dist/types/model/chat-v2/llmInvocationPlan.d.ts +41 -0
- package/dist/types/model/chat-v2/llmInvocationProjections.d.ts +3 -0
- package/dist/types/model/chat-v2/llmInvocationResultProjector.d.ts +26 -0
- package/dist/types/model/chat-v2/llmModelCandidate.d.ts +20 -0
- package/dist/types/model/chat-v2/llmProfile.d.ts +14 -0
- package/dist/types/model/chat-v2/llmProfileBody.d.ts +20 -0
- package/dist/types/model/chat-v2/llmProfileFallback.d.ts +36 -49
- package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +209 -0
- package/dist/types/model/chat-v2/llmProfileHealthStore.d.ts +111 -0
- package/dist/types/model/chat-v2/llmProfileNodeRuntime.d.ts +1 -1
- package/dist/types/model/chat-v2/llmProfileTypes.d.ts +4 -1
- package/dist/types/model/chat-v2/llmResponseMaterializer.d.ts +20 -0
- package/dist/types/model/chat-v2/modelRegistry.d.ts +17 -187
- package/dist/types/model/chat-v2/parallelToolCalls.d.ts +3 -1
- package/dist/types/model/chat-v2/providerOptions.d.ts +12 -0
- package/dist/types/model/chat-v2/rivetToolRegistry.d.ts +11 -0
- package/dist/types/model/chat-v2/toolCallCodec.d.ts +7 -0
- package/dist/types/model/chat-v2/toolContinuation.d.ts +3 -3
- package/dist/types/model/chat-v2/toolHandlerResolver.d.ts +25 -0
- package/dist/types/model/chat-v2/toolRoundExecutor.d.ts +18 -0
- package/dist/types/model/nodes/ChatNode.d.ts +2 -1
- package/dist/types/model/nodes/CodeNewNode.d.ts +0 -5
- package/dist/types/model/nodes/CodeNode.d.ts +0 -5
- package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +2 -1
- package/dist/types/model/nodes/LLMChatV2Node.d.ts +2 -1
- package/dist/types/model/nodes/LLMProfileNode.d.ts +2 -1
- package/dist/types/model/nodes/MatchNode.d.ts +6 -0
- package/dist/types/model/nodes/PromptNode.d.ts +4 -1
- package/dist/types/model/nodes/ToolNode.d.ts +2 -1
- package/dist/types/model/nodes/toolCallDelegation.d.ts +10 -3
- package/dist/types/plugins/anthropic/anthropic.d.ts +1 -0
- package/dist/types/plugins/gentrace/gentraceSdk.d.ts +0 -1
- package/dist/types/plugins/gentrace/plugin.d.ts +55 -9
- package/dist/types/plugins/google/google.d.ts +2 -8
- package/dist/types/plugins.d.ts +1 -1
- package/dist/types/recording/ExecutionRecorder.d.ts +7 -1
- package/dist/types/recording/RecordedEvents.d.ts +6 -0
- package/dist/types/utils/emitDetached.d.ts +3 -2
- package/dist/types/utils/openai.d.ts +49 -0
- package/dist/types/webAppRuntime.d.ts +4 -2
- package/package.json +2 -2
|
@@ -8,8 +8,33 @@ function withOptionalDuration(payload, durationMs, splitRunDurationMs) {
|
|
|
8
8
|
...(splitRunDurationMs === undefined ? {} : { splitRunDurationMs }),
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
+
function withReplayRecordedAt(data, replayRecordedAt) {
|
|
12
|
+
if (typeof replayRecordedAt !== 'number' ||
|
|
13
|
+
!Number.isFinite(replayRecordedAt) ||
|
|
14
|
+
data == null ||
|
|
15
|
+
typeof data !== 'object') {
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
return { ...data, replayRecordedAt };
|
|
19
|
+
}
|
|
20
|
+
const REPLAY_TIMED_LIFECYCLE_EVENTS = new Set([
|
|
21
|
+
'start',
|
|
22
|
+
'graphStart',
|
|
23
|
+
'graphOutputsReady',
|
|
24
|
+
'graphFinish',
|
|
25
|
+
'graphError',
|
|
26
|
+
'graphAbort',
|
|
27
|
+
'nodeStart',
|
|
28
|
+
'userInput',
|
|
29
|
+
'progress',
|
|
30
|
+
'partialOutput',
|
|
31
|
+
'nodeFinish',
|
|
32
|
+
'nodeError',
|
|
33
|
+
'nodeExcluded',
|
|
34
|
+
'nodeOutputsCleared',
|
|
35
|
+
]);
|
|
11
36
|
export async function replayExecutionRecording(options) {
|
|
12
|
-
const { emitter, erroredNodes, graphOutputs, project, recorder, recordingPlaybackChatLatency, setContextValues, setGraphInputs, setGraphOutputs, setRunning, visitedNodes, waitUntilUnpaused, nodeResults, isAborted, } = options;
|
|
37
|
+
const { emitter, erroredNodes, graphOutputs, fallbackGraphId, initialReplayExecution, project, recorder, recordingPlaybackChatLatency, setContextValues, setGraphInputs, setGraphOutputs, setRunning, visitedNodes, waitUntilUnpaused, nodeResults, isAborted, } = options;
|
|
13
38
|
const nodesByIdAllGraphs = {};
|
|
14
39
|
const graphIdByNodeId = {};
|
|
15
40
|
for (const graph of Object.values(project.graphs)) {
|
|
@@ -18,7 +43,64 @@ export async function replayExecutionRecording(options) {
|
|
|
18
43
|
graphIdByNodeId[node.id] = graph.metadata.id;
|
|
19
44
|
}
|
|
20
45
|
}
|
|
21
|
-
|
|
46
|
+
let hasEmittedRunActivityExecution = false;
|
|
47
|
+
let getFallbackExecution;
|
|
48
|
+
let currentReplayRecordedAt;
|
|
49
|
+
const getReplayFallbackGraph = () => {
|
|
50
|
+
const replayTargetGraph = fallbackGraphId == null ? undefined : project.graphs[fallbackGraphId];
|
|
51
|
+
const projectMainGraph = project.metadata.mainGraphId == null ? undefined : project.graphs[project.metadata.mainGraphId];
|
|
52
|
+
return replayTargetGraph ?? projectMainGraph ?? Object.values(project.graphs)[0];
|
|
53
|
+
};
|
|
54
|
+
const emitReplayExecutionEvent = (event, data) => {
|
|
55
|
+
// Run Activity can materialize a root only from an execution-bearing
|
|
56
|
+
// lifecycle or observability event. Remember emitted events so a later
|
|
57
|
+
// playback error remains attached to that root instead of synthesizing a
|
|
58
|
+
// second one.
|
|
59
|
+
hasEmittedRunActivityExecution = true;
|
|
60
|
+
const payload = REPLAY_TIMED_LIFECYCLE_EVENTS.has(event)
|
|
61
|
+
? withReplayRecordedAt(data, currentReplayRecordedAt)
|
|
62
|
+
: data;
|
|
63
|
+
emitDetached(emitter, event, payload);
|
|
64
|
+
};
|
|
65
|
+
const emitReplayTerminalEvent = (event, data) => {
|
|
66
|
+
emitDetached(emitter, event, withReplayRecordedAt(data, currentReplayRecordedAt));
|
|
67
|
+
};
|
|
68
|
+
const emitFallbackRootTerminal = (status, data) => {
|
|
69
|
+
// Older recordings and preflight-error recordings can contain only the
|
|
70
|
+
// unscoped processor terminal. Materialize the current project's root
|
|
71
|
+
// graph once so Run Activity has exact execution identity to attach that
|
|
72
|
+
// terminal confirmation to. Do not add a duplicate when any ordinary
|
|
73
|
+
// graph/node event has already established the replay root.
|
|
74
|
+
if (hasEmittedRunActivityExecution || !getFallbackExecution)
|
|
75
|
+
return;
|
|
76
|
+
const fallbackGraph = getReplayFallbackGraph();
|
|
77
|
+
const fallbackGraphMetadataId = fallbackGraph?.metadata?.id;
|
|
78
|
+
if (!fallbackGraph || !fallbackGraphMetadataId)
|
|
79
|
+
return;
|
|
80
|
+
const execution = getFallbackExecution(fallbackGraphMetadataId);
|
|
81
|
+
if (status === 'completed') {
|
|
82
|
+
emitReplayExecutionEvent('graphFinish', {
|
|
83
|
+
graph: fallbackGraph,
|
|
84
|
+
outputs: data.outputs ?? {},
|
|
85
|
+
execution,
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (status === 'error') {
|
|
90
|
+
emitReplayExecutionEvent('graphError', {
|
|
91
|
+
graph: fallbackGraph,
|
|
92
|
+
error: data.error ?? 'Recording replay failed before graph execution began.',
|
|
93
|
+
execution,
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
emitReplayExecutionEvent('graphAbort', {
|
|
98
|
+
graph: fallbackGraph,
|
|
99
|
+
error: data.error,
|
|
100
|
+
successful: data.successful ?? false,
|
|
101
|
+
execution,
|
|
102
|
+
});
|
|
103
|
+
};
|
|
22
104
|
const getGraph = (graphId) => {
|
|
23
105
|
const graph = project.graphs[graphId];
|
|
24
106
|
if (!graph) {
|
|
@@ -41,12 +123,20 @@ export async function replayExecutionRecording(options) {
|
|
|
41
123
|
return graphId;
|
|
42
124
|
};
|
|
43
125
|
try {
|
|
44
|
-
const legacyRootRunId = nanoid();
|
|
126
|
+
const legacyRootRunId = initialReplayExecution?.rootRunId ?? nanoid();
|
|
45
127
|
const legacyGraphRunsByGraphId = new Map();
|
|
128
|
+
const replayRootRunIds = new Map();
|
|
129
|
+
const replayGraphRunIdsByRoot = new Map();
|
|
46
130
|
const nodeStartTimestamps = new Map();
|
|
47
131
|
const getExecution = (graphId, recordedExecution) => {
|
|
48
132
|
if (recordedExecution) {
|
|
49
|
-
return recordedExecution;
|
|
133
|
+
return getReplayExecution(recordedExecution);
|
|
134
|
+
}
|
|
135
|
+
// Legacy recordings have no execution metadata. Keep the processor's
|
|
136
|
+
// already-allocated selected-graph identity so an external abort during
|
|
137
|
+
// replay terminates the same root instead of creating a second one.
|
|
138
|
+
if (initialReplayExecution?.graphId === graphId) {
|
|
139
|
+
return initialReplayExecution;
|
|
50
140
|
}
|
|
51
141
|
let graphRunId = legacyGraphRunsByGraphId.get(graphId);
|
|
52
142
|
if (!graphRunId) {
|
|
@@ -59,6 +149,44 @@ export async function replayExecutionRecording(options) {
|
|
|
59
149
|
rootRunId: legacyRootRunId,
|
|
60
150
|
};
|
|
61
151
|
};
|
|
152
|
+
getFallbackExecution = (graphId) => getExecution(graphId);
|
|
153
|
+
// A recording describes a past execution, but replay is a new editor run.
|
|
154
|
+
// Reusing recorded identities makes a second playback collide with the
|
|
155
|
+
// journal's terminal root and can leave Run Activity showing stale state.
|
|
156
|
+
// Keep its graph hierarchy intact while assigning fresh replay identity.
|
|
157
|
+
const getReplayExecution = (recordedExecution) => {
|
|
158
|
+
let replayRootRunId = replayRootRunIds.get(recordedExecution.rootRunId);
|
|
159
|
+
if (replayRootRunId == null) {
|
|
160
|
+
// The first recorded root belongs to this playback processor. Later
|
|
161
|
+
// roots remain distinct in malformed or concatenated recordings.
|
|
162
|
+
replayRootRunId =
|
|
163
|
+
replayRootRunIds.size === 0 && initialReplayExecution
|
|
164
|
+
? initialReplayExecution.rootRunId
|
|
165
|
+
: nanoid();
|
|
166
|
+
replayRootRunIds.set(recordedExecution.rootRunId, replayRootRunId);
|
|
167
|
+
}
|
|
168
|
+
const getReplayGraphRunId = (recordedGraphRunId) => {
|
|
169
|
+
let graphRunIds = replayGraphRunIdsByRoot.get(recordedExecution.rootRunId);
|
|
170
|
+
if (graphRunIds == null) {
|
|
171
|
+
graphRunIds = new Map();
|
|
172
|
+
replayGraphRunIdsByRoot.set(recordedExecution.rootRunId, graphRunIds);
|
|
173
|
+
}
|
|
174
|
+
const replayGraphRunId = graphRunIds.get(recordedGraphRunId) ?? nanoid();
|
|
175
|
+
graphRunIds.set(recordedGraphRunId, replayGraphRunId);
|
|
176
|
+
return replayGraphRunId;
|
|
177
|
+
};
|
|
178
|
+
const { rootRunId: _recordedRootRunId, graphRunId, parentGraphRunId, ...rest } = recordedExecution;
|
|
179
|
+
const isInitialRootGraph = initialReplayExecution != null &&
|
|
180
|
+
replayRootRunId === initialReplayExecution.rootRunId &&
|
|
181
|
+
parentGraphRunId == null &&
|
|
182
|
+
rest.graphId === initialReplayExecution.graphId;
|
|
183
|
+
return {
|
|
184
|
+
...rest,
|
|
185
|
+
rootRunId: replayRootRunId,
|
|
186
|
+
graphRunId: isInitialRootGraph ? initialReplayExecution.graphRunId : getReplayGraphRunId(graphRunId),
|
|
187
|
+
...(parentGraphRunId == null ? {} : { parentGraphRunId: getReplayGraphRunId(parentGraphRunId) }),
|
|
188
|
+
};
|
|
189
|
+
};
|
|
62
190
|
const getNodeRunKey = (execution, nodeId, processId) => `${execution.rootRunId}:${execution.graphRunId}:${nodeId}:${processId}`;
|
|
63
191
|
const getRecordedDuration = (recordedDuration, execution, nodeId, processId, terminalTs) => {
|
|
64
192
|
if (recordedDuration !== undefined) {
|
|
@@ -72,10 +200,11 @@ export async function replayExecutionRecording(options) {
|
|
|
72
200
|
break;
|
|
73
201
|
}
|
|
74
202
|
await waitUntilUnpaused();
|
|
203
|
+
currentReplayRecordedAt = event.ts;
|
|
75
204
|
switch (event.type) {
|
|
76
205
|
case 'start': {
|
|
77
206
|
const { data } = event;
|
|
78
|
-
|
|
207
|
+
emitReplayExecutionEvent('start', {
|
|
79
208
|
project,
|
|
80
209
|
contextValues: data.contextValues,
|
|
81
210
|
inputs: data.inputs,
|
|
@@ -87,28 +216,42 @@ export async function replayExecutionRecording(options) {
|
|
|
87
216
|
break;
|
|
88
217
|
}
|
|
89
218
|
case 'abort': {
|
|
90
|
-
|
|
219
|
+
emitFallbackRootTerminal('aborted', event.data);
|
|
220
|
+
emitReplayTerminalEvent('abort', event.data);
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
case 'pause': {
|
|
224
|
+
// A replay does not automatically stop at a historical pause, but
|
|
225
|
+
// observers still need the original lifecycle event to faithfully
|
|
226
|
+
// project the recorded run (including Run Activity's paused state).
|
|
227
|
+
emitDetached(emitter, 'pause', { isReplay: true });
|
|
91
228
|
break;
|
|
92
229
|
}
|
|
93
|
-
case 'pause':
|
|
94
230
|
case 'resume': {
|
|
231
|
+
emitDetached(emitter, 'resume', { isReplay: true });
|
|
95
232
|
break;
|
|
96
233
|
}
|
|
97
234
|
case 'done': {
|
|
98
|
-
|
|
235
|
+
emitFallbackRootTerminal('completed', { outputs: event.data.results });
|
|
236
|
+
emitReplayTerminalEvent('done', event.data);
|
|
99
237
|
setGraphOutputs(event.data.results);
|
|
100
238
|
setRunning(false);
|
|
101
239
|
break;
|
|
102
240
|
}
|
|
103
241
|
case 'error': {
|
|
104
|
-
|
|
242
|
+
emitFallbackRootTerminal('error', event.data);
|
|
243
|
+
emitReplayTerminalEvent('error', event.data);
|
|
105
244
|
break;
|
|
106
245
|
}
|
|
107
246
|
case 'globalSet': {
|
|
108
247
|
const { data } = event;
|
|
248
|
+
const legacyGraphId = data.execution?.graphId ?? getReplayFallbackGraph()?.metadata?.id;
|
|
249
|
+
if (legacyGraphId == null) {
|
|
250
|
+
throw new Error('Cannot replay a global value event because the current project has no graph to attach it to.');
|
|
251
|
+
}
|
|
109
252
|
emitDetached(emitter, 'globalSet', {
|
|
110
253
|
...data,
|
|
111
|
-
execution: getExecution(
|
|
254
|
+
execution: getExecution(legacyGraphId, data.execution),
|
|
112
255
|
});
|
|
113
256
|
break;
|
|
114
257
|
}
|
|
@@ -120,7 +263,7 @@ export async function replayExecutionRecording(options) {
|
|
|
120
263
|
const { data } = event;
|
|
121
264
|
const execution = getExecution(data.graphId, data.execution);
|
|
122
265
|
legacyGraphRunsByGraphId.set(data.graphId, execution.graphRunId);
|
|
123
|
-
|
|
266
|
+
emitReplayExecutionEvent('graphStart', {
|
|
124
267
|
graph: getGraph(data.graphId),
|
|
125
268
|
inputs: data.inputs,
|
|
126
269
|
execution,
|
|
@@ -129,7 +272,7 @@ export async function replayExecutionRecording(options) {
|
|
|
129
272
|
}
|
|
130
273
|
case 'graphFinish': {
|
|
131
274
|
const { data } = event;
|
|
132
|
-
|
|
275
|
+
emitReplayExecutionEvent('graphFinish', {
|
|
133
276
|
graph: getGraph(data.graphId),
|
|
134
277
|
outputs: data.outputs,
|
|
135
278
|
execution: getExecution(data.graphId, data.execution),
|
|
@@ -138,7 +281,7 @@ export async function replayExecutionRecording(options) {
|
|
|
138
281
|
}
|
|
139
282
|
case 'graphOutputsReady': {
|
|
140
283
|
const { data } = event;
|
|
141
|
-
|
|
284
|
+
emitReplayExecutionEvent('graphOutputsReady', {
|
|
142
285
|
graph: getGraph(data.graphId),
|
|
143
286
|
outputs: data.outputs,
|
|
144
287
|
execution: getExecution(data.graphId, data.execution),
|
|
@@ -147,7 +290,7 @@ export async function replayExecutionRecording(options) {
|
|
|
147
290
|
}
|
|
148
291
|
case 'graphError': {
|
|
149
292
|
const { data } = event;
|
|
150
|
-
|
|
293
|
+
emitReplayExecutionEvent('graphError', {
|
|
151
294
|
graph: getGraph(data.graphId),
|
|
152
295
|
error: data.error,
|
|
153
296
|
execution: getExecution(data.graphId, data.execution),
|
|
@@ -156,7 +299,7 @@ export async function replayExecutionRecording(options) {
|
|
|
156
299
|
}
|
|
157
300
|
case 'graphAbort': {
|
|
158
301
|
const { data } = event;
|
|
159
|
-
|
|
302
|
+
emitReplayExecutionEvent('graphAbort', {
|
|
160
303
|
graph: getGraph(data.graphId),
|
|
161
304
|
error: data.error,
|
|
162
305
|
successful: data.successful,
|
|
@@ -169,10 +312,12 @@ export async function replayExecutionRecording(options) {
|
|
|
169
312
|
const node = getNode(data.nodeId);
|
|
170
313
|
const execution = getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution);
|
|
171
314
|
nodeStartTimestamps.set(getNodeRunKey(execution, data.nodeId, data.processId), event.ts);
|
|
172
|
-
|
|
315
|
+
emitReplayExecutionEvent('nodeStart', {
|
|
173
316
|
node,
|
|
174
317
|
inputs: data.inputs,
|
|
318
|
+
...(data.inputConnections === undefined ? {} : { inputConnections: data.inputConnections }),
|
|
175
319
|
processId: data.processId,
|
|
320
|
+
...(data.resultOrigin === undefined ? {} : { resultOrigin: data.resultOrigin }),
|
|
176
321
|
execution,
|
|
177
322
|
});
|
|
178
323
|
if (node.type === 'chat') {
|
|
@@ -184,10 +329,11 @@ export async function replayExecutionRecording(options) {
|
|
|
184
329
|
const { data } = event;
|
|
185
330
|
const node = getNode(data.nodeId);
|
|
186
331
|
const execution = getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution);
|
|
187
|
-
|
|
332
|
+
emitReplayExecutionEvent('nodeFinish', withOptionalDuration({
|
|
188
333
|
node,
|
|
189
334
|
outputs: data.outputs,
|
|
190
335
|
processId: data.processId,
|
|
336
|
+
...(data.resultOrigin === undefined ? {} : { resultOrigin: data.resultOrigin }),
|
|
191
337
|
execution,
|
|
192
338
|
}, getRecordedDuration(data.durationMs, execution, data.nodeId, data.processId, event.ts), data.splitRunDurationMs));
|
|
193
339
|
nodeResults.set(data.nodeId, data.outputs);
|
|
@@ -198,10 +344,11 @@ export async function replayExecutionRecording(options) {
|
|
|
198
344
|
const { data } = event;
|
|
199
345
|
const node = getNode(data.nodeId);
|
|
200
346
|
const execution = getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution);
|
|
201
|
-
|
|
347
|
+
emitReplayExecutionEvent('nodeError', withOptionalDuration({
|
|
202
348
|
node,
|
|
203
349
|
error: data.error,
|
|
204
350
|
processId: data.processId,
|
|
351
|
+
...(data.resultOrigin === undefined ? {} : { resultOrigin: data.resultOrigin }),
|
|
205
352
|
execution,
|
|
206
353
|
}, getRecordedDuration(data.durationMs, execution, data.nodeId, data.processId, event.ts), data.splitRunDurationMs));
|
|
207
354
|
erroredNodes.set(data.nodeId, data.error);
|
|
@@ -211,12 +358,13 @@ export async function replayExecutionRecording(options) {
|
|
|
211
358
|
case 'nodeExcluded': {
|
|
212
359
|
const { data } = event;
|
|
213
360
|
const node = getNode(data.nodeId);
|
|
214
|
-
|
|
361
|
+
emitReplayExecutionEvent('nodeExcluded', {
|
|
215
362
|
node,
|
|
216
363
|
processId: data.processId,
|
|
217
364
|
inputs: data.inputs,
|
|
218
365
|
outputs: data.outputs,
|
|
219
366
|
reason: data.reason,
|
|
367
|
+
...(data.resultOrigin === undefined ? {} : { resultOrigin: data.resultOrigin }),
|
|
220
368
|
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
221
369
|
});
|
|
222
370
|
visitedNodes.add(data.nodeId);
|
|
@@ -228,7 +376,7 @@ export async function replayExecutionRecording(options) {
|
|
|
228
376
|
if (data.processId == null) {
|
|
229
377
|
nodeResults.delete(data.nodeId);
|
|
230
378
|
}
|
|
231
|
-
|
|
379
|
+
emitReplayExecutionEvent('nodeOutputsCleared', {
|
|
232
380
|
node,
|
|
233
381
|
processId: data.processId,
|
|
234
382
|
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
@@ -238,18 +386,19 @@ export async function replayExecutionRecording(options) {
|
|
|
238
386
|
case 'partialOutput': {
|
|
239
387
|
const { data } = event;
|
|
240
388
|
const node = getNode(data.nodeId);
|
|
241
|
-
|
|
389
|
+
emitReplayExecutionEvent('partialOutput', {
|
|
242
390
|
node,
|
|
243
391
|
outputs: data.outputs,
|
|
244
392
|
index: data.index,
|
|
245
393
|
processId: data.processId,
|
|
394
|
+
...(data.resultOrigin === undefined ? {} : { resultOrigin: data.resultOrigin }),
|
|
246
395
|
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
247
396
|
});
|
|
248
397
|
break;
|
|
249
398
|
}
|
|
250
399
|
case 'progress': {
|
|
251
400
|
const { data } = event;
|
|
252
|
-
|
|
401
|
+
emitReplayExecutionEvent('progress', {
|
|
253
402
|
node: getNode(data.nodeId),
|
|
254
403
|
processId: data.processId,
|
|
255
404
|
progress: data.progress,
|
|
@@ -257,13 +406,41 @@ export async function replayExecutionRecording(options) {
|
|
|
257
406
|
});
|
|
258
407
|
break;
|
|
259
408
|
}
|
|
409
|
+
case 'llmCallFinished': {
|
|
410
|
+
const { data } = event;
|
|
411
|
+
emitReplayExecutionEvent('llmCallFinished', {
|
|
412
|
+
...data,
|
|
413
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
414
|
+
});
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
case 'llmProfileAttempt': {
|
|
418
|
+
const { data } = event;
|
|
419
|
+
emitReplayExecutionEvent('llmProfileAttempt', {
|
|
420
|
+
...data,
|
|
421
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
422
|
+
});
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
case 'toolCallFinished': {
|
|
426
|
+
const { data } = event;
|
|
427
|
+
emitReplayExecutionEvent('toolCallFinished', {
|
|
428
|
+
...data,
|
|
429
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.sourceNodeId), data.execution),
|
|
430
|
+
});
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
260
433
|
case 'userInput': {
|
|
261
434
|
const { data } = event;
|
|
262
435
|
const node = getNode(data.nodeId);
|
|
263
|
-
|
|
264
|
-
|
|
436
|
+
emitReplayExecutionEvent('userInput', {
|
|
437
|
+
// A replayed prompt is historical and must not wait for a new
|
|
438
|
+
// answer, but listeners still receive a safe callback-shaped
|
|
439
|
+
// event for compatibility with ordinary user-input observers.
|
|
440
|
+
callback: () => undefined,
|
|
265
441
|
inputStrings: data.inputStrings,
|
|
266
442
|
inputs: data.inputs,
|
|
443
|
+
isReplay: true,
|
|
267
444
|
node,
|
|
268
445
|
processId: data.processId,
|
|
269
446
|
renderingType: data.renderingType,
|
|
@@ -292,7 +469,17 @@ export async function replayExecutionRecording(options) {
|
|
|
292
469
|
}
|
|
293
470
|
}
|
|
294
471
|
catch (error) {
|
|
295
|
-
|
|
472
|
+
const replayError = getError(error);
|
|
473
|
+
// A recording can fail before its first graph/node event, for example when
|
|
474
|
+
// it refers to a graph that no longer exists in the loaded project. The
|
|
475
|
+
// normal root-level `error` event is intentionally unscoped, so Run
|
|
476
|
+
// Activity has no active root to attach it to in that case.
|
|
477
|
+
emitFallbackRootTerminal('error', { error: replayError });
|
|
478
|
+
// This is a fresh playback failure, not a historical event from the last
|
|
479
|
+
// successful dispatch. Do not accidentally attribute it to that event's
|
|
480
|
+
// recording timestamp.
|
|
481
|
+
currentReplayRecordedAt = undefined;
|
|
482
|
+
emitReplayTerminalEvent('error', { error: replayError });
|
|
296
483
|
}
|
|
297
484
|
finally {
|
|
298
485
|
setRunning(false);
|
|
@@ -23,11 +23,17 @@ export async function processSplitRunNode(node, processId, deps) {
|
|
|
23
23
|
: Array.isArray(value?.value)
|
|
24
24
|
? value.value.length
|
|
25
25
|
: 1)) ?? 1, node.splitRunMax ?? 10);
|
|
26
|
-
await deps.emit('nodeStart', {
|
|
26
|
+
await deps.emit('nodeStart', {
|
|
27
|
+
node,
|
|
28
|
+
inputs: inputValues,
|
|
29
|
+
inputConnections: deps.getInputConnections(node),
|
|
30
|
+
processId,
|
|
31
|
+
resultOrigin: 'executed',
|
|
32
|
+
});
|
|
27
33
|
const timingStart = deps.startNodeTiming?.();
|
|
28
34
|
let splitRunDurationMs;
|
|
35
|
+
let results = [];
|
|
29
36
|
try {
|
|
30
|
-
let results;
|
|
31
37
|
if (node.isSplitSequential) {
|
|
32
38
|
results = await runSequential(node, inputValues, inputDefinitionsById, splittingAmount, processId, deps);
|
|
33
39
|
}
|
|
@@ -52,10 +58,11 @@ export async function processSplitRunNode(node, processId, deps) {
|
|
|
52
58
|
node,
|
|
53
59
|
outputs: aggregateResults,
|
|
54
60
|
processId,
|
|
61
|
+
resultOrigin: getSplitRunResultOrigin(results),
|
|
55
62
|
}, deps.finishNodeTiming?.(timingStart), splitRunDurationMs));
|
|
56
63
|
}
|
|
57
64
|
catch (error) {
|
|
58
|
-
await deps.nodeErrored(node, error, processId, deps.finishNodeTiming?.(timingStart), splitRunDurationMs);
|
|
65
|
+
await deps.nodeErrored(node, error, processId, deps.finishNodeTiming?.(timingStart), splitRunDurationMs, getSplitRunResultOrigin(results));
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
68
|
async function runSequential(node, inputValues, inputDefinitionsById, splittingAmount, processId, deps) {
|
|
@@ -66,15 +73,29 @@ async function runSequential(node, inputValues, inputDefinitionsById, splittingA
|
|
|
66
73
|
}
|
|
67
74
|
const inputs = splitInputsAtIndex(inputValues, inputDefinitionsById, i);
|
|
68
75
|
const splitTimingStart = deps.startNodeTiming?.();
|
|
76
|
+
let resultOrigin = 'executed';
|
|
69
77
|
try {
|
|
70
78
|
const output = await deps.processNodeWithInputData(node, inputs, i, processId, (n, partialOutputs, index) => {
|
|
71
|
-
deps.emit('partialOutput', {
|
|
79
|
+
deps.emit('partialOutput', {
|
|
80
|
+
node: n,
|
|
81
|
+
outputs: partialOutputs,
|
|
82
|
+
index,
|
|
83
|
+
processId,
|
|
84
|
+
resultOrigin: 'executed',
|
|
85
|
+
});
|
|
86
|
+
}, () => {
|
|
87
|
+
resultOrigin = 'editor-cache';
|
|
72
88
|
});
|
|
73
89
|
deps.accumulateCost(output);
|
|
74
|
-
results.push({ type: 'output', output, durationMs: deps.finishNodeTiming?.(splitTimingStart) });
|
|
90
|
+
results.push({ type: 'output', output, resultOrigin, durationMs: deps.finishNodeTiming?.(splitTimingStart) });
|
|
75
91
|
}
|
|
76
92
|
catch (error) {
|
|
77
|
-
results.push({
|
|
93
|
+
results.push({
|
|
94
|
+
type: 'error',
|
|
95
|
+
error: getError(error),
|
|
96
|
+
resultOrigin,
|
|
97
|
+
durationMs: deps.finishNodeTiming?.(splitTimingStart),
|
|
98
|
+
});
|
|
78
99
|
}
|
|
79
100
|
}
|
|
80
101
|
return results;
|
|
@@ -84,21 +105,36 @@ async function runParallel(node, inputValues, inputDefinitionsById, splittingAmo
|
|
|
84
105
|
return Promise.all(range(0, splittingAmount).map(async (i) => {
|
|
85
106
|
const result = await queue.add(async () => {
|
|
86
107
|
const splitTimingStart = deps.startNodeTiming?.();
|
|
108
|
+
let resultOrigin = 'executed';
|
|
87
109
|
try {
|
|
88
110
|
if (deps.isAborted()) {
|
|
89
111
|
throw deps.getAbortError();
|
|
90
112
|
}
|
|
91
113
|
const inputs = splitInputsAtIndex(inputValues, inputDefinitionsById, i);
|
|
92
114
|
const output = await deps.processNodeWithInputData(node, inputs, i, processId, (n, partialOutputs, index) => {
|
|
93
|
-
deps.emit('partialOutput', {
|
|
115
|
+
deps.emit('partialOutput', {
|
|
116
|
+
node: n,
|
|
117
|
+
outputs: partialOutputs,
|
|
118
|
+
index,
|
|
119
|
+
processId,
|
|
120
|
+
resultOrigin: 'executed',
|
|
121
|
+
});
|
|
122
|
+
}, () => {
|
|
123
|
+
resultOrigin = 'editor-cache';
|
|
94
124
|
});
|
|
95
125
|
deps.accumulateCost(output);
|
|
96
|
-
return {
|
|
126
|
+
return {
|
|
127
|
+
type: 'output',
|
|
128
|
+
output,
|
|
129
|
+
resultOrigin,
|
|
130
|
+
durationMs: deps.finishNodeTiming?.(splitTimingStart),
|
|
131
|
+
};
|
|
97
132
|
}
|
|
98
133
|
catch (error) {
|
|
99
134
|
return {
|
|
100
135
|
type: 'error',
|
|
101
136
|
error: getError(error),
|
|
137
|
+
resultOrigin,
|
|
102
138
|
durationMs: deps.finishNodeTiming?.(splitTimingStart),
|
|
103
139
|
};
|
|
104
140
|
}
|
|
@@ -109,6 +145,11 @@ async function runParallel(node, inputValues, inputDefinitionsById, splittingAmo
|
|
|
109
145
|
return result;
|
|
110
146
|
}));
|
|
111
147
|
}
|
|
148
|
+
function getSplitRunResultOrigin(results) {
|
|
149
|
+
return results.length > 0 && results.every((result) => result.resultOrigin === 'editor-cache')
|
|
150
|
+
? 'editor-cache'
|
|
151
|
+
: 'executed';
|
|
152
|
+
}
|
|
112
153
|
function getParallelSplitRunConcurrency(node, defaultConcurrency) {
|
|
113
154
|
const value = node.splitRunConcurrency;
|
|
114
155
|
return typeof value === 'number' && Number.isFinite(value) && value >= 2 ? Math.floor(value) : defaultConcurrency;
|
|
@@ -29,6 +29,9 @@ export function wireSubprocessorEvents(processor, parentEmitter, parentState) {
|
|
|
29
29
|
processor.on('nodeFinish', (event) => parentEmitter.emit('nodeFinish', event)),
|
|
30
30
|
processor.on('partialOutput', (event) => parentEmitter.emit('partialOutput', event)),
|
|
31
31
|
processor.on('progress', (event) => parentEmitter.emit('progress', event)),
|
|
32
|
+
processor.on('llmCallFinished', (event) => parentEmitter.emit('llmCallFinished', event)),
|
|
33
|
+
processor.on('llmProfileAttempt', (event) => parentEmitter.emit('llmProfileAttempt', event)),
|
|
34
|
+
processor.on('toolCallFinished', (event) => parentEmitter.emit('toolCallFinished', event)),
|
|
32
35
|
processor.on('nodeExcluded', (event) => parentEmitter.emit('nodeExcluded', event)),
|
|
33
36
|
processor.on('nodeStart', (event) => parentEmitter.emit('nodeStart', event)),
|
|
34
37
|
processor.on('graphAbort', (event) => parentEmitter.emit('graphAbort', event)),
|
|
@@ -63,8 +63,11 @@ export class ToolCallContinuationCoordinator {
|
|
|
63
63
|
const continuationBranchBoundaries = new Set(this.#adapter.getContinuationBranchBoundaryNodeIds(llmNode));
|
|
64
64
|
// Validate the complete round before parallel calls can cause side effects.
|
|
65
65
|
// The first invocation still produces a real Delegate error run for diagnostics.
|
|
66
|
+
let invalidInvocationIndex = 0;
|
|
66
67
|
try {
|
|
67
|
-
|
|
68
|
+
const frozenInvocationIndex = inputsByCall.findIndex((inputs, index) => this.#adapter.hasPreloadedOrFrozenDelegateOutput(delegateNode, inputs, processIds[index]));
|
|
69
|
+
if (frozenInvocationIndex >= 0) {
|
|
70
|
+
invalidInvocationIndex = frozenInvocationIndex;
|
|
68
71
|
throw new Error(`Delegate Tool Call "${delegateNode.title}" is the active auto-continuation handler and cannot use preloaded or frozen outputs. Clear its preload or unfreeze it before running this graph.`);
|
|
69
72
|
}
|
|
70
73
|
if (hasActivePreToolBranch) {
|
|
@@ -80,8 +83,8 @@ export class ToolCallContinuationCoordinator {
|
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
catch (error) {
|
|
83
|
-
const processId = processIds[
|
|
84
|
-
const inputs = inputsByCall[
|
|
86
|
+
const processId = processIds[invalidInvocationIndex];
|
|
87
|
+
const inputs = inputsByCall[invalidInvocationIndex];
|
|
85
88
|
await this.#adapter.emitDelegateStart(delegateNode, inputs, processId);
|
|
86
89
|
await this.#adapter.emitDelegateError(delegateNode, error, processId, this.#adapter.startNodeTiming());
|
|
87
90
|
throw error;
|
|
@@ -157,6 +160,7 @@ export class ToolCallContinuationCoordinator {
|
|
|
157
160
|
'tool-name',
|
|
158
161
|
'tool-arguments',
|
|
159
162
|
'output',
|
|
163
|
+
'execution-time',
|
|
160
164
|
'message',
|
|
161
165
|
]),
|
|
162
166
|
availableNodeOutputs: preToolBranch.nodeOutputs,
|
|
@@ -156,6 +156,27 @@ export function createUiGraphChatPinStatePatch(componentId, state, messageIndex)
|
|
|
156
156
|
: [...pinnedIndexes, messageIndex].sort((left, right) => left - right),
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Removes one persisted Chat message and keeps pinned assistant indexes aligned
|
|
161
|
+
* with the remaining history. Removing a pinned response unpins it.
|
|
162
|
+
*/
|
|
163
|
+
export function createUiGraphChatMessageRemovalStatePatch(componentId, state, messageIndex) {
|
|
164
|
+
const messages = getUiGraphChatMessages(componentId, state);
|
|
165
|
+
if (!Number.isSafeInteger(messageIndex) || messageIndex < 0 || messageIndex >= messages.length) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
const pinsStateKey = getUiGraphChatPinsStateKey(componentId);
|
|
169
|
+
const pinnedIndexes = getUiGraphChatPins(componentId, state).map((pin) => pin.messageIndex);
|
|
170
|
+
const remainingPinnedIndexes = pinnedIndexes.flatMap((pinnedIndex) => {
|
|
171
|
+
if (pinnedIndex === messageIndex)
|
|
172
|
+
return [];
|
|
173
|
+
return [pinnedIndex > messageIndex ? pinnedIndex - 1 : pinnedIndex];
|
|
174
|
+
});
|
|
175
|
+
return {
|
|
176
|
+
[getUiGraphChatMessagesStateKey(componentId)]: messages.filter((_message, index) => index !== messageIndex),
|
|
177
|
+
[pinsStateKey]: remainingPinnedIndexes,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
159
180
|
/** Clears a Chat's conversation and pins without discarding an unsent draft. */
|
|
160
181
|
export function createUiGraphChatHistoryFlushStatePatch(componentId) {
|
|
161
182
|
return {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeGraphProgress } from './GraphProgress.js';
|
|
2
|
+
import { isAgentResponseTrace } from './AgentResponseTrace.js';
|
|
2
3
|
export const RIVET_WEB_APP_ACTION_PROTOCOL_VERSION = 1;
|
|
3
4
|
export function parseRivetWebAppClientMessage(value) {
|
|
4
5
|
if (!isRecord(value) || typeof value.type !== 'string')
|
|
@@ -93,6 +94,7 @@ export function parseRivetWebAppServerMessage(value) {
|
|
|
93
94
|
...base,
|
|
94
95
|
statePatch: value.statePatch,
|
|
95
96
|
...(isRecord(value.storagePatch) ? { storagePatch: value.storagePatch } : {}),
|
|
97
|
+
...(isAgentResponseTrace(value.responseTrace) ? { responseTrace: value.responseTrace } : {}),
|
|
96
98
|
}
|
|
97
99
|
: undefined;
|
|
98
100
|
case 'action.failed':
|
|
@@ -102,6 +104,7 @@ export function parseRivetWebAppServerMessage(value) {
|
|
|
102
104
|
...base,
|
|
103
105
|
error: value.error,
|
|
104
106
|
...(typeof value.code === 'string' ? { code: value.code } : {}),
|
|
107
|
+
...(isAgentResponseTrace(value.responseTrace) ? { responseTrace: value.responseTrace } : {}),
|
|
105
108
|
}
|
|
106
109
|
: undefined;
|
|
107
110
|
case 'action.interrupted':
|