mirror of
https://github.com/agentclientprotocol/claude-agent-acp.git
synced 2026-11-13 12:51:35 +00:00
## Summary - surface Claude context compaction as a synthetic ACP tool lifecycle instead of assistant text - emit provider-neutral `_meta.contextCompaction` metadata with schema version 1 - handle status, stream heartbeat, compact-boundary, terminal-only, failure, and duplicate terminal event shapes - keep the generated compaction summary internal to the agent ## Protocol Compaction tool calls use `kind: "think"`, title `Compact conversation`, standard ACP lifecycle statuses, and optional metadata fields `trigger`, `preTokens`, `postTokens`, `durationMs`, and `error`. ## Testing - `npm run test:run` (769 passed, 26 skipped) - `npm run build` - `npm run check`
30 lines
936 B
TypeScript
30 lines
936 B
TypeScript
export const CONTEXT_COMPACTION_META_KEY = "contextCompaction";
|
|
export const CONTEXT_COMPACTION_META_VERSION = 1;
|
|
|
|
export type ContextCompactionTrigger = "manual" | "automatic";
|
|
|
|
export interface ContextCompactionMetadata {
|
|
version: typeof CONTEXT_COMPACTION_META_VERSION;
|
|
trigger?: ContextCompactionTrigger;
|
|
preTokens?: number;
|
|
postTokens?: number;
|
|
durationMs?: number;
|
|
error?: string;
|
|
}
|
|
|
|
/**
|
|
* Provider-neutral metadata for a synthetic ACP context-compaction tool call.
|
|
* The standard toolCallId and status fields own lifecycle identity and phase;
|
|
* this extension carries only compaction-specific facts.
|
|
*/
|
|
export function createContextCompactionMeta(
|
|
metadata: Omit<ContextCompactionMetadata, "version"> = {},
|
|
): Record<typeof CONTEXT_COMPACTION_META_KEY, ContextCompactionMetadata> {
|
|
return {
|
|
[CONTEXT_COMPACTION_META_KEY]: {
|
|
version: CONTEXT_COMPACTION_META_VERSION,
|
|
...metadata,
|
|
},
|
|
};
|
|
}
|