@fnnas-labs/fnos-cli 0.0.0-stage → 0.2.1
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 +21 -0
- package/README.md +169 -2
- package/THIRD_PARTY_NOTICES.txt +38904 -0
- package/cordis.patch.yml +3 -0
- package/npm/README.dsh.md +49 -0
- package/npm/acceptance-report.cjs +53 -0
- package/npm/dsh-integration.mjs +159 -0
- package/npm/dsh-test-support.mjs +55 -0
- package/npm/dsh.mjs +31 -0
- package/npm/install.cjs +140 -0
- package/npm/package-lib.cjs +274 -0
- package/npm/run.cjs +39 -0
- package/package.json +46 -4
- package/skill/LICENSE +21 -0
- package/skill/SKILL.md +143 -0
- package/skill/THIRD_PARTY_NOTICES.txt +38904 -0
- package/skill/bin/trim-cli-darwin-arm64 +0 -0
- package/skill/bin/trim-cli-darwin-x64 +0 -0
- package/skill/bin/trim-cli-linux-arm64 +0 -0
- package/skill/bin/trim-cli-linux-x64 +0 -0
- package/skill/bin/trim-cli-windows-arm64.exe +0 -0
- package/skill/bin/trim-cli-windows-x64.exe +0 -0
- package/skill/build-provenance.json +44 -0
- package/skill/entries/trim-app.md +63 -0
- package/skill/entries/trim-baidu-netdisk.md +42 -0
- package/skill/entries/trim-docker.md +35 -0
- package/skill/entries/trim-download.md +38 -0
- package/skill/entries/trim-file.md +30 -0
- package/skill/entries/trim-log.md +32 -0
- package/skill/entries/trim-monitor.md +41 -0
- package/skill/entries/trim-network.md +22 -0
- package/skill/entries/trim-photos.md +32 -0
- package/skill/entries/trim-shared.md +54 -0
- package/skill/entries/trim-storage.md +34 -0
- package/skill/entries/trim-system.md +59 -0
- package/skill/entries/trim-user.md +28 -0
- package/skill/manifest.json +43 -0
- package/skill/reference/_conventions.md +76 -0
- package/skill/reference/_index.md +78 -0
- package/skill/reference/app-center.md +234 -0
- package/skill/reference/baidu-netdisk.md +221 -0
- package/skill/reference/dockermgr.md +244 -0
- package/skill/reference/download.md +357 -0
- package/skill/reference/file.md +752 -0
- package/skill/reference/log.md +224 -0
- package/skill/reference/network.md +41 -0
- package/skill/reference/oauth.md +51 -0
- package/skill/reference/photos.md +158 -0
- package/skill/reference/power.md +34 -0
- package/skill/reference/resmon.md +160 -0
- package/skill/reference/stor.md +525 -0
- package/skill/reference/sysinfo.md +133 -0
- package/skill/reference/user.md +139 -0
- package/skill/reference/workflows/device-validation.md +66 -0
- package/skill/reference/workflows/file-routing.md +44 -0
- package/skill/reference/workflows/file-upload-validation.md +63 -0
- package/skill/reference/workflows/photos-routing.md +83 -0
- package/skill/reference/workflows/storage-dangerous-ops.md +53 -0
- package/skill/scripts/fnos-cli +63 -0
- package/skill/scripts/fnos-cli.cmd +36 -0
- package/skill/scripts/fnos-cli.ps1 +31 -0
- package/skill/scripts/trim-cli +63 -0
- package/skill/scripts/trim-cli.cmd +36 -0
- package/skill/scripts/trim-cli.ps1 +31 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# dockermgr 模块
|
|
2
|
+
|
|
3
|
+
## 模块概述
|
|
4
|
+
Docker 管理模块,涵盖 Docker 镜像、容器、网络、Compose 项目和 Docker 守护进程生命周期操作。
|
|
5
|
+
|
|
6
|
+
## 模块约定
|
|
7
|
+
- 镜像、容器、网络、Compose 和系统级端点分组管理。
|
|
8
|
+
- 区分列表/查询端点和长时间运行的变更端点。
|
|
9
|
+
- 命名空间说明:历史文档使用 `appcgi.dockermgr.*`,部分代码使用 `dockermgr.*`(如 `dockermgr.containerList`)。自动化调用时优先使用 `appcgi.dockermgr.*`。
|
|
10
|
+
|
|
11
|
+
## 任务路由
|
|
12
|
+
|
|
13
|
+
先判断是观察类还是变更类:
|
|
14
|
+
|
|
15
|
+
| 用户意图 | 优先命令 | 说明 |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| 看 Docker 总体状态 | `fnos-cli docker stats` | 适合作为进入 Docker 模块的只读探测 |
|
|
18
|
+
| 看镜像 | `fnos-cli docker image ls` / `inspect` | 需要镜像详情时再下钻 inspect |
|
|
19
|
+
| 拉镜像 | `fnos-cli docker image pull <imageRef> --yes` | 长耗时写操作,执行后应重新确认状态 |
|
|
20
|
+
| 看容器 | `fnos-cli docker container ls [--all]` / `inspect` / `stats` / `top` | `ls` 默认只列运行中容器;停止或创建态容器需要 `--all` |
|
|
21
|
+
| 启停、重启、强杀、删除容器 | `start/stop/restart/kill/rm` | 变更前建议先 inspect 或 ls |
|
|
22
|
+
| 看 Compose 项目 | `fnos-cli docker compose ls` | 目前优先作为只读入口 |
|
|
23
|
+
|
|
24
|
+
## 常见误判
|
|
25
|
+
|
|
26
|
+
- `docker stats` 是聚合统计,不是单容器统计
|
|
27
|
+
- `docker container ls` 默认不包含 stopped/created 容器;判断容器是否消失时使用 `docker container ls --all` 或按 ID 执行 `inspect`
|
|
28
|
+
- 列表接口成功但省略 `data` 时,只能确认请求成功,不能据此断言资源数量为 0;CLI 会保留原始成功信封,避免把后端漏字段伪装成空列表
|
|
29
|
+
- `image pull`、`container stop`、`container restart` 这类操作可能明显长于普通读请求
|
|
30
|
+
- `image pull` 与 `container create/update/start/stop/restart/kill` 必须显式传 `--yes`;删除命令可交互确认,但 Agent 或非交互流程也应传 `--yes`。`--force` 和 `--yes` 不是同一个概念
|
|
31
|
+
- `container update` 可能返回新 ID;CLI 会先 inspect 返回的 ID,确认本次资源字段已生效且网络配置未丢失后再报告成功。旧固件不返回 ID 时,CLI 会对原 ID 执行相同回查。后续操作使用命令输出的 ID
|
|
32
|
+
- 镜像引用和容器 ID 不是同一类标识,不要混传
|
|
33
|
+
|
|
34
|
+
## 高风险提醒
|
|
35
|
+
|
|
36
|
+
- 变更前先跑一条只读命令确认目标是否存在、当前状态是否符合预期
|
|
37
|
+
- 长耗时操作后要补一条只读命令确认结果,不要只看启动消息
|
|
38
|
+
- 删除类操作不应和不相关的镜像或容器清理打包在同一轮里
|
|
39
|
+
- 如果用户只说“把 Docker 弄一下”这类模糊目标,应先停下来确认是镜像、容器、网络还是 Compose
|
|
40
|
+
|
|
41
|
+
## 端点索引
|
|
42
|
+
- 镜像:
|
|
43
|
+
- `appcgi.dockermgr.imageList`
|
|
44
|
+
- `appcgi.dockermgr.imagePull`
|
|
45
|
+
- `appcgi.dockermgr.imageInspect`
|
|
46
|
+
- `appcgi.dockermgr.imageRemove`
|
|
47
|
+
- `appcgi.dockermgr.imageDownloadList`(通过 `docker request`)
|
|
48
|
+
- `appcgi.dockermgr.imageLoad`(通过 `docker request`)
|
|
49
|
+
- `appcgi.dockermgr.imageSave`(通过 `docker request`)
|
|
50
|
+
- `appcgi.dockermgr.imageUpgrade`(通过 `docker request`)
|
|
51
|
+
- `appcgi.dockermgr.imageCancel`(通过 `docker request`)
|
|
52
|
+
- 容器:
|
|
53
|
+
- `appcgi.dockermgr.containerList`
|
|
54
|
+
- `appcgi.dockermgr.containerCreate`
|
|
55
|
+
- `appcgi.dockermgr.containerInspect`
|
|
56
|
+
- `appcgi.dockermgr.containerTop`
|
|
57
|
+
- `appcgi.dockermgr.containerStats`
|
|
58
|
+
- `appcgi.dockermgr.containerStart`
|
|
59
|
+
- `appcgi.dockermgr.containerStop`
|
|
60
|
+
- `appcgi.dockermgr.containerRestart`
|
|
61
|
+
- `appcgi.dockermgr.containerKill`
|
|
62
|
+
- `appcgi.dockermgr.containerRemove`
|
|
63
|
+
- `appcgi.dockermgr.containerModify`
|
|
64
|
+
- 网络:
|
|
65
|
+
- `appcgi.dockermgr.networkCreate`
|
|
66
|
+
- `appcgi.dockermgr.networkList`
|
|
67
|
+
- `appcgi.dockermgr.networkRemove`
|
|
68
|
+
- `appcgi.dockermgr.networkConnect`
|
|
69
|
+
- `appcgi.dockermgr.networkDisconnect`
|
|
70
|
+
- 系统和 Compose:
|
|
71
|
+
- `appcgi.dockermgr.stats`
|
|
72
|
+
- `appcgi.dockermgr.composeList`
|
|
73
|
+
- `appcgi.dockermgr.systemStart`(通过 `docker request`)
|
|
74
|
+
- `appcgi.dockermgr.systemStop`(通过 `docker request`)
|
|
75
|
+
- `appcgi.dockermgr.systemRestart`(通过 `docker request`)
|
|
76
|
+
- `appcgi.dockermgr.composeContainers`(通过 `docker request`)
|
|
77
|
+
- `appcgi.dockermgr.composeCreate`(通过 `docker request`)
|
|
78
|
+
- `appcgi.dockermgr.composeStart`(通过 `docker request`)
|
|
79
|
+
- `appcgi.dockermgr.composeStop`(通过 `docker request`)
|
|
80
|
+
|
|
81
|
+
未封装为固定子命令的 `appcgi.dockermgr.*` 端点通过以下入口调用:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
fnos-cli docker request appcgi.dockermgr.<name> --json '<object>' --yes
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`--json` 必须是 JSON object,不能包含 `req` 或 `reqid`。泛化请求必须显式传 `--yes`,缺失时 CLI 会在读取 session 或访问网络前直接拒绝,不会进入交互提示;Docker system、network、Compose 和镜像导入导出类操作可能影响运行中服务,调用前应先执行只读探测。
|
|
88
|
+
|
|
89
|
+
## 端点详情
|
|
90
|
+
|
|
91
|
+
### appcgi.dockermgr.containerList
|
|
92
|
+
|
|
93
|
+
#### Endpoint
|
|
94
|
+
`appcgi.dockermgr.containerList`
|
|
95
|
+
|
|
96
|
+
#### Purpose
|
|
97
|
+
列出 Docker 容器及其运行时摘要信息。
|
|
98
|
+
|
|
99
|
+
#### Trim CLI Mapping
|
|
100
|
+
```
|
|
101
|
+
fnos-cli docker container ls [--all]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Request
|
|
105
|
+
| Field | Location | Required | Type | Meaning | Constraints / Notes | Example |
|
|
106
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
107
|
+
| `req` | body | yes | string | Endpoint selector | Fixed value | `appcgi.dockermgr.containerList` |
|
|
108
|
+
| `reqid` | body | yes | string | Request correlation ID | Generated per request | `69ba...` |
|
|
109
|
+
| `all` | body | no | boolean | 是否包含停止和创建态容器 | 仅 `--all` 时发送 `true`;默认只列运行中容器 | `true` |
|
|
110
|
+
|
|
111
|
+
#### Response
|
|
112
|
+
| Field | Always Present | Type | Meaning | Conditions / Notes | Example |
|
|
113
|
+
| --- | --- | --- | --- | --- | --- |
|
|
114
|
+
| `data` | no | array / object | 容器列表 | 格式可能因 Docker 版本而异 | `[{"name":"nginx","state":"running"}]` |
|
|
115
|
+
| `result` | no | string | Terminal marker | `succ`/`fail` | `succ` |
|
|
116
|
+
| `errno` | no | number | 错误码 | 失败时出现 | `65534` |
|
|
117
|
+
| `errmsg` | no | string | 错误描述 | | `docker not running` |
|
|
118
|
+
|
|
119
|
+
#### Protocol Notes
|
|
120
|
+
- 签名请求(当 session secret 可用时)。
|
|
121
|
+
- 历史名称别名:`dockermgr.containerList`。
|
|
122
|
+
- 判断容器在 update/stop 后是否仍存在时,使用 `--all` 或 `container inspect <id>`,不要仅凭默认列表下结论。
|
|
123
|
+
|
|
124
|
+
### appcgi.dockermgr.stats
|
|
125
|
+
|
|
126
|
+
#### Endpoint
|
|
127
|
+
`appcgi.dockermgr.stats`
|
|
128
|
+
|
|
129
|
+
#### Purpose
|
|
130
|
+
返回 Docker 聚合统计信息。
|
|
131
|
+
|
|
132
|
+
#### Trim CLI Mapping
|
|
133
|
+
```
|
|
134
|
+
fnos-cli docker stats
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### Response
|
|
138
|
+
| Field | Always Present | Type | Meaning | Conditions / Notes | Example |
|
|
139
|
+
| --- | --- | --- | --- | --- | --- |
|
|
140
|
+
| `data` | no | object | 聚合统计 | 包含利用率指标 | `{"cpu":12.5,"mem":47.1}` |
|
|
141
|
+
| `result` | no | string | Terminal marker | `succ`/`fail` | `succ` |
|
|
142
|
+
|
|
143
|
+
#### Field Semantics
|
|
144
|
+
- 聚合摘要端点;单容器指标使用 `containerStats`。
|
|
145
|
+
|
|
146
|
+
### appcgi.dockermgr.image.* 家族
|
|
147
|
+
|
|
148
|
+
#### Endpoint
|
|
149
|
+
`appcgi.dockermgr.imageList`、`imagePull`、`imageInspect`、`imageRemove`
|
|
150
|
+
|
|
151
|
+
#### Purpose
|
|
152
|
+
管理 Docker 镜像(列表/拉取/检查/删除)。
|
|
153
|
+
|
|
154
|
+
#### Trim CLI Mapping
|
|
155
|
+
```
|
|
156
|
+
fnos-cli docker image ls
|
|
157
|
+
fnos-cli docker image pull <imageRef> --yes
|
|
158
|
+
fnos-cli docker image inspect <imageRef>
|
|
159
|
+
fnos-cli docker image rm <imageRef> [--force] [--yes]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Request
|
|
163
|
+
| Field | Location | Required | Type | Meaning | Constraints / Notes | Example |
|
|
164
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
165
|
+
| `req` | body | yes | string | Endpoint selector | 对应具体操作 | `appcgi.dockermgr.imageList` |
|
|
166
|
+
| `reqid` | body | yes | string | Request correlation ID | Generated per request | `69ba...` |
|
|
167
|
+
| `fromImage` | body | conditional | string | 镜像名(imagePull) | 不含 tag 部分 | `nginx` |
|
|
168
|
+
| `tag` | body | conditional | string | 镜像标签(imagePull) | 未指定时默认 `latest` | `latest` |
|
|
169
|
+
| `imageId` | body | conditional | string | 镜像 ID 或引用(inspect/rm) | 可以是后端 ID 或如 `nginx:latest` | `nginx:latest` |
|
|
170
|
+
| `force` | body | no | boolean | 强制删除(imageRemove) | 仅 `--force` 时发送 | `true` |
|
|
171
|
+
|
|
172
|
+
#### Field Semantics
|
|
173
|
+
- `imagePull` 分割 `<imageRef>` 为 `fromImage` 和 `tag`;保留 registry 端口,如 `registry:5000/ns/app:1.0` → `fromImage="registry:5000/ns/app"`, `tag="1.0"`。
|
|
174
|
+
- `imageRemove` 默认要求确认,`--yes` 跳过确认。
|
|
175
|
+
- Pull/upgrade 可能是长时间运行的操作。
|
|
176
|
+
|
|
177
|
+
### appcgi.dockermgr.container.* 变更/详情家族
|
|
178
|
+
|
|
179
|
+
#### Endpoint
|
|
180
|
+
容器创建、生命周期和观察端点
|
|
181
|
+
|
|
182
|
+
#### Purpose
|
|
183
|
+
容器创建、启动/停止/重启/强杀/删除、检查、进程列表和统计。
|
|
184
|
+
|
|
185
|
+
#### Trim CLI Mapping
|
|
186
|
+
```
|
|
187
|
+
fnos-cli docker container create --image <imageRef> [--name <name>] [--start] [--restart] [--memory <mb>] [--cpu <shares>] [--env <key=value>] [--cmd <arg>] [--port <host:container[/proto]>] [--mount <source:target[:ro|rw]>] --yes
|
|
188
|
+
fnos-cli docker container update <containerId> [--restart] [--memory <mb>] [--cpu <shares>] --yes
|
|
189
|
+
fnos-cli docker container inspect <containerId>
|
|
190
|
+
fnos-cli docker container top <containerId>
|
|
191
|
+
fnos-cli docker container stats <containerId>
|
|
192
|
+
fnos-cli docker container start <containerId> --yes
|
|
193
|
+
fnos-cli docker container stop <containerId> --yes
|
|
194
|
+
fnos-cli docker container restart <containerId> --yes
|
|
195
|
+
fnos-cli docker container kill <containerId> --yes
|
|
196
|
+
fnos-cli docker container rm <containerId> [--force] [--yes]
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### Field Semantics
|
|
200
|
+
|
|
201
|
+
**containerCreate:**
|
|
202
|
+
- `--image` 必填,映射到请求中的镜像引用
|
|
203
|
+
- `--name` 可选容器名
|
|
204
|
+
- `--start` 映射到 `startWhenCreated: true`
|
|
205
|
+
- `--restart` 映射到 `restart: true`
|
|
206
|
+
- `--memory <mb>` 将 MB 转换为字节(如 `128` → `134217728`)
|
|
207
|
+
- `--cpu <shares>` 转发正整数 CPU shares
|
|
208
|
+
- `--env <key=value>` 可重复,映射到 `env[]`
|
|
209
|
+
- `--cmd <arg>` 可重复,映射到 `cmd[]`
|
|
210
|
+
- `--port <host:container[/proto]>` 可重复,映射到 `port[]`;协议默认 `tcp`
|
|
211
|
+
- `--mount <source:target[:ro|rw]>` 可重复,映射到 `mount[]`;权限默认 `rw`
|
|
212
|
+
- 默认值:`restart=false`、`privileged=false`、`net=['bridge']`、`cpu=0`、`memory=0`
|
|
213
|
+
- `create/update/start/stop/restart/kill` 必须显式传 `--yes`;`rm` 可交互确认,但 Agent 或非交互流程应传 `--yes`。
|
|
214
|
+
|
|
215
|
+
**containerModify:** CLI 先读取完整容器配置,将资源变更合并到当前配置后提交。若响应带 `rsp.id`,CLI 会 inspect 该 ID,并核对 `name/image/restart/privileged/gpuEnabled/cpu/memory/env/cmd/capAdd/capDrop/link/mount/port/networks`;全部字段与提交配置一致后才报告成功,其中集合字段按无序内容比较,网络还会核对名称及静态地址。若旧固件省略 `rsp.id`,则对原 ID 执行相同回查。
|
|
216
|
+
|
|
217
|
+
**containerCreate 成功响应**可能为顶层 `rsp` 对象(Docker 风格大写 key,如 `{"Id":"abcd","Warnings":[]}`),而不是嵌套在 `data.rsp` 中。
|
|
218
|
+
|
|
219
|
+
**containerInspect/top/stats/start/stop/restart/kill:** 通过 `containerId` 标识。
|
|
220
|
+
|
|
221
|
+
`container top` 需要目标容器处于运行状态。CLI 会先 inspect;当 `State.Running=false` 时在本地返回明确提示,不再发送会产生设备 errno 的 top 请求。
|
|
222
|
+
|
|
223
|
+
**containerRemove:** 通过 `containerId` 标识;`force` 仅在 `--force` 时发送;默认要求确认,`--yes` 跳过。
|
|
224
|
+
|
|
225
|
+
#### Errors
|
|
226
|
+
- 常见错误:容器不存在、无效状态转换、权限不足。
|
|
227
|
+
|
|
228
|
+
### appcgi.dockermgr.composeList
|
|
229
|
+
|
|
230
|
+
#### Endpoint
|
|
231
|
+
`appcgi.dockermgr.composeList`
|
|
232
|
+
|
|
233
|
+
#### Purpose
|
|
234
|
+
列出 Docker Compose 项目。
|
|
235
|
+
|
|
236
|
+
#### Trim CLI Mapping
|
|
237
|
+
```
|
|
238
|
+
fnos-cli docker compose ls
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## 注意事项
|
|
242
|
+
- 镜像拉取/升级和 Compose 操作是长时间运行的,可能涉及进度/取消模式。
|
|
243
|
+
- Docker 守护进程的启动/停止/重启是高影响操作,可能影响运行中的容器。
|
|
244
|
+
- 部分端点的详细请求/响应 schema 尚未完全规范化。
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
# download 模块
|
|
2
|
+
|
|
3
|
+
## 模块概述
|
|
4
|
+
下载中心模块,映射到 `appcgi.downloadcenter.*` 命名空间。支持通过 URL/磁力链接/种子文件创建下载任务,以及任务查询、控制和统计。
|
|
5
|
+
|
|
6
|
+
下载中心请求使用与其他 CGI 调用相同的 `{ req, reqid, ...params }` 格式,但部分端点通过 `data.rsp`、`data.body` 或 `data.block.data` 返回业务数据。
|
|
7
|
+
|
|
8
|
+
## 协议模型
|
|
9
|
+
|
|
10
|
+
### 请求模型
|
|
11
|
+
|
|
12
|
+
典型请求格式:
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"reqid": "250318103000ABCDEF0123456789ABCD",
|
|
17
|
+
"req": "appcgi.downloadcenter.task.query",
|
|
18
|
+
"init_flag": true,
|
|
19
|
+
"state_filter": 65535
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
注意事项:
|
|
24
|
+
- 部分参数在 API 层使用 camelCase(如 `initFlag`),但 CGI 层使用 snake_case(如 `init_flag`)
|
|
25
|
+
- 多数端点接受可选 `uid` 参数
|
|
26
|
+
- `task.addUris` 的 `save_dir` 在实际使用中是必需的
|
|
27
|
+
|
|
28
|
+
### 响应模型
|
|
29
|
+
|
|
30
|
+
响应数据可能嵌套在不同位置:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"reqid": "...",
|
|
35
|
+
"result": "succ",
|
|
36
|
+
"req": "appcgi.downloadcenter.task.query",
|
|
37
|
+
"data": {
|
|
38
|
+
"block": {
|
|
39
|
+
"id": "20260318160514HlEnuPgC19HGBlXP",
|
|
40
|
+
"total_size": 41653,
|
|
41
|
+
"offset": 0,
|
|
42
|
+
"data": "{\"tasks\":[],\"stats\":{}}"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
业务数据可能位于 `data.rsp`、`data.body` 或 `data.block.data`(JSON 字符串需解码)。
|
|
49
|
+
|
|
50
|
+
### 终态和错误处理
|
|
51
|
+
|
|
52
|
+
终态值:`succ`、`fail`、`cancel`
|
|
53
|
+
|
|
54
|
+
处理规则:
|
|
55
|
+
- 传输完成和业务成功是独立关注点
|
|
56
|
+
- 保留 `errno`、`errmsg` 和 `extra`
|
|
57
|
+
- 部分控制类端点成功时返回简单的 `"ok"`
|
|
58
|
+
- 部分端点返回 `{ code: 200, body: {} }` 格式
|
|
59
|
+
- 批量创建端点可能返回 `errs[]`(即使请求本身成功)
|
|
60
|
+
|
|
61
|
+
### 大块传输
|
|
62
|
+
|
|
63
|
+
- 单包不超过 1 MiB
|
|
64
|
+
- 大载荷使用相同 `reqid` 分块传输
|
|
65
|
+
- 响应包含 `block.id`、`block.total_size`、`block.offset`、`block.data`
|
|
66
|
+
|
|
67
|
+
## 端点索引
|
|
68
|
+
|
|
69
|
+
### 查询类(已实现)
|
|
70
|
+
- `appcgi.downloadcenter.task.query` — 任务列表和统计
|
|
71
|
+
- `appcgi.downloadcenter.task.search` — 关键字搜索
|
|
72
|
+
- `appcgi.downloadcenter.task.getInfo` — 任务详情
|
|
73
|
+
- `appcgi.downloadcenter.task.getFiles` — 任务文件列表
|
|
74
|
+
|
|
75
|
+
### 创建类(已实现)
|
|
76
|
+
- `appcgi.downloadcenter.task.addUris` — 从 URL/磁力链接创建
|
|
77
|
+
- `appcgi.downloadcenter.task.addPaths` — 从 NAS 上的种子文件创建
|
|
78
|
+
|
|
79
|
+
### 控制类(已实现)
|
|
80
|
+
- `appcgi.downloadcenter.task.pause` — 暂停任务
|
|
81
|
+
- `appcgi.downloadcenter.task.resume` — 恢复任务
|
|
82
|
+
- `appcgi.downloadcenter.task.retry` — 重试任务
|
|
83
|
+
- `appcgi.downloadcenter.task.delete` — 删除任务
|
|
84
|
+
|
|
85
|
+
### 统计类(已实现)
|
|
86
|
+
- `appcgi.downloadcenter.stat.all` — 汇总统计
|
|
87
|
+
|
|
88
|
+
### 泛化请求入口
|
|
89
|
+
|
|
90
|
+
未封装为固定子命令的 `appcgi.downloadcenter.*` 端点通过以下入口调用:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
fnos-cli download request appcgi.downloadcenter.<name> --json '<object>' --yes
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
- `--json` 必须是 JSON object,不能包含 `req` 或 `reqid`,CLI 会自动注入。
|
|
97
|
+
- 默认需要交互确认;自动化或确认过风险后用 `--yes`。
|
|
98
|
+
- 响应会按下载中心常见位置解包:`data.rsp`、`data.body`、`data.block.data`。
|
|
99
|
+
|
|
100
|
+
通过 `download request` 覆盖的端点包括:
|
|
101
|
+
- 创建类:`task.addfnShareLink`、`task.getfnShareLinkStatus`
|
|
102
|
+
- 控制类:`task.pin`、`task.setForceStart`、`task.setFilePriority`、`task.exportTorrentFile`、`task.setDownloadLimit`、`task.setUploadLimit`、`task.setShareLimit`
|
|
103
|
+
- 配置类:`config.getDefaultSaveDir`、`config.setDefaultSaveDir`、`config.getTransferCfg`、`config.setTransferCfg`、`config.getNetworkCfg`、`config.setNetworkCfg`、`config.getAltCfg`、`config.setAltCfg`、`config.getListColumns`、`config.setListColumns`
|
|
104
|
+
- 统计类:`stat.qbittorrent`、`stat.aria2`
|
|
105
|
+
- Tracker 类:`task.getTrackers`、`task.addTrackers`、`task.removeTrackers`、`task.editTracker`、`tracker.query`、`tracker.insert`、`tracker.delete`
|
|
106
|
+
- Peer 类:`task.getPeers`、`task.addPeers`、`transfer.banPeers`
|
|
107
|
+
- 扫描目录:`scanDir.query`、`scanDir.insert`、`scanDir.delete`
|
|
108
|
+
- 工具类:`util.getDirFreeSpace`、`util.isTcpPortInUse`
|
|
109
|
+
- 管理员:`admin.getUsers`
|
|
110
|
+
|
|
111
|
+
`task.addUploadFile` 涉及上传文件内容和大块传输,不是普通 JSON 参数请求;优先使用文件上传相关命令完成本地文件上传后,再按设备行为调用下载中心端点。
|
|
112
|
+
|
|
113
|
+
## 端点详情
|
|
114
|
+
|
|
115
|
+
### appcgi.downloadcenter.task.query
|
|
116
|
+
|
|
117
|
+
#### Endpoint
|
|
118
|
+
`appcgi.downloadcenter.task.query`
|
|
119
|
+
|
|
120
|
+
#### Purpose
|
|
121
|
+
查询任务列表、聚合统计和下载引擎错误信息。
|
|
122
|
+
|
|
123
|
+
#### Trim CLI Mapping
|
|
124
|
+
```
|
|
125
|
+
fnos-cli download ls
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Request
|
|
129
|
+
| Field | Location | Required | Type | Meaning | Constraints / Notes | Example |
|
|
130
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
131
|
+
| `req` | body | yes | string | Endpoint selector | Fixed value | `appcgi.downloadcenter.task.query` |
|
|
132
|
+
| `reqid` | body | yes | string | Request correlation ID | Generated per request | `69ba...` |
|
|
133
|
+
| `engine_types` | body | no | array | 引擎类型过滤 | 可选 | `[1,2]` |
|
|
134
|
+
| `ids` | body | no | array | 指定任务 ID | 可选 | `[42,43]` |
|
|
135
|
+
| `state_filter` | body | no | number | 状态过滤掩码 | CLI 默认 `65535`(所有状态) | `65535` |
|
|
136
|
+
| `type_filter` | body | no | number | 类型过滤 | 可选 | `1` |
|
|
137
|
+
| `init_flag` | body | no | boolean | 初始化标志 | CLI 默认 `true` | `true` |
|
|
138
|
+
| `uid` | body | no | number | 用户 ID | 可选 | `1000` |
|
|
139
|
+
|
|
140
|
+
#### Response
|
|
141
|
+
主要响应字段(位于 `data.block.data` 解码后):
|
|
142
|
+
|
|
143
|
+
| Field | Always Present | Type | Meaning | Conditions / Notes | Example |
|
|
144
|
+
| --- | --- | --- | --- | --- | --- |
|
|
145
|
+
| `tasks` | no | array | 任务列表 | 包含任务摘要信息 | `[...]` |
|
|
146
|
+
| `stats` | no | object | 聚合统计 | 速度和大小统计 | `{...}` |
|
|
147
|
+
| `errors` | no | array | 引擎错误 | 下载引擎报告的错误 | `[...]` |
|
|
148
|
+
|
|
149
|
+
常见任务字段:`id`、`type`、`name`、`state`、`total_size`、`size`、`dl_speed`、`up_speed`、`save_dir`、`uri`、`addition_time`、`error_code`、`error_message`
|
|
150
|
+
|
|
151
|
+
### appcgi.downloadcenter.task.search
|
|
152
|
+
|
|
153
|
+
#### Endpoint
|
|
154
|
+
`appcgi.downloadcenter.task.search`
|
|
155
|
+
|
|
156
|
+
#### Purpose
|
|
157
|
+
按任务名或文件名搜索下载任务。
|
|
158
|
+
|
|
159
|
+
#### Trim CLI Mapping
|
|
160
|
+
```
|
|
161
|
+
fnos-cli download ls <keyword>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### Request
|
|
165
|
+
| Field | Location | Required | Type | Meaning | Constraints / Notes | Example |
|
|
166
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
167
|
+
| `req` | body | yes | string | Endpoint selector | Fixed value | `appcgi.downloadcenter.task.search` |
|
|
168
|
+
| `reqid` | body | yes | string | Request correlation ID | Generated per request | `69ba...` |
|
|
169
|
+
| `keyword` | body | yes | string | 搜索关键字 | 按任务名或文件名匹配 | `ubuntu` |
|
|
170
|
+
| `uid` | body | no | number | 用户 ID | 可选 | `1000` |
|
|
171
|
+
|
|
172
|
+
### appcgi.downloadcenter.task.getInfo
|
|
173
|
+
|
|
174
|
+
#### Endpoint
|
|
175
|
+
`appcgi.downloadcenter.task.getInfo`
|
|
176
|
+
|
|
177
|
+
#### Purpose
|
|
178
|
+
获取单个下载任务的详细信息。
|
|
179
|
+
|
|
180
|
+
#### Trim CLI Mapping
|
|
181
|
+
```
|
|
182
|
+
fnos-cli download info <id>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### Request
|
|
186
|
+
| Field | Location | Required | Type | Meaning | Constraints / Notes | Example |
|
|
187
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
188
|
+
| `req` | body | yes | string | Endpoint selector | Fixed value | `appcgi.downloadcenter.task.getInfo` |
|
|
189
|
+
| `reqid` | body | yes | string | Request correlation ID | Generated per request | `69ba...` |
|
|
190
|
+
| `id` | body | yes | number | 任务 ID | 正整数 | `42` |
|
|
191
|
+
| `uid` | body | no | number | 用户 ID | 可选 | `1000` |
|
|
192
|
+
|
|
193
|
+
#### Response
|
|
194
|
+
主要响应字段(位于 `body` 中):
|
|
195
|
+
|
|
196
|
+
| Field | Always Present | Type | Meaning | Conditions / Notes | Example |
|
|
197
|
+
| --- | --- | --- | --- | --- | --- |
|
|
198
|
+
| `name` | no | string | 任务名称 | | `ubuntu-22.04.iso` |
|
|
199
|
+
| `total_size` | no | number | 总大小(bytes) | | `4194304` |
|
|
200
|
+
| `save_path` | no | string | 保存路径 | | `/vol1/downloads` |
|
|
201
|
+
| `dl_speed` | no | number | 下载速度 | | `1048576` |
|
|
202
|
+
| `up_speed` | no | number | 上传速度 | | `0` |
|
|
203
|
+
| `eta` | no | number | 预计剩余时间 | | `120` |
|
|
204
|
+
| `seeds` | no | number | 种子数 | | `5` |
|
|
205
|
+
| `peers` | no | number | 对等节点数 | | `12` |
|
|
206
|
+
| `share_ratio` | no | number | 分享比 | | `0.5` |
|
|
207
|
+
| `addition_date` | no | number | 添加时间 | | `1710000000` |
|
|
208
|
+
| `completion_date` | no | number | 完成时间 | | `1710100000` |
|
|
209
|
+
|
|
210
|
+
### appcgi.downloadcenter.task.getFiles
|
|
211
|
+
|
|
212
|
+
#### Endpoint
|
|
213
|
+
`appcgi.downloadcenter.task.getFiles`
|
|
214
|
+
|
|
215
|
+
#### Purpose
|
|
216
|
+
获取下载任务的文件列表,对 BT 类任务尤其有用。
|
|
217
|
+
|
|
218
|
+
#### Trim CLI Mapping
|
|
219
|
+
```
|
|
220
|
+
fnos-cli download files <id>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### Request
|
|
224
|
+
| Field | Location | Required | Type | Meaning | Constraints / Notes | Example |
|
|
225
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
226
|
+
| `req` | body | yes | string | Endpoint selector | Fixed value | `appcgi.downloadcenter.task.getFiles` |
|
|
227
|
+
| `reqid` | body | yes | string | Request correlation ID | Generated per request | `69ba...` |
|
|
228
|
+
| `id` | body | yes | number | 任务 ID | 正整数 | `42` |
|
|
229
|
+
| `mode` | body | no | number | 获取模式 | `1` 表示立即获取 | `1` |
|
|
230
|
+
| `uid` | body | no | number | 用户 ID | 可选 | `1000` |
|
|
231
|
+
|
|
232
|
+
#### Response
|
|
233
|
+
主要响应字段(位于 `body[]` 中):
|
|
234
|
+
|
|
235
|
+
| Field | Always Present | Type | Meaning | Conditions / Notes | Example |
|
|
236
|
+
| --- | --- | --- | --- | --- | --- |
|
|
237
|
+
| `index` | no | number | 文件序号 | | `0` |
|
|
238
|
+
| `name` | no | string | 文件名 | | `readme.txt` |
|
|
239
|
+
| `size` | no | number | 文件大小 | | `1024` |
|
|
240
|
+
| `progress` | no | number | 下载进度 | | `0.75` |
|
|
241
|
+
| `priority` | no | number | 优先级 | `0` 不下载,`1` 正常,`7` 最高 | `1` |
|
|
242
|
+
|
|
243
|
+
### appcgi.downloadcenter.task.addUris
|
|
244
|
+
|
|
245
|
+
#### Endpoint
|
|
246
|
+
`appcgi.downloadcenter.task.addUris`
|
|
247
|
+
|
|
248
|
+
#### Purpose
|
|
249
|
+
从 URL 或磁力链接创建下载任务。
|
|
250
|
+
|
|
251
|
+
#### Trim CLI Mapping
|
|
252
|
+
```
|
|
253
|
+
fnos-cli download add-uri <uri> <saveDir> --yes
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### Request
|
|
257
|
+
| Field | Location | Required | Type | Meaning | Constraints / Notes | Example |
|
|
258
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
259
|
+
| `req` | body | yes | string | Endpoint selector | Fixed value | `appcgi.downloadcenter.task.addUris` |
|
|
260
|
+
| `reqid` | body | yes | string | Request correlation ID | Generated per request | `69ba...` |
|
|
261
|
+
| `uris` | body | yes | string[] | URI 列表 | 支持 http/https/ftp/sftp/magnet | `["magnet:?xt=..."]` |
|
|
262
|
+
| `save_dir` | body | yes | string | 保存目录 | 必须为 `/vol{v}/...` 格式 | `/vol1/downloads` |
|
|
263
|
+
| `select_files` | body | no | array | 选择文件 | BT 类输入时有意义 | `[0,1,2]` |
|
|
264
|
+
| `uris_type` | body | no | number | URI 类型 | `0` 默认,`1` qBittorrent | `0` |
|
|
265
|
+
|
|
266
|
+
#### Response
|
|
267
|
+
| Field | Always Present | Type | Meaning | Conditions / Notes | Example |
|
|
268
|
+
| --- | --- | --- | --- | --- | --- |
|
|
269
|
+
| `ids` | no | number[] | 创建的任务 ID | | `[42]` |
|
|
270
|
+
| `errs` | no | array | 逐项错误 | 请求成功但部分项失败时出现 | `[{"uri":"...","err":"..."}]` |
|
|
271
|
+
|
|
272
|
+
### appcgi.downloadcenter.task.addPaths
|
|
273
|
+
|
|
274
|
+
#### Endpoint
|
|
275
|
+
`appcgi.downloadcenter.task.addPaths`
|
|
276
|
+
|
|
277
|
+
#### Purpose
|
|
278
|
+
从 NAS 上已有的种子文件创建下载任务。
|
|
279
|
+
|
|
280
|
+
#### Trim CLI Mapping
|
|
281
|
+
```
|
|
282
|
+
fnos-cli download add-path <path> <saveDir> --yes
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
#### Request
|
|
286
|
+
| Field | Location | Required | Type | Meaning | Constraints / Notes | Example |
|
|
287
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
288
|
+
| `req` | body | yes | string | Endpoint selector | Fixed value | `appcgi.downloadcenter.task.addPaths` |
|
|
289
|
+
| `reqid` | body | yes | string | Request correlation ID | Generated per request | `69ba...` |
|
|
290
|
+
| `paths` | body | yes | string[] | 种子文件路径列表 | 必须为 `/vol{v}/...` 格式 | `["/vol1/torrents/demo.torrent"]` |
|
|
291
|
+
| `save_dir` | body | yes | string | 保存目录 | 必须为 `/vol{v}/...` 格式 | `/vol1/downloads` |
|
|
292
|
+
| `select_files` | body | no | array | 选择文件 | 可选 | `[0,1]` |
|
|
293
|
+
|
|
294
|
+
#### Response
|
|
295
|
+
| Field | Always Present | Type | Meaning | Conditions / Notes | Example |
|
|
296
|
+
| --- | --- | --- | --- | --- | --- |
|
|
297
|
+
| `ids` | no | number[] | 创建的任务 ID | | `[43]` |
|
|
298
|
+
| `errs` | no | array | 逐项错误 | 请求成功但部分项失败时出现 | `[...]` |
|
|
299
|
+
|
|
300
|
+
### 控制类端点
|
|
301
|
+
|
|
302
|
+
#### appcgi.downloadcenter.task.pause / resume / retry / delete
|
|
303
|
+
|
|
304
|
+
这四个端点共享相同的请求结构。
|
|
305
|
+
|
|
306
|
+
#### Trim CLI Mapping
|
|
307
|
+
```
|
|
308
|
+
fnos-cli download pause <id...> --yes
|
|
309
|
+
fnos-cli download resume <id...> --yes
|
|
310
|
+
fnos-cli download retry <id...> --yes
|
|
311
|
+
fnos-cli download rm <id...> --yes
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
#### Request
|
|
315
|
+
| Field | Location | Required | Type | Meaning | Constraints / Notes | Example |
|
|
316
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
317
|
+
| `req` | body | yes | string | Endpoint selector | 对应具体操作 | `appcgi.downloadcenter.task.pause` |
|
|
318
|
+
| `reqid` | body | yes | string | Request correlation ID | Generated per request | `69ba...` |
|
|
319
|
+
| `ids` | body | yes | number[] | 任务 ID 列表 | 支持批量操作 | `[42, 43]` |
|
|
320
|
+
| `uid` | body | no | number | 用户 ID | 可选 | `1000` |
|
|
321
|
+
| `delete_files` | body | no | boolean | 是否同时删除文件 | 仅 `delete` 端点可用;CLI 默认不删除文件 | `false` |
|
|
322
|
+
|
|
323
|
+
#### Response
|
|
324
|
+
成功时通常返回 `"ok"`。
|
|
325
|
+
|
|
326
|
+
### appcgi.downloadcenter.stat.all
|
|
327
|
+
|
|
328
|
+
#### Endpoint
|
|
329
|
+
`appcgi.downloadcenter.stat.all`
|
|
330
|
+
|
|
331
|
+
#### Purpose
|
|
332
|
+
获取下载中心的汇总统计信息。
|
|
333
|
+
|
|
334
|
+
#### Trim CLI Mapping
|
|
335
|
+
```
|
|
336
|
+
fnos-cli download stat
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
#### Request
|
|
340
|
+
| Field | Location | Required | Type | Meaning | Constraints / Notes | Example |
|
|
341
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
342
|
+
| `req` | body | yes | string | Endpoint selector | Fixed value | `appcgi.downloadcenter.stat.all` |
|
|
343
|
+
| `reqid` | body | yes | string | Request correlation ID | Generated per request | `69ba...` |
|
|
344
|
+
| `uid` | body | no | number | 用户 ID | 可选 | `1000` |
|
|
345
|
+
|
|
346
|
+
#### Response
|
|
347
|
+
| Field | Always Present | Type | Meaning | Conditions / Notes | Example |
|
|
348
|
+
| --- | --- | --- | --- | --- | --- |
|
|
349
|
+
| `dl_speed` | no | number | 总下载速度 | | `1048576` |
|
|
350
|
+
| `dl_total_size` | no | number | 总下载量 | | `10737418240` |
|
|
351
|
+
| `up_speed` | no | number | 总上传速度 | | `524288` |
|
|
352
|
+
| `up_total_size` | no | number | 总上传量 | | `5368709120` |
|
|
353
|
+
|
|
354
|
+
## 注意事项
|
|
355
|
+
- 文件上传(`task.addUploadFile`)需要上传内容和大块传输支持,不应当作普通 `download request --json` 调用。
|
|
356
|
+
- `task.addfnShareLink` 是下载中心的导入任务端点,不要与 `appcgi.sharesvr.share.link.*` 的共享链接管理端点混淆。
|
|
357
|
+
- 部分响应数据的具体字段结构可能因后端版本而异。
|