UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

45 lines • 2.19 kB
/** * Per-session, per-model thinking-level memory (senpi#3819). * * The session file is the single source: every `thinking_level_change` names the model the level * applied to, so the map is rebuilt from the branch on resume, fork and tree navigation alike, and * no client (TUI, desktop, RPC) keeps a copy of its own. */ import type { ThinkingLevel } from "@earendil-works/pi-agent-core"; import type { SessionEntry } from "./session-manager.ts"; /** * Where the thinking level in force came from. * - `explicit`: a direct level request (`setThinkingLevel`, `/thinking`, RPC, a favorite's `:level`). * - `session`: this session's last level for the model, restored by a model switch. * - `global`: the model's last-used level from any session (`modelThinkingLevels`). * - `model-default`: the model's own declared default. * - `default`: the configured or built-in default. * - `fallback`: the ephemeral level a retry fallback applied. * - `clamped`: a requested or restored level the model cannot run, replaced by its nearest supported one. */ export type ThinkingLevelSource = "explicit" | "session" | "global" | "model-default" | "default" | "fallback" | "clamped"; export declare function modelThinkingKey(model: { readonly provider: string; readonly id: string; }): string; /** * The last level each model ran at on this branch, keyed `provider/id`. Entries written before * senpi#3819 carry no model and are skipped: attributing them by position would misfile the level a * switch writes just before its `model_change`. */ export declare function deriveSessionModelThinkingLevels(path: readonly SessionEntry[]): Record<string, ThinkingLevel>; /** Re-derives only when the branch leaf moved, so repeated `get_state` reads stay O(1). */ export declare class SessionThinkingMemory { private cached; private readonly source; constructor(source: { getLeafId(): string | null; getBranch(): SessionEntry[]; }); levels(): Record<string, ThinkingLevel>; levelFor(model: { readonly provider: string; readonly id: string; }): ThinkingLevel | undefined; } //# sourceMappingURL=session-thinking-memory.d.ts.map