bukesiyi-cli 0.3.1 → 0.3.3
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/README.md +105 -107
- package/dist/main.js +157 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,41 +1,36 @@
|
|
|
1
1
|
# bukesiyi-cli
|
|
2
2
|
|
|
3
|
-
《不可思议》(<https://buke41.com
|
|
3
|
+
《不可思议》(<https://buke41.com>)开放 API 的命令行客户端,命令名为 `buke`。支持交互式终端、脚本、CI 流水线和 AI agent 调用。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 支持范围与接入条件
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- **这一版能下单、查进度、下载成片**,覆盖三条产线:渲染短片(`buke shorts …`)、商品视频(`buke videos …`)和短剧(`buke drama …`),另有产品建档(`buke products …`)和余额(`buke balance`)。登录三件套(`buke login`、`buke whoami`、`buke logout`)负责把一把 API 密钥登录并稳妥地保存在本机。
|
|
12
|
-
- **注册账号都能用。** 登录《不可思议》后自己创建密钥,不用另外申请;遇到问题可以联系客服(联系方式见文末「联系我们」)。
|
|
13
|
-
- **密钥在网页上创建,不在这个工具里。** 账号本人登录《不可思议》,在右上角头像菜单的「账号设置」里打开「API 密钥」,在那里创建、查看和吊销:<https://buke41.com/account/api-keys>。完整密钥只在创建成功的那一刻显示一次。
|
|
14
|
-
|
|
15
|
-
下面的输出例子都是用这一版实际跑出来的,对面是一个按接口约定应答的本机模拟服务;密钥、家目录、编号是演示用的占位。
|
|
7
|
+
- 支持 API 凭据管理、产品建档、余额查询,以及渲染短片、商品视频和短剧的创建、查询、确认与下载。
|
|
8
|
+
- 注册账号无需单独申请 API 访问资格。调用要求 API 服务启用、密钥有效,且账号在密钥所属团队具有制作权限。
|
|
9
|
+
- 密钥由账号本人在[API 密钥页面](https://buke41.com/account/api-keys)创建、查看和吊销。完整密钥仅在创建成功时显示一次。
|
|
10
|
+
- 示例使用演示凭据、路径和编号。执行时替换为当前环境配置;程序应解析 JSON 字段,不应逐字匹配中文输出。
|
|
16
11
|
|
|
17
12
|
## 安装
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
运行环境要求 Node.js 20 或更高版本。
|
|
20
15
|
|
|
21
16
|
```sh
|
|
22
17
|
npm install -g bukesiyi-cli
|
|
23
18
|
```
|
|
24
19
|
|
|
25
|
-
|
|
20
|
+
安装后验证版本:
|
|
26
21
|
|
|
27
22
|
```console
|
|
28
23
|
$ buke --version
|
|
29
|
-
bukesiyi-cli/0.3.
|
|
24
|
+
bukesiyi-cli/0.3.3
|
|
30
25
|
```
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
也可使用 `npx bukesiyi-cli <命令>` 临时运行,例如 `npx bukesiyi-cli whoami`。
|
|
33
28
|
|
|
34
29
|
## 三步上手
|
|
35
30
|
|
|
36
|
-
|
|
31
|
+
先在[API 密钥页面](https://buke41.com/account/api-keys)创建密钥,设置名称及有效期(30 天、90 天、180 天、365 天,或长期有效),并安全保存完整密钥。
|
|
37
32
|
|
|
38
|
-
|
|
33
|
+
1. 运行 `buke login`。核对服务地址后输入密钥;终端输入无回显。CLI 验证凭据成功后保存至本机。
|
|
39
34
|
|
|
40
35
|
```console
|
|
41
36
|
$ buke login
|
|
@@ -49,7 +44,7 @@ $ buke login
|
|
|
49
44
|
凭据保存在 /home/you/.config/buke/credentials.json(只有本人可读写)
|
|
50
45
|
```
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
2. 运行 `buke whoami`,核对账号、团队、权限及有效期。
|
|
53
48
|
|
|
54
49
|
```console
|
|
55
50
|
$ buke whoami
|
|
@@ -61,14 +56,14 @@ $ buke whoami
|
|
|
61
56
|
密钥来自:/home/you/.config/buke/credentials.json
|
|
62
57
|
```
|
|
63
58
|
|
|
64
|
-
|
|
59
|
+
3. 停止使用本机凭据时运行 `buke logout`。该命令删除本机凭据,不吊销服务端密钥。
|
|
65
60
|
|
|
66
61
|
```console
|
|
67
62
|
$ buke logout
|
|
68
63
|
已退出登录,本机保存的密钥已删除。这把密钥本身仍然在用,不再使用请吊销它
|
|
69
64
|
```
|
|
70
65
|
|
|
71
|
-
|
|
66
|
+
自动化环境应通过受控环境变量 `BUKE_API_KEY` 或标准输入提供密钥。管道示例:
|
|
72
67
|
|
|
73
68
|
```console
|
|
74
69
|
$ printf '%s' "$KEY" | buke login
|
|
@@ -80,7 +75,7 @@ $ printf '%s' "$KEY" | buke login
|
|
|
80
75
|
凭据保存在 /home/you/.config/buke/credentials.json(只有本人可读写)
|
|
81
76
|
```
|
|
82
77
|
|
|
83
|
-
|
|
78
|
+
禁止将完整密钥写入命令行参数。参数可能被 shell 历史或进程列表记录,CLI 会在执行命令前拒绝此类输入:
|
|
84
79
|
|
|
85
80
|
```console
|
|
86
81
|
$ buke login bk_test_0123456789abcdef_……
|
|
@@ -90,33 +85,45 @@ $ buke login bk_test_0123456789abcdef_……
|
|
|
90
85
|
|
|
91
86
|
## 命令速查
|
|
92
87
|
|
|
93
|
-
| 命令 |
|
|
88
|
+
| 命令 | 功能 |
|
|
94
89
|
| --- | --- |
|
|
95
|
-
| `buke login` |
|
|
96
|
-
| `buke whoami` |
|
|
97
|
-
| `buke logout` |
|
|
98
|
-
| `buke balance` |
|
|
99
|
-
| `buke products create / set-images / confirm-lock` |
|
|
100
|
-
| `buke shorts catalog / upload / quote / order / status / download / cancel` |
|
|
101
|
-
| `buke videos create / status / message / confirm / download` |
|
|
102
|
-
| `buke drama create / status / quote / confirm / cancel / download` |
|
|
103
|
-
| `buke --version` |
|
|
104
|
-
| `buke --help`、`buke <命令> --help` |
|
|
90
|
+
| `buke login` | 读取密钥、执行服务端鉴权并保存本机凭据。输入优先级为环境变量、非交互标准输入、交互式终端 |
|
|
91
|
+
| `buke whoami` | 查询密钥归属、团队、权限及有效期。优先使用 `BUKE_API_KEY`,否则读取本机凭据 |
|
|
92
|
+
| `buke logout` | 删除本机凭据,不发送网络请求,不吊销密钥 |
|
|
93
|
+
| `buke balance` | 查询可用、冻结及已使用额度 |
|
|
94
|
+
| `buke products create / set-images / confirm-lock` | 创建产品、上传商品图片、确认外观信息 |
|
|
95
|
+
| `buke shorts catalog / upload / quote / order / status / download / cancel` | 查询模板、上传素材、报价、创建订单、查询进度、下载和取消 |
|
|
96
|
+
| `buke videos create / status / message / confirm / download` | 创建商品视频任务、查询进度、发送消息、确认制作和下载 |
|
|
97
|
+
| `buke drama create / status / quote / confirm / cancel / download` | 创建短剧订单、查询进度、报价、确认制作、取消和下载 |
|
|
98
|
+
| `buke --version` | 输出版本号 |
|
|
99
|
+
| `buke --help`、`buke <命令> --help` | 输出命令及选项帮助 |
|
|
100
|
+
|
|
101
|
+
写操作支持 `--idempotency-key <键>`。未指定时,CLI 自动生成并在结果中返回。重试同一操作必须保留原键和请求内容;新键表示新尝试,可能产生新订单及费用。渲染短片的报价哈希与幂等键绑定,`shorts quote` 和 `shorts order` 必须使用相同键。
|
|
102
|
+
|
|
103
|
+
`shorts order --wait`、`shorts status --wait` 和 `videos status --wait` 轮询原任务。成功退出 0,终态失败或取消退出 9,等待超过 `--timeout`(默认 600 秒)退出 8。商品视频进入等待回复或确认的状态时退出 0,等待调用方处理。
|
|
104
|
+
|
|
105
|
+
`drama confirm` 先获取当前报价;未指定 `--yes` 时仅展示报价,退出 2。指定 `--yes` 后才提交费用授权,并校验服务端报价哈希。`drama status --wait` 在终态或需要人工处理的状态停止:交付成功退出 0,失败或取消退出 9,`needs_attention` 和 `partial` 退出 0 并返回处理信息。
|
|
106
|
+
|
|
107
|
+
等待失败、超时或轮询中断后,应查询原任务。JSON 错误文档中的 `recovery` 保留任务编号、最后状态和查询命令;`shorts order` 同时保留幂等键。自定义服务的查询命令保留 `--base-url`。
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
`drama confirm` 失败时同样保留目标订单、最后一次成功查询的状态和已知幂等键,并返回 `operation: "confirm"`。`operationOutcome` 区分 `not_submitted`(确认请求尚未发送)、`rejected`(服务端明确拒绝)和 `unknown`(受理结果未知)。`acceptance` 仅表示原订单是否已确认存在,不表示本次费用确认成功。CLI 不自动重发确认请求;结果未知时应先查询原订单并保留原键。
|
|
107
110
|
|
|
108
|
-
|
|
111
|
+
提交结果不明时,`recovery.acceptance` 为 `unknown`,不返回虚构的任务编号。保存原幂等键,在 Studio 核对原请求;不得换键重新下单。CLI 不自动重试。
|
|
109
112
|
|
|
110
|
-
|
|
113
|
+
`drama create` 支持 `--model` 和 `--resolution`。未显式指定模型时,报价前可适配人物参考;显式指定不兼容模型时进入需要处理的状态,不自动替换。`drama quote` 展示实际制作规格、费用及适配说明。
|
|
111
114
|
|
|
112
|
-
|
|
115
|
+
短剧普通状态 JSON 可包含 `order.productionCompatibility` 和 `order.failures`。等待终态失败时,失败数组位于 JSON 顶层 `failures`,与 `error`、`recovery` 并列。素材定位不可确认时返回 `reference: null`,不推测具体图片;旧记录不会自动补齐证据。修正素材或在 Studio 明确修改规格后,须重新报价和确认,CLI 不自动切换模型或付费重试。
|
|
116
|
+
|
|
117
|
+
## 输出与通用选项
|
|
118
|
+
|
|
119
|
+
完整成片下载只接受 HTTP 200、非空正文及合法视频类型;短剧和渲染短片为 MP4,商品视频同时兼容服务端返回的 QuickTime。HTTP 202 表示文件尚未就绪,命令退出 7,不保存响应或覆盖已有文件。应查询原任务后再次下载,不重新生成。
|
|
113
120
|
|
|
114
121
|
| 选项 | 作用 |
|
|
115
122
|
| --- | --- |
|
|
116
|
-
| `--json` |
|
|
117
|
-
| `--base-url <地址>` |
|
|
123
|
+
| `--json` | 标准输出仅包含一个 JSON 文档:成功时为结果,失败时为结构化错误。适用于脚本和 AI agent |
|
|
124
|
+
| `--base-url <地址>` | 指定服务源地址,默认 `https://buke41.com`。地址须使用 HTTPS 且不包含路径;本机调试允许 `http://localhost`、`http://127.0.0.1`、`http://[::1]`。`logout` 不接受此选项 |
|
|
118
125
|
|
|
119
|
-
|
|
126
|
+
成功 JSON 示例:
|
|
120
127
|
|
|
121
128
|
```console
|
|
122
129
|
$ buke whoami --json
|
|
@@ -143,6 +150,8 @@ $ buke whoami --json
|
|
|
143
150
|
}
|
|
144
151
|
```
|
|
145
152
|
|
|
153
|
+
错误 JSON 示例:
|
|
154
|
+
|
|
146
155
|
```console
|
|
147
156
|
$ buke whoami --json
|
|
148
157
|
{
|
|
@@ -159,13 +168,13 @@ $ buke whoami --json
|
|
|
159
168
|
|
|
160
169
|
| 变量 | 作用 |
|
|
161
170
|
| --- | --- |
|
|
162
|
-
| `BUKE_API_KEY` | API
|
|
163
|
-
| `BUKE_BASE_URL` |
|
|
164
|
-
| `BUKE_CONFIG_DIR` |
|
|
171
|
+
| `BUKE_API_KEY` | 优先使用的 API 密钥;设置后不读取本机凭据文件。`login` 验证后将其保存至本机 |
|
|
172
|
+
| `BUKE_BASE_URL` | 服务源地址。`--base-url` 优先于该变量;未配置时使用 `https://buke41.com` |
|
|
173
|
+
| `BUKE_CONFIG_DIR` | 凭据目录,须为绝对路径,支持展开开头的 `~`。默认依次采用 `$XDG_CONFIG_HOME/buke`、`~/.config/buke`;Windows 使用 `%APPDATA%\buke` |
|
|
165
174
|
|
|
166
|
-
|
|
175
|
+
凭据保存在 `credentials.json` 中。macOS 和 Linux 上文件权限仅允许当前用户读写。文件包含明文密钥,不得提交至代码仓库、写入镜像或直接共享。
|
|
167
176
|
|
|
168
|
-
|
|
177
|
+
启用 Node.js 环境代理时,CLI 会拒绝可能经代理传输密钥的本机 HTTP 请求。本机调试可通过 `NO_PROXY` 排除回环地址:
|
|
169
178
|
|
|
170
179
|
```sh
|
|
171
180
|
export NO_PROXY='localhost,127.0.0.1,[::1]'
|
|
@@ -173,86 +182,75 @@ export NO_PROXY='localhost,127.0.0.1,[::1]'
|
|
|
173
182
|
|
|
174
183
|
## 退出码
|
|
175
184
|
|
|
176
|
-
| 退出码 | 含义 |
|
|
185
|
+
| 退出码 | 含义 | 当前支持 |
|
|
177
186
|
| --- | --- | --- |
|
|
178
|
-
| 0 | 成功 |
|
|
179
|
-
| 2 |
|
|
180
|
-
| 3 |
|
|
181
|
-
| 4 | 余额不足 |
|
|
182
|
-
| 5 |
|
|
183
|
-
| 6 |
|
|
184
|
-
| 7 |
|
|
185
|
-
| 8 | 等待超时 |
|
|
186
|
-
| 9 | 任务失败 |
|
|
187
|
-
| 10 |
|
|
188
|
-
| 130 |
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
脚本里先看退出码,再看 `--json` 输出里的 `error.code` 和 `error.retryable`;遇到 7,按 `error.retryAfterSeconds` 给的秒数等够了再试。要让脚本调得到 `buke`,它得在 PATH 上:全局安装之后就在。
|
|
187
|
+
| 0 | 成功 | 是 |
|
|
188
|
+
| 2 | 参数或用法错误 | 是 |
|
|
189
|
+
| 3 | 未登录、鉴权失败或账号不可用 | 是 |
|
|
190
|
+
| 4 | 余额不足 | 是 |
|
|
191
|
+
| 5 | 服务端、网络或本机错误 | 是 |
|
|
192
|
+
| 6 | 报价或幂等冲突 | 是 |
|
|
193
|
+
| 7 | 请求受限或操作尚未就绪 | 是 |
|
|
194
|
+
| 8 | 等待超时 | 是 |
|
|
195
|
+
| 9 | 任务失败 | 是 |
|
|
196
|
+
| 10 | 接口或资源不可访问 | 是 |
|
|
197
|
+
| 130 | 收到中断信号 | 是 |
|
|
198
|
+
|
|
199
|
+
信号中断采用 `128 + 信号编号`:SIGINT 为 130,SIGTERM 为 143,SIGHUP 为 129。脚本应结合退出码及 `error.code` 分支处理;需要等待时遵循 `error.retryAfterSeconds`。
|
|
193
200
|
|
|
194
201
|
## 错误码
|
|
195
202
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
- `OPEN_API_` 开头的是服务端回的:请求送到了,服务端没有接受。报错的第一行是服务端的原话,写明了原因和该怎么办;这类报错带一个请求编号(`--json` 里是 `error.traceId`),联系客服时把它一起给出。退出码按上面那张表:密钥或账号现在不能用是 3,余额不足是 4,报价变了是 6,请求太频繁或这一步还没到时候是 7,这个地址上没有接口或要找的东西不存在是 10,服务端出错是 5。
|
|
199
|
-
- `CLI_` 开头的是这个工具自己发现的问题:命令的写法、密钥的给法、服务地址、本机的凭据文件、网络。这一版一共有下面这些:
|
|
203
|
+
`OPEN_API_` 前缀表示服务端返回的错误;`CLI_` 前缀表示本机参数、配置、网络或输出处理错误。`--json` 模式使用 `error.code` 标识错误,服务端错误同时提供 `error.traceId`。
|
|
200
204
|
|
|
201
|
-
| 错误码 | 退出码 |
|
|
205
|
+
| 错误码 | 退出码 | 处理方式 |
|
|
202
206
|
| --- | --- | --- |
|
|
203
|
-
| `CLI_USAGE` | 2 |
|
|
204
|
-
| `CLI_KEY_IN_ARGV` | 2 |
|
|
205
|
-
| `CLI_KEY_MISSING` | 2 |
|
|
206
|
-
| `CLI_KEY_MALFORMED` | 2 |
|
|
207
|
-
| `CLI_BASE_URL_INVALID` | 2 |
|
|
208
|
-
| `CLI_BASE_URL_INSECURE` | 2 |
|
|
209
|
-
| `CLI_BASE_URL_MISMATCH` | 2 |
|
|
210
|
-
| `CLI_NOT_LOGGED_IN` | 3 |
|
|
211
|
-
| `CLI_CONFIG_DIR_INVALID` | 2 |
|
|
212
|
-
| `CLI_CREDENTIALS_UNREADABLE` | 5 |
|
|
213
|
-
| `CLI_CREDENTIALS_WRITE_FAILED` | 5 |
|
|
214
|
-
| `CLI_NETWORK` | 5 |
|
|
215
|
-
| `CLI_TIMEOUT` | 5 |
|
|
216
|
-
| `CLI_REDIRECT` | 5 |
|
|
217
|
-
| `CLI_BAD_RESPONSE` | 5 |
|
|
218
|
-
| `
|
|
219
|
-
| `
|
|
220
|
-
| `
|
|
221
|
-
| `
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
-
|
|
227
|
-
|
|
228
|
-
|
|
207
|
+
| `CLI_USAGE` | 2 | 参数不符合命令要求。运行 `buke --help` 或子命令帮助核对用法 |
|
|
208
|
+
| `CLI_KEY_IN_ARGV` | 2 | 命令行参数包含密钥,命令未执行。改用环境变量、标准输入或交互式输入;真实密钥应按泄露处理 |
|
|
209
|
+
| `CLI_KEY_MISSING` | 2 | 未提供密钥,或标准输入未在 30 秒内结束。检查输入来源 |
|
|
210
|
+
| `CLI_KEY_MALFORMED` | 2 | 密钥格式无效。检查前缀、截断及空白字符 |
|
|
211
|
+
| `CLI_BASE_URL_INVALID` | 2 | 服务地址无效,或包含路径、参数、用户信息。使用 HTTPS 源地址 |
|
|
212
|
+
| `CLI_BASE_URL_INSECURE` | 2 | 非回环地址使用 HTTP,或本机 HTTP 请求会经代理发送。改用 HTTPS 或正确配置 `NO_PROXY` |
|
|
213
|
+
| `CLI_BASE_URL_MISMATCH` | 2 | 目标服务与本机凭据绑定地址不符,请求未发送。使用原地址或为新地址重新登录 |
|
|
214
|
+
| `CLI_NOT_LOGGED_IN` | 3 | 环境变量和本机均无可用凭据。运行 `buke login` 或设置 `BUKE_API_KEY` |
|
|
215
|
+
| `CLI_CONFIG_DIR_INVALID` | 2 | 凭据路径无效。将 `BUKE_CONFIG_DIR` 设为绝对路径或以 `~/` 开头的路径 |
|
|
216
|
+
| `CLI_CREDENTIALS_UNREADABLE` | 5 | 凭据文件损坏、类型不符或权限不足。修正权限,或删除本机凭据后重新登录 |
|
|
217
|
+
| `CLI_CREDENTIALS_WRITE_FAILED` | 5 | 无法保存或删除凭据。修正目录权限,或通过 `BUKE_CONFIG_DIR` 指定可写目录 |
|
|
218
|
+
| `CLI_NETWORK` | 5 | 网络连接失败。检查地址、网络、代理和证书;确认配置正确后有限重试 |
|
|
219
|
+
| `CLI_TIMEOUT` | 5 | 请求超过时限;JSON 请求默认 15 秒、成片下载默认 120 秒。检查网络或代理;涉及提交时先核对原请求结果 |
|
|
220
|
+
| `CLI_REDIRECT` | 5 | 目标服务返回重定向,CLI 未跟随。核对服务源地址后重新登录 |
|
|
221
|
+
| `CLI_BAD_RESPONSE` | 5 | 响应不符合 API 结构。检查服务地址、代理或网关;仅对可重试状态采用有限退避 |
|
|
222
|
+
| `CLI_DOWNLOAD_NOT_READY` | 7 | 下载接口返回 HTTP 202,文件尚未就绪。查询原任务后再次下载;CLI 不保存响应为成片、不自动重试,也不重新生成 |
|
|
223
|
+
| `CLI_WAIT_TIMEOUT` | 8 | 等待达到时限,任务并未因此失败。按 `recovery.statusCommand` 查询原任务,不重新下单 |
|
|
224
|
+
| `CLI_TASK_FAILED` | 9 | 原任务进入失败或取消终态。查询原任务,核对原因、已完成内容及计费;新制作需要重新报价和授权 |
|
|
225
|
+
| `CLI_INTERRUPTED` | 130 | 进程收到中断信号。SIGTERM 和 SIGHUP 分别退出 143、129;提交被中断时先核对原任务 |
|
|
226
|
+
| `CLI_INTERNAL` | 5 | 未预期的本机错误。提交脱敏错误信息、命令及版本号以供排查 |
|
|
227
|
+
|
|
228
|
+
网络配置:
|
|
229
|
+
|
|
230
|
+
- 自签名证书使用 `NODE_EXTRA_CA_CERTS` 指定受信任根证书,不得关闭证书校验。
|
|
231
|
+
- CLI 默认不主动启用代理。Node.js 支持环境代理时,可通过 `NODE_USE_ENV_PROXY=1` 启用,并配置 `HTTP_PROXY`、`HTTPS_PROXY` 和 `NO_PROXY`。Node.js 24.18 支持该方式,20.19 和 22.19 不支持;应结合实际 Node.js 版本验证代理行为。
|
|
232
|
+
|
|
233
|
+
HTTP 404 应结合 `error.code` 排查。`OPEN_API_NOT_FOUND` 可能来自服务未启用、路径或方法不匹配。产品、模板、订单错误则需核对资源编号及所属账号或团队。API 的结构化 404 退出 10;无法解析为 API 响应的 404 退出 5。不能仅凭 404 判断服务已停用。
|
|
229
234
|
|
|
230
235
|
## 安全须知
|
|
231
236
|
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
- `buke logout`
|
|
235
|
-
-
|
|
236
|
-
-
|
|
237
|
-
- 每台机器、每条流水线、每个 agent 各用一把密钥,能设有效期就设。
|
|
237
|
+
- API 密钥授权以所属账号和团队身份执行操作,应仅存储于受控环境。
|
|
238
|
+
- 密钥暴露于命令行参数、URL、日志、截图或对话后,应立即吊销并替换。
|
|
239
|
+
- `buke logout` 仅删除本机文件;服务端吊销须通过[API 密钥页面](https://buke41.com/account/api-keys)执行。修改登录密码不会自动吊销 API 密钥。
|
|
240
|
+
- 日志和支持请求仅使用公开密钥标识、请求编号和错误码;不得包含完整凭据。
|
|
241
|
+
- 不同机器、流水线和 agent 应使用独立密钥,并设置符合用途的有效期。
|
|
238
242
|
|
|
239
243
|
## 从仓库源码运行
|
|
240
244
|
|
|
241
|
-
|
|
245
|
+
CLI 开发者可参考仓库 `docs/open-api/cli.md` 第 2.2 节进行构建、源码运行和本机链接。普通接入使用 npm 发布包。
|
|
242
246
|
|
|
243
247
|
## 许可
|
|
244
248
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
许可只管这个命令行工具的代码本身;用它调用《不可思议》的服务,仍然按注册账号时同意的用户协议。
|
|
248
|
-
|
|
249
|
-
「不可思议」的名称与标识不在许可范围内。
|
|
249
|
+
CLI 代码按 MIT 许可发布,许可全文见包内 `LICENSE`。服务调用仍受账号用户协议约束;《不可思议》的名称和标识不在 MIT 许可范围内。
|
|
250
250
|
|
|
251
251
|
## 联系我们
|
|
252
252
|
|
|
253
253
|
- 网站:<https://buke41.com>
|
|
254
|
-
- 客服邮箱:<winrock.inc@outlook.com
|
|
255
|
-
|
|
256
|
-
报问题时请带上:运行的命令、完整的报错(连同错误码;有请求编号的话一起给)、`buke --version` 的输出、大概的时间。**不要把完整密钥发过来**——要指明是哪一把,给编号前缀(形如 `bk_test_0123456789abcdef`)就够了。
|
|
254
|
+
- 客服邮箱:<winrock.inc@outlook.com>
|
|
257
255
|
|
|
258
|
-
|
|
256
|
+
提交问题时提供命令、CLI 和 Node.js 版本、请求时间,以及脱敏后的错误码、错误说明和请求编号。不得发送完整密钥、凭据文件或含客户素材的完整响应。
|
package/dist/main.js
CHANGED
|
@@ -90,6 +90,7 @@ var CliError = class _CliError extends Error {
|
|
|
90
90
|
httpStatus;
|
|
91
91
|
hints;
|
|
92
92
|
recovery;
|
|
93
|
+
failures;
|
|
93
94
|
constructor(init) {
|
|
94
95
|
super(redactKeys(init.message));
|
|
95
96
|
this.name = "CliError";
|
|
@@ -101,6 +102,7 @@ var CliError = class _CliError extends Error {
|
|
|
101
102
|
if (init.httpStatus !== void 0) this.httpStatus = init.httpStatus;
|
|
102
103
|
this.hints = init.hints ?? [];
|
|
103
104
|
if (init.recovery !== void 0) this.recovery = init.recovery;
|
|
105
|
+
if (init.failures !== void 0) this.failures = init.failures;
|
|
104
106
|
}
|
|
105
107
|
withHint(hint) {
|
|
106
108
|
return new _CliError({
|
|
@@ -112,7 +114,8 @@ var CliError = class _CliError extends Error {
|
|
|
112
114
|
retryAfterSeconds: this.retryAfterSeconds,
|
|
113
115
|
httpStatus: this.httpStatus,
|
|
114
116
|
hints: [...this.hints, hint],
|
|
115
|
-
recovery: this.recovery
|
|
117
|
+
recovery: this.recovery,
|
|
118
|
+
failures: this.failures
|
|
116
119
|
});
|
|
117
120
|
}
|
|
118
121
|
withRecovery(recovery) {
|
|
@@ -125,7 +128,8 @@ var CliError = class _CliError extends Error {
|
|
|
125
128
|
retryAfterSeconds: this.retryAfterSeconds,
|
|
126
129
|
httpStatus: this.httpStatus,
|
|
127
130
|
hints: this.hints,
|
|
128
|
-
recovery
|
|
131
|
+
recovery,
|
|
132
|
+
failures: this.failures
|
|
129
133
|
});
|
|
130
134
|
}
|
|
131
135
|
};
|
|
@@ -412,7 +416,7 @@ async function readNewKey(io) {
|
|
|
412
416
|
|
|
413
417
|
// package.json
|
|
414
418
|
var name = "bukesiyi-cli";
|
|
415
|
-
var version = "0.3.
|
|
419
|
+
var version = "0.3.3";
|
|
416
420
|
|
|
417
421
|
// src/version.ts
|
|
418
422
|
var PACKAGE_NAME = name;
|
|
@@ -428,13 +432,37 @@ function taskRecovery(taskType, taskId, status4, baseUrl, failureCode) {
|
|
|
428
432
|
taskType,
|
|
429
433
|
acceptance: "confirmed",
|
|
430
434
|
taskId,
|
|
431
|
-
status: status4,
|
|
435
|
+
...status4 === void 0 ? {} : { status: status4 },
|
|
432
436
|
...customOrigin ? { baseUrl } : {},
|
|
433
437
|
...failureCode === void 0 || failureCode === "" ? {} : { failureCode },
|
|
434
438
|
nextAction: "query",
|
|
435
439
|
statusCommand: `buke ${taskType} status ${shellArgument(taskId)}` + (customOrigin ? ` --base-url ${shellArgument(baseUrl)}` : "")
|
|
436
440
|
};
|
|
437
441
|
}
|
|
442
|
+
function dramaConfirmationRecovery(orderId, status4, baseUrl, idempotencyKey, operationOutcome) {
|
|
443
|
+
return {
|
|
444
|
+
...taskRecovery("drama", orderId, status4, baseUrl),
|
|
445
|
+
acceptance: status4 === void 0 ? "unknown" : "confirmed",
|
|
446
|
+
operation: "confirm",
|
|
447
|
+
operationOutcome,
|
|
448
|
+
...idempotencyKey === void 0 ? {} : { idempotencyKey }
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
async function retainDramaConfirmationOnError(orderId, status4, baseUrl, idempotencyKey, operation) {
|
|
452
|
+
try {
|
|
453
|
+
return await operation();
|
|
454
|
+
} catch (error) {
|
|
455
|
+
const failure = toCliError(error);
|
|
456
|
+
const rejected = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408;
|
|
457
|
+
throw failure.withRecovery(dramaConfirmationRecovery(
|
|
458
|
+
orderId,
|
|
459
|
+
status4,
|
|
460
|
+
baseUrl,
|
|
461
|
+
idempotencyKey,
|
|
462
|
+
rejected ? "rejected" : "unknown"
|
|
463
|
+
));
|
|
464
|
+
}
|
|
465
|
+
}
|
|
438
466
|
async function retainTaskOnError(recovery, operation) {
|
|
439
467
|
try {
|
|
440
468
|
return await operation();
|
|
@@ -464,6 +492,36 @@ async function retainSubmissionOnError(taskType, idempotencyKey, baseUrl, operat
|
|
|
464
492
|
}
|
|
465
493
|
}
|
|
466
494
|
|
|
495
|
+
// src/drama-failure.ts
|
|
496
|
+
function parseDramaShotFailure(value) {
|
|
497
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
498
|
+
const row = value;
|
|
499
|
+
if (typeof row.shotId !== "string" || !row.shotId || typeof row.message !== "string" || typeof row.suggestion !== "string" || row.reason !== "reference_privacy" && row.reason !== "content_safety") return null;
|
|
500
|
+
let reference = null;
|
|
501
|
+
if (row.reference && typeof row.reference === "object" && !Array.isArray(row.reference)) {
|
|
502
|
+
const ref = row.reference;
|
|
503
|
+
if (typeof ref.contentIndex !== "number" || !Number.isInteger(ref.contentIndex) || ref.contentIndex < 0 || ref.mediaType !== "image" && ref.mediaType !== "video" && ref.mediaType !== "audio" || typeof ref.roleLabel !== "string") return null;
|
|
504
|
+
reference = {
|
|
505
|
+
contentIndex: ref.contentIndex,
|
|
506
|
+
imageNumber: typeof ref.imageNumber === "number" && Number.isInteger(ref.imageNumber) && ref.imageNumber > 0 ? ref.imageNumber : null,
|
|
507
|
+
mediaType: ref.mediaType,
|
|
508
|
+
role: typeof ref.role === "string" ? ref.role : null,
|
|
509
|
+
roleLabel: ref.roleLabel,
|
|
510
|
+
assetIds: Array.isArray(ref.assetIds) ? ref.assetIds.filter((id) => typeof id === "string").slice(0, 12) : [],
|
|
511
|
+
label: typeof ref.label === "string" ? ref.label : null,
|
|
512
|
+
assetSlot: typeof ref.assetSlot === "string" && ["front_closeup.png", "full_body.png", "model_sheet.png"].includes(ref.assetSlot) ? ref.assetSlot : null
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
return {
|
|
516
|
+
shotId: row.shotId,
|
|
517
|
+
shotNumber: typeof row.shotNumber === "number" && Number.isInteger(row.shotNumber) && row.shotNumber > 0 ? row.shotNumber : null,
|
|
518
|
+
reason: row.reason,
|
|
519
|
+
message: row.message,
|
|
520
|
+
suggestion: row.suggestion,
|
|
521
|
+
reference
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
|
|
467
525
|
// src/client.ts
|
|
468
526
|
var DEFAULT_REQUEST_TIMEOUT_MS = 15e3;
|
|
469
527
|
var DEFAULT_DOWNLOAD_TIMEOUT_MS = 12e4;
|
|
@@ -610,6 +668,10 @@ async function exchange(url, apiKey, plan, deps, origin) {
|
|
|
610
668
|
return { status: response.status, redirectedTo: redirectTarget(response, url) };
|
|
611
669
|
}
|
|
612
670
|
if (asBytes) {
|
|
671
|
+
if (response.status >= 200 && response.status < 300 && response.status !== 200) {
|
|
672
|
+
discardBody(response);
|
|
673
|
+
return { status: response.status, bytes: Buffer.alloc(0), headers: response.headers };
|
|
674
|
+
}
|
|
613
675
|
const bytes = await readBodyBytes(response, controller.signal, MAX_DOWNLOAD_BYTES);
|
|
614
676
|
if (bytes === null) throw unreadableResponse(response.status);
|
|
615
677
|
return { status: response.status, bytes, headers: response.headers };
|
|
@@ -715,11 +777,25 @@ async function downloadFile(baseUrl, apiKey, path, deps) {
|
|
|
715
777
|
assertReachedDirectly(origin, deps.env);
|
|
716
778
|
const result = await exchange(`${origin}${path}`, apiKey, downloadPlan(path, deps), deps, origin);
|
|
717
779
|
if ("redirectedTo" in result) throw redirectError(result.redirectedTo);
|
|
780
|
+
if (result.status === 202) {
|
|
781
|
+
throw new CliError({
|
|
782
|
+
code: "CLI_DOWNLOAD_NOT_READY",
|
|
783
|
+
exitCode: EXIT.RETRY_LATER,
|
|
784
|
+
retryable: true,
|
|
785
|
+
httpStatus: 202,
|
|
786
|
+
message: "\u6210\u7247\u4E0B\u8F7D\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u6267\u884C\u4E0B\u8F7D\u547D\u4EE4\u3002\u672C\u6B21\u672A\u4FDD\u5B58\u6587\u4EF6\u3002"
|
|
787
|
+
});
|
|
788
|
+
}
|
|
718
789
|
if (result.status < 200 || result.status >= 300) {
|
|
719
790
|
const text = result.bytes.toString("utf8");
|
|
720
791
|
const parsed = parseJson(text);
|
|
721
792
|
throw (parsed && serverError(result.status, parsed.value, apiKey)) ?? unreadableResponse(result.status);
|
|
722
793
|
}
|
|
794
|
+
const mime = result.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
|
|
795
|
+
const quickTimeVideo = mime === "video/quicktime" && /^\/api\/open\/v1\/videos\/[^/?#]+\/download(?:\?[^#]*)?$/u.test(path);
|
|
796
|
+
if (result.status !== 200 || result.bytes.length === 0 || mime !== "video/mp4" && !quickTimeVideo) {
|
|
797
|
+
throw unreadableResponse(result.status);
|
|
798
|
+
}
|
|
723
799
|
return { bytes: result.bytes, filename: filenameFromDisposition(result.headers.get("content-disposition")) };
|
|
724
800
|
}
|
|
725
801
|
function downloadPlan(path, deps) {
|
|
@@ -943,6 +1019,8 @@ function parseDramaOrder(body) {
|
|
|
943
1019
|
return parsed2;
|
|
944
1020
|
});
|
|
945
1021
|
if (gaps !== void 0 && gaps.some((gap) => gap === null)) problems.push("gap");
|
|
1022
|
+
const failures = Array.isArray(order2.failures) ? order2.failures.slice(0, 100).map(parseDramaShotFailure).filter((failure) => failure !== null) : void 0;
|
|
1023
|
+
const productionCompatibility = parseDramaCompatibility(order2.productionCompatibility);
|
|
946
1024
|
const parsed = {
|
|
947
1025
|
id: text(order2.id),
|
|
948
1026
|
projectId: text(order2.projectId),
|
|
@@ -956,6 +1034,8 @@ function parseDramaOrder(body) {
|
|
|
956
1034
|
nextActions: actions,
|
|
957
1035
|
...typeof order2.reason === "string" ? { reason: order2.reason } : {},
|
|
958
1036
|
...gaps === void 0 ? {} : { gaps },
|
|
1037
|
+
...failures === void 0 ? {} : { failures },
|
|
1038
|
+
...productionCompatibility === void 0 ? {} : { productionCompatibility },
|
|
959
1039
|
createdAt: text(order2.createdAt),
|
|
960
1040
|
updatedAt: text(order2.updatedAt)
|
|
961
1041
|
};
|
|
@@ -973,6 +1053,7 @@ function parseDramaQuote(body) {
|
|
|
973
1053
|
const shotCreditCost = quote3 === null ? void 0 : numberOrUndefined(quote3.shotCreditCost);
|
|
974
1054
|
const videoModel = quote3 !== null && typeof quote3.videoModel === "string" ? quote3.videoModel : void 0;
|
|
975
1055
|
const resolution = quote3 !== null && typeof quote3.resolution === "string" ? quote3.resolution : void 0;
|
|
1056
|
+
const productionCompatibility = parseDramaCompatibility(body.productionCompatibility);
|
|
976
1057
|
const parsed = {
|
|
977
1058
|
quoteHash: text(body.quoteHash),
|
|
978
1059
|
sufficient: typeof body.sufficient === "boolean" ? body.sufficient : null,
|
|
@@ -980,10 +1061,21 @@ function parseDramaQuote(body) {
|
|
|
980
1061
|
shotCount: shotCount ?? -1,
|
|
981
1062
|
...shotCreditCost !== void 0 ? { shotCreditCost } : {},
|
|
982
1063
|
...videoModel !== void 0 ? { videoModel } : {},
|
|
983
|
-
...resolution !== void 0 ? { resolution } : {}
|
|
1064
|
+
...resolution !== void 0 ? { resolution } : {},
|
|
1065
|
+
...productionCompatibility === void 0 ? {} : { productionCompatibility }
|
|
984
1066
|
};
|
|
985
1067
|
return problems.length > 0 ? null : parsed;
|
|
986
1068
|
}
|
|
1069
|
+
function parseDramaCompatibility(value) {
|
|
1070
|
+
if (!isRecord2(value) || !isRecord2(value.requested) || !["compatible", "adjusted", "unavailable"].includes(String(value.status)) || typeof value.requested.videoModel !== "string" || typeof value.requested.resolution !== "string") return void 0;
|
|
1071
|
+
const effective = isRecord2(value.effective) && typeof value.effective.videoModel === "string" && typeof value.effective.resolution === "string" ? { videoModel: value.effective.videoModel, resolution: value.effective.resolution } : null;
|
|
1072
|
+
return {
|
|
1073
|
+
status: value.status,
|
|
1074
|
+
requested: { videoModel: value.requested.videoModel, resolution: value.requested.resolution },
|
|
1075
|
+
effective,
|
|
1076
|
+
notice: typeof value.notice === "string" ? value.notice : null
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
987
1079
|
function parseRunAction(value) {
|
|
988
1080
|
if (!isRecord2(value) || typeof value.type !== "string" || value.type === "") return null;
|
|
989
1081
|
return {
|
|
@@ -1230,19 +1322,21 @@ async function getDramaQuote(baseUrl, apiKey, orderId, deps) {
|
|
|
1230
1322
|
if (!view || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1231
1323
|
return { view, raw: reply.body };
|
|
1232
1324
|
}
|
|
1233
|
-
async function confirmDramaOrder(baseUrl, apiKey, orderId, expectedQuoteHash, idempotencyKey, deps) {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1325
|
+
async function confirmDramaOrder(baseUrl, apiKey, orderId, expectedQuoteHash, idempotencyKey, deps, knownStatus) {
|
|
1326
|
+
return retainDramaConfirmationOnError(orderId, knownStatus, baseUrl, idempotencyKey, async () => {
|
|
1327
|
+
const reply = await postJson(
|
|
1328
|
+
baseUrl,
|
|
1329
|
+
apiKey,
|
|
1330
|
+
`/api/open/v1/drama/orders/${encodeURIComponent(orderId)}/confirm`,
|
|
1331
|
+
{ expectedQuoteHash },
|
|
1332
|
+
idempotencyKey,
|
|
1333
|
+
deps
|
|
1334
|
+
);
|
|
1335
|
+
const view = parseDramaOrder(reply.body);
|
|
1336
|
+
const started = isRecord2(reply.body) ? reply.body.productionStarted : void 0;
|
|
1337
|
+
if (!view || !isRecord2(reply.body) || typeof started !== "boolean") throw unreadableResponse(reply.status);
|
|
1338
|
+
return { view, productionStarted: started, raw: reply.body };
|
|
1339
|
+
});
|
|
1246
1340
|
}
|
|
1247
1341
|
async function cancelDramaOrder(baseUrl, apiKey, orderId, idempotencyKey, deps) {
|
|
1248
1342
|
const reply = await postJson(
|
|
@@ -1992,7 +2086,7 @@ function settleOrder2(outcome, baseUrl) {
|
|
|
1992
2086
|
throw new CliError({
|
|
1993
2087
|
code: "CLI_WAIT_TIMEOUT",
|
|
1994
2088
|
exitCode: EXIT.WAIT_TIMEOUT,
|
|
1995
|
-
message: `\u7B49\
|
|
2089
|
+
message: order2.status === "quotable" ? `\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\u3002\u8BA2\u5355\u72B6\u6001\u4E3A quotable\uFF0C\u9700\u5B8C\u6210\u8D39\u7528\u786E\u8BA4\u540E\u624D\u80FD\u5F00\u59CB\u5236\u4F5C\u3002\u672C\u6B21\u67E5\u8BE2\u4E0D\u4F1A\u81EA\u52A8\u786E\u8BA4\uFF1B\u8BF7\u67E5\u8BE2\u62A5\u4EF7\u540E\u663E\u5F0F\u786E\u8BA4\u5F00\u62CD\u3002\u67E5\u8BE2\u539F\u8BA2\u5355\uFF1A${recovery.statusCommand}` : `\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\uFF0C\u8BA2\u5355\u5F53\u524D\u72B6\u6001\u4E3A ${singleLine(order2.status)}\u3002\u67E5\u8BE2\u539F\u8BA2\u5355\uFF1A${recovery.statusCommand}\uFF1B\u6DFB\u52A0 --wait --timeout <\u79D2\u6570> \u53EF\u7EE7\u7EED\u7B49\u5F85\u3002`,
|
|
1996
2090
|
recovery
|
|
1997
2091
|
});
|
|
1998
2092
|
}
|
|
@@ -2001,7 +2095,9 @@ function settleOrder2(outcome, baseUrl) {
|
|
|
2001
2095
|
code: "CLI_TASK_FAILED",
|
|
2002
2096
|
exitCode: EXIT.TASK_FAILED,
|
|
2003
2097
|
message: order2.reason === void 0 || order2.reason.trim() === "" ? "\u8FD9\u5355\u77ED\u5267\u6CA1\u6709\u62CD\u6210" : singleLine(order2.reason),
|
|
2004
|
-
recovery
|
|
2098
|
+
recovery,
|
|
2099
|
+
hints: failureLines(order2),
|
|
2100
|
+
...order2.failures?.length ? { failures: order2.failures } : {}
|
|
2005
2101
|
});
|
|
2006
2102
|
}
|
|
2007
2103
|
if (order2.status === "canceled") {
|
|
@@ -2038,9 +2134,18 @@ function guidanceLines(order2) {
|
|
|
2038
2134
|
const scenes = gap.sceneNos.length > 0 ? `\uFF0C\u51FA\u73B0\u5728\u7B2C ${gap.sceneNos.join("\u3001")} \u955C` : "";
|
|
2039
2135
|
lines.push(`\u7F3A\u53E3\uFF1A${kind}\u300C${singleLine(gap.label !== "" ? gap.label : gap.key)}\u300D\u8FD8\u6CA1\u7ED1\u5B9A${scenes}`);
|
|
2040
2136
|
}
|
|
2137
|
+
lines.push(...failureLines(order2));
|
|
2138
|
+
if (order2.productionCompatibility?.notice) lines.push(`\u5236\u4F5C\u89C4\u683C\uFF1A${singleLine(order2.productionCompatibility.notice)}`);
|
|
2041
2139
|
const next = nextStepOf(order2);
|
|
2042
2140
|
return next === null ? lines : [...lines, next];
|
|
2043
2141
|
}
|
|
2142
|
+
function failureLines(order2) {
|
|
2143
|
+
return (order2.failures ?? []).flatMap((failure) => [
|
|
2144
|
+
`\u955C\u5934\u95EE\u9898\uFF1A${singleLine(failure.message)}`,
|
|
2145
|
+
...failure.reference?.assetIds.length ? [`\u7D20\u6750\u7F16\u53F7\uFF1A${failure.reference.assetIds.map(singleLine).join("\u3001")}`] : [],
|
|
2146
|
+
`\u5904\u7406\u5EFA\u8BAE\uFF1A${singleLine(failure.suggestion)}`
|
|
2147
|
+
]);
|
|
2148
|
+
}
|
|
2044
2149
|
function nextStepOf(order2) {
|
|
2045
2150
|
switch (order2.status) {
|
|
2046
2151
|
case "preparing":
|
|
@@ -2053,6 +2158,7 @@ function nextStepOf(order2) {
|
|
|
2053
2158
|
case "stitching":
|
|
2054
2159
|
return `\u4E0B\u4E00\u6B65\uFF1A\u7B49\u5B83\u62CD\u5B8C\uFF1Abuke drama status ${order2.id} --wait`;
|
|
2055
2160
|
case "partial":
|
|
2161
|
+
if (order2.failures?.length) return "\u4E0B\u4E00\u6B65\uFF1A\u5148\u6309\u955C\u5934\u63D0\u793A\u4FEE\u6B63\u7D20\u6750\u6216\u5728 Studio \u66F4\u6362\u5236\u4F5C\u89C4\u683C\uFF0C\u91CD\u65B0\u67E5\u8BE2\u62A5\u4EF7\u540E\u518D\u786E\u8BA4\u8865\u62CD\u3002";
|
|
2056
2162
|
return `\u4E0B\u4E00\u6B65\uFF1A\u53EA\u8865\u7F3A\u7684\u955C\u5934\uFF1Abuke drama confirm ${order2.id} --quote-hash <\u62A5\u4EF7\u54C8\u5E0C>\uFF1B\u4E0D\u8981\u4E86\uFF1Abuke drama cancel ${order2.id}`;
|
|
2057
2163
|
case "delivered":
|
|
2058
2164
|
return `\u4E0B\u8F7D\uFF1Abuke drama download ${order2.id}`;
|
|
@@ -2069,9 +2175,12 @@ function quoteLines(orderId, quote3) {
|
|
|
2069
2175
|
const price = [`\u603B\u4EF7 ${quote3.totalCredits} \u5E03`, `${quote3.shotCount} \u4E2A\u955C\u5934`];
|
|
2070
2176
|
if (quote3.shotCreditCost !== void 0) price.push(`\u6BCF\u955C ${quote3.shotCreditCost} \u5E03`);
|
|
2071
2177
|
const spec = [quote3.videoModel, quote3.resolution].filter((entry) => entry !== void 0);
|
|
2178
|
+
const compatibility = quote3.productionCompatibility;
|
|
2072
2179
|
return [
|
|
2073
2180
|
`\u62A5\u4EF7\uFF1A${price.join("\uFF0C")}`,
|
|
2074
2181
|
...spec.length > 0 ? [`\u6863\u4F4D\uFF1A${spec.join(" / ")}`] : [],
|
|
2182
|
+
...compatibility?.status === "adjusted" ? [`\u539F\u8BF7\u6C42\u6863\u4F4D\uFF1A${singleLine(compatibility.requested.videoModel)} / ${singleLine(compatibility.requested.resolution)}`] : [],
|
|
2183
|
+
...compatibility?.notice ? [`\u89C4\u683C\u8BF4\u660E\uFF1A${singleLine(compatibility.notice)}`] : [],
|
|
2075
2184
|
`\u62A5\u4EF7\u54C8\u5E0C\uFF1A${quote3.quoteHash}`,
|
|
2076
2185
|
`\u4F59\u989D\uFF1A${sufficientLine(quote3.sufficient)}`,
|
|
2077
2186
|
`\u786E\u8BA4\u5F00\u62CD\uFF1Abuke drama confirm ${orderId} --quote-hash ${quote3.quoteHash}`
|
|
@@ -2089,6 +2198,8 @@ async function create(context) {
|
|
|
2089
2198
|
throw usageError(`--duration \u53EA\u80FD\u662F ${DURATION_KEYS.join("\u3001")}\uFF0C\u5199\u7684\u662F ${durationKey}`);
|
|
2090
2199
|
}
|
|
2091
2200
|
const briefRef = textOption(values, "brief");
|
|
2201
|
+
const videoModel = textOption(values, "model");
|
|
2202
|
+
const resolution = textOption(values, "resolution");
|
|
2092
2203
|
const brief = briefRef === void 0 ? void 0 : await readPropsArgument(io, briefRef, "\u6545\u4E8B\u8BBE\u5B9A\uFF08--brief\uFF09");
|
|
2093
2204
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
2094
2205
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
@@ -2099,7 +2210,9 @@ async function create(context) {
|
|
|
2099
2210
|
productId,
|
|
2100
2211
|
...genreId === void 0 ? {} : { genreId },
|
|
2101
2212
|
...durationKey === void 0 ? {} : { durationKey },
|
|
2102
|
-
...brief === void 0 ? {} : { brief }
|
|
2213
|
+
...brief === void 0 ? {} : { brief },
|
|
2214
|
+
...videoModel === void 0 ? {} : { videoModel },
|
|
2215
|
+
...resolution === void 0 ? {} : { resolution }
|
|
2103
2216
|
},
|
|
2104
2217
|
idempotencyKey,
|
|
2105
2218
|
io
|
|
@@ -2128,7 +2241,12 @@ async function quote2(context, rawId) {
|
|
|
2128
2241
|
const orderId = orderIdOf2(rawId);
|
|
2129
2242
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2130
2243
|
const { view, raw } = await getDramaQuote(baseUrl, apiKey, orderId, io);
|
|
2131
|
-
out.result(quoteLines(orderId, view), {
|
|
2244
|
+
out.result(quoteLines(orderId, view), {
|
|
2245
|
+
quote: raw.quote,
|
|
2246
|
+
quoteHash: view.quoteHash,
|
|
2247
|
+
sufficient: view.sufficient,
|
|
2248
|
+
...raw.productionCompatibility === void 0 ? {} : { productionCompatibility: raw.productionCompatibility }
|
|
2249
|
+
});
|
|
2132
2250
|
}
|
|
2133
2251
|
async function confirm(context, rawId) {
|
|
2134
2252
|
const { io, out, values } = context;
|
|
@@ -2138,8 +2256,11 @@ async function confirm(context, rawId) {
|
|
|
2138
2256
|
throw usageError("\u8981\u7ED9 --quote-hash <\u62A5\u4EF7\u54C8\u5E0C>\uFF08buke drama quote \u56DE\u7684\u90A3\u4E2A\uFF09");
|
|
2139
2257
|
}
|
|
2140
2258
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2141
|
-
const
|
|
2142
|
-
const
|
|
2259
|
+
const suppliedKey = textOption(values, "idempotency-key")?.trim();
|
|
2260
|
+
const preflightRecovery = (status4) => dramaConfirmationRecovery(orderId, status4, baseUrl, suppliedKey, "not_submitted");
|
|
2261
|
+
const current = await retainTaskOnError(() => preflightRecovery(), () => getDramaOrder(baseUrl, apiKey, orderId, io));
|
|
2262
|
+
const knownStatus = current.view.status;
|
|
2263
|
+
const quoted = current.view.status === "quotable" ? await retainTaskOnError(() => preflightRecovery(knownStatus), () => getDramaQuote(baseUrl, apiKey, orderId, io)) : null;
|
|
2143
2264
|
if (values.yes !== true) {
|
|
2144
2265
|
if (!out.json) {
|
|
2145
2266
|
out.result(
|
|
@@ -2155,7 +2276,7 @@ async function confirm(context, rawId) {
|
|
|
2155
2276
|
});
|
|
2156
2277
|
}
|
|
2157
2278
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
2158
|
-
const confirmed = await confirmDramaOrder(baseUrl, apiKey, orderId, quoteHash, idempotencyKey, io);
|
|
2279
|
+
const confirmed = await confirmDramaOrder(baseUrl, apiKey, orderId, quoteHash, idempotencyKey, io, knownStatus);
|
|
2159
2280
|
out.result(
|
|
2160
2281
|
[
|
|
2161
2282
|
...orderLines2(confirmed.view),
|
|
@@ -2209,6 +2330,7 @@ function errorDocument(error) {
|
|
|
2209
2330
|
if (error.retryAfterSeconds !== void 0) document.error.retryAfterSeconds = error.retryAfterSeconds;
|
|
2210
2331
|
if (error.httpStatus !== void 0) document.error.httpStatus = error.httpStatus;
|
|
2211
2332
|
if (error.recovery !== void 0) document.recovery = error.recovery;
|
|
2333
|
+
if (error.failures !== void 0) document.failures = error.failures;
|
|
2212
2334
|
return document;
|
|
2213
2335
|
}
|
|
2214
2336
|
function errorLines(error) {
|
|
@@ -2221,12 +2343,15 @@ function errorLines(error) {
|
|
|
2221
2343
|
`\uFF08${details.join("\uFF1B")}\uFF09`,
|
|
2222
2344
|
...error.hints,
|
|
2223
2345
|
...recovery === void 0 ? [] : [
|
|
2224
|
-
recovery.acceptance === "confirmed" ? `\u5DF2\u53D7\u7406\u4EFB\u52A1\uFF1A${singleLine(recovery.taskId ?? "")}` : "\u63D0\u4EA4\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u5148\u5728 Studio \u6838\u5BF9\u539F\u8BF7\u6C42\uFF1B\u4E0D\u8981\u91CD\u65B0\u4E0B\u5355",
|
|
2346
|
+
recovery.operation === "confirm" ? `${recovery.acceptance === "confirmed" ? "\u539F\u8BA2\u5355" : "\u76EE\u6807\u8BA2\u5355"}\uFF1A${singleLine(recovery.taskId ?? "")}` : recovery.acceptance === "confirmed" ? `\u5DF2\u53D7\u7406\u4EFB\u52A1\uFF1A${singleLine(recovery.taskId ?? "")}` : "\u63D0\u4EA4\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u5148\u5728 Studio \u6838\u5BF9\u539F\u8BF7\u6C42\uFF1B\u4E0D\u8981\u91CD\u65B0\u4E0B\u5355",
|
|
2347
|
+
...recovery.operation !== "confirm" ? [] : [
|
|
2348
|
+
recovery.operationOutcome === "not_submitted" ? "\u672C\u6B21\u786E\u8BA4\u5C1A\u672A\u63D0\u4EA4\uFF1B\u8BF7\u5148\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001\u5E76\u5904\u7406\u9519\u8BEF\u3002" : recovery.operationOutcome === "rejected" ? "\u672C\u6B21\u786E\u8BA4\u5DF2\u88AB\u62D2\u7EDD\uFF0C\u672A\u53D7\u7406\uFF1B\u8BF7\u5904\u7406\u9519\u8BEF\u540E\u67E5\u8BE2\u539F\u8BA2\u5355\u3002" : "\u672C\u6B21\u786E\u8BA4\u7ED3\u679C\u672A\u77E5\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u8BA2\u5355\uFF0C\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u786E\u8BA4\u3002"
|
|
2349
|
+
],
|
|
2225
2350
|
...recovery.baseUrl === void 0 ? [] : [`\u670D\u52A1\u5730\u5740\uFF1A${singleLine(recovery.baseUrl)}`],
|
|
2226
2351
|
...recovery.status === void 0 ? [] : [`\u6700\u540E\u72B6\u6001\uFF1A${singleLine(recovery.status)}`],
|
|
2227
2352
|
...recovery.failureCode === void 0 ? [] : [`\u4EFB\u52A1\u5931\u8D25\u7801\uFF1A${singleLine(recovery.failureCode)}`],
|
|
2228
2353
|
...recovery.idempotencyKey === void 0 ? [] : [`\u5E42\u7B49\u952E\uFF1A${singleLine(recovery.idempotencyKey)}`],
|
|
2229
|
-
...recovery.statusCommand === void 0 ? [] : [
|
|
2354
|
+
...recovery.statusCommand === void 0 ? [] : [`${recovery.operation === "confirm" ? "\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001" : "\u53EA\u67E5\u8BE2\u539F\u4EFB\u52A1"}\uFF1A${singleLine(recovery.statusCommand)}`]
|
|
2230
2355
|
]
|
|
2231
2356
|
];
|
|
2232
2357
|
}
|
|
@@ -2886,11 +3011,11 @@ var COMMANDS = {
|
|
|
2886
3011
|
drama: {
|
|
2887
3012
|
run: drama,
|
|
2888
3013
|
acceptsBaseUrl: true,
|
|
2889
|
-
options: ["product", "genre", "duration", "brief", "quote-hash", "yes", "wait", "timeout", "out", "idempotency-key"],
|
|
3014
|
+
options: ["product", "genre", "duration", "brief", "model", "resolution", "quote-hash", "yes", "wait", "timeout", "out", "idempotency-key"],
|
|
2890
3015
|
positionals: ["\u5B50\u547D\u4EE4", "\u8BA2\u5355id"],
|
|
2891
3016
|
help: [
|
|
2892
3017
|
"\u7528\u6CD5\uFF1A",
|
|
2893
|
-
" buke drama create --product <\u4EA7\u54C1id> [--genre <\u9898\u6750id>] [--duration 30s|60s|90s] [--brief <JSON \u6587\u4EF6|->] [--json]",
|
|
3018
|
+
" buke drama create --product <\u4EA7\u54C1id> [--genre <\u9898\u6750id>] [--duration 30s|60s|90s] [--brief <JSON \u6587\u4EF6|->] [--model <\u6A21\u578B>] [--resolution <\u5206\u8FA8\u7387>] [--json]",
|
|
2894
3019
|
" buke drama status <\u8BA2\u5355id> [--wait] [--timeout <\u79D2>]",
|
|
2895
3020
|
" buke drama quote <\u8BA2\u5355id>",
|
|
2896
3021
|
" buke drama confirm <\u8BA2\u5355id> --quote-hash <\u62A5\u4EF7\u54C8\u5E0C> [--yes]",
|
|
@@ -2910,6 +3035,8 @@ var COMMANDS = {
|
|
|
2910
3035
|
" --genre <\u9898\u6750id> \u9898\u6750 id\uFF08\u5982 counterattack\u3001urban-ceo\u3001family\uFF09",
|
|
2911
3036
|
" --duration <\u4F53\u91CF> \u6210\u7247\u4F53\u91CF\uFF1A30s\u300160s \u6216 90s\uFF1B\u4E0D\u7ED9\u65F6 30s",
|
|
2912
3037
|
" --brief <JSON \u6587\u4EF6|-> \u6545\u4E8B\u8BBE\u5B9A\uFF1Adescription\u3001forbidden\u3001storyTone \u4E09\u9879\uFF0C\u4E00\u4E2A JSON \u6587\u4EF6\u6216 - \u8868\u793A\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB",
|
|
3038
|
+
" --model <\u6A21\u578B> \u660E\u786E\u9009\u62E9\u5236\u4F5C\u6A21\u578B\uFF0C\u670D\u52A1\u7AEF\u6309\u5F53\u524D\u80FD\u529B\u6821\u9A8C\uFF1B\u5DF2\u6709\u8BA2\u5355\u8BF7\u5728 Studio \u4FEE\u6539\u5236\u4F5C\u89C4\u683C",
|
|
3039
|
+
" --resolution <\u5206\u8FA8\u7387> \u660E\u786E\u9009\u62E9\u5236\u4F5C\u5206\u8FA8\u7387\uFF0C\u4E0E\u6A21\u578B\u4E00\u5E76\u7531\u670D\u52A1\u7AEF\u6821\u9A8C",
|
|
2913
3040
|
" --quote-hash <\u54C8\u5E0C> \u62A5\u4EF7\u54C8\u5E0C\uFF08buke drama quote \u56DE\u7684\uFF09\uFF0C\u786E\u8BA4\u5F00\u62CD\u65F6\u539F\u6837\u5E26\u56DE",
|
|
2914
3041
|
" --yes confirm \u65F6\u771F\u7684\u63D0\u4EA4\u5E76\u5F00\u62CD\uFF1B\u4E0D\u7ED9\u65F6\u53EA\u770B\u5F53\u524D\u62A5\u4EF7",
|
|
2915
3042
|
" --wait \u4E00\u76F4\u7B49\u5230\u7EC8\u6001\u6216\u505C\u9760\uFF1A\u6210\u529F\u9000\u51FA 0\uFF0C\u5931\u8D25\u6216\u53D6\u6D88\u9000\u51FA 9\uFF0C\u5230\u65F6\u9650\u9000\u51FA 8",
|
|
@@ -2991,6 +3118,7 @@ var STRING_OPTIONS = /* @__PURE__ */ new Set([
|
|
|
2991
3118
|
"intent",
|
|
2992
3119
|
"duration",
|
|
2993
3120
|
"resolution",
|
|
3121
|
+
"model",
|
|
2994
3122
|
"speed",
|
|
2995
3123
|
"aspect-ratio",
|
|
2996
3124
|
"style-preset",
|