dsh-bottom-info-bar 1.26.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +3 -3
- package/lib/constants.js +4 -3
- package/lib/index.js +27 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -505,7 +505,7 @@ function clearNativePillVisibility() {
|
|
|
505
505
|
const PRESET_COLORS = ['red', 'green', 'blue', 'purple', 'orange', 'neutral'];
|
|
506
506
|
// v1.6 T7 / v1.7 FR-14:订阅/账单 provider 集合(构建注入,永不变)。以前在 BottomInfoBar 里每次渲染重建
|
|
507
507
|
// 字面量——值从不变,多建的只是垃圾。提到模块级,var 拼法保留(一致性测试按该字面锚点提取)。
|
|
508
|
-
var SUBSCRIPTION_PROVIDERS = ['codex', 'chatgpt', 'opencode-go', 'opencode', 'openai-codex', 'zai', 'zai-coding-cn', 'xiaomi-token-plan-cn', 'xiaomi-token-plan-sgp', 'xiaomi-token-plan-ams', 'command', 'command-code', 'minimax', 'minimax-cn', 'qwen-token-plan-cn', 'qwen-token-plan', 'qwen-token-plan-individual', 'kimi-coding'];
|
|
508
|
+
var SUBSCRIPTION_PROVIDERS = ['codex', 'chatgpt', 'chatgpt-siwc', 'opencode-go', 'opencode', 'openai-codex', 'zai', 'zai-coding-cn', 'xiaomi-token-plan-cn', 'xiaomi-token-plan-sgp', 'xiaomi-token-plan-ams', 'command', 'command-code', 'minimax', 'minimax-cn', 'qwen-token-plan-cn', 'qwen-token-plan', 'qwen-token-plan-individual', 'kimi-coding'];
|
|
509
509
|
var BILLING_PROVIDERS = ['together', 'fireworks', 'amazon-bedrock', 'cloudflare-ai-gateway', 'cloudflare-workers-ai', 'huggingface'];
|
|
510
510
|
const PRESET_COLOR_SET = new Set(PRESET_COLORS);
|
|
511
511
|
|
|
@@ -2906,7 +2906,7 @@ const CREDENTIAL_CATALOG = [
|
|
|
2906
2906
|
id: 'codex',
|
|
2907
2907
|
label: 'ChatGPT / Codex',
|
|
2908
2908
|
mode: 'subscription',
|
|
2909
|
-
providers: ['openai-codex', 'chatgpt', 'codex'],
|
|
2909
|
+
providers: ['openai-codex', 'chatgpt', 'chatgpt-siwc', 'codex'],
|
|
2910
2910
|
official: true,
|
|
2911
2911
|
verification: 'third-party',
|
|
2912
2912
|
credentials: [],
|
|
@@ -5309,7 +5309,7 @@ module.exports = {
|
|
|
5309
5309
|
// Codex 与 ChatGPT 已合并:实际 provider openai-codex / chatgpt 均显示 ChatGPT;codex 保持 Codex
|
|
5310
5310
|
// v1.6 T7:新增 zai/zai-coding-cn → '智谱';v1.7:小米 Token Plan → '小米 MiMo'
|
|
5311
5311
|
function subscriptionServiceName(provider) {
|
|
5312
|
-
if (provider === 'chatgpt' || provider === 'openai-codex') return 'ChatGPT';
|
|
5312
|
+
if (provider === 'chatgpt' || provider === 'openai-codex' || provider === 'chatgpt-siwc') return 'ChatGPT';
|
|
5313
5313
|
if (provider === 'codex') return 'Codex';
|
|
5314
5314
|
if (provider === 'opencode-go' || provider === 'opencode') return 'OpenCode Go';
|
|
5315
5315
|
if (provider === 'zai' || provider === 'zai-coding-cn') return t('ui.zhipu');
|
package/lib/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// v1.7:新增小米 MiMo Token Plan 三集群(月度 Credits 额度窗)
|
|
4
4
|
// v1.16.0:新增 MiniMax(海螺)Token Plan 双站点(Global minimax / CN minimax-cn,5 小时 + 周窗口)
|
|
5
5
|
// v1.22.0:新增阿里 Token Plan 中国站/国际站(百炼 Credits 订阅,月度窗口)与 Kimi For Coding(5 小时 + 周窗口)
|
|
6
|
-
export const SUBSCRIPTION_PROVIDERS = ['codex', 'chatgpt', 'opencode-go', 'opencode', 'openai-codex', 'zai', 'zai-coding-cn', 'xiaomi-token-plan-cn', 'xiaomi-token-plan-sgp', 'xiaomi-token-plan-ams', 'command', 'command-code', 'minimax', 'minimax-cn', 'qwen-token-plan-cn', 'qwen-token-plan', 'qwen-token-plan-individual', 'kimi-coding']
|
|
6
|
+
export const SUBSCRIPTION_PROVIDERS = ['codex', 'chatgpt', 'chatgpt-siwc', 'opencode-go', 'opencode', 'openai-codex', 'zai', 'zai-coding-cn', 'xiaomi-token-plan-cn', 'xiaomi-token-plan-sgp', 'xiaomi-token-plan-ams', 'command', 'command-code', 'minimax', 'minimax-cn', 'qwen-token-plan-cn', 'qwen-token-plan', 'qwen-token-plan-individual', 'kimi-coding']
|
|
7
7
|
// 云账单 provider 集合:这些 provider 走"账单型"显示(本月真实花费 / 预算%),与余额型/额度型互斥(FR-14)
|
|
8
8
|
export const BILLING_PROVIDERS = ['together', 'fireworks', 'amazon-bedrock', 'cloudflare-ai-gateway', 'cloudflare-workers-ai', 'huggingface']
|
|
9
9
|
|
|
@@ -126,7 +126,7 @@ export const CREDENTIAL_CATALOG = [
|
|
|
126
126
|
id: 'codex',
|
|
127
127
|
label: 'ChatGPT / Codex',
|
|
128
128
|
mode: 'subscription',
|
|
129
|
-
providers: ['openai-codex', 'chatgpt', 'codex'],
|
|
129
|
+
providers: ['openai-codex', 'chatgpt', 'chatgpt-siwc', 'codex'],
|
|
130
130
|
official: true,
|
|
131
131
|
verification: 'third-party',
|
|
132
132
|
credentials: [],
|
|
@@ -254,7 +254,7 @@ export const PROVIDER_DEFAULT_CURRENCY = {
|
|
|
254
254
|
'baseten': 'USD', 'cerebras': 'USD', 'cloudflare-ai-gateway': 'USD', 'cloudflare-workers-ai': 'USD',
|
|
255
255
|
'fireworks': 'USD', 'github-copilot': 'USD', 'google': 'USD', 'google-vertex': 'USD', 'groq': 'USD',
|
|
256
256
|
'huggingface': 'USD', 'kimi-coding': 'USD', 'mistral': 'USD', 'moonshotai': 'USD', 'nvidia': 'USD', 'openai': 'USD',
|
|
257
|
-
'openai-codex': 'USD', 'chatgpt': 'USD', 'codex': 'USD', 'openrouter': 'USD',
|
|
257
|
+
'openai-codex': 'USD', 'chatgpt': 'USD', 'chatgpt-siwc': 'USD', 'codex': 'USD', 'openrouter': 'USD',
|
|
258
258
|
'qwen-token-plan': 'USD', 'qwen-token-plan-individual': 'USD', 'together': 'USD',
|
|
259
259
|
'vercel-ai-gateway': 'USD', 'xai': 'USD',
|
|
260
260
|
}
|
|
@@ -281,6 +281,7 @@ export const PROVIDER_IDENTITY = {
|
|
|
281
281
|
'codex': { account: 'codex', subscription: 'codex', billing: null },
|
|
282
282
|
'chatgpt': { account: 'codex', subscription: 'codex', billing: null },
|
|
283
283
|
'openai-codex': { account: 'codex', subscription: 'codex', billing: null },
|
|
284
|
+
'chatgpt-siwc': { account: 'codex', subscription: 'codex', billing: null },
|
|
284
285
|
'opencode-go': { account: 'opencode-go', subscription: 'opencode-go', billing: null },
|
|
285
286
|
'opencode': { account: 'opencode-go', subscription: 'opencode-go', billing: null },
|
|
286
287
|
'zai': { account: 'zai', subscription: 'zai', billing: null },
|
package/lib/index.js
CHANGED
|
@@ -317,7 +317,7 @@ function latestVersion() {
|
|
|
317
317
|
|
|
318
318
|
// ---------- 双模式(余额制 / 订阅制)配置 ----------
|
|
319
319
|
// 订阅制 provider 集合:这些 provider 走"额度窗口"显示而非余额(共享常量注入,见 src/constants.js)
|
|
320
|
-
const SUBSCRIPTION_PROVIDERS = ['codex', 'chatgpt', 'opencode-go', 'opencode', 'openai-codex', 'zai', 'zai-coding-cn', 'xiaomi-token-plan-cn', 'xiaomi-token-plan-sgp', 'xiaomi-token-plan-ams', 'command', 'command-code', 'minimax', 'minimax-cn', 'qwen-token-plan-cn', 'qwen-token-plan', 'qwen-token-plan-individual', 'kimi-coding'];
|
|
320
|
+
const SUBSCRIPTION_PROVIDERS = ['codex', 'chatgpt', 'chatgpt-siwc', 'opencode-go', 'opencode', 'openai-codex', 'zai', 'zai-coding-cn', 'xiaomi-token-plan-cn', 'xiaomi-token-plan-sgp', 'xiaomi-token-plan-ams', 'command', 'command-code', 'minimax', 'minimax-cn', 'qwen-token-plan-cn', 'qwen-token-plan', 'qwen-token-plan-individual', 'kimi-coding'];
|
|
321
321
|
// 云账单 provider 集合:这些 provider 走"账单型"显示(本月真实花费 / 预算%),与余额型/额度型互斥(FR-14 共享常量注入)
|
|
322
322
|
const BILLING_PROVIDERS = ['together', 'fireworks', 'amazon-bedrock', 'cloudflare-ai-gateway', 'cloudflare-workers-ai', 'huggingface'];
|
|
323
323
|
// 窗口标签:模块顶层用硬编码中文兜底(避免加载时触发 translate);
|
|
@@ -2908,11 +2908,36 @@ export default {
|
|
|
2908
2908
|
return { data: { provider: 'codex', plan: plan, planType: parsed.planType, expiryAt: parsed.expiryMs, windows: [] } };
|
|
2909
2909
|
}
|
|
2910
2910
|
|
|
2911
|
+
// SIWC 会话通道:dsh-chatgpt-sub 0.9+ 把官方 Sign in with ChatGPT 会话存在
|
|
2912
|
+
// DSH 凭据库(chatgpt-sub/session)。它没有 ~/.codex/auth.json 时,套餐与有效期
|
|
2913
|
+
// 从这里读;旧版 Codex 文件仍保留为第三兜底。
|
|
2914
|
+
async function fetchCodexUsageFromSession() {
|
|
2915
|
+
try {
|
|
2916
|
+
if (!ctx.credentials || typeof ctx.credentials.readRecord !== 'function') return null;
|
|
2917
|
+
const record = await ctx.credentials.readRecord('chatgpt-sub/session');
|
|
2918
|
+
const payload = record && record.kind === 'grant' ? record.payload : null;
|
|
2919
|
+
if (!payload || typeof payload !== 'object' || payload.version !== 1) return null;
|
|
2920
|
+
const idToken = typeof payload.idToken === 'string' && payload.idToken.length > 0 ? payload.idToken : null;
|
|
2921
|
+
let parsed = null;
|
|
2922
|
+
if (idToken) {
|
|
2923
|
+
try { parsed = parseCodexJwt(idToken); } catch (err) { /* 只用会话里的字段 */ }
|
|
2924
|
+
}
|
|
2925
|
+
const planType = (parsed && parsed.planType) || (typeof payload.plan === 'string' && payload.plan.length > 0 ? payload.plan : null);
|
|
2926
|
+
const expiryAt = (parsed && parsed.expiryMs) || (typeof payload.expiresAt === 'number' ? payload.expiresAt : null);
|
|
2927
|
+
return { data: { provider: 'codex', plan: planType ? planDisplayName(planType) : null, planType: planType, expiryAt: expiryAt, windows: [] } };
|
|
2928
|
+
} catch (err) {
|
|
2929
|
+
return null;
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
|
|
2911
2933
|
async function fetchCodexUsage() {
|
|
2912
2934
|
// ① appAuth 优先:拿到额度窗口就用它(DSH Go 的唯一可用通道)
|
|
2913
2935
|
const viaAppAuth = await fetchCodexUsageViaAppAuth();
|
|
2914
2936
|
if (viaAppAuth && viaAppAuth.data) return viaAppAuth;
|
|
2915
|
-
// ②
|
|
2937
|
+
// ② 新版 dsh-chatgpt-sub 的 SIWC 会话(没有 Codex 文件也能显示套餐与有效期)
|
|
2938
|
+
const fromSession = await fetchCodexUsageFromSession();
|
|
2939
|
+
if (fromSession && fromSession.data) return fromSession;
|
|
2940
|
+
// ③ 旧版桌面文件通道:取到数据就用文件的数据,不被 appAuth 的失败状态遮住
|
|
2916
2941
|
const fromFile = fetchCodexUsageFromFile();
|
|
2917
2942
|
if (fromFile && fromFile.data) return fromFile;
|
|
2918
2943
|
// ③ 两条都失败:appAuth 存在时返回它的明确原因(「去 DSH App 授权」等),
|