@valerypopoff/rivet2-core 2.15.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bundle.cjs +4350 -2077
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/interpolationRuntime.cjs +22 -3
- package/dist/cjs/interpolationRuntime.cjs.map +3 -3
- package/dist/cjs/interpolationSyntax.cjs +9 -5
- package/dist/cjs/interpolationSyntax.cjs.map +2 -2
- package/dist/esm/api/createProcessor.js +5 -2
- package/dist/esm/exports.js +2 -0
- package/dist/esm/model/GraphBoundaryCache.js +2 -1
- package/dist/esm/model/GraphProcessor.js +268 -6
- package/dist/esm/model/Nodes.js +10 -0
- package/dist/esm/model/ProjectBundle.js +235 -0
- package/dist/esm/model/SplitRunProcessor.js +28 -7
- package/dist/esm/model/StreamingWatchTopology.js +118 -8
- package/dist/esm/model/SubgraphProjectTarget.js +7 -0
- package/dist/esm/model/chat-v2/aiSdkBridge.js +7 -5
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +13 -8
- package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +19 -1
- package/dist/esm/model/chat-v2/chatV2Shared.js +2 -1
- package/dist/esm/model/chat-v2/llmChatV2Body.js +11 -8
- package/dist/esm/model/chat-v2/llmChatV2NodeData.js +2 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +15 -1
- package/dist/esm/model/chat-v2/llmChatV2NodeMigration.js +22 -2
- package/dist/esm/model/chat-v2/llmProfile.js +3 -0
- package/dist/esm/model/chat-v2/llmProfileBody.js +2 -2
- package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +1 -1
- package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +1 -1
- package/dist/esm/model/chat-v2/temperature.js +9 -0
- package/dist/esm/model/classifier/credentials.js +30 -4
- package/dist/esm/model/classifier/images.js +176 -0
- package/dist/esm/model/classifier/json.js +57 -0
- package/dist/esm/model/classifier/limits.js +270 -0
- package/dist/esm/model/classifier/openai.js +118 -0
- package/dist/esm/model/classifier/preparation.js +74 -0
- package/dist/esm/model/classifier/providers.js +260 -185
- package/dist/esm/model/classifier/questionHelpers.js +29 -45
- package/dist/esm/model/classifier/questions.js +53 -0
- package/dist/esm/model/classifier/response.js +75 -0
- package/dist/esm/model/classifier/state.js +204 -0
- package/dist/esm/model/nodeRunFailure.js +47 -0
- package/dist/esm/model/nodes/CatchStreamingChunksNode.js +42 -0
- package/dist/esm/model/nodes/ClassifierEvaluateNode.js +178 -138
- package/dist/esm/model/nodes/ClassifierQuestionNode.js +59 -15
- package/dist/esm/model/nodes/GetGlobalNode.js +2 -2
- package/dist/esm/model/nodes/HttpCallNode.js +44 -75
- package/dist/esm/model/nodes/ImageNode.js +44 -3
- package/dist/esm/model/nodes/LLMChatV2Node.js +24 -3
- package/dist/esm/model/nodes/ObjectNode.js +29 -18
- package/dist/esm/model/nodes/PromptNode.js +2 -1
- package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +4 -1
- package/dist/esm/model/nodes/SetGlobalNode.js +5 -3
- package/dist/esm/model/nodes/StopWatchingStreamingOutputNode.js +8 -8
- package/dist/esm/model/nodes/StreamValueNode.js +38 -0
- package/dist/esm/model/nodes/SubGraphNode.js +196 -35
- package/dist/esm/model/nodes/ToBase64Node.js +106 -0
- package/dist/esm/model/nodes/WatchStreamingOutputNode.js +7 -7
- package/dist/esm/recording/ExecutionRecorder.js +26 -0
- package/dist/esm/utils/base64.js +18 -15
- package/dist/esm/utils/errors.js +41 -0
- package/dist/esm/utils/interpolation.js +44 -22
- package/dist/esm/utils/interpolationSyntax.js +15 -6
- package/dist/esm/utils/serialization/serialization.js +3 -2
- package/dist/esm/utils/serialization/serializationUtils.js +6 -0
- package/dist/esm/utils/serialization/serialization_v4.js +15 -3
- package/dist/types/api/createProcessor.d.ts +7 -1
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/model/CycleDetector.d.ts +1 -2
- package/dist/types/model/ExecutorProtocol.d.ts +2 -0
- package/dist/types/model/GraphBoundaryCache.d.ts +2 -0
- package/dist/types/model/GraphProcessor.d.ts +1 -0
- package/dist/types/model/Nodes.d.ts +6 -2
- package/dist/types/model/ProcessContext.d.ts +12 -0
- package/dist/types/model/ProjectBundle.d.ts +54 -0
- package/dist/types/model/ProjectReferenceLoader.d.ts +3 -0
- package/dist/types/model/StreamingWatchTopology.d.ts +11 -1
- package/dist/types/model/SubgraphProjectTarget.d.ts +38 -0
- package/dist/types/model/chat-v2/chatV2Shared.d.ts +1 -1
- package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +3 -1
- package/dist/types/model/chat-v2/llmChatV2NodeMigration.d.ts +3 -1
- package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +6 -6
- package/dist/types/model/chat-v2/temperature.d.ts +2 -0
- package/dist/types/model/classifier/credentials.d.ts +3 -1
- package/dist/types/model/classifier/images.d.ts +18 -0
- package/dist/types/model/classifier/json.d.ts +19 -0
- package/dist/types/model/classifier/limits.d.ts +42 -0
- package/dist/types/model/classifier/openai.d.ts +5 -0
- package/dist/types/model/classifier/preparation.d.ts +16 -0
- package/dist/types/model/classifier/providers.d.ts +67 -9
- package/dist/types/model/classifier/questionHelpers.d.ts +6 -4
- package/dist/types/model/classifier/questions.d.ts +4 -0
- package/dist/types/model/classifier/response.d.ts +4 -0
- package/dist/types/model/classifier/state.d.ts +37 -0
- package/dist/types/model/classifier/types.d.ts +2 -0
- package/dist/types/model/nodeRunFailure.d.ts +13 -0
- package/dist/types/model/nodes/CatchStreamingChunksNode.d.ts +20 -0
- package/dist/types/model/nodes/ClassifierEvaluateNode.d.ts +3 -0
- package/dist/types/model/nodes/GetGlobalNode.d.ts +7 -0
- package/dist/types/model/nodes/ImageNode.d.ts +4 -0
- package/dist/types/model/nodes/LLMChatV2Node.d.ts +1 -0
- package/dist/types/model/nodes/ObjectNode.d.ts +2 -1
- package/dist/types/model/nodes/StreamValueNode.d.ts +14 -0
- package/dist/types/model/nodes/SubGraphNode.d.ts +21 -2
- package/dist/types/model/nodes/ToBase64Node.d.ts +12 -0
- package/dist/types/recording/ExecutionRecorder.d.ts +8 -2
- package/dist/types/utils/base64.d.ts +1 -1
- package/dist/types/utils/errors.d.ts +4 -0
- package/dist/types/utils/interpolation.d.ts +13 -2
- package/dist/types/utils/interpolationSyntax.d.ts +1 -1
- package/dist/types/utils/serialization/serialization.d.ts +3 -1
- package/dist/types/utils/serialization/serializationUtils.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Project } from './Project.js';
|
|
2
|
+
import { type GraphBoundary } from './GraphBoundaryCache.js';
|
|
3
|
+
import type { PluginLoadSpec } from './PluginLoadSpec.js';
|
|
4
|
+
/** Deliberate, user-facing bundle validation failures; never raw storage errors. */
|
|
5
|
+
export declare class ProjectBundleError extends Error {
|
|
6
|
+
constructor(message: string, options?: ErrorOptions);
|
|
7
|
+
}
|
|
8
|
+
/** Portable, immutable project snapshots. Paths are relative to the manifest. */
|
|
9
|
+
export type ProjectBundleFile = {
|
|
10
|
+
path: string;
|
|
11
|
+
bytes: number;
|
|
12
|
+
sha256: string;
|
|
13
|
+
};
|
|
14
|
+
export type ProjectBundleArtifact = {
|
|
15
|
+
id: string;
|
|
16
|
+
projectId: string;
|
|
17
|
+
title: string;
|
|
18
|
+
version: 'latest' | 'published';
|
|
19
|
+
revision: string;
|
|
20
|
+
project: ProjectBundleFile;
|
|
21
|
+
datasets?: ProjectBundleFile;
|
|
22
|
+
};
|
|
23
|
+
export type ProjectBundleManifest = {
|
|
24
|
+
format: 'rivet-project-bundle';
|
|
25
|
+
schemaVersion: 1;
|
|
26
|
+
requiredLoaderVersion: 1;
|
|
27
|
+
exportingRuntimeVersion: string;
|
|
28
|
+
rootArtifact: string;
|
|
29
|
+
artifacts: ProjectBundleArtifact[];
|
|
30
|
+
targets: {
|
|
31
|
+
projectId: string;
|
|
32
|
+
version: 'latest' | 'published';
|
|
33
|
+
artifact: string;
|
|
34
|
+
}[];
|
|
35
|
+
references: {
|
|
36
|
+
projectId: string;
|
|
37
|
+
artifact: string;
|
|
38
|
+
}[];
|
|
39
|
+
plugins: PluginLoadSpec[];
|
|
40
|
+
};
|
|
41
|
+
export declare const PROJECT_BUNDLE_MANIFEST = "rivet-bundle.json";
|
|
42
|
+
export declare const PROJECT_BUNDLE_MAX_ARTIFACTS = 256;
|
|
43
|
+
export declare function projectBundleTargetKey(projectId: string, version: string): string;
|
|
44
|
+
export declare function listProjectBundleCalls(project: Project): {
|
|
45
|
+
projectId: string;
|
|
46
|
+
version: 'latest' | 'published';
|
|
47
|
+
graphId: string;
|
|
48
|
+
boundary?: GraphBoundary;
|
|
49
|
+
}[];
|
|
50
|
+
/** Uses the same saved wire contract as runtime execution, without running any nodes. */
|
|
51
|
+
export declare function validateProjectBundleCall(call: ReturnType<typeof listProjectBundleCalls>[number], target: Project): void;
|
|
52
|
+
/** Reject missing bindings and cross-project dependency cycles before executing any graph. */
|
|
53
|
+
export declare function validateProjectBundleProjects(manifest: ProjectBundleManifest, projects: ReadonlyMap<string, Project>): void;
|
|
54
|
+
export declare function validateProjectBundleManifest(value: unknown): ProjectBundleManifest;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Project, ProjectId, ProjectReference } from './Project.js';
|
|
2
|
+
import type { DatasetProvider } from '../integrations/DatasetProvider.js';
|
|
2
3
|
export type ProjectReferenceLoader = {
|
|
3
4
|
/** Loads a project based on the given reference. */
|
|
4
5
|
loadProject: (currentProjectPath: string | undefined, reference: ProjectReference) => Promise<Project>;
|
|
6
|
+
/** Optional snapshot-owned datasets; older loaders retain the caller's provider. */
|
|
7
|
+
getDatasetProvider?: (project: Project) => DatasetProvider | undefined;
|
|
5
8
|
};
|
|
6
9
|
/** The root information needed to load its complete referenced-project closure. */
|
|
7
10
|
export type ProjectReferenceRoot = {
|
|
@@ -15,7 +15,7 @@ export declare function canStreamThroughGraphInput(node: ChartNode): node is Gra
|
|
|
15
15
|
/** A named output may forward only when one direct producer determines its terminal value. */
|
|
16
16
|
export declare function canForwardGraphOutputPartials(graphOutput: ChartNode, sourceNode: ChartNode, graphOutputIsFrozen: boolean): graphOutput is GraphOutputNode;
|
|
17
17
|
/** Trace Watch demand through named boundaries without making ordinary nodes repeatable. */
|
|
18
|
-
export declare function getProjectStreamingOutputWatchConnections({ project, graph, referencedProjects, registry, frozenNodeOutputs, isNodeFrozen, fullGraphCallers, }: {
|
|
18
|
+
export declare function getProjectStreamingOutputWatchConnections({ project, graph, referencedProjects, registry, frozenNodeOutputs, isNodeFrozen, fullGraphCallers, getPreviewGraphOutputStreamingCapability, onlyStreamCapableSources, }: {
|
|
19
19
|
project: Project;
|
|
20
20
|
graph: NodeGraph;
|
|
21
21
|
referencedProjects: Record<ProjectId, Project>;
|
|
@@ -23,4 +23,14 @@ export declare function getProjectStreamingOutputWatchConnections({ project, gra
|
|
|
23
23
|
frozenNodeOutputs?: FrozenNodeOutputsByGraph;
|
|
24
24
|
isNodeFrozen?: (owner: Project, candidate: NodeGraph, node: ChartNode) => boolean;
|
|
25
25
|
fullGraphCallers?: ReadonlySet<NodeId>;
|
|
26
|
+
/** Redacted hosted previews contain boundaries, not executable graph topology. */
|
|
27
|
+
getPreviewGraphOutputStreamingCapability?: (owner: Project, graph: NodeGraph, outputNodeId: NodeId) => boolean | undefined;
|
|
28
|
+
/** Presentation-only filter. Runtime routing must accept ordinary values too. */
|
|
29
|
+
onlyStreamCapableSources?: boolean;
|
|
26
30
|
}): ReadonlySet<NodeConnection>;
|
|
31
|
+
/** Derive safe boundary capability hints for every graph in one topology pass. */
|
|
32
|
+
export declare function getProjectStreamableGraphOutputNodeIdsByGraph({ project, referencedProjects, registry, }: {
|
|
33
|
+
project: Project;
|
|
34
|
+
referencedProjects: Record<ProjectId, Project>;
|
|
35
|
+
registry: NodeRegistration<any, any>;
|
|
36
|
+
}): Record<string, NodeId[]>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DatasetProvider } from '../integrations/DatasetProvider.js';
|
|
2
|
+
import type { Project, ProjectId } from './Project.js';
|
|
3
|
+
import type { GraphId } from './NodeGraph.js';
|
|
4
|
+
import type { ExecutionRecorder } from '../recording/ExecutionRecorder.js';
|
|
5
|
+
/** Hosts resolve targets from saved storage; portable bundles resolve their captured snapshots. Never an editor tab. */
|
|
6
|
+
export type SubgraphProjectVersion = 'latest' | 'published';
|
|
7
|
+
export type SubgraphProjectTarget = {
|
|
8
|
+
projectId: ProjectId;
|
|
9
|
+
version: SubgraphProjectVersion;
|
|
10
|
+
};
|
|
11
|
+
export type ResolvedSubgraphProject = {
|
|
12
|
+
project: Project;
|
|
13
|
+
/** The selected project's dataset snapshot, when it differs from the caller's. */
|
|
14
|
+
datasetProvider?: DatasetProvider;
|
|
15
|
+
revisionKey?: string;
|
|
16
|
+
/** Exact saved artifact used for execution, including embedded attachments. */
|
|
17
|
+
projectContents?: string;
|
|
18
|
+
datasetsContents?: string;
|
|
19
|
+
/** Current source location for recording ownership; not used to execute. */
|
|
20
|
+
sourceProjectPath?: string;
|
|
21
|
+
};
|
|
22
|
+
export type SubgraphProjectRun = {
|
|
23
|
+
target: SubgraphProjectTarget;
|
|
24
|
+
resolved: ResolvedSubgraphProject;
|
|
25
|
+
graphId: GraphId;
|
|
26
|
+
recorder: ExecutionRecorder;
|
|
27
|
+
status: 'succeeded' | 'failed';
|
|
28
|
+
durationMs: number;
|
|
29
|
+
errorMessage?: string;
|
|
30
|
+
/** The caller's run correlation key, shared with its own recording when available. */
|
|
31
|
+
correlationId?: string;
|
|
32
|
+
};
|
|
33
|
+
export type SubgraphProjectLoader = {
|
|
34
|
+
loadTarget(target: SubgraphProjectTarget): Promise<ResolvedSubgraphProject>;
|
|
35
|
+
};
|
|
36
|
+
/** Internal definition key; not a project metadata ID or a persisted reference. */
|
|
37
|
+
export declare function getSubgraphProjectKey(target: SubgraphProjectTarget): ProjectId;
|
|
38
|
+
export declare function isSubgraphProjectKey(key: string): boolean;
|
|
@@ -3,7 +3,7 @@ import type { ChartNode, NodeInputDefinition, NodeOutputDefinition, PortId } fro
|
|
|
3
3
|
export type ChatV2CommonNodeData = {
|
|
4
4
|
model: string;
|
|
5
5
|
useModelInput: boolean;
|
|
6
|
-
temperature
|
|
6
|
+
temperature?: number;
|
|
7
7
|
useTemperatureInput: boolean;
|
|
8
8
|
topP?: number;
|
|
9
9
|
useTopPInput: boolean;
|
|
@@ -63,6 +63,8 @@ export type LLMChatV2NodeConfigData = ChatV2CommonNodeData & {
|
|
|
63
63
|
autoContinueToolCalls?: boolean;
|
|
64
64
|
maxToolRounds?: number;
|
|
65
65
|
retryOnNon200?: boolean;
|
|
66
|
+
errorOnNon200?: boolean;
|
|
67
|
+
catchRequestFailed?: boolean;
|
|
66
68
|
retryOnNon200RepeatTimes?: number;
|
|
67
69
|
retryOnNon200CooldownMs?: number;
|
|
68
70
|
outputLLMAttempts?: boolean;
|
|
@@ -72,7 +74,7 @@ export type LLMChatV2NodeConfigData = ChatV2CommonNodeData & {
|
|
|
72
74
|
export type LLMChatV2NodeData = LLMChatV2NodeConfigData;
|
|
73
75
|
export type LLMChatV2Node = ChartNode<'llmChatV2', LLMChatV2NodeData>;
|
|
74
76
|
/** @deprecated Use llmProfileDataKeys from llmProfileFieldRegistry instead. */
|
|
75
|
-
export declare const llmChatV2ProfileDataKeys: ("provider" | "model" | "maxTokens" | "temperature" | "topP" | "topK" | "presencePenalty" | "frequencyPenalty" | "stopSequences" | "seed" | "anthropicCacheControlTtl" | "
|
|
77
|
+
export declare const llmChatV2ProfileDataKeys: ("provider" | "model" | "customProviderApi" | "maxTokens" | "temperature" | "topP" | "topK" | "presencePenalty" | "frequencyPenalty" | "stopSequences" | "seed" | "anthropicCacheControlTtl" | "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")[];
|
|
76
78
|
export type LLMChatV2ProfileDataKey = (typeof llmChatV2ProfileDataKeys)[number];
|
|
77
79
|
export type LLMChatV2ProfileData = Pick<LLMChatV2NodeData, LLMChatV2ProfileDataKey>;
|
|
78
80
|
export type LLMChatV2EditorCacheKeyParts = {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ChartNode } from '../NodeBase.js';
|
|
2
|
+
/** Repair legacy payloads on read or Save without mutating the supplied data. */
|
|
3
|
+
export declare function normalizeSerializedLLMTemperatureData(nodeType: string, data: ChartNode['data']): ChartNode['data'];
|
|
2
4
|
/**
|
|
3
|
-
* Serialized LLM Chat migrations live beside the node contract, rather than
|
|
5
|
+
* Serialized LLM Chat/Profile migrations live beside the node contract, rather than
|
|
4
6
|
* making generic project serialization understand LLM-specific settings.
|
|
5
7
|
* This is deliberately idempotent because deserialization can normalize a
|
|
6
8
|
* graph more than once while it is imported or embedded in a prefab.
|
|
@@ -26,7 +26,7 @@ export declare const llmProfileFieldSpecs: readonly [{
|
|
|
26
26
|
}, {
|
|
27
27
|
readonly key: "temperature";
|
|
28
28
|
readonly inputId: "temperature";
|
|
29
|
-
readonly valueKind: "
|
|
29
|
+
readonly valueKind: "optional-number";
|
|
30
30
|
}, {
|
|
31
31
|
readonly key: "useTemperatureInput";
|
|
32
32
|
readonly valueKind: "boolean";
|
|
@@ -198,12 +198,12 @@ export declare const llmProfileFieldSpecs: readonly [{
|
|
|
198
198
|
readonly key: "circuitBreakerOpenDurationMs";
|
|
199
199
|
readonly valueKind: "required-number";
|
|
200
200
|
}];
|
|
201
|
-
export declare const llmProfileDataKeys: ("provider" | "model" | "maxTokens" | "temperature" | "topP" | "topK" | "presencePenalty" | "frequencyPenalty" | "stopSequences" | "seed" | "anthropicCacheControlTtl" | "
|
|
201
|
+
export declare const llmProfileDataKeys: ("provider" | "model" | "customProviderApi" | "maxTokens" | "temperature" | "topP" | "topK" | "presencePenalty" | "frequencyPenalty" | "stopSequences" | "seed" | "anthropicCacheControlTtl" | "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")[];
|
|
202
202
|
export declare const llmProfileInputIds: ("model" | "maxTokens" | "temperature" | "topP" | "topK" | "presencePenalty" | "frequencyPenalty" | "stopSequences" | "seed" | "customProviderBaseURL" | "headers" | "extraProviderOptions" | "anthropicThinkingBudget" | "googleThinkingBudget" | "apiKey" | "previousResponseId")[];
|
|
203
203
|
/** Runtime validation categories for resolved LLM Profile values. */
|
|
204
|
-
export declare const llmProfileStringDataKeys: ("provider" | "parallelToolCalls" | "responseFormat" | "toolChoice" | "anthropicCacheControlTtl" | "outputRequestBody" | "outputResponseBody" | "retryOnNon200" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "
|
|
205
|
-
export declare const llmProfileBooleanDataKeys: ("provider" | "parallelToolCalls" | "responseFormat" | "toolChoice" | "anthropicCacheControlTtl" | "outputRequestBody" | "outputResponseBody" | "retryOnNon200" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "
|
|
206
|
-
export declare const llmProfileRequiredNumberDataKeys: ("provider" | "parallelToolCalls" | "responseFormat" | "toolChoice" | "anthropicCacheControlTtl" | "outputRequestBody" | "outputResponseBody" | "retryOnNon200" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "
|
|
207
|
-
export declare const llmProfileOptionalNumberDataKeys: ("provider" | "parallelToolCalls" | "responseFormat" | "toolChoice" | "anthropicCacheControlTtl" | "outputRequestBody" | "outputResponseBody" | "retryOnNon200" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "
|
|
204
|
+
export declare const llmProfileStringDataKeys: ("provider" | "customProviderApi" | "parallelToolCalls" | "responseFormat" | "toolChoice" | "anthropicCacheControlTtl" | "outputRequestBody" | "outputResponseBody" | "retryOnNon200" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "baseURL" | "useBaseURLInput" | "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" | "toolChoiceFunction" | "autoContinueToolCalls" | "maxToolRounds" | "errorOnNon200" | "catchRequestFailed" | "outputLLMAttempts")[];
|
|
205
|
+
export declare const llmProfileBooleanDataKeys: ("provider" | "customProviderApi" | "parallelToolCalls" | "responseFormat" | "toolChoice" | "anthropicCacheControlTtl" | "outputRequestBody" | "outputResponseBody" | "retryOnNon200" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "baseURL" | "useBaseURLInput" | "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" | "toolChoiceFunction" | "autoContinueToolCalls" | "maxToolRounds" | "errorOnNon200" | "catchRequestFailed" | "outputLLMAttempts")[];
|
|
206
|
+
export declare const llmProfileRequiredNumberDataKeys: ("provider" | "customProviderApi" | "parallelToolCalls" | "responseFormat" | "toolChoice" | "anthropicCacheControlTtl" | "outputRequestBody" | "outputResponseBody" | "retryOnNon200" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "baseURL" | "useBaseURLInput" | "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" | "toolChoiceFunction" | "autoContinueToolCalls" | "maxToolRounds" | "errorOnNon200" | "catchRequestFailed" | "outputLLMAttempts")[];
|
|
207
|
+
export declare const llmProfileOptionalNumberDataKeys: ("provider" | "customProviderApi" | "parallelToolCalls" | "responseFormat" | "toolChoice" | "anthropicCacheControlTtl" | "outputRequestBody" | "outputResponseBody" | "retryOnNon200" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "baseURL" | "useBaseURLInput" | "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" | "toolChoiceFunction" | "autoContinueToolCalls" | "maxToolRounds" | "errorOnNon200" | "catchRequestFailed" | "outputLLMAttempts")[];
|
|
208
208
|
/** A serialized profile must be self-contained, not driven by hidden ports. */
|
|
209
209
|
export declare const llmProfileResolvedInputToggleDataKeys: Array<keyof LLMChatV2NodeData>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Inputs } from '../GraphProcessor.js';
|
|
2
2
|
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
3
|
-
export type ClassifierApiKeySource = 'configured' | 'input';
|
|
3
|
+
export type ClassifierApiKeySource = 'configured' | 'classifier-settings' | 'input';
|
|
4
4
|
export type ClassifierCredentialNames = {
|
|
5
5
|
programmaticName: string;
|
|
6
6
|
environmentVariableName: string;
|
|
@@ -9,6 +9,8 @@ export type ClassifierProviderCredentials = Record<string, {
|
|
|
9
9
|
apiKey?: string | undefined;
|
|
10
10
|
}>;
|
|
11
11
|
export declare const JEV_DEFAULT_CREDENTIAL_NAMES: ClassifierCredentialNames;
|
|
12
|
+
export declare const LIQUID_DEFAULT_CREDENTIAL_NAMES: ClassifierCredentialNames;
|
|
13
|
+
export declare const OPENAI_DEFAULT_CREDENTIAL_NAMES: ClassifierCredentialNames;
|
|
12
14
|
export declare function isValidClassifierProgrammaticCredentialName(name: string): boolean;
|
|
13
15
|
export declare function isValidClassifierEnvironmentCredentialName(name: string): boolean;
|
|
14
16
|
export declare function normalizeClassifierCredentialNames(value: unknown, defaults?: ClassifierCredentialNames): ClassifierCredentialNames;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ClassifierPreparationCheck } from './limits.js';
|
|
2
|
+
type ImageInfo = {
|
|
3
|
+
mediaType: string;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
export type PreparedClassifierImage = ImageInfo & {
|
|
8
|
+
dataUrl: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function prepareNativeClassifierImage(value: unknown, check?: ClassifierPreparationCheck): PreparedClassifierImage;
|
|
11
|
+
export declare function nativeClassifierImage(value: unknown, check?: ClassifierPreparationCheck): string;
|
|
12
|
+
export declare function inspectClassifierImage(value: unknown, check?: ClassifierPreparationCheck): ImageInfo;
|
|
13
|
+
/** Recognize image bytes, not merely strings using the base64 alphabet. */
|
|
14
|
+
export declare function classifierImageFromText(value: string, check?: ClassifierPreparationCheck): string | undefined;
|
|
15
|
+
export declare function prepareClassifierImageText(value: string, check?: ClassifierPreparationCheck): PreparedClassifierImage | undefined;
|
|
16
|
+
export declare function assertClassifierImages(value: unknown, check?: ClassifierPreparationCheck): asserts value is string[];
|
|
17
|
+
export declare function assertLiquidImageLimits(images: readonly PreparedClassifierImage[], check?: ClassifierPreparationCheck): void;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClassifierEntry } from './types.js';
|
|
2
|
+
import type { DataValue } from '../DataValue.js';
|
|
3
|
+
import type { Inputs } from '../GraphProcessor.js';
|
|
4
|
+
import { ClassifierValueBudget, type ClassifierPreparationCheck } from './limits.js';
|
|
5
|
+
/** Read evidence fields without invoking getters or accepting prototype-provided content. */
|
|
6
|
+
export declare function classifierDataProperty(value: object, key: string, label?: string): unknown;
|
|
7
|
+
/** Snapshot only the selected port's wrapper; never read unrelated input getters. */
|
|
8
|
+
export declare function classifierInputDataValue(inputs: Inputs, port: string): DataValue | undefined;
|
|
9
|
+
/** Match JSON array order; never invoke a caller-provided iterator or index getter. */
|
|
10
|
+
export declare function classifierArrayValues(value: readonly unknown[], label: string): Generator<unknown>;
|
|
11
|
+
/** Validate the data JSON.stringify will read, without invoking property getters or array iterators. */
|
|
12
|
+
export declare function assertClassifierJson(value: unknown, label?: string, allowUndefinedProperties?: boolean, check?: ClassifierPreparationCheck, maxBytes?: number): number;
|
|
13
|
+
/** Validate, account and detach JSON in one bounded walk, without serialization hooks. */
|
|
14
|
+
export declare function snapshotClassifierJson(value: unknown, label: string, budget: ClassifierValueBudget, allowUndefinedProperties?: boolean): unknown;
|
|
15
|
+
/** Root entry kinds are narrower than the JSON values allowed inside structured entries. */
|
|
16
|
+
export declare function assertClassifierEntryKind(value: unknown, label: string): asserts value is ClassifierEntry;
|
|
17
|
+
export declare function assertClassifierEntry(value: unknown, label: string): asserts value is ClassifierEntry;
|
|
18
|
+
export declare function assertClassifierInstructionsKind(value: unknown, label?: string): asserts value is Exclude<ClassifierEntry, null>;
|
|
19
|
+
export declare function assertClassifierInstructions(value: unknown, label?: string): asserts value is Exclude<ClassifierEntry, null>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Core safety limits, not provider capacity claims. Stricter provider limits still apply. */
|
|
2
|
+
export declare const CLASSIFIER_LIMITS: {
|
|
3
|
+
readonly requestBytes: number;
|
|
4
|
+
readonly responseBytes: number;
|
|
5
|
+
readonly depth: 64;
|
|
6
|
+
readonly values: 100000;
|
|
7
|
+
readonly questions: 1000;
|
|
8
|
+
readonly messages: 1024;
|
|
9
|
+
readonly parts: 4096;
|
|
10
|
+
};
|
|
11
|
+
export type ClassifierPreparationCheck = () => void;
|
|
12
|
+
export declare class ClassifierResourceLimitError extends Error {
|
|
13
|
+
}
|
|
14
|
+
/** A plain view uses real byte geometry and cannot execute authored byte accessors/methods. */
|
|
15
|
+
export declare function classifierByteView(value: Uint8Array): Uint8Array;
|
|
16
|
+
export declare function classifierPreparationCheck(signal: AbortSignal, deadline: number, timeoutMs?: number): ClassifierPreparationCheck;
|
|
17
|
+
/** Bound expanded work before JSON serialization or image encoding, without reading getters. */
|
|
18
|
+
export declare function assertClassifierResourceLimits(value: unknown, check?: ClassifierPreparationCheck, maxBytes?: number): number;
|
|
19
|
+
/** One traversal can account, validate plain JSON, and detach it before IO. */
|
|
20
|
+
export declare class ClassifierValueBudget {
|
|
21
|
+
readonly check: ClassifierPreparationCheck;
|
|
22
|
+
private bytes;
|
|
23
|
+
private values;
|
|
24
|
+
private readonly maxBytes;
|
|
25
|
+
constructor(check?: ClassifierPreparationCheck, maxBytes?: number);
|
|
26
|
+
get remainingBytes(): number;
|
|
27
|
+
private add;
|
|
28
|
+
private string;
|
|
29
|
+
private value;
|
|
30
|
+
inspect(value: unknown, json?: {
|
|
31
|
+
label: string;
|
|
32
|
+
allowUndefinedProperties?: boolean;
|
|
33
|
+
copy?: boolean;
|
|
34
|
+
}): {
|
|
35
|
+
value: unknown;
|
|
36
|
+
bytes: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Bound parser allocation without interpreting brackets or separators inside strings. */
|
|
40
|
+
export declare function checkClassifierJsonWork(text: string, check: ClassifierPreparationCheck, label?: string): void;
|
|
41
|
+
/** Consume decoded response bytes incrementally; Content-Length is not trusted. */
|
|
42
|
+
export declare function readClassifierResponse(response: Response, signal: AbortSignal, check?: ClassifierPreparationCheck): Promise<unknown>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ClassifierEvaluationResponse, PreparedClassifierQuestion } from './types.js';
|
|
2
|
+
import type { PreparedClassifierEvaluation } from './providers.js';
|
|
3
|
+
/** OpenAI's Decisions schema is not the System One protocol. */
|
|
4
|
+
export declare function createOpenAIDecisionRequest(args: PreparedClassifierEvaluation): Record<string, unknown>;
|
|
5
|
+
export declare function validateOpenAIDecisionResponse(body: unknown, questions: readonly PreparedClassifierQuestion[], providerLabel?: string): ClassifierEvaluationResponse;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { InterpolationGuard } from '../../utils/interpolation.js';
|
|
2
|
+
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
3
|
+
/** One cumulative budget for authored templates, referenced values and resolved entries. */
|
|
4
|
+
export declare class ClassifierQuestionPreparation implements InterpolationGuard {
|
|
5
|
+
readonly tokenLimit: 100000;
|
|
6
|
+
private readonly budget;
|
|
7
|
+
private operations;
|
|
8
|
+
private readonly deadlineCheck;
|
|
9
|
+
constructor(context: Pick<InternalProcessContext, 'signal'>);
|
|
10
|
+
check: () => void;
|
|
11
|
+
capture(value: unknown): void;
|
|
12
|
+
prepareValue: (value: unknown) => unknown;
|
|
13
|
+
private inspect;
|
|
14
|
+
output: (fragment: string, previousLength: number) => void;
|
|
15
|
+
processing: (input: string, name: string, parameter: number | undefined) => void;
|
|
16
|
+
}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { ClassifierCredentialNames } from './credentials.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DataValue } from '../DataValue.js';
|
|
3
|
+
import { type ClassifierStateMessage, type PreparedClassifierState } from './state.js';
|
|
4
|
+
import { validateClassifierEvaluationResponse } from './response.js';
|
|
5
|
+
import type { ClassifierEvaluationResponse, ClassifierQuestionDefinition, PreparedClassifierQuestion } from './types.js';
|
|
6
|
+
export { validateApiCompatibleClassifierResponse } from './response.js';
|
|
3
7
|
export declare const JEV_SYSTEM_ONE_ENDPOINT = "https://api.typesafe.ai/v1/systemone";
|
|
8
|
+
export declare const LIQUID_SYSTEM_ONE_ENDPOINT = "https://api.liquid.ai/decisions/v1/systemone";
|
|
9
|
+
export declare const OPENAI_DECISIONS_ENDPOINT = "https://api.openai.com/v1/decisions";
|
|
4
10
|
/** Jev's published USD rates. Keep this Core-owned rather than graph-authored. */
|
|
5
11
|
export declare const JEV_TOKEN_PRICING: {
|
|
6
12
|
readonly inputPerMillionTokens: 0.042;
|
|
7
13
|
readonly outputPerMillionTokens: 0;
|
|
8
14
|
};
|
|
15
|
+
/** Liquid d1's published USD rates: https://www.liquid.ai/blog/d1-decision-model */
|
|
16
|
+
export declare const LIQUID_TOKEN_PRICING: {
|
|
17
|
+
readonly inputPerMillionTokens: 0.04;
|
|
18
|
+
readonly outputPerMillionTokens: 0;
|
|
19
|
+
};
|
|
9
20
|
export declare const DEFAULT_CLASSIFIER_RETRY_ON_NON_200_REPEAT_TIMES = 1;
|
|
10
21
|
export declare const DEFAULT_CLASSIFIER_RETRY_ON_NON_200_COOLDOWN_MS = 0;
|
|
11
22
|
export type ClassifierProvider = {
|
|
@@ -14,18 +25,35 @@ export type ClassifierProvider = {
|
|
|
14
25
|
defaultModel: string;
|
|
15
26
|
credentialNames: ClassifierCredentialNames;
|
|
16
27
|
browserExecutionSupported: boolean;
|
|
17
|
-
|
|
28
|
+
supportsImages?: (model: string) => boolean;
|
|
29
|
+
/** A stricter provider request limit also bounds preparation before encoding. */
|
|
30
|
+
maxRequestBytes?: number;
|
|
31
|
+
/** Legacy shorthand: pricing for defaultModel only, never arbitrary models. */
|
|
18
32
|
pricing?: ClassifierTokenPricing;
|
|
33
|
+
modelPricing?: readonly ClassifierModelPricing[];
|
|
19
34
|
/**
|
|
20
35
|
* The response used by the node plus the exact JSON bodies that crossed the
|
|
21
36
|
* provider boundary. Request headers deliberately do not belong here: they
|
|
22
37
|
* carry the API key and must never become graph outputs.
|
|
23
38
|
*/
|
|
24
39
|
evaluate(args: ClassifierProviderEvaluateArgs): Promise<ClassifierProviderEvaluationResult>;
|
|
40
|
+
/** Graph entry uses the same runner without normalizing/copying State twice. */
|
|
41
|
+
evaluateInput?(args: ClassifierProviderEvaluateArgs): Promise<ClassifierProviderEvaluationResult>;
|
|
25
42
|
};
|
|
26
43
|
export type ClassifierTokenPricing = {
|
|
27
44
|
inputPerMillionTokens: number;
|
|
28
45
|
outputPerMillionTokens: number;
|
|
46
|
+
/** The full request uses these rates above the documented context threshold. */
|
|
47
|
+
longContext?: {
|
|
48
|
+
aboveInputTokens: number;
|
|
49
|
+
inputPerMillionTokens: number;
|
|
50
|
+
outputPerMillionTokens: number;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export type ClassifierModelPricing = {
|
|
54
|
+
/** Exact verified model IDs/aliases belonging to the same priced model. */
|
|
55
|
+
models: readonly string[];
|
|
56
|
+
pricing: ClassifierTokenPricing;
|
|
29
57
|
};
|
|
30
58
|
export type ClassifierProviderEvaluationResult = {
|
|
31
59
|
requestBody: Record<string, unknown>;
|
|
@@ -38,13 +66,29 @@ export type ClassifierProviderEvaluateArgs = {
|
|
|
38
66
|
questions: readonly ClassifierQuestionDefinition[];
|
|
39
67
|
signal: AbortSignal;
|
|
40
68
|
state: string | Record<string, unknown> | unknown[];
|
|
69
|
+
stateMessages?: ClassifierStateMessage[];
|
|
70
|
+
/** Optional Rivet wrapper for the graph entry; ordinary provider calls use state/stateMessages. */
|
|
71
|
+
stateInput?: DataValue;
|
|
41
72
|
timeoutMs: number;
|
|
73
|
+
/** An earlier node deadline includes State normalization in the request budget. */
|
|
74
|
+
deadline?: number;
|
|
42
75
|
/** Opt-in retry policy for non-authentication, non-validation HTTP errors. */
|
|
43
76
|
retryOnNon200?: boolean;
|
|
44
77
|
retryOnNon200RepeatTimes?: number;
|
|
45
78
|
retryOnNon200CooldownMs?: number;
|
|
46
79
|
fetchImplementation?: typeof fetch;
|
|
47
80
|
};
|
|
81
|
+
export type PreparedClassifierEvaluation = {
|
|
82
|
+
model: string;
|
|
83
|
+
state: PreparedClassifierState;
|
|
84
|
+
questions: PreparedClassifierQuestion[];
|
|
85
|
+
};
|
|
86
|
+
type ClassifierProviderSpec = Omit<ClassifierProvider, 'evaluate' | 'evaluateInput'> & {
|
|
87
|
+
endpoint: string;
|
|
88
|
+
buildRequest(args: PreparedClassifierEvaluation): Record<string, unknown>;
|
|
89
|
+
validateResponse: typeof validateClassifierEvaluationResponse;
|
|
90
|
+
checkState?(state: PreparedClassifierState, check: () => void): void;
|
|
91
|
+
};
|
|
48
92
|
export type ApiCompatibleClassifierProviderConfig = {
|
|
49
93
|
id: string;
|
|
50
94
|
label: string;
|
|
@@ -53,8 +97,13 @@ export type ApiCompatibleClassifierProviderConfig = {
|
|
|
53
97
|
/** Static, provider-owned endpoint. It must never come from graph data. */
|
|
54
98
|
endpoint: string;
|
|
55
99
|
browserExecutionSupported?: boolean;
|
|
56
|
-
/** Static USD token pricing
|
|
100
|
+
/** Static USD token pricing for Cost and optional Usage accounting. */
|
|
57
101
|
pricing?: ClassifierTokenPricing;
|
|
102
|
+
modelPricing?: readonly ClassifierModelPricing[];
|
|
103
|
+
supportsImages?: (model: string) => boolean;
|
|
104
|
+
maxRequestBytes?: number;
|
|
105
|
+
/** Provider-owned evidence checks, independent of the descriptor's ID. */
|
|
106
|
+
checkState?: ClassifierProviderSpec['checkState'];
|
|
58
107
|
};
|
|
59
108
|
/**
|
|
60
109
|
* Builds a provider for the shared System One-compatible protocol. Provider
|
|
@@ -63,16 +112,25 @@ export type ApiCompatibleClassifierProviderConfig = {
|
|
|
63
112
|
*/
|
|
64
113
|
export declare function createApiCompatibleClassifierProvider(config: ApiCompatibleClassifierProviderConfig): ClassifierProvider;
|
|
65
114
|
export declare const jevClassifierProvider: ClassifierProvider;
|
|
66
|
-
|
|
115
|
+
export declare const liquidClassifierProvider: ClassifierProvider;
|
|
116
|
+
/** Decisions-specific rates, not GPT-6 Luna's Chat/Responses cache/output rates.
|
|
117
|
+
* https://developers.openai.com/api/docs/guides/decisions#pricing-and-availability
|
|
118
|
+
*/
|
|
119
|
+
export declare const openaiClassifierProvider: ClassifierProvider;
|
|
120
|
+
/** Ordered so adding compatible providers does not alter authored IDs. */
|
|
67
121
|
export declare const classifierProviders: readonly ClassifierProvider[];
|
|
68
122
|
export declare function getClassifierProvider(id: string | undefined): ClassifierProvider;
|
|
69
123
|
export declare function getClassifierProviderEnvironmentVariableNames(): string[];
|
|
70
124
|
/**
|
|
71
|
-
* Returns a USD cost only
|
|
72
|
-
* the token counts are safe non-negative integers.
|
|
73
|
-
*
|
|
125
|
+
* Returns a USD cost only for a recognized requested/returned model pair and
|
|
126
|
+
* the token counts are safe non-negative integers. Provider input_tokens already
|
|
127
|
+
* includes billed text/image work across questions; never multiply by question
|
|
128
|
+
* count or add image tokens again. Decisions has no separate cache charges.
|
|
129
|
+
* Callers must not treat an unpriced provider as free.
|
|
74
130
|
*/
|
|
75
|
-
export declare function calculateClassifierUsageCost(provider: Pick<ClassifierProvider, 'pricing'
|
|
131
|
+
export declare function calculateClassifierUsageCost(provider: Pick<ClassifierProvider, 'pricing' | 'modelPricing'> & Partial<Pick<ClassifierProvider, 'defaultModel'>>, usage: ClassifierEvaluationResponse['usage'], models?: {
|
|
132
|
+
requestedModel: string;
|
|
133
|
+
responseModel: string;
|
|
134
|
+
}): number | undefined;
|
|
76
135
|
export declare function normalizeClassifierNon200RetryCount(value: number | undefined): number;
|
|
77
136
|
export declare function normalizeClassifierNon200RetryCooldownMs(value: number | undefined): number;
|
|
78
|
-
export declare function validateApiCompatibleClassifierResponse(body: unknown, questions: readonly ClassifierQuestionDefinition[], providerLabel?: string): ClassifierEvaluationResponse;
|
|
@@ -2,6 +2,8 @@ import type { Inputs } from '../GraphProcessor.js';
|
|
|
2
2
|
import type { NodeInputDefinition } from '../NodeBase.js';
|
|
3
3
|
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
4
4
|
import type { ClassifierEntry, ClassifierEntryEditorType } from './types.js';
|
|
5
|
+
import type { ClassifierQuestionPreparation } from './preparation.js';
|
|
6
|
+
export { assertClassifierEntry, assertClassifierInstructions } from './json.js';
|
|
5
7
|
export type ClassifierQuestionBaseData = {
|
|
6
8
|
questionId: string;
|
|
7
9
|
instructions: string;
|
|
@@ -13,8 +15,8 @@ export type ClassifierQuestionBaseData = {
|
|
|
13
15
|
export declare function getInstructionsInputDefinition(): NodeInputDefinition;
|
|
14
16
|
export declare function getCriteriaInputDefinition(dataTypes: NodeInputDefinition['dataType']): NodeInputDefinition;
|
|
15
17
|
export declare function getInterpolationInputDefinitions(templates: readonly string[], reserved: ReadonlySet<string>): NodeInputDefinition[];
|
|
16
|
-
export declare function interpolateQuestionText(template: string, inputs: Inputs, context: InternalProcessContext): string;
|
|
17
|
-
export declare function resolveAuthoredClassifierEntry({ type, text, lines, objectTemplate, inputs, context, label, }: {
|
|
18
|
+
export declare function interpolateQuestionText(template: string, inputs: Inputs, context: InternalProcessContext, preparation?: ClassifierQuestionPreparation): string;
|
|
19
|
+
export declare function resolveAuthoredClassifierEntry({ type, text, lines, objectTemplate, inputs, context, label, preparation, }: {
|
|
18
20
|
type: ClassifierEntryEditorType | undefined;
|
|
19
21
|
text: string | undefined;
|
|
20
22
|
lines: readonly string[] | undefined;
|
|
@@ -22,10 +24,10 @@ export declare function resolveAuthoredClassifierEntry({ type, text, lines, obje
|
|
|
22
24
|
inputs: Inputs;
|
|
23
25
|
context: InternalProcessContext;
|
|
24
26
|
label: string;
|
|
27
|
+
preparation?: ClassifierQuestionPreparation;
|
|
25
28
|
}): Exclude<ClassifierEntry, null>;
|
|
29
|
+
export declare function getQuestionInputValue(inputs: Inputs, portId: string, label: string): unknown;
|
|
26
30
|
export declare function getStringInput(inputs: Inputs, portId: string, label: string): string;
|
|
27
31
|
export declare function requireQuestionId(questionId: string): string;
|
|
28
32
|
export declare function getStructuredInput(inputs: Inputs, portId: string, label: string): ClassifierEntry;
|
|
29
|
-
export declare function assertClassifierEntry(value: unknown, label: string): asserts value is ClassifierEntry;
|
|
30
|
-
export declare function assertClassifierInstructions(value: unknown, label?: string): asserts value is Exclude<ClassifierEntry, null>;
|
|
31
33
|
export declare function abbreviate(value: string, maximum?: number): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PreparedClassifierQuestion } from './types.js';
|
|
2
|
+
import type { ClassifierValueBudget } from './limits.js';
|
|
3
|
+
/** Shared by node execution and direct provider calls, before taking the request snapshot. */
|
|
4
|
+
export declare function prepareClassifierQuestion(value: unknown, budget: ClassifierValueBudget): PreparedClassifierQuestion;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ClassifierQuestionDefinition, PreparedClassifierQuestion, ClassifierEvaluationResponse } from './types.js';
|
|
2
|
+
export declare function validateApiCompatibleClassifierResponse(body: unknown, questions: readonly ClassifierQuestionDefinition[], providerLabel?: string): ClassifierEvaluationResponse;
|
|
3
|
+
/** Validate the common Rivet result, independently of the provider's wire protocol. */
|
|
4
|
+
export declare function validateClassifierEvaluationResponse(body: unknown, questions: readonly PreparedClassifierQuestion[], providerLabel?: string): ClassifierEvaluationResponse;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DataValue } from '../DataValue.js';
|
|
2
|
+
import { type PreparedClassifierImage } from './images.js';
|
|
3
|
+
import { ClassifierValueBudget, type ClassifierPreparationCheck } from './limits.js';
|
|
4
|
+
export type ClassifierStatePart = {
|
|
5
|
+
type: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'image';
|
|
9
|
+
dataUrl: string;
|
|
10
|
+
};
|
|
11
|
+
export type ClassifierStateMessage = {
|
|
12
|
+
parts: ClassifierStatePart[];
|
|
13
|
+
};
|
|
14
|
+
/** Compatibility input/output used by direct provider callers and normalization helpers. */
|
|
15
|
+
export type ClassifierState = {
|
|
16
|
+
state: string | Record<string, unknown> | unknown[];
|
|
17
|
+
stateMessages?: ClassifierStateMessage[];
|
|
18
|
+
};
|
|
19
|
+
export type PreparedClassifierState = {
|
|
20
|
+
kind: 'json';
|
|
21
|
+
value: ClassifierState['state'];
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'messages';
|
|
24
|
+
messages: ClassifierStateMessage[];
|
|
25
|
+
images: PreparedClassifierImage[];
|
|
26
|
+
};
|
|
27
|
+
/** Graph and direct provider calls converge here; no caller can bypass preparation. */
|
|
28
|
+
export declare function prepareClassifierState(input: ClassifierState & {
|
|
29
|
+
stateInput?: DataValue;
|
|
30
|
+
}, budget: ClassifierValueBudget): PreparedClassifierState;
|
|
31
|
+
/** Standalone compatibility helper uses the same preparation, not a separate validator. */
|
|
32
|
+
export declare function normalizeClassifierState(input: DataValue | undefined, check?: ClassifierPreparationCheck, maxBytes?: number): ClassifierState;
|
|
33
|
+
/** System One separates images; numbered placeholders retain caption/image associations. */
|
|
34
|
+
export declare function systemOneState(input: ClassifierState): {
|
|
35
|
+
state: ClassifierState['state'];
|
|
36
|
+
images?: string[];
|
|
37
|
+
};
|
|
@@ -48,6 +48,8 @@ export type ClassifierNoulQuestionDefinition = ClassifierQuestionDefinition & {
|
|
|
48
48
|
false: ClassifierEntry;
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
|
+
/** Internal contract after the untrusted public definition has been validated. */
|
|
52
|
+
export type PreparedClassifierQuestion = ClassifierChoiceQuestionDefinition | ClassifierScoreQuestionDefinition | ClassifierNoulQuestionDefinition;
|
|
51
53
|
export type ClassifierEvaluationResponse = {
|
|
52
54
|
model: string;
|
|
53
55
|
answers: Record<string, unknown>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Outputs } from './GraphProcessor.js';
|
|
2
|
+
import type { NodeOutputDefinition } from './NodeBase.js';
|
|
3
|
+
export type NodeRunFailureSettings = {
|
|
4
|
+
/** Missing on legacy nodes preserves their existing throw behavior. */
|
|
5
|
+
errorOnNon200?: boolean;
|
|
6
|
+
catchRequestFailed?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function hasRunFailureOutputs(data: NodeRunFailureSettings): boolean;
|
|
9
|
+
export declare function getRunFailureOutputDefinitions(data: NodeRunFailureSettings): NodeOutputDefinition[];
|
|
10
|
+
export declare function shouldCatchRunFailure(data: NodeRunFailureSettings, error: unknown, signal: AbortSignal): boolean;
|
|
11
|
+
export declare function withRunSuccessOutputs(data: NodeRunFailureSettings, outputs: Outputs): Outputs;
|
|
12
|
+
/** Never route a partial model answer or fabricated usage through the success branch. */
|
|
13
|
+
export declare function createCaughtRunFailureOutputs(definitions: readonly NodeOutputDefinition[], error: unknown, evidence?: Outputs): Outputs;
|