@ggui-ai/ui-gen 0.16.0 → 0.17.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 (101) hide show
  1. package/dist/adapters/generation-dispatch.d.ts +6 -3
  2. package/dist/adapters/generation-dispatch.js +4944 -4239
  3. package/dist/adapters/generation-dispatch.js.map +1 -1
  4. package/dist/adapters/index.js +8 -5
  5. package/dist/adapters/index.js.map +1 -1
  6. package/dist/advanced/index.d.ts +12 -8
  7. package/dist/advanced/index.js +4462 -3726
  8. package/dist/advanced/index.js.map +1 -1
  9. package/dist/blueprint-validator.js +8 -12
  10. package/dist/blueprint-validator.js.map +1 -1
  11. package/dist/boilerplate.d.ts +5 -2
  12. package/dist/boilerplate.js +95 -12
  13. package/dist/boilerplate.js.map +1 -1
  14. package/dist/check/index.d.ts +2 -2
  15. package/dist/check/index.js +2 -0
  16. package/dist/check/index.js.map +1 -1
  17. package/dist/compose.js +1 -1
  18. package/dist/compose.js.map +1 -1
  19. package/dist/{create-ui-generator-CCIeQaEe.d.ts → create-ui-generator-C8Ki9Wz1.d.ts} +18 -2
  20. package/dist/{design-mode-BHEE7flj.d.ts → design-mode-DLufhrNp.d.ts} +0 -6
  21. package/dist/{dispatch-BA5dJcg-.d.ts → dispatch-D2htzi9h.d.ts} +2 -2
  22. package/dist/evaluation/axis-checks/index.d.ts +4 -4
  23. package/dist/evaluation/axis-checks/index.js +297 -13
  24. package/dist/evaluation/axis-checks/index.js.map +1 -1
  25. package/dist/evaluation/axis-checks/registry.d.ts +2 -2
  26. package/dist/evaluation/axis-checks/registry.js +252 -1
  27. package/dist/evaluation/axis-checks/registry.js.map +1 -1
  28. package/dist/evaluation/index.d.ts +160 -8
  29. package/dist/evaluation/index.js +702 -81
  30. package/dist/evaluation/index.js.map +1 -1
  31. package/dist/fragments/index.js +1 -1
  32. package/dist/fragments/index.js.map +1 -1
  33. package/dist/{generate-8L_bc2iP.d.ts → generate-9IeNT4ZY.d.ts} +1 -1
  34. package/dist/harness/check/runtime-render/index.d.ts +3 -2
  35. package/dist/harness/check/runtime-render/index.js +8 -12
  36. package/dist/harness/check/runtime-render/index.js.map +1 -1
  37. package/dist/harness/index.d.ts +3 -2
  38. package/dist/harness/index.js +385 -254
  39. package/dist/harness/index.js.map +1 -1
  40. package/dist/harness/prompts.d.ts +2 -2
  41. package/dist/harness/prompts.js +3 -3
  42. package/dist/harness/prompts.js.map +1 -1
  43. package/dist/harness/result-types.d.ts +3 -3
  44. package/dist/harness/runtime.d.ts +13 -4
  45. package/dist/harness/runtime.js +106 -19
  46. package/dist/harness/runtime.js.map +1 -1
  47. package/dist/harness/types-public.d.ts +13 -2
  48. package/dist/harness/types-public.js +385 -254
  49. package/dist/harness/types-public.js.map +1 -1
  50. package/dist/harness/validator-trace-sink.d.ts +2 -2
  51. package/dist/index.d.ts +29 -7
  52. package/dist/index.js +4465 -3727
  53. package/dist/index.js.map +1 -1
  54. package/dist/patch.d.ts +3 -2
  55. package/dist/{prompts-k6m6reqe.d.ts → prompts-YU9piOgs.d.ts} +12 -46
  56. package/dist/styling-profile-CxfvV48g.d.ts +35 -0
  57. package/dist/tools/get-primitives-ts.d.ts +1 -1
  58. package/dist/tools/get-primitives-ts.js +1 -1
  59. package/dist/tools/get-primitives-ts.js.map +1 -1
  60. package/dist/{types-public-D24JLJgl.d.ts → types-public-DVSssdc-.d.ts} +39 -3
  61. package/dist/validation/index.d.ts +1 -1
  62. package/dist/validation/index.js +1 -1
  63. package/dist/validation/index.js.map +1 -1
  64. package/dist/workflows.d.ts +3 -2
  65. package/package.json +12 -12
  66. package/src/adapters/generation-dispatch.ts +6 -1
  67. package/src/boilerplate/free-design-prompt.ts +7 -0
  68. package/src/boilerplate/hard-sections.ts +16 -1
  69. package/src/boilerplate/styling-profile.ts +166 -0
  70. package/src/boilerplate/system-prompt.ts +20 -8
  71. package/src/check/run-tier0.ts +2 -0
  72. package/src/contract-context.ts +15 -14
  73. package/src/create-harness.ts +4 -0
  74. package/src/create-ui-generator.ts +41 -2
  75. package/src/design-mode.ts +11 -1
  76. package/src/design-system-docs.ts +7 -4
  77. package/src/effort.ts +48 -0
  78. package/src/evaluation/axis-checks/checks/grid.ts +148 -0
  79. package/src/evaluation/axis-checks/checks/universal.ts +244 -0
  80. package/src/evaluation/axis-checks/dispatch.ts +78 -13
  81. package/src/evaluation/axis-checks/helpers.ts +12 -0
  82. package/src/evaluation/axis-checks/registry.ts +2 -0
  83. package/src/evaluation/design-identity.ts +96 -0
  84. package/src/evaluation/index.ts +17 -0
  85. package/src/evaluation/llm-evaluator.ts +13 -1
  86. package/src/evaluation/theme-css.ts +14 -0
  87. package/src/evaluation/types-public.ts +35 -1
  88. package/src/evaluation/visual-evaluator.ts +478 -45
  89. package/src/fragments/render.ts +1 -1
  90. package/src/harness/check/runtime-render/prepare-mockup.ts +18 -11
  91. package/src/harness/coding/init-session.ts +1 -0
  92. package/src/harness/coding/run-coding-turn.ts +6 -14
  93. package/src/harness/coding/run-eval-round.ts +31 -3
  94. package/src/harness/runtime.ts +10 -0
  95. package/src/harness/types-public.ts +11 -0
  96. package/src/index.ts +2 -0
  97. package/src/pin-fixtures.ts +98 -0
  98. package/src/run-check.ts +10 -10
  99. package/src/tools/get-primitives-ts.ts +1 -1
  100. package/src/tools.ts +2 -1
  101. package/src/validation/primitives.ts +1 -1
@@ -1,15 +1,16 @@
1
- import { E as EvalIssue, V as VisualEvalSummary } from '../types-public-D24JLJgl.js';
2
- export { A as AxisCheck, a as AxisCheckInput, C as CRITERIA, d as CanvasVisualSummary, e as CriterionCoverage, f as CriterionRunStatus, D as DEFAULT_QUALITY_CONFIG, g as EvalCategory, h as EvalCriterion, i as EvalOutcome, b as EvalResult, c as EvalTier, L as LLM_EVAL_STATIC_CRITERIA, P as Priority, Q as QualityConfig, j as QualityMode, k as buildCodingCriteriaSummary, l as criteriaFor, n as getActionableIssues, o as getCriteriaByPriority, p as getCriterionById, q as getLLMCriteria, r as isBlocked, m as matches, s as notApplicableCoverage, t as priorityForIssue } from '../types-public-D24JLJgl.js';
1
+ import { C as CanvasJudgeRecord, E as EvalIssue, V as VisualEvalSummary } from '../types-public-DVSssdc-.js';
2
+ export { A as AxisCheck, a as AxisCheckInput, d as CRITERIA, e as CanvasVisualSummary, f as CriterionCoverage, g as CriterionRunStatus, D as DEFAULT_QUALITY_CONFIG, h as EvalCategory, i as EvalCriterion, j as EvalOutcome, b as EvalResult, c as EvalTier, L as LLM_EVAL_STATIC_CRITERIA, P as Priority, Q as QualityConfig, k as QualityMode, l as buildCodingCriteriaSummary, n as criteriaFor, o as getActionableIssues, p as getCriteriaByPriority, q as getCriterionById, r as getLLMCriteria, s as isBlocked, m as matches, t as notApplicableCoverage, u as priorityForIssue } from '../types-public-DVSssdc-.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
5
  import { EvaluationContext, EvaluationConfig, QualityMetadata, EvaluationResult, EvaluationIssue } 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-BA5dJcg-.js';
8
- import { C as CanvasClass, g as CanvasViewport } from '../design-mode-BHEE7flj.js';
9
- 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-BHEE7flj.js';
7
+ export { R as RunAxisChecksInput, r as runAxisChecks } from '../dispatch-D2htzi9h.js';
10
8
  import { A as AgentConfig, L as LLMResponse } from '../llm-router-D7fjBhtr.js';
9
+ import { G as GenerationProfileInput } from '../styling-profile-CxfvV48g.js';
11
10
  import { LaunchOptions } from 'puppeteer-core';
12
- import '@ggui-ai/protocol';
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';
13
+ import { AppTheme } from '@ggui-ai/protocol';
13
14
  import '../axes-CzLEMDeB.js';
14
15
  import '../types-BOvHNG7K.js';
15
16
  import '../llm.js';
@@ -184,6 +185,30 @@ declare function extractCompiledCode(messages: SdkMessage[]): string | undefined
184
185
  */
185
186
  declare function extractSourceCode(messages: SdkMessage[]): string | undefined;
186
187
 
188
+ interface JudgeDesignIdentity {
189
+ /** Absolute path of the design `src` tree the judge bundled against. */
190
+ readonly src: string;
191
+ /** sha256 over every rendering input under `src` (see {@link isDesignRenderingInput}) — sorted relative path, then contents. */
192
+ readonly srcSha256: string;
193
+ }
194
+ /** sha256 over every rendering input under `root` (sorted relative path + contents) — the identity of a design tree as it paints. */
195
+ declare function designTreeSha256(root: string): string;
196
+ /**
197
+ * The identity of the tree at `src`, computed once per process per path (a
198
+ * judge run paints hundreds of frames from one tree).
199
+ *
200
+ * `null` when the tree cannot be READ (ggui#1110): a deployed image ships the
201
+ * design package as built output with no `src/`, and an identity is a receipt
202
+ * about a judgement — never a precondition for making one. Before this,
203
+ * `scandir` threw ENOENT inside the evaluation round wherever the package ships
204
+ * built output only, the round returned no evaluation at all, and a bar refused
205
+ * a card that had cleared it. A row without the receipt says so; a round that cannot
206
+ * stamp one still runs.
207
+ */
208
+ declare function judgeDesignIdentity(src: string): JudgeDesignIdentity | null;
209
+ /** Test seam: forget cached identities (a test that rewrites a tree between runs). */
210
+ declare function resetJudgeDesignIdentityCache(): void;
211
+
187
212
  interface VisualEvalConfig {
188
213
  /** LLM provider for multimodal evaluation */
189
214
  provider: 'claude' | 'google';
@@ -216,6 +241,23 @@ interface VisualEvalConfig {
216
241
  * evaluator constructs so its multimodal call never falls back to
217
242
  * `process.env` for credentials or model routing.
218
243
  */
244
+ /**
245
+ * Vision calls per judged canvas on the SAME captured frame, aggregated by
246
+ * the median (ggui#1072). Default 1 — a single judgement, byte-identical to
247
+ * the instrument before this option existed. K is an instrument dial: a
248
+ * run mixes K at its own peril.
249
+ */
250
+ judgeK?: number;
251
+ /** The canvases sampled `judgeK` times; default = every judged canvas when `judgeK > 1`. */
252
+ judgeKCanvases?: readonly CanvasClass[];
253
+ /**
254
+ * The design `src` tree the judge bundles the component against
255
+ * (ggui#1042): an explicit input, so a judge-only re-judge names the tree
256
+ * it painted with. Default: the design package beside this one.
257
+ */
258
+ designSrcDir?: string;
259
+ /** 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). */
260
+ themeMode?: 'light' | 'dark';
219
261
  routeOverride?: AgentConfig['routeOverride'];
220
262
  /**
221
263
  * Provider-429-retry observer — see `AgentConfig.onRetry`.
@@ -235,7 +277,39 @@ interface CanvasVisualResult {
235
277
  passed: boolean;
236
278
  /** The PNG the judge saw — kept for artefact persistence + the human look. */
237
279
  screenshotPng: Buffer;
280
+ /**
281
+ * The document's scroll height at this canvas's viewport, CSS px — what
282
+ * the box would have to be for nothing to be hidden (ggui#1027). `null`
283
+ * when the page could not be measured.
284
+ */
285
+ contentHeight: number | null;
286
+ /** `contentHeight > viewport.height` — a measurement; what it MEANS is {@link canvasFitPolicy}'s. */
287
+ overflow: boolean;
288
+ /** How `score` was reached — always present (ggui#1072). */
289
+ judge: CanvasJudgeRecord;
290
+ /** How the judge composed the mount (ggui#1100): `'fill'` on every fullscreen canvas, absent on the inline card. */
291
+ fit?: 'fill';
292
+ }
293
+ /** How a canvas is captured for the judge and what an overflow means there (ggui#1027). */
294
+ type CaptureMode = 'viewport' | 'full-page';
295
+ interface CanvasFitPolicy {
296
+ /** `viewport` = the judge sees the box the user sees; `full-page` = the whole scrolled document. */
297
+ readonly capture: CaptureMode;
298
+ /** The verdict an overflow earns on this canvas. */
299
+ readonly overflow: 'fail' | 'warn' | 'none';
238
300
  }
301
+ /**
302
+ * The inline chat card is a BOX — the bubble bounds the component and it
303
+ * does not scroll — so the judge captures the viewport (a 1289 px hello on
304
+ * a 640 px card was scored 86 from a full-page capture that showed the
305
+ * judge what no user sees) and an overflow is a critical layout issue that
306
+ * fails the canvas. A phone's first screen may scroll, so the overflow is
307
+ * reported as a major issue and the score stands. Pages (`md`/`lg`/`xl`)
308
+ * scroll by design: measured, never judged.
309
+ */
310
+ declare function canvasFitPolicy(canvas: CanvasClass): CanvasFitPolicy;
311
+ /** The deterministic fit issue — one per overflowing canvas, in the judge's issue shape so it rides the same channel. */
312
+ declare function canvasOverflowIssue(canvas: CanvasClass, viewport: CanvasViewport, contentHeight: number, verdict: 'fail' | 'warn'): EvaluationIssue;
239
313
  /**
240
314
  * `runVisualEvaluation`'s result. Identical to `EvaluationResult` when
241
315
  * `config.canvases` is unset; with canvases set, `canvases` holds the
@@ -244,6 +318,10 @@ interface CanvasVisualResult {
244
318
  */
245
319
  interface VisualEvaluationResult extends EvaluationResult {
246
320
  canvases?: CanvasVisualResult[];
321
+ /** The design tree the judge painted with (ggui#1042) — present on every per-canvas judgement. */
322
+ design?: JudgeDesignIdentity;
323
+ /** The mode `cssTokens` were composed in, when the caller said (ggui#1076). */
324
+ themeMode?: 'light' | 'dark';
247
325
  }
248
326
  /** Injection points for `runVisualEvaluation` — screenshot deps plus the judge call (tests). */
249
327
  interface VisualEvalDeps extends ScreenshotDeps {
@@ -257,7 +335,24 @@ interface VisualEvalContext {
257
335
  originalPrompt: string;
258
336
  /** Design system CSS tokens */
259
337
  cssTokens?: string;
338
+ /** The app's generation profile (#991) — judged relative to, never against. */
339
+ profile?: GenerationProfileInput;
260
340
  }
341
+ /**
342
+ * The `@ggui-ai/design` package root — resolved by MODULE ID, never by counting
343
+ * directories (ggui#1110).
344
+ *
345
+ * The arithmetic this replaced (`…/'..','..','..','design'`) was correct only
346
+ * for the layout it was written against — `node_modules/@ggui-ai/ui-gen/dist/
347
+ * evaluation` → `node_modules/@ggui-ai/` + `design`. Under a deploy-flattened
348
+ * layout it landed one level too high, at `node_modules/design`, a path that is
349
+ * not the design package at all: the judge then walked a directory that does not
350
+ * exist, threw ENOENT inside every evaluation round on that deployment, and a
351
+ * bar refused cards no one could judge. `@ggui-ai/design` exports `./package.json`,
352
+ * so the module resolver answers correctly in every layout — scoped, flattened,
353
+ * hoisted — and the receipt keeps working inside the image.
354
+ */
355
+ declare function resolveDesignPackageDir(): string;
261
356
  /** The page surface the capture uses — a structural subset of puppeteer's `Page`. */
262
357
  interface ScreenshotPage {
263
358
  setContent(html: string, options: {
@@ -271,6 +366,8 @@ interface ScreenshotPage {
271
366
  waitForSelector(selector: string, options: {
272
367
  timeout: number;
273
368
  }): Promise<unknown>;
369
+ /** Evaluates a JS expression in the page and returns its serialised value — the fit measurement (ggui#1027). */
370
+ evaluate(expression: string): Promise<unknown>;
274
371
  screenshot(options: {
275
372
  type: 'png';
276
373
  fullPage: boolean;
@@ -316,10 +413,24 @@ declare function resolveLaunchOptions(viewport: {
316
413
  * Take a screenshot of the rendered component.
317
414
  * Returns the PNG bytes, or null if no browser could be launched.
318
415
  */
416
+ /** Screenshot plus the reason when none could be taken — the judge's `unavailableReason`. */
417
+ interface ScreenshotAttempt {
418
+ readonly png: Buffer | null;
419
+ readonly reason?: string;
420
+ /** The document's scroll height at the viewport (ggui#1027); `null` when unmeasurable. */
421
+ readonly contentHeight: number | null;
422
+ }
423
+ /** The expression the fit measurement evaluates in the page — the taller of the two scroll heights. */
424
+ declare const CONTENT_HEIGHT_EXPRESSION = "Math.max(document.documentElement.scrollHeight, document.body ? document.body.scrollHeight : 0)";
425
+ declare function captureScreenshotDetailed(html: string, viewport?: {
426
+ width: number;
427
+ height: number;
428
+ }, deps?: ScreenshotDeps, capture?: CaptureMode): Promise<ScreenshotAttempt>;
319
429
  declare function captureScreenshot(html: string, viewport?: {
320
430
  width: number;
321
431
  height: number;
322
432
  }, deps?: ScreenshotDeps): Promise<Buffer | null>;
433
+ 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}";
323
434
  /**
324
435
  * Send the screenshot to the configured multimodal provider through
325
436
  * the shared `LLMAgent` machinery. Routing through `createVisionAgent`
@@ -330,7 +441,24 @@ declare function captureScreenshot(html: string, viewport?: {
330
441
  * governs credentials and model routing (including the Anthropic
331
442
  * Bedrock path) instead of `process.env`.
332
443
  */
333
- declare function callMultimodalLLM(config: VisualEvalConfig, model: string, prompt: string, screenshot: Buffer, originalPrompt: string): Promise<LLMResponse>;
444
+ /**
445
+ * Output budget for the judge's answer. 1500 cut a board's issue list
446
+ * mid-array (`Expected ',' or ']' after array element`, six kanban cells
447
+ * on 2026-09-11) — deterministic on the content, so a same-prompt retry
448
+ * could never clear it. 4096 fits the bounded list the prompt now asks for
449
+ * with room; the salvage path covers the remainder.
450
+ */
451
+ declare const VISUAL_JUDGE_MAX_OUTPUT_TOKENS = 4096;
452
+ /**
453
+ * The judge instrument's name and content digest, for the record a run
454
+ * stamps beside every visual score. The NAME is for readers; the DIGEST
455
+ * is computed from the prompt text at module load, so a stamped row can
456
+ * never claim a prompt version it did not run — change the prompt and the
457
+ * digest moves with it (the pin ties the name to the bounded-list text).
458
+ */
459
+ declare const VISUAL_JUDGE_PROMPT_VERSION = "v2-bounded-issues";
460
+ declare const VISUAL_JUDGE_PROMPT_DIGEST: string;
461
+ declare function callMultimodalLLM(config: VisualEvalConfig, model: string, prompt: string, screenshot: Buffer, originalPrompt: string, profileBlock?: string): Promise<LLMResponse>;
334
462
  /**
335
463
  * Run visual evaluation on a compiled component.
336
464
  *
@@ -340,7 +468,22 @@ declare function callMultimodalLLM(config: VisualEvalConfig, model: string, prom
340
468
  *
341
469
  * Returns null if puppeteer is not available (graceful fallback).
342
470
  */
471
+ /**
472
+ * The judge's answer WITH the reason when it could not judge: `result` is
473
+ * null exactly when no screenshot could be taken (no browser, a launch or
474
+ * in-page failure) or the component could not be bundled; `unavailableReason`
475
+ * names why in words and `canvas` the canvas it happened at. A production
476
+ * caller records the reason in its receipt — a `judge_unavailable` that only
477
+ * says "null" cost a log dive on 2026-09-10 (puppeteer-core missing in the
478
+ * deploy image).
479
+ */
480
+ interface VisualEvalDetailed {
481
+ readonly result: VisualEvaluationResult | null;
482
+ readonly unavailableReason?: string;
483
+ readonly canvas?: CanvasClass;
484
+ }
343
485
  declare function runVisualEvaluation(context: VisualEvalContext, config: VisualEvalConfig, deps?: VisualEvalDeps): Promise<VisualEvaluationResult | null>;
486
+ declare function runVisualEvaluationDetailed(context: VisualEvalContext, config: VisualEvalConfig, deps?: VisualEvalDeps): Promise<VisualEvalDetailed>;
344
487
  /** The per-canvas verdicts without the PNGs — what the harness stamps on `EvalResult.visual`. */
345
488
  declare function summarizeVisualResult(result: VisualEvaluationResult): VisualEvalSummary | undefined;
346
489
 
@@ -361,4 +504,13 @@ interface VisualEvalOutcome {
361
504
  */
362
505
  declare function runVisualEval(context: VisualEvalContext, config: VisualEvalConfig): Promise<VisualEvalOutcome>;
363
506
 
364
- export { CanvasClass, CanvasViewport, type CanvasVisualResult, type ChromiumProvider, EvalIssue, type EvaluateScoreInput, EvaluationConfig, EvaluationContext, EvaluationIssue, type EvaluationLoopOptions, type EvaluationLoopResult, EvaluationResult, QualityMetadata, type ScreenshotBrowser, type ScreenshotDeps, type ScreenshotLauncher, type ScreenshotPage, type SdkMessage, type VisualEvalConfig, type VisualEvalContext, type VisualEvalDeps, type VisualEvalOutcome, VisualEvalSummary, type VisualEvaluationResult, buildFixPrompt, callMultimodalLLM, captureScreenshot, computeEvaluationScore, createEvaluationToolsServer, extractCompiledCode, extractCompiledCodeFromMessage, extractEvalResult, extractSourceCode, extractSourceCodeFromMessage, extractToolResultTexts, getEvaluatorSystemPrompt, resolveLaunchOptions, runEvaluation, runEvaluationLoop, runVisualEval, runVisualEvaluation, summarizeVisualResult };
507
+ /**
508
+ * The stylesheet a visual judge renders under for an app: the app's theme
509
+ * composed the way the runtime composes it (`composeThemeCss`, layer `page`
510
+ * — one composition, never a second), so a judged canvas paints the tokens a
511
+ * visitor's page paints. Absent theme ⇒ the design's default tokens,
512
+ * byte-for-byte what the judge used before.
513
+ */
514
+ declare function cssTokensForAppTheme(theme: AppTheme | undefined, mode?: 'light' | 'dark'): string;
515
+
516
+ 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 };