mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-10 17:16:55 +00:00
refactor(media): remove stale completion wake wrappers
This commit is contained in:
@@ -19,8 +19,8 @@ vi.mock("../subagent-announce-delivery.js", () => announceDeliveryMocks);
|
||||
|
||||
const {
|
||||
createImageGenerationTaskRun,
|
||||
imageGenerationTaskLifecycle,
|
||||
recordImageGenerationTaskProgress,
|
||||
wakeImageGenerationTaskCompletion,
|
||||
} = await import("./image-generate-background.js");
|
||||
|
||||
describe("image generate background helpers", () => {
|
||||
@@ -87,7 +87,7 @@ describe("image generate background helpers", () => {
|
||||
path: "direct",
|
||||
});
|
||||
|
||||
await wakeImageGenerationTaskCompletion({
|
||||
await imageGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...createMediaCompletionFixture({
|
||||
runId: "tool:image_generate:abc",
|
||||
taskLabel: "small watercolor robot",
|
||||
@@ -122,7 +122,7 @@ describe("image generate background helpers", () => {
|
||||
result: "provider failed",
|
||||
});
|
||||
|
||||
await wakeImageGenerationTaskCompletion({
|
||||
await imageGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...completion,
|
||||
status: "error",
|
||||
statusLabel: "failed",
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
*
|
||||
* Binds shared detached media-task lifecycle behavior to image_generate labels and completion messages.
|
||||
*/
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import type { AgentGeneratedAttachment } from "../generated-attachments.js";
|
||||
import { IMAGE_GENERATION_TASK_KIND } from "../image-generation-task-status.js";
|
||||
import {
|
||||
createMediaGenerationTaskLifecycle,
|
||||
@@ -46,17 +44,3 @@ export const completeImageGenerationTaskRun = (
|
||||
export const failImageGenerationTaskRun = (
|
||||
...params: Parameters<typeof imageGenerationTaskLifecycle.failTaskRun>
|
||||
) => imageGenerationTaskLifecycle.failTaskRun(...params);
|
||||
|
||||
/** Wakes the requester session with image generation completion or failure. */
|
||||
export async function wakeImageGenerationTaskCompletion(params: {
|
||||
config?: OpenClawConfig;
|
||||
handle: ImageGenerationTaskHandle | null;
|
||||
status: "ok" | "error";
|
||||
statusLabel: string;
|
||||
result: string;
|
||||
attachments?: AgentGeneratedAttachment[];
|
||||
mediaUrls?: string[];
|
||||
statsLine?: string;
|
||||
}) {
|
||||
return await imageGenerationTaskLifecycle.wakeTaskCompletion(params);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ vi.mock("../subagent-announce-delivery.js", () => announceDeliveryMocks);
|
||||
|
||||
const {
|
||||
createMusicGenerationTaskRun,
|
||||
musicGenerationTaskLifecycle,
|
||||
recordMusicGenerationTaskProgress,
|
||||
wakeMusicGenerationTaskCompletion,
|
||||
} = await import("./music-generate-background.js");
|
||||
|
||||
function getDeliveredInternalEvents(): Array<Record<string, unknown>> {
|
||||
@@ -106,7 +106,7 @@ describe("music generate background helpers", () => {
|
||||
path: "direct",
|
||||
});
|
||||
|
||||
await wakeMusicGenerationTaskCompletion({
|
||||
await musicGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...createMediaCompletionFixture({
|
||||
runId: "tool:music_generate:abc",
|
||||
taskLabel: "night-drive synthwave",
|
||||
@@ -131,7 +131,7 @@ describe("music generate background helpers", () => {
|
||||
mediaUrls: ["/tmp/generated-night-drive.mp3"],
|
||||
});
|
||||
|
||||
await wakeMusicGenerationTaskCompletion({
|
||||
await musicGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...completion,
|
||||
handle: {
|
||||
...completion.handle,
|
||||
@@ -156,7 +156,7 @@ describe("music generate background helpers", () => {
|
||||
result: "provider failed",
|
||||
});
|
||||
|
||||
await wakeMusicGenerationTaskCompletion({
|
||||
await musicGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...completion,
|
||||
status: "error",
|
||||
statusLabel: "failed",
|
||||
@@ -185,7 +185,7 @@ describe("music generate background helpers", () => {
|
||||
mediaUrls: ["/tmp/generated-night-drive.mp3"],
|
||||
});
|
||||
|
||||
await wakeMusicGenerationTaskCompletion({
|
||||
await musicGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...completion,
|
||||
handle: {
|
||||
...completion.handle,
|
||||
@@ -208,7 +208,7 @@ describe("music generate background helpers", () => {
|
||||
path: "direct",
|
||||
});
|
||||
|
||||
await wakeMusicGenerationTaskCompletion({
|
||||
await musicGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...createMediaCompletionFixture({
|
||||
directSend: true,
|
||||
runId: "tool:music_generate:abc",
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
*
|
||||
* Binds shared detached media-task lifecycle behavior to music_generate labels and completion messages.
|
||||
*/
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import type { AgentGeneratedAttachment } from "../generated-attachments.js";
|
||||
import { MUSIC_GENERATION_TASK_KIND } from "../music-generation-task-status.js";
|
||||
import {
|
||||
createMediaGenerationTaskLifecycle,
|
||||
@@ -45,17 +43,3 @@ export const completeMusicGenerationTaskRun = (
|
||||
export const failMusicGenerationTaskRun = (
|
||||
...params: Parameters<typeof musicGenerationTaskLifecycle.failTaskRun>
|
||||
) => musicGenerationTaskLifecycle.failTaskRun(...params);
|
||||
|
||||
/** Wakes the waiting session turn with final music-generation output. */
|
||||
export async function wakeMusicGenerationTaskCompletion(params: {
|
||||
config?: OpenClawConfig;
|
||||
handle: MusicGenerationTaskHandle | null;
|
||||
status: "ok" | "error";
|
||||
statusLabel: string;
|
||||
result: string;
|
||||
attachments?: AgentGeneratedAttachment[];
|
||||
mediaUrls?: string[];
|
||||
statsLine?: string;
|
||||
}) {
|
||||
return await musicGenerationTaskLifecycle.wakeTaskCompletion(params);
|
||||
}
|
||||
|
||||
@@ -58,9 +58,7 @@ const musicGenerateBackgroundMocks = vi.hoisted(() => ({
|
||||
failTaskRun: (
|
||||
params: Parameters<typeof musicGenerateBackground.failMusicGenerationTaskRun>[0],
|
||||
) => musicGenerateBackgroundMocks.failMusicGenerationTaskRun(params),
|
||||
wakeTaskCompletion: (
|
||||
params: Parameters<typeof musicGenerateBackground.wakeMusicGenerationTaskCompletion>[0],
|
||||
) => musicGenerateBackgroundMocks.wakeMusicGenerationTaskCompletion(params),
|
||||
wakeTaskCompletion: vi.fn(),
|
||||
},
|
||||
completeMusicGenerationTaskRun: vi.fn((params) => {
|
||||
if (!params.handle) {
|
||||
@@ -119,7 +117,6 @@ const musicGenerateBackgroundMocks = vi.hoisted(() => ({
|
||||
eventSummary: params.eventSummary,
|
||||
});
|
||||
}),
|
||||
wakeMusicGenerationTaskCompletion: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../../config/config.js", () => configMocks);
|
||||
@@ -179,8 +176,10 @@ function resetMusicGenerateMocks() {
|
||||
taskExecutorMocks.completeTaskRunByRunId.mockReset();
|
||||
taskExecutorMocks.failTaskRunByRunId.mockReset();
|
||||
taskExecutorMocks.recordTaskRunProgressByRunId.mockReset();
|
||||
musicGenerateBackgroundMocks.wakeMusicGenerationTaskCompletion.mockReset();
|
||||
musicGenerateBackgroundMocks.wakeMusicGenerationTaskCompletion.mockResolvedValue(true);
|
||||
musicGenerateBackgroundMocks.musicGenerationTaskLifecycle.wakeTaskCompletion.mockReset();
|
||||
musicGenerateBackgroundMocks.musicGenerationTaskLifecycle.wakeTaskCompletion.mockResolvedValue(
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
function detailsOf(result: { details?: unknown }): Record<string, unknown> {
|
||||
@@ -218,7 +217,9 @@ function taskCompleteCall(callIndex = 0): Record<string, unknown> {
|
||||
|
||||
function wakeCompletionCall(callIndex = 0): Record<string, unknown> {
|
||||
const call =
|
||||
musicGenerateBackgroundMocks.wakeMusicGenerationTaskCompletion.mock.calls[callIndex]?.[0];
|
||||
musicGenerateBackgroundMocks.musicGenerationTaskLifecycle.wakeTaskCompletion.mock.calls[
|
||||
callIndex
|
||||
]?.[0];
|
||||
if (!call || typeof call !== "object") {
|
||||
throw new Error(`expected wake completion call ${callIndex}`);
|
||||
}
|
||||
@@ -558,7 +559,7 @@ describe("createMusicGenerateTool", () => {
|
||||
createdAt: Date.now(),
|
||||
});
|
||||
const wakeSpy = vi
|
||||
.spyOn(musicGenerateBackground, "wakeMusicGenerationTaskCompletion")
|
||||
.spyOn(musicGenerateBackground.musicGenerationTaskLifecycle, "wakeTaskCompletion")
|
||||
.mockResolvedValue(true);
|
||||
vi.spyOn(musicGenerationRuntime, "generateMusic").mockResolvedValue({
|
||||
provider: "google",
|
||||
|
||||
@@ -22,7 +22,7 @@ const {
|
||||
createVideoGenerationTaskRun,
|
||||
failVideoGenerationTaskRun,
|
||||
recordVideoGenerationTaskProgress,
|
||||
wakeVideoGenerationTaskCompletion,
|
||||
videoGenerationTaskLifecycle,
|
||||
} = await import("./video-generate-background.js");
|
||||
const { withMediaGenerationTaskKeepalive } = await import("./media-generate-background-shared.js");
|
||||
|
||||
@@ -165,7 +165,7 @@ describe("video generate background helpers", () => {
|
||||
path: "direct",
|
||||
});
|
||||
|
||||
await wakeVideoGenerationTaskCompletion({
|
||||
await videoGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...createMediaCompletionFixture({
|
||||
runId: "tool:video_generate:abc",
|
||||
taskLabel: "friendly lobster surfing",
|
||||
@@ -184,7 +184,7 @@ describe("video generate background helpers", () => {
|
||||
path: "direct",
|
||||
});
|
||||
|
||||
await wakeVideoGenerationTaskCompletion({
|
||||
await videoGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...createMediaCompletionFixture({
|
||||
directSend: true,
|
||||
runId: "tool:video_generate:abc",
|
||||
@@ -215,7 +215,7 @@ describe("video generate background helpers", () => {
|
||||
error: "completion agent did not deliver generated media",
|
||||
});
|
||||
|
||||
await wakeVideoGenerationTaskCompletion({
|
||||
await videoGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...createMediaCompletionFixture({
|
||||
runId: "tool:video_generate:abc",
|
||||
taskLabel: "friendly lobster surfing",
|
||||
@@ -249,7 +249,7 @@ describe("video generate background helpers", () => {
|
||||
path: "steered",
|
||||
});
|
||||
|
||||
await wakeVideoGenerationTaskCompletion({
|
||||
await videoGenerationTaskLifecycle.wakeTaskCompletion({
|
||||
...createMediaCompletionFixture({
|
||||
runId: "tool:video_generate:abc",
|
||||
taskLabel: "friendly lobster surfing",
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
*
|
||||
* Specializes the shared media background runner with video status text and completion metadata.
|
||||
*/
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import type { AgentGeneratedAttachment } from "../generated-attachments.js";
|
||||
import { VIDEO_GENERATION_TASK_KIND } from "../video-generation-task-status.js";
|
||||
import {
|
||||
createMediaGenerationTaskLifecycle,
|
||||
@@ -45,17 +43,3 @@ export const completeVideoGenerationTaskRun = (
|
||||
export const failVideoGenerationTaskRun = (
|
||||
...params: Parameters<typeof videoGenerationTaskLifecycle.failTaskRun>
|
||||
) => videoGenerationTaskLifecycle.failTaskRun(...params);
|
||||
|
||||
/** Wakes the waiting session turn with final video-generation output. */
|
||||
export async function wakeVideoGenerationTaskCompletion(params: {
|
||||
config?: OpenClawConfig;
|
||||
handle: VideoGenerationTaskHandle | null;
|
||||
status: "ok" | "error";
|
||||
statusLabel: string;
|
||||
result: string;
|
||||
attachments?: AgentGeneratedAttachment[];
|
||||
mediaUrls?: string[];
|
||||
statsLine?: string;
|
||||
}) {
|
||||
return await videoGenerationTaskLifecycle.wakeTaskCompletion(params);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user