@sliday/tamp 0.3.13 → 0.4.1

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
@@ -12,6 +12,17 @@ Or install globally:
12
12
  npm i -g @sliday/tamp
13
13
  ```
14
14
 
15
+ ### Claude Code plugin
16
+
17
+ Auto-start Tamp on every session — no manual setup:
18
+
19
+ ```bash
20
+ claude plugin marketplace add sliday/claude-plugins
21
+ claude plugin install tamp@sliday
22
+ ```
23
+
24
+ That's it. The plugin starts the proxy automatically, tells you if something's wrong, and adds `/tamp:status` and `/tamp:config` commands.
25
+
15
26
  ### 🦞 OpenClaw Quick Setup
16
27
 
17
28
  ```bash
@@ -113,7 +124,27 @@ That's it. Use your agent as normal — Tamp compresses silently in the backgrou
113
124
 
114
125
  ## Configuration
115
126
 
116
- All configuration via environment variables:
127
+ ### Config file
128
+
129
+ Run `tamp init` to create a persistent config file:
130
+
131
+ ```bash
132
+ tamp init
133
+ # Creates ~/.config/tamp/config
134
+ ```
135
+
136
+ Edit the file to set your defaults. All `TAMP_*` variables are supported. Environment variables still override the config file.
137
+
138
+ ```bash
139
+ # ~/.config/tamp/config
140
+ TAMP_PORT=7778
141
+ TAMP_UPSTREAM=https://api.anthropic.com
142
+ TAMP_STAGES=minify,toon,strip-lines,whitespace,dedup,diff,prune
143
+ ```
144
+
145
+ ### Environment variables
146
+
147
+ All configuration also works via environment variables (override config file):
117
148
 
118
149
  | Variable | Default | Description |
119
150
  |----------|---------|-------------|
@@ -168,6 +199,23 @@ cd tamp && npm install
168
199
  node bin/tamp.js
169
200
  ```
170
201
 
202
+ ### Systemd service (Ubuntu/Linux)
203
+
204
+ ```bash
205
+ npm i -g @sliday/tamp
206
+ tamp init # create config file
207
+ tamp install-service # install + start systemd user service
208
+ ```
209
+
210
+ Manages itself via `systemctl --user`. Starts on login, restarts on crash.
211
+
212
+ ```bash
213
+ tamp status # check if running
214
+ systemctl --user status tamp
215
+ journalctl --user -u tamp -f
216
+ tamp uninstall-service # remove
217
+ ```
218
+
171
219
  ### One-line installer
172
220
 
173
221
  ```bash
@@ -198,7 +246,7 @@ index.js HTTP proxy server
198
246
  providers.js API format adapters (Anthropic, OpenAI, Gemini) + auto-detection
199
247
  compress.js Compression pipeline (compressRequest, compressText)
200
248
  detect.js Content classification (classifyContent, tryParseJSON, stripLineNumbers)
201
- config.js Environment-based configuration
249
+ config.js Configuration (env vars + ~/.config/tamp/config)
202
250
  stats.js Session statistics and request logging
203
251
  setup.sh One-line installer script
204
252
  ```
package/bin/tamp.js CHANGED
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import { createProxy } from '../index.js'
3
- import { existsSync } from 'node:fs'
3
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, unlinkSync } from 'node:fs'
4
4
  import { spawn, execFileSync } from 'node:child_process'
5
5
  import { fileURLToPath } from 'node:url'
6
6
  import { dirname, join } from 'node:path'
7
+ import { homedir } from 'node:os'
7
8
  import http from 'node:http'
8
9
  import { DEFAULT_STAGES, EXTRA_STAGES, STAGE_DESCRIPTIONS, VERSION } from '../metadata.js'
10
+ import { CONFIG_PATH, CONFIG_TEMPLATE } from '../config.js'
9
11
 
10
12
  const __dirname = dirname(fileURLToPath(import.meta.url))
11
13
  const root = join(__dirname, '..')
@@ -77,6 +79,104 @@ export async function startSidecar() {
77
79
  return null
78
80
  }
79
81
 
82
+ // --- Subcommands ---
83
+ const subcommand = process.argv[2]
84
+
85
+ if (subcommand === 'init') {
86
+ const dir = dirname(CONFIG_PATH)
87
+ if (existsSync(CONFIG_PATH)) {
88
+ console.log(`Config file exists: ${CONFIG_PATH}\n`)
89
+ console.log(readFileSync(CONFIG_PATH, 'utf8'))
90
+ } else {
91
+ mkdirSync(dir, { recursive: true })
92
+ writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE)
93
+ console.log(`Created config file: ${CONFIG_PATH}`)
94
+ console.log('Edit it to set your defaults. Environment variables still override.\n')
95
+ console.log(CONFIG_TEMPLATE)
96
+ }
97
+ process.exit(0)
98
+ }
99
+
100
+ if (subcommand === 'install-service') {
101
+ if (process.platform !== 'linux') {
102
+ console.error('Service installation requires Linux (systemd).')
103
+ process.exit(1)
104
+ }
105
+ const nodeBin = process.execPath
106
+ const tampBin = join(__dirname, 'tamp.js')
107
+ const unitDir = join(homedir(), '.config', 'systemd', 'user')
108
+ const unitPath = join(unitDir, 'tamp.service')
109
+ const unit = `[Unit]
110
+ Description=Tamp token compression proxy
111
+ After=network.target
112
+
113
+ [Service]
114
+ Type=simple
115
+ ExecStart=${nodeBin} ${tampBin} -y
116
+ Restart=always
117
+ RestartSec=5
118
+ EnvironmentFile=-${CONFIG_PATH}
119
+
120
+ [Install]
121
+ WantedBy=default.target
122
+ `
123
+ mkdirSync(unitDir, { recursive: true })
124
+ writeFileSync(unitPath, unit)
125
+ try {
126
+ execFileSync('systemctl', ['--user', 'daemon-reload'], { stdio: 'inherit' })
127
+ execFileSync('systemctl', ['--user', 'enable', '--now', 'tamp.service'], { stdio: 'inherit' })
128
+ console.log(`\nService installed: ${unitPath}`)
129
+ console.log(' Status: systemctl --user status tamp')
130
+ console.log(' Logs: journalctl --user -u tamp -f')
131
+ console.log(' Stop: systemctl --user stop tamp')
132
+ console.log(' Remove: tamp uninstall-service')
133
+ } catch (e) {
134
+ console.error('systemctl failed:', e.message)
135
+ process.exit(1)
136
+ }
137
+ process.exit(0)
138
+ }
139
+
140
+ if (subcommand === 'uninstall-service') {
141
+ if (process.platform !== 'linux') {
142
+ console.error('Service management requires Linux (systemd).')
143
+ process.exit(1)
144
+ }
145
+ const unitPath = join(homedir(), '.config', 'systemd', 'user', 'tamp.service')
146
+ try { execFileSync('systemctl', ['--user', 'stop', 'tamp.service'], { stdio: 'inherit' }) } catch {}
147
+ try { execFileSync('systemctl', ['--user', 'disable', 'tamp.service'], { stdio: 'inherit' }) } catch {}
148
+ try { unlinkSync(unitPath) } catch {}
149
+ try { execFileSync('systemctl', ['--user', 'daemon-reload'], { stdio: 'inherit' }) } catch {}
150
+ console.log('Service removed.')
151
+ process.exit(0)
152
+ }
153
+
154
+ if (subcommand === 'status') {
155
+ const port = process.env.TAMP_PORT || 7778
156
+ const healthy = await checkPort(port)
157
+ console.log(`Tamp v${VERSION}`)
158
+ console.log(` Health: ${healthy ? 'running' : 'not running'} (port ${port})`)
159
+ if (process.platform === 'linux') {
160
+ try { execFileSync('systemctl', ['--user', 'status', 'tamp.service', '--no-pager'], { stdio: 'inherit' }) } catch {}
161
+ }
162
+ process.exit(healthy ? 0 : 1)
163
+ }
164
+
165
+ if (subcommand === 'help' || subcommand === '--help' || subcommand === '-h') {
166
+ console.log(`Tamp v${VERSION} — Token compression proxy for coding agents\n`)
167
+ console.log('Usage: tamp [command] [options]\n')
168
+ console.log('Commands:')
169
+ console.log(' (default) Start proxy (interactive stage picker)')
170
+ console.log(' -y Start proxy (non-interactive, use defaults)')
171
+ console.log(' init Create config file (~/.config/tamp/config)')
172
+ console.log(' status Check if proxy is running')
173
+ console.log(' install-service Install systemd user service (Linux)')
174
+ console.log(' uninstall-service Remove systemd service')
175
+ console.log(' help Show this help')
176
+ console.log(`\nConfig: ${CONFIG_PATH}`)
177
+ process.exit(0)
178
+ }
179
+
80
180
  // --- Mode detection ---
81
181
  const skipPrompt = process.argv.includes('-y') || process.argv.includes('--no-interactive') || !process.stdin.isTTY
82
182
 
package/compress.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createHash } from 'node:crypto'
1
2
  import { encode } from '@toon-format/toon'
2
3
  import { countTokens } from '@anthropic-ai/tokenizer'
3
4
  import { createPatch } from 'diff'
@@ -9,7 +10,7 @@ const MAX_CACHE = 500
9
10
 
10
11
  function cacheKey(text) {
11
12
  if (text.length < 128) return text
12
- return `${text.length}:${text.slice(0, 64)}:${text.slice(-64)}`
13
+ return createHash('sha256').update(text).digest('base64')
13
14
  }
14
15
 
15
16
  export function clearCache() { cache.clear() }
@@ -103,14 +104,30 @@ function pruneJSON(text) {
103
104
  }
104
105
 
105
106
  // --- Stage: strip-comments (opt-in, not in defaults) ---
107
+ function stripLineComments(line) {
108
+ let inSingle = false, inDouble = false, inTemplate = false
109
+ for (let i = 0; i < line.length; i++) {
110
+ const ch = line[i]
111
+ const prev = i > 0 ? line[i - 1] : ''
112
+ if (prev === '\\') continue
113
+ if (ch === "'" && !inDouble && !inTemplate) { inSingle = !inSingle; continue }
114
+ if (ch === '"' && !inSingle && !inTemplate) { inDouble = !inDouble; continue }
115
+ if (ch === '`' && !inSingle && !inDouble) { inTemplate = !inTemplate; continue }
116
+ if (inSingle || inDouble || inTemplate) continue
117
+ if (ch === '/' && line[i + 1] === '/') return line.slice(0, i).trimEnd()
118
+ if (ch === '#' && !line.startsWith('#!')) return line.slice(0, i).trimEnd()
119
+ }
120
+ return line
121
+ }
122
+
106
123
  function stripComments(text) {
107
- return text
108
- .replace(/\/\*\*[\s\S]*?\*\//g, '') // JSDoc /** ... */
109
- .replace(/\/\*[\s\S]*?\*\//g, '') // block /* ... */
110
- .replace(/\/\/.*$/gm, '') // line // ...
111
- .replace(/^\s*#(?!!).*$/gm, '') // Python/shell # (not #!)
112
- .replace(/<!--[\s\S]*?-->/g, '') // HTML <!-- ... -->
113
- .replace(/\n\s*\n\s*\n/g, '\n\n') // collapse resulting blank lines
124
+ // Block comments: only strip if they start at line-level (not inside strings)
125
+ let result = text
126
+ .replace(/^[ \t]*\/\*\*[\s\S]*?\*\//gm, '')
127
+ .replace(/^[ \t]*\/\*[\s\S]*?\*\//gm, '')
128
+ .replace(/<!--[\s\S]*?-->/g, '')
129
+ result = result.split('\n').map(stripLineComments).join('\n')
130
+ return result.replace(/\n\s*\n\s*\n/g, '\n\n')
114
131
  }
115
132
 
116
133
  // --- Stage: textpress (opt-in, uses Ollama or OpenRouter free model) ---
@@ -125,24 +142,25 @@ async function textpressCompress(text, config) {
125
142
  try {
126
143
  const controller = new AbortController()
127
144
  const timeout = setTimeout(() => controller.abort(), 15000)
128
- const res = await fetch(`${ollamaUrl}/api/chat`, {
129
- method: 'POST',
130
- headers: { 'Content-Type': 'application/json' },
131
- body: JSON.stringify({
132
- model: ollamaModel,
133
- messages: [{ role: 'system', content: TEXTPRESS_PROMPT }, { role: 'user', content: text }],
134
- stream: false,
135
- options: { temperature: 0, num_predict: Math.ceil(text.length * 0.7) },
136
- think: false,
137
- }),
138
- signal: controller.signal,
139
- })
140
- clearTimeout(timeout)
141
- if (res.ok) {
142
- const data = await res.json()
143
- const output = (data.message?.content || '').trim()
144
- if (output.length > 0 && output.length < text.length * 0.9) return output
145
- }
145
+ try {
146
+ const res = await fetch(`${ollamaUrl}/api/chat`, {
147
+ method: 'POST',
148
+ headers: { 'Content-Type': 'application/json' },
149
+ body: JSON.stringify({
150
+ model: ollamaModel,
151
+ messages: [{ role: 'system', content: TEXTPRESS_PROMPT }, { role: 'user', content: text }],
152
+ stream: false,
153
+ options: { temperature: 0, num_predict: Math.ceil(text.length * 0.7) },
154
+ think: false,
155
+ }),
156
+ signal: controller.signal,
157
+ })
158
+ if (res.ok) {
159
+ const data = await res.json()
160
+ const output = (data.message?.content || '').trim()
161
+ if (output.length > 0 && output.length < text.length * 0.9) return output
162
+ }
163
+ } finally { clearTimeout(timeout) }
146
164
  } catch { /* Ollama not available, try OpenRouter */ }
147
165
 
148
166
  // Fallback: OpenRouter free model
@@ -152,23 +170,24 @@ async function textpressCompress(text, config) {
152
170
  try {
153
171
  const controller = new AbortController()
154
172
  const timeout = setTimeout(() => controller.abort(), 10000)
155
- const res = await fetch('https://openrouter.ai/api/v1/chat/completions', {
156
- method: 'POST',
157
- headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${orKey}` },
158
- body: JSON.stringify({
159
- model: orModel,
160
- messages: [{ role: 'system', content: TEXTPRESS_PROMPT }, { role: 'user', content: text }],
161
- max_tokens: Math.ceil(text.length * 0.5),
162
- temperature: 0,
163
- }),
164
- signal: controller.signal,
165
- })
166
- clearTimeout(timeout)
167
- if (res.ok) {
168
- const data = await res.json()
169
- const output = (data.choices?.[0]?.message?.content || '').replace(/<think>[\s\S]*?<\/think>/g, '').trim()
170
- if (output.length > 0 && output.length < text.length * 0.9) return output
171
- }
173
+ try {
174
+ const res = await fetch('https://openrouter.ai/api/v1/chat/completions', {
175
+ method: 'POST',
176
+ headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${orKey}` },
177
+ body: JSON.stringify({
178
+ model: orModel,
179
+ messages: [{ role: 'system', content: TEXTPRESS_PROMPT }, { role: 'user', content: text }],
180
+ max_tokens: Math.ceil(text.length * 0.5),
181
+ temperature: 0,
182
+ }),
183
+ signal: controller.signal,
184
+ })
185
+ if (res.ok) {
186
+ const data = await res.json()
187
+ const output = (data.choices?.[0]?.message?.content || '').replace(/<think>[\s\S]*?<\/think>/g, '').trim()
188
+ if (output.length > 0 && output.length < text.length * 0.9) return output
189
+ }
190
+ } finally { clearTimeout(timeout) }
172
191
  } catch { /* OpenRouter not available */ }
173
192
 
174
193
  return null
@@ -238,16 +257,17 @@ async function compressWithLLMLingua(text, config) {
238
257
  try {
239
258
  const controller = new AbortController()
240
259
  const timeout = setTimeout(() => controller.abort(), 5000)
241
- const res = await fetch(config.llmLinguaUrl + '/compress', {
242
- method: 'POST',
243
- headers: { 'Content-Type': 'application/json' },
244
- body: JSON.stringify({ text, rate: 0.5 }),
245
- signal: controller.signal,
246
- })
247
- clearTimeout(timeout)
248
- if (!res.ok) return null
249
- const data = await res.json()
250
- return { text: data.text, method: 'llmlingua', originalLen: text.length, compressedLen: data.text.length, originalTokens: countTokens(text), compressedTokens: countTokens(data.text) }
260
+ try {
261
+ const res = await fetch(config.llmLinguaUrl + '/compress', {
262
+ method: 'POST',
263
+ headers: { 'Content-Type': 'application/json' },
264
+ body: JSON.stringify({ text, rate: 0.5 }),
265
+ signal: controller.signal,
266
+ })
267
+ if (!res.ok) return null
268
+ const data = await res.json()
269
+ return { text: data.text, method: 'llmlingua', originalLen: text.length, compressedLen: data.text.length, originalTokens: countTokens(text), compressedTokens: countTokens(data.text) }
270
+ } finally { clearTimeout(timeout) }
251
271
  } catch {
252
272
  return null
253
273
  }
@@ -270,11 +290,13 @@ async function compressBlock(text, config) {
270
290
  result = sync
271
291
  }
272
292
 
273
- if (cache.size >= MAX_CACHE) {
274
- const firstKey = cache.keys().next().value
275
- cache.delete(firstKey)
293
+ if (result) {
294
+ if (cache.size >= MAX_CACHE) {
295
+ const firstKey = cache.keys().next().value
296
+ cache.delete(firstKey)
297
+ }
298
+ cache.set(key, result)
276
299
  }
277
- cache.set(key, result)
278
300
  return result
279
301
  }
280
302
 
package/config.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { readFileSync } from 'node:fs'
2
+ import { homedir } from 'node:os'
3
+ import { join } from 'node:path'
1
4
  import { DEFAULT_STAGES, VERSION } from './metadata.js'
2
5
 
3
6
  function parseBoolean(value, defaultValue) {
@@ -7,28 +10,71 @@ function parseBoolean(value, defaultValue) {
7
10
  return defaultValue
8
11
  }
9
12
 
13
+ export const CONFIG_PATH = join(homedir(), '.config', 'tamp', 'config')
14
+
15
+ export function loadConfigFile(path) {
16
+ const filePath = path || process.env.TAMP_CONFIG || CONFIG_PATH
17
+ try {
18
+ const lines = readFileSync(filePath, 'utf8').split('\n')
19
+ const vars = {}
20
+ for (const raw of lines) {
21
+ const line = raw.trim()
22
+ if (!line || line.startsWith('#')) continue
23
+ const eq = line.indexOf('=')
24
+ if (eq < 1) continue
25
+ const key = line.slice(0, eq).trim()
26
+ let val = line.slice(eq + 1).trim()
27
+ if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
28
+ val = val.slice(1, -1)
29
+ }
30
+ vars[key] = val
31
+ }
32
+ return vars
33
+ } catch { return {} }
34
+ }
35
+
10
36
  export function loadConfig(env = process.env) {
11
- const stages = (env.TAMP_STAGES || DEFAULT_STAGES.join(',')).split(',').map(s => s.trim()).filter(Boolean)
37
+ const fileVars = (env === process.env) ? loadConfigFile() : {}
38
+ const get = (key) => env[key] !== undefined ? env[key] : fileVars[key]
39
+
40
+ const stages = (get('TAMP_STAGES') || DEFAULT_STAGES.join(',')).split(',').map(s => s.trim()).filter(Boolean)
12
41
  return Object.freeze({
13
42
  version: VERSION,
14
- port: parseInt(env.TAMP_PORT, 10) || 7778,
15
- upstream: env.TAMP_UPSTREAM || 'https://api.anthropic.com',
43
+ port: parseInt(get('TAMP_PORT'), 10) || 7778,
44
+ upstream: get('TAMP_UPSTREAM') || 'https://api.anthropic.com',
16
45
  upstreams: Object.freeze({
17
- anthropic: env.TAMP_UPSTREAM || 'https://api.anthropic.com',
18
- openai: env.TAMP_UPSTREAM_OPENAI || 'https://api.openai.com',
19
- gemini: env.TAMP_UPSTREAM_GEMINI || 'https://generativelanguage.googleapis.com',
46
+ anthropic: get('TAMP_UPSTREAM') || 'https://api.anthropic.com',
47
+ openai: get('TAMP_UPSTREAM_OPENAI') || 'https://api.openai.com',
48
+ gemini: get('TAMP_UPSTREAM_GEMINI') || 'https://generativelanguage.googleapis.com',
20
49
  }),
21
- minSize: parseInt(env.TAMP_MIN_SIZE, 10) || 200,
50
+ minSize: parseInt(get('TAMP_MIN_SIZE'), 10) || 200,
22
51
  stages,
23
- log: env.TAMP_LOG !== 'false',
24
- logFile: env.TAMP_LOG_FILE || null,
25
- maxBody: parseInt(env.TAMP_MAX_BODY, 10) || 10_485_760,
26
- cacheSafe: parseBoolean(env.TAMP_CACHE_SAFE, true),
27
- llmLinguaUrl: env.TAMP_LLMLINGUA_URL || null,
28
- textpressOllamaUrl: env.TAMP_TEXTPRESS_OLLAMA_URL || 'http://localhost:11434',
29
- textpressOllamaModel: env.TAMP_TEXTPRESS_OLLAMA_MODEL || 'qwen3.5:0.8b',
30
- textpressModel: env.TAMP_TEXTPRESS_MODEL || 'google/gemini-3.1-flash-lite-preview',
31
- textpressApiKey: env.TAMP_TEXTPRESS_API_KEY || env.OPENROUTER_API_KEY || null,
32
- tokenCost: parseFloat(env.TAMP_TOKEN_COST) || 3,
52
+ log: get('TAMP_LOG') !== 'false',
53
+ logFile: get('TAMP_LOG_FILE') || null,
54
+ maxBody: parseInt(get('TAMP_MAX_BODY'), 10) || 10_485_760,
55
+ cacheSafe: parseBoolean(get('TAMP_CACHE_SAFE'), true),
56
+ llmLinguaUrl: get('TAMP_LLMLINGUA_URL') || null,
57
+ textpressOllamaUrl: get('TAMP_TEXTPRESS_OLLAMA_URL') || 'http://localhost:11434',
58
+ textpressOllamaModel: get('TAMP_TEXTPRESS_OLLAMA_MODEL') || 'qwen3.5:0.8b',
59
+ textpressModel: get('TAMP_TEXTPRESS_MODEL') || 'google/gemini-3.1-flash-lite-preview',
60
+ textpressApiKey: get('TAMP_TEXTPRESS_API_KEY') || get('OPENROUTER_API_KEY') || null,
61
+ tokenCost: parseFloat(get('TAMP_TOKEN_COST')) || 3,
33
62
  })
34
63
  }
64
+
65
+ export const CONFIG_TEMPLATE = `# Tamp configuration
66
+ # Environment variables override these values
67
+ # https://github.com/sliday/tamp
68
+
69
+ # TAMP_PORT=7778
70
+ # TAMP_UPSTREAM=https://api.anthropic.com
71
+ # TAMP_UPSTREAM_OPENAI=https://api.openai.com
72
+ # TAMP_UPSTREAM_GEMINI=https://generativelanguage.googleapis.com
73
+ # TAMP_STAGES=minify,toon,strip-lines,whitespace,llmlingua,dedup,diff,prune
74
+ # TAMP_MIN_SIZE=200
75
+ # TAMP_LOG=true
76
+ # TAMP_LOG_FILE=
77
+ # TAMP_MAX_BODY=10485760
78
+ # TAMP_CACHE_SAFE=true
79
+ # TAMP_TOKEN_COST=3
80
+ `
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "providers.js",
11
11
  "stats.js"
12
12
  ],
13
- "version": "0.3.13",
13
+ "version": "0.4.1",
14
14
  "description": "Token compression proxy for coding agents. Works with Claude Code, Aider, Cursor, Cline, Windsurf. 52.6% fewer input tokens.",
15
15
  "type": "module",
16
16
  "main": "index.js",
package/providers.js CHANGED
@@ -68,23 +68,6 @@ const anthropic = {
68
68
  },
69
69
  }
70
70
 
71
- function extractOpenAIResponsesTargets(item, i) {
72
- const targets = []
73
- if (item.type === 'function_call_output' && typeof item.output === 'string') {
74
- targets.push({ path: ['input', i, 'output'], text: item.output, index: i })
75
- return targets
76
- }
77
- if (item.type === 'message' && Array.isArray(item.content)) {
78
- for (let j = 0; j < item.content.length; j++) {
79
- const part = item.content[j]
80
- if ((part.type === 'input_text' || part.type === 'output_text') && typeof part.text === 'string') {
81
- targets.push({ path: ['input', i, 'content', j, 'text'], text: part.text, index: i })
82
- }
83
- }
84
- }
85
- return targets
86
- }
87
-
88
71
  function extractOpenAIChatTargets(msg, i) {
89
72
  if (msg.role !== 'tool' || typeof msg.content !== 'string') return []
90
73
  return [{ path: ['messages', i, 'content'], text: msg.content, index: i }]
@@ -95,8 +78,7 @@ const openai = {
95
78
  match(method, url) {
96
79
  return method === 'POST' && (
97
80
  url.startsWith('/v1/chat/completions') ||
98
- url.startsWith('/chat/completions') ||
99
- url.startsWith('/v1/responses')
81
+ url.startsWith('/chat/completions')
100
82
  )
101
83
  },
102
84
  normalizeUrl(url) {
@@ -104,22 +86,6 @@ const openai = {
104
86
  return url
105
87
  },
106
88
  extract(body, config = {}) {
107
- // Responses API format: body.input array (Codex CLI)
108
- if (body?.input?.length) {
109
- if (config.cacheSafe) {
110
- const targets = []
111
- for (let i = body.input.length - 1; i >= 0; i--) {
112
- const itemTargets = extractOpenAIResponsesTargets(body.input[i], i)
113
- if (!itemTargets.length) break
114
- targets.unshift(...itemTargets)
115
- }
116
- return targets
117
- }
118
-
119
- return body.input.flatMap(extractOpenAIResponsesTargets)
120
- }
121
-
122
- // Chat Completions format
123
89
  if (!body?.messages?.length) return []
124
90
 
125
91
  if (config.cacheSafe) {