dsh-model-allowance 1.0.2 → 1.0.4

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.
@@ -0,0 +1,580 @@
1
+ /**
2
+ * Placeholder adapters for platforms without balance API support.
3
+ *
4
+ * These adapters declare the routes they serve but return `unsupported` status,
5
+ * indicating that no balance or quota reading is available for these providers.
6
+ * This allows the plugin to recognize the routes without attempting queries
7
+ * that would fail.
8
+ *
9
+ * When a platform adds a balance API, replace its placeholder with a real
10
+ * adapter following the patterns in deepseek.js, minimax_cn.js, or zai.js.
11
+ */
12
+
13
+ import { defineAdapter, KIND_AMOUNT } from './shared.js'
14
+
15
+ /**
16
+ * Create a placeholder adapter for a platform without balance support.
17
+ * @param {object} spec Adapter specification.
18
+ * @param {string} spec.id Adapter identity.
19
+ * @param {readonly string[]} spec.routes Provider routes this adapter serves.
20
+ * @param {{zh: string, en: string}} spec.name Display name.
21
+ * @param {string} spec.color Brand color.
22
+ * @param {string} [spec.icon] Optional icon hint.
23
+ * @param {string} [spec.consoleUrl] Provider console URL.
24
+ * @returns {import('../providers.js').ProviderAdapter} The placeholder adapter.
25
+ */
26
+ function placeholderAdapter({ id, routes, name, color, icon, consoleUrl }) {
27
+ const safeConsole =
28
+ typeof consoleUrl === 'string' && consoleUrl.startsWith('https://')
29
+ ? consoleUrl
30
+ : 'https://example.com'
31
+
32
+ return defineAdapter({
33
+ id,
34
+ routes,
35
+ kind: KIND_AMOUNT,
36
+ readWithEnv: async ({ route }) => ({
37
+ provider: route,
38
+ status: 'unsupported',
39
+ kind: KIND_AMOUNT,
40
+ }),
41
+ consoleUrl: safeConsole,
42
+ display: {
43
+ name: { zh: name.zh, en: name.en },
44
+ mark: { ...(typeof icon === 'string' ? { icon } : {}), color },
45
+ },
46
+ fixtures: [
47
+ {
48
+ name: 'placeholder returns unsupported',
49
+ services: {},
50
+ expect: { status: 'unsupported', kind: KIND_AMOUNT },
51
+ },
52
+ ],
53
+ })
54
+ }
55
+
56
+ // ============================================================================
57
+ // AWS Bedrock
58
+ // ============================================================================
59
+ export const amazonBedrockAdapters = [
60
+ placeholderAdapter({
61
+ id: 'amazon-bedrock',
62
+ routes: ['amazon-bedrock'],
63
+ name: { zh: 'AWS Bedrock', en: 'AWS Bedrock' },
64
+ color: '#ff9900',
65
+ icon: 'aws',
66
+ consoleUrl: 'https://console.aws.amazon.com/bedrock/',
67
+ }),
68
+ ]
69
+
70
+ // ============================================================================
71
+ // Ant Ling (蚂蚁灵光)
72
+ // ============================================================================
73
+ export const antLingAdapters = [
74
+ placeholderAdapter({
75
+ id: 'ant-ling',
76
+ routes: ['ant-ling'],
77
+ name: { zh: '蚂蚁灵光', en: 'Ant Ling' },
78
+ color: '#1677ff',
79
+ icon: 'ant',
80
+ consoleUrl: 'https://www.ant-ling.com/',
81
+ }),
82
+ ]
83
+
84
+ // ============================================================================
85
+ // Anthropic (Claude)
86
+ // ============================================================================
87
+ export const anthropicAdapters = [
88
+ placeholderAdapter({
89
+ id: 'anthropic',
90
+ routes: ['anthropic'],
91
+ name: { zh: 'Anthropic (Claude)', en: 'Anthropic (Claude)' },
92
+ color: '#d4a574',
93
+ icon: 'anthropic',
94
+ consoleUrl: 'https://console.anthropic.com/',
95
+ }),
96
+ ]
97
+
98
+ // ============================================================================
99
+ // Azure OpenAI
100
+ // ============================================================================
101
+ export const azureAdapters = [
102
+ placeholderAdapter({
103
+ id: 'azure',
104
+ routes: ['azure'],
105
+ name: { zh: 'Azure OpenAI', en: 'Azure OpenAI' },
106
+ color: '#0078d4',
107
+ icon: 'azure',
108
+ consoleUrl: 'https://portal.azure.com/',
109
+ }),
110
+ ]
111
+
112
+ // ============================================================================
113
+ // Baseten
114
+ // ============================================================================
115
+ export const basetenAdapters = [
116
+ placeholderAdapter({
117
+ id: 'baseten',
118
+ routes: ['baseten'],
119
+ name: { zh: 'Baseten', en: 'Baseten' },
120
+ color: '#6366f1',
121
+ icon: 'baseten',
122
+ consoleUrl: 'https://app.baseten.co/',
123
+ }),
124
+ ]
125
+
126
+ // ============================================================================
127
+ // Cerebras
128
+ // ============================================================================
129
+ export const cerebrasAdapters = [
130
+ placeholderAdapter({
131
+ id: 'cerebras',
132
+ routes: ['cerebras'],
133
+ name: { zh: 'Cerebras', en: 'Cerebras' },
134
+ color: '#f97316',
135
+ icon: 'cerebras',
136
+ consoleUrl: 'https://cloud.cerebras.ai/',
137
+ }),
138
+ ]
139
+
140
+ // ============================================================================
141
+ // Cloudflare AI Gateway
142
+ // ============================================================================
143
+ export const cloudflareAiGatewayAdapters = [
144
+ placeholderAdapter({
145
+ id: 'cloudflare-ai-gateway',
146
+ routes: ['cloudflare-ai-gateway'],
147
+ name: { zh: 'Cloudflare AI Gateway', en: 'Cloudflare AI Gateway' },
148
+ color: '#f38020',
149
+ icon: 'cloudflare',
150
+ consoleUrl: 'https://dash.cloudflare.com/',
151
+ }),
152
+ ]
153
+
154
+ // ============================================================================
155
+ // Cloudflare Workers AI
156
+ // ============================================================================
157
+ export const cloudflareWorkersAiAdapters = [
158
+ placeholderAdapter({
159
+ id: 'cloudflare-workers-ai',
160
+ routes: ['cloudflare-workers-ai'],
161
+ name: { zh: 'Cloudflare Workers AI', en: 'Cloudflare Workers AI' },
162
+ color: '#f38020',
163
+ icon: 'cloudflare',
164
+ consoleUrl: 'https://dash.cloudflare.com/',
165
+ }),
166
+ ]
167
+
168
+ // ============================================================================
169
+ // DeepSeek (already implemented in deepseek.js)
170
+ // This is just a re-export placeholder for completeness
171
+ // ============================================================================
172
+ // Note: DeepSeek has full implementation in deepseek.js
173
+
174
+ // ============================================================================
175
+ // Fireworks AI
176
+ // ============================================================================
177
+ export const fireworksAdapters = [
178
+ placeholderAdapter({
179
+ id: 'fireworks',
180
+ routes: ['fireworks'],
181
+ name: { zh: 'Fireworks AI', en: 'Fireworks AI' },
182
+ color: '#f43f5e',
183
+ icon: 'fireworks',
184
+ consoleUrl: 'https://app.fireworks.ai/',
185
+ }),
186
+ ]
187
+
188
+ // ============================================================================
189
+ // GitHub Copilot
190
+ // ============================================================================
191
+ export const githubCopilotAdapters = [
192
+ placeholderAdapter({
193
+ id: 'github-copilot',
194
+ routes: ['github-copilot'],
195
+ name: { zh: 'GitHub Copilot', en: 'GitHub Copilot' },
196
+ color: '#1f2328',
197
+ icon: 'github',
198
+ consoleUrl: 'https://github.com/settings/copilot',
199
+ }),
200
+ ]
201
+
202
+ // ============================================================================
203
+ // Google (Gemini)
204
+ // ============================================================================
205
+ export const googleAdapters = [
206
+ placeholderAdapter({
207
+ id: 'google',
208
+ routes: ['google'],
209
+ name: { zh: 'Google (Gemini)', en: 'Google (Gemini)' },
210
+ color: '#4285f4',
211
+ icon: 'google',
212
+ consoleUrl: 'https://aistudio.google.com/',
213
+ }),
214
+ ]
215
+
216
+ // ============================================================================
217
+ // Google Vertex AI
218
+ // ============================================================================
219
+ export const googleVertexAdapters = [
220
+ placeholderAdapter({
221
+ id: 'google-vertex',
222
+ routes: ['google-vertex'],
223
+ name: { zh: 'Google Vertex AI', en: 'Google Vertex AI' },
224
+ color: '#4285f4',
225
+ icon: 'google-cloud',
226
+ consoleUrl: 'https://console.cloud.google.com/vertex-ai',
227
+ }),
228
+ ]
229
+
230
+ // ============================================================================
231
+ // Groq
232
+ // ============================================================================
233
+ export const groqAdapters = [
234
+ placeholderAdapter({
235
+ id: 'groq',
236
+ routes: ['groq'],
237
+ name: { zh: 'Groq', en: 'Groq' },
238
+ color: '#f55036',
239
+ icon: 'groq',
240
+ consoleUrl: 'https://console.groq.com/',
241
+ }),
242
+ ]
243
+
244
+ // ============================================================================
245
+ // Hugging Face
246
+ // ============================================================================
247
+ export const huggingfaceAdapters = [
248
+ placeholderAdapter({
249
+ id: 'huggingface',
250
+ routes: ['huggingface'],
251
+ name: { zh: 'Hugging Face', en: 'Hugging Face' },
252
+ color: '#ffd21e',
253
+ icon: 'huggingface',
254
+ consoleUrl: 'https://huggingface.co/settings/billing',
255
+ }),
256
+ ]
257
+
258
+ // ============================================================================
259
+ // Kimi Coding (already implemented in kimi_coding.js)
260
+ // Note: Kimi Coding has full implementation in kimi_coding.js
261
+
262
+ // ============================================================================
263
+ // Meta (Llama)
264
+ // ============================================================================
265
+ export const metaAdapters = [
266
+ placeholderAdapter({
267
+ id: 'meta',
268
+ routes: ['meta'],
269
+ name: { zh: 'Meta (Llama)', en: 'Meta (Llama)' },
270
+ color: '#0668e1',
271
+ icon: 'meta',
272
+ consoleUrl: 'https://llama.meta.com/',
273
+ }),
274
+ ]
275
+
276
+ // ============================================================================
277
+ // MiniMax (International)
278
+ // ============================================================================
279
+ export const minimaxAdapters = [
280
+ placeholderAdapter({
281
+ id: 'minimax',
282
+ routes: ['minimax'],
283
+ name: { zh: 'MiniMax (国际)', en: 'MiniMax (International)' },
284
+ color: '#e21680',
285
+ icon: 'minimax',
286
+ consoleUrl: 'https://platform.minimax.io/console/usage',
287
+ }),
288
+ ]
289
+
290
+ // ============================================================================
291
+ // MiniMax CN (already implemented in minimax_cn.js)
292
+ // Note: MiniMax CN has full implementation in minimax_cn.js
293
+
294
+ // ============================================================================
295
+ // Mistral AI
296
+ // ============================================================================
297
+ export const mistralAdapters = [
298
+ placeholderAdapter({
299
+ id: 'mistral',
300
+ routes: ['mistral'],
301
+ name: { zh: 'Mistral AI', en: 'Mistral AI' },
302
+ color: '#f97316',
303
+ icon: 'mistral',
304
+ consoleUrl: 'https://console.mistral.ai/',
305
+ }),
306
+ ]
307
+
308
+ // ============================================================================
309
+ // Moonshot AI (International)
310
+ // ============================================================================
311
+ export const moonshotaiAdapters = [
312
+ placeholderAdapter({
313
+ id: 'moonshotai',
314
+ routes: ['moonshotai'],
315
+ name: { zh: 'Moonshot AI (国际)', en: 'Moonshot AI (International)' },
316
+ color: '#636ff6',
317
+ icon: 'moonshot',
318
+ consoleUrl: 'https://platform.moonshot.ai/',
319
+ }),
320
+ ]
321
+
322
+ // ============================================================================
323
+ // Moonshot AI CN
324
+ // ============================================================================
325
+ export const moonshotaiCnAdapters = [
326
+ placeholderAdapter({
327
+ id: 'moonshotai-cn',
328
+ routes: ['moonshotai-cn'],
329
+ name: { zh: 'Moonshot AI (国内)', en: 'Moonshot AI (CN)' },
330
+ color: '#636ff6',
331
+ icon: 'moonshot',
332
+ consoleUrl: 'https://platform.moonshot.cn/',
333
+ }),
334
+ ]
335
+
336
+ // ============================================================================
337
+ // NVIDIA NIM
338
+ // ============================================================================
339
+ export const nvidiaAdapters = [
340
+ placeholderAdapter({
341
+ id: 'nvidia',
342
+ routes: ['nvidia'],
343
+ name: { zh: 'NVIDIA NIM', en: 'NVIDIA NIM' },
344
+ color: '#76b900',
345
+ icon: 'nvidia',
346
+ consoleUrl: 'https://build.nvidia.com/',
347
+ }),
348
+ ]
349
+
350
+ // ============================================================================
351
+ // OpenAI
352
+ // ============================================================================
353
+ export const openaiAdapters = [
354
+ placeholderAdapter({
355
+ id: 'openai',
356
+ routes: ['openai'],
357
+ name: { zh: 'OpenAI', en: 'OpenAI' },
358
+ color: '#10a37f',
359
+ icon: 'openai',
360
+ consoleUrl: 'https://platform.openai.com/usage',
361
+ }),
362
+ ]
363
+
364
+ // ============================================================================
365
+ // OpenAI Codex
366
+ // ============================================================================
367
+ export const openaiCodexAdapters = [
368
+ placeholderAdapter({
369
+ id: 'openai-codex',
370
+ routes: ['openai-codex'],
371
+ name: { zh: 'OpenAI Codex', en: 'OpenAI Codex' },
372
+ color: '#10a37f',
373
+ icon: 'openai',
374
+ consoleUrl: 'https://platform.openai.com/',
375
+ }),
376
+ ]
377
+
378
+ // ============================================================================
379
+ // OpenCode
380
+ // ============================================================================
381
+ export const opencodeAdapters = [
382
+ placeholderAdapter({
383
+ id: 'opencode',
384
+ routes: ['opencode'],
385
+ name: { zh: 'OpenCode', en: 'OpenCode' },
386
+ color: '#3b82f6',
387
+ icon: 'opencode',
388
+ consoleUrl: 'https://opencode.ai/',
389
+ }),
390
+ ]
391
+
392
+ // ============================================================================
393
+ // OpenCode Go (already implemented in opencode_go.js)
394
+ // Note: OpenCode Go has full implementation in opencode_go.js
395
+
396
+ // ============================================================================
397
+ // OpenRouter
398
+ // ============================================================================
399
+ export const openrouterAdapters = [
400
+ placeholderAdapter({
401
+ id: 'openrouter',
402
+ routes: ['openrouter'],
403
+ name: { zh: 'OpenRouter', en: 'OpenRouter' },
404
+ color: '#6366f1',
405
+ icon: 'openrouter',
406
+ consoleUrl: 'https://openrouter.ai/activity',
407
+ }),
408
+ ]
409
+
410
+ // ============================================================================
411
+ // Qwen Token Plan
412
+ // ============================================================================
413
+ export const qwenTokenPlanAdapters = [
414
+ placeholderAdapter({
415
+ id: 'qwen-token-plan',
416
+ routes: ['qwen-token-plan'],
417
+ name: { zh: '通义千问 Token Plan', en: 'Qwen Token Plan' },
418
+ color: '#ff6a00',
419
+ icon: 'qwen',
420
+ consoleUrl: 'https://platform.qianwenai.com/home/analytics/token-plan/individual',
421
+ }),
422
+ ]
423
+
424
+ // ============================================================================
425
+ // Qwen Token Plan CN
426
+ // ============================================================================
427
+ export const qwenTokenPlanCnAdapters = [
428
+ placeholderAdapter({
429
+ id: 'qwen-token-plan-cn',
430
+ routes: ['qwen-token-plan-cn'],
431
+ name: { zh: '通义千问 Token Plan (国内)', en: 'Qwen Token Plan (CN)' },
432
+ color: '#ff6a00',
433
+ icon: 'qwen',
434
+ consoleUrl: 'https://platform.qianwenai.com/home/analytics/token-plan/individual',
435
+ }),
436
+ ]
437
+
438
+ // ============================================================================
439
+ // Qwen Token Plan Individual
440
+ // ============================================================================
441
+ export const qwenTokenPlanIndividualAdapters = [
442
+ placeholderAdapter({
443
+ id: 'qwen-token-plan-individual',
444
+ routes: ['qwen-token-plan-individual'],
445
+ name: { zh: '通义千问个人版', en: 'Qwen Token Plan Individual' },
446
+ color: '#ff6a00',
447
+ icon: 'qwen',
448
+ consoleUrl: 'https://platform.qianwenai.com/home/analytics/token-plan/individual',
449
+ }),
450
+ ]
451
+
452
+ // ============================================================================
453
+ // Radius
454
+ // ============================================================================
455
+ export const radiusAdapters = [
456
+ placeholderAdapter({
457
+ id: 'radius',
458
+ routes: ['radius'],
459
+ name: { zh: 'Radius', en: 'Radius' },
460
+ color: '#8b5cf6',
461
+ icon: 'radius',
462
+ consoleUrl: 'https://radius.ai/',
463
+ }),
464
+ ]
465
+
466
+ // ============================================================================
467
+ // Together AI
468
+ // ============================================================================
469
+ export const togetherAdapters = [
470
+ placeholderAdapter({
471
+ id: 'together',
472
+ routes: ['together'],
473
+ name: { zh: 'Together AI', en: 'Together AI' },
474
+ color: '#0f766e',
475
+ icon: 'together',
476
+ consoleUrl: 'https://api.together.xyz/settings/billing',
477
+ }),
478
+ ]
479
+
480
+ // ============================================================================
481
+ // TypeSafe
482
+ // ============================================================================
483
+ export const typesafeAdapters = [
484
+ placeholderAdapter({
485
+ id: 'typesafe',
486
+ routes: ['typesafe'],
487
+ name: { zh: 'TypeSafe', en: 'TypeSafe' },
488
+ color: '#3178c6',
489
+ icon: 'typescript',
490
+ consoleUrl: 'https://typesafe.io/',
491
+ }),
492
+ ]
493
+
494
+ // ============================================================================
495
+ // Vercel AI Gateway
496
+ // ============================================================================
497
+ export const vercelAiGatewayAdapters = [
498
+ placeholderAdapter({
499
+ id: 'vercel-ai-gateway',
500
+ routes: ['vercel-ai-gateway'],
501
+ name: { zh: 'Vercel AI Gateway', en: 'Vercel AI Gateway' },
502
+ color: '#000000',
503
+ icon: 'vercel',
504
+ consoleUrl: 'https://vercel.com/dashboard',
505
+ }),
506
+ ]
507
+
508
+ // ============================================================================
509
+ // xAI (Grok)
510
+ // ============================================================================
511
+ export const xaiAdapters = [
512
+ placeholderAdapter({
513
+ id: 'xai',
514
+ routes: ['xai'],
515
+ name: { zh: 'xAI (Grok)', en: 'xAI (Grok)' },
516
+ color: '#000000',
517
+ icon: 'xai',
518
+ consoleUrl: 'https://console.x.ai/',
519
+ }),
520
+ ]
521
+
522
+ // ============================================================================
523
+ // Xiaomi (小米)
524
+ // ============================================================================
525
+ export const xiaomiAdapters = [
526
+ placeholderAdapter({
527
+ id: 'xiaomi',
528
+ routes: ['xiaomi'],
529
+ name: { zh: '小米', en: 'Xiaomi' },
530
+ color: '#ff6700',
531
+ icon: 'xiaomi',
532
+ consoleUrl: 'https://ai.xiaomi.com/',
533
+ }),
534
+ ]
535
+
536
+ // ============================================================================
537
+ // Xiaomi Token Plan AMS
538
+ // ============================================================================
539
+ export const xiaomiTokenPlanAmsAdapters = [
540
+ placeholderAdapter({
541
+ id: 'xiaomi-token-plan-ams',
542
+ routes: ['xiaomi-token-plan-ams'],
543
+ name: { zh: '小米 Token Plan (阿姆斯特丹)', en: 'Xiaomi Token Plan (AMS)' },
544
+ color: '#ff6700',
545
+ icon: 'xiaomi',
546
+ consoleUrl: 'https://ai.xiaomi.com/',
547
+ }),
548
+ ]
549
+
550
+ // ============================================================================
551
+ // Xiaomi Token Plan CN
552
+ // ============================================================================
553
+ export const xiaomiTokenPlanCnAdapters = [
554
+ placeholderAdapter({
555
+ id: 'xiaomi-token-plan-cn',
556
+ routes: ['xiaomi-token-plan-cn'],
557
+ name: { zh: '小米 Token Plan (国内)', en: 'Xiaomi Token Plan (CN)' },
558
+ color: '#ff6700',
559
+ icon: 'xiaomi',
560
+ consoleUrl: 'https://ai.xiaomi.com/',
561
+ }),
562
+ ]
563
+
564
+ // ============================================================================
565
+ // Xiaomi Token Plan SGP
566
+ // ============================================================================
567
+ export const xiaomiTokenPlanSgpAdapters = [
568
+ placeholderAdapter({
569
+ id: 'xiaomi-token-plan-sgp',
570
+ routes: ['xiaomi-token-plan-sgp'],
571
+ name: { zh: '小米 Token Plan (新加坡)', en: 'Xiaomi Token Plan (SGP)' },
572
+ color: '#ff6700',
573
+ icon: 'xiaomi',
574
+ consoleUrl: 'https://ai.xiaomi.com/',
575
+ }),
576
+ ]
577
+
578
+ // ============================================================================
579
+ // Zhipu ZAI (already implemented in zai.js)
580
+ // Note: Zhipu ZAI has full implementation in zai.js
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Zhipu adapter.
2
+ * Zhipu ZAI adapter.
3
3
  *
4
4
  * Zhipu reports credit limits; it publishes no monetary balance. A limit
5
5
  * carries `unit` (a length code) and `number` (how many of them), so
@@ -103,10 +103,10 @@ function readQuota({ route, body }) {
103
103
  }
104
104
  }
105
105
 
106
- /** Zhipu's coding-plan routes: the CN plan and the international route. */
107
- export const zhipuAdapters = [
106
+ /** Zhipu ZAI's coding-plan routes: the CN plan and the international route. */
107
+ export const zaiAdapters = [
108
108
  defineAdapter({
109
- id: 'zhipu-quota',
109
+ id: 'zai-coding-cn',
110
110
  routes: ['zai', 'zai-coding-cn'],
111
111
  kind: KIND_QUOTA,
112
112
  endpoint: 'https://open.bigmodel.cn/api/monitor/usage/quota/limit',
@@ -116,7 +116,7 @@ export const zhipuAdapters = [
116
116
  consoleUrl: CONSOLE,
117
117
  schedule: SCHEDULE,
118
118
  display: {
119
- name: { zh: '智谱 GLM', en: 'Zhipu GLM' },
119
+ name: { zh: '智谱 ZAI', en: 'Zhipu ZAI' },
120
120
  mark: { icon: 'zhipu', color: '#5668f5' },
121
121
  },
122
122
  fixtures: [