@ggui-ai/ui-gen 0.7.0 → 0.9.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 (52) hide show
  1. package/dist/adapters/generation-dispatch.d.ts +10 -0
  2. package/dist/adapters/generation-dispatch.js +172 -1392
  3. package/dist/adapters/generation-dispatch.js.map +1 -1
  4. package/dist/advanced/index.d.ts +1 -1
  5. package/dist/advanced/index.js +191 -1403
  6. package/dist/advanced/index.js.map +1 -1
  7. package/dist/boilerplate.js +3 -2
  8. package/dist/boilerplate.js.map +1 -1
  9. package/dist/compose.js +5 -5
  10. package/dist/compose.js.map +1 -1
  11. package/dist/{create-ui-generator-GX7tvbyH.d.ts → create-ui-generator-B9kV4U9h.d.ts} +13 -0
  12. package/dist/evaluation/axis-checks/index.js +32 -1
  13. package/dist/evaluation/axis-checks/index.js.map +1 -1
  14. package/dist/evaluation/axis-checks/registry.js +32 -1
  15. package/dist/evaluation/axis-checks/registry.js.map +1 -1
  16. package/dist/evaluation/index.js +57 -12
  17. package/dist/evaluation/index.js.map +1 -1
  18. package/dist/fragments/index.js +5 -5
  19. package/dist/fragments/index.js.map +1 -1
  20. package/dist/harness/index.d.ts +4 -125
  21. package/dist/harness/index.js +34 -19
  22. package/dist/harness/index.js.map +1 -1
  23. package/dist/harness/runtime.d.ts +9 -0
  24. package/dist/harness/runtime.js +3 -2
  25. package/dist/harness/runtime.js.map +1 -1
  26. package/dist/harness/types-public.js +8 -7
  27. package/dist/harness/types-public.js.map +1 -1
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +191 -1403
  30. package/dist/index.js.map +1 -1
  31. package/dist/llm-router-1TyI0_TV.d.ts +156 -0
  32. package/dist/providers/index.d.ts +35 -93
  33. package/dist/providers/index.js +13 -8
  34. package/dist/providers/index.js.map +1 -1
  35. package/dist/validation/index.js +2 -2
  36. package/dist/validation/index.js.map +1 -1
  37. package/package.json +18 -18
  38. package/src/adapters/generation-dispatch.ts +19 -2
  39. package/src/boilerplate/system-prompt.ts +3 -2
  40. package/src/create-ui-generator.ts +44 -11
  41. package/src/evaluation/axis-checks/checks/state-merge.ts +1 -1
  42. package/src/evaluation/axis-checks/checks/universal.ts +39 -0
  43. package/src/evaluation/llm-evaluator.ts +13 -3
  44. package/src/evaluation/visual-evaluator.ts +5 -1
  45. package/src/fragments/realtime.ts +3 -3
  46. package/src/fragments/state.ts +2 -2
  47. package/src/harness/coding/init-session.ts +4 -1
  48. package/src/harness/coding/run-eval-round.ts +6 -0
  49. package/src/harness/llm-router.ts +59 -14
  50. package/src/harness/runtime.ts +8 -0
  51. package/src/providers/bedrock.ts +84 -22
  52. package/src/validation/ui-compiler.ts +2 -2
@@ -50,19 +50,29 @@
50
50
  * discriminator if a third auth mode (e.g. cross-account assume-role)
51
51
  * lands.
52
52
  *
53
- * ## Model IDs — pass-through
53
+ * ## Model IDs — pass-through, endpoint chosen by ID shape
54
54
  *
55
- * Bedrock and the direct Anthropic API use OVERLAPPING but DISTINCT
56
- * model id namespaces:
55
+ * Bedrock serves Anthropic models through TWO endpoints with DISJOINT
56
+ * model-id namespaces (live-probed against us-east-1, 2026-08-13):
57
57
  *
58
- * - Direct API: `claude-haiku-4-5`, `claude-opus-4-7`, etc.
59
- * - Bedrock foundation models: `anthropic.claude-sonnet-4-6`
60
- * - Bedrock cross-region inference profiles: `us.anthropic.claude-haiku-4-5-20251001-v1:0`
58
+ * - **bedrock-runtime** (`AnthropicBedrock`): serves ONLY
59
+ * cross-region inference-profile ids —
60
+ * `us.anthropic.claude-haiku-4-5-20251001-v1:0` etc. Bare
61
+ * `anthropic.*` foundation ids are rejected with 400
62
+ * "on-demand throughput isn't supported".
63
+ * - **Messages-API endpoint / Mantle** (`AnthropicBedrockMantle`):
64
+ * serves ONLY region-less `anthropic.*` ids —
65
+ * `anthropic.claude-opus-5`, `anthropic.claude-haiku-4-5`. The
66
+ * Claude 5 family and Opus 4.8 exist ONLY here. Profile ids are
67
+ * rejected with 404. Requires the account to have enabled Claude
68
+ * in Amazon Bedrock (otherwise every id 403s "not available for
69
+ * this account").
61
70
  *
62
- * The adapter passes whatever `request.model` contains straight to
63
- * Bedrock — translation lives in the caller (model picker / deployment
64
- * config). Supply a Bedrock foundation-model or inference-profile id,
65
- * not a direct-API model name.
71
+ * Because the namespaces never overlap, the adapter routes each
72
+ * request by shape: ids starting `anthropic.` go to Mantle, region-
73
+ * prefixed ids (`us.` / `eu.` / `apac.` / `global.`) go to
74
+ * bedrock-runtime. The id itself passes through untranslated —
75
+ * supply a Bedrock id, not a direct-API model name.
66
76
  *
67
77
  * ## Failure mapping
68
78
  *
@@ -87,7 +97,7 @@
87
97
  * subclasses in the SDK, distinguished by `.status` (403 / 429 / 400
88
98
  * respectively).
89
99
  */
90
- import { AnthropicBedrock } from '@anthropic-ai/bedrock-sdk';
100
+ import { AnthropicBedrock, AnthropicBedrockMantle } from '@anthropic-ai/bedrock-sdk';
91
101
  import type { LlmProvider } from '@ggui-ai/mcp-server-core';
92
102
  import {
93
103
  makeProviderError,
@@ -110,6 +120,47 @@ import { classifyFetchError } from './http.js';
110
120
  const PROVIDER: LlmProvider = 'bedrock';
111
121
  const DEFAULT_MAX_TOKENS = 4096;
112
122
 
123
+ /**
124
+ * Which Bedrock endpoint a model id resolves to. The namespaces are
125
+ * disjoint (see the docstring above), so the shape of the id fully
126
+ * determines the endpoint — no configuration knob needed.
127
+ */
128
+ export type BedrockEndpoint = 'runtime' | 'mantle';
129
+
130
+ /**
131
+ * Structural slice of the two SDK clients the adapter actually drives —
132
+ * the seam that lets tests inject a stub without standing up a real
133
+ * AWS client. Both `AnthropicBedrock` and `AnthropicBedrockMantle`
134
+ * satisfy it (the adapter's single-completion contract only ever calls
135
+ * non-streaming `messages.create`; the response is parsed from
136
+ * `unknown` by `parseAnthropicMessagesResponse`, so the SDK's
137
+ * version-volatile `Message` type is deliberately not part of the
138
+ * seam).
139
+ */
140
+ export interface BedrockMessagesClient {
141
+ readonly messages: {
142
+ create(
143
+ body: {
144
+ model: string;
145
+ max_tokens: number;
146
+ system?: string;
147
+ messages: Array<{ role: 'user'; content: string }>;
148
+ },
149
+ options?: { signal?: AbortSignal },
150
+ ): Promise<unknown>;
151
+ };
152
+ }
153
+
154
+ /**
155
+ * Route a Bedrock model id to its serving endpoint. Region-less
156
+ * `anthropic.*` ids exist only on the Messages-API (Mantle) endpoint;
157
+ * everything else (region-prefixed inference profiles, ARNs) belongs
158
+ * to bedrock-runtime.
159
+ */
160
+ export function bedrockEndpointFor(model: string): BedrockEndpoint {
161
+ return model.startsWith('anthropic.') ? 'mantle' : 'runtime';
162
+ }
163
+
113
164
  /**
114
165
  * Constructor options for the Bedrock adapter.
115
166
  *
@@ -130,11 +181,16 @@ export interface BedrockAdapterOptions {
130
181
  readonly region?: string;
131
182
  /**
132
183
  * Optional client factory override — used by tests to inject a
133
- * mock or stub `AnthropicBedrock` client without actually hitting
134
- * AWS. Production callers leave this unset; the adapter constructs
135
- * the real client lazily on first `complete(...)` call.
184
+ * mock or stub client without actually hitting AWS. Called with the
185
+ * endpoint the request's model id routed to (`'runtime'` →
186
+ * `AnthropicBedrock`, `'mantle'` → `AnthropicBedrockMantle`).
187
+ * Production callers leave this unset; the adapter constructs the
188
+ * real client lazily on first `complete(...)` call per endpoint.
136
189
  */
137
- readonly clientFactory?: (region: string) => AnthropicBedrock;
190
+ readonly clientFactory?: (
191
+ region: string,
192
+ endpoint: BedrockEndpoint,
193
+ ) => BedrockMessagesClient;
138
194
  }
139
195
 
140
196
  /**
@@ -150,13 +206,19 @@ export function createBedrockAdapter(
150
206
  ): ProviderAdapter {
151
207
  const region = options.region ?? process.env['AWS_REGION'] ?? 'us-east-1';
152
208
  const clientFactory =
153
- options.clientFactory ?? ((r: string) => new AnthropicBedrock({ awsRegion: r }));
209
+ options.clientFactory ??
210
+ ((r: string, endpoint: BedrockEndpoint): BedrockMessagesClient =>
211
+ endpoint === 'mantle'
212
+ ? new AnthropicBedrockMantle({ awsRegion: r })
213
+ : new AnthropicBedrock({ awsRegion: r }));
154
214
 
155
- let cachedClient: AnthropicBedrock | null = null;
156
- function getClient(): AnthropicBedrock {
157
- if (cachedClient) return cachedClient;
158
- cachedClient = clientFactory(region);
159
- return cachedClient;
215
+ const cachedClients: Partial<Record<BedrockEndpoint, BedrockMessagesClient>> = {};
216
+ function getClient(endpoint: BedrockEndpoint): BedrockMessagesClient {
217
+ const cached = cachedClients[endpoint];
218
+ if (cached) return cached;
219
+ const created = clientFactory(region, endpoint);
220
+ cachedClients[endpoint] = created;
221
+ return created;
160
222
  }
161
223
 
162
224
  function mapError(raw: unknown): ProviderError {
@@ -218,7 +280,7 @@ export function createBedrockAdapter(
218
280
  };
219
281
  }
220
282
 
221
- const client = getClient();
283
+ const client = getClient(bedrockEndpointFor(request.route.model));
222
284
  // The SDK's `Message` return type drifts between
223
285
  // `@anthropic-ai/sdk` versions (pnpm hoists multiple copies in
224
286
  // this workspace today). We type the captured value as
@@ -64,8 +64,8 @@ const SANDBOX_EXTERNALS = [
64
64
  '@ggui-ai/design/*',
65
65
  '@ggui-ai/wire',
66
66
  '@ggui-ai/wire/*',
67
- '@ggui-ai/react',
68
- '@ggui-ai/react/*',
67
+ '@ggui-ai/mcp-apps-react',
68
+ '@ggui-ai/mcp-apps-react/*',
69
69
  ];
70
70
 
71
71
  /** Max compiled bundle size (2MB). Prevents accidentally bundling huge deps. */