@abhishek944/pi-classifier 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +269 -31
- package/dist/auth.d.ts +4 -2
- package/dist/auth.js +18 -2
- package/dist/box-tool.d.ts +2 -24
- package/dist/box-tool.js +5 -35
- package/dist/choices.js +35 -1
- package/dist/classify.d.ts +3 -0
- package/dist/classify.js +3 -3
- package/dist/config.d.ts +140 -3
- package/dist/config.js +401 -20
- package/dist/cost.js +42 -4
- package/dist/durable.d.ts +34 -0
- package/dist/durable.js +237 -0
- package/dist/extension.d.ts +2 -275
- package/dist/extension.js +49 -211
- package/dist/extract.d.ts +11 -0
- package/dist/extract.js +191 -0
- package/dist/http.d.ts +6 -1
- package/dist/http.js +64 -28
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/inputs.d.ts +16 -1
- package/dist/inputs.js +421 -14
- package/dist/mcp-cli.d.ts +2 -0
- package/dist/mcp-cli.js +39 -0
- package/dist/mcp-server.d.ts +28 -0
- package/dist/mcp-server.js +121 -0
- package/dist/mcp-tool-definitions.d.ts +19 -0
- package/dist/mcp-tool-definitions.js +64 -0
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +1144 -53
- package/dist/tool-contracts.d.ts +785 -0
- package/dist/tool-contracts.js +530 -0
- package/dist/tree.js +1 -1
- package/dist/types.d.ts +284 -8
- package/dist/validation.js +122 -10
- package/package.json +34 -6
- package/src/auth.ts +26 -2
- package/src/box-tool.ts +12 -47
- package/src/choices.ts +42 -1
- package/src/classify.ts +6 -4
- package/src/config.ts +450 -23
- package/src/cost.ts +42 -4
- package/src/durable.ts +298 -0
- package/src/extension.ts +75 -288
- package/src/extract.ts +228 -0
- package/src/http.ts +63 -32
- package/src/index.ts +15 -0
- package/src/inputs.ts +454 -13
- package/src/mcp-cli.ts +44 -0
- package/src/mcp-server.ts +179 -0
- package/src/mcp-tool-definitions.ts +104 -0
- package/src/providers.ts +1323 -56
- package/src/tool-contracts.ts +785 -0
- package/src/tree.ts +1 -1
- package/src/types.ts +231 -5
- package/src/validation.ts +114 -9
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Extension } from "@earendil-works/pi-durable";
|
|
2
|
+
import { type ClassifierSettings } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Settings-only native Durable classifier extension.
|
|
5
|
+
*
|
|
6
|
+
* The factory accepts ordinary serializable settings at initialization and uses the
|
|
7
|
+
* existing Node provider and file handling internally (the same operations as the
|
|
8
|
+
* desktop entry). There are no admission, quota, authorization, credential-store, or
|
|
9
|
+
* host callbacks: the model only supplies classification arguments, never a provider,
|
|
10
|
+
* endpoint, credential, or local path outside the working directory.
|
|
11
|
+
*
|
|
12
|
+
* Provider credentials must be explicit: `providers.<id>.apiKey` (and
|
|
13
|
+
* `providers.cloudflare.accountId` for Cloudflare) or the provider environment
|
|
14
|
+
* variable. The native path never reads Pi settings files or Pi's stored API-key
|
|
15
|
+
* credentials; it fails closed with the existing actionable error when no explicit
|
|
16
|
+
* credential resolves.
|
|
17
|
+
*
|
|
18
|
+
* Per-call files (tree JSON, local images) resolve under `options.cwd`, the Durable
|
|
19
|
+
* environment cwd, the conversation agent `cwd`, or the process cwd (in that order).
|
|
20
|
+
* Cancellation follows the invocation `context.abortSignal`.
|
|
21
|
+
*
|
|
22
|
+
* `classifier_computer_use` is intentionally not registered here. It needs to invoke
|
|
23
|
+
* the Cua Driver MCP tools between classifier decisions, and Durable 1.1.0 exposes no
|
|
24
|
+
* generic tool-invocation API (a tool task requires an existing assistant entry and
|
|
25
|
+
* call id), so the loop cannot run natively. No placeholder tool is shipped; use the
|
|
26
|
+
* desktop extension for computer use.
|
|
27
|
+
*/
|
|
28
|
+
export type DurableClassifierOptions = {
|
|
29
|
+
/** Preferred working directory; falls back to the Durable environment cwd, the conversation agent cwd, then the process cwd. */
|
|
30
|
+
cwd?: string;
|
|
31
|
+
};
|
|
32
|
+
/** Native classifier tools through the existing operations with explicit credentials only. */
|
|
33
|
+
export declare function createClassifierExtension(settings: ClassifierSettings, options?: DurableClassifierOptions): Extension;
|
|
34
|
+
export type { ToolExecutionResult } from "@earendil-works/pi-durable";
|
package/dist/durable.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { defineExtension, defineTool } from "@earendil-works/pi-durable";
|
|
2
|
+
import { classify, compareClassifiers } from "./classify.js";
|
|
3
|
+
import { classifyTree } from "./tree.js";
|
|
4
|
+
import { extract } from "./extract.js";
|
|
5
|
+
import { renderClassifierBox } from "./box.js";
|
|
6
|
+
import { CLASSIFIER_BOX_TOOL, CLASSIFY_EXTRACT_TOOL, CLASSIFY_EXTRACT_TOOL_DESCRIPTION, classifyExtractParameters, CLASSIFIER_BOX_TOOL_DESCRIPTION, CLASSIFY_COMPARE_TOOL, CLASSIFY_COMPARE_TOOL_DESCRIPTION, CLASSIFY_TOOL, CLASSIFY_TOOL_DESCRIPTION, CLASSIFY_TREE_TOOL, CLASSIFY_TREE_TOOL_DESCRIPTION, boxParameters, classifyParameters, classifyTreeParameters, } from "./tool-contracts.js";
|
|
7
|
+
import { userError } from "./types.js";
|
|
8
|
+
/** Settings are plain data: clone once, then deep-freeze so calls cannot observe later mutation. */
|
|
9
|
+
function freezeSettings(settings) {
|
|
10
|
+
const copy = structuredClone(settings);
|
|
11
|
+
const freeze = (node) => {
|
|
12
|
+
if (!node || typeof node !== "object")
|
|
13
|
+
return;
|
|
14
|
+
for (const child of Object.values(node))
|
|
15
|
+
freeze(child);
|
|
16
|
+
Object.freeze(node);
|
|
17
|
+
};
|
|
18
|
+
freeze(copy);
|
|
19
|
+
return copy;
|
|
20
|
+
}
|
|
21
|
+
async function resolveCwd(api, context, configured) {
|
|
22
|
+
if (configured?.trim())
|
|
23
|
+
return configured;
|
|
24
|
+
const envCwd = api.env?.cwd;
|
|
25
|
+
if (typeof envCwd === "string" && envCwd.trim())
|
|
26
|
+
return envCwd;
|
|
27
|
+
try {
|
|
28
|
+
const agent = await api.agent(context);
|
|
29
|
+
if (agent.cwd?.trim())
|
|
30
|
+
return agent.cwd;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Agent metadata is observational; fall through to the process cwd.
|
|
34
|
+
}
|
|
35
|
+
return process.cwd();
|
|
36
|
+
}
|
|
37
|
+
function toJson(value) {
|
|
38
|
+
return JSON.parse(JSON.stringify(value));
|
|
39
|
+
}
|
|
40
|
+
/** Native classifier tools through the existing operations with explicit credentials only. */
|
|
41
|
+
export function createClassifierExtension(settings, options = {}) {
|
|
42
|
+
const frozenSettings = freezeSettings(settings);
|
|
43
|
+
const { cwd: configuredCwd } = options;
|
|
44
|
+
const classifyTool = defineTool({
|
|
45
|
+
name: CLASSIFY_TOOL,
|
|
46
|
+
description: CLASSIFY_TOOL_DESCRIPTION,
|
|
47
|
+
parameters: classifyParameters,
|
|
48
|
+
replay: "unsafe",
|
|
49
|
+
executionMode: "parallel",
|
|
50
|
+
async execute(args, api, context) {
|
|
51
|
+
const cwd = await resolveCwd(api, context, configuredCwd);
|
|
52
|
+
try {
|
|
53
|
+
const result = await classify(args, {
|
|
54
|
+
settings: frozenSettings,
|
|
55
|
+
cwd,
|
|
56
|
+
credentialSource: "explicit",
|
|
57
|
+
...(context.abortSignal ? { signal: context.abortSignal } : {}),
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
61
|
+
details: toJson(result),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
isError: true,
|
|
67
|
+
content: [
|
|
68
|
+
{ type: "text", text: "classify failed: " + userError(error) },
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
const compareTool = defineTool({
|
|
75
|
+
name: CLASSIFY_COMPARE_TOOL,
|
|
76
|
+
description: CLASSIFY_COMPARE_TOOL_DESCRIPTION,
|
|
77
|
+
parameters: classifyParameters,
|
|
78
|
+
replay: "unsafe",
|
|
79
|
+
executionMode: "parallel",
|
|
80
|
+
async execute(args, api, context) {
|
|
81
|
+
const cwd = await resolveCwd(api, context, configuredCwd);
|
|
82
|
+
try {
|
|
83
|
+
const result = await compareClassifiers(args, {
|
|
84
|
+
settings: frozenSettings,
|
|
85
|
+
cwd,
|
|
86
|
+
credentialSource: "explicit",
|
|
87
|
+
...(context.abortSignal ? { signal: context.abortSignal } : {}),
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
91
|
+
details: toJson(result),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
return {
|
|
96
|
+
isError: true,
|
|
97
|
+
content: [
|
|
98
|
+
{
|
|
99
|
+
type: "text",
|
|
100
|
+
text: "classify_compare failed: " + userError(error),
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
const treeTool = defineTool({
|
|
108
|
+
name: CLASSIFY_TREE_TOOL,
|
|
109
|
+
description: CLASSIFY_TREE_TOOL_DESCRIPTION,
|
|
110
|
+
parameters: classifyTreeParameters,
|
|
111
|
+
replay: "unsafe",
|
|
112
|
+
executionMode: "parallel",
|
|
113
|
+
async execute(args, api, context) {
|
|
114
|
+
const cwd = await resolveCwd(api, context, configuredCwd);
|
|
115
|
+
try {
|
|
116
|
+
const result = await classifyTree(args, {
|
|
117
|
+
settings: frozenSettings,
|
|
118
|
+
cwd,
|
|
119
|
+
credentialSource: "explicit",
|
|
120
|
+
...(context.abortSignal ? { signal: context.abortSignal } : {}),
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
124
|
+
details: toJson(result),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
return {
|
|
129
|
+
isError: true,
|
|
130
|
+
content: [
|
|
131
|
+
{ type: "text", text: "classify_tree failed: " + userError(error) },
|
|
132
|
+
],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
const extractTool = defineTool({
|
|
138
|
+
name: CLASSIFY_EXTRACT_TOOL,
|
|
139
|
+
description: CLASSIFY_EXTRACT_TOOL_DESCRIPTION,
|
|
140
|
+
parameters: classifyExtractParameters,
|
|
141
|
+
replay: "unsafe",
|
|
142
|
+
executionMode: "parallel",
|
|
143
|
+
async execute(args, api, context) {
|
|
144
|
+
const cwd = await resolveCwd(api, context, configuredCwd);
|
|
145
|
+
try {
|
|
146
|
+
const result = await extract(args, {
|
|
147
|
+
settings: frozenSettings,
|
|
148
|
+
cwd,
|
|
149
|
+
credentialSource: "explicit",
|
|
150
|
+
...(context.abortSignal ? { signal: context.abortSignal } : {}),
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
154
|
+
details: toJson(result),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
return {
|
|
159
|
+
isError: true,
|
|
160
|
+
content: [{ type: "text", text: "classify_extract failed: " + userError(error) }],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
const boxTool = defineTool({
|
|
166
|
+
name: CLASSIFIER_BOX_TOOL,
|
|
167
|
+
description: CLASSIFIER_BOX_TOOL_DESCRIPTION,
|
|
168
|
+
parameters: boxParameters,
|
|
169
|
+
// Pure local render: no provider request, upload, or disk write, so recovery may rerun it.
|
|
170
|
+
replay: "safe",
|
|
171
|
+
executionMode: "parallel",
|
|
172
|
+
async execute(args, api, context) {
|
|
173
|
+
const cwd = await resolveCwd(api, context, configuredCwd);
|
|
174
|
+
try {
|
|
175
|
+
const result = await renderClassifierBox(args, {
|
|
176
|
+
cwd,
|
|
177
|
+
...(context.abortSignal ? { signal: context.abortSignal } : {}),
|
|
178
|
+
});
|
|
179
|
+
const byteLength = Buffer.from(result.data, "base64").byteLength;
|
|
180
|
+
const details = {
|
|
181
|
+
mode: result.mode,
|
|
182
|
+
mimeType: result.mimeType,
|
|
183
|
+
width: result.width,
|
|
184
|
+
height: result.height,
|
|
185
|
+
pixelBox: { ...result.pixelBox },
|
|
186
|
+
byteLength,
|
|
187
|
+
};
|
|
188
|
+
const box = result.pixelBox;
|
|
189
|
+
return {
|
|
190
|
+
content: [
|
|
191
|
+
{
|
|
192
|
+
type: "text",
|
|
193
|
+
text: "Rendered " +
|
|
194
|
+
result.mode +
|
|
195
|
+
" box as a " +
|
|
196
|
+
result.width +
|
|
197
|
+
"×" +
|
|
198
|
+
result.height +
|
|
199
|
+
" PNG (" +
|
|
200
|
+
byteLength +
|
|
201
|
+
" bytes). Source pixel box: left=" +
|
|
202
|
+
box.left +
|
|
203
|
+
", top=" +
|
|
204
|
+
box.top +
|
|
205
|
+
", width=" +
|
|
206
|
+
box.width +
|
|
207
|
+
", height=" +
|
|
208
|
+
box.height +
|
|
209
|
+
". A box is a localization hint, not proof that the object exists.",
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
type: "image",
|
|
213
|
+
data: result.data,
|
|
214
|
+
mimeType: result.mimeType,
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
details: toJson(details),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
return {
|
|
222
|
+
isError: true,
|
|
223
|
+
content: [
|
|
224
|
+
{
|
|
225
|
+
type: "text",
|
|
226
|
+
text: "classifier_box_image failed: " + userError(error),
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
return defineExtension({
|
|
234
|
+
name: "classifier",
|
|
235
|
+
tools: [classifyTool, compareTool, treeTool, extractTool, boxTool],
|
|
236
|
+
});
|
|
237
|
+
}
|
package/dist/extension.d.ts
CHANGED
|
@@ -1,277 +1,4 @@
|
|
|
1
1
|
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
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.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
|
|
8
|
-
$image: Type.TString;
|
|
9
|
-
}>]>>]>;
|
|
10
|
-
criteria: Type.TOptional<Type.TObject<{
|
|
11
|
-
true: Type.TOptional<Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
|
|
12
|
-
$image: Type.TString;
|
|
13
|
-
}>]>>]>>;
|
|
14
|
-
false: Type.TOptional<Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
|
|
15
|
-
$image: Type.TString;
|
|
16
|
-
}>]>>]>>;
|
|
17
|
-
}>>;
|
|
18
|
-
}>, Type.TObject<{
|
|
19
|
-
type: Type.TLiteral<"choice">;
|
|
20
|
-
instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
|
|
21
|
-
$image: Type.TString;
|
|
22
|
-
}>]>>]>;
|
|
23
|
-
criteria: Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
|
|
24
|
-
$image: Type.TString;
|
|
25
|
-
}>]>>]>>;
|
|
26
|
-
}>, Type.TObject<{
|
|
27
|
-
type: Type.TLiteral<"score">;
|
|
28
|
-
instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
|
|
29
|
-
$image: Type.TString;
|
|
30
|
-
}>]>>]>;
|
|
31
|
-
criteria: Type.TArray<Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
|
|
32
|
-
$image: Type.TString;
|
|
33
|
-
}>]>>]>>;
|
|
34
|
-
}>, Type.TObject<{
|
|
35
|
-
type: Type.TLiteral<"box">;
|
|
36
|
-
instructions: Type.TUnion<[Type.TString, Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
|
|
37
|
-
$image: Type.TString;
|
|
38
|
-
}>]>>]>;
|
|
39
|
-
}>]>>;
|
|
40
|
-
images: Type.TOptional<Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
|
|
41
|
-
id: Type.TString;
|
|
42
|
-
path: Type.TString;
|
|
43
|
-
}>, Type.TObject<{
|
|
44
|
-
id: Type.TString;
|
|
45
|
-
url: Type.TString;
|
|
46
|
-
}>]>>>;
|
|
47
|
-
}>;
|
|
48
|
-
export declare const classifyOutput: Type.TObject<{
|
|
49
|
-
provider: Type.TString;
|
|
50
|
-
model: Type.TString;
|
|
51
|
-
answers: Type.TRecord<"^.*$", Type.TUnion<[Type.TObject<{
|
|
52
|
-
type: Type.TLiteral<"bool">;
|
|
53
|
-
probability: Type.TNumber;
|
|
54
|
-
}>, Type.TObject<{
|
|
55
|
-
type: Type.TLiteral<"choice">;
|
|
56
|
-
choice: Type.TString;
|
|
57
|
-
probabilities: Type.TRecord<"^.*$", Type.TNumber>;
|
|
58
|
-
confidence: Type.TNumber;
|
|
59
|
-
probabilityScope: Type.TOptional<Type.TLiteral<"batch">>;
|
|
60
|
-
noneOfAboveProbability: Type.TOptional<Type.TNumber>;
|
|
61
|
-
}>, Type.TObject<{
|
|
62
|
-
type: Type.TLiteral<"score">;
|
|
63
|
-
score: Type.TNumber;
|
|
64
|
-
confidence: Type.TNumber;
|
|
65
|
-
probabilities: Type.TOptional<Type.TRecord<"^.*$", Type.TNumber>>;
|
|
66
|
-
}>, Type.TObject<{
|
|
67
|
-
type: Type.TLiteral<"box">;
|
|
68
|
-
box: Type.TObject<{
|
|
69
|
-
top: Type.TNumber;
|
|
70
|
-
bottom: Type.TNumber;
|
|
71
|
-
left: Type.TNumber;
|
|
72
|
-
right: Type.TNumber;
|
|
73
|
-
}>;
|
|
74
|
-
confidence: Type.TNumber;
|
|
75
|
-
}>, Type.TObject<{
|
|
76
|
-
type: Type.TLiteral<"refusal">;
|
|
77
|
-
}>, Type.TObject<{
|
|
78
|
-
type: Type.TLiteral<"no_match">;
|
|
79
|
-
}>, Type.TObject<{
|
|
80
|
-
type: Type.TLiteral<"ambiguous">;
|
|
81
|
-
}>]>>;
|
|
82
|
-
providerCalls: Type.TOptional<Type.TInteger>;
|
|
83
|
-
usage: Type.TOptional<Type.TObject<{
|
|
84
|
-
inputTokens: Type.TNumber;
|
|
85
|
-
outputTokens: Type.TNumber;
|
|
86
|
-
totalTokens: Type.TNumber;
|
|
87
|
-
cachedInputTokens: Type.TOptional<Type.TNumber>;
|
|
88
|
-
cacheWriteTokens: Type.TOptional<Type.TNumber>;
|
|
89
|
-
}>>;
|
|
90
|
-
cost: Type.TUnion<[Type.TObject<{
|
|
91
|
-
status: Type.TLiteral<"estimated">;
|
|
92
|
-
currency: Type.TLiteral<"USD">;
|
|
93
|
-
input: Type.TNumber;
|
|
94
|
-
output: Type.TNumber;
|
|
95
|
-
total: Type.TNumber;
|
|
96
|
-
source: Type.TUnion<[Type.TLiteral<"builtin">, Type.TLiteral<"configured">]>;
|
|
97
|
-
rates: Type.TObject<{
|
|
98
|
-
inputPerMillion: Type.TNumber;
|
|
99
|
-
outputPerMillion: Type.TNumber;
|
|
100
|
-
cachedInputPerMillion: Type.TOptional<Type.TNumber>;
|
|
101
|
-
cacheWritePerMillion: Type.TOptional<Type.TNumber>;
|
|
102
|
-
}>;
|
|
103
|
-
}>, Type.TObject<{
|
|
104
|
-
status: Type.TLiteral<"estimated">;
|
|
105
|
-
currency: Type.TLiteral<"USD">;
|
|
106
|
-
input: Type.TNumber;
|
|
107
|
-
output: Type.TNumber;
|
|
108
|
-
total: Type.TNumber;
|
|
109
|
-
source: Type.TLiteral<"aggregated">;
|
|
110
|
-
}>, Type.TObject<{
|
|
111
|
-
status: Type.TLiteral<"unavailable">;
|
|
112
|
-
currency: Type.TLiteral<"USD">;
|
|
113
|
-
reason: Type.TUnion<[Type.TLiteral<"unknown_pricing">, Type.TLiteral<"missing_usage">, Type.TLiteral<"invalid_usage">, Type.TLiteral<"missing_cache_pricing">, Type.TLiteral<"calculation_overflow">]>;
|
|
114
|
-
}>]>;
|
|
115
|
-
requestId: Type.TOptional<Type.TString>;
|
|
116
|
-
attemptedRoutes: Type.TOptional<Type.TArray<Type.TObject<{
|
|
117
|
-
provider: Type.TString;
|
|
118
|
-
model: Type.TString;
|
|
119
|
-
}>>>;
|
|
120
|
-
}>;
|
|
121
|
-
export declare const classifyCompareOutput: Type.TObject<{
|
|
122
|
-
cancelled: Type.TBoolean;
|
|
123
|
-
results: Type.TArray<Type.TUnion<[Type.TObject<{
|
|
124
|
-
provider: Type.TString;
|
|
125
|
-
model: Type.TString;
|
|
126
|
-
durationMs: Type.TNumber;
|
|
127
|
-
status: Type.TLiteral<"success">;
|
|
128
|
-
result: Type.TObject<{
|
|
129
|
-
provider: Type.TString;
|
|
130
|
-
model: Type.TString;
|
|
131
|
-
answers: Type.TRecord<"^.*$", Type.TUnion<[Type.TObject<{
|
|
132
|
-
type: Type.TLiteral<"bool">;
|
|
133
|
-
probability: Type.TNumber;
|
|
134
|
-
}>, Type.TObject<{
|
|
135
|
-
type: Type.TLiteral<"choice">;
|
|
136
|
-
choice: Type.TString;
|
|
137
|
-
probabilities: Type.TRecord<"^.*$", Type.TNumber>;
|
|
138
|
-
confidence: Type.TNumber;
|
|
139
|
-
probabilityScope: Type.TOptional<Type.TLiteral<"batch">>;
|
|
140
|
-
noneOfAboveProbability: Type.TOptional<Type.TNumber>;
|
|
141
|
-
}>, Type.TObject<{
|
|
142
|
-
type: Type.TLiteral<"score">;
|
|
143
|
-
score: Type.TNumber;
|
|
144
|
-
confidence: Type.TNumber;
|
|
145
|
-
probabilities: Type.TOptional<Type.TRecord<"^.*$", Type.TNumber>>;
|
|
146
|
-
}>, Type.TObject<{
|
|
147
|
-
type: Type.TLiteral<"box">;
|
|
148
|
-
box: Type.TObject<{
|
|
149
|
-
top: Type.TNumber;
|
|
150
|
-
bottom: Type.TNumber;
|
|
151
|
-
left: Type.TNumber;
|
|
152
|
-
right: Type.TNumber;
|
|
153
|
-
}>;
|
|
154
|
-
confidence: Type.TNumber;
|
|
155
|
-
}>, Type.TObject<{
|
|
156
|
-
type: Type.TLiteral<"refusal">;
|
|
157
|
-
}>, Type.TObject<{
|
|
158
|
-
type: Type.TLiteral<"no_match">;
|
|
159
|
-
}>, Type.TObject<{
|
|
160
|
-
type: Type.TLiteral<"ambiguous">;
|
|
161
|
-
}>]>>;
|
|
162
|
-
providerCalls: Type.TOptional<Type.TInteger>;
|
|
163
|
-
usage: Type.TOptional<Type.TObject<{
|
|
164
|
-
inputTokens: Type.TNumber;
|
|
165
|
-
outputTokens: Type.TNumber;
|
|
166
|
-
totalTokens: Type.TNumber;
|
|
167
|
-
cachedInputTokens: Type.TOptional<Type.TNumber>;
|
|
168
|
-
cacheWriteTokens: Type.TOptional<Type.TNumber>;
|
|
169
|
-
}>>;
|
|
170
|
-
cost: Type.TUnion<[Type.TObject<{
|
|
171
|
-
status: Type.TLiteral<"estimated">;
|
|
172
|
-
currency: Type.TLiteral<"USD">;
|
|
173
|
-
input: Type.TNumber;
|
|
174
|
-
output: Type.TNumber;
|
|
175
|
-
total: Type.TNumber;
|
|
176
|
-
source: Type.TUnion<[Type.TLiteral<"builtin">, Type.TLiteral<"configured">]>;
|
|
177
|
-
rates: Type.TObject<{
|
|
178
|
-
inputPerMillion: Type.TNumber;
|
|
179
|
-
outputPerMillion: Type.TNumber;
|
|
180
|
-
cachedInputPerMillion: Type.TOptional<Type.TNumber>;
|
|
181
|
-
cacheWritePerMillion: Type.TOptional<Type.TNumber>;
|
|
182
|
-
}>;
|
|
183
|
-
}>, Type.TObject<{
|
|
184
|
-
status: Type.TLiteral<"estimated">;
|
|
185
|
-
currency: Type.TLiteral<"USD">;
|
|
186
|
-
input: Type.TNumber;
|
|
187
|
-
output: Type.TNumber;
|
|
188
|
-
total: Type.TNumber;
|
|
189
|
-
source: Type.TLiteral<"aggregated">;
|
|
190
|
-
}>, Type.TObject<{
|
|
191
|
-
status: Type.TLiteral<"unavailable">;
|
|
192
|
-
currency: Type.TLiteral<"USD">;
|
|
193
|
-
reason: Type.TUnion<[Type.TLiteral<"unknown_pricing">, Type.TLiteral<"missing_usage">, Type.TLiteral<"invalid_usage">, Type.TLiteral<"missing_cache_pricing">, Type.TLiteral<"calculation_overflow">]>;
|
|
194
|
-
}>]>;
|
|
195
|
-
requestId: Type.TOptional<Type.TString>;
|
|
196
|
-
attemptedRoutes: Type.TOptional<Type.TArray<Type.TObject<{
|
|
197
|
-
provider: Type.TString;
|
|
198
|
-
model: Type.TString;
|
|
199
|
-
}>>>;
|
|
200
|
-
}>;
|
|
201
|
-
}>, Type.TObject<{
|
|
202
|
-
provider: Type.TString;
|
|
203
|
-
model: Type.TString;
|
|
204
|
-
durationMs: Type.TNumber;
|
|
205
|
-
status: Type.TLiteral<"error">;
|
|
206
|
-
error: Type.TObject<{
|
|
207
|
-
code: Type.TString;
|
|
208
|
-
message: Type.TString;
|
|
209
|
-
}>;
|
|
210
|
-
}>]>>;
|
|
211
|
-
}>;
|
|
212
|
-
export declare const classifyTreeParameters: Type.TObject<{
|
|
213
|
-
state: Type.TUnion<[Type.TString, Type.TRecord<"^.*$", Type.TUnknown>, Type.TArray<Type.TUnknown>]>;
|
|
214
|
-
tree: Type.TUnion<[Type.TString, Type.TObject<{
|
|
215
|
-
roots: Type.TArray<Type.TRef<"#/$defs/ClassificationTreeNode">>;
|
|
216
|
-
}>]>;
|
|
217
|
-
instructions: Type.TOptional<Type.TString>;
|
|
218
|
-
images: Type.TOptional<Type.TArray<Type.TUnion<[Type.TString, Type.TObject<{
|
|
219
|
-
id: Type.TString;
|
|
220
|
-
path: Type.TString;
|
|
221
|
-
}>, Type.TObject<{
|
|
222
|
-
id: Type.TString;
|
|
223
|
-
url: Type.TString;
|
|
224
|
-
}>]>>>;
|
|
225
|
-
}>;
|
|
226
|
-
export declare const classifyTreeOutput: Type.TObject<{
|
|
227
|
-
provider: Type.TString;
|
|
228
|
-
model: Type.TString;
|
|
229
|
-
status: Type.TUnion<[Type.TLiteral<"complete">, Type.TLiteral<"no_match">, Type.TLiteral<"ambiguous">, Type.TLiteral<"refusal">]>;
|
|
230
|
-
levels: Type.TRecord<"^.*$", Type.TString>;
|
|
231
|
-
steps: Type.TArray<Type.TObject<{
|
|
232
|
-
level: Type.TInteger;
|
|
233
|
-
id: Type.TString;
|
|
234
|
-
source: Type.TUnion<[Type.TLiteral<"automatic">, Type.TLiteral<"model">]>;
|
|
235
|
-
confidence: Type.TOptional<Type.TNumber>;
|
|
236
|
-
probabilityScope: Type.TOptional<Type.TUnion<[Type.TLiteral<"siblings">, Type.TLiteral<"batch">]>>;
|
|
237
|
-
noneOfAboveProbability: Type.TOptional<Type.TNumber>;
|
|
238
|
-
}>>;
|
|
239
|
-
providerCalls: Type.TInteger;
|
|
240
|
-
cost: Type.TUnion<[Type.TObject<{
|
|
241
|
-
status: Type.TLiteral<"estimated">;
|
|
242
|
-
currency: Type.TLiteral<"USD">;
|
|
243
|
-
input: Type.TNumber;
|
|
244
|
-
output: Type.TNumber;
|
|
245
|
-
total: Type.TNumber;
|
|
246
|
-
source: Type.TUnion<[Type.TLiteral<"builtin">, Type.TLiteral<"configured">]>;
|
|
247
|
-
rates: Type.TObject<{
|
|
248
|
-
inputPerMillion: Type.TNumber;
|
|
249
|
-
outputPerMillion: Type.TNumber;
|
|
250
|
-
cachedInputPerMillion: Type.TOptional<Type.TNumber>;
|
|
251
|
-
cacheWritePerMillion: Type.TOptional<Type.TNumber>;
|
|
252
|
-
}>;
|
|
253
|
-
}>, Type.TObject<{
|
|
254
|
-
status: Type.TLiteral<"estimated">;
|
|
255
|
-
currency: Type.TLiteral<"USD">;
|
|
256
|
-
input: Type.TNumber;
|
|
257
|
-
output: Type.TNumber;
|
|
258
|
-
total: Type.TNumber;
|
|
259
|
-
source: Type.TLiteral<"aggregated">;
|
|
260
|
-
}>, Type.TObject<{
|
|
261
|
-
status: Type.TLiteral<"unavailable">;
|
|
262
|
-
currency: Type.TLiteral<"USD">;
|
|
263
|
-
reason: Type.TUnion<[Type.TLiteral<"unknown_pricing">, Type.TLiteral<"missing_usage">, Type.TLiteral<"invalid_usage">, Type.TLiteral<"missing_cache_pricing">, Type.TLiteral<"calculation_overflow">]>;
|
|
264
|
-
}>]>;
|
|
265
|
-
usage: Type.TOptional<Type.TObject<{
|
|
266
|
-
inputTokens: Type.TNumber;
|
|
267
|
-
outputTokens: Type.TNumber;
|
|
268
|
-
totalTokens: Type.TNumber;
|
|
269
|
-
cachedInputTokens: Type.TOptional<Type.TNumber>;
|
|
270
|
-
cacheWriteTokens: Type.TOptional<Type.TNumber>;
|
|
271
|
-
}>>;
|
|
272
|
-
attemptedRoutes: Type.TOptional<Type.TArray<Type.TObject<{
|
|
273
|
-
provider: Type.TString;
|
|
274
|
-
model: Type.TString;
|
|
275
|
-
}>>>;
|
|
276
|
-
}>;
|
|
2
|
+
import { classifyExtractOutput, classifyExtractParameters, classifyCompareOutput, classifyOutput, classifyParameters, classifyTreeOutput, classifyTreeParameters } from "./tool-contracts.js";
|
|
3
|
+
export { classifyCompareOutput, classifyOutput, classifyParameters, classifyTreeOutput, classifyTreeParameters, classifyExtractOutput, classifyExtractParameters, };
|
|
277
4
|
export default function piClassifier(pi: ExtensionAPI): void;
|