@valerypopoff/rivet2-core 2.22.0 → 2.24.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 +1166 -797
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/webAppRuntime.cjs +4 -1
- package/dist/cjs/webAppRuntime.cjs.map +2 -2
- package/dist/esm/exports.js +0 -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/GraphProcessor.js +32 -54
- package/dist/esm/model/NodeRegistration.js +2 -6
- 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 +14 -13
- package/dist/esm/model/classifier/profileExecution.js +26 -23
- package/dist/esm/model/classifier/providers.js +170 -74
- 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 +32 -61
- package/dist/esm/model/nodes/ClassifierProfileNode.js +9 -9
- package/dist/esm/model/nodes/ClassifierQuestionNode.js +53 -34
- 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/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/profileExecution.d.ts +1 -1
- package/dist/types/model/classifier/providers.d.ts +26 -5
- 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/package.json +2 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { systemOneState } from './state.js';
|
|
2
|
+
/** https://docs.subq.ai/using-the-api/models/ (verified 2026-10-24). */
|
|
3
|
+
export const SUBQ_DECISION_MODELS = ['subq-snap-1.1'];
|
|
4
|
+
/** SubQ separates images from State and requires typed, bare-base64 objects. */
|
|
5
|
+
export function subqDecisionState(state) {
|
|
6
|
+
if (state.kind === 'json')
|
|
7
|
+
return { state: state.value };
|
|
8
|
+
const wire = systemOneState({ state: '', stateMessages: state.messages });
|
|
9
|
+
return {
|
|
10
|
+
state: wire.state,
|
|
11
|
+
...(state.images.length
|
|
12
|
+
? {
|
|
13
|
+
images: state.images.map(({ mediaType, dataUrl }) => ({
|
|
14
|
+
mediaType,
|
|
15
|
+
base64: dataUrl.slice(dataUrl.indexOf(',') + 1),
|
|
16
|
+
})),
|
|
17
|
+
}
|
|
18
|
+
: {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Capability failures allow profile fallback without silently dropping/splitting evidence. */
|
|
22
|
+
export function assertSubQDecisionLimits({ state, questions }, check) {
|
|
23
|
+
if (questions.length > 128)
|
|
24
|
+
throw new Error('SubQ Snap supports at most 128 questions per request.');
|
|
25
|
+
for (const question of questions) {
|
|
26
|
+
// JSON Schema string lengths count Unicode code points, not UTF-16 units.
|
|
27
|
+
let characters = 0;
|
|
28
|
+
for (const _character of question.questionId) {
|
|
29
|
+
check();
|
|
30
|
+
if (++characters > 100)
|
|
31
|
+
throw new Error('SubQ Snap question IDs must contain at most 100 characters.');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (state.kind !== 'messages')
|
|
35
|
+
return;
|
|
36
|
+
if (state.images.length > 4)
|
|
37
|
+
throw new Error('SubQ Snap supports at most 4 images per request.');
|
|
38
|
+
let total = 0;
|
|
39
|
+
for (const { mediaType, dataUrl } of state.images) {
|
|
40
|
+
check();
|
|
41
|
+
if (!['image/png', 'image/jpeg', 'image/webp'].includes(mediaType))
|
|
42
|
+
throw new Error('SubQ Snap accepts PNG, JPEG and WebP images, not GIF.');
|
|
43
|
+
const payload = dataUrl.slice(dataUrl.indexOf(',') + 1);
|
|
44
|
+
const bytes = (payload.length / 4) * 3 - (payload.endsWith('==') ? 2 : payload.endsWith('=') ? 1 : 0);
|
|
45
|
+
if (bytes > 4 * 1024 * 1024)
|
|
46
|
+
throw new Error('SubQ Snap images must not exceed 4 MiB decoded each.');
|
|
47
|
+
total += bytes;
|
|
48
|
+
}
|
|
49
|
+
if (total > 8 * 1024 * 1024)
|
|
50
|
+
throw new Error('SubQ Snap images must not exceed 8 MiB decoded in total.');
|
|
51
|
+
}
|
|
@@ -8,7 +8,7 @@ import { getNextVariadicPortIndex } from './variadicPortIndex.js';
|
|
|
8
8
|
import { resolveClassifierApiKey } from '../classifier/credentials.js';
|
|
9
9
|
import { classifierArrayValues, classifierInputDataValue } from '../classifier/json.js';
|
|
10
10
|
import { normalizeClassifierState } from '../classifier/state.js';
|
|
11
|
-
import { CLASSIFIER_LIMITS,
|
|
11
|
+
import { CLASSIFIER_LIMITS, ClassifierValueBudget } from '../classifier/limits.js';
|
|
12
12
|
import { calculateClassifierUsageCost, classifierFailureKind, classifierProviders, DEFAULT_CLASSIFIER_RETRY_ON_NON_200_COOLDOWN_MS, DEFAULT_CLASSIFIER_RETRY_ON_NON_200_REPEAT_TIMES, getClassifierProvider, normalizeClassifierNon200RetryCooldownMs, normalizeClassifierNon200RetryCount, } from '../classifier/providers.js';
|
|
13
13
|
import { normalizeClassifierProfiles } from '../classifier/profile.js';
|
|
14
14
|
import { classifierProfileSummary, ClassifierProfileExhaustedError, runClassifierProfiles, } from '../classifier/profileExecution.js';
|
|
@@ -21,13 +21,13 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
21
21
|
static create() {
|
|
22
22
|
return {
|
|
23
23
|
type: 'classifierEvaluate',
|
|
24
|
-
title: '
|
|
24
|
+
title: 'Decision AI run',
|
|
25
25
|
id: nanoid(),
|
|
26
26
|
visualData: { x: 0, y: 0, width: 260 },
|
|
27
27
|
// Keep the default model in the provider descriptor rather than
|
|
28
28
|
// serializing Jev's model into every new node. A future provider then
|
|
29
29
|
// receives its own default when an author changes the Provider field.
|
|
30
|
-
data: { provider: 'jev',
|
|
30
|
+
data: { provider: 'jev', errorOnNon200: true, catchRequestFailed: false },
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
getInputDefinitions(connections) {
|
|
@@ -55,12 +55,12 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
55
55
|
if (this.data.configurationMode === 'profile') {
|
|
56
56
|
inputs.unshift({
|
|
57
57
|
id: 'classifierProfile',
|
|
58
|
-
title: '
|
|
58
|
+
title: 'Decision AI Profiles',
|
|
59
59
|
dataType: ['classifier-config', 'classifier-config[]'],
|
|
60
60
|
required: true,
|
|
61
61
|
coerced: true,
|
|
62
62
|
splitRunBehavior: 'preserve-array',
|
|
63
|
-
description: 'One
|
|
63
|
+
description: 'One Decision AI Profile or an ordered fallback chain.',
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
if (this.data.configurationMode !== 'profile' && this.data.useModelInput) {
|
|
@@ -99,11 +99,11 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
99
99
|
outputs.push({ id: 'responseBody', title: 'Response body', dataType: 'object' });
|
|
100
100
|
}
|
|
101
101
|
if (this.data.outputClassifierAttempts)
|
|
102
|
-
outputs.push({ id: 'classifierAttempts', title: '
|
|
102
|
+
outputs.push({ id: 'classifierAttempts', title: 'Decision AI Attempts', dataType: 'object[]' });
|
|
103
103
|
if (this.data.configurationMode === 'profile' && this.data.outputClassifierProfileSummary)
|
|
104
104
|
outputs.push({
|
|
105
105
|
id: 'classifierProfileSummary',
|
|
106
|
-
title: '
|
|
106
|
+
title: 'Decision AI Profile Summary',
|
|
107
107
|
dataType: 'string',
|
|
108
108
|
});
|
|
109
109
|
return [...outputs, ...getRunFailureOutputDefinitions({ catchRequestFailed: this.data.catchRequestFailed })];
|
|
@@ -111,7 +111,7 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
111
111
|
getEditors() {
|
|
112
112
|
return [
|
|
113
113
|
{ type: 'custom', label: 'Configuration', customEditorId: 'ClassifierConfiguration' },
|
|
114
|
-
{ ...getClassifierModelEditor(
|
|
114
|
+
{ ...getClassifierModelEditor(), hideIf: (data) => data.configurationMode === 'profile' },
|
|
115
115
|
{
|
|
116
116
|
type: 'group',
|
|
117
117
|
label: 'Outputs',
|
|
@@ -126,7 +126,7 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
126
126
|
type: 'toggle',
|
|
127
127
|
label: 'Request body',
|
|
128
128
|
dataKey: 'outputRequestBody',
|
|
129
|
-
helperMessage: 'Adds the exact
|
|
129
|
+
helperMessage: 'Adds the exact Decision AI request JSON body sent to the provider. It excludes authorization headers and Rivet-managed API keys.',
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
type: 'toggle',
|
|
@@ -134,31 +134,15 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
134
134
|
dataKey: 'outputResponseBody',
|
|
135
135
|
helperMessage: 'Shows the provider response, including rejected or invalid responses. Non-JSON responses appear as raw text. Captured content may contain sensitive input.',
|
|
136
136
|
},
|
|
137
|
-
{ type: 'toggle', label: '
|
|
137
|
+
{ type: 'toggle', label: 'Decision AI attempts', dataKey: 'outputClassifierAttempts' },
|
|
138
138
|
{
|
|
139
139
|
type: 'toggle',
|
|
140
|
-
label: '
|
|
140
|
+
label: 'Decision AI profile summary',
|
|
141
141
|
dataKey: 'outputClassifierProfileSummary',
|
|
142
142
|
hideIf: (data) => data.configurationMode !== 'profile',
|
|
143
143
|
},
|
|
144
144
|
],
|
|
145
145
|
},
|
|
146
|
-
{
|
|
147
|
-
type: 'group',
|
|
148
|
-
label: 'Advanced',
|
|
149
|
-
editors: [
|
|
150
|
-
{
|
|
151
|
-
type: 'number',
|
|
152
|
-
label: 'Overall timeout (seconds)',
|
|
153
|
-
dataKey: this.data.configurationMode === 'profile' ? 'profileChainTimeoutMs' : 'timeoutMs',
|
|
154
|
-
defaultValue: this.data.configurationMode === 'profile' ? 180_000 : 30_000,
|
|
155
|
-
storageMultiplier: 1000,
|
|
156
|
-
min: 1_000,
|
|
157
|
-
max: 600_000,
|
|
158
|
-
step: 1_000,
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
146
|
{
|
|
163
147
|
type: 'group',
|
|
164
148
|
label: 'Error behavior',
|
|
@@ -223,10 +207,10 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
223
207
|
}
|
|
224
208
|
static getUIData() {
|
|
225
209
|
return {
|
|
226
|
-
contextMenuTitle: '
|
|
227
|
-
infoBoxTitle: '
|
|
228
|
-
infoBoxBody: 'Evaluates shared state and optional images against typed
|
|
229
|
-
group: ['
|
|
210
|
+
contextMenuTitle: 'Decision AI run',
|
|
211
|
+
infoBoxTitle: 'Decision AI run',
|
|
212
|
+
infoBoxBody: 'Evaluates shared state and optional images against typed Decision AI questions. Images are shared evidence for every question.',
|
|
213
|
+
group: ['Decision AI'],
|
|
230
214
|
};
|
|
231
215
|
}
|
|
232
216
|
async process(inputs, context) {
|
|
@@ -299,15 +283,11 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
299
283
|
if (this.data.configurationMode !== undefined &&
|
|
300
284
|
this.data.configurationMode !== 'inline' &&
|
|
301
285
|
this.data.configurationMode !== 'profile')
|
|
302
|
-
throw new Error('Unknown
|
|
303
|
-
const
|
|
304
|
-
? normalizeTimeout(this.data.profileChainTimeoutMs ?? 180_000)
|
|
305
|
-
: normalizeTimeout(this.data.timeoutMs);
|
|
306
|
-
const deadline = Date.now() + timeoutMs;
|
|
307
|
-
const checkPreparation = classifierPreparationCheck(context.signal, deadline, timeoutMs);
|
|
286
|
+
throw new Error('Unknown Decision AI configuration mode.');
|
|
287
|
+
const checkPreparation = () => context.signal.throwIfAborted();
|
|
308
288
|
checkPreparation();
|
|
309
289
|
if (this.data.configurationMode === 'profile')
|
|
310
|
-
return this.processProfiles(inputs, context,
|
|
290
|
+
return this.processProfiles(inputs, context, checkPreparation, attempts, diagnostics);
|
|
311
291
|
const provider = getClassifierProvider(this.data.provider);
|
|
312
292
|
if (!provider.browserExecutionSupported && context.executor === 'browser') {
|
|
313
293
|
throw new Error(`${provider.label} cannot run in the Browser executor. Select the Node executor, or run through Studio Server or remote debugging.`);
|
|
@@ -354,7 +334,7 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
354
334
|
}
|
|
355
335
|
}
|
|
356
336
|
if (questions.length === 0)
|
|
357
|
-
throw new Error('
|
|
337
|
+
throw new Error('Decision AI run requires at least one question.');
|
|
358
338
|
const result = await (provider.evaluateInput ?? provider.evaluate).call(provider, {
|
|
359
339
|
apiKey,
|
|
360
340
|
model: modelValue,
|
|
@@ -364,8 +344,6 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
364
344
|
retryOnNon200RepeatTimes: this.data.retryOnNon200RepeatTimes,
|
|
365
345
|
signal: context.signal,
|
|
366
346
|
...state,
|
|
367
|
-
timeoutMs,
|
|
368
|
-
deadline,
|
|
369
347
|
...diagnostics,
|
|
370
348
|
onAttempt: ({ kind, ...attempt }) => {
|
|
371
349
|
const event = {
|
|
@@ -387,8 +365,7 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
387
365
|
});
|
|
388
366
|
},
|
|
389
367
|
});
|
|
390
|
-
// Custom providers
|
|
391
|
-
// result may become a successful node output after the original deadline.
|
|
368
|
+
// Custom providers own their transport; caller cancellation still wins.
|
|
392
369
|
checkPreparation();
|
|
393
370
|
return { ...this.projectResult(provider, modelValue, result, checkPreparation), ...this.profileEvidence(attempts) };
|
|
394
371
|
}
|
|
@@ -430,7 +407,7 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
430
407
|
: {}),
|
|
431
408
|
};
|
|
432
409
|
}
|
|
433
|
-
async processProfiles(inputs, context,
|
|
410
|
+
async processProfiles(inputs, context, check, attempts, diagnostics) {
|
|
434
411
|
const profiles = normalizeClassifierProfiles(classifierInputDataValue(inputs, 'classifierProfile')?.value, check);
|
|
435
412
|
const graph = context.project?.graphs[context.execution?.graphId];
|
|
436
413
|
if (classifierInputDataValue(inputs, 'images') !== undefined ||
|
|
@@ -449,7 +426,7 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
449
426
|
flattenQuestions(input.value, values, check, new Set(), 0, work);
|
|
450
427
|
}
|
|
451
428
|
if (!values.length)
|
|
452
|
-
throw new Error('
|
|
429
|
+
throw new Error('Decision AI run requires at least one question.');
|
|
453
430
|
const ids = new Set();
|
|
454
431
|
const questions = values.map((value) => {
|
|
455
432
|
const question = prepareClassifierQuestion(value, budget);
|
|
@@ -464,7 +441,6 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
464
441
|
questions,
|
|
465
442
|
context,
|
|
466
443
|
nodeId: this.chartNode.id,
|
|
467
|
-
deadline,
|
|
468
444
|
retryOnNon200: this.data.retryOnNon200,
|
|
469
445
|
retryOnNon200RepeatTimes: this.data.retryOnNon200RepeatTimes,
|
|
470
446
|
retryOnNon200CooldownMs: this.data.retryOnNon200CooldownMs,
|
|
@@ -487,7 +463,7 @@ export class ClassifierEvaluateNodeImpl extends NodeImpl {
|
|
|
487
463
|
}
|
|
488
464
|
}
|
|
489
465
|
/** Shared settings definition; constructing an unrelated node is unnecessary. */
|
|
490
|
-
export function getClassifierModelEditor(
|
|
466
|
+
export function getClassifierModelEditor() {
|
|
491
467
|
return {
|
|
492
468
|
type: 'group',
|
|
493
469
|
label: 'Model',
|
|
@@ -501,11 +477,11 @@ export function getClassifierModelEditor(data) {
|
|
|
501
477
|
options: classifierProviders.map((provider) => ({ value: provider.id, label: provider.label })),
|
|
502
478
|
},
|
|
503
479
|
{
|
|
504
|
-
type: '
|
|
480
|
+
type: 'custom',
|
|
505
481
|
label: 'Model',
|
|
506
482
|
dataKey: 'model',
|
|
507
483
|
useInputToggleDataKey: 'useModelInput',
|
|
508
|
-
|
|
484
|
+
customEditorId: 'ClassifierModel',
|
|
509
485
|
},
|
|
510
486
|
{
|
|
511
487
|
type: 'segmented',
|
|
@@ -515,7 +491,7 @@ export function getClassifierModelEditor(data) {
|
|
|
515
491
|
defaultValue: 'configured',
|
|
516
492
|
options: [
|
|
517
493
|
{ value: 'configured', label: 'Automatic' },
|
|
518
|
-
{ value: 'classifier-settings', label: '
|
|
494
|
+
{ value: 'classifier-settings', label: 'Decision AI settings' },
|
|
519
495
|
{ value: 'input', label: 'Input port' },
|
|
520
496
|
],
|
|
521
497
|
helperMessage: getApiKeySourceHelperMessage,
|
|
@@ -540,7 +516,7 @@ function getProviderForDisplay(id) {
|
|
|
540
516
|
function getStaticModel(model, defaultModel) {
|
|
541
517
|
return typeof model === 'string' && model.trim() !== '' ? model.trim() : defaultModel;
|
|
542
518
|
}
|
|
543
|
-
/** Shared presentation model for the app's
|
|
519
|
+
/** Shared presentation model for the app's Decision AI run card. */
|
|
544
520
|
export function getClassifierEvaluateBodySections(data) {
|
|
545
521
|
const provider = getProviderForDisplay(data.provider);
|
|
546
522
|
const sections = [
|
|
@@ -588,8 +564,8 @@ function getApiKeySourceHelperMessage(data) {
|
|
|
588
564
|
return 'Uses the API Key input port instead of a configured provider key.';
|
|
589
565
|
const provider = getProviderForDisplay(data.provider);
|
|
590
566
|
if (data.apiKeySource === 'classifier-settings')
|
|
591
|
-
return `Uses only Settings >
|
|
592
|
-
return 'Automatic checks the named programmatic setting, then the named environment variable, then the saved
|
|
567
|
+
return `Uses only Settings > Decision AI > ${provider.label} API Key on the executor. Does not fall back to named or environment credentials.`;
|
|
568
|
+
return 'Automatic checks the named programmatic setting, then the named environment variable, then the saved Decision AI key (default names only). OpenAI also accepts its legacy general key; Jev accepts its legacy plugin key last. Resolution happens on the executor, not in this editor.';
|
|
593
569
|
}
|
|
594
570
|
function flattenQuestions(value, target, check, seen = new Set(), depth = 0, work = { values: 0 }) {
|
|
595
571
|
check();
|
|
@@ -602,7 +578,7 @@ function flattenQuestions(value, target, check, seen = new Set(), depth = 0, wor
|
|
|
602
578
|
throw new Error('Question inputs must not contain circular arrays.');
|
|
603
579
|
seen.add(value);
|
|
604
580
|
if (value.length > CLASSIFIER_LIMITS.questions)
|
|
605
|
-
throw new Error('
|
|
581
|
+
throw new Error('Decision AI run supports at most 1000 questions.');
|
|
606
582
|
for (const item of classifierArrayValues(value, 'Questions'))
|
|
607
583
|
flattenQuestions(item, target, check, seen, depth + 1, work);
|
|
608
584
|
seen.delete(value);
|
|
@@ -612,12 +588,7 @@ function flattenQuestions(value, target, check, seen = new Set(), depth = 0, wor
|
|
|
612
588
|
throw new Error('Question inputs must contain question definition objects or nested arrays of definitions.');
|
|
613
589
|
}
|
|
614
590
|
if (target.length >= CLASSIFIER_LIMITS.questions)
|
|
615
|
-
throw new Error('
|
|
591
|
+
throw new Error('Decision AI run supports at most 1000 questions.');
|
|
616
592
|
target.push(value);
|
|
617
593
|
}
|
|
618
|
-
|
|
619
|
-
return typeof timeoutMs === 'number' && Number.isFinite(timeoutMs) && timeoutMs > 0
|
|
620
|
-
? Math.min(timeoutMs, 600_000)
|
|
621
|
-
: 30_000;
|
|
622
|
-
}
|
|
623
|
-
export const classifierEvaluateNode = nodeDefinition(ClassifierEvaluateNodeImpl, 'Classifier Evaluate');
|
|
594
|
+
export const classifierEvaluateNode = nodeDefinition(ClassifierEvaluateNodeImpl, 'Decision AI run');
|
|
@@ -9,7 +9,7 @@ export class ClassifierProfileNodeImpl extends NodeImpl {
|
|
|
9
9
|
static create() {
|
|
10
10
|
return {
|
|
11
11
|
type: 'classifierProfile',
|
|
12
|
-
title: '
|
|
12
|
+
title: 'Decision AI Profile',
|
|
13
13
|
id: nanoid(),
|
|
14
14
|
visualData: { x: 0, y: 0, width: 260 },
|
|
15
15
|
data: { provider: 'jev', responseTimeoutMs: DEFAULT_CLASSIFIER_PROFILE_RESPONSE_TIMEOUT_MS },
|
|
@@ -31,16 +31,16 @@ export class ClassifierProfileNodeImpl extends NodeImpl {
|
|
|
31
31
|
id: 'profile',
|
|
32
32
|
title: 'Profile',
|
|
33
33
|
dataType: 'classifier-config',
|
|
34
|
-
description: 'Sensitive resolved
|
|
34
|
+
description: 'Sensitive resolved Decision AI configuration. Combine profiles with Array for ordered fallback.',
|
|
35
35
|
},
|
|
36
36
|
];
|
|
37
37
|
}
|
|
38
38
|
getEditors() {
|
|
39
39
|
return [
|
|
40
|
-
getClassifierModelEditor(
|
|
40
|
+
getClassifierModelEditor(),
|
|
41
41
|
{
|
|
42
42
|
type: 'group',
|
|
43
|
-
label: '
|
|
43
|
+
label: 'Decision AI profile suspension',
|
|
44
44
|
editors: [
|
|
45
45
|
{
|
|
46
46
|
type: 'info',
|
|
@@ -117,10 +117,10 @@ export class ClassifierProfileNodeImpl extends NodeImpl {
|
|
|
117
117
|
}
|
|
118
118
|
static getUIData() {
|
|
119
119
|
return {
|
|
120
|
-
contextMenuTitle: '
|
|
121
|
-
infoBoxTitle: '
|
|
122
|
-
infoBoxBody: 'Reusable
|
|
123
|
-
group: ['
|
|
120
|
+
contextMenuTitle: 'Decision AI Profile',
|
|
121
|
+
infoBoxTitle: 'Decision AI Profile',
|
|
122
|
+
infoBoxBody: 'Reusable Decision AI provider/model/credential configuration. Combine profiles with Array for ordered fallback.',
|
|
123
|
+
group: ['Decision AI'],
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
async process(inputs, context) {
|
|
@@ -130,4 +130,4 @@ export class ClassifierProfileNodeImpl extends NodeImpl {
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
export const classifierProfileNode = nodeDefinition(ClassifierProfileNodeImpl, '
|
|
133
|
+
export const classifierProfileNode = nodeDefinition(ClassifierProfileNodeImpl, 'Decision AI Profile');
|
|
@@ -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');
|
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,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;
|