remote-codex 0.11.32 → 0.11.33

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.
@@ -12502,6 +12502,7 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12502
12502
  sessionApprovalModes = /* @__PURE__ */ new Map();
12503
12503
  liveUserPrompts = /* @__PURE__ */ new Map();
12504
12504
  subscriptionUsageWindows = /* @__PURE__ */ new Map();
12505
+ subscriptionAuthKind = "unknown";
12505
12506
  subscriptionUsageObservedAt = null;
12506
12507
  clientApp;
12507
12508
  sdkLoadError = null;
@@ -12519,7 +12520,7 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12519
12520
  }));
12520
12521
  return {
12521
12522
  provider: "claude",
12522
- authKind: windows.length > 0 ? "subscription" : "unknown",
12523
+ authKind: this.subscriptionAuthKind,
12523
12524
  observedAt,
12524
12525
  stale: false,
12525
12526
  windows
@@ -12537,8 +12538,37 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12537
12538
  usedPercent: Math.max(0, Math.min(100, info.utilization * 100)),
12538
12539
  resetsAt: typeof info.resetsAt === "number" ? new Date(info.resetsAt * 1e3).toISOString() : null
12539
12540
  });
12541
+ this.subscriptionAuthKind = "subscription";
12540
12542
  this.subscriptionUsageObservedAt = (/* @__PURE__ */ new Date()).toISOString();
12541
12543
  }
12544
+ async captureStructuredSubscriptionUsage(query) {
12545
+ const getUsage = query.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET;
12546
+ if (!getUsage) {
12547
+ return;
12548
+ }
12549
+ try {
12550
+ const usage = await getUsage.call(query);
12551
+ const nextWindows = /* @__PURE__ */ new Map();
12552
+ const addWindow = (id, window) => {
12553
+ if (typeof window?.utilization !== "number" || !Number.isFinite(window.utilization)) {
12554
+ return;
12555
+ }
12556
+ nextWindows.set(id, {
12557
+ usedPercent: Math.max(0, Math.min(100, window.utilization)),
12558
+ resetsAt: typeof window.resets_at === "string" ? window.resets_at : null
12559
+ });
12560
+ };
12561
+ addWindow("five_hour", usage.rate_limits?.five_hour);
12562
+ addWindow("seven_day", usage.rate_limits?.seven_day);
12563
+ this.subscriptionUsageWindows.clear();
12564
+ for (const [id, window] of nextWindows) {
12565
+ this.subscriptionUsageWindows.set(id, window);
12566
+ }
12567
+ this.subscriptionAuthKind = usage.subscription_type ? "subscription" : usage.rate_limits_available ? "subscription" : "apiKey";
12568
+ this.subscriptionUsageObservedAt = (/* @__PURE__ */ new Date()).toISOString();
12569
+ } catch {
12570
+ }
12571
+ }
12542
12572
  updateToolboxItemsFromSystemInit(message) {
12543
12573
  this.managementSchema.toolboxItems = buildClaudeToolboxItems(
12544
12574
  normalizeClaudeSlashCommands(message.slash_commands)
@@ -12683,9 +12713,14 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12683
12713
  let providerSessionId = null;
12684
12714
  let model = input.model;
12685
12715
  const rawMessages = [];
12716
+ let capturedStructuredUsage = false;
12686
12717
  try {
12687
12718
  for await (const message of query) {
12688
12719
  rawMessages.push(message);
12720
+ if (!capturedStructuredUsage) {
12721
+ capturedStructuredUsage = true;
12722
+ await this.captureStructuredSubscriptionUsage(query);
12723
+ }
12689
12724
  this.captureRateLimit(message);
12690
12725
  if (message.type === "system" && message.subtype === "init") {
12691
12726
  this.updateToolboxItemsFromSystemInit(message);
@@ -12931,9 +12966,14 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12931
12966
  const rawMessages = [];
12932
12967
  let terminalStatus = null;
12933
12968
  let terminalError = null;
12969
+ let capturedStructuredUsage = false;
12934
12970
  try {
12935
12971
  for await (const message of state.query) {
12936
12972
  rawMessages.push(message);
12973
+ if (!capturedStructuredUsage) {
12974
+ capturedStructuredUsage = true;
12975
+ await this.captureStructuredSubscriptionUsage(state.query);
12976
+ }
12937
12977
  this.captureRateLimit(message);
12938
12978
  this.consumeMessage(state, message);
12939
12979
  const status = queryResultStatus(message);