@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.
- package/dist/adapters/generation-dispatch.d.ts +10 -0
- package/dist/adapters/generation-dispatch.js +172 -1392
- package/dist/adapters/generation-dispatch.js.map +1 -1
- package/dist/advanced/index.d.ts +1 -1
- package/dist/advanced/index.js +191 -1403
- package/dist/advanced/index.js.map +1 -1
- package/dist/boilerplate.js +3 -2
- package/dist/boilerplate.js.map +1 -1
- package/dist/compose.js +5 -5
- package/dist/compose.js.map +1 -1
- package/dist/{create-ui-generator-GX7tvbyH.d.ts → create-ui-generator-B9kV4U9h.d.ts} +13 -0
- package/dist/evaluation/axis-checks/index.js +32 -1
- package/dist/evaluation/axis-checks/index.js.map +1 -1
- package/dist/evaluation/axis-checks/registry.js +32 -1
- package/dist/evaluation/axis-checks/registry.js.map +1 -1
- package/dist/evaluation/index.js +57 -12
- package/dist/evaluation/index.js.map +1 -1
- package/dist/fragments/index.js +5 -5
- package/dist/fragments/index.js.map +1 -1
- package/dist/harness/index.d.ts +4 -125
- package/dist/harness/index.js +34 -19
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/runtime.d.ts +9 -0
- package/dist/harness/runtime.js +3 -2
- package/dist/harness/runtime.js.map +1 -1
- package/dist/harness/types-public.js +8 -7
- package/dist/harness/types-public.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +191 -1403
- package/dist/index.js.map +1 -1
- package/dist/llm-router-1TyI0_TV.d.ts +156 -0
- package/dist/providers/index.d.ts +35 -93
- package/dist/providers/index.js +13 -8
- package/dist/providers/index.js.map +1 -1
- package/dist/validation/index.js +2 -2
- package/dist/validation/index.js.map +1 -1
- package/package.json +18 -18
- package/src/adapters/generation-dispatch.ts +19 -2
- package/src/boilerplate/system-prompt.ts +3 -2
- package/src/create-ui-generator.ts +44 -11
- package/src/evaluation/axis-checks/checks/state-merge.ts +1 -1
- package/src/evaluation/axis-checks/checks/universal.ts +39 -0
- package/src/evaluation/llm-evaluator.ts +13 -3
- package/src/evaluation/visual-evaluator.ts +5 -1
- package/src/fragments/realtime.ts +3 -3
- package/src/fragments/state.ts +2 -2
- package/src/harness/coding/init-session.ts +4 -1
- package/src/harness/coding/run-eval-round.ts +6 -0
- package/src/harness/llm-router.ts +59 -14
- package/src/harness/runtime.ts +8 -0
- package/src/providers/bedrock.ts +84 -22
- package/src/validation/ui-compiler.ts +2 -2
package/src/providers/bedrock.ts
CHANGED
|
@@ -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
|
|
56
|
-
* model
|
|
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
|
-
* -
|
|
59
|
-
*
|
|
60
|
-
*
|
|
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
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
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
|
|
134
|
-
*
|
|
135
|
-
*
|
|
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?: (
|
|
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 ??
|
|
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
|
-
|
|
156
|
-
function getClient():
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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. */
|