SLOPSHOPPER

cache-tax

A Claude Code mod that keeps the one-hour prompt cache warm during breaks and stops a cold send once with its estimated rewrite cost. Warming uses model…

bandcommandstatuspromptmodeltimer
★ 276v2.3.1MITupdated 2026-10-22karanb192/cache-tax
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · cache-tax
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM › /keepwarm ⎿ cache-tax: keepwarm on for 6h00m, a ping 50m after each idle stretch keeps the cache read, not re-written ⟨Claude Code's own drawing⟩ ▣ [>] cache-tax · warm · keepwarm 6h00m left · ping in 50m ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
⟨Claude Code's own drawing⟩ ▣ [>] cache-tax · warm · keepwarm 6h00m left · ping in 50m
README

<img src="site/assets/cache-tax-light.svg" alt="Cache Tax" width="64" height="64">

Cache Tax for Claude Code

Keep Claude Code's prompt cache warm during breaks.

Cache Tax is a Claude Code mod that refreshes your prompt cache while you step away and shows the estimated rewrite cost before a cold send. Run /keepwarm 90m before a break. Pings cost tokens; choose a window you expect to return within.

Install · Website · How it works · Costs and limits · Commands

Real recording of cache-tax stopping a cold send with a $6.61 estimate

A two-line recap in a 330k-token session triggered a $6.61 estimate. After resending, the reported cache write was $6.28. Recorded on 2.1.1; current wording says “up to” the estimated token count. These are API-equivalent costs, not extra subscription charges.

Install

Needs Claude Code 2.1.287 or later, a one-hour cache and Claude Code left running. Mods are on by default. Pings cost tokens, including uncapped output.

claude plugin marketplace add karanb192/claude-code-mods
claude plugin install cache-tax@claude-code-mods

Restart Claude Code or run /reload-plugins in an open session. No early-access flag is needed. If you set CLAUDE_CODE_ENABLE_FUNCTION_HOOKS previously, remove it; current Claude Code ignores it.

In a warm session, run /keepwarm to arm six hours. Use /keepwarm 90m for a shorter window, or /keepwarm off to stop.

Check the main cache lifetime. Included subscription usage defaults to one hour. API-key, usage-credit and cloud-provider sessions default to five minutes, so set promptCacheTtl to "1h" for those billing paths. A 50-minute timer cannot protect a five-minute main cache. See Limits for the fork evidence.

Prefer a settings hook? The hook version warns by default, refuses once with CACHE_TAX_BLOCK=1, and provides a standalone status-line countdown. Warming is part of this mod.

How it works

Before a break: /keepwarm arms a bounded window. After 50 idle minutes, a timer inside Claude Code sends one tool-less fork over the session's transcript. It reads usage after every ping and stops if reads are zero or writes reach 10% of reads. There is no background transcript-polling loop.

When you return cold: for a context of at least 50,000 tokens, the guard drops your ordinary message once when its one-hour clock says cold. It shows the estimated rewrite price. Resend to continue, or /clear and start from a note. A prompt no person sent, such as a background task's notification, a scheduled prompt or another session's message, is sent with the price logged, because nobody is there to resend it. Anything a person may have sent keeps the guard, including Remote Control, Slack and channel messages, SDK hosts and prompts Claude Code cannot classify.

A detected cold write automatically arms at least three hours of keepwarm, six with always on, and prints what it cost. /cache-tax shows the current cache estimate, warming window and this session's cold-write tally.

Windows belong to individual sessions. An already-cold session waits for your next turn before pinging, and so does a window restored after Claude Code restarts, until the new process has a turn to fork. A ping refused by a busy API (429, 529, 5xx) is retried after 1, 2 and 4 minutes while it can still land before the cache goes cold. With always on, each of your turns that reaches the cache leaves at least six hours of window at the default period, so any break up to six hours stays warm however long the session runs. The same turn brings back a window that stopped, stretches a shorter one to six hours and resets a testing period; a longer window you set stays. /keepwarm off in any session stops every session rolling from its next turn. A window ends at its deadline; /keepwarm off also cancels it and clears the always setting.

A recorded warming ping

Real keepwarm status showing a 75k-token cache read at $0.02

Sonnet 5, 16 September 2026: the status reported 75k tokens read at $0.02. Nothing appeared in the conversation during the live run. This capture used the one-minute testing interval on 2.0.0; its card's $0.45 rewrite estimate used an older Sonnet price row, versus $0.30 for the same context with the current row. The two-cent ping is a receipt for that session, not a fixed price.

Why a short message can cost so much

When the cached prefix expires, even “give me a recap” can trigger a rewrite of the old context before the answer. Cache Tax's Fable 5.1 price row compares a $20 one-hour write with a $0.25 cache read per million tokens: 80x per token, not 80x total savings. See the pricing assumptions and Anthropic's price table.

Watch the 23-second overview. Its designed scenes label Fable 5.1 list prices; every terminal and status-line pixel comes from the real refusal recording and keep-warm receipt above. The refusal was recorded on 2.1.1 and the keep-warm crop on 2.0.0.

New to caching? Anthropic explains how Claude Code uses it.

Commands

/keepwarm keep warm for six hours /keepwarm 90m keep warm for a window of your own (also 2h30m, 6h) /keepwarm always keep every session warm until six hours after its last turn, remembered across sessions /keepwarm 6h every 2m pinging every two minutes; a testing knob, 1m to 59m, forgotten after this window (with always on, at your next turn) /keepwarm status the warming window, next ping and last receipt /keepwarm off stop, forget the window, and turn always off /cache-tax the card /cache-tax guard warn show the price and send (the hook's default) /cache-tax guard refuse drop a cold send once, the resend goes through (this mod's default)

The refusal, verbatim:

cache-tax: the prompt cache went cold 2h00m ago. Sending this re-writes up to 200,502 tokens at $20/MTok = $4.01 (a warm turn would have cost $0.05). Send it again to pay it, and keepwarm will then hold the cache for 3h00m. Or /clear and start from a note.

The figure is an upper bound. The context count the engine reports for a resumed session is the last response's input, cache read, cache write and output together, and the resume payload carries no separate output count to take off; on one 15-day-old session the refusal said 330,316 tokens and $6.61 and the write that followed was 314k tokens, $6.28.

While keepwarm is armed, the terminal and Desktop Code tab show a row above the prompt with the Cache Tax cube. Its lid is green for warm, orange for cold, and grey before the first turn or after compaction. The bold state label matches; the timer and receipt text use normal weight. Ghostty and kitty can draw the image; other terminals show [>] in its place. A nonempty NO_COLOR selects a bold text icon and an uncolored state label. The row also says warm, cold or unknown, so color is never the only signal. These states use the same one-hour clock as /cache-tax; they are estimates, not a live server cache check.

The row includes the warming window, next ping and last readback. A stopped loop shows a neutral symbol and its reason. /keepwarm off or an expired window removes the row. Surveys temporarily take priority, and other mods' content stays in the band. Sessions without this band retain the plain status text.

The cube follows Claude's light or dark theme. Its terminal image also has a contrasting edge for terminal backgrounds that differ from that setting. The embedded assets come from the website's official SVGs; maintainers can regenerate them with python3 tools/generate-status-icons.py and rsvg-convert installed. No image files are read or fetched at runtime.

The mod reads the theme and NO_COLOR once when the session starts. Accepted theme changes update the icon immediately; ordinary redraws do not reread either setting. Set NO_COLOR before starting the session.

Both forms installed

The hook and the mod share a name and a job, so having both means two guards on every cold send. The mod checks at session start whether the hook's /cache-tax:status command exists and says so once. Keep one guard. The hook remains an option for people who prefer settings hooks. Before uninstalling it, check your status line: the 🧊 row wired to cache-tax.js comes from the hook's files. This mod draws above the prompt while keepwarm is armed; it does not replace your shell status line.

What it can reach

Validated on Claude Code 2.1.304:

❯ ./register.ts hooks: config.set{key=theme}, ui.render{component=AbovePrompt}, session.start, session.end, classic.SessionStart, command.run{command=keepwarm}, command.run{command=cache-tax}, prompt.submit, turn.step, turn.complete, session.compact ❯ ./register.ts calls: $.clock.after (via arm, ping), $.clock.now, $.command.list, $.command.register, $.config.list, $.env.get, $.model.fork (via ping), $.session.id (via reseat, seat), $.session.model (via seat), $.session.usage, $.store.delete (via endConversation, prune, startWindow, stop), $.store.get, $.store.set, $.ui.invalidate, $.ui.log, $.ui.resolve, $.ui.status ❯ ./register.ts env reads: NO_COLOR

Reach L2, drives Claude. Sees every prompt you type, every model request's timing and every answer's token counts.

Threat model for cache-tax (reach L2, drives Claude)

  1. Reads: of each prompt, whether it starts with a slash and nothing else (the text is passed on untouched, never kept, never logged); the time; the token counts and model id the engine already holds on turn.complete and on the fork's reply; the resume fields Claude Code computes for settings hooks; the command list; the session id, the session's model and the engine's own context figure and start time, once per conversation the process runs; the reason and session id of a conversation ending under /clear or an in-process resume; each main request's message count; from its own $.store, the keepwarm deadline and the ping period keyed by session id, plus the global always switch and guard mode
  2. Runs: one $.model.fork per idle stretch inside a keepwarm window, one per ping period (50 minutes unless the testing knob set it, floor 1 minute), never outside the window, never onto a cache the mod already knows is cold, never after a readback that read nothing or wrote at least a tenth of what it read
  3. Sends: nothing leaves the machine except the fork, an API request over the session's own transcript with a fixed one-line prompt
  4. Persists: in $.store, the keepwarm deadline and the ping period under this session's id (with always on, rewritten after each turn), and the always switch and the guard mode for every session; a window that has ended is deleted at stop and at this session's next start, together with the bare keys of a 2.1.0 store; another session's keys are never deleted here, because a read followed by a delete cannot be made atomic against that session renewing its window, so a session that armed keepwarm and never came back leaves two small keys behind; the session's cold-write tally lives in memory and dies with the session
  5. Hostile input: the only text it parses is the argument of its two commands, matched against a duration regex and five literals; of the prompt text only the first non-blank character is inspected, for a slash; tool results and files never reach a branch; the fork's prompt is a constant, so nothing crafted can be sent through it; a refusal only ever drops the user's own message, and the resend is unconditional; if a hook throws, the engine skips it and the message enters unguarded, with one dim line

Cost and the plan-limit question

Prices are the list table, where Fable 5.1 reads at $0.25, writes the 1h tier at $20 and answers at $50 per million tokens; Sonnet 5 has its own row ($0.20, $4, $10). On an API key the arithmetic is plain. A ping bills the cache read, its own few uncached tokens at the base rate, and whatever the model says back at the output rate; the displayed ping cost counts all of it, since a fork takes no output cap and a model at high effort may think before it says "warm". A comeback after the lapse is a write. The card prints the read-only upper bound for your model, 80 pings on Fable 5.1, with the idle that covers at the current ping period; a real ping costs a little more than a read, so the true break-even sits below that number. On a subscription the dollars are a yardstick, not the bill, and how a cache read weighs against the 5-hour and weekly limits is not documented anywhere I could find. Watch the rate-limit row of your status line during the first window.

Limits

  • Mods require Claude Code 2.1.287+. They are on by default, but local settings, safe mode or organization policy can prevent them from loading. See mod controls.
  • The 50-minute schedule needs a one-hour main cache. Included subscription usage has it by default. Other billing paths need promptCacheTtl set to "1h".
  • One transcript-verified return at the default interval, Fable 5.1 on a subscription, 19 September 2026: /keepwarm armed at minute 42 of a break, the ping fired at minute 50 and read 157k, and the message sent at minute 62 read 156,886 tokens from cache and wrote 2,255. Claude Code's own cache countdown reset to 58 minutes after the ping, so the fork carried the one-hour TTL. One run, one configuration: it shows the ping kept that cache alive past the hour, not net savings for every setup. Claude Code documents forks in its non-main request bucket, normally five minutes. In this run, the fork still read the one-hour session prefix and reset the native countdown. That is observed behavior in one configuration, not proof that every provider handles the buckets identically.
  • A ping that reads warm proves the cache was warm then. Prefix changes can invalidate the cache regardless of time. The exact effect depends on the model and when Claude Code applies the change; see Claude Code's cache behavior.
  • Resume fields let the guard check the first ordinary send after resuming. If those fields are absent, the first turn seeds its clock and context.
  • On Team and Enterprise accounts a managed plugin seated above this mod handles the classic events and compaction and continues beneath it, so they never reach the mod. It then learns a /clear from the session's end, so keepwarm stops and the new conversation gets its own window; a resumed transcript's context from the engine's figures, with no time of its last response, so from an hour after that transcript's first launch the first message logs what a cold send would cost instead of refusing; and a compaction from a request over fewer than half the previous one's messages (a rewind takes a few off, a summary replaces tens), so a ping or a send between the compaction and that request still sees the old context. The summary written after a compaction is never scored as a cold write; a cold write the same turn paid before it still is, when the host reports usage per request. A window carried through an in-process resume moves to the new session's keys.
  • The refusal's token count is an upper bound: it is the context the engine reports for the last response, which on a resume includes that response's output, and the mod has no separate output count to subtract.
  • The cold-write tally is per session and in memory; /clear empties it.
  • Context size is the engine's live window figure. A turn's own usage is its responses summed, which on a ten-step turn is ten reads of the context, so it is only the fallback where the host reports no live figure.

Local development

From a local checkout, load it for one session:

claude --plugin-dir .

To keep it installed, use the marketplace commands.

Prove it on your own session

The mock-clock tests prove the timer, the guard and the scoring, not that a fork hits the main cache. One ping proves that, and it costs a cache read plus the answer. In any warm session:

Reply with one word: ready /keepwarm 1h every 1m

Watch the row above the prompt after a minute, or the plain status text on other surfaces. last ping read 20k $0.01 reports the fork's readback. keepwarm stopped: the ping read ... and wrote ... means the readback did not meet the warm threshold; the loop has stopped. API busy, ping retry 1 of 3 means a 429, 529 or 5xx is being retried; the loop stops if the API is still busy after three retries or a minute before the cache goes cold. nothing to fork yet means the process has no conversation to fork, as after a restart; the window waits for your next message. Any other API error, an interruption or an empty reply stops the loop with a reason. Older engines that return null show a combined cold-snapshot or API-failure message. Finish with /keepwarm off. This short check establishes a cache read, not retention across the default 50-minute interval.

Tests and typecheck

Run from the repository root:

claude plugin validate .claude-plugin/plugin.json
claude plugin test .

The 160 tests use a mock clock and engine. They cover:

  • Guard: refuse once and resend, warn mode, slash commands, small contexts, prompts nobody typed, resume seeding and cold-write scoring.
  • Warming: command defaults and refused windows and periods, always/off, always after /clear, always rolling from the last turn, idle resets, usage-based stopping, cold-window expiry and delayed timers after sleep.
  • Session state: isolated store keys, restored windows, legacy cleanup, clear/compaction resets and subagent isolation.
  • Managed plugins above the mod: /clear, resume, a restored window and compaction with the classic and compaction events continued beneath the user tier, the same events delivered twice or out of order without a second window, warning or reset, a window and a model change carried through an in-process resume, a transcript that turns old enough to be cold after its resume, a rewind told apart from a compaction, a summary write that is no cold write beside a cold write that is (a guarded send compacted before its first request, two compactions in one turn), an end of the old conversation that overlaps or outlasts the classic resume, and a /keepwarm run before the host reports the next conversation's id.
  • Pricing and display: a row for every listed model, the Haiku 5.5 long-prompt tier priced per request, Opus 4 and 4.1 apart from Opus 4.5, output and uncached input costs, context counts, duration formatting and the read-only break-even figure.
  • Indicator: terminal images and desktop SVGs, theme selection, warm/cold transitions, resume, compaction, clear, expiry, surveys, other mods' content, text alternatives and NO_COLOR fallback.
  • Preferences: one read per session, immediate theme updates, denied changes and the effective theme returned by the settings writer.
  • Fork failures: a busy API is retried while the cache is warm, a retry that wakes too late is dropped, nothing to fork waits for the next turn, one ping is out at a time, a reply that lands after a request, /clear or compaction is discarded, and other failures and the null result returned by older releases stop without retrying.

The render tests check the element tree, not native terminal or desktop pixels. They do not validate server-side cache retention. See the live check.

Typecheck

Load this checkout with claude --plugin-dir . to generate declarations beside the plugin. Then, from the repository root:

npx -p typescript tsc -p .

Generated declarations live in .claude-plugin/types/. Keep them untracked.

Source 2 files
hooks/register.ts 787 lines
1import type { EngineInterface, Register } from 'claude-code'
2import { statusIcons } from './status-icons'
3
4const TTL_MS = 60 * 60 * 1000
5const PING_AFTER_MS = 50 * 60 * 1000
6const MIN_PING_MS = 60 * 1000
7const MAX_RETRIES = 3
8const AUTO_WARM_MS = 3 * 60 * 60 * 1000
9const DEFAULT_WINDOW_MS = 6 * 60 * 60 * 1000
10const BIG_TOKENS = 50000
11const PING_PROMPT = 'Reply with the single word: warm'
12const KEY_DEADLINE = 'deadline'
13const KEY_EVERY = 'every'
14const KEY_GUARD = 'guard'
15const KEY_ALWAYS = 'always'
16
17// Prompts no person sent, so nobody could send them again after a refusal. Every
18// other origin, including sdk, unclassified and the owner's own Slack or channel
19// messages, may carry a person's words and keeps the guard.
20const UNATTENDED = new Set(['task-notification', 'scheduled-trigger', 'peer', 'peer-send-message', 'projects-relay', 'coordinator', 'observer', 'observer-activity'])
21
22const LONG_PROMPT_TOKENS = 100000
23
24// $ per million tokens, [cache read, 1h cache write, output], list prices October 2026.
25// More specific families first: a model id takes the first row it matches.
26const PRICES: Array<[string | RegExp, number, number, number]> = [
27  ['fable-5-1', 0.25, 20, 50],
28  ['mythos-5-1', 0.25, 20, 50],
29  ['fable-5', 1, 20, 50],
30  ['mythos-5', 1, 20, 50],
31  ['opus-5-5', 0.2, 8, 20],
32  ['opus-5', 0.5, 10, 25],
33  // Opus 4 and 4.1 in every spelling (claude-opus-4-1-20250805, claude-opus-4@20250514, the -0 and -1 aliases), never Opus 4.5 and later.
34  [/opus-4(?:-[01])?(?:$|[^-\d]|-20\d{6})/, 1.5, 30, 75],
35  ['opus-4', 0.5, 10, 25],
36  ['sonnet-5-5', 0.1, 4, 10],
37  ['sonnet-5', 0.2, 4, 10],
38  ['sonnet', 0.3, 6, 15],
39  ['haiku-5-5', 0.01, 0.2, 0.5],
40  ['3-5-haiku', 0.08, 1.6, 4],
41  ['haiku-3-5', 0.08, 1.6, 4],
42  ['haiku', 0.1, 2, 5],
43]
44
45// A request whose prompt, cache reads and writes included, is over 100k tokens pays these instead.
46const LONG_PRICES: Array<[string, number, number, number]> = [
47  ['haiku-5-5', 0.05, 1, 2.5],
48]
49
50type PingRecord = { at: number; read: number; write: number; usd: number | null; warm: boolean }
51type Miss = { at: number; tokens: number; usd: number | null }
52type GuardMode = 'refuse' | 'warn'
53
54export type State = {
55  hasBand: boolean
56  sid: string
57  deadline: number
58  every: number
59  always: boolean
60  lastRequestAt: number
61  lastModel: string | null
62  ctx: number
63  compacted: boolean
64  resumedAt: number
65  transcript: number
66  guard: GuardMode
67  ackedAt: number
68  coldWritePending: boolean
69  misses: Miss[]
70  pending: { cancel: () => void } | null
71  last: PingRecord | null
72  stopped: string | null
73  waitForTurn: boolean
74  retries: number
75  retryReason: string
76  gen: number
77  tick: number
78  offs: number
79  turnOffs: number | null
80  inFlight: boolean
81  stepWrites: StepWrites | null
82  steps: number
83  endingSid: string
84}
85
86/** What this turn's main requests wrote before any compaction it saw, priced per request where the steps reported usage. */
87type StepWrites = { tokens: number; usd: number; priced: boolean }
88
89function priceOf(model: string | null, promptTokens: number): [number, number, number] | null {
90  const m = (model ?? '').toLowerCase().replace(/[\s.]+/g, '-')
91  if (promptTokens > LONG_PROMPT_TOKENS) {
92    for (const [family, read, write, output] of LONG_PRICES) if (m.includes(family)) return [read, write, output]
93  }
94  for (const [family, read, write, output] of PRICES) {
95    if (typeof family === 'string' ? m.includes(family) : family.test(m)) return [read, write, output]
96  }
97  return null
98}
99
100export function parseDuration(text: string): number | null {
101  const m = /^(?:(\d+)h)?(?:(\d+)m)?$/.exec(text.trim())
102  if (!m || (m[1] === undefined && m[2] === undefined)) return null
103  return (Number(m[1] ?? 0) * 60 + Number(m[2] ?? 0)) * 60 * 1000
104}
105
106export function fmtDuration(ms: number): string {
107  const total = Math.max(0, Math.round(ms / 60000))
108  const h = Math.floor(total / 60)
109  const m = total % 60
110  if (h >= 48) return `${Math.floor(h / 24)}d ${h % 24}h`
111  return h > 0 ? `${h}h${String(m).padStart(2, '0')}m` : `${m}m`
112}
113
114function fmtUsd(usd: number | null): string {
115  return usd == null ? 'n/a' : '$' + (usd >= 100 ? usd.toFixed(0) : usd.toFixed(2))
116}
117
118function fmtTok(n: number): string {
119  return n >= 1e6 ? (n / 1e6).toFixed(1) + 'M' : n >= 1000 ? Math.round(n / 1000) + 'k' : String(n)
120}
121
122function coldUsd(s: State): number | null {
123  const price = priceOf(s.lastModel, s.ctx)
124  return price ? s.ctx * price[1] / 1e6 : null
125}
126
127function warmUsd(s: State): number | null {
128  const price = priceOf(s.lastModel, s.ctx)
129  return price ? s.ctx * price[0] / 1e6 : null
130}
131
132/** Everything a fork bills: the cache read, any cache write, uncached input at the base rate (half the 1h write rate), and the output. */
133function pingUsd(u: { input_tokens: number; output_tokens: number; cache_read_input_tokens: number; cache_creation_input_tokens: number }, price: [number, number, number]): number {
134  return (u.cache_read_input_tokens * price[0] + u.cache_creation_input_tokens * price[1] + u.input_tokens * price[1] / 2 + u.output_tokens * price[2]) / 1e6
135}
136
137/** The read-only upper bound: pings at the cache-read rate that cost as much as one cold write of the same context. */
138function breakEvenPings(s: State): number | null {
139  const price = priceOf(s.lastModel, s.ctx)
140  if (!price || s.ctx <= 0) return null
141  return Math.floor(price[1] / price[0])
142}
143
144function isCold(s: State, now: number): boolean {
145  return s.lastRequestAt > 0 && !s.compacted && now - s.lastRequestAt >= TTL_MS
146}
147
148function guardText(s: State, now: number): string {
149  const price = priceOf(s.lastModel, s.ctx)
150  const rate = price ? `$${price[1]}/MTok` : 'the cache-write rate'
151  const warm = warmUsd(s)
152  return `the prompt cache went cold ${fmtDuration(now - s.lastRequestAt - TTL_MS)} ago. Sending this re-writes ` +
153    `up to ${s.ctx.toLocaleString('en-US')} tokens at ${rate} = ${fmtUsd(coldUsd(s))}` +
154    (warm == null ? '' : ` (a warm turn would have cost ${fmtUsd(warm)})`) + '.'
155}
156
157export type ResumeFields = {
158  source: string
159  model?: string
160  context_tokens?: number
161  seconds_since_last_response?: number
162  prompt_cache_likely_expired?: boolean
163  estimated_cache_write_usd?: number
164}
165
166/** /clear starts a new conversation in the same process; nothing priced before it still exists. */
167export function resetForClear(s: State) {
168  s.ctx = 0
169  s.lastRequestAt = 0
170  s.compacted = false
171  s.resumedAt = 0
172  s.transcript = 0
173  s.ackedAt = 0
174  s.coldWritePending = false
175  s.misses = []
176  s.waitForTurn = false
177  s.stepWrites = null
178  s.steps = 0
179  outdate(s)
180  disarm(s)
181}
182
183/** Applies a resumed session's fields to the state; returns the line to log, if any. */
184export function seedFromResume(s: State, e: ResumeFields, now: number): string | null {
185  if (e.source !== 'resume' && e.source !== 'fork') return null
186  if (typeof e.context_tokens === 'number' && e.context_tokens > 0) s.ctx = e.context_tokens
187  if (typeof e.seconds_since_last_response === 'number') {
188    s.lastRequestAt = now - e.seconds_since_last_response * 1000
189    s.resumedAt = 0
190  }
191  if (typeof e.model === 'string') s.lastModel = e.model
192  s.compacted = false
193  if (e.prompt_cache_likely_expired !== true || s.ctx < BIG_TOKENS) return null
194  const usd = typeof e.estimated_cache_write_usd === 'number' ? fmtUsd(e.estimated_cache_write_usd) : fmtUsd(coldUsd(s))
195  return `resuming cold. The first message re-writes ${s.ctx.toLocaleString('en-US')} tokens, about ${usd}. /clear and paste a summary if you only need the conclusions.`
196}
197
198/** A transcript resumed without the time of its last response: that response came after its first launch, so an hour after that launch the cache may be cold. */
199function mayBeCold(s: State, now: number): boolean {
200  return s.resumedAt > 0 && !s.lastRequestAt && now - s.resumedAt >= TTL_MS
201}
202
203/** The line for a resumed session whose last response time never arrived: the cache may be cold, and this is what that would cost. */
204function unknownText(s: State): string {
205  const price = priceOf(s.lastModel, s.ctx)
206  const rate = price ? `$${price[1]}/MTok` : 'the cache-write rate'
207  return `resumed with up to ${s.ctx.toLocaleString('en-US')} tokens of context and no time of its last response, so the cache may be cold. ` +
208    `If it is, this message re-writes them at ${rate} = ${fmtUsd(coldUsd(s))}.`
209}
210
211/** The conversation was summarized: the next request is the first over the new prefix, and a ping out for the old one is dropped. */
212function markCompacted(s: State) {
213  s.compacted = true
214  s.transcript = 0
215  s.ackedAt = 0
216  outdate(s)
217}
218
219function statusText(s: State, now: number): string | undefined {
220  if (s.stopped) return `keepwarm stopped: ${s.stopped}`
221  if (!s.deadline) return undefined
222  const pingText = s.last ? ` · last ping read ${fmtTok(s.last.read)} ${fmtUsd(s.last.usd)}` : ''
223  const nextText = !s.lastRequestAt ? ' · waiting for the first turn'
224    : s.compacted ? ' · waiting for the first turn after compaction'
225    : isCold(s, now) ? ` · cold now, first ping ${fmtDuration(s.every)} after the next turn`
226    : s.waitForTurn ? ' · nothing to fork yet, first ping after the next turn'
227    : s.retries ? ` · API busy, ping retry ${s.retries} of ${MAX_RETRIES}`
228    : ` · ping in ${fmtDuration(s.lastRequestAt + s.every - now)}`
229  return `keepwarm ${fmtDuration(s.deadline - now)} left${nextText}${pingText}`
230}
231
232function updateStatus($: EngineInterface, s: State, now: number) {
233  if (s.hasBand) $.ui.invalidate('ui.render')
234  else $.ui.status(statusText(s, now))
235}
236
237/** Cancels the timer. Every new timer is set right after this, so the tick also says the schedule changed. */
238function disarm(s: State) {
239  if (s.pending) s.pending.cancel()
240  s.pending = null
241  s.tick++
242}
243
244/** Outdates any ping in flight: /clear, a resume, compaction or stop replaced the state it was sent for. Re-arming or extending the window does not, so a ping out at that moment still counts; a main request outdates it through the request clock. */
245function outdate(s: State) {
246  s.gen++
247}
248
249// The window and its ping period belong to the session that armed them, so a
250// second session, or one resumed from another transcript, never inherits them
251// and cannot turn them off. The always switch and the guard mode stay global.
252function deadlineKey(s: State): string {
253  return `${KEY_DEADLINE}:${s.sid}`
254}
255
256function everyKey(s: State): string {
257  return `${KEY_EVERY}:${s.sid}`
258}
259
260/** Clears this session's own dead window and the bare keys a store written before 2.1.1 still holds. Other sessions' keys are never touched: a read followed by a delete cannot be made atomic against their renewal. */
261async function prune($: EngineInterface, s: State, now: number) {
262  for (const key of [KEY_DEADLINE, deadlineKey(s)]) {
263    const deadline = await $.store.get(key)
264    if (deadline === undefined) continue
265    if (typeof deadline === 'number' && deadline > now) continue
266    await $.store.delete(key)
267    await $.store.delete(KEY_EVERY + key.slice(KEY_DEADLINE.length))
268  }
269}
270
271async function stop($: EngineInterface, s: State, why: string | null, forgetAlways = false) {
272  // Set before any await, so a window being opened at the same moment sees the off and does not write itself back.
273  if (forgetAlways) {
274    s.always = false
275    s.offs++
276  }
277  s.deadline = 0
278  s.every = PING_AFTER_MS
279  s.stopped = why
280  s.retries = 0
281  outdate(s)
282  disarm(s)
283  await $.store.delete(deadlineKey(s))
284  await $.store.delete(everyKey(s))
285  if (forgetAlways) await $.store.delete(KEY_ALWAYS)
286  updateStatus($, s, await $.clock.now())
287}
288
289/** The conversation ended under /clear or an in-process resume. The next one's id cannot be read until the engine has switched, so the state is left unseated. */
290async function endConversation($: EngineInterface, s: State, reason: 'clear' | 'resume') {
291  // Claimed before any await: a second end or a classic start for the same conversation finds it already gone, and an
292  // end cut short by its budget leaves no timer and no old id behind, only the keys below.
293  const keys = [deadlineKey(s), everyKey(s)]
294  const ending = s.sid
295  resetForClear(s)
296  s.sid = ''
297  s.endingSid = ending
298  // /clear ends the conversation the window was armed for. A resume carries the window on to the next one, under its
299  // id: the old id's keys go here, or a /keepwarm off there could never find them and the old session would re-arm them.
300  if (reason === 'clear') {
301    s.deadline = 0
302    s.every = PING_AFTER_MS
303    s.stopped = null
304    s.retries = 0
305  }
306  for (const key of keys) await $.store.delete(key)
307  if (reason === 'clear') updateStatus($, s, await $.clock.now())
308}
309
310/** Reads the session the process runs now: its id, its model and the engine's figures for its context. Returns the time read with them. */
311async function seat($: EngineInterface, s: State, id?: string): Promise<number> {
312  s.sid = id ?? await $.session.id()
313  s.endingSid = ''
314  s.lastModel = await $.session.model()
315  const usage = await $.session.usage()
316  const now = await $.clock.now()
317  if (usage.context.tokens) s.ctx = usage.context.tokens
318  // A resumed transcript's last response came somewhere between its first launch and now; only the resume fields say where.
319  s.resumedAt = !s.lastRequestAt && usage.context.tokens ? usage.startedAt : 0
320  return now
321}
322
323/** Seats the state in the conversation that followed a /clear or a resume, once, and arms what always or a window opened meanwhile asks for. */
324async function reseat($: EngineInterface, s: State) {
325  if (s.sid) return
326  const id = await $.session.id()
327  // The host still answers with the conversation being ended: the next one is not there to seat yet, so nothing is
328  // seated under the old id, and a window opened meanwhile waits in memory for the id it belongs to.
329  if (id === s.endingSid) return
330  const now = await seat($, s, id)
331  if (s.always) await startWindow($, s, DEFAULT_WINDOW_MS, PING_AFTER_MS)
332  // A window carried over, or armed while the conversation was ending, is written under this id.
333  else if (s.deadline) await startWindow($, s, s.deadline - now, s.every)
334  else updateStatus($, s, now)
335}
336
337async function arm($: EngineInterface, s: State) {
338  disarm(s)
339  s.retries = 0
340  if (!s.deadline) return
341  const now = await $.clock.now()
342  // A timer set while the clock was read, such as a retry, is replaced here, never left running beside this one;
343  // from this line to the assignment below nothing awaits.
344  disarm(s)
345  s.retries = 0
346  if (now >= s.deadline) return stop($, s, null)
347  // A cold window still needs expiry cleanup, but must not send a model request.
348  if (s.lastRequestAt && !s.compacted && !isCold(s, now)) {
349    const untilCold = s.lastRequestAt + TTL_MS - now
350    // Waiting for a turn sends nothing, but wakes when the cache goes cold so the row says so.
351    if (s.waitForTurn) s.pending = $.clock.after(Math.min(s.deadline - now, untilCold), () => { void arm($, s) })
352    else {
353      const delay = Math.min(s.deadline - now, untilCold, Math.max(1000, s.lastRequestAt + s.every - now))
354      s.pending = $.clock.after(delay, () => { void ping($, s) })
355    }
356  } else {
357    s.pending = $.clock.after(s.deadline - now, () => { void arm($, s) })
358  }
359  updateStatus($, s, now)
360}
361
362async function ping($: EngineInterface, s: State) {
363  s.pending = null
364  if (!s.deadline) return
365  const tick = s.tick
366  const now = await $.clock.now()
367  // A timer set or cancelled while the clock was read (an extension, a retry, a turn) owns the window now;
368  // if that left no timer, a window still open is armed again rather than left without one.
369  if (s.tick !== tick) return s.pending || s.inFlight ? undefined : arm($, s)
370  // One fork at a time: the one already out re-arms when it settles. Checked after the await, and set
371  // below with no await in between, so two timers can never both send.
372  if (s.inFlight) return
373  if (now >= s.deadline) return arm($, s)
374  if (isCold(s, now)) return arm($, s)
375  if (s.compacted || s.waitForTurn || !s.lastRequestAt) return arm($, s)
376  // A request since this timer was set moved the clock; schedule from it.
377  if (now - s.lastRequestAt < s.every - 1000) return arm($, s)
378  // A host that slept past a retry's slot must not send it inside the last minute.
379  if (s.retries && now >= s.lastRequestAt + TTL_MS - MIN_PING_MS) return stop($, s, s.retryReason + afterRetries(s.retries))
380  const gen = s.gen
381  const sentAt = s.lastRequestAt
382  s.inFlight = true
383  const sent = await $.model.fork({ prompt: PING_PROMPT }).then(reply => ({ reply }), (err: unknown) => ({ err }))
384  const at = await $.clock.now()
385  s.inFlight = false
386  // Checked after the last await. A stop, /clear, resume or compaction, or a main request that moved the
387  // cache clock, replaced what this fork was sent for: its reply is dropped and the window armed afresh.
388  if (gen !== s.gen || s.lastRequestAt !== sentAt) return s.pending ? undefined : arm($, s)
389  if ('err' in sent) return stop($, s, `the ping failed, ${sent.err instanceof Error ? sent.err.message : String(sent.err)}`)
390  const reply = sent.reply
391  if (reply === null) return stop($, s, 'the engine did not send the ping, either the snapshot was cold or the API call failed')
392  if (reply.isAnswered === false) {
393    // A restarted process has no conversation to fork until its first turn; the window waits for one instead of ending.
394    if (reply.reason === 'nothing-to-fork') {
395      s.waitForTurn = true
396      return arm($, s)
397    }
398    const reason = reply.reason === 'api-error' ? `the API call failed${reply.status === null ? '' : ` (${reply.status})`}`
399      : reply.reason === 'aborted' ? 'the ping was interrupted'
400      : 'the ping returned no text'
401    // A busy or failing API is usually brief; retry while a ping can still land a minute before the cache goes cold.
402    if (reply.reason === 'api-error' && (reply.status === null || reply.status === 429 || reply.status >= 500)) {
403      const wait = MIN_PING_MS * 2 ** s.retries
404      if (s.retries < MAX_RETRIES && at + wait < Math.min(s.deadline, s.lastRequestAt + TTL_MS - MIN_PING_MS)) {
405        s.retries++
406        s.retryReason = reason
407        // Replaces any timer set while the fork was out, such as a window extension's, so only the retry fires.
408        disarm(s)
409        s.pending = $.clock.after(wait, () => { void ping($, s) })
410        updateStatus($, s, at)
411        return
412      }
413    }
414    return stop($, s, reason + afterRetries(s.retries))
415  }
416  const u = reply.usage
417  const price = priceOf(s.lastModel, u.input_tokens + u.cache_read_input_tokens + u.cache_creation_input_tokens)
418  // A warm ping reads the prefix and writes only its own message; a write of a tenth of the read or more means the prefix broke.
419  const warm = u.cache_read_input_tokens > 0 && u.cache_creation_input_tokens < 0.1 * u.cache_read_input_tokens
420  const usd = price ? pingUsd(u, price) : null
421  s.last = { at: now, read: u.cache_read_input_tokens, write: u.cache_creation_input_tokens, usd, warm }
422  if (!warm) return stop($, s, `the ping read ${fmtTok(u.cache_read_input_tokens)} and wrote ${fmtTok(u.cache_creation_input_tokens)} tokens (${fmtUsd(usd)}), the cache was already gone`)
423  s.lastRequestAt = now
424  await arm($, s)
425}
426
427function afterRetries(n: number): string {
428  return n ? ` after ${n} ${n === 1 ? 'retry' : 'retries'}` : ''
429}
430
431/** The reply to an arming command; on a cold cache it says when the first ping can come. */
432/** How long keepwarm holds the cache after a paid cold write: the rolling window when always is on. */
433function holdMs(s: State): number {
434  return s.always ? DEFAULT_WINDOW_MS : AUTO_WARM_MS
435}
436
437function armedText(s: State, now: number, windowMs: number): string {
438  if (isCold(s, now)) return `keepwarm on for ${fmtDuration(windowMs)}. The cache is cold now, so the first ping comes ${fmtDuration(s.every)} after the next turn`
439  return `keepwarm on for ${fmtDuration(windowMs)}, a ping ${fmtDuration(s.every)} after each idle stretch keeps the cache read, not re-written`
440}
441
442// A /keepwarm off after `offs` was read wins: the window it cancelled is not written back. A caller that awaited
443// before deciding to open a window passes the count it read first.
444async function startWindow($: EngineInterface, s: State, windowMs: number, every: number, offs = s.offs) {
445  if (s.offs !== offs) return
446  const now = await $.clock.now()
447  if (s.offs !== offs) return
448  const deadline = now + windowMs
449  s.every = every
450  s.deadline = deadline
451  s.stopped = null
452  // Unseated, between a conversation's end and the host reporting the next, the window has no id to be written under; the seat writes it.
453  if (!s.sid) return arm($, s)
454  if (every === PING_AFTER_MS) await $.store.delete(everyKey(s))
455  else await $.store.set(everyKey(s), every)
456  await $.store.set(deadlineKey(s), deadline)
457  if (s.offs !== offs) {
458    // Remove only what this call wrote; a window armed after the off is left alone.
459    if ((await $.store.get(deadlineKey(s))) === deadline) {
460      await $.store.delete(deadlineKey(s))
461      if (!s.deadline) await $.store.delete(everyKey(s))
462    }
463    return
464  }
465  await arm($, s)
466}
467
468function card(s: State, now: number): string {
469  const lines: string[] = []
470  lines.push(`${s.lastModel ?? 'model not seen yet'}`)
471  if (s.compacted) lines.push('state       reset by compaction, waiting for the first turn')
472  else if (s.resumedAt) lines.push(mayBeCold(s, now) ? 'state       unknown, resumed without the time of its last response' : `state       resumed without the time of its last response, warm for up to ${fmtDuration(s.resumedAt + TTL_MS - now)} more`)
473  else if (!s.lastRequestAt) lines.push('state       no request yet this session')
474  else if (isCold(s, now)) lines.push(`state       COLD, last request ${fmtDuration(now - s.lastRequestAt)} ago`)
475  else lines.push(`state       warm, ${fmtDuration(s.lastRequestAt + TTL_MS - now)} left`)
476  lines.push(`context     ${s.ctx.toLocaleString('en-US')} tokens`)
477  lines.push(`cold cost   ${fmtUsd(coldUsd(s))} to re-write it (warm turn ${fmtUsd(warmUsd(s))})`)
478  const always = s.always ? ' (always)' : ''
479  const idle = s.always ? 'off until the next turn, which arms 6h00m (always)' : 'off (/keepwarm to arm it for 6h00m)'
480  lines.push(`keepwarm    ${s.deadline ? (statusText(s, now) ?? '').replace(/^keepwarm /, 'on, ') + always : s.stopped ? `stopped, ${s.stopped}${always}` : idle}`)
481  const pings = breakEvenPings(s)
482  if (pings != null) lines.push(`break-even  up to ${pings} pings at the read rate cost one cold write, about ${fmtDuration(pings * s.every)} of idle at one ping per ${fmtDuration(s.every)}`)
483  lines.push(`guard       ${s.guard === 'refuse' ? 'refuse once (/cache-tax guard warn to only show the price)' : 'warn only (/cache-tax guard refuse to be stopped once)'}`)
484  const paid = s.misses.reduce((a, m) => a + (m.usd ?? 0), 0)
485  lines.push(`session     ${s.misses.length} cold write${s.misses.length === 1 ? '' : 's'} paid, ${fmtUsd(paid)}`)
486  return lines.join('\n')
487}
488
489export function freshState(): State {
490  return {
491    hasBand: false, sid: '', deadline: 0, every: PING_AFTER_MS, always: false, lastRequestAt: 0, lastModel: null, ctx: 0, compacted: false,
492    resumedAt: 0, transcript: 0, guard: 'refuse', ackedAt: 0, coldWritePending: false, misses: [], pending: null, last: null, stopped: null,
493    waitForTurn: false, retries: 0, retryReason: '', gen: 0, tick: 0, offs: 0, turnOffs: null, inFlight: false, stepWrites: null, steps: 0, endingSid: '',
494  }
495}
496
497export const register: Register = on => {
498  const s = freshState()
499  let light = false
500  let noColor = false
501
502  on('config.set', { key: 'theme' }, async ($, e, next) => {
503    const result = await next(e)
504    if (result.deny === undefined) {
505      light = typeof result.value === 'string' && result.value.startsWith('light')
506      if (s.hasBand) $.ui.invalidate('ui.render')
507    }
508    return result
509  })
510
511  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
512    const rest = await next(e)
513    if (!s.hasBand || e.props.hasSurvey) return rest
514    const now = await $.clock.now()
515    const text = statusText(s, now)
516    if (!text || (s.deadline && now >= s.deadline)) return rest
517    const state = s.stopped ? 'stopped' : !s.lastRequestAt || s.compacted ? 'unknown' : isCold(s, now) ? 'cold' : 'warm'
518    const color = noColor ? undefined : state === 'warm' ? 'success' : state === 'cold' ? (light ? '#c15f3c' : '#d97757') : undefined
519    const { Box, Text } = $.ui.resolve(e)
520    const asset = statusIcons[light ? 'light' : 'dark'][state === 'warm' || state === 'cold' ? state : 'neutral']
521    const icon = noColor ? Text({ bold: true, children: ['[>]'] })
522      : e.surface === 'terminal' ? $.ui.resolve(e).Image({ source: { png: asset.png }, columns: 3, rows: 1, alt: '[>]' })
523      : e.surface === 'desktop' ? $.ui.resolve(e).Svg({ source: asset.svg, width: 18, height: 18, alt: 'Cache Tax' })
524      : Text({ color, bold: true, children: ['[>]'] })
525    return Box({ flexDirection: 'column', children: [
526      rest,
527      Box({ flexDirection: 'row', alignItems: 'center', children: [
528        Box({ flexShrink: 0, children: [icon] }),
529        Text({ children: [
530          ' cache-tax · ',
531          Text({ color, bold: true, children: [state] }),
532          ` · ${text}`,
533        ] }),
534      ] }),
535    ] })
536  })
537
538  on('session.start', async ($, e, next) => {
539    const r = await next(e)
540    s.hasBand = e.surface === 'terminal' || e.surface === 'desktop'
541    if (s.hasBand) {
542      const theme = (await $.config.list()).find(row => row.key === 'theme')?.value
543      light = typeof theme === 'string' && theme.startsWith('light')
544      noColor = Boolean(await $.env.get('NO_COLOR'))
545      $.ui.status(undefined)
546    }
547    const now = await seat($, s)
548    await prune($, s, now)
549    const saved = await $.store.get(deadlineKey(s))
550    const savedEvery = await $.store.get(everyKey(s))
551    const savedGuard = await $.store.get(KEY_GUARD)
552    s.deadline = typeof saved === 'number' && saved > now ? saved : 0
553    s.every = typeof savedEvery === 'number' && savedEvery >= MIN_PING_MS && savedEvery < TTL_MS ? savedEvery : PING_AFTER_MS
554    s.guard = savedGuard === 'warn' ? 'warn' : 'refuse'
555    s.always = (await $.store.get(KEY_ALWAYS)) === true
556    // Always means a fresh default window every session, whatever the last one left behind.
557    if (s.always) await startWindow($, s, DEFAULT_WINDOW_MS, PING_AFTER_MS)
558    // The classic start arms a restored window too, but a managed plugin above this tier may continue beneath it; arming twice leaves one timer.
559    else if (s.deadline) await arm($, s)
560    await $.command.register({
561      name: 'keepwarm',
562      description: 'Keep the prompt cache warm: bare for 6h, a window such as 90m, always, off, or status (cache-tax)',
563      argumentHint: '[6h | always | off | status]',
564      immediate: true,
565    })
566    await $.command.register({
567      name: 'cache-tax',
568      description: 'Prompt cache state, cold price and this session\'s cold writes; guard warn|refuse (cache-tax, the Mod)',
569      argumentHint: '[status | guard warn | guard refuse]',
570      immediate: true,
571    })
572    // The hook form of cache-tax ships a /cache-tax:status skill; both installed means two guards.
573    const commands = await $.command.list()
574    if (commands.some(c => c.name === 'cache-tax:status')) {
575      $.ui.log('the hook form (cache-tax@claude-code-hooks) is also installed, so a cold send is warned about or refused twice. Uninstall it, or /cache-tax guard warn here.')
576    }
577    updateStatus($, s, now)
578    return r
579  })
580
581  // On Team and Enterprise accounts a managed plugin seated above this tier handles classic.* and continues beneath it, so
582  // nothing here is relied on alone: session.end carries the /clear, turn.step the compaction, and the engine's own figures
583  // the resumed context. What arrives here refines that, once: a clear already ended is only seated, a seat is never redone.
584  on('session.end', async ($, e, next) => {
585    // Only the conversation this state sits in: after the classic start of the next one, the old id is history.
586    if ((e.reason === 'clear' || e.reason === 'resume') && e.sessionId === s.sid) await endConversation($, s, e.reason)
587    return next(e)
588  })
589
590  // Resume fields seed the guard before any turn of the resumed session has run.
591  on('classic.SessionStart', async ($, e, next) => {
592    const r = await next(e)
593    // A resumed or cleared conversation is not the one a ping in flight was sent for.
594    outdate(s)
595    // The conversation moved under this state without session.end reaching it: the payload names another id, or a
596    // clear names none. One that already seated the new id (a command ran first) is left as it is.
597    if (s.sid && (e.session_id === undefined ? e.source === 'clear' : e.session_id !== s.sid)) await endConversation($, s, e.source === 'clear' ? 'clear' : 'resume')
598    // No session.start fires after /clear, so this is where always arms the new conversation.
599    await reseat($, s)
600    if (e.source === 'clear') return r
601    const line = seedFromResume(s, e, await $.clock.now())
602    if (line) $.ui.log(line)
603    // The seeded clock decides whether a restored or always window pings before the first turn: never when it is cold.
604    await arm($, s)
605    return r
606  })
607
608  on('command.run', { command: 'keepwarm' }, async ($, e) => {
609    await reseat($, s)
610    const words = String(e.args ?? '').trim().split(/\s+/).filter(Boolean)
611    const now = await $.clock.now()
612    if (words[0] === 'off') {
613      const wasAlways = s.always
614      await stop($, s, null, true)
615      return { text: wasAlways ? 'keepwarm is off, and always is off for every session from its next turn' : 'keepwarm is off' }
616    }
617    if (words[0] === 'always') {
618      s.always = true
619      await $.store.set(KEY_ALWAYS, true)
620      await startWindow($, s, DEFAULT_WINDOW_MS, PING_AFTER_MS)
621      const cold = isCold(s, now) ? `. The cache is cold now, so the first ping comes ${fmtDuration(s.every)} after the next turn` : ''
622      return { text: `keepwarm always on: every session stays warm until ${fmtDuration(DEFAULT_WINDOW_MS)} after its last turn; /keepwarm off turns it off for good${cold}` }
623    }
624    if (!words.length) {
625      await startWindow($, s, DEFAULT_WINDOW_MS, PING_AFTER_MS)
626      return { text: armedText(s, now, DEFAULT_WINDOW_MS) }
627    }
628    if (words[0] !== 'status') {
629      const window = parseDuration(words[0])
630      if (!window) return { text: 'keepwarm takes a window such as 6h or 90m, or always, off, or status' }
631      // "every 2m" is a testing knob and lasts only for the window it was given with.
632      let every = PING_AFTER_MS
633      if (words[1] === 'every') {
634        const period = parseDuration(words[2] ?? '')
635        // A period of the cache's whole hour or more would fire only once the cache is already cold.
636        if (period == null || period < MIN_PING_MS || period >= TTL_MS) return { text: 'every takes a period from 1m to 59m' }
637        every = period
638      }
639      await startWindow($, s, window, every)
640      const rolls = s.always && (window < DEFAULT_WINDOW_MS || every !== PING_AFTER_MS)
641      return { text: armedText(s, now, window) + (rolls ? `. Always is on, so your next turn makes it at least ${fmtDuration(DEFAULT_WINDOW_MS)} at one ping per ${fmtDuration(PING_AFTER_MS)}` : '') }
642    }
643    return { text: statusText(s, now) ?? 'keepwarm is off' }
644  })
645
646  on('command.run', { command: 'cache-tax' }, async ($, e) => {
647    await reseat($, s)
648    const words = String(e.args ?? '').trim().split(/\s+/).filter(Boolean)
649    const now = await $.clock.now()
650    if (words[0] === 'guard') {
651      if (words[1] !== 'warn' && words[1] !== 'refuse') return { text: '/cache-tax guard takes warn or refuse' }
652      s.guard = words[1]
653      await $.store.set(KEY_GUARD, s.guard)
654      return { text: s.guard === 'refuse' ? 'guard set to refuse once: a cold send is dropped with its price, the resend goes through' : 'guard set to warn: a cold send goes through with its price shown' }
655    }
656    return { text: card(s, now) }
657  })
658
659  // The message that pays. Only its first character is read.
660  on('prompt.submit', async ($, e, next) => {
661    if (e.origin.kind === 'plugin') return next(e)
662    await reseat($, s)
663    if (typeof e.text !== 'string' || e.text.trimStart().startsWith('/')) return next(e)
664    const now = await $.clock.now()
665    // Without the time of the last response nothing says whether the cache is cold: the price is shown once and the message goes through.
666    if (s.resumedAt) {
667      const cold = mayBeCold(s, now)
668      s.resumedAt = 0
669      if (cold && s.ctx >= BIG_TOKENS) $.ui.log(unknownText(s))
670      return next(e)
671    }
672    if (!isCold(s, now) || s.ctx < BIG_TOKENS) return next(e)
673    // A refused prompt that no person sent would be lost: nobody is there to send it again.
674    const unattended = UNATTENDED.has(e.origin.kind)
675    if (s.guard === 'warn' || unattended) {
676      $.ui.log(`${guardText(s, now)} Sending anyway${unattended ? `, since this ${e.origin.kind} prompt cannot be sent again` : ''}; keepwarm will hold the cache for ${fmtDuration(holdMs(s))} once it lands.`)
677      s.coldWritePending = true
678      return next(e)
679    }
680    if (s.ackedAt === s.lastRequestAt) {
681      s.ackedAt = 0
682      s.coldWritePending = true
683      return next(e)
684    }
685    s.ackedAt = s.lastRequestAt
686    return { drop: `cache-tax: ${guardText(s, now)} Send it again to pay it, and keepwarm will then hold the cache for ${fmtDuration(holdMs(s))}. Or /clear and start from a note.` }
687  })
688
689  on('turn.step', async function* ($, e, next) {
690    if (!e.agentId) {
691      await reseat($, s)
692      // The off count when the turn's first request went out: an off after it wins over what the turn opens.
693      if (e.index === 0) s.turnOffs = s.offs
694      // A compaction leaves a summary where tens of messages were; a rewind takes a few off. A request over fewer than half the
695      // last one's messages is read as a compaction, whether or not session.compact arrived. The context stays as it was, so
696      // turn.complete still scores a cold write this turn paid against it before the live figure replaces it.
697      if (e.messageCount * 2 < s.transcript) markCompacted(s)
698      s.transcript = e.messageCount
699      // Only a request sent before any compaction this turn saw can hold a cold write; what follows one is the summary.
700      if (!s.compacted) s.steps++
701      s.lastRequestAt = await $.clock.now()
702    }
703    const r = yield* next(e)
704    // Each request's write is priced at its own prompt length's tier (Haiku 5.5 changes price at 100k), not the turn's sum.
705    const u = r.usage
706    if (!e.agentId && u && !s.compacted) {
707      const price = priceOf(u.model || e.model, u.input_tokens + u.cache_read_input_tokens + u.cache_creation_input_tokens)
708      const was = s.stepWrites ?? { tokens: 0, usd: 0, priced: true }
709      s.stepWrites = { tokens: was.tokens + u.cache_creation_input_tokens, usd: was.usd + (price ? u.cache_creation_input_tokens * price[1] / 1e6 : 0), priced: was.priced && price != null }
710    }
711    return r
712  })
713
714  on('turn.complete', async ($, e, next) => {
715    const r = await next(e)
716    if (e.agentId) return r
717    // An off at any point in this turn wins over every window the turn would open; a host that raised no
718    // step falls back to the count at completion.
719    const offs = s.turnOffs ?? s.offs
720    s.turnOffs = null
721    const now = await $.clock.now()
722    // A sleeping host may deliver this turn before the expired window's timer.
723    if (s.deadline && now >= s.deadline) await stop($, s, null)
724    // turn.step stamps the exact request time; when no step of this turn did, the turn's end is the floor.
725    // A turn aborted before it sent anything touched no cache, so it leaves the clock alone.
726    if ((e.usage || !e.isAborted) && now - s.lastRequestAt > e.durationMs) s.lastRequestAt = now
727    const compacted = s.compacted
728    s.compacted = false
729    if (s.lastRequestAt) s.resumedAt = 0
730    s.waitForTurn = false
731    s.ackedAt = 0
732    // Always covers any break up to six hours after a turn that reached the cache (a turn that failed before any
733    // response touched nothing, and its cache may be cold): a window of at least six hours at the default period,
734    // which brings back a stopped window and replaces a shorter one or a testing period. Another session's
735    // /keepwarm off or /keepwarm always changes the shared switch, so every such turn reads it.
736    if (e.usage) {
737      const shared = (await $.store.get(KEY_ALWAYS)) === true
738      if (s.offs === offs) s.always = shared
739      if (s.always) await startWindow($, s, Math.max(DEFAULT_WINDOW_MS, s.deadline - now), PING_AFTER_MS, offs)
740    }
741    const u = e.usage
742    if (u) {
743      if (u.model) s.lastModel = u.model
744      const prev = s.ctx
745      // A turn's usage is its responses summed, so a ten-step turn reports ten
746      // reads of the context. The live window is the engine's figure; the sum
747      // is only the fallback for a host that reports no tokens.
748      const written = u.cache_creation_input_tokens
749      const live = (await $.session.usage()).context.tokens
750      s.ctx = live && live > 0 ? live : u.input_tokens + u.cache_read_input_tokens + written
751      // A compaction since the last complete turn: what followed it is the summary, no cold write, so the turn is scored
752      // on the requests before it alone. None before it leaves nothing to score, whatever the guard saw; requests before
753      // it that reported no usage leave only the turn's total, an upper bound kept for a send the guard saw go cold.
754      const writes = s.stepWrites
755      const write = !compacted ? written : writes ? writes.tokens : s.steps && s.coldWritePending ? written : 0
756      const full = prev > 20000 && write >= 0.5 * prev
757      if (full || (s.coldWritePending && write > 0)) {
758        // Priced per request when the steps reported usage; otherwise at the tier of the context the comeback re-sent.
759        const price = priceOf(s.lastModel, prev || s.ctx)
760        const usd = writes?.priced ? writes.usd : price ? write * price[1] / 1e6 : null
761        s.misses.push({ at: now, tokens: write, usd })
762        const extend = s.deadline < now + AUTO_WARM_MS && s.offs === offs
763        if (extend) await startWindow($, s, AUTO_WARM_MS, s.every, offs)
764        $.ui.log(`cold write of ${fmtTok(write)} tokens paid (${fmtUsd(usd)}).` +
765          (extend ? ` Keeping the cache warm for ${fmtDuration(AUTO_WARM_MS)} so it is not paid again today; /keepwarm off to stop.` : ''))
766      }
767    }
768    s.coldWritePending = false
769    s.stepWrites = null
770    s.steps = 0
771    await arm($, s)
772    return r
773  })
774
775  on('session.compact', async ($, e, next) => {
776    const r = await next(e)
777    if (!e.agentId) {
778      markCompacted(s)
779      // Between turns nothing is left to score, and the next turn's summary write is not a cold write.
780      s.ctx = 0
781      disarm(s)
782      await arm($, s)
783    }
784    return r
785  })
786}
787
hooks/status-icons.ts 32 lines
1// Generated by tools/generate-status-icons.py from the official SVG assets.
2export const statusIcons = {
3  "dark": {
4    "warm": {
5      "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"64\" height=\"64\" viewBox=\"0 0 64 64\" fill=\"none\">\n  <title>Cache Tax</title>\n  <g stroke=\"#faf9f5\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n    <path fill=\"#78b85a\" d=\"M8 18 32 5 56 18 32 31Z\"/>\n    <path d=\"M8 18v28l24 13 24-13V18M32 31v28\"/>\n    <path d=\"m40 32 8 5-8 5\"/>\n  </g>\n</svg>\n",
6      "png": "iVBORw0KGgoAAAANSUhEUgAAAGAAAABACAYAAADlNHIOAAAABmJLR0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LVdgJom1rdJa20tNS3y+/bgV8JINP48e5UIiQCAGPIIWLp/vjx7t/wMf8HjK9ER0Ercn4AAAAASUVORK5CYII="
7    },
8    "cold": {
9      "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"64\" height=\"64\" viewBox=\"0 0 64 64\" fill=\"none\">\n  <title>Cache Tax</title>\n  <g stroke=\"#faf9f5\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n    <path fill=\"#d97757\" d=\"M8 18 32 5 56 18 32 31Z\"/>\n    <path d=\"M8 18v28l24 13 24-13V18M32 31v28\"/>\n    <path d=\"m40 32 8 5-8 5\"/>\n  </g>\n</svg>\n",
10      "png": "iVBORw0KGgoAAAANSUhEUgAAAGAAAABACAYAAADlNHIOAAAABmJLR0QA/wD/AP+gvaeTAAAMwklEQVR4nO1ce3RUxR3+ZjePFZKQ3Zm7G5KIJg1BsbaFBkSKoDFBqohiTSPWA/FRxHCowQePEF8VQkRIBTynkacgRwEh1pZDFUIERVDURKhCQCEISzT7Ssj7sbu//pFcXbI35ME+2Oh3zv1jZ+bO/X6/787Mzm9mLvAL/ArmbwK9gRDi94zRAiKkAABjKCJiiywWyxf+5tZTBJQAWq12kFrNFgDsEQCqDtkEsG2MsWyz2fytP/j1Bh2NuCwRHh7OJYnnqdWqEwCbrtFoVDMzZ6C09HOUln6OmZkzoNFoGEBpRM6jQuhe0+v1Bn/zDnhER0f345zPFYJXC8FJr5coI2Manfz2GLU0119wfXf6W8rKmkUGg56E4CQEr5MknqfT6SL8bUcgQsU5nyoEr2h3Jt0z+S76svQzN8d3vL7+6jBlZEyTRSAhhFmSdI8DCPK3UQEBznkK5/yI7MDx41No3949XTq+47Vv7x4aPz7FRQheJkm6NATYuOcz6HS6UULo9skOGzEiid4p3ErNTXWKDm6uryZzcSGZiwupub5auUxTHb1TuJVGjEhyFeJTIcQ4f9srw+9vg06nG6pSscUAJrX/xowZj2L6Xx9GSEiI+w1EqD/6OWy7tsFeZQYA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hlZc0ivV6SxwdL1wK0lZEkQRkZ07qs/7HHppMkCZd7dbMTEhJC/e0vr8HlDa3p7hv62aGDHd/QTgWQW9jH+/depIWd7djC6uUW5m//+AxtfbRYIwS396aPVhJg9OhR3Rpj4uKukh1vF0Ks4Zx79ORjQKHjv5RrrxlCq1cVUH2d8jeAmhpradMbG9zSN72xgZoaaxXvqa+rptWrCujaa4Z0+S/rZ4uefrCpO1cgfLDpssMvnyy7PNCjWI3rdamxpl/gAoPB0F+SeI5oD/AZDHrKzJxBp8u/cXP86fJvKDNzhutnK89LEs8xGAz9/W1HwCMqKkrinC8XgjcLwSk2NoaefSabzp45RWfPnKJnn8mm2NgY2fHNnPPlUVFRyuedLjMEVH9oMBjiHY7WhQC7D+7cCaDNanVwTmVlpX+P3/cAASWAjPaPd2cTIRUAGMNuIpYbiB/v/gV+xv8Bhtk7GIFOT8EAAAAASUVORK5CYII="
11    },
12    "neutral": {
13      "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"64\" height=\"64\" viewBox=\"0 0 64 64\" fill=\"none\">\n  <title>Cache Tax</title>\n  <g stroke=\"#faf9f5\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n    <path fill=\"#92928b\" d=\"M8 18 32 5 56 18 32 31Z\"/>\n    <path d=\"M8 18v28l24 13 24-13V18M32 31v28\"/>\n    <path d=\"m40 32 8 5-8 5\"/>\n  </g>\n</svg>\n",
14      "png": "iVBORw0KGgoAAAANSUhEUgAAAGAAAABACAYAAADlNHIOAAAABmJLR0QA/wD/AP+gvaeTAAAMsklEQVR4nO2ceXAUVR7Hv2+GhOEIJP1ez0xCFkw2BFCwCsxBKMQr4MV6Y8S1MLu6iLFYgwdHiNcKIaJk5ajaCIKilCssZMsti9qVoLBCCFESQZCIcoUhu5npmRwTkpBk5rd/kHaHpEMO5shEP1X9x/R7/fr3+3379Zv+vX4N/EJAYYE2oDcIIW5gjJYSIRUAGEMhEVuuKMqhQNvWU4JKgIiIiJ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Bmttu0IRLa0V7SJUKg6O2HCeNq0cQM1NtRpOttwoZY2bdxA1107zrNHfCJJ0rUd2+6ZAJIkXSsE/0Qtj48fTXl5b1G9s1rTlqZGJxXs2EoTJ070tKUwaILvCec8VQh+SHUkJSWZCnZs7bQ31FTbKC/vLYqNvUZ13CWE2GY2h1+jttldATjnI4SQ3hGCtwjBaeTIX9Grr2STXam6Ym+86aYbPQN/tO37EkENk2VplhD8R9WxO+64nfZ9+UWngfjvfyz06ivZFBUVqQaiQZZ5bnh4eHhXAsiyPLRtHtkpBKfISDNlZs4ni+VMp+crOVhE9937G8/AVwgh5gLoP6tM4uLiBgohLZBlrqiOzp6dRt+XH+00MKdOfk+ZmfPJaJTV8UHpWoBLdWRZUHr64122//TTc0mWhcex0oK4uLiBgY6Xz/C4Quu6e4V+VXKg/RXaqQBqD9u/b88Veti59j3sgtrDAh0fv3HpHi3eFYK39uYerSXAlCmTuzXGxMSMUgPfKoR4l3MemPVJfYH2/1LGjR1DG9bn04X6mk7/pWz5cHOH/Vs+3ExNjU7NYy7U19CG9fk0buyYLv9l/Wzp6QeburMFwweb+hy/fLKsb9CjXI3ndrW5pl/wwGQyDZFlni3aEnwmk5EyMubRmdM/dAj8mdM/UEbGPM/PVtbKMs82mUxDAu1H0GM2m2XO+Woh+EUhOEVHj6CXX8qicxWn6FzFKXr5pSyKjh6hBv4i53y12WzWXu/Uxwiq+6HJZIp1uVqWAewRdLSdAPpYrw/JrqqqOhUI+3pDUAmg0vbx7iwiTAcAxrCLiOUE48e7fyHA/A+cbDv3qiAY4gAAAABJRU5ErkJggg=="
15    }
16  },
17  "light": {
18    "warm": {
19      "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"64\" height=\"64\" viewBox=\"0 0 64 64\" fill=\"none\">\n  <title>Cache Tax</title>\n  <g stroke=\"#141413\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n    <path fill=\"#397527\" d=\"M8 18 32 5 56 18 32 31Z\"/>\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t+v6HrsZXtGpeLiCg60noMeog8iUJ41wguc9F5cOvq1WWUnp5G6elptHp1WdeDW7kQ3jVEnsA9Txc5P1RVvUxw72bBZb3ruL/z0gX3bo7ErNa3js7Du7d3Obx7+8XDuy8yIP4Ps2m8hDMsk+cAAAAASUVORK5CYII="
21    },
22    "cold": {
23      "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"64\" height=\"64\" viewBox=\"0 0 64 64\" fill=\"none\">\n  <title>Cache Tax</title>\n  <g stroke=\"#141413\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n    <path fill=\"#c15f3c\" d=\"M8 18 32 5 56 18 32 31Z\"/>\n    <path d=\"M8 18v28l24 13 24-13V18M32 31v28\"/>\n    <path d=\"m40 32 8 5-8 5\"/>\n  </g>\n</svg>\n",
24      "png": "iVBORw0KGgoAAAANSUhEUgAAAGAAAABACAYAAADlNHIOAAAABmJLR0QA/wD/AP+gvaeTAAAMn0lEQVR4nO2ce3AV1R3Hv2fvM5cEAuQhEFMBGyEBlFhbpakvgtWMrRUjMpSGaFtMp0YDVOQRq1YkgUICdcZiEU3TFAUhHSpm2hKojxEcH6EtWsLLWIgJJCGPe+/u3XM29/76B1kIuZsn90Ein5n9Z/e3u7/z++45u+d3zh7gClfoL0LIN2pcLhdccQquODUulwsh3xhuv4Y8Ho8nUajyy4LLXsFl6rL5NC5vV1X12nD7OeQgco7mXCkUXFYFl8nZdpaKi9dTSvJkSkmeTMXF68nZdlYXQghVfpnc7vhw+z3oISKHxt1PCS63Ci6T6nFR+c5tNH36dIqJGX3RNnXqFHp1y2byKE5dCDfnSiHR2eHhLsegg4gkIdxZnMt1ehNTWfl3uvXWNL/Ad91uueU7VL5z24WmSZUbhao8QUTmcJfLCBZuB7qiqe50YqwIwFQAqKo6iBdWF+DAgQ/7dZ1bbrkZK1csR2rq9I497AgBT1utETsYYxRgtwfMZSOAEMrN8PnWgLFbAaCmpgarC9aioqICRP7xskgMGdeMBABUfNkC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+6el30r59ezoH/qQQ8kIiCuwM4XBCRDahKosEl5v0gr69exfddNO3ug3MDTdcT69u2Uyqx6UHpqk3AXQbrrqpfOe2Xq//57JS4qr7wrmqsoiIQvuzQii58IQqzr4+oTNn3tH1Ce1JANr/wbt0zz1391DDvtm1hsl6DQt3fEJGRxv9iuBy+0DaaCMBPjv0rz69Y842ndED3y5U+RVFUQL652N/uOyWq2lsakJRUTG2bn0Dmqb52UuShMzM2di+fcdF++fMycSOHeXw+fyTmhaLBfPmzcXixYsQGxMD4MpyNX70d25oX7iyYNMA+LotWXZZ0t9cTSBzTVfoBBEN07icryf4PIqTyv5UQtOmTfUL/LRpU6nsTyWdl61s07icT0R9+63mCt1D5IoVwr1RcJmLjoVbN2woopSUZEpJSaYNG4o6L9zKhXBvJHLFhtvvIYeqqhMEd28VXPZ1/u7v2HyCu7eGY1Tra0fH4t07Oy3evfPK4t1XGBD/B0HDzNOE5wCHAAAAAElFTkSuQmCC"
25    },
26    "neutral": {
27      "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"64\" height=\"64\" viewBox=\"0 0 64 64\" fill=\"none\">\n  <title>Cache Tax</title>\n  <g stroke=\"#141413\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n    <path fill=\"#686861\" d=\"M8 18 32 5 56 18 32 31Z\"/>\n    <path d=\"M8 18v28l24 13 24-13V18M32 31v28\"/>\n    <path d=\"m40 32 8 5-8 5\"/>\n  </g>\n</svg>\n",
28      "png": "iVBORw0KGgoAAAANSUhEUgAAAGAAAABACAYAAADlNHIOAAAABmJLR0QA/wD/AP+gvaeTAAAMhklEQVR4nO2ce3AURR7Hvz2bfbAJEB5JDMRoEBLYPIB43inmfEDwlLLuToxocVaIL8jVGQ1wIo944IkkICQgVR6KPA45PBC4QpG6MwEfV6IFXhCJAQIYhZgAIQF2d2ZnerL7uz/IQMhOnuwjCXyq5p/pnp5f/77TPT2/7mngBjfoKJyLt6uKuJ0rkp0rkl1VxO2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