dsh-checkin-all 0.0.0-stage → 0.5.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AIcivilization
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,283 @@
1
- # Temporary Holding Version
1
+ # dsh-checkin-all
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 每天自动给 **MiniMax Code**、**WPS 灵犀**、**百度 DuMate(搭子)** 和 **AStudio(星火)** 签到领积分。装进 [DeepSeek Harness](https://github.com/deepseek-ai/dsh)(dsh)之后,
4
+ 它会用本机 App 已经存好的登录凭据,每天到点调一次官方签到接口,签完记账,面板挂在对话页右侧栏,
5
+ **顶部按服务切换卡片**。
6
+
7
+ > 你不用记着签,也不用把账号密码交给任何东西——凭据本来就是 App 自己存的
8
+ > (MiniMax Code 在 `~/.minimax/auth/`,WPS 灵犀和 DuMate 在各自的 Cookies 里)。
9
+
10
+ > **为什么要自动签**:灵犀的连续签到断一天就归零(回退到第 1 天)。手动记着签太容易忘,
11
+ > 这个插件就是替你记住的那一下。
12
+
13
+ ## 支持的服务
14
+
15
+ | 服务 | 凭据来源 | 签到单位 | 「今天」按哪算 |
16
+ | --- | --- | --- | --- |
17
+ | MiniMax Code | `~/.minimax/auth/`(OAuth) | 分 | 本机时区 |
18
+ | WPS 灵犀 | 灵犀自己的 Cookies(`wps_sid`) | 智点 | **北京时间** |
19
+ | 百度 DuMate | `qianfan-desktop-app/auth.json`(加密 cookie) | 积分 | **北京时间** |
20
+ | AStudio | `~/.acode/acode/userdata/astron-session.json` | 积分 | **北京时间** |
21
+
22
+ 签到窗口不一样:灵犀、搭子和 AStudio 按北京时间算日期,美西晚上 8 点之后就已经是北京的第二天了。
23
+ 插件按各自的规则判断「今天」,互不干扰。
24
+
25
+ ## 它做什么
26
+
27
+ - **每个服务每天到点自动签到**:默认 09:00,可给每个服务单独设时间
28
+ - **顶部索引**:每个服务一张卡,显示登录状态、今天签没签、连续天数,点一下切到详情
29
+ - **补签**:电脑睡过了、DSH 半夜才启动,醒来照样补上(可关)
30
+ - **不重复签**:今天已经签过(哪怕你是在 App 里点的)就不动
31
+ - **自动续期**:access token 快过期时用 refresh token 换新的并**写回 App 的位置**,App 那边不受影响
32
+ - **记账**:每个服务分开记连续天数、累计积分、最近 14 天每天的结果
33
+ - **面板**:对话页右侧栏,顶部索引卡 + 每个服务的一周签到表 + 设置;DSH 设置里也有一块
34
+ - **对话里能用**:说「帮我签到」「MiniMax 积分还有多少」「以后每天 8 点签」就行
35
+ - **登录兜底**:凭据失效时给一个设备码,在浏览器里确认一次(和 App 里登录是同一条 OAuth 链路)
36
+
37
+ ## 安装
38
+
39
+ ```bash
40
+ # 从 npm(推荐)
41
+ dsh plugin --profile desktop add dsh-checkin-all
42
+
43
+ # 或者从仓库
44
+ git clone https://github.com/AIcivilization/dsh-checkin-all.git
45
+ dsh plugin --profile desktop add /path/to/dsh-checkin-all
46
+ ```
47
+
48
+ 完全退出 DSH(macOS 按 Cmd+Q,不是关窗口)再重新打开。
49
+
50
+ 装好后打开对话页右侧栏,引导页里点「自动签到」;或者「设置 → 自动签到」。
51
+
52
+ ## 命令行
53
+
54
+ 不开 DSH 也能用:
55
+
56
+ ```bash
57
+ node bin/dsh-checkin-all.js status # 每个服务:登录状态 + 本周签到表 + 连续天数
58
+ node bin/dsh-checkin-all.js checkin # 全部签到(--dry 只看不领)
59
+ node bin/dsh-checkin-all.js checkin lingxi # 只签灵犀(或 minimax / dumate / astudio)
60
+ node bin/dsh-checkin-all.js login # 设备码登录 MiniMax Code
61
+ node bin/dsh-checkin-all.js time 08:30 # 改自动签到时间
62
+ node bin/dsh-checkin-all.js on | off # 开 / 关自动签到
63
+ ```
64
+
65
+ ### 不依赖 DSH 常驻:挂到系统 crontab
66
+
67
+ ```cron
68
+ 0 9 * * * /usr/local/bin/node /Users/wf/dsh/dsh-checkin-all/bin/dsh-checkin-all.js cron >> ~/.dsh/dsh-checkin-all/cron.log 2>&1
69
+ ```
70
+
71
+ `cron` 是静默模式:今天签过了就什么都不做,只在真签的时候输出一行。
72
+
73
+ ## 在对话里
74
+
75
+ | 你说 | 会发生什么 |
76
+ | --- | --- |
77
+ | 帮我签到 / 领一下积分 | 调 `minimax_checkin`,三个服务都签(也可只签一个) |
78
+ | 灵犀连续多少天了 / 签到情况 | 调 `minimax_checkin_status`,给每个服务的一周表、连续天数 |
79
+ | 以后每天 8 点自动签 | 调 `minimax_checkin_config`,改时间(可只改一个服务) |
80
+ | MiniMax 登录失效了 | 调 `minimax_login`,给设备码和网址 |
81
+
82
+ 命令:`/checkin 状态|签到 [服务]|时间 09:00|开启|关闭|登录`(`/minimax` 是别名)
83
+
84
+ 服务名:`minimax`(MiniMax Code)/ `lingxi`(WPS 灵犀)/ `dumate`(百度 DuMate)/ `astudio`(AStudio)
85
+
86
+ ## 配置
87
+
88
+ 面板里改,或者 profile 的 `cordis.patch.yml` 里给 `id: dsh-checkin-all` 加 `config`:
89
+
90
+ ```yaml
91
+ - id: dsh-checkin-all
92
+ config:
93
+ enabled: true # 是否自动签到
94
+ time: '09:00' # 每天几点签
95
+ timeZone: '' # 时区覆盖,空 = 跟随本机(只影响 MiniMax;灵犀固定按北京时间)
96
+ catchUp: true # 过了时间才开机是否补签
97
+ notify: true # 签完是否提示
98
+ ```
99
+
100
+ 面板里可以给每个服务单独设开关和时间(存在 `config.json` 的 `providers` 字段里)。
101
+
102
+ 插件自己的数据(设置、签到历史)在 `~/.dsh/dsh-checkin-all/`:
103
+
104
+ - `config.json` — 设置(全局 + 每个服务的 `providers` 覆盖)
105
+ - `state.json` — 按服务分开记:最近一次结果、连续天数、累计积分、每天一条记录(保留 400 天)
106
+ ```
107
+ { "version": 2, "providers": { "minimax": {...}, "lingxi": {...} } }
108
+ ```
109
+ 老版本的单服务 `state.json` 会自动迁移成 `providers.minimax`,历史不丢。
110
+
111
+ ## 接口与凭据
112
+
113
+ ### MiniMax Code
114
+
115
+ MiniMax Code 桌面端自己用的就是这两个接口,插件原样调用(`lib/signin.js`):
116
+
117
+ ```
118
+ GET https://agent.minimax.io/minimax-cloud/api/v1/signin/status?timezone_id=<IANA>
119
+ POST https://agent.minimax.io/minimax-cloud/api/v1/signin/claim?timezone_id=<IANA>
120
+ Authorization: Bearer <access token>
121
+ ```
122
+
123
+ `agent.minimax.io` / `agent.minimax.cn` 按 region 分(`en` / `cn`)。**必须带 `timezone_id`**,
124
+ 不带会报 `invalid timezone_id`——这是「按谁的一天算」的关键。
125
+
126
+ 凭据(`lib/credentials.js`):
127
+
128
+ ```
129
+ ~/.minimax/auth/<buildEnv>/<region>/mcode-public/auth.json # { schemaVersion, records: { "<service>\0<account>": {...} } }
130
+ ~/.minimax/auth/<buildEnv>/<region>/mcode-public/auth-state.json # generation / expiresAtMs 必须和凭据对得上
131
+ ```
132
+
133
+ - `service` = `com.minimax.mcode.oauth.<buildEnv>.<region>`
134
+ - `account` = `base64url(sha256("<authHome>\0mcode-public"))`
135
+ - 文件 `0600`、目录 `0700`(App 会检查,太宽直接拒绝读)
136
+ - 写回在 `auth.lock` 的锁里做,和 App 自己的 `proper-lockfile` 兼容
137
+ - refresh token 是一次性的:换一次旧的就作废,所以必须写回
138
+
139
+ ### WPS 灵犀
140
+
141
+ ```
142
+ GET https://lingxi.wps.cn/api/public/v1/tasks # 任务列表
143
+ POST https://lingxi.wps.cn/api/public/v1/tasks/daily_check_in/claim # 签到
144
+ Cookie: wps_sid=<...>
145
+ ```
146
+
147
+ 签到数据在 `tasks[].task_key === "daily_check_in"` 那条里:
148
+
149
+ ```
150
+ extra.check_in_days 七天签到表 [{day, date, reward, status}]
151
+ extra.consecutive_days 连续签到天数(断一天就回 1)
152
+ extra.today_day 今天是第几天
153
+ data.total_claimed_credits 账户累计智点
154
+ status: claimed / available / locked
155
+ ```
156
+
157
+ 凭据(`lib/providers/lingxi.js`):读灵犀自己的 `Cookies`(SQLite,用 `node:sqlite` 只读打开),
158
+ 取 `wps_sid`。位置:`~/Library/Application Support/WPS 灵犀/Cookies`。
159
+
160
+ **日期按北京时间算**——服务器返回的 `date` 是北京日期。本机在美西时,晚上 8 点之后就已经是北京的第二天,
161
+ 所以灵犀的签到窗口和 MiniMax 完全不同,代码里两个 provider 分开判断。
162
+
163
+ ### 百度 DuMate(搭子)
164
+
165
+ ```
166
+ GET https://console.bce.baidu.com/api/dumate/points/loginBonusInfo 签到状态
167
+ POST https://console.bce.baidu.com/api/dumate/points/loginBonus 领今天的分
168
+ GET https://console.bce.baidu.com/api/dumate/points/quota_overview 积分总览
169
+ Cookie: <解密出来的 cookie>; csrftoken: <bce-user-info 的值>
170
+ ```
171
+
172
+ `loginBonusInfo` 返回:
173
+
174
+ ```json
175
+ {"totalTimes":2,"totalPoints":1000,"hasIssued":true,"signInDays":["2026-11-01","2026-11-02"]}
176
+ ```
177
+
178
+ **坑:必须带 `csrftoken` 头**(值来自 `bce-user-info` cookie,去掉引号)。
179
+ 少了它服务端一律回 `{"success":false,"message":{"global":"登录凭证已过期,请重新登录"}}`——
180
+ 这句话是误导的,cookie 其实好好的。注意不是 `X-Bce-Csrf-Token`,就叫 `csrftoken`。
181
+
182
+ 凭据(`lib/providers/dumate.js`):DuMate 把 cookie 加密存在
183
+ `~/Library/Application Support/qianfan-desktop-app/auth.json` 的 `cookies` 字段:
184
+
185
+ ```
186
+ base64( iv(12) || authTag(16) || ciphertext ) AES-256-GCM
187
+ 密钥:同目录 .cookie-key 的 32 字节
188
+ ```
189
+
190
+ 插件用 `node:crypto` 解密(不需要额外的原生模块)。
191
+
192
+ ### AStudio(星火)
193
+
194
+ AStudio 的「签到」= **每日登录积分**:每天首次连上时自动到账,桌面端用「每日积分」弹窗提示。
195
+ 插件复刻同一套调用(`lib/providers/astudio.js`):
196
+
197
+ ```
198
+ GET points/balance 积分余额(通用 + 星火)
199
+ GET points/summary 积分摘要
200
+ GET membership/me 当前套餐
201
+ GET membership/plan-config 每日登录积分配置(按套餐给 dailyLoginPoints)
202
+ GET client-popups/pending 待展示/待领取弹窗(每日积分在这里)
203
+ POST client-popups/complete 领取(body: { popupId, instanceKey })
204
+ ```
205
+
206
+ - 上游:`https://agent.xfyun.cn/xingchen-studio/`
207
+ - 认证:`Cookie` + 身份头 `clientType` / `studioVersion`
208
+ - `clientType` 按平台自动上报:Windows `21`、macOS/Linux `22`
209
+ - `studioVersion` 默认 `3.5.5`,可用环境变量 `ASTUDIO_VERSION` 覆盖
210
+ - 「今天」按**北京时间**算
211
+
212
+ 凭据(`lib/providers/astudio.js`)读 AStudio 的登录态文件 `astron-session.json`:
213
+
214
+ ```
215
+ # macOS / Linux
216
+ ~/.acode/acode/userdata/astron-session.json
217
+ # Windows
218
+ %USERPROFILE%\.acode\acode\userdata\astron-session.json
219
+ # { accountId, uid, token, ssoSessionId, mobile, ... }
220
+ ```
221
+
222
+ 凭据目录可用 `ASTUDIO_DATA_DIR` 环境变量覆盖(VPS 部署时指到同步目录)。
223
+
224
+ 拼出的 Cookie(和桌面端 `buildAstronCookieHeader` 一致):
225
+
226
+ ```
227
+ ssoSessionId=<ssoSessionId>; sso_sessionid=<ssoSessionId>; account_id=<accountId>; token=<token>
228
+ ```
229
+
230
+ ## 隐私
231
+
232
+ - 不保存账号密码,只用 App 已经存好的 OAuth 凭据
233
+ - 除了 MiniMax 自己的签到接口和 OAuth 接口,不往任何地方发请求
234
+ - 签到历史只写在本机 `~/.dsh/dsh-checkin-all/`
235
+
236
+ ## 部署到 VPS(无图形界面)
237
+
238
+ 可以。三个服务都支持,详细步骤见 **[docs/VPS.md](docs/VPS.md)**。
239
+
240
+ 三步:
241
+
242
+ ```bash
243
+ # 1) 传代码
244
+ rsync -av ~/dsh/dsh-checkin-all/ vps:/opt/dsh-checkin-all/
245
+
246
+ # 2) 传凭据(在本机跑)
247
+ bash ~/dsh/dsh-checkin-all/scripts/sync-to-vps.sh vps
248
+
249
+ # 3) 装(在 VPS 上)
250
+ ssh vps 'bash /opt/dsh-checkin-all/scripts/deploy-vps.sh /opt/dsh-checkin-all'
251
+ ```
252
+
253
+ 要点(细节见 docs/VPS.md):
254
+
255
+ - **时区**:VPS 多是 UTC,灵犀和搭子按北京时间算日期 → 签到时间设 **01:00**
256
+ - **MiniMax 的 refresh token 一次性**:VPS 默认只读(`DSH_CHECKIN_ALL_READONLY=1`),
257
+ 本机要定时 `sync-to-vps.sh` 同步;或者干脆只让 VPS 跑、本机关掉
258
+ - **灵犀和搭子不受限制**:cookie 多处使用不会互相失效
259
+
260
+ ### 环境变量
261
+
262
+ | 变量 | 作用 |
263
+ | --- | --- |
264
+ | `MINIMAX_DATA_DIR` | MiniMax 数据根目录(默认 `~/.minimax`) |
265
+ | `LINGXI_DATA_DIR` | 灵犀数据目录(默认 macOS 的 `~/Library/Application Support/WPS 灵犀`) |
266
+ | `DUMATE_DATA_DIR` | DuMate 数据目录(默认 `~/Library/Application Support/qianfan-desktop-app`) |
267
+ | `ASTUDIO_DATA_DIR` | AStudio 用户数据目录(默认 `~/.acode/acode/userdata`) |
268
+ | `ASTUDIO_VERSION` | AStudio 版本号(默认 `3.5.5`,用于上游 `studioVersion` 头) |
269
+ | `DSH_CHECKIN_ALL_READONLY` | `1` = 不刷新 refresh token |
270
+ | `DSH_CHECKIN_ALL_HOME` | 插件自己的状态目录(默认 `~/.dsh/dsh-checkin-all`) |
271
+
272
+ > 凭据文件的记录 key 里嵌了 **authHome 的绝对路径**,换目录后算出来的 key 对不上。
273
+ > 插件会自动按 service 前缀兜底找(`lib/credentials.js` 的 `pickRecord`),所以拷过去能用。
274
+
275
+ ## 开发
276
+
277
+ ```bash
278
+ node --test "test/*.test.js"
279
+ ```
280
+
281
+ ## License
282
+
283
+ MIT
@@ -0,0 +1,166 @@
1
+ #!/usr/bin/env node
2
+ // bin/dsh-checkin-all.js — 不开 DSH 也能用:查状态、签到、登录、改时间
3
+ //
4
+ // dsh-checkin-all status 所有服务:登录状态 + 本周签到表 + 连续天数
5
+ // dsh-checkin-all checkin [服务] 立刻签到(--dry 只看不领);不指定服务就全签
6
+ // dsh-checkin-all login 设备码登录 MiniMax Code
7
+ // dsh-checkin-all time 08:30 改自动签到时间
8
+ // dsh-checkin-all on | off 开 / 关自动签到
9
+ // dsh-checkin-all cron 给系统 crontab 用的静默签到
10
+ //
11
+ // 服务名:minimax(MiniMax Code)/ lingxi(WPS 灵犀)/ dumate(百度 DuMate)/ astudio(AStudio)
12
+ //
13
+ // 系统 crontab 里可以这样挂(不想依赖 DSH 常驻时):
14
+ // 0 9 * * * /path/to/dsh-checkin-all cron >> ~/.dsh/dsh-checkin-all/cron.log 2>&1
15
+
16
+ import { Runner } from '../lib/runner.js'
17
+ import { loadConfig, loadState, saveConfig, providerConfig } from '../lib/store.js'
18
+
19
+ const argv = process.argv.slice(2)
20
+ const command = (argv[0] || 'status').toLowerCase()
21
+ const flags = new Set(argv.slice(1).filter(a => a.startsWith('-')))
22
+ const rest = argv.slice(1).filter(a => !a.startsWith('-'))
23
+
24
+ const log = (message) => console.log(message)
25
+ const runner = new Runner({ log })
26
+
27
+ const STATUS_TAG = { 1: '未到', 2: '可领', 3: '已领', 4: '未开放' }
28
+
29
+ function printPanel(panel, unit) {
30
+ if (!panel || !panel.days.length) return console.log(' 签到表读不出来')
31
+ for (const day of panel.days) {
32
+ const mark = day.isToday ? ' ← 今天' : ''
33
+ const bonus = day.bonusPoints ? ` +${day.bonusPoints}奖励` : ''
34
+ console.log(` 第 ${day.dayNo} 天 ${String(day.points).padStart(5)}${bonus.padEnd(9)} ${STATUS_TAG[day.status] || day.status}${mark}`)
35
+ }
36
+ if (panel.consecutiveDays !== undefined) console.log(` 连续 ${panel.consecutiveDays} 天`)
37
+ console.log(` 本周已领 ${panel.claimedDays} 天,共 ${panel.totalPoints} ${unit}`)
38
+ if (panel.accountCredits) console.log(` 账户累计 ${panel.accountCredits} ${unit}`)
39
+ }
40
+
41
+ /** 按名字找服务 */
42
+ function findProvider(text) {
43
+ const metas = runner.meta()
44
+ if (!text) return null
45
+ const t = String(text).toLowerCase()
46
+ return metas.find(m => m.id === t || m.short === text || m.name.toLowerCase() === t
47
+ || m.name.toLowerCase().includes(t) || m.short.includes(text)) || null
48
+ }
49
+
50
+ async function main() {
51
+ const metas = runner.meta()
52
+
53
+ if (command === 'status') {
54
+ const cfg = await loadConfig()
55
+ const state = await loadState()
56
+ for (const meta of metas) {
57
+ const own = providerConfig(cfg, meta.id)
58
+ const account = await runner.account(meta.id).catch(e => ({ loggedIn: false, detail: e.message }))
59
+ const ps = (state.providers && state.providers[meta.id]) || {}
60
+ console.log(`── ${meta.name} ──`)
61
+ console.log(account.loggedIn
62
+ ? `登录:已登录(${account.detail || ''})`
63
+ : `登录:未登录${account.detail ? `(${account.detail})` : ''}`)
64
+ console.log(`自动签到:${own.enabled ? `每天 ${own.time}` : '已关闭'}${meta.timeZoneMode === 'fixed' ? `(按 ${meta.timeZone} 算日期)` : ''}`)
65
+ console.log(`连续 ${ps.streak || 0} 天`)
66
+ if (ps.lastAttempt) console.log(`最近一次:${ps.lastAttempt.message}`)
67
+ if (account.loggedIn) {
68
+ try {
69
+ const panel = await runner.panel(meta.id)
70
+ printPanel(panel, meta.unit)
71
+ } catch (error) {
72
+ console.log(` 读签到表失败:${error.message}`)
73
+ }
74
+ }
75
+ console.log('')
76
+ }
77
+ return
78
+ }
79
+
80
+ if (command === 'checkin' || command === 'sign' || command === '签到') {
81
+ const target = findProvider(rest[0])
82
+ const dryRun = flags.has('--dry') || flags.has('-d')
83
+ if (target) {
84
+ const result = await runner.run(target.id, { trigger: 'manual', dryRun })
85
+ console.log(`${target.short}:${result.message}`)
86
+ if (result.panel) printPanel(result.panel, target.unit)
87
+ process.exitCode = result.ok ? 0 : 1
88
+ return
89
+ }
90
+ const results = await runner.runAll({ trigger: 'manual', dryRun })
91
+ for (const r of results) {
92
+ const meta = metas.find(m => m.id === r.provider) || { short: r.provider, unit: '分' }
93
+ console.log(`${meta.short}:${r.message}`)
94
+ if (r.panel) printPanel(r.panel, meta.unit)
95
+ }
96
+ process.exitCode = results.every(r => r.ok) ? 0 : 1
97
+ return
98
+ }
99
+
100
+ if (command === 'login' || command === '登录') {
101
+ const info = await runner.loginStart('minimax')
102
+ console.log(`在浏览器打开:${info.verificationUri}`)
103
+ console.log(`设备码:${info.userCode}`)
104
+ console.log(`(或直接打开 ${info.verificationUriComplete})`)
105
+ console.log(`等待确认…(${Math.round(info.expiresInSec / 60)} 分钟内有效)`)
106
+ const result = await runner.loginWait('minimax', { timeoutMs: info.expiresInSec * 1000 })
107
+ console.log(`登录成功,凭据已写回 MiniMax Code(${result.expiresAt} 过期)`)
108
+ return
109
+ }
110
+
111
+ if (command === 'time' || command === '时间') {
112
+ const value = rest[0]
113
+ if (!/^([01]?\d|2[0-3]):[0-5]\d$/.test(String(value || ''))) {
114
+ console.error('用法:dsh-checkin-all time 08:30')
115
+ process.exitCode = 2
116
+ return
117
+ }
118
+ const [hour, minute] = String(value).split(':')
119
+ const time = `${hour.padStart(2, '0')}:${minute}`
120
+ await saveConfig({ time, providers: null })
121
+ console.log(`全部服务自动签到时间改为每天 ${time}`)
122
+ return
123
+ }
124
+
125
+ if (command === 'on' || command === 'off') {
126
+ await saveConfig({ enabled: command === 'on', providers: null })
127
+ console.log(`全部服务自动签到已${command === 'on' ? '开启' : '关闭'}`)
128
+ return
129
+ }
130
+
131
+ if (command === 'cron') {
132
+ const cfg = await loadConfig()
133
+ if (!cfg.enabled) return
134
+ const results = await runner.runAll({ trigger: 'auto' })
135
+ for (const r of results) {
136
+ const meta = metas.find(m => m.id === r.provider) || { short: r.provider }
137
+ console.log(`${new Date().toISOString()} ${meta.short} ${r.outcome} ${r.message}`)
138
+ }
139
+ process.exitCode = results.every(r => r.ok) ? 0 : 1
140
+ return
141
+ }
142
+
143
+ console.log(`用法:
144
+ dsh-checkin-all status 所有服务:登录状态 + 本周签到表
145
+ dsh-checkin-all checkin [服务] 立刻签到(--dry 只看不领)
146
+ dsh-checkin-all login 设备码登录 MiniMax Code
147
+ dsh-checkin-all time 08:30 改自动签到时间
148
+ dsh-checkin-all on | off 开 / 关自动签到
149
+ dsh-checkin-all cron 给系统 crontab 用的静默签到
150
+
151
+ 服务名:${metas.map(m => `${m.id}(${m.name})`).join(' / ')}`)
152
+ }
153
+
154
+ main().catch((error) => {
155
+ console.error(`出错:${error.message}`)
156
+ if (error.code === 'AUTH_REQUIRED' || error.code === 'AUTH_INVALID_GRANT' || error.code === 'AUTH_NO_REFRESH_TOKEN') {
157
+ console.error('MiniMax 登录状态没了,跑一次:dsh-checkin-all login')
158
+ }
159
+ if (error.code === 'LINGXI_NOT_LOGGED_IN' || error.code === 'LINGXI_NO_COOKIE_DB') {
160
+ console.error('灵犀没登录:打开 WPS 灵犀 App 登录一次')
161
+ }
162
+ if (error.code === 'ASTUDIO_NOT_LOGGED_IN' || error.code === 'ASTUDIO_SESSION_EXPIRED') {
163
+ console.error('AStudio 没登录或登录失效:打开 AStudio App 登录一次')
164
+ }
165
+ process.exitCode = 1
166
+ })
package/docs/VPS.md ADDED
@@ -0,0 +1,175 @@
1
+ # 在 VPS 上安装 dsh-checkin-all
2
+
3
+ 四个签到服务(MiniMax Code / WPS 灵犀 / 百度 DuMate / AStudio)都能在无图形界面的服务器上跑。
4
+ 凭据从本机拷过去,插件用环境变量指过去。
5
+
6
+ ---
7
+
8
+ ## 为什么不能直接装
9
+
10
+ VPS 上没有这四个 App,插件默认去这几个位置找凭据:
11
+
12
+ | 服务 | 默认位置(macOS) |
13
+ | --- | --- |
14
+ | MiniMax Code | `~/.minimax/auth/` |
15
+ | WPS 灵犀 | `~/Library/Application Support/WPS 灵犀/Cookies` |
16
+ | 百度 DuMate | `~/Library/Application Support/qianfan-desktop-app/{auth.json,.cookie-key}` |
17
+ | AStudio | `~/.acode/acode/userdata/astron-session.json` |
18
+
19
+ 所以要把凭据拷到 VPS,再用环境变量告诉插件去哪读。
20
+
21
+ ---
22
+
23
+ ## 三步装好
24
+
25
+ ### 1. 传代码
26
+
27
+ ```bash
28
+ # 在你电脑上
29
+ rsync -av ~/dsh/dsh-checkin-all/ vps:/opt/dsh-checkin-all/
30
+ ```
31
+
32
+ (或者用 DSH 面板的「文件」页拖上去。)
33
+
34
+ ### 2. 传凭据
35
+
36
+ ```bash
37
+ # 在你电脑上
38
+ bash ~/dsh/dsh-checkin-all/scripts/sync-to-vps.sh vps
39
+ ```
40
+
41
+ 这个脚本会:
42
+ - 在 VPS 建 `~/.minimax-auth/`(权限 700)
43
+ - 把三个服务的凭据都推过去
44
+ - 在 VPS 上跑一次 `dsh-checkin-all status` 验证
45
+
46
+ 如果想换凭据目录:`bash scripts/sync-to-vps.sh vps /root/.minimax-auth`
47
+
48
+ ### 3. 装插件
49
+
50
+ ```bash
51
+ # 在 VPS 上
52
+ ssh vps
53
+ bash /opt/dsh-checkin-all/scripts/deploy-vps.sh /opt/dsh-checkin-all
54
+ ```
55
+
56
+ 脚本会检查环境、link 进 profile、生成 `env.sh`、并跑一次 status。
57
+
58
+ ---
59
+
60
+ ## 接进 systemd
61
+
62
+ `deploy-vps.sh` 会生成 `~/.minimax-auth/env.sh`。dsh 由 systemd 管的话:
63
+
64
+ ```ini
65
+ [Service]
66
+ EnvironmentFile=/root/.minimax-auth/env.sh
67
+ ```
68
+
69
+ 然后:
70
+
71
+ ```bash
72
+ systemctl daemon-reload
73
+ systemctl restart <你的 dsh 服务名>
74
+ ```
75
+
76
+ 手动跑 dsh 的话,启动前 `source ~/.minimax-auth/env.sh`。
77
+
78
+ ---
79
+
80
+ ## 时区(容易踩)
81
+
82
+ VPS 通常是 UTC。四个服务的「今天」不一样:
83
+
84
+ | 服务 | 「今天」按哪算 |
85
+ | --- | --- |
86
+ | MiniMax Code | 本机时区(VPS 上就是 UTC) |
87
+ | WPS 灵犀 | **北京时间** |
88
+ | 百度 DuMate | **北京时间** |
89
+ | AStudio | **北京时间** |
90
+
91
+ 想在北京时间早上 9 点签,UTC 机器上要把灵犀、搭子和 AStudio 的签到时间设成 **01:00**。
92
+ 面板里可以给每个服务单独设时间。
93
+
94
+ ---
95
+
96
+ ## 凭据过期怎么办
97
+
98
+ | 服务 | 过期表现 | 怎么修 |
99
+ | --- | --- | --- |
100
+ | MiniMax | 401,`AUTH_READONLY_EXPIRED` | 本机重新登录 → 重跑 sync |
101
+ | 灵犀 | `LINGXI_NOT_LOGGED_IN` | 灵犀 App 里重新登录 → 重跑 sync |
102
+ | 搭子 | `DUMATE_API_ERROR` 或解密失败 | 搭子 App 里重新登录 → 重跑 sync |
103
+ | AStudio | `ASTUDIO_SESSION_EXPIRED` 或 `ASTUDIO_NOT_LOGGED_IN` | AStudio App 里重新登录 → 重跑 sync |
104
+
105
+ **建议挂个定时同步**(本机 crontab,每小时一次):
106
+
107
+ ```cron
108
+ 0 * * * * bash ~/dsh/dsh-checkin-all/scripts/sync-to-vps.sh vps >> ~/.dsh/dsh-checkin-all/sync.log 2>&1
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 关键:MiniMax 的 refresh token 是一次性的
114
+
115
+ 这是最容易出事的地方。实测确认:**RT 用一次旧的立刻作废**。
116
+
117
+ 所以两台机器共用一份 MiniMax 凭据时,**谁先刷新,另一个就 401**。
118
+
119
+ ### 三种策略
120
+
121
+ | 策略 | 做法 | 结果 |
122
+ | --- | --- | --- |
123
+ | **A. 只让 VPS 跑** | 本机把 MiniMax 自动签到关掉 | ✅ 最省心,一份凭据一处用 |
124
+ | **B. VPS 只读** | `DSH_CHECKIN_ALL_READONLY=1`(默认)+ 本机定时同步 | ⚠️ 能用,但 access token 约 1 小时过期,同步要跟上 |
125
+ | **C. 两边都跑,都刷新** | 不加只读 | ❌ 会互相踢 |
126
+
127
+ `deploy-vps.sh` 默认给的是 **B**(只读)。
128
+
129
+ 想改成 A(VPS 负责刷新):把 `env.sh` 里的 `DSH_CHECKIN_ALL_READONLY=1` 删掉或改成 0,
130
+ 同时**在本机把 MiniMax 的自动签到关掉**(面板里点一下)。
131
+
132
+ **灵犀和搭子不受这个限制**——它们用 cookie,多处使用不会互相失效。
133
+
134
+ ---
135
+
136
+ ## 面板里按服务开关
137
+
138
+ 正好用来做上面的取舍:
139
+
140
+ 1. 打开 DSH 网页版 → 右侧栏「自动签到」
141
+ 2. 点 MiniMax 那张卡
142
+ 3. 关掉「每天自动签到」→ 保存
143
+
144
+ 灵犀和搭子照常开着。
145
+
146
+ ---
147
+
148
+ ## 排查
149
+
150
+ ```bash
151
+ # 在 VPS 上
152
+ source ~/.minimax-auth/env.sh
153
+ dsh-checkin-all status # 三个服务的登录状态和签到表
154
+ dsh-checkin-all checkin --dry # 只看不签
155
+ ```
156
+
157
+ | 现象 | 原因 |
158
+ | --- | --- |
159
+ | `没找到 ... 的 Cookies 库` | `LINGXI_DATA_DIR` 没设,或文件没拷过去 |
160
+ | `AUTH_READONLY_EXPIRED` | 只读模式下 token 过期了,从本机重新同步 |
161
+ | `读不了 SQLite` | node 版本低于 22.5(灵犀用 `node:sqlite`) |
162
+ | 三张卡都在但都是「未登录」 | `env.sh` 没生效,检查 systemd 的 `EnvironmentFile` |
163
+
164
+ ---
165
+
166
+ ## 验证清单
167
+
168
+ 装完对照一下:
169
+
170
+ - [ ] `dsh-checkin-all status` 三个服务都显示「已登录」
171
+ - [ ] DSH 网页版右侧栏有三张卡
172
+ - [ ] 点「立刻签到」返回 `already_claimed` 或 `claimed`
173
+ - [ ] `env.sh` 已接进 systemd(`systemctl show <服务> -p EnvironmentFiles`)
174
+ - [ ] 本机 crontab 有定时同步(可选但建议)
175
+ - [ ] 时区换算对(UTC 机器上灵犀/搭子设 01:00)