@ferris1225/pi-subagents 4.3.23 → 4.3.24

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/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  Release notes for `@ferris1225/pi-subagents`. Only the most recent releases
4
4
  are kept here; every published version is preserved as a GitHub Release.
5
5
 
6
+ ## 4.3.24
7
+
8
+ - Remove the live `tok/s` throughput figure from the per-model cost footer.
9
+ Dividing the message's output tokens by wall-clock stream time could not be
10
+ made trustworthy across providers (reasoning tokens, time-to-first-token,
11
+ and per-chunk usage semantics differ), and no mainstream agent CLI ships a
12
+ comparable live rate. The footer keeps exactly-reported facts only: per-model
13
+ token flow, cost, context share, and thinking level.
14
+
6
15
  ## 4.3.23
7
16
 
8
17
  - Track Pi 1.0.3. The extension API, RPC command types, and the child
package/README.md CHANGED
@@ -13,6 +13,11 @@ is clear, and delegation will actually reduce cost or improve completion quality
13
13
 
14
14
  ## What's new
15
15
 
16
+ **4.3.24** — the per-model cost footer drops the live `tok/s` throughput
17
+ figure: measured rates could not be trusted across providers, so the footer
18
+ sticks to what pi reports exactly — per-model token flow, cost, context share,
19
+ and thinking level.
20
+
16
21
  **4.3.23** — Pi 1.0.3. Development dependencies track that release. A stored
17
22
  agent model that still names `azure-openai-responses/<id>` keeps working: it
18
23
  follows the live catalog, and is saved as `azure/<id>` once that is the id Pi
@@ -403,13 +408,12 @@ capped at ten lines: when many runs are live, extra runs collapse into a
403
408
  In TUI sessions the extension replaces pi's built-in consumption line with a
404
409
  per-model tally of the main window's own spend, directly under the
405
410
  current-project line. Models are never merged: each `provider/model` keeps its
406
- own token flow, cost, and — for the current model — context share, effective
407
- thinking level, and live throughput (`~` marks the streaming estimate; the
408
- exact rate of the last completed message replaces it):
411
+ own token flow, cost, and — for the current model — context share and
412
+ effective thinking level:
409
413
 
410
414
  ```text
411
415
  ~/projs/app (main)
412
- ↑48.1k ↓112.7k R1.9M W302.4k $3.0812 · 41.2%/200.0k · ~58.3 tok/s zhipu/glm-4.7 • high
416
+ ↑48.1k ↓112.7k R1.9M W302.4k $3.0812 · 41.2%/200.0k zhipu/glm-4.7 • high
413
417
  anthropic/claude-sonnet-4 ↑12.0k ↓31.2k R410.0k $0.9104
414
418
  ```
415
419
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferris1225/pi-subagents",
3
- "version": "4.3.23",
3
+ "version": "4.3.24",
4
4
  "description": "A managed sub-agent team for pi: lightweight scout research and artisan implementation, one-shot runs, read-only status, and Git worktree isolation.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Persistent cost footer: replaces pi's built-in consumption line with a
3
3
  * per-model tally of the main window's own spend, so models are never summed
4
- * into one number — each `provider/model` keeps its own token flow, cost,
5
- * context share, and live throughput. The current-project line stays first,
6
- * exactly where pi put it; extension statuses stay last.
4
+ * into one number — each `provider/model` keeps its own token flow, cost, and
5
+ * context share. The current-project line stays first, exactly where pi put
6
+ * it; extension statuses stay last.
7
7
  *
8
8
  * Sub-agent spend is intentionally absent: children report per-run usage with
9
9
  * their model ref when they settle, and injecting it here (or into the parent
@@ -61,11 +61,6 @@ function contextPart(theme: Theme, usage: { percent?: number | null; contextWind
61
61
  return display;
62
62
  }
63
63
 
64
- function speedPart(speed: { tokensPerSecond: number; streaming: boolean } | undefined): string {
65
- if (!speed || speed.tokensPerSecond <= 0) return "";
66
- return `${speed.streaming ? "~" : ""}${speed.tokensPerSecond.toFixed(1)} tok/s`;
67
- }
68
-
69
64
  function spendUsage(spend: ModelSpendRow["spend"]): UsageStats {
70
65
  return { ...spend, contextTokens: 0, turns: 0 };
71
66
  }
@@ -88,11 +83,6 @@ function currentModelLine(
88
83
  const parts = [spendPart(row.spend)];
89
84
  const context = contextPart(theme, ctx.getContextUsage?.());
90
85
  if (context) parts.push(context);
91
- const speed = costLedger.speed();
92
- if (speed && speed.model === row.model) {
93
- const part = speedPart(speed);
94
- if (part) parts.push(part);
95
- }
96
86
  let left = parts.join(" ");
97
87
  if (visibleWidth(left) > width) left = truncateToWidth(left, width, "…");
98
88
 
@@ -124,7 +114,7 @@ function settledModelLine(row: ModelSpendRow, theme: Theme, width: number): stri
124
114
  }
125
115
 
126
116
  /** Render the replacement footer: project line first, one line per model the
127
- * main window spent on (current model with context + throughput), extension
117
+ * main window spent on (current model with context share), extension
128
118
  * statuses last — the same slots the built-in footer used. Settled models are
129
119
  * ranked by spend and capped, so a session that switched through many models
130
120
  * never grows the footer without bound. */
@@ -6,7 +6,7 @@
6
6
  * per-model completion totals), so mixing its live spend into the parent's
7
7
  * footer would just re-create the cross-model sum this ledger exists to
8
8
  * avoid. The ledger covers the main window only — across `/model` switches,
9
- * each model keeps its own tally — plus its live token throughput.
9
+ * each model keeps its own tally.
10
10
  */
11
11
 
12
12
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
@@ -28,23 +28,6 @@ export interface ModelSpendRow {
28
28
  spend: ModelSpend;
29
29
  }
30
30
 
31
- export interface MainStreamSpeed {
32
- model: string;
33
- tokensPerSecond: number;
34
- /** True while the assistant is still streaming (value is an estimate). */
35
- streaming: boolean;
36
- }
37
-
38
- interface StreamState {
39
- model: string;
40
- startedAt: number;
41
- estimatedChars: number;
42
- }
43
-
44
- /** Rough chars-per-token for the live estimate; the exact rate replaces it at
45
- * `message_end`, where real output tokens are known. */
46
- const ESTIMATED_CHARS_PER_TOKEN = 4;
47
-
48
31
  /** pi Usage shape: numeric token buckets plus a cost that is either already a
49
32
  * number (child tallies) or the provider object with a `total`. */
50
33
  interface UsageLike {
@@ -84,8 +67,6 @@ export class CostLedger {
84
67
  /** First-seen order, so row order is stable between notifications. */
85
68
  private order: string[] = [];
86
69
  private currentModel: string | undefined;
87
- private stream: StreamState | undefined;
88
- private lastSpeed: MainStreamSpeed | undefined;
89
70
  private subscribers = new Set<() => void>();
90
71
 
91
72
  record(model: string, spend: UsageLike | undefined): void {
@@ -133,8 +114,6 @@ export class CostLedger {
133
114
  this.rows.clear();
134
115
  this.order = [];
135
116
  this.currentModel = undefined;
136
- this.stream = undefined;
137
- this.lastSpeed = undefined;
138
117
  this.notify();
139
118
  }
140
119
 
@@ -145,46 +124,6 @@ export class CostLedger {
145
124
  };
146
125
  }
147
126
 
148
- noteStreamStart(model: string): void {
149
- this.stream = { model, startedAt: Date.now(), estimatedChars: 0 };
150
- this.lastSpeed = undefined;
151
- this.notify();
152
- }
153
-
154
- noteStreamDelta(chars: number): void {
155
- if (!this.stream || chars <= 0) return;
156
- this.stream.estimatedChars += chars;
157
- this.notify();
158
- }
159
-
160
- isStreaming(): boolean {
161
- return this.stream !== undefined;
162
- }
163
-
164
- noteStreamEnd(model: string, outputTokens: number): void {
165
- const stream = this.stream;
166
- this.stream = undefined;
167
- if (stream && outputTokens > 0) {
168
- const seconds = Math.max(0.001, (Date.now() - stream.startedAt) / 1_000);
169
- this.lastSpeed = { model, tokensPerSecond: outputTokens / seconds, streaming: false };
170
- }
171
- this.notify();
172
- }
173
-
174
- /** Live estimate while streaming, exact rate of the last completed
175
- * assistant message afterwards; undefined before any generation. */
176
- speed(): MainStreamSpeed | undefined {
177
- if (this.stream) {
178
- const seconds = Math.max(0.001, (Date.now() - this.stream.startedAt) / 1_000);
179
- return {
180
- model: this.stream.model,
181
- tokensPerSecond: this.stream.estimatedChars / ESTIMATED_CHARS_PER_TOKEN / seconds,
182
- streaming: true,
183
- };
184
- }
185
- return this.lastSpeed;
186
- }
187
-
188
127
  private notify(): void {
189
128
  for (const cb of this.subscribers) {
190
129
  try {
@@ -202,35 +141,12 @@ export const costLedger = new CostLedger();
202
141
  * carry the serving model and exact usage, model switches re-key the current
203
142
  * row, and compaction calls land on the model that made them. */
204
143
  export function registerMainCostTracking(pi: ExtensionAPI): void {
205
- pi.on("message_start", async (event) => {
206
- const message = (event as { message?: { role?: string } }).message;
207
- if (message?.role !== "assistant") return;
208
- const ref = messageModelRef(message as { provider?: string; model?: string });
209
- if (ref) costLedger.noteStreamStart(ref);
210
- });
211
-
212
- pi.on("message_update", async (event) => {
213
- const delta = (event as { assistantMessageEvent?: { type?: string; delta?: string } }).assistantMessageEvent;
214
- if (delta?.type !== "text_delta" && delta?.type !== "thinking_delta") return;
215
- // `message_start` does not always carry the model yet; the first delta
216
- // of the stream is just as good a clock start.
217
- if (!costLedger.isStreaming()) {
218
- const partial = (event as { message?: { role?: string } }).message;
219
- if (partial?.role === "assistant") {
220
- const ref = messageModelRef(partial as { provider?: string; model?: string });
221
- if (ref) costLedger.noteStreamStart(ref);
222
- }
223
- }
224
- costLedger.noteStreamDelta(delta.delta?.length ?? 0);
225
- });
226
-
227
144
  pi.on("message_end", async (event) => {
228
145
  const message = (event as { message?: { role?: string; provider?: string; model?: string; usage?: UsageLike } }).message;
229
146
  if (message?.role !== "assistant") return;
230
147
  const ref = messageModelRef(message) ?? costLedger.getCurrentModel();
231
148
  if (!ref) return;
232
149
  const usage = finiteUsage(message.usage);
233
- costLedger.noteStreamEnd(ref, usage.output);
234
150
  costLedger.record(ref, usage);
235
151
  });
236
152