dsh-subscriptions 0.2.0 → 0.2.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.
Files changed (99) hide show
  1. package/README.md +212 -180
  2. package/lib/auth/claude-code-creds.js +31 -9
  3. package/lib/auth/device-flow.js +16 -9
  4. package/lib/auth/oauth-flow.js +13 -10
  5. package/lib/auth/rpc.js +74 -23
  6. package/lib/auth/store.js +80 -31
  7. package/lib/client/CursorCard.d.ts +1 -1
  8. package/lib/client/CursorCard.js +50 -16
  9. package/lib/client/ExternalUsageCards.d.ts +1 -1
  10. package/lib/client/ExternalUsageCards.js +37 -16
  11. package/lib/client/ImageGallery.d.ts +2 -2
  12. package/lib/client/ImageGallery.js +92 -33
  13. package/lib/client/ImageGenerateToolview.js +50 -14
  14. package/lib/client/OllamaCard.d.ts +1 -1
  15. package/lib/client/OllamaCard.js +26 -8
  16. package/lib/client/OllamaSettingsManager.js +113 -30
  17. package/lib/client/ProviderAccountManager.d.ts +1 -1
  18. package/lib/client/ProviderAccountManager.js +164 -49
  19. package/lib/client/ProviderModelEditor.js +107 -26
  20. package/lib/client/SpeedSelect.d.ts +62 -14
  21. package/lib/client/SpeedSelect.js +257 -46
  22. package/lib/client/SubscriptionUsageBadge.d.ts +4 -10
  23. package/lib/client/SubscriptionUsageBadge.js +300 -112
  24. package/lib/client/SubscriptionsSection.js +258 -85
  25. package/lib/client/UsageBadgeDisplaySetting.js +35 -12
  26. package/lib/client/UsageMeter.d.ts +1 -1
  27. package/lib/client/UsageMeter.js +62 -24
  28. package/lib/client/VideoGenerateToolview.js +69 -17
  29. package/lib/client/account-preferences.d.ts +8 -0
  30. package/lib/client/account-preferences.js +20 -5
  31. package/lib/client/host-contract.d.ts +11 -2
  32. package/lib/client/host-contract.js +20 -3
  33. package/lib/client/index.d.ts +5 -5
  34. package/lib/client/index.js +34 -12
  35. package/lib/client/locales.d.ts +10 -0
  36. package/lib/client/locales.js +61 -51
  37. package/lib/client/ollama-draft.js +21 -12
  38. package/lib/client/reset-action.js +6 -4
  39. package/lib/client/reset-credits-view.d.ts +1 -1
  40. package/lib/client/reset-credits-view.js +66 -17
  41. package/lib/client/subscription-card-styles.js +94 -24
  42. package/lib/client/usage-color-preferences.js +4 -2
  43. package/lib/client/usage-pace.js +30 -12
  44. package/lib/client.js +287 -47
  45. package/lib/client.js.map +1 -1
  46. package/lib/http.js +1 -1
  47. package/lib/index.d.ts +3 -3
  48. package/lib/index.js +118 -64
  49. package/lib/model-defaults.js +4 -2
  50. package/lib/provider-settings.d.ts +12 -0
  51. package/lib/provider-settings.js +58 -16
  52. package/lib/providers/account-preferences.js +51 -22
  53. package/lib/providers/accounts.js +15 -9
  54. package/lib/providers/antigravity-oauth-client.js +2 -2
  55. package/lib/providers/antigravity.js +141 -68
  56. package/lib/providers/catalog-store.js +120 -41
  57. package/lib/providers/claude-cli-version.js +3 -3
  58. package/lib/providers/claude.d.ts +9 -2
  59. package/lib/providers/claude.js +153 -90
  60. package/lib/providers/codex-client-version.js +3 -3
  61. package/lib/providers/codex-search.js +40 -13
  62. package/lib/providers/codex.js +196 -112
  63. package/lib/providers/common.js +71 -39
  64. package/lib/providers/copilot.js +143 -82
  65. package/lib/providers/cursor-adapter.js +42 -18
  66. package/lib/providers/cursor-auth.d.ts +1 -1
  67. package/lib/providers/cursor-auth.js +69 -24
  68. package/lib/providers/cursor-model-settings.js +14 -5
  69. package/lib/providers/cursor-usage.js +27 -13
  70. package/lib/providers/external-usage-controller.js +14 -5
  71. package/lib/providers/external-usage.js +59 -23
  72. package/lib/providers/grok.js +152 -89
  73. package/lib/providers/image-pool.js +29 -11
  74. package/lib/providers/minimax-usage.js +31 -11
  75. package/lib/providers/npm-cli-version.js +10 -3
  76. package/lib/providers/ollama-settings.js +24 -8
  77. package/lib/providers/ollama-web.js +29 -11
  78. package/lib/providers/ollama.js +129 -66
  79. package/lib/providers/pool-family.js +11 -3
  80. package/lib/providers/pool-health.js +28 -8
  81. package/lib/providers/pool-usage.js +16 -9
  82. package/lib/providers/pool.d.ts +8 -0
  83. package/lib/providers/pool.js +81 -42
  84. package/lib/providers/rate-limit.js +8 -2
  85. package/lib/providers/replay.js +40 -17
  86. package/lib/providers/reset-redemption.js +18 -6
  87. package/lib/tools/image-generate.js +123 -65
  88. package/lib/tools/registration.js +5 -2
  89. package/lib/tools/video-generate.js +51 -31
  90. package/lib/tools/x-search.js +50 -22
  91. package/lib/translate/anthropic.js +85 -37
  92. package/lib/translate/antigravity-schema.js +71 -28
  93. package/lib/translate/antigravity-thinking.js +22 -9
  94. package/lib/translate/antigravity.js +141 -50
  95. package/lib/translate/chat-completions.js +67 -23
  96. package/lib/translate/resolved.js +55 -21
  97. package/lib/translate/responses.js +69 -29
  98. package/lib/translate/sse.js +4 -1
  99. package/package.json +26 -4
@@ -20,23 +20,28 @@ export const en = {
20
20
  accountsNoModels: 'No models reported for this account.',
21
21
  accountsCatalogUnavailable: 'Model discovery is currently unavailable. Saved model selections are preserved.',
22
22
  modelsPartialSave: 'Some reasoning defaults were saved. Remaining changes are still in the draft; retry to finish.',
23
- modelsEdit: "Edit model list",
24
- modelsHint: "Configure model visibility, default reasoning effort, context and tools here; Save changes below submits them together with the account settings. Hidden models remain usable by existing sessions; tool changes apply to new sessions.",
25
- modelsAutomatic: "Automatically show all models, including new models",
26
- modelsSelectAll: "Select all",
27
- modelsSelectNone: "Clear selection",
28
- modelsContext: "Context (tokens)",
29
- modelsContextBounds: "Default {default} · Maximum {max}",
30
- modelsContextHint: "Leave blank to follow the provider. The requested window is capped by the account’s advertised maximum; account pools use the smallest member window. This controls local history and compaction, not the API’s capacity.",
31
- modelsContextInvalid: "Enter a positive whole number of tokens for {model}.",
32
- modelsTools: "Provider tools",
33
- modelsToolsHint: "Changes apply only to sessions created after saving. Existing sessions keep their tools. Shared tools remain available if any supporting provider is enabled.",
34
- modelsImage: "Image generation",
35
- modelsVideo: "Video generation",
36
- modelsSearch: "X search",
37
- modelsWebSearch: "Web search",
38
- modelsSave: "Save changes",
39
- modelsUnavailable: "Currently unavailable",
23
+ modelsEdit: 'Edit model list',
24
+ modelsHint: 'Configure model visibility, default reasoning effort, context and tools here; Save changes below submits them together with the account settings. Hidden models remain usable by existing sessions; tool changes apply to new sessions.',
25
+ modelsAutomatic: 'Automatically show all models, including new models',
26
+ modelsSelectAll: 'Select all',
27
+ modelsSelectNone: 'Clear selection',
28
+ modelsContext: 'Context (tokens)',
29
+ modelsContextBounds: 'Default {default} · Maximum {max}',
30
+ modelsContextHint: 'Leave blank to follow the provider. The requested window is capped by the account’s advertised maximum; account pools use the smallest member window. This controls local history and compaction, not the API’s capacity.',
31
+ modelsContextInvalid: 'Enter a positive whole number of tokens for {model}.',
32
+ modelsTools: 'Provider tools',
33
+ modelsToolsHint: 'Changes apply only to sessions created after saving. Existing sessions keep their tools. Shared tools remain available if any supporting provider is enabled.',
34
+ modelsImage: 'Image generation',
35
+ modelsVideo: 'Video generation',
36
+ modelsSearch: 'X search',
37
+ modelsWebSearch: 'Web search',
38
+ modelsSave: 'Save changes',
39
+ modelsUnavailable: 'Currently unavailable',
40
+ claudeCacheTtl: 'Prompt cache lifetime',
41
+ claudeCacheTtlFollowConfig: 'Follow config',
42
+ claudeCacheTtl5m: '5 minutes',
43
+ claudeCacheTtl1h: '1 hour',
44
+ claudeCacheTtlHint: 'Overrides the claudePromptCacheTtl config for this Claude route; Follow config uses the configured value. Saved changes apply from the next request. One hour keeps cached prefixes longer but writes them at a higher input price; compaction and session-title requests stay at five minutes.',
40
45
  nav: 'Subscriptions',
41
46
  intro: 'Log a subscription provider in or out. Login opens the provider’s authorization page in a new tab; headless setups can paste the callback URL or code instead.',
42
47
  unavailable: 'Connection unavailable; subscription status cannot be loaded.',
@@ -206,21 +211,21 @@ export const en = {
206
211
  ollamaWebOn: 'Web search/fetch enabled',
207
212
  ollamaWebOff: 'Web search/fetch off',
208
213
  ollamaManageTitle: 'Manage Ollama Cloud',
209
- ollamaManageHint: 'Fetch the Cloud list, tick the models this route serves, then Save. The picker '
210
- + 'shows the ticked models in order; the API key itself stays in DSH credentials.',
214
+ ollamaManageHint: 'Fetch the Cloud list, tick the models this route serves, then Save. The picker ' +
215
+ 'shows the ticked models in order; the API key itself stays in DSH credentials.',
211
216
  ollamaFetch: 'Fetch cloud models',
212
217
  ollamaFetching: 'Fetching…',
213
218
  ollamaKeyPlaceholder: 'One-time API key (optional)',
214
- ollamaKeyHint: 'A key typed here is used for this fetch only and is never saved. Leave it '
215
- + 'blank to use the stored credential.',
219
+ ollamaKeyHint: 'A key typed here is used for this fetch only and is never saved. Leave it ' +
220
+ 'blank to use the stored credential.',
216
221
  ollamaFetchFailed: 'Could not fetch cloud models: {message}',
217
222
  ollamaCandidatesCount: '{count} returned',
218
223
  ollamaCandidatesEmpty: 'No cloud models returned.',
219
224
  ollamaModelsEmpty: 'No models configured. Fetch the cloud list and tick the ones to keep.',
220
225
  ollamaModelsLoadFailed: 'Could not load Ollama settings: {message}',
221
226
  ollamaModelsSaveFailed: 'Could not save Ollama settings: {message}',
222
- ollamaConfigureHint: 'No API key found at {ref}. Add it to the credentials file '
223
- + '(~/.dsh/.credentials.yaml).',
227
+ ollamaConfigureHint: 'No API key found at {ref}. Add it to the credentials file ' +
228
+ '(~/.dsh/.credentials.yaml).',
224
229
  ollamaDisplayName: 'Display name',
225
230
  ollamaRowDetails: 'Details',
226
231
  ollamaEffortsUnknown: 'This model reasons; its level set will come from live discovery.',
@@ -228,16 +233,16 @@ export const en = {
228
233
  ollamaMoveDown: 'Move down',
229
234
  ollamaBaseURL: 'Base URL',
230
235
  ollamaApiKeyRef: 'API key reference',
231
- ollamaConnectionHint: "The base URL receives this route's requests and the credential lookup; the "
232
- + "reference names the DSH credential, not the key itself. Requests send "
233
- + "the resolved key to that address, so point it only at a host you trust.",
234
- ollamaWebHint: 'Enables the Ollama Cloud web search and fetch providers. The host still '
235
- + 'has to select them before the web tools use them.',
236
- ollamaCatalogOverride: "A profile pins this route's model list; the picker ignores store models "
237
- + "until that override is removed.",
236
+ ollamaConnectionHint: "The base URL receives this route's requests and the credential lookup; the " +
237
+ 'reference names the DSH credential, not the key itself. Requests send ' +
238
+ 'the resolved key to that address, so point it only at a host you trust.',
239
+ ollamaWebHint: 'Enables the Ollama Cloud web search and fetch providers. The host still ' +
240
+ 'has to select them before the web tools use them.',
241
+ ollamaCatalogOverride: "A profile pins this route's model list; the picker ignores store models " +
242
+ 'until that override is removed.',
238
243
  ollamaResetDefaults: 'Restore deployment defaults',
239
- ollamaResetConfirm: 'Clear every saved Ollama override? The profile values and built-in '
240
- + 'defaults apply again.',
244
+ ollamaResetConfirm: 'Clear every saved Ollama override? The profile values and built-in ' +
245
+ 'defaults apply again.',
241
246
  ollamaCapVision: 'vision',
242
247
  ollamaCapThinking: 'thinking',
243
248
  ollamaContext: 'context {tokens}',
@@ -263,23 +268,28 @@ export const zh = {
263
268
  accountsNoModels: '此账号暂未返回模型。',
264
269
  accountsCatalogUnavailable: '暂时无法获取模型目录,已保存的模型选择会被保留。',
265
270
  modelsPartialSave: '部分推理档已保存,其余更改仍保留在草稿中,请重试完成保存。',
266
- modelsEdit: "编辑模型列表",
267
- modelsHint: "在此配置模型显示、默认推理档、上下文与工具,底部的「保存更改」会连同账号设置一起提交。隐藏模型不影响已有会话;工具开关对新建会话生效。",
268
- modelsAutomatic: "自动显示全部模型(包含以后新增的模型)",
269
- modelsSelectAll: "全选",
270
- modelsSelectNone: "清空选择",
271
- modelsContext: "上下文(token)",
272
- modelsContextBounds: "默认 {default} · 最大 {max}",
273
- modelsContextHint: "留空跟随服务商。配置值按账号返回的最大窗口限制;账号池取各成员的最小窗口。此设置控制本地历史保留和压缩时机,不会扩大 API 本身的容量。",
274
- modelsContextInvalid: "请为 {model} 输入正整数 token 数。",
275
- modelsTools: "Provider 工具",
276
- modelsToolsHint: "仅对保存后新建的会话生效,已有会话保留原工具。任一支持的服务商启用共享工具时,该工具仍会显示。",
277
- modelsImage: "图片生成",
278
- modelsVideo: "视频生成",
279
- modelsSearch: "X 搜索",
280
- modelsWebSearch: "网页搜索",
281
- modelsSave: "保存更改",
282
- modelsUnavailable: "当前不可用",
271
+ modelsEdit: '编辑模型列表',
272
+ modelsHint: '在此配置模型显示、默认推理档、上下文与工具,底部的「保存更改」会连同账号设置一起提交。隐藏模型不影响已有会话;工具开关对新建会话生效。',
273
+ modelsAutomatic: '自动显示全部模型(包含以后新增的模型)',
274
+ modelsSelectAll: '全选',
275
+ modelsSelectNone: '清空选择',
276
+ modelsContext: '上下文(token)',
277
+ modelsContextBounds: '默认 {default} · 最大 {max}',
278
+ modelsContextHint: '留空跟随服务商。配置值按账号返回的最大窗口限制;账号池取各成员的最小窗口。此设置控制本地历史保留和压缩时机,不会扩大 API 本身的容量。',
279
+ modelsContextInvalid: '请为 {model} 输入正整数 token 数。',
280
+ modelsTools: 'Provider 工具',
281
+ modelsToolsHint: '仅对保存后新建的会话生效,已有会话保留原工具。任一支持的服务商启用共享工具时,该工具仍会显示。',
282
+ modelsImage: '图片生成',
283
+ modelsVideo: '视频生成',
284
+ modelsSearch: 'X 搜索',
285
+ modelsWebSearch: '网页搜索',
286
+ modelsSave: '保存更改',
287
+ modelsUnavailable: '当前不可用',
288
+ claudeCacheTtl: '提示词缓存时长',
289
+ claudeCacheTtlFollowConfig: '跟随配置',
290
+ claudeCacheTtl5m: '5 分钟',
291
+ claudeCacheTtl1h: '1 小时',
292
+ claudeCacheTtlHint: '覆盖此 Claude 路由的 claudePromptCacheTtl 配置;选择「跟随配置」时使用配置值。保存后自下一次请求生效。1 小时可更久保留缓存前缀,但写入按更高的输入价格计费;压缩与会话标题请求仍为 5 分钟。',
283
293
  nav: '订阅',
284
294
  intro: '在此登录或退出订阅服务商。点击登录会在新标签页打开服务商的授权页面;无浏览器环境可改为粘贴回调 URL 或授权码。',
285
295
  unavailable: '连接不可用,无法加载订阅状态。',
@@ -468,8 +478,8 @@ export const zh = {
468
478
  ollamaMoveDown: '下移',
469
479
  ollamaBaseURL: '基础 URL',
470
480
  ollamaApiKeyRef: 'API 密钥引用',
471
- ollamaConnectionHint: '基础 URL 用于此路由的请求与凭据查询;引用是 DSH 凭据的名称,不是密钥本身。'
472
- + '请求会把解析出的密钥发往该地址,请只填写可信主机。',
481
+ ollamaConnectionHint: '基础 URL 用于此路由的请求与凭据查询;引用是 DSH 凭据的名称,不是密钥本身。' +
482
+ '请求会把解析出的密钥发往该地址,请只填写可信主机。',
473
483
  ollamaWebHint: '启用 Ollama Cloud 的网页搜索与抓取能力。宿主仍需选择它们,网页工具才会使用。',
474
484
  ollamaCatalogOverride: '配置档案固定了此路由的模型列表;在移除该覆盖前,选择器会忽略存储中的模型。',
475
485
  ollamaResetDefaults: '恢复部署默认值',
@@ -17,7 +17,7 @@
17
17
  */
18
18
  export function adoptCandidates(current, candidates, selectedIds) {
19
19
  const models = [...(current ?? [])];
20
- const present = new Set(models.map(model => model.id));
20
+ const present = new Set(models.map((model) => model.id));
21
21
  const selected = new Set(selectedIds);
22
22
  for (const candidate of candidates) {
23
23
  if (!selected.has(candidate.id) || present.has(candidate.id))
@@ -26,7 +26,9 @@ export function adoptCandidates(current, candidates, selectedIds) {
26
26
  models.push({
27
27
  id: candidate.id,
28
28
  name: candidate.name,
29
- ...(candidate.contextWindow === undefined ? {} : { contextWindow: candidate.contextWindow }),
29
+ ...(candidate.contextWindow === undefined
30
+ ? {}
31
+ : { contextWindow: candidate.contextWindow }),
30
32
  ...(candidate.vision ? { vision: true } : {}),
31
33
  ...(candidate.thinking ? { thinking: true } : {}),
32
34
  // The vendor's default is not copied: defaultEffort in the store is
@@ -48,7 +50,7 @@ export function adoptCandidates(current, candidates, selectedIds) {
48
50
  */
49
51
  export function moveModel(models, id, delta) {
50
52
  const next = [...models];
51
- const index = next.findIndex(model => model.id === id);
53
+ const index = next.findIndex((model) => model.id === id);
52
54
  const target = index + delta;
53
55
  if (index === -1 || target < 0 || target >= next.length)
54
56
  return next;
@@ -64,7 +66,7 @@ export function moveModel(models, id, delta) {
64
66
  * @returns a new list; the input array is not mutated.
65
67
  */
66
68
  export function removeModel(models, id) {
67
- return models.filter(model => model.id !== id);
69
+ return models.filter((model) => model.id !== id);
68
70
  }
69
71
  /**
70
72
  * Short context-window label for a model row.
@@ -91,7 +93,7 @@ export function contextLabel(contextWindow) {
91
93
  * @returns a new list; the input array is not mutated.
92
94
  */
93
95
  export function renameModel(models, id, name) {
94
- return models.map(model => {
96
+ return models.map((model) => {
95
97
  if (model.id !== id)
96
98
  return model;
97
99
  const next = { ...model };
@@ -112,7 +114,7 @@ export function renameModel(models, id, name) {
112
114
  * @returns a new list; the input array is not mutated.
113
115
  */
114
116
  export function setModelEffort(models, id, effort) {
115
- return models.map(model => {
117
+ return models.map((model) => {
116
118
  if (model.id !== id)
117
119
  return model;
118
120
  if (effort === '') {
@@ -133,7 +135,7 @@ export function setModelEffort(models, id, effort) {
133
135
  * @returns a new list; the input array is not mutated.
134
136
  */
135
137
  export function setModelContext(models, id, tokens) {
136
- return models.map(model => {
138
+ return models.map((model) => {
137
139
  if (model.id !== id)
138
140
  return model;
139
141
  const next = { ...model };
@@ -169,7 +171,7 @@ export function parseContextInput(text) {
169
171
  * @returns the new list and stash; neither input is mutated.
170
172
  */
171
173
  export function untickModel(models, stash, id) {
172
- const row = models.find(model => model.id === id);
174
+ const row = models.find((model) => model.id === id);
173
175
  if (row === undefined)
174
176
  return { models: [...models], stash };
175
177
  return { models: removeModel(models, id), stash: new Map(stash).set(id, row) };
@@ -186,7 +188,7 @@ export function untickModel(models, stash, id) {
186
188
  * @returns a new list and the stash without the restored row.
187
189
  */
188
190
  export function tickModel(models, stash, candidates, id) {
189
- if (models.some(model => model.id === id))
191
+ if (models.some((model) => model.id === id))
190
192
  return { models: [...models], stash };
191
193
  const stashed = stash.get(id);
192
194
  if (stashed === undefined)
@@ -237,10 +239,17 @@ export function untickModels(models, stash, ids) {
237
239
  * @returns the options in picker order.
238
240
  */
239
241
  export function effortOptions(row, fetched, labels) {
240
- const ids = row.efforts ?? fetched ?? labels?.map(entry => entry.id) ?? [];
241
- const options = ids.map(id => ({ id, name: labels?.find(entry => entry.id === id)?.name ?? id }));
242
+ const ids = row.efforts ?? fetched ?? labels?.map((entry) => entry.id) ?? [];
243
+ const options = ids.map((id) => ({
244
+ id,
245
+ name: labels?.find((entry) => entry.id === id)?.name ?? id,
246
+ }));
242
247
  if (row.defaultEffort !== undefined && !ids.includes(row.defaultEffort)) {
243
- options.push({ id: row.defaultEffort, name: row.defaultEffort, unavailable: true });
248
+ options.push({
249
+ id: row.defaultEffort,
250
+ name: row.defaultEffort,
251
+ unavailable: true,
252
+ });
244
253
  }
245
254
  return options;
246
255
  }
@@ -1,15 +1,17 @@
1
1
  /** Explain client-side gating; the server independently revalidates before spending. */
2
2
  export function resetActionBlock(usage, now = Date.now()) {
3
- const weekly = usage.windows?.find(w => w.kind === 'weekly' && w.scope === undefined);
3
+ const weekly = usage.windows?.find((w) => w.kind === 'weekly' && w.scope === undefined);
4
4
  if (!weekly || !Number.isFinite(weekly.usedPercent))
5
5
  return 'resetUseRefresh';
6
6
  if (weekly.usedPercent < 80)
7
7
  return 'resetUseGuard';
8
- if (weekly.resetsAt === undefined || weekly.resetsAt <= now || usage.resetCreditsError)
8
+ if (weekly.resetsAt === undefined ||
9
+ weekly.resetsAt <= now ||
10
+ usage.resetCreditsError)
9
11
  return 'resetUseRefresh';
10
- if (!usage.resetCredits?.some(c => c.id))
12
+ if (!usage.resetCredits?.some((c) => c.id))
11
13
  return 'resetUseRestart';
12
- if (!usage.resetCredits.some(c => c.id && (c.expiresAt === undefined || c.expiresAt > now)))
14
+ if (!usage.resetCredits.some((c) => c.id && (c.expiresAt === undefined || c.expiresAt > now)))
13
15
  return 'resetUseRefresh';
14
16
  return undefined;
15
17
  }
@@ -29,7 +29,7 @@ export declare function resetCreditRowName(t: Translate, credit: ResetCreditView
29
29
  /** Claude omits an empty grant list; Codex still shows a defined, possibly empty, list. */
30
30
  export declare function showsResetCredits(provider: 'codex' | 'claude', credits: readonly ResetCreditView[] | undefined): boolean;
31
31
  /** The error line the settings card mounts. Claude never interpolates provider text. */
32
- export declare function ResetCreditsErrorLine({ provider, message, t }: {
32
+ export declare function ResetCreditsErrorLine({ provider, message, t, }: {
33
33
  provider: 'codex' | 'claude';
34
34
  message: string;
35
35
  t: Translate;
@@ -19,7 +19,8 @@ export function resetCreditState(credit, now) {
19
19
  return 'paused';
20
20
  if (credit.resetsLeft === 0)
21
21
  return 'exhausted';
22
- if ((credit.cooldownUntil !== undefined && credit.cooldownUntil > now) || credit.usableNow === false)
22
+ if ((credit.cooldownUntil !== undefined && credit.cooldownUntil > now) ||
23
+ credit.usableNow === false)
23
24
  return 'notUsable';
24
25
  return 'available';
25
26
  }
@@ -37,7 +38,9 @@ export function resetCreditsAvailableCount(credits, now, mode) {
37
38
  const state = resetCreditState(credit, now);
38
39
  if (state === 'expired' || state === 'paused')
39
40
  continue;
40
- if (typeof credit.resetsLeft === 'number' && Number.isFinite(credit.resetsLeft) && credit.resetsLeft > 0) {
41
+ if (typeof credit.resetsLeft === 'number' &&
42
+ Number.isFinite(credit.resetsLeft) &&
43
+ credit.resetsLeft > 0) {
41
44
  sum += credit.resetsLeft;
42
45
  }
43
46
  }
@@ -46,7 +49,9 @@ export function resetCreditsAvailableCount(credits, now, mode) {
46
49
  function expiryText(t, credit) {
47
50
  return credit.expiresAt === undefined
48
51
  ? t('resetCreditExpiryUnknown')
49
- : t('resetCreditExpires', { date: new Date(credit.expiresAt).toLocaleString() });
52
+ : t('resetCreditExpires', {
53
+ date: new Date(credit.expiresAt).toLocaleString(),
54
+ });
50
55
  }
51
56
  function remainingText(t, credit) {
52
57
  const left = credit.resetsLeft;
@@ -62,9 +67,18 @@ function remainingText(t, credit) {
62
67
  /** Accessible name of one Claude grant row: state, remaining, and expiry, not a control name. */
63
68
  export function resetCreditRowName(t, credit, now) {
64
69
  const state = resetCreditState(credit, now);
65
- const parts = [t('resetCreditFull'), t(STATE_KEYS[state]), remainingText(t, credit), expiryText(t, credit)];
66
- if (state === 'notUsable' && credit.cooldownUntil !== undefined && credit.cooldownUntil > now) {
67
- parts.push(t('resetCreditCooldownUntil', { date: new Date(credit.cooldownUntil).toLocaleString() }));
70
+ const parts = [
71
+ t('resetCreditFull'),
72
+ t(STATE_KEYS[state]),
73
+ remainingText(t, credit),
74
+ expiryText(t, credit),
75
+ ];
76
+ if (state === 'notUsable' &&
77
+ credit.cooldownUntil !== undefined &&
78
+ credit.cooldownUntil > now) {
79
+ parts.push(t('resetCreditCooldownUntil', {
80
+ date: new Date(credit.cooldownUntil).toLocaleString(),
81
+ }));
68
82
  }
69
83
  return parts.join(', ');
70
84
  }
@@ -75,15 +89,21 @@ export function showsResetCredits(provider, credits) {
75
89
  return (credits?.length ?? 0) > 0;
76
90
  }
77
91
  /** The error line the settings card mounts. Claude never interpolates provider text. */
78
- export function ResetCreditsErrorLine({ provider, message, t }) {
79
- return _jsx("p", { style: cardStyles.error, children: resetCreditsErrorText(provider, message, t) });
92
+ export function ResetCreditsErrorLine({ provider, message, t, }) {
93
+ return (_jsx("p", { style: cardStyles.error, children: resetCreditsErrorText(provider, message, t) }));
80
94
  }
81
95
  /** Fixed sentence for Claude. Codex may include the lookup message; Claude must not. */
82
96
  export function resetCreditsErrorText(provider, message, t) {
83
- return provider === 'claude' ? t('resetCreditsErrorFixed') : t('resetCreditsError', { message });
97
+ return provider === 'claude'
98
+ ? t('resetCreditsErrorFixed')
99
+ : t('resetCreditsError', { message });
84
100
  }
85
101
  const summaryStyle = {
86
- ...cardStyles.usageMeta, cursor: 'pointer', listStyle: 'none', justifyContent: 'flex-start', gap: 6,
102
+ ...cardStyles.usageMeta,
103
+ cursor: 'pointer',
104
+ listStyle: 'none',
105
+ justifyContent: 'flex-start',
106
+ gap: 6,
87
107
  };
88
108
  /**
89
109
  * The closed disclosure both providers share. Claude rows are plain text:
@@ -92,12 +112,41 @@ const summaryStyle = {
92
112
  */
93
113
  export function ResetCreditsDisclosure({ mode, credits, t, now = Date.now(), nextCredit, useAction, statusMessage, }) {
94
114
  const count = resetCreditsAvailableCount(credits, now, mode);
95
- return (_jsxs("details", { className: "subscriptions-reset-credits", style: cardStyles.usageRow, children: [_jsxs("summary", { style: summaryStyle, children: [_jsx("svg", { "aria-hidden": "true", width: "12", height: "12", viewBox: "0 0 16 16", style: { flexShrink: 0 }, children: _jsx("path", { d: "m6 3 5 5-5 5", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("span", { children: t('resetCreditsTitle') }), mode === 'grants' && _jsx("span", { children: t('resetCreditReadOnlyLabel') }), _jsx("span", { style: { marginLeft: 'auto' }, children: t('resetCreditsAvailable', { count }) })] }), _jsx("style", { children: '.subscriptions-reset-credits > summary::-webkit-details-marker { display: none; }'
96
- + '.subscriptions-reset-credits[open] > summary > svg { transform: rotate(90deg); }' }), _jsxs("div", { style: { paddingLeft: 18, marginTop: 6 }, children: [mode === 'grants' && _jsx("p", { style: cardStyles.status, children: t('resetCreditReadOnly') }), credits.map((credit, index) => {
115
+ return (_jsxs("details", { className: "subscriptions-reset-credits", style: cardStyles.usageRow, children: [_jsxs("summary", { style: summaryStyle, children: [_jsx("svg", { "aria-hidden": "true", width: "12", height: "12", viewBox: "0 0 16 16", style: { flexShrink: 0 }, children: _jsx("path", { d: "m6 3 5 5-5 5", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("span", { children: t('resetCreditsTitle') }), mode === 'grants' && _jsx("span", { children: t('resetCreditReadOnlyLabel') }), _jsx("span", { style: { marginLeft: 'auto' }, children: t('resetCreditsAvailable', { count }) })] }), _jsx("style", { children: '.subscriptions-reset-credits > summary::-webkit-details-marker { display: none; }' +
116
+ '.subscriptions-reset-credits[open] > summary > svg { transform: rotate(90deg); }' }), _jsxs("div", { style: { paddingLeft: 18, marginTop: 6 }, children: [mode === 'grants' && (_jsx("p", { style: cardStyles.status, children: t('resetCreditReadOnly') })), credits.map((credit, index) => {
97
117
  const state = resetCreditState(credit, now);
98
- const showUse = mode === 'credits' && useAction !== undefined && credit === nextCredit;
99
- return (_jsxs("div", { "data-reset-state": mode === 'grants' ? state : undefined, "data-reset-claimable": mode === 'grants' && credit.claimable === true ? 'true' : undefined, role: mode === 'grants' ? 'group' : undefined, "aria-label": mode === 'grants' ? resetCreditRowName(t, credit, now) : undefined, style: { ...cardStyles.usageMeta, minHeight: 28, gap: 12, cursor: mode === 'grants' ? 'default' : undefined }, children: [_jsxs("span", { style: { display: 'inline-flex', alignItems: 'center', gap: 8, flexShrink: 0 }, children: [t('resetCreditFull'), mode === 'grants' && (_jsx("span", { "aria-hidden": "true", "data-reset-state-word": state, children: t(STATE_KEYS[state]) })), showUse && (_jsx("button", { type: "button", "aria-disabled": useAction.disabled, title: useAction.title, style: { minHeight: 22, height: 22, padding: '0 7px', borderRadius: 6,
100
- opacity: useAction.disabled ? 0.35 : 1, cursor: useAction.disabled ? 'not-allowed' : 'pointer' }, onClick: () => { if (!useAction.disabled)
101
- useAction.onUse(); }, children: useAction.busy ? t('resetUseChecking') : useAction.label }))] }), _jsxs("span", { style: { textAlign: 'right' }, children: [mode === 'grants' && _jsxs("span", { "aria-hidden": "true", children: [remainingText(t, credit), " \u00B7 "] }), mode === 'grants' && state === 'notUsable' && credit.cooldownUntil !== undefined && credit.cooldownUntil > now && (_jsxs("span", { "aria-hidden": "true", children: [t('resetCreditCooldownUntil', { date: new Date(credit.cooldownUntil).toLocaleString() }), " \u00B7 "] })), _jsx("span", { "aria-hidden": mode === 'grants' ? true : undefined, children: expiryText(t, credit) })] })] }, credit.id ?? index));
102
- }), statusMessage !== undefined && statusMessage !== '' && _jsx("p", { role: "status", style: cardStyles.status, children: statusMessage })] })] }));
118
+ const showUse = mode === 'credits' &&
119
+ useAction !== undefined &&
120
+ credit === nextCredit;
121
+ return (_jsxs("div", { "data-reset-state": mode === 'grants' ? state : undefined, "data-reset-claimable": mode === 'grants' && credit.claimable === true
122
+ ? 'true'
123
+ : undefined, role: mode === 'grants' ? 'group' : undefined, "aria-label": mode === 'grants'
124
+ ? resetCreditRowName(t, credit, now)
125
+ : undefined, style: {
126
+ ...cardStyles.usageMeta,
127
+ minHeight: 28,
128
+ gap: 12,
129
+ cursor: mode === 'grants' ? 'default' : undefined,
130
+ }, children: [_jsxs("span", { style: {
131
+ display: 'inline-flex',
132
+ alignItems: 'center',
133
+ gap: 8,
134
+ flexShrink: 0,
135
+ }, children: [t('resetCreditFull'), mode === 'grants' && (_jsx("span", { "aria-hidden": "true", "data-reset-state-word": state, children: t(STATE_KEYS[state]) })), showUse && (_jsx("button", { type: "button", "aria-disabled": useAction.disabled, title: useAction.title, style: {
136
+ minHeight: 22,
137
+ height: 22,
138
+ padding: '0 7px',
139
+ borderRadius: 6,
140
+ opacity: useAction.disabled ? 0.35 : 1,
141
+ cursor: useAction.disabled ? 'not-allowed' : 'pointer',
142
+ }, onClick: () => {
143
+ if (!useAction.disabled)
144
+ useAction.onUse();
145
+ }, children: useAction.busy ? t('resetUseChecking') : useAction.label }))] }), _jsxs("span", { style: { textAlign: 'right' }, children: [mode === 'grants' && (_jsxs("span", { "aria-hidden": "true", children: [remainingText(t, credit), " \u00B7 "] })), mode === 'grants' &&
146
+ state === 'notUsable' &&
147
+ credit.cooldownUntil !== undefined &&
148
+ credit.cooldownUntil > now && (_jsxs("span", { "aria-hidden": "true", children: [t('resetCreditCooldownUntil', {
149
+ date: new Date(credit.cooldownUntil).toLocaleString(),
150
+ }), ' ', "\u00B7", ' '] })), _jsx("span", { "aria-hidden": mode === 'grants' ? true : undefined, children: expiryText(t, credit) })] })] }, credit.id ?? index));
151
+ }), statusMessage !== undefined && statusMessage !== '' && (_jsx("p", { role: "status", style: cardStyles.status, children: statusMessage }))] })] }));
103
152
  }
@@ -1,48 +1,118 @@
1
1
  /** Shared visual language for OAuth, Cursor, and built-in provider cards. */
2
2
  export const subscriptionCardStyles = {
3
3
  card: {
4
- border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 12,
5
- padding: '12px 14px', display: 'flex', flexDirection: 'column', gap: 6,
4
+ border: '1px solid var(--dsw-alias-border-l2)',
5
+ borderRadius: 12,
6
+ padding: '12px 14px',
7
+ display: 'flex',
8
+ flexDirection: 'column',
9
+ gap: 6,
6
10
  color: 'var(--dsw-alias-label-primary)',
7
11
  },
8
12
  header: { display: 'flex', alignItems: 'center', gap: 8 },
9
13
  dot: { width: 8, height: 8, borderRadius: '50%', flexShrink: 0 },
10
- name: { fontWeight: 500, fontSize: 14, lineHeight: '22px', color: 'var(--dsw-alias-label-primary)' },
11
- status: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },
12
- error: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-error-primary)' },
13
- actions: { display: 'flex', gap: 8, marginTop: 4, alignItems: 'center', flexWrap: 'wrap' },
14
+ name: {
15
+ fontWeight: 500,
16
+ fontSize: 14,
17
+ lineHeight: '22px',
18
+ color: 'var(--dsw-alias-label-primary)',
19
+ },
20
+ status: {
21
+ margin: 0,
22
+ fontSize: 12,
23
+ lineHeight: '18px',
24
+ color: 'var(--dsw-alias-label-tertiary)',
25
+ },
26
+ error: {
27
+ margin: 0,
28
+ fontSize: 12,
29
+ lineHeight: '18px',
30
+ color: 'var(--dsw-alias-state-error-primary)',
31
+ },
32
+ actions: {
33
+ display: 'flex',
34
+ gap: 8,
35
+ marginTop: 4,
36
+ alignItems: 'center',
37
+ flexWrap: 'wrap',
38
+ },
14
39
  button: {
15
- boxSizing: 'border-box', display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
16
- height: 28, padding: '0 10px', borderRadius: 14,
17
- border: '1px solid var(--dsw-alias-border-l2)', background: 'transparent',
18
- color: 'var(--dsw-alias-label-primary)', font: 'inherit', fontSize: 12, lineHeight: '18px',
40
+ boxSizing: 'border-box',
41
+ display: 'inline-flex',
42
+ alignItems: 'center',
43
+ justifyContent: 'center',
44
+ height: 28,
45
+ padding: '0 10px',
46
+ borderRadius: 14,
47
+ border: '1px solid var(--dsw-alias-border-l2)',
48
+ background: 'transparent',
49
+ color: 'var(--dsw-alias-label-primary)',
50
+ font: 'inherit',
51
+ fontSize: 12,
52
+ lineHeight: '18px',
19
53
  cursor: 'pointer',
20
54
  },
21
55
  account: {
22
- display: 'flex', flexDirection: 'column', gap: 6,
23
- border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8,
24
- padding: '8px 10px', marginTop: 4,
56
+ display: 'flex',
57
+ flexDirection: 'column',
58
+ gap: 6,
59
+ border: '1px solid var(--dsw-alias-border-l2)',
60
+ borderRadius: 8,
61
+ padding: '8px 10px',
62
+ marginTop: 4,
25
63
  },
26
64
  accountHeader: { display: 'flex', alignItems: 'center', gap: 8 },
27
- accountName: { fontSize: 13, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)', userSelect: 'all' },
65
+ accountName: {
66
+ fontSize: 13,
67
+ lineHeight: '20px',
68
+ color: 'var(--dsw-alias-label-primary)',
69
+ userSelect: 'all',
70
+ },
28
71
  defaultStar: { color: 'var(--dsw-alias-state-warn-label)' },
29
72
  usage: {
30
- display: 'flex', flexDirection: 'column', gap: 6, marginTop: 4,
31
- borderTop: '1px solid var(--dsw-alias-border-l2)', paddingTop: 8,
73
+ display: 'flex',
74
+ flexDirection: 'column',
75
+ gap: 6,
76
+ marginTop: 4,
77
+ borderTop: '1px solid var(--dsw-alias-border-l2)',
78
+ paddingTop: 8,
32
79
  },
33
80
  usageHeader: { display: 'flex', alignItems: 'center', gap: 8 },
34
- usageTitle: { fontSize: 12, lineHeight: '18px', fontWeight: 500, color: 'var(--dsw-alias-label-secondary)' },
35
- usagePlan: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },
81
+ usageTitle: {
82
+ fontSize: 12,
83
+ lineHeight: '18px',
84
+ fontWeight: 500,
85
+ color: 'var(--dsw-alias-label-secondary)',
86
+ },
87
+ usagePlan: {
88
+ fontSize: 12,
89
+ lineHeight: '18px',
90
+ color: 'var(--dsw-alias-label-tertiary)',
91
+ },
36
92
  usageRefresh: {
37
- boxSizing: 'border-box', display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
38
- height: 22, padding: '0 8px', borderRadius: 11, marginLeft: 'auto',
39
- border: '1px solid var(--dsw-alias-border-l2)', background: 'transparent',
40
- color: 'var(--dsw-alias-label-secondary)', font: 'inherit', fontSize: 12, lineHeight: '18px',
93
+ boxSizing: 'border-box',
94
+ display: 'inline-flex',
95
+ alignItems: 'center',
96
+ justifyContent: 'center',
97
+ height: 22,
98
+ padding: '0 8px',
99
+ borderRadius: 11,
100
+ marginLeft: 'auto',
101
+ border: '1px solid var(--dsw-alias-border-l2)',
102
+ background: 'transparent',
103
+ color: 'var(--dsw-alias-label-secondary)',
104
+ font: 'inherit',
105
+ fontSize: 12,
106
+ lineHeight: '18px',
41
107
  cursor: 'pointer',
42
108
  },
43
109
  usageRow: { display: 'flex', flexDirection: 'column', gap: 3 },
44
110
  usageMeta: {
45
- display: 'flex', justifyContent: 'space-between', gap: 8,
46
- fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)',
111
+ display: 'flex',
112
+ justifyContent: 'space-between',
113
+ gap: 8,
114
+ fontSize: 12,
115
+ lineHeight: '18px',
116
+ color: 'var(--dsw-alias-label-tertiary)',
47
117
  },
48
118
  };
@@ -24,8 +24,10 @@ export function setUsageColorPreset(value) {
24
24
  window.dispatchEvent(new Event(EVENT));
25
25
  }
26
26
  export function subscribeUsageColorPreset(notify) {
27
- const storage = (event) => { if (event.key === KEY || event.key === null)
28
- notify(); };
27
+ const storage = (event) => {
28
+ if (event.key === KEY || event.key === null)
29
+ notify();
30
+ };
29
31
  window.addEventListener(EVENT, notify);
30
32
  window.addEventListener('storage', storage);
31
33
  return () => {