@khanglvm/llm-router 1.3.1 → 2.0.0-beta.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 (43) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +337 -41
  3. package/package.json +19 -3
  4. package/src/cli/router-module.js +7331 -3805
  5. package/src/cli/wrangler-toml.js +1 -1
  6. package/src/cli-entry.js +162 -24
  7. package/src/node/amp-client-config.js +426 -0
  8. package/src/node/coding-tool-config.js +763 -0
  9. package/src/node/config-store.js +49 -18
  10. package/src/node/instance-state.js +213 -12
  11. package/src/node/listen-port.js +5 -37
  12. package/src/node/local-server-settings.js +122 -0
  13. package/src/node/local-server.js +3 -2
  14. package/src/node/provider-probe.js +13 -0
  15. package/src/node/start-command.js +282 -40
  16. package/src/node/startup-manager.js +64 -29
  17. package/src/node/web-command.js +106 -0
  18. package/src/node/web-console-assets.js +26 -0
  19. package/src/node/web-console-client.js +56 -0
  20. package/src/node/web-console-dev-assets.js +258 -0
  21. package/src/node/web-console-server.js +3146 -0
  22. package/src/node/web-console-styles.generated.js +1 -0
  23. package/src/node/web-console-ui/config-editor-utils.js +616 -0
  24. package/src/node/web-console-ui/lib/utils.js +6 -0
  25. package/src/node/web-console-ui/rate-limit-utils.js +144 -0
  26. package/src/node/web-console-ui/select-search-utils.js +36 -0
  27. package/src/runtime/codex-request-transformer.js +46 -5
  28. package/src/runtime/codex-response-transformer.js +268 -35
  29. package/src/runtime/config.js +1394 -35
  30. package/src/runtime/handler/amp-gemini.js +913 -0
  31. package/src/runtime/handler/amp-response.js +308 -0
  32. package/src/runtime/handler/amp.js +290 -0
  33. package/src/runtime/handler/auth.js +17 -2
  34. package/src/runtime/handler/provider-call.js +168 -50
  35. package/src/runtime/handler/provider-translation.js +937 -26
  36. package/src/runtime/handler/request.js +149 -6
  37. package/src/runtime/handler/route-debug.js +22 -1
  38. package/src/runtime/handler.js +449 -9
  39. package/src/runtime/subscription-auth.js +1 -6
  40. package/src/shared/local-router-defaults.js +62 -0
  41. package/src/translator/index.js +3 -1
  42. package/src/translator/request/openai-to-claude.js +217 -6
  43. package/src/translator/response/openai-to-claude.js +206 -58
package/CHANGELOG.md CHANGED
@@ -5,6 +5,45 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [2.0.0-beta.0] - 2026-03-11
11
+
12
+ ### Beta
13
+ - Published this release as `2.0.0-beta.0` because it introduces large routing and operator-surface changes. Expect regressions while it is validated before the stable `2.0.0` release.
14
+
15
+ ### Added
16
+ - Added AMP CLI / AMP Code compatibility routes:
17
+ - `/api/provider/openai/v1/chat/completions`
18
+ - `/api/provider/openai/v1/completions`
19
+ - `/api/provider/openai/v1/responses`
20
+ - `/api/provider/anthropic/v1/messages`
21
+ - Added a local-only real-provider test suite for CLI, TUI, and web-console flows:
22
+ - isolated temp HOME/config/runtime-state handling so live tests do not mutate the developer's normal `~/.llm-router*` files
23
+ - real provider discovery/probe coverage through the web-console APIs
24
+ - browser-bundle render coverage for the web console via jsdom
25
+ - `npm run test:provider-live` (with `test:provider-smoke` kept as an alias)
26
+ - Added AMP-aware runtime config block with local bare-model matching and explicit model rewrites:
27
+ - `amp.upstreamUrl`
28
+ - `amp.upstreamApiKey`
29
+ - `amp.restrictManagementToLocalhost`
30
+ - `amp.forceModelMappings`
31
+ - `amp.modelMappings`
32
+ - Added AMP upstream proxy handling for management/auth routes and unresolved AMP provider requests.
33
+ - Added AMP Gemini/Google compatibility bridging for local `models`, `generateContent`, and `streamGenerateContent` routes.
34
+ - Added `llm-router config --operation=set-amp-config` AMP wizard for upstream/proxy settings, mode/model mappings, editable subagent definitions/mappings, and AMP client file patching.
35
+ - Added AMP subagent mapping support with local default-model fallback for unmapped specialized/system agents.
36
+ - Added editable `amp.subagentDefinitions` support so AMP agent ids/model-pattern bindings can be renamed, added, removed, cleared, or reset to built-in defaults without breaking local fallback routing.
37
+ - Added focused runtime tests covering AMP route parsing, local resolution, upstream fallback, Gemini translation, and `/openai/v1/responses` provider dispatch.
38
+ - Added reusable `npm run test:amp-smoke` local AMP E2E smoke suite that clones local config, starts a local handler server, runs headless AMP modes, and records router/CLI logs.
39
+
40
+ ### Changed
41
+ - Extended provider URL resolution so OpenAI-compatible providers can receive `/v1/completions` and `/v1/responses` requests instead of always forcing `/v1/chat/completions`.
42
+ - Updated README with AMP wizard flow, AMP client patching behavior/file locations, upstream key guidance via `https://ampcode.com/settings`, editable subagent definition flow, reset behavior, and local Gemini bridge behavior.
43
+
44
+ ### Fixed
45
+ - Fixed Codex CLI global-route patching to generate `model_catalog_json` metadata for direct managed route refs like `provider/model`, and to keep that catalog synced when managed route refs are renamed. This avoids Codex fallback metadata warnings for direct route bindings such as `rc/gpt-5.4`.
46
+
8
47
  ## [1.3.1] - 2026-03-05
9
48
 
10
49
  ### Changed
package/README.md CHANGED
@@ -1,19 +1,35 @@
1
1
  # llm-router
2
2
 
3
- `llm-router` exposes unified API endpoint for multiple AI providers and models.
4
-
5
- ## Main feature
3
+ ## Main Features
6
4
 
7
5
  1. Single endpoint, unified providers & models
8
6
  2. Support grouping models with rate-limit and load balancing strategy
9
7
  3. Configuration auto reload in real time, no interruption
10
8
 
9
+ ## Beta Notice
10
+
11
+ `2.0.0-beta.0` is the next public prerelease. It includes major AMP routing, web console, and local operator workflow changes, so treat it as beta and expect rough edges while validating it before a stable `2.0.0` release.
12
+
13
+ Short highlights in this beta:
14
+ - New localhost web console for config editing, provider testing, and router lifecycle control
15
+ - Quick patching for AMP Code, Codex CLI and Claude Code
16
+ - Expanded operator workflows across CLI, TUI, OAuth subscription setup, and live provider validation
17
+ - Fixed various format-transformation issues
18
+
11
19
  ## Install
12
20
 
21
+ Stable channel:
22
+
13
23
  ```bash
14
24
  npm i -g @khanglvm/llm-router@latest
15
25
  ```
16
26
 
27
+ Beta preview:
28
+
29
+ ```bash
30
+ npm i -g @khanglvm/llm-router@2.0.0-beta.0
31
+ ```
32
+
17
33
  ## Usage
18
34
 
19
35
  Copy/paste this short instruction to your AI agent:
@@ -22,6 +38,35 @@ Copy/paste this short instruction to your AI agent:
22
38
  Run `llm-router ai-help` first, then set up and operate llm-router for me using CLI commands.
23
39
  ```
24
40
 
41
+ ## Local Real-Provider Test Suite
42
+
43
+ The repo now includes a local-only live provider suite that covers all three operator surfaces:
44
+
45
+ - CLI config + `start`
46
+ - TUI config menus
47
+ - Web console provider discovery/test + browser bundle render
48
+
49
+ Setup:
50
+
51
+ ```bash
52
+ cp .env.test-suite.example .env.test-suite
53
+ # fill your own provider keys/endpoints/models in .env.test-suite
54
+ ```
55
+
56
+ Run it:
57
+
58
+ ```bash
59
+ npm run test:provider-live
60
+ # legacy alias:
61
+ npm run test:provider-smoke
62
+ ```
63
+
64
+ Notes:
65
+
66
+ - `.env.test-suite` is gitignored and is intended only for local runs.
67
+ - The live suite uses isolated temp HOME/config/runtime-state folders so it does not overwrite your normal `~/.llm-router.json` or `~/.llm-router.runtime.json`.
68
+ - Public contributors should keep using `.env.test-suite.example` as the template and fill their own providers locally.
69
+
25
70
  ## Main Workflow
26
71
 
27
72
  1. Add providers + models into llm-router (standard API-key providers or OAuth subscription providers)
@@ -68,7 +113,9 @@ Your app can use `opus` model and `llm-router` chooses target models based on yo
68
113
  Open the TUI:
69
114
 
70
115
  ```bash
71
- llm-router
116
+ llm-router --tui
117
+ # or
118
+ llm-router config --tui
72
119
  ```
73
120
 
74
121
  Then follow this order.
@@ -76,17 +123,18 @@ Then follow this order.
76
123
  ### 1) Add Provider
77
124
  Flow:
78
125
  1. `Config manager`
79
- 2. `Add/Edit provider`
80
- 3. Select provider auth mode:
81
- - `API Key` -> endpoint + API key + model list
126
+ 2. `Providers`
127
+ 3. `Add or edit`
128
+ 4. Choose auth method:
129
+ - `API key` -> endpoint + API key + model list
82
130
  - `OAuth` -> browser OAuth + editable model list
83
- 4. For `OAuth`:
131
+ 5. For `OAuth`:
84
132
  - Choose subscription provider (`ChatGPT` or `Claude Code`)
85
- - Enter Friendly Name and Provider ID
133
+ - Enter provider name and provider ID
86
134
  - Complete browser OAuth login inside this same flow
87
135
  - Edit model list (pre-filled defaults; you can add/remove)
88
136
  - llm-router live-tests every selected model before save
89
- 5. Save
137
+ 6. Save
90
138
 
91
139
  ### 1b) Add Subscription Provider (OAuth)
92
140
  Commandline examples:
@@ -119,62 +167,108 @@ Notes:
119
167
  ### 2) Configure Model Fallback (Optional)
120
168
  Flow:
121
169
  1. `Config manager`
122
- 2. `Set model silent-fallbacks`
123
- 3. Pick main model
124
- 4. Pick fallback models
125
- 5. Save
170
+ 2. `Routing`
171
+ 3. `Fallbacks`
172
+ 4. Pick main model
173
+ 5. Pick fallback models
174
+ 6. Save
126
175
 
127
176
  ### 3) Configure Rate Limits (Optional)
128
177
  Flow:
129
178
  1. `Config manager`
130
- 2. `Manage provider rate-limit buckets`
131
- 3. `Create bucket(s)`
132
- 4. Set name, model scope, request cap, time window
133
- 5. Save
179
+ 2. `Routing`
180
+ 3. `Rate limits`
181
+ 4. `Create`
182
+ 5. Set name, model scope, request cap, time window
183
+ 6. Save
134
184
 
135
185
  ### 4) Group Models With Alias (Recommended)
136
186
  Flow:
137
187
  1. `Config manager`
138
- 2. `Add/Edit model alias`
139
- 3. Set alias ID (example: `chat.default`)
140
- 4. Select target models
141
- 5. Save
188
+ 2. `Routing`
189
+ 3. `Aliases`
190
+ 4. Set alias ID (example: `chat.default`)
191
+ 5. Select target models
192
+ 6. Save
142
193
 
143
194
  ### 5) Configure Model Load Balancer
144
195
  Flow:
145
196
  1. `Config manager`
146
- 2. `Add/Edit model alias`
147
- 3. Open the alias you want to balance
148
- 4. Choose strategy (`auto` recommended)
149
- 5. Review alias targets
150
- 6. Save
197
+ 2. `Routing`
198
+ 3. `Aliases`
199
+ 4. Open the alias you want to balance
200
+ 5. Choose strategy (`auto` recommended)
201
+ 6. Review alias targets
202
+ 7. Save
151
203
 
152
204
  ### 6) Set Gateway Key
153
205
  Flow:
154
206
  1. `Config manager`
155
- 2. `Set worker master key`
156
- 3. Set or generate key
157
- 4. Save
207
+ 2. `Security`
208
+ 3. `Master key`
209
+ 4. Set or generate key
210
+ 5. Save
158
211
 
159
- ## Start Local Server
212
+ ## Setup using Web Console
213
+
214
+ Open the browser-based console:
160
215
 
161
216
  ```bash
162
- llm-router start
217
+ llm-router
218
+ # or
219
+ llm-router config
220
+ # explicit alias
221
+ llm-router web
163
222
  ```
164
223
 
165
- Custom port (optional):
224
+ Local contributor development workflow:
166
225
 
167
226
  ```bash
168
- llm-router start --port=3001
169
- # or
170
- LLM_ROUTER_PORT=3001 llm-router start
227
+ yarn dev
228
+ ```
229
+
230
+ What you get:
231
+ - Compact Claude-light localhost UI built with React, shadcn-style primitives, and Tailwind
232
+ - JSON-first config editor with live validation, external file sync, and a first-run quick-start wizard when no providers are configured
233
+ - Quick status cards for config health, managed router state, startup status, and recent activity
234
+ - Sections for:
235
+ - raw config editing with validate / prettify / save / open-in-editor actions
236
+ - provider inventory with per-provider probe actions
237
+ - OS startup enable / disable
238
+ - Start / restart / stop controls for the local router
239
+ - `Open Config File` buttons for detected editors like VS Code, Sublime, Cursor, TextEdit/default app, and other common local editors
240
+
241
+ Useful flags:
242
+
243
+ ```bash
244
+ llm-router web --port=9090
245
+ llm-router web --open=false
171
246
  ```
172
247
 
248
+ Notes:
249
+ - The web console is localhost-only by default because it exposes live config editing, including secrets.
250
+ - The web console runs as a separate service from the local router. Closing the UI does not stop the router service.
251
+ - `yarn dev` hot-reloads the browser UI and restarts the local router service when router source files change.
252
+ - If the config file contains invalid JSON, validation surfaces the parse error and save/probe/start actions stay guarded until the JSON is repaired.
253
+ - When the web console patches Codex CLI, it writes a generated `model_catalog_json` for both alias bindings and direct managed route refs like `provider/model`, which avoids Codex fallback metadata warnings for managed routes.
254
+
255
+ ## Start Local Server
256
+
257
+ ```bash
258
+ llm-router start
259
+ ```
260
+
261
+ The local router endpoint is fixed to `http://127.0.0.1:8376`.
262
+
173
263
  Local endpoints:
174
- - Unified: `http://127.0.0.1:<port>/route`
175
- - Anthropic-style: `http://127.0.0.1:<port>/anthropic`
176
- - OpenAI-style: `http://127.0.0.1:<port>/openai`
177
- - OpenAI Responses-style: `http://127.0.0.1:<port>/openai/v1/responses` (Codex CLI-compatible)
264
+ - Unified: `http://127.0.0.1:8376/route`
265
+ - Anthropic-style: `http://127.0.0.1:8376/anthropic`
266
+ - OpenAI-style: `http://127.0.0.1:8376/openai`
267
+ - OpenAI legacy completions: `http://127.0.0.1:8376/openai/v1/completions`
268
+ - OpenAI Responses-style: `http://127.0.0.1:8376/openai/v1/responses` (Codex CLI-compatible)
269
+ - AMP OpenAI-style: `http://127.0.0.1:8376/api/provider/openai/v1/chat/completions`
270
+ - AMP Anthropic-style: `http://127.0.0.1:8376/api/provider/anthropic/v1/messages`
271
+ - AMP OpenAI Responses-style: `http://127.0.0.1:8376/api/provider/openai/v1/responses`
178
272
 
179
273
  ## Connect your coding tool
180
274
 
@@ -185,7 +279,7 @@ Claude Code example (`~/.claude/settings.local.json`):
185
279
  ```json
186
280
  {
187
281
  "env": {
188
- "ANTHROPIC_BASE_URL": "http://127.0.0.1:8787",
282
+ "ANTHROPIC_BASE_URL": "http://127.0.0.1:8376",
189
283
  "ANTHROPIC_AUTH_TOKEN": "gw_your_gateway_key",
190
284
  "ANTHROPIC_DEFAULT_OPUS_MODEL": "provider_name/model_name_1",
191
285
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "provider_name/model_name_2",
@@ -194,6 +288,207 @@ Claude Code example (`~/.claude/settings.local.json`):
194
288
  }
195
289
  ```
196
290
 
291
+ ## AMP CLI / AMP Code
292
+
293
+ `llm-router` can now accept AMP provider-path requests and route them into your configured local models.
294
+
295
+ ### Quick AMP setup in the TUI
296
+
297
+ Recommended flow for non-expert users:
298
+
299
+ 1. Run `llm-router`
300
+ 2. Open `AMP`
301
+ 3. Choose `Quick setup`
302
+ 4. Pick where AMP should be patched:
303
+ - `This workspace` for only the current repo
304
+ - `All projects` for your global AMP config
305
+ 5. Confirm the local `llm-router` URL and API key
306
+ 6. Pick one default route such as `chat.default` or `provider/model`
307
+ 7. `Save and exit`
308
+
309
+ That is enough to make AMP send requests to `llm-router`.
310
+
311
+ After that, if you want AMP modes like `smart`, `rush`, `deep`, or `oracle` to use different llm-router aliases/models:
312
+
313
+ 1. Open `AMP`
314
+ 2. Choose `Common AMP routes`
315
+ 3. Pick the AMP route you want to customize
316
+ 4. Pick the llm-router alias/model to use
317
+ 5. Save
318
+
319
+ The `Advanced` menu is where the older, more detailed AMP controls now live:
320
+
321
+ - upstream / proxy settings
322
+ - legacy model-pattern mappings
323
+ - legacy subagent definitions and mappings
324
+
325
+ Recommended config snippet in `~/.llm-router.json`:
326
+
327
+ ```json
328
+ {
329
+ "masterKey": "gw_your_gateway_key",
330
+ "defaultModel": "chat.default",
331
+ "amp": {
332
+ "upstreamUrl": "https://ampcode.com",
333
+ "upstreamApiKey": "amp_upstream_api_key",
334
+ "restrictManagementToLocalhost": true,
335
+ "preset": "builtin",
336
+ "defaultRoute": "chat.default",
337
+ "routes": {
338
+ "smart": "chat.smart",
339
+ "rush": "chat.fast",
340
+ "deep": "chat.deep",
341
+ "oracle": "chat.oracle",
342
+ "librarian": "chat.research",
343
+ "review": "chat.review",
344
+ "@google-gemini-flash-shared": "chat.tools",
345
+ "painter": "image.default"
346
+ },
347
+ "rawModelRoutes": [
348
+ { "from": "gpt-*-codex*", "to": "chat.deep" }
349
+ ],
350
+ "overrides": {
351
+ "entities": [
352
+ {
353
+ "id": "reviewer",
354
+ "type": "feature",
355
+ "match": ["gemini-4-pro*"],
356
+ "route": "chat.review"
357
+ }
358
+ ]
359
+ },
360
+ "fallback": {
361
+ "onUnknown": "default-route",
362
+ "onAmbiguous": "default-route",
363
+ "proxyUpstream": true
364
+ }
365
+ }
366
+ }
367
+ ```
368
+
369
+ Notes:
370
+ - `amp` is the normalized config key. Input aliases `ampcode` and `amp-code` are also accepted.
371
+ - `amp.routes` is the new main user-facing mapping surface. Keys can be friendly AMP entities like `smart`, `rush`, `oracle`, `review`, `title`, or shared signatures like `@google-gemini-flash-shared`.
372
+ - `amp.defaultRoute` is AMP-specific fallback and is checked before the global `defaultModel`.
373
+ - `amp.rawModelRoutes` is the new-schema escape hatch for raw model-name matching when entity/signature routing is not enough.
374
+ - `amp.overrides` lets users add or update entity/signature detection without editing the built-in preset in code.
375
+ - `amp.preset=builtin` enables the shipped AMP catalog. Set `amp.preset=none` to disable built-in entity/signature detection entirely.
376
+ - Shared signatures exist because some AMP helpers currently share the same observed model family, such as `rush` + `title` on Haiku and `search` + `look-at` + `handoff` on Gemini Flash.
377
+ - AMP model matching now canonicalizes display-style names like `Claude Opus 4.6`, `GPT-5.3 Codex`, and `Gemini 3 Flash` before matching.
378
+ - Legacy AMP fields are still supported for backward compatibility: `amp.modelMappings`, `amp.subagentMappings`, `amp.subagentDefinitions`, and `amp.forceModelMappings`.
379
+ - When any new AMP schema fields are present (`preset`, `defaultRoute`, `routes`, `rawModelRoutes`, `overrides`, `fallback`), the new AMP resolver path is used. Otherwise legacy AMP routing behavior is preserved.
380
+ - Bare AMP model names like `gpt-4o-mini` are matched against configured local `model.id` and `model.aliases` automatically.
381
+ - If no local match is found and `amp.upstreamUrl` is set, `llm-router` proxies the request upstream to AMP.
382
+ - AMP management/auth routes (`/api/auth`, `/threads`, `/docs`, `/settings`, etc.) proxy through the configured AMP upstream and reuse your `masterKey` as the local gateway auth token.
383
+ - AMP Google `/api/provider/google/v1beta/...` requests are translated locally into OpenAI-compatible chat requests, including Gemini model listing, `generateContent`, and `streamGenerateContent`.
384
+ - `llm-router config --operation=set-amp-config` supports both the new AMP schema flags and the legacy AMP flags. The interactive wizard now leads with `Quick setup`, `Default AMP route`, and `Common AMP routes`, while the older mapping controls live under `Advanced`.
385
+ - If the AMP upstream API key is not found in local AMP config/secrets, the wizard tells you to open `https://ampcode.com/settings` and paste the key into `llm-router`.
386
+ - Developer notes and architecture details live in `docs/amp-routing.md`.
387
+
388
+ You can also configure the AMP block non-interactively:
389
+
390
+ ```bash
391
+ llm-router config --operation=set-amp-config \
392
+ --amp-upstream-url=https://ampcode.com \
393
+ --amp-upstream-api-key=amp_... \
394
+ --amp-default-route=chat.default \
395
+ --amp-routes="smart => chat.smart, rush => chat.fast, @google-gemini-flash-shared => chat.tools" \
396
+ --amp-raw-model-routes="gpt-*-codex* => chat.deep"
397
+ ```
398
+
399
+ Legacy-compatible CLI example:
400
+
401
+ ```bash
402
+ llm-router config --operation=set-amp-config \
403
+ --amp-force-model-mappings=true \
404
+ --amp-subagent-definitions="oracle => /^gpt-\d+(?:\.\d+)?$/, planner => gpt-6*" \
405
+ --amp-model-mappings="* => rc/gpt-5.3-codex" \
406
+ --amp-subagent-mappings="oracle => rc/gpt-5.3-codex, planner => rc/gpt-5.3-codex"
407
+ ```
408
+
409
+ To reset custom AMP subagent names/patterns back to the built-in defaults:
410
+
411
+ ```bash
412
+ llm-router config --operation=set-amp-config --reset-amp-subagent-definitions=true
413
+ ```
414
+
415
+ To patch AMP so it points at your local `llm-router` without editing AMP files manually:
416
+
417
+ ```bash
418
+ llm-router config --operation=set-amp-config \
419
+ --patch-amp-client-config=true \
420
+ --amp-client-settings-scope=workspace \
421
+ --amp-client-url=http://127.0.0.1:8376
422
+ ```
423
+
424
+ When you run the patch flow on a config that does not already have AMP routing configured, `llm-router` now bootstraps a safe default AMP setup automatically:
425
+
426
+ - patches AMP client `amp.url` + the local gateway API key entry
427
+ - sets `amp.preset=builtin`
428
+ - sets `amp.defaultRoute` to your current `defaultModel` (or the first configured provider/model)
429
+ - enables `amp.restrictManagementToLocalhost=true`
430
+ - auto-discovers `amp.upstreamApiKey` for `https://ampcode.com` from AMP secrets when available
431
+
432
+ That means a normal existing config with `defaultModel`, providers, and `masterKey` can usually patch AMP and start using a single default local model immediately.
433
+
434
+ Then customize AMP behavior later without re-patching the AMP client:
435
+
436
+ ```bash
437
+ llm-router config --operation=set-amp-config \
438
+ --amp-default-route=chat.default \
439
+ --amp-routes="smart => chat.smart, rush => chat.fast, deep => chat.deep, oracle => chat.oracle"
440
+ ```
441
+
442
+ AMP client file locations used by the wizard/patch flow:
443
+ - global settings: `~/.config/amp/settings.json`
444
+ - workspace settings: `.amp/settings.json`
445
+ - secrets: `~/.local/share/amp/secrets.json`
446
+
447
+ When patching AMP client files, `llm-router` only updates or adds:
448
+ - `amp.url` in `settings.json`
449
+ - `apiKey@<endpoint-url>` in `secrets.json`
450
+
451
+ All other existing AMP settings/secrets fields are preserved. Missing files/directories are created automatically.
452
+
453
+ Reusable local smoke test:
454
+
455
+ ```bash
456
+ npm run test:amp-smoke
457
+ ```
458
+
459
+ The smoke suite clones your current `~/.llm-router.json`, auto-discovers your AMP upstream key from local AMP secrets, forces all AMP traffic to `rc/gpt-5.3-codex`, runs headless AMP execute-mode checks (`smart`, `rush`, `deep`, plus an Oracle-style prompt), captures the raw inbound AMP `model` labels seen by `llm-router`, verifies each observed label still resolves through the current AMP matcher, and writes reusable logs/artifacts to a temp directory.
460
+
461
+ Key artifacts in the output directory:
462
+
463
+ - `router-log.jsonl`: full inbound + upstream request log
464
+ - `observed-models.json`: unique live AMP model labels grouped by case with resolver checks
465
+ - `summary.json`: top-level smoke results plus observed-model summary
466
+
467
+ Suggested AMP client setup:
468
+
469
+ `~/.config/amp/settings.json`
470
+
471
+ ```json
472
+ {
473
+ "amp.url": "http://127.0.0.1:8376"
474
+ }
475
+ ```
476
+
477
+ `~/.local/share/amp/secrets.json`
478
+
479
+ ```json
480
+ {
481
+ "apiKey@http://127.0.0.1:8376": "gw_your_gateway_key"
482
+ }
483
+ ```
484
+
485
+ Or use environment variables:
486
+
487
+ ```bash
488
+ export AMP_URL=http://127.0.0.1:8376
489
+ export AMP_API_KEY=gw_your_gateway_key
490
+ ```
491
+
197
492
  ## Real-Time Update Experience
198
493
 
199
494
  When local server is running:
@@ -237,3 +532,4 @@ See [`SECURITY.md`](https://github.com/khanglvm/llm-router/blob/master/SECURITY.
237
532
 
238
533
  - Semver: [Semantic Versioning](https://semver.org/)
239
534
  - Release notes: [`CHANGELOG.md`](https://github.com/khanglvm/llm-router/blob/master/CHANGELOG.md)
535
+ - Prereleases are published with explicit beta versions such as `2.0.0-beta.0`; pin them intentionally instead of treating them as stable upgrades.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanglvm/llm-router",
3
- "version": "1.3.1",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "Single gateway endpoint for multi-provider LLMs with unified OpenAI+Anthropic format and seamless fallback",
5
5
  "keywords": [
6
6
  "llm-router",
@@ -21,18 +21,34 @@
21
21
  "llm-router-route": "./src/cli-entry.js"
22
22
  },
23
23
  "scripts": {
24
- "dev": "wrangler dev",
24
+ "dev": "node ./scripts/dev.mjs",
25
+ "dev:worker": "wrangler dev",
25
26
  "deploy": "wrangler deploy",
26
27
  "tail": "wrangler tail",
28
+ "build:web-console": "node ./scripts/build-web-console.mjs",
27
29
  "start": "node ./src/cli-entry.js start",
28
30
  "config": "node ./src/cli-entry.js config",
29
31
  "deploy:worker": "node ./src/cli-entry.js deploy",
30
- "test:provider-smoke": "node ./scripts/provider-smoke-suite.mjs"
32
+ "test:provider-live": "node --test --test-concurrency=1 ./test/live-provider-suite.test.js",
33
+ "test:provider-smoke": "npm run test:provider-live",
34
+ "test:amp-smoke": "node ./scripts/amp-smoke-suite.mjs"
31
35
  },
32
36
  "dependencies": {
33
37
  "@levu/snap": "^0.3.13"
34
38
  },
35
39
  "devDependencies": {
40
+ "@radix-ui/react-select": "^2.2.6",
41
+ "@radix-ui/react-switch": "^1.2.6",
42
+ "@radix-ui/react-tabs": "^1.1.13",
43
+ "@tailwindcss/cli": "^4.2.1",
44
+ "class-variance-authority": "^0.7.1",
45
+ "clsx": "^2.1.1",
46
+ "esbuild": "^0.27.3",
47
+ "jsdom": "^28.1.0",
48
+ "react": "^19.2.4",
49
+ "react-dom": "^19.2.4",
50
+ "tailwind-merge": "^3.5.0",
51
+ "tailwindcss": "^4.2.1",
36
52
  "wrangler": "^4.68.1"
37
53
  },
38
54
  "publishConfig": {