@eddyskywalker/dsh-chatgpt-subscription 0.10.1 → 0.10.6

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 (29) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/lib/client.js +109 -0
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +1185 -357
  5. package/lib/types/client/minimax-code/MinimaxCodeSection.d.ts.map +1 -1
  6. package/lib/types/client/minimax-code/locales.d.ts +38 -2
  7. package/lib/types/client/minimax-code/locales.d.ts.map +1 -1
  8. package/lib/types/host/minimax-code/adapter.d.ts.map +1 -1
  9. package/lib/types/host/minimax-code/checkin-gateway.d.ts +109 -0
  10. package/lib/types/host/minimax-code/checkin-gateway.d.ts.map +1 -0
  11. package/lib/types/host/minimax-code/checkin.d.ts +150 -0
  12. package/lib/types/host/minimax-code/checkin.d.ts.map +1 -0
  13. package/lib/types/host/minimax-code/mapper.d.ts +52 -23
  14. package/lib/types/host/minimax-code/mapper.d.ts.map +1 -1
  15. package/lib/types/host/minimax-code/routes.d.ts +3 -0
  16. package/lib/types/host/minimax-code/routes.d.ts.map +1 -1
  17. package/lib/types/host/minimax-code/token-store.d.ts +15 -0
  18. package/lib/types/host/minimax-code/token-store.d.ts.map +1 -1
  19. package/lib/types/host/minimax-code/types.d.ts +25 -9
  20. package/lib/types/host/minimax-code/types.d.ts.map +1 -1
  21. package/lib/types/index.d.ts +1 -0
  22. package/lib/types/index.d.ts.map +1 -1
  23. package/lib/types/shared/minimax-code-contracts.d.ts +43 -0
  24. package/lib/types/shared/minimax-code-contracts.d.ts.map +1 -1
  25. package/package.json +31 -31
  26. package/lib/types/host/claude/__probe-assert.d.ts +0 -2
  27. package/lib/types/host/claude/__probe-assert.d.ts.map +0 -1
  28. package/lib/types/shared/__probe-claude-import.d.ts +0 -2
  29. package/lib/types/shared/__probe-claude-import.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - **MiniMax Code 线路新增每日自动签到(用户要求「类似 workbuddy」)**。桌面端「每日签到」积分(400/800/…/2000 的七日循环)现在可以本线路自动领取:设置卡片新增「每日签到」组(自动开关、今日已签 x/y、连签天数、本轮积分、上次运行、「立即签到」手动补签),语义与 workbuddy 调度器逐条对齐——启动即签、运行期每 10 分钟补检、幂等(已签只记录)、当日格未开放按小时复查、失败每日每账号至多 3 次、手动运行忽略开关与上限。
6
+ - **关键事实:官方客户端是开源的,签到用的就是本线路的 OAuth 凭据**。`MiniMax-AI/minimax-code`(MIT)里 `packages/tui/src/checkin/http-gateway.ts` 就是签到实现,`runtime/public-gateway.ts` 是请求构造:`GET /minimax-cloud/api/v1/signin/status` 读七日面板、今日格 `status=2`(可领)时 `POST .../signin/claim`,`claim_result: 1` 新签 / `2` 已签;源站按账号 region 走 `agent.minimaxi.com` / `agent.minimax.io`(**两区都签**,不像 workbuddy 只限国区);`user_id` 需要的 realUserID 由 `/v1/api/user/info` 解析并缓存进状态文件。响应校验(七日、day_no 1–7 不重复、可领/今日格至多各一)与连签算法逐行对齐官方 `shared/daily-signin.ts`。
7
+ - **签名头是网关强制项,这一点如实记录**。`yy` / `x-timestamp` / `x-signature` 就是本插件在配额功能里默认拒绝伪造的那组第一方标识头——官方源码自己的注释称它们是「标记请求来自第一方客户端的字面量」「不是凭据也不是安全边界」。配额读取没有它们也能诚实失败,**签到没有它们就是 400,没有绕行路径**,因此本功能必然发送它们(用户已在知晓这一点的前提下确认要做)。但两条诚实线仍守住:`User-Agent` 仍是插件自报家门(未伪造 `MiniMaxCode`),`desktop_version` 报插件自己的版本号而不是官方应用的版本号。
8
+ - **调研弯路也记录在案**:先按网页版(agent.minimax.cn 的 `_token` JWT + 设备注册)完整验证过 web 路径(含「插件自注册设备可复用该 JWT」的实测),后按用户指正找到官方 CLI 源码才发现 OAuth 才是正路,web-session 方案整体废弃、一行未留。探测过程中两次直接用池文件的 refresh token 手动刷新,耗尽了服务端轮换链导致本机登录态失效(已如实告知并由用户重新登录恢复)——**教训:凭据链操作必须走 `AccountPoolCore` 自己的读写路径,任何手写脚本都是刷新争用**。
9
+ - 结构:wire 半在 `src/host/minimax-code/checkin-gateway.ts`(请求签名、面板/领取校验、身份解析),调度半在 `src/host/minimax-code/checkin.ts`(队列、每日状态文件 `minimax-code-checkin.json`、汇总),路由 `/checkin/now` + `/settings` 的 `checkin.enabled`,凭据刷新完全复用号池的 `getFreshCredential`/`renewCredential`(401 先强刷一次再记失败)。
10
+ - **测试**:新增 22 条(`test/minimax-code-checkin.test.ts`)——可领即签、已签不发请求、`claim_result=2` 视为成功、双区源站、未开放按小时复查/手动覆盖、重试上限与手动豁免、开关、401 先续期再重试、跨天复用缓存身份、重启后状态恢复、签名头逐字节比对(yy/x-timestamp 秒级/x-signature 与官方一致)、面板/领取畸形拒绝、连签算法、路由层(手动签到、开关持久化、未装载 400、跨域 403)。全套 **1707 passed / 7 skipped**,仍只剩 6 条既有 Windows Antigravity 回调端口失败;强制 typecheck 与 build 全净。
11
+ - ⚠️ **端到端唯一未跑通的一步**:真实 `signin/status` + `claim` 的 OAuth 路径调用(`/v1/api/user/info` 已实测 200),因上述登录态失效待用户重新登录后实测。
12
+
13
+ - **跟进 DSH 0.2.0-rc.1(本机 harness 仓库更新,npm `next` 标签)**。`dsh-v0.1.7-rc.2..dsh-v0.2.0-rc.1` 共 793 个文件,但逐一审计插件导入的 20 个包与全部兼容缝后,**无需任何行为性适配**:`dsh-llm` / `dsh-settings` / `dsh-web` / `dsh-tools` 等核心包源码零改动(仅版本号),`vendor/`(cordis / loader / schemastery)字节相同;`conversation.input.right` 与 `tool.call.toolview` 插槽契约两 tag 间逐字节一致;`agent-loop` 新增的 `ToolCallRecovery` 只改写 harness 内部的会话事件簿记,不碰适配器边界的请求词汇;`session-controller` 客户端的 `fork(onCreated)`、`ui-model-selection` 的目录构造参、remotes 的 `productAnalyticsRemote` 全是插件不消费的新增面。运行时包名探测无一失效(`workflow-worker-thread` 仍是 0.1.6 桥接里的旧名回退,属设计如此)。本轮的实际变更:
14
+ - `package.json`:15 个 `@deepseek-ai/dsh-*` peer 区间各加 `|| ^0.2.0-rc.1`(预发布区间不跨版本组,该子句是必需的),devDependencies 基线 `^0.1.7-rc.2` → `^0.2.0-rc.1`;对 7 个历史运行时版本逐一做了 `semver.satisfies(includePrerelease)` 预检,全部通过。
15
+ - lockfile:`dsh-attachment@0.2.0-rc.1` 精确钉 `dsh-brand` peer,增量 `npm install` 如期死于 ERESOLVE,按既定做法干净重建(`rm -rf node_modules package-lock.json`);pnpm 侧 38 行排除表各加 `0.2.0-rc.1`、`pnpm-lock.yaml` 重建(363 条,36 个 dsh 包全部 0.2.0-rc.1)。
16
+ - **验证(三个房间同一份源码)**:新基线 0.2.0-rc.1 强制类型检查 + 构建全净,测试 **1685 passed / 7 skipped**(118 文件);旧基线净室(精确 0.1.7-rc.2)结果**逐项相同**——证明本轮无行为变化;老一代净室(0.1.5-rc.3)**1682 passed**,差额 3 条仍是已知受世代限制的 `dsh-ptc-runtime` 测试文件。三个房间均只剩 6 条既有的 Windows Antigravity 回调端口失败。详见 `.dsh/skills/dsh-harness-upgrade/references/0.2.0-rc.1.md`。
17
+
5
18
  - **找到并接上 mcode 自己的用量端点(用户要求「在我们这查看」)**。上一轮打的 `/v1/token_plan/remains` 是**平台**端点(只认平台 API 密钥),所以必然被拒。真正的端点在**官方客户端源码**里:`packages/tui/src/account/matrix-account-client.ts` 用 `GET https://agent.minimaxi.com/v1/api/openplatform/coding_plan/remains`(国际 `agent.minimax.io`)——**路径与平台端点完全不同**。现已改为该路径,主机按「本线路自己的 `agent.minimax.cn` 优先、官方主机兜底」探测并记住命中者。
6
19
  - ⚠️ **该请求带四个「官方客户端标识头」**:`yy` / `x-timestamp` / `x-signature` / `User-Agent: MiniMaxCode`。官方源码的注释自己写明这些字面量是「把请求标记为来自 MiniMax 第一方客户端」(同时注明它们并非凭据、也非安全边界,鉴权仍是 Bearer 令牌)。本插件 `types.ts` 已明确决定**不伪造官方客户端身份**,因此**默认一律不发**这些头——宁可拿到一个拒绝让卡片如实说明,也不冒充官方应用;确实要数字的用户可设 `DSH_MINIMAX_CODE_QUOTA_ATTRIBUTION=1` 显式选择该取舍。新增测试锁定该默认:未开启时四个头一个都不出现、`user-agent` 不是 `MiniMaxCode`;开启后恰好出现该组。
7
20
  - **诚实失败的三条保留**:`base_resp` 非 0 视为凭据被拒、只试一台就停、记住 30 分钟;其它失败按 `unreachable` 区分、记住 10 分钟;`/status` 只读缓存、绝不在轮询里发网络请求。
package/lib/client.js CHANGED
@@ -6213,6 +6213,18 @@ window.__ModuleLoader__.load({
6213
6213
  modelsHint: "模型目录由本线路硬编码(MiniMax Code 未开放 /v1/models 接口),当前共 {count} 个可用模型。勾选后模型才会出现在对话页的模型选择列表中;未勾选或关闭下方「启用此供应商」可在列表中隐藏该线路。",
6214
6214
  modelsUnavailable: "暂无可显示的模型。",
6215
6215
  quotaSection: "用量与配额",
6216
+ dailyCheckin: "每日签到",
6217
+ checkinHint: "用本线路自己的登录态签到(与官方 MiniMax Code 客户端同一条接口)。DSH 启动时自动签到一次,运行期间每 10 分钟补检,进程关闭的当天不会签到。",
6218
+ checkinAuto: "自动签到",
6219
+ checkinToday: "今日已签 {done}/{total}",
6220
+ checkinSkipped: "{count} 个暂不可签",
6221
+ checkinFailed: "{count} 个失败",
6222
+ checkinStreak: "连续 {days} 天",
6223
+ checkinClaimed: "本轮 +{points} 积分",
6224
+ checkinLastRun: "上次运行:{time}",
6225
+ checkinNever: "尚未运行",
6226
+ checkinNow: "立即签到",
6227
+ checkinRunning: "签到中…",
6216
6228
  quotaUnavailable: "暂时没有用量数据。",
6217
6229
  quotaNeedsApiKey: "上游拒绝了这个登录态读取用量(官方客户端的用量端点要求带官方客户端标识头,本插件默认不伪造)。请在 MiniMax 控制台的用量条里查看 Token Plan 用量;如果你接受该取舍,可设 DSH_MINIMAX_CODE_QUOTA_ATTRIBUTION=1 后重试。",
6218
6230
  quotaUnreachable: "暂时读不到用量(用量端点未应答),稍后会自动重试。",
@@ -6305,6 +6317,18 @@ window.__ModuleLoader__.load({
6305
6317
  modelsHint: "The catalog is hardcoded on this line (MiniMax Code exposes no /v1/models endpoint): {count} models available. Only checked models appear in the conversation model picker; unchecking or switching off \"Enable this provider\" hides the line from the list.",
6306
6318
  modelsUnavailable: "No model to show yet.",
6307
6319
  quotaSection: "Usage & quota",
6320
+ dailyCheckin: "Daily check-in",
6321
+ checkinHint: "Signs in with this line’s own credential (the same interface the official MiniMax Code client uses). The host signs in once at startup and re-checks every 10 minutes while running; a day the process never runs is not signed.",
6322
+ checkinAuto: "Auto check-in",
6323
+ checkinToday: "Checked in today {done}/{total}",
6324
+ checkinSkipped: "{count} not claimable yet",
6325
+ checkinFailed: "{count} failed",
6326
+ checkinStreak: "{days}-day streak",
6327
+ checkinClaimed: "+{points} credits this run",
6328
+ checkinLastRun: "Last run: {time}",
6329
+ checkinNever: "Never run",
6330
+ checkinNow: "Check in now",
6331
+ checkinRunning: "Checking in…",
6308
6332
  quotaUnavailable: "No usage data yet.",
6309
6333
  quotaNeedsApiKey: "The service refused this sign-in for the usage read (the official client's endpoint expects first-party attribution headers, which this plugin does not forge by default). Check the usage bar in the MiniMax console; if you accept that trade, set DSH_MINIMAX_CODE_QUOTA_ATTRIBUTION=1 and retry.",
6310
6334
  quotaUnreachable: "Usage is temporarily unreadable (the usage endpoint did not answer); this retries on its own.",
@@ -6473,12 +6497,17 @@ window.__ModuleLoader__.load({
6473
6497
  const [contextDrafts, setContextDrafts] = (0, react.useState)({});
6474
6498
  const [savingModel, setSavingModel] = (0, react.useState)(null);
6475
6499
  const [pool, setPool] = (0, react.useState)(void 0);
6500
+ const quotaFollowUp = (0, react.useRef)(void 0);
6476
6501
  const loadStatus = (0, react.useCallback)(async (quiet = false) => {
6477
6502
  if (!quiet) setError(null);
6478
6503
  try {
6479
6504
  const next = await get("/status");
6480
6505
  setStatus(next);
6481
6506
  setContextDrafts(contextDraftsFor$1(next));
6507
+ quotaFollowUp.current ??= createQuotaFollowUp();
6508
+ quotaFollowUp.current.observe(next.quotaRefreshing === true, () => {
6509
+ loadStatus(true);
6510
+ });
6482
6511
  } catch (cause) {
6483
6512
  if (!quiet) setError(messageOf(cause));
6484
6513
  } finally {
@@ -6499,6 +6528,7 @@ window.__ModuleLoader__.load({
6499
6528
  return () => {
6500
6529
  window.clearInterval(timer);
6501
6530
  document.removeEventListener("visibilitychange", refreshWhenVisible);
6531
+ quotaFollowUp.current?.cancel();
6502
6532
  };
6503
6533
  }, [loadStatus]);
6504
6534
  const loginId = flow?.loginId;
@@ -6689,6 +6719,32 @@ window.__ModuleLoader__.load({
6689
6719
  await loadStatus(true);
6690
6720
  }
6691
6721
  };
6722
+ /** Flip the check-in scheduler's own switch, through the same settings route. */
6723
+ const handleCheckinToggle = async (enabled) => {
6724
+ try {
6725
+ setBusy("checkin");
6726
+ setError(null);
6727
+ const updated = await post("/settings", { checkin: { enabled } });
6728
+ setStatus(updated);
6729
+ } catch (cause) {
6730
+ setError(messageOf(cause));
6731
+ } finally {
6732
+ setBusy(null);
6733
+ }
6734
+ };
6735
+ /** Run one check-in pass now: the toggle and the retry cap are bypassed. */
6736
+ const handleCheckinNow = async () => {
6737
+ try {
6738
+ setBusy("checkin");
6739
+ setError(null);
6740
+ const updated = await post("/checkin/now");
6741
+ setStatus(updated);
6742
+ } catch (cause) {
6743
+ setError(messageOf(cause));
6744
+ } finally {
6745
+ setBusy(null);
6746
+ }
6747
+ };
6692
6748
  const toggleModel = (modelId, checked) => {
6693
6749
  if (status === null) return;
6694
6750
  const current = status.models.filter((model) => model.enabled).map((model) => model.id);
@@ -6832,6 +6888,59 @@ window.__ModuleLoader__.load({
6832
6888
  onClearCooldown: (accountId) => void poolAction("clear-cooldown", accountId),
6833
6889
  onSetStrategy: (strategy) => void poolSetStrategy(strategy)
6834
6890
  }),
6891
+ status?.checkin != null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
6892
+ className: "dsha-group",
6893
+ children: [
6894
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6895
+ className: "dsha-grouphead",
6896
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("dailyCheckin") })
6897
+ }),
6898
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6899
+ className: "dsha-muted",
6900
+ children: t("checkinHint")
6901
+ }),
6902
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6903
+ className: "dsha-row",
6904
+ style: { marginBottom: 8 },
6905
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6906
+ className: "dsha-label",
6907
+ style: { fontWeight: 600 },
6908
+ children: t("checkinAuto")
6909
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
6910
+ type: "checkbox",
6911
+ checked: status.checkin.enabled,
6912
+ disabled: busy !== null,
6913
+ onChange: (event) => void handleCheckinToggle(event.currentTarget.checked)
6914
+ })]
6915
+ }),
6916
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6917
+ className: "dsha-row",
6918
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6919
+ className: "dsha-label",
6920
+ children: t("dailyCheckin")
6921
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
6922
+ className: "dsha-value",
6923
+ children: [
6924
+ t("checkinToday").replace("{done}", String(status.checkin.doneToday)).replace("{total}", String(status.checkin.totalAccounts)),
6925
+ status.checkin.skippedToday > 0 ? ` · ${t("checkinSkipped").replace("{count}", String(status.checkin.skippedToday))}` : "",
6926
+ status.checkin.failedToday > 0 ? ` · ${t("checkinFailed").replace("{count}", String(status.checkin.failedToday))}` : "",
6927
+ status.checkin.streakDays !== void 0 ? ` · ${t("checkinStreak").replace("{days}", String(status.checkin.streakDays))}` : "",
6928
+ status.checkin.claimedPoints !== void 0 ? ` · ${t("checkinClaimed").replace("{points}", String(status.checkin.claimedPoints))}` : "",
6929
+ ` · ${status.checkin.lastRunAt === null ? t("checkinNever") : t("checkinLastRun").replace("{time}", formatDate$1(status.checkin.lastRunAt))}`
6930
+ ]
6931
+ })]
6932
+ }),
6933
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6934
+ className: "dsha-actions",
6935
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6936
+ className: "dsha-btn",
6937
+ disabled: busy !== null,
6938
+ onClick: () => void handleCheckinNow(),
6939
+ children: busy === "checkin" ? t("checkinRunning") : t("checkinNow")
6940
+ })
6941
+ })
6942
+ ]
6943
+ }) : null,
6835
6944
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
6836
6945
  className: "dsha-group",
6837
6946
  children: [