@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
40 lines • 1.98 kB
TypeScript
import type { AgentMessage } from "@earendil-works/pi-agent-core";
import { type SessionEntry } from "../../../session-manager.ts";
import type { ModelUsabilityBudgetProjection } from "./model-usability-budget.ts";
export declare const RESUME_SLICE_SCHEMA = "senpi.compaction.resume-slice.v1";
export declare const RESUME_SLICE_ORIGIN = "resume-admission";
export interface ResumeSlicePlan {
readonly firstKeptEntryId: string;
readonly summary: string;
readonly tokensBefore: number;
readonly tokensAfter: number;
readonly droppedEntries: number;
}
export interface ResumeSliceInput {
readonly entries: readonly SessionEntry[];
readonly projection: ModelUsabilityBudgetProjection;
/**
* Provider-reported tokens per estimated token (senpi#3447). The projection's
* live context is in reported tokens, so every per-message measure is scaled by
* this before it is compared with the window. Defaults to 1.
*/
readonly tokenScale?: number;
}
export declare function resumeSliceNotice(plan: ResumeSlicePlan): string;
/**
* Live context tokens at `tokenScale` reported tokens per estimated token
* (senpi#3447). A compaction or branch summary is written fresh and its estimate
* is about right, so only the other messages take the reported ratio.
*/
export declare function chargeContextTokens(messages: readonly AgentMessage[], tokenScale: number): number;
export declare function contextTokenParts(messages: readonly AgentMessage[]): {
readonly summaryTokens: number;
readonly otherTokens: number;
};
/**
* Choose the smallest deterministic context reduction that lets an over-window
* restored session carry an ordinary request. `findCutPoint` owns boundary
* safety, so a retained tool result always keeps its originating tool call.
*/
export declare function planResumeSlice({ entries, projection, tokenScale, }: ResumeSliceInput): ResumeSlicePlan | undefined;
//# sourceMappingURL=resume-slice.d.ts.map