@valerypopoff/rivet2-core 2.1.8 → 2.1.9

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 (55) hide show
  1. package/dist/cjs/bundle.cjs +1922 -1125
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/esm/model/GraphProcessor.js +1 -0
  4. package/dist/esm/model/SplitRunProcessor.js +19 -10
  5. package/dist/esm/model/ToolCallContinuationCoordinator.js +6 -1
  6. package/dist/esm/model/chat/aiSdkMessages.js +8 -0
  7. package/dist/esm/model/chat-v2/chatV2CallObserver.js +2 -0
  8. package/dist/esm/model/chat-v2/chatV2EditorCache.js +22 -0
  9. package/dist/esm/model/chat-v2/chatV2Outputs.js +41 -31
  10. package/dist/esm/model/chat-v2/chatV2Pipeline.js +122 -44
  11. package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +1 -0
  12. package/dist/esm/model/chat-v2/chatV2RequestPlan.js +6 -5
  13. package/dist/esm/model/chat-v2/chatV2Shared.js +1 -6
  14. package/dist/esm/model/chat-v2/chatV2Types.js +11 -1
  15. package/dist/esm/model/chat-v2/developerMessageRoles.js +45 -0
  16. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +3 -5
  17. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +22 -13
  18. package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +224 -68
  19. package/dist/esm/model/chat-v2/llmProfile.js +21 -0
  20. package/dist/esm/model/chat-v2/llmProfileFallback.js +288 -0
  21. package/dist/esm/model/chat-v2/messageConverter.js +14 -0
  22. package/dist/esm/model/chat-v2/providerOptions.js +44 -11
  23. package/dist/esm/model/chat-v2/toolContinuation.js +0 -4
  24. package/dist/esm/model/nodes/AssembleMessageNode.js +6 -0
  25. package/dist/esm/model/nodes/DelegateFunctionCallNode.js +12 -0
  26. package/dist/esm/model/nodes/LLMChatV2Node.js +115 -11
  27. package/dist/esm/model/nodes/PromptNode.js +9 -2
  28. package/dist/esm/model/nodes/toolCallDelegation.js +18 -2
  29. package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +22 -28
  30. package/dist/esm/plugins/google/google.js +20 -9
  31. package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +17 -6
  32. package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +4 -0
  33. package/dist/esm/utils/serialization/serialization.js +19 -0
  34. package/dist/types/model/DataValue.d.ts +7 -1
  35. package/dist/types/model/NodeBase.d.ts +6 -0
  36. package/dist/types/model/ProcessContext.d.ts +4 -0
  37. package/dist/types/model/SplitRunProcessor.d.ts +2 -1
  38. package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +4 -0
  39. package/dist/types/model/chat-v2/chatV2Outputs.d.ts +5 -5
  40. package/dist/types/model/chat-v2/chatV2Pipeline.d.ts +33 -0
  41. package/dist/types/model/chat-v2/chatV2ProviderProfile.d.ts +1 -0
  42. package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +2 -2
  43. package/dist/types/model/chat-v2/chatV2Shared.d.ts +0 -1
  44. package/dist/types/model/chat-v2/chatV2Types.d.ts +24 -0
  45. package/dist/types/model/chat-v2/developerMessageRoles.d.ts +10 -0
  46. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +4 -1
  47. package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +18 -2
  48. package/dist/types/model/chat-v2/llmProfile.d.ts +7 -0
  49. package/dist/types/model/chat-v2/llmProfileFallback.d.ts +79 -0
  50. package/dist/types/model/chat-v2/providerOptions.d.ts +1 -0
  51. package/dist/types/model/nodes/AssembleMessageNode.d.ts +2 -1
  52. package/dist/types/model/nodes/PromptNode.d.ts +2 -2
  53. package/dist/types/plugins/google/google.d.ts +12 -1
  54. package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +2 -1
  55. package/package.json +1 -1
@@ -1,3 +1,10 @@
1
1
  import { type LLMProfileValue } from './llmProfileTypes.js';
2
2
  export { applyLLMProfileToNodeData, createDefaultLLMProfileValue, createLLMProfileNodeData, LLM_PROFILE_VALUE_VERSION, pickLLMChatV2ProfileData, type LLMProfileValue, } from './llmProfileTypes.js';
3
3
  export declare function normalizeLLMProfileValue(value: unknown): LLMProfileValue;
4
+ /**
5
+ * Normalizes the single LLM Profile or ordered fallback chain accepted by
6
+ * LLM Chat's From profile input. We validate every member here rather than
7
+ * trusting a same-type `llm-config[]` wrapper: arrays can otherwise carry
8
+ * malformed values without re-entering scalar coercion.
9
+ */
10
+ export declare function normalizeLLMProfileChainInput(value: unknown): LLMProfileValue[];
@@ -0,0 +1,79 @@
1
+ import { type ChatV2Provider, type ChatV2PipelineResult, type RunChatV2PipelineOptions } from './chatV2Types.js';
2
+ export type LLMProfileAttempt = {
3
+ roundIndex: number;
4
+ profileIndex: number;
5
+ provider: ChatV2Provider;
6
+ model: string;
7
+ stage: 'configuration' | 'request';
8
+ outcome: 'success' | 'failure';
9
+ attemptIndex?: number;
10
+ status?: number;
11
+ error?: string;
12
+ };
13
+ export type LLMProfileFallbackCandidate = {
14
+ provider: ChatV2Provider;
15
+ model: string;
16
+ credential?: string | undefined;
17
+ /** Additional known request secrets, such as profile or global header values. */
18
+ redactionValues?: readonly string[] | undefined;
19
+ };
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
+ export type LLMProfileFallbackRunner = {
44
+ run: (roundOptions: RunChatV2PipelineOptions) => Promise<ChatV2PipelineResult>;
45
+ attempts: LLMProfileAttempt[];
46
+ summary: () => string;
47
+ wasExhausted: () => boolean;
48
+ };
49
+ export declare class LLMProfileFallbackExhaustedError extends Error {
50
+ readonly attempts: readonly LLMProfileAttempt[];
51
+ constructor(attempts: readonly LLMProfileAttempt[]);
52
+ }
53
+ /**
54
+ * Produces the concise, developer-facing companion to the full attempt trace.
55
+ * It deliberately includes candidates that were never reached, so a successful
56
+ * primary profile does not make the configured fallback order invisible.
57
+ */
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;
71
+ /**
72
+ * Creates one forward-only fallback chain for a whole LLM Chat invocation.
73
+ * A model which succeeds in an earlier tool round stays active for subsequent
74
+ * rounds; only a later failure advances farther through the configured chain.
75
+ */
76
+ export declare function createLLMProfileFallbackRunner(params: {
77
+ candidates: readonly LLMProfileFallbackCandidate[];
78
+ resolveCandidate: (profileIndex: number, roundOptions: RunChatV2PipelineOptions) => Promise<RunChatV2PipelineOptions>;
79
+ }): LLMProfileFallbackRunner;
@@ -49,6 +49,7 @@ export type CreateChatV2ModelOptions = {
49
49
  baseURL?: string | undefined;
50
50
  headers?: Record<string, string> | undefined;
51
51
  onRequestBody?: ((body: unknown) => void) | undefined;
52
+ transformRequestBody?: ((body: unknown) => unknown) | undefined;
52
53
  };
53
54
  export type ResolveChatV2ProviderConfigContext = Pick<InternalProcessContext, 'getPluginConfig' | 'settings'>;
54
55
  export type ResolvedChatV2ProviderConfig = {
@@ -1,11 +1,12 @@
1
1
  import { type ChartNode, type NodeConnection, type NodeInputDefinition, type NodeOutputDefinition } from '../NodeBase.js';
2
2
  import { NodeImpl, type NodeBody, type NodeUIData } from '../NodeImpl.js';
3
+ import { type ChatMessage } from '../DataValue.js';
3
4
  import { type Inputs, type Outputs } from '../GraphProcessor.js';
4
5
  import type { EditorDefinition } from '../EditorDefinition.js';
5
6
  import type { RivetUIContext } from '../RivetUIContext.js';
6
7
  export type AssembleMessageNode = ChartNode<'assembleMessage', AssembleMessageNodeData>;
7
8
  export type AssembleMessageNodeData = {
8
- type: 'system' | 'user' | 'assistant' | 'function';
9
+ type: ChatMessage['type'];
9
10
  useTypeInput: boolean;
10
11
  toolCallId: string;
11
12
  useToolCallIdInput?: boolean;
@@ -1,9 +1,9 @@
1
1
  import { type ChartNode, type NodeInputDefinition, type NodeOutputDefinition } from '../NodeBase.js';
2
2
  import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
3
- import { type EditorDefinition, type Inputs, type InternalProcessContext, type NodeBodySpec, type Outputs } from '../../index.js';
3
+ import { type ChatMessage, type EditorDefinition, type Inputs, type InternalProcessContext, type NodeBodySpec, type Outputs } from '../../index.js';
4
4
  export type PromptNode = ChartNode<'prompt', PromptNodeData>;
5
5
  export type PromptNodeData = {
6
- type: 'system' | 'user' | 'assistant' | 'function';
6
+ type: ChatMessage['type'];
7
7
  useTypeInput: boolean;
8
8
  promptText: string;
9
9
  name?: string;
@@ -98,6 +98,7 @@ export type ChatCompletionOptions = {
98
98
  location: string;
99
99
  applicationCredentials: string;
100
100
  model: GoogleModelsDeprecated;
101
+ systemPrompt?: string;
101
102
  prompt: Content[];
102
103
  max_output_tokens: number;
103
104
  temperature?: number;
@@ -111,6 +112,16 @@ export type ChatCompletionChunk = {
111
112
  finish_reason: 'FINISH_REASON_UNSPECIFIED' | 'FINISH_REASON_STOP' | 'FINISH_REASON_MAX_TOKENS' | 'FINISH_REASON_SAFETY' | 'FINISH_REASON_RECITATION' | 'FINISH_REASON_OTHER' | undefined;
112
113
  model: string;
113
114
  };
115
+ export declare function getVertexGenerativeModelOptions(options: Pick<ChatCompletionOptions, 'model' | 'systemPrompt' | 'max_output_tokens' | 'temperature' | 'top_p' | 'top_k'>): {
116
+ model: "gemini-pro" | "gemini-pro-vision";
117
+ systemInstruction: string | undefined;
118
+ generationConfig: {
119
+ maxOutputTokens: number;
120
+ temperature: number | undefined;
121
+ topP: number | undefined;
122
+ topK: number | undefined;
123
+ };
124
+ };
114
125
  export type StreamGenerativeAiOptions = {
115
126
  apiKey: string;
116
127
  model: GenerativeAiGoogleModel;
@@ -126,4 +137,4 @@ export type StreamGenerativeAiOptions = {
126
137
  additionalHeaders?: Record<string, string>;
127
138
  };
128
139
  export declare function streamGenerativeAi({ apiKey, model, systemPrompt, prompt, maxOutputTokens, temperature, topP, topK, signal, tools, thinkingBudget, additionalHeaders, }: StreamGenerativeAiOptions): AsyncGenerator<ChatCompletionChunk>;
129
- export declare function streamChatCompletions({ project, location, applicationCredentials, model, signal, max_output_tokens, temperature, top_p, top_k, prompt, }: ChatCompletionOptions): AsyncGenerator<ChatCompletionChunk>;
140
+ export declare function streamChatCompletions({ project, location, applicationCredentials, model, signal, max_output_tokens, temperature, top_p, top_k, systemPrompt, prompt, }: ChatCompletionOptions): AsyncGenerator<ChatCompletionChunk>;
@@ -31,5 +31,6 @@ export type ChatGoogleNodeData = ChatGoogleNodeConfigData & {
31
31
  export declare const ChatGoogleNodeImpl: PluginNodeImpl<ChatGoogleNode>;
32
32
  export declare const chatGoogleNode: import("../../../index.js").PluginNodeDefinition<ChatGoogleNode>;
33
33
  export declare function getChatGoogleNodeMessages(inputs: Inputs): {
34
- messages: import("../../../index.js").ChatMessage[];
34
+ messages: (import("../../../index.js").UserChatMessage | import("../../../index.js").AssistantChatMessage | import("../../../index.js").FunctionResponseChatMessage)[];
35
+ systemPrompt: string | undefined;
35
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerypopoff/rivet2-core",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "license": "MIT",
5
5
  "main": "dist/cjs/bundle.cjs",
6
6
  "module": "dist/esm/index.js",