@sliday/tamp 0.8.16 → 0.8.19
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 +70 -5
- package/bin/tamp.js +80 -6
- package/compress.js +27 -1
- package/index.js +18 -2
- package/lib/rules-generator.js +8 -5
- package/package.json +2 -3
- package/providers.js +29 -6
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ The plugin adds `/tamp:status` and `/tamp:config` commands. It auto-starts Tamp
|
|
|
20
20
|
{ "env": { "ANTHROPIC_BASE_URL": "http://localhost:7778" } }
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
That line makes Claude Code depend on Tamp. Run `tamp install-service` in the same sitting so the proxy is up at every login, and keep `~/.claude/settings.json.backup` until you trust the setup. To undo, delete the `ANTHROPIC_BASE_URL` key.
|
|
24
|
+
|
|
23
25
|
### 🦞 OpenClaw
|
|
24
26
|
|
|
25
27
|
```bash
|
|
@@ -70,6 +72,20 @@ curl -s http://localhost:8788/health # Verify: {"status":"ok","model_loaded":tru
|
|
|
70
72
|
tamp stop && tamp -y # restart Tamp, health endpoint will show `sidecar: ok`
|
|
71
73
|
```
|
|
72
74
|
|
|
75
|
+
**What it will not touch.** LLMLingua-2 paraphrases, and a paraphrased file path is a broken file path. At the default rate of 0.7 it turned real command output into this:
|
|
76
|
+
|
|
77
|
+
| Before | After |
|
|
78
|
+
|--------|-------|
|
|
79
|
+
| `/Users/x/.config/tamp/tamp.err.log` | `/Users/x./tamp..` |
|
|
80
|
+
| `"version":"0.8.17"` | `"version""0.. 17"` |
|
|
81
|
+
| `launchctl bootout gui/501/dev.tamp.proxy` | `launchctl bootout gui/501/dev..` |
|
|
82
|
+
|
|
83
|
+
So Tamp skips the sidecar for any block carrying paths, URLs, JSON separators, hex ids, or semver, and sends only prose. Across Tamp's own benchmark fixtures that guard fires on 92% of text blocks, which is the honest measure of how much `llmlingua` contributes to a coding agent: very little. Keep it for doc-heavy and web-fetch traffic, drop it if you want a fully lossless pipeline:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
TAMP_STAGES=cmd-strip,minify,toon,strip-lines,whitespace,dedup,diff,read-diff,prune tamp -y
|
|
87
|
+
```
|
|
88
|
+
|
|
73
89
|
## Quick Start
|
|
74
90
|
|
|
75
91
|
```bash
|
|
@@ -98,7 +114,7 @@ env_key = "OPENAI_API_KEY"
|
|
|
98
114
|
wire_api = "responses"
|
|
99
115
|
```
|
|
100
116
|
|
|
101
|
-
Then `export OPENAI_API_KEY=sk-...` and run `codex` or `codex exec "..."` as usual. Tamp routes `/v1/responses` through the `openai-responses` adapter and compresses every `function_call_output` block.
|
|
117
|
+
Then `export OPENAI_API_KEY=sk-...` and run `codex` or `codex exec "..."` as usual. Tamp routes `/v1/responses` through the `openai-responses` adapter and compresses every `function_call_output` and `custom_tool_call_output` block, including outputs carried as `input_text` content arrays.
|
|
102
118
|
|
|
103
119
|
**ChatGPT Plus / Pro subscription.** If you sign in with `codex login` instead of using an API key, add this line to `~/.codex/config.toml`:
|
|
104
120
|
|
|
@@ -106,7 +122,9 @@ Then `export OPENAI_API_KEY=sk-...` and run `codex` or `codex exec "..."` as usu
|
|
|
106
122
|
openai_base_url = "http://localhost:7778/v1"
|
|
107
123
|
```
|
|
108
124
|
|
|
109
|
-
Tamp detects OAuth bearer tokens and routes them to `chatgpt.com/backend-api/codex` automatically, so your ChatGPT Plus/Pro subscription keeps paying for inference while Tamp compresses every tool result in flight.
|
|
125
|
+
Tamp detects OAuth bearer tokens and routes them to `chatgpt.com/backend-api/codex` automatically, so your ChatGPT Plus/Pro subscription keeps paying for inference while Tamp compresses every tool result in flight. Verified against `codex-cli 0.146.0`.
|
|
126
|
+
|
|
127
|
+
One transport caveat: Codex 0.146 opens a WebSocket to `<base>/responses` first. Tamp proxies HTTP only, so it answers that upgrade with `501` and Codex falls back to its HTTPS transport. Expect a handful of `failed to connect to websocket` lines in the log; the session then runs normally.
|
|
110
128
|
|
|
111
129
|
### Cursor
|
|
112
130
|
|
|
@@ -136,6 +154,29 @@ opencode **silently ignores** `OPENAI_API_BASE` / `OPENAI_BASE_URL`. Configure b
|
|
|
136
154
|
|
|
137
155
|
Restart opencode. Tamp's adapter table routes each provider to the correct upstream.
|
|
138
156
|
|
|
157
|
+
### Kimi Code
|
|
158
|
+
|
|
159
|
+
Config lives at `~/.kimi-code/config.toml` (not `~/.kimi/`), and the provider table is named after the managed provider:
|
|
160
|
+
|
|
161
|
+
```toml
|
|
162
|
+
[providers."managed:kimi-code"]
|
|
163
|
+
base_url = "http://localhost:7778/kimi/coding/v1"
|
|
164
|
+
|
|
165
|
+
# Moonshot API key instead of a subscription:
|
|
166
|
+
[providers.moonshot]
|
|
167
|
+
base_url = "http://localhost:7778/moonshot/v1"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
> **Read this before you edit that file.** Kimi Code stores its OAuth token under a key derived from the provider environment, and `base_url` is part of that key. Change the URL and the CLI loses the token it already has:
|
|
171
|
+
>
|
|
172
|
+
> ```
|
|
173
|
+
> No token for "kimi-code-env-92f579c50dab5f50". Run /login to authenticate.
|
|
174
|
+
> ```
|
|
175
|
+
>
|
|
176
|
+
> Every running agent fails at once, including background ones. Run `/login` in Kimi after the edit to re-authenticate under the new key, or leave `base_url` alone and accept no compression on Kimi. Restoring the original URL restores the original token.
|
|
177
|
+
|
|
178
|
+
An API-key Moonshot setup has no such problem; only the OAuth subscription path is affected.
|
|
179
|
+
|
|
139
180
|
### VS Code
|
|
140
181
|
|
|
141
182
|
#### Cline (recommended)
|
|
@@ -315,10 +356,34 @@ npx @sliday/tamp
|
|
|
315
356
|
# npm global
|
|
316
357
|
npm install -g @sliday/tamp
|
|
317
358
|
tamp
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Keep it running
|
|
362
|
+
|
|
363
|
+
Read this before you point an agent at Tamp permanently. Once `ANTHROPIC_BASE_URL` (or a `config.toml` `base_url`) names `localhost:7778`, that agent talks to nothing when Tamp is down. Every session fails until you start it again.
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
tamp install-service # launchd on macOS, systemd user unit on Linux
|
|
367
|
+
tamp status # confirm it came up
|
|
368
|
+
tamp uninstall-service # remove it
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
macOS installs `~/Library/LaunchAgents/dev.tamp.proxy.plist` with `RunAtLoad` and `KeepAlive`, so Tamp starts at login and restarts if it dies. Logs land in `~/.config/tamp/tamp.err.log`.
|
|
372
|
+
|
|
373
|
+
If you would rather not add a background service, keep the agent on its normal endpoint and start Tamp by hand when you want the savings.
|
|
318
374
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
375
|
+
### Verify a global install actually replaced the old one
|
|
376
|
+
|
|
377
|
+
`npm install -g` writes to `npm config get prefix`, which is not always the directory your shell resolves from. Check the copy you actually run:
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
grep '"version"' "$(dirname "$(readlink -f "$(command -v tamp)")")/../package.json"
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
If that disagrees with `npm view @sliday/tamp version`, install into the prefix your PATH uses:
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
npm install -g --prefix "$(dirname "$(dirname "$(readlink -f "$(command -v tamp)")")")" @sliday/tamp
|
|
322
387
|
```
|
|
323
388
|
|
|
324
389
|
## Monitoring
|
package/bin/tamp.js
CHANGED
|
@@ -220,9 +220,66 @@ if (subcommand === 'settings' || subcommand === 'config') {
|
|
|
220
220
|
instance = render(h(LevelPicker, { version: VERSION, envLevel, onSelect, onCancel }))
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
// macOS LaunchAgent. Pointing an agent's base URL at Tamp makes that agent
|
|
224
|
+
// depend on Tamp being up, so "run it by hand in a terminal" is not a real
|
|
225
|
+
// answer once you route Claude Code or Codex through it.
|
|
226
|
+
const LAUNCH_AGENT_LABEL = 'dev.tamp.proxy'
|
|
227
|
+
const LAUNCH_AGENT_PATH = join(homedir(), 'Library', 'LaunchAgents', `${LAUNCH_AGENT_LABEL}.plist`)
|
|
228
|
+
|
|
229
|
+
if (subcommand === 'install-service' && process.platform === 'darwin') {
|
|
230
|
+
const nodeBin = process.execPath
|
|
231
|
+
const tampBin = join(__dirname, 'tamp.js')
|
|
232
|
+
const logDir = join(homedir(), '.config', 'tamp')
|
|
233
|
+
mkdirSync(logDir, { recursive: true })
|
|
234
|
+
mkdirSync(dirname(LAUNCH_AGENT_PATH), { recursive: true })
|
|
235
|
+
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
236
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
237
|
+
<plist version="1.0">
|
|
238
|
+
<dict>
|
|
239
|
+
<key>Label</key><string>${LAUNCH_AGENT_LABEL}</string>
|
|
240
|
+
<key>ProgramArguments</key>
|
|
241
|
+
<array>
|
|
242
|
+
<string>${nodeBin}</string>
|
|
243
|
+
<string>${tampBin}</string>
|
|
244
|
+
<string>-y</string>
|
|
245
|
+
<string>--force</string>
|
|
246
|
+
</array>
|
|
247
|
+
<key>RunAtLoad</key><true/>
|
|
248
|
+
<key>KeepAlive</key><true/>
|
|
249
|
+
<key>StandardOutPath</key><string>${join(logDir, 'tamp.out.log')}</string>
|
|
250
|
+
<key>StandardErrorPath</key><string>${join(logDir, 'tamp.err.log')}</string>
|
|
251
|
+
</dict>
|
|
252
|
+
</plist>
|
|
253
|
+
`
|
|
254
|
+
writeFileSync(LAUNCH_AGENT_PATH, plist)
|
|
255
|
+
const uid = process.getuid()
|
|
256
|
+
try { execFileSync('launchctl', ['bootout', `gui/${uid}/${LAUNCH_AGENT_LABEL}`], { stdio: 'ignore' }) } catch {}
|
|
257
|
+
try {
|
|
258
|
+
execFileSync('launchctl', ['bootstrap', `gui/${uid}`, LAUNCH_AGENT_PATH], { stdio: 'inherit' })
|
|
259
|
+
execFileSync('launchctl', ['enable', `gui/${uid}/${LAUNCH_AGENT_LABEL}`], { stdio: 'ignore' })
|
|
260
|
+
console.log(`\nLaunchAgent installed: ${LAUNCH_AGENT_PATH}`)
|
|
261
|
+
console.log(' Status: tamp status')
|
|
262
|
+
console.log(` Logs: tail -f ${join(logDir, 'tamp.err.log')}`)
|
|
263
|
+
console.log(` Stop: launchctl bootout gui/${uid}/${LAUNCH_AGENT_LABEL}`)
|
|
264
|
+
console.log(' Remove: tamp uninstall-service')
|
|
265
|
+
} catch (e) {
|
|
266
|
+
console.error('launchctl failed:', e.message)
|
|
267
|
+
process.exit(1)
|
|
268
|
+
}
|
|
269
|
+
process.exit(0)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (subcommand === 'uninstall-service' && process.platform === 'darwin') {
|
|
273
|
+
const uid = process.getuid()
|
|
274
|
+
try { execFileSync('launchctl', ['bootout', `gui/${uid}/${LAUNCH_AGENT_LABEL}`], { stdio: 'ignore' }) } catch {}
|
|
275
|
+
try { unlinkSync(LAUNCH_AGENT_PATH) } catch {}
|
|
276
|
+
console.log('LaunchAgent removed.')
|
|
277
|
+
process.exit(0)
|
|
278
|
+
}
|
|
279
|
+
|
|
223
280
|
if (subcommand === 'install-service') {
|
|
224
281
|
if (process.platform !== 'linux') {
|
|
225
|
-
console.error('Service installation requires Linux (systemd).')
|
|
282
|
+
console.error('Service installation requires Linux (systemd) or macOS (launchd).')
|
|
226
283
|
process.exit(1)
|
|
227
284
|
}
|
|
228
285
|
const nodeBin = process.execPath
|
|
@@ -262,7 +319,7 @@ WantedBy=default.target
|
|
|
262
319
|
|
|
263
320
|
if (subcommand === 'uninstall-service') {
|
|
264
321
|
if (process.platform !== 'linux') {
|
|
265
|
-
console.error('Service management requires Linux (systemd).')
|
|
322
|
+
console.error('Service management requires Linux (systemd) or macOS (launchd).')
|
|
266
323
|
process.exit(1)
|
|
267
324
|
}
|
|
268
325
|
const unitPath = join(homedir(), '.config', 'systemd', 'user', 'tamp.service')
|
|
@@ -385,8 +442,8 @@ if (subcommand === 'help' || subcommand === '--help' || subcommand === '-h' || p
|
|
|
385
442
|
console.log(' init Create config file (~/.config/tamp/config)')
|
|
386
443
|
console.log(' settings Edit compression level and stages')
|
|
387
444
|
console.log(' status Check if proxy is running')
|
|
388
|
-
console.log(' install-service
|
|
389
|
-
console.log(' uninstall-service Remove
|
|
445
|
+
console.log(' install-service Keep Tamp running (launchd on macOS, systemd on Linux)')
|
|
446
|
+
console.log(' uninstall-service Remove the service')
|
|
390
447
|
console.log(' help Show this help')
|
|
391
448
|
console.log('')
|
|
392
449
|
console.log('Options:')
|
|
@@ -399,8 +456,25 @@ if (subcommand === 'help' || subcommand === '--help' || subcommand === '-h' || p
|
|
|
399
456
|
const skipPrompt = process.argv.includes('-y') || process.argv.includes('--no-interactive') || !process.stdin.isTTY
|
|
400
457
|
const forceReplace = process.argv.includes('--force')
|
|
401
458
|
|
|
402
|
-
|
|
403
|
-
|
|
459
|
+
// TAMP_STAGES may come from the environment or from ~/.config/tamp/config.
|
|
460
|
+
// Reading only process.env meant a stage list written to the config file was
|
|
461
|
+
// silently overwritten by DEFAULT_STAGES on every `tamp -y`, so the documented
|
|
462
|
+
// knob did nothing on the non-interactive path most people use.
|
|
463
|
+
function readStagesSetting() {
|
|
464
|
+
if (process.env.TAMP_STAGES) return process.env.TAMP_STAGES
|
|
465
|
+
try {
|
|
466
|
+
const line = readFileSync(CONFIG_PATH, 'utf8')
|
|
467
|
+
.split('\n')
|
|
468
|
+
.map(l => l.trim())
|
|
469
|
+
.filter(l => l && !l.startsWith('#'))
|
|
470
|
+
.find(l => l.startsWith('TAMP_STAGES='))
|
|
471
|
+
return line ? line.slice('TAMP_STAGES='.length).trim() : null
|
|
472
|
+
} catch { return null }
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const stagesSetting = readStagesSetting()
|
|
476
|
+
const envStages = stagesSetting
|
|
477
|
+
? new Set(stagesSetting.split(',').map(s => s.trim()).filter(Boolean))
|
|
404
478
|
: null
|
|
405
479
|
|
|
406
480
|
async function ensurePortFree(port) {
|
package/compress.js
CHANGED
|
@@ -373,6 +373,22 @@ async function textpressCompress(text, config) {
|
|
|
373
373
|
return null
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
+
// Content an agent must be able to copy back out byte for byte. Neural
|
|
377
|
+
// compressors paraphrase, and a paraphrased path is a broken path.
|
|
378
|
+
const VERBATIM_CRITICAL = [
|
|
379
|
+
/(?:^|[\s"'(=])\.{0,2}\/[\w.\-]+\/[\w.\-]+/, // /usr/local, ./src/app, ../a/b
|
|
380
|
+
/[A-Za-z]:\\[\w.\-]+\\/, // C:\Users\x\
|
|
381
|
+
/\bhttps?:\/\//, // urls
|
|
382
|
+
/"\s*:\s*/, // json key/value separators
|
|
383
|
+
/[{[]\s*"/, // json object/array openers
|
|
384
|
+
/\b[0-9a-f]{7,}\b/, // sha/commit/hex ids
|
|
385
|
+
/\bv?\d+\.\d+\.\d+\b/, // semver
|
|
386
|
+
]
|
|
387
|
+
|
|
388
|
+
export function hasVerbatimCriticalContent(text) {
|
|
389
|
+
return VERBATIM_CRITICAL.some(re => re.test(text))
|
|
390
|
+
}
|
|
391
|
+
|
|
376
392
|
// --- Core compression ---
|
|
377
393
|
export function compressText(text, config) {
|
|
378
394
|
if (text.length < config.minSize) { if (config.log !== false) process.stderr.write(`[tamp] skip: too small (${text.length} < ${config.minSize})\n`); return null }
|
|
@@ -410,7 +426,17 @@ export function compressText(text, config) {
|
|
|
410
426
|
return { text: processed, method, originalLen: text.length, compressedLen: processed.length, originalTokens: countTokens(text), compressedTokens: countTokens(processed) }
|
|
411
427
|
}
|
|
412
428
|
if (config.stages.includes('llmlingua') && config.llmLinguaUrl) {
|
|
413
|
-
|
|
429
|
+
// LLMLingua-2 is a prose compressor. On tool output it drops characters
|
|
430
|
+
// from the middle of tokens the agent has to reuse verbatim:
|
|
431
|
+
// /Users/x/.config/tamp/tamp.err.log -> /Users/x./tamp..
|
|
432
|
+
// "version":"0.8.17" -> "version""0.. 17"
|
|
433
|
+
// A path the agent cannot cat is worse than a payload it cannot shrink,
|
|
434
|
+
// so anything carrying paths, URLs, JSON or hashes skips the sidecar.
|
|
435
|
+
if (hasVerbatimCriticalContent(processed)) {
|
|
436
|
+
if (config.log !== false) process.stderr.write('[tamp] skip: llmlingua (verbatim-critical content: paths/JSON/urls/hashes)\n')
|
|
437
|
+
} else {
|
|
438
|
+
return { async: true, asyncMethod: 'llmlingua', text: processed, cls }
|
|
439
|
+
}
|
|
414
440
|
}
|
|
415
441
|
if (config.stages.includes('foundation-models') && config.foundationModelsPath) {
|
|
416
442
|
return { async: true, asyncMethod: 'foundation-models', text: processed, cls }
|
package/index.js
CHANGED
|
@@ -92,6 +92,10 @@ export function createProxy(overrides = {}, loadOpts = {}) {
|
|
|
92
92
|
: null
|
|
93
93
|
const sessionStore = createSessionStore({ brCache })
|
|
94
94
|
const readCache = createReadCache()
|
|
95
|
+
// `tamp -y` starts the sidecar itself and hands the URL down via env, so the
|
|
96
|
+
// isMain probe below never runs and /health kept reporting sidecar:false
|
|
97
|
+
// while llmlingua was in fact wired up. Probe here too, quietly.
|
|
98
|
+
if (config.stages?.includes('llmlingua') && config.llmLinguaUrl) probeSidecar(config, true)
|
|
95
99
|
return { config, session, sessionStore, readCache, brCache, server: _createServer(config, session, sessionStore, readCache, brCache) }
|
|
96
100
|
}
|
|
97
101
|
|
|
@@ -189,6 +193,17 @@ function pipeRequest(req, res, upstreamUrl, prefixChunks) {
|
|
|
189
193
|
}
|
|
190
194
|
|
|
191
195
|
return http.createServer(async (req, res) => {
|
|
196
|
+
// Codex CLI 0.146+ opens a WebSocket to <base>/responses before falling
|
|
197
|
+
// back to HTTPS. Tamp only proxies HTTP, and forwarding the upgrade
|
|
198
|
+
// upstream earns a Cloudflare 503 that Codex retries five times (~17s of
|
|
199
|
+
// dead time per session). Refuse it locally and immediately: 501 is not
|
|
200
|
+
// retryable, so Codex drops to the HTTP transport on the first try.
|
|
201
|
+
if (String(req.headers.upgrade || '').toLowerCase() === 'websocket') {
|
|
202
|
+
const body = JSON.stringify({ error: { message: 'Tamp does not proxy WebSocket transport; use HTTP.', type: 'not_implemented' } })
|
|
203
|
+
res.writeHead(501, { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body), Connection: 'close' })
|
|
204
|
+
return res.end(body)
|
|
205
|
+
}
|
|
206
|
+
|
|
192
207
|
// Health check endpoint
|
|
193
208
|
if ((req.url === '/health' || req.url === '/health?text') && (req.method === 'GET' || req.method === 'HEAD')) {
|
|
194
209
|
const totals = session.getTotals()
|
|
@@ -401,17 +416,18 @@ const SIDECAR_URL = `http://localhost:${SIDECAR_PORT}`
|
|
|
401
416
|
|
|
402
417
|
let sidecarAvailable = false
|
|
403
418
|
|
|
404
|
-
function probeSidecar(config) {
|
|
419
|
+
function probeSidecar(config, quiet = false) {
|
|
405
420
|
const req = http.get(`${SIDECAR_URL}/health`, { timeout: 2000 }, (res) => {
|
|
406
421
|
if (res.statusCode === 200) {
|
|
407
422
|
sidecarAvailable = true
|
|
408
423
|
if (!config.llmLinguaUrl) config.llmLinguaUrl = SIDECAR_URL
|
|
409
|
-
console.error(`[tamp] llmlingua sidecar: ok (${config.llmLinguaUrl})`)
|
|
424
|
+
if (!quiet) console.error(`[tamp] llmlingua sidecar: ok (${config.llmLinguaUrl})`)
|
|
410
425
|
}
|
|
411
426
|
res.resume()
|
|
412
427
|
})
|
|
413
428
|
req.on('error', () => {
|
|
414
429
|
sidecarAvailable = false
|
|
430
|
+
if (quiet) return
|
|
415
431
|
console.error('[tamp] \u26a0 llmlingua stage enabled but sidecar not running \u2014 text blocks won\u2019t compress')
|
|
416
432
|
console.error('[tamp] start with: uv run --with fastapi --with uvicorn --with llmlingua --with mlx uvicorn server:app --host 127.0.0.1 --port 8788 --app-dir sidecar')
|
|
417
433
|
})
|
package/lib/rules-generator.js
CHANGED
|
@@ -14,15 +14,18 @@ const SAFE_TASK_PATTERNS = [
|
|
|
14
14
|
/^(format|lint|fmt)|run linter/i,
|
|
15
15
|
]
|
|
16
16
|
|
|
17
|
-
// Dangerous task patterns: require detailed output
|
|
17
|
+
// Dangerous task patterns: require detailed output.
|
|
18
|
+
// Keyword alternations need \b on both ends: unanchored, `latest`/`contest` hit
|
|
19
|
+
// `test` and `specific`/`inspect` hit `spec`, and one false positive disables
|
|
20
|
+
// disclosure (compress.js:136) and bm25-trim (compress.js:168) for the session.
|
|
18
21
|
const DANGEROUS_TASK_PATTERNS = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
/\bsecurity\b|\bvulnerabilit\w*|\bexploit\w*|\battack\w*/i,
|
|
23
|
+
/\bdebug\w*|\binvestigat\w*|\bdiagnos\w*|\btroubleshoot\w*/i,
|
|
24
|
+
/\bmemory leak\b|\bperforman\w*|\boptimi[sz]\w*/i,
|
|
22
25
|
/^refactor|^architecture|^design/i,
|
|
23
26
|
/^fix\s+bug/i,
|
|
24
27
|
/^explain|^why|^how\s+(does|work)/i,
|
|
25
|
-
|
|
28
|
+
/\btest(s|ing)?\b|\bspecs?\b|\bcoverage\b/i,
|
|
26
29
|
]
|
|
27
30
|
|
|
28
31
|
/**
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"sidecar/server.py",
|
|
15
15
|
"sidecar/requirements.txt"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.8.
|
|
17
|
+
"version": "0.8.19",
|
|
18
18
|
"description": "Token compression proxy for coding agents. Works with Claude Code, Aider, Cursor, Cline, Windsurf. 60-70% combined input+output savings with Caveman-integrated presets and per-command rewriters.",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"main": "index.js",
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"start": "node bin/tamp.js",
|
|
26
|
-
"
|
|
27
|
-
"test": "node --test test/*.test.js",
|
|
26
|
+
"test": "node --test test/*.test.js && node bench/retrieval-eval.js",
|
|
28
27
|
"test:sidecar": "node test/capture-golden.js --verify",
|
|
29
28
|
"bench:semantic": "node bench/semantic-eval.js",
|
|
30
29
|
"bench:retrieval": "node bench/retrieval-eval.js",
|
package/providers.js
CHANGED
|
@@ -472,10 +472,30 @@ const gemini = {
|
|
|
472
472
|
},
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
+
// Codex CLI 0.146 emits two tool-result item types (`function_call_output`
|
|
476
|
+
// for JSON-schema tools, `custom_tool_call_output` for freeform ones) and
|
|
477
|
+
// carries `output` either as a plain string (older wire format) or as an
|
|
478
|
+
// array of `input_text` content parts. Matching only the string form left
|
|
479
|
+
// every Codex tool result uncompressed.
|
|
480
|
+
function isResponsesToolOutput(type) {
|
|
481
|
+
return type === 'function_call_output' || type === 'custom_tool_call_output'
|
|
482
|
+
}
|
|
483
|
+
|
|
475
484
|
function extractOpenAIResponsesTargets(item, i) {
|
|
476
|
-
if (item?.type
|
|
477
|
-
if (typeof item.output
|
|
478
|
-
|
|
485
|
+
if (!isResponsesToolOutput(item?.type)) return []
|
|
486
|
+
if (typeof item.output === 'string') {
|
|
487
|
+
return [{ path: ['input', i, 'output'], text: item.output, index: i }]
|
|
488
|
+
}
|
|
489
|
+
if (Array.isArray(item.output)) {
|
|
490
|
+
const targets = []
|
|
491
|
+
for (const [j, part] of item.output.entries()) {
|
|
492
|
+
if (part?.type === 'input_text' && typeof part.text === 'string') {
|
|
493
|
+
targets.push({ path: ['input', i, 'output', j, 'text'], text: part.text, index: i })
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return targets
|
|
497
|
+
}
|
|
498
|
+
return []
|
|
479
499
|
}
|
|
480
500
|
|
|
481
501
|
const openaiResponses = {
|
|
@@ -497,7 +517,7 @@ const openaiResponses = {
|
|
|
497
517
|
const targets = []
|
|
498
518
|
for (let i = body.input.length - 1; i >= 0; i--) {
|
|
499
519
|
const item = body.input[i]
|
|
500
|
-
if (item?.type
|
|
520
|
+
if (!isResponsesToolOutput(item?.type)) break
|
|
501
521
|
targets.unshift(...extractOpenAIResponsesTargets(item, i))
|
|
502
522
|
}
|
|
503
523
|
return targets
|
|
@@ -602,9 +622,12 @@ export function resolveOpenAIUpstream({ mode, base, providerName }) {
|
|
|
602
622
|
base: 'https://chatgpt.com',
|
|
603
623
|
transformPath(path) {
|
|
604
624
|
// Codex calls land on /v1/responses or /v1/chat/completions. The
|
|
605
|
-
// ChatGPT backend expects
|
|
625
|
+
// ChatGPT backend is unversioned and expects
|
|
626
|
+
// /backend-api/codex/responses — keeping the /v1 segment yields a
|
|
627
|
+
// 404 {"detail":"Not Found"} from chatgpt.com.
|
|
606
628
|
if (path.startsWith('/backend-api/codex')) return path
|
|
607
|
-
|
|
629
|
+
const unversioned = path.replace(/^\/v1(?=\/|$)/, '')
|
|
630
|
+
return '/backend-api/codex' + unversioned
|
|
608
631
|
},
|
|
609
632
|
mode,
|
|
610
633
|
providerName,
|