Skip to content

feat: 新手任务一键领取 + 面板短信验证码登录 - #2

Open
mpmp666 wants to merge 1 commit into
Patrick130306:mainfrom
mpmp666:feat/onboarding-and-sms-login
Open

mpmp666 wants to merge 1 commit into
Patrick130306:mainfrom
mpmp666:feat/onboarding-and-sms-login

Conversation

@mpmp666

@mpmp666 mpmp666 commented Oct 11, 2026

Copy link
Copy Markdown

这个 PR 加了什么

两个功能,都是照 dsh-codearts-auth 里同协议实现移植过来的(那份实现踩过的坑已经写进代码注释)。

1. 新手任务一键领取(loomy2api/onboarding.py)

Loomy 的 8 个新手任务合计 10 000 积分,而服务端不校验前置行为 —— 完成条件在 Electron 客户端本地判定(onboarding-service.js),服务端只做「幂等置位 + 加分」。所以 8 个裸 POST /onboarding/tasks/complete 就能把新账号从 0 分打到 10 000 分,一个模型 token 都不用花。

实测(真实账号):

—— main ——
  ✓ 发送你的第一条消息 +500
  ✓ 试试选择一个技能 +1000
  ✓ 生成第一份 PPT +1500
  ✓ 设置定时任务 +1000
  ✓ 在技能广场安装一个技能 +1500
  ✓ 配置远程控制 +1000
  ✓ 创建你的第一个搭子 +1500
  ✓ 把搭子分享给朋友 +2000
  本次 +10000,累计 10000/10000

积分进的是永久池(余额 10000 + 每日 4571),不是每日额度 —— 这点对新账号很值。

重跑幂等:本次 +0,已完成 8/8(已完成的不发请求)。

2. 面板短信验证码登录(/api/panel/sms/send + /api/panel/sms/verify)

CLI 本来就有 sms / verify,但面板只能填「手机号+密码」或裸 session —— 没设过密码的账号、或者密码登录被风控拦的账号,在 UI 上根本加不进来。现在面板有了完整的两步流程:

填手机号 → 发送验证码 → 填验证码 → 验证并登录

msgid 存在浏览器里(只 5 分钟有效),所以服务端不需要任何登录态;同名账号走续期而不是重复添加。

3. 顺带

  • CLI 新增 loomy2api onboarding [name ...]
  • 面板每个账号行加「领任务」按钮

从参考实现带过来的四条语义(每条都是实测踩出来的,不是风格选择)

规则 为什么
幂等判据是响应体的 alreadyCompleted 不是 HTTP 码、不是 code;重放算成功
不采信服务端的 earned 按本地任务表现算(官方客户端也这么做,历史上两边不一致过)
上报 body 只有 key 无设备指纹、无版本号、无渠道号(OnboardingService 构造参数里就没有 getDeviceId)
认证失败(100002)立即中止整批 否则会对后续任务发一串必然失败的请求

测试

  • python -m loomy2api onboarding main → 8/8,+10 000(真实账号实测)
  • 重跑 → 0 请求、8 跳过(幂等)
  • 面板两个接口:不带 API Key → 401;带 Key 且空参数 → 参数校验报错;带 Key 正常参数 → 正确返回
  • 面板页面实测渲染(短信区块 + 每行「领任务」按钮)

说明

改动只有 6 个文件(onboarding.py 新增,其余 5 个接线),没有包含任何部署脚本或账号数据(accounts.json / config.json 本来就在 .gitignore 里)。

Two additions, ported from the `dsh-codearts-auth` implementation of the same
protocol.

* New `onboarding.py` — claim the eight newbie tasks (10 000 points total)
  through the API.  The upstream does **not** verify the prerequisite
  behaviour: the completion conditions live in the Electron client
  (`onboarding-service.js`), and the server only does "idempotent set + add
  points".  Eight bare `POST /onboarding/tasks/complete` calls therefore take
  a fresh account from 0 to 10 000 points without spending a single model
  token.  Measured on a real account: 8/8 claimed, balance 0 → 10 000, and the
  points land in the *permanent* pool (not the daily grant).

* SMS login in the web panel (`POST /api/panel/sms/send` and
  `POST /api/panel/sms/verify`).  The CLI already had `sms` / `verify`, but
  the panel only offered phone+password and a raw session — so an account
  without a password set, or one blocked by the password-login risk control,
  could not be added from the UI at all.  The panel keeps the `msgid` in the
  browser between the two steps (it is only valid for 5 minutes), so no
  server-side login state is needed.

Also included:

* `loomy2api onboarding [name ...]` CLI command.
* A "领任务" button on every account row in the panel.

Semantics carried over from the reference implementation, each of which is a
measured trap rather than a style choice:

* idempotency is judged by the response body's `alreadyCompleted` — not by the
  HTTP status, not by `code` (a replay counts as success);
* the server's `earned` is **not** trusted; points are recomputed locally from
  the task table (the official client does the same);
* the report body carries **only** `key` — no device fingerprint, no version,
  no channel;
* an auth failure (`100002`) aborts the whole batch instead of firing a string
  of doomed requests.

Tests: `python -m loomy2api onboarding <name>` on a real account (8/8, +10 000),
re-run for idempotency (0 requested, 8 skipped), plus manual verification of
both panel endpoints with and without the API-key gate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant