Quark Drive automation (夸克网盘)
Hard constraints (must follow)
- - Remote allowlist: Only operate under remote path prefix(es) configured in
references/config.json (or fallback references/config.example.json). Default allowlist should be /OpenClaw/**. - Local allowlist: Only read/upload from local path prefix(es) configured. Do not read arbitrary local paths.
- Destructive operations need confirmation by default: delete / move / rename / copy / purge.
- If Quark triggers captcha / risk control, stop and ask the user to take over in a real browser.
Privacy & safety (publishable skill defaults)
- - Treat these files as sensitive (never commit, never paste their contents):
-
references/session_api.json,
references/cookies.json,
references/login_token.json,
references/qr_code.png
- (If enabled)
references/index.json (may contain private filenames/paths)
- - Do not print cookies, auth headers, or full raw responses unless user explicitly requests debug.
- When sharing the skill, keep examples generic (no usernames, absolute paths, chat_id, or personal tokens).
Runtime / dependencies
- - Runtime: system Python (this repo does not bundle a venv).
- Dependencies are expected to be installed by the host (often via OS packages).
requirements.txt exists for portability/reference.
Config
- - Preferred: INLINECODE9
- Fallback: INLINECODE10
Key fields (example names; see config.example.json):
- -
remoteAllowlist: e.g. INLINECODE13 - INLINECODE14 : e.g. INLINECODE15
- INLINECODE16
Login workflow (QR)
Terminal (local)
1) Run
login-prepare to generate QR
2) User scans in Quark App
3) Run
login-wait to persist session
Any OpenClaw channel (Telegram / WhatsApp / 飞书 ...)
Use orchestration pattern:
1) Run:
channel-run <op> ...
2) If exit code ==
10 and JSON contains
need_login: true:
- Send
qr_png back to the
current chat/channel
- Immediately start
login-wait (poll every ~5s)
- When login succeeds,
automatically reply in the same chat/channel (e.g. “登录成功”) and then re-run the original INLINECODE23
Machine-readable interaction exit codes (for orchestration):
- - 10: INLINECODE24
- 11:
need_pick=true (multiple candidates; re-run with --pick) - 12:
need_confirm=true (destructive ops; re-run with --confirm)
Commands (scripts/quark_drive.py)
Invoke as:
Auth
- - INLINECODE30
- INLINECODE31
- INLINECODE32
- INLINECODE33
- INLINECODE34 (preferred)
- INLINECODE35 (alias)
Browse
- - INLINECODE36
- INLINECODE37
- INLINECODE38 (privacy default: scoped to
/OpenClaw/**)
Upload
Share (create link)
Conversation contract (important)
When the user asks to “生成分享链接/创建分享/分享某个文件(夹)”:
1)
Search candidates first (do not ask user to provide full remote path).
- Default: use server search.
- If server search is insufficient and the user wants stronger fuzzy search, use a
client-side fuzzy index and rank results by fuzzy score.
- Privacy default: build the index
in-memory (ephemeral) and do not write it to disk.
- Only keep candidates whose resolved path is inside remote allowlist.
2) If multiple candidates: list them with
index + path + type/size, ask user to pick.
3) Before creating the share, ask:
-
Expiry: 1 / 7 / 30 / 永久
-
Passcode: 有 / 无
- If 有: ask for the code; if user does not provide, generate one (4–6 alnum).
4) If user does not answer: default to
no passcode + permanent.
CLI
- - INLINECODE41
- INLINECODE42
- If multiple candidates and
--pick is omitted, returns JSON with
need_pick=true and a candidate list.
Local index helpers:
- -
index-build --root <remote_path> --max-items <n> [--write] (may issue many API calls; without --write it does not persist) - INLINECODE47 (builds ephemeral index; does not persist)
Share (save others' share into my drive / 转存)
Notes:
- - Quark typically forbids saving your own share (will error). Use an external share to test.
Destructive
- - INLINECODE49
- INLINECODE50
- INLINECODE51 (soft-delete into
/OpenClaw/.trash) - INLINECODE53
Troubleshooting
- -
auth-status fails (401/403): session expired → run login flow again. - INLINECODE55 fails with “用户禁止转存自己的分享”: you tried saving your own link → test with someone else’s share.
- If endpoints change and commands start 404/410xx: capture a browser network request (copy as cURL) and update adapter.
Quark Drive automation (夸克网盘)
硬性约束(必须遵守)
- - 远程白名单:仅操作 references/config.json(或回退 references/config.example.json)中配置的远程路径前缀。默认白名单应为 /OpenClaw/。
- 本地白名单:仅从配置的本地路径前缀读取/上传。不读取任意本地路径。
- 破坏性操作需确认(默认):删除/移动/重命名/复制/清空。
- 若夸克触发验证码/风控,停止操作并提示用户在真实浏览器中接管。
隐私与安全(可发布技能的默认设置)
- - 将以下文件视为敏感文件(绝不提交,绝不粘贴其内容):
- references/session
api.json、references/cookies.json、references/logintoken.json、references/qr_code.png
- (若启用)references/index.json(可能包含私有文件名/路径)
- - 除非用户明确请求调试,否则不打印cookies、认证头或完整原始响应。
- 分享技能时,示例保持通用性(不包含用户名、绝对路径、chat_id或个人令牌)。
运行时/依赖
- - 运行时:系统Python(本仓库不捆绑虚拟环境)。
- 依赖项应由宿主环境安装(通常通过操作系统包)。requirements.txt仅用于可移植性/参考。
配置
- - 首选:references/config.json
- 回退:references/config.example.json
关键字段(示例名称;详见config.example.json):
- - remoteAllowlist:例如 [/OpenClaw/]
- localAllowlist:例如 [/path/to/Uploads]
- loginTimeoutSeconds
登录流程(二维码)
终端(本地)
1) 运行 login-prepare 生成二维码
2) 用户在夸克App中扫描
3) 运行 login-wait 持久化会话
任意OpenClaw渠道(Telegram / WhatsApp / 飞书...)
使用编排模式:
1) 运行:channel-run <操作> [参数...]
2) 若退出码为
10 且JSON包含 need_login: true:
- 将 qr_png 发送回
当前聊天/渠道
- 立即启动 login-wait(每约5秒轮询一次)
- 登录成功后,
自动回复同一聊天/渠道(例如“登录成功”),然后重新运行原始 channel-run <操作> [参数...]
机器可读的交互退出码(用于编排):
- - 10:needlogin=true
- 11:needpick=true(多个候选项;使用 --pick 重新运行)
- 12:need_confirm=true(破坏性操作;使用 --confirm 重新运行)
命令(scripts/quark_drive.py)
调用方式:
- - python3 scripts/quark_drive.py <命令> [参数...]
认证
- - login
- login-prepare [--no-open]
- login-wait
- auth-status
- channel-run <操作> [参数...](推荐)
- telegram-run <操作> [参数...](别名)
浏览
- - mkdir <远程路径>
- ls <远程路径> [--json]
- search <关键词> [--allow-outside-openclaw](隐私默认:限定在 /OpenClaw/ 范围内)
上传
分享(创建链接)
对话约定(重要)
当用户要求“生成分享链接/创建分享/分享某个文件(夹)”时:
1)
先搜索候选项(不要求用户提供完整远程路径)。
- 默认:使用服务器搜索。
- 若服务器搜索不足且用户希望更强模糊搜索,使用
客户端模糊索引并按模糊分数排序结果。
- 隐私默认:在
内存中构建索引(临时),不写入磁盘。
- 仅保留解析路径在远程白名单内的候选项。
2) 若有多个候选项:列出
索引 + 路径 + 类型/大小,让用户选择。
3) 创建分享前,询问:
-
有效期:1 / 7 / 30 / 永久
-
提取码:有 / 无
- 若有:询问提取码;若用户未提供,自动生成一个(4-6位字母数字)。
4) 若用户未回答:默认
无提取码 + 永久有效。
CLI
- - share-create <远程路径> [--days 1|7|30|0] [--passcode XXXX] [--title ...]
- share-create-auto <关键词> [--pick N] [--days 1|7|30|0] [--passcode XXXX] [--local] [--allow-outside-openclaw]
- 若有多个候选项且省略 --pick,返回包含 need_pick=true 和候选项列表的JSON。
本地索引辅助命令:
- - index-build --root <远程路径> --max-items <数量> [--write](可能发起大量API调用;不加 --write 则不持久化)
- search-local <关键词> [--top N](构建临时索引;不持久化)
分享(转存他人分享到我的网盘)
- - share-save <分享文本或链接> [--passcode XXXX] [--to /OpenClaw/FromShares] [--no-wait]
注意:
- - 夸克通常禁止转存自己的分享(会报错)。请使用外部分享进行测试。
破坏性操作
- - rename <源路径> <新名称>
- mv <源路径> <目标目录>
- rm <源路径> --confirm(软删除至 /OpenClaw/.trash)
- purge-trash --days <天数> --confirm
故障排除
- - auth-status 失败(401/403):会话过期 → 重新执行登录流程。
- share-save 失败并提示“用户禁止转存自己的分享”:你尝试转存自己的链接 → 使用他人的分享进行测试。
- 若接口变更导致命令返回404/410xx:捕获浏览器网络请求(复制为cURL)并更新适配器。