Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

feat: add complete stickman video workflow

wulien-center5dad6df6238e
diff --git a/apps/daemon/package.json b/apps/daemon/package.json
index 55c50ff1..1a5fa303 100644
--- a/apps/daemon/package.json
+++ b/apps/daemon/package.json
@@ -2,6 +2,10 @@
"name": "@opencreator/daemon",
"version": "0.1.0",
"type": "module",
+ "files": [
+ "dist",
+ "runtime"
+ ],
"scripts": {
"predev": "pnpm --filter @opencreator/protocol build && pnpm --filter @opencreator/config build && pnpm --filter @opencreator/skill-market build && pnpm --filter @opencreator/writing-templates build",
"dev": "node scripts/dev.mjs",
@@ -22,6 +26,7 @@
"@opencreator/protocol": "workspace:*",
"@opencreator/skill-market": "workspace:*",
"@opencreator/writing-templates": "workspace:*",
+ "@remotion/renderer": "4.0.473",
"better-sqlite3": "^12.11.1",
"cheerio": "1.1.2",
"cron-parser": "^5.6.1",
@@ -32,13 +37,18 @@
"nanoid": "^5.0.9",
"pdf-parse": "1.1.1",
"pdfkit": "^0.20.2",
+ "sharp": "0.34.3",
+ "toml": "^3.0.0",
"yaml": "^2.8.1",
+ "yauzl": "3.4.0",
"zod": "^3.25.76"
},
"devDependencies": {
+ "@remotion/bundler": "4.0.473",
"@types/better-sqlite3": "^7.6.13",
"@types/cross-spawn": "^6.0.6",
"@types/pdf-parse": "1.1.5",
- "@types/pdfkit": "^0.17.6"
+ "@types/pdfkit": "^0.17.6",
+ "@types/yauzl": "3.4.0"
}
}
diff --git a/apps/daemon/src/api/routes.creator.ts b/apps/daemon/src/api/routes.creator.ts
index d4e2ad65..ae8493fe 100644
--- a/apps/daemon/src/api/routes.creator.ts
+++ b/apps/daemon/src/api/routes.creator.ts
@@ -13,6 +13,7 @@ import type {
CreatorStageRun,
RuntimeErrorCode
} from '@opencreator/protocol';
+import { readCreatorResultSnapshots } from '@opencreator/protocol';
import { createHash } from 'node:crypto';
import { createReadStream } from 'node:fs';
import { rm, stat } from 'node:fs/promises';
@@ -44,6 +45,11 @@ import {
VideoTranslationWorkflowError,
type VideoTranslationWorkflow
} from '../creator/templates/video-translation-actions.js';
+import type { StickmanVideoWorkflow } from '../creator/templates/stickman-video-actions.js';
+import {
+ StickmanVisualAssetError,
+ type StickmanVisualAssetRegistry
+} from '../creator/stickman/visual-assets.js';
import type { CreatorProjectCoverService } from '../creator/project-cover.js';
import type { CreatorStageRunner } from '../creator/stage-runner.js';
import {
@@ -75,6 +81,8 @@ export async function registerCreatorRoutes(
agentService?: CreatorAgentService;
coverWorkflow?: CoverWorkflow;
videoTranslationWorkflow?: VideoTranslationWorkflow;
+ stickmanVideoWorkflow?: StickmanVideoWorkflow;
+ stickmanVisualAssets?: StickmanVisualAssetRegistry;
projectCoverService?: CreatorProjectCoverService;
referenceImageUploadService?: CreatorReferenceImageUploadService;
sourceUploadService?: CreatorSourceUploadService;
@@ -82,9 +90,56 @@ export async function registerCreatorRoutes(
artifactImportService?: CreatorArtifactImportService;
jobsRoot: string;
dispatcher: CreatorCommandDispatcher;
- stageRunner?: Pick<CreatorStageRunner, 'cancel'>;
+ stageRunner?: Pick<CreatorStageRunner, 'cancel' | 'cancelJob'>;
}
): Promise<void> {
+ if (options.stickmanVisualAssets !== undefined) {
+ server.get('/creator/visual-assets', async (request, reply) => {
+ try {
+ const query = readObject(request.query);
+ const templateId = readString(query.templateId, 'templateId');
+ if (templateId !== 'stickman-video') {
+ return reply.code(404).send(apiError(
+ 'creator_artifact_not_found',
+ 'Creator visual asset catalog was not found'
+ ));
+ }
+ const kind = query.kind === undefined ? undefined : readString(query.kind, 'kind');
+ if (kind !== undefined && kind !== 'character' && kind !== 'style') {
+ throw new TypeError('kind must be character or style');
+ }
+ return options.stickmanVisualAssets!.list(kind);
+ } catch (error) {
+ return sendCreatorError(reply, error);
+ }
+ });
+ server.get(
+ '/creator/visual-assets/:id/revisions/:revision/preview',
+ async (request, reply) => {
+ try {
+ const { id, revision } = request.params as { id: string; revision: string };
+ const preview = options.stickmanVisualAssets!.preview({
+ assetId: id,
+ revision: readQueryInteger(revision, 'revision')
+ });
+ if (preview === undefined) {
+ return reply.code(404).send(apiError(
+ 'creator_artifact_not_found',
+ 'Creator visual asset preview was not found'
+ ));
+ }
+ return reply
+ .type(preview.mimeType)
+ .header('Cache-Control', 'private, max-age=86400, immutable')
+ .header('Content-Disposition', 'inline')
+ .send(preview.stream);
+ } catch (error) {
+ return sendCreatorError(reply, error);
+ }
+ }
+ );
+ }
+
if (options.sourceUploadService !== undefined) {
server.addContentTypeParser(
CREATOR_SOURCE_UPLOAD_CONTENT_TYPE,
@@ -357,10 +412,10 @@ export async function registerCreatorRoutes(
);
}
const job = requireCreatorJob(service, id);
- const activeStage = latestStageMatching(job, stage => (
+ const activeStages = job.stages.filter(stage => (
stage.status === 'queued' || stage.status === 'running'
));
- if (activeStage === undefined) {
+ if (activeStages.length === 0) {
const latest = job.stages.at(-1);
if (latest?.status === 'canceled') {
return {
@@ -374,7 +429,8 @@ export async function registerCreatorRoutes(
'Creator job has no active stage'
);
}
- const stage = options.stageRunner.cancel(activeStage.id);
+ const stages = options.stageRunner.cancelJob(id);
+ const stage = stages.at(-1);
if (stage === undefined) {
throw new CreatorServiceError(
'creator_job_not_running',
@@ -386,6 +442,7 @@ export async function registerCreatorRoutes(
return reply.code(canceling ? 202 : 200).send({
job: latestJob,
stage,
+ stages,
control: canceling ? 'canceling' : 'canceled'
});
} catch (error) {
@@ -435,6 +492,15 @@ export async function registerCreatorRoutes(
}
job = requireCreatorJob(service, id);
}
+ if (job.templateId === 'stickman-video' && options.stickmanVideoWorkflow !== undefined) {
+ try {
+ await options.stickmanVideoWorkflow.validateResume(job, latest);
+ } catch (error) {
+ publishSnapshotIfChanged(events, service, job);
+ throw error;
+ }
+ job = requireCreatorJob(service, id);
+ }
const target = job.stages.at(-1);
if (target?.id !== latest.id || (target.status !== 'canceled' && target.status !== 'interrupted')) {
throw new CreatorServiceError(
@@ -448,10 +514,6 @@ export async function registerCreatorRoutes(
idempotencyKey: `resume:${target.id}`,
input: {
stageId: target.stageId,
- ...(target.progress.workflow === true ? { workflow: true } : {}),
- ...(typeof target.progress.workflowParentStageRunId === 'string'
- ? { workflowParentStageRunId: target.progress.workflowParentStageRunId }
- : {}),
...(typeof target.progress.baseResultVersion === 'number'
? { baseResultVersion: target.progress.baseResultVersion }
: {}),
@@ -469,7 +531,14 @@ export async function registerCreatorRoutes(
: {}),
resumedFromStageRunId: target.id
}
- }, 'user');
+ }, 'user', {
+ scopeKey: target.scopeKey,
+ inputFingerprint: target.inputFingerprint,
+ resumedFromStageRunId: target.id,
+ ...(typeof target.progress.workflowParentStageRunId === 'string'
+ ? { parentStageRunId: target.progress.workflowParentStageRunId }
+ : {})
+ });
const resumedJob = requireCreatorJob(service, id);
const resumedStage = result.commandReceipt.stageRunId === null
? undefined
@@ -514,7 +583,14 @@ export async function registerCreatorRoutes(
return reply.code(404).send(apiError('creator_job_not_found', 'Creator job not found'));
}
const artifact = job.artifacts.find(candidate => candidate.id === artifactId);
- if (artifact?.path === null || artifact === undefined || artifact.status === 'stale') {
+ const referencedBySnapshot = artifact === undefined ? false : readCreatorResultSnapshots(
+ job.state.resultSnapshots
+ ).some(snapshot => Object.values(snapshot.artifactRefs).flat().includes(artifact.id));
+ if (
+ artifact?.path === null
+ || artifact === undefined
+ || (artifact.status === 'stale' && !referencedBySnapshot)
+ ) {
return reply.code(404).send(apiError('creator_artifact_not_found', 'Creator artifact not found'));
}
try {
@@ -545,7 +621,7 @@ export async function registerCreatorRoutes(
throw new CreatorServiceError('creator_job_not_found', 'Creator job not found');
}
if (
- action === 'run-stage'
+ (action === 'run-stage' || action === 'retry-stage')
&& jobBeforeAction.templateId === 'video-translation'
&& options.videoTranslationWorkflow !== undefined
) {
@@ -567,7 +643,7 @@ export async function registerCreatorRoutes(
}
}
if (
- action === 'run-stage'
+ (action === 'run-stage' || action === 'retry-stage')
&& jobBeforeAction.templateId === 'cover'
&& options.coverWorkflow !== undefined
) {
@@ -588,6 +664,23 @@ export async function registerCreatorRoutes(
throw error;
}
}
+ if (
+ (action === 'run-stage' || action === 'retry-stage')
+ && jobBeforeAction.templateId === 'stickman-video'
+ && options.stickmanVideoWorkflow !== undefined
+ ) {
+ const stageId = readString(actionInput.stageId, 'stageId');
+ try {
+ await options.stickmanVideoWorkflow.validateStage(
+ jobBeforeAction,
+ stageId,
+ typeof actionInput.scopeKey === 'string' ? actionInput.scopeKey : null
+ );
+ } catch (error) {
+ publishSnapshotIfChanged(events, service, jobBeforeAction);
+ throw error;
+ }
+ }
const expectedRevision = readInteger(body.expectedRevision, 'expectedRevision');
const result = options.dispatcher.dispatch(id, {
idempotencyKey: typeof body.idempotencyKey === 'string'
@@ -597,6 +690,14 @@ export async function registerCreatorRoutes(
expectedRevision,
input: actionInput
}, 'user');
+ if (
+ options.stickmanVideoWorkflow !== undefined
+ && jobBeforeAction.templateId === 'stickman-video'
+ && action === 'retry-stage'
+ ) {
+ await options.stickmanVideoWorkflow.reconcile(result.job);
+ return { ...result, job: service.getJob(id) ?? result.job };
+ }
if (
options.videoTranslationWorkflow !== undefined
&& shouldReconcileVideoTranslation(jobBeforeAction, result.job)
@@ -902,6 +1003,10 @@ function readCreatorAgentSandbox(
}
function sendCreatorError(reply: FastifyReply, error: unknown) {
+ if (error instanceof StickmanVisualAssetError) {
+ const status = error.code.endsWith('_not_found') ? 404 : 422;
+ return reply.code(status).send(apiError(error.code as RuntimeErrorCode, error.message));
+ }
if (error instanceof CreatorArtifactImportError) {
return reply.code(error.statusCode)
.send(apiError(error.code, error.message));
diff --git a/apps/daemon/src/api/server.ts b/apps/daemon/src/api/server.ts
index 0afba7e2..0176c51f 100644
--- a/apps/daemon/src/api/server.ts
+++ b/apps/daemon/src/api/server.ts
@@ -2,7 +2,7 @@ import type Database from 'better-sqlite3';
import type { CodexAvailabilityProbe, CodexRuntimeComponentReadiness } from '@opencreator/protocol';
import cors from '@fastify/cors';
import Fastify from 'fastify';
-import { readFileSync } from 'node:fs';
+import { existsSync, readFileSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import {
@@ -56,13 +56,27 @@ import {
} from '../creator/image/executor.js';
import { createVideoExecutor } from '../creator/video/executor.js';
import { createClipExecutor } from '../creator/clip/executor.js';
-import { createStickmanExecutor } from '../creator/stickman/executor.js';
import { createSmartDubbingExecutor } from '../creator/smart-dubbing/executor.js';
import { createXiaohongshuPostExecutor } from '../creator/xiaohongshu/executor.js';
import { createWechatArticleExecutor } from '../creator/article/executor.js';
import { createArticleImageGenerator } from '../creator/article/image-generator.js';
import { createArticleSourceExtractor } from '../creator/article/source-extractor.js';
import { createWechatArticleModel } from '../creator/article/model.js';
+import {
+ migrateStickmanVisualAssetState,
+ purgeLegacyStickmanJobs
+} from '../creator/stickman/legacy-migration.js';
+import { createStickmanContentExecutor } from '../creator/stickman/content-executor.js';
+import { createStickmanCodexJsonCompletion } from '../creator/stickman/codex-json-completion.js';
+import { createStickmanAudioExecutor } from '../creator/stickman/audio-executor.js';
+import { createStickmanImageExecutor } from '../creator/stickman/image-executor.js';
+import { createStickmanVisualAssetRegistry } from '../creator/stickman/visual-assets.js';
+import { createStickmanValidationExecutor } from '../creator/stickman/validation-executor.js';
+import { createStickmanTimelineExecutor } from '../creator/stickman/timeline-executor.js';
+import { createStickmanRemotionExecutor } from '../creator/stickman/remotion-executor.js';
+import { createStickmanMediaValidationExecutor } from '../creator/stickman/media-validation-executor.js';
+import { createStickmanDeliveryExecutor } from '../creator/stickman/delivery-executor.js';
+import { CreatorProviderRequestLedger } from '../creator/provider-requests.js';
import { createCreatorProjectCoverService } from '../creator/project-cover.js';
import { createVideoGenerationService } from '../video-generation/service.js';
import {
@@ -87,6 +101,10 @@ import {
createVideoTranslationWorkflow,
type VideoTranslationWorkflow
} from '../creator/templates/video-translation-actions.js';
+import {
+ createStickmanVideoWorkflow,
+ type StickmanVideoWorkflow
+} from '../creator/templates/stickman-video-actions.js';
import {
registerCreatorMcpRoute,
registerAgentScheduleMcpRoute
@@ -350,12 +368,16 @@ export async function buildServer(input: BuildServerInput) {
| undefined;
let appServerRuntimeManager: AppServerRuntimeManager | undefined;
let creatorAppServerRuntimeManager: AppServerRuntimeManager | undefined;
+ const stickmanContentRuntimeManager = input.creatorExecutors === undefined
+ ? createAppServerRuntimeManager({ codexBin, codexHome })
+ : undefined;
const invalidatePersistentRuntime = (reason: string): Promise<void> => {
const work = Promise.all([
appServerRuntimeManager?.invalidate(reason)
?? persistentAppServerExecutor?.invalidate(reason)
?? Promise.resolve(),
- creatorAppServerRuntimeManager?.invalidate(reason) ?? Promise.resolve()
+ creatorAppServerRuntimeManager?.invalidate(reason) ?? Promise.resolve(),
+ stickmanContentRuntimeManager?.invalidate(reason) ?? Promise.resolve()
]).then(() => undefined);
void work.catch(error => {
console.warn(
@@ -410,7 +432,11 @@ export async function buildServer(input: BuildServerInput) {
}
});
const creatorEvents = createCreatorEventHub();
+ const creatorJobsRoot = join(creatorDir, 'jobs');
+ await purgeLegacyStickmanJobs({ db, jobsRoot: creatorJobsRoot });
+ migrateStickmanVisualAssetState({ db });
const creatorRepository = createCreatorRepository(db);
+ const creatorProviderRequestLedger = new CreatorProviderRequestLedger(creatorRepository);
const creatorAgentRepository = createCreatorAgentRepository(db);
const creatorAgentReconciler = createCreatorAgentReconciler({
repository: creatorAgentRepository
@@ -418,7 +444,8 @@ export async function buildServer(input: BuildServerInput) {
creatorAgentReconciler.reconcileAfterDaemonRestart();
const creatorService = input.creatorService ?? createCreatorService({
repository: creatorRepository,
- templates: createDefaultCreatorTemplateRegistry()
+ templates: createDefaultCreatorTemplateRegistry(),
+ providerRequestLedger: creatorProviderRequestLedger
});
const agentCapabilityTokens =
input.agentCapabilityTokens ?? createAgentCapabilityTokenStore();
@@ -500,7 +527,6 @@ export async function buildServer(input: BuildServerInput) {
);
const creatorRuntimeRoot = process.env.OPENCREATOR_CREATOR_RUNTIME_ROOT
?? join(runtimeDir, 'krillinai');
- const creatorJobsRoot = join(creatorDir, 'jobs');
const krillinDependencyLoader = createKrillinDependencyLoader({
root: join(runtimeDir, 'krillinai', 'dependencies')
});
@@ -517,7 +543,58 @@ export async function buildServer(input: BuildServerInput) {
dataDir,
configStore: creatorServicesConfigStore
});
+ const developmentStickmanRuntimeRoot = resolve(
+ dirname(fileURLToPath(import.meta.url)),
+ '../../../desktop/.pack/stickman-runtime'
+ );
+ const stickmanRuntimeRoot = process.env.OPENCREATOR_STICKMAN_RUNTIME_ROOT
+ ?? (existsSync(developmentStickmanRuntimeRoot)
+ ? developmentStickmanRuntimeRoot
+ : join(dataDir, 'creator-runtime', 'stickman'));
+ const packagedStickmanCatalog = join(stickmanRuntimeRoot, 'visual-assets', 'catalog.json');
+ const developmentStickmanCatalog = resolve(
+ dirname(fileURLToPath(import.meta.url)),
+ '../../../../resources/stickman/visual-assets/catalog.json'
+ );
+ const stickmanCatalogPath = existsSync(packagedStickmanCatalog)
+ ? packagedStickmanCatalog
+ : existsSync(developmentStickmanCatalog)
+ ? developmentStickmanCatalog
+ : undefined;
+ const stickmanVisualAssets = stickmanCatalogPath !== undefined
+ ? createStickmanVisualAssetRegistry({
+ root: stickmanRuntimeRoot,
+ catalogPath: stickmanCatalogPath
+ })
+ : undefined;
+ const creatorTesseractPath = [
+ process.env.OPENCREATOR_TESSERACT_PATH,
+ process.platform === 'win32' ? 'C:\\Program Files\\Tesseract-OCR\\tesseract.exe' : undefined,
+ process.platform === 'win32' ? 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe' : undefined
+ ].find(candidate => candidate !== undefined && existsSync(candidate));
const creatorExecutors: CreatorExecutor[] = input.creatorExecutors ?? [];
+ if (input.creatorExecutors === undefined) {
+ if (stickmanVisualAssets !== undefined) {
+ creatorExecutors.push(createStickmanContentExecutor({
+ configStore: creatorServicesConfigStore,
+ codexCompleteJson: createStickmanCodexJsonCompletion({
+ runtimeManager: stickmanContentRuntimeManager!
+ }),
+ visualAssets: stickmanVisualAssets
+ }));
+ creatorExecutors.push(createStickmanImageExecutor({
+ configStore: creatorServicesConfigStore,
+ ledger: creatorProviderRequestLedger,
+ ...(creatorTesseractPath === undefined ? {} : { tesseractPath: creatorTesseractPath })
+ }));
+ }
+ creatorExecutors.push(
+ createStickmanValidationExecutor({
+ ...(creatorTesseractPath === undefined ? {} : { tesseractPath: creatorTesseractPath })
+ }),
+ createStickmanTimelineExecutor()
+ );
+ }
let creatorFfmpegPath: string | undefined;
let creatorFfprobePath: string | undefined;
let creatorYtDlpUpdateManager = input.creatorYtDlpUpdateManager;
@@ -595,10 +672,33 @@ export async function buildServer(input: BuildServerInput) {
}));
}
if (input.creatorExecutors === undefined && creatorFfmpegPath && creatorFfprobePath) {
- creatorExecutors.push(
- createClipExecutor({ configStore: creatorServicesConfigStore, ffmpegPath: creatorFfmpegPath, ffprobePath: creatorFfprobePath }),
- createStickmanExecutor({ configStore: creatorServicesConfigStore, ffmpegPath: creatorFfmpegPath, ffprobePath: creatorFfprobePath })
- );
+ creatorExecutors.push(createClipExecutor({
+ configStore: creatorServicesConfigStore,
+ ffmpegPath: creatorFfmpegPath,
+ ffprobePath: creatorFfprobePath
+ }));
+ }
+ if (input.creatorExecutors === undefined && creatorFfprobePath) {
+ creatorExecutors.push(createStickmanAudioExecutor({
+ configStore: creatorServicesConfigStore,
+ ttsService: krillinTtsService,
+ ledger: creatorProviderRequestLedger,
+ ffprobePath: creatorFfprobePath
+ }));
+ creatorExecutors.push(createStickmanRemotionExecutor({
+ ffprobePath: creatorFfprobePath,
+ runtimeRoot: stickmanRuntimeRoot
+ }));
+ if (creatorFfmpegPath) {
+ creatorExecutors.push(createStickmanMediaValidationExecutor({
+ ffprobePath: creatorFfprobePath,
+ ffmpegPath: creatorFfmpegPath
+ }));
+ }
+ creatorExecutors.push(createStickmanDeliveryExecutor({
+ ffprobePath: creatorFfprobePath,
+ ffmpegPath: creatorFfmpegPath
+ }));
}
} catch (error) {
console.warn(`Creator optional runtime executors are unavailable: ${formatError(error)}`);
@@ -672,6 +772,7 @@ export async function buildServer(input: BuildServerInput) {
});
let coverWorkflow: CoverWorkflow | undefined;
let videoTranslationWorkflow: VideoTranslationWorkflow | undefined;
+ let stickmanVideoWorkflow: StickmanVideoWorkflow | undefined;
const creatorStageRunner = input.creatorService === undefined
? createCreatorStageRunner({
repository: creatorRepository,
@@ -697,6 +798,11 @@ export async function buildServer(input: BuildServerInput) {
kind: 'stage_progress',
payload: { stage }
});
+ if (['failed', 'canceled', 'interrupted'].includes(stage.status)) {
+ void stickmanVideoWorkflow?.handleStageChanged(stage).catch(error => {
+ console.warn(`Stickman video workflow reconciliation failed: ${formatError(error)}`);
+ });
+ }
},
onStageSucceeded(stage) {
void coverWorkflow?.handleStageChanged(stage).catch(error => {
@@ -705,6 +811,9 @@ export async function buildServer(input: BuildServerInput) {
void videoTranslationWorkflow?.handleStageChanged(stage).catch(error => {
console.warn(`Video translation workflow continuation failed: ${formatError(error)}`);
});
+ void stickmanVideoWorkflow?.handleStageChanged(stage).catch(error => {
+ console.warn(`Stickman video workflow continuation failed: ${formatError(error)}`);
+ });
}
})
: undefined;
@@ -754,6 +863,12 @@ export async function buildServer(input: BuildServerInput) {
kind: 'snapshot_changed',
payload: { revision: result.job.revision }
});
+ void stickmanVideoWorkflow?.handleAction(
+ result.job,
+ result.commandReceipt.command
+ ).catch(error => {
+ console.warn(`Stickman video action continuation failed: ${formatError(error)}`);
+ });
}
});
videoTranslationWorkflow = creatorStageRunner === undefined
@@ -770,12 +885,24 @@ export async function buildServer(input: BuildServerInput) {
dispatcher: creatorCommandDispatcher,
configStore: creatorServicesConfigStore
});
+ stickmanVideoWorkflow = creatorStageRunner === undefined
+ ? undefined
+ : createStickmanVideoWorkflow({
+ creator: creatorService,
+ dispatcher: creatorCommandDispatcher,
+ configStore: creatorServicesConfigStore,
+ repository: creatorRepository,
+ providerLedger: creatorProviderRequestLedger
+ });
void coverWorkflow?.recover().catch(error => {
console.warn(`Cover workflow recovery failed: ${formatError(error)}`);
});
void videoTranslationWorkflow?.recover().catch(error => {
console.warn(`Video translation workflow recovery failed: ${formatError(error)}`);
});
+ void stickmanVideoWorkflow?.recover().catch(error => {
+ console.warn(`Stickman video workflow recovery failed: ${formatError(error)}`);
+ });
const scheduleRunInjector = createAgentScheduleRunInjector({
capabilities: agentCapabilityTokens,
getBaseUrl: getAgentToolBaseUrl,
@@ -957,6 +1084,7 @@ export async function buildServer(input: BuildServerInput) {
await capture(() => runManager.close());
await capture(() => appServerRuntimeManager?.close());
await capture(() => creatorAppServerRuntimeManager?.close());
+ await capture(() => stickmanContentRuntimeManager?.close());
await capture(() => codexSessionProvider.close());
await capture(() => codexModelCatalog.close());
await capture(() => codexControlClient.close());
@@ -1040,6 +1168,7 @@ export async function buildServer(input: BuildServerInput) {
async () => {
await videoTranslationWorkflow?.resumeConfiguredJobs();
await coverWorkflow?.resumeConfiguredJobs();
+ await stickmanVideoWorkflow?.resumeConfiguredJobs();
}
);
await registerSmartDubbingRoutes(server, smartDubbingService);
@@ -1050,6 +1179,8 @@ export async function buildServer(input: BuildServerInput) {
agentService: creatorAgentService,
coverWorkflow,
videoTranslationWorkflow,
+ stickmanVideoWorkflow,
+ stickmanVisualAssets,
projectCoverService: creatorProjectCoverService,
referenceImageUploadService: creatorReferenceImageUploadService,
sourceUploadService: creatorSourceUploadService,
diff --git a/apps/daemon/src/creator/command-dispatcher.ts b/apps/daemon/src/creator/command-dispatcher.ts
index a26411af..39a322e6 100644
--- a/apps/daemon/src/creator/command-dispatcher.ts
+++ b/apps/daemon/src/creator/command-dispatcher.ts
@@ -41,13 +41,47 @@ export function createCreatorCommandDispatcher(input: {
function dispatch(
jobId: string,
request: CreatorCommandRequest,
- actor: CreatorActor
+ actor: CreatorActor,
+ workflowIdentity?: {
+ scopeKey?: string | null;
+ inputFingerprint?: string | null;
+ parentStageRunId?: string;
+ resumedFromStageRunId?: string;
+ }
+ ): CreatorCommandDispatchResult {
+ return dispatchCommand(jobId, request, actor, workflowIdentity);
+ }
+
+ function dispatchWorkflow(
+ jobId: string,
+ request: CreatorCommandRequest,
+ identity: {
+ scopeKey?: string | null;
+ inputFingerprint?: string | null;
+ parentStageRunId?: string;
+ resumedFromStageRunId?: string;
+ } = {}
+ ): CreatorCommandDispatchResult {
+ return dispatchCommand(jobId, request, 'system', identity);
+ }
+
+ function dispatchCommand(
+ jobId: string,
+ request: CreatorCommandRequest,
+ actor: CreatorActor,
+ workflowIdentity?: {
+ scopeKey?: string | null;
+ inputFingerprint?: string | null;
+ parentStageRunId?: string;
+ resumedFromStageRunId?: string;
+ }
): CreatorCommandDispatchResult {
const normalized = {
action: request.action,
expectedRevision: request.expectedRevision,
actor,
- input: normalizeJson(request.input)
+ input: normalizeJson(request.input),
+ ...(workflowIdentity === undefined ? {} : { workflowIdentity })
};
const requestHash = createHash('sha256')
.update(stableStringify(normalized))
@@ -107,13 +141,27 @@ export function createCreatorCommandDispatcher(input: {
status: 'queued',
dispatchStatus: 'queued',
idempotencyKey: `${request.idempotencyKey}:stage`,
+ ...(workflowIdentity !== undefined
+ ? {
+ scopeKey: workflowIdentity.scopeKey ?? null,
+ inputFingerprint: workflowIdentity.inputFingerprint ?? null
+ }
+ : request.input.workflow === true
+ ? scopedStageIdentity(request.input)
+ : {}),
progress: {
commandIdempotencyKey: request.idempotencyKey,
- ...(request.input.workflow === true ? { workflow: true } : {}),
- ...(typeof request.input.workflowParentStageRunId === 'string'
+ ...(workflowIdentity !== undefined || request.input.workflow === true
+ ? { workflow: true }
+ : {}),
+ ...(workflowIdentity?.parentStageRunId !== undefined
+ ? { workflowParentStageRunId: workflowIdentity.parentStageRunId }
+ : typeof request.input.workflowParentStageRunId === 'string'
? { workflowParentStageRunId: request.input.workflowParentStageRunId }
: {}),
- ...(typeof request.input.resumedFromStageRunId === 'string'
+ ...(workflowIdentity?.resumedFromStageRunId !== undefined
+ ? { resumedFromStageRunId: workflowIdentity.resumedFromStageRunId }
+ : typeof request.input.resumedFromStageRunId === 'string'
? { resumedFromStageRunId: request.input.resumedFromStageRunId }
: {}),
...stageRequestProgress(actionResponse.job, stageId, request.input),
@@ -177,7 +225,20 @@ export function createCreatorCommandDispatcher(input: {
}
}
- return { dispatch };
+ return { dispatch, dispatchWorkflow };
+}
+
+function scopedStageIdentity(
+ input: Record<string, CreatorJson>
+): { scopeKey?: string; inputFingerprint?: string } {
+ const scopeKey = input.scopeKey;
+ const inputFingerprint = input.inputFingerprint;
+ return {
+ ...(typeof scopeKey === 'string' && scopeKey.length > 0 ? { scopeKey } : {}),
+ ...(typeof inputFingerprint === 'string' && /^[a-f0-9]{64}$/i.test(inputFingerprint)
+ ? { inputFingerprint: inputFingerprint.toLowerCase() }
+ : {})
+ };
}
function serializeResult(result: CreatorActionResponse): Record<string, CreatorJson> {
diff --git a/apps/daemon/src/creator/download/executor.ts b/apps/daemon/src/creator/download/executor.ts
index f6b6e5f9..1633b440 100644
--- a/apps/daemon/src/creator/download/executor.ts
+++ b/apps/daemon/src/creator/download/executor.ts
@@ -27,7 +27,9 @@ type DownloadExecutorOptions = {
ytDlpEnv?: NodeJS.ProcessEnv;
getYtDlpRuntime?(): YtDlpRuntime;
ffmpegPath: string;
+ ffmpegPrefixArgs?: string[];
ffprobePath: string;
+ ffprobePrefixArgs?: string[];
};
type PlaybackCodecs = {
@@ -65,6 +67,15 @@ export function createDownloadExecutor(
? downloadSelectedOption(input, url, proxy, stage)
: downloadLegacy(input, url, proxy, stage);
}
+ if (stage.stageRun.stageId === 'acquire-source') {
+ if (!isYoutube(url)) {
+ throw new CreatorExecutorError(
+ 'unsupported_source',
+ 'Stickman video accepts public YouTube URLs only'
+ );
+ }
+ return downloadStickmanSource(input, url, proxy, stage);
+ }
throw new CreatorExecutorError(
'creator_stage_not_supported',
'Unsupported download stage'
@@ -240,7 +251,7 @@ async function downloadSelectedOption(
};
const metadata = await outputMetadata(
output.path,
- input.ffprobePath,
+ input,
probe,
option,
output
@@ -265,6 +276,111 @@ async function downloadSelectedOption(
};
}
+async function downloadStickmanSource(
+ input: DownloadExecutorOptions,
+ url: string,
+ proxy: string,
+ stage: CreatorExecutorInput
+): Promise<CreatorExecutorResult> {
+ stage.reportProgress({
+ status: 'running',
+ phase: 'preparing_download',
+ percent: 2,
+ message: 'Preparing the YouTube source'
+ });
+ const outputTemplate = join(stage.workdir, 'source.%(ext)s');
+ const ytDlp = currentYtDlpRuntime(input);
+ const stdout = await run(
+ ytDlp.executable,
+ [
+ ...ytDlp.prefixArgs,
+ ...withYtDlpProxy([
+ '--no-playlist',
+ '--newline',
+ '--windows-filenames',
+ '--ffmpeg-location',
+ input.ffmpegPath,
+ '--print',
+ 'after_move:filepath',
+ '--progress',
+ '--progress-delta',
+ '0.5',
+ '-f',
+ 'bestvideo+bestaudio/best',
+ '--merge-output-format',
+ 'mp4',
+ '--remux-video',
+ 'mp4',
+ '-o',
+ outputTemplate,
+ url
+ ], proxy)
+ ],
+ stage,
+ createDownloadProgressReporter(stage, 'video', [1]),
+ ytDlp.env
+ );
+ const reportedPath = printedOutputPath(stdout);
+ if (reportedPath === undefined) {
+ throw new CreatorExecutorError(
+ 'download_output_missing',
+ 'yt-dlp did not report an output path'
+ );
+ }
+ const downloadedPath = await safeOutputPath(stage.workdir, reportedPath);
+ stage.reportProgress({
+ status: 'running',
+ phase: 'validating_output',
+ percent: 97,
+ message: 'Checking the YouTube source'
+ });
+ const output = await normalizeVideoForPlayback(
+ downloadedPath,
+ input,
+ stage,
+ null
+ );
+ const [media, info, sha256] = await Promise.all([
+ validateMediaFile(
+ output.path,
+ input.ffprobePath,
+ input.ffprobePrefixArgs
+ ),
+ stat(output.path),
+ sha256File(output.path)
+ ]);
+ const progress = {
+ status: 'succeeded',
+ phase: 'completed',
+ percent: 100,
+ message: 'YouTube source downloaded'
+ };
+ stage.reportProgress(progress);
+ return {
+ outputs: [{
+ kind: 'source_video',
+ status: 'completed',
+ path: output.path,
+ metadata: {
+ ...media,
+ fileName: output.fileName,
+ size: info.size,
+ bytes: info.size,
+ sha256,
+ mimeType: mimeTypeFor(output.path),
+ source: 'stickman-video',
+ sourceUrl: url,
+ videoCodec: output.videoCodec,
+ audioCodec: output.audioCodec,
+ pixelFormat: output.pixelFormat,
+ playbackCompatible: isPlaybackCompatible(output),
+ normalizedForPlayback: output.normalizedForPlayback
+ }
+ }],
+ progress
+ };
+}
+
async function downloadLegacy(
input: DownloadExecutorOptions,
url: string,
@@ -319,7 +435,11 @@ async function downloadLegacy(
);
}
const path = await safeOutputPath(stage.workdir, reportedPath);
- const media = await validateMediaFile(path, input.ffprobePath);
+ const media = await validateMediaFile(
+ path,
+ input.ffprobePath,
+ input.ffprobePrefixArgs
+ );
const info = await stat(path);
return {
outputs: [{
@@ -470,13 +590,13 @@ function videoDownloadArgs(
async function outputMetadata(
path: string,
- ffprobePath: string,
+ input: DownloadExecutorOptions,
probe: DownloadProbe,
option: DownloadOption,
playback: PlaybackOutput
): Promise<Record<string, CreatorJson>> {
const [media, info, sha256] = await Promise.all([
- validateMediaFile(path, ffprobePath),
+ validateMediaFile(path, input.ffprobePath, input.ffprobePrefixArgs),
stat(path),
sha256File(path)
]);
@@ -526,7 +646,7 @@ async function normalizeVideoForPlayback(
duration: number | null
): Promise<PlaybackOutput> {
const fileName = basename(path);
- const codecs = await readPlaybackCodecs(path, input.ffprobePath, stage);
+ const codecs = await readPlaybackCodecs(path, input, stage);
if (isPlaybackCompatible(codecs)) {
return {
path,
@@ -583,12 +703,16 @@ async function normalizeVideoForPlayback(
try {
await run(
input.ffmpegPath,
- args,
+ [...(input.ffmpegPrefixArgs ?? []), ...args],
stage,
line => reportPlaybackConversionProgress(stage, line, duration)
);
- await validateMediaFile(outputPath, input.ffprobePath);
- const normalized = await readPlaybackCodecs(outputPath, input.ffprobePath, stage);
+ await validateMediaFile(
+ outputPath,
+ input.ffprobePath,
+ input.ffprobePrefixArgs
+ );
+ const normalized = await readPlaybackCodecs(outputPath, input, stage);
if (!isPlaybackCompatible(normalized)) {
throw new CreatorExecutorError(
'download_playback_conversion_failed',
@@ -632,10 +756,11 @@ function reportPlaybackConversionProgress(
async function readPlaybackCodecs(
path: string,
- ffprobePath: string,
+ input: DownloadExecutorOptions,
stage: CreatorExecutorInput
): Promise<PlaybackCodecs> {
- const stdout = await run(ffprobePath, [
+ const stdout = await run(input.ffprobePath, [
+ ...(input.ffprobePrefixArgs ?? []),
'-v',
'error',
'-show_entries',
@@ -1001,3 +1126,18 @@ function isSupported(value: string): boolean {
return false;
}
}
+
+function isYoutube(value: string): boolean {
+ try {
+ const parsed = new URL(value);
+ const host = parsed.hostname.toLowerCase();
+ return parsed.protocol === 'https:'
+ && (
+ host === 'youtu.be'
+ || host === 'youtube.com'
+ || host.endsWith('.youtube.com')
+ );
+ } catch {
+ return false;
+ }
+}
diff --git a/apps/daemon/src/creator/executor.ts b/apps/daemon/src/creator/executor.ts
index 712bb46b..0d24877d 100644
--- a/apps/daemon/src/creator/executor.ts
+++ b/apps/daemon/src/creator/executor.ts
@@ -10,6 +10,8 @@ export type CreatorExecutorOutput = {
kind: string;
status: CreatorArtifactStatus;
path: string | null;
+ scopeKey?: string | null;
+ inputFingerprint?: string | null;
sourceArtifactIds?: string[];
metadata?: Record<string, CreatorJson>;
};
diff --git a/apps/daemon/src/creator/krillin/adapter.ts b/apps/daemon/src/creator/krillin/adapter.ts
index 2f5d77aa..96fd7e01 100644
--- a/apps/daemon/src/creator/krillin/adapter.ts
+++ b/apps/daemon/src/creator/krillin/adapter.ts
@@ -46,12 +46,11 @@ export function createKrillinExecutor(input: {
);
const ffprobe = executablePath(input.resourceRoot, /(?:^|\/)ffprobe(?:\.exe)?$/i);
const materializedArtifacts = await writeArtifactIndex(input.jobsRoot, stage);
- const options = stageOptions(stage);
+ const options = buildKrillinStageOptions(stage);
let artifacts: KrillinResultArtifact[];
try {
const attempts = createKrillinCliExecutionPlan(
- stage.stageRun.stageId,
- resolveKrillinCliSource(materializedArtifacts, options),
+ resolveKrillinStageContract(stage).stageType,
options
);
let completed: KrillinResultArtifact[] | undefined;
@@ -147,14 +146,16 @@ export function normalizeKrillinFailure(error: { code?: string; message?: string
return { code: error?.code ?? 'krillin_stage_failed', message };
}
-function stageOptions(input: CreatorExecutorInput): Record<string, unknown> {
+export function buildKrillinStageOptions(input: CreatorExecutorInput): Record<string, unknown> {
const state = input.job.state;
return compactObject({
sourceUrl: typeof state.sourceUrl === 'string' ? state.sourceUrl : undefined,
originLanguage: typeof state.sourceLanguage === 'string' ? state.sourceLanguage : undefined,
targetLanguage: typeof state.targetLanguage === 'string' ? state.targetLanguage : undefined,
captionSource: state.preferPlatformCaptions === false ? 'whisper' : 'any',
- bilingual: state.bilingual === true,
+ sourceOnly: input.job.templateId === 'stickman-video'
+ && input.stageRun.stageId === 'source-transcript',
+ bilingual: input.stageRun.stageId === 'subtitles' || state.bilingual === true,
bilingualTop: state.subtitlePosition === 'top',
ttsProvider: typeof state.ttsProvider === 'string' ? state.ttsProvider : undefined,
ttsModel: typeof state.ttsModel === 'string' ? state.ttsModel : undefined,
@@ -203,7 +204,7 @@ async function writeArtifactIndex(
const path = await materializeArtifact(jobRoot, artifact);
entries.push({
id: artifact.id,
- kind: artifact.kind,
+ kind: krillinInputKind(input, artifact.kind),
relativePath: relative(jobRoot, path).replaceAll('\\', '/'),
path
});
@@ -238,19 +239,21 @@ async function materializeArtifact(jobRoot: string, artifact: CreatorArtifact):
return actual;
}
-async function validateResultArtifacts(input: {
+export async function validateResultArtifacts(input: {
stage: CreatorExecutorInput;
jobsRoot: string;
artifacts: KrillinResultArtifact[];
ffprobe: string;
}): Promise<CreatorExecutorOutput[]> {
- const expected = expectedOutputKinds(input.stage.stageRun.stageId);
+ const contract = resolveKrillinStageContract(input.stage);
const outputs: CreatorExecutorOutput[] = [];
const jobRoot = await realpath(resolve(input.jobsRoot, input.stage.job.id));
for (const artifact of input.artifacts) {
- if (!expected.has(artifact.kind)) {
+ if (!contract.allowedOutputKinds.has(artifact.kind)) {
throw new CreatorExecutorError('krillin_output_mismatch', `KrillinAI returned undeclared output ${artifact.kind}`);
}
+ const outputKind = contract.outputAliases[artifact.kind];
+ if (outputKind === undefined) continue;
const path = await realpath(resolve(input.jobsRoot, artifact.relativePath));
if (!isInside(jobRoot, path)) {
throw new CreatorExecutorError('krillin_output_escape', 'KrillinAI output escapes the current Job root');
@@ -261,9 +264,9 @@ async function validateResultArtifacts(input: {
sha256: artifact.sha256 ?? null,
bytes: artifact.size ?? null
};
- if (artifact.kind.includes('subtitle')) {
+ if (outputKind.includes('subtitle')) {
const cues = await validateSrtFile(path, {
- allowOverlaps: artifact.kind === 'vertical_subtitle'
+ allowOverlaps: outputKind === 'vertical_subtitle'
});
metadata = {
...metadata,
@@ -278,9 +281,9 @@ async function validateResultArtifacts(input: {
} else {
metadata = { ...metadata, ...(await validateMediaFile(path, input.ffprobe)) };
}
- outputs.push({ kind: artifact.kind, status: 'completed', path, metadata });
+ outputs.push({ kind: outputKind, status: 'completed', path, metadata });
}
- for (const required of requiredOutputKinds(input.stage.stageRun.stageId)) {
+ for (const required of contract.requiredOutputKinds) {
if (!outputs.some(output => output.kind === required)) {
throw new CreatorExecutorError('krillin_output_missing', `KrillinAI did not produce ${required}`);
}
@@ -295,6 +298,69 @@ function executablePath(resourceRoot: string, pattern: RegExp): string {
return resolveInside(resourceRoot, resource.path);
}
+export type KrillinStageContract = {
+ stageType: 'subtitle' | 'tts' | 'render-horizontal' | 'render-vertical';
+ allowedOutputKinds: Set<string>;
+ outputAliases: Record<string, string | undefined>;
+ requiredOutputKinds: string[];
+};
+
+export function resolveKrillinStageContract(
+ input: Pick<CreatorExecutorInput, 'job' | 'stageRun'>
+): KrillinStageContract {
+ const stageId = input.stageRun.stageId;
+ if (input.job.templateId === 'stickman-video') {
+ if (stageId === 'source-transcript') return {
+ stageType: 'subtitle',
+ allowedOutputKinds: new Set(['source_video', 'source_subtitle', 'target_subtitle', 'bilingual_subtitle', 'vertical_subtitle']),
+ outputAliases: { source_subtitle: 'source_subtitle' },
+ requiredOutputKinds: ['source_subtitle']
+ };
+ if (stageId === 'narration') return {
+ stageType: 'tts',
+ allowedOutputKinds: new Set(['dubbed_audio', 'dubbed_video', 'narration_audio']),
+ outputAliases: { dubbed_audio: 'narration_audio', narration_audio: 'narration_audio' },
+ requiredOutputKinds: ['narration_audio']
+ };
+ if (stageId === 'subtitles') return {
+ stageType: 'subtitle',
+ allowedOutputKinds: new Set(['source_video', 'source_subtitle', 'target_subtitle', 'bilingual_subtitle', 'vertical_subtitle']),
+ outputAliases: { bilingual_subtitle: 'bilingual_subtitle' },
+ requiredOutputKinds: ['bilingual_subtitle']
+ };
+ if (stageId === 'bilingual-render') return {
+ stageType: 'render-horizontal',
+ allowedOutputKinds: new Set(['horizontal_video', 'bilingual_video']),
+ outputAliases: { horizontal_video: 'bilingual_video', bilingual_video: 'bilingual_video' },
+ requiredOutputKinds: ['bilingual_video']
+ };
+ }
+ if (stageId === 'subtitle' || stageId === 'tts' || stageId === 'render-horizontal' || stageId === 'render-vertical') {
+ const expected = expectedOutputKinds(stageId);
+ return {
+ stageType: stageId,
+ allowedOutputKinds: expected,
+ outputAliases: Object.fromEntries([...expected].map(kind => [kind, kind])),
+ requiredOutputKinds: requiredOutputKinds(stageId)
+ };
+ }
+ throw new CreatorExecutorError('creator_stage_not_supported', `Unsupported KrillinAI stage ${stageId}`);
+}
+
+function krillinInputKind(input: CreatorExecutorInput, kind: string): string {
+ if (input.job.templateId !== 'stickman-video') return kind;
+ if (input.stageRun.stageId === 'narration' && kind === 'narration_subtitle') {
+ return 'target_subtitle';
+ }
+ if (
+ (input.stageRun.stageId === 'subtitles' || input.stageRun.stageId === 'bilingual-render')
+ && kind === 'clean_video'
+ ) {
+ return 'source_video';
+ }
+ return kind;
+}
+
function expectedOutputKinds(stageId: string): Set<string> {
if (stageId === 'subtitle') return new Set([
'source_video',
diff --git a/apps/daemon/src/creator/krillin/capabilities.ts b/apps/daemon/src/creator/krillin/capabilities.ts
index 70ca7a4c..c56ac65d 100644
--- a/apps/daemon/src/creator/krillin/capabilities.ts
+++ b/apps/daemon/src/creator/krillin/capabilities.ts
@@ -8,6 +8,7 @@ export function createKrillinCreatorServicesCapabilities(
arch: string = process.arch
): CreatorServicesCapabilitiesResponse {
const whisperKitAvailable = platform === 'darwin' && arch === 'arm64';
+ const whisperCppAvailable = platform === 'win32' && arch === 'x64';
return {
platform,
arch,
@@ -33,9 +34,9 @@ export function createKrillinCreatorServicesCapabilities(
localProvider(
'whisper.cpp',
['tiny', 'medium', 'large-v2'],
- platform === 'win32' && arch === 'x64',
+ whisperCppAvailable,
false,
- platform === 'win32' && arch === 'x64' ? undefined : 'unsupported_platform'
+ whisperCppAvailable ? undefined : 'unsupported_platform'
),
cloudProvider('aliyun', [])
]
diff --git a/apps/daemon/src/creator/krillin/cli-runner.ts b/apps/daemon/src/creator/krillin/cli-runner.ts
index b1bdb8dc..6bc171a3 100644
--- a/apps/daemon/src/creator/krillin/cli-runner.ts
+++ b/apps/daemon/src/creator/krillin/cli-runner.ts
@@ -1,5 +1,5 @@
+import { copyFile, link, mkdir, readFile, readdir, realpath, rename, rm, stat, symlink, writeFile } from 'node:fs/promises';
import { createHash } from 'node:crypto';
-import { copyFile, mkdir, readFile, readdir, realpath, rm, stat, symlink, writeFile } from 'node:fs/promises';
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
import type {
CreatorJson,
@@ -9,6 +9,7 @@ import type { CreatorExecutorInput } from '../executor.js';
import { CreatorExecutorError } from '../executor.js';
import { spawnCreatorProcess } from '../process-tree.js';
import { createKrillinConfigToml } from './config-bridge.js';
+import { isYouTubeSource } from './execution-plan.js';
import {
resolveInside,
type KrillinRuntimeManifest
@@ -51,6 +52,13 @@ export type KrillinCliProgressFrame = {
message?: string;
};
+type RunProcess = (input: {
+ executable: string;
+ args: string[];
+ cwd: string;
+ signal: AbortSignal;
+}) => Promise<void>;
+
export class KrillinCliError extends Error {
constructor(
readonly code: string,
@@ -92,11 +100,15 @@ export async function runKrillinCli(input: RunKrillinCliInput): Promise<KrillinR
resourceRoot: input.resourceRoot,
dependencyRoot: input.dependencyRoot,
launcherRoot,
- useOnDemandTranscription: input.config.transcription.provider === 'whisperkit',
- useWhisperCpp: input.config.transcription.provider === 'whisper.cpp',
+ onDemandTranscriptionProvider: isOnDemandTranscriptionProvider(
+ input.config.transcription.provider
+ ) ? input.config.transcription.provider : undefined,
+ onDemandTranscriptionModel: input.config.transcription.provider === 'whisper.cpp'
+ ? input.config.transcription.whisperCpp.model
+ : undefined,
ytDlpRuntime: input.ytDlpRuntime
});
- const cliConfig = stageConfig(input.config, input.stage.stageRun.stageId, input.options);
+ const cliConfig = stageConfig(input.config, krillinCliStageId(input.stage.stageRun.stageId), input.options);
await writeFile(
join(configDir, 'config.toml'),
createKrillinConfigToml(cliConfig),
@@ -109,28 +121,45 @@ export async function runKrillinCli(input: RunKrillinCliInput): Promise<KrillinR
if (stylePath !== undefined) {
await writeFile(stylePath, `${JSON.stringify(style, null, 2)}\n`, { mode: 0o600 });
}
- if (input.stage.stageRun.stageId !== 'subtitle') {
+ if (krillinCliStageId(input.stage.stageRun.stageId) !== 'subtitle') {
await writeInitialManifest(input.stage, input.options);
}
- const args = commandArguments(input.stage, input.artifacts, input.options, stylePath);
+ const args = buildKrillinCliCommandArguments(input.stage, input.artifacts, input.options, stylePath);
input.stage.reportProgress({
krillinMode: 'cli',
providerStatus: 'running',
percent: 5
});
try {
- const response = await executeCli({
- executable: resolveInside(input.resourceRoot, cli.path),
- args,
- cwd: launcherRoot,
- runtimeBin,
- resourceRoot: cliResourceRoot,
- dependencyBin,
- ytDlpRuntime: input.ytDlpRuntime,
- reportProgress: progress => input.stage.reportProgress(progress),
- signal: input.stage.signal
- });
+ let response: KrillinCliResponse;
+ try {
+ response = await executeCli({
+ executable: resolveInside(input.resourceRoot, cli.path),
+ args,
+ cwd: launcherRoot,
+ runtimeBin,
+ resourceRoot: cliResourceRoot,
+ dependencyBin,
+ ytDlpRuntime: input.ytDlpRuntime,
+ reportProgress: progress => input.stage.reportProgress(progress),
+ signal: input.stage.signal
+ });
+ } catch (error) {
+ const recovered = await recoverWindowsHorizontalAssRender({
+ platform: process.platform,
+ resourceRoot: input.resourceRoot,
+ manifest: input.manifest,
+ stageId: input.stage.stageRun.stageId,
+ workdir: input.stage.workdir,
+ artifacts: input.artifacts,
+ signal: input.stage.signal,
+ error,
+ reportProgress: progress => input.stage.reportProgress(progress)
+ });
+ if (recovered === undefined) throw error;
+ response = recovered;
+ }
const artifacts = await collectArtifacts(input, response);
input.stage.reportProgress({
krillinMode: 'cli',
@@ -178,13 +207,13 @@ function stageConfig(
return config;
}
-function commandArguments(
+export function buildKrillinCliCommandArguments(
stage: CreatorExecutorInput,
artifacts: MaterializedKrillinArtifact[],
options: Record<string, unknown>,
stylePath: string | undefined
): string[] {
- const command = stage.stageRun.stageId;
+ const command = krillinCliStageId(stage.stageRun.stageId);
const common = ['--workdir', stage.workdir, '--task-id', stage.stageRun.id];
if (command === 'subtitle') {
const source = resolveKrillinCliSource(artifacts, options);
@@ -196,6 +225,7 @@ function commandArguments(
'--origin-lang', requiredOption(options, 'originLanguage'),
'--target-lang', requiredOption(options, 'targetLanguage'),
'--caption-source', stringOption(options, 'captionSource') ?? 'any',
+ ...(booleanOption(options, 'sourceOnly', false) ? ['--source-only'] : []),
`--bilingual-top=${booleanOption(options, 'bilingualTop', true)}`,
...common,
...styleArgument(stylePath)
@@ -376,6 +406,10 @@ async function collectArtifacts(
}
export function outputMappings(stageId: string): Array<[string, string]> {
+ if (stageId === 'source-transcript') return [['origin_srt', 'source_subtitle']];
+ if (stageId === 'narration') return [['tts_audio', 'narration_audio']];
+ if (stageId === 'subtitles') return [['bilingual_srt', 'bilingual_subtitle']];
+ if (stageId === 'bilingual-render') return [['horizontal_video', 'bilingual_video']];
if (stageId === 'subtitle') {
return [
['origin_video', 'source_video'],
@@ -391,6 +425,13 @@ export function outputMappings(stageId: string): Array<[string, string]> {
return [];
}
+function krillinCliStageId(stageId: string): string {
+ if (stageId === 'source-transcript' || stageId === 'subtitles') return 'subtitle';
+ if (stageId === 'narration') return 'tts';
+ if (stageId === 'bilingual-render') return 'render-horizontal';
+ return stageId;
+}
+
export function createKrillinCliEnvironment(
env: NodeJS.ProcessEnv,
runtimeBin: string,
@@ -417,7 +458,13 @@ export function createKrillinCliEnvironment(
Path: executablePath,
KRILLINAI_RESOURCE_ROOT: resourceRoot,
KRILLINAI_OFFLINE_DEPENDENCIES: '1',
- OPENCREATOR_KRILLINAI_CLI: '1'
+ OPENCREATOR_KRILLINAI_CLI: '1',
+ ...(ytDlpRuntime === undefined
+ ? {}
+ : {
+ KRILLINAI_YT_DLP_EXECUTABLE: ytDlpRuntime.executable,
+ KRILLINAI_YT_DLP_PREFIX_ARGS: JSON.stringify(ytDlpRuntime.prefixArgs)
+ })
};
}
@@ -478,7 +525,9 @@ export async function prepareCliResourceRoot(input: {
resourceRoot: string;
dependencyRoot: string;
launcherRoot: string;
- useOnDemandTranscription: boolean;
+ onDemandTranscriptionProvider?: 'whisperkit' | 'whisper.cpp';
+ onDemandTranscriptionModel?: 'tiny' | 'medium' | 'large-v2';
+ useOnDemandTranscription?: boolean;
useWhisperCpp?: boolean;
ytDlpRuntime?: YtDlpRuntime;
}): Promise<string> {
@@ -487,11 +536,32 @@ export async function prepareCliResourceRoot(input: {
await mkdir(dependencyBin, { recursive: true });
await mkdir(dependencyModels, { recursive: true });
const type = process.platform === 'win32' ? 'junction' : 'dir';
- await symlink(dependencyModels, join(input.launcherRoot, 'models'), type);
+ if (input.onDemandTranscriptionProvider === 'whisper.cpp') {
+ const model = input.onDemandTranscriptionModel;
+ if (model === undefined) {
+ throw new CreatorExecutorError(
+ 'creator_transcription_config_missing',
+ 'Whisper.cpp model selection is required'
+ );
+ }
+ const sourceModels = join(dependencyModels, 'whispercpp');
+ const mountedModels = join(input.launcherRoot, 'models', 'whispercpp');
+ await mkdir(mountedModels, { recursive: true });
+ await linkDirectoryEntries(sourceModels, mountedModels);
+ if (model !== 'large-v2') {
+ await linkFile(
+ join(sourceModels, `ggml-${model}.bin`),
+ join(mountedModels, 'ggml-large-v2.bin'),
+ true
+ );
+ }
+ } else {
+ await symlink(dependencyModels, join(input.launcherRoot, 'models'), type);
+ }
const overlayBin = join(input.launcherRoot, 'bin');
await mkdir(overlayBin, { recursive: true });
await linkDirectoryEntries(join(input.resourceRoot, 'bin'), overlayBin);
- if (input.useWhisperCpp) {
+ if (input.useWhisperCpp === true && input.onDemandTranscriptionProvider === undefined) {
await linkDirectoryEntries(join(dependencyBin, 'whispercpp'), overlayBin);
}
if (input.ytDlpRuntime !== undefined) {
@@ -501,16 +571,163 @@ export async function prepareCliResourceRoot(input: {
join(overlayBin, ytDlpName)
);
}
- if (input.useOnDemandTranscription) {
+ if (
+ input.onDemandTranscriptionProvider === 'whisperkit'
+ || input.useOnDemandTranscription === true
+ ) {
const whisperKitName = process.platform === 'win32' ? 'whisperkit-cli.exe' : 'whisperkit-cli';
await linkFile(
join(dependencyBin, whisperKitName),
join(overlayBin, whisperKitName)
);
+ } else if (input.onDemandTranscriptionProvider === 'whisper.cpp') {
+ await linkDirectory(
+ join(dependencyBin, 'whispercpp'),
+ join(overlayBin, 'whispercpp')
+ );
}
return input.launcherRoot;
}
+export async function recoverWindowsHorizontalAssRender(input: {
+ platform: NodeJS.Platform;
+ resourceRoot: string;
+ manifest: KrillinRuntimeManifest;
+ stageId: string;
+ workdir: string;
+ artifacts: MaterializedKrillinArtifact[];
+ signal: AbortSignal;
+ error: unknown;
+ reportProgress(progress: Record<string, CreatorJson>): void;
+ runProcess?: RunProcess;
+}): Promise<KrillinCliResponse | undefined> {
+ if (!isWindowsHorizontalAssPathFailure(input)) return undefined;
+ const sourceVideo = artifactPath(input.artifacts, 'source_video');
+ const assName = 'formatted_horizontal_bilingual.ass';
+ const assPath = join(input.workdir, assName);
+ if (!sourceVideo || !await isNonEmptyFile(sourceVideo) || !await isNonEmptyFile(assPath)) {
+ return undefined;
+ }
+ const ffmpeg = input.manifest.resources.find(resource => (
+ resource.kind === 'executable'
+ && /(?:^|\/)ffmpeg(?:\.exe)?$/i.test(resource.path)
+ ));
+ if (ffmpeg === undefined) return undefined;
+
+ const outputPath = join(input.workdir, 'horizontal_bilingual.mp4');
+ const temporaryPath = join(input.workdir, '.horizontal_bilingual.opencreator-recovery.mp4');
+ const args = [
+ '-y',
+ '-i', sourceVideo,
+ '-map', '0:v:0',
+ '-map', '0:a:0?',
+ '-vf', `ass=${assName}`,
+ '-c:v', 'libx264',
+ '-preset', 'medium',
+ '-crf', '23',
+ '-c:a', 'aac',
+ '-b:a', '128k',
+ temporaryPath
+ ];
+ await rm(outputPath, { force: true });
+ await rm(temporaryPath, { force: true });
+ input.reportProgress({
+ krillinMode: 'cli',
+ providerStatus: 'running',
+ phase: 'rendering_subtitles',
+ percent: 95,
+ message: 'Rendering bilingual subtitles'
+ });
+ try {
+ await (input.runProcess ?? runProcess)({
+ executable: resolveInside(input.resourceRoot, ffmpeg.path),
+ args,
+ cwd: input.workdir,
+ signal: input.signal
+ });
+ if (!await isNonEmptyFile(temporaryPath)) {
+ throw new KrillinCliError(
+ 'render_video_failed',
+ 'Windows ASS compatibility render did not produce a video'
+ );
+ }
+ await rename(temporaryPath, outputPath);
+ await writeFile(join(input.workdir, 'opencreator-windows-ass-recovery.json'), `${JSON.stringify({
+ schemaVersion: 1,
+ reason: 'krillinai-2.1.0-windows-absolute-ass-path',
+ cwd: input.workdir,
+ inputVideo: sourceVideo,
+ assFile: assName,
+ outputVideo: outputPath,
+ ffmpegArgs: args
+ }, null, 2)}\n`);
+ } catch (error) {
+ await rm(temporaryPath, { force: true });
+ if (error instanceof CreatorExecutorError || error instanceof KrillinCliError) throw error;
+ throw new KrillinCliError(
+ 'render_video_failed',
+ `Windows ASS compatibility render failed: ${error instanceof Error ? error.message : String(error)}`
+ );
+ }
+ return {
+ ok: true,
+ stage: 'render-horizontal',
+ outputs: { horizontal_video: outputPath },
+ warnings: ['Recovered KrillinAI 2.1.0 Windows ASS path handling with a relative ASS filter path']
+ };
+}
+
+function isWindowsHorizontalAssPathFailure(input: {
+ platform: NodeJS.Platform;
+ stageId: string;
+ error: unknown;
+}): boolean {
+ if (
+ input.platform !== 'win32'
+ || input.stageId !== 'bilingual-render'
+ || !(input.error instanceof KrillinCliError)
+ || input.error.code !== 'render_video_failed'
+ ) return false;
+ return /Unable to parse option value[\s\S]*formatted_horizontal_bilingual\.ass[\s\S]*as image size/i
+ .test(input.error.message)
+ && /Error applying option ['"]?original_size['"]? to filter ['"]?ass['"]?/i
+ .test(input.error.message);
+}
+
+async function isNonEmptyFile(path: string): Promise<boolean> {
+ try {
+ const info = await stat(path);
+ return info.isFile() && info.size > 0;
+ } catch {
+ return false;
+ }
+}
+
+function runProcess(input: {
+ executable: string;
+ args: string[];
+ cwd: string;
+ signal: AbortSignal;
+}): Promise<void> {
+ return new Promise((resolvePromise, reject) => {
+ const child = spawnCreatorProcess(input.executable, input.args, {
+ cwd: input.cwd,
+ stdio: ['ignore', 'ignore', 'pipe']
+ }, input.signal);
+ let stderr = '';
+ child.stderr?.on('data', chunk => { stderr = boundedAppend(stderr, String(chunk)); });
+ child.once('error', reject);
+ child.once('exit', code => {
+ if (input.signal.aborted) {
+ reject(new CreatorExecutorError('creator_stage_canceled', 'Creator stage was canceled'));
+ return;
+ }
+ if (code === 0) resolvePromise();
+ else reject(new Error(redact(stderr || `FFmpeg exited with code ${code ?? 'unknown'}`)));
+ });
+ });
+}
+
async function linkDirectoryEntries(source: string, destination: string): Promise<void> {
for (const entry of await readdir(source, { withFileTypes: true })) {
if (!entry.isFile() && !entry.isSymbolicLink()) continue;
@@ -518,14 +735,26 @@ async function linkDirectoryEntries(source: string, destination: string): Promis
}
}
-async function linkFile(source: string, target: string): Promise<void> {
+async function linkFile(
+ source: string,
+ target: string,
+ preferWindowsHardlink = false
+): Promise<void> {
await rm(target, { force: true });
- // Windows file symlinks require privileges unavailable to ordinary installed apps.
- if (process.platform === 'win32') {
+ if (process.platform !== 'win32') {
+ await symlink(source, target);
+ return;
+ }
+ if (!preferWindowsHardlink) {
await copyFile(source, target);
return;
}
- await symlink(source, target);
+ try {
+ await link(source, target);
+ } catch (error) {
+ if (!isWindowsLinkFallbackError(error)) throw error;
+ await copyFile(source, target);
+ }
}
async function installYtDlpCommand(
@@ -555,6 +784,22 @@ function quoteShellArgument(value: string): string {
return `'${value.replaceAll("'", "'\\''")}'`;
}
+function isWindowsLinkFallbackError(error: unknown): boolean {
+ if (error === null || typeof error !== 'object' || !('code' in error)) return false;
+ return ['EPERM', 'EACCES', 'EXDEV', 'ENOTSUP'].includes(String(error.code));
+}
+
+async function linkDirectory(source: string, target: string): Promise<void> {
+ await rm(target, { recursive: true, force: true });
+ await symlink(source, target, process.platform === 'win32' ? 'junction' : 'dir');
+}
+
+function isOnDemandTranscriptionProvider(
+ provider: CreatorServicesConfig['transcription']['provider']
+): provider is 'whisperkit' | 'whisper.cpp' {
+ return provider === 'whisperkit' || provider === 'whisper.cpp';
+}
+
function parseResponse(stdout: string): KrillinCliResponse | undefined {
for (const line of stdout.trim().split(/\r?\n/).reverse()) {
const value = line.trim();
@@ -577,8 +822,13 @@ export function resolveKrillinCliSource(
artifacts: MaterializedKrillinArtifact[],
options: Record<string, unknown>
): string | undefined {
+ const sourceUrl = stringOption(options, 'sourceUrl');
+ const captionSource = stringOption(options, 'captionSource') ?? 'any';
+ if (isYouTubeSource(sourceUrl) && captionSource !== 'whisper') {
+ return sourceUrl;
+ }
const localSource = artifactPath(artifacts, 'source_video');
- return localSource === undefined ? stringOption(options, 'sourceUrl') : `local:${localSource}`;
+ return localSource === undefined ? sourceUrl : `local:${localSource}`;
}
function requiredOption(options: Record<string, unknown>, name: string): string {
diff --git a/apps/daemon/src/creator/krillin/config-bridge.ts b/apps/daemon/src/creator/krillin/config-bridge.ts
index b749a13d..a3f555ca 100644
--- a/apps/daemon/src/creator/krillin/config-bridge.ts
+++ b/apps/daemon/src/creator/krillin/config-bridge.ts
@@ -16,7 +16,14 @@ export function createKrillinConfigToml(config: CreatorServicesConfig): string {
openai: openAi(config.transcription.openai),
fasterwhisper: config.transcription.fasterWhisper,
whisperkit: config.transcription.whisperKit,
- whispercpp: config.transcription.whisperCpp,
+ whispercpp: {
+ ...config.transcription.whisperCpp,
+ // KrillinAI 2.1 validates this label even though whisper.cpp reads the
+ // selected model from the compatible file mounted by the CLI runner.
+ model: config.transcription.provider === 'whisper.cpp'
+ ? 'large-v2'
+ : config.transcription.whisperCpp.model
+ },
aliyun: {
oss: snakeAliyunOss(config.transcription.aliyun.oss),
speech: snakeAliyunSpeech(config.transcription.aliyun.speech)
diff --git a/apps/daemon/src/creator/krillin/dependency-loader.ts b/apps/daemon/src/creator/krillin/dependency-loader.ts
index 25b7dafa..4eab043f 100644
--- a/apps/daemon/src/creator/krillin/dependency-loader.ts
+++ b/apps/daemon/src/creator/krillin/dependency-loader.ts
@@ -1,17 +1,17 @@
import { createHash, randomUUID } from 'node:crypto';
-import { createReadStream } from 'node:fs';
+import { createReadStream, createWriteStream } from 'node:fs';
import {
chmod,
copyFile,
mkdir,
readFile,
- readdir,
rename,
rm,
stat,
writeFile
} from 'node:fs/promises';
import { dirname, join, resolve } from 'node:path';
+import { pipeline } from 'node:stream/promises';
import type {
CreatorJson,
CreatorServicesCapabilitiesResponse,
@@ -20,6 +20,7 @@ import type {
import { CreatorExecutorError } from '../executor.js';
import { spawnCreatorProcess } from '../process-tree.js';
import { createKrillinCreatorServicesCapabilities } from './capabilities.js';
+import { openPromise, type ZipFile } from 'yauzl';
const whisperKitRelease = {
executable: {
@@ -38,6 +39,53 @@ const whisperKitRelease = {
}
} as const;
+const whisperCppRelease = {
+ executable: {
+ version: '1.9.2',
+ archiveUrl: 'https://github.com/ggml-org/whisper.cpp/releases/download/v1.9.2/whisper-bin-x64.zip',
+ archiveSha256: '49dcc16de826f20bd53d44f947a1ae49dfa81f86cad67a64d80820cb192d674a',
+ archiveRoot: 'Release',
+ binarySha256: '95e3c0b0e778ad9499eb0125f97c1dcf437dd9eb4ea77050b043574f93c2631d',
+ files: [
+ ['whisper-cli.exe', 479_232],
+ ['whisper.dll', 1_368_064],
+ ['ggml.dll', 67_584],
+ ['ggml-base.dll', 666_624],
+ ['ggml-cpu-alderlake.dll', 809_984],
+ ['ggml-cpu-cannonlake.dll', 853_504],
+ ['ggml-cpu-cascadelake.dll', 850_944],
+ ['ggml-cpu-haswell.dll', 811_008],
+ ['ggml-cpu-icelake.dll', 850_944],
+ ['ggml-cpu-sandybridge.dll', 803_328],
+ ['ggml-cpu-skylakex.dll', 852_992],
+ ['ggml-cpu-sse42.dll', 790_016],
+ ['ggml-cpu-x64.dll', 794_112]
+ ] as ReadonlyArray<readonly [string, number]>
+ },
+ models: {
+ tiny: {
+ url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/5359861c739e955e79d9a303bcbc70fb988958b1/ggml-tiny.bin',
+ sha256: 'be07e048e1e599ad46341c8d2a135645097a538221678b7acdd1b1919c6e1b21',
+ size: 77_691_713,
+ environment: 'OPENCREATOR_WHISPERCPP_TINY_MODEL'
+ },
+ medium: {
+ url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/5359861c739e955e79d9a303bcbc70fb988958b1/ggml-medium.bin',
+ sha256: '6c14d5adee5f86394037b4e4e8b59f1673b6cee10e3cf0b11bbdbee79c156208',
+ size: 1_533_763_059,
+ environment: 'OPENCREATOR_WHISPERCPP_MEDIUM_MODEL'
+ },
+ 'large-v2': {
+ url: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/5359861c739e955e79d9a303bcbc70fb988958b1/ggml-large-v2.bin',
+ sha256: '9a423fe4d40c82774b6af34115b8b935f34152246eb19e80e376071d3f999487',
+ size: 3_094_623_691,
+ environment: 'OPENCREATOR_WHISPERCPP_LARGE_V2_MODEL'
+ }
+ }
+} as const;
+
+type WhisperCppModel = keyof typeof whisperCppRelease.models;
+
type WhisperKitInstaller = {
isInstalled(root: string): Promise<boolean>;
install(input: {
@@ -48,6 +96,17 @@ type WhisperKitInstaller = {
}): Promise<void>;
};
+type WhisperCppInstaller = {
+ isInstalled(root: string, model: WhisperCppModel): Promise<boolean>;
+ install(input: {
+ root: string;
+ proxy: string;
+ model: WhisperCppModel;
+ signal: AbortSignal;
+ onPhase(phase: 'cli' | 'model'): void;
+ }): Promise<void>;
+};
+
export type KrillinDependencyLoader = {
root: string;
capabilities(): CreatorServicesCapabilitiesResponse;
@@ -63,17 +122,17 @@ export function createKrillinDependencyLoader(input: {
platform?: NodeJS.Platform;
arch?: string;
whisperKitInstaller?: WhisperKitInstaller;
- whisperCppInstaller?: {
- ensure(input: { root: string; model: string; proxy: string; signal: AbortSignal; onPhase(phase: 'cli' | 'model'): void }): Promise<void>;
- };
+ whisperCppInstaller?: WhisperCppInstaller;
}): KrillinDependencyLoader {
const root = resolve(input.root);
const platform = input.platform ?? process.platform;
const arch = input.arch ?? process.arch;
- const installer = input.whisperKitInstaller ?? defaultWhisperKitInstaller;
+ const whisperKitInstaller = input.whisperKitInstaller ?? defaultWhisperKitInstaller;
+ const whisperCppInstaller = input.whisperCppInstaller ?? defaultWhisperCppInstaller;
let whisperKitReady = false;
let whisperKitPending: Promise<void> | undefined;
- let whisperCppPending: Promise<void> = Promise.resolve();
+ const whisperCppReady = new Set<WhisperCppModel>();
+ const whisperCppPending = new Map<WhisperCppModel, Promise<void>>();
return {
root,
@@ -81,36 +140,76 @@ export function createKrillinDependencyLoader(input: {
return createKrillinCreatorServicesCapabilities(platform, arch);
},
async ensure({ config, signal, reportProgress }): Promise<void> {
- if (config.transcription.provider === 'whisper.cpp') {
+ const provider = normalizedProvider(config);
+ if (provider === 'whispercpp') {
if (platform !== 'win32' || arch !== 'x64') {
- throw new CreatorExecutorError('dependency_not_packaged', `Whisper.cpp is unavailable on ${platform}/${arch}`);
+ throw new CreatorExecutorError(
+ 'dependency_not_packaged',
+ `Whisper.cpp is unavailable on ${platform}/${arch}`
+ );
+ }
+ const model = config.transcription.whisperCpp.model;
+ if (whisperCppReady.has(model) || await whisperCppInstaller.isInstalled(root, model)) {
+ whisperCppReady.add(model);
+ return;
+ }
+ if (signal.aborted) {
+ throw new CreatorExecutorError('creator_stage_canceled', 'Creator stage was canceled');
}
- const pending = whisperCppPending.catch(() => {}).then(() => (
- (input.whisperCppInstaller?.ensure ?? ensureWhisperCpp)({
- root, model: config.transcription.whisperCpp.model, proxy: config.proxy.trim(), signal,
+ reportProgress({
+ krillinMode: 'cli',
+ providerStatus: 'preparing',
+ dependency: 'whispercpp',
+ dependencyPhase: 'download',
+ percent: 2
+ });
+ let pending = whisperCppPending.get(model);
+ if (pending === undefined) {
+ pending = whisperCppInstaller.install({
+ root,
+ proxy: config.proxy.trim(),
+ model,
+ signal,
onPhase(phase) {
- reportProgress({ krillinMode: 'cli', providerStatus: 'preparing', dependency: 'whisper.cpp',
- dependencyPhase: phase, percent: phase === 'cli' ? 2 : 4 });
+ reportProgress({
+ krillinMode: 'cli',
+ providerStatus: 'preparing',
+ dependency: 'whispercpp',
+ dependencyPhase: phase,
+ percent: phase === 'cli' ? 2 : 4
+ });
+ }
+ }).then(async () => {
+ if (!await whisperCppInstaller.isInstalled(root, model)) {
+ throw new Error('Whisper.cpp dependency verification failed after installation');
}
- })
- ));
- whisperCppPending = pending;
+ whisperCppReady.add(model);
+ }).finally(() => {
+ whisperCppPending.delete(model);
+ });
+ whisperCppPending.set(model, pending);
+ }
try {
await pending;
} catch (cause) {
- if (signal.aborted) throw new CreatorExecutorError('creator_stage_canceled', 'Creator stage was canceled');
- throw new CreatorExecutorError('creator_dependency_prepare_failed', `Whisper.cpp dependency preparation failed: ${errorMessage(cause)}`);
+ if (signal.aborted) {
+ throw new CreatorExecutorError('creator_stage_canceled', 'Creator stage was canceled');
+ }
+ throw new CreatorExecutorError(
+ 'creator_dependency_prepare_failed',
+ `Whisper.cpp 依赖加载失败:${errorMessage(cause)}`
+ );
}
return;
}
- if (normalizedProvider(config) !== 'whisperkit') return;
+ if (provider !== 'whisperkit') return;
if (platform !== 'darwin' || arch !== 'arm64') {
throw new CreatorExecutorError(
'dependency_not_packaged',
`WhisperKit is unavailable on ${platform}/${arch}`
);
}
- if (whisperKitReady || await installer.isInstalled(root)) {
+ if (whisperKitReady || await whisperKitInstaller.isInstalled(root)) {
whisperKitReady = true;
return;
}
@@ -124,7 +223,7 @@ export function createKrillinDependencyLoader(input: {
dependencyPhase: 'download',
percent: 2
});
- whisperKitPending ??= installer.install({
+ whisperKitPending ??= whisperKitInstaller.install({
root,
proxy: config.proxy.trim(),
signal,
@@ -138,7 +237,7 @@ export function createKrillinDependencyLoader(input: {
});
}
}).then(async () => {
- if (!await installer.isInstalled(root)) {
+ if (!await whisperKitInstaller.isInstalled(root)) {
throw new Error('WhisperKit dependency verification failed after installation');
}
whisperKitReady = true;
@@ -165,87 +264,218 @@ const defaultWhisperKitInstaller: WhisperKitInstaller = {
install: installWhisperKit
};
-const whisperCppVersion = '1.8.3';
-const whisperCppModels: Record<string, { sha256: string; bytes: number }> = {
- tiny: { sha256: 'be07e048e1e599ad46341c8d2a135645097a538221678b7acdd1b1919c6e1b21', bytes: 77691713 },
- medium: { sha256: '6c14d5adee5f86394037b4e4e8b59f1673b6cee10e3cf0b11bbdbee79c156208', bytes: 1533763059 },
- 'large-v2': { sha256: '9a423fe4d40c82774b6af34115b8b935f34152246eb19e80e376071d3f999487', bytes: 3094623691 }
+const defaultWhisperCppInstaller: WhisperCppInstaller = {
+ isInstalled: isWhisperCppInstalled,
+ install: installWhisperCpp
};
-async function ensureWhisperCpp(input: {
- root: string; model: string; proxy: string; signal: AbortSignal;
+async function installWhisperCpp(input: {
+ root: string;
+ proxy: string;
+ model: WhisperCppModel;
+ signal: AbortSignal;
onPhase(phase: 'cli' | 'model'): void;
}): Promise<void> {
- input.signal.throwIfAborted();
- const model = whisperCppModels[input.model];
- if (model === undefined) throw new Error(`Unsupported Whisper.cpp model: ${input.model}`);
- const bin = join(input.root, 'bin', 'whispercpp');
- const marker = join(bin, 'installed.json');
- let installed = false;
+ await mkdir(input.root, { recursive: true, mode: 0o700 });
+ const staging = join(input.root, `.whispercpp-${randomUUID()}`);
+ await mkdir(staging, { recursive: true, mode: 0o700 });
try {
- const record = JSON.parse(await readFile(marker, 'utf8')) as {
- version: string; files: Record<string, string>;
+ input.onPhase('cli');
+ await installWhisperCppExecutable(input, staging);
+ input.onPhase('model');
+ await installWhisperCppModel(input, staging);
+ } finally {
+ await rm(staging, { recursive: true, force: true });
+ }
+}
+
+async function installWhisperCppExecutable(
+ input: { root: string; proxy: string; signal: AbortSignal },
+ staging: string
+): Promise<void> {
+ const executableRoot = join(input.root, 'bin', 'whispercpp');
+ if (await isWhisperCppExecutableInstalled(executableRoot)) return;
+ const archive = await configuredOrDownloadedFile({
+ configured: process.env.OPENCREATOR_WHISPERCPP_CLI_ARCHIVE,
+ name: 'Whisper.cpp CLI',
+ url: whisperCppRelease.executable.archiveUrl,
+ sha256: whisperCppRelease.executable.archiveSha256,
+ path: join(staging, 'whisper-bin-x64.zip'),
+ proxy: input.proxy,
+ signal: input.signal
+ });
+ const extracted = join(staging, 'cli');
+ await extractWhisperCppExecutableArchive(archive, extracted, input.signal);
+ await verifyWhisperCppExecutableFiles(extracted);
+ const version = await runCommand(join(extracted, 'whisper-cli.exe'), ['--version'], {
+ cwd: extracted,
+ signal: input.signal,
+ captureStdout: true
+ });
+ if (!`${version.stdout}\n${version.stderr}`.includes(whisperCppRelease.executable.version)) {
+ throw new Error(`Unexpected Whisper.cpp CLI version: ${version.stdout || version.stderr}`);
+ }
+ await writeFile(join(extracted, '.opencreator-runtime.json'), `${JSON.stringify({
+ version: 1,
+ cliVersion: whisperCppRelease.executable.version,
+ archiveSha256: whisperCppRelease.executable.archiveSha256
+ }, null, 2)}\n`, { mode: 0o600 });
+ await mkdir(dirname(executableRoot), { recursive: true });
+ await rm(executableRoot, { recursive: true, force: true });
+ await rename(extracted, executableRoot);
+}
+
+async function installWhisperCppModel(
+ input: {
+ root: string;
+ proxy: string;
+ model: WhisperCppModel;
+ signal: AbortSignal;
+ },
+ staging: string
+): Promise<void> {
+ const modelRoot = join(input.root, 'models', 'whispercpp');
+ if (await isWhisperCppModelInstalled(modelRoot, input.model)) return;
+ const release = whisperCppRelease.models[input.model];
+ const stagedModel = join(staging, `ggml-${input.model}.bin`);
+ const downloaded = await configuredOrDownloadedFile({
+ configured: process.env[release.environment],
+ name: `Whisper.cpp ${input.model} model`,
+ url: release.url,
+ sha256: release.sha256,
+ path: stagedModel,
+ proxy: input.proxy,
+ signal: input.signal
+ });
+ const source = downloaded === stagedModel
+ ? stagedModel
+ : join(staging, `ggml-${input.model}.verified.bin`);
+ if (source !== downloaded) {
+ await pipeline(
+ createReadStream(downloaded),
+ createWriteStream(source, { flags: 'wx', mode: 0o600 }),
+ { signal: input.signal }
+ );
+ }
+ await verifyWhisperCppModelFile(source, input.model);
+ await mkdir(modelRoot, { recursive: true });
+ const model = join(modelRoot, `ggml-${input.model}.bin`);
+ const marker = join(modelRoot, `.opencreator-${input.model}.json`);
+ await rm(model, { force: true });
+ await rename(source, model);
+ await writeFile(marker, `${JSON.stringify({
+ version: 1,
+ model: input.model,
+ sha256: release.sha256,
+ size: release.size
+ }, null, 2)}\n`, { mode: 0o600 });
+}
+
+async function isWhisperCppInstalled(root: string, model: WhisperCppModel): Promise<boolean> {
+ return await isWhisperCppExecutableInstalled(join(root, 'bin', 'whispercpp'))
+ && await isWhisperCppModelInstalled(join(root, 'models', 'whispercpp'), model);
+}
+
+async function isWhisperCppExecutableInstalled(root: string): Promise<boolean> {
+ try {
+ const record = JSON.parse(await readFile(join(root, '.opencreator-runtime.json'), 'utf8')) as {
+ archiveSha256?: unknown;
+ cliVersion?: unknown;
};
- const required = ['whispercpp.exe', 'whisper.dll', 'ggml.dll', 'ggml-base.dll', 'ggml-cpu.dll'];
- installed = record.version === whisperCppVersion && (await Promise.all(required.map(async name => (
- await hashFile(join(bin, name)) === record.files[name]
- )))).every(Boolean);
- } catch { /* Missing or incomplete installs are replaced below. */ }
- const modelPath = join(input.root, 'models', 'whispercpp', `ggml-${input.model}.bin`);
- const modelMarker = `${modelPath}.sha256`;
- let modelInstalled = false;
+ if (
+ record.archiveSha256 !== whisperCppRelease.executable.archiveSha256
+ || record.cliVersion !== whisperCppRelease.executable.version
+ ) return false;
+ await verifyWhisperCppExecutableFiles(root);
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+async function verifyWhisperCppExecutableFiles(root: string): Promise<void> {
+ for (const [name, expectedSize] of whisperCppRelease.executable.files) {
+ const path = join(root, name);
+ const info = await stat(path);
+ if (!info.isFile() || info.size !== expectedSize) {
+ throw new Error(`Whisper.cpp CLI file is invalid: ${name}`);
+ }
+ }
+ if (await hashFile(join(root, 'whisper-cli.exe')) !== whisperCppRelease.executable.binarySha256) {
+ throw new Error('Whisper.cpp CLI executable hash mismatch');
+ }
+}
+
+async function isWhisperCppModelInstalled(
+ root: string,
+ model: WhisperCppModel
+): Promise<boolean> {
try {
- modelInstalled = (await stat(modelPath)).size === model.bytes
- && (await readFile(modelMarker, 'utf8')).trim() === model.sha256;
- } catch { /* A model is ready only after the verified download was committed. */ }
- if (installed && modelInstalled) return;
- await mkdir(input.root, { recursive: true });
- const staging = join(input.root, `.whispercpp-${randomUUID()}`);
- await mkdir(staging);
+ const release = whisperCppRelease.models[model];
+ const record = JSON.parse(await readFile(join(root, `.opencreator-${model}.json`), 'utf8')) as {
+ model?: unknown;
+ sha256?: unknown;
+ size?: unknown;
+ };
+ if (
+ record.model !== model
+ || record.sha256 !== release.sha256
+ || record.size !== release.size
+ ) return false;
+ const info = await stat(join(root, `ggml-${model}.bin`));
+ return info.isFile() && info.size === release.size;
+ } catch {
+ return false;
+ }
+}
+
+async function verifyWhisperCppModelFile(path: string, model: WhisperCppModel): Promise<void> {
+ const release = whisperCppRelease.models[model];
+ const info = await stat(path);
+ if (!info.isFile() || info.size !== release.size) {
+ throw new Error(`Whisper.cpp ${model} model size mismatch`);
+ }
+}
+
+async function extractWhisperCppExecutableArchive(
+ archive: string,
+ destination: string,
+ signal: AbortSignal
+): Promise<void> {
+ await mkdir(destination, { recursive: true, mode: 0o700 });
+ const expected = new Map(whisperCppRelease.executable.files.map(([name, size]) => [
+ `${whisperCppRelease.executable.archiveRoot}/${name}`,
+ { name, size }
+ ]));
+ const extracted = new Set<string>();
+ let zip: ZipFile | undefined;
try {
- if (!installed) {
- input.onPhase('cli');
- const archive = await configuredOrDownloadedArchive({
- configured: process.env.OPENCREATOR_WHISPERCPP_CLI_ARCHIVE,
- name: 'Whisper.cpp',
- url: `https://github.com/ggml-org/whisper.cpp/releases/download/v${whisperCppVersion}/whisper-bin-x64.zip`,
- sha256: 'd824b1e37599f882b396e73f1ee0bfd5d0529f700314c48311dcbd00b803321d',
- path: join(staging, 'cli.zip'), proxy: input.proxy, signal: input.signal
- });
- await runCommand('tar.exe', ['-xf', archive, '-C', staging], { cwd: staging, signal: input.signal });
- const prepared = join(staging, 'bin');
- await mkdir(prepared);
- const files: Record<string, string> = {};
- for (const entry of await readdir(join(staging, 'Release'), { withFileTypes: true })) {
- if (!entry.isFile() || (entry.name !== 'whisper-cli.exe' && !entry.name.endsWith('.dll'))) continue;
- const name = entry.name === 'whisper-cli.exe' ? 'whispercpp.exe' : entry.name;
- await copyFile(join(staging, 'Release', entry.name), join(prepared, name));
- files[name] = await hashFile(join(prepared, name));
+ zip = await openPromise(archive, {
+ autoClose: true,
+ decodeStrings: true,
+ strictFileNames: true,
+ validateEntrySizes: true
+ });
+ for await (const entry of zip.eachEntry()) {
+ if (signal.aborted) throw new Error('dependency_download_canceled');
+ const descriptor = expected.get(entry.fileName);
+ if (descriptor === undefined) continue;
+ if (extracted.has(descriptor.name) || entry.uncompressedSize !== descriptor.size) {
+ throw new Error(`Whisper.cpp archive entry is invalid: ${entry.fileName}`);
}
- await runCommand(join(prepared, 'whispercpp.exe'), ['--help'], { cwd: prepared, signal: input.signal });
- await writeFile(join(prepared, 'installed.json'), JSON.stringify({ version: whisperCppVersion, files }));
- await mkdir(dirname(bin), { recursive: true });
- await rm(bin, { recursive: true, force: true });
- await rename(prepared, bin);
- }
- if (!modelInstalled) {
- input.onPhase('model');
- const downloaded = await configuredOrDownloadedArchive({
- configured: process.env.OPENCREATOR_WHISPERCPP_MODEL_FILE,
- name: `Whisper.cpp ${input.model} model`,
- url: `https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-${input.model}.bin`,
- sha256: model.sha256, path: join(staging, 'model.bin'), proxy: input.proxy, signal: input.signal
- });
- await mkdir(dirname(modelPath), { recursive: true });
- const temporary = join(staging, 'verified-model.bin');
- await copyFile(downloaded, temporary);
- await rm(modelMarker, { force: true });
- await rm(modelPath, { force: true });
- await rename(temporary, modelPath);
- await writeFile(modelMarker, model.sha256);
+ const stream = await zip.openReadStreamPromise(entry);
+ await pipeline(
+ stream,
+ createWriteStream(join(destination, descriptor.name), { flags: 'wx', mode: 0o600 })
+ );
+ extracted.add(descriptor.name);
}
} finally {
- await rm(staging, { recursive: true, force: true });
+ if (zip?.isOpen) zip.close();
+ }
+ const missing = whisperCppRelease.executable.files.find(([name]) => !extracted.has(name));
+ if (missing !== undefined) {
+ throw new Error(`Whisper.cpp archive file is missing: ${missing[0]}`);
}
}
@@ -276,7 +506,7 @@ async function installWhisperKitExecutable(
const executable = join(input.root, 'bin', 'whisperkit-cli');
if (await isWhisperKitExecutableInstalled(executable)) return;
await mkdir(join(input.root, 'bin'), { recursive: true });
- const archive = await configuredOrDownloadedArchive({
+ const archive = await configuredOrDownloadedFile({
configured: process.env.OPENCREATOR_WHISPERKIT_CLI_ARCHIVE,
name: 'WhisperKit CLI',
url: whisperKitRelease.executable.archiveUrl,
@@ -325,7 +555,7 @@ async function installWhisperKitModel(
const marker = join(modelRoot, '.opencreator-large-v2.json');
if (await isWhisperKitModelInstalled(model, marker)) return;
await mkdir(modelRoot, { recursive: true });
- const archive = await configuredOrDownloadedArchive({
+ const archive = await configuredOrDownloadedFile({
configured: process.env.OPENCREATOR_WHISPERKIT_MODEL_ARCHIVE,
name: 'WhisperKit large-v2 model',
url: whisperKitRelease.model.archiveUrl,
@@ -406,7 +636,7 @@ async function verifyWhisperKitModel(root: string): Promise<void> {
}
}
-async function configuredOrDownloadedArchive(input: {
+async function configuredOrDownloadedFile(input: {
configured: string | undefined;
name: string;
url: string;
@@ -421,7 +651,7 @@ async function configuredOrDownloadedArchive(input: {
if (!(await stat(configured)).isFile()) {
throw new Error(`${input.name} archive is unavailable`);
}
- await verifyHash(input.name, configured, input.sha256);
+ await verifyHash(input.name, configured, input.sha256, input.signal);
return configured;
}
const args = [
@@ -454,25 +684,28 @@ async function configuredOrDownloadedArchive(input: {
cwd: dirname(input.path),
signal: input.signal
});
- await verifyHash(input.name, input.path, input.sha256);
+ await verifyHash(input.name, input.path, input.sha256, input.signal);
return input.path;
}
-async function verifyHash(name: string, path: string, expected: string): Promise<void> {
- const actual = await hashFile(path);
+async function verifyHash(
+ name: string,
+ path: string,
+ expected: string,
+ signal?: AbortSignal
+): Promise<void> {
+ const actual = await hashFile(path, signal);
if (actual !== expected) {
throw new Error(`${name} SHA-256 mismatch`);
}
}
-async function hashFile(path: string): Promise<string> {
+async function hashFile(path: string, signal?: AbortSignal): Promise<string> {
const digest = createHash('sha256');
- await new Promise<void>((resolvePromise, reject) => {
- const stream = createReadStream(path);
- stream.on('data', chunk => digest.update(chunk));
- stream.once('end', resolvePromise);
- stream.once('error', reject);
- });
+ for await (const chunk of createReadStream(path)) {
+ if (signal?.aborted === true) throw new Error('dependency_download_canceled');
+ digest.update(chunk as Buffer);
+ }
return digest.digest('hex');
}
@@ -484,7 +717,7 @@ function runCommand(
signal: AbortSignal;
captureStdout?: boolean;
}
-): Promise<{ stdout: string }> {
+): Promise<{ stdout: string; stderr: string }> {
return new Promise((resolvePromise, reject) => {
const child = spawnCreatorProcess(command, args, {
cwd: input.cwd,
@@ -506,7 +739,7 @@ function runCommand(
} else if (code !== 0) {
reject(new Error(stderr.trim() || `${command} exited with code ${code ?? 'unknown'}`));
} else {
- resolvePromise({ stdout });
+ resolvePromise({ stdout, stderr });
}
});
});
@@ -514,12 +747,30 @@ function runCommand(
function dependencyEnvironment(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
if (process.platform === 'win32') {
- const names = ['SystemRoot', 'SystemDrive', 'WINDIR', 'ComSpec', 'TEMP', 'TMP',
- 'USERPROFILE', 'LOCALAPPDATA', 'APPDATA', 'HTTP_PROXY', 'HTTPS_PROXY', 'ALL_PROXY',
- 'NO_PROXY', 'SSL_CERT_FILE', 'SSL_CERT_DIR'];
+ const names = [
+ 'SystemRoot',
+ 'SystemDrive',
+ 'WINDIR',
+ 'ComSpec',
+ 'TEMP',
+ 'TMP',
+ 'USERPROFILE',
+ 'LOCALAPPDATA',
+ 'APPDATA',
+ 'HTTP_PROXY',
+ 'HTTPS_PROXY',
+ 'ALL_PROXY',
+ 'NO_PROXY',
+ 'SSL_CERT_FILE',
+ 'SSL_CERT_DIR'
+ ];
+ const executablePath = env.Path ?? env.PATH ?? (
+ env.SystemRoot === undefined ? '' : join(env.SystemRoot, 'System32')
+ );
return {
...Object.fromEntries(names.flatMap(name => env[name] === undefined ? [] : [[name, env[name]]])),
- PATH: join(env.SystemRoot ?? 'C:\\Windows', 'System32')
+ PATH: executablePath,
+ Path: executablePath
};
}
const names = ['HOME', 'TMPDIR', 'LANG', 'LC_ALL', 'SSL_CERT_FILE', 'SSL_CERT_DIR'];
diff --git a/apps/daemon/src/creator/krillin/execution-plan.ts b/apps/daemon/src/creator/krillin/execution-plan.ts
index 3f735740..bea40736 100644
--- a/apps/daemon/src/creator/krillin/execution-plan.ts
+++ b/apps/daemon/src/creator/krillin/execution-plan.ts
@@ -5,30 +5,13 @@ export type KrillinCliExecutionAttempt = {
export function createKrillinCliExecutionPlan(
stageId: string,
- source: string | undefined,
options: Record<string, unknown>
): KrillinCliExecutionAttempt[] {
- if (stageId !== 'subtitle') {
- return [{ options }];
- }
-
- const captionSource = stringOption(options, 'captionSource') ?? 'any';
- if (!isYouTubeSource(source) || captionSource === 'whisper') {
- return [{ options }];
- }
- if (captionSource !== 'any') {
- return [{ options }];
- }
-
- return [
- {
- options: { ...options, captionSource: 'platform' },
- continueOnErrorCode: 'platform_caption_failed'
- },
- {
- options: { ...options, captionSource: 'whisper' }
- }
- ];
+ return [{
+ options: stageId === 'subtitle' && stringOption(options, 'captionSource') === undefined
+ ? { ...options, captionSource: 'any' }
+ : options
+ }];
}
export function isYouTubeSource(value: string | undefined): boolean {
diff --git a/apps/daemon/src/creator/krillin/manifest.ts b/apps/daemon/src/creator/krillin/manifest.ts
index 9d5e50c5..e3ea1fb9 100644
--- a/apps/daemon/src/creator/krillin/manifest.ts
+++ b/apps/daemon/src/creator/krillin/manifest.ts
@@ -33,6 +33,12 @@ const ytDlpRuntimeSchema = z.discriminatedUnion('mode', [
}).strict()
]);
+const cliSourceSchema = z.object({
+ kind: z.enum(['local-source', 'configured-binary', 'vendor-release']),
+ revision: z.string().min(1).optional(),
+ dirty: z.boolean().optional()
+}).strict();
+
const manifestSchema = z.object({
version: z.number().int().positive(),
runtimeMode: z.literal('cli').optional(),
@@ -42,6 +48,8 @@ const manifestSchema = z.object({
integrationPatchSha256: z.string().regex(/^[a-f0-9]{64}$/i).optional(),
platform: z.string().min(1),
arch: z.string().min(1),
+ upstreamCommit: z.string().optional(),
+ cliSource: cliSourceSchema.optional(),
ytDlp: ytDlpRuntimeSchema.optional(),
resources: z.array(resourceSchema)
}).strict();
diff --git a/apps/daemon/src/creator/krillin/tts-service.ts b/apps/daemon/src/creator/krillin/tts-service.ts
index bcae00c2..5cae07fc 100644
--- a/apps/daemon/src/creator/krillin/tts-service.ts
+++ b/apps/daemon/src/creator/krillin/tts-service.ts
@@ -6,7 +6,7 @@ import type {
CreatorTtsVoicesResponse,
RuntimeErrorCode
} from '@opencreator/protocol';
-import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
+import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
import { join, resolve } from 'node:path';
import { spawn } from 'node:child_process';
import type { CreatorServicesConfigStore } from '../../creator-services/config-store.js';
@@ -51,6 +51,23 @@ type ExecuteUtilityInput = {
signal?: AbortSignal;
};
+type ExecuteSynthesisInput = {
+ config: CreatorServicesConfig;
+ provider: Exclude<CreatorTtsProvider, 'edge-tts'>;
+ model: string;
+ voiceId: string;
+ text: string;
+ format: 'mp3' | 'wav';
+ speed: number;
+ instructions?: string;
+ signal?: AbortSignal;
+};
+
+type ExecuteSynthesisResult = {
+ content: Buffer;
+ format: 'mp3' | 'wav';
+};
+
export type KrillinTtsSynthesisRequest = {
text: string;
provider?: CreatorTtsProvider;
@@ -95,12 +112,17 @@ export function createKrillinTtsService(input: {
configStore: Pick<CreatorServicesConfigStore, 'read'>;
timeoutMs?: number;
executeUtility?: (input: ExecuteUtilityInput) => Promise<KrillinUtilityResponse>;
+ executeSynthesis?: (input: ExecuteSynthesisInput) => Promise<ExecuteSynthesisResult>;
}) {
const executeUtility = input.executeUtility ?? (utility => executePackagedKrillinUtility({
...utility,
resourceRoot: input.resourceRoot,
timeoutMs: input.timeoutMs ?? DEFAULT_TIMEOUT_MS
}));
+ const executeSynthesis = input.executeSynthesis ?? (request => executeProviderSynthesis({
+ ...request,
+ timeoutMs: input.timeoutMs ?? DEFAULT_TIMEOUT_MS
+ }));
async function listVoices(
provider: CreatorTtsProvider,
@@ -170,31 +192,21 @@ export function createKrillinTtsService(input: {
);
}
- const launcherRoot = await createLauncherRoot(input.workRoot);
- const textPath = join(launcherRoot, 'speech.txt');
- const outputPath = join(launcherRoot, `speech.${format}`);
- await writeFile(textPath, text, { mode: 0o600 });
try {
- const args = [
- 'speech',
- '--text-file', textPath,
- '--output', outputPath,
- '--provider', provider,
- '--voice', voiceId,
- '--format', format,
- '--speed', String(speed)
- ];
- if (request.instructions?.trim()) {
- args.push('--instructions', request.instructions.trim());
- }
- const response = await executeUtility({
+ const synthesis = await executeSynthesis({
config: prepared.config,
- args,
- launcherRoot,
+ provider,
+ model: prepared.model,
+ voiceId,
+ text,
+ format,
+ speed,
+ ...(request.instructions?.trim()
+ ? { instructions: request.instructions.trim() }
+ : {}),
...(request.signal === undefined ? {} : { signal: request.signal })
});
- ensureSuccessfulResponse(response);
- const content = await readFile(outputPath);
+ const content = synthesis.content;
if (content.length === 0 || content.length > MAX_OUTPUT_BYTES) {
throw new KrillinTtsServiceError(
'creator_tts_upstream_error',
@@ -207,8 +219,8 @@ export function createKrillinTtsService(input: {
provider,
model: prepared.model,
voiceId,
- format,
- mime: format === 'mp3' ? 'audio/mpeg' : 'audio/wav'
+ format: synthesis.format,
+ mime: synthesis.format === 'mp3' ? 'audio/mpeg' : 'audio/wav'
};
} catch (error) {
if (error instanceof KrillinTtsServiceError) throw error;
@@ -217,8 +229,6 @@ export function createKrillinTtsService(input: {
error instanceof Error ? error.message : 'KrillinAI speech synthesis failed',
502
);
- } finally {
- await rm(launcherRoot, { recursive: true, force: true });
}
}
@@ -305,6 +315,239 @@ function ensureSuccessfulResponse(response: KrillinUtilityResponse): void {
);
}
+async function executeProviderSynthesis(
+ input: ExecuteSynthesisInput & { timeoutMs: number }
+): Promise<ExecuteSynthesisResult> {
+ if (input.provider === 'aliyun') return synthesizeAliyun(input);
+ if (input.provider === 'minimax') return synthesizeMinimax(input);
+ return synthesizeOpenAi(input);
+}
+
+async function synthesizeOpenAi(
+ input: ExecuteSynthesisInput & { timeoutMs: number }
+): Promise<ExecuteSynthesisResult> {
+ const provider = input.config.tts.openai;
+ const response = await providerFetch(
+ appendPath(provider.baseUrl || 'https://api.openai.com/v1', '/audio/speech'),
+ provider.apiKey,
+ {
+ model: input.model,
+ input: input.text,
+ voice: input.voiceId,
+ response_format: input.format,
+ speed: input.speed,
+ ...(input.instructions === undefined ? {} : { instructions: input.instructions })
+ },
+ input
+ );
+ return {
+ content: await readAudioResponse(response),
+ format: audioFormat(response.headers.get('content-type'), undefined, input.format)
+ };
+}
+
+async function synthesizeAliyun(
+ input: ExecuteSynthesisInput & { timeoutMs: number }
+): Promise<ExecuteSynthesisResult> {
+ const provider = input.config.tts.aliyun;
+ const endpoint = aliyunTtsEndpoint(provider.baseUrl);
+ const response = await providerFetch(endpoint, provider.apiKey, {
+ model: input.model,
+ input: {
+ text: input.text,
+ voice: input.voiceId,
+ language_type: containsCjk(input.text) ? 'Chinese' : 'English'
+ }
+ }, input);
+ const payload = await readJsonResponse(response) as {
+ output?: { audio?: { data?: string; url?: string } };
+ request_id?: string;
+ };
+ const audio = payload.output?.audio;
+ const encoded = audio?.data?.trim();
+ if (encoded) {
+ const content = decodeBase64Audio(encoded);
+ return { content, format: detectAudioFormat(content, input.format) };
+ }
+ if (!audio?.url) throw new Error('Aliyun TTS response did not contain audio');
+ const audioUrl = new URL(audio.url);
+ if (audioUrl.protocol === 'http:') audioUrl.protocol = 'https:';
+ if (audioUrl.protocol !== 'https:') throw new Error('Aliyun TTS returned an invalid audio URL');
+ const audioResponse = await timedFetch(audioUrl, { method: 'GET' }, input);
+ if (!audioResponse.ok) await throwProviderHttpError(audioResponse);
+ const content = await readAudioResponse(audioResponse);
+ return {
+ content,
+ format: audioFormat(
+ audioResponse.headers.get('content-type'),
+ audioUrl.pathname,
+ detectAudioFormat(content, input.format)
+ )
+ };
+}
+
+async function synthesizeMinimax(
+ input: ExecuteSynthesisInput & { timeoutMs: number }
+): Promise<ExecuteSynthesisResult> {
+ const provider = input.config.tts.minimax;
+ const response = await providerFetch(
+ minimaxTtsEndpoint(provider.baseUrl || 'https://api.minimax.io'),
+ provider.apiKey,
+ {
+ model: input.model,
+ text: input.text,
+ stream: false,
+ voice_setting: {
+ voice_id: input.voiceId,
+ speed: input.speed,
+ vol: 1,
+ pitch: 0
+ },
+ audio_setting: {
+ sample_rate: 44_100,
+ format: input.format,
+ channel: 1
+ }
+ },
+ input
+ );
+ const payload = await readJsonResponse(response) as {
+ data?: { audio?: string; status?: number };
+ base_resp?: { status_code?: number; status_msg?: string };
+ };
+ if (payload.base_resp?.status_code !== undefined && payload.base_resp.status_code !== 0) {
+ throw new Error(
+ `MiniMax TTS failed: ${payload.base_resp.status_msg || payload.base_resp.status_code}`
+ );
+ }
+ const encoded = payload.data?.audio;
+ if (!encoded) throw new Error('MiniMax TTS response did not contain audio');
+ const content = Buffer.from(encoded, 'hex');
+ if (content.length === 0) throw new Error('MiniMax TTS returned invalid audio');
+ return { content, format: detectAudioFormat(content, input.format) };
+}
+
+async function providerFetch(
+ url: string,
+ apiKey: string,
+ body: unknown,
+ input: ExecuteSynthesisInput & { timeoutMs: number }
+): Promise<Response> {
+ const response = await timedFetch(url, {
+ method: 'POST',
+ headers: {
+ authorization: `Bearer ${apiKey}`,
+ 'content-type': 'application/json'
+ },
+ body: JSON.stringify(body)
+ }, input);
+ if (!response.ok) await throwProviderHttpError(response);
+ return response;
+}
+
+async function timedFetch(
+ url: string | URL,
+ init: RequestInit,
+ input: Pick<ExecuteSynthesisInput, 'signal'> & { timeoutMs: number }
+): Promise<Response> {
+ const controller = new AbortController();
+ const abort = () => controller.abort();
+ const timeout = setTimeout(abort, input.timeoutMs);
+ timeout.unref();
+ if (input.signal?.aborted) abort();
+ else input.signal?.addEventListener('abort', abort, { once: true });
+ try {
+ return await fetch(url, { ...init, signal: controller.signal });
+ } finally {
+ clearTimeout(timeout);
+ input.signal?.removeEventListener('abort', abort);
+ }
+}
+
+async function readJsonResponse(response: Response): Promise<unknown> {
+ try {
+ return await response.json() as unknown;
+ } catch {
+ throw new Error('TTS provider returned invalid JSON');
+ }
+}
+
+async function readAudioResponse(response: Response): Promise<Buffer> {
+ const declaredLength = Number(response.headers.get('content-length'));
+ if (Number.isFinite(declaredLength) && declaredLength > MAX_OUTPUT_BYTES) {
+ throw new Error('TTS provider audio exceeds the size limit');
+ }
+ const content = Buffer.from(await response.arrayBuffer());
+ if (content.length === 0 || content.length > MAX_OUTPUT_BYTES) {
+ throw new Error('TTS provider returned invalid audio bytes');
+ }
+ return content;
+}
+
+async function throwProviderHttpError(response: Response): Promise<never> {
+ const detail = redactProviderDetail((await response.text()).slice(-1_000));
+ throw new Error(
+ `TTS provider request failed: HTTP ${response.status}${detail ? `: ${detail}` : ''}`
+ );
+}
+
+function appendPath(baseUrl: string, suffix: string): string {
+ const base = baseUrl.replace(/\/$/, '');
+ return base.toLowerCase().endsWith(suffix.toLowerCase()) ? base : `${base}${suffix}`;
+}
+
+function aliyunTtsEndpoint(baseUrl: string): string {
+ const base = (baseUrl || 'https://dashscope.aliyuncs.com/api/v1').replace(/\/$/, '');
+ const suffix = '/services/aigc/multimodal-generation/generation';
+ if (base.toLowerCase().endsWith(suffix)) return base;
+ return /\/api\/v1$/i.test(base)
+ ? `${base}${suffix}`
+ : `${base}/api/v1${suffix}`;
+}
+
+function minimaxTtsEndpoint(baseUrl: string): string {
+ const base = baseUrl.replace(/\/$/, '');
+ if (/\/v1\/t2a_v2$/i.test(base)) return base;
+ return /\/v1$/i.test(base) ? `${base}/t2a_v2` : `${base}/v1/t2a_v2`;
+}
+
+function decodeBase64Audio(value: string): Buffer {
+ const encoded = value.includes(',') ? value.slice(value.indexOf(',') + 1) : value;
+ const content = Buffer.from(encoded, 'base64');
+ if (content.length === 0) throw new Error('TTS provider returned invalid base64 audio');
+ return content;
+}
+
+function audioFormat(
+ contentType: string | null,
+ path: string | undefined,
+ fallback: 'mp3' | 'wav'
+): 'mp3' | 'wav' {
+ if (contentType?.toLowerCase().includes('mpeg')) return 'mp3';
+ if (contentType?.toLowerCase().includes('wav')) return 'wav';
+ if (/\.mp3$/i.test(path ?? '')) return 'mp3';
+ if (/\.wav$/i.test(path ?? '')) return 'wav';
+ return fallback;
+}
+
+function detectAudioFormat(content: Buffer, fallback: 'mp3' | 'wav'): 'mp3' | 'wav' {
+ if (content.subarray(0, 4).toString('ascii') === 'RIFF') return 'wav';
+ if (content.subarray(0, 3).toString('ascii') === 'ID3') return 'mp3';
+ if (content.length >= 2 && content[0] === 0xff && (content[1]! & 0xe0) === 0xe0) return 'mp3';
+ return fallback;
+}
+
+function containsCjk(value: string): boolean {
+ return /[\u3400-\u9fff]/u.test(value);
+}
+
+function redactProviderDetail(value: string): string {
+ return value
+ .replace(/https?:\/\/[^\s"']+/gi, '[url]')
+ .replace(/[A-Za-z0-9_-]{32,}/g, '[redacted]')
+ .trim();
+}
+
async function createLauncherRoot(workRoot: string): Promise<string> {
await mkdir(workRoot, { recursive: true, mode: 0o700 });
return mkdtemp(join(resolve(workRoot), 'tts-'));
diff --git a/apps/daemon/src/creator/project-cover.ts b/apps/daemon/src/creator/project-cover.ts
index aec7630e..f8b6c509 100644
--- a/apps/daemon/src/creator/project-cover.ts
+++ b/apps/daemon/src/creator/project-cover.ts
@@ -26,6 +26,8 @@ const videoArtifactKinds = [
'dubbed_video',
'auto_clip_video',
'stickman_video',
+ 'clean_video',
+ 'bilingual_video',
'clip_video',
'generated_video'
] as const;
diff --git a/apps/daemon/src/creator/provider-requests.ts b/apps/daemon/src/creator/provider-requests.ts
new file mode 100644
index 00000000..04d39cbe
--- /dev/null
+++ b/apps/daemon/src/creator/provider-requests.ts
@@ -0,0 +1,274 @@
+import { createHash } from 'node:crypto';
+import type {
+ CreatorJson,
+ CreatorProviderRequest,
+ CreatorProviderRequestStatus
+} from '@opencreator/protocol';
+import type { CreatorRepository } from './repository.js';
+
+export type CreatorProviderLookupResult =
+ | { status: 'waiting_remote'; remoteTaskId: string }
+ | { status: 'succeeded'; remoteTaskId?: string; resultArtifactId?: string | null }
+ | { status: 'failed'; remoteTaskId?: string }
+ | { status: 'not_found' };
+
+export type CreatorProviderCapabilities = {
+ lookupByRequestKey: boolean;
+ lookup(input: {
+ provider: string;
+ requestKey: string;
+ remoteTaskId: string | null;
+ }): Promise<CreatorProviderLookupResult>;
+};
+
+export class CreatorProviderRequestError extends Error {
+ constructor(readonly code: string, message: string) {
+ super(message);
+ this.name = 'CreatorProviderRequestError';
+ }
+}
+
+export class CreatorProviderRequestLedger {
+ constructor(private readonly repository: CreatorRepository) {}
+
+ registerBeforeSubmit(input: {
+ jobId: string;
+ provider: string;
+ stageRunId: string;
+ scopeKey?: string | null;
+ requestKey: string;
+ request: Record<string, CreatorJson>;
+ billingSideEffect?: boolean;
+ }): CreatorProviderRequest {
+ const requestHash = hashRequest(input.request);
+ return this.repository.transaction(() => {
+ const latest = this.repository.getLatestProviderRequest(input.provider, input.requestKey);
+ if (latest === undefined) {
+ return this.repository.createProviderRequest({
+ jobId: input.jobId,
+ provider: input.provider,
+ stageRunId: input.stageRunId,
+ scopeKey: input.scopeKey ?? null,
+ requestKey: input.requestKey,
+ requestHash,
+ billingSideEffect: input.billingSideEffect ?? true,
+ status: 'registered'
+ });
+ }
+ if (latest.jobId !== input.jobId || latest.requestHash !== requestHash) {
+ throw new CreatorProviderRequestError(
+ 'creator_provider_request_key_conflict',
+ 'Provider request key is already associated with a different request payload'
+ );
+ }
+ if (latest.status === 'registered') return latest;
+ if (isPendingRemote(latest.status)) {
+ throw new CreatorProviderRequestError(
+ 'creator_provider_resolution_required',
+ 'Provider request acceptance must be resolved before this request can be submitted again'
+ );
+ }
+ if (latest.stageRunId === input.stageRunId) {
+ throw new CreatorProviderRequestError(
+ 'creator_provider_request_already_finalized',
+ 'Provider request was already finalized for the current stage run'
+ );
+ }
+ return this.repository.createProviderRequest({
+ jobId: input.jobId,
+ provider: input.provider,
+ stageRunId: input.stageRunId,
+ scopeKey: input.scopeKey ?? null,
+ requestKey: input.requestKey,
+ requestHash,
+ billingSideEffect: input.billingSideEffect ?? true,
+ status: 'registered',
+ generation: latest.generation + 1,
+ resubmissionOf: latest.id
+ });
+ });
+ }
+
+ markSubmitting(id: string): CreatorProviderRequest {
+ return this.transition(id, ['registered'], 'submitting');
+ }
+
+ markWaitingRemote(id: string, remoteTaskId: string): CreatorProviderRequest {
+ if (remoteTaskId.trim().length === 0) {
+ throw new CreatorProviderRequestError(
+ 'creator_provider_remote_id_invalid',
+ 'Provider remote task id must not be empty'
+ );
+ }
+ return this.transition(
+ id,
+ ['submitting', 'unknown_remote_acceptance', 'waiting_remote'],
+ 'waiting_remote',
+ { remoteTaskId }
+ );
+ }
+
+ markSucceeded(id: string, resultArtifactId?: string | null): CreatorProviderRequest {
+ return this.transition(
+ id,
+ ['submitting', 'waiting_remote'],
+ 'succeeded',
+ { resultArtifactId: resultArtifactId ?? null }
+ );
+ }
+
+ markFailed(id: string): CreatorProviderRequest {
+ return this.transition(id, ['submitting', 'waiting_remote'], 'failed');
+ }
+
+ markUnknownRemoteAcceptance(id: string): CreatorProviderRequest {
+ return this.transition(
+ id,
+ ['submitting', 'waiting_remote'],
+ 'unknown_remote_acceptance'
+ );
+ }
+
+ async recover(
+ id: string,
+ capabilities: CreatorProviderCapabilities
+ ): Promise<CreatorProviderRequest> {
+ const current = this.require(id);
+ if (isTerminal(current.status)) return current;
+ const canLookup = current.remoteTaskId !== null || capabilities.lookupByRequestKey;
+ if (!canLookup) return this.toUnknown(current);
+
+ const result = await capabilities.lookup({
+ provider: current.provider,
+ requestKey: current.requestKey,
+ remoteTaskId: current.remoteTaskId
+ });
+ if (result.status === 'not_found') return this.toUnknown(current);
+ if (result.status === 'waiting_remote') {
+ return this.transition(
+ id,
+ ['submitting', 'waiting_remote', 'unknown_remote_acceptance'],
+ 'waiting_remote',
+ { remoteTaskId: result.remoteTaskId }
+ );
+ }
+ if (result.status === 'succeeded') {
+ return this.transition(
+ id,
+ ['submitting', 'waiting_remote', 'unknown_remote_acceptance'],
+ 'succeeded',
+ {
+ ...(result.remoteTaskId === undefined ? {} : { remoteTaskId: result.remoteTaskId }),
+ resultArtifactId: result.resultArtifactId ?? null
+ }
+ );
+ }
+ return this.transition(
+ id,
+ ['submitting', 'waiting_remote', 'unknown_remote_acceptance'],
+ 'failed',
+ result.remoteTaskId === undefined ? {} : { remoteTaskId: result.remoteTaskId }
+ );
+ }
+
+ confirmResubmit(id: string): CreatorProviderRequest {
+ return this.repository.transaction(() => {
+ const current = this.transition(
+ id,
+ ['unknown_remote_acceptance'],
+ 'abandoned_unknown'
+ );
+ return this.repository.createProviderRequest({
+ jobId: current.jobId,
+ provider: current.provider,
+ stageRunId: current.stageRunId,
+ scopeKey: current.scopeKey,
+ requestKey: current.requestKey,
+ requestHash: current.requestHash,
+ billingSideEffect: current.billingSideEffect,
+ status: 'registered',
+ generation: current.generation + 1,
+ resubmissionOf: current.id
+ });
+ });
+ }
+
+ cancelScope(id: string): CreatorProviderRequest {
+ return this.transition(id, ['unknown_remote_acceptance'], 'canceled');
+ }
+
+ unresolvedForStage(input: {
+ jobId: string;
+ stageId: string;
+ scopeKey?: string | null;
+ }): CreatorProviderRequest[] {
+ const stageIds = new Set(this.repository.listStageRuns(input.jobId)
+ .filter(stage => (
+ stage.stageId === input.stageId
+ && stage.scopeKey === (input.scopeKey ?? null)
+ ))
+ .map(stage => stage.id));
+ return this.repository.listProviderRequests(input.jobId).filter(request => (
+ stageIds.has(request.stageRunId)
+ && request.status === 'unknown_remote_acceptance'
+ ));
+ }
+
+ private toUnknown(current: CreatorProviderRequest): CreatorProviderRequest {
+ if (current.status === 'unknown_remote_acceptance') return current;
+ return this.transition(
+ current.id,
+ ['registered', 'submitting', 'waiting_remote'],
+ 'unknown_remote_acceptance'
+ );
+ }
+
+ private transition(
+ id: string,
+ allowed: CreatorProviderRequestStatus[],
+ status: CreatorProviderRequestStatus,
+ patch: { remoteTaskId?: string | null; resultArtifactId?: string | null } = {}
+ ): CreatorProviderRequest {
+ const current = this.require(id);
+ if (!allowed.includes(current.status)) {
+ throw new CreatorProviderRequestError(
+ 'creator_provider_transition_invalid',
+ `Provider request cannot transition from ${current.status} to ${status}`
+ );
+ }
+ return this.repository.updateProviderRequest({ id, status, ...patch });
+ }
+
+ private require(id: string): CreatorProviderRequest {
+ const request = this.repository.getProviderRequest(id);
+ if (request === undefined) {
+ throw new CreatorProviderRequestError(
+ 'creator_provider_request_not_found',
+ 'Creator provider request was not found'
+ );
+ }
+ return request;
+ }
+}
+
+function hashRequest(value: Record<string, CreatorJson>): string {
+ return createHash('sha256').update(JSON.stringify(sortValue(value))).digest('hex');
+}
+
+function sortValue(value: CreatorJson): CreatorJson {
+ if (Array.isArray(value)) return value.map(sortValue);
+ if (value === null || typeof value !== 'object') return value;
+ return Object.fromEntries(
+ Object.entries(value)
+ .sort(([left], [right]) => left.localeCompare(right))
+ .map(([key, entry]) => [key, sortValue(entry)])
+ );
+}
+
+function isTerminal(status: CreatorProviderRequestStatus): boolean {
+ return ['succeeded', 'failed', 'abandoned_unknown', 'canceled'].includes(status);
+}
+
+function isPendingRemote(status: CreatorProviderRequestStatus): boolean {
+ return ['submitting', 'waiting_remote', 'unknown_remote_acceptance'].includes(status);
+}
diff --git a/apps/daemon/src/creator/repository.ts b/apps/daemon/src/creator/repository.ts
index 0559f767..e68c8e5f 100644
--- a/apps/daemon/src/creator/repository.ts
+++ b/apps/daemon/src/creator/repository.ts
@@ -10,6 +10,8 @@ import type {
CreatorJob,
CreatorJobStatus,
CreatorJson,
+ CreatorProviderRequest,
+ CreatorProviderRequestStatus,
CreatorStageRun,
CreatorStageDispatchStatus,
CreatorStageRunStatus
@@ -36,6 +38,9 @@ type InsertArtifactInput = {
kind: string;
status: CreatorArtifactStatus;
path: string | null;
+ scopeKey?: string | null;
+ inputFingerprint?: string | null;
+ sha256?: string | null;
sourceArtifactIds: string[];
metadata: Record<string, CreatorJson>;
};
@@ -57,6 +62,21 @@ type CreateStageRunInput = {
progress?: Record<string, CreatorJson>;
dispatchStatus?: CreatorStageDispatchStatus;
idempotencyKey?: string | null;
+ scopeKey?: string | null;
+ inputFingerprint?: string | null;
+};
+
+type CreateProviderRequestInput = {
+ jobId: string;
+ provider: string;
+ stageRunId: string;
+ scopeKey?: string | null;
+ requestKey: string;
+ requestHash: string;
+ billingSideEffect?: boolean;
+ status?: CreatorProviderRequestStatus;
+ generation?: number;
+ resubmissionOf?: string | null;
};
export type CreatorRepository = {
@@ -101,6 +121,16 @@ export type CreatorRepository = {
}): CreatorStageRun | undefined;
renewStageRunClaim(input: { id: string; owner: string; expiresAt: string }): boolean;
finishStageRunDispatch(id: string, owner: string): boolean;
+ createProviderRequest(input: CreateProviderRequestInput): CreatorProviderRequest;
+ getProviderRequest(id: string): CreatorProviderRequest | undefined;
+ getLatestProviderRequest(provider: string, requestKey: string): CreatorProviderRequest | undefined;
+ listProviderRequests(jobId: string): CreatorProviderRequest[];
+ updateProviderRequest(input: {
+ id: string;
+ status: CreatorProviderRequestStatus;
+ remoteTaskId?: string | null;
+ resultArtifactId?: string | null;
+ }): CreatorProviderRequest;
listArtifacts(jobId: string): CreatorArtifact[];
listActivities(jobId: string): CreatorActivity[];
};
@@ -136,6 +166,7 @@ export function createCreatorRepository(
agentThreadId: row.agent_thread_id,
stages: listStageRuns(row.id),
artifacts: listArtifacts(row.id),
+ providerRequests: listProviderRequests(row.id),
activities: listActivities(row.id),
createdAt: toIso(row.created_at),
updatedAt: toIso(row.updated_at)
@@ -145,6 +176,7 @@ export function createCreatorRepository(
db.prepare(`
SELECT id, job_id, stage_id, executor, status, dispatch_status,
claim_owner, claim_expires_at, attempt, idempotency_key,
+ scope_key, input_fingerprint,
progress_json, error_code, error_message, started_at, finished_at
FROM creator_stage_runs
WHERE job_id = ?
@@ -161,6 +193,8 @@ export function createCreatorRepository(
claimExpiresAt: nullableIso(row.claim_expires_at),
attempt: row.attempt,
idempotencyKey: row.idempotency_key,
+ scopeKey: row.scope_key,
+ inputFingerprint: row.input_fingerprint,
progress: parseJsonRecord(row.progress_json),
errorCode: row.error_code,
errorMessage: row.error_message,
@@ -171,6 +205,7 @@ export function createCreatorRepository(
const listArtifacts = (jobId: string): CreatorArtifact[] => (
db.prepare(`
SELECT id, job_id, kind, version, status, path,
+ scope_key, input_fingerprint, sha256,
source_artifact_ids_json, metadata_json, created_at
FROM creator_artifacts
WHERE job_id = ?
@@ -183,6 +218,9 @@ export function createCreatorRepository(
version: row.version,
status: row.status,
path: row.path,
+ scopeKey: row.scope_key,
+ inputFingerprint: row.input_fingerprint,
+ sha256: row.sha256,
sourceArtifactIds: parseStringArray(row.source_artifact_ids_json),
metadata: parseJsonRecord(row.metadata_json),
createdAt: toIso(row.created_at)
@@ -206,6 +244,17 @@ export function createCreatorRepository(
createdAt: toIso(row.created_at)
}));
+ const listProviderRequests = (jobId: string): CreatorProviderRequest[] => (
+ db.prepare(`
+ SELECT id, job_id, provider, stage_run_id, scope_key, request_key, request_hash,
+ remote_task_id, billing_side_effect, status, result_artifact_id,
+ generation, resubmission_of, created_at, updated_at
+ FROM creator_provider_requests
+ WHERE job_id = ?
+ ORDER BY created_at ASC, generation ASC, id ASC
+ `).all(jobId) as ProviderRequestRow[]
+ ).map(hydrateProviderRequest);
+
const insertArtifact = (input: InsertArtifactInput): CreatorArtifact => {
const id = idFactory('creator_artifact');
const versionRow = db.prepare(`
@@ -217,8 +266,9 @@ export function createCreatorRepository(
db.prepare(`
INSERT INTO creator_artifacts (
id, job_id, kind, version, status, path,
+ scope_key, input_fingerprint, sha256,
source_artifact_ids_json, metadata_json, created_at
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`).run(
id,
input.jobId,
@@ -226,6 +276,9 @@ export function createCreatorRepository(
versionRow.version,
input.status,
input.path,
+ input.scopeKey ?? null,
+ input.inputFingerprint ?? null,
+ input.sha256 ?? null,
JSON.stringify(input.sourceArtifactIds),
JSON.stringify(input.metadata),
createdAt
@@ -353,9 +406,10 @@ export function createCreatorRepository(
db.prepare(`
INSERT INTO creator_stage_runs (
id, job_id, stage_id, executor, status, dispatch_status,
- claim_owner, claim_expires_at, attempt, idempotency_key, progress_json,
+ claim_owner, claim_expires_at, attempt, idempotency_key,
+ scope_key, input_fingerprint, progress_json,
started_at, created_at
- ) VALUES (?, ?, ?, ?, ?, ?, NULL, NULL, 0, ?, ?, ?, ?)
+ ) VALUES (?, ?, ?, ?, ?, ?, NULL, NULL, 0, ?, ?, ?, ?, ?, ?)
`).run(
id,
input.jobId,
@@ -364,6 +418,8 @@ export function createCreatorRepository(
input.status,
input.dispatchStatus ?? (isTerminalStage(input.status) ? 'finished' : 'queued'),
input.idempotencyKey ?? null,
+ input.scopeKey ?? null,
+ input.inputFingerprint ?? null,
JSON.stringify(input.progress ?? {}),
input.status === 'running' ? timestamp : null,
timestamp
@@ -374,6 +430,7 @@ export function createCreatorRepository(
const row = db.prepare(`
SELECT id, job_id, stage_id, executor, status, dispatch_status,
claim_owner, claim_expires_at, attempt, idempotency_key,
+ scope_key, input_fingerprint,
progress_json, error_code, error_message, started_at, finished_at
FROM creator_stage_runs WHERE id = ?
`).get(id) as StageRow | undefined;
@@ -389,6 +446,8 @@ export function createCreatorRepository(
claimExpiresAt: nullableIso(row.claim_expires_at),
attempt: row.attempt,
idempotencyKey: row.idempotency_key,
+ scopeKey: row.scope_key,
+ inputFingerprint: row.input_fingerprint,
progress: parseJsonRecord(row.progress_json),
errorCode: row.error_code,
errorMessage: row.error_message,
@@ -432,6 +491,7 @@ export function createCreatorRepository(
return (db.prepare(`
SELECT id, job_id, stage_id, executor, status, dispatch_status,
claim_owner, claim_expires_at, attempt, idempotency_key,
+ scope_key, input_fingerprint,
progress_json, error_code, error_message, started_at, finished_at
FROM creator_stage_runs
WHERE dispatch_status = 'queued'
@@ -454,6 +514,7 @@ export function createCreatorRepository(
const row = db.prepare(`
SELECT id, job_id, stage_id, executor, status, dispatch_status,
claim_owner, claim_expires_at, attempt, idempotency_key,
+ scope_key, input_fingerprint,
progress_json, error_code, error_message, started_at, finished_at
FROM creator_stage_runs WHERE id = ?
`).get(input.id) as StageRow;
@@ -472,6 +533,73 @@ export function createCreatorRepository(
WHERE id = ? AND dispatch_status = 'claimed' AND claim_owner = ?
`).run(id, owner).changes === 1;
},
+ createProviderRequest(providerInput): CreatorProviderRequest {
+ const id = idFactory('creator_provider_request');
+ const timestamp = now();
+ db.prepare(`
+ INSERT INTO creator_provider_requests (
+ id, job_id, provider, stage_run_id, scope_key, request_key, request_hash,
+ remote_task_id, billing_side_effect, status, result_artifact_id,
+ generation, resubmission_of, created_at, updated_at
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, NULL, ?, ?, ?, ?)
+ `).run(
+ id,
+ providerInput.jobId,
+ providerInput.provider,
+ providerInput.stageRunId,
+ providerInput.scopeKey ?? null,
+ providerInput.requestKey,
+ providerInput.requestHash,
+ providerInput.billingSideEffect === false ? 0 : 1,
+ providerInput.status ?? 'registered',
+ providerInput.generation ?? 1,
+ providerInput.resubmissionOf ?? null,
+ timestamp,
+ timestamp
+ );
+ return listProviderRequests(providerInput.jobId).find(item => item.id === id)!;
+ },
+ getProviderRequest(id): CreatorProviderRequest | undefined {
+ const row = db.prepare(`
+ SELECT id, job_id, provider, stage_run_id, scope_key, request_key, request_hash,
+ remote_task_id, billing_side_effect, status, result_artifact_id,
+ generation, resubmission_of, created_at, updated_at
+ FROM creator_provider_requests
+ WHERE id = ?
+ `).get(id) as ProviderRequestRow | undefined;
+ return row === undefined ? undefined : hydrateProviderRequest(row);
+ },
+ getLatestProviderRequest(provider, requestKey): CreatorProviderRequest | undefined {
+ const row = db.prepare(`
+ SELECT id, job_id, provider, stage_run_id, scope_key, request_key, request_hash,
+ remote_task_id, billing_side_effect, status, result_artifact_id,
+ generation, resubmission_of, created_at, updated_at
+ FROM creator_provider_requests
+ WHERE provider = ? AND request_key = ?
+ ORDER BY generation DESC
+ LIMIT 1
+ `).get(provider, requestKey) as ProviderRequestRow | undefined;
+ return row === undefined ? undefined : hydrateProviderRequest(row);
+ },
+ listProviderRequests,
+ updateProviderRequest(providerInput): CreatorProviderRequest {
+ const current = this.getProviderRequest(providerInput.id);
+ if (current === undefined) throw new Error('Creator provider request not found');
+ db.prepare(`
+ UPDATE creator_provider_requests
+ SET status = ?, remote_task_id = ?, result_artifact_id = ?, updated_at = ?
+ WHERE id = ?
+ `).run(
+ providerInput.status,
+ providerInput.remoteTaskId === undefined ? current.remoteTaskId : providerInput.remoteTaskId,
+ providerInput.resultArtifactId === undefined
+ ? current.resultArtifactId
+ : providerInput.resultArtifactId,
+ now(),
+ providerInput.id
+ );
+ return this.getProviderRequest(providerInput.id)!;
+ },
listArtifacts,
listActivities
};
@@ -717,6 +845,8 @@ type StageRow = {
claim_expires_at: string | null;
attempt: number;
idempotency_key: string | null;
+ scope_key: string | null;
+ input_fingerprint: string | null;
progress_json: string;
error_code: string | null;
error_message: string | null;
@@ -736,6 +866,8 @@ function hydrateStageRun(row: StageRow): CreatorStageRun {
claimExpiresAt: nullableIso(row.claim_expires_at),
attempt: row.attempt,
idempotencyKey: row.idempotency_key,
+ scopeKey: row.scope_key,
+ inputFingerprint: row.input_fingerprint,
progress: parseJsonRecord(row.progress_json),
errorCode: row.error_code,
errorMessage: row.error_message,
@@ -755,11 +887,52 @@ type ArtifactRow = {
version: number;
status: CreatorArtifactStatus;
path: string | null;
+ scope_key: string | null;
+ input_fingerprint: string | null;
+ sha256: string | null;
source_artifact_ids_json: string;
metadata_json: string;
created_at: string;
};
+type ProviderRequestRow = {
+ id: string;
+ job_id: string;
+ provider: string;
+ stage_run_id: string;
+ scope_key: string | null;
+ request_key: string;
+ request_hash: string;
+ remote_task_id: string | null;
+ billing_side_effect: 0 | 1;
+ status: CreatorProviderRequestStatus;
+ result_artifact_id: string | null;
+ generation: number;
+ resubmission_of: string | null;
+ created_at: string;
+ updated_at: string;
+};
+
+function hydrateProviderRequest(row: ProviderRequestRow): CreatorProviderRequest {
+ return {
+ id: row.id,
+ jobId: row.job_id,
+ provider: row.provider,
+ stageRunId: row.stage_run_id,
+ scopeKey: row.scope_key,
+ requestKey: row.request_key,
+ requestHash: row.request_hash,
+ remoteTaskId: row.remote_task_id,
+ billingSideEffect: row.billing_side_effect === 1,
+ status: row.status,
+ resultArtifactId: row.result_artifact_id,
+ generation: row.generation,
+ resubmissionOf: row.resubmission_of,
+ createdAt: toIso(row.created_at),
+ updatedAt: toIso(row.updated_at)
+ };
+}
+
type LegacyTargetSubtitleRow = {
id: string;
job_id: string;
diff --git a/apps/daemon/src/creator/result-snapshots.ts b/apps/daemon/src/creator/result-snapshots.ts
index 3dff4b38..5a855f88 100644
--- a/apps/daemon/src/creator/result-snapshots.ts
+++ b/apps/daemon/src/creator/result-snapshots.ts
@@ -29,8 +29,7 @@ const legacyResultArtifactKinds = new Set([
'vertical_video',
'cover_image',
'generated_image',
- 'clip_video',
- 'stickman_video'
+ 'clip_video'
]);
export function nextCreatorResultVersion(job: CreatorJob): number {
@@ -134,7 +133,7 @@ function legacyArtifactRefs(artifacts: CreatorArtifact[], excludedIds: Set<strin
const refs: Record<string, string[]> = {};
for (const artifact of artifacts) {
if (excludedIds.has(artifact.id) || !['completed', 'stale'].includes(artifact.status)) continue;
- refs[artifact.kind] = [artifact.id];
+ refs[artifact.kind] = [...(refs[artifact.kind] ?? []), artifact.id];
}
return refs;
}
diff --git a/apps/daemon/src/creator/service.ts b/apps/daemon/src/creator/service.ts
index 9fedf31e..6095f315 100644
--- a/apps/daemon/src/creator/service.ts
+++ b/apps/daemon/src/creator/service.ts
@@ -13,6 +13,8 @@ import { wechatArticleSourceLimit } from '@opencreator/protocol';
import { writeFileSync } from 'node:fs';
import { basename, extname, join, dirname } from 'node:path';
import type { CreatorRepository } from './repository.js';
+import { CreatorProviderRequestLedger } from './provider-requests.js';
+import { handleStickmanAction } from './stickman/action-handler.js';
import {
appendCreatorResultSnapshot,
creatorResultSnapshotForVersion,
@@ -37,8 +39,11 @@ export class CreatorServiceError extends Error {
export function createCreatorService(input: {
repository: CreatorRepository;
templates: CreatorTemplateRegistry;
+ providerRequestLedger?: CreatorProviderRequestLedger;
}) {
const { repository, templates } = input;
+ const providerRequestLedger = input.providerRequestLedger
+ ?? new CreatorProviderRequestLedger(repository);
const getJob = (id: string): CreatorJob | undefined => repository.getJob(id);
@@ -605,6 +610,8 @@ export function createCreatorService(input: {
deepLink?: string;
resumeStageId?: string;
workflow?: boolean;
+ reviewKind?: 'approve-script';
+ artifactId?: string;
}): CreatorJob {
return repository.transaction(() => {
const current = repository.getJob(jobId);
@@ -624,6 +631,8 @@ export function createCreatorService(input: {
? {}
: { resumeStageId: input.resumeStageId }),
...(input.workflow === undefined ? {} : { workflow: input.workflow })
+ , ...(input.reviewKind === undefined ? {} : { kind: input.reviewKind })
+ , ...(input.artifactId === undefined ? {} : { artifactId: input.artifactId })
}
}
});
@@ -666,8 +675,23 @@ export function createCreatorService(input: {
let nextState = { ...current.state };
let nextStatus: CreatorJobStatus = current.status;
const affectedArtifactIds: string[] = [];
+ const stickmanAction = handleStickmanAction({
+ repository,
+ current,
+ action: request.action,
+ parsedInput,
+ actor,
+ newRevision
+ });
+ if (stickmanAction.handled) {
+ nextState = stickmanAction.state;
+ nextStatus = stickmanAction.status;
+ affectedArtifactIds.push(...stickmanAction.affectedArtifactIds);
+ }
- if (request.action === 'update-settings' || request.action === 'undo-action') {
+ if (stickmanAction.handled) {
+ // Template-specific mutations have already produced the authoritative state.
+ } else if (request.action === 'update-settings' || request.action === 'undo-action') {
const patch = readNonEmptyRecord(parsedInput.patch, 'patch');
nextState = { ...nextState, ...patch };
if (current.templateId === 'video-translation' && nextState.sourceType === 'url') {
@@ -852,53 +876,6 @@ export function createCreatorService(input: {
state: nextState
})
};
- } else if (request.action === 'edit-script-segment') {
- const artifactId = readString(parsedInput.artifactId, 'artifactId');
- const source = current.artifacts.find(artifact => artifact.id === artifactId);
- if (source === undefined || source.kind !== 'script_segment') {
- throw new CreatorServiceError('creator_artifact_not_found', 'Script segment artifact was not found');
- }
- const invalidKinds = new Set(
- templates.resolveInvalidatedArtifactKinds(
- current.templateId,
- current.templateVersion,
- request.action
- )
- );
- const resultVersion = nextCreatorResultVersion(current);
- for (const artifact of dependentArtifacts(current.artifacts, artifactId)) {
- if (!invalidKinds.has(artifact.kind) || artifact.status === 'stale') continue;
- repository.setArtifactStatus(artifact.id, 'stale');
- affectedArtifactIds.push(artifact.id);
- }
- const nextSegment = repository.insertArtifact({
- jobId,
- kind: 'script_segment',
- status: 'completed',
- path: source.path,
- sourceArtifactIds: source.sourceArtifactIds,
- metadata: {
- ...source.metadata,
- narration: readString(parsedInput.narration, 'narration'),
- ...(typeof parsedInput.visualPrompt === 'string'
- ? { visualPrompt: parsedInput.visualPrompt }
- : {}),
- editedFromArtifactId: source.id,
- resultVersion
- }
- });
- affectedArtifactIds.push(nextSegment.id);
- nextState = {
- ...nextState,
- ...appendCreatorResultSnapshot({
- job: current,
- version: resultVersion,
- changedArtifacts: [nextSegment],
- staleArtifactIds: affectedArtifactIds.filter(id => id !== nextSegment.id),
- action: request.action,
- description: '保存脚本修改'
- })
- };
} else if (request.action === 'commit-version') {
const baseResultVersion = readResultVersion(
current,
@@ -932,6 +909,59 @@ export function createCreatorService(input: {
nextState = { ...nextState, currentStage: stageId };
delete nextState.needsInput;
nextStatus = 'running';
+ } else if (request.action === 'retry-stage') {
+ const stageId = readString(parsedInput.stageId, 'stageId');
+ const scopeKey = typeof parsedInput.scopeKey === 'string'
+ ? parsedInput.scopeKey
+ : null;
+ if (providerRequestLedger.unresolvedForStage({ jobId, stageId, scopeKey }).length > 0) {
+ throw new CreatorServiceError(
+ 'creator_provider_resolution_required',
+ 'Provider request acceptance must be resolved before retrying this stage'
+ );
+ }
+ nextState = { ...nextState, currentStage: stageId };
+ delete nextState.needsInput;
+ nextStatus = 'running';
+ } else if (request.action === 'resolve-provider-request') {
+ const ledgerId = readString(parsedInput.ledgerId, 'ledgerId');
+ const ledger = current.providerRequests.find(item => item.id === ledgerId);
+ if (ledger === undefined) {
+ throw new CreatorServiceError(
+ 'creator_provider_request_not_found',
+ 'Creator provider request was not found'
+ );
+ }
+ const decision = readString(parsedInput.decision, 'decision');
+ if (decision === 'confirm-resubmit') {
+ if (actor !== 'user' || parsedInput.acceptDuplicateBilling !== true) {
+ throw new CreatorServiceError(
+ 'creator_provider_confirmation_required',
+ 'Only a user can confirm a potentially duplicate billed request'
+ );
+ }
+ providerRequestLedger.confirmResubmit(ledgerId);
+ nextStatus = 'running';
+ delete nextState.needsInput;
+ } else if (decision === 'cancel-scope') {
+ providerRequestLedger.cancelScope(ledgerId);
+ const stage = current.stages.find(item => item.id === ledger.stageRunId);
+ if (stage !== undefined && !['succeeded', 'failed', 'canceled', 'interrupted'].includes(stage.status)) {
+ repository.updateStageRun({
+ id: stage.id,
+ status: 'canceled',
+ errorCode: 'creator_provider_scope_canceled',
+ errorMessage: 'Provider request scope was canceled by the user'
+ });
+ }
+ } else if (decision === 'query') {
+ nextStatus = 'needs_input';
+ } else {
+ throw new CreatorServiceError(
+ 'creator_action_invalid',
+ 'Unsupported provider request decision'
+ );
+ }
}
repository.updateJob({
@@ -1004,6 +1034,11 @@ function writeActivity(input: {
if (input.action === 'run-stage' && typeof input.input.stageId === 'string') {
details.stageId = input.input.stageId;
}
+ if (input.action === 'resolve-provider-request') {
+ details.ledgerId = input.input.ledgerId ?? null;
+ details.decision = input.input.decision ?? null;
+ details.revision = input.input.revision ?? null;
+ }
if (
input.action === 'update-settings'
&& details.objectId === ''
@@ -1050,6 +1085,13 @@ function activityInputFor(
action: string,
input: Record<string, CreatorJson>
): Record<string, CreatorJson> {
+ if (action === 'resolve-provider-request') {
+ return {
+ ledgerId: input.ledgerId ?? null,
+ decision: input.decision ?? null,
+ revision: input.revision ?? null
+ };
+ }
if (action !== 'update-settings') return input;
const patch = input.patch;
if (patch === null || Array.isArray(patch) || typeof patch !== 'object') return input;
@@ -1205,6 +1247,8 @@ function summarizeAction(action: string, input: Record<string, CreatorJson>): st
if (action === 'edit-subtitle') return '更新字幕并保留下游旧版本';
if (action === 'commit-version') return '保存项目版本设置';
if (action === 'run-stage') return `启动阶段 ${String(input.stageId ?? '')}`.trim();
+ if (action === 'retry-stage') return `重试阶段 ${String(input.stageId ?? '')}`.trim();
+ if (action === 'resolve-provider-request') return '处置计费服务请求';
if (action === 'undo-action') return '撤销上一次创作修改';
return '更新创作设置';
}
diff --git a/apps/daemon/src/creator/stage-runner.ts b/apps/daemon/src/creator/stage-runner.ts
index b3322367..134ad6ba 100644
--- a/apps/daemon/src/creator/stage-runner.ts
+++ b/apps/daemon/src/creator/stage-runner.ts
@@ -1,14 +1,17 @@
-import { mkdir } from 'node:fs/promises';
+import { createHash } from 'node:crypto';
+import { mkdir, readFile } from 'node:fs/promises';
import { join } from 'node:path';
import type { CreatorArtifact, CreatorJob, CreatorJson, CreatorStageRun } from '@opencreator/protocol';
import type { CreatorExecutor } from './executor.js';
import { CreatorExecutorError } from './executor.js';
import type { CreatorRepository } from './repository.js';
+import { CreatorProviderRequestError } from './provider-requests.js';
import {
appendCreatorResultSnapshot,
creatorResultSnapshotForVersion,
nextCreatorResultVersion
} from './result-snapshots.js';
+import { currentStickmanScopedArtifacts } from './stickman/lineage.js';
import type { CreatorTemplateRegistry } from './templates/types.js';
import { videoTranslationArtifactRefsPatch } from './templates/video-translation-results.js';
@@ -26,7 +29,7 @@ export function createCreatorStageRunner(input: {
}) {
const executors = new Map(input.executors.map(executor => [executor.id, executor]));
const active = new Map<string, AbortController>();
- const jobTails = new Map<string, Promise<unknown>>();
+ const laneTails = new Map<string, Promise<unknown>>();
const waiters: Array<() => void> = [];
let running = 0;
let closed = false;
@@ -56,13 +59,16 @@ export function createCreatorStageRunner(input: {
throw new CreatorExecutorError('creator_stage_not_found', 'Creator stage run was not found');
}
const jobId = queued.jobId;
- const previous = jobTails.get(jobId) ?? Promise.resolve();
+ const laneKey = queued.scopeKey === null
+ ? jobId
+ : `${jobId}:${queued.stageId}:${queued.scopeKey}`;
+ const previous = laneTails.get(laneKey) ?? Promise.resolve();
const work = previous.catch(() => undefined).then(() => execute(stageRunId));
- jobTails.set(jobId, work);
+ laneTails.set(laneKey, work);
try {
return await work;
} finally {
- if (jobTails.get(jobId) === work) jobTails.delete(jobId);
+ if (laneTails.get(laneKey) === work) laneTails.delete(laneKey);
}
}
@@ -142,7 +148,20 @@ export function createCreatorStageRunner(input: {
if (declaredOutputs.get(output.kind) !== output.status) {
throw new CreatorExecutorError('creator_executor_output_invalid', `Executor returned undeclared output ${output.kind}/${output.status}`);
}
+ if (
+ (output.scopeKey !== undefined && output.scopeKey !== stageRun.scopeKey)
+ || (output.inputFingerprint !== undefined
+ && output.inputFingerprint !== stageRun.inputFingerprint)
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_artifact_scope_mismatch',
+ 'Executor output scope does not match the current stage run'
+ );
+ }
}
+ const outputHashes = await Promise.all(result.outputs.map(async output => (
+ output.path === null ? null : sha256File(output.path)
+ )));
input.repository.transaction(() => {
const beforeOutputs = requireJob(input.repository, jobId);
const createsResultVersion = stage.resultVersionPolicy !== 'none';
@@ -151,21 +170,38 @@ export function createCreatorStageRunner(input: {
? targetResultVersion ?? nextCreatorResultVersion(beforeOutputs)
: undefined;
const insertedArtifacts: CreatorArtifact[] = [];
- const staleArtifactIds = stage.invalidateDependentArtifacts === false
- ? []
- : dependentArtifactIdsForChangedKinds(
+ const changedKinds = new Set(result.outputs.map(output => output.kind));
+ const scopedReplacementIds = stage.replaceOutputArtifactsInScope === true
+ && stageRun!.scopeKey !== null
+ ? artifactIdsAndDependents(
beforeOutputs,
- new Set(result.outputs.map(output => output.kind))
- );
+ beforeOutputs.artifacts
+ .filter(artifact => (
+ artifact.status === 'completed'
+ && artifact.scopeKey === stageRun!.scopeKey
+ && changedKinds.has(artifact.kind)
+ ))
+ .map(artifact => artifact.id)
+ )
+ : [];
+ const staleArtifactIds = [...new Set([
+ ...(stage.invalidateDependentArtifacts === false
+ ? []
+ : dependentArtifactIdsForChangedKinds(beforeOutputs, changedKinds)),
+ ...scopedReplacementIds
+ ])];
for (const artifactId of staleArtifactIds) {
input.repository.setArtifactStatus(artifactId, 'stale');
}
- for (const output of result.outputs) {
+ for (const [outputIndex, output] of result.outputs.entries()) {
insertedArtifacts.push(input.repository.insertArtifact({
jobId,
kind: output.kind,
status: output.status,
path: output.path,
+ scopeKey: stageRun!.scopeKey,
+ inputFingerprint: stageRun!.inputFingerprint,
+ sha256: outputHashes[outputIndex] ?? null,
sourceArtifactIds: output.sourceArtifactIds ?? resolved.artifacts.map(artifact => artifact.id),
metadata: {
...(output.metadata ?? {}),
@@ -188,6 +224,9 @@ export function createCreatorStageRunner(input: {
: {}),
...(job.templateId === 'video-translation'
? videoTranslationArtifactRefsPatch(job.state, stageId)
+ : {}),
+ ...(job.templateId === 'stickman-video' && stageId === 'package-validation'
+ ? exactArtifactRefsPatch(latest, insertedArtifacts)
: {})
};
const baseResultVersion = readPositiveInteger(stageRun!.progress.baseResultVersion);
@@ -205,11 +244,25 @@ export function createCreatorStageRunner(input: {
description: resultSnapshotDescription(stageId, job.templateId),
state: job.state
});
+ const unresolvedScopedFailure = stageRun!.scopeKey !== null
+ && hasUnresolvedScopedFailure(latest, stageId);
updateJob(
input.repository,
latest,
- stage.completesJob === false ? 'draft' : 'completed',
- { currentStage: stageId, ...snapshotPatch },
+ unresolvedScopedFailure
+ ? 'needs_input'
+ : stage.jobCompletionPolicy === 'continue'
+ ? 'running'
+ : stage.completesJob === false
+ ? 'draft'
+ : 'completed',
+ {
+ currentStage: stageId,
+ ...snapshotPatch,
+ ...(!unresolvedScopedFailure && stageRun!.scopeKey !== null
+ ? { needsInput: null }
+ : {})
+ },
input.onJobChanged
);
});
@@ -239,13 +292,29 @@ export function createCreatorStageRunner(input: {
});
const job = input.repository.getJob(jobId);
if (job !== undefined) {
+ const scopedFailure = stageRun.scopeKey !== null && !canceled;
updateJob(
input.repository,
job,
- canceled ? 'canceled' : configurationInput === null ? 'failed' : 'needs_input',
+ canceled
+ ? 'canceled'
+ : scopedFailure || configurationInput !== null
+ ? 'needs_input'
+ : 'failed',
{
currentStage: stageId,
- ...(configurationInput === null ? {} : { needsInput: configurationInput })
+ ...(configurationInput !== null
+ ? { needsInput: configurationInput }
+ : scopedFailure
+ ? {
+ needsInput: {
+ code: failureCode,
+ message: failureMessage,
+ stageId,
+ scopeKey: stageRun.scopeKey
+ }
+ }
+ : {})
},
input.onJobChanged
);
@@ -280,7 +349,28 @@ export function createCreatorStageRunner(input: {
return {
run,
runStageRun,
+ cancelJob(jobId: string): CreatorStageRun[] {
+ return input.repository.listStageRuns(jobId)
+ .filter(stage => stage.status === 'queued' || stage.status === 'running')
+ .map(stage => cancelStage(stage.id))
+ .filter((stage): stage is CreatorStageRun => stage !== undefined);
+ },
cancel(stageRunId: string): CreatorStageRun | undefined {
+ return cancelStage(stageRunId);
+ },
+ retry(stageRunId: string): Promise<CreatorStageRun> {
+ const stage = input.repository.getStageRun(stageRunId);
+ if (stage !== undefined) return run(stage.jobId, stage.stageId);
+ throw new CreatorExecutorError('creator_stage_not_found', 'Creator stage run was not found');
+ },
+ async close() {
+ closed = true;
+ for (const controller of active.values()) controller.abort();
+ await Promise.allSettled([...laneTails.values()]);
+ }
+ };
+
+ function cancelStage(stageRunId: string): CreatorStageRun | undefined {
const stage = input.repository.getStageRun(stageRunId);
if (stage === undefined) return undefined;
if (['succeeded', 'failed', 'canceled', 'interrupted'].includes(stage.status)) {
@@ -323,18 +413,7 @@ export function createCreatorStageRunner(input: {
}
});
return canceled;
- },
- retry(stageRunId: string): Promise<CreatorStageRun> {
- const stage = input.repository.getStageRun(stageRunId);
- if (stage !== undefined) return run(stage.jobId, stage.stageId);
- throw new CreatorExecutorError('creator_stage_not_found', 'Creator stage run was not found');
- },
- async close() {
- closed = true;
- for (const controller of active.values()) controller.abort();
- await Promise.allSettled([...jobTails.values()]);
- }
- };
+ }
async function acquire(): Promise<void> {
if (running < maxConcurrency) {
@@ -351,6 +430,11 @@ export function createCreatorStageRunner(input: {
}
}
+async function sha256File(path: string): Promise<string> {
+ const content = await readFile(path);
+ return createHash('sha256').update(content).digest('hex');
+}
+
function resolveInputs(
job: CreatorJob,
requirements: Array<{
@@ -383,6 +467,16 @@ function resolveInputs(
&& requirement.stateKey !== undefined
? job.state[requirement.stateKey]
: undefined;
+ if (
+ job.templateId === 'stickman-video'
+ && requirement.selector === 'latest-completed'
+ && (requirement.kind === 'shot_image' || requirement.kind === 'narration_audio')
+ ) {
+ const scoped = currentStickmanScopedArtifacts(job, requirement.kind);
+ if (scoped.length > 0) artifacts.push(...scoped);
+ else if (requirement.optional !== true) missing.push(requirement.kind);
+ continue;
+ }
const artifact = requirement.selector === 'state-artifact-id'
? typeof selectedId === 'string'
? job.artifacts.find(candidate => (
@@ -423,6 +517,15 @@ function dependentArtifactIdsForChangedKinds(job: CreatorJob, changedKinds: Set<
const queue = job.artifacts
.filter(artifact => artifact.status === 'completed' && changedKinds.has(artifact.kind))
.map(artifact => artifact.id);
+ return dependentArtifactIds(job, queue);
+}
+
+function artifactIdsAndDependents(job: CreatorJob, rootIds: string[]): string[] {
+ return [...new Set([...rootIds, ...dependentArtifactIds(job, rootIds)])];
+}
+
+function dependentArtifactIds(job: CreatorJob, rootIds: string[]): string[] {
+ const queue = [...rootIds];
const visited = new Set<string>();
const stale = new Set<string>();
while (queue.length > 0) {
@@ -446,6 +549,32 @@ function artifactRefsByKind(artifacts: CreatorArtifact[]): Record<string, string
return Object.fromEntries(refs);
}
+function exactArtifactRefsPatch(
+ job: CreatorJob,
+ artifacts: CreatorArtifact[]
+): Record<string, string[]> {
+ return {
+ ...Object.fromEntries(
+ [...new Set(job.artifacts.map(artifact => artifact.kind))].map(kind => [kind, []])
+ ),
+ ...artifactRefsByKind(artifacts)
+ };
+}
+
+function hasUnresolvedScopedFailure(job: CreatorJob, stageId: string): boolean {
+ return job.stages.some(stage => (
+ stage.stageId === stageId
+ && stage.scopeKey !== null
+ && stage.inputFingerprint !== null
+ && (stage.status === 'failed' || stage.status === 'interrupted')
+ && !job.artifacts.some(artifact => (
+ artifact.status === 'completed'
+ && artifact.scopeKey === stage.scopeKey
+ && artifact.inputFingerprint === stage.inputFingerprint
+ ))
+ ));
+}
+
function readPositiveInteger(value: CreatorJson | undefined): number | undefined {
return typeof value === 'number' && Number.isInteger(value) && value > 0
? value
@@ -476,7 +605,9 @@ function requireJob(repository: CreatorRepository, jobId: string): CreatorJob {
}
function errorCode(error: unknown): string {
- return error instanceof CreatorExecutorError ? error.code : 'creator_stage_failed';
+ return error instanceof CreatorExecutorError || error instanceof CreatorProviderRequestError
+ ? error.code
+ : 'creator_stage_failed';
}
function resultSnapshotDescription(stageId: string, templateId: string): string {
diff --git a/apps/daemon/src/creator/stickman/action-handler.ts b/apps/daemon/src/creator/stickman/action-handler.ts
new file mode 100644
index 00000000..c3666df4
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/action-handler.ts
@@ -0,0 +1,538 @@
+import { createHash } from 'node:crypto';
+import { readFileSync, renameSync, writeFileSync } from 'node:fs';
+import { dirname, join } from 'node:path';
+import type {
+ CreatorActor,
+ CreatorArtifact,
+ CreatorJob,
+ CreatorJobStatus,
+ CreatorJson
+} from '@opencreator/protocol';
+import type { CreatorRepository } from '../repository.js';
+import { CreatorServiceError } from '../service.js';
+import {
+ stickmanScriptManifestSchema,
+ stickmanShotSpecSchema
+} from './contracts.js';
+import {
+ staleStickmanShotScope,
+ staleSupersededStickmanScopedArtifacts
+} from './lineage.js';
+import {
+ DEFAULT_STICKMAN_CHARACTER_ASSET,
+ DEFAULT_STICKMAN_STYLE_ASSET,
+ readVisualAssetRef
+} from './visual-assets.js';
+
+export type StickmanActionResult = {
+ handled: boolean;
+ state: Record<string, CreatorJson>;
+ status: CreatorJobStatus;
+ affectedArtifactIds: string[];
+};
+
+export function handleStickmanAction(input: {
+ repository: CreatorRepository;
+ current: CreatorJob;
+ action: string;
+ parsedInput: Record<string, CreatorJson>;
+ actor: CreatorActor;
+ newRevision: number;
+}): StickmanActionResult {
+ const { current, parsedInput, repository } = input;
+ if (current.templateId !== 'stickman-video' || current.templateVersion !== 2) {
+ return {
+ handled: false,
+ state: current.state,
+ status: current.status,
+ affectedArtifactIds: []
+ };
+ }
+
+ if (input.action === 'update-settings') {
+ const patch = readRecord(parsedInput.patch, 'patch');
+ if (patch.characterAsset === undefined && patch.styleAsset === undefined) {
+ return {
+ handled: false,
+ state: current.state,
+ status: current.status,
+ affectedArtifactIds: []
+ };
+ }
+ const nextCharacter = patch.characterAsset === undefined
+ ? readVisualAssetRef(current.state.characterAsset, DEFAULT_STICKMAN_CHARACTER_ASSET)
+ : requireVisualAssetRef(patch.characterAsset, 'characterAsset');
+ const nextStyle = patch.styleAsset === undefined
+ ? readVisualAssetRef(current.state.styleAsset, DEFAULT_STICKMAN_STYLE_ASSET)
+ : requireVisualAssetRef(patch.styleAsset, 'styleAsset');
+ const previousCharacter = readVisualAssetRef(
+ current.state.characterAsset,
+ DEFAULT_STICKMAN_CHARACTER_ASSET
+ );
+ const previousStyle = readVisualAssetRef(
+ current.state.styleAsset,
+ DEFAULT_STICKMAN_STYLE_ASSET
+ );
+ const visualProfileChanged = !sameAssetRef(previousCharacter, nextCharacter)
+ || !sameAssetRef(previousStyle, nextStyle);
+ const affectedArtifactIds = visualProfileChanged
+ ? staleVisualPipeline(repository, current)
+ : [];
+ return {
+ handled: true,
+ state: {
+ ...current.state,
+ ...patch,
+ characterAsset: nextCharacter,
+ styleAsset: nextStyle
+ },
+ status: current.status,
+ affectedArtifactIds
+ };
+ }
+
+ if (input.action === 'approve-script') {
+ const source = requireCurrentArtifact(current, parsedInput, 'script_manifest');
+ requireApprovalRevision(current, parsedInput);
+ if (source.path === null) {
+ throw new CreatorServiceError('creator_artifact_not_found', 'Script file is unavailable');
+ }
+ const script = stickmanScriptManifestSchema.parse(JSON.parse(readFileSync(source.path, 'utf8')));
+ const locked = stickmanScriptManifestSchema.parse({
+ ...script,
+ reviewStatus: 'approved',
+ contentLocked: true
+ });
+ repository.setArtifactStatus(source.id, 'stale');
+ const path = writeEditedJson(source, `script-manifest-approved-${input.newRevision}.json`, locked);
+ const artifact = repository.insertArtifact({
+ jobId: current.id,
+ kind: 'script_manifest',
+ status: 'completed',
+ path,
+ sha256: sha256File(path),
+ sourceArtifactIds: [...new Set([...source.sourceArtifactIds, source.id])],
+ metadata: {
+ contract: locked.contract,
+ contentLocked: true,
+ approvedFromArtifactId: source.id,
+ approvedBy: input.actor
+ }
+ });
+ const state: Record<string, CreatorJson> = {
+ ...current.state,
+ approvedScriptArtifactId: artifact.id,
+ workflowTarget: 'audio_ready',
+ currentStage: 'narration'
+ };
+ delete state.needsInput;
+ return {
+ handled: true,
+ state,
+ status: 'running',
+ affectedArtifactIds: [source.id, artifact.id]
+ };
+ }
+ if (input.action === 'continue-after-audio') {
+ const source = requireCurrentArtifact(current, parsedInput, 'audio_timing');
+ requireApprovalRevision(current, parsedInput);
+ const state: Record<string, CreatorJson> = {
+ ...current.state,
+ workflowTarget: 'visuals_ready',
+ currentStage: 'storyboard'
+ };
+ delete state.needsInput;
+ return {
+ handled: true,
+ state,
+ status: 'running',
+ affectedArtifactIds: [source.id]
+ };
+ }
+ if (input.action === 'continue-after-visuals') {
+ const source = requireCurrentArtifact(current, parsedInput, 'visual_validation');
+ requireApprovalRevision(current, parsedInput);
+ const state: Record<string, CreatorJson> = {
+ ...current.state,
+ workflowTarget: 'delivery_ready',
+ currentStage: 'timeline'
+ };
+ delete state.needsInput;
+ return {
+ handled: true,
+ state,
+ status: 'running',
+ affectedArtifactIds: [source.id]
+ };
+ }
+ if (input.action === 'edit-script') {
+ const source = requireCurrentArtifact(current, parsedInput, 'script_manifest');
+ const content = typeof parsedInput.content === 'string' ? parsedInput.content : '';
+ let value: unknown;
+ try {
+ value = JSON.parse(content);
+ } catch {
+ throw new CreatorServiceError('creator_action_input_invalid', 'Script content must be valid JSON');
+ }
+ const script = normalizeEditedScript(stickmanScriptManifestSchema.parse(value));
+ const affectedArtifactIds = [
+ ...staleFrom(repository, current, source, true),
+ ...current.artifacts
+ .filter(artifact => artifact.kind === 'narration_subtitle')
+ .flatMap(artifact => staleFrom(repository, current, artifact, true))
+ ];
+ const path = writeEditedJson(source, `script-manifest-edit-${input.newRevision}.json`, script);
+ const artifact = repository.insertArtifact({
+ jobId: current.id,
+ kind: 'script_manifest',
+ status: 'completed',
+ path,
+ sha256: sha256File(path),
+ sourceArtifactIds: source.sourceArtifactIds,
+ metadata: { contract: script.contract, contentLocked: false, editedFromArtifactId: source.id }
+ });
+ affectedArtifactIds.push(artifact.id);
+ const state: Record<string, CreatorJson> = {
+ ...current.state,
+ workflowTarget: 'script_ready',
+ currentStage: 'script'
+ };
+ delete state.needsInput;
+ delete state.approvedScriptArtifactId;
+ return {
+ handled: true,
+ state,
+ status: 'running',
+ affectedArtifactIds: [...new Set(affectedArtifactIds)]
+ };
+ }
+ if (input.action === 'edit-shot') {
+ const source = requireCurrentArtifact(current, parsedInput, 'shot_spec');
+ if (source.path === null) throw new CreatorServiceError('creator_artifact_not_found', 'Shot spec file is unavailable');
+ const shotSpec = stickmanShotSpecSchema.parse(JSON.parse(readFileSync(source.path, 'utf8')));
+ const targetScope = readString(parsedInput.scopeKey, 'scopeKey');
+ const patch = readRecord(parsedInput.patch, 'patch');
+ const targetIndex = shotSpec.shots.findIndex(shot => shot.id === targetScope);
+ if (targetIndex < 0) throw new CreatorServiceError('creator_shot_not_found', 'Shot was not found');
+ const visualDescription = typeof patch.visualDescription === 'string'
+ ? patch.visualDescription.trim()
+ : undefined;
+ const motion = typeof patch.motion === 'string' ? patch.motion : undefined;
+ if (visualDescription === undefined && motion === undefined) {
+ throw new CreatorServiceError(
+ 'creator_action_input_invalid',
+ '画面描述或运镜至少需要修改一项'
+ );
+ }
+ const shots = shotSpec.shots.map((shot, index) => index === targetIndex
+ ? {
+ ...shot,
+ ...(visualDescription === undefined ? {} : { visualDescription }),
+ ...(motion === undefined ? {} : { motion })
+ }
+ : shot);
+ const next = stickmanShotSpecSchema.parse({ ...shotSpec, shots });
+ repository.setArtifactStatus(source.id, 'stale');
+ const affectedArtifactIds = [
+ source.id,
+ ...staleStickmanShotScope({ repository, job: current, scopeKey: targetScope })
+ ];
+ const path = writeEditedJson(source, `shot-spec-edit-${input.newRevision}.json`, next);
+ const artifact = repository.insertArtifact({
+ jobId: current.id,
+ kind: 'shot_spec',
+ status: 'completed',
+ path,
+ sha256: sha256File(path),
+ sourceArtifactIds: source.sourceArtifactIds,
+ metadata: {
+ contract: 'stickman-semantic-storyboard-v3',
+ shotCount: next.shots.length,
+ editedScopeKey: targetScope,
+ editedFromArtifactId: source.id
+ }
+ });
+ affectedArtifactIds.push(artifact.id);
+ const state: Record<string, CreatorJson> = {
+ ...current.state,
+ workflowTarget: 'visuals_ready',
+ currentStage: 'images'
+ };
+ delete state.needsInput;
+ return {
+ handled: true,
+ state,
+ status: 'running',
+ affectedArtifactIds: [...new Set(affectedArtifactIds)]
+ };
+ }
+ if (input.action === 'regenerate-shot') {
+ const targetScope = readString(parsedInput.scopeKey, 'scopeKey');
+ requireNoPendingShotProviderRequest(current, targetScope);
+ const affectedArtifactIds = staleStickmanShotScope({
+ repository,
+ job: current,
+ scopeKey: targetScope
+ });
+ const state: Record<string, CreatorJson> = {
+ ...current.state,
+ workflowTarget: 'visuals_ready',
+ currentStage: 'images'
+ };
+ delete state.needsInput;
+ return {
+ handled: true,
+ state,
+ status: 'running',
+ affectedArtifactIds: [...new Set(affectedArtifactIds)]
+ };
+ }
+ if (input.action === 'generate-missing-shots') {
+ requireApprovalRevision(current, parsedInput);
+ requireNoPendingImageProviderRequest(current);
+ const affectedArtifactIds = staleSupersededStickmanScopedArtifacts({
+ repository,
+ job: current,
+ kind: 'shot_image'
+ });
+ const state: Record<string, CreatorJson> = {
+ ...current.state,
+ workflowTarget: 'visuals_ready',
+ currentStage: 'images'
+ };
+ delete state.needsInput;
+ return {
+ handled: true,
+ state,
+ status: 'running',
+ affectedArtifactIds
+ };
+ }
+ return {
+ handled: false,
+ state: current.state,
+ status: current.status,
+ affectedArtifactIds: []
+ };
+}
+
+function requireNoPendingShotProviderRequest(job: CreatorJob, scopeKey: string): void {
+ const stageRunIds = new Set(job.stages.filter(stage => (
+ stage.stageId === 'images' && stage.scopeKey === scopeKey
+ )).map(stage => stage.id));
+ const pending = job.providerRequests.some(request => (
+ stageRunIds.has(request.stageRunId)
+ && (
+ request.status === 'submitting'
+ || request.status === 'waiting_remote'
+ || request.status === 'unknown_remote_acceptance'
+ )
+ ));
+ if (pending) {
+ throw new CreatorServiceError(
+ 'creator_provider_resolution_required',
+ 'Provider request acceptance must be resolved before regenerating this shot'
+ );
+ }
+}
+
+function requireNoPendingImageProviderRequest(job: CreatorJob): void {
+ const imageStageRunIds = new Set(job.stages.filter(stage => (
+ stage.stageId === 'images'
+ )).map(stage => stage.id));
+ const pending = job.providerRequests.some(request => (
+ imageStageRunIds.has(request.stageRunId)
+ && (
+ request.status === 'submitting'
+ || request.status === 'waiting_remote'
+ || request.status === 'unknown_remote_acceptance'
+ )
+ ));
+ if (pending) {
+ throw new CreatorServiceError(
+ 'creator_provider_resolution_required',
+ '必须先确认状态未明的画面生成请求,才能继续批量生成'
+ );
+ }
+}
+
+function normalizeEditedScript(
+ value: ReturnType<typeof stickmanScriptManifestSchema.parse>
+): ReturnType<typeof stickmanScriptManifestSchema.parse> {
+ const unit = value.narrationBudget.unit;
+ const segments = value.segments.map((segment, index) => {
+ const narration = segment.narration.trim();
+ const narrationUnits = unit === 'words'
+ ? narration.match(/[\p{L}\p{N}]+(?:['’-][\p{L}\p{N}]+)*/gu)?.length ?? 0
+ : narration.match(/[\p{L}\p{N}]/gu)?.length ?? 0;
+ const estimatedDurationSeconds = roundSeconds(
+ narrationUnits / value.narrationBudget.unitsPerMinute * 60
+ );
+ return {
+ ...segment,
+ id: `segment-${String(index + 1).padStart(2, '0')}`,
+ order: index + 1,
+ narration,
+ narrationUnits,
+ estimatedDurationSeconds
+ };
+ });
+ const overlongSegment = segments.find(segment => segment.estimatedDurationSeconds > 5);
+ if (overlongSegment !== undefined) {
+ throw new CreatorServiceError(
+ 'creator_script_segment_duration_invalid',
+ `${overlongSegment.id} 的预计配音时长超过 5 秒,请按完整语义拆成多个旁白单元`
+ );
+ }
+ const totalNarrationUnits = segments.reduce((total, segment) => total + segment.narrationUnits, 0);
+ if (
+ totalNarrationUnits < value.narrationBudget.minUnits
+ || totalNarrationUnits > value.narrationBudget.maxUnits
+ ) {
+ throw new CreatorServiceError(
+ 'creator_script_duration_budget_invalid',
+ `旁白长度必须保持在 ${value.narrationBudget.minUnits}-${value.narrationBudget.maxUnits} ${unit === 'words' ? '词' : '字符'}内`
+ );
+ }
+ return stickmanScriptManifestSchema.parse({
+ ...value,
+ reviewStatus: 'needs_review',
+ contentLocked: false,
+ segmentCount: segments.length,
+ totalNarrationUnits,
+ estimatedTotalDurationSeconds: roundSeconds(
+ totalNarrationUnits / value.narrationBudget.unitsPerMinute * 60
+ ),
+ segments
+ });
+}
+
+function roundSeconds(value: number): number {
+ return Math.round(value * 1_000) / 1_000;
+}
+
+function requireCurrentArtifact(
+ job: CreatorJob,
+ input: Record<string, CreatorJson>,
+ kind: string
+): CreatorArtifact {
+ const artifactId = readString(input.artifactId, 'artifactId');
+ const current = [...job.artifacts].reverse().find(artifact => (
+ artifact.kind === kind && artifact.status === 'completed'
+ ));
+ if (current === undefined || current.id !== artifactId) {
+ throw new CreatorServiceError('creator_stale_approval', `Current ${kind} artifact does not match`);
+ }
+ return current;
+}
+
+function requireApprovalRevision(job: CreatorJob, input: Record<string, CreatorJson>): void {
+ if (input.revision !== job.revision) {
+ throw new CreatorServiceError(
+ 'creator_revision_conflict',
+ 'Creator job revision changed',
+ job.revision
+ );
+ }
+}
+
+function staleFrom(
+ repository: CreatorRepository,
+ job: CreatorJob,
+ source: CreatorArtifact,
+ includeSource: boolean
+): string[] {
+ const result = includeSource ? [source.id] : [];
+ const queue = [source.id];
+ const visited = new Set<string>();
+ while (queue.length > 0) {
+ const id = queue.shift()!;
+ if (visited.has(id)) continue;
+ visited.add(id);
+ for (const artifact of job.artifacts) {
+ if (!artifact.sourceArtifactIds.includes(id)) continue;
+ result.push(artifact.id);
+ queue.push(artifact.id);
+ }
+ }
+ for (const id of new Set(result)) repository.setArtifactStatus(id, 'stale');
+ return [...new Set(result)];
+}
+
+function staleVisualPipeline(repository: CreatorRepository, job: CreatorJob): string[] {
+ const rootKinds = new Set([
+ 'character_reference',
+ 'style_reference',
+ 'style_contract',
+ 'image_prompt_pack'
+ ]);
+ const roots = job.artifacts.filter(artifact => (
+ artifact.status !== 'stale' && rootKinds.has(artifact.kind)
+ ));
+ const affected = new Set<string>();
+ for (const root of roots) {
+ for (const artifactId of staleFrom(repository, job, root, true)) {
+ affected.add(artifactId);
+ }
+ }
+ return [...affected];
+}
+
+function requireVisualAssetRef(
+ value: CreatorJson,
+ field: string
+): { assetId: string; revision: number } {
+ if (value === null || Array.isArray(value) || typeof value !== 'object') {
+ throw new CreatorServiceError('creator_action_input_invalid', `${field} must be an asset reference`);
+ }
+ const assetId = value.assetId;
+ const revision = value.revision;
+ if (
+ typeof assetId !== 'string'
+ || assetId.trim().length === 0
+ || typeof revision !== 'number'
+ || !Number.isSafeInteger(revision)
+ || revision <= 0
+ ) {
+ throw new CreatorServiceError('creator_action_input_invalid', `${field} must include assetId and revision`);
+ }
+ return { assetId: assetId.trim(), revision };
+}
+
+function sameAssetRef(
+ left: { assetId: string; revision: number },
+ right: { assetId: string; revision: number }
+): boolean {
+ return left.assetId === right.assetId && left.revision === right.revision;
+}
+
+function writeEditedJson(source: CreatorArtifact, fileName: string, value: unknown): string {
+ return writeEditedFile(source, fileName, `${JSON.stringify(value, null, 2)}\n`);
+}
+
+function writeEditedFile(source: CreatorArtifact, fileName: string, content: string): string {
+ if (source.path === null) throw new CreatorServiceError('creator_artifact_not_found', 'Artifact file is unavailable');
+ const path = join(dirname(source.path), fileName);
+ const temporary = `${path}.tmp`;
+ writeFileSync(temporary, content, 'utf8');
+ renameSync(temporary, path);
+ return path;
+}
+
+function sha256File(path: string): string {
+ return createHash('sha256').update(readFileSync(path)).digest('hex');
+}
+
+function readString(value: CreatorJson | undefined, field: string): string {
+ if (typeof value !== 'string' || value.length === 0) {
+ throw new CreatorServiceError('creator_action_input_invalid', `${field} is required`);
+ }
+ return value;
+}
+
+function readRecord(value: CreatorJson | undefined, field: string): Record<string, CreatorJson> {
+ if (value === null || value === undefined || Array.isArray(value) || typeof value !== 'object') {
+ throw new CreatorServiceError('creator_action_input_invalid', `${field} must be an object`);
+ }
+ return value;
+}
diff --git a/apps/daemon/src/creator/stickman/audio-executor.ts b/apps/daemon/src/creator/stickman/audio-executor.ts
new file mode 100644
index 00000000..d0a2430f
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/audio-executor.ts
@@ -0,0 +1,295 @@
+import { createHash } from 'node:crypto';
+import { readFile, writeFile } from 'node:fs/promises';
+import { join } from 'node:path';
+import type { CreatorArtifact, CreatorServicesConfig } from '@opencreator/protocol';
+import type { CreatorServicesConfigStore } from '../../creator-services/config-store.js';
+import type { KrillinTtsService } from '../krillin/tts-service.js';
+import type { CreatorExecutor, CreatorExecutorInput } from '../executor.js';
+import { CreatorExecutorError } from '../executor.js';
+import { CreatorProviderRequestLedger } from '../provider-requests.js';
+import { validateMediaFile, type MediaProbe } from '../validators/media.js';
+import {
+ stickmanAudioTimingSchema,
+ stickmanScriptManifestSchema
+} from './contracts.js';
+
+type Synthesize = Pick<KrillinTtsService, 'synthesize'>['synthesize'];
+
+export function createStickmanAudioExecutor(input: {
+ configStore: Pick<CreatorServicesConfigStore, 'read'>;
+ ttsService: Pick<KrillinTtsService, 'synthesize'>;
+ ledger: CreatorProviderRequestLedger;
+ ffprobePath: string;
+ synthesize?: Synthesize;
+ probe?: (path: string, ffprobe: string) => Promise<MediaProbe>;
+}): CreatorExecutor {
+ const synthesize = input.synthesize ?? (request => input.ttsService.synthesize(request));
+ const probe = input.probe ?? validateMediaFile;
+ return {
+ id: 'stickman-audio',
+ async run(stage) {
+ if (stage.stageRun.stageId === 'narration') {
+ return synthesizeSegment(stage, input, synthesize, probe);
+ }
+ if (stage.stageRun.stageId === 'audio-timing') {
+ return buildAudioTiming(stage, probe, input.ffprobePath);
+ }
+ throw new CreatorExecutorError(
+ 'creator_stage_not_supported',
+ `Unsupported stickman audio stage: ${stage.stageRun.stageId}`
+ );
+ }
+ };
+}
+
+async function synthesizeSegment(
+ stage: CreatorExecutorInput,
+ input: {
+ configStore: Pick<CreatorServicesConfigStore, 'read'>;
+ ledger: CreatorProviderRequestLedger;
+ ffprobePath: string;
+ },
+ synthesize: Synthesize,
+ probe: (path: string, ffprobe: string) => Promise<MediaProbe>
+) {
+ const scopeKey = stage.stageRun.scopeKey;
+ const fingerprint = stage.stageRun.inputFingerprint;
+ if (scopeKey === null || fingerprint === null) {
+ throw new CreatorExecutorError(
+ 'creator_stage_scope_missing',
+ 'Narration segment scope and fingerprint are required'
+ );
+ }
+ const scriptArtifact = requireArtifact(stage.inputArtifacts, 'script_manifest');
+ if (scriptArtifact.path === null) {
+ throw new CreatorExecutorError('creator_stage_input_missing', 'Script file is required');
+ }
+ const script = stickmanScriptManifestSchema.parse(JSON.parse(
+ await readFile(scriptArtifact.path, 'utf8')
+ ));
+ if (
+ stage.job.state.approvedScriptArtifactId !== scriptArtifact.id
+ || !script.contentLocked
+ || script.reviewStatus !== 'approved'
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_script_approval_required',
+ 'Narration requires the current locked script'
+ );
+ }
+ const segment = script.segments.find(candidate => candidate.id === scopeKey);
+ if (segment === undefined) {
+ throw new CreatorExecutorError('creator_narration_segment_missing', `Script segment ${scopeKey} was not found`);
+ }
+ const segmentIndex = script.segments.findIndex(candidate => candidate.id === scopeKey);
+ const segmentCount = script.segments.length;
+ const config = await input.configStore.read();
+ const selection = resolveTtsSelection(stage, config);
+ const requestKey = `${stage.job.id}:narration:${scopeKey}:${fingerprint}`;
+ const ledger = input.ledger.registerBeforeSubmit({
+ jobId: stage.job.id,
+ provider: selection.provider,
+ stageRunId: stage.stageRun.id,
+ scopeKey,
+ requestKey,
+ request: {
+ textSha256: createHash('sha256').update(segment.narration).digest('hex'),
+ provider: selection.provider,
+ model: selection.model,
+ voiceId: selection.voiceId,
+ format: 'wav'
+ }
+ });
+ input.ledger.markSubmitting(ledger.id);
+ stage.reportProgress({
+ phase: 'synthesizing',
+ percent: Math.round(((segmentIndex + 0.1) / segmentCount) * 100),
+ completed: segmentIndex,
+ failed: 0,
+ total: segmentCount,
+ ledgerId: ledger.id
+ });
+ try {
+ const result = await synthesize({
+ text: segment.narration,
+ provider: selection.provider,
+ model: selection.model,
+ voiceId: selection.voiceId,
+ format: 'wav',
+ signal: stage.signal
+ });
+ const path = join(stage.workdir, `${scopeKey}.wav`);
+ await writeFile(path, result.content);
+ const media = await probe(path, input.ffprobePath);
+ if (!media.hasAudio || media.duration <= 0) {
+ throw new CreatorExecutorError(
+ 'creator_audio_invalid',
+ `Narration for ${scopeKey} is not a valid audio file`
+ );
+ }
+ input.ledger.markSucceeded(ledger.id);
+ return {
+ outputs: [{
+ kind: 'narration_audio',
+ status: 'completed' as const,
+ path,
+ scopeKey,
+ inputFingerprint: fingerprint,
+ sourceArtifactIds: [scriptArtifact.id],
+ metadata: {
+ segmentId: scopeKey,
+ duration: media.duration,
+ hasAudio: media.hasAudio,
+ provider: result.provider,
+ model: result.model,
+ voiceId: result.voiceId,
+ mimeType: result.mime,
+ ledgerId: ledger.id,
+ timingSource: 'ffprobe'
+ }
+ }],
+ progress: {
+ phase: 'completed',
+ percent: Math.round(((segmentIndex + 1) / segmentCount) * 100),
+ completed: segmentIndex + 1,
+ failed: 0,
+ total: segmentCount,
+ ledgerId: ledger.id
+ }
+ };
+ } catch (error) {
+ input.ledger.markFailed(ledger.id);
+ if (error instanceof CreatorExecutorError) throw error;
+ if (hasErrorCode(error)) {
+ throw new CreatorExecutorError(error.code, error.message);
+ }
+ throw error;
+ }
+}
+
+async function buildAudioTiming(
+ stage: CreatorExecutorInput,
+ probe: (path: string, ffprobe: string) => Promise<MediaProbe>,
+ ffprobePath: string
+) {
+ const scriptArtifact = requireArtifact(stage.inputArtifacts, 'script_manifest');
+ if (scriptArtifact.path === null) {
+ throw new CreatorExecutorError('creator_stage_input_missing', 'Script file is required');
+ }
+ const script = stickmanScriptManifestSchema.parse(JSON.parse(
+ await readFile(scriptArtifact.path, 'utf8')
+ ));
+ const audioArtifacts = stage.inputArtifacts.filter(artifact => (
+ artifact.kind === 'narration_audio' && artifact.status === 'completed'
+ ));
+ const segments = [];
+ let cursor = 0;
+ for (const segment of script.segments) {
+ const candidates = audioArtifacts.filter(artifact => artifact.scopeKey === segment.id);
+ if (candidates.length !== 1) {
+ throw new CreatorExecutorError(
+ 'creator_narration_incomplete',
+ `Exactly one current narration artifact is required for ${segment.id}`
+ );
+ }
+ const audio = candidates[0]!;
+ if (audio.path === null || audio.sha256 === null) {
+ throw new CreatorExecutorError(
+ 'creator_artifact_hash_missing',
+ `Narration artifact for ${segment.id} is incomplete`
+ );
+ }
+ const media = await probe(audio.path, ffprobePath);
+ if (!media.hasAudio || media.duration <= 0) {
+ throw new CreatorExecutorError('creator_audio_invalid', `Narration for ${segment.id} is invalid`);
+ }
+ const startSeconds = roundSeconds(cursor);
+ const endSeconds = roundSeconds(startSeconds + media.duration);
+ segments.push({
+ segmentId: segment.id,
+ startSeconds,
+ endSeconds,
+ durationSeconds: roundSeconds(endSeconds - startSeconds),
+ audioArtifactId: audio.id,
+ audioSha256: audio.sha256
+ });
+ cursor = endSeconds;
+ }
+ const timing = stickmanAudioTimingSchema.parse({
+ scriptArtifactId: scriptArtifact.id,
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ segments,
+ totalDurationSeconds: roundSeconds(cursor)
+ });
+ const targetDurationSeconds = script.targetDurationSeconds;
+ const minimumTargetSeconds = roundSeconds(targetDurationSeconds * 0.9);
+ const maximumTargetSeconds = roundSeconds(targetDurationSeconds * 1.1);
+ const path = join(stage.workdir, 'audio-timing.json');
+ await writeFile(path, `${JSON.stringify(timing, null, 2)}\n`, 'utf8');
+ return {
+ outputs: [{
+ kind: 'audio_timing',
+ status: 'completed' as const,
+ path,
+ sourceArtifactIds: [scriptArtifact.id, ...audioArtifacts.map(artifact => artifact.id)],
+ metadata: {
+ timingSource: timing.timingSource,
+ segmentCount: timing.segments.length,
+ duration: timing.totalDurationSeconds,
+ targetDurationSeconds,
+ durationDeltaSeconds: roundSeconds(timing.totalDurationSeconds - targetDurationSeconds),
+ durationWithinTargetRange: timing.totalDurationSeconds >= minimumTargetSeconds
+ && timing.totalDurationSeconds <= maximumTargetSeconds
+ }
+ }],
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ };
+}
+
+function resolveTtsSelection(stage: CreatorExecutorInput, config: CreatorServicesConfig) {
+ const provider = stage.job.state.ttsProvider === 'openai'
+ || stage.job.state.ttsProvider === 'aliyun'
+ || stage.job.state.ttsProvider === 'minimax'
+ ? stage.job.state.ttsProvider
+ : config.tts.provider === 'edge-tts'
+ ? undefined
+ : config.tts.provider;
+ if (provider === undefined) {
+ throw new CreatorExecutorError(
+ 'creator_tts_config_missing',
+ '请先在 AI 服务的配音服务中配置可用的配音 Provider'
+ );
+ }
+ const providerConfig = config.tts[provider];
+ const model = typeof stage.job.state.ttsModel === 'string' && stage.job.state.ttsModel.trim()
+ ? stage.job.state.ttsModel.trim()
+ : providerConfig.model;
+ const voiceId = typeof stage.job.state.voiceCode === 'string' && stage.job.state.voiceCode.trim()
+ ? stage.job.state.voiceCode.trim()
+ : providerConfig.defaultVoiceId;
+ if (!voiceId) {
+ throw new CreatorExecutorError(
+ 'creator_tts_config_missing',
+ '请先在 AI 服务的配音服务中选择默认音色'
+ );
+ }
+ return { provider, model, voiceId };
+}
+
+function requireArtifact(artifacts: CreatorArtifact[], kind: string): CreatorArtifact {
+ const artifact = artifacts.find(item => item.kind === kind && item.status === 'completed');
+ if (artifact === undefined) {
+ throw new CreatorExecutorError('creator_stage_input_missing', `${kind} artifact is required`);
+ }
+ return artifact;
+}
+
+function roundSeconds(value: number): number {
+ return Math.round(value * 1_000) / 1_000;
+}
+
+function hasErrorCode(error: unknown): error is Error & { code: string } {
+ return error instanceof Error
+ && 'code' in error
+ && typeof (error as { code?: unknown }).code === 'string';
+}
diff --git a/apps/daemon/src/creator/stickman/codex-json-completion.ts b/apps/daemon/src/creator/stickman/codex-json-completion.ts
new file mode 100644
index 00000000..06dfe2d8
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/codex-json-completion.ts
@@ -0,0 +1,197 @@
+import { nanoid } from 'nanoid';
+import { resolve } from 'node:path';
+import type { AppServerRuntimeManager } from '../../codex/app-server-runtime-manager.js';
+import type { RuntimeThread } from '../../threads/types.js';
+import { CreatorExecutorError } from '../executor.js';
+
+const TURN_TIMEOUT_MS = 10 * 60_000;
+const TURN_INACTIVITY_TIMEOUT_MS = 2 * 60_000;
+const PROCESS_SPAWN_TIMEOUT_MS = 15_000;
+
+export type StickmanCodexJsonCompletionInput = {
+ stageId: string;
+ prompt: string;
+ signal: AbortSignal;
+ jobId: string;
+ projectId: string;
+ cwd: string;
+ model: string;
+};
+
+export function createStickmanCodexJsonCompletion(input: {
+ runtimeManager: AppServerRuntimeManager;
+}) {
+ return async (request: StickmanCodexJsonCompletionInput): Promise<unknown> => {
+ const runId = `stickman_json_${nanoid(12)}`;
+ const messages = new Map<string, AgentMessageRecord>();
+ const execution = input.runtimeManager.startTurn({
+ scope: { kind: 'creator-job', id: request.jobId },
+ runId,
+ thread: completionThread(request),
+ jobId: request.jobId,
+ projectId: request.projectId,
+ cwd: request.cwd,
+ profile: 'default',
+ sandbox: 'read-only',
+ ...(request.model.trim().length === 0 ? {} : { model: request.model.trim() }),
+ prompt: request.prompt,
+ developerInstructions: [
+ 'Return exactly one valid JSON value that satisfies the user prompt.',
+ 'Do not use Markdown fences, commentary, citations, or explanatory text.',
+ 'Do not call tools. Do not read or modify files. Do not access the network.'
+ ].join('\n'),
+ timeoutMs: TURN_TIMEOUT_MS,
+ inactivityTimeoutMs: TURN_INACTIVITY_TIMEOUT_MS,
+ spawnTimeoutMs: PROCESS_SPAWN_TIMEOUT_MS,
+ runtimeInjection: {
+ mcpServers: [],
+ env: {},
+ builtInTools: {
+ shell: false,
+ fileRead: false,
+ fileWrite: false,
+ applyPatch: false,
+ webSearch: false
+ },
+ configurationFingerprint: 'stickman-json-completion-v1'
+ },
+ onNotification(notification) {
+ recordAgentMessage(messages, notification);
+ }
+ });
+ const cancel = () => execution.cancel();
+ if (request.signal.aborted) cancel();
+ else request.signal.addEventListener('abort', cancel, { once: true });
+
+ try {
+ const result = await execution.result;
+ if (request.signal.aborted || result.turnStatus === 'interrupted') {
+ throw new CreatorExecutorError('creator_stage_canceled', 'Creator stage was canceled');
+ }
+ if (result.turnStatus !== 'completed') {
+ throw new CreatorExecutorError(
+ 'creator_llm_failed',
+ `Codex JSON completion failed during ${request.stageId}`
+ );
+ }
+ return parseJsonResponse(finalAgentMessage(messages));
+ } catch (error) {
+ if (request.signal.aborted) {
+ throw new CreatorExecutorError('creator_stage_canceled', 'Creator stage was canceled');
+ }
+ if (error instanceof CreatorExecutorError) throw error;
+ throw new CreatorExecutorError(
+ 'creator_llm_failed',
+ `Codex JSON completion failed during ${request.stageId}: ${errorMessage(error)}`
+ );
+ } finally {
+ request.signal.removeEventListener('abort', cancel);
+ }
+ };
+}
+
+function completionThread(input: StickmanCodexJsonCompletionInput): RuntimeThread {
+ const now = new Date().toISOString();
+ const cwd = resolve(input.cwd);
+ return {
+ id: `stickman-content-${input.jobId}`,
+ title: `Stickman content: ${input.stageId}`,
+ projectId: input.projectId,
+ origin: 'opencreator_created',
+ cwd,
+ canonicalCwd: cwd,
+ workspaceMode: 'external',
+ profile: 'default',
+ model: input.model.trim() || null,
+ reasoning: null,
+ sandbox: 'read-only',
+ status: 'active',
+ purpose: 'creator_agent',
+ createdAt: now,
+ updatedAt: now
+ };
+}
+
+type AgentMessageRecord = {
+ text: string;
+ phase: 'commentary' | 'final_answer' | null;
+};
+
+function recordAgentMessage(
+ messages: Map<string, AgentMessageRecord>,
+ notification: Record<string, unknown>
+): void {
+ const method = typeof notification.method === 'string' ? notification.method : '';
+ const params = readRecord(notification.params);
+ const item = readRecord(params?.item);
+ const itemId = typeof params?.itemId === 'string'
+ ? params.itemId
+ : typeof item?.id === 'string'
+ ? item.id
+ : null;
+ if (itemId === null) return;
+ const current = messages.get(itemId) ?? { text: '', phase: null };
+ if (item?.type === 'agentMessage') {
+ messages.set(itemId, {
+ phase: item.phase === 'commentary' || item.phase === 'final_answer'
+ ? item.phase
+ : current.phase,
+ text: agentMessageText(item) ?? current.text
+ });
+ return;
+ }
+ if (method === 'item/agentMessage/delta' && typeof params?.delta === 'string') {
+ messages.set(itemId, { ...current, text: current.text + params.delta });
+ }
+}
+
+function finalAgentMessage(messages: Map<string, AgentMessageRecord>): string {
+ const ordered = [...messages.values()];
+ return ordered.filter(message => message.phase === 'final_answer').at(-1)?.text
+ ?? ordered.filter(message => message.phase !== 'commentary').at(-1)?.text
+ ?? ordered.at(-1)?.text
+ ?? '';
+}
+
+function agentMessageText(item: Record<string, unknown>): string | undefined {
+ if (typeof item.text === 'string') return item.text;
+ if (!Array.isArray(item.content)) return undefined;
+ const text = item.content
+ .map(entry => readRecord(entry))
+ .map(entry => typeof entry?.text === 'string' ? entry.text : '')
+ .join('');
+ return text || undefined;
+}
+
+function parseJsonResponse(content: string): unknown {
+ const normalized = stripMarkdownFence(content.trim());
+ if (normalized.length === 0) {
+ throw new CreatorExecutorError(
+ 'creator_llm_invalid_response',
+ 'Codex response did not contain JSON'
+ );
+ }
+ try {
+ return JSON.parse(normalized) as unknown;
+ } catch {
+ throw new CreatorExecutorError(
+ 'creator_llm_invalid_response',
+ 'Codex response was not valid JSON'
+ );
+ }
+}
+
+function stripMarkdownFence(value: string): string {
+ const match = /^```(?:json)?\s*\r?\n?([\s\S]*?)\r?\n?```$/i.exec(value);
+ return match?.[1]?.trim() ?? value;
+}
+
+function readRecord(value: unknown): Record<string, unknown> | undefined {
+ return value !== null && typeof value === 'object' && !Array.isArray(value)
+ ? value as Record<string, unknown>
+ : undefined;
+}
+
+function errorMessage(error: unknown): string {
+ return error instanceof Error ? error.message : String(error);
+}
diff --git a/apps/daemon/src/creator/stickman/content-executor.ts b/apps/daemon/src/creator/stickman/content-executor.ts
new file mode 100644
index 00000000..ab08573a
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/content-executor.ts
@@ -0,0 +1,1111 @@
+import { readFile, rename, writeFile } from 'node:fs/promises';
+import { extname, join } from 'node:path';
+import sharp from 'sharp';
+import { z } from 'zod';
+import type { CreatorServicesConfigStore } from '../../creator-services/config-store.js';
+import type { CreatorArtifact, CreatorJson } from '@opencreator/protocol';
+import type { CreatorExecutor, CreatorExecutorInput, CreatorExecutorOutput } from '../executor.js';
+import { CreatorExecutorError } from '../executor.js';
+import {
+ stickmanContentPlanSchema,
+ stickmanAudioTimingSchema,
+ stickmanImagePromptPackSchema,
+ stickmanScriptManifestSchema,
+ stickmanShotSpecSchema,
+ stickmanStyleContractSchema,
+ stickmanSourceBriefSchema
+} from './contracts.js';
+import {
+ buildStickmanImagePrompt,
+ STICKMAN_IMAGE_PROMPT_CONTRACT,
+ shouldUsePreviousShotReference
+} from './image-prompt.js';
+import {
+ DEFAULT_STICKMAN_CHARACTER_ASSET,
+ DEFAULT_STICKMAN_STYLE_ASSET,
+ readVisualAssetRef,
+ type ResolvedVisualAssetFile,
+ type StickmanVisualAssetRegistry
+} from './visual-assets.js';
+
+type CompleteJson = (input: {
+ stageId: string;
+ prompt: string;
+ signal: AbortSignal;
+}) => Promise<unknown>;
+
+type CodexCompleteJson = (input: {
+ stageId: string;
+ prompt: string;
+ signal: AbortSignal;
+ jobId: string;
+ projectId: string;
+ cwd: string;
+ model: string;
+}) => Promise<unknown>;
+
+const PREFERRED_SCRIPT_SEGMENT_SECONDS = 4;
+const MAX_ESTIMATED_SCRIPT_SEGMENT_SECONDS = 4.5;
+
+const generatedSourceBriefSchema = z.object({
+ title: z.string().trim().min(1),
+ summary: z.string().trim().min(1),
+ audience: z.string().trim().min(1),
+ claims: z.array(z.object({
+ id: z.string().regex(/^claim-\d{3}$/),
+ text: z.string().trim().min(1),
+ sourceSpanIds: z.array(z.string().regex(/^source-\d{3}$/)).min(1).max(200)
+ }).strict()).min(1).max(200)
+}).strict();
+
+const generatedContentPlanSchema = z.object({
+ title: z.string().trim().min(1),
+ audience: z.string().trim().min(1),
+ objective: z.string().trim().min(1),
+ retainedClaimIds: z.array(z.string().regex(/^claim-\d{3}$/)).min(1).max(200),
+ discardedClaimIds: z.array(z.string().regex(/^claim-\d{3}$/)).max(200),
+ sections: z.array(z.object({
+ id: z.string().regex(/^section-\d{2}$/),
+ title: z.string().trim().min(1),
+ claimIds: z.array(z.string().regex(/^claim-\d{3}$/)).min(1).max(200)
+ }).strict()).min(1).max(200)
+}).strict();
+
+const generatedShotScriptSchema = z.object({
+ title: z.string().trim().min(1),
+ segments: z.array(z.object({
+ narration: z.string().trim().min(1),
+ claimIds: z.array(z.string().regex(/^claim-\d{3}$/)).min(1).max(200),
+ sourceSpanIds: z.array(z.string().regex(/^source-\d{3}$/)).min(1).max(200)
+ }).strict()).min(1).max(200)
+}).strict();
+
+const generatedStoryboardSchema = z.object({
+ shots: z.array(z.object({
+ sourceSegmentId: z.string().regex(/^segment-[a-z0-9-]+$/),
+ semanticAnchor: z.string().trim().min(1),
+ visualDescription: z.string().trim().min(1),
+ compositionAndAction: z.string().trim().min(1),
+ keyObjects: z.array(z.string().trim().min(1)).min(1).max(12),
+ continuityReason: z.string().trim(),
+ motion: z.enum(['static', 'push-in', 'pan-left', 'pan-right', 'zoom-out']),
+ motionReason: z.string().trim().min(1)
+ }).strict()).min(1).max(200)
+}).strict();
+
+export function createStickmanContentExecutor(input: {
+ configStore: Pick<CreatorServicesConfigStore, 'read'>;
+ completeJson?: CompleteJson;
+ codexCompleteJson?: CodexCompleteJson;
+ visualAssets?: StickmanVisualAssetRegistry;
+}): CreatorExecutor {
+ return {
+ id: 'stickman-content',
+ async run(stage) {
+ const completeJson = input.completeJson ?? createStickmanConfiguredCompletion({
+ configStore: input.configStore,
+ codexCompleteJson: input.codexCompleteJson,
+ context: {
+ jobId: stage.job.id,
+ projectId: stage.job.projectId,
+ cwd: stage.workdir
+ }
+ });
+ switch (stage.stageRun.stageId) {
+ case 'ingest-text': return ingestText(stage);
+ case 'source-brief': return sourceBrief(stage, completeJson);
+ case 'content-plan': return contentPlan(stage, completeJson);
+ case 'script': return script(stage, completeJson);
+ case 'storyboard': return storyboard(stage, completeJson);
+ case 'style-assets': return styleAssets(stage, input.visualAssets);
+ case 'prompt-pack': return promptPack(stage);
+ default: throw new CreatorExecutorError(
+ 'creator_stage_not_supported',
+ `Unsupported stickman content stage: ${stage.stageRun.stageId}`
+ );
+ }
+ }
+ };
+}
+
+async function ingestText(stage: CreatorExecutorInput) {
+ stage.reportProgress({
+ phase: 'preparing_source',
+ percent: 25,
+ completed: 0,
+ failed: 0,
+ total: 1
+ });
+ const sourceText = readStateString(stage, 'sourceText', '');
+ if (sourceText.length === 0) {
+ throw new CreatorExecutorError('creator_stage_input_missing', 'Source text is required');
+ }
+ const path = join(stage.workdir, 'source-text.txt');
+ await writeAtomic(path, `${sourceText}\n`);
+ return {
+ outputs: [{
+ kind: 'source_text',
+ status: 'completed' as const,
+ path,
+ sourceArtifactIds: [],
+ metadata: { fileName: 'source-text.txt', characterCount: sourceText.length }
+ }],
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ };
+}
+
+async function sourceBrief(stage: CreatorExecutorInput, complete: CompleteJson) {
+ stage.reportProgress({ phase: 'analyzing', percent: 15, completed: 0, failed: 0, total: 1 });
+ const sourceKind = stage.job.state.sourceType === 'text' ? 'source_text' : 'source_subtitle';
+ const source = requireArtifact(stage, sourceKind);
+ const transcript = source.path === null ? '' : await readFile(source.path, 'utf8');
+ const sourceSpans = buildSourceSpans(transcript, sourceKind);
+ const generated = await complete({
+ stageId: 'source-brief',
+ prompt: `你是来源证据分析员。请把以下带稳定编号的来源片段拆成可独立保留或舍弃的内容 Claim,只返回严格 JSON,不要 Markdown。
+每个 Claim 必须是来源直接支持的完整含义,字段固定为 id、text、sourceSpanIds;id 从 claim-001 连续编号;sourceSpanIds 必须引用实际支持它的来源片段。
+必须覆盖每个来源片段,不能只摘录重点,也不能新增来源中没有的事实、人物属性、因果、结论或常识。重复信息可以合并为一个 Claim,但合并后必须列出全部来源片段。
+输出结构:{"title":"标题","summary":"摘要","audience":"受众","claims":[{"id":"claim-001","text":"来源事实","sourceSpanIds":["source-001"]}]}。
+来源片段:${JSON.stringify(sourceSpans)}`,
+ signal: stage.signal
+ });
+ stage.reportProgress({ phase: 'analyzing', percent: 85, completed: 0, failed: 0, total: 1 });
+ const generatedBrief = generatedSourceBriefSchema.parse(
+ normalizeGeneratedJson('source-brief', generated)
+ );
+ const value = stickmanSourceBriefSchema.parse({ ...generatedBrief, sourceSpans });
+ return {
+ ...await jsonOutput(stage, 'source_brief', 'source-brief.json', value, [source.id]),
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ };
+}
+
+async function contentPlan(stage: CreatorExecutorInput, complete: CompleteJson) {
+ stage.reportProgress({ phase: 'planning', percent: 15, completed: 0, failed: 0, total: 1 });
+ const source = requireArtifact(stage, 'source_brief');
+ const brief = stickmanSourceBriefSchema.parse(await readJson(source));
+ const targetDurationSeconds = readStateNumber(stage, 'targetDurationSeconds', 30);
+ const targetLanguage = readStateString(stage, 'targetLanguage', 'zh-CN');
+ const narrationBudget = narrationBudgetFor(targetDurationSeconds, targetLanguage);
+ const generated = await complete({
+ stageId: 'content-plan',
+ prompt: `你是短视频内容策划。请在目标时长内对来源 Claim 做明确取舍,只返回严格 JSON,不要 Markdown。
+所有 Claim 必须且只能进入 retainedClaimIds 或 discardedClaimIds 之一,不能静默遗漏。sections 只能引用 retainedClaimIds,并且必须覆盖每个保留 Claim。
+保留最能构成完整叙事的内容;当预算不足时,明确舍弃次要 Claim,不要把一个 Claim 截成残缺语义,不要补充来源之外的知识。
+这里只规划内容,不讨论角色、火柴人、镜头、画面、动画、字幕、配音或生图方式。
+目标时长:${targetDurationSeconds} 秒。
+旁白预算:${JSON.stringify(narrationBudget)}。
+输出结构:{"title":"标题","audience":"受众","objective":"目标","retainedClaimIds":["claim-001"],"discardedClaimIds":[],"sections":[{"id":"section-01","title":"章节","claimIds":["claim-001"]}]}。
+来源 Claim:${JSON.stringify(brief)}`,
+ signal: stage.signal
+ });
+ stage.reportProgress({ phase: 'planning', percent: 85, completed: 0, failed: 0, total: 1 });
+ const generatedPlan = generatedContentPlanSchema.parse(
+ normalizeGeneratedJson('content-plan', generated)
+ );
+ const value = stickmanContentPlanSchema.parse({
+ ...generatedPlan,
+ targetDurationSeconds,
+ narrationBudget
+ });
+ assertContentPlanClaims(value, brief);
+ return {
+ ...await jsonOutput(stage, 'content_plan', 'content-plan.json', value, [source.id]),
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ };
+}
+
+async function script(stage: CreatorExecutorInput, complete: CompleteJson) {
+ stage.reportProgress({ phase: 'writing', percent: 15, completed: 0, failed: 0, total: 1 });
+ const planArtifact = requireArtifact(stage, 'content_plan');
+ const sourceBriefArtifact = requireArtifact(stage, 'source_brief');
+ const plan = stickmanContentPlanSchema.parse(await readJson(planArtifact));
+ const sourceBrief = stickmanSourceBriefSchema.parse(await readJson(sourceBriefArtifact));
+ const targetLanguage = readStateString(stage, 'targetLanguage', 'zh-CN');
+ let draft: unknown;
+ let failures: string[] = [];
+
+ for (let attempt = 0; attempt < 3; attempt += 1) {
+ draft = await complete({
+ stageId: 'script',
+ prompt: shotScriptPrompt({
+ sourceBrief,
+ plan,
+ targetLanguage,
+ draftToRepair: attempt === 0 ? undefined : draft,
+ validationFailures: failures
+ }),
+ signal: stage.signal
+ });
+ const finalized = finalizeShotScript(draft, sourceBrief, plan, targetLanguage);
+ if (finalized.script !== undefined) {
+ const manifestPath = await writeJsonArtifact(stage, 'script-manifest.json', finalized.script);
+ const outputs: CreatorExecutorOutput[] = [{
+ kind: 'script_manifest',
+ status: 'completed',
+ path: manifestPath,
+ sourceArtifactIds: [planArtifact.id, sourceBriefArtifact.id],
+ metadata: {
+ contract: finalized.script.contract,
+ segmentCount: finalized.script.segmentCount,
+ retainedClaimCount: plan.retainedClaimIds.length,
+ discardedClaimCount: plan.discardedClaimIds.length,
+ generationAttempts: attempt + 1
+ }
+ }];
+ return {
+ outputs,
+ progress: {
+ phase: 'completed',
+ percent: 100,
+ message: '脚本已生成,等待审核',
+ completed: 1,
+ failed: 0,
+ total: 1
+ }
+ };
+ }
+ failures = finalized.failures;
+ stage.reportProgress({
+ phase: 'writing',
+ percent: 40 + attempt * 25,
+ message: `脚本第 ${attempt + 1} 次生成未通过完整性校验,正在整稿重生成`,
+ completed: 0,
+ failed: 1,
+ total: 1
+ });
+ }
+
+ throw new CreatorExecutorError(
+ 'creator_script_validation_failed',
+ `脚本在 3 次整稿生成后仍未通过校验:${formatScriptFailures(failures)}`
+ );
+}
+
+function narrationBudgetFor(
+ targetDurationSeconds: number,
+ targetLanguage: string
+): z.infer<typeof stickmanContentPlanSchema>['narrationBudget'] {
+ const usesCharacters = /^(?:zh|ja|ko)(?:-|$)/iu.test(targetLanguage);
+ const unitsPerMinute = usesCharacters ? 240 : 179;
+ const expectedUnits = targetDurationSeconds / 60 * unitsPerMinute;
+ return {
+ unit: usesCharacters ? 'characters' : 'words',
+ unitsPerMinute,
+ minUnits: Math.max(1, Math.ceil(expectedUnits * 0.9)),
+ maxUnits: Math.max(1, Math.floor(expectedUnits * 1.1))
+ };
+}
+
+function countNarrationUnits(
+ narration: string,
+ unit: 'characters' | 'words'
+): number {
+ if (unit === 'words') {
+ return narration.match(/[\p{L}\p{N}]+(?:['’-][\p{L}\p{N}]+)*/gu)?.length ?? 0;
+ }
+ return narration.match(/[\p{L}\p{N}]/gu)?.length ?? 0;
+}
+
+function shotScriptPrompt(input: {
+ sourceBrief: z.infer<typeof stickmanSourceBriefSchema>;
+ plan: z.infer<typeof stickmanContentPlanSchema>;
+ targetLanguage: string;
+ draftToRepair?: unknown;
+ validationFailures: string[];
+}): string {
+ const claims = input.sourceBrief.claims.filter(claim => (
+ input.plan.retainedClaimIds.includes(claim.id)
+ ));
+ const sourceSpanIds = new Set(claims.flatMap(claim => claim.sourceSpanIds));
+ const sourceSpans = input.sourceBrief.sourceSpans.filter(span => sourceSpanIds.has(span.id));
+ const repair = input.draftToRepair === undefined
+ ? ''
+ : `
+上一份完整草稿:${JSON.stringify(input.draftToRepair)}`
+ + `
+校验失败原因:${JSON.stringify(input.validationFailures)}`
+ + '\n请根据失败原因重新生成整份脚本,不要只返回局部修改。';
+ const preferredUnits = Math.max(1, Math.floor(
+ input.plan.narrationBudget.unitsPerMinute / 60 * PREFERRED_SCRIPT_SEGMENT_SECONDS
+ ));
+ const maximumUnits = Math.max(1, Math.floor(
+ input.plan.narrationBudget.unitsPerMinute / 60 * MAX_ESTIMATED_SCRIPT_SEGMENT_SECONDS
+ ));
+ return `你负责生成知识视频旁白。来源 Claim 和来源片段是唯一事实来源。只生成可直接用于配音的旁白单元,不要生成画面、镜头、生图或制作说明;只返回严格 JSON,不要 Markdown。
+旁白使用 ${input.targetLanguage},只能对保留 Claim 做忠实、自然、连贯的改写,不得新增事实。每段只表达一个完整语义节拍,必须可以独立朗读并自然停顿;长内容要改写成多个完整句意,不得按字数截断句子;无独立意义的过渡语要合并到相邻段落。
+每段按正常语速设计为约 3-${PREFERRED_SCRIPT_SEGMENT_SECONDS} 秒,估算最多不超过 ${MAX_ESTIMATED_SCRIPT_SEGMENT_SECONDS} 秒,为真实配音的停顿和韵律留出余量。当前语速预算下,每段建议不超过 ${preferredUnits} ${input.plan.narrationBudget.unit === 'characters' ? '个有效字符' : '个单词'},绝对不超过 ${maximumUnits};这是生成目标,不能通过截断语义满足。
+每段必须填写 claimIds 和 sourceSpanIds。所有 retainedClaimIds 必须至少被一段覆盖;不得引用 discardedClaimIds;引用的来源片段必须确实属于该 Claim。
+旁白只能讲来源内容,不得出现角色设定、火柴人、镜头、画面、动画、字幕、配音、生图等制作过程。不要为了凑时长重复同一含义。
+整份旁白的${input.plan.narrationBudget.unit === 'characters' ? '有效字符数' : '单词数'}必须在 ${input.plan.narrationBudget.minUnits}-${input.plan.narrationBudget.maxUnits} 之间,对应 ${input.plan.targetDurationSeconds} 秒目标;优先保持语义完整,不要重复同一含义凑时长。
+输出结构:{"title":"标题","segments":[{"narration":"完整旁白","claimIds":["claim-001"],"sourceSpanIds":["source-001"]}]}。
+内容计划:${JSON.stringify(input.plan)}
+保留 Claim:${JSON.stringify(claims)}
+对应来源片段:${JSON.stringify(sourceSpans)}${repair}`;
+}
+
+function finalizeShotScript(
+ payload: unknown,
+ sourceBrief: z.infer<typeof stickmanSourceBriefSchema>,
+ plan: z.infer<typeof stickmanContentPlanSchema>,
+ targetLanguage: string
+): { script?: z.infer<typeof stickmanScriptManifestSchema>; failures: string[] } {
+ const parsed = generatedShotScriptSchema.safeParse(normalizeGeneratedJson('script', payload));
+ if (!parsed.success) {
+ return {
+ failures: parsed.error.issues.map(issue => (
+ `invalid script response at ${issue.path.join('.') || 'root'}: ${issue.message}`
+ ))
+ };
+ }
+
+ const retained = new Set(plan.retainedClaimIds);
+ const claimSpans = new Map(sourceBrief.claims.map(claim => [
+ claim.id,
+ new Set(claim.sourceSpanIds)
+ ]));
+ const coveredClaims = new Set<string>();
+ const failures: string[] = [];
+ const normalizedNarrations = new Map<string, string>();
+ const segments = parsed.data.segments.map((raw, index) => {
+ const id = `segment-${String(index + 1).padStart(2, '0')}`;
+ const claimIds = [...new Set(raw.claimIds)];
+ const sourceSpanIds = [...new Set(raw.sourceSpanIds)];
+ const narration = raw.narration.trim();
+
+ if (!/[。!?!?;;.]\s*["'”’))\]]?$/u.test(narration)) {
+ failures.push(`${id} 的旁白不是完整句子`);
+ }
+ if (claimIds.some(claimId => !retained.has(claimId))) {
+ failures.push(`${id} 引用了未保留或不存在的 Claim`);
+ }
+ const supportedSpans = new Set(
+ claimIds.flatMap(claimId => [...(claimSpans.get(claimId) ?? [])])
+ );
+ if (sourceSpanIds.some(sourceSpanId => !supportedSpans.has(sourceSpanId))) {
+ failures.push(`${id} 的来源片段不受其 Claim 支持`);
+ }
+ claimIds.forEach(claimId => coveredClaims.add(claimId));
+
+ const normalized = normalizeScriptText(narration);
+ if (normalizedNarrations.has(normalized)) {
+ failures.push(`${id} 与 ${normalizedNarrations.get(normalized)} 的旁白重复`);
+ } else {
+ normalizedNarrations.set(normalized, id);
+ }
+ const narrationUnits = countNarrationUnits(narration, plan.narrationBudget.unit);
+ const estimatedDurationSeconds = roundSeconds(
+ narrationUnits / plan.narrationBudget.unitsPerMinute * 60
+ );
+ if (estimatedDurationSeconds > MAX_ESTIMATED_SCRIPT_SEGMENT_SECONDS) {
+ failures.push(`${id} 的预计配音时长 ${estimatedDurationSeconds} 秒超过 ${MAX_ESTIMATED_SCRIPT_SEGMENT_SECONDS} 秒,请按完整语义重新拆成多个旁白单元`);
+ }
+ return {
+ id,
+ order: index + 1,
+ narration,
+ claimIds,
+ sourceSpanIds,
+ narrationUnits,
+ estimatedDurationSeconds
+ };
+ });
+
+ const missingClaims = plan.retainedClaimIds.filter(claimId => !coveredClaims.has(claimId));
+ if (missingClaims.length > 0) {
+ failures.push(`保留 Claim 未被脚本覆盖:${missingClaims.join('、')}`);
+ }
+ const totalNarrationUnits = segments.reduce((total, segment) => (
+ total + segment.narrationUnits
+ ), 0);
+ if (
+ totalNarrationUnits < plan.narrationBudget.minUnits
+ || totalNarrationUnits > plan.narrationBudget.maxUnits
+ ) {
+ failures.push(
+ `旁白总${plan.narrationBudget.unit === 'characters' ? '字符' : '词'}数 ${totalNarrationUnits} `
+ + `不在预算 ${plan.narrationBudget.minUnits}-${plan.narrationBudget.maxUnits} 内`
+ );
+ }
+ if (failures.length > 0) return { failures: [...new Set(failures)] };
+
+ const estimatedTotalDurationSeconds = roundSeconds(
+ totalNarrationUnits / plan.narrationBudget.unitsPerMinute * 60
+ );
+ const script = stickmanScriptManifestSchema.parse({
+ contract: 'stickman-narration-script-v2',
+ reviewStatus: 'needs_review',
+ contentLocked: false,
+ title: parsed.data.title,
+ language: targetLanguage,
+ targetDurationSeconds: plan.targetDurationSeconds,
+ narrationBudget: plan.narrationBudget,
+ segmentCount: segments.length,
+ totalNarrationUnits,
+ estimatedTotalDurationSeconds,
+ segments
+ });
+ return { script, failures: [] };
+}
+
+function assertContentPlanClaims(
+ plan: z.infer<typeof stickmanContentPlanSchema>,
+ brief: z.infer<typeof stickmanSourceBriefSchema>
+): void {
+ const expected = new Set(brief.claims.map(claim => claim.id));
+ const planned = new Set([...plan.retainedClaimIds, ...plan.discardedClaimIds]);
+ const missing = [...expected].filter(claimId => !planned.has(claimId));
+ const unknown = [...planned].filter(claimId => !expected.has(claimId));
+ if (missing.length > 0 || unknown.length > 0 || planned.size !== expected.size) {
+ throw new CreatorExecutorError(
+ 'creator_content_plan_claim_partition_invalid',
+ [
+ missing.length > 0 ? `未处理 Claim:${missing.join('、')}` : '',
+ unknown.length > 0 ? `未知 Claim:${unknown.join('、')}` : ''
+ ].filter(Boolean).join(';') || '内容计划的 Claim 取舍无效'
+ );
+ }
+}
+
+function requestsVisibleText(value: string): boolean {
+ return /字幕|标题|标签|文字|水印|写着|标注|caption|headline|label|lettering|subtitle|watermark|\btext\b|written|labeled/iu.test(value);
+}
+
+function formatScriptFailures(failures: string[]): string {
+ return [...new Set(failures)].join(';');
+}
+
+function roundSeconds(value: number): number {
+ return Math.round(value * 1_000) / 1_000;
+}
+
+async function storyboard(stage: CreatorExecutorInput, complete: CompleteJson) {
+ stage.reportProgress({ phase: 'planning', percent: 15, completed: 0, failed: 0, total: 1 });
+ const scriptArtifact = requireArtifact(stage, 'script_manifest');
+ const timingArtifact = requireArtifact(stage, 'audio_timing');
+ const scriptValue = stickmanScriptManifestSchema.parse(await readJson(scriptArtifact));
+ const timing = stickmanAudioTimingSchema.parse(await readJson(timingArtifact));
+ const timingBySegment = new Map(timing.segments.map(segment => [segment.segmentId, segment]));
+ let draft: unknown;
+ let failures: string[] = [];
+ let value: z.infer<typeof stickmanShotSpecSchema> | undefined;
+ for (let attempt = 0; attempt < 3; attempt += 1) {
+ draft = await complete({
+ stageId: 'storyboard',
+ prompt: storyboardPrompt({
+ script: scriptValue,
+ timing,
+ draftToRepair: attempt === 0 ? undefined : draft,
+ validationFailures: failures
+ }),
+ signal: stage.signal
+ });
+ const finalized = finalizeStoryboard({
+ payload: draft,
+ scriptArtifactId: scriptArtifact.id,
+ audioTimingArtifactId: timingArtifact.id,
+ script: scriptValue,
+ timingBySegment
+ });
+ if (finalized.storyboard !== undefined) {
+ value = finalized.storyboard;
+ break;
+ }
+ failures = finalized.failures;
+ stage.reportProgress({
+ phase: 'planning',
+ percent: 40 + attempt * 25,
+ message: `分镜第 ${attempt + 1} 次生成未通过语义契约,正在整稿重生成`,
+ completed: 0,
+ failed: 1,
+ total: 1
+ });
+ }
+ if (value === undefined) {
+ throw new CreatorExecutorError(
+ 'creator_storyboard_validation_failed',
+ `分镜在 3 次整稿生成后仍未通过校验:${formatScriptFailures(failures)}`
+ );
+ }
+ const shotSpec = await writeJsonArtifact(stage, 'shot-spec.json', value);
+ const outputs: CreatorExecutorOutput[] = [
+ {
+ kind: 'shot_spec',
+ status: 'completed',
+ path: shotSpec,
+ sourceArtifactIds: [scriptArtifact.id, timingArtifact.id],
+ metadata: {
+ shotCount: value.shots.length,
+ contract: 'stickman-semantic-storyboard-v3',
+ timingSource: timing.timingSource
+ }
+ }
+ ];
+ return {
+ outputs,
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ };
+}
+
+function storyboardPrompt(input: {
+ script: z.infer<typeof stickmanScriptManifestSchema>;
+ timing: z.infer<typeof stickmanAudioTimingSchema>;
+ draftToRepair?: unknown;
+ validationFailures: string[];
+}): string {
+ const rows = input.script.segments.map(segment => ({
+ segmentId: segment.id,
+ narration: segment.narration,
+ startSeconds: input.timing.segments.find(item => item.segmentId === segment.id)?.startSeconds,
+ endSeconds: input.timing.segments.find(item => item.segmentId === segment.id)?.endSeconds,
+ durationSeconds: input.timing.segments.find(item => item.segmentId === segment.id)?.durationSeconds
+ }));
+ const repair = input.draftToRepair === undefined
+ ? ''
+ : `\n上一份完整分镜:${JSON.stringify(input.draftToRepair)}\n校验失败原因:${JSON.stringify(input.validationFailures)}\n请重新生成整份分镜。`;
+ return `你负责把已经审核并完成真实配音的旁白转换成语义分镜,只返回严格 JSON,不要 Markdown。
+每个 sourceSegmentId 必须且只能出现一次,并保持输入顺序。每个旁白单元生成一张图,严格采用提供的真实起止时间,不得合并或拆分时间。
+visualDescription 是真正用于生图的画面描述:只写当前画面中的主体关系、动作、环境和可见物,不写旁白原文,不写角色长相,不写绘画风格,不要求任何文字、数字、字幕、标题、标签、Logo、界面或分屏。
+semanticAnchor 概括画面必须传达的唯一含义;compositionAndAction 描述主体位置、视线、动作方向和空间关系;keyObjects 只列支撑含义的必要物体;continuityReason 说明与前后镜头如何连续,没有要求时返回空字符串。
+motion 必须由构图和叙事意图选择:静态说明用 static,聚焦主体用 push-in,揭示全局用 zoom-out,只有存在明确横向关注移动时才使用 pan-left 或 pan-right。motionReason 必须说明选择原因,不能按序号轮换。
+角色身份和视觉风格由后续统一契约与真实参考图负责,本阶段不得重新设计人物。
+输出结构:{"shots":[{"sourceSegmentId":"segment-01","semanticAnchor":"唯一画面含义","visualDescription":"可直接生图的具体场景","compositionAndAction":"主体位置与动作","keyObjects":["必要道具"],"continuityReason":"连续性说明或空字符串","motion":"push-in","motionReason":"聚焦主体动作"}]}。
+旁白与真实时长:${JSON.stringify(rows)}${repair}`;
+}
+
+function finalizeStoryboard(input: {
+ payload: unknown;
+ scriptArtifactId: string;
+ audioTimingArtifactId: string;
+ script: z.infer<typeof stickmanScriptManifestSchema>;
+ timingBySegment: Map<string, z.infer<typeof stickmanAudioTimingSchema>['segments'][number]>;
+}): { storyboard?: z.infer<typeof stickmanShotSpecSchema>; failures: string[] } {
+ const parsed = generatedStoryboardSchema.safeParse(
+ normalizeGeneratedJson('storyboard', input.payload)
+ );
+ if (!parsed.success) {
+ return {
+ failures: parsed.error.issues.map(issue => (
+ `invalid storyboard response at ${issue.path.join('.') || 'root'}: ${issue.message}`
+ ))
+ };
+ }
+ const expectedIds = input.script.segments.map(segment => segment.id);
+ const actualIds = parsed.data.shots.map(shot => shot.sourceSegmentId);
+ const failures: string[] = [];
+ if (JSON.stringify(actualIds) !== JSON.stringify(expectedIds)) {
+ failures.push('分镜必须按顺序完整覆盖每个旁白单元,且每个单元只能出现一次');
+ }
+ for (const shot of parsed.data.shots) {
+ if (requestsVisibleText(shot.visualDescription)) {
+ failures.push(`${shot.sourceSegmentId} 的画面描述要求生成可见文字`);
+ }
+ }
+ if (failures.length > 0) return { failures };
+ try {
+ return {
+ storyboard: stickmanShotSpecSchema.parse({
+ scriptArtifactId: input.scriptArtifactId,
+ audioTimingArtifactId: input.audioTimingArtifactId,
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ shots: parsed.data.shots.map((shot, index) => {
+ const measured = input.timingBySegment.get(shot.sourceSegmentId);
+ if (measured === undefined) {
+ throw new CreatorExecutorError(
+ 'creator_audio_timing_incomplete',
+ `Audio timing is missing script segment ${shot.sourceSegmentId}`
+ );
+ }
+ return {
+ id: `shot-${String(index + 1).padStart(2, '0')}`,
+ ...shot,
+ startSeconds: measured.startSeconds,
+ endSeconds: measured.endSeconds,
+ durationSeconds: measured.durationSeconds
+ };
+ })
+ }),
+ failures: []
+ };
+ } catch (error) {
+ if (error instanceof CreatorExecutorError) throw error;
+ return { failures: [error instanceof Error ? error.message : String(error)] };
+ }
+}
+
+async function styleAssets(
+ stage: CreatorExecutorInput,
+ visualAssets: StickmanVisualAssetRegistry | undefined
+) {
+ if (visualAssets === undefined) {
+ throw new CreatorExecutorError(
+ 'creator_stickman_runtime_unavailable',
+ 'Stickman visual asset catalog is unavailable'
+ );
+ }
+ const characterRef = readVisualAssetRef(
+ stage.job.state.characterAsset,
+ DEFAULT_STICKMAN_CHARACTER_ASSET
+ );
+ const styleRef = readVisualAssetRef(
+ stage.job.state.styleAsset,
+ DEFAULT_STICKMAN_STYLE_ASSET
+ );
+ const character = visualAssets.character(characterRef);
+ const style = visualAssets.style(styleRef);
+ const characterReferences = visualAssets.referenceFiles(character);
+ const styleReferences = visualAssets.referenceFiles(style);
+ const primaryCharacter = characterReferences[0];
+ if (primaryCharacter === undefined) {
+ throw new CreatorExecutorError(
+ 'creator_character_reference_invalid',
+ 'Selected character has no identity reference'
+ );
+ }
+ const content = await readFile(primaryCharacter.path);
+ const dimensions = await sharp(content).metadata();
+ if (!dimensions.width || !dimensions.height) {
+ throw new CreatorExecutorError(
+ 'creator_character_reference_invalid',
+ 'Selected character reference is not a decodable image'
+ );
+ }
+ const fileName = `character-reference${extname(primaryCharacter.path).toLowerCase()}`;
+ const characterPath = join(stage.workdir, fileName);
+ await writeFile(characterPath, content);
+ const styleContract = stickmanStyleContractSchema.parse({
+ contract: 'stickman-visual-profile-v2',
+ ratio: '16:9',
+ character: {
+ assetId: character.id,
+ revision: character.revision,
+ identity: character.identity,
+ references: characterReferences.map(referenceContract)
+ },
+ style: {
+ assetId: style.id,
+ revision: style.revision,
+ rendering: style.rendering,
+ semanticRenderingRules: style.semanticRenderingRules,
+ forbiddenDirections: style.forbiddenDirections,
+ references: styleReferences.map(referenceContract)
+ }
+ });
+ const styleContractPath = await writeJsonArtifact(stage, 'style-contract.json', styleContract);
+ const sourceArtifactIds = stage.inputArtifacts.map(artifact => artifact.id);
+ const outputs: CreatorExecutorOutput[] = [
+ {
+ kind: 'character_reference',
+ status: 'completed',
+ path: characterPath,
+ sourceArtifactIds,
+ metadata: {
+ assetId: character.id,
+ revision: character.revision,
+ role: primaryCharacter.role,
+ mimeType: primaryCharacter.mimeType,
+ width: dimensions.width,
+ height: dimensions.height,
+ sourceReferenceSha256: primaryCharacter.sha256
+ }
+ },
+ {
+ kind: 'style_contract',
+ status: 'completed',
+ path: styleContractPath,
+ sourceArtifactIds,
+ metadata: {
+ contract: styleContract.contract,
+ characterAssetId: character.id,
+ characterRevision: character.revision,
+ styleAssetId: style.id,
+ styleRevision: style.revision,
+ styleReferenceCount: styleReferences.length
+ }
+ }
+ ];
+ const primaryStyle = styleReferences[0];
+ if (primaryStyle !== undefined) {
+ const styleReferencePath = join(
+ stage.workdir,
+ `style-reference${extname(primaryStyle.path).toLowerCase()}`
+ );
+ await writeFile(styleReferencePath, await readFile(primaryStyle.path));
+ outputs.splice(1, 0, {
+ kind: 'style_reference',
+ status: 'completed',
+ path: styleReferencePath,
+ sourceArtifactIds,
+ metadata: {
+ assetId: style.id,
+ revision: style.revision,
+ role: primaryStyle.role,
+ mimeType: primaryStyle.mimeType,
+ sourceReferenceSha256: primaryStyle.sha256
+ }
+ });
+ }
+ return {
+ outputs,
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ };
+}
+
+async function promptPack(stage: CreatorExecutorInput) {
+ const shotSpecArtifact = requireArtifact(stage, 'shot_spec');
+ const characterReference = requireArtifact(stage, 'character_reference');
+ const styleContractArtifact = requireArtifact(stage, 'style_contract');
+ const styleReference = stage.inputArtifacts.find(artifact => (
+ artifact.kind === 'style_reference' && artifact.status === 'completed'
+ ));
+ const shotSpec = stickmanShotSpecSchema.parse(await readJson(shotSpecArtifact));
+ const visualProfile = stickmanStyleContractSchema.parse(await readJson(styleContractArtifact));
+ const value = stickmanImagePromptPackSchema.parse({
+ shotSpecArtifactId: shotSpecArtifact.id,
+ characterReferenceArtifactId: characterReference.id,
+ styleContractArtifactId: styleContractArtifact.id,
+ ...(styleReference === undefined ? {} : { styleReferenceArtifactId: styleReference.id }),
+ prompts: shotSpec.shots.map((shot, shotIndex) => ({
+ shotId: shot.id,
+ visualDescription: shot.visualDescription,
+ prompt: buildStickmanImagePrompt({
+ visualProfile,
+ shot,
+ hasStyleReference: styleReference !== undefined,
+ hasPreviousShotReference: shouldUsePreviousShotReference(shot, shotIndex)
+ })
+ }))
+ });
+ const sourceArtifactIds = [
+ shotSpecArtifact.id,
+ characterReference.id,
+ styleContractArtifact.id,
+ ...(styleReference === undefined ? [] : [styleReference.id])
+ ];
+ return {
+ ...await jsonOutput(
+ stage,
+ 'image_prompt_pack',
+ 'image-prompt-pack.json',
+ value,
+ sourceArtifactIds,
+ STICKMAN_IMAGE_PROMPT_CONTRACT
+ ),
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ };
+}
+
+function referenceContract(reference: ResolvedVisualAssetFile) {
+ return {
+ role: reference.role,
+ sha256: reference.sha256,
+ bytes: reference.bytes,
+ mimeType: reference.mimeType
+ };
+}
+
+async function jsonOutput(
+ stage: CreatorExecutorInput,
+ kind: string,
+ fileName: string,
+ value: Record<string, unknown>,
+ sourceArtifactIds: string[],
+ contract = `${kind}-v1`
+) {
+ const path = await writeJsonArtifact(stage, fileName, value);
+ return {
+ outputs: [{
+ kind,
+ status: 'completed' as const,
+ path,
+ sourceArtifactIds,
+ metadata: { contract }
+ }]
+ };
+}
+
+async function writeJsonArtifact(
+ stage: CreatorExecutorInput,
+ fileName: string,
+ value: unknown
+): Promise<string> {
+ const path = join(stage.workdir, fileName);
+ await writeAtomic(path, `${canonicalJson(value)}\n`);
+ return path;
+}
+
+async function writeAtomic(path: string, content: string): Promise<void> {
+ const temporary = `${path}.tmp`;
+ await writeFile(temporary, content, 'utf8');
+ await rename(temporary, path);
+}
+
+function canonicalJson(value: unknown): string {
+ return JSON.stringify(sortValue(value), null, 2);
+}
+
+function sortValue(value: unknown): unknown {
+ if (Array.isArray(value)) return value.map(sortValue);
+ if (value === null || typeof value !== 'object') return value;
+ return Object.fromEntries(
+ Object.entries(value as Record<string, unknown>)
+ .sort(([left], [right]) => left.localeCompare(right))
+ .map(([key, entry]) => [key, sortValue(entry)])
+ );
+}
+
+function requireArtifact(stage: CreatorExecutorInput, kind: string): CreatorArtifact {
+ const artifact = stage.inputArtifacts.find(item => item.kind === kind && item.status === 'completed');
+ if (artifact === undefined) {
+ throw new CreatorExecutorError('creator_stage_input_missing', `${kind} artifact is required`);
+ }
+ return artifact;
+}
+
+function requireOneArtifact(stage: CreatorExecutorInput, kinds: string[]): CreatorArtifact {
+ const artifacts = stage.inputArtifacts.filter(item => (
+ kinds.includes(item.kind) && item.status === 'completed'
+ ));
+ if (artifacts.length !== 1) {
+ throw new CreatorExecutorError(
+ 'creator_stage_input_missing',
+ `Exactly one of ${kinds.join(', ')} is required`
+ );
+ }
+ return artifacts[0]!;
+}
+
+async function readJson(artifact: CreatorArtifact): Promise<unknown> {
+ if (artifact.path === null) {
+ throw new CreatorExecutorError('creator_stage_input_missing', `${artifact.kind} file is required`);
+ }
+ return JSON.parse(await readFile(artifact.path, 'utf8'));
+}
+
+function readStateString(stage: CreatorExecutorInput, key: string, fallback: string): string {
+ const value = stage.job.state[key];
+ return typeof value === 'string' && value.trim().length > 0 ? value.trim() : fallback;
+}
+
+function readStateNumber(stage: CreatorExecutorInput, key: string, fallback: number): number {
+ const value = stage.job.state[key];
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback;
+}
+
+function buildSourceSpans(
+ source: string,
+ sourceKind: 'source_text' | 'source_subtitle'
+): Array<{ id: string; text: string }> {
+ const normalized = source.replace(/\r/g, '').trim();
+ const content = sourceKind === 'source_subtitle'
+ ? normalized
+ .split('\n')
+ .map(line => line.trim())
+ .filter(line => (
+ line.length > 0
+ && !/^\d+$/.test(line)
+ && !/^WEBVTT$/i.test(line)
+ && !/^\d{2}:\d{2}:\d{2}[,.]\d{3}\s+-->\s+/.test(line)
+ ))
+ .join(' ')
+ : normalized;
+ if (content.length === 0) {
+ throw new CreatorExecutorError(
+ 'creator_source_content_missing',
+ '来源内容为空,无法生成来源片段'
+ );
+ }
+ const sentences = (content.match(/[^。!?!?;;\n]+[。!?!?;;]?/gu) ?? [content])
+ .map(value => value.trim())
+ .filter(Boolean)
+ .flatMap(splitLongSourceSpan);
+ const grouped = sentences.length <= 200
+ ? sentences
+ : Array.from({ length: 200 }, (_, index) => {
+ const start = Math.floor(index * sentences.length / 200);
+ const end = Math.floor((index + 1) * sentences.length / 200);
+ return sentences.slice(start, end).join('');
+ });
+ return grouped.map((text, index) => ({
+ id: `source-${String(index + 1).padStart(3, '0')}`,
+ text
+ }));
+}
+
+function splitLongSourceSpan(value: string): string[] {
+ const characters = Array.from(value);
+ if (characters.length <= 360) return [value];
+ const chunks: string[] = [];
+ for (let index = 0; index < characters.length; index += 360) {
+ chunks.push(characters.slice(index, index + 360).join('').trim());
+ }
+ return chunks.filter(Boolean);
+}
+
+function assertSourceReferences(
+ ids: string[],
+ spans: Array<{ id: string }>,
+ errorCode: string
+): void {
+ const validIds = new Set(spans.map(span => span.id));
+ const invalidIds = [...new Set(ids.filter(id => !validIds.has(id)))];
+ if (invalidIds.length > 0) {
+ throw new CreatorExecutorError(
+ errorCode,
+ `内容引用了不存在的来源片段:${invalidIds.join('、')}`
+ );
+ }
+}
+
+function normalizeScriptText(value: string): string {
+ return value.toLocaleLowerCase().replace(/[^a-z0-9\u3400-\u9fff]+/gu, '');
+}
+
+function normalizeGeneratedJson(stageId: string, value: unknown): unknown {
+ if (stageId === 'source-brief') {
+ const root = remapGeneratedKeys(value, {
+ '标题': 'title',
+ '摘要': 'summary',
+ '受众': 'audience',
+ '内容单元': 'claims',
+ '主张': 'claims'
+ });
+ if (isJsonRecord(root) && Array.isArray(root.claims)) {
+ root.claims = root.claims.map(claim => remapGeneratedKeys(claim, {
+ '编号': 'id',
+ '内容': 'text',
+ '来源片段': 'sourceSpanIds'
+ }));
+ }
+ return root;
+ }
+ if (stageId === 'content-plan') {
+ const root = remapGeneratedKeys(value, {
+ '标题': 'title',
+ '受众': 'audience',
+ '目标': 'objective',
+ '保留内容': 'retainedClaimIds',
+ '舍弃内容': 'discardedClaimIds',
+ '章节': 'sections'
+ });
+ if (isJsonRecord(root) && Array.isArray(root.sections)) {
+ root.sections = root.sections.map(item => remapGeneratedKeys(item, {
+ '编号': 'id',
+ '标题': 'title',
+ '内容编号': 'claimIds'
+ }));
+ }
+ return root;
+ }
+ if (stageId === 'script') {
+ const root = remapGeneratedKeys(value, {
+ '标题': 'title',
+ '段落': 'segments',
+ '镜头': 'segments'
+ });
+ if (isJsonRecord(root) && Array.isArray(root.segments)) {
+ root.segments = root.segments.map(segment => remapGeneratedKeys(segment, {
+ '旁白': 'narration',
+ '内容编号': 'claimIds',
+ '来源片段': 'sourceSpanIds'
+ }));
+ }
+ return root;
+ }
+ if (stageId === 'storyboard') {
+ const root = remapGeneratedKeys(value, { '分镜': 'shots', '镜头': 'shots' });
+ if (isJsonRecord(root) && Array.isArray(root.shots)) {
+ root.shots = root.shots.map(shot => remapGeneratedKeys(shot, {
+ '来源段落': 'sourceSegmentId',
+ '语义锚点': 'semanticAnchor',
+ '画面描述': 'visualDescription',
+ '构图与动作': 'compositionAndAction',
+ '关键物体': 'keyObjects',
+ '连续性说明': 'continuityReason',
+ '运镜': 'motion',
+ '运镜理由': 'motionReason'
+ }));
+ }
+ return root;
+ }
+ return value;
+}
+
+function remapGeneratedKeys(value: unknown, aliases: Readonly<Record<string, string>>): unknown {
+ if (!isJsonRecord(value)) return value;
+ const normalized: Record<string, unknown> = {};
+ for (const [key, entry] of Object.entries(value)) {
+ const canonicalKey = aliases[key] ?? key;
+ if (!(canonicalKey in normalized) || key === canonicalKey) {
+ normalized[canonicalKey] = entry;
+ }
+ }
+ return normalized;
+}
+
+function isJsonRecord(value: unknown): value is Record<string, unknown> {
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
+}
+
+function requireGeneratedRecord(stageId: string, value: unknown): Record<string, unknown> {
+ if (isJsonRecord(value)) return value;
+ throw new CreatorExecutorError(
+ 'creator_llm_invalid_response',
+ `${stageId} response was not a JSON object`
+ );
+}
+
+export function createStickmanConfiguredCompletion(input: {
+ configStore: Pick<CreatorServicesConfigStore, 'read'>;
+ codexCompleteJson?: CodexCompleteJson;
+ context: { jobId: string; projectId: string; cwd: string };
+}): CompleteJson {
+ return async request => {
+ const config = await input.configStore.read();
+ if (config.llm.source === 'codex') {
+ if (input.codexCompleteJson === undefined) {
+ throw new CreatorExecutorError(
+ 'creator_llm_config_missing',
+ 'Codex JSON completion runtime is unavailable'
+ );
+ }
+ return input.codexCompleteJson({
+ ...request,
+ ...input.context,
+ model: config.llm.model
+ });
+ }
+ if (!config.llm.apiKey.trim()) {
+ throw new CreatorExecutorError('creator_llm_config_missing', 'LLM configuration is incomplete');
+ }
+ const response = await fetch(
+ `${config.llm.baseUrl.replace(/\/$/, '') || 'https://api.openai.com/v1'}/chat/completions`,
+ {
+ method: 'POST',
+ signal: request.signal,
+ headers: {
+ authorization: `Bearer ${config.llm.apiKey}`,
+ 'content-type': 'application/json'
+ },
+ body: JSON.stringify({
+ model: config.llm.model,
+ response_format: { type: 'json_object' },
+ messages: [{ role: 'user', content: request.prompt }]
+ })
+ }
+ );
+ if (!response.ok) {
+ throw new CreatorExecutorError('creator_llm_failed', `LLM request failed: HTTP ${response.status}`);
+ }
+ const payload = await response.json() as { choices?: Array<{ message?: { content?: string } }> };
+ const content = payload.choices?.[0]?.message?.content;
+ if (typeof content !== 'string' || content.trim().length === 0) {
+ throw new CreatorExecutorError('creator_llm_invalid_response', 'LLM response did not contain JSON');
+ }
+ try {
+ return JSON.parse(content) as Record<string, CreatorJson>;
+ } catch {
+ throw new CreatorExecutorError('creator_llm_invalid_response', 'LLM response was not valid JSON');
+ }
+ };
+}
diff --git a/apps/daemon/src/creator/stickman/contracts.ts b/apps/daemon/src/creator/stickman/contracts.ts
new file mode 100644
index 00000000..2f81b259
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/contracts.ts
@@ -0,0 +1,370 @@
+import { z } from 'zod';
+
+export const stickmanSourceSpanSchema = z.object({
+ id: z.string().regex(/^source-\d{3}$/),
+ text: z.string().trim().min(1)
+}).strict();
+
+export const stickmanSourceClaimSchema = z.object({
+ id: z.string().regex(/^claim-\d{3}$/),
+ text: z.string().trim().min(1),
+ sourceSpanIds: z.array(z.string().regex(/^source-\d{3}$/)).min(1).max(200)
+}).strict();
+
+export const stickmanSourceBriefSchema = z.object({
+ title: z.string().min(1),
+ summary: z.string().min(1),
+ audience: z.string().min(1),
+ claims: z.array(stickmanSourceClaimSchema).min(1).max(200),
+ sourceSpans: z.array(stickmanSourceSpanSchema).min(1).max(200)
+}).strict().superRefine((value, context) => {
+ uniqueIds(value.sourceSpans.map(span => span.id), 'source span', context);
+ uniqueIds(value.claims.map(claim => claim.id), 'source claim', context);
+ const sourceSpanIds = new Set(value.sourceSpans.map(span => span.id));
+ const referencedSpanIds = new Set(value.claims.flatMap(claim => claim.sourceSpanIds));
+ for (const claim of value.claims) {
+ for (const sourceSpanId of claim.sourceSpanIds) {
+ if (!sourceSpanIds.has(sourceSpanId)) {
+ context.addIssue({ code: 'custom', message: `Unknown source span: ${sourceSpanId}` });
+ }
+ }
+ }
+ for (const sourceSpan of value.sourceSpans) {
+ if (!referencedSpanIds.has(sourceSpan.id)) {
+ context.addIssue({ code: 'custom', message: `Unclaimed source span: ${sourceSpan.id}` });
+ }
+ }
+});
+
+export const stickmanNarrationBudgetSchema = z.object({
+ unit: z.enum(['characters', 'words']),
+ unitsPerMinute: z.number().positive(),
+ minUnits: z.number().int().positive(),
+ maxUnits: z.number().int().positive()
+}).strict().refine(value => value.minUnits <= value.maxUnits, {
+ message: 'Narration budget minimum cannot exceed its maximum'
+});
+
+export const stickmanContentPlanSchema = z.object({
+ title: z.string().min(1),
+ audience: z.string().min(1),
+ objective: z.string().min(1),
+ targetDurationSeconds: z.number().positive().max(600),
+ retainedClaimIds: z.array(z.string().regex(/^claim-\d{3}$/)).min(1).max(200),
+ discardedClaimIds: z.array(z.string().regex(/^claim-\d{3}$/)).max(200),
+ narrationBudget: stickmanNarrationBudgetSchema,
+ sections: z.array(z.object({
+ id: z.string().regex(/^section-\d{2}$/),
+ title: z.string().min(1),
+ claimIds: z.array(z.string().regex(/^claim-\d{3}$/)).min(1).max(200)
+ }).strict()).min(1).max(200)
+}).strict().superRefine((value, context) => {
+ uniqueIds(value.sections.map(item => item.id), 'content plan section', context);
+ uniqueIds(value.retainedClaimIds, 'retained claim', context);
+ uniqueIds(value.discardedClaimIds, 'discarded claim', context);
+ const retained = new Set(value.retainedClaimIds);
+ for (const claimId of value.discardedClaimIds) {
+ if (retained.has(claimId)) {
+ context.addIssue({ code: 'custom', message: `Claim cannot be retained and discarded: ${claimId}` });
+ }
+ }
+ const covered = new Set(value.sections.flatMap(section => section.claimIds));
+ for (const claimId of covered) {
+ if (!retained.has(claimId)) {
+ context.addIssue({ code: 'custom', message: `Section references a non-retained claim: ${claimId}` });
+ }
+ }
+ for (const claimId of retained) {
+ if (!covered.has(claimId)) {
+ context.addIssue({ code: 'custom', message: `Retained claim is missing from sections: ${claimId}` });
+ }
+ }
+});
+
+export const stickmanScriptSegmentSchema = z.object({
+ id: z.string().regex(/^segment-[a-z0-9-]+$/),
+ order: z.number().int().positive(),
+ narration: z.string().min(1),
+ claimIds: z.array(z.string().regex(/^claim-\d{3}$/)).min(1).max(200),
+ sourceSpanIds: z.array(z.string().regex(/^source-\d{3}$/)).min(1).max(200),
+ narrationUnits: z.number().int().positive(),
+ estimatedDurationSeconds: z.number().positive().max(5)
+}).strict();
+
+export const stickmanScriptManifestSchema = z.object({
+ contract: z.literal('stickman-narration-script-v2'),
+ reviewStatus: z.enum(['needs_review', 'approved']),
+ contentLocked: z.boolean(),
+ title: z.string().min(1),
+ language: z.string().min(1),
+ targetDurationSeconds: z.number().positive().max(600),
+ narrationBudget: stickmanNarrationBudgetSchema,
+ segmentCount: z.number().int().positive(),
+ totalNarrationUnits: z.number().int().positive(),
+ estimatedTotalDurationSeconds: z.number().positive(),
+ segments: z.array(stickmanScriptSegmentSchema).min(1).max(200)
+}).strict().superRefine((value, context) => {
+ uniqueIds(value.segments.map(segment => segment.id), 'script segment', context);
+ for (const [index, segment] of value.segments.entries()) {
+ if (segment.order !== index + 1 || segment.id !== `segment-${String(index + 1).padStart(2, '0')}`) {
+ context.addIssue({ code: 'custom', message: 'Script segment ids and order must be contiguous' });
+ break;
+ }
+ }
+ if (value.segmentCount !== value.segments.length) {
+ context.addIssue({ code: 'custom', message: 'Script segment count does not match' });
+ }
+ const totalUnits = value.segments.reduce((total, segment) => total + segment.narrationUnits, 0);
+ if (value.totalNarrationUnits !== totalUnits) {
+ context.addIssue({ code: 'custom', message: 'Script narration unit total does not match' });
+ }
+ const estimatedDuration = totalUnits / value.narrationBudget.unitsPerMinute * 60;
+ if (Math.abs(value.estimatedTotalDurationSeconds - estimatedDuration) > 0.011) {
+ context.addIssue({ code: 'custom', message: 'Script estimated duration does not match its narration budget' });
+ }
+ if (value.contentLocked !== (value.reviewStatus === 'approved')) {
+ context.addIssue({ code: 'custom', message: 'Script lock state does not match its review status' });
+ }
+});
+
+export const stickmanAudioTimingSchema = z.object({
+ scriptArtifactId: z.string().min(1),
+ timingSource: z.literal('ffprobe_cumulative_tts_duration'),
+ segments: z.array(z.object({
+ segmentId: z.string().regex(/^segment-[a-z0-9-]+$/),
+ startSeconds: z.number().nonnegative(),
+ endSeconds: z.number().positive(),
+ durationSeconds: z.number().positive(),
+ audioArtifactId: z.string().min(1),
+ audioSha256: z.string().regex(/^[a-f0-9]{64}$/i)
+ }).strict()).min(1).max(200),
+ totalDurationSeconds: z.number().positive()
+}).strict().superRefine((value, context) => {
+ uniqueIds(value.segments.map(segment => segment.segmentId), 'audio timing segment', context);
+ let cursor = 0;
+ for (const segment of value.segments) {
+ if (
+ Math.abs(segment.startSeconds - cursor) > 0.001
+ || Math.abs(segment.endSeconds - segment.startSeconds - segment.durationSeconds) > 0.001
+ ) {
+ context.addIssue({ code: 'custom', message: `Invalid audio timing: ${segment.segmentId}` });
+ }
+ cursor = segment.endSeconds;
+ }
+ if (Math.abs(cursor - value.totalDurationSeconds) > 0.001) {
+ context.addIssue({ code: 'custom', message: 'Audio timing total does not match its segments' });
+ }
+});
+
+export const stickmanMotionSchema = z.enum([
+ 'static',
+ 'push-in',
+ 'pan-left',
+ 'pan-right',
+ 'zoom-out'
+]);
+
+export const stickmanShotSchema = z.object({
+ id: z.string().regex(/^shot-[a-z0-9-]+$/),
+ sourceSegmentId: z.string().regex(/^segment-[a-z0-9-]+$/),
+ semanticAnchor: z.string().trim().min(1),
+ visualDescription: z.string().trim().min(1),
+ compositionAndAction: z.string().trim().min(1),
+ keyObjects: z.array(z.string().trim().min(1)).min(1).max(12),
+ continuityReason: z.string().trim(),
+ motion: stickmanMotionSchema,
+ motionReason: z.string().trim().min(1),
+ startSeconds: z.number().nonnegative(),
+ endSeconds: z.number().positive(),
+ durationSeconds: z.number().positive()
+}).strict();
+
+export const stickmanShotSpecSchema = z.object({
+ scriptArtifactId: z.string().min(1),
+ audioTimingArtifactId: z.string().min(1),
+ timingSource: z.literal('ffprobe_cumulative_tts_duration'),
+ shots: z.array(stickmanShotSchema).min(1).max(200)
+}).strict().superRefine((value, context) => {
+ uniqueIds(value.shots.map(shot => shot.id), 'shot', context);
+ uniqueIds(value.shots.map(shot => shot.sourceSegmentId), 'shot source segment', context);
+ let cursor = 0;
+ for (const shot of value.shots) {
+ if (
+ Math.abs(shot.startSeconds - cursor) > 0.001
+ || Math.abs(shot.endSeconds - shot.startSeconds - shot.durationSeconds) > 0.001
+ ) {
+ context.addIssue({ code: 'custom', message: `Invalid shot timing: ${shot.id}` });
+ }
+ cursor = shot.endSeconds;
+ }
+});
+
+export const stickmanImagePromptPackSchema = z.object({
+ shotSpecArtifactId: z.string().min(1),
+ characterReferenceArtifactId: z.string().min(1),
+ styleContractArtifactId: z.string().min(1),
+ styleReferenceArtifactId: z.string().min(1).optional(),
+ prompts: z.array(z.object({
+ shotId: z.string().regex(/^shot-[a-z0-9-]+$/),
+ visualDescription: z.string().trim().min(1),
+ prompt: z.string().min(1)
+ }).strict()).min(1).max(200)
+}).strict().superRefine((value, context) => {
+ uniqueIds(value.prompts.map(prompt => prompt.shotId), 'image prompt shot', context);
+});
+
+const stickmanVisualAssetReferenceSchema = z.object({
+ role: z.string().min(1),
+ sha256: z.string().regex(/^[a-f0-9]{64}$/i),
+ bytes: z.number().int().positive(),
+ mimeType: z.enum(['image/png', 'image/jpeg', 'image/webp'])
+}).strict();
+
+const stickmanRenderingContractSchema = z.object({
+ medium: z.string().min(1),
+ surface: z.string().min(1),
+ linework: z.string().min(1),
+ shading: z.string().min(1),
+ palette: z.string().min(1),
+ sceneDensity: z.string().min(1),
+ composition: z.string().min(1),
+ characterRendering: z.string().min(1)
+}).strict();
+
+export const stickmanStyleContractSchema = z.object({
+ contract: z.literal('stickman-visual-profile-v2'),
+ ratio: z.literal('16:9'),
+ character: z.object({
+ assetId: z.string().min(1),
+ revision: z.number().int().positive(),
+ identity: z.object({
+ preserve: z.string().min(1),
+ prohibit: z.string().min(1)
+ }).strict(),
+ references: z.array(stickmanVisualAssetReferenceSchema).min(1).max(8)
+ }).strict(),
+ style: z.object({
+ assetId: z.string().min(1),
+ revision: z.number().int().positive(),
+ rendering: stickmanRenderingContractSchema,
+ semanticRenderingRules: z.object({
+ color: z.string().min(1),
+ light: z.string().min(1),
+ complexEnvironment: z.string().min(1)
+ }).strict(),
+ forbiddenDirections: z.array(z.string().min(1)).min(1),
+ references: z.array(stickmanVisualAssetReferenceSchema).max(8)
+ }).strict()
+}).strict();
+
+export const stickmanVisualValidationSchema = z.object({
+ ok: z.literal(true),
+ validation: z.literal('automated_decode_aspect_nonblank_hash_and_ocr'),
+ approvedShotSpecArtifactId: z.string().min(1),
+ shotCount: z.number().int().positive(),
+ ocrStatus: z.enum(['passed', 'unavailable']),
+ publishable: z.boolean(),
+ warnings: z.array(z.string().min(1)),
+ shots: z.array(z.object({
+ shotId: z.string().regex(/^shot-[a-z0-9-]+$/),
+ imageArtifactId: z.string().min(1),
+ imageSha256: z.string().regex(/^[a-f0-9]{64}$/i),
+ width: z.number().int().positive(),
+ height: z.number().int().positive(),
+ brightnessMean: z.number().nonnegative().max(255),
+ contrastStddev: z.number().nonnegative(),
+ ocrStatus: z.enum(['passed', 'unavailable']),
+ detectedText: z.array(z.string())
+ }).strict()).min(1).max(200)
+}).strict().superRefine((value, context) => {
+ uniqueIds(value.shots.map(shot => shot.shotId), 'validated shot', context);
+ if (value.shotCount !== value.shots.length) {
+ context.addIssue({ code: 'custom', message: 'Visual validation shot count does not match' });
+ }
+ if (value.publishable !== (value.ocrStatus === 'passed' && value.warnings.length === 0)) {
+ context.addIssue({ code: 'custom', message: 'Visual publishability does not match its checks' });
+ }
+});
+
+export const stickmanTimelineSchema = z.object({
+ fps: z.number().int().positive(),
+ width: z.literal(1280),
+ height: z.literal(720),
+ totalFrames: z.number().int().positive(),
+ shots: z.array(z.object({
+ shotId: z.string().min(1),
+ startFrame: z.number().int().nonnegative(),
+ endFrame: z.number().int().positive(),
+ imageArtifactId: z.string().min(1),
+ audioArtifactId: z.string().min(1),
+ motion: stickmanMotionSchema,
+ imageSha256: z.string().regex(/^[a-f0-9]{64}$/i),
+ audioSha256: z.string().regex(/^[a-f0-9]{64}$/i),
+ imagePath: z.string().min(1).optional(),
+ audioPath: z.string().min(1).optional()
+ }).strict()).min(1)
+}).strict();
+
+export const stickmanMediaValidationSchema = z.object({
+ ok: z.literal(true),
+ validation: z.literal('ffprobe_and_three_frame_sampling'),
+ cleanVideoArtifactId: z.string().min(1),
+ cleanVideoSha256: z.string().regex(/^[a-f0-9]{64}$/i),
+ timelineArtifactId: z.string().min(1),
+ duration: z.number().positive(),
+ expectedDuration: z.number().positive(),
+ durationTolerance: z.number().positive(),
+ width: z.literal(1280),
+ height: z.literal(720),
+ hasVideo: z.literal(true),
+ hasAudio: z.literal(true),
+ sampledFrames: z.array(z.object({
+ index: z.number().int().min(1).max(3),
+ timestampSeconds: z.number().nonnegative(),
+ sha256: z.string().regex(/^[a-f0-9]{64}$/i),
+ width: z.literal(1280),
+ height: z.literal(720),
+ brightnessMean: z.number().nonnegative().max(255),
+ contrastStddev: z.number().nonnegative()
+ }).strict()).length(3)
+}).strict();
+
+export const stickmanDeliveryManifestSchema = z.object({
+ packageStatus: z.enum(['technical-draft', 'publishable']),
+ placeholderAssets: z.array(z.string().min(1)),
+ blockingChecks: z.array(z.string().min(1)),
+ files: z.array(z.object({
+ name: z.enum([
+ 'stickman-video.mp4',
+ 'narration.srt'
+ ]),
+ relativePath: z.string().min(1),
+ sha256: z.string().regex(/^[a-f0-9]{64}$/i),
+ bytes: z.number().int().nonnegative(),
+ mime: z.string().min(1),
+ sourceArtifactId: z.string().min(1)
+ }).strict()).length(2)
+}).strict();
+
+export type StickmanSourceBrief = z.infer<typeof stickmanSourceBriefSchema>;
+export type StickmanContentPlan = z.infer<typeof stickmanContentPlanSchema>;
+export type StickmanScriptManifest = z.infer<typeof stickmanScriptManifestSchema>;
+export type StickmanAudioTiming = z.infer<typeof stickmanAudioTimingSchema>;
+export type StickmanShotSpec = z.infer<typeof stickmanShotSpecSchema>;
+export type StickmanShot = z.infer<typeof stickmanShotSchema>;
+export type StickmanImagePromptPack = z.infer<typeof stickmanImagePromptPackSchema>;
+export type StickmanStyleContract = z.infer<typeof stickmanStyleContractSchema>;
+export type StickmanVisualValidation = z.infer<typeof stickmanVisualValidationSchema>;
+export type StickmanTimeline = z.infer<typeof stickmanTimelineSchema>;
+export type StickmanMediaValidation = z.infer<typeof stickmanMediaValidationSchema>;
+export type StickmanDeliveryManifest = z.infer<typeof stickmanDeliveryManifestSchema>;
+
+function uniqueIds(ids: string[], label: string, context: z.RefinementCtx): void {
+ const seen = new Set<string>();
+ for (const id of ids) {
+ if (seen.has(id)) {
+ context.addIssue({ code: 'custom', message: `Duplicate ${label}: ${id}` });
+ }
+ seen.add(id);
+ }
+}
diff --git a/apps/daemon/src/creator/stickman/delivery-executor.ts b/apps/daemon/src/creator/stickman/delivery-executor.ts
new file mode 100644
index 00000000..a131032b
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/delivery-executor.ts
@@ -0,0 +1,391 @@
+import { createHash } from 'node:crypto';
+import { execFile } from 'node:child_process';
+import { constants, createReadStream } from 'node:fs';
+import {
+ copyFile,
+ lstat,
+ mkdir,
+ readFile,
+ readdir,
+ realpath,
+ stat,
+ writeFile
+} from 'node:fs/promises';
+import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
+import sharp from 'sharp';
+import type { CreatorArtifact } from '@opencreator/protocol';
+import type { CreatorExecutor, CreatorExecutorOutput } from '../executor.js';
+import { CreatorExecutorError } from '../executor.js';
+import { validateMediaFile } from '../validators/media.js';
+import { validateSrtFile } from '../validators/srt.js';
+import {
+ stickmanAudioTimingSchema,
+ stickmanDeliveryManifestSchema,
+ stickmanMediaValidationSchema,
+ stickmanTimelineSchema,
+ stickmanVisualValidationSchema
+} from './contracts.js';
+
+const deliveryFiles = [
+ { kind: 'clean_video', name: 'stickman-video.mp4', mime: 'video/mp4' },
+ { kind: 'narration_subtitle', name: 'narration.srt', mime: 'application/x-subrip' }
+] as const;
+
+type VideoValidator = typeof validateMediaFile;
+type VideoFrameSampler = (input: {
+ path: string;
+ kind: 'clean_video';
+ duration: number;
+ workdir: string;
+ ffmpegPath?: string;
+}) => Promise<{ sampleCount: number }>;
+
+export function createStickmanDeliveryExecutor(input: {
+ ffprobePath: string;
+ ffmpegPath?: string;
+ validateVideo?: VideoValidator;
+ sampleVideoFrames?: VideoFrameSampler;
+}): CreatorExecutor {
+ const validateVideo = input.validateVideo ?? validateMediaFile;
+ const sampleVideoFrames = input.sampleVideoFrames
+ ?? (input.ffmpegPath === undefined ? undefined : sampleFramesWithFfmpeg);
+ return {
+ id: 'stickman-delivery',
+ async run(stage) {
+ const jobRoot = dirname(resolve(stage.workdir));
+ const deliveryRoot = join(stage.workdir, 'delivery');
+ await mkdir(deliveryRoot, { recursive: true });
+ const existing = await readdir(deliveryRoot);
+ if (existing.length > 0) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_extra_file',
+ `Delivery directory is not empty: ${existing[0]}`
+ );
+ }
+ const manifestFiles = [];
+ const outputs: CreatorExecutorOutput[] = [];
+ const sampledVideos = new Set<string>();
+ for (const definition of deliveryFiles) {
+ const artifact = requireSingleArtifact(stage.inputArtifacts, definition.kind);
+ const sourcePath = await validateSourcePath(jobRoot, artifact);
+ const actualSha256 = await sha256File(sourcePath);
+ if (artifact.sha256 === null || artifact.sha256.toLowerCase() !== actualSha256) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_hash_mismatch',
+ `Artifact hash mismatch: ${definition.kind}`
+ );
+ }
+ const targetPath = join(deliveryRoot, definition.name);
+ await copyFile(sourcePath, targetPath, constants.COPYFILE_EXCL);
+ const info = await stat(targetPath);
+ const media = await validateDeliveryFile(definition.kind, targetPath, input.ffprobePath, validateVideo);
+ if (
+ media !== undefined
+ && sampleVideoFrames !== undefined
+ && definition.kind === 'clean_video'
+ ) {
+ const samples = await sampleVideoFrames({
+ path: targetPath,
+ kind: definition.kind,
+ duration: media.duration,
+ workdir: join(stage.workdir, `frame-samples-${definition.kind}`),
+ ...(input.ffmpegPath === undefined ? {} : { ffmpegPath: input.ffmpegPath })
+ });
+ if (samples.sampleCount < 3) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_frame_sampling_failed',
+ `${definition.kind} requires at least three decoded frame samples`
+ );
+ }
+ sampledVideos.add(definition.kind);
+ }
+ manifestFiles.push({
+ name: definition.name,
+ relativePath: `delivery/${definition.name}`,
+ sha256: actualSha256,
+ bytes: info.size,
+ mime: definition.mime,
+ sourceArtifactId: artifact.id
+ });
+ outputs.push({
+ kind: definition.kind,
+ status: 'completed' as const,
+ path: targetPath,
+ sourceArtifactIds: [artifact.id],
+ metadata: {
+ fileName: definition.name,
+ mimeType: definition.mime,
+ bytes: info.size,
+ delivery: true
+ }
+ });
+ }
+ const actualFiles = await readdir(deliveryRoot);
+ const expectedFiles = deliveryFiles.map(file => file.name).sort();
+ if (JSON.stringify([...actualFiles].sort()) !== JSON.stringify(expectedFiles)) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_file_set_mismatch',
+ 'Delivery file set is not exact'
+ );
+ }
+ const placeholderAssets = findPlaceholderAssets(stage.inputArtifacts);
+ const blockingChecks = await collectBlockingChecks({
+ artifacts: stage.inputArtifacts,
+ sampledVideos
+ });
+ const packageStatus = placeholderAssets.length === 0 && blockingChecks.length === 0
+ ? 'publishable' as const
+ : 'technical-draft' as const;
+ const manifest = stickmanDeliveryManifestSchema.parse({
+ packageStatus,
+ placeholderAssets,
+ blockingChecks,
+ files: manifestFiles
+ });
+ const manifestPath = join(stage.workdir, 'delivery-manifest.json');
+ await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8');
+ return {
+ outputs: [
+ ...outputs,
+ {
+ kind: 'delivery_manifest',
+ status: 'completed' as const,
+ path: manifestPath,
+ sourceArtifactIds: stage.inputArtifacts.map(artifact => artifact.id),
+ metadata: {
+ fileName: 'delivery-manifest.json',
+ mimeType: 'application/json',
+ fileCount: manifest.files.length,
+ packageStatus,
+ placeholderAssets,
+ blockingChecks
+ }
+ }
+ ],
+ progress: { phase: 'completed', percent: 100, files: manifest.files.length }
+ };
+ }
+ };
+}
+
+function requireSingleArtifact(artifacts: CreatorArtifact[], kind: string): CreatorArtifact {
+ const candidates = artifacts.filter(artifact => artifact.kind === kind && artifact.status === 'completed');
+ if (candidates.length !== 1) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_artifact_ambiguous',
+ `Delivery requires exactly one completed ${kind}`
+ );
+ }
+ return candidates[0]!;
+}
+
+async function validateSourcePath(jobRoot: string, artifact: CreatorArtifact): Promise<string> {
+ if (artifact.path === null) {
+ throw new CreatorExecutorError('creator_delivery_file_missing', `${artifact.kind} file is missing`);
+ }
+ const link = await lstat(artifact.path);
+ if (link.isSymbolicLink()) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_symlink_forbidden',
+ `${artifact.kind} cannot be a symbolic link`
+ );
+ }
+ const path = await realpath(artifact.path);
+ const value = relative(jobRoot, path);
+ if (value.startsWith('..') || isAbsolute(value)) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_path_escape',
+ `${artifact.kind} escapes the Job root`
+ );
+ }
+ if (!(await stat(path)).isFile()) {
+ throw new CreatorExecutorError('creator_delivery_file_missing', `${artifact.kind} is not a file`);
+ }
+ return path;
+}
+
+async function validateDeliveryFile(
+ kind: string,
+ path: string,
+ ffprobePath: string,
+ validateVideo: VideoValidator
+): Promise<Awaited<ReturnType<VideoValidator>> | undefined> {
+ if (kind === 'clean_video') {
+ const media = await validateVideo(path, ffprobePath);
+ if (!media.hasVideo || !media.hasAudio || media.width !== 1280 || media.height !== 720) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_video_invalid',
+ `${kind} must be 1280x720 audio/video media`
+ );
+ }
+ return media;
+ }
+ if (kind === 'narration_subtitle') await validateSrtFile(path);
+ return undefined;
+}
+
+async function collectBlockingChecks(input: {
+ artifacts: CreatorArtifact[];
+ sampledVideos: Set<string>;
+}): Promise<string[]> {
+ const blocking = new Set<string>();
+ const visual = singleCompleted(input.artifacts, 'visual_validation');
+ if (visual?.path === null || visual?.path === undefined) {
+ blocking.add('visual_validation_missing');
+ } else {
+ try {
+ const report = stickmanVisualValidationSchema.parse(JSON.parse(await readFile(visual.path, 'utf8')));
+ if (!report.publishable || report.ocrStatus !== 'passed') blocking.add('visual_ocr_unverified');
+ } catch {
+ blocking.add('visual_validation_invalid');
+ }
+ }
+
+ const narration = input.artifacts.filter(artifact => (
+ artifact.kind === 'narration_audio' && artifact.status === 'completed'
+ ));
+ if (
+ narration.length === 0
+ || !(await everyArtifactHashMatches(narration))
+ || narration.some(artifact => (
+ artifact.scopeKey === null
+ || artifact.metadata.timingSource !== 'ffprobe'
+ || typeof artifact.metadata.duration !== 'number'
+ || artifact.metadata.duration <= 0
+ || typeof artifact.metadata.provider !== 'string'
+ ))
+ ) blocking.add('narration_audio_unverified');
+
+ const timingArtifact = singleCompleted(input.artifacts, 'audio_timing');
+ if (timingArtifact?.path === null || timingArtifact?.path === undefined) {
+ blocking.add('audio_timing_missing');
+ } else {
+ try {
+ const timing = stickmanAudioTimingSchema.parse(JSON.parse(await readFile(timingArtifact.path, 'utf8')));
+ const narrationById = new Map(narration.map(artifact => [artifact.id, artifact]));
+ if (timing.segments.some(segment => {
+ const artifact = narrationById.get(segment.audioArtifactId);
+ return artifact === undefined || artifact.sha256?.toLowerCase() !== segment.audioSha256.toLowerCase();
+ })) blocking.add('audio_timing_unverified');
+ } catch {
+ blocking.add('audio_timing_unverified');
+ }
+ }
+
+ const timelineArtifact = singleCompleted(input.artifacts, 'timeline_manifest');
+ if (timelineArtifact?.path === null || timelineArtifact?.path === undefined) {
+ blocking.add('timeline_missing');
+ } else {
+ try {
+ stickmanTimelineSchema.parse(JSON.parse(await readFile(timelineArtifact.path, 'utf8')));
+ if (timelineArtifact.metadata.timingSource !== 'ffprobe_cumulative_tts_duration') {
+ blocking.add('timeline_unverified');
+ }
+ } catch {
+ blocking.add('timeline_unverified');
+ }
+ }
+
+ const cleanVideo = singleCompleted(input.artifacts, 'clean_video');
+ const mediaValidation = singleCompleted(input.artifacts, 'media_validation');
+ if (
+ cleanVideo === undefined
+ || mediaValidation?.path === null
+ || mediaValidation?.path === undefined
+ ) {
+ blocking.add('media_validation_missing');
+ } else {
+ try {
+ const report = stickmanMediaValidationSchema.parse(JSON.parse(
+ await readFile(mediaValidation.path, 'utf8')
+ ));
+ if (
+ report.cleanVideoArtifactId !== cleanVideo.id
+ || report.cleanVideoSha256.toLowerCase() !== cleanVideo.sha256?.toLowerCase()
+ ) blocking.add('media_validation_unverified');
+ } catch {
+ blocking.add('media_validation_unverified');
+ }
+ }
+ if (
+ cleanVideo?.metadata.renderEngine !== 'remotion'
+ || cleanVideo.metadata.renderKind !== 'final'
+ ) blocking.add('remotion_final_unverified');
+ if (
+ !input.sampledVideos.has('clean_video')
+ ) blocking.add('video_frame_sampling_unverified');
+ return [...blocking].sort();
+}
+
+function findPlaceholderAssets(artifacts: CreatorArtifact[]): string[] {
+ return artifacts.filter(artifact => (
+ artifact.metadata.placeholder === true
+ || artifact.metadata.placeholderAsset === true
+ || artifact.metadata.fakeProvider === true
+ || artifact.metadata.technicalDraft === true
+ )).map(artifact => `${artifact.kind}:${artifact.id}`).sort();
+}
+
+function singleCompleted(artifacts: CreatorArtifact[], kind: string): CreatorArtifact | undefined {
+ const matches = artifacts.filter(artifact => artifact.kind === kind && artifact.status === 'completed');
+ return matches.length === 1 ? matches[0] : undefined;
+}
+
+async function everyArtifactHashMatches(artifacts: CreatorArtifact[]): Promise<boolean> {
+ for (const artifact of artifacts) {
+ if (artifact.path === null || artifact.sha256 === null) return false;
+ try {
+ if ((await sha256File(artifact.path)) !== artifact.sha256.toLowerCase()) return false;
+ } catch {
+ return false;
+ }
+ }
+ return true;
+}
+
+async function sampleFramesWithFfmpeg(input: {
+ path: string;
+ kind: 'clean_video';
+ duration: number;
+ workdir: string;
+ ffmpegPath?: string;
+}): Promise<{ sampleCount: number }> {
+ if (input.ffmpegPath === undefined) return { sampleCount: 0 };
+ await mkdir(input.workdir, { recursive: true });
+ const timestamps = [
+ Math.min(0.1, input.duration / 4),
+ input.duration / 2,
+ Math.max(0, input.duration - Math.min(0.2, input.duration / 4))
+ ];
+ for (const [index, timestamp] of timestamps.entries()) {
+ const target = join(input.workdir, `frame-${index + 1}.png`);
+ await execFileAsync(input.ffmpegPath, [
+ '-y', '-ss', timestamp.toFixed(3), '-i', input.path,
+ '-frames:v', '1', '-f', 'image2', target
+ ]);
+ const stats = await sharp(target).greyscale().stats();
+ const channel = stats.channels[0];
+ if (channel === undefined || channel.mean < 3 || channel.mean > 252 || channel.stdev < 2) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_frame_sampling_failed',
+ `${input.kind} contains a blank or unreadable sampled frame`
+ );
+ }
+ }
+ return { sampleCount: timestamps.length };
+}
+
+function execFileAsync(command: string, args: string[]): Promise<void> {
+ return new Promise((resolve, reject) => {
+ execFile(command, args, { windowsHide: true, timeout: 120_000 }, error => {
+ if (error) reject(error);
+ else resolve();
+ });
+ });
+}
+
+async function sha256File(path: string): Promise<string> {
+ const digest = createHash('sha256');
+ for await (const chunk of createReadStream(path)) digest.update(chunk);
+ return digest.digest('hex');
+}
diff --git a/apps/daemon/src/creator/stickman/executor.ts b/apps/daemon/src/creator/stickman/executor.ts
deleted file mode 100644
index 2f3519cc..00000000
--- a/apps/daemon/src/creator/stickman/executor.ts
+++ /dev/null
@@ -1,256 +0,0 @@
-import { readFile, writeFile } from 'node:fs/promises';
-import { join } from 'node:path';
-import type { CreatorArtifact, CreatorJson } from '@opencreator/protocol';
-import type { CreatorServicesConfigStore } from '../../creator-services/config-store.js';
-import type { CreatorExecutor, CreatorExecutorInput, CreatorExecutorOutput } from '../executor.js';
-import { CreatorExecutorError } from '../executor.js';
-import { createOpenAiCompatibleImageProvider } from '../image/openai-compatible-provider.js';
-import { spawnCreatorProcess } from '../process-tree.js';
-import { validateImageFile } from '../validators/image.js';
-import { validateMediaFile } from '../validators/media.js';
-import { generateStickmanScript, parseStickmanScript, type StickmanScriptSegment } from './script-generator.js';
-import { generateStickmanStoryboard } from './storyboard-generator.js';
-
-export function createStickmanExecutor(input: {
- configStore: Pick<CreatorServicesConfigStore, 'read'>;
- ffmpegPath: string;
- ffprobePath: string;
-}): CreatorExecutor {
- return {
- id: 'stickman',
- async run(stage) {
- switch (stage.stageRun.stageId) {
- case 'script': return runScript(input.configStore, stage);
- case 'storyboard': return runStoryboard(input.configStore, stage);
- case 'narration': return runNarration(input.configStore, input.ffprobePath, stage);
- case 'render': return runRender(input.ffmpegPath, input.ffprobePath, stage);
- default: throw new CreatorExecutorError('creator_stage_not_supported', 'Unsupported stickman stage');
- }
- }
- };
-}
-
-async function runScript(
- configStore: Pick<CreatorServicesConfigStore, 'read'>,
- stage: CreatorExecutorInput
-) {
- const config = await configStore.read();
- if (!config.llm.apiKey) throw new CreatorExecutorError('creator_llm_config_missing', 'LLM configuration is incomplete');
- const topic = readStateString(stage, 'topic');
- const targetDurationSeconds = readStateNumber(stage, 'targetDurationSeconds', 30);
- const script = await generateStickmanScript({ ...config.llm, topic, targetDurationSeconds });
- const manifestPath = join(stage.workdir, 'script.json');
- await writeFile(manifestPath, `${JSON.stringify(script, null, 2)}\n`);
- const srtPath = join(stage.workdir, 'narration.srt');
- await writeFile(srtPath, createSrt(script.segments));
- const outputs: CreatorExecutorOutput[] = [
- { kind: 'script_manifest', status: 'completed', path: manifestPath, metadata: { title: script.title, segmentCount: script.segments.length } },
- { kind: 'target_subtitle', status: 'completed', path: srtPath, metadata: { generatedFor: 'stickman' } },
- ...script.segments.map(segment => ({
- kind: 'script_segment',
- status: 'completed' as const,
- path: null,
- metadata: segment as unknown as Record<string, CreatorJson>
- }))
- ];
- return {
- outputs
- };
-}
-
-async function runStoryboard(
- configStore: Pick<CreatorServicesConfigStore, 'read'>,
- stage: CreatorExecutorInput
-) {
- const config = await configStore.read();
- if (!config.llm.apiKey || !config.image.openai.apiKey) {
- throw new CreatorExecutorError('creator_image_config_missing', 'LLM and image configuration are required');
- }
- const segments = currentSegments(stage.job.artifacts);
- if (segments.length === 0) throw new CreatorExecutorError('creator_stage_input_missing', 'Script segments are required');
- const shots = await generateStickmanStoryboard({
- ...config.llm,
- style: readStateString(stage, 'style', '极简黑白线稿'),
- characterPrompt: readStateString(stage, 'characterPrompt', '统一的极简火柴人角色'),
- segments
- });
- const provider = createOpenAiCompatibleImageProvider(config.image.openai);
- const ratio = readRatio(stage);
- const outputs: CreatorExecutorOutput[] = [];
- const manifest: Array<{ segmentId: string; path: string; motion: string }> = [];
- for (const shot of shots) {
- const segmentArtifact = latestSegmentArtifact(stage.job.artifacts, shot.segmentId);
- const result = await provider.generate({ prompt: shot.imagePrompt, ratio }, stage.signal);
- const path = join(stage.workdir, `${safeName(shot.segmentId)}.${result.mimeType === 'image/jpeg' ? 'jpg' : 'png'}`);
- await writeFile(path, result.bytes);
- const metadata = await validateImageFile(path);
- manifest.push({ segmentId: shot.segmentId, path, motion: shot.motion });
- outputs.push({
- kind: 'storyboard_image',
- status: 'completed',
- path,
- sourceArtifactIds: segmentArtifact ? [segmentArtifact.id] : [],
- metadata: { ...metadata, segmentId: shot.segmentId, motion: shot.motion, prompt: shot.imagePrompt }
- });
- }
- const manifestPath = join(stage.workdir, 'storyboard.json');
- await writeFile(manifestPath, `${JSON.stringify({ shots: manifest }, null, 2)}\n`);
- outputs.unshift({
- kind: 'storyboard_manifest',
- status: 'completed',
- path: manifestPath,
- sourceArtifactIds: currentSegmentArtifacts(stage.job.artifacts).map(artifact => artifact.id),
- metadata: { shotCount: manifest.length, ratio }
- });
- return { outputs };
-}
-
-async function runNarration(
- configStore: Pick<CreatorServicesConfigStore, 'read'>,
- ffprobePath: string,
- stage: CreatorExecutorInput
-) {
- const config = await configStore.read();
- if (config.tts.provider !== 'openai' || !config.tts.openai.apiKey) {
- throw new CreatorExecutorError('creator_tts_config_missing', '火柴人逐段配音当前需要 OpenAI-compatible TTS 配置');
- }
- const segments = currentSegments(stage.job.artifacts);
- const outputs: CreatorExecutorOutput[] = [];
- const manifest: Array<{ segmentId: string; path: string; duration: number }> = [];
- for (const segment of segments) {
- const response = await fetch(`${config.tts.openai.baseUrl.replace(/\/$/, '') || 'https://api.openai.com/v1'}/audio/speech`, {
- method: 'POST',
- signal: stage.signal,
- headers: { authorization: `Bearer ${config.tts.openai.apiKey}`, 'content-type': 'application/json' },
- body: JSON.stringify({ model: config.tts.openai.model, voice: readStateString(stage, 'voice', 'alloy'), input: segment.narration, format: 'mp3' })
- });
- if (!response.ok) throw new CreatorExecutorError('creator_tts_failed', `TTS failed: HTTP ${response.status}`);
- const path = join(stage.workdir, `${safeName(segment.id)}.mp3`);
- await writeFile(path, Buffer.from(await response.arrayBuffer()));
- const media = await validateMediaFile(path, ffprobePath);
- const segmentArtifact = latestSegmentArtifact(stage.job.artifacts, segment.id);
- manifest.push({ segmentId: segment.id, path, duration: media.duration });
- outputs.push({
- kind: 'segment_audio', status: 'completed', path,
- sourceArtifactIds: segmentArtifact ? [segmentArtifact.id] : [],
- metadata: { ...media, segmentId: segment.id }
- });
- }
- const manifestPath = join(stage.workdir, 'narration.json');
- await writeFile(manifestPath, `${JSON.stringify({ segments: manifest }, null, 2)}\n`);
- outputs.unshift({
- kind: 'narration_manifest', status: 'completed', path: manifestPath,
- sourceArtifactIds: currentSegmentArtifacts(stage.job.artifacts).map(artifact => artifact.id),
- metadata: { segmentCount: manifest.length }
- });
- return { outputs };
-}
-
-async function runRender(ffmpegPath: string, ffprobePath: string, stage: CreatorExecutorInput) {
- const images = latestPerSegment(stage.job.artifacts, 'storyboard_image');
- const audios = latestPerSegment(stage.job.artifacts, 'segment_audio');
- const segments = currentSegments(stage.job.artifacts);
- if (images.size === 0 || audios.size === 0 || segments.length === 0) {
- throw new CreatorExecutorError('creator_stage_input_missing', 'Storyboard images and narration audio are required');
- }
- const dimensions = readRatio(stage) === '9:16' ? { width: 1080, height: 1920 }
- : readRatio(stage) === '1:1' ? { width: 1080, height: 1080 } : { width: 1920, height: 1080 };
- const args: string[] = ['-y'];
- for (const segment of segments) {
- const image = images.get(segment.id)?.path;
- const audio = audios.get(segment.id)?.path;
- if (!image || !audio) throw new CreatorExecutorError('creator_stage_input_missing', `Missing assets for segment ${segment.id}`);
- args.push('-loop', '1', '-i', image, '-i', audio);
- }
- const filters: string[] = [];
- const concatInputs: string[] = [];
- segments.forEach((segment, index) => {
- const imageIndex = index * 2;
- const audioIndex = imageIndex + 1;
- filters.push(`[${imageIndex}:v]scale=${dimensions.width}:${dimensions.height}:force_original_aspect_ratio=decrease,pad=${dimensions.width}:${dimensions.height}:(ow-iw)/2:(oh-ih)/2,setsar=1,trim=duration=${segment.durationSeconds},setpts=PTS-STARTPTS[v${index}]`);
- filters.push(`[${audioIndex}:a]atrim=duration=${segment.durationSeconds},asetpts=PTS-STARTPTS[a${index}]`);
- concatInputs.push(`[v${index}][a${index}]`);
- });
- filters.push(`${concatInputs.join('')}concat=n=${segments.length}:v=1:a=1[outv][outa]`);
- const output = join(stage.workdir, 'stickman-video.mp4');
- args.push('-filter_complex', filters.join(';'), '-map', '[outv]', '-map', '[outa]', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-shortest', output);
- await runProcess(ffmpegPath, args, stage.signal);
- return {
- outputs: [{
- kind: 'stickman_video', status: 'completed' as const, path: output,
- sourceArtifactIds: [...images.values(), ...audios.values()].map(artifact => artifact.id),
- metadata: await validateMediaFile(output, ffprobePath)
- }]
- };
-}
-
-function currentSegments(artifacts: CreatorArtifact[]): StickmanScriptSegment[] {
- return [...latestPerSegment(artifacts, 'script_segment').values()]
- .map(artifact => artifact.metadata as unknown as StickmanScriptSegment)
- .sort((left, right) => left.id.localeCompare(right.id, undefined, { numeric: true }));
-}
-
-function currentSegmentArtifacts(artifacts: CreatorArtifact[]): CreatorArtifact[] {
- return [...latestPerSegment(artifacts, 'script_segment').values()];
-}
-
-function latestSegmentArtifact(artifacts: CreatorArtifact[], segmentId: string): CreatorArtifact | undefined {
- return latestPerSegment(artifacts, 'script_segment').get(segmentId);
-}
-
-function latestPerSegment(artifacts: CreatorArtifact[], kind: string): Map<string, CreatorArtifact> {
- const result = new Map<string, CreatorArtifact>();
- for (const artifact of artifacts) {
- if (artifact.kind !== kind || artifact.status !== 'completed') continue;
- const segmentId = artifact.metadata.segmentId ?? artifact.metadata.id;
- if (typeof segmentId === 'string') result.set(segmentId, artifact);
- }
- return result;
-}
-
-function createSrt(segments: StickmanScriptSegment[]): string {
- let cursor = 0;
- return `${segments.map((segment, index) => {
- const start = cursor;
- cursor += segment.durationSeconds * 1000;
- return `${index + 1}\n${formatSrt(start)} --> ${formatSrt(cursor)}\n${segment.narration}`;
- }).join('\n\n')}\n`;
-}
-
-function formatSrt(milliseconds: number): string {
- const hours = Math.floor(milliseconds / 3_600_000);
- const minutes = Math.floor((milliseconds % 3_600_000) / 60_000);
- const seconds = Math.floor((milliseconds % 60_000) / 1_000);
- const remainder = Math.floor(milliseconds % 1_000);
- return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')},${String(remainder).padStart(3, '0')}`;
-}
-
-function readStateString(stage: CreatorExecutorInput, key: string, fallback?: string): string {
- const value = stage.job.state[key];
- if (typeof value === 'string' && value.trim()) return value.trim();
- if (fallback !== undefined) return fallback;
- throw new CreatorExecutorError('creator_stage_input_missing', `${key} is required`);
-}
-
-function readStateNumber(stage: CreatorExecutorInput, key: string, fallback: number): number {
- const value = stage.job.state[key];
- return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback;
-}
-
-function readRatio(stage: CreatorExecutorInput): '16:9' | '1:1' | '9:16' {
- return stage.job.state.ratio === '1:1' || stage.job.state.ratio === '9:16' ? stage.job.state.ratio : '16:9';
-}
-
-function safeName(value: string): string {
- return value.replace(/[^a-zA-Z0-9_-]/g, '_').slice(0, 80) || 'segment';
-}
-
-function runProcess(binary: string, args: string[], signal: AbortSignal): Promise<void> {
- return new Promise((resolve, reject) => {
- const child = spawnCreatorProcess(binary, args, { stdio: ['ignore', 'pipe', 'pipe'] }, signal);
- let stderr = '';
- child.stderr?.on('data', chunk => { stderr += String(chunk); });
- child.once('error', reject);
- child.once('exit', code => code === 0 ? resolve() : reject(new CreatorExecutorError('stickman_render_failed', stderr.slice(-2000))));
- });
-}
diff --git a/apps/daemon/src/creator/stickman/image-executor.ts b/apps/daemon/src/creator/stickman/image-executor.ts
new file mode 100644
index 00000000..aa037df3
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/image-executor.ts
@@ -0,0 +1,507 @@
+import type { ImageGenerationProvider, ImageGenerationQuality } from '@opencreator/protocol';
+import { execFile } from 'node:child_process';
+import { createHash } from 'node:crypto';
+import { copyFile, readFile } from 'node:fs/promises';
+import { join } from 'node:path';
+import sharp from 'sharp';
+import type { CreatorServicesConfigStore } from '../../creator-services/config-store.js';
+import {
+ generateImageContents,
+ imageGenerationCapabilities
+} from '../../image-generation/provider.js';
+import type { CreatorExecutor } from '../executor.js';
+import { CreatorExecutorError } from '../executor.js';
+import { CreatorProviderRequestLedger } from '../provider-requests.js';
+import { validateImageFile } from '../validators/image.js';
+import {
+ stickmanImagePromptPackSchema,
+ stickmanShotSpecSchema,
+ stickmanStyleContractSchema
+} from './contracts.js';
+import {
+ STICKMAN_CHARACTER_REFERENCE_PREPARATION,
+ STICKMAN_IMAGE_PROMPT_CONTRACT,
+ shouldUsePreviousShotReference
+} from './image-prompt.js';
+import { previousStickmanShotImage } from './lineage.js';
+import {
+ DEFAULT_STICKMAN_CHARACTER_ASSET,
+ DEFAULT_STICKMAN_STYLE_ASSET,
+ readVisualAssetRef
+} from './visual-assets.js';
+
+export function createStickmanImageExecutor(input: {
+ configStore: Pick<CreatorServicesConfigStore, 'read'>;
+ ledger: CreatorProviderRequestLedger;
+ generate?: typeof generateImageContents;
+ tesseractPath?: string;
+ validateCandidate?: (path: string) => Promise<StickmanImageCandidateQuality>;
+}): CreatorExecutor {
+ const generate = input.generate ?? generateImageContents;
+ const validateCandidate = input.validateCandidate
+ ?? (path => inspectStickmanImageCandidate(path, input.tesseractPath));
+ return {
+ id: 'stickman-image',
+ async run(stage) {
+ if (stage.stageRun.stageId !== 'images') {
+ throw new CreatorExecutorError('creator_stage_not_supported', 'Unsupported stickman image stage');
+ }
+ const scopeKey = stage.stageRun.scopeKey;
+ const inputFingerprint = stage.stageRun.inputFingerprint;
+ if (scopeKey === null || inputFingerprint === null) {
+ throw new CreatorExecutorError('creator_stage_scope_missing', 'Shot scope and fingerprint are required');
+ }
+ const shotSpecArtifact = stage.inputArtifacts.find(artifact => artifact.kind === 'shot_spec');
+ if (shotSpecArtifact?.path === null || shotSpecArtifact?.path === undefined) {
+ throw new CreatorExecutorError('creator_stage_input_missing', 'Approved shot spec is required');
+ }
+ const shotSpec = stickmanShotSpecSchema.parse(JSON.parse(
+ await readFile(shotSpecArtifact.path, 'utf8')
+ ));
+ const shot = shotSpec.shots.find(candidate => candidate.id === scopeKey);
+ if (shot === undefined) throw new CreatorExecutorError('creator_shot_not_found', 'Shot was not found');
+ const shotIndex = shotSpec.shots.findIndex(candidate => candidate.id === scopeKey);
+ const shotCount = shotSpec.shots.length;
+ const promptPackArtifact = stage.inputArtifacts.find(artifact => (
+ artifact.kind === 'image_prompt_pack' && artifact.status === 'completed'
+ ));
+ if (promptPackArtifact?.path === null || promptPackArtifact?.path === undefined) {
+ throw new CreatorExecutorError('creator_stage_input_missing', 'Approved image prompt pack is required');
+ }
+ const promptPack = stickmanImagePromptPackSchema.parse(JSON.parse(
+ await readFile(promptPackArtifact.path, 'utf8')
+ ));
+ const shotPrompt = promptPack.prompts.find(candidate => candidate.shotId === scopeKey);
+ if (shotPrompt === undefined) {
+ throw new CreatorExecutorError('creator_image_prompt_missing', `Image prompt for ${scopeKey} was not found`);
+ }
+ const characterReference = stage.inputArtifacts.find(artifact => (
+ artifact.kind === 'character_reference' && artifact.status === 'completed'
+ ));
+ if (characterReference?.path === null || characterReference?.path === undefined || characterReference.sha256 === null) {
+ throw new CreatorExecutorError(
+ 'creator_character_reference_missing',
+ 'A materialized character reference is required for every shot'
+ );
+ }
+ const selectedCharacter = readVisualAssetRef(
+ stage.job.state.characterAsset,
+ DEFAULT_STICKMAN_CHARACTER_ASSET
+ );
+ const selectedStyle = readVisualAssetRef(
+ stage.job.state.styleAsset,
+ DEFAULT_STICKMAN_STYLE_ASSET
+ );
+ if (
+ characterReference.metadata.assetId !== selectedCharacter.assetId
+ || characterReference.metadata.revision !== selectedCharacter.revision
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_character_reference_changed',
+ 'The materialized character does not match the selected preset'
+ );
+ }
+ const styleContractArtifact = stage.inputArtifacts.find(artifact => (
+ artifact.kind === 'style_contract' && artifact.status === 'completed'
+ ));
+ if (styleContractArtifact?.path === null || styleContractArtifact?.path === undefined) {
+ throw new CreatorExecutorError('creator_style_contract_missing', 'Character style contract is required');
+ }
+ const styleContract = stickmanStyleContractSchema.parse(JSON.parse(
+ await readFile(styleContractArtifact.path, 'utf8')
+ ));
+ if (
+ styleContract.character.assetId !== selectedCharacter.assetId
+ || styleContract.character.revision !== selectedCharacter.revision
+ || styleContract.character.references[0]?.sha256 !== characterReference.sha256
+ || styleContract.style.assetId !== selectedStyle.assetId
+ || styleContract.style.revision !== selectedStyle.revision
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_style_contract_stale',
+ 'Character reference or visual style changed after the image prompt was prepared'
+ );
+ }
+ const sourceReferenceContent = await readFile(characterReference.path);
+ const characterReferenceSha256 = createHash('sha256')
+ .update(sourceReferenceContent)
+ .digest('hex');
+ if (characterReferenceSha256 !== characterReference.sha256) {
+ throw new CreatorExecutorError(
+ 'creator_character_reference_changed',
+ 'The selected character reference no longer matches its artifact hash'
+ );
+ }
+ const characterReferenceMime = readReferenceMime(
+ characterReference.path,
+ characterReference.metadata.mimeType
+ );
+ const styleReference = stage.inputArtifacts.find(artifact => (
+ artifact.kind === 'style_reference' && artifact.status === 'completed'
+ ));
+ const primaryStyleReference = styleContract.style.references[0];
+ if (
+ (primaryStyleReference === undefined) !== (styleReference === undefined)
+ || (styleReference !== undefined && (
+ styleReference.path === null
+ || styleReference.sha256 === null
+ || styleReference.metadata.assetId !== selectedStyle.assetId
+ || styleReference.metadata.revision !== selectedStyle.revision
+ || styleReference.sha256 !== primaryStyleReference?.sha256
+ ))
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_style_contract_stale',
+ 'The materialized style reference does not match the selected visual style'
+ );
+ }
+ const expectsPreviousShotReference = shouldUsePreviousShotReference(shot, shotIndex);
+ const previousShotImage = previousStickmanShotImage({
+ artifacts: stage.inputArtifacts,
+ shotSpec,
+ shotIndex
+ });
+ if (
+ expectsPreviousShotReference
+ && (
+ previousShotImage?.path === null
+ || previousShotImage?.path === undefined
+ || previousShotImage.sha256 === null
+ )
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_previous_shot_reference_missing',
+ `Previous shot image is required to preserve visual continuity for ${scopeKey}`
+ );
+ }
+ const referenceImages = [{
+ role: 'character_identity',
+ content: sourceReferenceContent,
+ mime: characterReferenceMime,
+ sha256: characterReferenceSha256,
+ artifactId: characterReference.id
+ }];
+ if (styleReference?.path !== null && styleReference?.path !== undefined) {
+ const content = await readFile(styleReference.path);
+ const sha256 = createHash('sha256').update(content).digest('hex');
+ if (sha256 !== styleReference.sha256) {
+ throw new CreatorExecutorError(
+ 'creator_style_reference_changed',
+ 'The visual style reference no longer matches its artifact hash'
+ );
+ }
+ referenceImages.push({
+ role: 'visual_style',
+ content,
+ mime: readReferenceMime(styleReference.path, styleReference.metadata.mimeType),
+ sha256,
+ artifactId: styleReference.id
+ });
+ }
+ if (previousShotImage?.path !== null && previousShotImage?.path !== undefined) {
+ const content = await readFile(previousShotImage.path);
+ const sha256 = createHash('sha256').update(content).digest('hex');
+ if (sha256 !== previousShotImage.sha256) {
+ throw new CreatorExecutorError(
+ 'creator_previous_shot_reference_changed',
+ 'The previous shot image no longer matches its artifact hash'
+ );
+ }
+ referenceImages.push({
+ role: 'previous_shot',
+ content,
+ mime: readReferenceMime(previousShotImage.path, previousShotImage.metadata.mimeType),
+ sha256,
+ artifactId: previousShotImage.id
+ });
+ }
+ const requestReferenceSha256 = createHash('sha256')
+ .update(referenceImages.map(reference => `${reference.role}:${reference.sha256}`).join('\n'))
+ .digest('hex');
+ const sourceArtifactIds = [...new Set([
+ ...stage.inputArtifacts
+ .filter(artifact => artifact.kind !== 'shot_image')
+ .map(artifact => artifact.id),
+ ...(previousShotImage === undefined ? [] : [previousShotImage.id])
+ ])];
+ const config = await input.configStore.read();
+ const provider = config.image.provider;
+ const quality = readQuality(stage.job.state.quality);
+ assertReferenceImageSupport(provider, referenceImages.length);
+ const model = config.image[provider].model;
+ if (
+ promptPackArtifact.metadata.contract !== STICKMAN_IMAGE_PROMPT_CONTRACT
+ || promptPack.characterReferenceArtifactId !== characterReference.id
+ || promptPack.styleContractArtifactId !== styleContractArtifact.id
+ || promptPack.styleReferenceArtifactId !== styleReference?.id
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_image_prompt_stale',
+ 'The image prompt pack does not match the current visual profile'
+ );
+ }
+ const generationPrompt = shotPrompt.prompt;
+ const request = {
+ prompt: generationPrompt,
+ provider,
+ size: '1536x1024' as const,
+ quality,
+ count: 1
+ };
+ const candidateLimit = 3;
+ const candidateFailures: string[] = [];
+ for (let candidateAttempt = 1; candidateAttempt <= candidateLimit; candidateAttempt += 1) {
+ const candidatePrompt = candidateAttempt === 1
+ ? request.prompt
+ : [
+ request.prompt,
+ 'Regenerate from scratch. The previous candidate failed an automated image-quality check.',
+ 'Keep the attached reference as the exact same protagonist; do not change hairstyle, eyewear, clothing silhouette, or outfit details.',
+ 'Do not draw any letters, words, numbers, captions, labels, signs, watermarks, or interface text.'
+ ].join('\n');
+ const candidateRequest = { ...request, prompt: candidatePrompt };
+ const requestKey = `${stage.job.id}:images:${scopeKey}:${inputFingerprint}:candidate:${candidateAttempt}`;
+ const ledger = input.ledger.registerBeforeSubmit({
+ jobId: stage.job.id,
+ provider,
+ stageRunId: stage.stageRun.id,
+ scopeKey,
+ requestKey,
+ request: {
+ ...candidateRequest,
+ model,
+ characterReferenceSha256,
+ requestReferenceSha256,
+ characterReferenceMime,
+ referenceImages: referenceImages.map(reference => ({
+ role: reference.role,
+ sha256: reference.sha256,
+ mimeType: reference.mime,
+ artifactId: reference.artifactId
+ })),
+ characterAsset: selectedCharacter,
+ styleAsset: selectedStyle,
+ referenceImagePreparation: STICKMAN_CHARACTER_REFERENCE_PREPARATION,
+ imagePromptContract: STICKMAN_IMAGE_PROMPT_CONTRACT
+ }
+ });
+ input.ledger.markSubmitting(ledger.id);
+ stage.reportProgress({
+ phase: candidateAttempt === 1 ? 'submitting' : 'retrying_candidate',
+ percent: Math.round((
+ (shotIndex + (candidateAttempt - 0.9) / candidateLimit) / shotCount
+ ) * 100),
+ completed: shotIndex,
+ failed: candidateAttempt - 1,
+ total: shotCount,
+ ledgerId: ledger.id
+ });
+ let result: Awaited<ReturnType<typeof generate>>;
+ try {
+ result = await generate(candidateRequest, config, {
+ signal: stage.signal,
+ referenceImages: referenceImages.map(reference => ({
+ content: reference.content,
+ mime: reference.mime
+ }))
+ });
+ input.ledger.markSucceeded(ledger.id);
+ } catch (error) {
+ input.ledger.markFailed(ledger.id);
+ throw error;
+ }
+ const image = result.contents[0];
+ if (image === undefined) {
+ candidateFailures.push(`Candidate ${candidateAttempt} returned no image`);
+ if (candidateAttempt < candidateLimit) continue;
+ break;
+ }
+ const extension = image.mime === 'image/jpeg' ? 'jpg' : image.mime === 'image/webp' ? 'webp' : 'png';
+ const candidatePath = join(stage.workdir, `${scopeKey}-candidate-${candidateAttempt}.${extension}`);
+ await sharp(image.content)
+ .resize(1280, 720, { fit: 'cover', position: 'centre' })
+ .toFile(candidatePath);
+ let candidateQuality: StickmanImageCandidateQuality;
+ try {
+ candidateQuality = await validateCandidate(candidatePath);
+ } catch (error) {
+ candidateFailures.push(
+ error instanceof Error ? error.message : `Candidate ${candidateAttempt} failed quality checks`
+ );
+ if (candidateAttempt < candidateLimit) continue;
+ break;
+ }
+ const path = join(stage.workdir, `${scopeKey}.${extension}`);
+ await copyFile(candidatePath, path);
+ const metadata = await validateImageFile(path);
+ return {
+ outputs: [{
+ kind: 'shot_image',
+ status: 'completed',
+ path,
+ sourceArtifactIds,
+ metadata: {
+ ...metadata,
+ shotId: scopeKey,
+ prompt: candidateRequest.prompt,
+ provider,
+ model: result.model,
+ quality,
+ width: candidateQuality.width,
+ height: candidateQuality.height,
+ brightnessMean: candidateQuality.brightnessMean,
+ contrastStddev: candidateQuality.contrastStddev,
+ ocrStatus: candidateQuality.ocrStatus,
+ detectedText: candidateQuality.detectedText,
+ characterReferenceArtifactId: characterReference.id,
+ characterReferenceSha256,
+ requestReferenceSha256,
+ characterReferenceMime,
+ referenceImages: referenceImages.map(reference => ({
+ role: reference.role,
+ sha256: reference.sha256,
+ mimeType: reference.mime,
+ artifactId: reference.artifactId
+ })),
+ characterAssetId: selectedCharacter.assetId,
+ characterRevision: selectedCharacter.revision,
+ styleAssetId: selectedStyle.assetId,
+ styleRevision: selectedStyle.revision,
+ ...(previousShotImage === undefined ? {} : {
+ previousShotArtifactId: previousShotImage.id,
+ previousShotSha256: previousShotImage.sha256
+ }),
+ referenceImagePreparation: STICKMAN_CHARACTER_REFERENCE_PREPARATION,
+ imagePromptContract: STICKMAN_IMAGE_PROMPT_CONTRACT,
+ ledgerId: ledger.id,
+ candidateAttempt,
+ candidateLimit,
+ candidateFailures
+ }
+ }],
+ progress: {
+ phase: 'completed',
+ percent: Math.round(((shotIndex + 1) / shotCount) * 100),
+ completed: shotIndex + 1,
+ failed: 0,
+ total: shotCount,
+ ledgerId: ledger.id
+ }
+ };
+ }
+ throw new CreatorExecutorError(
+ 'creator_shot_image_invalid',
+ `Image quality retries exhausted for ${scopeKey}: ${candidateFailures.join('; ')}`
+ );
+ }
+ };
+}
+
+type StickmanImageCandidateQuality = {
+ width: number;
+ height: number;
+ brightnessMean: number;
+ contrastStddev: number;
+ ocrStatus: 'passed' | 'unavailable';
+ detectedText: string[];
+};
+
+async function inspectStickmanImageCandidate(
+ path: string,
+ tesseractPath?: string
+): Promise<StickmanImageCandidateQuality> {
+ let metadata: Awaited<ReturnType<typeof sharp.prototype.metadata>>;
+ let stats: Awaited<ReturnType<typeof sharp.prototype.stats>>;
+ try {
+ [metadata, stats] = await Promise.all([
+ sharp(path).metadata(),
+ sharp(path).greyscale().stats()
+ ]);
+ } catch {
+ throw new CreatorExecutorError('creator_shot_image_invalid', 'Generated image is not decodable');
+ }
+ const width = metadata.width ?? 0;
+ const height = metadata.height ?? 0;
+ if (width <= 0 || height <= 0 || Math.abs(width / height - 16 / 9) > 0.03) {
+ throw new CreatorExecutorError('creator_shot_image_invalid', 'Generated image is not 16:9');
+ }
+ const brightnessMean = stats.channels[0]?.mean ?? 0;
+ const contrastStddev = stats.channels[0]?.stdev ?? 0;
+ if (brightnessMean < 12 || brightnessMean > 248 || contrastStddev < 8) {
+ throw new CreatorExecutorError(
+ 'creator_shot_image_unreadable',
+ 'Generated image appears blank or unreadable'
+ );
+ }
+ const detectedText = tesseractPath === undefined
+ ? []
+ : await runCandidateTesseract(tesseractPath, path);
+ if (detectedText.length > 0) {
+ throw new CreatorExecutorError(
+ 'creator_visual_text_detected',
+ `Generated image contains prohibited visible text: ${detectedText.join(', ')}`
+ );
+ }
+ return {
+ width,
+ height,
+ brightnessMean: roundMetric(brightnessMean),
+ contrastStddev: roundMetric(contrastStddev),
+ ocrStatus: tesseractPath === undefined ? 'unavailable' : 'passed',
+ detectedText
+ };
+}
+
+function runCandidateTesseract(tesseractPath: string, path: string): Promise<string[]> {
+ return new Promise((resolve, reject) => {
+ execFile(
+ tesseractPath,
+ [path, 'stdout', '--psm', '11', 'tsv'],
+ { windowsHide: true, timeout: 120_000, maxBuffer: 8 * 1024 * 1024 },
+ (error, stdout) => {
+ if (error) {
+ reject(new CreatorExecutorError(
+ 'creator_visual_ocr_failed',
+ `Tesseract failed for ${path}: ${error.message}`
+ ));
+ return;
+ }
+ resolve(String(stdout).split(/\r?\n/).slice(1).flatMap(line => {
+ const columns = line.split('\t');
+ const confidence = Number(columns[10]);
+ const text = columns[11]?.trim() ?? '';
+ const normalized = text.replace(/[^A-Za-z0-9\u3400-\u9fff]/g, '');
+ return confidence >= 80 && normalized.length >= 3 ? [text] : [];
+ }));
+ }
+ );
+ });
+}
+
+function roundMetric(value: number): number {
+ return Math.round(value * 1_000) / 1_000;
+}
+
+function assertReferenceImageSupport(provider: ImageGenerationProvider, count: number): void {
+ const capabilities = imageGenerationCapabilities(provider);
+ if (capabilities.supportsReferenceImage && capabilities.maxReferenceImages >= count) return;
+ throw new CreatorExecutorError(
+ 'creator_stickman_image_provider_unsupported',
+ `当前生图服务 ${provider} 不支持任务需要的 ${count} 张参考图。请在 AI 服务 -> 生图服务中切换到支持多参考图的 OpenAI 或 Gemini 服务`
+ );
+}
+
+function readReferenceMime(
+ path: string,
+ configured: unknown
+): 'image/png' | 'image/jpeg' | 'image/webp' {
+ if (configured === 'image/jpeg' || configured === 'image/webp') return configured;
+ if (configured === 'image/png') return configured;
+ if (/\.jpe?g$/i.test(path)) return 'image/jpeg';
+ if (/\.webp$/i.test(path)) return 'image/webp';
+ return 'image/png';
+}
+
+function readQuality(value: unknown): ImageGenerationQuality {
+ return value === 'low' || value === 'high' ? value : 'medium';
+}
diff --git a/apps/daemon/src/creator/stickman/image-prompt.ts b/apps/daemon/src/creator/stickman/image-prompt.ts
new file mode 100644
index 00000000..0a27e821
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/image-prompt.ts
@@ -0,0 +1,76 @@
+import type { StickmanShot, StickmanStyleContract } from './contracts.js';
+
+export const STICKMAN_CHARACTER_REFERENCE_PREPARATION = 'original-bytes-v2';
+export const STICKMAN_IMAGE_PROMPT_CONTRACT = 'stickman-visual-profile-prompt-v2';
+
+export function shouldUsePreviousShotReference(shot: StickmanShot, shotIndex: number): boolean {
+ return shotIndex > 0 && shot.continuityReason.trim().length > 0;
+}
+
+export function buildStickmanImagePrompt(input: {
+ visualProfile: StickmanStyleContract;
+ shot: StickmanShot;
+ hasStyleReference: boolean;
+ hasPreviousShotReference: boolean;
+}): string {
+ const { character, style } = input.visualProfile;
+ const referenceInstructions = input.hasStyleReference
+ ? [
+ 'Reference Image 1 is the CHARACTER IDENTITY source of truth. Preserve who the protagonist is; do not borrow its original pose, framing, or background.',
+ 'Reference Image 2 is the STYLE source of truth. Borrow only its medium, surface, linework, shading, and palette; do not copy its person, objects, composition, text, or scene.'
+ ]
+ : [
+ 'Reference Image 1 is the CHARACTER IDENTITY source of truth. Preserve who the protagonist is; do not borrow its original pose, framing, or background.',
+ 'There is no style reference image. Follow the complete rendering contract below exactly.'
+ ];
+ if (input.hasPreviousShotReference) {
+ const previousReferenceNumber = input.hasStyleReference ? 3 : 2;
+ referenceInstructions.push(
+ `Reference Image ${previousReferenceNumber} is the PREVIOUS SHOT from the same narrative sequence. Preserve recurring objects, their recognizable shape and relative scale, the location, and the established visual state.`,
+ 'Use the previous shot only for continuity. Follow the current shot for camera distance, composition, protagonist pose, action, and lighting; do not simply copy the previous frame.'
+ );
+ }
+
+ return [
+ 'Create exactly one full-frame 16:9 narrative image for a recurring stick-figure video.',
+ '',
+ '[REFERENCE RESPONSIBILITIES]',
+ ...referenceInstructions,
+ '',
+ '[CHARACTER IDENTITY - WHAT MUST REMAIN THE SAME]',
+ `Preserve: ${character.identity.preserve}.`,
+ `Forbidden identity changes: ${character.identity.prohibit}.`,
+ 'Keep the same head and face, hair, eyewear, clothing silhouette, outfit details, accessories, age presentation, gender presentation, and stick-figure proportions in every shot.',
+ 'Only pose, facial expression, camera framing, and interaction with scene objects may change.',
+ 'Secondary people may appear only when required by the shot. Keep them subordinate and visually distinct from the protagonist.',
+ '',
+ '[VISUAL STYLE - HOW EVERYTHING MUST BE DRAWN]',
+ `Medium: ${style.rendering.medium}.`,
+ `Surface: ${style.rendering.surface}.`,
+ `Linework: ${style.rendering.linework}.`,
+ `Shading: ${style.rendering.shading}.`,
+ `Palette: ${style.rendering.palette}.`,
+ `Scene density: ${style.rendering.sceneDensity}.`,
+ `Composition: ${style.rendering.composition}.`,
+ `Character rendering: ${style.rendering.characterRendering}.`,
+ '',
+ '[SEMANTIC-TO-VISUAL TRANSLATION]',
+ `Color words: ${style.semanticRenderingRules.color}.`,
+ `Light words: ${style.semanticRenderingRules.light}.`,
+ `Complex environments: ${style.semanticRenderingRules.complexEnvironment}.`,
+ 'A source phrase such as pale golden glow describes meaning and emphasis, not permission to introduce yellow. Translate it through the selected palette and lighting rules.',
+ '',
+ '[SHOT CONTENT - WHAT THIS FRAME MUST COMMUNICATE]',
+ `Semantic anchor: ${input.shot.semanticAnchor}.`,
+ `Concrete scene: ${input.shot.visualDescription}.`,
+ `Composition and action: ${input.shot.compositionAndAction}.`,
+ `Required objects: ${input.shot.keyObjects.join('; ')}.`,
+ `Continuity from adjacent shots: ${input.shot.continuityReason || 'No additional continuity constraint.'}.`,
+ 'Preserve the semantic anchor first. Simplify decorative details when necessary, but never remove an action-critical object or change the stated relationship between subjects and objects.',
+ 'Express one immediately readable moment, with a clear protagonist silhouette and a coherent foreground, middle ground, and background.',
+ '',
+ '[HARD EXCLUSIONS]',
+ `Never produce: ${style.forbiddenDirections.join(', ')}.`,
+ 'Do not add captions, labels, letters, numbers, logos, watermarks, subtitles, interfaces, character sheets, collages, or split-panel layouts.'
+ ].join('\n');
+}
diff --git a/apps/daemon/src/creator/stickman/legacy-migration.ts b/apps/daemon/src/creator/stickman/legacy-migration.ts
new file mode 100644
index 00000000..6e6bc8b0
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/legacy-migration.ts
@@ -0,0 +1,193 @@
+import type Database from 'better-sqlite3';
+import { rm } from 'node:fs/promises';
+import { isAbsolute, relative, resolve } from 'node:path';
+
+const migrationKey = 'purge-stickman-video-v1';
+
+const legacyStyleAssets: Record<string, string> = {
+ '极简黑白线稿': 'stickman.style.minimal-ink',
+ '纸面铅笔手绘': 'stickman.style.paper-pencil',
+ '漫画分镜线稿': 'stickman.style.comic-storyboard',
+ '白板讲解线稿': 'stickman.style.whiteboard-marker'
+};
+
+const legacyCharacterIds = new Set([
+ 'default',
+ 'tech-guy',
+ 'long-hair',
+ 'short-hair',
+ 'student',
+ 'manager',
+ 'hiphop',
+ 'elder',
+ 'chef',
+ 'fitness'
+]);
+
+type MigrationState = {
+ pendingJobIds: string[];
+ blockedJobIds: string[];
+ completed: boolean;
+};
+
+export async function purgeLegacyStickmanJobs(input: {
+ db: Database.Database;
+ jobsRoot: string;
+ removeDirectory?(path: string): Promise<void>;
+}): Promise<MigrationState> {
+ ensureMigrationTable(input.db);
+ const state = input.db.transaction(() => {
+ const previous = readState(input.db);
+ const rows = input.db.prepare(`
+ SELECT id
+ FROM creator_jobs
+ WHERE template_id = 'stickman-video' AND template_version = 1
+ ORDER BY id ASC
+ `).all() as Array<{ id: string }>;
+ const pendingJobIds = [...new Set([
+ ...previous.pendingJobIds,
+ ...rows.map(row => row.id)
+ ])];
+ if (rows.length > 0) {
+ const removeJob = input.db.prepare('DELETE FROM creator_jobs WHERE id = ?');
+ for (const row of rows) removeJob.run(row.id);
+ }
+ const next: MigrationState = {
+ pendingJobIds,
+ blockedJobIds: previous.blockedJobIds,
+ completed: pendingJobIds.length === 0
+ };
+ writeState(input.db, next);
+ return next;
+ })();
+
+ const removeDirectory = input.removeDirectory
+ ?? (path => rm(path, { recursive: true, force: true }));
+ const root = resolve(input.jobsRoot);
+ const pending: string[] = [];
+ const blocked = new Set(state.blockedJobIds);
+ for (const jobId of state.pendingJobIds) {
+ const target = resolve(root, jobId);
+ const targetRelative = relative(root, target);
+ if (
+ targetRelative === ''
+ || targetRelative.startsWith('..')
+ || isAbsolute(targetRelative)
+ ) {
+ blocked.add(jobId);
+ pending.push(jobId);
+ continue;
+ }
+ try {
+ await removeDirectory(target);
+ } catch {
+ pending.push(jobId);
+ }
+ writeState(input.db, {
+ pendingJobIds: pending.concat(state.pendingJobIds.slice(state.pendingJobIds.indexOf(jobId) + 1)),
+ blockedJobIds: [...blocked],
+ completed: false
+ });
+ }
+ const result: MigrationState = {
+ pendingJobIds: pending,
+ blockedJobIds: [...blocked].sort(),
+ completed: pending.length === 0
+ };
+ writeState(input.db, result);
+ return result;
+}
+
+export function migrateStickmanVisualAssetState(input: {
+ db: Database.Database;
+}): { migratedJobIds: string[] } {
+ const rows = input.db.prepare(`
+ SELECT id, state_json
+ FROM creator_jobs
+ WHERE template_id = 'stickman-video' AND template_version = 2
+ ORDER BY id ASC
+ `).all() as Array<{ id: string; state_json: string }>;
+ const update = input.db.prepare(`
+ UPDATE creator_jobs
+ SET state_json = ?, updated_at = ?
+ WHERE id = ?
+ `);
+ const migratedJobIds: string[] = [];
+ input.db.transaction(() => {
+ for (const row of rows) {
+ const state = JSON.parse(row.state_json) as Record<string, unknown>;
+ const characterAsset = readStoredAssetRef(state.characterAsset)
+ ?? {
+ assetId: `stickman.character.${readLegacyCharacterId(state.selectedPresetId)}`,
+ revision: 1
+ };
+ const styleAsset = readStoredAssetRef(state.styleAsset)
+ ?? {
+ assetId: legacyStyleAssets[typeof state.style === 'string' ? state.style : '']
+ ?? 'stickman.style.minimal-ink',
+ revision: 1
+ };
+ const next: Record<string, unknown> = { ...state, characterAsset, styleAsset };
+ delete next.selectedPresetId;
+ delete next.style;
+ if (JSON.stringify(next) === row.state_json) continue;
+ update.run(JSON.stringify(next), new Date().toISOString(), row.id);
+ migratedJobIds.push(row.id);
+ }
+ })();
+ return { migratedJobIds };
+}
+
+function readStoredAssetRef(value: unknown): { assetId: string; revision: number } | undefined {
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return undefined;
+ const record = value as Record<string, unknown>;
+ if (
+ typeof record.assetId !== 'string'
+ || !Number.isSafeInteger(record.revision)
+ || Number(record.revision) <= 0
+ ) return undefined;
+ return { assetId: record.assetId, revision: Number(record.revision) };
+}
+
+function readLegacyCharacterId(value: unknown): string {
+ return typeof value === 'string' && legacyCharacterIds.has(value) ? value : 'default';
+}
+
+function ensureMigrationTable(db: Database.Database): void {
+ db.exec(`
+ CREATE TABLE IF NOT EXISTS creator_data_migrations (
+ key TEXT PRIMARY KEY,
+ state_json TEXT NOT NULL,
+ updated_at TEXT NOT NULL
+ );
+ `);
+}
+
+function readState(db: Database.Database): MigrationState {
+ const row = db.prepare(`
+ SELECT state_json
+ FROM creator_data_migrations
+ WHERE key = ?
+ `).get(migrationKey) as { state_json: string } | undefined;
+ if (row === undefined) return { pendingJobIds: [], blockedJobIds: [], completed: false };
+ const parsed = JSON.parse(row.state_json) as Partial<MigrationState>;
+ return {
+ pendingJobIds: Array.isArray(parsed.pendingJobIds)
+ ? parsed.pendingJobIds.filter(item => typeof item === 'string')
+ : [],
+ blockedJobIds: Array.isArray(parsed.blockedJobIds)
+ ? parsed.blockedJobIds.filter(item => typeof item === 'string')
+ : [],
+ completed: parsed.completed === true
+ };
+}
+
+function writeState(db: Database.Database, state: MigrationState): void {
+ db.prepare(`
+ INSERT INTO creator_data_migrations (key, state_json, updated_at)
+ VALUES (?, ?, ?)
+ ON CONFLICT(key) DO UPDATE SET
+ state_json = excluded.state_json,
+ updated_at = excluded.updated_at
+ `).run(migrationKey, JSON.stringify(state), new Date().toISOString());
+}
diff --git a/apps/daemon/src/creator/stickman/lineage.ts b/apps/daemon/src/creator/stickman/lineage.ts
new file mode 100644
index 00000000..c477509e
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/lineage.ts
@@ -0,0 +1,253 @@
+import { createHash } from 'node:crypto';
+import type { CreatorArtifact, CreatorJob, CreatorJson } from '@opencreator/protocol';
+import type { CreatorRepository } from '../repository.js';
+import type { StickmanShot, StickmanShotSpec } from './contracts.js';
+import {
+ STICKMAN_CHARACTER_REFERENCE_PREPARATION,
+ STICKMAN_IMAGE_PROMPT_CONTRACT,
+ shouldUsePreviousShotReference
+} from './image-prompt.js';
+import {
+ DEFAULT_STICKMAN_CHARACTER_ASSET,
+ DEFAULT_STICKMAN_STYLE_ASSET,
+ readVisualAssetRef
+} from './visual-assets.js';
+
+export type StickmanImageSettings = {
+ provider: string;
+ model: string;
+ quality: string;
+};
+
+export type StickmanTtsSettings = {
+ provider: string;
+ model: string;
+ voiceId: string;
+};
+
+export function stickmanNarrationFingerprint(input: {
+ segment: { id: string; narration: string };
+ script: CreatorArtifact;
+ settings: StickmanTtsSettings;
+}): string {
+ return createHash('sha256').update(canonicalJson({
+ segmentId: input.segment.id,
+ narration: input.segment.narration,
+ scriptSha256: input.script.sha256,
+ provider: input.settings.provider,
+ model: input.settings.model,
+ voiceId: input.settings.voiceId,
+ format: 'wav'
+ })).digest('hex');
+}
+
+export function currentNarrationAudio(
+ job: CreatorJob,
+ scopeKey: string,
+ inputFingerprint: string
+): CreatorArtifact | undefined {
+ return [...job.artifacts].reverse().find(artifact => (
+ artifact.kind === 'narration_audio'
+ && artifact.scopeKey === scopeKey
+ && artifact.inputFingerprint === inputFingerprint
+ && artifact.status === 'completed'
+ ));
+}
+
+export function stickmanShotFingerprint(input: {
+ shot: StickmanShot;
+ job: CreatorJob;
+ shotSpec: CreatorArtifact;
+ characterReference?: CreatorArtifact;
+ styleReference?: CreatorArtifact;
+ styleContract?: CreatorArtifact;
+ promptPack?: CreatorArtifact;
+ previousShotImage?: CreatorArtifact;
+ settings: StickmanImageSettings;
+}): string {
+ return createHash('sha256').update(canonicalJson({
+ shot: input.shot as unknown as CreatorJson,
+ characterAsset: readVisualAssetRef(
+ input.job.state.characterAsset,
+ DEFAULT_STICKMAN_CHARACTER_ASSET
+ ) as unknown as CreatorJson,
+ styleAsset: readVisualAssetRef(
+ input.job.state.styleAsset,
+ DEFAULT_STICKMAN_STYLE_ASSET
+ ) as unknown as CreatorJson,
+ ratio: input.job.state.ratio ?? '16:9',
+ provider: input.settings.provider,
+ model: input.settings.model,
+ quality: input.settings.quality,
+ characterReferencePreparation: STICKMAN_CHARACTER_REFERENCE_PREPARATION,
+ imagePromptContract: STICKMAN_IMAGE_PROMPT_CONTRACT,
+ shotSpecSha256: input.shotSpec.sha256,
+ characterReferenceSha256: input.characterReference?.sha256 ?? null,
+ styleReferenceSha256: input.styleReference?.sha256 ?? null,
+ styleContractSha256: input.styleContract?.sha256 ?? null,
+ promptPackSha256: input.promptPack?.sha256 ?? null,
+ previousShotImageSha256: input.previousShotImage?.sha256 ?? null
+ })).digest('hex');
+}
+
+export function previousStickmanShotImage(input: {
+ artifacts: CreatorArtifact[];
+ shotSpec: StickmanShotSpec;
+ shotIndex: number;
+}): CreatorArtifact | undefined {
+ const shot = input.shotSpec.shots[input.shotIndex];
+ const previousShot = input.shotSpec.shots[input.shotIndex - 1];
+ if (
+ shot === undefined
+ || previousShot === undefined
+ || !shouldUsePreviousShotReference(shot, input.shotIndex)
+ ) return undefined;
+ return [...input.artifacts].reverse().find(artifact => (
+ artifact.kind === 'shot_image'
+ && artifact.scopeKey === previousShot.id
+ && artifact.status === 'completed'
+ ));
+}
+
+export function currentShotImage(
+ job: CreatorJob,
+ scopeKey: string,
+ inputFingerprint: string
+): CreatorArtifact | undefined {
+ return [...job.artifacts].reverse().find(artifact => (
+ artifact.kind === 'shot_image'
+ && artifact.scopeKey === scopeKey
+ && artifact.inputFingerprint === inputFingerprint
+ && artifact.status === 'completed'
+ ));
+}
+
+export function currentStickmanScopedArtifacts(
+ job: CreatorJob,
+ kind: 'shot_image' | 'narration_audio'
+): CreatorArtifact[] {
+ const stageId = kind === 'shot_image' ? 'images' : 'narration';
+ const completedByScope = new Map<string, CreatorArtifact[]>();
+ for (const artifact of job.artifacts) {
+ if (artifact.kind !== kind || artifact.status !== 'completed' || artifact.scopeKey === null) continue;
+ completedByScope.set(artifact.scopeKey, [
+ ...(completedByScope.get(artifact.scopeKey) ?? []),
+ artifact
+ ]);
+ }
+
+ const current: CreatorArtifact[] = [];
+ for (const [scopeKey, artifacts] of completedByScope) {
+ const latestSucceededStage = [...job.stages].reverse().find(stage => (
+ stage.stageId === stageId
+ && stage.scopeKey === scopeKey
+ && stage.inputFingerprint !== null
+ && stage.status === 'succeeded'
+ ));
+ const selected = latestSucceededStage === undefined
+ ? artifacts.at(-1)
+ : [...artifacts].reverse().find(artifact => (
+ artifact.inputFingerprint === latestSucceededStage.inputFingerprint
+ ));
+ if (selected !== undefined) current.push(selected);
+ }
+ return current;
+}
+
+export function staleSupersededStickmanScopedArtifacts(input: {
+ repository: CreatorRepository;
+ job: CreatorJob;
+ kind: 'shot_image' | 'narration_audio';
+}): string[] {
+ const currentByScope = new Map(
+ currentStickmanScopedArtifacts(input.job, input.kind)
+ .map(artifact => [artifact.scopeKey!, artifact.id])
+ );
+ const roots = input.job.artifacts.filter(artifact => (
+ artifact.kind === input.kind
+ && artifact.status === 'completed'
+ && artifact.scopeKey !== null
+ && currentByScope.has(artifact.scopeKey)
+ && currentByScope.get(artifact.scopeKey) !== artifact.id
+ ));
+ return staleArtifactsAndDependents(input.repository, input.job, roots);
+}
+
+export function staleStickmanShotScope(input: {
+ repository: CreatorRepository;
+ job: CreatorJob;
+ scopeKey: string;
+}): string[] {
+ const roots = input.job.artifacts.filter(artifact => (
+ artifact.kind === 'shot_image'
+ && artifact.scopeKey === input.scopeKey
+ && artifact.status !== 'stale'
+ ));
+ return staleArtifactsAndDependents(input.repository, input.job, roots);
+}
+
+function staleArtifactsAndDependents(
+ repository: CreatorRepository,
+ job: CreatorJob,
+ roots: CreatorArtifact[]
+): string[] {
+ const stale = new Set(roots.map(artifact => artifact.id));
+ const queue = [...stale];
+ while (queue.length > 0) {
+ const current = queue.shift()!;
+ for (const artifact of job.artifacts) {
+ if (artifact.status === 'stale' || !artifact.sourceArtifactIds.includes(current)) continue;
+ if (!stale.has(artifact.id)) {
+ stale.add(artifact.id);
+ queue.push(artifact.id);
+ }
+ }
+ }
+ for (const id of stale) repository.setArtifactStatus(id, 'stale');
+ return [...stale];
+}
+
+export function missingCurrentShots(input: {
+ job: CreatorJob;
+ shotSpec: StickmanShotSpec;
+ shotSpecArtifact: CreatorArtifact;
+ characterReference?: CreatorArtifact;
+ styleReference?: CreatorArtifact;
+ styleContract?: CreatorArtifact;
+ settings: StickmanImageSettings;
+}): Array<{ shot: StickmanShot; fingerprint: string }> {
+ return input.shotSpec.shots.flatMap((shot, shotIndex) => {
+ const previousShotImage = previousStickmanShotImage({
+ artifacts: input.job.artifacts,
+ shotSpec: input.shotSpec,
+ shotIndex
+ });
+ const fingerprint = stickmanShotFingerprint({
+ shot,
+ job: input.job,
+ shotSpec: input.shotSpecArtifact,
+ characterReference: input.characterReference,
+ styleReference: input.styleReference,
+ styleContract: input.styleContract,
+ previousShotImage,
+ settings: input.settings
+ });
+ return currentShotImage(input.job, shot.id, fingerprint) === undefined
+ ? [{ shot, fingerprint }]
+ : [];
+ });
+}
+
+function canonicalJson(value: CreatorJson): string {
+ return JSON.stringify(sortValue(value));
+}
+
+function sortValue(value: CreatorJson): CreatorJson {
+ if (Array.isArray(value)) return value.map(sortValue);
+ if (value === null || typeof value !== 'object') return value;
+ return Object.fromEntries(
+ Object.entries(value)
+ .sort(([left], [right]) => left.localeCompare(right))
+ .map(([key, entry]) => [key, sortValue(entry)])
+ );
+}
diff --git a/apps/daemon/src/creator/stickman/media-validation-executor.ts b/apps/daemon/src/creator/stickman/media-validation-executor.ts
new file mode 100644
index 00000000..a6bc00b4
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/media-validation-executor.ts
@@ -0,0 +1,216 @@
+import { createHash } from 'node:crypto';
+import { execFile } from 'node:child_process';
+import { createReadStream } from 'node:fs';
+import { mkdir, readFile, writeFile } from 'node:fs/promises';
+import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
+import sharp from 'sharp';
+import type { CreatorArtifact } from '@opencreator/protocol';
+import type { CreatorExecutor } from '../executor.js';
+import { CreatorExecutorError } from '../executor.js';
+import { validateMediaFile } from '../validators/media.js';
+import { stickmanMediaValidationSchema, stickmanTimelineSchema } from './contracts.js';
+
+type MediaProbe = typeof validateMediaFile;
+type FrameSample = {
+ index: number;
+ timestampSeconds: number;
+ sha256: string;
+ width: 1280;
+ height: 720;
+ brightnessMean: number;
+ contrastStddev: number;
+};
+
+export function createStickmanMediaValidationExecutor(input: {
+ ffprobePath: string;
+ ffmpegPath: string;
+ validateVideo?: MediaProbe;
+ sampleFrames?: (path: string, duration: number, workdir: string) => Promise<FrameSample[]>;
+}): CreatorExecutor {
+ const validateVideo = input.validateVideo ?? validateMediaFile;
+ const sampleFrames = input.sampleFrames
+ ?? ((path, duration, workdir) => sampleVideoFrames(input.ffmpegPath, path, duration, workdir));
+ return {
+ id: 'stickman-media-validation',
+ async run(stage) {
+ const cleanVideo = requireArtifact(stage.inputArtifacts, 'clean_video');
+ const timelineArtifact = requireArtifact(stage.inputArtifacts, 'timeline_manifest');
+ if (
+ cleanVideo.path === null
+ || cleanVideo.sha256 === null
+ || timelineArtifact.path === null
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_stage_input_missing',
+ 'Clean video, its hash, and Timeline are required for media validation'
+ );
+ }
+ const jobRoot = dirname(resolve(stage.workdir));
+ assertInside(jobRoot, cleanVideo.path);
+ assertInside(jobRoot, timelineArtifact.path);
+ const actualVideoSha256 = await sha256File(cleanVideo.path);
+ if (actualVideoSha256 !== cleanVideo.sha256.toLowerCase()) {
+ throw new CreatorExecutorError(
+ 'creator_media_validation_hash_mismatch',
+ 'Clean video no longer matches its artifact hash'
+ );
+ }
+ if (!cleanVideo.sourceArtifactIds.includes(timelineArtifact.id)) {
+ throw new CreatorExecutorError(
+ 'creator_media_validation_lineage_mismatch',
+ 'Clean video is not derived from the current Timeline'
+ );
+ }
+ const timeline = stickmanTimelineSchema.parse(JSON.parse(
+ await readFile(timelineArtifact.path, 'utf8')
+ ));
+ const expectedDuration = timeline.totalFrames / timeline.fps;
+ const durationTolerance = Math.max(0.15, 2 / timeline.fps);
+ const media = await validateVideo(cleanVideo.path, input.ffprobePath);
+ if (
+ media.width !== 1280
+ || media.height !== 720
+ || !media.hasVideo
+ || !media.hasAudio
+ || Math.abs(media.duration - expectedDuration) > durationTolerance
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_media_validation_failed',
+ 'Clean video must be decodable 1280x720 audio/video media with Timeline-matched duration'
+ );
+ }
+ const sampledFrames = await sampleFrames(
+ cleanVideo.path,
+ media.duration,
+ join(stage.workdir, 'frame-samples')
+ );
+ if (sampledFrames.length !== 3) {
+ throw new CreatorExecutorError(
+ 'creator_media_validation_frame_count',
+ 'Media validation requires exactly three decoded frame samples'
+ );
+ }
+ const report = stickmanMediaValidationSchema.parse({
+ ok: true,
+ validation: 'ffprobe_and_three_frame_sampling',
+ cleanVideoArtifactId: cleanVideo.id,
+ cleanVideoSha256: actualVideoSha256,
+ timelineArtifactId: timelineArtifact.id,
+ duration: media.duration,
+ expectedDuration,
+ durationTolerance,
+ width: 1280,
+ height: 720,
+ hasVideo: true,
+ hasAudio: true,
+ sampledFrames
+ });
+ const path = join(stage.workdir, 'media-validation.json');
+ await writeFile(path, `${JSON.stringify(report, null, 2)}\n`, 'utf8');
+ return {
+ outputs: [{
+ kind: 'media_validation',
+ status: 'completed',
+ path,
+ sourceArtifactIds: [cleanVideo.id, timelineArtifact.id],
+ metadata: {
+ validation: report.validation,
+ sampleCount: report.sampledFrames.length,
+ duration: report.duration,
+ width: report.width,
+ height: report.height
+ }
+ }],
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ };
+ }
+ };
+}
+
+async function sampleVideoFrames(
+ ffmpegPath: string,
+ videoPath: string,
+ duration: number,
+ workdir: string
+): Promise<FrameSample[]> {
+ await mkdir(workdir, { recursive: true });
+ const timestamps = [
+ Math.min(0.1, duration / 4),
+ duration / 2,
+ Math.max(0, duration - Math.min(0.2, duration / 4))
+ ];
+ const result: FrameSample[] = [];
+ for (const [position, timestampSeconds] of timestamps.entries()) {
+ const path = join(workdir, `frame-${position + 1}.png`);
+ await execFileAsync(ffmpegPath, [
+ '-y', '-ss', timestampSeconds.toFixed(3), '-i', videoPath,
+ '-frames:v', '1', '-f', 'image2', path
+ ]);
+ const [metadata, stats, sha256] = await Promise.all([
+ sharp(path).metadata(),
+ sharp(path).greyscale().stats(),
+ sha256File(path)
+ ]);
+ const brightnessMean = stats.channels[0]?.mean ?? 0;
+ const contrastStddev = stats.channels[0]?.stdev ?? 0;
+ if (
+ metadata.width !== 1280
+ || metadata.height !== 720
+ || brightnessMean < 3
+ || brightnessMean > 252
+ || contrastStddev < 2
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_media_validation_blank_frame',
+ `Decoded frame ${position + 1} is blank or unreadable`
+ );
+ }
+ result.push({
+ index: position + 1,
+ timestampSeconds,
+ sha256,
+ width: 1280,
+ height: 720,
+ brightnessMean: roundMetric(brightnessMean),
+ contrastStddev: roundMetric(contrastStddev)
+ });
+ }
+ return result;
+}
+
+function requireArtifact(artifacts: CreatorArtifact[], kind: string): CreatorArtifact {
+ const matches = artifacts.filter(artifact => artifact.kind === kind && artifact.status === 'completed');
+ if (matches.length !== 1) {
+ throw new CreatorExecutorError(
+ 'creator_stage_input_missing',
+ `Media validation requires exactly one current ${kind}`
+ );
+ }
+ return matches[0]!;
+}
+
+function assertInside(root: string, path: string): void {
+ const value = relative(resolve(root), resolve(path));
+ if (value.startsWith('..') || isAbsolute(value)) {
+ throw new CreatorExecutorError('creator_artifact_path_escape', 'Media validation input escapes Job root');
+ }
+}
+
+function execFileAsync(command: string, args: string[]): Promise<void> {
+ return new Promise((resolvePromise, reject) => {
+ execFile(command, args, { windowsHide: true, timeout: 120_000 }, error => {
+ if (error) reject(error);
+ else resolvePromise();
+ });
+ });
+}
+
+async function sha256File(path: string): Promise<string> {
+ const digest = createHash('sha256');
+ for await (const chunk of createReadStream(path)) digest.update(chunk);
+ return digest.digest('hex');
+}
+
+function roundMetric(value: number): number {
+ return Math.round(value * 1_000) / 1_000;
+}
diff --git a/apps/daemon/src/creator/stickman/narration-subtitle.ts b/apps/daemon/src/creator/stickman/narration-subtitle.ts
new file mode 100644
index 00000000..e43dd963
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/narration-subtitle.ts
@@ -0,0 +1,32 @@
+import type { StickmanAudioTiming, StickmanScriptManifest } from './contracts.js';
+
+export function renderStickmanNarrationSrt(
+ segments: StickmanScriptManifest['segments']
+): string {
+ let cursor = 0;
+ return `${segments.map((segment, index) => {
+ const start = cursor;
+ cursor += Math.round(segment.estimatedDurationSeconds * 1_000);
+ return `${index + 1}\n${srtTimestamp(start)} --> ${srtTimestamp(cursor)}\n${segment.narration}`;
+ }).join('\n\n')}\n`;
+}
+
+export function renderStickmanTimedNarrationSrt(
+ script: StickmanScriptManifest,
+ timing: StickmanAudioTiming
+): string {
+ const narrationById = new Map(script.segments.map(segment => [segment.id, segment.narration]));
+ return `${timing.segments.map((segment, index) => {
+ const narration = narrationById.get(segment.segmentId);
+ if (narration === undefined) throw new Error(`narration_segment_missing: ${segment.segmentId}`);
+ return `${index + 1}\n${srtTimestamp(Math.round(segment.startSeconds * 1_000))} --> ${srtTimestamp(Math.round(segment.endSeconds * 1_000))}\n${narration}`;
+ }).join('\n\n')}\n`;
+}
+
+function srtTimestamp(milliseconds: number): string {
+ const hours = Math.floor(milliseconds / 3_600_000);
+ const minutes = Math.floor((milliseconds % 3_600_000) / 60_000);
+ const seconds = Math.floor((milliseconds % 60_000) / 1_000);
+ const remainder = milliseconds % 1_000;
+ return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')},${String(remainder).padStart(3, '0')}`;
+}
diff --git a/apps/daemon/src/creator/stickman/remotion-executor.ts b/apps/daemon/src/creator/stickman/remotion-executor.ts
new file mode 100644
index 00000000..04c93bb8
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/remotion-executor.ts
@@ -0,0 +1,149 @@
+import { readFile, rm, writeFile } from 'node:fs/promises';
+import { createRequire } from 'node:module';
+import { dirname, extname, join } from 'node:path';
+import { fileURLToPath, pathToFileURL } from 'node:url';
+import type { CreatorExecutor } from '../executor.js';
+import { CreatorExecutorError } from '../executor.js';
+import { spawnCreatorProcess } from '../process-tree.js';
+import { validateMediaFile } from '../validators/media.js';
+import { readStickmanRemotionRuntime, type StickmanRemotionRuntime } from './remotion-runtime.js';
+
+type ValidateVideo = (path: string, ffprobePath: string) => Promise<{
+ duration: number;
+ width?: number;
+ height?: number;
+ hasVideo: boolean;
+ hasAudio: boolean;
+}>;
+
+export function createStickmanRemotionExecutor(input: {
+ ffprobePath: string;
+ runtimeRoot: string;
+ workerEntrypoint?: string;
+ runtime?: StickmanRemotionRuntime;
+ validateVideo?: ValidateVideo;
+}): CreatorExecutor {
+ const validateVideo = input.validateVideo ?? validateMediaFile;
+ return {
+ id: 'stickman-remotion',
+ async run(stage) {
+ const timeline = stage.inputArtifacts.find(artifact => artifact.kind === 'timeline_manifest');
+ if (timeline?.path === null || timeline?.path === undefined) {
+ throw new CreatorExecutorError('creator_stage_input_missing', 'Timeline manifest is required');
+ }
+ const runtime = input.runtime ?? readStickmanRemotionRuntime(input.runtimeRoot);
+ const outputPath = join(stage.workdir, 'landscape-clean.mp4');
+ const requestPath = join(stage.workdir, 'remotion-request.json');
+ const resultPath = join(stage.workdir, 'remotion-result.json');
+ await writeFile(requestPath, `${JSON.stringify({
+ timelinePath: timeline.path,
+ outputPath,
+ bundlePath: runtime.bundlePath,
+ browserExecutable: runtime.browserExecutable,
+ workdir: stage.workdir,
+ jobRoot: dirname(stage.workdir),
+ runtimeRoot: runtime.root
+ }, null, 2)}\n`, 'utf8');
+ const workerEntrypoint = input.workerEntrypoint
+ ?? resolveDefaultWorkerEntrypoint();
+ try {
+ await runWorker(workerEntrypoint, requestPath, resultPath, stage.signal);
+ const result = JSON.parse(await readFile(resultPath, 'utf8')) as {
+ ok?: boolean;
+ error?: string;
+ };
+ if (result.ok !== true) {
+ throw new CreatorExecutorError(
+ 'stickman_remotion_failed',
+ result.error ?? 'Remotion worker failed'
+ );
+ }
+ const media = await validateVideo(outputPath, input.ffprobePath);
+ const timelineValue = JSON.parse(await readFile(timeline.path, 'utf8')) as {
+ totalFrames?: number;
+ fps?: number;
+ };
+ const expectedDuration = Number(timelineValue.totalFrames) / Number(timelineValue.fps);
+ const durationTolerance = Math.max(0.15, 2 / Number(timelineValue.fps));
+ if (
+ media.width !== 1280
+ || media.height !== 720
+ || !media.hasVideo
+ || !media.hasAudio
+ || !Number.isFinite(expectedDuration)
+ || Math.abs(media.duration - expectedDuration) > durationTolerance
+ ) {
+ throw new CreatorExecutorError(
+ 'stickman_render_invalid',
+ 'Rendered video must be decodable 1280x720 media with matching audio duration'
+ );
+ }
+ return {
+ outputs: [{
+ kind: 'clean_video',
+ status: 'completed',
+ path: outputPath,
+ sourceArtifactIds: [timeline.id],
+ metadata: {
+ ...media,
+ fileName: 'landscape-clean.mp4',
+ renderEngine: 'remotion',
+ renderKind: 'final',
+ mediaValidation: 'ffprobe'
+ }
+ }]
+ };
+ } catch (error) {
+ await Promise.all([
+ rm(outputPath, { force: true }),
+ rm(resultPath, { force: true })
+ ]);
+ if (stage.signal.aborted) {
+ throw new CreatorExecutorError('creator_stage_canceled', 'Creator stage was canceled');
+ }
+ throw error;
+ }
+ }
+ };
+}
+
+function runWorker(
+ workerEntrypoint: string,
+ requestPath: string,
+ resultPath: string,
+ signal: AbortSignal
+): Promise<void> {
+ return new Promise((resolve, reject) => {
+ const workerArgs = extname(workerEntrypoint).toLowerCase() === '.ts'
+ ? [
+ '--import',
+ pathToFileURL(createRequire(import.meta.url).resolve('tsx')).href,
+ workerEntrypoint,
+ requestPath,
+ resultPath
+ ]
+ : [workerEntrypoint, requestPath, resultPath];
+ const child = spawnCreatorProcess(
+ process.execPath,
+ workerArgs,
+ { cwd: dirname(requestPath), stdio: ['ignore', 'ignore', 'pipe'] },
+ signal
+ );
+ let stderr = '';
+ child.stderr?.on('data', chunk => { stderr += String(chunk); });
+ child.once('error', reject);
+ child.once('exit', code => {
+ if (code === 0) resolve();
+ else reject(new CreatorExecutorError(
+ 'stickman_remotion_worker_failed',
+ stderr.slice(-2_000) || `Remotion worker exited with code ${code}`
+ ));
+ });
+ });
+}
+
+function resolveDefaultWorkerEntrypoint(): string {
+ const sourceExtension = extname(fileURLToPath(import.meta.url)).toLowerCase();
+ const workerExtension = sourceExtension === '.ts' ? '.ts' : '.js';
+ return fileURLToPath(new URL(`./remotion-worker${workerExtension}`, import.meta.url));
+}
diff --git a/apps/daemon/src/creator/stickman/remotion-runtime.ts b/apps/daemon/src/creator/stickman/remotion-runtime.ts
new file mode 100644
index 00000000..5d07afc3
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/remotion-runtime.ts
@@ -0,0 +1,58 @@
+import { existsSync, readFileSync, statSync } from 'node:fs';
+import { isAbsolute, relative, resolve, sep } from 'node:path';
+import { z } from 'zod';
+
+const runtimeManifestSchema = z.object({
+ version: z.literal(1),
+ platform: z.string().min(1),
+ arch: z.string().min(1),
+ remotionVersion: z.literal('4.0.473'),
+ chromiumVersion: z.string().min(1),
+ bundlePath: z.string().min(1),
+ browserExecutable: z.string().min(1),
+ resources: z.array(z.object({
+ path: z.string().min(1),
+ kind: z.enum(['bundle', 'browser', 'font', 'character', 'brand', 'audio', 'visual-asset']),
+ sha256: z.string().regex(/^[a-f0-9]{64}$/i),
+ bytes: z.number().int().nonnegative(),
+ version: z.string().min(1),
+ platform: z.string().min(1),
+ arch: z.string().min(1)
+ }).strict()).min(1)
+}).strict();
+
+export type StickmanRemotionRuntime = {
+ root: string;
+ bundlePath: string;
+ browserExecutable: string;
+};
+
+export function readStickmanRemotionRuntime(rootPath: string): StickmanRemotionRuntime {
+ const root = resolve(rootPath);
+ const manifest = runtimeManifestSchema.parse(JSON.parse(
+ readFileSync(resolveInside(root, 'manifest.json'), 'utf8')
+ ));
+ if (manifest.platform !== process.platform || manifest.arch !== process.arch) {
+ throw new Error('stickman_runtime_wrong_platform');
+ }
+ for (const resource of manifest.resources) {
+ const path = resolveInside(root, resource.path);
+ if (!existsSync(path) || !statSync(path).isFile()) {
+ throw new Error(`stickman_runtime_resource_missing: ${resource.path}`);
+ }
+ }
+ return {
+ root,
+ bundlePath: resolveInside(root, manifest.bundlePath),
+ browserExecutable: resolveInside(root, manifest.browserExecutable)
+ };
+}
+
+export function resolveInside(root: string, child: string): string {
+ const target = resolve(root, child);
+ const value = relative(resolve(root), target);
+ if (value === '' || (!value.startsWith(`..${sep}`) && value !== '..' && !isAbsolute(value))) {
+ return target;
+ }
+ throw new Error(`stickman_runtime_path_escape: ${child}`);
+}
diff --git a/apps/daemon/src/creator/stickman/remotion-worker.ts b/apps/daemon/src/creator/stickman/remotion-worker.ts
new file mode 100644
index 00000000..350cc1b8
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/remotion-worker.ts
@@ -0,0 +1,186 @@
+import { createReadStream, existsSync, statSync } from 'node:fs';
+import { readFile, writeFile } from 'node:fs/promises';
+import { createServer, type IncomingMessage, type ServerResponse } from 'node:http';
+import { extname, isAbsolute, relative, resolve } from 'node:path';
+
+type WorkerRequest = {
+ timelinePath: string;
+ outputPath: string;
+ bundlePath: string;
+ browserExecutable: string;
+ workdir: string;
+ jobRoot: string;
+ runtimeRoot: string;
+};
+
+async function main(): Promise<void> {
+ const requestPath = process.argv[2];
+ const resultPath = process.argv[3];
+ if (!requestPath || !resultPath) throw new Error('stickman_worker_arguments_missing');
+ try {
+ const request = JSON.parse(await readFile(resolve(requestPath), 'utf8')) as WorkerRequest;
+ const workdir = resolve(request.workdir);
+ const jobRoot = resolve(request.jobRoot);
+ const runtimeRoot = resolve(request.runtimeRoot);
+ assertInside(jobRoot, request.timelinePath, 'timeline');
+ assertInside(workdir, request.outputPath, 'output');
+ assertInside(workdir, requestPath, 'request');
+ assertInside(workdir, resultPath, 'result');
+ assertInside(runtimeRoot, request.bundlePath, 'bundle');
+ assertInside(runtimeRoot, request.browserExecutable, 'browser');
+ if (!existsSync(resolve(request.bundlePath)) || !statSync(resolve(request.bundlePath)).isDirectory()) {
+ throw new Error('stickman_worker_bundle_missing');
+ }
+ if (!existsSync(resolve(request.browserExecutable)) || !statSync(resolve(request.browserExecutable)).isFile()) {
+ throw new Error('stickman_worker_browser_missing');
+ }
+ const timeline = JSON.parse(await readFile(resolve(request.timelinePath), 'utf8')) as {
+ totalFrames: number;
+ fps: number;
+ shots?: Array<{ imagePath?: string; audioPath?: string }>;
+ };
+ for (const shot of timeline.shots ?? []) {
+ if (!shot.imagePath || !shot.audioPath) throw new Error('stickman_worker_timeline_path_missing');
+ assertInside(jobRoot, shot.imagePath, 'image');
+ assertInside(jobRoot, shot.audioPath, 'audio');
+ }
+ const assetServer = await startAssetServer(
+ resolve(request.bundlePath),
+ timeline.shots ?? []
+ );
+ try {
+ const renderTimeline = {
+ ...timeline,
+ shots: (timeline.shots ?? []).map((shot, index) => ({
+ ...shot,
+ imagePath: `${assetServer.url}/media/${index}/image${extname(shot.imagePath!)}`,
+ audioPath: `${assetServer.url}/media/${index}/audio${extname(shot.audioPath!)}`
+ }))
+ };
+ const renderer = await import('@remotion/renderer');
+ const composition = await renderer.selectComposition({
+ serveUrl: assetServer.url,
+ id: 'StickmanLandscape',
+ inputProps: renderTimeline,
+ browserExecutable: resolve(request.browserExecutable)
+ });
+ await renderer.renderMedia({
+ composition: { ...composition, durationInFrames: timeline.totalFrames, fps: timeline.fps },
+ serveUrl: assetServer.url,
+ codec: 'h264',
+ outputLocation: resolve(request.outputPath),
+ inputProps: renderTimeline,
+ browserExecutable: resolve(request.browserExecutable),
+ concurrency: 1
+ });
+ } finally {
+ await assetServer.close();
+ }
+ await writeFile(resolve(resultPath), JSON.stringify({ ok: true }), 'utf8');
+ } catch (error) {
+ await writeFile(resolve(resultPath), JSON.stringify({
+ ok: false,
+ error: error instanceof Error ? error.message : String(error)
+ }), 'utf8');
+ process.exitCode = 1;
+ }
+}
+
+async function startAssetServer(
+ bundleRoot: string,
+ shots: Array<{ imagePath?: string; audioPath?: string }>
+): Promise<{ url: string; close(): Promise<void> }> {
+ const media = new Map<string, string>();
+ for (const [index, shot] of shots.entries()) {
+ media.set(`/media/${index}/image${extname(shot.imagePath!)}`, resolve(shot.imagePath!));
+ media.set(`/media/${index}/audio${extname(shot.audioPath!)}`, resolve(shot.audioPath!));
+ }
+ const server = createServer((request, response) => {
+ try {
+ const pathname = decodeURIComponent(new URL(request.url ?? '/', 'http://127.0.0.1').pathname);
+ const mediaPath = media.get(pathname);
+ if (mediaPath !== undefined) {
+ serveFile(request, response, mediaPath);
+ return;
+ }
+ const relativePath = pathname === '/' ? 'index.html' : pathname.replace(/^\/+/, '');
+ const bundlePath = resolve(bundleRoot, relativePath);
+ const value = relative(bundleRoot, bundlePath);
+ if (value.startsWith('..') || isAbsolute(value)) {
+ respond(response, 403, 'Forbidden');
+ return;
+ }
+ serveFile(request, response, bundlePath);
+ } catch {
+ respond(response, 400, 'Bad Request');
+ }
+ });
+ await new Promise<void>((resolvePromise, reject) => {
+ server.once('error', reject);
+ server.listen(0, '127.0.0.1', () => resolvePromise());
+ });
+ const address = server.address();
+ if (address === null || typeof address === 'string') {
+ await new Promise<void>(resolvePromise => server.close(() => resolvePromise()));
+ throw new Error('stickman_worker_asset_server_failed');
+ }
+ return {
+ url: `http://127.0.0.1:${address.port}`,
+ close: () => new Promise<void>((resolvePromise, reject) => {
+ server.close(error => error ? reject(error) : resolvePromise());
+ })
+ };
+}
+
+function serveFile(request: IncomingMessage, response: ServerResponse, path: string): void {
+ if (!existsSync(path) || !statSync(path).isFile()) {
+ respond(response, 404, 'Not Found');
+ return;
+ }
+ const size = statSync(path).size;
+ const range = request.headers.range?.match(/^bytes=(\d+)-(\d*)$/);
+ const start = range ? Number(range[1]) : 0;
+ const requestedEnd = range?.[2] ? Number(range[2]) : size - 1;
+ const end = Math.min(size - 1, requestedEnd);
+ if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start < 0 || end < start || start >= size) {
+ response.writeHead(416, { 'Content-Range': `bytes */${size}` });
+ response.end();
+ return;
+ }
+ response.writeHead(range ? 206 : 200, {
+ 'Accept-Ranges': 'bytes',
+ 'Content-Length': String(end - start + 1),
+ 'Content-Type': mimeType(path),
+ ...(range ? { 'Content-Range': `bytes ${start}-${end}/${size}` } : {})
+ });
+ createReadStream(path, { start, end }).pipe(response);
+}
+
+function respond(response: ServerResponse, status: number, body: string): void {
+ response.writeHead(status, { 'Content-Type': 'text/plain; charset=utf-8' });
+ response.end(body);
+}
+
+function mimeType(path: string): string {
+ const extension = extname(path).toLowerCase();
+ if (extension === '.html') return 'text/html; charset=utf-8';
+ if (extension === '.js') return 'text/javascript; charset=utf-8';
+ if (extension === '.css') return 'text/css; charset=utf-8';
+ if (extension === '.png') return 'image/png';
+ if (extension === '.jpg' || extension === '.jpeg') return 'image/jpeg';
+ if (extension === '.woff2') return 'font/woff2';
+ if (extension === '.mp3') return 'audio/mpeg';
+ if (extension === '.wav') return 'audio/wav';
+ if (extension === '.json') return 'application/json';
+ return 'application/octet-stream';
+}
+
+function assertInside(root: string, child: string, label: string): void {
+ const target = resolve(child);
+ const value = relative(root, target);
+ if (value.startsWith('..') || isAbsolute(value)) {
+ throw new Error(`stickman_worker_${label}_path_escape`);
+ }
+}
+
+void main();
diff --git a/apps/daemon/src/creator/stickman/timeline-executor.ts b/apps/daemon/src/creator/stickman/timeline-executor.ts
new file mode 100644
index 00000000..5f4388a6
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/timeline-executor.ts
@@ -0,0 +1,178 @@
+import { realpath, readFile, writeFile } from 'node:fs/promises';
+import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
+import type { CreatorArtifact } from '@opencreator/protocol';
+import type { CreatorExecutor, CreatorExecutorOutput } from '../executor.js';
+import { CreatorExecutorError } from '../executor.js';
+import {
+ stickmanAudioTimingSchema,
+ stickmanScriptManifestSchema,
+ stickmanShotSpecSchema,
+ stickmanTimelineSchema
+} from './contracts.js';
+import { renderStickmanTimedNarrationSrt } from './narration-subtitle.js';
+
+export function createStickmanTimelineExecutor(): CreatorExecutor {
+ return {
+ id: 'stickman-timeline',
+ async run(stage) {
+ const shotSpecArtifact = requireArtifact(stage.inputArtifacts, 'shot_spec');
+ const scriptArtifact = requireArtifact(stage.inputArtifacts, 'script_manifest');
+ const timingArtifact = requireArtifact(stage.inputArtifacts, 'audio_timing');
+ if (
+ shotSpecArtifact.path === null
+ || scriptArtifact.path === null
+ || timingArtifact.path === null
+ ) {
+ throw new CreatorExecutorError('creator_stage_input_missing', 'Timeline file inputs are required');
+ }
+ const jobRoot = dirname(resolve(stage.workdir));
+ await assertInputPath(jobRoot, shotSpecArtifact.path);
+ await assertInputPath(jobRoot, scriptArtifact.path);
+ await assertInputPath(jobRoot, timingArtifact.path);
+ const shotSpec = stickmanShotSpecSchema.parse(JSON.parse(
+ await readFile(shotSpecArtifact.path, 'utf8')
+ ));
+ const script = stickmanScriptManifestSchema.parse(JSON.parse(
+ await readFile(scriptArtifact.path, 'utf8')
+ ));
+ const timing = stickmanAudioTimingSchema.parse(JSON.parse(
+ await readFile(timingArtifact.path, 'utf8')
+ ));
+ const images = stage.inputArtifacts.filter(artifact => (
+ artifact.kind === 'shot_image' && artifact.status === 'completed'
+ ));
+ const narration = stage.inputArtifacts.filter(artifact => (
+ artifact.kind === 'narration_audio' && artifact.status === 'completed'
+ ));
+ const timingBySegment = new Map(timing.segments.map(segment => [segment.segmentId, segment]));
+ const fps = 30;
+ const totalFrames = Math.round(timing.totalDurationSeconds * fps);
+ if (totalFrames < shotSpec.shots.length) {
+ throw new CreatorExecutorError(
+ 'creator_audio_too_short',
+ 'Narration duration cannot allocate at least one frame to every shot'
+ );
+ }
+ const shots = [];
+ for (const shot of shotSpec.shots) {
+ const measured = timingBySegment.get(shot.sourceSegmentId);
+ if (measured === undefined) {
+ throw new CreatorExecutorError(
+ 'creator_audio_timing_incomplete',
+ `Audio timing is missing ${shot.sourceSegmentId}`
+ );
+ }
+ if (
+ Math.abs(shot.startSeconds - measured.startSeconds) > 0.001
+ || Math.abs(shot.endSeconds - measured.endSeconds) > 0.001
+ || Math.abs(shot.durationSeconds - measured.durationSeconds) > 0.001
+ ) {
+ throw new CreatorExecutorError(
+ 'creator_storyboard_timing_stale',
+ `Shot ${shot.id} is not derived from current audio timing`
+ );
+ }
+ const candidates = images.filter(image => image.scopeKey === shot.id);
+ if (candidates.length !== 1) {
+ throw new CreatorExecutorError(
+ 'creator_shot_image_ambiguous',
+ `Shot ${shot.id} requires exactly one current image`
+ );
+ }
+ const image = candidates[0]!;
+ const audioCandidates = narration.filter(audio => audio.scopeKey === shot.sourceSegmentId);
+ if (audioCandidates.length !== 1) {
+ throw new CreatorExecutorError(
+ 'creator_narration_incomplete',
+ `Shot ${shot.id} requires exactly one current narration segment`
+ );
+ }
+ const audio = audioCandidates[0]!;
+ if (image.path === null || image.sha256 === null) {
+ throw new CreatorExecutorError('creator_artifact_hash_missing', `Shot ${shot.id} image is incomplete`);
+ }
+ if (audio.path === null || audio.sha256 === null || audio.id !== measured.audioArtifactId) {
+ throw new CreatorExecutorError('creator_artifact_hash_missing', `Shot ${shot.id} audio is incomplete`);
+ }
+ await assertInputPath(jobRoot, image.path);
+ await assertInputPath(jobRoot, audio.path);
+ const startFrame = Math.round(measured.startSeconds * fps);
+ const endFrame = Math.round(measured.endSeconds * fps);
+ shots.push({
+ shotId: shot.id,
+ startFrame,
+ endFrame,
+ imageArtifactId: image.id,
+ audioArtifactId: audio.id,
+ motion: shot.motion,
+ imageSha256: image.sha256,
+ audioSha256: audio.sha256,
+ imagePath: image.path,
+ audioPath: audio.path
+ });
+ }
+ const timeline = stickmanTimelineSchema.parse({
+ fps,
+ width: 1280,
+ height: 720,
+ totalFrames,
+ shots
+ });
+ const path = join(stage.workdir, 'timeline-manifest.json');
+ await writeFile(path, `${JSON.stringify({ ...timeline, shots }, null, 2)}\n`, 'utf8');
+ const subtitlePath = join(stage.workdir, 'narration.srt');
+ await writeFile(subtitlePath, renderStickmanTimedNarrationSrt(script, timing), 'utf8');
+ const outputs: CreatorExecutorOutput[] = [
+ {
+ kind: 'timeline_manifest',
+ status: 'completed',
+ path,
+ sourceArtifactIds: [
+ scriptArtifact.id,
+ timingArtifact.id,
+ shotSpecArtifact.id,
+ ...narration.map(audio => audio.id),
+ ...images.map(image => image.id)
+ ],
+ metadata: {
+ fps,
+ width: 1280,
+ height: 720,
+ totalFrames,
+ duration: timing.totalDurationSeconds,
+ shotCount: shots.length,
+ timingSource: timing.timingSource
+ }
+ },
+ {
+ kind: 'narration_subtitle',
+ status: 'completed',
+ path: subtitlePath,
+ sourceArtifactIds: [scriptArtifact.id, timingArtifact.id],
+ metadata: {
+ cueCount: timing.segments.length,
+ duration: timing.totalDurationSeconds,
+ timingSource: timing.timingSource
+ }
+ }
+ ];
+ return { outputs };
+ }
+ };
+}
+
+async function assertInputPath(jobRoot: string, path: string): Promise<void> {
+ const actual = await realpath(resolve(path));
+ const value = relative(jobRoot, actual);
+ if (value.startsWith('..') || isAbsolute(value)) {
+ throw new CreatorExecutorError('creator_artifact_path_escape', `Artifact path escapes Job root: ${path}`);
+ }
+}
+
+function requireArtifact(artifacts: CreatorArtifact[], kind: string): CreatorArtifact {
+ const artifact = artifacts.find(item => item.kind === kind && item.status === 'completed');
+ if (artifact === undefined) {
+ throw new CreatorExecutorError('creator_stage_input_missing', `${kind} is required`);
+ }
+ return artifact;
+}
diff --git a/apps/daemon/src/creator/stickman/validation-executor.ts b/apps/daemon/src/creator/stickman/validation-executor.ts
new file mode 100644
index 00000000..0677e26a
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/validation-executor.ts
@@ -0,0 +1,179 @@
+import { createHash } from 'node:crypto';
+import { execFile } from 'node:child_process';
+import { readFile, writeFile } from 'node:fs/promises';
+import { join } from 'node:path';
+import sharp from 'sharp';
+import type { CreatorExecutor } from '../executor.js';
+import { CreatorExecutorError } from '../executor.js';
+import { stickmanShotSpecSchema, stickmanVisualValidationSchema } from './contracts.js';
+
+type OcrResult = {
+ available: boolean;
+ detectedText: string[];
+};
+
+export function createStickmanValidationExecutor(input: {
+ tesseractPath?: string;
+ runOcr?: (path: string) => Promise<OcrResult>;
+} = {}): CreatorExecutor {
+ const runOcr = input.runOcr ?? (input.tesseractPath === undefined
+ ? (async () => ({ available: false, detectedText: [] }))
+ : (path => runTesseract(input.tesseractPath!, path)));
+ return {
+ id: 'stickman-validation',
+ async run(stage) {
+ const shotSpec = stage.inputArtifacts.find(artifact => artifact.kind === 'shot_spec');
+ if (shotSpec?.path === null || shotSpec?.path === undefined) {
+ throw new CreatorExecutorError('creator_stage_input_missing', 'Shot spec is required');
+ }
+ const value = stickmanShotSpecSchema.parse(JSON.parse(
+ await readFile(shotSpec.path, 'utf8')
+ ));
+ const images = stage.inputArtifacts.filter(artifact => (
+ artifact.kind === 'shot_image' && artifact.status === 'completed'
+ ));
+ const rows = [];
+ const hashes = new Set<string>();
+ for (const shot of value.shots) {
+ const candidates = images.filter(image => image.scopeKey === shot.id);
+ if (candidates.length !== 1) {
+ throw new CreatorExecutorError(
+ candidates.length === 0
+ ? 'creator_shot_images_incomplete'
+ : 'creator_shot_image_ambiguous',
+ `Shot ${shot.id} requires exactly one current image`
+ );
+ }
+ const image = candidates[0]!;
+ if (image.path === null || image.sha256 === null) {
+ throw new CreatorExecutorError('creator_artifact_hash_missing', `Shot ${shot.id} image is incomplete`);
+ }
+ const content = await readFile(image.path);
+ const actualSha256 = createHash('sha256').update(content).digest('hex');
+ if (actualSha256 !== image.sha256.toLowerCase()) {
+ throw new CreatorExecutorError(
+ 'creator_shot_image_hash_mismatch',
+ `Shot ${shot.id} image no longer matches its artifact hash`
+ );
+ }
+ if (hashes.has(actualSha256)) {
+ throw new CreatorExecutorError(
+ 'creator_shot_images_duplicate',
+ `Shot ${shot.id} duplicates another generated image`
+ );
+ }
+ hashes.add(actualSha256);
+ const [metadata, stats] = await Promise.all([
+ sharp(content).metadata(),
+ sharp(content).greyscale().stats()
+ ]);
+ const width = metadata.width ?? 0;
+ const height = metadata.height ?? 0;
+ if (width <= 0 || height <= 0 || Math.abs(width / height - 16 / 9) > 0.03) {
+ throw new CreatorExecutorError(
+ 'creator_shot_image_invalid',
+ `Shot ${shot.id} image must be decodable 16:9 media`
+ );
+ }
+ const brightnessMean = stats.channels[0]?.mean ?? 0;
+ const contrastStddev = stats.channels[0]?.stdev ?? 0;
+ if (brightnessMean < 12 || brightnessMean > 248 || contrastStddev < 8) {
+ throw new CreatorExecutorError(
+ 'creator_shot_image_unreadable',
+ `Shot ${shot.id} image appears blank or unreadable`
+ );
+ }
+ let ocr: OcrResult;
+ try {
+ ocr = await runOcr(image.path);
+ } catch (error) {
+ throw new CreatorExecutorError(
+ 'creator_visual_ocr_failed',
+ error instanceof Error ? error.message : `OCR failed for ${shot.id}`
+ );
+ }
+ if (ocr.detectedText.length > 0) {
+ throw new CreatorExecutorError(
+ 'creator_visual_text_detected',
+ `Shot ${shot.id} contains prohibited visible text: ${ocr.detectedText.join(', ')}`
+ );
+ }
+ rows.push({
+ shotId: shot.id,
+ imageArtifactId: image.id,
+ imageSha256: actualSha256,
+ width,
+ height,
+ brightnessMean: roundMetric(brightnessMean),
+ contrastStddev: roundMetric(contrastStddev),
+ ocrStatus: ocr.available ? 'passed' as const : 'unavailable' as const,
+ detectedText: ocr.detectedText
+ });
+ }
+ const unexpected = images.filter(image => !value.shots.some(shot => shot.id === image.scopeKey));
+ if (unexpected.length > 0) {
+ throw new CreatorExecutorError(
+ 'creator_shot_image_ambiguous',
+ `Unexpected current shot images: ${unexpected.map(image => image.scopeKey ?? image.id).join(', ')}`
+ );
+ }
+ const ocrStatus = rows.every(row => row.ocrStatus === 'passed') ? 'passed' as const : 'unavailable' as const;
+ const warnings = ocrStatus === 'passed' ? [] : ['visual_ocr_unavailable'];
+ const result = stickmanVisualValidationSchema.parse({
+ ok: true,
+ validation: 'automated_decode_aspect_nonblank_hash_and_ocr',
+ approvedShotSpecArtifactId: shotSpec.id,
+ shotCount: value.shots.length,
+ ocrStatus,
+ publishable: ocrStatus === 'passed',
+ warnings,
+ shots: rows
+ });
+ const path = join(stage.workdir, 'visual-validation.json');
+ await writeFile(path, `${JSON.stringify(result, null, 2)}\n`, 'utf8');
+ return {
+ outputs: [{
+ kind: 'visual_validation',
+ status: 'completed',
+ path,
+ sourceArtifactIds: [shotSpec.id, ...images.map(image => image.id)],
+ metadata: {
+ shotCount: value.shots.length,
+ warningCount: warnings.length,
+ ocrStatus,
+ publishable: result.publishable,
+ validation: result.validation
+ }
+ }]
+ };
+ }
+ };
+}
+
+function runTesseract(tesseractPath: string, path: string): Promise<OcrResult> {
+ return new Promise((resolve, reject) => {
+ execFile(
+ tesseractPath,
+ [path, 'stdout', '--psm', '11', 'tsv'],
+ { windowsHide: true, timeout: 120_000, maxBuffer: 8 * 1024 * 1024 },
+ (error, stdout) => {
+ if (error) {
+ reject(new Error(`Tesseract failed for ${path}: ${error.message}`));
+ return;
+ }
+ const detectedText = String(stdout).split(/\r?\n/).slice(1).flatMap(line => {
+ const columns = line.split('\t');
+ const confidence = Number(columns[10]);
+ const text = columns[11]?.trim() ?? '';
+ const normalized = text.replace(/[^A-Za-z0-9\u3400-\u9fff]/g, '');
+ return confidence >= 80 && normalized.length >= 3 ? [text] : [];
+ });
+ resolve({ available: true, detectedText });
+ }
+ );
+ });
+}
+
+function roundMetric(value: number): number {
+ return Math.round(value * 1_000) / 1_000;
+}
diff --git a/apps/daemon/src/creator/stickman/visual-assets.ts b/apps/daemon/src/creator/stickman/visual-assets.ts
new file mode 100644
index 00000000..b8cc2f39
--- /dev/null
+++ b/apps/daemon/src/creator/stickman/visual-assets.ts
@@ -0,0 +1,286 @@
+import { createHash } from 'node:crypto';
+import {
+ createReadStream,
+ readFileSync,
+ statSync,
+ type ReadStream
+} from 'node:fs';
+import { isAbsolute, relative, resolve } from 'node:path';
+import type {
+ CreatorVisualAssetCatalogResponse,
+ CreatorVisualAssetRef,
+ CreatorVisualAssetSummary
+} from '@opencreator/protocol';
+import { z } from 'zod';
+
+const localizedTextSchema = z.object({
+ zhCN: z.string().trim().min(1),
+ en: z.string().trim().min(1)
+}).strict();
+
+const referenceFileSchema = z.object({
+ role: z.string().trim().min(1),
+ path: z.string().trim().min(1)
+}).strict();
+
+const characterSchema = z.object({
+ id: z.string().trim().min(1),
+ revision: z.number().int().positive(),
+ name: localizedTextSchema,
+ description: localizedTextSchema,
+ previewFile: z.string().trim().min(1),
+ referenceFiles: z.array(referenceFileSchema).min(1).max(1),
+ identity: z.object({
+ preserve: z.string().trim().min(1),
+ prohibit: z.string().trim().min(1)
+ }).strict(),
+ tags: z.array(z.string().trim().min(1)).default([])
+}).strict();
+
+const styleSchema = z.object({
+ id: z.string().trim().min(1),
+ revision: z.number().int().positive(),
+ name: localizedTextSchema,
+ description: localizedTextSchema,
+ recommended: z.boolean().default(false),
+ previewFile: z.string().trim().min(1).nullable(),
+ referenceFiles: z.array(referenceFileSchema).max(1),
+ rendering: z.object({
+ medium: z.string().trim().min(1),
+ surface: z.string().trim().min(1),
+ linework: z.string().trim().min(1),
+ shading: z.string().trim().min(1),
+ palette: z.string().trim().min(1),
+ sceneDensity: z.string().trim().min(1),
+ composition: z.string().trim().min(1),
+ characterRendering: z.string().trim().min(1)
+ }).strict(),
+ semanticRenderingRules: z.object({
+ color: z.string().trim().min(1),
+ light: z.string().trim().min(1),
+ complexEnvironment: z.string().trim().min(1)
+ }).strict(),
+ forbiddenDirections: z.array(z.string().trim().min(1)).min(1),
+ styleAttributes: z.object({
+ medium: localizedTextSchema,
+ palette: localizedTextSchema,
+ sceneDensity: localizedTextSchema,
+ swatch: z.object({
+ background: z.string().regex(/^#[a-f0-9]{6}$/i),
+ foreground: z.string().regex(/^#[a-f0-9]{6}$/i),
+ accent: z.string().regex(/^#[a-f0-9]{6}$/i),
+ texture: z.enum(['none', 'paper', 'screentone', 'marker'])
+ }).strict()
+ }).strict(),
+ tags: z.array(z.string().trim().min(1)).default([])
+}).strict();
+
+const catalogSchema = z.object({
+ version: z.literal(1),
+ templateId: z.literal('stickman-video'),
+ characters: z.array(characterSchema).min(1),
+ styles: z.array(styleSchema).min(1)
+}).strict();
+
+export type StickmanCharacterAsset = z.infer<typeof characterSchema>;
+export type StickmanStyleAsset = z.infer<typeof styleSchema>;
+export type StickmanVisualAssetCatalog = z.infer<typeof catalogSchema>;
+
+export const DEFAULT_STICKMAN_CHARACTER_ASSET: CreatorVisualAssetRef = {
+ assetId: 'stickman.character.default',
+ revision: 1
+};
+
+export const DEFAULT_STICKMAN_STYLE_ASSET: CreatorVisualAssetRef = {
+ assetId: 'stickman.style.paper-pencil',
+ revision: 1
+};
+
+export type ResolvedVisualAssetFile = {
+ role: string;
+ path: string;
+ sha256: string;
+ bytes: number;
+ mimeType: 'image/png' | 'image/jpeg' | 'image/webp';
+};
+
+export type StickmanVisualAssetRegistry = ReturnType<typeof createStickmanVisualAssetRegistry>;
+
+export function createStickmanVisualAssetRegistry(input: {
+ root: string;
+ catalogPath?: string;
+}) {
+ const root = resolve(input.root);
+ const catalogPath = input.catalogPath === undefined
+ ? resolveInside(root, 'visual-assets/catalog.json')
+ : resolve(input.catalogPath);
+ const catalog = catalogSchema.parse(JSON.parse(readFileSync(catalogPath, 'utf8')));
+ assertUniqueAssets(catalog);
+ const characters = new Map(catalog.characters.map(asset => [assetKey(asset), asset]));
+ const styles = new Map(catalog.styles.map(asset => [assetKey(asset), asset]));
+
+ return {
+ list(kind?: 'character' | 'style'): CreatorVisualAssetCatalogResponse {
+ const assets = [
+ ...(kind === 'style' ? [] : catalog.characters.map(characterSummary)),
+ ...(kind === 'character' ? [] : catalog.styles.map(styleSummary))
+ ];
+ return { assets };
+ },
+ character(reference: CreatorVisualAssetRef): StickmanCharacterAsset {
+ const asset = characters.get(assetRefKey(reference));
+ if (asset === undefined) {
+ throw new StickmanVisualAssetError(
+ 'creator_character_asset_not_found',
+ `Character asset ${reference.assetId}@${reference.revision} is unavailable`
+ );
+ }
+ return asset;
+ },
+ style(reference: CreatorVisualAssetRef): StickmanStyleAsset {
+ const asset = styles.get(assetRefKey(reference));
+ if (asset === undefined) {
+ throw new StickmanVisualAssetError(
+ 'creator_style_asset_not_found',
+ `Visual style ${reference.assetId}@${reference.revision} is unavailable`
+ );
+ }
+ return asset;
+ },
+ referenceFiles(asset: StickmanCharacterAsset | StickmanStyleAsset): ResolvedVisualAssetFile[] {
+ return asset.referenceFiles.map(file => inspectImageFile(root, file));
+ },
+ preview(reference: CreatorVisualAssetRef): { stream: ReadStream; path: string; mimeType: string } | undefined {
+ const character = characters.get(assetRefKey(reference));
+ const style = styles.get(assetRefKey(reference));
+ const previewFile = character?.previewFile ?? style?.previewFile ?? null;
+ if (previewFile === null) return undefined;
+ const path = resolveInside(root, previewFile);
+ const info = statSync(path);
+ if (!info.isFile() || info.size === 0) return undefined;
+ return { stream: createReadStream(path), path, mimeType: imageMime(path) };
+ }
+ };
+}
+
+export class StickmanVisualAssetError extends Error {
+ constructor(readonly code: string, message: string) {
+ super(message);
+ this.name = 'StickmanVisualAssetError';
+ }
+}
+
+export function readVisualAssetRef(
+ value: unknown,
+ fallback: CreatorVisualAssetRef
+): CreatorVisualAssetRef {
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return fallback;
+ const record = value as Record<string, unknown>;
+ return typeof record.assetId === 'string'
+ && Number.isSafeInteger(record.revision)
+ && Number(record.revision) > 0
+ ? { assetId: record.assetId, revision: Number(record.revision) }
+ : fallback;
+}
+
+function characterSummary(asset: StickmanCharacterAsset): CreatorVisualAssetSummary {
+ return {
+ id: asset.id,
+ revision: asset.revision,
+ templateId: 'stickman-video',
+ kind: 'character',
+ source: 'builtin',
+ status: 'ready',
+ name: asset.name,
+ description: asset.description,
+ previewUrl: previewUrl(asset),
+ referenceCount: asset.referenceFiles.length,
+ recommended: asset.id === DEFAULT_STICKMAN_CHARACTER_ASSET.assetId,
+ tags: asset.tags
+ };
+}
+
+function styleSummary(asset: StickmanStyleAsset): CreatorVisualAssetSummary {
+ return {
+ id: asset.id,
+ revision: asset.revision,
+ templateId: 'stickman-video',
+ kind: 'style',
+ source: 'builtin',
+ status: 'ready',
+ name: asset.name,
+ description: asset.description,
+ previewUrl: asset.previewFile === null ? null : previewUrl(asset),
+ referenceCount: asset.referenceFiles.length,
+ recommended: asset.recommended,
+ tags: asset.tags,
+ styleAttributes: asset.styleAttributes
+ };
+}
+
+function previewUrl(asset: { id: string; revision: number }): string {
+ return `/creator/visual-assets/${encodeURIComponent(asset.id)}/revisions/${asset.revision}/preview`;
+}
+
+function inspectImageFile(root: string, file: z.infer<typeof referenceFileSchema>): ResolvedVisualAssetFile {
+ const path = resolveInside(root, file.path);
+ const info = statSync(path);
+ if (!info.isFile() || info.size === 0) {
+ throw new StickmanVisualAssetError(
+ 'creator_visual_asset_invalid',
+ `Visual asset file is empty: ${file.path}`
+ );
+ }
+ return {
+ role: file.role,
+ path,
+ sha256: hashFile(path),
+ bytes: info.size,
+ mimeType: imageMime(path)
+ };
+}
+
+function hashFile(path: string): string {
+ const hash = createHash('sha256');
+ hash.update(readFileSync(path));
+ return hash.digest('hex');
+}
+
+function imageMime(path: string): 'image/png' | 'image/jpeg' | 'image/webp' {
+ const lower = path.toLowerCase();
+ if (lower.endsWith('.jpg') || lower.endsWith('.jpeg')) return 'image/jpeg';
+ if (lower.endsWith('.webp')) return 'image/webp';
+ if (lower.endsWith('.png')) return 'image/png';
+ throw new StickmanVisualAssetError(
+ 'creator_visual_asset_invalid',
+ `Unsupported visual asset image type: ${path}`
+ );
+}
+
+function resolveInside(root: string, child: string): string {
+ const target = resolve(root, child);
+ const value = relative(root, target);
+ if (value !== '' && !value.startsWith('..') && !isAbsolute(value)) return target;
+ throw new StickmanVisualAssetError(
+ 'creator_visual_asset_invalid',
+ `Visual asset path escapes its root: ${child}`
+ );
+}
+
+function assetKey(asset: { id: string; revision: number }): string {
+ return `${asset.id}@${asset.revision}`;
+}
+
+function assetRefKey(reference: CreatorVisualAssetRef): string {
+ return `${reference.assetId}@${reference.revision}`;
+}
+
+function assertUniqueAssets(catalog: StickmanVisualAssetCatalog): void {
+ const keys = [...catalog.characters, ...catalog.styles].map(assetKey);
+ if (new Set(keys).size !== keys.length) {
+ throw new StickmanVisualAssetError(
+ 'creator_visual_asset_invalid',
+ 'Visual asset catalog contains duplicate asset revisions'
+ );
+ }
+}
diff --git a/apps/daemon/src/creator/templates/stickman-video-actions.ts b/apps/daemon/src/creator/templates/stickman-video-actions.ts
new file mode 100644
index 00000000..6c3e81db
--- /dev/null
+++ b/apps/daemon/src/creator/templates/stickman-video-actions.ts
@@ -0,0 +1,666 @@
+import type {
+ CreatorArtifact,
+ CreatorJob,
+ CreatorProviderRequest,
+ CreatorStageRun
+} from '@opencreator/protocol';
+import { readFile } from 'node:fs/promises';
+import type { CreatorServicesConfigStore } from '../../creator-services/config-store.js';
+import type { CreatorCommandDispatcher } from '../command-dispatcher.js';
+import {
+ type CreatorProviderCapabilities,
+ type CreatorProviderRequestLedger
+} from '../provider-requests.js';
+import type { CreatorRepository } from '../repository.js';
+import { CreatorServiceError, type CreatorService } from '../service.js';
+import {
+ stickmanScriptManifestSchema,
+ stickmanShotSpecSchema
+} from '../stickman/contracts.js';
+import {
+ currentNarrationAudio,
+ currentShotImage,
+ previousStickmanShotImage,
+ stickmanNarrationFingerprint,
+ stickmanShotFingerprint,
+ type StickmanImageSettings,
+ type StickmanTtsSettings
+} from '../stickman/lineage.js';
+import { STICKMAN_IMAGE_PROMPT_CONTRACT } from '../stickman/image-prompt.js';
+import {
+ DEFAULT_STICKMAN_CHARACTER_ASSET,
+ DEFAULT_STICKMAN_STYLE_ASSET,
+ readVisualAssetRef
+} from '../stickman/visual-assets.js';
+
+export type StickmanVideoWorkflow = ReturnType<typeof createStickmanVideoWorkflow>;
+
+const noProviderLookup: CreatorProviderCapabilities = {
+ lookupByRequestKey: false,
+ async lookup() {
+ return { status: 'not_found' };
+ }
+};
+
+export function createStickmanVideoWorkflow(input: {
+ creator: CreatorService;
+ dispatcher: Pick<CreatorCommandDispatcher, 'dispatchWorkflow'>;
+ configStore?: Pick<CreatorServicesConfigStore, 'read'>;
+ repository?: CreatorRepository;
+ providerLedger?: CreatorProviderRequestLedger;
+ providerCapabilities?: CreatorProviderCapabilities;
+}) {
+ async function handleStageChanged(stage: CreatorStageRun): Promise<void> {
+ const job = input.creator.getJob(stage.jobId);
+ if (!isStickman(job) || stage.status !== 'succeeded') return;
+ await reconcile(job);
+ }
+
+ async function handleAction(job: CreatorJob, action: string): Promise<void> {
+ if (!isStickman(job)) return;
+ if (
+ action === 'approve-script'
+ || action === 'continue-after-audio'
+ || action === 'continue-after-visuals'
+ || action === 'edit-script'
+ || action === 'edit-shot'
+ || action === 'regenerate-shot'
+ || action === 'generate-missing-shots'
+ || action === 'retry-stage'
+ || action === 'resolve-provider-request'
+ ) {
+ await reconcile(input.creator.getJob(job.id) ?? job);
+ }
+ }
+
+ async function validateStage(
+ job: CreatorJob,
+ stageId: string,
+ scopeKey: string | null = null
+ ): Promise<void> {
+ if (!isStickman(job)) return;
+ const unresolved = input.providerLedger?.unresolvedForStage({
+ jobId: job.id,
+ stageId,
+ scopeKey
+ }) ?? [];
+ if (unresolved.length > 0) {
+ throw new CreatorServiceError(
+ 'creator_provider_resolution_required',
+ '必须先处置状态未知的 Provider 请求,才能重新执行该阶段'
+ );
+ }
+ const interrupted = [...job.stages].reverse().find(stage => (
+ stage.stageId === stageId
+ && stage.scopeKey === scopeKey
+ && stage.status === 'interrupted'
+ ));
+ if (interrupted !== undefined && hasRemoteSideEffect(interrupted, job.providerRequests)) {
+ throw new CreatorServiceError(
+ 'creator_provider_resolution_required',
+ '该阶段存在尚未确认的远端任务,不能自动重试'
+ );
+ }
+ requireApprovedInputs(job, stageId);
+ requireWorkflowTarget(job, stageId);
+ }
+
+ async function validateResume(job: CreatorJob, stage: CreatorStageRun): Promise<void> {
+ await validateStage(job, stage.stageId, stage.scopeKey);
+ if (stage.scopeKey !== null && stage.inputFingerprint !== null) {
+ const current = completedScopedOutput(job, stage);
+ if (current !== undefined) {
+ throw new CreatorServiceError(
+ 'creator_job_not_resumable',
+ '该阶段的精确输出已经完成,无需再次执行'
+ );
+ }
+ }
+ }
+
+ async function reconcile(job: CreatorJob): Promise<void> {
+ if (
+ !isStickman(job)
+ || job.status === 'draft'
+ || job.status === 'canceled'
+ || job.status === 'completed'
+ || job.status === 'failed'
+ ) return;
+ if (job.providerRequests.some(request => (
+ request.status === 'unknown_remote_acceptance' || request.status === 'waiting_remote'
+ ))) return;
+ const needsInput = job.state.needsInput;
+ if (
+ needsInput !== null
+ && typeof needsInput === 'object'
+ && !Array.isArray(needsInput)
+ && needsInput.code === 'creator_provider_resolution_required'
+ ) return;
+ if (
+ needsInput !== null
+ && typeof needsInput === 'object'
+ && !Array.isArray(needsInput)
+ && typeof needsInput.code === 'string'
+ && needsInput.code !== 'creator_review_required'
+ ) return;
+
+ const sourceType = job.state.sourceType === 'text' ? 'text' : 'url';
+ let sourceInput: CreatorArtifact;
+ if (sourceType === 'text') {
+ const sourceText = latestCompleted(job, 'source_text');
+ if (sourceText === undefined) {
+ queueStage(job, 'ingest-text', 'workflow:start');
+ return;
+ }
+ sourceInput = sourceText;
+ } else {
+ const sourceSubtitle = latestCompleted(job, 'source_subtitle');
+ if (sourceSubtitle === undefined) {
+ queueStage(job, 'source-transcript', 'workflow:start');
+ return;
+ }
+ sourceInput = sourceSubtitle;
+ }
+ const sourceBrief = latestCompleted(job, 'source_brief');
+ if (sourceBrief === undefined) {
+ queueStage(job, 'source-brief', sourceInput.id);
+ return;
+ }
+ const contentPlan = latestCompleted(job, 'content_plan');
+ if (contentPlan === undefined) {
+ queueStage(job, 'content-plan', sourceBrief.id);
+ return;
+ }
+ const script = latestCompleted(job, 'script_manifest');
+ if (script === undefined) {
+ queueStage(job, 'script', contentPlan.id);
+ return;
+ }
+ if (job.state.approvedScriptArtifactId !== script.id) {
+ setReviewGate(input.creator, job, 'approve-script', script.id);
+ return;
+ }
+
+ const narrationReady = await reconcileNarration(job, script);
+ if (!narrationReady) return;
+ const audioTiming = latestCompleted(job, 'audio_timing');
+ if (audioTiming === undefined) {
+ queueStage(job, 'audio-timing', `narration:${script.id}`);
+ return;
+ }
+ if (!workflowTargetAtLeast(job, 'visuals_ready')) return;
+ const storyboard = latestCompleted(job, 'shot_spec');
+ if (storyboard === undefined) {
+ queueStage(job, 'storyboard', audioTiming.id);
+ return;
+ }
+ const characterReference = latestCompleted(job, 'character_reference');
+ const styleReference = latestCompleted(job, 'style_reference');
+ const styleContract = latestCompleted(job, 'style_contract');
+ if (
+ characterReference === undefined
+ || styleContract === undefined
+ || !matchesCurrentVisualProfile(job, characterReference, styleReference, styleContract)
+ ) {
+ queueStage(job, 'style-assets', storyboard.id);
+ return;
+ }
+ const promptPack = latestCompleted(job, 'image_prompt_pack');
+ if (
+ promptPack === undefined
+ || promptPack.metadata.contract !== STICKMAN_IMAGE_PROMPT_CONTRACT
+ || !promptPack.sourceArtifactIds.includes(styleContract.id)
+ || !promptPack.sourceArtifactIds.includes(characterReference.id)
+ || (styleReference !== undefined && !promptPack.sourceArtifactIds.includes(styleReference.id))
+ ) {
+ queueStage(job, 'prompt-pack', `${storyboard.id}:${characterReference.id}`);
+ return;
+ }
+ const mediaReady = await reconcileApprovedMedia(job, storyboard);
+ if (!mediaReady) return;
+
+ const visualValidation = latestCompleted(job, 'visual_validation');
+ if (visualValidation === undefined) {
+ queueStage(job, 'visual-validation', `${storyboard.id}:${promptPack.id}`);
+ return;
+ }
+ if (!workflowTargetAtLeast(job, 'delivery_ready')) return;
+
+ const timeline = latestCompleted(job, 'timeline_manifest');
+ if (timeline === undefined) {
+ queueStage(job, 'timeline', visualValidation.id);
+ return;
+ }
+ const cleanVideo = latestCompleted(job, 'clean_video');
+ if (cleanVideo === undefined) {
+ queueStage(job, 'render-clean', timeline.id);
+ return;
+ }
+ const mediaValidation = latestCompleted(job, 'media_validation');
+ if (
+ mediaValidation === undefined
+ || !mediaValidation.sourceArtifactIds.includes(cleanVideo.id)
+ ) {
+ queueStage(job, 'media-validation', `${timeline.id}:${cleanVideo.id}`);
+ return;
+ }
+
+ if (latestCompleted(job, 'delivery_manifest') === undefined) {
+ queueStage(
+ job,
+ 'package-validation',
+ `${cleanVideo.id}:${mediaValidation.id}:${timeline.id}`
+ );
+ }
+ }
+
+ async function reconcileApprovedMedia(
+ job: CreatorJob,
+ shotSpecArtifact: CreatorArtifact
+ ): Promise<boolean> {
+ if (shotSpecArtifact.path === null) return false;
+ const shotSpec = stickmanShotSpecSchema.parse(JSON.parse(
+ await readFile(shotSpecArtifact.path, 'utf8')
+ ));
+ const characterReference = latestCompleted(job, 'character_reference');
+ const styleReference = latestCompleted(job, 'style_reference');
+ const styleContract = latestCompleted(job, 'style_contract');
+ const promptPack = latestCompleted(job, 'image_prompt_pack');
+ if (characterReference === undefined || styleContract === undefined || promptPack === undefined) {
+ return false;
+ }
+ const settings = await imageSettings(job);
+ for (const [shotIndex, shot] of shotSpec.shots.entries()) {
+ const previousShotImage = previousStickmanShotImage({
+ artifacts: job.artifacts,
+ shotSpec,
+ shotIndex
+ });
+ const fingerprint = stickmanShotFingerprint({
+ shot,
+ job,
+ shotSpec: shotSpecArtifact,
+ characterReference,
+ styleReference,
+ styleContract,
+ promptPack,
+ previousShotImage,
+ settings
+ });
+ if (currentShotImage(job, shot.id, fingerprint) !== undefined) continue;
+ if (hasUnresolvedProvider(job, 'images', shot.id)) return false;
+ queueStage(job, 'images', `approval:${shotSpecArtifact.id}:${shot.id}`, {
+ scopeKey: shot.id,
+ inputFingerprint: fingerprint
+ });
+ return false;
+ }
+ return true;
+ }
+
+ async function reconcileNarration(
+ job: CreatorJob,
+ scriptArtifact: CreatorArtifact
+ ): Promise<boolean> {
+ if (scriptArtifact.path === null) return false;
+ const script = stickmanScriptManifestSchema.parse(JSON.parse(
+ await readFile(scriptArtifact.path, 'utf8')
+ ));
+ const settings = await ttsSettings(job);
+ for (const segment of script.segments) {
+ const fingerprint = stickmanNarrationFingerprint({
+ segment,
+ script: scriptArtifact,
+ settings
+ });
+ if (currentNarrationAudio(job, segment.id, fingerprint) !== undefined) continue;
+ if (hasUnresolvedProvider(job, 'narration', segment.id)) return false;
+ queueStage(job, 'narration', `approval:${scriptArtifact.id}:${segment.id}`, {
+ scopeKey: segment.id,
+ inputFingerprint: fingerprint
+ });
+ return false;
+ }
+ return true;
+ }
+
+ function queueStage(
+ job: CreatorJob,
+ stageId: string,
+ parentIdentity: string,
+ identity: { scopeKey?: string; inputFingerprint?: string } = {}
+ ): void {
+ const current = input.creator.getJob(job.id) ?? job;
+ const scopedRuns = current.stages.filter(stage => (
+ stage.stageId === stageId
+ && stage.scopeKey === (identity.scopeKey ?? null)
+ ));
+ const matchingRuns = scopedRuns.filter(stage => (
+ stage.inputFingerprint === (identity.inputFingerprint ?? null)
+ ));
+ if (matchingRuns.some(stage => stage.status === 'queued' || stage.status === 'running')) return;
+ const generation = scopedRuns.length + 1;
+ input.dispatcher.dispatchWorkflow(current.id, {
+ action: 'run-stage',
+ expectedRevision: current.revision,
+ idempotencyKey: `stickman:${current.id}:${parentIdentity}:${stageId}:${identity.scopeKey ?? 'global'}:${generation}`,
+ input: { stageId }
+ }, { parentStageRunId: parentIdentity, ...identity });
+ }
+
+ async function recover(): Promise<void> {
+ for (const job of input.creator.listJobs()) {
+ if (!isStickman(job)) continue;
+ await recoverProviderRequests(job);
+ await recoverInterruptedScopes(input.creator.getJob(job.id) ?? job);
+ await reconcile(input.creator.getJob(job.id) ?? job);
+ }
+ }
+
+ async function recoverProviderRequests(job: CreatorJob): Promise<void> {
+ if (input.providerLedger === undefined) return;
+ for (const request of job.providerRequests) {
+ if (isProviderTerminal(request)) continue;
+ await input.providerLedger.recover(
+ request.id,
+ input.providerCapabilities ?? noProviderLookup
+ );
+ }
+ }
+
+ async function recoverInterruptedScopes(job: CreatorJob): Promise<void> {
+ if (input.repository === undefined) return;
+ for (const stage of job.stages.filter(candidate => candidate.status === 'interrupted')) {
+ const latest = input.creator.getJob(job.id) ?? job;
+ const artifact = completedScopedOutput(latest, stage);
+ if (artifact !== undefined) {
+ input.repository.updateStageRun({
+ id: stage.id,
+ status: 'succeeded',
+ progress: { ...stage.progress, recoveredArtifactId: artifact.id },
+ errorCode: null,
+ errorMessage: null
+ });
+ continue;
+ }
+ const requests = latest.providerRequests.filter(request => request.stageRunId === stage.id);
+ const unresolved = requests.find(request => (
+ request.status === 'unknown_remote_acceptance'
+ || request.status === 'waiting_remote'
+ ));
+ if (unresolved !== undefined || hasRemoteSideEffect(stage, requests)) {
+ setProviderRecoveryGate(input.creator, latest, stage, unresolved);
+ continue;
+ }
+ if (requests.some(request => request.status === 'succeeded')) {
+ setProviderRecoveryGate(input.creator, latest, stage, requests.at(-1));
+ continue;
+ }
+ queueStage(latest, stage.stageId, `recovery:${stage.id}`, {
+ ...(stage.scopeKey === null ? {} : { scopeKey: stage.scopeKey }),
+ ...(stage.inputFingerprint === null
+ ? {}
+ : { inputFingerprint: stage.inputFingerprint })
+ });
+ const resumed = (input.creator.getJob(job.id) ?? latest).stages.find(candidate => (
+ candidate.progress.workflowParentStageRunId === `recovery:${stage.id}`
+ ));
+ if (resumed !== undefined) {
+ input.repository.updateStageRun({
+ id: resumed.id,
+ status: resumed.status,
+ progress: { ...resumed.progress, resumedFromStageRunId: stage.id }
+ });
+ }
+ }
+ }
+
+ async function imageSettings(job: CreatorJob): Promise<StickmanImageSettings> {
+ if (input.configStore === undefined) {
+ return {
+ provider: 'configured-image-provider',
+ model: 'configured-image-model',
+ quality: typeof job.state.quality === 'string' ? job.state.quality : 'medium'
+ };
+ }
+ const config = await input.configStore.read();
+ const provider = config.image.provider;
+ return {
+ provider,
+ model: config.image[provider].model,
+ quality: typeof job.state.quality === 'string' ? job.state.quality : 'medium'
+ };
+ }
+
+ async function ttsSettings(job: CreatorJob): Promise<StickmanTtsSettings> {
+ if (input.configStore === undefined) {
+ return {
+ provider: typeof job.state.ttsProvider === 'string' ? job.state.ttsProvider : 'openai',
+ model: typeof job.state.ttsModel === 'string' ? job.state.ttsModel : 'default',
+ voiceId: typeof job.state.voiceCode === 'string' ? job.state.voiceCode : 'default'
+ };
+ }
+ const config = await input.configStore.read();
+ const provider = job.state.ttsProvider === 'openai'
+ || job.state.ttsProvider === 'aliyun'
+ || job.state.ttsProvider === 'minimax'
+ ? job.state.ttsProvider
+ : config.tts.provider;
+ if (provider === 'edge-tts') {
+ return { provider, model: '', voiceId: '' };
+ }
+ const providerConfig = config.tts[provider];
+ return {
+ provider,
+ model: typeof job.state.ttsModel === 'string' && job.state.ttsModel.trim()
+ ? job.state.ttsModel.trim()
+ : providerConfig.model,
+ voiceId: typeof job.state.voiceCode === 'string' && job.state.voiceCode.trim()
+ ? job.state.voiceCode.trim()
+ : providerConfig.defaultVoiceId
+ };
+ }
+
+ return {
+ handleStageChanged,
+ handleAction,
+ validateStage,
+ validateResume,
+ reconcile,
+ recover,
+ async resumeConfiguredJobs(): Promise<void> {
+ for (const job of input.creator.listJobs()) await reconcile(job);
+ }
+ };
+}
+
+function matchesCurrentVisualProfile(
+ job: CreatorJob,
+ characterReference: CreatorArtifact,
+ styleReference: CreatorArtifact | undefined,
+ styleContract: CreatorArtifact
+): boolean {
+ const character = readVisualAssetRef(
+ job.state.characterAsset,
+ DEFAULT_STICKMAN_CHARACTER_ASSET
+ );
+ const style = readVisualAssetRef(job.state.styleAsset, DEFAULT_STICKMAN_STYLE_ASSET);
+ return characterReference.metadata.assetId === character.assetId
+ && characterReference.metadata.revision === character.revision
+ && styleContract.metadata.contract === 'stickman-visual-profile-v2'
+ && styleContract.metadata.characterAssetId === character.assetId
+ && styleContract.metadata.characterRevision === character.revision
+ && styleContract.metadata.styleAssetId === style.assetId
+ && styleContract.metadata.styleRevision === style.revision
+ && (
+ styleContract.metadata.styleReferenceCount === 0
+ ? styleReference === undefined
+ : styleReference !== undefined
+ && styleReference.metadata.assetId === style.assetId
+ && styleReference.metadata.revision === style.revision
+ );
+}
+
+function requireApprovedInputs(job: CreatorJob, stageId: string): void {
+ const script = latestCompleted(job, 'script_manifest');
+ if (
+ stageAtOrAfter(stageId, 'narration')
+ && (script === undefined || job.state.approvedScriptArtifactId !== script.id)
+ ) {
+ throw new CreatorServiceError('creator_review_required', '必须先审核当前脚本');
+ }
+ const storyboard = latestCompleted(job, 'shot_spec');
+ if (
+ stageAtOrAfter(stageId, 'style-assets')
+ && storyboard === undefined
+ ) {
+ throw new CreatorServiceError('creator_stage_input_missing', '必须先生成当前分镜');
+ }
+}
+
+function requireWorkflowTarget(job: CreatorJob, stageId: string): void {
+ if (stageAtOrAfter(stageId, 'timeline') && !workflowTargetAtLeast(job, 'delivery_ready')) {
+ throw new CreatorServiceError(
+ 'creator_workflow_gate_required',
+ '必须先确认当前分镜画面,才能开始动画合成'
+ );
+ }
+ if (stageAtOrAfter(stageId, 'storyboard') && !workflowTargetAtLeast(job, 'visuals_ready')) {
+ throw new CreatorServiceError(
+ 'creator_workflow_gate_required',
+ '必须先完成配音与节奏阶段,才能开始生成分镜画面'
+ );
+ }
+}
+
+type StickmanWorkflowTarget = 'script_ready' | 'audio_ready' | 'visuals_ready' | 'delivery_ready';
+
+function workflowTargetAtLeast(job: CreatorJob, expected: StickmanWorkflowTarget): boolean {
+ const order: StickmanWorkflowTarget[] = [
+ 'script_ready',
+ 'audio_ready',
+ 'visuals_ready',
+ 'delivery_ready'
+ ];
+ return order.indexOf(readWorkflowTarget(job)) >= order.indexOf(expected);
+}
+
+function readWorkflowTarget(job: CreatorJob): StickmanWorkflowTarget {
+ const value = job.state.workflowTarget;
+ if (
+ value === 'script_ready'
+ || value === 'audio_ready'
+ || value === 'visuals_ready'
+ || value === 'delivery_ready'
+ ) return value;
+
+ const currentStage = typeof job.state.currentStage === 'string' ? job.state.currentStage : '';
+ if (stageAtOrAfter(currentStage, 'timeline')) return 'delivery_ready';
+ if (stageAtOrAfter(currentStage, 'storyboard')) return 'visuals_ready';
+ if (stageAtOrAfter(currentStage, 'narration')) return 'audio_ready';
+ return 'script_ready';
+}
+
+function stageAtOrAfter(stageId: string, boundary: string): boolean {
+ const order = [
+ 'ingest-text', 'source-transcript', 'source-brief', 'content-plan', 'script',
+ 'narration', 'audio-timing', 'storyboard', 'style-assets', 'prompt-pack',
+ 'images', 'visual-validation', 'timeline', 'render-clean', 'media-validation',
+ 'package-validation'
+ ];
+ return order.indexOf(stageId) >= order.indexOf(boundary);
+}
+
+function completedScopedOutput(job: CreatorJob, stage: CreatorStageRun): CreatorArtifact | undefined {
+ if (stage.scopeKey === null || stage.inputFingerprint === null) return undefined;
+ return job.artifacts.find(artifact => (
+ artifact.status === 'completed'
+ && artifact.scopeKey === stage.scopeKey
+ && artifact.inputFingerprint === stage.inputFingerprint
+ ));
+}
+
+function hasUnresolvedProvider(job: CreatorJob, stageId: string, scopeKey: string | null): boolean {
+ const stageIds = new Set(job.stages.filter(stage => (
+ stage.stageId === stageId && stage.scopeKey === scopeKey
+ )).map(stage => stage.id));
+ return job.providerRequests.some(request => (
+ stageIds.has(request.stageRunId)
+ && (request.status === 'unknown_remote_acceptance' || request.status === 'waiting_remote')
+ ));
+}
+
+function hasRemoteSideEffect(
+ stage: CreatorStageRun,
+ requests: CreatorProviderRequest[]
+): boolean {
+ return typeof stage.progress.krillinTaskId === 'string'
+ || requests.some(request => (
+ request.status === 'submitting'
+ || request.status === 'waiting_remote'
+ || request.status === 'unknown_remote_acceptance'
+ ));
+}
+
+function isProviderTerminal(request: CreatorProviderRequest): boolean {
+ return ['succeeded', 'failed', 'abandoned_unknown', 'canceled'].includes(request.status);
+}
+
+function latestCompleted(job: CreatorJob, kind: string): CreatorArtifact | undefined {
+ return [...job.artifacts].reverse().find(artifact => (
+ artifact.kind === kind && artifact.status === 'completed'
+ ));
+}
+
+function isStickman(job: CreatorJob | undefined): job is CreatorJob {
+ return job?.templateId === 'stickman-video' && job.templateVersion === 2;
+}
+
+function setReviewGate(
+ creator: CreatorService,
+ job: CreatorJob,
+ kind: 'approve-script',
+ artifactId: string
+): void {
+ const currentGate = job.state.needsInput;
+ if (
+ currentGate !== null
+ && typeof currentGate === 'object'
+ && !Array.isArray(currentGate)
+ && currentGate.kind === kind
+ && currentGate.artifactId === artifactId
+ ) return;
+ const messages = {
+ 'approve-script': '请审核脚本后继续'
+ } as const;
+ creator.setNeedsInput(job.id, {
+ code: 'creator_review_required',
+ message: messages[kind],
+ reviewKind: kind,
+ artifactId
+ });
+}
+
+function setProviderRecoveryGate(
+ creator: CreatorService,
+ job: CreatorJob,
+ stage: CreatorStageRun,
+ request?: CreatorProviderRequest
+): void {
+ const currentGate = job.state.needsInput;
+ if (
+ currentGate !== null
+ && typeof currentGate === 'object'
+ && !Array.isArray(currentGate)
+ && currentGate.code === 'creator_provider_resolution_required'
+ && currentGate.resumeStageId === stage.stageId
+ ) return;
+ creator.setNeedsInput(job.id, {
+ code: 'creator_provider_resolution_required',
+ message: request === undefined
+ ? '检测到未完成的远端任务,请确认状态后继续'
+ : `Provider 请求 ${request.id} 的远端接受状态需要用户处置`,
+ resumeStageId: stage.stageId,
+ workflow: true
+ });
+}
diff --git a/apps/daemon/src/creator/templates/stickman-video.ts b/apps/daemon/src/creator/templates/stickman-video.ts
index f854091c..e75c4df3 100644
--- a/apps/daemon/src/creator/templates/stickman-video.ts
+++ b/apps/daemon/src/creator/templates/stickman-video.ts
@@ -1,76 +1,146 @@
import { z } from 'zod';
-import type { CreatorTemplateDefinition } from './types.js';
+import type { CreatorTemplateAction, CreatorTemplateDefinition, CreatorTemplateStage } from './types.js';
-const record = z.record(z.string(), z.unknown()) as never;
+const jsonRecord = z.record(z.string(), z.unknown());
+const positiveVersion = z.number().int().positive();
+const stageId = z.string().min(1);
+const artifactId = z.string().min(1);
+const scopeKey = z.string().min(1);
+const fingerprint = z.string().regex(/^[a-f0-9]{64}$/i);
+
+const workflowTarget = z.enum([
+ 'script_ready',
+ 'audio_ready',
+ 'visuals_ready',
+ 'delivery_ready'
+]);
+const visualAssetRef = z.object({
+ assetId: z.string().min(1),
+ revision: z.number().int().positive()
+}).strict();
+
+const action = (
+ id: string,
+ schema: z.ZodTypeAny,
+ allowedStages: string[]
+): CreatorTemplateAction => ({ id, inputSchema: schema as never, allowedStages });
+
+const stage = (
+ definition: Omit<CreatorTemplateStage, 'allowedJobStatuses' | 'jobCompletionPolicy'>
+ & { final?: boolean }
+): CreatorTemplateStage => {
+ const { final = false, ...value } = definition;
+ return {
+ ...value,
+ allowedJobStatuses: ['draft', 'running', 'failed', 'needs_input', 'completed'],
+ jobCompletionPolicy: final ? 'complete' : 'continue',
+ resultVersionPolicy: final ? 'snapshot' : 'none'
+ };
+};
+
+export const stickmanVideoStageIds = [
+ 'ingest-text',
+ 'source-transcript',
+ 'source-brief',
+ 'content-plan',
+ 'script',
+ 'narration',
+ 'audio-timing',
+ 'storyboard',
+ 'style-assets',
+ 'prompt-pack',
+ 'images',
+ 'visual-validation',
+ 'timeline',
+ 'render-clean',
+ 'media-validation',
+ 'package-validation'
+] as const;
export function createStickmanVideoTemplate(): CreatorTemplateDefinition {
+ const allStages = [...stickmanVideoStageIds];
return {
id: 'stickman-video',
- version: 1,
+ version: 2,
renderer: 'stickman-video',
inputSchema: z.object({
+ sourceType: z.enum(['url', 'text']).default('url'),
+ sourceUrl: z.string().default(''),
+ sourceText: z.string().max(50_000).default(''),
topic: z.string().default(''),
- style: z.string().default('极简黑白线稿'),
- characterPrompt: z.string().default('统一的极简火柴人角色'),
- ratio: z.enum(['16:9', '1:1', '9:16']).default('16:9'),
+ characterAsset: visualAssetRef.default({
+ assetId: 'stickman.character.default',
+ revision: 1
+ }),
+ styleAsset: visualAssetRef.default({
+ assetId: 'stickman.style.paper-pencil',
+ revision: 1
+ }),
+ ratio: z.literal('16:9').default('16:9'),
targetDurationSeconds: z.number().positive().max(600).default(30),
- voice: z.string().default('alloy'),
+ sourceLanguage: z.string().default('auto'),
+ targetLanguage: z.string().default('zh-CN'),
+ ttsProvider: z.enum(['openai', 'aliyun', 'edge-tts', 'minimax']).optional(),
+ ttsModel: z.string().optional(),
+ voiceCode: z.string().optional(),
+ voiceName: z.string().optional(),
+ workflowTarget: workflowTarget.default('script_ready'),
currentStage: z.string().nullable().default(null)
}).passthrough() as never,
stages: [
- {
- id: 'script', executor: 'stickman', allowedJobStatuses: ['draft', 'running', 'failed', 'needs_input'],
- inputArtifacts: [],
- outputArtifacts: [
- { kind: 'script_manifest', status: 'completed' },
- { kind: 'script_segment', status: 'completed' },
- { kind: 'target_subtitle', status: 'completed' }
- ]
- },
- {
- id: 'storyboard', executor: 'stickman', dependsOn: ['script'], allowedJobStatuses: ['draft', 'running', 'failed', 'needs_input'],
- inputArtifacts: [
- { kind: 'script_manifest', selector: 'latest-completed' },
- { kind: 'script_segment', selector: 'latest-completed' }
- ],
- outputArtifacts: [
- { kind: 'storyboard_manifest', status: 'completed' },
- { kind: 'storyboard_image', status: 'completed' }
- ]
- },
- {
- id: 'narration', executor: 'stickman', dependsOn: ['script'], allowedJobStatuses: ['draft', 'running', 'failed', 'needs_input'],
- inputArtifacts: [
- { kind: 'script_manifest', selector: 'latest-completed' },
- { kind: 'script_segment', selector: 'latest-completed' }
- ],
- outputArtifacts: [
- { kind: 'narration_manifest', status: 'completed' },
- { kind: 'segment_audio', status: 'completed' }
- ]
- },
- {
- id: 'render', executor: 'stickman', dependsOn: ['storyboard', 'narration'], allowedJobStatuses: ['draft', 'running', 'failed', 'needs_input'],
- inputArtifacts: [
- { kind: 'storyboard_manifest', selector: 'latest-completed' },
- { kind: 'narration_manifest', selector: 'latest-completed' }
- ],
- outputArtifacts: [{ kind: 'stickman_video', status: 'completed' }]
- }
+ stage({ id: 'ingest-text', executor: 'stickman-content', inputArtifacts: [], outputArtifacts: [{ kind: 'source_text', status: 'completed' }] }),
+ stage({ id: 'source-transcript', executor: 'krillinai', inputArtifacts: [], outputArtifacts: [{ kind: 'source_subtitle', status: 'completed' }] }),
+ stage({ id: 'source-brief', executor: 'stickman-content', inputArtifacts: [{ kind: 'source_text', selector: 'latest-completed', optional: true }, { kind: 'source_subtitle', selector: 'latest-completed', optional: true }], outputArtifacts: [{ kind: 'source_brief', status: 'completed' }] }),
+ stage({ id: 'content-plan', executor: 'stickman-content', dependsOn: ['source-brief'], inputArtifacts: [{ kind: 'source_brief', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'content_plan', status: 'completed' }] }),
+ stage({ id: 'script', executor: 'stickman-content', dependsOn: ['content-plan'], inputArtifacts: [{ kind: 'content_plan', selector: 'latest-completed' }, { kind: 'source_brief', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'script_manifest', status: 'completed' }] }),
+ stage({ id: 'narration', executor: 'stickman-audio', dependsOn: ['script'], inputArtifacts: [{ kind: 'script_manifest', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'narration_audio', status: 'completed' }] }),
+ stage({ id: 'audio-timing', executor: 'stickman-audio', dependsOn: ['narration'], inputArtifacts: [{ kind: 'script_manifest', selector: 'latest-completed' }, { kind: 'narration_audio', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'audio_timing', status: 'completed' }] }),
+ stage({ id: 'storyboard', executor: 'stickman-content', dependsOn: ['audio-timing'], inputArtifacts: [{ kind: 'script_manifest', selector: 'latest-completed' }, { kind: 'audio_timing', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'shot_spec', status: 'completed' }] }),
+ stage({ id: 'style-assets', executor: 'stickman-content', dependsOn: ['storyboard'], inputArtifacts: [{ kind: 'shot_spec', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'character_reference', status: 'completed' }, { kind: 'style_reference', status: 'completed' }, { kind: 'style_contract', status: 'completed' }] }),
+ stage({ id: 'prompt-pack', executor: 'stickman-content', dependsOn: ['style-assets'], inputArtifacts: [{ kind: 'shot_spec', selector: 'latest-completed' }, { kind: 'character_reference', selector: 'latest-completed' }, { kind: 'style_reference', selector: 'latest-completed', optional: true }, { kind: 'style_contract', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'image_prompt_pack', status: 'completed' }] }),
+ stage({ id: 'images', executor: 'stickman-image', dependsOn: ['prompt-pack'], invalidateDependentArtifacts: false, replaceOutputArtifactsInScope: true, inputArtifacts: [{ kind: 'shot_spec', selector: 'latest-completed' }, { kind: 'image_prompt_pack', selector: 'latest-completed' }, { kind: 'character_reference', selector: 'latest-completed' }, { kind: 'style_reference', selector: 'latest-completed', optional: true }, { kind: 'style_contract', selector: 'latest-completed' }, { kind: 'shot_image', selector: 'latest-completed', optional: true }], outputArtifacts: [{ kind: 'shot_image', status: 'completed' }] }),
+ stage({ id: 'visual-validation', executor: 'stickman-validation', dependsOn: ['images'], inputArtifacts: [{ kind: 'shot_spec', selector: 'latest-completed' }, { kind: 'shot_image', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'visual_validation', status: 'completed' }] }),
+ stage({ id: 'timeline', executor: 'stickman-timeline', dependsOn: ['visual-validation'], inputArtifacts: [{ kind: 'script_manifest', selector: 'latest-completed' }, { kind: 'audio_timing', selector: 'latest-completed' }, { kind: 'shot_spec', selector: 'latest-completed' }, { kind: 'shot_image', selector: 'latest-completed' }, { kind: 'narration_audio', selector: 'latest-completed' }, { kind: 'visual_validation', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'timeline_manifest', status: 'completed' }, { kind: 'narration_subtitle', status: 'completed' }] }),
+ stage({ id: 'render-clean', executor: 'stickman-remotion', dependsOn: ['timeline'], inputArtifacts: [{ kind: 'timeline_manifest', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'clean_video', status: 'completed' }] }),
+ stage({ id: 'media-validation', executor: 'stickman-media-validation', dependsOn: ['render-clean'], inputArtifacts: [{ kind: 'clean_video', selector: 'latest-completed' }, { kind: 'timeline_manifest', selector: 'latest-completed' }], outputArtifacts: [{ kind: 'media_validation', status: 'completed' }] }),
+ stage({ id: 'package-validation', executor: 'stickman-delivery', dependsOn: ['media-validation'], final: true, invalidateDependentArtifacts: false, inputArtifacts: [
+ { kind: 'clean_video', selector: 'latest-completed' },
+ { kind: 'narration_subtitle', selector: 'latest-completed' },
+ { kind: 'visual_validation', selector: 'latest-completed' },
+ { kind: 'audio_timing', selector: 'latest-completed' },
+ { kind: 'timeline_manifest', selector: 'latest-completed' },
+ { kind: 'media_validation', selector: 'latest-completed' },
+ { kind: 'narration_audio', selector: 'latest-completed' }
+ ], outputArtifacts: [
+ { kind: 'clean_video', status: 'completed' },
+ { kind: 'narration_subtitle', status: 'completed' },
+ { kind: 'delivery_manifest', status: 'completed' }
+ ] })
],
actions: [
- {
- id: 'update-settings', inputSchema: record, allowedStages: ['script', 'storyboard', 'narration', 'render'],
- invalidates: [{ sourceArtifactKind: 'script_manifest', propagateThroughStageGraph: true }]
- },
- {
- id: 'edit-script-segment', inputSchema: record, allowedStages: ['storyboard', 'narration', 'render'],
- invalidates: [{ sourceArtifactKind: 'script_segment', propagateThroughStageGraph: true }]
- },
- { id: 'run-stage', inputSchema: record, allowedStages: ['script', 'storyboard', 'narration', 'render'] },
- { id: 'undo-action', inputSchema: record, allowedStages: ['script', 'storyboard', 'narration', 'render'] }
+ action('update-settings', z.object({ patch: jsonRecord, activityMode: z.enum(['draft', 'semantic']).optional(), objectId: z.string().optional() }).strict(), allStages),
+ action('edit-script', z.object({ artifactId, content: z.string().min(1), baseResultVersion: positiveVersion.optional() }).strict(), ['script', 'storyboard']),
+ action('approve-script', z.object({ artifactId, revision: z.number().int().nonnegative() }).strict(), ['script']),
+ action('continue-after-audio', z.object({ artifactId, revision: z.number().int().nonnegative() }).strict(), ['audio-timing']),
+ action('continue-after-visuals', z.object({ artifactId, revision: z.number().int().nonnegative() }).strict(), ['visual-validation']),
+ action('edit-shot', z.object({ artifactId, scopeKey, patch: jsonRecord, revision: z.number().int().nonnegative() }).strict(), ['storyboard', 'images', 'visual-validation']),
+ action('regenerate-shot', z.object({ scopeKey, inputFingerprint: fingerprint, revision: z.number().int().nonnegative() }).strict(), ['images', 'visual-validation']),
+ action('generate-missing-shots', z.object({ revision: z.number().int().nonnegative() }).strict(), ['images', 'visual-validation']),
+ action('run-stage', z.object({ stageId, baseResultVersion: positiveVersion.optional(), inputResultVersion: positiveVersion.optional(), targetResultVersion: positiveVersion.optional() }).strict(), allStages),
+ action('commit-version', z.object({ baseResultVersion: positiveVersion }).strict(), ['package-validation']),
+ action('retry-stage', z.object({ stageId, scopeKey: scopeKey.optional() }).strict(), allStages),
+ action('resolve-provider-request', z.discriminatedUnion('decision', [
+ z.object({ ledgerId: z.string().min(1), revision: z.number().int().nonnegative(), decision: z.literal('query') }).strict(),
+ z.object({ ledgerId: z.string().min(1), revision: z.number().int().nonnegative(), decision: z.literal('confirm-resubmit'), acceptDuplicateBilling: z.literal(true) }).strict(),
+ z.object({ ledgerId: z.string().min(1), revision: z.number().int().nonnegative(), decision: z.literal('cancel-scope') }).strict()
+ ]), allStages),
+ action('undo-action', z.object({ patch: jsonRecord }).strict(), allStages)
+ ],
+ outputs: [
+ { kind: 'clean_video', required: true },
+ { kind: 'narration_subtitle', required: true },
+ { kind: 'delivery_manifest', required: true }
],
- outputs: [{ kind: 'stickman_video', required: true }],
- agentGuidance: '先生成脚本,再生成逐段分镜和配音,最后合成视频;修改单段脚本时保留其他段落的有效资产。'
+ agentGuidance: '按脚本、配音、分镜画面、动画合成和成片交付的阶段边界推进;计费请求未知时只能建议用户显式处置。'
};
}
diff --git a/apps/daemon/src/creator/templates/types.ts b/apps/daemon/src/creator/templates/types.ts
index 4aec44be..028b2ac6 100644
--- a/apps/daemon/src/creator/templates/types.ts
+++ b/apps/daemon/src/creator/templates/types.ts
@@ -12,7 +12,9 @@ export type CreatorTemplateStage = {
optional?: boolean;
completesJob?: boolean;
resultVersionPolicy?: 'snapshot' | 'none';
+ jobCompletionPolicy?: 'complete' | 'continue';
invalidateDependentArtifacts?: boolean;
+ replaceOutputArtifactsInScope?: boolean;
allowedJobStatuses: CreatorJobStatus[];
inputArtifacts: Array<{
kind: string;
diff --git a/apps/daemon/src/creator/validators/media.ts b/apps/daemon/src/creator/validators/media.ts
index 3bfdf4b0..9d39987e 100644
--- a/apps/daemon/src/creator/validators/media.ts
+++ b/apps/daemon/src/creator/validators/media.ts
@@ -9,10 +9,15 @@ export type MediaProbe = {
hasAudio: boolean;
};
-export async function validateMediaFile(path: string, ffprobe: string): Promise<MediaProbe> {
+export async function validateMediaFile(
+ path: string,
+ ffprobe: string,
+ ffprobePrefixArgs: string[] = []
+): Promise<MediaProbe> {
const info = await stat(path);
if (!info.isFile() || info.size === 0) throw new Error('invalid_media: empty file');
const output = await execFileText(ffprobe, [
+ ...ffprobePrefixArgs,
'-v', 'error',
'-show_entries', 'format=duration:stream=codec_type,width,height',
'-of', 'json',
diff --git a/apps/daemon/src/image-generation/provider.ts b/apps/daemon/src/image-generation/provider.ts
index 53bb3265..1039b0a9 100644
--- a/apps/daemon/src/image-generation/provider.ts
+++ b/apps/daemon/src/image-generation/provider.ts
@@ -22,6 +22,20 @@ export type GeneratedImageContent = {
mime: ImageGenerationAsset['mime'];
};
+export type ImageGenerationCapabilities = {
+ supportsReferenceImage: boolean;
+ maxReferenceImages: number;
+};
+
+export function imageGenerationCapabilities(
+ provider: CreateImageGenerationRequest['provider']
+): ImageGenerationCapabilities {
+ return {
+ supportsReferenceImage: provider === 'openai' || provider === 'gemini',
+ maxReferenceImages: provider === 'openai' || provider === 'gemini' ? 8 : 0
+ };
+}
+
export class ImageGenerationProviderError extends Error {
constructor(
readonly code: 'config_missing' | 'upstream_error' | 'unsupported_capability',
@@ -39,8 +53,12 @@ export async function generateImageContents(
fetchImpl?: typeof fetch;
signal?: AbortSignal;
referenceImage?: GeneratedImageContent;
+ referenceImages?: GeneratedImageContent[];
} = {}
): Promise<{ model: string; contents: GeneratedImageContent[] }> {
+ const referenceImages = options.referenceImages
+ ?? (options.referenceImage === undefined ? [] : [options.referenceImage]);
+ const capabilities = imageGenerationCapabilities(request.provider);
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
const abort = () => controller.abort(options.signal?.reason);
@@ -49,13 +67,13 @@ export async function generateImageContents(
else options.signal?.addEventListener('abort', abort, { once: true });
try {
if (
- options.referenceImage !== undefined
- && request.provider !== 'openai'
- && request.provider !== 'gemini'
+ referenceImages.length > capabilities.maxReferenceImages
) {
throw new ImageGenerationProviderError(
'unsupported_capability',
- `The ${request.provider} image provider does not support reference images`
+ capabilities.supportsReferenceImage
+ ? `The ${request.provider} image provider supports at most ${capabilities.maxReferenceImages} reference images`
+ : `The ${request.provider} image provider does not support reference images`
);
}
if (request.provider === 'gemini') {
@@ -63,7 +81,7 @@ export async function generateImageContents(
request,
config,
controller.signal,
- options.referenceImage,
+ referenceImages,
options.fetchImpl
);
}
@@ -74,7 +92,7 @@ export async function generateImageContents(
request,
config,
controller.signal,
- options.referenceImage,
+ referenceImages,
options.fetchImpl
);
} catch (error) {
@@ -94,7 +112,7 @@ async function generateOpenAiImages(
request: CreateImageGenerationRequest,
config: CreatorServicesConfig,
signal: AbortSignal,
- referenceImage?: GeneratedImageContent,
+ referenceImages: GeneratedImageContent[],
fetchImpl?: typeof fetch
) {
const provider = request.provider === 'jimeng' ? config.image.jimeng : config.image.openai;
@@ -103,9 +121,9 @@ async function generateOpenAiImages(
|| (request.provider === 'jimeng' ? 'doubao-seedream-4-0-250828' : 'gpt-image-1');
const endpoint = openAiImageEndpoint(
provider.baseUrl,
- referenceImage === undefined ? 'generations' : 'edits'
+ referenceImages.length === 0 ? 'generations' : 'edits'
);
- const multipart = referenceImage === undefined
+ const multipart = referenceImages.length === 0
? undefined
: createImageEditBody({
model,
@@ -113,7 +131,7 @@ async function generateOpenAiImages(
size: request.size,
quality: request.quality,
count: request.count,
- image: referenceImage
+ images: referenceImages
});
const response = await fetchCreatorService({
endpoint,
@@ -154,7 +172,7 @@ async function generateGeminiImages(
request: CreateImageGenerationRequest,
config: CreatorServicesConfig,
signal: AbortSignal,
- referenceImage?: GeneratedImageContent,
+ referenceImages: GeneratedImageContent[],
fetchImpl?: typeof fetch
) {
const provider = config.image.gemini;
@@ -173,14 +191,12 @@ async function generateGeminiImages(
body: JSON.stringify({
contents: [{
parts: [
- ...(referenceImage === undefined
- ? []
- : [{
- inlineData: {
- mimeType: referenceImage.mime,
- data: referenceImage.content.toString('base64')
- }
- }]),
+ ...referenceImages.map(referenceImage => ({
+ inlineData: {
+ mimeType: referenceImage.mime,
+ data: referenceImage.content.toString('base64')
+ }
+ })),
{ text: request.prompt.trim() }
]
}],
@@ -229,7 +245,7 @@ function createImageEditBody(input: {
size: string;
quality: string;
count: number;
- image: GeneratedImageContent;
+ images: GeneratedImageContent[];
}): { contentType: string; body: Buffer } {
const boundary = `opencreator-${crypto.randomUUID()}`;
const parts: Buffer[] = [];
@@ -247,15 +263,19 @@ function createImageEditBody(input: {
addField('size', input.size);
addField('quality', input.quality);
addField('n', String(input.count));
- parts.push(Buffer.from([
- `--${boundary}`,
- 'Content-Disposition: form-data; name="image"; filename="reference-image"',
- `Content-Type: ${input.image.mime}`,
- '',
- ''
- ].join('\r\n')));
- parts.push(input.image.content);
- parts.push(Buffer.from(`\r\n--${boundary}--\r\n`));
+ for (const [index, image] of input.images.entries()) {
+ const fieldName = input.images.length === 1 ? 'image' : 'image[]';
+ parts.push(Buffer.from([
+ `--${boundary}`,
+ `Content-Disposition: form-data; name="${fieldName}"; filename="reference-image-${index + 1}"`,
+ `Content-Type: ${image.mime}`,
+ '',
+ ''
+ ].join('\r\n')));
+ parts.push(image.content);
+ parts.push(Buffer.from('\r\n'));
+ }
+ parts.push(Buffer.from(`--${boundary}--\r\n`));
return {
contentType: `multipart/form-data; boundary=${boundary}`,
body: Buffer.concat(parts)
diff --git a/apps/daemon/src/storage/migrations.ts b/apps/daemon/src/storage/migrations.ts
index 4f9e7803..ff152655 100644
--- a/apps/daemon/src/storage/migrations.ts
+++ b/apps/daemon/src/storage/migrations.ts
@@ -343,6 +343,8 @@ export function migrate(db: Database.Database): void {
claim_expires_at TEXT,
attempt INTEGER NOT NULL DEFAULT 0,
idempotency_key TEXT,
+ scope_key TEXT,
+ input_fingerprint TEXT,
progress_json TEXT NOT NULL DEFAULT '{}',
error_code TEXT,
error_message TEXT,
@@ -359,6 +361,9 @@ export function migrate(db: Database.Database): void {
version INTEGER NOT NULL,
status TEXT NOT NULL,
path TEXT,
+ scope_key TEXT,
+ input_fingerprint TEXT,
+ sha256 TEXT,
source_artifact_ids_json TEXT NOT NULL DEFAULT '[]',
metadata_json TEXT NOT NULL DEFAULT '{}',
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -366,6 +371,29 @@ export function migrate(db: Database.Database): void {
UNIQUE(job_id, kind, version)
);
+ CREATE TABLE IF NOT EXISTS creator_provider_requests (
+ id TEXT PRIMARY KEY,
+ job_id TEXT NOT NULL,
+ provider TEXT NOT NULL,
+ stage_run_id TEXT NOT NULL,
+ scope_key TEXT,
+ request_key TEXT NOT NULL,
+ request_hash TEXT NOT NULL,
+ remote_task_id TEXT,
+ billing_side_effect INTEGER NOT NULL DEFAULT 1,
+ status TEXT NOT NULL,
+ result_artifact_id TEXT,
+ generation INTEGER NOT NULL DEFAULT 1,
+ resubmission_of TEXT,
+ created_at TEXT NOT NULL,
+ updated_at TEXT NOT NULL,
+ FOREIGN KEY(job_id) REFERENCES creator_jobs(id) ON DELETE CASCADE,
+ FOREIGN KEY(stage_run_id) REFERENCES creator_stage_runs(id) ON DELETE CASCADE,
+ FOREIGN KEY(result_artifact_id) REFERENCES creator_artifacts(id) ON DELETE SET NULL,
+ FOREIGN KEY(resubmission_of) REFERENCES creator_provider_requests(id) ON DELETE SET NULL,
+ UNIQUE(provider, request_key, generation)
+ );
+
CREATE TABLE IF NOT EXISTS creator_activities (
id TEXT PRIMARY KEY,
job_id TEXT NOT NULL,
@@ -572,6 +600,8 @@ export function migrate(db: Database.Database): void {
ON creator_stage_runs(job_id, created_at ASC, id ASC);
CREATE INDEX IF NOT EXISTS idx_creator_artifacts_job_kind_version
ON creator_artifacts(job_id, kind, version DESC);
+ CREATE INDEX IF NOT EXISTS idx_creator_provider_requests_job_scope_status
+ ON creator_provider_requests(job_id, scope_key, status, created_at ASC);
CREATE INDEX IF NOT EXISTS idx_creator_activities_job_revision
ON creator_activities(job_id, revision ASC, created_at ASC, id ASC);
CREATE INDEX IF NOT EXISTS idx_creator_agent_turns_session_created
@@ -624,6 +654,11 @@ export function migrate(db: Database.Database): void {
ensureColumn(db, 'creator_stage_runs', 'claim_expires_at', 'claim_expires_at TEXT');
ensureColumn(db, 'creator_stage_runs', 'attempt', 'attempt INTEGER NOT NULL DEFAULT 0');
ensureColumn(db, 'creator_stage_runs', 'idempotency_key', 'idempotency_key TEXT');
+ ensureColumn(db, 'creator_stage_runs', 'scope_key', 'scope_key TEXT');
+ ensureColumn(db, 'creator_stage_runs', 'input_fingerprint', 'input_fingerprint TEXT');
+ ensureColumn(db, 'creator_artifacts', 'scope_key', 'scope_key TEXT');
+ ensureColumn(db, 'creator_artifacts', 'input_fingerprint', 'input_fingerprint TEXT');
+ ensureColumn(db, 'creator_artifacts', 'sha256', 'sha256 TEXT');
ensureColumn(db, 'creator_jobs', 'creation_key', 'creation_key TEXT');
db.prepare(`
UPDATE schedules
@@ -671,6 +706,11 @@ export function migrate(db: Database.Database): void {
CREATE UNIQUE INDEX IF NOT EXISTS idx_creator_stage_runs_job_idempotency
ON creator_stage_runs(job_id, idempotency_key)
WHERE idempotency_key IS NOT NULL;
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_creator_stage_runs_active_scope_identity
+ ON creator_stage_runs(job_id, stage_id, scope_key, input_fingerprint)
+ WHERE scope_key IS NOT NULL
+ AND input_fingerprint IS NOT NULL
+ AND status IN ('queued', 'running');
CREATE UNIQUE INDEX IF NOT EXISTS idx_creator_jobs_creation_key
ON creator_jobs(creation_key)
WHERE creation_key IS NOT NULL;
diff --git a/apps/daemon/test/integration/creator-api.test.ts b/apps/daemon/test/integration/creator-api.test.ts
index 97e74910..258b7331 100644
--- a/apps/daemon/test/integration/creator-api.test.ts
+++ b/apps/daemon/test/integration/creator-api.test.ts
@@ -22,7 +22,12 @@ type TestResponse = { statusCode: number; json(): any };
afterEach(async () => {
await server?.close();
server = undefined;
- if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ if (tempDir) rmSync(tempDir, {
+ recursive: true,
+ force: true,
+ maxRetries: 30,
+ retryDelay: 100
+ });
tempDir = '';
});
diff --git a/apps/daemon/test/integration/creator-cover-generation.test.ts b/apps/daemon/test/integration/creator-cover-generation.test.ts
index 053b1f40..02c86b9c 100644
--- a/apps/daemon/test/integration/creator-cover-generation.test.ts
+++ b/apps/daemon/test/integration/creator-cover-generation.test.ts
@@ -12,7 +12,14 @@ let tempDir = '';
afterEach(async () => {
await server?.close();
server = undefined;
- if (tempDir) await rm(tempDir, { recursive: true, force: true });
+ if (tempDir) {
+ await rm(tempDir, {
+ recursive: true,
+ force: true,
+ maxRetries: 10,
+ retryDelay: 100
+ });
+ }
tempDir = '';
vi.unstubAllGlobals();
});
diff --git a/apps/daemon/test/integration/creator-krillin-cli-runner.test.ts b/apps/daemon/test/integration/creator-krillin-cli-runner.test.ts
index 12d5259e..330935a4 100644
--- a/apps/daemon/test/integration/creator-krillin-cli-runner.test.ts
+++ b/apps/daemon/test/integration/creator-krillin-cli-runner.test.ts
@@ -11,10 +11,16 @@ import {
writeFileSync
} from 'node:fs';
import { tmpdir } from 'node:os';
-import { dirname, join, relative } from 'node:path';
-import { afterEach, describe, expect, it } from 'vitest';
+import { basename, dirname, join, relative } from 'node:path';
+import { afterEach, describe, expect, it, vi } from 'vitest';
import type { CreatorExecutorInput } from '../../src/creator/executor.js';
-import { runKrillinCli } from '../../src/creator/krillin/cli-runner.js';
+import { createKrillinConfigToml } from '../../src/creator/krillin/config-bridge.js';
+import {
+ prepareCliResourceRoot,
+ recoverWindowsHorizontalAssRender,
+ runKrillinCli
+} from '../../src/creator/krillin/cli-runner.js';
+import { KrillinCliError } from '../../src/creator/krillin/cli-runner.js';
import type { KrillinRuntimeManifest } from '../../src/creator/krillin/manifest.js';
let tempDir = '';
@@ -25,6 +31,163 @@ afterEach(() => {
});
describe('KrillinAI CLI runner', () => {
+ it.runIf(process.platform === 'win32')('mounts packaged executable files without requiring symlink privileges', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-krillin-windows-file-overlay-'));
+ const resourceRoot = join(tempDir, 'runtime');
+ const dependencyRoot = join(tempDir, 'dependencies');
+ const launcherRoot = join(tempDir, 'launcher');
+ const ytDlp = join(tempDir, 'managed-yt-dlp.exe');
+ mkdirSync(join(resourceRoot, 'bin'), { recursive: true });
+ mkdirSync(launcherRoot, { recursive: true });
+ writeFileSync(join(resourceRoot, 'bin', 'ffmpeg.exe'), 'fixture-ffmpeg');
+ writeFileSync(ytDlp, 'fixture-yt-dlp');
+
+ await expect(prepareCliResourceRoot({
+ resourceRoot,
+ dependencyRoot,
+ launcherRoot,
+ ytDlpRuntime: {
+ version: 'test',
+ executable: ytDlp,
+ prefixArgs: [],
+ env: {}
+ }
+ })).resolves.toBe(launcherRoot);
+
+ expect(readFileSync(join(launcherRoot, 'bin', 'ffmpeg.exe'), 'utf8'))
+ .toBe('fixture-ffmpeg');
+ writeFileSync(join(launcherRoot, 'bin', 'yt-dlp.exe'), 'updated-by-krillin');
+ expect(readFileSync(ytDlp, 'utf8')).toBe('fixture-yt-dlp');
+ });
+
+ it('mounts the on-demand Whisper.cpp directory in the KrillinAI v2 layout', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-krillin-whispercpp-overlay-'));
+ const resourceRoot = join(tempDir, 'runtime');
+ const dependencyRoot = join(tempDir, 'dependencies');
+ const whisperCpp = join(dependencyRoot, 'bin', 'whispercpp');
+ const models = join(dependencyRoot, 'models');
+ const launcherRoot = join(tempDir, 'launcher');
+ mkdirSync(join(resourceRoot, 'bin'), { recursive: true });
+ mkdirSync(whisperCpp, { recursive: true });
+ mkdirSync(join(models, 'whispercpp'), { recursive: true });
+ mkdirSync(launcherRoot, { recursive: true });
+ writeFileSync(join(whisperCpp, 'whisper-cli.exe'), 'fixture-whispercpp');
+ writeFileSync(join(models, 'whispercpp', 'ggml-tiny.bin'), 'fixture-model');
+
+ await prepareCliResourceRoot({
+ resourceRoot,
+ dependencyRoot,
+ launcherRoot,
+ onDemandTranscriptionProvider: 'whisper.cpp',
+ onDemandTranscriptionModel: 'tiny'
+ });
+
+ expect(realpathSync(join(launcherRoot, 'bin', 'whispercpp')))
+ .toBe(realpathSync(whisperCpp));
+ expect(existsSync(join(launcherRoot, 'bin', 'whispercpp', 'whisper-cli.exe'))).toBe(true);
+ expect(existsSync(join(launcherRoot, 'models', 'whispercpp', 'ggml-tiny.bin'))).toBe(true);
+ expect(readFileSync(join(launcherRoot, 'models', 'whispercpp', 'ggml-large-v2.bin'), 'utf8'))
+ .toBe('fixture-model');
+ });
+
+ it('bridges the selected Whisper.cpp weights to the KrillinAI 2.1 model label', () => {
+ const config = createDefaultCreatorServicesConfig();
+ config.transcription.provider = 'whisper.cpp';
+ config.transcription.whisperCpp.model = 'tiny';
+
+ const value = parse(createKrillinConfigToml(config)) as {
+ transcribe: { provider: string; whispercpp: { model: string } };
+ };
+
+ expect(value.transcribe).toMatchObject({
+ provider: 'whispercpp',
+ whispercpp: { model: 'large-v2' }
+ });
+ });
+
+ it('recovers only the known Windows ASS drive-letter failure with the auto-video relative-path command', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-krillin-windows-ass-'));
+ const resourceRoot = join(tempDir, 'runtime');
+ const workdir = join(tempDir, 'jobs', 'job-1', 'render-run');
+ const source = join(tempDir, 'jobs', 'job-1', 'clean.mp4');
+ const ffmpeg = join(resourceRoot, 'bin', 'ffmpeg.exe');
+ mkdirSync(dirname(ffmpeg), { recursive: true });
+ mkdirSync(workdir, { recursive: true });
+ writeFileSync(ffmpeg, 'fixture-ffmpeg');
+ writeFileSync(source, 'fixture-video');
+ writeFileSync(join(workdir, 'formatted_horizontal_bilingual.ass'), 'fixture-ass');
+ const manifest: KrillinRuntimeManifest = {
+ version: 1,
+ platform: 'win32',
+ arch: 'x64',
+ resources: [{
+ path: relative(resourceRoot, ffmpeg).replaceAll('\\', '/'),
+ sha256: 'f'.repeat(64),
+ kind: 'executable'
+ }]
+ };
+ const runProcess = vi.fn(async (input: { args: string[] }) => {
+ writeFileSync(input.args.at(-1)!, 'recovered-video');
+ });
+ const progress: Array<Record<string, unknown>> = [];
+ const knownFailure = new KrillinCliError(
+ 'render_video_failed',
+ '[Parsed_ass_0] Unable to parse option value "/project/formatted_horizontal_bilingual.ass" as image size\n'
+ + "Error applying option 'original_size' to filter 'ass': Invalid argument"
+ );
+
+ const recovered = await recoverWindowsHorizontalAssRender({
+ platform: 'win32',
+ resourceRoot,
+ manifest,
+ stageId: 'bilingual-render',
+ workdir,
+ artifacts: [{ id: 'clean', kind: 'source_video', path: source }],
+ signal: new AbortController().signal,
+ error: knownFailure,
+ reportProgress(value) { progress.push(value); },
+ runProcess
+ });
+
+ const invocation = runProcess.mock.calls[0]![0];
+ const filterIndex = invocation.args.indexOf('-vf');
+ expect(invocation).toMatchObject({ executable: ffmpeg, cwd: workdir });
+ expect(invocation.args[filterIndex + 1]).toBe('ass=formatted_horizontal_bilingual.ass');
+ expect(invocation.args).toEqual(expect.arrayContaining([
+ '-map', '0:v:0', '-map', '0:a:0?', '-c:v', 'libx264',
+ '-preset', 'medium', '-crf', '23', '-c:a', 'aac', '-b:a', '128k'
+ ]));
+ expect(invocation.args.some(value => value.includes('/project/formatted_horizontal_bilingual.ass'))).toBe(false);
+ expect(recovered).toMatchObject({
+ ok: true,
+ outputs: { horizontal_video: join(workdir, 'horizontal_bilingual.mp4') }
+ });
+ expect(readFileSync(recovered!.outputs!.horizontal_video!, 'utf8')).toBe('recovered-video');
+ expect(JSON.parse(readFileSync(join(workdir, 'opencreator-windows-ass-recovery.json'), 'utf8')))
+ .toMatchObject({
+ reason: 'krillinai-2.1.0-windows-absolute-ass-path',
+ assFile: 'formatted_horizontal_bilingual.ass',
+ outputVideo: join(workdir, 'horizontal_bilingual.mp4')
+ });
+ expect(basename(invocation.args.at(-1)!)).toBe('.horizontal_bilingual.opencreator-recovery.mp4');
+ expect(progress).toEqual([expect.objectContaining({ phase: 'rendering_subtitles', percent: 95 })]);
+
+ runProcess.mockClear();
+ await expect(recoverWindowsHorizontalAssRender({
+ platform: 'win32',
+ resourceRoot,
+ manifest,
+ stageId: 'bilingual-render',
+ workdir,
+ artifacts: [{ id: 'clean', kind: 'source_video', path: source }],
+ signal: new AbortController().signal,
+ error: new KrillinCliError('render_video_failed', 'unrelated render failure'),
+ reportProgress() {},
+ runProcess
+ })).resolves.toBeUndefined();
+ expect(runProcess).not.toHaveBeenCalled();
+ });
+
it.skipIf(process.platform === 'win32')('writes private config, invokes the official CLI shape, maps outputs, and removes secrets', async () => {
tempDir = mkdtempSync(join(tmpdir(), 'creator-krillin-cli-'));
const resourceRoot = join(tempDir, 'runtime');
diff --git a/apps/daemon/test/integration/creator-stickman-real-pipeline.test.ts b/apps/daemon/test/integration/creator-stickman-real-pipeline.test.ts
new file mode 100644
index 00000000..e50ec497
--- /dev/null
+++ b/apps/daemon/test/integration/creator-stickman-real-pipeline.test.ts
@@ -0,0 +1,821 @@
+import { createHash } from 'node:crypto';
+import { execFile } from 'node:child_process';
+import {
+ existsSync,
+ mkdirSync,
+ readFileSync,
+ statSync,
+ writeFileSync
+} from 'node:fs';
+import { join, resolve } from 'node:path';
+import { promisify } from 'node:util';
+import { fileURLToPath } from 'node:url';
+import type { CreatorArtifact, CreatorJob, CreatorServicesConfig } from '@opencreator/protocol';
+import type { FastifyInstance } from 'fastify';
+import sharp from 'sharp';
+import { afterEach, describe, expect, it } from 'vitest';
+import { buildServer } from '../../src/api/server.js';
+import { parseCreatorServicesConfig } from '../../src/creator-services/config-store.js';
+
+const repoRoot = resolve(fileURLToPath(new URL('../../../../', import.meta.url)));
+const enabled = process.env.OPENCREATOR_RUN_REAL_STICKMAN_E2E === '1';
+const configPath = process.env.OPENCREATOR_STICKMAN_E2E_CONFIG;
+const acceptanceSourceText = [
+ '学习复杂主题可以分成三步。',
+ '第一步,先明确要解决的问题。',
+ '第二步,用一个具体例子验证自己的理解。',
+ '第三步,复盘结果并记录下一次改进。',
+ '这样做能把模糊目标转化为可执行行动。'
+].join('');
+const krillinRuntimeRoot = resolve(
+ process.env.OPENCREATOR_CREATOR_RUNTIME_ROOT
+ ?? join(repoRoot, 'apps', 'desktop', '.pack', 'creator-runtime', 'krillinai')
+);
+const stickmanRuntimeRoot = resolve(
+ process.env.OPENCREATOR_STICKMAN_RUNTIME_ROOT
+ ?? join(repoRoot, 'apps', 'desktop', '.pack', 'stickman-runtime')
+);
+const execFileAsync = promisify(execFile);
+let server: FastifyInstance | undefined;
+let previousCreatorRuntimeRoot: string | undefined;
+let previousStickmanRuntimeRoot: string | undefined;
+
+afterEach(async () => {
+ await server?.close();
+ server = undefined;
+ restoreEnvironment('OPENCREATOR_CREATOR_RUNTIME_ROOT', previousCreatorRuntimeRoot);
+ restoreEnvironment('OPENCREATOR_STICKMAN_RUNTIME_ROOT', previousStickmanRuntimeRoot);
+});
+
+describe('stickman real provider pipeline', () => {
+ it.skipIf(!enabled)(
+ '通过公开 Creator API 生成并验证火柴人视频与旁白字幕',
+ async () => {
+ if (configPath === undefined) {
+ throw new Error('真实火柴人 E2E 需要 OPENCREATOR_STICKMAN_E2E_CONFIG');
+ }
+ for (const path of [configPath, krillinRuntimeRoot, stickmanRuntimeRoot]) {
+ if (!existsSync(path)) throw new Error(`真实火柴人 E2E 依赖不存在:${path}`);
+ }
+
+ const config = readPrivateConfig(configPath);
+ const tts = configuredTts(config);
+ const imageConfig = configuredImage(config);
+ const evidenceRoot = createEvidenceRoot();
+ previousCreatorRuntimeRoot = process.env.OPENCREATOR_CREATOR_RUNTIME_ROOT;
+ previousStickmanRuntimeRoot = process.env.OPENCREATOR_STICKMAN_RUNTIME_ROOT;
+ process.env.OPENCREATOR_CREATOR_RUNTIME_ROOT = krillinRuntimeRoot;
+ process.env.OPENCREATOR_STICKMAN_RUNTIME_ROOT = stickmanRuntimeRoot;
+ server = await buildServer({
+ token: 'stickman-real-e2e',
+ dataDir: join(evidenceRoot, 'runtime'),
+ creatorServicesConfigStore: inMemoryConfigStore(config),
+ codexProviderCredentialStore: {
+ async readApiKey() { return undefined; },
+ async writeApiKey() {}
+ }
+ });
+
+ const created = await request('POST', '/creator/jobs', {
+ projectId: 'project_stickman_real_e2e',
+ templateId: 'stickman-video',
+ state: {
+ sourceType: 'text',
+ sourceText: acceptanceSourceText,
+ characterAsset: { assetId: 'stickman.character.student', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.minimal-ink', revision: 1 },
+ ratio: '16:9',
+ targetDurationSeconds: 30,
+ targetLanguage: 'zh-CN',
+ ttsProvider: tts.provider,
+ ttsModel: tts.model,
+ voiceCode: tts.voiceId,
+ voiceName: tts.voiceId,
+ quality: 'medium'
+ }
+ });
+ expect(created.statusCode).toBe(201);
+ const jobId = created.json().job.id as string;
+
+ const started = await request('POST', `/creator/jobs/${jobId}/actions`, {
+ action: 'run-stage',
+ expectedRevision: 0,
+ input: { stageId: 'ingest-text' }
+ });
+ expect(started.statusCode).toBe(200);
+
+ const finalScriptGate = await waitForReview(jobId, 'approve-script');
+ await approve(jobId, finalScriptGate);
+ const audioReady = await waitForJob(jobId, job => (
+ latestCurrentArtifactOrUndefined(job, 'audio_timing') !== undefined
+ && !job.stages.some(stage => stage.stageId === 'storyboard')
+ ), 30 * 60_000);
+ await continueAfterArtifact(jobId, audioReady, 'audio_timing', 'continue-after-audio');
+ const visualsReady = await waitForJob(jobId, job => (
+ latestCurrentArtifactOrUndefined(job, 'visual_validation') !== undefined
+ && !job.stages.some(stage => stage.stageId === 'timeline')
+ ), 30 * 60_000);
+ await continueAfterArtifact(jobId, visualsReady, 'visual_validation', 'continue-after-visuals');
+ const completed = await waitForJob(jobId, job => job.status === 'completed', 45 * 60_000);
+
+ const ffprobePath = findRuntimeExecutable(krillinRuntimeRoot, /(?:^|\/)ffprobe(?:\.exe)?$/i);
+ const stageById = new Map(completed.stages.map(stage => [stage.id, stage]));
+ expect(completed.activities.filter(activity => activity.action === 'approve-script')).toHaveLength(1);
+ expect(completed.activities.some(activity => activity.action === 'approve-visuals')).toBe(false);
+
+ const scriptArtifact = latestCurrentArtifact(completed, 'script_manifest');
+ const script = JSON.parse(readFileSync(scriptArtifact.path!, 'utf8')) as {
+ title: string;
+ language: string;
+ reviewStatus: string;
+ contentLocked: boolean;
+ totalNarrationUnits: number;
+ estimatedTotalDurationSeconds: number;
+ narrationBudget: { minUnits: number; maxUnits: number };
+ segments: Array<{
+ id: string;
+ narration: string;
+ estimatedDurationSeconds: number;
+ claimIds: string[];
+ sourceSpanIds: string[];
+ }>;
+ };
+ expect(script).toMatchObject({
+ reviewStatus: 'approved',
+ contentLocked: true,
+ narrationBudget: { minUnits: 108, maxUnits: 132 }
+ });
+ expect(script.segments.length).toBeGreaterThan(0);
+ expect(new Set(script.segments.map(segment => segment.id)).size).toBe(script.segments.length);
+ expect(script.estimatedTotalDurationSeconds)
+ .toBeGreaterThanOrEqual(27);
+ expect(script.estimatedTotalDurationSeconds)
+ .toBeLessThanOrEqual(33);
+ const sourceBrief = readArtifactJson(completed, 'source_brief') as {
+ claims: Array<{ id: string; sourceSpanIds: string[] }>;
+ sourceSpans: Array<{ id: string }>;
+ };
+ const contentPlan = readArtifactJson(completed, 'content_plan') as {
+ retainedClaimIds: string[];
+ discardedClaimIds: string[];
+ };
+ const claimIds = new Set(sourceBrief.claims.map(claim => claim.id));
+ const plannedClaimIds = new Set([
+ ...contentPlan.retainedClaimIds,
+ ...contentPlan.discardedClaimIds
+ ]);
+ expect(plannedClaimIds).toEqual(claimIds);
+ expect(new Set(sourceBrief.claims.flatMap(claim => claim.sourceSpanIds))).toEqual(
+ new Set(sourceBrief.sourceSpans.map(span => span.id))
+ );
+ const validSourceSpanIds = new Set(sourceBrief.sourceSpans.map(span => span.id));
+ const claimSourceSpanIds = new Map(sourceBrief.claims.map(claim => [
+ claim.id,
+ new Set(claim.sourceSpanIds)
+ ]));
+ const retainedClaimIds = new Set(contentPlan.retainedClaimIds);
+ const coveredClaimIds = new Set(script.segments.flatMap(segment => segment.claimIds));
+ expect(coveredClaimIds).toEqual(retainedClaimIds);
+ expect(script.segments.every(segment => (
+ segment.claimIds.length > 0
+ && segment.claimIds.every(claimId => retainedClaimIds.has(claimId))
+ && segment.sourceSpanIds.length > 0
+ && segment.sourceSpanIds.every(sourceSpanId => validSourceSpanIds.has(sourceSpanId))
+ && segment.sourceSpanIds.every(sourceSpanId => segment.claimIds.some(claimId => (
+ claimSourceSpanIds.get(claimId)?.has(sourceSpanId) === true
+ )))
+ && segment.estimatedDurationSeconds <= 5
+ ))).toBe(true);
+ expect(script.segments.map(segment => segment.narration).join('\n'))
+ .not.toMatch(/火柴人|镜头|画面|动画|字幕|配音|提示词|旁白/);
+ expect(completed.stages.some(stage => stage.stageId === 'semantic-review')).toBe(false);
+
+ const narrationRuns = completed.stages.filter(stage => stage.stageId === 'narration');
+ expect(narrationRuns).toHaveLength(script.segments.length);
+ expect(narrationRuns.map(stage => stage.scopeKey)).toEqual(script.segments.map(segment => segment.id));
+ for (const [index, stage] of narrationRuns.entries()) {
+ expect(stage.status).toBe('succeeded');
+ if (index > 0) {
+ expect(Date.parse(stage.startedAt!)).toBeGreaterThanOrEqual(
+ Date.parse(narrationRuns[index - 1]!.finishedAt!)
+ );
+ }
+ }
+ const narrationRequests = completed.providerRequests.filter(request => (
+ stageById.get(request.stageRunId)?.stageId === 'narration'
+ ));
+ expect(narrationRequests).toHaveLength(script.segments.length);
+ expect(narrationRequests.every(request => request.status === 'succeeded')).toBe(true);
+
+ const narrationArtifacts = completed.artifacts.filter(artifact => (
+ artifact.kind === 'narration_audio' && artifact.status === 'completed'
+ ));
+ expect(narrationArtifacts).toHaveLength(script.segments.length);
+ expect(narrationArtifacts.map(artifact => artifact.scopeKey)).toEqual(
+ script.segments.map(segment => segment.id)
+ );
+ for (const artifact of narrationArtifacts) {
+ expect(artifact.sourceArtifactIds).toContain(scriptArtifact.id);
+ expect(hashFile(artifact.path!)).toBe(artifact.sha256);
+ }
+
+ const timingArtifact = latestCurrentArtifact(completed, 'audio_timing');
+ const timing = JSON.parse(readFileSync(timingArtifact.path!, 'utf8')) as {
+ scriptArtifactId: string;
+ timingSource: string;
+ totalDurationSeconds: number;
+ segments: Array<{
+ segmentId: string;
+ startSeconds: number;
+ endSeconds: number;
+ durationSeconds: number;
+ audioArtifactId: string;
+ audioSha256: string;
+ }>;
+ };
+ expect(timing).toMatchObject({
+ scriptArtifactId: scriptArtifact.id,
+ timingSource: 'ffprobe_cumulative_tts_duration'
+ });
+ expect(timing.totalDurationSeconds).toBeGreaterThanOrEqual(27);
+ expect(timing.totalDurationSeconds).toBeLessThanOrEqual(33);
+ expect(timing.segments).toHaveLength(script.segments.length);
+ let timingCursor = 0;
+ for (const row of timing.segments) {
+ const audio = narrationArtifacts.find(artifact => artifact.id === row.audioArtifactId)!;
+ const probe = await probeMedia(ffprobePath, audio.path!);
+ expect(row.segmentId).toBe(audio.scopeKey);
+ expect(row.audioSha256).toBe(audio.sha256);
+ expect(Math.abs(row.startSeconds - timingCursor)).toBeLessThan(0.002);
+ expect(Math.abs(row.durationSeconds - probe.duration)).toBeLessThan(0.08);
+ expect(Math.abs(row.endSeconds - row.startSeconds - row.durationSeconds)).toBeLessThan(0.002);
+ timingCursor = row.endSeconds;
+ }
+ expect(Math.abs(timing.totalDurationSeconds - timingCursor)).toBeLessThan(0.002);
+
+ const audioTimingRun = completed.stages.find(stage => stage.stageId === 'audio-timing')!;
+ const storyboardRuns = completed.stages.filter(stage => stage.stageId === 'storyboard');
+ expect(storyboardRuns).toHaveLength(1);
+ expect(Date.parse(storyboardRuns[0]!.startedAt!)).toBeGreaterThanOrEqual(
+ Date.parse(audioTimingRun.finishedAt!)
+ );
+ const shotSpecArtifact = latestCurrentArtifact(completed, 'shot_spec');
+ const shotSpec = JSON.parse(readFileSync(shotSpecArtifact.path!, 'utf8')) as {
+ scriptArtifactId: string;
+ audioTimingArtifactId: string;
+ timingSource: string;
+ shots: Array<{
+ id: string;
+ sourceSegmentId: string;
+ semanticAnchor: string;
+ visualDescription: string;
+ compositionAndAction: string;
+ keyObjects: string[];
+ continuityReason: string;
+ motionReason: string;
+ startSeconds: number;
+ endSeconds: number;
+ durationSeconds: number;
+ }>;
+ };
+ expect(shotSpec.scriptArtifactId).toBe(scriptArtifact.id);
+ expect(shotSpec.audioTimingArtifactId).toBe(timingArtifact.id);
+ expect(shotSpec.timingSource).toBe('ffprobe_cumulative_tts_duration');
+ expect(shotSpec.shots).toHaveLength(script.segments.length);
+ expect(shotSpec.shots.every(shot => (
+ shot.semanticAnchor.trim().length > 0
+ && shot.visualDescription.trim().length > 0
+ && shot.compositionAndAction.trim().length > 0
+ && shot.keyObjects.length > 0
+ && shot.motionReason.trim().length > 0
+ ))).toBe(true);
+ expect(shotSpec.shots.map(shot => ({
+ segmentId: shot.sourceSegmentId,
+ startSeconds: shot.startSeconds,
+ endSeconds: shot.endSeconds,
+ durationSeconds: shot.durationSeconds
+ }))).toEqual(timing.segments.map(row => ({
+ segmentId: row.segmentId,
+ startSeconds: row.startSeconds,
+ endSeconds: row.endSeconds,
+ durationSeconds: row.durationSeconds
+ })));
+
+ const studentPath = join(stickmanRuntimeRoot, 'characters', 'student.png');
+ const studentSha256 = hashFile(studentPath);
+ const character = latestCurrentArtifact(completed, 'character_reference');
+ expect(character.metadata).toMatchObject({
+ assetId: 'stickman.character.student',
+ revision: 1
+ });
+ expect(character.sha256).toBe(studentSha256);
+ expect(hashFile(character.path!)).toBe(studentSha256);
+
+ const shotImages = completed.artifacts.filter(artifact => (
+ artifact.kind === 'shot_image' && artifact.status === 'completed'
+ ));
+ const shotImageByScope = new Map(shotImages.map(image => [image.scopeKey, image]));
+ expect(shotImages).toHaveLength(script.segments.length);
+ expect(new Set(shotImages.map(artifact => artifact.sha256)).size).toBe(shotImages.length);
+ for (const [shotIndex, shot] of shotSpec.shots.entries()) {
+ const image = shotImageByScope.get(shot.id)!;
+ const previousImage = shotIndex > 0 && shot.continuityReason.trim().length > 0
+ ? shotImageByScope.get(shotSpec.shots[shotIndex - 1]!.id)
+ : undefined;
+ const referenceImages = [{
+ role: 'character_identity',
+ sha256: studentSha256,
+ mimeType: 'image/png',
+ artifactId: character.id
+ }, ...(previousImage === undefined ? [] : [{
+ role: 'previous_shot',
+ sha256: previousImage.sha256,
+ mimeType: 'image/png',
+ artifactId: previousImage.id
+ }])];
+ const requestReferenceSha256 = createHash('sha256')
+ .update(referenceImages.map(reference => `${reference.role}:${reference.sha256}`).join('\n'))
+ .digest('hex');
+ const dimensions = await sharp(image.path!).metadata();
+ expect(dimensions.width).toBeTruthy();
+ expect(dimensions.height).toBeTruthy();
+ expect(Math.abs(dimensions.width! / dimensions.height! - 16 / 9)).toBeLessThan(0.03);
+ expect(image.metadata).toMatchObject({
+ characterReferenceArtifactId: character.id,
+ characterReferenceSha256: studentSha256,
+ requestReferenceSha256,
+ referenceImages,
+ ...(previousImage === undefined ? {} : {
+ previousShotArtifactId: previousImage.id,
+ previousShotSha256: previousImage.sha256
+ }),
+ characterAssetId: 'stickman.character.student',
+ styleAssetId: 'stickman.style.minimal-ink',
+ referenceImagePreparation: 'original-bytes-v2',
+ imagePromptContract: 'stickman-visual-profile-prompt-v2',
+ provider: imageConfig.provider,
+ model: imageConfig.model
+ });
+ }
+ const imageRequests = completed.providerRequests.filter(request => (
+ stageById.get(request.stageRunId)?.stageId === 'images'
+ ));
+ expect(imageRequests.length).toBeGreaterThanOrEqual(script.segments.length);
+ expect(imageRequests.every(request => request.status === 'succeeded')).toBe(true);
+ for (const [shotIndex, shot] of shotSpec.shots.entries()) {
+ const image = shotImageByScope.get(shot.id)!;
+ const previousImage = shotIndex > 0 && shot.continuityReason.trim().length > 0
+ ? shotImageByScope.get(shotSpec.shots[shotIndex - 1]!.id)
+ : undefined;
+ const referenceImages = [{
+ role: 'character_identity',
+ sha256: studentSha256,
+ mimeType: 'image/png',
+ artifactId: character.id
+ }, ...(previousImage === undefined ? [] : [{
+ role: 'previous_shot',
+ sha256: previousImage.sha256,
+ mimeType: 'image/png',
+ artifactId: previousImage.id
+ }])];
+ const requestReferenceSha256 = createHash('sha256')
+ .update(referenceImages.map(reference => `${reference.role}:${reference.sha256}`).join('\n'))
+ .digest('hex');
+ const expectedRequestHash = hashRequest({
+ prompt: String(image.metadata.prompt),
+ provider: imageConfig.provider,
+ size: '1536x1024',
+ quality: 'medium',
+ count: 1,
+ model: imageConfig.model,
+ characterReferenceSha256: studentSha256,
+ requestReferenceSha256,
+ characterReferenceMime: 'image/png',
+ referenceImages,
+ characterAsset: { assetId: 'stickman.character.student', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.minimal-ink', revision: 1 },
+ referenceImagePreparation: 'original-bytes-v2',
+ imagePromptContract: 'stickman-visual-profile-prompt-v2'
+ });
+ expect(imageRequests.some(request => (
+ request.scopeKey === image.scopeKey && request.requestHash === expectedRequestHash
+ ))).toBe(true);
+ }
+
+ const timelineArtifact = latestCurrentArtifact(completed, 'timeline_manifest');
+ const timeline = JSON.parse(readFileSync(timelineArtifact.path!, 'utf8')) as {
+ fps: number;
+ width: number;
+ height: number;
+ totalFrames: number;
+ shots: Array<{
+ shotId: string;
+ imageArtifactId: string;
+ audioArtifactId: string;
+ imageSha256: string;
+ audioSha256: string;
+ }>;
+ };
+ expect(timeline).toMatchObject({
+ width: 1280,
+ height: 720
+ });
+ expect(timeline).not.toHaveProperty('assets');
+ expect(timeline.shots).toHaveLength(script.segments.length);
+ for (const shot of timeline.shots) {
+ const image = shotImages.find(artifact => artifact.id === shot.imageArtifactId)!;
+ const audio = narrationArtifacts.find(artifact => artifact.id === shot.audioArtifactId)!;
+ expect(shot.imageSha256).toBe(image.sha256);
+ expect(shot.audioSha256).toBe(audio.sha256);
+ }
+ const narrationSubtitle = readFileSync(
+ latestCurrentArtifact(completed, 'narration_subtitle').path!,
+ 'utf8'
+ );
+ const narrationCues = parseSrtCues(narrationSubtitle);
+ expect(narrationCues).toHaveLength(script.segments.length);
+ for (const [index, cue] of narrationCues.entries()) {
+ expect(Math.abs(cue.startSeconds - timing.segments[index]!.startSeconds)).toBeLessThan(0.002);
+ expect(Math.abs(cue.endSeconds - timing.segments[index]!.endSeconds)).toBeLessThan(0.002);
+ expect(cue.text).toBe(script.segments[index]!.narration);
+ }
+
+ const mediaValidation = readArtifactJson(completed, 'media_validation') as {
+ ok: boolean;
+ validation: string;
+ cleanVideoArtifactId: string;
+ cleanVideoSha256: string;
+ sampledFrames: Array<{ sha256: string; width: number; height: number }>;
+ };
+ expect(mediaValidation).toMatchObject({
+ ok: true,
+ validation: 'ffprobe_and_three_frame_sampling'
+ });
+ expect(mediaValidation.sampledFrames).toHaveLength(3);
+ expect(mediaValidation.sampledFrames.every(frame => (
+ frame.width === 1280 && frame.height === 720 && /^[a-f0-9]{64}$/i.test(frame.sha256)
+ ))).toBe(true);
+
+ const deliveryKinds = [
+ 'clean_video',
+ 'narration_subtitle'
+ ] as const;
+ const deliveries = deliveryKinds.map(kind => requireDelivery(completed, kind));
+ for (const artifact of deliveries) {
+ expect(artifact.path, `${artifact.kind} 路径`).toBeTruthy();
+ expect(statSync(artifact.path!).size, `${artifact.kind} 文件大小`).toBeGreaterThan(0);
+ expect(hashFile(artifact.path!), `${artifact.kind} Artifact 哈希`).toBe(artifact.sha256);
+ }
+ const video = requireDelivery(completed, 'clean_video');
+ const probe = await probeMedia(ffprobePath, video.path!);
+ expect(probe.streams).toEqual(expect.arrayContaining([
+ expect.objectContaining({ codec_type: 'video', width: 1280, height: 720 }),
+ expect.objectContaining({ codec_type: 'audio' })
+ ]));
+ expect(probe.duration).toBeGreaterThan(0);
+ const subtitle = readFileSync(
+ requireDelivery(completed, 'narration_subtitle').path!,
+ 'utf8'
+ );
+ expect(subtitle).toMatch(/\d+\r?\n\d{2}:\d{2}:\d{2},\d{3} --> /);
+ expect(subtitle.split(/\r?\n/).filter(line => line.trim().length > 0).length)
+ .toBeGreaterThanOrEqual(4);
+
+ const manifestArtifact = latestCurrentArtifact(completed, 'delivery_manifest');
+ const manifest = JSON.parse(readFileSync(manifestArtifact.path!, 'utf8')) as {
+ packageStatus: string;
+ placeholderAssets: string[];
+ blockingChecks: string[];
+ files: Array<{
+ name: string;
+ relativePath: string;
+ sha256: string;
+ bytes: number;
+ sourceArtifactId: string;
+ }>;
+ };
+ expect(manifest).toMatchObject({
+ packageStatus: 'publishable',
+ placeholderAssets: [],
+ blockingChecks: []
+ });
+ expect(manifest.files).toHaveLength(2);
+ for (const file of manifest.files) {
+ const source = completed.artifacts.find(item => item.id === file.sourceArtifactId);
+ const delivery = deliveries.find(item => item.sha256 === file.sha256);
+ expect(source, `Manifest 来源 ${file.sourceArtifactId}`).toBeDefined();
+ expect(delivery, `Manifest 交付 ${file.name}`).toBeDefined();
+ expect(file.sha256).toBe(source!.sha256);
+ expect(file.bytes).toBe(statSync(source!.path!).size);
+ }
+
+ const summary = {
+ jobId,
+ evidenceRoot,
+ providerRequestCount: completed.providerRequests.length,
+ billingRequestCount: completed.providerRequests.filter(item => item.billingSideEffect).length,
+ deliveries: Object.fromEntries(deliveries.map(item => [item.kind, {
+ path: item.path,
+ sha256: item.sha256,
+ bytes: statSync(item.path!).size
+ }])),
+ manifest: {
+ path: manifestArtifact.path,
+ sha256: manifestArtifact.sha256,
+ files: manifest.files
+ }
+ };
+ writeFileSync(
+ join(evidenceRoot, 'stickman-real-pipeline-summary.json'),
+ `${JSON.stringify(summary, null, 2)}\n`,
+ 'utf8'
+ );
+ console.info(
+ `真实火柴人流水线证据:${evidenceRoot};Provider 请求 ${summary.providerRequestCount} 次,`
+ + `计费请求 ${summary.billingRequestCount} 次`
+ );
+ },
+ 50 * 60_000
+ );
+});
+
+function readPrivateConfig(path: string): CreatorServicesConfig {
+ const parsed = JSON.parse(readFileSync(path, 'utf8')) as unknown;
+ const candidate = isRecord(parsed) && 'config' in parsed ? parsed.config : parsed;
+ const config = parseCreatorServicesConfig(candidate);
+ if (
+ (config.llm.source === 'custom' && !config.llm.apiKey.trim())
+ ) {
+ throw new Error('真实火柴人 E2E 配置必须包含可用的真实 LLM');
+ }
+ configuredImage(config);
+ return config;
+}
+
+function configuredImage(config: CreatorServicesConfig): {
+ provider: 'openai' | 'gemini';
+ model: string;
+} {
+ const provider = config.image.provider;
+ if (provider !== 'openai' && provider !== 'gemini') {
+ throw new Error('真实火柴人 E2E 的生图服务必须支持角色参考图(OpenAI 或 Gemini)');
+ }
+ const providerConfig = config.image[provider];
+ if (!providerConfig.apiKey.trim() || !providerConfig.model.trim()) {
+ throw new Error(`真实火柴人 E2E 的 ${provider} 生图服务必须配置 API Key 和模型`);
+ }
+ return { provider, model: providerConfig.model.trim() };
+}
+
+function inMemoryConfigStore(config: CreatorServicesConfig) {
+ let current = structuredClone(config);
+ return {
+ async read() { return structuredClone(current); },
+ async write(next: CreatorServicesConfig) {
+ current = structuredClone(next);
+ return structuredClone(current);
+ },
+ async reset() {
+ current = structuredClone(config);
+ return structuredClone(current);
+ }
+ };
+}
+
+function configuredTts(config: CreatorServicesConfig): {
+ provider: 'openai' | 'aliyun' | 'minimax';
+ model: string;
+ voiceId: string;
+} {
+ const provider = config.tts.provider;
+ if (provider === 'edge-tts') {
+ throw new Error('真实火柴人 E2E 必须配置真实配音服务,不能使用本地 edge-tts');
+ }
+ const providerConfig = config.tts[provider];
+ if (!providerConfig.defaultVoiceId.trim()) {
+ throw new Error('真实火柴人 E2E 的配音服务必须配置默认音色');
+ }
+ return {
+ provider,
+ model: providerConfig.model,
+ voiceId: providerConfig.defaultVoiceId
+ };
+}
+
+async function approve(
+ jobId: string,
+ job: CreatorJob
+): Promise<void> {
+ const needsInput = readNeedsInput(job);
+ const response = await request('POST', `/creator/jobs/${jobId}/actions`, {
+ action: 'approve-script',
+ expectedRevision: job.revision,
+ input: {
+ artifactId: needsInput.artifactId,
+ revision: job.revision
+ }
+ });
+ expect(response.statusCode).toBe(200);
+}
+
+async function continueAfterArtifact(
+ jobId: string,
+ job: CreatorJob,
+ artifactKind: 'audio_timing' | 'visual_validation',
+ action: 'continue-after-audio' | 'continue-after-visuals'
+): Promise<void> {
+ const artifact = latestCurrentArtifact(job, artifactKind);
+ const response = await request('POST', `/creator/jobs/${jobId}/actions`, {
+ action,
+ expectedRevision: job.revision,
+ input: { artifactId: artifact.id, revision: job.revision }
+ });
+ expect(response.statusCode).toBe(200);
+}
+
+async function waitForReview(
+ jobId: string,
+ kind: 'approve-script'
+): Promise<CreatorJob> {
+ return waitForJob(jobId, job => (
+ job.status === 'needs_input' && readNeedsInput(job).kind === kind
+ ), 30 * 60_000);
+}
+
+async function waitForJob(
+ jobId: string,
+ predicate: (job: CreatorJob) => boolean,
+ timeoutMs: number
+): Promise<CreatorJob> {
+ const deadline = Date.now() + timeoutMs;
+ let latest: CreatorJob | undefined;
+ while (Date.now() < deadline) {
+ const response = await request('GET', `/creator/jobs/${jobId}`);
+ expect(response.statusCode).toBe(200);
+ latest = response.json().job as CreatorJob;
+ if (predicate(latest)) return latest;
+ if (latest.status === 'failed' || latest.status === 'canceled') {
+ const stage = latest.stages.at(-1);
+ throw new Error(
+ `真实火柴人流水线提前终止:${latest.status} ${stage?.stageId ?? ''} `
+ + `${stage?.errorCode ?? ''} ${stage?.errorMessage ?? ''}`
+ );
+ }
+ const needsInput = latest.state.needsInput;
+ if (latest.status === 'needs_input' && isRecord(needsInput)) {
+ throw new Error(
+ `真实火柴人流水线需要额外输入:${String(needsInput.code ?? needsInput.kind ?? 'unknown')} `
+ + `${String(needsInput.message ?? '')}`
+ );
+ }
+ if (
+ isRecord(needsInput)
+ && needsInput.code === 'creator_provider_resolution_required'
+ ) {
+ throw new Error(`真实 Provider 接受状态未知,需要人工处置:${JSON.stringify(needsInput)}`);
+ }
+ await new Promise(resolve => setTimeout(resolve, 1_000));
+ }
+ throw new Error(
+ `等待真实火柴人流水线超时:${jobId} ${latest?.status ?? 'unknown'} `
+ + `${latest?.stages.at(-1)?.stageId ?? ''}`
+ );
+}
+
+function readNeedsInput(job: CreatorJob): { kind: string; artifactId: string } {
+ const value = job.state.needsInput;
+ if (!isRecord(value) || typeof value.kind !== 'string' || typeof value.artifactId !== 'string') {
+ return { kind: '', artifactId: '' };
+ }
+ return { kind: value.kind, artifactId: value.artifactId };
+}
+
+function requireDelivery(job: CreatorJob, kind: string): CreatorArtifact {
+ const candidates = job.artifacts.filter(item => (
+ item.kind === kind
+ && item.status === 'completed'
+ && item.metadata.delivery === true
+ ));
+ if (candidates.length !== 1) {
+ throw new Error(`真实交付 ${kind} 数量错误:${candidates.length}`);
+ }
+ return candidates[0]!;
+}
+
+function latestCurrentArtifact(job: CreatorJob, kind: string): CreatorArtifact {
+ const artifact = latestCurrentArtifactOrUndefined(job, kind);
+ if (artifact?.path === null || artifact === undefined) {
+ throw new Error(`缺少当前真实工件:${kind}`);
+ }
+ return artifact;
+}
+
+function latestCurrentArtifactOrUndefined(
+ job: CreatorJob,
+ kind: string
+): CreatorArtifact | undefined {
+ return [...job.artifacts].reverse().find(item => (
+ item.kind === kind && item.status === 'completed'
+ ));
+}
+
+function readArtifactJson(job: CreatorJob, kind: string): unknown {
+ return JSON.parse(readFileSync(latestCurrentArtifact(job, kind).path!, 'utf8')) as unknown;
+}
+
+async function probeMedia(ffprobePath: string, path: string): Promise<{
+ streams: Array<{ codec_type?: string; width?: number; height?: number }>;
+ duration: number;
+}> {
+ const value = JSON.parse((await execFileAsync(ffprobePath, [
+ '-v', 'error',
+ '-show_entries', 'stream=codec_type,width,height:format=duration',
+ '-of', 'json',
+ path
+ ], { windowsHide: true })).stdout) as {
+ streams?: Array<{ codec_type?: string; width?: number; height?: number }>;
+ format?: { duration?: string };
+ };
+ return {
+ streams: value.streams ?? [],
+ duration: Number(value.format?.duration ?? 0)
+ };
+}
+
+function parseSrtCues(content: string): Array<{
+ startSeconds: number;
+ endSeconds: number;
+ text: string;
+}> {
+ return content.trim().split(/\r?\n\r?\n/).map(block => {
+ const lines = block.split(/\r?\n/);
+ const match = /^(\d{2}):(\d{2}):(\d{2}),(\d{3}) --> (\d{2}):(\d{2}):(\d{2}),(\d{3})$/.exec(lines[1] ?? '');
+ if (match === null) throw new Error(`无效的旁白 SRT cue:${block}`);
+ return {
+ startSeconds: srtTime(match.slice(1, 5).map(Number)),
+ endSeconds: srtTime(match.slice(5, 9).map(Number)),
+ text: lines.slice(2).join('\n').trim()
+ };
+ });
+}
+
+function srtTime(parts: number[]): number {
+ return parts[0]! * 3600 + parts[1]! * 60 + parts[2]! + parts[3]! / 1000;
+}
+
+function hashRequest(value: Record<string, unknown>): string {
+ return createHash('sha256').update(JSON.stringify(sortJson(value))).digest('hex');
+}
+
+function sortJson(value: unknown): unknown {
+ if (Array.isArray(value)) return value.map(sortJson);
+ if (value === null || typeof value !== 'object') return value;
+ return Object.fromEntries(Object.entries(value as Record<string, unknown>)
+ .sort(([left], [right]) => left.localeCompare(right))
+ .map(([key, entry]) => [key, sortJson(entry)]));
+}
+
+function findRuntimeExecutable(runtimeRoot: string, pattern: RegExp): string {
+ const manifest = JSON.parse(readFileSync(join(runtimeRoot, 'manifest.json'), 'utf8')) as {
+ resources: Array<{ path: string; kind: string }>;
+ };
+ const resource = manifest.resources.find(item => item.kind === 'executable' && pattern.test(item.path));
+ if (resource === undefined) throw new Error(`Runtime 缺少可执行文件:${pattern}`);
+ return resolve(runtimeRoot, resource.path);
+}
+
+function createEvidenceRoot(): string {
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
+ const root = resolve(
+ process.env.OPENCREATOR_STICKMAN_E2E_EVIDENCE_DIR
+ ?? join(repoRoot, 'test-results', 'stickman-real-pipeline', timestamp)
+ );
+ mkdirSync(root, { recursive: true });
+ return root;
+}
+
+function hashFile(path: string): string {
+ return createHash('sha256').update(readFileSync(path)).digest('hex');
+}
+
+function isRecord(value: unknown): value is Record<string, unknown> {
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
+}
+
+function restoreEnvironment(name: string, value: string | undefined): void {
+ if (value === undefined) delete process.env[name];
+ else process.env[name] = value;
+}
+
+async function request(
+ method: 'GET' | 'POST',
+ url: string,
+ payload?: object
+): Promise<{ statusCode: number; json(): any }> {
+ return await server!.inject({
+ method,
+ url,
+ headers: { authorization: 'Bearer stickman-real-e2e' },
+ ...(payload === undefined ? {} : { payload })
+ }) as unknown as { statusCode: number; json(): any };
+}
diff --git a/apps/daemon/test/integration/creator-stickman-remotion-smoke.test.ts b/apps/daemon/test/integration/creator-stickman-remotion-smoke.test.ts
new file mode 100644
index 00000000..b02aa071
--- /dev/null
+++ b/apps/daemon/test/integration/creator-stickman-remotion-smoke.test.ts
@@ -0,0 +1,140 @@
+import { execFile } from 'node:child_process';
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { dirname, join, resolve } from 'node:path';
+import { promisify } from 'node:util';
+import sharp from 'sharp';
+import { afterAll, describe, expect, it } from 'vitest';
+import { createStickmanRemotionExecutor } from '../../src/creator/stickman/remotion-executor.js';
+
+const runtimeRoot = process.env.OPENCREATOR_STICKMAN_RUNTIME_ROOT;
+const ffmpegPath = process.env.OPENCREATOR_FFMPEG_PATH;
+const ffprobePath = process.env.OPENCREATOR_FFPROBE_PATH;
+const enabled = Boolean(runtimeRoot && ffmpegPath && ffprobePath);
+const execFileAsync = promisify(execFile);
+let tempRoot = '';
+
+afterAll(() => {
+ if (tempRoot) rmSync(tempRoot, { recursive: true, force: true });
+});
+
+describe.runIf(enabled)('stickman Remotion packaged runtime smoke', () => {
+ it('renders a nonblank fixed-frame video with packaged browser and fonts', async () => {
+ tempRoot = mkdtempSync(join(tmpdir(), 'creator-stickman-render-smoke-'));
+ const jobRoot = join(tempRoot, 'jobs', 'job-1');
+ const workdir = join(jobRoot, 'stage-render');
+ const inputDir = join(jobRoot, 'inputs');
+ const imageOne = join(inputDir, 'shot-one.png');
+ const imageTwo = join(inputDir, 'shot-two.png');
+ const narrationOne = join(inputDir, 'narration-one.mp3');
+ const narrationTwo = join(inputDir, 'narration-two.mp3');
+ const bgm = join(inputDir, 'background.mp3');
+ const logo = join(inputDir, 'logo.jpg');
+ const timelinePath = join(inputDir, 'timeline.json');
+ mkdirSync(workdir, { recursive: true });
+ mkdirSync(inputDir, { recursive: true });
+ await Promise.all([
+ renderFixtureImage(imageOne, '#f7f7f5', '#111827', 260),
+ renderFixtureImage(imageTwo, '#dff4ff', '#0f766e', 880),
+ renderFixtureImage(logo, '#ffffff', '#111827', 640)
+ ]);
+ await execFileAsync(ffmpegPath!, [
+ '-y', '-f', 'lavfi', '-i', 'sine=frequency=440:duration=1',
+ '-c:a', 'libmp3lame', '-q:a', '4', narrationOne
+ ], { windowsHide: true });
+ await execFileAsync(ffmpegPath!, [
+ '-y', '-f', 'lavfi', '-i', 'sine=frequency=880:duration=1',
+ '-c:a', 'libmp3lame', '-q:a', '4', narrationTwo
+ ], { windowsHide: true });
+ await execFileAsync(ffmpegPath!, [
+ '-y', '-f', 'lavfi', '-i', 'sine=frequency=110:duration=2',
+ '-c:a', 'libmp3lame', '-q:a', '4', bgm
+ ], { windowsHide: true });
+ writeFileSync(timelinePath, `${JSON.stringify({
+ fps: 30,
+ width: 1280,
+ height: 720,
+ totalFrames: 60,
+ assets: {
+ logoArtifactId: 'logo-1',
+ logoSha256: '3'.repeat(64),
+ logoPath: logo,
+ bgmArtifactId: 'bgm-1',
+ bgmSha256: '4'.repeat(64),
+ bgmPath: bgm,
+ bgmVolume: 0.12,
+ bgmLoop: true
+ },
+ shots: [
+ fixtureShot('shot-01', 0, 30, imageOne, narrationOne, 'push-in'),
+ fixtureShot('shot-02', 30, 60, imageTwo, narrationTwo, 'pan-left')
+ ]
+ }, null, 2)}\n`);
+
+ const manifestBefore = readFileSync(join(runtimeRoot!, 'manifest.json'), 'utf8');
+ const executor = createStickmanRemotionExecutor({
+ runtimeRoot: runtimeRoot!,
+ ffprobePath: ffprobePath!,
+ workerEntrypoint: resolve('dist/creator/stickman/remotion-worker.js')
+ });
+ const result = await executor.run({
+ stageRun: { id: 'stage-render', stageId: 'render-clean' },
+ job: { id: 'job-1' },
+ inputArtifacts: [{
+ id: 'timeline-1',
+ kind: 'timeline_manifest',
+ status: 'completed',
+ path: timelinePath
+ }],
+ workdir,
+ signal: new AbortController().signal,
+ reportProgress() {}
+ } as never);
+
+ const outputPath = result.outputs[0]!.path!;
+ expect(result.outputs[0]).toMatchObject({ kind: 'clean_video', status: 'completed' });
+ for (const [index, seconds] of [0.2, 1, 1.8].entries()) {
+ const framePath = join(tempRoot, `frame-${index}.png`);
+ await execFileAsync(ffmpegPath!, [
+ '-y', '-ss', String(seconds), '-i', outputPath, '-frames:v', '1', framePath
+ ], { windowsHide: true });
+ const stats = await sharp(framePath).stats();
+ expect(stats.channels.slice(0, 3).reduce((sum, channel) => sum + channel.stdev, 0)).toBeGreaterThan(20);
+ }
+ expect(readFileSync(join(runtimeRoot!, 'manifest.json'), 'utf8')).toBe(manifestBefore);
+ }, 120_000);
+});
+
+async function renderFixtureImage(path: string, background: string, stroke: string, x: number): Promise<void> {
+ const svg = Buffer.from(`
+ <svg xmlns="http://www.w3.org/2000/svg" width="1280" height="720">
+ <rect width="1280" height="720" fill="${background}"/>
+ <circle cx="${x}" cy="210" r="74" fill="none" stroke="${stroke}" stroke-width="22"/>
+ <path d="M ${x} 284 L ${x} 500 M ${x} 350 L ${x - 120} 430 M ${x} 350 L ${x + 120} 430 M ${x} 500 L ${x - 110} 640 M ${x} 500 L ${x + 110} 640" fill="none" stroke="${stroke}" stroke-width="24" stroke-linecap="round"/>
+ <rect x="80" y="70" width="1120" height="580" fill="none" stroke="${stroke}" stroke-width="8" stroke-dasharray="18 12"/>
+ </svg>
+ `);
+ await sharp(svg).png().toFile(path);
+}
+
+function fixtureShot(
+ shotId: string,
+ startFrame: number,
+ endFrame: number,
+ imagePath: string,
+ audioPath: string,
+ motion: string
+) {
+ return {
+ shotId,
+ startFrame,
+ endFrame,
+ imageArtifactId: `${shotId}-image`,
+ audioArtifactId: 'narration-1',
+ motion,
+ imageSha256: '1'.repeat(64),
+ audioSha256: '2'.repeat(64),
+ imagePath,
+ audioPath
+ };
+}
diff --git a/apps/daemon/test/integration/image-generation-api.test.ts b/apps/daemon/test/integration/image-generation-api.test.ts
index a70dd210..4cdcba95 100644
--- a/apps/daemon/test/integration/image-generation-api.test.ts
+++ b/apps/daemon/test/integration/image-generation-api.test.ts
@@ -6,6 +6,7 @@ import { join } from 'node:path';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { registerImageGenerationRoutes } from '../../src/api/routes.image-generation.js';
import type { CreatorServicesConfigStore } from '../../src/creator-services/config-store.js';
+import { generateImageContents } from '../../src/image-generation/provider.js';
import { createImageGenerationService } from '../../src/image-generation/service.js';
describe('image generation API', () => {
@@ -101,6 +102,122 @@ describe('image generation API', () => {
expect(JSON.parse(String(fetchImpl.mock.calls[0]?.[1]?.body))).not.toHaveProperty('quality');
});
+ it('keeps configured OpenAI endpoints on the OpenAI edit protocol', async () => {
+ const config = createDefaultCreatorServicesConfig();
+ config.image.openai.apiKey = 'openai-compatible-test';
+ config.image.openai.baseUrl = 'https://forward.krillinai.com/v1/images/generations';
+ config.image.openai.model = 'gpt-image-2';
+ const image = Buffer.concat([
+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
+ Buffer.from('openai-compatible-image')
+ ]);
+ const reference = Buffer.concat([
+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
+ Buffer.from('character-reference')
+ ]);
+ const styleReference = Buffer.concat([
+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
+ Buffer.from('style-reference')
+ ]);
+ const fetchImpl = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) => new Response(JSON.stringify({
+ data: [{ b64_json: image.toString('base64') }]
+ }), { status: 200, headers: { 'Content-Type': 'application/json' } }));
+
+ const result = await generateImageContents({
+ prompt: 'Keep the selected character in a new scene',
+ provider: 'openai',
+ size: '1536x1024',
+ quality: 'medium',
+ count: 1
+ }, config, {
+ fetchImpl: fetchImpl as typeof fetch,
+ referenceImages: [
+ { content: reference, mime: 'image/png' },
+ { content: styleReference, mime: 'image/png' }
+ ]
+ });
+
+ expect(result).toMatchObject({ model: 'gpt-image-2' });
+ expect(result.contents[0]?.content).toEqual(image);
+ expect(String(fetchImpl.mock.calls[0]?.[0]))
+ .toBe('https://forward.krillinai.com/v1/images/edits');
+ expect(fetchImpl.mock.calls[0]?.[1]?.headers).toMatchObject({
+ Authorization: 'Bearer openai-compatible-test',
+ 'Content-Type': expect.stringContaining('multipart/form-data; boundary=')
+ });
+ const body = Buffer.from(fetchImpl.mock.calls[0]?.[1]?.body as ArrayBuffer).toString('latin1');
+ expect(body).toContain('gpt-image-2');
+ expect(body.match(/name="image\[\]"/g)).toHaveLength(2);
+ expect(body).not.toContain('name="async"');
+ expect(body.indexOf('character-reference')).toBeLessThan(body.indexOf('style-reference'));
+ });
+
+ it('sends multiple references as ordered image array fields to OpenAI edits', async () => {
+ const config = createDefaultCreatorServicesConfig();
+ config.image.openai.apiKey = 'openai-test';
+ config.image.openai.baseUrl = 'https://images.example.test/v1';
+ const image = Buffer.concat([
+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
+ Buffer.from('generated')
+ ]);
+ const character = Buffer.from('character-reference');
+ const style = Buffer.from('style-reference');
+ const fetchImpl = vi.fn(async (_url: RequestInfo | URL, _init?: RequestInit) => new Response(JSON.stringify({
+ data: [{ b64_json: image.toString('base64') }]
+ }), { status: 200 }));
+
+ await generateImageContents({
+ prompt: 'Use character identity then visual style',
+ provider: 'openai',
+ size: '1536x1024',
+ quality: 'medium',
+ count: 1
+ }, config, {
+ fetchImpl: fetchImpl as typeof fetch,
+ referenceImages: [
+ { content: character, mime: 'image/png' },
+ { content: style, mime: 'image/jpeg' }
+ ]
+ });
+
+ expect(String(fetchImpl.mock.calls[0]?.[0]))
+ .toBe('https://images.example.test/v1/images/edits');
+ const body = Buffer.from(fetchImpl.mock.calls[0]?.[1]?.body as ArrayBuffer).toString('latin1');
+ expect(body.match(/name="image\[\]"/g)).toHaveLength(2);
+ expect(body.indexOf('character-reference')).toBeLessThan(body.indexOf('style-reference'));
+ });
+
+ it('sends multiple references as ordered Gemini inline data parts', async () => {
+ const config = createDefaultCreatorServicesConfig();
+ config.image.gemini.apiKey = 'gemini-test';
+ config.image.gemini.baseUrl = 'https://gemini.example.test/v1beta';
+ const image = Buffer.concat([
+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
+ Buffer.from('gemini-result')
+ ]);
+ const references = [Buffer.from('character'), Buffer.from('style')];
+ const fetchImpl = vi.fn(async (_url: RequestInfo | URL, _init?: RequestInit) => new Response(JSON.stringify({
+ candidates: [{ content: { parts: [{ inlineData: { mimeType: 'image/png', data: image.toString('base64') } }] } }]
+ }), { status: 200 }));
+
+ await generateImageContents({
+ prompt: 'Use ordered references',
+ provider: 'gemini',
+ size: '1536x1024',
+ quality: 'medium',
+ count: 1
+ }, config, {
+ fetchImpl: fetchImpl as typeof fetch,
+ referenceImages: references.map(content => ({ content, mime: 'image/png' as const }))
+ });
+
+ const body = JSON.parse(String(fetchImpl.mock.calls[0]?.[1]?.body));
+ expect(body.contents[0].parts.slice(0, 2)).toEqual(references.map(content => ({
+ inlineData: { mimeType: 'image/png', data: content.toString('base64') }
+ })));
+ expect(body.contents[0].parts[2]).toEqual({ text: 'Use ordered references' });
+ });
+
it('extracts inline image data from Gemini', async () => {
const config = createDefaultCreatorServicesConfig();
config.image.gemini.apiKey = 'gemini-test';
diff --git a/apps/daemon/test/unit/creator-agent-context.test.ts b/apps/daemon/test/unit/creator-agent-context.test.ts
index 0910da00..116ffaf9 100644
--- a/apps/daemon/test/unit/creator-agent-context.test.ts
+++ b/apps/daemon/test/unit/creator-agent-context.test.ts
@@ -97,6 +97,8 @@ function job(): CreatorJob {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
percent: 100,
krillinStatus: 'succeeded',
@@ -118,6 +120,8 @@ function job(): CreatorJob {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {},
errorCode: null,
errorMessage: null,
@@ -132,6 +136,9 @@ function job(): CreatorJob {
version: 1,
status: 'completed',
path: 'D:\\private\\jobs\\translated.mp4',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
fileName: 'translated.mp4',
@@ -142,6 +149,7 @@ function job(): CreatorJob {
},
createdAt
}],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
diff --git a/apps/daemon/test/unit/creator-artifact-import.test.ts b/apps/daemon/test/unit/creator-artifact-import.test.ts
index c1d4ce09..c666ee85 100644
--- a/apps/daemon/test/unit/creator-artifact-import.test.ts
+++ b/apps/daemon/test/unit/creator-artifact-import.test.ts
@@ -34,6 +34,9 @@ describe('creator artifact import', () => {
kind: 'source_video',
status: 'completed',
path: sourcePath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
fileName: 'Creator Demo.mp4',
@@ -101,6 +104,9 @@ describe('creator artifact import', () => {
kind: 'source_video',
status: 'completed',
path: sourcePath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { fileName: 'source.mp4' }
});
@@ -134,6 +140,9 @@ describe('creator artifact import', () => {
kind: 'source_video',
status: 'completed',
path: sourcePath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { fileName: 'source.mp4' }
});
diff --git a/apps/daemon/test/unit/creator-command-dispatcher.test.ts b/apps/daemon/test/unit/creator-command-dispatcher.test.ts
index 5b90bbcb..4ec6b6e0 100644
--- a/apps/daemon/test/unit/creator-command-dispatcher.test.ts
+++ b/apps/daemon/test/unit/creator-command-dispatcher.test.ts
@@ -237,6 +237,9 @@ function setupDownload() {
kind: 'download_probe',
status: 'completed',
path: join(tempDir, 'probe.json'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
id: 'multi-download',
diff --git a/apps/daemon/test/unit/creator-cover-executor.test.ts b/apps/daemon/test/unit/creator-cover-executor.test.ts
index 6ead73ae..9374217d 100644
--- a/apps/daemon/test/unit/creator-cover-executor.test.ts
+++ b/apps/daemon/test/unit/creator-cover-executor.test.ts
@@ -86,6 +86,7 @@ function stageInput(
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -101,6 +102,8 @@ function stageInput(
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'cover-analysis-test',
+ scopeKey: null,
+ inputFingerprint: null,
progress: { workflow: true },
errorCode: null,
errorMessage: null,
diff --git a/apps/daemon/test/unit/creator-cover-workflow.test.ts b/apps/daemon/test/unit/creator-cover-workflow.test.ts
index e88bb13e..804f4934 100644
--- a/apps/daemon/test/unit/creator-cover-workflow.test.ts
+++ b/apps/daemon/test/unit/creator-cover-workflow.test.ts
@@ -93,6 +93,9 @@ describe('cover workflow', () => {
kind: 'source_keyframe',
status: 'completed',
path: join(tempDir, 'youtube-thumbnail.jpg'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {}
});
@@ -150,6 +153,9 @@ describe('cover workflow', () => {
kind: 'source_keyframe',
status: 'completed',
path: join(tempDir, 'youtube-thumbnail.jpg'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {}
});
@@ -182,6 +188,9 @@ describe('cover workflow', () => {
kind: 'reference_image',
status: 'completed',
path: join(tempDir, 'reference.png'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {}
});
diff --git a/apps/daemon/test/unit/creator-download-executor.test.ts b/apps/daemon/test/unit/creator-download-executor.test.ts
index bb69224a..634fb08b 100644
--- a/apps/daemon/test/unit/creator-download-executor.test.ts
+++ b/apps/daemon/test/unit/creator-download-executor.test.ts
@@ -443,6 +443,52 @@ describe('creator download executor', () => {
})]);
});
+ it('downloads a YouTube source for stickman video without a probe artifact', async () => {
+ const binaries = await fakeBinaries();
+ const workdir = join(tempDir, 'stickman-source-work');
+ await mkdir(workdir, { recursive: true });
+ const reportProgress = vi.fn();
+ const executor = createDownloadExecutor(binaries);
+
+ const result = await executor.run(stageInput({
+ workdir,
+ stageId: 'acquire-source',
+ state: {
+ sourceUrl: 'https://www.youtube.com/watch?v=stickman-demo'
+ },
+ reportProgress
+ }));
+
+ const args = JSON.parse(
+ await readFile(join(workdir, 'args.json'), 'utf8')
+ ) as string[];
+ expect(args).toEqual(expect.arrayContaining([
+ '--proxy',
+ 'http://127.0.0.1:7897',
+ '--ffmpeg-location',
+ binaries.ffmpegPath,
+ '-f',
+ 'bestvideo+bestaudio/best',
+ '--merge-output-format',
+ 'mp4'
+ ]));
+ expect(result.outputs).toEqual([expect.objectContaining({
+ kind: 'source_video',
+ status: 'completed',
+ metadata: expect.objectContaining({
+ source: 'stickman-video',
+ sourceUrl: 'https://www.youtube.com/watch?v=stickman-demo',
+ mimeType: 'video/mp4',
+ playbackCompatible: true
+ })
+ })]);
+ expect(reportProgress).toHaveBeenLastCalledWith(expect.objectContaining({
+ status: 'succeeded',
+ phase: 'completed',
+ percent: 100
+ }));
+ });
+
it('rejects a stale probe after the source URL changes', async () => {
const binaries = await fakeBinaries();
const workdir = join(tempDir, 'stale-work');
@@ -736,15 +782,17 @@ async function fakeBinaries(input?: {
ytDlpPrefixArgs?: string[];
ytDlpEnv?: NodeJS.ProcessEnv;
ffmpegPath: string;
+ ffmpegPrefixArgs?: string[];
ffprobePath: string;
+ ffprobePrefixArgs?: string[];
}> {
tempDir = await mkdtemp(join(tmpdir(), 'creator-download-executor-'));
- const ytDlpPath = join(tempDir, 'yt-dlp');
- const ffmpegPath = join(tempDir, 'ffmpeg');
- const ffprobePath = join(tempDir, 'ffprobe');
+ const ytDlpScriptPath = join(tempDir, 'yt-dlp.mjs');
+ const ffmpegScriptPath = join(tempDir, 'ffmpeg.mjs');
+ const ffprobeScriptPath = join(tempDir, 'ffprobe.mjs');
const failure = input?.failure;
const videoCodec = input?.videoCodec ?? 'h264';
- await writeExecutable(ytDlpPath, `#!/usr/bin/env node
+ await writeExecutable(ytDlpScriptPath, `#!/usr/bin/env node
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
const args = process.argv.slice(2);
@@ -783,7 +831,7 @@ if (args.includes('--progress')) {
process.stderr.write(audio ? '[ExtractAudio] Destination\\n' : '[Merger] Merging formats\\n');
process.stdout.write(output + '\\n');
`);
- await writeExecutable(ffmpegPath, `#!/usr/bin/env node
+ await writeExecutable(ffmpegScriptPath, `#!/usr/bin/env node
import { copyFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
const args = process.argv.slice(2);
@@ -792,7 +840,7 @@ const inputIndex = args.indexOf('-i');
copyFileSync(args[inputIndex + 1], args.at(-1));
process.stderr.write('out_time=00:00:06.000000\\n');
`);
- await writeExecutable(ffprobePath, `#!/usr/bin/env node
+ await writeExecutable(ffprobeScriptPath, `#!/usr/bin/env node
const path = process.argv.at(-1) ?? '';
const audio = path.endsWith('.mp3');
const compatible = path.endsWith('.playable.mp4');
@@ -816,17 +864,22 @@ process.stdout.write(JSON.stringify({
config.proxy = 'http://127.0.0.1:7897';
return {
configStore: { read: async () => config },
- ytDlpPath: input?.portableRuntime ? process.execPath : ytDlpPath,
+ ytDlpPath: process.execPath,
+ ytDlpPrefixArgs: [
+ ytDlpScriptPath,
+ ...(input?.portableRuntime ? ['--portable-runtime'] : [])
+ ],
...(input?.portableRuntime
? {
- ytDlpPrefixArgs: [ytDlpPath, '--portable-runtime'],
ytDlpEnv: {
SSL_CERT_FILE: '/runtime/cacert.pem'
}
}
: {}),
- ffmpegPath,
- ffprobePath
+ ffmpegPath: process.execPath,
+ ffmpegPrefixArgs: [ffmpegScriptPath],
+ ffprobePath: process.execPath,
+ ffprobePrefixArgs: [ffprobeScriptPath]
};
}
@@ -848,6 +901,9 @@ async function writeProbeArtifact(
version: 1,
status: 'completed',
path,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {},
createdAt: '2026-08-30T00:00:00.000Z'
@@ -856,7 +912,7 @@ async function writeProbeArtifact(
function stageInput(input: {
workdir: string;
- stageId: 'probe' | 'download';
+ stageId: 'probe' | 'download' | 'acquire-source';
state: CreatorJob['state'];
progress?: CreatorStageRun['progress'];
inputArtifacts?: CreatorArtifact[];
@@ -866,7 +922,9 @@ function stageInput(input: {
const job: CreatorJob = {
id: 'download_job',
projectId: 'project_1',
- templateId: 'video-download',
+ templateId: input.stageId === 'acquire-source'
+ ? 'stickman-video'
+ : 'video-download',
templateVersion: 2,
status: 'running',
revision: 1,
@@ -874,6 +932,7 @@ function stageInput(input: {
agentThreadId: null,
stages: [],
artifacts: input.inputArtifacts ?? [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -889,6 +948,8 @@ function stageInput(input: {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: input.progress ?? {},
errorCode: null,
errorMessage: null,
diff --git a/apps/daemon/test/unit/creator-image-executor.test.ts b/apps/daemon/test/unit/creator-image-executor.test.ts
index f1d51013..8541cf3c 100644
--- a/apps/daemon/test/unit/creator-image-executor.test.ts
+++ b/apps/daemon/test/unit/creator-image-executor.test.ts
@@ -189,6 +189,9 @@ describe('creator image executor', () => {
version: 1,
status: 'completed',
path: keyframePath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {},
createdAt: '2026-08-26T00:00:00.000Z'
@@ -200,6 +203,9 @@ describe('creator image executor', () => {
version: 1,
status: 'completed',
path: referencePath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {},
createdAt: '2026-08-26T00:00:01.000Z'
@@ -260,6 +266,9 @@ describe('creator image executor', () => {
version: 1,
status: 'completed',
path: join(tempDir, 'cover-brief.json'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
headline: '真正拉开差距的习惯',
@@ -276,6 +285,9 @@ describe('creator image executor', () => {
version: 1,
status: 'completed',
path: keyframePath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {},
createdAt: '2026-08-26T00:00:01.000Z'
@@ -343,6 +355,7 @@ function stageInput(
agentThreadId: null,
stages: [],
artifacts: jobPatch.artifacts ?? [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -358,6 +371,8 @@ function stageInput(
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {},
errorCode: null,
errorMessage: null,
diff --git a/apps/daemon/test/unit/creator-krillin-capabilities.test.ts b/apps/daemon/test/unit/creator-krillin-capabilities.test.ts
index c3d74293..cdcee1c0 100644
--- a/apps/daemon/test/unit/creator-krillin-capabilities.test.ts
+++ b/apps/daemon/test/unit/creator-krillin-capabilities.test.ts
@@ -23,7 +23,7 @@ describe('KrillinAI transcription capabilities', () => {
]));
});
- it('does not advertise local providers without a controlled installer', () => {
+ it('offers Whisper.cpp on Windows x64 while keeping unsupported local providers disabled', () => {
const capabilities = createKrillinCreatorServicesCapabilities('win32', 'x64');
const localProviders = capabilities.transcription.providers.filter(
provider => provider.kind === 'local'
@@ -33,17 +33,30 @@ describe('KrillinAI transcription capabilities', () => {
expect(localProviders).toEqual(expect.arrayContaining([
expect.objectContaining({
provider: 'faster-whisper',
+ available: false,
unavailableReason: 'installer_unavailable'
}),
expect.objectContaining({
provider: 'whisper.cpp',
available: true,
- gpuAcceleration: false
+ gpuAcceleration: false,
+ models: ['tiny', 'medium', 'large-v2']
}),
expect.objectContaining({
provider: 'whisperkit',
+ available: false,
unavailableReason: 'unsupported_platform'
})
]));
});
+
+ it('keeps Whisper.cpp unavailable on unsupported Windows architectures', () => {
+ const provider = createKrillinCreatorServicesCapabilities('win32', 'arm64')
+ .transcription.providers.find(candidate => candidate.provider === 'whisper.cpp');
+
+ expect(provider).toMatchObject({
+ available: false,
+ unavailableReason: 'unsupported_platform'
+ });
+ });
});
diff --git a/apps/daemon/test/unit/creator-krillin-cli-protocol.test.ts b/apps/daemon/test/unit/creator-krillin-cli-protocol.test.ts
index 7164c220..985e8e9e 100644
--- a/apps/daemon/test/unit/creator-krillin-cli-protocol.test.ts
+++ b/apps/daemon/test/unit/creator-krillin-cli-protocol.test.ts
@@ -8,7 +8,19 @@ import {
} from '../../src/creator/krillin/cli-runner.js';
describe('KrillinAI CLI protocol', () => {
- it('marks materialized videos as local CLI inputs', () => {
+ it('uses the original YouTube URL for platform captions and local media otherwise', () => {
+ expect(resolveKrillinCliSource([
+ { id: 'source-1', kind: 'source_video', path: 'D:\\media\\source.webm' }
+ ], {
+ sourceUrl: 'https://www.youtube.com/watch?v=demo',
+ captionSource: 'any'
+ })).toBe('https://www.youtube.com/watch?v=demo');
+ expect(resolveKrillinCliSource([
+ { id: 'source-1', kind: 'source_video', path: 'D:\\media\\source.webm' }
+ ], {
+ sourceUrl: 'https://www.youtube.com/watch?v=demo',
+ captionSource: 'whisper'
+ })).toBe('local:D:\\media\\source.webm');
expect(resolveKrillinCliSource([
{ id: 'source-1', kind: 'source_video', path: 'D:\\media\\source.webm' }
], { sourceUrl: 'https://example.com/video' })).toBe('local:D:\\media\\source.webm');
@@ -41,7 +53,9 @@ describe('KrillinAI CLI protocol', () => {
...inherited,
KRILLINAI_RESOURCE_ROOT: 'D:\\resources',
KRILLINAI_OFFLINE_DEPENDENCIES: '1',
- OPENCREATOR_KRILLINAI_CLI: '1'
+ OPENCREATOR_KRILLINAI_CLI: '1',
+ KRILLINAI_YT_DLP_EXECUTABLE: ytDlpExecutable,
+ KRILLINAI_YT_DLP_PREFIX_ARGS: JSON.stringify(['-I', '-B', '/runtime/yt-dlp'])
});
expect(String(env.PATH)).toContain('D:\\dependencies\\bin');
expect(String(env.PATH)).toContain(dirname(ytDlpExecutable));
diff --git a/apps/daemon/test/unit/creator-krillin-dependency-loader.test.ts b/apps/daemon/test/unit/creator-krillin-dependency-loader.test.ts
index a086d4a4..9ec8679b 100644
--- a/apps/daemon/test/unit/creator-krillin-dependency-loader.test.ts
+++ b/apps/daemon/test/unit/creator-krillin-dependency-loader.test.ts
@@ -3,30 +3,6 @@ import { describe, expect, it } from 'vitest';
import { createKrillinDependencyLoader } from '../../src/creator/krillin/dependency-loader.js';
describe('KrillinAI on-demand dependency loader', () => {
- it('prepares the selected Windows Whisper.cpp model and serializes concurrent installs', async () => {
- const models: string[] = [];
- const phases: unknown[] = [];
- let active = 0;
- const loader = createKrillinDependencyLoader({
- root: '/tmp/whispercpp', platform: 'win32', arch: 'x64',
- whisperCppInstaller: { async ensure(input) {
- expect(active++).toBe(0);
- models.push(input.model);
- input.onPhase('cli');
- await Promise.resolve();
- input.onPhase('model');
- active--;
- } }
- });
- const config = createDefaultCreatorServicesConfig();
- config.transcription.provider = 'whisper.cpp';
- config.transcription.whisperCpp.model = 'tiny';
- const run = () => loader.ensure({ config, signal: new AbortController().signal, reportProgress: value => phases.push(value) });
- await Promise.all([run(), run()]);
- expect(models).toEqual(['tiny', 'tiny']);
- expect(phases).toContainEqual(expect.objectContaining({ dependency: 'whisper.cpp', dependencyPhase: 'model' }));
- });
-
it('does not enable Windows x64 Whisper.cpp on ARM64', async () => {
const loader = createKrillinDependencyLoader({ root: '/tmp/whispercpp', platform: 'win32', arch: 'arm64' });
const config = createDefaultCreatorServicesConfig();
@@ -146,4 +122,73 @@ describe('KrillinAI on-demand dependency loader', () => {
})).rejects.toMatchObject({ code: 'dependency_not_packaged' });
expect(installs).toBe(0);
});
+
+ it('prepares each selected Whisper.cpp model once on Windows x64', async () => {
+ const installed = new Set<string>();
+ const installs: string[] = [];
+ const phases: string[] = [];
+ const loader = createKrillinDependencyLoader({
+ root: 'C:\\opencreator-test-dependencies',
+ platform: 'win32',
+ arch: 'x64',
+ whisperCppInstaller: {
+ async isInstalled(_root, model) {
+ return installed.has(model);
+ },
+ async install(input) {
+ installs.push(input.model);
+ input.onPhase('cli');
+ input.onPhase('model');
+ installed.add(input.model);
+ }
+ }
+ });
+ const config = createDefaultCreatorServicesConfig();
+ config.transcription.provider = 'whisper.cpp';
+ const ensure = () => loader.ensure({
+ config,
+ signal: new AbortController().signal,
+ reportProgress(progress) {
+ if (typeof progress.dependencyPhase === 'string') {
+ phases.push(progress.dependencyPhase);
+ }
+ }
+ });
+
+ await Promise.all([ensure(), ensure()]);
+ await ensure();
+ config.transcription.whisperCpp.model = 'medium';
+ await ensure();
+
+ expect(installs).toEqual(['tiny', 'medium']);
+ expect(phases).toContain('download');
+ expect(phases).toContain('cli');
+ expect(phases).toContain('model');
+ });
+
+ it('rejects Whisper.cpp outside Windows x64 without installing anything', async () => {
+ let installs = 0;
+ const loader = createKrillinDependencyLoader({
+ root: '/tmp/opencreator-test-dependencies',
+ platform: 'win32',
+ arch: 'arm64',
+ whisperCppInstaller: {
+ async isInstalled() {
+ return false;
+ },
+ async install() {
+ installs += 1;
+ }
+ }
+ });
+ const config = createDefaultCreatorServicesConfig();
+ config.transcription.provider = 'whisper.cpp';
+
+ await expect(loader.ensure({
+ config,
+ signal: new AbortController().signal,
+ reportProgress() {}
+ })).rejects.toMatchObject({ code: 'dependency_not_packaged' });
+ expect(installs).toBe(0);
+ });
});
diff --git a/apps/daemon/test/unit/creator-krillin-execution-plan.test.ts b/apps/daemon/test/unit/creator-krillin-execution-plan.test.ts
index 07303096..f27ab4b9 100644
--- a/apps/daemon/test/unit/creator-krillin-execution-plan.test.ts
+++ b/apps/daemon/test/unit/creator-krillin-execution-plan.test.ts
@@ -5,36 +5,25 @@ import {
} from '../../src/creator/krillin/execution-plan.js';
describe('KrillinAI CLI execution plan', () => {
- it('tries platform captions before speech recognition for YouTube', () => {
+ it('delegates platform-caption fallback to KrillinAI in one attempt', () => {
const plan = createKrillinCliExecutionPlan(
'subtitle',
- 'https://www.youtube.com/watch?v=demo',
{ captionSource: 'any' }
);
- expect(plan).toEqual([
- {
- options: { captionSource: 'platform' },
- continueOnErrorCode: 'platform_caption_failed'
- },
- {
- options: { captionSource: 'whisper' }
- }
- ]);
+ expect(plan).toEqual([{ options: { captionSource: 'any' } }]);
});
- it('keeps one attempt for local media or forced speech recognition', () => {
+ it('defaults subtitles to KrillinAI any-source mode', () => {
expect(createKrillinCliExecutionPlan(
'subtitle',
- 'local:/tmp/video.mp4',
- { captionSource: 'any' }
+ {}
)).toEqual([{
options: { captionSource: 'any' }
}]);
expect(createKrillinCliExecutionPlan(
'subtitle',
- 'https://youtu.be/demo',
{ captionSource: 'whisper' }
)).toEqual([{
options: { captionSource: 'whisper' }
@@ -44,7 +33,6 @@ describe('KrillinAI CLI execution plan', () => {
it('keeps non-subtitle stages unchanged', () => {
expect(createKrillinCliExecutionPlan(
'render-horizontal',
- undefined,
{}
)).toEqual([{ options: {} }]);
});
diff --git a/apps/daemon/test/unit/creator-project-cover.test.ts b/apps/daemon/test/unit/creator-project-cover.test.ts
index 3ed208e7..c00f16ea 100644
--- a/apps/daemon/test/unit/creator-project-cover.test.ts
+++ b/apps/daemon/test/unit/creator-project-cover.test.ts
@@ -117,6 +117,21 @@ describe('creator project cover', () => {
expect(extractFrame).toHaveBeenCalledWith(expect.objectContaining({ sourcePath }));
});
+ it('extracts a project cover from the new stickman clean video artifact', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-project-stickman-cover-'));
+ const sourcePath = join(tempDir, 'landscape-clean.mp4');
+ writeFileSync(sourcePath, 'video');
+ const extractFrame = vi.fn(async (input: { outputPath: string }) => {
+ await writeFile(input.outputPath, 'stickman-frame');
+ });
+ const service = createCreatorProjectCoverService({ jobsRoot: tempDir, extractFrame });
+
+ const cover = await service.resolve(creatorJob([artifact('clean_video', sourcePath)]));
+
+ expect(await readFile(cover!.path, 'utf8')).toBe('stickman-frame');
+ expect(extractFrame).toHaveBeenCalledWith(expect.objectContaining({ sourcePath }));
+ });
+
it('falls back to the first frame when a video is shorter than five seconds', async () => {
tempDir = mkdtempSync(join(tmpdir(), 'creator-project-cover-'));
const sourcePath = join(tempDir, 'short.mp4');
@@ -148,6 +163,7 @@ function creatorJob(artifacts: CreatorArtifact[]): CreatorJob {
agentThreadId: null,
stages: [],
artifacts,
+ providerRequests: [],
activities: [],
createdAt: '2026-08-25T00:00:00.000Z',
updatedAt: '2026-08-25T00:00:00.000Z'
@@ -166,6 +182,9 @@ function artifact(
version: 1,
status: 'completed',
path,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata,
createdAt: '2026-08-25T00:00:00.000Z'
diff --git a/apps/daemon/test/unit/creator-provider-requests.test.ts b/apps/daemon/test/unit/creator-provider-requests.test.ts
new file mode 100644
index 00000000..6f67889a
--- /dev/null
+++ b/apps/daemon/test/unit/creator-provider-requests.test.ts
@@ -0,0 +1,389 @@
+import { mkdtempSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { z } from 'zod';
+import {
+ CreatorProviderRequestError,
+ CreatorProviderRequestLedger,
+ type CreatorProviderCapabilities
+} from '../../src/creator/provider-requests.js';
+import { createCreatorRepository } from '../../src/creator/repository.js';
+import { CreatorServiceError, createCreatorService } from '../../src/creator/service.js';
+import {
+ createCreatorTemplateRegistry,
+ createStickmanVideoTemplate
+} from '../../src/creator/templates/registry.js';
+import { openRuntimeDatabase } from '../../src/storage/database.js';
+
+let tempDir = '';
+
+afterEach(() => {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = '';
+});
+
+function setup(path = join(tempDir, 'runtime.sqlite')) {
+ const db = openRuntimeDatabase(path);
+ const repository = createCreatorRepository(db);
+ const job = repository.createJob({
+ projectId: 'project_1',
+ templateId: 'image-generation',
+ templateVersion: 1,
+ status: 'running',
+ state: {}
+ });
+ const stage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'running',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ });
+ return { db, repository, job, stage, ledger: new CreatorProviderRequestLedger(repository) };
+}
+
+describe('creator provider request ledger', () => {
+ it('blocks automatic resubmit after provider acceptance is uncertain', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-provider-ledger-'));
+ const path = join(tempDir, 'runtime.sqlite');
+ const first = setup(path);
+ let submitCount = 0;
+ const registered = first.ledger.registerBeforeSubmit({
+ jobId: first.job.id,
+ provider: 'openai-image',
+ stageRunId: first.stage.id,
+ scopeKey: 'shot-01',
+ requestKey: `${first.job.id}:images:shot-01`,
+ request: { prompt: 'draw', apiKey: 'must-not-be-persisted' }
+ });
+ first.ledger.markSubmitting(registered.id);
+ submitCount += 1;
+ first.ledger.markUnknownRemoteAcceptance(registered.id);
+ expect(JSON.stringify(first.repository.getJob(first.job.id))).not.toContain('must-not-be-persisted');
+ first.db.close();
+
+ const secondDb = openRuntimeDatabase(path);
+ const secondRepository = createCreatorRepository(secondDb);
+ const lookup = vi.fn<CreatorProviderCapabilities['lookup']>();
+ const recovered = await new CreatorProviderRequestLedger(secondRepository).recover(
+ registered.id,
+ { lookupByRequestKey: false, lookup }
+ );
+
+ expect(recovered.status).toBe('unknown_remote_acceptance');
+ expect(lookup).not.toHaveBeenCalled();
+ expect(submitCount).toBe(1);
+
+ const retryStage = secondRepository.createStageRun({
+ jobId: first.job.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'running',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ });
+ expect(() => new CreatorProviderRequestLedger(secondRepository).registerBeforeSubmit({
+ jobId: first.job.id,
+ provider: 'openai-image',
+ stageRunId: retryStage.id,
+ scopeKey: 'shot-01',
+ requestKey: `${first.job.id}:images:shot-01`,
+ request: { prompt: 'draw', apiKey: 'must-not-be-persisted' }
+ })).toThrowError(expect.objectContaining<Partial<CreatorProviderRequestError>>({
+ code: 'creator_provider_resolution_required'
+ }));
+ secondDb.close();
+ });
+
+ it('creates a new generation only after the unknown request is abandoned', () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-provider-ledger-'));
+ const { db, job, stage, ledger, repository } = setup();
+ const first = ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai-image',
+ stageRunId: stage.id,
+ scopeKey: stage.scopeKey,
+ requestKey: `${job.id}:images:shot-01`,
+ request: { prompt: 'draw' }
+ });
+ ledger.markSubmitting(first.id);
+ ledger.markUnknownRemoteAcceptance(first.id);
+
+ const second = ledger.confirmResubmit(first.id);
+ repository.updateStageRun({
+ id: stage.id,
+ status: 'failed',
+ errorCode: 'creator_provider_resolution_required',
+ errorMessage: 'Provider request acceptance requires resolution'
+ });
+
+ expect(repository.getProviderRequest(first.id)?.status).toBe('abandoned_unknown');
+ expect(second).toMatchObject({
+ generation: 2,
+ resubmissionOf: first.id,
+ status: 'registered',
+ requestHash: first.requestHash
+ });
+ const retryStage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'running',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ });
+ const reused = ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai-image',
+ stageRunId: retryStage.id,
+ scopeKey: 'shot-01',
+ requestKey: `${job.id}:images:shot-01`,
+ request: { prompt: 'draw' }
+ });
+ expect(reused.id).toBe(second.id);
+ expect(repository.listProviderRequests(job.id)).toHaveLength(2);
+ db.close();
+ });
+
+ it('creates the next generation when a terminal request is retried by a new stage run', () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-provider-ledger-'));
+ const { db, job, stage, ledger, repository } = setup();
+ const requestKey = `${job.id}:images:shot-01`;
+ const first = ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai-image',
+ stageRunId: stage.id,
+ scopeKey: 'shot-01',
+ requestKey,
+ request: { prompt: 'draw' }
+ });
+ ledger.markSubmitting(first.id);
+ ledger.markFailed(first.id);
+ repository.updateStageRun({
+ id: stage.id,
+ status: 'failed',
+ errorCode: 'creator_stage_failed',
+ errorMessage: 'Provider request failed'
+ });
+ const retryStage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'running',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ });
+
+ const retry = ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai-image',
+ stageRunId: retryStage.id,
+ scopeKey: 'shot-01',
+ requestKey,
+ request: { prompt: 'draw' }
+ });
+
+ expect(retry).toMatchObject({
+ generation: 2,
+ resubmissionOf: first.id,
+ status: 'registered',
+ stageRunId: retryStage.id
+ });
+ db.close();
+ });
+
+ it('rejects reuse of a request key for a different payload', () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-provider-ledger-'));
+ const { db, job, stage, ledger, repository } = setup();
+ const requestKey = `${job.id}:images:shot-01`;
+ const first = ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai-image',
+ stageRunId: stage.id,
+ scopeKey: 'shot-01',
+ requestKey,
+ request: { prompt: 'draw' }
+ });
+ ledger.markSubmitting(first.id);
+ ledger.markFailed(first.id);
+ repository.updateStageRun({
+ id: stage.id,
+ status: 'failed',
+ errorCode: 'creator_stage_failed',
+ errorMessage: 'Provider request failed'
+ });
+ const retryStage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'running',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ });
+
+ expect(() => ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai-image',
+ stageRunId: retryStage.id,
+ scopeKey: 'shot-01',
+ requestKey,
+ request: { prompt: 'changed payload' }
+ })).toThrowError(expect.objectContaining<Partial<CreatorProviderRequestError>>({
+ code: 'creator_provider_request_key_conflict'
+ }));
+ expect(repository.listProviderRequests(job.id)).toHaveLength(1);
+ db.close();
+ });
+
+ it('queries and cancels an unknown scope without creating a paid request', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-provider-ledger-'));
+ const { db, job, stage, ledger, repository } = setup();
+ const artifact = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-02',
+ inputFingerprint: 'b'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const queryRequest = ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai-image',
+ stageRunId: stage.id,
+ scopeKey: 'shot-01',
+ requestKey: `${job.id}:images:shot-01`,
+ request: { prompt: 'draw' }
+ });
+ ledger.markSubmitting(queryRequest.id);
+ ledger.markUnknownRemoteAcceptance(queryRequest.id);
+ const lookup = vi.fn<CreatorProviderCapabilities['lookup']>().mockResolvedValue({
+ status: 'waiting_remote',
+ remoteTaskId: 'remote-1'
+ });
+
+ const queried = await ledger.recover(queryRequest.id, {
+ lookupByRequestKey: true,
+ lookup
+ });
+ expect(queried).toMatchObject({ status: 'waiting_remote', remoteTaskId: 'remote-1' });
+ expect(lookup).toHaveBeenCalledTimes(1);
+
+ const cancelStage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'running',
+ scopeKey: 'shot-03',
+ inputFingerprint: 'c'.repeat(64)
+ });
+ const cancelRequest = ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai-image',
+ stageRunId: cancelStage.id,
+ scopeKey: 'shot-03',
+ requestKey: `${job.id}:images:shot-03`,
+ request: { prompt: 'draw' }
+ });
+ ledger.markSubmitting(cancelRequest.id);
+ ledger.markUnknownRemoteAcceptance(cancelRequest.id);
+ expect(ledger.cancelScope(cancelRequest.id).status).toBe('canceled');
+ expect(repository.getJob(job.id)?.artifacts.find(item => item.id === artifact.id)?.status)
+ .toBe('completed');
+ db.close();
+ });
+
+ it('allows only a user-confirmed resubmit and blocks ordinary retry', () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-provider-ledger-'));
+ const db = openRuntimeDatabase(join(tempDir, 'runtime.sqlite'));
+ const repository = createCreatorRepository(db);
+ const base = createStickmanVideoTemplate();
+ const record = z.record(z.string(), z.unknown()) as never;
+ const service = createCreatorService({
+ repository,
+ templates: createCreatorTemplateRegistry([{
+ ...base,
+ actions: [
+ ...base.actions.filter(action => (
+ action.id !== 'retry-stage' && action.id !== 'resolve-provider-request'
+ )),
+ { id: 'retry-stage', inputSchema: record, allowedStages: ['script'] },
+ { id: 'resolve-provider-request', inputSchema: record, allowedStages: ['script'] }
+ ]
+ }])
+ });
+ const job = service.createJob({ projectId: 'project_1', templateId: 'stickman-video' });
+ const stage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'script',
+ executor: 'stickman',
+ status: 'running',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ });
+ const ledger = new CreatorProviderRequestLedger(repository);
+ const request = ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai-image',
+ stageRunId: stage.id,
+ scopeKey: stage.scopeKey,
+ requestKey: `${job.id}:script:shot-01`,
+ request: { prompt: 'draw' }
+ });
+ ledger.markSubmitting(request.id);
+ ledger.markUnknownRemoteAcceptance(request.id);
+
+ expect(() => service.applyAction(job.id, {
+ actor: 'agent',
+ action: 'resolve-provider-request',
+ expectedRevision: 0,
+ input: {
+ ledgerId: request.id,
+ decision: 'confirm-resubmit',
+ acceptDuplicateBilling: true,
+ revision: 0
+ }
+ })).toThrowError(expect.objectContaining<Partial<CreatorServiceError>>({
+ code: 'creator_provider_confirmation_required'
+ }));
+ expect(() => service.applyAction(job.id, {
+ actor: 'user',
+ action: 'resolve-provider-request',
+ expectedRevision: 0,
+ input: { ledgerId: request.id, decision: 'confirm-resubmit', revision: 0 }
+ })).toThrowError(expect.objectContaining<Partial<CreatorServiceError>>({
+ code: 'creator_provider_confirmation_required'
+ }));
+ expect(() => service.applyAction(job.id, {
+ actor: 'user',
+ action: 'retry-stage',
+ expectedRevision: 0,
+ input: { stageId: 'script', scopeKey: 'shot-01' }
+ })).toThrowError(expect.objectContaining<Partial<CreatorServiceError>>({
+ code: 'creator_provider_resolution_required'
+ }));
+
+ expect(() => service.applyAction(job.id, {
+ actor: 'user',
+ action: 'resolve-provider-request',
+ expectedRevision: 0,
+ input: {
+ ledgerId: request.id,
+ decision: 'confirm-resubmit',
+ acceptDuplicateBilling: true,
+ revision: 0,
+ apiKey: 'must-not-be-audited'
+ }
+ })).not.toThrow();
+ const resolved = service.getJob(job.id)!;
+ expect(resolved.providerRequests).toMatchObject([
+ { id: request.id, status: 'abandoned_unknown', generation: 1 },
+ { status: 'registered', generation: 2, resubmissionOf: request.id }
+ ]);
+ expect(JSON.stringify(resolved.activities.at(-1))).not.toContain('must-not-be-audited');
+ db.close();
+ });
+});
diff --git a/apps/daemon/test/unit/creator-runtime-advanced.test.ts b/apps/daemon/test/unit/creator-runtime-advanced.test.ts
index 8b68cb0d..8139a67e 100644
--- a/apps/daemon/test/unit/creator-runtime-advanced.test.ts
+++ b/apps/daemon/test/unit/creator-runtime-advanced.test.ts
@@ -1,3 +1,4 @@
+import { createHash } from 'node:crypto';
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
@@ -40,6 +41,308 @@ function setup() {
}
describe('creator runtime advanced contracts', () => {
+ it('runs distinct shot scopes concurrently while keeping unscoped stages serial', async () => {
+ const { db, repository, service, templates } = setup();
+ let active = 0;
+ let peak = 0;
+ const releases: Array<() => void> = [];
+ const executor: CreatorExecutor = {
+ id: 'image',
+ async run({ stageRun, workdir }) {
+ active += 1;
+ peak = Math.max(peak, active);
+ await new Promise<void>(resolve => releases.push(resolve));
+ active -= 1;
+ const outputPath = join(workdir, 'generated.png');
+ writeFileSync(outputPath, stageRun.scopeKey ?? 'unscoped');
+ return {
+ outputs: [{
+ kind: 'generated_image',
+ status: 'completed',
+ path: outputPath
+ }]
+ };
+ }
+ };
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ executors: [executor],
+ workRoot: join(tempDir, 'work'),
+ maxConcurrency: 4
+ });
+ const scopedJob = service.createJob({
+ projectId: 'p1',
+ templateId: 'image-generation',
+ state: { prompt: 'scoped' }
+ });
+ const scopedRuns = ['shot-01', 'shot-02'].map(scopeKey => repository.createStageRun({
+ jobId: scopedJob.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'queued',
+ scopeKey,
+ inputFingerprint: scopeKey === 'shot-01' ? '1'.repeat(64) : '2'.repeat(64)
+ }));
+ const scopedExecution = scopedRuns.map(stage => runner.runStageRun(stage.id));
+ await expect.poll(() => active).toBe(2);
+ expect(peak).toBe(2);
+ releases.splice(0).forEach(release => release());
+ await Promise.all(scopedExecution);
+ const scopedArtifacts = repository.getJob(scopedJob.id)!.artifacts;
+ expect(scopedArtifacts).toHaveLength(2);
+ for (const artifact of scopedArtifacts) {
+ expect(artifact.scopeKey).toMatch(/^shot-0[12]$/);
+ expect(artifact.inputFingerprint).toMatch(/^[12]{64}$/);
+ expect(artifact.sha256).toBe(createHash('sha256')
+ .update(artifact.scopeKey!)
+ .digest('hex'));
+ }
+
+ active = 0;
+ peak = 0;
+ const unscopedJob = service.createJob({
+ projectId: 'p1',
+ templateId: 'image-generation',
+ state: { prompt: 'unscoped' }
+ });
+ const unscopedRuns = [1, 2].map(() => repository.createStageRun({
+ jobId: unscopedJob.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'queued'
+ }));
+ const unscopedExecution = unscopedRuns.map(stage => runner.runStageRun(stage.id));
+ await expect.poll(() => active).toBe(1);
+ expect(peak).toBe(1);
+ releases.shift()?.();
+ await expect.poll(() => active).toBe(1);
+ expect(peak).toBe(1);
+ releases.shift()?.();
+ await Promise.all(unscopedExecution);
+
+ await runner.close();
+ db.close();
+ });
+
+ it('replaces only the previous artifact in the completed output scope', async () => {
+ const { db, repository, service, templates } = setup();
+ const outputPath = join(tempDir, 'replacement.png');
+ writeFileSync(outputPath, 'replacement');
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ executors: [{
+ id: 'stickman-image',
+ async run() {
+ return {
+ outputs: [{
+ kind: 'shot_image',
+ status: 'completed' as const,
+ path: outputPath
+ }]
+ };
+ }
+ }],
+ workRoot: join(tempDir, 'work')
+ });
+ const job = service.createJob({ projectId: 'p1', templateId: 'stickman-video' });
+ for (const kind of ['shot_spec', 'image_prompt_pack', 'character_reference', 'style_contract']) {
+ repository.insertArtifact({
+ jobId: job.id,
+ kind,
+ status: 'completed',
+ path: null,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ }
+ const oldImage = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-03',
+ inputFingerprint: 'a'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const otherImage = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-02',
+ inputFingerprint: '2'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const oldValidation = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'visual_validation',
+ status: 'completed',
+ path: null,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [oldImage.id],
+ metadata: {}
+ });
+ const oldTimeline = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'timeline_manifest',
+ status: 'completed',
+ path: null,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [oldValidation.id],
+ metadata: {}
+ });
+ const unrelatedProof = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'unrelated_proof',
+ status: 'completed',
+ path: null,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [otherImage.id],
+ metadata: {}
+ });
+ const imageStage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'queued',
+ scopeKey: 'shot-03',
+ inputFingerprint: 'b'.repeat(64)
+ });
+
+ await runner.runStageRun(imageStage.id);
+
+ const completed = service.getJob(job.id)!;
+ expect(completed.artifacts.find(artifact => artifact.id === oldImage.id)?.status).toBe('stale');
+ expect(completed.artifacts.find(artifact => artifact.id === oldValidation.id)?.status).toBe('stale');
+ expect(completed.artifacts.find(artifact => artifact.id === oldTimeline.id)?.status).toBe('stale');
+ expect(completed.artifacts.find(artifact => artifact.id === otherImage.id)?.status).toBe('completed');
+ expect(completed.artifacts.find(artifact => artifact.id === unrelatedProof.id)?.status).toBe('completed');
+ expect(completed.artifacts).toContainEqual(expect.objectContaining({
+ kind: 'shot_image',
+ scopeKey: 'shot-03',
+ inputFingerprint: 'b'.repeat(64),
+ status: 'completed'
+ }));
+ await runner.close();
+ db.close();
+ });
+
+ it('resolves one current stickman image per scope from the latest succeeded fingerprint', async () => {
+ const { db, repository, service, templates } = setup();
+ let observedInputs: string[] = [];
+ const validationPath = join(tempDir, 'visual-validation.json');
+ writeFileSync(validationPath, '{}');
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ executors: [{
+ id: 'stickman-validation',
+ async run({ inputArtifacts }) {
+ observedInputs = inputArtifacts.map(artifact => artifact.id);
+ return {
+ outputs: [{
+ kind: 'visual_validation',
+ status: 'completed' as const,
+ path: validationPath
+ }]
+ };
+ }
+ }],
+ workRoot: join(tempDir, 'work')
+ });
+ const job = service.createJob({ projectId: 'p1', templateId: 'stickman-video' });
+ const shotSpec = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_spec',
+ status: 'completed',
+ path: null,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'succeeded',
+ scopeKey: 'shot-03',
+ inputFingerprint: 'a'.repeat(64)
+ });
+ const oldImage = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-03',
+ inputFingerprint: 'a'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'succeeded',
+ scopeKey: 'shot-03',
+ inputFingerprint: 'b'.repeat(64)
+ });
+ const currentImage = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-03',
+ inputFingerprint: 'b'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'succeeded',
+ scopeKey: 'shot-04',
+ inputFingerprint: 'c'.repeat(64)
+ });
+ const otherImage = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-04',
+ inputFingerprint: 'c'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+
+ await runner.run(job.id, 'visual-validation');
+
+ expect(observedInputs).toEqual(expect.arrayContaining([
+ shotSpec.id,
+ currentImage.id,
+ otherImage.id
+ ]));
+ expect(observedInputs).not.toContain(oldImage.id);
+ expect(observedInputs.filter(id => id === currentImage.id || id === otherImage.id)).toHaveLength(2);
+ await runner.close();
+ db.close();
+ });
+
it('cancels queued and running stage runs without committing partial outputs', async () => {
const { db, repository, dispatcher, service, templates } = setup();
const queuedJob = service.createJob({
@@ -140,6 +443,8 @@ describe('creator runtime advanced contracts', () => {
it('keeps a video download job in draft after the non-final probe stage', async () => {
const { db, repository, service, templates } = setup();
+ const probePath = join(tempDir, 'probe.json');
+ writeFileSync(probePath, '{}');
const runner = createCreatorStageRunner({
repository,
templates,
@@ -150,7 +455,7 @@ describe('creator runtime advanced contracts', () => {
outputs: [{
kind: 'download_probe',
status: 'completed' as const,
- path: join(tempDir, 'probe.json'),
+ path: probePath,
metadata: {
requestedUrl: 'https://www.youtube.com/watch?v=probe-only',
options: []
@@ -278,6 +583,8 @@ describe('creator runtime advanced contracts', () => {
executors: [{
id: 'cover-analysis',
async run() {
+ writeFileSync(join(tempDir, 'cover-brief.json'), '{}');
+ writeFileSync(join(tempDir, 'source-keyframe.jpg'), 'jpeg');
return {
outputs: [
{
@@ -326,6 +633,9 @@ describe('creator runtime advanced contracts', () => {
kind: 'cover_image',
status: 'completed',
path: join(tempDir, 'cover-v1.png'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { resultVersion: 1 }
});
@@ -365,6 +675,7 @@ describe('creator runtime advanced contracts', () => {
id: 'krillinai',
async run({ stageRun }) {
if (stageRun.stageId === 'subtitle') {
+ writeFileSync(join(tempDir, 'subtitle-v1.srt'), '1\n00:00:00,000 --> 00:00:01,000\nTest\n');
return {
outputs: [{
kind: 'target_subtitle',
@@ -375,6 +686,7 @@ describe('creator runtime advanced contracts', () => {
};
}
if (stageRun.stageId === 'render-horizontal') {
+ writeFileSync(join(tempDir, 'horizontal-v1.mp4'), 'video');
return {
outputs: [{
kind: 'horizontal_video',
@@ -383,6 +695,7 @@ describe('creator runtime advanced contracts', () => {
}]
};
}
+ writeFileSync(join(tempDir, 'voice-v1.wav'), 'audio');
return {
outputs: [{
kind: 'dubbed_audio',
@@ -410,6 +723,9 @@ describe('creator runtime advanced contracts', () => {
kind: 'source_video',
status: 'completed',
path: join(tempDir, 'source.mp4'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {}
});
@@ -495,6 +811,7 @@ describe('creator runtime advanced contracts', () => {
id: 'krillinai',
async run({ inputArtifacts }) {
observedInputIds = inputArtifacts.map(artifact => artifact.id);
+ writeFileSync(join(tempDir, 'branched-horizontal.mp4'), 'video');
return {
outputs: [{
kind: 'horizontal_video',
@@ -521,6 +838,9 @@ describe('creator runtime advanced contracts', () => {
kind: 'source_video',
status: 'completed',
path: join(tempDir, 'source-v1.mp4'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { resultVersion: 1 }
});
@@ -529,6 +849,9 @@ describe('creator runtime advanced contracts', () => {
kind: 'target_subtitle',
status: 'completed',
path: join(tempDir, 'subtitle-v1.srt'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [sourceV1.id],
metadata: { resultVersion: 1 }
});
@@ -537,6 +860,9 @@ describe('creator runtime advanced contracts', () => {
kind: 'dubbed_audio',
status: 'completed',
path: join(tempDir, 'voice-v1.wav'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [subtitleV1.id],
metadata: { resultVersion: 1 }
});
@@ -545,6 +871,9 @@ describe('creator runtime advanced contracts', () => {
kind: 'dubbed_video',
status: 'completed',
path: join(tempDir, 'dubbed-v1.mp4'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [sourceV1.id, voiceV1.id],
metadata: { resultVersion: 1 }
});
@@ -553,6 +882,9 @@ describe('creator runtime advanced contracts', () => {
kind: 'source_video',
status: 'completed',
path: join(tempDir, 'source-v2.mp4'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { resultVersion: 2 }
});
@@ -561,6 +893,9 @@ describe('creator runtime advanced contracts', () => {
kind: 'target_subtitle',
status: 'completed',
path: join(tempDir, 'subtitle-v2.srt'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [sourceV2.id],
metadata: { resultVersion: 2 }
});
@@ -696,6 +1031,9 @@ describe('creator runtime advanced contracts', () => {
kind: 'source_video',
status: 'completed',
path: join(tempDir, 'old-local-source.mp4'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { source: 'local-upload' }
});
@@ -823,26 +1161,4 @@ describe('creator runtime advanced contracts', () => {
}] }, 12)).toThrow(/invalid_clip_range/);
});
- it('stales only the edited stickman segment assets and the final render', () => {
- const { db, repository, service } = setup();
- const job = service.createJob({ projectId: 'p1', templateId: 'stickman-video', state: { topic: '测试' } });
- const segmentA = repository.insertArtifact({ jobId: job.id, kind: 'script_segment', status: 'completed', path: null, sourceArtifactIds: [], metadata: { id: 's1', narration: 'A', visualPrompt: 'A', durationSeconds: 2 } });
- const segmentB = repository.insertArtifact({ jobId: job.id, kind: 'script_segment', status: 'completed', path: null, sourceArtifactIds: [], metadata: { id: 's2', narration: 'B', visualPrompt: 'B', durationSeconds: 2 } });
- const imageA = repository.insertArtifact({ jobId: job.id, kind: 'storyboard_image', status: 'completed', path: 'a.png', sourceArtifactIds: [segmentA.id], metadata: { segmentId: 's1' } });
- const imageB = repository.insertArtifact({ jobId: job.id, kind: 'storyboard_image', status: 'completed', path: 'b.png', sourceArtifactIds: [segmentB.id], metadata: { segmentId: 's2' } });
- const audioA = repository.insertArtifact({ jobId: job.id, kind: 'segment_audio', status: 'completed', path: 'a.mp3', sourceArtifactIds: [segmentA.id], metadata: { segmentId: 's1' } });
- const audioB = repository.insertArtifact({ jobId: job.id, kind: 'segment_audio', status: 'completed', path: 'b.mp3', sourceArtifactIds: [segmentB.id], metadata: { segmentId: 's2' } });
- const final = repository.insertArtifact({ jobId: job.id, kind: 'stickman_video', status: 'completed', path: 'final.mp4', sourceArtifactIds: [imageA.id, imageB.id, audioA.id, audioB.id], metadata: {} });
- service.applyAction(job.id, {
- actor: 'user', action: 'edit-script-segment', expectedRevision: 0,
- input: { artifactId: segmentB.id, narration: 'B2' }
- });
- const artifacts = service.getJob(job.id)!.artifacts;
- expect(artifacts.find(item => item.id === imageA.id)?.status).toBe('completed');
- expect(artifacts.find(item => item.id === audioA.id)?.status).toBe('completed');
- expect(artifacts.find(item => item.id === imageB.id)?.status).toBe('stale');
- expect(artifacts.find(item => item.id === audioB.id)?.status).toBe('stale');
- expect(artifacts.find(item => item.id === final.id)?.status).toBe('stale');
- db.close();
- });
});
diff --git a/apps/daemon/test/unit/creator-service.test.ts b/apps/daemon/test/unit/creator-service.test.ts
index 58128dea..6cd1ed81 100644
--- a/apps/daemon/test/unit/creator-service.test.ts
+++ b/apps/daemon/test/unit/creator-service.test.ts
@@ -444,6 +444,9 @@ describe('creator service', () => {
kind: 'target_subtitle',
status: 'completed',
path: join(tempDir, 'v1.srt'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { resultVersion: 1 }
});
@@ -452,6 +455,9 @@ describe('creator service', () => {
kind: 'dubbed_audio',
status: 'completed',
path: join(tempDir, 'v1.mp3'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [subtitleV1.id],
metadata: { resultVersion: 1 }
});
@@ -460,6 +466,9 @@ describe('creator service', () => {
kind: 'target_subtitle',
status: 'completed',
path: join(tempDir, 'v2.srt'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { resultVersion: 2 }
});
@@ -468,6 +477,9 @@ describe('creator service', () => {
kind: 'dubbed_audio',
status: 'completed',
path: join(tempDir, 'v2.mp3'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [subtitleV2.id],
metadata: { resultVersion: 2 }
});
@@ -476,6 +488,9 @@ describe('creator service', () => {
kind: 'horizontal_video',
status: 'completed',
path: join(tempDir, 'v2.mp4'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [audioV2.id, subtitleV2.id],
metadata: { resultVersion: 2 }
});
@@ -598,6 +613,9 @@ describe('creator service', () => {
kind: 'horizontal_video',
status: 'completed',
path: join(tempDir, 'horizontal.mp4'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { resultVersion: 1 }
});
@@ -606,6 +624,9 @@ describe('creator service', () => {
kind: 'vertical_subtitle',
status: 'completed',
path: join(tempDir, 'vertical.srt'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { resultVersion: 1 }
});
@@ -614,6 +635,9 @@ describe('creator service', () => {
kind: 'vertical_video',
status: 'completed',
path: join(tempDir, 'vertical.mp4'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [verticalSubtitle.id],
metadata: { resultVersion: 1 }
});
@@ -698,6 +722,9 @@ describe('creator service', () => {
kind: 'target_subtitle',
status: 'completed',
path: join(tempDir, 'subtitle-v1.srt'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { resultVersion: 1 }
});
@@ -706,6 +733,9 @@ describe('creator service', () => {
kind: 'horizontal_video',
status: 'completed',
path: join(tempDir, 'video-v1.mp4'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [subtitle.id],
metadata: { resultVersion: 1 }
});
diff --git a/apps/daemon/test/unit/creator-stickman-audio.test.ts b/apps/daemon/test/unit/creator-stickman-audio.test.ts
new file mode 100644
index 00000000..1f069105
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-audio.test.ts
@@ -0,0 +1,317 @@
+import { createHash } from 'node:crypto';
+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { createDefaultCreatorServicesConfig, type CreatorArtifact } from '@opencreator/protocol';
+import { CreatorProviderRequestLedger } from '../../src/creator/provider-requests.js';
+import { createCreatorRepository } from '../../src/creator/repository.js';
+import { createCreatorService } from '../../src/creator/service.js';
+import { createCreatorStageRunner } from '../../src/creator/stage-runner.js';
+import { createStickmanAudioExecutor } from '../../src/creator/stickman/audio-executor.js';
+import { stickmanNarrationFingerprint } from '../../src/creator/stickman/lineage.js';
+import { createDefaultCreatorTemplateRegistry } from '../../src/creator/templates/registry.js';
+import { openRuntimeDatabase } from '../../src/storage/database.js';
+
+let tempDir = '';
+
+afterEach(() => {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = '';
+});
+
+describe('stickman audio executor', () => {
+ it('synthesizes one scoped audio per segment and builds contiguous ffprobe timing', async () => {
+ const { db, repository, service, templates, script } = setupConfiguredJob();
+ const synthesize = vi.fn(async (request: { text: string; voiceId?: string }) => ({
+ content: Buffer.from(`wave:${request.text}`),
+ mime: 'audio/wav' as const,
+ provider: 'openai' as const,
+ model: 'gpt-4o-mini-tts',
+ voiceId: request.voiceId ?? 'alloy',
+ format: 'wav' as const
+ }));
+ const probe = vi.fn(async (path: string) => ({
+ duration: path.includes('segment-01') ? 1.25 : 2.75,
+ hasVideo: false,
+ hasAudio: true
+ }));
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ workRoot: join(tempDir, 'jobs'),
+ executors: [createStickmanAudioExecutor({
+ configStore: { read: async () => configuredTts() },
+ ttsService: { synthesize },
+ ledger: new CreatorProviderRequestLedger(repository),
+ ffprobePath: 'ffprobe-test',
+ synthesize,
+ probe
+ })]
+ });
+
+ for (const [index, scopeKey] of ['segment-01', 'segment-02'].entries()) {
+ const run = repository.createStageRun({
+ jobId: script.jobId,
+ stageId: 'narration',
+ executor: 'stickman-audio',
+ status: 'queued',
+ scopeKey,
+ inputFingerprint: String(index + 1).repeat(64)
+ });
+ expect((await runner.runStageRun(run.id)).status).toBe('succeeded');
+ }
+ const timingRun = repository.createStageRun({
+ jobId: script.jobId,
+ stageId: 'audio-timing',
+ executor: 'stickman-audio',
+ status: 'queued'
+ });
+ expect((await runner.runStageRun(timingRun.id)).status).toBe('succeeded');
+
+ const completed = service.getJob(script.jobId)!;
+ const narration = completed.artifacts.filter(artifact => artifact.kind === 'narration_audio');
+ expect(narration.map(artifact => artifact.scopeKey)).toEqual(['segment-01', 'segment-02']);
+ expect(synthesize.mock.calls.map(([request]) => ({
+ text: request.text,
+ voiceId: request.voiceId
+ }))).toEqual([
+ { text: '第一段旁白', voiceId: 'alloy' },
+ { text: '第二段旁白', voiceId: 'alloy' }
+ ]);
+ expect(completed.providerRequests).toHaveLength(2);
+ const timingArtifact = completed.artifacts.find(artifact => artifact.kind === 'audio_timing')!;
+ expect(JSON.parse(readFileSync(timingArtifact.path!, 'utf8'))).toMatchObject({
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ segments: [
+ { segmentId: 'segment-01', startSeconds: 0, endSeconds: 1.25, durationSeconds: 1.25 },
+ { segmentId: 'segment-02', startSeconds: 1.25, endSeconds: 4, durationSeconds: 2.75 }
+ ],
+ totalDurationSeconds: 4
+ });
+ expect(probe).toHaveBeenCalledTimes(4);
+ await runner.close();
+ db.close();
+ });
+
+ it('changes the narration fingerprint when the selected voice changes', () => {
+ const script = {
+ sha256: 'a'.repeat(64)
+ } as CreatorArtifact;
+ const base = {
+ segment: { id: 'segment-01', narration: '同一段旁白' },
+ script,
+ settings: { provider: 'openai', model: 'gpt-4o-mini-tts', voiceId: 'alloy' }
+ };
+ expect(stickmanNarrationFingerprint(base)).not.toBe(stickmanNarrationFingerprint({
+ ...base,
+ settings: { ...base.settings, voiceId: 'nova' }
+ }));
+ });
+
+ it('keeps real TTS timing outside the target window as a non-blocking measurement', async () => {
+ const { db, repository, service, templates, script } = setupConfiguredJob({
+ targetDurationSeconds: 30
+ });
+ const synthesize = vi.fn(async (request: { text: string; voiceId?: string }) => ({
+ content: Buffer.from(`wave:${request.text}`),
+ mime: 'audio/wav' as const,
+ provider: 'openai' as const,
+ model: 'gpt-4o-mini-tts',
+ voiceId: request.voiceId ?? 'alloy',
+ format: 'wav' as const
+ }));
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ workRoot: join(tempDir, 'jobs'),
+ executors: [createStickmanAudioExecutor({
+ configStore: { read: async () => configuredTts() },
+ ttsService: { synthesize },
+ ledger: new CreatorProviderRequestLedger(repository),
+ ffprobePath: 'ffprobe-test',
+ synthesize,
+ probe: async () => ({ duration: 12.36, hasVideo: false, hasAudio: true })
+ })]
+ });
+
+ for (const [index, scopeKey] of ['segment-01', 'segment-02'].entries()) {
+ const run = repository.createStageRun({
+ jobId: script.jobId,
+ stageId: 'narration',
+ executor: 'stickman-audio',
+ status: 'queued',
+ scopeKey,
+ inputFingerprint: String(index + 1).repeat(64)
+ });
+ expect((await runner.runStageRun(run.id)).status).toBe('succeeded');
+ }
+ const timingRun = repository.createStageRun({
+ jobId: script.jobId,
+ stageId: 'audio-timing',
+ executor: 'stickman-audio',
+ status: 'queued'
+ });
+
+ expect(await runner.runStageRun(timingRun.id)).toMatchObject({ status: 'succeeded' });
+ const timingArtifact = service.getJob(script.jobId)!.artifacts.find(artifact => (
+ artifact.kind === 'audio_timing' && artifact.status === 'completed'
+ ));
+ expect(timingArtifact).toMatchObject({
+ metadata: {
+ duration: 24.72,
+ targetDurationSeconds: 30,
+ durationDeltaSeconds: -5.28,
+ durationWithinTargetRange: false
+ }
+ });
+ expect(JSON.parse(readFileSync(timingArtifact!.path!, 'utf8'))).toMatchObject({
+ totalDurationSeconds: 24.72
+ });
+ await runner.close();
+ db.close();
+ });
+
+ it('fails before synthesis when no supported TTS provider is configured', async () => {
+ const { db, repository, templates, script } = setupConfiguredJob({ configured: false });
+ const synthesize = vi.fn();
+ const config = createDefaultCreatorServicesConfig();
+ config.tts.provider = 'edge-tts';
+ const run = repository.createStageRun({
+ jobId: script.jobId,
+ stageId: 'narration',
+ executor: 'stickman-audio',
+ status: 'queued',
+ scopeKey: 'segment-01',
+ inputFingerprint: '1'.repeat(64)
+ });
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ workRoot: join(tempDir, 'jobs'),
+ executors: [createStickmanAudioExecutor({
+ configStore: { read: async () => config },
+ ttsService: { synthesize: synthesize as never },
+ ledger: new CreatorProviderRequestLedger(repository),
+ ffprobePath: 'ffprobe-test',
+ synthesize: synthesize as never,
+ probe: async () => ({ duration: 1, hasVideo: false, hasAudio: true })
+ })]
+ });
+
+ expect(await runner.runStageRun(run.id)).toMatchObject({
+ status: 'failed',
+ errorCode: 'creator_tts_config_missing'
+ });
+ expect(synthesize).not.toHaveBeenCalled();
+ await runner.close();
+ db.close();
+ });
+
+ it('does not publish a narration artifact when the generated bytes are not valid audio', async () => {
+ const { db, repository, service, templates, script } = setupConfiguredJob();
+ const synthesize = vi.fn(async () => ({
+ content: Buffer.from('not an audio file'),
+ mime: 'audio/wav' as const,
+ provider: 'openai' as const,
+ model: 'gpt-4o-mini-tts',
+ voiceId: 'alloy',
+ format: 'wav' as const
+ }));
+ const run = repository.createStageRun({
+ jobId: script.jobId,
+ stageId: 'narration',
+ executor: 'stickman-audio',
+ status: 'queued',
+ scopeKey: 'segment-01',
+ inputFingerprint: '1'.repeat(64)
+ });
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ workRoot: join(tempDir, 'jobs'),
+ executors: [createStickmanAudioExecutor({
+ configStore: { read: async () => configuredTts() },
+ ttsService: { synthesize },
+ ledger: new CreatorProviderRequestLedger(repository),
+ ffprobePath: 'ffprobe-test',
+ synthesize,
+ probe: async () => ({ duration: 0, hasVideo: false, hasAudio: false })
+ })]
+ });
+
+ expect(await runner.runStageRun(run.id)).toMatchObject({
+ status: 'failed',
+ errorCode: 'creator_audio_invalid'
+ });
+ expect(service.getJob(script.jobId)!.artifacts.filter(artifact => artifact.kind === 'narration_audio'))
+ .toHaveLength(0);
+ await runner.close();
+ db.close();
+ });
+});
+
+function setupConfiguredJob(options: {
+ configured?: boolean;
+ targetDurationSeconds?: number;
+} = {}) {
+ const targetDurationSeconds = options.targetDurationSeconds ?? 60;
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-audio-'));
+ const db = openRuntimeDatabase(join(tempDir, 'runtime.sqlite'));
+ const repository = createCreatorRepository(db);
+ const templates = createDefaultCreatorTemplateRegistry();
+ const service = createCreatorService({ repository, templates });
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: options.configured === false
+ ? {}
+ : {
+ ttsProvider: 'openai',
+ ttsModel: 'gpt-4o-mini-tts',
+ voiceCode: 'alloy',
+ targetDurationSeconds
+ }
+ });
+ const path = join(tempDir, 'script.json');
+ writeFileSync(path, JSON.stringify({
+ contract: 'stickman-narration-script-v2',
+ reviewStatus: 'approved',
+ contentLocked: true,
+ title: '音频测试',
+ language: 'zh-CN',
+ targetDurationSeconds,
+ narrationBudget: { unit: 'characters', unitsPerMinute: 240, minUnits: 1, maxUnits: 20 },
+ segmentCount: 2,
+ totalNarrationUnits: 10,
+ estimatedTotalDurationSeconds: 2.5,
+ segments: [
+ { id: 'segment-01', order: 1, narration: '第一段旁白', claimIds: ['claim-001'], sourceSpanIds: ['source-001'], narrationUnits: 5, estimatedDurationSeconds: 1.25 },
+ { id: 'segment-02', order: 2, narration: '第二段旁白', claimIds: ['claim-002'], sourceSpanIds: ['source-002'], narrationUnits: 5, estimatedDurationSeconds: 1.25 }
+ ]
+ }));
+ const script = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'script_manifest',
+ status: 'completed',
+ path,
+ sha256: createHash('sha256').update(readFileSync(path)).digest('hex'),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ repository.updateJob({
+ id: job.id,
+ status: job.status,
+ revision: job.revision,
+ state: { ...job.state, approvedScriptArtifactId: script.id }
+ });
+ return { db, repository, service, templates, script };
+}
+
+function configuredTts() {
+ const config = createDefaultCreatorServicesConfig();
+ config.tts.provider = 'openai';
+ config.tts.openai.model = 'gpt-4o-mini-tts';
+ config.tts.openai.defaultVoiceId = 'alloy';
+ return config;
+}
diff --git a/apps/daemon/test/unit/creator-stickman-codex-completion.test.ts b/apps/daemon/test/unit/creator-stickman-codex-completion.test.ts
new file mode 100644
index 00000000..0e468a3f
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-codex-completion.test.ts
@@ -0,0 +1,177 @@
+import { createDefaultCreatorServicesConfig } from '@opencreator/protocol';
+import { describe, expect, it, vi } from 'vitest';
+import type { CodexAppServerResult } from '../../src/codex/app-server-host-2026-07-28.js';
+import { createStickmanCodexJsonCompletion } from '../../src/creator/stickman/codex-json-completion.js';
+import { createStickmanConfiguredCompletion } from '../../src/creator/stickman/content-executor.js';
+
+describe('stickman Codex JSON completion', () => {
+ it('parses the final agent JSON message and disables every tool', async () => {
+ const startTurn = vi.fn((input: Record<string, unknown>) => {
+ void (input.onNotification as (event: Record<string, unknown>) => void)({
+ method: 'item/completed',
+ params: {
+ item: {
+ id: 'final-1',
+ type: 'agentMessage',
+ phase: 'final_answer',
+ text: '{"title":"ok"}'
+ }
+ }
+ });
+ return execution(Promise.resolve(result('completed')));
+ });
+ const complete = createStickmanCodexJsonCompletion({
+ runtimeManager: { startTurn } as never
+ });
+
+ await expect(complete(request())).resolves.toEqual({ title: 'ok' });
+ expect(startTurn).toHaveBeenCalledWith(expect.objectContaining({
+ scope: { kind: 'creator-job', id: 'job-1' },
+ jobId: 'job-1',
+ projectId: 'project-1',
+ profile: 'default',
+ sandbox: 'read-only',
+ model: 'gpt-5.6-sol',
+ runtimeInjection: {
+ mcpServers: [],
+ env: {},
+ builtInTools: {
+ shell: false,
+ fileRead: false,
+ fileWrite: false,
+ applyPatch: false,
+ webSearch: false
+ },
+ configurationFingerprint: 'stickman-json-completion-v1'
+ }
+ }));
+ });
+
+ it('parses fenced JSON assembled from agent message deltas', async () => {
+ const startTurn = vi.fn((input: Record<string, unknown>) => {
+ const notify = input.onNotification as (event: Record<string, unknown>) => void;
+ notify({
+ method: 'item/agentMessage/delta',
+ params: { itemId: 'answer-1', delta: '```json\n{"segments":' }
+ });
+ notify({
+ method: 'item/agentMessage/delta',
+ params: { itemId: 'answer-1', delta: '[]}\n```' }
+ });
+ return execution(Promise.resolve(result('completed')));
+ });
+ const complete = createStickmanCodexJsonCompletion({
+ runtimeManager: { startTurn } as never
+ });
+
+ await expect(complete(request())).resolves.toEqual({ segments: [] });
+ });
+
+ it('rejects a failed Codex turn as an LLM failure', async () => {
+ const complete = createStickmanCodexJsonCompletion({
+ runtimeManager: {
+ startTurn: () => execution(Promise.resolve(result('failed')))
+ } as never
+ });
+
+ await expect(complete(request())).rejects.toMatchObject({
+ code: 'creator_llm_failed'
+ });
+ });
+
+ it('cancels the active Codex turn when the stage is aborted', async () => {
+ let finish!: (value: CodexAppServerResult) => void;
+ const pending = new Promise<CodexAppServerResult>(resolve => { finish = resolve; });
+ const cancel = vi.fn(() => finish(result('interrupted')));
+ const controller = new AbortController();
+ const complete = createStickmanCodexJsonCompletion({
+ runtimeManager: {
+ startTurn: () => execution(pending, cancel)
+ } as never
+ });
+
+ const work = complete(request(controller.signal));
+ controller.abort();
+ await expect(work).rejects.toMatchObject({ code: 'creator_stage_canceled' });
+ expect(cancel).toHaveBeenCalledTimes(1);
+ });
+});
+
+describe('stickman configured completion', () => {
+ it('uses the Codex runtime without requiring a separate API key', async () => {
+ const config = createDefaultCreatorServicesConfig();
+ config.llm.source = 'codex';
+ config.llm.apiKey = '';
+ config.llm.model = 'gpt-5.6-sol';
+ const codexCompleteJson = vi.fn(async () => ({ title: 'ok' }));
+ const complete = createStickmanConfiguredCompletion({
+ configStore: { read: async () => config },
+ codexCompleteJson,
+ context: { jobId: 'job-1', projectId: 'project-1', cwd: 'D:\\jobs\\job-1' }
+ });
+
+ await expect(complete({
+ stageId: 'source-brief',
+ prompt: 'return JSON',
+ signal: new AbortController().signal
+ })).resolves.toEqual({ title: 'ok' });
+ expect(codexCompleteJson).toHaveBeenCalledWith(expect.objectContaining({
+ jobId: 'job-1',
+ projectId: 'project-1',
+ model: 'gpt-5.6-sol'
+ }));
+ });
+
+ it('still requires an API key for a custom HTTP model', async () => {
+ const config = createDefaultCreatorServicesConfig();
+ config.llm.source = 'custom';
+ config.llm.apiKey = '';
+ const complete = createStickmanConfiguredCompletion({
+ configStore: { read: async () => config },
+ context: { jobId: 'job-1', projectId: 'project-1', cwd: 'D:\\jobs\\job-1' }
+ });
+
+ await expect(complete({
+ stageId: 'source-brief',
+ prompt: 'return JSON',
+ signal: new AbortController().signal
+ })).rejects.toMatchObject({ code: 'creator_llm_config_missing' });
+ });
+});
+
+function request(signal = new AbortController().signal) {
+ return {
+ stageId: 'source-brief',
+ prompt: 'Return JSON',
+ signal,
+ jobId: 'job-1',
+ projectId: 'project-1',
+ cwd: process.cwd(),
+ model: 'gpt-5.6-sol'
+ };
+}
+
+function execution(
+ work: Promise<CodexAppServerResult>,
+ cancel = vi.fn()
+) {
+ return {
+ cancel,
+ started: Promise.resolve({ pid: 101, reused: false, generation: 1 }),
+ result: work
+ };
+}
+
+function result(turnStatus: CodexAppServerResult['turnStatus']): CodexAppServerResult {
+ return {
+ threadId: 'thread-1',
+ turnId: 'turn-1',
+ turnStatus,
+ stderr: '',
+ terminationReason: turnStatus === 'interrupted' ? 'canceled' : 'completed',
+ outputTruncation: {
+ stderr: { truncated: false, droppedBytes: 0, droppedItems: 0 },
+ frames: { truncated: false, droppedBytes: 0, droppedItems: 0 }
+ }
+ };
+}
diff --git a/apps/daemon/test/unit/creator-stickman-delivery.test.ts b/apps/daemon/test/unit/creator-stickman-delivery.test.ts
new file mode 100644
index 00000000..366d5653
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-delivery.test.ts
@@ -0,0 +1,274 @@
+import { createHash } from 'node:crypto';
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, describe, expect, it } from 'vitest';
+import type { CreatorArtifact } from '@opencreator/protocol';
+import { createStickmanDeliveryExecutor } from '../../src/creator/stickman/delivery-executor.js';
+
+let tempRoot = '';
+
+afterEach(() => {
+ if (tempRoot) rmSync(tempRoot, { recursive: true, force: true });
+ tempRoot = '';
+});
+
+describe('stickman delivery executor', () => {
+ it('materializes and validates the video and narration subtitle', async () => {
+ const fixture = await createFixture();
+ const result = await run(fixture.artifacts, fixture.workdir);
+ expect(result.outputs.map(output => output.kind)).toEqual([
+ 'clean_video',
+ 'narration_subtitle',
+ 'delivery_manifest'
+ ]);
+ const manifest = JSON.parse(readFileSync(result.outputs.at(-1)!.path!, 'utf8'));
+ expect(manifest).toMatchObject({
+ packageStatus: 'technical-draft',
+ placeholderAssets: [],
+ blockingChecks: expect.arrayContaining([
+ 'visual_validation_missing',
+ 'narration_audio_unverified',
+ 'media_validation_missing',
+ 'video_frame_sampling_unverified'
+ ])
+ });
+ expect(manifest.files.map((file: { name: string }) => file.name)).toEqual([
+ 'stickman-video.mp4',
+ 'narration.srt'
+ ]);
+ });
+
+ it('marks the package publishable only when every real-media evidence gate passes', async () => {
+ const fixture = await createFixture();
+ addPublishableEvidence(fixture.artifacts, join(tempRoot, 'job-1', 'source'));
+ const result = await run(fixture.artifacts, fixture.workdir, {
+ sampleVideoFrames: async () => ({ sampleCount: 3 })
+ });
+ const manifest = JSON.parse(readFileSync(result.outputs.at(-1)!.path!, 'utf8'));
+
+ expect(manifest).toMatchObject({
+ packageStatus: 'publishable',
+ placeholderAssets: [],
+ blockingChecks: []
+ });
+ const delivery = result.outputs.at(-1);
+ if (delivery === undefined) throw new Error('delivery manifest output is missing');
+ expect(delivery.metadata?.packageStatus).toBe('publishable');
+ });
+
+ it('rejects extra, stale, hash-mismatched, and invalid subtitle inputs', async () => {
+ let fixture = await createFixture();
+ mkdirSync(join(fixture.workdir, 'delivery'), { recursive: true });
+ writeFileSync(join(fixture.workdir, 'delivery', 'extra.txt'), 'extra');
+ await expect(run(fixture.artifacts, fixture.workdir)).rejects.toMatchObject({
+ code: 'creator_delivery_extra_file'
+ });
+
+ fixture = await createFixture();
+ fixture.artifacts[0] = { ...fixture.artifacts[0]!, status: 'stale' };
+ await expect(run(fixture.artifacts, fixture.workdir)).rejects.toMatchObject({
+ code: 'creator_delivery_artifact_ambiguous'
+ });
+
+ fixture = await createFixture();
+ fixture.artifacts[0] = { ...fixture.artifacts[0]!, sha256: '0'.repeat(64) };
+ await expect(run(fixture.artifacts, fixture.workdir)).rejects.toMatchObject({
+ code: 'creator_delivery_hash_mismatch'
+ });
+
+ fixture = await createFixture();
+ const subtitle = fixture.artifacts.find(artifact => artifact.kind === 'narration_subtitle')!;
+ writeFileSync(subtitle.path!, 'invalid subtitle');
+ subtitle.sha256 = hashFile(subtitle.path!);
+ await expect(run(fixture.artifacts, fixture.workdir)).rejects.toThrow(/invalid_srt/);
+ });
+});
+
+async function createFixture(): Promise<{ artifacts: CreatorArtifact[]; workdir: string }> {
+ if (tempRoot) rmSync(tempRoot, { recursive: true, force: true });
+ tempRoot = mkdtempSync(join(tmpdir(), 'creator-stickman-delivery-'));
+ const jobRoot = join(tempRoot, 'job-1');
+ const sourceRoot = join(jobRoot, 'source');
+ const workdir = join(jobRoot, 'stage-delivery');
+ mkdirSync(sourceRoot, { recursive: true });
+ mkdirSync(workdir, { recursive: true });
+ const files = {
+ clean_video: join(sourceRoot, 'clean.mp4'),
+ narration_subtitle: join(sourceRoot, 'narration.srt')
+ };
+ writeFileSync(files.clean_video, 'clean-video');
+ writeFileSync(files.narration_subtitle, '1\n00:00:00,000 --> 00:00:01,000\n第一段旁白\n');
+ return {
+ workdir,
+ artifacts: Object.entries(files).map(([kind, path], index): CreatorArtifact => ({
+ id: `artifact-${index}`,
+ jobId: 'job-1',
+ kind,
+ version: 1,
+ status: 'completed',
+ path,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: hashFile(path),
+ sourceArtifactIds: [],
+ metadata: kind === 'clean_video'
+ ? { renderEngine: 'remotion', renderKind: 'final' }
+ : {},
+ createdAt: '2026-08-31T00:00:00.000Z'
+ }))
+ };
+}
+
+function run(
+ artifacts: CreatorArtifact[],
+ workdir: string,
+ options: {
+ sampleVideoFrames?: () => Promise<{ sampleCount: number }>;
+ } = {}
+) {
+ return createStickmanDeliveryExecutor({
+ ffprobePath: 'unused',
+ validateVideo: async () => ({
+ duration: 1,
+ width: 1280,
+ height: 720,
+ hasVideo: true,
+ hasAudio: true
+ }),
+ ...(options.sampleVideoFrames === undefined
+ ? {}
+ : { sampleVideoFrames: options.sampleVideoFrames })
+ }).run({
+ stageRun: { id: 'stage-delivery', stageId: 'package-validation' },
+ job: { id: 'job-1' },
+ inputArtifacts: artifacts,
+ workdir,
+ signal: new AbortController().signal,
+ reportProgress() {}
+ } as never);
+}
+
+function addPublishableEvidence(artifacts: CreatorArtifact[], sourceRoot: string): void {
+ const narrationPath = join(sourceRoot, 'segment-01.wav');
+ writeFileSync(narrationPath, 'real-narration-fixture');
+ const narration = artifact('artifact-narration', 'narration_audio', narrationPath, {
+ duration: 1,
+ provider: 'openai',
+ timingSource: 'ffprobe'
+ }, 'segment-01');
+ const timingPath = join(sourceRoot, 'audio-timing.json');
+ writeFileSync(timingPath, JSON.stringify({
+ scriptArtifactId: 'script-1',
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ segments: [{
+ segmentId: 'segment-01',
+ startSeconds: 0,
+ endSeconds: 1,
+ durationSeconds: 1,
+ audioArtifactId: narration.id,
+ audioSha256: narration.sha256
+ }],
+ totalDurationSeconds: 1
+ }));
+ const timelinePath = join(sourceRoot, 'timeline.json');
+ writeFileSync(timelinePath, JSON.stringify({
+ fps: 30,
+ width: 1280,
+ height: 720,
+ totalFrames: 30,
+ shots: [{
+ shotId: 'shot-01',
+ startFrame: 0,
+ endFrame: 30,
+ imageArtifactId: 'image-1',
+ audioArtifactId: narration.id,
+ motion: 'static',
+ imageSha256: 'a'.repeat(64),
+ audioSha256: narration.sha256
+ }]
+ }));
+ const visualPath = join(sourceRoot, 'visual-validation.json');
+ writeFileSync(visualPath, JSON.stringify({
+ ok: true,
+ validation: 'automated_decode_aspect_nonblank_hash_and_ocr',
+ approvedShotSpecArtifactId: 'shot-spec-1',
+ shotCount: 1,
+ ocrStatus: 'passed',
+ publishable: true,
+ warnings: [],
+ shots: [{
+ shotId: 'shot-01',
+ imageArtifactId: 'image-1',
+ imageSha256: 'a'.repeat(64),
+ width: 1024,
+ height: 576,
+ brightnessMean: 200,
+ contrastStddev: 30,
+ ocrStatus: 'passed',
+ detectedText: []
+ }]
+ }));
+ const timelineArtifact = artifact('artifact-timeline', 'timeline_manifest', timelinePath, {
+ timingSource: 'ffprobe_cumulative_tts_duration'
+ });
+ const cleanVideo = artifacts.find(candidate => candidate.kind === 'clean_video')!;
+ const mediaValidationPath = join(sourceRoot, 'media-validation.json');
+ writeFileSync(mediaValidationPath, JSON.stringify({
+ ok: true,
+ validation: 'ffprobe_and_three_frame_sampling',
+ cleanVideoArtifactId: cleanVideo.id,
+ cleanVideoSha256: cleanVideo.sha256,
+ timelineArtifactId: timelineArtifact.id,
+ duration: 1,
+ expectedDuration: 1,
+ durationTolerance: 0.15,
+ width: 1280,
+ height: 720,
+ hasVideo: true,
+ hasAudio: true,
+ sampledFrames: [1, 2, 3].map(index => ({
+ index,
+ timestampSeconds: index / 4,
+ sha256: String(index).repeat(64),
+ width: 1280,
+ height: 720,
+ brightnessMean: 180,
+ contrastStddev: 24
+ }))
+ }));
+ artifacts.push(
+ narration,
+ artifact('artifact-timing', 'audio_timing', timingPath),
+ timelineArtifact,
+ artifact('artifact-visual', 'visual_validation', visualPath),
+ artifact('artifact-media-validation', 'media_validation', mediaValidationPath)
+ );
+}
+
+function artifact(
+ id: string,
+ kind: string,
+ path: string,
+ metadata: CreatorArtifact['metadata'] = {},
+ scopeKey: string | null = null
+): CreatorArtifact {
+ return {
+ id,
+ jobId: 'job-1',
+ kind,
+ version: 1,
+ status: 'completed',
+ path,
+ scopeKey,
+ inputFingerprint: null,
+ sha256: hashFile(path),
+ sourceArtifactIds: [],
+ metadata,
+ createdAt: '2026-09-03T00:00:00.000Z'
+ };
+}
+
+function hashFile(path: string): string {
+ return createHash('sha256').update(readFileSync(path)).digest('hex');
+}
diff --git a/apps/daemon/test/unit/creator-stickman-image-prompt.test.ts b/apps/daemon/test/unit/creator-stickman-image-prompt.test.ts
new file mode 100644
index 00000000..5b8e20f7
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-image-prompt.test.ts
@@ -0,0 +1,110 @@
+import { describe, expect, it } from 'vitest';
+import { stickmanStyleContractSchema, type StickmanShot } from '../../src/creator/stickman/contracts.js';
+import {
+ buildStickmanImagePrompt,
+ shouldUsePreviousShotReference
+} from '../../src/creator/stickman/image-prompt.js';
+
+describe('stickman image prompt compiler', () => {
+ it('keeps character, style, and shot semantics in separate explicit contracts', () => {
+ const prompt = buildStickmanImagePrompt({
+ visualProfile: visualProfile(),
+ shot: shot(),
+ hasStyleReference: true,
+ hasPreviousShotReference: true
+ });
+
+ expect(prompt).toContain('Reference Image 1 is the CHARACTER IDENTITY source of truth');
+ expect(prompt).toContain('Reference Image 2 is the STYLE source of truth');
+ expect(prompt).toContain('Reference Image 3 is the PREVIOUS SHOT');
+ expect(prompt).toContain('do not simply copy the previous frame');
+ expect(prompt).toContain('do not copy its person, objects, composition, text, or scene');
+ expect(prompt).toContain('Preserve: blunt bob haircut and sailor-collar school uniform');
+ expect(prompt).toContain('Medium: graphite pencil drawing');
+ expect(prompt).toContain('Semantic anchor: 珍贵物品发出淡金色光泽,吸引女孩注意');
+ expect(prompt).toContain('Concrete scene: 女孩在茂密森林深处发现发光的旧盒子');
+ expect(prompt).toContain('Composition and action: 女孩位于左侧前景,伸手靠近右侧石头上的盒子');
+ expect(prompt).toContain('Required objects: 女孩; 旧盒子; 石头; 树木');
+ });
+
+ it('translates color and complex environments through the selected monochrome style', () => {
+ const prompt = buildStickmanImagePrompt({
+ visualProfile: visualProfile(),
+ shot: shot(),
+ hasStyleReference: false,
+ hasPreviousShotReference: false
+ });
+
+ expect(prompt).toContain('translate every color into grayscale value or white highlight');
+ expect(prompt).toContain('pale golden glow describes meaning and emphasis, not permission to introduce yellow');
+ expect(prompt).toContain('reduce forests to a few trees while preserving required spatial relationships');
+ expect(prompt).toContain('never remove an action-critical object');
+ expect(prompt).toContain('Never produce: photography, colored cartoon, dense realistic environment');
+ expect(prompt).not.toContain('PREVIOUS SHOT');
+ });
+
+ it('uses the previous shot only for non-initial shots with explicit continuity', () => {
+ expect(shouldUsePreviousShotReference(shot(), 0)).toBe(false);
+ expect(shouldUsePreviousShotReference(shot(), 1)).toBe(true);
+ expect(shouldUsePreviousShotReference({ ...shot(), continuityReason: '' }, 1)).toBe(false);
+ });
+});
+
+function visualProfile() {
+ return stickmanStyleContractSchema.parse({
+ contract: 'stickman-visual-profile-v2',
+ ratio: '16:9',
+ character: {
+ assetId: 'stickman.character.student',
+ revision: 1,
+ identity: {
+ preserve: 'blunt bob haircut and sailor-collar school uniform',
+ prohibit: 'glasses, trousers, or a different outfit'
+ },
+ references: [{
+ role: 'identity-primary',
+ sha256: 'a'.repeat(64),
+ bytes: 100,
+ mimeType: 'image/png'
+ }]
+ },
+ style: {
+ assetId: 'stickman.style.paper-pencil',
+ revision: 1,
+ rendering: {
+ medium: 'graphite pencil drawing',
+ surface: 'light paper with subtle grain',
+ linework: 'bold imperfect pencil contours',
+ shading: 'restrained graphite hatching',
+ palette: 'black, paper white, and graphite gray only',
+ sceneDensity: 'one concrete location with only story-critical objects',
+ composition: 'one full-frame narrative moment',
+ characterRendering: 'preserve the selected identity in pencil'
+ },
+ semanticRenderingRules: {
+ color: 'translate every color into grayscale value or white highlight',
+ light: 'use white space and sparse rays instead of colored glow',
+ complexEnvironment: 'reduce forests to a few trees while preserving required spatial relationships'
+ },
+ forbiddenDirections: ['photography', 'colored cartoon', 'dense realistic environment'],
+ references: []
+ }
+ });
+}
+
+function shot(): StickmanShot {
+ return {
+ id: 'shot-01',
+ sourceSegmentId: 'segment-01',
+ semanticAnchor: '珍贵物品发出淡金色光泽,吸引女孩注意',
+ visualDescription: '女孩在茂密森林深处发现发光的旧盒子',
+ compositionAndAction: '女孩位于左侧前景,伸手靠近右侧石头上的盒子',
+ keyObjects: ['女孩', '旧盒子', '石头', '树木'],
+ continuityReason: '延续上一镜头的行进方向',
+ motion: 'push-in',
+ motionReason: '聚焦发现瞬间',
+ startSeconds: 0,
+ endSeconds: 4,
+ durationSeconds: 4
+ };
+}
diff --git a/apps/daemon/test/unit/creator-stickman-images.test.ts b/apps/daemon/test/unit/creator-stickman-images.test.ts
new file mode 100644
index 00000000..81a98c2b
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-images.test.ts
@@ -0,0 +1,775 @@
+import { createHash } from 'node:crypto';
+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import sharp from 'sharp';
+import { afterEach, describe, expect, it } from 'vitest';
+import { createDefaultCreatorServicesConfig } from '@opencreator/protocol';
+import { CreatorProviderRequestLedger } from '../../src/creator/provider-requests.js';
+import { createCreatorRepository } from '../../src/creator/repository.js';
+import { createCreatorService } from '../../src/creator/service.js';
+import { createCreatorStageRunner } from '../../src/creator/stage-runner.js';
+import { createStickmanImageExecutor } from '../../src/creator/stickman/image-executor.js';
+import { stickmanShotFingerprint } from '../../src/creator/stickman/lineage.js';
+import { createDefaultCreatorTemplateRegistry } from '../../src/creator/templates/registry.js';
+import { openRuntimeDatabase } from '../../src/storage/database.js';
+
+let tempDir = '';
+
+afterEach(() => {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = '';
+});
+
+function setup() {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-images-'));
+ const db = openRuntimeDatabase(join(tempDir, 'runtime.sqlite'));
+ const repository = createCreatorRepository(db);
+ const templates = createDefaultCreatorTemplateRegistry();
+ const service = createCreatorService({ repository, templates });
+ return { db, repository, templates, service };
+}
+
+async function acceptCandidate() {
+ return {
+ width: 320,
+ height: 180,
+ brightnessMean: 128,
+ contrastStddev: 32,
+ ocrStatus: 'passed' as const,
+ detectedText: []
+ };
+}
+
+function shotSpecValue() {
+ return {
+ scriptArtifactId: 'script-1',
+ audioTimingArtifactId: 'audio-timing-1',
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ shots: [
+ shot('shot-01', 'segment-01', 'success one', 'static', 0),
+ shot('shot-02', 'segment-02', 'fail two', 'push-in', 4),
+ shot('shot-03', 'segment-03', 'success three', 'pan-left', 8)
+ ]
+ } as const;
+}
+
+function shot(id: string, sourceSegmentId: string, visualDescription: string, motion: 'static' | 'push-in' | 'pan-left', startSeconds: number) {
+ return {
+ id,
+ sourceSegmentId,
+ semanticAnchor: visualDescription,
+ visualDescription,
+ compositionAndAction: '人物在画面中央完成动作',
+ keyObjects: ['人物'],
+ continuityReason: '',
+ motion,
+ motionReason: '服务当前语义重点',
+ startSeconds,
+ endSeconds: startSeconds + 4,
+ durationSeconds: 4
+ };
+}
+
+type TestRepository = ReturnType<typeof createCreatorRepository>;
+
+function insertImageContracts(input: {
+ repository: TestRepository;
+ jobId: string;
+ shotSpecId: string;
+ character: { id: string; sha256: string | null };
+ characterAssetId: string;
+ prompts: Array<{ shotId: string; visualDescription: string; prompt: string }>;
+}): void {
+ const stylePath = join(tempDir, `style-contract-${input.shotSpecId}.json`);
+ writeFileSync(stylePath, JSON.stringify({
+ contract: 'stickman-visual-profile-v2',
+ ratio: '16:9',
+ character: {
+ assetId: input.characterAssetId,
+ revision: 1,
+ identity: {
+ preserve: 'oversized bald circular white head, black glasses, checkered shirt',
+ prohibit: 'different hair, clothing, or eyewear'
+ },
+ references: [{
+ role: 'identity-primary',
+ sha256: input.character.sha256,
+ bytes: 100,
+ mimeType: 'image/png'
+ }]
+ },
+ style: {
+ assetId: 'stickman.style.minimal-ink',
+ revision: 1,
+ rendering: {
+ medium: 'black ink line art',
+ surface: 'pure white background',
+ linework: 'bold hand-drawn contours',
+ shading: 'restrained light gray only',
+ palette: 'black, white, and gray only',
+ sceneDensity: 'essential objects only',
+ composition: 'one full-frame narrative moment',
+ characterRendering: 'preserve the selected identity'
+ },
+ semanticRenderingRules: {
+ color: 'translate color into grayscale contrast',
+ light: 'translate light into white space',
+ complexEnvironment: 'retain required spatial relationships while simplifying detail'
+ },
+ forbiddenDirections: ['photography', '3D', 'colored cartoon'],
+ references: []
+ }
+ }));
+ const styleContract = input.repository.insertArtifact({
+ jobId: input.jobId,
+ kind: 'style_contract',
+ status: 'completed',
+ path: stylePath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [input.character.id],
+ metadata: {
+ contract: 'stickman-visual-profile-v2',
+ characterAssetId: input.characterAssetId,
+ characterRevision: 1,
+ styleAssetId: 'stickman.style.minimal-ink',
+ styleRevision: 1,
+ styleReferenceCount: 0
+ }
+ });
+ const promptPath = join(tempDir, `prompt-pack-${input.shotSpecId}.json`);
+ writeFileSync(promptPath, JSON.stringify({
+ shotSpecArtifactId: input.shotSpecId,
+ characterReferenceArtifactId: input.character.id,
+ styleContractArtifactId: styleContract.id,
+ prompts: input.prompts
+ }));
+ input.repository.insertArtifact({
+ jobId: input.jobId,
+ kind: 'image_prompt_pack',
+ status: 'completed',
+ path: promptPath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [input.shotSpecId, input.character.id, styleContract.id],
+ metadata: { contract: 'stickman-visual-profile-prompt-v2' }
+ });
+}
+
+describe('stickman scoped images', () => {
+ it('submits the selected character and previous linked shot with the current prompt contract', async () => {
+ const { db, repository, templates, service } = setup();
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: {
+ characterAsset: { assetId: 'stickman.character.tech-guy', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.minimal-ink', revision: 1 },
+ characterPrompt: '恶意覆盖角色描述',
+ }
+ });
+ const shotSpecPath = join(tempDir, 'fixed-character-shot.json');
+ writeFileSync(shotSpecPath, JSON.stringify({
+ scriptArtifactId: 'script-1',
+ audioTimingArtifactId: 'audio-timing-1',
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ shots: [{
+ id: 'shot-01',
+ sourceSegmentId: 'segment-01',
+ semanticAnchor: '讲解重点',
+ visualDescription: '站在白板旁讲解',
+ compositionAndAction: '人物站在白板左侧并指向图形',
+ keyObjects: ['白板'],
+ continuityReason: '',
+ motion: 'static',
+ motionReason: '保持讲解稳定',
+ startSeconds: 0,
+ endSeconds: 4,
+ durationSeconds: 4
+ }, {
+ id: 'shot-02',
+ sourceSegmentId: 'segment-02',
+ semanticAnchor: 'continue the same scene',
+ visualDescription: 'show the same object from a closer camera',
+ compositionAndAction: 'move the camera closer while preserving the scene',
+ keyObjects: ['same object'],
+ continuityReason: 'continue the object and location established in the previous shot',
+ motion: 'push-in',
+ motionReason: 'focus on the recurring object',
+ startSeconds: 4,
+ endSeconds: 8,
+ durationSeconds: 4
+ }]
+ }));
+ repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_spec',
+ status: 'completed',
+ path: shotSpecPath,
+ sha256: 'a'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const character = await sharp({
+ create: {
+ width: 128,
+ height: 128,
+ channels: 4,
+ background: { r: 17, g: 17, b: 17, alpha: 0.25 }
+ }
+ }).png().toBuffer();
+ const characterPath = join(tempDir, 'tech-guy.png');
+ writeFileSync(characterPath, character);
+ const characterArtifact = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'character_reference',
+ status: 'completed',
+ path: characterPath,
+ sha256: createHash('sha256').update(character).digest('hex'),
+ sourceArtifactIds: [],
+ metadata: {
+ assetId: 'stickman.character.tech-guy',
+ revision: 1,
+ mimeType: 'image/png'
+ }
+ });
+ insertImageContracts({
+ repository,
+ jobId: job.id,
+ shotSpecId: service.getJob(job.id)!.artifacts.find(artifact => artifact.kind === 'shot_spec')!.id,
+ character: characterArtifact,
+ characterAssetId: 'stickman.character.tech-guy',
+ prompts: [{
+ shotId: 'shot-02',
+ visualDescription: '站在白板旁讲解',
+ prompt: 'compiled visual profile prompt for 站在白板旁讲解'
+ }]
+ });
+ const previousShot = await sharp({
+ create: { width: 320, height: 180, channels: 4, background: '#777777' }
+ }).png().toBuffer();
+ const previousShotPath = join(tempDir, 'shot-01.png');
+ writeFileSync(previousShotPath, previousShot);
+ const previousShotArtifact = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: previousShotPath,
+ sha256: createHash('sha256').update(previousShot).digest('hex'),
+ sourceArtifactIds: [],
+ scopeKey: 'shot-01',
+ inputFingerprint: '0'.repeat(64),
+ metadata: { mimeType: 'image/png' }
+ });
+ const stage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'queued',
+ scopeKey: 'shot-02',
+ inputFingerprint: '1'.repeat(64)
+ });
+ const image = await sharp({
+ create: { width: 320, height: 180, channels: 4, background: '#ffffff' }
+ }).png().toBuffer();
+ let submittedPrompt = '';
+ let submittedReferences: Buffer[] = [];
+ let candidateValidations = 0;
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ workRoot: join(tempDir, 'jobs'),
+ executors: [createStickmanImageExecutor({
+ configStore: { read: async () => createDefaultCreatorServicesConfig() },
+ ledger: new CreatorProviderRequestLedger(repository),
+ async validateCandidate() {
+ candidateValidations += 1;
+ if (candidateValidations === 1) throw new Error('visible text detected');
+ return acceptCandidate();
+ },
+ async generate(request, _config, options) {
+ submittedPrompt = request.prompt;
+ submittedReferences = options?.referenceImages?.map(reference => reference.content) ?? [];
+ return {
+ model: 'test-image',
+ contents: [{ mime: 'image/png' as const, content: image }]
+ };
+ }
+ })]
+ });
+
+ const completed = await runner.runStageRun(stage.id);
+ expect(completed.status).toBe('succeeded');
+ expect(submittedPrompt).toContain('compiled visual profile prompt for 站在白板旁讲解');
+ expect(submittedPrompt).not.toContain('恶意覆盖角色描述');
+ expect(submittedReferences).toHaveLength(2);
+ expect(createHash('sha256').update(submittedReferences[0]!).digest('hex'))
+ .toBe(createHash('sha256').update(character).digest('hex'));
+ expect(createHash('sha256').update(submittedReferences[1]!).digest('hex'))
+ .toBe(createHash('sha256').update(previousShot).digest('hex'));
+ expect(await sharp(submittedReferences[0]!).metadata()).toMatchObject({
+ format: 'png',
+ channels: 4,
+ hasAlpha: true
+ });
+ expect(submittedPrompt).toContain('Regenerate from scratch');
+ expect(service.getJob(job.id)!.providerRequests).toHaveLength(2);
+ const imageArtifact = service.getJob(job.id)!.artifacts.find(artifact => (
+ artifact.kind === 'shot_image' && artifact.scopeKey === 'shot-02'
+ ));
+ expect(imageArtifact?.metadata).toMatchObject({
+ candidateAttempt: 2,
+ candidateFailures: ['visible text detected'],
+ characterReferenceSha256: createHash('sha256').update(character).digest('hex'),
+ characterReferenceMime: 'image/png',
+ referenceImages: [{
+ role: 'character_identity',
+ sha256: createHash('sha256').update(submittedReferences[0]!).digest('hex'),
+ mimeType: 'image/png',
+ artifactId: characterArtifact.id
+ }, {
+ role: 'previous_shot',
+ sha256: createHash('sha256').update(submittedReferences[1]!).digest('hex'),
+ mimeType: 'image/png',
+ artifactId: previousShotArtifact.id
+ }],
+ previousShotArtifactId: previousShotArtifact.id,
+ previousShotSha256: createHash('sha256').update(previousShot).digest('hex'),
+ characterAssetId: 'stickman.character.tech-guy',
+ styleAssetId: 'stickman.style.minimal-ink',
+ referenceImagePreparation: 'original-bytes-v2',
+ imagePromptContract: 'stickman-visual-profile-prompt-v2'
+ });
+ expect(imageArtifact?.sourceArtifactIds).toContain(previousShotArtifact.id);
+
+ const retryStage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'queued',
+ scopeKey: 'shot-02',
+ inputFingerprint: '1'.repeat(64)
+ });
+ const retried = await runner.runStageRun(retryStage.id);
+ expect(retried.status).toBe('succeeded');
+ const candidateOneRequests = service.getJob(job.id)!.providerRequests.filter(request => (
+ request.requestKey.endsWith(':candidate:1')
+ ));
+ expect(candidateOneRequests).toMatchObject([
+ { generation: 1, status: 'succeeded' },
+ { generation: 2, status: 'succeeded', resubmissionOf: candidateOneRequests[0]!.id }
+ ]);
+ await runner.close();
+ db.close();
+ });
+
+ it('normalizes the configured provider output to the 16:9 video canvas', async () => {
+ const { db, repository, templates, service } = setup();
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: { styleAsset: { assetId: 'stickman.style.minimal-ink', revision: 1 } }
+ });
+ const shotSpecPath = join(tempDir, 'invalid-ratio-shot.json');
+ writeFileSync(shotSpecPath, JSON.stringify({
+ scriptArtifactId: 'script-1',
+ audioTimingArtifactId: 'audio-timing-1',
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ shots: [{
+ id: 'shot-01',
+ sourceSegmentId: 'segment-01',
+ semanticAnchor: '16:9 scene',
+ visualDescription: '16:9 scene',
+ compositionAndAction: '人物居中',
+ keyObjects: ['人物'],
+ continuityReason: '',
+ motion: 'static',
+ motionReason: '静态说明',
+ startSeconds: 0,
+ endSeconds: 4,
+ durationSeconds: 4
+ }]
+ }));
+ const shotSpecArtifact = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_spec',
+ status: 'completed',
+ path: shotSpecPath,
+ sha256: 'a'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const referencePath = join(tempDir, 'default.png');
+ const reference = await sharp({
+ create: { width: 100, height: 100, channels: 4, background: '#333333' }
+ }).png().toBuffer();
+ writeFileSync(referencePath, reference);
+ const characterArtifact = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'character_reference',
+ status: 'completed',
+ path: referencePath,
+ sha256: createHash('sha256').update(reference).digest('hex'),
+ sourceArtifactIds: [],
+ metadata: { assetId: 'stickman.character.default', revision: 1, mimeType: 'image/png' }
+ });
+ insertImageContracts({
+ repository,
+ jobId: job.id,
+ shotSpecId: shotSpecArtifact.id,
+ character: characterArtifact,
+ characterAssetId: 'stickman.character.default',
+ prompts: [{ shotId: 'shot-01', visualDescription: '16:9 scene', prompt: '16:9 scene' }]
+ });
+ const stage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'queued',
+ scopeKey: 'shot-01',
+ inputFingerprint: '1'.repeat(64)
+ });
+ const invalidImage = await sharp({
+ create: { width: 300, height: 200, channels: 4, background: '#ffffff' }
+ }).png().toBuffer();
+ let attempts = 0;
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ workRoot: join(tempDir, 'jobs'),
+ executors: [createStickmanImageExecutor({
+ configStore: { read: async () => createDefaultCreatorServicesConfig() },
+ ledger: new CreatorProviderRequestLedger(repository),
+ validateCandidate: acceptCandidate,
+ async generate() {
+ attempts += 1;
+ return {
+ model: 'test-image',
+ contents: [{ mime: 'image/png' as const, content: invalidImage }]
+ };
+ }
+ })]
+ });
+
+ const completed = await runner.runStageRun(stage.id);
+ expect(completed.status).toBe('succeeded');
+ const generated = service.getJob(job.id)!.artifacts.find(artifact => artifact.kind === 'shot_image');
+ expect(await sharp(generated!.path!).metadata()).toMatchObject({ width: 1280, height: 720 });
+ expect(attempts).toBe(1);
+ expect(service.getJob(job.id)!.providerRequests).toHaveLength(1);
+ await runner.close();
+ db.close();
+ });
+
+ it('keeps successful shot artifacts when another scope fails', async () => {
+ const { db, repository, templates, service } = setup();
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: { styleAsset: { assetId: 'stickman.style.minimal-ink', revision: 1 } }
+ });
+ const shotSpecPath = join(tempDir, 'shot-spec.json');
+ writeFileSync(shotSpecPath, JSON.stringify(shotSpecValue()));
+ repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_spec',
+ status: 'completed',
+ path: shotSpecPath,
+ sha256: 'a'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const reference = await sharp({
+ create: { width: 100, height: 100, channels: 4, background: '#222222' }
+ }).png().toBuffer();
+ const referencePath = join(tempDir, 'default.png');
+ writeFileSync(referencePath, reference);
+ const characterArtifact = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'character_reference',
+ status: 'completed',
+ path: referencePath,
+ sha256: createHash('sha256').update(reference).digest('hex'),
+ sourceArtifactIds: [],
+ metadata: { assetId: 'stickman.character.default', revision: 1, mimeType: 'image/png' }
+ });
+ insertImageContracts({
+ repository,
+ jobId: job.id,
+ shotSpecId: service.getJob(job.id)!.artifacts.find(artifact => artifact.kind === 'shot_spec')!.id,
+ character: characterArtifact,
+ characterAssetId: 'stickman.character.default',
+ prompts: shotSpecValue().shots.map(shot => ({
+ shotId: shot.id,
+ visualDescription: shot.visualDescription,
+ prompt: shot.visualDescription
+ }))
+ });
+ const runs = shotSpecValue().shots.map((shot, index) => repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'queued',
+ scopeKey: shot.id,
+ inputFingerprint: String(index + 1).repeat(64)
+ }));
+ const config = createDefaultCreatorServicesConfig();
+ const validImage = await sharp({
+ create: { width: 320, height: 180, channels: 4, background: '#fefefe' }
+ }).png().toBuffer();
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ workRoot: join(tempDir, 'jobs'),
+ maxConcurrency: 3,
+ executors: [createStickmanImageExecutor({
+ configStore: { read: async () => config },
+ ledger: new CreatorProviderRequestLedger(repository),
+ validateCandidate: acceptCandidate,
+ async generate(request) {
+ if (request.prompt.includes('fail two')) throw new Error('injected provider failure');
+ return {
+ model: 'test-image',
+ contents: [{ mime: 'image/png', content: validImage }]
+ };
+ }
+ })]
+ });
+
+ const results = await Promise.all(runs.map(run => runner.runStageRun(run.id)));
+ const completed = service.getJob(job.id)!;
+
+ expect(results.map(run => run.status).sort()).toEqual(['failed', 'succeeded', 'succeeded']);
+ expect(completed.artifacts
+ .filter(artifact => artifact.kind === 'shot_image')
+ .sort((left, right) => (left.scopeKey ?? '').localeCompare(right.scopeKey ?? ''))).toMatchObject([
+ { scopeKey: 'shot-01', status: 'completed', sha256: expect.stringMatching(/^[a-f0-9]{64}$/) },
+ { scopeKey: 'shot-03', status: 'completed', sha256: expect.stringMatching(/^[a-f0-9]{64}$/) }
+ ]);
+ expect(completed).toMatchObject({
+ status: 'needs_input',
+ state: { needsInput: { scopeKey: 'shot-02' } }
+ });
+ expect(completed.providerRequests).toHaveLength(3);
+ await runner.close();
+ db.close();
+ });
+
+ it('regenerates one shot and stales only its transitive dependents', () => {
+ const { db, repository, service } = setup();
+ const job = service.createJob({ projectId: 'p1', templateId: 'stickman-video' });
+ const shotSpecPath = join(tempDir, 'shot-spec.json');
+ writeFileSync(shotSpecPath, JSON.stringify(shotSpecValue()));
+ const shotSpec = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_spec',
+ status: 'completed',
+ path: shotSpecPath,
+ sha256: 'a'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const images = ['shot-01', 'shot-02', 'shot-03'].map((scopeKey, index) => repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey,
+ inputFingerprint: String(index + 1).repeat(64),
+ sha256: String.fromCharCode(98 + index).repeat(64),
+ sourceArtifactIds: [shotSpec.id],
+ metadata: {}
+ }));
+ const validation = repository.insertArtifact({ jobId: job.id, kind: 'visual_validation', status: 'completed', path: null, sourceArtifactIds: images.map(image => image.id), metadata: {} });
+ const timeline = repository.insertArtifact({ jobId: job.id, kind: 'timeline_manifest', status: 'completed', path: null, sourceArtifactIds: [validation.id, ...images.map(image => image.id)], metadata: {} });
+ const clean = repository.insertArtifact({ jobId: job.id, kind: 'clean_video', status: 'completed', path: null, sourceArtifactIds: [timeline.id], metadata: {} });
+
+ const response = service.applyAction(job.id, {
+ actor: 'user',
+ action: 'edit-shot',
+ expectedRevision: 0,
+ input: {
+ artifactId: shotSpec.id,
+ scopeKey: 'shot-02',
+ patch: { visualDescription: 'updated shot two' },
+ revision: 0
+ }
+ });
+
+ expect(response.job.artifacts.find(item => item.id === images[0]!.id)?.status).toBe('completed');
+ expect(response.job.artifacts.find(item => item.id === images[2]!.id)?.status).toBe('completed');
+ expect(response.job.artifacts.find(item => item.id === images[1]!.id)?.status).toBe('stale');
+ expect(response.job.artifacts.find(item => item.id === validation.id)?.status).toBe('stale');
+ expect(response.job.artifacts.find(item => item.id === timeline.id)?.status).toBe('stale');
+ expect(response.job.artifacts.find(item => item.id === clean.id)?.status).toBe('stale');
+ expect(response.job.artifacts.find(item => item.id === images[0]!.id)?.sha256).toBe('b'.repeat(64));
+ expect(response.job.artifacts.find(item => item.id === images[2]!.id)?.sha256).toBe('d'.repeat(64));
+ db.close();
+ });
+
+ it('cleans historical duplicate images before retrying visual validation', () => {
+ const { db, repository, service } = setup();
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: { currentStage: 'visual-validation', workflowTarget: 'visuals_ready' }
+ });
+ repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'succeeded',
+ scopeKey: 'shot-03',
+ inputFingerprint: 'a'.repeat(64)
+ });
+ const oldImage = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-03',
+ inputFingerprint: 'a'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'succeeded',
+ scopeKey: 'shot-03',
+ inputFingerprint: 'b'.repeat(64)
+ });
+ const currentImage = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-03',
+ inputFingerprint: 'b'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const oldValidation = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'visual_validation',
+ status: 'completed',
+ path: null,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [oldImage.id],
+ metadata: {}
+ });
+ repository.updateJob({
+ id: job.id,
+ status: 'failed',
+ revision: job.revision,
+ state: job.state
+ });
+ const failedJob = service.getJob(job.id)!;
+
+ const response = service.applyAction(job.id, {
+ actor: 'user',
+ action: 'generate-missing-shots',
+ expectedRevision: failedJob.revision,
+ input: { revision: failedJob.revision }
+ });
+
+ expect(response.job.artifacts.find(artifact => artifact.id === oldImage.id)?.status).toBe('stale');
+ expect(response.job.artifacts.find(artifact => artifact.id === currentImage.id)?.status).toBe('completed');
+ expect(response.job.artifacts.find(artifact => artifact.id === oldValidation.id)?.status).toBe('stale');
+ expect(response.job).toMatchObject({
+ status: 'running',
+ state: { currentStage: 'images', workflowTarget: 'visuals_ready' }
+ });
+ db.close();
+ });
+
+ it('invalidates only visual descendants when the selected asset revision changes', () => {
+ const { db, repository, service } = setup();
+ const created = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: {
+ characterAsset: { assetId: 'stickman.character.default', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.paper-pencil', revision: 1 }
+ }
+ });
+ const script = repository.insertArtifact({ jobId: created.id, kind: 'script_manifest', status: 'completed', path: null, sourceArtifactIds: [], metadata: {} });
+ const audio = repository.insertArtifact({ jobId: created.id, kind: 'narration_audio', status: 'completed', path: null, sourceArtifactIds: [script.id], metadata: {} });
+ const shotSpec = repository.insertArtifact({ jobId: created.id, kind: 'shot_spec', status: 'completed', path: null, sha256: '1'.repeat(64), sourceArtifactIds: [script.id, audio.id], metadata: {} });
+ const character = repository.insertArtifact({ jobId: created.id, kind: 'character_reference', status: 'completed', path: null, sha256: '2'.repeat(64), sourceArtifactIds: [shotSpec.id], metadata: {} });
+ const contract = repository.insertArtifact({ jobId: created.id, kind: 'style_contract', status: 'completed', path: null, sha256: '3'.repeat(64), sourceArtifactIds: [shotSpec.id], metadata: {} });
+ const prompt = repository.insertArtifact({ jobId: created.id, kind: 'image_prompt_pack', status: 'completed', path: null, sha256: '4'.repeat(64), sourceArtifactIds: [shotSpec.id, character.id, contract.id], metadata: {} });
+ const image = repository.insertArtifact({ jobId: created.id, kind: 'shot_image', status: 'completed', path: null, sha256: '5'.repeat(64), scopeKey: 'shot-01', inputFingerprint: '6'.repeat(64), sourceArtifactIds: [prompt.id, character.id, contract.id], metadata: {} });
+ const validation = repository.insertArtifact({ jobId: created.id, kind: 'visual_validation', status: 'completed', path: null, sourceArtifactIds: [image.id], metadata: {} });
+ const timeline = repository.insertArtifact({ jobId: created.id, kind: 'timeline_manifest', status: 'completed', path: null, sourceArtifactIds: [validation.id, audio.id], metadata: {} });
+
+ const before = service.getJob(created.id)!;
+ const fingerprint = stickmanShotFingerprint({
+ shot: shotSpecValue().shots[0],
+ job: before,
+ shotSpec,
+ characterReference: character,
+ styleContract: contract,
+ promptPack: prompt,
+ settings: { provider: 'openai', model: 'gpt-image-1', quality: 'medium' }
+ });
+ const response = service.applyAction(created.id, {
+ actor: 'user',
+ action: 'update-settings',
+ expectedRevision: created.revision,
+ input: {
+ patch: { styleAsset: { assetId: 'stickman.style.paper-pencil', revision: 2 } },
+ activityMode: 'semantic',
+ objectId: 'styleAsset'
+ }
+ });
+
+ for (const artifact of [script, audio, shotSpec]) {
+ expect(response.job.artifacts.find(candidate => candidate.id === artifact.id)?.status)
+ .toBe('completed');
+ }
+ for (const artifact of [character, contract, prompt, image, validation, timeline]) {
+ expect(response.job.artifacts.find(candidate => candidate.id === artifact.id)?.status)
+ .toBe('stale');
+ }
+ expect(response.job.state.styleAsset).toEqual({
+ assetId: 'stickman.style.paper-pencil',
+ revision: 2
+ });
+ expect(stickmanShotFingerprint({
+ shot: shotSpecValue().shots[0],
+ job: response.job,
+ shotSpec,
+ characterReference: character,
+ styleContract: contract,
+ promptPack: prompt,
+ settings: { provider: 'openai', model: 'gpt-image-1', quality: 'medium' }
+ })).not.toBe(fingerprint);
+ expect(stickmanShotFingerprint({
+ shot: shotSpecValue().shots[0],
+ job: before,
+ shotSpec,
+ characterReference: character,
+ styleContract: { ...contract, sha256: '9'.repeat(64) },
+ promptPack: prompt,
+ settings: { provider: 'openai', model: 'gpt-image-1', quality: 'medium' }
+ })).not.toBe(fingerprint);
+ expect(stickmanShotFingerprint({
+ shot: shotSpecValue().shots[0],
+ job: before,
+ shotSpec,
+ characterReference: character,
+ styleContract: contract,
+ promptPack: prompt,
+ previousShotImage: { ...image, sha256: '8'.repeat(64) },
+ settings: { provider: 'openai', model: 'gpt-image-1', quality: 'medium' }
+ })).not.toBe(fingerprint);
+ db.close();
+ });
+});
diff --git a/apps/daemon/test/unit/creator-stickman-krillin.test.ts b/apps/daemon/test/unit/creator-stickman-krillin.test.ts
new file mode 100644
index 00000000..70497b57
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-krillin.test.ts
@@ -0,0 +1,129 @@
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, describe, expect, it } from 'vitest';
+import {
+ buildKrillinStageOptions,
+ resolveKrillinStageContract,
+ validateResultArtifacts
+} from '../../src/creator/krillin/adapter.js';
+import {
+ buildKrillinCliCommandArguments,
+ outputMappings
+} from '../../src/creator/krillin/cli-runner.js';
+
+let tempDir = '';
+
+afterEach(() => {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = '';
+});
+
+function stage(stageId: string) {
+ return {
+ job: { id: 'job-1', templateId: 'stickman-video', state: {} },
+ stageRun: { id: 'stage-1', stageId, progress: {} },
+ inputArtifacts: []
+ } as never;
+}
+
+describe('stickman KrillinAI mapping', () => {
+ it('maps semantic stages onto the existing Krillin stage enum', () => {
+ expect(resolveKrillinStageContract(stage('source-transcript'))).toMatchObject({
+ stageType: 'subtitle',
+ requiredOutputKinds: ['source_subtitle']
+ });
+ expect(resolveKrillinStageContract(stage('narration'))).toMatchObject({
+ stageType: 'tts',
+ outputAliases: { dubbed_audio: 'narration_audio' }
+ });
+ expect(resolveKrillinStageContract(stage('subtitles'))).toMatchObject({
+ stageType: 'subtitle',
+ requiredOutputKinds: ['bilingual_subtitle']
+ });
+ expect(resolveKrillinStageContract(stage('bilingual-render'))).toMatchObject({
+ stageType: 'render-horizontal',
+ outputAliases: { horizontal_video: 'bilingual_video' }
+ });
+ expect(outputMappings('narration')).toEqual([['tts_audio', 'narration_audio']]);
+ expect(outputMappings('bilingual-render')).toEqual([['horizontal_video', 'bilingual_video']]);
+ });
+
+ it('uses source-only only for the stickman transcript stage', () => {
+ const sourceTranscript = {
+ workdir: 'job/source-transcript',
+ job: {
+ id: 'job-1',
+ templateId: 'stickman-video',
+ state: {
+ sourceUrl: 'https://www.youtube.com/watch?v=abc',
+ sourceLanguage: 'auto',
+ targetLanguage: 'zh_cn'
+ }
+ },
+ stageRun: { id: 'stage-1', stageId: 'source-transcript', progress: {} },
+ inputArtifacts: [],
+ signal: new AbortController().signal,
+ reportProgress() {}
+ };
+ const stickmanOptions = buildKrillinStageOptions(sourceTranscript as never);
+ expect(stickmanOptions.sourceOnly).toBe(true);
+ expect(buildKrillinCliCommandArguments(
+ sourceTranscript as never,
+ [],
+ stickmanOptions,
+ undefined
+ )).toContain('--source-only');
+
+ const translationStage = {
+ ...sourceTranscript,
+ job: { ...sourceTranscript.job, templateId: 'video-translation' },
+ stageRun: { ...sourceTranscript.stageRun, stageId: 'subtitle' }
+ };
+ const translationOptions = buildKrillinStageOptions(translationStage as never);
+ expect(translationOptions.sourceOnly).toBe(false);
+ expect(buildKrillinCliCommandArguments(
+ translationStage as never,
+ [],
+ translationOptions,
+ undefined
+ )).not.toContain('--source-only');
+ });
+
+ it('rejects undeclared or missing stickman outputs and aliases valid subtitles', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-krillin-'));
+ const jobRoot = join(tempDir, 'job-1');
+ mkdirSync(jobRoot, { recursive: true });
+
+ await expect(validateResultArtifacts({
+ stage: stage('source-transcript'),
+ jobsRoot: tempDir,
+ artifacts: [],
+ ffprobe: 'unused'
+ })).rejects.toMatchObject({ code: 'krillin_output_missing' });
+ await expect(validateResultArtifacts({
+ stage: stage('source-transcript'),
+ jobsRoot: tempDir,
+ artifacts: [{
+ id: 'bad',
+ kind: 'vertical_video',
+ relativePath: 'job-1/bad.mp4'
+ }],
+ ffprobe: 'unused'
+ })).rejects.toMatchObject({ code: 'krillin_output_mismatch' });
+
+ const subtitlePath = join(jobRoot, 'source.srt');
+ writeFileSync(subtitlePath, '1\n00:00:00,000 --> 00:00:01,000\n测试\n');
+ const outputs = await validateResultArtifacts({
+ stage: stage('source-transcript'),
+ jobsRoot: tempDir,
+ artifacts: [{
+ id: 'source-subtitle',
+ kind: 'source_subtitle',
+ relativePath: 'job-1/source.srt'
+ }],
+ ffprobe: 'unused'
+ });
+ expect(outputs).toMatchObject([{ kind: 'source_subtitle', status: 'completed' }]);
+ });
+});
diff --git a/apps/daemon/test/unit/creator-stickman-media-validation.test.ts b/apps/daemon/test/unit/creator-stickman-media-validation.test.ts
new file mode 100644
index 00000000..2fe56247
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-media-validation.test.ts
@@ -0,0 +1,153 @@
+import { createHash } from 'node:crypto';
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, describe, expect, it } from 'vitest';
+import type { CreatorArtifact } from '@opencreator/protocol';
+import { createStickmanMediaValidationExecutor } from '../../src/creator/stickman/media-validation-executor.js';
+
+let tempRoot = '';
+
+afterEach(() => {
+ if (tempRoot) rmSync(tempRoot, { recursive: true, force: true });
+ tempRoot = '';
+});
+
+describe('stickman media validation executor', () => {
+ it('binds ffprobe and exactly three frame samples to the current Remotion output', async () => {
+ const fixture = setup();
+ const result = await createStickmanMediaValidationExecutor({
+ ffprobePath: 'unused',
+ ffmpegPath: 'unused',
+ validateVideo: async () => ({
+ duration: 2,
+ width: 1280,
+ height: 720,
+ hasVideo: true,
+ hasAudio: true
+ }),
+ sampleFrames: async () => [1, 2, 3].map(index => ({
+ index,
+ timestampSeconds: index / 2,
+ sha256: String(index).repeat(64),
+ width: 1280 as const,
+ height: 720 as const,
+ brightnessMean: 180,
+ contrastStddev: 20
+ }))
+ }).run(fixture.input as never);
+
+ expect(result.outputs).toHaveLength(1);
+ expect(result.outputs[0]).toMatchObject({
+ kind: 'media_validation',
+ status: 'completed',
+ sourceArtifactIds: ['clean-1', 'timeline-1'],
+ metadata: { sampleCount: 3, width: 1280, height: 720 }
+ });
+ expect(JSON.parse(readFileSync(result.outputs[0]!.path!, 'utf8'))).toMatchObject({
+ ok: true,
+ cleanVideoArtifactId: 'clean-1',
+ timelineArtifactId: 'timeline-1',
+ sampledFrames: [{ index: 1 }, { index: 2 }, { index: 3 }]
+ });
+ });
+
+ it('rejects stale hashes, wrong lineage, and insufficient frame evidence', async () => {
+ let fixture = setup();
+ fixture.input.inputArtifacts[0]!.sha256 = '0'.repeat(64);
+ await expect(run(fixture)).rejects.toMatchObject({ code: 'creator_media_validation_hash_mismatch' });
+
+ fixture = setup();
+ fixture.input.inputArtifacts[0]!.sourceArtifactIds = [];
+ await expect(run(fixture)).rejects.toMatchObject({ code: 'creator_media_validation_lineage_mismatch' });
+
+ fixture = setup();
+ await expect(run(fixture, 2)).rejects.toMatchObject({ code: 'creator_media_validation_frame_count' });
+ });
+});
+
+function setup() {
+ if (tempRoot) rmSync(tempRoot, { recursive: true, force: true });
+ tempRoot = mkdtempSync(join(tmpdir(), 'creator-stickman-media-validation-'));
+ const jobRoot = join(tempRoot, 'job-1');
+ const sourceRoot = join(jobRoot, 'source');
+ const workdir = join(jobRoot, 'stage-media-validation');
+ mkdirSync(sourceRoot, { recursive: true });
+ mkdirSync(workdir, { recursive: true });
+ const timelinePath = join(sourceRoot, 'timeline.json');
+ writeFileSync(timelinePath, JSON.stringify({
+ fps: 30,
+ width: 1280,
+ height: 720,
+ totalFrames: 60,
+ shots: [{
+ shotId: 'shot-01',
+ startFrame: 0,
+ endFrame: 60,
+ imageArtifactId: 'image-1',
+ audioArtifactId: 'audio-1',
+ motion: 'static',
+ imageSha256: 'c'.repeat(64),
+ audioSha256: 'd'.repeat(64)
+ }]
+ }));
+ const cleanPath = join(sourceRoot, 'clean.mp4');
+ writeFileSync(cleanPath, 'validated remotion video');
+ const timeline = artifact('timeline-1', 'timeline_manifest', timelinePath, []);
+ const clean = artifact('clean-1', 'clean_video', cleanPath, [timeline.id]);
+ return {
+ input: {
+ stageRun: { id: 'stage-1', stageId: 'media-validation' },
+ job: { id: 'job-1' },
+ inputArtifacts: [clean, timeline],
+ workdir,
+ signal: new AbortController().signal,
+ reportProgress() {}
+ }
+ };
+}
+
+function run(fixture: ReturnType<typeof setup>, samples = 3) {
+ return createStickmanMediaValidationExecutor({
+ ffprobePath: 'unused',
+ ffmpegPath: 'unused',
+ validateVideo: async () => ({
+ duration: 2,
+ width: 1280,
+ height: 720,
+ hasVideo: true,
+ hasAudio: true
+ }),
+ sampleFrames: async () => Array.from({ length: samples }, (_, position) => ({
+ index: position + 1,
+ timestampSeconds: position,
+ sha256: String(position + 1).repeat(64),
+ width: 1280 as const,
+ height: 720 as const,
+ brightnessMean: 180,
+ contrastStddev: 20
+ }))
+ }).run(fixture.input as never);
+}
+
+function artifact(
+ id: string,
+ kind: string,
+ path: string,
+ sourceArtifactIds: string[]
+): CreatorArtifact {
+ return {
+ id,
+ jobId: 'job-1',
+ kind,
+ version: 1,
+ status: 'completed',
+ path,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: createHash('sha256').update(readFileSync(path)).digest('hex'),
+ sourceArtifactIds,
+ metadata: {},
+ createdAt: '2026-09-03T00:00:00.000Z'
+ };
+}
diff --git a/apps/daemon/test/unit/creator-stickman-migration.test.ts b/apps/daemon/test/unit/creator-stickman-migration.test.ts
new file mode 100644
index 00000000..65e32172
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-migration.test.ts
@@ -0,0 +1,118 @@
+import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, describe, expect, it } from 'vitest';
+import { createCreatorRepository } from '../../src/creator/repository.js';
+import {
+ migrateStickmanVisualAssetState,
+ purgeLegacyStickmanJobs
+} from '../../src/creator/stickman/legacy-migration.js';
+import { openRuntimeDatabase } from '../../src/storage/database.js';
+
+let tempDir = '';
+
+afterEach(() => {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = '';
+});
+
+describe('legacy stickman migration', () => {
+ it('purges only v1 jobs and resumes post-commit directory cleanup', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-migration-'));
+ const jobsRoot = join(tempDir, 'jobs');
+ mkdirSync(jobsRoot, { recursive: true });
+ const db = openRuntimeDatabase(join(tempDir, 'runtime.sqlite'));
+ const repository = createCreatorRepository(db);
+ const v1 = repository.createJob({ projectId: 'p1', templateId: 'stickman-video', templateVersion: 1, status: 'running', state: {} });
+ const v2 = repository.createJob({ projectId: 'p1', templateId: 'stickman-video', templateVersion: 2, status: 'draft', state: {} });
+ const other = repository.createJob({ projectId: 'p1', templateId: 'cover', templateVersion: 2, status: 'draft', state: {} });
+ for (const job of [v1, v2, other]) {
+ mkdirSync(join(jobsRoot, job.id), { recursive: true });
+ writeFileSync(join(jobsRoot, job.id, 'marker.txt'), job.id);
+ }
+ const stage = repository.createStageRun({ jobId: v1.id, stageId: 'render', executor: 'stickman', status: 'failed' });
+ repository.insertArtifact({ jobId: v1.id, kind: 'stickman_video', status: 'completed', path: null, sourceArtifactIds: [], metadata: {} });
+ repository.createProviderRequest({
+ jobId: v1.id,
+ provider: 'test',
+ stageRunId: stage.id,
+ requestKey: 'legacy-request',
+ requestHash: 'a'.repeat(64),
+ status: 'failed'
+ });
+ let interrupted = true;
+ const first = await purgeLegacyStickmanJobs({
+ db,
+ jobsRoot,
+ async removeDirectory(path) {
+ if (interrupted) {
+ interrupted = false;
+ throw new Error('injected cleanup interruption');
+ }
+ rmSync(path, { recursive: true, force: true });
+ }
+ });
+
+ expect(repository.getJob(v1.id)).toBeUndefined();
+ expect(repository.getJob(v2.id)).toBeDefined();
+ expect(repository.getJob(other.id)).toBeDefined();
+ expect(first).toMatchObject({ pendingJobIds: [v1.id], completed: false });
+ expect(existsSync(join(jobsRoot, v1.id))).toBe(true);
+
+ const second = await purgeLegacyStickmanJobs({ db, jobsRoot });
+ expect(second).toMatchObject({ pendingJobIds: [], completed: true });
+ expect(existsSync(join(jobsRoot, v1.id))).toBe(false);
+ expect(existsSync(join(jobsRoot, v2.id))).toBe(true);
+ expect(existsSync(join(jobsRoot, other.id))).toBe(true);
+ db.close();
+ });
+
+ it('rejects an escaped legacy job directory without deleting outside the jobs root', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-migration-'));
+ const jobsRoot = join(tempDir, 'jobs');
+ const outside = join(tempDir, 'outside');
+ mkdirSync(jobsRoot, { recursive: true });
+ mkdirSync(outside, { recursive: true });
+ writeFileSync(join(outside, 'keep.txt'), 'keep');
+ const db = openRuntimeDatabase(join(tempDir, 'runtime.sqlite'));
+ db.prepare(`
+ INSERT INTO creator_jobs (
+ id, project_id, template_id, template_version, status, revision,
+ state_json, created_at, updated_at
+ ) VALUES (?, 'p1', 'stickman-video', 1, 'draft', 0, '{}', ?, ?)
+ `).run('../outside', new Date().toISOString(), new Date().toISOString());
+
+ const result = await purgeLegacyStickmanJobs({ db, jobsRoot });
+
+ expect(result.blockedJobIds).toEqual(['../outside']);
+ expect(result.pendingJobIds).toEqual(['../outside']);
+ expect(existsSync(join(outside, 'keep.txt'))).toBe(true);
+ expect(db.prepare('SELECT id FROM creator_jobs WHERE id = ?').get('../outside')).toBeUndefined();
+ db.close();
+ });
+
+ it('migrates v2 character and style fields once without deleting task data', () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-migration-'));
+ const db = openRuntimeDatabase(join(tempDir, 'runtime.sqlite'));
+ const repository = createCreatorRepository(db);
+ const legacy = repository.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ templateVersion: 2,
+ status: 'completed',
+ state: { selectedPresetId: 'student', style: '漫画分镜线稿', retained: 'value' }
+ });
+
+ expect(migrateStickmanVisualAssetState({ db })).toEqual({ migratedJobIds: [legacy.id] });
+ expect(repository.getJob(legacy.id)?.state).toMatchObject({
+ characterAsset: { assetId: 'stickman.character.student', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.comic-storyboard', revision: 1 },
+ retained: 'value'
+ });
+ expect(repository.getJob(legacy.id)?.state).not.toHaveProperty('selectedPresetId');
+ expect(repository.getJob(legacy.id)?.state).not.toHaveProperty('style');
+ expect(repository.getJob(legacy.id)?.status).toBe('completed');
+ expect(migrateStickmanVisualAssetState({ db })).toEqual({ migratedJobIds: [] });
+ db.close();
+ });
+});
diff --git a/apps/daemon/test/unit/creator-stickman-recovery.test.ts b/apps/daemon/test/unit/creator-stickman-recovery.test.ts
new file mode 100644
index 00000000..db298ca3
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-recovery.test.ts
@@ -0,0 +1,325 @@
+import { mkdtempSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, describe, expect, it } from 'vitest';
+import { createCreatorAgentRepository } from '../../src/creator/agent/repository.js';
+import { createCreatorCommandDispatcher } from '../../src/creator/command-dispatcher.js';
+import { CreatorProviderRequestLedger } from '../../src/creator/provider-requests.js';
+import { createCreatorRepository } from '../../src/creator/repository.js';
+import { CreatorServiceError, createCreatorService } from '../../src/creator/service.js';
+import { createCreatorStageRunner } from '../../src/creator/stage-runner.js';
+import { createDefaultCreatorTemplateRegistry } from '../../src/creator/templates/registry.js';
+import { createStickmanVideoWorkflow } from '../../src/creator/templates/stickman-video-actions.js';
+import { openRuntimeDatabase } from '../../src/storage/database.js';
+
+let tempDir = '';
+
+afterEach(() => {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = '';
+});
+
+function setup() {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-recovery-'));
+ const db = openRuntimeDatabase(join(tempDir, 'runtime.sqlite'));
+ const repository = createCreatorRepository(db);
+ const templates = createDefaultCreatorTemplateRegistry();
+ const ledger = new CreatorProviderRequestLedger(repository);
+ const service = createCreatorService({
+ repository,
+ templates,
+ providerRequestLedger: ledger
+ });
+ const dispatcher = createCreatorCommandDispatcher({
+ service,
+ repository,
+ receipts: createCreatorAgentRepository(db)
+ });
+ const workflow = createStickmanVideoWorkflow({
+ creator: service,
+ dispatcher,
+ repository,
+ providerLedger: ledger
+ });
+ return { db, repository, service, dispatcher, ledger, workflow, templates };
+}
+
+describe('stickman video recovery', () => {
+ it('keeps pristine drafts idle during recovery', async () => {
+ const { db, service, workflow } = setup();
+ const job = service.createJob({ projectId: 'p1', templateId: 'stickman-video' });
+
+ await workflow.recover();
+
+ expect(service.getJob(job.id)).toMatchObject({ status: 'draft', stages: [] });
+ db.close();
+ });
+
+ it('does not enqueue a replacement while a failed stage is still updating the job', async () => {
+ const { db, repository, service, workflow } = setup();
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: { sourceType: 'url', sourceUrl: '' }
+ });
+ repository.updateJob({
+ id: job.id,
+ status: 'running',
+ revision: job.revision,
+ state: job.state
+ });
+ const failed = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'source-transcript',
+ executor: 'krillinai',
+ status: 'failed'
+ });
+
+ await workflow.handleStageChanged(failed);
+
+ expect(service.getJob(job.id)!.stages).toEqual([
+ expect.objectContaining({ id: failed.id, status: 'failed' })
+ ]);
+ db.close();
+ });
+
+ it('recovers interrupted scopes without duplicating unknown provider billing', async () => {
+ const { db, repository, service, ledger, workflow } = setup();
+ const converged = service.createJob({ projectId: 'p1', templateId: 'stickman-video' });
+ const fingerprint = 'a'.repeat(64);
+ const completedStage = repository.createStageRun({
+ jobId: converged.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'interrupted',
+ scopeKey: 'shot-01',
+ inputFingerprint: fingerprint
+ });
+ const artifact = repository.insertArtifact({
+ jobId: converged.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-01',
+ inputFingerprint: fingerprint,
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+
+ const unknown = service.createJob({ projectId: 'p2', templateId: 'stickman-video' });
+ const unknownStage = repository.createStageRun({
+ jobId: unknown.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'interrupted',
+ scopeKey: 'shot-02',
+ inputFingerprint: 'b'.repeat(64)
+ });
+ const request = ledger.registerBeforeSubmit({
+ jobId: unknown.id,
+ provider: 'openai',
+ stageRunId: unknownStage.id,
+ scopeKey: 'shot-02',
+ requestKey: 'unknown-request',
+ request: { prompt: 'test' }
+ });
+ ledger.markSubmitting(request.id);
+
+ await workflow.recover();
+
+ expect(repository.getStageRun(completedStage.id)).toMatchObject({
+ status: 'succeeded',
+ progress: { recoveredArtifactId: artifact.id }
+ });
+ expect(repository.getProviderRequest(request.id)?.status).toBe('unknown_remote_acceptance');
+ expect(service.getJob(unknown.id)).toMatchObject({
+ status: 'needs_input',
+ state: { needsInput: { code: 'creator_provider_resolution_required' } }
+ });
+ expect(service.getJob(unknown.id)!.stages).toHaveLength(1);
+ db.close();
+ });
+
+ it('resumes an interrupted scope only when no remote side effect exists', async () => {
+ const { db, repository, service, workflow } = setup();
+ const job = service.createJob({ projectId: 'p1', templateId: 'stickman-video' });
+ const interrupted = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'interrupted',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'c'.repeat(64)
+ });
+
+ await workflow.recover();
+
+ expect(service.getJob(job.id)!.stages).toContainEqual(expect.objectContaining({
+ stageId: 'images',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'c'.repeat(64),
+ status: 'queued',
+ progress: expect.objectContaining({ resumedFromStageRunId: interrupted.id })
+ }));
+ db.close();
+ });
+
+ it('cancels every active scope and preserves completed artifacts', () => {
+ const { db, repository, service, templates } = setup();
+ const job = service.createJob({ projectId: 'p1', templateId: 'stickman-video' });
+ repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'queued',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'd'.repeat(64)
+ });
+ repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'queued',
+ scopeKey: 'shot-02',
+ inputFingerprint: 'e'.repeat(64)
+ });
+ const completed = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-00',
+ inputFingerprint: 'f'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ executors: [],
+ workRoot: join(tempDir, 'jobs')
+ });
+
+ expect(runner.cancelJob(job.id)).toHaveLength(2);
+ expect(service.getJob(job.id)!.stages.map(stage => stage.status)).toEqual([
+ 'canceled',
+ 'canceled'
+ ]);
+ expect(service.getJob(job.id)!.artifacts.find(item => item.id === completed.id)?.status)
+ .toBe('completed');
+ db.close();
+ });
+
+ it('rejects stale agent revisions and agent duplicate-billing confirmation', () => {
+ const { db, repository, service, ledger } = setup();
+ const job = service.createJob({ projectId: 'p1', templateId: 'stickman-video' });
+ const stage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'interrupted',
+ scopeKey: 'shot-01',
+ inputFingerprint: '1'.repeat(64)
+ });
+ const request = ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai',
+ stageRunId: stage.id,
+ scopeKey: 'shot-01',
+ requestKey: 'agent-guard',
+ request: { prompt: 'test' }
+ });
+ ledger.markSubmitting(request.id);
+ ledger.markUnknownRemoteAcceptance(request.id);
+ const updated = service.applyAction(job.id, {
+ actor: 'user',
+ action: 'update-settings',
+ expectedRevision: job.revision,
+ input: { patch: { style: 'new' }, activityMode: 'semantic', objectId: 'style' }
+ }).job;
+
+ expect(() => service.applyAction(job.id, {
+ actor: 'agent',
+ action: 'update-settings',
+ expectedRevision: job.revision,
+ input: { patch: { style: 'stale' }, activityMode: 'semantic', objectId: 'style' }
+ })).toThrowError(expect.objectContaining<Partial<CreatorServiceError>>({
+ code: 'creator_revision_conflict',
+ latestRevision: updated.revision
+ }));
+ expect(() => service.applyAction(job.id, {
+ actor: 'agent',
+ action: 'resolve-provider-request',
+ expectedRevision: updated.revision,
+ input: {
+ ledgerId: request.id,
+ revision: updated.revision,
+ decision: 'confirm-resubmit',
+ acceptDuplicateBilling: true
+ }
+ })).toThrowError(expect.objectContaining<Partial<CreatorServiceError>>({
+ code: 'creator_provider_confirmation_required'
+ }));
+ db.close();
+ });
+
+ it('rejects shot regeneration while provider acceptance is unresolved', () => {
+ const { db, repository, service, ledger } = setup();
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: { currentStage: 'images', workflowTarget: 'visuals_ready' }
+ });
+ const fingerprint = '2'.repeat(64);
+ const stage = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'images',
+ executor: 'stickman-image',
+ status: 'interrupted',
+ scopeKey: 'shot-02',
+ inputFingerprint: fingerprint
+ });
+ const request = ledger.registerBeforeSubmit({
+ jobId: job.id,
+ provider: 'openai',
+ stageRunId: stage.id,
+ scopeKey: 'shot-02',
+ requestKey: 'unresolved-regeneration',
+ request: { prompt: 'test' }
+ });
+ ledger.markSubmitting(request.id);
+ ledger.markUnknownRemoteAcceptance(request.id);
+ const waiting = service.setNeedsInput(job.id, {
+ code: 'creator_provider_resolution_required',
+ message: 'Provider request acceptance is unknown',
+ resumeStageId: 'images'
+ });
+
+ expect(() => service.applyAction(job.id, {
+ actor: 'user',
+ action: 'regenerate-shot',
+ expectedRevision: waiting.revision,
+ input: {
+ scopeKey: 'shot-02',
+ inputFingerprint: fingerprint,
+ revision: waiting.revision
+ }
+ })).toThrowError(expect.objectContaining<Partial<CreatorServiceError>>({
+ code: 'creator_provider_resolution_required'
+ }));
+ expect(() => service.applyAction(job.id, {
+ actor: 'user',
+ action: 'generate-missing-shots',
+ expectedRevision: waiting.revision,
+ input: { revision: waiting.revision }
+ })).toThrowError(expect.objectContaining<Partial<CreatorServiceError>>({
+ code: 'creator_provider_resolution_required'
+ }));
+ expect(service.getJob(job.id)).toMatchObject({
+ revision: waiting.revision,
+ status: 'needs_input',
+ state: { needsInput: { code: 'creator_provider_resolution_required' } }
+ });
+ db.close();
+ });
+});
diff --git a/apps/daemon/test/unit/creator-stickman-remotion.test.ts b/apps/daemon/test/unit/creator-stickman-remotion.test.ts
new file mode 100644
index 00000000..2423d950
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-remotion.test.ts
@@ -0,0 +1,88 @@
+import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, describe, expect, it } from 'vitest';
+import { createStickmanRemotionExecutor } from '../../src/creator/stickman/remotion-executor.js';
+import { readStickmanRemotionRuntime } from '../../src/creator/stickman/remotion-runtime.js';
+
+let tempDir = '';
+
+afterEach(() => {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = '';
+});
+
+describe('stickman Remotion worker isolation', () => {
+ it('accepts visual assets from the packaged runtime manifest', () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-runtime-'));
+ const visualAssetPath = join(tempDir, 'catalog.json');
+ writeFileSync(visualAssetPath, '{}\n');
+ writeFileSync(join(tempDir, 'manifest.json'), JSON.stringify({
+ version: 1,
+ platform: process.platform,
+ arch: process.arch,
+ remotionVersion: '4.0.473',
+ chromiumVersion: 'test',
+ bundlePath: 'bundle',
+ browserExecutable: 'browser',
+ resources: [{
+ path: 'catalog.json',
+ kind: 'visual-asset',
+ sha256: '0'.repeat(64),
+ bytes: 3,
+ version: '1',
+ platform: process.platform,
+ arch: process.arch
+ }]
+ }));
+
+ expect(readStickmanRemotionRuntime(tempDir)).toEqual({
+ root: tempDir,
+ bundlePath: join(tempDir, 'bundle'),
+ browserExecutable: join(tempDir, 'browser')
+ });
+ });
+
+ it('isolates worker crashes and cancellation without leaving a clean video', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-remotion-'));
+ const timelinePath = join(tempDir, 'timeline.json');
+ writeFileSync(timelinePath, JSON.stringify({ fps: 30, width: 1280, height: 720, totalFrames: 30, shots: [] }));
+ const crashWorker = join(tempDir, 'crash-worker.ts');
+ writeFileSync(crashWorker, "const code: number = 2; process.stderr.write('injected crash'); process.exit(code);\n");
+ const executor = createStickmanRemotionExecutor({
+ ffprobePath: 'unused',
+ runtimeRoot: tempDir,
+ workerEntrypoint: crashWorker,
+ runtime: { root: tempDir, bundlePath: join(tempDir, 'bundle'), browserExecutable: join(tempDir, 'browser') },
+ validateVideo: async () => ({ duration: 1, width: 1280, height: 720, hasVideo: true, hasAudio: true })
+ });
+ const baseInput = {
+ stageRun: { id: 'stage-1', stageId: 'render-clean' },
+ job: { id: 'job-1' },
+ inputArtifacts: [{ id: 'timeline-1', kind: 'timeline_manifest', status: 'completed', path: timelinePath }],
+ workdir: tempDir,
+ reportProgress() {}
+ };
+
+ await expect(executor.run({
+ ...baseInput,
+ signal: new AbortController().signal
+ } as never)).rejects.toMatchObject({ code: 'stickman_remotion_worker_failed' });
+ expect(existsSync(join(tempDir, 'landscape-clean.mp4'))).toBe(false);
+
+ const waitWorker = join(tempDir, 'wait-worker.mjs');
+ writeFileSync(waitWorker, 'setInterval(() => {}, 1000);\n');
+ const cancelExecutor = createStickmanRemotionExecutor({
+ ffprobePath: 'unused',
+ runtimeRoot: tempDir,
+ workerEntrypoint: waitWorker,
+ runtime: { root: tempDir, bundlePath: join(tempDir, 'bundle'), browserExecutable: join(tempDir, 'browser') },
+ validateVideo: async () => ({ duration: 1, width: 1280, height: 720, hasVideo: true, hasAudio: true })
+ });
+ const controller = new AbortController();
+ const running = cancelExecutor.run({ ...baseInput, signal: controller.signal } as never);
+ setTimeout(() => controller.abort(), 100);
+ await expect(running).rejects.toMatchObject({ code: 'creator_stage_canceled' });
+ expect(existsSync(join(tempDir, 'landscape-clean.mp4'))).toBe(false);
+ });
+});
diff --git a/apps/daemon/test/unit/creator-stickman-results.test.ts b/apps/daemon/test/unit/creator-stickman-results.test.ts
new file mode 100644
index 00000000..f713c6c6
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-results.test.ts
@@ -0,0 +1,251 @@
+import { createHash } from 'node:crypto';
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import Fastify from 'fastify';
+import { afterEach, describe, expect, it } from 'vitest';
+import { readCreatorResultSnapshots } from '@opencreator/protocol';
+import { registerCreatorRoutes } from '../../src/api/routes.creator.js';
+import { createCreatorAgentRepository } from '../../src/creator/agent/repository.js';
+import { createCreatorCommandDispatcher } from '../../src/creator/command-dispatcher.js';
+import { createCreatorEventHub } from '../../src/creator/events.js';
+import { createCreatorRepository } from '../../src/creator/repository.js';
+import { createCreatorService } from '../../src/creator/service.js';
+import { createCreatorStageRunner } from '../../src/creator/stage-runner.js';
+import { createStickmanDeliveryExecutor } from '../../src/creator/stickman/delivery-executor.js';
+import { createDefaultCreatorTemplateRegistry } from '../../src/creator/templates/registry.js';
+import { openRuntimeDatabase } from '../../src/storage/database.js';
+
+let tempRoot = '';
+let database: ReturnType<typeof openRuntimeDatabase> | undefined;
+
+afterEach(() => {
+ database?.close();
+ database = undefined;
+ if (tempRoot) rmSync(tempRoot, { recursive: true, force: true });
+ tempRoot = '';
+});
+
+describe('stickman result snapshots', () => {
+ it('creates a snapshot only after package validation and keeps the previous result readable', async () => {
+ const context = setup();
+ const job = context.service.createJob({
+ projectId: 'project-1',
+ templateId: 'stickman-video',
+ state: { topic: 'snapshot test' }
+ });
+ await insertInputs(context.repository, job.id, 'v1');
+ expect(readCreatorResultSnapshots(context.service.getJob(job.id)!.state.resultSnapshots)).toEqual([]);
+
+ const firstRun = await context.runner.run(job.id, 'package-validation');
+ expect(firstRun.status).toBe('succeeded');
+ const afterFirst = context.service.getJob(job.id)!;
+ const firstSnapshots = readCreatorResultSnapshots(afterFirst.state.resultSnapshots);
+ expect(firstSnapshots).toHaveLength(1);
+ expect(Object.keys(firstSnapshots[0]!.artifactRefs).sort()).toEqual([
+ 'clean_video',
+ 'delivery_manifest',
+ 'narration_subtitle'
+ ]);
+ const firstCleanId = firstSnapshots[0]!.artifactRefs.clean_video![0]!;
+
+ await insertInputs(context.repository, job.id, 'v2');
+ const secondRun = await context.runner.run(job.id, 'package-validation');
+ expect(secondRun.status).toBe('succeeded');
+ const afterSecond = context.service.getJob(job.id)!;
+ const snapshots = readCreatorResultSnapshots(afterSecond.state.resultSnapshots);
+ expect(snapshots).toHaveLength(2);
+ expect(snapshots[0]!.artifactRefs.clean_video).toEqual([firstCleanId]);
+ expect(snapshots[1]!.artifactRefs.clean_video).not.toEqual([firstCleanId]);
+ expect(afterSecond.artifacts.find(artifact => artifact.id === firstCleanId)?.status).toBe('completed');
+
+ const app = Fastify();
+ await registerCreatorRoutes(app, context.service, createCreatorEventHub(), {
+ jobsRoot: tempRoot,
+ dispatcher: context.dispatcher,
+ stageRunner: context.runner
+ });
+ const response = await app.inject({
+ method: 'GET',
+ url: `/creator/jobs/${job.id}/artifacts/${firstCleanId}/content`
+ });
+ expect(response.statusCode).toBe(200);
+ expect(response.rawPayload.toString()).toBe('clean-v1');
+ await app.close();
+ });
+
+ it('does not create a snapshot or completed job when package validation fails', async () => {
+ const context = setup();
+ const job = context.service.createJob({
+ projectId: 'project-1',
+ templateId: 'stickman-video'
+ });
+ const inserted = await insertInputs(context.repository, job.id, 'bad');
+ writeFileSync(inserted.clean_video.path!, 'tampered-after-hash');
+ const run = await context.runner.run(job.id, 'package-validation');
+ expect(run.status).toBe('failed');
+ const failed = context.service.getJob(job.id)!;
+ expect(failed.status).toBe('failed');
+ expect(readCreatorResultSnapshots(failed.state.resultSnapshots)).toEqual([]);
+ });
+});
+
+function setup() {
+ tempRoot = mkdtempSync(join(tmpdir(), 'creator-stickman-results-'));
+ database = openRuntimeDatabase(join(tempRoot, 'runtime.sqlite'));
+ const repository = createCreatorRepository(database);
+ const templates = createDefaultCreatorTemplateRegistry();
+ const service = createCreatorService({ repository, templates });
+ const receipts = createCreatorAgentRepository(database);
+ const dispatcher = createCreatorCommandDispatcher({ service, repository, receipts });
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ executors: [createStickmanDeliveryExecutor({
+ ffprobePath: 'unused',
+ validateVideo: async () => ({
+ duration: 1,
+ width: 1280,
+ height: 720,
+ hasVideo: true,
+ hasAudio: true
+ })
+ })],
+ workRoot: join(tempRoot, 'jobs')
+ });
+ return { repository, service, dispatcher, runner };
+}
+
+async function insertInputs(
+ repository: ReturnType<typeof createCreatorRepository>,
+ jobId: string,
+ label: string
+) {
+ const sourceRoot = join(tempRoot, 'jobs', jobId, `source-${label}`);
+ mkdirSync(sourceRoot, { recursive: true });
+ const files = {
+ clean_video: join(sourceRoot, 'clean.mp4'),
+ narration_subtitle: join(sourceRoot, 'narration.srt'),
+ narration_audio: join(sourceRoot, 'segment-01.wav'),
+ audio_timing: join(sourceRoot, 'audio-timing.json'),
+ timeline_manifest: join(sourceRoot, 'timeline.json'),
+ visual_validation: join(sourceRoot, 'visual-validation.json'),
+ media_validation: join(sourceRoot, 'media-validation.json')
+ };
+ writeFileSync(files.clean_video, `clean-${label}`);
+ writeFileSync(files.narration_subtitle, `1\n00:00:00,000 --> 00:00:01,000\n${label}\n`);
+ writeFileSync(files.narration_audio, `narration-${label}`);
+
+ const insert = (
+ kind: keyof typeof files,
+ metadata: Record<string, string | number> = {},
+ scopeKey: string | null = null
+ ) => repository.insertArtifact({
+ jobId,
+ kind,
+ status: 'completed',
+ path: files[kind],
+ sha256: createHash('sha256').update(readFileSync(files[kind])).digest('hex'),
+ scopeKey,
+ sourceArtifactIds: [],
+ metadata: {
+ fileName: files[kind].split(/[\\/]/).at(-1) ?? kind,
+ ...metadata
+ }
+ });
+
+ const cleanVideo = insert('clean_video', { renderEngine: 'remotion', renderKind: 'final' });
+ const narrationSubtitle = insert('narration_subtitle');
+ const narrationAudio = insert('narration_audio', {
+ duration: 1,
+ provider: 'openai',
+ timingSource: 'ffprobe'
+ }, 'segment-01');
+ writeFileSync(files.audio_timing, JSON.stringify({
+ scriptArtifactId: `script-${label}`,
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ segments: [{
+ segmentId: 'segment-01',
+ startSeconds: 0,
+ endSeconds: 1,
+ durationSeconds: 1,
+ audioArtifactId: narrationAudio.id,
+ audioSha256: narrationAudio.sha256
+ }],
+ totalDurationSeconds: 1
+ }));
+ const audioTiming = insert('audio_timing');
+ writeFileSync(files.timeline_manifest, JSON.stringify({
+ fps: 30,
+ width: 1280,
+ height: 720,
+ totalFrames: 30,
+ shots: [{
+ shotId: 'shot-01',
+ startFrame: 0,
+ endFrame: 30,
+ imageArtifactId: `image-${label}`,
+ audioArtifactId: narrationAudio.id,
+ motion: 'static',
+ imageSha256: 'a'.repeat(64),
+ audioSha256: narrationAudio.sha256
+ }]
+ }));
+ const timeline = insert('timeline_manifest', {
+ timingSource: 'ffprobe_cumulative_tts_duration'
+ });
+ writeFileSync(files.visual_validation, JSON.stringify({
+ ok: true,
+ validation: 'automated_decode_aspect_nonblank_hash_and_ocr',
+ approvedShotSpecArtifactId: `shot-spec-${label}`,
+ shotCount: 1,
+ ocrStatus: 'passed',
+ publishable: true,
+ warnings: [],
+ shots: [{
+ shotId: 'shot-01',
+ imageArtifactId: `image-${label}`,
+ imageSha256: 'a'.repeat(64),
+ width: 1280,
+ height: 720,
+ brightnessMean: 200,
+ contrastStddev: 30,
+ ocrStatus: 'passed',
+ detectedText: []
+ }]
+ }));
+ const visualValidation = insert('visual_validation');
+ writeFileSync(files.media_validation, JSON.stringify({
+ ok: true,
+ validation: 'ffprobe_and_three_frame_sampling',
+ cleanVideoArtifactId: cleanVideo.id,
+ cleanVideoSha256: cleanVideo.sha256,
+ timelineArtifactId: timeline.id,
+ duration: 1,
+ expectedDuration: 1,
+ durationTolerance: 0.15,
+ width: 1280,
+ height: 720,
+ hasVideo: true,
+ hasAudio: true,
+ sampledFrames: [1, 2, 3].map(index => ({
+ index,
+ timestampSeconds: index / 4,
+ sha256: String(index).repeat(64),
+ width: 1280,
+ height: 720,
+ brightnessMean: 180,
+ contrastStddev: 24
+ }))
+ }));
+ const mediaValidation = insert('media_validation');
+ return {
+ clean_video: cleanVideo,
+ narration_subtitle: narrationSubtitle,
+ narration_audio: narrationAudio,
+ audio_timing: audioTiming,
+ timeline_manifest: timeline,
+ visual_validation: visualValidation,
+ media_validation: mediaValidation
+ };
+}
diff --git a/apps/daemon/test/unit/creator-stickman-timeline.test.ts b/apps/daemon/test/unit/creator-stickman-timeline.test.ts
new file mode 100644
index 00000000..e36c54a3
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-timeline.test.ts
@@ -0,0 +1,126 @@
+import { createHash } from 'node:crypto';
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, describe, expect, it } from 'vitest';
+import type { CreatorArtifact } from '@opencreator/protocol';
+import { createStickmanTimelineExecutor } from '../../src/creator/stickman/timeline-executor.js';
+
+let tempDir = '';
+
+afterEach(() => {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = '';
+});
+
+describe('stickman timeline executor', () => {
+ it('builds a deterministic contiguous timeline from approved current artifacts', async () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-timeline-'));
+ const workdir = join(tempDir, 'stage-timeline');
+ mkdirSync(workdir, { recursive: true });
+ const shotSpecPath = join(tempDir, 'shots.json');
+ const scriptPath = join(tempDir, 'script.json');
+ const timingPath = join(tempDir, 'audio-timing.json');
+ writeFileSync(join(tempDir, 'one.png'), 'one');
+ writeFileSync(join(tempDir, 'two.png'), 'two');
+ writeFileSync(join(tempDir, 'old.png'), 'old');
+ writeFileSync(join(tempDir, 'one.wav'), 'voice one');
+ writeFileSync(join(tempDir, 'two.wav'), 'voice two');
+ writeFileSync(scriptPath, JSON.stringify({
+ contract: 'stickman-narration-script-v2',
+ reviewStatus: 'approved',
+ contentLocked: true,
+ title: '测试脚本',
+ language: 'zh-CN',
+ targetDurationSeconds: 5,
+ narrationBudget: { unit: 'characters', unitsPerMinute: 240, minUnits: 1, maxUnits: 10 },
+ segmentCount: 2,
+ totalNarrationUnits: 6,
+ estimatedTotalDurationSeconds: 1.5,
+ segments: [
+ { id: 'segment-01', order: 1, narration: '第一段', claimIds: ['claim-001'], sourceSpanIds: ['source-001'], narrationUnits: 3, estimatedDurationSeconds: 0.75 },
+ { id: 'segment-02', order: 2, narration: '第二段', claimIds: ['claim-002'], sourceSpanIds: ['source-002'], narrationUnits: 3, estimatedDurationSeconds: 0.75 }
+ ]
+ }));
+ writeFileSync(shotSpecPath, JSON.stringify({
+ scriptArtifactId: 'script-1',
+ audioTimingArtifactId: 'audio-timing',
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ shots: [
+ { id: 'shot-01', sourceSegmentId: 'segment-01', semanticAnchor: '一', visualDescription: '人物展示第一段含义', compositionAndAction: '人物居中讲解', keyObjects: ['人物'], continuityReason: '', motion: 'static', motionReason: '静态说明', startSeconds: 0, endSeconds: 2, durationSeconds: 2 },
+ { id: 'shot-02', sourceSegmentId: 'segment-02', semanticAnchor: '二', visualDescription: '人物展示第二段含义', compositionAndAction: '人物指向目标', keyObjects: ['人物', '目标'], continuityReason: '承接上一段', motion: 'push-in', motionReason: '聚焦目标', startSeconds: 2, endSeconds: 5, durationSeconds: 3 }
+ ]
+ }));
+ writeFileSync(timingPath, JSON.stringify({
+ scriptArtifactId: 'script-1',
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ segments: [
+ { segmentId: 'segment-01', startSeconds: 0, endSeconds: 2, durationSeconds: 2, audioArtifactId: 'narration-01', audioSha256: '3'.repeat(64) },
+ { segmentId: 'segment-02', startSeconds: 2, endSeconds: 5, durationSeconds: 3, audioArtifactId: 'narration-02', audioSha256: '4'.repeat(64) }
+ ],
+ totalDurationSeconds: 5
+ }));
+ const artifacts: CreatorArtifact[] = [
+ artifact('old-shot-01', 'shot_image', 'stale', join(tempDir, 'old.png'), 'shot-01', '0'.repeat(64)),
+ artifact('shot-02-image', 'shot_image', 'completed', join(tempDir, 'two.png'), 'shot-02', '2'.repeat(64)),
+ artifact('script-1', 'script_manifest', 'completed', scriptPath, null, '5'.repeat(64)),
+ artifact('audio-timing', 'audio_timing', 'completed', timingPath, null, '6'.repeat(64)),
+ artifact('narration-01', 'narration_audio', 'completed', join(tempDir, 'one.wav'), 'segment-01', '3'.repeat(64), { duration: 2 }),
+ artifact('narration-02', 'narration_audio', 'completed', join(tempDir, 'two.wav'), 'segment-02', '4'.repeat(64), { duration: 3 }),
+ artifact('shot-spec', 'shot_spec', 'completed', shotSpecPath, null, '4'.repeat(64)),
+ artifact('shot-01-image', 'shot_image', 'completed', join(tempDir, 'one.png'), 'shot-01', '1'.repeat(64))
+ ];
+ const result = await createStickmanTimelineExecutor().run({
+ stageRun: { stageId: 'timeline' },
+ job: {},
+ inputArtifacts: artifacts,
+ workdir,
+ signal: new AbortController().signal,
+ reportProgress() {}
+ } as never);
+
+ const timeline = JSON.parse(readFileSync(result.outputs[0]!.path!, 'utf8'));
+ expect(timeline).toMatchObject({
+ fps: 30,
+ width: 1280,
+ height: 720,
+ totalFrames: 150,
+ shots: [
+ { shotId: 'shot-01', startFrame: 0, endFrame: 60, imageArtifactId: 'shot-01-image' },
+ { shotId: 'shot-02', startFrame: 60, endFrame: 150, imageArtifactId: 'shot-02-image' }
+ ]
+ });
+ expect(readFileSync(result.outputs[1]!.path!, 'utf8')).toBe(
+ '1\n00:00:00,000 --> 00:00:02,000\n第一段\n\n2\n00:00:02,000 --> 00:00:05,000\n第二段\n'
+ );
+ });
+});
+
+function artifact(
+ id: string,
+ kind: string,
+ status: CreatorArtifact['status'],
+ path: string,
+ scopeKey: string | null,
+ sha256: string,
+ metadata: CreatorArtifact['metadata'] = {}
+): CreatorArtifact {
+ return {
+ id,
+ jobId: 'job-1',
+ kind,
+ version: 1,
+ status,
+ path,
+ scopeKey,
+ inputFingerprint: null,
+ sha256,
+ sourceArtifactIds: [],
+ metadata,
+ createdAt: '2026-08-31T00:00:00.000Z'
+ };
+}
+
+function hashFile(path: string): string {
+ return createHash('sha256').update(readFileSync(path)).digest('hex');
+}
diff --git a/apps/daemon/test/unit/creator-stickman-validation.test.ts b/apps/daemon/test/unit/creator-stickman-validation.test.ts
new file mode 100644
index 00000000..1811c23b
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-validation.test.ts
@@ -0,0 +1,152 @@
+import { createHash } from 'node:crypto';
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import sharp from 'sharp';
+import { afterEach, describe, expect, it } from 'vitest';
+import type { CreatorArtifact } from '@opencreator/protocol';
+import { createStickmanValidationExecutor } from '../../src/creator/stickman/validation-executor.js';
+
+let tempDir = '';
+
+afterEach(() => {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = '';
+});
+
+describe('stickman visual validation', () => {
+ it('records hash-bound decode, ratio, readability, and OCR evidence for every shot', async () => {
+ const fixture = await createFixture();
+ const result = await run(fixture.artifacts, async () => ({ available: true, detectedText: [] }));
+ const report = JSON.parse(readFileSync(result.outputs[0]!.path!, 'utf8'));
+
+ expect(report).toMatchObject({
+ ok: true,
+ validation: 'automated_decode_aspect_nonblank_hash_and_ocr',
+ shotCount: 2,
+ ocrStatus: 'passed',
+ publishable: true,
+ warnings: [],
+ shots: [
+ { shotId: 'shot-01', width: 320, height: 180, ocrStatus: 'passed' },
+ { shotId: 'shot-02', width: 320, height: 180, ocrStatus: 'passed' }
+ ]
+ });
+ expect(report.shots.every((shot: { contrastStddev: number }) => shot.contrastStddev >= 8))
+ .toBe(true);
+ });
+
+ it('keeps OCR-unavailable visuals as non-publishable technical evidence', async () => {
+ const fixture = await createFixture();
+ const result = await run(fixture.artifacts, async () => ({ available: false, detectedText: [] }));
+ const report = JSON.parse(readFileSync(result.outputs[0]!.path!, 'utf8'));
+
+ expect(report).toMatchObject({
+ ocrStatus: 'unavailable',
+ publishable: false,
+ warnings: ['visual_ocr_unavailable']
+ });
+ });
+
+ it('rejects blank, duplicate, and OCR-positive images instead of promoting them', async () => {
+ let fixture = await createFixture();
+ const first = fixture.artifacts.find(artifact => artifact.scopeKey === 'shot-01')!;
+ await sharp({ create: { width: 320, height: 180, channels: 3, background: '#ffffff' } })
+ .png()
+ .toFile(first.path!);
+ first.sha256 = hashFile(first.path!);
+ await expect(run(fixture.artifacts, async () => ({ available: true, detectedText: [] })))
+ .rejects.toMatchObject({ code: 'creator_shot_image_unreadable' });
+
+ fixture = await createFixture();
+ const [one, two] = fixture.artifacts.filter(artifact => artifact.kind === 'shot_image');
+ writeFileSync(two!.path!, readFileSync(one!.path!));
+ two!.sha256 = hashFile(two!.path!);
+ await expect(run(fixture.artifacts, async () => ({ available: true, detectedText: [] })))
+ .rejects.toMatchObject({ code: 'creator_shot_images_duplicate' });
+
+ fixture = await createFixture();
+ await expect(run(fixture.artifacts, async path => ({
+ available: true,
+ detectedText: path.endsWith('shot-02.png') ? ['WATERMARK'] : []
+ }))).rejects.toMatchObject({ code: 'creator_visual_text_detected' });
+ });
+});
+
+async function createFixture(): Promise<{ artifacts: CreatorArtifact[] }> {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-validation-'));
+ mkdirSync(join(tempDir, 'stage-validation'), { recursive: true });
+ const shotSpecPath = join(tempDir, 'shot-spec.json');
+ writeFileSync(shotSpecPath, JSON.stringify({
+ scriptArtifactId: 'script-1',
+ audioTimingArtifactId: 'audio-timing-1',
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ shots: [
+ { id: 'shot-01', sourceSegmentId: 'segment-01', semanticAnchor: '一', visualDescription: '第一幅画面', compositionAndAction: '人物居中', keyObjects: ['人物'], continuityReason: '', motion: 'static', motionReason: '静态说明', startSeconds: 0, endSeconds: 1, durationSeconds: 1 },
+ { id: 'shot-02', sourceSegmentId: 'segment-02', semanticAnchor: '二', visualDescription: '第二幅画面', compositionAndAction: '人物向右', keyObjects: ['人物'], continuityReason: '延续动作', motion: 'push-in', motionReason: '聚焦人物', startSeconds: 1, endSeconds: 2, durationSeconds: 1 }
+ ]
+ }));
+ const one = join(tempDir, 'shot-01.png');
+ const two = join(tempDir, 'shot-02.png');
+ await writeCheckerboard(one, 0);
+ await writeCheckerboard(two, 1);
+ return {
+ artifacts: [
+ artifact('shot-spec', 'shot_spec', shotSpecPath, null),
+ artifact('image-1', 'shot_image', one, 'shot-01'),
+ artifact('image-2', 'shot_image', two, 'shot-02')
+ ]
+ };
+}
+
+function run(
+ artifacts: CreatorArtifact[],
+ runOcr: (path: string) => Promise<{ available: boolean; detectedText: string[] }>
+) {
+ return createStickmanValidationExecutor({ runOcr }).run({
+ stageRun: { id: 'stage-validation', stageId: 'visual-validation' },
+ job: { id: 'job-1' },
+ inputArtifacts: artifacts,
+ workdir: join(tempDir, 'stage-validation'),
+ signal: new AbortController().signal,
+ reportProgress() {}
+ } as never);
+}
+
+async function writeCheckerboard(path: string, offset: number): Promise<void> {
+ const width = 320;
+ const height = 180;
+ const content = Buffer.alloc(width * height * 3);
+ for (let y = 0; y < height; y += 1) {
+ for (let x = 0; x < width; x += 1) {
+ const value = ((Math.floor(x / 20) + Math.floor(y / 20) + offset) % 2 === 0) ? 24 : 232;
+ const index = (y * width + x) * 3;
+ content[index] = value;
+ content[index + 1] = value;
+ content[index + 2] = value;
+ }
+ }
+ await sharp(content, { raw: { width, height, channels: 3 } }).png().toFile(path);
+}
+
+function artifact(id: string, kind: string, path: string, scopeKey: string | null): CreatorArtifact {
+ return {
+ id,
+ jobId: 'job-1',
+ kind,
+ version: 1,
+ status: 'completed',
+ path,
+ scopeKey,
+ inputFingerprint: null,
+ sha256: hashFile(path),
+ sourceArtifactIds: [],
+ metadata: {},
+ createdAt: '2026-09-03T00:00:00.000Z'
+ };
+}
+
+function hashFile(path: string): string {
+ return createHash('sha256').update(readFileSync(path)).digest('hex');
+}
diff --git a/apps/daemon/test/unit/creator-stickman-visual-assets.test.ts b/apps/daemon/test/unit/creator-stickman-visual-assets.test.ts
new file mode 100644
index 00000000..0fb87980
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-visual-assets.test.ts
@@ -0,0 +1,114 @@
+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import Fastify from 'fastify';
+import { afterEach, describe, expect, it } from 'vitest';
+import { registerCreatorRoutes } from '../../src/api/routes.creator.js';
+import { createCreatorAgentRepository } from '../../src/creator/agent/repository.js';
+import { createCreatorCommandDispatcher } from '../../src/creator/command-dispatcher.js';
+import { createCreatorEventHub } from '../../src/creator/events.js';
+import { createCreatorRepository } from '../../src/creator/repository.js';
+import { createCreatorService } from '../../src/creator/service.js';
+import {
+ createStickmanVisualAssetRegistry,
+ StickmanVisualAssetError
+} from '../../src/creator/stickman/visual-assets.js';
+import { createDefaultCreatorTemplateRegistry } from '../../src/creator/templates/registry.js';
+import { openRuntimeDatabase } from '../../src/storage/database.js';
+
+const catalogPath = fileURLToPath(new URL(
+ '../../../../resources/stickman/visual-assets/catalog.json',
+ import.meta.url
+));
+const assetRoot = fileURLToPath(new URL(
+ '../../../../apps/web/public/dashboard',
+ import.meta.url
+));
+
+let tempRoot = '';
+
+afterEach(() => {
+ if (tempRoot) rmSync(tempRoot, { recursive: true, force: true });
+ tempRoot = '';
+});
+
+describe('stickman visual asset catalog', () => {
+ it('lists the shared catalog and serves character previews through Creator routes', async () => {
+ tempRoot = mkdtempSync(join(tmpdir(), 'stickman-visual-assets-'));
+ const db = openRuntimeDatabase(join(tempRoot, 'runtime.sqlite'));
+ const repository = createCreatorRepository(db);
+ const service = createCreatorService({
+ repository,
+ templates: createDefaultCreatorTemplateRegistry()
+ });
+ const dispatcher = createCreatorCommandDispatcher({
+ service,
+ repository,
+ receipts: createCreatorAgentRepository(db)
+ });
+ const visualAssets = createStickmanVisualAssetRegistry({ root: assetRoot, catalogPath });
+ const app = Fastify();
+ await registerCreatorRoutes(app, service, createCreatorEventHub(), {
+ jobsRoot: join(tempRoot, 'jobs'),
+ dispatcher,
+ stickmanVisualAssets: visualAssets
+ });
+
+ const catalog = await app.inject({
+ method: 'GET',
+ url: '/creator/visual-assets?templateId=stickman-video'
+ });
+ expect(catalog.statusCode).toBe(200);
+ expect(catalog.json().assets).toHaveLength(14);
+ expect(catalog.json().assets.filter((asset: { kind: string }) => asset.kind === 'character'))
+ .toHaveLength(10);
+ expect(catalog.json().assets).toContainEqual(expect.objectContaining({
+ id: 'stickman.style.paper-pencil',
+ kind: 'style',
+ recommended: true,
+ styleAttributes: expect.objectContaining({
+ swatch: expect.objectContaining({ texture: 'paper' })
+ })
+ }));
+
+ const preview = await app.inject({
+ method: 'GET',
+ url: '/creator/visual-assets/stickman.character.student/revisions/1/preview'
+ });
+ expect(preview.statusCode).toBe(200);
+ expect(preview.headers['content-type']).toContain('image/png');
+ expect(preview.rawPayload.length).toBeGreaterThan(1_000);
+
+ await app.close();
+ db.close();
+ });
+
+ it('rejects duplicate revisions and reference paths outside the Runtime root', () => {
+ tempRoot = mkdtempSync(join(tmpdir(), 'stickman-visual-assets-'));
+ const catalog = JSON.parse(readFileSync(catalogPath, 'utf8')) as {
+ characters: Array<Record<string, unknown>>;
+ styles: Array<Record<string, unknown>>;
+ };
+ catalog.characters.push(structuredClone(catalog.characters[0]!));
+ const duplicatePath = join(tempRoot, 'duplicate.json');
+ writeFileSync(duplicatePath, JSON.stringify(catalog));
+ expect(() => createStickmanVisualAssetRegistry({
+ root: tempRoot,
+ catalogPath: duplicatePath
+ })).toThrowError(StickmanVisualAssetError);
+
+ catalog.characters.pop();
+ catalog.characters[0] = {
+ ...catalog.characters[0],
+ referenceFiles: [{ role: 'identity-primary', path: '../outside.png' }]
+ };
+ const escapedPath = join(tempRoot, 'escaped.json');
+ writeFileSync(escapedPath, JSON.stringify(catalog));
+ const registry = createStickmanVisualAssetRegistry({ root: tempRoot, catalogPath: escapedPath });
+ expect(() => registry.referenceFiles(registry.character({
+ assetId: 'stickman.character.default',
+ revision: 1
+ }))).toThrowError(/escapes its root/);
+ });
+});
diff --git a/apps/daemon/test/unit/creator-stickman-workflow.test.ts b/apps/daemon/test/unit/creator-stickman-workflow.test.ts
new file mode 100644
index 00000000..709ee4ba
--- /dev/null
+++ b/apps/daemon/test/unit/creator-stickman-workflow.test.ts
@@ -0,0 +1,889 @@
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { afterEach, describe, expect, it } from 'vitest';
+import { createDefaultCreatorServicesConfig } from '@opencreator/protocol';
+import { createCreatorAgentRepository } from '../../src/creator/agent/repository.js';
+import { createCreatorCommandDispatcher } from '../../src/creator/command-dispatcher.js';
+import type { CreatorExecutor } from '../../src/creator/executor.js';
+import { createCreatorRepository } from '../../src/creator/repository.js';
+import { createCreatorService } from '../../src/creator/service.js';
+import { createCreatorStageRunner } from '../../src/creator/stage-runner.js';
+import { createStickmanContentExecutor } from '../../src/creator/stickman/content-executor.js';
+import { createStickmanVisualAssetRegistry } from '../../src/creator/stickman/visual-assets.js';
+import { createDefaultCreatorTemplateRegistry } from '../../src/creator/templates/registry.js';
+import { createStickmanVideoWorkflow } from '../../src/creator/templates/stickman-video-actions.js';
+import { openRuntimeDatabase } from '../../src/storage/database.js';
+
+let tempDir = '';
+
+afterEach(() => {
+ if (tempDir) rmSync(tempDir, { recursive: true, force: true });
+ tempDir = '';
+});
+
+type CompletionRequest = {
+ stageId: string;
+ prompt: string;
+ signal: AbortSignal;
+};
+
+type CompletionOverride = (input: CompletionRequest) => unknown | Promise<unknown>;
+
+function setup(options: {
+ segmentCount?: number;
+ narrationUnits?: number;
+ narrationDurationSeconds?: number;
+ completionOverride?: CompletionOverride;
+} = {}) {
+ const narrationUnits = options.narrationUnits ?? 40;
+ const segmentCount = options.segmentCount ?? Math.ceil(narrationUnits / 18);
+ const narrationDurationSeconds = options.narrationDurationSeconds ?? 2.25;
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-stickman-workflow-'));
+ const runtimeRoot = join(tempDir, 'stickman-runtime');
+ mkdirSync(join(runtimeRoot, 'characters'), { recursive: true });
+ const imageFixture = Buffer.from(
+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAEAQH/69m8WQAAAABJRU5ErkJggg==',
+ 'base64'
+ );
+ writeFileSync(join(runtimeRoot, 'characters', 'default.png'), imageFixture);
+ writeFileSync(join(runtimeRoot, 'characters', 'student.png'), imageFixture);
+ const visualAssets = createStickmanVisualAssetRegistry({
+ root: runtimeRoot,
+ catalogPath: fileURLToPath(new URL(
+ '../../../../resources/stickman/visual-assets/catalog.json',
+ import.meta.url
+ ))
+ });
+
+ const db = openRuntimeDatabase(join(tempDir, 'runtime.sqlite'));
+ const repository = createCreatorRepository(db);
+ const templates = createDefaultCreatorTemplateRegistry();
+ const service = createCreatorService({ repository, templates });
+ const receipts = createCreatorAgentRepository(db);
+ const dispatcher = createCreatorCommandDispatcher({ service, repository, receipts });
+ const completionRequests: CompletionRequest[] = [];
+
+ const content = createStickmanContentExecutor({
+ configStore: { read: async () => createDefaultCreatorServicesConfig() },
+ visualAssets,
+ async completeJson(request) {
+ completionRequests.push(request);
+ const overridden = await options.completionOverride?.(request);
+ if (overridden !== undefined) return overridden;
+ if (request.stageId === 'source-brief') {
+ return {
+ title: '测试来源',
+ summary: '忠实的来源摘要',
+ audience: '普通观众',
+ claims: [{
+ id: 'claim-001',
+ text: '来源中的完整内容',
+ sourceSpanIds: ['source-001']
+ }]
+ };
+ }
+ if (request.stageId === 'content-plan') {
+ return {
+ title: '测试视频',
+ audience: '普通观众',
+ objective: '忠实讲清来源内容',
+ retainedClaimIds: ['claim-001'],
+ discardedClaimIds: [],
+ sections: [{
+ id: 'section-01',
+ title: '完整内容',
+ claimIds: ['claim-001']
+ }]
+ };
+ }
+ if (request.stageId === 'script') {
+ return generatedScript(segmentCount, narrationUnits);
+ }
+ if (request.stageId === 'storyboard') {
+ return generatedStoryboard(segmentCount);
+ }
+ return { title: '标题', description: '简介', tags: ['知识'] };
+ }
+ });
+
+ const audio: CreatorExecutor = {
+ id: 'stickman-audio',
+ async run({ stageRun, inputArtifacts, workdir }) {
+ if (stageRun.stageId === 'narration') {
+ const path = join(workdir, `${stageRun.scopeKey}.wav`);
+ writeFileSync(path, `audio:${stageRun.scopeKey}`);
+ return {
+ outputs: [{
+ kind: 'narration_audio',
+ status: 'completed',
+ path,
+ scopeKey: stageRun.scopeKey,
+ inputFingerprint: stageRun.inputFingerprint,
+ metadata: { duration: narrationDurationSeconds, timingSource: 'ffprobe' }
+ }]
+ };
+ }
+ const scriptArtifact = inputArtifacts.find(artifact => artifact.kind === 'script_manifest')!;
+ const narration = inputArtifacts.filter(artifact => artifact.kind === 'narration_audio');
+ const script = JSON.parse(readFileSync(scriptArtifact.path!, 'utf8')) as {
+ segments: Array<{ id: string }>;
+ };
+ let cursor = 0;
+ const segments = script.segments.map(segment => {
+ const audioArtifact = narration.find(artifact => artifact.scopeKey === segment.id)!;
+ const startSeconds = cursor;
+ cursor += narrationDurationSeconds;
+ return {
+ segmentId: segment.id,
+ startSeconds,
+ endSeconds: cursor,
+ durationSeconds: narrationDurationSeconds,
+ audioArtifactId: audioArtifact.id,
+ audioSha256: audioArtifact.sha256
+ };
+ });
+ const path = join(workdir, 'audio-timing.json');
+ writeFileSync(path, JSON.stringify({
+ scriptArtifactId: scriptArtifact.id,
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ segments,
+ totalDurationSeconds: cursor
+ }));
+ return { outputs: [{ kind: 'audio_timing', status: 'completed', path }] };
+ }
+ };
+
+ const runner = createCreatorStageRunner({
+ repository,
+ templates,
+ executors: [content, audio],
+ workRoot: join(tempDir, 'jobs')
+ });
+ const workflow = createStickmanVideoWorkflow({ creator: service, dispatcher });
+ return {
+ db,
+ repository,
+ service,
+ dispatcher,
+ runner,
+ workflow,
+ completionRequests
+ };
+}
+
+describe('stickman video workflow', () => {
+ it('queues KrillinAI directly for a YouTube source without a download stage', async () => {
+ const { db, service, repository, workflow } = setup();
+ try {
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: {
+ sourceType: 'url',
+ sourceUrl: 'https://www.youtube.com/watch?v=demo'
+ }
+ });
+ repository.updateJob({
+ id: job.id,
+ status: 'running',
+ revision: job.revision,
+ state: job.state
+ });
+
+ await workflow.reconcile(service.getJob(job.id)!);
+
+ expect(service.getJob(job.id)!.stages).toMatchObject([{
+ stageId: 'source-transcript',
+ executor: 'krillinai',
+ status: 'queued'
+ }]);
+ expect(service.getJob(job.id)!.stages.some(stage => stage.stageId === 'acquire-source'))
+ .toBe(false);
+ } finally {
+ db.close();
+ }
+ });
+
+ it('builds claims, a complete claim partition, and one narration script for a 30-second task', async () => {
+ const context = setup({ narrationUnits: 120 });
+ const { db, service, dispatcher, runner, workflow, completionRequests } = context;
+ try {
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: {
+ sourceType: 'text',
+ sourceText: '这是一段由用户直接输入的完整来源文本。',
+ characterAsset: { assetId: 'stickman.character.student', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.paper-pencil', revision: 1 },
+ targetDurationSeconds: 30,
+ targetLanguage: 'zh-CN'
+ }
+ });
+ let queued = dispatcher.dispatch(job.id, {
+ action: 'run-stage',
+ expectedRevision: job.revision,
+ idempotencyKey: 'stickman-claim-pipeline',
+ input: { stageId: 'ingest-text' }
+ }, 'user').commandReceipt.stageRunId!;
+
+ for (const expectedStage of ['ingest-text', 'source-brief', 'content-plan', 'script']) {
+ const completed = await runner.runStageRun(queued);
+ expect(completed).toMatchObject({
+ stageId: expectedStage,
+ status: 'succeeded',
+ progress: { phase: 'completed', percent: 100 }
+ });
+ await workflow.handleStageChanged(completed);
+ if (expectedStage !== 'script') {
+ queued = service.getJob(job.id)!.stages.find(stage => stage.status === 'queued')!.id;
+ }
+ }
+
+ const completed = service.getJob(job.id)!;
+ expect(completed.stages.map(stage => stage.stageId)).toEqual([
+ 'ingest-text', 'source-brief', 'content-plan', 'script'
+ ]);
+ expect(completed).toMatchObject({
+ status: 'needs_input',
+ state: { needsInput: { kind: 'approve-script' } }
+ });
+ const brief = readArtifact(completed, 'source_brief') as {
+ claims: Array<{ id: string; sourceSpanIds: string[] }>;
+ };
+ const plan = readArtifact(completed, 'content_plan') as {
+ retainedClaimIds: string[];
+ discardedClaimIds: string[];
+ narrationBudget: { minUnits: number; maxUnits: number };
+ };
+ const script = readArtifact(completed, 'script_manifest') as {
+ reviewStatus: string;
+ contentLocked: boolean;
+ totalNarrationUnits: number;
+ estimatedTotalDurationSeconds: number;
+ segments: Array<{
+ narration: string;
+ claimIds: string[];
+ sourceSpanIds: string[];
+ estimatedDurationSeconds: number;
+ }>;
+ };
+
+ expect(brief.claims).toMatchObject([{
+ id: 'claim-001',
+ sourceSpanIds: ['source-001']
+ }]);
+ expect(plan).toMatchObject({
+ retainedClaimIds: ['claim-001'],
+ discardedClaimIds: [],
+ narrationBudget: { minUnits: 108, maxUnits: 132 }
+ });
+ expect(script).toMatchObject({
+ reviewStatus: 'needs_review',
+ contentLocked: false,
+ totalNarrationUnits: 120,
+ estimatedTotalDurationSeconds: 30
+ });
+ expect(script.segments[0]).toMatchObject({
+ claimIds: ['claim-001'],
+ sourceSpanIds: ['source-001']
+ });
+ expect(script.segments[0]!.narration).not.toContain('火柴人');
+ expect(script.segments.every(segment => segment.estimatedDurationSeconds <= 4.5)).toBe(true);
+
+ const scriptRequests = completionRequests.filter(request => request.stageId === 'script');
+ expect(scriptRequests).toHaveLength(1);
+ expect(scriptRequests[0]!.prompt).toContain('只生成可直接用于配音的旁白单元');
+ expect(scriptRequests[0]!.prompt).toContain('不要生成画面、镜头、生图或制作说明');
+ expect(scriptRequests[0]!.prompt).not.toContain('纸面铅笔手绘');
+ expect(scriptRequests[0]!.prompt).not.toContain('student');
+ } finally {
+ await runner.close();
+ db.close();
+ }
+ });
+
+ it('regenerates the complete script with validation evidence instead of patching individual narration', async () => {
+ let scriptCalls = 0;
+ const context = setup({
+ narrationUnits: 120,
+ completionOverride({ stageId }) {
+ if (stageId !== 'script') return undefined;
+ scriptCalls += 1;
+ return scriptCalls === 1
+ ? generatedScript(1, 12)
+ : generatedScript(7, 120);
+ }
+ });
+ const { db, service, dispatcher, runner, workflow, completionRequests } = context;
+ try {
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: {
+ sourceType: 'text',
+ sourceText: '完整来源内容。',
+ targetDurationSeconds: 30,
+ targetLanguage: 'zh-CN'
+ }
+ });
+ await runContentPipeline({ service, dispatcher, runner, workflow, jobId: job.id });
+ const script = readArtifact(service.getJob(job.id)!, 'script_manifest') as {
+ totalNarrationUnits: number;
+ };
+
+ expect(scriptCalls).toBe(2);
+ expect(script.totalNarrationUnits).toBe(120);
+ const secondPrompt = completionRequests.filter(request => request.stageId === 'script')[1]!.prompt;
+ expect(secondPrompt).toContain('上一份完整草稿');
+ expect(secondPrompt).toContain('旁白总字符数');
+ expect(secondPrompt).toContain('重新生成整份脚本');
+ expect(completionRequests.some(request => (
+ request.stageId === 'script-narration'
+ || request.stageId === 'script-visuals'
+ || request.stageId === 'semantic-review'
+ ))).toBe(false);
+ } finally {
+ await runner.close();
+ db.close();
+ }
+ });
+
+ it('rejects a content plan that silently drops a source claim', async () => {
+ const context = setup({
+ completionOverride({ stageId }) {
+ if (stageId === 'source-brief') {
+ return {
+ title: '两项来源',
+ summary: '包含两项内容',
+ audience: '普通观众',
+ claims: [
+ { id: 'claim-001', text: '第一项内容', sourceSpanIds: ['source-001'] },
+ { id: 'claim-002', text: '第二项内容', sourceSpanIds: ['source-002'] }
+ ]
+ };
+ }
+ if (stageId === 'content-plan') {
+ return {
+ title: '错误计划',
+ audience: '普通观众',
+ objective: '测试遗漏',
+ retainedClaimIds: ['claim-001'],
+ discardedClaimIds: [],
+ sections: [{ id: 'section-01', title: '第一项', claimIds: ['claim-001'] }]
+ };
+ }
+ return undefined;
+ }
+ });
+ const { db, service, dispatcher, runner, workflow } = context;
+ try {
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: {
+ sourceType: 'text',
+ sourceText: '第一项内容。第二项内容。',
+ targetDurationSeconds: 30
+ }
+ });
+ let queued = dispatcher.dispatch(job.id, {
+ action: 'run-stage',
+ expectedRevision: job.revision,
+ idempotencyKey: 'stickman-missing-claim',
+ input: { stageId: 'ingest-text' }
+ }, 'user').commandReceipt.stageRunId!;
+ for (const expectedStage of ['ingest-text', 'source-brief']) {
+ const completed = await runner.runStageRun(queued);
+ expect(completed.status).toBe('succeeded');
+ await workflow.handleStageChanged(completed);
+ queued = service.getJob(job.id)!.stages.find(stage => stage.status === 'queued')!.id;
+ expect(completed.stageId).toBe(expectedStage);
+ }
+
+ expect(await runner.runStageRun(queued)).toMatchObject({
+ stageId: 'content-plan',
+ status: 'failed',
+ errorCode: 'creator_content_plan_claim_partition_invalid'
+ });
+ expect(service.getJob(job.id)!.artifacts.some(artifact => (
+ artifact.kind === 'script_manifest' && artifact.status === 'completed'
+ ))).toBe(false);
+ } finally {
+ await runner.close();
+ db.close();
+ }
+ });
+
+ it('stops after real audio timing and only derives shots after the user continues', async () => {
+ const context = setup({
+ segmentCount: 3,
+ narrationUnits: 40,
+ narrationDurationSeconds: 5.6
+ });
+ const { db, service, dispatcher, runner, workflow } = context;
+ try {
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: {
+ sourceType: 'text',
+ sourceText: '这是一段完整来源内容。',
+ targetDurationSeconds: 10,
+ targetLanguage: 'zh-CN',
+ ttsProvider: 'openai',
+ ttsModel: 'gpt-4o-mini-tts',
+ voiceCode: 'alloy'
+ }
+ });
+ await runContentPipeline({ service, dispatcher, runner, workflow, jobId: job.id });
+ const reviewJob = service.getJob(job.id)!;
+ const draft = reviewJob.artifacts.find(artifact => (
+ artifact.kind === 'script_manifest' && artifact.status === 'completed'
+ ))!;
+ const approved = service.applyAction(job.id, {
+ actor: 'user',
+ action: 'approve-script',
+ expectedRevision: reviewJob.revision,
+ input: { artifactId: draft.id, revision: reviewJob.revision }
+ });
+ await workflow.handleAction(approved.job, 'approve-script');
+
+ const lockedJob = service.getJob(job.id)!;
+ const lockedArtifact = lockedJob.artifacts.find(artifact => (
+ artifact.kind === 'script_manifest' && artifact.status === 'completed'
+ ))!;
+ const locked = JSON.parse(readFileSync(lockedArtifact.path!, 'utf8')) as {
+ reviewStatus: string;
+ contentLocked: boolean;
+ };
+ expect(lockedArtifact.id).not.toBe(draft.id);
+ expect(lockedArtifact.sourceArtifactIds).toContain(draft.id);
+ expect(locked).toMatchObject({ reviewStatus: 'approved', contentLocked: true });
+ expect(lockedJob.state.approvedScriptArtifactId).toBe(lockedArtifact.id);
+ expect(lockedJob.artifacts.find(artifact => artifact.id === draft.id)?.status).toBe('stale');
+
+ for (const expectedScope of ['segment-01', 'segment-02', 'segment-03']) {
+ const narrationStage = service.getJob(job.id)!.stages.find(stage => (
+ stage.stageId === 'narration' && stage.status === 'queued'
+ ))!;
+ expect(narrationStage.scopeKey).toBe(expectedScope);
+ const completed = await runner.runStageRun(narrationStage.id);
+ expect(completed.status).toBe('succeeded');
+ await workflow.handleStageChanged(completed);
+ }
+ const pendingTiming = service.getJob(job.id)!.stages.find(stage => stage.status === 'queued')!;
+ expect(pendingTiming.stageId).toBe('audio-timing');
+ const completedTiming = await runner.runStageRun(pendingTiming.id);
+ expect(completedTiming.status).toBe('succeeded');
+ await workflow.handleStageChanged(completedTiming);
+
+ const audioReadyJob = service.getJob(job.id)!;
+ expect(audioReadyJob.state.workflowTarget).toBe('audio_ready');
+ expect(audioReadyJob.stages.some(stage => stage.stageId === 'storyboard')).toBe(false);
+ await expect(workflow.validateStage(audioReadyJob, 'storyboard')).rejects.toMatchObject({
+ code: 'creator_workflow_gate_required'
+ });
+
+ const audioTimingArtifact = audioReadyJob.artifacts.find(artifact => (
+ artifact.kind === 'audio_timing' && artifact.status === 'completed'
+ ))!;
+ const continued = service.applyAction(job.id, {
+ actor: 'user',
+ action: 'continue-after-audio',
+ expectedRevision: audioReadyJob.revision,
+ input: { artifactId: audioTimingArtifact.id, revision: audioReadyJob.revision }
+ });
+ await workflow.handleAction(continued.job, 'continue-after-audio');
+ const pendingStoryboard = service.getJob(job.id)!.stages.find(stage => stage.status === 'queued')!;
+ expect(pendingStoryboard.stageId).toBe('storyboard');
+ const completedStoryboard = await runner.runStageRun(pendingStoryboard.id);
+ expect(completedStoryboard.status).toBe('succeeded');
+ await workflow.handleStageChanged(completedStoryboard);
+
+ const shotSpec = readArtifact(service.getJob(job.id)!, 'shot_spec') as {
+ scriptArtifactId: string;
+ shots: Array<{
+ sourceSegmentId: string;
+ visualDescription: string;
+ startSeconds: number;
+ endSeconds: number;
+ }>;
+ };
+ expect(shotSpec.scriptArtifactId).toBe(lockedArtifact.id);
+ expect(shotSpec.shots).toHaveLength(3);
+ expect(shotSpec.shots[0]).toMatchObject({
+ sourceSegmentId: 'segment-01',
+ visualDescription: '人物在清晰场景中忠实表现第1段来源含义',
+ startSeconds: 0,
+ endSeconds: 5.6
+ });
+ expect(service.getJob(job.id)!.stages.some(stage => (
+ stage.stageId === 'style-assets' && stage.status === 'queued'
+ ))).toBe(true);
+ expect(service.getJob(job.id)!.stages.some(stage => stage.stageId === 'semantic-review')).toBe(false);
+ } finally {
+ await runner.close();
+ db.close();
+ }
+ });
+
+ it('uses the selected reference image as the sole character authority in image prompts', async () => {
+ const context = setup();
+ const { db, repository, service, runner } = context;
+ try {
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: {
+ characterAsset: { assetId: 'stickman.character.student', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.minimal-ink', revision: 1 }
+ }
+ });
+ const shotSpecPath = join(tempDir, 'identity-shot-spec.json');
+ writeFileSync(shotSpecPath, JSON.stringify({
+ scriptArtifactId: 'script-1',
+ audioTimingArtifactId: 'audio-timing-1',
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ shots: [{
+ id: 'shot-01',
+ sourceSegmentId: 'segment-01',
+ semanticAnchor: '女孩开始阅读',
+ visualDescription: '女孩在书桌前打开一本书',
+ compositionAndAction: '女孩坐在画面中央,双手打开桌上的书',
+ keyObjects: ['书桌', '书'],
+ continuityReason: '',
+ motion: 'static',
+ motionReason: '静态构图清楚展示阅读动作',
+ startSeconds: 0,
+ endSeconds: 4,
+ durationSeconds: 4
+ }]
+ }));
+ repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_spec',
+ status: 'completed',
+ path: shotSpecPath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const assetsStage = await runner.run(job.id, 'style-assets');
+ expect(assetsStage.status).toBe('succeeded');
+ const stage = await runner.run(job.id, 'prompt-pack');
+ expect(stage.status).toBe('succeeded');
+ const completedJob = service.getJob(job.id)!;
+ const promptPackArtifact = completedJob.artifacts.find(artifact => (
+ artifact.kind === 'image_prompt_pack' && artifact.status === 'completed'
+ ));
+ expect(promptPackArtifact?.metadata.contract).toBe('stickman-visual-profile-prompt-v2');
+ const promptPack = readArtifact(completedJob, 'image_prompt_pack') as {
+ prompts: Array<{ prompt: string }>;
+ };
+ const prompt = promptPack.prompts[0]!.prompt;
+ expect(prompt).toContain('CHARACTER IDENTITY source of truth');
+ expect(prompt).toContain('oversized circular white head, chin-length straight bob haircut');
+ expect(prompt).toContain('short-sleeve sailor-collar school uniform');
+ expect(prompt).toContain('Forbidden identity changes: eyeglasses, hoodies, jackets');
+ expect(prompt).toContain('Palette: strict monochrome black, white, and light gray only');
+ expect(prompt).toContain('Only pose, facial expression, camera framing, and interaction with scene objects may change');
+ expect(prompt).not.toContain('Character:');
+ expect(prompt).not.toContain('背包与轻快动作');
+ expect(prompt).toContain('Concrete scene: 女孩在书桌前打开一本书');
+ expect(prompt).toContain('Composition and action: 女孩坐在画面中央,双手打开桌上的书');
+ expect(prompt).toContain('Required objects: 书桌; 书');
+ } finally {
+ await runner.close();
+ db.close();
+ }
+ });
+
+ it('continues all missing shots after an ordinary failure with a monotonic generation', async () => {
+ const context = setup({ segmentCount: 2, narrationUnits: 20 });
+ const { db, repository, service, runner, workflow } = context;
+ try {
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: {
+ sourceType: 'text',
+ sourceText: '这是用于验证镜头重新生成调度的完整来源文本。',
+ targetDurationSeconds: 5,
+ targetLanguage: 'zh-CN'
+ }
+ });
+ await runContentPipeline({
+ service,
+ dispatcher: context.dispatcher,
+ runner,
+ workflow,
+ jobId: job.id
+ });
+ const reviewJob = service.getJob(job.id)!;
+ const script = reviewJob.artifacts.find(artifact => (
+ artifact.kind === 'script_manifest' && artifact.status === 'completed'
+ ))!;
+ const approved = service.applyAction(job.id, {
+ actor: 'user',
+ action: 'approve-script',
+ expectedRevision: reviewJob.revision,
+ input: { artifactId: script.id, revision: reviewJob.revision }
+ });
+ await workflow.handleAction(approved.job, 'approve-script');
+
+ for (const expectedScope of ['segment-01', 'segment-02']) {
+ const stage = service.getJob(job.id)!.stages.find(candidate => (
+ candidate.stageId === 'narration' && candidate.status === 'queued'
+ ))!;
+ expect(stage.scopeKey).toBe(expectedScope);
+ const completed = await runner.runStageRun(stage.id);
+ await workflow.handleStageChanged(completed);
+ }
+ for (const expectedStage of ['audio-timing', 'storyboard']) {
+ const stage = service.getJob(job.id)!.stages.find(candidate => candidate.status === 'queued')!;
+ expect(stage.stageId).toBe(expectedStage);
+ const completed = await runner.runStageRun(stage.id);
+ await workflow.handleStageChanged(completed);
+ if (expectedStage === 'audio-timing') {
+ const ready = service.getJob(job.id)!;
+ const timing = ready.artifacts.find(artifact => (
+ artifact.kind === 'audio_timing' && artifact.status === 'completed'
+ ))!;
+ const continued = service.applyAction(job.id, {
+ actor: 'user',
+ action: 'continue-after-audio',
+ expectedRevision: ready.revision,
+ input: { artifactId: timing.id, revision: ready.revision }
+ });
+ await workflow.handleAction(continued.job, 'continue-after-audio');
+ }
+ }
+ for (const expectedStage of ['style-assets', 'prompt-pack']) {
+ const stage = service.getJob(job.id)!.stages.find(candidate => candidate.status === 'queued')!;
+ expect(stage.stageId).toBe(expectedStage);
+ const completed = await runner.runStageRun(stage.id);
+ await workflow.handleStageChanged(completed);
+ }
+
+ const firstImageStage = service.getJob(job.id)!.stages.find(stage => (
+ stage.stageId === 'images' && stage.scopeKey === 'shot-01' && stage.status === 'queued'
+ ))!;
+ repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-01',
+ inputFingerprint: firstImageStage.inputFingerprint,
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ repository.updateStageRun({ id: firstImageStage.id, status: 'succeeded' });
+ await workflow.handleStageChanged(repository.getStageRun(firstImageStage.id)!);
+
+ const failedStage = service.getJob(job.id)!.stages.find(stage => (
+ stage.stageId === 'images' && stage.scopeKey === 'shot-02' && stage.status === 'queued'
+ ))!;
+ repository.updateStageRun({
+ id: failedStage.id,
+ status: 'failed',
+ errorCode: 'creator_stage_failed',
+ errorMessage: 'Image generation failed'
+ });
+ const waiting = service.setNeedsInput(job.id, {
+ code: 'creator_stage_failed',
+ message: 'Image generation failed',
+ resumeStageId: 'images'
+ });
+ const replacementPreviousShot = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: null,
+ scopeKey: 'shot-01',
+ inputFingerprint: firstImageStage.inputFingerprint,
+ sha256: 'f'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+
+ const continued = service.applyAction(job.id, {
+ actor: 'user',
+ action: 'generate-missing-shots',
+ expectedRevision: waiting.revision,
+ input: { revision: waiting.revision }
+ });
+ expect(continued.job).toMatchObject({
+ status: 'running',
+ state: { workflowTarget: 'visuals_ready', currentStage: 'images' }
+ });
+ expect(continued.job.state).not.toHaveProperty('needsInput');
+
+ await workflow.handleAction(continued.job, 'generate-missing-shots');
+
+ const latest = service.getJob(job.id)!;
+ const shotRuns = latest.stages.filter(stage => (
+ stage.stageId === 'images' && stage.scopeKey === 'shot-02'
+ ));
+ expect(shotRuns).toHaveLength(2);
+ expect(shotRuns.at(-1)).toMatchObject({
+ status: 'queued',
+ idempotencyKey: expect.stringMatching(/:2:stage$/)
+ });
+ expect(shotRuns.at(-1)!.inputFingerprint).not.toBe(failedStage.inputFingerprint);
+ expect(latest.artifacts.find(artifact => artifact.id === replacementPreviousShot.id)?.status)
+ .toBe('completed');
+ } finally {
+ await runner.close();
+ db.close();
+ }
+ });
+
+ it('keeps animation blocked until the current visuals are explicitly continued', async () => {
+ const context = setup();
+ const { db, repository, service, workflow } = context;
+ try {
+ const job = service.createJob({
+ projectId: 'p1',
+ templateId: 'stickman-video',
+ state: {
+ currentStage: 'visual-validation',
+ workflowTarget: 'visuals_ready'
+ }
+ });
+ const script = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'script_manifest',
+ status: 'completed',
+ path: null,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_spec',
+ status: 'completed',
+ path: null,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const validation = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'visual_validation',
+ status: 'completed',
+ path: null,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
+ sourceArtifactIds: [],
+ metadata: {}
+ });
+ const beforeSettings = service.getJob(job.id)!;
+ const ready = service.applyAction(job.id, {
+ actor: 'user',
+ action: 'update-settings',
+ expectedRevision: beforeSettings.revision,
+ input: { patch: { approvedScriptArtifactId: script.id } }
+ }).job;
+
+ await expect(workflow.validateStage(ready, 'timeline')).rejects.toMatchObject({
+ code: 'creator_workflow_gate_required'
+ });
+ const continued = service.applyAction(job.id, {
+ actor: 'user',
+ action: 'continue-after-visuals',
+ expectedRevision: ready.revision,
+ input: { artifactId: validation.id, revision: ready.revision }
+ });
+ expect(continued.job.state).toMatchObject({
+ workflowTarget: 'delivery_ready',
+ currentStage: 'timeline'
+ });
+ } finally {
+ db.close();
+ }
+ });
+});
+
+function generatedScript(segmentCount: number, totalUnits: number) {
+ const baseUnits = Math.floor(totalUnits / segmentCount);
+ let remainder = totalUnits % segmentCount;
+ return {
+ title: '忠实来源脚本',
+ segments: Array.from({ length: segmentCount }, (_, index) => {
+ const units = baseUnits + (remainder-- > 0 ? 1 : 0);
+ return {
+ narration: narrationWithUnits(index + 1, units),
+ claimIds: ['claim-001'],
+ sourceSpanIds: ['source-001']
+ };
+ })
+ };
+}
+
+function generatedStoryboard(segmentCount: number) {
+ return {
+ shots: Array.from({ length: segmentCount }, (_, index) => ({
+ sourceSegmentId: `segment-${String(index + 1).padStart(2, '0')}`,
+ semanticAnchor: `第 ${index + 1} 段来源的唯一含义`,
+ visualDescription: `人物在清晰场景中忠实表现第${index + 1}段来源含义`,
+ compositionAndAction: '人物位于画面中央,以清晰动作表达当前含义',
+ keyObjects: ['当前事件所需物体'],
+ continuityReason: index === 0 ? '' : '延续上一段事件顺序',
+ motion: 'static',
+ motionReason: '静态构图足以清楚表达当前含义'
+ }))
+ };
+}
+
+function narrationWithUnits(index: number, units: number): string {
+ const seed = Array.from(`第${index}段忠实讲述来源中的完整内容并保持人物关系和事件顺序`)
+ .filter(character => /[\p{L}\p{N}]/u.test(character));
+ const output: string[] = [];
+ while (output.length < units) output.push(...seed);
+ return `${output.slice(0, units).join('')}。`;
+}
+
+async function runContentPipeline(input: {
+ service: ReturnType<typeof createCreatorService>;
+ dispatcher: ReturnType<typeof createCreatorCommandDispatcher>;
+ runner: ReturnType<typeof createCreatorStageRunner>;
+ workflow: ReturnType<typeof createStickmanVideoWorkflow>;
+ jobId: string;
+}) {
+ const initial = input.service.getJob(input.jobId)!;
+ let queued = input.dispatcher.dispatch(input.jobId, {
+ action: 'run-stage',
+ expectedRevision: initial.revision,
+ idempotencyKey: `stickman-content-${input.jobId}`,
+ input: { stageId: 'ingest-text' }
+ }, 'user').commandReceipt.stageRunId!;
+
+ for (const expectedStage of ['ingest-text', 'source-brief', 'content-plan', 'script']) {
+ const completed = await input.runner.runStageRun(queued);
+ expect(completed).toMatchObject({ stageId: expectedStage, status: 'succeeded' });
+ await input.workflow.handleStageChanged(completed);
+ if (expectedStage !== 'script') {
+ queued = input.service.getJob(input.jobId)!.stages.find(stage => stage.status === 'queued')!.id;
+ }
+ }
+}
+
+function readArtifact(job: NonNullable<ReturnType<ReturnType<typeof createCreatorService>['getJob']>>, kind: string): unknown {
+ const artifact = [...job.artifacts].reverse().find(item => (
+ item.kind === kind && item.status === 'completed'
+ ));
+ if (artifact?.path === null || artifact === undefined) throw new Error(`Missing artifact: ${kind}`);
+ return JSON.parse(readFileSync(artifact.path, 'utf8')) as unknown;
+}
diff --git a/apps/daemon/test/unit/creator-storage.test.ts b/apps/daemon/test/unit/creator-storage.test.ts
index 9079781c..08f7ef76 100644
--- a/apps/daemon/test/unit/creator-storage.test.ts
+++ b/apps/daemon/test/unit/creator-storage.test.ts
@@ -33,6 +33,9 @@ describe('creator storage', () => {
kind: 'target_subtitle',
status: 'completed',
path: join(tempDir, 'target.srt'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { language: 'en' }
});
@@ -55,6 +58,7 @@ describe('creator storage', () => {
revision: 0,
state: { targetLanguage: 'en' },
artifacts: [{ kind: 'target_subtitle', version: 1, status: 'completed' }],
+ providerRequests: [],
activities: [{ action: 'create-job', actor: 'user' }]
});
});
@@ -87,6 +91,73 @@ describe('creator storage', () => {
expect(restored?.status).toBe('needs_input');
});
+ it('persists scoped stage runs and artifacts while rejecting duplicate active identities', () => {
+ tempDir = mkdtempSync(join(tmpdir(), 'creator-storage-'));
+ const path = join(tempDir, 'app.sqlite');
+ const firstDb = openRuntimeDatabase(path);
+ const repository = createCreatorRepository(firstDb);
+ const job = repository.createJob({
+ projectId: 'project_1',
+ templateId: 'image-generation',
+ templateVersion: 1,
+ status: 'running',
+ state: { prompt: 'scope persistence' }
+ });
+ const first = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'queued',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ });
+
+ expect(() => repository.createStageRun({
+ jobId: job.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'running',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ })).toThrow();
+
+ repository.updateStageRun({ id: first.id, status: 'failed' });
+ const retry = repository.createStageRun({
+ jobId: job.id,
+ stageId: 'generate',
+ executor: 'image',
+ status: 'queued',
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ });
+ repository.insertArtifact({
+ jobId: job.id,
+ kind: 'shot_image',
+ status: 'completed',
+ path: join(tempDir, 'shot-01.png'),
+ sourceArtifactIds: [],
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64),
+ sha256: 'b'.repeat(64),
+ metadata: { width: 1280, height: 720 }
+ });
+ firstDb.close();
+
+ const secondDb = openRuntimeDatabase(path);
+ const restored = createCreatorRepository(secondDb).getJob(job.id)!;
+ secondDb.close();
+
+ expect(restored.stages.find(stage => stage.id === retry.id)).toMatchObject({
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ });
+ expect(restored.artifacts[0]).toMatchObject({
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64),
+ sha256: 'b'.repeat(64)
+ });
+ });
+
it('repairs project snapshots that incorrectly started from the UI placeholder V2', () => {
tempDir = mkdtempSync(join(tmpdir(), 'creator-storage-'));
const path = join(tempDir, 'app.sqlite');
@@ -104,6 +175,9 @@ describe('creator storage', () => {
kind: 'target_subtitle',
status: 'completed',
path: join(tempDir, 'target.srt'),
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { resultVersion: 2 }
});
@@ -176,6 +250,9 @@ describe('creator storage', () => {
kind: 'target_subtitle',
status: 'completed',
path: targetPath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { resultVersion: 1, fileName: 'target_language_srt.srt' }
});
@@ -210,6 +287,9 @@ describe('creator storage', () => {
version: 1,
status: 'completed',
path: verticalPath,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [target.id],
metadata: {
resultVersion: 1,
diff --git a/apps/daemon/test/unit/creator-template-registry.test.ts b/apps/daemon/test/unit/creator-template-registry.test.ts
index ab9528bd..ce7c7e7b 100644
--- a/apps/daemon/test/unit/creator-template-registry.test.ts
+++ b/apps/daemon/test/unit/creator-template-registry.test.ts
@@ -7,10 +7,39 @@ import {
createXiaohongshuPostTemplate,
createVideoDownloadTemplate,
createVideoGenerationTemplate,
+ createDefaultCreatorTemplateRegistry,
+ createStickmanVideoTemplate,
createVideoTranslationTemplate
} from '../../src/creator/templates/registry.js';
describe('creator template registry', () => {
+ it('exposes only stickman-video version 2 and rejects v2 in an old registry fixture', () => {
+ const production = createDefaultCreatorTemplateRegistry();
+ const stickman = production.list().filter(template => template.id === 'stickman-video');
+
+ expect(stickman).toHaveLength(1);
+ expect(stickman[0]).toMatchObject({
+ version: 2,
+ stages: expect.arrayContaining([
+ expect.objectContaining({
+ id: 'images',
+ jobCompletionPolicy: 'continue',
+ invalidateDependentArtifacts: false
+ }),
+ expect.objectContaining({ id: 'package-validation', jobCompletionPolicy: 'complete' })
+ ])
+ });
+ expect(stickman[0]!.actions.map(action => action.id)).toContain('generate-missing-shots');
+ const v2 = createStickmanVideoTemplate();
+ const oldRegistry = createCreatorTemplateRegistry([{
+ ...v2,
+ version: 1,
+ stages: [],
+ actions: []
+ }]);
+ expect(() => oldRegistry.get('stickman-video', 2)).toThrow(/unknown creator template/i);
+ });
+
it('registers the current cover workflow with real source and artifact stages', () => {
const template = createCoverTemplate();
@@ -219,6 +248,25 @@ describe('creator template registry', () => {
expect(state).not.toHaveProperty('voiceName');
});
+ it('uses the shared TTS settings contract for the single stickman template version', () => {
+ const template = createStickmanVideoTemplate();
+ const state = template.inputSchema.parse({});
+
+ expect(state).not.toHaveProperty('voice');
+ expect(state).not.toHaveProperty('ttsProvider');
+ expect(state).not.toHaveProperty('ttsModel');
+ expect(state).not.toHaveProperty('voiceCode');
+ expect(state).not.toHaveProperty('voiceName');
+ expect(createDefaultCreatorTemplateRegistry().list().filter(template => (
+ template.id === 'stickman-video'
+ ))).toHaveLength(1);
+ expect(template.stages.some(stage => stage.id === 'acquire-source')).toBe(false);
+ expect(template.stages.find(stage => stage.id === 'source-transcript')).toMatchObject({
+ executor: 'krillinai',
+ inputArtifacts: []
+ });
+ });
+
it('passes the dedicated short subtitle into vertical rendering when available', () => {
const template = createVideoTranslationTemplate();
expect(template.stages.find(stage => stage.id === 'subtitle')?.outputArtifacts).toContainEqual({
diff --git a/apps/daemon/test/unit/creator-tools.test.ts b/apps/daemon/test/unit/creator-tools.test.ts
index c0950d7a..5a7b62d1 100644
--- a/apps/daemon/test/unit/creator-tools.test.ts
+++ b/apps/daemon/test/unit/creator-tools.test.ts
@@ -72,6 +72,8 @@ function job(status: CreatorJob['stages'][number]['status'], revision = 1): Crea
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'stage_1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {},
errorCode: null,
errorMessage: null,
@@ -79,6 +81,7 @@ function job(status: CreatorJob['stages'][number]['status'], revision = 1): Crea
finishedAt: status === 'running' ? null : '2026-09-03T00:00:01.000Z'
}],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt: '2026-09-03T00:00:00.000Z',
updatedAt: '2026-09-03T00:00:01.000Z'
diff --git a/apps/daemon/test/unit/creator-video-executor.test.ts b/apps/daemon/test/unit/creator-video-executor.test.ts
index 27aefa3b..07e0dec2 100644
--- a/apps/daemon/test/unit/creator-video-executor.test.ts
+++ b/apps/daemon/test/unit/creator-video-executor.test.ts
@@ -373,6 +373,7 @@ function stageInput(
agentThreadId: null,
stages: [],
artifacts: inputArtifacts,
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -404,6 +405,8 @@ function stageRun(
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress,
errorCode: null,
errorMessage: null,
@@ -424,6 +427,9 @@ function artifact(
version: 1,
status: 'completed',
path,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata,
createdAt: '2026-09-07T00:00:00.000Z'
diff --git a/apps/daemon/test/unit/creator-wechat-article.test.ts b/apps/daemon/test/unit/creator-wechat-article.test.ts
index 12480ae4..4949d32c 100644
--- a/apps/daemon/test/unit/creator-wechat-article.test.ts
+++ b/apps/daemon/test/unit/creator-wechat-article.test.ts
@@ -535,6 +535,9 @@ function outputArtifact(id: string, output: {
kind: output.kind,
status: output.status,
path: output.path,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: output.sourceArtifactIds ?? [],
metadata: output.metadata ?? {},
createdAt: '2026-09-07T00:00:00.000Z'
diff --git a/apps/daemon/test/unit/krillin-tts-service.test.ts b/apps/daemon/test/unit/krillin-tts-service.test.ts
index d8770f37..a516bf2a 100644
--- a/apps/daemon/test/unit/krillin-tts-service.test.ts
+++ b/apps/daemon/test/unit/krillin-tts-service.test.ts
@@ -1,5 +1,5 @@
import { createDefaultCreatorServicesConfig } from '@opencreator/protocol';
-import { mkdtemp, writeFile } from 'node:fs/promises';
+import { mkdtemp } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -13,6 +13,7 @@ describe('KrillinTtsService', () => {
const roots: string[] = [];
afterEach(async () => {
+ vi.unstubAllGlobals();
const { rm } = await import('node:fs/promises');
await Promise.all(roots.splice(0).map(root => rm(root, { recursive: true, force: true })));
});
@@ -154,22 +155,19 @@ describe('KrillinTtsService', () => {
expect(executeUtility).toHaveBeenCalledOnce();
});
- it('synthesizes through the Krillin speech command with provider controls', async () => {
+ it('synthesizes through the configured provider with voice controls', async () => {
const root = await temporaryRoot();
const config = createDefaultCreatorServicesConfig();
config.tts.openai.apiKey = 'sk-test';
- const executeUtility = vi.fn(async input => {
- const outputIndex = input.args.indexOf('--output');
- const outputPath = input.args[outputIndex + 1];
- expect(outputPath).toBeTypeOf('string');
- await writeFile(outputPath!, Buffer.from('speech-audio'));
- return { ok: true, outputs: { tts_audio: outputPath } };
- });
+ const executeSynthesis = vi.fn(async () => ({
+ content: Buffer.from('speech-audio'),
+ format: 'mp3' as const
+ }));
const service = createKrillinTtsService({
resourceRoot: join(root, 'runtime'),
workRoot: join(root, 'work'),
configStore: createConfigStore(config),
- executeUtility
+ executeSynthesis
});
const result = await service.synthesize({
@@ -189,18 +187,67 @@ describe('KrillinTtsService', () => {
mime: 'audio/mpeg'
});
expect(result.content.toString()).toBe('speech-audio');
- expect(executeUtility).toHaveBeenCalledWith(expect.objectContaining({
- args: expect.arrayContaining([
- 'speech',
- '--provider', 'openai',
- '--voice', 'marin',
- '--format', 'mp3',
- '--speed', '1.1',
- '--instructions', 'Speak warmly.'
- ])
+ expect(executeSynthesis).toHaveBeenCalledWith(expect.objectContaining({
+ provider: 'openai',
+ model: 'gpt-4o-mini-tts',
+ voiceId: 'marin',
+ format: 'mp3',
+ speed: 1.1,
+ instructions: 'Speak warmly.'
}));
});
+ it('uses the Qwen multimodal endpoint and downloads the returned Aliyun audio', async () => {
+ const root = await temporaryRoot();
+ const config = createDefaultCreatorServicesConfig();
+ config.tts.provider = 'aliyun';
+ config.tts.aliyun.baseUrl = 'https://tts.example.com/api/v1';
+ config.tts.aliyun.apiKey = 'dashscope-key';
+ const wav = Buffer.from('RIFFfixture-wave');
+ const fetchMock = vi.fn()
+ .mockResolvedValueOnce(new Response(JSON.stringify({
+ output: { audio: { url: 'http://audio.example.com/result.wav?signature=secret' } }
+ }), { status: 200, headers: { 'content-type': 'application/json' } }))
+ .mockResolvedValueOnce(new Response(wav, {
+ status: 200,
+ headers: { 'content-type': 'audio/wav' }
+ }));
+ vi.stubGlobal('fetch', fetchMock);
+ const service = createKrillinTtsService({
+ resourceRoot: join(root, 'runtime'),
+ workRoot: join(root, 'work'),
+ configStore: createConfigStore(config)
+ });
+
+ const result = await service.synthesize({
+ text: '测试文本',
+ provider: 'aliyun',
+ model: 'qwen3-tts-flash',
+ voiceId: 'Cherry',
+ format: 'wav'
+ });
+
+ expect(result).toMatchObject({
+ provider: 'aliyun',
+ model: 'qwen3-tts-flash',
+ voiceId: 'Cherry',
+ format: 'wav',
+ mime: 'audio/wav'
+ });
+ expect(result.content).toEqual(wav);
+ expect(fetchMock.mock.calls[0]![0]).toBe(
+ 'https://tts.example.com/api/v1/services/aigc/multimodal-generation/generation'
+ );
+ const request = JSON.parse(String((fetchMock.mock.calls[0]![1] as RequestInit).body));
+ expect(request).toEqual({
+ model: 'qwen3-tts-flash',
+ input: { text: '测试文本', voice: 'Cherry', language_type: 'Chinese' }
+ });
+ expect(String(fetchMock.mock.calls[1]![0])).toBe(
+ 'https://audio.example.com/result.wav?signature=secret'
+ );
+ });
+
it('requires the configured provider API key before synthesis', async () => {
const root = await temporaryRoot();
const service = createKrillinTtsService({
diff --git a/apps/desktop/e2e/creator-packaged-app.spec.ts b/apps/desktop/e2e/creator-packaged-app.spec.ts
index b5cf8f81..f00e5f3b 100644
--- a/apps/desktop/e2e/creator-packaged-app.spec.ts
+++ b/apps/desktop/e2e/creator-packaged-app.spec.ts
@@ -105,6 +105,44 @@ test('实际 Desktop 包创建并重启恢复 Creator Job,且使用内嵌 Runt
'SKILL.md',
'manifest.json'
]);
+ const stickmanRuntimeRoot = packagedStickmanRuntimeRoot();
+ const stickmanRuntimeManifest = JSON.parse(
+ readFileSync(join(stickmanRuntimeRoot, 'manifest.json'), 'utf8')
+ ) as {
+ platform: string;
+ arch: string;
+ remotionVersion: string;
+ chromiumVersion: string;
+ browserExecutable: string;
+ resources: Array<{ path: string; kind: string; platform: string; arch: string }>;
+ };
+ expect(stickmanRuntimeManifest).toMatchObject({
+ platform: process.platform,
+ arch: process.arch,
+ remotionVersion: '4.0.473',
+ browserExecutable: executableResource('browser/chrome-headless-shell')
+ });
+ expect(stickmanRuntimeManifest.chromiumVersion).toMatch(/^\d+\.\d+\.\d+\.\d+$/);
+ expect(stickmanRuntimeManifest.resources).toEqual(expect.arrayContaining([
+ expect.objectContaining({
+ path: stickmanRuntimeManifest.browserExecutable,
+ kind: 'browser',
+ platform: process.platform,
+ arch: process.arch
+ }),
+ expect.objectContaining({
+ path: 'fonts/NotoSansSC-Bold.woff2',
+ kind: 'font',
+ platform: process.platform,
+ arch: process.arch
+ }),
+ expect.objectContaining({
+ path: 'visual-assets/catalog.json',
+ kind: 'visual-asset',
+ platform: process.platform,
+ arch: process.arch
+ })
+ ]));
const projectDir = join(fixture.root, 'creator-workspace');
mkdirSync(projectDir, { recursive: true });
@@ -131,6 +169,27 @@ test('实际 Desktop 包创建并重启恢复 Creator Job,且使用内嵌 Runt
'stickman-video'
])
);
+ const creatorCapabilities = await runtimeRequest<{
+ platform: string;
+ arch: string;
+ transcription: {
+ providers: Array<{ provider: string; available: boolean; models: string[] }>;
+ };
+ }>(currentApp.page, 'GET', '/creator-services/capabilities');
+ expect(creatorCapabilities.status).toBe(200);
+ expect(creatorCapabilities.body).toMatchObject({
+ platform: 'win32',
+ arch: 'x64',
+ transcription: {
+ providers: expect.arrayContaining([
+ expect.objectContaining({
+ provider: 'whisper.cpp',
+ available: true,
+ models: ['tiny', 'medium', 'large-v2']
+ })
+ ])
+ }
+ });
const ytDlpStatus = await runtimeRequest<{
ytDlp: {
channel: string;
@@ -180,6 +239,13 @@ test('实际 Desktop 包创建并重启恢复 Creator Job,且使用内嵌 Runt
await expect(currentApp.page.getByRole('tab', { name: '模型服务' }))
.toHaveAttribute('aria-selected', 'true');
await expect(currentApp.page.getByRole('group', { name: '模型服务' })).toBeVisible();
+ await currentApp.page.getByRole('tab', { name: '语音识别' }).click();
+ const localWhisper = currentApp.page.getByRole('button', { name: '本地 Whisper' });
+ await expect(localWhisper).toBeEnabled();
+ await localWhisper.click();
+ await expect(currentApp.page.getByRole('combobox', { name: '语音识别服务' }))
+ .toHaveText('Whisper.cpp');
+ await expect(currentApp.page.getByRole('combobox', { name: '本地模型' })).toHaveText('tiny');
await currentApp.page.getByRole('tab', { name: '配音服务' }).click();
const providerSelect = currentApp.page.getByRole('combobox', { name: '服务商' });
await expect(providerSelect).toHaveText('OpenAI TTS');
@@ -231,7 +297,7 @@ test('实际 Desktop 包创建并重启恢复 Creator Job,且使用内嵌 Runt
message: '合成横屏视频',
sandbox: 'danger-full-access'
});
- expect(agentTurn.status).toBe(200);
+ expect(agentTurn.status, JSON.stringify(agentTurn.body)).toBe(200);
expect(agentTurn.body.turn).toMatchObject({
role: 'assistant',
status: 'completed',
@@ -335,6 +401,70 @@ test('实际 Desktop 包创建并重启恢复 Creator Job,且使用内嵌 Runt
candidateCount: 2
}
});
+ const stickmanJob = await runtimeRequest<{
+ job: {
+ id: string;
+ revision: number;
+ templateVersion: number;
+ state: Record<string, unknown>;
+ };
+ }>(currentApp.page, 'POST', '/creator/jobs', {
+ projectId: createdProject.body.project.id,
+ templateId: 'stickman-video',
+ state: {
+ sourceType: 'url',
+ sourceUrl: 'https://www.youtube.com/watch?v=creator-stickman-package-smoke',
+ characterAsset: { assetId: 'stickman.character.default', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.minimal-ink', revision: 1 },
+ ratio: '16:9',
+ targetDurationSeconds: 30,
+ targetLanguage: 'zh-CN',
+ ttsProvider: 'openai',
+ ttsModel: 'gpt-4o-mini-tts',
+ voiceCode: 'marin',
+ voiceName: 'Marin'
+ }
+ });
+ expect(stickmanJob.status).toBe(201);
+ expect(stickmanJob.body.job).toMatchObject({
+ revision: 0,
+ templateVersion: 2,
+ state: {
+ sourceType: 'url',
+ sourceUrl: 'https://www.youtube.com/watch?v=creator-stickman-package-smoke',
+ characterAsset: { assetId: 'stickman.character.default', revision: 1 }
+ }
+ });
+ const updatedStickmanJob = await runtimeRequest<{
+ job: { id: string; revision: number; state: Record<string, unknown> };
+ }>(currentApp.page, 'POST', `/creator/jobs/${stickmanJob.body.job.id}/actions`, {
+ action: 'update-settings',
+ expectedRevision: stickmanJob.body.job.revision,
+ input: {
+ patch: {
+ characterAsset: { assetId: 'stickman.character.tech-guy', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.whiteboard-marker', revision: 1 },
+ targetDurationSeconds: 125,
+ voiceCode: 'nova',
+ voiceName: 'Nova'
+ }
+ }
+ });
+ expect(updatedStickmanJob.status).toBe(200);
+ expect(updatedStickmanJob.body.job).toMatchObject({
+ revision: 1,
+ state: {
+ characterAsset: { assetId: 'stickman.character.tech-guy', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.whiteboard-marker', revision: 1 },
+ targetDurationSeconds: 125,
+ ttsProvider: 'openai',
+ ttsModel: 'gpt-4o-mini-tts',
+ voiceCode: 'nova',
+ voiceName: 'Nova'
+ }
+ });
+ expect(updatedStickmanJob.body.job.state).not.toHaveProperty('characterPrompt');
+ expect(updatedStickmanJob.body.job.state).not.toHaveProperty('voice');
const relaunchInput = {
executablePath: currentApp.executablePath,
@@ -462,6 +592,50 @@ test('实际 Desktop 包创建并重启恢复 Creator Job,且使用内嵌 Runt
expect(containsPythonBytecodeCache(
join(runtimeRoot, 'yt-dlp-runtime', 'python')
)).toBe(false);
+ const restoredStickmanJob = await runtimeRequest<{
+ job: { id: string; revision: number; templateVersion: number; state: Record<string, unknown> };
+ }>(currentApp.page, 'GET', `/creator/jobs/${stickmanJob.body.job.id}`);
+ expect(restoredStickmanJob.status).toBe(200);
+ expect(restoredStickmanJob.body.job).toMatchObject({
+ id: stickmanJob.body.job.id,
+ templateVersion: 2,
+ state: {
+ sourceType: 'url',
+ sourceUrl: 'https://www.youtube.com/watch?v=creator-stickman-package-smoke',
+ characterAsset: { assetId: 'stickman.character.tech-guy', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.whiteboard-marker', revision: 1 },
+ targetDurationSeconds: 125,
+ ttsProvider: 'openai',
+ ttsModel: 'gpt-4o-mini-tts',
+ voiceCode: 'nova',
+ voiceName: 'Nova'
+ }
+ });
+ expect(restoredStickmanJob.body.job.state).not.toHaveProperty('characterPrompt');
+ expect(restoredStickmanJob.body.job.state).not.toHaveProperty('voice');
+ expect(restoredStickmanJob.body.job.revision)
+ .toBeGreaterThanOrEqual(updatedStickmanJob.body.job.revision);
+ await currentApp.page.getByRole('button', { name: '我的项目' }).click();
+ await currentApp.page.getByRole('button', {
+ name: '打开项目 youtube.com · creator-stickman-package-smoke'
+ }).click();
+ await expect(currentApp.page.getByRole('heading', { name: '火柴人动画' })).toBeVisible();
+ await expect(currentApp.page.getByRole('radio', { name: '科技男' })).toBeChecked();
+ await expect(currentApp.page.getByRole('textbox', { name: '角色描述' })).toHaveCount(0);
+ await expect(currentApp.page.getByRole('combobox', { name: '视觉风格' }))
+ .toHaveValue('stickman.style.whiteboard-marker@1');
+ await expect(currentApp.page.getByRole('combobox', { name: '目标时长' }))
+ .toHaveValue('custom');
+ await expect(currentApp.page.getByRole('spinbutton', { name: '自定义时长(秒)' }))
+ .toHaveValue('125');
+ await expect(currentApp.page.getByRole('combobox', { name: '配音音色' }))
+ .toHaveCount(0);
+ await expect(currentApp.page.getByText('尚未配置配音服务', { exact: true }))
+ .toBeVisible();
+ await expect(currentApp.page.getByRole('link', { name: '前往配音服务配置' }))
+ .toHaveAttribute('href', '#/settings?tab=ai-services&section=tts');
+ await expect(currentApp.page.getByLabel('任务摘要')).toHaveCount(0);
+ await expect(currentApp.page.locator('.creator-collaboration-panel')).toHaveCount(1);
expect(hasWhisperKitDependency(fixture.root)).toBe(false);
} finally {
await closePackagedApp(currentApp).catch(() => undefined);
@@ -640,6 +814,13 @@ function packagedRuntimeRoot(): string {
: join(packageRoot, 'resources', 'creator-runtime', 'krillinai');
}
+function packagedStickmanRuntimeRoot(): string {
+ const packageRoot = dirname(packagedExecutable(desktopDir));
+ return process.platform === 'darwin'
+ ? resolve(packageRoot, '..', 'Resources', 'stickman-runtime')
+ : join(packageRoot, 'resources', 'stickman-runtime');
+}
+
function executableResource(path: string): string {
return process.platform === 'win32' ? `${path}.exe` : path;
}
diff --git a/apps/desktop/electron-builder.yml b/apps/desktop/electron-builder.yml
index c4632071..d83186a2 100644
--- a/apps/desktop/electron-builder.yml
+++ b/apps/desktop/electron-builder.yml
@@ -49,6 +49,8 @@ extraResources:
to: creator-runtime
- from: .pack/codex-runtime
to: codex-runtime
+ - from: .pack/stickman-runtime
+ to: stickman-runtime
- from: ../web/dist
to: web
- from: resources
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index f9c7fe1d..e8426b1c 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -19,6 +19,7 @@
"prepare:codex-runtime": "node scripts/prepare-codex-runtime.mjs",
"install:creator-runtime-dependencies": "node scripts/install-creator-runtime-dependencies.mjs",
"prepare:creator-runtime": "node scripts/prepare-creator-runtime.mjs",
+ "prepare:stickman-runtime": "node scripts/prepare-stickman-runtime.mjs",
"package": "node scripts/package-release.mjs --dir",
"package:signed": "node scripts/package-release.mjs --dir --signed",
"dist": "node scripts/package-release.mjs --dist",
diff --git a/apps/desktop/packaging/daemon-runtime/package.json b/apps/desktop/packaging/daemon-runtime/package.json
index f9face38..8df9b9e5 100644
--- a/apps/desktop/packaging/daemon-runtime/package.json
+++ b/apps/desktop/packaging/daemon-runtime/package.json
@@ -7,13 +7,21 @@
"@fastify/cors": "11.2.0",
"@iarna/toml": "2.2.5",
"@modelcontextprotocol/sdk": "1.29.0",
+ "@remotion/renderer": "4.0.473",
"better-sqlite3": "12.11.1",
+ "cheerio": "1.1.2",
"cron-parser": "5.6.1",
"cross-spawn": "7.0.6",
"fastify": "5.9.0",
"https-proxy-agent": "7.0.6",
+ "marked": "18.0.12",
"nanoid": "5.1.16",
+ "pdf-parse": "1.1.1",
+ "pdfkit": "0.20.2",
+ "sharp": "0.34.3",
+ "toml": "3.0.0",
"yaml": "2.9.0",
+ "yauzl": "3.4.0",
"zod": "3.25.76"
}
}
diff --git a/apps/desktop/packaging/daemon-runtime/pnpm-lock.yaml b/apps/desktop/packaging/daemon-runtime/pnpm-lock.yaml
index 91483b3b..154fb986 100644
--- a/apps/desktop/packaging/daemon-runtime/pnpm-lock.yaml
+++ b/apps/desktop/packaging/daemon-runtime/pnpm-lock.yaml
@@ -17,9 +17,15 @@ importers:
'@modelcontextprotocol/sdk':
specifier: 1.29.0
version: 1.29.0([email protected])
+ '@remotion/renderer':
+ specifier: 4.0.473
better-sqlite3:
specifier: 12.11.1
version: 12.11.1
+ cheerio:
+ specifier: 1.1.2
+ version: 1.1.2
cron-parser:
specifier: 5.6.1
version: 5.6.1
@@ -32,18 +38,39 @@ importers:
https-proxy-agent:
specifier: 7.0.6
version: 7.0.6
+ marked:
+ specifier: 18.0.12
+ version: 18.0.12
nanoid:
specifier: 5.1.16
version: 5.1.16
+ pdf-parse:
+ specifier: 1.1.1
+ version: 1.1.1
+ pdfkit:
+ specifier: 0.20.2
+ version: 0.20.2
+ sharp:
+ specifier: 0.34.3
+ version: 0.34.3
+ toml:
+ specifier: 3.0.0
+ version: 3.0.0
yaml:
specifier: 2.9.0
version: 2.9.0
+ yauzl:
+ specifier: 3.4.0
+ version: 3.4.0
zod:
specifier: 3.25.76
version: 3.25.76
packages:
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==}
+
'@fastify/[email protected]':
resolution: {integrity: sha512-NtuzM0SfaMJbGlnjr9LWQUN5LzgSrbB8tf/wRZNas+4E1O/Nmzl53e7ruT61HDZyRCJGC6FxIogmNZO1c5ETBA==}
@@ -74,6 +101,128 @@ packages:
resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==}
+ resolution: {integrity: sha512-ryFMfvxxpQRsgZJqBd4wsttYQbCxsJksrv9Lw/v798JcQ8+w84mBWuXwl+TT0WJ/WrYOLaYpwQXi3sA9nTIaIg==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [arm64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-yHpJYynROAj12TA6qil58hmPmAwxKKC7reUqtGLzsOHfP7/rniNGTL8tjWX6L3CTV4+5P4ypcS7Pp+7OB+8ihA==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [x64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-sBZmpwmxqwlqG9ueWFXtockhsxefaV6O84BMOrhtg/YqbTaRdqDE7hxraVE3y6gVM4eExmfzW4a8el9ArLeEiQ==}
+ cpu: [arm64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-M64XVuL94OgiNHa5/m2YvEQI5q2cl9d/wk0qFTDVXcYzi43lxuiFTftMR1tOnFQovVXNZJ5TURSDK2pNe9Yzqg==}
+ cpu: [x64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-RXwd0CgG+uPRX5YYrkzKyalt2OJYRiJQ8ED/fi1tq9WQW2jsQIn0tqrlR5l5dr/rjqq6AHAxURhj2DVjyQWSOA==}
+ cpu: [arm64]
+ os: [linux]
+
+ resolution: {integrity: sha512-mWd2uWvDtL/nvIzThLq3fr2nnGfyr/XMXlq8ZJ9WMR6PXijHlC3ksp0IpuhK6bougvQrchUAfzRLnbsen0Cqvw==}
+ cpu: [arm]
+ os: [linux]
+
+ resolution: {integrity: sha512-Xod/7KaDDHkYu2phxxfeEPXfVXFKx70EAFZ0qyUdOjCcxbjqyJOEUpDe6RIyaunGxT34Anf9ue/wuWOqBW2WcQ==}
+ cpu: [ppc64]
+ os: [linux]
+
+ resolution: {integrity: sha512-eMKfzDxLGT8mnmPJTNMcjfO33fLiTDsrMlUVcp6b96ETbnJmd4uvZxVJSKPQfS+odwfVaGifhsB07J1LynFehw==}
+ cpu: [s390x]
+ os: [linux]
+
+ resolution: {integrity: sha512-ZW3FPWIc7K1sH9E3nxIGB3y3dZkpJlMnkk7z5tu1nSkBoCgw2nSRTFHI5pB/3CQaJM0pdzMF3paf9ckKMSE9Tg==}
+ cpu: [x64]
+ os: [linux]
+
+ resolution: {integrity: sha512-UG+LqQJbf5VJ8NWJ5Z3tdIe/HXjuIdo4JeVNADXBFuG7z9zjoegpzzGIyV5zQKi4zaJjnAd2+g2nna8TZvuW9Q==}
+ cpu: [arm64]
+ os: [linux]
+
+ resolution: {integrity: sha512-SRYOLR7CXPgNze8akZwjoGBoN1ThNZoqpOgfnOxmWsklTGVfJiGJoC/Lod7aNMGA1jSsKWM1+HRX43OP6p9+6Q==}
+ cpu: [x64]
+ os: [linux]
+
+ resolution: {integrity: sha512-QdrKe3EvQrqwkDrtuTIjI0bu6YEJHTgEeqdzI3uWJOH6G1O8Nl1iEeVYRGdj1h5I21CqxSvQp1Yv7xeU3ZewbA==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [arm64]
+ os: [linux]
+
+ resolution: {integrity: sha512-oBK9l+h6KBN0i3dC8rYntLiVfW8D8wH+NPNT3O/WBHeW0OQWCjfWksLUaPidsrDKpJgXp3G3/hkmhptAW0I3+A==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [arm]
+ os: [linux]
+
+ resolution: {integrity: sha512-GLtbLQMCNC5nxuImPR2+RgrviwKwVql28FWZIW1zWruy6zLgA5/x2ZXk3mxj58X/tszVF69KK0Is83V8YgWhLA==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [ppc64]
+ os: [linux]
+
+ resolution: {integrity: sha512-3gahT+A6c4cdc2edhsLHmIOXMb17ltffJlxR0aC2VPZfwKoTGZec6u5GrFgdR7ciJSsHT27BD3TIuGcuRT0KmQ==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [s390x]
+ os: [linux]
+
+ resolution: {integrity: sha512-8kYso8d806ypnSq3/Ly0QEw90V5ZoHh10yH0HnrzOCr6DKAPI6QVHvwleqMkVQ0m+fc7EH8ah0BB0QPuWY6zJQ==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [x64]
+ os: [linux]
+
+ resolution: {integrity: sha512-vAjbHDlr4izEiXM1OTggpCcPg9tn4YriK5vAjowJsHwdBIdx0fYRsURkxLG2RLm9gyBq66gwtWI8Gx0/ov+JKQ==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [arm64]
+ os: [linux]
+
+ resolution: {integrity: sha512-gCWUn9547K5bwvOn9l5XGAEjVTTRji4aPTqLzGXHvIr6bIDZKNTA34seMPgM0WmSf+RYBH411VavCejp3PkOeQ==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [x64]
+ os: [linux]
+
+ resolution: {integrity: sha512-+CyRcpagHMGteySaWos8IbnXcHgfDn7pO2fiC2slJxvNq9gDipYBN42/RagzctVRKgxATmfqOSulgZv5e1RdMg==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [wasm32]
+
+ resolution: {integrity: sha512-MjnHPnbqMXNC2UgeLJtX4XqoVHHlZNd+nPt1kRPmj63wURegwBhZlApELdtxM2OIZDRv/DFtLcNhVbd1z8GYXQ==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [arm64]
+ os: [win32]
+
+ resolution: {integrity: sha512-xuCdhH44WxuXgOM714hn4amodJMZl3OEvf0GVTm0BEyMeA2to+8HEdRPShH0SLYptJY1uBw+SCFP9WVQi1Q/cw==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [ia32]
+ os: [win32]
+
+ resolution: {integrity: sha512-OWwz05d++TxzLEv4VnsTz5CmZ6mI6S05sfQGEMrNrQcOEERbX46332IvE7pO/EUiw7jUrrS40z/M7kPyjfl04g==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [x64]
+ os: [win32]
+
'@modelcontextprotocol/[email protected]':
resolution: {integrity: sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==}
engines: {node: '>=18'}
@@ -84,9 +233,67 @@ packages:
'@cfworker/json-schema':
optional: true
+ '@noble/[email protected]':
+ resolution: {integrity: sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==}
+ engines: {node: ^14.21.3 || >=16}
+
+ '@noble/[email protected]':
+ resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==}
+ engines: {node: ^14.21.3 || >=16}
+
'@pinojs/[email protected]':
resolution: {integrity: sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==}
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-cSKS6VPKpLlEs+W0TSgXbxzdHDFxj+ft1jeP/MhedtL3rcSDyjir8RTI8bqDgrcEF4km3Rcg0CxrGbYTKgUVVQ==}
+ cpu: [arm64]
+ os: [darwin]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-Sf0IHz/zXroP4UGZ0NkyVn0ICiOMeUj07i8nRoz0A95d4TDR3YKVThY4U16ElsaLSbHk3pMcobCxx1tscvtZYQ==}
+ cpu: [x64]
+ os: [darwin]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-HeV247O9dwhSfXFYoA7Dd0zPmyn2grbrIhaYs2MJZxO6IHmEUk0gm9/drWyjDHy4e2WCg98uSlcycNOmWtG5ng==}
+ cpu: [arm64]
+ os: [linux]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-7EGy2MtQch3yLzwxvWncz/3rmXOWQkWigCDL37I90aHhlf8JgrMZXo8dUtIoD0LP/zHWtFNBcJmgg9Ej+bHshA==}
+ cpu: [arm64]
+ os: [linux]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-X5Gzod9Q8sTtzjc+hIYKw6PMaB3tY0ADx68j2z+Zm8nJanmkzLZEDyZvlMexmE4nkb7IdOkHzYGm9NpynbMH2A==}
+ cpu: [x64]
+ os: [linux]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-REyhvrjGYfFTxGaaRDP31zANM744JI7pKXCgTqXHZBCe8mCZjxZCxmwt9pNL2lJsQ+qLr9zai488Bbj/PUuB6g==}
+ cpu: [x64]
+ os: [linux]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-J69HIENHpH1m8I85kTe111viqB5AGgKJdTCSKp4mGBxM95IL4nydzrYxVd91BvWjanQfVVq1C3voaF8YLwkT7A==}
+ cpu: [x64]
+ os: [win32]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-BBw6SuEWuUD/lYXbLKEC0TTUzW7aLsO0X72pG38W1dOUyfU2KZYYfWGZkd+ermZTWWJ8cW+mevIwloUGk7FRaQ==}
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-WOOmT38O3ax78oDIE75FnsDi8eUMBKOdnqiXU3NeArNoA/xQZv7yDUgV3e1SxFaCHS7IbWHIATXUfVgS8TIXBA==}
+ peerDependencies:
+ react: '>=16.8.0'
+ react-dom: '>=16.8.0'
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-JRXgqnzHbcaZU+LH3VK9KRNBHd7rhNnf34C3uUeFYFChRQhnmHWTSo7p/SDUhCpVh+hIHsS52xJz9JPwwy5gUw==}
+
+ resolution: {integrity: sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==}
+
resolution: {integrity: sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==}
@@ -116,6 +323,10 @@ packages:
resolution: {integrity: sha512-g2tQ7LE7oOSqDfwEm3M+ZCMTJc7KiZCdJ4UwyZJb5ckTKyYu50OYmvv0mCFXPuYXoM4zkSt8zM9XQ9KCvxA74A==}
+ resolution: {integrity: sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
@@ -133,6 +344,12 @@ packages:
resolution: {integrity: sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==}
+
+ resolution: {integrity: sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg==}
+
resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
@@ -148,9 +365,34 @@ packages:
resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==}
+
+ resolution: {integrity: sha512-IkxPpb5rS/d1IiLbHMgfPuS0FgiWTtFIm/Nj+2woXDLTZ7fOT2eqzgYbdMlLweqlHbsZjxEChoVK+7iph7jyQg==}
+ engines: {node: '>=20.18.1'}
+
resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==}
+ resolution: {integrity: sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==}
+ engines: {node: '>=0.8'}
+
+ resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
+ engines: {node: '>=7.0.0'}
+
+ resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
+
+ resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==}
+
+ resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==}
+ engines: {node: '>=12.5.0'}
+
resolution: {integrity: sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==}
engines: {node: '>=18'}
@@ -187,6 +429,21 @@ packages:
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
engines: {node: '>= 8'}
+ resolution: {integrity: sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==}
+
+ resolution: {integrity: sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==}
+ engines: {node: '>= 6'}
+
+ resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
+ peerDependencies:
+ supports-color: '*'
+ peerDependenciesMeta:
+ supports-color:
+ optional: true
+
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
engines: {node: '>=6.0'}
@@ -216,6 +473,22 @@ packages:
resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==}
+
+ resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==}
+
+ resolution: {integrity: sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==}
+
+ resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==}
+ engines: {node: '>= 4'}
+
+ resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==}
+
resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==}
engines: {node: '>= 0.4'}
@@ -227,9 +500,24 @@ packages:
resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==}
engines: {node: '>= 0.8'}
+ resolution: {integrity: sha512-5gvq20T6vfpekVtqrYQsSCFZ1wEg5+wW0/QaZMWkFr6BqD3NfKs0rLCx4rrVlSWJeZb5NBJgVLswK/w2MWU+Gw==}
+
resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==}
+ resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
+ engines: {node: '>=0.12'}
+
+ resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==}
+ engines: {node: '>=0.12'}
+
+ resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==}
+ engines: {node: '>=0.12'}
+
resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==}
engines: {node: '>= 0.4'}
@@ -257,6 +545,10 @@ packages:
resolution: {integrity: sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==}
engines: {node: '>=18.0.0'}
+ resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==}
+ engines: {node: '>=10'}
+
resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}
engines: {node: '>=6'}
@@ -301,6 +593,9 @@ packages:
resolution: {integrity: sha512-XKv5nnLs6nLF71NgiKJLIZFLkPyIEuOselLG7ujZnGrRfQK8HpvY+WqKhAJUAdLomwVHErVS4LfxFlPq0/FTAw==}
+ resolution: {integrity: sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==}
+
resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==}
@@ -312,6 +607,9 @@ packages:
resolution: {integrity: sha512-sJsgZ1sQH2UDuowPuMKg8az7Qc8F0jnj+SKkFWU/+T0xcFlgV5skgXOGUqmQzOdmW6ALA7AhJINWx3qFBkbLHA==}
engines: {node: '>=20'}
+ resolution: {integrity: sha512-syetQadaUEDNdxdugga9CpEYVaQIxOwk7GlwZWWZ19//qW4zE5bknOKeMBDYAASwnpaSHKJITRLMF9m1fp3s6g==}
+
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
engines: {node: '>= 0.6'}
@@ -334,6 +632,10 @@ packages:
resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==}
+ engines: {node: '>=10'}
+
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
@@ -353,6 +655,9 @@ packages:
resolution: {integrity: sha512-c8/gF9ac8Y78/agExVocyLevgR+JlpNB444Py0FSX8pJoPdYUfUzRcXtYEYGwt6l19qIlVZPN5Mfsw9jFShmQQ==}
engines: {node: '>=16.9.0'}
+ resolution: {integrity: sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==}
+
resolution: {integrity: sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==}
engines: {node: '>= 0.8'}
@@ -361,6 +666,14 @@ packages:
resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==}
engines: {node: '>= 14'}
+ resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==}
+ engines: {node: '>=10.17.0'}
+
+ resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==}
engines: {node: '>=0.10.0'}
@@ -386,9 +699,16 @@ packages:
resolution: {integrity: sha512-aq+t5NAc+cS6rZQQVWC2x98CPqGtKKTMDd4Gaodv0wShnItdKg/51djkGJ1hqH+Oy0ivDftCbSLCQob8zso01w==}
engines: {node: '>= 10'}
+ resolution: {integrity: sha512-m6UrgzFVUYawGBh1dUsWR5M2Clqic9RVXC/9f8ceNlv2IcO9j9J/z8UoCLPqtsPBFNzEpfR3xftohbfqDx8EQA==}
+
resolution: {integrity: sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==}
+ resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==}
+ engines: {node: '>=8'}
+
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
@@ -407,10 +727,21 @@ packages:
resolution: {integrity: sha512-CHYbu8RtboSIoVsHZ6Ye4cj4Aw/yg2oAFimlF7mNvfDV192LR7nDiKtSIfCuLT7KokPSTn/9kfVLm5OGN0A28A==}
+ resolution: {integrity: sha512-MHp03UImeVhB7XZtjd0E4n6+3xr5Dq/9xI/5FptGk5FrbDR3zagPa2DS6U8ks/3HjbKWG9Q1M2ufOzxV2qLYSQ==}
+
+ resolution: {integrity: sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==}
+
resolution: {integrity: sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew==}
engines: {node: '>=12'}
+ resolution: {integrity: sha512-LEm4ga2YeI2T3GVHj9b0BaDPPk93LLTHMFeMyQbNIzPxc8vCI0y/scy0ZA6z6lXKyT9j9Nhl/OC6ZYKYGuFScA==}
+ engines: {node: '>= 20'}
+ hasBin: true
+
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'}
@@ -423,6 +754,9 @@ packages:
resolution: {integrity: sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==}
+
resolution: {integrity: sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==}
engines: {node: '>= 0.6'}
@@ -431,6 +765,10 @@ packages:
resolution: {integrity: sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==}
engines: {node: '>=10'}
@@ -460,6 +798,16 @@ packages:
resolution: {integrity: sha512-rebQ/lz7i0EkoLzUVSrKRzA69zMkwLp95kKMWoMDkkM00Suxz0D7zEQPwRml5fQum24mj7bPvmlgLAmu2JCiYg==}
engines: {node: '>=10'}
+ resolution: {integrity: sha512-DRI60hzo2oKN1ma0ckc6nQWlHU69RH6xN0sjQTjMpChPfTYvKZdcQFfdYK2RWbJcKyUizSIy/l8OTGxMAM1QDw==}
+
+ resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==}
+ engines: {node: '>=8'}
+
+ resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==}
+
resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
engines: {node: '>=0.10.0'}
@@ -479,6 +827,22 @@ packages:
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
+ resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==}
+ engines: {node: '>=6'}
+
+ resolution: {integrity: sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==}
+
+ resolution: {integrity: sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==}
+
+ resolution: {integrity: sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==}
+
+ resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==}
+
resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==}
engines: {node: '>= 0.8'}
@@ -490,6 +854,16 @@ packages:
resolution: {integrity: sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==}
+ resolution: {integrity: sha512-v6ZJ/efsBpGrGGknjtq9J/oC8tZWq0KWL5vQrk2GlzLEQPUDB1ex+13Rmidl1neNN358Jn9EHZw5y07FFtaC7A==}
+ engines: {node: '>=6.8.1'}
+
+ resolution: {integrity: sha512-Q/w03ICAQyXfHNfTsg1udp0ADerdBN0s7a6XSPL7J7Ro6ABnafoBOCDBstIO9U02mvzHEV8HrvFIw5iV5ejIRA==}
+
+ resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==}
+
resolution: {integrity: sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==}
@@ -504,6 +878,9 @@ packages:
resolution: {integrity: sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==}
engines: {node: '>=16.20.0'}
+ resolution: {integrity: sha512-GdzJuUMc6ZSpxFJWVxtOH1bzYHym+TOnveqUjb+VJIbZWbZzyiRGFiKhbiielfpYbgMlhHVhsJ0FTazfuRFkMA==}
+
resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==}
engines: {node: '>=10'}
@@ -523,6 +900,10 @@ packages:
resolution: {integrity: sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==}
+ resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==}
engines: {node: '>=0.6'}
@@ -542,6 +923,15 @@ packages:
resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==}
hasBin: true
+ resolution: {integrity: sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==}
+ peerDependencies:
+ react: ^19.3.0
+
+ resolution: {integrity: sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
engines: {node: '>= 6'}
@@ -553,10 +943,19 @@ packages:
resolution: {integrity: sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g==}
+ resolution: {integrity: sha512-Li2u4cVxlbxWgxQPn5oBpUlmNKYFpLUmpE9OHMP7QurvOMfvVK1tcC7utxVEwYFZf18tXwqIPBwmuFvdzMu+YA==}
+ peerDependencies:
+ react: '>=16.8.0'
+ react-dom: '>=16.8.0'
+
resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-gSfoiOEA0VPE6Tukkrr7I0RBdE0s7H1eFCDBk05l1KIQT1UIKNc5JZy6jdyW6eYH3aR3g5b3PuL77rq0hvwtAw==}
+
resolution: {integrity: sha512-I1XxrZSQ+oErkRR4jYbAyEEu2I0avBvvMM5JN+6EBprOGRCs63ENqZ3vjavq8fBw2+62G5LF5XelKwuJpcvcxw==}
engines: {node: '>=10'}
@@ -586,6 +985,9 @@ packages:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
+ resolution: {integrity: sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==}
+
resolution: {integrity: sha512-l4KnYfEyqYJxDwlNVyRfO2E4NTHfMKAWdUuA8J0yve2Dz/E/PdBepY03RvyJpssIpRFwJoCD55wA+mEDs6ByWA==}
@@ -608,6 +1010,10 @@ packages:
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
+ resolution: {integrity: sha512-eX2IQ6nFohW4DbvHIOLRB3MHFpYqaqvXd3Tp5e/T/dSH83fxaNJQRvDMhASmkNTsNTVF2/OOopzRCt7xokgPfg==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
engines: {node: '>=8'}
@@ -632,15 +1038,26 @@ packages:
resolution: {integrity: sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
+
resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==}
resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
+ resolution: {integrity: sha512-nAu1WFPQSMNr2Zn9PGSZK9AGn4t/y97lEm+MXTtUDwfP0ksAIX4nO+6ruD9Jwut4C49SB1Ws+fbXsm/yScWOHw==}
+
resolution: {integrity: sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==}
+ resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==}
+ engines: {node: '>= 8'}
+ deprecated: The work that was done in this beta branch won't be included in future versions
+
resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==}
engines: {node: '>= 10.x'}
@@ -652,6 +1069,10 @@ packages:
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
+ resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==}
engines: {node: '>=0.10.0'}
@@ -667,6 +1088,9 @@ packages:
resolution: {integrity: sha512-e2zZ96wSChazBsbENf/Pcm/4swHt2cEKQ92rhUjkL9GCKiTDJIaTBenjE/m9DXi0QBmTMDkFDdOomUy20A1tDQ==}
engines: {node: '>=20'}
+ resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==}
+
resolution: {integrity: sha512-m1TdR/rvT7kgGJZhspNtXdsdYk0fddFpJJFlG5s+UkPFo6lkLoZ3YLOaovPYjq1R75NP5JfeTlSHaOsE09peCg==}
engines: {node: '>=20'}
@@ -675,6 +1099,15 @@ packages:
resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
engines: {node: '>=0.6'}
+ resolution: {integrity: sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==}
+
+ resolution: {integrity: sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==}
+
+ resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
+
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
@@ -682,6 +1115,16 @@ packages:
resolution: {integrity: sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==}
engines: {node: '>= 18'}
+ resolution: {integrity: sha512-RYONW2MeafgYlkVOKYKkA/Ag7BmXqgIWCa8t1m0JcxrQg9pI9lEqRhAOruOBCbAohOa/gkCF+iPi9hrgvTzu6Q==}
+ engines: {node: '>=20.18.1'}
+
+ resolution: {integrity: sha512-CLjCCLQ6UuMxWnbIylkisbRj31qxHPAurvena/0iwSVbQ2G1VY5/HjV0IRabOEbDHlzZlRdCrD4NhB0JtU40Pg==}
+
+ resolution: {integrity: sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ==}
+
resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==}
engines: {node: '>= 0.8'}
@@ -693,6 +1136,21 @@ packages:
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
engines: {node: '>= 0.8'}
+ resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==}
+
+ resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==}
+ engines: {node: '>=18'}
+ deprecated: Use @exodus/bytes instead for a more spec-conformant and faster implementation
+
+ resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==}
+ engines: {node: '>=18'}
+
+ resolution: {integrity: sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==}
+
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
engines: {node: '>= 8'}
@@ -701,11 +1159,27 @@ packages:
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
+ resolution: {integrity: sha512-It4dO0K5v//JtTXuPkfEOaI3uUN87iYPnqo/ZzqCoG3g8uhA66QUMs/SrM0YK7/NAu+r4LMh/9dq2A7k+rHs+w==}
+ engines: {node: '>=10.0.0'}
+ peerDependencies:
+ bufferutil: ^4.0.1
+ utf-8-validate: '>=5.0.2'
+ peerDependenciesMeta:
+ bufferutil:
+ optional: true
+ utf-8-validate:
+ optional: true
+
resolution: {integrity: sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==}
engines: {node: '>= 14.6'}
hasBin: true
+ resolution: {integrity: sha512-jIH9yLR9wqr0wOS0TpBvo/g/2UgZH5qePVbjgRliiF0BYvOZyaBknKsF+x9Iht0O6sqgnB93rCICdOZFecJuDw==}
+ engines: {node: '>=12'}
+
resolution: {integrity: sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==}
peerDependencies:
@@ -716,6 +1190,11 @@ packages:
snapshots:
+ '@emnapi/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@fastify/[email protected]':
dependencies:
ajv: 8.20.0
@@ -750,6 +1229,92 @@ snapshots:
'@iarna/[email protected]': {}
+ optionalDependencies:
+ '@img/sharp-libvips-darwin-arm64': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-darwin-x64': 1.2.0
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-arm64': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-arm': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-ppc64': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-s390x': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-x64': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linuxmusl-arm64': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linuxmusl-x64': 1.2.0
+ optional: true
+
+ dependencies:
+ '@emnapi/runtime': 1.11.3
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
'@modelcontextprotocol/[email protected]([email protected])':
dependencies:
'@hono/node-server': 1.19.17([email protected])
@@ -772,8 +1337,63 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ '@noble/[email protected]': {}
+
+ '@noble/[email protected]': {}
+
'@pinojs/[email protected]': {}
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]': {}
+
+ dependencies:
+ '@remotion/licensing': 4.0.473
+ '@remotion/streaming': 4.0.473
+ execa: 5.1.1
+ react: 19.3.0
+ react-dom: 19.3.0([email protected])
+ source-map: 0.8.0-beta.0
+ ws: 8.20.1
+ optionalDependencies:
+ '@remotion/compositor-darwin-arm64': 4.0.473
+ '@remotion/compositor-darwin-x64': 4.0.473
+ '@remotion/compositor-linux-arm64-gnu': 4.0.473
+ '@remotion/compositor-linux-arm64-musl': 4.0.473
+ '@remotion/compositor-linux-x64-gnu': 4.0.473
+ '@remotion/compositor-linux-x64-musl': 4.0.473
+ '@remotion/compositor-win32-x64-msvc': 4.0.473
+ transitivePeerDependencies:
+ - bufferutil
+ - utf-8-validate
+
+ '@remotion/[email protected]': {}
+
+ dependencies:
+ tslib: 2.8.1
+
@@ -801,6 +1421,8 @@ snapshots:
'@fastify/error': 4.2.0
fastq: 1.20.3
+
@@ -832,6 +1454,12 @@ snapshots:
transitivePeerDependencies:
- supports-color
+
+ dependencies:
+ base64-js: 1.5.1
+
dependencies:
base64-js: 1.5.1
@@ -849,8 +1477,49 @@ snapshots:
call-bind-apply-helpers: 1.0.2
get-intrinsic: 1.3.0
+ dependencies:
+ boolbase: 1.0.0
+ css-select: 5.2.2
+ css-what: 6.2.2
+ domelementtype: 2.3.0
+ domhandler: 5.0.3
+ domutils: 3.2.2
+
+ dependencies:
+ cheerio-select: 2.1.0
+ dom-serializer: 2.0.0
+ domhandler: 5.0.3
+ domutils: 3.2.2
+ encoding-sniffer: 0.2.1
+ htmlparser2: 10.1.0
+ parse5: 7.3.0
+ parse5-htmlparser2-tree-adapter: 7.1.0
+ parse5-parser-stream: 7.1.2
+ undici: 7.29.1
+ whatwg-mimetype: 4.0.0
+
+
+ dependencies:
+ color-name: 1.1.4
+
+
+ dependencies:
+ color-name: 1.1.4
+ simple-swizzle: 0.2.4
+
+ dependencies:
+ color-convert: 2.0.1
+ color-string: 1.9.1
+
@@ -878,6 +1547,20 @@ snapshots:
shebang-command: 2.0.0
which: 2.0.2
+ dependencies:
+ boolbase: 1.0.0
+ css-what: 6.2.2
+ domhandler: 5.0.3
+ domutils: 3.2.2
+ nth-check: 2.1.1
+
+
+ dependencies:
+ ms: 2.1.3
+
dependencies:
ms: 2.1.3
@@ -894,6 +1577,26 @@ snapshots:
+
+ dependencies:
+ domelementtype: 2.3.0
+ domhandler: 5.0.3
+ entities: 4.5.0
+
+
+ dependencies:
+ domelementtype: 2.3.0
+
+ dependencies:
+ dom-serializer: 2.0.0
+ domelementtype: 2.3.0
+ domhandler: 5.0.3
+
dependencies:
call-bind-apply-helpers: 1.0.2
@@ -904,10 +1607,21 @@ snapshots:
+ dependencies:
+ iconv-lite: 0.6.3
+ whatwg-encoding: 3.1.1
+
dependencies:
once: 1.4.0
+
+
+
@@ -926,6 +1640,18 @@ snapshots:
dependencies:
eventsource-parser: 3.1.1
+ dependencies:
+ cross-spawn: 7.0.6
+ get-stream: 6.0.1
+ human-signals: 2.1.0
+ is-stream: 2.0.1
+ merge-stream: 2.0.0
+ npm-run-path: 4.0.1
+ onetime: 5.1.2
+ signal-exit: 3.0.7
+ strip-final-newline: 2.0.0
+
@@ -1023,6 +1749,8 @@ snapshots:
dependencies:
reusify: 1.1.0
+
@@ -1042,6 +1770,18 @@ snapshots:
fast-querystring: 1.1.2
safe-regex2: 5.1.1
+ dependencies:
+ '@swc/helpers': 0.5.23
+ brotli: 1.3.3
+ clone: 2.1.2
+ dfa: 1.2.0
+ fast-deep-equal: 3.1.3
+ restructure: 3.0.2
+ tiny-inflate: 1.0.3
+ unicode-properties: 1.4.1
+ unicode-trie: 2.0.0
+
@@ -1068,6 +1808,8 @@ snapshots:
dunder-proto: 1.0.1
es-object-atoms: 1.1.2
+
@@ -1080,6 +1822,13 @@ snapshots:
+ dependencies:
+ domelementtype: 2.3.0
+ domhandler: 5.0.3
+ domutils: 3.2.2
+ entities: 7.0.1
+
dependencies:
depd: 2.0.0
@@ -1095,6 +1844,12 @@ snapshots:
transitivePeerDependencies:
- supports-color
+
+ dependencies:
+ safer-buffer: 2.1.2
+
dependencies:
safer-buffer: 2.1.2
@@ -1111,8 +1866,12 @@ snapshots:
+
+
@@ -1131,20 +1890,33 @@ snapshots:
process-warning: 4.0.1
set-cookie-parser: 2.7.2
+ dependencies:
+ base64-js: 0.0.8
+ unicode-trie: 2.0.0
+
+
+
+
dependencies:
mime-db: 1.54.0
+
@@ -1165,6 +1937,16 @@ snapshots:
dependencies:
semver: 7.8.5
+
+ dependencies:
+ path-key: 3.1.1
+
+ dependencies:
+ boolbase: 1.0.0
+
@@ -1179,12 +1961,49 @@ snapshots:
dependencies:
wrappy: 1.0.2
+ dependencies:
+ mimic-fn: 2.1.0
+
+
+ dependencies:
+ domhandler: 5.0.3
+ parse5: 7.3.0
+
+ dependencies:
+ parse5: 7.3.0
+
+ dependencies:
+ entities: 6.0.1
+
+ dependencies:
+ debug: 3.2.7
+ node-ensure: 0.0.0
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@noble/ciphers': 1.3.0
+ '@noble/hashes': 1.8.0
+ fflate: 0.8.3
+ fontkit: 2.0.4
+ linebreak: 1.1.0
+ png-js: 2.0.0
+
+
dependencies:
split2: 4.2.0
@@ -1207,6 +2026,10 @@ snapshots:
+ dependencies:
+ fflate: 0.8.3
+
dependencies:
detect-libc: 2.1.2
@@ -1236,6 +2059,8 @@ snapshots:
end-of-stream: 1.4.5
once: 1.4.0
+
dependencies:
es-define-property: 1.0.1
@@ -1259,6 +2084,13 @@ snapshots:
minimist: 1.2.8
strip-json-comments: 2.0.1
+ dependencies:
+ react: 19.3.0
+ scheduler: 0.28.0
+
+
dependencies:
inherits: 2.0.4
@@ -1269,8 +2101,15 @@ snapshots:
+ dependencies:
+ react: 19.3.0
+ react-dom: 19.3.0([email protected])
+
+
@@ -1297,6 +2136,8 @@ snapshots:
+
@@ -1330,6 +2171,35 @@ snapshots:
+ dependencies:
+ color: 4.2.3
+ detect-libc: 2.1.2
+ semver: 7.8.5
+ optionalDependencies:
+ '@img/sharp-darwin-arm64': 0.34.3
+ '@img/sharp-darwin-x64': 0.34.3
+ '@img/sharp-libvips-darwin-arm64': 1.2.0
+ '@img/sharp-libvips-darwin-x64': 1.2.0
+ '@img/sharp-libvips-linux-arm': 1.2.0
+ '@img/sharp-libvips-linux-arm64': 1.2.0
+ '@img/sharp-libvips-linux-ppc64': 1.2.0
+ '@img/sharp-libvips-linux-s390x': 1.2.0
+ '@img/sharp-libvips-linux-x64': 1.2.0
+ '@img/sharp-libvips-linuxmusl-arm64': 1.2.0
+ '@img/sharp-libvips-linuxmusl-x64': 1.2.0
+ '@img/sharp-linux-arm': 0.34.3
+ '@img/sharp-linux-arm64': 0.34.3
+ '@img/sharp-linux-ppc64': 0.34.3
+ '@img/sharp-linux-s390x': 0.34.3
+ '@img/sharp-linux-x64': 0.34.3
+ '@img/sharp-linuxmusl-arm64': 0.34.3
+ '@img/sharp-linuxmusl-x64': 0.34.3
+ '@img/sharp-wasm32': 0.34.3
+ '@img/sharp-win32-arm64': 0.34.3
+ '@img/sharp-win32-ia32': 0.34.3
+ '@img/sharp-win32-x64': 0.34.3
+
dependencies:
shebang-regex: 3.0.0
@@ -1364,6 +2234,8 @@ snapshots:
side-channel-map: 1.0.1
side-channel-weakmap: 1.0.2
+
@@ -1372,10 +2244,18 @@ snapshots:
once: 1.4.0
simple-concat: 1.0.1
+ dependencies:
+ is-arrayish: 0.3.4
+
dependencies:
atomic-sleep: 1.0.0
+ dependencies:
+ whatwg-url: 7.1.0
+
@@ -1384,6 +2264,8 @@ snapshots:
dependencies:
safe-buffer: 5.2.1
+
@@ -1405,10 +2287,20 @@ snapshots:
dependencies:
real-require: 1.0.0
+
+
+ dependencies:
+ punycode: 2.3.1
+
+
dependencies:
safe-buffer: 5.2.1
@@ -1419,20 +2311,52 @@ snapshots:
media-typer: 1.1.1
mime-types: 3.0.2
+
+ dependencies:
+ base64-js: 1.5.1
+ unicode-trie: 2.0.0
+
+ dependencies:
+ pako: 0.2.9
+ tiny-inflate: 1.0.3
+
+
+ dependencies:
+ iconv-lite: 0.6.3
+
+
+ dependencies:
+ lodash.sortby: 4.7.0
+ tr46: 1.0.1
+ webidl-conversions: 4.0.2
+
dependencies:
isexe: 2.0.0
+
+ dependencies:
+ pend: 1.2.0
+
dependencies:
zod: 3.25.76
diff --git a/apps/desktop/scripts/package-content-contract.mjs b/apps/desktop/scripts/package-content-contract.mjs
new file mode 100644
index 00000000..b3c27436
--- /dev/null
+++ b/apps/desktop/scripts/package-content-contract.mjs
@@ -0,0 +1,67 @@
+import { readdirSync } from 'node:fs';
+import { basename, join, relative } from 'node:path';
+
+const forbiddenDirectoryNames = new Set([
+ '.venv',
+ 'venv',
+ 'site-packages',
+ '__pycache__',
+ 'auto-video'
+]);
+
+export function findPythonRuntimeMarker(roots, asarEntries = []) {
+ for (const root of roots) {
+ const marker = scanRoot(root);
+ if (marker !== undefined) return marker;
+ }
+ for (const entry of asarEntries) {
+ const marker = pythonRuntimePathMarker(entry.replaceAll('\\', '/'));
+ if (marker !== undefined) return `app.asar:${marker}`;
+ }
+ return undefined;
+}
+
+export function verifyStickmanBuildBinding(buildManifest, runtime, runtimeManifest, manifestSha256) {
+ if (
+ buildManifest.stickmanRuntimeHash !== runtime.hash
+ || buildManifest.stickmanRuntimeFileCount !== runtime.fileCount
+ || buildManifest.stickmanRuntimeManifestSha256 !== manifestSha256
+ || buildManifest.remotionVersion !== runtimeManifest.remotionVersion
+ || buildManifest.chromiumVersion !== runtimeManifest.chromiumVersion
+ ) {
+ throw new Error('Desktop build manifest is not bound to the exact Stickman Runtime');
+ }
+}
+
+function scanRoot(root) {
+ const stack = [root];
+ while (stack.length > 0) {
+ const current = stack.pop();
+ for (const entry of readdirSync(current, { withFileTypes: true })) {
+ const path = join(current, entry.name);
+ const relativePath = relative(root, path).replaceAll('\\', '/');
+ const marker = pythonRuntimePathMarker(relativePath);
+ if (marker !== undefined) return `${root}:${marker}`;
+ if (entry.isDirectory()) stack.push(path);
+ }
+ }
+ return undefined;
+}
+
+function pythonRuntimePathMarker(path) {
+ const normalized = path.toLowerCase().replace(/^\/+/, '');
+ const segments = normalized.split('/').filter(Boolean);
+ const forbiddenDirectory = segments.find(segment => forbiddenDirectoryNames.has(segment));
+ if (forbiddenDirectory !== undefined) return path;
+ const name = basename(normalized);
+ if (
+ name === 'python'
+ || name === 'python.exe'
+ || /^python3(?:\.\d+)?(?:\.exe)?$/.test(name)
+ || /^libpython.*\.(?:so|dylib|dll)$/.test(name)
+ || name.endsWith('.pyc')
+ || name.endsWith('.pyo')
+ || name.endsWith('.pth')
+ ) return path;
+ return undefined;
+}
diff --git a/apps/desktop/scripts/package-release.mjs b/apps/desktop/scripts/package-release.mjs
index c74dc90e..a69a1f11 100644
--- a/apps/desktop/scripts/package-release.mjs
+++ b/apps/desktop/scripts/package-release.mjs
@@ -28,6 +28,11 @@ import { submitAndWaitForNotarization } from './apple-notarization.mjs';
import { prepareElectronBuilderCache } from './electron-builder-cache.mjs';
import { runStage } from './script-utils.mjs';
import { stageReleaseAssets } from './release-assets.mjs';
+import {
+ hashDirectory as hashStickmanDirectory,
+ hashFile as hashStickmanFile,
+ verifyStickmanRuntime
+} from './stickman-runtime-contract.mjs';
const scriptDir = dirname(fileURLToPath(import.meta.url));
const desktopDir = resolve(scriptDir, '..');
@@ -95,6 +100,13 @@ await runStage('准备 Creator Runtime', process.execPath, [
env,
timeoutMs: 25 * 60_000
});
+await runStage('准备 Stickman Runtime', process.execPath, [
+ resolve(scriptDir, 'prepare-stickman-runtime.mjs')
+], {
+ cwd: rootDir,
+ env,
+ timeoutMs: 25 * 60_000
+});
await runStage('准备 Codex Runtime', process.execPath, [
resolve(scriptDir, 'prepare-codex-runtime.mjs')
], {
@@ -151,6 +163,16 @@ const creatorRuntimeManifest = JSON.parse(readFileSync(
resolve(desktopDir, '.pack', 'creator-runtime', 'krillinai', 'manifest.json'),
'utf8'
));
+const stickmanRuntimeRoot = resolve(desktopDir, '.pack', 'stickman-runtime');
+const stickmanRuntimeManifest = verifyStickmanRuntime(
+ stickmanRuntimeRoot,
+ platform,
+ arch
+);
+const stickmanRuntime = hashStickmanDirectory(stickmanRuntimeRoot);
+const stickmanRuntimeManifestSha256 = hashStickmanFile(
+ resolve(stickmanRuntimeRoot, 'manifest.json')
+);
const manifest = {
version: 1,
commit: gitOutput(['rev-parse', 'HEAD']) || 'unknown',
@@ -165,6 +187,11 @@ const manifest = {
webFileCount: webBuild.fileCount,
creatorAgentRuntimeHash: creatorAgentRuntime.hash,
creatorAgentRuntimeFileCount: creatorAgentRuntime.fileCount,
+ stickmanRuntimeHash: stickmanRuntime.hash,
+ stickmanRuntimeFileCount: stickmanRuntime.fileCount,
+ stickmanRuntimeManifestSha256,
+ remotionVersion: stickmanRuntimeManifest.remotionVersion,
+ chromiumVersion: stickmanRuntimeManifest.chromiumVersion,
codexRuntimeVersion: codexRuntimeManifest.version,
codexRuntimeCommit: codexRuntimeManifest.commit,
codexRuntimeBinarySha256: codexRuntimeManifest.binary.sha256,
diff --git a/apps/desktop/scripts/prepare-daemon.mjs b/apps/desktop/scripts/prepare-daemon.mjs
index 74f2777c..a3279a94 100644
--- a/apps/desktop/scripts/prepare-daemon.mjs
+++ b/apps/desktop/scripts/prepare-daemon.mjs
@@ -125,6 +125,7 @@ assertExists(resolve(targetDir, 'runtime/opencreator-runtime/manifest.json'));
assertWorkspaceRuntimePackage('protocol', 'Protocol');
assertWorkspaceRuntimePackage('config', 'Config');
assertWorkspaceRuntimePackage('skill-market', 'Skill Market');
+assertWorkspaceRuntimePackage('writing-templates', 'Writing Templates');
assertMissing(
resolve(targetDir, 'node_modules/@opencreator/protocol/dist/krillin-opencreator.js'),
'Desktop Protocol runtime package still contains the removed Krillin sidecar contract'
@@ -171,7 +172,8 @@ function assertRuntimeDependencyManifest() {
const workspacePackages = new Set([
'@opencreator/config',
'@opencreator/protocol',
- '@opencreator/skill-market'
+ '@opencreator/skill-market',
+ '@opencreator/writing-templates'
]);
const expectedNames = Object.keys(daemonPackage.dependencies)
.filter(name => !workspacePackages.has(name))
@@ -219,7 +221,7 @@ function prepareDaemonRuntimeFiles() {
}
function prepareWorkspaceRuntimePackages() {
- for (const name of ['protocol', 'config', 'skill-market']) {
+ for (const name of ['protocol', 'config', 'skill-market', 'writing-templates']) {
copyWorkspaceRuntimePackage(name);
}
}
diff --git a/apps/desktop/scripts/prepare-stickman-runtime.mjs b/apps/desktop/scripts/prepare-stickman-runtime.mjs
new file mode 100644
index 00000000..98034858
--- /dev/null
+++ b/apps/desktop/scripts/prepare-stickman-runtime.mjs
@@ -0,0 +1,245 @@
+import { createRequire } from 'node:module';
+import {
+ chmodSync,
+ cpSync,
+ createWriteStream,
+ existsSync,
+ mkdirSync,
+ readdirSync,
+ rmSync,
+ statSync,
+ writeFileSync
+} from 'node:fs';
+import { execFileSync } from 'node:child_process';
+import { Readable } from 'node:stream';
+import { pipeline } from 'node:stream/promises';
+import { basename, dirname, join, relative, resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import {
+ hashFile,
+ verifyStickmanRuntime
+} from './stickman-runtime-contract.mjs';
+
+const scriptDir = dirname(fileURLToPath(import.meta.url));
+const desktopDir = resolve(scriptDir, '..');
+const rootDir = resolve(desktopDir, '../..');
+const targetPlatform = normalizePlatform(
+ process.env.OPENCREATOR_DESKTOP_TARGET_PLATFORM ?? process.platform
+);
+const targetArch = process.env.OPENCREATOR_DESKTOP_TARGET_ARCH ?? process.arch;
+if (targetPlatform !== process.platform || targetArch !== process.arch) {
+ throw new Error('Stickman Runtime preparation must run on its target platform and architecture');
+}
+const outputRoot = resolve(
+ process.env.OPENCREATOR_STICKMAN_RUNTIME_OUTPUT
+ ?? join(desktopDir, '.pack', 'stickman-runtime')
+);
+const bundleRoot = join(outputRoot, 'bundle');
+const browserRoot = join(outputRoot, 'browser');
+const fontRoot = join(outputRoot, 'fonts');
+const characterRoot = join(outputRoot, 'characters');
+const visualAssetRoot = join(outputRoot, 'visual-assets');
+const remotionVersion = '4.0.473';
+const chromiumVersion = '149.0.7790.0';
+const requireFromDaemon = createRequire(join(rootDir, 'apps', 'daemon', 'package.json'));
+const { bundle } = requireFromDaemon('@remotion/bundler');
+const yauzl = requireFromDaemon('yauzl');
+
+rmSync(outputRoot, { recursive: true, force: true });
+mkdirSync(outputRoot, { recursive: true });
+await bundle({
+ entryPoint: join(rootDir, 'packages', 'stickman-remotion', 'src', 'index.ts'),
+ outDir: bundleRoot,
+ enableCaching: false,
+ onProgress: () => undefined,
+ webpackOverride: configuration => ({
+ ...configuration,
+ resolve: {
+ ...configuration.resolve,
+ extensionAlias: {
+ ...configuration.resolve?.extensionAlias,
+ '.js': ['.ts', '.tsx', '.js']
+ }
+ }
+ })
+});
+
+const browserSource = await resolveBrowserSource();
+const browserVersion = execFileSync(browserSource, ['--version'], {
+ encoding: 'utf8',
+ windowsHide: true,
+ timeout: 30_000
+}).trim();
+if (!browserVersion.includes(chromiumVersion)) {
+ throw new Error(`Unexpected Chromium version: ${browserVersion}`);
+}
+cpSync(dirname(browserSource), browserRoot, { recursive: true });
+const packagedBrowserExecutable = join(browserRoot, basename(browserSource));
+
+cpSync(
+ join(rootDir, 'packages', 'stickman-remotion', 'assets', 'fonts'),
+ fontRoot,
+ { recursive: true }
+);
+cpSync(
+ join(rootDir, 'apps', 'web', 'public', 'dashboard', 'characters'),
+ characterRoot,
+ { recursive: true }
+);
+cpSync(
+ join(rootDir, 'resources', 'stickman', 'visual-assets'),
+ visualAssetRoot,
+ { recursive: true }
+);
+
+const resources = [];
+addDirectory(bundleRoot, 'bundle', remotionVersion);
+addDirectory(browserRoot, 'browser', chromiumVersion);
+addDirectory(fontRoot, 'font', '@fontsource/[email protected]');
+addDirectory(characterRoot, 'character', 'opencreator-dashboard@1');
+addDirectory(visualAssetRoot, 'visual-asset', 'stickman-visual-assets@1');
+resources.sort((left, right) => left.path.localeCompare(right.path));
+const manifest = {
+ version: 1,
+ platform: targetPlatform,
+ arch: targetArch,
+ remotionVersion,
+ chromiumVersion,
+ bundlePath: normalizeRelative(relative(outputRoot, bundleRoot)),
+ browserExecutable: normalizeRelative(relative(outputRoot, packagedBrowserExecutable)),
+ resources
+};
+writeFileSync(join(outputRoot, 'manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`);
+verifyStickmanRuntime(outputRoot, targetPlatform, targetArch);
+console.log(JSON.stringify({
+ ok: true,
+ outputRoot,
+ resources: resources.length,
+ browserVersion
+}));
+
+function addDirectory(root, kind, version) {
+ visit(root);
+ function visit(current) {
+ for (const entry of readdirSync(current, { withFileTypes: true })) {
+ const path = join(current, entry.name);
+ if (entry.isDirectory()) visit(path);
+ else if (entry.isFile()) {
+ resources.push({
+ path: normalizeRelative(relative(outputRoot, path)),
+ kind,
+ sha256: hashFile(path),
+ bytes: statSync(path).size,
+ version,
+ platform: targetPlatform,
+ arch: targetArch
+ });
+ }
+ }
+ }
+}
+
+function normalizePlatform(value) {
+ if (value === 'mac') return 'darwin';
+ if (value === 'win') return 'win32';
+ if (['darwin', 'win32', 'linux'].includes(value)) return value;
+ throw new Error(`Unsupported Stickman Runtime platform: ${value}`);
+}
+
+function normalizeRelative(path) {
+ return path.replaceAll('\\', '/');
+}
+
+async function resolveBrowserSource() {
+ const configured = process.env.OPENCREATOR_STICKMAN_BROWSER_PATH?.trim();
+ if (configured) {
+ const path = resolve(configured);
+ if (!existsSync(path)) throw new Error(`Configured Stickman browser is missing: ${path}`);
+ return path;
+ }
+ const platformKey = browserPlatformKey(targetPlatform, targetArch);
+ const executableName = targetPlatform === 'win32' ? 'chrome-headless-shell.exe' : 'chrome-headless-shell';
+ const vendorRoot = resolve(
+ process.env.OPENCREATOR_STICKMAN_RUNTIME_VENDOR
+ ?? join(rootDir, '.runtime', 'vendor', 'stickman-runtime', `${targetPlatform}-${targetArch}`)
+ );
+ const extractedRoot = join(vendorRoot, `chrome-headless-shell-${platformKey}`);
+ const executable = join(extractedRoot, executableName);
+ if (existsSync(executable)) return executable;
+
+ rmSync(vendorRoot, { recursive: true, force: true });
+ mkdirSync(vendorRoot, { recursive: true });
+ const archivePath = join(vendorRoot, `chrome-headless-shell-${platformKey}.zip`);
+ const url = process.env.OPENCREATOR_STICKMAN_BROWSER_URL?.trim()
+ || `https://cdn.npmmirror.com/binaries/chrome-for-testing/${chromiumVersion}/${platformKey}/chrome-headless-shell-${platformKey}.zip`;
+ await downloadFile(url, archivePath);
+ await extractZip(archivePath, vendorRoot);
+ rmSync(archivePath, { force: true });
+ if (!existsSync(executable)) {
+ throw new Error(`Downloaded Stickman browser executable is missing: ${executable}`);
+ }
+ if (targetPlatform !== 'win32') chmodSync(executable, 0o755);
+ return executable;
+}
+
+async function downloadFile(url, destination) {
+ const response = await fetch(url, {
+ redirect: 'follow',
+ signal: AbortSignal.timeout(10 * 60_000)
+ });
+ if (!response.ok || response.body === null) {
+ throw new Error(`Stickman browser download failed: HTTP ${response.status}`);
+ }
+ await pipeline(Readable.fromWeb(response.body), createWriteStream(destination));
+}
+
+function extractZip(archivePath, destination) {
+ return new Promise((resolvePromise, reject) => {
+ yauzl.open(archivePath, { lazyEntries: true }, (openError, zipFile) => {
+ if (openError || !zipFile) {
+ reject(openError ?? new Error('Stickman browser archive could not be opened'));
+ return;
+ }
+ zipFile.once('error', reject);
+ zipFile.once('end', resolvePromise);
+ zipFile.on('entry', entry => {
+ const entryName = entry.fileName.replaceAll('\\', '/');
+ const target = resolve(destination, entryName);
+ if (relative(destination, target).startsWith('..')) {
+ zipFile.close();
+ reject(new Error(`Stickman browser archive path escapes target: ${entryName}`));
+ return;
+ }
+ if (entryName.endsWith('/')) {
+ mkdirSync(target, { recursive: true });
+ zipFile.readEntry();
+ return;
+ }
+ mkdirSync(dirname(target), { recursive: true });
+ zipFile.openReadStream(entry, (streamError, stream) => {
+ if (streamError || !stream) {
+ zipFile.close();
+ reject(streamError ?? new Error(`Cannot extract ${entryName}`));
+ return;
+ }
+ pipeline(stream, createWriteStream(target)).then(
+ () => zipFile.readEntry(),
+ error => {
+ zipFile.close();
+ reject(error);
+ }
+ );
+ });
+ });
+ zipFile.readEntry();
+ });
+ });
+}
+
+function browserPlatformKey(platform, arch) {
+ if (platform === 'win32' && arch === 'x64') return 'win64';
+ if (platform === 'linux' && arch === 'x64') return 'linux64';
+ if (platform === 'darwin' && arch === 'x64') return 'mac-x64';
+ if (platform === 'darwin' && arch === 'arm64') return 'mac-arm64';
+ throw new Error(`Unsupported Chromium target: ${platform}-${arch}`);
+}
diff --git a/apps/desktop/scripts/stickman-runtime-contract.mjs b/apps/desktop/scripts/stickman-runtime-contract.mjs
new file mode 100644
index 00000000..e2b91156
--- /dev/null
+++ b/apps/desktop/scripts/stickman-runtime-contract.mjs
@@ -0,0 +1,181 @@
+import { createHash } from 'node:crypto';
+import {
+ closeSync,
+ existsSync,
+ openSync,
+ readFileSync,
+ readSync,
+ readdirSync,
+ statSync
+} from 'node:fs';
+import { isAbsolute, join, relative, resolve } from 'node:path';
+
+const remotionVersion = '4.0.473';
+const requiredFonts = new Set([
+ 'fonts/NotoSans-Bold.woff2',
+ 'fonts/NotoSansSC-Bold.woff2',
+ 'fonts/OFL.txt'
+]);
+const requiredCharacters = new Set([
+ 'characters/default.png',
+ 'characters/tech-guy.png',
+ 'characters/long-hair.png',
+ 'characters/short-hair.png',
+ 'characters/hiphop.png',
+ 'characters/student.png',
+ 'characters/elder.png',
+ 'characters/manager.png',
+ 'characters/chef.png',
+ 'characters/fitness.png'
+]);
+const requiredVisualAssets = new Set([
+ 'visual-assets/catalog.json'
+]);
+export function verifyStickmanRuntime(rootPath, platform, arch) {
+ const root = resolve(rootPath);
+ const manifestPath = join(root, 'manifest.json');
+ if (!existsSync(manifestPath)) {
+ throw new Error(`Stickman Runtime manifest is missing: ${manifestPath}`);
+ }
+ const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
+ if (
+ manifest?.version !== 1
+ || manifest.platform !== platform
+ || manifest.arch !== arch
+ || manifest.remotionVersion !== remotionVersion
+ || typeof manifest.chromiumVersion !== 'string'
+ || typeof manifest.bundlePath !== 'string'
+ || typeof manifest.browserExecutable !== 'string'
+ || !Array.isArray(manifest.resources)
+ ) {
+ throw new Error('Stickman Runtime manifest is invalid or targets another platform');
+ }
+
+ const expected = new Set(['manifest.json']);
+ for (const resource of manifest.resources) {
+ if (
+ typeof resource?.path !== 'string'
+ || !['bundle', 'browser', 'font', 'character', 'visual-asset'].includes(resource.kind)
+ || !/^[a-f0-9]{64}$/i.test(resource.sha256 ?? '')
+ || !Number.isSafeInteger(resource.bytes)
+ || resource.bytes < 0
+ || typeof resource.version !== 'string'
+ || resource.version.length === 0
+ || resource.platform !== platform
+ || resource.arch !== arch
+ ) {
+ throw new Error('Stickman Runtime contains an invalid resource record');
+ }
+ const path = resolveInside(root, resource.path);
+ if (!existsSync(path) || !statSync(path).isFile()) {
+ throw new Error(`Stickman Runtime resource is missing: ${resource.path}`);
+ }
+ if (statSync(path).size !== resource.bytes) {
+ throw new Error(`Stickman Runtime resource size mismatch: ${resource.path}`);
+ }
+ if (hashFile(path) !== resource.sha256.toLowerCase()) {
+ throw new Error(`Stickman Runtime resource hash mismatch: ${resource.path}`);
+ }
+ if (expected.has(resource.path)) {
+ throw new Error(`Stickman Runtime resource is duplicated: ${resource.path}`);
+ }
+ expected.add(resource.path);
+ }
+
+ const actual = new Set(listFiles(root));
+ const difference = findFirstDifferentPath([...expected].sort(), [...actual].sort());
+ if (difference !== undefined) {
+ throw new Error(`Stickman Runtime file list differs from manifest: ${difference}`);
+ }
+ const bundleRoot = `${normalizeRelative(manifest.bundlePath).replace(/\/$/, '')}/`;
+ if (!manifest.resources.some(resource => (
+ resource.kind === 'bundle'
+ && resource.path.startsWith(bundleRoot)
+ && resource.path.endsWith('/index.html')
+ ))) {
+ throw new Error('Stickman Runtime bundle entry is missing');
+ }
+ const browserExecutable = normalizeRelative(manifest.browserExecutable);
+ if (!manifest.resources.some(resource => (
+ resource.kind === 'browser' && resource.path === browserExecutable
+ ))) {
+ throw new Error('Stickman Runtime browser executable is not bound to the manifest');
+ }
+ for (const path of requiredFonts) {
+ if (!manifest.resources.some(resource => resource.kind === 'font' && resource.path === path)) {
+ throw new Error(`Stickman Runtime font is missing: ${path}`);
+ }
+ }
+ for (const path of requiredCharacters) {
+ if (!manifest.resources.some(resource => resource.kind === 'character' && resource.path === path)) {
+ throw new Error(`Stickman Runtime character is missing: ${path}`);
+ }
+ }
+ for (const path of requiredVisualAssets) {
+ if (!manifest.resources.some(resource => resource.kind === 'visual-asset' && resource.path === path)) {
+ throw new Error(`Stickman Runtime visual asset is missing: ${path}`);
+ }
+ }
+ return manifest;
+}
+
+export function hashDirectory(root) {
+ const files = listFiles(root);
+ const aggregate = createHash('sha256');
+ for (const relativePath of files) {
+ const contentHash = hashFile(join(root, relativePath));
+ aggregate.update(relativePath).update('\0').update(contentHash).update('\0');
+ }
+ return { files, fileCount: files.length, hash: aggregate.digest('hex') };
+}
+
+export function findFirstDifferentPath(left, right) {
+ const length = Math.max(left.length, right.length);
+ for (let index = 0; index < length; index += 1) {
+ if (left[index] !== right[index]) {
+ return `${left[index] ?? '<missing>'} / ${right[index] ?? '<missing>'}`;
+ }
+ }
+ return undefined;
+}
+
+export function hashFile(path) {
+ const digest = createHash('sha256');
+ const descriptor = openSync(path, 'r');
+ const buffer = Buffer.allocUnsafe(1024 * 1024);
+ try {
+ let bytesRead;
+ do {
+ bytesRead = readSync(descriptor, buffer, 0, buffer.length, null);
+ if (bytesRead > 0) digest.update(buffer.subarray(0, bytesRead));
+ } while (bytesRead > 0);
+ } finally {
+ closeSync(descriptor);
+ }
+ return digest.digest('hex');
+}
+
+function listFiles(root) {
+ const result = [];
+ visit(root);
+ return result.sort();
+
+ function visit(current) {
+ for (const entry of readdirSync(current, { withFileTypes: true })) {
+ const path = join(current, entry.name);
+ if (entry.isDirectory()) visit(path);
+ else if (entry.isFile()) result.push(normalizeRelative(relative(root, path)));
+ }
+ }
+}
+
+function resolveInside(root, child) {
+ const target = resolve(root, child);
+ const value = relative(root, target);
+ if (value === '' || (!value.startsWith('..') && !isAbsolute(value))) return target;
+ throw new Error(`Stickman Runtime resource escapes its root: ${child}`);
+}
+
+function normalizeRelative(path) {
+ return path.replaceAll('\\', '/');
+}
diff --git a/apps/desktop/scripts/verify-package.mjs b/apps/desktop/scripts/verify-package.mjs
index fce7db46..aa30bcb8 100644
--- a/apps/desktop/scripts/verify-package.mjs
+++ b/apps/desktop/scripts/verify-package.mjs
@@ -30,6 +30,16 @@ import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { verifyCreatorRuntime } from './creator-runtime-contract.mjs';
import { verifyCodexRuntime } from './codex-runtime-contract.mjs';
+import {
+ hashDirectory as hashStickmanDirectory,
+ hashFile as hashStickmanFile,
+ findFirstDifferentPath as findFirstDifferentStickmanPath,
+ verifyStickmanRuntime
+} from './stickman-runtime-contract.mjs';
+import {
+ findPythonRuntimeMarker,
+ verifyStickmanBuildBinding
+} from './package-content-contract.mjs';
const scriptDir = dirname(fileURLToPath(import.meta.url));
const desktopDir = resolve(scriptDir, '..');
@@ -53,11 +63,13 @@ const daemonDir = join(resourcesDir, 'daemon');
const webDir = join(resourcesDir, 'web');
const creatorRuntimeDir = join(resourcesDir, 'creator-runtime', 'krillinai');
const codexRuntimeDir = join(resourcesDir, 'codex-runtime');
+const stickmanRuntimeDir = join(resourcesDir, 'stickman-runtime');
const sourceWebDir = resolve(desktopDir, '../web/dist');
const sourceCreatorAgentRuntimeDir = resolve(
desktopDir,
'../daemon/runtime/opencreator-runtime'
);
+const sourceStickmanRuntimeDir = resolve(desktopDir, '.pack', 'stickman-runtime');
const executable = packagedExecutable(packageRoot);
const machOMagicValues = new Set([
'feedface',
@@ -92,9 +104,14 @@ assertDaemonContents();
assertWebContents();
assertCreatorRuntime();
assertCodexRuntime();
+assertStickmanRuntime();
+assertNoUnexpectedPythonRuntime();
assertNoLocalData();
assertSize('app.asar', appAsar, 80 * 1024 * 1024);
assertSize('Daemon resources', daemonDir, 250 * 1024 * 1024);
+assertSize('Creator Runtime', creatorRuntimeDir, 384 * 1024 * 1024);
+assertSize('Codex Runtime', codexRuntimeDir, 450 * 1024 * 1024);
+assertSize('Stickman Runtime', stickmanRuntimeDir, 384 * 1024 * 1024);
assertSize('Desktop package', packageRoot, 1536 * 1024 * 1024);
await assertFuseConfiguration();
verifyMacPackageMetadata();
@@ -401,6 +418,47 @@ function assertCodexRuntime() {
}
}
+function assertStickmanRuntime() {
+ const runtime = verifyStickmanRuntime(stickmanRuntimeDir, targetPlatform, targetArch);
+ const sourceManifest = verifyStickmanRuntime(
+ sourceStickmanRuntimeDir,
+ targetPlatform,
+ targetArch
+ );
+ const source = hashStickmanDirectory(sourceStickmanRuntimeDir);
+ const packaged = hashStickmanDirectory(stickmanRuntimeDir);
+ const firstDifferentPath = findFirstDifferentStickmanPath(source.files, packaged.files);
+ if (firstDifferentPath !== undefined) {
+ throw new Error(`Packaged Stickman Runtime file list differs from source at: ${firstDifferentPath}`);
+ }
+ if (source.hash !== packaged.hash) {
+ throw new Error('Packaged Stickman Runtime contents differ from .pack/stickman-runtime');
+ }
+ if (
+ runtime.remotionVersion !== sourceManifest.remotionVersion
+ || runtime.chromiumVersion !== sourceManifest.chromiumVersion
+ ) {
+ throw new Error('Packaged Stickman Runtime versions differ from the source manifest');
+ }
+ if (typeof manifest.packageRoot !== 'string') return;
+ verifyStickmanBuildBinding(
+ manifest,
+ source,
+ runtime,
+ hashStickmanFile(join(sourceStickmanRuntimeDir, 'manifest.json'))
+ );
+}
+
+function assertNoUnexpectedPythonRuntime() {
+ const marker = findPythonRuntimeMarker(
+ [daemonDir, stickmanRuntimeDir],
+ normalizedAsarEntries()
+ );
+ if (marker !== undefined) {
+ throw new Error(`Desktop package contains an unexpected Python Runtime marker: ${marker}`);
+ }
+}
+
function hashDirectory(root) {
const files = [];
walk(root, path => {
diff --git a/apps/desktop/src/main/bootstrap-controller.ts b/apps/desktop/src/main/bootstrap-controller.ts
index 4904f926..c492dad0 100644
--- a/apps/desktop/src/main/bootstrap-controller.ts
+++ b/apps/desktop/src/main/bootstrap-controller.ts
@@ -44,6 +44,7 @@ export class BootstrapController extends EventEmitter<BootstrapControllerEvents>
dataDir: string;
codexRuntimeRoot: string;
creatorRuntimeRoot: string;
+ stickmanRuntimeRoot: string;
defaultProjectRoot: string;
development: boolean;
}) {
@@ -316,6 +317,7 @@ export class BootstrapController extends EventEmitter<BootstrapControllerEvents>
codexHome: environment.codexHome,
dataDir: this.input.dataDir,
creatorRuntimeRoot: this.input.creatorRuntimeRoot,
+ stickmanRuntimeRoot: this.input.stickmanRuntimeRoot,
codexRuntimeRoot: this.input.codexRuntimeRoot,
codexRuntimeMode: environment.source,
defaultCwd: environment.defaultCwd,
diff --git a/apps/desktop/src/main/daemon-manager.ts b/apps/desktop/src/main/daemon-manager.ts
index ae6c6386..e0ee8d70 100644
--- a/apps/desktop/src/main/daemon-manager.ts
+++ b/apps/desktop/src/main/daemon-manager.ts
@@ -31,6 +31,7 @@ export type DaemonStartInput = {
codexHome: string;
dataDir: string;
creatorRuntimeRoot?: string;
+ stickmanRuntimeRoot?: string;
codexRuntimeRoot?: string;
codexRuntimeMode?: 'bundled' | 'external';
defaultCwd: string;
@@ -308,6 +309,9 @@ export function buildDaemonEnvironment(
...(input.creatorRuntimeRoot === undefined
? {}
: { OPENCREATOR_CREATOR_RUNTIME_ROOT: input.creatorRuntimeRoot }),
+ ...(input.stickmanRuntimeRoot === undefined
+ ? {}
+ : { OPENCREATOR_STICKMAN_RUNTIME_ROOT: input.stickmanRuntimeRoot }),
...(input.codexRuntimeRoot === undefined
? {}
: { OPENCREATOR_CODEX_RUNTIME_ROOT: input.codexRuntimeRoot }),
diff --git a/apps/desktop/src/main/main.ts b/apps/desktop/src/main/main.ts
index ff6fd81b..023c7f14 100644
--- a/apps/desktop/src/main/main.ts
+++ b/apps/desktop/src/main/main.ts
@@ -134,6 +134,10 @@ async function launchDesktop(): Promise<void> {
?? (development
? join(appRoot, '.pack', 'codex-runtime')
: join(process.resourcesPath, 'codex-runtime'));
+ const stickmanRuntimeRoot = process.env.OPENCREATOR_STICKMAN_RUNTIME_ROOT
+ ?? (development
+ ? join(appRoot, '.pack', 'stickman-runtime')
+ : join(process.resourcesPath, 'stickman-runtime'));
logger.info('OpenCreator Desktop starting', {
development,
@@ -151,6 +155,7 @@ async function launchDesktop(): Promise<void> {
dataDir,
codexRuntimeRoot,
creatorRuntimeRoot,
+ stickmanRuntimeRoot,
defaultProjectRoot,
development
});
diff --git a/apps/desktop/test/release-runtime-regressions.test.mjs b/apps/desktop/test/release-runtime-regressions.test.mjs
index b1709a79..ddb150c0 100644
--- a/apps/desktop/test/release-runtime-regressions.test.mjs
+++ b/apps/desktop/test/release-runtime-regressions.test.mjs
@@ -37,10 +37,17 @@ describe('Desktop release runtime regressions', () => {
expect(prepareSource).toContain("'--config.node-linker=hoisted'");
expect(prepareSource).toContain('assertPortableDependencyTree();');
expect(runtimePackage.dependencies).toMatchObject({
+ '@remotion/renderer': '4.0.473',
'cross-spawn': '7.0.6',
- fastify: '5.9.0'
+ fastify: '5.9.0',
+ sharp: '0.34.3',
+ yauzl: '3.4.0'
});
expect(runtimePackage.dependencies).not.toHaveProperty('which');
+ expect(prepareSource).toContain("'writing-templates'");
+ expect(prepareSource).toContain(
+ "assertWorkspaceRuntimePackage('writing-templates', 'Writing Templates')"
+ );
expect(builderConfig).toContain('differentialPackage: false');
expect(builderConfig).toContain('useZip: true');
});
diff --git a/apps/desktop/test/stickman-runtime-package.test.mjs b/apps/desktop/test/stickman-runtime-package.test.mjs
new file mode 100644
index 00000000..c8bb4b1e
--- /dev/null
+++ b/apps/desktop/test/stickman-runtime-package.test.mjs
@@ -0,0 +1,147 @@
+import { createHash } from 'node:crypto';
+import {
+ mkdirSync,
+ mkdtempSync,
+ readFileSync,
+ rmSync,
+ unlinkSync,
+ writeFileSync
+} from 'node:fs';
+import { tmpdir } from 'node:os';
+import { dirname, join } from 'node:path';
+import { afterEach, describe, expect, it } from 'vitest';
+import {
+ findPythonRuntimeMarker,
+ verifyStickmanBuildBinding
+} from '../scripts/package-content-contract.mjs';
+import { verifyStickmanRuntime } from '../scripts/stickman-runtime-contract.mjs';
+
+let roots = [];
+
+afterEach(() => {
+ for (const root of roots) rmSync(root, { recursive: true, force: true });
+ roots = [];
+});
+
+describe('Stickman Runtime package contract', () => {
+ it('accepts an exact manifest-pinned runtime', () => {
+ const root = fixture();
+ expect(verifyStickmanRuntime(root, process.platform, process.arch)).toMatchObject({
+ remotionVersion: '4.0.473',
+ chromiumVersion: '149.0.7790.0'
+ });
+ });
+
+ it.each([
+ ['missing', root => unlinkSync(join(root, 'fonts', 'NotoSans-Bold.woff2'))],
+ ['extra', root => write(join(root, 'extra.bin'), 'extra')],
+ ['hash-mismatched', root => write(join(root, 'characters', 'default.png'), 'changed')],
+ ['wrong-platform', root => updateManifest(root, manifest => { manifest.platform = 'wrong'; })]
+ ])('rejects %s resources', (_label, mutate) => {
+ const root = fixture();
+ mutate(root);
+ expect(() => verifyStickmanRuntime(root, process.platform, process.arch)).toThrow();
+ });
+
+ it('rejects packaged Python Runtime markers but allows inert Python source', () => {
+ const root = mkdtempSync(join(tmpdir(), 'stickman-python-scan-'));
+ roots.push(root);
+ write(join(root, 'docs', 'example.py'), 'print("docs")');
+ expect(findPythonRuntimeMarker([root])).toBeUndefined();
+ write(join(root, 'runtime', '__pycache__', 'module.pyc'), 'compiled');
+ expect(findPythonRuntimeMarker([root])).toContain('__pycache__');
+ expect(findPythonRuntimeMarker([], ['/node_modules/.venv/python.exe'])).toContain('app.asar');
+ });
+
+ it('binds the Desktop build manifest to exact Stickman and Web-era runtime evidence', () => {
+ const runtime = { hash: 'a'.repeat(64), fileCount: 12 };
+ const runtimeManifest = { remotionVersion: '4.0.473', chromiumVersion: '149.0.7790.0' };
+ const manifestHash = 'b'.repeat(64);
+ const buildManifest = {
+ stickmanRuntimeHash: runtime.hash,
+ stickmanRuntimeFileCount: runtime.fileCount,
+ stickmanRuntimeManifestSha256: manifestHash,
+ remotionVersion: runtimeManifest.remotionVersion,
+ chromiumVersion: runtimeManifest.chromiumVersion
+ };
+ expect(() => verifyStickmanBuildBinding(
+ buildManifest,
+ runtime,
+ runtimeManifest,
+ manifestHash
+ )).not.toThrow();
+ expect(() => verifyStickmanBuildBinding(
+ { ...buildManifest, stickmanRuntimeHash: 'c'.repeat(64) },
+ runtime,
+ runtimeManifest,
+ manifestHash
+ )).toThrow(/exact Stickman Runtime/);
+ });
+});
+
+function fixture() {
+ const root = mkdtempSync(join(tmpdir(), 'stickman-runtime-package-'));
+ roots.push(root);
+ const files = [
+ 'bundle/index.html',
+ `browser/${process.platform === 'win32' ? 'chrome-headless-shell.exe' : 'chrome-headless-shell'}`,
+ 'fonts/NotoSans-Bold.woff2',
+ 'fonts/NotoSansSC-Bold.woff2',
+ 'fonts/OFL.txt',
+ 'visual-assets/catalog.json',
+ ...[
+ 'default.png', 'tech-guy.png', 'long-hair.png', 'short-hair.png', 'hiphop.png',
+ 'student.png', 'elder.png', 'manager.png', 'chef.png', 'fitness.png'
+ ].map(name => `characters/${name}`)
+ ];
+ for (const path of files) write(join(root, path), `fixture:${path}`);
+ const browserExecutable = files.find(path => path.startsWith('browser/'));
+ const resources = files.map(path => ({
+ path,
+ kind: path.startsWith('bundle/')
+ ? 'bundle'
+ : path.startsWith('browser/')
+ ? 'browser'
+ : path.startsWith('fonts/')
+ ? 'font'
+ : path.startsWith('visual-assets/')
+ ? 'visual-asset'
+ : 'character',
+ sha256: hash(readFileSync(join(root, path))),
+ bytes: readFileSync(join(root, path)).length,
+ version: path.startsWith('bundle/')
+ ? '4.0.473'
+ : path.startsWith('browser/')
+ ? '149.0.7790.0'
+ : 'fixture',
+ platform: process.platform,
+ arch: process.arch
+ }));
+ writeFileSync(join(root, 'manifest.json'), `${JSON.stringify({
+ version: 1,
+ platform: process.platform,
+ arch: process.arch,
+ remotionVersion: '4.0.473',
+ chromiumVersion: '149.0.7790.0',
+ bundlePath: 'bundle',
+ browserExecutable,
+ resources
+ }, null, 2)}\n`);
+ return root;
+}
+
+function updateManifest(root, update) {
+ const path = join(root, 'manifest.json');
+ const manifest = JSON.parse(readFileSync(path, 'utf8'));
+ update(manifest);
+ writeFileSync(path, `${JSON.stringify(manifest, null, 2)}\n`);
+}
+
+function write(path, value) {
+ mkdirSync(dirname(path), { recursive: true });
+ writeFileSync(path, value);
+}
+
+function hash(value) {
+ return createHash('sha256').update(value).digest('hex');
+}
diff --git a/apps/web/e2e/stickman-web-desktop-parity.spec.ts b/apps/web/e2e/stickman-web-desktop-parity.spec.ts
new file mode 100644
index 00000000..b1492f88
--- /dev/null
+++ b/apps/web/e2e/stickman-web-desktop-parity.spec.ts
@@ -0,0 +1,400 @@
+import type { Browser, Page, TestInfo } from '@playwright/test';
+import { expect, test, type RuntimeFixture } from './fixtures/runtime.js';
+import {
+ FakeStickmanDaemon,
+ type FakeStickmanMutation,
+ type FakeStickmanSnapshot
+} from './support/fake-stickman-daemon.js';
+
+type Platform = 'browser' | 'desktop';
+
+type Checkpoint = {
+ text: string;
+ boxes: Record<string, { x: number; y: number; width: number; height: number }>;
+ screenshot: Buffer;
+};
+
+type PlatformResult = {
+ checkpoint: Checkpoint;
+ mutations: FakeStickmanMutation[];
+ snapshot: FakeStickmanSnapshot;
+ nativeDirectorySelections: number;
+ unknownRequests: string[];
+};
+
+type PixelDiff = {
+ width: number;
+ height: number;
+ differentPixels: number;
+ maxChannelDelta: number;
+};
+
+const viewports = [
+ { name: 'desktop', width: 1440, height: 900 },
+ { name: 'mobile', width: 390, height: 844 }
+] as const;
+
+test('火柴人工作台在 Browser/Desktop Bridge 下保持同构并持久化同一结果', async ({
+ browser,
+ runtime
+}, testInfo) => {
+ test.setTimeout(180_000);
+ test.skip(
+ testInfo.project.name !== 'chromium-desktop',
+ '本规格内部固定创建桌面和移动内容视口,避免重复执行'
+ );
+
+ for (const viewport of viewports) {
+ const browserResult = await runPlatform({
+ browser,
+ runtime,
+ platform: 'browser',
+ viewport,
+ testInfo
+ });
+ const desktopResult = await runPlatform({
+ browser,
+ runtime,
+ platform: 'desktop',
+ viewport,
+ testInfo
+ });
+
+ expect(browserResult.unknownRequests, `${viewport.name} Browser 未知请求`).toEqual([]);
+ expect(desktopResult.unknownRequests, `${viewport.name} Desktop 未知请求`).toEqual([]);
+ expect(desktopResult.mutations, `${viewport.name} Action 请求`).toEqual(
+ browserResult.mutations
+ );
+ expect(desktopResult.snapshot, `${viewport.name} 持久化快照`).toEqual(
+ browserResult.snapshot
+ );
+ expect(desktopResult.checkpoint.text, `${viewport.name} 可见文案`).toBe(
+ browserResult.checkpoint.text
+ );
+ expect(desktopResult.checkpoint.boxes, `${viewport.name} 关键尺寸`).toEqual(
+ browserResult.checkpoint.boxes
+ );
+ const pixelDiff = await compareScreenshots(
+ browser,
+ browserResult.checkpoint.screenshot,
+ desktopResult.checkpoint.screenshot
+ );
+ expect(pixelDiff.width, `${viewport.name} 截图宽度`).toBe(viewport.width);
+ expect(pixelDiff.height, `${viewport.name} 截图高度`).toBe(viewport.height);
+ expect(pixelDiff.maxChannelDelta, `${viewport.name} 最大像素通道差`).toBeLessThanOrEqual(1);
+ expect(pixelDiff.differentPixels, `${viewport.name} 抗锯齿差异像素`).toBeLessThanOrEqual(100);
+ expect(browserResult.nativeDirectorySelections).toBe(0);
+ expect(desktopResult.nativeDirectorySelections).toBe(viewport.name === 'desktop' ? 1 : 0);
+ }
+});
+
+async function runPlatform(input: {
+ browser: Browser;
+ runtime: RuntimeFixture;
+ platform: Platform;
+ viewport: { name: string; width: number; height: number };
+ testInfo: TestInfo;
+}): Promise<PlatformResult> {
+ const fakeDaemon = new FakeStickmanDaemon(input.runtime.projectId);
+ const context = await input.browser.newContext({
+ viewport: { width: input.viewport.width, height: input.viewport.height },
+ deviceScaleFactor: 1,
+ colorScheme: 'dark',
+ reducedMotion: 'reduce',
+ locale: 'zh-CN',
+ acceptDownloads: true
+ });
+ const page = await context.newPage();
+ await fakeDaemon.attach(page);
+ await installPlatformEnvironment(page, input.platform);
+
+ try {
+ await input.runtime.openApp(page, { currentProjectId: fakeDaemon.projectId });
+ await page.goto(
+ `${input.runtime.origin}/#/workbench?tool=stickman-video&jobId=${fakeDaemon.jobId}`
+ );
+ await expect(page.getByRole('heading', { name: '火柴人动画' })).toBeVisible();
+ await expect(page.getByRole('textbox', { name: '脚本标题' })).toHaveValue(
+ '用火柴人理解复利'
+ );
+ await expect(page.locator('.creator-collaboration-panel')).toHaveCount(1);
+
+ await page.getByRole('button', { name: '下一步', exact: true }).click();
+ await expect(page.getByRole('heading', { name: '配音与节奏' })).toBeVisible();
+ await expect(page.locator('.stickman-audio-row')).toHaveCount(2);
+ await expect(page.locator('.stickman-audio-control audio')).toHaveCount(2);
+ await page.getByRole('button', { name: '下一步', exact: true }).click();
+ await expect(page.getByText('2 个镜头 · 画面已生成 2/2')).toBeVisible();
+ await expect(page.getByRole('button', { name: '下一步', exact: true })).toBeVisible();
+ const regenerateButtons = page.getByRole('button', {
+ name: '重新生成',
+ exact: true
+ });
+ await expect(regenerateButtons).toHaveCount(2);
+ await regenerateButtons.first().click();
+ await expect.poll(() => fakeDaemon.mutationLog().map(item => (
+ isAction(item.body) ? item.body.action : null
+ ))).toContain('regenerate-shot');
+
+ const nextButton = page.getByRole('button', { name: '下一步', exact: true });
+ await expect(nextButton).toBeEnabled();
+ await nextButton.click();
+ await expect.poll(() => fakeDaemon.mutationLog().map(item => (
+ isAction(item.body) ? item.body.action : null
+ ))).toContain('continue-after-visuals');
+ await expect(page.getByRole('heading', { name: '成片交付' })).toBeVisible();
+ await expect(page.getByText('成片已生成,部分发布检查尚未通过')).toBeVisible();
+ const deliveryFiles = page.locator('.creator-result-files');
+ for (const label of ['火柴人动画', '旁白字幕']) {
+ await expect(deliveryFiles.getByText(label, { exact: true })).toBeVisible();
+ }
+ await expect(deliveryFiles.locator('article[data-ready="true"]')).toHaveCount(2);
+ await expect(page.locator('.creator-collaboration-panel')).toHaveCount(1);
+ await expect(page.locator('.creator-collaboration-stage')).toHaveCount(1);
+ expect(fakeDaemon.mutationLog().map(item => (
+ isAction(item.body) ? item.body.action : null
+ ))).not.toContain('approve-visuals');
+
+ let nativeDirectorySelections = 0;
+ if (input.viewport.name === 'desktop') {
+ nativeDirectorySelections = await verifyNativeProjectCapability(
+ page,
+ input.platform,
+ input.runtime.origin,
+ input.runtime.ordinaryThreadId
+ );
+ await page.goto(
+ `${input.runtime.origin}/#/workbench?tool=stickman-video&jobId=${fakeDaemon.jobId}`
+ );
+ await expect(page.getByRole('heading', { name: '成片交付' })).toBeVisible();
+ }
+
+ const checkpoint = await captureCheckpoint(page);
+ await input.testInfo.attach(
+ `stickman-${input.viewport.name}-${input.platform}.png`,
+ { body: checkpoint.screenshot, contentType: 'image/png' }
+ );
+ return {
+ checkpoint,
+ mutations: fakeDaemon.mutationLog(),
+ snapshot: fakeDaemon.snapshot(),
+ nativeDirectorySelections,
+ unknownRequests: fakeDaemon.unknownRequestPaths()
+ };
+ } finally {
+ await context.close();
+ }
+}
+
+async function compareScreenshots(
+ browser: Browser,
+ left: Buffer,
+ right: Buffer
+): Promise<PixelDiff> {
+ const context = await browser.newContext();
+ const page = await context.newPage();
+ try {
+ return await page.evaluate(async ({ leftUrl, rightUrl }) => {
+ const decode = async (url: string) => {
+ const image = new Image();
+ image.src = url;
+ await image.decode();
+ const canvas = document.createElement('canvas');
+ canvas.width = image.naturalWidth;
+ canvas.height = image.naturalHeight;
+ const renderingContext = canvas.getContext('2d', { willReadFrequently: true });
+ if (renderingContext === null) throw new Error('截图像素解码失败');
+ renderingContext.drawImage(image, 0, 0);
+ return {
+ width: canvas.width,
+ height: canvas.height,
+ pixels: renderingContext.getImageData(0, 0, canvas.width, canvas.height).data
+ };
+ };
+ const [leftImage, rightImage] = await Promise.all([decode(leftUrl), decode(rightUrl)]);
+ if (leftImage.width !== rightImage.width || leftImage.height !== rightImage.height) {
+ throw new Error(
+ `截图尺寸不同:${leftImage.width}x${leftImage.height} / ${rightImage.width}x${rightImage.height}`
+ );
+ }
+ let differentPixels = 0;
+ let maxChannelDelta = 0;
+ for (let offset = 0; offset < leftImage.pixels.length; offset += 4) {
+ let pixelDifferent = false;
+ for (let channel = 0; channel < 4; channel += 1) {
+ const delta = Math.abs(
+ leftImage.pixels[offset + channel]! - rightImage.pixels[offset + channel]!
+ );
+ if (delta > 0) pixelDifferent = true;
+ if (delta > maxChannelDelta) maxChannelDelta = delta;
+ }
+ if (pixelDifferent) differentPixels += 1;
+ }
+ return {
+ width: leftImage.width,
+ height: leftImage.height,
+ differentPixels,
+ maxChannelDelta
+ };
+ }, {
+ leftUrl: `data:image/png;base64,${left.toString('base64')}`,
+ rightUrl: `data:image/png;base64,${right.toString('base64')}`
+ });
+ } finally {
+ await context.close();
+ }
+}
+
+async function installPlatformEnvironment(page: Page, platform: Platform): Promise<void> {
+ await page.addInitScript(({ currentPlatform }) => {
+ localStorage.setItem('clawee.preferences.dynamicBackground', 'false');
+ localStorage.setItem('opencreator.preferences.colorMode', 'dark');
+ localStorage.setItem('opencreator.preferences.language', 'zh-CN');
+ Object.defineProperty(window, '__opencreatorStickmanDirectorySelections', {
+ configurable: true,
+ writable: true,
+ value: 0
+ });
+ if (currentPlatform !== 'desktop') return;
+ const success = { ok: true as const };
+ Object.defineProperty(window, 'opencreatorDesktop', {
+ configurable: true,
+ value: {
+ kind: 'desktop',
+ readConnectionConfig: async () => ({ baseUrl: '/.opencreator/runtime' }),
+ subscribeConnectionConfig: () => () => undefined,
+ restartRuntime: async () => success,
+ selectCodexPath: async () => success,
+ reloadWorkspace: async () => success,
+ workspaceReady: () => undefined,
+ readDesktopPreferences: async () => ({
+ closeBehavior: 'hide' as const,
+ telemetryEnabled: false
+ }),
+ updateDesktopPreferences: async () => ({
+ closeBehavior: 'hide' as const,
+ telemetryEnabled: false
+ }),
+ selectProjectDirectory: async () => {
+ const target = window as Window & {
+ __opencreatorStickmanDirectorySelections?: number;
+ };
+ target.__opencreatorStickmanDirectorySelections =
+ (target.__opencreatorStickmanDirectorySelections ?? 0) + 1;
+ return null;
+ },
+ resolveDroppedFilePath: () => {
+ const target = window as Window & {
+ __opencreatorStickmanDirectorySelections?: number;
+ };
+ target.__opencreatorStickmanDirectorySelections =
+ (target.__opencreatorStickmanDirectorySelections ?? 0) + 1;
+ return null;
+ },
+ openExternal: async () => undefined,
+ revealPath: async () => success,
+ notify: async () => undefined,
+ configureBackgroundNotifications: async () => success,
+ subscribeNavigation: () => () => undefined
+ }
+ });
+ }, { currentPlatform: platform });
+}
+
+async function verifyNativeProjectCapability(
+ page: Page,
+ platform: Platform,
+ origin: string,
+ threadId: string
+): Promise<number> {
+ await page.goto(`${origin}/#/thread/${encodeURIComponent(threadId)}`);
+ await expect(page.getByRole('textbox', { name: '输入任务' })).toBeVisible();
+ await expect(page.getByRole('button', { name: '使用现有文件夹' })).toHaveCount(0);
+ const dropRoot = page.locator('[data-project-drop-root="true"]');
+ await expect(dropRoot).toBeVisible();
+ await dropRoot.evaluate(element => {
+ const file = new File([], 'stickman-parity-project');
+ const dataTransfer = {
+ dropEffect: 'none',
+ effectAllowed: 'all',
+ files: [file],
+ items: [{
+ kind: 'file',
+ type: '',
+ getAsFile: () => file,
+ webkitGetAsEntry: () => ({
+ fullPath: `/${file.name}`,
+ isDirectory: true,
+ isFile: false,
+ name: file.name
+ })
+ }],
+ types: ['Files']
+ };
+ for (const type of ['dragenter', 'dragover', 'drop']) {
+ const event = new Event(type, {
+ bubbles: true,
+ cancelable: true
+ });
+ Object.defineProperty(event, 'dataTransfer', { value: dataTransfer });
+ element.dispatchEvent(event);
+ }
+ });
+ if (platform === 'desktop') {
+ await expect.poll(() => page.evaluate(() => Number((window as Window & {
+ __opencreatorStickmanDirectorySelections?: number;
+ }).__opencreatorStickmanDirectorySelections ?? 0))).toBe(1);
+ }
+ return await page.evaluate(() => Number((window as Window & {
+ __opencreatorStickmanDirectorySelections?: number;
+ }).__opencreatorStickmanDirectorySelections ?? 0));
+}
+
+async function captureCheckpoint(page: Page): Promise<Checkpoint> {
+ await page.evaluate(() => document.fonts.ready);
+ const root = page.locator('.stickman-workspace-page');
+ await expect(root).toBeVisible();
+ await page.mouse.move(0, 0);
+ await page.evaluate(() => {
+ if (document.activeElement instanceof HTMLElement) document.activeElement.blur();
+ });
+ const text = normalizeText(await root.innerText());
+ const boxes: Checkpoint['boxes'] = {};
+ for (const selector of [
+ '.stickman-workspace-content',
+ '.creator-task-workspace',
+ '.stickman-delivery-content',
+ '.creator-collaboration-panel',
+ '.creator-result-files'
+ ]) {
+ const box = await page.locator(selector).first().boundingBox();
+ if (box !== null) {
+ boxes[selector] = {
+ x: Math.round(box.x),
+ y: Math.round(box.y),
+ width: Math.round(box.width),
+ height: Math.round(box.height)
+ };
+ }
+ }
+ return {
+ text,
+ boxes,
+ screenshot: await page.screenshot({
+ animations: 'disabled',
+ mask: [root.locator('video'), root.locator('audio')],
+ maskColor: '#17191d'
+ })
+ };
+}
+
+function normalizeText(value: string): string {
+ return value.replace(/\s+/g, ' ').trim();
+}
+
+function isAction(value: unknown): value is { action: string } {
+ return value !== null
+ && typeof value === 'object'
+ && 'action' in value
+ && typeof (value as { action?: unknown }).action === 'string';
+}
diff --git a/apps/web/e2e/support/fake-stickman-daemon.ts b/apps/web/e2e/support/fake-stickman-daemon.ts
new file mode 100644
index 00000000..6383f197
--- /dev/null
+++ b/apps/web/e2e/support/fake-stickman-daemon.ts
@@ -0,0 +1,704 @@
+import type {
+ CreatorActionRequest,
+ CreatorActivity,
+ CreatorArtifact,
+ CreatorJob,
+ CreatorProviderRequest,
+ CreatorStageRun
+} from '@opencreator/protocol';
+import type { Page, Route } from '@playwright/test';
+
+export type FakeStickmanMutation = {
+ method: string;
+ path: string;
+ body: unknown;
+};
+
+export type FakeStickmanSnapshot = {
+ revision: number;
+ status: CreatorJob['status'];
+ state: CreatorJob['state'];
+ stages: Array<Pick<CreatorStageRun, 'stageId' | 'scopeKey' | 'status' | 'inputFingerprint'>>;
+ artifacts: Array<Pick<CreatorArtifact, 'id' | 'kind' | 'scopeKey' | 'status' | 'inputFingerprint'>>;
+ providerRequests: Array<Pick<CreatorProviderRequest, 'provider' | 'scopeKey' | 'status' | 'generation'>>;
+};
+
+const jobId = 'creator_job_stickman_parity';
+const createdAt = '2026-08-31T08:00:00.000Z';
+const firstFingerprint = '1'.repeat(64);
+const secondFingerprint = '2'.repeat(64);
+const transparentPng = Buffer.from(
+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAF/gL+4xF4WQAAAABJRU5ErkJggg==',
+ 'base64'
+);
+
+export class FakeStickmanDaemon {
+ readonly jobId = jobId;
+ readonly projectId: string;
+ private job: CreatorJob;
+ private readonly mutations: FakeStickmanMutation[] = [];
+ private readonly unknown: string[] = [];
+ private readonly contents = new Map<string, { body: Buffer | string; contentType: string }>([
+ ['artifact-script', {
+ body: JSON.stringify({
+ contract: 'stickman-narration-script-v2',
+ reviewStatus: 'needs_review',
+ contentLocked: false,
+ title: '用火柴人理解复利',
+ language: 'zh-CN',
+ targetDurationSeconds: 10,
+ narrationBudget: { unit: 'characters', unitsPerMinute: 240, minUnits: 1, maxUnits: 100 },
+ segmentCount: 2,
+ totalNarrationUnits: 40,
+ estimatedTotalDurationSeconds: 10,
+ segments: [
+ {
+ id: 'segment-01',
+ order: 1,
+ narration: '复利让每一次增长都成为下一次增长的基础。',
+ claimIds: ['claim-001'],
+ sourceSpanIds: ['source-001'],
+ narrationUnits: 20,
+ estimatedDurationSeconds: 5
+ },
+ {
+ id: 'segment-02',
+ order: 2,
+ narration: '时间越长,增长曲线与线性积累的差距越明显。',
+ claimIds: ['claim-002'],
+ sourceSpanIds: ['source-002'],
+ narrationUnits: 20,
+ estimatedDurationSeconds: 5
+ }
+ ]
+ }),
+ contentType: 'application/json; charset=utf-8'
+ }]
+ ]);
+
+ constructor(projectId: string) {
+ this.projectId = projectId;
+ this.job = initialJob(projectId);
+ }
+
+ async attach(page: Page): Promise<void> {
+ await page.route('**/.opencreator/runtime/creator/**', route => this.handle(route));
+ }
+
+ reset(): void {
+ this.job = initialJob(this.projectId);
+ this.mutations.length = 0;
+ this.unknown.length = 0;
+ for (const key of [...this.contents.keys()]) {
+ if (key !== 'artifact-script') this.contents.delete(key);
+ }
+ }
+
+ mutationLog(): FakeStickmanMutation[] {
+ return structuredClone(this.mutations);
+ }
+
+ snapshot(): FakeStickmanSnapshot {
+ return {
+ revision: this.job.revision,
+ status: this.job.status,
+ state: structuredClone(this.job.state),
+ stages: this.job.stages.map(stage => ({
+ stageId: stage.stageId,
+ scopeKey: stage.scopeKey,
+ status: stage.status,
+ inputFingerprint: stage.inputFingerprint
+ })),
+ artifacts: this.job.artifacts.map(artifact => ({
+ id: artifact.id,
+ kind: artifact.kind,
+ scopeKey: artifact.scopeKey,
+ status: artifact.status,
+ inputFingerprint: artifact.inputFingerprint
+ })),
+ providerRequests: this.job.providerRequests.map(request => ({
+ provider: request.provider,
+ scopeKey: request.scopeKey,
+ status: request.status,
+ generation: request.generation
+ }))
+ };
+ }
+
+ unknownRequestPaths(): string[] {
+ return [...this.unknown];
+ }
+
+ private async handle(route: Route): Promise<void> {
+ const request = route.request();
+ const method = request.method();
+ const url = new URL(request.url());
+ const marker = '/.opencreator/runtime';
+ const path = `${url.pathname.slice(url.pathname.indexOf(marker) + marker.length)}${url.search}`;
+ const pathWithoutQuery = path.split('?')[0]!;
+
+ if (method === 'GET' && pathWithoutQuery === '/creator/templates') {
+ return json(route, {
+ templates: [{
+ id: 'stickman-video',
+ version: 2,
+ renderer: 'stickman-video',
+ outputs: [
+ { kind: 'clean_video', required: true },
+ { kind: 'narration_subtitle', required: true },
+ { kind: 'delivery_manifest', required: true }
+ ]
+ }]
+ });
+ }
+ if (method === 'GET' && pathWithoutQuery === '/creator/visual-assets') {
+ return json(route, { assets: fakeVisualAssets() });
+ }
+ if (method === 'GET' && pathWithoutQuery === '/creator/yt-dlp/status') {
+ return json(route, {
+ ytDlp: {
+ channel: 'nightly',
+ source: 'bundled',
+ currentVersion: '2026.08.31.120000',
+ bundledVersion: '2026.08.31.120000',
+ latestVersion: null,
+ updateAvailable: false,
+ checkDue: false,
+ lastCheckedAt: null,
+ lastCheckAttemptAt: null,
+ installedAt: null
+ }
+ });
+ }
+ if (method === 'GET' && pathWithoutQuery === '/creator/jobs') {
+ return json(route, { jobs: [this.cloneJob()] });
+ }
+ if (method === 'GET' && pathWithoutQuery === `/creator/jobs/${jobId}`) {
+ return json(route, { job: this.cloneJob() });
+ }
+ if (
+ method === 'GET'
+ && (pathWithoutQuery === `/creator/jobs/${jobId}/agent-timeline`
+ || pathWithoutQuery === `/creator/jobs/${jobId}/agent-history`)
+ ) {
+ return json(route, {
+ session: null,
+ turns: [],
+ items: [],
+ approvals: [],
+ lastEventSequence: 0
+ });
+ }
+ if (method === 'GET' && pathWithoutQuery === `/creator/jobs/${jobId}/events`) {
+ await route.fulfill({
+ status: 200,
+ contentType: 'text/event-stream; charset=utf-8',
+ headers: { 'cache-control': 'no-cache' },
+ body: ': fake-stickman-daemon\n\n'
+ });
+ return;
+ }
+ const artifactMatch = pathWithoutQuery.match(
+ new RegExp(`^/creator/jobs/${jobId}/artifacts/([^/]+)/content$`)
+ );
+ if (method === 'GET' && artifactMatch !== null) {
+ const artifactId = decodeURIComponent(artifactMatch[1]!);
+ const content = this.contents.get(artifactId);
+ if (content === undefined) return json(route, { code: 'artifact_not_found' }, 404);
+ await route.fulfill({ status: 200, contentType: content.contentType, body: content.body });
+ return;
+ }
+ if (method === 'POST' && pathWithoutQuery === `/creator/jobs/${jobId}/actions`) {
+ const body = request.postDataJSON() as CreatorActionRequest;
+ this.mutations.push({ method, path: pathWithoutQuery, body: structuredClone(body) });
+ return this.applyAction(route, body);
+ }
+ if (method === 'POST' && pathWithoutQuery === `/creator/jobs/${jobId}/cancel`) {
+ this.mutations.push({ method, path: pathWithoutQuery, body: null });
+ this.job.status = 'canceled';
+ this.bump('cancel', '已取消火柴人视频任务');
+ return json(route, { job: this.cloneJob(), canceled: true, stage: null, stages: [] });
+ }
+ if (method === 'POST' && pathWithoutQuery === `/creator/jobs/${jobId}/resume`) {
+ this.mutations.push({ method, path: pathWithoutQuery, body: null });
+ this.job.status = 'needs_input';
+ this.bump('resume', '已恢复火柴人视频任务');
+ return json(route, { job: this.cloneJob(), resumed: true, stage: null, stages: [] });
+ }
+
+ this.unknown.push(`${method} ${path}`);
+ await json(route, { code: 'fake_stickman_route_missing', path }, 404);
+ }
+
+ private async applyAction(route: Route, request: CreatorActionRequest): Promise<void> {
+ if (request.expectedRevision !== this.job.revision) {
+ return json(route, {
+ code: 'creator_revision_conflict',
+ message: 'Creator job revision conflict'
+ }, 409);
+ }
+ switch (request.action) {
+ case 'approve-script':
+ this.approveScript();
+ break;
+ case 'continue-after-audio':
+ this.continueAfterAudio();
+ break;
+ case 'continue-after-visuals':
+ this.continueAfterVisuals();
+ break;
+ case 'regenerate-shot':
+ this.regenerateShot(String(request.input.scopeKey ?? ''));
+ break;
+ case 'update-settings':
+ this.job.state = {
+ ...this.job.state,
+ ...(isRecord(request.input.patch) ? request.input.patch : {})
+ };
+ this.bump(request.action, '已保存火柴人视频设置');
+ break;
+ default:
+ return json(route, {
+ code: 'creator_action_not_supported',
+ message: `Unsupported fake action: ${request.action}`
+ }, 400);
+ }
+ await json(route, {
+ job: this.cloneJob(),
+ receipt: {
+ actor: request.actor ?? 'user',
+ action: request.action,
+ summary: this.job.activities.at(-1)?.summary ?? request.action,
+ affectedArtifacts: [],
+ newRevision: this.job.revision,
+ createdAt: this.job.updatedAt
+ }
+ });
+ }
+
+ private approveScript(): void {
+ const narrationOne = artifact('artifact-narration-01', 'narration_audio', 'segment-01', firstFingerprint, 'segment-01.wav');
+ const narrationTwo = artifact('artifact-narration-02', 'narration_audio', 'segment-02', firstFingerprint, 'segment-02.wav');
+ const timing = artifact('artifact-audio-timing', 'audio_timing', null, null, 'audio-timing.json');
+ this.contents.set(narrationOne.id, { body: 'narration-one', contentType: 'audio/wav' });
+ this.contents.set(narrationTwo.id, { body: 'narration-two', contentType: 'audio/wav' });
+ this.contents.set(timing.id, {
+ body: JSON.stringify({
+ scriptArtifactId: 'artifact-script',
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ segments: [
+ { segmentId: 'segment-01', startSeconds: 0, endSeconds: 5, durationSeconds: 5, audioArtifactId: narrationOne.id, audioSha256: narrationOne.sha256 },
+ { segmentId: 'segment-02', startSeconds: 5, endSeconds: 10, durationSeconds: 5, audioArtifactId: narrationTwo.id, audioSha256: narrationTwo.sha256 }
+ ],
+ totalDurationSeconds: 10
+ }),
+ contentType: 'application/json; charset=utf-8'
+ });
+ this.job.artifacts.push(narrationOne, narrationTwo, timing);
+ this.job.stages.push(
+ stage('narration', 'succeeded', 'segment-01', firstFingerprint),
+ stage('narration', 'succeeded', 'segment-02', firstFingerprint),
+ stage('audio-timing', 'succeeded')
+ );
+ this.job.status = 'running';
+ this.job.state = {
+ ...this.job.state,
+ approvedScriptArtifactId: 'artifact-script',
+ workflowTarget: 'audio_ready',
+ currentStage: 'audio-timing',
+ needsInput: null
+ };
+ this.bump('approve-script', '脚本已确认,配音与节奏已生成');
+ }
+
+ private continueAfterAudio(): void {
+ const shotSpec = artifact('artifact-shot-spec', 'shot_spec', null, null, 'shot-spec.json');
+ this.contents.set(shotSpec.id, {
+ body: JSON.stringify({
+ scriptArtifactId: 'artifact-script',
+ audioTimingArtifactId: 'artifact-audio-timing',
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ shots: [
+ {
+ id: 'shot-01',
+ sourceSegmentId: 'segment-01',
+ semanticAnchor: '每次增长成为下一次增长的基础',
+ visualDescription: '人物把一枚硬币放入逐渐升高的增长曲线',
+ compositionAndAction: '人物位于画面左侧,把硬币放入右侧向上延伸的增长曲线',
+ keyObjects: ['硬币', '增长曲线'],
+ continuityReason: '',
+ motion: 'push-in',
+ motionReason: '聚焦硬币进入增长曲线的关键动作',
+ startSeconds: 0,
+ endSeconds: 5,
+ durationSeconds: 5
+ },
+ {
+ id: 'shot-02',
+ sourceSegmentId: 'segment-02',
+ semanticAnchor: '时间拉大复利与线性积累的差距',
+ visualDescription: '人物观察直线与指数曲线之间逐渐扩大的距离',
+ compositionAndAction: '人物位于画面中央,对比两条向右延伸且差距逐渐扩大的曲线',
+ keyObjects: ['直线', '指数曲线'],
+ continuityReason: '承接上一镜头的增长曲线并展示长期结果',
+ motion: 'pan-right',
+ motionReason: '沿时间方向展示两条曲线的差距变化',
+ startSeconds: 5,
+ endSeconds: 10,
+ durationSeconds: 5
+ }
+ ]
+ }),
+ contentType: 'application/json; charset=utf-8'
+ });
+ this.job.artifacts.push(shotSpec);
+ const shotOne = artifact('artifact-shot-01-v1', 'shot_image', 'shot-01', firstFingerprint, 'shot-01.png');
+ const shotTwo = artifact('artifact-shot-02-v1', 'shot_image', 'shot-02', firstFingerprint, 'shot-02.png');
+ const validation = artifact('artifact-visual-validation', 'visual_validation', null, null, 'visual-validation.json');
+ this.contents.set(shotOne.id, { body: transparentPng, contentType: 'image/png' });
+ this.contents.set(shotTwo.id, { body: transparentPng, contentType: 'image/png' });
+ this.contents.set(validation.id, {
+ body: JSON.stringify({ valid: true, shotCount: 2 }),
+ contentType: 'application/json; charset=utf-8'
+ });
+ this.job.artifacts.push(shotOne, shotTwo, validation);
+ this.job.stages.push(
+ stage('storyboard', 'succeeded'),
+ stage('images', 'succeeded', 'shot-01', firstFingerprint),
+ stage('images', 'succeeded', 'shot-02', firstFingerprint),
+ stage('visual-validation', 'succeeded')
+ );
+ this.job.providerRequests = [providerRequest()];
+ this.job.state = {
+ ...this.job.state,
+ workflowTarget: 'visuals_ready',
+ currentStage: 'visual-validation',
+ needsInput: null
+ };
+ this.bump('continue-after-audio', '配音已确认,分镜画面已生成');
+ }
+
+ private continueAfterVisuals(): void {
+ this.job.state = {
+ ...this.job.state,
+ workflowTarget: 'delivery_ready',
+ currentStage: 'timeline'
+ };
+ this.completeTechnicalDraft(1);
+ this.bump('continue-after-visuals', '画面已确认,动画和交付文件已生成');
+ }
+
+ private regenerateShot(scopeKey: string): void {
+ if (scopeKey !== 'shot-01') throw new Error(`Unexpected scope: ${scopeKey}`);
+ const previous = this.job.artifacts.find(item => item.id === 'artifact-shot-01-v1');
+ if (previous !== undefined) previous.status = 'stale';
+ const next = artifact('artifact-shot-01-v2', 'shot_image', 'shot-01', secondFingerprint, 'shot-01-v2.png', 2);
+ this.contents.set(next.id, { body: transparentPng, contentType: 'image/png' });
+ this.job.artifacts.push(next);
+ this.job.stages.push(stage('images', 'succeeded', 'shot-01', secondFingerprint, 2));
+ for (const artifact of this.job.artifacts) {
+ if (artifact.kind === 'visual_validation' || isDeliveryKind(artifact.kind)) {
+ artifact.status = 'stale';
+ }
+ }
+ const validation = artifact(
+ 'artifact-visual-validation-v2',
+ 'visual_validation',
+ null,
+ null,
+ 'visual-validation-v2.json',
+ 2
+ );
+ this.contents.set(validation.id, {
+ body: JSON.stringify({ valid: true, shotCount: 2, technicalDraft: true }),
+ contentType: 'application/json; charset=utf-8'
+ });
+ this.job.artifacts.push(validation);
+ this.job.stages.push(stage('visual-validation', 'succeeded', null, null, 2));
+ this.job.state = {
+ ...this.job.state,
+ workflowTarget: 'visuals_ready',
+ currentStage: 'visual-validation',
+ needsInput: null
+ };
+ this.bump('regenerate-shot', '镜头 01 已按精确作用域重生成');
+ }
+
+ private completeTechnicalDraft(version: number): void {
+ const suffix = version === 1 ? '' : `-v${version}`;
+ const deliveries = [
+ artifact(`artifact-clean-video${suffix}`, 'clean_video', null, null, `stickman-video${suffix}.mp4`, version),
+ artifact(`artifact-narration-subtitle${suffix}`, 'narration_subtitle', null, null, `narration${suffix}.srt`, version),
+ artifact(`artifact-delivery-manifest${suffix}`, 'delivery_manifest', null, null, `delivery-manifest${suffix}.json`, version)
+ ];
+ for (const delivery of deliveries) {
+ this.contents.set(delivery.id, delivery.kind === 'delivery_manifest'
+ ? {
+ body: JSON.stringify({
+ packageStatus: 'technical-draft',
+ placeholderAssets: deliveries.map(item => `${item.kind}:${item.id}`),
+ blockingChecks: ['fake_provider', 'media_validation_unverified'],
+ files: deliveries.filter(item => item.kind !== 'delivery_manifest').map(item => ({
+ name: item.metadata.fileName,
+ relativePath: String(item.metadata.fileName),
+ sourceArtifactId: item.id,
+ sha256: item.sha256,
+ bytes: 1,
+ mime: mediaType(item.kind)
+ }))
+ }),
+ contentType: 'application/json; charset=utf-8'
+ }
+ : { body: `${delivery.kind}\n`, contentType: mediaType(delivery.kind) });
+ }
+ this.job.artifacts.push(...deliveries);
+ this.job.stages.push(
+ stage('timeline', 'succeeded', null, null, version),
+ stage('render-clean', 'succeeded', null, null, version),
+ stage('media-validation', 'succeeded', null, null, version),
+ stage('package-validation', 'succeeded', null, null, version)
+ );
+ this.job.status = 'completed';
+ const previousSnapshots = Array.isArray(this.job.state.resultSnapshots)
+ ? this.job.state.resultSnapshots
+ : [];
+ this.job.state = {
+ ...this.job.state,
+ workflowTarget: 'delivery_ready',
+ currentStage: 'package-validation',
+ needsInput: null,
+ packageStatus: 'technical-draft',
+ resultSnapshots: [...previousSnapshots, {
+ version,
+ createdAt: '2026-08-31T08:05:00.000Z',
+ action: 'stage-succeeded',
+ stageId: 'package-validation',
+ description: '完成视频与旁白字幕交付',
+ artifactRefs: Object.fromEntries(deliveries.map(item => [item.kind, [item.id]])),
+ changedArtifactIds: deliveries.map(item => item.id),
+ staleArtifactIds: ['artifact-shot-01-v1'],
+ state: { packageStatus: 'technical-draft' }
+ }]
+ };
+ }
+
+ private bump(action: string, summary: string): void {
+ this.job.revision += 1;
+ this.job.updatedAt = `2026-08-31T08:${String(this.job.revision).padStart(2, '0')}:00.000Z`;
+ this.job.activities.push(activity(this.job.revision, action, summary));
+ }
+
+ private cloneJob(): CreatorJob {
+ return structuredClone(this.job);
+ }
+}
+
+function initialJob(projectId: string): CreatorJob {
+ return {
+ id: jobId,
+ projectId,
+ templateId: 'stickman-video',
+ templateVersion: 2,
+ status: 'needs_input',
+ revision: 3,
+ state: {
+ sourceType: 'url',
+ sourceUrl: 'https://www.youtube.com/watch?v=OpenCreatorStickmanE2E',
+ characterAsset: { assetId: 'stickman.character.default', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.paper-pencil', revision: 1 },
+ ratio: '16:9',
+ targetDurationSeconds: 20,
+ targetLanguage: 'zh-CN',
+ ttsProvider: 'openai',
+ ttsModel: 'gpt-4o-mini-tts',
+ voiceCode: 'marin',
+ voiceName: 'Marin',
+ workflowTarget: 'script_ready',
+ currentStage: null,
+ needsInput: review('approve-script', 'artifact-script', '请审核脚本后继续')
+ },
+ agentThreadId: null,
+ stages: [
+ stage('acquire-source', 'succeeded'),
+ stage('source-transcript', 'succeeded'),
+ stage('source-brief', 'succeeded'),
+ stage('content-plan', 'succeeded'),
+ stage('script', 'succeeded')
+ ],
+ artifacts: [artifact('artifact-script', 'script_manifest', null, null, 'script-manifest.json')],
+ providerRequests: [],
+ activities: [
+ activity(1, 'update-settings', '已保存来源、角色与视觉风格'),
+ activity(2, 'run-stage', '已开始执行火柴人视频生产'),
+ activity(3, 'stage-succeeded', '脚本生成完成,等待审核')
+ ],
+ createdAt,
+ updatedAt: '2026-08-31T08:03:00.000Z'
+ };
+}
+
+function fakeVisualAssets() {
+ return [{
+ id: 'stickman.character.default',
+ revision: 1,
+ templateId: 'stickman-video',
+ kind: 'character',
+ source: 'builtin',
+ status: 'ready',
+ name: { zhCN: '默认角色', en: 'Default' },
+ description: { zhCN: '通用火柴人角色', en: 'General stick-figure character' },
+ previewUrl: null,
+ referenceCount: 1,
+ recommended: true,
+ tags: ['neutral']
+ }, {
+ id: 'stickman.style.paper-pencil',
+ revision: 1,
+ templateId: 'stickman-video',
+ kind: 'style',
+ source: 'builtin',
+ status: 'ready',
+ name: { zhCN: '纸面铅笔手绘', en: 'Pencil sketch on paper' },
+ description: { zhCN: '纸面、铅笔轮廓与石墨排线', en: 'Paper, pencil contours, and graphite hatching' },
+ previewUrl: null,
+ referenceCount: 0,
+ recommended: true,
+ tags: ['pencil'],
+ styleAttributes: {
+ medium: { zhCN: '石墨铅笔', en: 'Graphite pencil' },
+ palette: { zhCN: '纸白、黑、灰', en: 'Paper white, black, gray' },
+ sceneDensity: { zhCN: '中等', en: 'Medium' },
+ swatch: {
+ background: '#f5f3ed',
+ foreground: '#252525',
+ accent: '#8a8a86',
+ texture: 'paper'
+ }
+ }
+ }];
+}
+
+function stage(
+ stageId: string,
+ status: CreatorStageRun['status'],
+ scopeKey: string | null = null,
+ inputFingerprint: string | null = null,
+ attempt = 1
+): CreatorStageRun {
+ return {
+ id: `stage-${stageId}-${scopeKey ?? 'global'}-${attempt}`,
+ jobId,
+ stageId,
+ executor: stageId === 'images' ? 'stickman-image' : `stickman-${stageId}`,
+ status,
+ dispatchStatus: 'finished',
+ claimOwner: null,
+ claimExpiresAt: null,
+ attempt,
+ idempotencyKey: `fake:${stageId}:${scopeKey ?? 'global'}:${attempt}`,
+ scopeKey,
+ inputFingerprint,
+ progress: scopeKey === null ? { phase: 'completed' } : { phase: 'completed', percent: 100 },
+ errorCode: null,
+ errorMessage: null,
+ startedAt: createdAt,
+ finishedAt: '2026-08-31T08:01:00.000Z'
+ };
+}
+
+function artifact(
+ id: string,
+ kind: string,
+ scopeKey: string | null,
+ inputFingerprint: string | null,
+ fileName: string,
+ version = 1
+): CreatorArtifact {
+ return {
+ id,
+ jobId,
+ kind,
+ version,
+ status: 'completed',
+ path: `/fake-stickman/${fileName}`,
+ scopeKey,
+ inputFingerprint,
+ sha256: version === 1 ? 'a'.repeat(64) : 'b'.repeat(64),
+ sourceArtifactIds: [],
+ metadata: {
+ fileName,
+ placeholder: true,
+ technicalDraft: true
+ },
+ createdAt: version === 1 ? createdAt : '2026-08-31T08:04:00.000Z'
+ };
+}
+
+function providerRequest(): CreatorProviderRequest {
+ return {
+ id: 'provider-request-shot-01',
+ jobId,
+ provider: 'openai',
+ stageRunId: 'stage-images-shot-01-1',
+ scopeKey: 'shot-01',
+ requestKey: 'fake-provider-request',
+ requestHash: 'c'.repeat(64),
+ remoteTaskId: 'fake-provider-task',
+ billingSideEffect: true,
+ status: 'succeeded',
+ resultArtifactId: 'artifact-shot-01-v1',
+ generation: 1,
+ resubmissionOf: null,
+ createdAt,
+ updatedAt: createdAt
+ };
+}
+
+function activity(revision: number, action: string, summary: string): CreatorActivity {
+ return {
+ id: `activity-${revision}-${action}`,
+ jobId,
+ revision,
+ actor: 'user',
+ action,
+ summary,
+ details: {},
+ createdAt: `2026-08-31T08:${String(revision).padStart(2, '0')}:00.000Z`
+ };
+}
+
+function review(kind: string, artifactId: string, message: string) {
+ return {
+ code: 'creator_review_required',
+ kind,
+ artifactId,
+ message
+ };
+}
+
+function mediaType(kind: string): string {
+ if (kind.includes('video')) return 'video/mp4';
+ if (kind.includes('subtitle')) return 'application/x-subrip; charset=utf-8';
+ if (kind.includes('manifest')) return 'application/json; charset=utf-8';
+ return 'text/markdown; charset=utf-8';
+}
+
+function isDeliveryKind(kind: string): boolean {
+ return [
+ 'clean_video',
+ 'narration_subtitle',
+ 'delivery_manifest'
+ ].includes(kind);
+}
+
+function isRecord(value: unknown): value is Record<string, never> {
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
+}
+
+async function json(route: Route, body: unknown, status = 200): Promise<void> {
+ await route.fulfill({
+ status,
+ contentType: 'application/json; charset=utf-8',
+ body: JSON.stringify(body)
+ });
+}
diff --git a/apps/web/e2e/web-desktop-parity.spec.ts b/apps/web/e2e/web-desktop-parity.spec.ts
index 5964f33a..f4cdaa11 100644
--- a/apps/web/e2e/web-desktop-parity.spec.ts
+++ b/apps/web/e2e/web-desktop-parity.spec.ts
@@ -438,6 +438,104 @@ test('小红书帖子在 Browser/Desktop Bridge 下保持相同界面、请求
expect(results[1]!.state).toEqual(results[0]!.state);
});
+test('Windows 本地 Whisper 在 Browser/Desktop Bridge 下保持相同界面、请求和持久状态', async ({
+ browser,
+ runtime
+}, testInfo) => {
+ test.skip(
+ testInfo.project.name !== 'chromium-desktop',
+ '一致性规格内部固定创建 Browser/Desktop Chromium 上下文'
+ );
+
+ const results: Array<{
+ text: string;
+ boxes: Record<string, { x: number; y: number; width: number; height: number }>;
+ requests: string[];
+ transcription: Record<string, unknown>;
+ }> = [];
+
+ for (const platform of ['browser', 'desktop'] as const) {
+ await runtime.api('DELETE', '/creator-services/config');
+ const context = await browser.newContext({
+ viewport: { width: 1280, height: 800 },
+ deviceScaleFactor: 1,
+ colorScheme: 'dark',
+ reducedMotion: 'reduce'
+ });
+ const page = await context.newPage();
+ if (platform === 'desktop') await installDesktopBridge(page);
+ const requests: string[] = [];
+ page.on('request', request => {
+ const url = new URL(request.url());
+ if (!url.pathname.includes('/creator-services/')) return;
+ requests.push(`${request.method()} ${url.pathname.replace('/.opencreator/runtime', '')}`);
+ });
+
+ try {
+ await runtime.openApp(page);
+ await page.goto(`${runtime.origin}/#/settings?tab=ai-services&section=transcription`);
+ const settings = page
+ .getByRole('region', { name: 'OpenCreator 工作区' })
+ .getByRole('main');
+ const localMode = settings.getByRole('button', { name: '本地 Whisper' });
+ await expect(settings.getByText('Windows · x64')).toBeVisible();
+ await expect(localMode).toBeEnabled();
+ await localMode.click();
+
+ const provider = settings.getByRole('combobox', { name: '语音识别服务' });
+ const model = settings.getByRole('combobox', { name: '本地模型' });
+ await expect(provider).toHaveText('Whisper.cpp');
+ await expect(model).toHaveText('tiny');
+ await model.click();
+ await settings.getByRole('option', { name: 'medium' }).click();
+ await settings.getByRole('button', { name: '保存配置' }).click();
+ await page.getByRole('button', { name: '保存并启用' }).click();
+ await expect(settings.getByText('配置已安全保存')).toBeVisible();
+
+ const boxes: Record<
+ string,
+ { x: number; y: number; width: number; height: number }
+ > = {};
+ for (const [name, locator] of [
+ ['settings', settings],
+ ['local-mode', localMode],
+ ['provider', provider],
+ ['model', model]
+ ] as const) {
+ const box = await locator.boundingBox();
+ expect(box, `${platform} 缺少 ${name} 尺寸目标`).not.toBeNull();
+ boxes[name] = {
+ x: Math.round(box!.x),
+ y: Math.round(box!.y),
+ width: Math.round(box!.width),
+ height: Math.round(box!.height)
+ };
+ }
+ const persisted = await runtime.api<{
+ config: { transcription: Record<string, unknown> };
+ }>('GET', '/creator-services/config');
+ results.push({
+ text: normalizeParityText(await settings.innerText()),
+ boxes,
+ requests,
+ transcription: persisted.config.transcription
+ });
+ } finally {
+ await context.close();
+ }
+ }
+
+ expect(results[1]!.text).toBe(results[0]!.text);
+ expect(results[1]!.boxes).toEqual(results[0]!.boxes);
+ expect(results[1]!.requests).toEqual(results[0]!.requests);
+ expect(results[1]!.transcription).toEqual(results[0]!.transcription);
+ expect(results[0]!.transcription).toMatchObject({
+ provider: 'whisper.cpp',
+ whisperCpp: { model: 'medium' }
+ });
+ expect(results[0]!.requests).toContain('PATCH /creator-services/config');
+});
+
test('第三方组件设置在 Browser/Desktop Bridge 下保持相同状态、尺寸和 Runtime 请求', async ({
browser,
runtime
diff --git a/apps/web/src/app/App.test.tsx b/apps/web/src/app/App.test.tsx
index 5ca3aaca..bc9b0f4c 100644
--- a/apps/web/src/app/App.test.tsx
+++ b/apps/web/src/app/App.test.tsx
@@ -314,6 +314,7 @@ describe('App', () => {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -7798,6 +7799,7 @@ function handleDefaultCreatorApiRequest(
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt: now,
updatedAt: now
@@ -7837,6 +7839,9 @@ function handleDefaultCreatorApiRequest(
version: 1,
status: 'completed' as const,
path: `/tmp/${fileName}`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: 'test-source-sha256',
sourceArtifactIds: [],
metadata: {
fileName,
@@ -7892,6 +7897,9 @@ function handleDefaultCreatorApiRequest(
version: 1,
status: 'completed',
path: '/tmp/translated.srt',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
cues: [
diff --git a/apps/web/src/features/dashboard/CoverGeneratorWorkspace.test.tsx b/apps/web/src/features/dashboard/CoverGeneratorWorkspace.test.tsx
index d5d93ad0..b37674bd 100644
--- a/apps/web/src/features/dashboard/CoverGeneratorWorkspace.test.tsx
+++ b/apps/web/src/features/dashboard/CoverGeneratorWorkspace.test.tsx
@@ -356,6 +356,8 @@ describe('CoverGeneratorWorkspace', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'cover-stage-running',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'generating_candidates',
percent: 53,
@@ -407,6 +409,8 @@ describe('CoverGeneratorWorkspace', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'cover-analysis-running',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
workflow: true,
phase: 'analyzing_source',
@@ -454,6 +458,8 @@ describe('CoverGeneratorWorkspace', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'cover-analysis-retrying',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
workflow: true,
phase: 'reading_source_retry',
@@ -535,6 +541,7 @@ function createFixture() {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -644,6 +651,9 @@ function createFixture() {
version: 1,
status: 'completed',
path: '/tmp/reference.png',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
fileName: input.file.name,
@@ -706,6 +716,9 @@ function coverArtifact(
version: candidate,
status: 'completed',
path: `/tmp/cover-${candidate}.png`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
candidate,
@@ -731,6 +744,9 @@ function sourceKeyframeArtifact(
version: 1,
status: 'completed',
path: '/tmp/source-thumbnail.jpg',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
fileName: 'source-thumbnail.jpg',
diff --git a/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsx b/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsx
index 4d5d011b..f958b0a5 100644
--- a/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsx
+++ b/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsx
@@ -307,6 +307,34 @@ describe('CreatorCollaborationPanel', () => {
expect(screen.queryByText(/upstreamId|videoGenerationResultId/)).not.toBeInTheDocument();
});
+ it('完成阶段不误报结果已同步到工作台', () => {
+ const current = downloadJob();
+ current.stages[0] = {
+ ...current.stages[0]!,
+ status: 'succeeded',
+ dispatchStatus: 'finished',
+ progress: { phase: 'completed', percent: 100 },
+ finishedAt: '2026-08-30T08:00:06.000Z'
+ };
+ render(
+ <LanguageProvider initialPreference="zh-CN">
+ <CreatorSessionProvider
+ initialJob={current}
+ service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}
+ >
+ <CreatorCollaborationPanel
+ adapter={videoDownloadPanelAdapter}
+ stepLabel="下载到项目"
+ contextSummary="YouTube · 1080p"
+ />
+ </CreatorSessionProvider>
+ </LanguageProvider>
+ );
+
+ expect(screen.getByText('已完成')).toBeInTheDocument();
+ expect(screen.queryByText('已完成,结果已同步到工作台')).not.toBeInTheDocument();
+ });
+
it('视频解析阶段显示不确定进度而不是固定 20%', () => {
const current = downloadJob();
current.state.currentStage = 'probe';
@@ -586,6 +614,8 @@ function wechatArticleJob(): CreatorJob {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'wechat-topics-1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: { phase: 'generating_topics', percent: 55, completed: 2, failed: 0, total: 2 },
errorCode: null,
errorMessage: null,
@@ -593,6 +623,7 @@ function wechatArticleJob(): CreatorJob {
finishedAt: null
}],
artifacts: [],
+ providerRequests: [],
activities: [
{ id: 'ui', jobId, revision: 1, actor: 'user', action: 'update-settings:draft', summary: '更新创作设置', details: { objectId: 'currentStep,furthestStep' }, createdAt: '2026-09-07T09:00:01.000Z' },
{ id: 'brief', jobId, revision: 2, actor: 'user', action: 'update-settings:draft', summary: '更新创作设置', details: { objectId: 'writingPrompt' }, createdAt: '2026-09-07T09:00:02.000Z' },
@@ -634,6 +665,8 @@ function xiaohongshuPostJob(): CreatorJob {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'xiaohongshu-1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'generating_post',
percent: 20,
@@ -647,6 +680,7 @@ function xiaohongshuPostJob(): CreatorJob {
finishedAt: null
}],
artifacts: [],
+ providerRequests: [],
activities: [
{
id: 'activity_topic_1',
@@ -716,6 +750,8 @@ function smartDubbingJob(): CreatorJob {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'smart-dubbing-1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'generating_voice',
percent: 20,
@@ -729,6 +765,7 @@ function smartDubbingJob(): CreatorJob {
finishedAt: null
}],
artifacts: [],
+ providerRequests: [],
activities: [
{
id: 'activity_ui',
@@ -805,6 +842,8 @@ function coverJob(): CreatorJob {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'cover-generate-1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'generating_candidates',
percent: 50,
@@ -818,6 +857,7 @@ function coverJob(): CreatorJob {
finishedAt: null
}],
artifacts: [],
+ providerRequests: [],
activities: [
{
id: 'activity_ui_1',
@@ -902,6 +942,8 @@ function downloadJob(): CreatorJob {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'download-1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'downloading',
percent: 42,
@@ -913,6 +955,7 @@ function downloadJob(): CreatorJob {
finishedAt: null
}],
artifacts: [],
+ providerRequests: [],
activities: [
{
id: 'activity_ui',
@@ -989,6 +1032,8 @@ function videoGenerationJob(): CreatorJob {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'video-generation-1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'generating',
message: 'The video provider is generating the video',
@@ -1000,6 +1045,7 @@ function videoGenerationJob(): CreatorJob {
finishedAt: null
}],
artifacts: [],
+ providerRequests: [],
activities: [
{
id: 'video_generation_ui',
diff --git a/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx b/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx
index 5684b77f..2803c4ad 100644
--- a/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx
+++ b/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx
@@ -541,7 +541,8 @@ function buildCollaborationTimeline(
events: SyncEvent[],
adapter: CreatorPanelAdapter
): CollaborationTimelineItem[] {
- const stages = latestStageRuns(job?.stages ?? []);
+ const stages = adapter.aggregateStages?.(latestStageRuns(job?.stages ?? []))
+ ?? latestStageRuns(job?.stages ?? []);
const representedStageIds = new Set(stages.map(stage => stage.stageId));
const items: CollaborationTimelineItem[] = messages.map(message => ({
id: message.id,
@@ -650,9 +651,10 @@ function actorLabel(
function latestStageRuns(stages: CreatorStageRun[]): CreatorStageRun[] {
const runsByStage = new Map<string, CreatorStageRun[]>();
for (const stage of stages) {
- const runs = runsByStage.get(stage.stageId) ?? [];
+ const key = `${stage.stageId}:${stage.scopeKey ?? ''}`;
+ const runs = runsByStage.get(key) ?? [];
runs.push(stage);
- runsByStage.set(stage.stageId, runs);
+ runsByStage.set(key, runs);
}
return [...runsByStage.values()].map(runs => {
const latest = runs.at(-1)!;
@@ -699,7 +701,7 @@ function stageProgressText(
if (stage.status === 'queued') return l('等待执行', 'Queued');
if (stage.status === 'succeeded') {
return adapter.succeededProgressText?.(stage, l)
- ?? l('已完成,结果已同步到工作台', 'Completed and synced to Workbench');
+ ?? l('已完成', 'Completed');
}
if (stage.status === 'failed') {
return adapter.failedProgressText?.(stage, l)
diff --git a/apps/web/src/features/dashboard/CreatorToolShell.tsx b/apps/web/src/features/dashboard/CreatorToolShell.tsx
index e354d6ba..9af85117 100644
--- a/apps/web/src/features/dashboard/CreatorToolShell.tsx
+++ b/apps/web/src/features/dashboard/CreatorToolShell.tsx
@@ -9,6 +9,7 @@ import { useOptionalCreatorSession } from './creator-session-store.js';
export default function CreatorToolShell(props: {
title: string;
+ titleIcon?: ReactNode;
subtitle: string;
context: string;
initialMessage?: string;
@@ -40,10 +41,13 @@ export default function CreatorToolShell(props: {
<main className={`creator-workspace-page${props.pageClassName ? ` ${props.pageClassName}` : ''}`}>
<div className="creator-workspace-layout">
<section className="creator-workspace-main" aria-label={`${props.title} ${l('操作区', 'workspace')}`}>
- <header className="creator-workspace-header">
+ <header className={`creator-workspace-header${props.titleIcon === undefined ? '' : ' has-title-icon'}`}>
<button type="button" onClick={props.onBack} aria-label={l('返回', 'Back')}>
<ArrowLeft size={18} strokeWidth={1.8} aria-hidden="true" />
</button>
+ {props.titleIcon === undefined ? null : (
+ <span className="creator-workspace-title-icon" aria-hidden="true">{props.titleIcon}</span>
+ )}
<div>
<h1>{props.title}</h1>
<p>{props.subtitle}</p>
diff --git a/apps/web/src/features/dashboard/DashboardPage.test.tsx b/apps/web/src/features/dashboard/DashboardPage.test.tsx
index efe2e010..db75197b 100644
--- a/apps/web/src/features/dashboard/DashboardPage.test.tsx
+++ b/apps/web/src/features/dashboard/DashboardPage.test.tsx
@@ -43,6 +43,7 @@ function createInMemoryCreatorService(): CreatorWebService {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt: now,
updatedAt: now
@@ -129,6 +130,9 @@ function completeSmartDubbingStage(current: CreatorJob): CreatorJob {
version,
status: 'completed',
path: `/tmp/${fileName}`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
resultVersion: version,
@@ -168,6 +172,8 @@ function completeSmartDubbingStage(current: CreatorJob): CreatorJob {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'completed',
percent: 100,
@@ -410,6 +416,8 @@ function completeTranslationStage(
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
workflow: true,
resultVersion: version,
@@ -449,6 +457,9 @@ function translationArtifact(
version: input.artifactVersion ?? input.version,
status: 'completed',
path: `/tmp/${input.fileName}`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
resultVersion: input.version,
@@ -604,6 +615,7 @@ describe('DashboardPage', () => {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -1996,6 +2008,7 @@ describe('DashboardPage', () => {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -2024,6 +2037,9 @@ describe('DashboardPage', () => {
version,
status: 'completed',
path: `/tmp/image-${candidate}.png`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
provider: 'openai',
@@ -2078,6 +2094,8 @@ describe('DashboardPage', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: { status: 'succeeded' },
errorCode: null,
errorMessage: null,
@@ -2189,6 +2207,7 @@ describe('DashboardPage', () => {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -2212,6 +2231,9 @@ describe('DashboardPage', () => {
version,
status: 'completed',
path: '/tmp/generated-video-v1.mp4',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: job.artifacts
.filter(candidate => candidate.kind === 'reference_image')
.map(candidate => candidate.id),
@@ -2266,6 +2288,8 @@ describe('DashboardPage', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: { status: 'succeeded', phase: 'completed', percent: 100 },
errorCode: null,
errorMessage: null,
@@ -2298,6 +2322,9 @@ describe('DashboardPage', () => {
version: 1,
status: 'completed',
path: '/tmp/coast-reference.png',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
fileName: input.file.name,
diff --git a/apps/web/src/features/dashboard/DashboardPage.tsx b/apps/web/src/features/dashboard/DashboardPage.tsx
index 7eb9fdf8..ef9c65fc 100644
--- a/apps/web/src/features/dashboard/DashboardPage.tsx
+++ b/apps/web/src/features/dashboard/DashboardPage.tsx
@@ -388,6 +388,8 @@ export default function DashboardPage(props: {
return renderCreatorWorkspace('stickman-video', (
<StickmanVideoWorkspace
promptHint={activePromptHint}
+ creatorServicesService={props.creatorServicesService}
+ creatorService={props.creatorService}
onBack={closeWorkspace}
/>
));
@@ -707,13 +709,14 @@ function createPendingCreatorJob(projectId: string, templateId: string): Creator
id: `pending:${projectId}:${templateId}`,
projectId,
templateId,
- templateVersion: 1,
+ templateVersion: templateId === 'stickman-video' ? 2 : 1,
status: 'draft',
revision: 0,
state: {},
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt: now,
updatedAt: now
diff --git a/apps/web/src/features/dashboard/ImageGenerationWorkspace.test.tsx b/apps/web/src/features/dashboard/ImageGenerationWorkspace.test.tsx
index 645e4c74..14c5db6a 100644
--- a/apps/web/src/features/dashboard/ImageGenerationWorkspace.test.tsx
+++ b/apps/web/src/features/dashboard/ImageGenerationWorkspace.test.tsx
@@ -166,6 +166,9 @@ function imageArtifact(jobId: string, resultVersion: number, createdAt: string):
version: resultVersion,
status: 'completed',
path: `/tmp/generated-image-v${resultVersion}.png`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
candidate: 1,
@@ -224,6 +227,7 @@ function createFixture(options: { pending?: boolean } = {}) {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -272,6 +276,9 @@ function createFixture(options: { pending?: boolean } = {}) {
version: 1,
status: 'completed',
path: '/tmp/reference.png',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
fileName: input.file.name,
diff --git a/apps/web/src/features/dashboard/StickmanVideoWorkspace.test.tsx b/apps/web/src/features/dashboard/StickmanVideoWorkspace.test.tsx
new file mode 100644
index 00000000..5d77425b
--- /dev/null
+++ b/apps/web/src/features/dashboard/StickmanVideoWorkspace.test.tsx
@@ -0,0 +1,1392 @@
+import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
+import type { ComponentProps } from 'react';
+import {
+ createDefaultCreatorServicesConfig,
+ type CreatorArtifact,
+ type CreatorJob,
+ type CreatorStageRun
+} from '@opencreator/protocol';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { LanguageProvider } from '../../i18n/LanguageProvider.js';
+import { CreatorSessionProvider } from './creator-session-store.js';
+import StickmanVideoWorkspace from './StickmanVideoWorkspace.js';
+
+beforeEach(() => {
+ Object.defineProperty(URL, 'createObjectURL', {
+ configurable: true,
+ value: vi.fn(() => 'blob:stickman-artifact')
+ });
+ Object.defineProperty(URL, 'revokeObjectURL', {
+ configurable: true,
+ value: vi.fn()
+ });
+});
+
+describe('StickmanVideoWorkspace', () => {
+ it('supports text input with fixed characters, a style selector, and a scrollable tool stack', async () => {
+ const initialJob = job({
+ state: {
+ sourceType: 'text',
+ sourceText: '用火柴人解释为什么要做最小充分验证',
+ characterAsset: { assetId: 'stickman.character.tech-guy', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.minimal-ink', revision: 1 }
+ }
+ });
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => ({
+ job: initialJob,
+ receipt: {
+ actor: 'user',
+ action: request.action,
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: initialJob.revision,
+ createdAt: initialJob.updatedAt
+ }
+ }));
+ const { container } = renderWorkspace(initialJob, new Map(), applyAction, configuredTtsService());
+
+ expect(screen.getByRole('textbox', { name: '文本内容' })).toHaveValue('用火柴人解释为什么要做最小充分验证');
+ expect(screen.queryByLabelText('角色描述')).not.toBeInTheDocument();
+ await waitFor(() => expect(screen.getByRole('combobox', { name: '视觉风格' }))
+ .toHaveValue('stickman.style.minimal-ink@1'));
+ expect(screen.getByRole('combobox', { name: '目标时长' })).toHaveValue('30');
+ expect(await screen.findByRole('combobox', { name: '配音音色' })).toBeInTheDocument();
+ expect(within(screen.getByRole('radiogroup', { name: '角色预设' })).getAllByRole('radio')).toHaveLength(10);
+ expect(screen.queryByLabelText('任务摘要')).not.toBeInTheDocument();
+ expect(container.querySelector('.creator-tool-stack.stickman-tool-stack')).not.toBeNull();
+ expect(screen.getByRole('button', { name: '开始生成' })).toHaveClass('video-translation-primary-action');
+
+ const steps = screen.getByRole('navigation', { name: '火柴人视频制作步骤' });
+ expect(steps).toHaveClass('video-translation-steps', 'stickman-steps');
+ expect(within(steps).getByRole('button', { name: /来源与角色/ })).toHaveAttribute('aria-current', 'step');
+ expect(within(steps).getByRole('button', { name: /脚本审核/ })).toBeDisabled();
+
+ fireEvent.click(screen.getByRole('button', { name: '开始生成' }));
+ await waitFor(() => expect(applyAction).toHaveBeenCalledWith(
+ initialJob.id,
+ expect.objectContaining({
+ action: 'run-stage',
+ input: { stageId: 'ingest-text' }
+ })
+ ));
+ });
+
+ it('supports duration presets and a bounded custom duration', () => {
+ renderWorkspace(job());
+
+ const duration = screen.getByRole('combobox', { name: '目标时长' });
+ fireEvent.change(duration, { target: { value: '300' } });
+ expect(duration).toHaveValue('300');
+ expect(screen.queryByRole('spinbutton', { name: '自定义时长(秒)' })).not.toBeInTheDocument();
+
+ fireEvent.change(duration, { target: { value: 'custom' } });
+ const custom = screen.getByRole('spinbutton', { name: '自定义时长(秒)' });
+ expect(custom).toHaveValue(90);
+ fireEvent.change(custom, { target: { value: '125' } });
+ expect(custom).toHaveValue(125);
+ });
+
+ it('inherits the shared TTS configuration and persists the selected voice fields', async () => {
+ const initialJob = job();
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => ({
+ job: initialJob,
+ receipt: {
+ actor: 'user',
+ action: request.action,
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: initialJob.revision,
+ createdAt: initialJob.updatedAt
+ }
+ }));
+ const config = createDefaultCreatorServicesConfig();
+ const creatorServicesService = {
+ getConfig: vi.fn(async () => ({ config, configuredCredentials: ['tts.openai.apiKey'] })),
+ getTtsVoices: vi.fn(async () => ({
+ provider: 'openai' as const,
+ model: config.tts.openai.model,
+ voices: [
+ { id: 'marin', name: 'Marin', provider: 'openai' as const, kind: 'builtin' as const },
+ { id: 'nova', name: 'Nova', provider: 'openai' as const, kind: 'builtin' as const }
+ ]
+ })),
+ previewTtsVoice: vi.fn()
+ };
+ renderWorkspace(initialJob, new Map(), applyAction, creatorServicesService as never);
+
+ const voice = await screen.findByRole('combobox', { name: '配音音色' });
+ await waitFor(() => expect(voice).toHaveValue('marin'));
+ fireEvent.change(voice, { target: { value: 'nova' } });
+ fireEvent.click(screen.getByRole('button', { name: '开始生成' }));
+
+ await waitFor(() => {
+ const persisted = Object.assign({}, ...applyAction.mock.calls.flatMap(([, request]) => {
+ if (request.action !== 'update-settings') return [];
+ const input = request.input as { patch?: Record<string, unknown> };
+ return input.patch === undefined ? [] : [input.patch];
+ }));
+ expect(persisted).toMatchObject({
+ ttsProvider: 'openai',
+ ttsModel: config.tts.openai.model,
+ voiceCode: 'nova',
+ voiceName: 'Nova'
+ });
+ });
+ });
+
+ it('prompts for TTS configuration instead of showing a default voice without credentials', async () => {
+ const config = createDefaultCreatorServicesConfig();
+ const creatorServicesService = {
+ getConfig: vi.fn(async () => ({ config, configuredCredentials: [] })),
+ getTtsVoices: vi.fn(),
+ previewTtsVoice: vi.fn()
+ };
+
+ renderWorkspace(job(), new Map(), undefined, creatorServicesService as never);
+
+ expect(await screen.findByText('尚未配置配音服务')).toBeInTheDocument();
+ expect(screen.queryByRole('combobox', { name: '配音音色' })).not.toBeInTheDocument();
+ expect(screen.getByRole('link', { name: '前往配音服务配置' }))
+ .toHaveAttribute('href', '#/settings?tab=ai-services&section=tts');
+ expect(screen.getByRole('button', { name: '开始生成' })).toBeDisabled();
+ expect(creatorServicesService.getTtsVoices).not.toHaveBeenCalled();
+ });
+
+ it('passes a YouTube URL directly to the KrillinAI transcript stage', async () => {
+ const initialJob = job();
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => ({
+ job: initialJob,
+ receipt: {
+ actor: 'user',
+ action: request.action,
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: initialJob.revision,
+ createdAt: initialJob.updatedAt
+ }
+ }));
+ renderWorkspace(initialJob, new Map(), applyAction, configuredTtsService());
+
+ expect(screen.getByRole('textbox', { name: 'YouTube 链接' })).toBeInTheDocument();
+ await screen.findByRole('combobox', { name: '配音音色' });
+ fireEvent.click(screen.getByRole('button', { name: '开始生成' }));
+ await waitFor(() => expect(applyAction).toHaveBeenCalledWith(
+ initialJob.id,
+ expect.objectContaining({
+ action: 'run-stage',
+ input: { stageId: 'source-transcript' }
+ })
+ ));
+ });
+
+ it('does not show ready results before persisted artifacts arrive', () => {
+ renderWorkspace(job({ status: 'running', stages: [stage('source-transcript', 'running')] }));
+
+ expect(document.querySelectorAll('.creator-collaboration-panel')).toHaveLength(1);
+ expect(screen.queryByText('固定五项交付')).not.toBeInTheDocument();
+ expect(screen.queryByText('项目 V1')).not.toBeInTheDocument();
+ expect(screen.getAllByText('执行中').length).toBeGreaterThan(0);
+ });
+
+ it('moves to a stable script editor skeleton while the script is being generated', () => {
+ const { container } = renderWorkspace(job({
+ status: 'running',
+ stages: [stage('script', 'running')],
+ state: { currentStage: 'script' }
+ }));
+
+ const steps = screen.getByRole('navigation', { name: '火柴人视频制作步骤' });
+ expect(within(steps).getByRole('button', { name: /脚本审核/ })).toHaveAttribute('aria-current', 'step');
+ expect(container.querySelector('.stickman-script-placeholder')).toHaveAttribute('data-state', 'loading');
+ expect(container.querySelector('.stickman-script-skeleton-editor')).toHaveAttribute('aria-hidden', 'true');
+ expect(container.querySelectorAll('.stickman-script-skeleton-row')).toHaveLength(3);
+ expect(screen.getByRole('status')).toHaveTextContent('正在生成');
+ expect(screen.getByRole('button', { name: '上一步' })).toBeEnabled();
+ expect(screen.getByRole('button', { name: '下一步' })).toBeDisabled();
+ expect(screen.queryByText('脚本正在生成或等待执行')).not.toBeInTheDocument();
+ });
+
+ it('shows a local retry action when script generation fails', async () => {
+ const failedStage = {
+ ...stage('script', 'failed'),
+ errorCode: 'creator_stage_failed',
+ errorMessage: '脚本服务暂时不可用'
+ };
+ const failedJob = job({
+ status: 'failed',
+ stages: [failedStage],
+ state: { currentStage: 'script' }
+ });
+ const applyAction = vi.fn(async () => ({
+ job: failedJob,
+ receipt: {
+ actor: 'user' as const,
+ action: 'retry-stage',
+ summary: 'retry-stage',
+ affectedArtifacts: [],
+ newRevision: failedJob.revision,
+ createdAt: failedJob.updatedAt
+ }
+ }));
+ const { container } = renderWorkspace(failedJob, new Map(), applyAction);
+
+ const error = container.querySelector('.stickman-script-placeholder-error');
+ expect(error).not.toBeNull();
+ expect(within(error as HTMLElement).getByText('脚本服务暂时不可用')).toBeInTheDocument();
+ fireEvent.click(within(error as HTMLElement).getByRole('button', { name: '重新生成' }));
+
+ await waitFor(() => expect(applyAction).toHaveBeenCalledWith(
+ failedJob.id,
+ expect.objectContaining({ action: 'retry-stage', input: { stageId: 'script' } })
+ ));
+ });
+
+ it('shows regeneration progress and prevents advancing with the previous script', async () => {
+ const persisted = scriptReviewJob();
+ const runningJob: CreatorJob = {
+ ...persisted.job,
+ status: 'running',
+ revision: persisted.job.revision + 1,
+ stages: [
+ {
+ ...stage('ingest-text', 'succeeded'),
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ },
+ {
+ ...stage('source-brief', 'succeeded'),
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ },
+ {
+ ...stage('content-plan', 'succeeded'),
+ progress: { phase: 'completed', percent: 100, completed: 1, failed: 0, total: 1 }
+ },
+ {
+ ...stage('script', 'running'),
+ progress: {
+ phase: 'writing',
+ percent: 15,
+ completed: 0,
+ failed: 0,
+ total: 1
+ }
+ }
+ ],
+ state: { ...persisted.job.state, currentStage: 'script', needsInput: null }
+ };
+ const applyAction = vi.fn(async () => ({
+ job: runningJob,
+ receipt: {
+ actor: 'user' as const,
+ action: 'run-stage',
+ summary: 'run-stage',
+ affectedArtifacts: [],
+ newRevision: runningJob.revision,
+ createdAt: runningJob.updatedAt
+ }
+ }));
+ renderWorkspace(persisted.job, persisted.contents, applyAction, configuredTtsService());
+
+ await screen.findByRole('textbox', { name: '第 1 段旁白' });
+ fireEvent.click(screen.getByRole('button', { name: '上一步' }));
+ fireEvent.click(await screen.findByRole('button', { name: '重新生成' }));
+
+ expect(await screen.findByRole('button', { name: '重新生成中...' })).toBeDisabled();
+ expect(screen.getByRole('button', { name: '下一步' })).toBeDisabled();
+ expect(screen.getByRole('progressbar', { name: '生成脚本进度' }))
+ .toHaveAttribute('aria-valuenow', '79');
+ expect(document.querySelectorAll('.creator-collaboration-stage')).toHaveLength(1);
+ expect(screen.getByText('生成创作内容')).toBeInTheDocument();
+ expect(screen.queryByText(/镜头完成/)).not.toBeInTheDocument();
+ });
+
+ it('opens script review automatically when a regenerated script requests approval', async () => {
+ const persisted = scriptReviewJob();
+ const regeneratedArtifact = { ...artifact('script-regenerated', 'script_manifest'), version: 2 };
+ const regeneratedValue: ScriptManifestFixture = {
+ ...persisted.value,
+ title: '重新生成的脚本',
+ segments: [{
+ ...persisted.value.segments[0]!,
+ narration: '重新生成后忠实解释核心概念'
+ }]
+ };
+ const regeneratedJob: CreatorJob = {
+ ...persisted.job,
+ revision: persisted.job.revision + 1,
+ artifacts: [{ ...persisted.artifact, status: 'stale' }, regeneratedArtifact],
+ state: {
+ ...persisted.job.state,
+ currentStage: 'script',
+ needsInput: {
+ code: 'creator_review_required',
+ kind: 'approve-script',
+ message: '请审核脚本后继续',
+ artifactId: regeneratedArtifact.id
+ }
+ }
+ };
+ const applyAction = vi.fn(async () => ({
+ job: regeneratedJob,
+ receipt: {
+ actor: 'user' as const,
+ action: 'run-stage',
+ summary: 'run-stage',
+ affectedArtifacts: [],
+ newRevision: regeneratedJob.revision,
+ createdAt: regeneratedJob.updatedAt
+ }
+ }));
+ const contents = new Map(persisted.contents);
+ contents.set(regeneratedArtifact.id, regeneratedValue);
+ renderWorkspace(persisted.job, contents, applyAction, configuredTtsService());
+
+ await screen.findByRole('textbox', { name: '第 1 段旁白' });
+ fireEvent.click(screen.getByRole('button', { name: '上一步' }));
+ fireEvent.click(await screen.findByRole('button', { name: '重新生成' }));
+
+ await waitFor(() => expect(screen.getByRole('textbox', { name: '脚本标题' }))
+ .toHaveValue('重新生成的脚本'));
+ expect(screen.getByRole('textbox', { name: '第 1 段旁白' }))
+ .toHaveValue('重新生成后忠实解释核心概念');
+ expect(within(screen.getByRole('navigation', { name: '火柴人视频制作步骤' }))
+ .getByRole('button', { name: /脚本审核/ })).toHaveAttribute('aria-current', 'step');
+ });
+
+ it('asks to regenerate an outdated script instead of rendering empty descriptions', async () => {
+ const persisted = scriptReviewJob();
+ const legacyValue = {
+ ...persisted.value,
+ contract: 'stickman-shot-script-v1',
+ segments: persisted.value.segments.map(segment => ({
+ ...segment,
+ visualIntent: '旧画面意图',
+ imagePrompt: '旧生图描述',
+ timingReview: 'short'
+ }))
+ };
+ renderWorkspace(
+ persisted.job,
+ new Map<string, unknown>([[persisted.artifact.id, legacyValue]])
+ );
+
+ expect(await screen.findByRole('alert')).toHaveTextContent(
+ '当前脚本结构已更新,请返回来源与角色重新生成'
+ );
+ expect(screen.queryByRole('textbox', { name: '第 1 段画面描述' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '下一步' })).toBeDisabled();
+ });
+
+ it('renders a full-width inline script editor and keeps draft changes when going back', async () => {
+ const persisted = scriptReviewJob();
+ const { container } = renderWorkspace(persisted.job, persisted.contents);
+
+ const title = await screen.findByRole('textbox', { name: '脚本标题' });
+ const narration = screen.getByRole('textbox', { name: '第 1 段旁白' });
+ expect(title).toHaveValue('测试脚本');
+ expect(narration).toHaveValue('解释核心概念');
+ expect(screen.queryByRole('textbox', { name: '第 1 段画面描述' })).not.toBeInTheDocument();
+ expect(container.querySelector('.stickman-step-scroll')).toHaveAttribute('data-step', '1');
+ expect(container.querySelector('.stickman-script-row .stickman-script-fields')).not.toBeNull();
+ expect(container.querySelector('.stickman-script-panel > .stickman-script-editor')).not.toBeNull();
+ expect(screen.queryByLabelText('任务摘要')).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '编辑脚本' })).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: '审核通过' })).not.toBeInTheDocument();
+
+ const scriptScroll = container.querySelector<HTMLElement>('.stickman-step-scroll');
+ expect(scriptScroll).not.toBeNull();
+ scriptScroll!.scrollTop = 240;
+ fireEvent.change(narration, { target: { value: '直接修改后的旁白' } });
+ expect(screen.getByText('有未保存修改')).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '上一步' }));
+ const sourceScroll = container.querySelector<HTMLElement>('.stickman-step-scroll');
+ expect(sourceScroll).not.toBe(scriptScroll);
+ expect(sourceScroll?.scrollTop).toBe(0);
+ expect(screen.getByRole('button', { name: '重新生成' })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '下一步' }));
+ expect(screen.getByRole('textbox', { name: '第 1 段旁白' })).toHaveValue('直接修改后的旁白');
+ });
+
+ it('saves an edited script before advancing with the new artifact and revision', async () => {
+ const persisted = scriptReviewJob();
+ const editedArtifact = { ...artifact('script-edited', 'script_manifest'), version: 2 };
+ const editedValue = {
+ ...persisted.value,
+ segments: [{ ...persisted.value.segments[0]!, narration: '修改后继续下一步' }]
+ };
+ const editedJob: CreatorJob = {
+ ...persisted.job,
+ revision: 8,
+ artifacts: [
+ { ...persisted.artifact, status: 'stale' },
+ editedArtifact
+ ],
+ state: {
+ ...persisted.job.state,
+ needsInput: {
+ code: 'creator_review_required',
+ kind: 'approve-script',
+ artifactId: editedArtifact.id
+ }
+ }
+ };
+ const approvedJob: CreatorJob = {
+ ...editedJob,
+ revision: 9,
+ status: 'running',
+ state: {
+ ...editedJob.state,
+ currentStage: 'narration',
+ workflowTarget: 'audio_ready',
+ approvedScriptArtifactId: editedArtifact.id,
+ needsInput: null
+ }
+ };
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => ({
+ job: request.action === 'edit-script' ? editedJob : approvedJob,
+ receipt: {
+ actor: 'user' as const,
+ action: String(request.action),
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: request.action === 'edit-script' ? 8 : 9,
+ createdAt: persisted.job.updatedAt
+ }
+ }));
+ const contents = new Map(persisted.contents);
+ contents.set(editedArtifact.id, editedValue);
+ renderWorkspace(persisted.job, contents, applyAction);
+
+ const narration = await screen.findByRole('textbox', { name: '第 1 段旁白' });
+ fireEvent.change(narration, { target: { value: '修改后继续下一步' } });
+ fireEvent.click(screen.getByRole('button', { name: '下一步' }));
+
+ await waitFor(() => expect(applyAction).toHaveBeenCalledTimes(1));
+ expect(applyAction.mock.calls[0]?.[1]).toMatchObject({
+ action: 'edit-script',
+ expectedRevision: 7,
+ input: { artifactId: persisted.artifact.id }
+ });
+ const savedContent = JSON.parse(String((applyAction.mock.calls[0]?.[1].input as Record<string, unknown>).content));
+ expect(savedContent.segments[0].narration).toBe('修改后继续下一步');
+ expect(screen.getByText(/请检查修改后的最终脚本/)).toBeInTheDocument();
+ });
+
+ it('advances with the current script without creating a redundant edit', async () => {
+ const persisted = scriptReviewJob();
+ const applyAction = vi.fn(async (_jobId?: string, _request?: Record<string, unknown>) => ({
+ job: {
+ ...persisted.job,
+ revision: 8,
+ status: 'running' as const,
+ state: {
+ ...persisted.job.state,
+ currentStage: 'narration',
+ workflowTarget: 'audio_ready',
+ approvedScriptArtifactId: persisted.artifact.id,
+ needsInput: null
+ }
+ },
+ receipt: {
+ actor: 'user' as const,
+ action: 'approve-script',
+ summary: 'approve-script',
+ affectedArtifacts: [],
+ newRevision: 8,
+ createdAt: persisted.job.updatedAt
+ }
+ }));
+ renderWorkspace(persisted.job, persisted.contents, applyAction);
+
+ await screen.findByRole('textbox', { name: '脚本标题' });
+ fireEvent.click(screen.getByRole('button', { name: '下一步' }));
+
+ await waitFor(() => expect(applyAction).toHaveBeenCalledTimes(1));
+ expect(applyAction.mock.calls[0]?.[1]).toMatchObject({
+ action: 'approve-script',
+ expectedRevision: 7,
+ input: { artifactId: persisted.artifact.id, revision: 7 }
+ });
+ expect(screen.getByRole('heading', { name: '配音与节奏' })).toBeInTheDocument();
+ });
+
+ it('shows playable narration timing and only starts visuals after the next action', async () => {
+ const persisted = audioReadyJob();
+ const continuedJob: CreatorJob = {
+ ...persisted.job,
+ revision: persisted.job.revision + 1,
+ state: {
+ ...persisted.job.state,
+ workflowTarget: 'visuals_ready',
+ currentStage: 'storyboard'
+ }
+ };
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => ({
+ job: continuedJob,
+ receipt: {
+ actor: 'user' as const,
+ action: String(request.action),
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: continuedJob.revision,
+ createdAt: continuedJob.updatedAt
+ }
+ }));
+ const { container } = renderWorkspace(persisted.job, persisted.contents, applyAction);
+
+ expect(await screen.findByRole('heading', { name: '配音与节奏' })).toBeInTheDocument();
+ expect(screen.getByText('1 段旁白 · 实际 5s · 目标 5s')).toBeInTheDocument();
+ expect(container.querySelector('.stickman-audio-control audio'))
+ .toHaveAttribute('src', 'blob:stickman-artifact');
+ fireEvent.click(screen.getByRole('button', { name: '下一步' }));
+
+ await waitFor(() => expect(applyAction).toHaveBeenCalledWith(
+ persisted.job.id,
+ expect.objectContaining({
+ action: 'continue-after-audio',
+ input: { artifactId: 'audio-timing', revision: persisted.job.revision }
+ })
+ ));
+ expect(within(screen.getByRole('navigation', { name: '火柴人视频制作步骤' }))
+ .getByRole('button', { name: /分镜与画面/ })).toHaveAttribute('aria-current', 'step');
+ const placeholder = container.querySelector('.stickman-storyboard-placeholder');
+ expect(placeholder).not.toBeNull();
+ expect(within(placeholder as HTMLElement).getByText('正在规划 1 个镜头的画面描述'))
+ .toBeInTheDocument();
+ expect(within(placeholder as HTMLElement).getAllByText('解释核心概念')).toHaveLength(1);
+ expect(placeholder?.querySelectorAll('.stickman-storyboard-loading-row')).toHaveLength(1);
+ expect(placeholder?.querySelectorAll('.stickman-storyboard-placeholder-image')).toHaveLength(1);
+ expect(placeholder?.querySelectorAll('.stickman-storyboard-description-skeleton')).toHaveLength(1);
+ expect(screen.getByRole('button', { name: '上一步' })).toBeVisible();
+ expect(screen.getByRole('button', { name: '下一步' })).toBeDisabled();
+ });
+
+ it('retries only audio timing after a measurement failure without discarding narration', async () => {
+ const persisted = audioReadyJob();
+ const failedTiming = stage('audio-timing', 'failed');
+ const failedJob: CreatorJob = {
+ ...persisted.job,
+ status: 'failed',
+ stages: [
+ ...persisted.job.stages.filter(item => item.stageId !== 'audio-timing'),
+ failedTiming
+ ],
+ artifacts: persisted.job.artifacts.filter(artifact => artifact.kind !== 'audio_timing'),
+ state: {
+ ...persisted.job.state,
+ workflowTarget: 'audio_ready',
+ currentStage: 'audio-timing'
+ }
+ };
+ const contents = new Map(persisted.contents);
+ contents.delete('audio-timing');
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => ({
+ job: failedJob,
+ receipt: {
+ actor: 'user' as const,
+ action: String(request.action),
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: failedJob.revision,
+ createdAt: failedJob.updatedAt
+ }
+ }));
+ renderWorkspace(failedJob, contents, applyAction);
+
+ expect(await screen.findByRole('heading', { name: '配音与节奏' })).toBeInTheDocument();
+ expect(screen.getByText('解释核心概念')).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '重新测量时长' }));
+
+ await waitFor(() => expect(applyAction).toHaveBeenCalledWith(
+ failedJob.id,
+ expect.objectContaining({
+ action: 'retry-stage',
+ input: { stageId: 'audio-timing' }
+ })
+ ));
+ });
+
+ it('renders storyboard and result versions from persisted artifact content after mount', async () => {
+ const persisted = completedJob();
+ const { container } = renderWorkspace(persisted.job, persisted.contents);
+
+ const steps = screen.getByRole('navigation', { name: '火柴人视频制作步骤' });
+ expect(within(steps).getByRole('button', { name: /来源与角色/ }).closest('li')).toHaveAttribute('data-completed', 'true');
+ expect(within(steps).getByRole('button', { name: /成片交付/ })).toHaveAttribute('aria-current', 'step');
+
+ fireEvent.click(screen.getByRole('button', { name: /分镜与画面/ }));
+ expect(await screen.findByText('白底黑线火柴人讲解核心概念')).toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: /成片交付/ }));
+ expect(await screen.findByRole('heading', { name: '成片交付' })).toBeInTheDocument();
+ expect(screen.getByText('项目 V1')).toBeInTheDocument();
+ const delivery = container.querySelector('.stickman-delivery-content');
+ expect(delivery).not.toBeNull();
+ expect(within(delivery as HTMLElement).getByText('火柴人动画')).toBeInTheDocument();
+ expect(within(delivery as HTMLElement).getByText('旁白字幕')).toBeInTheDocument();
+ expect(screen.queryByLabelText('任务摘要')).not.toBeInTheDocument();
+ expect(container.querySelector('.stickman-delivery-step > footer')).not.toBeNull();
+ expect(screen.getByRole('button', { name: '上一步' })).toBeVisible();
+ expect(screen.queryByRole('button', { name: '完成' })).not.toBeInTheDocument();
+ });
+
+ it('scrolls only storyboard content and keeps back and next actions visible', async () => {
+ const persisted = completedJob({ withSnapshot: false });
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => ({
+ job: persisted.job,
+ receipt: {
+ actor: 'user' as const,
+ action: String(request.action),
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: persisted.job.revision,
+ createdAt: persisted.job.updatedAt
+ }
+ }));
+ const { container } = renderWorkspace(persisted.job, persisted.contents, applyAction);
+
+ expect(await screen.findByText('白底黑线火柴人讲解核心概念')).toBeInTheDocument();
+ expect(container.querySelector('.stickman-step-scroll')).toHaveAttribute('data-step', '3');
+ expect(container.querySelector('.stickman-storyboard-review > .stickman-storyboard-editor')).not.toBeNull();
+ expect(container.querySelector('.stickman-storyboard-step > .stickman-storyboard-step-actions')).not.toBeNull();
+ expect(screen.getByRole('button', { name: '上一步' })).toBeVisible();
+ expect(screen.getByRole('button', { name: '下一步' })).toBeEnabled();
+ expect(screen.queryByText('审核分镜并生成画面')).not.toBeInTheDocument();
+ expect(screen.queryByText('确认画面并继续成片')).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: '下一步' }));
+ expect(await screen.findByRole('heading', { name: '动画合成' })).toBeInTheDocument();
+ await waitFor(() => expect(applyAction).toHaveBeenCalledWith(
+ persisted.job.id,
+ expect.objectContaining({
+ action: 'continue-after-visuals',
+ input: { artifactId: 'validation', revision: persisted.job.revision }
+ })
+ ));
+ });
+
+ it('continues all missing visuals with one action and keeps waiting shots passive', async () => {
+ const persisted = partialStoryboardJob('idle');
+ let releaseAction!: () => void;
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => {
+ await new Promise<void>(resolve => {
+ releaseAction = resolve;
+ });
+ return {
+ job: persisted.job,
+ receipt: {
+ actor: 'user' as const,
+ action: String(request.action),
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: persisted.job.revision,
+ createdAt: persisted.job.updatedAt
+ }
+ };
+ });
+ renderWorkspace(persisted.job, persisted.contents, applyAction);
+
+ const batch = await screen.findByRole('button', { name: '继续生成剩余 2 个' });
+ const waitingRow = screen.getByRole('textbox', { name: '第 3 个镜头画面描述' })
+ .closest('.stickman-storyboard-row') as HTMLElement;
+ expect(within(waitingRow).getByText('等待生成')).toBeInTheDocument();
+ expect(within(waitingRow).queryByRole('button', { name: '重新生成' })).not.toBeInTheDocument();
+
+ fireEvent.click(batch);
+
+ expect(screen.getByRole('button', { name: '正在准备续跑...' })).toBeDisabled();
+ await waitFor(() => expect(applyAction).toHaveBeenCalledTimes(1));
+ expect(applyAction).toHaveBeenCalledWith(
+ persisted.job.id,
+ expect.objectContaining({
+ action: 'generate-missing-shots',
+ expectedRevision: persisted.job.revision,
+ input: { revision: persisted.job.revision }
+ })
+ );
+ await act(async () => releaseAction());
+ });
+
+ it('summarizes failed and active visual generation in the fixed action bar', async () => {
+ const failed = partialStoryboardJob('failed');
+ const rendered = renderWorkspace(failed.job, failed.contents);
+
+ expect(await screen.findByRole('button', { name: '重试失败并继续(1 个失败)' })).toBeEnabled();
+ const failedRow = screen.getByRole('textbox', { name: '第 2 个镜头画面描述' })
+ .closest('.stickman-storyboard-row') as HTMLElement;
+ expect(within(failedRow).getByRole('button', { name: '单独重试' })).toBeEnabled();
+
+ rendered.unmount();
+ const running = partialStoryboardJob('running');
+ renderWorkspace(running.job, running.contents);
+
+ expect(await screen.findByRole('button', { name: '正在生成 1/3' })).toBeDisabled();
+ });
+
+ it('shows distinct actions while visual validation is failed, running, and completed', async () => {
+ const persisted = completedJob({ withSnapshot: false });
+ const withoutValidation = persisted.job.artifacts.filter(artifact => (
+ artifact.kind !== 'visual_validation'
+ ));
+ const failedJob: CreatorJob = {
+ ...persisted.job,
+ status: 'failed',
+ artifacts: withoutValidation,
+ stages: persisted.job.stages.map(current => current.stageId === 'visual-validation'
+ ? {
+ ...current,
+ status: 'failed',
+ errorCode: 'creator_shot_image_ambiguous',
+ errorMessage: 'Shot shot-03 requires exactly one current image'
+ }
+ : current)
+ };
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => ({
+ job: { ...failedJob, status: 'running' as const, revision: failedJob.revision + 1 },
+ receipt: {
+ actor: 'user' as const,
+ action: String(request.action),
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: failedJob.revision + 1,
+ createdAt: failedJob.updatedAt
+ }
+ }));
+ const failed = renderWorkspace(failedJob, persisted.contents, applyAction);
+
+ fireEvent.click(await screen.findByRole('button', { name: '重新检查画面' }));
+ await waitFor(() => expect(applyAction).toHaveBeenCalledTimes(1));
+ expect(applyAction).toHaveBeenCalledWith(
+ failedJob.id,
+ expect.objectContaining({ action: 'generate-missing-shots' })
+ );
+
+ failed.unmount();
+ const runningJob: CreatorJob = {
+ ...failedJob,
+ status: 'running',
+ stages: failedJob.stages.map(current => current.stageId === 'visual-validation'
+ ? { ...current, status: 'running', errorCode: null, errorMessage: null }
+ : current)
+ };
+ const running = renderWorkspace(runningJob, persisted.contents);
+ expect(await screen.findByRole('button', { name: '正在检查画面...' })).toBeDisabled();
+
+ running.unmount();
+ renderWorkspace(persisted.job, persisted.contents);
+ await waitFor(() => expect(screen.getByRole('button', { name: '下一步' })).toBeEnabled());
+ });
+
+ it('restores an in-progress render to the animation step without opening delivery', async () => {
+ const persisted = completedJob({ withSnapshot: false });
+ const renderingJob: CreatorJob = {
+ ...persisted.job,
+ stages: [
+ ...persisted.job.stages,
+ stage('timeline', 'succeeded'),
+ stage('render-clean', 'running')
+ ],
+ state: {
+ ...persisted.job.state,
+ workflowTarget: 'delivery_ready',
+ currentStage: 'render-clean'
+ }
+ };
+ const { container } = renderWorkspace(renderingJob, persisted.contents);
+
+ expect(await screen.findByRole('heading', { name: '动画合成' })).toBeInTheDocument();
+ expect(container.querySelector('.stickman-step-scroll')).toHaveAttribute('data-step', '4');
+ expect(container.querySelector('.stickman-composition-content')).not.toBeNull();
+ expect(container.querySelector('.stickman-composition-step > footer')).not.toBeNull();
+ expect(container.querySelector('.stickman-composition-step video')).toBeNull();
+ expect(screen.queryByRole('button', { name: '查看成片' })).not.toBeInTheDocument();
+ expect(screen.queryByRole('heading', { name: '成片交付' })).not.toBeInTheDocument();
+ });
+
+ it('opens the single delivery result when composition produces a snapshot', async () => {
+ const rendering = completedJob({ withSnapshot: false });
+ const completed = completedJob();
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => ({
+ job: completed.job,
+ receipt: {
+ actor: 'user' as const,
+ action: String(request.action),
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: completed.job.revision,
+ createdAt: completed.job.updatedAt
+ }
+ }));
+ const { container } = renderWorkspace(rendering.job, rendering.contents, applyAction);
+
+ expect(await screen.findByText('白底黑线火柴人讲解核心概念')).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '下一步' }));
+
+ expect(await screen.findByRole('heading', { name: '成片交付' })).toBeInTheDocument();
+ expect(container.querySelector('.stickman-delivery-preview video')).not.toBeNull();
+
+ fireEvent.click(screen.getByRole('button', { name: '上一步' }));
+ expect(await screen.findByRole('heading', { name: '动画合成' })).toBeInTheDocument();
+ expect(container.querySelector('.stickman-composition-step video')).toBeNull();
+ expect(screen.queryByRole('heading', { name: '成片交付' })).not.toBeInTheDocument();
+ });
+
+ it('edits visual descriptions and motion directly in each storyboard row', async () => {
+ const persisted = completedJob({ withSnapshot: false });
+ const applyAction = vi.fn(async (_jobId: string, request: Record<string, unknown>) => ({
+ job: { ...persisted.job, revision: persisted.job.revision + 1 },
+ receipt: {
+ actor: 'user',
+ action: request.action,
+ summary: String(request.action),
+ affectedArtifacts: [],
+ newRevision: persisted.job.revision + 1,
+ createdAt: persisted.job.updatedAt
+ }
+ }));
+ renderWorkspace(persisted.job, persisted.contents, applyAction);
+
+ const description = await screen.findByRole('textbox', { name: '第 1 个镜头画面描述' });
+ expect(description).toHaveValue('白底黑线火柴人讲解核心概念');
+ expect(screen.getByText('旁白(来自脚本)')).toBeInTheDocument();
+ expect(screen.getByRole('combobox', { name: '第 1 个镜头运动' })).toHaveValue('push-in');
+ expect(screen.queryByRole('dialog', { name: '编辑镜头' })).not.toBeInTheDocument();
+
+ fireEvent.change(description, {
+ target: { value: '新的镜头提示词' }
+ });
+ expect(screen.getByRole('button', { name: '重新生成' })).toBeDisabled();
+ fireEvent.click(screen.getByRole('button', { name: '保存修改' }));
+
+ await waitFor(() => expect(applyAction).toHaveBeenCalledWith(
+ persisted.job.id,
+ expect.objectContaining({
+ action: 'edit-shot',
+ expectedRevision: persisted.job.revision,
+ input: expect.objectContaining({
+ scopeKey: 'shot-01',
+ revision: persisted.job.revision,
+ patch: expect.objectContaining({ visualDescription: '新的镜头提示词' })
+ })
+ })
+ ));
+ });
+
+ it('shows immediate feedback and then runtime progress while regenerating one shot', async () => {
+ const persisted = completedJob({ withSnapshot: false });
+ const runningStage: CreatorStageRun = {
+ ...stage('images', 'running', 'shot-01'),
+ id: 'images-shot-01-retry',
+ progress: { phase: 'submitting', percent: 42, completed: 0, failed: 0, total: 1 }
+ };
+ const runningJob: CreatorJob = {
+ ...persisted.job,
+ revision: persisted.job.revision + 1,
+ status: 'running',
+ stages: [...persisted.job.stages, runningStage],
+ artifacts: persisted.job.artifacts.map(artifact => artifact.kind === 'shot_image'
+ ? { ...artifact, status: 'stale' as const }
+ : artifact)
+ };
+ const response = {
+ job: runningJob,
+ receipt: {
+ actor: 'user' as const,
+ action: 'regenerate-shot',
+ summary: 'regenerate-shot',
+ affectedArtifacts: [],
+ newRevision: runningJob.revision,
+ createdAt: runningJob.updatedAt
+ }
+ };
+ let releaseAction!: () => void;
+ const applyAction = vi.fn(async () => {
+ await new Promise<void>(resolve => {
+ releaseAction = resolve;
+ });
+ return response;
+ });
+ const { container } = renderWorkspace(persisted.job, persisted.contents, applyAction);
+
+ const description = await screen.findByRole('textbox', { name: '第 1 个镜头画面描述' });
+ const row = description.closest('.stickman-storyboard-row') as HTMLElement;
+ fireEvent.click(within(row).getByRole('button', { name: '重新生成' }));
+
+ expect(within(row).queryByRole('button', { name: '重新生成中...' })).not.toBeInTheDocument();
+ expect(within(row).getByRole('status')).toHaveTextContent('请求已提交,等待生成');
+ expect(container.querySelector('.stickman-storyboard-image .creator-collaboration-spin')).not.toBeNull();
+
+ await waitFor(() => expect(applyAction).toHaveBeenCalledTimes(1));
+ await act(async () => releaseAction());
+ await waitFor(() => expect(applyAction).toHaveBeenCalledWith(
+ persisted.job.id,
+ expect.objectContaining({
+ action: 'regenerate-shot',
+ input: expect.objectContaining({
+ scopeKey: 'shot-01',
+ inputFingerprint: 'a'.repeat(64)
+ })
+ })
+ ));
+ await waitFor(() => expect(within(row).getByRole('status'))
+ .toHaveTextContent('正在生成画面 · 42%'));
+ expect(within(row).queryByRole('button', { name: '重新生成中...' })).not.toBeInTheDocument();
+ });
+});
+
+function renderWorkspace(
+ initialJob: CreatorJob,
+ contents = new Map<string, unknown>(),
+ applyAction = vi.fn(async (_jobId: string, _request: Record<string, unknown>) => ({
+ job: initialJob,
+ receipt: {
+ actor: 'user' as const,
+ action: 'noop',
+ summary: 'noop',
+ affectedArtifacts: [],
+ newRevision: initialJob.revision,
+ createdAt: initialJob.updatedAt
+ }
+ })),
+ creatorServicesService: ComponentProps<typeof StickmanVideoWorkspace>['creatorServicesService'] = null
+) {
+ return render(
+ <LanguageProvider initialPreference="zh-CN">
+ <CreatorSessionProvider
+ initialJob={initialJob}
+ service={{
+ applyAction,
+ runAgentTurn: vi.fn(),
+ openArtifact: vi.fn(async (_jobId: string, artifactId: string) => {
+ const value = contents.get(artifactId);
+ return value === undefined
+ ? new Response(new Blob(['media'], { type: 'application/octet-stream' }))
+ : new Response(JSON.stringify(value), { headers: { 'Content-Type': 'application/json' } });
+ })
+ } as never}
+ >
+ <StickmanVideoWorkspace
+ creatorServicesService={creatorServicesService}
+ creatorService={{
+ listVisualAssets: vi.fn(async () => ({ assets: visualAssetCatalog() })),
+ openVisualAssetPreview: vi.fn()
+ } as never}
+ onBack={vi.fn()}
+ />
+ </CreatorSessionProvider>
+ </LanguageProvider>
+ );
+}
+
+function configuredTtsService() {
+ const config = createDefaultCreatorServicesConfig();
+ return {
+ getConfig: vi.fn(async () => ({
+ config,
+ configuredCredentials: ['tts.openai.apiKey', 'image.openai.apiKey']
+ })),
+ getTtsVoices: vi.fn(async () => ({
+ provider: 'openai' as const,
+ model: config.tts.openai.model,
+ voices: [{
+ id: config.tts.openai.defaultVoiceId,
+ name: 'Marin',
+ provider: 'openai' as const,
+ kind: 'builtin' as const
+ }]
+ })),
+ previewTtsVoice: vi.fn()
+ } as never;
+}
+
+function job(input: {
+ status?: CreatorJob['status'];
+ stages?: CreatorStageRun[];
+ artifacts?: CreatorArtifact[];
+ state?: CreatorJob['state'];
+} = {}): CreatorJob {
+ return {
+ id: 'stickman-job-1',
+ projectId: 'project-1',
+ templateId: 'stickman-video',
+ templateVersion: 2,
+ status: input.status ?? 'draft',
+ revision: 7,
+ state: {
+ sourceType: 'url',
+ sourceUrl: 'https://www.youtube.com/watch?v=test',
+ sourceText: '',
+ characterAsset: { assetId: 'stickman.character.default', revision: 1 },
+ styleAsset: { assetId: 'stickman.style.paper-pencil', revision: 1 },
+ ratio: '16:9',
+ targetDurationSeconds: 30,
+ targetLanguage: 'zh-CN',
+ currentStage: null,
+ ...(input.state ?? {})
+ },
+ agentThreadId: null,
+ stages: input.stages ?? [],
+ artifacts: input.artifacts ?? [],
+ providerRequests: [],
+ activities: [],
+ createdAt: '2026-08-31T00:00:00.000Z',
+ updatedAt: '2026-08-31T00:00:07.000Z'
+ };
+}
+
+function visualAssetCatalog() {
+ const characters = [
+ ['default', '默认角色', 'Default'],
+ ['tech-guy', '科技男', 'Tech Guy'],
+ ['long-hair', '长发角色', 'Long Hair'],
+ ['short-hair', '短发角色', 'Short Hair'],
+ ['student', '学生角色', 'Student'],
+ ['manager', '经理', 'Manager'],
+ ['hiphop', '潮流角色', 'Street Style'],
+ ['elder', '长者', 'Elder'],
+ ['chef', '厨师', 'Chef'],
+ ['fitness', '健身角色', 'Fitness']
+ ].map(([id, zhCN, en]) => ({
+ id: `stickman.character.${id}`,
+ revision: 1,
+ templateId: 'stickman-video',
+ kind: 'character' as const,
+ source: 'builtin' as const,
+ status: 'ready' as const,
+ name: { zhCN: zhCN!, en: en! },
+ description: { zhCN: zhCN!, en: en! },
+ previewUrl: null,
+ referenceCount: 1,
+ recommended: id === 'default',
+ tags: []
+ }));
+ const styles = [
+ ['minimal-ink', '极简黑白线稿', 'Minimal black-and-white line art', 'none'],
+ ['paper-pencil', '纸面铅笔手绘', 'Pencil sketch on paper', 'paper'],
+ ['comic-storyboard', '漫画分镜线稿', 'Comic storyboard line art', 'screentone'],
+ ['whiteboard-marker', '白板讲解线稿', 'Whiteboard explainer line art', 'marker']
+ ].map(([id, zhCN, en, texture]) => ({
+ id: `stickman.style.${id}`,
+ revision: 1,
+ templateId: 'stickman-video',
+ kind: 'style' as const,
+ source: 'builtin' as const,
+ status: 'ready' as const,
+ name: { zhCN: zhCN!, en: en! },
+ description: { zhCN: `${zhCN}说明`, en: `${en} description` },
+ previewUrl: null,
+ referenceCount: 0,
+ recommended: id === 'paper-pencil',
+ tags: [],
+ styleAttributes: {
+ medium: { zhCN: '手绘线条', en: 'Hand-drawn lines' },
+ palette: { zhCN: '黑白灰', en: 'Monochrome' },
+ sceneDensity: { zhCN: '适中', en: 'Medium' },
+ swatch: {
+ background: '#ffffff',
+ foreground: '#171717',
+ accent: '#a3a3a3',
+ texture: texture as 'none' | 'paper' | 'screentone' | 'marker'
+ }
+ }
+ }));
+ return [...characters, ...styles];
+}
+
+function stage(stageId: string, status: CreatorStageRun['status'], scopeKey: string | null = null): CreatorStageRun {
+ return {
+ id: `${stageId}-${scopeKey ?? 'global'}`,
+ jobId: 'stickman-job-1',
+ stageId,
+ executor: stageId === 'images' ? 'stickman-image' : 'download',
+ status,
+ dispatchStatus: status === 'queued' || status === 'running' ? 'claimed' : 'finished',
+ claimOwner: status === 'running' ? 'scheduler' : null,
+ claimExpiresAt: null,
+ attempt: 1,
+ idempotencyKey: `${stageId}-key`,
+ scopeKey,
+ inputFingerprint: scopeKey === null ? null : 'a'.repeat(64),
+ progress: {},
+ errorCode: null,
+ errorMessage: null,
+ startedAt: '2026-08-31T00:00:01.000Z',
+ finishedAt: status === 'succeeded' ? '2026-08-31T00:00:02.000Z' : null
+ };
+}
+
+function artifact(id: string, kind: string, scopeKey: string | null = null): CreatorArtifact {
+ return {
+ id,
+ jobId: 'stickman-job-1',
+ kind,
+ version: 1,
+ status: 'completed',
+ path: `/tmp/${id}`,
+ scopeKey,
+ inputFingerprint: scopeKey === null ? null : 'a'.repeat(64),
+ sha256: id.padEnd(64, '0').slice(0, 64),
+ sourceArtifactIds: [],
+ metadata: { fileName: `${kind}.${kind.includes('video') ? 'mp4' : kind.includes('subtitle') ? 'srt' : 'json'}` },
+ createdAt: '2026-08-31T00:00:03.000Z'
+ };
+}
+
+function scriptReviewJob() {
+ const script = artifact('script', 'script_manifest');
+ const value: ScriptManifestFixture = {
+ contract: 'stickman-narration-script-v2',
+ reviewStatus: 'needs_review',
+ contentLocked: false,
+ title: '测试脚本',
+ language: 'zh-CN',
+ targetDurationSeconds: 5,
+ narrationBudget: { unit: 'characters', unitsPerMinute: 240, minUnits: 1, maxUnits: 100 },
+ segmentCount: 1,
+ totalNarrationUnits: 6,
+ estimatedTotalDurationSeconds: 1.5,
+ segments: [{
+ id: 'segment-01',
+ order: 1,
+ narration: '解释核心概念',
+ claimIds: ['claim-001'],
+ sourceSpanIds: ['source-001'],
+ narrationUnits: 6,
+ estimatedDurationSeconds: 1.5
+ }]
+ };
+ return {
+ artifact: script,
+ value,
+ job: job({
+ status: 'needs_input',
+ artifacts: [script],
+ state: {
+ currentStage: 'script',
+ needsInput: {
+ code: 'creator_review_required',
+ kind: 'approve-script',
+ message: '请审核脚本后继续',
+ artifactId: script.id
+ }
+ }
+ }),
+ contents: new Map<string, unknown>([[script.id, value]])
+ };
+}
+
+type ScriptManifestFixture = {
+ contract: 'stickman-narration-script-v2';
+ reviewStatus: 'needs_review' | 'approved';
+ contentLocked: boolean;
+ title: string;
+ language: string;
+ targetDurationSeconds: number;
+ narrationBudget: {
+ unit: 'characters' | 'words';
+ unitsPerMinute: number;
+ minUnits: number;
+ maxUnits: number;
+ };
+ segmentCount: number;
+ totalNarrationUnits: number;
+ estimatedTotalDurationSeconds: number;
+ segments: Array<{
+ id: string;
+ order: number;
+ narration: string;
+ claimIds: string[];
+ sourceSpanIds: string[];
+ narrationUnits: number;
+ estimatedDurationSeconds: number;
+ }>;
+};
+
+function audioReadyJob() {
+ const persisted = scriptReviewJob();
+ const narration = artifact('narration-01', 'narration_audio', 'segment-01');
+ const timing = artifact('audio-timing', 'audio_timing');
+ return {
+ job: job({
+ status: 'running',
+ stages: [stage('narration', 'succeeded', 'segment-01'), stage('audio-timing', 'succeeded')],
+ artifacts: [persisted.artifact, narration, timing],
+ state: {
+ ...persisted.job.state,
+ approvedScriptArtifactId: persisted.artifact.id,
+ workflowTarget: 'audio_ready',
+ currentStage: 'audio-timing',
+ needsInput: null,
+ voiceName: 'Marin'
+ }
+ }),
+ contents: new Map<string, unknown>([
+ ...persisted.contents,
+ [timing.id, {
+ scriptArtifactId: persisted.artifact.id,
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ segments: [{
+ segmentId: 'segment-01',
+ startSeconds: 0,
+ endSeconds: 5,
+ durationSeconds: 5,
+ audioArtifactId: narration.id,
+ audioSha256: 'a'.repeat(64)
+ }],
+ totalDurationSeconds: 5
+ }]
+ ])
+ };
+}
+
+function completedJob(options: { withSnapshot?: boolean } = {}) {
+ const script = artifact('script', 'script_manifest');
+ const narration = artifact('narration-01', 'narration_audio', 'segment-01');
+ const timing = artifact('audio-timing', 'audio_timing');
+ const shots = artifact('shots', 'shot_spec');
+ const shotImage = artifact('shot-image', 'shot_image', 'shot-01');
+ const validation = artifact('validation', 'visual_validation');
+ const deliveries = [
+ artifact('clean', 'clean_video'),
+ artifact('narration-srt', 'narration_subtitle'),
+ artifact('manifest', 'delivery_manifest')
+ ];
+ const withSnapshot = options.withSnapshot ?? true;
+ const state: CreatorJob['state'] = {
+ approvedScriptArtifactId: script.id,
+ workflowTarget: withSnapshot ? 'delivery_ready' : 'visuals_ready',
+ currentStage: withSnapshot ? 'package-validation' : 'visual-validation',
+ needsInput: null,
+ ...(withSnapshot ? {
+ resultSnapshots: [{
+ version: 1,
+ createdAt: '2026-08-31T00:00:06.000Z',
+ action: 'stage-succeeded',
+ stageId: 'package-validation',
+ description: '完成火柴人视频与旁白字幕交付',
+ artifactRefs: Object.fromEntries(deliveries.map(item => [item.kind, [item.id]])),
+ changedArtifactIds: deliveries.map(item => item.id),
+ staleArtifactIds: [],
+ state: {}
+ }]
+ } : {})
+ };
+ return {
+ job: job({
+ status: withSnapshot ? 'completed' : 'running',
+ stages: [
+ stage('narration', 'succeeded', 'segment-01'),
+ stage('audio-timing', 'succeeded'),
+ stage('images', 'succeeded', 'shot-01'),
+ stage('visual-validation', 'succeeded'),
+ ...(withSnapshot ? [stage('package-validation', 'succeeded')] : [])
+ ],
+ artifacts: [script, narration, timing, shots, shotImage, validation, ...deliveries],
+ state
+ }),
+ contents: new Map<string, unknown>([
+ [script.id, {
+ contract: 'stickman-narration-script-v2',
+ reviewStatus: 'approved',
+ contentLocked: true,
+ title: '测试脚本',
+ language: 'zh-CN',
+ targetDurationSeconds: 5,
+ narrationBudget: { unit: 'characters', unitsPerMinute: 240, minUnits: 1, maxUnits: 100 },
+ segmentCount: 1,
+ totalNarrationUnits: 6,
+ estimatedTotalDurationSeconds: 1.5,
+ segments: [{ id: 'segment-01', order: 1, narration: '解释核心概念', claimIds: ['claim-001'], sourceSpanIds: ['source-001'], narrationUnits: 6, estimatedDurationSeconds: 1.5 }]
+ }],
+ [timing.id, {
+ scriptArtifactId: script.id,
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ segments: [{ segmentId: 'segment-01', startSeconds: 0, endSeconds: 5, durationSeconds: 5, audioArtifactId: narration.id, audioSha256: 'a'.repeat(64) }],
+ totalDurationSeconds: 5
+ }],
+ [shots.id, {
+ scriptArtifactId: script.id,
+ audioTimingArtifactId: timing.id,
+ timingSource: 'ffprobe_cumulative_tts_duration',
+ shots: [{
+ id: 'shot-01',
+ sourceSegmentId: 'segment-01',
+ semanticAnchor: '解释核心概念的关系',
+ visualDescription: '白底黑线火柴人讲解核心概念',
+ compositionAndAction: '人物站在画面中央讲解核心概念',
+ keyObjects: ['白板'],
+ continuityReason: '',
+ motion: 'push-in',
+ motionReason: '聚焦人物正在解释的核心关系',
+ startSeconds: 0,
+ endSeconds: 5,
+ durationSeconds: 5
+ }]
+ }]
+ ])
+ };
+}
+
+function partialStoryboardJob(status: 'idle' | 'failed' | 'running') {
+ const persisted = completedJob({ withSnapshot: false });
+ const shotsArtifact = persisted.job.artifacts.find(artifact => artifact.kind === 'shot_spec')!;
+ const baseShotSpec = persisted.contents.get(shotsArtifact.id) as {
+ shots: Array<{
+ id: string;
+ visualDescription: string;
+ continuityReason: string;
+ [key: string]: unknown;
+ }>;
+ [key: string]: unknown;
+ };
+ const shots = [
+ baseShotSpec.shots[0]!,
+ {
+ ...baseShotSpec.shots[0]!,
+ id: 'shot-02',
+ visualDescription: '第二个镜头的画面描述',
+ continuityReason: '延续上一幅画面'
+ },
+ {
+ ...baseShotSpec.shots[0]!,
+ id: 'shot-03',
+ visualDescription: '第三个镜头的画面描述',
+ continuityReason: '延续上一幅画面'
+ }
+ ];
+ const imageStages = [stage('images', 'succeeded', 'shot-01')];
+ if (status !== 'idle') {
+ imageStages.push({
+ ...stage('images', status, 'shot-02'),
+ id: `images-shot-02-${status}`,
+ progress: status === 'running'
+ ? { phase: 'generating', percent: 42, completed: 0, failed: 0, total: 1 }
+ : {},
+ errorCode: status === 'failed' ? 'creator_stage_failed' : null,
+ errorMessage: status === 'failed' ? 'Image generation failed' : null
+ });
+ }
+ const contents = new Map(persisted.contents);
+ contents.set(shotsArtifact.id, { ...baseShotSpec, shots });
+ return {
+ job: {
+ ...persisted.job,
+ status: status === 'failed' ? 'needs_input' as const : 'running' as const,
+ stages: [
+ ...persisted.job.stages.filter(stage => (
+ stage.stageId !== 'images' && stage.stageId !== 'visual-validation'
+ )),
+ ...imageStages
+ ],
+ artifacts: persisted.job.artifacts.filter(artifact => artifact.kind !== 'visual_validation'),
+ state: {
+ ...persisted.job.state,
+ currentStage: 'images',
+ workflowTarget: 'visuals_ready',
+ ...(status === 'failed'
+ ? { needsInput: { code: 'creator_stage_failed', scopeKey: 'shot-02' } }
+ : { needsInput: null })
+ }
+ },
+ contents
+ };
+}
diff --git a/apps/web/src/features/dashboard/StickmanVideoWorkspace.tsx b/apps/web/src/features/dashboard/StickmanVideoWorkspace.tsx
index b35bdad5..c24126e2 100644
--- a/apps/web/src/features/dashboard/StickmanVideoWorkspace.tsx
+++ b/apps/web/src/features/dashboard/StickmanVideoWorkspace.tsx
@@ -1,1327 +1,2365 @@
-import { useEffect, useRef, useState } from 'react';
-import { createPortal } from 'react-dom';
+import {
+ readCreatorResultSnapshots,
+ type CreatorArtifact,
+ type CreatorJson,
+ type CreatorStageRun,
+ type CreatorTtsProvider,
+ type CreatorVisualAssetRef,
+ type CreatorVisualAssetSummary
+} from '@opencreator/protocol';
import {
ArrowLeft,
ArrowRight,
+ Captions,
Check,
+ Circle,
+ Clock3,
Download,
Eye,
+ FileAudio,
+ FileText,
FileVideo,
- ImagePlus,
- Info,
- Music2,
- PanelsTopLeft,
+ Film,
+ Image as ImageIcon,
+ Link2,
+ LoaderCircle,
PersonStanding,
- Play,
RefreshCw,
Settings2,
Sparkles,
- UploadCloud,
Volume2,
X
} from 'lucide-react';
-import CreatorToolShell from './CreatorToolShell.js';
-import CreatorResultVersionMenu from './CreatorResultVersionMenu.js';
-import CreatorTaskSummary from './CreatorTaskSummary.js';
+import { useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
+import { TtsVoicePicker } from '../../components/tts/TtsVoicePicker.js';
import { useLocalizedCopy } from '../../i18n/useLocalizedCopy.js';
-import { useAppLanguage } from '../../i18n/LanguageProvider.js';
-import { useOptionalCreatorSession } from './creator-session-store.js';
-
-const storyboardShots = [
- {
- titleZh: '建立场景',
- titleEn: 'Establish the scene',
- subtitleZh: '灵感来了,就别让它从手中溜走。',
- subtitleEn: 'When inspiration arrives, do not let it slip away.',
- visualZh: '角色站在城市天台,远景缓慢推进,风吹动围巾和手中的创意手稿。',
- visualEn: 'The character stands on a city rooftop as the wide shot slowly pushes in, with the wind moving the scarf and manuscript.',
- duration: '0-3s'
- },
- {
- titleZh: '冲突出现',
- titleEn: 'Conflict appears',
- subtitleZh: '风把手稿卷向城市上空。',
- subtitleEn: 'The wind carries the manuscript above the city.',
- visualZh: '一阵强风吹走角色手中的纸张,角色转身快速追赶,画面表现突然发生的动作。',
- visualEn: 'A strong gust carries the paper away, and the character turns to chase it as the action begins suddenly.',
- duration: '3-7s'
- },
- {
- titleZh: '动作高潮',
- titleEn: 'Action climax',
- subtitleZh: '再高的障碍,也拦不住这次追赶。',
- subtitleEn: 'No obstacle can stop this chase.',
- visualZh: '角色越过天台障碍,在空中伸手抓向纸张,使用有速度感的动态构图。',
- visualEn: 'The character clears a rooftop obstacle and reaches for the paper in midair, using a dynamic composition with a sense of speed.',
- duration: '7-12s'
- },
- {
- titleZh: '结尾定格',
- titleEn: 'Final freeze frame',
- subtitleZh: '抓住手稿,也抓住了最重要的想法。',
- subtitleEn: 'The manuscript is safe, along with the idea that matters most.',
- visualZh: '角色平稳落地并举起找回的手稿,镜头定格,结尾轻松而有成就感。',
- visualEn: 'The character lands safely and raises the recovered manuscript as the frame freezes on a relaxed, accomplished ending.',
- duration: '12-15s'
- }
-];
-const characterPromptZh = '黑色线条、白色圆形头部、红色围巾,动作灵活';
-const characterPromptEn = 'Black lines, a round white head, a red scarf, and agile movement';
-const generatedCharacterImages = {
- image: '/dashboard/characters/default.png'
-} as const;
-const storyZh = '一个火柴人在城市天台追逐被风吹走的创意手稿,最后成功抓住。';
-const storyEn = 'A stick figure chases a creative manuscript blown across a city rooftop and catches it at the last moment.';
-const characterPresets = [
- {
- id: 'default',
- nameZh: '默认角色',
- nameEn: 'Default',
- image: '/dashboard/characters/default.png'
- },
- {
- id: 'tech-guy',
- nameZh: '科技男',
- nameEn: 'Tech Guy',
- image: '/dashboard/characters/tech-guy.png'
- },
- {
- id: 'long-hair',
- nameZh: '长发角色',
- nameEn: 'Long Hair',
- image: '/dashboard/characters/long-hair.png'
- },
- {
- id: 'short-hair',
- nameZh: '短发角色',
- nameEn: 'Short Hair',
- image: '/dashboard/characters/short-hair.png'
- },
- {
- id: 'hiphop',
- nameZh: '嘻哈',
- nameEn: 'HipHop',
- image: '/dashboard/characters/hiphop.png'
- },
- {
- id: 'student',
- nameZh: '学生角色',
- nameEn: 'Student',
- image: '/dashboard/characters/student.png'
- },
- {
- id: 'elder',
- nameZh: '长者角色',
- nameEn: 'Elder',
- image: '/dashboard/characters/elder.png'
- },
- {
- id: 'manager',
- nameZh: '经理',
- nameEn: 'Manager',
- image: '/dashboard/characters/manager.png'
- },
- {
- id: 'chef',
- nameZh: '厨师',
- nameEn: 'Chef',
- image: '/dashboard/characters/chef.png'
- },
- {
- id: 'fitness',
- nameZh: '健身',
- nameEn: 'Fitness',
- image: '/dashboard/characters/fitness.png'
- }
-] as const;
+import type { CreatorServicesSettingsService } from '../../services/creator-services-service.js';
+import type { CreatorWebService } from '../../services/creator-service.js';
+import CreatorResultVersionMenu from './CreatorResultVersionMenu.js';
+import CreatorToolShell from './CreatorToolShell.js';
+import { useCreatorSession } from './creator-session-store.js';
+
+type ScriptManifest = {
+ contract: 'stickman-narration-script-v2';
+ reviewStatus: 'needs_review' | 'approved';
+ contentLocked: boolean;
+ title: string;
+ language: string;
+ targetDurationSeconds: number;
+ narrationBudget: {
+ unit: 'characters' | 'words';
+ unitsPerMinute: number;
+ minUnits: number;
+ maxUnits: number;
+ };
+ segmentCount: number;
+ totalNarrationUnits: number;
+ estimatedTotalDurationSeconds: number;
+ segments: Array<{
+ id: string;
+ order: number;
+ narration: string;
+ claimIds: string[];
+ sourceSpanIds: string[];
+ narrationUnits: number;
+ estimatedDurationSeconds: number;
+ }>;
+};
+
+type ShotSpec = {
+ scriptArtifactId: string;
+ audioTimingArtifactId: string;
+ timingSource: 'ffprobe_cumulative_tts_duration';
+ shots: Array<{
+ id: string;
+ sourceSegmentId: string;
+ semanticAnchor: string;
+ visualDescription: string;
+ compositionAndAction: string;
+ keyObjects: string[];
+ continuityReason: string;
+ motion: string;
+ motionReason: string;
+ startSeconds: number;
+ endSeconds: number;
+ durationSeconds: number;
+ }>;
+};
+
+type ScriptDraftState = {
+ artifactId: string;
+ baseline: string;
+ value: ScriptManifest;
+};
-type CharacterPresetId = typeof characterPresets[number]['id'];
-type StickmanStep = 0 | 1 | 2 | 3;
-type CharacterSource = 'preset' | 'generate' | 'upload';
-type StickmanResultTab = 'video' | 'storyboard' | 'character' | 'settings';
-type VoiceLanguage = 'auto' | 'zh-CN' | 'en-US';
-type VoiceTone = 'natural' | 'energetic' | 'calm';
-type StoryboardDialogState = { shotIndex: number; mode: 'view' | 'regenerate' };
-
-type StickmanResultVersion = {
- value: number;
- description: string;
- signature: string;
- characterSource: CharacterSource;
- selectedPresetId: CharacterPresetId | null;
- characterPrompt: string;
- characterFile: File | null;
- characterGenerated: boolean;
- story: string;
- ratio: '16:9' | '9:16' | '1:1';
- style: string;
- storyboardSubtitles: string[];
- storyboardImageVersions: number[];
- storyboardPromptOverrides: Array<string | null>;
- voiceover: boolean;
- voiceLanguage: VoiceLanguage;
- voiceTone: VoiceTone;
- backgroundMusic: File | null;
- backgroundMusicVolume: number;
+type AudioTiming = {
+ scriptArtifactId: string;
+ timingSource: 'ffprobe_cumulative_tts_duration';
+ segments: Array<{
+ segmentId: string;
+ startSeconds: number;
+ endSeconds: number;
+ durationSeconds: number;
+ audioArtifactId: string;
+ audioSha256: string;
+ }>;
+ totalDurationSeconds: number;
};
-export default function StickmanVideoWorkspace(props: { onBack(): void; promptHint?: string }) {
+type DeliveryManifest = {
+ packageStatus: 'technical-draft' | 'publishable';
+ blockingChecks?: string[];
+ files?: Array<{
+ name: string;
+ relativePath: string;
+ bytes: number;
+ mime: string;
+ sourceArtifactId: string;
+ }>;
+};
+
+type TtsConfigurationStatus = 'loading' | 'configured' | 'missing' | 'unavailable';
+type ImageConfigurationStatus = TtsConfigurationStatus | 'unsupported';
+type VisualAssetCatalogStatus = 'loading' | 'ready' | 'error' | 'unavailable';
+
+const defaultCharacterAsset: CreatorVisualAssetRef = {
+ assetId: 'stickman.character.default',
+ revision: 1
+};
+const defaultStyleAsset: CreatorVisualAssetRef = {
+ assetId: 'stickman.style.paper-pencil',
+ revision: 1
+};
+
+const targetDurationPresets = [30, 60, 300, 600] as const;
+
+const deliveryKinds = [
+ 'clean_video',
+ 'narration_subtitle'
+] as const;
+
+export default function StickmanVideoWorkspace(props: {
+ onBack(): void;
+ promptHint?: string;
+ creatorServicesService?: CreatorServicesSettingsService | null;
+ creatorService?: CreatorWebService | null;
+}) {
const l = useLocalizedCopy();
- const { language } = useAppLanguage();
- const session = useOptionalCreatorSession();
- const draftInitializedRef = useRef(false);
- const [characterMode, setCharacterMode] = useState<CharacterSource>('preset');
- const [characterSource, setCharacterSource] = useState<CharacterSource>('preset');
- const [selectedPresetId, setSelectedPresetId] = useState<CharacterPresetId | null>('default');
- const [characterPrompt, setCharacterPrompt] = useState(() => typeof session?.state.characterPrompt === 'string' ? session.state.characterPrompt : l(characterPromptZh, characterPromptEn));
- const [characterFile, setCharacterFile] = useState<File | null>(null);
- const [characterPreview, setCharacterPreview] = useState('');
- const [characterGenerated, setCharacterGenerated] = useState(false);
- const [story, setStory] = useState(() => typeof session?.state.topic === 'string' ? session.state.topic : l(storyZh, storyEn));
- const [ratio, setRatio] = useState<'16:9' | '9:16' | '1:1'>(() => session?.state.ratio === '9:16' || session?.state.ratio === '1:1' ? session.state.ratio : '16:9');
- const [style, setStyle] = useState(() => typeof session?.state.style === 'string' ? session.state.style : '手绘线稿');
- const [storyboardSubtitles, setStoryboardSubtitles] = useState(() => storyboardShots.map(shot => l(shot.subtitleZh, shot.subtitleEn)));
- const [storyboardImageVersions, setStoryboardImageVersions] = useState(() => storyboardShots.map(() => 0));
- const [storyboardPromptOverrides, setStoryboardPromptOverrides] = useState<Array<string | null>>(() => storyboardShots.map(() => null));
- const [voiceover, setVoiceover] = useState(true);
- const [voiceLanguage, setVoiceLanguage] = useState<VoiceLanguage>('auto');
- const [voiceTone, setVoiceTone] = useState<VoiceTone>('natural');
- const [backgroundMusic, setBackgroundMusic] = useState<File | null>(null);
- const [backgroundMusicVolume, setBackgroundMusicVolume] = useState(25);
- const [storyboardReady, setStoryboardReady] = useState(false);
- const [videoReady, setVideoReady] = useState(false);
+ const session = useCreatorSession();
+ const { job, state } = session;
+ const [activeStep, setActiveStep] = useState(0);
const [notice, setNotice] = useState('');
- const [currentStep, setCurrentStep] = useState<StickmanStep>(0);
- const [furthestStep, setFurthestStep] = useState<StickmanStep>(0);
- const [resultVersions, setResultVersions] = useState<StickmanResultVersion[]>([]);
- const [resultVersion, setResultVersion] = useState(0);
- const [resultTab, setResultTab] = useState<StickmanResultTab>('video');
- const [audioEditing, setAudioEditing] = useState(false);
- const [storyboardDialog, setStoryboardDialog] = useState<StoryboardDialogState | null>(null);
- const selectedPreset = characterPresets.find(preset => preset.id === selectedPresetId);
- const characterReady = characterSource === 'preset'
- ? selectedPreset !== undefined
- : characterSource === 'generate'
- ? characterGenerated
- : characterFile !== null;
- const steps = [l('选择角色', 'Choose character'), l('故事与分镜', 'Story and storyboard'), l('确认分镜', 'Review storyboard'), l('配音与音乐', 'Voice and music')];
- const currentSignature = createVersionSignature({
- characterSource,
- selectedPresetId,
- characterPrompt,
- characterFile,
- characterGenerated,
- story,
- ratio,
- style,
- storyboardSubtitles,
- storyboardImageVersions,
- storyboardPromptOverrides,
- voiceover,
- voiceLanguage,
- voiceTone,
- backgroundMusic,
- backgroundMusicVolume
- });
- const selectedResult = resultVersions.find(version => version.value === resultVersion);
- const nextVersion = resultVersions.reduce((highest, version) => Math.max(highest, version.value), 0) + 1;
- const hasSavedResults = resultVersions.length > 0;
- const hasPendingChanges = selectedResult !== undefined && selectedResult.signature !== currentSignature;
- const resultPreset = selectedResult?.selectedPresetId
- ? characterPresets.find(preset => preset.id === selectedResult.selectedPresetId)
- : undefined;
- const resultCharacterName = selectedResult?.characterSource === 'preset' && resultPreset
- ? l(resultPreset.nameZh, resultPreset.nameEn)
- : selectedResult?.characterSource === 'upload'
- ? selectedResult.characterFile?.name ?? l('上传角色', 'Uploaded character')
- : l('AI 生成角色', 'AI-generated character');
- const resultCharacterSource = selectedResult?.characterSource === 'preset'
- ? l('默认角色', 'Default character')
- : selectedResult?.characterSource === 'upload'
- ? l('上传图片', 'Uploaded image')
- : l('提示词生成', 'Prompt generated');
- const resultCharacterImage = resultPreset?.image
- ?? (selectedResult?.characterSource === 'upload' && selectedResult.characterFile === characterFile && characterPreview
- ? characterPreview
- : generatedCharacterImages.image);
- const taskCharacterName = characterSource === 'preset' && selectedPreset
- ? l(selectedPreset.nameZh, selectedPreset.nameEn)
- : characterSource === 'upload'
- ? characterFile?.name ?? l('上传角色', 'Uploaded character')
- : l('AI 生成角色', 'AI-generated character');
- const taskVoiceover = voiceover
- ? `${voiceLanguageLabel(voiceLanguage, l)} · ${voiceToneLabel(voiceTone, l)}`
- : l('关闭', 'Off');
- const taskBackgroundMusic = backgroundMusic
- ? `${backgroundMusic.name} · ${backgroundMusicVolume}%`
- : l('未添加', 'Not added');
- const resultVoiceover = selectedResult?.voiceover
- ? `${voiceLanguageLabel(selectedResult.voiceLanguage, l)} · ${voiceToneLabel(selectedResult.voiceTone, l)}`
- : l('关闭', 'Off');
- const resultBackgroundMusic = selectedResult?.backgroundMusic
- ? `${selectedResult.backgroundMusic.name} · ${selectedResult.backgroundMusicVolume}%`
- : l('未添加', 'Not added');
+ const [selectedVersion, setSelectedVersion] = useState(0);
+ const [controlPending, setControlPending] = useState<'canceling' | 'resuming'>();
+ const [ttsConfigurationStatus, setTtsConfigurationStatus] = useState<TtsConfigurationStatus>('loading');
+ const [imageConfigurationStatus, setImageConfigurationStatus] = useState<ImageConfigurationStatus>('loading');
+ const [scriptDraftState, setScriptDraftState] = useState<ScriptDraftState>();
+ const [scriptSubmitting, setScriptSubmitting] = useState(false);
+ const [transitionPending, setTransitionPending] = useState<'audio' | 'visuals'>();
+ const [savingShotId, setSavingShotId] = useState<string>();
+ const [regenerationRequests, setRegenerationRequests] = useState<Record<string, string | null>>({});
+ const [batchGenerationPending, setBatchGenerationPending] = useState(false);
+ const batchGenerationStageCount = useRef(0);
+ const [visualAssets, setVisualAssets] = useState<CreatorVisualAssetSummary[]>([]);
+ const [visualAssetPreviewUrls, setVisualAssetPreviewUrls] = useState<Record<string, string>>({});
+ const [visualAssetCatalogStatus, setVisualAssetCatalogStatus] = useState<VisualAssetCatalogStatus>('loading');
+
+ const scriptArtifact = latestCompleted(job.artifacts, 'script_manifest');
+ const scriptStage = latestStage(job.stages, 'script');
+ const audioTimingArtifact = latestCompleted(job.artifacts, 'audio_timing');
+ const shotSpecArtifact = latestCompleted(job.artifacts, 'shot_spec');
+ const visualValidationArtifact = latestCompleted(job.artifacts, 'visual_validation');
+ const rawScript = useArtifactJson<unknown>(scriptArtifact?.id);
+ const script = readScriptManifest(rawScript);
+ const scriptRequiresRegeneration = rawScript !== undefined && script === undefined;
+ const audioTiming = useArtifactJson<AudioTiming>(audioTimingArtifact?.id);
+ const shotSpec = useArtifactJson<ShotSpec>(shotSpecArtifact?.id);
+ const snapshots = readCreatorResultSnapshots(job.state.resultSnapshots);
+ const latestSnapshot = snapshots.at(-1);
+ const observedSnapshotVersion = useRef(latestSnapshot?.version);
+ const currentSnapshot = snapshots.find(snapshot => snapshot.version === selectedVersion)
+ ?? latestSnapshot;
+ const derivedStep = snapshots.length > 0
+ ? 5
+ : visualValidationArtifact !== undefined
+ ? 3
+ : audioTimingArtifact !== undefined
+ ? 2
+ : scriptArtifact !== undefined
+ ? 1
+ : 0;
+ const workflowStep = stickmanWorkflowStep(state.currentStage);
+ const workbenchStep = Math.max(derivedStep, workflowStep);
+ const activeStages = job.stages.filter(stage => stage.status === 'queued' || stage.status === 'running');
+ const isBusy = activeStages.length > 0;
+ const review = readNeedsInput(state.needsInput);
+ const characterAsset = readVisualAssetRef(state.characterAsset, defaultCharacterAsset);
+ const sourceType = state.sourceType === 'text' ? 'text' : 'url';
+ const sourceUrl = typeof state.sourceUrl === 'string' ? state.sourceUrl : '';
+ const sourceText = typeof state.sourceText === 'string' ? state.sourceText : '';
+ const styleAsset = readVisualAssetRef(state.styleAsset, defaultStyleAsset);
+ const targetDurationSeconds = typeof state.targetDurationSeconds === 'number'
+ ? state.targetDurationSeconds
+ : 30;
+ const ttsProvider = isTtsProvider(state.ttsProvider) ? state.ttsProvider : 'openai';
+ const ttsModel = typeof state.ttsModel === 'string' ? state.ttsModel : '';
+ const voiceCode = typeof state.voiceCode === 'string' ? state.voiceCode : '';
+ const voiceName = typeof state.voiceName === 'string' ? state.voiceName : voiceCode;
+ const targetLanguage = typeof state.targetLanguage === 'string' ? state.targetLanguage : 'zh-CN';
+ const scriptDraft = scriptArtifact !== undefined && scriptDraftState?.artifactId === scriptArtifact.id
+ ? scriptDraftState.value
+ : script;
+ const scriptDirty = scriptDraftState !== undefined
+ && scriptDraftState.artifactId === scriptArtifact?.id
+ && JSON.stringify(scriptDraftState.value) !== scriptDraftState.baseline;
+ const characterAssets = useMemo(
+ () => visualAssets.filter(asset => asset.kind === 'character' && asset.status === 'ready'),
+ [visualAssets]
+ );
+ const styleAssets = useMemo(
+ () => visualAssets.filter(asset => asset.kind === 'style' && asset.status === 'ready'),
+ [visualAssets]
+ );
useEffect(() => {
- setCharacterPrompt(current => current === characterPromptZh || current === characterPromptEn
- ? l(characterPromptZh, characterPromptEn)
- : current);
- setStory(current => current === storyZh || current === storyEn
- ? l(storyZh, storyEn)
- : current);
- setStoryboardSubtitles(current => current.map((subtitle, index) => {
- const shot = storyboardShots[index];
- if (!shot || (subtitle !== shot.subtitleZh && subtitle !== shot.subtitleEn)) return subtitle;
- return l(shot.subtitleZh, shot.subtitleEn);
- }));
- }, [l, language]);
+ let active = true;
+ const objectUrls: string[] = [];
+ const service = props.creatorService;
+ if (service === null || service === undefined) {
+ setVisualAssetCatalogStatus('unavailable');
+ return () => {
+ active = false;
+ };
+ }
+ setVisualAssetCatalogStatus('loading');
+ void service.listVisualAssets('stickman-video')
+ .then(async response => {
+ if (!active) return;
+ setVisualAssets(response.assets);
+ const previews = await Promise.all(response.assets.flatMap(asset => (
+ asset.previewUrl === null
+ ? []
+ : [service.openVisualAssetPreview(asset.id, asset.revision)
+ .then(async preview => {
+ const url = URL.createObjectURL(await preview.blob());
+ objectUrls.push(url);
+ return [assetRefKey(asset), url] as const;
+ })]
+ )));
+ if (!active) return;
+ setVisualAssetPreviewUrls(Object.fromEntries(previews));
+ setVisualAssetCatalogStatus('ready');
+ })
+ .catch(() => {
+ if (active) setVisualAssetCatalogStatus('error');
+ });
+ return () => {
+ active = false;
+ for (const url of objectUrls) URL.revokeObjectURL(url);
+ };
+ }, [job.id, props.creatorService]);
useEffect(() => {
- if (session === null) return;
- session.updateDraft({
- topic: story,
- characterPrompt,
- ratio,
- style,
- targetDurationSeconds: 30
- }, { persist: draftInitializedRef.current });
- draftInitializedRef.current = true;
- }, [characterPrompt, ratio, session?.updateDraft, story, style]);
+ let active = true;
+ const service = props.creatorServicesService;
+ if (service === null || service === undefined) {
+ setTtsConfigurationStatus('unavailable');
+ setImageConfigurationStatus('unavailable');
+ return () => {
+ active = false;
+ };
+ }
+ setTtsConfigurationStatus('loading');
+ void service.getConfig()
+ .then(response => {
+ if (!active) return;
+ const provider = response.config.tts.provider;
+ const providerConfig = provider === 'edge-tts'
+ ? null
+ : response.config.tts[provider];
+ const configured = provider === 'edge-tts'
+ || (providerConfig !== null && (
+ providerConfig.apiKey.trim().length > 0
+ || response.configuredCredentials.some(credential => credential === `tts.${provider}.apiKey`)
+ ));
+ setTtsConfigurationStatus(configured ? 'configured' : 'missing');
+ const imageProvider = response.config.image.provider;
+ if (imageProvider !== 'openai' && imageProvider !== 'gemini') {
+ setImageConfigurationStatus('unsupported');
+ } else {
+ const credential = imageProvider === 'openai'
+ ? 'image.openai.apiKey' as const
+ : 'image.gemini.apiKey' as const;
+ const imageConfigured = response.config.image[imageProvider].apiKey.trim().length > 0
+ || response.configuredCredentials.includes(credential);
+ setImageConfigurationStatus(imageConfigured ? 'configured' : 'missing');
+ }
+ if (scriptArtifact !== undefined) return;
+ session.updateDraft({
+ ttsProvider: provider,
+ ttsModel: providerConfig?.model ?? '',
+ voiceCode: configured ? providerConfig?.defaultVoiceId ?? '' : '',
+ voiceName: configured ? providerConfig?.defaultVoiceId ?? '' : ''
+ });
+ })
+ .catch(() => {
+ if (active) {
+ setTtsConfigurationStatus('unavailable');
+ setImageConfigurationStatus('unavailable');
+ }
+ });
+ return () => {
+ active = false;
+ };
+ }, [job.id, props.creatorServicesService, scriptArtifact?.id]);
+
+ useEffect(() => {
+ setActiveStep(current => (
+ current === 0 || current > workbenchStep ? workbenchStep : current
+ ));
+ }, [workbenchStep]);
useEffect(() => {
- if (!characterFile || typeof URL.createObjectURL !== 'function') {
- setCharacterPreview('');
- return undefined;
+ if (
+ review?.kind === 'approve-script'
+ && review.artifactId === scriptArtifact?.id
+ ) {
+ setActiveStep(1);
}
- const objectUrl = URL.createObjectURL(characterFile);
- setCharacterPreview(objectUrl);
- return () => URL.revokeObjectURL(objectUrl);
- }, [characterFile]);
-
- function generateCharacter() {
- if (!characterPrompt.trim()) {
- setNotice(l('请先描述角色形象', 'Describe the character first'));
- return false;
+ }, [review?.artifactId, review?.kind, scriptArtifact?.id]);
+
+ useEffect(() => {
+ const previousVersion = observedSnapshotVersion.current;
+ observedSnapshotVersion.current = latestSnapshot?.version;
+ if (latestSnapshot === undefined) return;
+ setSelectedVersion(latestSnapshot.version);
+ if (previousVersion !== latestSnapshot.version) {
+ setActiveStep(current => current === 4 ? 5 : current);
}
- setCharacterMode('generate');
- setCharacterSource('generate');
- setSelectedPresetId(null);
- setCharacterFile(null);
- setCharacterGenerated(true);
- setStoryboardReady(false);
- setVideoReady(false);
- setCurrentStep(0);
- setFurthestStep(hasSavedResults ? 3 : 0);
- setNotice(l('角色形象已生成,可以继续生成分镜', 'Character image generated. Continue to the storyboard.'));
- return true;
- }
+ }, [latestSnapshot?.version]);
- function selectPreset(id: CharacterPresetId) {
- setCharacterMode('preset');
- setCharacterSource('preset');
- setSelectedPresetId(id);
- setCharacterGenerated(false);
- setCharacterFile(null);
- setStoryboardReady(false);
- setVideoReady(false);
- setCurrentStep(0);
- setFurthestStep(hasSavedResults ? 3 : 0);
- const preset = characterPresets.find(item => item.id === id)!;
- setNotice(l(`已选择${preset.nameZh},可以继续生成分镜`, `${preset.nameEn} selected. Continue to the storyboard.`));
- }
+ useEffect(() => {
+ if (scriptArtifact === undefined || script === undefined) return;
+ setScriptDraftState(current => {
+ if (current?.artifactId === scriptArtifact.id) return current;
+ const value = cloneScriptManifest(script);
+ return {
+ artifactId: scriptArtifact.id,
+ baseline: JSON.stringify(value),
+ value
+ };
+ });
+ }, [script, scriptArtifact?.id]);
- function updateCharacterPrompt(value: string) {
- setCharacterPrompt(value);
- if (characterSource !== 'generate') return;
- setCharacterGenerated(false);
- setStoryboardReady(false);
- setVideoReady(false);
- setCurrentStep(0);
- setFurthestStep(hasSavedResults ? 3 : 0);
- }
+ useEffect(() => {
+ setRegenerationRequests(current => {
+ let changed = false;
+ const next = { ...current };
+ for (const [shotId, previousStageId] of Object.entries(current)) {
+ const latest = latestShotStage(job.stages, shotId);
+ if (latest !== undefined && latest.id !== previousStageId) {
+ delete next[shotId];
+ changed = true;
+ }
+ }
+ return changed ? next : current;
+ });
+ }, [job.stages]);
- function uploadCharacter(file: File | null) {
- if (!file) return;
- setCharacterFile(file);
- setCharacterMode('upload');
- setCharacterSource('upload');
- setSelectedPresetId(null);
- setCharacterGenerated(false);
- setStoryboardReady(false);
- setVideoReady(false);
- setCurrentStep(0);
- setFurthestStep(hasSavedResults ? 3 : 0);
- setNotice(l('角色图片已上传,可以继续生成分镜', 'Character image uploaded. Continue to the storyboard.'));
+ useEffect(() => {
+ if (!batchGenerationPending) return;
+ const continuationStarted = job.stages.length > batchGenerationStageCount.current
+ || job.stages.some(stage => (
+ (stage.status === 'queued' || stage.status === 'running')
+ && (stage.stageId === 'images' || stage.stageId === 'visual-validation')
+ ));
+ if (continuationStarted || visualValidationArtifact !== undefined) {
+ setBatchGenerationPending(false);
+ }
+ }, [batchGenerationPending, job.stages, visualValidationArtifact]);
+
+ useEffect(() => {
+ if (session.error?.code === 'creator_revision_conflict') {
+ setNotice(l('任务已被其他入口更新,已刷新到最新版本,请重新操作', 'The task changed elsewhere. The latest revision has been loaded; retry your action.'));
+ }
+ }, [l, session.error?.code]);
+
+ const currentVideo = artifactFromSnapshot(job.artifacts, currentSnapshot?.artifactRefs.clean_video);
+ const currentDeliveryManifest = artifactFromSnapshot(
+ job.artifacts,
+ currentSnapshot?.artifactRefs.delivery_manifest
+ );
+ const deliveryManifest = useArtifactJson<DeliveryManifest>(currentDeliveryManifest?.id);
+ const videoUrl = useArtifactUrl(currentVideo?.id);
+
+ async function apply(action: string, input: Record<string, unknown>) {
+ session.clearError();
+ setNotice('');
+ try {
+ await session.applyAction({ actor: 'user', action, input: input as never });
+ } catch (error) {
+ setNotice(error instanceof Error ? error.message : String(error));
+ }
}
- function generateStoryboard() {
- if (!characterReady) {
- setCurrentStep(0);
- setFurthestStep(0);
- setNotice(l('请先上传或生成角色形象', 'Upload or generate a character first'));
- return false;
+ function startWorkflow() {
+ if (visualAssetCatalogStatus === 'error' || visualAssetCatalogStatus === 'unavailable') {
+ setNotice(l(
+ '暂时无法读取人物与视觉风格目录,请检查 Runtime 后重试',
+ 'Could not load the character and visual style catalog. Check the Runtime and retry.'
+ ));
+ return;
}
- if (!story.trim()) {
- setNotice(l('请先填写故事创意', 'Enter a story idea first'));
- return false;
+ if (ttsConfigurationStatus !== 'configured') {
+ setNotice(ttsConfigurationStatus === 'unavailable'
+ ? l('暂时无法读取配音服务配置,请检查 Runtime 后重试', 'Could not read TTS settings. Check the Runtime and retry.')
+ : l('请先前往 AI 服务配置配音服务', 'Configure a TTS service in AI Services first.'));
+ return;
}
- if (session !== null) {
- void session.applyAction({ actor: 'user', action: 'run-stage', input: { stageId: 'storyboard' } });
+ if (imageConfigurationStatus !== 'configured') {
+ setNotice(imageConfigurationStatus === 'unsupported'
+ ? l('当前生图服务不支持角色参考图,请在 AI 服务中切换到 OpenAI 或 Gemini', 'The current image provider does not support character references. Switch to OpenAI or Gemini in AI Services.')
+ : imageConfigurationStatus === 'unavailable'
+ ? l('暂时无法读取生图服务配置,请检查 Runtime 后重试', 'Could not read image settings. Check the Runtime and retry.')
+ : l('请先前往 AI 服务配置生图服务', 'Configure an image provider in AI Services first.'));
+ return;
}
- setCurrentStep(2);
- setFurthestStep(2);
- setStoryboardSubtitles(storyboardShots.map(shot => l(shot.subtitleZh, shot.subtitleEn)));
- setStoryboardImageVersions(storyboardShots.map(() => 0));
- setStoryboardPromptOverrides(storyboardShots.map(() => null));
- setStoryboardReady(true);
- setVideoReady(false);
- setNotice(l(`已生成 ${storyboardShots.length} 个关键分镜,请确认后生成视频`, `Generated ${storyboardShots.length} key storyboard shots. Review them before creating the video.`));
- return true;
+ if (sourceType === 'text') {
+ if (sourceText.trim().length === 0) {
+ setNotice(l('请输入要生成火柴人视频的文本内容', 'Enter the text to turn into a stickman video.'));
+ return;
+ }
+ void apply('run-stage', { stageId: 'ingest-text' });
+ return;
+ }
+ if (!isPublicYoutubeUrl(sourceUrl)) {
+ setNotice(l('请输入有效的公开 YouTube 链接', 'Enter a valid public YouTube URL.'));
+ return;
+ }
+ void apply('run-stage', { stageId: 'source-transcript' });
}
- function generateVideo() {
- if (!storyboardReady) {
- setCurrentStep(characterReady ? 1 : 0);
- setFurthestStep(hasSavedResults ? 3 : characterReady ? 1 : 0);
- setNotice(l('请先生成并确认分镜图', 'Generate and review the storyboard first'));
- return false;
+ function updateScriptDraft(value: ScriptManifest) {
+ if (scriptArtifact === undefined || script === undefined) return;
+ setScriptDraftState(current => {
+ if (current?.artifactId === scriptArtifact.id) return { ...current, value };
+ const baseline = cloneScriptManifest(script);
+ return {
+ artifactId: scriptArtifact.id,
+ baseline: JSON.stringify(baseline),
+ value
+ };
+ });
+ }
+
+ async function continueFromScript() {
+ if (scriptArtifact === undefined || scriptDraft === undefined || scriptSubmitting) return;
+ const normalized = normalizeScriptManifest(scriptDraft);
+ const validationError = validateScriptManifest(normalized, l);
+ if (validationError !== '') {
+ setNotice(validationError);
+ return;
}
- if (session !== null) {
- void session.applyAction({ actor: 'user', action: 'run-stage', input: { stageId: 'render' } });
+ session.clearError();
+ setNotice('');
+ setScriptSubmitting(true);
+ try {
+ let nextJob = job;
+ let nextArtifact = scriptArtifact;
+ if (scriptDirty) {
+ nextJob = await session.applyAction({
+ actor: 'user',
+ action: 'edit-script',
+ input: {
+ artifactId: scriptArtifact.id,
+ content: JSON.stringify(normalized)
+ }
+ });
+ const editedArtifact = latestCompleted(nextJob.artifacts, 'script_manifest');
+ if (editedArtifact === undefined) {
+ throw new Error(l('脚本已保存,但未找到新的脚本版本', 'The script was saved, but the new version could not be found.'));
+ }
+ nextArtifact = editedArtifact;
+ setScriptDraftState({
+ artifactId: editedArtifact.id,
+ baseline: JSON.stringify(normalized),
+ value: normalized
+ });
+ setNotice(l(
+ '脚本修改已保存,请检查修改后的最终脚本并再次点击下一步确认。',
+ 'Script changes were saved. Review the final script and click Next again to approve it.'
+ ));
+ return;
+ }
+ await session.applyAction({
+ actor: 'user',
+ action: 'approve-script',
+ input: { artifactId: nextArtifact.id, revision: nextJob.revision }
+ });
+ setActiveStep(2);
+ } catch (error) {
+ setNotice(error instanceof Error ? error.message : String(error));
+ } finally {
+ setScriptSubmitting(false);
}
- if (selectedResult?.signature === currentSignature) {
- setCurrentStep(3);
- setFurthestStep(3);
- setAudioEditing(false);
- setVideoReady(true);
- setNotice(l(`当前设置没有变化,继续查看 V${resultVersion}`, `Nothing changed. Continuing with V${resultVersion}.`));
- return true;
+ }
+
+ async function continueFromAudio() {
+ if (audioTimingArtifact === undefined || transitionPending !== undefined || isBusy) return;
+ session.clearError();
+ setNotice('');
+ setTransitionPending('audio');
+ try {
+ await session.applyAction({
+ actor: 'user',
+ action: 'continue-after-audio',
+ input: { artifactId: audioTimingArtifact.id, revision: job.revision }
+ });
+ setActiveStep(3);
+ } catch (error) {
+ setNotice(error instanceof Error ? error.message : String(error));
+ } finally {
+ setTransitionPending(undefined);
}
- const version = nextVersion;
- setResultVersions(current => [
- ...current,
- {
- value: version,
- description: version === 1
- ? l('初次生成', 'Initial generation')
- : l(`基于 V${resultVersion} 调整`, `Adjusted from V${resultVersion}`),
- signature: currentSignature,
- characterSource,
- selectedPresetId,
- characterPrompt,
- characterFile,
- characterGenerated,
- story,
- ratio,
- style,
- storyboardSubtitles,
- storyboardImageVersions,
- storyboardPromptOverrides,
- voiceover,
- voiceLanguage,
- voiceTone,
- backgroundMusic,
- backgroundMusicVolume
- }
- ]);
- setResultVersion(version);
- setResultTab('video');
- setCurrentStep(3);
- setFurthestStep(3);
- setAudioEditing(false);
- setVideoReady(true);
- setNotice(version === 1
- ? l('V1 已生成完成', 'V1 is ready.')
- : l(`V${version} 已生成完成,之前的版本仍可查看`, `V${version} is ready. Previous versions remain available.`));
- return true;
}
- function selectResultVersion(version: number) {
- const result = resultVersions.find(item => item.value === version);
- if (!result) return;
-
- setResultVersion(result.value);
- setResultTab('video');
- setCharacterSource(result.characterSource);
- setCharacterMode(result.characterSource);
- setSelectedPresetId(result.selectedPresetId);
- setCharacterPrompt(result.characterPrompt);
- setCharacterFile(result.characterFile);
- setCharacterGenerated(result.characterGenerated);
- setStory(result.story);
- setRatio(result.ratio);
- setStyle(result.style);
- setStoryboardSubtitles(result.storyboardSubtitles);
- setStoryboardImageVersions(result.storyboardImageVersions);
- setStoryboardPromptOverrides(result.storyboardPromptOverrides);
- setVoiceover(result.voiceover);
- setVoiceLanguage(result.voiceLanguage);
- setVoiceTone(result.voiceTone);
- setBackgroundMusic(result.backgroundMusic);
- setBackgroundMusicVolume(result.backgroundMusicVolume);
- setStoryboardReady(true);
- setVideoReady(true);
- setCurrentStep(3);
- setFurthestStep(3);
- setAudioEditing(false);
+ async function continueFromVisuals() {
+ if (visualValidationArtifact === undefined || transitionPending !== undefined || isBusy) return;
+ session.clearError();
setNotice('');
+ setTransitionPending('visuals');
+ try {
+ const nextJob = await session.applyAction({
+ actor: 'user',
+ action: 'continue-after-visuals',
+ input: { artifactId: visualValidationArtifact.id, revision: job.revision }
+ });
+ setActiveStep(readCreatorResultSnapshots(nextJob.state.resultSnapshots).length > 0 ? 5 : 4);
+ } catch (error) {
+ setNotice(error instanceof Error ? error.message : String(error));
+ } finally {
+ setTransitionPending(undefined);
+ }
}
- function updateStoryboardSubtitle(index: number, value: string) {
- setStoryboardSubtitles(current => current.map((subtitle, itemIndex) => itemIndex === index ? value : subtitle));
- setVideoReady(false);
+ function retryAudioStage(stage: CreatorStageRun) {
+ void apply('retry-stage', {
+ stageId: stage.stageId,
+ ...(stage.scopeKey === null ? {} : { scopeKey: stage.scopeKey })
+ });
}
- function regenerateStoryboardImage(index: number, prompt: string) {
- setStoryboardImageVersions(current => current.map((version, itemIndex) => itemIndex === index ? version + 1 : version));
- setStoryboardPromptOverrides(current => current.map((value, itemIndex) => itemIndex === index ? prompt.trim() : value));
- setVideoReady(false);
- setNotice(l(`分镜 ${index + 1} 的图片已重新生成`, `The image for shot ${index + 1} has been regenerated.`));
+ function retryRenderStage() {
+ const failed = [...job.stages].reverse().find(stage => (
+ stickmanWorkflowStep(stage.stageId) === 4 && stage.status === 'failed'
+ ));
+ if (failed === undefined) return;
+ void apply('retry-stage', {
+ stageId: failed.stageId,
+ ...(failed.scopeKey === null ? {} : { scopeKey: failed.scopeKey })
+ });
}
- function continueToStory() {
- if (!characterReady) {
- setNotice(l('请先选择、上传或生成一个角色', 'Choose, upload, or generate a character first'));
+ async function saveShot(shotId: string, visualDescription: string, motion: string) {
+ if (shotSpecArtifact === undefined || savingShotId !== undefined) return;
+ const description = visualDescription.trim();
+ if (description === '') {
+ setNotice(l('画面描述不能为空', 'Visual description cannot be empty.'));
return;
}
- setCurrentStep(1);
- setFurthestStep(current => Math.max(current, 1) as StickmanStep);
+ const previousStageId = latestShotStage(job.stages, shotId)?.id ?? null;
+ session.clearError();
setNotice('');
+ setSavingShotId(shotId);
+ setRegenerationRequests(current => ({ ...current, [shotId]: previousStageId }));
+ try {
+ await session.applyAction({
+ actor: 'user',
+ action: 'edit-shot',
+ input: {
+ artifactId: shotSpecArtifact.id,
+ scopeKey: shotId,
+ patch: {
+ visualDescription: description,
+ motion
+ },
+ revision: job.revision
+ }
+ });
+ } catch (error) {
+ setRegenerationRequests(current => {
+ const next = { ...current };
+ delete next[shotId];
+ return next;
+ });
+ setNotice(error instanceof Error ? error.message : String(error));
+ } finally {
+ setSavingShotId(undefined);
+ }
}
- function continueToVideo() {
- if (!storyboardReady) {
- setNotice(l('请先生成并确认分镜图', 'Generate and review the storyboard first'));
+ async function regenerateShot(shotId: string) {
+ if (Object.hasOwn(regenerationRequests, shotId)) return;
+ const stage = latestShotStage(job.stages, shotId);
+ if (stage?.inputFingerprint === null || stage?.inputFingerprint === undefined) {
+ setNotice(l('当前镜头尚未建立生成指纹,请先审核分镜', 'This shot has no generation fingerprint yet. Approve the storyboard first.'));
return;
}
- setCurrentStep(2);
- setFurthestStep(2);
+ session.clearError();
setNotice('');
+ setRegenerationRequests(current => ({ ...current, [shotId]: stage.id }));
+ try {
+ await session.applyAction({
+ actor: 'user',
+ action: 'regenerate-shot',
+ input: {
+ scopeKey: shotId,
+ inputFingerprint: stage.inputFingerprint,
+ revision: job.revision
+ }
+ });
+ } catch (error) {
+ setRegenerationRequests(current => {
+ const next = { ...current };
+ delete next[shotId];
+ return next;
+ });
+ setNotice(error instanceof Error ? error.message : String(error));
+ }
}
- function continueToAudio() {
- if (!storyboardReady) {
- setCurrentStep(1);
- setNotice(l('请先生成并确认分镜图', 'Generate and review the storyboard first'));
- return;
- }
- setAudioEditing(true);
- setCurrentStep(3);
- setFurthestStep(3);
+ async function generateMissingShots() {
+ if (batchGenerationPending || isBusy) return;
+ session.clearError();
setNotice('');
+ batchGenerationStageCount.current = job.stages.length;
+ setBatchGenerationPending(true);
+ try {
+ await session.applyAction({
+ actor: 'user',
+ action: 'generate-missing-shots',
+ input: { revision: job.revision }
+ });
+ } catch (error) {
+ setBatchGenerationPending(false);
+ setNotice(error instanceof Error ? error.message : String(error));
+ }
}
- function handleCommand(command: string) {
- const requestedPreset = characterPresets.find(preset => {
- const keywords: Record<CharacterPresetId, RegExp> = {
- default: /默认|基础|简单|default|basic|simple/i,
- 'tech-guy': /科技男|技术宅|科技|格纹|眼镜|tech guy|tech enthusiast|tech|checks|glasses/i,
- 'long-hair': /长发|long hair/i,
- 'short-hair': /短发|short hair/i,
- hiphop: /嘻哈|说唱|歌手|街头|帽衫|球鞋|hiphop|hip hop|rapper|street|hoodie|sneakers/i,
- student: /学生|校园|水手服|student|school|campus/i,
- elder: /长者|老人|胡须|elder|older|beard/i,
- manager: /经理|管理者|西装|manager|executive|suit/i,
- chef: /厨师|美食|餐厅|chef|cook|food/i,
- fitness: /健身|教练|肌肉|fitness|fitness coach|coach|trainer|muscle/i
- };
- return keywords[preset.id].test(command);
- });
- if (requestedPreset) {
- selectPreset(requestedPreset.id);
- return l(`已切换为${requestedPreset.nameZh},左侧角色选择已同步。`, `Switched to ${requestedPreset.nameEn}. The character selection is synced on the left.`);
- }
- if (/生成角色|角色形象|generate character|character image/i.test(command)) {
- return generateCharacter() ? l('角色形象已经生成,左侧可以查看。下一步可以生成故事分镜。', 'The character is ready on the left. Next, generate the storyboard.') : l('请先补充角色外观描述。', 'Add a character appearance description first.');
- }
- if (/生成分镜|分镜图|generate storyboard|storyboard/i.test(command)) {
- return generateStoryboard() ? l(`${storyboardShots.length} 个关键分镜已生成,请在左侧检查镜头和节奏。`, `${storyboardShots.length} key shots are ready. Review the scenes and pacing on the left.`) : l('需要先准备角色形象和故事创意。', 'Prepare a character and story idea first.');
+ async function control(kind: 'canceling' | 'resuming') {
+ setControlPending(kind);
+ try {
+ if (kind === 'canceling') await session.cancelJob();
+ else await session.resumeJob();
+ } catch (error) {
+ setNotice(error instanceof Error ? error.message : String(error));
+ } finally {
+ setControlPending(undefined);
}
- if (/生成视频|开始生成|generate video|create video/i.test(command)) {
- const unchanged = selectedResult?.signature === currentSignature;
- return generateVideo()
- ? unchanged
- ? l(`设置没有变化,继续查看 V${resultVersion},未创建新版本。`, `Nothing changed. Continuing with V${resultVersion}; no new version was created.`)
- : l(`V${nextVersion} 已生成,可以在左侧预览和下载。`, `V${nextVersion} is ready to preview and download on the left.`)
- : l('需要先生成角色形象和分镜图。', 'Generate the character and storyboard first.');
- }
- if (/竖屏|9:16|vertical/i.test(command)) {
- setRatio('9:16');
- setCurrentStep(1);
- setFurthestStep(current => Math.max(current, 1) as StickmanStep);
- setVideoReady(false);
- return l('已切换为 9:16 竖屏视频。', 'Switched to 9:16 vertical video.');
- }
- if (/横屏|16:9|horizontal/i.test(command)) {
- setRatio('16:9');
- setCurrentStep(1);
- setFurthestStep(current => Math.max(current, 1) as StickmanStep);
- setVideoReady(false);
- return l('已切换为 16:9 横屏视频。', 'Switched to 16:9 horizontal video.');
- }
- if (command.length > 12) {
- setStory(command);
- setStoryboardReady(false);
- setVideoReady(false);
- setCurrentStep(1);
- setFurthestStep(hasSavedResults ? 3 : 1);
- return l('已把这段内容作为故事创意同步到左侧。准备好角色后即可生成分镜。', 'This is now the story idea on the left. Once the character is ready, generate the storyboard.');
- }
- return l('你可以描述角色外观和故事,也可以直接让我生成角色、分镜或视频。', 'Describe the character and story, or ask me to generate the character, storyboard, or video.');
}
- const context = videoReady
- ? l(`视频已完成,${ratio}`, `Video complete, ${ratio}`)
- : storyboardReady
- ? l(`${storyboardShots.length} 个分镜,${ratio}`, `${storyboardShots.length} storyboard shots, ${ratio}`)
- : characterReady
- ? l('角色已准备,等待分镜', 'Character ready, waiting for storyboard')
- : l('等待角色形象', 'Waiting for a character');
- const dialogShot = storyboardDialog ? storyboardShots[storyboardDialog.shotIndex] : undefined;
+ const steps = [
+ l('来源与角色', 'Source and character'),
+ l('脚本审核', 'Script review'),
+ l('配音与节奏', 'Voice and timing'),
+ l('分镜与画面', 'Storyboard and visuals'),
+ l('动画合成', 'Video composition'),
+ l('成片交付', 'Video delivery')
+ ];
+ const completedSteps = [
+ scriptArtifact !== undefined,
+ scriptArtifact !== undefined && job.state.approvedScriptArtifactId === scriptArtifact.id,
+ audioTimingArtifact !== undefined,
+ visualValidationArtifact !== undefined,
+ latestSnapshot !== undefined,
+ latestSnapshot !== undefined
+ ];
return (
- <>
- <CreatorToolShell
- title={l('火柴人动画', 'Stick Figure Animation')}
- subtitle={l('先创建角色与分镜,再生成完整动画', 'Create a character and storyboard, then generate the full animation')}
- context={context}
- initialMessage={l('已经为你选好一个默认角色。你可以直接生成分镜,也可以换一个默认角色、上传参考图或生成自己的角色。', 'A default character is ready. Generate the storyboard now, or choose another character, upload a reference, or generate your own.')}
- suggestions={videoReady
- ? [l('让 Agent 重新生成视频', 'Ask Agent to regenerate video')]
- : storyboardReady
- ? [l('让 Agent 生成视频', 'Ask Agent to generate video')]
- : characterReady
- ? [l('让 Agent 生成分镜', 'Ask Agent to generate storyboard')]
- : [l('让 Agent 生成角色', 'Ask Agent to generate character')]}
- placeholder={props.promptHint ?? l('描述角色、故事或生成要求', 'Describe the character, story, or generation requirements')}
+ <CreatorToolShell
+ title={l('火柴人动画', 'Stickman video')}
+ titleIcon={<PersonStanding size={20} strokeWidth={1.8} />}
+ subtitle={l('从文本或 YouTube 内容生成旁白、配音、分镜画面、字幕与动画', 'Turn text or YouTube content into narration, voice, storyboard visuals, subtitles, and animation.')}
+ context={currentIssue(job, steps[workbenchStep]!, l)}
+ stepLabel={steps[workbenchStep]}
+ currentIssue={review?.message ?? undefined}
+ placeholder={props.promptHint ?? l('告诉 Agent 需要调整的脚本、镜头或画面要求', 'Tell the Agent what to change in the script, shots, or visuals')}
+ suggestions={[
+ l('检查当前任务状态', 'Check the current task status'),
+ l('优化脚本节奏', 'Improve the script pacing'),
+ l('检查镜头一致性', 'Check shot consistency')
+ ]}
+ pageClassName="stickman-workspace-page"
contentClassName="stickman-workspace-content"
+ onCancelTask={isBusy ? () => void control('canceling') : undefined}
+ onResumeTask={job.status === 'canceled' ? () => void control('resuming') : undefined}
+ taskControlPending={controlPending}
onBack={props.onBack}
- onCommand={handleCommand}
>
<div className="creator-tool-stack stickman-tool-stack">
- <nav className="video-translation-steps creator-tool-steps" aria-label={l('火柴人生成流程', 'Stick figure generation steps')}>
- <ol>
- {steps.map((step, index) => {
- const completed = index < currentStep;
- const active = index === currentStep;
- return (
- <li key={step} data-active={active} data-completed={completed}>
- <button
- type="button"
- disabled={index > furthestStep}
- aria-current={active ? 'step' : undefined}
- onClick={() => index !== currentStep && setCurrentStep(index as StickmanStep)}
+ <div className="stickman-tool-top">
+ <nav className="video-translation-steps creator-tool-steps stickman-steps" aria-label={l('火柴人视频制作步骤', 'Stickman video steps')}>
+ <ol>
+ {steps.map((step, index) => {
+ const active = index === activeStep;
+ const completed = completedSteps[index] ?? false;
+ return (
+ <li
+ key={step}
+ data-active={active}
+ data-completed={completed}
+ data-visited={index <= workbenchStep}
+ data-running={index === workbenchStep && isBusy}
>
- <span>{completed ? <Check size={13} strokeWidth={2.2} aria-hidden="true" /> : index + 1}</span>
- <strong>{step}</strong>
- </button>
- </li>
- );
- })}
- </ol>
- </nav>
-
- <div className="stickman-step-scroll">
-
- {currentStep === 0 ? (
- <section className="creator-tool-panel" aria-labelledby="stickman-character-title">
- <div className="creator-tool-panel-heading">
- <div><span>{l('角色形象', 'Character')}</span><h2 id="stickman-character-title">{l('准备主角', 'Prepare the main character')}</h2><p>{l('选择默认角色,也可以生成或上传自己的角色', 'Choose a default character, or generate or upload your own')}</p></div>
- {characterReady ? <small><Check size={14} strokeWidth={2} />{selectedPreset ? l(`已选择${selectedPreset.nameZh}`, `${selectedPreset.nameEn} selected`) : l('已完成', 'Complete')}</small> : null}
- </div>
- <div className="creator-tool-segmented" role="tablist" aria-label={l('角色来源', 'Character source')}>
- <button type="button" role="tab" aria-selected={characterMode === 'preset'} onClick={() => setCharacterMode('preset')}>
- <PersonStanding size={15} strokeWidth={1.8} />{l('默认角色', 'Characters')}
- </button>
- <button type="button" role="tab" aria-selected={characterMode === 'generate'} onClick={() => setCharacterMode('generate')}>
- <Sparkles size={15} strokeWidth={1.8} />{l('生成角色', 'Generate')}
- </button>
- <button type="button" role="tab" aria-selected={characterMode === 'upload'} onClick={() => setCharacterMode('upload')}>
- <UploadCloud size={15} strokeWidth={1.8} />{l('上传角色', 'Upload')}
- </button>
- </div>
- {characterMode === 'preset' ? (
- <div className="stickman-character-picker">
- <div className="stickman-character-presets" role="radiogroup" aria-label={l('默认角色', 'Default characters')}>
- {characterPresets.map(preset => {
- const selected = preset.id === selectedPresetId;
- return (
<button
type="button"
- role="radio"
- aria-checked={selected}
- key={preset.id}
- onClick={() => selectPreset(preset.id)}
+ disabled={index > workbenchStep}
+ aria-current={active ? 'step' : undefined}
+ onClick={() => setActiveStep(index)}
>
- <span className="stickman-character-preset-visual" aria-hidden="true">
- <CharacterArtwork image={preset.image} alt="" />
- </span>
- <strong>{l(preset.nameZh, preset.nameEn)}</strong>
- {selected ? <Check className="stickman-character-preset-check" size={15} strokeWidth={2.2} aria-hidden="true" /> : null}
+ <span>{completed
+ ? <Check size={13} strokeWidth={2.2} aria-hidden="true" />
+ : index === workbenchStep && isBusy
+ ? <LoaderCircle className="creator-collaboration-spin" size={13} aria-hidden="true" />
+ : index + 1}</span>
+ <strong>{step}</strong>
</button>
- );
- })}
- </div>
- {selectedPreset ? (
- <aside className="stickman-character-selected" aria-label={l('已选角色全身预览', 'Full view of selected character')}>
- <div>
- <CharacterArtwork
- image={selectedPreset.image}
- alt={l(selectedPreset.nameZh, selectedPreset.nameEn)}
- />
- </div>
- </aside>
- ) : null}
- </div>
- ) : characterMode === 'generate' ? (
- <div className="stickman-character-grid">
- <label className="creator-tool-field">
- <span>{l('角色描述', 'Character description')}</span>
- <textarea value={characterPrompt} onChange={event => updateCharacterPrompt(event.target.value)} rows={4} />
- </label>
- {characterGenerated ? (
- <div className="stickman-character-preview"><CharacterArtwork {...generatedCharacterImages} alt={l('生成的火柴人角色形象', 'Generated stick figure character')} /></div>
- ) : (
- <div className="stickman-character-empty"><ImagePlus size={24} strokeWidth={1.5} /><span>{l('角色设定图将在这里生成', 'The character sheet will appear here')}</span></div>
- )}
- </div>
- ) : (
- <div className="stickman-character-upload">
- <label className="creator-tool-upload">
- <input type="file" accept="image/*" aria-label={l('上传火柴人角色形象', 'Upload a stick figure character')} onChange={event => uploadCharacter(event.target.files?.[0] ?? null)} />
- {characterFile ? (
- <><CharacterArtwork image={characterPreview || generatedCharacterImages.image} alt={l('上传的角色形象', 'Uploaded character')} /><strong>{characterFile.name}</strong><span>{l('点击重新选择', 'Click to choose another')}</span></>
- ) : (
- <><UploadCloud size={25} strokeWidth={1.5} /><strong>{l('上传角色设定图', 'Upload character sheet')}</strong><span>{l('支持 PNG、JPG、WebP', 'Supports PNG, JPG, and WebP')}</span></>
- )}
- </label>
- <aside className="stickman-upload-guidance" aria-label={l('角色图片上传建议', 'Character image upload guidance')}>
- <Info size={16} strokeWidth={1.8} aria-hidden="true" />
- <div>
- <strong>{l('上传建议', 'Upload guidance')}</strong>
- <p>{l('人物全身完整可见,背景干净简洁,保持单人清晰且无遮挡。', 'Keep the full body visible, use a clean background, and provide one clear, unobstructed character.')}</p>
- </div>
- </aside>
+ </li>
+ );
+ })}
+ </ol>
+ </nav>
+
+ {notice || session.error ? (
+ <div className="creator-tool-notice" role="alert">
+ <span>{notice || session.error?.message}</span>
+ <button type="button" onClick={() => { setNotice(''); session.clearError(); }} aria-label={l('关闭提示', 'Dismiss')}><X size={15} /></button>
</div>
- )}
- </section>
- ) : null}
+ ) : null}
+ </div>
- {currentStep === 1 ? (
- <section className="creator-tool-panel stickman-story-panel" aria-labelledby="stickman-story-title">
- <div className="creator-tool-panel-heading"><div><span>{l('故事与画面', 'Story and visuals')}</span><h2 id="stickman-story-title">{l('生成分镜', 'Generate storyboard')}</h2><p>{l('角色会在所有镜头中保持一致', 'The character remains consistent across every shot')}</p></div></div>
- <label className="creator-tool-field stickman-story-field"><span>{l('故事创意', 'Story idea')}</span><textarea value={story} onChange={event => { setStory(event.target.value); setStoryboardReady(false); setVideoReady(false); setFurthestStep(hasSavedResults ? 3 : 1); }} rows={5} /></label>
- <div className="creator-tool-form-row">
- <label className="creator-tool-field"><span>{l('画面风格', 'Visual style')}</span><select value={style} onChange={event => { setStyle(event.target.value); setStoryboardReady(false); setVideoReady(false); setFurthestStep(hasSavedResults ? 3 : 1); }}><option value="手绘线稿">{l('手绘线稿', 'Hand-drawn line art')}</option><option value="漫画网点">{l('漫画网点', 'Manga halftone')}</option><option value="极简黑白">{l('极简黑白', 'Minimal black and white')}</option></select></label>
- <label className="creator-tool-field"><span>{l('视频比例', 'Video ratio')}</span><select value={ratio} onChange={event => { setRatio(event.target.value as typeof ratio); setStoryboardReady(false); setVideoReady(false); setFurthestStep(hasSavedResults ? 3 : 1); }}><option>16:9</option><option>9:16</option><option>1:1</option></select></label>
- </div>
- </section>
- ) : null}
+ <div
+ className="creator-task-layout stickman-step-scroll"
+ data-step={activeStep}
+ key={`stickman-step-${activeStep}`}
+ >
+ <section className="creator-task-workspace">
+ {activeStep === 0 ? (
+ <SourceAndCharacterStep
+ sourceType={sourceType}
+ sourceUrl={sourceUrl}
+ sourceText={sourceText}
+ characterAsset={characterAsset}
+ styleAsset={styleAsset}
+ characterAssets={characterAssets}
+ styleAssets={styleAssets}
+ previewUrls={visualAssetPreviewUrls}
+ visualAssetCatalogStatus={visualAssetCatalogStatus}
+ targetDurationSeconds={targetDurationSeconds}
+ ttsProvider={ttsProvider}
+ ttsModel={ttsModel}
+ voiceCode={voiceCode}
+ creatorServicesService={props.creatorServicesService ?? null}
+ ttsConfigurationStatus={ttsConfigurationStatus}
+ imageConfigurationStatus={imageConfigurationStatus}
+ busy={isBusy}
+ canContinue={workbenchStep > 0}
+ l={l}
+ onPatch={patch => session.updateDraft({ ratio: '16:9', ...patch }, { semantic: true })}
+ onStart={startWorkflow}
+ onContinue={() => setActiveStep(1)}
+ />
+ ) : null}
- {currentStep === 2 ? (
- <div className="stickman-storyboard-step">
- {hasSavedResults && hasPendingChanges ? (
- <div className="stickman-version-draft" role="status">
- <div>
- <strong>{l(`正在基于 V${resultVersion} 调整`, `Adjusting from V${resultVersion}`)}</strong>
- <span>{l('原版本的角色、分镜和成片仍可查看', 'The original character, storyboard, and video remain available')}</span>
- </div>
- </div>
+ {activeStep === 1 ? (
+ <ScriptStep
+ artifact={scriptArtifact}
+ script={scriptDraft}
+ stage={scriptStage}
+ requiresRegeneration={scriptRequiresRegeneration}
+ dirty={scriptDirty}
+ busy={isBusy}
+ submitting={scriptSubmitting}
+ l={l}
+ onChange={updateScriptDraft}
+ onBack={() => setActiveStep(0)}
+ onNext={() => void continueFromScript()}
+ onRetry={() => void apply('retry-stage', { stageId: 'script' })}
+ />
) : null}
- <section className="creator-tool-panel stickman-storyboard-review" aria-labelledby="stickman-storyboard-review-title">
- <div className="creator-tool-panel-heading">
- <div><span>{l('故事分镜', 'Storyboard')}</span><h2 id="stickman-storyboard-review-title">{l('确认故事分镜', 'Review storyboard')}</h2><p>{l('逐镜头修改字幕,或重新生成不合适的画面', 'Edit each subtitle or regenerate any image that does not fit')}</p></div>
- </div>
- <StickmanStoryboard
- ariaLabel={l('待确认的火柴人故事分镜', 'Stick figure storyboard to review')}
- subtitles={storyboardSubtitles}
- imageVersions={storyboardImageVersions}
- editable
+
+ {activeStep === 2 ? (
+ <AudioStep
+ script={script}
+ timing={audioTiming}
+ timingStage={latestStage(job.stages, 'audio-timing')}
+ artifacts={job.artifacts}
+ stages={job.stages}
+ voiceName={voiceName}
+ targetLanguage={targetLanguage}
+ busy={isBusy || transitionPending === 'audio'}
+ l={l}
+ onBack={() => setActiveStep(1)}
+ onNext={() => void continueFromAudio()}
+ onRetry={retryAudioStage}
+ />
+ ) : null}
+
+ {activeStep === 3 ? (
+ <StoryboardStep
+ jobStages={job.stages}
+ shotSpec={shotSpec}
+ script={script}
+ timing={audioTiming}
+ artifacts={job.artifacts}
+ busy={isBusy || transitionPending === 'visuals'}
+ batchGenerationPending={batchGenerationPending}
+ savingShotId={savingShotId}
+ regenerationRequests={regenerationRequests}
l={l}
- onSubtitleChange={updateStoryboardSubtitle}
- onRegenerateRequest={index => setStoryboardDialog({ shotIndex: index, mode: 'regenerate' })}
- onViewPrompt={index => setStoryboardDialog({ shotIndex: index, mode: 'view' })}
+ onSave={saveShot}
+ onRegenerate={shotId => void regenerateShot(shotId)}
+ onGenerateMissing={() => void generateMissingShots()}
+ onBack={() => setActiveStep(2)}
+ onNext={() => void continueFromVisuals()}
/>
- </section>
+ ) : null}
+
+ {activeStep === 4 ? (
+ <CompositionStep
+ stages={job.stages}
+ deliveryReady={latestSnapshot !== undefined}
+ l={l}
+ onBack={() => setActiveStep(3)}
+ onRetry={retryRenderStage}
+ />
+ ) : null}
+
+ {activeStep === 5 ? (
+ <ResultStep
+ artifacts={job.artifacts}
+ snapshot={currentSnapshot}
+ videoUrl={videoUrl}
+ version={selectedVersion || latestSnapshot?.version || 0}
+ versions={snapshots.map(snapshot => ({ value: snapshot.version, description: snapshot.description }))}
+ manifest={deliveryManifest}
+ l={l}
+ onVersionChange={setSelectedVersion}
+ onOpen={artifact => void openArtifact(session.openArtifact, artifact)}
+ onDownload={artifact => void downloadArtifact(session.openArtifact, artifact)}
+ onBack={() => setActiveStep(4)}
+ />
+ ) : null}
+ </section>
+ </div>
+ </div>
+
+ </CreatorToolShell>
+ );
+}
+
+function SourceAndCharacterStep(props: {
+ sourceType: 'url' | 'text';
+ sourceUrl: string;
+ sourceText: string;
+ characterAsset: CreatorVisualAssetRef;
+ styleAsset: CreatorVisualAssetRef;
+ characterAssets: CreatorVisualAssetSummary[];
+ styleAssets: CreatorVisualAssetSummary[];
+ previewUrls: Record<string, string>;
+ visualAssetCatalogStatus: VisualAssetCatalogStatus;
+ targetDurationSeconds: number;
+ ttsProvider: CreatorTtsProvider;
+ ttsModel: string;
+ voiceCode: string;
+ creatorServicesService: CreatorServicesSettingsService | null;
+ ttsConfigurationStatus: TtsConfigurationStatus;
+ imageConfigurationStatus: ImageConfigurationStatus;
+ busy: boolean;
+ canContinue: boolean;
+ l: ReturnType<typeof useLocalizedCopy>;
+ onPatch(patch: Record<string, CreatorJson>): void;
+ onStart(): void;
+ onContinue(): void;
+}) {
+ return (
+ <div className="creator-tool-panel stickman-story-panel">
+ <header className="creator-tool-panel-heading"><span><Sparkles size={18} /></span><div><h2>{props.l('来源与角色', 'Source and character')}</h2><p>{props.l('选择创作来源与固定角色。', 'Choose a source and a fixed character.')}</p></div></header>
+ <div className="creator-tool-segmented" role="tablist" aria-label={props.l('内容来源', 'Content source')}>
+ <button type="button" role="tab" aria-selected={props.sourceType === 'text'} onClick={() => props.onPatch({ sourceType: 'text' })}><FileText size={15} />{props.l('输入文本', 'Text')}</button>
+ <button type="button" role="tab" aria-selected={props.sourceType === 'url'} onClick={() => props.onPatch({ sourceType: 'url' })}><Link2 size={15} />YouTube</button>
+ </div>
+ {props.sourceType === 'text' ? (
+ <label className="creator-tool-field stickman-source-text"><span>{props.l('文本内容', 'Source text')}</span><textarea value={props.sourceText} placeholder={props.l('输入文章、脚本草稿或要讲解的内容', 'Enter an article, script draft, or topic content')} maxLength={50_000} onChange={event => props.onPatch({ sourceText: event.target.value })} /></label>
+ ) : (
+ <label className="creator-tool-field"><span>{props.l('YouTube 链接', 'YouTube URL')}</span><input type="url" value={props.sourceUrl} placeholder="https://www.youtube.com/watch?v=..." onChange={event => props.onPatch({ sourceUrl: event.target.value })} /></label>
+ )}
+ <div className="stickman-character-picker">
+ <div className="stickman-character-presets" role="radiogroup" aria-label={props.l('角色预设', 'Character presets')}>
+ {props.characterAssets.map(asset => {
+ const selected = sameAssetRef(props.characterAsset, asset);
+ const previewUrl = props.previewUrls[assetRefKey(asset)];
+ return (
+ <button type="button" role="radio" aria-checked={selected} key={assetRefKey(asset)} onClick={() => props.onPatch({ characterAsset: { assetId: asset.id, revision: asset.revision } })}>
+ <span className="stickman-character-preset-visual">{previewUrl === undefined ? <LoaderCircle className="creator-collaboration-spin" size={18} aria-hidden="true" /> : <img src={previewUrl} alt="" />}</span>
+ <strong title={props.l(asset.name.zhCN, asset.name.en)}>{props.l(asset.name.zhCN, asset.name.en)}</strong>
+ {selected ? <Check className="stickman-character-preset-check" size={15} /> : null}
+ </button>
+ );})}
+ </div>
+ {props.visualAssetCatalogStatus === 'loading' ? <div className="stickman-asset-catalog-state" role="status"><LoaderCircle className="creator-collaboration-spin" size={17} />{props.l('正在读取视觉资产', 'Loading visual assets')}</div> : null}
+ {props.visualAssetCatalogStatus === 'error' || props.visualAssetCatalogStatus === 'unavailable' ? <div className="stickman-asset-catalog-state is-error" role="alert"><ImageIcon size={17} />{props.l('人物与视觉风格目录不可用', 'The character and visual style catalog is unavailable')}</div> : null}
+ </div>
+ <div className="creator-tool-form-row">
+ <VisualStylePicker
+ assets={props.styleAssets}
+ selected={props.styleAsset}
+ l={props.l}
+ onChange={styleAsset => props.onPatch({ styleAsset })}
+ />
+ <div className="creator-tool-field">
+ <span id="stickman-target-duration-label">{props.l('目标时长', 'Target duration')}</span>
+ <div className="stickman-duration-control">
+ <select
+ aria-labelledby="stickman-target-duration-label"
+ value={targetDurationPreset(props.targetDurationSeconds)}
+ onChange={event => props.onPatch({
+ targetDurationSeconds: event.target.value === 'custom'
+ ? 90
+ : Number(event.target.value)
+ })}
+ >
+ <option value="30">{props.l('30 秒', '30 seconds')}</option>
+ <option value="60">{props.l('1 分钟', '1 minute')}</option>
+ <option value="300">{props.l('5 分钟', '5 minutes')}</option>
+ <option value="600">{props.l('10 分钟', '10 minutes')}</option>
+ <option value="custom">{props.l('自定义', 'Custom')}</option>
+ </select>
+ {targetDurationPreset(props.targetDurationSeconds) === 'custom' ? (
+ <span className="stickman-custom-duration">
+ <input
+ type="number"
+ min={10}
+ max={600}
+ value={props.targetDurationSeconds}
+ aria-label={props.l('自定义时长(秒)', 'Custom duration in seconds')}
+ onChange={event => {
+ const value = Number(event.target.value);
+ if (Number.isFinite(value) && value >= 10 && value <= 600) {
+ props.onPatch({ targetDurationSeconds: value });
+ }
+ }}
+ />
+ <small>{props.l('秒', 'sec')}</small>
+ </span>
+ ) : null}
+ </div>
+ </div>
+ </div>
+ <div className="stickman-voice-settings">
+ {props.ttsConfigurationStatus === 'configured' && props.ttsProvider !== 'edge-tts' ? (
+ <TtsVoicePicker
+ id="stickman-video-voice"
+ provider={props.ttsProvider}
+ model={props.ttsModel}
+ value={props.voiceCode}
+ service={props.creatorServicesService}
+ label={props.l('配音音色', 'Narration voice')}
+ disabled={props.busy}
+ onChange={(voiceId, voice) => props.onPatch({
+ voiceCode: voiceId,
+ voiceName: voice?.name ?? voiceId
+ })}
+ onVoiceResolved={voice => props.onPatch({ voiceName: voice.name })}
+ />
+ ) : props.ttsConfigurationStatus === 'configured' ? (
+ <div className="stickman-tts-configuration is-configured" role="status">
+ <Volume2 size={18} aria-hidden="true" />
+ <div>
+ <strong>{props.l('使用 Edge TTS 配音', 'Using Edge TTS')}</strong>
+ <small>{props.l('无需选择音色,将使用服务默认音色。', 'No voice selection is required; the service default will be used.')}</small>
+ </div>
+ </div>
+ ) : (
+ <div className="stickman-tts-configuration" role="status">
+ {props.ttsConfigurationStatus === 'loading'
+ ? <LoaderCircle className="creator-collaboration-spin" size={18} aria-hidden="true" />
+ : <Settings2 size={18} aria-hidden="true" />}
+ <div>
+ <strong>{props.ttsConfigurationStatus === 'loading'
+ ? props.l('正在读取配音服务配置', 'Loading TTS settings')
+ : props.l('尚未配置配音服务', 'TTS service is not configured')}</strong>
+ <small>{props.ttsConfigurationStatus === 'unavailable'
+ ? props.l('暂时无法读取配置,请检查 Runtime 或前往设置。', 'Settings are temporarily unavailable. Check the Runtime or open Settings.')
+ : props.l('配置服务商和 API Key 后,才能选择配音音色。', 'Configure a provider and API key before selecting a voice.')}</small>
+ </div>
+ {props.ttsConfigurationStatus !== 'loading' ? (
+ <a href="#/settings?tab=ai-services&section=tts">
+ {props.l('前往配音服务配置', 'Configure TTS service')}
+ </a>
+ ) : null}
+ </div>
+ )}
+ </div>
+ {props.imageConfigurationStatus !== 'configured' ? (
+ <div className="stickman-tts-configuration" role="status">
+ {props.imageConfigurationStatus === 'loading'
+ ? <LoaderCircle className="creator-collaboration-spin" size={18} aria-hidden="true" />
+ : <ImageIcon size={18} aria-hidden="true" />}
+ <div>
+ <strong>{props.imageConfigurationStatus === 'loading'
+ ? props.l('正在读取生图服务配置', 'Loading image settings')
+ : props.imageConfigurationStatus === 'unsupported'
+ ? props.l('当前生图服务不支持角色参考图', 'The image provider does not support character references')
+ : props.l('尚未配置生图服务', 'Image service is not configured')}</strong>
+ <small>{props.imageConfigurationStatus === 'unsupported'
+ ? props.l('火柴人必须把所选角色图片随每个镜头提交,请切换到 OpenAI 或 Gemini。', 'Stickman generation must attach the selected character to every shot. Switch to OpenAI or Gemini.')
+ : props.l('配置支持参考图的服务后,才能保证镜头使用所选角色。', 'Configure a reference-capable provider so every shot uses the selected character.')}</small>
</div>
+ {props.imageConfigurationStatus !== 'loading' ? (
+ <a href="#/settings?tab=ai-services&section=image">
+ {props.l('前往生图服务配置', 'Configure image service')}
+ </a>
+ ) : null}
+ </div>
+ ) : null}
+ <div className={`stickman-wizard-actions stickman-source-actions${props.canContinue ? ' has-next' : ''}`}>
+ {props.canContinue ? (
+ <button
+ className="video-translation-secondary-action"
+ type="button"
+ disabled={props.busy || props.ttsConfigurationStatus !== 'configured' || props.imageConfigurationStatus !== 'configured'}
+ onClick={props.onStart}
+ >
+ {props.busy
+ ? <LoaderCircle className="creator-collaboration-spin" size={16} aria-hidden="true" />
+ : <Sparkles size={16} strokeWidth={1.8} aria-hidden="true" />}
+ {props.busy
+ ? props.l('重新生成中...', 'Regenerating...')
+ : props.l('重新生成', 'Regenerate')}
+ </button>
) : null}
+ <button
+ className="video-translation-primary-action"
+ type="button"
+ disabled={props.busy || (!props.canContinue && (
+ props.ttsConfigurationStatus !== 'configured'
+ || props.imageConfigurationStatus !== 'configured'
+ || props.visualAssetCatalogStatus === 'error'
+ || props.visualAssetCatalogStatus === 'unavailable'
+ ))}
+ onClick={props.canContinue ? props.onContinue : props.onStart}
+ >
+ {props.canContinue
+ ? props.l('下一步', 'Next')
+ : props.busy
+ ? props.l('生成中...', 'Generating...')
+ : props.l('开始生成', 'Start generation')}
+ {props.canContinue
+ ? <ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" />
+ : props.busy
+ ? <LoaderCircle className="creator-collaboration-spin" size={16} aria-hidden="true" />
+ : <Sparkles size={16} aria-hidden="true" />}
+ </button>
+ </div>
+ </div>
+ );
+}
- {currentStep === 3 ? (
- hasSavedResults && selectedResult && !audioEditing ? (
- <section className="video-result-workspace stickman-result-workspace" aria-label={l('火柴人项目产出', 'Stick figure project outputs')}>
- <div className="video-result-toolbar">
- <div className="video-result-tabs" role="tablist" aria-label={l('产出物类型', 'Output types')}>
- {([
- { value: 'video', label: l('成片', 'Final video'), icon: FileVideo },
- { value: 'storyboard', label: l('分镜', 'Storyboard'), icon: PanelsTopLeft },
- { value: 'character', label: l('角色', 'Character'), icon: PersonStanding },
- { value: 'settings', label: l('任务设置', 'Task settings'), icon: Settings2 }
- ] as const).map(tab => {
- const Icon = tab.icon;
- return (
- <button type="button" role="tab" aria-selected={resultTab === tab.value} key={tab.value} onClick={() => setResultTab(tab.value)}>
- <Icon size={15} strokeWidth={1.8} aria-hidden="true" />
- {tab.label}
- </button>
- );
- })}
- </div>
- <CreatorResultVersionMenu
- version={resultVersion}
- versions={resultVersions.map(({ value, description }) => ({ value, description }))}
- onVersionChange={selectResultVersion}
- />
- </div>
+function VisualStylePicker(props: {
+ assets: CreatorVisualAssetSummary[];
+ selected: CreatorVisualAssetRef;
+ l: ReturnType<typeof useLocalizedCopy>;
+ onChange(reference: CreatorVisualAssetRef): void;
+}) {
+ const selectedAsset = props.assets.find(asset => sameAssetRef(props.selected, asset));
+ return (
+ <div className="creator-tool-field stickman-style-field">
+ <label htmlFor="stickman-visual-style">{props.l('视觉风格', 'Visual style')}</label>
+ <select
+ id="stickman-visual-style"
+ value={selectedAsset === undefined ? '' : assetRefKey(selectedAsset)}
+ disabled={props.assets.length === 0}
+ onChange={event => {
+ const asset = props.assets.find(candidate => assetRefKey(candidate) === event.target.value);
+ if (asset !== undefined) props.onChange({ assetId: asset.id, revision: asset.revision });
+ }}
+ >
+ {props.assets.length === 0 ? <option value="">{props.l('正在读取视觉风格', 'Loading visual styles')}</option> : null}
+ {props.assets.map(asset => (
+ <option key={assetRefKey(asset)} value={assetRefKey(asset)}>
+ {props.l(asset.name.zhCN, asset.name.en)}
+ </option>
+ ))}
+ </select>
+ {selectedAsset?.styleAttributes !== undefined ? (
+ <div className="stickman-style-summary">
+ <span
+ className="stickman-style-swatch"
+ data-texture={selectedAsset.styleAttributes.swatch.texture}
+ aria-hidden="true"
+ style={{
+ '--stickman-style-bg': selectedAsset.styleAttributes.swatch.background,
+ '--stickman-style-fg': selectedAsset.styleAttributes.swatch.foreground,
+ '--stickman-style-accent': selectedAsset.styleAttributes.swatch.accent
+ } as CSSProperties}
+ ><i /><i /><i /></span>
+ <span className="stickman-style-copy">
+ <strong>{props.l(selectedAsset.name.zhCN, selectedAsset.name.en)}</strong>
+ <small>{props.l(selectedAsset.description.zhCN, selectedAsset.description.en)}</small>
+ <span>
+ <em>{props.l(selectedAsset.styleAttributes.medium.zhCN, selectedAsset.styleAttributes.medium.en)}</em>
+ <em>{props.l(selectedAsset.styleAttributes.palette.zhCN, selectedAsset.styleAttributes.palette.en)}</em>
+ <em>{props.l(selectedAsset.styleAttributes.sceneDensity.zhCN, selectedAsset.styleAttributes.sceneDensity.en)}</em>
+ </span>
+ </span>
+ </div>
+ ) : null}
+ </div>
+ );
+}
- {hasPendingChanges ? (
- <div className="stickman-version-draft" role="status">
- <div>
- <strong>{l(`正在基于 V${resultVersion} 调整`, `Adjusting from V${resultVersion}`)}</strong>
- <span>{l('原版本的角色、分镜和成片仍可查看', 'The original character, storyboard, and video remain available')}</span>
- </div>
- <button type="button" onClick={storyboardReady ? generateVideo : () => setCurrentStep(1)}>
- {storyboardReady ? l(`生成 V${nextVersion}`, `Generate V${nextVersion}`) : l('完善故事与分镜', 'Complete story and storyboard')}
- </button>
- </div>
- ) : null}
- <div className="creator-result-layout">
-
- {resultTab === 'video' ? (
- <div className="video-result-pane">
- <header className="video-result-pane-heading">
- <div><h2>{l('视频成片', 'Final video')}</h2><p>{l(`V${resultVersion} 已完成`, `V${resultVersion} completed`)}</p></div>
- <button type="button" onClick={() => setNotice(l(`V${resultVersion} 已加入下载队列`, `V${resultVersion} added to the download queue`))}><Download size={15} strokeWidth={1.8} aria-hidden="true" />{l('下载视频', 'Download video')}</button>
- </header>
- <div className="stickman-video-result">
- <div><img src="/dashboard/templates/ai-video-insane.jpg" alt={l('火柴人动画预览', 'Stick figure animation preview')} /><span><Play size={22} fill="currentColor" /></span></div>
- <section><h2>{l('火柴人动画', 'stick-figure-animation')}-V{resultVersion}.mp4</h2><p>{selectedResult.ratio} · 15 {l('秒', 'sec')} · {localizeShot(selectedResult.style, l)} · {selectedResult.voiceover ? l('含配音', 'Voiceover') : l('无配音', 'No voiceover')}</p></section>
- </div>
- </div>
- ) : null}
-
- {resultTab === 'storyboard' ? (
- <div className="video-result-pane">
- <header className="video-result-pane-heading">
- <div><h2>{l('故事分镜', 'Storyboard')}</h2><p>{l(`当前版本共 ${storyboardShots.length} 个关键镜头`, `${storyboardShots.length} key shots in this version`)}</p></div>
- <button type="button" onClick={() => setCurrentStep(2)}><PanelsTopLeft size={15} strokeWidth={1.8} aria-hidden="true" />{l('调整分镜', 'Adjust storyboard')}</button>
- </header>
- <StickmanStoryboard
- ariaLabel={l(`V${resultVersion} 火柴人故事分镜`, `V${resultVersion} stick figure storyboard`)}
- subtitles={selectedResult.storyboardSubtitles}
- imageVersions={selectedResult.storyboardImageVersions}
- l={l}
+function readVisualAssetRef(
+ value: CreatorJson | undefined,
+ fallback: CreatorVisualAssetRef
+): CreatorVisualAssetRef {
+ if (value === null || value === undefined || Array.isArray(value) || typeof value !== 'object') {
+ return fallback;
+ }
+ return typeof value.assetId === 'string'
+ && typeof value.revision === 'number'
+ && Number.isSafeInteger(value.revision)
+ && value.revision > 0
+ ? { assetId: value.assetId, revision: value.revision }
+ : fallback;
+}
+
+function sameAssetRef(
+ reference: CreatorVisualAssetRef,
+ asset: Pick<CreatorVisualAssetSummary, 'id' | 'revision'>
+): boolean {
+ return reference.assetId === asset.id && reference.revision === asset.revision;
+}
+
+function assetRefKey(asset: Pick<CreatorVisualAssetSummary, 'id' | 'revision'>): string {
+ return `${asset.id}@${asset.revision}`;
+}
+
+function targetDurationPreset(value: number): string {
+ return targetDurationPresets.includes(value as (typeof targetDurationPresets)[number])
+ ? String(value)
+ : 'custom';
+}
+
+function stickmanWorkflowStep(value: unknown): number {
+ if (typeof value !== 'string') return 0;
+ if (
+ value === 'source-brief'
+ || value === 'content-plan'
+ || value === 'script'
+ ) return 1;
+ if (
+ value === 'narration'
+ || value === 'audio-timing'
+ ) return 2;
+ if (
+ value === 'storyboard'
+ || value === 'style-assets'
+ || value === 'prompt-pack'
+ || value === 'images'
+ || value === 'visual-validation'
+ ) return 3;
+ if (
+ value === 'timeline'
+ || value === 'render-clean'
+ || value === 'media-validation'
+ || value === 'package-validation'
+ ) return 4;
+ return 0;
+}
+
+function isTtsProvider(value: unknown): value is CreatorTtsProvider {
+ return value === 'openai'
+ || value === 'aliyun'
+ || value === 'minimax'
+ || value === 'edge-tts';
+}
+
+function cloneScriptManifest(value: ScriptManifest): ScriptManifest {
+ return {
+ ...value,
+ narrationBudget: { ...value.narrationBudget },
+ segments: value.segments.map(segment => ({
+ ...segment,
+ claimIds: [...segment.claimIds],
+ sourceSpanIds: [...segment.sourceSpanIds]
+ }))
+ };
+}
+
+function normalizeScriptManifest(value: ScriptManifest): ScriptManifest {
+ return {
+ ...value,
+ title: value.title.trim(),
+ language: value.language.trim(),
+ segments: value.segments.map(segment => ({
+ ...segment,
+ narration: segment.narration.trim()
+ }))
+ };
+}
+
+function validateScriptManifest(
+ value: ScriptManifest,
+ l: ReturnType<typeof useLocalizedCopy>
+): string {
+ if (value.title.length === 0) return l('请填写脚本标题', 'Enter a script title.');
+ const invalidSegment = value.segments.findIndex(segment => (
+ segment.narration.length === 0
+ ));
+ if (invalidSegment >= 0) {
+ return l(
+ `请完善第 ${invalidSegment + 1} 段旁白`,
+ `Complete the narration for segment ${invalidSegment + 1}.`
+ );
+ }
+ return '';
+}
+
+function ScriptStep(props: {
+ artifact?: CreatorArtifact;
+ script?: ScriptManifest;
+ stage?: CreatorStageRun;
+ requiresRegeneration: boolean;
+ dirty: boolean;
+ busy: boolean;
+ submitting: boolean;
+ l: ReturnType<typeof useLocalizedCopy>;
+ onChange(value: ScriptManifest): void;
+ onBack(): void;
+ onNext(): void;
+ onRetry(): void;
+}) {
+ if (props.requiresRegeneration) {
+ return (
+ <div className="stickman-script-step">
+ <div className="creator-tool-panel creator-workspace-loading" role="alert">
+ <FileText size={20} />
+ <p>{props.l(
+ '当前脚本结构已更新,请返回来源与角色重新生成',
+ 'The script structure has changed. Return to Source and character to regenerate it.'
+ )}</p>
+ </div>
+ <footer className="stickman-wizard-actions stickman-script-actions">
+ <button className="video-translation-secondary-action" type="button" onClick={props.onBack}>
+ <ArrowLeft size={16} strokeWidth={1.8} aria-hidden="true" />
+ {props.l('上一步', 'Back')}
+ </button>
+ <button className="video-translation-primary-action" type="button" disabled>
+ {props.l('下一步', 'Next')}
+ <ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" />
+ </button>
+ </footer>
+ </div>
+ );
+ }
+ if (props.artifact === undefined || props.script === undefined) {
+ return (
+ <div className="stickman-script-step">
+ <ScriptPlaceholderPanel
+ stage={props.stage}
+ busy={props.busy}
+ l={props.l}
+ onRetry={props.onRetry}
+ />
+ <footer className="stickman-wizard-actions stickman-script-actions">
+ <button className="video-translation-secondary-action" type="button" onClick={props.onBack}>
+ <ArrowLeft size={16} strokeWidth={1.8} aria-hidden="true" />
+ {props.l('上一步', 'Back')}
+ </button>
+ <button className="video-translation-primary-action" type="button" disabled>
+ {props.l('下一步', 'Next')}
+ <ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" />
+ </button>
+ </footer>
+ </div>
+ );
+ }
+ const script = props.script;
+ const totalDuration = Math.round(script.estimatedTotalDurationSeconds * 10) / 10;
+ function updateSegment(index: number, patch: Partial<ScriptManifest['segments'][number]>) {
+ props.onChange({
+ ...script,
+ segments: script.segments.map((segment, segmentIndex) => (
+ segmentIndex === index ? { ...segment, ...patch } : segment
+ ))
+ });
+ }
+ return (
+ <div className="stickman-script-step">
+ <div className="creator-tool-panel stickman-script-panel">
+ <header className="creator-tool-panel-heading">
+ <span><FileText size={18} /></span>
+ <div className="stickman-script-heading-copy">
+ <input
+ aria-label={props.l('脚本标题', 'Script title')}
+ value={script.title}
+ onChange={event => props.onChange({ ...script, title: event.target.value })}
+ />
+ <p>
+ {script.language} · {script.segments.length} {props.l('段', 'segments')}
+ {' · '}{props.l('预计', 'est.')} {totalDuration}s / {props.l('目标', 'target')} {formatSeconds(script.targetDurationSeconds)}
+ </p>
+ </div>
+ {props.dirty ? <small className="stickman-script-unsaved">{props.l('有未保存修改', 'Unsaved changes')}</small> : null}
+ </header>
+ <div className="stickman-script-editor">
+ {script.segments.map((segment, index) => (
+ <article className="stickman-script-row" key={segment.id}>
+ <div className="stickman-script-meta">
+ <strong>{String(index + 1).padStart(2, '0')}</strong>
+ <small>{props.l('预计', 'est.')} {Math.round(segment.estimatedDurationSeconds * 10) / 10}s</small>
+ </div>
+ <div className="stickman-script-fields">
+ <label>
+ <span>{props.l('旁白', 'Narration')}</span>
+ <textarea
+ rows={3}
+ value={segment.narration}
+ aria-label={props.l(`第 ${index + 1} 段旁白`, `Segment ${index + 1} narration`)}
+ onChange={event => updateSegment(index, { narration: event.target.value })}
/>
- </div>
- ) : null}
-
- {resultTab === 'character' ? (
- <div className="video-result-pane">
- <header className="video-result-pane-heading">
- <div><h2>{l('角色设定', 'Character')}</h2><p>{resultCharacterSource}</p></div>
- <button type="button" onClick={() => setCurrentStep(0)}><PersonStanding size={15} strokeWidth={1.8} aria-hidden="true" />{l('更换角色', 'Change character')}</button>
- </header>
- <div className="stickman-result-character">
- <div><CharacterArtwork image={resultCharacterImage} alt={resultCharacterName} /></div>
- <section>
- <h3>{resultCharacterName}</h3>
- <p>{selectedResult.characterSource === 'generate' ? selectedResult.characterPrompt : resultCharacterSource}</p>
- </section>
- </div>
- </div>
- ) : null}
-
- {resultTab === 'settings' ? (
- <div className="video-result-pane">
- <header className="video-result-pane-heading">
- <div><h2>{l('当前版本设置', 'Current version settings')}</h2><p>{l('调整后会生成新版本,当前结果不会被覆盖', 'Changes create a new version without overwriting the current output')}</p></div>
- <div className="video-result-pane-actions">
- <button type="button" onClick={() => setCurrentStep(0)}><PersonStanding size={15} strokeWidth={1.8} aria-hidden="true" />{l('调整角色', 'Adjust character')}</button>
- <button type="button" onClick={() => setCurrentStep(1)}><Settings2 size={15} strokeWidth={1.8} aria-hidden="true" />{l('调整故事与画面', 'Adjust story and visuals')}</button>
- <button type="button" onClick={() => { setAudioEditing(true); setCurrentStep(3); }}><Volume2 size={15} strokeWidth={1.8} aria-hidden="true" />{l('调整配音与音乐', 'Adjust voice and music')}</button>
- </div>
- </header>
- <dl className="video-result-settings">
- <div><dt>{l('角色', 'Character')}</dt><dd>{resultCharacterName}</dd></div>
- <div><dt>{l('画面风格', 'Visual style')}</dt><dd>{localizeShot(selectedResult.style, l)}</dd></div>
- <div><dt>{l('视频比例', 'Video ratio')}</dt><dd>{selectedResult.ratio}</dd></div>
- <div><dt>{l('视频时长', 'Duration')}</dt><dd>15 {l('秒', 'sec')}</dd></div>
- <div><dt>{l('配音', 'Voiceover')}</dt><dd>{resultVoiceover}</dd></div>
- <div><dt>{l('背景音乐', 'Music')}</dt><dd>{resultBackgroundMusic}</dd></div>
- <div className="stickman-result-story-setting"><dt>{l('故事创意', 'Story idea')}</dt><dd title={selectedResult.story}>{selectedResult.story}</dd></div>
- </dl>
- </div>
- ) : null}
- <CreatorTaskSummary
- sourceIcon={PersonStanding}
- sourceLabel={l('角色', 'Character')}
- sourceValue={resultCharacterName}
- items={[
- { label: l('分镜', 'Storyboard'), value: l(`${storyboardShots.length} 个镜头`, `${storyboardShots.length} shots`) },
- { label: l('画面风格', 'Visual style'), value: localizeShot(selectedResult.style, l) },
- { label: l('视频比例', 'Video ratio'), value: selectedResult.ratio },
- { label: l('配音', 'Voiceover'), value: resultVoiceover },
- { label: l('背景音乐', 'Music'), value: resultBackgroundMusic },
- { label: l('当前版本', 'Version'), value: `V${selectedResult.value}` }
- ]}
- />
+ </label>
</div>
- </section>
- ) : (
- <div className="creator-task-final-grid">
- {hasSavedResults && hasPendingChanges ? (
- <div className="stickman-version-draft" role="status">
- <div>
- <strong>{l(`正在基于 V${resultVersion} 调整`, `Adjusting from V${resultVersion}`)}</strong>
- <span>{l('原版本的角色、分镜和成片仍可查看', 'The original character, storyboard, and video remain available')}</span>
- </div>
- </div>
- ) : null}
- <section className="creator-tool-panel stickman-audio-panel" aria-labelledby="stickman-audio-title">
- <div className="creator-tool-panel-heading">
- <div><span>{l('音频设置', 'Audio settings')}</span><h2 id="stickman-audio-title">{l('配音与音乐', 'Voice and music')}</h2><p>{l('为成片添加旁白,也可以上传背景音乐', 'Add narration and optionally upload background music')}</p></div>
- </div>
- <div className="stickman-audio-settings">
- <div className="stickman-audio-layout">
- <div className="stickman-voice-settings">
- <StickmanSwitch
- checked={voiceover}
- label={l('生成旁白配音', 'Generate narration')}
- description={l('根据故事内容自动生成旁白', 'Generate narration from the story')}
- onChange={value => { setVoiceover(value); setVideoReady(false); }}
- />
- {voiceover ? (
- <div className="creator-tool-form-row">
- <label className="creator-tool-field"><span>{l('配音语言', 'Voice language')}</span><select aria-label={l('配音语言', 'Voice language')} value={voiceLanguage} onChange={event => { setVoiceLanguage(event.target.value as VoiceLanguage); setVideoReady(false); }}><option value="auto">{l('自动匹配', 'Auto match')}</option><option value="zh-CN">{l('中文', 'Chinese')}</option><option value="en-US">English</option></select></label>
- <label className="creator-tool-field"><span>{l('配音音色', 'Voice tone')}</span><select aria-label={l('配音音色', 'Voice tone')} value={voiceTone} onChange={event => { setVoiceTone(event.target.value as VoiceTone); setVideoReady(false); }}><option value="natural">{l('自然叙事', 'Natural narration')}</option><option value="energetic">{l('活力青年', 'Energetic')}</option><option value="calm">{l('沉稳讲述', 'Calm')}</option></select></label>
- </div>
- ) : null}
- </div>
- <div className="stickman-music-settings">
- <div className="stickman-music-heading"><Music2 size={16} strokeWidth={1.8} aria-hidden="true" /><span><strong>{l('背景音乐', 'Background music')}</strong><small>{l('选填', 'Optional')}</small></span></div>
- <div className="stickman-music-upload-row">
- <label className="creator-tool-upload stickman-music-upload">
- <input type="file" accept="audio/*" aria-label={l('上传背景音乐', 'Upload background music')} onChange={event => { setBackgroundMusic(event.target.files?.[0] ?? null); setVideoReady(false); }} />
- <UploadCloud size={20} strokeWidth={1.6} aria-hidden="true" />
- <strong>{backgroundMusic?.name ?? l('上传背景音乐', 'Upload background music')}</strong>
- <span>{backgroundMusic ? l('点击更换音频', 'Click to replace audio') : l('支持 MP3、WAV、M4A', 'Supports MP3, WAV, and M4A')}</span>
- </label>
- {backgroundMusic ? <button className="stickman-music-remove" type="button" onClick={() => { setBackgroundMusic(null); setVideoReady(false); }} aria-label={l('移除背景音乐', 'Remove background music')}><X size={16} strokeWidth={1.8} aria-hidden="true" /></button> : null}
- </div>
- {backgroundMusic ? (
- <label className="stickman-music-volume">
- <span>{l('音乐音量', 'Music volume')} <output>{backgroundMusicVolume}%</output></span>
- <input type="range" min="0" max="100" step="5" value={backgroundMusicVolume} aria-label={l('背景音乐音量', 'Background music volume')} onChange={event => { setBackgroundMusicVolume(Number(event.target.value)); setVideoReady(false); }} />
- </label>
- ) : null}
- </div>
+ </article>
+ ))}
+ </div>
+ </div>
+ <footer className="stickman-wizard-actions stickman-script-actions">
+ <button className="video-translation-secondary-action" type="button" disabled={props.submitting} onClick={props.onBack}>
+ <ArrowLeft size={16} strokeWidth={1.8} aria-hidden="true" />
+ {props.l('上一步', 'Back')}
+ </button>
+ <button className="video-translation-primary-action" type="button" disabled={props.busy || props.submitting} onClick={props.onNext}>
+ {props.submitting ? props.l('正在保存...', 'Saving...') : props.l('下一步', 'Next')}
+ {props.submitting
+ ? <LoaderCircle className="creator-collaboration-spin" size={16} aria-hidden="true" />
+ : <ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" />}
+ </button>
+ </footer>
+ </div>
+ );
+}
+
+function ScriptPlaceholderPanel(props: {
+ stage?: CreatorStageRun;
+ busy: boolean;
+ l: ReturnType<typeof useLocalizedCopy>;
+ onRetry(): void;
+}) {
+ const failed = props.stage?.status === 'failed';
+ return (
+ <div
+ className="creator-tool-panel stickman-script-panel stickman-script-placeholder"
+ data-state={failed ? 'failed' : 'loading'}
+ aria-busy={!failed}
+ >
+ <header className="creator-tool-panel-heading">
+ <span><FileText size={18} /></span>
+ <div className="stickman-script-placeholder-heading">
+ <h2>{props.l('脚本内容', 'Script')}</h2>
+ <p role="status">{failed ? props.l('生成失败', 'Generation failed') : props.l('正在生成', 'Generating')}</p>
+ </div>
+ {!failed ? <LoaderCircle className="creator-collaboration-spin" size={17} aria-hidden="true" /> : null}
+ </header>
+ {failed ? (
+ <div className="stickman-script-placeholder-error" role="alert">
+ <span><FileText size={20} /></span>
+ <strong>{props.l('脚本生成失败', 'Script generation failed')}</strong>
+ <p>{props.stage?.errorMessage ?? props.l('生成脚本时出现问题,请重新生成', 'Something went wrong while generating the script.')}</p>
+ <button
+ className="video-translation-secondary-action"
+ type="button"
+ disabled={props.busy}
+ onClick={props.onRetry}
+ >
+ <RefreshCw size={15} aria-hidden="true" />
+ {props.l('重新生成', 'Regenerate')}
+ </button>
+ </div>
+ ) : (
+ <div className="stickman-script-editor stickman-script-skeleton-editor" aria-hidden="true">
+ {[0, 1, 2].map(index => (
+ <article className="stickman-script-row stickman-script-skeleton-row" key={index}>
+ <div className="stickman-script-meta">
+ <strong>{String(index + 1).padStart(2, '0')}</strong>
+ <i className="stickman-script-skeleton-duration" />
+ </div>
+ <div className="stickman-script-skeleton-fields">
+ <div>
+ <span>{props.l('旁白', 'Narration')}</span>
+ <div className="stickman-script-skeleton-box is-narration">
+ <i />
+ <i className="is-medium" />
+ <i className="is-short" />
</div>
</div>
- </section>
- <CreatorTaskSummary
- sourceIcon={PersonStanding}
- sourceLabel={l('角色', 'Character')}
- sourceValue={taskCharacterName}
- items={[
- { label: l('分镜', 'Storyboard'), value: l(`${storyboardShots.length} 个镜头`, `${storyboardShots.length} shots`) },
- { label: l('画面风格', 'Visual style'), value: localizeShot(style, l) },
- { label: l('视频比例', 'Video ratio'), value: ratio },
- { label: l('配音', 'Voiceover'), value: taskVoiceover },
- { label: l('背景音乐', 'Music'), value: taskBackgroundMusic },
- { label: l('视频时长', 'Duration'), value: l('15 秒', '15 sec') }
- ]}
- note={l('分镜、配音与音乐设置将用于生成成片', 'Storyboard, voice, and music settings will be used for the final video')}
- noteIcon={Volume2}
- />
- </div>
- )
- ) : null}
- {notice ? <p className="creator-tool-notice" role="status">{notice}</p> : null}
+ </div>
+ </article>
+ ))}
</div>
+ )}
+ </div>
+ );
+}
- {currentStep < 3 || audioEditing || !hasSavedResults ? (
- <footer className="video-translation-wizard-actions stickman-wizard-actions">
- {currentStep > 0 ? (
- <button className="video-translation-secondary-action" type="button" onClick={() => setCurrentStep((currentStep - 1) as StickmanStep)}>
- <ArrowLeft size={16} strokeWidth={1.8} aria-hidden="true" />
- {l('上一步', 'Back')}
- </button>
- ) : <span />}
- <div className="video-translation-action-group">
- {currentStep === 0 && characterMode === 'generate' ? (
- <button className="video-translation-secondary-action" type="button" onClick={generateCharacter}>
- <Sparkles size={15} strokeWidth={1.8} aria-hidden="true" />
- {l('生成角色形象', 'Generate character')}
- </button>
- ) : null}
- {currentStep === 0 ? (
- <button className="video-translation-primary-action" type="button" disabled={!characterReady} onClick={continueToStory}>
- {l('下一步:故事与分镜', 'Next: Story and storyboard')}
- <ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" />
- </button>
- ) : currentStep === 1 ? (
- <button className="video-translation-primary-action" type="button" disabled={!characterReady || !story.trim()} onClick={storyboardReady ? continueToVideo : generateStoryboard}>
- {storyboardReady ? l('下一步:查看分镜', 'Next: Review storyboard') : l('生成分镜图', 'Generate storyboard')}
- {storyboardReady ? <ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" /> : null}
- </button>
- ) : currentStep === 2 ? (
- <button className="video-translation-primary-action" type="button" onClick={continueToAudio}>
- {l('下一步:配音与音乐', 'Next: Voice and music')}
- <ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" />
- </button>
- ) : (
- <button className="video-translation-primary-action" type="button" onClick={generateVideo}>
- <Play size={16} strokeWidth={1.8} aria-hidden="true" />
- {hasSavedResults ? l(`生成 V${nextVersion}`, `Generate V${nextVersion}`) : l('根据分镜生成视频', 'Generate video from storyboard')}
- </button>
- )}
+function AudioStep(props: {
+ script?: ScriptManifest;
+ timing?: AudioTiming;
+ timingStage?: CreatorStageRun;
+ artifacts: CreatorArtifact[];
+ stages: CreatorStageRun[];
+ voiceName: string;
+ targetLanguage: string;
+ busy: boolean;
+ l: ReturnType<typeof useLocalizedCopy>;
+ onBack(): void;
+ onNext(): void;
+ onRetry(stage: CreatorStageRun): void;
+}) {
+ const timingBySegment = new Map(
+ props.timing?.segments.map(segment => [segment.segmentId, segment]) ?? []
+ );
+ const segments = props.script?.segments ?? [];
+ const readyCount = segments.filter(segment => props.artifacts.some(artifact => (
+ artifact.kind === 'narration_audio'
+ && artifact.scopeKey === segment.id
+ && artifact.status === 'completed'
+ ))).length;
+ return (
+ <div className="stickman-audio-step">
+ <div className="creator-tool-panel stickman-audio-review">
+ <header className="creator-tool-panel-heading">
+ <span><Volume2 size={18} /></span>
+ <div>
+ <h2>{props.l('配音与节奏', 'Voice and timing')}</h2>
+ <p>
+ {props.timing
+ ? props.l(
+ `${segments.length} 段旁白 · 实际 ${formatSeconds(props.timing.totalDurationSeconds)} · 目标 ${formatSeconds(props.script?.targetDurationSeconds ?? props.timing.totalDurationSeconds)}`,
+ `${segments.length} narration segments · ${formatSeconds(props.timing.totalDurationSeconds)} actual · ${formatSeconds(props.script?.targetDurationSeconds ?? props.timing.totalDurationSeconds)} target`
+ )
+ : props.l(
+ `正在生成旁白 ${readyCount}/${segments.length}`,
+ `Generating narration ${readyCount}/${segments.length}`
+ )}
+ </p>
+ </div>
+ <div className="stickman-audio-meta">
+ <strong>{props.voiceName || props.l('服务默认音色', 'Service default voice')}</strong>
+ <small>{props.targetLanguage}</small>
+ </div>
+ </header>
+ <div className="stickman-audio-segments">
+ {segments.length === 0 ? (
+ <div className="stickman-inline-empty">
+ <FileAudio size={20} />
+ <span>{props.l('正在准备配音内容', 'Preparing narration content.')}</span>
</div>
- </footer>
- ) : null}
+ ) : segments.map((segment, index) => {
+ const timing = timingBySegment.get(segment.id);
+ const artifact = timing === undefined
+ ? [...props.artifacts].reverse().find(candidate => (
+ candidate.kind === 'narration_audio'
+ && candidate.scopeKey === segment.id
+ && candidate.status === 'completed'
+ ))
+ : props.artifacts.find(candidate => candidate.id === timing.audioArtifactId);
+ const stage = latestScopedStage(props.stages, 'narration', segment.id);
+ return (
+ <NarrationRow
+ key={segment.id}
+ index={index}
+ narration={segment.narration}
+ durationSeconds={timing?.durationSeconds ?? readArtifactDuration(artifact)}
+ artifact={artifact}
+ stage={stage}
+ l={props.l}
+ onRetry={() => stage && props.onRetry(stage)}
+ />
+ );
+ })}
+ </div>
</div>
- </CreatorToolShell>
- {storyboardDialog && dialogShot ? (
- <StickmanPromptDialog
- mode={storyboardDialog.mode}
- shot={dialogShot}
- shotIndex={storyboardDialog.shotIndex}
- story={story}
- characterName={taskCharacterName}
- style={localizeShot(style, l)}
- ratio={ratio}
- promptOverride={storyboardPromptOverrides[storyboardDialog.shotIndex]}
- l={l}
- onClose={() => setStoryboardDialog(null)}
- onRegenerate={prompt => {
- regenerateStoryboardImage(storyboardDialog.shotIndex, prompt);
- setStoryboardDialog(null);
- }}
+ {props.timingStage?.status === 'failed' && props.timing === undefined ? (
+ <footer className="stickman-wizard-actions stickman-script-actions">
+ <button className="video-translation-secondary-action" type="button" onClick={props.onBack}>
+ <ArrowLeft size={16} strokeWidth={1.8} aria-hidden="true" />
+ {props.l('上一步', 'Back')}
+ </button>
+ <button className="video-translation-primary-action" type="button" onClick={() => props.onRetry(props.timingStage!)}>
+ <RefreshCw size={16} aria-hidden="true" />
+ {props.l('重新测量时长', 'Measure timing again')}
+ </button>
+ </footer>
+ ) : (
+ <WizardActions
+ busy={props.busy}
+ canContinue={props.timing !== undefined}
+ pendingLabel={props.l('配音生成中...', 'Generating narration...')}
+ l={props.l}
+ onBack={props.onBack}
+ onNext={props.onNext}
/>
- ) : null}
- </>
+ )}
+ </div>
);
}
-function StickmanSwitch(props: {
- checked: boolean;
- label: string;
- description: string;
- onChange(checked: boolean): void;
+function NarrationRow(props: {
+ index: number;
+ narration: string;
+ durationSeconds?: number;
+ artifact?: CreatorArtifact;
+ stage?: CreatorStageRun;
+ l: ReturnType<typeof useLocalizedCopy>;
+ onRetry(): void;
}) {
+ const url = useArtifactUrl(props.artifact?.id);
+ const failed = props.stage?.status === 'failed';
+ const running = props.stage?.status === 'running' || props.stage?.status === 'queued';
return (
- <div className="video-translation-toggle-row">
- <span><strong>{props.label}</strong><small>{props.description}</small></span>
- <button className="video-translation-switch" type="button" role="switch" aria-checked={props.checked} aria-label={props.label} onClick={() => props.onChange(!props.checked)}><span /></button>
+ <article className="stickman-audio-row" data-status={failed ? 'failed' : url ? 'ready' : running ? 'running' : 'waiting'}>
+ <div className="stickman-audio-index">
+ <strong>{String(props.index + 1).padStart(2, '0')}</strong>
+ <small>{props.durationSeconds === undefined ? '--' : formatSeconds(props.durationSeconds)}</small>
+ </div>
+ <p>{props.narration}</p>
+ <div className="stickman-audio-control">
+ {url ? <audio controls preload="metadata" src={url} /> : null}
+ {!url && running ? <span><LoaderCircle className="creator-collaboration-spin" size={16} />{props.l('生成中', 'Generating')}</span> : null}
+ {!url && !running && !failed ? <span><Clock3 size={16} />{props.l('等待生成', 'Waiting')}</span> : null}
+ {failed ? (
+ <button type="button" onClick={props.onRetry}>
+ <RefreshCw size={15} />{props.l('重试', 'Retry')}
+ </button>
+ ) : null}
+ </div>
+ </article>
+ );
+}
+
+function StoryboardStep(props: {
+ jobStages: CreatorStageRun[];
+ shotSpec?: ShotSpec;
+ script?: ScriptManifest;
+ timing?: AudioTiming;
+ artifacts: CreatorArtifact[];
+ busy: boolean;
+ batchGenerationPending: boolean;
+ savingShotId?: string;
+ regenerationRequests: Record<string, string | null>;
+ l: ReturnType<typeof useLocalizedCopy>;
+ onSave(shotId: string, visualDescription: string, motion: string): Promise<void>;
+ onRegenerate(shotId: string): void;
+ onGenerateMissing(): void;
+ onBack(): void;
+ onNext(): void;
+}) {
+ if (props.shotSpec === undefined) {
+ return (
+ <div className="stickman-storyboard-step">
+ <StoryboardPlaceholderPanel
+ script={props.script}
+ timing={props.timing}
+ l={props.l}
+ />
+ <WizardActions
+ canContinue={false}
+ busy={props.busy}
+ pendingLabel={props.l('正在准备画面...', 'Preparing visuals...')}
+ l={props.l}
+ onBack={props.onBack}
+ onNext={props.onNext}
+ />
+ </div>
+ );
+ }
+ const readyCount = props.shotSpec.shots.filter(shot => {
+ const stage = latestShotStage(props.jobStages, shot.id);
+ return latestShotImage(props.artifacts, shot.id, stage?.inputFingerprint ?? null) !== undefined;
+ }).length;
+ const visualValidation = latestCompleted(props.artifacts, 'visual_validation');
+ const visualValidationStage = latestStage(props.jobStages, 'visual-validation');
+ const failedCount = props.shotSpec.shots.filter(shot => {
+ const stage = latestShotStage(props.jobStages, shot.id);
+ const image = latestShotImage(props.artifacts, shot.id, stage?.inputFingerprint ?? null);
+ return image === undefined && stage?.status === 'failed';
+ }).length;
+ const imageGenerationActive = props.jobStages.some(stage => (
+ stage.stageId === 'images' && (stage.status === 'queued' || stage.status === 'running')
+ ));
+ const visualValidationActive = visualValidationStage?.status === 'queued'
+ || visualValidationStage?.status === 'running';
+ const visualValidationFailed = visualValidationStage?.status === 'failed';
+ const canContinue = readyCount === props.shotSpec.shots.length
+ && props.shotSpec.shots.length > 0
+ && visualValidation !== undefined;
+ return (
+ <div className="stickman-storyboard-step">
+ <div className="creator-tool-panel stickman-storyboard-review">
+ <header className="creator-tool-panel-heading"><span><ImageIcon size={18} /></span><div><h2>{props.l('分镜与画面', 'Storyboard and visuals')}</h2><p>{props.l(`${props.shotSpec.shots.length} 个镜头 · 画面已生成 ${readyCount}/${props.shotSpec.shots.length}`, `${props.shotSpec.shots.length} shots · ${readyCount}/${props.shotSpec.shots.length} visuals generated`)}</p></div></header>
+ <div className="stickman-storyboard-editor">
+ {props.shotSpec.shots.map((shot, index) => {
+ const stage = latestShotStage(props.jobStages, shot.id);
+ const image = latestShotImage(props.artifacts, shot.id, stage?.inputFingerprint ?? null);
+ const narration = props.script?.segments.find(segment => segment.id === shot.sourceSegmentId)?.narration;
+ return (
+ <StoryboardShotRow
+ key={shot.id}
+ index={index}
+ shot={shot}
+ stage={stage}
+ image={image}
+ narration={narration}
+ saving={props.savingShotId === shot.id}
+ regenerationRequested={Object.hasOwn(props.regenerationRequests, shot.id)}
+ l={props.l}
+ onSave={props.onSave}
+ onRegenerate={props.onRegenerate}
+ />
+ );
+ })}
+ </div>
+ </div>
+ <StoryboardStepActions
+ canContinue={canContinue}
+ busy={props.busy}
+ batchGenerationPending={props.batchGenerationPending}
+ totalCount={props.shotSpec.shots.length}
+ readyCount={readyCount}
+ failedCount={failedCount}
+ imageGenerationActive={imageGenerationActive}
+ visualValidationActive={visualValidationActive}
+ visualValidationFailed={visualValidationFailed}
+ l={props.l}
+ onBack={props.onBack}
+ onGenerateMissing={props.onGenerateMissing}
+ onNext={props.onNext}
+ />
</div>
);
}
-function StickmanStoryboard(props: {
- ariaLabel: string;
- subtitles: string[];
- imageVersions: number[];
- editable?: boolean;
+function StoryboardShotRow(props: {
+ index: number;
+ shot: ShotSpec['shots'][number];
+ stage?: CreatorStageRun;
+ image?: CreatorArtifact;
+ narration?: string;
+ saving: boolean;
+ regenerationRequested: boolean;
l: ReturnType<typeof useLocalizedCopy>;
- onSubtitleChange?(index: number, value: string): void;
- onRegenerateRequest?(index: number): void;
- onViewPrompt?(index: number): void;
+ onSave(shotId: string, visualDescription: string, motion: string): Promise<void>;
+ onRegenerate(shotId: string): void;
}) {
+ const [visualDescription, setVisualDescription] = useState(props.shot.visualDescription);
+ const [motion, setMotion] = useState(props.shot.motion);
+ useEffect(() => {
+ setVisualDescription(props.shot.visualDescription);
+ setMotion(props.shot.motion);
+ }, [props.shot.id, props.shot.motion, props.shot.visualDescription]);
+
+ const stageActive = props.stage?.status === 'queued' || props.stage?.status === 'running';
+ const generating = props.regenerationRequested || stageActive;
+ const dirty = visualDescription !== props.shot.visualDescription || motion !== props.shot.motion;
+ const percent = typeof props.stage?.progress.percent === 'number'
+ ? Math.max(0, Math.min(100, Math.round(props.stage.progress.percent)))
+ : undefined;
+ const generationStatus = props.regenerationRequested && !stageActive
+ ? props.l('请求已提交,等待生成', 'Request submitted. Waiting to generate.')
+ : props.stage?.status === 'queued'
+ ? props.l('已进入生成队列', 'Queued for generation.')
+ : props.stage?.status === 'running'
+ ? props.l(
+ `正在生成画面${percent === undefined ? '' : ` · ${percent}%`}`,
+ `Generating visual${percent === undefined ? '' : ` · ${percent}%`}`
+ )
+ : props.stage?.status === 'failed'
+ ? props.stage.errorMessage ?? props.l('画面生成失败', 'Visual generation failed.')
+ : '';
+
+ return (
+ <article className="stickman-storyboard-row" data-status={generating ? 'generating' : props.stage?.status}>
+ <div className="stickman-storyboard-meta">
+ <strong>{String(props.index + 1).padStart(2, '0')}</strong>
+ <small>{formatSeconds(props.shot.durationSeconds)}</small>
+ </div>
+ <ShotPreview artifact={props.image} status={props.stage?.status} pending={props.regenerationRequested} l={props.l} />
+ <div className="stickman-storyboard-copy">
+ <label className="stickman-storyboard-description">
+ <strong>{props.l('画面描述', 'Visual description')}</strong>
+ <textarea
+ aria-label={props.l(`第 ${props.index + 1} 个镜头画面描述`, `Visual description for shot ${props.index + 1}`)}
+ value={visualDescription}
+ disabled={props.saving || generating}
+ onChange={event => setVisualDescription(event.target.value)}
+ />
+ </label>
+ {props.narration ? (
+ <div className="stickman-storyboard-narration">
+ <span>{props.l('旁白(来自脚本)', 'Narration (from script)')}</span>
+ <p>{props.narration}</p>
+ </div>
+ ) : null}
+ <label className="stickman-storyboard-motion">
+ <span>{props.l('镜头运动', 'Motion')}</span>
+ <select
+ aria-label={props.l(`第 ${props.index + 1} 个镜头运动`, `Motion for shot ${props.index + 1}`)}
+ value={motion}
+ disabled={props.saving || generating}
+ onChange={event => setMotion(event.target.value)}
+ >
+ <option value="static">{props.l('静止', 'Static')}</option>
+ <option value="push-in">{props.l('推进', 'Push in')}</option>
+ <option value="zoom-out">{props.l('拉远', 'Zoom out')}</option>
+ <option value="pan-left">{props.l('向左平移', 'Pan left')}</option>
+ <option value="pan-right">{props.l('向右平移', 'Pan right')}</option>
+ </select>
+ </label>
+ <div className="stickman-storyboard-actions">
+ {dirty ? (
+ <button
+ className="stickman-storyboard-prompt"
+ type="button"
+ disabled={props.saving || generating || visualDescription.trim() === ''}
+ onClick={() => void props.onSave(props.shot.id, visualDescription, motion)}
+ >
+ {props.saving
+ ? <LoaderCircle className="creator-collaboration-spin" size={15} aria-hidden="true" />
+ : <Check size={15} aria-hidden="true" />}
+ {props.saving ? props.l('保存中...', 'Saving...') : props.l('保存修改', 'Save changes')}
+ </button>
+ ) : null}
+ {!generating && props.stage?.status === 'failed' && props.image === undefined ? (
+ <button
+ className="stickman-storyboard-regenerate"
+ type="button"
+ disabled={props.saving || dirty}
+ onClick={() => props.onRegenerate(props.shot.id)}
+ >
+ <RefreshCw size={15} aria-hidden="true" />
+ {props.l('单独重试', 'Retry this shot')}
+ </button>
+ ) : null}
+ {!generating && props.image !== undefined ? (
+ <button
+ className="stickman-storyboard-regenerate"
+ type="button"
+ disabled={props.saving || dirty}
+ onClick={() => props.onRegenerate(props.shot.id)}
+ >
+ <RefreshCw size={15} aria-hidden="true" />
+ {props.l('重新生成', 'Regenerate')}
+ </button>
+ ) : null}
+ {!generating && props.image === undefined && props.stage?.status !== 'failed' ? (
+ <span className="stickman-storyboard-waiting"><Clock3 size={15} />{props.l('等待生成', 'Waiting')}</span>
+ ) : null}
+ {generationStatus !== '' ? (
+ <span
+ className="stickman-storyboard-generation-status"
+ data-status={props.stage?.status ?? 'submitting'}
+ role="status"
+ >
+ {generationStatus}
+ </span>
+ ) : null}
+ </div>
+ </div>
+ </article>
+ );
+}
+
+function StoryboardPlaceholderPanel(props: {
+ script?: ScriptManifest;
+ timing?: AudioTiming;
+ l: ReturnType<typeof useLocalizedCopy>;
+}) {
+ const timingBySegment = new Map(
+ props.timing?.segments.map(segment => [segment.segmentId, segment]) ?? []
+ );
+ const segments = props.script?.segments ?? [];
+ const rows = segments.length > 0
+ ? segments.map(segment => ({
+ id: segment.id,
+ narration: segment.narration,
+ durationSeconds: timingBySegment.get(segment.id)?.durationSeconds
+ ?? segment.estimatedDurationSeconds
+ }))
+ : [0, 1, 2].map(index => ({
+ id: `pending-${index}`,
+ narration: '',
+ durationSeconds: undefined
+ }));
+
return (
- <div className="stickman-storyboard-editor" aria-label={props.ariaLabel}>
- {storyboardShots.map((shot, index) => {
- const imageVersion = props.imageVersions[index] ?? 0;
- const title = props.l(shot.titleZh, shot.titleEn);
- return (
- <article className="stickman-storyboard-row" key={shot.titleZh}>
+ <div
+ className="creator-tool-panel stickman-storyboard-review stickman-storyboard-placeholder"
+ aria-busy="true"
+ >
+ <header className="creator-tool-panel-heading">
+ <span><ImageIcon size={18} /></span>
+ <div>
+ <h2>{props.l('分镜与画面', 'Storyboard and visuals')}</h2>
+ <p role="status">
+ {segments.length > 0
+ ? props.l(
+ `正在规划 ${segments.length} 个镜头的画面描述`,
+ `Planning visual descriptions for ${segments.length} shots`
+ )
+ : props.l('正在读取旁白并规划分镜', 'Reading narration and planning the storyboard')}
+ </p>
+ </div>
+ <LoaderCircle className="creator-collaboration-spin" size={17} aria-hidden="true" />
+ </header>
+ <div className="stickman-storyboard-editor">
+ {rows.map((row, index) => (
+ <article
+ className="stickman-storyboard-row stickman-storyboard-loading-row"
+ data-status="planning"
+ key={row.id}
+ >
<div className="stickman-storyboard-meta">
- <strong>{title}</strong>
- <small>{shot.duration}</small>
+ <strong>{String(index + 1).padStart(2, '0')}</strong>
+ <small>
+ {row.durationSeconds === undefined ? '--' : formatSeconds(row.durationSeconds)}
+ </small>
</div>
<div className="stickman-storyboard-media">
- <div className="stickman-storyboard-image">
- <img
- src={`/dashboard/templates/ai-video-insane.jpg?shot=${index + 1}&version=${imageVersion}`}
- alt={props.l(`分镜 ${index + 1}:${title}`, `Shot ${index + 1}: ${title}`)}
- data-image-version={imageVersion}
- style={{ objectPosition: storyboardImagePosition(index, imageVersion) }}
- />
- <span aria-hidden="true">{index + 1}</span>
- </div>
- {props.editable ? (
- <div className="stickman-storyboard-actions">
- <button
- className="stickman-storyboard-regenerate"
- type="button"
- aria-label={props.l(`重新生成分镜 ${index + 1} 图片`, `Regenerate image for shot ${index + 1}`)}
- onClick={() => props.onRegenerateRequest?.(index)}
- >
- <RefreshCw size={12} strokeWidth={1.8} aria-hidden="true" />
- {props.l('重新生成', 'Regenerate')}
- </button>
- <button
- className="stickman-storyboard-prompt"
- type="button"
- aria-label={props.l(`查看分镜 ${index + 1} 提示词`, `View prompt for shot ${index + 1}`)}
- onClick={() => props.onViewPrompt?.(index)}
- >
- <Eye size={12} strokeWidth={1.8} aria-hidden="true" />
- {props.l('查看提示词', 'View prompt')}
- </button>
+ <div className="stickman-storyboard-image stickman-storyboard-placeholder-image">
+ <div className="stickman-storyboard-placeholder-image-status">
+ <LoaderCircle className="creator-collaboration-spin" size={17} aria-hidden="true" />
+ <small>{props.l('准备画面', 'Preparing visual')}</small>
</div>
- ) : null}
+ </div>
</div>
<div className="stickman-storyboard-copy">
- {props.editable ? (
- <label className="creator-tool-field stickman-storyboard-subtitle">
- <textarea
- aria-label={props.l(`分镜 ${index + 1} 字幕`, `Subtitle for shot ${index + 1}`)}
- rows={2}
- value={props.subtitles[index] ?? ''}
- onChange={event => props.onSubtitleChange?.(index, event.target.value)}
- />
- </label>
+ <strong>{props.l('画面描述', 'Visual description')}</strong>
+ <div
+ className="stickman-storyboard-description-skeleton"
+ aria-label={props.l('正在生成画面描述', 'Generating visual description')}
+ >
+ <i />
+ <i className="is-medium" />
+ </div>
+ {row.narration !== '' ? (
+ <div className="stickman-storyboard-narration">
+ <span>{props.l('旁白', 'Narration')}</span>
+ <p>{row.narration}</p>
+ </div>
) : (
- <div className="stickman-storyboard-readonly-subtitle">
- <p>{props.subtitles[index]}</p>
+ <div className="stickman-storyboard-narration-skeleton" aria-hidden="true">
+ <i />
+ <i className="is-short" />
</div>
)}
</div>
</article>
- );
- })}
+ ))}
+ </div>
</div>
);
}
-function StickmanPromptDialog(props: {
- mode: 'view' | 'regenerate';
- shot: (typeof storyboardShots)[number];
- shotIndex: number;
- story: string;
- characterName: string;
- style: string;
- ratio: '16:9' | '9:16' | '1:1';
- promptOverride?: string | null;
+function StoryboardStepActions(props: {
+ canContinue: boolean;
+ busy: boolean;
+ batchGenerationPending: boolean;
+ totalCount: number;
+ readyCount: number;
+ failedCount: number;
+ imageGenerationActive: boolean;
+ visualValidationActive: boolean;
+ visualValidationFailed: boolean;
l: ReturnType<typeof useLocalizedCopy>;
- onClose(): void;
- onRegenerate(prompt: string): void;
+ onBack(): void;
+ onGenerateMissing(): void;
+ onNext(): void;
}) {
- const dialogRef = useRef<HTMLElement>(null);
- const closeRef = useRef<HTMLButtonElement>(null);
- const onCloseRef = useRef(props.onClose);
- const [prompt, setPrompt] = useState(() => props.promptOverride ?? createStoryboardImagePrompt(props));
+ const batchBusy = props.batchGenerationPending
+ || props.imageGenerationActive
+ || props.visualValidationActive
+ || props.busy;
+ const remainingCount = Math.max(0, props.totalCount - props.readyCount);
+ const label = props.canContinue
+ ? props.l('下一步', 'Next')
+ : props.batchGenerationPending
+ ? props.l('正在准备续跑...', 'Preparing to continue...')
+ : props.imageGenerationActive
+ ? props.l(
+ `正在生成 ${props.readyCount}/${props.totalCount}`,
+ `Generating ${props.readyCount}/${props.totalCount}`
+ )
+ : props.visualValidationActive
+ ? props.l('正在检查画面...', 'Validating visuals...')
+ : props.busy
+ ? props.l('正在准备画面...', 'Preparing visuals...')
+ : props.failedCount > 0
+ ? props.l(
+ `重试失败并继续(${props.failedCount} 个失败)`,
+ `Retry failures and continue (${props.failedCount} failed)`
+ )
+ : props.readyCount === 0
+ ? props.l(
+ `生成全部画面(${props.totalCount})`,
+ `Generate all visuals (${props.totalCount})`
+ )
+ : remainingCount > 0
+ ? props.l(
+ `继续生成剩余 ${remainingCount} 个`,
+ `Generate the remaining ${remainingCount}`
+ )
+ : props.visualValidationFailed
+ ? props.l('重新检查画面', 'Retry visual validation')
+ : props.l('继续完成画面检查', 'Continue visual validation');
+ return (
+ <footer className="stickman-wizard-actions stickman-script-actions stickman-storyboard-step-actions">
+ <button className="video-translation-secondary-action" type="button" onClick={props.onBack}>
+ <ArrowLeft size={16} strokeWidth={1.8} aria-hidden="true" />
+ {props.l('上一步', 'Back')}
+ </button>
+ <button
+ className="video-translation-primary-action stickman-storyboard-batch-action"
+ type="button"
+ disabled={props.canContinue ? props.busy : batchBusy || props.totalCount === 0}
+ onClick={props.canContinue ? props.onNext : props.onGenerateMissing}
+ >
+ {batchBusy && !props.canContinue
+ ? <LoaderCircle className="creator-collaboration-spin" size={16} aria-hidden="true" />
+ : null}
+ {label}
+ {!batchBusy || props.canContinue
+ ? props.visualValidationFailed && !props.canContinue
+ ? <RefreshCw size={16} strokeWidth={1.8} aria-hidden="true" />
+ : <ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" />
+ : null}
+ </button>
+ </footer>
+ );
+}
- useEffect(() => {
- onCloseRef.current = props.onClose;
- }, [props.onClose]);
+function WizardActions(props: {
+ canContinue: boolean;
+ busy: boolean;
+ pendingLabel: string;
+ l: ReturnType<typeof useLocalizedCopy>;
+ onBack(): void;
+ onNext(): void;
+}) {
+ return (
+ <footer className="stickman-wizard-actions stickman-script-actions stickman-storyboard-step-actions">
+ <button className="video-translation-secondary-action" type="button" onClick={props.onBack}>
+ <ArrowLeft size={16} strokeWidth={1.8} aria-hidden="true" />
+ {props.l('上一步', 'Back')}
+ </button>
+ <button
+ className="video-translation-primary-action"
+ type="button"
+ disabled={props.busy || !props.canContinue}
+ onClick={props.onNext}
+ >
+ {props.busy ? props.pendingLabel : props.l('下一步', 'Next')}
+ {props.busy
+ ? <LoaderCircle className="creator-collaboration-spin" size={16} aria-hidden="true" />
+ : <ArrowRight size={16} strokeWidth={1.8} aria-hidden="true" />}
+ </button>
+ </footer>
+ );
+}
- useEffect(() => {
- const previousFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
- const previousOverflow = document.body.style.overflow;
- document.body.style.overflow = 'hidden';
- closeRef.current?.focus();
-
- function handleKeyDown(event: KeyboardEvent) {
- if (event.key === 'Escape') {
- event.preventDefault();
- onCloseRef.current();
- return;
- }
- if (event.key !== 'Tab') return;
-
- const focusable = Array.from(dialogRef.current?.querySelectorAll<HTMLElement>('button, textarea, [tabindex]:not([tabindex="-1"])') ?? [])
- .filter(element => !element.hasAttribute('disabled'));
- if (focusable.length === 0) return;
- const first = focusable[0]!;
- const last = focusable[focusable.length - 1]!;
- if (event.shiftKey && document.activeElement === first) {
- event.preventDefault();
- last.focus();
- } else if (!event.shiftKey && document.activeElement === last) {
- event.preventDefault();
- first.focus();
- }
- }
+function ShotPreview(props: { artifact?: CreatorArtifact; status?: CreatorStageRun['status']; pending?: boolean; l: ReturnType<typeof useLocalizedCopy> }) {
+ const url = useArtifactUrl(props.artifact?.id);
+ const generating = props.pending || props.status === 'running' || props.status === 'queued';
+ return (
+ <div className="stickman-storyboard-media">
+ <div className="stickman-storyboard-image">
+ {url ? <img src={url} alt={props.l('镜头画面', 'Shot visual')} /> : null}
+ {generating ? (
+ <span aria-label={props.l('正在重新生成画面', 'Regenerating visual')}>
+ <LoaderCircle className="creator-collaboration-spin" size={18} />
+ </span>
+ ) : !url ? <span><ImageIcon size={18} /></span> : null}
+ </div>
+ </div>
+ );
+}
- document.addEventListener('keydown', handleKeyDown);
- return () => {
- document.removeEventListener('keydown', handleKeyDown);
- document.body.style.overflow = previousOverflow;
- previousFocused?.focus();
- };
- }, []);
+const compositionPhases = [
+ { id: 'timeline', stageIds: ['timeline'], icon: Captions },
+ { id: 'clean-render', stageIds: ['render-clean', 'media-validation'], icon: Film },
+ { id: 'delivery', stageIds: ['package-validation'], icon: Download }
+] as const;
- return createPortal(
- <div
- className="stickman-prompt-backdrop"
- onMouseDown={event => {
- if (event.target === event.currentTarget) props.onClose();
- }}
- >
- <section
- ref={dialogRef}
- className="stickman-prompt-dialog"
- role="dialog"
- aria-modal="true"
- aria-labelledby="stickman-prompt-dialog-title"
- >
- <header>
- <div>
- <span>{props.l(`分镜 ${props.shotIndex + 1},${props.shot.titleZh},${props.shot.duration}`, `Shot ${props.shotIndex + 1}, ${props.shot.titleEn}, ${props.shot.duration}`)}</span>
- <h2 id="stickman-prompt-dialog-title">
- {props.mode === 'regenerate' ? props.l('重新生成图片', 'Regenerate image') : props.l('画面提示词', 'Image prompt')}
- </h2>
+function CompositionStep(props: {
+ stages: CreatorStageRun[];
+ deliveryReady: boolean;
+ l: ReturnType<typeof useLocalizedCopy>;
+ onBack(): void;
+ onRetry(): void;
+}) {
+ const failed = [...props.stages].reverse().find(stage => (
+ stickmanWorkflowStep(stage.stageId) === 4 && stage.status === 'failed'
+ ));
+ return (
+ <div className="stickman-composition-step">
+ <div className="stickman-composition-content">
+ <div className="creator-tool-panel stickman-composition-panel">
+ <header className="creator-tool-panel-heading">
+ <span><Film size={18} /></span>
+ <div>
+ <h2>{props.l('动画合成', 'Video composition')}</h2>
+ <p>{props.deliveryReady
+ ? props.l('合成流程已完成,可在成片交付中预览和下载文件', 'Composition is complete. Preview and download files from Video delivery.')
+ : props.l('正在按真实时间线生成字幕并合成视频', 'Generating subtitles and composing the video from the real timeline.')}</p>
+ </div>
+ </header>
+ <div className="stickman-composition-phases" aria-label={props.l('合成进度', 'Composition progress')}>
+ {compositionPhases.map(phase => {
+ const status = compositionPhaseStatus(props.stages, [...phase.stageIds]);
+ const Icon = phase.icon;
+ return (
+ <div key={phase.id} data-status={status}>
+ <span><Icon size={16} /></span>
+ <div>
+ <strong>{compositionPhaseLabel(phase.id, props.l)}</strong>
+ <small>{compositionStatusLabel(status, props.l)}</small>
+ </div>
+ {status === 'completed' ? <Check size={16} /> : null}
+ {status === 'running' ? <LoaderCircle className="creator-collaboration-spin" size={16} /> : null}
+ {status === 'failed' ? <X size={16} /> : null}
+ {status === 'waiting' ? <Circle size={14} /> : null}
+ </div>
+ );
+ })}
</div>
- <button ref={closeRef} type="button" aria-label={props.l('关闭提示词', 'Close prompt')} onClick={props.onClose}>
- <X size={17} strokeWidth={1.8} aria-hidden="true" />
+ </div>
+ </div>
+ <footer className="stickman-wizard-actions stickman-script-actions">
+ <button className="video-translation-secondary-action" type="button" onClick={props.onBack}>
+ <ArrowLeft size={16} strokeWidth={1.8} aria-hidden="true" />
+ {props.l('上一步', 'Back')}
+ </button>
+ {failed !== undefined ? (
+ <button className="video-translation-primary-action" type="button" onClick={props.onRetry}>
+ <RefreshCw size={16} />{props.l('重试失败步骤', 'Retry failed step')}
</button>
- </header>
- <label className="stickman-prompt-content">
- <span>{props.mode === 'regenerate' ? props.l('可编辑提示词', 'Editable prompt') : props.l('完整提示词', 'Full prompt')}</span>
- <textarea
- readOnly={props.mode === 'view'}
- rows={10}
- aria-label={props.l(`分镜 ${props.shotIndex + 1} 画面提示词`, `Image prompt for shot ${props.shotIndex + 1}`)}
- value={prompt}
- onChange={event => setPrompt(event.target.value)}
- />
- </label>
- <footer>
- {props.mode === 'regenerate' ? (
- <>
- <button className="is-secondary" type="button" onClick={props.onClose}>{props.l('取消', 'Cancel')}</button>
- <button className="is-primary" type="button" disabled={!prompt.trim()} onClick={() => props.onRegenerate(prompt)}>{props.l('确认重新生成', 'Confirm regeneration')}</button>
- </>
- ) : (
- <button className="is-secondary" type="button" onClick={props.onClose}>{props.l('关闭', 'Close')}</button>
- )}
- </footer>
- </section>
- </div>,
- document.body
+ ) : null}
+ </footer>
+ </div>
);
}
-function createStoryboardImagePrompt(input: {
- shot: (typeof storyboardShots)[number];
- story: string;
- characterName: string;
- style: string;
- ratio: '16:9' | '9:16' | '1:1';
+function ResultStep(props: {
+ artifacts: CreatorArtifact[];
+ snapshot?: ReturnType<typeof readCreatorResultSnapshots>[number];
+ videoUrl: string;
+ version: number;
+ versions: Array<{ value: number; description: string }>;
+ manifest?: DeliveryManifest;
l: ReturnType<typeof useLocalizedCopy>;
+ onVersionChange(version: number): void;
+ onOpen(artifact: CreatorArtifact): void;
+ onDownload(artifact: CreatorArtifact): void;
+ onBack(): void;
}) {
- const visualZh = ensurePromptSentence(input.shot.visualZh, '。');
- const storyZh = ensurePromptSentence(input.story, '。');
- const visualEn = ensurePromptSentence(input.shot.visualEn, '.');
- const storyEn = ensurePromptSentence(input.story, '.');
- return input.l(
- `创建一张${input.style}风格的火柴人故事分镜。镜头主题:${input.shot.titleZh}。画面内容:${visualZh}主角:${input.characterName}。故事背景:${storyZh}画面比例:${input.ratio}。保持角色的外观、线条、服装和配色与其他镜头一致,构图清晰,人物动作完整,不要在画面中渲染字幕、标识或其他文字。`,
- `Create a ${input.style} stick figure storyboard image. Shot: ${input.shot.titleEn}. Visual direction: ${visualEn} Character: ${input.characterName}. Story context: ${storyEn} Aspect ratio: ${input.ratio}. Keep the character's appearance, line work, clothing, and colors consistent with the other shots. Use a clear composition and complete body action. Do not render subtitles, labels, or other text in the image.`
+ if (props.snapshot === undefined) return <PendingPanel icon={FileVideo} label={props.l('最终交付尚未完成', 'Final delivery is not complete yet.')} />;
+ const publishable = props.manifest?.packageStatus === 'publishable';
+ return (
+ <div className="stickman-delivery-step">
+ <header className="stickman-result-toolbar">
+ <div>
+ <h2>{props.l('成片交付', 'Video delivery')}</h2>
+ <small className="stickman-delivery-status" data-status={props.manifest?.packageStatus}>
+ {publishable
+ ? props.l('成片和交付文件已就绪', 'The video and delivery files are ready.')
+ : props.l('成片已生成,部分发布检查尚未通过', 'The video is ready, but some publishing checks still need attention.')}
+ </small>
+ </div>
+ <CreatorResultVersionMenu version={props.version} versions={props.versions} onVersionChange={props.onVersionChange} />
+ </header>
+ <div className="stickman-delivery-content">
+ <section className="stickman-delivery-preview" aria-label={props.l('成片预览', 'Video preview')}>
+ {props.videoUrl
+ ? <video controls preload="metadata" src={props.videoUrl} />
+ : <div><FileVideo size={28} /><span>{props.l('成片暂时无法预览', 'The video preview is unavailable.')}</span></div>}
+ </section>
+ <section className="stickman-delivery-files">
+ <header>
+ <h3>{props.l('交付文件', 'Delivery files')}</h3>
+ <span>{props.l(`${deliveryKinds.length} 项`, `${deliveryKinds.length} items`)}</span>
+ </header>
+ <div className="creator-result-files">
+ {deliveryKinds.map(kind => {
+ const artifact = artifactFromSnapshot(props.artifacts, props.snapshot!.artifactRefs[kind]);
+ const file = props.manifest?.files?.find(candidate => candidate.sourceArtifactId === artifact?.id);
+ return (
+ <article key={kind} data-ready={artifact !== undefined}>
+ <span>{deliveryIcon(kind)}</span>
+ <div>
+ <strong>{deliveryLabel(kind, props.l)}</strong>
+ <small>{file === undefined
+ ? artifact === undefined
+ ? props.l('文件不可用', 'File unavailable')
+ : artifactFileDetail(artifact, props.l)
+ : `${formatFileSize(file.bytes)} · ${file.mime}`}</small>
+ </div>
+ <button type="button" disabled={artifact === undefined} title={props.l('预览', 'Preview')} aria-label={`${props.l('预览', 'Preview')} ${deliveryLabel(kind, props.l)}`} onClick={() => artifact && props.onOpen(artifact)}><Eye size={15} /></button>
+ <button type="button" disabled={artifact === undefined} title={props.l('下载', 'Download')} aria-label={`${props.l('下载', 'Download')} ${deliveryLabel(kind, props.l)}`} onClick={() => artifact && props.onDownload(artifact)}><Download size={15} /></button>
+ </article>
+ );
+ })}
+ </div>
+ </section>
+ </div>
+ <footer className="stickman-wizard-actions stickman-script-actions">
+ <button className="video-translation-secondary-action" type="button" onClick={props.onBack}>
+ <ArrowLeft size={16} strokeWidth={1.8} aria-hidden="true" />
+ {props.l('上一步', 'Back')}
+ </button>
+ </footer>
+ </div>
);
}
-function ensurePromptSentence(value: string, punctuation: '。' | '.') {
- const trimmed = value.trim();
- return /[。!?.!?]$/.test(trimmed) ? trimmed : `${trimmed}${punctuation}`;
+function PendingPanel(props: { icon: typeof FileText; label: string }) {
+ const Icon = props.icon;
+ return <div className="creator-tool-panel creator-workspace-loading" aria-live="polite"><Icon size={20} /><p>{props.label}</p></div>;
}
-function storyboardImagePosition(index: number, version: number) {
- const positions = ['left center', '34% center', '66% center', 'right center'];
- return positions[(index + version) % positions.length];
+function useArtifactJson<T>(artifactId?: string): T | undefined {
+ const session = useCreatorSession();
+ const [loaded, setLoaded] = useState<{ artifactId: string; value: T }>();
+ useEffect(() => {
+ let canceled = false;
+ if (artifactId === undefined) return () => { canceled = true; };
+ void session.openArtifactJson<T>(artifactId).then(next => {
+ if (!canceled) setLoaded({ artifactId, value: next });
+ }).catch(() => undefined);
+ return () => { canceled = true; };
+ }, [artifactId, session.openArtifactJson]);
+ return loaded !== undefined && loaded.artifactId === artifactId
+ ? loaded.value
+ : undefined;
}
-function CharacterArtwork(props: {
- image: string;
- alt: string;
-}) {
- return (
- <img
- className="stickman-character-artwork"
- src={props.image}
- alt={props.alt}
- />
- );
+function readScriptManifest(value: unknown): ScriptManifest | undefined {
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return undefined;
+ const record = value as Record<string, unknown>;
+ if (
+ record.contract !== 'stickman-narration-script-v2'
+ || (record.reviewStatus !== 'needs_review' && record.reviewStatus !== 'approved')
+ || typeof record.contentLocked !== 'boolean'
+ || typeof record.title !== 'string'
+ || typeof record.language !== 'string'
+ || typeof record.targetDurationSeconds !== 'number'
+ || record.narrationBudget === null
+ || typeof record.narrationBudget !== 'object'
+ || Array.isArray(record.narrationBudget)
+ || typeof record.segmentCount !== 'number'
+ || typeof record.totalNarrationUnits !== 'number'
+ || typeof record.estimatedTotalDurationSeconds !== 'number'
+ || !Array.isArray(record.segments)
+ ) return undefined;
+ const validSegments = record.segments.every(segment => {
+ if (segment === null || typeof segment !== 'object' || Array.isArray(segment)) return false;
+ const item = segment as Record<string, unknown>;
+ return typeof item.id === 'string'
+ && typeof item.order === 'number'
+ && typeof item.narration === 'string'
+ && typeof item.narrationUnits === 'number'
+ && typeof item.estimatedDurationSeconds === 'number'
+ && Array.isArray(item.claimIds)
+ && item.claimIds.length > 0
+ && item.claimIds.every(claimId => typeof claimId === 'string')
+ && Array.isArray(item.sourceSpanIds)
+ && item.sourceSpanIds.length > 0
+ && item.sourceSpanIds.every(sourceSpanId => typeof sourceSpanId === 'string');
+ });
+ return validSegments ? value as ScriptManifest : undefined;
}
-function voiceLanguageLabel(value: VoiceLanguage, l: ReturnType<typeof useLocalizedCopy>) {
- if (value === 'zh-CN') return l('中文', 'Chinese');
- if (value === 'en-US') return 'English';
- return l('自动匹配', 'Auto match');
+function useArtifactUrl(artifactId?: string): string {
+ const session = useCreatorSession();
+ const [url, setUrl] = useState('');
+ useEffect(() => {
+ let objectUrl = '';
+ let canceled = false;
+ setUrl('');
+ if (artifactId === undefined) return () => { canceled = true; };
+ void session.openArtifact(artifactId).then(async response => {
+ if (!response.ok) return;
+ objectUrl = URL.createObjectURL(await response.blob());
+ if (!canceled) setUrl(objectUrl);
+ }).catch(() => undefined);
+ return () => { canceled = true; if (objectUrl) URL.revokeObjectURL(objectUrl); };
+ }, [artifactId, session.openArtifact]);
+ return url;
+}
+
+function latestCompleted(artifacts: CreatorArtifact[], kind: string): CreatorArtifact | undefined {
+ return [...artifacts].reverse().find(artifact => artifact.kind === kind && artifact.status === 'completed');
+}
+
+function latestStage(stages: CreatorStageRun[], stageId: string): CreatorStageRun | undefined {
+ return [...stages].reverse().find(stage => stage.stageId === stageId);
+}
+
+function latestScopedStage(
+ stages: CreatorStageRun[],
+ stageId: string,
+ scopeKey: string
+): CreatorStageRun | undefined {
+ return [...stages].reverse().find(stage => (
+ stage.stageId === stageId && stage.scopeKey === scopeKey
+ ));
}
-function voiceToneLabel(value: VoiceTone, l: ReturnType<typeof useLocalizedCopy>) {
- if (value === 'energetic') return l('活力青年', 'Energetic');
- if (value === 'calm') return l('沉稳讲述', 'Calm');
- return l('自然叙事', 'Natural narration');
+function latestShotStage(stages: CreatorStageRun[], scopeKey: string): CreatorStageRun | undefined {
+ return [...stages].reverse().find(stage => stage.stageId === 'images' && stage.scopeKey === scopeKey);
}
-function localizeShot(value: string, l: ReturnType<typeof useLocalizedCopy>): string {
- const translations: Record<string, string> = {
- '建立场景': 'Establish the scene',
- '角色站在城市天台,远景缓慢推进': 'The character stands on a city rooftop as the wide shot slowly pushes in',
- '冲突出现': 'Conflict appears',
- '风吹走手中的纸张,角色快速追赶': 'Wind carries the paper away and the character gives chase',
- '动作高潮': 'Action climax',
- '角色越过障碍,在空中抓住纸张': 'The character clears an obstacle and catches the paper in midair',
- '结尾定格': 'Final freeze frame',
- '角色落地举起纸张,镜头定格': 'The character lands, raises the paper, and the frame freezes',
- '手绘线稿': 'Hand-drawn line art',
- '漫画网点': 'Manga halftone',
- '极简黑白': 'Minimal black and white'
+function latestShotImage(artifacts: CreatorArtifact[], scopeKey: string, fingerprint: string | null): CreatorArtifact | undefined {
+ return [...artifacts].reverse().find(artifact => artifact.kind === 'shot_image' && artifact.status === 'completed' && artifact.scopeKey === scopeKey && (fingerprint === null || artifact.inputFingerprint === fingerprint));
+}
+
+function artifactFromSnapshot(artifacts: CreatorArtifact[], ids?: string[]): CreatorArtifact | undefined {
+ return [...(ids ?? [])].reverse().flatMap(id => artifacts.find(artifact => artifact.id === id) ?? []).at(0);
+}
+
+function readNeedsInput(value: unknown): { code: string; kind?: string; message?: string; artifactId?: string } | null {
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return null;
+ const record = value as Record<string, unknown>;
+ if (typeof record.code !== 'string') return null;
+ return {
+ code: record.code,
+ ...(typeof record.kind === 'string' ? { kind: record.kind } : {}),
+ ...(typeof record.message === 'string' ? { message: record.message } : {}),
+ ...(typeof record.artifactId === 'string' ? { artifactId: record.artifactId } : {})
};
- return l(value, translations[value] ?? value);
}
-function createVersionSignature(input: {
- characterSource: CharacterSource;
- selectedPresetId: CharacterPresetId | null;
- characterPrompt: string;
- characterFile: File | null;
- characterGenerated: boolean;
- story: string;
- ratio: '16:9' | '9:16' | '1:1';
- style: string;
- storyboardSubtitles: string[];
- storyboardImageVersions: number[];
- storyboardPromptOverrides: Array<string | null>;
- voiceover: boolean;
- voiceLanguage: VoiceLanguage;
- voiceTone: VoiceTone;
- backgroundMusic: File | null;
- backgroundMusicVolume: number;
-}) {
- const file = input.characterSource === 'upload' && input.characterFile
- ? {
- name: input.characterFile.name,
- size: input.characterFile.size,
- type: input.characterFile.type,
- lastModified: input.characterFile.lastModified
- }
- : null;
- const backgroundMusic = input.backgroundMusic
- ? {
- name: input.backgroundMusic.name,
- size: input.backgroundMusic.size,
- type: input.backgroundMusic.type,
- lastModified: input.backgroundMusic.lastModified
- }
- : null;
-
- return JSON.stringify({
- characterSource: input.characterSource,
- selectedPresetId: input.characterSource === 'preset' ? input.selectedPresetId : null,
- characterPrompt: input.characterSource === 'generate' ? input.characterPrompt.trim() : '',
- characterGenerated: input.characterSource === 'generate' ? input.characterGenerated : false,
- file,
- story: input.story.trim(),
- ratio: input.ratio,
- style: input.style,
- storyboardSubtitles: input.storyboardSubtitles,
- storyboardImageVersions: input.storyboardImageVersions,
- storyboardPromptOverrides: input.storyboardPromptOverrides,
- voiceover: input.voiceover,
- voiceLanguage: input.voiceover ? input.voiceLanguage : null,
- voiceTone: input.voiceover ? input.voiceTone : null,
- backgroundMusic,
- backgroundMusicVolume: backgroundMusic ? input.backgroundMusicVolume : null
- });
+function currentIssue(job: { status: string; stages: CreatorStageRun[] }, step: string, l: ReturnType<typeof useLocalizedCopy>): string {
+ const active = [...job.stages].reverse().find(stage => stage.status === 'running' || stage.status === 'queued');
+ if (active) return l(`正在执行:${step}`, `Running: ${step}`);
+ return job.status === 'needs_input' ? l(`等待操作:${step}`, `Action required: ${step}`) : step;
+}
+
+function deliveryLabel(kind: typeof deliveryKinds[number], l: ReturnType<typeof useLocalizedCopy>): string {
+ const labels = { clean_video: ['火柴人动画', 'Stickman video'], narration_subtitle: ['旁白字幕', 'Narration subtitles'] } as const;
+ const [zh, en] = labels[kind];
+ return l(zh, en);
+}
+
+function deliveryIcon(kind: typeof deliveryKinds[number]) {
+ return kind === 'narration_subtitle' ? <Captions size={17} /> : <FileVideo size={17} />;
+}
+
+type CompositionStatus = 'waiting' | 'running' | 'completed' | 'failed';
+
+function compositionPhaseStatus(
+ stages: CreatorStageRun[],
+ stageIds: string[]
+): CompositionStatus {
+ const current = stageIds.flatMap(stageId => latestStage(stages, stageId) ?? []);
+ if (current.some(stage => stage.status === 'failed')) return 'failed';
+ if (current.some(stage => stage.status === 'running' || stage.status === 'queued')) return 'running';
+ if (current.length === stageIds.length && current.every(stage => stage.status === 'succeeded')) {
+ return 'completed';
+ }
+ if (current.some(stage => stage.status === 'succeeded')) return 'running';
+ return 'waiting';
+}
+
+function compositionPhaseLabel(
+ id: typeof compositionPhases[number]['id'],
+ l: ReturnType<typeof useLocalizedCopy>
+): string {
+ const labels = {
+ timeline: ['生成时间线与旁白字幕', 'Build timeline and narration subtitles'],
+ 'clean-render': ['渲染并检查火柴人动画', 'Render and validate the stickman video'],
+ delivery: ['整理交付文件', 'Prepare delivery files']
+ } as const;
+ const [zh, en] = labels[id];
+ return l(zh, en);
+}
+
+function compositionStatusLabel(
+ status: CompositionStatus,
+ l: ReturnType<typeof useLocalizedCopy>
+): string {
+ const labels = {
+ waiting: ['等待执行', 'Waiting'],
+ running: ['正在处理', 'In progress'],
+ completed: ['已完成', 'Completed'],
+ failed: ['执行失败', 'Failed']
+ } as const;
+ const [zh, en] = labels[status];
+ return l(zh, en);
+}
+
+function formatSeconds(value: number): string {
+ const rounded = Math.round(value * 10) / 10;
+ return `${rounded}s`;
+}
+
+function readArtifactDuration(artifact?: CreatorArtifact): number | undefined {
+ return typeof artifact?.metadata.duration === 'number' ? artifact.metadata.duration : undefined;
+}
+
+function formatFileSize(bytes: number): string {
+ if (bytes < 1024) return `${bytes} B`;
+ if (bytes < 1024 * 1024) return `${Math.round(bytes / 102.4) / 10} KB`;
+ return `${Math.round(bytes / 1024 / 102.4) / 10} MB`;
+}
+
+function artifactFileDetail(
+ artifact: CreatorArtifact,
+ l: ReturnType<typeof useLocalizedCopy>
+): string {
+ const duration = typeof artifact.metadata.duration === 'number'
+ ? formatSeconds(artifact.metadata.duration)
+ : '';
+ const width = typeof artifact.metadata.width === 'number' ? artifact.metadata.width : undefined;
+ const height = typeof artifact.metadata.height === 'number' ? artifact.metadata.height : undefined;
+ const dimensions = width !== undefined && height !== undefined ? `${width}×${height}` : '';
+ return [duration, dimensions].filter(Boolean).join(' · ') || l('文件已就绪', 'File ready');
+}
+
+async function openArtifact(open: (id: string) => Promise<Response>, artifact: CreatorArtifact) {
+ const response = await open(artifact.id);
+ if (!response.ok) return;
+ const url = URL.createObjectURL(await response.blob());
+ window.open(url, '_blank', 'noopener,noreferrer');
+ window.setTimeout(() => URL.revokeObjectURL(url), 60_000);
+}
+
+async function downloadArtifact(open: (id: string) => Promise<Response>, artifact: CreatorArtifact) {
+ const response = await open(artifact.id);
+ if (!response.ok) return;
+ const url = URL.createObjectURL(await response.blob());
+ const anchor = document.createElement('a');
+ anchor.href = url;
+ anchor.download = typeof artifact.metadata.fileName === 'string' ? artifact.metadata.fileName : artifact.kind;
+ anchor.click();
+ URL.revokeObjectURL(url);
+}
+
+function isPublicYoutubeUrl(value: string): boolean {
+ try {
+ const host = new URL(value).hostname.toLowerCase();
+ return host === 'youtu.be' || host.endsWith('youtube.com');
+ } catch {
+ return false;
+ }
}
diff --git a/apps/web/src/features/dashboard/VideoDownloadWorkspace.test.tsx b/apps/web/src/features/dashboard/VideoDownloadWorkspace.test.tsx
index 11715698..b662e826 100644
--- a/apps/web/src/features/dashboard/VideoDownloadWorkspace.test.tsx
+++ b/apps/web/src/features/dashboard/VideoDownloadWorkspace.test.tsx
@@ -453,6 +453,8 @@ describe('VideoDownloadWorkspace', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'probing_source',
percent: 20
@@ -625,6 +627,7 @@ function job(patch: Partial<CreatorJob> = {}): CreatorJob {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt,
@@ -640,6 +643,9 @@ function probeArtifact(): CreatorArtifact {
version: 1,
status: 'completed',
path: '/tmp/probe.json',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
id: 'demo',
@@ -739,6 +745,8 @@ function downloadStage(
claimExpiresAt: null,
attempt: status === 'queued' ? 0 : 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
optionId,
mediaType: 'video',
@@ -762,6 +770,9 @@ function videoArtifact(): CreatorArtifact {
version: 1,
status: 'completed',
path: '/tmp/Creator Download.mp4',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: ['probe_artifact'],
metadata: {
fileName: 'Creator Download.mp4',
@@ -787,6 +798,9 @@ function audioArtifact(): CreatorArtifact {
version: 1,
status: 'completed',
path: '/tmp/Creator Download.mp3',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: ['probe_artifact'],
metadata: {
fileName: 'Creator Download.mp3',
diff --git a/apps/web/src/features/dashboard/VideoGenerationWorkspace.test.tsx b/apps/web/src/features/dashboard/VideoGenerationWorkspace.test.tsx
index 37ab11ed..72103669 100644
--- a/apps/web/src/features/dashboard/VideoGenerationWorkspace.test.tsx
+++ b/apps/web/src/features/dashboard/VideoGenerationWorkspace.test.tsx
@@ -83,6 +83,8 @@ describe('VideoGenerationWorkspace', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'provider_failed',
percent: null
@@ -127,6 +129,8 @@ describe('VideoGenerationWorkspace', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'submitting',
percent: 8
@@ -174,6 +178,8 @@ describe('VideoGenerationWorkspace', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'generating',
percent: null,
@@ -380,6 +386,7 @@ function creatorJob(patch: Partial<CreatorJob>): CreatorJob {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt,
@@ -395,6 +402,9 @@ function videoArtifact(version: number): CreatorArtifact {
version,
status: 'completed',
path: `/tmp/generated-video-v${version}.mp4`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
provider: version === 1 ? 'seedance' : 'veo',
diff --git a/apps/web/src/features/dashboard/VideoTranslationAgentPanel.test.tsx b/apps/web/src/features/dashboard/VideoTranslationAgentPanel.test.tsx
index d031ecae..3bd4c3f6 100644
--- a/apps/web/src/features/dashboard/VideoTranslationAgentPanel.test.tsx
+++ b/apps/web/src/features/dashboard/VideoTranslationAgentPanel.test.tsx
@@ -346,6 +346,8 @@ describe('VideoTranslationAgentPanel', () => {
claimExpiresAt: '2026-08-21T00:01:00.000Z',
attempt: 1,
idempotencyKey: 'subtitle_localized_1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'translating_subtitles',
percent: 24,
@@ -367,6 +369,8 @@ describe('VideoTranslationAgentPanel', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'tts_localized_1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'generating_voice',
percent: 35,
@@ -443,6 +447,8 @@ describe('VideoTranslationAgentPanel', () => {
claimExpiresAt: '2026-08-21T00:01:00.000Z',
attempt: 1,
idempotencyKey: 'subtitle_1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
krillinStatus: 'running',
krillinEventPayload: {
@@ -488,6 +494,8 @@ describe('VideoTranslationAgentPanel', () => {
claimExpiresAt: '2026-08-28T06:01:00.000Z',
attempt: 1,
idempotencyKey: 'stage-control',
+ scopeKey: null,
+ inputFingerprint: null,
progress: { percent: 25 },
errorCode: null,
errorMessage: null,
@@ -569,6 +577,8 @@ describe('VideoTranslationAgentPanel', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'subtitle_failed_1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
percent: 67,
phase: 'translating_subtitles',
@@ -882,6 +892,7 @@ function job(): CreatorJob {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [
{
id: 'activity_1',
diff --git a/apps/web/src/features/dashboard/VideoTranslationWorkspace.artifacts.test.ts b/apps/web/src/features/dashboard/VideoTranslationWorkspace.artifacts.test.ts
index fd609d48..c0a56b2f 100644
--- a/apps/web/src/features/dashboard/VideoTranslationWorkspace.artifacts.test.ts
+++ b/apps/web/src/features/dashboard/VideoTranslationWorkspace.artifacts.test.ts
@@ -575,6 +575,9 @@ function artifact(input: Partial<CreatorArtifact> & Pick<CreatorArtifact, 'id' |
jobId: 'job-1',
status: 'completed',
path: null,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {},
createdAt: `2026-08-24T00:00:0${input.version}.000Z`,
diff --git a/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsx b/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsx
index fa938484..cadc959c 100644
--- a/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsx
+++ b/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsx
@@ -188,6 +188,9 @@ describe('VideoTranslationWorkspace task controls', () => {
version: 1,
status: 'completed',
path: '/tmp/vertical-subtitle-v1.srt',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
resultVersion: 1,
@@ -696,6 +699,7 @@ function job(input: {
agentThreadId: null,
stages: input.stages,
artifacts: input.artifacts ?? [],
+ providerRequests: [],
activities: [],
createdAt: '2026-08-28T06:00:00.000Z',
updatedAt: '2026-08-28T06:00:00.000Z'
@@ -710,6 +714,9 @@ function subtitleArtifact(resultVersion: number, text: string): CreatorArtifact
version: resultVersion,
status: 'completed',
path: `/tmp/target-subtitle-v${resultVersion}.srt`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
resultVersion,
@@ -739,6 +746,9 @@ function textSubtitleArtifact(input: {
version: input.version,
status: 'completed',
path: `/tmp/${input.fileName}`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
resultVersion: input.version,
@@ -762,6 +772,9 @@ function sourceVideoArtifact(resultVersion: number): CreatorArtifact {
version: resultVersion,
status: 'completed',
path: `/tmp/source-video-v${resultVersion}.mp4`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
resultVersion,
@@ -800,6 +813,8 @@ function stage(input: {
: null,
attempt: input.status === 'queued' ? 0 : 1,
idempotencyKey: input.id,
+ scopeKey: null,
+ inputFingerprint: null,
progress: input.progress,
errorCode: null,
errorMessage: null,
diff --git a/apps/web/src/features/dashboard/WechatArticleWorkspace.test.tsx b/apps/web/src/features/dashboard/WechatArticleWorkspace.test.tsx
index c4c0d7af..e064badc 100644
--- a/apps/web/src/features/dashboard/WechatArticleWorkspace.test.tsx
+++ b/apps/web/src/features/dashboard/WechatArticleWorkspace.test.tsx
@@ -31,6 +31,8 @@ describe('WechatArticleWorkspace', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: { phase: 'completed', percent: 100, completed: 3, failed: 0, total: 3 },
errorCode: null,
errorMessage: null,
@@ -836,6 +838,8 @@ describe('WechatArticleWorkspace', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: { phase: 'failed', percent: 0, completed: 0, failed: 1, total: 1 },
errorCode: 'creator_image_config_missing',
errorMessage: 'Image generation service is not configured',
@@ -919,6 +923,9 @@ function documentArtifact(
version: 1,
status: 'completed',
path: `/tmp/示例文章.${extension}`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: ['article-artifact-1'],
metadata: {
fileName: `示例文章.${extension}`,
@@ -942,6 +949,9 @@ function articleImageArtifact(id: string, resultVersion: number, imageIndex: num
version: resultVersion,
status: 'completed',
path: `/tmp/${id}.png`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: ['article-artifact-1'],
metadata: {
fileName: `${id}.png`,
@@ -965,6 +975,9 @@ function manualArticleImageArtifact(id: string, originalFileName: string, index:
version: index,
status: 'completed',
path: `/tmp/${id}.${extension}`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
fileName: `article-upload-${index}.${extension}`,
@@ -984,6 +997,9 @@ function sourceDocumentArtifact(id: string, fileName: string): CreatorJob['artif
version: 1,
status: 'completed',
path: `/tmp/${fileName}`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { fileName, bytes: 13, mimeType: 'text/markdown' },
createdAt: '2026-09-07T08:00:00.000Z'
@@ -998,6 +1014,9 @@ function articleSourcesArtifact(id: string, automaticTranscriptCount = 0): Creat
version: 1,
status: 'completed',
path: '/tmp/article-sources.json',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
fileName: 'article-sources.json',
@@ -1021,6 +1040,8 @@ function sourceStage(status: 'succeeded' | 'failed'): CreatorJob['stages'][numbe
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: { phase: status === 'succeeded' ? 'completed' : 'reading_video', message: 'youtube.com' },
errorCode: status === 'failed' ? 'creator_source_transcript_missing' : null,
errorMessage: status === 'failed' ? 'No subtitles are available for video' : null,
@@ -1052,6 +1073,7 @@ function inspirationJob(sourceCount = 0): CreatorJob {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
@@ -1085,10 +1107,14 @@ function articleJob(): CreatorJob {
version: 1,
status: 'completed',
path: '/tmp/wechat-article.md',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { fileName: 'wechat-article.md' },
createdAt
}],
+ providerRequests: [],
activities: [],
createdAt,
updatedAt: createdAt
diff --git a/apps/web/src/features/dashboard/XiaohongshuPostWorkspace.test.tsx b/apps/web/src/features/dashboard/XiaohongshuPostWorkspace.test.tsx
index 081f6df4..f9b13a58 100644
--- a/apps/web/src/features/dashboard/XiaohongshuPostWorkspace.test.tsx
+++ b/apps/web/src/features/dashboard/XiaohongshuPostWorkspace.test.tsx
@@ -256,6 +256,7 @@ function initialJob(): CreatorJob {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt: '2026-09-08T08:00:00.000Z',
updatedAt: '2026-09-08T08:00:00.000Z'
@@ -270,6 +271,9 @@ function completedJob(job: CreatorJob): CreatorJob {
version: 1,
status: 'completed',
path: '/tmp/OpenCreator-xiaohongshu-post.md',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: {
fileName: 'OpenCreator-xiaohongshu-post.md',
@@ -299,6 +303,8 @@ function completedJob(job: CreatorJob): CreatorJob {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: null,
+ scopeKey: null,
+ inputFingerprint: null,
progress: {
phase: 'completed',
percent: 100,
diff --git a/apps/web/src/features/dashboard/creator-panel-adapters.test.ts b/apps/web/src/features/dashboard/creator-panel-adapters.test.ts
new file mode 100644
index 00000000..c8479a5d
--- /dev/null
+++ b/apps/web/src/features/dashboard/creator-panel-adapters.test.ts
@@ -0,0 +1,176 @@
+import type { CreatorActivity, CreatorStageRun } from '@opencreator/protocol';
+import { describe, expect, it } from 'vitest';
+import {
+ creatorPanelAdapterFor,
+ stickmanVideoPanelAdapter,
+ type CreatorPanelLocalize
+} from './creator-panel-adapters.js';
+
+const zh: CreatorPanelLocalize = value => value;
+const en: CreatorPanelLocalize = (_zh, value) => value;
+
+const stages = [
+ 'ingest-text', 'source-transcript', 'source-brief', 'content-plan', 'script',
+ 'narration', 'audio-timing', 'storyboard', 'style-assets', 'prompt-pack',
+ 'images', 'visual-validation', 'timeline', 'render-clean', 'media-validation', 'package-validation'
+];
+
+describe('stickmanVideoPanelAdapter', () => {
+ it('selects the stickman adapter and labels every production stage in both locales', () => {
+ expect(creatorPanelAdapterFor('stickman-video')).toBe(stickmanVideoPanelAdapter);
+ for (const stageId of stages) {
+ expect(stickmanVideoPanelAdapter.stageLabel(stageId, zh)).not.toBe('火柴人视频任务');
+ expect(stickmanVideoPanelAdapter.stageLabel(stageId, en)).not.toBe('Stickman video task');
+ }
+ for (const phase of ['validating', 'preparing_source', 'reading_platform_captions', 'processing_platform_captions', 'translating_subtitles', 'preparing_audio', 'transcribing_audio', 'collecting_outputs', 'transcribing', 'analyzing', 'planning', 'writing', 'reviewing', 'materializing', 'submitting', 'retrying_candidate', 'generating', 'synthesizing', 'measuring', 'validating_media', 'rendering', 'packaging', 'failed', 'completed']) {
+ expect(stickmanVideoPanelAdapter.phaseLabel(phase, zh)).not.toBeNull();
+ expect(stickmanVideoPanelAdapter.phaseLabel(phase, en)).not.toBeNull();
+ }
+ });
+
+ it('labels production actions and filters draft setting noise', () => {
+ for (const action of ['approve-script', 'continue-after-audio', 'continue-after-visuals', 'edit-script', 'edit-shot', 'regenerate-shot', 'generate-missing-shots', 'retry-stage', 'commit-version']) {
+ const normalized = stickmanVideoPanelAdapter.normalizeActivity(activity(action), zh);
+ expect(normalized?.label).toBeTruthy();
+ }
+ expect(stickmanVideoPanelAdapter.normalizeActivity(activity('create-job'), zh)).toBeNull();
+ expect(stickmanVideoPanelAdapter.normalizeActivity(activity('approve-visuals'), zh)).toBeNull();
+ expect(stickmanVideoPanelAdapter.normalizeActivity(activity('run-stage', {
+ stageId: 'source-brief'
+ }), zh)).toBeNull();
+ expect(stickmanVideoPanelAdapter.normalizeActivity(activity('update-settings'), zh)).toBeNull();
+ expect(stickmanVideoPanelAdapter.normalizeActivity(activity('update-settings', {
+ objectId: 'sourceType,sourceText,styleAsset'
+ }), zh)).toMatchObject({ fields: ['内容来源', '文本来源', '视觉风格'] });
+ expect(stickmanVideoPanelAdapter.normalizeActivity(activity('resolve-provider-request', {
+ decision: 'confirm-resubmit'
+ }), zh)?.label).toContain('重复计费');
+ });
+
+ it('collapses script preparation into one continuous progress card', () => {
+ const aggregated = stickmanVideoPanelAdapter.aggregateStages?.([
+ stage('ingest', '', 'succeeded', null, 'ingest-text', 100, 'completed'),
+ stage('brief', '', 'succeeded', null, 'source-brief', 100, 'completed'),
+ stage('plan', '', 'succeeded', null, 'content-plan', 100, 'completed'),
+ stage('script', '', 'running', null, 'script', 15, 'writing')
+ ]);
+
+ expect(aggregated).toHaveLength(1);
+ expect(aggregated?.[0]).toMatchObject({
+ id: 'script',
+ stageId: 'script',
+ status: 'running',
+ progress: {
+ phase: 'writing',
+ percent: 79,
+ completed: 3,
+ failed: 0,
+ total: 4
+ }
+ });
+ const progress = stickmanVideoPanelAdapter.readStageProgress(aggregated![0]!);
+ expect(stickmanVideoPanelAdapter.runningProgressText?.(aggregated![0]!, progress, zh))
+ .toBe('生成创作内容');
+ });
+
+ it('keeps one completed script card after the validated script is generated', () => {
+ const aggregated = stickmanVideoPanelAdapter.aggregateStages?.([
+ stage('ingest', '', 'succeeded', null, 'ingest-text', 100, 'completed'),
+ stage('brief', '', 'succeeded', null, 'source-brief', 100, 'completed'),
+ stage('plan', '', 'succeeded', null, 'content-plan', 100, 'completed'),
+ stage('script', '', 'succeeded', null, 'script', 100, 'completed')
+ ]);
+
+ expect(aggregated).toHaveLength(1);
+ expect(aggregated?.[0]).toMatchObject({
+ stageId: 'script',
+ status: 'succeeded',
+ progress: { percent: 100, completed: 4, failed: 0, total: 4 }
+ });
+ });
+
+ it('starts the aggregated URL workflow at the KrillinAI transcript stage', () => {
+ const aggregated = stickmanVideoPanelAdapter.aggregateStages?.([
+ stage('transcript', '', 'running', null, 'source-transcript', 20, 'reading_platform_captions')
+ ]);
+
+ expect(aggregated).toHaveLength(1);
+ expect(aggregated?.[0]).toMatchObject({
+ stageId: 'script',
+ status: 'running',
+ progress: {
+ phase: 'reading_platform_captions',
+ percent: 5,
+ completed: 0,
+ failed: 0,
+ total: 4
+ }
+ });
+ expect(stickmanVideoPanelAdapter.phaseLabel('reading_platform_captions', zh))
+ .toBe('获取平台字幕');
+ const progress = stickmanVideoPanelAdapter.readStageProgress(aggregated![0]!);
+ expect(stickmanVideoPanelAdapter.runningProgressText?.(aggregated![0]!, progress, zh))
+ .toBe('获取平台字幕');
+ });
+
+ it('keeps only the current shot run instead of rendering repeated completion cards', () => {
+ const aggregated = stickmanVideoPanelAdapter.aggregateStages?.([
+ stage('shot-1-old', 'shot-1', 'failed', '1'.repeat(64)),
+ stage('shot-1-new', 'shot-1', 'succeeded', '2'.repeat(64)),
+ stage('shot-2', 'shot-2', 'succeeded', '3'.repeat(64)),
+ stage('shot-3', 'shot-3', 'failed', '4'.repeat(64))
+ ]);
+ expect(aggregated).toHaveLength(1);
+ expect(aggregated?.[0]).toMatchObject({
+ id: 'shot-3',
+ stageId: 'images',
+ status: 'failed'
+ });
+ });
+});
+
+function activity(action: string, details: CreatorActivity['details'] = {}): CreatorActivity {
+ return {
+ id: `activity-${action}`,
+ jobId: 'job-1',
+ revision: 1,
+ actor: 'user',
+ action,
+ summary: action,
+ details,
+ createdAt: '2026-08-31T00:00:00.000Z'
+ };
+}
+
+function stage(
+ id: string,
+ scopeKey: string,
+ status: CreatorStageRun['status'],
+ inputFingerprint: string | null,
+ stageId = 'images',
+ percent?: number,
+ phase?: string
+): CreatorStageRun {
+ return {
+ id,
+ jobId: 'job-1',
+ stageId,
+ executor: 'stickman-image',
+ status,
+ dispatchStatus: 'finished',
+ claimOwner: null,
+ claimExpiresAt: null,
+ attempt: 1,
+ idempotencyKey: id,
+ scopeKey,
+ inputFingerprint,
+ progress: {
+ ...(percent === undefined ? {} : { percent }),
+ ...(phase === undefined ? {} : { phase })
+ },
+ errorCode: status === 'failed' ? 'image_failed' : null,
+ errorMessage: status === 'failed' ? 'failed' : null,
+ startedAt: `2026-08-31T00:00:0${id.includes('old') ? 1 : 2}.000Z`,
+ finishedAt: '2026-08-31T00:00:03.000Z'
+ };
+}
diff --git a/apps/web/src/features/dashboard/creator-panel-adapters.ts b/apps/web/src/features/dashboard/creator-panel-adapters.ts
index 3c2d72a7..55be3ef2 100644
--- a/apps/web/src/features/dashboard/creator-panel-adapters.ts
+++ b/apps/web/src/features/dashboard/creator-panel-adapters.ts
@@ -32,6 +32,7 @@ export type CreatorPanelAdapter = {
l: CreatorPanelLocalize
): NormalizedCreatorActivity | null;
readStageProgress(stage: CreatorStageRun): CreatorStageProgressView;
+ aggregateStages?(stages: CreatorStageRun[]): CreatorStageRun[];
runningProgressText?(
stage: CreatorStageRun,
progress: CreatorStageProgressView,
@@ -310,6 +311,201 @@ export const videoDownloadPanelAdapter: CreatorPanelAdapter = {
}
};
+export const stickmanVideoPanelAdapter: CreatorPanelAdapter = {
+ id: 'stickman-video',
+ composerPlaceholder: l => l(
+ '询问状态,或描述要调整的脚本、镜头、角色和成片要求',
+ 'Ask about status or describe script, shot, character, and delivery changes'
+ ),
+ stageLabel(stageId, l) {
+ const labels: Record<string, string> = {
+ 'ingest-text': l('保存文本来源', 'Save text source'),
+ 'source-transcript': l('提取来源字幕', 'Extract source transcript'),
+ 'source-brief': l('生成来源摘要', 'Create source brief'),
+ 'content-plan': l('规划内容结构', 'Plan content structure'),
+ script: l('生成脚本', 'Generate script'),
+ narration: l('生成旁白', 'Generate narration'),
+ 'audio-timing': l('测量旁白时长', 'Measure narration timing'),
+ storyboard: l('生成分镜', 'Generate storyboard'),
+ 'style-assets': l('准备角色参考图与风格', 'Prepare character reference and style'),
+ 'prompt-pack': l('生成镜头提示词', 'Build shot prompts'),
+ images: l('生成镜头画面', 'Generate shot visuals'),
+ 'visual-validation': l('校验画面', 'Validate visuals'),
+ timeline: l('生成时间线与旁白字幕', 'Build timeline and narration subtitles'),
+ 'render-clean': l('渲染火柴人动画', 'Render stickman video'),
+ 'media-validation': l('校验成片媒体', 'Validate rendered media'),
+ 'package-validation': l('整理成片与字幕', 'Prepare video and subtitles')
+ };
+ return labels[stageId] ?? l('火柴人视频任务', 'Stickman video task');
+ },
+ phaseLabel(phase, l) {
+ const labels: Record<string, string> = {
+ validating: l('检查任务输入', 'Checking task input'),
+ preparing_source: l('准备 YouTube 来源', 'Preparing the YouTube source'),
+ reading_platform_captions: l('获取平台字幕', 'Fetching platform captions'),
+ processing_platform_captions: l('解析平台字幕', 'Processing platform captions'),
+ translating_subtitles: l('整理来源字幕', 'Preparing source captions'),
+ preparing_audio: l('平台字幕不可用,准备音频转录', 'Platform captions unavailable; preparing audio transcription'),
+ transcribing_audio: l('使用 Whisper 转录音频', 'Transcribing audio with Whisper'),
+ collecting_outputs: l('整理来源字幕', 'Collecting source captions'),
+ transcribing: l('提取来源字幕', 'Extracting source transcript'),
+ analyzing: l('理解来源内容', 'Analyzing source content'),
+ planning: l('规划内容结构', 'Planning content structure'),
+ writing: l('生成创作内容', 'Writing creative content'),
+ reviewing: l('检查脚本结构与语义', 'Reviewing script structure and meaning'),
+ materializing: l('准备角色参考图与风格合同', 'Preparing character reference and style contract'),
+ submitting: l('提交图像生成服务', 'Submitting to the image provider'),
+ retrying_candidate: l('重新生成当前镜头候选', 'Retrying the current shot candidate'),
+ generating: l('生成镜头画面', 'Generating shot visuals'),
+ synthesizing: l('合成旁白音频', 'Synthesizing narration'),
+ measuring: l('测量真实音频时长', 'Measuring real audio timing'),
+ validating_media: l('检查视频轨、音频轨与抽帧', 'Checking video, audio, and sampled frames'),
+ rendering: l('渲染视频', 'Rendering video'),
+ packaging: l('整理成片与字幕', 'Packaging video and subtitles'),
+ failed: l('阶段执行失败', 'Stage failed'),
+ completed: l('阶段已完成', 'Stage completed')
+ };
+ return labels[phase] ?? genericPhaseLabel(phase, l);
+ },
+ activityStageId: readActivityStageId,
+ normalizeActivity(activity, l) {
+ if (activity.action === 'run-stage') return null;
+ const labels: Record<string, string> = {
+ 'approve-script': l('审核通过了脚本', 'Approved the script'),
+ 'continue-after-audio': l('确认配音并开始生成分镜画面', 'Continued from audio to storyboard visuals'),
+ 'continue-after-visuals': l('确认画面并开始动画合成', 'Continued from visuals to video composition'),
+ 'edit-script': l('保存了脚本修改', 'Saved script changes'),
+ 'edit-shot': l('保存了镜头修改', 'Saved shot changes'),
+ 'regenerate-shot': l('重新生成了单个镜头', 'Regenerated one shot'),
+ 'generate-missing-shots': l('继续生成剩余分镜画面', 'Continued generating missing shot visuals'),
+ 'retry-stage': l('重试了失败阶段', 'Retried a failed stage'),
+ 'commit-version': l('保存了新的交付版本', 'Committed a new delivery version')
+ };
+ if (activity.action === 'resolve-provider-request') {
+ const decision = readString(activity.details.decision);
+ if (decision === 'confirm-resubmit') {
+ return { label: l('用户确认了可能重复计费的重提', 'User confirmed a potentially duplicate billed resubmission'), fields: [] };
+ }
+ if (decision === 'cancel-scope') {
+ return { label: l('用户取消了状态未知的镜头请求', 'User canceled the unresolved shot request'), fields: [] };
+ }
+ return { label: l('查询了状态未知的 Provider 请求', 'Queried an unresolved provider request'), fields: [] };
+ }
+ return normalizeCommonActivity(
+ activity,
+ l,
+ stickmanVideoPanelAdapter,
+ labels,
+ stickmanFieldLabel
+ );
+ },
+ readStageProgress: readStandardProgress,
+ aggregateStages(stages) {
+ const scriptStageIds = new Set<string>([
+ 'ingest-text',
+ 'source-transcript',
+ 'source-brief',
+ 'content-plan',
+ 'script'
+ ]);
+ const scriptStages = stages.filter(stage => scriptStageIds.has(stage.stageId));
+ const productionStages = stages.filter(stage => (
+ !scriptStageIds.has(stage.stageId) && stage.stageId !== 'acquire-source'
+ ));
+ if (productionStages.length === 0) {
+ const scriptPipeline = aggregateStickmanScriptStages(scriptStages);
+ return scriptPipeline === undefined ? [] : [scriptPipeline];
+ }
+ const representative = currentStickmanStage(productionStages);
+ return representative === undefined ? [] : [representative];
+ },
+ runningProgressText(stage, progress, l) {
+ if (stage.stageId === 'script' && progress.phase !== null) {
+ return stickmanVideoPanelAdapter.phaseLabel(progress.phase, l);
+ }
+ if (stage.stageId !== 'images') return null;
+ if (progress.total === null || progress.completed === null) return null;
+ return l(
+ `镜头完成 ${progress.completed}/${progress.total}${progress.failed ? `,失败 ${progress.failed}` : ''}`,
+ `${progress.completed}/${progress.total} shots completed${progress.failed ? `, ${progress.failed} failed` : ''}`
+ );
+ }
+};
+
+function aggregateStickmanScriptStages(
+ stages: CreatorStageRun[]
+): CreatorStageRun | undefined {
+ if (stages.length === 0) return undefined;
+ const textSource = stages.some(stage => stage.stageId === 'ingest-text');
+ const order = textSource
+ ? ['ingest-text', 'source-brief', 'content-plan', 'script']
+ : ['source-transcript', 'source-brief', 'content-plan', 'script'];
+ const current = order.flatMap(stageId => (
+ stages.find(stage => stage.stageId === stageId) ?? []
+ ));
+ if (current.length === 0) return undefined;
+
+ const active = latestStartedStage(current.filter(stage => stage.status === 'running'))
+ ?? latestStartedStage(current.filter(stage => stage.status === 'queued'));
+ const stopped = latestStartedStage(current.filter(stage => (
+ stage.status === 'failed'
+ || stage.status === 'canceled'
+ || stage.status === 'interrupted'
+ )));
+ const script = current.find(stage => stage.stageId === 'script');
+ const representative = active ?? stopped ?? script ?? latestStartedStage(current)!;
+ const currentIndex = Math.max(0, order.indexOf(representative.stageId));
+ const completed = active === undefined
+ && stopped === undefined
+ && script?.status === 'succeeded';
+ const status = completed
+ ? 'succeeded' as const
+ : active?.status ?? stopped?.status ?? 'running' as const;
+ const stagePercent = representative.status === 'succeeded'
+ ? 100
+ : Math.max(0, Math.min(100, readFiniteNumber(representative.progress.percent) ?? 0));
+ const percent = completed
+ ? 100
+ : Math.round(((currentIndex + stagePercent / 100) / order.length) * 100);
+
+ return {
+ ...representative,
+ stageId: 'script',
+ scopeKey: null,
+ inputFingerprint: null,
+ status,
+ progress: {
+ ...representative.progress,
+ phase: representative.progress.phase ?? null,
+ message: representative.progress.message ?? null,
+ percent,
+ completed: completed ? order.length : currentIndex,
+ failed: stopped?.status === 'failed' ? 1 : 0,
+ total: order.length
+ },
+ startedAt: current[0]?.startedAt ?? null,
+ finishedAt: completed ? script?.finishedAt ?? representative.finishedAt : null
+ };
+}
+
+function currentStickmanStage(stages: CreatorStageRun[]): CreatorStageRun | undefined {
+ return latestStartedStage(stages.filter(stage => stage.status === 'running'))
+ ?? latestStartedStage(stages.filter(stage => stage.status === 'queued'))
+ ?? latestStartedStage(stages.filter(stage => (
+ stage.status === 'failed'
+ || stage.status === 'canceled'
+ || stage.status === 'interrupted'
+ )))
+ ?? latestStartedStage(stages.filter(stage => stage.status === 'succeeded'));
+}
+
+function latestStartedStage(stages: CreatorStageRun[]): CreatorStageRun | undefined {
+ return [...stages].sort((left, right) => (
+ (left.startedAt ?? '').localeCompare(right.startedAt ?? '')
+ || left.id.localeCompare(right.id)
+ )).at(-1);
+}
+
export const smartDubbingPanelAdapter: CreatorPanelAdapter = {
id: 'smart-dubbing',
composerPlaceholder: l => l(
@@ -535,6 +731,7 @@ export function creatorPanelAdapterFor(templateId: string): CreatorPanelAdapter
if (templateId === 'wechat-article') return wechatArticlePanelAdapter;
if (templateId === 'cover') return coverPanelAdapter;
if (templateId === 'video-generation') return videoGenerationPanelAdapter;
+ if (templateId === 'stickman-video') return stickmanVideoPanelAdapter;
return genericAdapter;
}
@@ -663,6 +860,23 @@ function videoDownloadFieldLabel(
return labels[field] ?? null;
}
+function stickmanFieldLabel(
+ field: string,
+ l: CreatorPanelLocalize
+): string | null {
+ const labels: Record<string, string> = {
+ sourceType: l('内容来源', 'Content source'),
+ sourceUrl: l('YouTube 来源', 'YouTube source'),
+ sourceText: l('文本来源', 'Text source'),
+ characterAsset: l('人物形象', 'Character'),
+ styleAsset: l('视觉风格', 'Visual style'),
+ targetDurationSeconds: l('目标时长', 'Target duration'),
+ targetLanguage: l('目标语言', 'Target language'),
+ voice: l('旁白音色', 'Narration voice')
+ };
+ return labels[field] ?? null;
+}
+
function smartDubbingFieldLabel(
field: string,
l: CreatorPanelLocalize
diff --git a/apps/web/src/features/dashboard/creator-session-store.test.tsx b/apps/web/src/features/dashboard/creator-session-store.test.tsx
index 17b8e87b..b1e37082 100644
--- a/apps/web/src/features/dashboard/creator-session-store.test.tsx
+++ b/apps/web/src/features/dashboard/creator-session-store.test.tsx
@@ -19,6 +19,7 @@ function job(revision: number, state: Record<string, any>): CreatorJob {
agentThreadId: null,
stages: [],
artifacts: [],
+ providerRequests: [],
activities: [],
createdAt: '2026-08-20T00:00:00.000Z',
updatedAt: '2026-08-20T00:00:00.000Z'
@@ -644,6 +645,9 @@ describe('CreatorSessionStore', () => {
version: 1,
status: 'completed' as const,
path: '/tmp/source.webm',
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { source: 'local-upload' },
createdAt: '2026-08-20T00:00:02.000Z'
@@ -725,6 +729,8 @@ describe('CreatorSessionStore', () => {
claimExpiresAt: null,
attempt: 1,
idempotencyKey: 'stage_1',
+ scopeKey: null,
+ inputFingerprint: null,
progress: { percent: 35 },
errorCode: null,
errorMessage: null,
diff --git a/apps/web/src/features/dashboard/creator-session-store.tsx b/apps/web/src/features/dashboard/creator-session-store.tsx
index 63bb8f42..0a6a2ff4 100644
--- a/apps/web/src/features/dashboard/creator-session-store.tsx
+++ b/apps/web/src/features/dashboard/creator-session-store.tsx
@@ -46,6 +46,7 @@ type CreatorSessionContextValue = {
uploadArticleImage(file: File): Promise<CreatorArtifact>;
uploadSourceDocument(file: File): Promise<void>;
openArtifact(artifactId: string): Promise<Response>;
+ openArtifactJson<T = unknown>(artifactId: string): Promise<T>;
agentSession: CreatorAgentSession | null;
turns: CreatorAgentTurn[];
items: CreatorAgentItem[];
@@ -106,6 +107,7 @@ export function CreatorSessionProvider(props: {
const dirtyRef = useRef(dirtyFields);
const timelineReloadWorkRef = useRef<Promise<void> | null>(null);
const timelineReloadRequestedRef = useRef(false);
+ const artifactJsonCacheRef = useRef(new Map<string, Promise<unknown>>());
confirmedRef.current = confirmedJob;
draftRef.current = draft;
dirtyRef.current = dirtyFields;
@@ -217,6 +219,13 @@ export function CreatorSessionProvider(props: {
void flush().catch(() => undefined);
}, [flush]);
+ const artifactIdentity = confirmedJob.artifacts
+ .map(artifact => `${artifact.id}:${artifact.status}`)
+ .join('|');
+ useEffect(() => {
+ artifactJsonCacheRef.current.clear();
+ }, [artifactIdentity, confirmedJob.id]);
+
const updateDraft = useCallback((
patch: Record<string, CreatorJson>,
options: { semantic?: boolean; persist?: boolean } = {}
@@ -345,12 +354,20 @@ export function CreatorSessionProvider(props: {
setError(null);
return response.job;
} catch (cause) {
+ const nextError = toSessionError(cause);
if (!isSupersededRevisionConflict(cause, requestRevision, confirmedRef.current.revision)) {
- setError(toSessionError(cause));
+ setError(nextError);
+ if (
+ nextError.code === 'creator_revision_conflict'
+ && props.service.getJob !== undefined
+ ) {
+ const response = await props.service.getJob(confirmedRef.current.id).catch(() => undefined);
+ if (response !== undefined) applyRemoteSnapshot(response.job);
+ }
}
throw cause;
}
- }, [ensurePersistedJob, flush, props.service]);
+ }, [applyRemoteSnapshot, ensurePersistedJob, flush, props.service]);
const uploadSourceVideo = useCallback(async (file: File) => {
if (props.service.uploadSourceVideo === undefined) {
@@ -493,6 +510,20 @@ export function CreatorSessionProvider(props: {
return props.service.openArtifact(confirmedRef.current.id, artifactId);
}, [props.service]);
+ const openArtifactJson = useCallback(<T,>(artifactId: string): Promise<T> => {
+ const cached = artifactJsonCacheRef.current.get(artifactId);
+ if (cached !== undefined) return cached as Promise<T>;
+ const request = openArtifact(artifactId).then(async response => {
+ if (!response.ok) throw new Error(`Creator artifact request failed: ${response.status}`);
+ return response.json() as Promise<T>;
+ }).catch(error => {
+ artifactJsonCacheRef.current.delete(artifactId);
+ throw error;
+ });
+ artifactJsonCacheRef.current.set(artifactId, request);
+ return request;
+ }, [openArtifact]);
+
const runAgentTurn = useCallback(async (
message: string,
sandbox?: CreatorAgentTurnRequest['sandbox']
@@ -607,6 +638,7 @@ export function CreatorSessionProvider(props: {
uploadSourceVideo,
uploadArticleImage,
openArtifact,
+ openArtifactJson,
agentSession,
turns,
items,
@@ -616,7 +648,7 @@ export function CreatorSessionProvider(props: {
steerAgentTurn,
interruptAgentTurn,
respondAgentApproval
- }), [agentBusy, agentSession, applyAction, applyRemoteSnapshot, approvals, cancelJob, clearError, confirmedJob, conflictedFields, draft, error, flush, interruptAgentTurn, items, openArtifact, respondAgentApproval, resumeJob, runAgentTurn, steerAgentTurn, turns, updateDraft, uploadArticleImage, uploadReferenceImage, uploadSourceDocument, uploadSourceVideo]);
+ }), [agentBusy, agentSession, applyAction, applyRemoteSnapshot, approvals, cancelJob, clearError, confirmedJob, conflictedFields, draft, error, flush, interruptAgentTurn, items, openArtifact, openArtifactJson, respondAgentApproval, resumeJob, runAgentTurn, steerAgentTurn, turns, updateDraft, uploadArticleImage, uploadReferenceImage, uploadSourceDocument, uploadSourceVideo]);
return (
<CreatorSessionContext.Provider value={value}>
diff --git a/apps/web/src/features/dashboard/dashboard-css.test.ts b/apps/web/src/features/dashboard/dashboard-css.test.ts
index 4c782d8d..81ee62d4 100644
--- a/apps/web/src/features/dashboard/dashboard-css.test.ts
+++ b/apps/web/src/features/dashboard/dashboard-css.test.ts
@@ -123,6 +123,37 @@ describe('dashboard CSS contracts', () => {
expect(resultPane[0]).toContain('min-height: 0;');
});
+ it('keeps storyboard navigation fixed while only the shot list scrolls', () => {
+ const storyboardStep = cssBlocks('.stickman-storyboard-step');
+ const storyboardPanel = cssBlocks('.stickman-storyboard-review');
+ const storyboardEditor = cssBlocks('.stickman-storyboard-review .stickman-storyboard-editor');
+
+ expect(storyboardStep).toHaveLength(1);
+ expect(storyboardStep[0]).toContain('grid-template-rows: minmax(0, 1fr) auto;');
+ expect(storyboardPanel).toHaveLength(1);
+ expect(storyboardPanel[0]).toContain('overflow: hidden;');
+ expect(storyboardEditor).toHaveLength(1);
+ expect(storyboardEditor[0]).toContain('overflow-y: auto;');
+ expect(storyboardEditor[0]).toContain('scrollbar-gutter: stable;');
+ });
+
+ it('keeps script generation content meaningful inside the fixed editor layout', () => {
+ const scriptStep = cssBlocks('.stickman-script-step');
+ const scriptPanel = cssBlocks('.stickman-script-panel');
+ const scriptEditor = cssBlocks('.stickman-script-editor');
+ const skeletonBox = cssBlocks('.stickman-script-skeleton-box');
+
+ expect(scriptStep).toHaveLength(1);
+ expect(scriptStep[0]).toContain('grid-template-rows: minmax(0, 1fr) auto;');
+ expect(scriptPanel).toHaveLength(1);
+ expect(scriptPanel[0]).toContain('grid-template-rows: auto minmax(0, 1fr);');
+ expect(scriptPanel[0]).toContain('overflow: hidden;');
+ expect(scriptEditor).toHaveLength(1);
+ expect(scriptEditor[0]).toContain('overflow-y: auto;');
+ expect(skeletonBox).toHaveLength(1);
+ expect(skeletonBox[0]).toContain('background: var(--conversation-bg);');
+ });
+
it('visually preserves creator steps that remain reachable after navigating back', () => {
const reachableConnector = cssBlocks(
'.video-translation-steps li[data-next-reachable="true"]::after'
diff --git a/apps/web/src/features/dashboard/dashboard.css b/apps/web/src/features/dashboard/dashboard.css
index 7007d440..3a934615 100644
--- a/apps/web/src/features/dashboard/dashboard.css
+++ b/apps/web/src/features/dashboard/dashboard.css
@@ -1287,12 +1287,6 @@
min-height: 0;
}
-.stickman-storyboard-step {
- display: grid;
- align-items: start;
- gap: 14px;
-}
-
.video-translation-header button:focus-visible,
.video-translation-source-tabs button:focus-visible,
.video-translation-upload button:focus-visible,
@@ -1361,6 +1355,20 @@
box-sizing: border-box;
}
+.creator-workspace-header.has-title-icon {
+ grid-template-columns: 34px 36px minmax(0, 1fr);
+}
+
+.creator-workspace-title-icon {
+ width: 36px;
+ height: 36px;
+ display: grid;
+ place-items: center;
+ border-radius: 8px;
+ background: color-mix(in srgb, var(--accent) 12%, var(--surface));
+ color: var(--accent);
+}
+
.creator-workspace-header > button {
width: 34px;
height: 34px;
@@ -1414,22 +1422,56 @@
}
.stickman-workspace-content {
+ display: grid;
+ min-height: 0;
overflow: hidden;
}
.stickman-tool-stack {
height: 100%;
- grid-template-rows: auto minmax(0, 1fr) auto;
+ min-height: 0;
+ grid-template-rows: auto minmax(0, 1fr);
+}
+
+.stickman-tool-top {
+ display: grid;
+ gap: 14px;
}
.stickman-step-scroll {
+ height: 100%;
min-height: 0;
overflow-y: auto;
- padding: 2px;
+ padding: 2px 2px 24px;
+ box-sizing: border-box;
+ overscroll-behavior: contain;
scrollbar-gutter: stable;
}
+.stickman-step-scroll[data-step="1"],
+.stickman-step-scroll[data-step="2"],
+.stickman-step-scroll[data-step="3"],
+.stickman-step-scroll[data-step="4"],
+.stickman-step-scroll[data-step="5"] {
+ display: grid;
+ grid-template-rows: minmax(0, 1fr);
+ overflow: hidden;
+ padding-bottom: 2px;
+ scrollbar-gutter: auto;
+}
+
+.stickman-step-scroll[data-step="1"] > .creator-task-workspace,
+.stickman-step-scroll[data-step="2"] > .creator-task-workspace,
+.stickman-step-scroll[data-step="3"] > .creator-task-workspace,
+.stickman-step-scroll[data-step="4"] > .creator-task-workspace,
+.stickman-step-scroll[data-step="5"] > .creator-task-workspace {
+ min-height: 0;
+ height: 100%;
+}
+
.stickman-wizard-actions {
+ display: flex;
+ justify-content: flex-end;
margin-top: 0;
padding-top: 14px;
border-top: 1px solid var(--border-hairline);
@@ -1443,8 +1485,32 @@
grid-template-columns: repeat(3, minmax(0, 1fr));
}
-.stickman-tool-stack .creator-tool-steps ol {
- grid-template-columns: repeat(4, minmax(0, 1fr));
+.stickman-steps {
+ width: min(860px, 100%);
+}
+
+.video-translation-steps.stickman-steps ol {
+ grid-template-columns: repeat(6, minmax(0, 1fr));
+}
+
+.stickman-steps button strong {
+ min-height: 32px;
+ display: grid;
+ place-items: start center;
+ overflow: visible;
+ font-size: 12px;
+ line-height: 1.35;
+ text-align: center;
+ white-space: normal;
+}
+
+.creator-workspace-page .stickman-steps button:focus-visible {
+ outline: 0;
+}
+
+.creator-workspace-page .stickman-steps button:focus-visible > span {
+ outline: 2px solid var(--accent);
+ outline-offset: 2px;
}
.creator-tool-panel {
@@ -7017,20 +7083,16 @@
}
.stickman-character-picker {
- display: grid;
- grid-template-columns: max-content 240px;
- align-items: start;
- justify-content: start;
- column-gap: 24px;
+ display: block;
}
.stickman-character-presets {
+ width: 100%;
min-width: 0;
display: grid;
- grid-template-columns: repeat(5, 82px);
+ grid-template-columns: repeat(6, minmax(64px, 1fr));
align-content: start;
- justify-content: start;
- gap: 8px 10px;
+ gap: 8px;
}
.stickman-character-presets > button {
@@ -7058,8 +7120,8 @@
}
.stickman-character-presets > button[aria-checked="true"] {
- border-color: transparent;
- background: color-mix(in srgb, var(--accent) 6%, var(--conversation-bg));
+ border-color: color-mix(in srgb, var(--accent) 26%, var(--border));
+ background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.stickman-character-preset-visual {
@@ -7139,25 +7201,128 @@
object-position: center;
}
-@media (max-width: 1180px) {
- .stickman-character-picker {
- grid-template-columns: max-content 240px;
- column-gap: 20px;
- }
-
+@media (max-width: 760px) {
.stickman-character-presets {
- grid-template-columns: repeat(4, 82px);
+ grid-template-columns: repeat(3, minmax(72px, 1fr));
}
}
-@media (max-width: 1020px) {
- .stickman-character-picker {
- grid-template-columns: max-content 200px;
- }
+.stickman-asset-catalog-state {
+ min-height: 124px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ color: var(--text-muted);
+ font-size: 12px;
+}
- .stickman-character-presets {
- grid-template-columns: repeat(3, 82px);
- }
+.stickman-asset-catalog-state.is-error {
+ color: var(--danger);
+}
+
+.stickman-style-field {
+ align-self: start;
+}
+
+.stickman-style-summary {
+ min-height: 88px;
+ display: grid;
+ grid-template-columns: 76px minmax(0, 1fr);
+ align-items: stretch;
+ gap: 10px;
+ padding: 9px;
+ border: 1px solid var(--border);
+ border-radius: 6px;
+ background: var(--surface-2);
+}
+
+.stickman-style-swatch {
+ position: relative;
+ min-height: 68px;
+ overflow: hidden;
+ border: 1px solid color-mix(in srgb, var(--stickman-style-fg) 18%, transparent);
+ border-radius: 4px;
+ background: var(--stickman-style-bg);
+}
+
+.stickman-style-swatch i {
+ position: absolute;
+ left: 11px;
+ right: 11px;
+ height: 3px;
+ border-radius: 2px;
+ background: var(--stickman-style-fg);
+ transform-origin: left center;
+}
+
+.stickman-style-swatch i:nth-child(1) {
+ top: 18px;
+ transform: rotate(-7deg);
+}
+
+.stickman-style-swatch i:nth-child(2) {
+ top: 34px;
+ right: 22px;
+ background: var(--stickman-style-accent);
+ transform: rotate(4deg);
+}
+
+.stickman-style-swatch i:nth-child(3) {
+ top: 50px;
+ left: 22px;
+ transform: rotate(-2deg);
+}
+
+.stickman-style-swatch[data-texture="paper"] {
+ box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--stickman-style-accent) 12%, transparent);
+}
+
+.stickman-style-swatch[data-texture="screentone"] i:nth-child(2) {
+ height: 8px;
+ opacity: 0.55;
+}
+
+.stickman-style-swatch[data-texture="marker"] i {
+ height: 5px;
+}
+
+.stickman-style-copy {
+ min-width: 0;
+ display: grid;
+ align-content: start;
+ gap: 4px;
+}
+
+.stickman-style-copy strong,
+.stickman-style-copy small {
+ min-width: 0;
+ overflow-wrap: anywhere;
+}
+
+.stickman-style-copy strong {
+ color: var(--text);
+ font-size: 12px;
+ font-weight: 650;
+}
+
+.stickman-style-copy small {
+ color: var(--text-muted);
+ font-size: 11px;
+ line-height: 1.45;
+}
+
+.stickman-style-copy > span {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 3px 8px;
+ margin-top: 2px;
+}
+
+.stickman-style-copy em {
+ color: var(--text-subtle);
+ font-size: 10px;
+ font-style: normal;
}
.stickman-character-grid {
@@ -7216,421 +7381,1482 @@
min-height: 112px;
}
-.stickman-story-panel .creator-tool-field select:focus {
- border-color: var(--border);
- box-shadow: none;
+.stickman-source-text textarea {
+ min-height: 156px;
}
-.creator-workspace-page .stickman-story-panel select:focus-visible {
- outline: 1px solid var(--border-strong);
- outline-offset: 1px;
+.stickman-duration-control {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr);
+ gap: 8px;
}
-.stickman-storyboard-editor {
- display: grid;
- margin-top: 18px;
+.stickman-custom-duration {
+ position: relative;
+ display: block;
}
-.stickman-storyboard-review .stickman-storyboard-editor {
- margin-top: 0;
+.stickman-custom-duration input {
+ padding-right: 44px;
}
-.stickman-storyboard-row {
- min-width: 0;
- display: grid;
- grid-template-columns: 76px 150px minmax(0, 1fr);
- align-items: start;
- gap: 12px;
- padding: 10px 0;
- border-bottom: 1px solid var(--border-hairline);
+.stickman-custom-duration small {
+ position: absolute;
+ top: 50%;
+ right: 12px;
+ transform: translateY(-50%);
+ color: var(--subtle);
+ font-size: 11px;
+ pointer-events: none;
}
-.stickman-storyboard-row:first-child {
- padding-top: 0;
+.stickman-voice-settings {
+ margin-top: 14px;
+ padding-top: 14px;
+ border-top: 1px solid var(--border-hairline);
}
-.stickman-storyboard-row:last-child {
- padding-bottom: 0;
- border-bottom: 0;
+.stickman-tts-configuration {
+ min-height: 48px;
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ align-items: center;
+ gap: 10px;
+ padding: 10px 12px;
+ border: 1px solid color-mix(in srgb, var(--warning) 34%, var(--border));
+ border-radius: 7px;
+ background: color-mix(in srgb, var(--warning) 6%, var(--surface-2));
+ color: var(--muted);
}
-.stickman-storyboard-meta,
-.stickman-storyboard-media,
-.stickman-storyboard-copy {
- min-width: 0;
+.stickman-tts-configuration.is-configured {
+ grid-template-columns: auto minmax(0, 1fr);
+ border-color: var(--border);
+ background: var(--surface-2);
}
-.stickman-storyboard-meta {
+.stickman-tts-configuration > div {
+ min-width: 0;
display: grid;
- align-content: start;
- gap: 4px;
- padding-top: 2px;
+ gap: 2px;
}
-.stickman-storyboard-meta strong {
+.stickman-tts-configuration strong {
color: var(--text);
font-size: 12px;
+}
+
+.stickman-tts-configuration small {
+ color: var(--muted);
+ font-size: 11px;
+ line-height: 1.45;
+}
+
+.stickman-tts-configuration a {
+ color: var(--accent);
+ font-size: 12px;
font-weight: 620;
- line-height: 1.4;
+ text-decoration: none;
+ white-space: nowrap;
}
-.stickman-storyboard-meta small {
- color: var(--subtle);
- font-size: 10px;
+.stickman-tts-configuration a:hover {
+ text-decoration: underline;
}
-.stickman-storyboard-media {
- width: 100%;
- max-width: 150px;
- display: grid;
- align-content: start;
- gap: 4px;
+@media (max-width: 640px) {
+ .stickman-tts-configuration {
+ grid-template-columns: auto minmax(0, 1fr);
+ }
+
+ .stickman-tts-configuration a {
+ grid-column: 2;
+ justify-self: start;
+ white-space: normal;
+ }
}
-.stickman-storyboard-image {
- position: relative;
- aspect-ratio: 16 / 9;
- overflow: hidden;
- border-radius: 7px;
- background: var(--surface-2);
+.stickman-workspace-page .creator-tool-panel-heading {
+ align-items: center;
+ justify-content: flex-start;
}
-.stickman-storyboard-image img {
- width: 100%;
- height: 100%;
- display: block;
- object-fit: cover;
+.stickman-workspace-page .creator-tool-panel-heading > span {
+ width: 32px;
+ height: 32px;
+ flex: 0 0 auto;
+ display: grid;
+ place-items: center;
+ border-radius: 7px;
+ background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
+ color: var(--accent);
+}
+
+.stickman-story-panel .creator-tool-segmented button[aria-selected="true"] {
+ border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
+ background: color-mix(in srgb, var(--accent) 8%, var(--surface));
+ color: var(--accent);
+ box-shadow: none;
+}
+
+.stickman-story-panel .creator-tool-field input:focus,
+.stickman-story-panel .creator-tool-field textarea:focus,
+.stickman-story-panel .creator-tool-field select:focus {
+ border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 9%, transparent);
+}
+
+.creator-workspace-page .stickman-story-panel select:focus-visible {
+ outline: 0;
+}
+
+.stickman-script-step {
+ min-width: 0;
+ min-height: 0;
+ height: 100%;
+ display: grid;
+ grid-template-rows: minmax(0, 1fr) auto;
+ gap: 14px;
+}
+
+.stickman-script-panel {
+ min-height: 0;
+ display: grid;
+ grid-template-rows: auto minmax(0, 1fr);
+ overflow: hidden;
+ padding-bottom: 4px;
+}
+
+.stickman-script-heading-copy {
+ min-width: 0;
+ flex: 1 1 auto;
+}
+
+.stickman-script-heading-copy > input {
+ width: 100%;
+ height: 32px;
+ padding: 0 8px;
+ border: 1px solid transparent;
+ border-radius: 6px;
+ outline: 0;
+ background: transparent;
+ color: var(--text);
+ font: inherit;
+ font-size: 17px;
+ font-weight: 650;
+ box-sizing: border-box;
+}
+
+.stickman-script-heading-copy > input:hover {
+ border-color: var(--border);
+ background: var(--conversation-bg);
+}
+
+.stickman-script-heading-copy > input:focus {
+ border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
+ background: var(--conversation-bg);
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 9%, transparent);
+}
+
+.stickman-script-heading-copy > p {
+ padding-left: 8px;
+}
+
+.creator-tool-panel-heading > .stickman-script-unsaved {
+ margin-left: auto;
+ color: var(--accent);
+}
+
+.stickman-script-placeholder-heading {
+ min-width: 0;
+ flex: 1 1 auto;
+}
+
+.stickman-script-placeholder-heading h2,
+.stickman-script-placeholder-heading p {
+ margin: 0;
+ letter-spacing: 0;
+}
+
+.stickman-script-placeholder-heading h2 {
+ font-size: 16px;
+ font-weight: 650;
+}
+
+.stickman-script-placeholder-heading p {
+ margin-top: 4px;
+ color: var(--muted);
+ font-size: 11px;
+}
+
+.stickman-script-placeholder > .creator-tool-panel-heading > .creator-collaboration-spin {
+ flex: 0 0 auto;
+ color: var(--accent);
+}
+
+.stickman-script-editor {
+ min-height: 0;
+ display: grid;
+ align-content: start;
+ overflow-y: auto;
+ padding-right: 8px;
+ border-top: 1px solid var(--border-hairline);
+ scrollbar-gutter: stable;
+}
+
+.stickman-script-skeleton-row {
+ pointer-events: none;
+}
+
+.stickman-script-skeleton-duration,
+.stickman-script-skeleton-box,
+.stickman-script-skeleton-box > i {
+ display: block;
+ border-radius: 5px;
+ background: color-mix(in srgb, var(--text) 8%, var(--surface-2));
+}
+
+.stickman-script-skeleton-duration {
+ width: 58px;
+ height: 32px;
+}
+
+.stickman-script-skeleton-fields {
+ min-width: 0;
+ display: grid;
+ gap: 12px;
+}
+
+.stickman-script-skeleton-fields > div {
+ min-width: 0;
+ display: grid;
+ gap: 6px;
+}
+
+.stickman-script-skeleton-fields span {
+ color: var(--muted);
+ font-size: 11px;
+ font-weight: 580;
+}
+
+.stickman-script-skeleton-box {
+ min-height: 64px;
+ display: grid;
+ align-content: center;
+ gap: 10px;
+ padding: 10px 11px;
+ border: 1px solid var(--border);
+ background: var(--conversation-bg);
+ box-sizing: border-box;
+}
+
+.stickman-script-skeleton-box.is-narration {
+ min-height: 82px;
+}
+
+.stickman-script-skeleton-box > i {
+ width: 88%;
+ height: 8px;
+ animation: stickman-script-skeleton-pulse 1.25s ease-in-out infinite alternate;
+}
+
+.stickman-script-skeleton-box > .is-medium {
+ width: 68%;
+ animation-delay: 120ms;
+}
+
+.stickman-script-skeleton-box > .is-short {
+ width: 42%;
+ animation-delay: 240ms;
+}
+
+.stickman-script-placeholder-error {
+ min-height: 0;
+ display: grid;
+ place-content: center;
+ justify-items: center;
+ gap: 8px;
+ padding: 28px;
+ text-align: center;
+}
+
+.stickman-script-placeholder-error > span {
+ width: 38px;
+ height: 38px;
+ display: grid;
+ place-items: center;
+ border-radius: 7px;
+ background: color-mix(in srgb, var(--danger) 10%, var(--surface-2));
+ color: var(--danger);
+}
+
+.stickman-script-placeholder-error strong {
+ font-size: 14px;
+}
+
+.stickman-script-placeholder-error p {
+ max-width: 520px;
+ margin: 0;
+ color: var(--muted);
+ font-size: 12px;
+ line-height: 1.6;
+}
+
+.stickman-script-placeholder-error button {
+ margin-top: 4px;
+}
+
+@keyframes stickman-script-skeleton-pulse {
+ from { opacity: 0.48; }
+ to { opacity: 0.9; }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .stickman-script-skeleton-box > i {
+ animation: none;
+ }
+}
+
+.stickman-script-row {
+ min-width: 0;
+ display: grid;
+ grid-template-columns: 72px minmax(0, 1fr);
+ align-items: start;
+ gap: 18px;
+ padding: 18px 0;
+ border-bottom: 1px solid var(--border-hairline);
+}
+
+.stickman-script-row:last-child {
+ border-bottom: 0;
+}
+
+.stickman-script-meta {
+ min-width: 0;
+ display: grid;
+ align-content: start;
+ gap: 10px;
+ padding-top: 2px;
+}
+
+.stickman-script-meta > strong {
+ color: var(--text);
+ font-size: 13px;
+ font-weight: 680;
+}
+
+.stickman-script-meta > label {
+ width: 64px;
+ height: 32px;
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto;
+ align-items: center;
+ overflow: hidden;
+ border: 1px solid var(--border);
+ border-radius: 6px;
+ background: var(--conversation-bg);
+ box-sizing: border-box;
+}
+
+.stickman-script-meta input {
+ width: 100%;
+ min-width: 0;
+ height: 30px;
+ padding: 0 2px 0 8px;
+ border: 0;
+ outline: 0;
+ background: transparent;
+ color: var(--text);
+ font: inherit;
+ font-size: 11px;
+ box-sizing: border-box;
+}
+
+.stickman-script-meta small {
+ padding-right: 6px;
+ color: var(--subtle);
+ font-size: 9px;
+ pointer-events: none;
+}
+
+.stickman-script-meta > label:focus-within {
+ border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 9%, transparent);
+}
+
+.stickman-script-fields {
+ min-width: 0;
+ display: grid;
+ gap: 12px;
+}
+
+.stickman-script-fields > label {
+ min-width: 0;
+ display: grid;
+ gap: 6px;
+}
+
+.stickman-script-fields > label > span {
+ color: var(--muted);
+ font-size: 11px;
+ font-weight: 580;
+}
+
+.stickman-script-fields input,
+.stickman-script-fields textarea {
+ width: 100%;
+ border: 1px solid var(--border);
+ border-radius: 7px;
+ outline: 0;
+ background: var(--conversation-bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 13px;
+ line-height: 1.65;
+ box-sizing: border-box;
+}
+
+.stickman-script-fields input {
+ height: 38px;
+ padding: 0 11px;
+ font-weight: 620;
+}
+
+.stickman-script-fields textarea {
+ min-height: 82px;
+ max-height: 240px;
+ padding: 9px 11px;
+ resize: vertical;
+ field-sizing: content;
+}
+
+.stickman-script-fields input:focus,
+.stickman-script-fields textarea:focus {
+ border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 9%, transparent);
+}
+
+.stickman-script-actions {
+ justify-content: space-between;
+ margin-top: 0;
+ padding: 14px 0 2px;
+ background: var(--conversation-bg);
+}
+
+.stickman-source-actions.has-next {
+ justify-content: space-between;
+ gap: 12px;
+}
+
+.stickman-storyboard-editor {
+ display: grid;
+ margin-top: 18px;
+}
+
+.stickman-storyboard-step {
+ min-width: 0;
+ min-height: 0;
+ height: 100%;
+ display: grid;
+ grid-template-rows: minmax(0, 1fr) auto;
+ gap: 14px;
+}
+
+.stickman-storyboard-review {
+ min-height: 0;
+ display: grid;
+ grid-template-rows: auto minmax(0, 1fr);
+ overflow: hidden;
+ padding-bottom: 4px;
+}
+
+.stickman-storyboard-review .stickman-storyboard-editor {
+ min-height: 0;
+ overflow-y: auto;
+ margin-top: 0;
+ padding-right: 8px;
+ scrollbar-gutter: stable;
+}
+
+.stickman-storyboard-placeholder > .creator-tool-panel-heading > .creator-collaboration-spin {
+ flex: 0 0 auto;
+ color: var(--accent);
+}
+
+.stickman-storyboard-loading-row {
+ pointer-events: none;
+}
+
+.stickman-storyboard-placeholder-image {
+ display: grid;
+ place-items: center;
+ border: 1px solid var(--border-hairline);
+ background: color-mix(in srgb, var(--text) 5%, var(--surface-2));
+}
+
+.stickman-storyboard-placeholder-image-status {
+ display: grid;
+ justify-items: center;
+ gap: 7px;
+ color: var(--muted);
+}
+
+.stickman-storyboard-placeholder-image-status small {
+ font-size: 10px;
+}
+
+.stickman-storyboard-description-skeleton,
+.stickman-storyboard-narration-skeleton {
+ min-width: 0;
+ display: grid;
+ align-content: center;
+ gap: 9px;
+}
+
+.stickman-storyboard-description-skeleton {
+ min-height: 42px;
+ margin-top: 7px;
+ padding: 9px 10px;
+ border: 1px solid var(--border-hairline);
+ border-radius: 7px;
+ background: var(--surface-2);
+ box-sizing: border-box;
+}
+
+.stickman-storyboard-narration-skeleton {
+ min-height: 45px;
+ margin-top: 10px;
+ padding-top: 9px;
+ border-top: 1px solid var(--border-hairline);
+}
+
+.stickman-storyboard-description-skeleton > i,
+.stickman-storyboard-narration-skeleton > i {
+ width: 88%;
+ height: 7px;
+ display: block;
+ border-radius: 5px;
+ background: color-mix(in srgb, var(--text) 8%, var(--surface-2));
+ animation: stickman-script-skeleton-pulse 1.25s ease-in-out infinite alternate;
+}
+
+.stickman-storyboard-description-skeleton > .is-medium {
+ width: 62%;
+ animation-delay: 120ms;
+}
+
+.stickman-storyboard-narration-skeleton > .is-short {
+ width: 46%;
+ animation-delay: 160ms;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .stickman-storyboard-description-skeleton > i,
+ .stickman-storyboard-narration-skeleton > i {
+ animation: none;
+ }
+}
+
+.stickman-storyboard-row {
+ min-width: 0;
+ display: grid;
+ grid-template-columns: 76px 150px minmax(0, 1fr);
+ align-items: start;
+ gap: 12px;
+ padding: 10px 0;
+ border-bottom: 1px solid var(--border-hairline);
+}
+
+.stickman-storyboard-row:first-child {
+ padding-top: 0;
+}
+
+.stickman-storyboard-row:last-child {
+ padding-bottom: 0;
+ border-bottom: 0;
+}
+
+.stickman-storyboard-meta,
+.stickman-storyboard-media,
+.stickman-storyboard-copy {
+ min-width: 0;
+}
+
+.stickman-storyboard-meta {
+ display: grid;
+ align-content: start;
+ gap: 4px;
+ padding-top: 2px;
+}
+
+.stickman-storyboard-meta strong {
+ color: var(--text);
+ font-size: 12px;
+ font-weight: 620;
+ line-height: 1.4;
+}
+
+.stickman-storyboard-meta small {
+ color: var(--subtle);
+ font-size: 10px;
+}
+
+.stickman-storyboard-media {
+ width: 100%;
+ max-width: 150px;
+ display: grid;
+ align-content: start;
+ gap: 4px;
+}
+
+.stickman-storyboard-image {
+ position: relative;
+ aspect-ratio: 16 / 9;
+ overflow: hidden;
+ border-radius: 7px;
+ background: var(--surface-2);
+}
+
+.stickman-storyboard-image img {
+ width: 100%;
+ height: 100%;
+ display: block;
+ object-fit: cover;
+}
+
+.stickman-storyboard-row[data-status="generating"] .stickman-storyboard-image {
+ outline: 1px solid color-mix(in srgb, var(--accent) 46%, var(--border));
+ outline-offset: -1px;
}
.stickman-storyboard-image > span {
position: absolute;
- top: 7px;
- left: 7px;
- width: 20px;
- height: 20px;
+ top: 7px;
+ left: 7px;
+ width: 20px;
+ height: 20px;
+ display: grid;
+ place-items: center;
+ border-radius: 6px;
+ background: rgba(20, 22, 26, 0.82);
+ color: #f7f7f8;
+ font-size: 11px;
+ font-weight: 650;
+}
+
+.stickman-storyboard-actions {
+ min-width: 0;
+ min-height: 30px;
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 8px;
+ margin-top: 8px;
+}
+
+.stickman-storyboard-regenerate,
+.stickman-storyboard-prompt {
+ width: max-content;
+ min-width: 98px;
+ min-height: 28px;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 5px;
+ padding: 3px 9px;
+ border: 1px solid var(--border);
+ border-radius: 6px;
+ background: var(--surface);
+ color: var(--subtle);
+ font-size: 10px;
+ font-weight: 580;
+}
+
+.stickman-storyboard-regenerate:hover,
+.stickman-storyboard-prompt:hover {
+ background: color-mix(in srgb, var(--text) 6%, var(--surface));
+ color: var(--text);
+}
+
+.stickman-storyboard-prompt {
+ border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
+ color: var(--accent);
+}
+
+.stickman-storyboard-regenerate {
+ width: 112px;
+}
+
+.stickman-storyboard-regenerate:disabled,
+.stickman-storyboard-prompt:disabled {
+ cursor: default;
+ opacity: 0.62;
+}
+
+.stickman-storyboard-copy {
+ display: grid;
+ align-content: start;
+}
+
+.stickman-storyboard-description {
+ min-width: 0;
+ display: grid;
+ gap: 6px;
+}
+
+.stickman-storyboard-description > strong {
+ color: var(--text);
+ font-size: 11px;
+ font-weight: 620;
+}
+
+.stickman-storyboard-description textarea {
+ width: 100%;
+ min-height: 58px;
+ max-height: 180px;
+ padding: 7px 9px;
+ resize: vertical;
+ border: 1px solid transparent;
+ border-radius: 6px;
+ background: color-mix(in srgb, var(--text) 3%, var(--surface-2));
+ color: var(--text);
+ font: inherit;
+ font-size: 12px;
+ line-height: 1.55;
+ box-sizing: border-box;
+}
+
+.stickman-storyboard-description textarea:hover {
+ border-color: var(--border);
+}
+
+.stickman-storyboard-description textarea:focus {
+ border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
+ outline: 0;
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 9%, transparent);
+}
+
+.stickman-storyboard-description textarea:disabled {
+ opacity: 0.72;
+}
+
+.stickman-storyboard-motion {
+ width: max-content;
+ display: inline-flex;
+ align-items: center;
+ gap: 7px;
+ margin-top: 8px;
+ color: var(--subtle);
+ font-size: 10px;
+ font-weight: 580;
+}
+
+.stickman-storyboard-motion select {
+ min-width: 92px;
+ min-height: 26px;
+ padding: 2px 24px 2px 8px;
+ border: 1px solid var(--border);
+ border-radius: 6px;
+ background: var(--surface);
+ color: var(--text);
+ font-size: 10px;
+}
+
+.stickman-storyboard-generation-status {
+ min-width: 0;
+ flex: 1 1 180px;
+ color: var(--muted);
+ font-size: 10px;
+ line-height: 1.45;
+}
+
+.stickman-storyboard-generation-status[data-status="failed"] {
+ color: var(--danger);
+}
+
+.stickman-storyboard-waiting {
+ min-height: 28px;
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ color: var(--muted);
+ font-size: 10px;
+}
+
+.stickman-storyboard-batch-action {
+ min-width: 190px;
+}
+
+.stickman-storyboard-subtitle textarea {
+ min-height: 60px;
+ resize: vertical;
+}
+
+.stickman-storyboard-readonly-subtitle {
+ display: grid;
+}
+
+.stickman-storyboard-readonly-subtitle p {
+ min-height: 48px;
+ margin: 0;
+ padding: 8px 10px;
+ border: 1px solid var(--border-hairline);
+ border-radius: 7px;
+ background: var(--surface-2);
+ color: var(--text);
+ font-size: 12px;
+ line-height: 1.55;
+}
+
+.stickman-prompt-backdrop {
+ position: fixed;
+ inset: 0;
+ z-index: 120;
+ display: grid;
+ place-items: center;
+ padding: 24px;
+ background: rgba(15, 17, 21, 0.52);
+}
+
+.stickman-prompt-dialog {
+ width: min(560px, calc(100vw - 32px));
+ max-height: min(680px, calc(100dvh - 48px));
+ display: grid;
+ grid-template-rows: auto minmax(0, 1fr) auto;
+ overflow: hidden;
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ background: var(--surface);
+ box-shadow: 0 24px 72px rgba(15, 17, 21, 0.24);
+}
+
+.stickman-prompt-dialog > header {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 16px;
+ padding: 18px 20px;
+ border-bottom: 1px solid var(--border-hairline);
+}
+
+.stickman-prompt-dialog > header span {
+ display: block;
+ margin-bottom: 3px;
+ color: var(--muted);
+ font-size: 11px;
+}
+
+.stickman-prompt-dialog > header h2 {
+ margin: 0;
+ color: var(--text);
+ font-size: 17px;
+ font-weight: 640;
+}
+
+.stickman-prompt-dialog > header > button {
+ width: 30px;
+ height: 30px;
+ flex: none;
+ display: grid;
+ place-items: center;
+ padding: 0;
+ border: 1px solid var(--border);
+ border-radius: 7px;
+ background: var(--surface);
+ color: var(--muted);
+}
+
+.stickman-prompt-dialog > header > button:hover {
+ background: var(--surface-2);
+ color: var(--text);
+}
+
+.stickman-prompt-content {
+ min-height: 0;
+ display: grid;
+ gap: 7px;
+ overflow: auto;
+ padding: 18px 20px;
+}
+
+.stickman-prompt-content > span {
+ color: var(--muted);
+ font-size: 11px;
+ font-weight: 580;
+}
+
+.stickman-prompt-content textarea {
+ width: 100%;
+ min-height: 220px;
+ box-sizing: border-box;
+ resize: none;
+ padding: 12px;
+ border: 1px solid var(--border);
+ border-radius: 7px;
+ outline: 0;
+ background: var(--conversation-bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 12px;
+ line-height: 1.65;
+}
+
+.stickman-prompt-content textarea:focus {
+ border-color: var(--border-strong);
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--text) 5%, transparent);
+}
+
+.stickman-prompt-dialog > footer {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ padding: 12px 20px;
+ border-top: 1px solid var(--border-hairline);
+}
+
+.stickman-prompt-dialog > footer button {
+ min-height: 34px;
+ padding: 0 14px;
+ border: 1px solid var(--border);
+ border-radius: 7px;
+ background: var(--surface);
+ color: var(--text);
+ font-size: 12px;
+ font-weight: 580;
+}
+
+.stickman-prompt-dialog > footer button:hover {
+ border-color: var(--border-strong);
+ background: var(--surface-2);
+}
+
+.stickman-prompt-dialog > footer .is-primary {
+ border-color: var(--accent);
+ background: var(--accent);
+ color: var(--on-accent);
+}
+
+.stickman-prompt-dialog > footer .is-primary:hover {
+ border-color: var(--accent);
+ background: color-mix(in srgb, var(--accent) 88%, var(--text));
+ color: var(--on-accent);
+}
+
+.stickman-prompt-dialog > footer .is-primary:disabled {
+ cursor: not-allowed;
+ opacity: 0.46;
+}
+
+@media (max-width: 600px) {
+ .stickman-prompt-backdrop {
+ padding: 16px;
+ }
+
+ .stickman-prompt-dialog {
+ max-height: calc(100dvh - 32px);
+ }
+
+ .stickman-prompt-dialog > header,
+ .stickman-prompt-content,
+ .stickman-prompt-dialog > footer {
+ padding-right: 16px;
+ padding-left: 16px;
+ }
+
+ .stickman-prompt-content textarea {
+ min-height: 180px;
+ }
+}
+
+.stickman-audio-settings {
+ min-width: 0;
+}
+
+.stickman-audio-layout {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ align-items: start;
+ gap: 18px;
+}
+
+.stickman-voice-settings,
+.stickman-music-settings {
+ min-width: 0;
+}
+
+.stickman-music-settings {
+ padding-left: 18px;
+ border-left: 1px solid var(--border-hairline);
+}
+
+.stickman-music-heading {
+ min-height: 38px;
+ display: flex;
+ align-items: center;
+ gap: 9px;
+ color: var(--muted);
+}
+
+.stickman-music-heading > span {
+ min-width: 0;
+ display: flex;
+ align-items: baseline;
+ gap: 6px;
+}
+
+.stickman-music-heading strong {
+ color: var(--text);
+ font-size: 13px;
+ font-weight: 570;
+}
+
+.stickman-music-heading small {
+ color: var(--subtle);
+ font-size: 10px;
+}
+
+.stickman-music-upload-row {
+ position: relative;
+}
+
+.stickman-music-upload {
+ min-height: 102px;
+ padding: 10px 36px 10px 10px;
+}
+
+.stickman-music-upload strong {
+ max-width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.stickman-music-remove {
+ position: absolute;
+ top: 8px;
+ right: 8px;
+ width: 28px;
+ height: 28px;
display: grid;
place-items: center;
- border-radius: 6px;
- background: rgba(20, 22, 26, 0.82);
- color: #f7f7f8;
+ border: 1px solid var(--border);
+ border-radius: 7px;
+ background: var(--surface);
+ color: var(--muted);
+}
+
+.stickman-music-volume {
+ display: grid;
+ gap: 7px;
+ margin-top: 12px;
+}
+
+.stickman-music-volume > span {
+ display: flex;
+ justify-content: space-between;
+ color: var(--muted);
font-size: 11px;
- font-weight: 650;
}
-.stickman-storyboard-actions {
+.stickman-music-volume output {
+ color: var(--text);
+ font-weight: 620;
+}
+
+.stickman-music-volume input {
+ width: 100%;
+ accent-color: var(--accent);
+}
+
+.stickman-audio-step,
+.stickman-composition-step,
+.stickman-delivery-step {
min-width: 0;
- min-height: 24px;
- display: flex;
- align-items: center;
- gap: 8px;
+ min-height: 0;
+ height: 100%;
+ display: grid;
+ grid-template-rows: minmax(0, 1fr) auto;
+ gap: 14px;
}
-.stickman-storyboard-regenerate,
-.stickman-storyboard-prompt {
- width: max-content;
- min-height: 24px;
- display: inline-flex;
- align-items: center;
- justify-content: flex-start;
- gap: 5px;
- padding: 2px 0;
- border: 0;
- background: transparent;
- color: var(--subtle);
- font-size: 10px;
- font-weight: 580;
+.stickman-audio-review {
+ min-height: 0;
+ display: grid;
+ grid-template-rows: auto minmax(0, 1fr);
+ overflow: hidden;
+ padding-bottom: 4px;
}
-.stickman-storyboard-regenerate:hover,
-.stickman-storyboard-prompt:hover {
- background: transparent;
+.stickman-audio-meta {
+ min-width: 120px;
+ display: grid;
+ justify-items: end;
+ gap: 3px;
+ padding-top: 2px;
+}
+
+.stickman-audio-meta strong,
+.stickman-audio-meta small {
+ max-width: 180px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.stickman-audio-meta strong {
color: var(--text);
+ font-size: 12px;
+ font-weight: 620;
}
-.stickman-storyboard-copy {
+.stickman-audio-meta small {
+ color: var(--subtle);
+ font-size: 10px;
+}
+
+.stickman-audio-segments {
+ min-height: 0;
display: grid;
align-content: start;
+ overflow-y: auto;
+ padding-right: 8px;
+ border-top: 1px solid var(--border-hairline);
+ scrollbar-gutter: stable;
}
-.stickman-storyboard-subtitle textarea {
- min-height: 60px;
- resize: vertical;
+.stickman-inline-empty {
+ min-height: 220px;
+ display: grid;
+ place-content: center;
+ justify-items: center;
+ gap: 10px;
+ color: var(--muted);
+ font-size: 12px;
}
-.stickman-storyboard-readonly-subtitle {
+.stickman-audio-row {
+ min-width: 0;
display: grid;
+ grid-template-columns: 58px minmax(0, 1fr) minmax(220px, 0.8fr);
+ align-items: center;
+ gap: 16px;
+ padding: 16px 0;
+ border-bottom: 1px solid var(--border-hairline);
}
-.stickman-storyboard-readonly-subtitle p {
- min-height: 48px;
+.stickman-audio-row:last-child {
+ border-bottom: 0;
+}
+
+.stickman-audio-index {
+ display: grid;
+ gap: 5px;
+}
+
+.stickman-audio-index strong {
+ color: var(--text);
+ font-size: 13px;
+}
+
+.stickman-audio-index small {
+ color: var(--subtle);
+ font-size: 10px;
+}
+
+.stickman-audio-row > p {
+ min-width: 0;
margin: 0;
- padding: 8px 10px;
- border: 1px solid var(--border-hairline);
- border-radius: 7px;
- background: var(--surface-2);
color: var(--text);
font-size: 12px;
- line-height: 1.55;
+ line-height: 1.65;
}
-.stickman-prompt-backdrop {
- position: fixed;
- inset: 0;
- z-index: 120;
- display: grid;
- place-items: center;
- padding: 24px;
- background: rgba(15, 17, 21, 0.52);
+.stickman-audio-control {
+ min-width: 0;
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
}
-.stickman-prompt-dialog {
- width: min(560px, calc(100vw - 32px));
- max-height: min(680px, calc(100dvh - 48px));
+.stickman-audio-control audio {
+ width: 100%;
+ height: 34px;
+}
+
+.stickman-audio-control > span,
+.stickman-audio-control > button {
+ display: inline-flex;
+ align-items: center;
+ gap: 7px;
+ color: var(--muted);
+ font-size: 11px;
+}
+
+.stickman-audio-control > button {
+ min-height: 32px;
+ padding: 0 10px;
+ border: 1px solid var(--border);
+ border-radius: 7px;
+ background: var(--surface);
+ color: var(--danger);
+}
+
+.stickman-storyboard-narration {
display: grid;
- grid-template-rows: auto minmax(0, 1fr) auto;
+ gap: 4px;
+ margin-top: 10px;
+ padding-top: 9px;
+ border-top: 1px solid var(--border-hairline);
+}
+
+.stickman-storyboard-narration > span {
+ color: var(--subtle);
+ font-size: 10px;
+ font-weight: 620;
+}
+
+.stickman-storyboard-narration > p {
+ margin: 0;
+ color: var(--muted);
+ font-size: 11px;
+ line-height: 1.55;
+}
+
+.stickman-composition-content {
+ min-height: 0;
+ overflow-y: auto;
+ padding-right: 2px;
+ scrollbar-gutter: stable;
+}
+
+.stickman-composition-panel {
+ min-height: 100%;
+ box-sizing: border-box;
+}
+
+.stickman-delivery-preview {
+ min-width: 0;
+ aspect-ratio: 16 / 9;
overflow: hidden;
- border: 1px solid var(--border);
+ border: 1px solid var(--border-hairline);
border-radius: 8px;
- background: var(--surface);
- box-shadow: 0 24px 72px rgba(15, 17, 21, 0.24);
+ background: #17191d;
}
-.stickman-prompt-dialog > header {
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- gap: 16px;
- padding: 18px 20px;
- border-bottom: 1px solid var(--border-hairline);
+.stickman-delivery-preview video {
+ width: 100%;
+ height: 100%;
+ display: block;
+ object-fit: contain;
+}
+
+.stickman-delivery-preview > div {
+ width: 100%;
+ height: 100%;
+ display: grid;
+ place-content: center;
+ justify-items: center;
+ gap: 10px;
+ padding: 24px;
+ color: #a9adb5;
+ font-size: 12px;
+ text-align: center;
+ box-sizing: border-box;
+}
+
+.stickman-composition-phases {
+ min-width: 0;
+ max-width: 720px;
+ display: grid;
+ margin-top: 18px;
}
-.stickman-prompt-dialog > header span {
- display: block;
- margin-bottom: 3px;
- color: var(--muted);
- font-size: 11px;
+.stickman-composition-phases > div {
+ min-width: 0;
+ min-height: 54px;
+ display: grid;
+ grid-template-columns: 32px minmax(0, 1fr) 18px;
+ align-items: center;
+ gap: 10px;
+ padding: 8px 0;
+ border-bottom: 1px solid var(--border-hairline);
}
-.stickman-prompt-dialog > header h2 {
- margin: 0;
- color: var(--text);
- font-size: 17px;
- font-weight: 640;
+.stickman-composition-phases > div:last-child {
+ border-bottom: 0;
}
-.stickman-prompt-dialog > header > button {
+.stickman-composition-phases > div > span {
width: 30px;
height: 30px;
- flex: none;
display: grid;
place-items: center;
- padding: 0;
- border: 1px solid var(--border);
border-radius: 7px;
- background: var(--surface);
- color: var(--muted);
-}
-
-.stickman-prompt-dialog > header > button:hover {
background: var(--surface-2);
- color: var(--text);
-}
-
-.stickman-prompt-content {
- min-height: 0;
- display: grid;
- gap: 7px;
- overflow: auto;
- padding: 18px 20px;
-}
-
-.stickman-prompt-content > span {
color: var(--muted);
- font-size: 11px;
- font-weight: 580;
-}
-
-.stickman-prompt-content textarea {
- width: 100%;
- min-height: 220px;
- box-sizing: border-box;
- resize: none;
- padding: 12px;
- border: 1px solid var(--border);
- border-radius: 7px;
- outline: 0;
- background: var(--conversation-bg);
- color: var(--text);
- font: inherit;
- font-size: 12px;
- line-height: 1.65;
}
-.stickman-prompt-content textarea:focus {
- border-color: var(--border-strong);
- box-shadow: 0 0 0 2px color-mix(in srgb, var(--text) 5%, transparent);
+.stickman-composition-phases > div > div {
+ min-width: 0;
+ display: grid;
+ gap: 3px;
}
-.stickman-prompt-dialog > footer {
- display: flex;
- justify-content: flex-end;
- gap: 8px;
- padding: 12px 20px;
- border-top: 1px solid var(--border-hairline);
+.stickman-composition-phases strong,
+.stickman-composition-phases small {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
-.stickman-prompt-dialog > footer button {
- min-height: 34px;
- padding: 0 14px;
- border: 1px solid var(--border);
- border-radius: 7px;
- background: var(--surface);
+.stickman-composition-phases strong {
color: var(--text);
font-size: 12px;
- font-weight: 580;
+ font-weight: 620;
}
-.stickman-prompt-dialog > footer button:hover {
- border-color: var(--border-strong);
- background: var(--surface-2);
+.stickman-composition-phases small {
+ color: var(--subtle);
+ font-size: 10px;
}
-.stickman-prompt-dialog > footer .is-primary {
- border-color: var(--accent);
- background: var(--accent);
- color: var(--on-accent);
+.stickman-composition-phases > div[data-status="completed"] > span,
+.stickman-composition-phases > div[data-status="completed"] > svg {
+ color: var(--success, #2f855a);
}
-.stickman-prompt-dialog > footer .is-primary:hover {
- border-color: var(--accent);
- background: color-mix(in srgb, var(--accent) 88%, var(--text));
- color: var(--on-accent);
+.stickman-composition-phases > div[data-status="running"] > span,
+.stickman-composition-phases > div[data-status="running"] > svg {
+ color: var(--accent);
}
-.stickman-prompt-dialog > footer .is-primary:disabled {
- cursor: not-allowed;
- opacity: 0.46;
+.stickman-composition-phases > div[data-status="failed"] > span,
+.stickman-composition-phases > div[data-status="failed"] > svg {
+ color: var(--danger);
}
-@media (max-width: 600px) {
- .stickman-prompt-backdrop {
- padding: 16px;
- }
-
- .stickman-prompt-dialog {
- max-height: calc(100dvh - 32px);
- }
-
- .stickman-prompt-dialog > header,
- .stickman-prompt-content,
- .stickman-prompt-dialog > footer {
- padding-right: 16px;
- padding-left: 16px;
- }
-
- .stickman-prompt-content textarea {
- min-height: 180px;
- }
+.stickman-delivery-step {
+ grid-template-rows: auto minmax(0, 1fr) auto;
}
-.stickman-audio-settings {
- min-width: 0;
+.stickman-result-toolbar {
+ min-height: 46px;
+ align-items: center;
+ margin-bottom: 0;
+ padding: 0 2px 14px;
+ border-bottom: 1px solid var(--border-hairline);
}
-.stickman-audio-layout {
+.stickman-delivery-content {
+ min-height: 0;
display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
+ grid-template-columns: minmax(340px, 1.45fr) minmax(280px, 0.9fr);
align-items: start;
- gap: 18px;
+ gap: 22px;
+ overflow-y: auto;
+ padding: 16px 2px 4px;
+ scrollbar-gutter: stable;
}
-.stickman-voice-settings,
-.stickman-music-settings {
+.stickman-delivery-files {
min-width: 0;
}
-.stickman-music-settings {
- padding-left: 18px;
- border-left: 1px solid var(--border-hairline);
-}
-
-.stickman-music-heading {
- min-height: 38px;
- display: flex;
- align-items: center;
- gap: 9px;
- color: var(--muted);
-}
-
-.stickman-music-heading > span {
- min-width: 0;
+.stickman-delivery-files > header {
+ min-height: 30px;
display: flex;
align-items: baseline;
- gap: 6px;
+ justify-content: space-between;
+ gap: 12px;
+ padding-bottom: 8px;
}
-.stickman-music-heading strong {
+.stickman-delivery-files h3 {
+ margin: 0;
color: var(--text);
font-size: 13px;
- font-weight: 570;
+ font-weight: 650;
+ letter-spacing: 0;
}
-.stickman-music-heading small {
+.stickman-delivery-files > header > span {
color: var(--subtle);
font-size: 10px;
}
-.stickman-music-upload-row {
- position: relative;
+.stickman-delivery-files .creator-result-files {
+ display: grid;
}
-.stickman-music-upload {
- min-height: 102px;
- padding: 10px 36px 10px 10px;
+.stickman-delivery-files .creator-result-files > article {
+ min-width: 0;
+ min-height: 58px;
+ display: grid;
+ grid-template-columns: 34px minmax(0, 1fr) 30px 30px;
+ align-items: center;
+ gap: 9px;
+ padding: 9px 0;
+ border-bottom: 1px solid var(--border-hairline);
}
-.stickman-music-upload strong {
- max-width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
+.stickman-delivery-files .creator-result-files > article:first-child {
+ border-top: 1px solid var(--border-hairline);
}
-.stickman-music-remove {
- position: absolute;
- top: 8px;
- right: 8px;
- width: 28px;
- height: 28px;
+.stickman-delivery-files .creator-result-files > article > span {
+ width: 32px;
+ height: 32px;
display: grid;
place-items: center;
- border: 1px solid var(--border);
border-radius: 7px;
- background: var(--surface);
+ background: var(--surface-2);
color: var(--muted);
}
-.stickman-music-volume {
+.stickman-delivery-files .creator-result-files > article > div {
+ min-width: 0;
display: grid;
- gap: 7px;
- margin-top: 12px;
+ gap: 3px;
}
-.stickman-music-volume > span {
- display: flex;
- justify-content: space-between;
- color: var(--muted);
- font-size: 11px;
+.stickman-delivery-files .creator-result-files strong,
+.stickman-delivery-files .creator-result-files small {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
-.stickman-music-volume output {
+.stickman-delivery-files .creator-result-files strong {
color: var(--text);
+ font-size: 12px;
font-weight: 620;
}
-.stickman-music-volume input {
- width: 100%;
- accent-color: var(--accent);
+.stickman-delivery-files .creator-result-files small {
+ color: var(--subtle);
+ font-size: 10px;
+}
+
+.stickman-delivery-files .creator-result-files button {
+ width: 30px;
+ height: 30px;
+ display: grid;
+ place-items: center;
+ padding: 0;
+ border: 1px solid var(--border);
+ border-radius: 7px;
+ background: var(--surface);
+ color: var(--muted);
+}
+
+.stickman-delivery-files .creator-result-files button:hover:not(:disabled) {
+ background: var(--surface-2);
+ color: var(--text);
+}
+
+.stickman-delivery-files .creator-result-files button:disabled {
+ cursor: default;
+ opacity: 0.38;
}
.stickman-video-result {
@@ -7666,6 +8892,19 @@
line-height: 1.45;
}
+.stickman-delivery-status {
+ display: block;
+ margin-top: 8px;
+ color: var(--warning, #b7791f);
+ font-size: 12px;
+ line-height: 1.45;
+ letter-spacing: 0;
+}
+
+.stickman-delivery-status[data-status="publishable"] {
+ color: var(--success, #2f855a);
+}
+
.stickman-result-workspace {
height: auto;
min-height: 520px;
@@ -9836,10 +11075,24 @@
.creator-task-final-grid,
.creator-result-layout,
- .stickman-audio-layout {
+ .stickman-audio-layout,
+ .stickman-delivery-content {
grid-template-columns: minmax(0, 1fr);
}
+ .stickman-delivery-preview {
+ width: min(560px, 100%);
+ }
+
+ .stickman-audio-row {
+ grid-template-columns: 50px minmax(0, 1fr);
+ }
+
+ .stickman-audio-control {
+ grid-column: 2;
+ justify-content: flex-start;
+ }
+
.creator-result-layout > .creator-task-summary {
position: static;
}
@@ -9877,6 +11130,25 @@
.stickman-storyboard-row {
grid-template-columns: minmax(0, 1fr);
}
+
+ .stickman-steps button {
+ padding-right: 2px;
+ padding-left: 2px;
+ }
+
+ .stickman-steps button strong {
+ min-height: 30px;
+ font-size: 10px;
+ }
+
+ .stickman-audio-meta {
+ display: none;
+ }
+
+ .stickman-delivery-files .creator-result-files > article {
+ grid-template-columns: 32px minmax(0, 1fr) 28px 28px;
+ gap: 7px;
+ }
}
.creator-collaboration-header {
diff --git a/apps/web/src/features/projects/ProjectsPage.test.tsx b/apps/web/src/features/projects/ProjectsPage.test.tsx
index c69b7f44..ad4e2f70 100644
--- a/apps/web/src/features/projects/ProjectsPage.test.tsx
+++ b/apps/web/src/features/projects/ProjectsPage.test.tsx
@@ -36,7 +36,14 @@ const jobs = [
id: 'job_stickman',
templateId: 'stickman-video',
state: { topic: '如何建立内容创作流程' },
- updatedAt: '2026-08-19T10:00:00.000Z'
+ updatedAt: '2026-08-19T10:00:00.000Z',
+ artifacts: [
+ artifact('job_stickman', 'clean_video', 'landscape-clean.mp4'),
+ artifact('job_stickman', 'cover_image', 'youtube-cover.png'),
+ artifact('job_stickman', 'publish_copy', 'publish-copy-youtube.md'),
+ artifact('job_stickman', 'bilingual_video', 'horizontal-bilingual.mp4'),
+ artifact('job_stickman', 'bilingual_subtitle', 'bilingual.srt')
+ ]
})
];
@@ -49,13 +56,13 @@ describe('ProjectsPage', () => {
);
expect(screen.getByRole('heading', { name: 'My Projects' })).toBeInTheDocument();
- expect(screen.queryByRole('heading', { name: 'Recent projects' })).not.toBeInTheDocument();
- expect(screen.queryByText('Output Center')).not.toBeInTheDocument();
- expect(screen.queryByRole('tablist', { name: 'Content view' })).not.toBeInTheDocument();
+ expect(screen.getByRole('heading', { name: 'Recent projects' })).toBeInTheDocument();
+ expect(screen.getByText('Output Center')).toBeInTheDocument();
+ expect(screen.getByRole('tablist', { name: 'Content view' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Open project 夏季新品封面' })).toBeInTheDocument();
expect(screen.getByText('Thumbnail generation')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Open project 夏季新品封面' }))
- .not.toHaveTextContent('默认工作目录');
+ .toHaveTextContent('默认工作目录');
expect(screen.getByRole('button', { name: 'Open project 夏季新品封面' }).querySelector('img'))
.toHaveAttribute('src', '/dashboard/templates/image-generation-project-cover.png');
expect(screen.getByRole('button', { name: 'Open project youtube.com · launch-talk' }).querySelector('img'))
@@ -423,6 +430,32 @@ describe('ProjectsPage', () => {
expect(screen.queryByRole('button', { name: '打开项目 夏季新品封面' })).not.toBeInTheDocument();
});
+ it('builds the output center from persisted artifacts without synthetic files', () => {
+ const onOpenJob = vi.fn();
+ render(<ProjectsPage jobs={jobs} workspaces={workspaces} onOpenJob={onOpenJob} />);
+
+ fireEvent.click(within(screen.getByRole('tablist', { name: '内容维度' }))
+ .getByRole('tab', { name: '产出中心' }));
+
+ const outputList = screen.getByRole('list', { name: '产出列表' });
+ expect(within(outputList).getAllByRole('listitem')).toHaveLength(7);
+ expect(screen.getByText('target.srt')).toBeInTheDocument();
+ expect(screen.getByText('translated.mp4')).toBeInTheDocument();
+ for (const fileName of [
+ 'landscape-clean.mp4',
+ 'youtube-cover.png',
+ 'publish-copy-youtube.md',
+ 'horizontal-bilingual.mp4',
+ 'bilingual.srt'
+ ]) {
+ expect(screen.getByText(fileName)).toBeInTheDocument();
+ }
+ expect(screen.queryByText(/最终成片|方案 01|配音音轨/)).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: '在项目中打开产出 translated.mp4' }));
+ expect(onOpenJob).toHaveBeenCalledWith(expect.objectContaining({ id: 'job_translation' }));
+ });
+
it('classifies generated image projects and shows their shared project cover', () => {
const imageJob = creatorJob({
id: 'job_image_generation',
@@ -444,6 +477,13 @@ describe('ProjectsPage', () => {
.toHaveTextContent('图像生成');
expect(screen.getByRole('button', { name: '打开项目 清晨海边的产品摄影' }).querySelector('img'))
.toHaveAttribute('src', '/dashboard/templates/image-generation-project-cover.png');
+ fireEvent.click(within(screen.getByRole('tablist', { name: '内容维度' }))
+ .getByRole('tab', { name: '产出中心' }));
+ const output = screen.getByRole('button', {
+ name: '在项目中打开产出 generated-image.png'
+ });
+ expect(output).toBeInTheDocument();
+ expect(within(output).getByText('PNG')).toBeInTheDocument();
});
it('lists Xiaohongshu posts as writing projects and hides untouched drafts', () => {
@@ -512,13 +552,14 @@ function creatorJob(input: {
id: input.id,
projectId: 'workspace_1',
templateId: input.templateId,
- templateVersion: 1,
+ templateVersion: input.templateId === 'stickman-video' ? 2 : 1,
status: input.artifacts === undefined ? 'draft' : 'completed',
revision: 0,
state: input.state,
agentThreadId: null,
stages: [],
artifacts: input.artifacts ?? [],
+ providerRequests: [],
activities: [],
createdAt: input.updatedAt,
updatedAt: input.updatedAt
@@ -533,6 +574,9 @@ function artifact(jobId: string, kind: string, fileName: string): CreatorJob['ar
version: 1,
status: 'completed',
path: `/outputs/${fileName}`,
+ scopeKey: null,
+ inputFingerprint: null,
+ sha256: null,
sourceArtifactIds: [],
metadata: { fileName },
createdAt: '2026-08-17T10:00:00.000Z'
diff --git a/apps/web/src/features/projects/ProjectsPage.tsx b/apps/web/src/features/projects/ProjectsPage.tsx
index d9221837..ff77ff4b 100644
--- a/apps/web/src/features/projects/ProjectsPage.tsx
+++ b/apps/web/src/features/projects/ProjectsPage.tsx
@@ -1,8 +1,15 @@
-import type { CreatorJob } from '@opencreator/protocol';
+import type { CreatorArtifact, CreatorJob } from '@opencreator/protocol';
import {
+ Captions,
+ CirclePlay,
+ FileText,
FolderKanban,
+ Image as ImageIcon,
+ Music2,
+ PackageOpen,
Search,
- Trash2
+ Trash2,
+ Video
} from 'lucide-react';
import { useEffect, useMemo, useState } from 'react';
import { ConfirmDialog } from '../../components/dialogs/ConfirmDialog.js';
@@ -15,6 +22,42 @@ import './projects-page.css';
const projectCategories = ['全部', '视频创作', '图像设计', '文案创作'] as const;
type ProjectCategory = typeof projectCategories[number];
+const outputCategories = ['全部', '视频', '图片', '音频', '字幕', '文档'] as const;
+type OutputCategory = typeof outputCategories[number];
+type ProjectsView = 'projects' | 'outputs';
+type ProjectOutputKind = Exclude<OutputCategory, '全部'>;
+
+type ProjectOutput = {
+ id: string;
+ job: CreatorJob;
+ projectName: string;
+ name: string;
+ kind: ProjectOutputKind;
+ format: string;
+ detail: string;
+ cover: string;
+ youtubeCovers: string[];
+ updatedAt: string;
+};
+
+const projectArtifactKinds = new Set([
+ 'source_video',
+ 'source_subtitle',
+ 'target_subtitle',
+ 'bilingual_subtitle',
+ 'dubbed_audio',
+ 'horizontal_video',
+ 'vertical_video',
+ 'auto_clip_video',
+ 'clean_video',
+ 'bilingual_video',
+ 'cover_image',
+ 'generated_image',
+ 'publish_copy',
+ 'script_manifest',
+ 'shot_image',
+ 'clip_candidates'
+]);
const projectCoverArtifactKinds = new Set([
'cover_image',
'generated_image',
@@ -24,6 +67,8 @@ const projectCoverArtifactKinds = new Set([
'dubbed_video',
'auto_clip_video',
'stickman_video',
+ 'clean_video',
+ 'bilingual_video',
'clip_video',
'generated_video'
]);
@@ -49,8 +94,10 @@ export default function ProjectsPage(props: {
}) {
const { language } = useAppLanguage();
const l = useLocalizedCopy();
+ const [view, setView] = useState<ProjectsView>('projects');
const [query, setQuery] = useState('');
const [category, setCategory] = useState<ProjectCategory>('全部');
+ const [outputCategory, setOutputCategory] = useState<OutputCategory>('全部');
const [projectPendingDeletion, setProjectPendingDeletion] = useState<CreatorProject>();
const [deleteProjectFiles, setDeleteProjectFiles] = useState(false);
const [deletingProjectId, setDeletingProjectId] = useState<string>();
@@ -73,6 +120,22 @@ export default function ProjectsPage(props: {
].join(' ').toLocaleLowerCase().includes(normalizedQuery))
.sort((left, right) => right.job.updatedAt.localeCompare(left.job.updatedAt)),
[category, normalizedQuery, projects]);
+ const outputs = useMemo(
+ () => projects.flatMap(project => createProjectOutputs(project, l)),
+ [l, projects]
+ );
+ const visibleOutputs = useMemo(() => outputs
+ .filter(output => outputCategory === '全部' || output.kind === outputCategory)
+ .filter(output => normalizedQuery.length === 0 || `${output.name} ${output.projectName} ${output.format}`
+ .toLocaleLowerCase()
+ .includes(normalizedQuery))
+ .sort((left, right) => right.updatedAt.localeCompare(left.updatedAt)),
+ [normalizedQuery, outputCategory, outputs]);
+
+ function selectView(nextView: ProjectsView) {
+ setView(nextView);
+ setQuery('');
+ }
return (
<main className="projects-page">
@@ -80,7 +143,9 @@ export default function ProjectsPage(props: {
<header className="projects-page-header">
<div>
<h1>{l('我的项目', 'My Projects')}</h1>
- <p>{l('继续最近的创作项目,保留完整设置、进度和历史', 'Continue recent creator projects with their settings, progress, and history')}</p>
+ <p>{view === 'projects'
+ ? l('继续最近的创作项目,保留完整设置、进度和历史', 'Continue recent creator projects with their settings, progress, and history')
+ : l('集中查看所有创作项目产生的真实文件', 'Review real files generated across creator projects')}</p>
</div>
<label className="projects-search">
<Search size={17} strokeWidth={1.8} aria-hidden="true" />
@@ -88,32 +153,51 @@ export default function ProjectsPage(props: {
type="search"
value={query}
onChange={event => setQuery(event.target.value)}
- aria-label={l('搜索项目', 'Search projects')}
- placeholder={l('搜索项目', 'Search projects')}
+ aria-label={view === 'projects' ? l('搜索项目', 'Search projects') : l('搜索产出', 'Search outputs')}
+ placeholder={view === 'projects' ? l('搜索项目', 'Search projects') : l('搜索产出', 'Search outputs')}
/>
</label>
</header>
- <div className="projects-category-tabs" role="tablist" aria-label={l('项目分类', 'Project categories')}>
- {projectCategories.map(item => (
+ <div className="projects-dimension-tabs" role="tablist" aria-label={l('内容维度', 'Content view')}>
+ <button type="button" role="tab" aria-selected={view === 'projects'} onClick={() => selectView('projects')}>
+ <FolderKanban size={16} strokeWidth={1.8} aria-hidden="true" />
+ {l('项目', 'Projects')}
+ </button>
+ <button type="button" role="tab" aria-selected={view === 'outputs'} onClick={() => selectView('outputs')}>
+ <PackageOpen size={16} strokeWidth={1.8} aria-hidden="true" />
+ {l('产出中心', 'Output Center')}
+ </button>
+ </div>
+
+ <div className={`projects-category-tabs${view === 'outputs' ? ' is-output' : ''}`} role="tablist" aria-label={view === 'projects' ? l('项目分类', 'Project categories') : l('产出分类', 'Output categories')}>
+ {(view === 'projects' ? projectCategories : outputCategories).map(item => (
<button
type="button"
role="tab"
key={item}
- aria-selected={category === item}
- onClick={() => setCategory(item)}
+ aria-selected={view === 'projects' ? category === item : outputCategory === item}
+ onClick={() => view === 'projects'
+ ? setCategory(item as ProjectCategory)
+ : setOutputCategory(item as OutputCategory)}
>
- {localizeProjectCategory(item, l)}
+ {view === 'projects'
+ ? localizeProjectCategory(item as ProjectCategory, l)
+ : localizeOutputCategory(item as OutputCategory, l)}
</button>
))}
</div>
- <section className="projects-library" aria-label={l('项目列表', 'Project list')}>
- <div className={`projects-library-heading${category === '全部' ? ' is-count-only' : ''}`}>
- {category === '全部' ? null : (
- <h2>{localizeProjectCategory(category, l)}</h2>
- )}
- <span>{`${visibleProjects.length} ${l('个项目', 'projects')}`}</span>
+ <section className="projects-library" aria-labelledby="projects-library-title">
+ <div className="projects-library-heading">
+ <h2 id="projects-library-title">
+ {view === 'projects'
+ ? category === '全部' ? l('最近项目', 'Recent projects') : localizeProjectCategory(category, l)
+ : outputCategory === '全部' ? l('全部产出', 'All outputs') : localizeOutputCategory(outputCategory, l)}
+ </h2>
+ <span>{view === 'projects'
+ ? `${visibleProjects.length} ${l('个项目', 'projects')}`
+ : `${visibleOutputs.length} ${l('个产出', 'outputs')}`}</span>
</div>
{props.error !== undefined ? (
@@ -127,7 +211,7 @@ export default function ProjectsPage(props: {
<FolderKanban size={28} strokeWidth={1.5} aria-hidden="true" />
<strong>{l('正在加载最近项目', 'Loading recent projects')}</strong>
</div>
- ) : visibleProjects.length > 0 ? (
+ ) : view === 'projects' ? visibleProjects.length > 0 ? (
<div className="projects-card-grid" role="list" aria-label={l('项目列表', 'Project list')}>
{visibleProjects.map(project => (
<article className="project-card" role="listitem" key={project.job.id}>
@@ -149,7 +233,7 @@ export default function ProjectsPage(props: {
<span className="project-card-copy">
<small>{project.type}</small>
<strong>{project.title}</strong>
- <span>{formatProjectTime(project.job.updatedAt, language)}</span>
+ <span>{project.workspaceName} · {formatProjectTime(project.job.updatedAt, language)}</span>
</span>
</button>
{props.onDeleteJob !== undefined ? (
@@ -185,6 +269,61 @@ export default function ProjectsPage(props: {
? l('换个名称重新搜索。', 'Try searching with another name.')
: l('完成对应类型的创作后,项目会显示在这里。', 'Projects of this type will appear here after you create them.')}</p>
</div>
+ ) : visibleOutputs.length > 0 ? (
+ <div className="project-output-grid" role="list" aria-label={l('产出列表', 'Output list')}>
+ {visibleOutputs.map(output => (
+ <article className="project-output-card" role="listitem" key={output.id}>
+ <button
+ type="button"
+ className="project-output-open"
+ aria-label={`${l('在项目中打开产出', 'Open output in project')} ${output.name}`}
+ onClick={() => props.onOpenJob(output.job)}
+ >
+ <span className="project-output-preview" data-kind={output.kind}>
+ {output.kind === '视频' || output.kind === '图片' ? (
+ <ProjectCoverImage
+ job={output.job}
+ youtubeCovers={output.youtubeCovers}
+ fallback={output.cover}
+ service={props.service}
+ />
+ ) : (
+ <span className="project-output-file-icon" aria-hidden="true">
+ {outputKindIcon(output.kind, 28)}
+ </span>
+ )}
+ {output.kind === '视频' ? (
+ <span className="project-output-play" aria-hidden="true">
+ <CirclePlay size={28} strokeWidth={1.6} />
+ </span>
+ ) : null}
+ <small>{output.format}</small>
+ </span>
+ <span className="project-output-copy">
+ <span className="project-output-kind">
+ {outputKindIcon(output.kind, 13)}
+ {localizeOutputCategory(output.kind, l)}
+ </span>
+ <strong>{output.name}</strong>
+ <span>{output.projectName}</span>
+ <small>{output.detail} · {formatProjectTime(output.updatedAt, language)}</small>
+ </span>
+ </button>
+ </article>
+ ))}
+ </div>
+ ) : (
+ <div className="projects-empty" role="status">
+ <PackageOpen size={28} strokeWidth={1.5} aria-hidden="true" />
+ <strong>{normalizedQuery.length > 0
+ ? l('没有找到匹配的产出', 'No matching outputs')
+ : outputCategory === '全部'
+ ? l('还没有产出', 'No outputs yet')
+ : l('这个分类还没有产出', 'No outputs in this category')}</strong>
+ <p>{normalizedQuery.length > 0
+ ? l('换个名称重新搜索。', 'Try searching with another name.')
+ : l('创作项目生成真实文件后,会集中显示在这里。', 'Files generated by creator projects will appear here.')}</p>
+ </div>
)}
</section>
</div>
@@ -520,6 +659,85 @@ function localizeJobStatus(status: CreatorJob['status'], l: LocalizeCopy): strin
return l('草稿', 'Draft');
}
+function outputKindIcon(kind: ProjectOutputKind, size: number) {
+ if (kind === '视频') return <Video size={size} strokeWidth={1.8} aria-hidden="true" />;
+ if (kind === '图片') return <ImageIcon size={size} strokeWidth={1.8} aria-hidden="true" />;
+ if (kind === '音频') return <Music2 size={size} strokeWidth={1.8} aria-hidden="true" />;
+ if (kind === '字幕') return <Captions size={size} strokeWidth={1.8} aria-hidden="true" />;
+ return <FileText size={size} strokeWidth={1.8} aria-hidden="true" />;
+}
+
+function createProjectOutputs(project: CreatorProject, l: LocalizeCopy): ProjectOutput[] {
+ return project.job.artifacts
+ .filter(artifact => (
+ artifact.path !== null
+ && artifact.status !== 'stale'
+ && projectArtifactKinds.has(artifact.kind)
+ ))
+ .map(artifact => ({
+ id: artifact.id,
+ job: project.job,
+ projectName: project.title,
+ name: artifactName(artifact, l),
+ kind: artifactKind(artifact.kind),
+ format: artifactFormat(artifact),
+ detail: artifact.status === 'technical_preview'
+ ? l(`技术预览 · V${artifact.version}`, `Technical preview · V${artifact.version}`)
+ : `V${artifact.version}`,
+ cover: project.cover,
+ youtubeCovers: project.youtubeCovers,
+ updatedAt: artifact.createdAt
+ }));
+}
+
+function artifactName(artifact: CreatorArtifact, l: LocalizeCopy): string {
+ const fileName = artifact.metadata.fileName;
+ if (typeof fileName === 'string' && fileName.trim().length > 0) return fileName;
+ const pathName = artifact.path?.split(/[\\/]/).at(-1);
+ if (pathName !== undefined && pathName.length > 0) return pathName;
+ const labels: Record<string, string> = {
+ source_video: l('原始视频', 'Source video'),
+ target_subtitle: l('目标语言字幕', 'Translated subtitles'),
+ source_subtitle: l('原文字幕', 'Source subtitles'),
+ bilingual_subtitle: l('双语字幕', 'Bilingual subtitles'),
+ dubbed_audio: l('配音音轨', 'Dubbed audio'),
+ horizontal_video: l('横屏成片', 'Landscape video'),
+ vertical_video: l('竖屏成片', 'Portrait video'),
+ auto_clip_video: l('剪辑成片', 'Edited video'),
+ cover_image: l('封面图片', 'Thumbnail'),
+ generated_image: l('生成图片', 'Generated image'),
+ clean_video: l('火柴人纯净视频', 'Stickman clean video'),
+ bilingual_video: l('火柴人双语视频', 'Stickman bilingual video'),
+ publish_copy: l('发布文案', 'Publish copy'),
+ shot_image: l('火柴人镜头画面', 'Stickman shot visual')
+ };
+ return labels[artifact.kind] ?? artifact.kind;
+}
+
+function artifactKind(kind: string): ProjectOutputKind {
+ if (/video/i.test(kind)) return '视频';
+ if (/image|cover|storyboard/i.test(kind)) return '图片';
+ if (/audio|narration|voice/i.test(kind)) return '音频';
+ if (/subtitle|caption/i.test(kind)) return '字幕';
+ return '文档';
+}
+
+function artifactFormat(artifact: CreatorArtifact): string {
+ const fileName = typeof artifact.metadata.fileName === 'string'
+ ? artifact.metadata.fileName
+ : artifact.path?.split(/[\\/]/).at(-1);
+ const extension = fileName?.split('.').at(-1);
+ return extension === undefined || extension === fileName ? 'FILE' : extension.toUpperCase();
+}
+
+function localizeOutputCategory(category: OutputCategory, l: LocalizeCopy): string {
+ if (category === '全部') return l(category, 'All');
+ if (category === '视频') return l(category, 'Videos');
+ if (category === '图片') return l(category, 'Images');
+ if (category === '音频') return l(category, 'Audio');
+ if (category === '字幕') return l(category, 'Subtitles');
+ return l(category, 'Documents');
+}
function projectCover(templateId: string): string {
if (templateId === 'video-translation') {
return '/dashboard/templates/video-translation-project-cover.png';
diff --git a/apps/web/src/features/settings/CreatorServicesSettingsView.test.tsx b/apps/web/src/features/settings/CreatorServicesSettingsView.test.tsx
index cf58e064..7bc565ff 100644
--- a/apps/web/src/features/settings/CreatorServicesSettingsView.test.tsx
+++ b/apps/web/src/features/settings/CreatorServicesSettingsView.test.tsx
@@ -137,6 +137,7 @@ describe('CreatorServicesSettingsView', () => {
it('allows selecting and saving local Whisper.cpp on Windows x64', async () => {
const service = createService([], runtimeCapabilities('win32', 'x64'));
+ const user = userEvent.setup();
render(
<ConfirmDialogProvider>
<CreatorServicesSettingsView
@@ -147,15 +148,16 @@ describe('CreatorServicesSettingsView', () => {
</ConfirmDialogProvider>
);
- await userEvent.setup().click(await screen.findByRole('tab', { name: '语音识别' }));
+ await user.click(await screen.findByRole('tab', { name: '语音识别' }));
expect(screen.getByText('Windows · x64')).toBeInTheDocument();
- await userEvent.setup().click(screen.getByRole('button', { name: '本地 Whisper' }));
expect(screen.getByRole('button', { name: '本地 Whisper' })).toBeEnabled();
+ await user.click(screen.getByRole('button', { name: '本地 Whisper' }));
+ expect(screen.getByRole('combobox', { name: '语音识别服务' })).toHaveTextContent('Whisper.cpp');
+ expect(screen.getByText('tiny')).toBeInTheDocument();
expect(screen.queryByText('WhisperKit')).not.toBeInTheDocument();
expect(screen.queryByText('FasterWhisper')).not.toBeInTheDocument();
- expect(screen.getByText('Whisper.cpp')).toBeInTheDocument();
- await userEvent.setup().click(screen.getByRole('button', { name: '保存配置' }));
- await userEvent.setup().click(await screen.findByRole('button', { name: '保存并启用' }));
+ await user.click(screen.getByRole('button', { name: '保存配置' }));
+ await user.click(await screen.findByRole('button', { name: '保存并启用' }));
expect(service.saveConfig).toHaveBeenCalledWith(expect.objectContaining({
transcription: expect.objectContaining({ provider: 'whisper.cpp' })
}));
@@ -331,6 +333,7 @@ function runtimeCapabilities(
arch: string
): CreatorServicesCapabilitiesResponse {
const whisperKitAvailable = platform === 'darwin' && arch === 'arm64';
+ const whisperCppAvailable = platform === 'win32' && arch === 'x64';
return {
platform,
arch,
@@ -364,10 +367,10 @@ function runtimeCapabilities(
{
provider: 'whisper.cpp',
kind: 'local',
- available: platform === 'win32' && arch === 'x64',
+ available: whisperCppAvailable,
models: ['tiny', 'medium', 'large-v2'],
gpuAcceleration: false,
- ...(platform === 'win32' && arch === 'x64' ? {} : { unavailableReason: 'unsupported_platform' as const })
+ ...(whisperCppAvailable ? {} : { unavailableReason: 'unsupported_platform' as const })
},
{
provider: 'aliyun',
diff --git a/apps/web/src/services/creator-service.test.ts b/apps/web/src/services/creator-service.test.ts
index 3a0185dd..de01b44e 100644
--- a/apps/web/src/services/creator-service.test.ts
+++ b/apps/web/src/services/creator-service.test.ts
@@ -76,6 +76,8 @@ describe('creator web service', () => {
await service.openArtifact('job_1', 'artifact 1');
await service.deleteJob('job 1');
await service.deleteJob('job 2', { deleteFiles: true });
+ await service.listVisualAssets('stickman-video', 'style');
+ await service.openVisualAssetPreview('stickman.style.paper-pencil', 2);
expect(client.get).toHaveBeenCalledWith('/creator/jobs?projectId=project%201');
expect(client.get).toHaveBeenCalledWith('/creator/jobs');
@@ -130,6 +132,10 @@ describe('creator web service', () => {
expect(client.rawGet).toHaveBeenCalledWith('/creator/jobs/job_1/artifacts/artifact%201/content');
expect(client.delete).toHaveBeenNthCalledWith(1, '/creator/jobs/job%201');
expect(client.delete).toHaveBeenNthCalledWith(2, '/creator/jobs/job%202?deleteFiles=true');
+ expect(client.get).toHaveBeenCalledWith('/creator/visual-assets?templateId=stickman-video&kind=style');
+ expect(client.rawGet).toHaveBeenCalledWith(
+ '/creator/visual-assets/stickman.style.paper-pencil/revisions/2/preview'
+ );
});
it('deduplicates stable SSE ids and reconnects with the last cursor', async () => {
diff --git a/apps/web/src/services/creator-service.ts b/apps/web/src/services/creator-service.ts
index 5c01ad10..9c51ae08 100644
--- a/apps/web/src/services/creator-service.ts
+++ b/apps/web/src/services/creator-service.ts
@@ -16,7 +16,9 @@ import type {
CreatorJobListResponse,
CreatorStageRun,
CreatorSourceUploadResponse,
- CreatorTemplateListResponse
+ CreatorTemplateListResponse,
+ CreatorVisualAssetCatalogResponse,
+ CreatorVisualAssetKind
} from '@opencreator/protocol';
type ClientLike = {
@@ -47,6 +49,24 @@ export function createCreatorService(client: ClientLike) {
listTemplates(): Promise<CreatorTemplateListResponse> {
return client.get('/creator/templates') as Promise<CreatorTemplateListResponse>;
},
+ listVisualAssets(
+ templateId: string,
+ kind?: CreatorVisualAssetKind
+ ): Promise<CreatorVisualAssetCatalogResponse> {
+ const query = new URLSearchParams({ templateId });
+ if (kind !== undefined) query.set('kind', kind);
+ return client.get(
+ `/creator/visual-assets?${query.toString()}`
+ ) as Promise<CreatorVisualAssetCatalogResponse>;
+ },
+ openVisualAssetPreview(assetId: string, revision: number): Promise<Response> {
+ if (client.rawGet === undefined) {
+ throw new Error('Creator visual asset preview transport is unavailable');
+ }
+ return client.rawGet(
+ `/creator/visual-assets/${encodeURIComponent(assetId)}/revisions/${revision}/preview`
+ );
+ },
createJob(request: CreateCreatorJobRequest): Promise<{ job: CreatorJob }> {
return client.post('/creator/jobs', request) as Promise<{ job: CreatorJob }>;
},
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts
index d310c8ff..1bd1abad 100644
--- a/apps/web/vite.config.ts
+++ b/apps/web/vite.config.ts
@@ -2,7 +2,7 @@ import react from '@vitejs/plugin-react';
import { existsSync } from 'node:fs';
import { request as httpRequest } from 'node:http';
import { spawn, spawnSync, type ChildProcessByStdio } from 'node:child_process';
-import { dirname, join, resolve } from 'node:path';
+import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import type { Readable } from 'node:stream';
import { defineConfig } from 'vite';
@@ -43,6 +43,16 @@ function opencreatorRuntimeDevPlugin(): Plugin {
return {
name: 'opencreator-runtime-dev',
configureServer(server) {
+ const daemonSourceDir = resolve(webDir, '../daemon/src');
+ server.watcher.add(daemonSourceDir);
+ server.watcher.on('change', changedPath => {
+ const relativePath = relative(daemonSourceDir, resolve(changedPath));
+ if (relativePath.startsWith('..') || isAbsolute(relativePath)) return;
+ if (runtimeProcess === undefined) return;
+ console.warn(`[opencreator-runtime-dev] Daemon source changed (${relativePath}); restarting on the next request.`);
+ stopRuntimeProcess();
+ });
+
server.middlewares.use('/.opencreator/runtime-config', async (_request, response) => {
try {
const config = await getRuntimeConfig();
diff --git "a/docs/plans/OpenCreator\347\201\253\346\237\264\344\272\272\350\247\206\351\242\221\347\224\237\344\272\247\344\273\273\345\212\241\351\207\215\346\236\204-\345\256\236\346\226\275\350\256\241\345\210\222-2026-08-31.md" "b/docs/plans/OpenCreator\347\201\253\346\237\264\344\272\272\350\247\206\351\242\221\347\224\237\344\272\247\344\273\273\345\212\241\351\207\215\346\236\204-\345\256\236\346\226\275\350\256\241\345\210\222-2026-08-31.md"
new file mode 100644
index 00000000..636c0504
--- /dev/null
+++ "b/docs/plans/OpenCreator\347\201\253\346\237\264\344\272\272\350\247\206\351\242\221\347\224\237\344\272\247\344\273\273\345\212\241\351\207\215\346\236\204-\345\256\236\346\226\275\350\256\241\345\210\222-2026-08-31.md"
@@ -0,0 +1,805 @@
+# OpenCreator 火柴人视频生产任务重构实施计划
+
+> 状态:代码与本地门禁已完成;真实 Provider 验收 `BLOCKED`
+> 制定日期:2026-08-31
+> 来源方案:`docs/specs/OpenCreator火柴人视频生产任务重构-方案-2026-08-31.md`
+> 用户批准证据:用户在 D-1、D-2、D-3 后分别回复“没问题,继续”,来源方案已记录“已批准(2026-08-31)”且未决问题为无。
+> 用户执行授权:已授权(2026-08-31),原话为“没问题,继续,中间不要停,一直把task全部处理完”。用户已看到独立 Reviewer 因容量失败的风险并知情授权继续。
+> 计划基线:分支 `feat-stick-video`,初始提交 `accef876bfd81a4c6c20962f096ab6dd81fd2da2`;最终实现前已同步 `origin/main` 到 `476f451`。
+> 体量判断:复杂。任务同时修改 Creator 公共协议与持久化、计费 Provider 恢复、破坏性旧数据迁移、镜头级并发、KrillinAI 映射、Remotion 资源、Web/Desktop 共用工作台和正式打包门禁;这些增量共同交付同一个 `stickman-video@2`,不能拆成可独立发布的多份 Plan。
+
+## 1. 执行边界
+
+本计划把当前火柴人 Demo 直接替换为唯一生产任务 `stickman-video@2`。OpenCreator TypeScript 负责来源获取、内容理解、脚本与分镜审核、镜头血缘、时间线、结果版本和五项交付;KrillinAI 只承担字幕、配音和横屏双语渲染;Remotion 只按已登记时间线渲染纯净视频。火柴人源码和专用 Runtime 不依赖 Python;来源获取可复用既有 Creator Runtime 中受 Manifest、版本和哈希约束的便携 Python `yt-dlp`,不得引入 auto-video Python 实现。
+
+本计划不保留 `stickman-video@1`、旧执行器、旧页面业务状态、Legacy 路由或旧 Job 恢复;不把火柴人产品阶段加入 KrillinAI 协议;不重构其他 Creator 模板;不恢复 auto-video 的十三项多平台交付合同。
+
+执行必须从 `TASK-0` 开始,按任务依赖顺序完成。任何实现不得回退或覆盖工作区内与本任务无关的用户改动。计划完成独立审核并向用户展示结果后,只有用户明确给出“开始执行”或等价指令才进入编码。
+
+## 2. 契约快照
+
+### 2.1 P0 需求与规则
+
+| ID | 不可变合同 |
+| --- | --- |
+| FR-1 | 产品只存在一套真实运行的 `stickman-video` 工作台、模板、工作流和执行实现;页面可复用 Demo 交互,但完成状态只能来自持久 Creator 数据。 |
+| FR-2 | 有效 YouTube 链接经脚本、分镜审核后,自动完成来源理解、图片、配音、时间线、纯净视频、字幕、封面、发布文案和交付校验。 |
+| FR-3 | 用户和 Agent 能编辑脚本、审核分镜、重生成单镜头、查看历史结果;修改只失效受影响 Artifact 和下游结果。 |
+| FR-4 | CreatorJob 是工作台和 Agent 的唯一状态源;刷新、Daemon 重启和外部任务恢复后,阶段、审核、进度、版本和结果一致。 |
+| BR-1 | Registry 只注册 `stickman-video@2`;旧 `@1` Job 及关联数据由一次性迁移定向删除;不提供兼容模式。 |
+| BR-2 | OpenCreator 负责产品编排、审核、状态、血缘和交付;KrillinAI 负责通用媒体能力;Remotion 只负责受信时间线渲染。 |
+| BR-3 | 前端不维护独立结果版本且不提前宣布成功;只展示 `completed` 或历史 `stale` Artifact 与 ResultSnapshot。 |
+| BR-4 | 计费 Provider 远端接受状态未知时不得自动重提;单镜头成功结果在其他镜头失败或重试时保留。 |
+| BR-5 | 最终固定交付纯净视频、1280x720 YouTube 封面、YouTube 发布文案、双语视频和双语 SRT,并由 Delivery Manifest 验真。 |
+| NFR-1 | 火柴人源码、Daemon、Stickman Runtime 和 `app.asar` 不包含 Python;既有 Creator Runtime 的便携 Python `yt-dlp` 只承担统一媒体获取并由独立 Manifest 固定版本、文件集和 SHA-256;Remotion、Chromium、字体、素材和 KrillinAI 依赖同样固定版本并记录 SHA-256。 |
+| NFR-2 | 相同内容视口、Job 和设置下,Web 与实际 Desktop App 的通用界面、动作、Runtime 请求、持久化和交付一致。 |
+| NFR-3 | Desktop 打包必须重新构建当前 Web,记录 commit、dirty、Web 哈希、平台、架构和时间,并逐文件比较 `apps/web/dist` 与 App 内嵌 Web。 |
+
+### 2.2 架构决策
+
+| ID | 实施约束 |
+| --- | --- |
+| DEC-1 | 保留模板 ID,生产 Registry 只含 `version: 2`;旧 Registry 必须以 unknown template 拒绝 `@2`,不得按 ID 或 latest 回退解释。 |
+| DEC-2 | CreatorService 是业务状态唯一权威;OpenCreator TS 编排,KrillinAI 提供通用媒体原子能力,Remotion 在隔离 Node 子进程执行。 |
+| DEC-3 | 审核使用 Job `needs_input` 与显式 CreatorAction;大内容写 Artifact,Job State 只存设置、选择、审核状态和必要 ID;结果版本来自 ResultSnapshot。 |
+| DEC-4 | 动态昂贵阶段使用 `scopeKey` 与 `inputFingerprint`;计费请求先持久化身份,再提交远端;未知接受状态必须人工处置。 |
+| DEC-5 | 固定五项交付;Remotion、Chromium、字体、角色素材和 KrillinAI 进入正式资源 Manifest 与实际包校验。 |
+
+### 2.3 公开类型与持久化合同
+
+`packages/protocol/src/creator.ts` 增加下列兼容性扩展;除 `stickman-video@2` 外的现有模板不填写新增可选字段,行为保持不变:
+
+```ts
+export type CreatorStageRun = {
+ // 现有字段保持不变
+ scopeKey: string | null;
+ inputFingerprint: string | null;
+};
+
+export type CreatorArtifact = {
+ // 现有字段保持不变
+ scopeKey: string | null;
+ inputFingerprint: string | null;
+ sha256: string | null;
+};
+
+export type CreatorProviderRequestStatus =
+ | 'registered'
+ | 'submitting'
+ | 'waiting_remote'
+ | 'succeeded'
+ | 'failed'
+ | 'unknown_remote_acceptance'
+ | 'abandoned_unknown'
+ | 'canceled';
+
+export type CreatorProviderRequest = {
+ id: string;
+ jobId: string;
+ provider: string;
+ stageRunId: string;
+ scopeKey: string | null;
+ requestKey: string;
+ requestHash: string;
+ remoteTaskId: string | null;
+ billingSideEffect: boolean;
+ status: CreatorProviderRequestStatus;
+ resultArtifactId: string | null;
+ generation: number;
+ resubmissionOf: string | null;
+ createdAt: string;
+ updatedAt: string;
+};
+```
+
+`CreatorJob` 响应增加 `providerRequests: CreatorProviderRequest[]`。`creator_stage_runs` 增加 `scope_key`、`input_fingerprint`;`creator_artifacts` 增加 `scope_key`、`input_fingerprint`、`sha256`;新增 `creator_provider_requests` 表。活动执行唯一性由部分唯一索引约束 `job_id + stage_id + scope_key + input_fingerprint` 且状态为 `queued/running`,历史成功、失败和中断记录可共存。
+
+`apps/daemon/src/creator/templates/types.ts` 为阶段增加:
+
+```ts
+jobCompletionPolicy?: 'complete' | 'continue';
+```
+
+默认值为 `complete`,保持现有模板行为;`stickman-video@2` 的中间阶段全部使用 `continue`,只有 `package-validation` 使用 `complete`。scope 和 fingerprint 只由 Workflow 通过 Command Dispatcher 的内部入队参数写入,公开 `run-stage` Action 不接受客户端伪造这两个字段。
+
+计费请求状态只能按下列路径转换:
+
+```text
+registered -> submitting -> waiting_remote -> succeeded
+ -> failed
+ -> unknown_remote_acceptance
+unknown_remote_acceptance -> waiting_remote (query 找回原任务)
+unknown_remote_acceptance -> abandoned_unknown (用户确认重提)
+unknown_remote_acceptance -> canceled (取消作用域)
+abandoned_unknown -> 新 generation 的 registered (resubmissionOf 指向原账本)
+```
+
+`resolve-provider-request` 输入使用判别联合:
+
+```ts
+type ResolveProviderRequestInput = {
+ ledgerId: string;
+ revision: number;
+} & (
+ | { decision: 'query' }
+ | { decision: 'confirm-resubmit'; acceptDuplicateBilling: true }
+ | { decision: 'cancel-scope' }
+);
+```
+
+只有 `actor: 'user'` 可执行 `confirm-resubmit`。普通 `retry-stage` 遇到相同作用域的 `unknown_remote_acceptance` 必须返回 `creator_provider_resolution_required`。Activity 记录 actor、ledgerId、decision、revision,不写 API Key、Token、完整请求体或 Provider 凭证。
+
+### 2.4 `stickman-video@2` 阶段、Action 与 Artifact 合同
+
+模板阶段固定为:
+
+```text
+acquire-source -> source-transcript -> source-brief -> content-plan -> script
+script --approve-script--> storyboard --approve-storyboard--> images[*] + narration
+images[*] + narration -> visual-validation -> timeline -> render-clean
+render-clean -> cover + subtitles + publish-copy
+subtitles -> bilingual-render
+render-clean + cover + publish-copy + subtitles + bilingual-render -> package-validation
+```
+
+`images` 按镜头产生多个 `CreatorStageRun`,`scopeKey` 为稳定 shot ID。审核不注册空 Stage;`approve-script`、`approve-storyboard` 直接解除 Job 的 `needs_input` 门。`visual-validation` 无警告时自动推进;有可接受但非阻断警告时进入 `needs_input`,由 `approve-visuals` 明确继续;技术校验失败不得批准绕过。
+
+显式 Action 为:`update-settings`、`edit-script`、`approve-script`、`edit-shot`、`approve-storyboard`、`regenerate-shot`、`approve-visuals`、`run-stage`、`commit-version`、`retry-stage`、`resolve-provider-request`、`undo-action`。每个 Action 在 `templates/stickman-video.ts` 使用 `.strict()` Zod Schema;审核输入必须携带当前 Artifact ID 和 revision。
+
+核心 Artifact 为:`source_video`、`source_subtitle`、`source_brief`、`content_plan`、`script_manifest`、`shot_spec`、`character_reference`、`shot_image`、`narration_audio`、`visual_validation`、`timeline_manifest`、`clean_video`、`bilingual_subtitle`、`bilingual_video`、`cover_image`、`publish_copy`、`delivery_manifest`。每个文件 Artifact 必须记录 SHA-256、来源 Artifact ID、作用域、输入指纹、模板/模型快照及适用的 MIME、尺寸、时长。
+
+最终文件名固定为:
+
+```text
+landscape-clean.mp4
+youtube-cover.png
+publish-copy-youtube.md
+horizontal_bilingual.mp4
+bilingual_srt.srt
+```
+
+`delivery_manifest` 必须列出且只列出五项交付,记录相对路径、SHA-256、字节数、MIME、来源 Artifact ID;封面必须是 1280x720,视频必须可由 FFprobe 读取,SRT 必须通过双语字幕校验。最终 ResultSnapshot 引用五项交付与 `delivery_manifest`;旧版本 Artifact 保留为 `stale` 并可打开,但不会被新阶段隐式读取。
+
+### 2.5 失败、恢复和取消语义
+
+- Daemon 启动时未结束 StageRun 收敛为 `interrupted`;Workflow 依据成功 Artifact、指纹、Provider 账本和幂等键补排缺失阶段。
+- 相同 `stageId + scopeKey + inputFingerprint` 已有成功 Artifact 时直接复用,不创建新计费请求。
+- 镜头失败只失败该 scope;其他镜头的 StageRun 和 `shot_image` 保持成功。聚合阶段要求已批准 Storyboard 的每个 shot 都存在当前指纹的成功图片。
+- 用户取消必须终止 Remotion、FFmpeg、KrillinAI 及其他子进程树;未通过校验的临时文件不登记 Artifact。
+- 配置缺失、审核等待和未知计费接受状态使用 Job `needs_input`;技术执行错误使用 StageRun `failed/interrupted/canceled`。
+- 同一测试或命令进入 GREEN 后,针对同一根因做两次有实质差异的修复仍失败,当前 TASK 立即标记 `BLOCKED`,记录失败证据、根因假设和最小改动,不继续放宽断言或改变合同。
+
+## 3. 基线与文件地图
+
+### 3.1 当前工作区
+
+- 当前分支:`feat-stick-video`;计划创建时 HEAD 与 `origin/main` 均为 `accef87`,最终实现前已同步到 `476f451`。
+- 未跟踪参考仓库:`auto-video/`,只作为行为、合同和黄金样例来源,不纳入产品 Runtime。
+- 未跟踪已批准方案:`docs/specs/OpenCreator火柴人视频生产任务重构-方案-2026-08-31.md`。
+- 执行前不得删除、移动或提交 `auto-video/`,除非用户另行明确授权。
+
+### 3.2 权威入口与参考符号
+
+| 范围 | 当前文件与符号 | 本计划用途 |
+| --- | --- | --- |
+| Creator Protocol | `packages/protocol/src/creator.ts` 的 `CreatorStageRun`、`CreatorArtifact`、`CreatorJob`、`CreatorActionRequest` | 增加作用域、指纹、哈希和 Provider 账本响应。 |
+| Schema/Repository | `apps/daemon/src/storage/migrations.ts`;`creator/repository.ts` 的 `CreateStageRunInput`、`createStageRun`、`hydrateStageRun` | 增列、账本表、活动唯一索引、查询和写入。 |
+| Service/Runner | `creator/service.ts` 的 `applyAction`;`stage-runner.ts` 的 `runStageRun`、`resolveInputs`、`dependentArtifactIdsForChangedKinds` | 接入火柴人 Action Handler、镜头并发、精确血缘、结果快照。 |
+| 队列 | `creator/command-dispatcher.ts` | 保持命令幂等,并把 scope/fingerprint 传给 StageRun。 |
+| 模板/工作流 | `templates/stickman-video.ts`、`templates/video-translation-actions.ts` | 直接替换 `@1`,按现有 Workflow Controller 模式建立 `@2`。 |
+| 注册入口 | `templates/registry.ts`、`api/server.ts`、`api/routes.creator.ts` | 只注册 `@2`、新 Executor 和 Workflow 的 recover/reconcile/resume。 |
+| 旧 Demo | `creator/stickman/executor.ts`、`script-generator.ts`、`storyboard-generator.ts` | 删除旧 Executor 语义;可在新严格合同下重写生成器,不保留旧入口。 |
+| 图像能力 | `creator/image/executor.ts`、`image-generation/provider.ts` | 复用 Provider 调用与图片校验;火柴人增加账本、安全恢复和镜头作用域。 |
+| KrillinAI | `creator/krillin/adapter.ts`、`execution-plan.ts`、`packages/protocol/src/krillin-opencreator.ts` | 将产品 stage 映射到现有 `subtitle/tts/render-horizontal`,不新增火柴人协议 stage。 |
+| Remotion 参考 | `auto-video/autovideo/render/remotion/template/src/*`、`stages/timeline.py`、`stages/rendering.py` | 迁移为 TypeScript 时间线合同和固定版本 Worker,不复制 Python Runner。 |
+| Delivery 参考 | `auto-video/autovideo/stages/delivery.py` 的 `PackageStage`、`PackageValidationStage` | 固定五项文件、哈希、封面尺寸、字幕与血缘验真。 |
+| Web 工作台 | `apps/web/src/features/dashboard/StickmanVideoWorkspace.tsx` | 保留交互布局,删除硬编码 `storyboardShots`、本地 ready/version 和提前成功。 |
+| 会话与面板 | `creator-session-store.tsx`、`CreatorToolShell.tsx`、`creator-panel-adapters.ts` | 复用持久草稿、Revision、SSE、唯一面板,新增火柴人 Adapter。 |
+| Desktop | `apps/desktop/scripts/prepare-daemon.mjs`、`package-release.mjs`、`verify-package.mjs`、`electron-builder.yml` | 新鲜 Web 构建已存在;扩展 Remotion 资源清单、无 Python 扫描和实际 App 门禁。 |
+| 一致性测试 | `apps/web/e2e/web-desktop-parity.spec.ts`、`apps/desktop/e2e/creator-packaged-app.spec.ts` | 增加相同 Fake Daemon/视口对比和实际包火柴人流程。 |
+
+### 3.3 公共验证命令
+
+执行任务时优先运行该任务列出的定向命令;只在最终门禁或定向失败暴露跨模块影响时扩大范围。
+
+```powershell
+pnpm --filter @opencreator/protocol test -- test/creator-contract.test.ts test/krillin-opencreator-contract.test.ts
+pnpm --filter @opencreator/protocol typecheck
+pnpm --filter @opencreator/daemon test -- <定向测试文件>
+pnpm --filter @opencreator/daemon typecheck
+pnpm --filter @opencreator/web test -- <定向测试文件>
+pnpm --filter @opencreator/web typecheck
+pnpm --filter @opencreator/desktop test -- <定向测试文件>
+pnpm --filter @opencreator/desktop typecheck
+git diff --check
+```
+
+正式交付门禁命令在 `TASK-14` 单独定义;之前不得以局部测试暗示完整发布就绪。
+
+## 4. 依赖图
+
+```text
+TASK-0 基线有效性
+ -> TASK-1 作用域与 Artifact 合同
+ -> TASK-2 Provider 账本与安全处置
+ -> TASK-3 @2 模板与旧数据清理
+ -> TASK-4 内容与审核工作流
+ -> TASK-5 镜头图片、部分成功与精确 stale
+ -> TASK-6 KrillinAI 配音、字幕与双语成片
+ -> TASK-7 时间线与 Remotion Worker
+ -> TASK-8 五项交付与 ResultSnapshot
+ -> TASK-9 重启恢复、取消与 Revision 冲突
+ -> TASK-10 持久工作台
+ -> TASK-11 唯一协作面板 Adapter
+ -> TASK-12 Desktop 资源与正式打包合同
+ -> TASK-13 Web/Desktop 与真实流水线 E2E
+ -> TASK-14 本地差异自审和完整功能验收
+```
+
+## 5. 追踪矩阵
+
+| 实施任务 | 需求/规则 | 关键决策 | 自动化测试 | 功能验收 |
+| --- | --- | --- | --- | --- |
+| TASK-1 | FR-3、FR-4、BR-3 | DEC-3、DEC-4 | Creator Protocol、Storage、Stage Scheduler | AC-3、AC-5 |
+| TASK-2 | FR-4、BR-4 | DEC-4 | Provider Ledger、Action 权限、故障注入 | AC-4 |
+| TASK-3 | FR-1、BR-1 | DEC-1 | Registry、Migration、旧 Registry fixture | AC-1、AC-7 |
+| TASK-4 | FR-2、FR-3、FR-4、BR-2 | DEC-2、DEC-3 | Template、Workflow、Action、审核门 | AC-2、AC-5、AC-6 |
+| TASK-5 | FR-3、BR-4 | DEC-4 | 镜头级 Executor、部分成功、精确 stale | AC-3、AC-4 |
+| TASK-6 | FR-2、BR-2、BR-5 | DEC-2 | Krillin Adapter/CLI/合同测试 | AC-2 |
+| TASK-7 | FR-2、BR-2、NFR-1 | DEC-2、DEC-5 | Timeline、Worker 崩溃/取消、媒体校验 | AC-2、AC-9 |
+| TASK-8 | FR-2、FR-3、BR-3、BR-5 | DEC-3、DEC-5 | Delivery Manifest、ResultSnapshot、路径/哈希 | AC-2、AC-3、AC-5 |
+| TASK-9 | FR-4、BR-4 | DEC-3、DEC-4 | recover/reconcile/cancel、Revision 冲突 | AC-4、AC-5、AC-6 |
+| TASK-10 | FR-1、FR-3、FR-4、BR-3 | DEC-3 | Workspace、Session、刷新、结果打开 | AC-1、AC-5、AC-6 |
+| TASK-11 | FR-4、NFR-2 | DEC-2、DEC-3 | Adapter、Panel、Activity 去重 | AC-8、AC-10 |
+| TASK-12 | NFR-1、NFR-3、BR-2 | DEC-5 | Runtime Manifest、包扫描、完整哈希 | AC-9 |
+| TASK-13 | FR-1、FR-2、FR-4、NFR-2 | DEC-1 至 DEC-5 | Fake Daemon parity、实际 App、真实 Provider | AC-2、AC-5、AC-8、AC-9、AC-10 |
+| TASK-14 | 全部 P0 | 全部决策 | 最终门禁与新鲜证据 | AC-1 至 AC-10 |
+
+## 6. 实施任务
+
+### TASK-0:确认 Plan 仍然有效
+
+**交付结果**
+- 确认分支、基线、工作区、方案批准、文件与符号、依赖版本和公共命令仍与本计划一致;无效时在编码前熔断。
+
+**实施步骤**
+1. 运行 `git status --short --branch`、`git log -5 --oneline --decorate`、`git rev-parse HEAD`,确认在 `feat-stick-video`,记录是否已领先或落后 `origin/main`。
+2. 确认来源方案仍为 `PASS`、用户批准仍有效、`FR/BR/NFR/DEC/AC` 未发生变化。
+3. 用 `rg` 核对第 3.2 节全部入口符号;确认 `auto-video/` 仍只作为参考目录。
+4. 运行 `pnpm install --frozen-lockfile --lockfile-only --ignore-scripts`,只验证锁文件可解析,不触发运行时下载。
+5. 若只有无关文件或局部命名变化,记录偏差并继续;若 `DEC`、职责边界、公开合同、迁移或 AC 失效,停止执行并更新方案或 Plan。
+
+**TDD**
+- 策略:豁免。该任务是只读基线门,不修改业务行为。
+
+**任务完成门**
+- 基线记录完整;不存在改变 P0 合同的未审变化;`git diff --check` 可运行。
+
+### TASK-1:建立镜头作用域、输入指纹和 Artifact 哈希基础 `[FR-3, FR-4, BR-3, DEC-3, DEC-4, AC-3, AC-5]`
+
+**交付结果**
+- StageRun 和 Artifact 具备第一类 `scopeKey`、`inputFingerprint`、SHA-256;镜头 StageRun 可并发但同一活动身份不可重复;其他模板行为不变。
+
+**文件与符号**
+- 修改:`packages/protocol/src/creator.ts` - `CreatorStageRun`、`CreatorArtifact`、`CreatorJob`。
+- 修改:`apps/daemon/src/storage/migrations.ts` - Creator 表增列和部分唯一索引。
+- 修改:`apps/daemon/src/creator/repository.ts` - `CreateStageRunInput`、`InsertArtifactInput`、查询与 hydrate。
+- 修改:`apps/daemon/src/creator/command-dispatcher.ts` - scoped `run-stage` 参数持久化。
+- 修改:`apps/daemon/src/creator/stage-runner.ts` - `run`、`runStageRun`、执行 lane、Artifact 写入与 SHA-256。
+- 测试:`packages/protocol/test/creator-contract.test.ts`、`apps/daemon/test/unit/creator-storage.test.ts`、`creator-stage-scheduler.test.ts`、`creator-runtime-advanced.test.ts`。
+
+**实施步骤**
+1. 在 Protocol 中把新增字段定义为响应必有、值可为 `null`,避免调用方用字段缺失表达旧数据。
+2. 迁移为现有行写入 `NULL`;新增部分唯一索引只约束 `scope_key IS NOT NULL` 且 StageRun 状态为 `queued/running`。
+3. `createStageRun` 接受可选 scope/fingerprint;Repository 所有 StageRun SELECT 使用同一列清单,Artifact 插入时写 scope/fingerprint/sha256。
+4. StageRunner 在文件输出通过类型校验后计算 SHA-256,再在同一事务登记 Artifact;无文件 Artifact 的 `sha256=null`。
+5. 把当前按 Job 串行的 `jobTails` 改为 lane:无 scope 使用 `jobId`,有 scope 使用 `jobId:stageId:scopeKey`;全局 `maxConcurrency` 继续限流。Workflow 未补齐前不允许自动排入 scoped StageRun。
+6. Runner 将 StageRun 的 scope/fingerprint 默认传播到输出 Artifact;Executor 显式覆盖必须与当前 StageRun 一致,否则返回 `creator_artifact_scope_mismatch`。
+
+**TDD**
+- RED:`persists scoped stage runs and artifacts with hashes`,创建两个不同镜头和一个重复活动身份;断言不同 scope 可入队、重复身份被拒绝、文件 Artifact 返回正确 SHA-256。基线会因字段和索引缺失失败。
+- RED:`runs distinct shot scopes concurrently without parallelizing unscoped stages`,使用受控 Executor barrier;断言两个镜头同时进入 running,而两个无 scope 阶段仍按 Job 串行。基线会因 `jobTails` 仅按 jobId 排队失败。
+- GREEN:完成最小协议、迁移、Repository 和 lane 实现,运行上述测试及 `creator-service.test.ts` 回归。
+- REFACTOR:抽取统一 StageRow/ArtifactRow 列清单和文件哈希函数;重跑 Protocol、Storage、Scheduler、Runtime Advanced 与 daemon typecheck。
+
+**任务完成门**
+- 定向测试、Protocol/Daemon typecheck、`git diff --check` 通过;其他模板 fixture 已补齐新增必有可空字段;对应 AC-3、AC-5 的基础合同可观察。
+
+### TASK-2:实现计费 Provider 请求账本和显式处置 `[FR-4, BR-4, DEC-4, AC-4]`
+
+**交付结果**
+- 每个计费请求在提交前有持久身份;未知远端接受状态不会自动重提;查询、用户确认重提和取消作用域均有可审计状态转换。
+
+**文件与符号**
+- 修改:`packages/protocol/src/creator.ts` - `CreatorProviderRequest*`、`CreatorJob.providerRequests`。
+- 修改:`apps/daemon/src/storage/migrations.ts` - `creator_provider_requests` 表、索引和外键。
+- 修改:`apps/daemon/src/creator/repository.ts` - Provider request CRUD 与 Job hydrate。
+- 创建:`apps/daemon/src/creator/provider-requests.ts` - `CreatorProviderRequestLedger`、合法转换和脱敏。
+- 修改:`apps/daemon/src/creator/service.ts` - `retry-stage` 未知状态拒绝和 user-only 重提保护。
+- 测试:创建 `apps/daemon/test/unit/creator-provider-requests.test.ts`,修改 `creator-service.test.ts`、`creator-storage.test.ts`。
+
+**实施步骤**
+1. 表字段按第 2.3 节落地;`request_key` 对 provider+generation 唯一,`request_hash` 使用规范 JSON 的 SHA-256,不保存密钥或完整请求体。
+2. `CreatorProviderRequestLedger.registerBeforeSubmit()` 在事务内创建 `registered` 记录;`markSubmitting()` 必须发生在网络调用前;Remote ID、结果 Artifact 和终态分别独立持久化。
+3. 提供 `recover(ledgerId, providerCapabilities)`:优先 Remote ID 查询;无 Remote ID 仅在 `lookupByRequestKey=true` 时查询;否则转 `unknown_remote_acceptance` 并返回 `needs_input` 原因。
+4. `resolve-provider-request/query` 不创建新请求;`confirm-resubmit` 校验 actor、revision、布尔确认后把原记录置为 `abandoned_unknown` 并创建 generation+1;`cancel-scope` 取消账本和对应 StageRun,不造 Artifact。
+5. `retry-stage` 在执行前查询同 scope 未解决账本并以稳定错误码拒绝;Activity 只写允许字段。
+
+**TDD**
+- RED:`blocks automatic resubmit after crash between provider acceptance and remote id commit`,Fake Provider 记录已接受但抛连接错误;重启后断言账本为 unknown、submit 次数仍为 1。基线无账本会再次提交。
+- RED:`allows only user-confirmed duplicate billing generation`,分别以 agent、用户缺少确认、用户完整确认调用;前两者拒绝,最后生成 generation 2 且 `resubmissionOf` 正确。
+- RED:`query and cancel-scope never create a paid request`,断言 query 只调用 lookup,cancel 保留其他 scope 成果且无假 Artifact。
+- GREEN:实现状态机、Repository、Service guard,运行新测试、Creator Service/Storage 回归。
+- REFACTOR:集中错误码和审计字段白名单;重跑 daemon typecheck。
+
+**任务完成门**
+- AC-4 四条处置路径均有故障注入证据;日志与 Activity 不含测试凭证;普通重试无法绕过 unknown 状态。
+
+### TASK-3:注册唯一 `stickman-video@2` 并定向清理旧 Demo `[FR-1, BR-1, DEC-1, AC-1, AC-7]`
+
+**交付结果**
+- 生产 Registry 只枚举 `stickman-video@2`;旧 `@1` Job 与级联数据被事务删除,文件目录在根约束下可恢复清理;重复升级无副作用。
+
+**文件与符号**
+- 替换:`apps/daemon/src/creator/templates/stickman-video.ts` - `createStickmanVideoTemplate`。
+- 修改:`apps/daemon/src/creator/templates/registry.ts` - 唯一 `@2` 注册。
+- 创建:`apps/daemon/src/creator/stickman/legacy-migration.ts` - `purgeLegacyStickmanJobs`。
+- 修改:`apps/daemon/src/api/server.ts` - Repository 建立后、Workflow 恢复前执行迁移。
+- 删除:`apps/daemon/src/creator/stickman/executor.ts` 的旧聚合入口;新 Executor 在后续任务按职责文件注册。
+- 测试:`creator-template-registry.test.ts`、创建 `creator-stickman-migration.test.ts`。
+
+**实施步骤**
+1. 新模板使用 `version: 2`、第 2.4 节阶段与严格 Action Schema;中间阶段设置 `resultVersionPolicy: 'none'`,只有 `package-validation` 创建结果版本。
+2. 不保留 `@1` 定义、Legacy 导出或模板 ID fallback。测试中的旧 Registry 使用仅存在于测试文件的最小 `@1` fixture。
+3. `purgeLegacyStickmanJobs` 首次事务查询 `template_id='stickman-video' AND template_version=1`,记录 Job ID,删除 Job 让外键级联,并写迁移标记与待清理目录列表。
+4. 事务提交后,对每个 `jobsRoot/<jobId>` 做 `resolve/relative` 越界检查再递归删除;崩溃时迁移标记保留未完成列表,下一次启动继续目录清理并更新完成状态。
+5. `@2` Job、其他模板 Job、项目文件目录及不在 `jobsRoot` 下的路径不得进入删除集合。
+
+**TDD**
+- RED:`registry exposes only stickman-video version 2 and old registry rejects v2 jobs`,基线会枚举 version 1。
+- RED:`purges only v1 jobs and resumes post-commit directory cleanup`,数据库同时包含 v1、v2、其他模板,并在事务提交后注入文件删除崩溃;断言二次运行只补清 v1 目录。
+- RED:`rejects escaped legacy job directory`,伪造越界路径,断言文件不删除且迁移结果记录受阻目录。
+- GREEN:完成模板身份和迁移;运行 Registry、Storage、Agent Storage、Migration 定向回归。
+- REFACTOR:迁移 SQL 与文件清理分离,保持可重复执行。
+
+**任务完成门**
+- AC-1、AC-7 自动化通过;生产源码中不存在 `stickman-video@1` 或旧 Executor 注册;不可逆清理行为已保留发布说明入口。
+
+### TASK-4:实现内容理解、脚本/分镜 Artifact 与审核工作流 `[FR-2, FR-3, FR-4, BR-2, DEC-2, DEC-3, AC-2, AC-5, AC-6]`
+
+**交付结果**
+- 来源获取到 Storyboard 审核形成可恢复流水线;脚本、内容计划和分镜写 Artifact;审核绑定当前 revision 和 Artifact,旧审批不能推进。
+
+**文件与符号**
+- 创建:`apps/daemon/src/creator/stickman/contracts.ts` - 内容、脚本、Shot、Timeline、Delivery Zod 合同。
+- 创建:`apps/daemon/src/creator/stickman/content-executor.ts` - `createStickmanContentExecutor`。
+- 创建:`apps/daemon/src/creator/stickman/action-handler.ts` - `createStickmanActionHandler`。
+- 创建:`apps/daemon/src/creator/templates/stickman-video-actions.ts` - `createStickmanVideoWorkflow`。
+- 修改:`apps/daemon/src/creator/download/executor.ts` - `acquire-source` 分支。
+- 修改:`apps/daemon/src/creator/service.ts` - 模板专属 Action Handler 扩展点,现有通用/视频翻译行为不变。
+- 修改:`apps/daemon/src/api/server.ts`、`routes.creator.ts` - 注册、reconcile、recover、resume。
+- 重写:`creator/stickman/script-generator.ts`、`storyboard-generator.ts` - 使用严格合同和受控 upstream fetch。
+- 测试:创建 `creator-stickman-workflow.test.ts`、`creator-stickman-content-executor.test.ts`;修改 `creator-api.test.ts`、`creator-service.test.ts`。
+
+**实施步骤**
+1. `acquire-source` 只接受公共 YouTube URL,使用现有 yt-dlp/FFprobe 路径产出 `source_video` 和来源技术元数据。
+2. Workflow 依次排入 `source-transcript`、`source-brief`、`content-plan`、`script`;内容 Executor 使用 Creator LLM 配置、规范 JSON、Zod 解析和原子文件写入。
+3. `script` 成功后把 Job 置 `needs_input`,保存 `{kind:'approve-script', artifactId, revision}`;`approve-script` 必须匹配当前 completed `script_manifest` 和 revision。
+4. `edit-script` 接收完整严格脚本模型,写新 `script_manifest`,将旧脚本及依赖 Artifact 标 stale,并重新建立审核门;正文不写入 Job State。
+5. `storyboard` 产出包含稳定 shot ID、narration、imagePrompt、motion、duration、来源 script segment 的 `shot_spec`;成功后建立 `approve-storyboard` 门。
+6. `edit-shot` 写包含全部 shots 的新 `shot_spec`,只改变目标 shot;`approve-storyboard` 绑定当前 `shot_spec`;Workflow 只对已批准版本排图片和配音。
+7. 每个自动排队命令使用稳定 idempotency key;`recover()` 扫描未完成 `@2` Job,`reconcile()` 依据 Artifact 和审核状态补排,不按 Job State 猜测大内容。
+
+**TDD**
+- RED:`stops on script and storyboard approval gates and rejects stale approvals`,基线没有审核门且 Action Schema 宽泛。
+- RED:`persists edited script and shot specs as artifacts without storing bodies in job state`,断言重启后可读取文件、Job State 无脚本/shot 数组。
+- RED:`reconcile enqueues each content stage exactly once after restart`,在 stage 成功和下一命令提交之间模拟重启;断言仅补排一次。
+- GREEN:实现合同、Executor、Action Handler 与 Workflow;运行 Creator API/Service/Workflow 回归。
+- REFACTOR:共享规范 JSON、原子写入和 LLM 错误映射;不得抽象到 KrillinAI。
+
+**任务完成门**
+- 来源到分镜审批的 API 集成测试通过;旧 revision 返回现有可识别冲突码;Agent 与用户走同一 Action Handler。
+
+### TASK-5:实现镜头图片、部分成功和精确血缘失效 `[FR-3, BR-4, DEC-4, AC-3, AC-4]`
+
+**交付结果**
+- 每个 shot 独立生成、持久进度和计费请求;失败不丢其他镜头;编辑或重生成单 shot 只替换该图片并失效真实下游。
+
+**文件与符号**
+- 创建:`apps/daemon/src/creator/stickman/image-executor.ts` - `createStickmanImageExecutor`。
+- 创建:`apps/daemon/src/creator/stickman/lineage.ts` - scoped 指纹、聚合完整性和 stale 计算。
+- 修改:`apps/daemon/src/creator/stickman/action-handler.ts` - `regenerate-shot`、`resolve-provider-request`。
+- 修改:`templates/stickman-video-actions.ts` - 批量排 scope 和聚合推进。
+- 复用:`apps/daemon/src/image-generation/provider.ts`、`creator/validators/image.ts`。
+- 测试:创建 `creator-stickman-image-executor.test.ts`、`creator-stickman-lineage.test.ts`;扩展 `creator-provider-requests.test.ts`、`creator-stage-scheduler.test.ts`。
+
+**实施步骤**
+1. `inputFingerprint` 规范哈希覆盖 shot 内容、角色参考 SHA-256、风格、比例、Provider/model/quality 和直接输入 Artifact 哈希。
+2. Workflow 为每个批准 shot 创建 `stageId='images'`、`scopeKey=shot.id` 的 StageRun;已有同指纹成功图片则复用,失败/旧指纹才创建新运行。
+3. Executor 从批准 `shot_spec` 只读取当前 scope,调用共享 Image Provider;计费 Provider 通过 TASK-2 账本包裹,结果校验后写 `shot_image`。
+4. 每个镜头 progress 使用标准 `phase/percent/message/completed/failed/total`,单运行终态为 1/0/1 或 0/1/1;面板聚合所有当前指纹运行。
+5. `edit-shot`/`regenerate-shot` 把目标旧图片及递归依赖它的 `visual_validation/timeline_manifest/clean_video/cover_image/bilingual_* /publish_copy/delivery_manifest` 标 stale;其他 `shot_image` 保持 completed。
+6. 进入 `visual-validation` 前验证全部批准 shot 具备当前指纹图片;任何缺失只回到对应 scope,不重跑成功 scope。
+
+**TDD**
+- RED:`keeps successful shot artifacts when another scope fails`,三个 scope 中一个失败;断言两个成功 Artifact 保留、Job 等待缺失 scope。
+- RED:`regenerates one shot and stales only its transitive dependents`,断言其他 shot ID、SHA 和状态不变,时间线与交付 stale。
+- RED:复用 TASK-2 的远端接受后崩溃用例,断言 scope 级 unknown 不阻断查看其他镜头,但阻止聚合与普通重试。
+- GREEN:实现指纹、Executor、部分成功与 lineage;运行 Image Executor、Provider、Scheduler、Workflow 回归。
+- REFACTOR:将通用哈希/路径校验留在 Creator 公共层,火柴人 shot 解析留在 stickman 模块。
+
+**任务完成门**
+- AC-3、AC-4 的镜头级断言全部通过;同一 scope 活动重复提交被数据库和 Workflow 双重阻止。
+
+### TASK-6:映射 KrillinAI 配音、字幕和双语成片 `[FR-2, BR-2, BR-5, DEC-2, AC-2]`
+
+**交付结果**
+- `narration`、`source-transcript`、`subtitles`、`bilingual-render` 通过现有 KrillinAI 通用 stage 执行并返回火柴人 Artifact 名称,不扩展产品级 Krillin 协议。
+
+**文件与符号**
+- 修改:`apps/daemon/src/creator/krillin/adapter.ts` - `resolveKrillinStageContract`、输出别名和按模板必需输出。
+- 修改:`apps/daemon/src/creator/krillin/cli-runner.ts` - 仅补通用 options/输入映射。
+- 修改:`apps/daemon/src/creator/templates/stickman-video.ts`、`stickman-video-actions.ts` - Krillin 阶段声明和推进。
+- 保持:`packages/protocol/src/krillin-opencreator.ts`、`contracts/krillin-opencreator-v1.schema.json` 的 stage enum 不新增火柴人名称。
+- 测试:`creator-krillin-adapter-dependency.test.ts`、`creator-krillin-cli-protocol.test.ts`、`creator-krillin-execution-plan.test.ts`、`krillin-opencreator-contract.test.ts`,创建 `creator-stickman-krillin.test.ts`。
+
+**实施步骤**
+1. 映射 `source-transcript -> subtitle`,只要求 `source_subtitle`;字幕来源优先平台字幕,失败按现有 execution plan 回落 Whisper。
+2. 映射 `narration -> tts`,输入批准脚本生成的字幕/文本 Artifact,把 `dubbed_audio` 注册为 `narration_audio`,保留 Provider/voice/model 和时长元数据。
+3. 映射 `subtitles -> subtitle`,输入 `clean_video`,产出固定文件名 `bilingual_srt.srt` 的 `bilingual_subtitle`。
+4. 映射 `bilingual-render -> render-horizontal`,输入 `clean_video + bilingual_subtitle`,把 `horizontal_video` 注册为 `bilingual_video`,文件名固定 `horizontal_bilingual.mp4`。
+5. Krillin result manifest 的 SHA-256、路径越界、必需输出和媒体/SRT 校验继续在 Adapter 验证;Job State 不保存 Krillin 私有任务 payload。
+
+**TDD**
+- RED:`maps stickman semantic stages onto existing krillin stage enum`,断言请求 stageType 只出现 `subtitle/tts/render-horizontal`,输出别名正确;基线会以 unsupported stage 失败。
+- RED:`rejects undeclared or missing stickman krillin outputs`,Fake Manifest 返回 vertical_video 或缺失字幕,断言稳定错误码且不登记 Artifact。
+- GREEN:实现 contract resolver 和别名;运行 Krillin unit/integration 与 Protocol 合同测试。
+- REFACTOR:把现有 video-translation 硬编码收敛为默认 contract,保持其请求和输出不变。
+
+**任务完成门**
+- Krillin schema enum 未增加火柴人 stage;四个产品阶段均有通用请求/输出合同测试;现有视频翻译回归通过。
+
+### TASK-7:实现时间线合同和隔离 Remotion Worker `[FR-2, BR-2, NFR-1, DEC-2, DEC-5, AC-2, AC-9]`
+
+**交付结果**
+- 已批准 shots、图片和配音生成可验证时间线;隔离 Node Worker 使用固定 Remotion/Chromium/字体/素材渲染 `landscape-clean.mp4`,崩溃只失败当前 StageRun。
+
+**文件与符号**
+- 创建:`apps/daemon/src/creator/stickman/timeline-executor.ts` - `createStickmanTimelineExecutor`。
+- 创建:`apps/daemon/src/creator/stickman/remotion-executor.ts` - `createStickmanRemotionExecutor`。
+- 创建:`apps/daemon/src/creator/stickman/remotion-worker.ts` - 子进程入口和 JSON 文件协议。
+- 创建:`packages/stickman-remotion/package.json`、`tsconfig.json`、`src/index.ts`、`src/Root.tsx`、`src/StickmanLandscape.tsx`、`src/timeline.ts`。
+- 创建:`packages/stickman-remotion/assets/fonts/NotoSans-Bold.woff2`、`NotoSansSC-Bold.woff2`、`OFL.txt`。
+- 修改:`apps/daemon/package.json`、根 `pnpm-lock.yaml` - 精确固定 `@remotion/[email protected]`、`@remotion/[email protected]`、`[email protected]`、`[email protected]`;Remotion package 使用仓库现有 `[email protected]`、`[email protected]`。
+- 测试:创建 `creator-stickman-timeline.test.ts`、`creator-stickman-remotion.test.ts`;增加 `packages/stickman-remotion/src/*.test.ts`。
+
+**实施步骤**
+1. 时间线 schema 固定 fps、1280x720、shot 顺序、每镜头帧区间、图片 Artifact ID、音频 Artifact ID、motion 和来源 SHA-256;总帧数由真实音频时长和批准顺序计算。
+2. Timeline Executor 拒绝缺图、缺音频、负时长、重叠、空洞、越界路径和 stale 输入,写 `timeline_manifest` 并记录自身 SHA-256。
+3. Remotion package 从 auto-video TypeScript 模板迁移需要的干净横屏构图,不复制 legacy 兼容层、Python 调度和竖屏交付;组件只消费经过 Zod 验证的 props。字体通过本地 `@font-face` 加载上述两个 WOFF2 文件,不使用 `@remotion/google-fonts` 或网络字体。
+4. 构建阶段用固定 `@remotion/bundler` 生成 bundle;运行阶段 Worker 用固定 `@remotion/renderer` 和 Manifest 指定 Chromium,禁止 `npm install`、浏览器自动下载和网络字体。
+5. Daemon 通过 `spawnCreatorProcess(process.execPath, ...)` 启动 Worker;请求、结果和错误通过当前 Stage workdir 内 JSON 文件交换,Worker 校验时间线、bundle、Chromium和输出均位于允许根。
+6. Worker 成功后用 FFprobe 校验视频可解码、1280x720、时长与时间线容差,才登记 `clean_video`;取消或崩溃删除未完成输出。
+
+**TDD**
+- RED:`builds deterministic timeline from approved current artifacts`,打乱 Artifact 顺序并含 stale 输入,断言输出仍按 shot 规范且不选 stale。
+- RED:`isolates remotion worker crash and cancellation`,Fake Worker 分别异常退出和长时间运行;断言仅当前 StageRun failed/canceled、子进程树退出、无 clean_video。
+- RED:`renders a nonblank fixed-frame smoke video with packaged browser and fonts`,对三帧做像素方差检查并 FFprobe;未准备资源时应明确失败而非在线下载。
+- GREEN:完成 timeline、package 和 Worker;运行定向测试、daemon/package typecheck。
+- REFACTOR:把 runtime path/manifest 解析独立于渲染业务,供 TASK-12 打包校验复用。
+
+**任务完成门**
+- 时间线和 Worker 测试通过;固定版本已进入锁文件;运行路径无 Python、无运行时安装和不受控下载。
+
+### TASK-8:生成五项交付、Delivery Manifest 和历史结果 `[FR-2, FR-3, BR-3, BR-5, DEC-3, DEC-5, AC-2, AC-3, AC-5]`
+
+**交付结果**
+- 五项文件与 Delivery Manifest 逐项一致;最终 Stage 才生成 ResultSnapshot;重生成后旧结果保持可查看的 stale 历史。
+
+**文件与符号**
+- 创建:`apps/daemon/src/creator/stickman/delivery-executor.ts` - `createStickmanDeliveryExecutor`。
+- 修改:`apps/daemon/src/creator/stage-runner.ts` - stickman 最终 `artifactRefsPatch` 与 job completion policy。
+- 修改:`apps/daemon/src/creator/result-snapshots.ts` - 多同类 scoped Artifact 与五项引用。
+- 修改:`templates/stickman-video.ts`、`stickman-video-actions.ts` - `cover`、`publish-copy`、`package-validation`。
+- 复用:`creator/validators/image.ts`、`media.ts`、`srt.ts`;使用 `sharp` 输出 1280x720 封面。
+- 测试:创建 `creator-stickman-delivery.test.ts`、`creator-stickman-results.test.ts`;修改 `creator-runtime-advanced.test.ts`。
+
+**实施步骤**
+1. `cover` 通过共享 Image Provider 生成候选,使用 sharp 归一化到 1280x720,保留模型、Prompt、来源和最终尺寸证据,文件名 `youtube-cover.png`。
+2. `publish-copy` 从 `content_plan + script_manifest` 生成 `publish-copy-youtube.md`,Zod 校验标题、简介、标签段存在且文件非空。
+3. `package-validation` 在 Job 根内物化固定五项文件,拒绝符号链接和路径越界;比较实际文件集合、SHA-256、字节数、MIME、封面尺寸、视频 FFprobe、SRT 解析和 sourceArtifactIds。
+4. 只在所有校验通过后写 `delivery_manifest`、把 Job 标 `completed` 并追加 ResultSnapshot;快照 `artifactRefs` 同时引用五项 Artifact 和 Manifest。
+5. 新版本完成前旧 ResultSnapshot 保持可打开;任何上游变更后其 Artifact 状态为 stale,但快照内容不被覆盖。
+
+**TDD**
+- RED:`rejects delivery with extra, stale, hash-mismatched or wrong-size files`,逐项注入错误;基线没有五项合同。
+- RED:`creates one result snapshot only after package validation succeeds`,中间阶段不增加版本,失败交付无新版本,成功后引用五项精确 ID。
+- RED:`keeps previous result snapshot readable after one-shot regeneration`,断言 V1 文件仍能通过 content API 打开,V2 不引用 stale V1 输入。
+- GREEN:实现 Delivery 和结果快照补丁;运行 Delivery、Runtime Advanced、API content route 回归。
+- REFACTOR:共享文件清单/哈希比较函数给 TASK-12,业务文件名仍由 stickman contract 权威定义。
+
+**任务完成门**
+- AC-2、AC-3、AC-5 的交付与历史断言通过;失败 Delivery 不产生假完成状态或 ResultSnapshot。
+
+### TASK-9:闭合重启恢复、取消和工作台/Agent 冲突 `[FR-4, BR-4, DEC-3, DEC-4, AC-4, AC-5, AC-6]`
+
+**交付结果**
+- 所有阶段、审核、镜头进度、Provider 状态和结果可在重启后恢复;取消清理进程;旧 revision 不覆盖新数据。
+
+**文件与符号**
+- 修改:`templates/stickman-video-actions.ts` - `recover`、`reconcile`、`resumeConfiguredJobs`。
+- 修改:`apps/daemon/src/api/routes.creator.ts` - resume/retry/resolve 路由接入。
+- 修改:`apps/daemon/src/creator/stage-runner.ts`、`process-tree.ts` - scoped cancel 与终态回调。
+- 修改:`apps/daemon/src/creator/agent/service.ts` 及 Agent CreatorAction 桥接调用方 - 保持 expectedRevision 和 actor。
+- 测试:创建 `creator-stickman-recovery.test.ts`;修改 `creator-api.test.ts`、`creator-agent-service.test.ts`、`creator-agent-recovery.test.ts`、`creator-tool-process-lease.test.ts`。
+
+**实施步骤**
+1. 启动恢复先执行旧数据迁移,再恢复 StageRun/Provider Ledger,最后执行 stickman Workflow `recover()`;顺序不得让已删除 `@1` Job 被恢复。
+2. 对 interrupted scoped run:成功 Artifact 指纹匹配则收敛成功;Provider waiting/unknown 走账本;没有远端副作用且无成功 Artifact才允许重新排队。
+3. `resume` 和 `retry-stage` 统一调用 Workflow guard,不绕过审核、当前输入指纹或 Provider unknown 状态。
+4. Job cancel 枚举所有 active scope,终止进程树并把未完成 StageRun 置 canceled;已 completed Artifact 不删除。
+5. 工作台和 Agent 都必须提交 `expectedRevision`;冲突返回现有 revision conflict 错误,客户端刷新后再操作。Agent 只能建议 `confirm-resubmit`,服务端拒绝其执行。
+
+**TDD**
+- RED:`recovers running review completed and unknown-provider jobs after daemon restart`,四类状态分别断言恢复结果和 submit 次数。
+- RED:`cancels all scoped process trees without deleting completed shots`,两个运行 scope、一个成功 scope,断言子进程退出与 Artifact 保留。
+- RED:`rejects stale agent revision and agent duplicate-billing confirmation`,断言用户较新改动不被覆盖。
+- GREEN:完成恢复顺序、路由和 Agent guard;运行 API、Agent、Process Lease、Workflow 回归。
+- REFACTOR:统一 Workflow 错误映射和 needsInput 结构,避免 route 私有判断。
+
+**任务完成门**
+- AC-4、AC-5、AC-6 的服务和 API 场景通过;重启不会重复计费或重复排队;取消无残留子进程。
+
+### TASK-10:把 Demo 工作台改为 CreatorSession 持久视图 `[FR-1, FR-3, FR-4, BR-3, DEC-3, AC-1, AC-5, AC-6]`
+
+**交付结果**
+- 保留现有步骤、角色、分镜弹窗、配音设置、结果页和版本菜单的交互设计,但所有业务内容、状态、进度和版本来自 CreatorSession。
+
+**文件与符号**
+- 重写:`apps/web/src/features/dashboard/StickmanVideoWorkspace.tsx`。
+- 修改:`apps/web/src/features/dashboard/DashboardPage.tsx` - `createPendingCreatorJob` 使用模板摘要中的 version 2,不再写死 1。
+- 修改:`apps/web/src/features/dashboard/creator-session-store.tsx` - JSON Artifact 读取缓存与冲突刷新,不新增业务真相源。
+- 修改:`apps/web/src/services/creator-service.ts` - 保持 content API,按需增加 JSON helper。
+- 创建:`apps/web/src/features/dashboard/StickmanVideoWorkspace.test.tsx`。
+- 修改:`DashboardPage.test.tsx`、`creator-session-store.test.tsx`。
+
+**实施步骤**
+1. 删除硬编码 `storyboardShots`、`storyboardReady`、`videoReady`、`resultVersions` 和调用后立即 set success 的路径。
+2. 表单设置只通过 `session.updateDraft` 持久化;执行、审核、编辑、重生成、Provider 处置全部调用 `session.applyAction`。
+3. 通过 `openArtifact` 读取 `script_manifest`、`shot_spec`、`delivery_manifest`;组件可缓存解析结果和 Object URL,但 Job 更新或 Artifact ID 变化时必须失效缓存。
+4. 镜头卡片由当前 `shot_spec` 与匹配 scope/fingerprint 的 `shot_image` 组合;running/failed/unknown 状态来自 StageRun/ProviderRequest。
+5. 结果版本由 `readCreatorResultSnapshots(job.state)` 派生;只有快照引用的五项 Artifact 可出现在版本页和下载入口。
+6. revision conflict 显示可识别错误并触发远端快照刷新,不覆盖用户/Agent 较新数据。
+
+**TDD**
+- RED:`does not show ready or result versions before persisted artifacts arrive`,Action 返回 running Job,断言 UI 不提前成功;基线会立即 set ready。
+- RED:`renders storyboard and versions from artifact content after refresh`,卸载重挂组件,断言镜头、审核和版本从服务恢复。
+- RED:`submits edit and regenerate with current revision and scope`,并模拟冲突后刷新。
+- GREEN:完成工作台与 Session helper;运行 Workspace、Dashboard、Session、Creator Service 测试。
+- REFACTOR:仅保留 UI 临时状态,例如当前 tab、打开的 modal 和 object URL;不得恢复业务 ready/version state。
+
+**任务完成门**
+- AC-1 静态断言与组件测试通过;刷新和冲突场景有自动化证据;Web typecheck 通过。
+
+### TASK-11:新增 `stickmanVideoPanelAdapter` 并复用唯一协作面板 `[FR-4, NFR-2, DEC-2, DEC-3, AC-8, AC-10]`
+
+**交付结果**
+- 火柴人使用唯一 `CreatorCollaborationPanel`;P0 Stage/Phase、Action Activity 和镜头聚合进度具有中英文语义、过滤和去重。
+
+**文件与符号**
+- 修改:`apps/web/src/features/dashboard/creator-panel-adapters.ts` - 导出 `stickmanVideoPanelAdapter`,在 `creatorPanelAdapterFor` 选择。
+- 修改:`apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx` - 仅补通用 scope 聚合显示。
+- 保持:`CreatorToolShell.tsx` 的唯一面板结构,不创建火柴人 Panel。
+- 创建:`apps/web/src/features/dashboard/creator-panel-adapters.test.ts`。
+- 修改:`CreatorCollaborationPanel.test.tsx`、`DashboardPage.test.tsx`。
+
+**实施步骤**
+1. 为第 2.4 节全部 Stage 和 phase 提供 zh-CN/en 标签;未知 phase 回落 generic,不读取 Executor 私有 payload。
+2. 为 `approve-script/edit-script/edit-shot/approve-storyboard/regenerate-shot/approve-visuals/retry-stage/resolve-provider-request/commit-version` 定义 Activity 文案和安全字段。
+3. 过滤 `create-job`、无 objectId 的草稿设置和无语义系统噪声;连续同 stage+scope 的 progress Activity 合并为最新一条。
+4. 图片阶段从当前指纹 StageRun 聚合 completed/failed/total;scopeKey 仅用于镜头标识,不改变面板结构。
+5. Provider unknown 显示“需要用户处置”,Agent 建议与用户实际处置保持不同 actor 语义。
+
+**TDD**
+- RED:`selects stickman adapter without rendering a second panel`,断言 DOM 只有一个 panel region。
+- RED:`labels every p0 stage phase and action in both locales`,表驱动覆盖全部合同项。
+- RED:`aggregates current shot runs and deduplicates activity by stage and scope`,混入旧指纹、draft Activity,断言真实 2/1/3 和过滤结果。
+- GREEN:实现 Adapter 和通用聚合;运行 Adapter、Panel、Dashboard 测试。
+- REFACTOR:共享去重工具只在能保持现有 video translation/cover 行为时抽取。
+
+**任务完成门**
+- AC-10 全部断言通过;源码不存在 `Stickman*AgentPanel` 或第二个 `CreatorCollaborationPanel` 实例。
+
+### TASK-12:固定 Remotion 资源并扩展 Desktop 正式打包合同 `[NFR-1, NFR-3, BR-2, DEC-5, AC-9]`
+
+**交付结果**
+- Desktop 包包含受 Manifest 约束的 Remotion bundle、Chromium、字体和角色素材;构建清单记录资源哈希;Daemon、Stickman Runtime 和 `app.asar` 不含 Python Runtime,既有 Creator Runtime 的便携 Python `yt-dlp` 由独立合同验真;任一资源或 Web 不一致阻止交付。
+
+**文件与符号**
+- 创建:`apps/desktop/scripts/prepare-stickman-runtime.mjs`、`stickman-runtime-contract.mjs`。
+- 修改:`apps/desktop/scripts/package-release.mjs` - 准备资源和记录 manifest 字段。
+- 修改:`apps/desktop/scripts/verify-package.mjs` - 资源完整文件集、哈希和 Python 扫描。
+- 修改:`apps/desktop/scripts/prepare-daemon.mjs` - 构建 Remotion package/worker,保持当前 Web 新鲜构建。
+- 修改:`apps/desktop/electron-builder.yml` - `.pack/stickman-runtime -> stickman-runtime`。
+- 修改:`apps/desktop/package.json` - `prepare:stickman-runtime`。
+- 创建:`apps/desktop/test/stickman-runtime-package.test.mjs`。
+- 修改:`apps/desktop/test/creator-runtime-package.test.mjs`、`apps/desktop/e2e/creator-packaged-app.spec.ts`。
+
+**实施步骤**
+1. prepare 脚本从锁定依赖生成 Remotion bundle,把固定 Chromium、两个字体文件和以下角色素材复制到 `.pack/stickman-runtime`:`default.png`、`tech-guy.png`、`long-hair.png`、`short-hair.png`、`hiphop.png`、`student.png`、`elder.png`、`manager.png`、`chef.png`、`fitness.png`;角色源文件固定来自 `apps/web/public/dashboard/characters/`。Manifest 为每个文件记录 kind、version、sha256、size、platform、arch。
+2. 合同校验要求实际文件集合与 Manifest 完全相等,且包含 bundle、Chromium 可执行文件、字体和角色素材;路径越界、缺失、多余、哈希错误均失败。
+3. `package-release.mjs` 在 electron-builder 前执行 prepare;现有 `prepare-daemon.mjs` 继续重新构建 `apps/web/dist`。构建清单增加 `stickmanRuntimeHash`、`stickmanRuntimeFileCount`、Remotion/Chromium 版本和资源 Manifest SHA-256。
+4. `verify-package.mjs` 比较源 runtime、`.pack` runtime 与 App runtime 的文件列表和逐文件哈希,并继续比较 Web 源/包。Python 禁止扫描覆盖 daemon、stickman-runtime 和 app.asar,拒绝 Python 可执行文件、`libpython`、`site-packages`、`venv/.venv`、`__pycache__`、`.pyc/.pyo/.pth`、`auto-video` 路径和其他已知 Python Runtime 标志;Creator Runtime 中既有便携 Python `yt-dlp` 由 `creator-runtime-contract` 独立验证版本、文件集、哈希和无可变字节码缓存。普通依赖附带但不可执行的 `.py` 源文件单独报告,不以文件扩展名替代 Runtime 判定。
+5. 包内 Worker 用资源 Manifest 解析 Chromium/字体/素材,不读取开发机全局缓存或 PATH。
+
+**TDD**
+- RED:`rejects missing extra hash-mismatched or wrong-platform stickman resources`,表驱动修改 fixture。
+- RED:`rejects packaged python runtime and stale embedded web`,分别注入 `.pyc` 与 Web 单文件差异,断言 verify-package 非零退出。
+- RED:`build manifest binds package to exact stickman and web hashes`,篡改 manifest 字段后校验失败。
+- GREEN:实现 prepare/contract/package/verify;运行 Desktop package contract、typecheck。
+- REFACTOR:复用现有 `hashDirectory/findFirstDifferentPath` 语义,避免两套不一致哈希算法。
+
+**任务完成门**
+- AC-9 的静态打包合同全部有自动化;未执行实际包前只能声明“合同测试通过”,不能声明可发布。
+
+### TASK-13:完成 Web/Desktop 一致性、实际 App 与真实流水线 E2E `[FR-1, FR-2, FR-4, NFR-2, DEC-1, DEC-2, DEC-3, DEC-4, DEC-5, AC-2, AC-5, AC-8, AC-9, AC-10]`
+
+**交付结果**
+- 同一 Fake Daemon 下 Browser/Desktop Bridge 的通用 UI、Action、Runtime 请求和持久化结果一致;实际打包 App 可运行完整火柴人关键流程;真实受控 Provider 产生五项交付。
+
+**文件与符号**
+- 创建:`apps/web/e2e/support/fake-stickman-daemon.ts`、`apps/web/e2e/stickman-web-desktop-parity.spec.ts`。
+- 修改:`apps/web/e2e/web-desktop-parity.spec.ts`、`fixtures/runtime.ts` - 共用视口和 Creator fixture。
+- 修改:`apps/desktop/e2e/creator-packaged-app.spec.ts` - 打包态火柴人创建、审核、重生成、重启和结果。
+- 创建:`apps/daemon/test/integration/creator-stickman-real-pipeline.test.ts` - 环境门控真实短输入。
+- 修改:Playwright 配置,仅纳入对应项目,不改变无关测试收集。
+
+**实施步骤**
+1. Fake Daemon 固定同一 project/job/preferences、Artifact 内容、Provider unknown 和请求日志;分别注入 Browser Bridge 与具备真实 capability 回调的 Desktop Bridge,内容视口固定 1440x900,并增加 390x844 响应式检查。
+2. 对比首页、项目选择器、创建项目、设置、会话输入区、文件工作区以及火柴人脚本审核、分镜审核、单镜头重生成、协作面板和结果页的可见文案、按钮、状态、关键尺寸、Action 请求和持久化快照。
+3. Browser Bridge 不显示目录选择、窗口控制等不可用入口;Desktop Bridge 的原生入口必须调用真实 fake callback,不传空函数。
+4. 实际 App E2E 使用打包目录启动 `opencreator-app://`,走 Preload Bridge 和 Runtime 代理,创建 `@2` Job,完成审核、scope 重生成、Daemon 重启恢复、Artifact 打开和五项结果验证。
+5. 真实流水线测试只在 `OPENCREATOR_RUN_REAL_STICKMAN_E2E=1` 时运行,读取 `OPENCREATOR_STICKMAN_E2E_CONFIG` 私密配置路径和 `OPENCREATOR_STICKMAN_E2E_YOUTUBE_URL` 固定短视频;限制镜头数和图片候选数,记录计费请求数但不输出凭证。
+6. 真实测试验证五项文件可用、封面 1280x720、视频可解码、SRT 双语、Manifest 哈希一致;失败必须保留临时证据路径并阻止发布。
+
+**TDD**
+- RED:`browser and desktop bridges produce identical stickman actions and snapshots`,基线 Demo 本地状态与硬编码镜头会导致差异。
+- RED:`packaged app restores scoped progress and five artifacts after daemon restart`,基线包只验证旧 Demo/通用 Creator。
+- RED:真实测试在未设置门控时明确 skip;设置后任何一项 Delivery 校验失败使测试失败,不允许降级为 warning。
+- GREEN:完成 fixture 和 E2E;先跑 Fake parity,再跑 package app,最后在授权配置下跑真实 Provider。
+- REFACTOR:E2E helper 只抽取公开 API/Bridge 操作,不从数据库直接伪造被验收的最终结果。
+
+**任务完成门**
+- AC-8 全套一致性和实际 App E2E 通过;AC-2 有本次真实运行证据。若真实凭证、网络或目标平台不可用,标记 `BLOCKED`,不得宣布功能完成或可发布。
+
+### TASK-14:执行本地差异自审和完整功能验收 `[AC-1, AC-2, AC-3, AC-4, AC-5, AC-6, AC-7, AC-8, AC-9, AC-10]`
+
+**交付结果**
+- 主 Agent 对最终差异完成一次本地自审,修复范围内问题后,用最后一次相关改动之后的新鲜证据执行全部 P0 验收;不启动新的 Reviewer。
+
+**文件与符号**
+- 检查:`git diff --stat`、本任务全部 `git diff`、新增/删除文件、依赖和打包资源。
+- 验收:第 7 节矩阵列出的公开 API、浏览器、实际 App、真实流水线和包合同。
+
+**实施步骤**
+1. 审查最终 diff 是否完整映射契约与追踪矩阵,重点检查旧兼容残留、状态双写、重复抽象、凭证泄漏、路径越界、未知计费重提、子进程回收、Web/Desktop 分叉和无关修改。
+2. 自审发现问题时按对应 TASK 的 RED/GREEN 修复并重跑受影响测试;修复后的旧验收证据失效。
+3. 依次运行:Protocol/Daemon/Web/Desktop typecheck;全部定向 Creator/Stickman/Krillin/Package 测试;Web build;Desktop build;Fake parity;真实流水线;`pnpm --filter @opencreator/desktop package`;`verify:package`;实际打包 App E2E。
+4. 对 App 内嵌 Web 与本次 `apps/web/dist` 保存文件列表、逐文件 SHA-256 和聚合哈希;保存构建清单、stickman runtime manifest 和 Python 扫描结果。
+5. 对每个 AC 记录 `PASS/FAIL/BLOCKED`、实际结果、执行目录、时间、退出码、证据路径或输出摘要。任一 P0 为 FAIL/BLOCKED 时不声明完成或发布就绪。
+
+**TDD**
+- 策略:豁免新增测试。该任务只消费前序测试和公开功能入口;自审修复回到对应 TASK 的 TDD 流程。
+
+**任务完成门**
+- 第 7 节全部 P0 AC 为 PASS 且证据产生在最后一次相关代码修改之后;`git diff --check` 通过;未提交工作区只包含本任务实现、已批准方案/计划和用户原有未跟踪 `auto-video/`。
+
+## 7. 最终功能验收矩阵
+
+| AC ID | 优先级 | 场景 | 前置条件 | 操作 | 预期结果 | 验证方式 | 证据 |
+| --- | --- | --- | --- | --- | --- | --- | --- |
+| AC-1 | P0 | 唯一生产实现 | 新 Registry、测试内旧 @1 Registry、清洁 Job | 枚举模板、创建 @2、打开工作台、用旧 Registry 操作 @2 | 只枚举 `stickman-video@2`;无旧 Executor/硬编码镜头/本地结果;旧 Registry 明确拒绝 | Registry/组件测试 + 源码搜索 | 测试输出、`rg` 清单 |
+| AC-2 | P0 | 真实五项交付 | 私密 Provider 配置、KrillinAI、固定短 YouTube URL | 完成脚本和分镜审核并等待结束 | 五项文件可用;封面 1280x720;Manifest 路径、哈希、参数、血缘一致 | 真实流水线集成测试 | 临时 Job 路径、Manifest 摘要、FFprobe/SRT 结果 |
+| AC-3 | P0 | 单镜头修改 | 已完成多镜头 V1 | 修改一个 shot 并重生成至 V2 | 只新增该 scope 的 StageRun/图片;其他图片不变;下游 stale 后生成新版本 | Service 集成测试 | StageRun/Artifact/ResultSnapshot 对比 |
+| AC-4 | P0 | 计费请求未知接受 | 可故障注入 Fake Provider | 崩溃后依次 query、普通 retry、用户确认重提、cancel | query 找回原任务;retry 拒绝;仅用户确认产生 generation 2;cancel 无假 Artifact且有 Activity | Provider 故障注入 | submit/lookup 次数、账本与 Activity |
+| AC-5 | P0 | 刷新与重启恢复 | Job 分别 running/needs_input/completed | 刷新页面并重启 Daemon | Job、阶段、scope 进度、审核、Provider、快照和 Artifact 恢复;安全继续 | API + 浏览器 + 实际 App | API 快照、页面断言、重启日志 |
+| AC-6 | P0 | 工作台/Agent 冲突 | 两端打开同一 revision | 工作台先改,Agent 用旧 revision;刷新后再改 | 旧 revision 被拒绝且不覆盖;刷新后两端一致;Agent 不可确认重复计费 | Service + Agent 集成 | 冲突响应、最终 Job/Activity |
+| AC-7 | P0 | 旧 Demo 清理 | DB 含 @1、@2、其他模板及文件目录 | 执行升级两次,并注入一次目录清理中断 | 只删除 @1 及关联数据/目录;@2 和其他数据不变;二次幂等并补清目录 | 迁移测试 | SQL 计数、目录集合、迁移标记 |
+| AC-8 | P0 | Web/Desktop 一致性 | 同 Fake Daemon、Job、偏好、内容视口和实际 App | 两端完成审核、重生成、面板/结果查看和原生能力操作 | 通用 DOM、文案、尺寸、Action、Runtime 请求、持久化和结果一致;原生入口按 capability 工作 | Playwright parity + App E2E | 请求日志、状态快照、截图/几何 |
+| AC-9 | P0 | 正式打包 | 当前工作区允许 dirty 如实记录 | 运行 package、verify 和 App E2E | 新鲜 Web;清单字段完整;Web 与包逐文件一致;Remotion/Krillin 资源有效;Daemon、Stickman Runtime 和 `app.asar` 无 Python,Creator Runtime 仅含受合同约束的便携 Python `yt-dlp` | 构建/包合同 + 实际 App | build manifest、文件哈希、runtime manifest、扫描输出 |
+| AC-10 | P0 | 唯一协作面板 | Job 含全部 P0 Activity 和 scope 进度 | 执行设置、审核、重生成、retry、Provider 处置 | Adapter 文案完整、过滤/去重正确、显示真实完成/失败/总数;只有一个 Panel | Adapter/Panel 测试 + parity | 测试表、DOM 数量、面板截图 |
+
+功能验收必须从公开 API、Web UI、Host Bridge 或实际打包 App 发起。单元测试可以补充证据,但不能替代 AC-2、AC-5、AC-8、AC-9 的真实边界。
+
+## 8. 发布、迁移与回滚
+
+### 8.1 发布步骤
+
+1. 全部 TASK 完成后同步最新 `origin/main`,只解决直接相关冲突,并重跑受影响门禁和 TASK-14。
+2. 首次有效实现提交后推送 `feat-stick-video`;提交不包含未跟踪 `auto-video/`,除非用户另行授权纳入。
+3. 发布前执行实际目标平台的 `pnpm --filter @opencreator/desktop package` 或正式发行命令;不得复用来源不明的 `apps/web/dist` 或 `.pack/stickman-runtime`。
+4. 保存 Desktop build manifest、Web 完整哈希、Creator/Krillin runtime manifest、stickman runtime manifest、实际 App E2E 和真实流水线结果。
+5. 发布说明明确:旧 `stickman-video@1` Job 会被定向永久删除;代码回滚不会恢复这些 Job。
+
+### 8.2 回滚步骤
+
+- 数据迁移执行前:可不合并或回滚分支提交,恢复主分支代码与包,不产生数据副作用。
+- 数据迁移执行后:允许回滚代码和资源,但不恢复旧 Demo Job;不得创建伪造旧数据。旧代码遇到 `stickman-video@2` 必须报 unknown template,禁止按 `@1` 解释。
+- 新 @2 结果文件保留在 Job 根中;若回滚版本无法识别,只允许保持不可操作状态,不删除或降级解释。
+- Provider unknown 账本不得因回滚自动重提;恢复到新版本后继续显式处置。
+- 任一包资源或 Web 哈希不一致时停止交付,删除该次生成的 release 产物后重新从当前工作区构建;不得手工替换包内文件。
+
+## 9. 执行偏差与最终报告
+
+不改变 `FR/BR/NFR/DEC/AC` 的局部文件位置、命名和实现细节可以调整,但最终报告必须记录原因、影响和替代验证。任何公开合同、职责边界、迁移范围、Provider 安全语义、五项交付或验收标准变化都必须立即停止并更新方案/Plan,不能通过放宽测试继续。
+
+最终报告必须包含:
+
+- 已完成任务、未完成项和每个 AC 的 PASS/FAIL/BLOCKED。
+- Plan 偏差及其是否改变合同。
+- 主 Agent 最终 diff 自审发现和修复项。
+- 关键 RED、GREEN、回归、typecheck、build、package、E2E 命令与结果。
+- 真实流水线五项交付摘要及计费请求数量,不包含凭证。
+- Web/App 文件哈希、资源 Manifest、Python 扫描和实际 App 证据。
+- 发布/回滚状态和残余风险。
+
+## 10. 风险控制
+
+| 风险 | 控制与失败条件 |
+| --- | --- |
+| 计费 Provider 不支持幂等查询 | 未知接受状态进入 `needs_input`;普通 retry 拒绝;无用户确认不得新 generation。 |
+| Creator 公共核心受 scope 扩展影响 | 新字段对旧模板为 null;定向跑 Service/Storage/Scheduler/视频翻译/封面回归;跨模块失败才升级验证。 |
+| 多 scope 并发产生状态竞态 | lane 只并发 scoped run;SQLite 事务登记 Artifact/Stage 终态;Workflow 聚合后才排下游。 |
+| Remotion/Chromium 跨平台和包体增长 | 固定版本、Manifest 和平台/架构;实际目标平台 package/App E2E 未过即 BLOCKED。 |
+| 旧 Demo 数据删除不可逆 | 精确 SQL、事务、可恢复目录清理、路径守卫、二次幂等;发布说明明确不可恢复。 |
+| 真实 Provider 成本或不稳定 | 固定短输入、限制镜头和候选、记录请求数;真实 AC-2 失败不能由 Fake 测试替代。 |
+| Web/Desktop 表面共用但行为分叉 | 相同 Fake Daemon、偏好和内容视口比较 DOM、请求和持久化;再跑实际 App。 |
+| auto-video 参考实现漂移 | 只迁移已批准五项合同和 TypeScript Remotion 行为;Python 测试通过不作为完成证据。 |
+
+## 11. 独立审核记录
+
+> Reviewer 原始结论:`FAILED`,所选 Reviewer 模型容量不足,错误为 `Selected model is at capacity. Please try a different model.`
+> 流程结论:`PASS(用户知情授权执行)`
+
+| 问题 ID | 严重程度 | 处理决定 | 修改位置 | 关闭证据或不采纳理由 | 遗留风险 |
+| --- | --- | --- | --- | --- | --- |
+| REVIEW-INFRA-1 | Blocker | 按 Plan Skill 约束不启动第二个 Reviewer,不以主 Agent 自审冒充独立审核 | 文档头部、独立审核记录 | 已成功创建 Reviewer 任务,但其 turn 因模型容量失败且没有返回合法 `PASS/REVISE/BLOCKED` 结论 | 本 Plan 已完成主 Agent 自审,但没有第二视角验证方案一致性、追踪、TDD 和验收闭合;用户看到本风险后可明确授权开始执行,或要求以后重新进行独立审核 |
+
+## 12. 2026-09-01 执行结果
+
+### 12.1 TASK 状态
+
+| 范围 | 状态 | 结果 |
+| --- | --- | --- |
+| TASK-0 至 TASK-12 | `PASS` | 唯一 `stickman-video@2`、Creator 持久工作流、镜头级恢复与 Provider 账本、五项交付执行器、统一协作面板和 Desktop Runtime/包合同均已实现并通过对应定向测试。 |
+| TASK-13 | `BLOCKED` | Fake Browser/Desktop parity 和实际打包 App E2E 已通过;真实 Provider 流水线因未配置 `OPENCREATOR_RUN_REAL_STICKMAN_E2E`、`OPENCREATOR_STICKMAN_E2E_CONFIG`、`OPENCREATOR_STICKMAN_E2E_YOUTUBE_URL` 按设计跳过,因此没有真实五项付费交付证据。 |
+| TASK-14 | `BLOCKED` | 最终差异自审、类型检查、定向测试、构建、打包、包验证和实际 App E2E 已执行;因 AC-2 阻塞,整体不得声明功能完成、发布就绪或可合并主分支。 |
+
+### 12.2 AC 状态
+
+| AC | 状态 | 本次证据摘要 |
+| --- | --- | --- |
+| AC-1 | `PASS` | Registry/模板/工作台测试与生产源码扫描通过;只存在 `stickman-video@2`,旧 Executor 已删除。 |
+| AC-2 | `BLOCKED` | 真实流水线测试入口和强校验已实现,但缺少私密 Provider 配置与固定短 YouTube URL,未产生本次真实五项交付。 |
+| AC-3 | `PASS` | 镜头图片、时间线、交付和 ResultSnapshot 定向测试覆盖单 scope 重生成与精确 stale。 |
+| AC-4 | `PASS` | Provider Ledger、未知远端接受、查询、拒绝普通重试、用户确认重提和取消作用域测试通过。 |
+| AC-5 | `PASS` | Creator API/恢复测试、页面恢复测试和实际 App Daemon 重启恢复通过。 |
+| AC-6 | `PASS` | Creator Service/Agent revision 冲突和动作权限测试通过。 |
+| AC-7 | `PASS` | `stickman-video@1` 定向迁移、幂等和目录清理恢复测试通过。 |
+| AC-8 | `PASS` | Fake Browser/Desktop parity 通过;实际 Desktop App E2E `1 passed (46.2s)`。 |
+| AC-9 | `PASS` | 正式目录包校验通过:包体 `1,505,514,995` 字节,Web 74 个文件逐文件一致;FFmpeg/FFprobe `6.1.1`、yt-dlp `2026.08.29.232711`、Python `3.13.15`、Remotion `4.0.473`、Chromium `149.0.7790.0` 均由 Runtime 合同验证。Python 禁止扫描覆盖 Daemon、Stickman Runtime 和 `app.asar`,Creator Runtime 的便携 Python `yt-dlp` 由独立合同验证。 |
+| AC-10 | `PASS` | Adapter、唯一 Panel、P0 文案、Activity 过滤去重和镜头进度聚合测试通过。 |
+
+### 12.3 自审修复与偏差
+
+- 修正 `ffmpeg-static b6.1.1` 的声明与检测版本,由错误的 `6.0` 改为实际 `6.1.1`。
+- Windows 实际 App E2E 改用 Go 编译的 `codex.exe` 启动 Fake Codex,并补齐 Node/脚本环境变量;同时按动态 `latestVersion` 判断 yt-dlp 更新状态、按实际 revision 验证重启恢复,并从“我的项目”打开正确的火柴人 Job。
+- 增加 Creator Runtime、Codex Runtime、Stickman Runtime 单项包体积门禁,分别为 384 MiB、450 MiB、384 MiB;总包门禁保持 1536 MiB。
+- 方案原文“整个 Desktop 包无 Python”与仓库既有 Creator Runtime 便携 Python `yt-dlp` 冲突。本次修订将 NFR-1/AC-9 明确为“不新增 Python 火柴人实现,禁止 Python 进入 Daemon、Stickman Runtime 和 `app.asar`;既有 Creator Runtime 例外必须受独立 Manifest/哈希合同约束”。该修订不改变 TypeScript 火柴人实现边界,也不引入 auto-video Python 代码。
+
+### 12.4 最终门禁结论
+
+- 已通过:Protocol、Daemon、Web、Desktop typecheck;Creator/Stickman/Download 定向测试;Web 相关组件测试;Desktop Creator/Stickman 包合同 `14/14`;Fake parity;Remotion 包内 smoke;实际 Desktop App E2E;`verify:package`;`git diff --check`。
+- 未通过或失败:无。
+- 环境阻塞:仅 AC-2 真实 Provider 五项交付。
+- 分支可以提交并推送用于协作和后续配置验收,但在 AC-2 获得真实证据前不得合并主分支或发布。
diff --git "a/docs/specs/OpenCreator\347\201\253\346\237\264\344\272\272\350\247\206\351\242\221-auto-video\350\241\214\344\270\272\347\255\211\344\273\267\345\220\210\345\220\214-2026-09-03.md" "b/docs/specs/OpenCreator\347\201\253\346\237\264\344\272\272\350\247\206\351\242\221-auto-video\350\241\214\344\270\272\347\255\211\344\273\267\345\220\210\345\220\214-2026-09-03.md"
new file mode 100644
index 00000000..8c802ed5
--- /dev/null
+++ "b/docs/specs/OpenCreator\347\201\253\346\237\264\344\272\272\350\247\206\351\242\221-auto-video\350\241\214\344\270\272\347\255\211\344\273\267\345\220\210\345\220\214-2026-09-03.md"
@@ -0,0 +1,124 @@
+# OpenCreator 火柴人视频与 auto-video 行为等价合同
+
+> 状态:实施基线
+> 参考实现:`auto-video@c85da4a2d86ec761baa0e697ed10d62982ff401b`
+> 目标实现:`stickman-video@2`,TypeScript + CreatorJob + KrillinAI + Remotion
+
+## 1. 等价边界
+
+本合同约束生产行为,不要求复用 Python 代码,也不承诺模型输出逐像素一致。只有下列各项同时成立,才可称为与参考实现行为等价:
+
+- 阶段先后关系、输入工件和输出工件一致。
+- 来源先拆成有原文引用的 Claim,所有 Claim 必须明确保留或舍弃,不能静默遗漏。
+- 脚本由一次 LLM 调用同时生成旁白、画面意图和生图描述;每段引用保留 Claim 及其原始来源片段。
+- 角色参考图片以真实文件和 SHA-256 进入每次镜头生图请求。
+- 旁白先按段生成,再以真实媒体时长建立分镜、字幕和时间线。
+- 固定角色、品牌和 BGM 先物化并锁定风格合同,才允许全量镜头产生新的计费请求。
+- 视觉、时间线、媒体和交付质量门真实执行;失败不得生成成功工件。
+- 上游变化使所有依赖工件变为 `stale`,恢复时只复用指纹完全一致的成功工件。
+- 占位资产、Fake Provider 和未验证媒体只能得到 `technical-draft`,不能得到 `publishable`。
+
+## 2. 生产执行图
+
+```text
+文本或 URL 来源
+ -> source-brief
+ -> content-plan
+ -> script(一次生成旁白 + 画面意图 + 生图描述,并完成结构校验)
+ -> [唯一人工门:approve-script]
+ -> locked-script(审核稿锁定为新的不可变工件)
+ -> tts(逐旁白单元)
+ -> audio-timing(ffprobe 累计真实 TTS 时长)
+ -> storyboard(基于真实时间)
+ -> prompt-pack
+ -> character-reference(真实文件)
+ -> style-assets(物化角色、品牌、BGM)
+ -> style-calibration(自动合同锁)
+ -> images(全量镜头)
+ -> visual-validation
+ -> timeline + narration-srt
+ -> render-clean
+ -> media-validation
+ -> cover / bilingual-subtitles / publish-copy
+ -> bilingual-render
+ -> package-validation
+```
+
+工作台仍显示四个业务步骤;这些步骤是上述生产阶段的产品分组,不是第二套状态机。`CreatorCollaborationPanel` 是唯一 Agent、进度、Activity 和错误展示面。
+
+## 3. 阶段与工件合同
+
+| 阶段 | 必需输入 | 必需输出 | 硬性质量门 |
+| --- | --- | --- | --- |
+| `ingest-text` / `acquire-source` / `source-transcript` | 用户文本或 URL | `source_text` 或 `source_video` + `source_subtitle` | 输入非空;URL 媒体和字幕可读取 |
+| `source-brief` | 来源文本 | `source_brief` | 每个来源片段进入至少一个 Claim;Claim 只能引用真实来源片段 |
+| `content-plan` | `source_brief` | `content_plan` | 所有 Claim 必须且只能进入保留或舍弃集合;章节覆盖全部保留 Claim |
+| `script` | `content_plan` + `source_brief` | `script_manifest` | 同一 Prompt 同时生成旁白、画面意图、生图描述;每段绑定 `claimIds` 和 `sourceSpanIds`;覆盖全部保留 Claim;满足总旁白预算;失败时携带整稿和校验原因重新生成整稿 |
+| `approve-script` | 待审核 `script_manifest` | 新的已锁定 `script_manifest` | 审核状态为 approved、`contentLocked=true`;旧审核稿变为 stale;TTS 只能读取当前锁定稿 |
+| `tts` | 已审核脚本中的单段旁白 | 每段一个 `narration_audio` | 真实非空音频;ffprobe 得到正时长;scope 与 segment 一致 |
+| `audio-timing` | 全部段音频 | `audio_timing` | 每段 start/end/duration 来自 ffprobe;连续且总时长一致;30 秒任务真实总时长必须为 27–33 秒 |
+| `storyboard` | `script_manifest` + `audio_timing` | `shot_spec` | 镜头时间必须引用真实 timing,不得按脚本估时比例分配 |
+| `prompt-pack` | `shot_spec` | `image_prompt_pack` | 最终 Prompt 由画面意图、角色、风格、构图约束共同生成 |
+| `character-reference` | `selectedPresetId` | `character_reference` | `path`、`sha256`、MIME、尺寸均存在;哈希与预设资源一致 |
+| `style-assets` | `selectedPresetId` + 固定资源包 | `character_reference` + `style_contract` | 角色 `path`、`sha256`、MIME、尺寸均存在;哈希与预设资源一致 |
+| `style-calibration` | `style_contract` | `style_calibration` | 自动合同锁必须证明风格、16:9 和角色引用完整 |
+| `images` | 已校准 Prompt Pack + 角色参考图 | 每镜头一个 `shot_image` | 每个请求携带同一参考图字节;只复用相同指纹结果 |
+| `visual-validation` | 全部镜头图 | `visual_validation` | 可解码、16:9、非空白、OCR 无字幕、哈希不重复;全部通过才成功 |
+| `timeline` | `audio_timing` + 镜头图 + 音频 | `timeline_manifest` + `narration_subtitle` | 画面轨、旁白轨、字幕轨边界一致;SRT 机械导出自真实 timing |
+| `render-clean` / `media-validation` | Timeline | `clean_video` + `media_validation` | Remotion 成功;ffprobe 和抽帧检查通过 |
+| 交付阶段 | 已验证纯净视频 | 固定五项结果 + `delivery_manifest` | 文件存在、非空、哈希匹配、可探测;manifest 决定可发布性 |
+
+## 4. Provider 请求合同
+
+当 OpenAI 图像配置指向 RightCodes 兼容端点时,镜头图请求固定为:
+
+```json
+{
+ "model": "gpt-image-2",
+ "prompt": "<最终镜头 Prompt>",
+ "size": "1024x576",
+ "n": 1,
+ "quality": "auto",
+ "response_format": "b64_json",
+ "async": true,
+ "image": ["data:image/<type>;base64,<所选角色原始字节>"]
+}
+```
+
+提交地址只能是 `/images/generations`,不能因有参考图而切换为 `/images/edits` multipart。异步响应必须保存 `task_id` 并查询原任务;远端是否接收未知时进入 `needs_input`,普通重试不得再次计费。
+
+## 5. 审核、失败与失效矩阵
+
+| 事件 | 当前工件 | 必须失效 | 不得发生 |
+| --- | --- | --- | --- |
+| 修改脚本 | 新 `script_manifest` | 旧锁定脚本、TTS、timing、分镜、Prompt、样图、全量图、Timeline、视频和交付 | 复用旧音频或旧时间线 |
+| 修改单镜头画面描述 | 新 `shot_spec` | 对应 Prompt、样图/镜头图及全部聚合下游 | 删除无关镜头的当前图片 |
+| 更换角色 | 新 `character_reference` | 全部样图、全量图、视觉校验、Timeline、视频和交付 | 只改 Prompt 文本而继续使用旧图 |
+| 更换音色/TTS 模型 | 新分段音频 | timing、分镜节奏、Timeline、字幕、视频和交付 | 按旧估时拼接新音频 |
+| 单镜头候选尺寸或内容校验失败 | 失败证据 | 当前候选不得晋级;按固定重试上限处理 | 把失败候选写成成功图片或继续下一镜头 |
+| 任一真实依赖失败 | `failed` / `needs_input` | 下游保持缺失或 stale | 写入成功工件、显示 100% 成功、产出 publishable |
+
+正常流程只保留脚本人工审核。样图自动校准成功后继续;自动检查无法证明可用时阻塞并给出可操作原因,不新增常态人工审核步骤。
+
+旁白中的人物、事件和关系由脚本 Prompt 基于保留 Claim 与原始来源片段生成。Runtime 不通过制作词黑名单删词、替换句子或局部修补旁白,避免为了命中规则破坏语义;结构、引用闭环和预算不合格时,必须把完整失败原因交回模型并重新生成整稿。图片中禁止可见文字属于生图质量约束,只检查 `imagePrompt`,不参与改写旁白。
+
+## 6. 进度与完成判定
+
+- 同一时刻协作面板只展示一个当前业务进度。内部 scoped StageRun 可并行,但由 Adapter 聚合为单条标准进度。
+- 标准进度只含 `phase`、`percent`、`message`、`completed`、`failed`、`total`,通用 Panel 不读取执行器私有字段。
+- 等待执行的后续阶段不显示独立进度条;完成的内部阶段进入 Activity,不重复显示多条 100%。
+- Fake Daemon、1x1 图片、伪 MP3、手填 duration 和跳过的真实 E2E 不能作为发布能力通过证据。
+- `publishable` 只能由真实角色图、真实生图、真实 TTS、真实 timing/SRT、真实 Timeline、Remotion final、ffprobe、抽帧和包校验共同证明。
+
+## 7. 验收最小样例
+
+正式验收固定使用:短文本、`student` 非默认角色、3 个镜头、已配置的真实音色和真实图像服务。验收必须证明:
+
+1. 每次生图请求中的参考图 SHA-256 与 `student.png` 一致。
+2. 所有生成图为 16:9;单镜头候选按固定上限重试,耗尽后不得继续下一镜头。
+3. 脚本一次生成旁白、画面意图和生图描述;每段引用有效的保留 Claim 和来源片段,且全部保留 Claim 都被覆盖。
+4. TTS 恰好按脚本段数生成;每段时长来自 ffprobe,30 秒任务的真实总时长必须为 27–33 秒。
+5. Storyboard 在 `audio_timing` 成功前没有 StageRun。
+6. Timeline 三轨边界和 SRT cue 与真实 timing 一致。
+7. 页面只显示一个当前进度,失败原因与 Daemon 事实一致。
+8. 五项交付都通过实际文件、哈希、ffprobe/抽帧和 manifest 校验;否则状态保持 `BLOCKED`。
diff --git "a/docs/specs/OpenCreator\347\201\253\346\237\264\344\272\272\350\247\206\351\242\221\347\224\237\344\272\247\344\273\273\345\212\241\351\207\215\346\236\204-\346\226\271\346\241\210-2026-08-31.md" "b/docs/specs/OpenCreator\347\201\253\346\237\264\344\272\272\350\247\206\351\242\221\347\224\237\344\272\247\344\273\273\345\212\241\351\207\215\346\236\204-\346\226\271\346\241\210-2026-08-31.md"
new file mode 100644
index 00000000..8ec3dd18
--- /dev/null
+++ "b/docs/specs/OpenCreator\347\201\253\346\237\264\344\272\272\350\247\206\351\242\221\347\224\237\344\272\247\344\273\273\345\212\241\351\207\215\346\236\204-\346\226\271\346\241\210-2026-08-31.md"
@@ -0,0 +1,264 @@
+# OpenCreator 火柴人视频生产任务重构方案
+
+> 状态:草案
+> 体量判断:复杂。该交付同时涉及 Creator 模板与状态、持久化数据清理、镜头级并发与幂等、外部付费 Provider、KrillinAI、Remotion、Web/Desktop 共用界面和正式打包门禁;各部分共同约束同一个可发布任务,无法独立批准或验收,因此保持一份内聚方案。
+> 设计确认:已完成(D-1 至 D-3)
+> Reviewer 原始结论:REVISE
+> 流程结论:PASS
+> 用户批准:已批准(2026-08-31)
+
+## 背景、目标与非目标
+
+### 目标
+
+在 `feat-stick-video` 分支中删除现有火柴人 Demo 的业务实现,以 auto-video 当前真实生产链路为基线,重新实现唯一的 `stickman-video` Creator 任务。新任务必须使用 OpenCreator 已落地于视频翻译、图像生成等功能的 CreatorJob、StageRun、Artifact、CreatorAction、Revision、ResultSnapshot 和 Agent 协作架构,并由 OpenCreator、KrillinAI 与 Remotion 按明确边界共同完成五项交付物。
+
+### 非目标
+
+- 不保留旧火柴人模板、执行器、页面状态或兼容入口。
+- 不迁移或恢复旧火柴人 Demo Job。
+- P0 不恢复 auto-video 旧设计文档中的十三项多平台交付合同。
+- 不把脚本审核、分镜审核、交付包等火柴人产品语义放入 KrillinAI。
+- 不把 auto-video 的 Python 实现、解释器或依赖放入 OpenCreator 源码运行链路或火柴人 Runtime;既有 Creator Runtime 中受 Manifest、版本和哈希约束的便携 Python `yt-dlp` 保持原有媒体获取职责,不扩展为火柴人业务实现。
+- 不借本任务重构视频翻译、图像生成及其他 Creator 模板。
+
+## 用户需求原文
+
+1. `auto-video是自动生成视频的项目,我现在希望把当前这个功能合并到opencreator里面,就像Krillinai提供视频下载、字幕生成等能力一样,需要给出技术方案分析,因为auto-video是Python实现的,opencreator不太适合引入更多语言,有两种选择:1. 用OpenCreator的ts重构 2. 放到Krillinai里面重构,或者你有没有更好的方案,评估一下`
+2. `你推荐的方案整体没问题,需要修正下,auto-video是对应 火柴人生成,目前OpenCreator的 火柴人生成,还是之前的demo,并没有按照 视频翻译、图像生成等这些按照新的架构设计出来的任务,所以需要你重新评估下`
+3. `$zhiyu-brainstorm 1. 从OpenCreator拉取一个新的分支 feat-stick-video开发。2. 不要留兼容模式,stickman-video就只有一个版本,可以使用现有demo的功能交互设计,但底层只有一套`
+4. D-1 确认:`没问题,继续`
+5. D-2 确认:`没问题,继续`
+6. D-3 确认:`没问题,继续`
+
+## 事实基线与假设
+
+| 证据 | 已确认事实 | 对设计的影响 |
+| --- | --- | --- |
+| `apps/web/src/features/dashboard/StickmanVideoWorkspace.tsx` 的 `storyboardShots`、`resultVersions`、`generateStoryboard`、`generateVideo` | 现有火柴人页面以硬编码分镜和 React 本地结果为主,调用后端后会立即标记结果就绪 | 现有业务状态和结果逻辑必须删除,只允许复用交互与视觉设计 |
+| `apps/daemon/src/creator/templates/stickman-video.ts`、`creator/stickman/executor.ts` | 现有模板只有简化的 script、storyboard、narration、render 四阶段,未形成真实审核、版本和完整交付闭环 | 直接替换模板和执行器,不以现有实现为增量基座 |
+| `creator-session-store.tsx`、`creator/service.ts`、`creator/stage-runner.ts`、`creator/result-snapshots.ts` | OpenCreator 已具备持久 CreatorJob、Revision、StageRun、Artifact、stale 血缘、事件同步和结果快照 | 新任务复用 Creator 通用领域模型,不迁移 auto-video 的 SQLite 与 Runner |
+| `video-translation.ts`、`video-translation-actions.ts` | 视频翻译已经形成模板、工作流推进、配置门、reconcile/recover 和 KrillinAI 执行边界 | 火柴人任务按同一新架构建立专属 Workflow Controller |
+| `packages/protocol/src/krillin-opencreator.ts`、KrillinAI `internal/opencreatorapi` | KrillinAI 暴露下载、字幕、TTS、横竖屏渲染等媒体能力,并具有任务、事件、Manifest 和幂等字段 | 只复用通用媒体原子能力,不向 KrillinAI 下沉火柴人产品状态 |
+| auto-video `application/factory.py`、`stages/*`、Remotion 模板 | auto-video 的 Python 主要承担编排、合同和工件处理,字幕已调用 KrillinAI,Remotion 模板本身是 TypeScript | Python 作为行为参考和黄金基线,不作为最终 Runtime |
+| 当前 Git 状态 | 已从最新 `origin/main` 创建本地 `feat-stick-video`,未跟踪的 `auto-video/` 目录保持不变 | 后续方案、Plan 和实现均以该分支为工作分支;首次有效提交后再推送远端 |
+
+假设:P0 输入为有效的 YouTube 公共链接;当前 auto-video 实际五项交付合同是本轮功能基线;旧火柴人 Demo 数据不具有需要保留的生产价值。不存在未决问题。
+
+## 设计确认记录
+
+| 设计部分 | 核心决定 | 用户确认原话 |
+| --- | --- | --- |
+| D-1 产品范围与替换策略 | 直接重做唯一 `stickman-video`;清理旧 Demo Job;P0 交付纯净视频、封面、发布文案、双语视频和双语 SRT;不新增 Python 火柴人实现或 Runtime | `没问题,继续` |
+| D-2 技术架构与任务数据流 | OpenCreator TS 编排,KrillinAI 承担媒体原子能力,Remotion 使用 Node Worker;页面、Agent、版本和进度全部由 CreatorJob、StageRun 和 Artifact 驱动 | `没问题,继续` |
+| D-3 失败恢复、测试与交付门禁 | 定义中断恢复、付费请求安全、镜头级幂等、旧数据清理、Web/Desktop 一致性和实际打包 App 门禁 | `没问题,继续` |
+
+## 需求与业务规则
+
+| ID | 类型 | 优先级 | 描述 |
+| --- | --- | --- | --- |
+| FR-1 | 功能需求 | P0 | 产品中只存在一套可真实运行的 `stickman-video` 工作台、模板、工作流和执行实现;页面可以沿用 Demo 的交互设计,但所有完成状态来自持久任务数据。 |
+| FR-2 | 功能需求 | P0 | 用户输入有效 YouTube 链接并完成脚本、分镜审核后,任务自动完成内容理解、图片、配音、时间线、纯净成片、字幕、封面、发布文案和交付校验。 |
+| FR-3 | 功能需求 | P0 | 用户和 Agent 可以编辑脚本、审核分镜、重生成单镜头并查看历史结果;修改只使受影响 Artifact 及其下游结果失效。 |
+| FR-4 | 功能需求 | P0 | CreatorJob 是工作台与 Agent 的共享权威状态;刷新页面、重启 Daemon 或恢复外部任务后,阶段、审核、进度、版本和结果保持一致。 |
+| BR-1 | 业务规则 | P0 | 不保留兼容模式;TemplateRegistry 只注册当前生产定义 `stickman-video@2`,不注册旧 `@1`;旧 Demo Job 及其关联数据通过一次性迁移定向删除。 |
+| BR-2 | 业务规则 | P0 | OpenCreator 负责产品编排、审核、状态、血缘和交付;KrillinAI 只负责通用媒体能力;Remotion 只负责按照已登记时间线渲染。 |
+| BR-3 | 业务规则 | P0 | 前端不得维护独立结果版本或自行宣布成功;所有可展示结果来自 `completed` 或历史 `stale` Artifact 及 ResultSnapshot。 |
+| BR-4 | 业务规则 | P0 | 具有计费副作用的 Provider 在远端接受状态未知时不得自动再次提交;单镜头成功结果必须在其他镜头失败或重试时保留。 |
+| BR-5 | 业务规则 | P0 | P0 最终交付固定为纯净视频、YouTube 封面、YouTube 发布文案、双语视频和双语 SRT 五项文件,并由 Delivery Manifest 逐项验真。 |
+| NFR-1 | 非功能需求 | P0 | 火柴人源码、Daemon、Stickman Runtime 和 `app.asar` 不包含 Python 实现或 Runtime;既有 Creator Runtime 的便携 Python `yt-dlp` 只能用于统一媒体获取,必须由独立 Manifest 固定版本、文件集和哈希。Remotion、Chromium、字体、素材和 KrillinAI 依赖同样必须固定版本并记录哈希。 |
+| NFR-2 | 非功能需求 | P0 | Web 与实际 Desktop App 在相同内容视口、Job 和设置下具有相同通用界面、动作、Runtime 请求、持久化结果和交付结果。 |
+| NFR-3 | 非功能需求 | P0 | Desktop 正式打包必须从当前工作区重新构建 Web,记录 commit、dirty 状态、Web 构建标识或哈希、平台、架构和构建时间,并逐文件比较 `apps/web/dist` 与 App 内嵌 Web 目录的文件列表和内容哈希。 |
+
+需求追踪:FR-1 由 AC-1、AC-7 验证;FR-2 由 AC-2 验证;FR-3 由 AC-3、AC-6 验证;FR-4 由 AC-5、AC-6、AC-10 验证;BR-1 由 AC-1、AC-7 验证;BR-2 由 AC-2、AC-9 验证;BR-3 由 AC-1、AC-5 验证;BR-4 由 AC-3、AC-4 验证;BR-5 由 AC-2 验证;NFR-1 由 AC-9 验证;NFR-2 由 AC-8 验证;NFR-3 由 AC-9 验证。
+
+## 方案比较与推荐
+
+| 方案 | 状态与调用方影响 | 失败与维护成本 | 结论 |
+| --- | --- | --- | --- |
+| OpenCreator 全量 TS 重写 | 产品状态自然落入 Creator 架构,但会在 TS 中重复下载、ASR、TTS、字幕和媒体渲染能力 | 媒体实现和跨平台依赖维护面过大 | 不采用 |
+| 整条火柴人流水线放入 KrillinAI | OpenCreator 只能把高层流程视作黑盒,或被迫与 KrillinAI 双写阶段、审核和版本 | Go Runtime 被产品语义污染,Agent 与 UI 的逐镜修改、stale 血缘和恢复复杂 | 不采用 |
+| Python Sidecar | 最快复用 auto-video,但新增解释器、依赖、跨平台环境和另一套状态账本 | 与“不引入更多语言”和正式打包约束冲突 | 只作为测试基线,不进入产品 |
+| OpenCreator Creator 编排 + 专用 TS Executor + KrillinAI + Remotion Worker | CreatorJob 保持唯一状态源,媒体能力通过现有 Runtime 边界复用,Remotion 使用原生 Node 生态 | 需要补充镜头级 StageRun 和 Provider 请求安全,但边界可测试、可恢复 | 推荐 |
+
+## 关键设计决策
+
+| DEC ID | 决策 | 理由 | 约束范围 |
+| --- | --- | --- | --- |
+| DEC-1 | 保留模板 ID `stickman-video`,当前 Registry 只注册单一 `version: 2` 生产定义并删除旧 `@1` 定义;旧数据定向删除,不保留 Legacy 模块或并行注册版本 | 仍满足“只有一个版本”,同时让旧代码的 Registry 无法识别或运行新 `@2` Job,避免代码回滚后用 Demo 语义打开生产数据 | TemplateRegistry、数据库迁移、Web 路由、结果打开逻辑、回滚 |
+| DEC-2 | CreatorService 是业务状态唯一权威;OpenCreator TS 承担内容、审核、时间线和交付,KrillinAI 承担通用媒体能力,Remotion 在隔离 Node Worker 中渲染 | 复用新 Creator 架构和既有媒体 Runtime,同时保持产品语义在 OpenCreator | Daemon、Krillin 协议、渲染、UI、Agent |
+| DEC-3 | 审核使用 `needs_input` 和显式 CreatorAction;大内容存为 Artifact,Job State 只保存设置、选择和审核状态;结果版本由 ResultSnapshot 派生 | 避免假 Stage、前端双状态和大对象状态漂移,支持重启恢复与 Agent 协作 | Template、Workflow Controller、CreatorSession、Artifact |
+| DEC-4 | 为昂贵的动态项目执行引入 `scopeKey` 与 `inputFingerprint`;Provider 请求在提交前持久化请求身份,在远端状态未知时阻止自动重试 | 支持单镜头重生成、部分成功、精确 stale 和计费安全 | StageRun、ImageExecutor、Provider Ledger、恢复逻辑 |
+| DEC-5 | P0 固定五项交付合同;Remotion、Chromium、字体、角色素材和 KrillinAI 进入正式资源 Manifest 与实际打包 App 校验 | 防止目标漂移、运行时安装和不可复现资源;满足 Desktop 发布门禁 | Delivery、资源打包、Desktop E2E、发布 |
+
+## 详细设计
+
+### 模块边界
+
+直接替换现有 `templates/stickman-video.ts`、`creator/stickman/*` 和 `StickmanVideoWorkspace.tsx` 的业务实现,不创建 Legacy 目录。新增 `stickman-video-actions.ts` 作为模板专属 Workflow Controller;它与视频翻译工作流保持同一调用模式,负责自动推进、配置门、审核门、幂等排队、`reconcile` 和 `recover`。
+
+执行所有权固定如下:
+
+| 能力 | 执行者 | 主要输入 | 主要输出 |
+| --- | --- | --- | --- |
+| 来源获取 | OpenCreator DownloadExecutor | YouTube URL | `source_video` |
+| 来源转录 | KrillinAI subtitle | `source_video` | `source_subtitle` |
+| 摘要、计划、脚本、分镜规格 | TS LLM Executor | 上游文本 Artifact、用户创作设置 | `source_brief`、`content_plan`、`script_manifest`、`shot_spec` |
+| 分镜图片、封面候选 | OpenCreator ImageExecutor | `shot_spec`、`character_reference`、Prompt、Provider 设置 | `shot_image`、`cover_image` |
+| 配音 | KrillinAI tts | 已批准脚本或字幕 | `narration_audio` |
+| 图片和媒体技术校验 | TS + `sharp`、按需 Tesseract、FFprobe | 图片、音视频 Artifact | 校验元数据或失败 |
+| 时间线 | TS Timeline Executor | 已批准镜头、图片、音频 | `timeline_manifest` |
+| 纯净视频 | Remotion Node Worker | `timeline_manifest` 和受信 Artifact | `clean_video` |
+| 双语字幕与视频 | KrillinAI subtitle/render-horizontal | `clean_video`、语言和字幕设置 | `bilingual_subtitle`、`bilingual_video` |
+| 发布和交付 | TS Delivery Executor | 结果 Artifact、脚本、内容计划 | `publish_copy`、`delivery_manifest` 和五项交付文件 |
+
+KrillinAI 协议不得增加火柴人产品级 Stage。若现有媒体能力缺失,只允许增加可被其他模板复用的通用媒体能力,并同步 TS 类型、JSON Schema、Go DTO 和合同测试。
+
+### 阶段与审核数据流
+
+执行 DAG 为:
+
+```text
+acquire-source
+→ source-transcript
+→ source-brief
+→ content-plan
+→ script
+→ [approve-script]
+→ storyboard
+→ [approve-storyboard]
+→ images ─────┐
+→ narration ──┤
+ ▼
+ visual-validation
+ ↓
+ timeline
+ ↓
+ render-clean
+ ↙ ↓ ↘
+ cover subtitles publish-copy
+ ↓
+ bilingual-render
+ ↘ ↓ ↙
+ package-validation
+```
+
+`approve-script` 和 `approve-storyboard` 是 Action,不注册无执行内容的假 Stage。对应上游 Stage 成功后,Workflow Controller 将 Job 切换为 `needs_input` 并持久化审核对象、来源 Artifact 和 revision;只有针对当前 revision 与当前 Artifact 的批准才能继续。
+
+CreatorAction 至少包括:`update-settings`、`approve-script`、`edit-shot`、`approve-storyboard`、`regenerate-shot`、`approve-visuals`、`run-stage`、`commit-version`、`retry-stage`、`resolve-provider-request` 和 `undo-action`。每个 Action 使用显式 Zod Schema,不使用无边界通用 Record 代替业务合同。
+
+### Job State、Artifact 与结果版本
+
+Job State 只保存来源 URL、角色/参考图选择、创作偏好、语言与配音设置、BGM 设置、当前 UI 步骤、审核状态、当前结果选择和必要的 Artifact ID。脚本、分镜、时间线、字幕、媒体和发布文本都存为 Artifact。
+
+核心 Artifact 包括:`source_video`、`source_subtitle`、`source_brief`、`content_plan`、`script_manifest`、`shot_spec`、`character_reference`、`shot_image`、`narration_audio`、`timeline_manifest`、`clean_video`、`bilingual_subtitle`、`bilingual_video`、`cover_image`、`publish_copy` 和 `delivery_manifest`。
+
+每个 Artifact 必须保存版本、SHA-256、来源 Artifact ID、作用域、模板与模型配置快照,以及媒体适用的 MIME、尺寸、时长等技术证据。ResultSnapshot 只从已登记 Artifact 生成,允许历史结果继续查看;上游变化后旧结果保留为 `stale`,不得作为新运行输入静默复用。
+
+### 镜头级执行与失效
+
+CreatorStageRun 增加可选 `scopeKey` 和 `inputFingerprint`。图片阶段按镜头创建独立 StageRun,例如 `stageId=images`、`scopeKey=shot-07`,指纹覆盖镜头 Prompt、角色参考、风格、模型和所有直接输入 Artifact 哈希。同一 `stageId + scopeKey + inputFingerprint` 只能存在一个活动执行。
+
+修改 `shot-07` 只使该镜头图片以及依赖它的视觉校验、时间线、视频和交付结果失效;其他镜头图片保持 `completed`。Workflow Controller 在进入聚合阶段前校验已批准 Storyboard 中每个 shot 都有匹配当前指纹的成功 Artifact。
+
+### Provider 请求安全
+
+对计费 Provider 持久化请求账本,最少包含 provider、stageRunId、scopeKey、requestKey、requestHash、remoteTaskId、billingSideEffect、status 和 resultArtifactId。流程必须先登记稳定请求身份,再提交远端,再登记 Remote ID,最后登记结果 Artifact。
+
+恢复时优先按 Remote ID 查询;没有 Remote ID 时只有 Provider 明确支持 requestKey 查询才可自动恢复。无法判断远端是否已接受的请求进入 `needs_input`,不得默认再次提交。已经成功的其他镜头 Artifact 不因单项失败而删除或覆盖。
+
+未知计费请求只能通过 `resolve-provider-request` 处置,其 Zod 合同固定为请求账本 ID、当前 revision 和以下一种决策:
+
+| 决策 | 行为 |
+| --- | --- |
+| `query` | 仅当 Provider 声明支持 Remote ID 或 requestKey 查询时继续查询原请求;不创建新计费请求 |
+| `confirm-resubmit` | 只允许用户角色提交,并要求 `acceptDuplicateBilling: true`;原账本标记为 `abandoned_unknown`,新请求使用新的 generation、requestKey 并记录 `resubmissionOf` |
+| `cancel-scope` | 将未知请求和对应镜头执行标记为已取消,不生成假 Artifact;必需镜头仍阻止聚合,用户需编辑或移除该镜头后继续 |
+
+普通 `retry-stage` 必须拒绝存在 `unknown_remote_acceptance` 的计费请求。每次处置写入 Creator Activity,记录 actor、账本 ID、决策和 revision,但不得记录凭证;Agent 可以建议处置,不能代替用户执行 `confirm-resubmit`。
+
+### 前端和 Agent
+
+现有 Demo 的步骤布局、角色选择视觉、分镜弹窗、配音设置、结果页和版本菜单可以继续使用,但所有数据改由 CreatorSession 提供。表单通过 `updateDraft` 持久化,执行通过 CreatorAction 发起,进度由 StageRun 事件驱动,分镜由 `shot_spec` 与 `shot_image` 渲染,结果菜单由 ResultSnapshot 派生。
+
+删除前端的硬编码 `storyboardShots`、本地 `resultVersions`、`storyboardReady`、`videoReady` 和调用后立即成功的逻辑。工作台和 Agent 对同一 Job 使用 `expectedRevision`;冲突时拒绝旧 revision,重新加载后再提交,不覆盖另一入口的较新修改。
+
+火柴人必须复用唯一 `CreatorCollaborationPanel`,不得创建独立 Agent Panel。`creator-panel-adapters.ts` 新增 `stickmanVideoPanelAdapter` 并由 `creatorPanelAdapterFor('stickman-video')` 选择;Adapter 负责全部 P0 Stage 和 Phase 的中英文文案、`approve-script`、`edit-shot`、`approve-storyboard`、`regenerate-shot`、`approve-visuals`、`resolve-provider-request` 等 Activity 语义、无意义草稿 Activity 过滤,以及连续同阶段/同镜头更新的合并去重。
+
+镜头级进度只读取 CreatorStageRun 的标准字段 `phase/percent/message/completed/failed/total/scopeKey`,不得读取执行器私有 Payload。协作面板必须展示真实镜头完成数、失败数和总数,并把脚本审核、分镜审核、渲染、字幕和交付映射为可识别阶段。
+
+### Remotion Worker
+
+Remotion 使用固定版本 `@remotion/bundler` 与 `@remotion/renderer`,由 Daemon 启动隔离 Node 子进程。Worker 只接收受信时间线、Artifact 路径和当前 Stage 工作目录;崩溃只使当前 StageRun 失败。运行时不得执行 `npm install` 或下载不受控 Chromium。
+
+模板、Chromium、字体、角色和固定素材进入 Desktop 资源 Manifest,逐文件记录版本和 SHA-256。输出必须位于当前 Stage 工作目录,完成技术校验后才能登记 `clean_video` Artifact。
+
+## 异常、兼容、迁移与回滚
+
+### 状态和恢复
+
+StageRun 使用 `queued/running/succeeded/failed/interrupted`;配置、审核或远端未知状态通过 Job `needs_input` 表达。Daemon 重启时未结束 StageRun 转为 `interrupted`,Workflow Controller 依据已完成 Artifact、输入指纹、请求账本和父 StageRun 幂等键恢复。成功且指纹未变化的阶段不重跑;Stage 成功但后续排队中断时由 `reconcile` 补排。
+
+用户取消时终止 Remotion、FFmpeg、KrillinAI 和其他子进程树;未通过最终校验的临时文件不登记 Artifact。日志和进度不得输出 API Key、Token、完整 Provider 请求或其他凭证。
+
+### Demo 数据迁移
+
+一次性数据库迁移在事务内定向识别 `template_id='stickman-video' AND template_version=1` 的旧 Job,删除其 StageRun、Artifact、Activity、Agent 关联记录和 Job,并写入迁移标记。事务提交后,只允许在经过根目录约束和路径越界检查后删除这些 Job 的 Creator 文件目录。其他模板数据、`stickman-video@2` Job 和项目文件不得修改。
+
+不提供旧 Demo 数据恢复、Legacy 页面或旧执行器。旧 Demo 主要结果原本是前端内存状态,设计不建立无事实依据的兼容层。
+
+### 发布和回滚
+
+开发只在 `feat-stick-video` 进行,首次有效提交后推送远端。合并前同步最新 `origin/main`,解决 Creator 架构相关冲突并重新执行直接受影响门禁。所有门禁通过前不合并主分支。
+
+发布前可以通过不合并或回滚分支提交撤回功能;数据库清理一旦在用户环境执行,代码回滚不会恢复旧 Demo Job。该不可逆性是用户已确认“不保留兼容模式”的直接结果,发布说明必须明确。新生产任务固定为 `stickman-video@2`,旧代码只注册 `@1`,因此必须以 `Unknown creator template: stickman-video@2` 拒绝打开、修改或运行新任务,不能回退到 latest 或按模板 ID 猜测解释。
+
+## 验收标准
+
+| AC ID | 关联需求 | 前置条件 | 操作 | 可观察结果 | 验证层级 |
+| --- | --- | --- | --- | --- | --- |
+| AC-1 | FR-1、BR-1、BR-3 | 使用新代码、旧代码 Registry 和清洁测试库 | 枚举模板、创建新任务、打开火柴人页面,并尝试用旧 Registry 加载新 Job | 新 Registry 只枚举 `stickman-video@2`;无硬编码分镜、本地结果版本或旧执行器;旧 Registry 明确拒绝加载、修改和运行 `@2` Job | 静态检查 + 单元测试 |
+| AC-2 | FR-2、BR-2、BR-5 | 配置真实生产 Provider、KrillinAI 和固定短 YouTube 输入 | 完成脚本与分镜审核并等待流水线结束 | 产生可播放纯净视频、1280x720 封面、发布文案、可播放双语视频和合法双语 SRT;Delivery Manifest 的路径、哈希和技术参数全部匹配 | 真实流水线 E2E |
+| AC-3 | FR-3、BR-4 | 已完成含多个镜头的结果版本 | 修改一个镜头并重生成 | 只产生该镜头的新 StageRun/Artifact,其他镜头保持有效;时间线、视频和交付被精确标记 stale 后生成新版本 | Service 集成测试 |
+| AC-4 | BR-4 | Fake Provider 支持故障注入和可配置查询能力 | 在远端接受请求后、Remote ID 持久化前模拟崩溃;分别执行查询、普通重试、用户确认重提交和取消作用域 | 可查询时恢复原任务;不可查询时普通 `retry-stage` 被拒绝;只有用户提交 `acceptDuplicateBilling: true` 才创建新 generation;取消不产生假 Artifact 且保留审计 Activity | Provider 故障注入测试 |
+| AC-5 | FR-4、BR-3 | 流水线分别处于运行、审核和完成状态 | 刷新页面并重启 Daemon | Job、阶段、进度、审核对象、ResultSnapshot 和可打开 Artifact 完整恢复;中断阶段可安全继续 | API + 浏览器 E2E |
+| AC-6 | FR-3、FR-4 | 工作台和 Agent 同时打开同一 Job | 工作台先修改,Agent 再使用旧 revision 提交;随后 Agent 刷新并修改镜头 | 旧 revision 返回可识别冲突且不覆盖新数据;刷新后双方看到相同 Job 和 Artifact | Service + Agent 集成测试 |
+| AC-7 | FR-1、BR-1 | 数据库含旧 `stickman-video@1` Demo Job、新 `@2` Job 和其他模板 Job | 执行升级迁移 | 仅旧 `@1` Job 及关联数据被定向删除,新 `@2` 和其他 Creator Job、Artifact、文件保持不变;重复迁移无副作用 | 数据迁移测试 |
+| AC-8 | NFR-2 | 同一 Fake Daemon、Job、偏好和内容视口,以及实际 Desktop App | 执行项目规定的完整 Web/Desktop 一致性套件,并在两端完成审核、单镜头重生成、协作面板查看和结果查看 | 首页、项目选择、设置、输入区、文件工作区及火柴人通用文案、按钮、状态、关键尺寸、CreatorAction、Runtime API、持久化和交付结果一致;Desktop 原生入口仍按 capability 工作 | Web/Desktop 一致性 E2E + 实际 App E2E |
+| AC-9 | BR-2、NFR-1、NFR-3 | 当前工作区准备正式 Desktop 打包,允许工作区 dirty 状态被如实记录 | 运行正式打包链路、资源合同校验和实际 App 火柴人 E2E | 打包前重新构建当前 `apps/web/dist`;构建清单记录 commit、dirty、Web 构建标识或哈希、平台、架构和时间;App 内嵌 Web 与本次 dist 的完整文件列表和逐文件哈希完全一致;Remotion、Chromium、字体、素材和 KrillinAI Manifest 有效;Daemon、Stickman Runtime 和 `app.asar` 无 Python Runtime,Creator Runtime 仅允许受独立 Manifest/哈希合同约束的便携 Python `yt-dlp`;任一不一致均阻止交付 | 构建清单 + 完整哈希比较报告 + 打包合同 + 实际 App E2E |
+| AC-10 | FR-4 | Job 含工作台、Agent、镜头进度和各类火柴人 Activity | 在唯一 CreatorCollaborationPanel 中执行设置修改、审核、镜头重生成、失败重试和 Provider 处置 | `stickmanVideoPanelAdapter` 提供全部 P0 Stage/Phase 文案,过滤无意义 Activity,合并连续同阶段/同镜头更新,展示标准字段产生的真实 completed/failed/total;未创建独立 Panel,也未读取执行器私有字段 | Adapter 单元测试 + Panel 组件测试 |
+
+## 测试策略
+
+- 单元层验证 Zod Action/Artifact 合同、时间线、指纹、作用域、血缘失效、Delivery Manifest 和路径约束。
+- Service 集成层使用临时 SQLite 和文件目录验证 revision、审核门、镜头级 StageRun、部分成功、恢复、取消、迁移和 ResultSnapshot。
+- Provider 层使用 Fake LLM、Fake Image Provider、Fake KrillinAI 验证幂等、未知提交状态、超时、Remote ID 恢复、配置缺失和错误映射;真实 Provider 测试只使用受控短输入并避免无界计费。
+- 前端层验证页面只消费 CreatorSession、StageRun 和 Artifact,运行中不提前显示成功,刷新和冲突后能够恢复;不以硬编码媒体或本地版本冒充结果。
+- 协作层验证 `stickmanVideoPanelAdapter` 的 Stage/Phase 文案、Action Activity、过滤去重、镜头级真实进度和唯一 `CreatorCollaborationPanel` 选择逻辑。
+- 真实边界使用一条固定短视频验证 KrillinAI、Remotion、字幕、双语烧录和五项交付合同。
+- 发布层执行项目完整 Web/Desktop 一致性套件、当前工作区 Web 新鲜构建、构建清单字段校验、`apps/web/dist` 与 App 内嵌资源的完整文件列表和逐文件哈希比较、实际打包 App E2E、Creator Runtime 与 Remotion 资源校验,以及安装包 Python Runtime 扫描。
+
+## 风险与未决问题
+
+| 风险 | 处理 |
+| --- | --- |
+| Remotion Chromium 和字体增大安装包并存在跨平台差异 | 固定版本和资源哈希,逐平台运行实际打包 App;未通过平台不得发布 |
+| 图片 Provider 缺少服务端幂等查询 | 正式流水线阻止未知状态自动重试,通过 `needs_input` 显式处理 |
+| 镜头级 StageRun 扩展影响共享 Creator 核心 | 字段设计为可选,只改变火柴人及明确使用 scope 的执行路径;共享回归由 Creator Service 定向测试覆盖 |
+| 旧 Demo 数据清理不可逆 | 定向事务、路径守卫和迁移测试;发布说明明确不兼容决定 |
+| auto-video 当前测试没有完整真实整链覆盖 | 使用黄金输入输出和新 Fake/真实 E2E 建立新的可执行证据,不把旧单元测试通过视为迁移完成 |
+
+未决问题:无。
+
+## 独立审核记录
+
+Reviewer 原始结论:`REVISE`。
+
+| 问题 ID | 严重程度 | 处理决定 | 修改位置 | 关闭证据或不采纳理由 | 遗留风险 |
+| --- | --- | --- | --- | --- | --- |
+| R-01 | Major | 采纳。当前唯一注册模板改为 `stickman-video@2`,删除 `@1` 注册;旧数据只清理 `@1`;旧代码必须拒绝 `@2` | BR-1、DEC-1、Demo 数据迁移、发布和回滚、AC-1、AC-7 | 关闭条件要求统一身份隔离并证明旧 Registry 无法操作新 Job;AC-1 明确用旧 Registry 验证拒绝,AC-7 验证版本定向迁移 | 数值版本由 1 改为 2,但 Registry 中仍只有一个当前版本,符合用户“只有一个版本”要求 |
+| R-02 | Major | 采纳。增加 `resolve-provider-request` 及 query、confirm-resubmit、cancel-scope 三种决策;普通重试拒绝未知计费状态 | CreatorAction、Provider 请求安全、AC-4 | 关闭条件要求状态转换、Action、审计和三类恢复路径;对应合同与 AC-4 已逐项补齐 | 用户确认重提交仍可能产生重复计费,但必须明确勾选并有 Activity 审计 |
+| R-03 | Major | 采纳。复用唯一协作面板并新增火柴人语义 Adapter,覆盖 Stage/Phase、Activity、去重和标准镜头进度 | 前端和 Agent、AC-10、测试策略 | 关闭条件要求 Adapter 责任和测试;AC-10 同时验证 Adapter、Activity、进度和无独立 Panel | 多阶段文案需要在实现时保持中英文同步,由 Adapter 测试约束 |
+| R-04 | Major | 采纳。补充新鲜 Web 构建、完整构建清单、dist 与 App 内嵌目录的文件列表和逐文件哈希门禁 | NFR-3、AC-8、AC-9、测试策略 | 关闭条件要求完整一致性套件和可判定打包证据;AC-8/AC-9 已列出全部项目门禁和失败语义 | 实际打包成本较高,但属于发布前强制门禁,不能降级 |
+
+全部 Major 均已按 Reviewer 的可验证关闭条件修订,流程结论记录为 `PASS`;Reviewer 原始结论保持 `REVISE`,本版本不启动第二次 Reviewer。
diff --git a/packages/protocol/src/creator-visual-assets.ts b/packages/protocol/src/creator-visual-assets.ts
new file mode 100644
index 00000000..510a0e17
--- /dev/null
+++ b/packages/protocol/src/creator-visual-assets.ts
@@ -0,0 +1,45 @@
+export type CreatorVisualAssetKind = 'character' | 'style';
+export type CreatorVisualAssetSource = 'builtin' | 'user';
+export type CreatorVisualAssetStatus = 'draft' | 'ready' | 'disabled';
+
+export type CreatorVisualAssetRef = {
+ assetId: string;
+ revision: number;
+};
+
+export type CreatorVisualAssetLocalizedText = {
+ zhCN: string;
+ en: string;
+};
+
+export type CreatorVisualStyleSwatch = {
+ background: string;
+ foreground: string;
+ accent: string;
+ texture: 'none' | 'paper' | 'screentone' | 'marker';
+};
+
+export type CreatorVisualAssetSummary = {
+ id: string;
+ revision: number;
+ templateId: string;
+ kind: CreatorVisualAssetKind;
+ source: CreatorVisualAssetSource;
+ status: CreatorVisualAssetStatus;
+ name: CreatorVisualAssetLocalizedText;
+ description: CreatorVisualAssetLocalizedText;
+ previewUrl: string | null;
+ referenceCount: number;
+ recommended: boolean;
+ tags: string[];
+ styleAttributes?: {
+ medium: CreatorVisualAssetLocalizedText;
+ palette: CreatorVisualAssetLocalizedText;
+ sceneDensity: CreatorVisualAssetLocalizedText;
+ swatch: CreatorVisualStyleSwatch;
+ };
+};
+
+export type CreatorVisualAssetCatalogResponse = {
+ assets: CreatorVisualAssetSummary[];
+};
diff --git a/packages/protocol/src/creator.ts b/packages/protocol/src/creator.ts
index 8f07cbf1..eb9fb20a 100644
--- a/packages/protocol/src/creator.ts
+++ b/packages/protocol/src/creator.ts
@@ -31,6 +31,17 @@ export const creatorArtifactStatuses = [
'stale'
] as const;
+export const creatorProviderRequestStatuses = [
+ 'registered',
+ 'submitting',
+ 'waiting_remote',
+ 'succeeded',
+ 'failed',
+ 'unknown_remote_acceptance',
+ 'abandoned_unknown',
+ 'canceled'
+] as const;
+
export const creatorEventKinds = [
'snapshot_changed',
'activity_changed',
@@ -95,6 +106,7 @@ export type CreatorJobStatus = typeof creatorJobStatuses[number];
export type CreatorStageRunStatus = typeof creatorStageRunStatuses[number];
export type CreatorStageDispatchStatus = typeof creatorStageDispatchStatuses[number];
export type CreatorArtifactStatus = typeof creatorArtifactStatuses[number];
+export type CreatorProviderRequestStatus = typeof creatorProviderRequestStatuses[number];
export type CreatorEventKind = typeof creatorEventKinds[number];
export type CreatorAgentSessionStatus = typeof creatorAgentSessionStatuses[number];
export type CreatorAgentTurnStatus = typeof creatorAgentTurnStatuses[number];
@@ -114,6 +126,9 @@ export type CreatorArtifact = {
version: number;
status: CreatorArtifactStatus;
path: string | null;
+ scopeKey: string | null;
+ inputFingerprint: string | null;
+ sha256: string | null;
sourceArtifactIds: string[];
metadata: Record<string, CreatorJson>;
createdAt: string;
@@ -131,6 +146,24 @@ export type CreatorResultSnapshot = {
state: Record<string, CreatorJson>;
};
+export type CreatorProviderRequest = {
+ id: string;
+ jobId: string;
+ provider: string;
+ stageRunId: string;
+ scopeKey: string | null;
+ requestKey: string;
+ requestHash: string;
+ remoteTaskId: string | null;
+ billingSideEffect: boolean;
+ status: CreatorProviderRequestStatus;
+ resultArtifactId: string | null;
+ generation: number;
+ resubmissionOf: string | null;
+ createdAt: string;
+ updatedAt: string;
+};
+
export type CreatorStageRun = {
id: string;
jobId: string;
@@ -142,6 +175,8 @@ export type CreatorStageRun = {
claimExpiresAt: string | null;
attempt: number;
idempotencyKey: string | null;
+ scopeKey: string | null;
+ inputFingerprint: string | null;
progress: Record<string, CreatorJson>;
errorCode: string | null;
errorMessage: string | null;
@@ -171,6 +206,7 @@ export type CreatorJob = {
agentThreadId: string | null;
stages: CreatorStageRun[];
artifacts: CreatorArtifact[];
+ providerRequests: CreatorProviderRequest[];
activities: CreatorActivity[];
createdAt: string;
updatedAt: string;
diff --git a/packages/protocol/src/index.ts b/packages/protocol/src/index.ts
index f5210fdc..a8f80c97 100644
--- a/packages/protocol/src/index.ts
+++ b/packages/protocol/src/index.ts
@@ -1,6 +1,7 @@
export const protocolVersion = '0.1.0';
export * from './creator.js';
+export * from './creator-visual-assets.js';
export * from './creator-download.js';
export * from './api.js';
export * from './creator-services.js';
diff --git a/packages/stickman-remotion/assets/audio/blossom-echo.mp3 b/packages/stickman-remotion/assets/audio/blossom-echo.mp3
new file mode 100644
index 00000000..567c3cac
Binary files /dev/null and b/packages/stickman-remotion/assets/audio/blossom-echo.mp3 differ
diff --git a/packages/stickman-remotion/assets/brand/mindspark-logo.jpg b/packages/stickman-remotion/assets/brand/mindspark-logo.jpg
new file mode 100644
index 00000000..f2ba5b6c
Binary files /dev/null and b/packages/stickman-remotion/assets/brand/mindspark-logo.jpg differ
diff --git a/packages/stickman-remotion/assets/fonts/NotoSans-Bold.woff2 b/packages/stickman-remotion/assets/fonts/NotoSans-Bold.woff2
new file mode 100644
index 00000000..c1b2eb8e
Binary files /dev/null and b/packages/stickman-remotion/assets/fonts/NotoSans-Bold.woff2 differ
diff --git a/packages/stickman-remotion/assets/fonts/NotoSansSC-Bold.woff2 b/packages/stickman-remotion/assets/fonts/NotoSansSC-Bold.woff2
new file mode 100644
index 00000000..8faaeb3f
Binary files /dev/null and b/packages/stickman-remotion/assets/fonts/NotoSansSC-Bold.woff2 differ
diff --git a/packages/stickman-remotion/assets/fonts/OFL.txt b/packages/stickman-remotion/assets/fonts/OFL.txt
new file mode 100644
index 00000000..046fc664
--- /dev/null
+++ b/packages/stickman-remotion/assets/fonts/OFL.txt
@@ -0,0 +1,93 @@
+Google Inc.
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/packages/stickman-remotion/package.json b/packages/stickman-remotion/package.json
new file mode 100644
index 00000000..142769f3
--- /dev/null
+++ b/packages/stickman-remotion/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "@opencreator/stickman-remotion",
+ "version": "0.1.0",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "build": "tsc -p tsconfig.json --noEmit",
+ "typecheck": "tsc -p tsconfig.json --noEmit",
+ "test": "vitest run --passWithNoTests"
+ },
+ "dependencies": {
+ "react": "18.3.1",
+ "react-dom": "18.3.1",
+ "remotion": "4.0.473"
+ },
+ "devDependencies": {
+ "@types/react": "18.3.18",
+ "@types/react-dom": "18.3.5",
+ "typescript": "5.7.3",
+ "vitest": "3.2.7"
+ }
+}
diff --git a/packages/stickman-remotion/src/Root.tsx b/packages/stickman-remotion/src/Root.tsx
new file mode 100644
index 00000000..f887d0c6
--- /dev/null
+++ b/packages/stickman-remotion/src/Root.tsx
@@ -0,0 +1,30 @@
+import React from 'react';
+import { Composition } from 'remotion';
+import { StickmanLandscape } from './StickmanLandscape.js';
+import type { StickmanTimelineProps } from './timeline.js';
+
+const defaultProps: StickmanTimelineProps = {
+ fps: 30,
+ width: 1280,
+ height: 720,
+ totalFrames: 30,
+ shots: []
+};
+
+export const RemotionRoot: React.FC = () => (
+ <Composition
+ id="StickmanLandscape"
+ component={StickmanLandscape}
+ width={1280}
+ height={720}
+ fps={30}
+ durationInFrames={30}
+ defaultProps={defaultProps}
+ calculateMetadata={({ props }) => ({
+ durationInFrames: props.totalFrames,
+ fps: props.fps,
+ width: props.width,
+ height: props.height
+ })}
+ />
+);
diff --git a/packages/stickman-remotion/src/StickmanLandscape.tsx b/packages/stickman-remotion/src/StickmanLandscape.tsx
new file mode 100644
index 00000000..130d0cf5
--- /dev/null
+++ b/packages/stickman-remotion/src/StickmanLandscape.tsx
@@ -0,0 +1,93 @@
+import React from 'react';
+import {
+ AbsoluteFill,
+ Audio,
+ Img,
+ Sequence,
+ interpolate,
+ useCurrentFrame
+} from 'remotion';
+import { assertTimeline, buildNarrationTrack, type StickmanTimelineProps } from './timeline.js';
+import notoSansBold from '../assets/fonts/NotoSans-Bold.woff2';
+import notoSansScBold from '../assets/fonts/NotoSansSC-Bold.woff2';
+
+const localFontFaces = `
+@font-face {
+ font-family: "OpenCreator Noto Sans";
+ src: url("${notoSansBold}") format("woff2");
+ font-style: normal;
+ font-weight: 700;
+ font-display: block;
+}
+@font-face {
+ font-family: "OpenCreator Noto Sans SC";
+ src: url("${notoSansScBold}") format("woff2");
+ font-style: normal;
+ font-weight: 700;
+ font-display: block;
+}
+`;
+
+export const StickmanLandscape: React.FC<StickmanTimelineProps> = props => {
+ const timeline = assertTimeline(props);
+ const narrationTrack = buildNarrationTrack(timeline);
+ return (
+ <AbsoluteFill style={{
+ backgroundColor: '#f7f7f5',
+ fontFamily: '"OpenCreator Noto Sans SC", "OpenCreator Noto Sans", sans-serif'
+ }}>
+ <style>{localFontFaces}</style>
+ {narrationTrack.map(clip => (
+ <Sequence
+ key={`audio-${clip.shotId}`}
+ from={clip.from}
+ durationInFrames={clip.durationInFrames}
+ >
+ <Audio src={fileUrl(clip.audioPath)} />
+ </Sequence>
+ ))}
+ {timeline.shots.map(shot => (
+ <Sequence
+ key={shot.shotId}
+ from={shot.startFrame}
+ durationInFrames={shot.endFrame - shot.startFrame}
+ >
+ <Shot shot={shot} />
+ </Sequence>
+ ))}
+ </AbsoluteFill>
+ );
+};
+
+const Shot: React.FC<{ shot: StickmanTimelineProps['shots'][number] }> = ({ shot }) => {
+ const frame = useCurrentFrame();
+ const duration = shot.endFrame - shot.startFrame;
+ const progress = interpolate(frame, [0, Math.max(1, duration - 1)], [0, 1], {
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp'
+ });
+ const transform = motionTransform(shot.motion, progress);
+ return (
+ <AbsoluteFill style={{ overflow: 'hidden', backgroundColor: '#ffffff' }}>
+ <Img
+ src={fileUrl(shot.imagePath)}
+ style={{ width: '100%', height: '100%', objectFit: 'cover', transform }}
+ />
+ <div style={{ position: 'absolute', inset: 24, border: '3px solid rgba(15,23,42,0.12)' }} />
+ </AbsoluteFill>
+ );
+};
+
+function motionTransform(motion: StickmanTimelineProps['shots'][number]['motion'], progress: number): string {
+ if (motion === 'push-in') return `scale(${1 + progress * 0.08})`;
+ if (motion === 'zoom-out') return `scale(${1.08 - progress * 0.08})`;
+ if (motion === 'pan-left') return `scale(1.06) translateX(${3 - progress * 6}%)`;
+ if (motion === 'pan-right') return `scale(1.06) translateX(${-3 + progress * 6}%)`;
+ return 'scale(1)';
+}
+
+function fileUrl(path: string): string {
+ if (/^(?:https?:|data:|blob:)/i.test(path)) return path;
+ const normalized = path.replaceAll('\\', '/');
+ return normalized.startsWith('/') ? `file://${normalized}` : `file:///${normalized}`;
+}
diff --git a/packages/stickman-remotion/src/assets.d.ts b/packages/stickman-remotion/src/assets.d.ts
new file mode 100644
index 00000000..742dadfb
--- /dev/null
+++ b/packages/stickman-remotion/src/assets.d.ts
@@ -0,0 +1,14 @@
+declare module '*.woff2' {
+ const url: string;
+ export default url;
+}
+
+declare module '*.jpg' {
+ const url: string;
+ export default url;
+}
+
+declare module '*.mp3' {
+ const url: string;
+ export default url;
+}
diff --git a/packages/stickman-remotion/src/index.ts b/packages/stickman-remotion/src/index.ts
new file mode 100644
index 00000000..426fd4a2
--- /dev/null
+++ b/packages/stickman-remotion/src/index.ts
@@ -0,0 +1,4 @@
+import { registerRoot } from 'remotion';
+import { RemotionRoot } from './Root.js';
+
+registerRoot(RemotionRoot);
diff --git a/packages/stickman-remotion/src/timeline.test.ts b/packages/stickman-remotion/src/timeline.test.ts
new file mode 100644
index 00000000..7dd5ac08
--- /dev/null
+++ b/packages/stickman-remotion/src/timeline.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, it } from 'vitest';
+import { assertTimeline, buildNarrationTrack } from './timeline.js';
+
+describe('stickman remotion timeline', () => {
+ it('rejects gaps and accepts contiguous shots', () => {
+ const base = {
+ fps: 30,
+ width: 1280 as const,
+ height: 720 as const,
+ totalFrames: 60,
+ shots: [
+ { shotId: 'shot-1', startFrame: 0, endFrame: 30, imageArtifactId: 'i1', audioArtifactId: 'a1', motion: 'static' as const, imageSha256: 'a'.repeat(64), audioSha256: 'b'.repeat(64), imagePath: 'a.png', audioPath: 'a.mp3' },
+ { shotId: 'shot-2', startFrame: 30, endFrame: 60, imageArtifactId: 'i2', audioArtifactId: 'a1', motion: 'push-in' as const, imageSha256: 'c'.repeat(64), audioSha256: 'b'.repeat(64), imagePath: 'b.png', audioPath: 'a.mp3' }
+ ]
+ };
+ expect(assertTimeline(base)).toBe(base);
+ expect(() => assertTimeline({
+ ...base,
+ shots: [{ ...base.shots[0]!, startFrame: 1 }, base.shots[1]!]
+ })).toThrow(/gap_or_overlap/);
+ expect(buildNarrationTrack(base)).toEqual([
+ { shotId: 'shot-1', from: 0, durationInFrames: 30, audioPath: 'a.mp3' },
+ { shotId: 'shot-2', from: 30, durationInFrames: 30, audioPath: 'a.mp3' }
+ ]);
+ });
+});
diff --git a/packages/stickman-remotion/src/timeline.ts b/packages/stickman-remotion/src/timeline.ts
new file mode 100644
index 00000000..9750a470
--- /dev/null
+++ b/packages/stickman-remotion/src/timeline.ts
@@ -0,0 +1,48 @@
+export type StickmanTimelineProps = {
+ fps: number;
+ width: 1280;
+ height: 720;
+ totalFrames: number;
+ shots: Array<{
+ shotId: string;
+ startFrame: number;
+ endFrame: number;
+ imageArtifactId: string;
+ audioArtifactId: string;
+ motion: 'static' | 'push-in' | 'pan-left' | 'pan-right' | 'zoom-out';
+ imageSha256: string;
+ audioSha256: string;
+ imagePath: string;
+ audioPath: string;
+ }>;
+};
+
+export function assertTimeline(value: StickmanTimelineProps): StickmanTimelineProps {
+ if (value.width !== 1280 || value.height !== 720 || value.fps <= 0 || value.totalFrames <= 0) {
+ throw new Error('stickman_timeline_invalid');
+ }
+ let cursor = 0;
+ for (const shot of value.shots) {
+ if (shot.startFrame !== cursor || shot.endFrame <= shot.startFrame) {
+ throw new Error(`stickman_timeline_gap_or_overlap:${shot.shotId}`);
+ }
+ if (!shot.imagePath || !shot.audioPath) throw new Error(`stickman_timeline_path_missing:${shot.shotId}`);
+ cursor = shot.endFrame;
+ }
+ if (cursor !== value.totalFrames) throw new Error('stickman_timeline_total_mismatch');
+ return value;
+}
+
+export function buildNarrationTrack(timeline: StickmanTimelineProps): Array<{
+ shotId: string;
+ from: number;
+ durationInFrames: number;
+ audioPath: string;
+}> {
+ return timeline.shots.map(shot => ({
+ shotId: shot.shotId,
+ from: shot.startFrame,
+ durationInFrames: shot.endFrame - shot.startFrame,
+ audioPath: shot.audioPath
+ }));
+}
diff --git a/packages/stickman-remotion/tsconfig.json b/packages/stickman-remotion/tsconfig.json
new file mode 100644
index 00000000..571b0ffe
--- /dev/null
+++ b/packages/stickman-remotion/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "compilerOptions": {
+ "target": "ES2022",
+ "module": "ESNext",
+ "moduleResolution": "Bundler",
+ "jsx": "react-jsx",
+ "strict": true,
+ "skipLibCheck": true,
+ "types": ["node"]
+ },
+ "include": ["src/**/*.ts", "src/**/*.tsx"]
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 46b260ff..69e7aea6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -36,7 +36,7 @@ importers:
version: 5.9.3
vitest:
specifier: ^3.2.7
apps/daemon:
dependencies:
@@ -61,6 +61,9 @@ importers:
'@opencreator/writing-templates':
specifier: workspace:*
version: link:../../packages/writing-templates
+ '@remotion/renderer':
+ specifier: 4.0.473
better-sqlite3:
specifier: ^12.11.1
version: 12.11.1
@@ -91,13 +94,25 @@ importers:
pdfkit:
specifier: ^0.20.2
version: 0.20.2
+ sharp:
+ specifier: 0.34.3
+ version: 0.34.3
+ toml:
+ specifier: ^3.0.0
+ version: 3.0.0
yaml:
specifier: ^2.8.1
version: 2.9.0
+ yauzl:
+ specifier: 3.4.0
+ version: 3.4.0
zod:
specifier: ^3.25.76
version: 3.25.76
devDependencies:
+ '@remotion/bundler':
+ specifier: 4.0.473
'@types/better-sqlite3':
specifier: ^7.6.13
version: 7.6.13
@@ -110,6 +125,9 @@ importers:
'@types/pdfkit':
specifier: ^0.17.6
version: 0.17.6
+ '@types/yauzl':
+ specifier: 3.4.0
+ version: 3.4.0
apps/desktop:
dependencies:
@@ -149,10 +167,10 @@ importers:
version: 5.9.3
vite:
specifier: ^6.0.7
vitest:
specifier: ^3.2.7
apps/harness:
dependencies:
@@ -224,7 +242,7 @@ importers:
vite:
specifier: ^6.0.7
devDependencies:
'@testing-library/jest-dom':
specifier: ^6.6.3
@@ -243,7 +261,7 @@ importers:
version: 18.3.7(@types/[email protected])
'@vitejs/plugin-react':
specifier: ^4.3.4
fake-indexeddb:
specifier: ^6.0.0
version: 6.2.5
@@ -252,7 +270,7 @@ importers:
version: 25.0.1
vitest:
specifier: ^3.2.4
packages/config:
dependencies:
@@ -265,12 +283,37 @@ importers:
devDependencies:
vitest:
specifier: ^3.2.7
packages/protocol: {}
packages/skill-market: {}
+ packages/stickman-remotion:
+ dependencies:
+ react:
+ specifier: 18.3.1
+ version: 18.3.1
+ react-dom:
+ specifier: 18.3.1
+ version: 18.3.1([email protected])
+ remotion:
+ specifier: 4.0.473
+ devDependencies:
+ '@types/react':
+ specifier: 18.3.18
+ version: 18.3.18
+ '@types/react-dom':
+ specifier: 18.3.5
+ version: 18.3.5(@types/[email protected])
+ typescript:
+ specifier: 5.7.3
+ version: 5.7.3
+ vitest:
+ specifier: 3.2.7
+
packages/writing-templates: {}
packages:
@@ -482,12 +525,27 @@ packages:
engines: {node: '>=14.14'}
hasBin: true
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==}
+
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==}
+
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==}
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [aix]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-lhRUCeuOyJQURhTxl4WkpFTjIsbDayJHih5kZC1giwE+MhIzAb7mEsQMqMf18rHLsrb5qI1tafG20mLxEWcWlA==}
+ engines: {node: '>=18'}
+ cpu: [ppc64]
+ os: [aix]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==}
engines: {node: '>=18'}
@@ -500,6 +558,12 @@ packages:
cpu: [arm64]
os: [android]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-+WzIXQOSaGs33tLEgYPYe/yQHf0WTU0X42Jca3y8NWMbUVhp7rUnw+vAsRC/QiDrdD31IszMrZy+qwPOPjd+rw==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [android]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==}
engines: {node: '>=18'}
@@ -512,6 +576,12 @@ packages:
cpu: [arm]
os: [android]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-wqh0ByljabXLKHeWXYLqoJ5jKC4XBaw6Hk08OfMrCRd2nP2ZQ5eleDZC41XHyCNgktBGYMbqnrJKq/K/lzPMSQ==}
+ engines: {node: '>=18'}
+ cpu: [arm]
+ os: [android]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==}
engines: {node: '>=18'}
@@ -524,6 +594,12 @@ packages:
cpu: [x64]
os: [android]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-+VJggoaKhk2VNNqVL7f6S189UzShHC/mR9EE8rDdSkdpN0KflSwWY/gWjDrNxxisg8Fp1ZCD9jLMo4m0OUfeUA==}
+ engines: {node: '>=18'}
+ cpu: [x64]
+ os: [android]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==}
engines: {node: '>=18'}
@@ -536,6 +612,12 @@ packages:
cpu: [arm64]
os: [darwin]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-0T+A9WZm+bZ84nZBtk1ckYsOvyA3x7e2Acj1KdVfV4/2tdG4fzUp91YHx+GArWLtwqp77pBXVCPn2We7Letr0Q==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [darwin]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==}
engines: {node: '>=18'}
@@ -548,6 +630,12 @@ packages:
cpu: [x64]
os: [darwin]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-fyzLm/DLDl/84OCfp2f/XQ4flmORsjU7VKt8HLjvIXChJoFFOIL6pLJPH4Yhd1n1gGFF9mPwtlN5Wf82DZs+LQ==}
+ engines: {node: '>=18'}
+ cpu: [x64]
+ os: [darwin]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==}
engines: {node: '>=18'}
@@ -560,6 +648,12 @@ packages:
cpu: [arm64]
os: [freebsd]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-l9GeW5UZBT9k9brBYI+0WDffcRxgHQD8ShN2Ur4xWq/NFzUKm3k5lsH4PdaRgb2w7mI9u61nr2gI2mLI27Nh3Q==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [freebsd]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==}
engines: {node: '>=18'}
@@ -572,6 +666,12 @@ packages:
cpu: [x64]
os: [freebsd]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-BXoQai/A0wPO6Es3yFJ7APCiKGc1tdAEOgeTNy3SsB491S3aHn4S4r3e976eUnPdU+NbdtmBuLncYir2tMU9Nw==}
+ engines: {node: '>=18'}
+ cpu: [x64]
+ os: [freebsd]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==}
engines: {node: '>=18'}
@@ -584,6 +684,12 @@ packages:
cpu: [arm64]
os: [linux]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-RVyzfb3FWsGA55n6WY0MEIEPURL1FcbhFE6BffZEMEekfCzCIMtB5yyDcFnVbTnwk+CLAgTujmV/Lgvih56W+A==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [linux]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==}
engines: {node: '>=18'}
@@ -596,6 +702,12 @@ packages:
cpu: [arm]
os: [linux]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-CjaaREJagqJp7iTaNQjjidaNbCKYcd4IDkzbwwxtSvjI7NZm79qiHc8HqciMddQ6CKvJT6aBd8lO9kN/ZudLlw==}
+ engines: {node: '>=18'}
+ cpu: [arm]
+ os: [linux]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==}
engines: {node: '>=18'}
@@ -608,6 +720,12 @@ packages:
cpu: [ia32]
os: [linux]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-KBnSTt1kxl9x70q+ydterVdl+Cn0H18ngRMRCEQfrbqdUuntQQ0LoMZv47uB97NljZFzY6HcfqEZ2SAyIUTQBQ==}
+ engines: {node: '>=18'}
+ cpu: [ia32]
+ os: [linux]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==}
engines: {node: '>=18'}
@@ -620,6 +738,12 @@ packages:
cpu: [loong64]
os: [linux]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-zpSlUce1mnxzgBADvxKXX5sl8aYQHo2ezvMNI8I0lbblJtp8V4odlm3Yzlj7gPyt3T8ReksE6bK+pT3WD+aJRg==}
+ engines: {node: '>=18'}
+ cpu: [loong64]
+ os: [linux]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==}
engines: {node: '>=18'}
@@ -632,6 +756,12 @@ packages:
cpu: [mips64el]
os: [linux]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-2jIfP6mmjkdmeTlsX/9vmdmhBmKADrWqN7zcdtHIeNSCH1SqIoNI63cYsjQR8J+wGa4Y5izRcSHSm8K3QWmk3w==}
+ engines: {node: '>=18'}
+ cpu: [mips64el]
+ os: [linux]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==}
engines: {node: '>=18'}
@@ -644,6 +774,12 @@ packages:
cpu: [ppc64]
os: [linux]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-bc0FE9wWeC0WBm49IQMPSPILRocGTQt3j5KPCA8os6VprfuJ7KD+5PzESSrJ6GmPIPJK965ZJHTUlSA6GNYEhg==}
+ engines: {node: '>=18'}
+ cpu: [ppc64]
+ os: [linux]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==}
engines: {node: '>=18'}
@@ -656,6 +792,12 @@ packages:
cpu: [riscv64]
os: [linux]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-SQPZOwoTTT/HXFXQJG/vBX8sOFagGqvZyXcgLA3NhIqcBv1BJU1d46c0rGcrij2B56Z2rNiSLaZOYW5cUk7yLQ==}
+ engines: {node: '>=18'}
+ cpu: [riscv64]
+ os: [linux]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==}
engines: {node: '>=18'}
@@ -668,6 +810,12 @@ packages:
cpu: [s390x]
os: [linux]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-SCfR0HN8CEEjnYnySJTd2cw0k9OHB/YFzt5zgJEwa+wL/T/raGWYMBqwDNAC6dqFKmJYZoQBRfHjgwLHGSrn3Q==}
+ engines: {node: '>=18'}
+ cpu: [s390x]
+ os: [linux]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==}
engines: {node: '>=18'}
@@ -680,6 +828,12 @@ packages:
cpu: [x64]
os: [linux]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-us0dSb9iFxIi8srnpl931Nvs65it/Jd2a2K3qs7fz2WfGPHqzfzZTfec7oxZJRNPXPnNYZtanmRc4AL/JwVzHQ==}
+ engines: {node: '>=18'}
+ cpu: [x64]
+ os: [linux]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==}
engines: {node: '>=18'}
@@ -692,6 +846,12 @@ packages:
cpu: [arm64]
os: [netbsd]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-CR/RYotgtCKwtftMwJlUU7xCVNg3lMYZ0RzTmAHSfLCXw3NtZtNpswLEj/Kkf6kEL3Gw+BpOekRX0BYCtklhUw==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [netbsd]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==}
engines: {node: '>=18'}
@@ -704,6 +864,12 @@ packages:
cpu: [x64]
os: [netbsd]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-nU1yhmYutL+fQ71Kxnhg8uEOdC0pwEW9entHykTgEbna2pw2dkbFSMeqjjyHZoCmt8SBkOSvV+yNmm94aUrrqw==}
+ engines: {node: '>=18'}
+ cpu: [x64]
+ os: [netbsd]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==}
engines: {node: '>=18'}
@@ -716,6 +882,12 @@ packages:
cpu: [arm64]
os: [openbsd]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-cXb5vApOsRsxsEl4mcZ1XY3D4DzcoMxR/nnc4IyqYs0rTI8ZKmW6kyyg+11Z8yvgMfAEldKzP7AdP64HnSC/6g==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [openbsd]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==}
engines: {node: '>=18'}
@@ -728,6 +900,12 @@ packages:
cpu: [x64]
os: [openbsd]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-8wZM2qqtv9UP3mzy7HiGYNH/zjTA355mpeuA+859TyR+e+Tc08IHYpLJuMsfpDJwoLo1ikIJI8jC3GFjnRClzA==}
+ engines: {node: '>=18'}
+ cpu: [x64]
+ os: [openbsd]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==}
engines: {node: '>=18'}
@@ -740,6 +918,12 @@ packages:
cpu: [arm64]
os: [openharmony]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-FLGfyizszcef5C3YtoyQDACyg95+dndv79i2EekILBofh5wpCa1KuBqOWKrEHZg3zrL3t5ouE5jgr94vA+Wb2w==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [openharmony]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==}
engines: {node: '>=18'}
@@ -752,6 +936,12 @@ packages:
cpu: [x64]
os: [sunos]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-1ZgjUoEdHZZl/YlV76TSCz9Hqj9h9YmMGAgAPYd+q4SicWNX3G5GCyx9uhQWSLcbvPW8Ni7lj4gDa1T40akdlw==}
+ engines: {node: '>=18'}
+ cpu: [x64]
+ os: [sunos]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==}
engines: {node: '>=18'}
@@ -764,6 +954,12 @@ packages:
cpu: [arm64]
os: [win32]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-Q9StnDmQ/enxnpxCCLSg0oo4+34B9TdXpuyPeTedN/6+iXBJ4J+zwfQI28u/Jl40nOYAxGoNi7mFP40RUtkmUA==}
+ engines: {node: '>=18'}
+ cpu: [arm64]
+ os: [win32]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==}
engines: {node: '>=18'}
@@ -776,6 +972,12 @@ packages:
cpu: [ia32]
os: [win32]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-zF3ag/gfiCe6U2iczcRzSYJKH1DCI+ByzSENHlM2FcDbEeo5Zd2C86Aq0tKUYAJJ1obRP84ymxIAksZUcdztHA==}
+ engines: {node: '>=18'}
+ cpu: [ia32]
+ os: [win32]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==}
engines: {node: '>=18'}
@@ -788,6 +990,12 @@ packages:
cpu: [x64]
os: [win32]
+ '@esbuild/[email protected]':
+ resolution: {integrity: sha512-pEl1bO9mfAmIC+tW5btTmrKaujg3zGtUmWNdCw/xs70FBjwAL3o9OEKNHvNmnyylD6ubxUERiEhdsL0xBQ9efw==}
+ engines: {node: '>=18'}
+ cpu: [x64]
+ os: [win32]
+
'@esbuild/[email protected]':
resolution: {integrity: sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==}
engines: {node: '>=18'}
@@ -824,6 +1032,128 @@ packages:
resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==}
+ resolution: {integrity: sha512-ryFMfvxxpQRsgZJqBd4wsttYQbCxsJksrv9Lw/v798JcQ8+w84mBWuXwl+TT0WJ/WrYOLaYpwQXi3sA9nTIaIg==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [arm64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-yHpJYynROAj12TA6qil58hmPmAwxKKC7reUqtGLzsOHfP7/rniNGTL8tjWX6L3CTV4+5P4ypcS7Pp+7OB+8ihA==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [x64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-sBZmpwmxqwlqG9ueWFXtockhsxefaV6O84BMOrhtg/YqbTaRdqDE7hxraVE3y6gVM4eExmfzW4a8el9ArLeEiQ==}
+ cpu: [arm64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-M64XVuL94OgiNHa5/m2YvEQI5q2cl9d/wk0qFTDVXcYzi43lxuiFTftMR1tOnFQovVXNZJ5TURSDK2pNe9Yzqg==}
+ cpu: [x64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-RXwd0CgG+uPRX5YYrkzKyalt2OJYRiJQ8ED/fi1tq9WQW2jsQIn0tqrlR5l5dr/rjqq6AHAxURhj2DVjyQWSOA==}
+ cpu: [arm64]
+ os: [linux]
+
+ resolution: {integrity: sha512-mWd2uWvDtL/nvIzThLq3fr2nnGfyr/XMXlq8ZJ9WMR6PXijHlC3ksp0IpuhK6bougvQrchUAfzRLnbsen0Cqvw==}
+ cpu: [arm]
+ os: [linux]
+
+ resolution: {integrity: sha512-Xod/7KaDDHkYu2phxxfeEPXfVXFKx70EAFZ0qyUdOjCcxbjqyJOEUpDe6RIyaunGxT34Anf9ue/wuWOqBW2WcQ==}
+ cpu: [ppc64]
+ os: [linux]
+
+ resolution: {integrity: sha512-eMKfzDxLGT8mnmPJTNMcjfO33fLiTDsrMlUVcp6b96ETbnJmd4uvZxVJSKPQfS+odwfVaGifhsB07J1LynFehw==}
+ cpu: [s390x]
+ os: [linux]
+
+ resolution: {integrity: sha512-ZW3FPWIc7K1sH9E3nxIGB3y3dZkpJlMnkk7z5tu1nSkBoCgw2nSRTFHI5pB/3CQaJM0pdzMF3paf9ckKMSE9Tg==}
+ cpu: [x64]
+ os: [linux]
+
+ resolution: {integrity: sha512-UG+LqQJbf5VJ8NWJ5Z3tdIe/HXjuIdo4JeVNADXBFuG7z9zjoegpzzGIyV5zQKi4zaJjnAd2+g2nna8TZvuW9Q==}
+ cpu: [arm64]
+ os: [linux]
+
+ resolution: {integrity: sha512-SRYOLR7CXPgNze8akZwjoGBoN1ThNZoqpOgfnOxmWsklTGVfJiGJoC/Lod7aNMGA1jSsKWM1+HRX43OP6p9+6Q==}
+ cpu: [x64]
+ os: [linux]
+
+ resolution: {integrity: sha512-QdrKe3EvQrqwkDrtuTIjI0bu6YEJHTgEeqdzI3uWJOH6G1O8Nl1iEeVYRGdj1h5I21CqxSvQp1Yv7xeU3ZewbA==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [arm64]
+ os: [linux]
+
+ resolution: {integrity: sha512-oBK9l+h6KBN0i3dC8rYntLiVfW8D8wH+NPNT3O/WBHeW0OQWCjfWksLUaPidsrDKpJgXp3G3/hkmhptAW0I3+A==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [arm]
+ os: [linux]
+
+ resolution: {integrity: sha512-GLtbLQMCNC5nxuImPR2+RgrviwKwVql28FWZIW1zWruy6zLgA5/x2ZXk3mxj58X/tszVF69KK0Is83V8YgWhLA==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [ppc64]
+ os: [linux]
+
+ resolution: {integrity: sha512-3gahT+A6c4cdc2edhsLHmIOXMb17ltffJlxR0aC2VPZfwKoTGZec6u5GrFgdR7ciJSsHT27BD3TIuGcuRT0KmQ==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [s390x]
+ os: [linux]
+
+ resolution: {integrity: sha512-8kYso8d806ypnSq3/Ly0QEw90V5ZoHh10yH0HnrzOCr6DKAPI6QVHvwleqMkVQ0m+fc7EH8ah0BB0QPuWY6zJQ==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [x64]
+ os: [linux]
+
+ resolution: {integrity: sha512-vAjbHDlr4izEiXM1OTggpCcPg9tn4YriK5vAjowJsHwdBIdx0fYRsURkxLG2RLm9gyBq66gwtWI8Gx0/ov+JKQ==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [arm64]
+ os: [linux]
+
+ resolution: {integrity: sha512-gCWUn9547K5bwvOn9l5XGAEjVTTRji4aPTqLzGXHvIr6bIDZKNTA34seMPgM0WmSf+RYBH411VavCejp3PkOeQ==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [x64]
+ os: [linux]
+
+ resolution: {integrity: sha512-+CyRcpagHMGteySaWos8IbnXcHgfDn7pO2fiC2slJxvNq9gDipYBN42/RagzctVRKgxATmfqOSulgZv5e1RdMg==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [wasm32]
+
+ resolution: {integrity: sha512-MjnHPnbqMXNC2UgeLJtX4XqoVHHlZNd+nPt1kRPmj63wURegwBhZlApELdtxM2OIZDRv/DFtLcNhVbd1z8GYXQ==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [arm64]
+ os: [win32]
+
+ resolution: {integrity: sha512-xuCdhH44WxuXgOM714hn4amodJMZl3OEvf0GVTm0BEyMeA2to+8HEdRPShH0SLYptJY1uBw+SCFP9WVQi1Q/cw==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [ia32]
+ os: [win32]
+
+ resolution: {integrity: sha512-OWwz05d++TxzLEv4VnsTz5CmZ6mI6S05sfQGEMrNrQcOEERbX46332IvE7pO/EUiw7jUrrS40z/M7kPyjfl04g==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+ cpu: [x64]
+ os: [win32]
+
'@isaacs/[email protected]':
resolution: {integrity: sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==}
engines: {node: '>=18.0.0'}
@@ -838,6 +1168,9 @@ packages:
resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}
engines: {node: '>=6.0.0'}
+ '@jridgewell/[email protected]':
+ resolution: {integrity: sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==}
+
'@jridgewell/[email protected]':
resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==}
@@ -885,6 +1218,21 @@ packages:
'@marijn/[email protected]':
resolution: {integrity: sha512-FY+MKLBoTsLNJF/eLWaOsXGdz6uh3Iu1axjPf6TUq92IYumcTcXWHoS747JARLkcdlJ/Waiaxc5wQfFO8jC6NA==}
+ '@mediabunny/[email protected]':
+ resolution: {integrity: sha512-vLQw8cY7Me6pvTTMkMhOiH9UCuINzfTOETCeDxbGNeNfDqc/7QlxloUH1Ylp/Zz2ek0O8kc6YdygV2vWAPakrA==}
+ peerDependencies:
+ mediabunny: ^1.0.0
+
+ '@mediabunny/[email protected]':
+ resolution: {integrity: sha512-LfKbAMZVkxRS7PpEIVnWOY/l0KcHv+rjO7pYY3O0TPCZvbHWfrnQjn8JPacPIfuq6Yv7r4f8lhcl7yHSynoRkQ==}
+ peerDependencies:
+ mediabunny: ^1.0.0
+
+ '@mediabunny/[email protected]':
+ resolution: {integrity: sha512-Bobi6AaQYEc7TWmPJ8Q0/hcUtBN7pLUC2qjoC7oZR4FcGqGztby6k7A1SWlmswoMOEIhYsOrgDaemrSDAC0QVQ==}
+ peerDependencies:
+ mediabunny: ^1.0.0
+
'@modelcontextprotocol/[email protected]':
resolution: {integrity: sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==}
engines: {node: '>=18'}
@@ -895,6 +1243,27 @@ packages:
'@cfworker/json-schema':
optional: true
+ '@module-federation/[email protected]':
+ resolution: {integrity: sha512-xF9SjnEy7vTdx+xekjPCV5cIHOGCkdn3pIxo9vU7gEZMIw0SvAEdsy6Uh17xaCpm8V0FWvR0SZoK9Ik6jGOaug==}
+
+ '@module-federation/[email protected]':
+ resolution: {integrity: sha512-GR1TcD6/s7zqItfhC87zAp30PqzvceoeDGYTgF3Vx2TXvsfDrhP6Qw9T4vudDQL3uJRne6t7CzdT29YyVxlgIA==}
+
+ '@module-federation/[email protected]':
+ resolution: {integrity: sha512-4ScUJ/aUfEernb+4PbLdhM/c60VHl698Gn1gY21m9vyC1Ucn69fPCA1y2EwcCB7IItseRMoNhdcWQnzt/OPCNA==}
+
+ '@module-federation/[email protected]':
+ resolution: {integrity: sha512-38g5iPju2tPC3KHMPxRKmy4k4onNp6ypFPS1eKGsNLUkXgHsPMBFqAjDw96iEcjri91BrahG4XcdyKi97xZzlA==}
+
+ '@module-federation/[email protected]':
+ resolution: {integrity: sha512-x4aFNBKn2KVQRuNVC5A7SnrSCSqyfIWmm1DvubjbO9iKFe7ith5niw8dqSFBekYBg2Fwy+eMg4sEFNVvCAdo6g==}
+
+ '@module-federation/[email protected]':
+ resolution: {integrity: sha512-aM8gCqXu+/4wBmJtVeMeeMN5guw3chf+2i6HajKtQv7SJfxV/f4IyNQJUeUQu9HfiAZHjqtMV5Lvq/Lvh8LdyA==}
+
+ '@napi-rs/[email protected]':
+ resolution: {integrity: sha512-SeDnOO0Tk7Okiq6DbXmmBODgOAb9dp9gjlphokTUxmt8U3liIP1ZsozBahH69j/RJv+Rfs6IwUKHTgQYJ/HBAw==}
+
resolution: {integrity: sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==}
engines: {node: ^14.21.3 || >=16}
@@ -937,6 +1306,97 @@ packages:
resolution: {integrity: sha512-4An71tdz9X8+3sI4Qqqd2LWd9vS39J7sqd9EU4Scw7TJE/qB10Flv/UuqbPVgfQV9XoK8Np6jNquZitnZq5i+Q==}
engines: {node: '>=14.0.0'}
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-UOGKU3iSmU5mICCcW9qZx++sSBssjAZofX8UA3pbyKJIVvVfG+QznikA0fI4W+1/1l5zMyxd/fwMFbz8+q4u2A==}
+ peerDependencies:
+ react: '>=16.8.0'
+ react-dom: '>=16.8.0'
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-cSKS6VPKpLlEs+W0TSgXbxzdHDFxj+ft1jeP/MhedtL3rcSDyjir8RTI8bqDgrcEF4km3Rcg0CxrGbYTKgUVVQ==}
+ cpu: [arm64]
+ os: [darwin]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-Sf0IHz/zXroP4UGZ0NkyVn0ICiOMeUj07i8nRoz0A95d4TDR3YKVThY4U16ElsaLSbHk3pMcobCxx1tscvtZYQ==}
+ cpu: [x64]
+ os: [darwin]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-HeV247O9dwhSfXFYoA7Dd0zPmyn2grbrIhaYs2MJZxO6IHmEUk0gm9/drWyjDHy4e2WCg98uSlcycNOmWtG5ng==}
+ cpu: [arm64]
+ os: [linux]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-7EGy2MtQch3yLzwxvWncz/3rmXOWQkWigCDL37I90aHhlf8JgrMZXo8dUtIoD0LP/zHWtFNBcJmgg9Ej+bHshA==}
+ cpu: [arm64]
+ os: [linux]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-X5Gzod9Q8sTtzjc+hIYKw6PMaB3tY0ADx68j2z+Zm8nJanmkzLZEDyZvlMexmE4nkb7IdOkHzYGm9NpynbMH2A==}
+ cpu: [x64]
+ os: [linux]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-REyhvrjGYfFTxGaaRDP31zANM744JI7pKXCgTqXHZBCe8mCZjxZCxmwt9pNL2lJsQ+qLr9zai488Bbj/PUuB6g==}
+ cpu: [x64]
+ os: [linux]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-J69HIENHpH1m8I85kTe111viqB5AGgKJdTCSKp4mGBxM95IL4nydzrYxVd91BvWjanQfVVq1C3voaF8YLwkT7A==}
+ cpu: [x64]
+ os: [win32]
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-BBw6SuEWuUD/lYXbLKEC0TTUzW7aLsO0X72pG38W1dOUyfU2KZYYfWGZkd+ermZTWWJ8cW+mevIwloUGk7FRaQ==}
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-jajhgumDSdnM/CUb3lZgae7D2pfioz9rczc6tLaRNP28IG3d2foQ0jP8INfCdMsOszCD0wKw4RHe0m5GKRxhTg==}
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-f4Ip10pkawlUBTunE++DZ6J/TrPtKalkxoTx7qQGBlhz3BcWRK7AbEGouZtcAmkLFVxq80hpH/1cBFOMF6FVfA==}
+ peerDependencies:
+ react: '>=16.8.0'
+ react-dom: '>=16.8.0'
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-giJ8cIQEdVxftpcX4m+9jWYCbIvpcdKRGVUc3ownxYEsJ30WUSP2+TuQ6aqqLXFAfwhY/SdBVLfopylh3BgMXA==}
+ peerDependencies:
+ react: '>=16.8.0'
+ react-dom: '>=16.8.0'
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-WOOmT38O3ax78oDIE75FnsDi8eUMBKOdnqiXU3NeArNoA/xQZv7yDUgV3e1SxFaCHS7IbWHIATXUfVgS8TIXBA==}
+ peerDependencies:
+ react: '>=16.8.0'
+ react-dom: '>=16.8.0'
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-JRXgqnzHbcaZU+LH3VK9KRNBHd7rhNnf34C3uUeFYFChRQhnmHWTSo7p/SDUhCpVh+hIHsS52xJz9JPwwy5gUw==}
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-nOONVvgEMw0lL7oPobmXAguvKVgVnV6MAwOfB5ZvjJrkLorFFePZ8ryhoftpRVrn3hGU3ZgQM2Zbb2eiaQPycg==}
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-d7FnevW0TGhoJovdLs/Mi8kmthj800QL5gSxDXlpoznymeT41CdRRgiQoXGM2f43r7WyoX0bvE2i9AxIogJoWg==}
+ peerDependencies:
+ react: '>=16.8.0'
+ react-dom: '>=16.8.0'
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-DrEvnOY97lBlMVUJkU997Ip70Z1hkggXVoiZZk7udTIpkrbhEfI4GrdOd/HOMCTtniepkGH8kXmk6Aqv99Q0uA==}
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-WTyFdBdqsmmqrMpW1k6Uhcze2z8tZvKc15BYu1FwmDgdQ1QeaAMgEsyp5qRLzKZ/000XafK4q8bUjdEQoudc8A==}
+ peerDependencies:
+ react: '>=18.0.0'
+ react-dom: '>=18.0.0'
+
+ '@remotion/[email protected]':
+ resolution: {integrity: sha512-hAUla1gXVe6afzoRACiDp2L58pgGOfS5pxAG9wPHLv2Br16K6K/ToGZYLwxwugUxmZdMNPGOCkR3pWK5x7O5HQ==}
+ peerDependencies:
+ zod: 4.3.6
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==}
@@ -1065,6 +1525,79 @@ packages:
cpu: [x64]
os: [win32]
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-NZ9AWtB1COLUX1tA9HQQvWpTy07NSFfKBU8A6ylWd5KH8AePZztpNgLLAVPTuNO4CZXYpwcoclf8jG/luJcQdQ==}
+ cpu: [arm64]
+ os: [darwin]
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-J2g6xk8ZS7uc024dNTGTHxoFzFovAZIRixUG7PiciLKTMP78svbSSWrmW6N8oAsAkzYfJWwQpVgWfFNRHvYxSw==}
+ cpu: [x64]
+ os: [darwin]
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-eQfcsaxhFrv5FmtaA7+O1F9/2yFDNIoPZzV/ZvqvFz5bBXVc4FAm/1fVpBg8Po/kX1h0chBc7Xkpry3cabFW8w==}
+ cpu: [arm64]
+ os: [linux]
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-DfQXKiyPIl7i1yECHy4eAkSmlUzzsSAbOjgMuKn7pudsWf483jg0UUYutNgXSlBjc/QSUp7906Cg8oty9OfwPA==}
+ cpu: [arm64]
+ os: [linux]
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-NdA+2X3lk2GGrMMnTGyYTzM3pn+zNjaqXqlgKmFBXvjfZqzSsKq3pdD1KHZCd5QHN+Fwvoszj0JFsquEVhE1og==}
+ cpu: [x64]
+ os: [linux]
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-rEy6MHKob02t/77YNgr6dREyJ0e0tv1X6Xsg8Z5E7rPXead06zefUbfazj4RELYySWnM38ovZyJAkPx/gOn3VA==}
+ cpu: [x64]
+ os: [linux]
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-YupOrz0daSG+YBbCIgpDgzfMM38YpChv+afZpaxx5Ml7xPeAZIIdgWmLHnQ2rts73N2M1NspAiBwV00Xx0N4Vg==}
+ cpu: [wasm32]
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-INj7aVXjBvlZ84kEhSK4kJ484ub0i+BzgnjDWOWM1K+eFYDZjLdAsQSS3fGGXwVc3qKbPIssFfnftATDMTEJHQ==}
+ cpu: [arm64]
+ os: [win32]
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-lXGvC+z67UMcw58In12h8zCa9IyYRmuptUBMItQJzu+M278aMuD1nETyGLL7e4+OZ2lvrnnBIcjXN1hfw2yRzw==}
+ cpu: [ia32]
+ os: [win32]
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-zeUxEc0ZaPpmaYlCeWcjSJUPuRRySiSHN23oJ2Xyw0jsQ01Qm4OScPdr0RhEOFuK/UE+ANyRtDo4zJsY52Hadw==}
+ cpu: [x64]
+ os: [win32]
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-/NrEcfo8Gx22hLGysanrV6gHMuqZSxToSci/3M4kzEQtF5cPjfOv5pqeLK/+B6cr56ul/OmE96cCdWcXeVnFjQ==}
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-Iax6UhrfZqJajA778c1d5DBFbSIqPOSrI34kpNIiNpWd8Jq7mFIa+Z60SQb5ZQDZuUxcCZikjz5BxinFjTkg7Q==}
+ engines: {node: '>=18.12.0'}
+ peerDependencies:
+ '@swc/helpers': '>=0.5.1'
+ peerDependenciesMeta:
+ '@swc/helpers':
+ optional: true
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-E2B0JhYFmVAwdDiG14+DW0Di4Ze4Jg10Pc4/lILUrd5DRCaklduz2OvJ5HYQ6G+hd+WTzqQb3QnDNfK4yvAFYw==}
+
+ '@rspack/[email protected]':
+ resolution: {integrity: sha512-eqqW5645VG3CzGzFgNg5HqNdHVXY+567PGjtDhhrM8t67caxmsSzRmT5qfoEIfBcGgFkH9vEg7kzXwmCYQdQDw==}
+ peerDependencies:
+ react-refresh: '>=0.10.0 <1.0.0'
+ webpack-hot-middleware: 2.x
+ peerDependenciesMeta:
+ webpack-hot-middleware:
+ optional: true
+
'@sindresorhus/[email protected]':
resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==}
engines: {node: '>=10'}
@@ -1101,6 +1634,9 @@ packages:
peerDependencies:
'@testing-library/dom': '>=7.21.4'
+ '@tybys/[email protected]':
+ resolution: {integrity: sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==}
+
resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==}
@@ -1134,6 +1670,18 @@ packages:
resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-d7/QsLRwF864A5mgIM/YrfiglHoYn7zgCcAoJgW404r+2DwnNr7EBbLnCWpmOMgH8y0te73L1AV6H1bmauaWFw==}
+
+ '@types/[email protected]':
+ resolution: {integrity: sha512-O5hkiFIcjjszPIYyUSyvScyvrBoV3NOEEZx/pMlsu44TKzWNkLVBBxnxJz42in5n3QIolYOcBYFCPZZ0h8SkwQ==}
+
+ '@types/[email protected]':
+ resolution: {integrity: sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==}
+
+ '@types/[email protected]':
+ resolution: {integrity: sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==}
+
resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==}
@@ -1143,6 +1691,9 @@ packages:
resolution: {integrity: sha512-L3LgimLHXtGkWikKnsPg0/VFx9OGZaC+eN1u4r+OB1XRqH3meBIAVC2zr1WdMH+RHmnRkqliQAOHNJ/E0j/e0Q==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
+
resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==}
@@ -1164,17 +1715,28 @@ packages:
resolution: {integrity: sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-P4t6saawp+b/dFrUr2cvkVsfvPguwsxtH6dNIYRllMsefqFzkZk5UIjzyDOv5g1dXIPdG4Sp1yCR4Z6RCUsG/Q==}
+ peerDependencies:
+ '@types/react': ^18.0.0
+
resolution: {integrity: sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==}
peerDependencies:
'@types/react': ^18.0.0
+ '@types/[email protected]':
+ resolution: {integrity: sha512-t4yC+vtgnkYjNSKlFx1jkAhH8LgTo2N/7Qvi83kdEaUtMDiwpbLAktKDaAMlRcJ5eSxZkH74eEGt1ky31d7kfQ==}
+
resolution: {integrity: sha512-vfEqpXTvwT91yhmwdfouStN2hSKwTvyRs8qpLfADyrq/kxDw0hZM7Wk9Ug1FELj8hIby+S/+kQCSRFF32nv2Qw==}
resolution: {integrity: sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-NRPn5w6h8dhcnmx3YIRQcqMywY/+nND/uOkJessedcrowO3C0AssHp3tMJpxKAwOhFOo0OV1y9VtsC5hbKKBAw==}
+
'@vitejs/[email protected]':
resolution: {integrity: sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA==}
engines: {node: ^14.18.0 || >=16.0.0}
@@ -1210,11 +1772,62 @@ packages:
'@vitest/[email protected]':
resolution: {integrity: sha512-x6BDOd7dyo3PFLY3I9/HJ25X/6OurhGXk2/B9gOZNPF7XDVjeBK4k01lQE5uvDpbuheErh91qYuE1E2OEjK3Rw==}
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-jyH7wtcHiKssDtFPRB+iQdxlDf96m0E39yb0k5uJVhFGleZFoNw1c4aeIcVUPPbXUVJ94wwnMOAqUHyzoEPVMA==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-ds5mXEqTJ6oxRoqjhWDU83OgzAYjwsCV8Lo/N+oRsNDmx/ZDpqalmrtgOMkHwxsG0iI//3BwWAErYRHtgn0dZw==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-4LtOzh58S/5lX4ITKxnAK2USuNEvpdVV9AlgGQb8rJDHaLeHciwG4zlGr0j/SNWlr7x3vO1lDEsuePvtcDNCkw==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-Lde1oNoIdzVzdkNEAWZ1dZ5orIbff80YPdHx20mrHwHrVNNTjNr8E3xz9BdpcGqRQbAEa+fkrCb+fRFTl/6sQw==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-3NQWGjKTASY1xV5m7Hr0iPeXD9+RDobLll3T9d2AO+g3my8xy5peVyjSag4I50mR1bBSN/Ct12lo+R9tJk0NZQ==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-RNJUIQH/J8iA/1NzlE4N7KtyZNHi3w7at7hDjvRNm5rcUXa00z1vRz3glZoULfJ5mpvYhLybmVcwcjGrC1pRrQ==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-AmomSIjP8ZbfGQhumkNvgC33AY7qtMCXnN6bL2u2Js4gVCg8fp735aEiMSBbDR7UQIj90n4wKAFUSEd0QN2Ukg==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-PTcKLUNvBqnY2U6E5bdOQcSM+oVP/PmrDY9NzowJjislEjwP/C4an2303MCVS2Mg9d3AJpIGdUFIQQWbPds0Sw==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-JLBl+KZ0R5qB7mCnud/yyX08jWFw5MsoalJ1pQ4EdFlgj9VdXKGuENGsiCIjegI1W7p91rUlcB/LB5yRJKNTcQ==}
+
+ '@webassemblyjs/[email protected]':
+ resolution: {integrity: sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw==}
+
'@xmldom/[email protected]':
resolution: {integrity: sha512-KRYzxepc14G/CEpEGc3Yn+JKaAeT63smlDr+vjB8jRfgTBBI9wRj/nkQEO+ucV8p8I9bfKLWp37uHgFrbntPvw==}
engines: {node: '>=10.0.0'}
deprecated: this version has critical issues, please update to the latest version
+ resolution: {integrity: sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==}
+
+ resolution: {integrity: sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==}
+
resolution: {integrity: sha512-a1wflyaL0tHtJSmLSOVybYhy22vRih4eduhhrkcjgrWGnRfrZtovJ2FRjxuTtkkj47O/baf0R86QU5OuYpz8fA==}
engines: {node: ^20.17.0 || >=22.9.0}
@@ -1230,6 +1843,17 @@ packages:
resolution: {integrity: sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==}
engines: {node: '>= 0.6'}
+ resolution: {integrity: sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ==}
+ engines: {node: '>=10.13.0'}
+ peerDependencies:
+ acorn: ^8.14.0
+
+ resolution: {integrity: sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==}
+ engines: {node: '>=0.4.0'}
+ hasBin: true
+
resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==}
engines: {node: '>= 14'}
@@ -1242,6 +1866,11 @@ packages:
ajv:
optional: true
+ resolution: {integrity: sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==}
+ peerDependencies:
+ ajv: ^8.8.2
+
resolution: {integrity: sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==}
@@ -1438,6 +2067,10 @@ packages:
resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==}
+ engines: {node: '>=6.0'}
+
resolution: {integrity: sha512-1R5Fho+jBq0DDydt+/vHWj5KJNJCKdARKOCwZUen84I5BreWoLqRLANH1U87eJy1tiASPtMnGqJJq0ZsLoRPOw==}
@@ -1467,10 +2100,20 @@ packages:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
+ resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==}
+
+ resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==}
+ engines: {node: '>=12.5.0'}
+
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
engines: {node: '>= 0.8'}
+ resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
+
resolution: {integrity: sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==}
engines: {node: '>= 6'}
@@ -1534,6 +2177,18 @@ packages:
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
engines: {node: '>= 8'}
+ resolution: {integrity: sha512-vv3J9tlOl04WjiMvHQI/9tmIrCxVrj6PFbHemBB1iihpeRbi/I4h033eoFIhwxBBqLhI0KYFS7yvynBFhIZfTw==}
+ engines: {node: '>= 18.12.0'}
+ peerDependencies:
+ '@rspack/core': 0.x || ^1.0.0 || ^2.0.0-0
+ webpack: ^5.27.0
+ peerDependenciesMeta:
+ '@rspack/core':
+ optional: true
+ webpack:
+ optional: true
+
resolution: {integrity: sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==}
@@ -1544,6 +2199,11 @@ packages:
resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==}
+ resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==}
+ engines: {node: '>=4'}
+ hasBin: true
+
resolution: {integrity: sha512-2z+rWdzbbSZv6/rhtvzvqeZQHrBaqgogqt85sqFNbabZOuFbCVFb8kPeEtZjiKkbrm395irpNKiYeFeLiQnFPg==}
engines: {node: '>=18'}
@@ -1595,6 +2255,10 @@ packages:
resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==}
+ engines: {node: '>=8'}
+
resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==}
engines: {node: '>= 0.4'}
@@ -1708,6 +2372,10 @@ packages:
resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==}
+ resolution: {integrity: sha512-L1l8TNvomm6UVW5B253AGxQagSQr+vGwhMlrrfRS2qmhx46AMpMVJKQYLvWYbysTMY8VoicOvzHzoHMbyzB+4A==}
+ engines: {node: '>=10.13.0'}
+
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
engines: {node: '>=0.12'}
@@ -1731,6 +2399,9 @@ packages:
resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==}
+ resolution: {integrity: sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==}
+
resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==}
engines: {node: '>= 0.4'}
@@ -1742,6 +2413,9 @@ packages:
resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==}
+ resolution: {integrity: sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==}
+
resolution: {integrity: sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==}
engines: {node: '>= 0.4'}
@@ -1758,6 +2432,11 @@ packages:
engines: {node: '>=18'}
hasBin: true
+ resolution: {integrity: sha512-sNR9MHpXSUV/XB4zmsFKN+QgVG82Cc7+/aaxJ8Adi8hyOac+EXptIp45QBPaVyX3N70664wRbTcLTOemCAnyqw==}
+ engines: {node: '>=18'}
+ hasBin: true
+
resolution: {integrity: sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==}
engines: {node: '>=18'}
@@ -1774,6 +2453,22 @@ packages:
resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
engines: {node: '>=10'}
+ resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==}
+ engines: {node: '>=8.0.0'}
+
+ resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==}
+ engines: {node: '>=4.0'}
+
+ resolution: {integrity: sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==}
+ engines: {node: '>=4.0'}
+
+ resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==}
+ engines: {node: '>=4.0'}
+
resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
@@ -1781,6 +2476,10 @@ packages:
resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}
engines: {node: '>= 0.6'}
+ resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}
+ engines: {node: '>=0.8.x'}
+
resolution: {integrity: sha512-kJezFj9YFAMLeORyi7aCLxLbD5/qWMQnoMVlVPyHIll7lgRJCc3JVln9Vgl9nwQi0YkMnhdGTMNn7CkRRAptMg==}
engines: {node: '>=18.0.0'}
@@ -1789,6 +2488,10 @@ packages:
resolution: {integrity: sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==}
engines: {node: '>=18.0.0'}
+ resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==}
+ engines: {node: '>=10'}
+
resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}
engines: {node: '>=6'}
@@ -1906,6 +2609,9 @@ packages:
resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==}
engines: {node: '>=10'}
+ resolution: {integrity: sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q==}
+
resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
@@ -1942,9 +2648,16 @@ packages:
resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==}
+ engines: {node: '>=10'}
+
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
+ resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==}
+
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting [email protected]
@@ -1999,6 +2712,9 @@ packages:
resolution: {integrity: sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-kig+rMn/QOVRvr7c86gQ8lWXq+Hkv6CbAH1hLu+RG338StTpE8Z0b44SDVaqVu7HGKf27frdmUYEs9hTUX/cLQ==}
+
resolution: {integrity: sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==}
@@ -2021,6 +2737,10 @@ packages:
resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==}
engines: {node: '>= 14'}
+ resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==}
+ engines: {node: '>=10.17.0'}
+
resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
engines: {node: '>=0.10.0'}
@@ -2029,6 +2749,12 @@ packages:
resolution: {integrity: sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==}
+ engines: {node: ^10 || ^12 || >= 14}
+ peerDependencies:
+ postcss: 8.5.18
+
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
@@ -2058,6 +2784,14 @@ packages:
resolution: {integrity: sha512-9VGk3HGanVE6JoZXHiCpnGy5X0jYDnN4EA4lntFPj+1vIWlFhIylq2CrrCOJH9EAhc5CYhq18F2Av2tgoAPsYQ==}
engines: {node: '>= 10'}
+ resolution: {integrity: sha512-m6UrgzFVUYawGBh1dUsWR5M2Clqic9RVXC/9f8ceNlv2IcO9j9J/z8UoCLPqtsPBFNzEpfR3xftohbfqDx8EQA==}
+
+ resolution: {integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==}
+ engines: {node: '>=8'}
+ hasBin: true
+
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
engines: {node: '>=8'}
@@ -2068,6 +2802,14 @@ packages:
resolution: {integrity: sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==}
+ resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==}
+ engines: {node: '>=8'}
+
+ resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==}
+ engines: {node: '>=8'}
+
resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==}
@@ -2095,6 +2837,10 @@ packages:
engines: {node: '>=10'}
hasBin: true
+ resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==}
+ engines: {node: '>= 10.13.0'}
+
resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==}
hasBin: true
@@ -2129,6 +2875,9 @@ packages:
resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==}
+ resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==}
+
resolution: {integrity: sha512-hOrZIVL5jyYFjzk7+y7n5JDzGlU8rfWDuYyHwGa2WA8/pcmMHezp2xsVwxrebD/Q9t8Nc5DboieySDpCp4WG4A==}
@@ -2164,6 +2913,10 @@ packages:
resolution: {integrity: sha512-MHp03UImeVhB7XZtjd0E4n6+3xr5Dq/9xI/5FptGk5FrbDR3zagPa2DS6U8ks/3HjbKWG9Q1M2ufOzxV2qLYSQ==}
+ resolution: {integrity: sha512-DFEqQ3ihfS9blba08cLfYf1NRAIEm+dDjic073DRDc3/JspI/8wYmtDsHwd3+4hwvdxSK7PGaElfTmm0awWJ4w==}
+ engines: {node: '>=6.11.5'}
+
resolution: {integrity: sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==}
@@ -2171,6 +2924,9 @@ packages:
resolution: {integrity: sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==}
deprecated: This package is deprecated. Use require('node:util').isDeepStrictEqual instead.
+ resolution: {integrity: sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==}
+
resolution: {integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==}
@@ -2228,10 +2984,20 @@ packages:
resolution: {integrity: sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==}
engines: {node: '>= 0.8'}
+ resolution: {integrity: sha512-oK3sMMYbucoF6LUX62L/2M9d+p9ve6KDQgL87kNfhsB0/XmTe9iRLUcgQgg9Gpgvi8Sb96zYfOUL6i17y0bdNg==}
+
+ resolution: {integrity: sha512-eivjfi7Ahr6eQTn44nvTnR60e4a1Fs1Via2kCR5lHo/kyNoiMWaXCNJ/GpSd0ilXas2JSOl9B5FTIhflXu0hlg==}
+ engines: {node: '>= 4.0.0'}
+
resolution: {integrity: sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==}
+
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
engines: {node: '>= 0.6'}
@@ -2253,6 +3019,10 @@ packages:
engines: {node: '>=4.0.0'}
hasBin: true
+ resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==}
engines: {node: '>=4'}
@@ -2318,6 +3088,9 @@ packages:
resolution: {integrity: sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==}
engines: {node: '>= 0.6'}
+ resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==}
+
resolution: {integrity: sha512-W5ZNO5KRPB5TkYmGVD9F6YqhsglXJzE6etpbmT+f6EQElhiX/UTG551cnsRGvLG3fyZEg9HwaDmNmj5nwJ4z9g==}
engines: {node: '>=10'}
@@ -2363,6 +3136,10 @@ packages:
resolution: {integrity: sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==}
engines: {node: '>=10'}
+ resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==}
+ engines: {node: '>=8'}
+
resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==}
@@ -2392,6 +3169,14 @@ packages:
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
+ resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==}
+ engines: {node: '>=6'}
+
+ resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==}
+ engines: {node: '>=12'}
+
resolution: {integrity: sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==}
engines: {node: '>=8'}
@@ -2445,6 +3230,9 @@ packages:
resolution: {integrity: sha512-eRWB5LBz7PpDu4PUlwT0PhnQfTQJlDDdPa35urV4Osrm0t0AqQFGn+UIkU3klZvwJ8KPO3VbBFsXquA6p6kqZw==}
engines: {node: '>=12', npm: '>=6'}
+ resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==}
+
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
@@ -2487,6 +3275,37 @@ packages:
resolution: {integrity: sha512-GdzJuUMc6ZSpxFJWVxtOH1bzYHym+TOnveqUjb+VJIbZWbZzyiRGFiKhbiielfpYbgMlhHVhsJ0FTazfuRFkMA==}
+ resolution: {integrity: sha512-k3kNe0aNFQDAZGbin48pL2VNidTF0w4/eASDsxlyspobzU3wZQLOGj7L9gfRe0Jo9/4uud09DsjFNH7winGv8Q==}
+ engines: {node: ^10 || ^12 || >= 14}
+ peerDependencies:
+ postcss: 8.5.18
+
+ resolution: {integrity: sha512-5kcJm/zk+GJDSfw+V/42fJ5fhjL5YbFDl8nVdXkJPLLW+Vf9mTD5Xe0wqIaDnLuL2U6cDNpTr+UQ+v2HWIBhzw==}
+ engines: {node: ^10 || ^12 || >= 14}
+ peerDependencies:
+ postcss: 8.5.18
+
+ resolution: {integrity: sha512-m9jZstCVaqGjTAuny8MdgE88scJnCiQSlSrOWcTQgM2t32UBe+MUmFSO5t7VMSfAf/FJKImAxBav8ooCHJXCJA==}
+ engines: {node: ^10 || ^12 || >= 14}
+ peerDependencies:
+ postcss: 8.5.18
+
+ resolution: {integrity: sha512-RDxHkAiEGI78gS2ofyvCsu7iycRv7oqw5xMWn9iMoR0N/7mf9D50ecQqUo5BZ9Zh2vH4bCUR/ktCqbB9m8vJjQ==}
+ engines: {node: ^10 || ^12 || >= 14}
+ peerDependencies:
+ postcss: 8.5.18
+
+ resolution: {integrity: sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==}
+ engines: {node: '>=4'}
+
+ resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==}
+
resolution: {integrity: sha512-xdB1oSLHbz1vRWgCDalrCqEFTWzFlhqFC5tIHLMOSUIjhm3XXQ1qrFy8S/ESr1JYRRXqM3c1QFiMZUJdUTqyMQ==}
engines: {node: ^10 || ^12 || >=14}
@@ -2587,6 +3406,10 @@ packages:
resolution: {integrity: sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-QgT5//D3jfjJb6Gsjxv0Slpj23ip+HtOpnNgnb2S5zU3CB26G/IDPGoy4RJB42wzFE46DRsstbW6tKHoKbhAxw==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-q4HvNl+mmDdkS0g+MqiBZNteQJCuimWoOyHMy4T/RQLAn9Z29+E91QXRaxOujeMl2HTzRSS0KFPd7lxX3PjV0Q==}
engines: {node: '>=14.0.0'}
@@ -2632,6 +3455,12 @@ packages:
resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-Li2u4cVxlbxWgxQPn5oBpUlmNKYFpLUmpE9OHMP7QurvOMfvVK1tcC7utxVEwYFZf18tXwqIPBwmuFvdzMu+YA==}
+ peerDependencies:
+ react: '>=16.8.0'
+ react-dom: '>=16.8.0'
+
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
engines: {node: '>=0.10.0'}
@@ -2723,6 +3552,10 @@ packages:
resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==}
+ resolution: {integrity: sha512-ZzWFVzFgyRHi/T2Ecxm37lL6J9+hZO0P9L7LCuLxAbC6XWxkvxcaQBCXhQxMGn/Tdt9nD7zIBk0ELwhMQ3UEDg==}
+ engines: {node: '>= 10.13.0'}
+
resolution: {integrity: sha512-l4KnYfEyqYJxDwlNVyRfO2E4NTHfMKAWdUuA8J0yve2Dz/E/PdBepY03RvyJpssIpRFwJoCD55wA+mEDs6ByWA==}
@@ -2737,6 +3570,11 @@ packages:
resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==}
hasBin: true
+ resolution: {integrity: sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==}
+ engines: {node: '>=10'}
+ hasBin: true
+
resolution: {integrity: sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==}
engines: {node: '>=10'}
@@ -2765,6 +3603,10 @@ packages:
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
+ resolution: {integrity: sha512-eX2IQ6nFohW4DbvHIOLRB3MHFpYqaqvXd3Tp5e/T/dSH83fxaNJQRvDMhASmkNTsNTVF2/OOopzRCt7xokgPfg==}
+ engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
+
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
engines: {node: '>=8'}
@@ -2801,6 +3643,9 @@ packages:
resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
+ resolution: {integrity: sha512-nAu1WFPQSMNr2Zn9PGSZK9AGn4t/y97lEm+MXTtUDwfP0ksAIX4nO+6ruD9Jwut4C49SB1Ws+fbXsm/yScWOHw==}
+
resolution: {integrity: sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==}
engines: {node: '>=10'}
@@ -2819,6 +3664,11 @@ packages:
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==}
+ engines: {node: '>= 8'}
+ deprecated: The work that was done in this beta branch won't be included in future versions
+
resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==}
engines: {node: '>= 10.x'}
@@ -2829,6 +3679,9 @@ packages:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
+ resolution: {integrity: sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==}
+
resolution: {integrity: sha512-jH9EhtKIjuXZ2cWxmXS8ZP80XyC3iasQxMDV8jzhNJpfDb7VbQLVW4Wvsxz9QZvzV+G4YoSfBUVKDOyxLzi/sg==}
engines: {node: '>= 6'}
@@ -2854,6 +3707,10 @@ packages:
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==}
engines: {node: '>=8'}
@@ -2865,6 +3722,12 @@ packages:
resolution: {integrity: sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==}
+ resolution: {integrity: sha512-1V4WqhhZZgjVAVJyt7TdDPZoPBPNHbekX4fWnCJL1yQukhCeZhJySUL+gL9y6sNdN95uEOS83Y55SqHcP7MzLA==}
+ engines: {node: '>= 18.12.0'}
+ peerDependencies:
+ webpack: ^5.27.0
+
resolution: {integrity: sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==}
@@ -2876,9 +3739,17 @@ packages:
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==}
+ engines: {node: '>=10'}
+
resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}
+ resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-OboTd8mmMhZDNPV+UjQcK9yKAatXu2aJ+r1w4im1Otd4M4fl2hwvdoXUxIYHFTHWK/3y3FarBP70v3vwmGlOxw==}
@@ -2897,6 +3768,54 @@ packages:
resolution: {integrity: sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==}
engines: {node: '>=6.0.0'}
+ resolution: {integrity: sha512-201R5j+sJpK8nFWwKVyNfZot8FaJbLZDq5evriVzbV1wDtSXDjRUDRfJzHpAaxFDMEhsZL1QkeqM61wgsS3KaQ==}
+ engines: {node: '>= 10.13.0'}
+ peerDependencies:
+ '@minify-html/node': '*'
+ '@swc/core': '*'
+ '@swc/css': '*'
+ '@swc/html': '*'
+ clean-css: '*'
+ cssnano: '*'
+ csso: '*'
+ esbuild: '*'
+ html-minifier-terser: '*'
+ lightningcss: '*'
+ postcss: '*'
+ uglify-js: '*'
+ webpack: ^5.1.0
+ peerDependenciesMeta:
+ '@minify-html/node':
+ optional: true
+ '@swc/core':
+ optional: true
+ '@swc/css':
+ optional: true
+ '@swc/html':
+ optional: true
+ clean-css:
+ optional: true
+ cssnano:
+ optional: true
+ csso:
+ optional: true
+ esbuild:
+ optional: true
+ html-minifier-terser:
+ optional: true
+ lightningcss:
+ optional: true
+ postcss:
+ optional: true
+ uglify-js:
+ optional: true
+
+ resolution: {integrity: sha512-bWnjSNscmuI+GJze6ZupnHP8G/cTcsJF+bXCeQknk2SHQsgbNJnLrqiH9jZ2W4STPVXH2mDKKRX3iwPhc9Cn/Q==}
+ engines: {node: '>=10'}
+ hasBin: true
+
resolution: {integrity: sha512-e2zZ96wSChazBsbENf/Pcm/4swHt2cEKQ92rhUjkL9GCKiTDJIaTBenjE/m9DXi0QBmTMDkFDdOomUy20A1tDQ==}
engines: {node: '>=20'}
@@ -2954,10 +3873,16 @@ packages:
resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
engines: {node: '>=0.6'}
+ resolution: {integrity: sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==}
+
resolution: {integrity: sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==}
engines: {node: '>=16'}
+ resolution: {integrity: sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==}
+
resolution: {integrity: sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==}
engines: {node: '>=18'}
@@ -2984,6 +3909,11 @@ packages:
resolution: {integrity: sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==}
engines: {node: '>= 18'}
+ resolution: {integrity: sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==}
+ engines: {node: '>=14.17'}
+ hasBin: true
+
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
engines: {node: '>=14.17'}
@@ -3124,13 +4054,34 @@ packages:
resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-6i/00NBjP4yGPs+caKSyRfpTF/8Torsu0MOW3mMzIbhgISFder8i7xbqgHlLMwJrdiN8ndBV3UA1/AfzPSr+jg==}
+ engines: {node: '>=10.13.0'}
+
resolution: {integrity: sha512-gsXecm82UQNlTBURJGuqOWy1Ww08S3kZUcr3aOJS02Pk0xLtkfeUAVC0u0xhgdonFme80edSJUIJyuvL/7250Q==}
+ resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==}
+
resolution: {integrity: sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==}
engines: {node: '>=12'}
+ resolution: {integrity: sha512-jyuiGJdtvY434z5bUZrjz67v76/ePNvFZTp9Mdz29IlH4+GPsgyGjiv0fKI+M7BdkU6ADjulUcKAd3tUK3WlEw==}
+ engines: {node: '>=10.13.0'}
+
+ resolution: {integrity: sha512-gX/dMkRQc7QOMzgTe6KsYFM7DxeIONQSui1s0n/0xht36HvrgbxtM1xBlgx596NbpHuQU8P7QpKwrZYwUX48nw==}
+ engines: {node: '>=10.13.0'}
+ hasBin: true
+ peerDependencies:
+ webpack-cli: '*'
+ peerDependenciesMeta:
+ webpack-cli:
+ optional: true
+
resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==}
engines: {node: '>=18'}
@@ -3144,6 +4095,9 @@ packages:
resolution: {integrity: sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==}
+
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
engines: {node: '>= 8'}
@@ -3176,6 +4130,18 @@ packages:
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
+ resolution: {integrity: sha512-It4dO0K5v//JtTXuPkfEOaI3uUN87iYPnqo/ZzqCoG3g8uhA66QUMs/SrM0YK7/NAu+r4LMh/9dq2A7k+rHs+w==}
+ engines: {node: '>=10.0.0'}
+ peerDependencies:
+ bufferutil: ^4.0.1
+ utf-8-validate: '>=5.0.2'
+ peerDependenciesMeta:
+ bufferutil:
+ optional: true
+ utf-8-validate:
+ optional: true
+
resolution: {integrity: sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==}
engines: {node: '>=10.0.0'}
@@ -3226,6 +4192,10 @@ packages:
resolution: {integrity: sha512-GZtjxm/J/4TSxuL3FNYjCmLktBTnIw/rVmKSIyKeYAZpmJB2ig9VauCC5xsa82GNKVKDAqpOn3KVzNt0zmrU0g==}
engines: {node: '>=12'}
+ resolution: {integrity: sha512-jIH9yLR9wqr0wOS0TpBvo/g/2UgZH5qePVbjgRliiF0BYvOZyaBknKsF+x9Iht0O6sqgnB93rCICdOZFecJuDw==}
+ engines: {node: '>=12'}
+
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
@@ -3238,6 +4208,9 @@ packages:
resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
+ resolution: {integrity: sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==}
+
snapshots:
'@adobe/[email protected]': {}
@@ -3586,159 +4559,253 @@ snapshots:
- supports-color
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ '@emnapi/wasi-threads': 1.2.3
+ tslib: 2.8.1
+ optional: true
+
+ '@emnapi/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
+ '@emnapi/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
'@esbuild/[email protected]':
optional: true
+ '@esbuild/[email protected]':
+ optional: true
+
'@esbuild/[email protected]':
optional: true
@@ -3776,6 +4843,92 @@ snapshots:
'@iarna/[email protected]': {}
+ optionalDependencies:
+ '@img/sharp-libvips-darwin-arm64': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-darwin-x64': 1.2.0
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-arm64': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-arm': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-ppc64': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-s390x': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-x64': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linuxmusl-arm64': 1.2.0
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linuxmusl-x64': 1.2.0
+ optional: true
+
+ dependencies:
+ '@emnapi/runtime': 1.11.3
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
'@isaacs/[email protected]':
dependencies:
minipass: 7.1.3
@@ -3792,6 +4945,11 @@ snapshots:
'@jridgewell/[email protected]': {}
+ '@jridgewell/[email protected]':
+ dependencies:
+ '@jridgewell/gen-mapping': 0.3.13
+ '@jridgewell/trace-mapping': 0.3.31
+
'@jridgewell/[email protected]': {}
'@jridgewell/[email protected]':
@@ -3865,6 +5023,18 @@ snapshots:
'@marijn/[email protected]': {}
+ dependencies:
+ mediabunny: 1.45.0
+
+ dependencies:
+ mediabunny: 1.45.0
+
+ dependencies:
+ mediabunny: 1.45.0
+
'@modelcontextprotocol/[email protected]([email protected])':
dependencies:
'@hono/node-server': 1.19.14([email protected])
@@ -3887,6 +5057,38 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ '@module-federation/[email protected]': {}
+
+ '@module-federation/[email protected]':
+ dependencies:
+ '@module-federation/error-codes': 0.22.0
+ '@module-federation/sdk': 0.22.0
+
+ '@module-federation/[email protected]':
+ dependencies:
+ '@module-federation/runtime': 0.22.0
+ '@module-federation/webpack-bundler-runtime': 0.22.0
+
+ '@module-federation/[email protected]':
+ dependencies:
+ '@module-federation/error-codes': 0.22.0
+ '@module-federation/runtime-core': 0.22.0
+ '@module-federation/sdk': 0.22.0
+
+ '@module-federation/[email protected]': {}
+
+ '@module-federation/[email protected]':
+ dependencies:
+ '@module-federation/runtime': 0.22.0
+ '@module-federation/sdk': 0.22.0
+
+ '@napi-rs/[email protected]':
+ dependencies:
+ '@emnapi/core': 1.11.3
+ '@emnapi/runtime': 1.11.3
+ '@tybys/wasm-util': 0.10.3
+ optional: true
+
'@noble/[email protected]': {}
'@noble/[email protected]': {}
@@ -3901,29 +5103,177 @@ snapshots:
asn1js: 3.0.10
tslib: 2.8.1
- '@peculiar/[email protected]':
+ '@peculiar/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+
+ '@peculiar/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+
+ '@peculiar/[email protected]':
+ dependencies:
+ '@peculiar/asn1-schema': 2.8.0
+ '@peculiar/json-schema': 1.1.12
+ '@peculiar/utils': 2.0.3
+ tslib: 2.8.1
+ webcrypto-core: 1.9.2
+
+ '@pinojs/[email protected]': {}
+
+ '@playwright/[email protected]':
+ dependencies:
+ playwright: 1.61.1
+
+ '@remix-run/[email protected]': {}
+
+ dependencies:
+ '@remotion/media-parser': 4.0.473
+ '@remotion/studio-shared': 4.0.473([email protected]([email protected]))([email protected])
+ '@remotion/timeline-utils': 4.0.473
+ '@rspack/core': 1.7.6(@swc/[email protected])
+ '@rspack/plugin-react-refresh': 1.6.1([email protected])
+ esbuild: 0.28.0
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ react-refresh: 0.18.0
+ transitivePeerDependencies:
+ - '@minify-html/node'
+ - '@swc/core'
+ - '@swc/css'
+ - '@swc/helpers'
+ - '@swc/html'
+ - bufferutil
+ - clean-css
+ - cssnano
+ - csso
+ - html-minifier-terser
+ - lightningcss
+ - postcss
+ - uglify-js
+ - utf-8-validate
+ - webpack-cli
+ - webpack-hot-middleware
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]':
+ optional: true
+
+ '@remotion/[email protected]': {}
+
+ '@remotion/[email protected]': {}
+
+ dependencies:
+ mediabunny: 1.45.0
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+
+ dependencies:
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+
+ dependencies:
+ '@remotion/licensing': 4.0.473
+ '@remotion/streaming': 4.0.473
+ execa: 5.1.1
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ source-map: 0.8.0-beta.0
+ ws: 8.20.1
+ optionalDependencies:
+ '@remotion/compositor-darwin-arm64': 4.0.473
+ '@remotion/compositor-darwin-x64': 4.0.473
+ '@remotion/compositor-linux-arm64-gnu': 4.0.473
+ '@remotion/compositor-linux-arm64-musl': 4.0.473
+ '@remotion/compositor-linux-x64-gnu': 4.0.473
+ '@remotion/compositor-linux-x64-musl': 4.0.473
+ '@remotion/compositor-win32-x64-msvc': 4.0.473
+ transitivePeerDependencies:
+ - bufferutil
+ - utf-8-validate
+
+ '@remotion/[email protected]': {}
+
dependencies:
- tslib: 2.8.1
+ transitivePeerDependencies:
+ - react
+ - react-dom
- '@peculiar/[email protected]':
dependencies:
- tslib: 2.8.1
+ '@jridgewell/trace-mapping': 0.3.31
+ '@remotion/media-utils': 4.0.473([email protected]([email protected]))([email protected])
+ '@remotion/renderer': 4.0.473([email protected]([email protected]))([email protected])
+ '@remotion/studio-shared': 4.0.473([email protected]([email protected]))([email protected])
+ '@remotion/timeline-utils': 4.0.473
+ '@remotion/web-renderer': 4.0.473([email protected]([email protected]))([email protected])
+ mediabunny: 1.45.0
+ memfs: 3.4.3
+ open: 8.4.2
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ semver: 7.5.3
+ zod: 4.3.6
+ transitivePeerDependencies:
+ - bufferutil
+ - utf-8-validate
- '@peculiar/[email protected]':
+ '@remotion/[email protected]':
dependencies:
- '@peculiar/asn1-schema': 2.8.0
- '@peculiar/json-schema': 1.1.12
- '@peculiar/utils': 2.0.3
- tslib: 2.8.1
- webcrypto-core: 1.9.2
-
- '@pinojs/[email protected]': {}
+ mediabunny: 1.45.0
- '@playwright/[email protected]':
dependencies:
- playwright: 1.61.1
+ '@mediabunny/aac-encoder': 1.45.0([email protected])
+ '@mediabunny/flac-encoder': 1.45.0([email protected])
+ '@mediabunny/mp3-encoder': 1.45.0([email protected])
+ '@remotion/licensing': 4.0.473
+ mediabunny: 1.45.0
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
- '@remix-run/[email protected]': {}
+ dependencies:
+ zod: 4.3.6
+ transitivePeerDependencies:
+ - react
+ - react-dom
'@rolldown/[email protected]': {}
@@ -4002,6 +5352,67 @@ snapshots:
'@rollup/[email protected]':
optional: true
+ '@rspack/[email protected]':
+ optional: true
+
+ '@rspack/[email protected]':
+ optional: true
+
+ '@rspack/[email protected]':
+ optional: true
+
+ '@rspack/[email protected]':
+ optional: true
+
+ '@rspack/[email protected]':
+ optional: true
+
+ '@rspack/[email protected]':
+ optional: true
+
+ '@rspack/[email protected]':
+ dependencies:
+ '@napi-rs/wasm-runtime': 1.0.7
+ optional: true
+
+ '@rspack/[email protected]':
+ optional: true
+
+ '@rspack/[email protected]':
+ optional: true
+
+ '@rspack/[email protected]':
+ optional: true
+
+ '@rspack/[email protected]':
+ optionalDependencies:
+ '@rspack/binding-darwin-arm64': 1.7.6
+ '@rspack/binding-darwin-x64': 1.7.6
+ '@rspack/binding-linux-arm64-gnu': 1.7.6
+ '@rspack/binding-linux-arm64-musl': 1.7.6
+ '@rspack/binding-linux-x64-gnu': 1.7.6
+ '@rspack/binding-linux-x64-musl': 1.7.6
+ '@rspack/binding-wasm32-wasi': 1.7.6
+ '@rspack/binding-win32-arm64-msvc': 1.7.6
+ '@rspack/binding-win32-ia32-msvc': 1.7.6
+ '@rspack/binding-win32-x64-msvc': 1.7.6
+
+ dependencies:
+ '@module-federation/runtime-tools': 0.22.0
+ '@rspack/binding': 1.7.6
+ '@rspack/lite-tapable': 1.1.0
+ optionalDependencies:
+ '@swc/helpers': 0.5.23
+
+ '@rspack/[email protected]': {}
+
+ dependencies:
+ error-stack-parser: 2.1.4
+ html-entities: 2.6.0
+ react-refresh: 0.18.0
+
'@sindresorhus/[email protected]': {}
@@ -4046,6 +5457,11 @@ snapshots:
dependencies:
'@testing-library/dom': 10.4.1
+ '@tybys/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@types/[email protected]': {}
@@ -4095,6 +5511,22 @@ snapshots:
'@types/[email protected]': {}
+ '@types/[email protected]':
+ dependencies:
+ '@types/dom-webcodecs': 0.1.13
+
+ '@types/[email protected]': {}
+
+ '@types/[email protected]':
+ dependencies:
+ '@types/eslint': 9.6.1
+ '@types/estree': 1.0.9
+
+ '@types/[email protected]':
+ dependencies:
+ '@types/estree': 1.0.9
+ '@types/json-schema': 7.0.15
+
'@types/[email protected]': {}
@@ -4103,6 +5535,8 @@ snapshots:
'@types/[email protected]': {}
+ '@types/[email protected]': {}
+
dependencies:
'@types/node': 22.20.0
@@ -4127,10 +5561,19 @@ snapshots:
'@types/[email protected]': {}
+ dependencies:
+ '@types/react': 18.3.18
+
dependencies:
'@types/react': 18.3.31
+ '@types/[email protected]':
+ dependencies:
+ '@types/prop-types': 15.7.15
+ csstype: 3.2.3
+
dependencies:
'@types/prop-types': 15.7.15
@@ -4140,7 +5583,11 @@ snapshots:
dependencies:
'@types/node': 22.20.0
+ '@types/[email protected]':
+ dependencies:
+ '@types/node': 22.20.0
+
dependencies:
'@babel/core': 7.29.7
'@babel/plugin-transform-react-jsx-self': 7.29.7(@babel/[email protected])
@@ -4148,7 +5595,7 @@ snapshots:
'@rolldown/pluginutils': 1.0.0-beta.27
'@types/babel__core': 7.20.5
react-refresh: 0.17.0
transitivePeerDependencies:
- supports-color
@@ -4160,21 +5607,21 @@ snapshots:
chai: 5.3.3
tinyrainbow: 2.0.0
dependencies:
'@vitest/spy': 3.2.7
estree-walker: 3.0.3
magic-string: 0.30.21
optionalDependencies:
dependencies:
'@vitest/spy': 3.2.7
estree-walker: 3.0.3
magic-string: 0.30.21
optionalDependencies:
'@vitest/[email protected]':
dependencies:
@@ -4202,8 +5649,88 @@ snapshots:
loupe: 3.2.1
tinyrainbow: 2.0.0
+ '@webassemblyjs/[email protected]':
+ dependencies:
+ '@webassemblyjs/helper-numbers': 1.13.2
+ '@webassemblyjs/helper-wasm-bytecode': 1.13.2
+
+ '@webassemblyjs/[email protected]': {}
+
+ '@webassemblyjs/[email protected]': {}
+
+ '@webassemblyjs/[email protected]': {}
+
+ '@webassemblyjs/[email protected]':
+ dependencies:
+ '@webassemblyjs/floating-point-hex-parser': 1.13.2
+ '@webassemblyjs/helper-api-error': 1.13.2
+ '@xtuc/long': 4.2.2
+
+ '@webassemblyjs/[email protected]': {}
+
+ '@webassemblyjs/[email protected]':
+ dependencies:
+ '@webassemblyjs/ast': 1.14.1
+ '@webassemblyjs/helper-buffer': 1.14.1
+ '@webassemblyjs/helper-wasm-bytecode': 1.13.2
+ '@webassemblyjs/wasm-gen': 1.14.1
+
+ '@webassemblyjs/[email protected]':
+ dependencies:
+ '@xtuc/ieee754': 1.2.0
+
+ '@webassemblyjs/[email protected]':
+ dependencies:
+ '@xtuc/long': 4.2.2
+
+ '@webassemblyjs/[email protected]': {}
+
+ '@webassemblyjs/[email protected]':
+ dependencies:
+ '@webassemblyjs/ast': 1.14.1
+ '@webassemblyjs/helper-buffer': 1.14.1
+ '@webassemblyjs/helper-wasm-bytecode': 1.13.2
+ '@webassemblyjs/helper-wasm-section': 1.14.1
+ '@webassemblyjs/wasm-gen': 1.14.1
+ '@webassemblyjs/wasm-opt': 1.14.1
+ '@webassemblyjs/wasm-parser': 1.14.1
+ '@webassemblyjs/wast-printer': 1.14.1
+
+ '@webassemblyjs/[email protected]':
+ dependencies:
+ '@webassemblyjs/ast': 1.14.1
+ '@webassemblyjs/helper-wasm-bytecode': 1.13.2
+ '@webassemblyjs/ieee754': 1.13.2
+ '@webassemblyjs/leb128': 1.13.2
+ '@webassemblyjs/utf8': 1.13.2
+
+ '@webassemblyjs/[email protected]':
+ dependencies:
+ '@webassemblyjs/ast': 1.14.1
+ '@webassemblyjs/helper-buffer': 1.14.1
+ '@webassemblyjs/wasm-gen': 1.14.1
+ '@webassemblyjs/wasm-parser': 1.14.1
+
+ '@webassemblyjs/[email protected]':
+ dependencies:
+ '@webassemblyjs/ast': 1.14.1
+ '@webassemblyjs/helper-api-error': 1.13.2
+ '@webassemblyjs/helper-wasm-bytecode': 1.13.2
+ '@webassemblyjs/ieee754': 1.13.2
+ '@webassemblyjs/leb128': 1.13.2
+ '@webassemblyjs/utf8': 1.13.2
+
+ '@webassemblyjs/[email protected]':
+ dependencies:
+ '@webassemblyjs/ast': 1.14.1
+ '@xtuc/long': 4.2.2
+
'@xmldom/[email protected]': {}
+ '@xtuc/[email protected]': {}
+
+ '@xtuc/[email protected]': {}
+
@@ -4215,12 +5742,23 @@ snapshots:
mime-types: 3.0.2
negotiator: 1.0.0
+ dependencies:
+ acorn: 8.18.0
+
+
optionalDependencies:
ajv: 8.20.0
+ dependencies:
+ ajv: 8.20.0
+ fast-deep-equal: 3.1.3
+
dependencies:
fast-deep-equal: 3.1.3
@@ -4493,6 +6031,8 @@ snapshots:
+
@@ -4517,10 +6057,22 @@ snapshots:
+ dependencies:
+ color-name: 1.1.4
+ simple-swizzle: 0.2.4
+
+ dependencies:
+ color-convert: 2.0.1
+ color-string: 1.9.1
+
dependencies:
delayed-stream: 1.0.0
+
@@ -4566,6 +6118,20 @@ snapshots:
shebang-command: 2.0.0
which: 2.0.2
+ dependencies:
+ icss-utils: 5.1.0([email protected])
+ postcss: 8.5.18
+ postcss-modules-extract-imports: 3.1.0([email protected])
+ postcss-modules-local-by-default: 4.2.0([email protected])
+ postcss-modules-scope: 3.2.1([email protected])
+ postcss-modules-values: 4.0.0([email protected])
+ postcss-value-parser: 4.2.0
+ semver: 7.8.5
+ optionalDependencies:
+ '@rspack/core': 1.7.6(@swc/[email protected])
+
dependencies:
boolbase: 1.0.0
@@ -4578,6 +6144,8 @@ snapshots:
+
dependencies:
'@asamuzakjp/css-color': 3.2.0
@@ -4617,6 +6185,8 @@ snapshots:
gopd: 1.2.0
optional: true
+
dependencies:
define-data-property: 1.1.4
@@ -4783,6 +6353,11 @@ snapshots:
dependencies:
once: 1.4.0
+ dependencies:
+ graceful-fs: 4.2.11
+ tapable: 2.3.3
+
@@ -4795,12 +6370,18 @@ snapshots:
+ dependencies:
+ stackframe: 1.3.4
+
+
dependencies:
es-errors: 1.3.0
@@ -4844,6 +6425,35 @@ snapshots:
'@esbuild/win32-ia32': 0.25.12
'@esbuild/win32-x64': 0.25.12
+ optionalDependencies:
+ '@esbuild/aix-ppc64': 0.28.0
+ '@esbuild/android-arm': 0.28.0
+ '@esbuild/android-arm64': 0.28.0
+ '@esbuild/android-x64': 0.28.0
+ '@esbuild/darwin-arm64': 0.28.0
+ '@esbuild/darwin-x64': 0.28.0
+ '@esbuild/freebsd-arm64': 0.28.0
+ '@esbuild/freebsd-x64': 0.28.0
+ '@esbuild/linux-arm': 0.28.0
+ '@esbuild/linux-arm64': 0.28.0
+ '@esbuild/linux-ia32': 0.28.0
+ '@esbuild/linux-loong64': 0.28.0
+ '@esbuild/linux-mips64el': 0.28.0
+ '@esbuild/linux-ppc64': 0.28.0
+ '@esbuild/linux-riscv64': 0.28.0
+ '@esbuild/linux-s390x': 0.28.0
+ '@esbuild/linux-x64': 0.28.0
+ '@esbuild/netbsd-arm64': 0.28.0
+ '@esbuild/netbsd-x64': 0.28.0
+ '@esbuild/openbsd-arm64': 0.28.0
+ '@esbuild/openbsd-x64': 0.28.0
+ '@esbuild/openharmony-arm64': 0.28.0
+ '@esbuild/sunos-x64': 0.28.0
+ '@esbuild/win32-arm64': 0.28.0
+ '@esbuild/win32-ia32': 0.28.0
+ '@esbuild/win32-x64': 0.28.0
+
optionalDependencies:
'@esbuild/aix-ppc64': 0.28.1
@@ -4880,18 +6490,45 @@ snapshots:
optional: true
+ dependencies:
+ esrecurse: 4.3.0
+ estraverse: 4.3.0
+
+ dependencies:
+ estraverse: 5.3.0
+
+
+
dependencies:
'@types/estree': 1.0.9
+
dependencies:
eventsource-parser: 3.1.0
+ dependencies:
+ cross-spawn: 7.0.6
+ get-stream: 6.0.1
+ human-signals: 2.1.0
+ is-stream: 2.0.1
+ merge-stream: 2.0.0
+ npm-run-path: 4.0.1
+ onetime: 5.1.2
+ signal-exit: 3.0.7
+ strip-final-newline: 2.0.0
+
@@ -5073,6 +6710,8 @@ snapshots:
jsonfile: 6.2.1
universalify: 2.0.1
+
@@ -5109,8 +6748,12 @@ snapshots:
dependencies:
pump: 3.0.4
+
+
dependencies:
fs.realpath: 1.0.0
@@ -5181,6 +6824,8 @@ snapshots:
dependencies:
whatwg-encoding: 3.1.1
+
dependencies:
domelementtype: 2.3.0
@@ -5217,6 +6862,8 @@ snapshots:
transitivePeerDependencies:
- supports-color
+
dependencies:
safer-buffer: 2.1.2
@@ -5225,6 +6872,10 @@ snapshots:
dependencies:
safer-buffer: 2.1.2
+ dependencies:
+ postcss: 8.5.18
+
@@ -5244,12 +6895,22 @@ snapshots:
+
+
+
+ dependencies:
+ is-docker: 2.2.1
+
@@ -5268,6 +6929,12 @@ snapshots:
filelist: 1.0.6
picocolors: 1.1.1
+ dependencies:
+ '@types/node': 22.20.0
+ merge-stream: 2.0.0
+ supports-color: 8.1.1
+
@@ -5312,6 +6979,8 @@ snapshots:
+
dependencies:
dequal: 2.0.3
@@ -5352,10 +7021,14 @@ snapshots:
base64-js: 0.0.8
unicode-trie: 2.0.0
+
+
@@ -5399,8 +7072,19 @@ snapshots:
+ dependencies:
+ '@types/dom-mediacapture-transform': 0.1.12
+ '@types/dom-webcodecs': 0.1.13
+
+ dependencies:
+ fs-monkey: 1.0.3
+
+
@@ -5415,6 +7099,8 @@ snapshots:
+
@@ -5461,6 +7147,8 @@ snapshots:
+
dependencies:
semver: 7.8.5
@@ -5515,6 +7203,10 @@ snapshots:
+ dependencies:
+ path-key: 3.1.1
+
dependencies:
boolbase: 1.0.0
@@ -5538,6 +7230,16 @@ snapshots:
dependencies:
wrappy: 1.0.2
+ dependencies:
+ mimic-fn: 2.1.0
+
+ dependencies:
+ define-lazy-prop: 2.0.0
+ is-docker: 2.2.1
+ is-wsl: 2.2.0
+
@@ -5589,6 +7291,8 @@ snapshots:
+
@@ -5642,6 +7346,34 @@ snapshots:
dependencies:
fflate: 0.8.3
+ dependencies:
+ postcss: 8.5.18
+
+ dependencies:
+ icss-utils: 5.1.0([email protected])
+ postcss: 8.5.18
+ postcss-selector-parser: 7.1.6
+ postcss-value-parser: 4.2.0
+
+ dependencies:
+ postcss: 8.5.18
+ postcss-selector-parser: 7.1.6
+
+ dependencies:
+ icss-utils: 5.1.0([email protected])
+ postcss: 8.5.18
+
+ dependencies:
+ cssesc: 3.0.0
+ util-deprecate: 1.0.2
+
+
dependencies:
nanoid: 3.3.18
@@ -5750,6 +7482,8 @@ snapshots:
+
dependencies:
'@remix-run/router': 1.23.3
@@ -5802,6 +7536,11 @@ snapshots:
indent-string: 4.0.0
strip-indent: 3.0.0
+ dependencies:
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+
@@ -5911,6 +7650,13 @@ snapshots:
dependencies:
loose-envify: 1.4.0
+ dependencies:
+ '@types/json-schema': 7.0.15
+ ajv: 8.20.0
+ ajv-formats: 3.0.1([email protected])
+ ajv-keywords: 5.1.0([email protected])
+
@@ -5920,6 +7666,10 @@ snapshots:
+ dependencies:
+ lru-cache: 6.0.0
+
@@ -5958,6 +7708,35 @@ snapshots:
+ dependencies:
+ color: 4.2.3
+ detect-libc: 2.1.2
+ semver: 7.8.5
+ optionalDependencies:
+ '@img/sharp-darwin-arm64': 0.34.3
+ '@img/sharp-darwin-x64': 0.34.3
+ '@img/sharp-libvips-darwin-arm64': 1.2.0
+ '@img/sharp-libvips-darwin-x64': 1.2.0
+ '@img/sharp-libvips-linux-arm': 1.2.0
+ '@img/sharp-libvips-linux-arm64': 1.2.0
+ '@img/sharp-libvips-linux-ppc64': 1.2.0
+ '@img/sharp-libvips-linux-s390x': 1.2.0
+ '@img/sharp-libvips-linux-x64': 1.2.0
+ '@img/sharp-libvips-linuxmusl-arm64': 1.2.0
+ '@img/sharp-libvips-linuxmusl-x64': 1.2.0
+ '@img/sharp-linux-arm': 0.34.3
+ '@img/sharp-linux-arm64': 0.34.3
+ '@img/sharp-linux-ppc64': 0.34.3
+ '@img/sharp-linux-s390x': 0.34.3
+ '@img/sharp-linux-x64': 0.34.3
+ '@img/sharp-linuxmusl-arm64': 0.34.3
+ '@img/sharp-linuxmusl-x64': 0.34.3
+ '@img/sharp-wasm32': 0.34.3
+ '@img/sharp-win32-arm64': 0.34.3
+ '@img/sharp-win32-ia32': 0.34.3
+ '@img/sharp-win32-x64': 0.34.3
+
dependencies:
shebang-regex: 3.0.0
@@ -6004,6 +7783,10 @@ snapshots:
once: 1.4.0
simple-concat: 1.0.1
+ dependencies:
+ is-arrayish: 0.3.4
+
dependencies:
semver: 7.8.5
@@ -6021,6 +7804,10 @@ snapshots:
+ dependencies:
+ whatwg-url: 7.1.0
+
@@ -6028,6 +7815,8 @@ snapshots:
+
@@ -6052,6 +7841,8 @@ snapshots:
dependencies:
ansi-regex: 5.0.1
+
dependencies:
min-indent: 1.0.1
@@ -6062,6 +7853,10 @@ snapshots:
dependencies:
js-tokens: 9.0.1
+ dependencies:
+
@@ -6074,8 +7869,14 @@ snapshots:
dependencies:
has-flag: 4.0.0
+ dependencies:
+ has-flag: 4.0.0
+
+
dependencies:
chownr: 1.1.4
@@ -6109,6 +7910,24 @@ snapshots:
mkdirp: 0.5.6
rimraf: 2.6.3
+ dependencies:
+ '@jridgewell/trace-mapping': 0.3.31
+ jest-worker: 27.5.1
+ schema-utils: 4.4.0
+ terser: 5.51.2
+ optionalDependencies:
+ esbuild: 0.28.0
+ postcss: 8.5.18
+
+ dependencies:
+ '@jridgewell/source-map': 0.3.11
+ acorn: 8.18.0
+ commander: 2.20.3
+ source-map-support: 0.5.21
+
dependencies:
real-require: 1.0.0
@@ -6152,10 +7971,16 @@ snapshots:
+
dependencies:
tldts: 6.1.86
+ dependencies:
+ punycode: 2.3.1
+
dependencies:
punycode: 2.3.1
@@ -6185,6 +8010,8 @@ snapshots:
media-typer: 1.1.0
mime-types: 3.0.2
+
@@ -6233,13 +8060,13 @@ snapshots:
dependencies:
cac: 6.7.14
debug: 4.4.3
es-module-lexer: 1.7.0
pathe: 2.0.3
transitivePeerDependencies:
- '@types/node'
- jiti
@@ -6254,13 +8081,13 @@ snapshots:
- tsx
- yaml
dependencies:
cac: 6.7.14
debug: 4.4.3
es-module-lexer: 1.7.0
pathe: 2.0.3
transitivePeerDependencies:
- '@types/node'
- jiti
@@ -6275,7 +8102,7 @@ snapshots:
- tsx
- yaml
dependencies:
esbuild: 0.25.12
fdir: 6.5.0([email protected])
@@ -6287,10 +8114,11 @@ snapshots:
'@types/node': 22.20.0
fsevents: 2.3.3
jiti: 2.7.0
+ terser: 5.51.2
tsx: 4.23.0
yaml: 2.9.0
dependencies:
esbuild: 0.25.12
fdir: 6.5.0([email protected])
@@ -6302,14 +8130,15 @@ snapshots:
'@types/node': 24.13.3
fsevents: 2.3.3
jiti: 2.7.0
+ terser: 5.51.2
tsx: 4.23.0
yaml: 2.9.0
dependencies:
'@types/chai': 5.2.3
'@vitest/expect': 3.2.7
'@vitest/pretty-format': 3.2.7
'@vitest/runner': 3.2.7
'@vitest/snapshot': 3.2.7
@@ -6327,8 +8156,8 @@ snapshots:
tinyglobby: 0.2.17
tinypool: 1.1.1
tinyrainbow: 2.0.0
why-is-node-running: 2.3.0
optionalDependencies:
'@types/debug': 4.1.13
@@ -6348,11 +8177,11 @@ snapshots:
- tsx
- yaml
dependencies:
'@types/chai': 5.2.3
'@vitest/expect': 3.2.7
'@vitest/pretty-format': 3.2.7
'@vitest/runner': 3.2.7
'@vitest/snapshot': 3.2.7
@@ -6370,8 +8199,8 @@ snapshots:
tinyglobby: 0.2.17
tinypool: 1.1.1
tinyrainbow: 2.0.0
why-is-node-running: 2.3.0
optionalDependencies:
'@types/debug': 4.1.13
@@ -6397,6 +8226,10 @@ snapshots:
dependencies:
xml-name-validator: 5.0.0
+ dependencies:
+ graceful-fs: 4.2.11
+
dependencies:
'@peculiar/asn1-schema': 2.8.0
@@ -6405,8 +8238,53 @@ snapshots:
asn1js: 3.0.10
tslib: 2.8.1
+
+
+ dependencies:
+ '@types/eslint-scope': 3.7.7
+ '@types/estree': 1.0.9
+ '@types/json-schema': 7.0.15
+ '@webassemblyjs/ast': 1.14.1
+ '@webassemblyjs/wasm-edit': 1.14.1
+ '@webassemblyjs/wasm-parser': 1.14.1
+ acorn: 8.18.0
+ acorn-import-phases: 1.0.4([email protected])
+ browserslist: 4.28.7
+ chrome-trace-event: 1.0.4
+ enhanced-resolve: 5.24.5
+ es-module-lexer: 2.3.2
+ eslint-scope: 5.1.1
+ events: 3.3.0
+ glob-to-regexp: 0.4.1
+ graceful-fs: 4.2.11
+ json-parse-even-better-errors: 2.3.1
+ loader-runner: 4.3.2
+ mime-types: 2.1.35
+ neo-async: 2.6.2
+ schema-utils: 4.4.0
+ tapable: 2.3.3
+ watchpack: 2.5.2
+ webpack-sources: 3.5.1
+ transitivePeerDependencies:
+ - '@minify-html/node'
+ - '@swc/core'
+ - '@swc/css'
+ - '@swc/html'
+ - clean-css
+ - cssnano
+ - csso
+ - esbuild
+ - html-minifier-terser
+ - lightningcss
+ - postcss
+ - uglify-js
+
dependencies:
iconv-lite: 0.6.3
@@ -6418,6 +8296,12 @@ snapshots:
tr46: 5.1.1
webidl-conversions: 7.0.0
+ dependencies:
+ lodash.sortby: 4.7.0
+ tr46: 1.0.1
+ webidl-conversions: 4.0.2
+
dependencies:
isexe: 2.0.0
@@ -6447,6 +8331,8 @@ snapshots:
+
@@ -6477,6 +8363,10 @@ snapshots:
y18n: 5.0.8
yargs-parser: 21.1.1
+ dependencies:
+ pend: 1.2.0
+
@@ -6484,3 +8374,5 @@ snapshots:
zod: 3.25.76
+
diff --git a/resources/stickman/visual-assets/catalog.json b/resources/stickman/visual-assets/catalog.json
new file mode 100644
index 00000000..ab104931
--- /dev/null
+++ b/resources/stickman/visual-assets/catalog.json
@@ -0,0 +1,266 @@
+{
+ "version": 1,
+ "templateId": "stickman-video",
+ "characters": [
+ {
+ "id": "stickman.character.default",
+ "revision": 1,
+ "name": { "zhCN": "默认角色", "en": "Default" },
+ "description": { "zhCN": "大圆头、极简五官和基础服装的通用火柴人", "en": "A universal stick figure with a large round head, minimal features, and plain clothing" },
+ "previewFile": "characters/default.png",
+ "referenceFiles": [{ "role": "identity-primary", "path": "characters/default.png" }],
+ "identity": {
+ "preserve": "oversized bald circular white head, two simple black dot eyes, broad curved black smile, no nose, plain unpatterned long-sleeve top, plain straight trousers, thin simplified limbs, no accessories",
+ "prohibit": "hair, eyewear, hats, scarves, patterned clothes, jackets, skirts, or bags"
+ },
+ "tags": ["neutral", "general"]
+ },
+ {
+ "id": "stickman.character.tech-guy",
+ "revision": 1,
+ "name": { "zhCN": "科技男", "en": "Tech Guy" },
+ "description": { "zhCN": "黑框眼镜、格子衬衫和深色长裤的科技从业者", "en": "A technology professional with black glasses, a checkered shirt, and dark trousers" },
+ "previewFile": "characters/tech-guy.png",
+ "referenceFiles": [{ "role": "identity-primary", "path": "characters/tech-guy.png" }],
+ "identity": {
+ "preserve": "oversized bald circular white head, two simple black dot eyes, broad curved black smile, no nose, thick rectangular black glasses, black checkered collared button-down shirt, dark straight trousers, thin simplified limbs",
+ "prohibit": "hair, hoodies, T-shirts, hats, skirts, dresses, or bags"
+ },
+ "tags": ["technology", "professional"]
+ },
+ {
+ "id": "stickman.character.long-hair",
+ "revision": 1,
+ "name": { "zhCN": "长发角色", "en": "Long Hair" },
+ "description": { "zhCN": "侧分波浪长发和简洁连衣裙的女性角色", "en": "A female character with side-parted wavy hair and a simple dress" },
+ "previewFile": "characters/long-hair.png",
+ "referenceFiles": [{ "role": "identity-primary", "path": "characters/long-hair.png" }],
+ "identity": {
+ "preserve": "oversized circular white head, shoulder-length wavy hair with a side part, simple black dot eyes with eyelashes, broad curved black smile, no nose, sleeveless plain fitted dress, high-heeled shoes, thin simplified limbs",
+ "prohibit": "eyewear, short hair, bangs, trousers, hoodies, jackets, school uniforms, or bags"
+ },
+ "tags": ["female", "formal"]
+ },
+ {
+ "id": "stickman.character.short-hair",
+ "revision": 1,
+ "name": { "zhCN": "短发角色", "en": "Short Hair" },
+ "description": { "zhCN": "侧分短发和长袖连衣裙的女性角色", "en": "A female character with side-swept short hair and a long-sleeve dress" },
+ "previewFile": "characters/short-hair.png",
+ "referenceFiles": [{ "role": "identity-primary", "path": "characters/short-hair.png" }],
+ "identity": {
+ "preserve": "oversized circular white head, chin-length bob haircut with a side-swept fringe, two simple black dot eyes, broad curved black smile, no nose, plain long-sleeve knee-length dress, plain low shoes, thin simplified limbs",
+ "prohibit": "eyewear, blunt bangs, long hair, trousers, hoodies, jackets, school uniforms, or bags"
+ },
+ "tags": ["female", "general"]
+ },
+ {
+ "id": "stickman.character.student",
+ "revision": 1,
+ "name": { "zhCN": "学生角色", "en": "Student" },
+ "description": { "zhCN": "齐刘海短发和水手领校服的女学生", "en": "A female student with a blunt bob and sailor-collar school uniform" },
+ "previewFile": "characters/student.png",
+ "referenceFiles": [{ "role": "identity-primary", "path": "characters/student.png" }],
+ "identity": {
+ "preserve": "female student with an oversized circular white head, chin-length straight bob haircut and blunt straight bangs, two simple black dot eyes, broad curved black smile, no nose, no eyewear, short-sleeve sailor-collar school uniform, tied neckerchief, pleated knee-length skirt, bare thin simplified legs, plain low shoes",
+ "prohibit": "eyeglasses, hoodies, jackets, coats, trousers, jeans, sneakers, backpacks, hats, or a different school uniform"
+ },
+ "tags": ["female", "student"]
+ },
+ {
+ "id": "stickman.character.manager",
+ "revision": 1,
+ "name": { "zhCN": "经理", "en": "Manager" },
+ "description": { "zhCN": "侧分短发、西装和领带的男性经理", "en": "A male manager with neat side-parted hair, a suit, and a tie" },
+ "previewFile": "characters/manager.png",
+ "referenceFiles": [{ "role": "identity-primary", "path": "characters/manager.png" }],
+ "identity": {
+ "preserve": "male manager with an oversized circular white head, short neatly side-parted hair, two simple black dot eyes, broad curved black smile, no nose, two-button suit jacket with lapels and patch pockets, white dress shirt, dark necktie, straight suit trousers, thin simplified limbs",
+ "prohibit": "eyewear, long hair, hoodies, T-shirts, dresses, skirts, shorts, or bags"
+ },
+ "tags": ["male", "business"]
+ },
+ {
+ "id": "stickman.character.hiphop",
+ "revision": 1,
+ "name": { "zhCN": "潮流角色", "en": "Street Style" },
+ "description": { "zhCN": "帽子、宽松上衣和潮流配饰的年轻角色", "en": "A young character with a cap, loose top, and street-style accessories" },
+ "previewFile": "characters/hiphop.png",
+ "referenceFiles": [{ "role": "identity-primary", "path": "characters/hiphop.png" }],
+ "identity": {
+ "preserve": "young stick-figure character with an oversized circular white head, casual cap, loose streetwear top, relaxed trousers, simple shoes, and a compact youthful silhouette matching the reference",
+ "prohibit": "business suits, school uniforms, dresses, formal shoes, removing the cap, or replacing the streetwear silhouette"
+ },
+ "tags": ["young", "streetwear"]
+ },
+ {
+ "id": "stickman.character.elder",
+ "revision": 1,
+ "name": { "zhCN": "长者", "en": "Elder" },
+ "description": { "zhCN": "具有长者面部与服装特征的火柴人角色", "en": "A stick-figure elder with distinctive mature facial and clothing features" },
+ "previewFile": "characters/elder.png",
+ "referenceFiles": [{ "role": "identity-primary", "path": "characters/elder.png" }],
+ "identity": {
+ "preserve": "elderly stick-figure character with an oversized circular white head, mature facial details, hairstyle, clothing silhouette, footwear, and accessories exactly matching the reference",
+ "prohibit": "youthful redesign, school uniforms, streetwear, changing gender presentation, or removing signature age and clothing features"
+ },
+ "tags": ["elder", "general"]
+ },
+ {
+ "id": "stickman.character.chef",
+ "revision": 1,
+ "name": { "zhCN": "厨师", "en": "Chef" },
+ "description": { "zhCN": "厨师帽和厨师制服的职业角色", "en": "A professional character wearing a chef hat and chef uniform" },
+ "previewFile": "characters/chef.png",
+ "referenceFiles": [{ "role": "identity-primary", "path": "characters/chef.png" }],
+ "identity": {
+ "preserve": "stick-figure chef with an oversized circular white head, chef hat, double-breasted chef jacket, work trousers, simple shoes, and all uniform details matching the reference",
+ "prohibit": "removing the chef hat, casual clothes, business suits, school uniforms, aprons or accessories not present in the reference"
+ },
+ "tags": ["profession", "food"]
+ },
+ {
+ "id": "stickman.character.fitness",
+ "revision": 1,
+ "name": { "zhCN": "健身角色", "en": "Fitness" },
+ "description": { "zhCN": "运动服装和健身气质的活力角色", "en": "An energetic character with athletic clothing and a fitness-oriented silhouette" },
+ "previewFile": "characters/fitness.png",
+ "referenceFiles": [{ "role": "identity-primary", "path": "characters/fitness.png" }],
+ "identity": {
+ "preserve": "athletic stick-figure character with an oversized circular white head, hairstyle, fitted sports top, athletic bottoms, training shoes, and body proportions matching the reference",
+ "prohibit": "business suits, dresses, school uniforms, formal shoes, changing the hairstyle, or adding unrelated sports equipment"
+ },
+ "tags": ["sport", "active"]
+ }
+ ],
+ "styles": [
+ {
+ "id": "stickman.style.minimal-ink",
+ "revision": 1,
+ "name": { "zhCN": "极简黑白线稿", "en": "Minimal black-and-white line art" },
+ "description": { "zhCN": "纯白背景、清晰墨线和克制灰阶,突出单一动作", "en": "Pure white backgrounds, crisp ink lines, restrained grayscale, and one clear action" },
+ "recommended": false,
+ "previewFile": null,
+ "referenceFiles": [],
+ "rendering": {
+ "medium": "minimal hand-drawn black ink line art, never photography or a rendered painting",
+ "surface": "clean pure white background without paper grain, canvas texture, gradients, or atmospheric haze",
+ "linework": "consistent bold black outer contours with a few thinner internal lines; simple, confident, slightly organic hand-drawn strokes",
+ "shading": "almost no shading; at most a small amount of flat light gray used to separate overlapping forms",
+ "palette": "strict monochrome black, white, and light gray only; translate every color mentioned by the scene into grayscale value or white highlight",
+ "sceneDensity": "keep only the protagonist, the action-critical object, and at most two environment cues; simplify forests, rooms, crowds, and textures into sparse readable symbols",
+ "composition": "one full-frame 16:9 narrative moment with generous breathing room, a strong silhouette, and no panels or diagram layout",
+ "characterRendering": "render the selected protagonist with the same simple line weight and flat white fills while preserving every identity anchor"
+ },
+ "semanticRenderingRules": {
+ "color": "Preserve the meaning of color through grayscale contrast, white highlights, or a light gray halo; never output chromatic color.",
+ "light": "Represent light with untouched white space, sparse rays, and one restrained gray shadow, not cinematic glow or volumetric lighting.",
+ "complexEnvironment": "Reduce nonessential environmental detail while retaining the objects and spatial relationship required by the semantic anchor."
+ },
+ "forbiddenDirections": ["photography", "photorealism", "3D", "oil painting", "watercolor", "colored cartoon", "anime rendering", "vector infographic", "dense realistic environment", "split panel"],
+ "styleAttributes": {
+ "medium": { "zhCN": "黑色手绘墨线", "en": "Hand-drawn black ink" },
+ "palette": { "zhCN": "纯黑、白、浅灰", "en": "Black, white, light gray" },
+ "sceneDensity": { "zhCN": "低,保留必要物体", "en": "Low, essential objects only" },
+ "swatch": { "background": "#ffffff", "foreground": "#171717", "accent": "#b8b8b8", "texture": "none" }
+ },
+ "tags": ["minimal", "monochrome", "ink"]
+ },
+ {
+ "id": "stickman.style.paper-pencil",
+ "revision": 1,
+ "name": { "zhCN": "纸面铅笔手绘", "en": "Pencil sketch on paper" },
+ "description": { "zhCN": "浅灰纸面、粗黑轮廓和石墨排线的叙事铅笔画", "en": "Narrative pencil drawings with light paper, bold outlines, and graphite hatching" },
+ "recommended": true,
+ "previewFile": null,
+ "referenceFiles": [],
+ "rendering": {
+ "medium": "a paused frame from a hand-drawn graphite pencil stick-figure animation, never a photograph, digital painting, or clean vector illustration",
+ "surface": "light gray to warm off-white paper with subtle natural paper grain, faint edge graphite haze, and a restrained vignette",
+ "linework": "bold dark hand-drawn outer contours, naturally imperfect pencil strokes, thinner construction details, and consistent line character across the whole frame",
+ "shading": "restrained graphite hatching and soft gray pencil smudging that add volume without becoming realistic",
+ "palette": "black, paper white, and graphite gray only; no automatic orange, yellow, or other colored accents",
+ "sceneDensity": "a concrete but simplified everyday scene; retain semantic props and spatial relationships while omitting decorative realistic detail",
+ "composition": "one full-frame 16:9 narrative or explanatory moment with a clear foreground, subject relationship, and visible state; never a generic decoration or information graphic",
+ "characterRendering": "preserve the selected protagonist exactly while translating surfaces into paper white, graphite gray fill, and black pencil contours"
+ },
+ "semanticRenderingRules": {
+ "color": "Translate color meaning into paper brightness, graphite density, edge contrast, or a soft pencil halo while remaining strictly monochrome.",
+ "light": "Use clean paper highlights, sparse pencil rays, and soft graphite shadows instead of photographic beams or colored glow.",
+ "complexEnvironment": "Summarize complex settings with a few hand-drawn depth cues and only the objects needed to understand the narration."
+ },
+ "forbiddenDirections": ["blackboard", "chalk texture", "photography", "photorealism", "3D", "oil painting", "watercolor wash", "colored cartoon", "business flat illustration", "clean vector icon", "PPT infographic", "split panel"],
+ "styleAttributes": {
+ "medium": { "zhCN": "纸面石墨铅笔", "en": "Graphite pencil on paper" },
+ "palette": { "zhCN": "米白、黑、石墨灰", "en": "Off-white, black, graphite gray" },
+ "sceneDensity": { "zhCN": "中低,具体但简化", "en": "Medium-low, concrete but simplified" },
+ "swatch": { "background": "#f3f1eb", "foreground": "#222222", "accent": "#8b8b87", "texture": "paper" }
+ },
+ "tags": ["recommended", "pencil", "paper", "monochrome"]
+ },
+ {
+ "id": "stickman.style.comic-storyboard",
+ "revision": 1,
+ "name": { "zhCN": "漫画分镜线稿", "en": "Comic storyboard line art" },
+ "description": { "zhCN": "强轮廓、网点阴影和动作线构成的单幅漫画镜头", "en": "A single comic frame with strong contours, screentone shadows, and action lines" },
+ "recommended": false,
+ "previewFile": null,
+ "referenceFiles": [],
+ "rendering": {
+ "medium": "black-and-white inked comic storyboard art rendered as one finished frame, not a rough thumbnail sheet",
+ "surface": "clean white comic paper with no photographic texture and no colored wash",
+ "linework": "expressive black ink contours with controlled line-weight variation, confident gesture lines, and sparse action accents",
+ "shading": "restrained grayscale screentone and compact black shadow shapes; avoid realistic soft lighting",
+ "palette": "strict black, white, and neutral gray screentone only",
+ "sceneDensity": "moderate detail around the focal action; secondary environment lines must stay subordinate and uncluttered",
+ "composition": "one full-frame 16:9 cinematic comic shot with a readable focal point, dynamic camera angle when justified, and no panel borders or multiple frames",
+ "characterRendering": "preserve the selected protagonist's exact face, hair, clothes, accessories, and proportions in the same inked comic language"
+ },
+ "semanticRenderingRules": {
+ "color": "Translate color into screentone density, black shadow mass, or white highlight without introducing chromatic color.",
+ "light": "Use high-contrast ink shapes, sparse rays, and screentone falloff instead of photorealistic illumination.",
+ "complexEnvironment": "Organize complex scenes around one focal action and reduce background elements to controlled comic depth cues."
+ },
+ "forbiddenDirections": ["multi-panel page", "character sheet", "manga page layout", "photography", "photorealism", "3D", "colored comic", "anime cel color", "PPT infographic", "interface", "watermark"],
+ "styleAttributes": {
+ "medium": { "zhCN": "黑白漫画墨线", "en": "Black-and-white comic ink" },
+ "palette": { "zhCN": "黑、白、灰色网点", "en": "Black, white, gray screentone" },
+ "sceneDensity": { "zhCN": "中等,聚焦动作", "en": "Medium, action-focused" },
+ "swatch": { "background": "#ffffff", "foreground": "#101010", "accent": "#777777", "texture": "screentone" }
+ },
+ "tags": ["comic", "ink", "dynamic"]
+ },
+ {
+ "id": "stickman.style.whiteboard-marker",
+ "revision": 1,
+ "name": { "zhCN": "白板讲解线稿", "en": "Whiteboard explainer line art" },
+ "description": { "zhCN": "白板底面、清晰马克笔轮廓和极少强调色的讲解画面", "en": "Explainer scenes with a whiteboard surface, clear marker contours, and minimal accents" },
+ "recommended": false,
+ "previewFile": null,
+ "referenceFiles": [],
+ "rendering": {
+ "medium": "hand-drawn whiteboard marker illustration, clearly made with physical black markers rather than vector paths",
+ "surface": "plain soft-white whiteboard surface with only a faint dry-erase trace and no paper grain, room background, frame, glare, or photographed board edges",
+ "linework": "strong rounded black marker contours, simple internal strokes, consistent marker width, and occasional natural dry-marker variation",
+ "shading": "no modeled shading; only tiny neutral gray marker accents when needed for separation",
+ "palette": "black and soft white with one restrained cool teal accent allowed only on the single most important prop; the protagonist remains monochrome",
+ "sceneDensity": "very low; show the protagonist, the action-critical prop, and only the minimum explanatory environment cues",
+ "composition": "one full-frame 16:9 illustrated scene, not a photographed presentation board, flowchart, mind map, or collection of icons",
+ "characterRendering": "preserve every identity feature of the selected protagonist using the same black marker outline and white fill"
+ },
+ "semanticRenderingRules": {
+ "color": "Ignore source colors except when the single allowed teal accent materially identifies the key prop; otherwise use outline shape and spacing.",
+ "light": "Represent light as two or three simple marker rays or open white space, never gradients, glow, or realistic shadows.",
+ "complexEnvironment": "Convert complex environments into two or three iconic line cues without turning the scene into a diagram."
+ },
+ "forbiddenDirections": ["photographed whiteboard", "room interior", "whiteboard frame", "flowchart", "mind map", "icon grid", "vector infographic", "photography", "photorealism", "3D", "colored cartoon", "split panel"],
+ "styleAttributes": {
+ "medium": { "zhCN": "白板马克笔", "en": "Whiteboard marker" },
+ "palette": { "zhCN": "黑、柔白、少量青色", "en": "Black, soft white, minimal teal" },
+ "sceneDensity": { "zhCN": "低,解释型构图", "en": "Low, explainer composition" },
+ "swatch": { "background": "#fbfcfc", "foreground": "#16191b", "accent": "#159a9c", "texture": "marker" }
+ },
+ "tags": ["whiteboard", "marker", "explainer"]
+ }
+ ]
+}