agent-cli-proxy 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 +21 -0
- package/README.md +348 -0
- package/dist/cli.js +4287 -0
- package/dist/data/plans.default.json +93 -0
- package/dist/index.js +4801 -0
- package/dist/migrations/001_init.sql +41 -0
- package/dist/migrations/002_agent_attribution.sql +25 -0
- package/dist/migrations/003_enhanced_logging.sql +3 -0
- package/dist/migrations/004_cliproxy_attribution.sql +40 -0
- package/dist/migrations/005_lifecycle_cost_subscription.sql +39 -0
- package/dist/migrations/006_account_subscriptions.sql +8 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agent CLI Proxy contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
# agent-cli-proxy
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://www.npmjs.com/package/agent-cli-proxy)
|
|
5
|
+
[](https://bun.sh)
|
|
6
|
+
|
|
7
|
+
AI API proxy with per-tool usage monitoring. Sits between AI coding tools (OpenCode, OpenClaw, Hermes) and upstream API providers, tracking usage per tool and per instance, computing token costs from live pricing data, and mapping CLIProxyAPI accounts to subscription plans for cost monitoring. Runs as a native Bun process. Self-hosted, no containers needed.
|
|
8
|
+
|
|
9
|
+
## Why this exists
|
|
10
|
+
|
|
11
|
+
Most AI coding tools share a single upstream API key, making it impossible to know which tool or session is responsible for a given cost spike. agent-cli-proxy intercepts every request, identifies the originating tool from request headers, and records per-tool usage with accurate cost attribution from models.dev pricing data. It also maps CLIProxyAPI accounts to subscription plans so you can monitor spend against plan limits without any enforcement overhead.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
### No global install (recommended for one-off use)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bunx agent-cli-proxy init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Global install via npm
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm i -g agent-cli-proxy
|
|
25
|
+
agent-cli-proxy init
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### From source
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/<owner>/agent-cli-proxy.git
|
|
32
|
+
cd agent-cli-proxy
|
|
33
|
+
bun install
|
|
34
|
+
bun run build
|
|
35
|
+
bun run src/cli.ts init
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quickstart
|
|
39
|
+
|
|
40
|
+
1. **Initialize** — creates config, database, and prompts for optional features:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
agent-cli-proxy init
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
2. **Install the daemon** — registers a systemd user service (Linux) or launchd agent (macOS):
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
agent-cli-proxy service install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
3. **Start the service**:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
agent-cli-proxy service start
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
4. **Send a request** — point your AI tool at `http://127.0.0.1:3100` instead of the upstream API.
|
|
59
|
+
|
|
60
|
+
5. **Check health and usage**:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
curl http://127.0.0.1:3100/health
|
|
64
|
+
curl http://127.0.0.1:3100/admin/usage/today
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The installer creates OS-appropriate local paths by default:
|
|
68
|
+
|
|
69
|
+
| Purpose | Default |
|
|
70
|
+
|---------|---------|
|
|
71
|
+
| Config | `~/.config/agent-cli-proxy/.env` |
|
|
72
|
+
| Data / SQLite | `~/.local/share/agent-cli-proxy/proxy.db` |
|
|
73
|
+
| Runtime bundle | `~/.local/share/agent-cli-proxy/runtime` |
|
|
74
|
+
| Linux daemon | `~/.config/systemd/user/agent-cli-proxy.service` |
|
|
75
|
+
| macOS daemon | `~/Library/LaunchAgents/ai.agent-cli-proxy.plist` |
|
|
76
|
+
|
|
77
|
+
`agent-cli-proxy init` asks which optional features to enable and writes only the needed settings. Existing `.env` files are not overwritten unless you pass `--force`; use `--merge` to keep existing values while adding missing defaults.
|
|
78
|
+
|
|
79
|
+
Optional features prompted during init:
|
|
80
|
+
|
|
81
|
+
- Dashboard login (`DASHBOARD_PASSWORD_HASH`)
|
|
82
|
+
- Admin API token (`ADMIN_API_KEY`) when exposing beyond loopback
|
|
83
|
+
- CLIProxyAPI account correlation (`CLIPROXY_MGMT_KEY`)
|
|
84
|
+
- SQLite/pricing cache paths
|
|
85
|
+
|
|
86
|
+
Provider API keys are intentionally **not** stored by this proxy. The proxy routes through CLIProxyAPI; configure provider credentials there.
|
|
87
|
+
|
|
88
|
+
## Configuration
|
|
89
|
+
|
|
90
|
+
| Variable | Default | Description |
|
|
91
|
+
|----------|---------|-------------|
|
|
92
|
+
| `PROXY_PORT` | `3100` | Proxy server port |
|
|
93
|
+
| `PROXY_HOST` | `127.0.0.1` | Bind host. Keep loopback unless you add auth/network controls. |
|
|
94
|
+
| `ADMIN_API_KEY` | | Required when `PROXY_HOST` is not loopback. Token for `/admin/*` endpoints. |
|
|
95
|
+
| `CLI_PROXY_API_URL` | `http://localhost:8317` | Upstream CLIProxyAPI URL (required unless `PROXY_LOCAL_OK=1`) |
|
|
96
|
+
| `CLI_PROXY_API_KEY` | `proxy` | Proxy auth key sent to CLIProxyAPI |
|
|
97
|
+
| `CLAUDE_CODE_VERSION` | `2.1.87` | Claude Code version for bypass headers |
|
|
98
|
+
| `DB_PATH` | `data/proxy.db` | SQLite database path |
|
|
99
|
+
| `PRICING_CACHE_PATH` | `data/pricing-cache.json` | Runtime models.dev pricing cache |
|
|
100
|
+
| `READY_PRICING_MAX_AGE_MS` | `86400000` | Maximum pricing cache age accepted by `/ready` (24h) |
|
|
101
|
+
| `PRICING_REFRESH_INTERVAL_MS` | `21600000` | How often to refresh pricing from models.dev (6h) |
|
|
102
|
+
| `COST_BACKFILL_INTERVAL_MS` | `1800000` | How often to backfill zero-cost request logs (30m) |
|
|
103
|
+
| `COST_BACKFILL_LOOKBACK_MS` | `604800000` | How far back cost backfill looks (7d) |
|
|
104
|
+
| `UPSTREAM_TIMEOUT_MS` | `300000` | Total upstream request timeout (5m) |
|
|
105
|
+
| `UPSTREAM_CONNECT_TIMEOUT_MS` | `10000` | Upstream connection timeout (10s) |
|
|
106
|
+
| `STALE_PENDING_MAX_AGE_MS` | `300000` | Age at which pending request rows are recovered on boot (5m) |
|
|
107
|
+
| `QUOTA_REFRESH_INTERVAL_MS` | `300000` | How often to refresh CLIProxyAPI quota snapshots (5m) |
|
|
108
|
+
| `QUOTA_REFRESH_TIMEOUT_MS` | `15000` | Timeout for provider quota refresh calls (15s) |
|
|
109
|
+
| `CLIENT_NAME_MAPPING` | | API key to display name mapping (e.g. `key1=alice,key2=bob`) |
|
|
110
|
+
| `PROVIDERS_CONFIG_PATH` | | Optional JSON file for custom providers |
|
|
111
|
+
| `PROVIDERS_JSON` | | Inline custom provider JSON; takes precedence over `PROVIDERS_CONFIG_PATH` |
|
|
112
|
+
| `PLANS_JSON` | | Inline plans JSON; takes precedence over `PLANS_PATH` |
|
|
113
|
+
| `PLANS_PATH` | | Path to a custom plans.json file |
|
|
114
|
+
| `CLIPROXY_MGMT_KEY` | | Optional CLIProxyAPI management key for account correlation |
|
|
115
|
+
| `CLIPROXY_AUTH_DIR` | | Optional CLIProxyAPI auth directory for subscription quota checks |
|
|
116
|
+
|
|
117
|
+
## Custom Providers
|
|
118
|
+
|
|
119
|
+
Add OpenAI-compatible local or custom providers with JSON config. Select them per request using `x-provider: <id>` or a request body `provider` field; the proxy strips the body `provider` field before forwarding by default.
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"providers": [
|
|
124
|
+
{
|
|
125
|
+
"id": "local",
|
|
126
|
+
"type": "openai-compatible",
|
|
127
|
+
"paths": ["/v1/chat/completions"],
|
|
128
|
+
"upstreamBaseUrl": "http://localhost:11434",
|
|
129
|
+
"upstreamPath": "/v1/chat/completions",
|
|
130
|
+
"models": ["llama", "qwen"],
|
|
131
|
+
"auth": "none"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"id": "glm",
|
|
135
|
+
"type": "openai-compatible",
|
|
136
|
+
"paths": ["/v1/chat/completions"],
|
|
137
|
+
"upstreamBaseUrl": "https://open.bigmodel.cn/api/paas/v4",
|
|
138
|
+
"models": ["glm"],
|
|
139
|
+
"auth": { "type": "bearer", "env": "GLM_API_KEY" }
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Provider fields: `id`, `type` (`openai-compatible` or `anthropic`), `paths`, `upstreamBaseUrl`, optional `upstreamPath`, `models`, `headers`, `auth` (`none`, `preserve`, `bearer`, `x-api-key`, or object with `env`/`value`/`header`), and `stripProviderField`.
|
|
146
|
+
|
|
147
|
+
Save this as a file and set `PROVIDERS_CONFIG_PATH`, or set `PROVIDERS_JSON` to the inline JSON string. Use `agent-cli-proxy providers init` to create a starter file at the default config path.
|
|
148
|
+
|
|
149
|
+
## Subscription Plans
|
|
150
|
+
|
|
151
|
+
Plans map CLIProxyAPI accounts to subscription tiers for cost monitoring. This is **monitoring-only** — no request enforcement or quota blocking happens.
|
|
152
|
+
|
|
153
|
+
### plans.json format
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"plans": [
|
|
158
|
+
{
|
|
159
|
+
"code": "claude_pro",
|
|
160
|
+
"display_name": "Anthropic Claude Pro",
|
|
161
|
+
"monthly_price_usd": 20,
|
|
162
|
+
"notes": "Conservative estimate — verify with vendor — last updated 2026-05"
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The proxy ships with a default `plans.json` covering common plans (Claude Pro/Max, ChatGPT Plus/Pro/Business, Kimi Pro, GLM Pro, local BYOK). Override with `PLANS_JSON` or `PLANS_PATH`.
|
|
169
|
+
|
|
170
|
+
### Plans CLI commands
|
|
171
|
+
|
|
172
|
+
| Command | Description |
|
|
173
|
+
|---------|-------------|
|
|
174
|
+
| `agent-cli-proxy plans show` | Show loaded plans (human-readable) |
|
|
175
|
+
| `agent-cli-proxy plans show --json` | Show loaded plans as JSON |
|
|
176
|
+
| `agent-cli-proxy plans list` | List all plan codes and prices |
|
|
177
|
+
| `agent-cli-proxy plans init` | Create a starter plans.json at the default config path |
|
|
178
|
+
| `agent-cli-proxy plans path` | Print the active plans.json path |
|
|
179
|
+
| `agent-cli-proxy plans bind <account> <code>` | Bind a CLIProxyAPI account to a plan code |
|
|
180
|
+
| `agent-cli-proxy plans unbind <account>` | Remove a plan binding for an account |
|
|
181
|
+
|
|
182
|
+
## CLI Reference
|
|
183
|
+
|
|
184
|
+
| Command | Description |
|
|
185
|
+
|---------|-------------|
|
|
186
|
+
| `agent-cli-proxy init` | Interactive config + DB setup |
|
|
187
|
+
| `agent-cli-proxy init --non-interactive ...` | Non-interactive install (CI-friendly) |
|
|
188
|
+
| `agent-cli-proxy db init` | Initialize or migrate the SQLite database |
|
|
189
|
+
| `agent-cli-proxy paths` | Print default install paths |
|
|
190
|
+
| `agent-cli-proxy doctor` | Validate config, DB, plans, providers, pricing, upstream |
|
|
191
|
+
| `agent-cli-proxy doctor --json` | Doctor output as JSON (for issue reports) |
|
|
192
|
+
| `agent-cli-proxy service install` | Install user daemon (systemd/launchd) |
|
|
193
|
+
| `agent-cli-proxy service start` | Start the daemon |
|
|
194
|
+
| `agent-cli-proxy service stop` | Stop the daemon |
|
|
195
|
+
| `agent-cli-proxy service restart` | Restart the daemon |
|
|
196
|
+
| `agent-cli-proxy service status` | Show daemon status |
|
|
197
|
+
| `agent-cli-proxy service logs` | Show daemon logs |
|
|
198
|
+
| `agent-cli-proxy service logs --follow` | Stream daemon logs |
|
|
199
|
+
| `agent-cli-proxy plans show` | Show loaded plans |
|
|
200
|
+
| `agent-cli-proxy plans list` | List plan codes |
|
|
201
|
+
| `agent-cli-proxy plans init` | Create starter plans.json |
|
|
202
|
+
| `agent-cli-proxy plans path` | Print active plans.json path |
|
|
203
|
+
| `agent-cli-proxy plans bind <account> <code>` | Bind account to plan |
|
|
204
|
+
| `agent-cli-proxy plans unbind <account>` | Remove account binding |
|
|
205
|
+
| `agent-cli-proxy providers show` | Show loaded provider config |
|
|
206
|
+
| `agent-cli-proxy providers path` | Print active providers config path |
|
|
207
|
+
| `agent-cli-proxy providers init` | Create starter providers.json |
|
|
208
|
+
| `agent-cli-proxy providers reload` | Reload provider config without restart |
|
|
209
|
+
| `agent-cli-proxy backfill-costs` | Recompute zero-cost request logs |
|
|
210
|
+
| `agent-cli-proxy backfill-costs --all` | Recompute all request logs |
|
|
211
|
+
|
|
212
|
+
Prefer `--admin-token-env` and `--cliproxy-mgmt-key-env` for non-interactive installs so secrets do not appear in shell history or process arguments.
|
|
213
|
+
|
|
214
|
+
## Admin Endpoints
|
|
215
|
+
|
|
216
|
+
All `/admin/*` endpoints require `ADMIN_API_KEY` when the proxy is not bound to loopback.
|
|
217
|
+
|
|
218
|
+
| Method | Path | Description |
|
|
219
|
+
|--------|------|-------------|
|
|
220
|
+
| `GET` | `/health` | Liveness probe (always 200 if process alive) |
|
|
221
|
+
| `GET` | `/ready` | Readiness probe (DB, pricing, upstream); 503 when failing |
|
|
222
|
+
| `GET` | `/metrics` | Prometheus-format metrics |
|
|
223
|
+
| `GET` | `/admin/usage/today` | Today's usage summary |
|
|
224
|
+
| `GET` | `/admin/usage/range?from=&to=` | Usage by date range |
|
|
225
|
+
| `GET` | `/admin/usage/models?day=` | Model breakdown for a day |
|
|
226
|
+
| `GET` | `/admin/usage/providers?day=` | Provider breakdown for a day |
|
|
227
|
+
| `GET` | `/admin/usage/accounts?day=` | Per-account usage for a day |
|
|
228
|
+
| `GET` | `/admin/usage/accounts/range?from=&to=` | Per-account usage over a range |
|
|
229
|
+
| `GET` | `/admin/usage/accounts/summary?from=&to=` | Account summary (7-day default) |
|
|
230
|
+
| `GET` | `/admin/stats` | Total statistics |
|
|
231
|
+
| `GET` | `/admin/logs` | Request logs (paginated) |
|
|
232
|
+
| `GET` | `/admin/logs?tool=openclaw` | Filter logs by tool |
|
|
233
|
+
| `GET` | `/admin/logs?client_id=openclaw-jongi` | Filter logs by instance |
|
|
234
|
+
| `GET` | `/admin/logs/:id` | Single request log by ID |
|
|
235
|
+
| `GET` | `/admin/quotas` | Latest stored quota snapshots |
|
|
236
|
+
| `GET` | `/admin/quotas?refresh=true` | Refresh and return quota snapshots |
|
|
237
|
+
| `GET` | `/admin/quotas/refresh` | Force refresh quota snapshots |
|
|
238
|
+
| `GET` | `/admin/plans` | List all plans |
|
|
239
|
+
| `GET` | `/admin/plans/cost-summary?month=YYYY-MM` | Monthly cost summary by account |
|
|
240
|
+
| `GET` | `/admin/plans/account/:account` | Plan binding and recent usage for an account |
|
|
241
|
+
|
|
242
|
+
## Health and Readiness
|
|
243
|
+
|
|
244
|
+
`/health` is a cheap liveness probe. It returns `200 {"status":"ok"}` as long as the process is alive, with no dependency checks.
|
|
245
|
+
|
|
246
|
+
`/ready` is a readiness probe that checks the database, pricing cache freshness, upstream CLIProxyAPI, and supervisor loop state. It returns `200` when all checks pass and `503` when any critical dependency is failing.
|
|
247
|
+
|
|
248
|
+
Sample `/ready` response:
|
|
249
|
+
|
|
250
|
+
```json
|
|
251
|
+
{
|
|
252
|
+
"status": "pass",
|
|
253
|
+
"checks": {
|
|
254
|
+
"database": { "status": "pass", "responseTime": 3 },
|
|
255
|
+
"pricing": { "status": "pass", "ageMs": 14400000 },
|
|
256
|
+
"upstream": { "status": "pass", "responseTime": 42 },
|
|
257
|
+
"supervisor": { "status": "pass", "loops": ["pricing-refresh", "cost-backfill"] }
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Results are cached for 3 seconds to protect dependencies from aggressive polling. The response includes `Cache-Control: no-store`.
|
|
263
|
+
|
|
264
|
+
## Observability
|
|
265
|
+
|
|
266
|
+
Logs are structured JSON written to stdout (`info`, `warn`, `debug`) and stderr (`error`). Set `LOG_FORMAT=pretty` for human-readable output during development.
|
|
267
|
+
|
|
268
|
+
Key event names:
|
|
269
|
+
|
|
270
|
+
| Event | Description |
|
|
271
|
+
|-------|-------------|
|
|
272
|
+
| `lifecycle.pre_logged` | Request row inserted before upstream call |
|
|
273
|
+
| `lifecycle.finalized` | Request row updated after upstream response |
|
|
274
|
+
| `lifecycle.aborted` | Request aborted before upstream response |
|
|
275
|
+
| `upstream.error` | Upstream call failed (with error details) |
|
|
276
|
+
| `cost.guard` | Cost computation skipped or guarded |
|
|
277
|
+
| `plans.unmapped` | CLIProxyAPI account has no plan binding |
|
|
278
|
+
| `shutdown.drain` | Graceful shutdown draining in-flight requests |
|
|
279
|
+
| `shutdown.complete` | Shutdown finalized cleanly |
|
|
280
|
+
|
|
281
|
+
## Architecture
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
OpenCode ─┐
|
|
285
|
+
OpenClaw ─┤── agent-cli-proxy (3100) ── CLIProxyAPI (8317) ── Upstream APIs
|
|
286
|
+
Hermes ─┘
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Each tool is automatically identified by request headers and tracked separately. Multiple instances of the same tool are distinguished by `X-Agent-Name` header or session IDs.
|
|
290
|
+
|
|
291
|
+
The request lifecycle: a `pending` row is inserted before the upstream call (pre-log), the upstream response streams to the client, and the row is finalized with tokens and cost after the stream completes. An optional correlator loop maps CLIProxyAPI accounts to request rows for subscription attribution. A cost backfill loop recomputes zero-cost rows when pricing data becomes available.
|
|
292
|
+
|
|
293
|
+
### Tool Identification
|
|
294
|
+
|
|
295
|
+
| Tool | Detected By |
|
|
296
|
+
|------|------------|
|
|
297
|
+
| OpenCode | `x-opencode-session`, `x-initiator`, or `User-Agent: opencode/*` |
|
|
298
|
+
| OpenClaw | `x-openclaw-session-id`, `originator: openclaw`, or `X-Agent-Name` |
|
|
299
|
+
| Hermes | `User-Agent: HermesAgent/*` or `x-activity-request-id` |
|
|
300
|
+
|
|
301
|
+
### Project Structure
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
src/
|
|
305
|
+
├── config/ # Environment configuration and validation
|
|
306
|
+
├── identification/ # Plugin-based tool identification
|
|
307
|
+
├── provider/
|
|
308
|
+
│ ├── anthropic/ # Claude bypass + request transform
|
|
309
|
+
│ └── openai/ # OpenAI pass-through
|
|
310
|
+
├── server/ # HTTP handler, stream relay, usage logging
|
|
311
|
+
├── storage/ # SQLite repos, pricing, usage service
|
|
312
|
+
├── usage/ # Usage type definitions
|
|
313
|
+
└── admin/ # Admin API routes
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Troubleshooting
|
|
317
|
+
|
|
318
|
+
Run `agent-cli-proxy doctor` first. It validates configuration, opens the SQLite database, reports applied migrations, checks plans/providers configuration, inspects the pricing cache, probes `CLI_PROXY_API_URL/health`, and lists supervised loops. Use `--json` when attaching output to issues.
|
|
319
|
+
|
|
320
|
+
For daemon logs:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
agent-cli-proxy service logs --follow
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
On Linux this proxies to `journalctl --user -u agent-cli-proxy.service -f`; on macOS it proxies to `log stream` for the `agent-cli-proxy` process.
|
|
327
|
+
|
|
328
|
+
**Common errors:**
|
|
329
|
+
|
|
330
|
+
- `CLI_PROXY_API_URL is required` — set `CLI_PROXY_API_URL` in your `.env` or pass `PROXY_LOCAL_OK=1` to allow the local default.
|
|
331
|
+
- `ADMIN_API_KEY is required when PROXY_HOST is not loopback` — set `ADMIN_API_KEY` before exposing the proxy beyond `127.0.0.1`.
|
|
332
|
+
- Plans fallback warning in logs — `plans.json` failed to parse; the proxy fell back to bundled defaults. Run `agent-cli-proxy plans show` to inspect the active config.
|
|
333
|
+
|
|
334
|
+
## Releasing
|
|
335
|
+
|
|
336
|
+
For maintainers: run `bun run release-check` to verify the build and package contents before tagging. Push a `v*` tag and the `.github/workflows/release.yml` GitHub Actions workflow runs `bun publish --access public --tolerate-republish` against the npm registry using the `NPM_TOKEN` repository secret.
|
|
337
|
+
|
|
338
|
+
## Contributing
|
|
339
|
+
|
|
340
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
341
|
+
|
|
342
|
+
## Security
|
|
343
|
+
|
|
344
|
+
See [SECURITY.md](SECURITY.md).
|
|
345
|
+
|
|
346
|
+
## License
|
|
347
|
+
|
|
348
|
+
MIT — see [LICENSE](LICENSE).
|