@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
26 lines • 1.66 kB
TypeScript
import { type Context, type Model, type WarmPromptCacheOptions, type WarmPromptCacheResult } from "@earendil-works/pi-ai";
import type { ExtensionAPI, ExtensionContext } from "../../types.ts";
export declare const PROMPT_CACHE_PREWARM_TIMEOUT_MS = 30000;
export type WarmPromptCacheFn = (model: Model<any>, context: Context, options?: WarmPromptCacheOptions) => Promise<WarmPromptCacheResult>;
export interface SessionPrewarmDependencies {
readonly warm: WarmPromptCacheFn;
readonly isPrewarmModel?: ((model: Model<any>) => boolean) | undefined;
}
export interface SessionPrewarm {
start(ctx: ExtensionContext): void;
cancel(): void;
}
/**
* Arm at session start, then prewarm once on the first draft edit (senpi#3140).
* A submitted prompt consumes the opportunity: the real request warms its own prefix.
* The request is the host's `getPromptCachePrefixRequest()` prefix, the first user turn's
* request with an empty conversation, because the platform reuses a prefix only up to a
* block boundary: a prewarmed system prompt that stops short of the turn's is never read.
* When the host cannot build that prefix without side effects (an extension handler that is
* not preview-safe, or a user prompt that already started its turn), a `skipped` entry
* records why (senpi#2115).
* The request runs detached from the turn pipeline, so it can never delay or fail the
* first user turn; its billed usage is recorded as a custom entry that session stats count.
*/
export declare function createSessionPrewarm(pi: ExtensionAPI, dependencies: SessionPrewarmDependencies): SessionPrewarm;
//# sourceMappingURL=session-prewarm.d.ts.map