@adea-ai/voice 0.0.0-stage → 0.2.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 (52) hide show
  1. package/README.md +51 -2
  2. package/dist/cli/helpers-cli.d.ts +2 -0
  3. package/dist/cli/helpers-cli.js +102 -0
  4. package/dist/contract/contract.d.ts +138 -0
  5. package/dist/contract/errors.d.ts +26 -0
  6. package/dist/contract/index.d.ts +9 -0
  7. package/dist/contract/index.js +54 -0
  8. package/dist/contract/session.d.ts +58 -0
  9. package/dist/contract/wire.d.ts +188 -0
  10. package/dist/desktop/desktop-voice.d.ts +152 -0
  11. package/dist/desktop/helper-lock.d.ts +83 -0
  12. package/dist/desktop/helper-process.d.ts +92 -0
  13. package/dist/desktop/index.d.ts +7 -0
  14. package/dist/desktop/index.js +1042 -0
  15. package/dist/index-9kerqn9r.js +150 -0
  16. package/dist/index-acm1yvvv.js +290 -0
  17. package/dist/index-r4hz8gk0.js +10 -0
  18. package/dist/index-rehs788p.js +42 -0
  19. package/dist/index-s270cw30.js +295 -0
  20. package/dist/index-tvz9s9nz.js +77 -0
  21. package/dist/index.d.ts +7 -0
  22. package/dist/index.js +86 -0
  23. package/dist/settings/index.d.ts +5 -0
  24. package/dist/settings/index.js +34 -0
  25. package/dist/settings/settings.d.ts +163 -0
  26. package/dist/web/index.d.ts +15 -0
  27. package/dist/web/index.js +1287 -0
  28. package/dist/web/stt/speech-recognition.d.ts +105 -0
  29. package/dist/web/tts/phonon.d.ts +139 -0
  30. package/dist/web/tts/player.d.ts +115 -0
  31. package/dist/web/tts/system-voices.d.ts +122 -0
  32. package/dist/web/turns.d.ts +101 -0
  33. package/package.json +68 -4
  34. package/src/cli/helpers-cli.ts +119 -0
  35. package/src/contract/contract.ts +365 -0
  36. package/src/contract/errors.ts +98 -0
  37. package/src/contract/index.ts +9 -0
  38. package/src/contract/session.ts +65 -0
  39. package/src/contract/wire.ts +263 -0
  40. package/src/desktop/desktop-voice.ts +933 -0
  41. package/src/desktop/helper-lock.ts +375 -0
  42. package/src/desktop/helper-process.ts +401 -0
  43. package/src/desktop/index.ts +16 -0
  44. package/src/index.ts +7 -0
  45. package/src/settings/index.ts +5 -0
  46. package/src/settings/settings.ts +478 -0
  47. package/src/web/index.ts +15 -0
  48. package/src/web/stt/speech-recognition.ts +583 -0
  49. package/src/web/tts/phonon.ts +386 -0
  50. package/src/web/tts/player.ts +271 -0
  51. package/src/web/tts/system-voices.ts +401 -0
  52. package/src/web/turns.ts +224 -0
@@ -0,0 +1,150 @@
1
+ // src/contract/contract.ts
2
+ var VOICE_CONTRACT2 = { major: 1, minor: 0 };
3
+ function isCompatibleContract2(candidate, supported = VOICE_CONTRACT2) {
4
+ return candidate.major === supported.major;
5
+ }
6
+ var VOICE_CAPABILITY_BITS2 = [
7
+ "streamingPartials",
8
+ "trueCancellation",
9
+ "modelInstallation",
10
+ "localeSelection",
11
+ "voiceSelection",
12
+ "utteranceQueueing",
13
+ "wordBoundaryPause"
14
+ ];
15
+ function capabilitiesToMask2(capabilities) {
16
+ let mask = 0;
17
+ VOICE_CAPABILITY_BITS2.forEach((name, bit) => {
18
+ if (capabilities[name] === true)
19
+ mask |= 1 << bit;
20
+ });
21
+ return mask;
22
+ }
23
+ function capabilitiesFromMask2(mask) {
24
+ const value = Number.isInteger(mask) && mask > 0 ? mask : 0;
25
+ const capabilities = {};
26
+ VOICE_CAPABILITY_BITS2.forEach((name, bit) => {
27
+ capabilities[name] = (value & 1 << bit) !== 0;
28
+ });
29
+ return capabilities;
30
+ }
31
+ var AVAILABLE2 = { status: "available" };
32
+ function unavailable2(reason, message, remedy) {
33
+ return { status: "unavailable", unavailable: remedy ? { reason, message, remedy } : { reason, message } };
34
+ }
35
+ function isAvailable2(availability) {
36
+ return availability.status === "available";
37
+ }
38
+ function requiresModelInstallation2(route) {
39
+ const reason = route.availability.status === "unavailable" ? route.availability.unavailable.reason : undefined;
40
+ return reason === "modelNotInstalled" || reason === "modelDownloadDisabled";
41
+ }
42
+ var ACTIONABILITY = {
43
+ modelNotInstalled: 100,
44
+ modelDownloadDisabled: 95,
45
+ unsupportedLocale: 90,
46
+ unsupportedOperatingSystem: 80,
47
+ unsupportedDevice: 70,
48
+ permissionDenied: 60,
49
+ licenseNotAccepted: 50,
50
+ contractIncompatible: 40,
51
+ engineFailed: 30,
52
+ networkRequired: 20,
53
+ providerNotRegistered: 10,
54
+ unsupportedPlatform: 0
55
+ };
56
+ var WEB_ROUTING_POLICY2 = {
57
+ chains: {
58
+ speechToText: ["web.speech-recognition-local"],
59
+ textToSpeech: ["web.phonon", "web.system-voices"]
60
+ },
61
+ allowsOptInModelInstallation: false
62
+ };
63
+ async function route2(request) {
64
+ const policy = request.policy ?? WEB_ROUTING_POLICY2;
65
+ const override = policy.overrides?.[request.kind];
66
+ const configured = override ? [override] : policy.chains[request.kind];
67
+ if (configured === undefined) {
68
+ return {
69
+ kind: request.kind,
70
+ locale: request.locale,
71
+ route: null,
72
+ candidates: [],
73
+ missing: [],
74
+ availability: unavailable2("unsupportedPlatform", `no ${request.kind} provider is defined for web`, {
75
+ kind: "chooseAnotherProvider",
76
+ detail: "run on a platform the Voice SDK has a provider for"
77
+ })
78
+ };
79
+ }
80
+ const chain = configured;
81
+ const byId = new Map(request.providers.map((provider) => [provider.descriptor.id, provider]));
82
+ const candidates = [];
83
+ const missing = [];
84
+ for (const id of chain) {
85
+ const provider = byId.get(id);
86
+ if (!provider) {
87
+ missing.push(id);
88
+ continue;
89
+ }
90
+ candidates.push({
91
+ kind: request.kind,
92
+ locale: request.locale,
93
+ descriptor: provider.descriptor,
94
+ availability: await evaluate(provider, request.locale, policy)
95
+ });
96
+ }
97
+ const selection = candidates.find((candidate) => isAvailable2(candidate.availability) || policy.allowsOptInModelInstallation && requiresModelInstallation2(candidate));
98
+ const availability = selection ? selection.availability : mostActionable(candidates) ?? unavailable2("providerNotRegistered", `no ${request.kind} provider from the web chain is registered in this build: ${chain.join(", ")}`, { kind: "chooseAnotherProvider", detail: "install a build that includes the provider" });
99
+ return {
100
+ kind: request.kind,
101
+ locale: request.locale,
102
+ route: selection ?? null,
103
+ candidates,
104
+ missing,
105
+ availability
106
+ };
107
+ }
108
+ async function evaluate(provider, locale, policy) {
109
+ const descriptor = provider.descriptor;
110
+ if (descriptor.execution === "network") {
111
+ return unavailable2("networkRequired", `${descriptor.displayName} requires a network path; the Voice SDK is offline-only`);
112
+ }
113
+ if (!isCompatibleContract2(descriptor.contract)) {
114
+ return unavailable2("contractIncompatible", `${descriptor.displayName} speaks contract ${descriptor.contract.major}.${descriptor.contract.minor}; this SDK speaks ${VOICE_CONTRACT2.major}.${VOICE_CONTRACT2.minor}`, { kind: "chooseAnotherProvider", detail: "update the provider or the SDK" });
115
+ }
116
+ let reported;
117
+ try {
118
+ reported = await provider.availability(locale);
119
+ } catch (error) {
120
+ return unavailable2("engineFailed", `${descriptor.displayName} failed while being probed: ${error instanceof Error ? error.message : String(error)}`);
121
+ }
122
+ if (reported.status === "unavailable" && reported.unavailable.reason === "modelNotInstalled" && !policy.allowsOptInModelInstallation) {
123
+ return unavailable2("modelDownloadDisabled", reported.unavailable.message, {
124
+ kind: "installModel",
125
+ detail: "Download the language in Voice settings."
126
+ });
127
+ }
128
+ return reported;
129
+ }
130
+ function mostActionable(candidates) {
131
+ let best;
132
+ for (const candidate of candidates) {
133
+ if (best === undefined) {
134
+ best = candidate;
135
+ continue;
136
+ }
137
+ const current = actionability(candidate.availability);
138
+ const incumbent = actionability(best.availability);
139
+ if (current > incumbent)
140
+ best = candidate;
141
+ }
142
+ return best?.availability;
143
+ }
144
+ function actionability(availability) {
145
+ if (availability.status === "available")
146
+ return Number.MAX_SAFE_INTEGER;
147
+ return ACTIONABILITY[availability.unavailable.reason] ?? -1;
148
+ }
149
+
150
+ export { VOICE_CONTRACT2, isCompatibleContract2, VOICE_CAPABILITY_BITS2, capabilitiesToMask2, capabilitiesFromMask2, AVAILABLE2, unavailable2, isAvailable2, requiresModelInstallation2, WEB_ROUTING_POLICY2, route2 };
@@ -0,0 +1,290 @@
1
+ import {
2
+ WIRE_VERSION2,
3
+ CONTRACT_MAJOR2,
4
+ parseWireLine2
5
+ } from "./index-rehs788p.js";
6
+
7
+ // src/desktop/helper-lock.ts
8
+ import { createHash } from "node:crypto";
9
+ import { spawnSync } from "node:child_process";
10
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync, chmodSync, statSync } from "node:fs";
11
+ import { dirname, join, resolve } from "node:path";
12
+ import { tmpdir } from "node:os";
13
+ var HELPER_LOCK_SCHEMA2 = 1;
14
+ var HELPER_NAMES2 = ["adea-voice-helper", "adea-transcribe-helper", "adea-tts-helper"];
15
+ var HELPER_TARGETS2 = ["macos-arm64", "macos-x64", "linux-x64", "linux-arm64", "windows-x64"];
16
+ var MAX_HELPER_ARCHIVE_BYTES2 = 256 * 1024 * 1024;
17
+ var STAGED_RECORD_FILE2 = "voice-helpers.json";
18
+ var SHA256 = /^[0-9a-f]{64}$/;
19
+ var SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
20
+ var FILE_NAME = /^[A-Za-z0-9._-]+\.tar\.gz$/;
21
+
22
+ class HelperLockError2 extends Error {
23
+ constructor(message) {
24
+ super(message);
25
+ this.name = "HelperLockError";
26
+ }
27
+ }
28
+ function validateHelperLock2(value) {
29
+ const fail = (message) => {
30
+ throw new HelperLockError2(`voice helper lock: ${message}`);
31
+ };
32
+ if (value === null || typeof value !== "object" || Array.isArray(value))
33
+ fail("must be a JSON object");
34
+ const lock = value;
35
+ if (lock.schema !== HELPER_LOCK_SCHEMA2)
36
+ fail(`schema must be ${HELPER_LOCK_SCHEMA2}`);
37
+ if (typeof lock.version !== "string" || !SEMVER.test(lock.version))
38
+ fail("version must be a semver");
39
+ if (typeof lock.base !== "string" || !/^https:\/\/[^\s]+\/$/.test(lock.base))
40
+ fail("base must be an https URL ending in /");
41
+ if (lock.helpers === null || typeof lock.helpers !== "object")
42
+ fail("helpers must be an object");
43
+ for (const [name, targets] of Object.entries(lock.helpers)) {
44
+ if (!HELPER_NAMES2.includes(name))
45
+ fail(`unknown helper ${name}`);
46
+ if (targets === null || typeof targets !== "object")
47
+ fail(`${name} must map targets to pins`);
48
+ for (const [target, pin] of Object.entries(targets)) {
49
+ if (!HELPER_TARGETS2.includes(target))
50
+ fail(`${name}: unknown target ${target}`);
51
+ const entry = pin;
52
+ if (typeof entry?.file !== "string" || !FILE_NAME.test(entry.file))
53
+ fail(`${name}/${target}: file must be a .tar.gz name`);
54
+ if (typeof entry.sha256 !== "string" || !SHA256.test(entry.sha256))
55
+ fail(`${name}/${target}: sha256 must be 64 hex`);
56
+ if (typeof entry.executableSha256 !== "string" || !SHA256.test(entry.executableSha256)) {
57
+ fail(`${name}/${target}: executableSha256 must be 64 hex`);
58
+ }
59
+ if (entry.bytes !== undefined && (typeof entry.bytes !== "number" || entry.bytes <= 0 || entry.bytes > MAX_HELPER_ARCHIVE_BYTES2)) {
60
+ fail(`${name}/${target}: bytes out of range`);
61
+ }
62
+ if (!entry.file.includes(lock.version))
63
+ fail(`${name}/${target}: file does not carry version ${String(lock.version)}`);
64
+ }
65
+ }
66
+ return value;
67
+ }
68
+ function readHelperLock2(path) {
69
+ let text;
70
+ try {
71
+ text = readFileSync(path, "utf8");
72
+ } catch (error) {
73
+ throw new HelperLockError2(`voice helper lock: cannot read ${path}: ${String(error)}`);
74
+ }
75
+ let parsed;
76
+ try {
77
+ parsed = JSON.parse(text);
78
+ } catch (error) {
79
+ throw new HelperLockError2(`voice helper lock: ${path} is not JSON: ${String(error)}`);
80
+ }
81
+ return validateHelperLock2(parsed);
82
+ }
83
+ function helperPin2(lock, helper, target) {
84
+ return lock.helpers[helper]?.[target];
85
+ }
86
+ function helperArtifactUrl2(lock, helper, target) {
87
+ const pin = helperPin2(lock, helper, target);
88
+ if (!pin)
89
+ throw new HelperLockError2(`voice helper lock pins no ${helper} for ${target}`);
90
+ return `${lock.base}${helper}/${lock.version}/${pin.file}`;
91
+ }
92
+ function currentHelperTarget2(platform = process.platform, arch = process.arch) {
93
+ const os = platform === "darwin" ? "macos" : platform === "win32" ? "windows" : platform === "linux" ? "linux" : undefined;
94
+ const cpu = arch === "arm64" ? "arm64" : arch === "x64" ? "x64" : undefined;
95
+ if (!os || !cpu)
96
+ return;
97
+ const target = `${os}-${cpu}`;
98
+ return HELPER_TARGETS2.includes(target) ? target : undefined;
99
+ }
100
+ function sha256File2(path) {
101
+ return createHash("sha256").update(readFileSync(path)).digest("hex");
102
+ }
103
+ async function stageVoiceHelpers2(options) {
104
+ const log = options.log ?? (() => {
105
+ return;
106
+ });
107
+ const outDir = resolve(options.outDir);
108
+ const handshake = options.handshake ?? options.target === currentHelperTarget2();
109
+ const existing = readStagedRecord2(outDir);
110
+ const record = {
111
+ schema: 1,
112
+ version: options.localDir ? `local+${options.lock.version}` : options.lock.version,
113
+ target: options.target,
114
+ helpers: {}
115
+ };
116
+ mkdirSync(outDir, { recursive: true });
117
+ try {
118
+ for (const helper of options.helpers) {
119
+ const executable = join(outDir, helper);
120
+ if (options.localDir) {
121
+ stageLocal(options.localDir, helper, outDir);
122
+ record.helpers[helper] = { sha256: "local", executableSha256: sha256File2(executable) };
123
+ } else {
124
+ const pin = helperPin2(options.lock, helper, options.target);
125
+ if (!pin)
126
+ throw new HelperLockError2(`voice helper lock pins no ${helper} for ${options.target}`);
127
+ const reuse = existing?.version === options.lock.version && existing.helpers[helper]?.sha256 === pin.sha256 && existsSync(executable) && sha256File2(executable) === pin.executableSha256;
128
+ if (reuse) {
129
+ log(`${helper} ${options.lock.version} already staged`);
130
+ } else {
131
+ const archive = await obtainArchive(options, helper, pin, log);
132
+ try {
133
+ extractArchive(archive, outDir, helper);
134
+ } finally {
135
+ if (!options.cacheDir)
136
+ rmSync(dirname(archive), { recursive: true, force: true });
137
+ }
138
+ const actual = existsSync(executable) ? sha256File2(executable) : "missing";
139
+ if (actual !== pin.executableSha256) {
140
+ throw new HelperLockError2(`${helper}: executable sha256 ${actual} is not the pinned ${pin.executableSha256}`);
141
+ }
142
+ chmodSync(executable, 493);
143
+ log(`staged ${helper} ${options.lock.version} (${options.target})`);
144
+ }
145
+ record.helpers[helper] = { sha256: pin.sha256, executableSha256: pin.executableSha256 };
146
+ }
147
+ if (handshake)
148
+ assertHandshake2(executable);
149
+ }
150
+ } catch (error) {
151
+ rmSync(outDir, { recursive: true, force: true });
152
+ throw error;
153
+ }
154
+ writeFileSync(join(outDir, STAGED_RECORD_FILE2), `${JSON.stringify(record, null, 2)}
155
+ `);
156
+ return record;
157
+ }
158
+ function verifyStagedVoiceHelpers2(options) {
159
+ const dir = resolve(options.dir);
160
+ const record = readStagedRecord2(dir);
161
+ if (!record)
162
+ throw new HelperLockError2(`no ${STAGED_RECORD_FILE2} in ${dir}: the voice helpers were not staged from the lock`);
163
+ if (record.version !== options.lock.version) {
164
+ throw new HelperLockError2(`staged voice helpers are ${record.version}; the lock pins ${options.lock.version}`);
165
+ }
166
+ if (record.target !== options.target)
167
+ throw new HelperLockError2(`staged voice helpers are for ${record.target}, not ${options.target}`);
168
+ for (const helper of options.helpers) {
169
+ const pin = helperPin2(options.lock, helper, options.target);
170
+ if (!pin)
171
+ throw new HelperLockError2(`voice helper lock pins no ${helper} for ${options.target}`);
172
+ const executable = join(dir, helper);
173
+ if (!existsSync(executable))
174
+ throw new HelperLockError2(`${helper} is missing from ${dir}`);
175
+ const actual = sha256File2(executable);
176
+ if (actual !== pin.executableSha256) {
177
+ throw new HelperLockError2(`${helper} in ${dir} has sha256 ${actual}, not the pinned ${pin.executableSha256}`);
178
+ }
179
+ if (options.handshake ?? options.target === currentHelperTarget2())
180
+ assertHandshake2(executable);
181
+ }
182
+ }
183
+ function readStagedRecord2(dir) {
184
+ const path = join(dir, STAGED_RECORD_FILE2);
185
+ if (!existsSync(path))
186
+ return;
187
+ try {
188
+ return JSON.parse(readFileSync(path, "utf8"));
189
+ } catch {
190
+ return;
191
+ }
192
+ }
193
+ function assertHandshake2(executable) {
194
+ const run = spawnSync(executable, ["--version"], { encoding: "utf8", timeout: 1e4 });
195
+ if (run.error || run.status !== 0) {
196
+ throw new HelperLockError2(`${executable} --version failed: ${run.error?.message ?? `exit ${String(run.status)}`}`);
197
+ }
198
+ const version = run.stdout.split(`
199
+ `).map(parseWireLine2).find((event) => event?.event === "version");
200
+ if (!version || version.event !== "version")
201
+ throw new HelperLockError2(`${executable} printed no version handshake`);
202
+ if (version.wire !== WIRE_VERSION2 || version.contractMajor !== CONTRACT_MAJOR2) {
203
+ throw new HelperLockError2(`${executable} speaks wire ${version.wire} / contract ${version.contract}; need wire ${WIRE_VERSION2} / contract ${CONTRACT_MAJOR2}`);
204
+ }
205
+ }
206
+ async function obtainArchive(options, helper, pin, log) {
207
+ const cached = options.cacheDir ? join(options.cacheDir, `${pin.sha256}.tar.gz`) : undefined;
208
+ if (cached && existsSync(cached) && sha256File2(cached) === pin.sha256) {
209
+ log(`${helper}: using cached ${pin.file}`);
210
+ return cached;
211
+ }
212
+ const url = helperArtifactUrl2(options.lock, helper, options.target);
213
+ log(`${helper}: downloading ${url}`);
214
+ const response = await (options.fetch ?? fetch)(url, { redirect: "follow" });
215
+ if (!response.ok || !response.body)
216
+ throw new HelperLockError2(`${helper}: GET ${url} answered ${response.status}`);
217
+ const limit = pin.bytes ?? MAX_HELPER_ARCHIVE_BYTES2;
218
+ const hash = createHash("sha256");
219
+ const chunks = [];
220
+ let total = 0;
221
+ const reader = response.body.getReader();
222
+ for (;; ) {
223
+ const { value, done } = await reader.read();
224
+ if (done)
225
+ break;
226
+ total += value.byteLength;
227
+ if (total > limit) {
228
+ await reader.cancel();
229
+ throw new HelperLockError2(`${helper}: ${url} is larger than the pinned ${limit} bytes`);
230
+ }
231
+ hash.update(value);
232
+ chunks.push(value);
233
+ }
234
+ const digest = hash.digest("hex");
235
+ if (digest !== pin.sha256)
236
+ throw new HelperLockError2(`${helper}: ${pin.file} has sha256 ${digest}, not the pinned ${pin.sha256}`);
237
+ const target = cached ?? join(mkdtempSync(join(tmpdir(), "adea-voice-helper-")), pin.file);
238
+ mkdirSync(dirname(target), { recursive: true });
239
+ const partial = `${target}.partial`;
240
+ writeFileSync(partial, Buffer.concat(chunks));
241
+ renameSync(partial, target);
242
+ return target;
243
+ }
244
+ function extractArchive(archive, outDir, helper) {
245
+ const scratch = mkdtempSync(join(tmpdir(), "adea-voice-extract-"));
246
+ try {
247
+ const listing = spawnSync("tar", ["-tzf", archive], { encoding: "utf8" });
248
+ if (listing.status !== 0)
249
+ throw new HelperLockError2(`${helper}: cannot read ${archive}`);
250
+ for (const entry of listing.stdout.split(`
251
+ `).filter(Boolean)) {
252
+ if (entry.startsWith("/") || entry.split("/").includes(".."))
253
+ throw new HelperLockError2(`${helper}: unsafe archive entry ${entry}`);
254
+ }
255
+ const unpack = spawnSync("tar", ["-xzf", archive, "-C", scratch], { encoding: "utf8" });
256
+ if (unpack.status !== 0)
257
+ throw new HelperLockError2(`${helper}: cannot unpack ${archive}: ${unpack.stderr}`);
258
+ const executable = join(scratch, helper);
259
+ if (!existsSync(executable) || !statSync(executable).isFile())
260
+ throw new HelperLockError2(`${helper}: the archive holds no ${helper}`);
261
+ rmSync(join(outDir, helper), { force: true });
262
+ renameSync(executable, join(outDir, helper));
263
+ const frameworks = join(scratch, "Frameworks");
264
+ if (existsSync(frameworks)) {
265
+ const destination = join(outDir, "Frameworks");
266
+ mkdirSync(destination, { recursive: true });
267
+ for (const entry of spawnSync("ls", ["-1", frameworks], { encoding: "utf8" }).stdout.split(`
268
+ `).filter(Boolean)) {
269
+ rmSync(join(destination, entry), { recursive: true, force: true });
270
+ renameSync(join(frameworks, entry), join(destination, entry));
271
+ }
272
+ }
273
+ } finally {
274
+ rmSync(scratch, { recursive: true, force: true });
275
+ }
276
+ }
277
+ function stageLocal(localDir, helper, outDir) {
278
+ const source = join(resolve(localDir), helper);
279
+ if (!existsSync(source))
280
+ throw new HelperLockError2(`${helper} is not in the local helper directory ${localDir}`);
281
+ const destination = join(outDir, helper);
282
+ rmSync(destination, { force: true });
283
+ writeFileSync(destination, readFileSync(source));
284
+ chmodSync(destination, 493);
285
+ const frameworks = join(resolve(localDir), "Frameworks");
286
+ if (existsSync(frameworks))
287
+ spawnSync("cp", ["-R", frameworks, outDir]);
288
+ }
289
+
290
+ export { HELPER_LOCK_SCHEMA2, HELPER_NAMES2, HELPER_TARGETS2, MAX_HELPER_ARCHIVE_BYTES2, STAGED_RECORD_FILE2, HelperLockError2, validateHelperLock2, readHelperLock2, helperPin2, helperArtifactUrl2, currentHelperTarget2, sha256File2, stageVoiceHelpers2, verifyStagedVoiceHelpers2, readStagedRecord2, assertHandshake2 };
@@ -0,0 +1,10 @@
1
+ // src/contract/session.ts
2
+ var DEFAULT_ENDPOINTING2 = {
3
+ silenceLimitSeconds: 1.6,
4
+ noSpeechTimeoutSeconds: 8,
5
+ maxDurationSeconds: 60,
6
+ finalizationDeadlineSeconds: 3,
7
+ tickIntervalSeconds: 0.25
8
+ };
9
+
10
+ export { DEFAULT_ENDPOINTING2 };
@@ -0,0 +1,42 @@
1
+ import {
2
+ normalizeVoiceErrorCode2
3
+ } from "./index-tvz9s9nz.js";
4
+
5
+ // src/contract/wire.ts
6
+ var WIRE_VERSION2 = 1;
7
+ var CONTRACT_MAJOR2 = 1;
8
+ var MAX_WIRE_LINE_BYTES2 = 1e6;
9
+ function parseWireLine2(line) {
10
+ if (line.length === 0 || line.length > MAX_WIRE_LINE_BYTES2)
11
+ return;
12
+ let value;
13
+ try {
14
+ value = JSON.parse(line);
15
+ } catch {
16
+ return;
17
+ }
18
+ if (value === null || typeof value !== "object" || Array.isArray(value))
19
+ return;
20
+ const object = value;
21
+ if (typeof object.event !== "string")
22
+ return;
23
+ if (object.event === "error" || object.event === "speech-error") {
24
+ return { ...object, code: normalizeVoiceErrorCode2(object.code) };
25
+ }
26
+ return object;
27
+ }
28
+ function encodeWireCommand2(command) {
29
+ return JSON.stringify({ ...command, command: command.cmd });
30
+ }
31
+ function correlationId2(event) {
32
+ if (event.event === "voice")
33
+ return event.requestId;
34
+ if ("id" in event && typeof event.id === "string")
35
+ return event.id;
36
+ return;
37
+ }
38
+ function isCompatibleHandshake2(event) {
39
+ return event.wire === WIRE_VERSION2 && event.contractMajor === CONTRACT_MAJOR2;
40
+ }
41
+
42
+ export { WIRE_VERSION2, CONTRACT_MAJOR2, MAX_WIRE_LINE_BYTES2, parseWireLine2, encodeWireCommand2, correlationId2, isCompatibleHandshake2 };