johns-harness 2026.10.27 → 2026.11.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 2026.11.2
4
+
5
+ - **Subscription reset times in `/status` and `session_status` (Family 93):** Claude and Codex OAuth profiles now show percent used, absolute reset time with timezone, and a relative countdown. The active provider is first; the other configured subscription stays visible too. Profile selection respects the last-served account, explicit overrides and normal auth order. Paid API fallback diagnostics are unchanged, with no subscription quota attributed to an API-key profile.
6
+ - **Real provider windows, not assumptions:** Anthropic `five_hour`/`seven_day` resets use the endpoint's ISO timestamps. Codex derives the window label from its reported duration, including weekly-primary-only accounts; absent 5h/secondary windows and null resets are not invented. Plan names are not guessed.
7
+ - **Cheap and bounded:** read-only quota endpoints, two-minute account/profile/credential-scoped cache, shared in-flight requests, bounded timeout (including response body), cached redacted errors and `Retry-After`. No model calls, extra usage or paid inference probes.
8
+ - **Verification:** real authenticated usage GETs from native `~/.johnness` returned 200 for both providers; endpoint shapes, timezone/DST, caching, errors, exact patch replay and all twenty status entrypoints are regression-tested. Legacy `~/.openclaw` state is not the active login store.
9
+ - **Upgrade:** run `/update`. Rollback: `npm i -g johns-harness@2026.10.27`. No live gateway restart or global install is part of publication.
10
+
3
11
  ## 2026.10.27
4
12
 
5
13
  - **GPT-6.1 Terra** (`gpt-6.1-terra`) is available on native OpenAI Responses and the Codex subscription. Native: 1,050,000 context, 922,000 maximum input, 128,000 output; text/image in, text out, June 1, 2026 cutoff. Codex: 500,000 context from the exact official slug (optional max 872,000 is not the default), 128,000 output, zero subscription costs.
@@ -1,3 +1,5 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93 dist/compact-B247y5Qt.js
2
+ import { loadSubscriptionStatus } from "./subscription-usage.js";
1
3
  import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "./anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
4
  import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "./usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/compact-B247y5Qt.js
3
5
  import { importOptional66 } from "./optional-module.js";
@@ -36814,13 +36816,18 @@ async function buildStatusReply(params) {
36814
36816
  const statusAgentDir = resolveAgentDir(cfg, statusAgentId);
36815
36817
  const currentUsageProvider = (() => {
36816
36818
  try {
36817
- return resolveUsageProviderId(provider);
36819
+ return resolveUsageProviderId(sessionEntry?.modelProvider || provider);
36818
36820
  } catch {
36819
36821
  return;
36820
36822
  }
36821
36823
  })();
36822
36824
  let usageLine = null;
36823
- if (currentUsageProvider) try {
36825
+ if (currentUsageProvider === "anthropic" || currentUsageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
36826
+ provider: currentUsageProvider, cfg, sessionEntry, agentDir: statusAgentDir,
36827
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
36828
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
36829
+ });
36830
+ else if (currentUsageProvider) try {
36824
36831
  const usageEntry = (await loadProviderUsageSummary({
36825
36832
  timeoutMs: 3500,
36826
36833
  providers: [currentUsageProvider],
@@ -52078,7 +52085,7 @@ function createSessionStatusTool(opts) {
52078
52085
  return {
52079
52086
  label: "Session Status",
52080
52087
  name: "session_status",
52081
- description: "Show a /status-equivalent session status card (usage + time + cost when available). Use for model-use questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
52088
+ description: "Show a /status-equivalent session status card (usage + subscription limit reset times + time + cost when available). Use for model-use and subscription reset questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
52082
52089
  parameters: SessionStatusToolSchema,
52083
52090
  execute: async (_toolCallId, args) => {
52084
52091
  const params = args;
@@ -52163,9 +52170,14 @@ function createSessionStatusTool(opts) {
52163
52170
  }
52164
52171
  const agentDir = resolveAgentDir(cfg, agentId);
52165
52172
  const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider;
52166
- const usageProvider = resolveUsageProviderId(providerForCard);
52173
+ const usageProvider = resolveUsageProviderId(resolved.entry.modelProvider || providerForCard);
52167
52174
  let usageLine;
52168
- if (usageProvider) try {
52175
+ if (usageProvider === "anthropic" || usageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
52176
+ provider: usageProvider, cfg, sessionEntry: resolved.entry, agentDir,
52177
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
52178
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
52179
+ });
52180
+ else if (usageProvider) try {
52169
52181
  const snapshot = (await loadProviderUsageSummary({
52170
52182
  timeoutMs: 3500,
52171
52183
  providers: [usageProvider],
@@ -1,3 +1,5 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93 dist/pi-embedded-C6ITuRXf.js
2
+ import { loadSubscriptionStatus } from "./subscription-usage.js";
1
3
  import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "./anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
4
  import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "./usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/pi-embedded-C6ITuRXf.js
3
5
  import { importOptional66 } from "./optional-module.js";
@@ -28827,13 +28829,18 @@ async function buildStatusReply(params) {
28827
28829
  const statusAgentDir = resolveAgentDir(cfg, statusAgentId);
28828
28830
  const currentUsageProvider = (() => {
28829
28831
  try {
28830
- return resolveUsageProviderId(provider);
28832
+ return resolveUsageProviderId(sessionEntry?.modelProvider || provider);
28831
28833
  } catch {
28832
28834
  return;
28833
28835
  }
28834
28836
  })();
28835
28837
  let usageLine = null;
28836
- if (currentUsageProvider) try {
28838
+ if (currentUsageProvider === "anthropic" || currentUsageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
28839
+ provider: currentUsageProvider, cfg, sessionEntry, agentDir: statusAgentDir,
28840
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
28841
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
28842
+ });
28843
+ else if (currentUsageProvider) try {
28837
28844
  const usageEntry = (await loadProviderUsageSummary({
28838
28845
  timeoutMs: 3500,
28839
28846
  providers: [currentUsageProvider],
@@ -45691,7 +45698,7 @@ function createSessionStatusTool(opts) {
45691
45698
  return {
45692
45699
  label: "Session Status",
45693
45700
  name: "session_status",
45694
- description: "Show a /status-equivalent session status card (usage + time + cost when available). Use for model-use questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
45701
+ description: "Show a /status-equivalent session status card (usage + subscription limit reset times + time + cost when available). Use for model-use and subscription reset questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
45695
45702
  parameters: SessionStatusToolSchema,
45696
45703
  execute: async (_toolCallId, args) => {
45697
45704
  const params = args;
@@ -45776,9 +45783,14 @@ function createSessionStatusTool(opts) {
45776
45783
  }
45777
45784
  const agentDir = resolveAgentDir(cfg, agentId);
45778
45785
  const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider;
45779
- const usageProvider = resolveUsageProviderId(providerForCard);
45786
+ const usageProvider = resolveUsageProviderId(resolved.entry.modelProvider || providerForCard);
45780
45787
  let usageLine;
45781
- if (usageProvider) try {
45788
+ if (usageProvider === "anthropic" || usageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
45789
+ provider: usageProvider, cfg, sessionEntry: resolved.entry, agentDir,
45790
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
45791
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
45792
+ });
45793
+ else if (usageProvider) try {
45782
45794
  const snapshot = (await loadProviderUsageSummary({
45783
45795
  timeoutMs: 3500,
45784
45796
  providers: [usageProvider],
@@ -1,3 +1,5 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93 dist/pi-embedded-DoQsYfIY.js
2
+ import { loadSubscriptionStatus } from "./subscription-usage.js";
1
3
  import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "./anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
4
  import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "./usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/pi-embedded-DoQsYfIY.js
3
5
  import { importOptional66 } from "./optional-module.js";
@@ -28823,13 +28825,18 @@ async function buildStatusReply(params) {
28823
28825
  const statusAgentDir = resolveAgentDir(cfg, statusAgentId);
28824
28826
  const currentUsageProvider = (() => {
28825
28827
  try {
28826
- return resolveUsageProviderId(provider);
28828
+ return resolveUsageProviderId(sessionEntry?.modelProvider || provider);
28827
28829
  } catch {
28828
28830
  return;
28829
28831
  }
28830
28832
  })();
28831
28833
  let usageLine = null;
28832
- if (currentUsageProvider) try {
28834
+ if (currentUsageProvider === "anthropic" || currentUsageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
28835
+ provider: currentUsageProvider, cfg, sessionEntry, agentDir: statusAgentDir,
28836
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
28837
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
28838
+ });
28839
+ else if (currentUsageProvider) try {
28833
28840
  const usageEntry = (await loadProviderUsageSummary({
28834
28841
  timeoutMs: 3500,
28835
28842
  providers: [currentUsageProvider],
@@ -45687,7 +45694,7 @@ function createSessionStatusTool(opts) {
45687
45694
  return {
45688
45695
  label: "Session Status",
45689
45696
  name: "session_status",
45690
- description: "Show a /status-equivalent session status card (usage + time + cost when available). Use for model-use questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
45697
+ description: "Show a /status-equivalent session status card (usage + subscription limit reset times + time + cost when available). Use for model-use and subscription reset questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
45691
45698
  parameters: SessionStatusToolSchema,
45692
45699
  execute: async (_toolCallId, args) => {
45693
45700
  const params = args;
@@ -45772,9 +45779,14 @@ function createSessionStatusTool(opts) {
45772
45779
  }
45773
45780
  const agentDir = resolveAgentDir(cfg, agentId);
45774
45781
  const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider;
45775
- const usageProvider = resolveUsageProviderId(providerForCard);
45782
+ const usageProvider = resolveUsageProviderId(resolved.entry.modelProvider || providerForCard);
45776
45783
  let usageLine;
45777
- if (usageProvider) try {
45784
+ if (usageProvider === "anthropic" || usageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
45785
+ provider: usageProvider, cfg, sessionEntry: resolved.entry, agentDir,
45786
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
45787
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
45788
+ });
45789
+ else if (usageProvider) try {
45778
45790
  const snapshot = (await loadProviderUsageSummary({
45779
45791
  timeoutMs: 3500,
45780
45792
  providers: [usageProvider],
@@ -1,3 +1,5 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93 dist/plugin-sdk/dispatch-BP0viZiL.js
2
+ import { loadSubscriptionStatus } from "../subscription-usage.js";
1
3
  import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "../anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
4
  import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/dispatch-BP0viZiL.js
3
5
  import { importOptional66 } from "../optional-module.js";
@@ -50529,13 +50531,18 @@ async function buildStatusReply(params) {
50529
50531
  const statusAgentDir = resolveAgentDir(cfg, statusAgentId);
50530
50532
  const currentUsageProvider = (() => {
50531
50533
  try {
50532
- return resolveUsageProviderId(provider);
50534
+ return resolveUsageProviderId(sessionEntry?.modelProvider || provider);
50533
50535
  } catch {
50534
50536
  return;
50535
50537
  }
50536
50538
  })();
50537
50539
  let usageLine = null;
50538
- if (currentUsageProvider) try {
50540
+ if (currentUsageProvider === "anthropic" || currentUsageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
50541
+ provider: currentUsageProvider, cfg, sessionEntry, agentDir: statusAgentDir,
50542
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
50543
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
50544
+ });
50545
+ else if (currentUsageProvider) try {
50539
50546
  const usageEntry = (await loadProviderUsageSummary({
50540
50547
  timeoutMs: 3500,
50541
50548
  providers: [currentUsageProvider],
@@ -71076,7 +71083,7 @@ function createSessionStatusTool(opts) {
71076
71083
  return {
71077
71084
  label: "Session Status",
71078
71085
  name: "session_status",
71079
- description: "Show a /status-equivalent session status card (usage + time + cost when available). Use for model-use questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
71086
+ description: "Show a /status-equivalent session status card (usage + subscription limit reset times + time + cost when available). Use for model-use and subscription reset questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
71080
71087
  parameters: SessionStatusToolSchema,
71081
71088
  execute: async (_toolCallId, args) => {
71082
71089
  const params = args;
@@ -71161,9 +71168,14 @@ function createSessionStatusTool(opts) {
71161
71168
  }
71162
71169
  const agentDir = resolveAgentDir(cfg, agentId);
71163
71170
  const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider;
71164
- const usageProvider = resolveUsageProviderId(providerForCard);
71171
+ const usageProvider = resolveUsageProviderId(resolved.entry.modelProvider || providerForCard);
71165
71172
  let usageLine;
71166
- if (usageProvider) try {
71173
+ if (usageProvider === "anthropic" || usageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
71174
+ provider: usageProvider, cfg, sessionEntry: resolved.entry, agentDir,
71175
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
71176
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
71177
+ });
71178
+ else if (usageProvider) try {
71167
71179
  const snapshot = (await loadProviderUsageSummary({
71168
71180
  timeoutMs: 3500,
71169
71181
  providers: [usageProvider],
@@ -1,3 +1,5 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93 dist/plugin-sdk/dispatch-CQsjmw7g.js
2
+ import { loadSubscriptionStatus } from "../subscription-usage.js";
1
3
  import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "../anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
4
  import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/dispatch-CQsjmw7g.js
3
5
  import { importOptional66 } from "../optional-module.js";
@@ -50529,13 +50531,18 @@ async function buildStatusReply(params) {
50529
50531
  const statusAgentDir = resolveAgentDir(cfg, statusAgentId);
50530
50532
  const currentUsageProvider = (() => {
50531
50533
  try {
50532
- return resolveUsageProviderId(provider);
50534
+ return resolveUsageProviderId(sessionEntry?.modelProvider || provider);
50533
50535
  } catch {
50534
50536
  return;
50535
50537
  }
50536
50538
  })();
50537
50539
  let usageLine = null;
50538
- if (currentUsageProvider) try {
50540
+ if (currentUsageProvider === "anthropic" || currentUsageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
50541
+ provider: currentUsageProvider, cfg, sessionEntry, agentDir: statusAgentDir,
50542
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
50543
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
50544
+ });
50545
+ else if (currentUsageProvider) try {
50539
50546
  const usageEntry = (await loadProviderUsageSummary({
50540
50547
  timeoutMs: 3500,
50541
50548
  providers: [currentUsageProvider],
@@ -71076,7 +71083,7 @@ function createSessionStatusTool(opts) {
71076
71083
  return {
71077
71084
  label: "Session Status",
71078
71085
  name: "session_status",
71079
- description: "Show a /status-equivalent session status card (usage + time + cost when available). Use for model-use questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
71086
+ description: "Show a /status-equivalent session status card (usage + subscription limit reset times + time + cost when available). Use for model-use and subscription reset questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
71080
71087
  parameters: SessionStatusToolSchema,
71081
71088
  execute: async (_toolCallId, args) => {
71082
71089
  const params = args;
@@ -71161,9 +71168,14 @@ function createSessionStatusTool(opts) {
71161
71168
  }
71162
71169
  const agentDir = resolveAgentDir(cfg, agentId);
71163
71170
  const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider;
71164
- const usageProvider = resolveUsageProviderId(providerForCard);
71171
+ const usageProvider = resolveUsageProviderId(resolved.entry.modelProvider || providerForCard);
71165
71172
  let usageLine;
71166
- if (usageProvider) try {
71173
+ if (usageProvider === "anthropic" || usageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
71174
+ provider: usageProvider, cfg, sessionEntry: resolved.entry, agentDir,
71175
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
71176
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
71177
+ });
71178
+ else if (usageProvider) try {
71167
71179
  const snapshot = (await loadProviderUsageSummary({
71168
71180
  timeoutMs: 3500,
71169
71181
  providers: [usageProvider],
@@ -1,3 +1,5 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93 dist/plugin-sdk/dispatch-Cerq29sy.js
2
+ import { loadSubscriptionStatus } from "../subscription-usage.js";
1
3
  import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "../anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
4
  import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/dispatch-Cerq29sy.js
3
5
  import { importOptional66 } from "../optional-module.js";
@@ -50920,13 +50922,18 @@ async function buildStatusReply(params) {
50920
50922
  const statusAgentDir = resolveAgentDir(cfg, statusAgentId);
50921
50923
  const currentUsageProvider = (() => {
50922
50924
  try {
50923
- return resolveUsageProviderId(provider);
50925
+ return resolveUsageProviderId(sessionEntry?.modelProvider || provider);
50924
50926
  } catch {
50925
50927
  return;
50926
50928
  }
50927
50929
  })();
50928
50930
  let usageLine = null;
50929
- if (currentUsageProvider) try {
50931
+ if (currentUsageProvider === "anthropic" || currentUsageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
50932
+ provider: currentUsageProvider, cfg, sessionEntry, agentDir: statusAgentDir,
50933
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
50934
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
50935
+ });
50936
+ else if (currentUsageProvider) try {
50930
50937
  const usageEntry = (await loadProviderUsageSummary({
50931
50938
  timeoutMs: 3500,
50932
50939
  providers: [currentUsageProvider],
@@ -71390,7 +71397,7 @@ function createSessionStatusTool(opts) {
71390
71397
  return {
71391
71398
  label: "Session Status",
71392
71399
  name: "session_status",
71393
- description: "Show a /status-equivalent session status card (usage + time + cost when available). Use for model-use questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
71400
+ description: "Show a /status-equivalent session status card (usage + subscription limit reset times + time + cost when available). Use for model-use and subscription reset questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
71394
71401
  parameters: SessionStatusToolSchema,
71395
71402
  execute: async (_toolCallId, args) => {
71396
71403
  const params = args;
@@ -71475,9 +71482,14 @@ function createSessionStatusTool(opts) {
71475
71482
  }
71476
71483
  const agentDir = resolveAgentDir(cfg, agentId);
71477
71484
  const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider;
71478
- const usageProvider = resolveUsageProviderId(providerForCard);
71485
+ const usageProvider = resolveUsageProviderId(resolved.entry.modelProvider || providerForCard);
71479
71486
  let usageLine;
71480
- if (usageProvider) try {
71487
+ if (usageProvider === "anthropic" || usageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
71488
+ provider: usageProvider, cfg, sessionEntry: resolved.entry, agentDir,
71489
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
71490
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
71491
+ });
71492
+ else if (usageProvider) try {
71481
71493
  const snapshot = (await loadProviderUsageSummary({
71482
71494
  timeoutMs: 3500,
71483
71495
  providers: [usageProvider],
@@ -1,3 +1,5 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93 dist/plugin-sdk/dispatch-Cndjtt0g.js
2
+ import { loadSubscriptionStatus } from "../subscription-usage.js";
1
3
  import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "../anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
4
  import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/dispatch-Cndjtt0g.js
3
5
  import { importOptional66 } from "../optional-module.js";
@@ -50570,13 +50572,18 @@ async function buildStatusReply(params) {
50570
50572
  const statusAgentDir = resolveAgentDir(cfg, statusAgentId);
50571
50573
  const currentUsageProvider = (() => {
50572
50574
  try {
50573
- return resolveUsageProviderId(provider);
50575
+ return resolveUsageProviderId(sessionEntry?.modelProvider || provider);
50574
50576
  } catch {
50575
50577
  return;
50576
50578
  }
50577
50579
  })();
50578
50580
  let usageLine = null;
50579
- if (currentUsageProvider) try {
50581
+ if (currentUsageProvider === "anthropic" || currentUsageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
50582
+ provider: currentUsageProvider, cfg, sessionEntry, agentDir: statusAgentDir,
50583
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
50584
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
50585
+ });
50586
+ else if (currentUsageProvider) try {
50580
50587
  const usageEntry = (await loadProviderUsageSummary({
50581
50588
  timeoutMs: 3500,
50582
50589
  providers: [currentUsageProvider],
@@ -71117,7 +71124,7 @@ function createSessionStatusTool(opts) {
71117
71124
  return {
71118
71125
  label: "Session Status",
71119
71126
  name: "session_status",
71120
- description: "Show a /status-equivalent session status card (usage + time + cost when available). Use for model-use questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
71127
+ description: "Show a /status-equivalent session status card (usage + subscription limit reset times + time + cost when available). Use for model-use and subscription reset questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
71121
71128
  parameters: SessionStatusToolSchema,
71122
71129
  execute: async (_toolCallId, args) => {
71123
71130
  const params = args;
@@ -71202,9 +71209,14 @@ function createSessionStatusTool(opts) {
71202
71209
  }
71203
71210
  const agentDir = resolveAgentDir(cfg, agentId);
71204
71211
  const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider;
71205
- const usageProvider = resolveUsageProviderId(providerForCard);
71212
+ const usageProvider = resolveUsageProviderId(resolved.entry.modelProvider || providerForCard);
71206
71213
  let usageLine;
71207
- if (usageProvider) try {
71214
+ if (usageProvider === "anthropic" || usageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
71215
+ provider: usageProvider, cfg, sessionEntry: resolved.entry, agentDir,
71216
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
71217
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
71218
+ });
71219
+ else if (usageProvider) try {
71208
71220
  const snapshot = (await loadProviderUsageSummary({
71209
71221
  timeoutMs: 3500,
71210
71222
  providers: [usageProvider],
@@ -1,3 +1,5 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93 dist/plugin-sdk/dispatch-UogiJYul.js
2
+ import { loadSubscriptionStatus } from "../subscription-usage.js";
1
3
  import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "../anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
4
  import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/dispatch-UogiJYul.js
3
5
  import { importOptional66 } from "../optional-module.js";
@@ -50529,13 +50531,18 @@ async function buildStatusReply(params) {
50529
50531
  const statusAgentDir = resolveAgentDir(cfg, statusAgentId);
50530
50532
  const currentUsageProvider = (() => {
50531
50533
  try {
50532
- return resolveUsageProviderId(provider);
50534
+ return resolveUsageProviderId(sessionEntry?.modelProvider || provider);
50533
50535
  } catch {
50534
50536
  return;
50535
50537
  }
50536
50538
  })();
50537
50539
  let usageLine = null;
50538
- if (currentUsageProvider) try {
50540
+ if (currentUsageProvider === "anthropic" || currentUsageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
50541
+ provider: currentUsageProvider, cfg, sessionEntry, agentDir: statusAgentDir,
50542
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
50543
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
50544
+ });
50545
+ else if (currentUsageProvider) try {
50539
50546
  const usageEntry = (await loadProviderUsageSummary({
50540
50547
  timeoutMs: 3500,
50541
50548
  providers: [currentUsageProvider],
@@ -71076,7 +71083,7 @@ function createSessionStatusTool(opts) {
71076
71083
  return {
71077
71084
  label: "Session Status",
71078
71085
  name: "session_status",
71079
- description: "Show a /status-equivalent session status card (usage + time + cost when available). Use for model-use questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
71086
+ description: "Show a /status-equivalent session status card (usage + subscription limit reset times + time + cost when available). Use for model-use and subscription reset questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
71080
71087
  parameters: SessionStatusToolSchema,
71081
71088
  execute: async (_toolCallId, args) => {
71082
71089
  const params = args;
@@ -71161,9 +71168,14 @@ function createSessionStatusTool(opts) {
71161
71168
  }
71162
71169
  const agentDir = resolveAgentDir(cfg, agentId);
71163
71170
  const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider;
71164
- const usageProvider = resolveUsageProviderId(providerForCard);
71171
+ const usageProvider = resolveUsageProviderId(resolved.entry.modelProvider || providerForCard);
71165
71172
  let usageLine;
71166
- if (usageProvider) try {
71173
+ if (usageProvider === "anthropic" || usageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
71174
+ provider: usageProvider, cfg, sessionEntry: resolved.entry, agentDir,
71175
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
71176
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
71177
+ });
71178
+ else if (usageProvider) try {
71167
71179
  const snapshot = (await loadProviderUsageSummary({
71168
71180
  timeoutMs: 3500,
71169
71181
  providers: [usageProvider],
@@ -1,3 +1,5 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93 dist/plugin-sdk/reply-DbZnH8-h.js
2
+ import { loadSubscriptionStatus } from "../subscription-usage.js";
1
3
  import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "../anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
4
  import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/reply-DbZnH8-h.js
3
5
  import { importOptional66 } from "../optional-module.js";
@@ -54615,13 +54617,18 @@ async function buildStatusReply(params) {
54615
54617
  const statusAgentDir = resolveAgentDir(cfg, statusAgentId);
54616
54618
  const currentUsageProvider = (() => {
54617
54619
  try {
54618
- return resolveUsageProviderId(provider);
54620
+ return resolveUsageProviderId(sessionEntry?.modelProvider || provider);
54619
54621
  } catch {
54620
54622
  return;
54621
54623
  }
54622
54624
  })();
54623
54625
  let usageLine = null;
54624
- if (currentUsageProvider) try {
54626
+ if (currentUsageProvider === "anthropic" || currentUsageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
54627
+ provider: currentUsageProvider, cfg, sessionEntry, agentDir: statusAgentDir,
54628
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
54629
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
54630
+ });
54631
+ else if (currentUsageProvider) try {
54625
54632
  const usageEntry = (await loadProviderUsageSummary({
54626
54633
  timeoutMs: 3500,
54627
54634
  providers: [currentUsageProvider],
@@ -72748,7 +72755,7 @@ function createSessionStatusTool(opts) {
72748
72755
  return {
72749
72756
  label: "Session Status",
72750
72757
  name: "session_status",
72751
- description: "Show a /status-equivalent session status card (usage + time + cost when available). Use for model-use questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
72758
+ description: "Show a /status-equivalent session status card (usage + subscription limit reset times + time + cost when available). Use for model-use and subscription reset questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
72752
72759
  parameters: SessionStatusToolSchema,
72753
72760
  execute: async (_toolCallId, args) => {
72754
72761
  const params = args;
@@ -72833,9 +72840,14 @@ function createSessionStatusTool(opts) {
72833
72840
  }
72834
72841
  const agentDir = resolveAgentDir(cfg, agentId);
72835
72842
  const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider;
72836
- const usageProvider = resolveUsageProviderId(providerForCard);
72843
+ const usageProvider = resolveUsageProviderId(resolved.entry.modelProvider || providerForCard);
72837
72844
  let usageLine;
72838
- if (usageProvider) try {
72845
+ if (usageProvider === "anthropic" || usageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
72846
+ provider: usageProvider, cfg, sessionEntry: resolved.entry, agentDir,
72847
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
72848
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
72849
+ });
72850
+ else if (usageProvider) try {
72839
72851
  const snapshot = (await loadProviderUsageSummary({
72840
72852
  timeoutMs: 3500,
72841
72853
  providers: [usageProvider],
@@ -1,3 +1,5 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93 dist/reply-C5LKjXcC.js
2
+ import { loadSubscriptionStatus } from "./subscription-usage.js";
1
3
  import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "./anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
4
  import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "./usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/reply-C5LKjXcC.js
3
5
  import { importOptional66 } from "./optional-module.js";
@@ -48338,13 +48340,18 @@ async function buildStatusReply(params) {
48338
48340
  const statusAgentDir = resolveAgentDir(cfg, statusAgentId);
48339
48341
  const currentUsageProvider = (() => {
48340
48342
  try {
48341
- return resolveUsageProviderId(provider);
48343
+ return resolveUsageProviderId(sessionEntry?.modelProvider || provider);
48342
48344
  } catch {
48343
48345
  return;
48344
48346
  }
48345
48347
  })();
48346
48348
  let usageLine = null;
48347
- if (currentUsageProvider) try {
48349
+ if (currentUsageProvider === "anthropic" || currentUsageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
48350
+ provider: currentUsageProvider, cfg, sessionEntry, agentDir: statusAgentDir,
48351
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
48352
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
48353
+ });
48354
+ else if (currentUsageProvider) try {
48348
48355
  const usageEntry = (await loadProviderUsageSummary({
48349
48356
  timeoutMs: 3500,
48350
48357
  providers: [currentUsageProvider],
@@ -64575,7 +64582,7 @@ function createSessionStatusTool(opts) {
64575
64582
  return {
64576
64583
  label: "Session Status",
64577
64584
  name: "session_status",
64578
- description: "Show a /status-equivalent session status card (usage + time + cost when available). Use for model-use questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
64585
+ description: "Show a /status-equivalent session status card (usage + subscription limit reset times + time + cost when available). Use for model-use and subscription reset questions (📊 session_status). Optional: set per-session model override (model=default resets overrides).",
64579
64586
  parameters: SessionStatusToolSchema,
64580
64587
  execute: async (_toolCallId, args) => {
64581
64588
  const params = args;
@@ -64660,9 +64667,14 @@ function createSessionStatusTool(opts) {
64660
64667
  }
64661
64668
  const agentDir = resolveAgentDir(cfg, agentId);
64662
64669
  const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider;
64663
- const usageProvider = resolveUsageProviderId(providerForCard);
64670
+ const usageProvider = resolveUsageProviderId(resolved.entry.modelProvider || providerForCard);
64664
64671
  let usageLine;
64665
- if (usageProvider) try {
64672
+ if (usageProvider === "anthropic" || usageProvider === "openai-codex") usageLine = await loadSubscriptionStatus({
64673
+ provider: usageProvider, cfg, sessionEntry: resolved.entry, agentDir,
64674
+ timeZone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone),
64675
+ ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile
64676
+ });
64677
+ else if (usageProvider) try {
64666
64678
  const snapshot = (await loadProviderUsageSummary({
64667
64679
  timeoutMs: 3500,
64668
64680
  providers: [usageProvider],
@@ -0,0 +1,150 @@
1
+ // JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93
2
+ // Read-only quota endpoints, never inference: /status cannot consume model tokens.
3
+ import { createHash } from 'node:crypto';
4
+
5
+ const TTL_MS = 120_000;
6
+ const MAX_ENTRIES = 256;
7
+ const PROVIDERS = { anthropic: 'Claude', 'openai-codex': 'Codex' };
8
+ const finite = value => typeof value === 'number' && Number.isFinite(value) ? value : undefined;
9
+ const percent = value => finite(value) === undefined ? undefined : Math.min(100, Math.max(0, value));
10
+ const epoch = value => finite(value) !== undefined && value > 0 && value * 1000 <= 8.64e15 ? value * 1000 : undefined;
11
+ const iso = value => typeof value === 'string' && Number.isFinite(Date.parse(value)) ? Date.parse(value) : undefined;
12
+
13
+ export function parseClaudeUsage(data) {
14
+ const windows = [];
15
+ for (const [key, label] of [['five_hour', '5h'], ['seven_day', 'week']]) {
16
+ const window = data?.[key];
17
+ const usedPercent = percent(window?.utilization);
18
+ if (usedPercent === undefined) continue;
19
+ windows.push({ label, usedPercent, resetAt: iso(window.resets_at) });
20
+ }
21
+ return windows;
22
+ }
23
+
24
+ export function parseCodexUsage(data, now = Date.now()) {
25
+ const windows = [];
26
+ for (const key of ['primary_window', 'secondary_window']) {
27
+ const window = data?.rate_limit?.[key];
28
+ const usedPercent = percent(window?.used_percent);
29
+ if (usedPercent === undefined) continue;
30
+ const seconds = finite(window.limit_window_seconds);
31
+ // Window position is not duration. Live Pro accounts can have only a weekly primary.
32
+ const label = seconds === 604800 ? 'week' : seconds > 0 ? (seconds % 3600 === 0 ? `${seconds / 3600}h` : `${Math.round(seconds / 60)}m`) : (key === 'primary_window' ? 'primary' : 'secondary');
33
+ const after = finite(window.reset_after_seconds);
34
+ const resetAt = epoch(window.reset_at) ?? (after !== undefined && after >= 0 && now + after * 1000 <= 8.64e15 ? now + after * 1000 : undefined);
35
+ windows.push({ label, usedPercent, resetAt });
36
+ }
37
+ return windows;
38
+ }
39
+
40
+ function relativeReset(resetAt, now) {
41
+ const mins = Math.ceil((resetAt - now) / 60000);
42
+ if (mins <= 0) return 'now';
43
+ if (mins < 60) return `in ${mins}m`;
44
+ const hours = Math.floor(mins / 60), remainder = mins % 60;
45
+ if (hours < 24) return `in ${hours}h${remainder ? ` ${remainder}m` : ''}`;
46
+ return `in ${Math.floor(hours / 24)}d${hours % 24 ? ` ${hours % 24}h` : ''}`;
47
+ }
48
+
49
+ export function formatSubscriptionUsage(snapshot, { timeZone = 'UTC', now = Date.now() } = {}) {
50
+ if (!snapshot || !PROVIDERS[snapshot.provider]) return null;
51
+ try { new Intl.DateTimeFormat('en-US', { timeZone }); } catch { timeZone = 'UTC'; }
52
+ const name = PROVIDERS[snapshot.provider]; // Do not guess Max/Pro/Team from an OAuth token.
53
+ const profile = snapshot.profileId ? ` (${String(snapshot.profileId).replace(/[\r\n\t]/g, ' ').slice(0, 100)})` : '';
54
+ if (snapshot.error) return `${name}${profile}: usage unavailable (${snapshot.error})`;
55
+ if (!snapshot.windows?.length) return `${name}${profile}: usage unavailable (no windows reported)`;
56
+ const dateKey = value => new Intl.DateTimeFormat('en-US', { timeZone, year: 'numeric', month: '2-digit', day: '2-digit' }).format(value);
57
+ return `${name}${profile}: ` + snapshot.windows.map(window => {
58
+ let reset = '';
59
+ if (finite(window.resetAt) !== undefined) {
60
+ const weekday = window.label === 'week' || dateKey(window.resetAt) !== dateKey(now) ? 'short' : undefined;
61
+ const at = new Intl.DateTimeFormat('en-US', { timeZone, weekday, hour: 'numeric', minute: '2-digit', hour12: true, timeZoneName: 'short' }).format(window.resetAt).replace(/^([A-Za-z]{3}), /, '$1 ');
62
+ reset = ` (resets ${at}, ${relativeReset(window.resetAt, now)})`;
63
+ }
64
+ return `${window.label} ${window.usedPercent.toFixed(0)}% used${reset}`;
65
+ }).join(' · ');
66
+ }
67
+
68
+ export function createSubscriptionUsageClient({ clock = Date.now, ttlMs = TTL_MS } = {}) {
69
+ const cache = new Map();
70
+ return async function fetchUsage({ provider, token, accountId, scope = '', profileId, fetchFn = globalThis.fetch, timeoutMs = 3500 }) {
71
+ if (!PROVIDERS[provider] || !token) return null;
72
+ // Hash credentials; no raw token, account ID, response body or exception is retained/logged.
73
+ const key = createHash('sha256').update(JSON.stringify([provider, scope, profileId, accountId, token])).digest('hex');
74
+ const now = clock();
75
+ const cached = cache.get(key);
76
+ if (cached && (cached.pending || cached.expires > now)) return cached.pending ?? structuredClone(cached.value);
77
+ const entry = {};
78
+ cache.delete(key);
79
+ cache.set(key, entry);
80
+ while (cache.size > MAX_ENTRIES) cache.delete(cache.keys().next().value);
81
+ entry.pending = (async () => {
82
+ const controller = new AbortController();
83
+ let timer;
84
+ const failure = error => ({ provider, profileId, windows: [], error });
85
+ // The deadline covers body decoding too; never show old utilization after a failed refresh.
86
+ const deadline = new Promise(resolve => { timer = setTimeout(() => { controller.abort(); resolve(failure('timeout')); }, timeoutMs); });
87
+ const work = (async () => {
88
+ try {
89
+ const claude = provider === 'anthropic';
90
+ const headers = { Authorization: `Bearer ${token}`, Accept: 'application/json' };
91
+ if (claude) headers['anthropic-beta'] = 'oauth-2025-04-20';
92
+ else if (accountId) headers['ChatGPT-Account-Id'] = accountId;
93
+ const response = await fetchFn(claude ? 'https://api.anthropic.com/api/oauth/usage' : 'https://chatgpt.com/backend-api/wham/usage', { method: 'GET', headers, signal: controller.signal });
94
+ if (response.status === 429) {
95
+ const retry = response.headers?.get?.('retry-after');
96
+ const seconds = retry?.trim() ? Number(retry) : NaN;
97
+ const delay = Number.isFinite(seconds) ? seconds * 1000 : Date.parse(retry) - clock();
98
+ if (Number.isFinite(delay) && delay > 0) entry.retryAfterMs = delay;
99
+ }
100
+ if (!response.ok) return failure(response.status === 401 ? 'sign in again' : response.status === 403 ? 'access denied' : response.status === 429 ? 'rate limited' : `HTTP ${response.status}`);
101
+ const data = await response.json();
102
+ return { provider, profileId, windows: claude ? parseClaudeUsage(data) : parseCodexUsage(data, clock()) };
103
+ } catch { return failure(controller.signal.aborted ? 'timeout' : 'request failed'); }
104
+ })();
105
+ const value = await Promise.race([work, deadline]);
106
+ clearTimeout(timer);
107
+ entry.value = value;
108
+ entry.expires = clock() + Math.max(ttlMs, entry.retryAfterMs ?? 0); // Cache failures too, so repeated /status never hammers a provider.
109
+ delete entry.pending;
110
+ return structuredClone(value);
111
+ })();
112
+ return entry.pending;
113
+ };
114
+ }
115
+
116
+ // All ten bundled entrypoints share one bounded cache and single-flight requests.
117
+ const CLIENT = Symbol.for('johnness.subscription-usage.93');
118
+ const client = globalThis[CLIENT] ??= createSubscriptionUsageClient();
119
+
120
+ async function loadSubscriptionProfileStatus({ provider, cfg, sessionEntry, agentDir, timeZone, ensureAuthProfileStore, resolveAuthProfileOrder, resolveApiKeyForProfile, fetchUsage = client }) {
121
+ if (!PROVIDERS[provider]) return null;
122
+ try {
123
+ const store = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false });
124
+ const served = sessionEntry?.authProfileServed;
125
+ const override = sessionEntry?.authProfileOverride;
126
+ const candidates = [served, override, ...resolveAuthProfileOrder({ cfg, store, provider, preferredProfile: override })].filter(Boolean);
127
+ // The last-served account wins. Do not show a different account after its profile is removed.
128
+ if (served && !store.profiles[served]) return null;
129
+ const profileId = candidates.find(id => store.profiles[id]?.provider === provider);
130
+ const credential = store.profiles[profileId];
131
+ // API fallback keeps its existing diagnostic line; no subscription quota is attributed to it.
132
+ if (credential?.type !== 'oauth') return null;
133
+ let resolved;
134
+ try { resolved = await resolveApiKeyForProfile({ cfg, store, profileId, agentDir }); } catch {}
135
+ if (!resolved?.apiKey) return `📊 ${formatSubscriptionUsage({ provider, profileId, error: 'credentials unavailable' }, { timeZone })}`;
136
+ const snapshot = await fetchUsage({ provider, token: resolved.apiKey, accountId: credential.accountId, scope: agentDir ?? '', profileId });
137
+ const formatted = formatSubscriptionUsage(snapshot, { timeZone });
138
+ return formatted ? `📊 ${formatted}` : null;
139
+ } catch { return null; }
140
+ }
141
+
142
+ // Show the preferred account for each configured subscription provider, active provider first.
143
+ // This still answers "when does Claude reset?" while the session is running on Codex.
144
+ // Within a provider, the last-served/explicit profile wins; an API fallback never gets a quota line.
145
+ export async function loadSubscriptionStatus(params) {
146
+ if (!PROVIDERS[params.provider]) return null;
147
+ const providers = [params.provider, ...Object.keys(PROVIDERS).filter(p => p !== params.provider)];
148
+ const lines = await Promise.all(providers.map(provider => loadSubscriptionProfileStatus({ ...params, provider })));
149
+ return lines.filter(Boolean).join('\n') || null;
150
+ }
package/docs/PATCHES.md CHANGED
@@ -17,7 +17,7 @@ they predate ~2026-06-06).
17
17
 
18
18
  ## Index
19
19
 
20
- Current addition: [91 - Exact API usage billing](#91---exact-api-usage-billing-2026-10-21).
20
+ Current addition: [93 - Subscription quota reset times](#family-93-subscription-quota-reset-times-2026-11-02).
21
21
 
22
22
  Family 01 is retired. Families 02 through 41, 43 through 81, including the 65.1 amendment, are live on `main`; the `latest` and `extended` release lines converged at 2026.9.24. Family 42 is omitted; native Codex OAuth ownership is Family 58.
23
23
 
@@ -3121,3 +3121,26 @@ now says why.
3121
3121
  ### Family 83 catalog update: GPT-6.1 Terra (2026-10-27, 2026.10.27)
3122
3122
 
3123
3123
  Only the two Terra cards and `terra56` are added to models/models.json. The existing latest-Terra rule moves `terra`; generated catalogs, aliases and xhigh/wire rules follow models-sync. No per-model replay script or adapter change is needed. The card, pricing tiers/cache retention, exact immutable Codex source, checked date, live subscription proof and rollback are in CHANGELOG 2026.10.27 and the master notes. Native window 1,050,000 / max input 922,000 / output 128,000; exact Codex context_window 500,000 (not an assumed 272K or optional max872K). Standard base input/output/read/write30m USD/MTok 1/5/0.05/1.25; 12h write2.50; >272K rates2/7.50/0.10/2.50/5. Batch/Flex50%, Fast2x, regional+10%; flat estimates only cover base Standard30m. Text/image in, text out, cutoff2026-06-01. API default medium; Codex UI default low; none through max, no minimal; drop sampling except explicit none. Tools require Responses. One bounded actual subscription-adapter call returned HTTP200 with a parsed function call and zero cost; native paid inference untested by billing policy. Fresh public source: https://github.com/openai/codex/blob/b6ad8ea1fcd5562a7d3003887930be7d84824307/codex-rs/models-manager/models.json . Sources/card/pricing/guide checked 2026-10-27. No live install, auth/config write or gateway restart.
3124
+
3125
+
3126
+ ## Family 93: subscription quota reset times (2026-11-02)
3127
+
3128
+ Marker: `JOHNNESS_PATCH_SUBSCRIPTION_USAGE_93`. Source:
3129
+ `patches/subscription-usage-93/subscription-usage.js`, exact manifest
3130
+ `changes.json`, replay `scripts/patch-subscription-usage-93.py`.
3131
+
3132
+ All ten reply/compact/embedded/SDK bundles wire both `/status` and `session_status`
3133
+ to a shared helper. Native OAuth auth resolution supplies the correct account;
3134
+ API fallback retains Family 92's explanation and gets no invented quota. Claude
3135
+ and Codex read-only usage endpoints are parsed defensively, never inferred from
3136
+ response-header status or an assumed 5h primary window. A two-minute bounded,
3137
+ process-shared, single-flight cache keys by hashed agent/profile/account/token
3138
+ identity. Timeouts cover decoding, errors never leak provider bodies, and 429
3139
+ Retry-After delays further reads. Times use configured user timezone with DST and
3140
+ relative countdowns. No inference probe is needed or performed.
3141
+
3142
+ Tests execute both status entrypoints in all ten copies, exercise real observed
3143
+ endpoint shapes and alternative valid windows, account isolation, fallback,
3144
+ malformed payloads, cache expiry/coalescing, bounded failures and exact preflighted
3145
+ reconstruction. Historical-family byte comparisons stay strict via the exact
3146
+ normalization/re-layering helpers. See the changelog and usage tracking docs.
@@ -26,3 +26,12 @@ Notes:
26
26
  - Update info surfaces in the Overview; if an update is available, status prints a hint to run `johnness update` (see [Updating](/install/updating)).
27
27
  - Read-only status surfaces (`status`, `status --json`, `status --all`) resolve supported SecretRefs for their targeted config paths when possible.
28
28
  - If a supported channel SecretRef is configured but unavailable in the current command path, status stays read-only and reports degraded output instead of crashing. Human output shows warnings such as “configured token unavailable in this command path”, and JSON output includes `secretDiagnostics`.
29
+
30
+ ## Chat status card
31
+
32
+ The chat `/status` command and `session_status` tool also show Claude/Codex
33
+ subscription usage by OAuth profile, including reset times in your configured
34
+ `agents.defaults.userTimezone`. Quota GETs are cached for two minutes; status never
35
+ makes an inference call. See [Usage tracking](/concepts/usage-tracking) for account
36
+ selection, absent windows, API fallback and error behavior. `johnness status --usage`
37
+ continues to provide the separate CLI provider report.
@@ -15,7 +15,7 @@ title: "Usage Tracking"
15
15
 
16
16
  ## Where it shows up
17
17
 
18
- - `/status` in chats: emoji‑rich status card with session tokens + estimated cost (API key only). Provider usage shows for the **current model provider** when available.
18
+ - `/status` in chats: emoji‑rich status card with session tokens + estimated cost (API key only). Claude and Codex subscription quotas show by profile, with the active provider first (other provider usage remains scoped to the current model).
19
19
  - `/usage off|tokens|full` in chats: per-response usage footer (OAuth shows tokens only).
20
20
  - `/usage cost` in chats: local cost summary aggregated from Johnness session logs.
21
21
  - CLI: `johnness status --usage` prints a full per-provider breakdown.
@@ -33,3 +33,35 @@ title: "Usage Tracking"
33
33
  - **z.ai**: API key via env/config/auth store.
34
34
 
35
35
  Usage is hidden if no matching OAuth/API credentials exist.
36
+
37
+ ## Subscription reset times (`/status` and `session_status`)
38
+
39
+ Claude and Codex OAuth profiles show **percent used**, the provider-reported reset
40
+ clock time in `agents.defaults.userTimezone`, and a relative countdown. The zone is
41
+ printed explicitly (for example PST/PDT); daylight-saving changes are respected.
42
+ Example (illustrative, not a fixed weekly schedule):
43
+
44
+ ```text
45
+ 📊 Claude (anthropic:subscription): 5h 42% used (resets 3:10 PM PST, in 1h 10m) · week 61% used (resets Thu 9:00 AM PST, in 2d 19h)
46
+ 📊 Codex (openai-codex:default): 5h 10% used (resets 4:05 PM PST, in 2h 5m) · week 23% used (resets Sun 2:00 AM PST, in 5d 12h)
47
+ ```
48
+
49
+ - One profile per configured subscription provider: last-served profile first,
50
+ then explicit override, then the normal auth-profile order. This keeps Claude's
51
+ reset visible while a session runs on Codex, without mixing accounts.
52
+ - An API-key or token-only profile gets no subscription line. The existing paid
53
+ API fallback reason remains unchanged. Plan names are not inferred from tokens.
54
+ - Only reported windows are shown. Codex can report a weekly **primary** window
55
+ and no 5-hour window. A null reset (for example an unused Claude 5-hour window)
56
+ shows utilization without inventing a reset time. Weekly resets are per account,
57
+ not a hard-coded weekday.
58
+ - Read-only GETs to Anthropic `/api/oauth/usage` and ChatGPT `/backend-api/wham/usage`
59
+ are cached in memory for two minutes, scoped by agent/profile/account/credential
60
+ generation, with concurrent lookups coalesced. **No inference/model probe** is
61
+ made, and no model tokens are consumed. Expired OAuth credentials use the existing
62
+ ownership-aware auth resolver. Restarts clear the quota cache.
63
+ - Endpoint errors show `usage unavailable`, never a fabricated 0% or stale success.
64
+ Errors are briefly cached too, and HTTP 429 `Retry-After` is honored. Raw endpoint
65
+ messages, tokens and account IDs are not logged or retained in the quota cache.
66
+ - The installed native harness uses `~/.johnness` by default. A leftover
67
+ `~/.openclaw` auth store is not evidence of the active installation's login state.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "johns-harness",
3
- "version": "2026.10.27",
3
+ "version": "2026.11.2",
4
4
  "description": "John's Harness: a production agent harness that runs autonomous coding agents as one cooperative swarm.",
5
5
  "keywords": [
6
6
  "ai-agents",