207 lines
4.4 KiB
TypeScript
207 lines
4.4 KiB
TypeScript
import type { VideoStoryboardConfig } from "@/lib/video-agent/config";
|
|
|
|
export type StoryboardGridType = "grid_2x2" | "grid_3x2" | "grid_3x3";
|
|
|
|
export type NormalizedStoryboardShot = {
|
|
index: number;
|
|
durationSec: number;
|
|
action: string;
|
|
camera: string;
|
|
mood: string;
|
|
negativePrompt: string;
|
|
preferredTileIndex?: number;
|
|
};
|
|
|
|
export type NormalizedStoryboardScript = {
|
|
language: "zh" | "en" | "mixed";
|
|
globalStyle: string;
|
|
shotCount: number;
|
|
shots: NormalizedStoryboardShot[];
|
|
raw: string;
|
|
};
|
|
|
|
export type StoryboardCropBox = {
|
|
index: number;
|
|
row: number;
|
|
col: number;
|
|
x: number;
|
|
y: number;
|
|
w: number;
|
|
h: number;
|
|
};
|
|
|
|
export type StoryboardTile = {
|
|
index: number;
|
|
row: number;
|
|
col: number;
|
|
imageUrl: string;
|
|
width: number;
|
|
height: number;
|
|
};
|
|
|
|
export type StoryboardDetectionResult = {
|
|
isStoryboardGrid: boolean;
|
|
isNineGrid: boolean;
|
|
gridType: StoryboardGridType | null;
|
|
rows: number;
|
|
cols: number;
|
|
shotCount: number;
|
|
confidence: number;
|
|
qualityScore: number;
|
|
cropBoxes: StoryboardCropBox[];
|
|
width: number;
|
|
height: number;
|
|
sourceImageUrl: string;
|
|
tiles: StoryboardTile[];
|
|
};
|
|
|
|
export type NineGridCropBox = StoryboardCropBox;
|
|
export type NineGridTile = StoryboardTile;
|
|
export type NineGridDetectionResult = StoryboardDetectionResult;
|
|
|
|
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;
|
|
gridType?: StoryboardGridType;
|
|
rows?: number;
|
|
cols?: number;
|
|
confidence: number;
|
|
sourceImageUrl: string;
|
|
shots: Array<{
|
|
shotIndex: number;
|
|
tileImageUrl: string;
|
|
prompt: string;
|
|
}>;
|
|
}
|
|
| {
|
|
stage: "hd_shot_completed";
|
|
provider: string;
|
|
taskId: string;
|
|
shotIndex: number;
|
|
imageUrl: string;
|
|
prompt: string;
|
|
}
|
|
| {
|
|
stage: "hd_shot_failed";
|
|
provider: string;
|
|
taskId: string;
|
|
shotIndex: number;
|
|
error: string;
|
|
}
|
|
| {
|
|
stage: "awaiting_confirmation";
|
|
provider: string;
|
|
taskId: string;
|
|
totalShots: number;
|
|
gridType?: StoryboardGridType;
|
|
rows?: number;
|
|
cols?: number;
|
|
message: string;
|
|
shots: Array<{
|
|
shotIndex: number;
|
|
tileImageUrl: string;
|
|
previewImageUrl: 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 = {
|
|
userId: string;
|
|
chatId: string;
|
|
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[];
|
|
previewImageUrls?: string[];
|
|
modelRefs?: string[];
|
|
metadata?: Record<string, any>;
|
|
reason?: string;
|
|
};
|