@abhishek944/pi-classifier 0.5.1 → 0.7.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/inputs.js CHANGED
@@ -20,15 +20,23 @@ export async function prepareInput(params, route, cwd, signal, memoryImages = []
20
20
  if (route.api === "perplexity-decisions" && params.mode === "web_grounding" && questionCount > 100)
21
21
  throw new ClassifierError("input", "Perplexity web grounding accepts at most 100 questions.");
22
22
  const openRouter = route.api === "openrouter-decisions" ? openRouterDecisionCapabilities(route.model) : undefined;
23
+ const liquid = route.api === "liquid-system-one";
23
24
  const imageCount = (params.images?.length ?? 0) + memoryImages.length;
24
25
  if (imageCount && !route.images)
25
26
  throw new ClassifierError("capability", "The selected model does not support images, or experimental Jev images are disabled.");
27
+ // Liquid documents exactly one image for box and boxes questions; other routes do not publish that rule.
28
+ const liquidLocationRead = liquid &&
29
+ Object.values(params.questions).some((question) => question.type === "box" || question.type === "boxes");
30
+ if (liquidLocationRead && imageCount !== 1)
31
+ throw new ClassifierError("input", "Liquid box and boxes questions require exactly one image per request; " + imageCount + " supplied. Send one image or split the reads across requests.");
26
32
  if (hasBox(params.questions) && (!route.box || !imageCount))
27
33
  throw new ClassifierError("capability", "box requires an enabled Jev 1.14 model, experimentalImages/experimentalBox and an image.");
28
34
  if (params.mode === "web_grounding" && route.api !== "perplexity-decisions")
29
35
  throw new ClassifierError("capability", "Web grounding is supported only by Perplexity Decisions routes.");
30
36
  if (route.api === "cloudflare-clairic")
31
- throw new ClassifierError("capability", "Clairic extraction uses classify_extract with fields, not classify questions.");
37
+ throw new ClassifierError("capability", "Clairic reads fields through classify_extract; it has no typed-question surface.");
38
+ if (route.api === "openrouter-extractions" || route.api === "litellm-extraction")
39
+ throw new ClassifierError("capability", "The selected extraction route reads fields only. Typed extraction questions need a decision route such as liquid-api, typesafe-api, perplexity-decisions or inception-api.");
32
40
  if (params.imageDetail !== undefined && !["openai-decisions", "openrouter-decisions"].includes(route.api))
33
41
  throw new ClassifierError("capability", "imageDetail is supported only by OpenAI-compatible and OpenRouter Decisions routes.");
34
42
  if (params.promptCache !== undefined && route.api !== "openai-decisions")
@@ -48,7 +56,7 @@ export async function prepareInput(params, route, cwd, signal, memoryImages = []
48
56
  ? sarvamQuestions
49
57
  : route.api === "inception-decisions"
50
58
  ? [...coreQuestions, "extract"]
51
- : ["gemini-decisions", "parallel-decisions", "local-system-one"].includes(route.api)
59
+ : ["gemini-decisions", "parallel-decisions", "local-system-one", "subq-system-one", "alibaba-system-one", "fireworks-system-one"].includes(route.api)
52
60
  ? coreQuestions
53
61
  : openRouter
54
62
  ? openRouterQuestions
@@ -85,7 +93,7 @@ export async function prepareInput(params, route, cwd, signal, memoryImages = []
85
93
  throw new ClassifierError("input", "locate requires a string state. Offsets are defined only for text.");
86
94
  }
87
95
  const clef = route.api === "cloudflare-system-one" && route.images;
88
- const liquid = route.api === "liquid-system-one";
96
+ const tightImages = clef || route.api === "subq-system-one";
89
97
  if (imageCount > route.limits.maxImages)
90
98
  throw new ClassifierError("input", "The selected route accepts at most " + route.limits.maxImages + " images in this package.");
91
99
  const flexibleReferences = openRouter?.flexibleImagePlacement === true;
@@ -125,7 +133,7 @@ export async function prepareInput(params, route, cwd, signal, memoryImages = []
125
133
  ];
126
134
  for (const entry of sources) {
127
135
  cancelled(signal);
128
- const maxBytes = (clef ? 4 : 5) * 1024 * 1024;
136
+ const maxBytes = (tightImages ? 4 : 5) * 1024 * 1024;
129
137
  let image;
130
138
  let id;
131
139
  if ("memory" in entry) {
@@ -142,7 +150,7 @@ export async function prepareInput(params, route, cwd, signal, memoryImages = []
142
150
  id = source.id;
143
151
  }
144
152
  totalBytes += Buffer.byteLength(image.data, "base64");
145
- if (totalBytes > (clef ? 8 : 10) * 1024 * 1024)
153
+ if (totalBytes > (tightImages ? 8 : 10) * 1024 * 1024)
146
154
  throw new ClassifierError("input", "Images exceed the selected route's total upload byte limit.");
147
155
  if (route.api === "microsoft-system-one" && image.mimeType === "image/webp")
148
156
  throw new ClassifierError("input", "Microsoft Foundry Decision-1.1 image assets accept PNG and JPEG only.");
@@ -401,6 +409,28 @@ async function prepareMedia(sources, route, cwd, signal) {
401
409
  }
402
410
  return result;
403
411
  }
412
+ /** Field extraction keeps its local-path/rotation image contract; question mode uses shared images. */
413
+ function fieldExtractionImages(value) {
414
+ if (value === undefined)
415
+ return [];
416
+ if (!Array.isArray(value))
417
+ throw new ClassifierError("input", "images must be an array.");
418
+ return value.map((image) => {
419
+ if (typeof image === "string") {
420
+ if (!image.trim() || image.length > 4096)
421
+ throw new ClassifierError("input", "Image paths must be non-empty, at most 4096 characters.");
422
+ return image;
423
+ }
424
+ const spec = image;
425
+ if (!isRecord(spec) || Object.keys(spec).some((key) => key !== "path" && key !== "rotation") ||
426
+ typeof spec.path !== "string" || !spec.path.trim() || spec.path.length > 4096 ||
427
+ (spec.rotation !== undefined && ![0, 90, 180, 270].includes(spec.rotation)))
428
+ throw new ClassifierError("input", "Field extraction images must be local path strings or {path, rotation} objects. Named and hosted images are accepted only by extraction questions.");
429
+ return spec.rotation === undefined
430
+ ? { path: spec.path }
431
+ : { path: spec.path, rotation: spec.rotation };
432
+ });
433
+ }
404
434
  const EXTRACTION_TYPES = new Set([
405
435
  "text", "number", "compute", "date", "time", "datetime", "duration",
406
436
  "boolean", "enum", "object", "list", "estimate", "forecast",
@@ -533,12 +563,18 @@ async function loadDocumentFile(path, cwd, signal) {
533
563
  }
534
564
  }
535
565
  export async function prepareExtractionInput(params, route, cwd, signal) {
566
+ if (params.questions !== undefined)
567
+ throw new ClassifierError("input", "Extraction questions use the typed-question path, not fields.");
568
+ if (params.media !== undefined || params.mode !== undefined)
569
+ throw new ClassifierError("capability", "Field extraction does not accept media or web grounding. Use extraction questions on a decision route instead.");
536
570
  if (!["cloudflare-clairic", "openrouter-extractions", "litellm-extraction"].includes(route.api))
537
- throw new ClassifierError("capability", "Extraction requires a clairic-api, openrouter-extractions-api or litellm-extraction-api route.");
571
+ throw new ClassifierError("capability", "Field extraction requires a clairic-api, openrouter-extractions-api or litellm-extraction-api route. Use questions for typed extraction on a decision route.");
538
572
  if (params.state !== undefined &&
539
573
  !(typeof params.state === "string" || Array.isArray(params.state) || isRecord(params.state)))
540
574
  throw new ClassifierError("input", "state must be text, a JSON object or an array.");
541
575
  const extractionCaps = route.api === "openrouter-extractions" ? openRouterExtractionCapabilities(route.model) : undefined;
576
+ if (params.fields === undefined)
577
+ throw new ClassifierError("input", "Field extraction requires a non-empty fields map.");
542
578
  const fields = validateExtractionFields(params.fields, extractionCaps ? new Set(extractionCaps.fieldTypes) : EXTRACTION_TYPES, extractionCaps?.maxFields);
543
579
  if (route.api === "openrouter-extractions")
544
580
  validateOpenRouterExtractionFields(fields, route.model);
@@ -553,13 +589,10 @@ export async function prepareExtractionInput(params, route, cwd, signal) {
553
589
  Object.values(params.options).some((value) => typeof value !== "boolean"))
554
590
  throw new ClassifierError("input", "options may only set includeQuantiles and returnStateText to booleans.");
555
591
  }
556
- if (params.images !== undefined && (!Array.isArray(params.images) || params.images.some((image) => typeof image === "string"
557
- ? !image.trim() || image.length > 4096
558
- : !isRecord(image) || Object.keys(image).some((key) => key !== "path" && key !== "rotation") ||
559
- typeof image.path !== "string" || !image.path.trim() || image.path.length > 4096 ||
560
- (image.rotation !== undefined && ![0, 90, 180, 270].includes(image.rotation)))))
561
- throw new ClassifierError("input", "images must be local path strings or {path, rotation} objects with rotation 0, 90, 180 or 270.");
562
- if (route.api !== "cloudflare-clairic" && (params.images ?? []).some((image) => typeof image !== "string" && image.rotation !== undefined))
592
+ if (params.images !== undefined && !Array.isArray(params.images))
593
+ throw new ClassifierError("input", "images must be an array.");
594
+ const fieldImages = fieldExtractionImages(params.images);
595
+ if (route.api !== "cloudflare-clairic" && fieldImages.some((image) => typeof image !== "string" && image.rotation !== undefined))
563
596
  throw new ClassifierError("capability", "Image rotation is documented only for direct Cloudflare Clairic.");
564
597
  if (params.documents !== undefined && (!Array.isArray(params.documents) || params.documents.some((document) => typeof document !== "string" || !document.trim() || document.length > 4096)))
565
598
  throw new ClassifierError("input", "documents must be local PDF path strings inside cwd.");
@@ -573,7 +606,7 @@ export async function prepareExtractionInput(params, route, cwd, signal) {
573
606
  const isScaleDown = route.api === "openrouter-extractions" && route.model === "scaledown/extract";
574
607
  if (isScaleDown && (params.images?.length ?? 0) + (params.documents?.length ?? 0) > 0 && params.state !== undefined && params.state !== "")
575
608
  throw new ClassifierError("input", "ScaleDown Extract reads either text state or one asset, not both. Omit state when sending a PDF or image.");
576
- const images = await Promise.all((params.images ?? []).map(async (image) => {
609
+ const images = await Promise.all(fieldImages.map(async (image) => {
577
610
  const spec = typeof image === "string" ? { path: image } : image;
578
611
  const loaded = await loadLocalImage(spec.path, cwd, signal, 4 * 1024 * 1024);
579
612
  return spec.rotation === undefined ? loaded : { ...loaded, rotation: spec.rotation };
package/dist/providers.js CHANGED
@@ -37,6 +37,12 @@ export async function classifyWithProvider(route, input, apiKey, signal) {
37
37
  return classifySarvam(route, input, apiKey, signal);
38
38
  case "system-one":
39
39
  return classifySystemOne(route, input, apiKey, signal);
40
+ case "subq-system-one":
41
+ return classifySubQ(route, input, apiKey, signal);
42
+ case "alibaba-system-one":
43
+ return classifyAlibaba(route, input, apiKey, signal);
44
+ case "fireworks-system-one":
45
+ return classifyFireworks(route, input, apiKey, signal);
40
46
  case "liquid-system-one":
41
47
  return classifyLiquid(route, input, apiKey, signal);
42
48
  case "microsoft-system-one":
@@ -1386,6 +1392,62 @@ async function classifySystemOne(route, input, apiKey, signal) {
1386
1392
  fail(TYPESAFE_LABEL + " returned an unexpected response.");
1387
1393
  return finish(route, parseTypedAnswers(TYPESAFE_LABEL, body.answers, input.questions), body.usage, requestId);
1388
1394
  }
1395
+ /* SubQ Snap --------------------------------------------------------------- */
1396
+ const SUBQ_LABEL = "SubQ Snap";
1397
+ async function classifySubQ(route, input, apiKey, signal) {
1398
+ const payload = {
1399
+ model: route.model,
1400
+ state: input.state,
1401
+ questions: systemOneQuestions(input.questions, false),
1402
+ };
1403
+ if (input.images.length > 0)
1404
+ payload.images = input.images.map((image) => {
1405
+ if ("url" in image)
1406
+ throw new ClassifierError("capability", "SubQ accepts inline image bytes only.");
1407
+ return { mediaType: image.mimeType, base64: image.data };
1408
+ });
1409
+ const { body, requestId } = await postJson(route, "v1/systemone", payload, apiKey, signal);
1410
+ if (!isRecord(body))
1411
+ fail(SUBQ_LABEL + " returned an unexpected response.");
1412
+ return finish(route, parseTypedAnswers(SUBQ_LABEL, body.answers, input.questions), body.usage, requestId);
1413
+ }
1414
+ /* Alibaba Model Studio Decision Model ------------------------------------ */
1415
+ const ALIBABA_LABEL = "Alibaba Decision Model";
1416
+ async function classifyAlibaba(route, input, apiKey, signal) {
1417
+ const payload = {
1418
+ model: route.model,
1419
+ state: input.state,
1420
+ questions: systemOneQuestions(input.questions, false),
1421
+ };
1422
+ if (input.images.length > 0) {
1423
+ // Alibaba takes its own `image`/`images` entries whose `url` accepts a Base64 data URL.
1424
+ const images = input.images.map((image) => {
1425
+ if ("url" in image)
1426
+ throw new ClassifierError("capability", "Alibaba Decision Model requires local image data.");
1427
+ return { url: imageUrl(image) };
1428
+ });
1429
+ if (images.length === 1)
1430
+ payload.image = images[0];
1431
+ else
1432
+ payload.images = images;
1433
+ }
1434
+ const { body, requestId } = await postJson(route, "compatible-mode/v1/systemone", payload, apiKey, signal);
1435
+ if (!isRecord(body))
1436
+ fail(ALIBABA_LABEL + " returned an unexpected response.");
1437
+ return finish(route, parseTypedAnswers(ALIBABA_LABEL, body.answers, input.questions), body.usage, requestId);
1438
+ }
1439
+ /* Fireworks Rune ---------------------------------------------------------- */
1440
+ const FIREWORKS_LABEL = "Fireworks System One";
1441
+ async function classifyFireworks(route, input, apiKey, signal) {
1442
+ const { body, requestId } = await postJson(route, "systemone", {
1443
+ model: route.model,
1444
+ state: input.state,
1445
+ questions: systemOneQuestions(input.questions, false),
1446
+ }, apiKey, signal);
1447
+ if (!isRecord(body))
1448
+ fail(FIREWORKS_LABEL + " returned an unexpected response.");
1449
+ return finish(route, parseTypedAnswers(FIREWORKS_LABEL, body.answers, input.questions), body.usage, requestId);
1450
+ }
1389
1451
  /* Cloudflare Workers AI (Clef and third-party System One envelopes) ------- */
1390
1452
  function clefBodyModel(model) {
1391
1453
  return /^@cf\/cloudflare\/(clef(?:-flash|-omni)?)$/.exec(model)?.[1];
@@ -9,10 +9,10 @@ export declare const CLASSIFY_TOOL = "classify";
9
9
  export declare const CLASSIFY_COMPARE_TOOL = "classify_compare";
10
10
  export declare const CLASSIFY_TREE_TOOL = "classify_tree";
11
11
  export declare const CLASSIFIER_BOX_TOOL = "classifier_box_image";
12
- export declare const CLASSIFY_TOOL_DESCRIPTION = "Ask a decision model typed questions about text, JSON, images and supported audio/video. Legacy image paths are shared; named path/url descriptors require explicit {$image:id} references. Jev supports images in instructions/criteria; OpenAI supports instruction images and hosted URLs. Unsupported placements fail locally. Returns bool probabilities, choices, scores, Perplexity locate spans, Liquid reads/estimates/multi-select answers and boxes, plus reported token usage and estimated USD cost (or an explicit unavailable reason). mode: web_grounding is an explicit Perplexity opt-in that sends question text and the start of state to web search and adds billed searches/fetches; cost.nonToken reports the documented fees. Experimental Jev box answers require explicit configuration. Provider/model are fixed by pi-classifier.default (or legacy defaultProvider/defaultModel); this tool cannot override them. API-key authentication is independent of Codex chat login. Only explicitly configured fallback routes may be used after a missing key or HTTP 401/404/429 before any batch has completed; never after uncertainty, refusals, timeouts or network failures. Use /classifier list or status to inspect configuration.";
13
- export declare const CLASSIFY_COMPARE_TOOL_DESCRIPTION = "Explicitly compare the same typed questions and state using exactly pi-classifier.compare provider/model pairs. Each entry makes potentially billable requests, including multiple requests when choice batching is configured. No fallback, default substitution, provider/model overrides, or default changes. Returns labeled results, duration, usage, estimated USD costs (or unavailable reasons) and safe per-entry failures; cancellation retains completed results and prevents later requests.";
12
+ export declare const CLASSIFY_TOOL_DESCRIPTION = "Ask a decision model classification questions about text, JSON, images and supported audio/video: yes/no (bool), category (choice), multi-choice (multiple labels) and score. Extraction reads (text, numbers, dates, passages, box/boxes locations, locate offsets, estimates, Inception extract) are not classification and are rejected here; send the same question to classify_extract. Legacy image paths are shared; named path/url descriptors require explicit {$image:id} references. Jev supports images in instructions/criteria; OpenAI supports instruction images and hosted URLs. Unsupported placements fail locally. Returns bool probabilities, choices, multi-choice probabilities and scores, plus reported token usage and estimated USD cost (or an explicit unavailable reason). mode: web_grounding is an explicit Perplexity opt-in that sends question text and the start of state to web search and adds billed searches/fetches; cost.nonToken reports the documented fees. Provider/model are fixed by pi-classifier.default (or legacy defaultProvider/defaultModel); this tool cannot override them. API-key authentication is independent of Codex chat login. Only explicitly configured fallback routes may be used after a missing key or HTTP 401/404/429 before any batch has completed; never after uncertainty, refusals, timeouts or network failures. Use /classifier list or status to inspect configuration.";
13
+ export declare const CLASSIFY_COMPARE_TOOL_DESCRIPTION = "Explicitly compare the same classification questions and state using exactly pi-classifier.compare provider/model pairs. Each entry makes potentially billable requests, including multiple requests when choice batching is configured. No fallback, default substitution, provider/model overrides, or default changes. Returns labeled results, duration, usage, estimated USD costs (or unavailable reasons) and safe per-entry failures; cancellation retains completed results and prevents later requests.";
14
14
  export declare const CLASSIFY_TREE_TOOL_DESCRIPTION = "Classify text, JSON or supported images through a nested classification tree. tree is an inline roots/id/description/children object or a local JSON file inside cwd. Choose among siblings, automatically follow sole children without model calls, and return Level1/Level2/etc under levels with per-step provenance, total providerCalls, reported usage and estimated USD cost. NONE, batching and initial fallback follow configured settings; after a successful decision the route is pinned. no_match, ambiguous and refusal retain only the selected prefix. Automatic steps are structural, not model confirmation; greedy traversal is not a global best-path guarantee. No provider/model override or comparison.";
15
- export declare const CLASSIFIER_BOX_TOOL_DESCRIPTION = "Render a normalized bounding box on a local image, or crop to it, entirely locally. Use to inspect a box answer from classify. overlay keeps the image and draws a rectangle; crop returns only the clamped region. Returns a PNG plus exact source-pixel box metadata. No provider request, upload, resizing or disk write. A box is a localization hint, not proof that the object exists.";
15
+ export declare const CLASSIFIER_BOX_TOOL_DESCRIPTION = "Render a normalized bounding box on a local image, or crop to it, entirely locally. Use to inspect a box value returned by classify_extract. overlay keeps the image and draws a rectangle; crop returns only the clamped region. Returns a PNG plus exact source-pixel box metadata. No provider request, upload, resizing or disk write. A box is a localization hint, not proof that the object exists.";
16
16
  export declare const classifyParameters: Type.TObject<{
17
17
  state: Type.TUnion<[Type.TString, Type.TRecord<"^.*$", Type.TUnknown>, Type.TArray<Type.TUnknown>]>;
18
18
  questions: Type.TRecord<"^.*$", Type.TUnion<[Type.TObject<{
@@ -46,66 +46,6 @@ export declare const classifyParameters: Type.TObject<{
46
46
  $image: Type.TString;
47
47
  }>]>>]>>;
48
48
  descriptions: Type.TOptional<Type.TArray<Type.TString>>;
49
- }>, Type.TObject<{
50
- type: Type.TLiteral<"box">;
51
- instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
52
- $image: Type.TString;
53
- }>]>>]>;
54
- }>, Type.TObject<{
55
- type: Type.TLiteral<"extract">;
56
- instructions: Type.TOptional<Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
57
- $image: Type.TString;
58
- }>]>>]>>;
59
- criteria: Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
60
- $image: Type.TString;
61
- }>]>>]>>;
62
- source: Type.TOptional<Type.TString>;
63
- threshold: Type.TOptional<Type.TNumber>;
64
- snapToWords: Type.TOptional<Type.TBoolean>;
65
- debug: Type.TOptional<Type.TBoolean>;
66
- }>, Type.TObject<{
67
- type: Type.TLiteral<"locate">;
68
- instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
69
- $image: Type.TString;
70
- }>]>>]>;
71
- }>, Type.TObject<{
72
- type: Type.TLiteral<"text">;
73
- instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
74
- $image: Type.TString;
75
- }>]>>]>;
76
- }>, Type.TObject<{
77
- type: Type.TLiteral<"number">;
78
- instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
79
- $image: Type.TString;
80
- }>]>>]>;
81
- unit: Type.TOptional<Type.TString>;
82
- range: Type.TOptional<Type.TTuple<[Type.TNumber, Type.TNumber]>>;
83
- step: Type.TOptional<Type.TNumber>;
84
- }>, Type.TObject<{
85
- type: Type.TLiteral<"date">;
86
- instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
87
- $image: Type.TString;
88
- }>]>>]>;
89
- }>, Type.TObject<{
90
- type: Type.TLiteral<"spans">;
91
- instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
92
- $image: Type.TString;
93
- }>]>>]>;
94
- max: Type.TOptional<Type.TInteger>;
95
- }>, Type.TObject<{
96
- type: Type.TLiteral<"boxes">;
97
- instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
98
- $image: Type.TString;
99
- }>]>>]>;
100
- max: Type.TOptional<Type.TInteger>;
101
- }>, Type.TObject<{
102
- type: Type.TLiteral<"estimate">;
103
- instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
104
- $image: Type.TString;
105
- }>]>>]>;
106
- range: Type.TTuple<[Type.TNumber, Type.TNumber]>;
107
- step: Type.TOptional<Type.TNumber>;
108
- unit: Type.TOptional<Type.TString>;
109
49
  }>, Type.TObject<{
110
50
  type: Type.TLiteral<"multi_choice">;
111
51
  instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
@@ -154,86 +94,6 @@ export declare const classifyOutput: Type.TObject<{
154
94
  score: Type.TNumber;
155
95
  confidence: Type.TNumber;
156
96
  probabilities: Type.TOptional<Type.TRecord<"^.*$", Type.TNumber>>;
157
- }>, Type.TObject<{
158
- type: Type.TLiteral<"box">;
159
- box: Type.TObject<{
160
- top: Type.TNumber;
161
- bottom: Type.TNumber;
162
- left: Type.TNumber;
163
- right: Type.TNumber;
164
- }>;
165
- confidence: Type.TNumber;
166
- found: Type.TOptional<Type.TNumber>;
167
- }>, Type.TObject<{
168
- type: Type.TLiteral<"locate">;
169
- spans: Type.TArray<Type.TObject<{
170
- start: Type.TInteger;
171
- end: Type.TInteger;
172
- text: Type.TString;
173
- score: Type.TNumber;
174
- searchResult: Type.TOptional<Type.TInteger>;
175
- }>>;
176
- }>, Type.TObject<{
177
- type: Type.TLiteral<"extract">;
178
- spans: Type.TRecord<"^.*$", Type.TArray<Type.TObject<{
179
- start: Type.TInteger;
180
- end: Type.TInteger;
181
- text: Type.TString;
182
- score: Type.TNumber;
183
- searchResult: Type.TOptional<Type.TInteger>;
184
- }>>>;
185
- notStated: Type.TRecord<"^.*$", Type.TNumber>;
186
- }>, Type.TObject<{
187
- type: Type.TLiteral<"text">;
188
- text: Type.TString;
189
- span: Type.TOptional<Type.TUnion<[Type.TTuple<[Type.TInteger, Type.TInteger]>, Type.TNull]>>;
190
- found: Type.TOptional<Type.TNumber>;
191
- path: Type.TOptional<Type.TString>;
192
- }>, Type.TObject<{
193
- type: Type.TLiteral<"number">;
194
- value: Type.TUnion<[Type.TNumber, Type.TNull]>;
195
- unit: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
196
- text: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
197
- span: Type.TOptional<Type.TUnion<[Type.TTuple<[Type.TInteger, Type.TInteger]>, Type.TNull]>>;
198
- found: Type.TOptional<Type.TNumber>;
199
- path: Type.TOptional<Type.TString>;
200
- }>, Type.TObject<{
201
- type: Type.TLiteral<"date">;
202
- date: Type.TUnion<[Type.TString, Type.TNull]>;
203
- text: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
204
- span: Type.TOptional<Type.TUnion<[Type.TTuple<[Type.TInteger, Type.TInteger]>, Type.TNull]>>;
205
- found: Type.TOptional<Type.TNumber>;
206
- path: Type.TOptional<Type.TString>;
207
- }>, Type.TObject<{
208
- type: Type.TLiteral<"spans">;
209
- spans: Type.TArray<Type.TObject<{
210
- text: Type.TString;
211
- span: Type.TTuple<[Type.TInteger, Type.TInteger]>;
212
- found: Type.TNumber;
213
- }>>;
214
- count: Type.TInteger;
215
- atLeast: Type.TBoolean;
216
- presence: Type.TArray<Type.TNumber>;
217
- }>, Type.TObject<{
218
- type: Type.TLiteral<"boxes">;
219
- boxes: Type.TArray<Type.TObject<{
220
- box: Type.TObject<{
221
- top: Type.TNumber;
222
- bottom: Type.TNumber;
223
- left: Type.TNumber;
224
- right: Type.TNumber;
225
- }>;
226
- found: Type.TNumber;
227
- confidence: Type.TNumber;
228
- }>>;
229
- count: Type.TInteger;
230
- atLeast: Type.TBoolean;
231
- presence: Type.TArray<Type.TNumber>;
232
- }>, Type.TObject<{
233
- type: Type.TLiteral<"estimate">;
234
- value: Type.TNumber;
235
- interval: Type.TTuple<[Type.TNumber, Type.TNumber]>;
236
- unit: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
237
97
  }>, Type.TObject<{
238
98
  type: Type.TLiteral<"multi_choice">;
239
99
  choices: Type.TArray<Type.TString>;
@@ -358,86 +218,6 @@ export declare const classifyCompareOutput: Type.TObject<{
358
218
  score: Type.TNumber;
359
219
  confidence: Type.TNumber;
360
220
  probabilities: Type.TOptional<Type.TRecord<"^.*$", Type.TNumber>>;
361
- }>, Type.TObject<{
362
- type: Type.TLiteral<"box">;
363
- box: Type.TObject<{
364
- top: Type.TNumber;
365
- bottom: Type.TNumber;
366
- left: Type.TNumber;
367
- right: Type.TNumber;
368
- }>;
369
- confidence: Type.TNumber;
370
- found: Type.TOptional<Type.TNumber>;
371
- }>, Type.TObject<{
372
- type: Type.TLiteral<"locate">;
373
- spans: Type.TArray<Type.TObject<{
374
- start: Type.TInteger;
375
- end: Type.TInteger;
376
- text: Type.TString;
377
- score: Type.TNumber;
378
- searchResult: Type.TOptional<Type.TInteger>;
379
- }>>;
380
- }>, Type.TObject<{
381
- type: Type.TLiteral<"extract">;
382
- spans: Type.TRecord<"^.*$", Type.TArray<Type.TObject<{
383
- start: Type.TInteger;
384
- end: Type.TInteger;
385
- text: Type.TString;
386
- score: Type.TNumber;
387
- searchResult: Type.TOptional<Type.TInteger>;
388
- }>>>;
389
- notStated: Type.TRecord<"^.*$", Type.TNumber>;
390
- }>, Type.TObject<{
391
- type: Type.TLiteral<"text">;
392
- text: Type.TString;
393
- span: Type.TOptional<Type.TUnion<[Type.TTuple<[Type.TInteger, Type.TInteger]>, Type.TNull]>>;
394
- found: Type.TOptional<Type.TNumber>;
395
- path: Type.TOptional<Type.TString>;
396
- }>, Type.TObject<{
397
- type: Type.TLiteral<"number">;
398
- value: Type.TUnion<[Type.TNumber, Type.TNull]>;
399
- unit: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
400
- text: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
401
- span: Type.TOptional<Type.TUnion<[Type.TTuple<[Type.TInteger, Type.TInteger]>, Type.TNull]>>;
402
- found: Type.TOptional<Type.TNumber>;
403
- path: Type.TOptional<Type.TString>;
404
- }>, Type.TObject<{
405
- type: Type.TLiteral<"date">;
406
- date: Type.TUnion<[Type.TString, Type.TNull]>;
407
- text: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
408
- span: Type.TOptional<Type.TUnion<[Type.TTuple<[Type.TInteger, Type.TInteger]>, Type.TNull]>>;
409
- found: Type.TOptional<Type.TNumber>;
410
- path: Type.TOptional<Type.TString>;
411
- }>, Type.TObject<{
412
- type: Type.TLiteral<"spans">;
413
- spans: Type.TArray<Type.TObject<{
414
- text: Type.TString;
415
- span: Type.TTuple<[Type.TInteger, Type.TInteger]>;
416
- found: Type.TNumber;
417
- }>>;
418
- count: Type.TInteger;
419
- atLeast: Type.TBoolean;
420
- presence: Type.TArray<Type.TNumber>;
421
- }>, Type.TObject<{
422
- type: Type.TLiteral<"boxes">;
423
- boxes: Type.TArray<Type.TObject<{
424
- box: Type.TObject<{
425
- top: Type.TNumber;
426
- bottom: Type.TNumber;
427
- left: Type.TNumber;
428
- right: Type.TNumber;
429
- }>;
430
- found: Type.TNumber;
431
- confidence: Type.TNumber;
432
- }>>;
433
- count: Type.TInteger;
434
- atLeast: Type.TBoolean;
435
- presence: Type.TArray<Type.TNumber>;
436
- }>, Type.TObject<{
437
- type: Type.TLiteral<"estimate">;
438
- value: Type.TNumber;
439
- interval: Type.TTuple<[Type.TNumber, Type.TNumber]>;
440
- unit: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
441
221
  }>, Type.TObject<{
442
222
  type: Type.TLiteral<"multi_choice">;
443
223
  choices: Type.TArray<Type.TString>;
@@ -665,10 +445,10 @@ export declare const boxOutput: Type.TObject<{
665
445
  byteLength: Type.TInteger;
666
446
  }>;
667
447
  export declare const CLASSIFY_EXTRACT_TOOL = "classify_extract";
668
- export declare const CLASSIFY_EXTRACT_TOOL_DESCRIPTION = "Extract typed fields with Cloudflare Clairic using the configured clairic-api route. fields maps names to provider field specifications such as text, number, date, enum, object, list, estimate and forecast; nested object/list fields are supported. State is text/JSON and optional images or embedded PDF paths are sent to the provider. Returns typed values with optional grounding metadata plus reported token usage and estimated USD cost. Rendering is provider-owned; truncated reports incomplete generated fields. The tool cannot override the provider or model.";
448
+ export declare const CLASSIFY_EXTRACT_TOOL_DESCRIPTION = "Read values out of source material; this tool does not make classification decisions. Use fields for Clairic-shaped field specifications (text, number, date, enum, object, list, estimate, forecast) on clairic-api, openrouter-extractions-api or litellm-extraction-api, or questions for typed extraction reads (text, number, date, spans, box, boxes, locate, estimate and Inception extract) on the configured decision route, including direct liquid-api d1.2 and d1.2-ultra. Supply exactly one of fields or questions. State is text/JSON plus optional images; field mode also accepts PDF documents. Question answers return {type, value, ...metadata} such as span, found, path and confidence. Returns reported token usage and estimated USD cost; truncated reports incomplete generated field output. The tool cannot override the provider or model.";
669
449
  export declare const classifyExtractParameters: Type.TObject<{
670
450
  state: Type.TOptional<Type.TUnion<[Type.TString, Type.TRecord<"^.*$", Type.TUnknown>, Type.TArray<Type.TUnknown>]>>;
671
- fields: Type.TRecord<"^.*$", Type.TObject<{
451
+ fields: Type.TOptional<Type.TRecord<"^.*$", Type.TObject<{
672
452
  type: Type.TUnion<[Type.TLiteral<"text">, Type.TLiteral<"number">, Type.TLiteral<"compute">, Type.TLiteral<"date">, Type.TLiteral<"time">, Type.TLiteral<"datetime">, Type.TLiteral<"duration">, Type.TLiteral<"boolean">, Type.TLiteral<"enum">, Type.TLiteral<"object">, Type.TLiteral<"list">, Type.TLiteral<"estimate">, Type.TLiteral<"forecast">]>;
673
453
  instructions: Type.TOptional<Type.TString>;
674
454
  nullable: Type.TOptional<Type.TBoolean>;
@@ -698,17 +478,89 @@ export declare const classifyExtractParameters: Type.TObject<{
698
478
  scale: Type.TOptional<Type.TUnion<[Type.TLiteral<"linear">, Type.TLiteral<"log">]>>;
699
479
  horizon: Type.TOptional<Type.TInteger>;
700
480
  interval: Type.TOptional<Type.TUnion<[Type.TLiteral<"step">, Type.TLiteral<"minute">, Type.TLiteral<"hour">, Type.TLiteral<"day">, Type.TLiteral<"week">, Type.TLiteral<"month">, Type.TLiteral<"quarter">, Type.TLiteral<"year">]>>;
701
- }>>;
481
+ }>>>;
482
+ questions: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TObject<{
483
+ type: Type.TLiteral<"box">;
484
+ instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
485
+ $image: Type.TString;
486
+ }>]>>]>;
487
+ }>, Type.TObject<{
488
+ type: Type.TLiteral<"extract">;
489
+ instructions: Type.TOptional<Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
490
+ $image: Type.TString;
491
+ }>]>>]>>;
492
+ criteria: Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
493
+ $image: Type.TString;
494
+ }>]>>]>>;
495
+ source: Type.TOptional<Type.TString>;
496
+ threshold: Type.TOptional<Type.TNumber>;
497
+ snapToWords: Type.TOptional<Type.TBoolean>;
498
+ debug: Type.TOptional<Type.TBoolean>;
499
+ }>, Type.TObject<{
500
+ type: Type.TLiteral<"locate">;
501
+ instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
502
+ $image: Type.TString;
503
+ }>]>>]>;
504
+ }>, Type.TObject<{
505
+ type: Type.TLiteral<"text">;
506
+ instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
507
+ $image: Type.TString;
508
+ }>]>>]>;
509
+ }>, Type.TObject<{
510
+ type: Type.TLiteral<"number">;
511
+ instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
512
+ $image: Type.TString;
513
+ }>]>>]>;
514
+ unit: Type.TOptional<Type.TString>;
515
+ range: Type.TOptional<Type.TTuple<[Type.TNumber, Type.TNumber]>>;
516
+ step: Type.TOptional<Type.TNumber>;
517
+ }>, Type.TObject<{
518
+ type: Type.TLiteral<"date">;
519
+ instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
520
+ $image: Type.TString;
521
+ }>]>>]>;
522
+ }>, Type.TObject<{
523
+ type: Type.TLiteral<"spans">;
524
+ instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
525
+ $image: Type.TString;
526
+ }>]>>]>;
527
+ max: Type.TOptional<Type.TInteger>;
528
+ }>, Type.TObject<{
529
+ type: Type.TLiteral<"boxes">;
530
+ instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
531
+ $image: Type.TString;
532
+ }>]>>]>;
533
+ max: Type.TOptional<Type.TInteger>;
534
+ }>, Type.TObject<{
535
+ type: Type.TLiteral<"estimate">;
536
+ instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
537
+ $image: Type.TString;
538
+ }>]>>]>;
539
+ range: Type.TTuple<[Type.TNumber, Type.TNumber]>;
540
+ step: Type.TOptional<Type.TNumber>;
541
+ unit: Type.TOptional<Type.TString>;
542
+ }>]>>>;
702
543
  images: Type.TOptional<Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
544
+ id: Type.TString;
545
+ path: Type.TString;
546
+ }>, Type.TObject<{
547
+ id: Type.TString;
548
+ url: Type.TString;
549
+ }>, Type.TObject<{
703
550
  path: Type.TString;
704
551
  rotation: Type.TOptional<Type.TUnion<[Type.TLiteral<0>, Type.TLiteral<90>, Type.TLiteral<180>, Type.TLiteral<270>]>>;
705
552
  }>]>>>;
553
+ media: Type.TOptional<Type.TArray<Type.TObject<{
554
+ type: Type.TUnion<[Type.TLiteral<"audio">, Type.TLiteral<"video">]>;
555
+ path: Type.TString;
556
+ }>>>;
706
557
  documents: Type.TOptional<Type.TArray<Type.TString>>;
707
558
  referenceDate: Type.TOptional<Type.TString>;
708
559
  options: Type.TOptional<Type.TObject<{
709
560
  includeQuantiles: Type.TOptional<Type.TBoolean>;
710
561
  returnStateText: Type.TOptional<Type.TBoolean>;
711
562
  }>>;
563
+ mode: Type.TOptional<Type.TLiteral<"web_grounding">>;
712
564
  }>;
713
565
  export declare const classifyExtractOutput: Type.TObject<{
714
566
  provider: Type.TString;
@@ -782,4 +634,27 @@ export declare const classifyExtractOutput: Type.TObject<{
782
634
  }>>;
783
635
  requestId: Type.TOptional<Type.TString>;
784
636
  stateText: Type.TOptional<Type.TString>;
637
+ citations: Type.TOptional<Type.TArray<Type.TObject<{
638
+ url: Type.TString;
639
+ title: Type.TOptional<Type.TString>;
640
+ excerpts: Type.TOptional<Type.TArray<Type.TString>>;
641
+ }>>>;
642
+ webGrounding: Type.TOptional<Type.TObject<{
643
+ searchResults: Type.TArray<Type.TObject<{
644
+ title: Type.TString;
645
+ url: Type.TString;
646
+ snippet: Type.TString;
647
+ date: Type.TOptional<Type.TString>;
648
+ lastUpdated: Type.TOptional<Type.TString>;
649
+ }>>;
650
+ fetchedResults: Type.TOptional<Type.TArray<Type.TObject<{
651
+ title: Type.TString;
652
+ url: Type.TString;
653
+ snippet: Type.TString;
654
+ }>>>;
655
+ }>>;
656
+ attemptedRoutes: Type.TOptional<Type.TArray<Type.TObject<{
657
+ provider: Type.TString;
658
+ model: Type.TString;
659
+ }>>>;
785
660
  }>;