import { request } from '../../lib/http' import type { GenerationOptions } from '../generation-config/types' import type { WorkflowExecutionStart } from '../workflows/execution.types' /** 人工确认的相对眼位;只提交用户选择,不能从画面区域猜测。 */ export interface RelativeGazeGeometry { subjectRef: string targetDescription: string horizontal: 'left' | 'right' | 'center' | 'unknown' vertical: 'above' | 'below' | 'level' | 'unknown' targetFocusRegion?: 'upper' | 'center' | 'lower' | 'whole' gazeAlignmentStrategy?: 'eyes_only' | 'head_assisted' | 'upper_body_assisted' source: 'manual' } /** 本次首帧编辑参数,不修改项目默认配置。 */ export interface KeyframeEditInput { editInstruction: string editMode: 'subject_only' | 'composition_assisted' allowBackgroundDeemphasis?: boolean relativeGazeGeometry?: RelativeGazeGeometry[] provider?: string generationOptions?: GenerationOptions } /** 后端编译的真实编辑输入。 */ export interface KeyframeEditPreview { shotId: string sourceKeyframeId: string provider: string model: string editInstruction: string editMode: KeyframeEditInput['editMode'] sourceImageSlots: number maxInputImages: number | null selected: Array<{ subjectRef: string; role: string; imageId: string }> omitted: Array<{ subjectRef: string; role: string; imageId: string }> } /** 预览和后台编辑使用完全相同的业务参数。 */ export const keyframeEditApi = { /** * 只读编译实际编辑指令和参考图名额。 * @param shotId 正式镜头 ID * @param sourceId 当前镜头有效源图 ID * @param input 本次人工确认的编辑参数 * @param signal 查询取消信号 * @returns 实际模型输入 */ preview: (shotId: string, sourceId: string, input: KeyframeEditInput, signal?: AbortSignal) => request( `/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(sourceId)}/edit/preview`, { method: 'POST', body: input, signal, timeoutMs: 0 } ), /** * 启动持久化编辑任务,结果由后台真实终态确认。 * @param shotId 正式镜头 ID * @param sourceId 已核对的编辑源图 ID * @param input 已预览并确认费用的参数 * @returns 后台首帧质量任务观察句柄 */ start: (shotId: string, sourceId: string, input: KeyframeEditInput) => request( `/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(sourceId)}/edit`, { method: 'POST', body: input, timeoutMs: 0 } ) }