Commit Graph
611 Commits
Author SHA1 Message Date
Neko Ayaka addfec1981 refactor(testing-audio,stage-ui): added pinia-plugin-tracing, directly assert from history of pinia 2026-08-14 03:22:32 +08:00
Neko 01eac03af1 fix(stage-ui): correct VAD segment processing (#2258) 2026-08-12 04:16:53 +08:00
Neko 788a509940 fix(stage-ui): share streaming transcription sessions (#2260) 2026-08-12 00:36:26 +08:00
Neko 2433e61378 fix(stage-ui): synchronize auth state across windows (#2256) 2026-08-11 22:42:03 +08:00
Neko Ayaka 66d7ef207e refactor(stage-web,stage-pages,stage-ui): better structure for asr & vad 2026-08-09 18:22:29 +08:00
Neko Ayaka 83ea2afbd7 refactor(*): generalize events 2026-08-09 01:34:48 +08:00
Neko Ayaka eb35c4d66a refactor(*): cleaner provider design, simplified chat store 2026-08-08 01:34:44 +08:00
Neko Ayaka 1226417768 refactor(*): new button 2026-08-04 03:24:32 +08:00
RainbowBird 0ae8c87295 chore(analytics): remove Plausible integration
Signed-off-by: RainbowBird <git@luoling.moe>

Commit-Message-Assisted-by: Claude (via Claude Code)
2026-07-30 14:36:15 +08:00
Neko Ayaka 1927e54c9c fix(stage-ui,stage-pocket,stage-web,stage-tamagotchi,ui-server-auth): analytics import not deferred or lazied 2026-07-30 14:33:21 +08:00
RainbowBird 742bb80ca5 feat(stage): add global button analytics directive (#2146) 2026-07-29 15:59:53 +08:00
RainbowBird 3543a60d3c feat(auth): integrate useAuthProviderSync across multiple components and add tests 2026-07-15 17:26:05 +08:00
RainbowBird 0642ede8d1 feat(analytics): expand PostHog coverage and forward server business facts (#2038)
## What

Closes the three structural gaps in AIRI's product analytics: the signup
surface had zero instrumentation, the payment funnel had no terminator
in PostHog, and SPA route changes emitted no pageviews. Also adds
semantic events for character cards, desktop-only features, and
data-maintenance actions.

## User paths

- User signs up / logs in / verifies email / resets password / links
OAuth / deletes account → each step now emits a PostHog event from
`apps/ui-server-auth` (previously fully uninstrumented), with
`identify()` wired on session load so anonymous funnel events merge into
the user person.
- User pays via Stripe → webhook writes `product_events` as before, and
the product-events service now forwards `payment_completed` (plus signup
and subscription lifecycle facts) to PostHog via posthog-node
`captureImmediate`, keyed by the Better Auth user id → the
`checkout_started → payment_completed` funnel closes end-to-end.
Per-request LLM/TTS volume is explicitly not forwarded.
- User navigates between routes in any surface (web / desktop / pocket /
docs) → `$pageview` + `$pageleave` fire per route change via the
posthog-js `defaults: '2025-05-24'` preset in the shared
`posthog.config.ts`.
- User creates / imports / duplicates / edits a ccv3 card, switches
stage background, runs destructive data actions (export / import / clear
chats, reset providers, wipe app data), or uses desktop differentiators
(Spotlight send, widget windows, in-app updater, MCP server management,
pairing QR) → dedicated low-cardinality events.

## Notable decisions

- Server forwarding defaults on: `POSTHOG_PROJECT_KEY` defaults to the
shared browser-safe phc_* project key; set it to an empty string to
disable. Postgres `product_events` remains the source of truth.
- Cross-surface events (`oauth_callback_failed`, account lifecycle)
share one stage vocabulary exported from stage-ui so the two emitters
cannot drift silently.
- Events captured right before full-page navigation use `sendBeacon` so
they survive the redirect (checkout, OAuth consent handoff, login
redirect).
- Removed dead wrappers (`trackSignup`, `trackFirstModelSelected`,
`trackModelChanged`) that duplicated live event streams under second
names.

## How tested

- `pnpm -F @proj-airi/server exec vitest run
src/services/domain/product-events.test.ts` — 6 passed, covering the
forwarding allowlist, the `user_signed_up → signup_completed` mapping,
non-forwarded per-request actions, and a throwing sink not failing the
webhook path nor losing the DB row.
- stage-ui suites (`use-analytics`, `use-linked-accounts`, exports
contract) — 22 passed, including new account/card/data/desktop event
assertions.
- Real transport smoke: posthog-node `captureImmediate` against
`us.i.posthog.com` with the production key resolved in 1380ms (one
`server_forwarding_smoke_test` event left in the project; filter by
event name).
- Browser-tested pageviews: `VITE_ENABLE_POSTHOG=true` dev build, two
`history.pushState` route changes each produced a `$pageview` with
`$pathname`, `navigation_type: pushState`, previous-page dwell time, and
the `surface` super property; batched POST to `us.i.posthog.com/e/`
returned 200. Note: posthog-js drops events from automated browsers
(`navigator.webdriver`) by default — the verification session bypassed
the bot filter locally; production config is untouched.
- Typecheck and lint pass for server, stage-ui, stage-pages, stage-web,
stage-tamagotchi, ui-server-auth.

Full verification record:
`apps/server/docs/ai-context/verifications/posthog-forwarding-and-pageview.md`

## Follow-ups (not in this PR)

- Bot channel usage stats (Discord / Telegram) once they route through
server-runtime counters.
- Main-process desktop events (tray menu, global shortcut fire) need
renderer relay plumbing.
- Confirm `payment_completed` arrives in PostHog after the first real
Stripe payment post-deploy.

https://claude.ai/code/session_01Q1yGavkQ1P41YhTWE4XKex
2026-07-08 15:33:39 +08:00
RainbowBird 9382a12137 chore: cleanup and lint fix 2026-06-07 20:31:22 +08:00
RainbowBird 007fae6810 chore: update package dependencies and remove specific catalog references
- Removed specific catalog references for '@unocss/core', 'es-toolkit', 'nanoid', and 'valibot' in pnpm-workspace.yaml and various service package.json files.
- Updated versions for '@vueuse/core', 'es-toolkit', 'nanoid', 'reka-ui', and 'valibot' to their latest compatible versions.
- Cleaned up unused catalog entries in pnpm-workspace.yaml.
2026-06-07 19:45:28 +08:00
RainbowBird 7841df28f8 build(deps): migrate workspace dependencies to catalogs
Move direct external dependency versions into pnpm catalogs and update workspace packages to reference catalog entries.

Signed-off-by: RainbowBird <git@luoling.moe>

Commit-Message-Assisted-by: Codex
2026-06-03 17:12:13 +08:00
Neko Ayaka 92b20b0dd2 fix(stage-*): many live2d and vrm issues, default values were missing 2026-05-21 02:25:04 +08:00
DrHuangMHT 7f9eeb715d fix(stage-*): improve cursor tracking (#1842) 2026-05-20 22:30:38 +08:00
RainbowBird 3984677b01 feat(analytics): integrate PostHog for server-side event tracking
- Added a new PostHog client for capturing server-side business events such as Stripe webhooks and subscription state changes.
- Implemented various tracking functions for pricing funnel steps, character creation, and chat session starts.
- Enhanced the flux meter tests to handle partial charges and report unbilled flux correctly.
- Updated the CharacterDialog and Flux settings pages to track user interactions with analytics events.
- Introduced a mechanism to identify users on PostHog based on authentication state to ensure accurate funnel tracking.
- Added necessary dependencies for PostHog integration in the project.
2026-05-15 16:20:47 +08:00
Doji 2c432fc1c8 refactor(stage-web,stage-ui): replace warpdrive plugin with unplugin-basemove (#1818) 2026-05-13 12:03:30 +08:00
Neko Ayaka 37433b98a2 refactor(stage-ui): new structure for models, services, stores 2026-05-08 17:03:46 +08:00
DrHuangMHT 85627d34ad feat(stage-*): allow setting character offset in landscape (#1696) 2026-05-06 17:04:18 +08:00
RainbowBirdandLiet Blue 172e4ce59c feat(auth): email login & profile (#1745)
Co-authored-by: Liet Blue <127093491+lietblue@users.noreply.github.com>
2026-04-28 00:07:38 +08:00
Neko 06fd6d9223 chore(stage-web): added Web Haptics devtools (#1736) 2026-04-27 01:57:08 +08:00
RainbowBird f292ab9b99 feat(ui): add ErrorBoundary component for error handling in Vue 2026-04-25 17:23:43 +08:00
fbd779563d fix(stage-web): remove duplicate page for route /devtools (#1677)
## Description

<!-- Please insert your description here and especially provide info
about the "what" this PR is solving -->

`vue-router` is producing a warning about duplicate route `/devtools` on
`stage-web`. Removing `stage-web/src/pages/devtools/index.vue` resolves
the warning.
There is a duplicate route introduced in
`stage-pages/src/pages/devtools/index.vue`. The file in `stage-web` is
removed in favor of the one in `stage-pages`.
related commit
[`44ec5e4`](https://github.com/moeru-ai/airi/commit/44ec5e416c04ab6fe1d39f01f67330703078439d)

## Linked Issues

<!-- Optional, if you have any -->

## Additional Context

<!-- e.g. is there anything you'd like reviewers to focus on? -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Neko <neko@ayaka.moe>
2026-04-23 22:22:31 +08:00
DrHuangMHT 7e4486c068 chore(ci): fix typecheck on navigator.gpu (#1700) 2026-04-21 20:27:17 +08:00
Neko Ayaka 2ab21879dd chore(deps): bump dependencies 2026-04-18 19:18:17 +08:00
DrHuangMHT 9d5c9e9332 chore(deps): remove deprecated unplugin-vue-router (#1664) 2026-04-15 15:02:10 +08:00
Neko Ayaka f286464e03 chore(deps): bump dependencies 2026-04-15 14:44:59 +08:00
Neko Ayaka 6d68cfbd92 refactor(stage-web,ui-server-auth): better ui of auth 2026-04-15 04:32:19 +08: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
Neko Ayaka 95eac8e41c chore(deps): bump dependencies 2026-04-11 04:00:49 +08:00
Neko Ayaka abc0cb0bc7 refactor(ui-server-auth,server): use better design of signin page 2026-04-10 16:25:11 +08:00
Neko Ayaka 90294ce15c refactor(stage-*): use new InputFileCard 2026-04-10 03:40:10 +08:00
286cc33d0e feat(stage-ui): let AIRI see tool failures in LLM context (captureToolErrors + xsai patches) (#1602)
---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Cursor
Co-authored-by-agent: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-04-08 01:29:17 +08:00
Neko Ayaka ffb7c2e05d refactor(stage-web,ui-server-auth): rollback sign in design 2026-04-07 18:18:55 +08:00
Neko Ayaka fe139f31cd chore(stage-*): configured https, now dev:web:https or pnpm -F @proj-airi/stage-web dev:https works 2026-04-07 01:39:49 +08:00
LemonNeko 883ec945d2 feat(stage-pocket): WebSocket status indicator + shared i18n (#1586) 2026-04-06 19:54:21 +08:00
Neko Ayaka 9baa81ec30 fix(stage-*): missing install of embla-carousel-vue 2026-04-03 15:49:37 +08:00
Neko Ayaka 248e28412a wip(ui-server-auth): basic ui, not yet finalized 2026-04-03 15:43:28 +08:00
Lovehsigure_520andNeko Ayaka f9ebe6522b feat(stage-ui): add hologram promo banner (#1514)
---------

Co-authored-by: Neko Ayaka <neko@ayaka.moe>
2026-04-03 07:22:34 +08:00
Neko Ayaka 3b76bab2fc feat(stage-*,workspace): added Nunito for default English font, ChillRoundM for CJK font
Close #1317, #1393
2026-04-02 18:31:53 +08:00
RainbowBird f1fe161bc0 feat(auth): OIDC (#1531) 2026-04-02 04:24:04 +08:00
fdeb9561bc feat(minecraft,stage-*): airi integration, isolated-vm plus misc updates (#1371)
* feat(minecraft): contextflow integration

Add AiriBridge to cognitive engine to enable communication with Airi system. Expose `notifyAiri` and `updateAiriContext` functions in JS planner runtime globals for sending notifications and context updates from agent code.

* refactor(minecraft): remove redundant destinations field from airi-bridge

Remove hardcoded `destinations: ['minecraft']` from spark:command, spark:notify, and context:update events as the destination is already implied by the bridge context.

* feat(minecraft): complete AIRI context flow integration

Wire up bidirectional AIRI ↔ Minecraft communication via dedicated
signal channels instead of reusing signal:chat_message.

- Add airi_command and airi_context to PerceptionSignalType
- Route spark:command intents: action/plan/proposal/reroute emit
  signal:airi_command; context intent emits signal:airi_context
- Add inbound context:update listener so AIRI can push context to
  the Minecraft agent
- airi_context signals are injected into conversation history directly
  without triggering a full cognitive cycle
- airi_command events reset the no-action budget (like player chat)
- enterContext/exitContext auto-emit context:update back to AIRI for
  task lifecycle visibility
- Add sendEmit() helper for queued/working/done progress reporting

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(minecraft): report bot startup state to AIRI

Send initial context update to AIRI when brain comes online, including
bot username, server address, position, health, game mode, and list of
other online players. Tagged with 'startup' and bot username for
filtering.

* feat(minecraft): manage bot config through airi

* feat(stage-ui): add minecraft service shell

* fix(stage-ui): use applied minecraft config for chat context

* fix(minecraft): fall back on invalid env port

* fix(minecraft): support quoted env values

* fix(minecraft): ignore empty env overrides

* fix(stage-ui): keep minecraft draft during apply

* fix(stage-ui): simplify minecraft heartbeat label

* feat(stage-ui): simplify minecraft settings shell

* fix(minecraft): use registry heartbeat for stage liveness

* chore(minecraft): remove annoying detector decision logging

* fix(minecraft): limit context flow to bot pushes

* fix(minecraft): use workspace server sdk

* fix(stage-ui): replay registry snapshots for late listeners

* chore(minecraft): add todo for explicit stage deregistration

* feat: improve context flow observability

* fix(stage-ui): remove redundant header and callout from settings and context flow pages

* feat(stage-ui): enhance context flow prompt projection UI with readiness indicator

* docs(stage-ui): clarify context flow prompt projection terminology

* fix(stage-ui): add test for clone-safe context snapshots with nested fields

* todo

* fix(minecraft): avoid blocking startup on airi connection

* Remove LLM timeouts from the Minecraft brain

* Remove context boundary system from Minecraft brain

* feat(minecraft): use isolated-vm for JS planner sandbox

* refactor(minecraft): harden planner sandbox defaults

* Remove LLM attempt timeout guard

* [autofix.ci] apply automated fixes

* Fix server runtime shutdown signal handling

* Remove misleading Minecraft integration toggle

* contextflow destination to stage-*

* chore(deps): updated

* Add settings layout route for web devtools

* chore: default to expand context panels

* fix(server-*): should export more types, and for module:announced should ignore self

* refactor(minecraft): better context orchestration, handle module announce, context sync, and more

* feat(stage-ui): not spark command ready

* [autofix.ci] apply automated fixes

* clean up

* refactor: use :class arrays per AGENTS.md styling guidelines

* cleanup bloated tests

* rm more tests

* use errorMessageFrom

* hardcode to reduce bloat

* update setup instructions

* timeout for brain

* remove more bloat

* fix

---------

Co-authored-by-agent: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by-agent: Codex
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Neko Ayaka <neko@ayaka.moe>
2026-04-01 23:33:59 +08:00
Lilia_Chenandautofix-ci[bot] d9ba2ab40e refactor(stage-ui-three): improved outline logic (#1536)
* refactor(stage-ui-three): improved outline logic

* [autofix.ci] apply automated fixes

* fix(stage-ui-three): restored runtime hooks being exposed

* some type fix

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-04-01 07:48:00 +08:00
Lilia-Chen 718e91a833 refactor(stage-ui-three): add hooks in VRM loading workflow 2026-03-31 00:24:13 +01:00
Neko Ayaka b6c5882366 chore(stage-ui): pwa toaster prompt 2026-03-30 23:18:29 +08:00
JasonandJasonOA888 7164318002 fix(pwa): show update toast when new version is available (#1517)
---------

Co-authored-by: JasonOA888 <JasonOA888@users.noreply.github.com>
Assume-co-authored-by-agent: Unknown <unknown@example.com>
2026-03-30 22:54:54 +08:00
Neko Ayaka 5f07b68876 fix(stage-*): should not wait until context bridge 2026-03-30 20:18:55 +08:00