@sliday/tamp 0.2.7 → 0.2.8
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/config.js +1 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/stats.js +5 -2
package/config.js
CHANGED
package/index.js
CHANGED
|
@@ -181,7 +181,7 @@ return http.createServer(async (req, res) => {
|
|
|
181
181
|
|
|
182
182
|
if (config.log) {
|
|
183
183
|
session.record(stats)
|
|
184
|
-
console.error(formatRequestLog(stats, session, provider.name, req.url, textBody.length))
|
|
184
|
+
console.error(formatRequestLog(stats, session, provider.name, req.url, textBody.length, config.tokenCost))
|
|
185
185
|
}
|
|
186
186
|
} catch (err) {
|
|
187
187
|
if (config.log) console.error(`[tamp] passthrough (parse error): ${err.message}`)
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"providers.js",
|
|
10
10
|
"stats.js"
|
|
11
11
|
],
|
|
12
|
-
"version": "0.2.
|
|
12
|
+
"version": "0.2.8",
|
|
13
13
|
"description": "Token compression proxy for coding agents. Works with Claude Code, Aider, Cursor, Cline, Windsurf. 33.9% fewer input tokens.",
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "index.js",
|
package/stats.js
CHANGED
|
@@ -9,7 +9,7 @@ const c = {
|
|
|
9
9
|
red: '\x1b[31m',
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export function formatRequestLog(stats, session, providerName, url, bodySize) {
|
|
12
|
+
export function formatRequestLog(stats, session, providerName, url, bodySize, tokenCost) {
|
|
13
13
|
const compressed = stats.filter(s => s.method)
|
|
14
14
|
const label = providerName || 'anthropic'
|
|
15
15
|
const path = url || '/v1/messages'
|
|
@@ -49,7 +49,10 @@ export function formatRequestLog(stats, session, providerName, url, bodySize) {
|
|
|
49
49
|
if (session) {
|
|
50
50
|
const t = session.getTotals()
|
|
51
51
|
const sessionPct = t.totalOriginal > 0 ? (((t.totalSaved) / t.totalOriginal) * 100).toFixed(1) : '0.0'
|
|
52
|
-
|
|
52
|
+
const costPerM = tokenCost || 3
|
|
53
|
+
const dollarsSaved = (t.totalTokensSaved / 1_000_000) * costPerM
|
|
54
|
+
const moneyInfo = t.totalTokensSaved > 0 ? ` ${c.green}$${dollarsSaved.toFixed(4)} saved${c.reset} ${c.dim}@ $${costPerM}/Mtok${c.reset}` : ''
|
|
55
|
+
lines.push(`[tamp] ${c.magenta}session${c.reset} ${fmtSize(t.totalSaved)} chars, ${t.totalTokensSaved} tokens saved across ${t.compressionCount} blocks ${c.dim}(${sessionPct}% avg)${c.reset}${moneyInfo}`)
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
return lines.join('\n')
|