@co0ontty/wand 2.5.0 → 2.6.0-beta.g13e288d

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.
@@ -1,6 +1,6 @@
1
1
  {
2
- "commit": "c04127b953cab17f63be52f5eded4320262dd641",
3
- "builtAt": "2026-07-10T14:28:43.912Z",
4
- "version": "2.5.0",
5
- "channel": "stable"
2
+ "commit": "13e288d5493387f9bb046fcfa5df3dd809590759",
3
+ "builtAt": "2026-07-11T11:40:41.589Z",
4
+ "version": "2.6.0-beta.g13e288d",
5
+ "channel": "beta"
6
6
  }
@@ -50,6 +50,12 @@ export interface CodexFileSnapshot {
50
50
  }
51
51
  type CodexFileSnapshotMap = Map<string, CodexFileSnapshot>;
52
52
  export declare function buildCodexFileChangeBlocks(item: Record<string, unknown>, completed: boolean, beforeSnapshots?: CodexFileSnapshotMap, afterSnapshots?: CodexFileSnapshotMap): ContentBlock[];
53
+ /**
54
+ * Codex `exec --json` only publishes authoritative usage with `turn.completed`.
55
+ * Keep the bottom usage row useful while the turn is running by estimating the
56
+ * model-produced text/tool arguments; the final provider value replaces this.
57
+ */
58
+ export declare function estimateCodexOutputTokens(blocks: ContentBlock[]): number;
53
59
  export declare class StructuredSessionManager {
54
60
  private readonly storage;
55
61
  private readonly config;
@@ -375,6 +375,47 @@ export function buildCodexFileChangeBlocks(item, completed, beforeSnapshots = ne
375
375
  });
376
376
  return blocks;
377
377
  }
378
+ /**
379
+ * Codex `exec --json` only publishes authoritative usage with `turn.completed`.
380
+ * Keep the bottom usage row useful while the turn is running by estimating the
381
+ * model-produced text/tool arguments; the final provider value replaces this.
382
+ */
383
+ export function estimateCodexOutputTokens(blocks) {
384
+ let asciiUnits = 0;
385
+ let wideUnits = 0;
386
+ const addText = (value) => {
387
+ for (const char of value) {
388
+ if (char.codePointAt(0) <= 0x7f)
389
+ asciiUnits += 1;
390
+ else
391
+ wideUnits += 1;
392
+ }
393
+ };
394
+ for (const block of blocks) {
395
+ if (block.type === "text")
396
+ addText(block.text);
397
+ else if (block.type === "thinking")
398
+ addText(block.thinking);
399
+ else if (block.type === "tool_use") {
400
+ addText(block.name);
401
+ try {
402
+ addText(JSON.stringify(block.input));
403
+ }
404
+ catch { /* best-effort live estimate */ }
405
+ }
406
+ }
407
+ if (asciiUnits === 0 && wideUnits === 0)
408
+ return 0;
409
+ return Math.max(1, Math.ceil(asciiUnits / 4 + wideUnits));
410
+ }
411
+ function refreshEstimatedCodexUsage(turnState) {
412
+ if (turnState.usage?.estimated !== true)
413
+ return;
414
+ turnState.usage = {
415
+ outputTokens: estimateCodexOutputTokens(turnState.blocks),
416
+ estimated: true,
417
+ };
418
+ }
378
419
  function captureTaskMeta(blocks, registry) {
379
420
  for (const b of blocks) {
380
421
  if (b.type !== "tool_use")
@@ -1479,7 +1520,7 @@ export class StructuredSessionManager {
1479
1520
  result: "",
1480
1521
  sessionId: session.claudeSessionId,
1481
1522
  model: session.selectedModel ?? session.structuredState?.model,
1482
- usage: undefined,
1523
+ usage: { outputTokens: 0, estimated: true },
1483
1524
  codexBlockIndex: new Map(),
1484
1525
  codexFileSnapshots: new Map(),
1485
1526
  cwd: session.cwd,
@@ -1510,6 +1551,7 @@ export class StructuredSessionManager {
1510
1551
  const current = this.sessions.get(sessionId);
1511
1552
  if (!current)
1512
1553
  return;
1554
+ refreshEstimatedCodexUsage(turnState);
1513
1555
  const inProgressTurn = {
1514
1556
  role: "assistant",
1515
1557
  content: this.compactContentBlocks([...turnState.blocks], turnState.result),
package/dist/types.d.ts CHANGED
@@ -368,6 +368,8 @@ export interface ConversationTurn {
368
368
  /** codex 专属:reasoning_output_tokens(GPT-5 等带思考模型,per-turn 计费)。 */
369
369
  reasoningOutputTokens?: number;
370
370
  totalCostUsd?: number;
371
+ /** True while the live value is estimated; omitted once the provider reports final usage. */
372
+ estimated?: boolean;
371
373
  };
372
374
  }
373
375
  export interface StructuredSessionState {