mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-18 17:13:25 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
146
openclaw/extensions/minimax/video-generation-provider.test.ts
Normal file
146
openclaw/extensions/minimax/video-generation-provider.test.ts
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { expectExplicitVideoGenerationCapabilities } from "../../test/helpers/media-generation/provider-capability-assertions.js";
|
||||
import {
|
||||
getMinimaxProviderHttpMocks,
|
||||
installMinimaxProviderHttpMockCleanup,
|
||||
loadMinimaxVideoGenerationProviderModule,
|
||||
} from "./provider-http.test-helpers.js";
|
||||
|
||||
const { postJsonRequestMock, fetchWithTimeoutMock } = getMinimaxProviderHttpMocks();
|
||||
|
||||
let buildMinimaxVideoGenerationProvider: Awaited<
|
||||
ReturnType<typeof loadMinimaxVideoGenerationProviderModule>
|
||||
>["buildMinimaxVideoGenerationProvider"];
|
||||
|
||||
beforeAll(async () => {
|
||||
({ buildMinimaxVideoGenerationProvider } = await loadMinimaxVideoGenerationProviderModule());
|
||||
});
|
||||
|
||||
installMinimaxProviderHttpMockCleanup();
|
||||
|
||||
describe("minimax video generation provider", () => {
|
||||
it("declares explicit mode capabilities", () => {
|
||||
expectExplicitVideoGenerationCapabilities(buildMinimaxVideoGenerationProvider());
|
||||
});
|
||||
|
||||
it("creates a task, polls status, and downloads the generated video", async () => {
|
||||
postJsonRequestMock.mockResolvedValue({
|
||||
response: {
|
||||
json: async () => ({
|
||||
task_id: "task-123",
|
||||
base_resp: { status_code: 0 },
|
||||
}),
|
||||
},
|
||||
release: vi.fn(async () => {}),
|
||||
});
|
||||
fetchWithTimeoutMock
|
||||
.mockResolvedValueOnce({
|
||||
json: async () => ({
|
||||
task_id: "task-123",
|
||||
status: "Success",
|
||||
video_url: "https://example.com/out.mp4",
|
||||
file_id: "file-1",
|
||||
base_resp: { status_code: 0 },
|
||||
}),
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
headers: new Headers({ "content-type": "video/mp4" }),
|
||||
arrayBuffer: async () => Buffer.from("mp4-bytes"),
|
||||
});
|
||||
|
||||
const provider = buildMinimaxVideoGenerationProvider();
|
||||
const result = await provider.generateVideo({
|
||||
provider: "minimax",
|
||||
model: "MiniMax-Hailuo-2.3",
|
||||
prompt: "A fox sprints across snowy hills",
|
||||
cfg: {},
|
||||
durationSeconds: 5,
|
||||
});
|
||||
|
||||
expect(postJsonRequestMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
url: "https://api.minimax.io/v1/video_generation",
|
||||
body: expect.objectContaining({
|
||||
duration: 6,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(result.videos).toHaveLength(1);
|
||||
expect(result.metadata).toEqual(
|
||||
expect.objectContaining({
|
||||
taskId: "task-123",
|
||||
fileId: "file-1",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("downloads via file_id when the status response omits video_url", async () => {
|
||||
postJsonRequestMock.mockResolvedValue({
|
||||
response: {
|
||||
json: async () => ({
|
||||
task_id: "task-456",
|
||||
base_resp: { status_code: 0 },
|
||||
}),
|
||||
},
|
||||
release: vi.fn(async () => {}),
|
||||
});
|
||||
fetchWithTimeoutMock
|
||||
.mockResolvedValueOnce({
|
||||
json: async () => ({
|
||||
task_id: "task-456",
|
||||
status: "Success",
|
||||
file_id: "file-9",
|
||||
base_resp: { status_code: 0 },
|
||||
}),
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
json: async () => ({
|
||||
file: {
|
||||
file_id: "file-9",
|
||||
filename: "output_aigc.mp4",
|
||||
download_url: "https://example.com/download.mp4",
|
||||
},
|
||||
base_resp: { status_code: 0 },
|
||||
}),
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
headers: new Headers({ "content-type": "video/mp4" }),
|
||||
arrayBuffer: async () => Buffer.from("mp4-bytes"),
|
||||
});
|
||||
|
||||
const provider = buildMinimaxVideoGenerationProvider();
|
||||
const result = await provider.generateVideo({
|
||||
provider: "minimax",
|
||||
model: "MiniMax-Hailuo-2.3",
|
||||
prompt: "A fox sprints across snowy hills",
|
||||
cfg: {},
|
||||
});
|
||||
|
||||
expect(fetchWithTimeoutMock).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
"https://api.minimax.io/v1/files/retrieve?file_id=file-9",
|
||||
expect.objectContaining({
|
||||
method: "GET",
|
||||
}),
|
||||
expect.any(Number),
|
||||
expect.any(Function),
|
||||
);
|
||||
expect(fetchWithTimeoutMock).toHaveBeenNthCalledWith(
|
||||
3,
|
||||
"https://example.com/download.mp4",
|
||||
expect.objectContaining({
|
||||
method: "GET",
|
||||
}),
|
||||
expect.any(Number),
|
||||
expect.any(Function),
|
||||
);
|
||||
expect(result.videos).toHaveLength(1);
|
||||
expect(result.metadata).toEqual(
|
||||
expect.objectContaining({
|
||||
taskId: "task-456",
|
||||
fileId: "file-9",
|
||||
videoUrl: undefined,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue