@certalis/agent-smith 0.1.18 → 0.2.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/README.md CHANGED
@@ -18,21 +18,24 @@
18
18
  Claude Code and Codex keep talking their own protocol. agent-smith sits between
19
19
  them and the provider: it chooses a provider from the pool you configure, then
20
20
  an account inside that provider, watches the quota each provider reports, and
21
- fails over when one cannot serve.
21
+ may try another account from that same provider. It never silently moves a
22
+ request to another provider.
22
23
 
23
24
  ## How it works
24
25
 
25
26
  - **A pool of providers per client protocol.** Claude Code speaks
26
27
  `anthropic-messages`; Codex speaks `openai-responses`. Each protocol gets an
27
28
  ordered list of providers.
28
- - **Each provider is a built-in strategy** (`anthropic-api`, `openai-api`,
29
- `claude-code`, `codex`). It knows how to authenticate, how to read its quota
30
- signals, and how to choose between its own accounts.
29
+ - **Each provider is a built-in strategy** (`anthropic-api`,
30
+ `model-studio-anthropic-api`, `kimi-code-anthropic-api`,
31
+ `google-gemini-api`, `openai-api`, `claude-code`, `codex`). It knows how to authenticate,
32
+ how to read its quota signals, and how to choose between its own accounts.
31
33
  - **Each provider holds its accounts**: API keys, or subscription sign-ins once
32
34
  you enable them.
33
35
 
34
- Nothing is translated between protocols: a provider only serves clients that
35
- speak its protocol.
36
+ The default is no cross-protocol translation. `google-gemini-api` is the first
37
+ explicit adapter: it accepts the canonical Anthropic Messages client wire and
38
+ converts supported requests/responses at the selected Google provider edge.
36
39
 
37
40
  ## Install
38
41
 
@@ -67,8 +70,12 @@ startServer({
67
70
 
68
71
  ```json
69
72
  {
70
- "provider_pools": {
71
- "anthropic-messages": ["anthropic"]
73
+ "routing": {
74
+ "routes": {
75
+ "anthropic-messages": [
76
+ "anthropic"
77
+ ]
78
+ }
72
79
  }
73
80
  }
74
81
  ```
@@ -96,7 +103,9 @@ key; provider tokens and the single database stay on the server.
96
103
  Device keys allow independent revocation and cannot read management data. A
97
104
  server-side policy may give a registered device name a lower weekly seat ceiling
98
105
  than the default; this filters account eligibility only and does not create a
99
- per-client budget or usage meter.
106
+ per-client budget or usage meter. The owner can also grant a named unattended
107
+ device forward-only provider fallback; every other caller still stays on its
108
+ selected provider.
100
109
 
101
110
  Seat owners join through the server's optional `/pool-enroll` page, not its
102
111
  proxy homepage. Allow individual addresses or an exact domain (`*@example.test`)
@@ -154,25 +163,27 @@ The config file is JSON, read at startup from:
154
163
  on macOS and Linux,
155
164
  - or the path in `AGENT_SMITH_CONFIG_PATH`.
156
165
 
157
- Restart agent-smith after changing `providers`, `provider_pools`, `alerts` or
158
- `block_when_all_full`.
166
+ Pool and Router management API updates apply live. Restart after hand-editing the configuration file.
167
+ On first start, Agent Smith automatically rewrites supported old configs and
168
+ keeps a private `<config-path>.backup` (or a timestamped backup if one already
169
+ differs). See the [migration and rollback guide](docs/configuration.md#migration-and-rollback).
159
170
 
160
171
  | Key | What it does |
161
172
  |---|---|
162
173
  | `providers.<name>.enabled` | Turns a provider's routes on or off. By default `anthropic` and `openai` are on, and `claude-code` and `codex` are off. |
163
- | `providers.<name>.strategy` | The built-in strategy: `anthropic-api`, `openai-api`, `claude-code` or `codex`. Required for a provider name you add yourself. |
174
+ | `providers.<name>.strategy` | The built-in strategy: `anthropic-api`, `model-studio-anthropic-api`, `kimi-code-anthropic-api`, `google-gemini-api`, `openai-api`, `claude-code` or `codex`. Required for a provider name you add yourself. |
164
175
  | `providers.<name>.base_url` | The upstream URL, for an endpoint compatible with one of the strategies. |
165
176
  | `providers.<name>.models` | The models a provider serves, as `"client model": "provider model"`. A trailing `*` matches a prefix. Without it, the provider serves every model name unchanged. |
166
- | `provider_pools.<protocol>` | The ordered providers for `anthropic-messages` or `openai-responses`. Clients reach it at `/v1/pool/<protocol>/*`, and the local wrappers use it automatically. |
177
+ | `routing.routes.<protocol>` | The ordered providers for `anthropic-messages` or `openai-responses`. Clients reach it at `/v1/pool/<protocol>/*`, and the local wrappers use it automatically. |
167
178
  | `client` | This machine's shared-pool switch, origin and forwarding-key file. Use `agent-smith client on`, `off` or `status`; it does not define providers or a separate pool. |
168
- | `team_routing` | Which subscription accounts may share a pool, and their usage caps. See the [configuration guide](docs/configuration.md#team-routing). |
179
+ | `providers.<name>.pool` | Membership, usage caps and admission for that provider’s subscription pool. See the [configuration guide](docs/configuration.md#provider-pools). |
169
180
  | `alerts` | A Slack webhook or bot token and/or an email address that hear when a seat spends extra usage and when every account is full. A filled value turns its channel on. See [Alerts](docs/configuration.md#alerts). |
170
- | `block_when_all_full` | `true` by default: when every account is full, every request is refused until the soonest reset, so none spends extra usage. |
181
+ | `providers.<name>.pool.block_when_all_full` | `true` by default: when every account is full, every request is refused until the soonest reset, so none spends extra usage. |
171
182
 
172
- To use capacity before renewal, enable `team_routing.prefer_expiring_quota`:
183
+ To use capacity before renewal, enable `providers.<name>.pool.prefer_expiring_quota`:
173
184
  new pinned chats may favor a fresh quota window close to its reset. Existing
174
185
  chats and hard caps stay unchanged; this option is off by default. See
175
- [load balancing](docs/load-balancing.md#team-routing-opt-in).
186
+ [load balancing](docs/load-balancing.md#provider-pools-opt-in).
176
187
 
177
188
  For direct Codex subscription accounts, the private dashboard's **Accounts →
178
189
  Usage resets** lists available reset grants and their expiration. Using one
@@ -192,8 +203,12 @@ Each example is a complete config file, also in [`examples/config/`](examples/co
192
203
 
193
204
  ```json
194
205
  {
195
- "provider_pools": {
196
- "anthropic-messages": ["anthropic"]
206
+ "routing": {
207
+ "routes": {
208
+ "anthropic-messages": [
209
+ "anthropic"
210
+ ]
211
+ }
197
212
  }
198
213
  }
199
214
  ```
@@ -203,16 +218,47 @@ Each example is a complete config file, also in [`examples/config/`](examples/co
203
218
 
204
219
  ```json
205
220
  {
206
- "provider_pools": {
207
- "openai-responses": ["openai"]
221
+ "routing": {
222
+ "routes": {
223
+ "openai-responses": [
224
+ "openai"
225
+ ]
226
+ }
227
+ }
228
+ }
229
+ ```
230
+
231
+ **Claude-compatible Gemini Developer API**
232
+ ([`google-gemini-anthropic-messages.json`](examples/config/google-gemini-anthropic-messages.json)).
233
+ The configured client model maps to Gemini's native model name; add a Gemini
234
+ Developer API key to the `gemini` account after starting Agent Smith.
235
+
236
+ ```json
237
+ {
238
+ "providers": {
239
+ "gemini": {
240
+ "strategy": "google-gemini-api",
241
+ "models": {
242
+ "claude-sonnet-*": "gemini-2.5-flash"
243
+ }
244
+ }
245
+ },
246
+ "routing": {
247
+ "routes": {
248
+ "anthropic-messages": [
249
+ "gemini"
250
+ ]
251
+ }
208
252
  }
209
253
  }
210
254
  ```
211
255
 
212
256
  **An Anthropic-compatible endpoint as fallback**
213
257
  ([`compatible-endpoint-fallback.json`](examples/config/compatible-endpoint-fallback.json)).
214
- Requests go to Anthropic first. When Anthropic cannot serve, Sonnet requests move
215
- to `acme` and are sent as `acme-large`. `acme` serves no other model.
258
+ Requests go to Anthropic first. A wrapped Claude Code session can choose `acme`
259
+ after Anthropic reports a capacity block; that choice sends Sonnet as
260
+ `acme-large`. Unattended callers receive Anthropic's capacity response and are
261
+ never moved to `acme` automatically. `acme` serves no other model.
216
262
 
217
263
  ```json
218
264
  {
@@ -221,11 +267,18 @@ to `acme` and are sent as `acme-large`. `acme` serves no other model.
221
267
  "enabled": true,
222
268
  "strategy": "anthropic-api",
223
269
  "base_url": "https://api.acme.example",
224
- "models": { "claude-sonnet-*": "acme-large" }
270
+ "models": {
271
+ "claude-sonnet-*": "acme-large"
272
+ }
225
273
  }
226
274
  },
227
- "provider_pools": {
228
- "anthropic-messages": ["anthropic", "acme"]
275
+ "routing": {
276
+ "routes": {
277
+ "anthropic-messages": [
278
+ "anthropic",
279
+ "acme"
280
+ ]
281
+ }
229
282
  }
230
283
  }
231
284
  ```
@@ -265,16 +318,17 @@ share that organisation's limits, so adding them adds no capacity.
265
318
 
266
319
  - **Inside a provider**, an account at its quota threshold is skipped. A
267
320
  server error before any output may take one hop to another eligible account.
268
- - **Across providers**, a pool moves to its next provider only when the current
269
- one has no eligible account, or has no eligible account left for that one
270
- server-error hop. It moves at most once per request.
321
+ - **Across providers**, an ordinary request never moves automatically. A person
322
+ in a wrapped Claude Code session must choose a provider, or a named unattended
323
+ device must have the private ordered-fallback policy. A change loses the
324
+ prompt cache and can change model behaviour and cost.
271
325
  - A per-minute rate limit never moves a request to another provider, and
272
326
  nothing moves once output has started reaching the client.
273
327
  - A conversation stays on its account while that account is eligible. Moving
274
328
  provider loses the prompt cache and can change model behaviour and cost.
275
329
  - If no provider in the pool serves the requested model, agent-smith returns
276
- `400` naming `provider_pools.<protocol>`.
277
- - Direct routes, `/v1/<provider>/*`, never use a pool.
330
+ `400`; its current error text refers to `provider_pools.<protocol>`.
331
+ - Direct routes, `/v1/<provider>/*`, do not traverse the ordered provider route; the selected provider’s seat pool still applies.
278
332
 
279
333
  Details: [load balancing](docs/load-balancing.md).
280
334
 
@@ -376,7 +430,7 @@ and [Usage Policy](https://www.anthropic.com/legal/aup), and OpenAI's
376
430
  ```
377
431
 
378
432
  Both examples enable a single sign-in. Putting several sign-ins in one pool
379
- with `team_routing.allowlisted_account_uuids` is the use the quoted terms most
433
+ with `providers.<name>.pool.members` is the use the quoted terms most
380
434
  clearly forbid.
381
435
 
382
436
  ## Advanced use