@omnicross/daemon 0.4.0 → 0.4.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.
package/dist/index.d.cts CHANGED
@@ -1636,6 +1636,56 @@ declare class CopilotAllowanceCollector {
1636
1636
  private unsupportedSnapshot;
1637
1637
  }
1638
1638
 
1639
+ /**
1640
+ * GeminiAllowanceCollector — gemini subscription quota via the Cloud Code
1641
+ * Assist internal user-quota RPC.
1642
+ *
1643
+ * Probes `POST ${cloudcode-pa}/v1internal:retrieveUserQuota` per gemini
1644
+ * account (Bearer access token + the GeminiCLI masquerade pair the inference
1645
+ * path also carries), parsing `buckets[]` into one per-model window:
1646
+ * `remainingFraction` (0–1) → used percent, `resetTime` → resetsAt. The
1647
+ * Code Assist project id comes from the SHARED `GeminiCodeAssistProjectResolver`
1648
+ * (the same instance the dispatch seam uses, so the handshake runs at most
1649
+ * once per token across inference + quota); a handshake hard failure degrades
1650
+ * to a project-less probe (the valid free-tier envelope), mirroring the
1651
+ * reference implementation's tolerant behavior.
1652
+ *
1653
+ * Mirrors the sibling collectors' cache contract: 5-minute cache, per-account
1654
+ * in-flight merging, one 401/403→refresh→retry. Display-only — the scheduling
1655
+ * whitelist deliberately excludes gemini (per-model fraction buckets do not
1656
+ * fit the worst-window pause/demote rule).
1657
+ *
1658
+ * @module @omnicross/daemon/allowance/GeminiAllowanceCollector
1659
+ */
1660
+
1661
+ interface GeminiAllowanceCredentialReader {
1662
+ getAccessTokenForAccount(providerId: 'gemini', accountId: string): Promise<string | null>;
1663
+ refreshAccountToken(providerId: 'gemini', accountId: string): Promise<boolean>;
1664
+ }
1665
+ type GeminiAllowanceFetch = (url: string, init: RequestInit, accountId: string) => Promise<Response>;
1666
+ interface GeminiAllowanceCollectOptions {
1667
+ force?: boolean;
1668
+ refreshAheadMs?: number;
1669
+ }
1670
+ declare class GeminiAllowanceCollector {
1671
+ private readonly credentials;
1672
+ private readonly store;
1673
+ private readonly fetchImpl;
1674
+ private readonly now;
1675
+ private readonly projectResolver;
1676
+ private readonly inFlight;
1677
+ constructor(credentials: GeminiAllowanceCredentialReader, store?: AccountAllowanceStore, fetchImpl?: GeminiAllowanceFetch, now?: () => number, projectResolver?: {
1678
+ resolveProject(accessToken: string): Promise<string | undefined>;
1679
+ });
1680
+ collectMany(accounts: readonly SubscriptionAccountEntry<GeminiTokenConfig>[], options?: GeminiAllowanceCollectOptions): Promise<AccountAllowanceSnapshot[]>;
1681
+ collect(account: SubscriptionAccountEntry<GeminiTokenConfig>, options?: GeminiAllowanceCollectOptions): Promise<AccountAllowanceSnapshot>;
1682
+ private isCacheValid;
1683
+ private fetchAccount;
1684
+ private request;
1685
+ private failureSnapshot;
1686
+ private unsupportedSnapshot;
1687
+ }
1688
+
1639
1689
  /**
1640
1690
  * OpenCodeGo usage collector.
1641
1691
  *
@@ -1683,8 +1733,8 @@ declare class OpenCodeGoAllowanceCollector {
1683
1733
  * literals — extending them all would make the overloads conflict.
1684
1734
  */
1685
1735
  interface AccountAllowanceCredentialReader {
1686
- getAccessTokenForAccount(providerId: 'claude' | 'codex' | 'kimi' | 'opencodego' | 'grok' | 'copilot', accountId: string): Promise<string | null>;
1687
- refreshAccountToken(providerId: 'claude' | 'codex' | 'kimi' | 'grok' | 'copilot', accountId: string): Promise<boolean>;
1736
+ getAccessTokenForAccount(providerId: 'claude' | 'codex' | 'kimi' | 'opencodego' | 'grok' | 'copilot' | 'gemini', accountId: string): Promise<string | null>;
1737
+ refreshAccountToken(providerId: 'claude' | 'codex' | 'kimi' | 'grok' | 'copilot' | 'gemini', accountId: string): Promise<boolean>;
1688
1738
  getFullConfig(): Promise<AccountTokensConfig>;
1689
1739
  }
1690
1740
  interface AccountAllowanceFilter {
@@ -1705,7 +1755,8 @@ declare class AccountAllowanceService {
1705
1755
  readonly grokCollector: GrokAllowanceCollector;
1706
1756
  readonly copilotCollector: CopilotAllowanceCollector;
1707
1757
  readonly opencodegoCollector: OpenCodeGoAllowanceCollector;
1708
- constructor(credentials: AccountAllowanceCredentialReader, store?: AccountAllowanceStore, collector?: ClaudeAllowanceCollector, codexCollector?: CodexAllowanceCollector, kimiCollector?: KimiAllowanceCollector, opencodegoCollector?: OpenCodeGoAllowanceCollector, grokCollector?: GrokAllowanceCollector, copilotCollector?: CopilotAllowanceCollector, now?: () => number);
1758
+ readonly geminiCollector: GeminiAllowanceCollector;
1759
+ constructor(credentials: AccountAllowanceCredentialReader, store?: AccountAllowanceStore, collector?: ClaudeAllowanceCollector, codexCollector?: CodexAllowanceCollector, kimiCollector?: KimiAllowanceCollector, opencodegoCollector?: OpenCodeGoAllowanceCollector, grokCollector?: GrokAllowanceCollector, copilotCollector?: CopilotAllowanceCollector, geminiCollector?: GeminiAllowanceCollector, now?: () => number);
1709
1760
  /**
1710
1761
  * Read all/filtered snapshots. Claude's and Codex's five-minute caches are
1711
1762
  * refreshed lazily on read (Codex polls `/backend-api/wham/usage`; the
@@ -1729,6 +1780,8 @@ declare class AccountAllowanceService {
1729
1780
  refreshCopilot(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
1730
1781
  /** Force-refresh Grok usage (CLI billing proxy) for one/all accounts. */
1731
1782
  refreshGrok(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
1783
+ /** Force-refresh Gemini usage (Code Assist retrieveUserQuota) for one/all accounts. */
1784
+ refreshGemini(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
1732
1785
  /**
1733
1786
  * Keep Claude + Codex + Kimi snapshots warm for allowance-aware routing. All
1734
1787
  * collectors preserve their cache + per-account in-flight coalescing; a tick
@@ -2939,6 +2992,8 @@ interface AccountAllowanceAdminReader {
2939
2992
  refreshGrok?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
2940
2993
  /** Optional: Copilot user-quota refresh (absent on older daemons). */
2941
2994
  refreshCopilot?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
2995
+ /** Optional: Gemini Code-Assist quota refresh (absent on older daemons). */
2996
+ refreshGemini?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
2942
2997
  removeAccountSnapshot?(providerId: SubscriptionProviderId, accountId: string): void;
2943
2998
  removeProviderSnapshots?(providerId: SubscriptionProviderId): void;
2944
2999
  getSchedulingStatus?(): AccountAllowanceSchedulingStatus;
package/dist/index.d.ts CHANGED
@@ -1636,6 +1636,56 @@ declare class CopilotAllowanceCollector {
1636
1636
  private unsupportedSnapshot;
1637
1637
  }
1638
1638
 
1639
+ /**
1640
+ * GeminiAllowanceCollector — gemini subscription quota via the Cloud Code
1641
+ * Assist internal user-quota RPC.
1642
+ *
1643
+ * Probes `POST ${cloudcode-pa}/v1internal:retrieveUserQuota` per gemini
1644
+ * account (Bearer access token + the GeminiCLI masquerade pair the inference
1645
+ * path also carries), parsing `buckets[]` into one per-model window:
1646
+ * `remainingFraction` (0–1) → used percent, `resetTime` → resetsAt. The
1647
+ * Code Assist project id comes from the SHARED `GeminiCodeAssistProjectResolver`
1648
+ * (the same instance the dispatch seam uses, so the handshake runs at most
1649
+ * once per token across inference + quota); a handshake hard failure degrades
1650
+ * to a project-less probe (the valid free-tier envelope), mirroring the
1651
+ * reference implementation's tolerant behavior.
1652
+ *
1653
+ * Mirrors the sibling collectors' cache contract: 5-minute cache, per-account
1654
+ * in-flight merging, one 401/403→refresh→retry. Display-only — the scheduling
1655
+ * whitelist deliberately excludes gemini (per-model fraction buckets do not
1656
+ * fit the worst-window pause/demote rule).
1657
+ *
1658
+ * @module @omnicross/daemon/allowance/GeminiAllowanceCollector
1659
+ */
1660
+
1661
+ interface GeminiAllowanceCredentialReader {
1662
+ getAccessTokenForAccount(providerId: 'gemini', accountId: string): Promise<string | null>;
1663
+ refreshAccountToken(providerId: 'gemini', accountId: string): Promise<boolean>;
1664
+ }
1665
+ type GeminiAllowanceFetch = (url: string, init: RequestInit, accountId: string) => Promise<Response>;
1666
+ interface GeminiAllowanceCollectOptions {
1667
+ force?: boolean;
1668
+ refreshAheadMs?: number;
1669
+ }
1670
+ declare class GeminiAllowanceCollector {
1671
+ private readonly credentials;
1672
+ private readonly store;
1673
+ private readonly fetchImpl;
1674
+ private readonly now;
1675
+ private readonly projectResolver;
1676
+ private readonly inFlight;
1677
+ constructor(credentials: GeminiAllowanceCredentialReader, store?: AccountAllowanceStore, fetchImpl?: GeminiAllowanceFetch, now?: () => number, projectResolver?: {
1678
+ resolveProject(accessToken: string): Promise<string | undefined>;
1679
+ });
1680
+ collectMany(accounts: readonly SubscriptionAccountEntry<GeminiTokenConfig>[], options?: GeminiAllowanceCollectOptions): Promise<AccountAllowanceSnapshot[]>;
1681
+ collect(account: SubscriptionAccountEntry<GeminiTokenConfig>, options?: GeminiAllowanceCollectOptions): Promise<AccountAllowanceSnapshot>;
1682
+ private isCacheValid;
1683
+ private fetchAccount;
1684
+ private request;
1685
+ private failureSnapshot;
1686
+ private unsupportedSnapshot;
1687
+ }
1688
+
1639
1689
  /**
1640
1690
  * OpenCodeGo usage collector.
1641
1691
  *
@@ -1683,8 +1733,8 @@ declare class OpenCodeGoAllowanceCollector {
1683
1733
  * literals — extending them all would make the overloads conflict.
1684
1734
  */
1685
1735
  interface AccountAllowanceCredentialReader {
1686
- getAccessTokenForAccount(providerId: 'claude' | 'codex' | 'kimi' | 'opencodego' | 'grok' | 'copilot', accountId: string): Promise<string | null>;
1687
- refreshAccountToken(providerId: 'claude' | 'codex' | 'kimi' | 'grok' | 'copilot', accountId: string): Promise<boolean>;
1736
+ getAccessTokenForAccount(providerId: 'claude' | 'codex' | 'kimi' | 'opencodego' | 'grok' | 'copilot' | 'gemini', accountId: string): Promise<string | null>;
1737
+ refreshAccountToken(providerId: 'claude' | 'codex' | 'kimi' | 'grok' | 'copilot' | 'gemini', accountId: string): Promise<boolean>;
1688
1738
  getFullConfig(): Promise<AccountTokensConfig>;
1689
1739
  }
1690
1740
  interface AccountAllowanceFilter {
@@ -1705,7 +1755,8 @@ declare class AccountAllowanceService {
1705
1755
  readonly grokCollector: GrokAllowanceCollector;
1706
1756
  readonly copilotCollector: CopilotAllowanceCollector;
1707
1757
  readonly opencodegoCollector: OpenCodeGoAllowanceCollector;
1708
- constructor(credentials: AccountAllowanceCredentialReader, store?: AccountAllowanceStore, collector?: ClaudeAllowanceCollector, codexCollector?: CodexAllowanceCollector, kimiCollector?: KimiAllowanceCollector, opencodegoCollector?: OpenCodeGoAllowanceCollector, grokCollector?: GrokAllowanceCollector, copilotCollector?: CopilotAllowanceCollector, now?: () => number);
1758
+ readonly geminiCollector: GeminiAllowanceCollector;
1759
+ constructor(credentials: AccountAllowanceCredentialReader, store?: AccountAllowanceStore, collector?: ClaudeAllowanceCollector, codexCollector?: CodexAllowanceCollector, kimiCollector?: KimiAllowanceCollector, opencodegoCollector?: OpenCodeGoAllowanceCollector, grokCollector?: GrokAllowanceCollector, copilotCollector?: CopilotAllowanceCollector, geminiCollector?: GeminiAllowanceCollector, now?: () => number);
1709
1760
  /**
1710
1761
  * Read all/filtered snapshots. Claude's and Codex's five-minute caches are
1711
1762
  * refreshed lazily on read (Codex polls `/backend-api/wham/usage`; the
@@ -1729,6 +1780,8 @@ declare class AccountAllowanceService {
1729
1780
  refreshCopilot(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
1730
1781
  /** Force-refresh Grok usage (CLI billing proxy) for one/all accounts. */
1731
1782
  refreshGrok(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
1783
+ /** Force-refresh Gemini usage (Code Assist retrieveUserQuota) for one/all accounts. */
1784
+ refreshGemini(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
1732
1785
  /**
1733
1786
  * Keep Claude + Codex + Kimi snapshots warm for allowance-aware routing. All
1734
1787
  * collectors preserve their cache + per-account in-flight coalescing; a tick
@@ -2939,6 +2992,8 @@ interface AccountAllowanceAdminReader {
2939
2992
  refreshGrok?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
2940
2993
  /** Optional: Copilot user-quota refresh (absent on older daemons). */
2941
2994
  refreshCopilot?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
2995
+ /** Optional: Gemini Code-Assist quota refresh (absent on older daemons). */
2996
+ refreshGemini?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
2942
2997
  removeAccountSnapshot?(providerId: SubscriptionProviderId, accountId: string): void;
2943
2998
  removeProviderSnapshots?(providerId: SubscriptionProviderId): void;
2944
2999
  getSchedulingStatus?(): AccountAllowanceSchedulingStatus;