Files
wehub-resource-sync 426e9eeabd
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
ci / test (push) Has been cancelled
ci / lint-and-format (push) Has been cancelled
ci / build (push) Has been cancelled
ci / dev-startup (push) Has been cancelled
gitleaks / gitleaks (push) Has been cancelled
Markdown Links / Relative Markdown Links (push) Has been cancelled
Quality (Extended) / Homepage Build (PR smoke) (push) Has been cancelled
Quality (Extended) / Comment-only diff guard (push) Has been cancelled
Quality (Extended) / Format + Type Safety Ratchet (push) Has been cancelled
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Has been cancelled
Quality (Extended) / Develop Gate (lint) (push) Has been cancelled
Chat shell gestures / Chat shell gesture + parity e2e (push) Has been cancelled
Cloud Gateway Discord / Test (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Has been cancelled
Build Agent Image / build-and-push (push) Has been cancelled
Dev Smoke / bun run dev onboarding chat (push) Has been cancelled
Dev Smoke / Vite HMR dependency-level smoke (push) Has been cancelled
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Has been cancelled
Publish @elizaos/example-code / check_npm (push) Has been cancelled
Publish @elizaos/example-code / publish_npm (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / verify_version (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / publish_npm (push) Has been cancelled
Sandbox Live Smoke / Sandbox live smoke (push) Has been cancelled
Snap Build & Test / Build Snap (amd64) (push) Has been cancelled
Snap Build & Test / Build Snap (arm64) (push) Has been cancelled
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Has been cancelled
Cloud Gateway Webhook / Test (push) Has been cancelled
Cloud Tests / lint-and-types (push) Has been cancelled
Cloud Tests / unit-tests (push) Has been cancelled
Cloud Tests / integration-tests (push) Has been cancelled
Cloud Tests / e2e-tests (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Apps Worker (Product 2) / Determine environment (push) Has been cancelled
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Has been cancelled
Deploy Eliza Provisioning Worker / Determine environment (push) Has been cancelled
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Has been cancelled
Dev Smoke / Classify changed paths (push) Has been cancelled
supply-chain / sbom (push) Has been cancelled
supply-chain / vulnerability-scan (push) Has been cancelled
Build, Push & Deploy to Phala Cloud / build-and-push (push) Has been cancelled
Test Packaging / Validate Packaging Configs (push) Has been cancelled
Test Packaging / Build & Test PyPI Package (push) Has been cancelled
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Has been cancelled
Test Packaging / Pack & Test JS Tarballs (push) Has been cancelled
UI Fixture E2E / ui-fixture-e2e (push) Has been cancelled
UI Fixture E2E / fixture-e2e (push) Has been cancelled
UI Story Gate / story-gate (push) Has been cancelled
vault-ci / test (macos-latest) (push) Has been cancelled
vault-ci / test (ubuntu-latest) (push) Has been cancelled
vault-ci / test (windows-latest) (push) Has been cancelled
vault-ci / app-core wiring tests (push) Has been cancelled
verify-patches / verify patches/CHECKSUMS.sha256 (push) Has been cancelled
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Has been cancelled
Voice Benchmark Smoke / voice bench smoke summary (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Has been cancelled
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00

204 lines
6.4 KiB
JavaScript

#!/usr/bin/env node
/**
* Process VRM avatars from characters/vrm: gzip for shipping.
*
* Replaces VRMs in packages/app/public/vrms and packages/app/public_src/vrms with
* gzipped versions of the character models.
*
* Note: gltf-transform optimize/meshopt/draco are intentionally NOT used because
* they strip or reindex VRM extensions (VRMC_vrm, VRMC_springBone,
* VRMC_materials_mtoon), breaking VRM loading. Gzip alone gives ~40% compression
* on these files, and the marginal benefit of mesh compression (~0.6MB/file) is
* not worth the complexity of preserving VRM extension integrity.
*
* Usage:
* node scripts/process-vrms.mjs
* node scripts/process-vrms.mjs --placeholders-only # only fix previews/backgrounds
* node scripts/process-vrms.mjs --dry-run
*/
import {
cpSync,
existsSync,
mkdirSync,
readdirSync,
readFileSync,
unlinkSync,
writeFileSync,
} from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { gzipSync } from "node:zlib";
import { resolveRepoRootFromImportMeta } from "./lib/repo-root.mjs";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const ROOT = resolveRepoRootFromImportMeta(import.meta.url);
const CHARACTERS_VRM = join(ROOT, "apps", "app", "characters", "vrm");
const PUBLIC_VRMS = join(ROOT, "apps", "app", "public", "vrms");
const PUBLIC_SRC_VRMS = join(
ROOT,
"eliza",
"apps",
"app-companion",
"public_src",
"vrms",
);
const TAG = "[process-vrms]";
// Character name -> eliza index (1-based). Order determines avatar order in UI.
const CHARACTER_TO_INDEX = [
["Chen", 1],
["Jin", 2],
["Kei", 3],
["Momo", 4],
["Rin", 5],
["Ryu", 6],
["Satoshi", 7],
["Yuki", 8],
];
function parseArgs() {
const args = process.argv.slice(2);
let dryRun = false;
let placeholdersOnly = false;
for (let i = 0; i < args.length; i++) {
if (args[i] === "--dry-run") {
dryRun = true;
} else if (args[i] === "--placeholders-only") {
placeholdersOnly = true;
}
}
return { dryRun, placeholdersOnly };
}
function processVrm(srcPath, destBaseName, dryRun) {
if (dryRun) {
console.log(`${TAG} [dry-run] ${srcPath} -> ${destBaseName}.vrm.gz`);
return;
}
const rawBytes = readFileSync(srcPath);
const rawMB = (rawBytes.length / 1024 / 1024).toFixed(1);
// Gzip for public (shipped assets)
const gzipPath = join(PUBLIC_VRMS, `${destBaseName}.vrm.gz`);
const gzipped = gzipSync(rawBytes, { level: 9 });
writeFileSync(gzipPath, gzipped);
const gzMB = (gzipped.length / 1024 / 1024).toFixed(1);
// Copy raw to public_src (for screenshotter / dev)
const publicSrcDest = join(PUBLIC_SRC_VRMS, `${destBaseName}.vrm`);
cpSync(srcPath, publicSrcDest, { force: true });
console.log(`${TAG} ${rawMB}MB -> ${gzMB}MB gzipped`);
}
function main() {
const { dryRun, placeholdersOnly } = parseArgs();
if (!placeholdersOnly && !existsSync(CHARACTERS_VRM)) {
console.error(
`${TAG} ERROR: characters/vrm not found at ${CHARACTERS_VRM}`,
);
process.exit(1);
}
const available = placeholdersOnly
? []
: readdirSync(CHARACTERS_VRM).filter((f) => f.endsWith(".vrm"));
if (!placeholdersOnly && available.length === 0) {
console.error(`${TAG} ERROR: no .vrm files in ${CHARACTERS_VRM}`);
process.exit(1);
}
console.log(
`${TAG} Processing ${placeholdersOnly ? "placeholders only" : `${available.length} VRMs from characters/vrm`} (dryRun=${dryRun})`,
);
// Remove old VRMs and previews/backgrounds not in our character set (eliza-1..8)
const keepIds = new Set(CHARACTER_TO_INDEX.map(([, i]) => i));
const dirsToClean = [
PUBLIC_VRMS,
PUBLIC_SRC_VRMS,
join(PUBLIC_VRMS, "previews"),
join(PUBLIC_VRMS, "backgrounds"),
join(PUBLIC_SRC_VRMS, "previews"),
join(PUBLIC_SRC_VRMS, "backgrounds"),
];
for (const dir of dirsToClean) {
if (existsSync(dir) && !dryRun) {
for (const f of readdirSync(dir)) {
const m = f.match(/^eliza-(\d+)\.(vrm|png)(\.gz)?$/);
if (m && !keepIds.has(Number(m[1]))) {
const p = join(dir, f);
try {
unlinkSync(p);
console.log(`${TAG} Removed obsolete ${f}`);
} catch {
// ignore
}
}
}
}
}
mkdirSync(PUBLIC_VRMS, { recursive: true });
mkdirSync(join(PUBLIC_VRMS, "previews"), { recursive: true });
mkdirSync(join(PUBLIC_VRMS, "backgrounds"), { recursive: true });
mkdirSync(PUBLIC_SRC_VRMS, { recursive: true });
mkdirSync(join(PUBLIC_SRC_VRMS, "previews"), { recursive: true });
mkdirSync(join(PUBLIC_SRC_VRMS, "backgrounds"), { recursive: true });
let processed = 0;
if (!placeholdersOnly) {
for (const [charName, index] of CHARACTER_TO_INDEX) {
const vrmFile = `${charName}.vrm`;
const srcPath = join(CHARACTERS_VRM, vrmFile);
if (!existsSync(srcPath)) {
console.warn(`${TAG} Skipping ${vrmFile} (not found)`);
continue;
}
const destBaseName = `eliza-${index}`;
console.log(`${TAG} ${charName}.vrm -> ${destBaseName}.vrm.gz`);
processVrm(srcPath, destBaseName, dryRun);
processed += 1;
}
} else {
processed = CHARACTER_TO_INDEX.length;
}
// Ensure previews and backgrounds exist for all avatars (copy from first existing if missing)
if (processed > 0 && !dryRun) {
let srcPreview = null;
let srcBg = null;
for (const [, index] of CHARACTER_TO_INDEX) {
const p = join(PUBLIC_VRMS, "previews", `eliza-${index}.png`);
const b = join(PUBLIC_VRMS, "backgrounds", `eliza-${index}.png`);
if (!srcPreview && existsSync(p)) srcPreview = p;
if (!srcBg && existsSync(b)) srcBg = b;
if (srcPreview && srcBg) break;
}
for (const [, index] of CHARACTER_TO_INDEX) {
const dstPreview = join(PUBLIC_VRMS, "previews", `eliza-${index}.png`);
const dstBg = join(PUBLIC_VRMS, "backgrounds", `eliza-${index}.png`);
if (!existsSync(dstPreview) && srcPreview) {
cpSync(srcPreview, dstPreview);
console.log(`${TAG} Copied placeholder preview eliza-${index}.png`);
}
if (!existsSync(dstBg) && srcBg) {
cpSync(srcBg, dstBg);
console.log(`${TAG} Copied placeholder background eliza-${index}.png`);
}
}
}
console.log(`${TAG} Processed ${processed} VRMs`);
if (processed > 0 && !dryRun) {
console.log(
`${TAG} Output: public/vrms/*.vrm.gz (shipped), public_src/vrms/*.vrm (archived)`,
);
}
}
main();