linkshell-cli 0.5.15 → 0.5.16

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.
@@ -5,6 +5,7 @@ import { createEnvelope, parseTypedPayload, } from "@linkshell/protocol";
5
5
  import { AcpClient } from "./acp-client.js";
6
6
  import { ClaudeSdkClient } from "./claude-sdk-client.js";
7
7
  import { ClaudeStreamJsonClient } from "./claude-stream-json-client.js";
8
+ import { aggregateUsage } from "../usage-report.js";
8
9
  import { resolveAgentCommand } from "./provider-resolver.js";
9
10
  const PERMISSION_TIMEOUT_MS = 5 * 60_000;
10
11
  const MAX_TIMELINE_ITEMS = 200;
@@ -1483,6 +1484,26 @@ export class AgentWorkspaceProxy {
1483
1484
  await this.loadOlderHistory(payload);
1484
1485
  break;
1485
1486
  }
1487
+ case "agent.v2.usage.request": {
1488
+ // Aggregate ALL on-disk transcripts (decoupled from live turns). The
1489
+ // scan is synchronous (~3s over a large corpus); acceptable for an
1490
+ // explicit, on-demand dashboard open. Errors must never break the
1491
+ // session, so swallow + send an empty report.
1492
+ try {
1493
+ const report = aggregateUsage();
1494
+ this.input.send(createEnvelope({
1495
+ type: "agent.v2.usage.report",
1496
+ sessionId: this.input.sessionId,
1497
+ payload: report,
1498
+ }));
1499
+ }
1500
+ catch (error) {
1501
+ if (this.input.verbose) {
1502
+ process.stderr.write(`[agent:v2] usage aggregation failed: ${error instanceof Error ? error.message : String(error)}\n`);
1503
+ }
1504
+ }
1505
+ break;
1506
+ }
1486
1507
  case "agent.v2.prompt": {
1487
1508
  const payload = parseTypedPayload("agent.v2.prompt", envelope.payload);
1488
1509
  await this.sendPrompt(payload);