@aexol/spectral 0.2.19 → 0.2.20

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.
@@ -833,8 +833,17 @@ export class PiBridge {
833
833
  // Emit token usage for this assistant message. pi provides token
834
834
  // counts via ev.message.usage; cost is computed from the model's
835
835
  // configured pricing (or null when unavailable).
836
+ //
837
+ // Skip zero-total-usage events — they happen when a turn is
838
+ // cancelled before the provider starts streaming, and emitting
839
+ // inputTokens:0 would mislead the UI into showing 0% context window
840
+ // usage after reconnect.
836
841
  const usage = ev.message.usage;
837
- if (usage) {
842
+ const totalTokens = (usage?.input ?? 0) +
843
+ (usage?.output ?? 0) +
844
+ (usage?.cacheRead ?? 0) +
845
+ (usage?.cacheWrite ?? 0);
846
+ if (usage && totalTokens > 0) {
838
847
  const usageEvent = {
839
848
  type: "token_usage",
840
849
  messageId,
@@ -843,7 +852,7 @@ export class PiBridge {
843
852
  outputTokens: usage.output ?? 0,
844
853
  cacheReadTokens: usage.cacheRead ?? 0,
845
854
  cacheWriteTokens: usage.cacheWrite ?? 0,
846
- totalTokens: usage.totalTokens ?? 0,
855
+ totalTokens: usage.totalTokens ?? totalTokens,
847
856
  cost: usage.cost?.total ?? null,
848
857
  },
849
858
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aexol/spectral",
3
- "version": "0.2.19",
3
+ "version": "0.2.20",
4
4
  "description": "Always-on coding agent for Aexol — branded pi wrapper with relay-based browser access.",
5
5
  "type": "module",
6
6
  "private": false,