@hyperwindmill/caretaker-cli 0.17.0 → 0.18.0
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/dist/cli/web/server.js +2 -2
- package/dist/cli/web/voice_backend.d.ts +17 -5
- package/dist/cli/web/voice_backend.d.ts.map +1 -1
- package/dist/cli/web/voice_backend.js +253 -114
- package/dist/cli/web/voice_proxy.d.ts +16 -0
- package/dist/cli/web/voice_proxy.d.ts.map +1 -1
- package/dist/cli/web/voice_proxy.js +103 -8
- package/dist/store/json.d.ts.map +1 -1
- package/dist/store/json.js +3 -0
- package/dist/webview/standalone.js +982 -777
- package/dist/webview/standalone.js.map +4 -4
- package/package.json +3 -3
|
@@ -11,6 +11,16 @@ export declare function resolveVoice(): Promise<{
|
|
|
11
11
|
error: string;
|
|
12
12
|
}>;
|
|
13
13
|
export declare function voiceAuthHeaders(voice: VoiceConfig): Record<string, string>;
|
|
14
|
+
/** Build auth headers from an explicit key (which may be stored encrypted).
|
|
15
|
+
* Used so the synthesis leg can send its own key — or none at all. */
|
|
16
|
+
export declare function authHeaders(apiKey: string | undefined | null): Record<string, string>;
|
|
17
|
+
/** Where synthesis goes. A configured `ttsEndpoint` takes its own key — or
|
|
18
|
+
* none at all: the transcription key belongs to a different host and must
|
|
19
|
+
* not leak to a third-party TTS service. */
|
|
20
|
+
export declare function ttsTarget(voice: VoiceConfig): {
|
|
21
|
+
endpoint: string;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
};
|
|
14
24
|
export declare function registerVoiceProxy(app: Hono): void;
|
|
15
25
|
/**
|
|
16
26
|
* Read a speech endpoint's installed models so the settings form can offer real
|
|
@@ -20,6 +30,12 @@ export declare function registerVoiceProxy(app: Hono): void;
|
|
|
20
30
|
* those are correctly scoped, unlike the global /v1/audio/voices catalogue, which
|
|
21
31
|
* ignores its model_id parameter. A plain OpenAI-compatible endpoint reports
|
|
22
32
|
* neither, so every id is offered for both tasks and the voice stays free text.
|
|
33
|
+
*
|
|
34
|
+
* openai-edge-tts reports models under `{"models": [...]}` (not `{"data": [...]}`),
|
|
35
|
+
* with no task metadata, and publishes its voice list at `/voices/all` rather than
|
|
36
|
+
* per model — voice ids are under the `"name"` key, not `"id"`. When no TTS entry
|
|
37
|
+
* carries its own voices, a best-effort `/voices/all` fetch fills them in; failure
|
|
38
|
+
* degrades to the free-text voice field, which already works.
|
|
23
39
|
*/
|
|
24
40
|
export declare function fetchVoiceCatalog(endpoint: string, apiKey?: string | null): Promise<VoiceCatalog>;
|
|
25
41
|
//# sourceMappingURL=voice_proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voice_proxy.d.ts","sourceRoot":"","sources":["../../../src/cli/web/voice_proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAIzE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,GAAG,IAAI,CAUnF;AAED;;0EAE0E;AAC1E,wBAAsB,YAAY,IAAI,OAAO,CAAC;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAUxF;AASD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"voice_proxy.d.ts","sourceRoot":"","sources":["../../../src/cli/web/voice_proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAIzE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,GAAG,IAAI,CAUnF;AAED;;0EAE0E;AAC1E,wBAAsB,YAAY,IAAI,OAAO,CAAC;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAUxF;AASD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE3E;AAED;uEACuE;AACvE,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGrF;AAED;;6CAE6C;AAC7C,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAInF;AAOD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CA2ElD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,YAAY,CAAC,CA6DvB"}
|
|
@@ -35,9 +35,23 @@ function plainKey(apiKey) {
|
|
|
35
35
|
return isEncrypted(apiKey) ? decrypt(apiKey) : apiKey;
|
|
36
36
|
}
|
|
37
37
|
export function voiceAuthHeaders(voice) {
|
|
38
|
-
|
|
38
|
+
return authHeaders(voice.apiKey);
|
|
39
|
+
}
|
|
40
|
+
/** Build auth headers from an explicit key (which may be stored encrypted).
|
|
41
|
+
* Used so the synthesis leg can send its own key — or none at all. */
|
|
42
|
+
export function authHeaders(apiKey) {
|
|
43
|
+
const key = plainKey(apiKey);
|
|
39
44
|
return key ? { authorization: `Bearer ${key}` } : {};
|
|
40
45
|
}
|
|
46
|
+
/** Where synthesis goes. A configured `ttsEndpoint` takes its own key — or
|
|
47
|
+
* none at all: the transcription key belongs to a different host and must
|
|
48
|
+
* not leak to a third-party TTS service. */
|
|
49
|
+
export function ttsTarget(voice) {
|
|
50
|
+
const tts = voice.ttsEndpoint?.trim();
|
|
51
|
+
if (!tts)
|
|
52
|
+
return { endpoint: voice.endpoint, apiKey: voice.apiKey };
|
|
53
|
+
return { endpoint: tts, ...(voice.ttsApiKey ? { apiKey: voice.ttsApiKey } : {}) };
|
|
54
|
+
}
|
|
41
55
|
/** Join a base URL and a path without doubling or dropping the slash. */
|
|
42
56
|
function url(endpoint, suffix) {
|
|
43
57
|
return `${endpoint.replace(/\/+$/, '')}${suffix}`;
|
|
@@ -99,9 +113,10 @@ export function registerVoiceProxy(app) {
|
|
|
99
113
|
}
|
|
100
114
|
let upstream;
|
|
101
115
|
try {
|
|
102
|
-
|
|
116
|
+
const target = ttsTarget(voice);
|
|
117
|
+
upstream = await fetch(url(target.endpoint, '/audio/speech'), {
|
|
103
118
|
method: 'POST',
|
|
104
|
-
headers: { ...
|
|
119
|
+
headers: { ...authHeaders(target.apiKey), 'content-type': 'application/json' },
|
|
105
120
|
body: JSON.stringify(payload),
|
|
106
121
|
});
|
|
107
122
|
}
|
|
@@ -126,17 +141,28 @@ export function registerVoiceProxy(app) {
|
|
|
126
141
|
* those are correctly scoped, unlike the global /v1/audio/voices catalogue, which
|
|
127
142
|
* ignores its model_id parameter. A plain OpenAI-compatible endpoint reports
|
|
128
143
|
* neither, so every id is offered for both tasks and the voice stays free text.
|
|
144
|
+
*
|
|
145
|
+
* openai-edge-tts reports models under `{"models": [...]}` (not `{"data": [...]}`),
|
|
146
|
+
* with no task metadata, and publishes its voice list at `/voices/all` rather than
|
|
147
|
+
* per model — voice ids are under the `"name"` key, not `"id"`. When no TTS entry
|
|
148
|
+
* carries its own voices, a best-effort `/voices/all` fetch fills them in; failure
|
|
149
|
+
* degrades to the free-text voice field, which already works.
|
|
129
150
|
*/
|
|
130
151
|
export async function fetchVoiceCatalog(endpoint, apiKey) {
|
|
131
152
|
const key = plainKey(apiKey);
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
});
|
|
153
|
+
const headers = authHeaders(key);
|
|
154
|
+
const res = await fetch(url(endpoint, '/models'), { headers });
|
|
135
155
|
if (!res.ok) {
|
|
136
156
|
throw new Error(`${res.status} ${res.statusText}: ${(await res.text()).slice(0, 300)}`);
|
|
137
157
|
}
|
|
138
158
|
const body = (await res.json());
|
|
139
|
-
|
|
159
|
+
// Accept both { "data": [...] } (OpenAI/Speaches) and { "models": [...] }
|
|
160
|
+
// (openai-edge-tts) — the latter uses a non-standard envelope key.
|
|
161
|
+
const rows = Array.isArray(body?.data)
|
|
162
|
+
? body.data
|
|
163
|
+
: Array.isArray(body?.models)
|
|
164
|
+
? body.models
|
|
165
|
+
: [];
|
|
140
166
|
const stt = [];
|
|
141
167
|
const tts = [];
|
|
142
168
|
const untasked = [];
|
|
@@ -173,8 +199,77 @@ export async function fetchVoiceCatalog(endpoint, apiKey) {
|
|
|
173
199
|
}
|
|
174
200
|
// No task metadata anywhere: offer everything for both, voices unknown.
|
|
175
201
|
if (stt.length === 0 && tts.length === 0) {
|
|
176
|
-
|
|
202
|
+
const ttsModels = untasked.map((id) => ({ id, voices: [] }));
|
|
203
|
+
await fillVoicesFromCatalog(endpoint, headers, ttsModels);
|
|
204
|
+
return { stt: untasked, tts: ttsModels };
|
|
177
205
|
}
|
|
178
206
|
// Mixed: keep the untasked ids selectable for transcription, the likelier use.
|
|
207
|
+
if (tts.length > 0 && tts.every((m) => m.voices.length === 0)) {
|
|
208
|
+
await fillVoicesFromCatalog(endpoint, headers, tts);
|
|
209
|
+
}
|
|
179
210
|
return { stt: [...stt, ...untasked], tts };
|
|
180
211
|
}
|
|
212
|
+
/** Best-effort GET <endpoint>/voices/all — openai-edge-tts publishes its voice
|
|
213
|
+
* list here rather than per model. Voice ids are under the `"name"` key (not
|
|
214
|
+
* `"id"`), the route defaults to en-US only on `/voices` (not `/voices/all`),
|
|
215
|
+
* and it may require auth. Failure is silent: an endpoint without the route
|
|
216
|
+
* degrades to the free-text voice field, which already works. */
|
|
217
|
+
async function fillVoicesFromCatalog(endpoint, headers, ttsModels) {
|
|
218
|
+
if (ttsModels.length === 0)
|
|
219
|
+
return;
|
|
220
|
+
let res;
|
|
221
|
+
try {
|
|
222
|
+
res = await fetch(url(endpoint, '/voices/all'), { headers });
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (!res.ok)
|
|
228
|
+
return;
|
|
229
|
+
let body;
|
|
230
|
+
try {
|
|
231
|
+
body = await res.json();
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
// Accept both a bare array and a { "voices": [...] } envelope. The edge-tts
|
|
237
|
+
// shape is { "voices": [{ "name": "it-IT-ElsaNeural", "gender": "Female",
|
|
238
|
+
// "language": "it-IT" }, ...] }.
|
|
239
|
+
const voiceRows = Array.isArray(body)
|
|
240
|
+
? body
|
|
241
|
+
: Array.isArray(body?.voices)
|
|
242
|
+
? body.voices
|
|
243
|
+
: [];
|
|
244
|
+
if (voiceRows.length === 0)
|
|
245
|
+
return;
|
|
246
|
+
const voices = voiceRows.flatMap((v) => {
|
|
247
|
+
if (!v || typeof v !== 'object')
|
|
248
|
+
return [];
|
|
249
|
+
const voice = v;
|
|
250
|
+
// edge-tts uses "name" for the voice id; Speaches uses "id"; some APIs use
|
|
251
|
+
// "ShortName". Accept any, preferring "name" first for edge-tts.
|
|
252
|
+
const id = typeof voice.name === 'string'
|
|
253
|
+
? voice.name
|
|
254
|
+
: typeof voice.id === 'string'
|
|
255
|
+
? voice.id
|
|
256
|
+
: typeof voice.ShortName === 'string'
|
|
257
|
+
? voice.ShortName
|
|
258
|
+
: null;
|
|
259
|
+
if (!id)
|
|
260
|
+
return [];
|
|
261
|
+
const language = voice.language ?? voice.Locale;
|
|
262
|
+
const gender = voice.gender ?? voice.Gender;
|
|
263
|
+
return [
|
|
264
|
+
{
|
|
265
|
+
id,
|
|
266
|
+
...(typeof language === 'string' ? { language } : {}),
|
|
267
|
+
...(typeof gender === 'string' ? { gender } : {}),
|
|
268
|
+
},
|
|
269
|
+
];
|
|
270
|
+
});
|
|
271
|
+
if (voices.length > 0) {
|
|
272
|
+
for (const model of ttsModels)
|
|
273
|
+
model.voices = voices;
|
|
274
|
+
}
|
|
275
|
+
}
|
package/dist/store/json.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/store/json.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK7F,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AACD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AACD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AACD,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AACD,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,eAAO,MAAM,aAAa,EAAE,eAG3B,CAAC;AAqDF,wBAAsB,UAAU,IAAI,OAAO,CAAC,eAAe,CAAC,CAE3D;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/store/json.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK7F,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AACD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AACD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AACD,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AACD,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,eAAO,MAAM,aAAa,EAAE,eAG3B,CAAC;AAqDF,wBAAsB,UAAU,IAAI,OAAO,CAAC,eAAe,CAAC,CAE3D;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBlE;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAEzD;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CASxD;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;AAMD,wBAAsB,cAAc,IAAI,OAAO,CAAC,cAAc,CAAC,CAO9D;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAExE;AAID;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAO5E"}
|
package/dist/store/json.js
CHANGED
|
@@ -91,6 +91,9 @@ export async function saveConfig(c) {
|
|
|
91
91
|
if (c.voice?.apiKey && !isEncrypted(c.voice.apiKey)) {
|
|
92
92
|
c.voice.apiKey = encrypt(c.voice.apiKey);
|
|
93
93
|
}
|
|
94
|
+
if (c.voice?.ttsApiKey && !isEncrypted(c.voice.ttsApiKey)) {
|
|
95
|
+
c.voice.ttsApiKey = encrypt(c.voice.ttsApiKey);
|
|
96
|
+
}
|
|
94
97
|
await writeJson(configPath(), c);
|
|
95
98
|
}
|
|
96
99
|
export async function loadAgents() {
|