@mizchi/vlmkit-ai 0.23.2 → 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.
@@ -0,0 +1,34 @@
1
+ import { JevClientOptions } from "./jev-client.mjs";
2
+ import { JevAsk } from "./locate.mjs";
3
+ export type ClaimExpectation = "shown" | "absent";
4
+ export interface Claim {
5
+ /** What the screenshot shows, as a statement: "an error message", "a modal dialog open over the page". */
6
+ statement: string;
7
+ expect: ClaimExpectation;
8
+ }
9
+ export interface ClaimResult extends Claim {
10
+ /** Jev's probability that the screenshot shows it (0-1). */
11
+ noul: number;
12
+ pass: boolean;
13
+ /** Within `uncertainBand` of the threshold: look at the screenshot before acting on it. */
14
+ uncertain: boolean;
15
+ }
16
+ export interface ClaimsReport {
17
+ results: ClaimResult[];
18
+ passed: boolean;
19
+ model: string;
20
+ costUsd: number;
21
+ inputTokens: number;
22
+ }
23
+ export interface ClaimsOptions {
24
+ /** A claim is true at or above this (default 0.5). */
25
+ threshold?: number;
26
+ /** Distance from the threshold under which a result is `uncertain` (default 0.3). */
27
+ uncertainBand?: number;
28
+ model?: string;
29
+ ask?: JevAsk;
30
+ client?: JevClientOptions;
31
+ }
32
+ /** "an error message" → "`screenshot` shows an error message." A statement already starting with "shows" is kept. */
33
+ export declare function claimInstruction(statement: string): string;
34
+ export declare function checkClaims(png: Uint8Array, claims: readonly Claim[], options?: ClaimsOptions): Promise<ClaimsReport>;
@@ -0,0 +1,66 @@
1
+ import { JEV_IMAGE_LIMITS, askJev, pngImage } from "./jev-client.mjs";
2
+ import { firstLookScale } from "./locate.mjs";
3
+ import { decodeImage, encodePngImage, resample } from "./zoom-image.mjs";
4
+ // src/claims.ts
5
+ /**
6
+ * Cheap typed checks on a screenshot: statements a page must or must not make visible ("shows
7
+ * an error message", "shows a modal dialog open over the page"), each answered by Jev as a
8
+ * `noul` (the probability the statement is true), no prose to parse.
9
+ *
10
+ * All claims share one request and one image: Jev reads the image once and each further question
11
+ * costs about 20 tokens, so ten claims on a 1280x800 screenshot are about $0.00014 and 0.2s.
12
+ *
13
+ * Advisory, not a gate. The deterministic gates measure; this asks a model what a person would
14
+ * notice at a glance. Measured 2026-10-17 (`docs/reports/2026-10-17-jev-claims.md`) — read its
15
+ * per-claim false-alarm rates before trusting a claim worded differently.
16
+ */
17
+ /** "an error message" → "`screenshot` shows an error message." A statement already starting with "shows" is kept. */
18
+ function claimInstruction(statement) {
19
+ const s = statement.trim().replace(/[.\s]+$/, "").replace(/^(the\s+)?(screenshot|page|screen)\s+/i, "");
20
+ return /^(shows|contains|has|displays)\b/i.test(s) ? `\`screenshot\` ${s}.` : `\`screenshot\` shows ${s}.`;
21
+ }
22
+ async function checkClaims(png, claims, options = {}) {
23
+ if (claims.length === 0) throw new Error("no claims to check");
24
+ const ask = options.ask ?? ((req) => askJev(req, options.client));
25
+ const threshold = options.threshold ?? .5;
26
+ const band = options.uncertainBand ?? .3;
27
+ const img = decodeImage(Buffer.from(png));
28
+ const scale = firstLookScale(img.width, img.height);
29
+ if (scale === null) throw new Error(`${img.width}x${img.height} cannot be shown within Jev's ${JEV_IMAGE_LIMITS.minEdge}-${JEV_IMAGE_LIMITS.maxEdge}px edges`);
30
+ const shown = scale === 1 ? png : encodePngImage(resample(img, {
31
+ width: Math.round(img.width * scale),
32
+ height: Math.round(img.height * scale)
33
+ }));
34
+ const questions = {};
35
+ claims.forEach((c, i) => {
36
+ questions[`c${i}`] = {
37
+ type: "noul",
38
+ instructions: claimInstruction(c.statement)
39
+ };
40
+ });
41
+ const r = await ask({
42
+ model: options.model ?? "jev-1.14.0",
43
+ state: { screenshot: "SHOT" },
44
+ assets: { SHOT: pngImage(shown) },
45
+ questions
46
+ });
47
+ const answers = r.answers;
48
+ const results = claims.map((c, i) => {
49
+ const noul = answers[`c${i}`].noul;
50
+ const pass = c.expect === "shown" ? noul >= threshold : noul < threshold;
51
+ return {
52
+ ...c,
53
+ noul,
54
+ pass,
55
+ uncertain: Math.abs(noul - threshold) < band
56
+ };
57
+ });
58
+ return {
59
+ results,
60
+ passed: results.every((x) => x.pass),
61
+ model: r.model,
62
+ costUsd: r.costUsd,
63
+ inputTokens: r.usage.input_tokens
64
+ };
65
+ }
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
  *
@@ -15,10 +14,22 @@
15
14
  * Codes are stable; new ones can only be added (never renumbered or
16
15
  * removed) in minor versions.
17
16
  */
18
- type VrtConfigErrorCode = /** Required env var (`OPENROUTER_API_KEY`, `GEMINI_API_KEY`, `ANTHROPIC_API_KEY`) not set. */"MISSING_KEY" /** Provider/model id doesn't resolve. */ | "INVALID_MODEL" /** Model substring matches more than one candidate. */ | "MULTIPLE_MATCHES" /** `VLMKIT_LLM_PROVIDER` value is not one of the known providers. */ | "INVALID_PROVIDER" /** No provider in the fallback chain has an API key configured. */ | "NO_PROVIDER_AVAILABLE" /** An optional runtime dependency (e.g. `@google/generative-ai`) failed to import. */ | "MISSING_DEPENDENCY" /** Caller-supplied request parameters are malformed (empty prompt, out-of-range size, etc.). */ | "INVALID_REQUEST";
19
- declare class VrtConfigError extends Error {
17
+ export type VrtConfigErrorCode =
18
+ /** Required env var (`OPENROUTER_API_KEY`, `GEMINI_API_KEY`, `ANTHROPIC_API_KEY`) not set. */
19
+ "MISSING_KEY" |
20
+ /** Provider/model id doesn't resolve. */
21
+ "INVALID_MODEL" |
22
+ /** Model substring matches more than one candidate. */
23
+ "MULTIPLE_MATCHES" |
24
+ /** `VLMKIT_LLM_PROVIDER` value is not one of the known providers. */
25
+ "INVALID_PROVIDER" |
26
+ /** No provider in the fallback chain has an API key configured. */
27
+ "NO_PROVIDER_AVAILABLE" |
28
+ /** An optional runtime dependency (e.g. `@google/generative-ai`) failed to import. */
29
+ "MISSING_DEPENDENCY" |
30
+ /** Caller-supplied request parameters are malformed (empty prompt, out-of-range size, etc.). */
31
+ "INVALID_REQUEST";
32
+ export declare class VrtConfigError extends Error {
20
33
  readonly code: VrtConfigErrorCode;
21
34
  constructor(code: VrtConfigErrorCode, message: string);
22
- }
23
- //#endregion
24
- export { VrtConfigError, VrtConfigErrorCode };
35
+ }
package/dist/errors.mjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/errors.ts
1
+ // src/errors.ts
2
2
  var VrtConfigError = class extends Error {
3
3
  code;
4
4
  constructor(code, message) {
@@ -7,5 +7,4 @@ var VrtConfigError = class extends Error {
7
7
  this.code = code;
8
8
  }
9
9
  };
10
- //#endregion
11
10
  export { VrtConfigError };
@@ -1,11 +1,10 @@
1
- //#region src/image-gen-client.d.ts
2
- type ImageGenSize = "1024x1024" | "1024x1536" | "1536x1024" | "auto";
3
- type ImageGenQuality = "low" | "medium" | "high" | "auto";
4
- type ImageGenOutputFormat = "png" | "jpeg" | "webp";
5
- type ImageGenBackground = "opaque" | "transparent" | "auto";
1
+ export type ImageGenSize = "1024x1024" | "1024x1536" | "1536x1024" | "auto";
2
+ export type ImageGenQuality = "low" | "medium" | "high" | "auto";
3
+ export type ImageGenOutputFormat = "png" | "jpeg" | "webp";
4
+ export type ImageGenBackground = "opaque" | "transparent" | "auto";
6
5
  /** The figure bench's choice: 3/3 on its briefs at the lowest price measured (2026-09-30). */
7
- declare const IMAGE_GEN_DEFAULT_MODEL = "openai/gpt-image-2.5-flare";
8
- interface ImageGenModel {
6
+ export declare const IMAGE_GEN_DEFAULT_MODEL = "openai/gpt-image-2.5-flare";
7
+ export interface ImageGenModel {
9
8
  id: string;
10
9
  /** `openai`: api.openai.com + OPENAI_API_KEY. `openrouter`: openrouter.ai + OPENROUTER_API_KEY. */
11
10
  provider: "openai" | "openrouter";
@@ -14,7 +13,7 @@ interface ImageGenModel {
14
13
  costPer1MInputImageTokens: number;
15
14
  costPer1MOutputImageTokens: number;
16
15
  }
17
- interface ImageGenRequest {
16
+ export interface ImageGenRequest {
18
17
  prompt: string;
19
18
  size?: ImageGenSize;
20
19
  quality?: ImageGenQuality;
@@ -30,12 +29,12 @@ interface ImageGenRequest {
30
29
  */
31
30
  inputReferences?: string[];
32
31
  }
33
- interface ImageGenUsage {
32
+ export interface ImageGenUsage {
34
33
  inputTextTokens: number;
35
34
  inputImageTokens: number;
36
35
  outputTokens: number;
37
36
  }
38
- interface ImageGenResponse {
37
+ export interface ImageGenResponse {
39
38
  model: string;
40
39
  images: Uint8Array[];
41
40
  /** One per image when the API names it (`image/png`, `image/svg+xml`, …). */
@@ -44,7 +43,7 @@ interface ImageGenResponse {
44
43
  costUsd: number;
45
44
  latencyMs: number;
46
45
  }
47
- interface OpenRouterImageBody {
46
+ export interface OpenRouterImageBody {
48
47
  model: string;
49
48
  prompt: string;
50
49
  n: number;
@@ -58,7 +57,7 @@ interface OpenRouterImageBody {
58
57
  };
59
58
  }[];
60
59
  }
61
- interface ImageGenRequestBody {
60
+ export interface ImageGenRequestBody {
62
61
  model: string;
63
62
  prompt: string;
64
63
  size: ImageGenSize;
@@ -67,16 +66,16 @@ interface ImageGenRequestBody {
67
66
  output_format: ImageGenOutputFormat;
68
67
  background: ImageGenBackground;
69
68
  }
70
- interface ImageGenClient {
69
+ export interface ImageGenClient {
71
70
  model: ImageGenModel;
72
71
  generate(req: ImageGenRequest): Promise<ImageGenResponse>;
73
72
  }
74
- declare function listImageGenModels(): ImageGenModel[];
75
- declare function resolveImageGenModel(id: string): ImageGenModel;
73
+ export declare function listImageGenModels(): ImageGenModel[];
74
+ export declare function resolveImageGenModel(id: string): ImageGenModel;
76
75
  /** `VLMKIT_IMAGE_MODEL`, else the bench's default. */
77
- declare function defaultImageGenModelId(env?: Record<string, string | undefined>): string;
78
- declare function buildGenerationBody(model: ImageGenModel, req: ImageGenRequest): ImageGenRequestBody;
79
- declare function buildOpenRouterBody(model: ImageGenModel, req: ImageGenRequest): OpenRouterImageBody;
76
+ export declare function defaultImageGenModelId(env?: Record<string, string | undefined>): string;
77
+ export declare function buildGenerationBody(model: ImageGenModel, req: ImageGenRequest): ImageGenRequestBody;
78
+ export declare function buildOpenRouterBody(model: ImageGenModel, req: ImageGenRequest): OpenRouterImageBody;
80
79
  interface RawGenerationResponse {
81
80
  data?: Array<{
82
81
  b64_json?: string;
@@ -84,7 +83,8 @@ interface RawGenerationResponse {
84
83
  media_type?: string;
85
84
  }>;
86
85
  usage?: {
87
- /** OpenRouter: what the call was billed, in USD. */cost?: number;
86
+ /** OpenRouter: what the call was billed, in USD. */
87
+ cost?: number;
88
88
  prompt_tokens?: number;
89
89
  completion_tokens?: number;
90
90
  input_tokens?: number;
@@ -96,22 +96,21 @@ interface RawGenerationResponse {
96
96
  };
97
97
  };
98
98
  }
99
- interface ParsedGeneration {
99
+ export interface ParsedGeneration {
100
100
  images: Uint8Array[];
101
101
  mediaTypes: (string | null)[];
102
102
  usage: ImageGenUsage | null;
103
103
  /** The provider's own figure (OpenRouter `usage.cost`), when it gives one. */
104
104
  reportedCostUsd: number | null;
105
105
  }
106
- declare function parseGenerationResponse(json: RawGenerationResponse): ParsedGeneration;
107
- declare function estimateImageGenCost(model: ImageGenModel, usage: ImageGenUsage | null): number;
108
- interface CreateImageGenClientOptions {
106
+ export declare function parseGenerationResponse(json: RawGenerationResponse): ParsedGeneration;
107
+ export declare function estimateImageGenCost(model: ImageGenModel, usage: ImageGenUsage | null): number;
108
+ export interface CreateImageGenClientOptions {
109
109
  apiKey?: string;
110
110
  throwIfMissing?: boolean;
111
111
  /** Override the API base URL (for tests / proxies). */
112
112
  baseUrl?: string;
113
113
  }
114
114
  /** With no model: `VLMKIT_IMAGE_MODEL`, else `IMAGE_GEN_DEFAULT_MODEL`. */
115
- declare function createImageGenClient(modelOrId?: ImageGenModel | string, options?: CreateImageGenClientOptions): ImageGenClient;
116
- //#endregion
117
- export { 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 };
115
+ export declare function createImageGenClient(modelOrId?: ImageGenModel | string, options?: CreateImageGenClientOptions): ImageGenClient;
116
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { VrtConfigError } from "./errors.mjs";
2
- //#region src/image-gen-client.ts
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
  *
@@ -40,24 +40,24 @@ const IMAGE_GEN_MODELS = [{
40
40
  costPer1MInputImageTokens: 8,
41
41
  costPer1MOutputImageTokens: 30
42
42
  }];
43
- const VALID_SIZES = new Set([
43
+ const VALID_SIZES = /* @__PURE__ */ new Set([
44
44
  "1024x1024",
45
45
  "1024x1536",
46
46
  "1536x1024",
47
47
  "auto"
48
48
  ]);
49
- const VALID_QUALITIES = new Set([
49
+ const VALID_QUALITIES = /* @__PURE__ */ new Set([
50
50
  "low",
51
51
  "medium",
52
52
  "high",
53
53
  "auto"
54
54
  ]);
55
- const VALID_OUTPUT_FORMATS = new Set([
55
+ const VALID_OUTPUT_FORMATS = /* @__PURE__ */ new Set([
56
56
  "png",
57
57
  "jpeg",
58
58
  "webp"
59
59
  ]);
60
- const VALID_BACKGROUNDS = new Set([
60
+ const VALID_BACKGROUNDS = /* @__PURE__ */ new Set([
61
61
  "opaque",
62
62
  "transparent",
63
63
  "auto"
@@ -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,11 +1,11 @@
1
+ import { DEFAULT_IMAGE_BUDGET } from "./zoom-geometry.mjs";
1
2
  import { VrtConfigError } from "./errors.mjs";
2
- import { IMAGE_GEN_DEFAULT_MODEL, buildGenerationBody, buildOpenRouterBody, createImageGenClient, defaultImageGenModelId, estimateImageGenCost, listImageGenModels, parseGenerationResponse, resolveImageGenModel } from "./image-gen-client.mjs";
3
3
  import { OPENAI_DEFAULT_MODEL, createLLMProvider, createUnifiedLLMClient } from "./llm-client.mjs";
4
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";
5
6
  import { createReasoningPipeline } from "./reasoning-pipeline.mjs";
6
7
  import { reasonAboutChanges } from "./reasoning.mjs";
7
8
  import { buildIntent, buildIntentWithLLM, buildReasoningPrompt, extractDiffSemantics, parseDiff } from "./intent.mjs";
8
- import { DEFAULT_IMAGE_BUDGET } from "./zoom-geometry.mjs";
9
9
  import { parseZoomRequests, runSingleLook, runZoomLoop } from "./zoom-loop.mjs";
10
10
  import { anthropicDriver, geminiDriver, openAiCompatibleDriver } from "./zoom-drivers.mjs";
11
11
  import { analyzeWithZoom, createZoomDriver } from "./zoom.mjs";
package/dist/intent.d.mts CHANGED
@@ -1,29 +1,25 @@
1
1
  import { ChangeIntent, DiffSemantics, FileChange, VrtDiff } from "@mizchi/vlmkit-core/types.ts";
2
-
3
- //#region src/intent.d.ts
4
2
  /**
5
3
  * Parse git diff and return structured change information.
6
4
  */
7
- declare function extractDiffSemantics(repoDir: string, base?: string, head?: string): Promise<DiffSemantics>;
5
+ export declare function extractDiffSemantics(repoDir: string, base?: string, head?: string): Promise<DiffSemantics>;
8
6
  /**
9
7
  * Parse unified diff into FileChange[].
10
8
  */
11
- declare function parseDiff(diffText: string): FileChange[];
9
+ export declare function parseDiff(diffText: string): FileChange[];
12
10
  /**
13
11
  * Infer change intent from files and commit message.
14
12
  * Lightweight version without LLM. See buildIntentWithLLM for LLM version.
15
13
  */
16
- declare function buildIntent(files: FileChange[], commitMessage: string): ChangeIntent;
17
- interface LLMProvider {
14
+ export declare function buildIntent(files: FileChange[], commitMessage: string): ChangeIntent;
15
+ export interface LLMProvider {
18
16
  complete(prompt: string): Promise<string>;
19
17
  }
20
18
  /**
21
19
  * Build Intent from diff and commit message using LLM.
22
20
  */
23
- declare function buildIntentWithLLM(files: FileChange[], commitMessage: string, llm: LLMProvider): Promise<ChangeIntent>;
21
+ export declare function buildIntentWithLLM(files: FileChange[], commitMessage: string, llm: LLMProvider): Promise<ChangeIntent>;
24
22
  /**
25
23
  * Build a reasoning prompt that validates VRT diff against Intent.
26
24
  */
27
- declare function buildReasoningPrompt(diff: VrtDiff, intent: ChangeIntent): string;
28
- //#endregion
29
- export { LLMProvider, buildIntent, buildIntentWithLLM, buildReasoningPrompt, extractDiffSemantics, parseDiff };
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
- //#region src/intent.ts
3
+ // src/intent.ts
4
4
  const execFileAsync = promisify(execFile);
5
5
  /**
6
6
  * Parse git diff and return structured change information.
@@ -12,7 +12,7 @@ async function extractDiffSemantics(repoDir, base = "HEAD~1", head = "HEAD") {
12
12
  `${base}...${head}`
13
13
  ], {
14
14
  cwd: repoDir,
15
- maxBuffer: 10 * 1024 * 1024
15
+ maxBuffer: 10485760
16
16
  }), execFileAsync("git", [
17
17
  "log",
18
18
  "--format=%s%n%b",
@@ -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 };
@@ -0,0 +1,131 @@
1
+ /**
2
+ * TypeSafe's Jev (System One): typed questions about a state, typed answers back. No prose.
3
+ *
4
+ * Jev generates no text. A request is a `state` (text, objects, images) and a map of questions,
5
+ * each one of four types, and every answer is a value the caller can use as is:
6
+ *
7
+ * - `box` → one bounding box, edges as fractions of the image (0-1, top-left origin) + confidence
8
+ * - `noul` → the probability a statement is true (0-1)
9
+ * - `choice` → one option key + a probability per option + confidence
10
+ * - `score` → a position on an ordered rubric + a probability per level + confidence
11
+ *
12
+ * That shape is why it fits vlmkit's judges and benches: nothing here parses a reply. Images and
13
+ * `box` are behind `TypeSafe-Danger-Zone-Images: true` (Jev 1.14 for `box`); docs
14
+ * https://docs.typesafe.ai/go/images and https://docs.typesafe.ai/go/box.
15
+ *
16
+ * Images are referenced, not inlined: each asset has a key, and any string in `state`,
17
+ * `instructions` or `criteria` that equals (or contains) the key becomes that image. Every asset
18
+ * must be referenced, and each reference adds a copy to what the model reads — put a shared image
19
+ * in `state` once rather than in every question's instructions.
20
+ */
21
+ export declare const JEV_ENDPOINT = "https://api.typesafe.ai/v1/systemone";
22
+ export declare const JEV_DEFAULT_MODEL = "jev-1.14.0";
23
+ /** USD per input token ($42 per billion, 2026-10). Output tokens are free. */
24
+ export declare const JEV_INPUT_USD_PER_TOKEN = 4.2e-8;
25
+ /** Images outside these are rejected by the API, not resized (docs.typesafe.ai/go/images). */
26
+ export declare const JEV_IMAGE_LIMITS: {
27
+ readonly minEdge: 280;
28
+ readonly maxEdge: 1568;
29
+ readonly minPixels: 78400;
30
+ readonly maxPixels: 2458624;
31
+ readonly maxFileBytes: number;
32
+ };
33
+ export type JevQuestion = {
34
+ type: "box";
35
+ instructions: string;
36
+ } | {
37
+ type: "noul";
38
+ instructions: string;
39
+ } | {
40
+ type: "choice";
41
+ instructions: string;
42
+ criteria: Record<string, string>;
43
+ } | {
44
+ type: "score";
45
+ instructions: string;
46
+ criteria: readonly string[];
47
+ };
48
+ /** Edges as fractions of the image: left/right of its width, top/bottom of its height. */
49
+ export interface JevBox {
50
+ top: number;
51
+ bottom: number;
52
+ left: number;
53
+ right: number;
54
+ }
55
+ export type JevAnswer = {
56
+ type: "box";
57
+ box: JevBox;
58
+ confidence: number;
59
+ } | {
60
+ type: "noul";
61
+ noul: number;
62
+ } | {
63
+ type: "choice";
64
+ choice: string;
65
+ confidence: number;
66
+ probabilities: Record<string, number>;
67
+ } | {
68
+ type: "score";
69
+ score: number;
70
+ confidence: number;
71
+ probabilities: Record<string, number>;
72
+ legend?: Record<string, string>;
73
+ };
74
+ export interface JevImage {
75
+ bytes: Uint8Array;
76
+ format: "png" | "jpg" | "jpeg";
77
+ }
78
+ export interface JevRequest<Q extends Record<string, JevQuestion> = Record<string, JevQuestion>> {
79
+ model?: string;
80
+ state: unknown;
81
+ /** Reference key → image. Every key must appear somewhere in `state` or a question. */
82
+ assets?: Record<string, JevImage>;
83
+ questions: Q;
84
+ }
85
+ export interface JevResponse<Q extends Record<string, JevQuestion> = Record<string, JevQuestion>> {
86
+ model: string;
87
+ answers: { [K in keyof Q]: Extract<JevAnswer, {
88
+ type: Q[K]["type"];
89
+ }>; };
90
+ usage: {
91
+ input_tokens: number;
92
+ output_tokens: number;
93
+ };
94
+ latencyMs: number;
95
+ costUsd: number;
96
+ }
97
+ export interface JevClientOptions {
98
+ apiKey?: string;
99
+ endpoint?: string;
100
+ /** Extra headers; `Danger-Zone-Long-Context` goes here when wanted. */
101
+ headers?: Record<string, string>;
102
+ fetch?: typeof fetch;
103
+ /** Retries on 429 / 5xx, honouring `retry-after` (default 3). */
104
+ retries?: number;
105
+ signal?: AbortSignal;
106
+ }
107
+ export declare class JevApiError extends Error {
108
+ readonly status: number;
109
+ readonly body: string;
110
+ constructor(status: number, body: string);
111
+ }
112
+ /** Why an image would be refused, or null. Checked locally so a bench fails before it spends. */
113
+ export declare function jevImageProblem(width: number, height: number, bytes?: number): string | null;
114
+ export declare function pngImage(bytes: Uint8Array): JevImage;
115
+ /** Width and height from a PNG's IHDR, without decoding it. */
116
+ export declare function pngSize(bytes: Uint8Array): {
117
+ width: number;
118
+ height: number;
119
+ };
120
+ /** A box answer in the pixel space of an image of `width` x `height`. */
121
+ export declare function jevBoxToPixels(box: JevBox, width: number, height: number): {
122
+ x1: number;
123
+ y1: number;
124
+ x2: number;
125
+ y2: number;
126
+ };
127
+ /** The multipart body: a `request` JSON part, then one file part per asset (`a0`, `a1`, …). */
128
+ export declare function buildJevForm(req: JevRequest): FormData;
129
+ export declare function askJev<Q extends Record<string, JevQuestion>>(req: JevRequest<Q>, options?: JevClientOptions): Promise<JevResponse<Q>>;
130
+ /** Decode-free sanity: a PNG Buffer that Jev would accept, or the reason it would not. */
131
+ export declare function checkPngForJev(bytes: Uint8Array): string | null;