mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-18 12:23:22 +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
88
openclaw/extensions/comfy/music-generation-provider.ts
Normal file
88
openclaw/extensions/comfy/music-generation-provider.ts
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
import type {
|
||||
GeneratedMusicAsset,
|
||||
MusicGenerationProvider,
|
||||
MusicGenerationSourceImage,
|
||||
} from "openclaw/plugin-sdk/music-generation";
|
||||
import {
|
||||
DEFAULT_COMFY_MODEL,
|
||||
isComfyCapabilityConfigured,
|
||||
runComfyWorkflow,
|
||||
} from "./workflow-runtime.js";
|
||||
|
||||
const COMFY_MAX_INPUT_IMAGES = 1;
|
||||
|
||||
function toGeneratedTrack(asset: {
|
||||
buffer: Buffer;
|
||||
mimeType: string;
|
||||
fileName: string;
|
||||
}): GeneratedMusicAsset {
|
||||
return {
|
||||
buffer: asset.buffer,
|
||||
mimeType: asset.mimeType,
|
||||
fileName: asset.fileName,
|
||||
};
|
||||
}
|
||||
|
||||
function resolveInputImage(inputImage: MusicGenerationSourceImage | undefined) {
|
||||
if (!inputImage) {
|
||||
return undefined;
|
||||
}
|
||||
if (!inputImage.buffer) {
|
||||
throw new Error("Comfy music generation requires loaded reference image bytes.");
|
||||
}
|
||||
return {
|
||||
buffer: inputImage.buffer,
|
||||
mimeType: inputImage.mimeType ?? "image/png",
|
||||
fileName: inputImage.fileName,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildComfyMusicGenerationProvider(): MusicGenerationProvider {
|
||||
return {
|
||||
id: "comfy",
|
||||
label: "ComfyUI",
|
||||
defaultModel: DEFAULT_COMFY_MODEL,
|
||||
models: [DEFAULT_COMFY_MODEL],
|
||||
isConfigured: ({ cfg, agentDir }) =>
|
||||
isComfyCapabilityConfigured({
|
||||
cfg,
|
||||
agentDir,
|
||||
capability: "music",
|
||||
}),
|
||||
capabilities: {
|
||||
generate: {},
|
||||
edit: {
|
||||
enabled: true,
|
||||
maxInputImages: COMFY_MAX_INPUT_IMAGES,
|
||||
},
|
||||
},
|
||||
async generateMusic(req) {
|
||||
if ((req.inputImages?.length ?? 0) > COMFY_MAX_INPUT_IMAGES) {
|
||||
throw new Error(
|
||||
`Comfy music generation supports at most ${COMFY_MAX_INPUT_IMAGES} reference image.`,
|
||||
);
|
||||
}
|
||||
|
||||
const result = await runComfyWorkflow({
|
||||
cfg: req.cfg,
|
||||
agentDir: req.agentDir,
|
||||
authStore: req.authStore,
|
||||
prompt: req.prompt,
|
||||
model: req.model,
|
||||
capability: "music",
|
||||
outputKinds: ["audio"],
|
||||
inputImage: resolveInputImage(req.inputImages?.[0]),
|
||||
});
|
||||
|
||||
return {
|
||||
tracks: result.assets.map(toGeneratedTrack),
|
||||
model: result.model,
|
||||
metadata: {
|
||||
promptId: result.promptId,
|
||||
outputNodeIds: result.outputNodeIds,
|
||||
inputImageCount: req.inputImages?.length ?? 0,
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue