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.

Merge develop into optimize-functions

Leggett1c40599ddc76
diff --cc apps/daemon/src/api/server.ts
index cd3b94c6,fb6b5e0c..8e8913c0
--- a/apps/daemon/src/api/server.ts
+++ b/apps/daemon/src/api/server.ts
@@@ -43,12 -41,12 +43,16 @@@ import { createCreatorCommandDispatche
import type { CreatorExecutor } from '../creator/executor.js';
import { createKrillinExecutor } from '../creator/krillin/adapter.js';
import { createKrillinDependencyLoader } from '../creator/krillin/dependency-loader.js';
-import { readKrillinRuntimeManifest, resolveInside, verifyKrillinRuntimeManifest } from '../creator/krillin/manifest.js';
+import { readKrillinRuntimeManifest, resolveInside } from '../creator/krillin/manifest.js';
+import {
+ hasKrillinRuntimeVerificationWorker,
+ startKrillinRuntimeVerification
+} from '../creator/krillin/runtime-verifier.js';
import { createKrillinTtsService } from '../creator/krillin/tts-service.js';
+ import {
+ createKrillinCodexLlmGateway,
+ KRILLIN_LLM_ROUTE_PREFIX
+ } from '../creator/krillin/codex-llm-gateway.js';
import { createDownloadExecutor } from '../creator/download/executor.js';
import { resolveYtDlpRuntime } from '../creator/yt-dlp/runtime.js';
import {
@@@ -747,8 -722,10 +774,12 @@@ export async function buildServer(input
dependencyLoader: krillinDependencyLoader,
configStore: creatorServicesConfigStore,
getYtDlpRuntime,
+ verificationCachePath: krillinVerificationCachePath,
- ensureRuntimeReady: () => ensureKrillinRuntimeReady()
++ ensureRuntimeReady: () => ensureKrillinRuntimeReady(),
+ getCodexLlmConfig() {
+ const baseUrl = resolveListeningOrigin(server.server.address());
+ return baseUrl === undefined ? undefined : krillinCodexLlmGateway.config(baseUrl);
+ }
}));
}
if (
diff --cc apps/daemon/src/creator/krillin/adapter.ts
index 5bdf1e94,f706ba84..d0de8eff
--- a/apps/daemon/src/creator/krillin/adapter.ts
+++ b/apps/daemon/src/creator/krillin/adapter.ts
@@@ -34,8 -34,7 +34,9 @@@ export function createKrillinExecutor(i
dependencyLoader: KrillinDependencyLoader;
configStore: Pick<CreatorServicesConfigStore, 'read'>;
getYtDlpRuntime?(): YtDlpRuntime | undefined;
+ verificationCachePath?: string;
+ ensureRuntimeReady?(): Promise<void>;
+ getCodexLlmConfig?(): { baseUrl: string; apiKey: string; model: string } | undefined;
}): CreatorExecutor {
return {
id: 'krillinai',
diff --cc apps/daemon/src/creator/stickman/delivery-executor.ts
index d39f9d19,18e6ec23..2f724716
--- a/apps/daemon/src/creator/stickman/delivery-executor.ts
+++ b/apps/daemon/src/creator/stickman/delivery-executor.ts
@@@ -12,7 -13,8 +13,7 @@@ import
writeFile
} from 'node:fs/promises';
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
- import type { CreatorArtifact } from '@opencreator/protocol';
-import sharp from 'sharp';
+ import { stickmanCanvasForRatio, type CreatorArtifact } from '@opencreator/protocol';
import type { CreatorExecutor, CreatorExecutorOutput } from '../executor.js';
import { CreatorExecutorError } from '../executor.js';
import { validateMediaFile } from '../validators/media.js';
@@@ -24,11 -27,11 +26,12 @@@ import
stickmanTimelineSchema,
stickmanVisualValidationSchema
} from './contracts.js';
+import { loadSharp } from './sharp-loader.js';
+ import { renderStickmanPublishCopy } from './publish-copy.js';
const deliveryFiles = [
- { kind: 'clean_video', name: 'stickman-video.mp4', mime: 'video/mp4' },
- { kind: 'narration_subtitle', name: 'narration.srt', mime: 'application/x-subrip' }
+ { kind: 'clean_video', name: 'short.mp4', mime: 'video/mp4' },
+ { kind: 'narration_subtitle', name: 'subtitles.srt', mime: 'application/x-subrip' }
] as const;
type VideoValidator = typeof validateMediaFile;
@@@ -120,8 -143,92 +143,92 @@@ export function createStickmanDeliveryE
}
});
}
+ if (cleanVideoMedia === undefined) {
+ throw new CreatorExecutorError('creator_delivery_video_invalid', 'Clean video media was not validated');
+ }
+ const cleanVideoArtifact = requireSingleArtifact(stage.inputArtifacts, 'clean_video');
+ const thumbnailPath = join(deliveryRoot, 'thumbnail.png');
+ const thumbnailGenerator = input.createThumbnail
+ ?? (input.ffmpegPath === undefined ? undefined : renderThumbnailWithFfmpeg);
+ if (thumbnailGenerator === undefined) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_thumbnail_failed',
+ 'FFmpeg is required to generate the delivery thumbnail'
+ );
+ }
+ await thumbnailGenerator({
+ path: join(deliveryRoot, 'short.mp4'),
+ duration: cleanVideoMedia.duration,
+ targetPath: thumbnailPath,
+ width: canvas.width,
+ height: canvas.height,
+ ...(input.ffmpegPath === undefined ? {} : { ffmpegPath: input.ffmpegPath })
+ });
+ const thumbnailInfo = await stat(thumbnailPath);
- const thumbnailMetadata = await sharp(thumbnailPath).metadata();
++ const thumbnailMetadata = await (await loadSharp())(thumbnailPath).metadata();
+ if (thumbnailMetadata.width !== canvas.width || thumbnailMetadata.height !== canvas.height) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_thumbnail_failed',
+ `Thumbnail must be ${canvas.width}x${canvas.height} media`
+ );
+ }
+ const thumbnailSha256 = await sha256File(thumbnailPath);
+ manifestFiles.push({
+ name: 'thumbnail.png',
+ relativePath: 'delivery/thumbnail.png',
+ sha256: thumbnailSha256,
+ bytes: thumbnailInfo.size,
+ mime: 'image/png',
+ sourceArtifactId: cleanVideoArtifact.id
+ });
+ outputs.push({
+ kind: 'thumbnail',
+ status: 'completed',
+ path: thumbnailPath,
+ sourceArtifactIds: [cleanVideoArtifact.id],
+ metadata: {
+ fileName: 'thumbnail.png',
+ mimeType: 'image/png',
+ bytes: thumbnailInfo.size,
+ delivery: true,
+ ratio: timeline.ratio,
+ width: canvas.width,
+ height: canvas.height
+ }
+ });
+ const publishCopyPath = join(deliveryRoot, 'publish-copy.md');
+ await writeFile(publishCopyPath, renderStickmanPublishCopy({
+ title: script.title,
+ language: script.language,
+ durationSeconds: cleanVideoMedia.duration,
+ ratio: timeline.ratio,
+ narration: script.segments.map(segment => segment.narration)
+ }), 'utf8');
+ const publishCopyInfo = await stat(publishCopyPath);
+ const publishCopySha256 = await sha256File(publishCopyPath);
+ manifestFiles.push({
+ name: 'publish-copy.md',
+ relativePath: 'delivery/publish-copy.md',
+ sha256: publishCopySha256,
+ bytes: publishCopyInfo.size,
+ mime: 'text/markdown',
+ sourceArtifactId: scriptArtifact.id
+ });
+ outputs.push({
+ kind: 'publish_copy',
+ status: 'completed',
+ path: publishCopyPath,
+ sourceArtifactIds: [scriptArtifact.id],
+ metadata: {
+ fileName: 'publish-copy.md',
+ mimeType: 'text/markdown',
+ bytes: publishCopyInfo.size,
+ delivery: true,
+ ratio: timeline.ratio
+ }
+ });
const actualFiles = await readdir(deliveryRoot);
- const expectedFiles = deliveryFiles.map(file => file.name).sort();
+ const expectedFiles = ['short.mp4', 'subtitles.srt', 'thumbnail.png', 'publish-copy.md'].sort();
if (JSON.stringify([...actualFiles].sort()) !== JSON.stringify(expectedFiles)) {
throw new CreatorExecutorError(
'creator_delivery_file_set_mismatch',
@@@ -225,7 -343,66 +343,66 @@@ async function validateDeliveryFile
return undefined;
}
+ async function assertArtifactHash(artifact: CreatorArtifact, path: string): Promise<string> {
+ const actualSha256 = await sha256File(path);
+ if (artifact.sha256 === null || artifact.sha256.toLowerCase() !== actualSha256) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_hash_mismatch',
+ `Artifact hash mismatch: ${artifact.kind}`
+ );
+ }
+ return actualSha256;
+ }
+
+ function readProvider(artifacts: CreatorArtifact[], kind: string): string {
+ const providers = artifacts
+ .filter(artifact => artifact.kind === kind && artifact.status === 'completed')
+ .map(artifact => artifact.metadata.provider)
+ .filter((provider): provider is string => typeof provider === 'string' && provider.trim().length > 0);
+ return providers[0] ?? 'unknown';
+ }
+
+ function readVideoProvider(artifact: CreatorArtifact): string {
+ const provider = artifact.metadata.provider;
+ if (typeof provider === 'string' && provider.trim().length > 0) return provider;
+ const renderEngine = artifact.metadata.renderEngine;
+ return typeof renderEngine === 'string' && renderEngine.trim().length > 0
+ ? renderEngine
+ : 'unknown';
+ }
+
+ async function renderThumbnailWithFfmpeg(input: {
+ path: string;
+ duration: number;
+ targetPath: string;
+ width: number;
+ height: number;
+ ffmpegPath?: string;
+ }): Promise<void> {
+ if (input.ffmpegPath === undefined) {
+ throw new CreatorExecutorError(
+ 'creator_delivery_thumbnail_failed',
+ 'FFmpeg is required to generate the delivery thumbnail'
+ );
+ }
+ const sourcePath = `${input.targetPath}.source.png`;
+ const timestamp = Math.max(0, Math.min(input.duration / 2, Math.max(0, input.duration - 0.1)));
+ try {
+ await execFileAsync(input.ffmpegPath, [
+ '-y', '-ss', timestamp.toFixed(3), '-i', input.path,
+ '-frames:v', '1', '-f', 'image2', sourcePath
+ ]);
- await sharp(sourcePath)
++ await (await loadSharp())(sourcePath)
+ .resize(input.width, input.height, { fit: 'cover', position: 'centre' })
+ .png()
+ .toFile(input.targetPath);
+ } finally {
+ await rm(sourcePath, { force: true });
+ }
+ }
+
async function collectBlockingChecks(input: {
+ jobRoot: string;
artifacts: CreatorArtifact[];
sampledVideos: Set<string>;
}): Promise<string[]> {
diff --cc apps/daemon/src/creator/stickman/image-executor.ts
index 21a6bb22,ff11fa6b..1d32a728
--- a/apps/daemon/src/creator/stickman/image-executor.ts
+++ b/apps/daemon/src/creator/stickman/image-executor.ts
@@@ -1,9 -1,16 +1,16 @@@
- import type { ImageGenerationProvider, ImageGenerationQuality } from '@opencreator/protocol';
+ import {
+ readStickmanRatio,
+ stickmanCanvasForRatio,
+ stickmanImageSizeForRatio,
+ type ImageGenerationProvider,
+ type ImageGenerationQuality,
+ type StickmanCanvas
+ } from '@opencreator/protocol';
import { execFile } from 'node:child_process';
import { createHash } from 'node:crypto';
- import { copyFile, readFile } from 'node:fs/promises';
+ import { copyFile, readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
-import sharp from 'sharp';
+import type { Metadata, Stats } from 'sharp';
import type { CreatorServicesConfigStore } from '../../creator-services/config-store.js';
import {
generateImageContents,
@@@ -319,9 -351,8 +352,9 @@@ export function createStickmanImageExec
}
const extension = image.mime === 'image/jpeg' ? 'jpg' : image.mime === 'image/webp' ? 'webp' : 'png';
const candidatePath = join(stage.workdir, `${scopeKey}-candidate-${candidateAttempt}.${extension}`);
+ const sharp = await loadSharp();
await sharp(image.content)
- .resize(1280, 720, { fit: 'cover', position: 'centre' })
+ .resize(canvas.width, canvas.height, { fit: 'cover', position: 'centre' })
.toFile(candidatePath);
let candidateQuality: StickmanImageCandidateQuality;
try {
@@@ -410,12 -442,12 +444,13 @@@ type StickmanImageCandidateQuality =
async function inspectStickmanImageCandidate(
path: string,
- tesseractPath?: string
+ tesseractPath?: string,
+ expectedCanvas: StickmanCanvas = stickmanCanvasForRatio('16:9')
): Promise<StickmanImageCandidateQuality> {
- let metadata: Awaited<ReturnType<typeof sharp.prototype.metadata>>;
- let stats: Awaited<ReturnType<typeof sharp.prototype.stats>>;
+ let metadata: Metadata;
+ let stats: Stats;
try {
+ const sharp = await loadSharp();
[metadata, stats] = await Promise.all([
sharp(path).metadata(),
sharp(path).greyscale().stats()
diff --cc apps/daemon/src/creator/stickman/media-validation-executor.ts
index 70a8ffee,cb153f32..5dda725a
--- a/apps/daemon/src/creator/stickman/media-validation-executor.ts
+++ b/apps/daemon/src/creator/stickman/media-validation-executor.ts
@@@ -3,7 -3,11 +3,10 @@@ import { execFile } from 'node:child_pr
import { createReadStream } from 'node:fs';
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
- import type { CreatorArtifact } from '@opencreator/protocol';
-import sharp from 'sharp';
+ import {
+ stickmanCanvasForRatio,
+ type CreatorArtifact
+ } from '@opencreator/protocol';
import type { CreatorExecutor } from '../executor.js';
import { CreatorExecutorError } from '../executor.js';
import { validateMediaFile } from '../validators/media.js';
diff --cc apps/daemon/src/creator/stickman/validation-executor.ts
index 9243fb2a,cf3d4ba7..40a7c6f2
--- a/apps/daemon/src/creator/stickman/validation-executor.ts
+++ b/apps/daemon/src/creator/stickman/validation-executor.ts
@@@ -2,6 -2,8 +2,7 @@@ 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 { readStickmanRatio, stickmanCanvasForRatio } from '@opencreator/protocol';
import type { CreatorExecutor } from '../executor.js';
import { CreatorExecutorError } from '../executor.js';
import { stickmanShotSpecSchema, stickmanVisualValidationSchema } from './contracts.js';
diff --cc apps/web/src/features/settings/OpenCreatorSettingsView.tsx
index fe08a41a,50510081..f0a9351c
--- a/apps/web/src/features/settings/OpenCreatorSettingsView.tsx
+++ b/apps/web/src/features/settings/OpenCreatorSettingsView.tsx
@@@ -1,9 -1,8 +1,9 @@@
- import { useEffect, useRef, useState, type CSSProperties } from 'react';
+ import { lazy, Suspense, useEffect, useRef, useState, type CSSProperties } from 'react';
-import { Check, Moon, Sun } from 'lucide-react';
+import { Check, FolderOpen, Moon, Save, Sun } from 'lucide-react';
import type {
CodexProfileListResponse,
- CodexStatusResponse
+ CodexStatusResponse,
+ OpenCreatorStorageSettings
} from '@opencreator/protocol';
import { useConfirmDialog } from '../../components/dialogs/ConfirmDialogProvider.js';
import type { ColorMode } from '../../styles/color-mode.js';
@@@ -33,8 -30,11 +31,12 @@@ import
import type { RuntimeDependenciesController } from '../../app/use-runtime-dependencies.js';
import { RuntimeComponentsSettingsView } from './RuntimeComponentsSettingsView.js';
import './settings-management.css';
+import type { OpenCreatorSettingsService } from '../../services/opencreator-settings-service.js';
- import { useLocalizedCopy } from '../../i18n/useLocalizedCopy.js';
+
+ const CreatorServicesSettingsView = lazy(async () => {
+ const module = await import('./CreatorServicesSettingsView.js');
+ return { default: module.CreatorServicesSettingsView };
+ });
export type RuntimeStatus = {
connected: boolean;