Skip to content

Commit c35f285

Browse files
committed
refactor(flags): align media command async and concurrent handling
- scope image/video task execution to --async and --concurrent - add concurrent task fan-out for video edit and video ref - extend image edit to the async image task path - refresh e2e coverage and generated command references
1 parent b3b1a08 commit c35f285

13 files changed

Lines changed: 424 additions & 187 deletions

File tree

docs/agents/stress-batch-tests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pnpm run test:stress -- video-edit --reuse-fixtures -- --count 3
126126

127127
**禁止**对子进程加 `--quiet`(与 `--output json` 并存时可能丢 `urls` / `video_url`)。
128128

129-
**禁止**对视频相关子进程加 `--no-wait`;须阻塞到任务完成(及下载路径正确时落盘)。
129+
**禁止**对视频相关子进程加 `--async`;须阻塞到任务完成(及下载路径正确时落盘)。
130130

131131
### 成功 / 失败判定(概要)
132132

@@ -192,7 +192,7 @@ pnpm run test:stress -- video-edit --reuse-fixtures -- --count 3
192192

193193
- [ ] `lib/paths.mjs` 解析的 `CLI_PACKAGE` / `MONOREPO_ROOT` 仍正确
194194
- [ ] 子进程仍为 `node` + `src/main.ts`,未改回裸 `pnpm run dev` 执行任务
195-
- [ ] 未对子进程加 `--quiet`,视频未加 `--no-wait`
195+
- [ ] 未对子进程加 `--quiet`,视频未加 `--async`
196196
- [ ] `parsers.mjs` 与文档中的成功判定一致
197197
- [ ]`package.json` 仅保留 `test:stress` 入口指向 `run.mjs`
198198
- [ ] `node --check` 对相关 `.mjs` 通过,`pnpm run test:stress -- list` 可运行

packages/cli/tests/e2e/image-edit.e2e.test.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,32 @@ describe("e2e: image edit", () => {
2727
test("image edit --help 正常退出", async () => {
2828
const { stderr, exitCode } = await runCli(["image", "edit", "--help"]);
2929
expect(exitCode, stderr).toBe(0);
30-
expect(stderr).toMatch(/edit|--image|--prompt/i);
30+
expect(stderr).toMatch(/edit|--image|--prompt|--async|--concurrent/i);
31+
});
32+
33+
test("image edit --dry-run 接受 async 模型的 --async 与 --concurrent", async () => {
34+
const { stdout, stderr, exitCode } = await runCli([
35+
"image",
36+
"edit",
37+
"--dry-run",
38+
"--model",
39+
"wan2.6-t2i",
40+
"--image",
41+
"https://example.com/source.png",
42+
"--prompt",
43+
"Change the background to blue",
44+
"--async",
45+
"--concurrent",
46+
"2",
47+
"--output",
48+
"json",
49+
]);
50+
expect(exitCode, stderr).toBe(0);
51+
const data = parseStdoutJson<{ mode?: string; request?: { input?: { messages?: unknown[] } } }>(
52+
stdout,
53+
);
54+
expect(data.mode).toBe("async");
55+
expect(data.request?.input?.messages?.length).toBeGreaterThan(0);
3156
});
3257
});
3358

packages/cli/tests/e2e/video-edit.e2e.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,29 @@ describe("e2e: video edit", () => {
2424
test("video edit --help 正常退出", async () => {
2525
const { stderr, exitCode } = await runCli(["video", "edit", "--help"]);
2626
expect(exitCode, stderr).toBe(0);
27-
expect(stderr).toMatch(/edit|--video|--prompt|model/i);
27+
expect(stderr).toMatch(/edit|--video|--prompt|model|--async|--concurrent/i);
28+
});
29+
30+
test("video edit --dry-run 接受 --async 与 --concurrent", async () => {
31+
const { stdout, stderr, exitCode } = await runCli([
32+
"video",
33+
"edit",
34+
"--dry-run",
35+
"--video",
36+
"https://example.com/input.mp4",
37+
"--prompt",
38+
"整体色调偏暖",
39+
"--async",
40+
"--concurrent",
41+
"2",
42+
"--output",
43+
"json",
44+
]);
45+
expect(exitCode, stderr).toBe(0);
46+
const data = parseStdoutJson<{ request?: { input?: { media?: Array<{ url?: string }> } } }>(
47+
stdout,
48+
);
49+
expect(data.request?.input?.media?.[0]?.url).toBe("https://example.com/input.mp4");
2850
});
2951
});
3052

packages/cli/tests/e2e/video-ref-r2v.e2e.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,29 @@ describe("e2e: video ref (r2v)", () => {
2424
test("video ref --help 正常退出", async () => {
2525
const { stderr, exitCode } = await runCli(["video", "ref", "--help"]);
2626
expect(exitCode, stderr).toBe(0);
27-
expect(stderr).toMatch(/ref|--prompt|--image|model/i);
27+
expect(stderr).toMatch(/ref|--prompt|--image|model|--async|--concurrent/i);
28+
});
29+
30+
test("video ref --dry-run 接受 --async 与 --concurrent", async () => {
31+
const { stdout, stderr, exitCode } = await runCli([
32+
"video",
33+
"ref",
34+
"--dry-run",
35+
"--prompt",
36+
"Image 1 waves",
37+
"--image",
38+
"https://example.com/person.png",
39+
"--async",
40+
"--concurrent",
41+
"2",
42+
"--output",
43+
"json",
44+
]);
45+
expect(exitCode, stderr).toBe(0);
46+
const data = parseStdoutJson<{ request?: { input?: { media?: Array<{ url?: string }> } } }>(
47+
stdout,
48+
);
49+
expect(data.request?.input?.media?.[0]?.url).toBe("https://example.com/person.png");
2850
});
2951
});
3052

packages/cli/tests/stress/lib/parsers.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function parseImageResult(stdout) {
7878
const ids = data.task_ids ?? [data.task_id];
7979
return {
8080
ok: false,
81-
error: `仅返回 task_id,未等待生成完成: ${ids.join(", ")}。请勿使用 --no-wait,或检查 ~/.bailian/config.json 是否开启 async`,
81+
error: `仅返回 task_id,未等待生成完成: ${ids.join(", ")}。请勿使用 --async,或检查调用参数是否开启 async`,
8282
};
8383
}
8484
return { ok: false, error: "JSON 中无 urls / saved 字段(可能生成未完成)" };
@@ -169,7 +169,7 @@ export function parseVideoResult(stdout) {
169169
const ids = taskIds ?? [taskId];
170170
return {
171171
ok: false,
172-
error: `仅返回 task_id,未等待生成完成: ${ids.join(", ")}。请勿使用 --no-wait,或检查 ~/.bailian/config.json 是否开启 async`,
172+
error: `仅返回 task_id,未等待生成完成: ${ids.join(", ")}。请勿使用 --async,或检查调用参数是否开启 async`,
173173
};
174174
}
175175
return { ok: false, error: "JSON 中无 video_url / saved 字段(可能生成未完成)" };

0 commit comments

Comments
 (0)