@certalis/agent-smith 0.0.0-stage → 0.1.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/LICENSE +22 -0
- package/README.md +323 -2
- package/dist/bin.js +17484 -0
- package/dist/dashboard/chunk-h03pp3xg.js +111 -0
- package/dist/dashboard/chunk-h03pp3xg.js.map +671 -0
- package/dist/dashboard/chunk-r6qvhv5e.css +1 -0
- package/dist/dashboard/favicon-7fef0tsq.svg +10 -0
- package/dist/dashboard/index.html +39 -0
- package/dist/dashboard/manifest.json +7 -0
- package/dist/post-processor.worker.js +4945 -0
- package/package.json +63 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 snipeship
|
|
4
|
+
Copyright (c) 2026 Certalis
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,324 @@
|
|
|
1
|
-
#
|
|
1
|
+
# agent-smith
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A proof-of-concept local proxy and provider pool for Claude Code and Codex.**
|
|
4
|
+
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> **This is a proof of concept for ideation, not a product.** It exists to
|
|
7
|
+
> explore an idea and start conversations.
|
|
8
|
+
>
|
|
9
|
+
> - **No warranty, no support, no stability.** It may change or disappear at any
|
|
10
|
+
> time.
|
|
11
|
+
> - **Subscription sign-ins are off by default.** Anthropic's and OpenAI's terms
|
|
12
|
+
> restrict using Claude or ChatGPT plan credentials through a tool like this:
|
|
13
|
+
> read [Subscription sign-ins and provider terms](#subscription-sign-ins-and-provider-terms)
|
|
14
|
+
> before enabling one. You alone are responsible for complying with your
|
|
15
|
+
> providers' terms.
|
|
16
|
+
> - Not affiliated with, endorsed by or sponsored by Anthropic or OpenAI.
|
|
17
|
+
|
|
18
|
+
Claude Code and Codex keep talking their own protocol. agent-smith sits on
|
|
19
|
+
localhost between them and the provider: it chooses a provider from the pool you
|
|
20
|
+
configure, then an account inside that provider, watches the quota each
|
|
21
|
+
provider reports, and fails over when one cannot serve.
|
|
22
|
+
|
|
23
|
+
## How it works
|
|
24
|
+
|
|
25
|
+
- **A pool of providers per client protocol.** Claude Code speaks
|
|
26
|
+
`anthropic-messages`; Codex speaks `openai-responses`. Each protocol gets an
|
|
27
|
+
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.
|
|
31
|
+
- **Each provider holds its accounts**: API keys, or subscription sign-ins once
|
|
32
|
+
you enable them.
|
|
33
|
+
|
|
34
|
+
Nothing is translated between protocols: a provider only serves clients that
|
|
35
|
+
speak its protocol.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
You need [Bun](https://bun.sh) 1.2.8 or newer on your `PATH` and a macOS or Linux
|
|
40
|
+
shell.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bun add -g @certalis/agent-smith # or: npm install -g @certalis/agent-smith
|
|
44
|
+
agent-smith
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or run it once without installing: `bunx @certalis/agent-smith`. To work from
|
|
48
|
+
source, clone this repository, then run `bun install && bun run ccflare`.
|
|
49
|
+
|
|
50
|
+
## Quick start: Claude Code with an Anthropic API key
|
|
51
|
+
|
|
52
|
+
1. Create the config file (see [Configuration](#configuration)) with a pool for
|
|
53
|
+
Claude Code's protocol:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"provider_pools": {
|
|
58
|
+
"anthropic-messages": ["anthropic"]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
2. Run `agent-smith`. The terminal screen, **Local Pool**, opens; keep it
|
|
64
|
+
running while you use the pool.
|
|
65
|
+
3. Press `a`, name the account, and add your Anthropic API key. From a script:
|
|
66
|
+
`agent-smith --add-account work --provider anthropic`.
|
|
67
|
+
4. Press `e` and confirm **Enable local client routing**. agent-smith writes small
|
|
68
|
+
wrappers in its own config directory and adds one marked `PATH` entry to your
|
|
69
|
+
shell profile; your real `claude` and `codex` programs are untouched.
|
|
70
|
+
5. Open a **new terminal** and run `claude` as usual. Press `e` again to remove
|
|
71
|
+
the wrappers and the `PATH` entry.
|
|
72
|
+
|
|
73
|
+
Codex works the same way with an OpenAI API key and an `openai-responses` pool.
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
The config file is JSON, read at startup from:
|
|
78
|
+
|
|
79
|
+
- `~/.config/ccflare/ccflare.json` (or `$XDG_CONFIG_HOME/ccflare/ccflare.json`)
|
|
80
|
+
on macOS and Linux,
|
|
81
|
+
- or the path in `ccflare_CONFIG_PATH`.
|
|
82
|
+
|
|
83
|
+
Restart agent-smith after changing `providers` or `provider_pools`.
|
|
84
|
+
|
|
85
|
+
| Key | What it does |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `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. |
|
|
88
|
+
| `providers.<name>.strategy` | The built-in strategy: `anthropic-api`, `openai-api`, `claude-code` or `codex`. Required for a provider name you add yourself. |
|
|
89
|
+
| `providers.<name>.base_url` | The upstream URL, for an endpoint compatible with one of the strategies. |
|
|
90
|
+
| `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. |
|
|
91
|
+
| `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. |
|
|
92
|
+
| `team_routing` | Which subscription accounts may share a pool, and their usage caps. See the [configuration guide](docs/configuration.md#team-routing). |
|
|
93
|
+
|
|
94
|
+
Every key, the environment variables and the HTTP API are in the
|
|
95
|
+
[configuration guide](docs/configuration.md).
|
|
96
|
+
|
|
97
|
+
### Examples
|
|
98
|
+
|
|
99
|
+
Each example is a complete config file, also in [`examples/config/`](examples/config/).
|
|
100
|
+
|
|
101
|
+
**Claude Code with an Anthropic API key**
|
|
102
|
+
([`anthropic-api-key.json`](examples/config/anthropic-api-key.json)):
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"provider_pools": {
|
|
107
|
+
"anthropic-messages": ["anthropic"]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Codex with an OpenAI API key**
|
|
113
|
+
([`openai-api-key.json`](examples/config/openai-api-key.json)):
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"provider_pools": {
|
|
118
|
+
"openai-responses": ["openai"]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**An Anthropic-compatible endpoint as fallback**
|
|
124
|
+
([`compatible-endpoint-fallback.json`](examples/config/compatible-endpoint-fallback.json)).
|
|
125
|
+
Requests go to Anthropic first. When Anthropic cannot serve, Sonnet requests move
|
|
126
|
+
to `acme` and are sent as `acme-large`. `acme` serves no other model.
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"providers": {
|
|
131
|
+
"acme": {
|
|
132
|
+
"enabled": true,
|
|
133
|
+
"strategy": "anthropic-api",
|
|
134
|
+
"base_url": "https://api.acme.example",
|
|
135
|
+
"models": { "claude-sonnet-*": "acme-large" }
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"provider_pools": {
|
|
139
|
+
"anthropic-messages": ["anthropic", "acme"]
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The Claude Code and Codex subscription examples are in
|
|
145
|
+
[Subscription sign-ins and provider terms](#subscription-sign-ins-and-provider-terms).
|
|
146
|
+
|
|
147
|
+
## How usage is watched
|
|
148
|
+
|
|
149
|
+
Each provider reads its own quota signals from the responses it gets:
|
|
150
|
+
|
|
151
|
+
- **Subscription providers** read the 5-hour and weekly windows.
|
|
152
|
+
- **API-key providers** read the provider's rate-limit headers and its 429
|
|
153
|
+
answers.
|
|
154
|
+
|
|
155
|
+
The Local Pool screen and the dashboard show the latest values. A new account
|
|
156
|
+
shows `limits not observed yet` until a response carries quota headers;
|
|
157
|
+
agent-smith never invents a zero limit. Several API keys from one organisation
|
|
158
|
+
share that organisation's limits, so adding them adds no capacity.
|
|
159
|
+
|
|
160
|
+
## How failover works
|
|
161
|
+
|
|
162
|
+
- **Inside a provider**, an account at its quota threshold is skipped. A
|
|
163
|
+
server error before any output may take one hop to another eligible account.
|
|
164
|
+
- **Across providers**, a pool moves to its next provider only when the current
|
|
165
|
+
one has no eligible account, or has no eligible account left for that one
|
|
166
|
+
server-error hop. It moves at most once per request.
|
|
167
|
+
- A per-minute rate limit never moves a request to another provider, and
|
|
168
|
+
nothing moves once output has started reaching the client.
|
|
169
|
+
- A conversation stays on its account while that account is eligible. Moving
|
|
170
|
+
provider loses the prompt cache and can change model behaviour and cost.
|
|
171
|
+
- If no provider in the pool serves the requested model, agent-smith returns
|
|
172
|
+
`400` naming `provider_pools.<protocol>`.
|
|
173
|
+
- Direct routes, `/v1/<provider>/*`, never use a pool.
|
|
174
|
+
|
|
175
|
+
Details: [load balancing](docs/load-balancing.md).
|
|
176
|
+
|
|
177
|
+
## Subscription sign-ins and provider terms
|
|
178
|
+
|
|
179
|
+
> [!CAUTION]
|
|
180
|
+
> `claude-code` signs in to a Claude subscription and `codex` signs in to a
|
|
181
|
+
> ChatGPT account. agent-smith then **stores the resulting tokens and routes
|
|
182
|
+
> requests through them**. Both are **disabled by default**. The provider terms
|
|
183
|
+
> below restrict this use. agent-smith makes **no claim that it is allowed**,
|
|
184
|
+
> and the two configs further down are **examples only**, not recommendations.
|
|
185
|
+
> If you enable either sign-in, that is your decision and your responsibility.
|
|
186
|
+
|
|
187
|
+
These are quoted word for word, as read on **30–31 October 2026**. Check the
|
|
188
|
+
current versions before acting on them.
|
|
189
|
+
|
|
190
|
+
**Anthropic, [Claude Code legal and compliance](https://code.claude.com/docs/en/legal-and-compliance),
|
|
191
|
+
"Authentication and credential use":**
|
|
192
|
+
|
|
193
|
+
> OAuth authentication is intended exclusively for purchasers of Claude Free,
|
|
194
|
+
> Pro, Max, Ultra, Team, and Enterprise subscription plans and is designed to
|
|
195
|
+
> support ordinary use of Claude Code and other native Anthropic applications.
|
|
196
|
+
|
|
197
|
+
> Anthropic does not permit third-party developers to offer Claude.ai login into
|
|
198
|
+
> their own applications, or to route requests through Free, Pro, Max, or Ultra
|
|
199
|
+
> plan credentials on behalf of their users. Moreover, developers may not
|
|
200
|
+
> collect, store, or intermediate Claude.ai credentials or session tokens —
|
|
201
|
+
> sign-in to a Claude account must complete through Anthropic’s own flow.
|
|
202
|
+
|
|
203
|
+
> Anthropic reserves the right to take measures to enforce these restrictions
|
|
204
|
+
> and may do so without prior notice.
|
|
205
|
+
|
|
206
|
+
**Anthropic, [Consumer Terms of Service](https://www.anthropic.com/legal/consumer-terms)
|
|
207
|
+
(effective 8 October 2025):**
|
|
208
|
+
|
|
209
|
+
> You may not share your Account login information, Anthropic API key, or
|
|
210
|
+
> Account credentials with anyone else or make your Account available to anyone
|
|
211
|
+
> else.
|
|
212
|
+
|
|
213
|
+
> You may not access or use, or help another person to access or use, our
|
|
214
|
+
> Services in the following ways: […] Except when you are accessing our
|
|
215
|
+
> Services via an Anthropic API Key or where we otherwise explicitly permit it,
|
|
216
|
+
> to access the Services through automated or non-human means, whether through a
|
|
217
|
+
> bot, script, or otherwise.
|
|
218
|
+
|
|
219
|
+
**OpenAI, [Terms of Use](https://openai.com/policies/terms-of-use/)
|
|
220
|
+
(effective 1 January 2026):**
|
|
221
|
+
|
|
222
|
+
> You may not share your account credentials or make your account available to
|
|
223
|
+
> anyone else and are responsible for all activities that occur under your
|
|
224
|
+
> account.
|
|
225
|
+
|
|
226
|
+
> What you cannot do. You may not use our Services for any illegal, harmful, or
|
|
227
|
+
> abusive activity. For example, you may not: […] Automatically or
|
|
228
|
+
> programmatically extract data or Output (defined below). […] Interfere with or
|
|
229
|
+
> disrupt our Services, including circumvent any rate limits or restrictions or
|
|
230
|
+
> bypass any protective measures or safety mitigations we put on our Services.
|
|
231
|
+
|
|
232
|
+
API keys are covered by each provider's business terms and usage policies:
|
|
233
|
+
Anthropic's [Commercial Terms](https://www.anthropic.com/legal/commercial-terms)
|
|
234
|
+
and [Usage Policy](https://www.anthropic.com/legal/aup), and OpenAI's
|
|
235
|
+
[Services Agreement](https://openai.com/policies/services-agreement/) and
|
|
236
|
+
[Usage Policies](https://openai.com/policies/usage-policies/).
|
|
237
|
+
|
|
238
|
+
### Example only: Claude Code subscription
|
|
239
|
+
|
|
240
|
+
> [!WARNING]
|
|
241
|
+
> **Example only.** This config shows the shape of the setting and nothing more.
|
|
242
|
+
> Anthropic's terms quoted above do not permit third-party tools to store or
|
|
243
|
+
> route requests through Claude plan credentials. Do not use it unless you have
|
|
244
|
+
> read those terms and accept the consequences.
|
|
245
|
+
|
|
246
|
+
[`example-only-claude-code-subscription.json`](examples/config/example-only-claude-code-subscription.json):
|
|
247
|
+
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"providers": {
|
|
251
|
+
"claude-code": { "enabled": true }
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Example only: Codex subscription
|
|
257
|
+
|
|
258
|
+
> [!WARNING]
|
|
259
|
+
> **Example only.** This config shows the shape of the setting and nothing more.
|
|
260
|
+
> OpenAI's terms quoted above forbid making an account available to anyone else
|
|
261
|
+
> and circumventing rate limits. Do not use it unless you have read those terms
|
|
262
|
+
> and accept the consequences.
|
|
263
|
+
|
|
264
|
+
[`example-only-codex-subscription.json`](examples/config/example-only-codex-subscription.json):
|
|
265
|
+
|
|
266
|
+
```json
|
|
267
|
+
{
|
|
268
|
+
"providers": {
|
|
269
|
+
"codex": { "enabled": true }
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Both examples enable a single sign-in. Putting several sign-ins in one pool
|
|
275
|
+
with `team_routing.allowlisted_account_uuids` is the use the quoted terms most
|
|
276
|
+
clearly forbid.
|
|
277
|
+
|
|
278
|
+
## Advanced use
|
|
279
|
+
|
|
280
|
+
The server also exposes the routes directly:
|
|
281
|
+
|
|
282
|
+
- `http://localhost:8080/v1/<provider>/*`: one enabled provider, no pool.
|
|
283
|
+
- `http://localhost:8080/v1/pool/<protocol>/*`: a configured pool.
|
|
284
|
+
|
|
285
|
+
Run only the server with `agent-smith --serve`. Management writes need an
|
|
286
|
+
explicit `CF_ADMIN_KEY` sent as the `x-api-key` header. Read the
|
|
287
|
+
[configuration guide](docs/configuration.md) and the
|
|
288
|
+
[HTTP API reference](docs/api-http.md) before exposing anything beyond
|
|
289
|
+
localhost.
|
|
290
|
+
|
|
291
|
+
## Development
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
bun install
|
|
295
|
+
bun run tui # Start the terminal screen from source
|
|
296
|
+
bun run server # Start only the local proxy and dashboard
|
|
297
|
+
bun run verify # Run tests, type checks, and linting
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
More detail lives in [docs/](docs/): [architecture](docs/architecture.md),
|
|
301
|
+
[configuration](docs/configuration.md), [provider behaviour](docs/providers.md)
|
|
302
|
+
and [load balancing](docs/load-balancing.md).
|
|
303
|
+
|
|
304
|
+
## Credits
|
|
305
|
+
|
|
306
|
+
agent-smith is a fork of [ccflare](https://github.com/snipeship/ccflare) by
|
|
307
|
+
snipeship. Routing behaviour is checked against
|
|
308
|
+
[TeamClaude](https://github.com/KarpelesLab/teamclaude) as reference data. Both
|
|
309
|
+
are MIT licensed.
|
|
310
|
+
|
|
311
|
+
## Disclaimer
|
|
312
|
+
|
|
313
|
+
agent-smith is an experimental proof of concept for ideation. It is not intended
|
|
314
|
+
for production use or for anyone else's accounts. It is not affiliated with,
|
|
315
|
+
endorsed by or sponsored by Anthropic or OpenAI. Claude, Claude Code, Codex,
|
|
316
|
+
ChatGPT and OpenAI are trademarks of their owners. Each provider's terms and
|
|
317
|
+
usage policies decide what you may do with your accounts, and checking them is
|
|
318
|
+
your job. The authors accept no liability for account actions, costs or other
|
|
319
|
+
consequences of running it.
|
|
320
|
+
|
|
321
|
+
## License
|
|
322
|
+
|
|
323
|
+
MIT, see [LICENSE](LICENSE). The software is provided "as is", without warranty
|
|
324
|
+
of any kind.
|