aibroker 0.47.0 → 0.47.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.
@@ -42,7 +42,28 @@ const cfg = readJson(CONFIG);
42
42
  if (!cfg || cfg.enabled === false) process.exit(0);
43
43
 
44
44
  const ceiling = typeof cfg.ceilingPercent === "number" ? cfg.ceilingPercent : 96;
45
- const pct = readJson(ADVISOR)?.weeklyBudgetPercent;
45
+
46
+ /*
47
+ * The measured figure first, the transcribed one only if there is nothing else.
48
+ *
49
+ * `advisor-mode.json` holds a number a person reads off the status bar and an
50
+ * agent writes down. It does not change when the window resets, so a ceiling
51
+ * reading it goes on refusing every prompt against a budget that is already
52
+ * back to zero — which is exactly what happened: real usage 0%, this hook still
53
+ * quoting 97, until the operator switched it off by hand.
54
+ *
55
+ * The cache is what the status bar itself reads, refreshed from the usage
56
+ * endpoint. This only reads it — a hook runs on every prompt and must not do
57
+ * network calls; the periodic brownout keeps it warm, and it does so precisely
58
+ * when the ceiling is on and the number matters.
59
+ */
60
+ function currentPercent() {
61
+ const live = readJson("/tmp/claude/statusline-usage-cache.json")?.seven_day?.utilization;
62
+ if (typeof live === "number") return live;
63
+ return readJson(ADVISOR)?.weeklyBudgetPercent;
64
+ }
65
+
66
+ const pct = currentPercent();
46
67
 
47
68
  // An unreadable or missing percentage is not evidence of being under the
48
69
  // ceiling, but it is not evidence of being over it either, and refusing every
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aibroker",
3
- "version": "0.47.0",
3
+ "version": "0.47.1",
4
4
  "description": "Platform-agnostic AI message broker — routes between user channels and AI backends",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",