@agent-finops/core 0.2.2 → 0.4.0

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.
@@ -27,6 +27,12 @@ export type DetectedPlan = {
27
27
  /** Human-readable plan label; falls back to the raw local identifier. */
28
28
  planLabel: string;
29
29
  billing: "subscription" | "api_key" | "unknown";
30
+ /**
31
+ * Evidence of plan-limit pressure found in the agent's local config —
32
+ * e.g. Claude Code records when extra-usage credits ran out. This is the
33
+ * difference between "you might hit limits" and "you ARE hitting limits".
34
+ */
35
+ limitSignal?: string;
30
36
  /** Where the detection came from (file or "--plan override"). */
31
37
  source: string;
32
38
  };
@@ -46,12 +46,20 @@ async function detectClaudePlan(configPath) {
46
46
  else {
47
47
  planLabel = organizationType ?? rateLimitTier ?? "unknown";
48
48
  }
49
+ // Claude Code records why extra usage is unavailable; "out_of_credits"
50
+ // means the user already exhausted their overage pool — hard evidence of
51
+ // limit pressure, not a guess.
52
+ const extraUsageReason = isRecord(config) ? stringOf(config.cachedExtraUsageDisabledReason) : undefined;
53
+ const limitSignal = extraUsageReason === "out_of_credits"
54
+ ? "extra-usage credits exhausted"
55
+ : undefined;
49
56
  return {
50
57
  agent: "claude-code",
51
58
  provider: "anthropic",
52
59
  planId,
53
60
  planLabel,
54
61
  billing: billingType === "stripe_subscription" ? "subscription" : billingType ? "unknown" : "unknown",
62
+ limitSignal,
55
63
  source: configPath
56
64
  };
57
65
  }
package/dist/planMath.js CHANGED
@@ -59,10 +59,17 @@ export function computePlanChecks(records, detectedPlans = []) {
59
59
  (effectiveSavings ? `, ~$${effectiveSavings.toFixed(2)}/mo cheaper than paying per token.` : `.`);
60
60
  if (monthly > detectedKnown.coversUpToUsd) {
61
61
  const nextTier = subscriptionPlans.find((plan) => plan.agent === agent && plan.coversUpToUsd > detectedKnown.coversUpToUsd);
62
+ // A local limit signal upgrades "might hit limits" to hard evidence.
63
+ const evidence = detected?.limitSignal
64
+ ? `your local config shows ${detected.limitSignal} — you ARE hitting your plan's limits`
65
+ : `if you're hitting rate limits`;
62
66
  upgradeHint = nextTier
63
- ? `usage runs past what ${detectedKnown.name} typically covers (~$${detectedKnown.coversUpToUsd}/mo) — if you're hitting rate limits, ${nextTier.name} ($${nextTier.monthlyUsd}/mo) is the next tier; trimming context (below) buys headroom without upgrading.`
67
+ ? `usage runs past what ${detectedKnown.name} typically covers (~$${detectedKnown.coversUpToUsd}/mo); ${evidence}: ${nextTier.name} ($${nextTier.monthlyUsd}/mo) is the next tier; trimming context (below) buys headroom without upgrading.`
64
68
  : `usage runs past what ${detectedKnown.name} typically covers (~$${detectedKnown.coversUpToUsd}/mo) — trimming context (below) is the main headroom lever.`;
65
69
  }
70
+ else if (detected?.limitSignal) {
71
+ upgradeHint = `your local config shows ${detected.limitSignal} — you're hitting your plan's limits; trimming context (below) buys headroom without upgrading.`;
72
+ }
66
73
  }
67
74
  else if (detected) {
68
75
  // Detected a plan we can't price (e.g. an unrecognized tier): state the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-finops/core",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",