@luxass/pi-cost-explorer 0.2.0 → 0.2.1
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/README.md +1 -1
- package/package.json +3 -2
- package/src/analysis.ts +7 -5
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Run `/cost` in Pi's terminal interface. The dialog has five tabs:
|
|
|
26
26
|
|
|
27
27
|
The totals use the same sources as Pi's `/session` command: model responses, usage that tools report for their own model calls, background usage such as cache warming, and compaction and branch summaries.
|
|
28
28
|
|
|
29
|
-
If you use `@luxass/pi-subagents`, the totals
|
|
29
|
+
If you use `@luxass/pi-subagents`, the totals include its runs under "Agents". Each run has one row with its model. Runs saved with `pi.appendUsage()` also count in Pi's footer and `/session`. Runs saved in the older format count in `/cost` but not in Pi's totals.
|
|
30
30
|
|
|
31
31
|
A Pi session branches when you go back to an earlier message and continue from there. These session branches are not Git branches. By default the dialog covers every session branch, and rows from other branches are dimmed. Press `b` to show only the current branch. While the dialog is open, it refreshes after each turn.
|
|
32
32
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxass/pi-cost-explorer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Explore a Pi session's cost by model, prompt, tool, and request in a tabbed dialog.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cost",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"lint:fix": "oxlint --fix .",
|
|
45
45
|
"fmt": "oxfmt .",
|
|
46
46
|
"fmt:check": "oxfmt --check .",
|
|
47
|
-
"typecheck": "tsc -p tsconfig.json"
|
|
47
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
48
|
+
"test": "node --test \"test/**/*.test.ts\""
|
|
48
49
|
}
|
|
49
50
|
}
|
package/src/analysis.ts
CHANGED
|
@@ -160,9 +160,10 @@ function toolCallNames(message: AssistantMessage): string[] {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
163
|
+
* Native usage kind and legacy custom entry type written by @luxass/pi-subagents.
|
|
164
|
+
* Each run uses one format, depending on which Pi APIs are available.
|
|
165
165
|
*/
|
|
166
|
+
const SUBAGENT_USAGE_KIND = "pi-subagents";
|
|
166
167
|
const SUBAGENT_USAGE_ENTRY_TYPE = "subagents-usage";
|
|
167
168
|
|
|
168
169
|
/**
|
|
@@ -182,7 +183,7 @@ interface SubagentUsageEntryData {
|
|
|
182
183
|
*
|
|
183
184
|
* Accounting follows Pi's `/session` totals: assistant messages, tool results with
|
|
184
185
|
* nested usage, usage entries, and compaction or branch summaries that report usage.
|
|
185
|
-
* Agent runs
|
|
186
|
+
* Agent runs from both native usage and legacy custom entries appear under Agents.
|
|
186
187
|
*/
|
|
187
188
|
export function analyze(
|
|
188
189
|
entries: readonly SessionEntry[],
|
|
@@ -257,10 +258,11 @@ export function analyze(
|
|
|
257
258
|
turnOf.set(entry.id, parentTurn);
|
|
258
259
|
const base = { entryId: entry.id, timestamp, turnId: parentTurn, toolCalls: [], onBranch };
|
|
259
260
|
if (entry.type === "usage") {
|
|
261
|
+
const isSubagent = entry.kind === SUBAGENT_USAGE_KIND;
|
|
260
262
|
addRecord({
|
|
261
263
|
...base,
|
|
262
|
-
source: "usage",
|
|
263
|
-
label: entry.kind,
|
|
264
|
+
source: isSubagent ? "agent" : "usage",
|
|
265
|
+
label: isSubagent ? (entry.note ?? entry.kind) : entry.kind,
|
|
264
266
|
provider: entry.provider,
|
|
265
267
|
model: entry.model,
|
|
266
268
|
usage: entry.usage,
|