@abhishek944/pi-classifier 0.0.0-stage → 0.2.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.
@@ -0,0 +1,117 @@
1
+ import { performance } from "node:perf_hooks";
2
+ import { resolveApiKey } from "./auth.js";
3
+ import { configuredDefault, configuredRoutes, resolveModel } from "./config.js";
4
+ import { prepareInput } from "./inputs.js";
5
+ import { classifyWithProvider } from "./providers.js";
6
+ import { ClassifierError, userError, } from "./types.js";
7
+ import { validateParams } from "./validation.js";
8
+ function checkCancelled(signal) {
9
+ if (signal?.aborted)
10
+ throw new ClassifierError("aborted", "Classification was cancelled.");
11
+ }
12
+ function routeKey(route) {
13
+ return JSON.stringify([route.api, route.baseUrl, route.model]);
14
+ }
15
+ function routePair(route) {
16
+ return { provider: route.route, model: route.model };
17
+ }
18
+ async function classifyOnce(input, route, options) {
19
+ checkCancelled(options.signal);
20
+ const prepared = await prepareInput(input, route, options.cwd, options.signal);
21
+ checkCancelled(options.signal);
22
+ const key = resolveApiKey(route);
23
+ const result = await classifyWithProvider(route, prepared, key, options.signal);
24
+ if (Buffer.byteLength(JSON.stringify(result, null, 2)) > 40 * 1024)
25
+ throw new ClassifierError("response", "Classifier result exceeds the 40 KiB tool output limit. Ask fewer questions.");
26
+ return result;
27
+ }
28
+ function permitsFallback(error) {
29
+ return (error instanceof ClassifierError &&
30
+ (error.code === "missing_credentials" ||
31
+ (error.code === "http" && [401, 404, 429].includes(error.httpStatus ?? 0))));
32
+ }
33
+ /** Default plus explicitly configured, selective fallback. Never retries a route. */
34
+ export async function classify(params, options) {
35
+ const input = validateParams(params);
36
+ const candidates = [
37
+ configuredDefault(options.settings),
38
+ ...configuredRoutes(options.settings, "fallback"),
39
+ ];
40
+ const seen = new Set();
41
+ const attemptedRoutes = [];
42
+ let lastError;
43
+ for (const candidate of candidates) {
44
+ checkCancelled(options.signal);
45
+ const route = resolveModel(options.settings, candidate);
46
+ const key = routeKey(route);
47
+ if (seen.has(key))
48
+ continue;
49
+ seen.add(key);
50
+ attemptedRoutes.push(routePair(route));
51
+ try {
52
+ const result = await classifyOnce(input, route, options);
53
+ if (attemptedRoutes.length > 1)
54
+ result.attemptedRoutes = attemptedRoutes;
55
+ return result;
56
+ }
57
+ catch (error) {
58
+ checkCancelled(options.signal);
59
+ if (!permitsFallback(error))
60
+ throw error;
61
+ lastError = error;
62
+ }
63
+ }
64
+ throw lastError;
65
+ }
66
+ /** Explicit comparisons only: configured entries, no default substitution or fallback. */
67
+ export async function compareClassifiers(params, options) {
68
+ const input = validateParams(params);
69
+ const candidates = configuredRoutes(options.settings, "compare");
70
+ if (candidates.length === 0)
71
+ throw new ClassifierError("configuration", "Set pi-classifier.compare to the provider/model pairs you explicitly want to compare. Each entry may incur a charge.");
72
+ const comparison = {
73
+ results: [],
74
+ cancelled: false,
75
+ };
76
+ const seen = new Set();
77
+ for (const candidate of candidates) {
78
+ if (options.signal?.aborted) {
79
+ comparison.cancelled = true;
80
+ break;
81
+ }
82
+ const start = performance.now();
83
+ let selected = candidate;
84
+ try {
85
+ const route = resolveModel(options.settings, candidate);
86
+ selected = routePair(route);
87
+ const key = routeKey(route);
88
+ if (seen.has(key))
89
+ throw new ClassifierError("configuration", "Duplicate comparison endpoint/model was not called again.");
90
+ seen.add(key);
91
+ const result = await classifyOnce(input, route, options);
92
+ comparison.results.push({
93
+ ...selected,
94
+ status: "success",
95
+ result,
96
+ durationMs: performance.now() - start,
97
+ });
98
+ }
99
+ catch (error) {
100
+ comparison.results.push({
101
+ ...selected,
102
+ status: "error",
103
+ error: {
104
+ code: error instanceof ClassifierError ? error.code : "unexpected",
105
+ message: userError(error),
106
+ },
107
+ durationMs: performance.now() - start,
108
+ });
109
+ if (options.signal?.aborted ||
110
+ (error instanceof ClassifierError && error.code === "aborted")) {
111
+ comparison.cancelled = true;
112
+ break;
113
+ }
114
+ }
115
+ }
116
+ return comparison;
117
+ }
@@ -0,0 +1,82 @@
1
+ import { type ClassifierSettings, type ClassifierRoute, type ResolvedModel } from "./types.js";
2
+ export declare const SETTINGS_KEY = "pi-classifier";
3
+ export declare const BUILT_INS: ({
4
+ id: string;
5
+ route: string;
6
+ api: "microsoft-system-one";
7
+ baseUrl: string;
8
+ credentialProvider: string;
9
+ envVar: string;
10
+ models: {
11
+ id: string;
12
+ input: "text"[];
13
+ }[];
14
+ } | {
15
+ id: string;
16
+ route: string;
17
+ api: "openai-decisions";
18
+ baseUrl: string;
19
+ credentialProvider: string;
20
+ envVar: string;
21
+ models: {
22
+ id: string;
23
+ input: ("text" | "image")[];
24
+ }[];
25
+ } | {
26
+ id: string;
27
+ route: string;
28
+ api: "perplexity-decisions";
29
+ baseUrl: string;
30
+ credentialProvider: string;
31
+ envVar: string;
32
+ models: {
33
+ id: string;
34
+ input: ("text" | "image")[];
35
+ }[];
36
+ } | {
37
+ id: string;
38
+ route: string;
39
+ api: "system-one";
40
+ baseUrl: string;
41
+ credentialProvider: string;
42
+ envVar: string;
43
+ models: ({
44
+ id: string;
45
+ input: ("text" | "image")[];
46
+ box?: never;
47
+ } | {
48
+ id: string;
49
+ input: ("text" | "image")[];
50
+ box: true;
51
+ })[];
52
+ } | {
53
+ id: string;
54
+ route: string;
55
+ api: "cloudflare-system-one";
56
+ baseUrl: string;
57
+ credentialProvider: string;
58
+ envVar: string;
59
+ models: ({
60
+ id: string;
61
+ input: ("text" | "image")[];
62
+ } | {
63
+ id: string;
64
+ input?: never;
65
+ })[];
66
+ } | {
67
+ id: string;
68
+ route: string;
69
+ api: "system-one";
70
+ baseUrl: string;
71
+ credentialProvider: string;
72
+ envVar: string;
73
+ models: {
74
+ id: string;
75
+ }[];
76
+ })[];
77
+ export declare function loadClassifierSettings(cwd: string, projectTrusted?: boolean): ClassifierSettings;
78
+ export declare function validateBaseUrl(raw: string): string;
79
+ export declare function configuredDefault(settings: ClassifierSettings): ClassifierRoute;
80
+ export declare function configuredRoutes(settings: ClassifierSettings, field: "fallback" | "compare"): ClassifierRoute[];
81
+ export declare function resolveModel(settings: ClassifierSettings, selected?: ClassifierRoute): ResolvedModel;
82
+ export declare function listModels(settings: ClassifierSettings): string;
package/dist/config.js ADDED
@@ -0,0 +1,298 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { loadPiSettings, resolveConfigDir, } from "@amaster.ai/pi-shared/settings";
5
+ import { cloudflareAccountId } from "./auth.js";
6
+ import { ClassifierError, isRecord, } from "./types.js";
7
+ export const SETTINGS_KEY = "pi-classifier";
8
+ export const BUILT_INS = [
9
+ {
10
+ id: "microsoft",
11
+ route: "microsoft-api",
12
+ api: "microsoft-system-one",
13
+ baseUrl: "",
14
+ credentialProvider: "microsoft",
15
+ envVar: "AZURE_API_KEY",
16
+ models: [{ id: "Microsoft-Decision-1", input: ["text"] }],
17
+ },
18
+ {
19
+ id: "openai",
20
+ route: "openai-api",
21
+ api: "openai-decisions",
22
+ baseUrl: "https://api.openai.com/v1",
23
+ credentialProvider: "openai",
24
+ envVar: "OPENAI_API_KEY",
25
+ models: [{ id: "gpt-6-luna", input: ["text", "image"] }],
26
+ },
27
+ {
28
+ id: "perplexity",
29
+ route: "perplexity-api",
30
+ api: "perplexity-decisions",
31
+ baseUrl: "https://api.perplexity.ai/v1",
32
+ credentialProvider: "perplexity",
33
+ envVar: "PERPLEXITY_API_KEY",
34
+ models: [
35
+ { id: "pplx-decider-v1.1-27b", input: ["text", "image"] },
36
+ { id: "pplx-decider-v1-27b", input: ["text", "image"] },
37
+ ],
38
+ },
39
+ {
40
+ id: "typesafe",
41
+ route: "typesafe-api",
42
+ api: "system-one",
43
+ baseUrl: "https://api.typesafe.ai/v1",
44
+ credentialProvider: "typesafe",
45
+ envVar: "TYPESAFE_API_KEY",
46
+ models: [
47
+ { id: "jev-latest", input: ["text", "image"] },
48
+ { id: "jev-1.13.0", input: ["text", "image"] },
49
+ { id: "jev-preview", input: ["text", "image"], box: true },
50
+ { id: "jev-1.14.0", input: ["text", "image"], box: true },
51
+ ],
52
+ },
53
+ {
54
+ id: "cloudflare",
55
+ route: "cloudflare-api",
56
+ api: "cloudflare-system-one",
57
+ baseUrl: "",
58
+ credentialProvider: "cloudflare-workers-ai",
59
+ envVar: "CLOUDFLARE_API_KEY",
60
+ models: [
61
+ { id: "@cf/cloudflare/clef", input: ["text", "image"] },
62
+ { id: "@cf/cloudflare/clef-flash", input: ["text", "image"] },
63
+ { id: "typesafe/jev" },
64
+ ],
65
+ },
66
+ {
67
+ id: "openrouter",
68
+ route: "openrouter-api",
69
+ api: "system-one",
70
+ baseUrl: "https://openrouter.ai/api/v1",
71
+ credentialProvider: "openrouter",
72
+ envVar: "OPENROUTER_API_KEY",
73
+ models: [{ id: "typesafe/jev-1.13" }, { id: "~typesafe/jev-latest" }],
74
+ },
75
+ ];
76
+ export function loadClassifierSettings(cwd, projectTrusted = false) {
77
+ try {
78
+ // The shared loader is forgiving; malformed layers must not silently select a different route.
79
+ const paths = new Set([
80
+ join(resolveConfigDir(join(homedir(), ".pi", "agent")), "settings.json"),
81
+ join(resolveConfigDir(), "settings.json"),
82
+ ...(projectTrusted ? [join(cwd, ".pi", "settings.json")] : []),
83
+ ]);
84
+ for (const path of paths)
85
+ validateSettingsLayer(path);
86
+ const settings = loadPiSettings(SETTINGS_KEY, {
87
+ cwd,
88
+ projectTrusted,
89
+ strictProjectSettings: true,
90
+ });
91
+ if (!isRecord(settings))
92
+ throw new Error();
93
+ return settings;
94
+ }
95
+ catch (error) {
96
+ if (error instanceof ClassifierError)
97
+ throw error;
98
+ throw new ClassifierError("configuration", "Could not load pi-classifier settings. Check that the namespace contains a valid JSON object.");
99
+ }
100
+ }
101
+ function validateSettingsLayer(path) {
102
+ let text;
103
+ try {
104
+ text = readFileSync(path, "utf8");
105
+ }
106
+ catch (error) {
107
+ if (error.code === "ENOENT")
108
+ return;
109
+ throw error;
110
+ }
111
+ if (text.charCodeAt(0) === 0xfeff)
112
+ configuration("pi-classifier settings require UTF-8 without a BOM. Remove the BOM from settings.json; no alternate configuration was used.");
113
+ const root = JSON.parse(text);
114
+ if (!isRecord(root) ||
115
+ (Object.hasOwn(root, SETTINGS_KEY) && !isRecord(root[SETTINGS_KEY])))
116
+ configuration("Settings and the pi-classifier namespace must be JSON objects, not null or arrays.");
117
+ }
118
+ function configuration(message) {
119
+ throw new ClassifierError("configuration", message);
120
+ }
121
+ export function validateBaseUrl(raw) {
122
+ try {
123
+ const url = new URL(raw);
124
+ const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
125
+ if ((url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) ||
126
+ url.username ||
127
+ url.password ||
128
+ url.search ||
129
+ url.hash)
130
+ throw new Error();
131
+ return url.toString().replace(/\/+$/, "");
132
+ }
133
+ catch {
134
+ return configuration("Provider baseUrl must be HTTPS (or loopback HTTP), without credentials, query or fragment.");
135
+ }
136
+ }
137
+ function optionalString(value, field) {
138
+ if (value === undefined)
139
+ return undefined;
140
+ if (typeof value !== "string" || !value.trim())
141
+ return configuration(field + " must be a non-empty string.");
142
+ return value.trim();
143
+ }
144
+ function headers(value) {
145
+ if (value === undefined)
146
+ return {};
147
+ if (!isRecord(value) ||
148
+ Object.entries(value).some(([key, entry]) => !/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(key) ||
149
+ typeof entry !== "string" ||
150
+ /[\r\n]/.test(entry))) {
151
+ return configuration("Provider headers must be a string map with valid HTTP header names and values.");
152
+ }
153
+ const protectedNames = [
154
+ "authorization",
155
+ "api-key",
156
+ "content-type",
157
+ "content-length",
158
+ "host",
159
+ "cookie",
160
+ "proxy-authorization",
161
+ "transfer-encoding",
162
+ "connection",
163
+ ];
164
+ if (Object.values(value).some((entry) => typeof entry === "string" && /\$\{?[A-Z_]/.test(entry)))
165
+ return configuration("Resolve header environment references in global settings, not project settings.");
166
+ if (Object.keys(value).some((key) => protectedNames.includes(key.toLowerCase())))
167
+ return configuration("Authentication and transport headers cannot be overridden.");
168
+ return value;
169
+ }
170
+ export function configuredDefault(settings) {
171
+ if (settings.default !== undefined)
172
+ return routePair(settings.default, "default");
173
+ return routePair({ provider: settings.defaultProvider, model: settings.defaultModel }, "defaultProvider/defaultModel");
174
+ }
175
+ function routePair(value, field) {
176
+ if (!isRecord(value))
177
+ return configuration(field + " must be a provider/model pair.");
178
+ const provider = optionalString(value.provider, field + ".provider");
179
+ const model = optionalString(value.model, field + ".model");
180
+ if (!provider || !model)
181
+ return configuration(field + " requires provider and model.");
182
+ return { provider, model };
183
+ }
184
+ export function configuredRoutes(settings, field) {
185
+ const value = settings[field];
186
+ if (value === undefined)
187
+ return [];
188
+ if (!Array.isArray(value))
189
+ return configuration(field + " must be an array of provider/model pairs.");
190
+ return value.map((entry, index) => routePair(entry, field + "[" + index + "]"));
191
+ }
192
+ export function resolveModel(settings, selected = configuredDefault(settings)) {
193
+ const { provider: routeId, model: modelId } = routePair(selected, "route");
194
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(routeId) ||
195
+ modelId.length > 256 ||
196
+ /[\u0000-\u001f\u007f]/.test(modelId))
197
+ return configuration("Provider routes must be short identifiers and model IDs must be at most 256 characters without control characters.");
198
+ const builtIn = BUILT_INS.find((entry) => entry.route === routeId || entry.id === routeId);
199
+ if (settings.providers !== undefined && !isRecord(settings.providers))
200
+ return configuration("providers must be an object.");
201
+ if (settings.customProviders !== undefined &&
202
+ !isRecord(settings.customProviders))
203
+ return configuration("customProviders must be an object.");
204
+ for (const name of Object.keys(settings.customProviders ?? {})) {
205
+ if (BUILT_INS.some((entry) => entry.route === name || entry.id === name))
206
+ return configuration("Custom providers cannot shadow built-in routes.");
207
+ }
208
+ const custom = builtIn ? undefined : settings.customProviders?.[routeId];
209
+ if (!builtIn && !custom)
210
+ return configuration("Unknown classifier provider route.");
211
+ const raw = builtIn
212
+ ? (settings.providers?.[builtIn.id] ?? {})
213
+ : custom;
214
+ if (!isRecord(raw))
215
+ return configuration("Provider settings must be an object.");
216
+ const api = builtIn?.api ?? custom.api;
217
+ if (![
218
+ "openai-decisions",
219
+ "perplexity-decisions",
220
+ "system-one",
221
+ "cloudflare-system-one",
222
+ "microsoft-system-one",
223
+ ].includes(api))
224
+ return configuration("Unsupported classifier API protocol.");
225
+ const models = builtIn?.models ?? custom.models;
226
+ if (!Array.isArray(models) ||
227
+ models.length === 0 ||
228
+ models.some((m) => !isRecord(m) ||
229
+ typeof m.id !== "string" ||
230
+ !m.id.trim() ||
231
+ (m.input !== undefined &&
232
+ (!Array.isArray(m.input) ||
233
+ m.input.some((x) => x !== "text" && x !== "image"))) ||
234
+ (m.box !== undefined && typeof m.box !== "boolean"))) {
235
+ return configuration("Provider models must declare an id and optional text/image input capabilities.");
236
+ }
237
+ const definition = models.find((entry) => entry.id === modelId);
238
+ // Built-in API routes allow new text model IDs without a package release. Images require known capabilities.
239
+ if (!definition && !builtIn)
240
+ return configuration("The selected model is not declared in customProviders.<id>.models.");
241
+ for (const flag of ["experimentalImages", "experimentalBox"]) {
242
+ if (raw[flag] !== undefined && typeof raw[flag] !== "boolean")
243
+ return configuration(flag + " must be a boolean.");
244
+ }
245
+ let baseUrl = optionalString(raw.baseUrl, "baseUrl") ?? builtIn?.baseUrl;
246
+ if (api === "cloudflare-system-one" && !baseUrl)
247
+ baseUrl =
248
+ "https://api.cloudflare.com/client/v4/accounts/" +
249
+ cloudflareAccountId(optionalString(raw.accountId, "accountId")) +
250
+ "/ai";
251
+ if (!baseUrl)
252
+ return configuration("The selected provider requires a baseUrl. Microsoft uses your Foundry resource endpoint.");
253
+ const timeout = settings.requestTimeoutMs ?? 30_000;
254
+ if (!Number.isInteger(timeout) || timeout < 100 || timeout > 300_000)
255
+ return configuration("requestTimeoutMs must be between 100 and 300000.");
256
+ if (raw.apiKey !== undefined && typeof raw.apiKey !== "string")
257
+ return configuration("apiKey must be a string.");
258
+ const configuredApiKey = typeof raw.apiKey === "string" ? raw.apiKey.trim() || undefined : undefined;
259
+ if (configuredApiKey && /\$\{?|^!/.test(configuredApiKey))
260
+ return configuration("API-key references must be resolved in global settings; project settings cannot expand environment variables or execute commands.");
261
+ const isJevDirect = builtIn?.id === "typesafe";
262
+ const result = {
263
+ route: builtIn?.route ?? routeId,
264
+ provider: builtIn?.id ?? routeId,
265
+ model: modelId,
266
+ api,
267
+ baseUrl: validateBaseUrl(baseUrl),
268
+ headers: headers(raw.headers),
269
+ credentialProvider: builtIn?.credentialProvider ?? routeId,
270
+ images: api === "microsoft-system-one"
271
+ ? false
272
+ : api === "system-one"
273
+ ? Boolean(raw.experimentalImages && definition?.input?.includes("image"))
274
+ : Boolean(definition?.input?.includes("image")),
275
+ box: Boolean((isJevDirect || custom?.api === "system-one") &&
276
+ definition?.box &&
277
+ definition?.input?.includes("image") &&
278
+ raw.experimentalBox &&
279
+ raw.experimentalImages),
280
+ experimentalImages: raw.experimentalImages === true,
281
+ requestTimeoutMs: timeout,
282
+ };
283
+ if (configuredApiKey)
284
+ result.configuredApiKey = configuredApiKey;
285
+ if (builtIn?.envVar)
286
+ result.envVar = builtIn.envVar;
287
+ return result;
288
+ }
289
+ export function listModels(settings) {
290
+ const lines = BUILT_INS.flatMap((provider) => provider.models.map((model) => provider.route + " " + model.id));
291
+ for (const [id, provider] of Object.entries(settings.customProviders ?? {})) {
292
+ if (Array.isArray(provider?.models))
293
+ for (const model of provider.models)
294
+ if (typeof model?.id === "string")
295
+ lines.push(JSON.stringify(id) + " " + JSON.stringify(model.id));
296
+ }
297
+ return lines.join("\n");
298
+ }
@@ -0,0 +1,122 @@
1
+ import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import { Type } from "typebox";
3
+ export declare const classifyParameters: Type.TObject<{
4
+ state: Type.TUnion<[Type.TString, Type.TRecord<"^.*$", Type.TUnknown>, Type.TArray<Type.TUnknown>]>;
5
+ questions: Type.TRecord<"^.*$", Type.TUnion<[Type.TObject<{
6
+ type: Type.TLiteral<"bool">;
7
+ instructions: Type.TString;
8
+ criteria: Type.TOptional<Type.TObject<{
9
+ true: Type.TOptional<Type.TString>;
10
+ false: Type.TOptional<Type.TString>;
11
+ }>>;
12
+ }>, Type.TObject<{
13
+ type: Type.TLiteral<"choice">;
14
+ instructions: Type.TString;
15
+ criteria: Type.TRecord<"^.*$", Type.TString>;
16
+ }>, Type.TObject<{
17
+ type: Type.TLiteral<"score">;
18
+ instructions: Type.TString;
19
+ criteria: Type.TArray<Type.TString>;
20
+ }>, Type.TObject<{
21
+ type: Type.TLiteral<"box">;
22
+ instructions: Type.TString;
23
+ }>]>>;
24
+ images: Type.TOptional<Type.TArray<Type.TString>>;
25
+ }>;
26
+ export declare const classifyOutput: Type.TObject<{
27
+ provider: Type.TString;
28
+ model: Type.TString;
29
+ answers: Type.TRecord<"^.*$", Type.TUnion<[Type.TObject<{
30
+ type: Type.TLiteral<"bool">;
31
+ probability: Type.TNumber;
32
+ }>, Type.TObject<{
33
+ type: Type.TLiteral<"choice">;
34
+ choice: Type.TString;
35
+ probabilities: Type.TRecord<"^.*$", Type.TNumber>;
36
+ confidence: Type.TNumber;
37
+ }>, Type.TObject<{
38
+ type: Type.TLiteral<"score">;
39
+ score: Type.TNumber;
40
+ confidence: Type.TNumber;
41
+ probabilities: Type.TOptional<Type.TRecord<"^.*$", Type.TNumber>>;
42
+ }>, Type.TObject<{
43
+ type: Type.TLiteral<"box">;
44
+ box: Type.TObject<{
45
+ top: Type.TNumber;
46
+ bottom: Type.TNumber;
47
+ left: Type.TNumber;
48
+ right: Type.TNumber;
49
+ }>;
50
+ confidence: Type.TNumber;
51
+ }>, Type.TObject<{
52
+ type: Type.TLiteral<"refusal">;
53
+ }>]>>;
54
+ usage: Type.TOptional<Type.TObject<{
55
+ inputTokens: Type.TNumber;
56
+ outputTokens: Type.TNumber;
57
+ totalTokens: Type.TNumber;
58
+ }>>;
59
+ requestId: Type.TOptional<Type.TString>;
60
+ attemptedRoutes: Type.TOptional<Type.TArray<Type.TObject<{
61
+ provider: Type.TString;
62
+ model: Type.TString;
63
+ }>>>;
64
+ }>;
65
+ export declare const classifyCompareOutput: Type.TObject<{
66
+ cancelled: Type.TBoolean;
67
+ results: Type.TArray<Type.TUnion<[Type.TObject<{
68
+ provider: Type.TString;
69
+ model: Type.TString;
70
+ durationMs: Type.TNumber;
71
+ status: Type.TLiteral<"success">;
72
+ result: Type.TObject<{
73
+ provider: Type.TString;
74
+ model: Type.TString;
75
+ answers: Type.TRecord<"^.*$", Type.TUnion<[Type.TObject<{
76
+ type: Type.TLiteral<"bool">;
77
+ probability: Type.TNumber;
78
+ }>, Type.TObject<{
79
+ type: Type.TLiteral<"choice">;
80
+ choice: Type.TString;
81
+ probabilities: Type.TRecord<"^.*$", Type.TNumber>;
82
+ confidence: Type.TNumber;
83
+ }>, Type.TObject<{
84
+ type: Type.TLiteral<"score">;
85
+ score: Type.TNumber;
86
+ confidence: Type.TNumber;
87
+ probabilities: Type.TOptional<Type.TRecord<"^.*$", Type.TNumber>>;
88
+ }>, Type.TObject<{
89
+ type: Type.TLiteral<"box">;
90
+ box: Type.TObject<{
91
+ top: Type.TNumber;
92
+ bottom: Type.TNumber;
93
+ left: Type.TNumber;
94
+ right: Type.TNumber;
95
+ }>;
96
+ confidence: Type.TNumber;
97
+ }>, Type.TObject<{
98
+ type: Type.TLiteral<"refusal">;
99
+ }>]>>;
100
+ usage: Type.TOptional<Type.TObject<{
101
+ inputTokens: Type.TNumber;
102
+ outputTokens: Type.TNumber;
103
+ totalTokens: Type.TNumber;
104
+ }>>;
105
+ requestId: Type.TOptional<Type.TString>;
106
+ attemptedRoutes: Type.TOptional<Type.TArray<Type.TObject<{
107
+ provider: Type.TString;
108
+ model: Type.TString;
109
+ }>>>;
110
+ }>;
111
+ }>, Type.TObject<{
112
+ provider: Type.TString;
113
+ model: Type.TString;
114
+ durationMs: Type.TNumber;
115
+ status: Type.TLiteral<"error">;
116
+ error: Type.TObject<{
117
+ code: Type.TString;
118
+ message: Type.TString;
119
+ }>;
120
+ }>]>>;
121
+ }>;
122
+ export default function piClassifier(pi: ExtensionAPI): void;