UNPKG

@code-yeongyu/senpi

Version:

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

27 lines • 2.36 kB
import type { AnthropicSubscriptionAuthLane } from "./options.ts"; /** Prompt-cache lifetimes Claude Code accepts for `CLAUDE_CODE_PROMPT_CACHE_TTL`. */ export type PromptCacheTtl = "5m" | "1h"; export declare const PROMPT_CACHE_TTL_ENV = "CLAUDE_CODE_PROMPT_CACHE_TTL"; /** Claude Code reads this before `CLAUDE_CODE_PROMPT_CACHE_TTL`: when set, every lifetime it writes is 5 minutes. */ export declare const FORCE_PROMPT_CACHING_5M_ENV = "FORCE_PROMPT_CACHING_5M"; type QueryEnvironment = { env?: Record<string, string | undefined>; }; /** * Pin Claude Code's prompt-cache lifetime for a one-shot query and return it, so senpi's history breakpoint uses the * same lifetime (senpi#2982). The Messages API rejects a 1-hour breakpoint that follows a 5-minute one, and Claude Code * otherwise picks its lifetime per request: 1 hour on a subscription within its usage limits, 5 minutes on an API key * or after the limits. `FORCE_PROMPT_CACHING_5M` wins, as it does in Claude Code; then a lifetime from a loaded * settings file. The managed subscription lanes pin 1 hour, * Claude Code's subscription default; so does the `claude-cli` lane, whose account is a verified first-party claude.ai login. The ambient lane can be an API key or a subscription login, so nothing is * pinned there unless a lifetime is set explicitly — and a lifetime set in a loaded settings file counts as explicit * (senpi#2988): Claude Code applies the `env` block of the settings files it loads, so `settingsEnv` carries the * effective settings env for the sources this attempt loads. Precedence is settings env, then explicit env, then the * lane default: Claude Code writes each settings source's env over the process env, and launch-env keys are only * protected when the session is host-orchestrated (a desktop host, or `CLAUDE_CODE_ENVIRONMENT_KIND=byoc`); an SDK * spawn is neither, so a settings value wins over the process env and over `options.env`, and a settings value * wins over senpi's assumption about Claude Code's default. */ export declare function pinOneShotPromptCacheTtl(options: QueryEnvironment, authLane: AnthropicSubscriptionAuthLane, environment: Readonly<Record<string, string | undefined>>, settingsEnv?: Readonly<Record<string, string | undefined>>): PromptCacheTtl | undefined; export {}; //# sourceMappingURL=prompt-cache-ttl.d.ts.map