@valerypopoff/rivet2-core 2.26.0 → 2.27.1
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 +73 -27
- package/dist/cjs/bundle.cjs.map +2 -2
- package/dist/cjs/webAppRuntime.cjs.map +1 -1
- package/dist/esm/model/GraphBoundaryCache.js +2 -2
- package/dist/esm/model/LatestDebuggerProtocol.js +28 -5
- package/dist/esm/model/classifier/baseten.js +2 -1
- package/dist/esm/model/classifier/providers.js +55 -30
- package/dist/types/model/GraphBoundaryCache.d.ts +1 -0
- package/dist/types/model/LatestDebuggerProtocol.d.ts +10 -2
- package/dist/types/model/classifier/baseten.d.ts +2 -2
- package/dist/types/model/classifier/providers.d.ts +11 -11
- package/dist/types/model/classifier/types.d.ts +5 -0
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ export function applyGraphBoundaryPortOrder(boundaryItems, portOrder) {
|
|
|
21
21
|
if (!portOrder?.length) {
|
|
22
22
|
return [...boundaryItems];
|
|
23
23
|
}
|
|
24
|
-
const itemsById = new Map(boundaryItems.map((item) => [item.id, item]));
|
|
24
|
+
const itemsById = new Map(boundaryItems.map((item) => [item.portId ?? item.id, item]));
|
|
25
25
|
const usedIds = new Set();
|
|
26
26
|
const orderedItems = [];
|
|
27
27
|
for (const id of portOrder) {
|
|
@@ -36,7 +36,7 @@ export function applyGraphBoundaryPortOrder(boundaryItems, portOrder) {
|
|
|
36
36
|
usedIds.add(id);
|
|
37
37
|
}
|
|
38
38
|
for (const item of boundaryItems) {
|
|
39
|
-
if (!usedIds.has(item.id)) {
|
|
39
|
+
if (!usedIds.has(item.portId ?? item.id)) {
|
|
40
40
|
orderedItems.push(item);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -33,17 +33,27 @@ export function isLatestDebuggerExecutionMessage(message) {
|
|
|
33
33
|
return (Object.hasOwn(managedProcessMessages, message) || message === 'latest-settled' || message === 'latest-prompt-closed');
|
|
34
34
|
}
|
|
35
35
|
/** Preserve historical writer ordering while readers accept arbitrary JSON ordering. */
|
|
36
|
-
export function encodeLatestDebuggerEnvelope(serialized, scope, eventId) {
|
|
37
|
-
if (!scope && !eventId)
|
|
36
|
+
export function encodeLatestDebuggerEnvelope(serialized, scope, eventId, history = false) {
|
|
37
|
+
if (!scope && !eventId && !history)
|
|
38
38
|
return serialized;
|
|
39
39
|
const metadata = JSON.stringify({
|
|
40
40
|
...(eventId ? { rivetEventId: eventId } : {}),
|
|
41
41
|
...(scope ? { rivetScope: scope } : {}),
|
|
42
|
+
...(history ? { rivetHistory: history } : {}),
|
|
42
43
|
});
|
|
43
44
|
return `${metadata.slice(0, -1)},${serialized.slice(1)}`;
|
|
44
45
|
}
|
|
45
|
-
export function createLatestDebuggerSession(channel) {
|
|
46
|
-
return {
|
|
46
|
+
export function createLatestDebuggerSession(channel, historyThrough) {
|
|
47
|
+
return {
|
|
48
|
+
message: 'latest-session',
|
|
49
|
+
data: {
|
|
50
|
+
protocol: 2,
|
|
51
|
+
channel,
|
|
52
|
+
channelIsolation: true,
|
|
53
|
+
runScopedControls: true,
|
|
54
|
+
...(historyThrough ? { historyThrough } : {}),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
47
57
|
}
|
|
48
58
|
export function isLatestDebuggerSession(value) {
|
|
49
59
|
const frame = value;
|
|
@@ -52,7 +62,11 @@ export function isLatestDebuggerSession(value) {
|
|
|
52
62
|
(frame.data.channel === null ||
|
|
53
63
|
(typeof frame.data.channel === 'string' && /^[A-Za-z0-9_-]{1,32}$/.test(frame.data.channel))) &&
|
|
54
64
|
frame.data.channelIsolation === true &&
|
|
55
|
-
frame.data.runScopedControls === true
|
|
65
|
+
frame.data.runScopedControls === true &&
|
|
66
|
+
(frame.data.historyThrough === undefined ||
|
|
67
|
+
(Array.isArray(frame.data.historyThrough) &&
|
|
68
|
+
frame.data.historyThrough.length <= 8192 &&
|
|
69
|
+
frame.data.historyThrough.every((id) => readLatestDebuggerEventPosition(id) !== undefined))));
|
|
56
70
|
}
|
|
57
71
|
/** Validate the routing contract only. Authored data and decoded sentinels stay intact. */
|
|
58
72
|
export function readLatestDebuggerExecution(value) {
|
|
@@ -112,6 +126,15 @@ export function readLatestDebuggerEventId(value) {
|
|
|
112
126
|
const id = value.rivetEventId;
|
|
113
127
|
return typeof id === 'string' && /^[a-z0-9:-]{1,200}$/.test(id) ? id : undefined;
|
|
114
128
|
}
|
|
129
|
+
export function readLatestDebuggerEventPosition(value) {
|
|
130
|
+
if (typeof value !== 'string' || value.length > 200 || !/^[a-z0-9:-]+:[1-9]\d{0,15}$/.test(value))
|
|
131
|
+
return;
|
|
132
|
+
const split = value.lastIndexOf(':');
|
|
133
|
+
const sequence = Number(value.slice(split + 1));
|
|
134
|
+
if (!Number.isSafeInteger(sequence))
|
|
135
|
+
return;
|
|
136
|
+
return { origin: value.slice(0, split), sequence };
|
|
137
|
+
}
|
|
115
138
|
export function isLatestDebuggerControlResult(value) {
|
|
116
139
|
const message = value;
|
|
117
140
|
return (message?.message === 'latest-control-result' &&
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { inspectClassifierImage } from './images.js';
|
|
2
|
-
/** Native Model API slugs, not Hugging Face or gateway IDs. Verified 2026-10-
|
|
2
|
+
/** Native Model API slugs, not Hugging Face or gateway IDs. Verified 2026-10-30. */
|
|
3
3
|
export const BASETEN_DECISION_MODELS = [
|
|
4
4
|
'decision-models/baseten-elephant-9b-latest',
|
|
5
5
|
'decision-models/baseten-mammoth-27b-latest',
|
|
6
|
+
'decision-models/baseten-joey-2b-latest',
|
|
6
7
|
];
|
|
7
8
|
/** Baseten uses inline user-message image parts, never top-level images/placeholders. */
|
|
8
9
|
export function basetenDecisionState(state) {
|
|
@@ -29,7 +29,6 @@ export const LIQUID_TOKEN_PRICING = {
|
|
|
29
29
|
inputPerMillionTokens: 0.02,
|
|
30
30
|
outputPerMillionTokens: 0,
|
|
31
31
|
};
|
|
32
|
-
const TOKENS_PER_MILLION = 1_000_000;
|
|
33
32
|
const MAX_AUTOMATIC_ATTEMPTS = 3;
|
|
34
33
|
const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
35
34
|
const RETRYABLE_STATUSES = new Set([429, 529]);
|
|
@@ -56,7 +55,11 @@ export const jevClassifierProvider = createClassifierProvider({
|
|
|
56
55
|
id: 'jev',
|
|
57
56
|
label: 'Jev',
|
|
58
57
|
defaultModel: 'jev-latest',
|
|
59
|
-
modelOptions: ['jev-latest', 'jev-preview', 'jev-1.14.0', 'jev-1.13.0'].map((value) => ({
|
|
58
|
+
modelOptions: ['jev-latest', 'jev-preview', 'jev-1.14.0', 'jev-1.13.0'].map((value) => ({
|
|
59
|
+
value,
|
|
60
|
+
label: value,
|
|
61
|
+
aggregateTokenUsageOnly: true,
|
|
62
|
+
})),
|
|
60
63
|
modelHelp: 'Jev images are experimental: use still PNG/JPEG, 280–1568 pixels per side. Image requests enable TypeSafe’s experimental image API.',
|
|
61
64
|
credentialNames: JEV_DEFAULT_CREDENTIAL_NAMES,
|
|
62
65
|
endpoint: JEV_SYSTEM_ONE_ENDPOINT,
|
|
@@ -86,7 +89,7 @@ export const liquidClassifierProvider = createApiCompatibleClassifierProvider({
|
|
|
86
89
|
id: 'liquid',
|
|
87
90
|
label: 'Liquid AI',
|
|
88
91
|
defaultModel: 'd1',
|
|
89
|
-
modelOptions: ['d1', 'd1.1'].map((value) => ({ value, label: value })),
|
|
92
|
+
modelOptions: ['d1', 'd1.1'].map((value) => ({ value, label: value, aggregateTokenUsageOnly: true })),
|
|
90
93
|
modelHelp: 'Images belong in shared State, not Question Instructions.',
|
|
91
94
|
credentialNames: LIQUID_DEFAULT_CREDENTIAL_NAMES,
|
|
92
95
|
endpoint: LIQUID_SYSTEM_ONE_ENDPOINT,
|
|
@@ -105,7 +108,9 @@ export const openrouterClassifierProvider = createApiCompatibleClassifierProvide
|
|
|
105
108
|
id: 'openrouter',
|
|
106
109
|
label: 'OpenRouter',
|
|
107
110
|
defaultModel: 'microsoft/microsoft-decision-1',
|
|
108
|
-
modelOptions: [
|
|
111
|
+
modelOptions: [
|
|
112
|
+
{ value: 'microsoft/microsoft-decision-1', label: 'Microsoft Decision-1 (9b)', aggregateTokenUsageOnly: true },
|
|
113
|
+
],
|
|
109
114
|
credentialNames: OPENROUTER_DEFAULT_CREDENTIAL_NAMES,
|
|
110
115
|
endpoint: OPENROUTER_DECISIONS_ENDPOINT,
|
|
111
116
|
modelPricing: [
|
|
@@ -115,7 +120,7 @@ export const openrouterClassifierProvider = createApiCompatibleClassifierProvide
|
|
|
115
120
|
},
|
|
116
121
|
],
|
|
117
122
|
});
|
|
118
|
-
/** Decisions-specific rates
|
|
123
|
+
/** Decisions-specific rates; cache reads/writes follow standard Luna ratios (verified 2026-10-30).
|
|
119
124
|
* https://developers.openai.com/api/docs/guides/decisions#pricing-and-availability
|
|
120
125
|
*/
|
|
121
126
|
export const openaiClassifierProvider = createClassifierProvider({
|
|
@@ -125,6 +130,7 @@ export const openaiClassifierProvider = createClassifierProvider({
|
|
|
125
130
|
modelOptions: [{ value: 'gpt-6-luna', label: 'gpt-6-luna' }],
|
|
126
131
|
credentialNames: OPENAI_DEFAULT_CREDENTIAL_NAMES,
|
|
127
132
|
browserExecutionSupported: false,
|
|
133
|
+
cacheTokenUsageSupported: true,
|
|
128
134
|
endpoint: OPENAI_DECISIONS_ENDPOINT,
|
|
129
135
|
supportsImages: (model) => model === 'gpt-6-luna',
|
|
130
136
|
supportsQuestionImages: (model) => model === 'gpt-6-luna',
|
|
@@ -134,7 +140,15 @@ export const openaiClassifierProvider = createClassifierProvider({
|
|
|
134
140
|
pricing: {
|
|
135
141
|
inputPerMillionTokens: 0.1,
|
|
136
142
|
outputPerMillionTokens: 0,
|
|
137
|
-
|
|
143
|
+
cacheReadPerMillionTokens: 0.01,
|
|
144
|
+
cacheWritePerMillionTokens: 0.125,
|
|
145
|
+
longContext: {
|
|
146
|
+
aboveInputTokens: 272_000,
|
|
147
|
+
inputPerMillionTokens: 0.2,
|
|
148
|
+
outputPerMillionTokens: 0,
|
|
149
|
+
cacheReadPerMillionTokens: 0.02,
|
|
150
|
+
cacheWritePerMillionTokens: 0.25,
|
|
151
|
+
},
|
|
138
152
|
},
|
|
139
153
|
},
|
|
140
154
|
],
|
|
@@ -146,7 +160,11 @@ export const perplexityClassifierProvider = createClassifierProvider({
|
|
|
146
160
|
id: 'perplexity',
|
|
147
161
|
label: 'Perplexity',
|
|
148
162
|
defaultModel: 'pplx-decider-v1.1-27b',
|
|
149
|
-
modelOptions: PERPLEXITY_DECISION_MODELS.map((value) => ({
|
|
163
|
+
modelOptions: PERPLEXITY_DECISION_MODELS.map((value) => ({
|
|
164
|
+
value,
|
|
165
|
+
label: value.replace(/-27b$/, ' (27b)'),
|
|
166
|
+
aggregateTokenUsageOnly: true,
|
|
167
|
+
})),
|
|
150
168
|
credentialNames: PERPLEXITY_DEFAULT_CREDENTIAL_NAMES,
|
|
151
169
|
browserExecutionSupported: false,
|
|
152
170
|
endpoint: PERPLEXITY_DECISIONS_ENDPOINT,
|
|
@@ -172,7 +190,7 @@ export const subqClassifierProvider = createClassifierProvider({
|
|
|
172
190
|
id: 'subq',
|
|
173
191
|
label: 'SubQ',
|
|
174
192
|
defaultModel: 'subq-snap-1.1',
|
|
175
|
-
modelOptions: SUBQ_DECISION_MODELS.map((value) => ({ value, label: value })),
|
|
193
|
+
modelOptions: SUBQ_DECISION_MODELS.map((value) => ({ value, label: value, aggregateTokenUsageOnly: true })),
|
|
176
194
|
credentialNames: SUBQ_DEFAULT_CREDENTIAL_NAMES,
|
|
177
195
|
browserExecutionSupported: false,
|
|
178
196
|
endpoint: SUBQ_DECISIONS_ENDPOINT,
|
|
@@ -193,8 +211,9 @@ export const basetenClassifierProvider = createClassifierProvider({
|
|
|
193
211
|
label: 'Baseten',
|
|
194
212
|
defaultModel: BASETEN_DECISION_MODELS[0],
|
|
195
213
|
modelOptions: [
|
|
196
|
-
{ value: BASETEN_DECISION_MODELS[0], label: 'Elephant-1' },
|
|
197
|
-
{ value: BASETEN_DECISION_MODELS[1], label: 'Mammoth-1' },
|
|
214
|
+
{ value: BASETEN_DECISION_MODELS[0], label: 'Elephant-1 (9b)', aggregateTokenUsageOnly: true },
|
|
215
|
+
{ value: BASETEN_DECISION_MODELS[1], label: 'Mammoth-1 (27b)', aggregateTokenUsageOnly: true },
|
|
216
|
+
{ value: BASETEN_DECISION_MODELS[2], label: 'Joey-1 (2b)', aggregateTokenUsageOnly: true },
|
|
198
217
|
],
|
|
199
218
|
modelHelp: 'Images belong in shared State, not Question Instructions.',
|
|
200
219
|
credentialNames: BASETEN_DEFAULT_CREDENTIAL_NAMES,
|
|
@@ -354,40 +373,46 @@ export function getClassifierProviderEnvironmentVariableNames() {
|
|
|
354
373
|
return [...new Set(classifierProviders.map((provider) => provider.credentialNames.environmentVariableName))];
|
|
355
374
|
}
|
|
356
375
|
/**
|
|
357
|
-
* Returns a USD cost
|
|
358
|
-
*
|
|
376
|
+
* Returns a USD cost for safe non-negative integer token counts using authored
|
|
377
|
+
* rates or a recognized requested/returned model pair. Provider input_tokens already
|
|
359
378
|
* includes billed text/image work across questions; never multiply by question
|
|
360
|
-
* count or add image tokens again.
|
|
379
|
+
* count or add image tokens again. Verified cache reads/writes are input subsets.
|
|
361
380
|
* Callers must not treat an unpriced provider as free.
|
|
362
381
|
*/
|
|
363
382
|
export function calculateClassifierUsageCost(provider, usage, models, tokenPricing) {
|
|
383
|
+
let inputTokenDetails;
|
|
384
|
+
if (provider.cacheTokenUsageSupported && usage.input_tokens_details !== undefined) {
|
|
385
|
+
const details = usage.input_tokens_details;
|
|
386
|
+
// A reported breakdown must be complete; missing counters are not known zeros.
|
|
387
|
+
if (details === null ||
|
|
388
|
+
typeof details !== 'object' ||
|
|
389
|
+
Array.isArray(details) ||
|
|
390
|
+
!isReportedTokenCount(details.cached_tokens) ||
|
|
391
|
+
!isReportedTokenCount(details.cache_write_tokens))
|
|
392
|
+
return undefined;
|
|
393
|
+
inputTokenDetails = { cacheReadTokens: details.cached_tokens, cacheWriteTokens: details.cache_write_tokens };
|
|
394
|
+
}
|
|
395
|
+
const reportedUsage = { inputTokens: usage.input_tokens, outputTokens: usage.output_tokens, inputTokenDetails };
|
|
364
396
|
if (tokenPricing !== undefined)
|
|
365
|
-
return calculateTokenUsageCost(tokenPricing,
|
|
366
|
-
inputTokens: usage.input_tokens,
|
|
367
|
-
outputTokens: usage.output_tokens,
|
|
368
|
-
});
|
|
397
|
+
return calculateTokenUsageCost(tokenPricing, reportedUsage);
|
|
369
398
|
if (!models)
|
|
370
399
|
return undefined;
|
|
371
400
|
const entries = normalizeModelPricing(provider);
|
|
372
401
|
const entry = entries.find(({ models: names }) => names.includes(models.requestedModel) && names.includes(models.responseModel));
|
|
373
402
|
const base = entry?.pricing;
|
|
374
403
|
const tier = base?.longContext;
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
!isReportedTokenCount(usage.input_tokens) ||
|
|
384
|
-
!isReportedTokenCount(usage.output_tokens)) {
|
|
404
|
+
if (base == null || (tier != null && !isReportedTokenCount(tier.aboveInputTokens)))
|
|
405
|
+
return undefined;
|
|
406
|
+
try {
|
|
407
|
+
validateTokenPricing(base);
|
|
408
|
+
if (tier != null)
|
|
409
|
+
validateTokenPricing(tier);
|
|
410
|
+
}
|
|
411
|
+
catch {
|
|
385
412
|
return undefined;
|
|
386
413
|
}
|
|
387
414
|
const pricing = tier && usage.input_tokens > tier.aboveInputTokens ? tier : base;
|
|
388
|
-
|
|
389
|
-
TOKENS_PER_MILLION;
|
|
390
|
-
return Number.isFinite(totalCost) && totalCost >= 0 ? totalCost : undefined;
|
|
415
|
+
return calculateTokenUsageCost(pricing, reportedUsage);
|
|
391
416
|
}
|
|
392
417
|
async function callClassifierHttp(args, spec, prepared, buildRequest, operation) {
|
|
393
418
|
const { apiKey, fetchImplementation, retryOnNon200, retryOnNon200CooldownMs, retryOnNon200RepeatTimes } = args;
|
|
@@ -26,6 +26,7 @@ export type GraphBoundaryCache = WeakMap<NodeGraph, GraphBoundary>;
|
|
|
26
26
|
export declare function getGraphBoundary(project: Project, graphId: GraphId | undefined, cache?: GraphBoundaryCache): GraphBoundary | undefined;
|
|
27
27
|
export declare function applyGraphBoundaryPortOrder<T extends {
|
|
28
28
|
id: string;
|
|
29
|
+
portId?: string;
|
|
29
30
|
}>(boundaryItems: readonly T[], portOrder: readonly string[] | undefined): T[];
|
|
30
31
|
export declare function getGraphBoundaryInputDefinitions(boundary: GraphBoundary, inputPortOrder?: readonly string[]): NodeInputDefinition[];
|
|
31
32
|
export declare function getGraphBoundaryOutputDefinitions(boundary: GraphBoundary, outputPortOrder?: readonly string[]): NodeOutputDefinition[];
|
|
@@ -32,6 +32,8 @@ export type LatestDebuggerSessionMessage = {
|
|
|
32
32
|
channel: LatestDebuggerChannel;
|
|
33
33
|
channelIsolation: true;
|
|
34
34
|
runScopedControls: true;
|
|
35
|
+
/** Per-origin event positions, bounded by the shared retained-event limit. */
|
|
36
|
+
historyThrough?: string[];
|
|
35
37
|
};
|
|
36
38
|
};
|
|
37
39
|
export type LatestDebuggerControlMessage = {
|
|
@@ -75,6 +77,8 @@ export type LatestDebuggerProcessMessage = {
|
|
|
75
77
|
}[keyof ProcessEventMessageMap];
|
|
76
78
|
export type LatestDebuggerExecutionMessage = (LatestDebuggerProcessMessage | LatestDebuggerLifecycleMessage) & {
|
|
77
79
|
rivetEventId?: string;
|
|
80
|
+
/** Browser delivery only: local subscription history, or recovered peer history of unproven newness. */
|
|
81
|
+
rivetHistory?: true | 'peer';
|
|
78
82
|
};
|
|
79
83
|
declare const diagnosticCodes: readonly ["history-truncated", "history-gap", "event-too-large", "owner-unavailable"];
|
|
80
84
|
export type LatestDebuggerDiagnosticCode = (typeof diagnosticCodes)[number];
|
|
@@ -90,8 +94,8 @@ export type LatestDebuggerMessage = LatestDebuggerServerMessage | LatestDebugger
|
|
|
90
94
|
export declare const LATEST_DEBUGGER_PATH = "/ws/latest-debugger";
|
|
91
95
|
export declare function isLatestDebuggerExecutionMessage(message: string): boolean;
|
|
92
96
|
/** Preserve historical writer ordering while readers accept arbitrary JSON ordering. */
|
|
93
|
-
export declare function encodeLatestDebuggerEnvelope(serialized: string, scope?: LatestDebuggerScope, eventId?: string): string;
|
|
94
|
-
export declare function createLatestDebuggerSession(channel: LatestDebuggerChannel): LatestDebuggerSessionMessage;
|
|
97
|
+
export declare function encodeLatestDebuggerEnvelope(serialized: string, scope?: LatestDebuggerScope, eventId?: string, history?: boolean | 'peer'): string;
|
|
98
|
+
export declare function createLatestDebuggerSession(channel: LatestDebuggerChannel, historyThrough?: string[]): LatestDebuggerSessionMessage;
|
|
95
99
|
export declare function isLatestDebuggerSession(value: unknown): value is LatestDebuggerSessionMessage;
|
|
96
100
|
/** Validate the routing contract only. Authored data and decoded sentinels stay intact. */
|
|
97
101
|
export declare function readLatestDebuggerExecution(value: unknown): LatestDebuggerExecutionMessage | undefined;
|
|
@@ -101,6 +105,10 @@ export declare function createLatestDebuggerControlResult(commandId: string, res
|
|
|
101
105
|
/** Validate only the wire control contract, never authored graph payloads. */
|
|
102
106
|
export declare function readLatestDebuggerControl(value: unknown): LatestDebuggerControlMessage | undefined;
|
|
103
107
|
export declare function readLatestDebuggerEventId(value: unknown): string | undefined;
|
|
108
|
+
export declare function readLatestDebuggerEventPosition(value: unknown): {
|
|
109
|
+
origin: string;
|
|
110
|
+
sequence: number;
|
|
111
|
+
} | undefined;
|
|
104
112
|
export declare function isLatestDebuggerControlResult(value: unknown): value is LatestDebuggerControlResultMessage;
|
|
105
113
|
/** Input is a decoded single path segment. Never decode it again. */
|
|
106
114
|
export declare function parseLatestEndpointSegment(segment: string): {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PreparedClassifierEvaluation } from './providers.js';
|
|
2
2
|
import type { PreparedClassifierState } from './state.js';
|
|
3
|
-
/** Native Model API slugs, not Hugging Face or gateway IDs. Verified 2026-10-
|
|
4
|
-
export declare const BASETEN_DECISION_MODELS: readonly ["decision-models/baseten-elephant-9b-latest", "decision-models/baseten-mammoth-27b-latest"];
|
|
3
|
+
/** Native Model API slugs, not Hugging Face or gateway IDs. Verified 2026-10-30. */
|
|
4
|
+
export declare const BASETEN_DECISION_MODELS: readonly ["decision-models/baseten-elephant-9b-latest", "decision-models/baseten-mammoth-27b-latest", "decision-models/baseten-joey-2b-latest"];
|
|
5
5
|
/** Baseten uses inline user-message image parts, never top-level images/placeholders. */
|
|
6
6
|
export declare function basetenDecisionState(state: PreparedClassifierState): unknown;
|
|
7
7
|
/** https://docs.baseten.co/reference/inference-api/system-one */
|
|
@@ -32,11 +32,15 @@ export type ClassifierProvider = {
|
|
|
32
32
|
modelOptions?: readonly {
|
|
33
33
|
value: string;
|
|
34
34
|
label: string;
|
|
35
|
+
/** UI notice for this verified model's upstream usage contract; absent means no claim. */
|
|
36
|
+
aggregateTokenUsageOnly?: boolean;
|
|
35
37
|
}[];
|
|
36
38
|
/** Provider-owned model guidance shared by inline and Profile editors. */
|
|
37
39
|
modelHelp?: string;
|
|
38
40
|
credentialNames: ClassifierCredentialNames;
|
|
39
41
|
browserExecutionSupported: boolean;
|
|
42
|
+
/** Opt in only for a verified native input_tokens_details cache contract. */
|
|
43
|
+
cacheTokenUsageSupported?: boolean;
|
|
40
44
|
supportsImages?: (model: string) => boolean;
|
|
41
45
|
supportsQuestionImages?: (model: string) => boolean;
|
|
42
46
|
supportsBoxQuestions?: (model: string) => boolean;
|
|
@@ -54,14 +58,10 @@ export type ClassifierProvider = {
|
|
|
54
58
|
/** Graph entry uses the same runner without normalizing/copying State twice. */
|
|
55
59
|
evaluateInput?(args: ClassifierProviderEvaluateArgs): Promise<ClassifierProviderEvaluationResult>;
|
|
56
60
|
};
|
|
57
|
-
export type ClassifierTokenPricing = {
|
|
58
|
-
inputPerMillionTokens: number;
|
|
59
|
-
outputPerMillionTokens: number;
|
|
61
|
+
export type ClassifierTokenPricing = TokenPricing & {
|
|
60
62
|
/** The full request uses these rates above the documented context threshold. */
|
|
61
|
-
longContext?: {
|
|
63
|
+
longContext?: TokenPricing & {
|
|
62
64
|
aboveInputTokens: number;
|
|
63
|
-
inputPerMillionTokens: number;
|
|
64
|
-
outputPerMillionTokens: number;
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
67
|
export type ClassifierModelPricing = {
|
|
@@ -151,7 +151,7 @@ export declare const liquidClassifierProvider: ClassifierProvider;
|
|
|
151
151
|
* https://openrouter.ai/microsoft/microsoft-decision-1
|
|
152
152
|
*/
|
|
153
153
|
export declare const openrouterClassifierProvider: ClassifierProvider;
|
|
154
|
-
/** Decisions-specific rates
|
|
154
|
+
/** Decisions-specific rates; cache reads/writes follow standard Luna ratios (verified 2026-10-30).
|
|
155
155
|
* https://developers.openai.com/api/docs/guides/decisions#pricing-and-availability
|
|
156
156
|
*/
|
|
157
157
|
export declare const openaiClassifierProvider: ClassifierProvider;
|
|
@@ -177,13 +177,13 @@ export declare function getClassifierSystemTokenPricing(providerId: string | und
|
|
|
177
177
|
export declare function getClassifierProvider(id: string | undefined): ClassifierProvider;
|
|
178
178
|
export declare function getClassifierProviderEnvironmentVariableNames(): string[];
|
|
179
179
|
/**
|
|
180
|
-
* Returns a USD cost
|
|
181
|
-
*
|
|
180
|
+
* Returns a USD cost for safe non-negative integer token counts using authored
|
|
181
|
+
* rates or a recognized requested/returned model pair. Provider input_tokens already
|
|
182
182
|
* includes billed text/image work across questions; never multiply by question
|
|
183
|
-
* count or add image tokens again.
|
|
183
|
+
* count or add image tokens again. Verified cache reads/writes are input subsets.
|
|
184
184
|
* Callers must not treat an unpriced provider as free.
|
|
185
185
|
*/
|
|
186
|
-
export declare function calculateClassifierUsageCost(provider: Pick<ClassifierProvider, 'pricing' | 'modelPricing'> & Partial<Pick<ClassifierProvider, 'defaultModel'>>, usage: ClassifierEvaluationResponse['usage'], models?: {
|
|
186
|
+
export declare function calculateClassifierUsageCost(provider: Pick<ClassifierProvider, 'pricing' | 'modelPricing'> & Partial<Pick<ClassifierProvider, 'defaultModel' | 'cacheTokenUsageSupported'>>, usage: ClassifierEvaluationResponse['usage'], models?: {
|
|
187
187
|
requestedModel: string;
|
|
188
188
|
responseModel: string;
|
|
189
189
|
}, tokenPricing?: TokenPricing): number | undefined;
|
|
@@ -72,5 +72,10 @@ export type ClassifierEvaluationResponse = {
|
|
|
72
72
|
usage: {
|
|
73
73
|
input_tokens: number;
|
|
74
74
|
output_tokens: number;
|
|
75
|
+
/** OpenAI's native cache counts are subsets of input_tokens, not additional tokens. */
|
|
76
|
+
input_tokens_details?: {
|
|
77
|
+
cached_tokens?: number;
|
|
78
|
+
cache_write_tokens?: number;
|
|
79
|
+
};
|
|
75
80
|
};
|
|
76
81
|
};
|