context-doctor 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/ab.js +3 -2
- package/dist/autopilot.js +9 -5
- package/dist/blob.js +66 -12
- package/dist/budget.d.ts +8 -2
- package/dist/budget.js +30 -7
- package/dist/ci.js +2 -1
- package/dist/claudeplugin.d.ts +97 -0
- package/dist/claudeplugin.js +142 -0
- package/dist/cli.js +109 -36
- package/dist/compactcost.d.ts +74 -0
- package/dist/compactcost.js +115 -0
- package/dist/cursor.js +2 -0
- package/dist/doctor.js +90 -18
- package/dist/extract.js +4 -3
- package/dist/fanout.d.ts +15 -0
- package/dist/fanout.js +30 -9
- package/dist/firstfix.d.ts +43 -0
- package/dist/firstfix.js +80 -0
- package/dist/fix.d.ts +46 -2
- package/dist/fix.js +95 -10
- package/dist/httpguard.d.ts +13 -0
- package/dist/httpguard.js +22 -0
- package/dist/install.d.ts +21 -9
- package/dist/install.js +211 -40
- package/dist/limits.d.ts +5 -0
- package/dist/limits.js +26 -2
- package/dist/mcp.js +60 -59
- package/dist/missledger.js +5 -3
- package/dist/mod/api.d.ts +8 -2
- package/dist/mod/api.js +2 -2
- package/dist/mod/logic.d.ts +13 -1
- package/dist/mod/logic.js +24 -2
- package/dist/mod/register.d.ts +2 -0
- package/dist/mod/register.js +19 -5
- package/dist/modelids.d.ts +4 -3
- package/dist/modelids.js +23 -7
- package/dist/modelswitch.js +8 -4
- package/dist/modmeasure.js +13 -1
- package/dist/orgrates.d.ts +18 -0
- package/dist/orgrates.js +51 -2
- package/dist/pack.d.ts +13 -0
- package/dist/pack.js +38 -2
- package/dist/preferences.js +2 -1
- package/dist/pricing.d.ts +8 -0
- package/dist/pricing.js +16 -0
- package/dist/progresssummaries.d.ts +148 -0
- package/dist/progresssummaries.js +248 -0
- package/dist/proxy.d.ts +1 -1
- package/dist/proxy.js +1 -1
- package/dist/prune.d.ts +8 -0
- package/dist/prune.js +11 -1
- package/dist/spend.d.ts +34 -0
- package/dist/spend.js +48 -4
- package/dist/subagentmodel.d.ts +12 -0
- package/dist/subagentmodel.js +17 -4
- package/dist/subagentpay.d.ts +8 -0
- package/dist/subagentpay.js +8 -1
- package/dist/toolcwd.d.ts +14 -0
- package/dist/toolcwd.js +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code's subagent progress summaries, estimated: side requests no
|
|
3
|
+
* transcript records. The `progress-summaries` lever of `fix`.
|
|
4
|
+
*
|
|
5
|
+
* While a background subagent runs, Claude Code asks a model every 30
|
|
6
|
+
* seconds for a 3-5 word line about what it is doing (the text on its task
|
|
7
|
+
* row). The request is made with `skipTranscript`, so no transcript row
|
|
8
|
+
* carries it, and Claude Code bills it and counts it in its own cost
|
|
9
|
+
* (anthropics/claude-code#86879 measured 22.7% of one subagent-heavy
|
|
10
|
+
* session's requests). `CLAUDE_CODE_DISABLE_AGENT_PROGRESS_SUMMARIES=1`
|
|
11
|
+
* (2.1.318+, documented in 2.1.323) turns them off, and the requests with
|
|
12
|
+
* them. The summary never enters the agent's context: the work is the same.
|
|
13
|
+
*
|
|
14
|
+
* Read from the 2.1.321 binary (the Desktop app's bundled Claude Code, with
|
|
15
|
+
* `strings`; docs/spend.md has the details):
|
|
16
|
+
* - Who gets them. Only a subagent run in the background (the async
|
|
17
|
+
* runner), and there only when the host asked for them (the SDK's
|
|
18
|
+
* `agentProgressSummaries` option) or the session is interactive (a
|
|
19
|
+
* terminal, `entrypoint: "cli"`) and the fork gate is open (on unless
|
|
20
|
+
* CLAUDE_CODE_FORK_SUBAGENT=0) or coordinator mode is on. A fork launched
|
|
21
|
+
* in the background gets them in every mode. A foreground subagent gets
|
|
22
|
+
* them only when the host asked. Workflow agents never do. The Desktop
|
|
23
|
+
* app's Code tab runs Claude Code through the SDK, so its sessions are
|
|
24
|
+
* not interactive, and its bundle (5.11492) never sets the option: none.
|
|
25
|
+
* - How often. A timer every 30 s from the agent's start; a tick is skipped
|
|
26
|
+
* while the agent's transcript has fewer than 3 messages or has not
|
|
27
|
+
* changed since the last summary; it stops when the agent ends.
|
|
28
|
+
* - What each sends. Either the agent's whole conversation as a one-turn
|
|
29
|
+
* fork on the agent's own model (no cache write, so its prefix is read
|
|
30
|
+
* from the agent's cache), or ("short") at most ~1,500 tokens of notes
|
|
31
|
+
* about its recent steps, with prompt caching off and low effort, on the
|
|
32
|
+
* agent's own model (or Haiku). Which one is served per model from
|
|
33
|
+
* Anthropic's side and is not in any file here; Anthropic said on
|
|
34
|
+
* 2026-11-09 (#86879) that the summaries now "consume 99% less", which is
|
|
35
|
+
* the notes. So both are priced: the notes as the low figure, the whole
|
|
36
|
+
* context as the high one.
|
|
37
|
+
*
|
|
38
|
+
* Estimated per subagent from what its transcript does record: the time of
|
|
39
|
+
* each message (the ticks and whether the transcript changed), each reply's
|
|
40
|
+
* prompt size and model (the context a fork would read, the rates). Each
|
|
41
|
+
* summary's output is #86879's measured mean (65 tokens). Not counted: a
|
|
42
|
+
* tick held while the agent's own request waits on a cold cache (it fires
|
|
43
|
+
* later, not more often), and the thinking a summary may do.
|
|
44
|
+
*/
|
|
45
|
+
import { type Extractor } from "./scan.js";
|
|
46
|
+
/** The variable the lever writes, and the value: Claude Code passes only "1" on to the sessions it starts in the background. */
|
|
47
|
+
export declare const PROGRESS_SUMMARIES_ENV = "CLAUDE_CODE_DISABLE_AGENT_PROGRESS_SUMMARIES";
|
|
48
|
+
export declare const PROGRESS_SUMMARIES_OFF = "1";
|
|
49
|
+
/** The first Claude Code that reads it (its CHANGELOG, 2.1.323: "available since 2.1.318"). */
|
|
50
|
+
export declare const PROGRESS_SUMMARIES_SINCE = "2.1.318";
|
|
51
|
+
/** The summary timer (the binary's default; #86879 and #105981 measured 30-32 s). */
|
|
52
|
+
export declare const SUMMARY_TICK_MS = 30000;
|
|
53
|
+
/** A short summary's prompt: notes capped at 2,000 - 500 tokens, plus its system prompt and instruction. */
|
|
54
|
+
export declare const NOTES_TOKENS = 1850;
|
|
55
|
+
/** A fork summary's own instruction, after the agent's context. */
|
|
56
|
+
export declare const FORK_PROMPT_TOKENS = 150;
|
|
57
|
+
/** Each summary's output: #86879's measured mean (21,966 tokens over 339 summaries). */
|
|
58
|
+
export declare const SUMMARY_OUTPUT_TOKENS = 65;
|
|
59
|
+
/** How Claude Code reads the variable (a boolean: "1", "true", "yes", "on"). */
|
|
60
|
+
export declare const disablesSummaries: (v: unknown) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* One subagent transcript's timeline: the first row's host and version, the
|
|
63
|
+
* time of each message, and each reply's prompt size and model (once per
|
|
64
|
+
* reply; its output is in the next prompt).
|
|
65
|
+
*/
|
|
66
|
+
export declare const PROGRESS_ROWS: Extractor<{
|
|
67
|
+
head: boolean;
|
|
68
|
+
ids: Record<string, 1>;
|
|
69
|
+
}>;
|
|
70
|
+
/** What a subagent's `.meta.json` says about how it ran (2.1.266+ write requestShape). */
|
|
71
|
+
export interface AgentMeta {
|
|
72
|
+
agentType?: string;
|
|
73
|
+
requestShape?: string;
|
|
74
|
+
isFork?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export declare function readAgentMeta(file: string): AgentMeta | undefined;
|
|
77
|
+
/** Why a subagent gets no summaries, or "yes". */
|
|
78
|
+
export type Eligibility = "yes" | "foreground" | "host" | "workflow" | "unknown" | "fork-gate-off" | "off" | "old";
|
|
79
|
+
/**
|
|
80
|
+
* Whether Claude Code (2.1.321's rules) wrote progress summaries for this
|
|
81
|
+
* agent. `interactive`: whether its host counts as interactive (default: a
|
|
82
|
+
* terminal session, entrypoint "cli").
|
|
83
|
+
*/
|
|
84
|
+
export declare function eligibility(meta: AgentMeta | undefined, entrypoint: string | undefined, opts?: {
|
|
85
|
+
workflow?: boolean;
|
|
86
|
+
forkGateOff?: boolean;
|
|
87
|
+
interactive?: (entrypoint: string | undefined) => boolean;
|
|
88
|
+
}): Eligibility;
|
|
89
|
+
/** One subagent's summaries: how many, and their price both ways. */
|
|
90
|
+
export interface AgentSummaries {
|
|
91
|
+
calls: number;
|
|
92
|
+
notesUsd: number;
|
|
93
|
+
forkUsd: number;
|
|
94
|
+
}
|
|
95
|
+
type Rec = {
|
|
96
|
+
t: "h";
|
|
97
|
+
entrypoint?: string;
|
|
98
|
+
version?: string;
|
|
99
|
+
} | {
|
|
100
|
+
t: "m";
|
|
101
|
+
ts: number;
|
|
102
|
+
} | {
|
|
103
|
+
t: "r";
|
|
104
|
+
ts: number;
|
|
105
|
+
model?: string;
|
|
106
|
+
p: number;
|
|
107
|
+
speed?: string;
|
|
108
|
+
geo?: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* The ticks a running agent's timer made and the summaries they sent, from
|
|
112
|
+
* its timeline: every 30 s from its first row to its last, a summary when
|
|
113
|
+
* it has 3+ messages and more than at the last summary. Only ticks in
|
|
114
|
+
* [since, until] are counted.
|
|
115
|
+
*/
|
|
116
|
+
export declare function simulateAgent(recs: Rec[], since?: number, until?: number): AgentSummaries;
|
|
117
|
+
export interface ProgressSummaryEstimate {
|
|
118
|
+
/** Subagent transcripts read (workflow agents included). */
|
|
119
|
+
agents: number;
|
|
120
|
+
/** Agents Claude Code wrote summaries for in the window, by the rules above. */
|
|
121
|
+
summarized: number;
|
|
122
|
+
calls: number;
|
|
123
|
+
/** The summaries as short notes (what Anthropic serves since November 2026): the low figure. */
|
|
124
|
+
notesUsd: number;
|
|
125
|
+
/** As a fork of the whole context (before): the high figure. */
|
|
126
|
+
forkUsd: number;
|
|
127
|
+
/** Agents with none, by why. */
|
|
128
|
+
none: Partial<Record<Exclude<Eligibility, "yes">, number>>;
|
|
129
|
+
/** The hosts of the background agents that got none because their host is not interactive. */
|
|
130
|
+
hosts: string[];
|
|
131
|
+
}
|
|
132
|
+
export interface ProgressOptions {
|
|
133
|
+
since?: number;
|
|
134
|
+
until?: number;
|
|
135
|
+
/** CLAUDE_CODE_FORK_SUBAGENT is off: interactive sessions' ordinary background agents got none. */
|
|
136
|
+
forkGateOff?: boolean;
|
|
137
|
+
/** From this time, on Claude Code 2.1.318+, the variable was set (fix's record): none after it. */
|
|
138
|
+
offSince?: number;
|
|
139
|
+
/** Which hosts count as interactive (default: entrypoint "cli"); a measurement can ask "what if all were". */
|
|
140
|
+
interactive?: (entrypoint: string | undefined) => boolean;
|
|
141
|
+
/** Only agents on this Claude Code or newer (what the variable would have stopped: 2.1.318+). */
|
|
142
|
+
minVersion?: string;
|
|
143
|
+
}
|
|
144
|
+
/** The summaries of the subagents in `files` (their `.jsonl` transcripts), estimated. */
|
|
145
|
+
export declare function estimateProgressSummaries(files: string[], opts?: ProgressOptions): ProgressSummaryEstimate;
|
|
146
|
+
/** "the Desktop app", "the SDK or -p": a host as a person knows it. */
|
|
147
|
+
export declare function hostName(entrypoint: string): string;
|
|
148
|
+
export {};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code's subagent progress summaries, estimated: side requests no
|
|
3
|
+
* transcript records. The `progress-summaries` lever of `fix`.
|
|
4
|
+
*
|
|
5
|
+
* While a background subagent runs, Claude Code asks a model every 30
|
|
6
|
+
* seconds for a 3-5 word line about what it is doing (the text on its task
|
|
7
|
+
* row). The request is made with `skipTranscript`, so no transcript row
|
|
8
|
+
* carries it, and Claude Code bills it and counts it in its own cost
|
|
9
|
+
* (anthropics/claude-code#86879 measured 22.7% of one subagent-heavy
|
|
10
|
+
* session's requests). `CLAUDE_CODE_DISABLE_AGENT_PROGRESS_SUMMARIES=1`
|
|
11
|
+
* (2.1.318+, documented in 2.1.323) turns them off, and the requests with
|
|
12
|
+
* them. The summary never enters the agent's context: the work is the same.
|
|
13
|
+
*
|
|
14
|
+
* Read from the 2.1.321 binary (the Desktop app's bundled Claude Code, with
|
|
15
|
+
* `strings`; docs/spend.md has the details):
|
|
16
|
+
* - Who gets them. Only a subagent run in the background (the async
|
|
17
|
+
* runner), and there only when the host asked for them (the SDK's
|
|
18
|
+
* `agentProgressSummaries` option) or the session is interactive (a
|
|
19
|
+
* terminal, `entrypoint: "cli"`) and the fork gate is open (on unless
|
|
20
|
+
* CLAUDE_CODE_FORK_SUBAGENT=0) or coordinator mode is on. A fork launched
|
|
21
|
+
* in the background gets them in every mode. A foreground subagent gets
|
|
22
|
+
* them only when the host asked. Workflow agents never do. The Desktop
|
|
23
|
+
* app's Code tab runs Claude Code through the SDK, so its sessions are
|
|
24
|
+
* not interactive, and its bundle (5.11492) never sets the option: none.
|
|
25
|
+
* - How often. A timer every 30 s from the agent's start; a tick is skipped
|
|
26
|
+
* while the agent's transcript has fewer than 3 messages or has not
|
|
27
|
+
* changed since the last summary; it stops when the agent ends.
|
|
28
|
+
* - What each sends. Either the agent's whole conversation as a one-turn
|
|
29
|
+
* fork on the agent's own model (no cache write, so its prefix is read
|
|
30
|
+
* from the agent's cache), or ("short") at most ~1,500 tokens of notes
|
|
31
|
+
* about its recent steps, with prompt caching off and low effort, on the
|
|
32
|
+
* agent's own model (or Haiku). Which one is served per model from
|
|
33
|
+
* Anthropic's side and is not in any file here; Anthropic said on
|
|
34
|
+
* 2026-11-09 (#86879) that the summaries now "consume 99% less", which is
|
|
35
|
+
* the notes. So both are priced: the notes as the low figure, the whole
|
|
36
|
+
* context as the high one.
|
|
37
|
+
*
|
|
38
|
+
* Estimated per subagent from what its transcript does record: the time of
|
|
39
|
+
* each message (the ticks and whether the transcript changed), each reply's
|
|
40
|
+
* prompt size and model (the context a fork would read, the rates). Each
|
|
41
|
+
* summary's output is #86879's measured mean (65 tokens). Not counted: a
|
|
42
|
+
* tick held while the agent's own request waits on a cold cache (it fires
|
|
43
|
+
* later, not more often), and the thinking a summary may do.
|
|
44
|
+
*/
|
|
45
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
46
|
+
import { pick, rowsOf } from "./scan.js";
|
|
47
|
+
import { requestCost } from "./pricing.js";
|
|
48
|
+
import { realModel } from "./tokens.js";
|
|
49
|
+
import { workflowRunOf } from "./subagents.js";
|
|
50
|
+
import { compareVersions } from "./modelswitch.js";
|
|
51
|
+
/** The variable the lever writes, and the value: Claude Code passes only "1" on to the sessions it starts in the background. */
|
|
52
|
+
export const PROGRESS_SUMMARIES_ENV = "CLAUDE_CODE_DISABLE_AGENT_PROGRESS_SUMMARIES";
|
|
53
|
+
export const PROGRESS_SUMMARIES_OFF = "1";
|
|
54
|
+
/** The first Claude Code that reads it (its CHANGELOG, 2.1.323: "available since 2.1.318"). */
|
|
55
|
+
export const PROGRESS_SUMMARIES_SINCE = "2.1.318";
|
|
56
|
+
/** The summary timer (the binary's default; #86879 and #105981 measured 30-32 s). */
|
|
57
|
+
export const SUMMARY_TICK_MS = 30_000;
|
|
58
|
+
/** A short summary's prompt: notes capped at 2,000 - 500 tokens, plus its system prompt and instruction. */
|
|
59
|
+
export const NOTES_TOKENS = 1_850;
|
|
60
|
+
/** A fork summary's own instruction, after the agent's context. */
|
|
61
|
+
export const FORK_PROMPT_TOKENS = 150;
|
|
62
|
+
/** Each summary's output: #86879's measured mean (21,966 tokens over 339 summaries). */
|
|
63
|
+
export const SUMMARY_OUTPUT_TOKENS = 65;
|
|
64
|
+
/** How Claude Code reads the variable (a boolean: "1", "true", "yes", "on"). */
|
|
65
|
+
export const disablesSummaries = (v) => ["1", "true", "yes", "on"].includes(String(v ?? "").trim().toLowerCase());
|
|
66
|
+
/**
|
|
67
|
+
* One subagent transcript's timeline: the first row's host and version, the
|
|
68
|
+
* time of each message, and each reply's prompt size and model (once per
|
|
69
|
+
* reply; its output is in the next prompt).
|
|
70
|
+
*/
|
|
71
|
+
export const PROGRESS_ROWS = {
|
|
72
|
+
id: "progress-summaries.1",
|
|
73
|
+
init: () => ({ head: false, ids: {} }),
|
|
74
|
+
line(raw, row, out, st) {
|
|
75
|
+
if (!raw.includes('"timestamp"'))
|
|
76
|
+
return;
|
|
77
|
+
let e;
|
|
78
|
+
try {
|
|
79
|
+
e = row();
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (!e || typeof e !== "object")
|
|
85
|
+
return;
|
|
86
|
+
if (!st.head && (typeof e.entrypoint === "string" || typeof e.version === "string")) {
|
|
87
|
+
st.head = true;
|
|
88
|
+
out.push({ t: "h", ...pick(e, ["entrypoint", "version"]) });
|
|
89
|
+
}
|
|
90
|
+
if (e.type !== "user" && e.type !== "assistant" && e.type !== "attachment")
|
|
91
|
+
return;
|
|
92
|
+
const ts = Date.parse(String(e.timestamp ?? ""));
|
|
93
|
+
if (!Number.isFinite(ts))
|
|
94
|
+
return;
|
|
95
|
+
out.push({ t: "m", ts });
|
|
96
|
+
const m = e.message;
|
|
97
|
+
if (e.type !== "assistant" || !m?.usage)
|
|
98
|
+
return;
|
|
99
|
+
const id = typeof m.id === "string" ? m.id : undefined;
|
|
100
|
+
if (id) {
|
|
101
|
+
if (st.ids[id])
|
|
102
|
+
return;
|
|
103
|
+
st.ids[id] = 1;
|
|
104
|
+
}
|
|
105
|
+
const u = m.usage;
|
|
106
|
+
const n = (v) => (typeof v === "number" && Number.isFinite(v) && v > 0 ? v : 0);
|
|
107
|
+
const prompt = n(u.input_tokens) + n(u.cache_read_input_tokens) + n(u.cache_creation_input_tokens);
|
|
108
|
+
out.push({ t: "r", ts, model: realModel(m.model), p: prompt, ...(u.speed === "fast" ? { speed: "fast" } : {}), ...(u.inference_geo === "us" ? { geo: "us" } : {}) });
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
export function readAgentMeta(file) {
|
|
112
|
+
const p = file.replace(/\.jsonl$/, ".meta.json");
|
|
113
|
+
if (!existsSync(p))
|
|
114
|
+
return undefined;
|
|
115
|
+
try {
|
|
116
|
+
const j = JSON.parse(readFileSync(p, "utf8"));
|
|
117
|
+
if (!j || typeof j !== "object")
|
|
118
|
+
return undefined;
|
|
119
|
+
return { ...(typeof j.agentType === "string" ? { agentType: j.agentType } : {}), ...(typeof j.requestShape === "string" ? { requestShape: j.requestShape } : {}), ...(j.isFork === true ? { isFork: true } : {}) };
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Whether Claude Code (2.1.321's rules) wrote progress summaries for this
|
|
127
|
+
* agent. `interactive`: whether its host counts as interactive (default: a
|
|
128
|
+
* terminal session, entrypoint "cli").
|
|
129
|
+
*/
|
|
130
|
+
export function eligibility(meta, entrypoint, opts = {}) {
|
|
131
|
+
if (opts.workflow || meta?.agentType === "workflow-subagent")
|
|
132
|
+
return "workflow";
|
|
133
|
+
if (!meta?.requestShape)
|
|
134
|
+
return "unknown";
|
|
135
|
+
if (meta.requestShape !== "background")
|
|
136
|
+
return "foreground";
|
|
137
|
+
if (meta.isFork)
|
|
138
|
+
return "yes";
|
|
139
|
+
const interactive = opts.interactive ?? ((ep) => ep === "cli");
|
|
140
|
+
if (!interactive(entrypoint))
|
|
141
|
+
return "host";
|
|
142
|
+
return opts.forkGateOff ? "fork-gate-off" : "yes";
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The ticks a running agent's timer made and the summaries they sent, from
|
|
146
|
+
* its timeline: every 30 s from its first row to its last, a summary when
|
|
147
|
+
* it has 3+ messages and more than at the last summary. Only ticks in
|
|
148
|
+
* [since, until] are counted.
|
|
149
|
+
*/
|
|
150
|
+
export function simulateAgent(recs, since = -Infinity, until = Infinity) {
|
|
151
|
+
const msgs = recs.filter((r) => r.t === "m").map((r) => r.ts).sort((a, b) => a - b);
|
|
152
|
+
const replies = recs.filter((r) => r.t === "r").sort((a, b) => a.ts - b.ts);
|
|
153
|
+
const out = { calls: 0, notesUsd: 0, forkUsd: 0 };
|
|
154
|
+
if (msgs.length < 3 || replies.length === 0)
|
|
155
|
+
return out;
|
|
156
|
+
const start = msgs[0];
|
|
157
|
+
const end = msgs[msgs.length - 1];
|
|
158
|
+
let n = 0, last = 0, ri = -1;
|
|
159
|
+
for (let at = start + SUMMARY_TICK_MS; at <= end; at += SUMMARY_TICK_MS) {
|
|
160
|
+
while (n < msgs.length && msgs[n] <= at)
|
|
161
|
+
n++;
|
|
162
|
+
while (ri + 1 < replies.length && replies[ri + 1].ts <= at)
|
|
163
|
+
ri++;
|
|
164
|
+
if (n < 3 || n === last)
|
|
165
|
+
continue;
|
|
166
|
+
last = n;
|
|
167
|
+
if (at < since || at > until)
|
|
168
|
+
continue;
|
|
169
|
+
// The last reply's prompt is cached (the fork reads it); what came after it (its output, the
|
|
170
|
+
// tool results) is new, as far as the next reply's prompt says; before any reply, the first prompt.
|
|
171
|
+
const cur = ri >= 0 ? replies[ri] : undefined;
|
|
172
|
+
const next = replies[ri + 1];
|
|
173
|
+
const ref = cur ?? next;
|
|
174
|
+
const model = ref.model;
|
|
175
|
+
if (!model)
|
|
176
|
+
continue;
|
|
177
|
+
const read = cur ? cur.p : 0;
|
|
178
|
+
const fresh = (next ? Math.max(0, next.p - read) : 0) + FORK_PROMPT_TOKENS;
|
|
179
|
+
const b = { ...(ref.speed ? { speed: ref.speed } : {}), ...(ref.geo ? { inference_geo: ref.geo } : {}) };
|
|
180
|
+
const fork = requestCost(model, { input_tokens: fresh, cache_read_input_tokens: read, cache_creation_input_tokens: 0, output_tokens: SUMMARY_OUTPUT_TOKENS, ...b }, at);
|
|
181
|
+
const notes = requestCost(model, { input_tokens: NOTES_TOKENS, cache_read_input_tokens: 0, cache_creation_input_tokens: 0, output_tokens: SUMMARY_OUTPUT_TOKENS, ...b }, at);
|
|
182
|
+
if (!fork || !notes)
|
|
183
|
+
continue;
|
|
184
|
+
out.calls++;
|
|
185
|
+
out.forkUsd += fork.totalUsd;
|
|
186
|
+
out.notesUsd += notes.totalUsd;
|
|
187
|
+
}
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
190
|
+
/** The summaries of the subagents in `files` (their `.jsonl` transcripts), estimated. */
|
|
191
|
+
export function estimateProgressSummaries(files, opts = {}) {
|
|
192
|
+
const r = { agents: 0, summarized: 0, calls: 0, notesUsd: 0, forkUsd: 0, none: {}, hosts: [] };
|
|
193
|
+
const hosts = new Set();
|
|
194
|
+
for (const file of files) {
|
|
195
|
+
let recs;
|
|
196
|
+
try {
|
|
197
|
+
recs = rowsOf(file, PROGRESS_ROWS);
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
// An agent that ran outside the window is not one of its agents (its file may be newer: a resumed session).
|
|
203
|
+
if (!recs.some((x) => x.t === "m" && x.ts >= (opts.since ?? -Infinity) && x.ts <= (opts.until ?? Infinity)))
|
|
204
|
+
continue;
|
|
205
|
+
r.agents++;
|
|
206
|
+
const head = recs.find((x) => x.t === "h");
|
|
207
|
+
let why = eligibility(readAgentMeta(file), head?.entrypoint, { workflow: workflowRunOf(file) !== undefined, forkGateOff: opts.forkGateOff, interactive: opts.interactive });
|
|
208
|
+
if (why === "yes" && opts.minVersion && !(head?.version && compareVersions(head.version, opts.minVersion) >= 0))
|
|
209
|
+
why = "old";
|
|
210
|
+
let until = opts.until ?? Infinity;
|
|
211
|
+
// The variable set from offSince on: a Claude Code that reads it wrote none after.
|
|
212
|
+
if (why === "yes" && opts.offSince !== undefined && head?.version && compareVersions(head.version, PROGRESS_SUMMARIES_SINCE) >= 0)
|
|
213
|
+
until = Math.min(until, opts.offSince);
|
|
214
|
+
if (why === "yes") {
|
|
215
|
+
const first = recs.reduce((m, x) => (x.t === "m" && x.ts < m ? x.ts : m), Infinity);
|
|
216
|
+
// An agent that started after the variable was set got none.
|
|
217
|
+
if (first > until)
|
|
218
|
+
why = "off";
|
|
219
|
+
else {
|
|
220
|
+
const s = simulateAgent(recs, opts.since, until);
|
|
221
|
+
// One that ran under 30 s, or outside the window, sent none.
|
|
222
|
+
if (s.calls)
|
|
223
|
+
r.summarized++;
|
|
224
|
+
r.calls += s.calls;
|
|
225
|
+
r.notesUsd += s.notesUsd;
|
|
226
|
+
r.forkUsd += s.forkUsd;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (why === "host" && head?.entrypoint)
|
|
231
|
+
hosts.add(head.entrypoint);
|
|
232
|
+
r.none[why] = (r.none[why] ?? 0) + 1;
|
|
233
|
+
}
|
|
234
|
+
r.hosts = [...hosts].sort();
|
|
235
|
+
return r;
|
|
236
|
+
}
|
|
237
|
+
/** "the Desktop app", "the SDK or -p": a host as a person knows it. */
|
|
238
|
+
export function hostName(entrypoint) {
|
|
239
|
+
if (entrypoint === "claude-desktop")
|
|
240
|
+
return "the Desktop app";
|
|
241
|
+
if (entrypoint === "claude-vscode")
|
|
242
|
+
return "the VS Code extension";
|
|
243
|
+
if (entrypoint === "sdk-cli")
|
|
244
|
+
return "claude -p";
|
|
245
|
+
if (entrypoint.startsWith("sdk"))
|
|
246
|
+
return "the Agent SDK";
|
|
247
|
+
return entrypoint;
|
|
248
|
+
}
|
package/dist/proxy.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export interface ProxyOptions extends OptimizeOptions {
|
|
|
76
76
|
/** Default request body cap: far above any real request (a 1M-token context is ~4 MB of JSON, images aside). */
|
|
77
77
|
export declare const DEFAULT_MAX_BODY_BYTES: number;
|
|
78
78
|
/** Reported by /health so `autopilot status` can tell an outdated service from a current one. */
|
|
79
|
-
export declare const PROXY_VERSION = "0.
|
|
79
|
+
export declare const PROXY_VERSION = "0.47.0";
|
|
80
80
|
/**
|
|
81
81
|
* Remove a leading `/t/<token>` from a request path, or return undefined when
|
|
82
82
|
* the prefix is absent or the token differs. The comparison is constant time
|
package/dist/proxy.js
CHANGED
|
@@ -25,7 +25,7 @@ import { makeGuard, refusal } from "./httpguard.js";
|
|
|
25
25
|
/** Default request body cap: far above any real request (a 1M-token context is ~4 MB of JSON, images aside). */
|
|
26
26
|
export const DEFAULT_MAX_BODY_BYTES = 100 * 1024 * 1024;
|
|
27
27
|
/** Reported by /health so `autopilot status` can tell an outdated service from a current one. */
|
|
28
|
-
export const PROXY_VERSION = "0.
|
|
28
|
+
export const PROXY_VERSION = "0.47.0";
|
|
29
29
|
/** Connection-level headers that must not be forwarded. */
|
|
30
30
|
const SKIP_REQUEST_HEADERS = new Set(["host", "content-length", "connection", "transfer-encoding", "accept-encoding", "expect"]);
|
|
31
31
|
const SKIP_RESPONSE_HEADERS = new Set(["content-length", "content-encoding", "transfer-encoding", "connection"]);
|
package/dist/prune.d.ts
CHANGED
|
@@ -85,6 +85,14 @@ export interface PrunePlan {
|
|
|
85
85
|
}
|
|
86
86
|
/** The project's own settings file, where prune writes. */
|
|
87
87
|
export declare function localSettingsPath(cwd: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* CLAUDE_CODE_IGNORE_PERSISTED_TRUST, read as Claude Code reads it (2.1.321:
|
|
90
|
+
* a boolean variable, true for 1, true, yes or on). Set, "no workspace trust
|
|
91
|
+
* record counts in this process" (a self-hosted runner sets it when started
|
|
92
|
+
* with --trust-workspace false): ~/.claude.json's hasTrustDialogAccepted is
|
|
93
|
+
* not read, so a project's own settings approve nothing.
|
|
94
|
+
*/
|
|
95
|
+
export declare function persistedTrustIgnored(env?: NodeJS.ProcessEnv): boolean;
|
|
88
96
|
/**
|
|
89
97
|
* Whether Claude Code would start this project `.mcp.json` server without
|
|
90
98
|
* asking: the user approved it (enabledMcpjsonServers, or
|
package/dist/prune.js
CHANGED
|
@@ -304,7 +304,7 @@ function mcpjsonApprovedBy(name, cwd, home, read, off) {
|
|
|
304
304
|
const projects = read(claudeJsonPath(home)).projects;
|
|
305
305
|
const keys = trustKeys(cwd);
|
|
306
306
|
const entry = (k) => (projects && typeof projects === "object" && projects[k] && typeof projects[k] === "object" ? projects[k] : undefined);
|
|
307
|
-
const trusted = keys.some((k) => entry(k)?.hasTrustDialogAccepted === true);
|
|
307
|
+
const trusted = !persistedTrustIgnored() && keys.some((k) => entry(k)?.hasTrustDialogAccepted === true);
|
|
308
308
|
const legacy = keys.map(entry).find((e) => e && (e.enabledMcpjsonServers !== undefined || e.enableAllProjectMcpServers !== undefined)) ?? {};
|
|
309
309
|
const sources = trusted ? [user, read(join(cwd, ".claude", "settings.json")), legacy, read(localSettingsPath(cwd))] : [user];
|
|
310
310
|
let all = false;
|
|
@@ -313,6 +313,16 @@ function mcpjsonApprovedBy(name, cwd, home, read, off) {
|
|
|
313
313
|
all = trusted ? s.enableAllProjectMcpServers : all || s.enableAllProjectMcpServers;
|
|
314
314
|
return all || sources.some((s) => list(s.enabledMcpjsonServers).some(same));
|
|
315
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* CLAUDE_CODE_IGNORE_PERSISTED_TRUST, read as Claude Code reads it (2.1.321:
|
|
318
|
+
* a boolean variable, true for 1, true, yes or on). Set, "no workspace trust
|
|
319
|
+
* record counts in this process" (a self-hosted runner sets it when started
|
|
320
|
+
* with --trust-workspace false): ~/.claude.json's hasTrustDialogAccepted is
|
|
321
|
+
* not read, so a project's own settings approve nothing.
|
|
322
|
+
*/
|
|
323
|
+
export function persistedTrustIgnored(env = process.env) {
|
|
324
|
+
return ["1", "true", "yes", "on"].includes(String(env.CLAUDE_CODE_IGNORE_PERSISTED_TRUST ?? "").trim().toLowerCase());
|
|
325
|
+
}
|
|
316
326
|
/**
|
|
317
327
|
* The keys ~/.claude.json may hold this workspace's trust under: the folder
|
|
318
328
|
* and the repository root it is in (Claude Code keys a project by its git
|
package/dist/spend.d.ts
CHANGED
|
@@ -29,11 +29,17 @@
|
|
|
29
29
|
* (scan.ts), so a second run reads only what was appended since; Cursor's
|
|
30
30
|
* replies are kept per chat until the chat changes.
|
|
31
31
|
*
|
|
32
|
+
* Not in the total: Claude Code's subagent progress summaries, side requests
|
|
33
|
+
* no transcript records (progresssummaries.ts). They are estimated per
|
|
34
|
+
* background subagent and shown beside the total as a range, the two ways
|
|
35
|
+
* Anthropic may serve them (short notes, or the whole context).
|
|
36
|
+
*
|
|
32
37
|
* `savings` bills a narrower slice of the same Claude Code requests: the main
|
|
33
38
|
* conversation's input (cache writes and reads included, output not), in
|
|
34
39
|
* sessions with 10+ requests. `spend` counts every request, its output and
|
|
35
40
|
* subagents too; on the requests both count, the dollars are the same.
|
|
36
41
|
*/
|
|
42
|
+
import { type ProgressOptions } from "./progresssummaries.js";
|
|
37
43
|
import { type Modifiers } from "./pricing.js";
|
|
38
44
|
import { type Extractor } from "./scan.js";
|
|
39
45
|
export type Tool = "claude" | "codex" | "gemini" | "cursor";
|
|
@@ -70,6 +76,8 @@ export interface SpendItem {
|
|
|
70
76
|
workflow?: string;
|
|
71
77
|
/** Claude Code: the reply's row uuid, which a fork's copy shares. Codex: the event's codexEventKey, which a forked rollout's copy shares. */
|
|
72
78
|
key?: string;
|
|
79
|
+
/** Claude Code: a compaction's own request, which no row records usage for: estimated from the context it read and its summary (compactcost.ts). */
|
|
80
|
+
compaction?: boolean;
|
|
73
81
|
}
|
|
74
82
|
/**
|
|
75
83
|
* A project folder's name (its path with "-" for separators, as Claude Code
|
|
@@ -210,6 +218,25 @@ export interface SpendReport {
|
|
|
210
218
|
requests: number;
|
|
211
219
|
usd: number;
|
|
212
220
|
}>;
|
|
221
|
+
/** Claude Code's compactions, each one's own request estimated (no row records its usage): inside `usd`; absent when none. */
|
|
222
|
+
compactions?: {
|
|
223
|
+
requests: number;
|
|
224
|
+
usd: number;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Claude Code's subagent progress summaries, estimated (no transcript records them): NOT in `usd`.
|
|
228
|
+
* `notesUsd` as short notes (served since November 2026), `forkUsd` as the whole context (before).
|
|
229
|
+
* `set`: CLAUDE_CODE_DISABLE_AGENT_PROGRESS_SUMMARIES is set there, since when unknown: not estimated.
|
|
230
|
+
* Absent when no subagent got any.
|
|
231
|
+
*/
|
|
232
|
+
progressSummaries?: {
|
|
233
|
+
agents: number;
|
|
234
|
+
calls: number;
|
|
235
|
+
notesUsd: number;
|
|
236
|
+
forkUsd: number;
|
|
237
|
+
} | {
|
|
238
|
+
set: string;
|
|
239
|
+
};
|
|
213
240
|
sessions: Array<{
|
|
214
241
|
tool: Tool;
|
|
215
242
|
project: string;
|
|
@@ -236,6 +263,13 @@ export interface SpendOptions {
|
|
|
236
263
|
claudePaths?: string[];
|
|
237
264
|
onProgress?: (done: number, total: number) => void;
|
|
238
265
|
now?: number;
|
|
266
|
+
/**
|
|
267
|
+
* The progress summaries' estimate: the fork gate, when the variable turned them off
|
|
268
|
+
* (fix's record), or where it is set with no record (then not estimated); false: none.
|
|
269
|
+
*/
|
|
270
|
+
progress?: false | (Pick<ProgressOptions, "forkGateOff" | "offSince"> & {
|
|
271
|
+
set?: string;
|
|
272
|
+
});
|
|
239
273
|
}
|
|
240
274
|
/**
|
|
241
275
|
* The longest window: ten years, older than any history these tools keep.
|
package/dist/spend.js
CHANGED
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
* (scan.ts), so a second run reads only what was appended since; Cursor's
|
|
30
30
|
* replies are kept per chat until the chat changes.
|
|
31
31
|
*
|
|
32
|
+
* Not in the total: Claude Code's subagent progress summaries, side requests
|
|
33
|
+
* no transcript records (progresssummaries.ts). They are estimated per
|
|
34
|
+
* background subagent and shown beside the total as a range, the two ways
|
|
35
|
+
* Anthropic may serve them (short notes, or the whole context).
|
|
36
|
+
*
|
|
32
37
|
* `savings` bills a narrower slice of the same Claude Code requests: the main
|
|
33
38
|
* conversation's input (cache writes and reads included, output not), in
|
|
34
39
|
* sessions with 10+ requests. `spend` counts every request, its output and
|
|
@@ -38,18 +43,19 @@ import { basename, dirname, join } from "node:path";
|
|
|
38
43
|
import { codexDir } from "./codexdir.js";
|
|
39
44
|
import { homedir } from "node:os";
|
|
40
45
|
import { closeSync, existsSync, openSync, readdirSync, readSync, statSync } from "node:fs";
|
|
41
|
-
import { claudeFileUsage, claudeUsageFiles, codexEventKey, codexSessionsRoot, rolloutFiles } from "./limits.js";
|
|
46
|
+
import { claudeFileUsage, claudeUsageFiles, codexEventKey, codexSessionsRoot, rolloutFiles, USAGE_ROWS } from "./limits.js";
|
|
47
|
+
import { estimateProgressSummaries, PROGRESS_ROWS, PROGRESS_SUMMARIES_ENV } from "./progresssummaries.js";
|
|
42
48
|
import { listGeminiChats, readGeminiMessages } from "./gemini.js";
|
|
43
49
|
import { cursorClaudeId, cursorUsage, SqliteUnavailableError } from "./cursor.js";
|
|
44
50
|
import { addModifiers, isUnbilledModel, NO_MODIFIERS, openAIUsage, priceChangedText, requestCost } from "./pricing.js";
|
|
45
|
-
import { orgRates, orgRatesLine, priceBasis } from "./orgrates.js";
|
|
51
|
+
import { managedSourcesLine, orgRates, orgRatesLine, priceBasis } from "./orgrates.js";
|
|
46
52
|
/**
|
|
47
53
|
* What spend's dollars are: each request as it was billed (its tier, fast mode,
|
|
48
54
|
* US-only, web searches) at list rates, or at the organization's rates.
|
|
49
55
|
* "At list prices" was true before those were priced; it no longer is.
|
|
50
56
|
*/
|
|
51
57
|
const spendBasis = () => (orgRates() ? priceBasis() : "as billed at list rates");
|
|
52
|
-
import { pick, rowsOf } from "./scan.js";
|
|
58
|
+
import { pick, prescan, rowsOf } from "./scan.js";
|
|
53
59
|
import { formatTokens } from "./tokens.js";
|
|
54
60
|
import { withInvocation } from "./invocation.js";
|
|
55
61
|
const DAY = 86_400_000;
|
|
@@ -124,6 +130,8 @@ export function claudeSpend(since, until = Infinity, tops, onProgress) {
|
|
|
124
130
|
usd: r.usd, inputUsd, readUsd, writeUsd: Math.max(0, r.promptUsd - inputUsd - readUsd), outputUsd: Math.max(0, r.usd - r.promptUsd - r.modifiers.webSearchUsd), priced: Boolean(price),
|
|
125
131
|
};
|
|
126
132
|
label(item, r);
|
|
133
|
+
if (r.compaction)
|
|
134
|
+
item.compaction = true;
|
|
127
135
|
if (r.model)
|
|
128
136
|
item.model = r.model;
|
|
129
137
|
if (f.run)
|
|
@@ -515,7 +523,12 @@ export function summarizeSpend(items, days, since, until, skipped = []) {
|
|
|
515
523
|
const runs = new Set();
|
|
516
524
|
const mods = { ...NO_MODIFIERS };
|
|
517
525
|
const changed = new Map();
|
|
526
|
+
const compactions = { requests: 0, usd: 0 };
|
|
518
527
|
for (const it of items) {
|
|
528
|
+
if (it.compaction) {
|
|
529
|
+
compactions.requests++;
|
|
530
|
+
compactions.usd += it.usd;
|
|
531
|
+
}
|
|
519
532
|
if (it.modifiers)
|
|
520
533
|
addModifiers(mods, it.modifiers);
|
|
521
534
|
if (it.changedOn) {
|
|
@@ -595,10 +608,19 @@ export function summarizeSpend(items, days, since, until, skipped = []) {
|
|
|
595
608
|
parts,
|
|
596
609
|
...(anyModifier(mods) ? { modifiers: mods } : {}),
|
|
597
610
|
...(changed.size ? { priceChanged: [...changed.values()].sort((a, b) => b.usd - a.usd) } : {}),
|
|
611
|
+
...(compactions.requests ? { compactions } : {}),
|
|
598
612
|
sessions: [...sessions.values()].sort(byUsd),
|
|
599
613
|
skipped,
|
|
600
614
|
};
|
|
601
615
|
}
|
|
616
|
+
/** The subagent progress summaries Claude Code wrote in the window, for the report. */
|
|
617
|
+
function claudeProgressSummaries(since, until, tops, o) {
|
|
618
|
+
if (o?.set && o.offSince === undefined)
|
|
619
|
+
return { set: o.set };
|
|
620
|
+
const files = claudeUsageFiles(since, tops).filter((f) => f.subagent && !f.run).map((f) => f.file);
|
|
621
|
+
const e = estimateProgressSummaries(files, { since, until, forkGateOff: o?.forkGateOff, offSince: o?.offSince });
|
|
622
|
+
return e.calls ? { agents: e.summarized, calls: e.calls, notesUsd: e.notesUsd, forkUsd: e.forkUsd } : undefined;
|
|
623
|
+
}
|
|
602
624
|
/**
|
|
603
625
|
* The longest window: ten years, older than any history these tools keep.
|
|
604
626
|
* Unbounded, `--days 10000000` listed every empty day of it (51 s, and
|
|
@@ -611,6 +633,9 @@ export function spendReport(days = 30, opts = {}) {
|
|
|
611
633
|
const until = opts.now ?? Date.now();
|
|
612
634
|
const since = until - days * DAY;
|
|
613
635
|
const home = opts.home ?? homedir();
|
|
636
|
+
// A subagent's transcript read once for its usage and its timeline (the progress summaries).
|
|
637
|
+
if (opts.progress !== false)
|
|
638
|
+
prescan([{ paths: claudeUsageFiles(since, opts.claudePaths).filter((f) => f.subagent && !f.run).map((f) => f.file), extractors: [USAGE_ROWS, PROGRESS_ROWS] }]);
|
|
614
639
|
const items = [...claudeSpend(since, until, opts.claudePaths, opts.onProgress), ...codexSpend(since, until, home), ...geminiSpend(since, until, home)];
|
|
615
640
|
const skipped = [];
|
|
616
641
|
try {
|
|
@@ -620,7 +645,9 @@ export function spendReport(days = 30, opts = {}) {
|
|
|
620
645
|
if (e instanceof SqliteUnavailableError)
|
|
621
646
|
skipped.push({ tool: "cursor", reason: "reading Cursor's history needs SQLite: Node 22.13+ or the sqlite3 command" });
|
|
622
647
|
}
|
|
623
|
-
|
|
648
|
+
const report = summarizeSpend(items, days, since, until, skipped);
|
|
649
|
+
const progress = opts.progress === false ? undefined : claudeProgressSummaries(since, until, opts.claudePaths, opts.progress);
|
|
650
|
+
return progress ? { ...report, progressSummaries: progress } : report;
|
|
624
651
|
}
|
|
625
652
|
// ---------------------------------------------------------------------------
|
|
626
653
|
// Rendering
|
|
@@ -653,6 +680,9 @@ export function renderSpend(r, top = 8) {
|
|
|
653
680
|
const org = orgRatesLine();
|
|
654
681
|
if (org)
|
|
655
682
|
lines.push(org);
|
|
683
|
+
const ahead = managedSourcesLine();
|
|
684
|
+
if (ahead)
|
|
685
|
+
lines.push(ahead);
|
|
656
686
|
lines.push("─".repeat(60));
|
|
657
687
|
for (const t of r.tools) {
|
|
658
688
|
const unit = t.tool === "cursor" ? "replies" : "requests";
|
|
@@ -692,9 +722,20 @@ export function renderSpend(r, top = 8) {
|
|
|
692
722
|
// What the requests' own billing added to the list rates, already in the parts above.
|
|
693
723
|
if (r.modifiers)
|
|
694
724
|
lines.push(` Of it, billed above list rates: ${modifiersText(r.modifiers)}`);
|
|
725
|
+
// A compaction's own request is in no row's usage: estimated from the context it read and the summary it wrote.
|
|
726
|
+
if (r.compactions)
|
|
727
|
+
lines.push(` Of it, ${r.compactions.requests.toLocaleString("en-US")} Claude Code ${r.compactions.requests === 1 ? "compaction's own request" : "compactions' own requests"} ${usd(r.compactions.usd)}, an estimate (no row records their usage)`);
|
|
695
728
|
const claude = r.tools.find((t) => t.tool === "claude");
|
|
696
729
|
if (claude?.subagentUsd)
|
|
697
730
|
lines.push(` Claude Code subagents ${usd(claude.subagentUsd)} (${share(claude.subagentUsd, r.usd)}): context-doctor subagents says which paid off`);
|
|
731
|
+
// Side requests no transcript records: a range, outside the total.
|
|
732
|
+
const ps = r.progressSummaries;
|
|
733
|
+
if (ps && "calls" in ps) {
|
|
734
|
+
lines.push(` Not in it: ~${ps.calls.toLocaleString("en-US")} subagent progress summaries (${ps.agents} background ${ps.agents === 1 ? "agent" : "agents"}), an estimate:`);
|
|
735
|
+
lines.push(` ${usd(ps.notesUsd)} as notes, ${usd(ps.forkUsd)} at the whole context; no transcript records them`);
|
|
736
|
+
}
|
|
737
|
+
else if (ps)
|
|
738
|
+
lines.push(` Subagent progress summaries: not estimated, ${PROGRESS_SUMMARIES_ENV} is set in ${ps.set}`);
|
|
698
739
|
if (claude?.workflowUsd)
|
|
699
740
|
lines.push(` Claude Code workflow agents ${usd(claude.workflowUsd)} (${share(claude.workflowUsd, r.usd)}), in ${runsText(claude.workflowRuns ?? 0)}`);
|
|
700
741
|
lines.push(" Biggest sessions:");
|
|
@@ -757,6 +798,9 @@ export function renderSpendShare(r) {
|
|
|
757
798
|
lines.push(`Of it, ${usd(r.priceChanged.reduce((s, c) => s + c.usd, 0))} is on models priced past the day their price changed, an estimate.`);
|
|
758
799
|
if (r.modifiers)
|
|
759
800
|
lines.push(`Billed above list rates: ${modifiersText(r.modifiers)}.`);
|
|
801
|
+
const ps = r.progressSummaries;
|
|
802
|
+
if (ps && "calls" in ps)
|
|
803
|
+
lines.push(`Not in it: Claude Code's subagent progress summaries, which no transcript records: ${usd(ps.notesUsd)}-${usd(ps.forkUsd)}, an estimate.`);
|
|
760
804
|
const parts = [["cache writes", r.parts.writeUsd], ["cache reads", r.parts.readUsd], ["output", r.parts.outputUsd], ["uncached input", r.parts.inputUsd], ["web searches", r.parts.webSearchUsd ?? 0]];
|
|
761
805
|
const [bigPart, bigUsd] = parts.sort((a, b) => b[1] - a[1])[0];
|
|
762
806
|
const busiest = [...r.daily].sort((a, b) => b.usd - a.usd)[0];
|