mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-18 06:03:17 +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
157
openclaw/extensions/vydra/video-generation-provider.ts
Normal file
157
openclaw/extensions/vydra/video-generation-provider.ts
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
|
||||
import {
|
||||
assertOkOrThrowHttpError,
|
||||
createProviderOperationDeadline,
|
||||
postJsonRequest,
|
||||
resolveProviderOperationTimeoutMs,
|
||||
} from "openclaw/plugin-sdk/provider-http";
|
||||
import type { VideoGenerationProvider } from "openclaw/plugin-sdk/video-generation";
|
||||
import {
|
||||
DEFAULT_VYDRA_VIDEO_MODEL,
|
||||
downloadVydraAsset,
|
||||
extractVydraResultUrls,
|
||||
resolveCompletedVydraPayload,
|
||||
resolveVydraResponseJobId,
|
||||
resolveVydraResponseStatus,
|
||||
resolveVydraRequestContext,
|
||||
} from "./shared.js";
|
||||
|
||||
const VYDRA_KLING_MODEL = "kling";
|
||||
|
||||
function resolveVydraVideoRequestBody(
|
||||
req: Parameters<VideoGenerationProvider["generateVideo"]>[0],
|
||||
) {
|
||||
const model = req.model?.trim() || DEFAULT_VYDRA_VIDEO_MODEL;
|
||||
if (model === VYDRA_KLING_MODEL) {
|
||||
const input = req.inputImages?.[0];
|
||||
const imageUrl = input?.url?.trim();
|
||||
if (!imageUrl) {
|
||||
throw new Error("Vydra kling currently requires a remote image URL reference.");
|
||||
}
|
||||
return {
|
||||
model,
|
||||
body: {
|
||||
prompt: req.prompt,
|
||||
// Vydra's kling route has been inconsistent about which field it requires.
|
||||
image_url: imageUrl,
|
||||
video_url: imageUrl,
|
||||
},
|
||||
};
|
||||
}
|
||||
if ((req.inputImages?.length ?? 0) > 0) {
|
||||
throw new Error(
|
||||
`Vydra ${model} does not support image reference inputs in the bundled plugin.`,
|
||||
);
|
||||
}
|
||||
return {
|
||||
model,
|
||||
body: {
|
||||
prompt: req.prompt,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function buildVydraVideoGenerationProvider(): VideoGenerationProvider {
|
||||
return {
|
||||
id: "vydra",
|
||||
label: "Vydra",
|
||||
defaultModel: DEFAULT_VYDRA_VIDEO_MODEL,
|
||||
models: [DEFAULT_VYDRA_VIDEO_MODEL, VYDRA_KLING_MODEL],
|
||||
isConfigured: ({ agentDir }) =>
|
||||
isProviderApiKeyConfigured({
|
||||
provider: "vydra",
|
||||
agentDir,
|
||||
}),
|
||||
capabilities: {
|
||||
generate: {
|
||||
maxVideos: 1,
|
||||
},
|
||||
imageToVideo: {
|
||||
enabled: true,
|
||||
maxVideos: 1,
|
||||
maxInputImages: 1,
|
||||
},
|
||||
videoToVideo: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
async generateVideo(req) {
|
||||
if ((req.inputVideos?.length ?? 0) > 0) {
|
||||
throw new Error("Vydra video generation does not support video reference inputs.");
|
||||
}
|
||||
|
||||
const { fetchFn, baseUrl, allowPrivateNetwork, headers, dispatcherPolicy } =
|
||||
await resolveVydraRequestContext({
|
||||
cfg: req.cfg,
|
||||
agentDir: req.agentDir,
|
||||
authStore: req.authStore,
|
||||
capability: "video",
|
||||
});
|
||||
const deadline = createProviderOperationDeadline({
|
||||
timeoutMs: req.timeoutMs,
|
||||
label: "Vydra video generation",
|
||||
});
|
||||
const { model, body } = resolveVydraVideoRequestBody(req);
|
||||
const { response, release } = await postJsonRequest({
|
||||
url: `${baseUrl}/models/${model}`,
|
||||
headers,
|
||||
body,
|
||||
timeoutMs: resolveProviderOperationTimeoutMs({
|
||||
deadline,
|
||||
defaultTimeoutMs: 120_000,
|
||||
}),
|
||||
fetchFn,
|
||||
allowPrivateNetwork,
|
||||
dispatcherPolicy,
|
||||
});
|
||||
|
||||
try {
|
||||
await assertOkOrThrowHttpError(response, "Vydra video generation failed");
|
||||
const submitted = await response.json();
|
||||
const completedPayload = await resolveCompletedVydraPayload({
|
||||
submitted,
|
||||
baseUrl,
|
||||
headers,
|
||||
timeoutMs: resolveProviderOperationTimeoutMs({
|
||||
deadline,
|
||||
defaultTimeoutMs: 120_000,
|
||||
}),
|
||||
fetchFn,
|
||||
kind: "video",
|
||||
missingJobIdMessage: "Vydra video generation response missing job id",
|
||||
});
|
||||
const videoUrl = extractVydraResultUrls(completedPayload, "video")[0];
|
||||
if (!videoUrl) {
|
||||
throw new Error("Vydra video generation completed without a video URL");
|
||||
}
|
||||
const video = await downloadVydraAsset({
|
||||
url: videoUrl,
|
||||
kind: "video",
|
||||
timeoutMs: resolveProviderOperationTimeoutMs({
|
||||
deadline,
|
||||
defaultTimeoutMs: 120_000,
|
||||
}),
|
||||
fetchFn,
|
||||
});
|
||||
return {
|
||||
videos: [
|
||||
{
|
||||
buffer: video.buffer,
|
||||
mimeType: video.mimeType,
|
||||
fileName: video.fileName,
|
||||
},
|
||||
],
|
||||
model,
|
||||
metadata: {
|
||||
jobId:
|
||||
resolveVydraResponseJobId(completedPayload) ?? resolveVydraResponseJobId(submitted),
|
||||
videoUrl,
|
||||
status: resolveVydraResponseStatus(completedPayload) ?? "completed",
|
||||
},
|
||||
};
|
||||
} finally {
|
||||
await release();
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue