@sliday/tamp 0.2.10 → 0.2.12
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/compress.js +3 -1
- package/index.js +1 -0
- package/package.json +1 -1
- package/providers.js +10 -1
package/compress.js
CHANGED
|
@@ -72,10 +72,12 @@ export async function compressRequest(body, config, provider) {
|
|
|
72
72
|
if (result) {
|
|
73
73
|
target.compressed = result.text
|
|
74
74
|
stats.push({ index: target.index, ...result })
|
|
75
|
+
} else {
|
|
76
|
+
stats.push({ index: target.index, skipped: 'not-compressible' })
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
provider.apply(body, targets)
|
|
78
|
-
return { body, stats }
|
|
80
|
+
return { body, stats, targetCount: targets.length }
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
export async function compressMessages(body, config) {
|
package/index.js
CHANGED
|
@@ -174,6 +174,7 @@ return http.createServer(async (req, res) => {
|
|
|
174
174
|
|
|
175
175
|
try {
|
|
176
176
|
const parsed = JSON.parse(textBody.toString('utf-8'))
|
|
177
|
+
|
|
177
178
|
const { body, stats } = await compressRequest(parsed, config, provider)
|
|
178
179
|
finalBody = Buffer.from(JSON.stringify(body), 'utf-8')
|
|
179
180
|
// Send uncompressed — simpler and content-length is accurate
|
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.12",
|
|
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/providers.js
CHANGED
|
@@ -66,12 +66,21 @@ const openai = {
|
|
|
66
66
|
extract(body) {
|
|
67
67
|
const targets = []
|
|
68
68
|
|
|
69
|
-
// Responses API format: body.input
|
|
69
|
+
// Responses API format: body.input array
|
|
70
70
|
if (body?.input?.length) {
|
|
71
71
|
for (let i = 0; i < body.input.length; i++) {
|
|
72
72
|
const item = body.input[i]
|
|
73
73
|
if (item.type === 'function_call_output' && typeof item.output === 'string') {
|
|
74
74
|
targets.push({ path: ['input', i, 'output'], text: item.output, index: i })
|
|
75
|
+
continue
|
|
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
|
+
}
|
|
75
84
|
}
|
|
76
85
|
}
|
|
77
86
|
return targets
|