@sliday/tamp 0.8.3 → 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 +5 -0
- package/compress.js +5 -2
- package/index.js +15 -6
- package/lib/br-cache.js +4 -0
- package/lib/compress-file.js +4 -2
- package/lib/rewriters/commands/docker.js +3 -1
- package/lib/rewriters/commands/jest.js +3 -1
- package/package.json +1 -1
- package/providers.js +11 -6
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/compress.js
CHANGED
|
@@ -37,8 +37,11 @@ function deduplicateTargets(targets) {
|
|
|
37
37
|
const prev = seen.get(key)
|
|
38
38
|
if (prev && prev.text === target.text) {
|
|
39
39
|
const ref = `[see tool_result in message ${prev.path[1]}, block ${prev.index} — identical content]`
|
|
40
|
-
|
|
41
|
-
target.
|
|
40
|
+
// Never expand: a tiny duplicate can be shorter than the reference itself.
|
|
41
|
+
if (ref.length < target.text.length) {
|
|
42
|
+
target.compressed = ref
|
|
43
|
+
target.dedup = true
|
|
44
|
+
}
|
|
42
45
|
} else {
|
|
43
46
|
seen.set(key, target)
|
|
44
47
|
}
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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/lib/br-cache.js
CHANGED
|
@@ -123,6 +123,10 @@ export function createBrCache({ cacheDir = defaultCacheDir(), maxBytes = DEFAULT
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
pruneInternal()
|
|
126
|
+
// If this entry alone exceeds maxBytes, pruneInternal() just evicted it.
|
|
127
|
+
// Don't claim persistence we can't honour — a phantom record would leave
|
|
128
|
+
// the caller with a brHash that get() can never resolve.
|
|
129
|
+
if (!existsSync(finalPath)) return null
|
|
126
130
|
return { hash, storedBytes: byteLen, brotliBytes }
|
|
127
131
|
}
|
|
128
132
|
|
package/lib/compress-file.js
CHANGED
|
@@ -144,9 +144,11 @@ export async function compressFile(filePath, options = {}) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
// Create backup
|
|
147
|
+
// Create backup. Never clobber an existing backup — it holds the pristine
|
|
148
|
+
// original from a prior run, and overwriting it with already-compressed
|
|
149
|
+
// content would make the original unrecoverable.
|
|
148
150
|
const backupPath = filePath + '.bak'
|
|
149
|
-
if (!options.noBackup) {
|
|
151
|
+
if (!options.noBackup && !existsSync(backupPath)) {
|
|
150
152
|
try {
|
|
151
153
|
await copyFile(filePath, backupPath)
|
|
152
154
|
} catch (error) {
|
|
@@ -34,7 +34,9 @@ export default {
|
|
|
34
34
|
if (LEGACY_PROGRESS.test(line)) continue;
|
|
35
35
|
// BuildKit "in-progress" duplicated step lines end with a fractional second
|
|
36
36
|
// marker and are re-emitted as DONE later; strip the non-DONE variants.
|
|
37
|
-
|
|
37
|
+
// Never strip a line carrying error/warning/failure context — a RUN step's
|
|
38
|
+
// stdout can legitimately end in a duration (e.g. "build failed in 2.3s").
|
|
39
|
+
if (/^#\d+\s+\S.*\s\d+\.\d+s$/.test(line) && !/\sDONE\b/.test(line) && !/\b(error|warning|fail)/i.test(line)) continue;
|
|
38
40
|
out.push(line);
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
// the Tests/Suites/Time/Snapshots summary and any stack traces.
|
|
7
7
|
|
|
8
8
|
const PASS_LINE = /^\s*PASS\s+\S+/;
|
|
9
|
-
|
|
9
|
+
// `m` flag is required: the all-pass gate scans the whole multi-line output,
|
|
10
|
+
// and a FAIL line is rarely the first line (jest interleaves PASS suites).
|
|
11
|
+
const FAIL_LINE = /^\s*FAIL\s+\S+/m;
|
|
10
12
|
const JEST_SIG = /(^|\n)(PASS\s+\S+|FAIL\s+\S+|Tests:\s+.*\d+\s+(passed|failed|total)|Test Suites:\s+\d)/;
|
|
11
13
|
|
|
12
14
|
export default {
|
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.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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
465
|
-
|
|
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
|
}
|