Commit Graph
100 Commits
Author SHA1 Message Date
RainbowBird 96b629165b fix(server): pass through final upstream errors (#2333)
Signed-off-by: RainbowBird <git@luoling.moe>
2026-09-06 16:08:47 +00:00
RainbowBird 05007ce3ca refactor(stage-ui): rename analytics runtime path (#2466) 2026-09-04 23:37:45 +08:00
RainbowBird ab2c1c99bb refactor(stage-ui): inject runtime emotion prompt (#2464) 2026-09-04 23:17:17 +08:00
RainbowBird e23fa64b62 fix(stage-layouts): suppress mobile browser form assistance (#2460) 2026-09-04 15:56:01 +08:00
RainbowBird fb574e69da docs(readme): update star history links (#2430) 2026-09-04 05:34:47 +00:00
RainbowBird 46a1e9bb70 docs(readme): refresh architecture overview (#2372) 2026-08-27 00:14:46 +08:00
RainbowBird f6969d07c5 feat(chat-ws): authenticate v2 after connect (#2309)
Signed-off-by: RainbowBird <git@luoling.moe>
2026-08-20 14:24:41 +08:00
RainbowBird d22daf6b4c feat(chat-ws): add versioned Eventa protocols (#2308)
Signed-off-by: RainbowBird <git@luoling.moe>
2026-08-20 12:24:47 +08:00
RainbowBird ae170f1ee0 fix(analytics): trim automatic product events (#2325) 2026-08-19 22:30:32 +08:00
RainbowBird 0062070d7d fix(api): correct gateway and database pool alerts (#2324) 2026-08-19 08:30:55 +00:00
RainbowBird d832137fde fix(analytics): remove model discovery events (#2312) 2026-08-18 11:41:10 +08:00
RainbowBird 5ea7bb1083 feat(auth): add lastSeenAt field to user schema and tests 2026-08-17 21:57:25 +08:00
RainbowBird bd790098d2 fix(api): load Drizzle migrations at runtime (#2307) 2026-08-17 11:19:53 +00:00
RainbowBird 07b26b530f fix(analytics): remove TS product events table (#2306) 2026-08-17 10:16:44 +00:00
RainbowBird 85a3f08987 fix(docker): update drizzle-migration build process to prevent virtual import issues 2026-08-16 17:03:38 +08:00
RainbowBird c25791a357 refactor(auth): replace admin plugin with ban guard (#2303) 2026-08-16 16:16:36 +08:00
RainbowBird 88625a8d84 feat(api): hot-reload ConfigKV from Postgres (#2289)
## Summary

- Add the `config_kv` schema and Drizzle migration `0020`.
- Keep the ConfigKV schema, cache store, and invalidation contract in
the Resource API.
- Read ConfigKV through a five-minute Redis cache with PostgreSQL
fallback.
- Reload Router and TTS voice state through `configkv:invalidate`.
- Keep Auth rate limits fixed at 20 requests per 60 seconds.

## Stack

- Depends on #2294 for the Redis test implementation.
- This PR adds ConfigKV-specific cache-aside and Pub/Sub tests on top of
that implementation.

## Deployment

Run migration `0020` before this runtime reaches production traffic.

Then freeze ConfigKV writes. Audit and backfill the data with
[proj-airi/backend#2](https://github.com/proj-airi/backend/pull/2).
Merge
[proj-airi/backend#4](https://github.com/proj-airi/backend/pull/4)
first, so
the fixed Auth rate-limit keys are skipped.

Keep writes frozen until the hashes match and two API instances pass the
Pub/Sub reload check. This PR does not run production DDL or data
migration.

## Verification

- `pnpm exec vitest run <ConfigKV cache store, sync subscriber, and Auth
rate-limit tests>` (12 tests passed)
- `pnpm -F @proj-airi/api-server typecheck`
- `git diff --check`

See #2294 for its frozen-install, ESLint, and 73-test verification.

## Visual changes

None. This PR changes backend persistence and rate-limit wiring only.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added centralized configuration storage with validation, caching,
refresh, and automatic synchronization across services.
- Configuration updates now refresh related language-model and
text-to-speech settings automatically.

- **Bug Fixes**
- Improved recovery after service reconnects by clearing stale
configuration and reloading current values.
- Invalid or unavailable configuration data now produces clearer
service-unavailable responses.

- **Changes**
- Authentication rate limiting now uses a consistent limit of 20
requests per minute per client.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: RainbowBird <git@luoling.moe>
Signed-off-by: RainbowBird <rbxin2003@outlook.com>
2026-08-15 22:24:32 +08:00
RainbowBirdandautofix-ci[bot] ab5e43ae0c test(server): use ioredis-mock for Redis behavior (#2294)
## Summary

- Replace Redis command fakes with `ioredis-mock` in API tests.
- Run the production Lua scripts through `EVAL`.
- Keep Redis behavior tests on the same command and Pub/Sub
implementation used by production code.

## Stack

- This PR is the base for #2289.
- It replaces #2291 as the merge-to-`main` unit. #2291 merged into the
old
  ConfigKV branch before the stack could be reordered.

## Tests

- `pnpm install --frozen-lockfile --offline --ignore-scripts`
- `pnpm exec vitest run <6 changed API test files>` (73 tests passed)
- `pnpm exec eslint <7 changed API TypeScript files>`
- `git diff --check`

## Visual changes

None. This PR changes test infrastructure only.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
  * Added isolated in-memory Redis support for automated testing.
* Updated billing, Stripe, flux, concurrency, and user-deletion tests to
use a shared Redis test setup.
* Improved verification of Redis operations while preserving existing
test coverage and expected outcomes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: RainbowBird <rbxin2003@outlook.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-15 21:43:30 +08:00
RainbowBird 44cd0cfe68 fix(stage-ui): normalize streaming transcription audio chunks (#2285) 2026-08-15 19:37:45 +08:00
RainbowBird 3da1ce163c chore(server): remove admin routes 2026-08-15 14:27:59 +08:00
RainbowBird f45bb2e678 fix(stage-ui): make streaming transcription requests half-duplex (#2283) 2026-08-14 19:21:48 +08:00
RainbowBird 27111382b4 fix(server): reconcile auth split with main 2026-08-12 23:33:58 +08:00
RainbowBird d5c95dca13 chore(server): define Railway service deployment config 2026-08-12 23:33:58 +08:00
RainbowBird 818cd0803f fix(auth-server): revoke social authorizations on account deletion (#2221) 2026-08-12 23:33:58 +08:00
RainbowBirdandautofix-ci[bot] 22b5249c64 refactor(server): split independent auth service (#2202)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-12 23:33:58 +08:00
RainbowBird d4f1837994 fix(auth): trust proxy client IP for rate limits 2026-08-11 23:03:21 +08:00
RainbowBird dd4658bd41 perf(api): remove legacy rolling user metric (#2233) 2026-08-06 18:31:29 +08:00
RainbowBird bd841d546f fix(electron): make remote inspector opening configurable (#2156) 2026-08-05 00:28:51 +08:00
RainbowBird 2abb1ac9ff fix(server): index hot Postgres query paths (#2218) 2026-08-04 21:24:26 +08:00
RainbowBird 04485788d0 perf(server): allow Neon to scale to zero when idle (#2217) 2026-08-04 10:58:27 +00:00
RainbowBird 4f4d256a49 perf(server): add query indexes and cache admin metrics (#2213)
Signed-off-by: RainbowBird <git@luoling.moe>
2026-08-04 17:31:16 +08:00
RainbowBird d5a241b10e chore: migrate services to integration folder 2026-08-02 20:12:13 +08:00
RainbowBird 4ccde2c96e chore: move the server to an independent folder 2026-08-02 18:43:57 +08:00
RainbowBird 9aa27af108 chore(server): cleanup unused scripts 2026-08-02 17:34:31 +08:00
RainbowBird 61e5470801 chore(server): remove otel config 2026-08-02 17:33:37 +08:00
RainbowBird 4d6e61f77d docs(server): cleanup ai context 2026-08-02 00:10:40 +08:00
RainbowBird 71dd65cb99 fix(rate-limit): clarify trusted proxy documentation and improve client address handling 2026-07-31 22:58:05 +08:00
RainbowBird bbad277671 fix(ui-server-auth): bust poisoned asset caches (#2196) 2026-07-31 22:56:17 +08:00
RainbowBird 2a34a52fdc feat(rate-limit): implement RATE_LIMIT_TRUSTED_PROXY for Railway deployments and update related documentation 2026-07-31 22:16:01 +08:00
RainbowBird 81b8a4d5b4 feat(server): add grouped provider fallback routing (#2170) 2026-07-31 00:22:06 +08:00
RainbowBird 269de5b9e1 fix(server): support native Apple ID token sign-in (#2176) 2026-07-30 19:02:10 +08:00
RainbowBird 204197b8b4 feat(routing): add 404 page and update redirects for proper asset handling 2026-07-30 14:36:15 +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
RainbowBird fe470ff81c fix(vite): update rolldownOptions to prevent chunk blocking in Safari 2026-07-30 13:37:56 +08:00
RainbowBird 54a48158cd fix(workflows): update Cloudflare API token and project name for auth UI deployment 2026-07-30 02:18:57 +08:00
RainbowBird 97cf26082f refactor(ui): share user avatar fallbacks (#2143) 2026-07-29 18:38:37 +08:00
RainbowBird c1ca39f1e6 feat(server): add Apple sign-in (#2158) 2026-07-29 18:06:07 +08:00
RainbowBird 742bb80ca5 feat(stage): add global button analytics directive (#2146) 2026-07-29 15:59:53 +08:00
RainbowBird acbbab0bd7 fix(server): correct observability dashboard signals (#2142) 2026-07-28 21:48:03 +08:00
RainbowBird ae35b580d8 feat(stage): group chat controls and track speech mute (#2139) 2026-07-28 19:34:14 +08:00
RainbowBird 899131b0a1 feat(stage): add persistent speech mute controls (#2128) 2026-07-28 17:58:50 +08:00
RainbowBird de8de0a353 fix(stage-ui): repair dangling character card selection (#2114)
Signed-off-by: RainbowBird <git@luoling.moe>
2026-07-27 19:48:40 +08:00
RainbowBird ce65bcd7f5 feat(ccc): add forward-compatible CCv3 codec (#2113)
Signed-off-by: RainbowBird <git@luoling.moe>
2026-07-27 01:38:53 +08:00
RainbowBird f414d165de fix(stage-ui): preserve character card runtime data (#2111) 2026-07-26 20:50:19 +08:00
RainbowBird 20355670a9 fix(stage-pages): sync active card sessions (#2110) 2026-07-26 17:45:04 +08:00
RainbowBird 019d3fa15f fix(stage-pages): validate and preserve AIRI Card drafts (#2109)
Signed-off-by: RainbowBird <git@luoling.moe>
2026-07-26 17:05:28 +08:00
RainbowBird c74ed2ff7b fix(server): improve ai generation analytics correlation 2026-07-15 19:06:34 +08:00
RainbowBird 3543a60d3c feat(auth): integrate useAuthProviderSync across multiple components and add tests 2026-07-15 17:26:05 +08:00
RainbowBird 73258b5aba feat: align PostHog API host with airi.build 2026-07-14 23:18:49 +08:00
RainbowBird 2e9f9ca435 feat: add llm usage and stripe identity analytics (#2056) 2026-07-14 21:56:47 +08:00
RainbowBird 0e4dc69ec0 fix(analytics): normalize PostHog event semantics (#2041) 2026-07-10 13:54:23 +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 689f02ac4f refactor(posthog): unify project key for all AIRI surfaces and streamline configuration 2026-07-08 00:05:26 +08:00
RainbowBird fb9461e00c fix(turbo): add missing dependency for build task 2026-07-02 02:42:57 +08:00
RainbowBird 63532367a9 chore: remove admin dashboard 2026-07-02 02:22:16 +08:00
RainbowBird c7de38b121 refactor(server): split capability alias admin routes 2026-07-02 01:04:29 +08:00
RainbowBird 281614d396 fix(server): harden provider catalog gating 2026-07-01 23:08:14 +08:00
RainbowBird ed8c93c77b feat(server): apply official llm alias routing policy 2026-07-01 22:34:57 +08:00
RainbowBird 14fb183723 fix(server): gate streaming tts requests 2026-07-01 22:34:57 +08:00
RainbowBird 28f93c2c5d fix(server): expose official voice preview urls 2026-07-01 22:34:56 +08:00
RainbowBird b2d7442949 feat(server): enforce official asr aliases 2026-07-01 22:34:56 +08:00
RainbowBird feec4da1fa feat(server): generate official tts voice previews 2026-07-01 22:34:56 +08:00
RainbowBird 87baf622c9 feat(server): add official provider catalog management 2026-07-01 22:34:56 +08:00
RainbowBird 3edbe4eb99 feat(tests): add createMockStripeCustomer function and update tests to use it 2026-07-01 20:28:18 +08:00
RainbowBird e1a2c51573 feat(speech): integrate Voice Pack model into speech catalog and update related tests 2026-07-01 20:18:13 +08:00
RainbowBird af7de96042 feat(analytics): add p1 behavior events 2026-07-01 20:16:09 +08:00
RainbowBird 0daac71435 feat(analytics): add p0 operations events 2026-07-01 20:16:06 +08:00
RainbowBird 27255001bd refactor: streamline speech module by removing voice pack dependencies
- Removed voice pack related imports and functionality from speech.vue and Stage.vue.
- Simplified speech input handling by eliminating voice pack parameters in speech store.
- Updated tests to reflect changes in voice pack handling and speech input resolution.
- Adjusted Airi card store to remove voice pack binding logic, focusing on speech configuration updates.
- Enhanced voice pack list item structure for clarity and maintainability.
2026-07-01 19:23:33 +08:00
RainbowBird c2aee68513 feat: add upstreamVoiceId to voice packs and related services
- Introduced upstreamVoiceId field in voice pack schema and database.
- Updated voice pack service to handle upstreamVoiceId in CRUD operations.
- Modified API routes and tests to accommodate upstreamVoiceId.
- Enhanced UI components to include upstreamVoiceId in forms and displays.
- Adjusted speech processing logic to utilize upstreamVoiceId where applicable.
- Updated related tests to ensure proper functionality with new field.
2026-07-01 16:07:33 +08:00
RainbowBird 1f1ef49eed feat(speech): refactor voice pack handling and remove synthetic model references 2026-07-01 02:47:31 +08:00
RainbowBird 4f80affcd3 feat(admin-dashboard): add support for Bedrock and OpenAI-compatible LLM slices in admin router config
- Implemented `buildBedrockSlice` function to handle multi-kilobyte Bedrock bearer tokens.
- Enhanced `createAdminRouterConfigService` to classify Bedrock and OpenAI-compatible LLM upstreams by baseURL.
- Added new interfaces for `AdminRouterBedrockSlice` and `AdminRouterOpenAICompatibleSlice`.
- Updated router config form to support Bedrock and OpenAI-compatible slices.
- Created tests for Bedrock and OpenAI-compatible slice compilation and behavior.
- Modified UI components to accommodate new slice types and improve user experience.
- Ensured proper normalization of API server URLs to HTTPS when necessary.
2026-07-01 02:14:12 +08:00
RainbowBird f9f20b88ff feat(api-environment): add API environment selection component and related functionality 2026-07-01 01:08:21 +08:00
RainbowBird 71482d3859 feat(speech): implement Voice Pack model option and integrate into settings 2026-07-01 00:45:08 +08:00
RainbowBird de9a2bac7f feat(stage-tamagotchi): add assistant label to ChatHistory component 2026-06-29 03:38:45 +08:00
RainbowBird cc6fe4e6e3 feat(stage-ui): add function to find recommended voice from available voices 2026-06-28 17:25:01 +08:00
RainbowBird 8036501fb0 feat(server): add default TTS model handling and update related tests 2026-06-28 16:55:09 +08:00
RainbowBird 51a44c1f54 fix: disable SSML when not support 2026-06-14 05:03:53 +08:00
RainbowBird c3f2beba47 feat(admin-ui): enhance LLM router page to support Streaming TTS and ASR providers 2026-06-14 04:45:36 +08:00
RainbowBird 3215687e98 feat(server): add Aliyun NLS ASR gateway and official transcription provider (#1970) 2026-06-14 04:22:07 +08:00
RainbowBird 8518c65aa4 feat(auth): enhance trusted admin redirect handling and add local patterns 2026-06-11 22:26:39 +08:00
RainbowBird 2786393aa5 feat(admin-ui): enhance dark mode support across UI components
- Updated various components in the llm-router to include dark mode styles, ensuring better visibility and aesthetics in dark theme.
- Added tests for API URL helpers to validate sign-in URL construction and redirection logic.
- Improved the sign-in flow to handle trusted redirects for standalone admin origins.
- Enhanced CSS styles for dark mode, including adjustments to backgrounds, borders, and text colors for better contrast and readability.
- Refactored input components to maintain consistent styling in both light and dark modes.
2026-06-11 21:59:08 +08:00
RainbowBird 8e572ad93c feat(server): add stepfun tts provider
Signed-off-by: RainbowBird <git@luoling.moe>

Commit-Message-Assisted-by: Claude (via Claude Code)
2026-06-11 00:23:04 +08:00
RainbowBird 5bf6deab89 feat(admin-ui): load and edit router config from forms
Add a form-first LLM/TTS router config editor and a redacted admin config snapshot so operators can inspect configKV state before applying changes.

Preserve existing encrypted key entries when loaded slices are submitted without new plaintext keys.

Signed-off-by: RainbowBird <git@luoling.moe>
Commit-Message-Assisted-by: Claude (via Claude Code)
2026-06-11 00:14:34 +08:00
RainbowBird 16f9aaa4e3 feat(auth): enhance OAuth linking flow with account selection and error handling
- Added `prompt: 'select_account'` for Google and GitHub providers to force account selection during OAuth linking.
- Introduced localized error messages for account linking issues in multiple languages.
- Implemented a function to resolve OAuth error codes to specific i18n keys for better user feedback.
- Updated account settings page to display relevant error messages based on OAuth linking status.
2026-06-10 16:42:13 +08:00
RainbowBird a331d3a42a feat(auth): update AUTH_UI_URL to point to accounts.airi.build 2026-06-09 18:01:34 +08:00
RainbowBird 7fa7f8a072 feat(admin-ui): update admin UI URLs to remove trailing slashes and adjust redirects 2026-06-09 17:46:58 +08:00
RainbowBird 2ac4e90d56 feat(auth): add account linking support for different email providers 2026-06-09 17:46:51 +08:00
RainbowBird 11b820a77f feat(admin-ui): implement standalone admin UI with Cloudflare Pages deployment 2026-06-09 17:09:06 +08:00
RainbowBird 57ba232432 feat(auth): migrate auth ui to unique domain 2026-06-09 00:15:34 +08:00
RainbowBird 19e5020fd3 test: resolve type 2026-06-07 20:47:40 +08:00