@sliday/tamp 0.8.4 → 0.8.5

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/bin/tamp.js CHANGED
@@ -274,6 +274,11 @@ if (subcommand === 'uninstall-service') {
274
274
  process.exit(0)
275
275
  }
276
276
 
277
+ if (subcommand === 'version' || subcommand === '--version' || subcommand === '-v' || process.argv.includes('--version')) {
278
+ console.log(`Tamp v${VERSION}`)
279
+ process.exit(0)
280
+ }
281
+
277
282
  if (subcommand === 'status') {
278
283
  const port = process.env.TAMP_PORT || 7778
279
284
  const healthy = await checkPort(port)
package/index.js CHANGED
@@ -260,13 +260,22 @@ return http.createServer(async (req, res) => {
260
260
  // request stream — pipeRequest() still needs to forward the unread remainder
261
261
  // to the upstream. Without this, an over-maxBody body is truncated while its
262
262
  // original content-length is preserved, hanging the upstream.
263
- for await (const chunk of req.iterator({ destroyOnReturn: false })) {
264
- size += chunk.length
265
- chunks.push(chunk)
266
- if (size > config.maxBody) {
267
- overflow = true
268
- break
263
+ try {
264
+ for await (const chunk of req.iterator({ destroyOnReturn: false })) {
265
+ size += chunk.length
266
+ chunks.push(chunk)
267
+ if (size > config.maxBody) {
268
+ overflow = true
269
+ break
270
+ }
269
271
  }
272
+ } catch (err) {
273
+ // Client aborted mid-upload (ECONNRESET / premature close). The client is
274
+ // gone, so there's nothing to forward — drop the request without letting
275
+ // the rejection bubble up and crash the proxy process.
276
+ log(`[tamp] client aborted during request body: ${err.code || err.message}`)
277
+ if (!res.writableEnded) res.destroy()
278
+ return
270
279
  }
271
280
 
272
281
  if (overflow) {
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "sidecar/server.py",
15
15
  "sidecar/requirements.txt"
16
16
  ],
17
- "version": "0.8.4",
17
+ "version": "0.8.5",
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",
package/providers.js CHANGED
@@ -203,11 +203,13 @@ function applyAnthropicRehydration(body, refs) {
203
203
  if (updated === current) continue
204
204
 
205
205
  if (isToolUseInput) {
206
+ // tool_use.input must stay a JSON object. If inserting the expansion made
207
+ // the serialized form invalid JSON, leave the original input untouched
208
+ // rather than writing a string Anthropic would reject.
206
209
  try {
207
- const parsed = JSON.parse(updated)
208
- setAtPath(body, path, parsed)
209
- continue
210
- } catch { /* fall through to string */ }
210
+ setAtPath(body, path, JSON.parse(updated))
211
+ } catch { /* not valid JSON: keep the original object input */ }
212
+ continue
211
213
  }
212
214
  setAtPath(body, path, updated)
213
215
  }
@@ -459,10 +461,13 @@ const gemini = {
459
461
  const path = t.path
460
462
  for (let i = 0; i < path.length - 1; i++) obj = obj[path[i]]
461
463
  if (t.wasObject) {
464
+ // Gemini's functionResponse.response must be a JSON object. If the
465
+ // compressed form isn't valid JSON (e.g. TOON), writing it as a string
466
+ // produces a request the API rejects — keep the original object.
462
467
  try {
463
468
  obj[path[path.length - 1]] = JSON.parse(t.compressed)
464
- continue
465
- } catch { /* fall through to string */ }
469
+ } catch { /* not valid JSON: leave the original object untouched */ }
470
+ continue
466
471
  }
467
472
  obj[path[path.length - 1]] = t.compressed
468
473
  }