按 DevDocs/design/22 §4.6/§5(7) 实现(后端由并行代理在做,按已定契约先行)。
- currentPersona 由「全局单值」改为「跟随激活会话」:新增 lib/sessionPersona.ts 解析(personaId 空 → 回落默认角色),App/TopBar/chat/lib/persona.ts 全部改为按激活会话取角色(头像/背景/名字/心情随会话切换)
- 交互:新建次级会话可选角色;会话换角色入口;管理面板 Sessions 页加「挂角色」下拉(走 PATCH /sessions/{id})
- 组件拆分:Nav.tsx 228→143(抽出 NavItem.tsx 53)、新增 SessionRail.tsx 275(会话侧栏)
- 契约:types.ts / lib/api/sessions.ts 加 personaId?(建会话/改会话支持)
- mood 改为**按角色分桶**(同一角色的多个会话共享该角色心情);升级后旧 mood 值不保留(刷新即空)——属行为变化,已在报告注明
- 测试:新增 personaSession.test.ts 40 checks(角色解析/回落/乐观更新与回滚)+ 既有 messageSync 54 checks 回归
- 验收:npm run build 绿;**未做浏览器端到端**(无 jsdom/渲染测试底座),UI 交互与失败路径提示未渲染验证
- 已知余量:useAppStore.ts 494/500 行(下次改动前应先拆 selectCurrentPersona/useCurrentPersona/useCurrentMood)
116 lines
2.8 KiB
TypeScript
116 lines
2.8 KiB
TypeScript
/**
|
|
* Public REST surface for the Cyrene v2 gateway, kept as a single import path
|
|
* (`lib/api`) so call sites never change. The implementation is split by domain
|
|
* under `lib/api/`:
|
|
*
|
|
* core.ts transport (request/ApiError) + token/role/API-key state
|
|
* auth.ts /auth/login, /health
|
|
* chat.ts /chat (sync + streaming)
|
|
* sessions.ts /sessions (list/create/delete, message history)
|
|
* messages.ts /messages/{id} (PATCH edit / DELETE)
|
|
* personas.ts /personas
|
|
* admin.ts /admin/* CRUD (personas, users, llm, rag, iot, automations…)
|
|
* adminChannels.ts /admin/channels/* (adapters, config, platform views, login)
|
|
* adminSystem.ts /admin/observability|notifications|backthink|system/*
|
|
*
|
|
* Everything below is a verbatim re-export — behaviour is unchanged.
|
|
*/
|
|
|
|
export {
|
|
ApiError,
|
|
decodeJwtRole,
|
|
getApiKey,
|
|
getAuthToken,
|
|
getStoredRole,
|
|
isNotImplemented,
|
|
isTokenExpired,
|
|
onAuthExpired,
|
|
setApiKey,
|
|
setAuthToken,
|
|
setStoredRole,
|
|
} from "./api/core";
|
|
|
|
export { health, login } from "./api/auth";
|
|
|
|
export { chatStream, chatSync } from "./api/chat";
|
|
|
|
export {
|
|
createSubSession,
|
|
deleteSession,
|
|
fetchMessages,
|
|
fetchSessions,
|
|
markSessionRead,
|
|
patchSession,
|
|
} from "./api/sessions";
|
|
export type { CreateSessionResult, MessageDto, SessionPatch } from "./api/sessions";
|
|
|
|
export { deleteMessage, patchMessage } from "./api/messages";
|
|
|
|
export { fetchPersonas } from "./api/personas";
|
|
|
|
export {
|
|
adminAddLlmProvider,
|
|
adminAddMemory,
|
|
adminCreateAutomation,
|
|
adminCreatePersona,
|
|
adminCreateUser,
|
|
adminDeleteAutomation,
|
|
adminDeleteRag,
|
|
adminExportSession,
|
|
adminGetLlm,
|
|
adminIndexRag,
|
|
adminIoTControl,
|
|
adminIoTRule,
|
|
adminIoTScenario,
|
|
adminIssueApiKey,
|
|
adminListAutomations,
|
|
adminListChannels,
|
|
adminListInstalledPlugins,
|
|
adminListIoT,
|
|
adminListMemories,
|
|
adminListPersonas,
|
|
adminListPlugins,
|
|
adminListRag,
|
|
adminListSessions,
|
|
adminListUsers,
|
|
adminMemorySearch,
|
|
adminPluginInstall,
|
|
adminPluginUninstall,
|
|
adminRevokeApiKey,
|
|
adminRunAutomation,
|
|
adminSearchRag,
|
|
adminSetPluginPolicy,
|
|
adminTestLlm,
|
|
adminUpdatePersona,
|
|
} from "./api/admin";
|
|
|
|
export {
|
|
adminChannelClose,
|
|
adminChannelFriendHandle,
|
|
adminChannelLogOverview,
|
|
adminChannelMessageTest,
|
|
adminChannelMessages,
|
|
adminChannelOpen,
|
|
adminChannelPlatformFriends,
|
|
adminChannelPlatformView,
|
|
adminChannelTest,
|
|
adminDeleteChannelAccount,
|
|
adminSaveChannelConfig,
|
|
adminWeixinLoginQR,
|
|
adminWeixinLoginStatus,
|
|
} from "./api/adminChannels";
|
|
export type { ChannelConfigSaveResult } from "./api/adminChannels";
|
|
|
|
export {
|
|
adminBackthink,
|
|
adminListNotifications,
|
|
adminObservabilityAudit,
|
|
adminObservabilityLogs,
|
|
adminObservabilityMetrics,
|
|
adminObservabilityTrace,
|
|
adminSystemBackup,
|
|
adminSystemRestore,
|
|
adminSystemRevokeKeys,
|
|
adminSystemRotateJWT,
|
|
} from "./api/adminSystem";
|