@valerypopoff/rivet2-core 2.13.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 +28167 -23834
- 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 +10 -2
- package/dist/esm/api/processSettings.js +1 -0
- package/dist/esm/exports.js +6 -0
- package/dist/esm/model/GraphBoundaryCache.js +2 -1
- package/dist/esm/model/GraphProcessor.js +278 -22
- package/dist/esm/model/MarkdownSanitizationPolicy.js +2 -0
- package/dist/esm/model/NodeImpl.js +1 -1
- package/dist/esm/model/Nodes.js +16 -0
- package/dist/esm/model/ProjectBundle.js +235 -0
- package/dist/esm/model/SplitRunProcessor.js +28 -7
- package/dist/esm/model/StreamingWatchTopology.js +211 -64
- 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 +107 -0
- 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/migration.js +97 -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 +422 -0
- package/dist/esm/model/classifier/questionHelpers.js +109 -0
- 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/classifier/types.js +1 -0
- package/dist/esm/model/nodeBodyMarkdown.js +37 -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 +432 -0
- package/dist/esm/model/nodes/ClassifierQuestionNode.js +613 -0
- package/dist/esm/model/nodes/CodeNewNode.js +33 -9
- 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 +27 -15
- package/dist/esm/model/nodes/LLMProfileNode.js +6 -12
- package/dist/esm/model/nodes/MatchCaseNode.js +76 -1
- package/dist/esm/model/nodes/MatchCaseNodeBase.js +24 -2
- package/dist/esm/model/nodes/ObjectNode.js +68 -50
- package/dist/esm/model/nodes/PassthroughNode.js +1 -1
- 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/model/nodes/codeOutputInference.js +292 -0
- 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 +7 -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 +6 -0
- package/dist/types/model/CycleDetector.d.ts +1 -2
- package/dist/types/model/EditorDefinition.d.ts +24 -0
- 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/MarkdownSanitizationPolicy.d.ts +1 -1
- package/dist/types/model/NodeImpl.d.ts +3 -1
- package/dist/types/model/Nodes.d.ts +10 -4
- 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/Settings.d.ts +4 -0
- package/dist/types/model/StreamingWatchTopology.d.ts +17 -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 +26 -0
- 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/migration.d.ts +18 -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 +136 -0
- package/dist/types/model/classifier/questionHelpers.d.ts +33 -0
- 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 +60 -0
- package/dist/types/model/nodeBodyMarkdown.d.ts +19 -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 +50 -0
- package/dist/types/model/nodes/ClassifierQuestionNode.d.ts +60 -0
- package/dist/types/model/nodes/CodeNewNode.d.ts +6 -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/MatchCaseNode.d.ts +8 -1
- package/dist/types/model/nodes/MatchCaseNodeBase.d.ts +13 -1
- package/dist/types/model/nodes/ObjectNode.d.ts +6 -0
- 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/model/nodes/codeOutputInference.d.ts +31 -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
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { ChartNode, NodeConnection, NodeId } from './NodeBase.js';
|
|
2
2
|
import type { FrozenNodeOutputsByGraph } from './GraphProcessor.js';
|
|
3
3
|
import type { GraphInputNode } from './nodes/GraphInputNode.js';
|
|
4
|
+
import type { GraphOutputNode } from './nodes/GraphOutputNode.js';
|
|
4
5
|
import type { NodeGraph } from './NodeGraph.js';
|
|
5
6
|
import type { NodeRegistration } from './NodeRegistration.js';
|
|
6
7
|
import type { Project, ProjectId } from './Project.js';
|
|
7
8
|
import type { ReferencedGraphAliasNode } from './nodes/ReferencedGraphAliasNode.js';
|
|
8
9
|
import type { SubGraphNode } from './nodes/SubGraphNode.js';
|
|
10
|
+
/** An executing caller may forward outputs after its condition has passed. */
|
|
11
|
+
export declare function canForwardGraphCallerOutputPartials(node: ChartNode): node is SubGraphNode | ReferencedGraphAliasNode;
|
|
12
|
+
/** Early input delivery must not bypass the caller's ordinary readiness/condition gate. */
|
|
9
13
|
export declare function canStreamThroughGraphCaller(node: ChartNode): node is SubGraphNode | ReferencedGraphAliasNode;
|
|
10
14
|
export declare function canStreamThroughGraphInput(node: ChartNode): node is GraphInputNode;
|
|
15
|
+
/** A named output may forward only when one direct producer determines its terminal value. */
|
|
16
|
+
export declare function canForwardGraphOutputPartials(graphOutput: ChartNode, sourceNode: ChartNode, graphOutputIsFrozen: boolean): graphOutput is GraphOutputNode;
|
|
11
17
|
/** Trace Watch demand through named boundaries without making ordinary nodes repeatable. */
|
|
12
|
-
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, }: {
|
|
13
19
|
project: Project;
|
|
14
20
|
graph: NodeGraph;
|
|
15
21
|
referencedProjects: Record<ProjectId, Project>;
|
|
@@ -17,4 +23,14 @@ export declare function getProjectStreamingOutputWatchConnections({ project, gra
|
|
|
17
23
|
frozenNodeOutputs?: FrozenNodeOutputsByGraph;
|
|
18
24
|
isNodeFrozen?: (owner: Project, candidate: NodeGraph, node: ChartNode) => boolean;
|
|
19
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;
|
|
20
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>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Inputs } from '../GraphProcessor.js';
|
|
2
|
+
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
3
|
+
export type ClassifierApiKeySource = 'configured' | 'classifier-settings' | 'input';
|
|
4
|
+
export type ClassifierCredentialNames = {
|
|
5
|
+
programmaticName: string;
|
|
6
|
+
environmentVariableName: string;
|
|
7
|
+
};
|
|
8
|
+
export type ClassifierProviderCredentials = Record<string, {
|
|
9
|
+
apiKey?: string | undefined;
|
|
10
|
+
}>;
|
|
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;
|
|
14
|
+
export declare function isValidClassifierProgrammaticCredentialName(name: string): boolean;
|
|
15
|
+
export declare function isValidClassifierEnvironmentCredentialName(name: string): boolean;
|
|
16
|
+
export declare function normalizeClassifierCredentialNames(value: unknown, defaults?: ClassifierCredentialNames): ClassifierCredentialNames;
|
|
17
|
+
export declare function getClassifierCredentialNamesForDisplay(value: unknown, defaults?: ClassifierCredentialNames): ClassifierCredentialNames;
|
|
18
|
+
export declare function isDefaultClassifierCredentialNames(names: ClassifierCredentialNames, defaults?: ClassifierCredentialNames): boolean;
|
|
19
|
+
export declare function resolveClassifierApiKey({ apiKeyNames, apiKeySource, context, defaults, inputs, providerId, }: {
|
|
20
|
+
apiKeyNames?: ClassifierCredentialNames | undefined;
|
|
21
|
+
apiKeySource?: ClassifierApiKeySource | undefined;
|
|
22
|
+
context: Pick<InternalProcessContext, 'settings'>;
|
|
23
|
+
defaults: ClassifierCredentialNames;
|
|
24
|
+
inputs: Inputs;
|
|
25
|
+
providerId: string;
|
|
26
|
+
}): string;
|
|
@@ -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,18 @@
|
|
|
1
|
+
import type { ChartNode } from '../NodeBase.js';
|
|
2
|
+
import type { NodeGraph } from '../NodeGraph.js';
|
|
3
|
+
import type { Project } from '../Project.js';
|
|
4
|
+
/**
|
|
5
|
+
* Converts the former TypeSafe plugin node family into the first-party
|
|
6
|
+
* classifier contract. It is intentionally idempotent because project data
|
|
7
|
+
* reaches Core through imports, hosted snapshots, recordings, and copies.
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeClassifierProject(project: Project): void;
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether a project still needs the in-place legacy migration. Hosts
|
|
12
|
+
* which receive a caller-owned project object use this before cloning, so a
|
|
13
|
+
* compatibility repair never mutates the caller's snapshot.
|
|
14
|
+
*/
|
|
15
|
+
export declare function hasLegacyClassifierProjectData(project: Project): boolean;
|
|
16
|
+
export declare function normalizeClassifierGraph(graph: NodeGraph): void;
|
|
17
|
+
export declare function hasLegacyClassifierGraphData(graph: NodeGraph): boolean;
|
|
18
|
+
export declare function normalizeClassifierNode(node: ChartNode): void;
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { ClassifierCredentialNames } from './credentials.js';
|
|
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';
|
|
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";
|
|
10
|
+
/** Jev's published USD rates. Keep this Core-owned rather than graph-authored. */
|
|
11
|
+
export declare const JEV_TOKEN_PRICING: {
|
|
12
|
+
readonly inputPerMillionTokens: 0.042;
|
|
13
|
+
readonly outputPerMillionTokens: 0;
|
|
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
|
+
};
|
|
20
|
+
export declare const DEFAULT_CLASSIFIER_RETRY_ON_NON_200_REPEAT_TIMES = 1;
|
|
21
|
+
export declare const DEFAULT_CLASSIFIER_RETRY_ON_NON_200_COOLDOWN_MS = 0;
|
|
22
|
+
export type ClassifierProvider = {
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
defaultModel: string;
|
|
26
|
+
credentialNames: ClassifierCredentialNames;
|
|
27
|
+
browserExecutionSupported: boolean;
|
|
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. */
|
|
32
|
+
pricing?: ClassifierTokenPricing;
|
|
33
|
+
modelPricing?: readonly ClassifierModelPricing[];
|
|
34
|
+
/**
|
|
35
|
+
* The response used by the node plus the exact JSON bodies that crossed the
|
|
36
|
+
* provider boundary. Request headers deliberately do not belong here: they
|
|
37
|
+
* carry the API key and must never become graph outputs.
|
|
38
|
+
*/
|
|
39
|
+
evaluate(args: ClassifierProviderEvaluateArgs): Promise<ClassifierProviderEvaluationResult>;
|
|
40
|
+
/** Graph entry uses the same runner without normalizing/copying State twice. */
|
|
41
|
+
evaluateInput?(args: ClassifierProviderEvaluateArgs): Promise<ClassifierProviderEvaluationResult>;
|
|
42
|
+
};
|
|
43
|
+
export type ClassifierTokenPricing = {
|
|
44
|
+
inputPerMillionTokens: number;
|
|
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;
|
|
57
|
+
};
|
|
58
|
+
export type ClassifierProviderEvaluationResult = {
|
|
59
|
+
requestBody: Record<string, unknown>;
|
|
60
|
+
response: ClassifierEvaluationResponse;
|
|
61
|
+
responseBody: Record<string, unknown>;
|
|
62
|
+
};
|
|
63
|
+
export type ClassifierProviderEvaluateArgs = {
|
|
64
|
+
apiKey: string;
|
|
65
|
+
model: string;
|
|
66
|
+
questions: readonly ClassifierQuestionDefinition[];
|
|
67
|
+
signal: AbortSignal;
|
|
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;
|
|
72
|
+
timeoutMs: number;
|
|
73
|
+
/** An earlier node deadline includes State normalization in the request budget. */
|
|
74
|
+
deadline?: number;
|
|
75
|
+
/** Opt-in retry policy for non-authentication, non-validation HTTP errors. */
|
|
76
|
+
retryOnNon200?: boolean;
|
|
77
|
+
retryOnNon200RepeatTimes?: number;
|
|
78
|
+
retryOnNon200CooldownMs?: number;
|
|
79
|
+
fetchImplementation?: typeof fetch;
|
|
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
|
+
};
|
|
92
|
+
export type ApiCompatibleClassifierProviderConfig = {
|
|
93
|
+
id: string;
|
|
94
|
+
label: string;
|
|
95
|
+
defaultModel: string;
|
|
96
|
+
credentialNames: ClassifierCredentialNames;
|
|
97
|
+
/** Static, provider-owned endpoint. It must never come from graph data. */
|
|
98
|
+
endpoint: string;
|
|
99
|
+
browserExecutionSupported?: boolean;
|
|
100
|
+
/** Static USD token pricing for Cost and optional Usage accounting. */
|
|
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'];
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Builds a provider for the shared System One-compatible protocol. Provider
|
|
110
|
+
* descriptors remain static Core code, while the Evaluate node stays agnostic
|
|
111
|
+
* to which compatible provider is selected.
|
|
112
|
+
*/
|
|
113
|
+
export declare function createApiCompatibleClassifierProvider(config: ApiCompatibleClassifierProviderConfig): ClassifierProvider;
|
|
114
|
+
export declare const jevClassifierProvider: ClassifierProvider;
|
|
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. */
|
|
121
|
+
export declare const classifierProviders: readonly ClassifierProvider[];
|
|
122
|
+
export declare function getClassifierProvider(id: string | undefined): ClassifierProvider;
|
|
123
|
+
export declare function getClassifierProviderEnvironmentVariableNames(): string[];
|
|
124
|
+
/**
|
|
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.
|
|
130
|
+
*/
|
|
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;
|
|
135
|
+
export declare function normalizeClassifierNon200RetryCount(value: number | undefined): number;
|
|
136
|
+
export declare function normalizeClassifierNon200RetryCooldownMs(value: number | undefined): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Inputs } from '../GraphProcessor.js';
|
|
2
|
+
import type { NodeInputDefinition } from '../NodeBase.js';
|
|
3
|
+
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
4
|
+
import type { ClassifierEntry, ClassifierEntryEditorType } from './types.js';
|
|
5
|
+
import type { ClassifierQuestionPreparation } from './preparation.js';
|
|
6
|
+
export { assertClassifierEntry, assertClassifierInstructions } from './json.js';
|
|
7
|
+
export type ClassifierQuestionBaseData = {
|
|
8
|
+
questionId: string;
|
|
9
|
+
instructions: string;
|
|
10
|
+
instructionsType?: ClassifierEntryEditorType;
|
|
11
|
+
instructionsLines?: string[];
|
|
12
|
+
instructionsObjectTemplate?: string;
|
|
13
|
+
useInstructionsInput?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function getInstructionsInputDefinition(): NodeInputDefinition;
|
|
16
|
+
export declare function getCriteriaInputDefinition(dataTypes: NodeInputDefinition['dataType']): NodeInputDefinition;
|
|
17
|
+
export declare function getInterpolationInputDefinitions(templates: readonly string[], reserved: ReadonlySet<string>): NodeInputDefinition[];
|
|
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, }: {
|
|
20
|
+
type: ClassifierEntryEditorType | undefined;
|
|
21
|
+
text: string | undefined;
|
|
22
|
+
lines: readonly string[] | undefined;
|
|
23
|
+
objectTemplate: string | undefined;
|
|
24
|
+
inputs: Inputs;
|
|
25
|
+
context: InternalProcessContext;
|
|
26
|
+
label: string;
|
|
27
|
+
preparation?: ClassifierQuestionPreparation;
|
|
28
|
+
}): Exclude<ClassifierEntry, null>;
|
|
29
|
+
export declare function getQuestionInputValue(inputs: Inputs, portId: string, label: string): unknown;
|
|
30
|
+
export declare function getStringInput(inputs: Inputs, portId: string, label: string): string;
|
|
31
|
+
export declare function requireQuestionId(questionId: string): string;
|
|
32
|
+
export declare function getStructuredInput(inputs: Inputs, portId: string, label: string): ClassifierEntry;
|
|
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
|
+
};
|