chore: cleanup

This commit is contained in:
RainbowBird
2026-03-28 02:25:44 +08:00
committed by RainbowBird
parent 87d3d65b6a
commit 4673494e73
26 changed files with 65 additions and 55 deletions
-7
View File
@@ -1,13 +1,6 @@
import { resolve } from 'node:path'
import { defineConfig } from 'vitest/config'
export default defineConfig({
resolve: {
alias: {
'@proj-airi/server-sdk-shared': resolve(import.meta.dirname, '..', '..', 'packages', 'server-sdk-shared', 'src', 'index.ts'),
},
},
test: {
environment: 'node',
globals: true,
+1
View File
@@ -42,6 +42,7 @@
"dependencies": {
"@moeru/eventa": "catalog:",
"@proj-airi/plugin-protocol": "workspace:*",
"@proj-airi/server-shared": "workspace:*",
"nanoid": "catalog:",
"valibot": "^1.3.1",
"xstate": "^5.28.0"
-1
View File
@@ -38,7 +38,6 @@
},
"dependencies": {
"@moeru/std": "catalog:",
"@proj-airi/server-sdk-shared": "workspace:^",
"@proj-airi/server-shared": "workspace:^",
"crossws": "^0.4.4",
"superjson": "catalog:"
-1
View File
@@ -1 +0,0 @@
export * from '@proj-airi/server-sdk-shared'
-1
View File
@@ -1,4 +1,3 @@
export * from './client'
export * from './events/chat'
export type * from '@proj-airi/server-shared/types'
export { ContextUpdateStrategy, WebSocketEventSource } from '@proj-airi/server-shared/types'
-14
View File
@@ -4,20 +4,8 @@
"lib": [
"ESNext"
],
"baseUrl": ".",
"module": "ESNext",
"moduleResolution": "bundler",
"paths": {
"@proj-airi/server-shared": [
"../server-shared/src/index.ts"
],
"@proj-airi/server-shared/*": [
"../server-shared/src/*"
],
"@proj-airi/server-sdk-shared": [
"../server-sdk-shared/src/index.ts"
]
},
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
@@ -25,8 +13,6 @@
"skipLibCheck": true
},
"include": [
"../server-shared/src/**/*.ts",
"../server-sdk-shared/src/**/*.ts",
"src/**/*.ts"
]
}
+43 -2
View File
@@ -1,6 +1,6 @@
# @proj-airi/server-shared
Server-side shared utilities for AIRI runtimes.
The shared type definitions for all server-side packages of Project AIRI.
## Usage
@@ -12,9 +12,50 @@ npm i @proj-airi/server-shared -D
```
```typescript
import { parseServerErrorMessage } from '@proj-airi/server-shared'
import type { WebSocketEvents } from '@proj-airi/server-shared'
```
## How to use the events in distributed use cases?
### Scenarios
#### Minecraft agent
##### 1. Urgent combat (witch attack)
- Minecraft sends `spark:notify` (kind=alarm, urgency=immediate, payload hp/location/gear, destinations=["character"]).
- Character `spark:emit` working ("Seen it").
- Character issues `spark:command` with interrupt=force and options (retreat vs push).
- Minecraft `spark:emit` working ("Pillared up; healing") then done/blocked as it executes.
- Optional `context:update` for summary/memory.
##### 2. Prep plan (Ender Dragon)
- Discord/user intent triggers character `spark:command` to Minecraft (intent=plan, interrupt=soft, steps gather beds/pots/gear, fallback).
- Optional `context:update` with tips (lane='game').
- Minecraft streams `spark:emit` progress.
- If ambushed, Minecraft raises new `spark:notify` (alarm/immediate) to preempt.
- Character revises with another `spark:command`.
- Completion via `spark:emit` done + summary note.
##### 3. Routine nudge
- Minecraft signals low food via `spark:notify` (kind=reminder, urgency=soon, destinations=["character"]).
- Character defers to next tick and sends `spark:command` (interrupt=soft, intent=plan: "gather food nearby").
- Minecraft `spark:emit` queued/working then done.
##### 4. Multi-step command while researching (plan + live control)
> [!NOTE]
> Using `intent=plan` keeps the loop alive even with un-finalized ideas—similar to TODO scaffolding in coding agents—while richer guidance is still being researched.
- Character receives a user goal (e.g., fortify base) and issues an initial `spark:command` to Minecraft (interrupt=soft, intent=plan, steps to gather materials) so the agent keeps working.
- Character simultaneously performs memory/search/design tasks outside the game loop (wiki lookup, prior notes).
- As insights arrive, character sends `context:update` (lane='game', hints/ideas) to enrich the sub-agent without preemption.
- If an urgent event occurs during prep, Minecraft raises `spark:notify` (alarm) → character responds with a short `spark:emit` working and a `spark:command` (interrupt=force) to handle it (e.g., retreat, block up).
- Once design is ready, character sends a refined `spark:command` (`intent=proposal` (or `action`), `interrupt=soft`) with structured options/steps/fallbacks.
- Minecraft streams `spark:emit` progress; when complete, character summarizes via `spark:emit` or `context:update` for memory.
## License
[MIT](../../LICENSE)
-1
View File
@@ -27,7 +27,6 @@
"@proj-airi/ccc": "workspace:*",
"@proj-airi/i18n": "workspace:*",
"@proj-airi/server-sdk": "workspace:*",
"@proj-airi/server-shared": "workspace:*",
"@proj-airi/stage-ui": "workspace:*",
"@proj-airi/stage-ui-live2d": "workspace:*",
"@proj-airi/stage-ui-three": "workspace:*",
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ContextUpdateStrategy } from '@proj-airi/server-shared/types'
import { ContextUpdateStrategy } from '@proj-airi/server-sdk'
import { Section } from '@proj-airi/stage-ui/components'
import { Button, FieldInput, FieldTextArea, SelectTab } from '@proj-airi/ui'
@@ -1,4 +1,4 @@
import type { WebSocketEvents } from '@proj-airi/server-shared/types'
import type { WebSocketEvents } from '@proj-airi/server-sdk'
import type { FlowEntry, PreviewItem } from '../context-flow-types'
@@ -1,4 +1,4 @@
import type { WebSocketEvents } from '@proj-airi/server-shared/types'
import type { WebSocketEvents } from '@proj-airi/server-sdk'
type Optional<T> = T | undefined
@@ -1,11 +1,11 @@
<script setup lang="ts">
import type { WebSocketBaseEvent, WebSocketEventOf, WebSocketEvents } from '@proj-airi/server-shared/types'
import type { WebSocketBaseEvent, WebSocketEventOf, WebSocketEvents } from '@proj-airi/server-sdk'
import type { ChatStreamEvent, ContextMessage } from '@proj-airi/stage-ui/types/chat'
import type { FlowDirection, FlowEntry, SparkNotifyEntryState } from './context-flow-types'
import { errorMessageFrom } from '@moeru/std'
import { ContextUpdateStrategy } from '@proj-airi/server-shared/types'
import { ContextUpdateStrategy } from '@proj-airi/server-sdk'
import { useCharacterOrchestratorStore, useCharacterStore } from '@proj-airi/stage-ui/stores/character'
import { useChatOrchestratorStore } from '@proj-airi/stage-ui/stores/chat'
import { CHAT_STREAM_CHANNEL_NAME, CONTEXT_CHANNEL_NAME } from '@proj-airi/stage-ui/stores/chat/constants'
-1
View File
@@ -70,7 +70,6 @@
"@proj-airi/model-driver-lipsync": "workspace:^",
"@proj-airi/pipelines-audio": "workspace:^",
"@proj-airi/server-sdk": "workspace:^",
"@proj-airi/server-shared": "workspace:^",
"@proj-airi/stage-shared": "workspace:^",
"@proj-airi/stage-ui-live2d": "workspace:^",
"@proj-airi/stage-ui-three": "workspace:^",
+1
View File
@@ -23,6 +23,7 @@ export function initializeAuth() {
export async function fetchSession() {
const { data } = await authClient.getSession()
const authStore = useAuthStore()
if (data) {
authStore.user = data.user
authStore.session = data.session
@@ -1,4 +1,4 @@
import type { WebSocketEventOf, WebSocketEvents } from '@proj-airi/server-shared/types'
import type { WebSocketEventOf, WebSocketEvents } from '@proj-airi/server-sdk'
import type { ChatProvider, ChatProviderWithExtraOptions, EmbedProvider, EmbedProviderWithExtraOptions, SpeechProvider, SpeechProviderWithExtraOptions, TranscriptionProvider, TranscriptionProviderWithExtraOptions } from '@xsai-ext/providers/utils'
import type { Message } from '@xsai/shared-chat'
@@ -1,7 +1,7 @@
/* eslint-disable style/indent-binary-ops */
/* eslint-disable style/operator-linebreak */
import type { WebSocketEventOf } from '@proj-airi/server-shared/types'
import type { WebSocketEventOf } from '@proj-airi/server-sdk'
import type { Store, StoreDefinition } from 'pinia'
import type { Mock } from 'vitest'
import type { UnwrapRef } from 'vue'
@@ -1,4 +1,4 @@
import type { WebSocketBaseEvent, WebSocketEventOf, WebSocketEvents } from '@proj-airi/server-shared/types'
import type { WebSocketBaseEvent, WebSocketEventOf, WebSocketEvents } from '@proj-airi/server-sdk'
import { defineStore, storeToRefs } from 'pinia'
import { ref } from 'vue'
+1 -1
View File
@@ -1,4 +1,4 @@
import type { WebSocketEventInputs } from '@proj-airi/server-shared/types'
import type { WebSocketEventInputs } from '@proj-airi/server-sdk'
import type { ChatProvider } from '@xsai-ext/providers/utils'
import type { CommonContentPart, Message, ToolMessage } from '@xsai/shared-chat'
@@ -1,6 +1,6 @@
import type { ContextMessage } from '../../../types/chat'
import { ContextUpdateStrategy } from '@proj-airi/server-shared/types'
import { ContextUpdateStrategy } from '@proj-airi/server-sdk'
import { nanoid } from 'nanoid'
const DATETIME_CONTEXT_ID = 'system:datetime'
@@ -1,6 +1,6 @@
import type { ContextMessage } from '../../types/chat'
import { ContextUpdateStrategy } from '@proj-airi/server-shared/types'
import { ContextUpdateStrategy } from '@proj-airi/server-sdk'
import { defineStore } from 'pinia'
import { ref, toRaw } from 'vue'
@@ -1,4 +1,4 @@
import type { WebSocketEvent } from '@proj-airi/server-shared/types'
import type { WebSocketEvent } from '@proj-airi/server-sdk'
import { nanoid } from 'nanoid'
import { defineStore } from 'pinia'
@@ -1,8 +1,7 @@
import type { ContextUpdate, InputContextUpdate, WebSocketBaseEvent, WebSocketEvent, WebSocketEventOptionalSource, WebSocketEvents } from '@proj-airi/server-shared/types'
import type { ContextUpdate, InputContextUpdate, WebSocketBaseEvent, WebSocketEvent, WebSocketEventOptionalSource, WebSocketEvents } from '@proj-airi/server-sdk'
import type { CommonContentPart } from '@xsai/shared-chat'
import { Client } from '@proj-airi/server-sdk'
import { WebSocketEventSource } from '@proj-airi/server-shared/types'
import { Client, WebSocketEventSource } from '@proj-airi/server-sdk'
import { isStageTamagotchi, isStageWeb } from '@proj-airi/stage-shared'
import { useLocalStorage } from '@vueuse/core'
import { nanoid } from 'nanoid'
@@ -2,7 +2,7 @@ import type { CommonContentPart } from '@xsai/shared-chat'
import type { VisionWorkloadId } from '../../../composables/vision/use-vision-workloads'
import { ContextUpdateStrategy } from '@proj-airi/server-shared/types'
import { ContextUpdateStrategy } from '@proj-airi/server-sdk'
import { defineStore, storeToRefs } from 'pinia'
import { ref } from 'vue'
+1 -1
View File
@@ -1,4 +1,4 @@
import type { ContextUpdate, MetadataEventSource, WebSocketEventInputs } from '@proj-airi/server-shared/types'
import type { ContextUpdate, MetadataEventSource, WebSocketEventInputs } from '@proj-airi/server-sdk'
import type { AssistantMessage, CommonContentPart, CompletionToolCall, Message, SystemMessage, ToolMessage, UserMessage } from '@xsai/shared-chat'
export interface ChatSlicesText {
+1 -1
View File
@@ -1,4 +1,4 @@
import type { MetadataEventSource } from '@proj-airi/server-shared/types'
import type { MetadataEventSource } from '@proj-airi/server-sdk'
interface EventSourcePayload {
source?: string
+3 -9
View File
@@ -2233,6 +2233,9 @@ importers:
'@proj-airi/plugin-protocol':
specifier: workspace:*
version: link:../plugin-protocol
'@proj-airi/server-shared':
specifier: workspace:*
version: link:../server-shared
nanoid:
specifier: 'catalog:'
version: 5.1.6
@@ -2281,9 +2284,6 @@ importers:
'@moeru/std':
specifier: 'catalog:'
version: 0.1.0-beta.17
'@proj-airi/server-sdk-shared':
specifier: workspace:^
version: link:../server-sdk-shared
'@proj-airi/server-shared':
specifier: workspace:^
version: link:../server-shared
@@ -2426,9 +2426,6 @@ importers:
'@proj-airi/server-sdk':
specifier: workspace:*
version: link:../server-sdk
'@proj-airi/server-shared':
specifier: workspace:*
version: link:../server-shared
'@proj-airi/stage-ui':
specifier: workspace:*
version: link:../stage-ui
@@ -2608,9 +2605,6 @@ importers:
'@proj-airi/server-sdk':
specifier: workspace:^
version: link:../server-sdk
'@proj-airi/server-shared':
specifier: workspace:^
version: link:../server-shared
'@proj-airi/stage-shared':
specifier: workspace:^
version: link:../stage-shared