@hyperwindmill/caretaker-cli 0.29.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.
Files changed (53) hide show
  1. package/dist/agents/dispatch.d.ts.map +1 -1
  2. package/dist/agents/dispatch.js +4 -1
  3. package/dist/cli/web/server.d.ts.map +1 -1
  4. package/dist/cli/web/server.js +29 -7
  5. package/dist/cli/web/session_scope.d.ts +11 -0
  6. package/dist/cli/web/session_scope.d.ts.map +1 -0
  7. package/dist/cli/web/session_scope.js +13 -0
  8. package/dist/cli/web/turn_guard.d.ts +9 -0
  9. package/dist/cli/web/turn_guard.d.ts.map +1 -0
  10. package/dist/cli/web/turn_guard.js +18 -0
  11. package/dist/cli/web/voice_builtin.d.ts +3 -0
  12. package/dist/cli/web/voice_builtin.d.ts.map +1 -0
  13. package/dist/cli/web/voice_builtin.js +55 -0
  14. package/dist/cli/web/voice_proxy.d.ts +33 -1
  15. package/dist/cli/web/voice_proxy.d.ts.map +1 -1
  16. package/dist/cli/web/voice_proxy.js +173 -27
  17. package/dist/commands/loader.js +2 -2
  18. package/dist/harness/tools/builtin/index.d.ts.map +1 -1
  19. package/dist/harness/tools/builtin/index.js +4 -0
  20. package/dist/harness/tools/builtin/set_workspace.d.ts +3 -0
  21. package/dist/harness/tools/builtin/set_workspace.d.ts.map +1 -0
  22. package/dist/harness/tools/builtin/set_workspace.js +49 -0
  23. package/dist/plugins/manifest.d.ts +1 -1
  24. package/dist/plugins/manifest.js +1 -1
  25. package/dist/session/store.d.ts +6 -0
  26. package/dist/session/store.d.ts.map +1 -1
  27. package/dist/session/store.js +8 -0
  28. package/dist/session/types.d.ts +4 -0
  29. package/dist/session/types.d.ts.map +1 -1
  30. package/dist/voice/pocket/catalog.d.ts +24 -0
  31. package/dist/voice/pocket/catalog.d.ts.map +1 -0
  32. package/dist/voice/pocket/catalog.js +152 -0
  33. package/dist/voice/pocket/engine.d.ts +17 -0
  34. package/dist/voice/pocket/engine.d.ts.map +1 -0
  35. package/dist/voice/pocket/engine.js +145 -0
  36. package/dist/voice/pocket/inference.d.ts +36 -0
  37. package/dist/voice/pocket/inference.d.ts.map +1 -0
  38. package/dist/voice/pocket/inference.js +228 -0
  39. package/dist/voice/pocket/install.d.ts +54 -0
  40. package/dist/voice/pocket/install.d.ts.map +1 -0
  41. package/dist/voice/pocket/install.js +275 -0
  42. package/dist/voice/pocket/tokenizer.d.ts +42 -0
  43. package/dist/voice/pocket/tokenizer.d.ts.map +1 -0
  44. package/dist/voice/pocket/tokenizer.js +279 -0
  45. package/dist/voice/pocket/voices.d.ts +9 -0
  46. package/dist/voice/pocket/voices.d.ts.map +1 -0
  47. package/dist/voice/pocket/voices.js +88 -0
  48. package/dist/voice/pronunciation.d.ts +16 -0
  49. package/dist/voice/pronunciation.d.ts.map +1 -0
  50. package/dist/voice/pronunciation.js +51 -0
  51. package/dist/webview/standalone.js +1508 -701
  52. package/dist/webview/standalone.js.map +4 -4
  53. package/package.json +3 -3
@@ -0,0 +1,49 @@
1
+ // Move the current chat session into one of the configured projects.
2
+ //
3
+ // Session-bound on purpose: it needs ctx.sessionId to persist the override,
4
+ // which is why it is a plain builtin and not part of a served mcp__* namespace
5
+ // (those are context-free). The switch mutates ctx.workingDir in place, so
6
+ // file/shell tools later in the same turn already resolve against the new
7
+ // directory; the prelude (AGENTS.md, project memories) is built once per run
8
+ // and picks the project up from the next turn, when the web server's chat
9
+ // controller reads the override back from the session meta.
10
+ // See docs/superpowers/specs/2026-11-07-desktop-assistant-design.md
11
+ import { stat } from 'node:fs/promises';
12
+ import { loadConfig } from '../../../store/json.js';
13
+ import { updateSessionWorkspace } from '../../../session/store.js';
14
+ import { projectWorkingDir } from '../../../lib/task_git.js';
15
+ export const setWorkspaceTool = {
16
+ name: 'set_workspace',
17
+ description: "Switch this chat session's working directory to one of the configured projects for the rest of the session. " +
18
+ 'Call mcp__task__project_list first to get the project_id.',
19
+ parameters: {
20
+ type: 'object',
21
+ properties: {
22
+ project_id: { type: 'string', description: 'Id of the project to switch to (from project_list).' },
23
+ },
24
+ required: ['project_id'],
25
+ },
26
+ dangerous: true,
27
+ execute: async (args, ctx) => {
28
+ const agentId = ctx.callerAgent?.id;
29
+ if (!ctx.sessionId || !agentId) {
30
+ return { content: 'Error: no chat session to switch — set_workspace only works inside a saved chat session.' };
31
+ }
32
+ const projectId = String(args.project_id ?? '');
33
+ const project = ((await loadConfig()).projects ?? []).find((p) => p.id === projectId);
34
+ if (!project) {
35
+ return { content: `Error: unknown project "${projectId}". Call mcp__task__project_list for the valid ids.` };
36
+ }
37
+ const dir = projectWorkingDir(project);
38
+ const isDir = dir ? await stat(dir).then((s) => s.isDirectory(), () => false) : false;
39
+ if (!isDir) {
40
+ return { content: `Error: project "${project.name}" has no directory on disk (${dir || 'no working dir configured'}).` };
41
+ }
42
+ ctx.workingDir = dir;
43
+ await updateSessionWorkspace({ agentId, id: ctx.sessionId }, { workingDir: dir, projectId: project.id });
44
+ return {
45
+ content: `Switched to project "${project.name}" (${dir}). File and shell tools already use it; ` +
46
+ 'project context files (AGENTS.md) and project memories apply from the next turn.',
47
+ };
48
+ },
49
+ };
@@ -3,7 +3,7 @@ import type { AgentSpec, CommandSpec, McpServerSpec, PluginManifestKind, SkillSp
3
3
  /**
4
4
  * Read `<pluginRoot>/.mcp.json` and return the declared MCP server specs.
5
5
  * Two shapes are observed in the wild and both are accepted:
6
- * - `{ "mcpServers": { name: { … } } }` (lh-youtrack, official spec)
6
+ * - `{ "mcpServers": { name: { … } } }` (official spec)
7
7
  * - `{ name: { … } }` (claude-plugins-official examples)
8
8
  *
9
9
  * Returns `undefined` when the file is absent, malformed, or contains zero
@@ -73,7 +73,7 @@ function parseMcpServersMap(raw) {
73
73
  /**
74
74
  * Read `<pluginRoot>/.mcp.json` and return the declared MCP server specs.
75
75
  * Two shapes are observed in the wild and both are accepted:
76
- * - `{ "mcpServers": { name: { … } } }` (lh-youtrack, official spec)
76
+ * - `{ "mcpServers": { name: { … } } }` (official spec)
77
77
  * - `{ name: { … } }` (claude-plugins-official examples)
78
78
  *
79
79
  * Returns `undefined` when the file is absent, malformed, or contains zero
@@ -46,6 +46,12 @@ export declare function updateTitle(meta: Pick<SessionMetaRecord, 'agentId' | 'i
46
46
  /** Persist the Claude Code session id by appending a fresh meta line
47
47
  * (readSession picks the latest meta; listForAgent keeps using the first). */
48
48
  export declare function updateClaudeSessionId(meta: Pick<SessionMetaRecord, 'agentId' | 'id'>, claudeSessionId: string): Promise<void>;
49
+ /** Persist a session-level workspace override (`set_workspace`). Appends a
50
+ * new session_meta record, latest wins — same pattern as claudeSessionId. */
51
+ export declare function updateSessionWorkspace(meta: Pick<SessionMetaRecord, 'agentId' | 'id'>, ws: {
52
+ workingDir: string;
53
+ projectId: string;
54
+ }): Promise<void>;
49
55
  export declare function updateAcpSessionId(meta: Pick<SessionMetaRecord, 'agentId' | 'id'>, acpSessionId: string): Promise<void>;
50
56
  export declare function deleteSession(agentId: string, sessionId: string): Promise<void>;
51
57
  export declare function userMessage(content: string, opts?: {
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/session/store.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,iBAAS,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED,iBAAS,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/D;AAmDD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,4EAA4E;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CAUf;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EAAE,EACtB,KAAK,CAAC,EAAE,cAAc,EACtB,IAAI,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,aAAa,CAYf;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnF;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,oBAAoB,EAAE,EACpC,IAAI,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,aAAa,CAWf;AAID,eAAO,MAAM,YAAY;;;;CAA2C,CAAC"}
@@ -211,6 +211,14 @@ export async function updateClaudeSessionId(meta, claudeSessionId) {
211
211
  const path = sessionPath(meta.agentId, meta.id);
212
212
  await appendFile(path, serialize(record), { mode: 0o600 });
213
213
  }
214
+ /** Persist a session-level workspace override (`set_workspace`). Appends a
215
+ * new session_meta record, latest wins — same pattern as claudeSessionId. */
216
+ export async function updateSessionWorkspace(meta, ws) {
217
+ const current = await readSession(meta.agentId, meta.id);
218
+ const record = { ...current.meta, workingDir: ws.workingDir, projectId: ws.projectId };
219
+ const path = sessionPath(meta.agentId, meta.id);
220
+ await appendFile(path, serialize(record), { mode: 0o600 });
221
+ }
214
222
  export async function updateAcpSessionId(meta, acpSessionId) {
215
223
  const current = await readSession(meta.agentId, meta.id);
216
224
  const record = { ...current.meta, acpSessionId };
@@ -35,6 +35,10 @@ export interface SessionMetaRecord {
35
35
  taskId?: string;
36
36
  projectId?: string;
37
37
  taskRole?: 'developer' | 'planner' | 'reviewer';
38
+ /** Session-level working-dir override written by the `set_workspace` tool
39
+ * (together with `projectId`). Honoured per turn by the web server's chat
40
+ * controller; absent ⇒ the agent's own workingDir. */
41
+ workingDir?: string;
38
42
  }
39
43
  export type Role = 'user' | 'assistant' | 'tool';
40
44
  export interface ToolAttachmentRecord {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/session/types.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,cAAc,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB;yDACqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;sDACkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;8DAC0D;IAC1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AC,EAAE,aAAa,EAAE,CAAC;IACxB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC;mEAC+D;IAC/D,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,aAAa,CAAC;AAE9D,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B"}
@@ -0,0 +1,24 @@
1
+ export type PocketLanguage = 'english' | 'french' | 'german' | 'spanish' | 'portuguese' | 'italian' | 'dutch';
2
+ export declare const POCKET_BASE_URL = "https://huggingface.co/Alias-Alias/pocket-3-3-0-tts-onnx/resolve";
3
+ export declare const POCKET_REVISION = "71a4d6d11a76e26b98709fa163477c77d16bdbdb";
4
+ export type BundleFile = {
5
+ name: string;
6
+ sha256: string;
7
+ bytes: number;
8
+ };
9
+ export declare const POCKET_LANGUAGES: Readonly<Record<PocketLanguage, {
10
+ code: string;
11
+ dir: string;
12
+ nativeVoice: string;
13
+ files: readonly BundleFile[];
14
+ }>>;
15
+ export declare const POCKET_VOICES: readonly string[];
16
+ export declare const ORT_VERSION = "1.31.1";
17
+ export declare const ORT_TARBALLS: Readonly<Record<'node' | 'common', {
18
+ url: string;
19
+ integrity: string;
20
+ }>>;
21
+ export declare const POCKET_SAMPLE_RATE = 24000;
22
+ export type InferenceSource = 'npm-pocket-tts' | 'own-loop';
23
+ export declare const INFERENCE_SOURCE: InferenceSource;
24
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/voice/pocket/catalog.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,SAAS,GACT,OAAO,CAAC;AAEZ,eAAO,MAAM,eAAe,qEACwC,CAAC;AACrE,eAAO,MAAM,eAAe,6CAA6C,CAAC;AAE1E,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAMzE,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CACrC,MAAM,CACJ,cAAc,EACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAA;CAAE,CACjF,CA2GF,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAS1C,CAAC;AAEF,eAAO,MAAM,WAAW,WAAW,CAAC;AAIpC,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,QAAQ,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAWhG,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAC5D,eAAO,MAAM,gBAAgB,EAAE,eAA4B,CAAC"}
@@ -0,0 +1,152 @@
1
+ // Pinned catalog for the built-in Pocket TTS engine: model bundles (Hugging Face), the
2
+ // ONNX runtime (npm registry tarballs) and the choice of who drives the graphs.
3
+ //
4
+ // INFERENCE_SOURCE = 'own-loop'. The npm `pocket-tts` package (1.0.0, MIT) was read, not
5
+ // run, and fails all three conditions. (1) It targets a different export, the community
6
+ // `KevinAHM/pocket-tts-onnx` repo (tokenizer.model, bos_before_voice.npy, a mimi encoder),
7
+ // not the schema-3 bundles of `Alias-Alias/pocket-3-3-0-tts-onnx` (explicit state_N /
8
+ // next_state_N tensors, tokenizer.json, voices.bin). (2) Local mode requires a reference
9
+ // WAV and encodes it (cloning); it never reads voices.bin or built-in voices. (3) It loads
10
+ // the runtime with a bare `import("onnxruntime-node")` (local/runtime.js) and exposes no
11
+ // way to pass a session factory or module, so it could not see our downloaded runtime.
12
+ // We therefore drive the four graphs ourselves; see the engine, which sits behind the
13
+ // small interface of the spec so the source can still be swapped.
14
+ export const POCKET_BASE_URL = 'https://huggingface.co/Alias-Alias/pocket-3-3-0-tts-onnx/resolve';
15
+ export const POCKET_REVISION = '71a4d6d11a76e26b98709fa163477c77d16bdbdb';
16
+ // `dir` is the bundle's subdirectory in the repo (also its language code). `nativeVoice`
17
+ // is the voice suggested first in the UI. The bundles ship no per-language native voices:
18
+ // every language carries the same eight official voices (each with a language-specific
19
+ // state in its own voices.bin), so the default is one shared voice.
20
+ export const POCKET_LANGUAGES = {
21
+ english: {
22
+ code: 'en',
23
+ dir: 'en',
24
+ nativeVoice: 'alba',
25
+ files: [
26
+ { name: 'bundle.json', sha256: 'ccbb828d6dceee19688ee6eee884bb8de16edcc0f21fac5ed713a8739d978b2e', bytes: 13438 },
27
+ { name: 'tokenizer.json', sha256: 'f498428e1eafee50492f7be13dc9bfafcfc12e508cd0eb1b01c92ecd5d8c6687', bytes: 245020 },
28
+ { name: 'voices.bin', sha256: '720343118b8ec5177397d3898d43b0d13c7948f76794956610e5f0e795100cf1', bytes: 52404520 },
29
+ { name: 'text_conditioner_int8.onnx', sha256: 'a060f0926e87a12309c54a681dde9daba8e32821e1e2348224fd6c30a3a7a28b', bytes: 16388338 },
30
+ { name: 'flow_lm_main_int8.onnx', sha256: 'c9328891492caaa7580284d81d47d01679f570f297023d68fc4c7ce503113dc8', bytes: 76397201 },
31
+ { name: 'flow_lm_flow_int8.onnx', sha256: '7edfcbccb1d40a84b2b59ac1e921963287471ff0cb266603d7fd4282a131d716', bytes: 10040048 },
32
+ { name: 'mimi_decoder_int8.onnx', sha256: 'b27d1c38b96947a08bc54a7b660b553866a47b3b368b2170b89b09f5c7f35b56', bytes: 22638621 },
33
+ { name: 'LICENSE-upstream.txt', sha256: '23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3', bytes: 1023 },
34
+ ],
35
+ },
36
+ french: {
37
+ code: 'fr',
38
+ dir: 'fr',
39
+ nativeVoice: 'alba',
40
+ files: [
41
+ { name: 'bundle.json', sha256: '0894c2fc533b0a94d1f120fa9f959f4125ccff2443ac5362925989a5fcdd7fae', bytes: 13638 },
42
+ { name: 'tokenizer.json', sha256: '6211acffe9cb95172f71f0051f18e26ea305b2b32ea00b331ee976551c70887f', bytes: 246403 },
43
+ { name: 'voices.bin', sha256: 'a43532290caa733c6670bc52427f0ed9f709c43867049f3e511f85568fcf9c5c', bytes: 52404520 },
44
+ { name: 'text_conditioner_int8.onnx', sha256: '6127b51df140da0123123aa929a9453fc9a63a7cfebdc33f8a1f3fb46c5f2139', bytes: 16388338 },
45
+ { name: 'flow_lm_main_int8.onnx', sha256: '1c6611cc3d524843e990e3abfdc15ce84f16f7a9250b5970b0255df4759fe70b', bytes: 76397201 },
46
+ { name: 'flow_lm_flow_int8.onnx', sha256: '8c72996bdcae9ea4a981b6afc0a40986523525aaa5491c09ef9546c14becd272', bytes: 10040048 },
47
+ { name: 'mimi_decoder_int8.onnx', sha256: 'd7b00abae02b2916f0be6d42bfbe14e87e0b4f1aaa25b1d5778a1f128edb6bb6', bytes: 22638621 },
48
+ { name: 'LICENSE-upstream.txt', sha256: '23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3', bytes: 1023 },
49
+ ],
50
+ },
51
+ german: {
52
+ code: 'de',
53
+ dir: 'de',
54
+ nativeVoice: 'alba',
55
+ files: [
56
+ { name: 'bundle.json', sha256: '7e43fa70568f3a1800a7dfeab6b3f97e2b5f1ff682c11db9cf22103d53f5fea5', bytes: 13623 },
57
+ { name: 'tokenizer.json', sha256: '2d77849811e3d1b6ae80e5b11b203f57e1847901104d8a0573b34f46f8dddb53', bytes: 245966 },
58
+ { name: 'voices.bin', sha256: 'a45485ca28c8f046f6e45089d7b01ea45e9a2d36f1ac4cb0947a956b27f4a70d', bytes: 52404520 },
59
+ { name: 'text_conditioner_int8.onnx', sha256: '0479f6bc635fedf130086c357d013a6a0c54568b301d9b255ffd67d732965378', bytes: 16388338 },
60
+ { name: 'flow_lm_main_int8.onnx', sha256: '96cb9a628438ca4b26d7ed3160d79bd8ad2e0f097d08a8faea95e00c944ea84e', bytes: 76397201 },
61
+ { name: 'flow_lm_flow_int8.onnx', sha256: '6198087a456287420d14b98083cd534bee3e92fa107dca1324f03a27c65c8315', bytes: 10040048 },
62
+ { name: 'mimi_decoder_int8.onnx', sha256: '3d0f9574384d73c91404514b933e239333d9580bc42c8fcc161e5402ff67d6b9', bytes: 22638621 },
63
+ { name: 'LICENSE-upstream.txt', sha256: '23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3', bytes: 1023 },
64
+ ],
65
+ },
66
+ spanish: {
67
+ code: 'es',
68
+ dir: 'es',
69
+ nativeVoice: 'alba',
70
+ files: [
71
+ { name: 'bundle.json', sha256: '196151a61b907afb2b0ccb4570a4c39993de69d705b371d38ae459120f6aac23', bytes: 13654 },
72
+ { name: 'tokenizer.json', sha256: '9ade09bbdc64ab2b59952b90773fa0890b780ece4fd5aef0d36a00c6ad5f0531', bytes: 246610 },
73
+ { name: 'voices.bin', sha256: '49a8e4d3562074a1e8d041edb4fad3877b327daf4cd898893ff10273216ae178', bytes: 52404520 },
74
+ { name: 'text_conditioner_int8.onnx', sha256: '8e98c0abd4ba06fde1db0decb75e3b211e6097ba15854fc9266aa1d16feaeae4', bytes: 16388338 },
75
+ { name: 'flow_lm_main_int8.onnx', sha256: 'f37c8b4a2409de010f638529daf947b863396a78b8b659a77ed6e35362174629', bytes: 76397201 },
76
+ { name: 'flow_lm_flow_int8.onnx', sha256: 'b3f028c3cdd909ffa10dffa8055edc9147f273e43bda852733e6a4a36cc3d292', bytes: 10040048 },
77
+ { name: 'mimi_decoder_int8.onnx', sha256: 'f2f1b6e380a6388557768534d24036cb8b549b9f4eb49bedbb7ed3c4fb06336a', bytes: 22638621 },
78
+ { name: 'LICENSE-upstream.txt', sha256: '23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3', bytes: 1023 },
79
+ ],
80
+ },
81
+ portuguese: {
82
+ code: 'pt',
83
+ dir: 'pt',
84
+ nativeVoice: 'alba',
85
+ files: [
86
+ { name: 'bundle.json', sha256: '4b23a635bd375e5d476416cc960ad7488aabd4441aea2861eaf54d98734ea34b', bytes: 13624 },
87
+ { name: 'tokenizer.json', sha256: 'b33e269f7f042a763080d71ba087d74d2f6759674b238a723c028e436b1a25ab', bytes: 247014 },
88
+ { name: 'voices.bin', sha256: '402d569dcb5d25c5b93cae6995d6d4d499cf1bfc591ed8edf2ce50547a8b3651', bytes: 52404520 },
89
+ { name: 'text_conditioner_int8.onnx', sha256: '22ee9182a3dadc37ba06cdf3ff9c0e0ac0622f006a2eb29d2f5e0a13ba642d3e', bytes: 16388338 },
90
+ { name: 'flow_lm_main_int8.onnx', sha256: '15357eb39cbd574bc4193fef960d6b332a861c84bfcf99e9417316bac129d1d8', bytes: 76397201 },
91
+ { name: 'flow_lm_flow_int8.onnx', sha256: 'f2e2a3da0fb5c1e6b472f1921459f7e6c051fa54c25e08186b46d559d620b379', bytes: 10040048 },
92
+ { name: 'mimi_decoder_int8.onnx', sha256: '6974a4330bbbfe91fcc46084b26e769c8eefd6121bd3ad42e84861f9f05854b2', bytes: 22638621 },
93
+ { name: 'LICENSE-upstream.txt', sha256: '23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3', bytes: 1023 },
94
+ ],
95
+ },
96
+ italian: {
97
+ code: 'it',
98
+ dir: 'it',
99
+ nativeVoice: 'alba',
100
+ files: [
101
+ { name: 'bundle.json', sha256: '5dce446b175a8b9fd8766bde7ce3ee15fb396f2228b77777028c26eb88acfc4f', bytes: 13624 },
102
+ { name: 'tokenizer.json', sha256: '4bc1c0d4d54f9480183e94c94cfabf74fd89b0912537d4ef607d1982c4a381ec', bytes: 246586 },
103
+ { name: 'voices.bin', sha256: 'cf8f292f5d91d887f8370ebbd4329928421a87f564d475f53a7d456bf144acac', bytes: 52404520 },
104
+ { name: 'text_conditioner_int8.onnx', sha256: 'f716f278fa279495889fbe8f4426da68d4ca5112b962121991ec8fed002ff090', bytes: 16388338 },
105
+ { name: 'flow_lm_main_int8.onnx', sha256: '80c1ebae13a0033f7746f2b7a886e3d7fa3523c9d7be2122bec9412ad82c46b8', bytes: 76397201 },
106
+ { name: 'flow_lm_flow_int8.onnx', sha256: 'b4da5f938b81d895eee0a8c6267162c6466382b761114affb96049db9e649431', bytes: 10040048 },
107
+ { name: 'mimi_decoder_int8.onnx', sha256: 'c258c72d1b8079eb16a08fc9c6a255e918d897f53f784abcb5eaae2f3a0e9344', bytes: 22638621 },
108
+ { name: 'LICENSE-upstream.txt', sha256: '23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3', bytes: 1023 },
109
+ ],
110
+ },
111
+ dutch: {
112
+ code: 'nl',
113
+ dir: 'nl',
114
+ nativeVoice: 'alba',
115
+ files: [
116
+ { name: 'bundle.json', sha256: '48581badbfe176db6df37ac0f784893fe2c681ae1e845263c4cd36106d8c1705', bytes: 13624 },
117
+ { name: 'tokenizer.json', sha256: 'e6f610b98c427641b4ab0e1024dca7843e3d6b620871a14b204932e42c5a1736', bytes: 245206 },
118
+ { name: 'voices.bin', sha256: '1e7f812d5824a931fef68337291896bd88521c9f031d545877e7f46b144ed38c', bytes: 52404520 },
119
+ { name: 'text_conditioner_int8.onnx', sha256: '3bd2960e2ea136a8f870149f4238789f6dbcc54c1b643a4639b7be028e52fbb2', bytes: 16388338 },
120
+ { name: 'flow_lm_main_int8.onnx', sha256: 'b6ae39189f6881ec0d87fa50ac690db239c6759c110e179714752b8b5d36e75c', bytes: 76397201 },
121
+ { name: 'flow_lm_flow_int8.onnx', sha256: 'd0b3e7da6ef29c0c0a2e6f721b9c3b3835b93c3f3f2854f5882e11222f7450ea', bytes: 10040048 },
122
+ { name: 'mimi_decoder_int8.onnx', sha256: '2cf5feebf7ba7486491c87a49036b0afae3093546aff3f5a46ec5e967b6c3ca5', bytes: 22638621 },
123
+ { name: 'LICENSE-upstream.txt', sha256: '23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3', bytes: 1023 },
124
+ ],
125
+ },
126
+ };
127
+ // Built-in voice names stored in every bundle's voices.bin (bundle.json `predefined_voices`).
128
+ export const POCKET_VOICES = [
129
+ 'alba',
130
+ 'azelma',
131
+ 'cosette',
132
+ 'eponine',
133
+ 'fantine',
134
+ 'javert',
135
+ 'jean',
136
+ 'marius',
137
+ ];
138
+ export const ORT_VERSION = '1.31.1';
139
+ // The node package bundles the native binding for every platform (~115 MB compressed);
140
+ // `postinstall` only fetches optional CUDA binaries and is never run.
141
+ export const ORT_TARBALLS = {
142
+ node: {
143
+ url: 'https://registry.npmjs.org/onnxruntime-node/-/onnxruntime-node-1.31.1.tgz',
144
+ integrity: 'sha512-ijnSghbDHVWaQ2nDPmVccPlCHI8kH1Mx1aJ4a/qzRP16bBcVs4E3EqZQKZCkhWnbqN1tuQWxagimFtDpbPYYQw==',
145
+ },
146
+ common: {
147
+ url: 'https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.31.1.tgz',
148
+ integrity: 'sha512-F+nnYNiQtmNJ95V6R/isBJqiVpdANCrsMEg1OaF+Bkbl3GAtzWLR7Ng17Ld0QtYtYJyotOHPJzOQn1Y6PLZjpg==',
149
+ },
150
+ };
151
+ export const POCKET_SAMPLE_RATE = 24000;
152
+ export const INFERENCE_SOURCE = 'own-loop';
@@ -0,0 +1,17 @@
1
+ import type { BuiltinSpeaker } from '../../cli/web/voice_proxy.js';
2
+ import { type PocketLanguage } from './catalog.js';
3
+ import { type OrtModule, type PocketModel } from './inference.js';
4
+ export type { PocketModel } from './inference.js';
5
+ export type ModelLoader = (lang: PocketLanguage) => Promise<PocketModel>;
6
+ export declare const PCM_CONTENT_TYPE = "audio/pcm;rate=24000;channels=1";
7
+ /** True once the native runtime is loaded into this process (its files are then in use). */
8
+ export declare const runtimeLoaded: () => boolean;
9
+ /** onnxruntime-node from the downloaded runtime. Throws a readable error when it is
10
+ * missing or cannot load on this system (the reason is kept for `runtimeLoadError`). */
11
+ export declare function loadOnnxRuntime(): OrtModule;
12
+ /** Why the installed runtime cannot load, probing it once if never tried. */
13
+ export declare function runtimeLoadError(): string | undefined;
14
+ export declare function setModelLoaderForTest(l: ModelLoader | null): void;
15
+ export declare function releasePocketModels(): Promise<void>;
16
+ export declare const speakBuiltin: BuiltinSpeaker;
17
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/voice/pocket/engine.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAuD,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AACxG,OAAO,EAAqB,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGrF,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAEzE,eAAO,MAAM,gBAAgB,oCAAoD,CAAC;AAKlF,4FAA4F;AAC5F,eAAO,MAAM,aAAa,eAAqB,CAAC;AAEhD;yFACyF;AACzF,wBAAgB,eAAe,IAAI,SAAS,CAY3C;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CASrD;AASD,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAEjE;AA4BD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIzD;AAaD,eAAO,MAAM,YAAY,EAAE,cAsD1B,CAAC"}
@@ -0,0 +1,145 @@
1
+ // The built-in voice engine: one warm Pocket model per language, calls on a model
2
+ // serialized, PCM int16 LE streamed back as it is generated. The ONNX runtime is the
3
+ // one the installer downloaded, loaded by absolute path (never a package dependency).
4
+ import { existsSync } from 'node:fs';
5
+ import { createRequire } from 'node:module';
6
+ import os from 'node:os';
7
+ import { POCKET_LANGUAGES, POCKET_SAMPLE_RATE, POCKET_VOICES } from './catalog.js';
8
+ import { createPocketModel } from './inference.js';
9
+ import { bundleDir, runtimeEntry } from './install.js';
10
+ export const PCM_CONTENT_TYPE = `audio/pcm;rate=${POCKET_SAMPLE_RATE};channels=1`;
11
+ let ort = null;
12
+ let lastLoadError;
13
+ /** True once the native runtime is loaded into this process (its files are then in use). */
14
+ export const runtimeLoaded = () => ort !== null;
15
+ /** onnxruntime-node from the downloaded runtime. Throws a readable error when it is
16
+ * missing or cannot load on this system (the reason is kept for `runtimeLoadError`). */
17
+ export function loadOnnxRuntime() {
18
+ if (ort)
19
+ return ort;
20
+ const entry = runtimeEntry();
21
+ if (!existsSync(entry))
22
+ throw new Error('The built-in voice runtime is not installed.');
23
+ try {
24
+ ort = createRequire(entry)(entry);
25
+ lastLoadError = undefined;
26
+ return ort;
27
+ }
28
+ catch (e) {
29
+ lastLoadError = e instanceof Error ? e.message : String(e);
30
+ throw new Error(`The built-in voice runtime could not be loaded: ${lastLoadError}`);
31
+ }
32
+ }
33
+ /** Why the installed runtime cannot load, probing it once if never tried. */
34
+ export function runtimeLoadError() {
35
+ if (!ort && existsSync(runtimeEntry())) {
36
+ try {
37
+ loadOnnxRuntime();
38
+ }
39
+ catch {
40
+ /* recorded in lastLoadError */
41
+ }
42
+ }
43
+ return lastLoadError;
44
+ }
45
+ // ponytail: physical cores capped at 4 — measured on a 6-core Zen 1: 4 threads
46
+ // slightly beat 6, 12 halved the speed. Make it a setting if other machines disagree.
47
+ const threads = () => Math.min(4, Math.max(1, Math.floor(os.availableParallelism() / 2)));
48
+ const defaultLoader = async (lang) => createPocketModel(loadOnnxRuntime(), bundleDir(lang), { threads: threads() });
49
+ let loader = defaultLoader;
50
+ export function setModelLoaderForTest(l) {
51
+ loader = l ?? defaultLoader;
52
+ }
53
+ const slots = new Map();
54
+ function closeSlot(s) {
55
+ void s.tail
56
+ .then(() => s.model)
57
+ .then((m) => m.close())
58
+ .catch(() => { });
59
+ }
60
+ function slotFor(lang) {
61
+ let s = slots.get(lang);
62
+ if (s)
63
+ return s;
64
+ for (const [other, o] of slots) {
65
+ slots.delete(other);
66
+ closeSlot(o);
67
+ }
68
+ s = { model: loader(lang), tail: Promise.resolve() };
69
+ s.model.catch(() => slots.get(lang) === s && slots.delete(lang));
70
+ slots.set(lang, s);
71
+ return s;
72
+ }
73
+ export async function releasePocketModels() {
74
+ const all = [...slots.values()];
75
+ slots.clear();
76
+ await Promise.all(all.map((s) => s.tail.then(() => s.model).then((m) => m.close()).catch(() => { })));
77
+ }
78
+ function toPcm16(samples) {
79
+ const out = new DataView(new ArrayBuffer(samples.length * 2));
80
+ for (let i = 0; i < samples.length; i++) {
81
+ const s = Math.max(-1, Math.min(1, samples[i]));
82
+ out.setInt16(i * 2, Math.round(s < 0 ? s * 32768 : s * 32767), true);
83
+ }
84
+ return new Uint8Array(out.buffer);
85
+ }
86
+ const text = (status, body) => new Response(body, { status });
87
+ export const speakBuiltin = async (voice, input, signal) => {
88
+ const lang = voice.ttsLanguage;
89
+ const spec = Object.hasOwn(POCKET_LANGUAGES, lang ?? '') ? POCKET_LANGUAGES[lang] : null;
90
+ if (!spec)
91
+ return text(400, `Unknown built-in voice language: ${voice.ttsLanguage ?? '(none)'}.`);
92
+ if (!existsSync(runtimeEntry()))
93
+ return text(409, 'The built-in voice runtime is not installed. Install a language in Settings → Voice.');
94
+ if (!existsSync(bundleDir(lang)))
95
+ return text(409, `The ${lang} built-in voice is not installed. Install it in Settings → Voice.`);
96
+ const name = voice.ttsVoice && POCKET_VOICES.includes(voice.ttsVoice) ? voice.ttsVoice : spec.nativeVoice;
97
+ // Take a turn on this language's model: calls run one at a time, in arrival order.
98
+ const slot = slotFor(lang);
99
+ let release;
100
+ const prev = slot.tail;
101
+ slot.tail = new Promise((r) => (release = r));
102
+ await prev;
103
+ let model;
104
+ try {
105
+ model = await slot.model;
106
+ }
107
+ catch (e) {
108
+ release();
109
+ return text(500, e instanceof Error ? e.message : String(e));
110
+ }
111
+ if (signal.aborted) {
112
+ release();
113
+ return new Response(null, { status: 204 });
114
+ }
115
+ const ac = new AbortController();
116
+ const onAbort = () => ac.abort();
117
+ signal.addEventListener('abort', onAbort, { once: true });
118
+ const body = new ReadableStream({
119
+ start(controller) {
120
+ void (async () => {
121
+ try {
122
+ for await (const frame of model.synthesize(input, name, ac.signal)) {
123
+ if (ac.signal.aborted)
124
+ break;
125
+ controller.enqueue(toPcm16(frame));
126
+ }
127
+ if (!ac.signal.aborted)
128
+ controller.close();
129
+ }
130
+ catch (e) {
131
+ if (!ac.signal.aborted)
132
+ controller.error(e);
133
+ }
134
+ finally {
135
+ signal.removeEventListener('abort', onAbort);
136
+ release();
137
+ }
138
+ })();
139
+ },
140
+ cancel() {
141
+ ac.abort();
142
+ },
143
+ });
144
+ return new Response(body, { headers: { 'content-type': PCM_CONTENT_TYPE } });
145
+ };
@@ -0,0 +1,36 @@
1
+ export interface PocketModel {
2
+ readonly sampleRate: number;
3
+ synthesize(text: string, voice: string, signal: AbortSignal): AsyncIterable<Float32Array>;
4
+ close(): Promise<void>;
5
+ }
6
+ export interface OrtTensor {
7
+ readonly data: unknown;
8
+ readonly dims: readonly number[];
9
+ }
10
+ export interface OrtSession {
11
+ run(feeds: Record<string, OrtTensor>): Promise<Record<string, OrtTensor>>;
12
+ release(): Promise<void>;
13
+ }
14
+ export interface OrtModule {
15
+ InferenceSession: {
16
+ create(path: string, options?: {
17
+ intraOpNumThreads?: number;
18
+ interOpNumThreads?: number;
19
+ executionMode?: 'sequential' | 'parallel';
20
+ }): Promise<OrtSession>;
21
+ };
22
+ Tensor: new (type: 'float32' | 'int64' | 'bool', data: Float32Array | BigInt64Array | Uint8Array, dims: readonly number[]) => OrtTensor;
23
+ }
24
+ export declare const POCKET_GRAPHS: {
25
+ readonly textConditioner: "text_conditioner_int8.onnx";
26
+ readonly flowMain: "flow_lm_main_int8.onnx";
27
+ readonly flowStep: "flow_lm_flow_int8.onnx";
28
+ readonly mimi: "mimi_decoder_int8.onnx";
29
+ };
30
+ export declare const POCKET_VOICES_FILE = "voices.bin";
31
+ export declare const DEFAULT_FRAMES_PER_DECODE = 4;
32
+ export declare function createPocketModel(ort: OrtModule, bundleDir: string, opts: {
33
+ threads: number;
34
+ framesPerDecode?: number;
35
+ }): Promise<PocketModel>;
36
+ //# sourceMappingURL=inference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../src/voice/pocket/inference.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;IAC1F,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAGD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AACD,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAC1E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,C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