@jingyi0605/codingns4dsh 0.2.1-beta.10 → 0.2.1-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +7 -5
- package/README.md +12 -6
- package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts +1 -1
- package/data/build/dist/bootstrap/index.d.ts +1 -1
- package/data/build/dist/client/bundle.js +9713 -7350
- package/data/build/dist/client/bundle.js.map +1 -1
- package/data/build/dist/client/cli-slots.d.ts +13 -3
- package/data/build/dist/client/cli-slots.d.ts.map +1 -1
- package/data/build/dist/client/cli-slots.js +93 -18
- package/data/build/dist/client/cli-slots.js.map +1 -1
- package/data/build/dist/client/client.assistant-configuration-view.js +4 -3
- package/data/build/dist/client/client.assistant-configuration-view.js.map +1 -1
- package/data/build/dist/client/client.moss-voice-output.js +415 -0
- package/data/build/dist/client/client.moss-voice-output.js.map +1 -0
- package/data/build/dist/client/client.native-workspace-store.js +4 -4
- package/data/build/dist/client/client.native-workspace-store.js.map +1 -1
- package/data/build/dist/client/client.primitives-adapter.js.map +1 -1
- package/data/build/dist/client/client.react-dom.js +0 -404
- package/data/build/dist/client/client.react-dom.js.map +1 -1
- package/data/build/dist/client/client.session-translation.js +105 -2
- package/data/build/dist/client/client.session-translation.js.map +1 -1
- package/data/build/dist/client/client.transport.js +103 -11
- package/data/build/dist/client/client.transport.js.map +1 -1
- package/data/build/dist/client/conversation-translation-settings.d.ts +10 -0
- package/data/build/dist/client/conversation-translation-settings.d.ts.map +1 -0
- package/data/build/dist/client/conversation-translation-settings.js +52 -0
- package/data/build/dist/client/conversation-translation-settings.js.map +1 -0
- package/data/build/dist/client/desktop-assistant.js +569 -450
- package/data/build/dist/client/features/cli-adapters.d.ts.map +1 -1
- package/data/build/dist/client/features/cli-adapters.js +3 -1
- package/data/build/dist/client/features/cli-adapters.js.map +1 -1
- package/data/build/dist/client/features/session-translation.d.ts.map +1 -1
- package/data/build/dist/client/features/session-translation.js +49 -48
- package/data/build/dist/client/features/session-translation.js.map +1 -1
- package/data/build/dist/client/locales/panels.d.ts.map +1 -1
- package/data/build/dist/client/locales/panels.js +103 -11
- package/data/build/dist/client/locales/panels.js.map +1 -1
- package/data/build/dist/client/native-model-translation-menu.d.ts +6 -0
- package/data/build/dist/client/native-model-translation-menu.d.ts.map +1 -0
- package/data/build/dist/client/native-model-translation-menu.js +57 -0
- package/data/build/dist/client/native-model-translation-menu.js.map +1 -0
- package/data/build/dist/client/native-translation-default.d.ts +6 -0
- package/data/build/dist/client/native-translation-default.d.ts.map +1 -0
- package/data/build/dist/client/native-translation-default.js +30 -0
- package/data/build/dist/client/native-translation-default.js.map +1 -0
- package/data/build/dist/client/session-translation-chat.d.ts +23 -2
- package/data/build/dist/client/session-translation-chat.d.ts.map +1 -1
- package/data/build/dist/client/session-translation-chat.js +238 -72
- package/data/build/dist/client/session-translation-chat.js.map +1 -1
- package/data/build/dist/client/session-translation-interactions.d.ts +31 -0
- package/data/build/dist/client/session-translation-interactions.d.ts.map +1 -0
- package/data/build/dist/client/session-translation-interactions.js +158 -0
- package/data/build/dist/client/session-translation-interactions.js.map +1 -0
- package/data/build/dist/client/session-translation-model-pool.d.ts +16 -0
- package/data/build/dist/client/session-translation-model-pool.d.ts.map +1 -0
- package/data/build/dist/client/session-translation-model-pool.js +246 -0
- package/data/build/dist/client/session-translation-model-pool.js.map +1 -0
- package/data/build/dist/client/session-translation-pending-dom.d.ts +8 -0
- package/data/build/dist/client/session-translation-pending-dom.d.ts.map +1 -0
- package/data/build/dist/client/session-translation-pending-dom.js +58 -0
- package/data/build/dist/client/session-translation-pending-dom.js.map +1 -0
- package/data/build/dist/client/session-translation-retry.d.ts +16 -0
- package/data/build/dist/client/session-translation-retry.d.ts.map +1 -0
- package/data/build/dist/client/session-translation-retry.js +66 -0
- package/data/build/dist/client/session-translation-retry.js.map +1 -0
- package/data/build/dist/client/session-translation-rules.d.ts +13 -0
- package/data/build/dist/client/session-translation-rules.d.ts.map +1 -0
- package/data/build/dist/client/session-translation-rules.js +58 -0
- package/data/build/dist/client/session-translation-rules.js.map +1 -0
- package/data/build/dist/client/style.css +276 -276
- package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.d.ts +30 -0
- package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.js +93 -0
- package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/interaction-text-dom.d.ts +12 -0
- package/data/build/dist/dsh-capabilities/client/interaction-text-dom.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/interaction-text-dom.js +181 -0
- package/data/build/dist/dsh-capabilities/client/interaction-text-dom.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.d.ts +19 -0
- package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.js +39 -0
- package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts +1 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.js +1 -0
- package/data/build/dist/dsh-capabilities/client/primitives-adapter.js.map +1 -1
- package/data/build/dist/dsh-capabilities/client/question-history-adapter.d.ts +20 -0
- package/data/build/dist/dsh-capabilities/client/question-history-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/question-history-adapter.js +65 -0
- package/data/build/dist/dsh-capabilities/client/question-history-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.d.ts +32 -0
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.js +90 -0
- package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.d.ts +10 -0
- package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.js +34 -0
- package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.d.ts +21 -0
- package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.js +11 -0
- package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-activation-adapter.d.ts +17 -0
- package/data/build/dist/dsh-capabilities/host/session-activation-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-activation-adapter.js +37 -0
- package/data/build/dist/dsh-capabilities/host/session-activation-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.d.ts +17 -0
- package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.js +45 -0
- package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.d.ts +28 -0
- package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.d.ts.map +1 -0
- package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.js +31 -0
- package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.js.map +1 -0
- package/data/build/dist/dsh-capabilities/matrix.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/matrix.js +12 -3
- package/data/build/dist/dsh-capabilities/matrix.js.map +1 -1
- package/data/build/dist/dsh-capabilities/routes.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/routes.js +26 -3
- package/data/build/dist/dsh-capabilities/routes.js.map +1 -1
- package/data/build/dist/dsh-capabilities/types.d.ts +1 -1
- package/data/build/dist/dsh-capabilities/types.d.ts.map +1 -1
- package/data/build/dist/dsh-capabilities/types.js.map +1 -1
- package/data/build/dist/host/cli-adapters/antigravity-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/antigravity-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/attachment-utils.d.ts +4 -3
- package/data/build/dist/host/cli-adapters/attachment-utils.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/attachment-utils.js +9 -8
- package/data/build/dist/host/cli-adapters/attachment-utils.js.map +1 -1
- package/data/build/dist/host/cli-adapters/claude-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/claude-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/command-code-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/command-code-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/driver.d.ts +2 -0
- package/data/build/dist/host/cli-adapters/driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts +2 -0
- package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/dsh-message-projector.js +28 -11
- package/data/build/dist/host/cli-adapters/dsh-message-projector.js.map +1 -1
- package/data/build/dist/host/cli-adapters/feature.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/feature.js +369 -70
- package/data/build/dist/host/cli-adapters/feature.js.map +1 -1
- package/data/build/dist/host/cli-adapters/gemini-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/gemini-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/grok-driver.d.ts +1 -0
- package/data/build/dist/host/cli-adapters/grok-driver.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/grok-driver.js +128 -40
- package/data/build/dist/host/cli-adapters/grok-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/kimi-driver.js +2 -2
- package/data/build/dist/host/cli-adapters/kimi-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/mcode-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/mcode-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/native-subagent-dispatch.js +2 -2
- package/data/build/dist/host/cli-adapters/native-subagent-dispatch.js.map +1 -1
- package/data/build/dist/host/cli-adapters/native-team-subagent.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/native-team-subagent.js +2 -1
- package/data/build/dist/host/cli-adapters/native-team-subagent.js.map +1 -1
- package/data/build/dist/host/cli-adapters/pi-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/pi-driver.js.map +1 -1
- package/data/build/dist/host/cli-adapters/registry.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/registry.js +25 -16
- package/data/build/dist/host/cli-adapters/registry.js.map +1 -1
- package/data/build/dist/host/cli-adapters/zcode-driver.js +1 -1
- package/data/build/dist/host/cli-adapters/zcode-driver.js.map +1 -1
- package/data/build/dist/host/features/global-voice-rpc.d.ts.map +1 -1
- package/data/build/dist/host/features/global-voice-rpc.js +2 -3
- package/data/build/dist/host/features/global-voice-rpc.js.map +1 -1
- package/data/build/dist/host/features/interaction-translation.d.ts +9 -0
- package/data/build/dist/host/features/interaction-translation.d.ts.map +1 -0
- package/data/build/dist/host/features/interaction-translation.js +168 -0
- package/data/build/dist/host/features/interaction-translation.js.map +1 -0
- package/data/build/dist/host/features/peer-host.js +6 -6
- package/data/build/dist/host/features/peer-host.js.map +1 -1
- package/data/build/dist/host/features/session-prompt-translation.d.ts +10 -0
- package/data/build/dist/host/features/session-prompt-translation.d.ts.map +1 -0
- package/data/build/dist/host/features/session-prompt-translation.js +197 -0
- package/data/build/dist/host/features/session-prompt-translation.js.map +1 -0
- package/data/build/dist/host/features/session-translation-protection.d.ts +16 -0
- package/data/build/dist/host/features/session-translation-protection.d.ts.map +1 -0
- package/data/build/dist/host/features/session-translation-protection.js +183 -0
- package/data/build/dist/host/features/session-translation-protection.js.map +1 -0
- package/data/build/dist/host/features/session-translation-recovery.d.ts +20 -0
- package/data/build/dist/host/features/session-translation-recovery.d.ts.map +1 -0
- package/data/build/dist/host/features/session-translation-recovery.js +122 -0
- package/data/build/dist/host/features/session-translation-recovery.js.map +1 -0
- package/data/build/dist/host/features/session-translation-runtime.d.ts +16 -0
- package/data/build/dist/host/features/session-translation-runtime.d.ts.map +1 -0
- package/data/build/dist/host/features/session-translation-runtime.js +85 -0
- package/data/build/dist/host/features/session-translation-runtime.js.map +1 -0
- package/data/build/dist/host/features/session-translation-service.d.ts +14 -4
- package/data/build/dist/host/features/session-translation-service.d.ts.map +1 -1
- package/data/build/dist/host/features/session-translation-service.js +217 -211
- package/data/build/dist/host/features/session-translation-service.js.map +1 -1
- package/data/build/dist/host/features/session-translation.d.ts.map +1 -1
- package/data/build/dist/host/features/session-translation.js +5 -2
- package/data/build/dist/host/features/session-translation.js.map +1 -1
- package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.d.ts +2 -2
- package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.d.ts.map +1 -1
- package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.js +10 -9
- package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.js.map +1 -1
- package/data/build/dist/host/modules/peer-host/peer-host-native-streams.d.ts +3 -3
- package/data/build/dist/host/modules/peer-host/peer-host-native-streams.d.ts.map +1 -1
- package/data/build/dist/host/modules/peer-host/peer-host-native-streams.js +26 -14
- package/data/build/dist/host/modules/peer-host/peer-host-native-streams.js.map +1 -1
- package/data/build/dist/host/native-session-bridge.d.ts +2 -1
- package/data/build/dist/host/native-session-bridge.d.ts.map +1 -1
- package/data/build/dist/host/native-session-bridge.js +7 -15
- package/data/build/dist/host/native-session-bridge.js.map +1 -1
- package/data/build/dist/host/rpc.d.ts.map +1 -1
- package/data/build/dist/host/rpc.js +14 -8
- package/data/build/dist/host/rpc.js.map +1 -1
- package/data/build/dist/host/settings.d.ts.map +1 -1
- package/data/build/dist/host/settings.js +10 -2
- package/data/build/dist/host/settings.js.map +1 -1
- package/data/build/dist/shared/attachment-prompts.d.ts +11 -0
- package/data/build/dist/shared/attachment-prompts.d.ts.map +1 -0
- package/data/build/dist/shared/attachment-prompts.js +17 -0
- package/data/build/dist/shared/attachment-prompts.js.map +1 -0
- package/data/build/dist/shared/contracts/cli-adapter.d.ts +8 -1
- package/data/build/dist/shared/contracts/cli-adapter.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/errors.d.ts +2 -2
- package/data/build/dist/shared/contracts/interaction-presentation.d.ts +32 -0
- package/data/build/dist/shared/contracts/interaction-presentation.d.ts.map +1 -0
- package/data/build/dist/shared/contracts/interaction-presentation.js +2 -0
- package/data/build/dist/shared/contracts/interaction-presentation.js.map +1 -0
- package/data/build/dist/shared/contracts/interaction-translation.d.ts +53 -0
- package/data/build/dist/shared/contracts/interaction-translation.d.ts.map +1 -0
- package/data/build/dist/shared/contracts/interaction-translation.js +44 -0
- package/data/build/dist/shared/contracts/interaction-translation.js.map +1 -0
- package/data/build/dist/shared/contracts/session-translation.d.ts +75 -7
- package/data/build/dist/shared/contracts/session-translation.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/session-translation.js +132 -2
- package/data/build/dist/shared/contracts/session-translation.js.map +1 -1
- package/data/build/dist/shared/contracts/version.d.ts +4 -4
- package/data/build/dist/shared/contracts/version.js +3 -3
- package/data/build/dist/shared/index.d.ts +1 -1
- package/data/build/dist/shared/index.d.ts.map +1 -1
- package/data/build/dist/shared/index.js +1 -1
- package/data/build/dist/shared/index.js.map +1 -1
- package/data/build/dist/shared/translation-indicator.d.ts +26 -0
- package/data/build/dist/shared/translation-indicator.d.ts.map +1 -0
- package/data/build/dist/shared/translation-indicator.js +29 -0
- package/data/build/dist/shared/translation-indicator.js.map +1 -0
- package/package.json +35 -34
- package/profile/README.md +2 -2
- package/profile/package.json +3 -3
- package/profile/version.json +3 -3
- package/version.json +3 -3
|
@@ -6,8 +6,6 @@ window.__ModuleLoader__.load({
|
|
|
6
6
|
var exports = module.exports;
|
|
7
7
|
const require_rolldown_runtime = require("@jingyi0605/codingns4dsh/client.rolldown-runtime.js");
|
|
8
8
|
const require_theme = require("@jingyi0605/codingns4dsh/client.theme.js");
|
|
9
|
-
const require_manager = require("@jingyi0605/codingns4dsh/client.manager.js");
|
|
10
|
-
const require_primitives_adapter = require("@jingyi0605/codingns4dsh/client.primitives-adapter.js");
|
|
11
9
|
let react = require("react");
|
|
12
10
|
//#region src/client/settings-controls.ts
|
|
13
11
|
const settingsControlClass = {
|
|
@@ -148,372 +146,6 @@ window.__ModuleLoader__.load({
|
|
|
148
146
|
.${settingsControlClass.iconButton}:disabled{opacity:.5;cursor:not-allowed}
|
|
149
147
|
@media (prefers-reduced-motion:reduce){.${settingsControlClass.track},.${settingsControlClass.thumb}{transition:none}}
|
|
150
148
|
`;
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/client/peer-host-color.ts
|
|
153
|
-
/**
|
|
154
|
-
* 工作区标签配色的推导与缓存。
|
|
155
|
-
*
|
|
156
|
-
* 用户在 PeerHost 管理里显式配置的颜色优先;没有配置时按 Host 名称推导一个稳定
|
|
157
|
-
* 颜色,保证同一台机器在多次刷新、多个工作区之间颜色一致——颜色本身是识别手段,
|
|
158
|
-
* 随机色会让标签失去意义。
|
|
159
|
-
*/
|
|
160
|
-
/** 无显式配色时使用的候选色板;与 PEER_HOST_COLOR_PRESETS 保持同一组观感。 */
|
|
161
|
-
const FALLBACK_PALETTE = [
|
|
162
|
-
"#1677ff",
|
|
163
|
-
"#722ed1",
|
|
164
|
-
"#13c2c2",
|
|
165
|
-
"#52c41a",
|
|
166
|
-
"#fa8c16",
|
|
167
|
-
"#eb2f96",
|
|
168
|
-
"#f5222d",
|
|
169
|
-
"#8c8c8c"
|
|
170
|
-
];
|
|
171
|
-
const derivedCache = /* @__PURE__ */ new Map();
|
|
172
|
-
/**
|
|
173
|
-
* 解析某台 Host 的工作区标签颜色。
|
|
174
|
-
*
|
|
175
|
-
* @param explicit - 用户在 PeerHost 配置里保存的颜色;非法或缺省时走推导。
|
|
176
|
-
* @param seed - 推导种子,通常用 PeerHost 名称;同一名称始终得到同一颜色。
|
|
177
|
-
* @returns `#rrggbb` 形式的小写颜色。
|
|
178
|
-
*/
|
|
179
|
-
function resolvePeerHostColor(explicit, seed) {
|
|
180
|
-
const configured = require_primitives_adapter.normalizePeerHostColor(explicit);
|
|
181
|
-
if (configured !== null) return configured;
|
|
182
|
-
const key = seed.trim() === "" ? "peer-host" : seed.trim();
|
|
183
|
-
const cached = derivedCache.get(key);
|
|
184
|
-
if (cached !== void 0) return cached;
|
|
185
|
-
const color = FALLBACK_PALETTE[hashString(key) % FALLBACK_PALETTE.length];
|
|
186
|
-
derivedCache.set(key, color);
|
|
187
|
-
return color;
|
|
188
|
-
}
|
|
189
|
-
/** FNV-1a 32 位哈希;只用于选色,不需要密码学强度。 */
|
|
190
|
-
function hashString(value) {
|
|
191
|
-
let hash = 2166136261;
|
|
192
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
193
|
-
hash ^= value.charCodeAt(index);
|
|
194
|
-
hash = Math.imul(hash, 16777619) >>> 0;
|
|
195
|
-
}
|
|
196
|
-
return hash >>> 0;
|
|
197
|
-
}
|
|
198
|
-
/** 标签胶囊的底色:与归档面板 Agent 徽标保持同一种 `color-mix` 写法。 */
|
|
199
|
-
function peerHostTagBackground(color) {
|
|
200
|
-
return `color-mix(in srgb, ${color} 16%, transparent)`;
|
|
201
|
-
}
|
|
202
|
-
/** 标签文字色;直接使用配置色,保证明暗主题下都有足够对比。 */
|
|
203
|
-
function peerHostTagForeground(color) {
|
|
204
|
-
return color;
|
|
205
|
-
}
|
|
206
|
-
/** 工作区列表与关联项目表共用的 Host 胶囊标签基础样式。 */
|
|
207
|
-
function peerHostTagStyle(color) {
|
|
208
|
-
return {
|
|
209
|
-
boxSizing: "border-box",
|
|
210
|
-
overflow: "hidden",
|
|
211
|
-
textOverflow: "ellipsis",
|
|
212
|
-
whiteSpace: "nowrap",
|
|
213
|
-
padding: "1px 6px",
|
|
214
|
-
borderRadius: "999px",
|
|
215
|
-
fontSize: "10px",
|
|
216
|
-
lineHeight: "1.5",
|
|
217
|
-
pointerEvents: "none",
|
|
218
|
-
color: peerHostTagForeground(color),
|
|
219
|
-
background: peerHostTagBackground(color)
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
//#endregion
|
|
223
|
-
//#region src/shared/voice-diagnostics.ts
|
|
224
|
-
const allowedFields = new Set(`ownerId clientId callId requestId diagnosticId epoch sequence firstSequence lastSequence
|
|
225
|
-
action state phase backend provider model code errorName status durationMs waitMs firstAudioMs firstTextMs
|
|
226
|
-
firstSentenceMs firstPlaybackMs queueMs gapMs intervalMs maxIntervalMs processMs maxProcessMs decodeMs
|
|
227
|
-
maxDecodeMs audioMs bytes pendingBytes pending frames chunks samples sampleRate inputRate threads tokens
|
|
228
|
-
textLength systemLength messageCount toolCount count dropped stale aborted completed continuation muted
|
|
229
|
-
sourceCount contextState processor cpuPercent rssMb heapMb eventLoopMeanMs eventLoopMaxMs eventLoopP99Ms
|
|
230
|
-
realTimeFactor generationMs codecMs transportMs segment generationFrames fileIndex
|
|
231
|
-
pcmBytes headerBytes pendingAudioMs inFlightMs endpointSilenceMs cached streaming
|
|
232
|
-
webSearchAvailable searchRegistration`.split(/\s+/u));
|
|
233
|
-
function sanitizeVoiceDiagnosticFields(value) {
|
|
234
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
235
|
-
const fields = {};
|
|
236
|
-
for (const key of allowedFields) {
|
|
237
|
-
const item = value[key];
|
|
238
|
-
if (typeof item === "number" && Number.isFinite(item) || typeof item === "boolean" || item === null) fields[key] = item;
|
|
239
|
-
else if (typeof item === "string") fields[key] = item.slice(0, 160);
|
|
240
|
-
}
|
|
241
|
-
return fields;
|
|
242
|
-
}
|
|
243
|
-
function voiceDiagnosticId() {
|
|
244
|
-
return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
245
|
-
}
|
|
246
|
-
function voiceDiagnosticError(error) {
|
|
247
|
-
return error instanceof Error ? error.name : "UnknownError";
|
|
248
|
-
}
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/client/moss-voice-output.ts
|
|
251
|
-
/** 可取消的 PCM 播放器;同一轮的各段串行生成,生成与播放并行。 */
|
|
252
|
-
var MossVoiceOutput = class {
|
|
253
|
-
options;
|
|
254
|
-
context;
|
|
255
|
-
abort;
|
|
256
|
-
sources = /* @__PURE__ */ new Set();
|
|
257
|
-
sequence = 0;
|
|
258
|
-
outputDeviceId = "";
|
|
259
|
-
nextStart = 0;
|
|
260
|
-
gain;
|
|
261
|
-
muted = false;
|
|
262
|
-
volume = 1;
|
|
263
|
-
constructor(options = {}) {
|
|
264
|
-
this.options = options;
|
|
265
|
-
}
|
|
266
|
-
get outputDeviceSupported() {
|
|
267
|
-
return typeof (globalThis.AudioContext?.prototype)?.setSinkId === "function";
|
|
268
|
-
}
|
|
269
|
-
/** 在点击开始或试听时调用,保留浏览器要求的用户手势。 */
|
|
270
|
-
async prepare() {
|
|
271
|
-
if (this.context === void 0 || this.context.state === "closed") this.context = this.options.context?.() ?? new AudioContext();
|
|
272
|
-
if (this.gain === void 0) {
|
|
273
|
-
this.gain = this.context.createGain();
|
|
274
|
-
this.gain.gain.value = this.muted ? 0 : this.volume;
|
|
275
|
-
this.gain.connect(this.context.destination);
|
|
276
|
-
}
|
|
277
|
-
if (this.context.state === "suspended") await this.context.resume();
|
|
278
|
-
if (this.outputDeviceId !== "" && typeof this.context.setSinkId === "function") await this.context.setSinkId(this.outputDeviceId);
|
|
279
|
-
}
|
|
280
|
-
async setOutputDevice(id) {
|
|
281
|
-
if (!this.outputDeviceSupported) throw new Error("当前浏览器不支持 MOSS 播放设备选择");
|
|
282
|
-
if (this.context !== void 0) await this.context.setSinkId(id);
|
|
283
|
-
this.outputDeviceId = id;
|
|
284
|
-
}
|
|
285
|
-
/** 输出静音不中断推理或时间线,恢复后继续听当前播报。 */
|
|
286
|
-
setMuted(muted) {
|
|
287
|
-
this.muted = muted;
|
|
288
|
-
if (this.gain !== void 0) this.gain.gain.value = muted ? 0 : this.volume;
|
|
289
|
-
}
|
|
290
|
-
async speak(text, voiceId, onStart, parameters) {
|
|
291
|
-
this.cancel();
|
|
292
|
-
const sequence = this.sequence;
|
|
293
|
-
if (!await this.append(text, voiceId, onStart, parameters) || sequence !== this.sequence) return false;
|
|
294
|
-
return this.finish();
|
|
295
|
-
}
|
|
296
|
-
/** 由文本队列串行调用;收到生成结束即可提交下一段,不取消仍在播放的前一段。 */
|
|
297
|
-
async append(text, voiceId, onStart, parameters) {
|
|
298
|
-
const started = performance.now();
|
|
299
|
-
const diagnosticId = voiceDiagnosticId();
|
|
300
|
-
const fields = {
|
|
301
|
-
...this.options.traceContext?.(),
|
|
302
|
-
diagnosticId,
|
|
303
|
-
textLength: text.length
|
|
304
|
-
};
|
|
305
|
-
const trace = (event, metrics) => this.options.trace?.(`client.tts.${event}`, {
|
|
306
|
-
...fields,
|
|
307
|
-
...metrics
|
|
308
|
-
});
|
|
309
|
-
let chunks = 0;
|
|
310
|
-
let audioMs = 0;
|
|
311
|
-
let lastChunkAt = started;
|
|
312
|
-
const playback = require_manager.readAssistantTtsParameters(parameters);
|
|
313
|
-
const sequence = this.sequence;
|
|
314
|
-
const continuation = this.abort !== void 0;
|
|
315
|
-
const abort = this.abort ?? new AbortController();
|
|
316
|
-
this.abort = abort;
|
|
317
|
-
const readerSignal = abort.signal;
|
|
318
|
-
trace("start", { continuation });
|
|
319
|
-
try {
|
|
320
|
-
await this.prepare();
|
|
321
|
-
if (readerSignal.aborted) return false;
|
|
322
|
-
const queueStarted = performance.now();
|
|
323
|
-
await this.waitUntil(() => this.sources.size === 0 || this.nextStart - this.context.currentTime <= 5, readerSignal);
|
|
324
|
-
if (readerSignal.aborted) return false;
|
|
325
|
-
trace("queue_ready", {
|
|
326
|
-
waitMs: performance.now() - queueStarted,
|
|
327
|
-
queueMs: Math.max(0, this.nextStart - this.context.currentTime) * 1e3
|
|
328
|
-
});
|
|
329
|
-
this.volume = playback.volume;
|
|
330
|
-
this.gain.gain.value = this.muted ? 0 : this.volume;
|
|
331
|
-
const response = await (this.options.fetch ?? globalThis.fetch)(new URL(require_manager.ASSISTANT_TTS_PATH, globalThis.location?.origin ?? "http://localhost"), {
|
|
332
|
-
method: "POST",
|
|
333
|
-
credentials: "same-origin",
|
|
334
|
-
signal: readerSignal,
|
|
335
|
-
headers: {
|
|
336
|
-
"content-type": "application/json",
|
|
337
|
-
accept: "application/x-ndjson"
|
|
338
|
-
},
|
|
339
|
-
body: JSON.stringify({
|
|
340
|
-
text,
|
|
341
|
-
parameters: playback,
|
|
342
|
-
diagnosticId,
|
|
343
|
-
...voiceId === void 0 ? {} : { voiceId },
|
|
344
|
-
...fields.requestId === void 0 ? {} : { requestId: fields.requestId },
|
|
345
|
-
...fields.ownerId === void 0 ? {} : { ownerId: fields.ownerId }
|
|
346
|
-
})
|
|
347
|
-
});
|
|
348
|
-
trace("headers", {
|
|
349
|
-
status: response.status,
|
|
350
|
-
durationMs: performance.now() - started
|
|
351
|
-
});
|
|
352
|
-
if (!response.ok) {
|
|
353
|
-
const value = await response.json().catch(() => ({}));
|
|
354
|
-
throw new Error(typeof value.error === "string" ? value.error : `Host TTS 请求失败(${response.status})`);
|
|
355
|
-
}
|
|
356
|
-
if (response.body === null) throw new Error("Host TTS 响应缺少音频流");
|
|
357
|
-
const reader = response.body.getReader();
|
|
358
|
-
const decoder = new TextDecoder();
|
|
359
|
-
let buffer = "";
|
|
360
|
-
let completed = false;
|
|
361
|
-
let played = false;
|
|
362
|
-
try {
|
|
363
|
-
while (true) {
|
|
364
|
-
const next = await reader.read();
|
|
365
|
-
if (readerSignal.aborted) return false;
|
|
366
|
-
if (next.done) break;
|
|
367
|
-
buffer += decoder.decode(next.value, { stream: true });
|
|
368
|
-
if (buffer.length > 2097152) throw new Error("Host TTS 音频事件过大");
|
|
369
|
-
let boundary = buffer.indexOf("\n");
|
|
370
|
-
while (boundary >= 0) {
|
|
371
|
-
const line = buffer.slice(0, boundary).trim();
|
|
372
|
-
buffer = buffer.slice(boundary + 1);
|
|
373
|
-
if (line !== "") {
|
|
374
|
-
const event = JSON.parse(line);
|
|
375
|
-
if (completed) throw new Error("Host TTS 在完成后继续返回音频");
|
|
376
|
-
if (event.type === "error") throw new Error(String(event.message));
|
|
377
|
-
if (event.type === "done") completed = true;
|
|
378
|
-
else if (event.type === "audio") {
|
|
379
|
-
const arrived = performance.now();
|
|
380
|
-
if (chunks === 0) trace("first_audio", { firstAudioMs: arrived - started });
|
|
381
|
-
const samples = decodeMossPcm(event);
|
|
382
|
-
const decodeMs = performance.now() - arrived;
|
|
383
|
-
chunks++;
|
|
384
|
-
audioMs += samples.length / Number(event.sampleRate) * 1e3;
|
|
385
|
-
trace("chunk", {
|
|
386
|
-
chunks,
|
|
387
|
-
decodeMs,
|
|
388
|
-
samples: samples.length,
|
|
389
|
-
audioMs: samples.length / Number(event.sampleRate) * 1e3,
|
|
390
|
-
intervalMs: arrived - lastChunkAt,
|
|
391
|
-
queueMs: Math.max(0, this.nextStart - this.context.currentTime) * 1e3
|
|
392
|
-
});
|
|
393
|
-
lastChunkAt = arrived;
|
|
394
|
-
if (!played && continuation) this.nextStart += playback.segmentPauseMs / 1e3;
|
|
395
|
-
await this.waitUntil(() => this.sources.size === 0 || this.nextStart - this.context.currentTime <= 5, readerSignal);
|
|
396
|
-
if (readerSignal.aborted) return false;
|
|
397
|
-
this.enqueue(samples, Number(event.sampleRate), playback.rate, trace, chunks === 1 && !continuation);
|
|
398
|
-
if (!played) {
|
|
399
|
-
played = true;
|
|
400
|
-
onStart?.();
|
|
401
|
-
}
|
|
402
|
-
} else throw new Error("Host TTS 返回未知事件");
|
|
403
|
-
}
|
|
404
|
-
boundary = buffer.indexOf("\n");
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
} finally {
|
|
408
|
-
await reader.cancel().catch(() => void 0);
|
|
409
|
-
reader.releaseLock();
|
|
410
|
-
}
|
|
411
|
-
if (!completed || !played || buffer.trim() !== "") throw new Error("Host TTS 音频流未完整结束");
|
|
412
|
-
trace("generated", {
|
|
413
|
-
durationMs: performance.now() - started,
|
|
414
|
-
chunks,
|
|
415
|
-
audioMs,
|
|
416
|
-
realTimeFactor: audioMs > 0 ? (performance.now() - started) / audioMs : 0
|
|
417
|
-
});
|
|
418
|
-
return !readerSignal.aborted && sequence === this.sequence;
|
|
419
|
-
} catch (error) {
|
|
420
|
-
trace("error", {
|
|
421
|
-
aborted: readerSignal.aborted,
|
|
422
|
-
durationMs: performance.now() - started,
|
|
423
|
-
errorName: voiceDiagnosticError(error)
|
|
424
|
-
});
|
|
425
|
-
if (readerSignal.aborted || sequence !== this.sequence) return false;
|
|
426
|
-
this.cancel();
|
|
427
|
-
throw error;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
/** 文本队列耗尽后再等音频播完;取消旧轮次不会误清理新轮次的请求。 */
|
|
431
|
-
async finish() {
|
|
432
|
-
const abort = this.abort;
|
|
433
|
-
if (abort === void 0) return true;
|
|
434
|
-
const sequence = this.sequence;
|
|
435
|
-
await this.waitUntil(() => this.sources.size === 0, abort.signal);
|
|
436
|
-
if (this.abort === abort) this.abort = void 0;
|
|
437
|
-
return !abort.signal.aborted && sequence === this.sequence;
|
|
438
|
-
}
|
|
439
|
-
cancel() {
|
|
440
|
-
this.sequence++;
|
|
441
|
-
this.abort?.abort();
|
|
442
|
-
this.abort = void 0;
|
|
443
|
-
for (const source of this.sources) {
|
|
444
|
-
source.onended = null;
|
|
445
|
-
try {
|
|
446
|
-
source.stop();
|
|
447
|
-
} catch {}
|
|
448
|
-
source.disconnect();
|
|
449
|
-
}
|
|
450
|
-
this.sources.clear();
|
|
451
|
-
this.nextStart = 0;
|
|
452
|
-
}
|
|
453
|
-
dispose() {
|
|
454
|
-
this.cancel();
|
|
455
|
-
this.gain?.disconnect();
|
|
456
|
-
this.gain = void 0;
|
|
457
|
-
const context = this.context;
|
|
458
|
-
this.context = void 0;
|
|
459
|
-
context?.close().catch(() => void 0);
|
|
460
|
-
}
|
|
461
|
-
enqueue(samples, sampleRate, rate, trace, first) {
|
|
462
|
-
const context = this.context;
|
|
463
|
-
if (this.nextStart - context.currentTime > 30) throw new Error("MOSS 播放队列过长,请缩短文本");
|
|
464
|
-
const buffer = context.createBuffer(1, samples.length, sampleRate);
|
|
465
|
-
buffer.copyToChannel(samples, 0);
|
|
466
|
-
const source = context.createBufferSource();
|
|
467
|
-
source.buffer = buffer;
|
|
468
|
-
source.playbackRate.value = rate;
|
|
469
|
-
source.connect(this.gain);
|
|
470
|
-
source.onended = () => {
|
|
471
|
-
this.sources.delete(source);
|
|
472
|
-
source.disconnect();
|
|
473
|
-
};
|
|
474
|
-
this.sources.add(source);
|
|
475
|
-
const start = Math.max(context.currentTime + .02, this.nextStart);
|
|
476
|
-
trace("playback_scheduled", {
|
|
477
|
-
gapMs: this.nextStart > 0 ? Math.max(0, context.currentTime - this.nextStart) * 1e3 : 0,
|
|
478
|
-
queueMs: (start - context.currentTime) * 1e3,
|
|
479
|
-
sourceCount: this.sources.size,
|
|
480
|
-
contextState: context.state,
|
|
481
|
-
muted: this.muted
|
|
482
|
-
});
|
|
483
|
-
if (first) trace("first_playback_scheduled", { queueMs: (start - context.currentTime) * 1e3 });
|
|
484
|
-
source.start(start);
|
|
485
|
-
this.nextStart = start + buffer.duration / rate;
|
|
486
|
-
}
|
|
487
|
-
async waitUntil(ready, signal) {
|
|
488
|
-
if (ready() || signal.aborted) return;
|
|
489
|
-
await new Promise((resolve) => {
|
|
490
|
-
let timer;
|
|
491
|
-
const finish = () => {
|
|
492
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
493
|
-
signal.removeEventListener("abort", finish);
|
|
494
|
-
resolve();
|
|
495
|
-
};
|
|
496
|
-
const check = () => {
|
|
497
|
-
if (signal.aborted || ready()) finish();
|
|
498
|
-
else timer = setTimeout(check, 30);
|
|
499
|
-
};
|
|
500
|
-
signal.addEventListener("abort", finish, { once: true });
|
|
501
|
-
check();
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
/** PCM 固定为 48kHz、单声道、16 位小端,与 Host 工作进程协议一致。 */
|
|
506
|
-
function decodeMossPcm(event) {
|
|
507
|
-
if (event.sampleRate !== 48e3 || typeof event.data !== "string" || event.data.length > 1048576) throw new Error("Host TTS PCM 格式无效");
|
|
508
|
-
const raw = atob(event.data);
|
|
509
|
-
if (raw.length === 0 || raw.length % 2 !== 0) throw new Error("Host TTS PCM 长度无效");
|
|
510
|
-
const samples = new Float32Array(raw.length / 2);
|
|
511
|
-
for (let index = 0; index < samples.length; index++) {
|
|
512
|
-
const value = raw.charCodeAt(index * 2) | raw.charCodeAt(index * 2 + 1) << 8;
|
|
513
|
-
samples[index] = (value >= 32768 ? value - 65536 : value) / 32768;
|
|
514
|
-
}
|
|
515
|
-
return samples;
|
|
516
|
-
}
|
|
517
149
|
//#endregion
|
|
518
150
|
//#region node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/cjs/scheduler.production.min.js
|
|
519
151
|
/**
|
|
@@ -7463,12 +7095,6 @@ window.__ModuleLoader__.load({
|
|
|
7463
7095
|
module.exports = require_react_dom_production_min();
|
|
7464
7096
|
}));
|
|
7465
7097
|
//#endregion
|
|
7466
|
-
Object.defineProperty(exports, "MossVoiceOutput", {
|
|
7467
|
-
enumerable: true,
|
|
7468
|
-
get: function() {
|
|
7469
|
-
return MossVoiceOutput;
|
|
7470
|
-
}
|
|
7471
|
-
});
|
|
7472
7098
|
Object.defineProperty(exports, "SettingsSwitch", {
|
|
7473
7099
|
enumerable: true,
|
|
7474
7100
|
get: function() {
|
|
@@ -7481,30 +7107,12 @@ window.__ModuleLoader__.load({
|
|
|
7481
7107
|
return SettingsToggleRow;
|
|
7482
7108
|
}
|
|
7483
7109
|
});
|
|
7484
|
-
Object.defineProperty(exports, "peerHostTagStyle", {
|
|
7485
|
-
enumerable: true,
|
|
7486
|
-
get: function() {
|
|
7487
|
-
return peerHostTagStyle;
|
|
7488
|
-
}
|
|
7489
|
-
});
|
|
7490
7110
|
Object.defineProperty(exports, "require_react_dom", {
|
|
7491
7111
|
enumerable: true,
|
|
7492
7112
|
get: function() {
|
|
7493
7113
|
return require_react_dom;
|
|
7494
7114
|
}
|
|
7495
7115
|
});
|
|
7496
|
-
Object.defineProperty(exports, "resolvePeerHostColor", {
|
|
7497
|
-
enumerable: true,
|
|
7498
|
-
get: function() {
|
|
7499
|
-
return resolvePeerHostColor;
|
|
7500
|
-
}
|
|
7501
|
-
});
|
|
7502
|
-
Object.defineProperty(exports, "sanitizeVoiceDiagnosticFields", {
|
|
7503
|
-
enumerable: true,
|
|
7504
|
-
get: function() {
|
|
7505
|
-
return sanitizeVoiceDiagnosticFields;
|
|
7506
|
-
}
|
|
7507
|
-
});
|
|
7508
7116
|
Object.defineProperty(exports, "settingsControlClass", {
|
|
7509
7117
|
enumerable: true,
|
|
7510
7118
|
get: function() {
|
|
@@ -7517,18 +7125,6 @@ window.__ModuleLoader__.load({
|
|
|
7517
7125
|
return settingsIconButtonStyle;
|
|
7518
7126
|
}
|
|
7519
7127
|
});
|
|
7520
|
-
Object.defineProperty(exports, "voiceDiagnosticError", {
|
|
7521
|
-
enumerable: true,
|
|
7522
|
-
get: function() {
|
|
7523
|
-
return voiceDiagnosticError;
|
|
7524
|
-
}
|
|
7525
|
-
});
|
|
7526
|
-
Object.defineProperty(exports, "voiceDiagnosticId", {
|
|
7527
|
-
enumerable: true,
|
|
7528
|
-
get: function() {
|
|
7529
|
-
return voiceDiagnosticId;
|
|
7530
|
-
}
|
|
7531
|
-
});
|
|
7532
7128
|
return module.exports;
|
|
7533
7129
|
}
|
|
7534
7130
|
});
|