linkshell-cli 0.5.15 → 0.5.17
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/dist/cli/src/runtime/acp/agent-workspace.d.ts +1 -0
- package/dist/cli/src/runtime/acp/agent-workspace.js +27 -0
- package/dist/cli/src/runtime/acp/agent-workspace.js.map +1 -1
- package/dist/cli/src/runtime/usage-report.d.ts +34 -0
- package/dist/cli/src/runtime/usage-report.js +332 -0
- package/dist/cli/src/runtime/usage-report.js.map +1 -0
- package/dist/cli/tsconfig.tsbuildinfo +1 -1
- package/dist/shared-protocol/src/index.d.ts +570 -2
- package/dist/shared-protocol/src/index.js +37 -0
- package/dist/shared-protocol/src/index.js.map +1 -1
- package/package.json +3 -3
- package/src/runtime/acp/agent-workspace.ts +27 -0
- package/src/runtime/usage-report.ts +342 -0
- package/web/assets/index-B4Wh4MQf.js +94 -0
- package/web/assets/index-CLbwsKyd.css +33 -0
- package/web/index.html +2 -2
- package/web/assets/index-BXxBRB9A.css +0 -33
- package/web/assets/index-DAgnaJ6t.js +0 -94
|
@@ -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;
|
|
@@ -1418,6 +1419,7 @@ export class AgentWorkspaceProxy {
|
|
|
1418
1419
|
case "agent.v2.capabilities.request":
|
|
1419
1420
|
await this.initialize();
|
|
1420
1421
|
this.sendCapabilities();
|
|
1422
|
+
this.sendUsageReport();
|
|
1421
1423
|
break;
|
|
1422
1424
|
case "agent.v2.conversation.open": {
|
|
1423
1425
|
const payload = parseTypedPayload("agent.v2.conversation.open", envelope.payload);
|
|
@@ -1483,6 +1485,10 @@ export class AgentWorkspaceProxy {
|
|
|
1483
1485
|
await this.loadOlderHistory(payload);
|
|
1484
1486
|
break;
|
|
1485
1487
|
}
|
|
1488
|
+
case "agent.v2.usage.request": {
|
|
1489
|
+
this.sendUsageReport();
|
|
1490
|
+
break;
|
|
1491
|
+
}
|
|
1486
1492
|
case "agent.v2.prompt": {
|
|
1487
1493
|
const payload = parseTypedPayload("agent.v2.prompt", envelope.payload);
|
|
1488
1494
|
await this.sendPrompt(payload);
|
|
@@ -3767,6 +3773,27 @@ export class AgentWorkspaceProxy {
|
|
|
3767
3773
|
}
|
|
3768
3774
|
return firstString(raw, ["turnId", "id"]);
|
|
3769
3775
|
}
|
|
3776
|
+
// Fire-and-forget usage report — sent on init so the session list page shows
|
|
3777
|
+
// summary cards without anyone clicking a button. First call scans disk (~3s)
|
|
3778
|
+
// so it's deferred off the handler's critical path; cached (60s TTL)
|
|
3779
|
+
// thereafter. Errors silently swallowed (best-effort, never blocks).
|
|
3780
|
+
sendUsageReport() {
|
|
3781
|
+
setTimeout(() => {
|
|
3782
|
+
try {
|
|
3783
|
+
const report = aggregateUsage();
|
|
3784
|
+
this.input.send(createEnvelope({
|
|
3785
|
+
type: "agent.v2.usage.report",
|
|
3786
|
+
sessionId: this.input.sessionId,
|
|
3787
|
+
payload: report,
|
|
3788
|
+
}));
|
|
3789
|
+
}
|
|
3790
|
+
catch (error) {
|
|
3791
|
+
if (this.input.verbose) {
|
|
3792
|
+
process.stderr.write(`[agent:v2] usage aggregation failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
}, 0);
|
|
3796
|
+
}
|
|
3770
3797
|
}
|
|
3771
3798
|
function parsePermissionOptions(value) {
|
|
3772
3799
|
if (!Array.isArray(value)) {
|