kimi-code/packages/acp-adapter
Kai 0fc0ae380b
feat(agent-core): announce image compression and keep originals readable (#1304)
* feat(agent-core): announce image compression and keep originals readable

Every image ingestion point (ReadMediaFile, MCP tool results, clipboard
paste, REST upload/inline base64, ACP) now places a <system> caption next
to a compressed image stating the original vs. delivered dimensions, byte
size, and format, so downsampling is never silent to the model.

Originals stay readable: file uploads point at the stored blob, and
in-memory images are persisted into the session's media-originals dir
(content-addressed, size-capped, removed with the session; temp-dir
fallback when no session is known).

ReadMediaFile gains region (crop in original-image pixel coordinates,
delivered at full fidelity) and full_resolution (skip downscaling, with
an explicit error over the per-image byte limit), so the model can zoom
into fine detail instead of silently degrading on large images.

* fix(agent-core): exempt compression captions from the MCP text budget

The caption announcing an image's compression was inserted before the
shared 100K text budget was applied, so a chatty MCP result (page text +
screenshot) consumed the budget first and the caption was evicted — or
sliced mid-string into an unclosed <system> fragment — while the
downsampled image survived, silently reintroducing the exact degradation
the caption exists to report, and orphaning the persisted original.

Split the size-limit pass in two and reorder the pipeline: the text
budget now runs on the tool's own text BEFORE compression inserts
captions (exempt by construction), and the per-part binary cap still
runs after compression so compressible screenshots are kept.

* fix(agent-core): harden crop error reporting and document readback semantics

- cropImageForModel rejects non-finite region coordinates with a clean
  message instead of surfacing the codec's internal validation dump
- the full_resolution and cropped-region over-budget errors now include
  exact byte counts alongside the rounded sizes, so a file a hair over
  budget no longer reads "is 3.8 MB, over the 3.8 MB limit"
- read-media.md notes that re-reading a file without region or
  full_resolution reproduces the same downsampled image
2026-07-02 19:07:56 +08:00
..
src feat(agent-core): announce image compression and keep originals readable (#1304) 2026-07-02 19:07:56 +08:00
test feat(agent-core): announce image compression and keep originals readable (#1304) 2026-07-02 19:07:56 +08:00
CHANGELOG.md ci: release packages (#1268) 2026-07-02 11:12:20 +08:00
package.json ci: release packages (#1268) 2026-07-02 11:12:20 +08:00
README.md feat(acp): implement ACP server with session lifecycle, tool streaming, and IDE integration (#368) 2026-06-03 21:11:30 +08:00
tsconfig.json feat(acp): implement ACP server with session lifecycle, tool streaming, and IDE integration (#368) 2026-06-03 21:11:30 +08:00
tsdown.config.ts feat(acp): implement ACP server with session lifecycle, tool streaming, and IDE integration (#368) 2026-06-03 21:11:30 +08:00
vitest.config.ts chore: use raw query imports for prompt sources (#682) 2026-06-12 11:47:44 +08:00

@moonshot-ai/acp-adapter

Agent Client Protocol adapter for kimi-code. Exposes the kimi-code agent over the Agent Client Protocol so that ACP-compatible clients (editors, IDEs, custom front-ends) can drive a kimi-code session over stdio.

Part of the Kimi Code monorepo.

Minimum usage

import { createKimiHarness } from '@moonshot-ai/kimi-code-sdk';
import { runAcpServer } from '@moonshot-ai/acp-adapter';

const harness = await createKimiHarness();
await runAcpServer(harness);

runAcpServer reads JSON-RPC from process.stdin, writes to process.stdout, and resolves when the client closes the connection. SIGINT and SIGTERM trigger a graceful drain that calls harness.close() before the process exits.

See docs/zh/reference/kimi-acp.md for the full capability matrix (which Agent methods are wired, which extensions are stubbed, image / MCP support) and docs/zh/guides/ides.md for Zed and JetBrains setup.

License

MIT