[PR #7539] [MERGED] feat(avatars): shared contract for the 2D and 3D avatar agents #7783

Closed
opened 2026-10-24 04:07:28 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7539
Author: @SpicyMarinara
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/avatars-contract


📝 Commits (6)

  • 15af58f feat(avatars): shared contract for the 2D and 3D avatar agents
  • df53866 fix(avatars): refuse Windows device names in stored paths and point code at the developer notes
  • e00796b Merge branch 'staging' into feat/avatars-contract
  • b8d4873 Merge branch 'staging' into feat/avatars-contract
  • 8fd3829 Merge branch 'staging' into feat/avatars-contract
  • 1e9e587 test(avatars): catch bare renderer imports outside the lazy modules

📊 Changes

37 files changed (+1954 additions, -5 deletions)

View changed files

📝 docs/agents/agents-overview.md (+1 -0)
➕ docs/agents/avatars.md (+44 -0)
📝 docs/development/optional-agent-packages.md (+19 -0)
📝 packages/client/package.json (+5 -0)
➕ packages/client/src/features/avatars/audio/avatar-audio.ts (+13 -0)
➕ packages/client/src/features/avatars/contract.ts (+198 -0)
➕ packages/client/src/features/avatars/director/avatar-director.ts (+24 -0)
➕ packages/client/src/features/avatars/generation/AvatarGenerationPanel.tsx (+8 -0)
➕ packages/client/src/features/avatars/renderers/mesh-avatar/MeshAvatarSetupPanel.tsx (+7 -0)
➕ packages/client/src/features/avatars/renderers/mesh-avatar/mesh-avatar-renderer.ts (+20 -0)
➕ packages/client/src/features/avatars/renderers/pngtuber/PngtuberSetupPanel.tsx (+7 -0)
➕ packages/client/src/features/avatars/renderers/pngtuber/pngtuber-renderer.ts (+19 -0)
➕ packages/client/src/features/avatars/renderers/vrm/VrmSetupPanel.tsx (+7 -0)
➕ packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts (+20 -0)
➕ packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx (+13 -0)
➕ packages/client/src/features/avatars/stage/AvatarStage.tsx (+15 -0)
📝 packages/client/vite.config.ts (+7 -0)
➕ packages/server/src/routes/avatar-classify.routes.ts (+11 -0)
➕ packages/server/src/routes/avatar-generation.routes.ts (+13 -0)
➕ packages/server/src/routes/avatar-models.routes.ts (+19 -0)

...and 17 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Refs #7537 (epic: 2D and 3D avatar agents). This is the contract PR; the epic stays open for the lanes.

Why this change

  • The 2D and 3D avatar agents are built in seven lanes at once (base, 2D, 3D, director, TTS, generation, packages). Each lane needs the same types, routes, file layout and dependency pins, and no two lanes may edit the same file. This PR fixes that contract first, so every lane's PR can land on its own on top of it.
  • Nothing changes for users yet: every stub is inert (no UI, no route does any work, no renderer draws), and the new libraries are not in any bundle until a lane imports them from a lazy renderer chunk.

What changed

  • Shared contract (packages/shared/src/types/avatars.ts, exported from the shared index): agent ids 2d-avatars and 3d-avatars; the expression contract (AVATAR_EMOTIONS, AVATAR_VISEMES, AVATAR_STATES, AvatarFrameInput); AvatarKind (pngtuber, mesh-avatar, vrm) and which agent owns each kind; the sprite label → emotion mapping for the 17 labels the sprite editors suggest plus word stems for free-form Game Master expressions; AvatarConfig v1 (avatar.json) with expression bindings that record their source and confidence; import, classifier and generation API types; AVATAR_PROMPT_TEMPLATE_IDS with their variables (the prompt text will live in the packages).
  • Zod schemas for avatar.json and the request bodies (packages/shared/src/schemas/avatars.schema.ts). Stored paths must match <kind>/<name> and may not be a Windows device name (CON, NUL, COM1, …), so nothing can point outside the owner's folder.
  • The 2D agent's avatarGenerationTemplates merge and reset like other built-in prompt template collections.
  • Capability API 1.73 marks an Engine that hosts the avatar agents; documented in docs/development/optional-agent-packages.md.
  • Server skeleton: inert /api/avatar-models, /api/avatar-classify and /api/avatar-generation plugins (registered, no routes yet); storage service signatures for DATA_DIR/avatar-models/<ownerType>/<ownerId>/; importer stubs for .save, .mavatar and .vrm/.vrma behind one fixed registry; classifier and generation service stubs. The existing /api/avatars profile-picture route is untouched.
  • Client skeleton under packages/client/src/features/avatars/: contract.ts (renderer, director, audio-source and setup-panel interfaces, the performance budget, lazy loaders that use import()), and stub modules for each lane.
  • Dependencies, pinned exactly, client only: three 0.186.1, @pixiv/three-vrm 3.5.5, @pixiv/three-vrm-animation 3.5.5, mesh-avatar 0.1.1, @types/three 0.186.0 (dev). Vite puts them in their own lazy vendor chunks, never in vendor-misc.
  • A user guide skeleton, docs/agents/avatars.md, with one section per lane, linked from the agents overview.
  • Regression scripts/regressions/avatar-contract.regression.ts: label mapping, bindings, avatar.json validation (including path escapes and device names), template merging, inert stubs, and a guard that only features/avatars/renderers/ may import three, @pixiv/* or mesh-avatar.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Commands run by the agent (results as reported; boxes above are for the human reviewer):

  • pnpm install --prefer-offline (lockfile update for the five new pins only; additive)

  • pnpm check: passed (impeccable, localization with no new keys, Prettier, ESLint with one existing warning in HomeProfessorMariChat.tsx, e2e and token-estimation types, full build)

  • node scripts/run-regressions.mjs --filter <name> for avatar-contract, capability-package-lifecycle, capability-gm-verb-runtime, docs-language, expression-tool-retirement, game-ruleset-catalogs, world-map-packs, prompt.regression (7 files), zip-reader, sprite-list-security: all passed

  • node scripts/run-regressions.mjs (full suite): 621/622 passed. The one failure, termux-sharp.regression.mjs, is local only: it installs offline from pnpm store path, which in this worktree points at an empty .pnpm-store because the worktree was installed from the main checkout's store (ERR_PNPM_NO_OFFLINE_TARBALL for tslib). This PR does not touch the server's lockfile entries; CI's complete-node-regressions runs it with a real store.

  • Bundle: no file in packages/client/dist contains three, three-vrm or mesh-avatar code, and the entry is unchanged in content (304 KiB). A throwaway local build (not committed) that imported the libraries from the stub renderers and called loadAvatarRenderer() from main.tsx put them in lazy chunks only: vendor-three 404 kB, vendor-three-core 233 kB, vendor-three-vrm 156 kB, vendor-mesh-avatar 89 kB, none in the entry's static import graph and all under the 500 KiB chunk budget.

  • Local CodeRabbit (coderabbit review --agent --committed, Pasta-Devs org): 2 minor findings, both left as they are. (1) "docs/agents/avatars.md has placeholder sections": the per-lane headings are the requested skeleton, so each lane writes only its own section; the intro says the guide fills in as parts land, and no avatar package is in the catalog yet, so nobody can reach the feature half-built. (2) "Mirror the docs change on docs-i18n or open a follow-up": done, #7540 covers all three changed guides.

  • GitHub CodeRabbit on 15af58f10: 4 threads. Fixed in df538660f: Windows device names in stored paths, and the contract comments now point at the developer notes instead of the user guide. Answered: the docs-i18n follow-up is #7540; the 1.73 bump stays (the contract fixes the value for the packages lane), and the developer notes now say the packages publish only after the Engine's setup, stage and a renderer are on staging. After the fixes, avatar-contract passes, and shared, server and client typecheck and Prettier are clean.

Manual verification notes

This PR has no user-visible change, so manual checks confirm that nothing moved:

  • Desktop Chrome, Firefox and Safari: open the app, open a Roleplay chat and a Game chat, and open the Agent editor for any agent. Everything looks and works as before.
  • Desktop Chrome: in DevTools → Network, reload the app and open a Roleplay chat. No vendor-three, vendor-three-core, vendor-three-vrm or vendor-mesh-avatar file is requested.
  • Android Chrome and the Android app WebView: open the app and a Roleplay chat; startup time and scrolling feel unchanged.
  • iOS Safari (PWA): open the app and a Roleplay chat; it loads as before.
  • Server: GET /api/avatar-models and POST /api/avatar-classify answer 404 (no routes yet), and GET /api/avatars/... profile pictures still load.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Docs changed: new docs/agents/avatars.md (skeleton), one link in docs/agents/agents-overview.md, and the Capability API 1.73 section in docs/development/optional-agent-packages.md. Translation follow-up: #7540 (translate after the lanes fill the guide). No version bump.

UI evidence (if applicable)

None: no UI changes.

Summary by CodeRabbit

  • New Features
    • Added foundational support for 2D and 3D avatar agents, including avatar settings, expression mappings, and compatibility with Capability API 1.73 packages.
  • Documentation
    • Added an avatar guide covering avatar types, setup, imports, expressions, lip sync, and performance, plus documentation for avatar agent packages.
  • Note
    • Avatar rendering, importing, storage, classification, and generation are not yet available.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7539 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/avatars-contract` --- ### 📝 Commits (6) - [`15af58f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/15af58f103a860121319c6010dd0d0be38a5ffe2) feat(avatars): shared contract for the 2D and 3D avatar agents - [`df53866`](https://github.com/Pasta-Devs/Marinara-Engine/commit/df538660f776c785451e6cfd981eda93dba7939f) fix(avatars): refuse Windows device names in stored paths and point code at the developer notes - [`e00796b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e00796bac664ed466caa4e66c3201899e8bc8c77) Merge branch 'staging' into feat/avatars-contract - [`b8d4873`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b8d4873a002b0acfefbefe6c5db669db46104e53) Merge branch 'staging' into feat/avatars-contract - [`8fd3829`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8fd3829bd2041cefe13dc459b2e06c99bb375be7) Merge branch 'staging' into feat/avatars-contract - [`1e9e587`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1e9e58776cca3f0a1a60e366046377d8b3d44515) test(avatars): catch bare renderer imports outside the lazy modules ### 📊 Changes **37 files changed** (+1954 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/agents-overview.md` (+1 -0) ➕ `docs/agents/avatars.md` (+44 -0) 📝 `docs/development/optional-agent-packages.md` (+19 -0) 📝 `packages/client/package.json` (+5 -0) ➕ `packages/client/src/features/avatars/audio/avatar-audio.ts` (+13 -0) ➕ `packages/client/src/features/avatars/contract.ts` (+198 -0) ➕ `packages/client/src/features/avatars/director/avatar-director.ts` (+24 -0) ➕ `packages/client/src/features/avatars/generation/AvatarGenerationPanel.tsx` (+8 -0) ➕ `packages/client/src/features/avatars/renderers/mesh-avatar/MeshAvatarSetupPanel.tsx` (+7 -0) ➕ `packages/client/src/features/avatars/renderers/mesh-avatar/mesh-avatar-renderer.ts` (+20 -0) ➕ `packages/client/src/features/avatars/renderers/pngtuber/PngtuberSetupPanel.tsx` (+7 -0) ➕ `packages/client/src/features/avatars/renderers/pngtuber/pngtuber-renderer.ts` (+19 -0) ➕ `packages/client/src/features/avatars/renderers/vrm/VrmSetupPanel.tsx` (+7 -0) ➕ `packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts` (+20 -0) ➕ `packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx` (+13 -0) ➕ `packages/client/src/features/avatars/stage/AvatarStage.tsx` (+15 -0) 📝 `packages/client/vite.config.ts` (+7 -0) ➕ `packages/server/src/routes/avatar-classify.routes.ts` (+11 -0) ➕ `packages/server/src/routes/avatar-generation.routes.ts` (+13 -0) ➕ `packages/server/src/routes/avatar-models.routes.ts` (+19 -0) _...and 17 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Refs #7537 (epic: 2D and 3D avatar agents). This is the contract PR; the epic stays open for the lanes. ## Why this change - The 2D and 3D avatar agents are built in seven lanes at once (base, 2D, 3D, director, TTS, generation, packages). Each lane needs the same types, routes, file layout and dependency pins, and no two lanes may edit the same file. This PR fixes that contract first, so every lane's PR can land on its own on top of it. - Nothing changes for users yet: every stub is inert (no UI, no route does any work, no renderer draws), and the new libraries are not in any bundle until a lane imports them from a lazy renderer chunk. ## What changed - Shared contract (`packages/shared/src/types/avatars.ts`, exported from the shared index): agent ids `2d-avatars` and `3d-avatars`; the expression contract (`AVATAR_EMOTIONS`, `AVATAR_VISEMES`, `AVATAR_STATES`, `AvatarFrameInput`); `AvatarKind` (`pngtuber`, `mesh-avatar`, `vrm`) and which agent owns each kind; the sprite label → emotion mapping for the 17 labels the sprite editors suggest plus word stems for free-form Game Master expressions; `AvatarConfig` v1 (`avatar.json`) with expression bindings that record their source and confidence; import, classifier and generation API types; `AVATAR_PROMPT_TEMPLATE_IDS` with their variables (the prompt text will live in the packages). - Zod schemas for `avatar.json` and the request bodies (`packages/shared/src/schemas/avatars.schema.ts`). Stored paths must match `<kind>/<name>` and may not be a Windows device name (CON, NUL, COM1, …), so nothing can point outside the owner's folder. - The 2D agent's `avatarGenerationTemplates` merge and reset like other built-in prompt template collections. - Capability API 1.73 marks an Engine that hosts the avatar agents; documented in `docs/development/optional-agent-packages.md`. - Server skeleton: inert `/api/avatar-models`, `/api/avatar-classify` and `/api/avatar-generation` plugins (registered, no routes yet); storage service signatures for `DATA_DIR/avatar-models/<ownerType>/<ownerId>/`; importer stubs for `.save`, `.mavatar` and `.vrm`/`.vrma` behind one fixed registry; classifier and generation service stubs. The existing `/api/avatars` profile-picture route is untouched. - Client skeleton under `packages/client/src/features/avatars/`: `contract.ts` (renderer, director, audio-source and setup-panel interfaces, the performance budget, lazy loaders that use `import()`), and stub modules for each lane. - Dependencies, pinned exactly, client only: `three` 0.186.1, `@pixiv/three-vrm` 3.5.5, `@pixiv/three-vrm-animation` 3.5.5, `mesh-avatar` 0.1.1, `@types/three` 0.186.0 (dev). Vite puts them in their own lazy vendor chunks, never in `vendor-misc`. - A user guide skeleton, `docs/agents/avatars.md`, with one section per lane, linked from the agents overview. - Regression `scripts/regressions/avatar-contract.regression.ts`: label mapping, bindings, `avatar.json` validation (including path escapes and device names), template merging, inert stubs, and a guard that only `features/avatars/renderers/` may import three, `@pixiv/*` or mesh-avatar. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Commands run by the agent (results as reported; boxes above are for the human reviewer): - `pnpm install --prefer-offline` (lockfile update for the five new pins only; additive) - `pnpm check`: passed (impeccable, localization with no new keys, Prettier, ESLint with one existing warning in `HomeProfessorMariChat.tsx`, e2e and token-estimation types, full build) - `node scripts/run-regressions.mjs --filter <name>` for `avatar-contract`, `capability-package-lifecycle`, `capability-gm-verb-runtime`, `docs-language`, `expression-tool-retirement`, `game-ruleset-catalogs`, `world-map-packs`, `prompt.regression` (7 files), `zip-reader`, `sprite-list-security`: all passed - `node scripts/run-regressions.mjs` (full suite): 621/622 passed. The one failure, `termux-sharp.regression.mjs`, is local only: it installs offline from `pnpm store path`, which in this worktree points at an empty `.pnpm-store` because the worktree was installed from the main checkout's store (`ERR_PNPM_NO_OFFLINE_TARBALL` for tslib). This PR does not touch the server's lockfile entries; CI's `complete-node-regressions` runs it with a real store. - Bundle: no file in `packages/client/dist` contains three, three-vrm or mesh-avatar code, and the entry is unchanged in content (304 KiB). A throwaway local build (not committed) that imported the libraries from the stub renderers and called `loadAvatarRenderer()` from `main.tsx` put them in lazy chunks only: `vendor-three` 404 kB, `vendor-three-core` 233 kB, `vendor-three-vrm` 156 kB, `vendor-mesh-avatar` 89 kB, none in the entry's static import graph and all under the 500 KiB chunk budget. - Local CodeRabbit (`coderabbit review --agent --committed`, Pasta-Devs org): 2 minor findings, both left as they are. (1) "`docs/agents/avatars.md` has placeholder sections": the per-lane headings are the requested skeleton, so each lane writes only its own section; the intro says the guide fills in as parts land, and no avatar package is in the catalog yet, so nobody can reach the feature half-built. (2) "Mirror the docs change on `docs-i18n` or open a follow-up": done, #7540 covers all three changed guides. - GitHub CodeRabbit on 15af58f10: 4 threads. Fixed in df538660f: Windows device names in stored paths, and the contract comments now point at the developer notes instead of the user guide. Answered: the docs-i18n follow-up is #7540; the 1.73 bump stays (the contract fixes the value for the packages lane), and the developer notes now say the packages publish only after the Engine's setup, stage and a renderer are on `staging`. After the fixes, `avatar-contract` passes, and shared, server and client typecheck and Prettier are clean. ### Manual verification notes This PR has no user-visible change, so manual checks confirm that nothing moved: - Desktop Chrome, Firefox and Safari: open the app, open a Roleplay chat and a Game chat, and open the Agent editor for any agent. Everything looks and works as before. - Desktop Chrome: in DevTools → Network, reload the app and open a Roleplay chat. No `vendor-three`, `vendor-three-core`, `vendor-three-vrm` or `vendor-mesh-avatar` file is requested. - Android Chrome and the Android app WebView: open the app and a Roleplay chat; startup time and scrolling feel unchanged. - iOS Safari (PWA): open the app and a Roleplay chat; it loads as before. - Server: `GET /api/avatar-models` and `POST /api/avatar-classify` answer 404 (no routes yet), and `GET /api/avatars/...` profile pictures still load. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Docs changed: new `docs/agents/avatars.md` (skeleton), one link in `docs/agents/agents-overview.md`, and the Capability API 1.73 section in `docs/development/optional-agent-packages.md`. Translation follow-up: #7540 (translate after the lanes fill the guide). No version bump. ## UI evidence (if applicable) None: no UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added foundational support for 2D and 3D avatar agents, including avatar settings, expression mappings, and compatibility with Capability API 1.73 packages. * **Documentation** * Added an avatar guide covering avatar types, setup, imports, expressions, lip sync, and performance, plus documentation for avatar agent packages. * **Note** * Avatar rendering, importing, storage, classification, and generation are not yet available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:07:28 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7783
No description provided.