@yalieny/pi-better-cost-display-footer 2.0.1 → 2.1.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.
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
//
|
|
4
4
|
// 配置驱动:读取 <configDir>/pi-better-cost-display-footer.json(configDir 默认 ~/.pi/agent,
|
|
5
5
|
// 可用 PI_CODING_AGENT_DIR 覆盖)。配置文件不存在时自动生成默认配置(内置 DeepSeek 官方价目)落盘。
|
|
6
|
-
// 在 session_start
|
|
7
|
-
//
|
|
6
|
+
// 在 session_start、每次发送消息(input 事件)和每次 LLM 调用前(turn_start,含工具循环内
|
|
7
|
+
// 的每次调用)按各 provider 的 tierFn 脚本函数计算当前档位并重注册其 cost,对齐按调用时刻计费。
|
|
8
|
+
// effectiveFrom(含)之前不做任何事。
|
|
8
9
|
//
|
|
9
10
|
// 档位 = 任意字符串 id(如 "peak" / "flat" / "valley" / "sharp"),不绑定峰值/谷值语义:
|
|
10
11
|
// {
|
|
@@ -665,7 +666,14 @@ export default function (pi: ExtensionAPI): void {
|
|
|
665
666
|
installCustomFooter(ctx);
|
|
666
667
|
apply(pi, ctx);
|
|
667
668
|
});
|
|
669
|
+
pi.on("session_shutdown", () => {
|
|
670
|
+
// Pi invalidates session-bound ctx before the next footer render.
|
|
671
|
+
activeCtx = null;
|
|
672
|
+
});
|
|
668
673
|
pi.on("input", (_e, ctx) => apply(pi, ctx));
|
|
669
674
|
// 切换模型时刷新档位标签(深色/深绿 ⇄ 其他模型)
|
|
670
675
|
pi.on("model_select", (_e, ctx) => apply(pi, ctx));
|
|
676
|
+
// 每个 LLM 调用(含工具循环内的每次调用)开始前按调用时刻重算档位,对齐按调用点计费;
|
|
677
|
+
// lastAppliedKey 守卫保证档位未变时零开销。
|
|
678
|
+
pi.on("turn_start", (_e, ctx) => apply(pi, ctx));
|
|
671
679
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yalieny/pi-better-cost-display-footer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "pi extension: scriptable peak/off-peak tier rules per provider with an enhanced footer (tier label, cache-hit-rate precision, custom currency symbol)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|