Repository navigation
feat: image pre-compression routing/downsample + image_full restore channel - #357
ranxianglei wants to merge 1 commit into
Conversation
[bot] 🏷 Reviewing this PR now (agent-completed work, not redoing): pulling branch |
141563b to
5095ec7
Compare
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)In your adapter project: npm install acp-kernel@pr-357Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf acp-kernel-pr357.tgz
npm install ./packageThis comment is automatically updated on each push. |
[bot] 🏷 Review complete — rebuilt on current master, CI green, ready to merge. What I verified
Blocker found & fixed directlyStale base. The branch was based on v0.0.73 (
Regression pass (existing behaviors on touched paths)
Behavior-change disclosure
Not blocking, noted separately
Per AGENTS.md §7.4 this stays human-gated (feat + state-schema change), so: ready for you to merge. 修了什么问题 / 为什么修 / 是否可以合并:PR 代码本身正确(WebP estimator 与 libwebp 及 billion-context 参考实现逐一核对无误),唯一问题是分支基于旧 master(v0.0.73)导致无法合并——已直接 rebase 到 v0.0.82、解决 6 个文件的纯叠加冲突并修复 4 处合并接缝,本地与 GitHub CI 全绿(903/903)、无行为回归,可以合并。 PR: #357 (head |
|
Rebased onto current master (v0.0.83 + #359 crush gate) and resolved all 6 conflict hunks as a union — both Pre-flight on the rebased head: typecheck ✅ / 952 tests pass ✅ / build ✅ |
Closes #353
What
Kernel-side half of image pre-compression (billion-context#1095 analysis): pure deterministic routing/downsample decisions + an
image_fullrestore channel. Zero native deps, zero file I/O — encode execution, sidecar I/O, and wire injection stay host-side.New module
src/image-compress.ts, exported from the barrel:Routing & estimation
decideImageRoute(meta, config, classifier?)— pure deterministic decision fn; check order: disabled → not-an-image → below-min-tokens → not-screenshot-like → downsample (with resolved recipe{maxDimension, quality, format}).src/image-tokens.ts: header-only dimension parsing (PNG/GIF/BMP/WebP VP8X|VP8L|VP8/JPEG SOF scan, budgeted base64 head) + OpenAI high-detail tile model (short side scaled up to 768, long side capped at 2048,85 + 170·tiles); unknown dims → 16384 fallback; bytes billing →ceil(b64len/4).ScreenshotClassifier; v1 default heuristic: aspect ratio band [1.4, 2.6] + short-side floor 720px. A trained router can slot in later without touching pipeline code.image_full restore channel
IMAGE_FULL_TOOL/_OPENAI/_RESPONSES), args{ref: "mNNNNN"}.applyImageFull({ref, state, config})— success / idempotent-already-restored / failure texts ([image_full FAILED: ...]); sticky per-session restored-ref set.buildImageFullSystemNote(count)fragment for host prompt injection.imagesShrunk/imageBytesSaved/imageTokensSaved);resetImageFullState()clears ref-keyed entries (hosts MUST call it on compaction reset / fork recovery / session restart — refs re-issue from m00001).ImageStoreEntry {kind:"image", ...}for the not-yet-merged content store (#1097).Config
imageCompression?: {enabled, minTokens=512, maxDimension=1280, quality=80, format="webp"}— defaults + validation insrc/config.ts, sub-field merge exactly likeabsorb; host-side 3-level merge unchanged.Answers to the issue's open questions
Behavior changes (disclosure)
enabled:false).mergeCompressionState. Old persisted states untouched (all readers use??); one pre-existing test literal updated to match the new seeded zeros.Verification
npm run typecheckclean ·npm test800/800 green (incl. new suite: routing matrix, crafted container headers, determinism loop, image_full failure modes, config/state/persist plumbing) ·npm run buildclean.Host follow-ups stay in billion-context: sharp encode execution, sidecar I/O, wire injection ×4 protocols, logging, packaging (#1095/#1097 integration).