Your Name 20898e1ac1
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
feat(video-agent): add ruxa nine-grid storyboard skill pipeline
2026-03-05 14:48:24 +08:00

153 lines
3.1 KiB
TypeScript

import type { VideoStoryboardConfig } from "@/lib/video-agent/config";
export type NormalizedStoryboardShot = {
index: number;
durationSec: number;
action: string;
camera: string;
mood: string;
negativePrompt: string;
};
export type NormalizedStoryboardScript = {
language: "zh" | "en" | "mixed";
globalStyle: string;
shots: NormalizedStoryboardShot[];
raw: string;
};
export type NineGridCropBox = {
index: number;
x: number;
y: number;
w: number;
h: number;
};
export type NineGridTile = {
index: number;
imageUrl: string;
width: number;
height: number;
};
export type NineGridDetectionResult = {
isNineGrid: boolean;
confidence: number;
qualityScore: number;
cropBoxes: NineGridCropBox[];
width: number;
height: number;
sourceImageUrl: string;
tiles: NineGridTile[];
};
export type MappedStoryboardShot = {
shotIndex: number;
tileIndex: number;
tileImageUrl: string;
durationSec: number;
prompt: string;
negativePrompt: string;
action: string;
camera: string;
mood: string;
};
export type PreparedStoryboardShot = MappedStoryboardShot & {
inputImageUrl: string;
upscaled: boolean;
upscaleReason?: string;
};
export type StoryboardModelCandidate = {
id: string;
modelId: string;
displayName?: string;
};
export type StoryboardProgressEvent =
| {
stage: "detecting";
provider: string;
message?: string;
}
| {
stage: "start";
provider: string;
taskId: string;
totalShots: number;
confidence: number;
sourceImageUrl: string;
shots: Array<{
shotIndex: number;
tileImageUrl: string;
prompt: string;
}>;
}
| {
stage: "shot_retry";
provider: string;
taskId: string;
shotIndex: number;
attempt: number;
modelId: string;
error: string;
}
| {
stage: "shot_completed";
provider: string;
taskId: string;
shotIndex: number;
modelId: string;
videoUrl: string;
text: string;
}
| {
stage: "shot_failed";
provider: string;
taskId: string;
shotIndex: number;
error: string;
}
| {
stage: "completed";
provider: string;
taskId: string;
totalShots: number;
successCount: number;
failedCount: number;
}
| {
stage: "failed";
provider: string;
taskId: string;
error: string;
};
export type RuxaNineGridPipelineParams = {
modelMessages: Array<{ role: string; content: any }>;
selectedModelId: string;
selectedModelRef: string;
modelCandidates: StoryboardModelCandidate[];
videoParams?: Record<string, any>;
config: VideoStoryboardConfig;
onProgress?: (event: StoryboardProgressEvent) => void;
doGenerate: (input: {
messages: Array<{ role: string; content: any }>;
videoParams?: Record<string, any>;
overrideModelId?: string;
}) => Promise<{ text?: string }>;
};
export type RuxaNineGridPipelineResult = {
triggered: boolean;
taskId?: string;
confidence?: number;
markdown?: string;
videoUrls?: string[];
modelRefs?: string[];
metadata?: Record<string, any>;
reason?: string;
};