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.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
Refresh yt-dlp to the latest nightly before packaging
Leggetted7ca667c1c6
diff --git a/apps/desktop/scripts/creator-runtime-releases.mjs b/apps/desktop/scripts/creator-runtime-releases.mjsindex 7bee43e8..676250f8 100644--- a/apps/desktop/scripts/creator-runtime-releases.mjs+++ b/apps/desktop/scripts/creator-runtime-releases.mjs@@ -51,7 +51,6 @@ function creatorRuntimeRelease(input) {const mediaVersion = input.mediaVersion ?? '6.0';const pythonRelease = '20260825';const pythonVersion = '3.13.15';- const ytDlpVersion = '2026.08.29.232711';const nodeVersion = '22.23.2';const nodeTarget = input.mediaTarget.replace('win32-', 'win-');const nodeExtension = suffix === '.exe' ? 'zip' : 'tar.gz';@@ -75,12 +74,6 @@ function creatorRuntimeRelease(input) {verify: ['-version'],expected: mediaVersionPattern('ffprobe', mediaVersion)},- ytDlp: {- version: ytDlpVersion,- fileName: 'yt-dlp',- url: `https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/download/${ytDlpVersion}/yt-dlp`,- sha256: 'e8bc4155d3af4fa4fa8efbb5146790f6e9da48266d103eea859de8a44ba194ad'- },pythonRuntime: {version: pythonVersion,fileName: 'python-runtime.tar.gz',@@ -102,6 +95,58 @@ function creatorRuntimeRelease(input) {};}+const ytDlpRepository = 'yt-dlp/yt-dlp-nightly-builds';++export function resolveYtDlpRelease({ readText, offline = false, cached }) {+ if (offline) {+ const asset = ytDlpAsset(cached?.version, cached?.sha256);+ if (cached?.path !== asset.fileName || cached?.source !== asset.url) {+ throw new Error('The offline yt-dlp cache has no valid release metadata');+ }+ return asset;+ }++ const release = JSON.parse(readText(+ `https://api.github.com/repos/${ytDlpRepository}/releases/latest`+ ));+ if (release.draft !== false || release.prerelease !== false) {+ throw new Error('The latest yt-dlp release is not a published nightly build');+ }+ const url = ytDlpDownloadUrl(release.tag_name);+ const download = release.assets?.find(candidate => candidate.name === 'yt-dlp');+ if (download?.browser_download_url !== url) {+ throw new Error('The latest yt-dlp release is missing its official download');+ }+ let sha256;+ if (download.digest != null) {+ sha256 = /^sha256:([a-f0-9]{64})$/i.exec(download.digest)?.[1];+ } else {+ const checksums = readText(url.replace(/\/yt-dlp$/, '/SHA2-256SUMS'));+ sha256 = /^([a-f0-9]{64})\s+\*?yt-dlp\r?$/im.exec(checksums)?.[1];+ }+ return ytDlpAsset(release.tag_name, sha256);+}++function ytDlpAsset(version, sha256) {+ const url = ytDlpDownloadUrl(version);+ if (!/^[a-f0-9]{64}$/i.test(sha256 ?? '')) {+ throw new Error('The yt-dlp release SHA-256 is missing or invalid');+ }+ return {+ version,+ fileName: 'yt-dlp',+ url,+ sha256: sha256.toLowerCase()+ };+}++function ytDlpDownloadUrl(version) {+ if (!/^\d{4}\.\d{2}\.\d{2}\.\d{6}$/.test(version ?? '')) {+ throw new Error('The yt-dlp release version is missing or invalid');+ }+ return `https://github.com/${ytDlpRepository}/releases/download/${version}/yt-dlp`;+}+function mediaVersionPattern(tool, version) {const escapedVersion = version.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');return new RegExp(`^${tool} version ${escapedVersion}(?:[\\s-]|$)`, 'm');diff --git a/apps/desktop/scripts/install-creator-runtime-dependencies.mjs b/apps/desktop/scripts/install-creator-runtime-dependencies.mjsindex abaf8a36..2a422cd0 100644--- a/apps/desktop/scripts/install-creator-runtime-dependencies.mjs+++ b/apps/desktop/scripts/install-creator-runtime-dependencies.mjs@@ -8,6 +8,7 @@ import {openSync,mkdtempSync,mkdirSync,+ readFileSync,readSync,renameSync,rmSync,@@ -17,7 +18,7 @@ import {import { tmpdir } from 'node:os';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';-import { creatorRuntimeReleases } from './creator-runtime-releases.mjs';+import { creatorRuntimeReleases, resolveYtDlpRelease } from './creator-runtime-releases.mjs';import { verifyRuntimeExecutable } from './runtime-executable-check.mjs';const scriptDir = dirname(fileURLToPath(import.meta.url));@@ -43,6 +44,13 @@ if (release === undefined) {);}+release.ytDlp = resolveYtDlpRelease({+ readText: readReleaseText,+ offline,+ cached: offline ? readCachedYtDlpRelease() : undefined+});+console.log(`[creator-runtime] ${offline ? 'Using offline cached' : 'Resolved latest nightly'} yt-dlp ${release.ytDlp.version}`);+mkdirSync(outputRoot, { recursive: true });const installed = {};for (const [name, asset] of Object.entries(release)) {@@ -69,6 +77,31 @@ writeFileSync(join(outputRoot, 'versions.json'), `${JSON.stringify({}, null, 2)}\n`);console.log(JSON.stringify({ ok: true, outputRoot, dependencies: installed }));+function readCachedYtDlpRelease() {+ const path = join(outputRoot, 'versions.json');+ if (!existsSync(path)) return undefined;+ const versions = JSON.parse(readFileSync(path, 'utf8'));+ return versions?.version === 1 && versions.platform === platform && versions.arch === arch+ ? versions.dependencies?.ytDlp+ : undefined;+}++function readReleaseText(url) {+ const args = [+ '--fail', '--silent', '--show-error', '--location',+ '--retry', '3', '--connect-timeout', '20', '--max-time', '60',+ '--header', 'Cache-Control: no-cache'+ ];+ if (proxy) args.push('--proxy', proxy);+ args.push(url);+ return execFileSync('curl', args, {+ cwd: rootDir,+ encoding: 'utf8',+ stdio: ['ignore', 'pipe', 'inherit'],+ maxBuffer: 4 * 1024 * 1024+ });+}+function installAsset(name, asset, path) {if (existsSync(path) && statSync(path).isFile() && hashFile(path) === asset.sha256) {if (asset.executable) chmodExecutable(path);diff --git a/apps/desktop/scripts/prepare-creator-runtime.mjs b/apps/desktop/scripts/prepare-creator-runtime.mjsindex 2013021d..9f31238c 100644--- a/apps/desktop/scripts/prepare-creator-runtime.mjs+++ b/apps/desktop/scripts/prepare-creator-runtime.mjs@@ -103,6 +103,7 @@ const buildRecord = {integrationPatchSha256: hashFiles([join(rootDir, 'scripts', 'build-krillinai.mjs'),join(scriptDir, 'install-creator-runtime-dependencies.mjs'),+ join(scriptDir, 'creator-runtime-releases.mjs'),join(scriptDir, 'prepare-creator-runtime.mjs'),join(scriptDir, 'prepare-creator-node.mjs'),join(rootDir, 'apps', 'daemon', 'src', 'creator', 'krillin', 'adapter.ts'),@@ -341,7 +342,7 @@ function ensureExternalDependencies() {[configuredYtDlpPath, join(vendorRoot, 'cacert.pem')],[process.env.OPENCREATOR_YT_DLP_NODE_PATH, join(vendorRoot, targetPlatform === 'win32' ? 'node-runtime.zip' : 'node-runtime.tar.gz')]];- if (required.every(([configured, vendored]) => configured || existsSync(vendored))) return;+ if (configuredYtDlpPath && required.every(([configured, vendored]) => configured || existsSync(vendored))) return;execFileSync(process.execPath, [join(scriptDir, 'install-creator-runtime-dependencies.mjs')], {cwd: rootDir,env: {diff --git a/apps/desktop/test/creator-runtime-updates.test.mjs b/apps/desktop/test/creator-runtime-updates.test.mjsnew file mode 100644index 00000000..640a229b--- /dev/null+++ b/apps/desktop/test/creator-runtime-updates.test.mjs@@ -0,0 +1,196 @@+import { createHash } from 'node:crypto';+import { mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { resolveYtDlpRelease } from '../scripts/creator-runtime-releases.mjs';++const repository = 'https://github.com/yt-dlp/yt-dlp-nightly-builds';+const latestUrl = 'https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest';+const oldVersion = '2026.08.29.232711';+const newVersion = '2026.10.10.233141';+const digest = content => createHash('sha256').update(content).digest('hex');+const contents = version => `yt-dlp ${version}`;+function asset(version = newVersion) {+ return { version, fileName: 'yt-dlp', url: `${repository}/releases/download/${version}/yt-dlp`, sha256: digest(contents(version)) };+}+function metadata(version = newVersion) {+ const release = asset(version);+ return { tag_name: version, draft: false, prerelease: false, assets: [{ name: 'yt-dlp', browser_download_url: release.url, digest: `sha256:${release.sha256}` }] };+}+function cache(version = oldVersion) {+ const release = asset(version);+ return { version, path: release.fileName, source: release.url, sha256: release.sha256 };+}++describe('yt-dlp release discovery', () => {+ it('resolves a fresh version on every call even when an older release is cached', () => {+ const readText = vi.fn().mockReturnValueOnce(JSON.stringify(metadata())).mockReturnValueOnce(JSON.stringify(metadata('2026.10.11.233141')));+ expect(resolveYtDlpRelease({ readText, cached: cache() })).toEqual(asset());+ expect(resolveYtDlpRelease({ readText, cached: cache(newVersion) })).toEqual(asset('2026.10.11.233141'));+ expect(readText.mock.calls).toEqual([[latestUrl], [latestUrl]]);+ });++ it('uses the checksum list from the same release when the asset digest is absent', () => {+ const release = metadata(); release.assets[0].digest = null;+ const readText = vi.fn().mockReturnValueOnce(JSON.stringify(release))+ .mockReturnValueOnce(`${'a'.repeat(64)} yt-dlp.exe\r\n${asset().sha256} yt-dlp\r\n`);+ expect(resolveYtDlpRelease({ readText })).toEqual(asset());+ expect(readText).toHaveBeenLastCalledWith(`${repository}/releases/download/${newVersion}/SHA2-256SUMS`);+ });++ it.each([+ release => { release.tag_name = 'latest'; },+ release => { release.draft = true; },+ release => { release.prerelease = true; },+ release => { release.assets = []; },+ release => { release.assets[0].browser_download_url = 'https://example.test/yt-dlp'; },+ release => { release.assets[0].digest = 'sha256:invalid'; }+ ])('rejects invalid release metadata instead of falling back to the cache (%#)', mutate => {+ const release = metadata(); mutate(release);+ expect(() => resolveYtDlpRelease({ readText: () => JSON.stringify(release), cached: cache() })).toThrow(/yt-dlp/);+ });++ it('fails an online update when discovery is unavailable', () => {+ const readText = vi.fn(() => { throw new Error('network unavailable'); });+ expect(() => resolveYtDlpRelease({ readText, cached: cache() })).toThrow('network unavailable');+ });++ it('rejects a checksum list without the portable yt-dlp asset', () => {+ const release = metadata(); delete release.assets[0].digest;+ const readText = vi.fn().mockReturnValueOnce(JSON.stringify(release)).mockReturnValueOnce(`${'a'.repeat(64)} yt-dlp.exe\n`);+ expect(() => resolveYtDlpRelease({ readText })).toThrow(/SHA-256/);+ });++ it('uses validated cached release metadata only in explicit offline mode', () => {+ const readText = vi.fn();+ expect(resolveYtDlpRelease({ readText, offline: true, cached: cache() })).toEqual(asset(oldVersion));+ expect(readText).not.toHaveBeenCalled();+ });++ it.each([undefined, { ...cache(), source: `${repository}/releases/latest/download/yt-dlp` }, { ...cache(), sha256: '' }])('rejects an incomplete offline release cache (%#)', cached => {+ const readText = vi.fn();+ expect(() => resolveYtDlpRelease({ readText, offline: true, cached })).toThrow(/yt-dlp/);+ expect(readText).not.toHaveBeenCalled();+ });+});++describe('Creator Runtime dependency updates', () => {+ let root;+ let run;+ let fixed;+ let platform;+ let currentVersion;+ let downloadContents;+ let discoveryError;++ beforeEach(async () => {+ vi.resetModules();+ root = mkdtempSync(join(tmpdir(), 'creator-runtime-updates-'));+ platform = process.platform === 'linux' ? 'darwin' : 'linux';+ currentVersion = newVersion;+ downloadContents = undefined;+ discoveryError = undefined;+ fixed = Object.fromEntries([+ ['ffmpeg', 'ffmpeg'], ['ffprobe', 'ffprobe'], ['pythonRuntime', 'python-runtime.tar.gz'],+ ['nodeRuntime', 'node-runtime.tar.gz'], ['certificateBundle', 'cacert.pem']+ ].map(([name, fileName]) => {+ writeFileSync(join(root, fileName), name);+ return [name, { version: 'test', fileName, url: `https://example.test/${fileName}`, sha256: digest(name) }];+ }));+ writeFileSync(join(root, 'yt-dlp'), contents(oldVersion));+ writeFileSync(join(root, 'versions.json'), JSON.stringify({ version: 1, platform, arch: 'x64', dependencies: { ytDlp: cache() } }));+ vi.stubEnv('OPENCREATOR_CREATOR_RUNTIME_VENDOR', root);+ vi.stubEnv('OPENCREATOR_CREATOR_RUNTIME_PLATFORM', platform);+ vi.stubEnv('OPENCREATOR_CREATOR_RUNTIME_ARCH', 'x64');+ vi.stubEnv('OPENCREATOR_DESKTOP_TARGET_PLATFORM', platform);+ vi.stubEnv('OPENCREATOR_DESKTOP_TARGET_ARCH', 'x64');+ vi.stubEnv('OPENCREATOR_DESKTOP_OFFLINE', '0');+ vi.stubEnv('OPENCREATOR_DOWNLOAD_PROXY', '');+ vi.stubEnv('OPENCREATOR_YT_DLP_PATH', '');+ vi.spyOn(console, 'log').mockImplementation(() => undefined);+ run = vi.fn((command, args) => {+ expect(command).toBe('curl');+ const url = args.at(-1);+ if (url === latestUrl) {+ if (discoveryError) throw discoveryError;+ return JSON.stringify(metadata(currentVersion));+ }+ expect(url).toBe(asset(currentVersion).url);+ const output = args[args.indexOf('--output') + 1];+ writeFileSync(output, downloadContents ?? contents(currentVersion));+ return '';+ });+ vi.doMock('node:child_process', async importOriginal => ({ ...await importOriginal(), execFileSync: run }));+ vi.doMock('../scripts/creator-runtime-releases.mjs', async importOriginal => ({+ ...await importOriginal(), creatorRuntimeReleases: () => ({ [`${platform}-x64`]: structuredClone(fixed) })+ }));+ });++ afterEach(() => {+ vi.doUnmock('node:child_process');+ vi.doUnmock('../scripts/creator-runtime-releases.mjs');+ vi.unstubAllEnvs();+ vi.restoreAllMocks();+ rmSync(root, { recursive: true, force: true });+ });++ const install = () => import('../scripts/install-creator-runtime-dependencies.mjs');++ it('updates a populated cache and records the verified release for each invocation', async () => {+ for (const version of [newVersion, '2026.10.11.233141']) {+ currentVersion = version;+ vi.resetModules();+ await install();+ expect(readFileSync(join(root, 'yt-dlp'), 'utf8')).toBe(contents(version));+ expect(JSON.parse(readFileSync(join(root, 'versions.json'), 'utf8')).dependencies.ytDlp).toEqual(cache(version));+ }+ expect(run.mock.calls.map(([, args]) => args.at(-1))).toEqual([latestUrl, asset().url, latestUrl, asset(currentVersion).url]);+ });++ it('checks the latest release again while reusing an already verified current download', async () => {+ await install();+ run.mockClear(); vi.resetModules();+ await install();+ expect(run.mock.calls.map(([, args]) => args.at(-1))).toEqual([latestUrl]);+ });++ it.each(['discovery', 'checksum'])('stops on an update %s failure and preserves the previous cache', async failure => {+ const previous = readFileSync(join(root, 'versions.json'), 'utf8');+ if (failure === 'discovery') discoveryError = new Error('network unavailable');+ else downloadContents = 'corrupt download';+ await expect(install()).rejects.toThrow(failure === 'discovery' ? /network unavailable/ : /SHA-256 mismatch/);+ expect(readFileSync(join(root, 'yt-dlp'), 'utf8')).toBe(contents(oldVersion));+ expect(readFileSync(join(root, 'versions.json'), 'utf8')).toBe(previous);+ expect(readdirSync(root).some(name => name.endsWith('.partial'))).toBe(false);+ });++ it('validates the offline cache without requesting a release or downloading files', async () => {+ vi.stubEnv('OPENCREATOR_DESKTOP_OFFLINE', '1');+ await install();+ expect(run).not.toHaveBeenCalled();+ expect(JSON.parse(readFileSync(join(root, 'versions.json'), 'utf8')).dependencies.ytDlp).toEqual(cache());+ });++ it('rejects a corrupted offline download without accessing the network', async () => {+ vi.stubEnv('OPENCREATOR_DESKTOP_OFFLINE', '1');+ writeFileSync(join(root, 'yt-dlp'), 'corrupt cache');+ await expect(install()).rejects.toThrow(/offline cache/);+ expect(run).not.toHaveBeenCalled();+ });++ it.each(['0', '1'])('refreshes dependencies from the prepare entry point even with a complete cache (offline=%s)', async offline => {+ vi.stubEnv('OPENCREATOR_DESKTOP_OFFLINE', offline);+ const stopped = new Error('dependency updater reached');+ run.mockImplementation((command, args) => {+ expect(command).toBe(process.execPath);+ if (args[0].endsWith('install-creator-runtime-dependencies.mjs')) throw stopped;+ expect(args[0].endsWith('build-krillinai.mjs')).toBe(true);+ return '';+ });+ await expect(import('../scripts/prepare-creator-runtime.mjs')).rejects.toBe(stopped);+ expect(run).toHaveBeenLastCalledWith(process.execPath,+ [expect.stringContaining('install-creator-runtime-dependencies.mjs')],+ expect.objectContaining({ env: expect.objectContaining({ OPENCREATOR_CREATOR_RUNTIME_VENDOR: root, OPENCREATOR_CREATOR_RUNTIME_PLATFORM: platform, OPENCREATOR_CREATOR_RUNTIME_ARCH: 'x64' }) }));+ });+});diff --git a/docs/operations/opencreator-desktop-release-runbook.md b/docs/operations/opencreator-desktop-release-runbook.mdindex f8d8ea57..4fecf409 100644--- a/docs/operations/opencreator-desktop-release-runbook.md+++ b/docs/operations/opencreator-desktop-release-runbook.md@@ -2,7 +2,7 @@## 1. 适用范围-本文用于发布 OpenCreator Desktop 的 macOS x64、macOS arm64 和 Windows x64 安装包,以及 KrillinAI Server 和 CLI 的 macOS、Windows、Linux 独立程序包。Desktop 安装包包含固定版本的 Codex CLI、KrillinAI CLI、ffmpeg、ffprobe 和 yt-dlp;Whisper CLI 与模型不进入安装包,由 KrillinAI 在功能实际需要时下载到用户数据目录。+本文用于发布 OpenCreator Desktop 的 macOS x64、macOS arm64 和 Windows x64 安装包,以及 KrillinAI Server 和 CLI 的 macOS、Windows、Linux 独立程序包。Desktop 安装包包含固定版本的 Codex CLI、KrillinAI CLI、ffmpeg、ffprobe,以及打包时解析的最新 yt-dlp nightly;Whisper CLI 与模型不进入安装包,由 KrillinAI 在功能实际需要时下载到用户数据目录。发布入口:@@ -26,6 +26,8 @@ pnpm desktop:package`OPENCREATOR_DESKTOP_OFFLINE=1` 要求 pnpm、Electron headers、原生模块、Codex Runtime 和 Creator Runtime 构建缓存已经完整。缓存缺失时必须明确失败,不能静默切换为在线下载。+在线打包即使命中 Creator Runtime 缓存,也会查询官方 yt-dlp nightly 最新发布。下载按解析出的具体版本地址进行,使用 GitHub 发布附件的 SHA-256(缺失时读取同一版本的 `SHA2-256SUMS`)校验;相同版本且哈希匹配时复用文件。查询、下载或校验失败会终止打包,不回退旧版本。实际版本、下载地址和哈希写入缓存 `versions.json`,版本继续写入包内 Runtime manifest。显式离线模式只使用带有效发布信息且哈希匹配的缓存,不保证缓存版本最新;设置 `OPENCREATOR_YT_DLP_PATH` 时使用显式指定的独立程序。+## 2. 发布前条件1. Node.js 22。@@ -35,7 +37,7 @@ pnpm desktop:package5. 仓库全量测试、类型检查和构建通过。6. 打包脚本会删除目标架构旧目录,并要求构建后只找到一个 fresh package root。7. Codex Runtime 三个平台清单中的 npm tarball integrity 和逐文件 SHA-256 已固定。-8. Creator Runtime 的 KrillinAI、ffmpeg、ffprobe、yt-dlp 下载地址和 SHA-256 已固定。+8. Creator Runtime 的 KrillinAI、ffmpeg、ffprobe 下载地址和 SHA-256 已固定;yt-dlp 在在线打包前解析最新 nightly,并固定本次下载地址和 SHA-256。9. OSV Scanner 2.3.8 扫描发布源码无未解释漏洞。10. `.github/workflows/desktop-release.yml` 通过 actionlint。