@eddyskywalker/dsh-chatgpt-subscription 0.10.12 → 0.10.14

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 (58) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +185 -42
  3. package/lib/client.js +133 -26
  4. package/lib/client.js.map +1 -1
  5. package/lib/index.js +821 -292
  6. package/lib/types/client/claude/ClaudeSection.d.ts.map +1 -1
  7. package/lib/types/client/claude/locales.d.ts +17 -2
  8. package/lib/types/client/claude/locales.d.ts.map +1 -1
  9. package/lib/types/client/kimi-code/KimiCodeSection.d.ts.map +1 -1
  10. package/lib/types/client/kimi-code/locales.d.ts +17 -2
  11. package/lib/types/client/kimi-code/locales.d.ts.map +1 -1
  12. package/lib/types/compat.d.ts +35 -2
  13. package/lib/types/compat.d.ts.map +1 -1
  14. package/lib/types/host/adapter.d.ts +20 -1
  15. package/lib/types/host/adapter.d.ts.map +1 -1
  16. package/lib/types/host/claude/adapter.d.ts +11 -0
  17. package/lib/types/host/claude/adapter.d.ts.map +1 -1
  18. package/lib/types/host/claude/client.d.ts +7 -2
  19. package/lib/types/host/claude/client.d.ts.map +1 -1
  20. package/lib/types/host/claude/mapper.d.ts +13 -1
  21. package/lib/types/host/claude/mapper.d.ts.map +1 -1
  22. package/lib/types/host/claude/routes.d.ts.map +1 -1
  23. package/lib/types/host/claude/token-store.d.ts +9 -0
  24. package/lib/types/host/claude/token-store.d.ts.map +1 -1
  25. package/lib/types/host/claude/types.d.ts +35 -0
  26. package/lib/types/host/claude/types.d.ts.map +1 -1
  27. package/lib/types/host/codex-catalog.d.ts +54 -0
  28. package/lib/types/host/codex-catalog.d.ts.map +1 -0
  29. package/lib/types/host/codex-images.d.ts.map +1 -1
  30. package/lib/types/host/codex-search.d.ts.map +1 -1
  31. package/lib/types/host/kimi-code/adapter.d.ts.map +1 -1
  32. package/lib/types/host/kimi-code/mapper.d.ts +24 -9
  33. package/lib/types/host/kimi-code/mapper.d.ts.map +1 -1
  34. package/lib/types/host/kimi-code/routes.d.ts.map +1 -1
  35. package/lib/types/host/kimi-code/token-store.d.ts +11 -1
  36. package/lib/types/host/kimi-code/token-store.d.ts.map +1 -1
  37. package/lib/types/host/kimi-code/types.d.ts +13 -0
  38. package/lib/types/host/kimi-code/types.d.ts.map +1 -1
  39. package/lib/types/host/minimax-code/adapter.d.ts.map +1 -1
  40. package/lib/types/host/minimax-code/mapper.d.ts +22 -8
  41. package/lib/types/host/minimax-code/mapper.d.ts.map +1 -1
  42. package/lib/types/host/minimax-code/types.d.ts +64 -0
  43. package/lib/types/host/minimax-code/types.d.ts.map +1 -1
  44. package/lib/types/host/model-catalog.d.ts +3 -2
  45. package/lib/types/host/model-catalog.d.ts.map +1 -1
  46. package/lib/types/host/responses-client.d.ts +24 -0
  47. package/lib/types/host/responses-client.d.ts.map +1 -1
  48. package/lib/types/host/responses-mapper.d.ts +5 -1
  49. package/lib/types/host/responses-mapper.d.ts.map +1 -1
  50. package/lib/types/host/wire-auth.d.ts +14 -1
  51. package/lib/types/host/wire-auth.d.ts.map +1 -1
  52. package/lib/types/index.d.ts +1 -1
  53. package/lib/types/index.d.ts.map +1 -1
  54. package/lib/types/shared/claude-contracts.d.ts +19 -0
  55. package/lib/types/shared/claude-contracts.d.ts.map +1 -1
  56. package/lib/types/shared/kimi-code-contracts.d.ts +16 -0
  57. package/lib/types/shared/kimi-code-contracts.d.ts.map +1 -1
  58. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -3618,6 +3618,11 @@ window.__ModuleLoader__.load({
3618
3618
  defaultReasoningEffort: "默认思考档位",
3619
3619
  defaultReasoningEffortHint: "下拉列出的是目录中出现过的全部档位(含 xhigh);每个模型真正支持的档位见下方列表,Host 按模型自身的阶梯发送。",
3620
3620
  defaultEffortAuto: "使用模型默认值",
3621
+ cacheTtl: "提示缓存时长",
3622
+ cacheTtlHint: "Anthropic 提供 5 分钟与 1 小时两档。订阅用户在套餐额度内,官方 Claude Code 对主对话默认使用 1 小时;超出额度改按用量计费后官方会降回 5 分钟。1 小时写入更贵,短会话不划算。",
3623
+ cacheTtlSubscription: "跟随官方(订阅默认 1 小时)",
3624
+ cacheTtl1h: "1 小时",
3625
+ cacheTtl5m: "5 分钟",
3621
3626
  effortLow: "低 (low)",
3622
3627
  effortMedium: "中 (medium)",
3623
3628
  effortHigh: "高 (high)",
@@ -3741,6 +3746,11 @@ window.__ModuleLoader__.load({
3741
3746
  enhanced: "Thinking",
3742
3747
  defaultReasoningEffort: "Default thinking level",
3743
3748
  defaultReasoningEffortHint: "The list is every level the catalog names (xhigh included); the per-model ladder is listed below, and the Host sends what that model itself accepts.",
3749
+ cacheTtl: "Prompt cache duration",
3750
+ cacheTtlHint: "Anthropic offers 5-minute and 1-hour tiers. While a subscription is drawing on included plan usage, the official Claude Code uses the hour for the main conversation; once the plan is exhausted and requests bill against usage credits, it drops back to five minutes. A 1-hour write costs more, so it does not pay off for short sessions.",
3751
+ cacheTtlSubscription: "Follow the official (subscription default 1h)",
3752
+ cacheTtl1h: "1 hour",
3753
+ cacheTtl5m: "5 minutes",
3744
3754
  defaultEffortAuto: "Use the model default",
3745
3755
  effortLow: "Low",
3746
3756
  effortMedium: "Medium",
@@ -4211,6 +4221,18 @@ window.__ModuleLoader__.load({
4211
4221
  reportError(err);
4212
4222
  }
4213
4223
  };
4224
+ const handleUpdateCacheTtl = async (ttl) => {
4225
+ try {
4226
+ const updated = await fetchApi$7("/settings", {
4227
+ method: "POST",
4228
+ body: JSON.stringify({ cacheTtl: ttl })
4229
+ });
4230
+ setStatus(updated);
4231
+ notifyChange();
4232
+ } catch (err) {
4233
+ reportError(err);
4234
+ }
4235
+ };
4214
4236
  const handleSaveContextWindow = async (modelId) => {
4215
4237
  const raw = contextDrafts[modelId] || "";
4216
4238
  const parsed = parsePositiveCapacity$3(raw);
@@ -4630,6 +4652,36 @@ window.__ModuleLoader__.load({
4630
4652
  }, effort))]
4631
4653
  })]
4632
4654
  }),
4655
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4656
+ className: "dsha-pref-row",
4657
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t.cacheTtl }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4658
+ className: "dsha-muted",
4659
+ children: t.cacheTtlHint
4660
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
4661
+ className: "dsha-select",
4662
+ "aria-label": t.cacheTtl,
4663
+ value: status?.cacheTtl ?? "",
4664
+ disabled: busy !== null,
4665
+ onChange: (event) => {
4666
+ const value = event.currentTarget.value;
4667
+ handleUpdateCacheTtl(value === "" ? null : value);
4668
+ },
4669
+ children: [
4670
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
4671
+ value: "",
4672
+ children: t.cacheTtlSubscription
4673
+ }),
4674
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
4675
+ value: "1h",
4676
+ children: t.cacheTtl1h
4677
+ }),
4678
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
4679
+ value: "5m",
4680
+ children: t.cacheTtl5m
4681
+ })
4682
+ ]
4683
+ })]
4684
+ }),
4633
4685
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4634
4686
  className: "dsha-muted",
4635
4687
  style: { paddingTop: 10 },
@@ -4956,6 +5008,11 @@ window.__ModuleLoader__.load({
4956
5008
  enhanced: "思考设置",
4957
5009
  defaultReasoningEffort: "默认思考档位",
4958
5010
  defaultReasoningEffortHint: "Kimi Code 只接受 low / high / max 三档;none 表示关闭思考。切换档位会使上下文缓存失效,建议在同一会话中保持一致。",
5011
+ cacheTtl: "上下文缓存时长",
5012
+ cacheTtlHint: "Kimi 按前缀自动缓存,这里选择写入时长。1h 写入更贵,只有当同一前缀会在一小时内被反复读取才划算;档位在首次写入时锁定,之后无法改写。留空表示不指定,由 Kimi 自己决定。",
5013
+ cacheTtlDefault: "不指定(Kimi 默认)",
5014
+ cacheTtl5m: "5 分钟",
5015
+ cacheTtl1h: "1 小时",
4959
5016
  defaultEffortAuto: "使用模型默认值",
4960
5017
  effortLow: "低 (low)",
4961
5018
  effortHigh: "高 (high)",
@@ -5080,6 +5137,11 @@ window.__ModuleLoader__.load({
5080
5137
  enhanced: "Thinking",
5081
5138
  defaultReasoningEffort: "Default thinking level",
5082
5139
  defaultReasoningEffortHint: "Kimi Code accepts only low / high / max; none disables thinking. Switching the level invalidates the context cache, so keep it steady within a session.",
5140
+ cacheTtl: "Context cache duration",
5141
+ cacheTtlHint: "Kimi caches prefixes automatically; this chooses the write duration. A 1h write costs more and only pays off when the same prefix is re-read within the hour. The tier is locked when first written and cannot be changed afterwards. Leave unset to send no cache field and let Kimi decide.",
5142
+ cacheTtlDefault: "Unset (Kimi default)",
5143
+ cacheTtl5m: "5 minutes",
5144
+ cacheTtl1h: "1 hour",
5083
5145
  defaultEffortAuto: "Use the model default",
5084
5146
  effortLow: "Low",
5085
5147
  effortHigh: "High",
@@ -5538,6 +5600,18 @@ window.__ModuleLoader__.load({
5538
5600
  setError(err instanceof Error ? err.message : String(err));
5539
5601
  }
5540
5602
  };
5603
+ const handleUpdateCacheTtl = async (ttl) => {
5604
+ try {
5605
+ const updated = await fetchApi$6("/settings", {
5606
+ method: "POST",
5607
+ body: JSON.stringify({ cacheTtl: ttl })
5608
+ });
5609
+ setStatus(updated);
5610
+ notifyChange();
5611
+ } catch (err) {
5612
+ setError(err instanceof Error ? err.message : String(err));
5613
+ }
5614
+ };
5541
5615
  const handleSaveContextWindow = async (modelId) => {
5542
5616
  const raw = contextDrafts[modelId] || "";
5543
5617
  const parsed = parsePositiveCapacity$2(raw);
@@ -5919,32 +5993,65 @@ window.__ModuleLoader__.load({
5919
5993
  }),
5920
5994
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
5921
5995
  className: "dsha-group",
5922
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5923
- className: "dsha-grouphead",
5924
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t.enhanced })
5925
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5926
- className: "dsha-pref-row",
5927
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t.defaultReasoningEffort }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5928
- className: "dsha-muted",
5929
- children: t.defaultReasoningEffortHint
5930
- })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
5931
- className: "dsha-select",
5932
- "aria-label": t.defaultReasoningEffort,
5933
- value: status?.defaultReasoningEffort ?? "",
5934
- disabled: busy !== null,
5935
- onChange: (event) => {
5936
- const value = event.currentTarget.value;
5937
- handleUpdateEffort(value === "" ? null : value);
5938
- },
5939
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
5940
- value: "",
5941
- children: t.defaultEffortAuto
5942
- }), KIMI_CODE_REASONING_EFFORTS.map((effort) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
5943
- value: effort,
5944
- children: EFFORT_LABEL[effort]
5945
- }, effort))]
5946
- })]
5947
- })]
5996
+ children: [
5997
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5998
+ className: "dsha-grouphead",
5999
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t.enhanced })
6000
+ }),
6001
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6002
+ className: "dsha-pref-row",
6003
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t.defaultReasoningEffort }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6004
+ className: "dsha-muted",
6005
+ children: t.defaultReasoningEffortHint
6006
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
6007
+ className: "dsha-select",
6008
+ "aria-label": t.defaultReasoningEffort,
6009
+ value: status?.defaultReasoningEffort ?? "",
6010
+ disabled: busy !== null,
6011
+ onChange: (event) => {
6012
+ const value = event.currentTarget.value;
6013
+ handleUpdateEffort(value === "" ? null : value);
6014
+ },
6015
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
6016
+ value: "",
6017
+ children: t.defaultEffortAuto
6018
+ }), KIMI_CODE_REASONING_EFFORTS.map((effort) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
6019
+ value: effort,
6020
+ children: EFFORT_LABEL[effort]
6021
+ }, effort))]
6022
+ })]
6023
+ }),
6024
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6025
+ className: "dsha-pref-row",
6026
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t.cacheTtl }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6027
+ className: "dsha-muted",
6028
+ children: t.cacheTtlHint
6029
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
6030
+ className: "dsha-select",
6031
+ "aria-label": t.cacheTtl,
6032
+ value: status?.cacheTtl ?? "",
6033
+ disabled: busy !== null,
6034
+ onChange: (event) => {
6035
+ const value = event.currentTarget.value;
6036
+ handleUpdateCacheTtl(value === "" ? null : value);
6037
+ },
6038
+ children: [
6039
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
6040
+ value: "",
6041
+ children: t.cacheTtlDefault
6042
+ }),
6043
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
6044
+ value: "5m",
6045
+ children: t.cacheTtl5m
6046
+ }),
6047
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
6048
+ value: "1h",
6049
+ children: t.cacheTtl1h
6050
+ })
6051
+ ]
6052
+ })]
6053
+ })
6054
+ ]
5948
6055
  }),
5949
6056
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
5950
6057
  className: "dsha-group",