@sliday/tamp 0.4.4 → 0.4.6

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
@@ -1,6 +1,6 @@
1
1
  # Tamp
2
2
 
3
- **Token compression proxy for coding agents.** 52.6% fewer input tokens, zero code changes. Works with Claude Code, Aider, Cursor, Cline, Windsurf, 🦞 [OpenClaw](https://openclaw.app), and any OpenAI-compatible agent.
3
+ **Token compression proxy for coding agents.** 52.6% fewer tokens, zero code changes. Works with Claude Code, Aider, Cursor, Cline, Windsurf, 🦞 [OpenClaw](https://openclaw.app), and any OpenAI-compatible agent.
4
4
 
5
5
  ```
6
6
  npx @sliday/tamp
@@ -84,43 +84,23 @@ All 8 default stages are enabled by default. Two additional lossy stages are ava
84
84
 
85
85
  ## Quick Start
86
86
 
87
- ### 1. Start the proxy
87
+ ### Option A: One-line installer
88
88
 
89
89
  ```bash
90
- npx @sliday/tamp
91
- ```
92
-
93
- ```
94
- ┌─ Tamp ─────────────────────────────────┐
95
- │ Proxy: http://localhost:7778 │
96
- │ Status: ● Ready │
97
- │ │
98
- │ Claude Code: │
99
- │ ANTHROPIC_BASE_URL=http://localhost:7778
100
- │ │
101
- │ Aider / Cursor / Cline: │
102
- │ OPENAI_API_BASE=http://localhost:7778
103
- └────────────────────────────────────────┘
90
+ curl -fsSL https://tamp.dev/setup.sh | bash
104
91
  ```
105
92
 
106
- ### 2. Point your agent at the proxy
93
+ Installs via npm, sets `ANTHROPIC_BASE_URL` and `OPENAI_API_BASE` in your shell profile. Then just run `tamp` in one terminal and your agent in another.
107
94
 
108
- **Claude Code:**
109
- ```bash
110
- export ANTHROPIC_BASE_URL=http://localhost:7778
111
- claude
112
- ```
95
+ ### Option B: Manual
113
96
 
114
- **Aider:**
115
97
  ```bash
116
- export OPENAI_API_BASE=http://localhost:7778
117
- aider
98
+ npx @sliday/tamp # start proxy
99
+ export ANTHROPIC_BASE_URL=http://localhost:7778 # Claude Code
100
+ export OPENAI_API_BASE=http://localhost:7778 # Aider, Cursor, Cline
118
101
  ```
119
102
 
120
- **Cursor / Cline / Windsurf:**
121
- Set the API base URL to `http://localhost:7778` in your editor's settings.
122
-
123
- That's it. Use your agent as normal — Tamp compresses silently in the background.
103
+ Use your agent as normal — Tamp compresses silently in the background.
124
104
 
125
105
  ## Configuration
126
106
 
@@ -222,7 +202,7 @@ tamp uninstall-service # remove
222
202
  curl -fsSL https://tamp.dev/setup.sh | bash
223
203
  ```
224
204
 
225
- The installer clones to `~/.tamp`, adds `ANTHROPIC_BASE_URL` to your shell profile, and creates a `tamp` alias.
205
+ Installs `@sliday/tamp` globally via npm and adds `ANTHROPIC_BASE_URL` + `OPENAI_API_BASE` to your shell profile.
226
206
 
227
207
  ## What Gets Compressed
228
208
 
package/compress.js CHANGED
@@ -269,7 +269,7 @@ async function compressWithLLMLingua(text, config) {
269
269
  const res = await fetch(config.llmLinguaUrl + '/compress', {
270
270
  method: 'POST',
271
271
  headers: { 'Content-Type': 'application/json' },
272
- body: JSON.stringify({ text, rate: 0.5 }),
272
+ body: JSON.stringify({ text, rate: config.llmLinguaRate || 0.7 }),
273
273
  signal: controller.signal,
274
274
  })
275
275
  if (!res.ok) return null
package/index.js CHANGED
@@ -162,18 +162,27 @@ return http.createServer(async (req, res) => {
162
162
  const encoding = (req.headers['content-encoding'] || '').toLowerCase()
163
163
  let textBody
164
164
  let decompressed = false
165
+
166
+ // Safety limit: decompressed body must not exceed 5× maxBody
167
+ // Prevents compression bomb DoS (small gzip → huge expansion)
168
+ const MAX_DECOMPRESSED = config.maxBody * 5
169
+
165
170
  try {
166
171
  if (encoding === 'gzip') {
167
- textBody = zlib.gunzipSync(rawBody)
172
+ textBody = zlib.gunzipSync(rawBody, { maxOutputLength: MAX_DECOMPRESSED })
168
173
  decompressed = true
169
174
  } else if (encoding === 'deflate') {
170
- textBody = zlib.inflateSync(rawBody)
175
+ textBody = zlib.inflateSync(rawBody, { maxOutputLength: MAX_DECOMPRESSED })
171
176
  decompressed = true
172
177
  } else if (encoding === 'br') {
173
- textBody = zlib.brotliDecompressSync(rawBody)
178
+ textBody = zlib.brotliDecompressSync(rawBody, { maxOutputLength: MAX_DECOMPRESSED })
174
179
  decompressed = true
175
180
  } else if (encoding === 'zstd') {
176
- textBody = Buffer.from(fzstd.decompress(new Uint8Array(rawBody)))
181
+ const decompressedBytes = fzstd.decompress(new Uint8Array(rawBody))
182
+ if (decompressedBytes.length > MAX_DECOMPRESSED) {
183
+ throw new Error('zstd decompression exceeded size limit')
184
+ }
185
+ textBody = Buffer.from(decompressedBytes)
177
186
  decompressed = true
178
187
  } else if (encoding && encoding !== 'identity') {
179
188
  // Unknown encoding — can't decompress, passthrough as-is
@@ -190,6 +199,13 @@ return http.createServer(async (req, res) => {
190
199
  return
191
200
  }
192
201
 
202
+ // Double-check decompressed size
203
+ if (textBody.length > MAX_DECOMPRESSED) {
204
+ log('[tamp] passthrough (decompressed body too large)')
205
+ forwardRequest(req.method, upstreamUrl, headers, rawBody, res)
206
+ return
207
+ }
208
+
193
209
  try {
194
210
  const parsed = JSON.parse(textBody.toString('utf-8'))
195
211
 
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "providers.js",
11
11
  "stats.js"
12
12
  ],
13
- "version": "0.4.4",
13
+ "version": "0.4.6",
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",