import { type VideoProduction } from "./video-production-state.ts"; import { type EntityImageExpectation } from "./entity-image-state.ts"; import { type EntityImageSlotRole } from "./entity-image-slots.ts"; import { type StudioVideoUnit, type VideoUnitInput, type VideoUnitOutlineInput, type VideoUnitPatch, type VideoUnitStatus, type VideoUnitImageStatus, type VideoUnitValidationOptions } from "./studio-video-units.ts"; import type { VideoUnitImageTarget } from "./studio-video-unit-image-plan.ts"; export declare const CROCO_WORKSPACE_SCHEMA_VERSION = 9; export declare const CROCO_STATE_RELATIVE_PATH: string; export declare const CROCO_DIRECTOR_SCRIPT_FILENAME = "SCRIPT.md"; export type EntityType = "character" | "scene" | "prop"; export type ImageRole = "current" | "reference" | "other"; export type WorkflowStage = "intake" | "story-crafting" | "analyzing" | "ready" | "error"; export interface ProjectMeta { title: string; synopsis: string; genre: string; theme: string; worldSetting: string; language: string; audience: string; aspectRatio: string; targetDuration: string; } export interface ProjectStyle { id: string; name: string; nameZh: string; description: string; imagePrompt: string; videoPrompt: string; sampleImage: string; source: "library" | "reference" | "inferred" | "user"; libraryStyleId?: string; } export interface EntityImage { id: string; relativePath: string; role: ImageRole; source: "generated" | "imported" | "library"; model?: string; prompt?: string; createdAt: string; } export interface EntityReferenceAudio { relativePath: string; source: "generated" | "imported" | "library"; model?: string; voiceDescription?: string; durationSeconds?: number; createdAt: string; } export interface CharacterBinding { characterId: string; characterName: string; referenceImageKeys: string[]; } export interface ProjectEntity { id: string; type: EntityType; name: string; description: string; prompt: string; status: "draft" | "ready" | "needs-update" | "generating"; voiceDescription?: string; voiceStatus?: "missing" | "generating" | "ready" | "error"; referenceAudio?: EntityReferenceAudio; /** Completed voice outputs, including previous reference voices. */ voiceVersions?: EntityReferenceAudio[]; binding?: CharacterBinding; images: EntityImage[]; /** A version can be displayed as both the main image and the explicit reference. */ referenceImageId?: string; /** Explicitly empty slots never fall back to older project or library images. */ clearedImageSlots?: EntityImageSlotRole[]; } export interface SourceRecord { relativePath: string; originalPath: string; kind: "document" | "reference"; } export interface UploadedSource { name: string; dataBase64: string; } export interface CrocoProjectState { schemaVersion: number; projectId: string; revision: number; createdAt: string; updatedAt: string; brief: string; workflowStage: WorkflowStage; workflowMessage: string; sourceTextPath: string; sources: SourceRecord[]; meta: ProjectMeta; style: ProjectStyle | null; entities: ProjectEntity[]; videoUnitStatus: VideoUnitStatus; videoUnitMessage: string; videoUnits: StudioVideoUnit[]; videoUnitsStale: boolean; videoUnitSourceRevision?: number; videoGeneration?: VideoProduction; } export interface CrocoProjectSnapshot extends CrocoProjectState { projectFolder: string; } export declare function resolveProjectPath(projectFolder: string, relativePath: string): string; /** Hold the project mutation lock while a versioned native media edit reads Unit planning. */ export declare function withProjectRevision(projectFolder: string, expectedRevision: number, operation: (state: CrocoProjectState) => Promise): Promise; export declare function prepareProjectFolder(projectFolder: string): Promise; export declare function initializeCrocoProject(input: { projectFolder: string; brief: string; sourcePaths?: readonly string[]; uploadedSources?: readonly UploadedSource[]; maxSourceChars: number; maxUploadBytes?: number; signal?: AbortSignal; }): Promise<{ state: CrocoProjectSnapshot; sourceText: string; }>; export declare function loadCrocoProject(projectFolder: string): Promise; /** Serialize video job updates with every other project write; callbacks retain unrelated fields. */ export declare function mutateVideoProduction(projectFolder: string, expectedRevision: number | undefined, update: (production: VideoProduction, state: CrocoProjectState) => void | Promise, rollback?: () => Promise): Promise; export declare function readCrocoProject(projectFolder: string, includeSourceText?: boolean): Promise<{ state: CrocoProjectSnapshot; sourceText?: string; }>; export declare function patchProjectMeta(projectFolder: string, patch: Partial, expectedRevision?: number): Promise; export declare function setProjectWorkflow(projectFolder: string, workflowStage: WorkflowStage, workflowMessage: string, expectedRevision?: number): Promise; /** Stop listing a Raw File in the project without deleting its on-disk copy. */ export declare function untrackProjectSource(projectFolder: string, relativePath: string, expectedRevision?: number): Promise; export declare function setProjectStory(projectFolder: string, story: string, expectedRevision?: number): Promise; /** Persist the fixed new-video intake choices before Studio preview starts. * @param projectFolder - Absolute Croco Project Folder. * @param selections - Confirmed aspect ratio and optional enabled library style snapshot. * @param expectedRevision - Project revision that the caller read before writing. * @returns The latest project snapshot. */ export declare function setProjectIntakeSelections(projectFolder: string, selections: { aspectRatio: "16:9" | "9:16"; style?: ProjectStyle; }, expectedRevision?: number): Promise; export declare function setProjectStyle(projectFolder: string, style: ProjectStyle | null, expectedRevision?: number): Promise; export declare function upsertProjectEntities(projectFolder: string, entities: Array & { images?: EntityImage[]; }>, options?: { replaceType?: EntityType; expectedRevision?: number; }): Promise; /** Set the Agent-owned Video Unit processing status without replacing its last valid plan. */ export declare function setProjectVideoUnitStatus(projectFolder: string, status: VideoUnitStatus, message: string, expectedRevision?: number): Promise; /** Replace the complete Video Unit plan after deterministic duration, source, and reference validation. */ export declare function setProjectVideoUnits(projectFolder: string, inputs: readonly VideoUnitInput[], options: VideoUnitValidationOptions & { expectedRevision?: number; preserveImages?: boolean; }): Promise; /** Save ten source-linked manuscripts immediately, before authoring their picture prompts. */ export declare function setProjectVideoUnitOutlines(projectFolder: string, outlines: readonly VideoUnitOutlineInput[], options: VideoUnitValidationOptions & { expectedRevision: number; }): Promise; /** Update one planned Unit and revalidate the complete linked timeline. */ export declare function patchProjectVideoUnit(projectFolder: string, unitId: string, patch: VideoUnitPatch, options: VideoUnitValidationOptions & { expectedRevision: number; }): Promise; export interface VideoUnitImageWriteResult { expectedContextFingerprint?: string; expectedAttemptId?: string; target: VideoUnitImageTarget; status: "ready" | "error"; sourcePath?: string; model?: string; prompt?: string; inputFingerprint?: string; message?: string; } /** Persist one status transition for every selected Storyboard or keyframe target. */ export declare function setProjectVideoUnitImageStatuses(projectFolder: string, targets: readonly VideoUnitImageTarget[], status: VideoUnitImageStatus, message: string, expectedRevision?: number): Promise; /** Save successful images and per-target failures in one revision. */ export declare function setProjectVideoUnitImageResults(projectFolder: string, results: readonly VideoUnitImageWriteResult[], expectedRevision?: number): Promise; export declare function patchProjectEntity(projectFolder: string, entityId: string, patch: Partial>, expectedRevision?: number): Promise; /** * Delete one entity and its project-owned media without touching the character library. * @param projectFolder - Absolute Project Folder. * @param entityId - Entity selected from the current project. * @param expectedRevision - Revision confirmed by the caller. * @returns The project snapshot after removing the entity and its Unit references. */ export declare function deleteProjectEntity(projectFolder: string, entityId: string, expectedRevision: number): Promise; /** Update the reference-voice state for one character batch in one project revision. */ export declare function setProjectEntityVoiceStatuses(projectFolder: string, entityIds: readonly string[], voiceStatus: NonNullable, expectedRevision?: number): Promise; /** Copy a generated voice sample into the character project folder and make it the H3 reference voice. */ export declare function addEntityReferenceAudio(input: { projectFolder: string; entityId: string; sourcePath: string; source: EntityReferenceAudio["source"]; model?: string; voiceDescription?: string; durationSeconds?: number; expectedRevision?: number; }): Promise<{ state: CrocoProjectSnapshot; audio: EntityReferenceAudio; absolutePath: string; }>; /** Select a saved voice without generating or judging its content. */ export declare function selectEntityVoiceVersion(projectFolder: string, entityId: string, relativePath: string, expectedRevision: number): Promise; /** Reserve unchanged image targets without conflicting with other cards' revisions. */ export declare function beginEntityImages(projectFolder: string, targets: EntityImageExpectation[]): Promise; /** Clear a failed attempt only while its target still has the planned image state. */ export declare function failEntityImage(projectFolder: string, target: EntityImageExpectation): Promise; /** Update one image batch's entity statuses in a single project revision. */ export declare function setProjectEntityStatuses(projectFolder: string, entityIds: readonly string[], status: ProjectEntity["status"], expectedRevision?: number): Promise; export declare function setCharacterBinding(projectFolder: string, entityId: string, binding: CharacterBinding | null, expectedRevision?: number): Promise; interface AddEntityImageInput { projectFolder: string; entityId: string; role: ImageRole; source: EntityImage["source"]; model?: string; prompt?: string; expectedRevision?: number; expectedImageState?: string; } /** Persist an entity image; replaced main images remain as other images, preserving reference slots. */ export declare function addEntityImage(input: AddEntityImageInput & { projectFolder: string; entityId: string; sourcePath: string; }): Promise<{ state: CrocoProjectSnapshot; image: EntityImage; absolutePath: string; binding?: CharacterBinding; }>; /** Uploads a browser image directly into one visible Acreel-style card slot. */ export declare function addUploadedEntityImage(input: AddEntityImageInput & { upload: UploadedSource; maxUploadBytes: number; }): Promise<{ state: CrocoProjectSnapshot; image: EntityImage; absolutePath: string; binding?: CharacterBinding; }>; /** Adopt a retained main-image candidate without changing the reference slot. */ export declare function selectEntityImageVersion(projectFolder: string, entityId: string, imageId: string, expectedRevision: number): Promise; /** Adopt one successful picture owned by this Unit target; preserve its planning text. */ export declare function selectVideoUnitImageVersion(projectFolder: string, target: VideoUnitImageTarget, versionId: string, expectedRevision: number): Promise; export declare function setEntityImageRole(projectFolder: string, entityId: string, imageId: string, role: ImageRole, expectedRevision?: number): Promise; /** Moves the visible character image between Acreel's single main and reference slots. */ export declare function moveEntityImageSlot(projectFolder: string, entityId: string, direction: "main-to-reference" | "reference-to-main", imageId: string | undefined, expectedRevision?: number): Promise; /** Remove one visible image association, preserving files, bindings and other slots. */ export declare function removeEntityImageSlot(input: { projectFolder: string; expectedRevision: number; entityId: string; role: EntityImageSlotRole; source: "project" | "library"; imageId: string; }): Promise; export declare function entityOutputDirectory(projectFolder: string, entity: Pick): string; export declare function projectMediaPath(projectFolder: string, relativePath: string): string; export {};