pi-kimi-keepalive 0.3.4 → 0.3.5
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 +1 -1
- package/src/index.ts +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-kimi-keepalive",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Prompt-cache keepalive for Kimi (kimi-coding) sessions in the Pi coding agent. Replays the last real provider request while idle so the automatic prefix cache never expires.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/index.ts
CHANGED
|
@@ -51,6 +51,18 @@ import {
|
|
|
51
51
|
|
|
52
52
|
const STATE_DIR = join(homedir(), ".pi", "cache-keepalive");
|
|
53
53
|
const STATE_FILE = join(STATE_DIR, "state.json");
|
|
54
|
+
|
|
55
|
+
/** Package version, read from the package.json that ships this extension. */
|
|
56
|
+
function ownVersion(): string {
|
|
57
|
+
try {
|
|
58
|
+
const pkg = JSON.parse(
|
|
59
|
+
readFileSync(new URL("../../package.json", import.meta.url), "utf8"),
|
|
60
|
+
) as { version?: unknown };
|
|
61
|
+
return typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
62
|
+
} catch {
|
|
63
|
+
return "unknown";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
54
66
|
/** Live OAuth state; resolved lazily so tests can redirect it via PI_AGENT_DIR. */
|
|
55
67
|
function authFile(): string {
|
|
56
68
|
return join(process.env.PI_AGENT_DIR ?? join(homedir(), ".pi", "agent"), "auth.json");
|
|
@@ -717,7 +729,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
717
729
|
const savings = hasPricing(capture?.cost) ? formatUsd(stats.savedUsd) : "n/a (no price data)";
|
|
718
730
|
ctx.ui.setStatus("cache-keepalive", `♥ ${state}`);
|
|
719
731
|
ctx.ui.setWidget("cache-keepalive", [
|
|
720
|
-
|
|
732
|
+
`pi-kimi-keepalive v${ownVersion()}`,
|
|
721
733
|
` state: ${state}`,
|
|
722
734
|
` probes: ${stats.probes} sent · ${stats.hits} hits · ${stats.misses} misses · ${stats.errors} errors`,
|
|
723
735
|
` est.: saved ${savings} · probe spend ${formatUsd(stats.spendUsd)} · cap ${config.spendCapUsd === null ? "none" : formatUsd(config.spendCapUsd)}`,
|
|
@@ -740,7 +752,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
740
752
|
? `${capture.provider} (${capture.api ?? "unknown api"}) @ ${capture.baseUrl}`
|
|
741
753
|
: "none yet — probes start after your first real turn";
|
|
742
754
|
return [
|
|
743
|
-
|
|
755
|
+
`pi-kimi-keepalive v${ownVersion()}`,
|
|
744
756
|
` state: ${config.enabled ? "on" : "off"}${pausedReason ? ` (paused: ${pausedReason})` : ""}`,
|
|
745
757
|
` capture: ${route}`,
|
|
746
758
|
` mode: ${config.mode}${config.mode === "smart" ? ` · cadence ${formatDuration(config.intervalMs)}${lastProbeInputTokens > SMART_MAX_CONTEXT_TOKENS ? ` · context ${lastProbeInputTokens.toLocaleString()} > cap, frozen at floor` : ""}` : " (fixed via interval=)"}`,
|