@valerypopoff/rivet2-core 2.22.1 → 2.25.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 +1438 -824
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/interpolationRuntime.cjs +23 -0
- package/dist/cjs/interpolationRuntime.cjs.map +3 -3
- package/dist/cjs/serialization.cjs +1 -0
- package/dist/cjs/serialization.cjs.map +2 -2
- package/dist/cjs/webAppRuntime.cjs +4 -1
- package/dist/cjs/webAppRuntime.cjs.map +2 -2
- package/dist/esm/exports.js +3 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/integrations/CodeRunner.js +6 -3
- package/dist/esm/integrations/CodeRunnerNamespace.js +10 -0
- package/dist/esm/model/AgentResponseTracePresentation.js +5 -1
- package/dist/esm/model/ChildInvocationOwnership.js +51 -0
- package/dist/esm/model/DatasetOwnership.js +9 -0
- package/dist/esm/model/GraphExecutionState.js +3 -0
- package/dist/esm/model/GraphProcessor.js +94 -55
- package/dist/esm/model/NodeRegistration.js +2 -6
- package/dist/esm/model/RunCostLedger.js +58 -0
- package/dist/esm/model/chat-v2/chatV2CallObserver.js +2 -2
- package/dist/esm/model/chat-v2/chatV2Outputs.js +1 -1
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +5 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +3 -0
- package/dist/esm/model/chat-v2/llmModelCandidate.js +3 -0
- package/dist/esm/model/chat-v2/llmProfile.js +2 -0
- package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +1 -0
- package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +2 -1
- package/dist/esm/model/chat-v2/modelRegistry.js +12 -3
- package/dist/esm/model/classifier/baseten.js +78 -0
- package/dist/esm/model/classifier/credentials.js +17 -9
- package/dist/esm/model/classifier/images.js +4 -4
- package/dist/esm/model/classifier/jev.js +45 -0
- package/dist/esm/model/classifier/json.js +1 -1
- package/dist/esm/model/classifier/limits.js +13 -13
- package/dist/esm/model/classifier/openai.js +20 -2
- package/dist/esm/model/classifier/preparation.js +5 -5
- package/dist/esm/model/classifier/profile.js +24 -15
- package/dist/esm/model/classifier/profileExecution.js +28 -24
- package/dist/esm/model/classifier/providers.js +194 -87
- package/dist/esm/model/classifier/questionHelpers.js +21 -2
- package/dist/esm/model/classifier/questions.js +37 -7
- package/dist/esm/model/classifier/response.js +8 -2
- package/dist/esm/model/classifier/state.js +2 -2
- package/dist/esm/model/classifier/subq.js +51 -0
- package/dist/esm/model/nodes/ClassifierEvaluateNode.js +48 -66
- package/dist/esm/model/nodes/ClassifierProfileNode.js +11 -9
- package/dist/esm/model/nodes/ClassifierQuestionNode.js +53 -34
- package/dist/esm/model/tokenPricing.js +52 -0
- package/dist/esm/model/tokenPricingEditor.js +9 -0
- package/dist/types/exports.d.ts +3 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/integrations/CodeRunner.d.ts +4 -1
- package/dist/types/integrations/CodeRunnerNamespace.d.ts +5 -0
- package/dist/types/model/AgentResponseTracePresentation.d.ts +2 -0
- package/dist/types/model/ChildInvocationOwnership.d.ts +36 -0
- package/dist/types/model/DatasetOwnership.d.ts +5 -0
- package/dist/types/model/GraphExecutionState.d.ts +2 -0
- package/dist/types/model/GraphProcessor.d.ts +3 -0
- package/dist/types/model/RunCostLedger.d.ts +19 -0
- package/dist/types/model/chat-v2/chatV2Outputs.d.ts +1 -1
- package/dist/types/model/chat-v2/chatV2Types.d.ts +2 -0
- package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +3 -1
- package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +7 -5
- package/dist/types/model/chat-v2/modelRegistry.d.ts +7 -1
- package/dist/types/model/classifier/baseten.d.ts +8 -0
- package/dist/types/model/classifier/credentials.d.ts +2 -0
- package/dist/types/model/classifier/jev.d.ts +9 -0
- package/dist/types/model/classifier/profile.d.ts +3 -1
- package/dist/types/model/classifier/profileExecution.d.ts +2 -1
- package/dist/types/model/classifier/providers.d.ts +30 -6
- package/dist/types/model/classifier/questionHelpers.d.ts +3 -1
- package/dist/types/model/classifier/questions.d.ts +2 -1
- package/dist/types/model/classifier/state.d.ts +1 -0
- package/dist/types/model/classifier/subq.d.ts +8 -0
- package/dist/types/model/classifier/types.d.ts +9 -2
- package/dist/types/model/nodes/ClassifierEvaluateNode.d.ts +2 -4
- package/dist/types/model/nodes/ClassifierQuestionNode.d.ts +2 -2
- package/dist/types/model/tokenPricing.d.ts +18 -0
- package/dist/types/model/tokenPricingEditor.d.ts +4 -0
- package/package.json +2 -2
|
@@ -3,8 +3,9 @@ import { nodeDefinition } from '../NodeDefinition.js';
|
|
|
3
3
|
import { NodeImpl } from '../NodeImpl.js';
|
|
4
4
|
import { formatNodeBodyMarkdownField, formatNodeBodyMarkdownSeparator, formatNodeBodyMarkdownTextRow, } from '../nodeBodyMarkdown.js';
|
|
5
5
|
import { ClassifierQuestionPreparation } from '../classifier/preparation.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { abbreviate, assertClassifierEntry, assertClassifierInstructions, getCriteriaInputDefinition, getInstructionsInputDefinition, getInterpolationInputDefinitions, getQuestionInputValue, getQuestionInstructionsInput, getStringInput, getStructuredInput, interpolateQuestionText, requireQuestionId, resolveAuthoredClassifierEntry, } from '../classifier/questionHelpers.js';
|
|
7
|
+
import { prepareClassifierQuestion } from '../classifier/questions.js';
|
|
8
|
+
import { ClassifierValueBudget } from '../classifier/limits.js';
|
|
8
9
|
const defaultOptions = () => [
|
|
9
10
|
{ key: '', value: '' },
|
|
10
11
|
{ key: '', value: '' },
|
|
@@ -26,7 +27,7 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
|
|
|
26
27
|
static create() {
|
|
27
28
|
return {
|
|
28
29
|
type: 'classifierQuestion',
|
|
29
|
-
title: '
|
|
30
|
+
title: 'Decision AI Question',
|
|
30
31
|
id: nanoid(),
|
|
31
32
|
visualData: { x: 0, y: 0, width: 280 },
|
|
32
33
|
data: {
|
|
@@ -54,7 +55,7 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
|
|
|
54
55
|
const inputs = [];
|
|
55
56
|
if (data.useInstructionsInput)
|
|
56
57
|
inputs.push(getInstructionsInputDefinition());
|
|
57
|
-
if (data.useCriteriaInput) {
|
|
58
|
+
if (data.questionType !== 'box' && data.useCriteriaInput) {
|
|
58
59
|
inputs.push(getCriteriaInputDefinition(getCriteriaInputTypes(data.questionType)));
|
|
59
60
|
}
|
|
60
61
|
else if (data.questionType === 'noul') {
|
|
@@ -67,7 +68,7 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
|
|
|
67
68
|
const templates = data.useInstructionsInput
|
|
68
69
|
? []
|
|
69
70
|
: getEntryTemplates(data.instructionsType, data.instructions, data.instructionsLines, data.instructionsObjectTemplate);
|
|
70
|
-
if (!data.useCriteriaInput) {
|
|
71
|
+
if (data.questionType !== 'box' && !data.useCriteriaInput) {
|
|
71
72
|
if (data.questionType === 'choice') {
|
|
72
73
|
if (getCriteriaType(data) === 'text')
|
|
73
74
|
templates.push(...(data.options ?? []).map((option) => option.value));
|
|
@@ -106,6 +107,7 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
|
|
|
106
107
|
{ value: 'noul', label: 'Noul' },
|
|
107
108
|
{ value: 'choice', label: 'Choice' },
|
|
108
109
|
{ value: 'score', label: 'Score' },
|
|
110
|
+
{ value: 'box', label: 'Bounding Box' },
|
|
109
111
|
],
|
|
110
112
|
defaultValue: 'choice',
|
|
111
113
|
allowOptionWrap: false,
|
|
@@ -165,7 +167,7 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
|
|
|
165
167
|
type: 'group',
|
|
166
168
|
label: 'Criteria',
|
|
167
169
|
presentation: 'section',
|
|
168
|
-
hideIf: (data) => data.questionType === 'noul' && Boolean(data.useCriteriaInput),
|
|
170
|
+
hideIf: (data) => data.questionType === 'box' || (data.questionType === 'noul' && Boolean(data.useCriteriaInput)),
|
|
169
171
|
editors: [
|
|
170
172
|
{
|
|
171
173
|
type: 'dropdown',
|
|
@@ -298,10 +300,10 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
|
|
|
298
300
|
}
|
|
299
301
|
static getUIData() {
|
|
300
302
|
return {
|
|
301
|
-
contextMenuTitle: '
|
|
302
|
-
infoBoxTitle: '
|
|
303
|
-
infoBoxBody: 'Builds one typed
|
|
304
|
-
group: ['
|
|
303
|
+
contextMenuTitle: 'Decision AI Question',
|
|
304
|
+
infoBoxTitle: 'Decision AI Question',
|
|
305
|
+
infoBoxBody: 'Builds one typed Decision AI question without making a network request.',
|
|
306
|
+
group: ['Decision AI'],
|
|
305
307
|
};
|
|
306
308
|
}
|
|
307
309
|
async process(inputs, context) {
|
|
@@ -309,7 +311,9 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
|
|
|
309
311
|
const data = this.data;
|
|
310
312
|
preparation.capture(data.questionId);
|
|
311
313
|
// Reject impossible cardinalities before resolving even Instructions.
|
|
312
|
-
const criteria = data.
|
|
314
|
+
const criteria = data.questionType !== 'box' && data.useCriteriaInput
|
|
315
|
+
? getQuestionInputValue(inputs, 'criteria', 'Criteria')
|
|
316
|
+
: undefined;
|
|
313
317
|
if (data.questionType === 'score') {
|
|
314
318
|
const count = data.useCriteriaInput
|
|
315
319
|
? Array.isArray(criteria)
|
|
@@ -330,26 +334,32 @@ export class ClassifierQuestionNodeImpl extends NodeImpl {
|
|
|
330
334
|
if (count < 2 || count > 255)
|
|
331
335
|
throw new Error('Choice questions require 2 to 255 options.');
|
|
332
336
|
}
|
|
333
|
-
if (data.useInstructionsInput)
|
|
334
|
-
preparation.capture(getQuestionInputValue(inputs, 'instructions', 'Instructions'));
|
|
335
337
|
const questionId = requireQuestionId(data.questionId);
|
|
336
|
-
const
|
|
337
|
-
?
|
|
338
|
-
:
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
338
|
+
const instructionInput = data.useInstructionsInput
|
|
339
|
+
? getQuestionInstructionsInput(inputs, preparation)
|
|
340
|
+
: {
|
|
341
|
+
instructions: resolveAuthoredClassifierEntry({
|
|
342
|
+
type: data.instructionsType,
|
|
343
|
+
text: data.instructions,
|
|
344
|
+
lines: data.instructionsLines,
|
|
345
|
+
objectTemplate: data.instructionsObjectTemplate,
|
|
346
|
+
inputs,
|
|
347
|
+
context,
|
|
348
|
+
label: 'Instructions',
|
|
349
|
+
preparation,
|
|
350
|
+
}),
|
|
351
|
+
};
|
|
352
|
+
const { instructions } = instructionInput;
|
|
353
|
+
if (data.useInstructionsInput)
|
|
354
|
+
preparation.capture(instructionInput);
|
|
355
|
+
if (!instructionInput.instructionsMessages)
|
|
356
|
+
assertClassifierInstructions(instructions);
|
|
349
357
|
const question = createQuestionDefinition(data, inputs, context, questionId, instructions, preparation);
|
|
350
|
-
|
|
358
|
+
if (instructionInput.instructionsMessages)
|
|
359
|
+
question.instructionsMessages = instructionInput.instructionsMessages;
|
|
360
|
+
const prepared = prepareClassifierQuestion(question, new ClassifierValueBudget(preparation.check));
|
|
351
361
|
preparation.check();
|
|
352
|
-
return { ['question']: { type: 'object', value:
|
|
362
|
+
return { ['question']: { type: 'object', value: prepared } };
|
|
353
363
|
}
|
|
354
364
|
}
|
|
355
365
|
function getCriteriaInputTypes(questionType) {
|
|
@@ -366,10 +376,12 @@ function getNoulCriteriaInputDefinition(id, title, criteriaType) {
|
|
|
366
376
|
};
|
|
367
377
|
}
|
|
368
378
|
function getQuestionTypeLabel(questionType) {
|
|
379
|
+
if (questionType === 'box')
|
|
380
|
+
return 'Bounding Box';
|
|
369
381
|
return questionType === 'noul' ? 'Noul' : questionType[0].toUpperCase() + questionType.slice(1);
|
|
370
382
|
}
|
|
371
383
|
/**
|
|
372
|
-
* Shared presentation model for the app's
|
|
384
|
+
* Shared presentation model for the app's Decision AI card. Keep this data-only
|
|
373
385
|
* so the Core Markdown fallback and the app's LLM-style React body cannot
|
|
374
386
|
* disagree about what a saved question represents.
|
|
375
387
|
*/
|
|
@@ -384,10 +396,15 @@ export function getClassifierQuestionBodySections(data) {
|
|
|
384
396
|
],
|
|
385
397
|
},
|
|
386
398
|
instructions,
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
399
|
+
data.questionType === 'box'
|
|
400
|
+
? {
|
|
401
|
+
id: 'capability',
|
|
402
|
+
fields: [{ label: 'Requires', value: 'Jev 1.14 and an image (experimental)' }],
|
|
403
|
+
}
|
|
404
|
+
: {
|
|
405
|
+
id: 'criteria',
|
|
406
|
+
fields: [{ label: 'Criteria', value: data.useCriteriaInput ? 'input' : getCriteriaSummary(data) }],
|
|
407
|
+
},
|
|
391
408
|
];
|
|
392
409
|
}
|
|
393
410
|
function getCriteriaSummary(data) {
|
|
@@ -414,6 +431,8 @@ function getInstructionsBodySection(data) {
|
|
|
414
431
|
return { id: 'instructions', fields: [], summary: abbreviate(data.instructions) || '(required)' };
|
|
415
432
|
}
|
|
416
433
|
function createQuestionDefinition(data, inputs, context, questionId, instructions, preparation) {
|
|
434
|
+
if (data.questionType === 'box')
|
|
435
|
+
return { questionId, type: 'box', instructions };
|
|
417
436
|
if (data.questionType === 'choice') {
|
|
418
437
|
return createChoiceQuestion(data, inputs, context, questionId, instructions, preparation);
|
|
419
438
|
}
|
|
@@ -610,4 +629,4 @@ function hasClassifierCriteriaValue(value) {
|
|
|
610
629
|
return true;
|
|
611
630
|
return Object.keys(value).length > 0;
|
|
612
631
|
}
|
|
613
|
-
export const classifierQuestionNode = nodeDefinition(ClassifierQuestionNodeImpl, '
|
|
632
|
+
export const classifierQuestionNode = nodeDefinition(ClassifierQuestionNodeImpl, 'Decision AI Question');
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Provider token counts must be exact, nonnegative integers before applying rates. */
|
|
2
|
+
export function isReportedTokenCount(value) {
|
|
3
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
|
|
4
|
+
}
|
|
5
|
+
export function validateTokenPricing(value) {
|
|
6
|
+
if (value === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
9
|
+
throw new Error('Token pricing override must be an object.');
|
|
10
|
+
const result = {};
|
|
11
|
+
for (const key of [
|
|
12
|
+
'inputPerMillionTokens',
|
|
13
|
+
'outputPerMillionTokens',
|
|
14
|
+
'cacheReadPerMillionTokens',
|
|
15
|
+
'cacheWritePerMillionTokens',
|
|
16
|
+
]) {
|
|
17
|
+
const rate = value[key];
|
|
18
|
+
if (rate === undefined && key.startsWith('cache'))
|
|
19
|
+
continue;
|
|
20
|
+
if (typeof rate !== 'number' || !Number.isFinite(rate) || rate < 0)
|
|
21
|
+
throw new Error(`Token pricing ${key} must be a finite, non-negative USD rate.`);
|
|
22
|
+
result[key] = rate;
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
export function calculateTokenUsageCost(pricing, usage) {
|
|
27
|
+
try {
|
|
28
|
+
const validated = validateTokenPricing(pricing);
|
|
29
|
+
if (!validated)
|
|
30
|
+
return undefined;
|
|
31
|
+
pricing = validated;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const { inputTokens, outputTokens, inputTokenDetails } = usage ?? {};
|
|
37
|
+
const read = inputTokenDetails?.cacheReadTokens === undefined ? 0 : inputTokenDetails.cacheReadTokens;
|
|
38
|
+
const write = inputTokenDetails?.cacheWriteTokens === undefined ? 0 : inputTokenDetails.cacheWriteTokens;
|
|
39
|
+
if (!isReportedTokenCount(inputTokens) ||
|
|
40
|
+
!isReportedTokenCount(outputTokens) ||
|
|
41
|
+
!isReportedTokenCount(read) ||
|
|
42
|
+
!isReportedTokenCount(write))
|
|
43
|
+
return undefined;
|
|
44
|
+
if (read + write > inputTokens)
|
|
45
|
+
return undefined;
|
|
46
|
+
const total = ((inputTokens - read - write) * pricing.inputPerMillionTokens +
|
|
47
|
+
read * (pricing.cacheReadPerMillionTokens ?? pricing.inputPerMillionTokens) +
|
|
48
|
+
write * (pricing.cacheWritePerMillionTokens ?? pricing.inputPerMillionTokens) +
|
|
49
|
+
outputTokens * pricing.outputPerMillionTokens) /
|
|
50
|
+
1_000_000;
|
|
51
|
+
return Number.isFinite(total) && total >= 0 ? total : undefined;
|
|
52
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Shared settings section for inline configurations and separate profile nodes. */
|
|
2
|
+
export function getTokenPricingEditor() {
|
|
3
|
+
return {
|
|
4
|
+
type: 'group',
|
|
5
|
+
label: 'Token pricing',
|
|
6
|
+
defaultOpen: false,
|
|
7
|
+
editors: [{ type: 'custom', label: 'Token pricing', customEditorId: 'AIProfilePricing' }],
|
|
8
|
+
};
|
|
9
|
+
}
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export * from './plugins.js';
|
|
|
60
60
|
export * from './model/classifier/credentials.js';
|
|
61
61
|
export * from './model/classifier/migration.js';
|
|
62
62
|
export * from './model/classifier/providers.js';
|
|
63
|
+
export * from './model/tokenPricing.js';
|
|
64
|
+
export { getChatV2SystemTokenPricing } from './model/chat-v2/modelRegistry.js';
|
|
63
65
|
export * from './model/classifier/types.js';
|
|
64
66
|
export * from './model/NodeRegistration.js';
|
|
65
67
|
export * from './model/RegistryAssembly.js';
|
|
@@ -69,6 +71,7 @@ export * from './model/NodeBodySpec.js';
|
|
|
69
71
|
export * from './model/interpolationInputDefinition.js';
|
|
70
72
|
export * from './integrations/DatasetProvider.js';
|
|
71
73
|
export * from './model/Dataset.js';
|
|
74
|
+
export { remapOwnedDatasets } from './model/DatasetOwnership.js';
|
|
72
75
|
export type { DatasetRequestMap, DatasetRequestMessage, DatasetRequestPayload, CodeConsoleLevel, CodeConsoleMessage, GraphUploadAllowedMessage, IncomingMessage, OutgoingMessage, OutgoingMessageMap, ProcessEventMessage, ProcessEventMessageMap, RemoteRunRequestId, SerializedProcessEventMap, } from './model/ExecutorProtocol.js';
|
|
73
76
|
export * from './api/streaming.js';
|
|
74
77
|
export * from './api/createProcessor.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { Inputs, Outputs } from '../
|
|
1
|
+
import type { NodeInputs as Inputs, NodeOutputs as Outputs } from '../model/NodeIO.js';
|
|
2
2
|
import type { DataValue } from '../model/DataValue.js';
|
|
3
3
|
import type { CodeRunnerOptions } from './CodeRunnerOptions.js';
|
|
4
|
+
import { type CodeRunnerNamespace } from './CodeRunnerNamespace.js';
|
|
4
5
|
export { ALL_CODE_RUNNER_OPTIONS } from './CodeRunnerOptions.js';
|
|
5
6
|
export type { CodeRunnerOptions } from './CodeRunnerOptions.js';
|
|
6
7
|
/**
|
|
@@ -15,6 +16,8 @@ export interface CodeRunner {
|
|
|
15
16
|
runCode: (code: string, inputs: Inputs, options: CodeRunnerOptions, graphInputs?: Record<string, DataValue>, contextValues?: Record<string, DataValue>, globalValues?: Record<string, DataValue>) => Promise<Outputs>;
|
|
16
17
|
}
|
|
17
18
|
export declare class IsomorphicCodeRunner implements CodeRunner {
|
|
19
|
+
private readonly resolveNamespace;
|
|
20
|
+
constructor(resolveNamespace?: () => CodeRunnerNamespace);
|
|
18
21
|
runCode(code: string, inputs: Inputs, options: CodeRunnerOptions, graphInputs?: Record<string, DataValue>, contextValues?: Record<string, DataValue>, globalValues?: Record<string, DataValue>): Promise<Outputs>;
|
|
19
22
|
}
|
|
20
23
|
export declare class NotAllowedCodeRunner implements CodeRunner {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type * as PublicNamespace from '../exports.js';
|
|
2
|
+
/** Installed by the public package entrypoint, not by the execution engine. */
|
|
3
|
+
export type CodeRunnerNamespace = typeof PublicNamespace;
|
|
4
|
+
export declare function installCodeRunnerNamespace(value: CodeRunnerNamespace): void;
|
|
5
|
+
export declare function getCodeRunnerNamespace(): CodeRunnerNamespace;
|
|
@@ -5,6 +5,8 @@ export type AgentProfileAttemptInspectorRow = Readonly<{
|
|
|
5
5
|
eventId: string;
|
|
6
6
|
providerAndModel: string;
|
|
7
7
|
}>;
|
|
8
|
+
/** Presentation only: family-scoped exact default alias, never a rewrite of authored/recorded names. */
|
|
9
|
+
export declare function getProfileDisplayName(name: string | undefined, family: AgentLLMProfileAttemptTrace['family']): string | undefined;
|
|
8
10
|
export declare function buildAgentProfileAttemptInspectorRows(attempts: readonly AgentLLMProfileAttemptTrace[]): AgentProfileAttemptInspectorRow[];
|
|
9
11
|
/** Physical classifier requests share profile evidence, not LLM chat-round semantics. */
|
|
10
12
|
export declare function isClassifierRequest(attempt: AgentLLMProfileAttemptTrace): boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { GraphInvocationState } from './GraphExecutionState.js';
|
|
2
|
+
import type { GraphRunId } from './ProcessContext.js';
|
|
3
|
+
type Identity = Pick<GraphInvocationState, 'rootRunId' | 'graphRunId' | 'parentGraphRunId'>;
|
|
4
|
+
type RunState = Pick<GraphInvocationState, 'attachedNodeData' | 'graphInputNodeValues' | 'graphOutputs'>;
|
|
5
|
+
/** Same-graph branches are not ordinary subgraphs. Their aliasing rules are
|
|
6
|
+
* deliberate: continuations commit overlays, async branches share inputs but
|
|
7
|
+
* never seed parent outputs, and watch snapshots isolate mutable node state. */
|
|
8
|
+
export type ChildInvocationMode = {
|
|
9
|
+
kind: 'continuation';
|
|
10
|
+
graphOutputs: RunState['graphOutputs'];
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'async';
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'watch';
|
|
15
|
+
graphRunId: GraphRunId;
|
|
16
|
+
};
|
|
17
|
+
export declare function resolveChildInvocationOwnership<Owner>(mode: ChildInvocationMode, context: {
|
|
18
|
+
parent: Owner;
|
|
19
|
+
root: Owner;
|
|
20
|
+
abortOwner: Owner;
|
|
21
|
+
sameGraphOwner: Owner;
|
|
22
|
+
rootGraphOrigin: boolean;
|
|
23
|
+
run: RunState & Identity;
|
|
24
|
+
rootIdentity: Identity;
|
|
25
|
+
sameGraphIdentity: Identity;
|
|
26
|
+
newGraphRunId(): GraphRunId;
|
|
27
|
+
}): {
|
|
28
|
+
parent: Owner;
|
|
29
|
+
abortOwner: Owner;
|
|
30
|
+
sameGraphOwner?: Owner;
|
|
31
|
+
suppressPartialOutputs: boolean;
|
|
32
|
+
suppressLifecycle: boolean;
|
|
33
|
+
state: RunState;
|
|
34
|
+
identity: Identity;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ProjectId } from './Project.js';
|
|
2
|
+
import type { CombinedDataset } from '../utils/serialization/serialization.js';
|
|
3
|
+
/** Change only the owner of already validated sidecars. Reference/version
|
|
4
|
+
* rewiring is an operation-specific policy, not part of dataset ownership. */
|
|
5
|
+
export declare function remapOwnedDatasets(datasets: readonly CombinedDataset[], sourceId: ProjectId, targetId: ProjectId): CombinedDataset[];
|
|
@@ -10,6 +10,7 @@ import type { RivetStoredValueController } from './StoredValueStore.js';
|
|
|
10
10
|
import type { KnowledgeStoreController } from '../integrations/KnowledgeStoreProvider.js';
|
|
11
11
|
import type { ResolvedSubgraphProject } from './SubgraphProjectTarget.js';
|
|
12
12
|
import type { GraphCostBreakdown } from './GraphBoundaryEffects.js';
|
|
13
|
+
import { RunCostLedger } from './RunCostLedger.js';
|
|
13
14
|
/** Invocation-owned fields; GraphProcessor resets them at the established initialization boundaries. */
|
|
14
15
|
export declare class GraphInvocationState {
|
|
15
16
|
rootRunId: RootRunId;
|
|
@@ -35,6 +36,7 @@ export declare class GraphInvocationState {
|
|
|
35
36
|
successfulAbortTerminalProcessIds: Set<ProcessId>;
|
|
36
37
|
totalCost: number;
|
|
37
38
|
costBreakdown: GraphCostBreakdown | undefined;
|
|
39
|
+
costLedger: RunCostLedger;
|
|
38
40
|
ignoreNodes: Set<NodeId>;
|
|
39
41
|
hasPreloadedData: boolean;
|
|
40
42
|
loadedProjects: Record<ProjectId, Project>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RunCostSnapshot } from './RunCostLedger.js';
|
|
1
2
|
import { type DataValue, type StringArrayDataValue, type ScalarOrArrayDataValue } from './DataValue.js';
|
|
2
3
|
import type { NodeInputs, NodeOutputs } from './NodeIO.js';
|
|
3
4
|
import { type ChartNode, type NodeConnection, type NodeId } from './NodeBase.js';
|
|
@@ -366,6 +367,8 @@ export declare class GraphProcessor {
|
|
|
366
367
|
graphInputStreams?: Readonly<Record<string, GraphInputStream>>;
|
|
367
368
|
}): Promise<GraphOutputs>;
|
|
368
369
|
getRootProcessor(): GraphProcessor;
|
|
370
|
+
/** Snapshot the root execution's observed provider estimates after completion. */
|
|
371
|
+
getRunCostSnapshot(): RunCostSnapshot;
|
|
369
372
|
/** Raise a user event on the processor, all subprocessors, and their children. */
|
|
370
373
|
raiseEvent(event: string, data: DataValue): void;
|
|
371
374
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ChatV2CallFinishedEvent, LLMProfileAttemptTraceEvent } from './ProcessContext.js';
|
|
2
|
+
/** Run-owned provider estimates. It is not an invoice or a graph output. */
|
|
3
|
+
export type RunCostSnapshot = {
|
|
4
|
+
status: 'complete' | 'partial';
|
|
5
|
+
knownCostUsd: number;
|
|
6
|
+
} | {
|
|
7
|
+
status: 'unknown';
|
|
8
|
+
knownCostUsd: null;
|
|
9
|
+
};
|
|
10
|
+
/** Receives physical-call observations directly, before display/recording filters. */
|
|
11
|
+
export declare class RunCostLedger {
|
|
12
|
+
#private;
|
|
13
|
+
observeChat(event: ChatV2CallFinishedEvent): void;
|
|
14
|
+
observeClassifier(event: LLMProfileAttemptTraceEvent): void;
|
|
15
|
+
/** Legacy Chat does not expose complete per-attempt accounting. */
|
|
16
|
+
observeLegacy(key: string, value: unknown): void;
|
|
17
|
+
markUnobserved(): void;
|
|
18
|
+
snapshot(executionPending?: boolean): RunCostSnapshot;
|
|
19
|
+
}
|
|
@@ -14,7 +14,7 @@ type CreateChatV2CommonOutputsOptions = ChatV2CommonOutputOptions & {
|
|
|
14
14
|
requestBodies?: unknown[] | undefined;
|
|
15
15
|
responseBodies?: unknown[] | undefined;
|
|
16
16
|
};
|
|
17
|
-
export declare function normalizeChatV2Usage(usage: LanguageModelUsage | undefined, options: Pick<RunChatV2PipelineOptions, 'provider' | 'modelId'>, providerMetadata?: Record<string, Record<string, unknown>>): ChatV2NormalizedUsage | undefined;
|
|
17
|
+
export declare function normalizeChatV2Usage(usage: LanguageModelUsage | undefined, options: Pick<RunChatV2PipelineOptions, 'provider' | 'modelId' | 'tokenPricing'>, providerMetadata?: Record<string, Record<string, unknown>>): ChatV2NormalizedUsage | undefined;
|
|
18
18
|
export declare function createChatV2ResponseOutput(response: string, structuredOutput: unknown | undefined, responseFormat: RunChatV2PipelineOptions['responseFormat']): DataValue;
|
|
19
19
|
export declare function createChatV2CapturedBodyOutputs(options: Pick<RunChatV2PipelineOptions, 'requestBodies' | 'responseBodies' | 'outputRequestBody' | 'outputResponseBody'>): Outputs;
|
|
20
20
|
export declare function createChatV2CommonOutputs({ requestMessages, response, structuredOutput, functionCalls, usage, reasoning, requestBodies, responseBodies, outputUsage, outputReasoning, outputRequestBody, outputResponseBody, includeFunctionCalls, functionCallMode, responseFormat, }: CreateChatV2CommonOutputsOptions): Outputs;
|
|
@@ -2,6 +2,7 @@ import type { generateText, streamText, LanguageModelUsage, ModelMessage, TextSt
|
|
|
2
2
|
import type { ChatMessage, GptFunction } from '../DataValue.js';
|
|
3
3
|
import type { Outputs } from '../GraphProcessor.js';
|
|
4
4
|
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
5
|
+
import type { TokenPricing } from '../tokenPricing.js';
|
|
5
6
|
import type { AssistantMessageFunctionCallMode, StreamedFunctionCall } from '../chat/streamChatResponse.js';
|
|
6
7
|
import type { ChatV2Provider } from './chatV2ProviderTypes.js';
|
|
7
8
|
import type { ChatV2ResponseBodyCapture } from './chatV2ResponseBodyCapture.js';
|
|
@@ -134,6 +135,7 @@ export type StreamChatV2Result = {
|
|
|
134
135
|
requestStatus: number | undefined;
|
|
135
136
|
};
|
|
136
137
|
export type RunChatV2PipelineOptions = {
|
|
138
|
+
tokenPricing?: TokenPricing | undefined;
|
|
137
139
|
provider: ChatV2Provider;
|
|
138
140
|
model: ChatV2Model;
|
|
139
141
|
modelId: string;
|
|
@@ -2,6 +2,7 @@ import type { ChatV2ResponseFormat } from './chatV2ResponseFormat.js';
|
|
|
2
2
|
import { type ChatV2CommonNodeData } from './chatV2Shared.js';
|
|
3
3
|
import type { ChatV2Provider } from './chatV2Types.js';
|
|
4
4
|
import type { ChartNode, NodeId } from '../NodeBase.js';
|
|
5
|
+
import type { TokenPricing } from '../tokenPricing.js';
|
|
5
6
|
import type { CustomProviderApi } from './customProviderApi.js';
|
|
6
7
|
import type { ChatV2CredentialNamesByProvider } from './chatV2CredentialNames.js';
|
|
7
8
|
export type { CustomProviderApi } from './customProviderApi.js';
|
|
@@ -9,6 +10,7 @@ export type LLMChatV2ToolChoiceMode = '' | 'auto' | 'function' | 'required';
|
|
|
9
10
|
export type LLMChatV2ApiKeySource = 'environment' | 'input';
|
|
10
11
|
export type LLMChatV2ConfigurationMode = 'inline' | 'profile';
|
|
11
12
|
export type LLMChatV2NodeConfigData = ChatV2CommonNodeData & {
|
|
13
|
+
tokenPricing?: TokenPricing;
|
|
12
14
|
configurationMode?: LLMChatV2ConfigurationMode;
|
|
13
15
|
provider: ChatV2Provider;
|
|
14
16
|
apiKeySource?: LLMChatV2ApiKeySource;
|
|
@@ -75,7 +77,7 @@ export type LLMChatV2NodeConfigData = ChatV2CommonNodeData & {
|
|
|
75
77
|
export type LLMChatV2NodeData = LLMChatV2NodeConfigData;
|
|
76
78
|
export type LLMChatV2Node = ChartNode<'llmChatV2', LLMChatV2NodeData>;
|
|
77
79
|
/** @deprecated Use llmProfileDataKeys from llmProfileFieldRegistry instead. */
|
|
78
|
-
export declare const llmChatV2ProfileDataKeys: ("provider" | "model" | "useModelInput" | "temperature" | "useTemperatureInput" | "topP" | "useTopPInput" | "topK" | "useTopKInput" | "presencePenalty" | "usePresencePenaltyInput" | "frequencyPenalty" | "useFrequencyPenaltyInput" | "stopSequences" | "useStopSequencesInput" | "seed" | "useSeedInput" | "maxTokens" | "useMaxTokensInput" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs")[];
|
|
80
|
+
export declare const llmChatV2ProfileDataKeys: ("provider" | "tokenPricing" | "model" | "useModelInput" | "temperature" | "useTemperatureInput" | "topP" | "useTopPInput" | "topK" | "useTopKInput" | "presencePenalty" | "usePresencePenaltyInput" | "frequencyPenalty" | "useFrequencyPenaltyInput" | "stopSequences" | "useStopSequencesInput" | "seed" | "useSeedInput" | "maxTokens" | "useMaxTokensInput" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs")[];
|
|
79
81
|
export type LLMChatV2ProfileDataKey = (typeof llmChatV2ProfileDataKeys)[number];
|
|
80
82
|
export type LLMChatV2ProfileData = Pick<LLMChatV2NodeData, LLMChatV2ProfileDataKey>;
|
|
81
83
|
export type LLMChatV2EditorCacheKeyParts = {
|
|
@@ -16,6 +16,8 @@ export type LLMProfileFieldSpec = {
|
|
|
16
16
|
resolvedInputToggle?: boolean;
|
|
17
17
|
};
|
|
18
18
|
export declare const llmProfileFieldSpecs: readonly [{
|
|
19
|
+
readonly key: "tokenPricing";
|
|
20
|
+
}, {
|
|
19
21
|
readonly key: "model";
|
|
20
22
|
readonly inputId: "model";
|
|
21
23
|
readonly valueKind: "string";
|
|
@@ -201,12 +203,12 @@ export declare const llmProfileFieldSpecs: readonly [{
|
|
|
201
203
|
readonly key: "circuitBreakerOpenDurationMs";
|
|
202
204
|
readonly valueKind: "required-number";
|
|
203
205
|
}];
|
|
204
|
-
export declare const llmProfileDataKeys: ("provider" | "model" | "useModelInput" | "temperature" | "useTemperatureInput" | "topP" | "useTopPInput" | "topK" | "useTopKInput" | "presencePenalty" | "usePresencePenaltyInput" | "frequencyPenalty" | "useFrequencyPenaltyInput" | "stopSequences" | "useStopSequencesInput" | "seed" | "useSeedInput" | "maxTokens" | "useMaxTokensInput" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs")[];
|
|
206
|
+
export declare const llmProfileDataKeys: ("provider" | "tokenPricing" | "model" | "useModelInput" | "temperature" | "useTemperatureInput" | "topP" | "useTopPInput" | "topK" | "useTopKInput" | "presencePenalty" | "usePresencePenaltyInput" | "frequencyPenalty" | "useFrequencyPenaltyInput" | "stopSequences" | "useStopSequencesInput" | "seed" | "useSeedInput" | "maxTokens" | "useMaxTokensInput" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs")[];
|
|
205
207
|
export declare const llmProfileInputIds: ("model" | "temperature" | "topP" | "topK" | "presencePenalty" | "frequencyPenalty" | "stopSequences" | "seed" | "maxTokens" | "customProviderBaseURL" | "headers" | "extraProviderOptions" | "anthropicThinkingBudget" | "googleThinkingBudget" | "apiKey" | "previousResponseId")[];
|
|
206
208
|
/** Runtime validation categories for resolved LLM Profile values. */
|
|
207
|
-
export declare const llmProfileStringDataKeys: ("provider" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "baseURL" | "useBaseURLInput" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs" | "responseFormat" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | "toolChoice" | "toolChoiceFunction" | "parallelToolCalls" | "autoContinueToolCalls" | "maxToolRounds" | "retryOnNon200" | "errorOnNon200" | "catchRequestFailed" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "outputLLMAttempts" | "outputRequestBody" | "outputResponseBody")[];
|
|
208
|
-
export declare const llmProfileBooleanDataKeys: ("provider" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "baseURL" | "useBaseURLInput" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs" | "responseFormat" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | "toolChoice" | "toolChoiceFunction" | "parallelToolCalls" | "autoContinueToolCalls" | "maxToolRounds" | "retryOnNon200" | "errorOnNon200" | "catchRequestFailed" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "outputLLMAttempts" | "outputRequestBody" | "outputResponseBody")[];
|
|
209
|
-
export declare const llmProfileRequiredNumberDataKeys: ("provider" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "baseURL" | "useBaseURLInput" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs" | "responseFormat" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | "toolChoice" | "toolChoiceFunction" | "parallelToolCalls" | "autoContinueToolCalls" | "maxToolRounds" | "retryOnNon200" | "errorOnNon200" | "catchRequestFailed" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "outputLLMAttempts" | "outputRequestBody" | "outputResponseBody")[];
|
|
210
|
-
export declare const llmProfileOptionalNumberDataKeys: ("provider" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "baseURL" | "useBaseURLInput" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs" | "responseFormat" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | "toolChoice" | "toolChoiceFunction" | "parallelToolCalls" | "autoContinueToolCalls" | "maxToolRounds" | "retryOnNon200" | "errorOnNon200" | "catchRequestFailed" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "outputLLMAttempts" | "outputRequestBody" | "outputResponseBody")[];
|
|
209
|
+
export declare const llmProfileStringDataKeys: ("provider" | "tokenPricing" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "baseURL" | "useBaseURLInput" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs" | "responseFormat" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | "toolChoice" | "toolChoiceFunction" | "parallelToolCalls" | "autoContinueToolCalls" | "maxToolRounds" | "retryOnNon200" | "errorOnNon200" | "catchRequestFailed" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "outputLLMAttempts" | "outputRequestBody" | "outputResponseBody")[];
|
|
210
|
+
export declare const llmProfileBooleanDataKeys: ("provider" | "tokenPricing" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "baseURL" | "useBaseURLInput" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs" | "responseFormat" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | "toolChoice" | "toolChoiceFunction" | "parallelToolCalls" | "autoContinueToolCalls" | "maxToolRounds" | "retryOnNon200" | "errorOnNon200" | "catchRequestFailed" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "outputLLMAttempts" | "outputRequestBody" | "outputResponseBody")[];
|
|
211
|
+
export declare const llmProfileRequiredNumberDataKeys: ("provider" | "tokenPricing" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "baseURL" | "useBaseURLInput" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs" | "responseFormat" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | "toolChoice" | "toolChoiceFunction" | "parallelToolCalls" | "autoContinueToolCalls" | "maxToolRounds" | "retryOnNon200" | "errorOnNon200" | "catchRequestFailed" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "outputLLMAttempts" | "outputRequestBody" | "outputResponseBody")[];
|
|
212
|
+
export declare const llmProfileOptionalNumberDataKeys: ("provider" | "tokenPricing" | keyof import("./chatV2Shared.js").ChatV2CommonNodeData | "configurationMode" | "apiKeySource" | "providerApiKeyNames" | "customProviderApiKeyProgrammaticName" | "customProviderApiKeyEnvVarName" | "customProviderBaseURL" | "useCustomProviderBaseURLInput" | "customProviderApi" | "baseURL" | "useBaseURLInput" | "headers" | "useHeadersInput" | "extraProviderOptions" | "useExtraProviderOptionsInput" | "openAIReasoningEffort" | "openRouterReasoningEffort" | "openAIReasoningSummary" | "openAIPreviousResponseId" | "useOpenAIPreviousResponseIdInput" | "enableOpenAIWebSearch" | "openAIWebSearchContextSize" | "enableOpenAICodeInterpreter" | "anthropicThinkingMode" | "anthropicThinkingBudget" | "useAnthropicThinkingBudgetInput" | "anthropicEffort" | "anthropicCacheControlTtl" | "googleThinkingBudget" | "useGoogleThinkingBudgetInput" | "googleThinkingLevel" | "googleIncludeThoughts" | "enableGoogleSearchGrounding" | "enableGoogleUrlContext" | "enableCircuitBreaker" | "firstOutputTimeoutMs" | "streamInactivityTimeoutMs" | "circuitBreakerFailureThreshold" | "circuitBreakerFailureWindowMs" | "circuitBreakerOpenDurationMs" | "responseFormat" | "responseSchemaName" | "useResponseSchemaNameInput" | "responseSchemaDescription" | "useResponseSchemaDescriptionInput" | "toolChoice" | "toolChoiceFunction" | "parallelToolCalls" | "autoContinueToolCalls" | "maxToolRounds" | "retryOnNon200" | "errorOnNon200" | "catchRequestFailed" | "retryOnNon200RepeatTimes" | "retryOnNon200CooldownMs" | "outputLLMAttempts" | "outputRequestBody" | "outputResponseBody")[];
|
|
211
213
|
/** A serialized profile must be self-contained, not driven by hidden ports. */
|
|
212
214
|
export declare const llmProfileResolvedInputToggleDataKeys: Array<keyof LLMChatV2NodeData>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ChatV2Provider } from './chatV2Types.js';
|
|
2
|
+
import { type TokenPricing } from '../tokenPricing.js';
|
|
2
3
|
export type ChatV2ModelInfo = {
|
|
3
4
|
maxTokens: number;
|
|
4
5
|
displayName: string;
|
|
@@ -9,6 +10,10 @@ export type ChatV2ModelInfo = {
|
|
|
9
10
|
};
|
|
10
11
|
};
|
|
11
12
|
type TokenUsageForCost = {
|
|
13
|
+
inputTokenDetails?: {
|
|
14
|
+
cacheReadTokens?: number | undefined;
|
|
15
|
+
cacheWriteTokens?: number | undefined;
|
|
16
|
+
} | undefined;
|
|
12
17
|
inputTokens?: number | undefined;
|
|
13
18
|
outputTokens?: number | undefined;
|
|
14
19
|
};
|
|
@@ -117,11 +122,12 @@ export declare function getChatV2ModelRegistry(): {
|
|
|
117
122
|
custom: {};
|
|
118
123
|
};
|
|
119
124
|
export declare function getChatV2ModelInfo(provider: ChatV2Provider, modelId: string): ChatV2ModelInfo | undefined;
|
|
125
|
+
export declare function getChatV2SystemTokenPricing(provider: ChatV2Provider, modelId: string): TokenPricing | undefined;
|
|
120
126
|
export declare function calculateChatV2Cost(provider: ChatV2Provider, modelId: string, promptTokens: number, completionTokens: number): number | undefined;
|
|
121
127
|
/**
|
|
122
128
|
* Uses reported OpenRouter cost; estimates other providers only when both
|
|
123
129
|
* billable text-token counts are available. Cache discounts, long-context
|
|
124
130
|
* premiums, and provider tool fees are not modeled in those estimates.
|
|
125
131
|
*/
|
|
126
|
-
export declare function calculateChatV2UsageCost(provider: ChatV2Provider, modelId: string, usage: TokenUsageForCost | undefined, providerMetadata?: Record<string, Record<string, unknown
|
|
132
|
+
export declare function calculateChatV2UsageCost(provider: ChatV2Provider, modelId: string, usage: TokenUsageForCost | undefined, providerMetadata?: Record<string, Record<string, unknown>>, tokenPricing?: TokenPricing): number | undefined;
|
|
127
133
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PreparedClassifierEvaluation } from './providers.js';
|
|
2
|
+
import type { PreparedClassifierState } from './state.js';
|
|
3
|
+
/** Native Model API slugs, not Hugging Face or gateway IDs. Verified 2026-10-26. */
|
|
4
|
+
export declare const BASETEN_DECISION_MODELS: readonly ["decision-models/baseten-elephant-9b-latest", "decision-models/baseten-mammoth-27b-latest"];
|
|
5
|
+
/** Baseten uses inline user-message image parts, never top-level images/placeholders. */
|
|
6
|
+
export declare function basetenDecisionState(state: PreparedClassifierState): unknown;
|
|
7
|
+
/** https://docs.baseten.co/reference/inference-api/system-one */
|
|
8
|
+
export declare function assertBasetenDecisionLimits({ model, state, questions }: PreparedClassifierEvaluation, check: () => void): void;
|
|
@@ -15,6 +15,8 @@ export declare const LIQUID_DEFAULT_CREDENTIAL_NAMES: ClassifierCredentialNames;
|
|
|
15
15
|
export declare const OPENAI_DEFAULT_CREDENTIAL_NAMES: ClassifierCredentialNames;
|
|
16
16
|
export declare const OPENROUTER_DEFAULT_CREDENTIAL_NAMES: ClassifierCredentialNames;
|
|
17
17
|
export declare const PERPLEXITY_DEFAULT_CREDENTIAL_NAMES: ClassifierCredentialNames;
|
|
18
|
+
export declare const SUBQ_DEFAULT_CREDENTIAL_NAMES: ClassifierCredentialNames;
|
|
19
|
+
export declare const BASETEN_DEFAULT_CREDENTIAL_NAMES: ClassifierCredentialNames;
|
|
18
20
|
export declare function isValidClassifierProgrammaticCredentialName(name: string): boolean;
|
|
19
21
|
export declare function isValidClassifierEnvironmentCredentialName(name: string): boolean;
|
|
20
22
|
export declare function normalizeClassifierCredentialNames(value: unknown, defaults?: ClassifierCredentialNames): ClassifierCredentialNames;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PreparedClassifierImage } from './images.js';
|
|
2
|
+
import type { PreparedClassifierEvaluation } from './providers.js';
|
|
3
|
+
/** Experimental image contract, verified 2026-10-24: https://docs.typesafe.ai/images */
|
|
4
|
+
export declare const JEV_IMAGE_MODELS: string[];
|
|
5
|
+
/** https://docs.typesafe.ai/primitives/box — Box requires Jev 1.14, not 1.13. */
|
|
6
|
+
export declare const JEV_BOX_MODELS: string[];
|
|
7
|
+
export declare function assertJevImageLimits(images: readonly PreparedClassifierImage[], check: () => void): void;
|
|
8
|
+
/** Jev substitutes opaque asset references, not Liquid's numbered image placeholders. */
|
|
9
|
+
export declare function createJevDecisionRequest({ model, state, questions, }: PreparedClassifierEvaluation): Record<string, unknown>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TokenPricing } from '../tokenPricing.js';
|
|
1
2
|
import type { NodeId } from '../NodeBase.js';
|
|
2
3
|
import type { ProjectId } from '../Project.js';
|
|
3
4
|
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
@@ -6,6 +7,7 @@ import { type ClassifierPreparationCheck } from './limits.js';
|
|
|
6
7
|
import { type ClassifierApiKeySource, type ClassifierCredentialNames } from './credentials.js';
|
|
7
8
|
import type { RivetLLMProfileCircuitBreakerPolicy, RivetLLMProfileHealthIdentity } from '../chat-v2/llmProfileHealthStore.js';
|
|
8
9
|
export type ClassifierProfileConfiguration = {
|
|
10
|
+
tokenPricing?: TokenPricing;
|
|
9
11
|
provider?: string;
|
|
10
12
|
model?: string;
|
|
11
13
|
useModelInput?: boolean;
|
|
@@ -36,7 +38,7 @@ export declare const DEFAULT_CLASSIFIER_PROFILE_FAILURE_THRESHOLD = 3;
|
|
|
36
38
|
export declare const DEFAULT_CLASSIFIER_PROFILE_FAILURE_WINDOW_MS = 300000;
|
|
37
39
|
export declare const DEFAULT_CLASSIFIER_PROFILE_OPEN_DURATION_MS = 300000;
|
|
38
40
|
export declare const classifierProfileInputIds: readonly ["model", "apiKey"];
|
|
39
|
-
export declare const classifierProfileDataKeys: readonly ["provider", "model", "useModelInput", "apiKeySource", "apiKeyNamesByProvider", "apiKeyNames", "responseTimeoutMs", "enableCircuitBreaker", "circuitBreakerFailureThreshold", "circuitBreakerFailureWindowMs", "circuitBreakerOpenDurationMs"];
|
|
41
|
+
export declare const classifierProfileDataKeys: readonly ["tokenPricing", "provider", "model", "useModelInput", "apiKeySource", "apiKeyNamesByProvider", "apiKeyNames", "responseTimeoutMs", "enableCircuitBreaker", "circuitBreakerFailureThreshold", "circuitBreakerFailureWindowMs", "circuitBreakerOpenDurationMs"];
|
|
40
42
|
export declare function pickClassifierProfileData(data: ClassifierProfileConfiguration): ClassifierProfileConfiguration;
|
|
41
43
|
export declare function classifierProfileResponseTimeout(configuration: ClassifierProfileConfiguration): number;
|
|
42
44
|
export declare function classifierProfileHealthPolicy(configuration: ClassifierProfileConfiguration): RivetLLMProfileCircuitBreakerPolicy | undefined;
|