Files
pxpipe/package.json
T
Steven Chong 47b5e412b3 feat: cache-stable history-collapse imaging for GPT (OpenAI) + Anthropic
Collapse old conversation history into rendered PNG sections so the model
reads a compact image instead of re-billed text, while preserving prompt
caching and tool-call behavior. Measures real vs compressed token/cost.

Core:
- GPT history collapse (openai-history.ts): append-only, o200k token-length
  sectioning. Sections seal only at a tool-closed boundary (open call-id set
  empty), so a function_call and its function_call_output never split across
  the collapse cut. Fixes the OpenAI 400 "No tool call found for function
  call output with call_id ..." that hit long Responses-API sessions.
- Anthropic cache contract (history.ts): append-only per-chunk rendering;
  cache_control markers are preserved/moved, never added; chunk boundaries
  align with caller marker seams for byte-stable prefix caching.
- GPT image budget (openai.ts): detail:'original' for gpt-5.x, flagship
  vision-multiplier fix, patch cap; schema-strip preserves real descriptions.
- Savings accounting (openai-savings.ts): cached_tokens + vision-token basis.

Model scope (applicability.ts):
- Default imaged scope = claude-fable-5 + gpt-5.6.
- gpt-5.5 and claude-opus-4-8 stay opt-in: same pipeline, but they degrade
  reading dense imaged history (gist drift), so silently imaging them by
  default is wrong. Promotion is gated on an OCR/recall threshold.

Dashboard: GPT + Anthropic rendering, per-family model toggles, persisted
metrics, thumbnail-expired session UI, reflow/newline handling.

Tests: cache-alignment (GPT + Anthropic), history sectioning + tool-boundary
invariants, savings, dashboard, sessions/restart-restore. 452 passing.
2026-06-20 21:11:24 -04:00

107 lines
2.7 KiB
JSON

{
"name": "pxpipe-proxy",
"version": "0.4.0",
"description": "Token-saving proxy for Claude Code: renders bulky context (system prompt, tool docs, old history) as dense PNGs to cut input tokens. Runs on Node and Cloudflare Workers.",
"type": "module",
"bin": {
"pxpipe": "bin/cli.js"
},
"exports": {
".": {
"types": "./dist/core/index.d.ts",
"import": "./dist/core/index.js"
},
"./transform": {
"types": "./dist/core/library.d.ts",
"import": "./dist/core/library.js"
},
"./measurement": {
"types": "./dist/core/measurement.d.ts",
"import": "./dist/core/measurement.js"
},
"./applicability": {
"types": "./dist/core/applicability.d.ts",
"import": "./dist/core/applicability.js"
},
"./proxy": {
"types": "./dist/core/proxy.d.ts",
"import": "./dist/core/proxy.js"
},
"./node": {
"types": "./dist/node.d.ts",
"import": "./dist/node.js"
},
"./worker": {
"types": "./dist/worker.d.ts",
"import": "./dist/worker.js"
}
},
"files": [
"bin/",
"dist/",
"!dist/**/*.map",
"README.md",
"LICENSE"
],
"scripts": {
"build": "node scripts/build.mjs",
"build:atlas": "tsx scripts/gen-atlas.ts",
"dev:node": "tsx watch src/node.ts",
"dev:worker": "wrangler dev",
"deploy:worker": "wrangler deploy",
"restart": "bash scripts/restart.sh",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest",
"test:restart": "bash tests/restart.test.sh",
"prepublishOnly": "pnpm run typecheck && pnpm test && pnpm run build",
"vendor:ui": "node scripts/vendor-ui.mjs"
},
"keywords": [
"claude",
"claude-code",
"anthropic",
"fable-5",
"proxy",
"token-optimization",
"prompt-cache",
"vision-tokens",
"cloudflare-workers"
],
"engines": {
"node": ">=18"
},
"packageManager": "pnpm@10.21.0",
"license": "MIT",
"devDependencies": {
"@cloudflare/workers-types": "^4.20240512.0",
"@napi-rs/canvas": "^0.1.53",
"@types/node": "^20.12.0",
"esbuild": "^0.28.1",
"tsx": "^4.10.0",
"typescript": "^5.4.0",
"vite": "^8.0.16",
"vitest": "^4.1.6",
"wrangler": "^4.92.0"
},
"pnpm": {
"overrides": {
"ws@>=8.0.0 <8.20.1": "^8.20.1",
"vite@>=8.0.0 <8.0.16": "^8.0.16",
"undici@>=7.0.0 <7.28.0": "^7.28.0",
"esbuild@>=0.27.3 <0.28.1": "^0.28.1"
}
},
"dependencies": {
"gpt-tokenizer": "^3.4.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/teamchong/pxpipe.git"
},
"homepage": "https://github.com/teamchong/pxpipe#readme",
"bugs": {
"url": "https://github.com/teamchong/pxpipe/issues"
}
}