@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,265 +0,0 @@
1
- import { JsonObject } from '@ggui-ai/protocol';
2
- import { LLMToolDef } from './llm.js';
3
-
4
- interface AgentConfig {
5
- provider: 'anthropic' | 'openai' | 'google' | 'openrouter';
6
- model: string;
7
- /**
8
- * Sampling temperature. When defined it is threaded into the provider
9
- * request; when undefined the provider default is used (unchanged
10
- * behavior for all existing callers).
11
- *
12
- * Capability is the ROUTER's: Anthropic Opus 4.7+ and the 5-family
13
- * (`claude-opus-4-7*`, `claude-fable-5*`, `claude-opus-5*`,
14
- * `claude-sonnet-5*`, incl. Bedrock ids) return HTTP 400 on a
15
- * non-default `temperature`/`top_p`/`top_k`, so the Anthropic adapter
16
- * STRIPS the value for those ids (one log line naming model + param)
17
- * and reports the effective sampling on `LLMResponse.sampling`. Callers
18
- * keep expressing intent; disclosure reads the applied value.
19
- */
20
- temperature?: number;
21
- /**
22
- * Explicit per-call credentials/routing, bypassing `process.env`
23
- * entirely when supplied. Absent (default) preserves today's
24
- * behavior — each agent falls back to reading its provider's env
25
- * var(s) directly, so existing callers (including self-hosters who
26
- * set env vars once at process start) are unaffected. Use this to
27
- * run concurrent generations safely in one process: two simultaneous
28
- * calls with different `routeOverride`s never race on shared
29
- * `process.env` state.
30
- */
31
- routeOverride?: {
32
- readonly apiKey?: string;
33
- /** Anthropic-only: force the Bedrock-IAM client instead of the direct API client. */
34
- readonly useBedrock?: boolean;
35
- /**
36
- * Anthropic-only (ggui#1185): run on the machine's own Claude Code
37
- * LOGIN instead of a key — the route decision `auth: 'claude-code-login'`
38
- * lands here, and `createAgent` / `createVisionAgent` select
39
- * `ClaudeCodeLoginAgent` (one `query()` per call) instead of the raw
40
- * API client. Every agent the harness builds — coding, evaluation,
41
- * visual judge — takes the same decision. Off unless set; a real key
42
- * never coexists with it (the router refuses a non-anthropic route).
43
- */
44
- readonly claudeCodeLogin?: boolean;
45
- };
46
- /**
47
- * Observer invoked once per retried attempt when `apiCall()` (#489)
48
- * retries a rate-limited (HTTP 429) provider call. Fires AFTER the
49
- * retry decision is made and BEFORE the delay is awaited — never on
50
- * the terminal failure/success of the whole call. Purely an
51
- * observability hook: it never influences whether or how long
52
- * `apiCall()` retries. If the observer itself throws, `apiCall()`
53
- * catches it, logs a `console.warn`, and proceeds to the retry
54
- * delay unaffected — a broken observer cannot turn a recoverable
55
- * 429 into an unrelated hard failure. Absent (default) is a no-op;
56
- * `apiCall()` still logs every retry via `console.warn` regardless.
57
- */
58
- onRetry?: (info: ProviderRetryInfo) => void;
59
- }
60
- /** One retried attempt's context — passed to `AgentConfig.onRetry`. */
61
- interface ProviderRetryInfo {
62
- readonly provider: AgentConfig['provider'];
63
- /** 1-based index of this retry (1 = first retry, 2 = second, …). */
64
- readonly attempt: number;
65
- /** Total retries `apiCall()` will attempt before giving up. */
66
- readonly maxAttempts: number;
67
- /** HTTP status of the failed call, when the caught error carries one. */
68
- readonly status: number | undefined;
69
- /** Provider-supplied `Retry-After` value in seconds, when present and within the cap. */
70
- readonly retryAfterSec: number | undefined;
71
- /** Delay actually awaited before the next attempt. */
72
- readonly delayMs: number;
73
- /** One-line error summary (same shape as the existing `console.error` line). */
74
- readonly message: string;
75
- }
76
- /**
77
- * What sampling the provider ACTUALLY received for a text call — so a
78
- * caller that asked for `temperature: 0` (a disclosed reproducibility
79
- * property, e.g. the benchmark judge panel) can record the effective
80
- * value instead of the requested one. `'provider-default'` means no
81
- * temperature reached the provider: either the caller passed none, or
82
- * the adapter stripped it because the model rejects sampling params
83
- * (Anthropic Opus 4.7+ / 5-family → HTTP 400 on non-default
84
- * `temperature`/`top_p`/`top_k`); `strippedReason` names the second case.
85
- */
86
- interface AppliedSampling {
87
- readonly temperature: number | 'provider-default';
88
- readonly strippedReason?: string;
89
- }
90
- interface LLMResponse {
91
- text: string;
92
- inputTokens: number;
93
- outputTokens: number;
94
- /**
95
- * Effective sampling for this call (see {@link AppliedSampling}).
96
- * Every provider's `callText` sets it; absent only on paths that
97
- * predate the field — treat absence as unknown, never as "as
98
- * requested".
99
- */
100
- sampling?: AppliedSampling;
101
- }
102
- interface LLMTool {
103
- name: string;
104
- description: string;
105
- parameters: JsonObject;
106
- handler: (args: JsonObject) => Promise<{
107
- content: Array<{
108
- text: string;
109
- }>;
110
- isError?: boolean;
111
- }>;
112
- }
113
- interface LLMWithToolsResponse {
114
- text: string;
115
- inputTokens: number;
116
- outputTokens: number;
117
- turnsUsed: number;
118
- /** Prompt-cache reads summed over the loop's turns, when the provider reports them (absent = unreported, never zero). */
119
- cacheReadTokens?: number;
120
- }
121
- interface LLMToolCall {
122
- /** Provider-specific call ID (for sendToolResult) */
123
- id?: string;
124
- name: string;
125
- input: JsonObject;
126
- }
127
- interface LLMToolCallResponse {
128
- toolCalls: LLMToolCall[];
129
- inputTokens: number;
130
- outputTokens: number;
131
- /**
132
- * The tool-choice mode the provider ACTUALLY received. Callers ask
133
- * for `'required'` (Anthropic `tool_choice: any`); Claude Fable 5.1 and
134
- * Opus 5.5 reject forced tool choice with HTTP 400, so the Anthropic
135
- * and OpenRouter adapters downgrade to `'auto'` for those families and
136
- * report it here. A
137
- * downgraded call may legitimately return zero tool calls — the
138
- * evaluator's `criteriaCoverage` records that as `skipped`, never as
139
- * a pass. Absent = predates the field (treat as unknown).
140
- */
141
- appliedToolChoice?: 'required' | 'auto';
142
- /**
143
- * Tokens read from / written to the prompt cache, when the provider
144
- * reports them. Optional because not every provider exposes
145
- * prompt-cache accounting — absent means "unreported", never zero.
146
- */
147
- cacheReadTokens?: number;
148
- cacheCreationTokens?: number;
149
- }
150
- /** Result of executing a tool — passed to sendToolResult to close the API contract. */
151
- interface LLMToolResult {
152
- /** Tool call ID from the response (for providers that need it) */
153
- callId?: string;
154
- /** Tool name */
155
- name: string;
156
- /** Text result of executing the tool */
157
- result: string;
158
- /** Whether the tool execution failed */
159
- isError?: boolean;
160
- }
161
- declare abstract class LLMAgent {
162
- abstract readonly provider: AgentConfig['provider'];
163
- private client;
164
- protected lastSessionId: string | undefined;
165
- /**
166
- * Explicit per-call routing override — see `AgentConfig.routeOverride`.
167
- * Absent when constructed via the bare `new XAgent()` form (every
168
- * existing call site), so `createClient()`/`resolveModel()` fall
169
- * back to `process.env` exactly as before.
170
- */
171
- protected readonly routeOverride: AgentConfig['routeOverride'];
172
- /** See `AgentConfig.onRetry` (#489). Absent is a no-op. */
173
- protected readonly onRetry: AgentConfig['onRetry'];
174
- constructor(routeOverride?: AgentConfig['routeOverride'], onRetry?: AgentConfig['onRetry']);
175
- protected abstract resolveModel(model: string): string;
176
- protected abstract createClient(): Promise<unknown>;
177
- protected getClient<T>(): Promise<T>;
178
- /** Text-only call — no tools */
179
- abstract callText(model: string, systemPrompt: string, userPrompt: string, maxTokens?: number, temperature?: number): Promise<LLMResponse>;
180
- /**
181
- * Single-turn function calling — returns tool calls without executing them.
182
- * Each provider uses its native function/tool calling:
183
- * - Anthropic: tool_use blocks
184
- * - OpenAI: function_call output items
185
- * - Google: functionCall parts
186
- * SDK handles JSON escaping — safe for code, diffs, and other content.
187
- */
188
- abstract callTools(model: string, systemPrompt: string, userPrompt: string, tools: LLMToolDef[], toolChoice?: 'required' | 'auto',
189
- /**
190
- * Optional scoped fallback tools. If the primary tools fail with a
191
- * transport-class error (e.g. `malformed_tool_call` on Gemini after
192
- * retry exhaustion), the provider may retry once with these narrower
193
- * tools before throwing. Universal signal — not provider-gated.
194
- */
195
- scopedTools?: LLMToolDef[]): Promise<LLMToolCallResponse>;
196
- /** Multi-turn agentic loop — executes tools internally */
197
- abstract callWithTools(model: string, systemPrompt: string, userPrompt: string, tools: LLMTool[], maxTurns: number): Promise<LLMWithToolsResponse>;
198
- /**
199
- * Pre-warm cache for repeated callTools() calls with the same system prompt + tools.
200
- * Override in providers that support server-side context caching (e.g., Google).
201
- * No-op by default (Anthropic/OpenAI handle caching automatically per-request).
202
- */
203
- warmCache(_model: string, _systemPrompt: string, _tools: LLMToolDef[], _toolChoice?: 'required' | 'auto'): Promise<void>;
204
- /** Cleanup any cached resources. Call after generation completes. No-op by default. */
205
- cleanup(): Promise<void>;
206
- /** Reset session state between independent generation runs. */
207
- resetSession(): void;
208
- /**
209
- * Send tool execution results back to the provider to close the API contract.
210
- * Call this after executing tools from callTools() and before the next callTools().
211
- *
212
- * For providers with server-side state (Google, OpenAI), this sends the
213
- * function results so the next callTools() can chain properly.
214
- * For stateless providers (Anthropic), this is a no-op.
215
- *
216
- * Override in providers that need it.
217
- */
218
- sendToolResult(_results: LLMToolResult[]): Promise<void>;
219
- /**
220
- * Execute an API call, retrying once or twice on HTTP 429
221
- * (rate-limited) before giving up (#489).
222
- *
223
- * Policy: on a 429, honor the provider's `Retry-After` header when
224
- * present (capped at `RETRY_AFTER_CAP_SEC` — a provider asking for a
225
- * longer wait is treated as "don't retry", not "wait longer": making
226
- * the caller sit through 15+ more seconds on a single failed call is
227
- * a bad experience regardless of what's driving the request);
228
- * otherwise fall back to exponential backoff with jitter, capped at
229
- * `DEFAULT_BACKOFF_MAX_MS` per attempt. Stops after
230
- * `MAX_RETRY_ATTEMPTS` retries OR once the cumulative delay would
231
- * exceed `MAX_TOTAL_RETRY_DELAY_MS`, whichever comes first. Any
232
- * non-429 error, or a 429 with no attempts left, is logged and
233
- * re-thrown immediately — unchanged from the pre-#489 behavior.
234
- *
235
- * **Budget scope (final-review correction):** `MAX_TOTAL_RETRY_DELAY_MS`
236
- * bounds a single `apiCall()` invocation, not a whole generation. A
237
- * generation issues many sequential `apiCall()` calls (coding turns,
238
- * tool-result round-trips, eval rounds); under sustained throttling
239
- * each one can independently add up to `MAX_TOTAL_RETRY_DELAY_MS`, so
240
- * a generation with k rate-limited calls can add up to roughly `k *
241
- * MAX_TOTAL_RETRY_DELAY_MS` to how long it holds its caller's
242
- * resources (e.g. the caller's concurrency slot) — not a flat 20s
243
- * ceiling. No shared per-generation budget is threaded here by
244
- * design (accepted ruling, not an oversight): the caller's own
245
- * queue/admission backstop is what bounds how long other
246
- * queued work waits, independent of any one generation's retry
247
- * total.
248
- */
249
- protected apiCall<T>(fn: () => Promise<T>): Promise<T>;
250
- }
251
- /**
252
- * Create a fresh agent instance for the given provider.
253
- * Each call returns a new instance — no shared state between callers.
254
- *
255
- * Accepts either a bare provider string (every pre-existing call
256
- * site — the agent falls back to reading its provider's env var(s)
257
- * directly) or a full {@link AgentConfig}, whose `routeOverride`
258
- * (when present) is threaded into the constructed agent so it never
259
- * touches `process.env`.
260
- */
261
- declare function createAgent(provider: AgentConfig['provider']): LLMAgent;
262
- declare function createAgent(config: AgentConfig): LLMAgent;
263
- declare function callLLM(config: AgentConfig, systemPrompt: string, userPrompt: string, maxTokens?: number): Promise<LLMResponse>;
264
-
265
- export { type AgentConfig as A, type LLMResponse as L, type ProviderRetryInfo as P, createAgent as a, callLLM as c };