Download src/media-understanding/runner.video.test.ts from Darochin/openskynet: direct link, hf CLI and curl.
- Browser
- Download file 4.01 kB
-
https://huggingface.co/Darochin/openskynet/resolve/main/src/media-understanding/runner.video.test.ts
- Command line
-
hf download hf://Darochin/openskynet/src/media-understanding/runner.video.test.ts
-
curl -L -o runner.video.test.ts https://huggingface.co/Darochin/openskynet/resolve/main/src/media-understanding/runner.video.test.ts
4.01 kB
| import { describe, expect, it } from "vitest"; | |
| import type { OpenClawConfig } from "../config/config.js"; | |
| import { withEnvAsync } from "../test-utils/env.js"; | |
| import { runCapability } from "./runner.js"; | |
| import { withVideoFixture } from "./runner.test-utils.js"; | |
| describe("runCapability video provider wiring", () => { | |
| it("merges video baseUrl and headers with entry precedence", async () => { | |
| let seenBaseUrl: string | undefined; | |
| let seenHeaders: Record<string, string> | undefined; | |
| await withVideoFixture("openclaw-video-merge", async ({ ctx, media, cache }) => { | |
| const cfg = { | |
| models: { | |
| providers: { | |
| moonshot: { | |
| apiKey: "provider-key", // pragma: allowlist secret | |
| baseUrl: "https://provider.example/v1", | |
| headers: { "X-Provider": "1" }, | |
| models: [], | |
| }, | |
| }, | |
| }, | |
| tools: { | |
| media: { | |
| video: { | |
| enabled: true, | |
| baseUrl: "https://config.example/v1", | |
| headers: { "X-Config": "2" }, | |
| models: [ | |
| { | |
| provider: "moonshot", | |
| model: "kimi-k2.5", | |
| baseUrl: "https://entry.example/v1", | |
| headers: { "X-Entry": "3" }, | |
| }, | |
| ], | |
| }, | |
| }, | |
| }, | |
| } as unknown as OpenClawConfig; | |
| const result = await runCapability({ | |
| capability: "video", | |
| cfg, | |
| ctx, | |
| attachments: cache, | |
| media, | |
| providerRegistry: new Map([ | |
| [ | |
| "moonshot", | |
| { | |
| id: "moonshot", | |
| capabilities: ["video"], | |
| describeVideo: async (req) => { | |
| seenBaseUrl = req.baseUrl; | |
| seenHeaders = req.headers; | |
| return { text: "video ok", model: req.model }; | |
| }, | |
| }, | |
| ], | |
| ]), | |
| }); | |
| expect(result.outputs[0]?.text).toBe("video ok"); | |
| expect(result.outputs[0]?.provider).toBe("moonshot"); | |
| expect(seenBaseUrl).toBe("https://entry.example/v1"); | |
| expect(seenHeaders).toMatchObject({ | |
| "X-Provider": "1", | |
| "X-Config": "2", | |
| "X-Entry": "3", | |
| }); | |
| }); | |
| }); | |
| it("auto-selects moonshot for video when google is unavailable", async () => { | |
| await withEnvAsync( | |
| { | |
| GEMINI_API_KEY: undefined, | |
| MOONSHOT_API_KEY: undefined, | |
| }, | |
| async () => { | |
| await withVideoFixture("openclaw-video-auto-moonshot", async ({ ctx, media, cache }) => { | |
| const cfg = { | |
| models: { | |
| providers: { | |
| moonshot: { | |
| apiKey: "moonshot-key", // pragma: allowlist secret | |
| models: [], | |
| }, | |
| }, | |
| }, | |
| tools: { | |
| media: { | |
| video: { | |
| enabled: true, | |
| }, | |
| }, | |
| }, | |
| } as unknown as OpenClawConfig; | |
| const result = await runCapability({ | |
| capability: "video", | |
| cfg, | |
| ctx, | |
| attachments: cache, | |
| media, | |
| providerRegistry: new Map([ | |
| [ | |
| "google", | |
| { | |
| id: "google", | |
| capabilities: ["video"], | |
| describeVideo: async () => ({ text: "google" }), | |
| }, | |
| ], | |
| [ | |
| "moonshot", | |
| { | |
| id: "moonshot", | |
| capabilities: ["video"], | |
| describeVideo: async () => ({ text: "moonshot", model: "kimi-k2.5" }), | |
| }, | |
| ], | |
| ]), | |
| }); | |
| expect(result.decision.outcome).toBe("success"); | |
| expect(result.outputs[0]?.provider).toBe("moonshot"); | |
| expect(result.outputs[0]?.text).toBe("moonshot"); | |
| }); | |
| }, | |
| ); | |
| }); | |
| }); | |