Commit Graph
3537 Commits
Author SHA1 Message Date
github-actions[bot] e87c24d60f chore(nix): update pnpmDeps hash 2026-04-13 15:25:51 +00:00
147d077aa7 feat(inference): unify and optimize WebGPU inference pipeline (#1622)
## Problem

The WebGPU inference pipeline had several structural issues:

1. **No unified protocol** — Kokoro TTS, Whisper ASR, and Background
Removal workers each used their own ad-hoc message formats. Adding a new
model meant reinventing worker communication from scratch.
2. **Infrastructure existed but was disconnected** —
`GPUResourceCoordinator`, `LoadQueue`, `InferenceWorkerManager`, and
`protocol.ts` were all implemented but had zero consumers. The adapters
duplicated the same lifecycle/timeout/mutex patterns independently.
3. **Performance gaps** — Kokoro only offered fp32 on WebGPU (no fp16),
Whisper warm-up compiled shaders for 187.5s of dummy audio, audio
transfer went through unnecessary WAV blob encode/decode, and
`listVoices` reloaded the model every time.
4. **Silent failures** — Whisper worker's `generate()` had no try-catch;
errors were swallowed and the main thread waited until timeout.
5. **No graceful degradation** — Whisper and Background Removal workers
hardcoded `device: 'webgpu'` with no WASM fallback.
6. **No observability** — Only Kokoro had performance tracing. No
adapter reported status to `useInferenceStatus`. No cache management UI
existed.
7. **Dead code accumulation** — Old `KokoroWorkerManager` (232 lines),
legacy Whisper message types, and scattered duplicate constants.

## Changes

### Phase 0 — Critical Performance & Bugs
- Add `fp16-webgpu` dtype for Kokoro TTS (~2x inference speed on
supported GPUs)
- Fix Whisper warm-up tensor from `[1, 128, 3000]` → `[1, 128, 1]`
(minimal shader compilation)
- Fix Whisper worker silent error bug (add try-catch to `generate()` and
`load()`)

### Phase 1 — Data Transfer & Caching
- Switch Kokoro audio to Float32Array transferable (skip WAV blob encode
in worker, lightweight WAV encode on main thread)
- Cache `listVoices` results (skip redundant model reload when adapter
state is `ready`)
- Normalize progress reporting to 0-100 across all adapters,
differentiate `warmup` phase

### Phase 2 — Protocol Unification & Infrastructure
- Migrate all 3 workers + 3 adapters to unified `protocol.ts` message
types (`load-model`, `run-inference`, `model-ready`, `inference-result`,
`progress`, `error`)
- Wire `GPUResourceCoordinator` into all adapters (VRAM allocation
tracking, LRU ordering, memory pressure events)
- Wire `LoadQueue` into all adapters (priority-based sequential model
loading: TTS=10 > ASR=5 > BG_REMOVAL=1)
- Add `coordinator.ts` global singleton for GPU coordinator + load queue
- Add WebGPU detection + WASM fallback in Whisper and Background Removal
workers

### Phase 3 — Error Recovery & Observability
- Add restart logic with exponential backoff to Whisper adapter
(matching Kokoro's existing pattern)
- Integrate `classifyError()` (OOM / DEVICE_LOST / TIMEOUT
classification) in Whisper adapter
- Extend `defaultPerfTracer` to Whisper `transcribe()` and Background
Removal `processImage()`
- Wire `useInferenceStatus` into all 3 adapters (downloading → ready →
terminated lifecycle)

### Phase 4 — Tests
- Add unit tests for `AsyncMutex` (4 tests), `LoadQueue` (4 tests),
`GPUResourceCoordinator` (7 tests) — all 15 passing

### Phase 5 — Cleanup & Features
- Delete old `KokoroWorkerManager` (232 lines, zero consumers)
- Delete orphaned `libs/workers/types.ts` (old Whisper message types)
- Clean up `workers/kokoro/types.ts` (remove legacy message types, keep
domain types)
- Create centralized `constants.ts` (MODEL_IDS, MODEL_NAMES, TIMEOUTS,
MAX_RESTARTS)
- Remove hardcoded WebGPU check from background-removal devtools pages
(worker auto-detects)
- Add `useModelPreload` composable for generic idle-time preloading
- Add `useInferencePreload` composable that reads provider config and
preloads configured local models
- Wire preloading into both `stage-web` and `stage-tamagotchi` App.vue
(Kokoro TTS preloads 3s after init)
- Add `ModelCacheManager.vue` settings component (cache size display,
per-model status, clear cache)
- Document GPU Device isolation architecture in protocol.ts

## After This PR

- All inference workers speak the same protocol → adding a new model
adapter is straightforward
- GPU memory is tracked across all models with automatic pressure
warnings at 80%/95% of VRAM budget
- Models load sequentially via priority queue → no bandwidth/VRAM
contention
- Workers auto-detect WebGPU and fall back to WASM → works on browsers
without WebGPU
- Kokoro TTS preloads during idle time → "instant" first use for
configured users
- All adapters auto-restart on worker crashes (max 3 attempts,
exponential backoff)
- 15 unit tests cover core infrastructure (mutex, queue, coordinator)
- Zero dead code remains in the inference pipeline

## Test Plan

- [x] `pnpm exec vitest run packages/stage-ui/src/libs/inference/` — 15
tests pass
- [x] `pnpm -F @proj-airi/stage-ui exec tsc --noEmit` — no TypeScript
errors
- [x] `pnpm lint:fix` — no lint errors in changed files
- [ ] Manual: verify Kokoro TTS works with fp16-webgpu on a supported
browser
- [ ] Manual: verify Whisper ASR loads and transcribes correctly
- [ ] Manual: verify Background Removal works in devtools page
- [ ] Manual: verify preloading triggers in console (`[Preload] Loading
kokoro-...`)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-04-13 23:19:27 +08:00
d86314f5a3 fix(minecraft): multiple core crashes and logic bugs in Minecraft bots (#1375)
## Description

本次修复解决了 Minecraft 机器人运行中的多个核心崩溃与逻辑问题,让 AI 能稳定执行挖掘、跟随、资源收集等任务:

1.  **修复 `expectMoved()` 验证逻辑**:
    - 当动作结果中不存在 `movedDistance` 字段时,默认使用 0 而非抛出错误
    - 新增非移动动作白名单(挖掘、放置、交互等),对这类动作直接返回成功,不再强制要求移动距离
- 解决了「挖掘动作被误判失败」的核心问题(报错:`Expectation failed: expectMoved() requires
last action result with movedDistance telemetry`)

2.  **优化 `breakBlockAt()` 挖掘逻辑**:
    - 修正脚下方块位置计算,提升挖掘精准度
    - 补充详细调试日志,便于排查挖掘相关问题

3.  **修复 `InventoryQueryChain.count()` 空值问题**:
    - 增加对 `name` 参数的空值检查,避免 `undefined` 调用 `toLowerCase()` 导致崩溃
- 解决了 `Cannot read properties of undefined (reading 'toLowerCase')` 报错

4.  **补全查询链缺失方法**:
    - 为 `EntityQueryChain` 新增 `whereName()` 方法,支持按实体名称过滤
    - 为 `BlockQueryChain` 新增 `where()` 方法,支持自定义谓词过滤
- 解决了 `whereName is not a function` / `where is not a function` 等类型错误

5.  **修复 `JavaScriptPlanner.runAction()` 异步竞态问题**:
- 在异步操作后增加 `this.activeRun` 空值检查,避免 `activeRun` 为 `null` 时访问 `executed`
导致崩溃
    - 解决了 `Cannot read properties of null (reading 'executed')` 报错

## Linked Issues

Fixes #1352

## Additional Context
- 所有修改均在 Minecraft 服务目录下,不影响其他模块
- 测试验证:机器人可正常执行挖掘、跟随、资源收集等任务,不再出现上述崩溃
- 原项目 Mineflayer 版本即将弃用,但本修复可让当前实验版机器人稳定可用,也为后续原生 Mod 版本提供参考

---------

Co-authored-by: Rin <shinohara-rin@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-04-13 18:21:38 +08:00
RainbowBird fc0ad03411 feat(server): require BETTER_AUTH_SECRET and pass it explicitly to betterAuth
Without a stable secret, better-auth generates a random one per process,
which invalidates every session cookie and JWKS private key on redeploy
and across multi-instance deployments. Make it a required env var and
wire it into betterAuth({ secret }) explicitly so missing config fails
fast at boot instead of silently rotating keys.
2026-04-13 18:13:19 +08:00
Liet Blue 61371060e7 fix(ci): harden pr-triage prompt against WASM guard UTF-8 crash (#1653)
The WASM guard (lib.rs:939) panics on `&output_json[..500]` when the
serialized output contains CJK characters at the byte boundary. This
poisons the guard for the entire session.

- Flip call order: get_files first (ASCII-dominant response), get second
- Add fallback: curl GitHub API when MCP server dies
- Narrow bash restriction: allow read-only shell for data retrieval
- Recompile lock file
2026-04-13 16:24:15 +08:00
Lulu 9bc2d718b6 fix(stage-ui): fit scroll visualizer metrics and scroller in fixed he… (#1632)
Co-authored-by-agent: Cursor <unknown@example.com>
2026-04-13 14:33:38 +08:00
yiduoyide 7309fcd358 fix(stage-tamagotchi): fix window title (#1639) 2026-04-13 14:31:30 +08:00
Lulu bc94ba480b fix(stage-pages): allow clearing OpenAI-compatible speech model field (#1644) 2026-04-13 13:55:00 +08:00
github-actions[bot] 1ca3a72394 chore(i18n): update translations (#1650) 2026-04-13 13:54:14 +08:00
github-actions[bot] 79e3ae002b chore(nix): update assets hash 2026-04-12 20:19:25 +00:00
Rin b7e9ce1a3d fix(ci): min-integrity: none for safeoutput mcp call (#1645) 2026-04-12 18:02:58 +08:00
github-actions[bot]andCrowdin Bot 977a8e4f57 chore(i18n): update translations (#1641)
This PR contains updated translations from Crowdin. Created from [GitHub
Actions](https://github.com/moeru-ai/airi/blob/main/.github/workflows/crowdin-cron-sync.yml).

You can review the source of translations
[here](https://crowdin.com/project/proj-airi)

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-12 17:03:13 +08:00
RainbowBird b7f9ff2749 chore(stage-ui): enhance flux package display and add recommended badge 2026-04-12 05:30:55 +08:00
RainbowBird 671517864a feat(flux): update transaction stats to use capacity from latest credit/initial transaction 2026-04-12 04:52:42 +08:00
RainbowBird 93888e6935 feat(server): use stripe product as flux pricing (#1640) 2026-04-12 04:32:42 +08:00
Makito bc5397b3f5 feat(stage-ui): add OTel deps and IO tracer helpers 2026-04-11 19:05:38 +09:00
Makito dd9cc0942b feat(stage-shared): add types for IO tracing 2026-04-11 18:25:19 +09:00
github-actions[bot]andCrowdin Bot 978009a13c chore(i18n): update translations (#1629)
This PR contains updated translations from Crowdin. Created from [GitHub
Actions](https://github.com/moeru-ai/airi/blob/main/.github/workflows/crowdin-cron-sync.yml).

You can review the source of translations
[here](https://crowdin.com/project/proj-airi)

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-11 10:39:16 +08:00
Neko Ayaka b77a1af2c8 chore(stage-tamagotchi): improve widget calling devtools 2026-04-11 05:21:46 +08:00
Neko Ayaka b18158bce2 chore(computer-use-mcp): remove all hardcoded file path 2026-04-11 05:13:55 +08:00
Neko Ayaka feb2055ed2 style(computer-use-mcp): house keeping, lint fixes, type missing, and many more 2026-04-11 04:59:13 +08:00
Neko Ayaka 87f719272a fix(stage-layouts): prevent using :global(...) as they gets compiled into .dark without the children selector 2026-04-11 04:22:34 +08:00
Neko Ayaka 67398494c7 fix(server): zod is required 2026-04-11 04:19:28 +08:00
github-actions[bot] 79af8bee76 chore(nix): update assets hash 2026-04-10 20:14:25 +00:00
github-actions[bot] 98bf4c93ef chore(nix): update pnpmDeps hash 2026-04-10 20:07:54 +00:00
Neko Ayaka 95eac8e41c chore(deps): bump dependencies 2026-04-11 04:00:49 +08:00
yewu 4da6fd3672 fix(stage-pages): persist default Kokoro model on first visit (#1624)
Co-authored-by-agent: Unknown <unknown@example.com>
2026-04-11 03:18:27 +08:00
Makito ccba8fbe65 fix(stage-ui): shrink icon size to better fit the button 2026-04-11 03:03:29 +09:00
Neko Ayaka aad3b7c115 chore(deps): updated 2026-04-11 01:17:31 +08:00
Rin 4e1946da43 fix(ci): pr triage permission (#1619) 2026-04-11 01:03:03 +08:00
Iro adcfcd9399 fix(stage-ui): resolve critical state and initialization issues (#1614) 2026-04-11 01:02:16 +08:00
刘梓恒 aa7428ace2 feat(mcp-computer-use): lay down the foundation of computer use (#1380) 2026-04-11 00:54:01 +08:00
Nashchennc 933ef01b10 test(stage-ui): add contract test (#1487) 2026-04-11 00:49:13 +08:00
Neko Ayaka 9a59848b85 fix(server): now import the ui-server-auth built artifacts into docker image 2026-04-10 22:35:24 +08:00
Neko Ayaka 139e71824f chore(ci): incorrect build name 2026-04-10 20:08:36 +08:00
Neko Ayaka b59c8d0861 chore(ci): with name, and should support branch for tag name 2026-04-10 19:49:07 +08:00
Neko Ayaka 9fe3abdf5b chore(ci): publishes ui-server-auth as assets image 2026-04-10 19:36:53 +08:00
LemonNeko c8a01e7a3b feat(stage-pocket): allow to set transparent background 2026-04-10 17:51:09 +08:00
Neko Ayaka fb3f54699b chore(18n): unified to use sign in / sign out 2026-04-10 16:25:11 +08:00
Neko Ayaka abc0cb0bc7 refactor(ui-server-auth,server): use better design of signin page 2026-04-10 16:25:11 +08:00
RainbowBird f769580099 docs(ui-components): add comprehensive component reference for standardized UI primitives 2026-04-10 15:58:19 +08:00
Neko Ayaka dd284f0f27 release: v0.9.0 2026-04-10 14:48:30 +08:00
github-actions[bot]andCrowdin Bot c05fd13545 chore(i18n): update translations (#1616)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-10 14:42:10 +08:00
Neko Ayaka 3962139b93 chore(stage-tamagotchi,ui): improved about page 2026-04-10 13:54:22 +08:00
github-actions[bot]andCrowdin Bot 558bd282b0 chore(i18n): update translations (#1613)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-10 11:14:38 +08:00
Makito 686c059364 perf(stage-tamagotchi): resize once and then animate the window move
---------

Co-authored-by-agent: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 05:04:50 +09:00
Makito 2a1c47eab7 feat(stage-tamagotchi): better transforming strategy for main-stage window 2026-04-10 05:02:34 +09:00
Neko f65a67f543 fix(ui): incorrect round and default shape of button 2026-04-10 03:50:35 +08:00
Makito b11f251dd0 feat(stage-tamagotchi): move main-stage window to avoid overlap with onboarding window 2026-04-10 04:44:50 +09:00
Neko Ayaka a0caaf3214 release: v0.9.0-rc.1 2026-04-10 03:40:59 +08:00