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.
Files changed (119) hide show
  1. package/README.md +120 -25
  2. package/dist/cli-utils.d.ts +2 -1
  3. package/dist/cli-utils.d.ts.map +1 -1
  4. package/dist/cli-utils.js +40 -13
  5. package/dist/cli-utils.js.map +1 -1
  6. package/dist/cli.js +184 -68
  7. package/dist/cli.js.map +1 -1
  8. package/dist/core/conversation.d.ts +63 -0
  9. package/dist/core/conversation.d.ts.map +1 -0
  10. package/dist/core/conversation.js +305 -0
  11. package/dist/core/conversation.js.map +1 -0
  12. package/dist/core/health.d.ts +7 -0
  13. package/dist/core/health.d.ts.map +1 -0
  14. package/dist/core/health.js +311 -0
  15. package/dist/core/health.js.map +1 -0
  16. package/dist/core/models.d.ts +36 -0
  17. package/dist/core/models.d.ts.map +1 -0
  18. package/dist/core/models.js +111 -0
  19. package/dist/core/models.js.map +1 -0
  20. package/dist/core/parse.d.ts +17 -0
  21. package/dist/core/parse.d.ts.map +1 -0
  22. package/dist/core/parse.js +349 -0
  23. package/dist/core/parse.js.map +1 -0
  24. package/dist/core/routing.d.ts +47 -0
  25. package/dist/core/routing.d.ts.map +1 -0
  26. package/dist/core/routing.js +132 -0
  27. package/dist/core/routing.js.map +1 -0
  28. package/dist/core/security.d.ts +8 -0
  29. package/dist/core/security.d.ts.map +1 -0
  30. package/dist/core/security.js +222 -0
  31. package/dist/core/security.js.map +1 -0
  32. package/dist/core/source.d.ts +22 -0
  33. package/dist/core/source.d.ts.map +1 -0
  34. package/dist/core/source.js +56 -0
  35. package/dist/core/source.js.map +1 -0
  36. package/dist/core/tokens.d.ts +29 -0
  37. package/dist/core/tokens.d.ts.map +1 -0
  38. package/dist/core/tokens.js +163 -0
  39. package/dist/core/tokens.js.map +1 -0
  40. package/dist/core.d.ts +14 -22
  41. package/dist/core.d.ts.map +1 -1
  42. package/dist/core.js +14 -471
  43. package/dist/core.js.map +1 -1
  44. package/dist/http/headers.d.ts +25 -0
  45. package/dist/http/headers.d.ts.map +1 -0
  46. package/dist/http/headers.js +54 -0
  47. package/dist/http/headers.js.map +1 -0
  48. package/dist/lhar/composition.d.ts +12 -0
  49. package/dist/lhar/composition.d.ts.map +1 -0
  50. package/dist/lhar/composition.js +258 -0
  51. package/dist/lhar/composition.js.map +1 -0
  52. package/dist/lhar/export.d.ts +5 -0
  53. package/dist/lhar/export.d.ts.map +1 -0
  54. package/dist/lhar/export.js +59 -0
  55. package/dist/lhar/export.js.map +1 -0
  56. package/dist/lhar/record.d.ts +6 -0
  57. package/dist/lhar/record.d.ts.map +1 -0
  58. package/dist/lhar/record.js +216 -0
  59. package/dist/lhar/record.js.map +1 -0
  60. package/dist/lhar/response.d.ts +11 -0
  61. package/dist/lhar/response.d.ts.map +1 -0
  62. package/dist/lhar/response.js +132 -0
  63. package/dist/lhar/response.js.map +1 -0
  64. package/dist/lhar-types.generated.d.ts +24 -3
  65. package/dist/lhar-types.generated.d.ts.map +1 -1
  66. package/dist/lhar.d.ts +12 -19
  67. package/dist/lhar.d.ts.map +1 -1
  68. package/dist/lhar.js +16 -473
  69. package/dist/lhar.js.map +1 -1
  70. package/dist/server/api.d.ts +8 -0
  71. package/dist/server/api.d.ts.map +1 -0
  72. package/dist/server/api.js +292 -0
  73. package/dist/server/api.js.map +1 -0
  74. package/dist/server/config.d.ts +13 -0
  75. package/dist/server/config.d.ts.map +1 -0
  76. package/dist/server/config.js +36 -0
  77. package/dist/server/config.js.map +1 -0
  78. package/dist/server/projection.d.ts +9 -0
  79. package/dist/server/projection.d.ts.map +1 -0
  80. package/dist/server/projection.js +47 -0
  81. package/dist/server/projection.js.map +1 -0
  82. package/dist/server/proxy.d.ts +13 -0
  83. package/dist/server/proxy.d.ts.map +1 -0
  84. package/dist/server/proxy.js +218 -0
  85. package/dist/server/proxy.js.map +1 -0
  86. package/dist/server/static.d.ts +9 -0
  87. package/dist/server/static.d.ts.map +1 -0
  88. package/dist/server/static.js +78 -0
  89. package/dist/server/static.js.map +1 -0
  90. package/dist/server/store.d.ts +81 -0
  91. package/dist/server/store.d.ts.map +1 -0
  92. package/dist/server/store.js +632 -0
  93. package/dist/server/store.js.map +1 -0
  94. package/dist/server/webui.d.ts +5 -0
  95. package/dist/server/webui.d.ts.map +1 -0
  96. package/dist/server/webui.js +42 -0
  97. package/dist/server/webui.js.map +1 -0
  98. package/dist/server-utils.d.ts +2 -2
  99. package/dist/server-utils.d.ts.map +1 -1
  100. package/dist/server-utils.js +12 -21
  101. package/dist/server-utils.js.map +1 -1
  102. package/dist/server.js +31 -697
  103. package/dist/server.js.map +1 -1
  104. package/dist/types.d.ts +94 -10
  105. package/dist/types.d.ts.map +1 -1
  106. package/dist/version.generated.d.ts +2 -0
  107. package/dist/version.generated.d.ts.map +1 -0
  108. package/dist/version.generated.js +2 -0
  109. package/dist/version.generated.js.map +1 -0
  110. package/findings-screenshot.png +0 -0
  111. package/messages-screenshot.png +0 -0
  112. package/package.json +23 -10
  113. package/schema/lhar.schema.json +58 -4
  114. package/screenshot-overview.png +0 -0
  115. package/sessions-screenshot.png +0 -0
  116. package/timeline-screenshot.png +0 -0
  117. package/diff.png +0 -0
  118. package/overview-sidebar.png +0 -0
  119. package/public/index.html +0 -2804
package/README.md CHANGED
@@ -1,60 +1,98 @@
1
1
  # Context Lens
2
2
 
3
3
  ![Early Development](https://img.shields.io/badge/status-early%20development-orange)
4
+ [![CI](https://github.com/larsderidder/context-lens/actions/workflows/ci.yml/badge.svg)](https://github.com/larsderidder/context-lens/actions/workflows/ci.yml)
5
+ [![npm](https://img.shields.io/npm/v/context-lens)](https://www.npmjs.com/package/context-lens)
4
6
 
5
- I kept wondering why my Claude Code sessions got so expensive. I couldn't find a tool that showed me what was exactly in the context window. So I built one.
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
- Zero dependencies. Sits between your tool and the API, captures everything, gives you a web UI to explore it. I've tested with Claude, Codex and Aider.
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
  ![Context Lens UI](screenshot-overview.png)
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, just open more terminals.
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** visual breakdown of what's filling your context: system prompts, tool definitions, tool results, messages, thinking, images
25
- - **Cost tracking** per-turn and per-session cost estimates across models
26
- - **Conversation threading** groups API calls by session, shows main agent vs subagent turns
27
- - **Agent breakdown** token usage and cost per agent within a session
28
- - **Timeline** bar chart of context size over time, filterable by main/all/cost
29
- - **Context diff** turn-to-turn delta showing what grew, shrank, or appeared
30
- - **Findings** flags large tool results, unused tool definitions, context overflow risk, compaction events
31
- - **Auto-detection** recognizes Claude Code, Codex, aider, and others by source tag or system prompt
32
- - **LHAR export** download session data as LHAR (LLM HTTP Archive) format ([doc](docs/LHAR.md))
33
- - **State persistence** data survives restarts; delete individual sessions or reset all from the UI
34
- - **Streaming support** passes through SSE chunks in real-time
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
- **Findings**
71
+ **Sessions list**
39
72
 
40
- ![Findings panel](findings-screenshot.png)
73
+ ![Sessions list](sessions-screenshot.png)
41
74
 
42
- **Diff view**
75
+ **Messages view with drill-down details**
43
76
 
44
- ![Context diff view](diff.png)
77
+ ![Messages view](messages-screenshot.png)
45
78
 
46
- **Drill-down details**
79
+ **Timeline view**
47
80
 
48
- ![Drill-down details panel](overview-sidebar.png)
81
+ ![Timeline view](timeline-screenshot.png)
82
+
83
+ **Findings panel**
84
+
85
+ ![Findings panel](findings-screenshot.png)
49
86
 
50
87
  ## Manual Mode
51
88
 
52
89
  ```bash
53
- npm start
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 just make sure `mitmdump` is installed:
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 ──HTTP──▶ Context Lens (:4040) ──HTTPS──▶ api.anthropic.com / api.openai.com
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 ──HTTPS via proxy──▶ mitmproxy (:8080) ──HTTPS──▶ chatgpt.com
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.
@@ -1,9 +1,10 @@
1
- import type { ToolConfig } from './types.js';
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
@@ -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;AAoC7C,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAO1D;AAGD,eAAO,MAAM,aAAa;;;;;CAMhB,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 { join, dirname } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
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 = 'http://localhost:4040';
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
- 'claude': {
11
+ claude: {
11
12
  childEnv: { ANTHROPIC_BASE_URL: `${PROXY_URL}/claude` },
12
13
  extraArgs: [],
13
14
  serverEnv: {},
14
15
  needsMitm: false,
15
16
  },
16
- 'codex': {
17
- // Codex subscription uses chatgpt.com with Cloudflare needs forward proxy (mitmproxy)
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 || '', '.mitmproxy', 'mitmproxy-ca-cert.pem'),
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
- 'aider': {
28
- childEnv: { ANTHROPIC_BASE_URL: `${PROXY_URL}/aider`, OPENAI_BASE_URL: `${PROXY_URL}/aider` },
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: { ANTHROPIC_BASE_URL: `${PROXY_URL}/${toolName}`, OPENAI_BASE_URL: `${PROXY_URL}/${toolName}` },
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, '..', 'mitm_addon.py'),
75
+ MITM_ADDON_PATH: join(__dirname, "..", "mitm_addon.py"),
49
76
  };
50
77
  //# sourceMappingURL=cli-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli-utils.js","sourceRoot":"","sources":["../src/cli-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,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,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