@mizchi/vlmkit-ai 0.23.1 → 0.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/claims.d.mts +36 -0
- package/dist/claims.mjs +67 -0
- package/dist/errors.d.mts +17 -4
- package/dist/image-gen-client.d.mts +25 -25
- package/dist/image-gen-client.mjs +4 -4
- package/dist/index.mjs +1 -1
- package/dist/intent.d.mts +7 -9
- package/dist/intent.mjs +1 -1
- package/dist/jev-client.d.mts +133 -0
- package/dist/jev-client.mjs +147 -0
- package/dist/llm-client.d.mts +12 -14
- package/dist/llm-client.mjs +8 -5
- package/dist/locate.d.mts +68 -0
- package/dist/locate.mjs +159 -0
- package/dist/motion-check.d.mts +156 -0
- package/dist/motion-check.mjs +250 -0
- package/dist/nlp.d.mts +3 -4
- package/dist/nlp.mjs +1 -1
- package/dist/reasoning-pipeline.d.mts +13 -13
- package/dist/reasoning-pipeline.mjs +2 -1
- package/dist/reasoning.d.mts +5 -7
- package/dist/reasoning.mjs +1 -1
- package/dist/region-kind.d.mts +70 -0
- package/dist/region-kind.mjs +140 -0
- package/dist/vlm-client.d.mts +16 -17
- package/dist/vlm-client.mjs +3 -2
- package/dist/zoom-drivers.d.mts +7 -8
- package/dist/zoom-geometry.d.mts +12 -13
- package/dist/zoom-image.d.mts +18 -16
- package/dist/zoom-loop.d.mts +22 -22
- package/dist/zoom.d.mts +5 -6
- package/dist/zoom.mjs +4 -3
- package/package.json +5 -4
package/dist/vlm-client.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/vlm-client.d.ts
|
|
2
|
-
interface VlmModel {
|
|
2
|
+
export interface VlmModel {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
5
5
|
promptCostPer1k: number;
|
|
@@ -7,7 +7,7 @@ interface VlmModel {
|
|
|
7
7
|
contextLength: number;
|
|
8
8
|
modality: string;
|
|
9
9
|
}
|
|
10
|
-
interface VlmResponse {
|
|
10
|
+
export interface VlmResponse {
|
|
11
11
|
content: string;
|
|
12
12
|
model: string;
|
|
13
13
|
promptTokens: number;
|
|
@@ -16,7 +16,7 @@ interface VlmResponse {
|
|
|
16
16
|
costUsd: number;
|
|
17
17
|
latencyMs: number;
|
|
18
18
|
}
|
|
19
|
-
interface VlmClient {
|
|
19
|
+
export interface VlmClient {
|
|
20
20
|
model: VlmModel;
|
|
21
21
|
analyzeImage(imageBase64: string, prompt: string, options?: {
|
|
22
22
|
maxTokens?: number;
|
|
@@ -36,22 +36,22 @@ interface VlmClient {
|
|
|
36
36
|
* invisible to them until restart. Named after `resetGateRegistryCache`, which exists for the
|
|
37
37
|
* same reason on the same kind of lazily-built module state.
|
|
38
38
|
*/
|
|
39
|
-
declare function resetVisionModelCache(): void;
|
|
40
|
-
declare function fetchVisionModels(): Promise<VlmModel[]>;
|
|
41
|
-
declare function listModels(options?: {
|
|
39
|
+
export declare function resetVisionModelCache(): void;
|
|
40
|
+
export declare function fetchVisionModels(): Promise<VlmModel[]>;
|
|
41
|
+
export declare function listModels(options?: {
|
|
42
42
|
maxCost?: number;
|
|
43
43
|
limit?: number;
|
|
44
44
|
includeGemini?: boolean;
|
|
45
45
|
includeClaude?: boolean;
|
|
46
46
|
}): Promise<VlmModel[]>;
|
|
47
|
-
declare function resolveModel(idOrIndex: string): Promise<VlmModel>;
|
|
48
|
-
declare function isGeminiDirectModel(id: string): boolean;
|
|
49
|
-
declare function resolveGeminiModel(id: string): VlmModel | undefined;
|
|
50
|
-
declare function listGeminiModels(): VlmModel[];
|
|
51
|
-
declare function isClaudeDirectModel(id: string): boolean;
|
|
52
|
-
declare function resolveClaudeModel(id: string): VlmModel | undefined;
|
|
53
|
-
declare function listClaudeModels(): VlmModel[];
|
|
54
|
-
interface CreateVlmClientOptions {
|
|
47
|
+
export declare function resolveModel(idOrIndex: string): Promise<VlmModel>;
|
|
48
|
+
export declare function isGeminiDirectModel(id: string): boolean;
|
|
49
|
+
export declare function resolveGeminiModel(id: string): VlmModel | undefined;
|
|
50
|
+
export declare function listGeminiModels(): VlmModel[];
|
|
51
|
+
export declare function isClaudeDirectModel(id: string): boolean;
|
|
52
|
+
export declare function resolveClaudeModel(id: string): VlmModel | undefined;
|
|
53
|
+
export declare function listClaudeModels(): VlmModel[];
|
|
54
|
+
export interface CreateVlmClientOptions {
|
|
55
55
|
/** Override `OPENROUTER_API_KEY` / `GEMINI_API_KEY` lookup. */
|
|
56
56
|
apiKey?: string;
|
|
57
57
|
/**
|
|
@@ -67,6 +67,5 @@ interface CreateVlmClientOptions {
|
|
|
67
67
|
* required API key isn't set in the environment. Pass
|
|
68
68
|
* `{ throwIfMissing: false }` for the legacy `T | null` return.
|
|
69
69
|
*/
|
|
70
|
-
declare function createVlmClient(model: VlmModel, options?: CreateVlmClientOptions): Promise<VlmClient | null>;
|
|
71
|
-
//#endregion
|
|
72
|
-
export { CreateVlmClientOptions, VlmClient, VlmModel, VlmResponse, createVlmClient, fetchVisionModels, isClaudeDirectModel, isGeminiDirectModel, listClaudeModels, listGeminiModels, listModels, resetVisionModelCache, resolveClaudeModel, resolveGeminiModel, resolveModel };
|
|
70
|
+
export declare function createVlmClient(model: VlmModel, options?: CreateVlmClientOptions): Promise<VlmClient | null>;
|
|
71
|
+
//#endregion
|
package/dist/vlm-client.mjs
CHANGED
|
@@ -63,7 +63,8 @@ async function resolveModel(idOrIndex) {
|
|
|
63
63
|
if (partial.length > 1) {
|
|
64
64
|
const segmentMatches = partial.filter((m) => m.id.split("/").includes(idOrIndex));
|
|
65
65
|
if (segmentMatches.length === 1) return segmentMatches[0];
|
|
66
|
-
|
|
66
|
+
const shown = (segmentMatches.length > 1 ? segmentMatches : partial).slice(0, 5).map((m) => m.id).join(", ");
|
|
67
|
+
throw new VrtConfigError("MULTIPLE_MATCHES", `Ambiguous model "${idOrIndex}". Matches: ${shown}\nTip: use more specific ID, e.g. "${(segmentMatches[0] ?? partial[0]).id}"`);
|
|
67
68
|
}
|
|
68
69
|
const idx = parseInt(idOrIndex, 10);
|
|
69
70
|
if (!isNaN(idx) && idx >= 0 && idx < models.length) return models[idx];
|
|
@@ -357,7 +358,7 @@ async function createVlmClient(model, options) {
|
|
|
357
358
|
method: "POST",
|
|
358
359
|
headers: {
|
|
359
360
|
"Content-Type": "application/json",
|
|
360
|
-
|
|
361
|
+
Authorization: `Bearer ${key}`,
|
|
361
362
|
"HTTP-Referer": "https://github.com/mizchi/vrt",
|
|
362
363
|
"X-Title": "vrt"
|
|
363
364
|
},
|
package/dist/zoom-drivers.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { VisionChatDriver, ZoomToolSpec } from "./zoom-loop.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/zoom-drivers.d.ts
|
|
4
3
|
type Fetch = typeof fetch;
|
|
5
|
-
interface OpenAiCompatibleDriverOptions {
|
|
4
|
+
export interface OpenAiCompatibleDriverOptions {
|
|
6
5
|
model: string;
|
|
7
6
|
apiKey?: string;
|
|
8
7
|
/** Chat Completions URL (default OpenRouter's). */
|
|
@@ -12,22 +11,22 @@ interface OpenAiCompatibleDriverOptions {
|
|
|
12
11
|
nativeTools?: boolean;
|
|
13
12
|
fetch?: Fetch;
|
|
14
13
|
}
|
|
15
|
-
declare function openAiCompatibleDriver(options: OpenAiCompatibleDriverOptions): VisionChatDriver;
|
|
16
|
-
interface AnthropicDriverOptions {
|
|
14
|
+
export declare function openAiCompatibleDriver(options: OpenAiCompatibleDriverOptions): VisionChatDriver;
|
|
15
|
+
export interface AnthropicDriverOptions {
|
|
17
16
|
model: string;
|
|
18
17
|
apiKey: string;
|
|
19
18
|
/** Default https://api.anthropic.com (or ANTHROPIC_BASE_URL when the caller passes it). */
|
|
20
19
|
baseUrl?: string;
|
|
21
20
|
fetch?: Fetch;
|
|
22
21
|
}
|
|
23
|
-
declare function anthropicDriver(options: AnthropicDriverOptions): VisionChatDriver;
|
|
24
|
-
interface GeminiDriverOptions {
|
|
22
|
+
export declare function anthropicDriver(options: AnthropicDriverOptions): VisionChatDriver;
|
|
23
|
+
export interface GeminiDriverOptions {
|
|
25
24
|
/** e.g. `gemini-2.5-flash` (no `gemini:` prefix). */
|
|
26
25
|
model: string;
|
|
27
26
|
apiKey: string;
|
|
28
27
|
baseUrl?: string;
|
|
29
28
|
fetch?: Fetch;
|
|
30
29
|
}
|
|
31
|
-
declare function geminiDriver(options: GeminiDriverOptions): VisionChatDriver;
|
|
30
|
+
export declare function geminiDriver(options: GeminiDriverOptions): VisionChatDriver;
|
|
32
31
|
//#endregion
|
|
33
|
-
export {
|
|
32
|
+
export type { ZoomToolSpec };
|
package/dist/zoom-geometry.d.mts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* (`viewBoxToOriginal`) — the crop always comes from the original, never from the view.
|
|
15
15
|
*/
|
|
16
16
|
/** How large an image one message may carry. Providers differ; stay under all of them. */
|
|
17
|
-
interface ImageBudget {
|
|
17
|
+
export interface ImageBudget {
|
|
18
18
|
/** Longest edge, px. */
|
|
19
19
|
maxEdge: number;
|
|
20
20
|
/** Width × height, px². Tile-counting providers bill by area; this bounds the bill too. */
|
|
@@ -28,22 +28,22 @@ interface ImageBudget {
|
|
|
28
28
|
* (`coordinates: "normalized"`, 0–1000 on each axis), invariant to any resize. Pass a budget
|
|
29
29
|
* that matches the model you use; nothing here assumes this one.
|
|
30
30
|
*/
|
|
31
|
-
declare const DEFAULT_IMAGE_BUDGET: ImageBudget;
|
|
31
|
+
export declare const DEFAULT_IMAGE_BUDGET: ImageBudget;
|
|
32
32
|
/**
|
|
33
33
|
* How the model states a box. `pixels`: absolute pixels of the view it was shown (the cookbook's
|
|
34
34
|
* form; exact when the provider does not resize the view again). `normalized`: 0–1000 of the
|
|
35
35
|
* view's width and height, the form several vision models are trained to emit for boxes, and
|
|
36
36
|
* correct whatever size the provider actually showed the model.
|
|
37
37
|
*/
|
|
38
|
-
type ZoomCoordinates = "pixels" | "normalized";
|
|
38
|
+
export type ZoomCoordinates = "pixels" | "normalized";
|
|
39
39
|
/** A box as the model stated it, in the view's pixel space. */
|
|
40
|
-
declare function toViewBox(box: Box, view: Size, coordinates: ZoomCoordinates): Box;
|
|
41
|
-
interface Size {
|
|
40
|
+
export declare function toViewBox(box: Box, view: Size, coordinates: ZoomCoordinates): Box;
|
|
41
|
+
export interface Size {
|
|
42
42
|
width: number;
|
|
43
43
|
height: number;
|
|
44
44
|
}
|
|
45
45
|
/** A box in some image's pixel space, x2 > x1 and y2 > y1 (half-open: x1 <= x < x2). */
|
|
46
|
-
interface Box {
|
|
46
|
+
export interface Box {
|
|
47
47
|
x1: number;
|
|
48
48
|
y1: number;
|
|
49
49
|
x2: number;
|
|
@@ -53,15 +53,15 @@ interface Box {
|
|
|
53
53
|
* The largest aspect-preserving size within the budget, never larger than the input. An image
|
|
54
54
|
* that already fits is returned unchanged, so a small screenshot is shown at 1:1.
|
|
55
55
|
*/
|
|
56
|
-
declare function fitToBudget(size: Size, budget?: ImageBudget): Size;
|
|
56
|
+
export declare function fitToBudget(size: Size, budget?: ImageBudget): Size;
|
|
57
57
|
/**
|
|
58
58
|
* The size a crop is magnified to: the largest aspect-preserving size within the budget, even
|
|
59
59
|
* when that means enlarging it — a 60×20 region comes back filling the budget, which is the
|
|
60
60
|
* point. (Magnifying past the original's own pixels adds no detail, but it does make each
|
|
61
61
|
* original pixel several of the model's, which is what lets it read an 8px gap.)
|
|
62
62
|
*/
|
|
63
|
-
declare function zoomSize(crop: Size, budget?: ImageBudget): Size;
|
|
64
|
-
type BoxProblem = {
|
|
63
|
+
export declare function zoomSize(crop: Size, budget?: ImageBudget): Size;
|
|
64
|
+
export type BoxProblem = {
|
|
65
65
|
ok: false;
|
|
66
66
|
reason: string;
|
|
67
67
|
};
|
|
@@ -71,7 +71,7 @@ type BoxProblem = {
|
|
|
71
71
|
* reading. A box that is empty after clamping is an error the model is told about, so it can
|
|
72
72
|
* try again, rather than a crash.
|
|
73
73
|
*/
|
|
74
|
-
declare function clampBox(box: Box, view: Size): {
|
|
74
|
+
export declare function clampBox(box: Box, view: Size): {
|
|
75
75
|
ok: true;
|
|
76
76
|
box: Box;
|
|
77
77
|
} | BoxProblem;
|
|
@@ -80,6 +80,5 @@ declare function clampBox(box: Box, view: Size): {
|
|
|
80
80
|
* size is not an exact multiple of the original's), rounds outward so a 1px feature on the
|
|
81
81
|
* box's edge is kept, and never returns an empty box.
|
|
82
82
|
*/
|
|
83
|
-
declare function viewBoxToOriginal(box: Box, view: Size, original: Size): Box;
|
|
84
|
-
//#endregion
|
|
85
|
-
export { Box, BoxProblem, DEFAULT_IMAGE_BUDGET, ImageBudget, Size, ZoomCoordinates, clampBox, fitToBudget, toViewBox, viewBoxToOriginal, zoomSize };
|
|
83
|
+
export declare function viewBoxToOriginal(box: Box, view: Size, original: Size): Box;
|
|
84
|
+
//#endregion
|
package/dist/zoom-image.d.mts
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import { Box, ImageBudget, Size } from "./zoom-geometry.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/zoom-image.d.ts
|
|
4
|
-
interface RgbaImage {
|
|
3
|
+
export interface RgbaImage {
|
|
5
4
|
width: number;
|
|
6
5
|
height: number;
|
|
7
6
|
/** RGBA, row-major, 4 bytes per pixel, alpha always 255 after decode. */
|
|
8
7
|
data: Uint8Array;
|
|
9
8
|
}
|
|
10
9
|
/** Decode a PNG and flatten it onto white. Anything else is refused with the reason. */
|
|
11
|
-
declare function decodeImage(buf: Buffer): RgbaImage;
|
|
12
|
-
declare function encodePngImage(img: RgbaImage): Buffer;
|
|
13
|
-
declare function cropImage(img: RgbaImage, box: Box): RgbaImage;
|
|
10
|
+
export declare function decodeImage(buf: Buffer): RgbaImage;
|
|
11
|
+
export declare function encodePngImage(img: RgbaImage): Buffer;
|
|
12
|
+
export declare function cropImage(img: RgbaImage, box: Box): RgbaImage;
|
|
14
13
|
/** Resize to exactly `size`: area-average on each axis that shrinks, bilinear on one that grows. */
|
|
15
|
-
declare function resample(img: RgbaImage, size: Size): RgbaImage;
|
|
14
|
+
export declare function resample(img: RgbaImage, size: Size): RgbaImage;
|
|
16
15
|
/** One image as the zoom loop holds it: the full-resolution original and the view the model sees. */
|
|
17
|
-
interface ZoomSource {
|
|
16
|
+
export interface ZoomSource {
|
|
18
17
|
original: RgbaImage;
|
|
19
18
|
view: RgbaImage;
|
|
20
19
|
/** The view, encoded — what is actually sent. */
|
|
21
20
|
viewPng: Buffer;
|
|
22
21
|
}
|
|
23
|
-
declare function prepareZoomSource(png: Buffer, budget?: ImageBudget): ZoomSource;
|
|
24
|
-
type ZoomOutcome = {
|
|
25
|
-
ok: true;
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
export declare function prepareZoomSource(png: Buffer, budget?: ImageBudget): ZoomSource;
|
|
23
|
+
export type ZoomOutcome = {
|
|
24
|
+
ok: true;
|
|
25
|
+
/** The box in view pixels after clamping. */
|
|
26
|
+
viewBox: Box;
|
|
27
|
+
/** The original's pixels that were cropped. */
|
|
28
|
+
originalBox: Box;
|
|
29
|
+
/** The magnified crop, encoded. */
|
|
28
30
|
png: Buffer;
|
|
29
|
-
size: Size;
|
|
31
|
+
size: Size;
|
|
32
|
+
/** What to tell the model alongside the image. */
|
|
30
33
|
text: string;
|
|
31
34
|
} | {
|
|
32
35
|
ok: false;
|
|
@@ -37,6 +40,5 @@ type ZoomOutcome = {
|
|
|
37
40
|
* spaces, so the model can place what it sees in the zoom back onto the view it is reasoning
|
|
38
41
|
* about ("…a 180x60px region of the original, returned at 1568x522px").
|
|
39
42
|
*/
|
|
40
|
-
declare function zoomInto(source: ZoomSource, box: Box, budget?: ImageBudget): ZoomOutcome;
|
|
41
|
-
//#endregion
|
|
42
|
-
export { RgbaImage, ZoomOutcome, ZoomSource, cropImage, decodeImage, encodePngImage, prepareZoomSource, resample, zoomInto };
|
|
43
|
+
export declare function zoomInto(source: ZoomSource, box: Box, budget?: ImageBudget): ZoomOutcome;
|
|
44
|
+
//#endregion
|
package/dist/zoom-loop.d.mts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Box, ImageBudget, ZoomCoordinates } from "./zoom-geometry.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/zoom-loop.d.ts
|
|
4
|
-
type ZoomPart = {
|
|
3
|
+
export type ZoomPart = {
|
|
5
4
|
type: "text";
|
|
6
5
|
text: string;
|
|
7
6
|
} | {
|
|
8
7
|
type: "image";
|
|
9
8
|
png: Buffer;
|
|
10
9
|
};
|
|
11
|
-
interface ZoomCall {
|
|
10
|
+
export interface ZoomCall {
|
|
12
11
|
/** Provider call id (native), or a synthetic one (text protocol). */
|
|
13
12
|
id: string;
|
|
14
13
|
imageIndex: number;
|
|
@@ -16,30 +15,32 @@ interface ZoomCall {
|
|
|
16
15
|
/** Set when the provider's arguments did not parse; the loop answers with it. */
|
|
17
16
|
error?: string;
|
|
18
17
|
}
|
|
19
|
-
interface ZoomResult {
|
|
18
|
+
export interface ZoomResult {
|
|
20
19
|
callId: string;
|
|
21
20
|
/** Text first, then the magnified crop when the zoom succeeded. */
|
|
22
21
|
parts: ZoomPart[];
|
|
23
22
|
isError: boolean;
|
|
24
23
|
}
|
|
25
|
-
type ZoomTurn = {
|
|
24
|
+
export type ZoomTurn = {
|
|
26
25
|
role: "user";
|
|
27
26
|
parts: ZoomPart[];
|
|
28
27
|
} | {
|
|
29
28
|
role: "assistant";
|
|
30
29
|
text: string;
|
|
31
|
-
calls: ZoomCall[];
|
|
30
|
+
calls: ZoomCall[];
|
|
31
|
+
/** The provider's own assistant message, so a driver can replay it verbatim. */
|
|
32
32
|
raw?: unknown;
|
|
33
33
|
} | {
|
|
34
|
-
role: "tool";
|
|
34
|
+
role: "tool";
|
|
35
|
+
/** True when the results answer native function calls; false for the text protocol. */
|
|
35
36
|
native: boolean;
|
|
36
37
|
results: ZoomResult[];
|
|
37
38
|
};
|
|
38
|
-
interface ZoomUsage {
|
|
39
|
+
export interface ZoomUsage {
|
|
39
40
|
promptTokens: number;
|
|
40
41
|
completionTokens: number;
|
|
41
42
|
}
|
|
42
|
-
interface DriverTurn {
|
|
43
|
+
export interface DriverTurn {
|
|
43
44
|
text: string;
|
|
44
45
|
calls: ZoomCall[];
|
|
45
46
|
raw?: unknown;
|
|
@@ -47,13 +48,13 @@ interface DriverTurn {
|
|
|
47
48
|
/** The provider stopped for its own reason (length, refusal) — not a finished answer. */
|
|
48
49
|
stop?: string;
|
|
49
50
|
}
|
|
50
|
-
interface ZoomToolSpec {
|
|
51
|
+
export interface ZoomToolSpec {
|
|
51
52
|
name: "zoom";
|
|
52
53
|
description: string;
|
|
53
54
|
/** JSON Schema of the arguments. */
|
|
54
55
|
parameters: Record<string, unknown>;
|
|
55
56
|
}
|
|
56
|
-
interface VisionChatDriver {
|
|
57
|
+
export interface VisionChatDriver {
|
|
57
58
|
model: string;
|
|
58
59
|
/** True when the driver maps `ZoomToolSpec` onto the provider's function calling. */
|
|
59
60
|
nativeTools: boolean;
|
|
@@ -63,12 +64,12 @@ interface VisionChatDriver {
|
|
|
63
64
|
maxTokens: number;
|
|
64
65
|
}): Promise<DriverTurn>;
|
|
65
66
|
}
|
|
66
|
-
interface ZoomImageInput {
|
|
67
|
+
export interface ZoomImageInput {
|
|
67
68
|
png: Buffer;
|
|
68
69
|
/** Shown before the image, e.g. "Baseline screenshot". */
|
|
69
70
|
label?: string;
|
|
70
71
|
}
|
|
71
|
-
interface ZoomLoopOptions {
|
|
72
|
+
export interface ZoomLoopOptions {
|
|
72
73
|
/** Zoom calls allowed before the model must answer (default 6). */
|
|
73
74
|
maxZooms?: number;
|
|
74
75
|
maxTokens?: number;
|
|
@@ -77,7 +78,7 @@ interface ZoomLoopOptions {
|
|
|
77
78
|
/** Force the text protocol even when the driver has native tools. */
|
|
78
79
|
protocol?: "native" | "text";
|
|
79
80
|
}
|
|
80
|
-
interface ZoomLoopResult {
|
|
81
|
+
export interface ZoomLoopResult {
|
|
81
82
|
answer: string;
|
|
82
83
|
zooms: {
|
|
83
84
|
imageIndex: number;
|
|
@@ -97,9 +98,9 @@ interface ZoomLoopResult {
|
|
|
97
98
|
/** Set when the provider stopped for its own reason on the last turn. */
|
|
98
99
|
stop?: string;
|
|
99
100
|
}
|
|
100
|
-
declare function zoomToolSpec(imageCount: number, coordinates: ZoomCoordinates): ZoomToolSpec;
|
|
101
|
+
export declare function zoomToolSpec(imageCount: number, coordinates: ZoomCoordinates): ZoomToolSpec;
|
|
101
102
|
/** Arguments a native call carried, whatever shape the provider gave them in. */
|
|
102
|
-
declare function zoomCallFromArgs(id: string, args: unknown): ZoomCall | {
|
|
103
|
+
export declare function zoomCallFromArgs(id: string, args: unknown): ZoomCall | {
|
|
103
104
|
id: string;
|
|
104
105
|
error: string;
|
|
105
106
|
};
|
|
@@ -107,8 +108,8 @@ declare function zoomCallFromArgs(id: string, args: unknown): ZoomCall | {
|
|
|
107
108
|
* Zoom requests written in a reply, one `ZOOM <image> <x1> <y1> <x2> <y2>` per line. The
|
|
108
109
|
* image index is always written, even with one image, so the grammar has one shape.
|
|
109
110
|
*/
|
|
110
|
-
declare function parseZoomRequests(text: string, turn: number): ZoomCall[];
|
|
111
|
-
interface SingleLookResult {
|
|
111
|
+
export declare function parseZoomRequests(text: string, turn: number): ZoomCall[];
|
|
112
|
+
export interface SingleLookResult {
|
|
112
113
|
answer: string;
|
|
113
114
|
usage: ZoomUsage;
|
|
114
115
|
stop?: string;
|
|
@@ -119,11 +120,10 @@ interface SingleLookResult {
|
|
|
119
120
|
* `runZoomLoop` isolates what zooming adds; comparing against a different client would also
|
|
120
121
|
* measure the difference between two request builders.
|
|
121
122
|
*/
|
|
122
|
-
declare function runSingleLook(driver: VisionChatDriver, images: readonly ZoomImageInput[], question: string, options?: Pick<ZoomLoopOptions, "maxTokens" | "budget" | "coordinates">): Promise<SingleLookResult>;
|
|
123
|
+
export declare function runSingleLook(driver: VisionChatDriver, images: readonly ZoomImageInput[], question: string, options?: Pick<ZoomLoopOptions, "maxTokens" | "budget" | "coordinates">): Promise<SingleLookResult>;
|
|
123
124
|
/**
|
|
124
125
|
* Run the loop. `images` are PNGs at any size; each is shown at `budget` and labelled with its
|
|
125
126
|
* index and size. The answer is the model's last reply with no zoom request.
|
|
126
127
|
*/
|
|
127
|
-
declare function runZoomLoop(driver: VisionChatDriver, images: readonly ZoomImageInput[], question: string, options?: ZoomLoopOptions): Promise<ZoomLoopResult>;
|
|
128
|
-
//#endregion
|
|
129
|
-
export { DriverTurn, SingleLookResult, VisionChatDriver, ZoomCall, ZoomImageInput, ZoomLoopOptions, ZoomLoopResult, ZoomPart, ZoomResult, ZoomToolSpec, ZoomTurn, ZoomUsage, parseZoomRequests, runSingleLook, runZoomLoop, zoomCallFromArgs, zoomToolSpec };
|
|
128
|
+
export declare function runZoomLoop(driver: VisionChatDriver, images: readonly ZoomImageInput[], question: string, options?: ZoomLoopOptions): Promise<ZoomLoopResult>;
|
|
129
|
+
//#endregion
|
package/dist/zoom.d.mts
CHANGED
|
@@ -3,17 +3,16 @@ import { Box, BoxProblem, DEFAULT_IMAGE_BUDGET, ImageBudget, Size, ZoomCoordinat
|
|
|
3
3
|
import { DriverTurn, SingleLookResult, VisionChatDriver, ZoomCall, ZoomImageInput, ZoomLoopOptions, ZoomLoopResult, ZoomPart, ZoomResult, ZoomToolSpec, ZoomTurn, ZoomUsage, parseZoomRequests, runSingleLook, runZoomLoop, zoomCallFromArgs, zoomToolSpec } from "./zoom-loop.mjs";
|
|
4
4
|
import { ZoomOutcome, ZoomSource, prepareZoomSource, zoomInto } from "./zoom-image.mjs";
|
|
5
5
|
import { AnthropicDriverOptions, GeminiDriverOptions, OpenAiCompatibleDriverOptions, anthropicDriver, geminiDriver, openAiCompatibleDriver } from "./zoom-drivers.mjs";
|
|
6
|
-
|
|
7
6
|
//#region src/zoom.d.ts
|
|
8
|
-
interface ZoomDriverOptions {
|
|
7
|
+
export interface ZoomDriverOptions {
|
|
9
8
|
/** Overrides the environment key lookup, as in `createVlmClient`. */
|
|
10
9
|
apiKey?: string;
|
|
11
10
|
/** OpenRouter only: false for a model without function calling (the loop then uses the text protocol). */
|
|
12
11
|
nativeTools?: boolean;
|
|
13
12
|
}
|
|
14
13
|
/** A driver for a model id, with the same key lookup and error as `createVlmClient`. */
|
|
15
|
-
declare function createZoomDriver(model: VlmModel, options?: ZoomDriverOptions): VisionChatDriver;
|
|
16
|
-
interface ZoomAnalysis extends VlmResponse {
|
|
14
|
+
export declare function createZoomDriver(model: VlmModel, options?: ZoomDriverOptions): VisionChatDriver;
|
|
15
|
+
export interface ZoomAnalysis extends VlmResponse {
|
|
17
16
|
zoom: Omit<ZoomLoopResult, "answer" | "usage">;
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
@@ -21,9 +20,9 @@ interface ZoomAnalysis extends VlmResponse {
|
|
|
21
20
|
* `VlmClient` response (content, tokens, cost, latency) plus what the model zoomed into, so a
|
|
22
21
|
* bench can put it beside a single-look answer.
|
|
23
22
|
*/
|
|
24
|
-
declare function analyzeWithZoom(model: VlmModel, images: readonly {
|
|
23
|
+
export declare function analyzeWithZoom(model: VlmModel, images: readonly {
|
|
25
24
|
png: Buffer;
|
|
26
25
|
label?: string;
|
|
27
26
|
}[], prompt: string, options?: ZoomLoopOptions & ZoomDriverOptions): Promise<ZoomAnalysis>;
|
|
28
27
|
//#endregion
|
|
29
|
-
export { AnthropicDriverOptions, Box, BoxProblem, DEFAULT_IMAGE_BUDGET, DriverTurn, GeminiDriverOptions, ImageBudget, OpenAiCompatibleDriverOptions, SingleLookResult, Size, VisionChatDriver,
|
|
28
|
+
export { AnthropicDriverOptions, Box, BoxProblem, DEFAULT_IMAGE_BUDGET, DriverTurn, GeminiDriverOptions, ImageBudget, OpenAiCompatibleDriverOptions, SingleLookResult, Size, VisionChatDriver, ZoomCall, ZoomCoordinates, ZoomImageInput, ZoomLoopOptions, ZoomLoopResult, type ZoomOutcome, ZoomPart, ZoomResult, type ZoomSource, ZoomToolSpec, ZoomTurn, ZoomUsage, anthropicDriver, clampBox, fitToBudget, geminiDriver, openAiCompatibleDriver, parseZoomRequests, prepareZoomSource, runSingleLook, runZoomLoop, toViewBox, viewBoxToOriginal, zoomCallFromArgs, zoomInto, zoomSize, zoomToolSpec };
|
package/dist/zoom.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { VrtConfigError } from "./errors.mjs";
|
|
2
|
-
import { isClaudeDirectModel, isGeminiDirectModel } from "./vlm-client.mjs";
|
|
3
1
|
import { DEFAULT_IMAGE_BUDGET, clampBox, fitToBudget, toViewBox, viewBoxToOriginal, zoomSize } from "./zoom-geometry.mjs";
|
|
4
2
|
import { prepareZoomSource, zoomInto } from "./zoom-image.mjs";
|
|
3
|
+
import { VrtConfigError } from "./errors.mjs";
|
|
4
|
+
import { isClaudeDirectModel, isGeminiDirectModel } from "./vlm-client.mjs";
|
|
5
5
|
import { parseZoomRequests, runSingleLook, runZoomLoop, zoomCallFromArgs, zoomToolSpec } from "./zoom-loop.mjs";
|
|
6
6
|
import { anthropicDriver, geminiDriver, openAiCompatibleDriver } from "./zoom-drivers.mjs";
|
|
7
7
|
//#region src/zoom.ts
|
|
@@ -45,7 +45,8 @@ function createZoomDriver(model, options = {}) {
|
|
|
45
45
|
*/
|
|
46
46
|
async function analyzeWithZoom(model, images, prompt, options = {}) {
|
|
47
47
|
const start = Date.now();
|
|
48
|
-
const
|
|
48
|
+
const driver = createZoomDriver(model, options);
|
|
49
|
+
const { answer, usage, ...zoom } = await runZoomLoop(driver, images, prompt, options);
|
|
49
50
|
return {
|
|
50
51
|
content: answer,
|
|
51
52
|
model: model.id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mizchi/vlmkit-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "VLM / LLM clients, reasoning pipeline, and NLP helpers used by VRT to interpret diff images and natural-language intent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "mizchi",
|
|
@@ -38,10 +38,11 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@google/generative-ai": "^0.24.1",
|
|
40
40
|
"pngjs": "^7.0.0",
|
|
41
|
-
"@mizchi/vlmkit-core": "0.
|
|
41
|
+
"@mizchi/vlmkit-core": "0.24.0",
|
|
42
|
+
"@mizchi/vlmkit-judge": "0.24.0"
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|
|
44
|
-
"build": "pnpm --dir ../.. exec
|
|
45
|
-
"test": "pnpm --dir ../.. exec
|
|
45
|
+
"build": "pnpm --dir ../.. exec vp pack --filter @mizchi/vlmkit-ai",
|
|
46
|
+
"test": "pnpm --dir ../.. exec vp test run packages/vlmkit-ai/src"
|
|
46
47
|
}
|
|
47
48
|
}
|