@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.
Files changed (188) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/bundle.cjs +5618 -2533
  3. package/dist/cjs/bundle.cjs.map +4 -4
  4. package/dist/cjs/webAppRuntime.cjs +333 -22
  5. package/dist/cjs/webAppRuntime.cjs.map +4 -4
  6. package/dist/esm/api/createProcessor.js +2 -0
  7. package/dist/esm/exports.js +1 -0
  8. package/dist/esm/integrations/CodeRunner.js +2 -7
  9. package/dist/esm/integrations/CodeRunnerOptions.js +7 -0
  10. package/dist/esm/model/AgentResponseTrace.js +558 -0
  11. package/dist/esm/model/ConnectedToolContinuationHost.js +33 -0
  12. package/dist/esm/model/GraphProcessor.js +165 -74
  13. package/dist/esm/model/NodeImpl.js +6 -0
  14. package/dist/esm/model/ProcessContextBuilder.js +3 -1
  15. package/dist/esm/model/RecordingPlayer.js +212 -25
  16. package/dist/esm/model/SplitRunProcessor.js +49 -8
  17. package/dist/esm/model/SubprocessorBridge.js +3 -0
  18. package/dist/esm/model/ToolCallContinuationCoordinator.js +7 -3
  19. package/dist/esm/model/UiGraph.js +21 -0
  20. package/dist/esm/model/UiGraphActionProtocol.js +3 -0
  21. package/dist/esm/model/UiGraphBrowserRuntime.js +133 -4
  22. package/dist/esm/model/UiGraphRendererStyles.js +221 -0
  23. package/dist/esm/model/UiGraphRuntimeModel.js +9 -3
  24. package/dist/esm/model/UiGraphSchema.js +7 -1
  25. package/dist/esm/model/chat/aiSdkTools.js +3 -2
  26. package/dist/esm/model/chat-v2/aiSdkBridge.js +146 -14
  27. package/dist/esm/model/chat-v2/chatV2CallObserver.js +11 -5
  28. package/dist/esm/model/chat-v2/chatV2CredentialNames.js +93 -0
  29. package/dist/esm/model/chat-v2/chatV2EditorCache.js +47 -20
  30. package/dist/esm/model/chat-v2/chatV2Errors.js +7 -19
  31. package/dist/esm/model/chat-v2/chatV2FeatureCompatibility.js +1 -1
  32. package/dist/esm/model/chat-v2/chatV2Outputs.js +48 -108
  33. package/dist/esm/model/chat-v2/chatV2Pipeline.js +101 -149
  34. package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +39 -4
  35. package/dist/esm/model/chat-v2/chatV2ProviderRegistry.js +9 -0
  36. package/dist/esm/model/chat-v2/chatV2RequestPlan.js +2 -3
  37. package/dist/esm/model/chat-v2/chatV2ResponseBodyCapture.js +63 -0
  38. package/dist/esm/model/chat-v2/chatV2ResponseFormat.js +8 -4
  39. package/dist/esm/model/chat-v2/chatV2Retry.js +4 -3
  40. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +7 -7
  41. package/dist/esm/model/chat-v2/chatV2Shared.js +1 -1
  42. package/dist/esm/model/chat-v2/chatV2Types.js +20 -8
  43. package/dist/esm/model/chat-v2/chatV2UsageAccounting.js +78 -0
  44. package/dist/esm/model/chat-v2/customProviderApi.js +40 -0
  45. package/dist/esm/model/chat-v2/index.js +15 -0
  46. package/dist/esm/model/chat-v2/llmChatV2Body.js +289 -0
  47. package/dist/esm/model/chat-v2/llmChatV2CacheBoundary.js +32 -0
  48. package/dist/esm/model/chat-v2/llmChatV2CachePolicy.js +25 -0
  49. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +13 -50
  50. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +117 -24
  51. package/dist/esm/model/chat-v2/llmChatV2NodeMigration.js +24 -0
  52. package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +150 -199
  53. package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +60 -0
  54. package/dist/esm/model/chat-v2/llmInvocationDecision.js +11 -0
  55. package/dist/esm/model/chat-v2/llmInvocationJournal.js +43 -0
  56. package/dist/esm/model/chat-v2/llmInvocationPlan.js +68 -0
  57. package/dist/esm/model/chat-v2/llmInvocationProjections.js +5 -0
  58. package/dist/esm/model/chat-v2/llmInvocationResultProjector.js +48 -0
  59. package/dist/esm/model/chat-v2/llmModelCandidate.js +79 -0
  60. package/dist/esm/model/chat-v2/llmProfile.js +52 -65
  61. package/dist/esm/model/chat-v2/llmProfileBody.js +193 -0
  62. package/dist/esm/model/chat-v2/llmProfileFallback.js +442 -100
  63. package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +74 -0
  64. package/dist/esm/model/chat-v2/llmProfileHealthStore.js +326 -0
  65. package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +55 -33
  66. package/dist/esm/model/chat-v2/llmProfileTypes.js +1 -18
  67. package/dist/esm/model/chat-v2/llmResponseMaterializer.js +42 -0
  68. package/dist/esm/model/chat-v2/modelRegistry.js +54 -4
  69. package/dist/esm/model/chat-v2/parallelToolCalls.js +9 -2
  70. package/dist/esm/model/chat-v2/providerOptions.js +116 -24
  71. package/dist/esm/model/chat-v2/rivetToolRegistry.js +9 -0
  72. package/dist/esm/model/chat-v2/toolCallCodec.js +52 -0
  73. package/dist/esm/model/chat-v2/toolContinuation.js +72 -35
  74. package/dist/esm/model/chat-v2/toolHandlerResolver.js +23 -0
  75. package/dist/esm/model/chat-v2/toolRoundExecutor.js +12 -0
  76. package/dist/esm/model/nodes/ChatNode.js +6 -0
  77. package/dist/esm/model/nodes/ChatNodeBase.js +1 -0
  78. package/dist/esm/model/nodes/CodeNewNode.js +5 -47
  79. package/dist/esm/model/nodes/CodeNode.js +4 -46
  80. package/dist/esm/model/nodes/DelegateFunctionCallNode.js +19 -6
  81. package/dist/esm/model/nodes/ExpressionNode.js +5 -8
  82. package/dist/esm/model/nodes/LLMChatV2Node.js +121 -229
  83. package/dist/esm/model/nodes/LLMProfileNode.js +27 -8
  84. package/dist/esm/model/nodes/MatchNode.js +86 -41
  85. package/dist/esm/model/nodes/PromptNode.js +7 -0
  86. package/dist/esm/model/nodes/ToolNode.js +7 -0
  87. package/dist/esm/model/nodes/toolCallDelegation.js +177 -110
  88. package/dist/esm/plugins/anthropic/anthropic.js +4 -4
  89. package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +7 -0
  90. package/dist/esm/plugins/gentrace/gentraceSdk.js +0 -1
  91. package/dist/esm/plugins/gentrace/index.js +0 -1
  92. package/dist/esm/plugins/gentrace/plugin.js +61 -179
  93. package/dist/esm/plugins/google/google.js +5 -9
  94. package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +4 -1
  95. package/dist/esm/plugins.js +1 -2
  96. package/dist/esm/recording/ExecutionRecorder.js +62 -13
  97. package/dist/esm/utils/emitDetached.js +6 -3
  98. package/dist/esm/utils/openai.js +60 -16
  99. package/dist/esm/utils/serialization/serialization.js +2 -19
  100. package/dist/esm/webAppRuntime.js +3 -2
  101. package/dist/types/api/createProcessor.d.ts +3 -0
  102. package/dist/types/exports.d.ts +1 -0
  103. package/dist/types/integrations/CodeRunner.d.ts +10 -7
  104. package/dist/types/integrations/CodeRunnerOptions.d.ts +15 -0
  105. package/dist/types/model/AgentResponseTrace.d.ts +123 -0
  106. package/dist/types/model/ConnectedToolContinuationHost.d.ts +34 -0
  107. package/dist/types/model/EditorDefinition.d.ts +16 -0
  108. package/dist/types/model/ExecutorProtocol.d.ts +32 -11
  109. package/dist/types/model/GraphProcessor.d.ts +41 -9
  110. package/dist/types/model/NodeBase.d.ts +0 -10
  111. package/dist/types/model/NodeImpl.d.ts +18 -1
  112. package/dist/types/model/Nodes.d.ts +2 -2
  113. package/dist/types/model/ProcessContext.d.ts +99 -0
  114. package/dist/types/model/ProcessContextBuilder.d.ts +3 -1
  115. package/dist/types/model/RecordingPlayer.d.ts +6 -0
  116. package/dist/types/model/SplitRunProcessor.d.ts +10 -3
  117. package/dist/types/model/UiGraph.d.ts +8 -0
  118. package/dist/types/model/UiGraphActionProtocol.d.ts +3 -0
  119. package/dist/types/model/UiGraphBrowserRuntime.d.ts +11 -2
  120. package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
  121. package/dist/types/model/UiGraphRuntimeModel.d.ts +2 -0
  122. package/dist/types/model/UiGraphSchema.d.ts +1 -0
  123. package/dist/types/model/chat-v2/chatV2CallObserver.d.ts +2 -0
  124. package/dist/types/model/chat-v2/chatV2CredentialNames.d.ts +30 -0
  125. package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +2 -3
  126. package/dist/types/model/chat-v2/chatV2Outputs.d.ts +6 -16
  127. package/dist/types/model/chat-v2/chatV2Pipeline.d.ts +13 -17
  128. package/dist/types/model/chat-v2/chatV2ProviderProfile.d.ts +7 -0
  129. package/dist/types/model/chat-v2/chatV2ProviderRegistry.d.ts +8 -0
  130. package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +2 -2
  131. package/dist/types/model/chat-v2/chatV2ResponseBodyCapture.d.ts +25 -0
  132. package/dist/types/model/chat-v2/chatV2ResponseFormat.d.ts +3 -2
  133. package/dist/types/model/chat-v2/chatV2Retry.d.ts +2 -0
  134. package/dist/types/model/chat-v2/chatV2RuntimeOptions.d.ts +3 -8
  135. package/dist/types/model/chat-v2/chatV2Types.d.ts +44 -10
  136. package/dist/types/model/chat-v2/chatV2UsageAccounting.d.ts +14 -0
  137. package/dist/types/model/chat-v2/customProviderApi.d.ts +22 -0
  138. package/dist/types/model/chat-v2/index.d.ts +15 -0
  139. package/dist/types/model/chat-v2/llmChatV2Body.d.ts +24 -0
  140. package/dist/types/model/chat-v2/llmChatV2CacheBoundary.d.ts +10 -0
  141. package/dist/types/model/chat-v2/llmChatV2CachePolicy.d.ts +13 -0
  142. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +19 -3
  143. package/dist/types/model/chat-v2/llmChatV2NodeMigration.d.ts +8 -0
  144. package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +14 -16
  145. package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +16 -0
  146. package/dist/types/model/chat-v2/llmInvocationDecision.d.ts +21 -0
  147. package/dist/types/model/chat-v2/llmInvocationJournal.d.ts +38 -0
  148. package/dist/types/model/chat-v2/llmInvocationPlan.d.ts +41 -0
  149. package/dist/types/model/chat-v2/llmInvocationProjections.d.ts +3 -0
  150. package/dist/types/model/chat-v2/llmInvocationResultProjector.d.ts +26 -0
  151. package/dist/types/model/chat-v2/llmModelCandidate.d.ts +20 -0
  152. package/dist/types/model/chat-v2/llmProfile.d.ts +14 -0
  153. package/dist/types/model/chat-v2/llmProfileBody.d.ts +20 -0
  154. package/dist/types/model/chat-v2/llmProfileFallback.d.ts +36 -49
  155. package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +209 -0
  156. package/dist/types/model/chat-v2/llmProfileHealthStore.d.ts +111 -0
  157. package/dist/types/model/chat-v2/llmProfileNodeRuntime.d.ts +1 -1
  158. package/dist/types/model/chat-v2/llmProfileTypes.d.ts +4 -1
  159. package/dist/types/model/chat-v2/llmResponseMaterializer.d.ts +20 -0
  160. package/dist/types/model/chat-v2/modelRegistry.d.ts +17 -187
  161. package/dist/types/model/chat-v2/parallelToolCalls.d.ts +3 -1
  162. package/dist/types/model/chat-v2/providerOptions.d.ts +12 -0
  163. package/dist/types/model/chat-v2/rivetToolRegistry.d.ts +11 -0
  164. package/dist/types/model/chat-v2/toolCallCodec.d.ts +7 -0
  165. package/dist/types/model/chat-v2/toolContinuation.d.ts +3 -3
  166. package/dist/types/model/chat-v2/toolHandlerResolver.d.ts +25 -0
  167. package/dist/types/model/chat-v2/toolRoundExecutor.d.ts +18 -0
  168. package/dist/types/model/nodes/ChatNode.d.ts +2 -1
  169. package/dist/types/model/nodes/CodeNewNode.d.ts +0 -5
  170. package/dist/types/model/nodes/CodeNode.d.ts +0 -5
  171. package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +2 -1
  172. package/dist/types/model/nodes/LLMChatV2Node.d.ts +2 -1
  173. package/dist/types/model/nodes/LLMProfileNode.d.ts +2 -1
  174. package/dist/types/model/nodes/MatchNode.d.ts +6 -0
  175. package/dist/types/model/nodes/PromptNode.d.ts +4 -1
  176. package/dist/types/model/nodes/ToolNode.d.ts +2 -1
  177. package/dist/types/model/nodes/toolCallDelegation.d.ts +10 -3
  178. package/dist/types/plugins/anthropic/anthropic.d.ts +1 -0
  179. package/dist/types/plugins/gentrace/gentraceSdk.d.ts +0 -1
  180. package/dist/types/plugins/gentrace/plugin.d.ts +55 -9
  181. package/dist/types/plugins/google/google.d.ts +2 -8
  182. package/dist/types/plugins.d.ts +1 -1
  183. package/dist/types/recording/ExecutionRecorder.d.ts +7 -1
  184. package/dist/types/recording/RecordedEvents.d.ts +6 -0
  185. package/dist/types/utils/emitDetached.d.ts +3 -2
  186. package/dist/types/utils/openai.d.ts +49 -0
  187. package/dist/types/webAppRuntime.d.ts +4 -2
  188. package/package.json +2 -2
@@ -0,0 +1,14 @@
1
+ import type { ChatV2CallFinishedEvent } from '../ProcessContext.js';
2
+ import type { ChatV2NormalizedUsage } from './chatV2Types.js';
3
+ /**
4
+ * The provider-neutral numeric contract shared by LLM Chat V2 usage consumers.
5
+ * Provider metadata is untrusted, so callers must not treat negative, NaN, or
6
+ * infinite token counts as real usage.
7
+ */
8
+ export declare function isChatV2FiniteNonNegativeNumber(value: unknown): value is number;
9
+ /**
10
+ * Aggregates one node invocation's physical provider calls into its portable
11
+ * Usage output. The call id is a stable transport identity, so a redelivered
12
+ * lifecycle event replaces prior metadata instead of inflating totals.
13
+ */
14
+ export declare function summarizeChatV2PhysicalCallUsage(events: readonly ChatV2CallFinishedEvent[]): ChatV2NormalizedUsage | undefined;
@@ -0,0 +1,22 @@
1
+ export type CustomProviderApi = 'completions' | 'responses';
2
+ export type CustomProviderApiContract = Readonly<{
3
+ api: CustomProviderApi;
4
+ adapter: 'openai-compatible' | 'openai-responses';
5
+ endpointPath: '/chat/completions' | '/responses';
6
+ label: 'Custom Completions' | 'Custom Responses';
7
+ structuredOutput: 'raw-response-format' | 'sdk-output';
8
+ parallelToolCalls: 'enabled-only-raw-field' | 'openai-option';
9
+ }>;
10
+ export declare const customProviderApiOptions: readonly [{
11
+ readonly value: "completions";
12
+ readonly label: "Completions";
13
+ }, {
14
+ readonly value: "responses";
15
+ readonly label: "Responses";
16
+ }];
17
+ /**
18
+ * Keep legacy nodes on Chat Completions while rejecting corrupt/API-authored
19
+ * values before a provider request is created.
20
+ */
21
+ export declare function parseCustomProviderApi(value: unknown): CustomProviderApi;
22
+ export declare function getCustomProviderApiContract(value: unknown): CustomProviderApiContract;
@@ -2,13 +2,28 @@ export * from './aiSdkBridge.js';
2
2
  export * from './chatV2FeatureCompatibility.js';
3
3
  export * from './chatV2Pipeline.js';
4
4
  export * from './chatV2ProviderProfile.js';
5
+ export * from './chatV2CredentialNames.js';
5
6
  export * from './chatV2RequestPlan.js';
6
7
  export * from './chatV2ResponseFormat.js';
7
8
  export * from './chatV2Shared.js';
8
9
  export * from './chatV2Types.js';
9
10
  export * from './llmProfileTypes.js';
11
+ export * from './llmProfileHealthStore.js';
12
+ export * from './llmProfileBody.js';
13
+ export * from './llmChatV2Body.js';
10
14
  export * from './messageConverter.js';
11
15
  export * from './modelRegistry.js';
12
16
  export * from './providerOptions.js';
13
17
  export * from './toolConverter.js';
14
18
  export * from './toolContinuationConnection.js';
19
+ export * from './chatV2ProviderRegistry.js';
20
+ export * from './llmChatV2NodeMigration.js';
21
+ export * from './llmChatV2NodeData.js';
22
+ export * from './llmInvocationCoordinator.js';
23
+ export * from './llmInvocationProjections.js';
24
+ export * from './llmInvocationDecision.js';
25
+ export * from './llmChatV2CacheBoundary.js';
26
+ export * from './llmResponseMaterializer.js';
27
+ export * from './toolCallCodec.js';
28
+ export * from './toolHandlerResolver.js';
29
+ export * from './toolRoundExecutor.js';
@@ -0,0 +1,24 @@
1
+ import type { LLMChatV2NodeData } from './llmChatV2NodeData.js';
2
+ export type LLMChatV2BodyField = Readonly<{
3
+ label: string;
4
+ value: string;
5
+ }>;
6
+ export type LLMChatV2BodySnippet = Readonly<{
7
+ label: string;
8
+ text: string;
9
+ }>;
10
+ export type LLMChatV2BodySection = Readonly<{
11
+ id: 'configuration' | 'model' | 'parameters' | 'provider' | 'response-format' | 'tools' | 'behavior' | 'advanced' | 'error';
12
+ fields: readonly LLMChatV2BodyField[];
13
+ snippet?: LLMChatV2BodySnippet | undefined;
14
+ }>;
15
+ /**
16
+ * Stable canvas presentation data for LLM Chat configuration.
17
+ *
18
+ * Inline mode exposes its local model/provider settings plus every active
19
+ * invocation setting. Profile mode deliberately exposes only invocation-owned
20
+ * settings because provider configuration comes from the connected LLM Profile
21
+ * value at runtime. Output toggles are intentionally omitted: their ports are
22
+ * already the canonical canvas indication that an output is enabled.
23
+ */
24
+ export declare function getLLMChatV2BodySections(data: LLMChatV2NodeData): readonly LLMChatV2BodySection[];
@@ -0,0 +1,10 @@
1
+ import type { Outputs } from '../GraphProcessor.js';
2
+ import type { ChatV2PipelineResult } from './chatV2Types.js';
3
+ import type { LLMChatV2RuntimeConfig } from './llmChatV2NodeRuntime.js';
4
+ /** Projects cache hits as current-run output without inventing provider work. */
5
+ export declare function projectLLMChatV2EditorCacheHit(runtime: LLMChatV2RuntimeConfig): Outputs | undefined;
6
+ /** Caches only final model answers; failed invocations never reach this boundary. */
7
+ export declare function writeLLMChatV2EditorCache(params: {
8
+ runtime: LLMChatV2RuntimeConfig;
9
+ result: ChatV2PipelineResult;
10
+ }): void;
@@ -0,0 +1,13 @@
1
+ import type { LLMChatV2NodeData } from './llmChatV2NodeData.js';
2
+ export type LLMChatV2EditorCacheEligibility = {
3
+ eligible: true;
4
+ } | {
5
+ eligible: false;
6
+ reason: 'disabled' | 'rivet-tools' | 'provider-native-tools' | 'circuit-breaker';
7
+ };
8
+ /**
9
+ * Editor-cache replay is safe only for ordinary deterministic model calls.
10
+ * Tool-capable calls can have side effects or live Delegate run shapes that a
11
+ * cached final output cannot reproduce.
12
+ */
13
+ export declare function getLLMChatV2EditorCacheEligibility(data: LLMChatV2NodeData): LLMChatV2EditorCacheEligibility;
@@ -2,6 +2,9 @@ import type { ChatV2ResponseFormat } from './chatV2ResponseFormat.js';
2
2
  import { type ChatV2CommonNodeData } from './chatV2Shared.js';
3
3
  import type { ChatV2Provider } from './chatV2Types.js';
4
4
  import type { ChartNode, NodeId } from '../NodeBase.js';
5
+ import type { CustomProviderApi } from './customProviderApi.js';
6
+ import type { ChatV2CredentialNamesByProvider } from './chatV2CredentialNames.js';
7
+ export type { CustomProviderApi } from './customProviderApi.js';
5
8
  export type LLMChatV2ToolChoiceMode = '' | 'auto' | 'function' | 'required';
6
9
  export type LLMChatV2ApiKeySource = 'environment' | 'input';
7
10
  export type LLMChatV2ConfigurationMode = 'inline' | 'profile';
@@ -9,10 +12,13 @@ export type LLMChatV2NodeConfigData = ChatV2CommonNodeData & {
9
12
  configurationMode?: LLMChatV2ConfigurationMode;
10
13
  provider: ChatV2Provider;
11
14
  apiKeySource?: LLMChatV2ApiKeySource;
15
+ providerApiKeyNames?: ChatV2CredentialNamesByProvider;
12
16
  customProviderApiKeyProgrammaticName?: string;
13
17
  customProviderApiKeyEnvVarName?: string;
14
18
  customProviderBaseURL: string;
15
19
  useCustomProviderBaseURLInput: boolean;
20
+ /** Missing on legacy/programmatically-created nodes means Chat Completions. */
21
+ customProviderApi?: CustomProviderApi;
16
22
  baseURL: string;
17
23
  useBaseURLInput: boolean;
18
24
  headers: {
@@ -40,6 +46,12 @@ export type LLMChatV2NodeConfigData = ChatV2CommonNodeData & {
40
46
  googleIncludeThoughts?: boolean;
41
47
  enableGoogleSearchGrounding: boolean;
42
48
  enableGoogleUrlContext: boolean;
49
+ enableCircuitBreaker?: boolean;
50
+ firstOutputTimeoutMs?: number;
51
+ streamInactivityTimeoutMs?: number;
52
+ circuitBreakerFailureThreshold?: number;
53
+ circuitBreakerFailureWindowMs?: number;
54
+ circuitBreakerOpenDurationMs?: number;
43
55
  responseFormat?: ChatV2ResponseFormat;
44
56
  responseSchemaName?: string;
45
57
  useResponseSchemaNameInput?: boolean;
@@ -53,16 +65,19 @@ export type LLMChatV2NodeConfigData = ChatV2CommonNodeData & {
53
65
  retryOnNon200?: boolean;
54
66
  retryOnNon200RepeatTimes?: number;
55
67
  retryOnNon200CooldownMs?: number;
56
- outputRequestStatus?: boolean;
57
- outputRequestError?: boolean;
68
+ outputLLMAttempts?: boolean;
58
69
  outputRequestBody?: boolean;
70
+ outputResponseBody?: boolean;
59
71
  };
60
72
  export type LLMChatV2NodeData = LLMChatV2NodeConfigData;
61
73
  export type LLMChatV2Node = ChartNode<'llmChatV2', LLMChatV2NodeData>;
62
- export declare const llmChatV2ProfileDataKeys: readonly ["model", "useModelInput", "temperature", "useTemperatureInput", "topP", "useTopPInput", "topK", "useTopKInput", "presencePenalty", "usePresencePenaltyInput", "frequencyPenalty", "useFrequencyPenaltyInput", "stopSequences", "useStopSequencesInput", "seed", "useSeedInput", "maxTokens", "useMaxTokensInput", "provider", "apiKeySource", "customProviderApiKeyProgrammaticName", "customProviderApiKeyEnvVarName", "customProviderBaseURL", "useCustomProviderBaseURLInput", "headers", "useHeadersInput", "extraProviderOptions", "useExtraProviderOptionsInput", "openAIReasoningEffort", "openAIReasoningSummary", "openAIPreviousResponseId", "useOpenAIPreviousResponseIdInput", "enableOpenAIWebSearch", "openAIWebSearchContextSize", "enableOpenAICodeInterpreter", "anthropicThinkingMode", "anthropicThinkingBudget", "useAnthropicThinkingBudgetInput", "anthropicEffort", "anthropicCacheControlTtl", "googleThinkingBudget", "useGoogleThinkingBudgetInput", "googleThinkingLevel", "googleIncludeThoughts", "enableGoogleSearchGrounding", "enableGoogleUrlContext"];
74
+ /** @deprecated Use llmProfileDataKeys from llmProfileFieldRegistry instead. */
75
+ export declare const llmChatV2ProfileDataKeys: ("provider" | "model" | "maxTokens" | "temperature" | "topP" | "topK" | "presencePenalty" | "frequencyPenalty" | "stopSequences" | "seed" | "anthropicCacheControlTtl" | "customProviderApi" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "useModelInput" | "useTemperatureInput" | "useTopPInput" | "useTopKInput" | "usePresencePenaltyInput" | "useFrequencyPenaltyInput" | "useStopSequencesInput" | "useSeedInput" | "useMaxTokensInput" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs")[];
63
76
  export type LLMChatV2ProfileDataKey = (typeof llmChatV2ProfileDataKeys)[number];
64
77
  export type LLMChatV2ProfileData = Pick<LLMChatV2NodeData, LLMChatV2ProfileDataKey>;
65
78
  export type LLMChatV2EditorCacheKeyParts = {
79
+ /** Bump when cache identity semantics change; entries are editor-memory only. */
80
+ cacheVersion?: number;
66
81
  nodeId: NodeId;
67
82
  nodeData: LLMChatV2NodeData;
68
83
  provider: ChatV2Provider;
@@ -75,6 +90,7 @@ export type LLMChatV2EditorCacheKeyParts = {
75
90
  generationParameters: unknown;
76
91
  responseFormatParameters: unknown;
77
92
  providerOptions: unknown;
93
+ requestBodyOverlay?: unknown;
78
94
  toolChoice: unknown;
79
95
  /** Ordered, credential-fingerprinted fallback profile configuration. */
80
96
  profileChain?: unknown;
@@ -0,0 +1,8 @@
1
+ import type { ChartNode } from '../NodeBase.js';
2
+ /**
3
+ * Serialized LLM Chat migrations live beside the node contract, rather than
4
+ * making generic project serialization understand LLM-specific settings.
5
+ * This is deliberately idempotent because deserialization can normalize a
6
+ * graph more than once while it is imported or embedded in a prefab.
7
+ */
8
+ export declare function normalizeSerializedLLMChatV2Node(node: ChartNode): void;
@@ -1,35 +1,31 @@
1
1
  import type { GptFunction } from '../DataValue.js';
2
2
  import type { Inputs, Outputs } from '../GraphProcessor.js';
3
3
  import type { InternalProcessContext } from '../ProcessContext.js';
4
- import { type LLMProfileAttempt } from './llmProfileFallback.js';
5
- import type { ChatV2ProviderProfile } from './chatV2ProviderProfile.js';
6
- import { type ChatV2PipelineResult, type RunChatV2PipelineOptions } from './chatV2Types.js';
4
+ import { type LLMAttempt } from './llmProfileFallback.js';
5
+ import type { ChatV2Model, ChatV2PipelineRoundOptions, ChatV2PipelineResult } from './chatV2Types.js';
7
6
  import { buildLLMChatV2EditorCacheKey, cloneLLMChatV2EditorCacheOutputs } from './chatV2EditorCache.js';
8
7
  import { type LLMChatV2EditorCacheKeyParts, type LLMChatV2NodeData } from './llmChatV2NodeData.js';
9
8
  export { buildLLMChatV2EditorCacheKey, cloneLLMChatV2EditorCacheOutputs };
10
9
  export { resolveLLMChatV2RuntimeProviderOptions } from './chatV2RuntimeOptions.js';
11
- export type { LLMProfileAttempt } from './llmProfileFallback.js';
10
+ export type { LLMAttempt } from './llmProfileFallback.js';
12
11
  export type LLMChatV2RuntimeConfig = {
13
12
  /**
14
- * Shared invocation values plus a profile-shaped placeholder in From profile
15
- * mode. The actual provider model is resolved lazily by `runPipeline` so a
16
- * broken primary candidate can advance to the next profile.
13
+ * Initial continuation-round settings. In From profile mode, `runPipeline`
14
+ * resolves the actual provider model lazily so a broken primary candidate
15
+ * can advance to the next profile before any provider request is made.
17
16
  */
18
- runOptions: RunChatV2PipelineOptions;
19
- /** A safe summary of the first configured candidate for editor/runtime consumers. */
20
- providerProfile: ChatV2ProviderProfile;
21
- runPipeline: (options: RunChatV2PipelineOptions) => Promise<ChatV2PipelineResult>;
17
+ /** Inline keeps its resolved model for compatibility/inspection; profile mode intentionally omits it. */
18
+ runOptions: ChatV2PipelineRoundOptions & {
19
+ model?: ChatV2Model | undefined;
20
+ };
21
+ runPipeline: (options: ChatV2PipelineRoundOptions) => Promise<ChatV2PipelineResult>;
22
22
  functions: GptFunction[] | undefined;
23
23
  cacheKey: string | undefined;
24
24
  cachedOutputs: Outputs | undefined;
25
25
  editorCache: Map<string, unknown> | undefined;
26
26
  shouldAutoContinueToolCalls: boolean;
27
27
  maxToolRounds: number;
28
- profileAttempts: LLMProfileAttempt[] | undefined;
29
- /** True only when the incoming LLM Profile value was an actual array. */
30
- profileChainUsesArray: boolean;
31
- /** Defined for From profile runs, including a scalar single-profile input. */
32
- profileChainLength: number | undefined;
28
+ outputLLMAttempts: boolean;
33
29
  getProfileSummary: (() => string) | undefined;
34
30
  isProfileFallbackExhausted: () => boolean;
35
31
  };
@@ -38,4 +34,6 @@ export declare function resolveLLMChatV2RuntimeConfig(params: {
38
34
  nodeId: LLMChatV2EditorCacheKeyParts['nodeId'];
39
35
  inputs: Inputs;
40
36
  context: InternalProcessContext;
37
+ /** Invocation-owned observer; it must not affect fallback recovery. */
38
+ onLLMAttempt?: ((attempt: LLMAttempt) => void) | undefined;
41
39
  }): Promise<LLMChatV2RuntimeConfig>;
@@ -0,0 +1,16 @@
1
+ import type { ChatV2PipelineResult } from './chatV2Types.js';
2
+ import type { LLMChatV2RuntimeConfig } from './llmChatV2NodeRuntime.js';
3
+ import type { InternalProcessContext } from '../ProcessContext.js';
4
+ import type { ToolCallContinuation } from '../ToolCallContinuation.js';
5
+ import type { LLMInvocationJournal } from './llmInvocationJournal.js';
6
+ /**
7
+ * Owns the LLM-level recovery and continuation decision boundary. The node
8
+ * boundary provides a resolved runtime and GraphProcessor supplies only the
9
+ * connected Delegate host; no graph scheduling policy lives here.
10
+ */
11
+ export declare function executeLLMInvocation(params: {
12
+ context: InternalProcessContext;
13
+ journal: LLMInvocationJournal;
14
+ runtime: LLMChatV2RuntimeConfig;
15
+ toolCallContinuation: ToolCallContinuation | undefined;
16
+ }): Promise<ChatV2PipelineResult>;
@@ -0,0 +1,21 @@
1
+ import type { StreamedFunctionCall } from '../chat/streamChatResponse.js';
2
+ export type LLMInvocationRoundDecision = {
3
+ kind: 'final-model-answer';
4
+ } | {
5
+ kind: 'delegate-tools';
6
+ } | {
7
+ kind: 'release-unresolved-calls';
8
+ } | {
9
+ kind: 'max-rounds-reached';
10
+ } | {
11
+ kind: 'direct-tool-response';
12
+ };
13
+ /** Pure terminal/continuation policy, intentionally independent of scheduling. */
14
+ export declare function decideLLMInvocationRound(params: {
15
+ autoContinue: boolean;
16
+ completedRounds: number;
17
+ maxToolRounds: number;
18
+ calls: readonly StreamedFunctionCall[];
19
+ knownToolNames: ReadonlySet<string>;
20
+ isDirectReturn: boolean;
21
+ }): LLMInvocationRoundDecision;
@@ -0,0 +1,38 @@
1
+ import type { ChatV2CallFinishedEvent } from '../ProcessContext.js';
2
+ import type { LLMAttempt } from './llmProfileFallback.js';
3
+ export type LLMInvocationJournalEvent = {
4
+ type: 'model-call';
5
+ event: ChatV2CallFinishedEvent;
6
+ } | {
7
+ type: 'llm-attempt';
8
+ attempt: LLMAttempt;
9
+ } | {
10
+ type: 'tool-round';
11
+ kind: 'connected' | 'internal';
12
+ count: number;
13
+ } | {
14
+ type: 'terminal';
15
+ kind: 'final-model-answer' | 'released-unresolved-calls' | 'failed' | 'cancelled';
16
+ };
17
+ /**
18
+ * Invocation-scoped, append-only facts collected from physical provider calls.
19
+ * It stores physical-call accounting alongside the full developer-visible LLM
20
+ * attempt diagnostics selected by the node.
21
+ */
22
+ export declare class LLMInvocationJournal {
23
+ #private;
24
+ recordModelCall(event: ChatV2CallFinishedEvent): void;
25
+ recordToolRound(event: {
26
+ kind: 'connected' | 'internal';
27
+ count: number;
28
+ }): void;
29
+ recordLLMAttempt(attempt: LLMAttempt): void;
30
+ recordTerminal(event: {
31
+ kind: Extract<LLMInvocationJournalEvent, {
32
+ type: 'terminal';
33
+ }>['kind'];
34
+ }): void;
35
+ get modelCalls(): readonly ChatV2CallFinishedEvent[];
36
+ get events(): readonly LLMInvocationJournalEvent[];
37
+ get llmAttempts(): readonly LLMAttempt[];
38
+ }
@@ -0,0 +1,41 @@
1
+ import type { GptFunction } from '../DataValue.js';
2
+ import type { Inputs } from '../GraphProcessor.js';
3
+ import type { InternalProcessContext } from '../ProcessContext.js';
4
+ import { getInstructionMessageRoles } from './developerMessageRoles.js';
5
+ import { type ChatV2ResponseFormatParameters } from './chatV2ResponseFormat.js';
6
+ import { resolveLLMChatV2ToolChoice } from './chatV2RuntimeOptions.js';
7
+ import { type LLMChatV2NodeData } from './llmChatV2NodeData.js';
8
+ import { type RunChatV2PipelineOptions } from './chatV2Types.js';
9
+ import type { parseChatV2Provider } from './providerOptions.js';
10
+ import { type ChatV2ResponseBodyCapture } from './chatV2ResponseBodyCapture.js';
11
+ /** Provider-neutral state assembled once per root LLM invocation. */
12
+ export type LLMInvocationPlan = {
13
+ data: LLMChatV2NodeData;
14
+ inputs: Inputs;
15
+ context: InternalProcessContext;
16
+ prompt: unknown;
17
+ systemPrompt: unknown;
18
+ functions: GptFunction[] | undefined;
19
+ responseFormatParameters: ChatV2ResponseFormatParameters;
20
+ toolChoice: ReturnType<typeof resolveLLMChatV2ToolChoice>;
21
+ requestBodies: unknown[] | undefined;
22
+ responseBodies: unknown[] | undefined;
23
+ responseBodyCapture: ChatV2ResponseBodyCapture | undefined;
24
+ instructionRoles: ReturnType<typeof getInstructionMessageRoles>;
25
+ };
26
+ export declare function resolveLLMChatV2BaseURL(data: LLMChatV2NodeData, inputs: Inputs): string | undefined;
27
+ export declare function buildLLMInvocationPlan(params: {
28
+ data: LLMChatV2NodeData;
29
+ inputs: Inputs;
30
+ context: InternalProcessContext;
31
+ }): LLMInvocationPlan;
32
+ /**
33
+ * Build the provider-neutral portion of an executable round. A model is never
34
+ * fabricated here; candidate resolution supplies it before this reaches the
35
+ * request pipeline.
36
+ */
37
+ export declare function buildLLMInvocationRunOptions(params: {
38
+ plan: LLMInvocationPlan;
39
+ provider: ReturnType<typeof parseChatV2Provider>;
40
+ modelId: string;
41
+ }): Omit<RunChatV2PipelineOptions, 'model'>;
@@ -0,0 +1,3 @@
1
+ import type { ChatV2CallFinishedEvent } from '../ProcessContext.js';
2
+ /** Pure public-shape projections over privacy-bounded invocation facts. */
3
+ export declare function projectLLMInvocationUsage(events: readonly ChatV2CallFinishedEvent[]): import("./chatV2Types.js").ChatV2NormalizedUsage | undefined;
@@ -0,0 +1,26 @@
1
+ import type { Outputs } from '../GraphProcessor.js';
2
+ import type { ChatV2CallFinishedEvent } from '../ProcessContext.js';
3
+ import type { LLMAttempt } from './llmProfileFallback.js';
4
+ import type { ChatV2PipelineResult, ChatV2PipelineRoundOptions } from './chatV2Types.js';
5
+ type LLMInvocationDiagnosticProjectionOptions = {
6
+ runOptions: Pick<ChatV2PipelineRoundOptions, 'requestBodies' | 'responseBodies' | 'outputRequestBody' | 'outputResponseBody'>;
7
+ outputLLMAttempts: boolean | undefined;
8
+ llmAttempts: readonly LLMAttempt[];
9
+ profileSummary?: string | undefined;
10
+ };
11
+ /**
12
+ * Projects invocation facts that remain useful even when the node fails.
13
+ * Captured HTTP bodies are emitted only through their opt-in ports, while
14
+ * attempts and profile summaries retain the same public shapes as a success.
15
+ */
16
+ export declare function projectLLMInvocationDiagnostics({ runOptions, outputLLMAttempts, llmAttempts, profileSummary, }: LLMInvocationDiagnosticProjectionOptions): Outputs;
17
+ /** Applies existing public LLM Chat output shapes from invocation facts. */
18
+ export declare function projectLLMInvocationResult(params: {
19
+ result: ChatV2PipelineResult;
20
+ modelCalls: readonly ChatV2CallFinishedEvent[];
21
+ outputUsage: boolean | undefined;
22
+ outputLLMAttempts: boolean | undefined;
23
+ llmAttempts: readonly LLMAttempt[];
24
+ profileSummary?: string | undefined;
25
+ }): Outputs;
26
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { LLMInvocationPlan } from './llmInvocationPlan.js';
2
+ import { applyLLMProfileToNodeData } from './llmProfile.js';
3
+ import type { LLMProfileValue } from './llmProfileTypes.js';
4
+ import { type ChatV2CredentialResult } from './chatV2ProviderProfile.js';
5
+ import { type LLMChatV2RequestBodyOverlay } from './chatV2RuntimeOptions.js';
6
+ import type { ChatV2PipelineRoundOptions, RunChatV2PipelineOptions } from './chatV2Types.js';
7
+ import { type ResolvedChatV2ProviderConfig } from './providerOptions.js';
8
+ /** A fully executable model/profile selection plus safe configuration facts. */
9
+ export type ResolvedLLMModelCandidate = {
10
+ effectiveData: ReturnType<typeof applyLLMProfileToNodeData>;
11
+ credential: ChatV2CredentialResult;
12
+ providerConfig: ResolvedChatV2ProviderConfig;
13
+ requestBodyOverlay: LLMChatV2RequestBodyOverlay | undefined;
14
+ runOptions: RunChatV2PipelineOptions;
15
+ };
16
+ export declare function resolveLLMModelCandidate(params: {
17
+ plan: LLMInvocationPlan;
18
+ profile?: LLMProfileValue | undefined;
19
+ roundOptions?: ChatV2PipelineRoundOptions | undefined;
20
+ }): Promise<ResolvedLLMModelCandidate>;
@@ -1,4 +1,6 @@
1
1
  import { type LLMProfileValue } from './llmProfileTypes.js';
2
+ import type { NodeId } from '../NodeBase.js';
3
+ import type { ProjectId } from '../Project.js';
2
4
  export { applyLLMProfileToNodeData, createDefaultLLMProfileValue, createLLMProfileNodeData, LLM_PROFILE_VALUE_VERSION, pickLLMChatV2ProfileData, type LLMProfileValue, } from './llmProfileTypes.js';
3
5
  export declare function normalizeLLMProfileValue(value: unknown): LLMProfileValue;
4
6
  /**
@@ -8,3 +10,15 @@ export declare function normalizeLLMProfileValue(value: unknown): LLMProfileValu
8
10
  * malformed values without re-entering scalar coercion.
9
11
  */
10
12
  export declare function normalizeLLMProfileChainInput(value: unknown): LLMProfileValue[];
13
+ /**
14
+ * Programmatic or serialized llm-config values may originate outside the
15
+ * currently executing project. Always bind health to that project before
16
+ * shared storage is consulted so copied values cannot share a circuit across
17
+ * projects. Preserve an originating profile-node identity when one exists;
18
+ * otherwise the consuming Chat node owns the identity.
19
+ */
20
+ export declare function scopeLLMProfileHealthIdentity(profile: LLMProfileValue, fallback: {
21
+ projectId: ProjectId;
22
+ profileNodeId: NodeId;
23
+ chatNodeHeaders?: Record<string, string> | undefined;
24
+ }): LLMProfileValue;
@@ -0,0 +1,20 @@
1
+ import type { LLMChatV2ProfileData } from './llmChatV2NodeData.js';
2
+ export type LLMProfileBodyField = Readonly<{
3
+ label: string;
4
+ value: string;
5
+ }>;
6
+ export type LLMProfileBodySnippet = Readonly<{
7
+ label: string;
8
+ text: string;
9
+ }>;
10
+ export type LLMProfileBodySection = Readonly<{
11
+ id: 'model' | 'parameters' | 'provider' | 'reliability' | 'advanced';
12
+ fields: readonly LLMProfileBodyField[];
13
+ snippet?: LLMProfileBodySnippet | undefined;
14
+ }>;
15
+ /**
16
+ * Stable canvas presentation data for LLM Profile configuration. It deliberately
17
+ * contains stored configuration only: runtime API-key values are never present
18
+ * in the node data and therefore cannot be rendered here.
19
+ */
20
+ export declare function getLLMProfileBodySections(data: LLMChatV2ProfileData): readonly LLMProfileBodySection[];
@@ -1,73 +1,56 @@
1
- import { type ChatV2Provider, type ChatV2PipelineResult, type RunChatV2PipelineOptions } from './chatV2Types.js';
2
- export type LLMProfileAttempt = {
1
+ import { type ChatV2Provider, type ChatV2PipelineRoundOptions, type ChatV2PipelineResult, type RunChatV2PipelineOptions } from './chatV2Types.js';
2
+ import { type CustomProviderApi } from './customProviderApi.js';
3
+ import { type RivetLLMProfileCircuitBreakerPolicy, type RivetLLMProfileHealthIdentity, type RivetLLMProfileHealthOutcome, type RivetLLMProfileHealthState, type RivetLLMProfileHealthStore } from './llmProfileHealthStore.js';
4
+ export type LLMAttempt = {
3
5
  roundIndex: number;
4
- profileIndex: number;
6
+ /** Present when a From profile candidate produced this attempt. */
7
+ profileIndex?: number;
5
8
  provider: ChatV2Provider;
6
9
  model: string;
7
- stage: 'configuration' | 'request';
8
- outcome: 'success' | 'failure';
10
+ customProviderApi?: CustomProviderApi;
11
+ stage: 'configuration' | 'request' | 'response-validation' | 'health-gate' | 'health-update';
12
+ outcome: 'success' | 'failure' | 'aborted' | 'skipped';
9
13
  attemptIndex?: number;
10
14
  status?: number;
11
15
  error?: string;
16
+ profileHealthKey?: string;
17
+ healthState?: RivetLLMProfileHealthState;
18
+ healthDisposition?: 'allow' | 'deny' | 'fail-open';
19
+ healthOutcome?: RivetLLMProfileHealthOutcome;
20
+ retryAt?: number;
21
+ timeoutKind?: 'first-output' | 'stream-inactivity';
22
+ };
23
+ export type LLMProfileFallbackHealth = {
24
+ identity: RivetLLMProfileHealthIdentity;
25
+ policy: RivetLLMProfileCircuitBreakerPolicy;
26
+ firstOutputTimeoutMs: number;
27
+ streamInactivityTimeoutMs: number;
12
28
  };
13
29
  export type LLMProfileFallbackCandidate = {
14
30
  provider: ChatV2Provider;
15
31
  model: string;
16
- credential?: string | undefined;
17
- /** Additional known request secrets, such as profile or global header values. */
18
- redactionValues?: readonly string[] | undefined;
32
+ customProviderApi?: CustomProviderApi;
33
+ health?: LLMProfileFallbackHealth;
19
34
  };
20
- /**
21
- * Request-level diagnostics grouped by the configured LLM Profile order.
22
- *
23
- * `LLMProfileAttempt` deliberately retains the full chronology and round
24
- * information. These compact arrays are the shape used by the familiar
25
- * Response Status and Response Error outputs when a profile *array* drives
26
- * LLM Chat: outer index is the input profile index; inner order is the
27
- * physical request order for that profile across the whole invocation.
28
- */
29
- export type LLMProfileRequestDiagnostics = {
30
- statuses: Array<number | number[]>;
31
- errors: LLMProfileRequestErrorDiagnostics;
32
- };
33
- /**
34
- * Compact error diagnostics for an LLM Profile array.
35
- *
36
- * A single request failure is easier to inspect as a string, while retries
37
- * still need an array. When every candidate completed without a request error,
38
- * there is nothing useful to preserve per profile, so the value is simply an
39
- * empty array. The detailed LLM Profile Attempts output remains the canonical
40
- * per-profile/per-attempt record in every case.
41
- */
42
- export type LLMProfileRequestErrorDiagnostics = string | string[] | Array<string | string[]>;
43
35
  export type LLMProfileFallbackRunner = {
44
- run: (roundOptions: RunChatV2PipelineOptions) => Promise<ChatV2PipelineResult>;
45
- attempts: LLMProfileAttempt[];
36
+ run: (roundOptions: ChatV2PipelineRoundOptions) => Promise<ChatV2PipelineResult>;
37
+ attempts: LLMAttempt[];
46
38
  summary: () => string;
47
39
  wasExhausted: () => boolean;
48
40
  };
49
41
  export declare class LLMProfileFallbackExhaustedError extends Error {
50
- readonly attempts: readonly LLMProfileAttempt[];
51
- constructor(attempts: readonly LLMProfileAttempt[]);
42
+ readonly attempts: readonly LLMAttempt[];
43
+ constructor(attempts: readonly LLMAttempt[]);
52
44
  }
45
+ export declare function getLLMAttemptErrorMessage(error: unknown): string;
53
46
  /**
54
47
  * Produces the concise, developer-facing companion to the full attempt trace.
55
48
  * It deliberately includes candidates that were never reached, so a successful
56
49
  * primary profile does not make the configured fallback order invisible.
57
50
  */
58
- export declare function buildLLMProfileFallbackSummary(candidates: readonly LLMProfileFallbackCandidate[], attempts: readonly LLMProfileAttempt[]): string;
59
- export declare function buildLLMProfileRequestDiagnostics(profileCount: number, attempts: readonly LLMProfileAttempt[]): LLMProfileRequestDiagnostics;
60
- /**
61
- * Preserves one profile slot per input profile while making a single physical
62
- * request easy to read. This also repairs cache entries made before the
63
- * scalar-single-status contract was introduced.
64
- */
65
- export declare function compactLLMProfileRequestStatuses(statuses: readonly unknown[]): unknown[];
66
- /**
67
- * Keeps Response Error readable for profile-array fallback chains and repairs
68
- * editor-cache entries written before that compact presentation contract.
69
- */
70
- export declare function compactLLMProfileRequestErrors(errors: readonly unknown[]): unknown;
51
+ export declare function buildLLMProfileFallbackSummary(candidates: readonly LLMProfileFallbackCandidate[], attempts: readonly LLMAttempt[]): string;
52
+ /** Classifies only provider availability failures, never local/configuration errors. */
53
+ export declare function isUnhealthyLLMProfileProviderFailure(error: unknown): boolean;
71
54
  /**
72
55
  * Creates one forward-only fallback chain for a whole LLM Chat invocation.
73
56
  * A model which succeeds in an earlier tool round stays active for subsequent
@@ -75,5 +58,9 @@ export declare function compactLLMProfileRequestErrors(errors: readonly unknown[
75
58
  */
76
59
  export declare function createLLMProfileFallbackRunner(params: {
77
60
  candidates: readonly LLMProfileFallbackCandidate[];
78
- resolveCandidate: (profileIndex: number, roundOptions: RunChatV2PipelineOptions) => Promise<RunChatV2PipelineOptions>;
61
+ resolveCandidate: (profileIndex: number, roundOptions: ChatV2PipelineRoundOptions) => Promise<RunChatV2PipelineOptions>;
62
+ onAttempt?: ((attempt: LLMAttempt) => void) | undefined;
63
+ healthStore?: RivetLLMProfileHealthStore | undefined;
64
+ /** Internal test/host hardening seam; ordinary runs use the bounded default. */
65
+ healthOperationTimeoutMs?: number | undefined;
79
66
  }): LLMProfileFallbackRunner;