@hyperwindmill/caretaker-cli 0.28.0 → 0.30.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/agents/dispatch.d.ts.map +1 -1
- package/dist/agents/dispatch.js +4 -1
- package/dist/cli/web/scheduler/telegram.d.ts +27 -0
- package/dist/cli/web/scheduler/telegram.d.ts.map +1 -1
- package/dist/cli/web/scheduler/telegram.js +133 -78
- package/dist/cli/web/scheduler/telegram_media.d.ts +73 -0
- package/dist/cli/web/scheduler/telegram_media.d.ts.map +1 -0
- package/dist/cli/web/scheduler/telegram_media.js +90 -0
- package/dist/cli/web/scheduler/telegram_window.d.ts +68 -0
- package/dist/cli/web/scheduler/telegram_window.d.ts.map +1 -0
- package/dist/cli/web/scheduler/telegram_window.js +144 -0
- package/dist/cli/web/server.d.ts.map +1 -1
- package/dist/cli/web/server.js +29 -7
- package/dist/cli/web/session_scope.d.ts +11 -0
- package/dist/cli/web/session_scope.d.ts.map +1 -0
- package/dist/cli/web/session_scope.js +13 -0
- package/dist/cli/web/turn_guard.d.ts +9 -0
- package/dist/cli/web/turn_guard.d.ts.map +1 -0
- package/dist/cli/web/turn_guard.js +18 -0
- package/dist/cli/web/voice_builtin.d.ts +3 -0
- package/dist/cli/web/voice_builtin.d.ts.map +1 -0
- package/dist/cli/web/voice_builtin.js +55 -0
- package/dist/cli/web/voice_proxy.d.ts +33 -1
- package/dist/cli/web/voice_proxy.d.ts.map +1 -1
- package/dist/cli/web/voice_proxy.js +173 -27
- package/dist/commands/loader.js +2 -2
- package/dist/harness/tools/builtin/index.d.ts.map +1 -1
- package/dist/harness/tools/builtin/index.js +4 -0
- package/dist/harness/tools/builtin/set_workspace.d.ts +3 -0
- package/dist/harness/tools/builtin/set_workspace.d.ts.map +1 -0
- package/dist/harness/tools/builtin/set_workspace.js +49 -0
- package/dist/plugins/manifest.d.ts +1 -1
- package/dist/plugins/manifest.js +1 -1
- package/dist/session/store.d.ts +6 -0
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js +8 -0
- package/dist/session/types.d.ts +4 -0
- package/dist/session/types.d.ts.map +1 -1
- package/dist/voice/pocket/catalog.d.ts +24 -0
- package/dist/voice/pocket/catalog.d.ts.map +1 -0
- package/dist/voice/pocket/catalog.js +152 -0
- package/dist/voice/pocket/engine.d.ts +17 -0
- package/dist/voice/pocket/engine.d.ts.map +1 -0
- package/dist/voice/pocket/engine.js +145 -0
- package/dist/voice/pocket/inference.d.ts +36 -0
- package/dist/voice/pocket/inference.d.ts.map +1 -0
- package/dist/voice/pocket/inference.js +228 -0
- package/dist/voice/pocket/install.d.ts +54 -0
- package/dist/voice/pocket/install.d.ts.map +1 -0
- package/dist/voice/pocket/install.js +275 -0
- package/dist/voice/pocket/tokenizer.d.ts +42 -0
- package/dist/voice/pocket/tokenizer.d.ts.map +1 -0
- package/dist/voice/pocket/tokenizer.js +279 -0
- package/dist/voice/pocket/voices.d.ts +9 -0
- package/dist/voice/pocket/voices.d.ts.map +1 -0
- package/dist/voice/pocket/voices.js +88 -0
- package/dist/voice/pronunciation.d.ts +16 -0
- package/dist/voice/pronunciation.d.ts.map +1 -0
- package/dist/voice/pronunciation.js +51 -0
- package/dist/webview/standalone.js +1508 -701
- package/dist/webview/standalone.js.map +4 -4
- package/package.json +3 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// voices.bin of a Pocket TTS schema-3 bundle ("PTVB1", little endian): per voice, the
|
|
2
|
+
// flow LM KV cache after prefilling BOS + the voice conditioning.
|
|
3
|
+
//
|
|
4
|
+
// "PTVB1" u32 voiceCount
|
|
5
|
+
// per voice: u16 nameLen name u16 tensorCount
|
|
6
|
+
// per tensor: u16 keyLen key("<module>/<key>") u8 dtype(0 f32, 1 i64) u8 ndim
|
|
7
|
+
// u32 dims[ndim] u32 byteLength bytes
|
|
8
|
+
const MAGIC = 'PTVB1';
|
|
9
|
+
export function parseVoices(buf) {
|
|
10
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
11
|
+
const text = new TextDecoder();
|
|
12
|
+
let p = 0;
|
|
13
|
+
const need = (n) => {
|
|
14
|
+
if (p + n > buf.byteLength)
|
|
15
|
+
throw new Error('voices.bin is truncated');
|
|
16
|
+
};
|
|
17
|
+
const u8 = () => (need(1), view.getUint8(p++));
|
|
18
|
+
const u16 = () => (need(2), (p += 2), view.getUint16(p - 2, true));
|
|
19
|
+
const u32 = () => (need(4), (p += 4), view.getUint32(p - 4, true));
|
|
20
|
+
const str = (n) => (need(n), (p += n), text.decode(buf.subarray(p - n, p)));
|
|
21
|
+
if (str(5) !== MAGIC)
|
|
22
|
+
throw new Error('voices.bin: bad magic');
|
|
23
|
+
const voices = new Map();
|
|
24
|
+
const count = u32();
|
|
25
|
+
for (let v = 0; v < count; v++) {
|
|
26
|
+
const name = str(u16());
|
|
27
|
+
const tensors = new Map();
|
|
28
|
+
const tensorCount = u16();
|
|
29
|
+
for (let t = 0; t < tensorCount; t++) {
|
|
30
|
+
const key = str(u16());
|
|
31
|
+
const code = u8();
|
|
32
|
+
const ndim = u8();
|
|
33
|
+
const dims = Array.from({ length: ndim }, u32);
|
|
34
|
+
const byteLength = u32();
|
|
35
|
+
need(byteLength);
|
|
36
|
+
// Copy: the tensor's offset in the file is not aligned for a typed array view (and
|
|
37
|
+
// Buffer#slice would not copy).
|
|
38
|
+
const bytes = new Uint8Array(byteLength);
|
|
39
|
+
bytes.set(buf.subarray(p, p + byteLength));
|
|
40
|
+
p += byteLength;
|
|
41
|
+
const elements = dims.reduce((a, b) => a * b, 1);
|
|
42
|
+
let tensor;
|
|
43
|
+
if (code === 0)
|
|
44
|
+
tensor = {
|
|
45
|
+
dtype: 'float32',
|
|
46
|
+
dims,
|
|
47
|
+
data: new Float32Array(bytes.buffer, 0, byteLength / 4),
|
|
48
|
+
};
|
|
49
|
+
else if (code === 1)
|
|
50
|
+
tensor = { dtype: 'int64', dims, data: new BigInt64Array(bytes.buffer, 0, byteLength / 8) };
|
|
51
|
+
else
|
|
52
|
+
throw new Error(`voices.bin: unknown dtype ${code} for ${name} ${key}`);
|
|
53
|
+
if (tensor.data.length !== elements)
|
|
54
|
+
throw new Error(`voices.bin: ${name} ${key} size does not match its dims`);
|
|
55
|
+
tensors.set(key, tensor);
|
|
56
|
+
}
|
|
57
|
+
voices.set(name, tensors);
|
|
58
|
+
}
|
|
59
|
+
if (p !== buf.byteLength)
|
|
60
|
+
throw new Error('voices.bin: trailing bytes');
|
|
61
|
+
return voices;
|
|
62
|
+
}
|
|
63
|
+
// Copy `src` into a zero-filled tensor of shape `dims` that may be larger along one axis
|
|
64
|
+
// (the voice KV cache [2,1,K,H,D] into the model's [2,1,1024,H,D]): the leading K rows
|
|
65
|
+
// of that axis are the voice, the rest stays zero.
|
|
66
|
+
export function padInto(src, dims) {
|
|
67
|
+
if (src.dims.length !== dims.length)
|
|
68
|
+
throw new Error(`rank mismatch: [${src.dims}] vs [${dims}]`);
|
|
69
|
+
const axes = dims.map((d, i) => i).filter((i) => dims[i] !== src.dims[i]);
|
|
70
|
+
if (axes.length > 1 || (axes.length === 1 && src.dims[axes[0]] > dims[axes[0]])) {
|
|
71
|
+
throw new Error(`cannot place [${src.dims}] into [${dims}]`);
|
|
72
|
+
}
|
|
73
|
+
const total = dims.reduce((a, b) => a * b, 1);
|
|
74
|
+
const out = src.dtype === 'float32' ? new Float32Array(total) : new BigInt64Array(total);
|
|
75
|
+
if (axes.length === 0) {
|
|
76
|
+
out.set(src.data);
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
const axis = axes[0];
|
|
80
|
+
const outer = dims.slice(0, axis).reduce((a, b) => a * b, 1);
|
|
81
|
+
const inner = dims.slice(axis + 1).reduce((a, b) => a * b, 1);
|
|
82
|
+
const srcBlock = src.dims[axis] * inner;
|
|
83
|
+
const dstBlock = dims[axis] * inner;
|
|
84
|
+
for (let o = 0; o < outer; o++) {
|
|
85
|
+
out.set(src.data.subarray(o * srcBlock, (o + 1) * srcBlock), o * dstBlock);
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PronunciationEntry, VoiceConfig } from 'caretaker-types';
|
|
2
|
+
/** Shipped defaults by ISO 639-1 code. Generic terms only (caretaker is open
|
|
3
|
+
* source). Respellings tuned by ear on the Italian built-in voice; the other
|
|
4
|
+
* languages ship empty. */
|
|
5
|
+
export declare const DEFAULT_PRONUNCIATION: Readonly<Record<string, readonly PronunciationEntry[]>>;
|
|
6
|
+
/** ISO code of the language being synthesized, or null when the server cannot
|
|
7
|
+
* know it (the renderer's navigator.language never reaches the server). */
|
|
8
|
+
export declare function synthesisLanguage(voice: VoiceConfig): string | null;
|
|
9
|
+
/** The saved dictionary for `code` when present (it replaces the defaults),
|
|
10
|
+
* else the shipped defaults, else empty. */
|
|
11
|
+
export declare function dictionaryFor(voice: VoiceConfig, code: string): readonly PronunciationEntry[];
|
|
12
|
+
/** Replace every whole-word, case-insensitive occurrence of an entry's term
|
|
13
|
+
* with its `say`. Terms are literal; the longest wins; one pass, so a
|
|
14
|
+
* replacement is never matched again. */
|
|
15
|
+
export declare function applyPronunciation(text: string, entries: readonly PronunciationEntry[]): string;
|
|
16
|
+
//# sourceMappingURL=pronunciation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pronunciation.d.ts","sourceRoot":"","sources":["../../src/voice/pronunciation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGvE;;4BAE4B;AAC5B,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAC,CAYzF,CAAC;AAEF;4EAC4E;AAC5E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAMnE;AAED;6CAC6C;AAC7C,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,kBAAkB,EAAE,CAE7F;AAID;;0CAE0C;AAC1C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,kBAAkB,EAAE,GAAG,MAAM,CAa/F"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { POCKET_LANGUAGES } from './pocket/catalog.js';
|
|
2
|
+
/** Shipped defaults by ISO 639-1 code. Generic terms only (caretaker is open
|
|
3
|
+
* source). Respellings tuned by ear on the Italian built-in voice; the other
|
|
4
|
+
* languages ship empty. */
|
|
5
|
+
export const DEFAULT_PRONUNCIATION = {
|
|
6
|
+
it: [
|
|
7
|
+
{ term: 'merge request', say: 'mèrg riquèst' },
|
|
8
|
+
{ term: 'pull request', say: 'pùl riquèst' },
|
|
9
|
+
{ term: 'pipeline', say: 'pàiplain' },
|
|
10
|
+
{ term: 'deploy', say: 'diplòi' },
|
|
11
|
+
{ term: 'branch', say: 'brènc' },
|
|
12
|
+
{ term: 'feature', say: 'fìciar' },
|
|
13
|
+
{ term: 'build', say: 'bìld' },
|
|
14
|
+
{ term: 'review', say: 'riviù' },
|
|
15
|
+
{ term: 'stage', say: 'stèij' },
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
/** ISO code of the language being synthesized, or null when the server cannot
|
|
19
|
+
* know it (the renderer's navigator.language never reaches the server). */
|
|
20
|
+
export function synthesisLanguage(voice) {
|
|
21
|
+
if (voice.ttsEngine === 'builtin') {
|
|
22
|
+
return POCKET_LANGUAGES[voice.ttsLanguage]?.code ?? null;
|
|
23
|
+
}
|
|
24
|
+
const primary = voice.lang?.split('-')[0]?.trim().toLowerCase();
|
|
25
|
+
return primary || null;
|
|
26
|
+
}
|
|
27
|
+
/** The saved dictionary for `code` when present (it replaces the defaults),
|
|
28
|
+
* else the shipped defaults, else empty. */
|
|
29
|
+
export function dictionaryFor(voice, code) {
|
|
30
|
+
return voice.pronunciation?.[code] ?? DEFAULT_PRONUNCIATION[code] ?? [];
|
|
31
|
+
}
|
|
32
|
+
const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
33
|
+
/** Replace every whole-word, case-insensitive occurrence of an entry's term
|
|
34
|
+
* with its `say`. Terms are literal; the longest wins; one pass, so a
|
|
35
|
+
* replacement is never matched again. */
|
|
36
|
+
export function applyPronunciation(text, entries) {
|
|
37
|
+
const say = new Map();
|
|
38
|
+
for (const e of entries) {
|
|
39
|
+
const term = e.term.trim();
|
|
40
|
+
if (term)
|
|
41
|
+
say.set(term.toLowerCase(), e.say);
|
|
42
|
+
}
|
|
43
|
+
if (say.size === 0)
|
|
44
|
+
return text;
|
|
45
|
+
const alternation = [...say.keys()]
|
|
46
|
+
.sort((a, b) => b.length - a.length)
|
|
47
|
+
.map(escapeRegExp)
|
|
48
|
+
.join('|');
|
|
49
|
+
const re = new RegExp(`(?<![\\p{L}\\p{N}])(?:${alternation})(?![\\p{L}\\p{N}])`, 'giu');
|
|
50
|
+
return text.replace(re, (m) => say.get(m.toLowerCase()) ?? m);
|
|
51
|
+
}
|