@ycodium-ai/agent-codex 0.2.2876 → 0.2.2882

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.
Files changed (2) hide show
  1. package/dist/index.js +35 -13
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1643,6 +1643,7 @@ var creditBalance = (value) => {
1643
1643
  return Number.isFinite(numeric) ? numeric : null;
1644
1644
  };
1645
1645
  var MAIN_LIMIT_ID = "codex";
1646
+ var CREDITS_BALANCE_ID = "credits";
1646
1647
  var isMainCodexLimit = (snapshot) => {
1647
1648
  const limitId = asNonEmptyString(asRecord(snapshot)?.["limitId"]);
1648
1649
  return limitId === null || limitId === MAIN_LIMIT_ID;
@@ -1657,7 +1658,7 @@ var mapCodexSnapshotWindows = (snapshot) => {
1657
1658
  if (window === null) continue;
1658
1659
  const id = takenIds.has(window.id) ? `${window.id}:${slot}` : window.id;
1659
1660
  takenIds.add(id);
1660
- windows.push({ ...window, id });
1661
+ windows.push({ ...window, id, group: MAIN_LIMIT_ID });
1661
1662
  }
1662
1663
  return windows;
1663
1664
  };
@@ -1688,16 +1689,14 @@ var mapCodexRateLimits = (response, accountKey) => {
1688
1689
  for (const [limitId, bucket] of others) {
1689
1690
  const name = asNonEmptyString(bucket["limitName"]) ?? limitId;
1690
1691
  for (const slot of ["primary", "secondary"]) {
1691
- push(
1692
- mapWindow(bucket[slot], slot, (minutes) => ({
1693
- id: `${limitId}:${slot}`,
1694
- label: minutes === null ? { text: name } : {
1695
- key: "usage.window.named",
1696
- values: { name, duration: formatWindowDuration(minutes) }
1697
- }
1698
- })),
1699
- slot
1700
- );
1692
+ const window = mapWindow(bucket[slot], slot, (minutes) => ({
1693
+ id: `${limitId}:${slot}`,
1694
+ label: minutes === null ? { text: name } : {
1695
+ key: "usage.window.named",
1696
+ values: { name, duration: formatWindowDuration(minutes) }
1697
+ }
1698
+ }));
1699
+ push(window === null ? null : { ...window, group: limitId }, slot);
1701
1700
  }
1702
1701
  }
1703
1702
  const balances = [];
@@ -1706,7 +1705,7 @@ var mapCodexRateLimits = (response, accountKey) => {
1706
1705
  if (credits !== null && credits["unlimited"] !== true && balance !== null) {
1707
1706
  if (credits["hasCredits"] === true || balance > 0) {
1708
1707
  balances.push({
1709
- id: "credits",
1708
+ id: CREDITS_BALANCE_ID,
1710
1709
  label: { key: "usage.balance.credits" },
1711
1710
  remaining: balance,
1712
1711
  used: null,
@@ -1729,6 +1728,24 @@ var mapCodexRateLimits = (response, accountKey) => {
1729
1728
  ...availableCount === null || availableCount < 0 ? {} : { resetCredits: { availableCount: Math.trunc(availableCount) } }
1730
1729
  };
1731
1730
  };
1731
+ var codexQuotaFromRateLimits = (snapshot) => {
1732
+ const bucket = asRecord(snapshot);
1733
+ if (bucket === null) return null;
1734
+ const reading = mapCodexRateLimits({ rateLimits: snapshot }, "");
1735
+ if (reading === null || reading.status !== "available") return null;
1736
+ const main = isMainCodexLimit(bucket);
1737
+ const group = main ? MAIN_LIMIT_ID : asNonEmptyString(bucket["limitId"]);
1738
+ const replaces = {
1739
+ windowGroups: group === null ? [] : [group],
1740
+ balanceIds: main ? [CREDITS_BALANCE_ID] : []
1741
+ };
1742
+ return {
1743
+ windows: reading.windows,
1744
+ balances: reading.balances,
1745
+ ...reading.plan === void 0 ? {} : { plan: reading.plan },
1746
+ replaces
1747
+ };
1748
+ };
1732
1749
  var classifyRateLimitsError = (message) => {
1733
1750
  const text = message.toLowerCase();
1734
1751
  if (text.includes("chatgpt authentication required")) return "unsupportedLogin";
@@ -5512,7 +5529,12 @@ var createCodexUsage = (input) => {
5512
5529
  }
5513
5530
  return { outcome };
5514
5531
  };
5515
- return { readQuota, readTokenUsage, redeemQuotaReset };
5532
+ return {
5533
+ readQuota,
5534
+ quotaFromRateLimits: codexQuotaFromRateLimits,
5535
+ readTokenUsage,
5536
+ redeemQuotaReset
5537
+ };
5516
5538
  };
5517
5539
 
5518
5540
  // src/codexInstance.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-codex",
3
- "version": "0.2.2876",
3
+ "version": "0.2.2882",
4
4
  "description": "Codex executor: Codex CLI over the app-server JSON-RPC protocol.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -29,7 +29,7 @@
29
29
  "tailwindcss": "^4.0.0",
30
30
  "typescript": "~6.0.3",
31
31
  "vite-plus": "0.2.2",
32
- "@ycodium-ai/plugin-api": "0.2.2876",
32
+ "@ycodium-ai/plugin-api": "0.2.2882",
33
33
  "ycodium-executor-testing": "0.0.0"
34
34
  },
35
35
  "ycodium": {