@valerypopoff/rivet2-core 2.1.9 → 2.1.10

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 (155) hide show
  1. package/dist/cjs/bundle.cjs +3596 -1745
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/cjs/webAppRuntime.cjs +298 -21
  4. package/dist/cjs/webAppRuntime.cjs.map +4 -4
  5. package/dist/esm/exports.js +1 -0
  6. package/dist/esm/model/AgentResponseTrace.js +448 -0
  7. package/dist/esm/model/ConnectedToolContinuationHost.js +33 -0
  8. package/dist/esm/model/GraphProcessor.js +151 -74
  9. package/dist/esm/model/NodeImpl.js +6 -0
  10. package/dist/esm/model/ProcessContextBuilder.js +3 -1
  11. package/dist/esm/model/RecordingPlayer.js +164 -22
  12. package/dist/esm/model/SplitRunProcessor.js +49 -8
  13. package/dist/esm/model/SubprocessorBridge.js +2 -0
  14. package/dist/esm/model/ToolCallContinuationCoordinator.js +7 -3
  15. package/dist/esm/model/UiGraph.js +21 -0
  16. package/dist/esm/model/UiGraphActionProtocol.js +2 -0
  17. package/dist/esm/model/UiGraphBrowserRuntime.js +133 -4
  18. package/dist/esm/model/UiGraphRendererStyles.js +221 -0
  19. package/dist/esm/model/UiGraphRuntimeModel.js +9 -3
  20. package/dist/esm/model/UiGraphSchema.js +7 -1
  21. package/dist/esm/model/chat/aiSdkTools.js +3 -2
  22. package/dist/esm/model/chat-v2/chatV2CallObserver.js +9 -5
  23. package/dist/esm/model/chat-v2/chatV2EditorCache.js +42 -16
  24. package/dist/esm/model/chat-v2/chatV2Errors.js +7 -19
  25. package/dist/esm/model/chat-v2/chatV2FeatureCompatibility.js +1 -1
  26. package/dist/esm/model/chat-v2/chatV2Outputs.js +48 -108
  27. package/dist/esm/model/chat-v2/chatV2Pipeline.js +61 -146
  28. package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +8 -2
  29. package/dist/esm/model/chat-v2/chatV2ProviderRegistry.js +9 -0
  30. package/dist/esm/model/chat-v2/chatV2RequestPlan.js +2 -3
  31. package/dist/esm/model/chat-v2/chatV2ResponseBodyCapture.js +55 -0
  32. package/dist/esm/model/chat-v2/chatV2ResponseFormat.js +8 -4
  33. package/dist/esm/model/chat-v2/chatV2Retry.js +4 -3
  34. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +6 -1
  35. package/dist/esm/model/chat-v2/chatV2Types.js +5 -9
  36. package/dist/esm/model/chat-v2/chatV2UsageAccounting.js +78 -0
  37. package/dist/esm/model/chat-v2/customProviderApi.js +42 -0
  38. package/dist/esm/model/chat-v2/index.js +12 -0
  39. package/dist/esm/model/chat-v2/llmChatV2Body.js +281 -0
  40. package/dist/esm/model/chat-v2/llmChatV2CacheBoundary.js +32 -0
  41. package/dist/esm/model/chat-v2/llmChatV2CachePolicy.js +20 -0
  42. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +6 -50
  43. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +25 -13
  44. package/dist/esm/model/chat-v2/llmChatV2NodeMigration.js +24 -0
  45. package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +121 -193
  46. package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +60 -0
  47. package/dist/esm/model/chat-v2/llmInvocationDecision.js +11 -0
  48. package/dist/esm/model/chat-v2/llmInvocationJournal.js +43 -0
  49. package/dist/esm/model/chat-v2/llmInvocationPlan.js +68 -0
  50. package/dist/esm/model/chat-v2/llmInvocationProjections.js +5 -0
  51. package/dist/esm/model/chat-v2/llmInvocationResultProjector.js +48 -0
  52. package/dist/esm/model/chat-v2/llmModelCandidate.js +75 -0
  53. package/dist/esm/model/chat-v2/llmProfile.js +10 -65
  54. package/dist/esm/model/chat-v2/llmProfileBody.js +183 -0
  55. package/dist/esm/model/chat-v2/llmProfileFallback.js +55 -99
  56. package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +67 -0
  57. package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +3 -0
  58. package/dist/esm/model/chat-v2/llmProfileTypes.js +1 -18
  59. package/dist/esm/model/chat-v2/llmResponseMaterializer.js +42 -0
  60. package/dist/esm/model/chat-v2/modelRegistry.js +54 -4
  61. package/dist/esm/model/chat-v2/parallelToolCalls.js +9 -2
  62. package/dist/esm/model/chat-v2/providerOptions.js +86 -20
  63. package/dist/esm/model/chat-v2/rivetToolRegistry.js +9 -0
  64. package/dist/esm/model/chat-v2/toolCallCodec.js +52 -0
  65. package/dist/esm/model/chat-v2/toolContinuation.js +72 -35
  66. package/dist/esm/model/chat-v2/toolHandlerResolver.js +23 -0
  67. package/dist/esm/model/chat-v2/toolRoundExecutor.js +12 -0
  68. package/dist/esm/model/nodes/ChatNode.js +6 -0
  69. package/dist/esm/model/nodes/ChatNodeBase.js +1 -0
  70. package/dist/esm/model/nodes/DelegateFunctionCallNode.js +19 -6
  71. package/dist/esm/model/nodes/LLMChatV2Node.js +112 -229
  72. package/dist/esm/model/nodes/LLMProfileNode.js +27 -8
  73. package/dist/esm/model/nodes/PromptNode.js +7 -0
  74. package/dist/esm/model/nodes/ToolNode.js +7 -0
  75. package/dist/esm/model/nodes/toolCallDelegation.js +177 -110
  76. package/dist/esm/plugins/anthropic/anthropic.js +4 -4
  77. package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +7 -0
  78. package/dist/esm/plugins/google/google.js +5 -9
  79. package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +4 -1
  80. package/dist/esm/recording/ExecutionRecorder.js +13 -5
  81. package/dist/esm/utils/emitDetached.js +6 -3
  82. package/dist/esm/utils/openai.js +60 -16
  83. package/dist/esm/utils/serialization/serialization.js +2 -19
  84. package/dist/esm/webAppRuntime.js +3 -2
  85. package/dist/types/exports.d.ts +1 -0
  86. package/dist/types/model/AgentResponseTrace.d.ts +110 -0
  87. package/dist/types/model/ConnectedToolContinuationHost.d.ts +34 -0
  88. package/dist/types/model/ExecutorProtocol.d.ts +25 -7
  89. package/dist/types/model/GraphProcessor.d.ts +27 -5
  90. package/dist/types/model/NodeImpl.d.ts +18 -1
  91. package/dist/types/model/Nodes.d.ts +2 -2
  92. package/dist/types/model/ProcessContext.d.ts +47 -0
  93. package/dist/types/model/ProcessContextBuilder.d.ts +3 -1
  94. package/dist/types/model/RecordingPlayer.d.ts +6 -0
  95. package/dist/types/model/SplitRunProcessor.d.ts +10 -3
  96. package/dist/types/model/UiGraph.d.ts +8 -0
  97. package/dist/types/model/UiGraphActionProtocol.d.ts +2 -0
  98. package/dist/types/model/UiGraphBrowserRuntime.d.ts +11 -2
  99. package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
  100. package/dist/types/model/UiGraphRuntimeModel.d.ts +2 -0
  101. package/dist/types/model/UiGraphSchema.d.ts +1 -0
  102. package/dist/types/model/chat-v2/chatV2CallObserver.d.ts +2 -0
  103. package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +1 -3
  104. package/dist/types/model/chat-v2/chatV2Outputs.d.ts +6 -16
  105. package/dist/types/model/chat-v2/chatV2Pipeline.d.ts +13 -17
  106. package/dist/types/model/chat-v2/chatV2ProviderProfile.d.ts +4 -0
  107. package/dist/types/model/chat-v2/chatV2ProviderRegistry.d.ts +8 -0
  108. package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +2 -2
  109. package/dist/types/model/chat-v2/chatV2ResponseBodyCapture.d.ts +19 -0
  110. package/dist/types/model/chat-v2/chatV2ResponseFormat.d.ts +3 -2
  111. package/dist/types/model/chat-v2/chatV2Retry.d.ts +2 -0
  112. package/dist/types/model/chat-v2/chatV2Types.d.ts +20 -10
  113. package/dist/types/model/chat-v2/chatV2UsageAccounting.d.ts +14 -0
  114. package/dist/types/model/chat-v2/customProviderApi.d.ts +23 -0
  115. package/dist/types/model/chat-v2/index.d.ts +12 -0
  116. package/dist/types/model/chat-v2/llmChatV2Body.d.ts +24 -0
  117. package/dist/types/model/chat-v2/llmChatV2CacheBoundary.d.ts +10 -0
  118. package/dist/types/model/chat-v2/llmChatV2CachePolicy.d.ts +13 -0
  119. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +10 -3
  120. package/dist/types/model/chat-v2/llmChatV2NodeMigration.d.ts +8 -0
  121. package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +14 -16
  122. package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +16 -0
  123. package/dist/types/model/chat-v2/llmInvocationDecision.d.ts +21 -0
  124. package/dist/types/model/chat-v2/llmInvocationJournal.d.ts +38 -0
  125. package/dist/types/model/chat-v2/llmInvocationPlan.d.ts +41 -0
  126. package/dist/types/model/chat-v2/llmInvocationProjections.d.ts +3 -0
  127. package/dist/types/model/chat-v2/llmInvocationResultProjector.d.ts +26 -0
  128. package/dist/types/model/chat-v2/llmModelCandidate.d.ts +18 -0
  129. package/dist/types/model/chat-v2/llmProfileBody.d.ts +20 -0
  130. package/dist/types/model/chat-v2/llmProfileFallback.d.ts +17 -49
  131. package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +189 -0
  132. package/dist/types/model/chat-v2/llmProfileTypes.d.ts +1 -1
  133. package/dist/types/model/chat-v2/llmResponseMaterializer.d.ts +20 -0
  134. package/dist/types/model/chat-v2/modelRegistry.d.ts +17 -187
  135. package/dist/types/model/chat-v2/parallelToolCalls.d.ts +3 -1
  136. package/dist/types/model/chat-v2/providerOptions.d.ts +10 -0
  137. package/dist/types/model/chat-v2/rivetToolRegistry.d.ts +11 -0
  138. package/dist/types/model/chat-v2/toolCallCodec.d.ts +7 -0
  139. package/dist/types/model/chat-v2/toolContinuation.d.ts +3 -3
  140. package/dist/types/model/chat-v2/toolHandlerResolver.d.ts +25 -0
  141. package/dist/types/model/chat-v2/toolRoundExecutor.d.ts +18 -0
  142. package/dist/types/model/nodes/ChatNode.d.ts +2 -1
  143. package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +2 -1
  144. package/dist/types/model/nodes/LLMChatV2Node.d.ts +2 -1
  145. package/dist/types/model/nodes/LLMProfileNode.d.ts +2 -1
  146. package/dist/types/model/nodes/PromptNode.d.ts +4 -1
  147. package/dist/types/model/nodes/ToolNode.d.ts +2 -1
  148. package/dist/types/model/nodes/toolCallDelegation.d.ts +10 -3
  149. package/dist/types/plugins/anthropic/anthropic.d.ts +1 -0
  150. package/dist/types/plugins/google/google.d.ts +2 -8
  151. package/dist/types/recording/RecordedEvents.d.ts +6 -0
  152. package/dist/types/utils/emitDetached.d.ts +3 -2
  153. package/dist/types/utils/openai.d.ts +49 -0
  154. package/dist/types/webAppRuntime.d.ts +4 -2
  155. package/package.json +2 -2
@@ -6,11 +6,55 @@ export const defaultOpenaiSupported = {
6
6
  parallelFunctionCalls: true,
7
7
  };
8
8
  export const openaiModels = {
9
+ 'gpt-5.6': {
10
+ maxTokens: 1_050_000,
11
+ cost: {
12
+ prompt: 0.005,
13
+ completion: 0.03,
14
+ },
15
+ displayName: 'GPT-5.6',
16
+ supported: {
17
+ parallelFunctionCalls: true,
18
+ },
19
+ },
20
+ 'gpt-5.6-sol': {
21
+ maxTokens: 1_050_000,
22
+ cost: {
23
+ prompt: 0.005,
24
+ completion: 0.03,
25
+ },
26
+ displayName: 'GPT-5.6 Sol',
27
+ supported: {
28
+ parallelFunctionCalls: true,
29
+ },
30
+ },
31
+ 'gpt-5.6-terra': {
32
+ maxTokens: 1_050_000,
33
+ cost: {
34
+ prompt: 0.002,
35
+ completion: 0.012,
36
+ },
37
+ displayName: 'GPT-5.6 Terra',
38
+ supported: {
39
+ parallelFunctionCalls: true,
40
+ },
41
+ },
42
+ 'gpt-5.6-luna': {
43
+ maxTokens: 1_050_000,
44
+ cost: {
45
+ prompt: 0.0002,
46
+ completion: 0.0012,
47
+ },
48
+ displayName: 'GPT-5.6 Luna',
49
+ supported: {
50
+ parallelFunctionCalls: true,
51
+ },
52
+ },
9
53
  'gpt-5': {
10
54
  maxTokens: 400000,
11
55
  cost: {
12
- prompt: 1.25e-6,
13
- completion: 10e-6,
56
+ prompt: 1.25e-3,
57
+ completion: 0.01,
14
58
  },
15
59
  displayName: 'GPT-5',
16
60
  supported: {
@@ -20,8 +64,8 @@ export const openaiModels = {
20
64
  'gpt-5-mini': {
21
65
  maxTokens: 400000,
22
66
  cost: {
23
- prompt: 0.25 - 6,
24
- completion: 2e-6,
67
+ prompt: 0.25e-3,
68
+ completion: 0.002,
25
69
  },
26
70
  displayName: 'GPT-5 mini',
27
71
  supported: {
@@ -31,8 +75,8 @@ export const openaiModels = {
31
75
  'gpt-5-nano': {
32
76
  maxTokens: 400000,
33
77
  cost: {
34
- prompt: 0.05e-6,
35
- completion: 0.4e-6,
78
+ prompt: 0.05e-3,
79
+ completion: 0.0004,
36
80
  },
37
81
  displayName: 'GPT-5 nano',
38
82
  supported: {
@@ -42,8 +86,8 @@ export const openaiModels = {
42
86
  'gpt-4o': {
43
87
  maxTokens: 128000,
44
88
  cost: {
45
- prompt: 0.005,
46
- completion: 0.015,
89
+ prompt: 0.0025,
90
+ completion: 0.01,
47
91
  },
48
92
  displayName: 'GPT-4o',
49
93
  },
@@ -51,7 +95,7 @@ export const openaiModels = {
51
95
  maxTokens: 128000,
52
96
  cost: {
53
97
  prompt: 0.00015,
54
- completion: 0.00075,
98
+ completion: 0.0006,
55
99
  },
56
100
  displayName: 'GPT-4o mini',
57
101
  },
@@ -59,7 +103,7 @@ export const openaiModels = {
59
103
  maxTokens: 128000,
60
104
  cost: {
61
105
  prompt: 0.015,
62
- completion: 0.6,
106
+ completion: 0.06,
63
107
  },
64
108
  displayName: 'o1',
65
109
  supported: {
@@ -101,24 +145,24 @@ export const openaiModels = {
101
145
  'gpt-4.1': {
102
146
  maxTokens: 1_047_576,
103
147
  cost: {
104
- prompt: 2e-6,
105
- completion: 8e-6,
148
+ prompt: 0.002,
149
+ completion: 0.008,
106
150
  },
107
151
  displayName: 'GPT-4.1',
108
152
  },
109
153
  o3: {
110
154
  maxTokens: 200_000,
111
155
  cost: {
112
- prompt: 10e-6,
113
- completion: 40e-6,
156
+ prompt: 0.01,
157
+ completion: 0.04,
114
158
  },
115
159
  displayName: 'o3',
116
160
  },
117
161
  'o4-mini': {
118
162
  maxTokens: 200_000,
119
163
  cost: {
120
- prompt: 1.1e-6,
121
- completion: 4.4e-6,
164
+ prompt: 0.0011,
165
+ completion: 0.0044,
122
166
  },
123
167
  displayName: 'o4-mini',
124
168
  },
@@ -8,6 +8,7 @@ import { UiGraphNormalizationError } from '../../model/UiGraphNormalization.js';
8
8
  import { datasetV4Deserializer, datasetV4Serializer, graphV4Deserializer, graphV4Serializer, projectV4Deserializer, projectV4Serializer, } from './serialization_v4.js';
9
9
  import { graphV2Deserializer, projectV2Deserializer } from './serialization_v2.js';
10
10
  import { graphV1Deserializer, projectV1Deserializer } from './serialization_v1.js';
11
+ import { normalizeSerializedLLMChatV2Node } from '../../model/chat-v2/llmChatV2NodeMigration.js';
11
12
  export function serializeProject(project, attachedData) {
12
13
  return projectV4Serializer(project, attachedData);
13
14
  }
@@ -71,24 +72,6 @@ function hasLegacyDataBusFlag(node) {
71
72
  const data = node.data;
72
73
  return node.type === 'passthrough' && data != null && Object.hasOwn(data, 'renderAsDataBus');
73
74
  }
74
- function migrateLegacyLLMChatV2Diagnostics(node) {
75
- if (node.type !== 'llmChatV2' || node.data == null || typeof node.data !== 'object') {
76
- return;
77
- }
78
- const data = node.data;
79
- if (data.outputRequestStatus !== true) {
80
- return;
81
- }
82
- // Output request details used to expose all three diagnostics together.
83
- // Materialize the split settings on load so existing output connections and
84
- // editor-visible behavior remain unchanged after the setting was separated.
85
- if (!Object.hasOwn(data, 'outputRequestError')) {
86
- data.outputRequestError = true;
87
- }
88
- if (!Object.hasOwn(data, 'outputRequestBody')) {
89
- data.outputRequestBody = true;
90
- }
91
- }
92
75
  function normalizeDeserializedNode(node) {
93
76
  if (node.type === 'code' && node.title === 'Code') {
94
77
  node.title = 'Code (legacy)';
@@ -100,7 +83,7 @@ function normalizeDeserializedNode(node) {
100
83
  const { renderAsDataBus: _legacyFlag, ...data } = node.data;
101
84
  node.data = data;
102
85
  }
103
- migrateLegacyLLMChatV2Diagnostics(node);
86
+ normalizeSerializedLLMChatV2Node(node);
104
87
  }
105
88
  function deserializeProjectByVersion(serializedProject, version) {
106
89
  switch (version) {
@@ -1,4 +1,5 @@
1
- export { createUiGraphChatHistoryFlushStatePatch, createUiGraphChatPinStatePatch, createUiGraphChatSubmissionStatePatch, getUiGraphActionState, getUiGraphChatDraftStateKey, getUiGraphChatMessagesStateKey, } from './model/UiGraph.js';
1
+ export { isAgentResponseTrace } from './model/AgentResponseTrace.js';
2
+ export { createUiGraphChatHistoryFlushStatePatch, createUiGraphChatMessageRemovalStatePatch, createUiGraphChatPinStatePatch, createUiGraphChatSubmissionStatePatch, getUiGraphActionState, getUiGraphChatDraftStateKey, getUiGraphChatMessagesStateKey, } from './model/UiGraph.js';
2
3
  export { applyUiGraphStatePatch, createUiGraphActionExecutionController, createUiGraphInteractionController, getUiGraphComponentRenderModel, getUiGraphJsonOutputFilename, getUiGraphProgressiveJsonOutputChunks, } from './model/UiGraphRuntimeModel.js';
3
4
  export { parseRivetWebAppClientMessage, parseRivetWebAppServerMessage, RIVET_WEB_APP_ACTION_PROTOCOL_VERSION, } from './model/UiGraphActionProtocol.js';
4
- export { copyUiGraphText, applyUiGraphWebAppStorageActionPatch, applyUiGraphWebAppStoragePatch, clearUiGraphChatSearchMatches, downloadUiGraphJsonOutput, enhanceUiGraphChatJsonCodeBlocks, hasUiGraphChatPersistentStateChanged, getUiGraphChatPersistentState, getUiGraphChatMessagePresentations, getUiGraphChatStorageKey, getUiGraphWebAppStorageKey, highlightUiGraphChatSearchMatches, loadUiGraphChatPersistentState, loadUiGraphWebAppStorage, observeUiGraphOutputResizeBounds, revealUiGraphChatElement, revealUiGraphChatSearchMatch, saveUiGraphChatPersistentState, } from './model/UiGraphBrowserRuntime.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';
@@ -26,6 +26,7 @@ export * from './native/BaseDir.js';
26
26
  export * from './native/NativeApi.js';
27
27
  export * from './native/BrowserNativeApi.js';
28
28
  export * from './model/ProcessContext.js';
29
+ export * from './model/AgentResponseTrace.js';
29
30
  export * from './model/DebuggerTransportSentinel.js';
30
31
  export * from './model/ProjectReferenceLoader.js';
31
32
  export * from './model/RivetUIContext.js';
@@ -0,0 +1,110 @@
1
+ import type { ChatV2CallTraceEvent, GraphExecutionMetadata, GraphRunId, ProcessId, RootRunId, ToolCallFinishedEvent } from './ProcessContext.js';
2
+ import type { GraphId } from './NodeGraph.js';
3
+ import type { NodeId } from './NodeBase.js';
4
+ import type { GraphProcessor } from './GraphProcessor.js';
5
+ export declare const AGENT_RESPONSE_TRACE_SCHEMA_VERSION: 1;
6
+ export declare const AGENT_RESPONSE_TRACE_MAX_MODEL_CALLS = 250;
7
+ export declare const AGENT_RESPONSE_TRACE_MAX_TOOL_CALLS = 500;
8
+ export type AgentModelCallTrace = {
9
+ callId: string;
10
+ nodeId: NodeId;
11
+ processId: ProcessId;
12
+ provider: string;
13
+ model: string;
14
+ customProviderApi?: ChatV2CallTraceEvent['customProviderApi'];
15
+ outcome: ChatV2CallTraceEvent['outcome'];
16
+ attemptIndex: number;
17
+ profileIndex?: number;
18
+ roundIndex?: number;
19
+ startedAt?: number;
20
+ durationMs?: number;
21
+ finishReason?: string;
22
+ usage?: ChatV2CallTraceEvent['normalizedUsage'];
23
+ pricing: ChatV2CallTraceEvent['pricing'];
24
+ };
25
+ export type AgentToolCallTrace = {
26
+ toolCallId?: string;
27
+ toolName: string;
28
+ sourceNodeId: NodeId;
29
+ sourceProcessId: ProcessId;
30
+ /** Pointer to the pre-existing Delegate Tool Call output, never copied result text. */
31
+ resultOwner?: ToolCallFinishedEvent['resultOwner'];
32
+ handlerKind: ToolCallFinishedEvent['handlerKind'];
33
+ handlerGraphId?: GraphId;
34
+ handlerName?: string;
35
+ outcome: ToolCallFinishedEvent['outcome'];
36
+ startedAt?: number;
37
+ durationMs?: number;
38
+ };
39
+ export type AgentResponseTrace = {
40
+ schemaVersion: typeof AGENT_RESPONSE_TRACE_SCHEMA_VERSION;
41
+ traceId: RootRunId;
42
+ scope: 'response' | 'llm-invocation';
43
+ rootRunId: RootRunId;
44
+ graphRunId: GraphRunId;
45
+ graphId: GraphId;
46
+ nodeId?: NodeId;
47
+ processId?: ProcessId;
48
+ startedAt?: number;
49
+ responseReadyAt?: number;
50
+ finishedAt?: number;
51
+ durationMs?: number;
52
+ status: 'running' | 'response-ready' | 'completed' | 'error' | 'aborted' | 'unavailable';
53
+ backgroundWorkPending?: boolean;
54
+ summary: {
55
+ modelCallCount: number;
56
+ toolCallCount: number;
57
+ retryCount: number;
58
+ fallbackCount: number;
59
+ promptTokens?: number;
60
+ completionTokens?: number;
61
+ totalTokens?: number;
62
+ cachedTokens?: number;
63
+ reasoningTokens?: number;
64
+ knownCostUsd: number;
65
+ costStatus: 'known' | 'partial' | 'unknown';
66
+ };
67
+ modelCalls: AgentModelCallTrace[];
68
+ toolCalls: AgentToolCallTrace[];
69
+ omittedModelCallCount: number;
70
+ omittedToolCallCount: number;
71
+ };
72
+ export type AgentTraceEvent = ({
73
+ type: 'llm-call-finished';
74
+ execution: GraphExecutionMetadata;
75
+ } & ChatV2CallTraceEvent) | ({
76
+ type: 'tool-call-finished';
77
+ execution: GraphExecutionMetadata;
78
+ } & ToolCallFinishedEvent);
79
+ export type BuildAgentResponseTraceOptions = {
80
+ scope: AgentResponseTrace['scope'];
81
+ execution: GraphExecutionMetadata;
82
+ events: readonly AgentTraceEvent[];
83
+ nodeId?: NodeId;
84
+ processId?: ProcessId;
85
+ startedAt?: number;
86
+ responseReadyAt?: number;
87
+ finishedAt?: number;
88
+ status: AgentResponseTrace['status'];
89
+ backgroundWorkPending?: boolean;
90
+ };
91
+ export declare function buildAgentResponseTrace(options: BuildAgentResponseTraceOptions): AgentResponseTrace;
92
+ export declare function getAgentTraceEventIdentity(event: AgentTraceEvent): string | undefined;
93
+ /**
94
+ * Redelivery is allowed to omit newly added optional observability fields. Keep
95
+ * an exact Delegate result pointer once it was observed instead of making a
96
+ * later legacy-shaped copy erase result navigation.
97
+ */
98
+ export declare function mergeAgentTraceEvent(existing: AgentTraceEvent, incoming: AgentTraceEvent): AgentTraceEvent;
99
+ export declare function isAgentResponseTrace(value: unknown): value is AgentResponseTrace;
100
+ /**
101
+ * Collects privacy-bounded response metadata for one root processor run.
102
+ * Listener failures are isolated by GraphProcessor; callers should dispose the
103
+ * collector after the processor and any asynchronous branches settle.
104
+ */
105
+ export declare class AgentResponseTraceCollector {
106
+ #private;
107
+ constructor(processor: GraphProcessor);
108
+ build(): AgentResponseTrace | undefined;
109
+ dispose(): void;
110
+ }
@@ -0,0 +1,34 @@
1
+ import type { Outputs } from './GraphProcessor.js';
2
+ import type { NodeId } from './NodeBase.js';
3
+ import type { ProcessId } from './ProcessContext.js';
4
+ import type { ToolCallContinuation } from './ToolCallContinuation.js';
5
+ import type { DelegateFunctionCallNode } from './nodes/DelegateFunctionCallNode.js';
6
+ /**
7
+ * Owns connected Delegate invocation lifetime. GraphProcessor supplies narrow
8
+ * scheduling callbacks, while this host owns only continuation-local state.
9
+ */
10
+ export type ConnectedToolContinuationInvocation = {
11
+ delegateNode: DelegateFunctionCallNode;
12
+ latestOutputs: Map<NodeId, Outputs>;
13
+ llmNodeId: NodeId;
14
+ llmProcessId: ProcessId;
15
+ released: boolean;
16
+ };
17
+ export declare class ConnectedToolContinuationHost {
18
+ #private;
19
+ begin(params: {
20
+ key: string;
21
+ delegateNode: DelegateFunctionCallNode;
22
+ llmNodeId: NodeId;
23
+ llmProcessId: ProcessId;
24
+ run: (invocation: ConnectedToolContinuationInvocation, toolCalls: Parameters<ToolCallContinuation['run']>[0], assistantMessage: string) => ReturnType<ToolCallContinuation['run']>;
25
+ }): ToolCallContinuation;
26
+ finalize(params: {
27
+ key: string;
28
+ nodeOutputs: Outputs;
29
+ replay: (invocation: ConnectedToolContinuationInvocation, nodeOutputs: Outputs) => void;
30
+ commit: (invocation: ConnectedToolContinuationInvocation) => void;
31
+ }): void;
32
+ discard(key: string): void;
33
+ reset(): void;
34
+ }
@@ -1,11 +1,11 @@
1
1
  import type { DataValue, ScalarOrArrayDataValue, StringArrayDataValue } from './DataValue.js';
2
2
  import type { Dataset, DatasetId, DatasetMetadata, DatasetRow } from './Dataset.js';
3
- import type { ChartNode, NodeId, PortId } from './NodeBase.js';
3
+ import type { ChartNode, NodeConnection, NodeId, PortId } from './NodeBase.js';
4
4
  import type { GraphId, NodeGraph } from './NodeGraph.js';
5
- import type { GraphExecutionMetadata, ProcessId } from './ProcessContext.js';
5
+ import type { ChatV2CallTraceEvent, GraphExecutionMetadata, ProcessId, ToolCallFinishedEvent } from './ProcessContext.js';
6
6
  import type { Project, ProjectId } from './Project.js';
7
7
  import type { Settings } from './Settings.js';
8
- import type { FrozenNodeOutputsByGraph } from './GraphProcessor.js';
8
+ import type { FrozenNodeOutputsByGraph, NodeResultOrigin } from './GraphProcessor.js';
9
9
  import type { GraphProgress } from './GraphProgress.js';
10
10
  import type { RivetWebAppStorage } from './UiGraphWebAppStorage.js';
11
11
  export type GraphInputs = Record<string, DataValue>;
@@ -55,12 +55,15 @@ export type SerializedProcessEventMap = {
55
55
  nodeStart: WithExecution<{
56
56
  node: ChartNode;
57
57
  inputs: Inputs;
58
+ inputConnections?: NodeConnection[];
58
59
  processId: ProcessId;
60
+ resultOrigin?: NodeResultOrigin;
59
61
  }>;
60
62
  nodeFinish: WithExecution<{
61
63
  node: ChartNode;
62
64
  outputs: Outputs;
63
65
  processId: ProcessId;
66
+ resultOrigin?: NodeResultOrigin;
64
67
  durationMs?: number;
65
68
  splitRunDurationMs?: Record<number, number>;
66
69
  }>;
@@ -68,6 +71,7 @@ export type SerializedProcessEventMap = {
68
71
  node: ChartNode;
69
72
  error: Error | string;
70
73
  processId: ProcessId;
74
+ resultOrigin?: NodeResultOrigin;
71
75
  durationMs?: number;
72
76
  splitRunDurationMs?: Record<number, number>;
73
77
  }>;
@@ -77,6 +81,7 @@ export type SerializedProcessEventMap = {
77
81
  inputs: Inputs;
78
82
  outputs: Outputs;
79
83
  reason: string;
84
+ resultOrigin?: NodeResultOrigin;
80
85
  }>;
81
86
  userInput: WithExecution<{
82
87
  node: ChartNode;
@@ -84,18 +89,23 @@ export type SerializedProcessEventMap = {
84
89
  inputs: Inputs;
85
90
  processId: ProcessId;
86
91
  renderingType: 'text' | 'markdown';
92
+ /** See ProcessEvents.userInput.isReplay. */
93
+ isReplay?: true;
87
94
  }>;
88
95
  partialOutput: WithExecution<{
89
96
  node: ChartNode;
90
97
  outputs: Outputs;
91
98
  index: number;
92
99
  processId: ProcessId;
100
+ resultOrigin?: NodeResultOrigin;
93
101
  }>;
94
102
  progress: WithExecution<{
95
103
  node: ChartNode;
96
104
  processId: ProcessId;
97
105
  progress: GraphProgress;
98
106
  }>;
107
+ llmCallFinished: WithExecution<ChatV2CallTraceEvent>;
108
+ toolCallFinished: WithExecution<ToolCallFinishedEvent>;
99
109
  nodeOutputsCleared: WithExecution<{
100
110
  node: ChartNode;
101
111
  processId?: ProcessId;
@@ -112,8 +122,14 @@ export type SerializedProcessEventMap = {
112
122
  };
113
123
  finish: void;
114
124
  trace: string;
115
- pause: void;
116
- resume: void;
125
+ /** Present only when RecordingPlayer re-emits a historical lifecycle transition. */
126
+ pause: {
127
+ isReplay?: true;
128
+ } | undefined;
129
+ /** Present only when RecordingPlayer re-emits a historical lifecycle transition. */
130
+ resume: {
131
+ isReplay?: true;
132
+ } | undefined;
117
133
  globalSet: WithExecution<{
118
134
  id: string;
119
135
  value: ScalarOrArrayDataValue;
@@ -144,12 +160,14 @@ export type ProcessEventMessageMap = {
144
160
  graphOutputsReady: SerializedProcessEventMap['graphOutputsReady'];
145
161
  partialOutput: SerializedProcessEventMap['partialOutput'];
146
162
  progress: SerializedProcessEventMap['progress'];
163
+ llmCallFinished: SerializedProcessEventMap['llmCallFinished'];
164
+ toolCallFinished: SerializedProcessEventMap['toolCallFinished'];
147
165
  nodeOutputsCleared: SerializedProcessEventMap['nodeOutputsCleared'];
148
166
  error: SerializedProcessEventMap['error'];
149
167
  graphError: SerializedProcessEventMap['graphError'];
150
168
  trace: string;
151
- pause: void;
152
- resume: void;
169
+ pause: SerializedProcessEventMap['pause'];
170
+ resume: SerializedProcessEventMap['resume'];
153
171
  };
154
172
  export type GraphUploadAllowedMessage = {
155
173
  message: 'graph-upload-allowed';
@@ -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 } from './ProcessContext.js';
7
+ import type { GraphExecutionMetadata, InternalProcessContext, ProcessContext, ProcessId, ChatV2CallTraceEvent, 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';
@@ -18,6 +18,7 @@ type WithExecution<T extends object> = T & {
18
18
  };
19
19
  declare const graphProcessorGraphOverride: unique symbol;
20
20
  declare const consumedAsyncBranchTriggerOverride: unique symbol;
21
+ export type NodeResultOrigin = 'executed' | 'preloaded' | 'frozen' | 'editor-cache' | 'unknown';
21
22
  export type ProcessEvents = {
22
23
  /** Called when processing has started. */
23
24
  start: WithExecution<{
@@ -56,13 +57,17 @@ export type ProcessEvents = {
56
57
  nodeStart: WithExecution<{
57
58
  node: ChartNode;
58
59
  inputs: Inputs;
60
+ /** Effective, value-free producer edges after Data Bus preprocessing. */
61
+ inputConnections?: NodeConnection[];
59
62
  processId: ProcessId;
63
+ resultOrigin?: NodeResultOrigin;
60
64
  }>;
61
65
  /** Called when a node has finished processing, with the output values for the node. */
62
66
  nodeFinish: WithExecution<{
63
67
  node: ChartNode;
64
68
  outputs: Outputs;
65
69
  processId: ProcessId;
70
+ resultOrigin?: NodeResultOrigin;
66
71
  durationMs?: number;
67
72
  splitRunDurationMs?: Record<number, number>;
68
73
  }>;
@@ -71,6 +76,7 @@ export type ProcessEvents = {
71
76
  node: ChartNode;
72
77
  error: Error | string;
73
78
  processId: ProcessId;
79
+ resultOrigin?: NodeResultOrigin;
74
80
  durationMs?: number;
75
81
  splitRunDurationMs?: Record<number, number>;
76
82
  }>;
@@ -81,6 +87,7 @@ export type ProcessEvents = {
81
87
  inputs: Inputs;
82
88
  outputs: Outputs;
83
89
  reason: string;
90
+ resultOrigin?: NodeResultOrigin;
84
91
  }>;
85
92
  /** Called when a user input node requires user input. Call the callback when finished, or call userInput() on the GraphProcessor with the results. */
86
93
  userInput: WithExecution<{
@@ -91,6 +98,12 @@ export type ProcessEvents = {
91
98
  callback: (values: StringArrayDataValue) => void;
92
99
  processId: ProcessId;
93
100
  renderingType: 'text' | 'markdown';
101
+ /**
102
+ * Present only when RecordingPlayer re-emits a historical prompt. It is
103
+ * display-only: hosts must project it to observability without asking the
104
+ * user for input again.
105
+ */
106
+ isReplay?: true;
94
107
  }>;
95
108
  /** Called when a node has partially processed, with the current partial output values for the node. */
96
109
  partialOutput: WithExecution<{
@@ -98,6 +111,7 @@ export type ProcessEvents = {
98
111
  outputs: Outputs;
99
112
  index: number;
100
113
  processId: ProcessId;
114
+ resultOrigin?: NodeResultOrigin;
101
115
  }>;
102
116
  /** Called when a node reports host-facing progress. */
103
117
  progress: WithExecution<{
@@ -105,6 +119,10 @@ export type ProcessEvents = {
105
119
  processId: ProcessId;
106
120
  progress: GraphProgress;
107
121
  }>;
122
+ /** Privacy-bounded metadata for one physical LLM provider call. */
123
+ llmCallFinished: WithExecution<ChatV2CallTraceEvent>;
124
+ /** Privacy-bounded metadata for one delegated tool execution. */
125
+ toolCallFinished: WithExecution<ToolCallFinishedEvent>;
108
126
  /** Called when the outputs of a node have been cleared entirely. If processId is present, only the one process() should be cleared. */
109
127
  nodeOutputsCleared: WithExecution<{
110
128
  node: ChartNode;
@@ -127,10 +145,14 @@ export type ProcessEvents = {
127
145
  finish: void;
128
146
  /** Called for trace level logs. */
129
147
  trace: string;
130
- /** Called when the graph has been paused. */
131
- pause: void;
132
- /** Called when the graph has been resumed. */
133
- resume: void;
148
+ /** Called when the graph has been paused. Historical playback pauses are display-only. */
149
+ pause: {
150
+ isReplay?: true;
151
+ } | undefined;
152
+ /** Called when the graph has been resumed. Historical playback resumes are display-only. */
153
+ resume: {
154
+ isReplay?: true;
155
+ } | undefined;
134
156
  /** Called when a global variable has been set in a graph. */
135
157
  globalSet: WithExecution<{
136
158
  id: string;
@@ -1,5 +1,5 @@
1
1
  import type { Inputs, Outputs } from './GraphProcessor.js';
2
- import { type ChartNode, type NodeConnection, type NodeId, type NodeInputDefinition, type NodeOutputDefinition } from './NodeBase.js';
2
+ import { type ChartNode, type NodeConnection, type NodeId, type NodeInputDefinition, type NodeOutputDefinition, type PortId } from './NodeBase.js';
3
3
  import type { Project, ProjectId } from './Project.js';
4
4
  import type { InternalProcessContext } from './ProcessContext.js';
5
5
  import type { EditorDefinition } from './EditorDefinition.js';
@@ -18,7 +18,22 @@ export interface PluginNodeImpl<T extends ChartNode> {
18
18
  getBody(data: T['data'], context: RivetUIContext): NodeBody | Promise<NodeBody>;
19
19
  create(): T;
20
20
  getUIData(context: RivetUIContext): NodeUIData | Promise<NodeUIData>;
21
+ /** Optional metadata-only presentation hints for the editor Run Activity view. */
22
+ getRunActivityDescriptor?(data: T['data']): NodeRunActivityDescriptor;
21
23
  }
24
+ export type NodeRunActivityDescriptor = {
25
+ category?: 'generic' | 'model' | 'tool';
26
+ /** Preferred output to preview without changing execution or serialization. */
27
+ primaryOutputPortId?: PortId;
28
+ /**
29
+ * @deprecated Run Activity no longer renders input provenance. Retained only
30
+ * so existing plugin descriptors remain source-compatible; new nodes must
31
+ * not use it.
32
+ */
33
+ contextInputPortIds?: PortId[];
34
+ /** Contextual label for the existing node-owned full-output action. */
35
+ fullOutputActionLabel?: string;
36
+ };
22
37
  export declare abstract class NodeImpl<T extends ChartNode, Type extends T['type'] = T['type']> {
23
38
  readonly chartNode: T;
24
39
  constructor(chartNode: T);
@@ -36,6 +51,7 @@ export declare abstract class NodeImpl<T extends ChartNode, Type extends T['type
36
51
  abstract process(inputData: Inputs, context: InternalProcessContext): Promise<Outputs>;
37
52
  getEditors(_context: RivetUIContext): EditorDefinition<T>[] | Promise<EditorDefinition<T>[]>;
38
53
  getBody(_context: RivetUIContext): NodeBody | Promise<NodeBody>;
54
+ getRunActivityDescriptor(): NodeRunActivityDescriptor | undefined;
39
55
  }
40
56
  export type NodeBody = string | NodeBodySpec | NodeBodySpec[] | undefined;
41
57
  export declare class PluginNodeImplClass<T extends ChartNode, Type extends T['type'] = T['type']> extends NodeImpl<T, Type> {
@@ -46,6 +62,7 @@ export declare class PluginNodeImplClass<T extends ChartNode, Type extends T['ty
46
62
  process(inputData: Inputs, context: InternalProcessContext): Promise<Outputs>;
47
63
  getEditors(context: RivetUIContext): EditorDefinition<T>[] | Promise<EditorDefinition<T>[]>;
48
64
  getBody(context: RivetUIContext): NodeBody | Promise<NodeBody>;
65
+ getRunActivityDescriptor(): NodeRunActivityDescriptor | undefined;
49
66
  }
50
67
  export type NodeUIData = {
51
68
  contextMenuTitle?: string;