@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.
Files changed (45) hide show
  1. package/README.md +86 -1
  2. package/dist/cli/helpers-cli.js +17 -2
  3. package/dist/contract/contract.d.ts +21 -2
  4. package/dist/contract/index.d.ts +1 -0
  5. package/dist/contract/index.js +12 -2
  6. package/dist/contract/session.d.ts +13 -0
  7. package/dist/contract/turns.d.ts +91 -0
  8. package/dist/contract/wire.d.ts +92 -1
  9. package/dist/desktop/conversation.d.ts +86 -0
  10. package/dist/desktop/desktop-voice.d.ts +61 -1
  11. package/dist/desktop/helper-lock.d.ts +45 -7
  12. package/dist/desktop/helper-process.d.ts +4 -0
  13. package/dist/desktop/index.d.ts +2 -0
  14. package/dist/desktop/index.js +427 -15
  15. package/dist/desktop/macho-digest.d.ts +9 -0
  16. package/dist/{index-rehs788p.js → index-7n7epq1a.js} +7 -2
  17. package/dist/{index-s270cw30.js → index-a7d617zr.js} +1 -1
  18. package/dist/{index-9kerqn9r.js → index-ght8wwpd.js} +9 -3
  19. package/dist/{index-acm1yvvv.js → index-m4g2tpeq.js} +258 -26
  20. package/dist/index.js +13 -3
  21. package/dist/settings/index.js +1 -1
  22. package/dist/web/index.d.ts +1 -0
  23. package/dist/web/index.js +459 -49
  24. package/dist/web/stt/speech-recognition.d.ts +128 -7
  25. package/dist/web/tts/locale-match.d.ts +40 -0
  26. package/dist/web/tts/system-voices.d.ts +44 -4
  27. package/dist/web/turns.d.ts +15 -25
  28. package/package.json +1 -1
  29. package/src/cli/helpers-cli.ts +18 -2
  30. package/src/contract/contract.ts +32 -4
  31. package/src/contract/index.ts +1 -0
  32. package/src/contract/session.ts +14 -2
  33. package/src/contract/turns.ts +48 -0
  34. package/src/contract/wire.ts +123 -2
  35. package/src/desktop/conversation.ts +347 -0
  36. package/src/desktop/desktop-voice.ts +197 -1
  37. package/src/desktop/helper-lock.ts +195 -20
  38. package/src/desktop/helper-process.ts +17 -10
  39. package/src/desktop/index.ts +2 -0
  40. package/src/desktop/macho-digest.ts +135 -0
  41. package/src/web/index.ts +1 -0
  42. package/src/web/stt/speech-recognition.ts +454 -24
  43. package/src/web/tts/locale-match.ts +131 -0
  44. package/src/web/tts/system-voices.ts +144 -35
  45. package/src/web/turns.ts +22 -11
@@ -29,6 +29,12 @@ function capabilitiesFromMask2(mask) {
29
29
  return capabilities;
30
30
  }
31
31
  var AVAILABLE2 = { status: "available" };
32
+ function availableWithMatch2(match, message) {
33
+ return message === undefined ? { status: "available", match } : { status: "available", match, message };
34
+ }
35
+ function isLanguageOnly2(availability) {
36
+ return availability.status === "available" && availability.match === "language";
37
+ }
32
38
  function unavailable2(reason, message, remedy) {
33
39
  return { status: "unavailable", unavailable: remedy ? { reason, message, remedy } : { reason, message } };
34
40
  }
@@ -71,7 +77,7 @@ async function route2(request) {
71
77
  route: null,
72
78
  candidates: [],
73
79
  missing: [],
74
- availability: unavailable2("unsupportedPlatform", `no ${request.kind} provider is defined for web`, {
80
+ availability: unavailable2("unsupportedPlatform", `no ${request.kind} provider is defined for this platform`, {
75
81
  kind: "chooseAnotherProvider",
76
82
  detail: "run on a platform the Voice SDK has a provider for"
77
83
  })
@@ -95,7 +101,7 @@ async function route2(request) {
95
101
  });
96
102
  }
97
103
  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" });
104
+ const availability = selection ? selection.availability : mostActionable(candidates) ?? unavailable2("providerNotRegistered", `this build registers no ${request.kind} provider from its routing chain (${chain.join(", ")})`, { kind: "chooseAnotherProvider", detail: "install a build that includes the provider" });
99
105
  return {
100
106
  kind: request.kind,
101
107
  locale: request.locale,
@@ -147,4 +153,4 @@ function actionability(availability) {
147
153
  return ACTIONABILITY[availability.unavailable.reason] ?? -1;
148
154
  }
149
155
 
150
- export { VOICE_CONTRACT2, isCompatibleContract2, VOICE_CAPABILITY_BITS2, capabilitiesToMask2, capabilitiesFromMask2, AVAILABLE2, unavailable2, isAvailable2, requiresModelInstallation2, WEB_ROUTING_POLICY2, route2 };
156
+ export { VOICE_CONTRACT2, isCompatibleContract2, VOICE_CAPABILITY_BITS2, capabilitiesToMask2, capabilitiesFromMask2, AVAILABLE2, availableWithMatch2, isLanguageOnly2, unavailable2, isAvailable2, requiresModelInstallation2, WEB_ROUTING_POLICY2, route2 };
@@ -2,14 +2,149 @@ import {
2
2
  WIRE_VERSION2,
3
3
  CONTRACT_MAJOR2,
4
4
  parseWireLine2
5
- } from "./index-rehs788p.js";
5
+ } from "./index-7n7epq1a.js";
6
6
 
7
7
  // src/desktop/helper-lock.ts
8
- import { createHash } from "node:crypto";
8
+ import { createHash as createHash2 } from "node:crypto";
9
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";
10
+ import {
11
+ chmodSync,
12
+ existsSync,
13
+ lstatSync,
14
+ mkdirSync,
15
+ mkdtempSync,
16
+ readdirSync,
17
+ readFileSync as readFileSync2,
18
+ renameSync,
19
+ rmSync,
20
+ statSync,
21
+ writeFileSync
22
+ } from "node:fs";
23
+ import { dirname, join, relative, resolve, sep } from "node:path";
12
24
  import { tmpdir } from "node:os";
25
+
26
+ // src/desktop/macho-digest.ts
27
+ import { createHash } from "node:crypto";
28
+ import { readFileSync } from "node:fs";
29
+ var MH_MAGIC_64 = 4277009103;
30
+ var FAT_MAGIC = 3405691582;
31
+ var FAT_MAGIC_64 = 3405691583;
32
+ var LC_SEGMENT_64 = 25;
33
+ var LC_CODE_SIGNATURE = 29;
34
+ var HEADER_SIZE = 32;
35
+ var SIGNATURE_COMMAND_SIZE = 16;
36
+ var MAX_FAT_ARCHS = 16;
37
+ function isMachO2(bytes) {
38
+ if (bytes.byteLength < 8)
39
+ return false;
40
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
41
+ const little = view.getUint32(0, true);
42
+ if (little === MH_MAGIC_64 || little === 4277009102)
43
+ return true;
44
+ const big = view.getUint32(0, false);
45
+ return (big === FAT_MAGIC || big === FAT_MAGIC_64) && view.getUint32(4, false) > 0 && view.getUint32(4, false) <= MAX_FAT_ARCHS;
46
+ }
47
+ function machoCodeDigest2(bytes) {
48
+ if (bytes.byteLength < 8)
49
+ return;
50
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
51
+ const magic = view.getUint32(0, false);
52
+ if (magic === FAT_MAGIC || magic === FAT_MAGIC_64)
53
+ return fatDigest(bytes, view, magic === FAT_MAGIC_64);
54
+ return thinDigest(bytes);
55
+ }
56
+ function machoCodeDigestFile2(path) {
57
+ return machoCodeDigest2(new Uint8Array(readFileSync(path)));
58
+ }
59
+ function fatDigest(bytes, view, wide) {
60
+ const count = view.getUint32(4, false);
61
+ if (count === 0 || count > MAX_FAT_ARCHS)
62
+ return;
63
+ const entrySize = wide ? 32 : 20;
64
+ if (8 + count * entrySize > bytes.byteLength)
65
+ return;
66
+ const lines = [];
67
+ for (let index = 0;index < count; index += 1) {
68
+ const at = 8 + index * entrySize;
69
+ const cpuType = view.getUint32(at, false);
70
+ const cpuSubtype = view.getUint32(at + 4, false);
71
+ const offset = wide ? Number(view.getBigUint64(at + 8, false)) : view.getUint32(at + 8, false);
72
+ const size = wide ? Number(view.getBigUint64(at + 16, false)) : view.getUint32(at + 12, false);
73
+ if (offset + size > bytes.byteLength || size < HEADER_SIZE)
74
+ return;
75
+ const slice = thinDigest(bytes.subarray(offset, offset + size));
76
+ if (!slice)
77
+ return;
78
+ lines.push(`${cpuType}:${cpuSubtype}:${slice}
79
+ `);
80
+ }
81
+ lines.sort();
82
+ return createHash("sha256").update(`fat
83
+ ${lines.join("")}`).digest("hex");
84
+ }
85
+ function thinDigest(bytes) {
86
+ if (bytes.byteLength < HEADER_SIZE)
87
+ return;
88
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
89
+ if (view.getUint32(0, true) !== MH_MAGIC_64)
90
+ return;
91
+ const commandCount = view.getUint32(16, true);
92
+ const commandsSize = view.getUint32(20, true);
93
+ const commandsEnd = HEADER_SIZE + commandsSize;
94
+ if (commandsEnd > bytes.byteLength)
95
+ return;
96
+ let signature;
97
+ const linkedit = [];
98
+ let offset = HEADER_SIZE;
99
+ for (let index = 0;index < commandCount; index += 1) {
100
+ if (offset + 8 > commandsEnd)
101
+ return;
102
+ const command = view.getUint32(offset, true);
103
+ const size = view.getUint32(offset + 4, true);
104
+ if (size < 8 || offset + size > commandsEnd)
105
+ return;
106
+ if (command === LC_CODE_SIGNATURE) {
107
+ if (signature || size !== SIGNATURE_COMMAND_SIZE)
108
+ return;
109
+ signature = { offset, dataOffset: view.getUint32(offset + 8, true) };
110
+ } else if (command === LC_SEGMENT_64 && size >= 72 && segmentName(bytes, offset + 8) === "__LINKEDIT") {
111
+ linkedit.push(offset);
112
+ }
113
+ offset += size;
114
+ }
115
+ if (offset !== commandsEnd)
116
+ return;
117
+ const end = signature ? signature.dataOffset : bytes.byteLength;
118
+ if (end > bytes.byteLength || end < commandsEnd)
119
+ return;
120
+ const code = Buffer.from(bytes.subarray(0, end));
121
+ for (const segment of linkedit) {
122
+ code.fill(0, segment + 32, segment + 40);
123
+ code.fill(0, segment + 48, segment + 56);
124
+ }
125
+ if (signature) {
126
+ code.copy(code, signature.offset, signature.offset + SIGNATURE_COMMAND_SIZE, commandsEnd);
127
+ code.fill(0, commandsEnd - SIGNATURE_COMMAND_SIZE, commandsEnd);
128
+ code.writeUInt32LE(commandCount - 1, 16);
129
+ code.writeUInt32LE(commandsSize - SIGNATURE_COMMAND_SIZE, 20);
130
+ }
131
+ let length = code.length;
132
+ while (length > 0 && code[length - 1] === 0)
133
+ length -= 1;
134
+ return createHash("sha256").update(code.subarray(0, length)).digest("hex");
135
+ }
136
+ function segmentName(bytes, at) {
137
+ let name = "";
138
+ for (let index = 0;index < 16; index += 1) {
139
+ const byte = bytes[at + index];
140
+ if (byte === 0)
141
+ break;
142
+ name += String.fromCharCode(byte);
143
+ }
144
+ return name;
145
+ }
146
+
147
+ // src/desktop/helper-lock.ts
13
148
  var HELPER_LOCK_SCHEMA2 = 1;
14
149
  var HELPER_NAMES2 = ["adea-voice-helper", "adea-transcribe-helper", "adea-tts-helper"];
15
150
  var HELPER_TARGETS2 = ["macos-arm64", "macos-x64", "linux-x64", "linux-arm64", "windows-x64"];
@@ -56,6 +191,9 @@ function validateHelperLock2(value) {
56
191
  if (typeof entry.executableSha256 !== "string" || !SHA256.test(entry.executableSha256)) {
57
192
  fail(`${name}/${target}: executableSha256 must be 64 hex`);
58
193
  }
194
+ if (entry.codeSha256 !== undefined && (typeof entry.codeSha256 !== "string" || !SHA256.test(entry.codeSha256))) {
195
+ fail(`${name}/${target}: codeSha256 must be 64 hex`);
196
+ }
59
197
  if (entry.bytes !== undefined && (typeof entry.bytes !== "number" || entry.bytes <= 0 || entry.bytes > MAX_HELPER_ARCHIVE_BYTES2)) {
60
198
  fail(`${name}/${target}: bytes out of range`);
61
199
  }
@@ -68,7 +206,7 @@ function validateHelperLock2(value) {
68
206
  function readHelperLock2(path) {
69
207
  let text;
70
208
  try {
71
- text = readFileSync(path, "utf8");
209
+ text = readFileSync2(path, "utf8");
72
210
  } catch (error) {
73
211
  throw new HelperLockError2(`voice helper lock: cannot read ${path}: ${String(error)}`);
74
212
  }
@@ -98,7 +236,7 @@ function currentHelperTarget2(platform = process.platform, arch = process.arch)
98
236
  return HELPER_TARGETS2.includes(target) ? target : undefined;
99
237
  }
100
238
  function sha256File2(path) {
101
- return createHash("sha256").update(readFileSync(path)).digest("hex");
239
+ return createHash2("sha256").update(readFileSync2(path)).digest("hex");
102
240
  }
103
241
  async function stageVoiceHelpers2(options) {
104
242
  const log = options.log ?? (() => {
@@ -107,19 +245,15 @@ async function stageVoiceHelpers2(options) {
107
245
  const outDir = resolve(options.outDir);
108
246
  const handshake = options.handshake ?? options.target === currentHelperTarget2();
109
247
  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
- };
248
+ const helpers = {};
249
+ const version = options.localDir ? `local+${options.lock.version}` : options.lock.version;
116
250
  mkdirSync(outDir, { recursive: true });
117
251
  try {
118
252
  for (const helper of options.helpers) {
119
253
  const executable = join(outDir, helper);
120
254
  if (options.localDir) {
121
255
  stageLocal(options.localDir, helper, outDir);
122
- record.helpers[helper] = { sha256: "local", executableSha256: sha256File2(executable) };
256
+ helpers[helper] = { sha256: "local", executableSha256: sha256File2(executable), ...codeDigestEntry(executable) };
123
257
  } else {
124
258
  const pin = helperPin2(options.lock, helper, options.target);
125
259
  if (!pin)
@@ -142,15 +276,26 @@ async function stageVoiceHelpers2(options) {
142
276
  chmodSync(executable, 493);
143
277
  log(`staged ${helper} ${options.lock.version} (${options.target})`);
144
278
  }
145
- record.helpers[helper] = { sha256: pin.sha256, executableSha256: pin.executableSha256 };
279
+ const code = codeDigestEntry(executable);
280
+ if (pin.codeSha256 && code.codeSha256 !== pin.codeSha256) {
281
+ throw new HelperLockError2(`${helper}: code digest ${code.codeSha256 ?? "unavailable"} is not the pinned ${pin.codeSha256}`);
282
+ }
283
+ helpers[helper] = { sha256: pin.sha256, executableSha256: pin.executableSha256, ...code };
146
284
  }
147
285
  if (handshake)
148
- assertHandshake2(executable);
286
+ assertHandshake2(executable, options.localDir ? {} : { release: options.lock.version });
149
287
  }
150
288
  } catch (error) {
151
289
  rmSync(outDir, { recursive: true, force: true });
152
290
  throw error;
153
291
  }
292
+ const record = {
293
+ schema: 1,
294
+ version,
295
+ target: options.target,
296
+ helpers,
297
+ files: supportFileDigests(outDir, Object.keys(helpers))
298
+ };
154
299
  writeFileSync(join(outDir, STAGED_RECORD_FILE2), `${JSON.stringify(record, null, 2)}
155
300
  `);
156
301
  return record;
@@ -165,19 +310,37 @@ function verifyStagedVoiceHelpers2(options) {
165
310
  }
166
311
  if (record.target !== options.target)
167
312
  throw new HelperLockError2(`staged voice helpers are for ${record.target}, not ${options.target}`);
313
+ const codesign = options.codesign ?? (process.platform === "darwin" && options.target.startsWith("macos-"));
168
314
  for (const helper of options.helpers) {
169
315
  const pin = helperPin2(options.lock, helper, options.target);
170
316
  if (!pin)
171
317
  throw new HelperLockError2(`voice helper lock pins no ${helper} for ${options.target}`);
172
318
  const executable = join(dir, helper);
173
- if (!existsSync(executable))
319
+ if (!existsSync(executable) || !lstatSync(executable).isFile())
174
320
  throw new HelperLockError2(`${helper} is missing from ${dir}`);
321
+ const staged = record.helpers[helper];
322
+ if (staged && (staged.sha256 !== pin.sha256 || staged.executableSha256 !== pin.executableSha256)) {
323
+ throw new HelperLockError2(`${helper} in ${dir} was staged from ${staged.sha256}, not the pinned ${pin.sha256}`);
324
+ }
175
325
  const actual = sha256File2(executable);
176
326
  if (actual !== pin.executableSha256) {
177
- throw new HelperLockError2(`${helper} in ${dir} has sha256 ${actual}, not the pinned ${pin.executableSha256}`);
327
+ const expected = pin.codeSha256 ?? staged?.codeSha256;
328
+ if (!expected) {
329
+ throw new HelperLockError2(`${helper} in ${dir} has sha256 ${actual}, not the pinned ${pin.executableSha256}, and neither the lock nor ${STAGED_RECORD_FILE2} records a code digest to compare a re-signed copy with (stage it with @adea-ai/voice 0.2.1 or later)`);
330
+ }
331
+ const code = machoCodeDigest2(new Uint8Array(readFileSync2(executable)));
332
+ if (code !== expected) {
333
+ throw new HelperLockError2(`${helper} in ${dir} has code digest ${code ?? "unavailable"}, not the pinned ${expected}`);
334
+ }
335
+ if (codesign)
336
+ assertSigned(executable);
337
+ }
338
+ }
339
+ verifySupportFiles(dir, record);
340
+ if (options.handshake ?? options.target === currentHelperTarget2()) {
341
+ for (const helper of options.helpers) {
342
+ assertHandshake2(join(dir, helper), { release: options.lock.version, timeoutMs: options.handshakeTimeoutMs });
178
343
  }
179
- if (options.handshake ?? options.target === currentHelperTarget2())
180
- assertHandshake2(executable);
181
344
  }
182
345
  }
183
346
  function readStagedRecord2(dir) {
@@ -185,15 +348,19 @@ function readStagedRecord2(dir) {
185
348
  if (!existsSync(path))
186
349
  return;
187
350
  try {
188
- return JSON.parse(readFileSync(path, "utf8"));
351
+ return JSON.parse(readFileSync2(path, "utf8"));
189
352
  } catch {
190
353
  return;
191
354
  }
192
355
  }
193
- function assertHandshake2(executable) {
194
- const run = spawnSync(executable, ["--version"], { encoding: "utf8", timeout: 1e4 });
356
+ function assertHandshake2(executable, expect = {}) {
357
+ const timeoutMs = expect.timeoutMs ?? 1e4;
358
+ const run = spawnSync(executable, ["--version"], { encoding: "utf8", timeout: timeoutMs, killSignal: "SIGKILL" });
195
359
  if (run.error || run.status !== 0) {
196
- throw new HelperLockError2(`${executable} --version failed: ${run.error?.message ?? `exit ${String(run.status)}`}`);
360
+ const reason = run.error ? run.error.code === "ETIMEDOUT" ? `did not answer within ${timeoutMs} ms` : run.error.message : run.signal ? `was killed by ${run.signal}` : `exited ${String(run.status)}`;
361
+ const detail = (run.stderr ?? "").trim().split(`
362
+ `)[0]?.slice(0, 300);
363
+ throw new HelperLockError2(`${executable} --version failed: ${reason}${detail ? ` (${detail})` : ""}`);
197
364
  }
198
365
  const version = run.stdout.split(`
199
366
  `).map(parseWireLine2).find((event) => event?.event === "version");
@@ -202,6 +369,71 @@ function assertHandshake2(executable) {
202
369
  if (version.wire !== WIRE_VERSION2 || version.contractMajor !== CONTRACT_MAJOR2) {
203
370
  throw new HelperLockError2(`${executable} speaks wire ${version.wire} / contract ${version.contract}; need wire ${WIRE_VERSION2} / contract ${CONTRACT_MAJOR2}`);
204
371
  }
372
+ if (expect.release !== undefined && version.release !== expect.release) {
373
+ throw new HelperLockError2(`${executable} reports release ${version.release ?? "(none)"}; the lock pins ${expect.release}`);
374
+ }
375
+ }
376
+ function codeDigestEntry(executable) {
377
+ const digest = machoCodeDigest2(new Uint8Array(readFileSync2(executable)));
378
+ return digest ? { codeSha256: digest } : {};
379
+ }
380
+ function assertSigned(path) {
381
+ const run = spawnSync("codesign", ["--verify", "--strict", path], { encoding: "utf8", timeout: 30000 });
382
+ if (run.error || run.status !== 0) {
383
+ throw new HelperLockError2(`${path} is not validly signed: ${(run.stderr || run.error?.message || `exit ${String(run.status)}`).trim()}`);
384
+ }
385
+ }
386
+ function walk(dir, root = dir) {
387
+ const entries = [];
388
+ for (const name of readdirSync(dir).sort()) {
389
+ const path = join(dir, name);
390
+ const stat = lstatSync(path);
391
+ entries.push([relative(root, path).split(sep).join("/"), stat]);
392
+ if (stat.isDirectory())
393
+ entries.push(...walk(path, root));
394
+ }
395
+ return entries;
396
+ }
397
+ function isSignatureFile(path) {
398
+ return path.split("/").includes("_CodeSignature");
399
+ }
400
+ function supportFileDigests(dir, helpers) {
401
+ const files = {};
402
+ for (const [path, stat] of walk(dir)) {
403
+ if (!stat.isFile() || helpers.includes(path) || path === STAGED_RECORD_FILE2 || isSignatureFile(path))
404
+ continue;
405
+ files[path] = fileDigest(join(dir, path));
406
+ }
407
+ return files;
408
+ }
409
+ function fileDigest(path) {
410
+ const bytes = new Uint8Array(readFileSync2(path));
411
+ if (isMachO2(bytes)) {
412
+ const code = machoCodeDigest2(bytes);
413
+ if (code)
414
+ return code;
415
+ }
416
+ return createHash2("sha256").update(bytes).digest("hex");
417
+ }
418
+ function verifySupportFiles(dir, record) {
419
+ for (const [path, expected] of Object.entries(record.files ?? {})) {
420
+ const absolute = join(dir, path);
421
+ if (!existsSync(absolute))
422
+ throw new HelperLockError2(`${path} is missing from ${dir}`);
423
+ const stat = lstatSync(absolute);
424
+ if (!stat.isFile())
425
+ throw new HelperLockError2(`${path} in ${dir} is not a regular file`);
426
+ const actual = fileDigest(absolute);
427
+ if (actual !== expected)
428
+ throw new HelperLockError2(`${path} in ${dir} has digest ${actual}, not the staged ${expected}`);
429
+ }
430
+ for (const [path, stat] of walk(dir)) {
431
+ if (stat.isSymbolicLink())
432
+ throw new HelperLockError2(`${path} in ${dir} is a symlink; packaged voice helpers must not contain symlinks`);
433
+ if (stat.isFile() && stat.size === 0 && path.split("/").includes("Frameworks")) {
434
+ throw new HelperLockError2(`${path} in ${dir} is an empty file (a flattened symlink?)`);
435
+ }
436
+ }
205
437
  }
206
438
  async function obtainArchive(options, helper, pin, log) {
207
439
  const cached = options.cacheDir ? join(options.cacheDir, `${pin.sha256}.tar.gz`) : undefined;
@@ -215,7 +447,7 @@ async function obtainArchive(options, helper, pin, log) {
215
447
  if (!response.ok || !response.body)
216
448
  throw new HelperLockError2(`${helper}: GET ${url} answered ${response.status}`);
217
449
  const limit = pin.bytes ?? MAX_HELPER_ARCHIVE_BYTES2;
218
- const hash = createHash("sha256");
450
+ const hash = createHash2("sha256");
219
451
  const chunks = [];
220
452
  let total = 0;
221
453
  const reader = response.body.getReader();
@@ -280,11 +512,11 @@ function stageLocal(localDir, helper, outDir) {
280
512
  throw new HelperLockError2(`${helper} is not in the local helper directory ${localDir}`);
281
513
  const destination = join(outDir, helper);
282
514
  rmSync(destination, { force: true });
283
- writeFileSync(destination, readFileSync(source));
515
+ writeFileSync(destination, readFileSync2(source));
284
516
  chmodSync(destination, 493);
285
517
  const frameworks = join(resolve(localDir), "Frameworks");
286
518
  if (existsSync(frameworks))
287
519
  spawnSync("cp", ["-R", frameworks, outDir]);
288
520
  }
289
521
 
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 };
522
+ export { isMachO2, machoCodeDigest2, machoCodeDigestFile2, 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 };
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  createVoiceSettingsStore2,
18
18
  withLegacyDictationPreferences2,
19
19
  assertUsableSettings2
20
- } from "./index-s270cw30.js";
20
+ } from "./index-a7d617zr.js";
21
21
  import {
22
22
  VOICE_CONTRACT2,
23
23
  isCompatibleContract2,
@@ -25,21 +25,26 @@ import {
25
25
  capabilitiesToMask2,
26
26
  capabilitiesFromMask2,
27
27
  AVAILABLE2,
28
+ availableWithMatch2,
29
+ isLanguageOnly2,
28
30
  unavailable2,
29
31
  isAvailable2,
30
32
  requiresModelInstallation2,
31
33
  WEB_ROUTING_POLICY2,
32
34
  route2
33
- } from "./index-9kerqn9r.js";
35
+ } from "./index-ght8wwpd.js";
34
36
  import {
35
37
  WIRE_VERSION2,
38
+ TURN_WIRE_MINOR2,
39
+ RELEASE_ASSETS_WIRE_MINOR2,
36
40
  CONTRACT_MAJOR2,
37
41
  MAX_WIRE_LINE_BYTES2,
42
+ isTurnTerminal2,
38
43
  parseWireLine2,
39
44
  encodeWireCommand2,
40
45
  correlationId2,
41
46
  isCompatibleHandshake2
42
- } from "./index-rehs788p.js";
47
+ } from "./index-7n7epq1a.js";
43
48
  import {
44
49
  VOICE_ERROR_CODES2,
45
50
  normalizeVoiceErrorCode2,
@@ -51,7 +56,9 @@ export {
51
56
  DEFAULT_ENDPOINTING2 as DEFAULT_ENDPOINTING,
52
57
  DEFAULT_VOICE_SETTINGS2 as DEFAULT_VOICE_SETTINGS,
53
58
  MAX_WIRE_LINE_BYTES2 as MAX_WIRE_LINE_BYTES,
59
+ RELEASE_ASSETS_WIRE_MINOR2 as RELEASE_ASSETS_WIRE_MINOR,
54
60
  SETTINGS_SCHEMA_VERSION2 as SETTINGS_SCHEMA_VERSION,
61
+ TURN_WIRE_MINOR2 as TURN_WIRE_MINOR,
55
62
  VOICE_CAPABILITY_BITS2 as VOICE_CAPABILITY_BITS,
56
63
  VOICE_CONTRACT2 as VOICE_CONTRACT,
57
64
  VOICE_ERROR_CODES2 as VOICE_ERROR_CODES,
@@ -63,6 +70,7 @@ export {
63
70
  allowsNetworkSpeechToText2 as allowsNetworkSpeechToText,
64
71
  allowsNetworkSynthesis2 as allowsNetworkSynthesis,
65
72
  assertUsableSettings2 as assertUsableSettings,
73
+ availableWithMatch2 as availableWithMatch,
66
74
  capabilitiesFromMask2 as capabilitiesFromMask,
67
75
  capabilitiesToMask2 as capabilitiesToMask,
68
76
  correlationId2 as correlationId,
@@ -71,6 +79,8 @@ export {
71
79
  isAvailable2 as isAvailable,
72
80
  isCompatibleContract2 as isCompatibleContract,
73
81
  isCompatibleHandshake2 as isCompatibleHandshake,
82
+ isLanguageOnly2 as isLanguageOnly,
83
+ isTurnTerminal2 as isTurnTerminal,
74
84
  normalizeVoiceErrorCode2 as normalizeVoiceErrorCode,
75
85
  parseWireLine2 as parseWireLine,
76
86
  readVoiceSettings2 as readVoiceSettings,
@@ -14,7 +14,7 @@ import {
14
14
  createVoiceSettingsStore2,
15
15
  withLegacyDictationPreferences2,
16
16
  assertUsableSettings2
17
- } from "../index-s270cw30.js";
17
+ } from "../index-a7d617zr.js";
18
18
  export {
19
19
  DEFAULT_VOICE_SETTINGS2 as DEFAULT_VOICE_SETTINGS,
20
20
  SETTINGS_SCHEMA_VERSION2 as SETTINGS_SCHEMA_VERSION,
@@ -10,6 +10,7 @@
10
10
  */
11
11
  export * from "./stt/speech-recognition";
12
12
  export * from "./tts/phonon";
13
+ export * from "./tts/locale-match";
13
14
  export * from "./tts/player";
14
15
  export * from "./tts/system-voices";
15
16
  export * from "./turns";