dsh-subscriptions 0.1.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.
Files changed (150) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +129 -0
  3. package/cordis.patch.yml +12 -0
  4. package/lib/auth/claude-code-creds.d.ts +23 -0
  5. package/lib/auth/claude-code-creds.js +172 -0
  6. package/lib/auth/device-flow.d.ts +55 -0
  7. package/lib/auth/device-flow.js +177 -0
  8. package/lib/auth/jwt.d.ts +10 -0
  9. package/lib/auth/jwt.js +25 -0
  10. package/lib/auth/oauth-flow.d.ts +91 -0
  11. package/lib/auth/oauth-flow.js +227 -0
  12. package/lib/auth/pkce.d.ts +31 -0
  13. package/lib/auth/pkce.js +35 -0
  14. package/lib/auth/rpc.d.ts +209 -0
  15. package/lib/auth/rpc.js +386 -0
  16. package/lib/auth/store.d.ts +196 -0
  17. package/lib/auth/store.js +468 -0
  18. package/lib/client/CursorCard.d.ts +9 -0
  19. package/lib/client/CursorCard.js +113 -0
  20. package/lib/client/ExternalUsageCards.d.ts +9 -0
  21. package/lib/client/ExternalUsageCards.js +72 -0
  22. package/lib/client/ImageGallery.d.ts +54 -0
  23. package/lib/client/ImageGallery.js +112 -0
  24. package/lib/client/ImageGenerateToolview.d.ts +48 -0
  25. package/lib/client/ImageGenerateToolview.js +133 -0
  26. package/lib/client/ProviderAccountManager.d.ts +13 -0
  27. package/lib/client/ProviderAccountManager.js +147 -0
  28. package/lib/client/ProviderModelEditor.d.ts +39 -0
  29. package/lib/client/ProviderModelEditor.js +107 -0
  30. package/lib/client/SpeedSelect.d.ts +71 -0
  31. package/lib/client/SpeedSelect.js +177 -0
  32. package/lib/client/SubscriptionUsageBadge.d.ts +116 -0
  33. package/lib/client/SubscriptionUsageBadge.js +543 -0
  34. package/lib/client/SubscriptionsSection.d.ts +140 -0
  35. package/lib/client/SubscriptionsSection.js +544 -0
  36. package/lib/client/UsageBadgeDisplaySetting.d.ts +7 -0
  37. package/lib/client/UsageBadgeDisplaySetting.js +36 -0
  38. package/lib/client/VideoGenerateToolview.d.ts +42 -0
  39. package/lib/client/VideoGenerateToolview.js +175 -0
  40. package/lib/client/account-preferences.d.ts +24 -0
  41. package/lib/client/account-preferences.js +21 -0
  42. package/lib/client/fast-command.d.ts +2 -0
  43. package/lib/client/fast-command.js +4 -0
  44. package/lib/client/host-contract.d.ts +90 -0
  45. package/lib/client/host-contract.js +101 -0
  46. package/lib/client/host-icons.d.ts +24 -0
  47. package/lib/client/host-icons.js +21 -0
  48. package/lib/client/index.d.ts +27 -0
  49. package/lib/client/index.js +136 -0
  50. package/lib/client/locales.d.ts +297 -0
  51. package/lib/client/locales.js +295 -0
  52. package/lib/client/subscription-card-styles.d.ts +3 -0
  53. package/lib/client/subscription-card-styles.js +53 -0
  54. package/lib/client/subscriptions-rpc.d.ts +14 -0
  55. package/lib/client/subscriptions-rpc.js +34 -0
  56. package/lib/client/usage-badge-preferences.d.ts +11 -0
  57. package/lib/client/usage-badge-preferences.js +41 -0
  58. package/lib/client.js +4472 -0
  59. package/lib/client.js.map +1 -0
  60. package/lib/compat.d.ts +36 -0
  61. package/lib/compat.js +20 -0
  62. package/lib/http.d.ts +6 -0
  63. package/lib/http.js +15 -0
  64. package/lib/index.d.ts +80 -0
  65. package/lib/index.js +14018 -0
  66. package/lib/model-defaults.d.ts +23 -0
  67. package/lib/model-defaults.js +237 -0
  68. package/lib/provider-settings.d.ts +39 -0
  69. package/lib/provider-settings.js +151 -0
  70. package/lib/providers/account-preferences.d.ts +41 -0
  71. package/lib/providers/account-preferences.js +153 -0
  72. package/lib/providers/accounts.d.ts +112 -0
  73. package/lib/providers/accounts.js +142 -0
  74. package/lib/providers/antigravity-oauth-client.d.ts +7 -0
  75. package/lib/providers/antigravity-oauth-client.js +7 -0
  76. package/lib/providers/antigravity.d.ts +110 -0
  77. package/lib/providers/antigravity.js +516 -0
  78. package/lib/providers/catalog-store.d.ts +48 -0
  79. package/lib/providers/catalog-store.js +243 -0
  80. package/lib/providers/claude-cli-version.d.ts +15 -0
  81. package/lib/providers/claude-cli-version.js +24 -0
  82. package/lib/providers/claude.d.ts +181 -0
  83. package/lib/providers/claude.js +680 -0
  84. package/lib/providers/codex-client-version.d.ts +8 -0
  85. package/lib/providers/codex-client-version.js +17 -0
  86. package/lib/providers/codex-search.d.ts +29 -0
  87. package/lib/providers/codex-search.js +198 -0
  88. package/lib/providers/codex.d.ts +229 -0
  89. package/lib/providers/codex.js +821 -0
  90. package/lib/providers/common.d.ts +389 -0
  91. package/lib/providers/common.js +656 -0
  92. package/lib/providers/copilot.d.ts +344 -0
  93. package/lib/providers/copilot.js +888 -0
  94. package/lib/providers/cursor-adapter.d.ts +15 -0
  95. package/lib/providers/cursor-adapter.js +39 -0
  96. package/lib/providers/cursor-auth.d.ts +43 -0
  97. package/lib/providers/cursor-auth.js +169 -0
  98. package/lib/providers/cursor-model-settings.d.ts +15 -0
  99. package/lib/providers/cursor-model-settings.js +51 -0
  100. package/lib/providers/cursor-usage.d.ts +9 -0
  101. package/lib/providers/cursor-usage.js +112 -0
  102. package/lib/providers/external-usage-controller.d.ts +19 -0
  103. package/lib/providers/external-usage-controller.js +32 -0
  104. package/lib/providers/external-usage.d.ts +8 -0
  105. package/lib/providers/external-usage.js +82 -0
  106. package/lib/providers/grok.d.ts +205 -0
  107. package/lib/providers/grok.js +713 -0
  108. package/lib/providers/image-pool.d.ts +30 -0
  109. package/lib/providers/image-pool.js +89 -0
  110. package/lib/providers/npm-cli-version.d.ts +56 -0
  111. package/lib/providers/npm-cli-version.js +98 -0
  112. package/lib/providers/pool-family.d.ts +56 -0
  113. package/lib/providers/pool-family.js +45 -0
  114. package/lib/providers/pool-health.d.ts +74 -0
  115. package/lib/providers/pool-health.js +150 -0
  116. package/lib/providers/pool-usage.d.ts +86 -0
  117. package/lib/providers/pool-usage.js +223 -0
  118. package/lib/providers/pool.d.ts +108 -0
  119. package/lib/providers/pool.js +368 -0
  120. package/lib/providers/rate-limit.d.ts +192 -0
  121. package/lib/providers/rate-limit.js +338 -0
  122. package/lib/tools/image-generate.d.ts +128 -0
  123. package/lib/tools/image-generate.js +438 -0
  124. package/lib/tools/registration.d.ts +15 -0
  125. package/lib/tools/registration.js +24 -0
  126. package/lib/tools/video-generate.d.ts +89 -0
  127. package/lib/tools/video-generate.js +257 -0
  128. package/lib/tools/x-search.d.ts +58 -0
  129. package/lib/tools/x-search.js +197 -0
  130. package/lib/translate/anthropic.d.ts +161 -0
  131. package/lib/translate/anthropic.js +515 -0
  132. package/lib/translate/antigravity-schema.d.ts +4 -0
  133. package/lib/translate/antigravity-schema.js +145 -0
  134. package/lib/translate/antigravity-thinking.d.ts +5 -0
  135. package/lib/translate/antigravity-thinking.js +44 -0
  136. package/lib/translate/antigravity.d.ts +114 -0
  137. package/lib/translate/antigravity.js +366 -0
  138. package/lib/translate/chat-completions.d.ts +120 -0
  139. package/lib/translate/chat-completions.js +382 -0
  140. package/lib/translate/resolved.d.ts +80 -0
  141. package/lib/translate/resolved.js +118 -0
  142. package/lib/translate/responses.d.ts +179 -0
  143. package/lib/translate/responses.js +408 -0
  144. package/lib/translate/sse.d.ts +21 -0
  145. package/lib/translate/sse.js +56 -0
  146. package/package.json +114 -0
  147. package/vendor/cursor/LICENSE +21 -0
  148. package/vendor/cursor/index.d.ts +18 -0
  149. package/vendor/cursor/index.js +3574 -0
  150. package/vendor/cursor/proto.js +254 -0
@@ -0,0 +1,140 @@
1
+ import type { ConnectionHandle } from '@deepseek-ai/dsh-api-remotes/client';
2
+ import type { SubscriptionsKey } from './locales.js';
3
+ export { callSubscriptionsAuth } from './subscriptions-rpc.js';
4
+ /** Subscription provider ids, fixed by the node half's OAuth adapters. */
5
+ export type SubscriptionProvider = 'codex' | 'claude' | 'grok' | 'copilot' | 'antigravity';
6
+ /** One logged-in account as answered by the `status` endpoint. */
7
+ export interface AccountStatus {
8
+ key: string;
9
+ account?: string;
10
+ expiresAt?: number;
11
+ plan?: string;
12
+ isDefault: boolean;
13
+ }
14
+ /** One provider's login state as answered by the `status` endpoint. */
15
+ export interface ProviderStatus {
16
+ busy: boolean;
17
+ accounts: AccountStatus[];
18
+ detail?: string;
19
+ /** The CLI version the route presents (Codex, Claude), and where it came from. */
20
+ clientVersion?: {
21
+ version: string;
22
+ source: ClientVersionSource;
23
+ };
24
+ }
25
+ /** Where a presented CLI version came from; the tag names the source so a stale one is visible. */
26
+ export type ClientVersionSource = 'npm' | 'local' | 'fallback' | 'config';
27
+ /** One rate-limit window as answered by the `usage` endpoint. */
28
+ export interface UsageWindow {
29
+ kind: 'session' | 'weekly' | 'other';
30
+ scope?: string;
31
+ usedPercent: number;
32
+ resetsAt?: number;
33
+ }
34
+ /** `usage` endpoint value: the node half owns this shape. */
35
+ export interface ProviderUsage {
36
+ supported: boolean;
37
+ windows?: UsageWindow[];
38
+ plan?: string;
39
+ }
40
+ /** One model's default-effort picker state as answered by `modelDefaults`. */
41
+ export interface ModelDefaultView {
42
+ id: string;
43
+ name: string;
44
+ /** Advertised effort levels, in catalog order (empty when the model has no reasoning). */
45
+ efforts: {
46
+ id: string;
47
+ name: string;
48
+ }[];
49
+ /** The user-configured default effort, when set. */
50
+ configured?: string;
51
+ }
52
+ /** `modelDefaults` endpoint value: one provider's picker state. */
53
+ export interface ModelDefaultsCatalog {
54
+ provider: SubscriptionProvider;
55
+ models: ModelDefaultView[];
56
+ }
57
+ /** Injected dependencies of {@link SubscriptionsSection} (slot `inject`). */
58
+ export interface SubscriptionsSectionInjected {
59
+ /** Generic logical-RPC caller over the Connection transport. */
60
+ rpc: ConnectionHandle['rpc'];
61
+ /** Section copy: translate a 'settings.subscriptions' key with `{name}` template params. */
62
+ t: (key: SubscriptionsKey, params?: Record<string, unknown>) => string;
63
+ }
64
+ /**
65
+ * Props delivered by the slot outlet: the inject face spread flat (the
66
+ * renderer erases the share boundary at the render call).
67
+ */
68
+ export type SubscriptionsSectionProps = Partial<SubscriptionsSectionInjected>;
69
+ /**
70
+ * The CLI version a route presents, beside the provider name; nothing for
71
+ * routes without one. The source word (npm / local / built-in / configured)
72
+ * is the fix for upstream issue #108: a failed npm lookup must read as a
73
+ * fallback, never as a plan limit.
74
+ */
75
+ export declare function clientVersionText(t: SubscriptionsSectionInjected['t'], clientVersion: ProviderStatus['clientVersion']): string;
76
+ /** Bar fill color: success normally, warn from 80%, error from 95%. Shared with the composer badge. */
77
+ export declare function usageBarColor(usedPercent: number): string;
78
+ /** What one provider's collapsible default-effort section renders. */
79
+ export interface ModelDefaultsView {
80
+ /** Models with reasoning levels, after the name filter — one row each. */
81
+ shown: ModelDefaultView[];
82
+ /** Models with reasoning levels before filtering (the header total). */
83
+ total: number;
84
+ /** How many of those carry a user override (the header count). */
85
+ overridden: number;
86
+ /** Models without reasoning levels: one count line, never a row each. */
87
+ withoutEfforts: number;
88
+ /** Whether the list is long enough to deserve a filter box. */
89
+ showFilter: boolean;
90
+ }
91
+ /**
92
+ * Derive one provider's default-effort section from its catalog and filter.
93
+ * Pure so the collapsed-header counts and the filter stay testable without a
94
+ * DOM: rows come only from models that advertise levels, the count of the rest
95
+ * rides as one line, and the filter matches display name or model id.
96
+ * @param models - the provider's catalog models, or undefined while loading.
97
+ * @param filter - the raw filter input (trimmed and lowercased here).
98
+ * @returns the section's rows and header counts.
99
+ */
100
+ export declare function deriveModelDefaultsView(models: readonly ModelDefaultView[] | undefined, filter: string): ModelDefaultsView;
101
+ /** Inputs of the default-effort fetch decision (see {@link shouldFetchModelDefaults}). */
102
+ export interface ModelDefaultsFetchInput {
103
+ /** Providers that currently have at least one account. */
104
+ loggedIn: readonly SubscriptionProvider[];
105
+ /** Providers whose disclosure is open. */
106
+ open: readonly SubscriptionProvider[];
107
+ /** The account signature the last completed fetch was answered for. */
108
+ loadedFor: string | undefined;
109
+ /** The account signature of the current status snapshot. */
110
+ signature: string;
111
+ /** Whether the last attempt failed (a failure latches until Retry). */
112
+ failed: boolean;
113
+ }
114
+ /**
115
+ * Whether the default-effort catalog needs (re)fetching.
116
+ *
117
+ * Fetching is gated on an *attempt* signature rather than on the payload
118
+ * being empty: an empty answer is a legitimate result (a narrowed
119
+ * `config.providers`, or a catalog that is momentarily unavailable), and
120
+ * treating it as "not loaded yet" re-ran this effect forever. The signature
121
+ * also covers the accounts, so logging a second provider in refetches
122
+ * instead of leaving that card on the previous answer.
123
+ * @param input - the decision inputs.
124
+ * @returns true when the caller should start a fetch.
125
+ */
126
+ export declare function shouldFetchModelDefaults(input: ModelDefaultsFetchInput): boolean;
127
+ /**
128
+ * Stable signature of the accounts a catalog answer depends on. A change
129
+ * means a previous answer is stale (an account arrived or left), so the next
130
+ * open disclosure refetches.
131
+ * @param statuses - the per-provider status snapshot.
132
+ * @returns a signature string, stable across renders with equal accounts.
133
+ */
134
+ export declare function modelDefaultsSignature(statuses: Partial<Record<SubscriptionProvider, ProviderStatus>>): string;
135
+ /**
136
+ * The Subscriptions settings page component.
137
+ * @param props - the slot inject face ({@link SubscriptionsSectionInjected}).
138
+ * @returns the section body, or a notice while the RPC face is absent.
139
+ */
140
+ export declare function SubscriptionsSection(props: SubscriptionsSectionProps): import("react").JSX.Element;