dsh-subscriptions 0.1.5 → 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 (110) hide show
  1. package/README.md +212 -154
  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.d.ts +73 -2
  6. package/lib/auth/rpc.js +124 -23
  7. package/lib/auth/store.js +80 -31
  8. package/lib/client/CursorCard.d.ts +1 -1
  9. package/lib/client/CursorCard.js +50 -16
  10. package/lib/client/ExternalUsageCards.d.ts +1 -1
  11. package/lib/client/ExternalUsageCards.js +37 -16
  12. package/lib/client/ImageGallery.d.ts +2 -2
  13. package/lib/client/ImageGallery.js +92 -33
  14. package/lib/client/ImageGenerateToolview.js +50 -14
  15. package/lib/client/OllamaCard.d.ts +13 -0
  16. package/lib/client/OllamaCard.js +94 -0
  17. package/lib/client/OllamaSettingsManager.d.ts +24 -0
  18. package/lib/client/OllamaSettingsManager.js +329 -0
  19. package/lib/client/ProviderAccountManager.d.ts +1 -1
  20. package/lib/client/ProviderAccountManager.js +164 -49
  21. package/lib/client/ProviderModelEditor.js +109 -26
  22. package/lib/client/SpeedSelect.d.ts +62 -14
  23. package/lib/client/SpeedSelect.js +257 -46
  24. package/lib/client/SubscriptionUsageBadge.d.ts +5 -11
  25. package/lib/client/SubscriptionUsageBadge.js +301 -112
  26. package/lib/client/SubscriptionsSection.d.ts +2 -0
  27. package/lib/client/SubscriptionsSection.js +259 -85
  28. package/lib/client/UsageBadgeDisplaySetting.js +35 -12
  29. package/lib/client/UsageMeter.d.ts +1 -1
  30. package/lib/client/UsageMeter.js +69 -27
  31. package/lib/client/VideoGenerateToolview.js +69 -17
  32. package/lib/client/account-preferences.d.ts +8 -0
  33. package/lib/client/account-preferences.js +20 -5
  34. package/lib/client/host-contract.d.ts +11 -2
  35. package/lib/client/host-contract.js +20 -3
  36. package/lib/client/index.d.ts +5 -5
  37. package/lib/client/index.js +34 -12
  38. package/lib/client/locales.d.ts +78 -0
  39. package/lib/client/locales.js +121 -34
  40. package/lib/client/ollama-draft.d.ts +229 -0
  41. package/lib/client/ollama-draft.js +255 -0
  42. package/lib/client/reset-action.js +6 -4
  43. package/lib/client/reset-credits-view.d.ts +1 -1
  44. package/lib/client/reset-credits-view.js +66 -17
  45. package/lib/client/subscription-card-styles.js +94 -24
  46. package/lib/client/usage-color-preferences.js +4 -2
  47. package/lib/client/usage-pace.d.ts +7 -0
  48. package/lib/client/usage-pace.js +43 -10
  49. package/lib/client.js +1647 -266
  50. package/lib/client.js.map +1 -1
  51. package/lib/http.js +1 -1
  52. package/lib/index.d.ts +28 -3
  53. package/lib/index.js +9329 -8217
  54. package/lib/model-defaults.js +4 -2
  55. package/lib/provider-settings.d.ts +14 -1
  56. package/lib/provider-settings.js +64 -20
  57. package/lib/providers/account-preferences.js +51 -22
  58. package/lib/providers/accounts.js +15 -9
  59. package/lib/providers/antigravity-oauth-client.js +2 -2
  60. package/lib/providers/antigravity.js +141 -68
  61. package/lib/providers/catalog-store.js +120 -41
  62. package/lib/providers/claude-cli-version.js +3 -3
  63. package/lib/providers/claude.d.ts +23 -3
  64. package/lib/providers/claude.js +167 -92
  65. package/lib/providers/codex-client-version.js +3 -3
  66. package/lib/providers/codex-search.js +40 -13
  67. package/lib/providers/codex.js +196 -112
  68. package/lib/providers/common.d.ts +14 -0
  69. package/lib/providers/common.js +118 -38
  70. package/lib/providers/copilot.js +143 -82
  71. package/lib/providers/cursor-adapter.js +42 -18
  72. package/lib/providers/cursor-auth.d.ts +1 -1
  73. package/lib/providers/cursor-auth.js +69 -24
  74. package/lib/providers/cursor-model-settings.js +14 -5
  75. package/lib/providers/cursor-usage.js +27 -13
  76. package/lib/providers/external-usage-controller.d.ts +9 -2
  77. package/lib/providers/external-usage-controller.js +30 -7
  78. package/lib/providers/external-usage.d.ts +8 -0
  79. package/lib/providers/external-usage.js +140 -20
  80. package/lib/providers/grok.js +152 -89
  81. package/lib/providers/image-pool.js +29 -11
  82. package/lib/providers/minimax-usage.js +31 -11
  83. package/lib/providers/npm-cli-version.js +10 -3
  84. package/lib/providers/ollama-settings.d.ts +90 -0
  85. package/lib/providers/ollama-settings.js +213 -0
  86. package/lib/providers/ollama-web.d.ts +46 -0
  87. package/lib/providers/ollama-web.js +231 -0
  88. package/lib/providers/ollama.d.ts +107 -0
  89. package/lib/providers/ollama.js +608 -0
  90. package/lib/providers/pool-family.js +11 -3
  91. package/lib/providers/pool-health.js +28 -8
  92. package/lib/providers/pool-usage.js +16 -9
  93. package/lib/providers/pool.d.ts +8 -0
  94. package/lib/providers/pool.js +81 -42
  95. package/lib/providers/rate-limit.js +8 -2
  96. package/lib/providers/replay.js +40 -17
  97. package/lib/providers/reset-redemption.js +18 -6
  98. package/lib/tools/image-generate.js +123 -65
  99. package/lib/tools/registration.js +5 -2
  100. package/lib/tools/video-generate.js +51 -31
  101. package/lib/tools/x-search.js +50 -22
  102. package/lib/translate/anthropic.js +85 -37
  103. package/lib/translate/antigravity-schema.js +71 -28
  104. package/lib/translate/antigravity-thinking.js +22 -9
  105. package/lib/translate/antigravity.js +141 -50
  106. package/lib/translate/chat-completions.js +67 -23
  107. package/lib/translate/resolved.js +55 -21
  108. package/lib/translate/responses.js +69 -29
  109. package/lib/translate/sse.js +4 -1
  110. package/package.json +26 -4
@@ -37,6 +37,11 @@ export declare const en: {
37
37
  modelsWebSearch: string;
38
38
  modelsSave: string;
39
39
  modelsUnavailable: string;
40
+ claudeCacheTtl: string;
41
+ claudeCacheTtlFollowConfig: string;
42
+ claudeCacheTtl5m: string;
43
+ claudeCacheTtl1h: string;
44
+ claudeCacheTtlHint: string;
40
45
  nav: string;
41
46
  intro: string;
42
47
  unavailable: string;
@@ -73,6 +78,7 @@ export declare const en: {
73
78
  usageRefresh: string;
74
79
  usageLoading: string;
75
80
  usageEmpty: string;
81
+ usageUnsupported: string;
76
82
  usageError: string;
77
83
  usageSession: string;
78
84
  usageWeekly: string;
@@ -199,6 +205,39 @@ export declare const en: {
199
205
  speedFastDescription: string;
200
206
  commandFast: string;
201
207
  commandFastUnavailable: string;
208
+ ollamaTitle: string;
209
+ ollamaStatus: string;
210
+ ollamaStatusNone: string;
211
+ ollamaWebOn: string;
212
+ ollamaWebOff: string;
213
+ ollamaManageTitle: string;
214
+ ollamaManageHint: string;
215
+ ollamaFetch: string;
216
+ ollamaFetching: string;
217
+ ollamaKeyPlaceholder: string;
218
+ ollamaKeyHint: string;
219
+ ollamaFetchFailed: string;
220
+ ollamaCandidatesCount: string;
221
+ ollamaCandidatesEmpty: string;
222
+ ollamaModelsEmpty: string;
223
+ ollamaModelsLoadFailed: string;
224
+ ollamaModelsSaveFailed: string;
225
+ ollamaConfigureHint: string;
226
+ ollamaDisplayName: string;
227
+ ollamaRowDetails: string;
228
+ ollamaEffortsUnknown: string;
229
+ ollamaMoveUp: string;
230
+ ollamaMoveDown: string;
231
+ ollamaBaseURL: string;
232
+ ollamaApiKeyRef: string;
233
+ ollamaConnectionHint: string;
234
+ ollamaWebHint: string;
235
+ ollamaCatalogOverride: string;
236
+ ollamaResetDefaults: string;
237
+ ollamaResetConfirm: string;
238
+ ollamaCapVision: string;
239
+ ollamaCapThinking: string;
240
+ ollamaContext: string;
202
241
  };
203
242
  /** zh strings, one per {@link en} key. */
204
243
  export declare const zh: {
@@ -238,6 +277,11 @@ export declare const zh: {
238
277
  modelsWebSearch: string;
239
278
  modelsSave: string;
240
279
  modelsUnavailable: string;
280
+ claudeCacheTtl: string;
281
+ claudeCacheTtlFollowConfig: string;
282
+ claudeCacheTtl5m: string;
283
+ claudeCacheTtl1h: string;
284
+ claudeCacheTtlHint: string;
241
285
  nav: string;
242
286
  intro: string;
243
287
  unavailable: string;
@@ -274,6 +318,7 @@ export declare const zh: {
274
318
  usageRefresh: string;
275
319
  usageLoading: string;
276
320
  usageEmpty: string;
321
+ usageUnsupported: string;
277
322
  usageError: string;
278
323
  usageSession: string;
279
324
  usageWeekly: string;
@@ -400,6 +445,39 @@ export declare const zh: {
400
445
  speedFastDescription: string;
401
446
  commandFast: string;
402
447
  commandFastUnavailable: string;
448
+ ollamaTitle: string;
449
+ ollamaStatus: string;
450
+ ollamaStatusNone: string;
451
+ ollamaWebOn: string;
452
+ ollamaWebOff: string;
453
+ ollamaManageTitle: string;
454
+ ollamaManageHint: string;
455
+ ollamaFetch: string;
456
+ ollamaFetching: string;
457
+ ollamaKeyPlaceholder: string;
458
+ ollamaKeyHint: string;
459
+ ollamaFetchFailed: string;
460
+ ollamaCandidatesCount: string;
461
+ ollamaCandidatesEmpty: string;
462
+ ollamaModelsEmpty: string;
463
+ ollamaModelsLoadFailed: string;
464
+ ollamaModelsSaveFailed: string;
465
+ ollamaConfigureHint: string;
466
+ ollamaDisplayName: string;
467
+ ollamaRowDetails: string;
468
+ ollamaEffortsUnknown: string;
469
+ ollamaMoveUp: string;
470
+ ollamaMoveDown: string;
471
+ ollamaBaseURL: string;
472
+ ollamaApiKeyRef: string;
473
+ ollamaConnectionHint: string;
474
+ ollamaWebHint: string;
475
+ ollamaCatalogOverride: string;
476
+ ollamaResetDefaults: string;
477
+ ollamaResetConfirm: string;
478
+ ollamaCapVision: string;
479
+ ollamaCapThinking: string;
480
+ ollamaContext: string;
403
481
  };
404
482
  /** The Subscriptions namespace key union (en is the key-set source of truth). */
405
483
  export type SubscriptionsKey = keyof typeof en;
@@ -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.',
@@ -73,6 +78,7 @@ export const en = {
73
78
  usageRefresh: 'Refresh',
74
79
  usageLoading: 'Loading usage…',
75
80
  usageEmpty: 'No usage windows reported.',
81
+ usageUnsupported: 'This endpoint has no usage surface.',
76
82
  usageError: 'Usage lookup failed: {message}',
77
83
  usageSession: '5-hour window',
78
84
  usageWeekly: 'Weekly',
@@ -199,6 +205,47 @@ export const en = {
199
205
  speedFastDescription: '1.5x speed, more usage',
200
206
  commandFast: 'Switch the Codex speed tier (Standard/Fast)',
201
207
  commandFastUnavailable: 'The current model has no fast tier; /fast only works on Codex models whose catalog advertises one',
208
+ ollamaTitle: 'Ollama Cloud',
209
+ ollamaStatus: '{count} model(s) in the picker',
210
+ ollamaStatusNone: 'No models configured',
211
+ ollamaWebOn: 'Web search/fetch enabled',
212
+ ollamaWebOff: 'Web search/fetch off',
213
+ ollamaManageTitle: 'Manage Ollama Cloud',
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.',
216
+ ollamaFetch: 'Fetch cloud models',
217
+ ollamaFetching: 'Fetching…',
218
+ ollamaKeyPlaceholder: 'One-time API key (optional)',
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.',
221
+ ollamaFetchFailed: 'Could not fetch cloud models: {message}',
222
+ ollamaCandidatesCount: '{count} returned',
223
+ ollamaCandidatesEmpty: 'No cloud models returned.',
224
+ ollamaModelsEmpty: 'No models configured. Fetch the cloud list and tick the ones to keep.',
225
+ ollamaModelsLoadFailed: 'Could not load Ollama settings: {message}',
226
+ ollamaModelsSaveFailed: 'Could not save Ollama settings: {message}',
227
+ ollamaConfigureHint: 'No API key found at {ref}. Add it to the credentials file ' +
228
+ '(~/.dsh/.credentials.yaml).',
229
+ ollamaDisplayName: 'Display name',
230
+ ollamaRowDetails: 'Details',
231
+ ollamaEffortsUnknown: 'This model reasons; its level set will come from live discovery.',
232
+ ollamaMoveUp: 'Move up',
233
+ ollamaMoveDown: 'Move down',
234
+ ollamaBaseURL: 'Base URL',
235
+ ollamaApiKeyRef: 'API key reference',
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.',
243
+ ollamaResetDefaults: 'Restore deployment defaults',
244
+ ollamaResetConfirm: 'Clear every saved Ollama override? The profile values and built-in ' +
245
+ 'defaults apply again.',
246
+ ollamaCapVision: 'vision',
247
+ ollamaCapThinking: 'thinking',
248
+ ollamaContext: 'context {tokens}',
202
249
  };
203
250
  /** zh strings, one per {@link en} key. */
204
251
  export const zh = {
@@ -221,23 +268,28 @@ export const zh = {
221
268
  accountsNoModels: '此账号暂未返回模型。',
222
269
  accountsCatalogUnavailable: '暂时无法获取模型目录,已保存的模型选择会被保留。',
223
270
  modelsPartialSave: '部分推理档已保存,其余更改仍保留在草稿中,请重试完成保存。',
224
- modelsEdit: "编辑模型列表",
225
- modelsHint: "在此配置模型显示、默认推理档、上下文与工具,底部的「保存更改」会连同账号设置一起提交。隐藏模型不影响已有会话;工具开关对新建会话生效。",
226
- modelsAutomatic: "自动显示全部模型(包含以后新增的模型)",
227
- modelsSelectAll: "全选",
228
- modelsSelectNone: "清空选择",
229
- modelsContext: "上下文(token)",
230
- modelsContextBounds: "默认 {default} · 最大 {max}",
231
- modelsContextHint: "留空跟随服务商。配置值按账号返回的最大窗口限制;账号池取各成员的最小窗口。此设置控制本地历史保留和压缩时机,不会扩大 API 本身的容量。",
232
- modelsContextInvalid: "请为 {model} 输入正整数 token 数。",
233
- modelsTools: "Provider 工具",
234
- modelsToolsHint: "仅对保存后新建的会话生效,已有会话保留原工具。任一支持的服务商启用共享工具时,该工具仍会显示。",
235
- modelsImage: "图片生成",
236
- modelsVideo: "视频生成",
237
- modelsSearch: "X 搜索",
238
- modelsWebSearch: "网页搜索",
239
- modelsSave: "保存更改",
240
- 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 分钟。',
241
293
  nav: '订阅',
242
294
  intro: '在此登录或退出订阅服务商。点击登录会在新标签页打开服务商的授权页面;无浏览器环境可改为粘贴回调 URL 或授权码。',
243
295
  unavailable: '连接不可用,无法加载订阅状态。',
@@ -274,6 +326,7 @@ export const zh = {
274
326
  usageRefresh: '刷新',
275
327
  usageLoading: '用量加载中…',
276
328
  usageEmpty: '服务商未返回任何用量窗口。',
329
+ usageUnsupported: '该端点不提供用量查询。',
277
330
  usageError: '用量查询失败:{message}',
278
331
  usageSession: '5 小时窗口',
279
332
  usageWeekly: '每周',
@@ -400,4 +453,38 @@ export const zh = {
400
453
  speedFastDescription: '约 1.5 倍速度,消耗更多用量',
401
454
  commandFast: '切换 Codex 速度档(标准/快速)',
402
455
  commandFastUnavailable: '当前模型不支持快速档;/fast 仅对目录声明了 fast tier 的 Codex 模型可用',
456
+ ollamaTitle: 'Ollama Cloud',
457
+ ollamaStatus: '选择器中 {count} 个模型',
458
+ ollamaStatusNone: '尚未配置模型',
459
+ ollamaWebOn: '网页搜索/抓取已启用',
460
+ ollamaWebOff: '网页搜索/抓取已关闭',
461
+ ollamaManageTitle: '管理 Ollama Cloud',
462
+ ollamaManageHint: '选择此路由提供的云端模型后保存。模型选择器按此顺序显示这份列表;API 密钥本身仍保存在 DSH 凭据中。',
463
+ ollamaFetch: '拉取云端模型',
464
+ ollamaFetching: '拉取中…',
465
+ ollamaKeyPlaceholder: '一次性 API 密钥(可选)',
466
+ ollamaKeyHint: '在此输入的密钥仅用于本次拉取,不会保存。留空则使用已存凭据。',
467
+ ollamaFetchFailed: '拉取云端模型失败:{message}',
468
+ ollamaCandidatesCount: '返回 {count} 个',
469
+ ollamaCandidatesEmpty: '未返回任何云端模型。',
470
+ ollamaModelsEmpty: '尚未配置模型。请拉取云端列表并勾选需要保留的模型。',
471
+ ollamaModelsLoadFailed: 'Ollama 设置加载失败:{message}',
472
+ ollamaModelsSaveFailed: 'Ollama 设置保存失败:{message}',
473
+ ollamaConfigureHint: '未在 {ref} 找到 API 密钥。请在凭据文件(~/.dsh/.credentials.yaml)中添加。',
474
+ ollamaDisplayName: '显示名',
475
+ ollamaRowDetails: '详情',
476
+ ollamaEffortsUnknown: '该模型支持思考,推理档位将由实时发现补充。',
477
+ ollamaMoveUp: '上移',
478
+ ollamaMoveDown: '下移',
479
+ ollamaBaseURL: '基础 URL',
480
+ ollamaApiKeyRef: 'API 密钥引用',
481
+ ollamaConnectionHint: '基础 URL 用于此路由的请求与凭据查询;引用是 DSH 凭据的名称,不是密钥本身。' +
482
+ '请求会把解析出的密钥发往该地址,请只填写可信主机。',
483
+ ollamaWebHint: '启用 Ollama Cloud 的网页搜索与抓取能力。宿主仍需选择它们,网页工具才会使用。',
484
+ ollamaCatalogOverride: '配置档案固定了此路由的模型列表;在移除该覆盖前,选择器会忽略存储中的模型。',
485
+ ollamaResetDefaults: '恢复部署默认值',
486
+ ollamaResetConfirm: '清除全部已保存的 Ollama 覆盖项?将重新使用配置档案值与内置默认值。',
487
+ ollamaCapVision: '视觉',
488
+ ollamaCapThinking: '思考',
489
+ ollamaContext: '上下文 {tokens}',
403
490
  };
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Draft rules of the Ollama Cloud settings dialog, kept free of React and the
3
+ * DOM so they can be unit tested. The node half owns the shapes below; the
4
+ * client restates them locally because the browser bundle does not import
5
+ * node-side modules.
6
+ */
7
+ /** One model entry as stored in the route settings. */
8
+ export interface OllamaModelSetting {
9
+ id: string;
10
+ name?: string;
11
+ contextWindow?: number;
12
+ /** The user's explicit local context window; absent follows the endpoint. */
13
+ contextOverride?: number;
14
+ maxTokens?: number;
15
+ vision?: boolean;
16
+ thinking?: boolean;
17
+ efforts?: string[];
18
+ defaultEffort?: string;
19
+ }
20
+ /** One model row of the editable draft (same fields as the stored entry). */
21
+ export interface OllamaModelDraft {
22
+ id: string;
23
+ name?: string;
24
+ contextWindow?: number;
25
+ /** The user's explicit local context window; absent follows the endpoint. */
26
+ contextOverride?: number;
27
+ maxTokens?: number;
28
+ vision?: boolean;
29
+ thinking?: boolean;
30
+ efforts?: string[];
31
+ defaultEffort?: string;
32
+ }
33
+ /** The editable settings draft; every field is an override of the deployment value. */
34
+ export interface OllamaSettingsDraft {
35
+ models?: OllamaModelDraft[];
36
+ web?: boolean;
37
+ baseURL?: string;
38
+ apiKeyRef?: string;
39
+ }
40
+ /** `ollamaSettings` endpoint value. */
41
+ export interface OllamaSettingsView {
42
+ provider: 'ollama-cloud';
43
+ settings: {
44
+ models?: OllamaModelSetting[];
45
+ web?: boolean;
46
+ baseURL?: string;
47
+ apiKeyRef?: string;
48
+ };
49
+ effective: {
50
+ baseURL: string;
51
+ apiKeyRef: string;
52
+ web: boolean;
53
+ };
54
+ models: {
55
+ id: string;
56
+ name: string;
57
+ vision: boolean;
58
+ thinking: boolean;
59
+ contextWindow?: number;
60
+ /** Advertised reasoning levels and the endpoint default, when the model reasons. */
61
+ efforts?: {
62
+ id: string;
63
+ name: string;
64
+ }[];
65
+ defaultEffort?: string;
66
+ }[];
67
+ configOverridesModels: boolean;
68
+ }
69
+ /** One cloud catalog entry returned by the `ollamaModels` endpoint. */
70
+ export interface OllamaCloudCandidate {
71
+ /** Normalized wire id; this is what the store keeps. */
72
+ id: string;
73
+ /** Listing id before normalization. */
74
+ rawId: string;
75
+ /** Display basename. */
76
+ name: string;
77
+ vision: boolean;
78
+ thinking: boolean;
79
+ contextWindow?: number;
80
+ efforts: string[];
81
+ defaultEffort?: string;
82
+ }
83
+ /**
84
+ * Append the checked candidates to the draft's model list. Existing rows are
85
+ * never replaced or reordered, ids already present are skipped, and adopted
86
+ * rows keep the candidate order. Optional fields are set only when the
87
+ * candidate advertises a value, because `exactOptionalPropertyTypes` (and the
88
+ * store) must not see an explicit `undefined`.
89
+ * @param current - the draft list before adoption.
90
+ * @param candidates - the cloud list as fetched, in display order.
91
+ * @param selectedIds - ids the user checked.
92
+ * @returns a new list; the input array is not mutated.
93
+ */
94
+ export declare function adoptCandidates(current: readonly OllamaModelDraft[] | undefined, candidates: readonly OllamaCloudCandidate[], selectedIds: readonly string[]): OllamaModelDraft[];
95
+ /**
96
+ * Swap one model with its neighbour. An id that is absent or a move past
97
+ * either end returns the same order.
98
+ * @param models - the current list.
99
+ * @param id - the row to move.
100
+ * @param delta - `-1` moves up, `1` moves down.
101
+ * @returns a new list; the input array is not mutated.
102
+ */
103
+ export declare function moveModel(models: readonly OllamaModelDraft[], id: string, delta: -1 | 1): OllamaModelDraft[];
104
+ /**
105
+ * Drop one model from the list.
106
+ * @param models - the current list.
107
+ * @param id - the row to drop; an unknown id leaves the list unchanged.
108
+ * @returns a new list; the input array is not mutated.
109
+ */
110
+ export declare function removeModel(models: readonly OllamaModelDraft[], id: string): OllamaModelDraft[];
111
+ /**
112
+ * Short context-window label for a model row.
113
+ * @param contextWindow - the advertised window in tokens.
114
+ * @returns `'1M'`, `'262K'`, the bare number below 1000, or `undefined` when unknown.
115
+ */
116
+ export declare function contextLabel(contextWindow: number | undefined): string | undefined;
117
+ /**
118
+ * Rename one model row. An empty display name deletes the field so the
119
+ * validator keeps accepting the draft; a blank id leaves the list unchanged.
120
+ * @param models - the current list.
121
+ * @param id - the row to rename; an unknown id leaves the list unchanged.
122
+ * @param name - the new display name; whitespace trims before storing.
123
+ * @returns a new list; the input array is not mutated.
124
+ */
125
+ export declare function renameModel(models: readonly OllamaModelDraft[], id: string, name: string): OllamaModelDraft[];
126
+ /**
127
+ * Set or clear one model row's default reasoning effort. An empty choice
128
+ * deletes the field so the resolver falls back to the vendor or family
129
+ * default.
130
+ * @param models - the current list.
131
+ * @param id - the row to edit; an unknown id leaves the list unchanged.
132
+ * @param effort - the chosen level, or `''` to clear.
133
+ * @returns a new list; the input array is not mutated.
134
+ */
135
+ export declare function setModelEffort(models: readonly OllamaModelDraft[], id: string, effort: string): OllamaModelDraft[];
136
+ /**
137
+ * Set or clear one model row's local context-window override. `undefined`
138
+ * deletes the field so the model follows the endpoint again; the runtime
139
+ * caps a stored value at the advertised window.
140
+ * @param models - the current list.
141
+ * @param id - the row to edit; an unknown id leaves the list unchanged.
142
+ * @param tokens - a positive safe integer, or `undefined` to clear.
143
+ * @returns a new list; the input array is not mutated.
144
+ */
145
+ export declare function setModelContext(models: readonly OllamaModelDraft[], id: string, tokens: number | undefined): OllamaModelDraft[];
146
+ /**
147
+ * Parse the context input's text. Only a positive safe integer is a value;
148
+ * an empty string clears the override.
149
+ * @param text - what the user typed.
150
+ * @returns the number, `undefined` for blank, or `null` for text to reject.
151
+ */
152
+ export declare function parseContextInput(text: string): number | undefined | null;
153
+ /** Models the user unticked in this dialog, kept by id so a re-tick restores them. */
154
+ export type OllamaStash = ReadonlyMap<string, OllamaModelDraft>;
155
+ /**
156
+ * Untick one model: drop it from the list and keep its full row (display
157
+ * name, default effort, context, ...) in the stash so ticking it again is
158
+ * lossless, even when the cloud listing no longer carries the id.
159
+ * @param models - the current list.
160
+ * @param stash - the stash before this untick.
161
+ * @param id - the row to untick; an absent id changes nothing.
162
+ * @returns the new list and stash; neither input is mutated.
163
+ */
164
+ export declare function untickModel(models: readonly OllamaModelDraft[], stash: OllamaStash, id: string): {
165
+ models: OllamaModelDraft[];
166
+ stash: OllamaStash;
167
+ };
168
+ /**
169
+ * Tick one model: restore its stashed row when this dialog unticked it,
170
+ * otherwise adopt it from the fetched candidates (which never copies the
171
+ * vendor default effort). A model already in the list, or unknown to both
172
+ * sources, leaves the list unchanged.
173
+ * @param models - the current list.
174
+ * @param stash - rows unticked earlier in this dialog.
175
+ * @param candidates - the cloud list as fetched.
176
+ * @param id - the row to tick.
177
+ * @returns a new list and the stash without the restored row.
178
+ */
179
+ export declare function tickModel(models: readonly OllamaModelDraft[], stash: OllamaStash, candidates: readonly OllamaCloudCandidate[], id: string): {
180
+ models: OllamaModelDraft[];
181
+ stash: OllamaStash;
182
+ };
183
+ /**
184
+ * Tick every listed id in order. Rows already in the list stay where they
185
+ * are; restored and adopted rows append in the given order.
186
+ * @param models - the current list.
187
+ * @param stash - rows unticked earlier in this dialog.
188
+ * @param candidates - the cloud list as fetched.
189
+ * @param ids - the ids to tick, typically the filtered view.
190
+ * @returns the new list and stash; neither input is mutated.
191
+ */
192
+ export declare function tickModels(models: readonly OllamaModelDraft[], stash: OllamaStash, candidates: readonly OllamaCloudCandidate[], ids: readonly string[]): {
193
+ models: OllamaModelDraft[];
194
+ stash: OllamaStash;
195
+ };
196
+ /**
197
+ * Untick every listed id, stashing each removed row. Ids outside the list,
198
+ * such as filtered-out rows, are untouched.
199
+ * @param models - the current list.
200
+ * @param stash - the stash before this untick.
201
+ * @param ids - the ids to untick, typically the filtered view.
202
+ * @returns the new list and stash; neither input is mutated.
203
+ */
204
+ export declare function untickModels(models: readonly OllamaModelDraft[], stash: OllamaStash, ids: readonly string[]): {
205
+ models: OllamaModelDraft[];
206
+ stash: OllamaStash;
207
+ };
208
+ /** One effort choice shown in a row's selector. */
209
+ export interface EffortOption {
210
+ id: string;
211
+ name: string;
212
+ unavailable?: boolean;
213
+ }
214
+ /**
215
+ * The effort choices for one ticked row. The row's own `efforts` decide the
216
+ * ids because the store rejects a default outside them, so the selector must
217
+ * never offer anything else. A snapshot of the endpoint (`labels`) may only
218
+ * supply friendlier names for the same ids. A saved default the list no
219
+ * longer contains is kept visible and marked unavailable instead of
220
+ * silently reading as "follow the provider".
221
+ * @param row - the draft row.
222
+ * @param fetched - efforts from this dialog's latest fetch, when it returned the row.
223
+ * @param labels - the opened dialog's snapshot of named efforts for the id.
224
+ * @returns the options in picker order.
225
+ */
226
+ export declare function effortOptions(row: OllamaModelDraft, fetched: readonly string[] | undefined, labels: readonly {
227
+ id: string;
228
+ name: string;
229
+ }[] | undefined): EffortOption[];