@2kw/ai 8.5.0-dev.10 → 8.5.0-dev.13
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/commands/tracing.js +9 -1
- package/dist/lib/call-usage.d.ts +22 -0
- package/dist/lib/call-usage.js +28 -0
- package/package.json +1 -1
package/dist/commands/tracing.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
import { usageLabel } from "../lib/call-usage.js";
|
|
2
3
|
import { getClient, runAction } from "../lib/client.js";
|
|
4
|
+
import { isJsonOutput } from "../lib/config.js";
|
|
3
5
|
import { formatDetail, formatList } from "../lib/output.js";
|
|
4
6
|
import { tracingSettingsBody } from "../lib/tracing-settings.js";
|
|
5
7
|
export function makeTracingCommand() {
|
|
@@ -102,7 +104,13 @@ export function makeTracingCommand() {
|
|
|
102
104
|
},
|
|
103
105
|
});
|
|
104
106
|
const page = data;
|
|
105
|
-
|
|
107
|
+
const content = (page?.content ?? []);
|
|
108
|
+
formatList(isJsonOutput(command)
|
|
109
|
+
? content
|
|
110
|
+
: content.map((s) => ({
|
|
111
|
+
...s,
|
|
112
|
+
usage: usageLabel(s.usage, s.costUsd),
|
|
113
|
+
})), command, ["id", "sessionId", "name", "startTime", "durationMs", "turnCount", "errorCount", "usage"]);
|
|
106
114
|
});
|
|
107
115
|
});
|
|
108
116
|
sessions.addCommand(sessionsList);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One line for what a session's model calls used (#1774): on a built-in model the share of the
|
|
3
|
+
* included usage, on your own key the estimate in euros, for spans you sent the cost your SDK
|
|
4
|
+
* recorded. Never a cost for a built-in model.
|
|
5
|
+
*/
|
|
6
|
+
type Usage = {
|
|
7
|
+
platform?: {
|
|
8
|
+
poolSharePercent?: string | null;
|
|
9
|
+
} | null;
|
|
10
|
+
byok?: {
|
|
11
|
+
estimatedCostEur?: string | null;
|
|
12
|
+
} | null;
|
|
13
|
+
} | null;
|
|
14
|
+
/**
|
|
15
|
+
* `0.4% of included usage`, `<0.1% of included usage` below 0.1, `0% of included usage` for a call
|
|
16
|
+
* that took nothing from it (paid from extra usage), `—` before the call is settled. Twin of
|
|
17
|
+
* `poolShare` in mcp/src/tools/tracing.ts (separate packages): change both.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatPoolShare(percent: string | null | undefined): string;
|
|
20
|
+
export declare function usageLabel(usage: Usage | undefined, costUsd: number | null | undefined): string;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=call-usage.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `0.4% of included usage`, `<0.1% of included usage` below 0.1, `0% of included usage` for a call
|
|
3
|
+
* that took nothing from it (paid from extra usage), `—` before the call is settled. Twin of
|
|
4
|
+
* `poolShare` in mcp/src/tools/tracing.ts (separate packages): change both.
|
|
5
|
+
*/
|
|
6
|
+
export function formatPoolShare(percent) {
|
|
7
|
+
if (percent == null)
|
|
8
|
+
return "—";
|
|
9
|
+
if (Number(percent) === 0)
|
|
10
|
+
return "0% of included usage";
|
|
11
|
+
if (Number(percent) < 0.1)
|
|
12
|
+
return "<0.1% of included usage";
|
|
13
|
+
// one place, rounded down, on the decimal string: no float can round 0.30 to 0.2
|
|
14
|
+
const [whole, fraction = ""] = percent.split(".");
|
|
15
|
+
const tenth = fraction[0] && fraction[0] !== "0" ? `.${fraction[0]}` : "";
|
|
16
|
+
return `${whole}${tenth}% of included usage`;
|
|
17
|
+
}
|
|
18
|
+
export function usageLabel(usage, costUsd) {
|
|
19
|
+
const parts = [];
|
|
20
|
+
if (usage?.platform)
|
|
21
|
+
parts.push(formatPoolShare(usage.platform.poolSharePercent));
|
|
22
|
+
if (usage?.byok)
|
|
23
|
+
parts.push(usage.byok.estimatedCostEur == null ? "~€—" : `~€${usage.byok.estimatedCostEur}`);
|
|
24
|
+
if (costUsd != null)
|
|
25
|
+
parts.push(`$${costUsd}`);
|
|
26
|
+
return parts.length ? parts.join(" · ") : "-";
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=call-usage.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2kw/ai",
|
|
3
|
-
"version": "8.5.0-dev.
|
|
3
|
+
"version": "8.5.0-dev.13",
|
|
4
4
|
"description": "CLI for 2kw.ai — schema-driven document extraction, an OpenAI-compatible EU LLM gateway, transcription, prompts, datasets, and experiments from your terminal or agentic workflows. Ships as 2kw, backbone, and bb.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|