@sliday/tamp 0.8.16 → 0.8.17

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 CHANGED
@@ -98,7 +98,7 @@ env_key = "OPENAI_API_KEY"
98
98
  wire_api = "responses"
99
99
  ```
100
100
 
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.
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` and `custom_tool_call_output` block, including outputs carried as `input_text` content arrays.
102
102
 
103
103
  **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
104
 
@@ -106,7 +106,9 @@ Then `export OPENAI_API_KEY=sk-...` and run `codex` or `codex exec "..."` as usu
106
106
  openai_base_url = "http://localhost:7778/v1"
107
107
  ```
108
108
 
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.
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. Verified against `codex-cli 0.146.0`.
110
+
111
+ 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
112
 
111
113
  ### Cursor
112
114
 
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/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "sidecar/server.py",
15
15
  "sidecar/requirements.txt"
16
16
  ],
17
- "version": "0.8.16",
17
+ "version": "0.8.17",
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
- "prepublishOnly": "node scripts/publish-guard.js",
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 !== 'function_call_output') return []
477
- if (typeof item.output !== 'string') return []
478
- return [{ path: ['input', i, 'output'], text: item.output, index: i }]
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 !== 'function_call_output') break
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 /backend-api/codex<rest>.
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
- return '/backend-api/codex' + path
629
+ const unversioned = path.replace(/^\/v1(?=\/|$)/, '')
630
+ return '/backend-api/codex' + unversioned
608
631
  },
609
632
  mode,
610
633
  providerName,