@sonara/client 0.21.6
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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/cjs/client.d.ts +87 -0
- package/dist/cjs/client.js +196 -0
- package/dist/cjs/connect.d.ts +44 -0
- package/dist/cjs/connect.js +157 -0
- package/dist/cjs/connection.d.ts +25 -0
- package/dist/cjs/connection.js +121 -0
- package/dist/cjs/discovery.d.ts +23 -0
- package/dist/cjs/discovery.js +116 -0
- package/dist/cjs/engines.d.ts +99 -0
- package/dist/cjs/engines.js +75 -0
- package/dist/cjs/errors.d.ts +23 -0
- package/dist/cjs/errors.js +14 -0
- package/dist/cjs/extensions.d.ts +82 -0
- package/dist/cjs/extensions.js +106 -0
- package/dist/cjs/index.d.ts +21 -0
- package/dist/cjs/index.js +29 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.d.ts +111 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/version.d.ts +7 -0
- package/dist/cjs/version.js +7 -0
- package/dist/esm/client.d.ts +87 -0
- package/dist/esm/client.js +192 -0
- package/dist/esm/connect.d.ts +44 -0
- package/dist/esm/connect.js +154 -0
- package/dist/esm/connection.d.ts +25 -0
- package/dist/esm/connection.js +117 -0
- package/dist/esm/discovery.d.ts +23 -0
- package/dist/esm/discovery.js +106 -0
- package/dist/esm/engines.d.ts +99 -0
- package/dist/esm/engines.js +71 -0
- package/dist/esm/errors.d.ts +23 -0
- package/dist/esm/errors.js +10 -0
- package/dist/esm/extensions.d.ts +82 -0
- package/dist/esm/extensions.js +100 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/types.d.ts +111 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/version.d.ts +7 -0
- package/dist/esm/version.js +4 -0
- package/package.json +55 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sonara/client: talk to the Sonara runtime (protocol v1) from Node 18+
|
|
3
|
+
* or an Electron main process. Zero dependencies.
|
|
4
|
+
*
|
|
5
|
+
* const sonara = await connect({ clientName: "my-app", runtimePath });
|
|
6
|
+
* sonara.onState((s) => render(s));
|
|
7
|
+
* await sonara.speak("Hello.");
|
|
8
|
+
*/
|
|
9
|
+
export { connect } from "./connect.js";
|
|
10
|
+
export type { ConnectOptions } from "./connect.js";
|
|
11
|
+
export { SonaraClient } from "./client.js";
|
|
12
|
+
export type { Unsubscribe } from "./client.js";
|
|
13
|
+
export { SonaraError } from "./errors.js";
|
|
14
|
+
export type { ErrorCode } from "./errors.js";
|
|
15
|
+
export { AgentApi, ChannelsApi, SystemApi } from "./extensions.js";
|
|
16
|
+
export { EnginesApi } from "./engines.js";
|
|
17
|
+
export type { EngineAddOptions, EngineModelsDraft, EngineProfile, SendMode, EngineTestOptions, } from "./engines.js";
|
|
18
|
+
export type { AskKind, AudioMode, ChannelOpenOptions, ChannelPolicy, StreamMessage } from "./extensions.js";
|
|
19
|
+
export { readRuntime, resolveHome } from "./discovery.js";
|
|
20
|
+
export { PROTOCOL, VERSION } from "./version.js";
|
|
21
|
+
export type { ControlAction, EngineStatus, HelloInfo, ItemEvent, ItemPhase, LogEvent, NowPlaying, Reply, RuntimeInfo, SettingKey, SpeakMode, SpeakOptions, State, Voice, } from "./types.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sonara/client: talk to the Sonara runtime (protocol v1) from Node 18+
|
|
3
|
+
* or an Electron main process. Zero dependencies.
|
|
4
|
+
*
|
|
5
|
+
* const sonara = await connect({ clientName: "my-app", runtimePath });
|
|
6
|
+
* sonara.onState((s) => render(s));
|
|
7
|
+
* await sonara.speak("Hello.");
|
|
8
|
+
*/
|
|
9
|
+
export { connect } from "./connect.js";
|
|
10
|
+
export { SonaraClient } from "./client.js";
|
|
11
|
+
export { SonaraError } from "./errors.js";
|
|
12
|
+
export { AgentApi, ChannelsApi, SystemApi } from "./extensions.js";
|
|
13
|
+
export { EnginesApi } from "./engines.js";
|
|
14
|
+
export { readRuntime, resolveHome } from "./discovery.js";
|
|
15
|
+
export { PROTOCOL, VERSION } from "./version.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/** Queue mode of `speak`: after everything queued, or drop the unread items first. */
|
|
2
|
+
export type SpeakMode = "append" | "replace";
|
|
3
|
+
/** Core playback controls (protocol v1, `control`). */
|
|
4
|
+
export type ControlAction = "play" | "pause" | "toggle" | "stop" | "skip" | "previous" | "next" | "restart" | "mute" | "unmute";
|
|
5
|
+
/** Core setting keys (protocol v1, `set` / `get`). */
|
|
6
|
+
export type SettingKey = "volume" | "rate" | "voice" | "engine";
|
|
7
|
+
export interface SpeakOptions {
|
|
8
|
+
/** `append` (default) or `replace` (drop unread items, never the current one). */
|
|
9
|
+
mode?: SpeakMode;
|
|
10
|
+
/** Also cut the current item and start this one now. */
|
|
11
|
+
interrupt?: boolean;
|
|
12
|
+
/** Shown in `state.now_playing.label`. */
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface NowPlaying {
|
|
16
|
+
item_id: number;
|
|
17
|
+
label: string | null;
|
|
18
|
+
/** The chunk being read. */
|
|
19
|
+
text: string;
|
|
20
|
+
chunk: number;
|
|
21
|
+
chunks: number;
|
|
22
|
+
[extra: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
/** A `state` event: a full snapshot, sent on change only. */
|
|
25
|
+
export interface State {
|
|
26
|
+
seq: number;
|
|
27
|
+
now_playing: NowPlaying | null;
|
|
28
|
+
queued: number;
|
|
29
|
+
paused: boolean;
|
|
30
|
+
muted: boolean;
|
|
31
|
+
volume: number;
|
|
32
|
+
rate: number;
|
|
33
|
+
voice: string | null;
|
|
34
|
+
engine_status: EngineStatus;
|
|
35
|
+
[extra: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `state.engine_status`. Protocol 1.1 adds readiness: Kokoro is `loading`,
|
|
39
|
+
* `downloading` (with `progress`), `waiting` to retry or `unavailable`
|
|
40
|
+
* until it is `ready`, and names the engine speaking meanwhile in
|
|
41
|
+
* `fallback`. A 1.0 runtime sends only `engine`.
|
|
42
|
+
*/
|
|
43
|
+
export interface EngineStatus {
|
|
44
|
+
engine: string;
|
|
45
|
+
ready?: boolean;
|
|
46
|
+
status?: "ready" | "loading" | "downloading" | "waiting" | "unavailable";
|
|
47
|
+
progress?: {
|
|
48
|
+
done: number;
|
|
49
|
+
total: number;
|
|
50
|
+
};
|
|
51
|
+
fallback?: string;
|
|
52
|
+
message?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Protocol 1.2: why an external engine is not speaking itself
|
|
55
|
+
* (`no_key`, `auth`, `quota`, `rate_limited`, `network`, `timeout`,
|
|
56
|
+
* `server`, `bad_voice`, `bad_config`, `format`).
|
|
57
|
+
*/
|
|
58
|
+
reason?: string;
|
|
59
|
+
[extra: string]: unknown;
|
|
60
|
+
}
|
|
61
|
+
export type ItemPhase = "started" | "finished" | "skipped" | "failed";
|
|
62
|
+
/** An `item` event. */
|
|
63
|
+
export interface ItemEvent {
|
|
64
|
+
item_id: number;
|
|
65
|
+
phase: ItemPhase;
|
|
66
|
+
[extra: string]: unknown;
|
|
67
|
+
}
|
|
68
|
+
/** A `log` event. */
|
|
69
|
+
export interface LogEvent {
|
|
70
|
+
message: string;
|
|
71
|
+
[extra: string]: unknown;
|
|
72
|
+
}
|
|
73
|
+
export interface Voice {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
language: string;
|
|
77
|
+
engine: string;
|
|
78
|
+
license_class: "permissive" | "os" | "external";
|
|
79
|
+
installed: boolean;
|
|
80
|
+
[extra: string]: unknown;
|
|
81
|
+
}
|
|
82
|
+
/** The `hello` reply: what the runtime offers. */
|
|
83
|
+
export interface HelloInfo {
|
|
84
|
+
version: string;
|
|
85
|
+
protocol: {
|
|
86
|
+
major: number;
|
|
87
|
+
minor: number;
|
|
88
|
+
};
|
|
89
|
+
capabilities: string[];
|
|
90
|
+
extensions: string[];
|
|
91
|
+
/** Requested extensions this runtime lacks. */
|
|
92
|
+
unavailable: string[];
|
|
93
|
+
[extra: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
/** Contents of `runtime.json` (protocol v1, Discovery). */
|
|
96
|
+
export interface RuntimeInfo {
|
|
97
|
+
pid: number;
|
|
98
|
+
port: number;
|
|
99
|
+
http_port: number;
|
|
100
|
+
token: string;
|
|
101
|
+
version: string;
|
|
102
|
+
protocol: {
|
|
103
|
+
major: number;
|
|
104
|
+
minor: number;
|
|
105
|
+
};
|
|
106
|
+
capabilities: string[];
|
|
107
|
+
started_at: string;
|
|
108
|
+
[extra: string]: unknown;
|
|
109
|
+
}
|
|
110
|
+
/** Any reply with `ok: true`; the fields depend on the request. */
|
|
111
|
+
export type Reply = Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sonara/client",
|
|
3
|
+
"version": "0.21.6",
|
|
4
|
+
"description": "Client for the Sonara text-to-speech runtime (protocol v1): connect, speak, control, live state. Zero dependencies.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Maxaubert/Sonara.git",
|
|
9
|
+
"directory": "clients/ts"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"sonara",
|
|
13
|
+
"tts",
|
|
14
|
+
"text-to-speech",
|
|
15
|
+
"electron",
|
|
16
|
+
"speech"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"main": "./dist/cjs/index.js",
|
|
22
|
+
"module": "./dist/esm/index.js",
|
|
23
|
+
"types": "./dist/cjs/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/esm/index.d.ts",
|
|
28
|
+
"default": "./dist/esm/index.js"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/cjs/index.d.ts",
|
|
32
|
+
"default": "./dist/cjs/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist/",
|
|
39
|
+
"LICENSE",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"sideEffects": false,
|
|
43
|
+
"scripts": {
|
|
44
|
+
"clean": "node scripts/clean.mjs",
|
|
45
|
+
"build": "node scripts/clean.mjs && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && node scripts/mark-dist.mjs",
|
|
46
|
+
"typecheck": "tsc -p tsconfig.esm.json --noEmit",
|
|
47
|
+
"test": "node scripts/test.mjs",
|
|
48
|
+
"test:unit": "node scripts/test.mjs unit",
|
|
49
|
+
"prepack": "npm run build"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "18.19.130",
|
|
53
|
+
"typescript": "5.9.3"
|
|
54
|
+
}
|
|
55
|
+
}
|