@goodandready/dsh-subscriptions 0.6.23 → 0.6.25

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 CHANGED
@@ -410,6 +410,9 @@ const cssId = 'dsh-subscriptions/settings.module.css'
410
410
  "diagCopy": "Copy report",
411
411
  "diagIssues": "Open issue tracker",
412
412
  "diagHint": "The report has no tokens, emails, proxy addresses or personal data.",
413
+ "cacheAnalyze": "Analyze Session Cache",
414
+ "cacheHitRate": "Cache Hit Rate",
415
+ "tokensSaved": "Saved Tokens",
413
416
  "subsPill": "SUBS",
414
417
  "subsModalTitle": "Subscription Hub",
415
418
  "subsActiveHero": "Active Subscription",
@@ -590,6 +593,9 @@ const cssId = 'dsh-subscriptions/settings.module.css'
590
593
  "diagCopy": "复制报告",
591
594
  "diagIssues": "打开 Issue 反馈",
592
595
  "diagHint": "诊断报告不包含令牌、邮箱、代理地址或任何个人隐私数据。",
596
+ "cacheAnalyze": "分析会话缓存",
597
+ "cacheHitRate": "缓存命中率",
598
+ "tokensSaved": "已节省 Token",
593
599
  "subsPill": "订阅",
594
600
  "subsModalTitle": "订阅管理中心",
595
601
  "subsActiveHero": "当前主用订阅",
@@ -802,6 +808,8 @@ const cssId = 'dsh-subscriptions/settings.module.css'
802
808
  const [device, setDevice] = React.useState({}) // #90 key -> {state,userCode,authUrl,intervalMs,status}
803
809
  const [proxyRes, setProxyRes] = React.useState({}) // #88 key -> {ok,latencyMs,error}
804
810
  const [diag, setDiag] = React.useState('')
811
+ const [sessionAnalysis, setSessionAnalysis] = React.useState(null)
812
+ const [analyzingCache, setAnalyzingCache] = React.useState(false)
805
813
  const [reset, setReset] = React.useState({}) // #85 key -> challenge state
806
814
  const [, setResetTick] = React.useState(0)
807
815
  React.useEffect(() => {
@@ -854,6 +862,37 @@ const cssId = 'dsh-subscriptions/settings.module.css'
854
862
  }
855
863
  }
856
864
  // #99: one click - fetch the anonymized report and copy it to the clipboard.
865
+ const runAnalyzeSession = () => {
866
+ setAnalyzingCache(true)
867
+ fetch('/dsh-subscriptions/history?limit=50', { cache: 'no-store' })
868
+ .then((r) => r.json())
869
+ .then((h) => {
870
+ const items = (h && h.items) || []
871
+ const events = items.map((it) => ({
872
+ usage: {
873
+ promptTokens: it.promptTokens || (it.tokens && it.tokens.prompt) || 0,
874
+ cachedTokens: it.cachedTokens || (it.tokens && it.tokens.cached) || 0,
875
+ completionTokens: it.completionTokens || (it.tokens && it.tokens.completion) || 0,
876
+ },
877
+ }))
878
+ return fetch('/dsh-subscriptions/analyze-session', {
879
+ method: 'POST',
880
+ headers: { 'Content-Type': 'application/json' },
881
+ body: JSON.stringify({ events }),
882
+ })
883
+ })
884
+ .then((r) => r.json())
885
+ .then((d) => {
886
+ setAnalyzingCache(false)
887
+ if (d && d.ok && d.analysis) {
888
+ setSessionAnalysis(d.analysis)
889
+ }
890
+ })
891
+ .catch((e) => {
892
+ setAnalyzingCache(false)
893
+ setErr(cleanErrorMessage(e && e.message || e))
894
+ })
895
+ }
857
896
  const genDiag = () => {
858
897
  fetch('/dsh-subscriptions/diagnostics', { cache: 'no-store' })
859
898
  .then((r) => r.json())
@@ -1481,9 +1520,14 @@ const cssId = 'dsh-subscriptions/settings.module.css'
1481
1520
  React.createElement('div', { className: 'dsub-block' },
1482
1521
  React.createElement('div', { className: 'dsub-row' },
1483
1522
  React.createElement('button', { type: 'button', className: 'dsub-mini', onClick: genDiag }, t('diagGenerate')),
1523
+ React.createElement('button', { type: 'button', className: 'dsub-mini', onClick: runAnalyzeSession }, analyzingCache ? '…' : t('cacheAnalyze')),
1484
1524
  React.createElement('a', { href: 'https://github.com/GooDAnDReaDY/dsh-subscriptions/issues', target: '_blank', rel: 'noopener noreferrer', className: 'dsub-mini' }, t('diagIssues')),
1485
1525
  ),
1486
1526
  React.createElement('div', { className: 'dsub-sub' }, t('diagHint')),
1527
+ sessionAnalysis ? React.createElement('div', { className: 'dsub-sub', style: { marginTop: '6px', fontWeight: 500 } },
1528
+ t('cacheHitRate') + ': ' + sessionAnalysis.weightedCacheHitPercent + '% · ' +
1529
+ t('tokensSaved') + ': ' + sessionAnalysis.savedTokens + ' / ' + sessionAnalysis.totalTokens
1530
+ ) : null,
1487
1531
  diag ? React.createElement('div', { className: 'dsub-row' },
1488
1532
  React.createElement('button', {
1489
1533
  type: 'button', className: 'dsub-mini',
@@ -56,6 +56,8 @@ export const Config = z.object({
56
56
  .description('#84 Composer quota indicator mode: off, percent, bar or forecast (predictive runway from a sliding window).'),
57
57
  codexRedirectUri: z.string().default(''),
58
58
  codexBaseUrl: z.string().default(''),
59
+ codexClientVersion: z.string().default('')
60
+ .description('Codex CLI identity version for /models catalog gating (e.g. 0.157.1). Empty uses the built-in default.'),
59
61
  claudeClientId: z.string().default(''),
60
62
  claudeRedirectUri: z.string().default(''),
61
63
  grokClientId: z.string().default(''),
@@ -19,6 +19,10 @@ export function registerProxyRoutes(ctx, state) {
19
19
  writeJson(res, 405, { ok: false, error: { code: 'method', message: 'POST only' } })
20
20
  return
21
21
  }
22
+ if (!isTrustedSettingsRequest(req)) {
23
+ writeJson(res, 403, { ok: false, error: { code: 'forbidden', message: 'same-origin only' } })
24
+ return
25
+ }
22
26
  const raw = await readBody(req, 128 * 1024).catch(() => Buffer.alloc(0))
23
27
  let body = {}
24
28
  try { body = JSON.parse(raw.toString('utf8') || '{}') } catch { body = {} }
@@ -30,14 +30,15 @@ export function defaults() {
30
30
  baseUrl: 'https://chatgpt.com/backend-api/codex',
31
31
  originator: 'codex_cli_rs',
32
32
  models: [
33
+ { id: 'gpt-6-astra', name: 'GPT-6 Astra' },
34
+ { id: 'gpt-6-sol', name: 'GPT-6 Sol' },
35
+ { id: 'gpt-6-luna', name: 'GPT-6 Luna' },
36
+ { id: 'gpt-5.6-sol', name: 'GPT-5.6 Sol' },
37
+ { id: 'gpt-5.6-terra', name: 'GPT-5.6 Terra' },
33
38
  { id: 'gpt-5.6-luna', name: 'GPT-5.6 Luna' },
34
- { id: 'gpt-5.3-codex', name: 'GPT-5.3 Codex' },
35
- { id: 'gpt-5.2-codex', name: 'GPT-5.2 Codex' },
36
- { id: 'gpt-5.1-codex', name: 'GPT-5.1 Codex' },
37
- { id: 'gpt-5.1-codex-mini', name: 'GPT-5.1 Codex Mini' },
38
- { id: 'gpt-5.1', name: 'GPT-5.1' },
39
+ { id: 'gpt-5.5', name: 'GPT-5.5' },
39
40
  ],
40
- clientVersion: '0.147.0',
41
+ clientVersion: '0.157.1',
41
42
  }
42
43
  }
43
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-subscriptions",
3
- "version": "0.6.23",
3
+ "version": "0.6.25",
4
4
  "description": "Use ChatGPT Codex, Claude, Grok, Antigravity, Kimi, GLM, Cursor, Kiro, Copilot, Qwen, ERNIE, Spark, JetBrains, Perplexity, Replit, and Cody subscriptions as DeepSeek Harness LLM providers via OAuth.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -37,7 +37,7 @@
37
37
  "url": "https://github.com/GooDAnDReaDY/dsh-subscriptions/issues"
38
38
  },
39
39
  "scripts": {
40
- "test": "eslint lib/ && node --test test/*.test.mjs",
40
+ "test": "eslint lib/ test/ && node --test test/*.test.mjs",
41
41
  "typecheck": "tsc -p tsconfig.checkjs.json"
42
42
  },
43
43
  "dsh": {