context-lens 0.2.0 → 0.3.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 +120 -25
- package/dist/cli-utils.d.ts +2 -1
- package/dist/cli-utils.d.ts.map +1 -1
- package/dist/cli-utils.js +40 -13
- package/dist/cli-utils.js.map +1 -1
- package/dist/cli.js +184 -68
- package/dist/cli.js.map +1 -1
- package/dist/core/conversation.d.ts +63 -0
- package/dist/core/conversation.d.ts.map +1 -0
- package/dist/core/conversation.js +305 -0
- package/dist/core/conversation.js.map +1 -0
- package/dist/core/health.d.ts +7 -0
- package/dist/core/health.d.ts.map +1 -0
- package/dist/core/health.js +311 -0
- package/dist/core/health.js.map +1 -0
- package/dist/core/models.d.ts +36 -0
- package/dist/core/models.d.ts.map +1 -0
- package/dist/core/models.js +111 -0
- package/dist/core/models.js.map +1 -0
- package/dist/core/parse.d.ts +17 -0
- package/dist/core/parse.d.ts.map +1 -0
- package/dist/core/parse.js +349 -0
- package/dist/core/parse.js.map +1 -0
- package/dist/core/routing.d.ts +47 -0
- package/dist/core/routing.d.ts.map +1 -0
- package/dist/core/routing.js +132 -0
- package/dist/core/routing.js.map +1 -0
- package/dist/core/security.d.ts +8 -0
- package/dist/core/security.d.ts.map +1 -0
- package/dist/core/security.js +222 -0
- package/dist/core/security.js.map +1 -0
- package/dist/core/source.d.ts +22 -0
- package/dist/core/source.d.ts.map +1 -0
- package/dist/core/source.js +56 -0
- package/dist/core/source.js.map +1 -0
- package/dist/core/tokens.d.ts +29 -0
- package/dist/core/tokens.d.ts.map +1 -0
- package/dist/core/tokens.js +163 -0
- package/dist/core/tokens.js.map +1 -0
- package/dist/core.d.ts +14 -22
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +14 -471
- package/dist/core.js.map +1 -1
- package/dist/http/headers.d.ts +25 -0
- package/dist/http/headers.d.ts.map +1 -0
- package/dist/http/headers.js +54 -0
- package/dist/http/headers.js.map +1 -0
- package/dist/lhar/composition.d.ts +12 -0
- package/dist/lhar/composition.d.ts.map +1 -0
- package/dist/lhar/composition.js +258 -0
- package/dist/lhar/composition.js.map +1 -0
- package/dist/lhar/export.d.ts +5 -0
- package/dist/lhar/export.d.ts.map +1 -0
- package/dist/lhar/export.js +59 -0
- package/dist/lhar/export.js.map +1 -0
- package/dist/lhar/record.d.ts +6 -0
- package/dist/lhar/record.d.ts.map +1 -0
- package/dist/lhar/record.js +216 -0
- package/dist/lhar/record.js.map +1 -0
- package/dist/lhar/response.d.ts +11 -0
- package/dist/lhar/response.d.ts.map +1 -0
- package/dist/lhar/response.js +132 -0
- package/dist/lhar/response.js.map +1 -0
- package/dist/lhar-types.generated.d.ts +24 -3
- package/dist/lhar-types.generated.d.ts.map +1 -1
- package/dist/lhar.d.ts +12 -19
- package/dist/lhar.d.ts.map +1 -1
- package/dist/lhar.js +16 -473
- package/dist/lhar.js.map +1 -1
- package/dist/server/api.d.ts +8 -0
- package/dist/server/api.d.ts.map +1 -0
- package/dist/server/api.js +292 -0
- package/dist/server/api.js.map +1 -0
- package/dist/server/config.d.ts +13 -0
- package/dist/server/config.d.ts.map +1 -0
- package/dist/server/config.js +36 -0
- package/dist/server/config.js.map +1 -0
- package/dist/server/projection.d.ts +9 -0
- package/dist/server/projection.d.ts.map +1 -0
- package/dist/server/projection.js +47 -0
- package/dist/server/projection.js.map +1 -0
- package/dist/server/proxy.d.ts +13 -0
- package/dist/server/proxy.d.ts.map +1 -0
- package/dist/server/proxy.js +218 -0
- package/dist/server/proxy.js.map +1 -0
- package/dist/server/static.d.ts +9 -0
- package/dist/server/static.d.ts.map +1 -0
- package/dist/server/static.js +78 -0
- package/dist/server/static.js.map +1 -0
- package/dist/server/store.d.ts +81 -0
- package/dist/server/store.d.ts.map +1 -0
- package/dist/server/store.js +632 -0
- package/dist/server/store.js.map +1 -0
- package/dist/server/webui.d.ts +5 -0
- package/dist/server/webui.d.ts.map +1 -0
- package/dist/server/webui.js +42 -0
- package/dist/server/webui.js.map +1 -0
- package/dist/server-utils.d.ts +2 -2
- package/dist/server-utils.d.ts.map +1 -1
- package/dist/server-utils.js +12 -21
- package/dist/server-utils.js.map +1 -1
- package/dist/server.js +31 -697
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +94 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/version.generated.d.ts +2 -0
- package/dist/version.generated.d.ts.map +1 -0
- package/dist/version.generated.js +2 -0
- package/dist/version.generated.js.map +1 -0
- package/findings-screenshot.png +0 -0
- package/messages-screenshot.png +0 -0
- package/package.json +23 -10
- package/schema/lhar.schema.json +58 -4
- package/screenshot-overview.png +0 -0
- package/sessions-screenshot.png +0 -0
- package/timeline-screenshot.png +0 -0
- package/diff.png +0 -0
- package/overview-sidebar.png +0 -0
- package/public/index.html +0 -2804
package/README.md
CHANGED
|
@@ -1,60 +1,98 @@
|
|
|
1
1
|
# Context Lens
|
|
2
2
|
|
|
3
3
|

|
|
4
|
+
[](https://github.com/larsderidder/context-lens/actions/workflows/ci.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/context-lens)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
See what's actually filling your context window. Context Lens is a local proxy that captures LLM API calls from your coding tools and shows you a composition breakdown: what percentage is system prompts, tool definitions, conversation history, tool results, thinking blocks. It answers the question every developer asks: "why is this session so expensive?"
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
Works with Claude Code, Codex, Gemini CLI, Aider, Pi, and anything else that talks to OpenAI/Anthropic/Google APIs. No code changes needed.
|
|
8
10
|
|
|
9
11
|

|
|
10
12
|
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add -g context-lens
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or with npm:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g context-lens
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or run directly:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx context-lens ...
|
|
29
|
+
```
|
|
30
|
+
|
|
11
31
|
## Quick Start
|
|
12
32
|
|
|
13
33
|
```bash
|
|
14
34
|
npx context-lens claude "your prompt"
|
|
15
35
|
npx context-lens codex "your prompt"
|
|
36
|
+
npx context-lens gemini "your prompt"
|
|
16
37
|
npx context-lens aider --model claude-sonnet-4
|
|
38
|
+
npx context-lens pi
|
|
17
39
|
npx context-lens -- python my_agent.py
|
|
18
40
|
```
|
|
19
41
|
|
|
20
|
-
This starts the proxy (port 4040), opens the web UI (http://localhost:4041), sets the right env vars, and runs your command. Multiple tools can share one proxy
|
|
42
|
+
This starts the proxy (port 4040), opens the web UI (http://localhost:4041), sets the right env vars, and runs your command. Multiple tools can share one proxy; just open more terminals.
|
|
43
|
+
|
|
44
|
+
## Supported Providers
|
|
45
|
+
|
|
46
|
+
| Provider | Method | Status | Environment Variable |
|
|
47
|
+
| :--- | :--- | :--- | :--- |
|
|
48
|
+
| **Anthropic** | Reverse Proxy | ✅ Stable | `ANTHROPIC_BASE_URL` |
|
|
49
|
+
| **OpenAI** | Reverse Proxy | ✅ Stable | `OPENAI_BASE_URL` |
|
|
50
|
+
| **Google Gemini** | Reverse Proxy | 🧪 Experimental | `GOOGLE_GEMINI_BASE_URL` |
|
|
51
|
+
| **ChatGPT (Subscription)** | MITM Proxy | ✅ Stable | `https_proxy` |
|
|
52
|
+
| **Pi Coding Agent** | Reverse Proxy (temporary per-run config) | ✅ Stable | `PI_CODING_AGENT_DIR` (set by wrapper) |
|
|
53
|
+
| **Aider / Generic** | Reverse Proxy | ✅ Stable | Detects standard patterns |
|
|
21
54
|
|
|
22
55
|
## What You Get
|
|
23
56
|
|
|
24
|
-
- **Composition treemap
|
|
25
|
-
- **Cost tracking
|
|
26
|
-
- **Conversation threading
|
|
27
|
-
- **Agent breakdown
|
|
28
|
-
- **Timeline
|
|
29
|
-
- **Context diff
|
|
30
|
-
- **Findings
|
|
31
|
-
- **Auto-detection
|
|
32
|
-
- **LHAR export
|
|
33
|
-
- **State persistence
|
|
34
|
-
- **Streaming support
|
|
57
|
+
- **Composition treemap:** visual breakdown of what's filling your context (system prompts, tool definitions, tool results, messages, thinking, images)
|
|
58
|
+
- **Cost tracking:** per-turn and per-session cost estimates across models
|
|
59
|
+
- **Conversation threading:** groups API calls by session, shows main agent vs subagent turns
|
|
60
|
+
- **Agent breakdown:** token usage and cost per agent within a session
|
|
61
|
+
- **Timeline:** bar chart of context size over time, filterable by main/all/cost
|
|
62
|
+
- **Context diff:** turn-to-turn delta showing what grew, shrank, or appeared
|
|
63
|
+
- **Findings:** flags large tool results, unused tool definitions, context overflow risk, compaction events
|
|
64
|
+
- **Auto-detection:** recognizes Claude Code, Codex, aider, Pi, and others by source tag or system prompt
|
|
65
|
+
- **LHAR export:** download session data as LHAR (LLM HTTP Archive) format ([doc](docs/LHAR.md))
|
|
66
|
+
- **State persistence:** data survives restarts; delete individual sessions or reset all from the UI
|
|
67
|
+
- **Streaming support:** passes through SSE chunks in real-time
|
|
35
68
|
|
|
36
69
|
### Screenshots
|
|
37
70
|
|
|
38
|
-
**
|
|
71
|
+
**Sessions list**
|
|
39
72
|
|
|
40
|
-

|
|
41
74
|
|
|
42
|
-
**
|
|
75
|
+
**Messages view with drill-down details**
|
|
43
76
|
|
|
44
|
-

|
|
45
78
|
|
|
46
|
-
**
|
|
79
|
+
**Timeline view**
|
|
47
80
|
|
|
48
|
-

|
|
82
|
+
|
|
83
|
+
**Findings panel**
|
|
84
|
+
|
|
85
|
+

|
|
49
86
|
|
|
50
87
|
## Manual Mode
|
|
51
88
|
|
|
52
89
|
```bash
|
|
53
|
-
|
|
90
|
+
pnpm start
|
|
54
91
|
# Port 4040 = proxy, port 4041 = web UI
|
|
55
92
|
|
|
56
93
|
ANTHROPIC_BASE_URL=http://localhost:4040 claude "your prompt"
|
|
57
|
-
OPENAI_BASE_URL=http://localhost:4040 codex "your prompt"
|
|
94
|
+
OPENAI_BASE_URL=http://localhost:4040 codex "your prompt" # API-key/OpenAI-base-url mode
|
|
95
|
+
GOOGLE_GEMINI_BASE_URL=http://localhost:4040 gemini "your prompt" # experimental
|
|
58
96
|
```
|
|
59
97
|
|
|
60
98
|
### Source Tagging
|
|
@@ -66,15 +104,51 @@ ANTHROPIC_BASE_URL=http://localhost:4040/claude claude "prompt"
|
|
|
66
104
|
OPENAI_BASE_URL=http://localhost:4040/aider aider "prompt"
|
|
67
105
|
```
|
|
68
106
|
|
|
107
|
+
### Pi Coding Agent
|
|
108
|
+
|
|
109
|
+
Pi ignores standard base-URL environment variables. `context-lens pi` works by creating a private per-run temporary Pi config directory under `/tmp/context-lens-pi-agent-*`, symlinking your normal `~/.pi/agent/*` files, and injecting proxy `baseUrl` overrides into its temporary `models.json`.
|
|
110
|
+
|
|
111
|
+
Your real `~/.pi/agent/models.json` is never modified, and the temporary directory is removed when the command exits.
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npx context-lens pi
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Pi config paths:
|
|
118
|
+
|
|
119
|
+
- Real Pi config dir: `~/.pi/agent`
|
|
120
|
+
- Real Pi models file: `~/.pi/agent/models.json` (left untouched)
|
|
121
|
+
- Temporary per-run config dir: `/tmp/context-lens-pi-agent-*`
|
|
122
|
+
- Runtime override providers in temp `models.json`: `anthropic`, `openai`, `google-gemini-cli`, `google-antigravity`
|
|
123
|
+
|
|
124
|
+
If you prefer not to use the temporary runtime override, you can also edit your real `~/.pi/agent/models.json` directly and set those providers' `baseUrl` values to `http://localhost:4040/pi`.
|
|
125
|
+
|
|
126
|
+
Example `~/.pi/agent/models.json`:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"providers": {
|
|
131
|
+
"anthropic": { "baseUrl": "http://localhost:4040/pi" },
|
|
132
|
+
"openai": { "baseUrl": "http://localhost:4040/pi" },
|
|
133
|
+
"google-gemini-cli": { "baseUrl": "http://localhost:4040/pi" },
|
|
134
|
+
"google-antigravity": { "baseUrl": "http://localhost:4040/pi" }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Tested with: Claude Opus 4.6, Gemini 2.5 Flash (via Gemini CLI subscription), GPT-OSS 120B (via Antigravity). The `openai-codex` provider (ChatGPT subscription) has the same Cloudflare limitation as Codex and is not supported through the reverse proxy.
|
|
140
|
+
|
|
69
141
|
### Codex Subscription Mode
|
|
70
142
|
|
|
71
|
-
Codex with a ChatGPT subscription needs mitmproxy for HTTPS interception (Cloudflare blocks reverse proxies). The CLI handles this automatically
|
|
143
|
+
Codex with a ChatGPT subscription needs mitmproxy for HTTPS interception (Cloudflare blocks reverse proxies). The CLI handles this automatically. Just make sure `mitmdump` is installed:
|
|
72
144
|
|
|
73
145
|
```bash
|
|
74
146
|
pipx install mitmproxy
|
|
75
147
|
npx context-lens codex "your prompt"
|
|
76
148
|
```
|
|
77
149
|
|
|
150
|
+
If Codex fails with certificate trust errors, install/trust the mitmproxy CA certificate (`~/.mitmproxy/mitmproxy-ca-cert.pem`) for your environment.
|
|
151
|
+
|
|
78
152
|
## How It Works
|
|
79
153
|
|
|
80
154
|
Context Lens sits between your coding tool and the LLM API, capturing requests in transit.
|
|
@@ -82,7 +156,7 @@ Context Lens sits between your coding tool and the LLM API, capturing requests i
|
|
|
82
156
|
**Reverse proxy (Claude Code, aider, OpenAI API tools)**
|
|
83
157
|
|
|
84
158
|
```
|
|
85
|
-
Tool
|
|
159
|
+
Tool ─HTTP─▶ Context Lens (:4040) ─HTTPS─▶ api.anthropic.com / api.openai.com
|
|
86
160
|
│
|
|
87
161
|
▼
|
|
88
162
|
Web UI (:4041)
|
|
@@ -95,7 +169,7 @@ The CLI sets env vars like `ANTHROPIC_BASE_URL=http://localhost:4040` so the too
|
|
|
95
169
|
Some tools can't be reverse-proxied. Codex with a ChatGPT subscription authenticates against `chatgpt.com`, which is behind Cloudflare. A reverse proxy changes the TLS fingerprint, causing Cloudflare to reject the request with a 403. For these tools, Context Lens uses mitmproxy as a forward HTTPS proxy instead:
|
|
96
170
|
|
|
97
171
|
```
|
|
98
|
-
Tool
|
|
172
|
+
Tool ─HTTPS via proxy─▶ mitmproxy (:8080) ─HTTPS─▶ chatgpt.com
|
|
99
173
|
│
|
|
100
174
|
mitm_addon.py
|
|
101
175
|
│
|
|
@@ -109,6 +183,27 @@ The tool makes its own TLS connection through the proxy, preserving its native T
|
|
|
109
183
|
|
|
110
184
|
Each request is parsed to extract: model name, system prompts, tool definitions, message history (with per-message token estimates), and content block types (text, tool calls, tool results, images, thinking). The response is captured to extract usage stats and cost. Requests are grouped into conversations using session IDs (Anthropic `metadata.user_id`), response chaining (OpenAI `previous_response_id`), or a fingerprint of the system prompt + first user message.
|
|
111
185
|
|
|
186
|
+
## Why Context Lens?
|
|
187
|
+
|
|
188
|
+
Tools like [Langfuse](https://langfuse.com/) and [Braintrust](https://braintrust.dev/) are great for observability when you control the code: you add their SDK, instrument your calls, and get traces in a dashboard. Context Lens solves a different problem.
|
|
189
|
+
|
|
190
|
+
**You can't instrument tools you don't own.** Claude Code, Codex, Gemini CLI, and Aider are closed-source binaries. You can't add an SDK to them. Context Lens works as a transparent proxy, so it captures everything without touching the tool's code.
|
|
191
|
+
|
|
192
|
+
**Context composition, not just token counts.** Most observability tools show you input/output token totals. Context Lens breaks down *what's inside* the context window: how much is system prompts vs. tool definitions vs. conversation history vs. tool results vs. thinking blocks. That's what you need to understand why sessions get expensive.
|
|
193
|
+
|
|
194
|
+
**Local and private.** Everything runs on your machine. No accounts, no cloud, no data leaving your network. Start it, use it, stop it.
|
|
195
|
+
|
|
196
|
+
| | Context Lens | Langfuse / Braintrust |
|
|
197
|
+
|:---|:---|:---|
|
|
198
|
+
| **Setup** | `npx context-lens claude` | Add SDK, configure API keys |
|
|
199
|
+
| **Works with closed-source tools** | Yes (proxy) | No (needs instrumentation) |
|
|
200
|
+
| **Context composition breakdown** | Yes (treemap, per-category) | Token totals only |
|
|
201
|
+
| **Runs locally** | Yes, entirely | Cloud or self-hosted server |
|
|
202
|
+
| **Prompt management & evals** | No | Yes |
|
|
203
|
+
| **Team/production use** | No (single-user, local) | Yes |
|
|
204
|
+
|
|
205
|
+
Context Lens is for developers who want to understand and optimize their coding agent sessions. If you need production monitoring, prompt versioning, or team dashboards, use Langfuse.
|
|
206
|
+
|
|
112
207
|
## Data
|
|
113
208
|
|
|
114
209
|
Captured requests are kept in memory (last 100) and persisted to `data/state.jsonl` across restarts. Each session is also logged as a separate `.lhar` file in `data/`. Use the Reset button in the UI to clear everything.
|
package/dist/cli-utils.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ToolConfig } from
|
|
1
|
+
import type { ToolConfig } from "./types.js";
|
|
2
2
|
export declare function getToolConfig(toolName: string): ToolConfig;
|
|
3
3
|
export declare const CLI_CONSTANTS: {
|
|
4
4
|
readonly PROXY_URL: "http://localhost:4040";
|
|
5
5
|
readonly MITM_PORT: 8080;
|
|
6
6
|
readonly MITM_PROXY_URL: "http://localhost:8080";
|
|
7
|
+
readonly PI_AGENT_DIR_PREFIX: "/tmp/context-lens-pi-agent-";
|
|
7
8
|
readonly MITM_ADDON_PATH: string;
|
|
8
9
|
};
|
|
9
10
|
//# sourceMappingURL=cli-utils.d.ts.map
|
package/dist/cli-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-utils.d.ts","sourceRoot":"","sources":["../src/cli-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-utils.d.ts","sourceRoot":"","sources":["../src/cli-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA+D7C,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAY1D;AAGD,eAAO,MAAM,aAAa;;;;;;CAOhB,CAAC"}
|
package/dist/cli-utils.js
CHANGED
|
@@ -1,50 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fileURLToPath } from
|
|
1
|
+
import { dirname, join } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
3
|
const __filename = fileURLToPath(import.meta.url);
|
|
4
4
|
const __dirname = dirname(__filename);
|
|
5
5
|
// Known tool config: env vars for the child process, extra CLI args, server env vars, and whether mitmproxy is needed
|
|
6
|
-
const PROXY_URL =
|
|
6
|
+
const PROXY_URL = "http://localhost:4040";
|
|
7
7
|
const MITM_PORT = 8080;
|
|
8
8
|
const MITM_PROXY_URL = `http://localhost:${MITM_PORT}`;
|
|
9
|
+
const PI_AGENT_DIR_PREFIX = "/tmp/context-lens-pi-agent-";
|
|
9
10
|
const TOOL_CONFIG = {
|
|
10
|
-
|
|
11
|
+
claude: {
|
|
11
12
|
childEnv: { ANTHROPIC_BASE_URL: `${PROXY_URL}/claude` },
|
|
12
13
|
extraArgs: [],
|
|
13
14
|
serverEnv: {},
|
|
14
15
|
needsMitm: false,
|
|
15
16
|
},
|
|
16
|
-
|
|
17
|
-
// Codex subscription uses chatgpt.com with Cloudflare
|
|
17
|
+
codex: {
|
|
18
|
+
// Codex subscription uses chatgpt.com with Cloudflare, needs forward proxy (mitmproxy)
|
|
18
19
|
// to intercept HTTPS traffic without breaking TLS fingerprinting.
|
|
19
20
|
childEnv: {
|
|
20
21
|
https_proxy: MITM_PROXY_URL,
|
|
21
|
-
SSL_CERT_FILE: join(process.env.HOME ||
|
|
22
|
+
SSL_CERT_FILE: join(process.env.HOME || "", ".mitmproxy", "mitmproxy-ca-cert.pem"),
|
|
22
23
|
},
|
|
23
24
|
extraArgs: [],
|
|
24
25
|
serverEnv: {},
|
|
25
26
|
needsMitm: true,
|
|
26
27
|
},
|
|
27
|
-
|
|
28
|
-
childEnv: {
|
|
28
|
+
aider: {
|
|
29
|
+
childEnv: {
|
|
30
|
+
ANTHROPIC_BASE_URL: `${PROXY_URL}/aider`,
|
|
31
|
+
OPENAI_BASE_URL: `${PROXY_URL}/aider`,
|
|
32
|
+
},
|
|
33
|
+
extraArgs: [],
|
|
34
|
+
serverEnv: {},
|
|
35
|
+
needsMitm: false,
|
|
36
|
+
},
|
|
37
|
+
gemini: {
|
|
38
|
+
childEnv: {
|
|
39
|
+
GOOGLE_GEMINI_BASE_URL: `${PROXY_URL}/gemini/`, // API-key auth path
|
|
40
|
+
CODE_ASSIST_ENDPOINT: `${PROXY_URL}/gemini`, // OAuth/Google login path
|
|
41
|
+
},
|
|
42
|
+
extraArgs: [],
|
|
43
|
+
serverEnv: {},
|
|
44
|
+
needsMitm: false,
|
|
45
|
+
},
|
|
46
|
+
pi: {
|
|
47
|
+
// Pi ignores standard base URL env vars. We point it at a temporary agent
|
|
48
|
+
// directory where cli.ts writes a proxy-aware models.json.
|
|
49
|
+
childEnv: {
|
|
50
|
+
PI_CODING_AGENT_DIR: PI_AGENT_DIR_PREFIX,
|
|
51
|
+
},
|
|
29
52
|
extraArgs: [],
|
|
30
53
|
serverEnv: {},
|
|
31
54
|
needsMitm: false,
|
|
32
55
|
},
|
|
33
56
|
};
|
|
34
57
|
export function getToolConfig(toolName) {
|
|
35
|
-
return TOOL_CONFIG[toolName] || {
|
|
36
|
-
childEnv: {
|
|
58
|
+
return (TOOL_CONFIG[toolName] || {
|
|
59
|
+
childEnv: {
|
|
60
|
+
ANTHROPIC_BASE_URL: `${PROXY_URL}/${toolName}`,
|
|
61
|
+
OPENAI_BASE_URL: `${PROXY_URL}/${toolName}`,
|
|
62
|
+
},
|
|
37
63
|
extraArgs: [],
|
|
38
64
|
serverEnv: {},
|
|
39
65
|
needsMitm: false,
|
|
40
|
-
};
|
|
66
|
+
});
|
|
41
67
|
}
|
|
42
68
|
// Exported for tests (and to keep cli.ts smaller).
|
|
43
69
|
export const CLI_CONSTANTS = {
|
|
44
70
|
PROXY_URL,
|
|
45
71
|
MITM_PORT,
|
|
46
72
|
MITM_PROXY_URL,
|
|
73
|
+
PI_AGENT_DIR_PREFIX,
|
|
47
74
|
// Resolved relative to compiled output (dist/ or dist-test/), matching cli.ts behavior.
|
|
48
|
-
MITM_ADDON_PATH: join(__dirname,
|
|
75
|
+
MITM_ADDON_PATH: join(__dirname, "..", "mitm_addon.py"),
|
|
49
76
|
};
|
|
50
77
|
//# sourceMappingURL=cli-utils.js.map
|
package/dist/cli-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-utils.js","sourceRoot":"","sources":["../src/cli-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli-utils.js","sourceRoot":"","sources":["../src/cli-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,sHAAsH;AACtH,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAC1C,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,MAAM,cAAc,GAAG,oBAAoB,SAAS,EAAE,CAAC;AACvD,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAE1D,MAAM,WAAW,GAA+B;IAC9C,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE,kBAAkB,EAAE,GAAG,SAAS,SAAS,EAAE;QACvD,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,KAAK;KACjB;IACD,KAAK,EAAE;QACL,uFAAuF;QACvF,kEAAkE;QAClE,QAAQ,EAAE;YACR,WAAW,EAAE,cAAc;YAC3B,aAAa,EAAE,IAAI,CACjB,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EACtB,YAAY,EACZ,uBAAuB,CACxB;SACF;QACD,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,IAAI;KAChB;IACD,KAAK,EAAE;QACL,QAAQ,EAAE;YACR,kBAAkB,EAAE,GAAG,SAAS,QAAQ;YACxC,eAAe,EAAE,GAAG,SAAS,QAAQ;SACtC;QACD,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,KAAK;KACjB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE;YACR,sBAAsB,EAAE,GAAG,SAAS,UAAU,EAAE,oBAAoB;YACpE,oBAAoB,EAAE,GAAG,SAAS,SAAS,EAAE,0BAA0B;SACxE;QACD,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,KAAK;KACjB;IACD,EAAE,EAAE;QACF,0EAA0E;QAC1E,2DAA2D;QAC3D,QAAQ,EAAE;YACR,mBAAmB,EAAE,mBAAmB;SACzC;QACD,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,KAAK;KACjB;CACF,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,OAAO,CACL,WAAW,CAAC,QAAQ,CAAC,IAAI;QACvB,QAAQ,EAAE;YACR,kBAAkB,EAAE,GAAG,SAAS,IAAI,QAAQ,EAAE;YAC9C,eAAe,EAAE,GAAG,SAAS,IAAI,QAAQ,EAAE;SAC5C;QACD,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,KAAK;KACjB,CACF,CAAC;AACJ,CAAC;AAED,mDAAmD;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,SAAS;IACT,SAAS;IACT,cAAc;IACd,mBAAmB;IACnB,wFAAwF;IACxF,eAAe,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,eAAe,CAAC;CAC/C,CAAC"}
|