Commit Graph
203 Commits
Author SHA1 Message Date
chaosreloadandautofix-ci[bot] a189536489 feat(providers): add Amazon Bedrock provider (#1256)
## Summary

Add support for Amazon Bedrock as an LLM provider using the native
**Converse API** with API Key authentication.

## Motivation

AWS Bedrock provides access to frontier models (Claude, Amazon Nova,
Llama, DeepSeek etc.) with enterprise-grade security and compliance.
Many teams running AI workloads on AWS infrastructure want to use
Bedrock directly, keeping all traffic within the AWS network.

## Implementation

- Uses Amazon Bedrock's native **Converse API**
(`bedrock-runtime.{region}.amazonaws.com/model/{modelId}/converse`)
- Authentication via **Amazon Bedrock API Key** (`Authorization: Bearer
<key>`) — no SigV4 signing, no extra dependencies
- Config: `apiKey` (Bedrock API key) + `region` (AWS region, default:
`us-east-1`)
- All Bedrock-specific config is declared via the generic
`onboardingFields` mechanism on the provider definition — no
`isAmazonBedrock` branching, no `ProviderConfigData` type changes
- Dynamic model listing via `ListFoundationModels` +
`ListInferenceProfiles` APIs, with fallback to a static list
- Streaming: calls `/converse` (standard JSON response), then re-emits
the full text as `text/event-stream` character-by-character —
bearer-token auth does not support the binary AWS Event Stream protocol
required by `/converse-stream`

## Supported Models

**Anthropic Claude (via Bedrock)**
- Claude Opus/Sonnet/Haiku 4.x
- Claude Sonnet 3.7 (hybrid reasoning)
- Claude Sonnet 3.5 v2

**Amazon Nova**
- Nova Pro (multimodal)
- Nova Lite (multimodal, low cost)
- Nova Micro (text-only, lowest cost)

**Meta / Others**
- Llama 3.3 70B Instruct
- DeepSeek, Moonshot, Minimax models available via inference profiles

## Authentication

Generate a Bedrock API key in: **AWS Console → Amazon Bedrock → API
Keys**

> Note: Long-term API keys have a 30-day expiry. AWS recommends them for
development/exploration use.

## Notes

⚠️ **CORS in browser**: Like other providers (Anthropic, etc.), direct
browser calls to Bedrock are subject to CORS restrictions. Works out of
the box in Tauri desktop app and Node.js server environments. For
browser use, a CORS proxy is needed.

## Testing

```
pnpm vitest run packages/stage-ui/src/libs/providers/providers/amazon-bedrock/index.test.ts
```

---------
Co-authored-by-agent: 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-22 17:37:29 +00:00
Neko Ayaka ca4c99f074 fix(stage-pages,stage-ui): plugin host update 2026-04-22 14:23:45 +08:00
Neko Ayaka c7cf0c6a47 fix(stage-pages,stage-shared,stage-ui): rollback 3f82942 falsy fix 2026-04-22 14:14:02 +08:00
Iro 3f829421d3 fix(server-runtime): enforce auth & routing safety, fix lifecycle leaks (#1686) 2026-04-22 14:03:16 +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
RainbowBird 8967bbe211 feat(server): add TTS support with per-character billing 2026-04-17 02:59:14 +08:00
Makito 186a70fbc7 fix(stage-pages): replace with vueuse utilities 2026-04-16 01:35:14 +09:00
Neko Ayaka f286464e03 chore(deps): bump dependencies 2026-04-15 14:44:59 +08:00
Makito bcd89786a0 fix(stage-pages,stage-shared,stage-ui): auto fit IO tracer 2026-04-15 02:56:04 +09:00
Makito a620c2395b feat(stage-tamagotchi,i18n,stage-pages): localize IO Tracer title and update route metadata 2026-04-15 02:17:10 +09:00
Makito b0b48840ec feat(stage-tamagotchi,stage-pages): initialize IO trace viewer 2026-04-15 02:17:10 +09: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
Lulu bc94ba480b fix(stage-pages): allow clearing OpenAI-compatible speech model field (#1644) 2026-04-13 13:55:00 +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
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
Neko Ayaka fb3f54699b chore(18n): unified to use sign in / sign out 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 160176b33a fix(stage-*): qr should have dark mode adapted, connection component moved 2026-04-08 01:06:40 +08:00
LemonNeko 7690dc08c9 feat(stage-pocket-ios): websocket bridge 2026-04-06 23:39:54 +08:00
LemonNeko a713929447 fix(stage-pocket): should not reset to default value when entering connections page 2026-04-06 19:37:54 +08:00
Neko Ayaka 476ef2018f style: many typescript v6 pending errors 2026-04-05 02:07:09 +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
a8441ba17d fix(stage-pages): XSS vulnerability in provider definition (#1492)
Authored-by-agent: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: shinohara-rin <25588514+shinohara-rin@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Neko <neko@ayaka.moe>
2026-04-01 23:18:02 +08:00
Neko Ayaka d391fad92c fix(stage-ui): save button always visible 2026-03-31 16:24:06 +08:00
Neko 447d718030 fix(stage-ui,stage-tamagotchi): bring back i18n, improved settings data ui (#1525)
* fix(stage-ui,stage-tamagotchi): bring back i18n, improved settings data ui

* fix(stage-layouts): extra height / top
2026-03-31 08:17:29 +08:00
Neko Ayaka 44ec5e416c fix(stage-pages): duplicated settings header 2026-03-30 22:12:44 +08:00
Stardust 7ad4debe11 feat(ui,stage-ui,stage-pages,i18n): transcription confidence filter (#1148) 2026-03-30 03:40:49 +08:00
MisakaKumomi 御坂云见 372695458e refactor: replace status check string literal with enum; add chat pin… (#1486)
* refactor: replace status check string literal with enum; add chat ping check option in provider configurations for anthropic, and if it's good, generalize to all openai based provider

* fix: merging conflicts

* refactor: remove manual validation logic and deprecated ProviderValidationAlerts component

* docs: mark 'Health' enum as deprecated with additional usage context

* feat: add manual test validation flow back

* refactor: reintroduce and integrate `ProviderValidationAlerts` component for streamlined validation logic

* chore: mark error msg

* refactor: extract `CHAT_COMPLETIONS_VALIDATOR_ID` constant; enforce skipping chat ping check in background validations

* chore: comments
2026-03-29 13:22:15 +08:00
Neko Ayaka 3007b265c6 fix(stage-ui): apply FieldCombobox layout style 2026-03-29 02:38:12 +08:00
LemonNeko e2b00e7d28 fix(stage-tamagotchi): persistence for settings of beat sync 2026-03-28 23:51:54 +08:00
RainbowBird 4673494e73 chore: cleanup 2026-03-28 02:25:44 +08:00
RainbowBird 87d3d65b6a refactor(billing): rename debitFlux to consumeFluxForLLM and enhance metadata handling 2026-03-28 02:25:44 +08:00
RainbowBird aed2265d4a fix(stage-pages): flux page display 2026-03-28 02:25:44 +08:00
RainbowBird 405904183f refactor(server): revert a8f445a17985a90d7eb5d981b4231114c3066e94 2026-03-28 02:25:44 +08:00
RainbowBird ba3d66de86 feat(server-protocol): introduce shared protocol types for AIRI server clients and frontends
- Added package.json for @proj-airi/server-protocol with necessary configurations.
- Implemented chat event types including WireMessage, SendMessagesRequest, and PullMessagesRequest.
- Defined WebSocket event types and structures for better integration with AIRI components.
- Updated server-runtime and server-sdk to utilize the new server-protocol package.
- Refactored imports across various packages to replace server-shared types with server-protocol types.
- Enhanced type definitions and added TypeScript configurations for better development experience.
2026-03-28 02:25:44 +08:00
RainbowBird 9b8d1f6ab7 feat(server): flux aduit (#1482) 2026-03-28 02:25:44 +08:00
RainbowBird e30eba8c71 fix(stage-*): onboarding issues 2026-03-28 02:25:44 +08:00
RainbowBird 302c5cd618 fix(stage-pages): fetch credits in flux page 2026-03-28 02:25:44 +08:00
RainbowBird 82a4ea26dd refactor(stage-ui): unify official provider to plug-able, add auth lifecycle hooks 2026-03-28 02:25:44 +08:00
RainbowBird 0f9ea751e5 feat(server): official provider router (#1117) 2026-03-28 02:25:44 +08:00
RainbowBird a64446fbb7 feat(server): enhance config guard with custom error messages and add FLUX_PACKAGES handling 2026-03-28 02:25:44 +08:00
RainbowBird fc51738209 feat(server): stripe integration and credits system (#1024) 2026-03-28 02:25:44 +08:00
RainbowBird b0576d3b89 chore(deps): move eventa to catalog 2026-03-26 21:45:01 +08:00
Neko Ayaka e1b0040a95 refactor(ui,stage-*): now Select component is ComboboxSelect 2026-03-26 19:18:15 +08:00