* fix(server): keep vendor chat fields off foreign endpoints and strip reasoning from responses * fix(engine): strip inline reasoning from polished text and assistant responses * fix(server): never block the voice control loop with modal dialogs * feat(server): provider registry for AI assistant with mainstream provider presets * feat(ui-html): settings pages for the provider registry, model fetch everywhere and new ASR providers * test(server): vendor detection, reasoning strip, provider store and expanded provider defaults * fix(server): keep the voice overlay dismissible at all times * fix(server,ui-html,installer): 服务商注册表与语音收尾的评审修正 - 加载配置时先读 ai_providers.json 再校验当前服务商,用户添加的服务商不再被重置为 deepseek - Token 不再明文写进 ai_providers.json,统一存为 config.toml 的 token_<id>(DPAPI 加密、升级时按凭证保留);旧文件里的明文 token 读取时清掉 - 配置重载同时检查 ai_providers.json 的修改时间,只改注册表也能同步到 Server - 删除当前服务商时按切换服务商的流程更新 token、地址和模型 - 内置服务商列表收敛到 ProviderStore::BuiltinProviderIds 一处,新增的六个预置服务商同样以 config.toml 为准;去掉未使用的 MakeProviderId,前端生成 id 时避开内置 id - 出厂模板和开发配置补上六个新预置服务商的 token_/endpoint_/model_ 键 - 录音回调失败时走完整的取消收尾,恢复系统静音并关闭豆包连接;删除不可达的第二段 Esc 处理 - 语音转写地址查询模型时正确推出 /models - 设置页补上语音识别和润色的 Custom 选项、新预置服务商的显示名,修正添加服务商的地址提示 --------- Co-authored-by: alayahbridge319-boop <246594988+alayahbridge319-boop@users.noreply.github.com> Co-authored-by: fanlusky <1730976608@qq.com>
125 lines
13 KiB
TypeScript
125 lines
13 KiB
TypeScript
// Generated by generate.py; edit messages.json.
|
|
import './schema.js';
|
|
import './runtime.js';
|
|
export type ClientMessage =
|
|
| { "type": "configRequest"; "protocolVersion"?: 1 }
|
|
| { "type": "skinCatalogRequest"; "protocolVersion"?: 1 }
|
|
| { "type": "openSkinDirectory"; "protocolVersion"?: 1 }
|
|
| { "type": "openHelpcodeDirectory"; "protocolVersion"?: 1 }
|
|
| { "type": "openShuangpinDirectory"; "protocolVersion"?: 1 }
|
|
| { "type": "collocationModelDownload"; "protocolVersion"?: 1; "data": { "modelId": string } }
|
|
| { "type": "collocationModelDelete"; "protocolVersion"?: 1; "data": { "modelId": string } }
|
|
| { "type": "collocationModelImport"; "protocolVersion"?: 1; "data": { "modelId": string } }
|
|
| { "type": "collocationModelStatusRequest"; "protocolVersion"?: 1 }
|
|
| { "type": "neuralModelDownload"; "protocolVersion"?: 1 }
|
|
| { "type": "neuralModelImport"; "protocolVersion"?: 1 }
|
|
| { "type": "neuralModelDelete"; "protocolVersion"?: 1 }
|
|
| { "type": "neuralModelStatusRequest"; "protocolVersion"?: 1 }
|
|
| { "type": "openHandwritingPanel"; "protocolVersion"?: 1 }
|
|
| { "type": "restartServer"; "protocolVersion"?: 1 }
|
|
| { "type": "copyText"; "protocolVersion"?: 1; "data": string }
|
|
| { "type": "openExternalUrl"; "protocolVersion"?: 1; "data": string }
|
|
| { "type": "dragStart"; "protocolVersion"?: 1 }
|
|
| { "type": "focus"; "protocolVersion"?: 1 }
|
|
| { "type": "resizeStart"; "protocolVersion"?: 1; "data": "left" | "right" | "top" | "bottom" | "left-top" | "right-top" | "left-bottom" | "right-bottom" | "client" }
|
|
| { "type": "resizeHitTest"; "protocolVersion"?: 1; "data": "left" | "right" | "top" | "bottom" | "left-top" | "right-top" | "left-bottom" | "right-bottom" | "client" }
|
|
| { "type": "windowControl"; "protocolVersion"?: 1; "data": "minimize" | "maximize" | "restore" | "close" }
|
|
| { "type": "maximizeButtonRect"; "protocolVersion"?: 1; "data": { "x": number; "y": number; "width": number; "height": number; "dpr": number } }
|
|
| { "type": "configUpdate"; "protocolVersion"?: 1; "data": { "path": string; "value": string | number | boolean } }
|
|
| { "type": "apiCredentialTest"; "protocolVersion"?: 1; "data": { "requestId": string; "service": "translation.tencent" | "translation.niutrans" | "translation.custom" | "translation.ai" | "voice.asr" | "voice.polish" | "ai.assistant"; "config": { [key: string]: unknown } } }
|
|
| { "type": "apiModelList"; "protocolVersion"?: 1; "data": { "requestId": string; "service": "ai.assistant" | "voice.asr" | "voice.polish"; "config": { [key: string]: unknown } } }
|
|
| { "type": "aiProviderSync"; "protocolVersion"?: 1; "data": { "requestId": string; "entries": Array<{ "id": string; "name": string; "endpoint": string; "token": string; "model": string }> } }
|
|
| { "type": "dictionaryRequest"; "protocolVersion"?: 1; "data": { "requestId": string; "dictionary": "quanpin" | "wubi" | "english" | "quick"; "action": "query" | "create" | "update" | "delete" | "import" | "importHans" | "export"; "word"?: string; "code"?: string; "content"?: string; "weight"?: number; "oldWord"?: string; "oldCode"?: string; "display"?: string; "oldDisplay"?: string; "offset"?: number; "limit"?: number } }
|
|
| { "type": "statsRequest"; "protocolVersion"?: 1; "data": { "requestId": string; "action": "overview" | "clearAll" | "openDirectory" } }
|
|
| { "type": "defaultImeRequest"; "protocolVersion"?: 1; "data": { "requestId": string; "action": "status" | "setDefault" | "openSystemSettings" } }
|
|
| { "type": "gameCompatRequest"; "protocolVersion"?: 1; "data": { "requestId": string; "action": "status" | "apply"; "enabled"?: boolean; "name"?: string } }
|
|
| { "type": "openKeyboardPanel"; "protocolVersion"?: 1 }
|
|
| { "type": "candidate"; "protocolVersion"?: 1; "data": number }
|
|
| { "type": "delete"; "protocolVersion"?: 1; "data": number }
|
|
| { "type": "pin"; "protocolVersion"?: 1; "data": number }
|
|
| { "type": "clearPosition"; "protocolVersion"?: 1; "data": number }
|
|
| { "type": "candidateWheel"; "protocolVersion"?: 1; "data": number }
|
|
| { "type": "candidatePage"; "protocolVersion"?: 1; "data": "previous" | "next" }
|
|
| { "type": "fixPosition"; "protocolVersion"?: 1; "data": { "index": number; "position": number } }
|
|
| { "type": "contextMenuResize"; "protocolVersion"?: 1; "data": { "width": number; "height": number; "topExpansion"?: number; "leftExpansion"?: number } }
|
|
| { "type": "contextMenuClosed"; "protocolVersion"?: 1 }
|
|
| { "type": "candidatePointerArmed"; "protocolVersion"?: 1 }
|
|
| { "type": "candidatePointerMotion"; "protocolVersion"?: 1 }
|
|
| { "type": "candidateFrameProbe"; "protocolVersion"?: 1; "data": { "revision": number; "stage": number; "performanceMs": number } }
|
|
| { "type": "candidatePointerProbe"; "protocolVersion"?: 1; "data": { "probe": number; "screenX": number; "screenY": number; "clientX": number; "clientY": number; "movementX": number; "movementY": number; "armed": boolean } }
|
|
| { "type": "contentTruncated"; "protocolVersion"?: 1; "data": { "surface": "candidate" | "toolbar" | "menu" | "ftb" | "candwnd" | "cand"; "width": number; "height": number; [key: string]: unknown } }
|
|
| { "type": "floatingToggle"; "protocolVersion"?: 1; "data": boolean }
|
|
| { "type": "settings"; "protocolVersion"?: 1 }
|
|
| { "type": "about"; "protocolVersion"?: 1 }
|
|
| { "type": "emojiSymbols"; "protocolVersion"?: 1 }
|
|
| { "type": "keyboardPanel"; "protocolVersion"?: 1 }
|
|
| { "type": "handwritingPanel"; "protocolVersion"?: 1 }
|
|
| { "type": "voiceInput"; "protocolVersion"?: 1 }
|
|
| { "type": "changeInputScheme"; "protocolVersion"?: 1; "data": "quanpin" | "shuangpin" | "wubi" }
|
|
| { "type": "inputSchemeSubmenu"; "protocolVersion"?: 1; "data": { "open": boolean; "width": number } }
|
|
| { "type": "ready"; "protocolVersion"?: 1 }
|
|
| { "type": "exitEnglishInputMode"; "protocolVersion"?: 1 }
|
|
| { "type": "changeCharacterSet"; "protocolVersion"?: 1 }
|
|
| { "type": "openSettings"; "protocolVersion"?: 1 }
|
|
| { "type": "openEmojiPanel"; "protocolVersion"?: 1 }
|
|
| { "type": "changeIMEMode"; "protocolVersion"?: 1; "data": "cn" | "en" }
|
|
| { "type": "changeCharMode"; "protocolVersion"?: 1; "data": "fullwidth" | "halfwidth" }
|
|
| { "type": "changePuncMode"; "protocolVersion"?: 1; "data": "puncEn" | "puncCn" };
|
|
export type ServerMessage =
|
|
| { "type": "configSnapshot"; "protocolVersion"?: 1; "data": { [key: string]: unknown } }
|
|
| { "type": "windowState"; "protocolVersion"?: 1; "data": { "isMaximized": boolean } }
|
|
| { "type": "maxButtonEvent"; "protocolVersion"?: 1; "data": { "event": "enter" | "leave" | "down" | "up" | "click" } }
|
|
| { "type": "apiCredentialTestResult"; "protocolVersion"?: 1; "requestId": string; "ok": boolean; "message": string }
|
|
| { "type": "defaultImeResponse"; "protocolVersion"?: 1; "requestId": string; "action": string; "ok": boolean; "message": string; "enabled"?: boolean; "isDefault"?: boolean }
|
|
| { "type": "gameCompatResponse"; "protocolVersion"?: 1; "requestId": string; "action": string; "ok": boolean; "message": string; "enabled"?: boolean; "name"?: string; "registeredName"?: string; "defaultName"?: string }
|
|
| { "type": "apiModelListResult"; "protocolVersion"?: 1; "requestId": string; "ok": boolean; "message": string; "models"?: Array<string> }
|
|
| { "type": "aiProviderSyncResult"; "protocolVersion"?: 1; "requestId": string; "ok": boolean; "message": string }
|
|
| { "type": "dictionaryResponse"; "protocolVersion"?: 1; "requestId": string; "action"?: string; "dictionary"?: string; "ok": boolean; "message": string; "rows": Array<{ "word": string; "code"?: string; "display"?: string; "weight"?: number }>; "content"?: string; "filename"?: string; "offset"?: number; "hasMore"?: boolean; [key: string]: unknown }
|
|
| { "type": "statsResponse"; "protocolVersion"?: 1; "requestId": string; "action": string; "ok": boolean; "message": string; "overview"?: { "hasData": boolean; "firstDayKey": number; "lastDayKey": number; "days": number; "totalChars": number; "totalActiveMs": number; "todayDayKey": number; "todayChars": number; "todayActiveMs": number; "averagePerDay": number; "currentStreak": number; "longestStreak": number; "bestDayKey": number; "bestDayChars": number; "todaySpeed": number; "averageSpeed": number; "fastestSpeed": number; "fastestDayKey": number; "todayFirstWordRatio": number | null; "totalFirstWordRatio": number | null; "todayFirstWordTotal": number; "categories": { "cjk": number; "latin": number; "digit": number; "punct": number; "other": number }; "todayHourly": Array<number>; "daily": Array<{ "dayKey": number; "cjk": number; "latin": number; "digit": number; "punct": number; "other": number; "activeMs": number; "firstWordHits": number; "firstWordTotal": number }> }; "removedDays"?: number; [key: string]: unknown };
|
|
export type SettingsMessage =
|
|
| { "type": "configRequest"; "protocolVersion"?: 1 }
|
|
| { "type": "skinCatalogRequest"; "protocolVersion"?: 1 }
|
|
| { "type": "openSkinDirectory"; "protocolVersion"?: 1 }
|
|
| { "type": "openHelpcodeDirectory"; "protocolVersion"?: 1 }
|
|
| { "type": "openShuangpinDirectory"; "protocolVersion"?: 1 }
|
|
| { "type": "collocationModelDownload"; "protocolVersion"?: 1; "data": { "modelId": string } }
|
|
| { "type": "collocationModelDelete"; "protocolVersion"?: 1; "data": { "modelId": string } }
|
|
| { "type": "collocationModelImport"; "protocolVersion"?: 1; "data": { "modelId": string } }
|
|
| { "type": "collocationModelStatusRequest"; "protocolVersion"?: 1 }
|
|
| { "type": "neuralModelDownload"; "protocolVersion"?: 1 }
|
|
| { "type": "neuralModelImport"; "protocolVersion"?: 1 }
|
|
| { "type": "neuralModelDelete"; "protocolVersion"?: 1 }
|
|
| { "type": "neuralModelStatusRequest"; "protocolVersion"?: 1 }
|
|
| { "type": "openHandwritingPanel"; "protocolVersion"?: 1 }
|
|
| { "type": "restartServer"; "protocolVersion"?: 1 }
|
|
| { "type": "copyText"; "protocolVersion"?: 1; "data": string }
|
|
| { "type": "openExternalUrl"; "protocolVersion"?: 1; "data": string }
|
|
| { "type": "dragStart"; "protocolVersion"?: 1 }
|
|
| { "type": "focus"; "protocolVersion"?: 1 }
|
|
| { "type": "resizeStart"; "protocolVersion"?: 1; "data": "left" | "right" | "top" | "bottom" | "left-top" | "right-top" | "left-bottom" | "right-bottom" | "client" }
|
|
| { "type": "resizeHitTest"; "protocolVersion"?: 1; "data": "left" | "right" | "top" | "bottom" | "left-top" | "right-top" | "left-bottom" | "right-bottom" | "client" }
|
|
| { "type": "windowControl"; "protocolVersion"?: 1; "data": "minimize" | "maximize" | "restore" | "close" }
|
|
| { "type": "maximizeButtonRect"; "protocolVersion"?: 1; "data": { "x": number; "y": number; "width": number; "height": number; "dpr": number } }
|
|
| { "type": "configUpdate"; "protocolVersion"?: 1; "data": { "path": string; "value": string | number | boolean } }
|
|
| { "type": "apiCredentialTest"; "protocolVersion"?: 1; "data": { "requestId": string; "service": "translation.tencent" | "translation.niutrans" | "translation.custom" | "translation.ai" | "voice.asr" | "voice.polish" | "ai.assistant"; "config": { [key: string]: unknown } } }
|
|
| { "type": "apiModelList"; "protocolVersion"?: 1; "data": { "requestId": string; "service": "ai.assistant" | "voice.asr" | "voice.polish"; "config": { [key: string]: unknown } } }
|
|
| { "type": "aiProviderSync"; "protocolVersion"?: 1; "data": { "requestId": string; "entries": Array<{ "id": string; "name": string; "endpoint": string; "token": string; "model": string }> } }
|
|
| { "type": "dictionaryRequest"; "protocolVersion"?: 1; "data": { "requestId": string; "dictionary": "quanpin" | "wubi" | "english" | "quick"; "action": "query" | "create" | "update" | "delete" | "import" | "importHans" | "export"; "word"?: string; "code"?: string; "content"?: string; "weight"?: number; "oldWord"?: string; "oldCode"?: string; "display"?: string; "oldDisplay"?: string; "offset"?: number; "limit"?: number } }
|
|
| { "type": "statsRequest"; "protocolVersion"?: 1; "data": { "requestId": string; "action": "overview" | "clearAll" | "openDirectory" } }
|
|
| { "type": "defaultImeRequest"; "protocolVersion"?: 1; "data": { "requestId": string; "action": "status" | "setDefault" | "openSystemSettings" } }
|
|
| { "type": "gameCompatRequest"; "protocolVersion"?: 1; "data": { "requestId": string; "action": "status" | "apply"; "enabled"?: boolean; "name"?: string } }
|
|
| { "type": "openKeyboardPanel"; "protocolVersion"?: 1 };
|
|
declare global {
|
|
var MsimeProtocol: {
|
|
validate(message: unknown, direction: 'client' | 'server', surface?: string): boolean;
|
|
serializeClientMessage(message: ClientMessage, surface: string): string;
|
|
version: number;
|
|
};
|
|
}
|
|
export function serializeHostMessage(message: SettingsMessage): string {
|
|
return globalThis.MsimeProtocol.serializeClientMessage(message, 'settings');
|
|
}
|
|
export function isServerMessage(message: unknown): message is ServerMessage {
|
|
return globalThis.MsimeProtocol.validate(message, 'server');
|
|
}
|