@mizchi/vlmkit-ai 0.24.0 → 0.28.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 +1 -3
- package/dist/claims.mjs +2 -3
- package/dist/errors.d.mts +1 -3
- package/dist/errors.mjs +1 -2
- package/dist/image-gen-client.d.mts +1 -2
- package/dist/image-gen-client.mjs +1 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/intent.d.mts +1 -3
- package/dist/intent.mjs +1 -2
- package/dist/jev-client.d.mts +1 -3
- package/dist/jev-client.mjs +1 -2
- package/dist/llm-client.d.mts +1 -3
- package/dist/llm-client.mjs +1 -2
- package/dist/locate.d.mts +1 -2
- package/dist/locate.mjs +2 -3
- package/dist/motion-check.d.mts +52 -7
- package/dist/motion-check.mjs +65 -11
- package/dist/nlp.d.mts +1 -3
- package/dist/nlp.mjs +1 -2
- package/dist/reasoning-pipeline.d.mts +1 -3
- package/dist/reasoning-pipeline.mjs +2 -3
- package/dist/reasoning.d.mts +1 -3
- package/dist/reasoning.mjs +1 -2
- package/dist/region-kind.d.mts +1 -2
- package/dist/region-kind.mjs +1 -2
- package/dist/vlm-client.d.mts +1 -3
- package/dist/vlm-client.mjs +1 -2
- package/dist/zoom-drivers.d.mts +0 -2
- package/dist/zoom-drivers.mjs +1 -2
- package/dist/zoom-geometry.d.mts +1 -3
- package/dist/zoom-geometry.mjs +1 -2
- package/dist/zoom-image.d.mts +1 -3
- package/dist/zoom-image.mjs +1 -2
- package/dist/zoom-loop.d.mts +1 -3
- package/dist/zoom-loop.mjs +1 -2
- package/dist/zoom.d.mts +1 -3
- package/dist/zoom.mjs +4 -5
- package/package.json +3 -3
package/dist/claims.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JevClientOptions } from "./jev-client.mjs";
|
|
2
2
|
import { JevAsk } from "./locate.mjs";
|
|
3
|
-
//#region src/claims.d.ts
|
|
4
3
|
export type ClaimExpectation = "shown" | "absent";
|
|
5
4
|
export interface Claim {
|
|
6
5
|
/** What the screenshot shows, as a statement: "an error message", "a modal dialog open over the page". */
|
|
@@ -32,5 +31,4 @@ export interface ClaimsOptions {
|
|
|
32
31
|
}
|
|
33
32
|
/** "an error message" → "`screenshot` shows an error message." A statement already starting with "shows" is kept. */
|
|
34
33
|
export declare function claimInstruction(statement: string): string;
|
|
35
|
-
export declare function checkClaims(png: Uint8Array, claims: readonly Claim[], options?: ClaimsOptions): Promise<ClaimsReport>;
|
|
36
|
-
//#endregion
|
|
34
|
+
export declare function checkClaims(png: Uint8Array, claims: readonly Claim[], options?: ClaimsOptions): Promise<ClaimsReport>;
|
package/dist/claims.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JEV_IMAGE_LIMITS, askJev, pngImage } from "./jev-client.mjs";
|
|
2
|
-
import { decodeImage, encodePngImage, resample } from "./zoom-image.mjs";
|
|
3
2
|
import { firstLookScale } from "./locate.mjs";
|
|
4
|
-
|
|
3
|
+
import { decodeImage, encodePngImage, resample } from "./zoom-image.mjs";
|
|
4
|
+
// src/claims.ts
|
|
5
5
|
/**
|
|
6
6
|
* Cheap typed checks on a screenshot: statements a page must or must not make visible ("shows
|
|
7
7
|
* an error message", "shows a modal dialog open over the page"), each answered by Jev as a
|
|
@@ -63,5 +63,4 @@ async function checkClaims(png, claims, options = {}) {
|
|
|
63
63
|
inputTokens: r.usage.input_tokens
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
//#endregion
|
|
67
66
|
export { checkClaims, claimInstruction };
|
package/dist/errors.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/errors.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Tagged error class for factory functions in @mizchi/vlmkit-ai.
|
|
4
3
|
*
|
|
@@ -33,5 +32,4 @@ export type VrtConfigErrorCode =
|
|
|
33
32
|
export declare class VrtConfigError extends Error {
|
|
34
33
|
readonly code: VrtConfigErrorCode;
|
|
35
34
|
constructor(code: VrtConfigErrorCode, message: string);
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
35
|
+
}
|
package/dist/errors.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/image-gen-client.d.ts
|
|
2
1
|
export type ImageGenSize = "1024x1024" | "1024x1536" | "1536x1024" | "auto";
|
|
3
2
|
export type ImageGenQuality = "low" | "medium" | "high" | "auto";
|
|
4
3
|
export type ImageGenOutputFormat = "png" | "jpeg" | "webp";
|
|
@@ -114,4 +113,4 @@ export interface CreateImageGenClientOptions {
|
|
|
114
113
|
}
|
|
115
114
|
/** With no model: `VLMKIT_IMAGE_MODEL`, else `IMAGE_GEN_DEFAULT_MODEL`. */
|
|
116
115
|
export declare function createImageGenClient(modelOrId?: ImageGenModel | string, options?: CreateImageGenClientOptions): ImageGenClient;
|
|
117
|
-
|
|
116
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VrtConfigError } from "./errors.mjs";
|
|
2
|
-
|
|
2
|
+
// src/image-gen-client.ts
|
|
3
3
|
/**
|
|
4
4
|
* Image generation client: OpenRouter's Images API (the default route) or the OpenAI Images API.
|
|
5
5
|
*
|
|
@@ -193,5 +193,4 @@ function createImageGenClient(modelOrId = defaultImageGenModelId(), options) {
|
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
|
-
//#endregion
|
|
197
196
|
export { IMAGE_GEN_DEFAULT_MODEL, buildGenerationBody, buildOpenRouterBody, createImageGenClient, defaultImageGenModelId, estimateImageGenCost, listImageGenModels, parseGenerationResponse, resolveImageGenModel };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { VrtConfigError, VrtConfigErrorCode } from "./errors.mjs";
|
|
2
|
-
import { CreateImageGenClientOptions, IMAGE_GEN_DEFAULT_MODEL, ImageGenBackground, ImageGenClient, ImageGenModel, ImageGenOutputFormat, ImageGenQuality, ImageGenRequest, ImageGenRequestBody, ImageGenResponse, ImageGenSize, ImageGenUsage, OpenRouterImageBody, ParsedGeneration, buildGenerationBody, buildOpenRouterBody, createImageGenClient, defaultImageGenModelId, estimateImageGenCost, listImageGenModels, parseGenerationResponse, resolveImageGenModel } from "./image-gen-client.mjs";
|
|
3
|
-
import { LLMProvider, buildIntent, buildIntentWithLLM, buildReasoningPrompt, extractDiffSemantics, parseDiff } from "./intent.mjs";
|
|
4
2
|
import { CreateLLMProviderOptions, ImageContent, LLMClientOptions, LLMProviderName, LLMResponse, MessageContent, OPENAI_DEFAULT_MODEL, TextContent, UnifiedLLMClient, createLLMProvider, createUnifiedLLMClient } from "./llm-client.mjs";
|
|
5
3
|
import { CreateVlmClientOptions, VlmClient, VlmModel, VlmResponse, createVlmClient, fetchVisionModels, isGeminiDirectModel, listGeminiModels, listModels, resolveGeminiModel, resolveModel } from "./vlm-client.mjs";
|
|
4
|
+
import { CreateImageGenClientOptions, IMAGE_GEN_DEFAULT_MODEL, ImageGenBackground, ImageGenClient, ImageGenModel, ImageGenOutputFormat, ImageGenQuality, ImageGenRequest, ImageGenRequestBody, ImageGenResponse, ImageGenSize, ImageGenUsage, OpenRouterImageBody, ParsedGeneration, buildGenerationBody, buildOpenRouterBody, createImageGenClient, defaultImageGenModelId, estimateImageGenCost, listImageGenModels, parseGenerationResponse, resolveImageGenModel } from "./image-gen-client.mjs";
|
|
6
5
|
import { AnalyzeOptions, CssFix, FixSuggestion, PipelineConfig, ReasoningPipeline, StructuredDiffReport, VisualChange, createReasoningPipeline } from "./reasoning-pipeline.mjs";
|
|
7
6
|
import { ActualChange, ExpectationMapping, ReasoningChain, reasonAboutChanges } from "./reasoning.mjs";
|
|
7
|
+
import { LLMProvider, buildIntent, buildIntentWithLLM, buildReasoningPrompt, extractDiffSemantics, parseDiff } from "./intent.mjs";
|
|
8
8
|
import { DEFAULT_IMAGE_BUDGET, ImageBudget, ZoomCoordinates } from "./zoom-geometry.mjs";
|
|
9
9
|
import { SingleLookResult, VisionChatDriver, ZoomLoopOptions, ZoomLoopResult, parseZoomRequests, runSingleLook, runZoomLoop } from "./zoom-loop.mjs";
|
|
10
10
|
import { anthropicDriver, geminiDriver, openAiCompatibleDriver } from "./zoom-drivers.mjs";
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_IMAGE_BUDGET } from "./zoom-geometry.mjs";
|
|
2
2
|
import { VrtConfigError } from "./errors.mjs";
|
|
3
|
-
import { IMAGE_GEN_DEFAULT_MODEL, buildGenerationBody, buildOpenRouterBody, createImageGenClient, defaultImageGenModelId, estimateImageGenCost, listImageGenModels, parseGenerationResponse, resolveImageGenModel } from "./image-gen-client.mjs";
|
|
4
3
|
import { OPENAI_DEFAULT_MODEL, createLLMProvider, createUnifiedLLMClient } from "./llm-client.mjs";
|
|
5
4
|
import { createVlmClient, fetchVisionModels, isGeminiDirectModel, listGeminiModels, listModels, resolveGeminiModel, resolveModel } from "./vlm-client.mjs";
|
|
5
|
+
import { IMAGE_GEN_DEFAULT_MODEL, buildGenerationBody, buildOpenRouterBody, createImageGenClient, defaultImageGenModelId, estimateImageGenCost, listImageGenModels, parseGenerationResponse, resolveImageGenModel } from "./image-gen-client.mjs";
|
|
6
6
|
import { createReasoningPipeline } from "./reasoning-pipeline.mjs";
|
|
7
7
|
import { reasonAboutChanges } from "./reasoning.mjs";
|
|
8
8
|
import { buildIntent, buildIntentWithLLM, buildReasoningPrompt, extractDiffSemantics, parseDiff } from "./intent.mjs";
|
package/dist/intent.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ChangeIntent, DiffSemantics, FileChange, VrtDiff } from "@mizchi/vlmkit-core/types.ts";
|
|
2
|
-
//#region src/intent.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Parse git diff and return structured change information.
|
|
5
4
|
*/
|
|
@@ -23,5 +22,4 @@ export declare function buildIntentWithLLM(files: FileChange[], commitMessage: s
|
|
|
23
22
|
/**
|
|
24
23
|
* Build a reasoning prompt that validates VRT diff against Intent.
|
|
25
24
|
*/
|
|
26
|
-
export declare function buildReasoningPrompt(diff: VrtDiff, intent: ChangeIntent): string;
|
|
27
|
-
//#endregion
|
|
25
|
+
export declare function buildReasoningPrompt(diff: VrtDiff, intent: ChangeIntent): string;
|
package/dist/intent.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
|
-
|
|
3
|
+
// src/intent.ts
|
|
4
4
|
const execFileAsync = promisify(execFile);
|
|
5
5
|
/**
|
|
6
6
|
* Parse git diff and return structured change information.
|
|
@@ -209,5 +209,4 @@ Respond in JSON:
|
|
|
209
209
|
"confidence": 0.0-1.0
|
|
210
210
|
}`;
|
|
211
211
|
}
|
|
212
|
-
//#endregion
|
|
213
212
|
export { buildIntent, buildIntentWithLLM, buildReasoningPrompt, extractDiffSemantics, parseDiff };
|
package/dist/jev-client.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/jev-client.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* TypeSafe's Jev (System One): typed questions about a state, typed answers back. No prose.
|
|
4
3
|
*
|
|
@@ -129,5 +128,4 @@ export declare function jevBoxToPixels(box: JevBox, width: number, height: numbe
|
|
|
129
128
|
export declare function buildJevForm(req: JevRequest): FormData;
|
|
130
129
|
export declare function askJev<Q extends Record<string, JevQuestion>>(req: JevRequest<Q>, options?: JevClientOptions): Promise<JevResponse<Q>>;
|
|
131
130
|
/** Decode-free sanity: a PNG Buffer that Jev would accept, or the reason it would not. */
|
|
132
|
-
export declare function checkPngForJev(bytes: Uint8Array): string | null;
|
|
133
|
-
//#endregion
|
|
131
|
+
export declare function checkPngForJev(bytes: Uint8Array): string | null;
|
package/dist/jev-client.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/jev-client.ts
|
|
2
2
|
/**
|
|
3
3
|
* TypeSafe's Jev (System One): typed questions about a state, typed answers back. No prose.
|
|
4
4
|
*
|
|
@@ -143,5 +143,4 @@ function checkPngForJev(bytes) {
|
|
|
143
143
|
const { width, height } = pngSize(bytes);
|
|
144
144
|
return jevImageProblem(width, height, bytes.length);
|
|
145
145
|
}
|
|
146
|
-
//#endregion
|
|
147
146
|
export { JEV_DEFAULT_MODEL, JEV_ENDPOINT, JEV_IMAGE_LIMITS, JEV_INPUT_USD_PER_TOKEN, JevApiError, askJev, buildJevForm, checkPngForJev, jevBoxToPixels, jevImageProblem, pngImage, pngSize };
|
package/dist/llm-client.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LLMProvider } from "./intent.mjs";
|
|
2
|
-
//#region src/llm-client.d.ts
|
|
3
2
|
export interface LLMClientOptions {
|
|
4
3
|
/** Whether vision support is needed */
|
|
5
4
|
vision?: boolean;
|
|
@@ -95,5 +94,4 @@ export interface CreateLLMProviderOptions {
|
|
|
95
94
|
* provider in the fallback chain has an API key. Pass
|
|
96
95
|
* `{ throwIfMissing: false }` for the legacy `T | null` return.
|
|
97
96
|
*/
|
|
98
|
-
export declare function createLLMProvider(options?: CreateLLMProviderOptions): LLMProvider | null;
|
|
99
|
-
//#endregion
|
|
97
|
+
export declare function createLLMProvider(options?: CreateLLMProviderOptions): LLMProvider | null;
|
package/dist/llm-client.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VrtConfigError } from "./errors.mjs";
|
|
2
2
|
import { readEnv } from "@mizchi/vlmkit-core/project-config.ts";
|
|
3
|
-
|
|
3
|
+
// src/llm-client.ts
|
|
4
4
|
function createAnthropicClient(apiKey, model) {
|
|
5
5
|
const modelId = model ?? "claude-sonnet-4-6";
|
|
6
6
|
async function call(content, maxTokens) {
|
|
@@ -384,5 +384,4 @@ function createLLMProvider(options) {
|
|
|
384
384
|
if (throwIfMissing) throw new VrtConfigError("NO_PROVIDER_AVAILABLE", "No LLM provider available. Set one of: GEMINI_API_KEY, ANTHROPIC_API_KEY, OPENROUTER_API_KEY.");
|
|
385
385
|
return null;
|
|
386
386
|
}
|
|
387
|
-
//#endregion
|
|
388
387
|
export { OPENAI_DEFAULT_MODEL, createLLMProvider, createUnifiedLLMClient };
|
package/dist/locate.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JevClientOptions, JevRequest, JevResponse } from "./jev-client.mjs";
|
|
2
|
-
//#region src/locate.d.ts
|
|
3
2
|
export interface LocatedBox {
|
|
4
3
|
x: number;
|
|
5
4
|
y: number;
|
|
@@ -65,4 +64,4 @@ export declare class LocateError extends Error {
|
|
|
65
64
|
}
|
|
66
65
|
/** Locate `description` on a PNG screenshot. `description` names one thing: "the Save button". */
|
|
67
66
|
export declare function locateByDescription(png: Uint8Array, description: string, options?: LocateOptions): Promise<LocateResult>;
|
|
68
|
-
|
|
67
|
+
export {};
|
package/dist/locate.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JEV_IMAGE_LIMITS, askJev, jevBoxToPixels, pngImage } from "./jev-client.mjs";
|
|
2
|
-
import { decodeImage, encodePngImage } from "./zoom-image.mjs";
|
|
3
2
|
import { regionKindScale, regionKindView } from "./region-kind.mjs";
|
|
4
|
-
|
|
3
|
+
import { decodeImage, encodePngImage } from "./zoom-image.mjs";
|
|
4
|
+
// src/locate.ts
|
|
5
5
|
/**
|
|
6
6
|
* Find an element on a screenshot from a description ("the Save button"), with no DOM.
|
|
7
7
|
*
|
|
@@ -155,5 +155,4 @@ async function locateByDescription(png, description, options = {}) {
|
|
|
155
155
|
costUsd
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
-
//#endregion
|
|
159
158
|
export { LocateError, firstLookScale, locateByDescription, refineWindow };
|
package/dist/motion-check.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { JevClientOptions } from "./jev-client.mjs";
|
|
2
2
|
import { JevAsk } from "./locate.mjs";
|
|
3
|
-
import { EasingName, MotionDirection, MotionPathReport, MotionSegment, OriginName } from "@mizchi/vlmkit-judge/motion-path.ts";
|
|
4
|
-
//#region src/motion-check.d.ts
|
|
3
|
+
import { EasingName, MotionDirection, MotionPathReport, MotionSegment, OriginName, OriginPoint } from "@mizchi/vlmkit-judge/motion-path.ts";
|
|
5
4
|
/** A target measured by the page at a frame: border box (frame pixels), rendered opacity, transform scale. */
|
|
6
5
|
export interface MotionDom {
|
|
7
6
|
box: {
|
|
@@ -37,6 +36,46 @@ export interface MotionDom {
|
|
|
37
36
|
notRendered?: boolean;
|
|
38
37
|
/** Every colour it paints (background stops, text, border), RGBA in order. */
|
|
39
38
|
paint?: number[];
|
|
39
|
+
/** Its gradients' stop positions and angles, on paint's 0-255 scale (100% or a turn is 255). */
|
|
40
|
+
stops?: number[];
|
|
41
|
+
/** Its box shadows: RGBA of each, then offsets, blur and spread (px). */
|
|
42
|
+
shadow?: number[];
|
|
43
|
+
/** A conic gradient's first arc, in degrees from its start (it grows as a ring fills clockwise). */
|
|
44
|
+
sweepDeg?: number;
|
|
45
|
+
/** Its own transform's translation (px): what carries its centre when it slides. */
|
|
46
|
+
shift?: number[];
|
|
47
|
+
/** Its clip-path's numbers (inset edges, radii), on paint's scale (100% is 255). */
|
|
48
|
+
clip?: number[];
|
|
49
|
+
/** Its filter's numbers (a blur's radius x 8, fractions x 255). */
|
|
50
|
+
filter?: number[];
|
|
51
|
+
/** A filter its finished animation's fill holds at rest, and why that matters. */
|
|
52
|
+
heldFilter?: string;
|
|
53
|
+
/** Its animation's @keyframes name is defined more than once, and what each defines. */
|
|
54
|
+
dupKeyframes?: string;
|
|
55
|
+
/** Its angle as drawn through every transform up the tree (2D only), and the ancestor that turns. */
|
|
56
|
+
screenDeg?: number;
|
|
57
|
+
turnedBy?: string;
|
|
58
|
+
/** One of its animations overridden on a property by a later one in animation-name. */
|
|
59
|
+
overriddenBy?: string;
|
|
60
|
+
/** Its own timing function when it is a curve with no name (cubic-bezier(…), linear(…)). */
|
|
61
|
+
ownEasing?: string;
|
|
62
|
+
/** A transition / animation duration var() that resolves to a unitless number. */
|
|
63
|
+
varDuration?: string;
|
|
64
|
+
/** Every run of its own animations (ms), when there is more than one. */
|
|
65
|
+
durations?: number[];
|
|
66
|
+
/** A keyframe of its own animation sets a timing function that overrides the element's. */
|
|
67
|
+
kfEasing?: string;
|
|
68
|
+
/** Points along its edge another element paints over (the 5x5 grid never reaches an edge). */
|
|
69
|
+
edgeCover?: {
|
|
70
|
+
share: number;
|
|
71
|
+
message: string;
|
|
72
|
+
};
|
|
73
|
+
/** It turns in 3D with no perspective to give the turn depth, and what to set. */
|
|
74
|
+
flat3d?: string;
|
|
75
|
+
/** Its own animation offsets a box that is position: static, where top / left do nothing. */
|
|
76
|
+
inertOffsets?: string;
|
|
77
|
+
/** A finished animation's forwards fill still holds what it animated, and why that matters. */
|
|
78
|
+
heldByFill?: string;
|
|
40
79
|
/** Its transition on background runs over a gradient (which steps: gradients do not interpolate). */
|
|
41
80
|
discreteBg?: boolean;
|
|
42
81
|
/** It takes a click at its centre as the page is. */
|
|
@@ -70,6 +109,8 @@ export interface MotionCheckOptions {
|
|
|
70
109
|
targetEasing?: readonly (EasingName | readonly EasingName[] | undefined)[];
|
|
71
110
|
/** The point a scale grows from: every target's, or per target in order. */
|
|
72
111
|
expectOrigin?: OriginName | readonly (OriginName | undefined)[];
|
|
112
|
+
/** The point a turn keeps still, in the element's own units: every target's, or per target in order. */
|
|
113
|
+
expectPivot?: readonly (OriginPoint | undefined)[];
|
|
73
114
|
/** When each target's own animation begins (page ms), per target in order. */
|
|
74
115
|
expectStartMs?: readonly (number | undefined)[];
|
|
75
116
|
/**
|
|
@@ -77,13 +118,18 @@ export interface MotionCheckOptions {
|
|
|
77
118
|
* first target's (or its --expect-start) plus k times this.
|
|
78
119
|
*/
|
|
79
120
|
expectStaggerMs?: number;
|
|
121
|
+
/** Device pixels per CSS px in the frames (a 2x capture): the frame's size in CSS px is its size over this. */
|
|
122
|
+
frameScale?: number;
|
|
80
123
|
/** How long one run takes (ms) and how many runs (null: infinite): one for all, or per target. */
|
|
81
|
-
expectDurationMs?: readonly number[];
|
|
82
|
-
expectIterations?: readonly (number | null)[];
|
|
124
|
+
expectDurationMs?: readonly (number | undefined)[];
|
|
125
|
+
expectIterations?: readonly (number | null | undefined)[];
|
|
126
|
+
expectLines?: readonly (number | undefined)[];
|
|
83
127
|
/** Which way each target's first segment moves: one for all, or per target. */
|
|
84
|
-
expectDirection?: readonly MotionDirection[];
|
|
128
|
+
expectDirection?: readonly (MotionDirection | undefined)[];
|
|
85
129
|
/** Every target's centre must not move: only its size and opacity change. */
|
|
86
130
|
expectStill?: boolean;
|
|
131
|
+
/** Its angle on screen must not change (a label kept level inside a turning dial). */
|
|
132
|
+
expectUpright?: boolean;
|
|
87
133
|
/** Per target in order: this one's centre must not move. */
|
|
88
134
|
expectStillFor?: readonly boolean[];
|
|
89
135
|
/** Animations that change layout on the page ("div.notice animates margin-top"). */
|
|
@@ -152,5 +198,4 @@ export interface MotionCheckReport {
|
|
|
152
198
|
costUsd: number;
|
|
153
199
|
inputTokens: number;
|
|
154
200
|
}
|
|
155
|
-
export declare function checkMotionFrames(frames: readonly MotionFrame[], options: MotionCheckOptions): Promise<MotionCheckReport>;
|
|
156
|
-
//#endregion
|
|
201
|
+
export declare function checkMotionFrames(frames: readonly MotionFrame[], options: MotionCheckOptions): Promise<MotionCheckReport>;
|
package/dist/motion-check.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { JEV_IMAGE_LIMITS, askJev, jevBoxToPixels, pngImage } from "./jev-client.mjs";
|
|
2
|
-
import { decodeImage, encodePngImage, resample } from "./zoom-image.mjs";
|
|
3
|
-
import { regionKindScale, regionKindView, regionKindWindow } from "./region-kind.mjs";
|
|
4
|
-
import { firstLookScale } from "./locate.mjs";
|
|
5
2
|
import { claimInstruction } from "./claims.mjs";
|
|
3
|
+
import { firstLookScale } from "./locate.mjs";
|
|
4
|
+
import { regionKindScale, regionKindView, regionKindWindow } from "./region-kind.mjs";
|
|
5
|
+
import { decodeImage, encodePngImage, resample } from "./zoom-image.mjs";
|
|
6
6
|
import { judgeMotionPath } from "@mizchi/vlmkit-judge/motion-path.ts";
|
|
7
|
-
|
|
7
|
+
// src/motion-check.ts
|
|
8
8
|
/**
|
|
9
9
|
* Is an animation visually broken? Frames of it, a target described in words, and statements
|
|
10
10
|
* that must not be seen. Jev answers per frame; vlmkit judges the motion.
|
|
@@ -52,9 +52,10 @@ async function checkMotionFrames(frames, options) {
|
|
|
52
52
|
}
|
|
53
53
|
const answers = options.jev === false ? frames.map((frame) => {
|
|
54
54
|
const img = decodeImage(Buffer.from(frame.png));
|
|
55
|
+
const k = options.frameScale ?? 1;
|
|
55
56
|
frameSize ??= {
|
|
56
|
-
width: img.width,
|
|
57
|
-
height: img.height
|
|
57
|
+
width: Math.round(img.width / k),
|
|
58
|
+
height: Math.round(img.height / k)
|
|
58
59
|
};
|
|
59
60
|
return {
|
|
60
61
|
atMs: frame.atMs,
|
|
@@ -185,10 +186,15 @@ async function checkMotionFrames(frames, options) {
|
|
|
185
186
|
if (a.present >= threshold && b.present >= threshold && iou(a.box, b.box) > .5) a.unsure = b.unsure = true;
|
|
186
187
|
}
|
|
187
188
|
const domAt = new Map(frames.map((f) => [f.atMs, f.dom]));
|
|
188
|
-
const
|
|
189
|
-
const
|
|
189
|
+
const side = (i) => !!(options.expectStillFor?.[i] || options.exitsFor?.[i]);
|
|
190
|
+
const someMain = options.targets.some((_, i) => !side(i));
|
|
191
|
+
const sharedOff = (i) => side(i) && someMain;
|
|
192
|
+
const perTarget = (xs, i) => xs === void 0 ? void 0 : xs.length === 1 ? sharedOff(i) ? void 0 : xs[0] : xs[i];
|
|
193
|
+
const originFor = (i) => typeof options.expectOrigin === "string" ? sharedOff(i) ? void 0 : options.expectOrigin : options.expectOrigin?.length === 1 ? sharedOff(i) ? void 0 : options.expectOrigin[0] : options.expectOrigin?.[i];
|
|
194
|
+
const easingFor = (i) => options.targetEasing?.[i] ?? (sharedOff(i) ? void 0 : options.expectEasing);
|
|
190
195
|
let staggerFrom = options.expectStartMs?.[0];
|
|
191
196
|
const startFor = (i) => options.expectStartMs?.[i] ?? (options.expectStaggerMs !== void 0 && i > 0 && staggerFrom !== void 0 ? staggerFrom + i * options.expectStaggerMs : void 0);
|
|
197
|
+
const startFrom = (i) => options.expectStartMs?.[i] !== void 0 ? `--expect-start ${Math.round(options.expectStartMs[i])}` : `${options.expectStartMs?.[0] !== void 0 ? `--expect-start ${Math.round(options.expectStartMs[0])}` : `the first target's measured start ${Math.round(staggerFrom)}ms`} + ${i} × --expect-stagger ${Math.round(options.expectStaggerMs)}`;
|
|
192
198
|
const targets = options.targets.map((target, i) => {
|
|
193
199
|
const measured = frames.every((f) => f.dom?.[i]);
|
|
194
200
|
const samples = answers.map((f) => ({
|
|
@@ -206,19 +212,68 @@ async function checkMotionFrames(frames, options) {
|
|
|
206
212
|
...frameSize ? { frame: frameSize } : {},
|
|
207
213
|
presenceThreshold: threshold,
|
|
208
214
|
...options.exits || options.exitsFor?.[i] ? { exits: true } : {},
|
|
209
|
-
...
|
|
215
|
+
...easingFor(i) ? { expectEasing: easingFor(i) } : {},
|
|
210
216
|
...originFor(i) ? { expectOrigin: originFor(i) } : {},
|
|
211
|
-
...
|
|
217
|
+
...perTarget(options.expectPivot, i) ? { expectPivot: perTarget(options.expectPivot, i) } : {},
|
|
218
|
+
...startFor(i) !== void 0 ? {
|
|
219
|
+
expectStartMs: startFor(i),
|
|
220
|
+
expectStartFrom: startFrom(i)
|
|
221
|
+
} : {},
|
|
212
222
|
...perTarget(options.expectDurationMs, i) !== void 0 ? { expectDurationMs: perTarget(options.expectDurationMs, i) } : {},
|
|
213
223
|
...perTarget(options.expectDirection, i) !== void 0 ? { expectDirection: perTarget(options.expectDirection, i) } : {},
|
|
224
|
+
...perTarget(options.expectLines, i) !== void 0 ? { expectLines: perTarget(options.expectLines, i) } : {},
|
|
214
225
|
...perTarget(options.expectIterations, i) !== void 0 ? { expectIterations: perTarget(options.expectIterations, i) } : {},
|
|
215
226
|
...options.expectStill || options.expectStillFor?.[i] ? { expectStill: true } : {},
|
|
227
|
+
...options.expectUpright ? { expectUpright: true } : {},
|
|
216
228
|
...options.layoutMovers ? { layoutMovers: options.layoutMovers } : {}
|
|
217
229
|
})
|
|
218
230
|
};
|
|
219
231
|
if (i === 0) staggerFrom ??= judged.startsAtMs;
|
|
220
232
|
return judged;
|
|
221
233
|
});
|
|
234
|
+
if (options.targets.length > 1) {
|
|
235
|
+
const once = [
|
|
236
|
+
[
|
|
237
|
+
"direction-mismatch",
|
|
238
|
+
"--expect-direction",
|
|
239
|
+
options.expectDirection?.length === 1
|
|
240
|
+
],
|
|
241
|
+
[
|
|
242
|
+
"duration-mismatch",
|
|
243
|
+
"--expect-duration",
|
|
244
|
+
options.expectDurationMs?.length === 1
|
|
245
|
+
],
|
|
246
|
+
[
|
|
247
|
+
"iterations-mismatch",
|
|
248
|
+
"--expect-iterations",
|
|
249
|
+
options.expectIterations?.length === 1
|
|
250
|
+
],
|
|
251
|
+
[
|
|
252
|
+
"lines-mismatch",
|
|
253
|
+
"--expect-lines",
|
|
254
|
+
options.expectLines?.length === 1
|
|
255
|
+
],
|
|
256
|
+
[
|
|
257
|
+
"origin-mismatch",
|
|
258
|
+
"--expect-origin",
|
|
259
|
+
typeof options.expectOrigin === "string" || options.expectOrigin?.length === 1 || options.expectPivot?.length === 1
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
"easing-mismatch",
|
|
263
|
+
"--expect-easing",
|
|
264
|
+
!!options.expectEasing && !options.targetEasing
|
|
265
|
+
],
|
|
266
|
+
[
|
|
267
|
+
"still-mismatch",
|
|
268
|
+
"--expect-still",
|
|
269
|
+
!!options.expectStill
|
|
270
|
+
]
|
|
271
|
+
];
|
|
272
|
+
for (const t of targets) for (const f of t.findings) {
|
|
273
|
+
const hit = once.find(([rule, , given]) => given && f.rule === rule);
|
|
274
|
+
if (hit) f.message += ` (${hit[1]} was given once, so it is every target's: give one per target in order${hit[1] === "--expect-still" ? ", or --still <css> for the one that stays" : ", any for one it does not describe"})`;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
222
277
|
const forbidden = [];
|
|
223
278
|
forbid.forEach((statement, i) => {
|
|
224
279
|
const seen = answers.filter((f) => f.forbid[i] >= threshold).map((f) => ({
|
|
@@ -246,5 +301,4 @@ async function checkMotionFrames(frames, options) {
|
|
|
246
301
|
inputTokens
|
|
247
302
|
};
|
|
248
303
|
}
|
|
249
|
-
//#endregion
|
|
250
304
|
export { checkMotionFrames };
|
package/dist/nlp.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
//#region src/nlp.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Text-matching helpers shared between expectation matching and reasoning.
|
|
4
3
|
*/
|
|
5
4
|
export declare const STOP_WORDS: Set<string>;
|
|
6
|
-
export declare const SYNONYMS: Record<string, string[]>;
|
|
7
|
-
//#endregion
|
|
5
|
+
export declare const SYNONYMS: Record<string, string[]>;
|
package/dist/nlp.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/nlp.ts
|
|
2
2
|
/**
|
|
3
3
|
* Text-matching helpers shared between expectation matching and reasoning.
|
|
4
4
|
*/
|
|
@@ -46,5 +46,4 @@ const SYNONYMS = {
|
|
|
46
46
|
column: ["columnheader", "header"],
|
|
47
47
|
header: ["columnheader", "column"]
|
|
48
48
|
};
|
|
49
|
-
//#endregion
|
|
50
49
|
export { STOP_WORDS, SYNONYMS };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ResolutionPreset } from "@mizchi/vlmkit-core/image-resize.ts";
|
|
2
|
-
//#region src/reasoning-pipeline.d.ts
|
|
3
2
|
export interface VisualChange {
|
|
4
3
|
element: string;
|
|
5
4
|
property: string;
|
|
@@ -88,5 +87,4 @@ export interface ReasoningPipeline {
|
|
|
88
87
|
vlmModel: string;
|
|
89
88
|
llmModel: string;
|
|
90
89
|
}
|
|
91
|
-
export declare function createReasoningPipeline(config?: PipelineConfig): ReasoningPipeline | null;
|
|
92
|
-
//#endregion
|
|
90
|
+
export declare function createReasoningPipeline(config?: PipelineConfig): ReasoningPipeline | null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { VrtConfigError } from "./errors.mjs";
|
|
2
1
|
import { createUnifiedLLMClient } from "./llm-client.mjs";
|
|
3
2
|
import { createVlmClient, resolveModel } from "./vlm-client.mjs";
|
|
3
|
+
import { VrtConfigError } from "./errors.mjs";
|
|
4
4
|
import { readEnv } from "@mizchi/vlmkit-core/project-config.ts";
|
|
5
5
|
import { resizeBase64Png } from "@mizchi/vlmkit-core/image-resize.ts";
|
|
6
|
-
|
|
6
|
+
// src/reasoning-pipeline.ts
|
|
7
7
|
/**
|
|
8
8
|
* VRT Reasoning Pipeline -- two-stage VLM + LLM pipeline
|
|
9
9
|
*
|
|
@@ -254,5 +254,4 @@ function createReasoningPipeline(config) {
|
|
|
254
254
|
}
|
|
255
255
|
};
|
|
256
256
|
}
|
|
257
|
-
//#endregion
|
|
258
257
|
export { createReasoningPipeline };
|
package/dist/reasoning.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { A11yDiff, ChangeIntent, PageExpectation } from "@mizchi/vlmkit-core/types.ts";
|
|
2
|
-
//#region src/reasoning.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Expectation -> change -> realization reasoning chain
|
|
5
4
|
*
|
|
@@ -35,5 +34,4 @@ export interface ExpectationMapping {
|
|
|
35
34
|
/**
|
|
36
35
|
* Reason about whether expected changes were realized in the a11y tree diff.
|
|
37
36
|
*/
|
|
38
|
-
export declare function reasonAboutChanges(testId: string, pageExp: PageExpectation, a11yDiff: A11yDiff | undefined, intent: ChangeIntent): ReasoningChain;
|
|
39
|
-
//#endregion
|
|
37
|
+
export declare function reasonAboutChanges(testId: string, pageExp: PageExpectation, a11yDiff: A11yDiff | undefined, intent: ChangeIntent): ReasoningChain;
|
package/dist/reasoning.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { STOP_WORDS, SYNONYMS } from "./nlp.mjs";
|
|
2
|
-
|
|
2
|
+
// src/reasoning.ts
|
|
3
3
|
/**
|
|
4
4
|
* Reason about whether expected changes were realized in the a11y tree diff.
|
|
5
5
|
*/
|
|
@@ -144,5 +144,4 @@ function buildReasoning(testId, expectation, mappings, sideEffects, verdict) {
|
|
|
144
144
|
}[verdict]}`);
|
|
145
145
|
return lines.join("\n");
|
|
146
146
|
}
|
|
147
|
-
//#endregion
|
|
148
147
|
export { reasonAboutChanges };
|
package/dist/region-kind.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JevClientOptions, JevResponse } from "./jev-client.mjs";
|
|
2
2
|
import { RgbaImage } from "./zoom-image.mjs";
|
|
3
|
-
//#region src/region-kind.d.ts
|
|
4
3
|
export type RegionKindLabel = "text" | "color" | "position" | "presence";
|
|
5
4
|
/** The options as Jev reads them. Changing a description changes the measured accuracy: re-run the bench. */
|
|
6
5
|
export declare const REGION_KIND_OPTIONS: Record<RegionKindLabel, string>;
|
|
@@ -67,4 +66,4 @@ export type RegionKindOutcome = {
|
|
|
67
66
|
* One region that fails is reported with its reason and leaves the others labelled.
|
|
68
67
|
*/
|
|
69
68
|
export declare function labelRegionKinds(baseline: RgbaImage, current: RgbaImage, regions: readonly RegionBox[], ask: AskRegionKind, concurrency?: number): Promise<RegionKindOutcome[]>;
|
|
70
|
-
|
|
69
|
+
export {};
|
package/dist/region-kind.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JEV_IMAGE_LIMITS, askJev, pngImage } from "./jev-client.mjs";
|
|
2
2
|
import { cropImage, encodePngImage, resample } from "./zoom-image.mjs";
|
|
3
|
-
|
|
3
|
+
// src/region-kind.ts
|
|
4
4
|
/**
|
|
5
5
|
* Name what changed in a pixel-diff region: text, colour, position, or presence.
|
|
6
6
|
*
|
|
@@ -136,5 +136,4 @@ async function labelRegionKinds(baseline, current, regions, ask, concurrency = 4
|
|
|
136
136
|
await Promise.all(Array.from({ length: Math.min(concurrency, regions.length) }, worker));
|
|
137
137
|
return out;
|
|
138
138
|
}
|
|
139
|
-
//#endregion
|
|
140
139
|
export { REGION_KIND_OPTIONS, REGION_KIND_QUESTION, REGION_KIND_SURE, jevRegionKindAsker, labelRegionKinds, regionKindScale, regionKindView, regionKindWindow };
|
package/dist/vlm-client.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/vlm-client.d.ts
|
|
2
1
|
export interface VlmModel {
|
|
3
2
|
id: string;
|
|
4
3
|
name: string;
|
|
@@ -67,5 +66,4 @@ export interface CreateVlmClientOptions {
|
|
|
67
66
|
* required API key isn't set in the environment. Pass
|
|
68
67
|
* `{ throwIfMissing: false }` for the legacy `T | null` return.
|
|
69
68
|
*/
|
|
70
|
-
export declare function createVlmClient(model: VlmModel, options?: CreateVlmClientOptions): Promise<VlmClient | null>;
|
|
71
|
-
//#endregion
|
|
69
|
+
export declare function createVlmClient(model: VlmModel, options?: CreateVlmClientOptions): Promise<VlmClient | null>;
|
package/dist/vlm-client.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VrtConfigError } from "./errors.mjs";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
|
|
3
|
+
// src/vlm-client.ts
|
|
4
4
|
/**
|
|
5
5
|
* VLM (Vision Language Model) client
|
|
6
6
|
*
|
|
@@ -437,5 +437,4 @@ async function createVlmClient(model, options) {
|
|
|
437
437
|
};
|
|
438
438
|
return orClient;
|
|
439
439
|
}
|
|
440
|
-
//#endregion
|
|
441
440
|
export { createVlmClient, fetchVisionModels, isClaudeDirectModel, isGeminiDirectModel, listClaudeModels, listGeminiModels, listModels, resetVisionModelCache, resolveClaudeModel, resolveGeminiModel, resolveModel };
|
package/dist/zoom-drivers.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { VisionChatDriver, ZoomToolSpec } from "./zoom-loop.mjs";
|
|
2
|
-
//#region src/zoom-drivers.d.ts
|
|
3
2
|
type Fetch = typeof fetch;
|
|
4
3
|
export interface OpenAiCompatibleDriverOptions {
|
|
5
4
|
model: string;
|
|
@@ -28,5 +27,4 @@ export interface GeminiDriverOptions {
|
|
|
28
27
|
fetch?: Fetch;
|
|
29
28
|
}
|
|
30
29
|
export declare function geminiDriver(options: GeminiDriverOptions): VisionChatDriver;
|
|
31
|
-
//#endregion
|
|
32
30
|
export type { ZoomToolSpec };
|
package/dist/zoom-drivers.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { zoomCallFromArgs } from "./zoom-loop.mjs";
|
|
2
|
-
|
|
2
|
+
// src/zoom-drivers.ts
|
|
3
3
|
async function postJson(fetcher, url, headers, body, provider) {
|
|
4
4
|
const res = await fetcher(url, {
|
|
5
5
|
method: "POST",
|
|
@@ -312,5 +312,4 @@ function withBroken(turn, broken) {
|
|
|
312
312
|
}))]
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
|
-
//#endregion
|
|
316
315
|
export { anthropicDriver, geminiDriver, openAiCompatibleDriver };
|
package/dist/zoom-geometry.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/zoom-geometry.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The arithmetic of letting a vision model zoom: which size it sees, which pixels a box it
|
|
4
3
|
* names refers to, and how large the magnified crop comes back. Pure — no image bytes here.
|
|
@@ -80,5 +79,4 @@ export declare function clampBox(box: Box, view: Size): {
|
|
|
80
79
|
* size is not an exact multiple of the original's), rounds outward so a 1px feature on the
|
|
81
80
|
* box's edge is kept, and never returns an empty box.
|
|
82
81
|
*/
|
|
83
|
-
export declare function viewBoxToOriginal(box: Box, view: Size, original: Size): Box;
|
|
84
|
-
//#endregion
|
|
82
|
+
export declare function viewBoxToOriginal(box: Box, view: Size, original: Size): Box;
|
package/dist/zoom-geometry.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/zoom-geometry.ts
|
|
2
2
|
/**
|
|
3
3
|
* 1568px on the long edge and about 1.15 megapixels: the size below which Anthropic documents
|
|
4
4
|
* that it does not resize. Other providers resize by their own rules (OpenAI's high-detail path
|
|
@@ -99,5 +99,4 @@ function viewBoxToOriginal(box, view, original) {
|
|
|
99
99
|
y2: Math.min(original.height, Math.max(y1 + 1, Math.ceil(box.y2 * sy)))
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
//#endregion
|
|
103
102
|
export { DEFAULT_IMAGE_BUDGET, clampBox, fitToBudget, toViewBox, viewBoxToOriginal, zoomSize };
|
package/dist/zoom-image.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Box, ImageBudget, Size } from "./zoom-geometry.mjs";
|
|
2
|
-
//#region src/zoom-image.d.ts
|
|
3
2
|
export interface RgbaImage {
|
|
4
3
|
width: number;
|
|
5
4
|
height: number;
|
|
@@ -40,5 +39,4 @@ export type ZoomOutcome = {
|
|
|
40
39
|
* spaces, so the model can place what it sees in the zoom back onto the view it is reasoning
|
|
41
40
|
* about ("…a 180x60px region of the original, returned at 1568x522px").
|
|
42
41
|
*/
|
|
43
|
-
export declare function zoomInto(source: ZoomSource, box: Box, budget?: ImageBudget): ZoomOutcome;
|
|
44
|
-
//#endregion
|
|
42
|
+
export declare function zoomInto(source: ZoomSource, box: Box, budget?: ImageBudget): ZoomOutcome;
|
package/dist/zoom-image.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_IMAGE_BUDGET, clampBox, fitToBudget, viewBoxToOriginal, zoomSize } from "./zoom-geometry.mjs";
|
|
2
2
|
import { PNG } from "pngjs";
|
|
3
|
-
|
|
3
|
+
// src/zoom-image.ts
|
|
4
4
|
/**
|
|
5
5
|
* The image half of zooming: make the view the model sees, and cut and magnify a region of
|
|
6
6
|
* the original when it asks. PNG in, PNG out, through `pngjs` only, so no native image library
|
|
@@ -143,5 +143,4 @@ function zoomInto(source, box, budget = DEFAULT_IMAGE_BUDGET) {
|
|
|
143
143
|
text: `Zoomed into (${b.x1},${b.y1})-(${b.x2},${b.y2}) of the image you see at ${source.view.width}x${source.view.height}px: a ${crop.width}x${crop.height}px region of the original, returned magnified to ${size.width}x${size.height}px.`
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
//#endregion
|
|
147
146
|
export { cropImage, decodeImage, encodePngImage, prepareZoomSource, resample, zoomInto };
|
package/dist/zoom-loop.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Box, ImageBudget, ZoomCoordinates } from "./zoom-geometry.mjs";
|
|
2
|
-
//#region src/zoom-loop.d.ts
|
|
3
2
|
export type ZoomPart = {
|
|
4
3
|
type: "text";
|
|
5
4
|
text: string;
|
|
@@ -125,5 +124,4 @@ export declare function runSingleLook(driver: VisionChatDriver, images: readonly
|
|
|
125
124
|
* Run the loop. `images` are PNGs at any size; each is shown at `budget` and labelled with its
|
|
126
125
|
* index and size. The answer is the model's last reply with no zoom request.
|
|
127
126
|
*/
|
|
128
|
-
export declare function runZoomLoop(driver: VisionChatDriver, images: readonly ZoomImageInput[], question: string, options?: ZoomLoopOptions): Promise<ZoomLoopResult>;
|
|
129
|
-
//#endregion
|
|
127
|
+
export declare function runZoomLoop(driver: VisionChatDriver, images: readonly ZoomImageInput[], question: string, options?: ZoomLoopOptions): Promise<ZoomLoopResult>;
|
package/dist/zoom-loop.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_IMAGE_BUDGET, toViewBox } from "./zoom-geometry.mjs";
|
|
2
2
|
import { prepareZoomSource, zoomInto } from "./zoom-image.mjs";
|
|
3
|
-
|
|
3
|
+
// src/zoom-loop.ts
|
|
4
4
|
/**
|
|
5
5
|
* The zoom loop, independent of any provider: show the model its images at a size we chose,
|
|
6
6
|
* give it one tool — `zoom(image, x1, y1, x2, y2)` — and answer each call with a magnified crop
|
|
@@ -310,5 +310,4 @@ async function runZoomLoop(driver, images, question, options = {}) {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
//#endregion
|
|
314
313
|
export { parseZoomRequests, runSingleLook, runZoomLoop, zoomCallFromArgs, zoomToolSpec };
|
package/dist/zoom.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { VlmModel, VlmResponse } from "./vlm-client.mjs";
|
|
2
|
-
import { Box, BoxProblem, DEFAULT_IMAGE_BUDGET, ImageBudget, Size, ZoomCoordinates, clampBox, fitToBudget, toViewBox, viewBoxToOriginal, zoomSize } from "./zoom-geometry.mjs";
|
|
3
2
|
import { DriverTurn, SingleLookResult, VisionChatDriver, ZoomCall, ZoomImageInput, ZoomLoopOptions, ZoomLoopResult, ZoomPart, ZoomResult, ZoomToolSpec, ZoomTurn, ZoomUsage, parseZoomRequests, runSingleLook, runZoomLoop, zoomCallFromArgs, zoomToolSpec } from "./zoom-loop.mjs";
|
|
3
|
+
import { Box, BoxProblem, DEFAULT_IMAGE_BUDGET, ImageBudget, Size, ZoomCoordinates, clampBox, fitToBudget, toViewBox, viewBoxToOriginal, zoomSize } from "./zoom-geometry.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
|
-
//#region src/zoom.d.ts
|
|
7
6
|
export interface ZoomDriverOptions {
|
|
8
7
|
/** Overrides the environment key lookup, as in `createVlmClient`. */
|
|
9
8
|
apiKey?: string;
|
|
@@ -24,5 +23,4 @@ export declare function analyzeWithZoom(model: VlmModel, images: readonly {
|
|
|
24
23
|
png: Buffer;
|
|
25
24
|
label?: string;
|
|
26
25
|
}[], prompt: string, options?: ZoomLoopOptions & ZoomDriverOptions): Promise<ZoomAnalysis>;
|
|
27
|
-
//#endregion
|
|
28
26
|
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,10 +1,10 @@
|
|
|
1
|
-
import { DEFAULT_IMAGE_BUDGET, clampBox, fitToBudget, toViewBox, viewBoxToOriginal, zoomSize } from "./zoom-geometry.mjs";
|
|
2
|
-
import { prepareZoomSource, zoomInto } from "./zoom-image.mjs";
|
|
3
1
|
import { VrtConfigError } from "./errors.mjs";
|
|
4
2
|
import { isClaudeDirectModel, isGeminiDirectModel } from "./vlm-client.mjs";
|
|
5
|
-
import { parseZoomRequests, runSingleLook, runZoomLoop, zoomCallFromArgs, zoomToolSpec } from "./zoom-loop.mjs";
|
|
6
3
|
import { anthropicDriver, geminiDriver, openAiCompatibleDriver } from "./zoom-drivers.mjs";
|
|
7
|
-
|
|
4
|
+
import { parseZoomRequests, runSingleLook, runZoomLoop, zoomCallFromArgs, zoomToolSpec } from "./zoom-loop.mjs";
|
|
5
|
+
import { DEFAULT_IMAGE_BUDGET, clampBox, fitToBudget, toViewBox, viewBoxToOriginal, zoomSize } from "./zoom-geometry.mjs";
|
|
6
|
+
import { prepareZoomSource, zoomInto } from "./zoom-image.mjs";
|
|
7
|
+
// src/zoom.ts
|
|
8
8
|
/**
|
|
9
9
|
* Zoom for any VLM this package already knows: the model ids `createVlmClient` takes
|
|
10
10
|
* (`claude:…`, `gemini:…`, an OpenRouter id) resolve to a zoom driver with the same keys, so a
|
|
@@ -58,5 +58,4 @@ async function analyzeWithZoom(model, images, prompt, options = {}) {
|
|
|
58
58
|
zoom
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
61
|
export { DEFAULT_IMAGE_BUDGET, analyzeWithZoom, anthropicDriver, clampBox, createZoomDriver, fitToBudget, geminiDriver, openAiCompatibleDriver, parseZoomRequests, prepareZoomSource, runSingleLook, runZoomLoop, toViewBox, viewBoxToOriginal, zoomCallFromArgs, zoomInto, zoomSize, zoomToolSpec };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mizchi/vlmkit-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.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,8 +38,8 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@google/generative-ai": "^0.24.1",
|
|
40
40
|
"pngjs": "^7.0.0",
|
|
41
|
-
"@mizchi/vlmkit-core": "0.
|
|
42
|
-
"@mizchi/vlmkit-judge": "0.
|
|
41
|
+
"@mizchi/vlmkit-core": "0.28.0",
|
|
42
|
+
"@mizchi/vlmkit-judge": "0.28.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "pnpm --dir ../.. exec vp pack --filter @mizchi/vlmkit-ai",
|