@ggui-ai/ui-gen 0.24.0 → 0.26.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.
Files changed (142) hide show
  1. package/README.md +2 -2
  2. package/dist/{adapter-Du7P_5Fx.d.ts → adapter-BJwn74rx.d.ts} +49 -1
  3. package/dist/adapters/generation-dispatch.d.ts +32 -7
  4. package/dist/adapters/generation-dispatch.js +1997 -216
  5. package/dist/adapters/generation-dispatch.js.map +1 -1
  6. package/dist/adapters/index.js +29 -6
  7. package/dist/adapters/index.js.map +1 -1
  8. package/dist/advanced/index.d.ts +15 -12
  9. package/dist/advanced/index.js +2013 -270
  10. package/dist/advanced/index.js.map +1 -1
  11. package/dist/{axes-CzLEMDeB.d.ts → axes-CKVCzR_x.d.ts} +1 -1
  12. package/dist/bank-Ctdp3FUA.d.ts +118 -0
  13. package/dist/blueprint-validator.js +416 -92
  14. package/dist/blueprint-validator.js.map +1 -1
  15. package/dist/boilerplate.d.ts +2 -2
  16. package/dist/boilerplate.js +34 -15
  17. package/dist/boilerplate.js.map +1 -1
  18. package/dist/check/index.d.ts +13 -5
  19. package/dist/check/index.js +56 -3
  20. package/dist/check/index.js.map +1 -1
  21. package/dist/classifier/index.d.ts +2 -2
  22. package/dist/compose.d.ts +2 -2
  23. package/dist/{create-ui-generator-GIhzx08x.d.ts → create-ui-generator-N4gRXpcL.d.ts} +11 -4
  24. package/dist/{design-mode-DLufhrNp.d.ts → design-mode-DGWN_Gkm.d.ts} +1 -1
  25. package/dist/{dispatch-BnAH56p4.d.ts → dispatch-BUoXRj_r.d.ts} +6 -4
  26. package/dist/evaluation/axis-checks/index.d.ts +7 -6
  27. package/dist/evaluation/axis-checks/index.js +90 -2
  28. package/dist/evaluation/axis-checks/index.js.map +1 -1
  29. package/dist/evaluation/axis-checks/registry.d.ts +6 -5
  30. package/dist/evaluation/axis-checks/registry.js +88 -1
  31. package/dist/evaluation/axis-checks/registry.js.map +1 -1
  32. package/dist/evaluation/index.d.ts +189 -344
  33. package/dist/evaluation/index.js +1272 -59
  34. package/dist/evaluation/index.js.map +1 -1
  35. package/dist/evaluation/types.d.ts +26 -1
  36. package/dist/evaluation/types.js.map +1 -1
  37. package/dist/fragments/index.d.ts +3 -3
  38. package/dist/{generate-9IeNT4ZY.d.ts → generate-tSO_shQ0.d.ts} +1 -1
  39. package/dist/harness/check/runtime-render/index.d.ts +7 -7
  40. package/dist/harness/check/runtime-render/index.js +416 -92
  41. package/dist/harness/check/runtime-render/index.js.map +1 -1
  42. package/dist/harness/check/runtime-render/render-check-worker.js +393 -88
  43. package/dist/harness/check/runtime-render/render-check-worker.js.map +1 -1
  44. package/dist/harness/index.d.ts +5 -6
  45. package/dist/harness/index.js +69 -20
  46. package/dist/harness/index.js.map +1 -1
  47. package/dist/harness/prompts.d.ts +2 -2
  48. package/dist/harness/prompts.js +10 -1
  49. package/dist/harness/prompts.js.map +1 -1
  50. package/dist/harness/result-types.d.ts +19 -5
  51. package/dist/harness/result-types.js.map +1 -1
  52. package/dist/harness/runtime.d.ts +21 -7
  53. package/dist/harness/runtime.js +36 -17
  54. package/dist/harness/runtime.js.map +1 -1
  55. package/dist/harness/types-public.d.ts +6 -4
  56. package/dist/harness/types-public.js +43 -18
  57. package/dist/harness/types-public.js.map +1 -1
  58. package/dist/harness/validator-trace-sink.d.ts +6 -5
  59. package/dist/hash.d.ts +1 -1
  60. package/dist/index.d.ts +64 -13
  61. package/dist/index.js +2023 -270
  62. package/dist/index.js.map +1 -1
  63. package/dist/patch.d.ts +5 -5
  64. package/dist/policy.d.ts +1 -1
  65. package/dist/{prompts-YU9piOgs.d.ts → prompts-BhNUuRoZ.d.ts} +1 -1
  66. package/dist/tools/get-primitives-ts.d.ts +1 -1
  67. package/dist/tools/get-primitives-ts.js +1 -1
  68. package/dist/tools/get-primitives-ts.js.map +1 -1
  69. package/dist/tools/render-check-worker.js +8 -1
  70. package/dist/tools/render-check-worker.js.map +1 -1
  71. package/dist/{types-BOvHNG7K.d.ts → types-Dh1s4K9j.d.ts} +1 -1
  72. package/dist/types-public-B7wn4ce5.d.ts +959 -0
  73. package/dist/validation/index.d.ts +1 -1
  74. package/dist/validation/index.js +1 -1
  75. package/dist/validation/index.js.map +1 -1
  76. package/dist/visual-evaluator-C9L-o6ap.d.ts +639 -0
  77. package/dist/workflows.d.ts +5 -5
  78. package/package.json +12 -12
  79. package/src/adapters/generation-dispatch.ts +38 -2
  80. package/src/adapters/tools.ts +2 -1
  81. package/src/boilerplate/free-design-prompt.ts +4 -4
  82. package/src/boilerplate/generate.ts +26 -1
  83. package/src/boilerplate/hard-sections.ts +14 -14
  84. package/src/boilerplate/system-prompt.ts +1 -1
  85. package/src/boilerplate/templates/layouts/chat-mobile.tsx.tmpl +3 -1
  86. package/src/boilerplate/templates/layouts/chat-universal.tsx.tmpl +3 -1
  87. package/src/boilerplate/templates/layouts/fullscreen-desktop.tsx.tmpl +3 -1
  88. package/src/boilerplate/templates/layouts/fullscreen-universal.tsx.tmpl +3 -1
  89. package/src/check/index.ts +1 -0
  90. package/src/check/run-tier0.ts +6 -3
  91. package/src/check/sample-props.ts +63 -0
  92. package/src/coding-agent/tools.ts +4 -1
  93. package/src/contract-context.ts +1 -1
  94. package/src/create-harness.ts +3 -3
  95. package/src/create-ui-generator.ts +20 -1
  96. package/src/evaluation/__fixtures__/png.ts +100 -0
  97. package/src/evaluation/axis-checks/checks/state-merge.ts +1 -1
  98. package/src/evaluation/axis-checks/checks/universal.ts +111 -0
  99. package/src/evaluation/axis-checks/dispatch.ts +4 -1
  100. package/src/evaluation/cost-tracker.ts +54 -6
  101. package/src/evaluation/criteria/bank.ts +85 -0
  102. package/src/evaluation/criteria/context.ts +52 -0
  103. package/src/evaluation/criteria/edge-probe.ts +286 -0
  104. package/src/evaluation/criteria/edge.ts +202 -0
  105. package/src/evaluation/criteria/resolve.ts +207 -0
  106. package/src/evaluation/criteria/select.ts +79 -0
  107. package/src/evaluation/index.ts +27 -0
  108. package/src/evaluation/ink-extent.ts +200 -0
  109. package/src/evaluation/judge-spend.ts +48 -0
  110. package/src/evaluation/theme-css.ts +12 -5
  111. package/src/evaluation/types-public.ts +221 -3
  112. package/src/evaluation/types.ts +19 -0
  113. package/src/evaluation/visual-evaluator.ts +853 -51
  114. package/src/harness/check/runtime-render/adapter.ts +18 -0
  115. package/src/harness/check/runtime-render/probe-pending.ts +111 -0
  116. package/src/harness/check/runtime-render/render-check-host.ts +10 -6
  117. package/src/harness/check/runtime-render/render-check-worker.ts +6 -3
  118. package/src/harness/check/runtime-render/render-check.ts +417 -133
  119. package/src/harness/check/runtime-render/walk.ts +200 -0
  120. package/src/harness/coding/assemble-result.ts +2 -0
  121. package/src/harness/coding/generate-task-runner.ts +30 -0
  122. package/src/harness/coding/init-session.ts +5 -3
  123. package/src/harness/coding/run-coding-turn.ts +12 -4
  124. package/src/harness/coding/run-eval-round.ts +82 -3
  125. package/src/harness/in-loop-evaluation.ts +39 -0
  126. package/src/harness/llm-router.ts +58 -1
  127. package/src/harness/result-types.ts +9 -0
  128. package/src/harness/runtime.ts +14 -0
  129. package/src/harness/types-public.ts +10 -1
  130. package/src/harness-tool-names.ts +38 -0
  131. package/src/index.ts +17 -0
  132. package/src/internal/verdict-line.ts +33 -0
  133. package/src/run-check.ts +2 -0
  134. package/src/taught-tokens.ts +32 -0
  135. package/src/tools/get-primitives-ts.ts +1 -1
  136. package/src/tools/get-wire.ts +1 -1
  137. package/src/tools/render-check-worker.ts +2 -1
  138. package/src/tools/render-check.ts +8 -67
  139. package/src/tools.ts +11 -1
  140. package/src/validation/primitives.ts +1 -1
  141. package/dist/llm-router-DwwUK1bz.d.ts +0 -265
  142. package/dist/types-public-Bk6d1WLN.d.ts +0 -451
@@ -1,20 +1,23 @@
1
- import { C as CanvasJudgeRecord, E as EvalIssue, V as VisualEvalSummary, d as VisualCoverage } from '../types-public-Bk6d1WLN.js';
2
- export { A as AxisCheck, a as AxisCheckInput, e as CRITERIA, f as CanvasVisualSummary, g as ContractFeedbackRecord, h as CriterionCoverage, i as CriterionRunStatus, D as DEFAULT_QUALITY_CONFIG, j as EvalCategory, k as EvalCriterion, l as EvalOutcome, b as EvalResult, c as EvalTier, L as LLM_EVAL_STATIC_CRITERIA, n as Priority, Q as QualityConfig, o as QualityMode, p as buildCodingCriteriaSummary, q as criteriaFor, r as getActionableIssues, s as getCriteriaByPriority, t as getCriterionById, u as getLLMCriteria, v as isBlocked, m as matches, w as notApplicableCoverage, x as priorityForIssue } from '../types-public-Bk6d1WLN.js';
1
+ import { r as CriteriaSelection, h as CriteriaContext, C as CriteriaAnswerCounts, s as VisionFinishReason, k as CriteriaBlock } from '../types-public-B7wn4ce5.js';
2
+ export { A as AxisCheck, a as AxisCheckInput, t as CRITERIA, n as CanvasHostPresentation, j as CanvasJudgeRecord, l as CanvasPresentationOutcome, u as CanvasVisualSummary, v as ContractFeedbackRecord, w as CriterionCoverage, x as CriterionRunStatus, D as DEFAULT_QUALITY_CONFIG, y as EvalCategory, z as EvalCriterion, E as EvalIssue, B as EvalOutcome, e as EvalResult, q as EvalTier, H as HostInlineFrame, F as HostPresentationIgnoredReason, G as LLM_EVAL_STATIC_CRITERIA, I as Priority, Q as QualityConfig, K as QualityMode, o as VisualEvalSummary, M as buildCodingCriteriaSummary, N as criteriaFor, O as getActionableIssues, S as getCriteriaByPriority, T as getCriterionById, U as getLLMCriteria, W as isBlocked, m as matches, X as notApplicableCoverage, Y as priorityForIssue } from '../types-public-B7wn4ce5.js';
3
3
  import * as _anthropic_ai_claude_agent_sdk from '@anthropic-ai/claude-agent-sdk';
4
4
  import { McpServerConfig } from '@anthropic-ai/claude-agent-sdk';
5
- import { EvaluationContext, EvaluationConfig, QualityMetadata, EvaluationResult, EvaluationIssue } from './types.js';
5
+ import { EvaluationContext, EvaluationConfig, QualityMetadata, EvaluationResult, EvaluationIssue, CriteriaAnswer } from './types.js';
6
6
  export { DEFAULT_EVAL_MAX_ROUNDS, DimensionScores, MAX_EVAL_ROUNDS_HARD_LIMIT } from './types.js';
7
- export { R as RunAxisChecksInput, r as runAxisChecks } from '../dispatch-BnAH56p4.js';
8
- import { A as AgentConfig, L as LLMResponse } from '../llm-router-DwwUK1bz.js';
9
- import { G as GenerationProfileInput } from '../styling-profile-CxfvV48g.js';
10
- import { LaunchOptions } from 'puppeteer-core';
11
- import { C as CanvasClass, g as CanvasViewport } from '../design-mode-DLufhrNp.js';
12
- export { a as CANVAS_BREAKPOINTS, b as CANVAS_CLASSES, c as CANVAS_DESCRIPTORS, d as CANVAS_VIEWPORTS, e as CanvasDescriptor, f as CanvasDisplayMode, j as canvasDisplayModeForShell, k as canvasForRendering, l as canvasForViewportWidth, m as describeCanvas } from '../design-mode-DLufhrNp.js';
7
+ export { R as RunAxisChecksInput, r as runAxisChecks } from '../dispatch-BUoXRj_r.js';
8
+ import { E as EdgeVerdict, a as EdgeBlock, C as CriteriaCallTokens } from '../visual-evaluator-C9L-o6ap.js';
9
+ export { b as CARD_HEIGHT_EXPRESSION, c as CONTENT_HEIGHT_EXPRESSION, d as CanvasFitPolicy, e as CanvasVisualResult, f as CaptureMode, g as ChromiumProvider, h as CriteriaContextInput, i as CriteriaContextSources, j as EDGE_TOLERANCE_PX, k as EdgeOffset, H as HOST_COLOUR_PATTERN, l as HOST_FRAME_BOUNDS, J as JUDGE_GROUND_MARGIN_PX, m as JUDGE_INK_INSET_PX, n as JudgeDesignIdentity, N as NaturalCaptureOptions, S as ScreenshotAttempt, o as ScreenshotBrowser, p as ScreenshotClip, q as ScreenshotDeps, r as ScreenshotLauncher, s as ScreenshotPage, t as StoredCaptureInput, u as StoredCaptureOutcome, v as StoredCaptureVerdict, w as VISUAL_EVAL_PROMPT, x as VISUAL_JUDGE_MAX_OUTPUT_TOKENS, y as VISUAL_JUDGE_PROMPT_DIGEST, z as VISUAL_JUDGE_PROMPT_VERSION, A as VisualEvalConfig, B as VisualEvalContext, D as VisualEvalDeps, F as VisualEvalDetailed, G as VisualEvalOutcome, I as VisualEvaluationResult, V as VisualLegTokens, K as callMultimodalLLM, L as canvasBlankIssue, M as canvasFitPolicy, O as canvasOverflowIssue, P as captureScreenshot, Q as captureScreenshotDetailed, R as chromaOfCssTokens, T as criteriaContextFor, U as designTreeSha256, W as judgeDesignIdentity, X as judgeEdges, Y as judgeStoredCapture, Z as resetJudgeDesignIdentityCache, _ as resolveDesignPackageDir, $ as resolveLaunchOptions, a0 as runVisualEval, a1 as runVisualEvaluation, a2 as runVisualEvaluationDetailed, a3 as summarizeVisualResult } from '../visual-evaluator-C9L-o6ap.js';
10
+ export { b as CANVAS_BREAKPOINTS, c as CANVAS_CLASSES, d as CANVAS_DESCRIPTORS, e as CANVAS_VIEWPORTS, C as CanvasClass, f as CanvasDescriptor, g as CanvasDisplayMode, a as CanvasViewport, j as canvasDisplayModeForShell, k as canvasForRendering, l as canvasForViewportWidth, m as describeCanvas } from '../design-mode-DGWN_Gkm.js';
13
11
  import { AppTheme } from '@ggui-ai/protocol';
14
- import '@ggui-ai/mcp-server-core';
15
- import '../axes-CzLEMDeB.js';
16
- import '../types-BOvHNG7K.js';
12
+ import { C as CriteriaBank } from '../bank-Ctdp3FUA.js';
13
+ export { B as BankRow, a as CriteriaScope, b as bankRows, c as criteriaBankSchema, p as parseCriteriaBank } from '../bank-Ctdp3FUA.js';
17
14
  import '../llm.js';
15
+ import '@ggui-ai/mcp-server-core';
16
+ import '../axes-CKVCzR_x.js';
17
+ import '../types-Dh1s4K9j.js';
18
+ import '../styling-profile-CxfvV48g.js';
19
+ import 'puppeteer-core';
20
+ import 'zod';
18
21
 
19
22
  /**
20
23
  * Options for running the evaluation loop.
@@ -186,364 +189,206 @@ declare function extractCompiledCode(messages: SdkMessage[]): string | undefined
186
189
  */
187
190
  declare function extractSourceCode(messages: SdkMessage[]): string | undefined;
188
191
 
189
- interface JudgeDesignIdentity {
190
- /** Absolute path of the design `src` tree the judge bundled against. */
191
- readonly src: string;
192
- /** sha256 over every rendering input under `src` (see {@link isDesignRenderingInput}) — sorted relative path, then contents. */
193
- readonly srcSha256: string;
192
+ /** A channel difference at or below this is the same colour (anti-aliasing and compositing noise). */
193
+ declare const INK_TOLERANCE = 8;
194
+ interface PixelRegion {
195
+ readonly x: number;
196
+ readonly y: number;
197
+ readonly width: number;
198
+ readonly height: number;
194
199
  }
195
- /**
196
- * sha256 over every rendering input under `root` (sorted relative path +
197
- * contents) — the identity of a design tree as it paints.
198
- *
199
- * A function of the TREE, not of the spelling of `root`: the relative keys
200
- * are taken against the RESOLVED root, so `…/design/src`, `…/design/src/` and
201
- * `…/ui-gen/../design/src` hash the same bytes. Before this the key was
202
- * sliced by the unresolved root's length while each entry had already been
203
- * resolved, so an un-normalised root produced a different hash for the same
204
- * tree — a phantom design skew for any caller composing the path.
205
- */
206
- declare function designTreeSha256(root: string): string;
207
- /**
208
- * The identity of the tree at `src`, computed once per process per path (a
209
- * judge run paints hundreds of frames from one tree).
210
- *
211
- * `null` when the tree cannot be READ (ggui#1110): a deployed image ships the
212
- * design package as built output with no `src/`, and an identity is a receipt
213
- * about a judgement — never a precondition for making one. Before this,
214
- * `scandir` threw ENOENT inside the evaluation round wherever the package ships
215
- * built output only, the round returned no evaluation at all, and a bar refused
216
- * a card that had cleared it. A row without the receipt says so; a round that cannot
217
- * stamp one still runs.
218
- */
219
- declare function judgeDesignIdentity(src: string): JudgeDesignIdentity | null;
220
- /** Test seam: forget cached identities (a test that rewrites a tree between runs). */
221
- declare function resetJudgeDesignIdentityCache(): void;
222
-
223
- interface VisualEvalConfig {
224
- /** LLM provider for multimodal evaluation */
225
- provider: 'claude' | 'google';
226
- /** Model ID (must support vision/multimodal) */
227
- model?: string;
228
- /** Pass threshold for visual score (0-100) */
229
- passThreshold: number;
230
- /** Sample props to render the component with */
231
- sampleProps?: Record<string, unknown>;
232
- /** Viewport dimensions for screenshot */
233
- viewport?: {
234
- width: number;
235
- height: number;
236
- };
237
- /**
238
- * Per-canvas judging — ARM-NEUTRAL (the same judge, prompt and
239
- * threshold in every design mode). When set, the SAME rendered HTML
240
- * shell is screenshotted once per class at `CANVAS_VIEWPORTS[class]`
241
- * and judged once per class; the result carries one entry per class
242
- * in `canvases`, and the single-shot fields aggregate: `finalScore` =
243
- * mean of the canvas scores (rounded), `passed` = every canvas passed,
244
- * `dimensions` = per-dimension means, `issues` = every canvas's issues
245
- * (description prefixed `[<canvas>]`). Unset (or empty) = today's
246
- * single screenshot at `viewport`; no `canvases` field on the result.
247
- */
248
- canvases?: readonly CanvasClass[];
249
- /**
250
- * ggui#1195 — the box a canvas is COMPOSED for and CAPTURED at when the
251
- * order declared one (the chat card at the visitor's real column, not the
252
- * class's 400×640). Keyed by canvas; a canvas without an entry is judged
253
- * at `CANVAS_VIEWPORTS[canvas]` as before. The composer's
254
- * `rendering.viewport` and this entry are ONE value written once (the
255
- * seam derives it), so the judge never scores a box the mint did not
256
- * target. Only read in per-canvas mode. Captured at WHOLE CSS px: the
257
- * browser's device-metrics override takes integers (measured — a 383.5 px
258
- * width is refused by CDP), so a fractional declared box is rounded once
259
- * where it enters and the capture, the ceiling and the reported
260
- * `viewport` all carry that same integer box.
261
- */
262
- canvasViewports?: Partial<Readonly<Record<CanvasClass, CanvasViewport>>>;
263
- /**
264
- * Optional provider-routing override — see
265
- * `AgentConfig.routeOverride`. Threaded onto the agent this
266
- * evaluator constructs so its multimodal call never falls back to
267
- * `process.env` for credentials or model routing.
268
- */
269
- /**
270
- * Vision calls per judged canvas on the SAME captured frame, aggregated by
271
- * the median (ggui#1072). Default 1 — a single judgement, byte-identical to
272
- * the instrument before this option existed. K is an instrument dial: a
273
- * run mixes K at its own peril.
274
- */
275
- judgeK?: number;
276
- /** The canvases sampled `judgeK` times; default = every judged canvas when `judgeK > 1`. */
277
- judgeKCanvases?: readonly CanvasClass[];
278
- /**
279
- * The design `src` tree the judge bundles the component against
280
- * (ggui#1042): an explicit input, so a judge-only re-judge names the tree
281
- * it painted with. Default: the design package beside this one.
282
- */
283
- designSrcDir?: string;
284
- /** The mode the caller composed `cssTokens` in — a receipt on the row, never a switch (ggui#1076: judge and runtime must name the same mode). */
285
- themeMode?: 'light' | 'dark';
286
- routeOverride?: AgentConfig['routeOverride'];
287
- /**
288
- * Provider-429-retry observer — see `AgentConfig.onRetry`.
289
- * Without it, a rate-limited retry inside the evaluation call
290
- * happens (the agent's retry loop is unconditional) but never
291
- * reaches the caller's structured log.
292
- */
293
- onRetry?: AgentConfig['onRetry'];
200
+ interface InkExtent {
201
+ /** `(lastInkRow + 1) / region.height`, rounded to 3 places; `0` when nothing differs from the ground. */
202
+ readonly ratio: number;
203
+ /** The last region row (0-based from the region's top) carrying ink; `null` when there is none — the blank. */
204
+ readonly lastInkRow: number | null;
205
+ /** The region read, in image px. */
206
+ readonly region: PixelRegion;
207
+ /** The dominant colour the ink was read against, `[r, g, b]`. */
208
+ readonly ground: readonly [number, number, number];
294
209
  }
295
- /** One canvas's verdict — screenshot + judge score at that class's viewport. */
296
- interface CanvasVisualResult {
297
- canvas: CanvasClass;
298
- viewport: CanvasViewport;
299
- /** The judge's weighted score for this canvas (0-100). */
300
- score: number;
301
- /** `score >= passThreshold`. */
302
- passed: boolean;
303
- /** The PNG the judge saw — kept for artefact persistence + the human look. */
304
- screenshotPng: Buffer;
305
- /**
306
- * The document's scroll height at this canvas's viewport, CSS px — what
307
- * the box would have to be for nothing to be hidden (ggui#1027). `null`
308
- * when the page could not be measured.
309
- */
310
- contentHeight: number | null;
311
- /** `contentHeight > viewport.height` — a measurement; what it MEANS is {@link canvasFitPolicy}'s. */
312
- overflow: boolean;
313
- /** How `score` was reached — always present (ggui#1072). */
314
- judge: CanvasJudgeRecord;
315
- /** How the judge composed the mount (ggui#1100): `'fill'` on every fullscreen canvas, absent on the inline card. */
316
- fit?: 'fill';
317
- /** ggui#1195 — `true` when the order DECLARED this canvas's box (`config.canvasViewports` carried an entry), whatever its value. */
318
- declared?: true;
210
+ /** Why a capture could not be read — reported, never mistaken for a blank. */
211
+ interface InkUnreadable {
212
+ readonly reason: string;
319
213
  }
320
- /** How a canvas is captured for the judge and what an overflow means there (ggui#1027). */
321
- type CaptureMode = 'viewport' | 'full-page';
322
- interface CanvasFitPolicy {
323
- /** `viewport` = the judge sees the box the user sees; `full-page` = the whole scrolled document. */
324
- readonly capture: CaptureMode;
325
- /** The verdict an overflow earns on this canvas. */
326
- readonly overflow: 'fail' | 'warn' | 'none';
214
+ interface DecodedImage {
215
+ readonly width: number;
216
+ readonly height: number;
217
+ readonly channels: 3 | 4;
218
+ /** Row-major, `channels` bytes per pixel, scanline filters undone. */
219
+ readonly pixels: Uint8Array;
327
220
  }
221
+ /** The PNG subset the judge's browser writes: 8-bit RGB (colour type 2) or RGBA (6), not interlaced. */
222
+ declare function decodePng(png: Uint8Array): DecodedImage | InkUnreadable;
328
223
  /**
329
- * The inline chat card is a BOX — the bubble bounds the component and it
330
- * does not scroll — so the judge captures the viewport (a 1289 px hello on
331
- * a 640 px card was scored 86 from a full-page capture that showed the
332
- * judge what no user sees) and an overflow is a critical layout issue that
333
- * fails the canvas. A phone's first screen may scroll, so the overflow is
334
- * reported as a major issue and the score stands. Pages (`md`/`lg`/`xl`)
335
- * scroll by design: measured, never judged.
336
- */
337
- declare function canvasFitPolicy(canvas: CanvasClass): CanvasFitPolicy;
338
- /** The deterministic fit issue — one per overflowing canvas, in the judge's issue shape so it rides the same channel. */
339
- declare function canvasOverflowIssue(canvas: CanvasClass, viewport: CanvasViewport, contentHeight: number, verdict: 'fail' | 'warn'): EvaluationIssue;
340
- /**
341
- * `runVisualEvaluation`'s result. Identical to `EvaluationResult` when
342
- * `config.canvases` is unset; with canvases set, `canvases` holds the
343
- * per-class verdicts and the base fields aggregate them (see
344
- * `VisualEvalConfig.canvases`).
224
+ * The ink extent of a capture, read `insetPx` in from every edge — the judge's inset skips a host
225
+ * panel's gap, rounded corners and hairline ({@link JUDGE_INK_INSET_PX}); `0` reads the whole image.
345
226
  */
346
- interface VisualEvaluationResult extends EvaluationResult {
347
- canvases?: CanvasVisualResult[];
348
- /** The design tree the judge painted with (ggui#1042) — present on every per-canvas judgement. */
349
- design?: JudgeDesignIdentity;
350
- /** The mode `cssTokens` were composed in, when the caller said (ggui#1076). */
351
- themeMode?: 'light' | 'dark';
352
- }
353
- /** Injection points for `runVisualEvaluation` — screenshot deps plus the judge call (tests). */
354
- interface VisualEvalDeps extends ScreenshotDeps {
355
- /** The multimodal judge call (default: `callMultimodalLLM`). */
356
- judge?: typeof callMultimodalLLM;
357
- }
358
- interface VisualEvalContext {
359
- /** Compiled JavaScript code (ESM with imports) */
360
- compiledCode: string;
361
- /** Original user prompt */
362
- originalPrompt: string;
363
- /** Design system CSS tokens */
364
- cssTokens?: string;
365
- /** The app's generation profile (#991) — judged relative to, never against. */
366
- profile?: GenerationProfileInput;
367
- }
227
+ declare function readInkExtent(png: Uint8Array, insetPx?: number): InkExtent | InkUnreadable;
228
+
368
229
  /**
369
- * The `@ggui-ai/design` package root — resolved by MODULE ID, never by counting
370
- * directories (ggui#1110).
371
- *
372
- * The arithmetic this replaced (`…/'..','..','..','design'`) was correct only
373
- * for the layout it was written against — `node_modules/@ggui-ai/ui-gen/dist/
374
- * evaluation` → `node_modules/@ggui-ai/` + `design`. Under a deploy-flattened
375
- * layout it landed one level too high, at `node_modules/design`, a path that is
376
- * not the design package at all: the judge then walked a directory that does not
377
- * exist, threw ENOENT inside every evaluation round on that deployment, and a
378
- * bar refused cards no one could judge. `@ggui-ai/design` exports `./package.json`,
379
- * so the module resolver answers correctly in every layout — scoped, flattened,
380
- * hoisted — and the receipt keeps working inside the image.
230
+ * The stylesheet a visual judge renders under for an app: the app's theme
231
+ * composed the way the runtime composes it (`composeThemeCss`, layer `page`
232
+ * — one composition, never a second), so a judged canvas paints the tokens a
233
+ * visitor's page paints. `themeId` is the registered ladder the app's theme
234
+ * sits on (the runtime's base layer); an unknown id composes the default
235
+ * ladder. Neither given ⇒ the design's default tokens, byte-for-byte what the
236
+ * judge used before.
381
237
  */
382
- declare function resolveDesignPackageDir(): string;
383
- /** The page surface the capture uses — a structural subset of puppeteer's `Page`. */
384
- interface ScreenshotPage {
385
- setContent(html: string, options: {
386
- waitUntil: 'load';
387
- timeout: number;
388
- }): Promise<void>;
389
- waitForNetworkIdle(options: {
390
- idleTime: number;
391
- timeout: number;
392
- }): Promise<void>;
393
- waitForSelector(selector: string, options: {
394
- timeout: number;
395
- }): Promise<unknown>;
396
- /** Evaluates a JS expression in the page and returns its serialised value — the fit measurement (ggui#1027). */
397
- evaluate(expression: string): Promise<unknown>;
398
- screenshot(options: {
399
- type: 'png';
400
- fullPage: boolean;
401
- }): Promise<Uint8Array>;
402
- }
403
- /** The browser surface the capture uses — a structural subset of puppeteer's `Browser`. */
404
- interface ScreenshotBrowser {
405
- newPage(): Promise<ScreenshotPage>;
406
- close(): Promise<void>;
407
- }
408
- type ScreenshotLauncher = (options: LaunchOptions) => Promise<ScreenshotBrowser>;
409
- /** The two members of `@sparticuz/chromium` the fallback launch path reads. */
410
- interface ChromiumProvider {
411
- readonly args: string[];
412
- executablePath(): Promise<string>;
238
+ declare function cssTokensForAppTheme(theme: AppTheme | undefined, mode?: 'light' | 'dark', themeId?: string): string;
239
+
240
+ /** Bump when a selection rule changes: it is hashed into every `criteriaSetId`. */
241
+ declare const CRITERIA_SELECTOR_VERSION = "selector@2";
242
+ /** The context as one string, keys sorted at every level — what the id hashes and what the record stores. */
243
+ declare function canonicalCriteriaContext(ctx: CriteriaContext): string;
244
+ /** sha256(bank version | selector version | canonical context), 16 hex — a label at this scale, not a security digest. */
245
+ declare function criteriaSetIdFor(bankVersion: string, ctx: CriteriaContext): string;
246
+ interface CriteriaSelectionResult {
247
+ readonly criteriaSetId: string;
248
+ readonly selection: CriteriaSelection[];
413
249
  }
414
250
  /**
415
- * Injection points for the capture — every default is the production
416
- * path; tests replace them to pin branch selection without launching a
417
- * browser.
251
+ * Select the bank's rows for one card. The bank-level `applies` gate is read first (canvases always;
252
+ * kind only when the caller named one and the bank names kinds other than `*`); then each row's
253
+ * `scope`. An empty scope is `static`; a matched scope is `context` with the keys that matched.
418
254
  */
419
- interface ScreenshotDeps {
420
- /** Launches the browser (default: `puppeteer-core`'s `launch`). */
421
- launch?: ScreenshotLauncher;
422
- /** Environment the executable-path override is read from (default: `process.env`). */
423
- env?: NodeJS.ProcessEnv;
424
- /** Loads `@sparticuz/chromium` (default: dynamic import) — only consulted when no override is set. */
425
- loadChromium?: () => Promise<ChromiumProvider>;
426
- /** Post-load settle time before the screenshot, ms (default 1000). */
427
- settleMs?: number;
428
- }
255
+ declare function selectCriteria(bank: CriteriaBank, ctx: CriteriaContext): CriteriaSelectionResult;
256
+
429
257
  /**
430
- * Pick the browser binary. `PUPPETEER_EXECUTABLE_PATH` (a system
431
- * Chromium — the bench runner image, a dev box) wins and skips the
432
- * `@sparticuz/chromium` load entirely; otherwise the bundled Lambda
433
- * Chromium supplies both binary and flags, as before.
258
+ * From K judge answers and the capture's measurements to one `CriteriaBlock` — ggui#1436.
259
+ *
260
+ * The judge is asked every `evaluation: judge` row (this block IS their implementation; the row's
261
+ * `status` is carried on the verdict as the author wrote it). An `instrument` row is answered by a
262
+ * measurement the capture already ran when its status is `live` and a binding exists; otherwise it
263
+ * reads `n/a` with the reason from `status`. A `human` row reads `n/a` for the judge. K-majority per
264
+ * id; a tie or an unanswered id reads `n/a` (the CTO's A2) — a `must` at `n/a` is never a pass when
265
+ * a gate later reads the set.
434
266
  */
435
- declare function resolveLaunchOptions(viewport: {
436
- width: number;
437
- height: number;
438
- }, deps?: Pick<ScreenshotDeps, 'env' | 'loadChromium'>): Promise<LaunchOptions>;
267
+
268
+ /** The instruments the capture runs today, by the bank ids they answer (v1 binding; a bank field may replace it). */
269
+ declare const INSTRUMENT_BY_ID: Readonly<Record<string, 'fit' | 'fill'>>;
439
270
  /**
440
- * Take a screenshot of the rendered component.
441
- * Returns the PNG bytes, or null if no browser could be launched.
271
+ * ggui#1663 — instruments that read BESIDE a judge row, report-only: the row keeps the judge's verdict and gains the
272
+ * measurement as `instrument`, so the two can be compared before any verdict moves.
442
273
  */
443
- /** Screenshot plus the reason when none could be taken — the judge's `unavailableReason`. */
444
- interface ScreenshotAttempt {
445
- readonly png: Buffer | null;
446
- readonly reason?: string;
447
- /** The document's scroll height at the viewport (ggui#1027); `null` when unmeasurable. */
274
+ declare const INSTRUMENT_BESIDE_JUDGE: Readonly<Record<string, 'edge'>>;
275
+ interface CriteriaMeasurements {
276
+ readonly overflow: boolean;
448
277
  readonly contentHeight: number | null;
278
+ readonly viewportHeight: number;
279
+ readonly inkRatio: number | null;
280
+ /**
281
+ * ggui#1663 — the edge rule on the capture's DOM: absent when this capture had no page to read (a stored frame),
282
+ * `null` when the probe ran and failed.
283
+ */
284
+ readonly edge?: EdgeVerdict | null;
449
285
  }
450
- /** The expression the fit measurement evaluates in the page — the taller of the two scroll heights. */
451
- declare const CONTENT_HEIGHT_EXPRESSION = "Math.max(document.documentElement.scrollHeight, document.body ? document.body.scrollHeight : 0)";
452
- declare function captureScreenshotDetailed(html: string, viewport?: {
453
- width: number;
454
- height: number;
455
- }, deps?: ScreenshotDeps, capture?: CaptureMode): Promise<ScreenshotAttempt>;
456
- declare function captureScreenshot(html: string, viewport?: {
457
- width: number;
458
- height: number;
459
- }, deps?: ScreenshotDeps): Promise<Buffer | null>;
460
- declare const VISUAL_EVAL_PROMPT = "You are a visual quality evaluator for ggui \u2014 a platform where AI agents generate React UI components on demand.\n\n## Context\nThe screenshot shows a generated React component built from a design system with CSS variable theming. The component was created by an LLM to fulfill a user's request. Your job is to evaluate whether the generated UI achieves the user's goal AND looks professionally designed.\n\n## Scoring Dimensions (0-100 each)\n\n1. **completeness** (25%): Does the screenshot show ALL features the user requested? Are all sections, controls, data fields, and interactive elements present? Missing features or sections = major deduction. Compare against the original request carefully.\n\n2. **layout** (25%): Is the layout well-composed? Clear sections and grouping? No overlapping elements? Proper spacing between elements? Responsive-looking? Does it look like a professional app UI, not a homework project?\n\n3. **hierarchy** (25%): Clear visual hierarchy? Headings are visually distinct from body text? Primary actions (buttons) are prominent? Information grouped logically with clear section breaks? Color and size used to guide the eye?\n\n4. **aesthetics** (25%): Professional, polished appearance? Consistent color palette? Good use of whitespace \u2014 not too sparse, not too cluttered? Cards, shadows, and borders used effectively? Does it look like something a designer would approve? Would you be comfortable showing this to a client?\n\n## Scoring Guide\n- 90-100: Production-ready. Would ship to real users. Polished layout, clear hierarchy, professional aesthetics.\n- 80-89: Good quality. Minor improvements needed (slightly tight spacing, one section could be better grouped).\n- 70-79: Acceptable but generic. Works correctly but lacks design polish or visual refinement.\n- 60-69: Below standard. Noticeable problems \u2014 cramped layout, poor hierarchy, or missing sections.\n- Below 60: Broken or fundamentally incomplete. Error messages visible, blank areas, or critical features missing.\n\n## Important\n- Check the screenshot against the \"Original Request\" \u2014 does it actually deliver what was asked for?\n- Error messages like \"Render error\" or blank white space = rendering score 0\n- A component that renders but is just a wall of text with no structure should score low on layout and hierarchy\n\nList AT MOST 6 issues, most severe first, one sentence each for \"description\" and \"fix\" \u2014 a longer list is cut off and lost.\n\nRespond with ONLY a JSON object (no markdown, no explanation):\n{\n \"completeness\": <0-100>,\n \"layout\": <0-100>,\n \"hierarchy\": <0-100>,\n \"aesthetics\": <0-100>,\n \"issues\": [\n { \"dimension\": \"<dimension>\", \"severity\": \"<critical|major|minor>\", \"description\": \"<what's wrong>\", \"fix\": \"<specific fix>\" }\n ],\n \"critique\": \"<2-3 sentences: what's good, what needs improvement, does it achieve the user's goal?>\"\n}";
461
- /**
462
- * Send the screenshot to the configured multimodal provider through
463
- * the shared `LLMAgent` machinery. Routing through `createVisionAgent`
464
- * (rather than constructing provider SDK clients inline) is what puts
465
- * this call inside the same `apiCall()` choke point as every other
466
- * completion: provider 429s retry with `Retry-After` honoring, the
467
- * caller's `onRetry` observer sees each retry, and `routeOverride`
468
- * governs credentials and model routing (including the Anthropic
469
- * Bedrock path) instead of `process.env`.
470
- */
471
- /**
472
- * Output budget for the judge's answer. 1500 cut a board's issue list
473
- * mid-array (`Expected ',' or ']' after array element`, six kanban cells
474
- * on 2026-09-11) — deterministic on the content, so a same-prompt retry
475
- * could never clear it. 4096 fits the bounded list the prompt now asks for
476
- * with room; the salvage path covers the remainder.
477
- */
478
- declare const VISUAL_JUDGE_MAX_OUTPUT_TOKENS = 4096;
479
- /**
480
- * The judge instrument's name and content digest, for the record a run
481
- * stamps beside every visual score. The NAME is for readers; the DIGEST
482
- * is computed from the prompt text at module load, so a stamped row can
483
- * never claim a prompt version it did not run — change the prompt and the
484
- * digest moves with it (the pin ties the name to the bounded-list text).
485
- */
486
- declare const VISUAL_JUDGE_PROMPT_VERSION = "v2-bounded-issues";
487
- declare const VISUAL_JUDGE_PROMPT_DIGEST: string;
488
- declare function callMultimodalLLM(config: VisualEvalConfig, model: string, prompt: string, screenshot: Buffer, originalPrompt: string, profileBlock?: string): Promise<LLMResponse>;
286
+ declare function resolveCriteriaBlock(args: {
287
+ readonly bank: CriteriaBank;
288
+ readonly context: CriteriaContext;
289
+ readonly selected: CriteriaSelectionResult;
290
+ readonly answers: readonly CriteriaAnswer[][];
291
+ readonly measurements: CriteriaMeasurements;
292
+ /**
293
+ * ggui#1127 — why a judge row has no answer, when the caller knows: a salvaged criteria answer keeps no criteria,
294
+ * so its rows say so instead of reading as a clean `n/a`. Absent ⇒ "not answered".
295
+ */
296
+ readonly unansweredReason?: string;
297
+ /** ggui#1687 — the call that answered, as it came back: its answer's counts and its stop reason. */
298
+ readonly call?: {
299
+ readonly answer: CriteriaAnswerCounts;
300
+ readonly finishReason?: VisionFinishReason;
301
+ };
302
+ }): CriteriaBlock;
303
+ /** The judge's prompt block for the selected `judge` rows; empty when none is selected. */
304
+ /** The capture the judge is handed: its canvas class and the box it was taken at (the class box, or a declared one). */
305
+ interface CriteriaJudgeFrame {
306
+ readonly canvas: CriteriaContext['canvas'];
307
+ readonly width: number;
308
+ readonly height: number;
309
+ /** ggui#1492 — the host whose presentation framed this canvas (e.g. "a chat widget, inline, reference theme"); absent ⇒ the judge's own stand-in. */
310
+ readonly hostLabel?: string;
311
+ }
312
+ /** What the block carries besides the selected rows: the frame's box, and the props the card was rendered with. */
313
+ interface CriteriaJudgeInputs {
314
+ readonly frame?: CriteriaJudgeFrame;
315
+ /** JSON text of the props the card was rendered with; bounded by {@link CRITERIA_PROPS_MAX_CHARS}. */
316
+ readonly propsJson?: string;
317
+ }
318
+ /** The judge's prompt block for the selected `judge` rows; empty when none is selected. */
319
+ declare function buildCriteriaJudgeBlock(bank: CriteriaBank, selected: CriteriaSelectionResult, inputs?: CriteriaJudgeInputs): string;
320
+
489
321
  /**
490
- * Run visual evaluation on a compiled component.
322
+ * `space.edge`'s measurement (#1663): the expression a capture evaluates in the page to produce {@link EdgeBlock}s for
323
+ * {@link judgeEdges}. It runs where the screenshot is taken, on the same DOM at the same width, so the rule reads what
324
+ * the judge's frame shows. It only reads layout; it never writes to the page.
491
325
  *
492
- * 1. Builds an HTML page with the component + sample props
493
- * 2. Takes a screenshot via puppeteer (if available)
494
- * 3. Sends screenshot to multimodal LLM for visual scoring
326
+ * What it measures, under `#root`, in CSS px from the card's left edge:
495
327
  *
496
- * Returns null if puppeteer is not available (graceful fallback).
497
- */
498
- /**
499
- * The judge's answer WITH the reason when it could not judge: `result` is
500
- * null exactly when no screenshot could be taken (no browser, a launch or
501
- * in-page failure) or the component could not be bundled; `unavailableReason`
502
- * names why in words and `canvas` the canvas it happened at. A production
503
- * caller records the reason in its receipt — a `judge_unavailable` that only
504
- * says "null" cost a log dive on 2026-09-10 (puppeteer-core missing in the
505
- * deploy image).
328
+ * - **Text blocks.** Text is grouped by its nearest non-inline element. A block's edge is its first visible character
329
+ * in ink: text in a transparent colour, private-use icon-font glyphs and formatting characters are not characters of
330
+ * the block. Its extent is the union of its inked line boxes. A marker before the text (an icon or image that paints,
331
+ * or a number or bullet on the same line) makes it a hanging marker: `edge` is the marker's, `textEdge` the text's.
332
+ * - **Control groups.** Native and ARIA controls, and bounded boxes the visitor clicks (a pointer cursor or a tab stop,
333
+ * holding no control of their own), group by their parent and are measured at the first control: the border box
334
+ * when bounded, else its text. A control's contents are never blocks of the enclosing column.
335
+ * - **Surfaces.** A non-inline box with a border on at least three sides, its own fill different from what it sits on,
336
+ * or a shadow. A table is a surface measured at its rule and not descended into. A box with no text, control, image
337
+ * or icon inside (a loading bar) is a `placeholder`, which is not a block.
338
+ * - **Roles.** A list item is `list-item` when its list follows a paragraph; text centred in a box wider than it, or
339
+ * controls in a centring row, are `centred`.
340
+ * - **Rows, first, read by geometry.** Items set on one line, however the CSS lays them out: an item after another
341
+ * measured item on its line that holds one block (a text, a control, or a box holding at most one text) belongs to
342
+ * the row and is not measured. An item with a stack inside it is a column.
343
+ * - **Ornaments:** text with no letters or digits is not measured.
344
+ *
345
+ * Hidden elements (through any ancestor), zero-size ones and transparent text are skipped. What the rows and ornament
346
+ * rules set aside is counted. A frame with no text in ink is reported as placeholders only. The expression returns a
347
+ * JSON value; {@link parseEdgeProbe} is its typed read. *
348
+ * **Validated instrument (#1663, 2026-10-02):** this file as of `cec465319` (with `7bb4da13e`) passed a fresh sealed
349
+ * blind draw at the registered bar (27/30, κ 0.76), stricter than the design lead's reading on its disagreements. Any
350
+ * later change to what this file measures or decides is a new instrument until another fresh sealed draw.
506
351
  */
507
- interface VisualEvalDetailed {
508
- readonly result: VisualEvaluationResult | null;
509
- readonly unavailableReason?: string;
510
- readonly canvas?: CanvasClass;
511
- }
512
- declare function runVisualEvaluation(context: VisualEvalContext, config: VisualEvalConfig, deps?: VisualEvalDeps): Promise<VisualEvaluationResult | null>;
513
- declare function runVisualEvaluationDetailed(context: VisualEvalContext, config: VisualEvalConfig, deps?: VisualEvalDeps): Promise<VisualEvalDetailed>;
514
- /** The per-canvas verdicts without the PNGs — what the harness stamps on `EvalResult.visual`. */
515
- declare function summarizeVisualResult(result: VisualEvaluationResult): VisualEvalSummary | undefined;
516
352
 
517
- /** What the harness's eval round consumes from the visual leg. */
518
- interface VisualEvalOutcome {
519
- /** Tier-2 issues (empty when no browser is available). */
520
- issues: EvalIssue[];
521
- /**
522
- * Per-canvas summary — present ONLY when `config.canvases` was set and
523
- * the leg ran; the harness stamps it on `EvalResult.visual`. Absent on
524
- * the single-shot path (byte-identical to the pre-canvas result).
525
- */
526
- summary?: VisualEvalSummary;
527
- /**
528
- * ggui#1221 — whether the judge leg ran or was skipped (with the reason
529
- * `runVisualEvaluationDetailed` names). Always present: the absence of a
530
- * summary used to be indistinguishable from a clean single-shot run.
531
- */
532
- coverage: VisualCoverage;
353
+ /** What the probe returns: the measured blocks, and whether the frame showed nothing to evaluate. */
354
+ interface EdgeProbe {
355
+ readonly blocks: readonly EdgeBlock[];
356
+ readonly placeholdersOnly: boolean;
357
+ /** What the probe saw and did not measure, by rule, so a dropped block is counted rather than silent. */
358
+ readonly skipped: {
359
+ readonly rowItems: number;
360
+ readonly ornaments: number;
361
+ };
533
362
  }
363
+ declare const EDGE_BLOCKS_EXPRESSION: string;
534
364
  /**
535
- * Run visual evaluation and return tier 2 EvalIssues (+ the per-canvas
536
- * summary when canvases were requested).
365
+ * The probe's typed read: `null` when the page had no `#root` or returned something else, so a failed measurement is
366
+ * reported as unmeasured and never read as "no offsets". A malformed block fails the whole read for the same reason.
537
367
  */
538
- declare function runVisualEval(context: VisualEvalContext, config: VisualEvalConfig, deps?: VisualEvalDeps): Promise<VisualEvalOutcome>;
368
+ declare function parseEdgeProbe(value: unknown): EdgeProbe | null;
539
369
 
540
370
  /**
541
- * The stylesheet a visual judge renders under for an app: the app's theme
542
- * composed the way the runtime composes it (`composeThemeCss`, layer `page`
543
- * — one composition, never a second), so a judged canvas paints the tokens a
544
- * visitor's page paints. Absent theme ⇒ the design's default tokens,
545
- * byte-for-byte what the judge used before.
371
+ * ggui#1640 — one judged frame's (or one visual evaluation's) spend, summed over EVERY leg the judge reports.
372
+ *
373
+ * The judge reports its legs apart: the scoring calls' `inputTokens` / `outputTokens`, and, since ggui#1436, the
374
+ * report-only criteria call's `criteriaTokens`. A caller that sums only the first leg under-counts, and a dollar
375
+ * ceiling built on that sum stops late. {@link judgedFrameTokens} is the one sum. The two `satisfies` tables below list
376
+ * every `*Tokens` member of the results it reads, so a leg added to either result type fails the build here until the
377
+ * sum counts it.
546
378
  */
547
- declare function cssTokensForAppTheme(theme: AppTheme | undefined, mode?: 'light' | 'dark'): string;
548
379
 
549
- export { CONTENT_HEIGHT_EXPRESSION, CanvasClass, type CanvasFitPolicy, CanvasJudgeRecord, CanvasViewport, type CanvasVisualResult, type CaptureMode, type ChromiumProvider, EvalIssue, type EvaluateScoreInput, EvaluationConfig, EvaluationContext, EvaluationIssue, type EvaluationLoopOptions, type EvaluationLoopResult, EvaluationResult, type JudgeDesignIdentity, QualityMetadata, type ScreenshotAttempt, type ScreenshotBrowser, type ScreenshotDeps, type ScreenshotLauncher, type ScreenshotPage, type SdkMessage, VISUAL_EVAL_PROMPT, VISUAL_JUDGE_MAX_OUTPUT_TOKENS, VISUAL_JUDGE_PROMPT_DIGEST, VISUAL_JUDGE_PROMPT_VERSION, type VisualEvalConfig, type VisualEvalContext, type VisualEvalDeps, type VisualEvalDetailed, type VisualEvalOutcome, VisualEvalSummary, type VisualEvaluationResult, buildFixPrompt, callMultimodalLLM, canvasFitPolicy, canvasOverflowIssue, captureScreenshot, captureScreenshotDetailed, computeEvaluationScore, createEvaluationToolsServer, cssTokensForAppTheme, designTreeSha256, extractCompiledCode, extractCompiledCodeFromMessage, extractEvalResult, extractSourceCode, extractSourceCodeFromMessage, extractToolResultTexts, getEvaluatorSystemPrompt, judgeDesignIdentity, resetJudgeDesignIdentityCache, resolveDesignPackageDir, resolveLaunchOptions, runEvaluation, runEvaluationLoop, runVisualEval, runVisualEvaluation, runVisualEvaluationDetailed, summarizeVisualResult };
380
+ /** A spend in tokens: input and output, over every leg. */
381
+ interface JudgeSpend {
382
+ readonly inputTokens: number;
383
+ readonly outputTokens: number;
384
+ }
385
+ /** The legs {@link judgedFrameTokens} reads, as both result types carry them. */
386
+ interface JudgedTokens {
387
+ readonly inputTokens?: number;
388
+ readonly outputTokens?: number;
389
+ readonly criteriaTokens?: CriteriaCallTokens;
390
+ }
391
+ /** A judged frame's spend over every leg: the scoring calls plus the report-only criteria call, when one ran. */
392
+ declare function judgedFrameTokens(result: JudgedTokens): JudgeSpend;
393
+
394
+ export { CRITERIA_SELECTOR_VERSION, CriteriaBank, CriteriaCallTokens, type CriteriaMeasurements, type CriteriaSelectionResult, type DecodedImage, EDGE_BLOCKS_EXPRESSION, EdgeBlock, type EdgeProbe, EdgeVerdict, type EvaluateScoreInput, EvaluationConfig, EvaluationContext, EvaluationIssue, type EvaluationLoopOptions, type EvaluationLoopResult, EvaluationResult, INK_TOLERANCE, INSTRUMENT_BESIDE_JUDGE, INSTRUMENT_BY_ID, type InkExtent, type InkUnreadable, type JudgeSpend, type JudgedTokens, type PixelRegion, QualityMetadata, type SdkMessage, buildCriteriaJudgeBlock, buildFixPrompt, canonicalCriteriaContext, computeEvaluationScore, createEvaluationToolsServer, criteriaSetIdFor, cssTokensForAppTheme, decodePng, extractCompiledCode, extractCompiledCodeFromMessage, extractEvalResult, extractSourceCode, extractSourceCodeFromMessage, extractToolResultTexts, getEvaluatorSystemPrompt, judgedFrameTokens, parseEdgeProbe, readInkExtent, resolveCriteriaBlock, runEvaluation, runEvaluationLoop, selectCriteria };