Files
moeka-project/integrations/satori-bot
fd8b7a0ae3 feat(core-agent): bump xsai / remove patches (#2164)
## Summary

- Bump catalog `@xsai/*`, `@xsai-ext/providers`, and `xsschema` to
**0.5.0-beta.8**, and delete the three `@xsai/*` pnpm patches — the
beta.2 ones from #1602 and the beta.8 regenerations that landed on main
in `38a008500`.
- Always capture tool failures on the core-agent chat path: xsAI beta.8
marks failed tool executions with `isError: true` on `tool-result.done`,
and `llm-service.ts` maps that to AIRI's `tool-error` event via
`toAiriStreamEvent`, so the agent loop continues instead of aborting.
- Remove the `captureToolErrors` request flag (and stop forwarding it
into `streamText`).
- Rebased onto latest `main` (`b230e16b2`). Includes one follow-up fix:
steps are marked settled before the finish listener runs, and finish
listener failures still reject the stream.

### Related

- Supersedes / follows up on
[#1602](https://github.com/moeru-ai/airi/pull/1602) (`captureToolErrors`
+ xsai patches).

### Scope of capture

| Case | Covered |
| --- | --- |
| A — unknown tool | yes |
| B — invalid / unparseable arguments JSON | yes |
| C — `validate` failure | yes |
| D — `execute` throw | yes |
| `missing_name` / `missing_arguments` | no (xsai still aborts) |
| `repairToolCall` | no |

Error copy on beta.8: `Tool "<toolName>" execution failed: …` (produced
by xsAI).

## Test plan

### Automated (Vitest)

- [x] core-agent `llm-service.test.ts` — 16/16
- [x] core-agent full suite — 82/82
- [x] stage-ui `llm.test.ts` + `chat.contract.test.ts` — 44/44 (the
previous `stepsSettled` timing failure is fixed in this branch)
- [x] stage-ui full suite — 594 passed / 0 failed (one
browser-test-runner teardown error, not a test failure)
- [x] typecheck — core-agent, stage-ui, component-calling, satori-bot
pass; telegram-bot fails only at `src/utils/velin.ts`, which is
pre-existing on main and untouched by this PR

### Real-environment E2E (rebase branch, DeepSeek V4 Flash via DeepSeek
API)

Harness: `/Users/lulu/GitHub/airi-e2e/pr2164/tool-error-e2e-rebase.mjs`
— drives the built `core-agent` `streamFrom` with a deliberately failing
tool.

| Case | Result | Evidence |
| --- | --- | --- |
| D — execute throw | **pass** | `tool-error` carried `Tool
"always_fail" execution failed: boom: deterministic tool failure`; the
model answered: "The always_fail tool threw a deterministic error as
expected." |
| A — unknown tool | **pass** | The model called the unavailable
`search_the_moon_database` after being told truthfully that this tests
AIRI's error capture; runtime returned `tool-error` and the conversation
continued. |
| B — bad arguments JSON | not observed on real model | providers rarely
emit invalid `arguments`; covered by unit test |
| C — `validate` failure | pass (earlier manual run with a temporary
validate-gated tool) | — |

Evidence artifacts:
`/Users/lulu/GitHub/airi-e2e/artifacts/pr2164/tool-error-e2e-2026-08-10T16-49-15-384Z.{json,log}`

### Notes / non-goals

- Fallout-only updates for the xsai beta.8 API rename: `textStream`,
`inputTokens` / `outputTokens` / `totalTokens` in component-calling /
telegram / satori.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-11 17:51:15 +08:00
..

AIRI Satori Bot

⚠️ Disclaimer: This is a submodule of AIRI. The core part of this satori bot is merely a temporary solution. We will eventually delete it and integrate with AIRI's Core once the main framework is stable.

A STANDALONE, event-driven AI agent built on the Satori Protocol. It connects to multiple chat platforms (QQ, Telegram, Discord, Lark) via a Koishi bridge, featuring an autonomous thought loop.

🏗 Architecture & Internals (Provisional)

Important: This module currently implements a self-contained "Mini-Core" (src/core/) to operate independently. This is NOT the final architecture of AIRI.

  • Temporary Logic: The Event Loop, Scheduler, and Planner logic located in src/core/ are placeholders. They simulate the behavior of the future AIRI Core.
  • Retained Components: The Dispatcher and Database will be retained. They will be exposed as tool-like modules to the AIRI Core for action execution and state persistence.
  • Future Migration: Once the main AIRI Core is ready, the src/core/ directory (specifically the loop/planning logic) will be removed. This module will then be refactored to strictly function as an Adapter (Satori Protocol handling) and Capability Provider (Actions), delegating the cognitive loop to the main AIRI process.

For the current standalone version, please refer to these documents:

  • HANDLER.md: Explains the current Event-to-Action Flow (Queue -> Scheduler -> LLM).
  • PERSISTENCE.md: Details the current Memory-First state management strategy specific to this temporary core.

Key Code Paths:

  • Loop & Logic (Temporary): src/core/
  • Adapter (Permanent): src/adapter/satori/
  • Capabilities (Permanent): src/capabilities/

Prerequisites

  • Node.js >= 18.0.0
  • pnpm >= 8.0.0
  • Koishi Instance: Running the server-satori plugin.
  • LLM Provider: OpenAI compatible API (Ollama, vLLM, DeepSeek, etc.).

Quick Start

  1. Install Dependencies
pnpm install
  1. Configure Environment Copy the example config and edit it:
cp .env .env.local

Key Variables:

# Satori Configuration
SATORI_WS_URL=ws://localhost:5140/satori/v1/events
SATORI_API_BASE_URL=http://localhost:5140/satori/v1
SATORI_TOKEN= # Optional: Leave empty if auth is disabled in Koishi

# LLM (OpenAI Compatible)
LLM_API_KEY=your_api_key_here
LLM_API_BASE_URL=https://api.openai.com/v1
LLM_MODEL=gpt-4
LLM_RESPONSE_LANGUAGE=English
LLM_OLLAMA_DISABLE_THINK=false
  1. Run
# Development (Hot-reload)
pnpm --filter @proj-airi/satori-bot dev

# Production
pnpm --filter @proj-airi/satori-bot start

Key Locations

  • Persona & System Prompts: src/core/planner/prompts/*.velin.md
  • Database (PGlite): data/pglite-db (See PERSISTENCE.md for architecture)
  • Action Logic: src/capabilities/actions/