@pi-unipi/compactor 2.2.1 → 2.4.0
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/package.json +3 -3
- package/src/info-screen.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/compactor",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Context engine for Pi — zero-LLM compaction, session continuity, sandbox execution, and tool display optimization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@pi-unipi/core": "2.
|
|
38
|
-
"@pi-unipi/info-screen": "2.
|
|
37
|
+
"@pi-unipi/core": "2.4.0",
|
|
38
|
+
"@pi-unipi/info-screen": "2.4.0",
|
|
39
39
|
"@earendil-works/pi-agent-core": "^0.80.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
package/src/info-screen.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import type { SessionDB } from "./session/db.js";
|
|
14
14
|
import { getLastCompactionStats } from "./compaction/hooks.js";
|
|
15
|
-
import {
|
|
15
|
+
import { parseUsageStatsAsync } from "@pi-unipi/info-screen/usage-parser.js";
|
|
16
16
|
import type { RuntimeCounters } from "./types.js";
|
|
17
17
|
|
|
18
18
|
export interface CompactorInfoData {
|
|
@@ -42,9 +42,9 @@ function formatCost(n: number): string {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/** Estimate cost per token for the most-used model in the current session. */
|
|
45
|
-
function estimateCostPerToken(): number | null {
|
|
45
|
+
async function estimateCostPerToken(): Promise<number | null> {
|
|
46
46
|
try {
|
|
47
|
-
const usage =
|
|
47
|
+
const usage = await parseUsageStatsAsync();
|
|
48
48
|
// Use today's most-used model if available, otherwise all-time
|
|
49
49
|
const models = usage.byModelToday;
|
|
50
50
|
const todayKeys = Object.keys(models);
|
|
@@ -154,7 +154,7 @@ export async function getInfoScreenData(
|
|
|
154
154
|
: "No tool calls yet";
|
|
155
155
|
|
|
156
156
|
// ── Cost saved estimate ──
|
|
157
|
-
const costPerToken = estimateCostPerToken();
|
|
157
|
+
const costPerToken = await estimateCostPerToken();
|
|
158
158
|
const costSaved = costPerToken !== null ? tokensSaved * costPerToken : null;
|
|
159
159
|
|
|
160
160
|
// ── Last compaction details ──
|