@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
56 lines • 3.21 kB
TypeScript
import type { Context } from "@earendil-works/pi-ai";
/**
* Most distinct historical images one cold-seed / flatten replay re-sends (#2490).
* The user's own uploads are kept first, then the most recently returned tool
* images; every other historical image becomes a one-line note. Every replayed
* image is labeled as history in the turn that held it (#2768), so the model
* does not read an earlier upload as attached to the new question. The final
* user message is not history and always carries its own images.
*/
export declare const MAX_REPLAYED_HISTORY_IMAGES = 8;
export type ReplayedImageOrigin = {
readonly kind: "user";
} | {
readonly kind: "tool";
readonly toolName: string;
readonly toolCallId: string;
};
type ToolOrigin = Extract<ReplayedImageOrigin, {
kind: "tool";
}>;
export declare const coldSeedImageText: {
/** Every tool image in the history, pending or answered, so its bytes never change when its turn ends (#5275). */
readonly toolImage: (origin: ToolOrigin) => string;
readonly currentTurnToolOutput: (origin: ToolOrigin) => string;
readonly userHistory: "[image the user attached to this message of the history (not part of any newer message)]";
readonly duplicate: (origin: ReplayedImageOrigin, first: ReplayedImageOrigin) => string;
readonly capped: (origin: ReplayedImageOrigin) => string;
readonly unreadable: (origin: ReplayedImageOrigin) => string;
};
/**
* Past `MAX_REPLAYED_HISTORY_IMAGES` distinct user uploads, the oldest ones are dropped in blocks of this many, so the
* history (where uploads are replayed in place) changes once per this many new uploads instead of on every one
* (senpi#2988 item 3). Between 8 - 4 + 1 = 5 and 8 of the newest uploads stay replayed.
*/
export declare const REPLAYED_UPLOAD_DROP_STEP = 4;
export type ReplayedHistoryImages = {
/** Replacement content for each history index that holds an image; every other message is replayed unchanged. */
readonly history: ReadonlyMap<number, readonly unknown[]>;
/** The current turn's tool images, sent after the history and its cache breakpoint. */
readonly currentTurn: readonly unknown[];
};
/**
* Rewrites the image entries of a cold-seed history (#2490): identical bytes are sent once and referenced in text
* afterwards, the replay is capped, and undecodable image data is dropped with a note.
*
* What a history entry becomes depends only on the history before it, never on whether a later assistant message
* answered it, so a request rebuilt after the turn ends starts with the bytes the previous one cached (#5275). A tool
* image is therefore always a text note in the history; while its turn is in progress it is also sent in
* `currentTurn`, which comes after the cache breakpoint and simply disappears when the turn ends (#2768: an answered
* tool image is never re-sent). A user upload is replayed in place under the same label in every state.
*/
export declare function replayHistoryImages(history: Context["messages"], sdkToolName: (piToolName: string) => string, options?: {
readonly inProgressTurn?: boolean;
}): ReplayedHistoryImages;
export {};
//# sourceMappingURL=cold-seed-images.d.ts.map