@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.
- package/dist/cjs/bundle.cjs +3596 -1745
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/webAppRuntime.cjs +298 -21
- package/dist/cjs/webAppRuntime.cjs.map +4 -4
- package/dist/esm/exports.js +1 -0
- package/dist/esm/model/AgentResponseTrace.js +448 -0
- package/dist/esm/model/ConnectedToolContinuationHost.js +33 -0
- package/dist/esm/model/GraphProcessor.js +151 -74
- package/dist/esm/model/NodeImpl.js +6 -0
- package/dist/esm/model/ProcessContextBuilder.js +3 -1
- package/dist/esm/model/RecordingPlayer.js +164 -22
- package/dist/esm/model/SplitRunProcessor.js +49 -8
- package/dist/esm/model/SubprocessorBridge.js +2 -0
- package/dist/esm/model/ToolCallContinuationCoordinator.js +7 -3
- package/dist/esm/model/UiGraph.js +21 -0
- package/dist/esm/model/UiGraphActionProtocol.js +2 -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/chatV2CallObserver.js +9 -5
- package/dist/esm/model/chat-v2/chatV2EditorCache.js +42 -16
- 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 +61 -146
- package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +8 -2
- 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 +55 -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 +6 -1
- package/dist/esm/model/chat-v2/chatV2Types.js +5 -9
- package/dist/esm/model/chat-v2/chatV2UsageAccounting.js +78 -0
- package/dist/esm/model/chat-v2/customProviderApi.js +42 -0
- package/dist/esm/model/chat-v2/index.js +12 -0
- package/dist/esm/model/chat-v2/llmChatV2Body.js +281 -0
- package/dist/esm/model/chat-v2/llmChatV2CacheBoundary.js +32 -0
- package/dist/esm/model/chat-v2/llmChatV2CachePolicy.js +20 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeData.js +6 -50
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +25 -13
- package/dist/esm/model/chat-v2/llmChatV2NodeMigration.js +24 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +121 -193
- 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 +75 -0
- package/dist/esm/model/chat-v2/llmProfile.js +10 -65
- package/dist/esm/model/chat-v2/llmProfileBody.js +183 -0
- package/dist/esm/model/chat-v2/llmProfileFallback.js +55 -99
- package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +67 -0
- package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +3 -0
- 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 +86 -20
- 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/DelegateFunctionCallNode.js +19 -6
- package/dist/esm/model/nodes/LLMChatV2Node.js +112 -229
- package/dist/esm/model/nodes/LLMProfileNode.js +27 -8
- 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/google/google.js +5 -9
- package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +4 -1
- package/dist/esm/recording/ExecutionRecorder.js +13 -5
- 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/exports.d.ts +1 -0
- package/dist/types/model/AgentResponseTrace.d.ts +110 -0
- package/dist/types/model/ConnectedToolContinuationHost.d.ts +34 -0
- package/dist/types/model/ExecutorProtocol.d.ts +25 -7
- package/dist/types/model/GraphProcessor.d.ts +27 -5
- 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 +47 -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 +2 -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/chatV2EditorCache.d.ts +1 -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 +4 -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 +19 -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/chatV2Types.d.ts +20 -10
- package/dist/types/model/chat-v2/chatV2UsageAccounting.d.ts +14 -0
- package/dist/types/model/chat-v2/customProviderApi.d.ts +23 -0
- package/dist/types/model/chat-v2/index.d.ts +12 -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 +10 -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 +18 -0
- package/dist/types/model/chat-v2/llmProfileBody.d.ts +20 -0
- package/dist/types/model/chat-v2/llmProfileFallback.d.ts +17 -49
- package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +189 -0
- package/dist/types/model/chat-v2/llmProfileTypes.d.ts +1 -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 +10 -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/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/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/google/google.d.ts +2 -8
- 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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { LanguageModelUsage } from 'ai';
|
|
2
|
-
import type { ChatMessage } from '../DataValue.js';
|
|
2
|
+
import type { ChatMessage, DataValue } from '../DataValue.js';
|
|
3
3
|
import type { Outputs } from '../GraphProcessor.js';
|
|
4
4
|
import { type StreamedFunctionCall } from '../chat/streamChatResponse.js';
|
|
5
5
|
import { type ChatV2NormalizedUsage, type ChatV2ReasoningOutput, type RunChatV2PipelineOptions } from './chatV2Types.js';
|
|
6
|
-
type ChatV2CommonOutputOptions = Pick<RunChatV2PipelineOptions, 'outputUsage' | 'outputReasoning' | '
|
|
6
|
+
type ChatV2CommonOutputOptions = Pick<RunChatV2PipelineOptions, 'outputUsage' | 'outputReasoning' | 'outputRequestBody' | 'outputResponseBody' | 'includeFunctionCalls' | 'functionCallMode' | 'responseFormat'>;
|
|
7
7
|
type CreateChatV2CommonOutputsOptions = ChatV2CommonOutputOptions & {
|
|
8
8
|
requestMessages: ChatMessage[];
|
|
9
9
|
response: string;
|
|
@@ -11,21 +11,11 @@ type CreateChatV2CommonOutputsOptions = ChatV2CommonOutputOptions & {
|
|
|
11
11
|
functionCalls: StreamedFunctionCall[];
|
|
12
12
|
usage: ChatV2NormalizedUsage | undefined;
|
|
13
13
|
reasoning: ChatV2ReasoningOutput | undefined;
|
|
14
|
-
requestStatus: number | undefined;
|
|
15
|
-
responseError: string | undefined;
|
|
16
|
-
requestStatuses: number[];
|
|
17
|
-
requestErrors: string[];
|
|
18
|
-
requestBodies?: unknown[] | undefined;
|
|
19
|
-
};
|
|
20
|
-
type CreateChatV2ProviderFailureOutputsOptions = Pick<RunChatV2PipelineOptions, 'outputUsage' | 'outputReasoning' | 'outputRequestStatus' | 'outputRequestError' | 'outputRequestBody' | 'includeFunctionCalls' | 'retryOnNon200'> & {
|
|
21
|
-
requestMessages: ChatMessage[];
|
|
22
|
-
responseStatus: number | undefined;
|
|
23
|
-
responseError: string;
|
|
24
|
-
requestStatuses: number[];
|
|
25
|
-
requestErrors: string[];
|
|
26
14
|
requestBodies?: unknown[] | undefined;
|
|
15
|
+
responseBodies?: unknown[] | undefined;
|
|
27
16
|
};
|
|
28
17
|
export declare function normalizeChatV2Usage(usage: LanguageModelUsage | undefined, options: Pick<RunChatV2PipelineOptions, 'provider' | 'modelId'>): ChatV2NormalizedUsage | undefined;
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function
|
|
18
|
+
export declare function createChatV2ResponseOutput(response: string, structuredOutput: unknown | undefined, responseFormat: RunChatV2PipelineOptions['responseFormat']): DataValue;
|
|
19
|
+
export declare function createChatV2CapturedBodyOutputs(options: Pick<RunChatV2PipelineOptions, 'requestBodies' | 'responseBodies' | 'outputRequestBody' | 'outputResponseBody'>): Outputs;
|
|
20
|
+
export declare function createChatV2CommonOutputs({ requestMessages, response, structuredOutput, functionCalls, usage, reasoning, requestBodies, responseBodies, outputUsage, outputReasoning, outputRequestBody, outputResponseBody, includeFunctionCalls, functionCallMode, responseFormat, }: CreateChatV2CommonOutputsOptions): Outputs;
|
|
31
21
|
export {};
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import type { ChatMessage } from '../DataValue.js';
|
|
2
1
|
import type { ChatV2PipelineResult, RunChatV2PipelineOptions } from './chatV2Types.js';
|
|
3
|
-
import { type ChatV2RequestPlan } from './chatV2RequestPlan.js';
|
|
4
2
|
export type ChatV2PipelineProviderFailure = {
|
|
5
|
-
requestMessages: ChatMessage[];
|
|
6
3
|
options: RunChatV2PipelineOptions;
|
|
7
|
-
plan: ChatV2RequestPlan;
|
|
8
4
|
normalizedError: unknown;
|
|
9
|
-
rawError: unknown;
|
|
10
|
-
requestStatuses: number[];
|
|
11
|
-
requestErrors: string[];
|
|
12
|
-
/** A completed non-200 custom stream may still have a useful response body. */
|
|
13
|
-
diagnosticResult?: ChatV2PipelineResult;
|
|
14
5
|
};
|
|
15
6
|
export type ChatV2PipelineExecution = {
|
|
16
7
|
outcome: 'success';
|
|
@@ -19,17 +10,22 @@ export type ChatV2PipelineExecution = {
|
|
|
19
10
|
outcome: 'provider-failure';
|
|
20
11
|
failure: ChatV2PipelineProviderFailure;
|
|
21
12
|
};
|
|
13
|
+
/** Identifies legacy pipeline results that represent a terminal provider failure. */
|
|
14
|
+
export declare function isChatV2PipelineProviderFailureResult(result: ChatV2PipelineResult): boolean;
|
|
15
|
+
export declare class ChatV2ResponseValidationError extends Error {
|
|
16
|
+
readonly responseDataType: string;
|
|
17
|
+
constructor(responseDataType: string);
|
|
18
|
+
}
|
|
19
|
+
export declare function isChatV2ResponseValidationError(error: unknown): error is ChatV2ResponseValidationError;
|
|
22
20
|
/**
|
|
23
|
-
* Runs one provider/model round
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* to throw: they are graph configuration errors, not a profile failure.
|
|
21
|
+
* Runs one provider/model round. Provider failures stay distinct from shared
|
|
22
|
+
* graph configuration errors so an LLM Profile fallback chain can advance to
|
|
23
|
+
* its next candidate; terminal failures always remain node errors.
|
|
27
24
|
*/
|
|
28
25
|
export declare function runChatV2PipelineExecution(options: RunChatV2PipelineOptions): Promise<ChatV2PipelineExecution>;
|
|
29
26
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* a thrown normalized provider error.
|
|
27
|
+
* Terminal provider failures are node errors. The fallback coordinator may
|
|
28
|
+
* still catch this decision boundary and advance to a later LLM Profile.
|
|
33
29
|
*/
|
|
34
|
-
export declare function materializeChatV2PipelineFailure(failure: ChatV2PipelineProviderFailure):
|
|
30
|
+
export declare function materializeChatV2PipelineFailure(failure: ChatV2PipelineProviderFailure): never;
|
|
35
31
|
export declare function runChatV2Pipeline(options: RunChatV2PipelineOptions): Promise<ChatV2PipelineResult>;
|
|
@@ -2,6 +2,7 @@ import type { Inputs } from '../GraphProcessor.js';
|
|
|
2
2
|
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
3
3
|
import { type CreateChatV2ModelOptions, type ResolvedChatV2ProviderConfig } from './providerOptions.js';
|
|
4
4
|
import type { ChatV2Model, ChatV2Provider } from './chatV2Types.js';
|
|
5
|
+
import type { CustomProviderApi } from './customProviderApi.js';
|
|
5
6
|
export type ChatV2CredentialReference = {
|
|
6
7
|
source: 'input' | 'settings' | 'plugin' | 'programmatic' | 'environment' | 'none';
|
|
7
8
|
name?: string | undefined;
|
|
@@ -13,6 +14,7 @@ export type ChatV2CredentialResult = {
|
|
|
13
14
|
export type ChatV2ProviderProfile = {
|
|
14
15
|
provider: ChatV2Provider;
|
|
15
16
|
modelId: string;
|
|
17
|
+
customProviderApi?: CustomProviderApi | undefined;
|
|
16
18
|
baseURL?: string | undefined;
|
|
17
19
|
hasCustomHeaders: boolean;
|
|
18
20
|
credential: ChatV2CredentialReference;
|
|
@@ -38,7 +40,9 @@ export declare function createResolvedChatV2Provider(options: {
|
|
|
38
40
|
headers?: Record<string, string> | undefined;
|
|
39
41
|
credential: ChatV2CredentialResult;
|
|
40
42
|
onRequestBody?: CreateChatV2ModelOptions['onRequestBody'];
|
|
43
|
+
onResponseBody?: CreateChatV2ModelOptions['onResponseBody'];
|
|
41
44
|
transformRequestBody?: CreateChatV2ModelOptions['transformRequestBody'];
|
|
45
|
+
customProviderApi?: CustomProviderApi | undefined;
|
|
42
46
|
}): Promise<{
|
|
43
47
|
profile: ChatV2ProviderProfile;
|
|
44
48
|
model: ChatV2Model;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChatV2Provider } from './chatV2Types.js';
|
|
2
|
+
/** Closed, provider-neutral capability table for the providers Rivet ships. */
|
|
3
|
+
export type ChatV2ProviderCapabilities = {
|
|
4
|
+
builtInTools: boolean;
|
|
5
|
+
parallelToolCalls: boolean;
|
|
6
|
+
structuredOutput: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function getChatV2ProviderCapabilities(provider: ChatV2Provider): ChatV2ProviderCapabilities;
|
|
@@ -10,9 +10,9 @@ export type ChatV2RequestPlan = {
|
|
|
10
10
|
cooldownMs: number;
|
|
11
11
|
};
|
|
12
12
|
request: Omit<StreamChatV2Options, 'abortSignal' | 'executeStream' | 'executeGenerate' | 'onPartialOutput'>;
|
|
13
|
-
output: Pick<RunChatV2PipelineOptions, 'outputUsage' | 'outputReasoning' | '
|
|
13
|
+
output: Pick<RunChatV2PipelineOptions, 'outputUsage' | 'outputReasoning' | 'outputRequestBody' | 'outputResponseBody' | 'includeFunctionCalls' | 'functionCallMode'>;
|
|
14
14
|
};
|
|
15
|
-
type BuildChatV2RequestPlanOptions = Pick<RunChatV2PipelineOptions, 'provider' | 'model' | 'modelId' | 'maxTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'responseOutput' | 'responseFormat' | 'providerOptions' | 'toolChoice' | 'retryOnNon200' | 'retryOnNon200RepeatTimes' | 'retryOnNon200CooldownMs' | 'outputUsage' | 'outputReasoning' | '
|
|
15
|
+
type BuildChatV2RequestPlanOptions = Pick<RunChatV2PipelineOptions, 'provider' | 'model' | 'modelId' | 'maxTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'responseOutput' | 'responseFormat' | 'providerOptions' | 'toolChoice' | 'retryOnNon200' | 'retryOnNon200RepeatTimes' | 'retryOnNon200CooldownMs' | 'outputUsage' | 'outputReasoning' | 'outputRequestBody' | 'outputResponseBody' | 'includeFunctionCalls' | 'emitPartialOutputs' | 'functionCallMode'> & {
|
|
16
16
|
messages: ChatV2MessageList;
|
|
17
17
|
tools?: ChatV2ToolSet | undefined;
|
|
18
18
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Captures provider HTTP response bodies for the opt-in LLM Chat diagnostic
|
|
3
|
+
* output without consuming the Response that the AI SDK is still streaming.
|
|
4
|
+
*/
|
|
5
|
+
export type ChatV2ResponseBodyCapture = {
|
|
6
|
+
/** Captured bodies in physical provider-response order. */
|
|
7
|
+
readonly bodies: unknown[];
|
|
8
|
+
/** Starts an independent clone read for one provider HTTP response. */
|
|
9
|
+
capture(response: Response): void;
|
|
10
|
+
/** Waits for every response observed so far to finish cloning. */
|
|
11
|
+
flush(): Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A failed clone is intentionally omitted instead of changing provider
|
|
15
|
+
* behavior. Captured diagnostics do not redact or truncate provider content.
|
|
16
|
+
* JSON is parsed only to make it inspectable as structured output; all other
|
|
17
|
+
* bodies remain their original text.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createChatV2ResponseBodyCapture(): ChatV2ResponseBodyCapture;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Inputs } from '../GraphProcessor.js';
|
|
2
2
|
import type { ChatV2Provider, ChatV2ProviderOptions, ChatV2ResponseOutput } from './chatV2Types.js';
|
|
3
|
+
import { type CustomProviderApi } from './customProviderApi.js';
|
|
3
4
|
export type ChatV2ResponseFormat = '' | 'text' | 'json' | 'json_schema';
|
|
4
5
|
export type ChatV2StructuredResponseFormat = Extract<ChatV2ResponseFormat, 'json' | 'json_schema'>;
|
|
5
6
|
export type ChatV2ResponseFormatData = {
|
|
@@ -23,5 +24,5 @@ export type ChatV2ResponseFormatParameters = undefined | {
|
|
|
23
24
|
};
|
|
24
25
|
export declare function isChatV2StructuredResponseFormat(responseFormat: unknown): responseFormat is ChatV2StructuredResponseFormat;
|
|
25
26
|
export declare function resolveChatV2ResponseFormatParameters(data: ChatV2ResponseFormatData, inputs: Inputs): ChatV2ResponseFormatParameters;
|
|
26
|
-
export declare function createChatV2ResponseOutput(parameters: ChatV2ResponseFormatParameters, provider?: ChatV2Provider): ChatV2ResponseOutput | undefined;
|
|
27
|
-
export declare function mergeCustomProviderResponseFormatOptions(provider: ChatV2Provider, providerOptions: ChatV2ProviderOptions | undefined, parameters: ChatV2ResponseFormatParameters): ChatV2ProviderOptions | undefined;
|
|
27
|
+
export declare function createChatV2ResponseOutput(parameters: ChatV2ResponseFormatParameters, provider?: ChatV2Provider, customProviderApi?: CustomProviderApi): ChatV2ResponseOutput | undefined;
|
|
28
|
+
export declare function mergeCustomProviderResponseFormatOptions(provider: ChatV2Provider, providerOptions: ChatV2ProviderOptions | undefined, parameters: ChatV2ResponseFormatParameters, customProviderApi?: CustomProviderApi): ChatV2ProviderOptions | undefined;
|
|
@@ -2,4 +2,6 @@ export declare const DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_REPEAT_TIMES = 1;
|
|
|
2
2
|
export declare const DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_COOLDOWN_MS = 0;
|
|
3
3
|
export declare function normalizeLLMChatV2RetryCount(value: number | undefined): number;
|
|
4
4
|
export declare function normalizeLLMChatV2RetryCooldownMs(value: number | undefined): number;
|
|
5
|
+
/** Keeps cancellation identity consistent before and during a retry cooldown. */
|
|
6
|
+
export declare function createLLMChatV2RetryAbortError(): Error;
|
|
5
7
|
export declare function waitForLLMChatV2RetryCooldown(cooldownMs: number, signal: AbortSignal): Promise<void>;
|
|
@@ -4,6 +4,8 @@ import type { Outputs } from '../GraphProcessor.js';
|
|
|
4
4
|
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
5
5
|
import type { AssistantMessageFunctionCallMode, StreamedFunctionCall } from '../chat/streamChatResponse.js';
|
|
6
6
|
import type { ChatV2Provider } from './chatV2ProviderTypes.js';
|
|
7
|
+
import type { ChatV2ResponseBodyCapture } from './chatV2ResponseBodyCapture.js';
|
|
8
|
+
import type { CustomProviderApi } from './customProviderApi.js';
|
|
7
9
|
export type { ChatV2Provider };
|
|
8
10
|
type StreamTextArgs = Parameters<typeof streamText>[0];
|
|
9
11
|
type GenerateTextArgs = Parameters<typeof generateText>[0];
|
|
@@ -111,11 +113,12 @@ export type RunChatV2PipelineOptions = {
|
|
|
111
113
|
toolChoice?: ChatV2ToolChoice | undefined;
|
|
112
114
|
anthropicCacheControlTtl?: '5m' | '1h' | undefined;
|
|
113
115
|
requestBodies?: unknown[] | undefined;
|
|
116
|
+
responseBodies?: unknown[] | undefined;
|
|
117
|
+
responseBodyCapture?: ChatV2ResponseBodyCapture | undefined;
|
|
114
118
|
outputUsage?: boolean | undefined;
|
|
115
119
|
outputReasoning?: boolean | undefined;
|
|
116
|
-
outputRequestStatus?: boolean | undefined;
|
|
117
|
-
outputRequestError?: boolean | undefined;
|
|
118
120
|
outputRequestBody?: boolean | undefined;
|
|
121
|
+
outputResponseBody?: boolean | undefined;
|
|
119
122
|
includeFunctionCalls?: boolean | undefined;
|
|
120
123
|
emitPartialOutputs?: boolean | undefined;
|
|
121
124
|
functionCallMode?: AssistantMessageFunctionCallMode | undefined;
|
|
@@ -129,22 +132,22 @@ export type RunChatV2PipelineOptions = {
|
|
|
129
132
|
*/
|
|
130
133
|
profileIndex?: number | undefined;
|
|
131
134
|
roundIndex?: number | undefined;
|
|
135
|
+
/** Selected wire contract for Custom-provider calls. Never sent to the provider. */
|
|
136
|
+
customProviderApi?: CustomProviderApi | undefined;
|
|
132
137
|
/** Internal physical-call trace used by the LLM Profile fallback coordinator. */
|
|
133
138
|
onProviderAttempt?: ((attempt: ChatV2ProviderAttempt) => void) | undefined;
|
|
134
139
|
context: Pick<InternalProcessContext, 'signal' | 'onPartialOutputs'> & Partial<Pick<InternalProcessContext, 'node' | 'onChatV2CallFinished' | 'processId'>>;
|
|
135
140
|
executeStream?: ChatV2StreamExecutor | undefined;
|
|
136
141
|
executeGenerate?: ChatV2GenerateExecutor | undefined;
|
|
137
142
|
};
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
export declare function shouldOutputChatV2RequestError(options: Pick<RunChatV2PipelineOptions, 'outputRequestStatus' | 'outputRequestError'>): boolean;
|
|
144
|
-
export declare function shouldOutputChatV2RequestBody(options: Pick<RunChatV2PipelineOptions, 'outputRequestStatus' | 'outputRequestBody'>): boolean;
|
|
143
|
+
/** Provider-neutral per-round fields. Candidate resolution supplies the model. */
|
|
144
|
+
export type ChatV2PipelineRoundOptions = Omit<RunChatV2PipelineOptions, 'model'>;
|
|
145
|
+
export declare function shouldOutputChatV2RequestBody(options: Pick<RunChatV2PipelineOptions, 'outputRequestBody'>): boolean;
|
|
146
|
+
/** New diagnostics are opt-in; old status-detail nodes never expose responses. */
|
|
147
|
+
export declare function shouldOutputChatV2ResponseBody(options: Pick<RunChatV2PipelineOptions, 'outputResponseBody'>): boolean;
|
|
145
148
|
export type ChatV2ProviderAttempt = {
|
|
146
149
|
attemptIndex: number;
|
|
147
|
-
outcome: 'success' | 'provider-failure';
|
|
150
|
+
outcome: 'success' | 'provider-failure' | 'aborted';
|
|
148
151
|
status?: number | undefined;
|
|
149
152
|
error?: unknown;
|
|
150
153
|
};
|
|
@@ -160,4 +163,11 @@ export type ChatV2PipelineResult = {
|
|
|
160
163
|
finishReason: string | undefined;
|
|
161
164
|
providerMetadata: ChatV2ProviderMetadata | undefined;
|
|
162
165
|
requestStatus: number | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* Internal terminal classification for a provider request that produced
|
|
168
|
+
* diagnostic outputs instead of throwing. A non-200 response can still
|
|
169
|
+
* carry partial text or tool-like data; it must never enter tool
|
|
170
|
+
* continuation as though the provider completed successfully.
|
|
171
|
+
*/
|
|
172
|
+
terminalOutcome?: 'provider-failure' | undefined;
|
|
163
173
|
};
|
|
@@ -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,23 @@
|
|
|
1
|
+
export type CustomProviderApi = 'completions' | 'responses';
|
|
2
|
+
export type CustomProviderApiContract = Readonly<{
|
|
3
|
+
api: CustomProviderApi;
|
|
4
|
+
adapter: 'openai-compatible' | 'openai-responses';
|
|
5
|
+
providerOptionsKey: 'custom' | 'openai';
|
|
6
|
+
endpointPath: '/chat/completions' | '/responses';
|
|
7
|
+
label: 'Custom Completions' | 'Custom Responses';
|
|
8
|
+
structuredOutput: 'raw-response-format' | 'sdk-output';
|
|
9
|
+
parallelToolCalls: 'enabled-only-raw-field' | 'openai-option';
|
|
10
|
+
}>;
|
|
11
|
+
export declare const customProviderApiOptions: readonly [{
|
|
12
|
+
readonly value: "completions";
|
|
13
|
+
readonly label: "Completions";
|
|
14
|
+
}, {
|
|
15
|
+
readonly value: "responses";
|
|
16
|
+
readonly label: "Responses";
|
|
17
|
+
}];
|
|
18
|
+
/**
|
|
19
|
+
* Keep legacy nodes on Chat Completions while rejecting corrupt/API-authored
|
|
20
|
+
* values before a provider request is created.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseCustomProviderApi(value: unknown): CustomProviderApi;
|
|
23
|
+
export declare function getCustomProviderApiContract(value: unknown): CustomProviderApiContract;
|
|
@@ -7,8 +7,20 @@ export * from './chatV2ResponseFormat.js';
|
|
|
7
7
|
export * from './chatV2Shared.js';
|
|
8
8
|
export * from './chatV2Types.js';
|
|
9
9
|
export * from './llmProfileTypes.js';
|
|
10
|
+
export * from './llmProfileBody.js';
|
|
11
|
+
export * from './llmChatV2Body.js';
|
|
10
12
|
export * from './messageConverter.js';
|
|
11
13
|
export * from './modelRegistry.js';
|
|
12
14
|
export * from './providerOptions.js';
|
|
13
15
|
export * from './toolConverter.js';
|
|
14
16
|
export * from './toolContinuationConnection.js';
|
|
17
|
+
export * from './chatV2ProviderRegistry.js';
|
|
18
|
+
export * from './llmChatV2NodeMigration.js';
|
|
19
|
+
export * from './llmInvocationCoordinator.js';
|
|
20
|
+
export * from './llmInvocationProjections.js';
|
|
21
|
+
export * from './llmInvocationDecision.js';
|
|
22
|
+
export * from './llmChatV2CacheBoundary.js';
|
|
23
|
+
export * from './llmResponseMaterializer.js';
|
|
24
|
+
export * from './toolCallCodec.js';
|
|
25
|
+
export * from './toolHandlerResolver.js';
|
|
26
|
+
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';
|
|
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,8 @@ 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
|
+
export type { CustomProviderApi } from './customProviderApi.js';
|
|
5
7
|
export type LLMChatV2ToolChoiceMode = '' | 'auto' | 'function' | 'required';
|
|
6
8
|
export type LLMChatV2ApiKeySource = 'environment' | 'input';
|
|
7
9
|
export type LLMChatV2ConfigurationMode = 'inline' | 'profile';
|
|
@@ -13,6 +15,8 @@ export type LLMChatV2NodeConfigData = ChatV2CommonNodeData & {
|
|
|
13
15
|
customProviderApiKeyEnvVarName?: string;
|
|
14
16
|
customProviderBaseURL: string;
|
|
15
17
|
useCustomProviderBaseURLInput: boolean;
|
|
18
|
+
/** Missing on legacy/programmatically-created nodes means Chat Completions. */
|
|
19
|
+
customProviderApi?: CustomProviderApi;
|
|
16
20
|
baseURL: string;
|
|
17
21
|
useBaseURLInput: boolean;
|
|
18
22
|
headers: {
|
|
@@ -53,16 +57,19 @@ export type LLMChatV2NodeConfigData = ChatV2CommonNodeData & {
|
|
|
53
57
|
retryOnNon200?: boolean;
|
|
54
58
|
retryOnNon200RepeatTimes?: number;
|
|
55
59
|
retryOnNon200CooldownMs?: number;
|
|
56
|
-
|
|
57
|
-
outputRequestError?: boolean;
|
|
60
|
+
outputLLMAttempts?: boolean;
|
|
58
61
|
outputRequestBody?: boolean;
|
|
62
|
+
outputResponseBody?: boolean;
|
|
59
63
|
};
|
|
60
64
|
export type LLMChatV2NodeData = LLMChatV2NodeConfigData;
|
|
61
65
|
export type LLMChatV2Node = ChartNode<'llmChatV2', LLMChatV2NodeData>;
|
|
62
|
-
|
|
66
|
+
/** @deprecated Use llmProfileDataKeys from llmProfileFieldRegistry instead. */
|
|
67
|
+
export declare const llmChatV2ProfileDataKeys: ("provider" | "model" | "customProviderApi" | "headers" | "temperature" | "seed" | "maxTokens" | "presencePenalty" | "frequencyPenalty" | "useModelInput" | "useTemperatureInput" | "useTopPInput" | "useMaxTokensInput" | "usePresencePenaltyInput" | "useFrequencyPenaltyInput" | "useHeadersInput" | "useSeedInput" | "topP" | "topK" | "useTopKInput" | "stopSequences" | "useStopSequencesInput" | "anthropicCacheControlTtl" | "apiKeySource" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext")[];
|
|
63
68
|
export type LLMChatV2ProfileDataKey = (typeof llmChatV2ProfileDataKeys)[number];
|
|
64
69
|
export type LLMChatV2ProfileData = Pick<LLMChatV2NodeData, LLMChatV2ProfileDataKey>;
|
|
65
70
|
export type LLMChatV2EditorCacheKeyParts = {
|
|
71
|
+
/** Bump when cache identity semantics change; entries are editor-memory only. */
|
|
72
|
+
cacheVersion?: number;
|
|
66
73
|
nodeId: NodeId;
|
|
67
74
|
nodeData: LLMChatV2NodeData;
|
|
68
75
|
provider: ChatV2Provider;
|
|
@@ -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
|
|
5
|
-
import type {
|
|
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 {
|
|
10
|
+
export type { LLMAttempt } from './llmProfileFallback.js';
|
|
12
11
|
export type LLMChatV2RuntimeConfig = {
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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;
|