@adea-ai/voice 0.2.0 → 0.4.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/README.md +86 -1
- package/dist/cli/helpers-cli.js +17 -2
- package/dist/contract/contract.d.ts +21 -2
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +12 -2
- package/dist/contract/session.d.ts +13 -0
- package/dist/contract/turns.d.ts +91 -0
- package/dist/contract/wire.d.ts +92 -1
- package/dist/desktop/conversation.d.ts +86 -0
- package/dist/desktop/desktop-voice.d.ts +61 -1
- package/dist/desktop/helper-lock.d.ts +45 -7
- package/dist/desktop/helper-process.d.ts +4 -0
- package/dist/desktop/index.d.ts +2 -0
- package/dist/desktop/index.js +427 -15
- package/dist/desktop/macho-digest.d.ts +9 -0
- package/dist/{index-rehs788p.js → index-7n7epq1a.js} +7 -2
- package/dist/{index-s270cw30.js → index-a7d617zr.js} +1 -1
- package/dist/{index-9kerqn9r.js → index-ght8wwpd.js} +9 -3
- package/dist/{index-acm1yvvv.js → index-m4g2tpeq.js} +258 -26
- package/dist/index.js +13 -3
- package/dist/settings/index.js +1 -1
- package/dist/web/index.d.ts +1 -0
- package/dist/web/index.js +459 -49
- package/dist/web/stt/speech-recognition.d.ts +128 -7
- package/dist/web/tts/locale-match.d.ts +40 -0
- package/dist/web/tts/system-voices.d.ts +44 -4
- package/dist/web/turns.d.ts +15 -25
- package/package.json +1 -1
- package/src/cli/helpers-cli.ts +18 -2
- package/src/contract/contract.ts +32 -4
- package/src/contract/index.ts +1 -0
- package/src/contract/session.ts +14 -2
- package/src/contract/turns.ts +48 -0
- package/src/contract/wire.ts +123 -2
- package/src/desktop/conversation.ts +347 -0
- package/src/desktop/desktop-voice.ts +197 -1
- package/src/desktop/helper-lock.ts +195 -20
- package/src/desktop/helper-process.ts +17 -10
- package/src/desktop/index.ts +2 -0
- package/src/desktop/macho-digest.ts +135 -0
- package/src/web/index.ts +1 -0
- package/src/web/stt/speech-recognition.ts +454 -24
- package/src/web/tts/locale-match.ts +131 -0
- package/src/web/tts/system-voices.ts +144 -35
- package/src/web/turns.ts +22 -11
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { type VoiceProviderAvailability, type VoiceProviderDescriptor, type VoiceProviderKind, type VoiceRoutingDecision, type VoiceRoutingPolicy } from "../contract/contract";
|
|
19
19
|
import type { PartialTranscript, TranscriptionSession } from "../contract/session";
|
|
20
|
-
import type { CombinedPermission, LocaleEvent, PermissionPart, TranscribeStatusEvent, VoiceEvent } from "../contract/wire";
|
|
20
|
+
import type { CombinedPermission, LocaleEvent, PermissionPart, SpeechVoiceIdentity, TranscribeStatusEvent, VoiceEvent } from "../contract/wire";
|
|
21
21
|
import { type VoiceSettings } from "../settings/settings";
|
|
22
|
+
import { type DesktopConversation } from "./conversation";
|
|
22
23
|
import { type HelperSpawner } from "./helper-process";
|
|
23
24
|
export declare const APPLE_ANALYZER_ID = "apple.analyzer";
|
|
24
25
|
export declare const APPLE_LEGACY_ID = "apple.legacy";
|
|
@@ -102,13 +103,42 @@ export interface SpeakRequest {
|
|
|
102
103
|
readonly queue?: "replace" | "after-current";
|
|
103
104
|
}
|
|
104
105
|
export type SpeechOutcome = "finished" | "cancelled";
|
|
106
|
+
/** What the helper reports when audio starts. */
|
|
107
|
+
export interface SpeechStart {
|
|
108
|
+
/**
|
|
109
|
+
* The voice that resolved for the request (`speech-started.voice`), when the helper reports it
|
|
110
|
+
* (Apple helper builds after 0.2.0 do, for a `speak` that named a voice or a locale).
|
|
111
|
+
*/
|
|
112
|
+
readonly voice?: SpeechVoiceIdentity;
|
|
113
|
+
}
|
|
105
114
|
export interface DesktopSpeech {
|
|
106
115
|
readonly id: string;
|
|
107
116
|
readonly provider: string;
|
|
117
|
+
/**
|
|
118
|
+
* Resolves when the helper reports `speech-started` (audio begins), with the voice it resolved.
|
|
119
|
+
* Resolves `undefined` if the speech ends, is cancelled or fails before it started; never
|
|
120
|
+
* rejects.
|
|
121
|
+
*/
|
|
122
|
+
readonly started: Promise<SpeechStart | undefined>;
|
|
108
123
|
/** Resolves when playback ends or is cancelled; rejects with `VoiceError` on failure. */
|
|
109
124
|
readonly done: Promise<SpeechOutcome>;
|
|
110
125
|
cancel(): Promise<void>;
|
|
111
126
|
}
|
|
127
|
+
export interface ConversationRequest {
|
|
128
|
+
readonly settings: VoiceSettings;
|
|
129
|
+
/** BCP-47 for listening; defaults to the settings' locale, then the system language. */
|
|
130
|
+
readonly locale?: string;
|
|
131
|
+
/** Starting a turn while the answer plays stops it (a request cancel). Default true. */
|
|
132
|
+
readonly bargeIn?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* The microphone stays closed while the answer plays, so the assistant never hears itself.
|
|
135
|
+
* Default true; turn it off only with echo cancellation (a headset).
|
|
136
|
+
*/
|
|
137
|
+
readonly halfDuplex?: boolean;
|
|
138
|
+
/** Start the next turn by itself once an answer has played. Default true (hands-free). */
|
|
139
|
+
readonly continuous?: boolean;
|
|
140
|
+
readonly signal?: AbortSignal;
|
|
141
|
+
}
|
|
112
142
|
export interface DesktopVoiceInfo {
|
|
113
143
|
readonly id: string;
|
|
114
144
|
readonly name: string;
|
|
@@ -126,6 +156,24 @@ export interface InstallRequest {
|
|
|
126
156
|
readonly onProgress?: (fraction: number | null) => void;
|
|
127
157
|
readonly signal?: AbortSignal;
|
|
128
158
|
}
|
|
159
|
+
export interface ReleaseRequest {
|
|
160
|
+
/** BCP-47 locale whose Apple model to remove, e.g. `es-419` (released as its model locale, `es_MX`). */
|
|
161
|
+
readonly locale: string;
|
|
162
|
+
}
|
|
163
|
+
/** What `releaseAssets` did, and the locale's model state afterwards. */
|
|
164
|
+
export interface ReleasedAsset {
|
|
165
|
+
readonly locale: string;
|
|
166
|
+
/** The model's own locale in BCP-47 (`es-MX` for `es-419`). */
|
|
167
|
+
readonly modelLocale: string;
|
|
168
|
+
/** False when this app held no reservation for the model (nothing was released). */
|
|
169
|
+
readonly released: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* The status the system reports after the release. Usually `notInstalled`; a model shared with
|
|
172
|
+
* system dictation can stay `installed` until the OS reclaims it.
|
|
173
|
+
*/
|
|
174
|
+
readonly status: LocaleEvent["status"];
|
|
175
|
+
readonly canInstall: boolean;
|
|
176
|
+
}
|
|
129
177
|
export interface DesktopVoice {
|
|
130
178
|
/** Which helpers this build bundles (synchronous, no process started). */
|
|
131
179
|
bundled(): Readonly<Record<"voice" | "transcribe" | "tts", boolean>>;
|
|
@@ -136,9 +184,21 @@ export interface DesktopVoice {
|
|
|
136
184
|
listen(request: DictationRequest): Promise<DesktopDictation>;
|
|
137
185
|
speak(request: SpeakRequest): Promise<DesktopSpeech>;
|
|
138
186
|
stopSpeaking(): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Starts a voice conversation (Octy-style turns with streamed answers and barge-in) and
|
|
189
|
+
* resolves once the first turn is listening. Runs on `adea-voice-helper` (Apple speech, wire
|
|
190
|
+
* 1.2+): a route to another engine is a typed `unavailable`.
|
|
191
|
+
*/
|
|
192
|
+
conversation(request: ConversationRequest): Promise<DesktopConversation>;
|
|
139
193
|
voices(settings: VoiceSettings, locale?: string): Promise<readonly DesktopVoiceInfo[]>;
|
|
140
194
|
locales(): Promise<readonly LocaleAsset[]>;
|
|
141
195
|
installAssets(request: InstallRequest): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Removes an Apple on-device speech model: releases this app's reservation of it so the OS may
|
|
198
|
+
* reclaim the storage. Nothing is deleted directly; the system decides when the files go.
|
|
199
|
+
* Needs a voice helper on wire 1.3+ (`unavailable` otherwise).
|
|
200
|
+
*/
|
|
201
|
+
releaseAssets(request: ReleaseRequest): Promise<ReleasedAsset>;
|
|
142
202
|
/** Stops every helper. The instance can be used again; helpers restart on demand. */
|
|
143
203
|
dispose(): Promise<void>;
|
|
144
204
|
}
|
|
@@ -9,6 +9,8 @@ export interface HelperArtifactPin {
|
|
|
9
9
|
readonly file: string;
|
|
10
10
|
readonly sha256: string;
|
|
11
11
|
readonly executableSha256: string;
|
|
12
|
+
/** The executable's `machoCodeDigest` (0.2.1+): what a re-signed packaged copy still matches. */
|
|
13
|
+
readonly codeSha256?: string;
|
|
12
14
|
readonly bytes?: number;
|
|
13
15
|
}
|
|
14
16
|
export interface HelperLock {
|
|
@@ -17,15 +19,25 @@ export interface HelperLock {
|
|
|
17
19
|
readonly base: string;
|
|
18
20
|
readonly helpers: Readonly<Partial<Record<HelperName, Readonly<Partial<Record<HelperTarget, HelperArtifactPin>>>>>>;
|
|
19
21
|
}
|
|
22
|
+
/** One staged helper: the pins it was staged from and the code digest of what was staged. */
|
|
23
|
+
export interface StagedHelperEntry {
|
|
24
|
+
readonly sha256: string;
|
|
25
|
+
readonly executableSha256: string;
|
|
26
|
+
/** `machoCodeDigest` of the staged executable (absent in records staged before 0.2.1). */
|
|
27
|
+
readonly codeSha256?: string;
|
|
28
|
+
}
|
|
20
29
|
/** What a staged directory records about itself, written next to the helpers. */
|
|
21
30
|
export interface StagedHelperRecord {
|
|
22
31
|
readonly schema: 1;
|
|
23
32
|
readonly version: string;
|
|
24
33
|
readonly target: HelperTarget;
|
|
25
|
-
readonly helpers: Readonly<Partial<Record<HelperName,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
readonly helpers: Readonly<Partial<Record<HelperName, StagedHelperEntry>>>;
|
|
35
|
+
/**
|
|
36
|
+
* Every other staged file (the helpers' `Frameworks/`), relative path → digest: the code digest
|
|
37
|
+
* for Mach-O files (they are re-signed when packaged), the sha256 otherwise. Signature
|
|
38
|
+
* directories (`_CodeSignature/`) are left out. Absent in records staged before 0.2.1.
|
|
39
|
+
*/
|
|
40
|
+
readonly files?: Readonly<Record<string, string>>;
|
|
29
41
|
}
|
|
30
42
|
export declare const STAGED_RECORD_FILE = "voice-helpers.json";
|
|
31
43
|
export declare class HelperLockError extends Error {
|
|
@@ -70,14 +82,40 @@ export interface VerifyStagedOptions {
|
|
|
70
82
|
readonly target: HelperTarget;
|
|
71
83
|
readonly dir: string;
|
|
72
84
|
readonly helpers: readonly HelperName[];
|
|
73
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Launch each helper with `--version` and require the lock's release and this SDK's wire and
|
|
87
|
+
* contract (only possible on a matching machine; default: when the target matches this one).
|
|
88
|
+
*/
|
|
74
89
|
readonly handshake?: boolean;
|
|
90
|
+
/** How long one `--version` may take. Default 10 s. */
|
|
91
|
+
readonly handshakeTimeoutMs?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Run `codesign --verify --strict` on a helper that was signed again after staging (default: on
|
|
94
|
+
* macOS for a macOS target).
|
|
95
|
+
*/
|
|
96
|
+
readonly codesign?: boolean;
|
|
75
97
|
}
|
|
76
98
|
/**
|
|
77
99
|
* The release gate: the packaged directory holds exactly the pinned helpers. Throws
|
|
78
100
|
* `HelperLockError` naming the first difference; a local (unpinned) staging is refused.
|
|
101
|
+
*
|
|
102
|
+
* The directory may be the staged one or the copy inside a packaged, re-signed app. A helper whose
|
|
103
|
+
* file sha256 is not the pinned one must still have the pinned code (`machoCodeDigest`): the
|
|
104
|
+
* lock's `codeSha256`, or, for a lock written before it, the digest the staging recorded for the
|
|
105
|
+
* pinned executable, plus a valid signature. Every other staged file (`Frameworks/`) must still be
|
|
106
|
+
* a regular file with the staged digest: a copy that flattened or dropped a symlink fails here.
|
|
107
|
+
* Then each helper must start and report the lock's release.
|
|
79
108
|
*/
|
|
80
109
|
export declare function verifyStagedVoiceHelpers(options: VerifyStagedOptions): void;
|
|
81
110
|
export declare function readStagedRecord(dir: string): StagedHelperRecord | undefined;
|
|
82
|
-
|
|
83
|
-
|
|
111
|
+
export interface HandshakeExpectations {
|
|
112
|
+
/** The release the helper must report (`version.release`), e.g. the lock's version. */
|
|
113
|
+
readonly release?: string;
|
|
114
|
+
/** How long `--version` may take before the helper counts as hung. Default 10 s. */
|
|
115
|
+
readonly timeoutMs?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Runs `<helper> --version` and refuses a helper that does not start (a missing library is a dyld
|
|
119
|
+
* abort here), hangs, or speaks another wire, contract or release.
|
|
120
|
+
*/
|
|
121
|
+
export declare function assertHandshake(executable: string, expect?: HandshakeExpectations): void;
|
|
@@ -16,6 +16,8 @@ export interface HelperSpawnOptions {
|
|
|
16
16
|
export type HelperSpawner = (path: string, args: readonly string[], options: HelperSpawnOptions) => HelperChild;
|
|
17
17
|
export interface HelperConnectionOptions {
|
|
18
18
|
readonly path: string;
|
|
19
|
+
/** Names the helper in errors and logs, e.g. `adea-transcribe-helper`. Default "voice helper". */
|
|
20
|
+
readonly name?: string;
|
|
19
21
|
readonly spawn: HelperSpawner;
|
|
20
22
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
21
23
|
/** How long `--version` may take. Default 5 s. */
|
|
@@ -56,6 +58,8 @@ export declare class HelperConnection {
|
|
|
56
58
|
private disposed;
|
|
57
59
|
private incompatible;
|
|
58
60
|
constructor(options: HelperConnectionOptions);
|
|
61
|
+
/** "the voice helper", or the configured helper name. */
|
|
62
|
+
private get label();
|
|
59
63
|
/** The handshake the running helper answered, once it has started. */
|
|
60
64
|
get version(): VersionEvent | undefined;
|
|
61
65
|
/** Receives every event, correlated or not (speech-state, route changes). */
|
package/dist/desktop/index.d.ts
CHANGED
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
* from a desktop shell process only (it spawns processes); a renderer talks to the shell.
|
|
4
4
|
*/
|
|
5
5
|
export * from "./desktop-voice";
|
|
6
|
+
export type { ConversationRespondOptions, DesktopConversation } from "./conversation";
|
|
6
7
|
export { HelperConnection, IncompatibleHelperError, LineSplitter, nodeSpawner, type HelperChild, type HelperConnectionOptions, type HelperSpawnOptions, type HelperSpawner, } from "./helper-process";
|
|
7
8
|
export * from "./helper-lock";
|
|
9
|
+
export { isMachO, machoCodeDigest, machoCodeDigestFile } from "./macho-digest";
|