dsh-mimo-speak 0.0.0-stage → 0.1.2

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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +197 -2
  3. package/README.zh.md +166 -0
  4. package/cordis.patch.yml +20 -0
  5. package/icon.svg +6 -0
  6. package/lib/client.js +3607 -0
  7. package/lib/client.js.map +1 -0
  8. package/lib/node/brief.d.ts +23 -0
  9. package/lib/node/brief.js +110 -0
  10. package/lib/node/brief.js.map +1 -0
  11. package/lib/node/client/BundleConfigCard.d.ts +15 -0
  12. package/lib/node/client/BundleConfigCard.js +22 -0
  13. package/lib/node/client/BundleConfigCard.js.map +1 -0
  14. package/lib/node/client/PlayerBar.d.ts +45 -0
  15. package/lib/node/client/PlayerBar.js +83 -0
  16. package/lib/node/client/PlayerBar.js.map +1 -0
  17. package/lib/node/client/SettingsSectionCard.d.ts +14 -0
  18. package/lib/node/client/SettingsSectionCard.js +19 -0
  19. package/lib/node/client/SettingsSectionCard.js.map +1 -0
  20. package/lib/node/client/SpeakAction.d.ts +32 -0
  21. package/lib/node/client/SpeakAction.js +651 -0
  22. package/lib/node/client/SpeakAction.js.map +1 -0
  23. package/lib/node/client/SpeakerIcon.d.ts +11 -0
  24. package/lib/node/client/SpeakerIcon.js +5 -0
  25. package/lib/node/client/SpeakerIcon.js.map +1 -0
  26. package/lib/node/client/TtsSettingsForm.d.ts +27 -0
  27. package/lib/node/client/TtsSettingsForm.js +164 -0
  28. package/lib/node/client/TtsSettingsForm.js.map +1 -0
  29. package/lib/node/client/api.d.ts +89 -0
  30. package/lib/node/client/api.js +247 -0
  31. package/lib/node/client/api.js.map +1 -0
  32. package/lib/node/client/audio-bus.d.ts +29 -0
  33. package/lib/node/client/audio-bus.js +91 -0
  34. package/lib/node/client/audio-bus.js.map +1 -0
  35. package/lib/node/client/chat-text.d.ts +32 -0
  36. package/lib/node/client/chat-text.js +90 -0
  37. package/lib/node/client/chat-text.js.map +1 -0
  38. package/lib/node/client/highlight.d.ts +45 -0
  39. package/lib/node/client/highlight.js +198 -0
  40. package/lib/node/client/highlight.js.map +1 -0
  41. package/lib/node/client/index.d.ts +26 -0
  42. package/lib/node/client/index.js +89 -0
  43. package/lib/node/client/index.js.map +1 -0
  44. package/lib/node/client/locales.d.ts +19 -0
  45. package/lib/node/client/locales.js +180 -0
  46. package/lib/node/client/locales.js.map +1 -0
  47. package/lib/node/client/panel-visibility.d.ts +24 -0
  48. package/lib/node/client/panel-visibility.js +16 -0
  49. package/lib/node/client/panel-visibility.js.map +1 -0
  50. package/lib/node/client/settings-controller.d.ts +116 -0
  51. package/lib/node/client/settings-controller.js +201 -0
  52. package/lib/node/client/settings-controller.js.map +1 -0
  53. package/lib/node/client/settings-registration.d.ts +24 -0
  54. package/lib/node/client/settings-registration.js +21 -0
  55. package/lib/node/client/settings-registration.js.map +1 -0
  56. package/lib/node/client/slots.d.ts +48 -0
  57. package/lib/node/client/slots.js +15 -0
  58. package/lib/node/client/slots.js.map +1 -0
  59. package/lib/node/client/speech-cache.d.ts +59 -0
  60. package/lib/node/client/speech-cache.js +68 -0
  61. package/lib/node/client/speech-cache.js.map +1 -0
  62. package/lib/node/client/split-speech.d.ts +20 -0
  63. package/lib/node/client/split-speech.js +100 -0
  64. package/lib/node/client/split-speech.js.map +1 -0
  65. package/lib/node/client/status.d.ts +28 -0
  66. package/lib/node/client/status.js +60 -0
  67. package/lib/node/client/status.js.map +1 -0
  68. package/lib/node/client/stream-dispose.d.ts +119 -0
  69. package/lib/node/client/stream-dispose.js +249 -0
  70. package/lib/node/client/stream-dispose.js.map +1 -0
  71. package/lib/node/client/styles.d.ts +19 -0
  72. package/lib/node/client/styles.js +176 -0
  73. package/lib/node/client/styles.js.map +1 -0
  74. package/lib/node/client/use-audio-player.d.ts +44 -0
  75. package/lib/node/client/use-audio-player.js +102 -0
  76. package/lib/node/client/use-audio-player.js.map +1 -0
  77. package/lib/node/client/use-audio-queue.d.ts +44 -0
  78. package/lib/node/client/use-audio-queue.js +151 -0
  79. package/lib/node/client/use-audio-queue.js.map +1 -0
  80. package/lib/node/client/use-stream-player.d.ts +41 -0
  81. package/lib/node/client/use-stream-player.js +60 -0
  82. package/lib/node/client/use-stream-player.js.map +1 -0
  83. package/lib/node/edge-tts.d.ts +21 -0
  84. package/lib/node/edge-tts.js +111 -0
  85. package/lib/node/edge-tts.js.map +1 -0
  86. package/lib/node/index.d.ts +97 -0
  87. package/lib/node/index.js +463 -0
  88. package/lib/node/index.js.map +1 -0
  89. package/lib/node/normalize.d.ts +30 -0
  90. package/lib/node/normalize.js +72 -0
  91. package/lib/node/normalize.js.map +1 -0
  92. package/lib/node/settings.d.ts +186 -0
  93. package/lib/node/settings.js +74 -0
  94. package/lib/node/settings.js.map +1 -0
  95. package/lib/node/summarize.d.ts +29 -0
  96. package/lib/node/summarize.js +131 -0
  97. package/lib/node/summarize.js.map +1 -0
  98. package/lib/node/tool.d.ts +54 -0
  99. package/lib/node/tool.js +123 -0
  100. package/lib/node/tool.js.map +1 -0
  101. package/lib/node/tts.d.ts +127 -0
  102. package/lib/node/tts.js +361 -0
  103. package/lib/node/tts.js.map +1 -0
  104. package/lib/node/wav.d.ts +32 -0
  105. package/lib/node/wav.js +63 -0
  106. package/lib/node/wav.js.map +1 -0
  107. package/locale/en.json +6 -0
  108. package/locale/zh.json +6 -0
  109. package/package.json +122 -4
@@ -0,0 +1,116 @@
1
+ /**
2
+ * The staged settings form behind the Plugins-page configuration card: one
3
+ * `SettingsFormModel` over the `mimo-speak` configuration namespace. The API key
4
+ * is a write-only control outside the section: a typed key stores through the
5
+ * host's `credentials/set` remote under the configured reference (`apiKeyEnv`,
6
+ * a section field the card reads but never renders as an input), and the card
7
+ * learns only whether one resolves, through the Host's status route.
8
+ * @module dsh-mimo-speak/client/settings-controller
9
+ */
10
+ import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
11
+ import type { SettingsFieldState, SettingsFormScope, SettingsFormShell } from '@deepseek-ai/dsh-client-ui-primitives';
12
+ import type { TtsSettings, TtsSynthesizeRequest, TtsTestResult } from '../settings.ts';
13
+ /** Field names inside the `mimo-speak` settings section. */
14
+ export type TtsSettingsField = keyof TtsSettings;
15
+ /** Synthesis verb shared by the Plugins-page card and the speak entries. */
16
+ export type TtsSettingsSynthesize = (request: TtsSynthesizeRequest) => Promise<Blob>;
17
+ /** Stores a credential literal under one reference in the host credentials store. */
18
+ export type TtsSetCredential = (ref: string, value: string) => Promise<boolean>;
19
+ /** What the Plugins-page card renders. */
20
+ export interface TtsSettingsState extends SettingsFormShell {
21
+ /** The write-only API key control (blank unless a key is being typed). */
22
+ apiKey: SettingsFieldState;
23
+ /** Whether the Host resolves a non-empty key through the reference. */
24
+ apiKeyConfigured: boolean;
25
+ /** The credential reference naming the key (shown as text, edited only in config). */
26
+ apiKeyEnv: string | undefined;
27
+ /** Endpoint base. */
28
+ baseUrl: SettingsFieldState;
29
+ /** Model id. */
30
+ model: SettingsFieldState;
31
+ /** Preset voice. */
32
+ voice: SettingsFieldState;
33
+ /** Host-local voice-clone sample path. */
34
+ voiceSamplePath: SettingsFieldState;
35
+ /** Default speaking style. */
36
+ style: SettingsFieldState;
37
+ /** Character budget. */
38
+ maxChars: SettingsFieldState;
39
+ /** Playback chunk size. */
40
+ chunkChars: SettingsFieldState;
41
+ /** Round-trip timeout. */
42
+ timeoutMs: SettingsFieldState;
43
+ /** Read new replies automatically. */
44
+ autoRead: SettingsFieldState;
45
+ /** Fallback engine used when MiMo synthesis fails. */
46
+ fallbackEngine: SettingsFieldState;
47
+ /** Edge-TTS voice used by the fallback engine. */
48
+ edgeVoice: SettingsFieldState;
49
+ /** Which parts of a reply are read aloud. */
50
+ readScope: SettingsFieldState;
51
+ /** Highlight the sentence being read inside the message. */
52
+ highlight: SettingsFieldState;
53
+ /** Show the seekable progress bar in the floating player. */
54
+ progressBar: SettingsFieldState;
55
+ /**
56
+ * Whether the running Host knows the `progressBar` key. A freshly installed
57
+ * client can meet a Host that still runs the previous schema — writing an
58
+ * unknown key makes the whole save roll back, so that control stays hidden
59
+ * until the Host reports the field.
60
+ */
61
+ supportsProgressBar: boolean;
62
+ /** Whether the running Host knows the `muteWhileRecording` key. */
63
+ muteWhileRecording: SettingsFieldState;
64
+ supportsMuteWhileRecording: boolean;
65
+ }
66
+ /** The registration-side face the Plugins-page card's slot entry injects. */
67
+ export interface TtsSettingsInjected {
68
+ hooks: {
69
+ /** Card snapshot bound by the renderer as useForm. */
70
+ form: SnapshotStore<TtsSettingsState>;
71
+ };
72
+ /** Stage draft text for one field (section fields or the API key control). */
73
+ edit: (field: TtsSettingsField | 'apiKey', text: string) => void;
74
+ /** Stage a clear so the field re-inherits the schema default. */
75
+ resetField: (field: TtsSettingsField) => void;
76
+ /** Write every staged edit (section fields, plus a typed key if any). */
77
+ save: () => void;
78
+ /** Drop every staged edit. */
79
+ discard: () => void;
80
+ /** @see TtsSettingsSynthesize */
81
+ synthesize: TtsSettingsSynthesize;
82
+ /** Run the Host-side round-trip health check against the live engine. */
83
+ test: () => Promise<TtsTestResult>;
84
+ }
85
+ /**
86
+ * Bridges the `mimo-speak` configuration namespace onto the Plugins-page card.
87
+ * @param scope - the bound settings scope for the `mimo-speak` namespace.
88
+ * @param setCredential - stores a key in the host credentials store.
89
+ */
90
+ export declare class TtsSettingsController {
91
+ private readonly scope;
92
+ private readonly setCredential;
93
+ private readonly form;
94
+ private readonly store;
95
+ private readonly unsubscribeStatus;
96
+ private readonly status;
97
+ constructor(scope: SettingsFormScope<TtsSettings>, setCredential: TtsSetCredential);
98
+ /**
99
+ * Build the face the card's slot registration injects.
100
+ * @returns the card's snapshot and its form actions.
101
+ */
102
+ inject(): TtsSettingsInjected;
103
+ /** Release form and status subscriptions. */
104
+ dispose(): void;
105
+ /**
106
+ * Store one typed key under the section's credential reference. A blank
107
+ * draft never reaches here (the form model writes nothing for it); a
108
+ * successful write refreshes the status mirror, so the configured flag
109
+ * follows immediately.
110
+ * @param text - the literal API key as typed.
111
+ * @returns whether the host accepted the write.
112
+ */
113
+ private writeApiKey;
114
+ /** @returns the card projection rebuilt from the form and the status mirror. */
115
+ private projection;
116
+ }
@@ -0,0 +1,201 @@
1
+ /**
2
+ * The staged settings form behind the Plugins-page configuration card: one
3
+ * `SettingsFormModel` over the `mimo-speak` configuration namespace. The API key
4
+ * is a write-only control outside the section: a typed key stores through the
5
+ * host's `credentials/set` remote under the configured reference (`apiKeyEnv`,
6
+ * a section field the card reads but never renders as an input), and the card
7
+ * learns only whether one resolves, through the Host's status route.
8
+ * @module dsh-mimo-speak/client/settings-controller
9
+ */
10
+ import { SettingsFormModel, settingsTextField, } from '@deepseek-ai/dsh-client-ui-primitives';
11
+ import { clearSpeechCache } from "./speech-cache.js";
12
+ import { requestSpeech, requestSpeechTest } from "./api.js";
13
+ import { refreshTtsStatus, ttsStatusStore } from "./status.js";
14
+ /** Form field name of the write-only API key control (not a section field). */
15
+ const API_KEY_CONTROL = 'apiKey';
16
+ /**
17
+ * A numeric spec that clamps into the range the Host schema declares
18
+ * (`chunkChars` 20–1000, the others at least 1). The shared
19
+ * `settingsNumberField` accepts any finite number, and one out-of-range value
20
+ * makes the Host reject the whole section — which the UI can only report as
21
+ * 「本部署没有接受这些值」. Clamping here keeps every save valid.
22
+ * @param field - section field name.
23
+ * @param min - smallest value the Host accepts.
24
+ * @param max - largest value the Host accepts, when it has one.
25
+ * @returns the field's conversion spec.
26
+ */
27
+ function settingsClampedNumberField(field, min, max) {
28
+ return {
29
+ field,
30
+ format: value => (typeof value === 'number' ? String(value) : ''),
31
+ parse: (text) => {
32
+ const trimmed = text.trim();
33
+ if (trimmed === '')
34
+ return { kind: 'clear' };
35
+ const parsed = Number(trimmed);
36
+ if (!Number.isFinite(parsed))
37
+ return undefined;
38
+ const rounded = Math.round(parsed);
39
+ const value = Math.min(max ?? Number.POSITIVE_INFINITY, Math.max(min, rounded));
40
+ return { kind: 'set', value };
41
+ },
42
+ };
43
+ }
44
+ /** Section fields the card edits; `apiKeyEnv` stays a read-only ref name. */
45
+ const SECTION_SPECS = [
46
+ settingsTextField('baseUrl'),
47
+ settingsTextField('model'),
48
+ settingsTextField('voice'),
49
+ settingsTextField('voiceSamplePath'),
50
+ settingsTextField('style'),
51
+ settingsClampedNumberField('maxChars', 1),
52
+ settingsClampedNumberField('chunkChars', 20, 1000),
53
+ settingsClampedNumberField('timeoutMs', 1),
54
+ {
55
+ field: 'autoRead',
56
+ format: value => (value === true ? 'true' : 'false'),
57
+ parse: text => text === 'true'
58
+ ? { kind: 'set', value: true }
59
+ : text === 'false'
60
+ ? { kind: 'set', value: false }
61
+ : undefined,
62
+ },
63
+ {
64
+ field: 'fallbackEngine',
65
+ format: value => (value === 'edge' ? 'edge' : 'none'),
66
+ parse: text => (text === 'edge' || text === 'none' ? { kind: 'set', value: text } : undefined),
67
+ },
68
+ settingsTextField('edgeVoice'),
69
+ {
70
+ field: 'readScope',
71
+ format: value => (value === 'all' || value === 'smart' || value === 'brief' ? value : 'text'),
72
+ parse: text => (text === 'text' || text === 'all' || text === 'smart' || text === 'brief'
73
+ ? { kind: 'set', value: text }
74
+ : undefined),
75
+ },
76
+ {
77
+ field: 'highlight',
78
+ format: value => (value === true ? 'true' : 'false'),
79
+ parse: text => text === 'true'
80
+ ? { kind: 'set', value: true }
81
+ : text === 'false'
82
+ ? { kind: 'set', value: false }
83
+ : undefined,
84
+ },
85
+ {
86
+ field: 'muteWhileRecording',
87
+ format: value => (value === true ? 'true' : 'false'),
88
+ parse: text => text === 'true'
89
+ ? { kind: 'set', value: true }
90
+ : text === 'false'
91
+ ? { kind: 'set', value: false }
92
+ : undefined,
93
+ },
94
+ {
95
+ field: 'progressBar',
96
+ format: value => (value === true ? 'true' : 'false'),
97
+ parse: text => text === 'true'
98
+ ? { kind: 'set', value: true }
99
+ : text === 'false'
100
+ ? { kind: 'set', value: false }
101
+ : undefined,
102
+ },
103
+ ];
104
+ /**
105
+ * Bridges the `mimo-speak` configuration namespace onto the Plugins-page card.
106
+ * @param scope - the bound settings scope for the `mimo-speak` namespace.
107
+ * @param setCredential - stores a key in the host credentials store.
108
+ */
109
+ export class TtsSettingsController {
110
+ scope;
111
+ setCredential;
112
+ form;
113
+ store;
114
+ unsubscribeStatus;
115
+ status = ttsStatusStore();
116
+ constructor(scope, setCredential) {
117
+ this.scope = scope;
118
+ this.setCredential = setCredential;
119
+ this.form = new SettingsFormModel(scope, SECTION_SPECS, [{
120
+ field: API_KEY_CONTROL,
121
+ write: text => this.writeApiKey(text),
122
+ }]);
123
+ this.store = this.form.bind(() => this.projection());
124
+ // The status mirror answers "is a key configured", which the form section
125
+ // cannot: secrets never ride a response. Its changes republish the card.
126
+ this.unsubscribeStatus = this.status.subscribe(() => { this.store.set(this.projection()); });
127
+ void refreshTtsStatus();
128
+ }
129
+ /**
130
+ * Build the face the card's slot registration injects.
131
+ * @returns the card's snapshot and its form actions.
132
+ */
133
+ inject() {
134
+ const actions = this.form.actions();
135
+ return {
136
+ hooks: { form: this.store },
137
+ edit: (field, text) => { actions.edit(field, text); },
138
+ resetField: (field) => { actions.resetField(field); },
139
+ // Drop cached audio on save: the user just asked for different audio, so
140
+ // replaying a take synthesized with the previous voice or style would
141
+ // quietly ignore the change. Refresh the status too: a newly set or
142
+ // cleared clone sample changes `hasVoiceSample`, which decides whether
143
+ // the speak entry may use the streaming path.
144
+ save: () => { clearSpeechCache(); actions.save(); void refreshTtsStatus(); },
145
+ discard: () => { actions.discard(); },
146
+ synthesize: request => requestSpeech(request),
147
+ test: () => requestSpeechTest(),
148
+ };
149
+ }
150
+ /** Release form and status subscriptions. */
151
+ dispose() {
152
+ this.unsubscribeStatus();
153
+ this.form.dispose();
154
+ }
155
+ /**
156
+ * Store one typed key under the section's credential reference. A blank
157
+ * draft never reaches here (the form model writes nothing for it); a
158
+ * successful write refreshes the status mirror, so the configured flag
159
+ * follows immediately.
160
+ * @param text - the literal API key as typed.
161
+ * @returns whether the host accepted the write.
162
+ */
163
+ async writeApiKey(text) {
164
+ const ref = (this.scope.getSnapshot().value?.apiKeyEnv ?? '').trim();
165
+ if (ref === '')
166
+ return false;
167
+ const ok = await this.setCredential(ref, text.trim());
168
+ if (ok)
169
+ void refreshTtsStatus();
170
+ return ok;
171
+ }
172
+ /** @returns the card projection rebuilt from the form and the status mirror. */
173
+ projection() {
174
+ return {
175
+ ...this.form.shell(),
176
+ apiKey: this.form.field(API_KEY_CONTROL),
177
+ apiKeyConfigured: this.status.getSnapshot().configured,
178
+ apiKeyEnv: this.scope.getSnapshot().value?.apiKeyEnv,
179
+ baseUrl: this.form.field('baseUrl'),
180
+ model: this.form.field('model'),
181
+ voice: this.form.field('voice'),
182
+ voiceSamplePath: this.form.field('voiceSamplePath'),
183
+ style: this.form.field('style'),
184
+ maxChars: this.form.field('maxChars'),
185
+ chunkChars: this.form.field('chunkChars'),
186
+ timeoutMs: this.form.field('timeoutMs'),
187
+ autoRead: this.form.field('autoRead'),
188
+ fallbackEngine: this.form.field('fallbackEngine'),
189
+ edgeVoice: this.form.field('edgeVoice'),
190
+ readScope: this.form.field('readScope'),
191
+ highlight: this.form.field('highlight'),
192
+ progressBar: this.form.field('progressBar'),
193
+ // An older Host answers /status without the key: hide the control rather
194
+ // than let a save fail with "the deployment did not accept these values".
195
+ supportsProgressBar: typeof this.status.getSnapshot().progressBar === 'boolean',
196
+ muteWhileRecording: this.form.field('muteWhileRecording'),
197
+ supportsMuteWhileRecording: typeof this.status.getSnapshot().muteWhileRecording === 'boolean',
198
+ };
199
+ }
200
+ }
201
+ //# sourceMappingURL=settings-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-controller.js","sourceRoot":"","sources":["../../../src/client/settings-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,uCAAuC,CAAA;AAK9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,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ACzE,0EAA0E;YAC1E,mBAAmB,EAAE,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,WAAW,KAAK,SAAS;YAC/E,kBAAkB,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC;YACzD,0BAA0B,EAAE,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,kBAAkB,KAAK,SAAS;SAC9F,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Registration facts for the two configuration surfaces. Kept as data so the
3
+ * slot wiring can be asserted without mounting React or a DSH client.
4
+ * @module dsh-mimo-speak/client/settings-registration
5
+ */
6
+ /** List-slot id of the MiMo page in DSH global Settings. */
7
+ export declare const SETTINGS_SECTION_ID = "mimo-speak-settings";
8
+ /** Nav order of the MiMo page; below the stock pages (which end near 60). */
9
+ export declare const SETTINGS_SECTION_ORDER = 80;
10
+ /** DOM id prefixes: the Plugins card keeps its historic ids; Settings differs. */
11
+ export declare const PLUGINS_FORM_ID_PREFIX = "mimo-speak";
12
+ export declare const SETTINGS_FORM_ID_PREFIX = "mimo-speak-settings";
13
+ /**
14
+ * The two surfaces must never share one controller or one id prefix: SettingsForm
15
+ * discards drafts on unmount, so a shared controller would let one surface wipe
16
+ * the other's edits.
17
+ */
18
+ export declare function surfacesAreIndependent(plugins: {
19
+ controller: unknown;
20
+ idPrefix: string;
21
+ }, settings: {
22
+ controller: unknown;
23
+ idPrefix: string;
24
+ }): boolean;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Registration facts for the two configuration surfaces. Kept as data so the
3
+ * slot wiring can be asserted without mounting React or a DSH client.
4
+ * @module dsh-mimo-speak/client/settings-registration
5
+ */
6
+ /** List-slot id of the MiMo page in DSH global Settings. */
7
+ export const SETTINGS_SECTION_ID = 'mimo-speak-settings';
8
+ /** Nav order of the MiMo page; below the stock pages (which end near 60). */
9
+ export const SETTINGS_SECTION_ORDER = 80;
10
+ /** DOM id prefixes: the Plugins card keeps its historic ids; Settings differs. */
11
+ export const PLUGINS_FORM_ID_PREFIX = 'mimo-speak';
12
+ export const SETTINGS_FORM_ID_PREFIX = 'mimo-speak-settings';
13
+ /**
14
+ * The two surfaces must never share one controller or one id prefix: SettingsForm
15
+ * discards drafts on unmount, so a shared controller would let one surface wipe
16
+ * the other's edits.
17
+ */
18
+ export function surfacesAreIndependent(plugins, settings) {
19
+ return plugins.controller !== settings.controller && plugins.idPrefix !== settings.idPrefix;
20
+ }
21
+ //# sourceMappingURL=settings-registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-registration.js","sourceRoot":"","sources":["../../../src/client/settings-registration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAA;AACxD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AACxC,kFAAkF;AAClF,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAA;AAClD,MAAM,CAAC,MAAM,uBAAuB,GAAG,qBAAqB,CAAA;AAE5D;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAkD,EAAE,QAAmD;IAC5I,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,CAAA;AAC7F,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Injected faces and composed props of this plugin's two slot entries: the
3
+ * speak control inside `conversation.chat.assistant-actions` and the plugin's
4
+ * configuration card inside `plugins.bundle.config` (the Plugins page's keyed
5
+ * slot for bundle-owned configuration).
6
+ *
7
+ * Both slots are declared and typed by other packages (ui-conversation and the
8
+ * Plugins page owner ui-plugin-manager); this package only contributes
9
+ * entries, so no SlotMap merge lives here. Live state arrives through the
10
+ * `hooks` compartment (the framework standard kit binds `status` into
11
+ * `useStatus` and `form` into `useForm`), and business verbs arrive as plain
12
+ * callbacks.
13
+ * @module dsh-mimo-speak/client/slots
14
+ */
15
+ import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
16
+ import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
17
+ import type { TtsStatusView, TtsSynthesizeRequest } from '../settings.ts';
18
+ import type { TtsSettingsInjected } from './settings-controller.ts';
19
+ export type { TtsSettingsInjected, TtsSettingsState } from './settings-controller.ts';
20
+ /** Injected business face of one assistant-message speak entry. */
21
+ export interface SpeakActionInjected {
22
+ hooks: {
23
+ /** The Host's resolved engine configuration (never secrets). */
24
+ status: SnapshotStore<TtsStatusView>;
25
+ };
26
+ /** Load the engine status once, on first interaction. */
27
+ ensureStatus: () => void;
28
+ /**
29
+ * Synthesize one text into playable audio.
30
+ * @param request - text and optional style/voice overrides.
31
+ * @returns the WAV payload as a Blob.
32
+ */
33
+ synthesize: (request: TtsSynthesizeRequest) => Promise<Blob>;
34
+ }
35
+ /** Full props of one assistant-message speak entry. */
36
+ export type SpeakActionProps = PropsRuntime<'conversation.chat.assistant-actions'> & InjectFace<SpeakActionInjected> & PropsLocale<'settings.mimo-speak'>;
37
+ /**
38
+ * Full props of the plugin's configuration card on the Plugins page. The
39
+ * `view` owner prop is `'page'` here — bundle configuration renders only the
40
+ * page form, never the summary one-liner.
41
+ */
42
+ export type BundleConfigCardProps = PropsRuntime<'plugins.bundle.config'> & InjectFace<TtsSettingsInjected> & PropsLocale<'settings.mimo-speak'>;
43
+ /**
44
+ * Full props of the MiMo page inside the DSH global Settings panel. The
45
+ * `settings.section` list slot supplies only `close`; that shell affordance is
46
+ * intentionally unused — saving is owned by the shared form.
47
+ */
48
+ export type SettingsSectionCardProps = PropsRuntime<'settings.section'> & InjectFace<TtsSettingsInjected> & PropsLocale<'settings.mimo-speak'>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Injected faces and composed props of this plugin's two slot entries: the
3
+ * speak control inside `conversation.chat.assistant-actions` and the plugin's
4
+ * configuration card inside `plugins.bundle.config` (the Plugins page's keyed
5
+ * slot for bundle-owned configuration).
6
+ *
7
+ * Both slots are declared and typed by other packages (ui-conversation and the
8
+ * Plugins page owner ui-plugin-manager); this package only contributes
9
+ * entries, so no SlotMap merge lives here. Live state arrives through the
10
+ * `hooks` compartment (the framework standard kit binds `status` into
11
+ * `useStatus` and `form` into `useForm`), and business verbs arrive as plain
12
+ * callbacks.
13
+ * @module dsh-mimo-speak/client/slots
14
+ */
15
+ //# sourceMappingURL=slots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slots.js","sourceRoot":"","sources":["../../../src/client/slots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Replay cache for synthesized speech, keyed by the *sound* of a chunk.
3
+ *
4
+ * Replaying the same passage (the same message again, or overlapping text
5
+ * across replies) should not call the provider twice. But the key must include
6
+ * everything that changes how it sounds — otherwise changing the voice, style
7
+ * or model keeps replaying the old take, and the settings appear to be ignored.
8
+ * `SpeechSignature` is that "how it sounds" fingerprint.
9
+ * @module dsh-mimo-speak/client/speech-cache
10
+ */
11
+ /** Which engine produced a cached chunk. */
12
+ export type CachedEngine = 'mimo' | 'edge';
13
+ /** One cached chunk: its object URL and the engine that answered. */
14
+ export interface CachedSpeech {
15
+ url: string;
16
+ engine: CachedEngine;
17
+ }
18
+ /** Everything that makes the same words sound different. */
19
+ export interface SpeechSignature {
20
+ /** Effective preset voice (or clone sample path). */
21
+ voice: string;
22
+ /** Effective model id. */
23
+ model: string;
24
+ /** Style phrase the Host wraps around the text, when set. */
25
+ style: string;
26
+ /** Endpoint base, so switching providers does not reuse audio. */
27
+ baseUrl: string;
28
+ /** Fallback Edge voice, used when MiMo is not the one answering. */
29
+ edgeVoice: string;
30
+ /** Per-request character budget, which can change the truncation point. */
31
+ maxChars: number;
32
+ }
33
+ /**
34
+ * Build the cache key for one chunk.
35
+ * @param signature - how the current configuration sounds.
36
+ * @param text - the chunk text.
37
+ * @returns a key that changes whenever the sound or the words do.
38
+ */
39
+ export declare function speechCacheKey(signature: SpeechSignature, text: string): string;
40
+ /**
41
+ * Look one chunk up.
42
+ * @param key - from `speechCacheKey`.
43
+ * @returns the cached audio, when present.
44
+ */
45
+ export declare function cachedSpeech(key: string): CachedSpeech | undefined;
46
+ /**
47
+ * Store one chunk, dropping the oldest entries past the cap.
48
+ * @param key - from `speechCacheKey`.
49
+ * @param value - the object URL and its engine.
50
+ */
51
+ export declare function cacheSpeech(key: string, value: CachedSpeech): void;
52
+ /**
53
+ * Drop every cached chunk.
54
+ *
55
+ * Called after a settings save: the user just asked for different audio, so
56
+ * replaying anything cached under the previous configuration would quietly
57
+ * ignore the change.
58
+ */
59
+ export declare function clearSpeechCache(): void;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Replay cache for synthesized speech, keyed by the *sound* of a chunk.
3
+ *
4
+ * Replaying the same passage (the same message again, or overlapping text
5
+ * across replies) should not call the provider twice. But the key must include
6
+ * everything that changes how it sounds — otherwise changing the voice, style
7
+ * or model keeps replaying the old take, and the settings appear to be ignored.
8
+ * `SpeechSignature` is that "how it sounds" fingerprint.
9
+ * @module dsh-mimo-speak/client/speech-cache
10
+ */
11
+ /** Entries kept before the oldest are revoked. */
12
+ const CACHE_CAP = 60;
13
+ const cache = new Map();
14
+ const order = [];
15
+ /**
16
+ * Build the cache key for one chunk.
17
+ * @param signature - how the current configuration sounds.
18
+ * @param text - the chunk text.
19
+ * @returns a key that changes whenever the sound or the words do.
20
+ */
21
+ export function speechCacheKey(signature, text) {
22
+ return [
23
+ signature.voice, signature.model, signature.style, signature.baseUrl,
24
+ signature.edgeVoice, String(signature.maxChars), text,
25
+ ].join('\u0000');
26
+ }
27
+ /**
28
+ * Look one chunk up.
29
+ * @param key - from `speechCacheKey`.
30
+ * @returns the cached audio, when present.
31
+ */
32
+ export function cachedSpeech(key) {
33
+ return cache.get(key);
34
+ }
35
+ /**
36
+ * Store one chunk, dropping the oldest entries past the cap.
37
+ * @param key - from `speechCacheKey`.
38
+ * @param value - the object URL and its engine.
39
+ */
40
+ export function cacheSpeech(key, value) {
41
+ if (cache.has(key))
42
+ return;
43
+ cache.set(key, value);
44
+ order.push(key);
45
+ while (order.length > CACHE_CAP) {
46
+ const oldest = order.shift();
47
+ if (oldest === undefined)
48
+ break;
49
+ const stale = cache.get(oldest);
50
+ cache.delete(oldest);
51
+ if (stale !== undefined)
52
+ URL.revokeObjectURL(stale.url);
53
+ }
54
+ }
55
+ /**
56
+ * Drop every cached chunk.
57
+ *
58
+ * Called after a settings save: the user just asked for different audio, so
59
+ * replaying anything cached under the previous configuration would quietly
60
+ * ignore the change.
61
+ */
62
+ export function clearSpeechCache() {
63
+ for (const value of cache.values())
64
+ URL.revokeObjectURL(value.url);
65
+ cache.clear();
66
+ order.length = 0;
67
+ }
68
+ //# sourceMappingURL=speech-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"speech-cache.js","sourceRoot":"","sources":["../../../src/client/speech-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2BH,kDAAkD;AAClD,MAAM,SAAS,GAAG,EAAE,CAAA;AAEpB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAwB,CAAA;AAC7C,MAAM,KAAK,GAAa,EAAE,CAAA;AAE1B;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,SAA0B,EAAE,IAAY;IACrE,OAAO;QACL,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO;QACpE,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,IAAI;KACtD,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,KAAmB;IAC1D,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAM;IAC1B,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACrB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACf,OAAO,KAAK,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;QAC5B,IAAI,MAAM,KAAK,SAAS;YAAE,MAAK;QAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAC/B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACpB,IAAI,KAAK,KAAK,SAAS;YAAE,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACzD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB;IAC9B,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE;QAAE,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClE,KAAK,CAAC,KAAK,EAAE,CAAA;IACb,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;AAClB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Sentence-aligned text splitting for pipelined playback.
3
+ *
4
+ * The browser splits already-normalized speakable text into chunks around a
5
+ * configured size, then synthesizes and plays them back-to-back while the next
6
+ * chunk is still being produced. Splitting at sentence boundaries keeps chunks
7
+ * sounding natural; a sentence longer than the budget is hard-split at a
8
+ * punctuation or whitespace seam.
9
+ * @module dsh-mimo-speak/client/split-speech
10
+ */
11
+ /**
12
+ * Split normalized speakable text into ordered chunks at sentence boundaries.
13
+ *
14
+ * @param text - plain text, already stripped of Markdown by the Host's
15
+ * normalizer; this function only partitions it for playback.
16
+ * @param chunkChars - target chunk size in characters.
17
+ * @returns speakable chunks, each non-empty and at most `chunkChars` long
18
+ * except when a single unbroken sentence must be hard-split.
19
+ */
20
+ export declare function splitForSpeech(text: string, chunkChars: number): string[];