@xrkseek/harness 0.7.6 → 0.7.8

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 (171) hide show
  1. package/node_modules/@xrkseek/a2a/dist/inbound.d.ts.map +1 -1
  2. package/node_modules/@xrkseek/a2a/dist/inbound.js +72 -2
  3. package/node_modules/@xrkseek/a2a/dist/inbound.js.map +1 -1
  4. package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.d.ts.map +1 -1
  5. package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js +2 -0
  6. package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js.map +1 -1
  7. package/node_modules/@xrkseek/exec-voice/README.md +4 -3
  8. package/node_modules/@xrkseek/exec-voice/dist/browser/index.d.ts +1 -0
  9. package/node_modules/@xrkseek/exec-voice/dist/browser/index.d.ts.map +1 -1
  10. package/node_modules/@xrkseek/exec-voice/dist/browser/index.js +1 -0
  11. package/node_modules/@xrkseek/exec-voice/dist/browser/index.js.map +1 -1
  12. package/node_modules/@xrkseek/exec-voice/dist/browser/wav-capture.d.ts +91 -0
  13. package/node_modules/@xrkseek/exec-voice/dist/browser/wav-capture.d.ts.map +1 -0
  14. package/node_modules/@xrkseek/exec-voice/dist/browser/wav-capture.js +269 -0
  15. package/node_modules/@xrkseek/exec-voice/dist/browser/wav-capture.js.map +1 -0
  16. package/node_modules/@xrkseek/exec-voice/dist/download-http.d.ts +46 -0
  17. package/node_modules/@xrkseek/exec-voice/dist/download-http.d.ts.map +1 -0
  18. package/node_modules/@xrkseek/exec-voice/dist/download-http.js +223 -0
  19. package/node_modules/@xrkseek/exec-voice/dist/download-http.js.map +1 -0
  20. package/node_modules/@xrkseek/exec-voice/dist/engine-ids.d.ts +19 -0
  21. package/node_modules/@xrkseek/exec-voice/dist/engine-ids.d.ts.map +1 -0
  22. package/node_modules/@xrkseek/exec-voice/dist/engine-ids.js +36 -0
  23. package/node_modules/@xrkseek/exec-voice/dist/engine-ids.js.map +1 -0
  24. package/node_modules/@xrkseek/exec-voice/dist/engines.d.ts +60 -0
  25. package/node_modules/@xrkseek/exec-voice/dist/engines.d.ts.map +1 -0
  26. package/node_modules/@xrkseek/exec-voice/dist/engines.js +130 -0
  27. package/node_modules/@xrkseek/exec-voice/dist/engines.js.map +1 -0
  28. package/node_modules/@xrkseek/exec-voice/dist/format.d.ts +13 -0
  29. package/node_modules/@xrkseek/exec-voice/dist/format.d.ts.map +1 -1
  30. package/node_modules/@xrkseek/exec-voice/dist/format.js +22 -3
  31. package/node_modules/@xrkseek/exec-voice/dist/format.js.map +1 -1
  32. package/node_modules/@xrkseek/exec-voice/dist/index.d.ts +23 -31
  33. package/node_modules/@xrkseek/exec-voice/dist/index.d.ts.map +1 -1
  34. package/node_modules/@xrkseek/exec-voice/dist/index.js +17 -66
  35. package/node_modules/@xrkseek/exec-voice/dist/index.js.map +1 -1
  36. package/node_modules/@xrkseek/exec-voice/dist/readiness.d.ts +14 -8
  37. package/node_modules/@xrkseek/exec-voice/dist/readiness.d.ts.map +1 -1
  38. package/node_modules/@xrkseek/exec-voice/dist/readiness.js +36 -27
  39. package/node_modules/@xrkseek/exec-voice/dist/readiness.js.map +1 -1
  40. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-assets.d.ts +48 -0
  41. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-assets.d.ts.map +1 -0
  42. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-assets.js +64 -0
  43. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-assets.js.map +1 -0
  44. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-local.d.ts +24 -0
  45. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-local.d.ts.map +1 -1
  46. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-local.js +66 -4
  47. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-local.js.map +1 -1
  48. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.d.ts +78 -0
  49. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.d.ts.map +1 -0
  50. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.js +332 -0
  51. package/node_modules/@xrkseek/exec-voice/dist/sensevoice-runtime.js.map +1 -0
  52. package/node_modules/@xrkseek/exec-voice/dist/system-tts.d.ts +40 -0
  53. package/node_modules/@xrkseek/exec-voice/dist/system-tts.d.ts.map +1 -0
  54. package/node_modules/@xrkseek/exec-voice/dist/system-tts.js +260 -0
  55. package/node_modules/@xrkseek/exec-voice/dist/system-tts.js.map +1 -0
  56. package/node_modules/@xrkseek/exec-voice/dist/tools.d.ts +13 -12
  57. package/node_modules/@xrkseek/exec-voice/dist/tools.d.ts.map +1 -1
  58. package/node_modules/@xrkseek/exec-voice/dist/tools.js +12 -6
  59. package/node_modules/@xrkseek/exec-voice/dist/tools.js.map +1 -1
  60. package/node_modules/@xrkseek/exec-voice/dist/types.d.ts +3 -1
  61. package/node_modules/@xrkseek/exec-voice/dist/types.d.ts.map +1 -1
  62. package/node_modules/@xrkseek/exec-voice/dist/types.js.map +1 -1
  63. package/node_modules/@xrkseek/exec-voice/package.json +39 -31
  64. package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts +4 -3
  65. package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
  66. package/node_modules/@xrkseek/preset-harness/dist/preset.js +31 -18
  67. package/node_modules/@xrkseek/preset-harness/dist/preset.js.map +1 -1
  68. package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
  69. package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
  70. package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
  71. package/node_modules/@xrkseek/protocol/dist/sidebar-previews.d.ts +2 -0
  72. package/node_modules/@xrkseek/protocol/dist/sidebar-previews.d.ts.map +1 -1
  73. package/node_modules/@xrkseek/protocol/dist/sidebar-previews.js.map +1 -1
  74. package/node_modules/@xrkseek/server-face/dist/adapt/subagent-notice.d.ts +21 -2
  75. package/node_modules/@xrkseek/server-face/dist/adapt/subagent-notice.d.ts.map +1 -1
  76. package/node_modules/@xrkseek/server-face/dist/adapt/subagent-notice.js +56 -7
  77. package/node_modules/@xrkseek/server-face/dist/adapt/subagent-notice.js.map +1 -1
  78. package/node_modules/@xrkseek/server-face/dist/agent-roster-store.d.ts.map +1 -1
  79. package/node_modules/@xrkseek/server-face/dist/agent-roster-store.js +26 -3
  80. package/node_modules/@xrkseek/server-face/dist/agent-roster-store.js.map +1 -1
  81. package/node_modules/@xrkseek/server-face/dist/agent-team-roles.d.ts.map +1 -1
  82. package/node_modules/@xrkseek/server-face/dist/agent-team-roles.js +4 -0
  83. package/node_modules/@xrkseek/server-face/dist/agent-team-roles.js.map +1 -1
  84. package/node_modules/@xrkseek/server-face/dist/dispatch.d.ts.map +1 -1
  85. package/node_modules/@xrkseek/server-face/dist/dispatch.js +16 -0
  86. package/node_modules/@xrkseek/server-face/dist/dispatch.js.map +1 -1
  87. package/node_modules/@xrkseek/server-face/dist/handlers/voice.d.ts +30 -0
  88. package/node_modules/@xrkseek/server-face/dist/handlers/voice.d.ts.map +1 -0
  89. package/node_modules/@xrkseek/server-face/dist/handlers/voice.js +195 -0
  90. package/node_modules/@xrkseek/server-face/dist/handlers/voice.js.map +1 -0
  91. package/node_modules/@xrkseek/server-face/dist/model-catalog.d.ts +15 -0
  92. package/node_modules/@xrkseek/server-face/dist/model-catalog.d.ts.map +1 -1
  93. package/node_modules/@xrkseek/server-face/dist/model-catalog.js +44 -10
  94. package/node_modules/@xrkseek/server-face/dist/model-catalog.js.map +1 -1
  95. package/node_modules/@xrkseek/server-face/dist/runtime.d.ts.map +1 -1
  96. package/node_modules/@xrkseek/server-face/dist/runtime.js +7 -2
  97. package/node_modules/@xrkseek/server-face/dist/runtime.js.map +1 -1
  98. package/node_modules/@xrkseek/server-face/dist/select-session-model.d.ts.map +1 -1
  99. package/node_modules/@xrkseek/server-face/dist/select-session-model.js +68 -1
  100. package/node_modules/@xrkseek/server-face/dist/select-session-model.js.map +1 -1
  101. package/node_modules/@xrkseek/server-face/dist/session-posture.js +1 -1
  102. package/node_modules/@xrkseek/server-face/dist/session-posture.js.map +1 -1
  103. package/node_modules/@xrkseek/server-face/dist/session-tool-copy.d.ts +4 -0
  104. package/node_modules/@xrkseek/server-face/dist/session-tool-copy.d.ts.map +1 -1
  105. package/node_modules/@xrkseek/server-face/dist/session-tool-copy.js +16 -0
  106. package/node_modules/@xrkseek/server-face/dist/session-tool-copy.js.map +1 -1
  107. package/node_modules/@xrkseek/server-face/dist/session-tools.d.ts.map +1 -1
  108. package/node_modules/@xrkseek/server-face/dist/session-tools.js +2 -0
  109. package/node_modules/@xrkseek/server-face/dist/session-tools.js.map +1 -1
  110. package/node_modules/@xrkseek/server-face/dist/settings-document.d.ts.map +1 -1
  111. package/node_modules/@xrkseek/server-face/dist/settings-document.js +56 -1
  112. package/node_modules/@xrkseek/server-face/dist/settings-document.js.map +1 -1
  113. package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
  114. package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +42 -12
  115. package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
  116. package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts +43 -0
  117. package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts.map +1 -1
  118. package/node_modules/@xrkseek/server-face/dist/subagent-tools.js +293 -24
  119. package/node_modules/@xrkseek/server-face/dist/subagent-tools.js.map +1 -1
  120. package/node_modules/@xrkseek/server-face/dist/wire/paths.d.ts.map +1 -1
  121. package/node_modules/@xrkseek/server-face/dist/wire/paths.js +6 -0
  122. package/node_modules/@xrkseek/server-face/dist/wire/paths.js.map +1 -1
  123. package/node_modules/@xrkseek/server-face/dist/workspace-orchestrate-tools.d.ts.map +1 -1
  124. package/node_modules/@xrkseek/server-face/dist/workspace-orchestrate-tools.js +4 -1
  125. package/node_modules/@xrkseek/server-face/dist/workspace-orchestrate-tools.js.map +1 -1
  126. package/node_modules/@xrkseek/server-face/package.json +1 -0
  127. package/node_modules/@xrkseek/server-host/dist/a2a-inbound-public.d.ts.map +1 -1
  128. package/node_modules/@xrkseek/server-host/dist/a2a-inbound-public.js +8 -1
  129. package/node_modules/@xrkseek/server-host/dist/a2a-inbound-public.js.map +1 -1
  130. package/node_modules/@xrkseek/server-host/dist/index.d.ts +1 -1
  131. package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
  132. package/node_modules/@xrkseek/server-host/dist/index.js +44 -45
  133. package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
  134. package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.d.ts.map +1 -1
  135. package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js +2 -0
  136. package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js.map +1 -1
  137. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-tool-pre.d.ts.map +1 -1
  138. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-tool-pre.js +5 -2
  139. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-tool-pre.js.map +1 -1
  140. package/node_modules/@xrkseek/server-http/dist/dsh-compat/our-free-model-host.d.ts +15 -0
  141. package/node_modules/@xrkseek/server-http/dist/dsh-compat/our-free-model-host.d.ts.map +1 -1
  142. package/node_modules/@xrkseek/server-http/dist/dsh-compat/our-free-model-host.js +61 -3
  143. package/node_modules/@xrkseek/server-http/dist/dsh-compat/our-free-model-host.js.map +1 -1
  144. package/node_modules/sherpa-onnx-node/README.md +11 -0
  145. package/node_modules/sherpa-onnx-node/addon-static-import.js +76 -0
  146. package/node_modules/sherpa-onnx-node/addon.js +98 -0
  147. package/node_modules/sherpa-onnx-node/audio-tagg.js +45 -0
  148. package/node_modules/sherpa-onnx-node/keyword-spotter.js +68 -0
  149. package/node_modules/sherpa-onnx-node/non-streaming-asr.js +158 -0
  150. package/node_modules/sherpa-onnx-node/non-streaming-speaker-diarization.js +38 -0
  151. package/node_modules/sherpa-onnx-node/non-streaming-speech-denoiser.js +32 -0
  152. package/node_modules/sherpa-onnx-node/non-streaming-tts.js +117 -0
  153. package/node_modules/sherpa-onnx-node/online-speech-denoiser.js +46 -0
  154. package/node_modules/sherpa-onnx-node/package.json +68 -0
  155. package/node_modules/sherpa-onnx-node/punctuation.js +43 -0
  156. package/node_modules/sherpa-onnx-node/resampler.js +80 -0
  157. package/node_modules/sherpa-onnx-node/sherpa-onnx.js +49 -0
  158. package/node_modules/sherpa-onnx-node/speaker-identification.js +152 -0
  159. package/node_modules/sherpa-onnx-node/spoken-language-identification.js +38 -0
  160. package/node_modules/sherpa-onnx-node/streaming-asr.js +181 -0
  161. package/node_modules/sherpa-onnx-node/types.js +833 -0
  162. package/node_modules/sherpa-onnx-node/vad.js +134 -0
  163. package/node_modules/sherpa-onnx-win-x64/README.md +3 -0
  164. package/node_modules/sherpa-onnx-win-x64/index.js +1 -0
  165. package/node_modules/sherpa-onnx-win-x64/onnxruntime.dll +0 -0
  166. package/node_modules/sherpa-onnx-win-x64/onnxruntime_providers_shared.dll +0 -0
  167. package/node_modules/sherpa-onnx-win-x64/package.json +65 -0
  168. package/node_modules/sherpa-onnx-win-x64/sherpa-onnx-c-api.dll +0 -0
  169. package/node_modules/sherpa-onnx-win-x64/sherpa-onnx-cxx-api.dll +0 -0
  170. package/node_modules/sherpa-onnx-win-x64/sherpa-onnx.node +0 -0
  171. package/package.json +5 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wav-capture.js","sourceRoot":"","sources":["../../src/browser/wav-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAA;AAEvC,yCAAyC;AACzC,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAqFjC,SAAS,GAAG;IAC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,KAAiB;IACxC,MAAM,KAAK,GAAG,MAAM,CAAA;IACpB,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;QAC5D,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAA;IAC1E,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAA;AACrB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /** One opened asset: status plus the body, which is null for a non-2xx. */
2
+ export interface DownloadStream {
3
+ readonly status: number;
4
+ readonly body: AsyncIterable<Uint8Array> | null;
5
+ }
6
+ export interface ProxyTarget {
7
+ readonly host: string;
8
+ readonly port: number;
9
+ }
10
+ /** Result of reading the operator's proxy setting. */
11
+ export interface ProxyParseResult {
12
+ /** CONNECT endpoint; present exactly when the text parsed. */
13
+ readonly target?: ProxyTarget;
14
+ /**
15
+ * Why the text cannot be used. Present only for a non-empty setting — an
16
+ * empty one means 「direct」, which is not an error.
17
+ */
18
+ readonly error?: string;
19
+ }
20
+ /**
21
+ * Parse an operator-supplied proxy URL.
22
+ *
23
+ * Accepts `http://127.0.0.1:7897`, the bare `127.0.0.1:7897` form people paste
24
+ * from a Clash panel, and `http:127.0.0.1:7897` — the same address with the
25
+ * `//` dropped, which is what a hurried paste produces. That last form used to
26
+ * build `http://http:127.0.0.1:7897`, throw inside `new URL()`, and come back
27
+ * as `undefined`: the card showed an address while every byte went unproxied,
28
+ * which reads as 「saved but still stuck」.
29
+ *
30
+ * Only `http:` / `https:` are accepted: {@link tunnel} speaks HTTP CONNECT and
31
+ * nothing else, so a `socks5://` value would open a socket that can never
32
+ * carry the tunnel.
33
+ * @param value - Setting text; empty means 「no proxy」.
34
+ * @returns A CONNECT target, or the reason the text is unusable.
35
+ */
36
+ export declare function parseProxy(value: string | undefined): ProxyParseResult;
37
+ /**
38
+ * Open one asset URL, preferring a local proxy and falling back to a direct
39
+ * request when the proxy cannot carry the hop.
40
+ * @param rawUrl - Absolute asset URL.
41
+ * @param signal - Caller cancellation (no header deadline of its own).
42
+ * @param proxyUrl - Operator-configured proxy, if any.
43
+ * @returns Status plus a byte stream.
44
+ */
45
+ export declare function openAssetStream(rawUrl: string, signal: AbortSignal, proxyUrl?: string): Promise<DownloadStream>;
46
+ //# sourceMappingURL=download-http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download-http.d.ts","sourceRoot":"","sources":["../src/download-http.ts"],"names":[],"mappings":"AA6BA,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAKD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,gBAAgB,CAkBtE;AA6ID;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC,CA4BzB"}
@@ -0,0 +1,223 @@
1
+ /**
2
+ * Asset download that survives a filtered network.
3
+ *
4
+ * Two facts measured on the failing box, both of which `fetch` ignores:
5
+ *
6
+ * 1. `huggingface.co` / `hf-mirror.com` answer with a 302 to
7
+ * `cas-bridge.xethub.hf.co`, and that CloudFront host **never completes a
8
+ * TLS handshake from Node** (15 s timeout, then ECONNRESET) while `curl`
9
+ * on the same machine pulls the same URL in 1.5 s. A local proxy fixes it
10
+ * — `curl -x http://127.0.0.1:7897` returns 200 in 3.6 s.
11
+ * 2. Node's `fetch` (undici) picks one A record and gives up; `https.request`
12
+ * honours `autoSelectFamily`, so it already walks to a second address when
13
+ * the first black-holes.
14
+ *
15
+ * So the transport is: an HTTP CONNECT tunnel through the proxy the operator
16
+ * configured, otherwise a name-based `https` request (never a pinned IP —
17
+ * pinning an address bypasses proxy rules that match on hostname, which is
18
+ * what made the first attempt fail). The proxy is a user setting, not a guess:
19
+ * see `parseProxy`.
20
+ *
21
+ * Deliberately not here: SOCKS, HTTP/2, keep-alive pooling. Three files, one
22
+ * press, one connection each (YAGNI).
23
+ */
24
+ import { once } from "node:events";
25
+ import https from "node:https";
26
+ import net from "node:net";
27
+ import tls from "node:tls";
28
+ const REDIRECT_LIMIT = 5;
29
+ const CONNECT_TIMEOUT_MS = 8_000;
30
+ /**
31
+ * Parse an operator-supplied proxy URL.
32
+ *
33
+ * Accepts `http://127.0.0.1:7897`, the bare `127.0.0.1:7897` form people paste
34
+ * from a Clash panel, and `http:127.0.0.1:7897` — the same address with the
35
+ * `//` dropped, which is what a hurried paste produces. That last form used to
36
+ * build `http://http:127.0.0.1:7897`, throw inside `new URL()`, and come back
37
+ * as `undefined`: the card showed an address while every byte went unproxied,
38
+ * which reads as 「saved but still stuck」.
39
+ *
40
+ * Only `http:` / `https:` are accepted: {@link tunnel} speaks HTTP CONNECT and
41
+ * nothing else, so a `socks5://` value would open a socket that can never
42
+ * carry the tunnel.
43
+ * @param value - Setting text; empty means 「no proxy」.
44
+ * @returns A CONNECT target, or the reason the text is unusable.
45
+ */
46
+ export function parseProxy(value) {
47
+ if (value === undefined)
48
+ return {};
49
+ const trimmed = value.trim();
50
+ if (trimmed === "")
51
+ return {};
52
+ let url;
53
+ try {
54
+ url = new URL(withProxyScheme(trimmed));
55
+ }
56
+ catch {
57
+ return { error: `not a URL: ${trimmed}` };
58
+ }
59
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
60
+ return {
61
+ error: `only HTTP CONNECT proxies work here (got ${url.protocol.slice(0, -1)}://)`,
62
+ };
63
+ }
64
+ if (url.hostname === "")
65
+ return { error: `no host in ${trimmed}` };
66
+ const port = url.port === "" ? (url.protocol === "https:" ? 443 : 80) : Number(url.port);
67
+ return { target: { host: url.hostname, port } };
68
+ }
69
+ /**
70
+ * Give `new URL` something it accepts.
71
+ * @param raw - Trimmed setting text.
72
+ * @returns The text with a scheme and `//`.
73
+ */
74
+ function withProxyScheme(raw) {
75
+ const missingSlashes = /^([a-z][a-z0-9+.-]*):(?!\/\/)/i.exec(raw);
76
+ if (missingSlashes !== null) {
77
+ return `${missingSlashes[1]}://${raw.slice(missingSlashes[0].length)}`;
78
+ }
79
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(raw))
80
+ return raw;
81
+ return `http://${raw}`;
82
+ }
83
+ /**
84
+ * Open an HTTP CONNECT tunnel and wrap it in TLS for the target host.
85
+ * @param proxy - Local CONNECT proxy.
86
+ * @param hostname - Origin host the tunnel should reach.
87
+ * @param port - Origin port.
88
+ * @param signal - Caller cancellation.
89
+ * @returns A TLS socket already speaking to the origin.
90
+ */
91
+ async function tunnel(proxy, hostname, port, signal) {
92
+ const socket = net.connect({ host: proxy.host, port: proxy.port });
93
+ const onAbort = () => {
94
+ socket.destroy();
95
+ };
96
+ signal.addEventListener("abort", onAbort, { once: true });
97
+ try {
98
+ socket.setTimeout(CONNECT_TIMEOUT_MS, () => socket.destroy(new Error("proxy connect timeout")));
99
+ await once(socket, "connect");
100
+ socket.write(`CONNECT ${hostname}:${port} HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`);
101
+ const [head] = (await once(socket, "data"));
102
+ const statusLine = head.toString("latin1").split("\r\n")[0] ?? "";
103
+ if (!/^HTTP\/1\.[01] 2\d\d/.test(statusLine)) {
104
+ throw new Error(`proxy refused CONNECT: ${statusLine}`);
105
+ }
106
+ socket.setTimeout(0);
107
+ const secured = tls.connect({ socket, servername: hostname });
108
+ await once(secured, "secureConnect");
109
+ return secured;
110
+ }
111
+ finally {
112
+ signal.removeEventListener("abort", onAbort);
113
+ }
114
+ }
115
+ /**
116
+ * Issue one GET over an established socket.
117
+ * @param url - Absolute https URL.
118
+ * @param socket - Connected TLS socket (tunnelled or direct).
119
+ * @param signal - Caller cancellation.
120
+ * @returns The response with headers already parsed.
121
+ */
122
+ function requestOn(url, socket, signal) {
123
+ return new Promise((resolve, reject) => {
124
+ const request = https.request({
125
+ host: url.hostname,
126
+ port: url.port === "" ? 443 : Number(url.port),
127
+ servername: url.hostname,
128
+ path: `${url.pathname}${url.search}`,
129
+ method: "GET",
130
+ headers: { host: url.hostname, "accept-encoding": "identity" },
131
+ createConnection: () => socket,
132
+ signal,
133
+ }, resolve);
134
+ request.once("error", reject);
135
+ request.end();
136
+ });
137
+ }
138
+ /**
139
+ * Issue one GET letting Node own the connection (and `autoSelectFamily` own
140
+ * address failover).
141
+ * @param url - Absolute https URL.
142
+ * @param signal - Caller cancellation.
143
+ * @returns The response with headers already parsed.
144
+ */
145
+ function requestDirect(url, signal) {
146
+ return new Promise((resolve, reject) => {
147
+ const request = https.request({
148
+ host: url.hostname,
149
+ port: url.port === "" ? 443 : Number(url.port),
150
+ servername: url.hostname,
151
+ path: `${url.pathname}${url.search}`,
152
+ method: "GET",
153
+ headers: { host: url.hostname, "accept-encoding": "identity" },
154
+ signal,
155
+ }, resolve);
156
+ request.once("error", reject);
157
+ request.end();
158
+ });
159
+ }
160
+ /**
161
+ * Follow redirects, opening each hop through the same transport.
162
+ * @param rawUrl - Absolute asset URL.
163
+ * @param proxy - Proxy to tunnel through, or undefined for a direct request.
164
+ * @param signal - Caller cancellation.
165
+ * @returns Status plus the body stream; non-2xx is reported, never thrown.
166
+ */
167
+ async function openFollow(rawUrl, proxy, signal) {
168
+ let current = new URL(rawUrl);
169
+ for (let hop = 0; hop <= REDIRECT_LIMIT; hop += 1) {
170
+ const port = current.port === "" ? 443 : Number(current.port);
171
+ const response = proxy === undefined
172
+ ? await requestDirect(current, signal)
173
+ : await requestOn(current, await tunnel(proxy, current.hostname, port, signal), signal);
174
+ const status = response.statusCode ?? 0;
175
+ const location = response.headers.location;
176
+ if (status >= 300 && status < 400 && typeof location === "string") {
177
+ response.resume();
178
+ current = new URL(location, current);
179
+ continue;
180
+ }
181
+ return { status, body: status >= 200 && status < 300 ? response : null };
182
+ }
183
+ return { status: 0, body: null };
184
+ }
185
+ /**
186
+ * Open one asset URL, preferring a local proxy and falling back to a direct
187
+ * request when the proxy cannot carry the hop.
188
+ * @param rawUrl - Absolute asset URL.
189
+ * @param signal - Caller cancellation (no header deadline of its own).
190
+ * @param proxyUrl - Operator-configured proxy, if any.
191
+ * @returns Status plus a byte stream.
192
+ */
193
+ export async function openAssetStream(rawUrl, signal, proxyUrl) {
194
+ // Explicit setting first, then the product's own env override. Never a
195
+ // guessed port: a Host must not route a user's traffic through a relay
196
+ // they did not name.
197
+ const setting = parseProxy(proxyUrl);
198
+ if (setting.error !== undefined) {
199
+ // Fail loud. Dropping an unusable proxy silently is what makes the card
200
+ // show an address while the transfer runs direct — the bug this file was
201
+ // rewritten to fix, back for a second round.
202
+ throw new Error(`download proxy is unusable (${proxyUrl ?? ""}): ${setting.error}`);
203
+ }
204
+ const fromEnv = parseProxy(process.env.XRK_DOWNLOAD_PROXY);
205
+ if (fromEnv.error !== undefined) {
206
+ throw new Error(`XRK_DOWNLOAD_PROXY is unusable (${process.env.XRK_DOWNLOAD_PROXY ?? ""}): ${fromEnv.error}`);
207
+ }
208
+ const proxy = setting.target ?? fromEnv.target;
209
+ if (proxy === undefined)
210
+ return openFollow(rawUrl, undefined, signal);
211
+ try {
212
+ return await openFollow(rawUrl, proxy, signal);
213
+ }
214
+ catch (error) {
215
+ if (signal.aborted)
216
+ throw error;
217
+ // A proxy that cannot carry this hop must not fail the download when the
218
+ // direct route might work: fall through and try it. Reaching here means
219
+ // the address parsed — only the tunnel itself failed.
220
+ return openFollow(rawUrl, undefined, signal);
221
+ }
222
+ }
223
+ //# sourceMappingURL=download-http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download-http.js","sourceRoot":"","sources":["../src/download-http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,GAAG,MAAM,UAAU,CAAC;AAwB3B,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,UAAU,CAAC,KAAyB;IAClD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC9B,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,KAAK,EAAE,cAAc,OAAO,EAAE,EAAE,CAAC;IAC5C,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1D,OAAO;YACL,KAAK,EAAE,4CAA4C,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM;SACnF,CAA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,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Engine ids and the `XRK_VOICE` CI bypass, shared by the registry and the
3
+ * readiness copy.
4
+ *
5
+ * Kept apart from both so neither has to import the other: `engines.ts` builds
6
+ * Providers, `readiness.ts` only describes them, and the alias table is the
7
+ * single place a bypass spelling is defined.
8
+ */
9
+ /**
10
+ * Resolve the engine id a call should use.
11
+ *
12
+ * A non-empty `XRK_VOICE` is a CI bypass and outranks Settings; anything else
13
+ * falls through to the requested engine, lowercased.
14
+ * @param env - environment to read the bypass from.
15
+ * @param requested - engine id staged by the card.
16
+ * @returns the engine id, or the empty string when neither source names one.
17
+ */
18
+ export declare function resolveEngineId(env: NodeJS.ProcessEnv, requested: string | undefined): string;
19
+ //# sourceMappingURL=engine-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-ids.d.ts","sourceRoot":"","sources":["../src/engine-ids.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,MAAM,CAMR"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Engine ids and the `XRK_VOICE` CI bypass, shared by the registry and the
3
+ * readiness copy.
4
+ *
5
+ * Kept apart from both so neither has to import the other: `engines.ts` builds
6
+ * Providers, `readiness.ts` only describes them, and the alias table is the
7
+ * single place a bypass spelling is defined.
8
+ */
9
+ /** `XRK_VOICE` aliases → engine ids. */
10
+ const ENV_ENGINE_ALIASES = {
11
+ "1": "openai",
12
+ openai: "openai",
13
+ local: "local",
14
+ sensevoice: "local",
15
+ // TTS spells its local engine `system`; the registry's table lookup falls
16
+ // back to that direction's local engine when the id does not exist there.
17
+ system: "local",
18
+ memory: "memory",
19
+ };
20
+ /**
21
+ * Resolve the engine id a call should use.
22
+ *
23
+ * A non-empty `XRK_VOICE` is a CI bypass and outranks Settings; anything else
24
+ * falls through to the requested engine, lowercased.
25
+ * @param env - environment to read the bypass from.
26
+ * @param requested - engine id staged by the card.
27
+ * @returns the engine id, or the empty string when neither source names one.
28
+ */
29
+ export function resolveEngineId(env, requested) {
30
+ const declared = String(env.XRK_VOICE ?? "").trim().toLowerCase();
31
+ const fromEnv = ENV_ENGINE_ALIASES[declared] ?? declared;
32
+ return (fromEnv !== "" ? fromEnv : (requested ?? ""))
33
+ .trim()
34
+ .toLowerCase();
35
+ }
36
+ //# sourceMappingURL=engine-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-ids.js","sourceRoot":"","sources":["../src/engine-ids.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wCAAwC;AACxC,MAAM,kBAAkB,GAAqC;IAC3D,GAAG,EAAE,QAAQ;IACb,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,OAAO;IACnB,0EAA0E;IAC1E,0EAA0E;IAC1E,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAsB,EACtB,SAA6B;IAE7B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAClE,MAAM,OAAO,GAAG,kBAAkB,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;IACzD,OAAO,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;SAClD,IAAI,EAAE;SACN,WAAW,EAAE,CAAC;AACnB,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { VoiceDirection, VoiceService } from "./types.js";
2
+ export type { VoiceDirection } from "./types.js";
3
+ /** Everything an engine factory may read from Settings + the environment. */
4
+ export interface VoiceEngineContext {
5
+ readonly env: NodeJS.ProcessEnv;
6
+ /** OpenAI-compatible endpoint override. */
7
+ readonly baseUrl?: string;
8
+ /** Local: OS voice name. Cloud: provider voice id. */
9
+ readonly voice?: string;
10
+ /** Cloud-only TTS model id. */
11
+ readonly model?: string;
12
+ readonly fetchImpl?: typeof fetch;
13
+ }
14
+ /** One registered engine. */
15
+ export interface VoiceEngineSpec {
16
+ readonly id: string;
17
+ readonly direction: VoiceDirection;
18
+ /** Cloud engines cannot be built without the shared OpenAI-compatible key. */
19
+ readonly needsKey: boolean;
20
+ /** Build the Provider, or undefined when its credential is missing. */
21
+ readonly create: (ctx: VoiceEngineContext) => VoiceService | undefined;
22
+ }
23
+ /**
24
+ * Every engine registered for one direction.
25
+ * @param direction - ASR or TTS.
26
+ * @returns the specs, local first.
27
+ */
28
+ export declare function listVoiceEngines(direction: VoiceDirection): readonly VoiceEngineSpec[];
29
+ /** What one access request asks for. */
30
+ export interface VoiceAccessRequest {
31
+ readonly direction: VoiceDirection;
32
+ /** Settings engine id (`local` / `openai`). Unknown ids fall back to `local`. */
33
+ readonly engine?: string;
34
+ readonly baseUrl?: string;
35
+ readonly voice?: string;
36
+ readonly model?: string;
37
+ readonly env?: NodeJS.ProcessEnv;
38
+ /** Injected Provider (tests / composition) wins over any engine. */
39
+ readonly service?: VoiceService;
40
+ readonly fetchImpl?: typeof fetch;
41
+ }
42
+ /** The resolved Provider plus the fact a caller may report. */
43
+ export interface VoiceAccess {
44
+ readonly service?: VoiceService;
45
+ /** Engine actually used after the `XRK_VOICE` bypass. */
46
+ readonly engine: string;
47
+ /** Tool-facing error when `service` is undefined. */
48
+ readonly unavailableMessage: string;
49
+ }
50
+ /**
51
+ * Resolve one direction's Provider from Settings + environment.
52
+ *
53
+ * Precedence: injected service → `XRK_VOICE` alias → the requested engine.
54
+ * An id that is not registered for this direction falls back to that
55
+ * direction's local engine, so a stale card value can never brick the tool.
56
+ * @param request - direction, engine id and provider options.
57
+ * @returns the Provider (when resolvable) and the honest failure copy.
58
+ */
59
+ export declare function createVoiceAccess(request: VoiceAccessRequest): VoiceAccess;
60
+ //# sourceMappingURL=engines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engines.d.ts","sourceRoot":"","sources":["../src/engines.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/D,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,6EAA6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CACnC;AAED,6BAA6B;AAC7B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,YAAY,GAAG,SAAS,CAAC;CACxE;AAwED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,cAAc,GACxB,SAAS,eAAe,EAAE,CAE5B;AAED,wCAAwC;AACxC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,iFAAiF;IACjF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CACnC;AAED,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;IAChC,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CA+B1E"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Voice engine registry — one row per Provider, split by direction.
3
+ *
4
+ * Adding an engine is one row here plus the settings enum: the Host mount, the
5
+ * Face handler and the cards all resolve through this table instead of each
6
+ * growing its own `if (engine === …)` ladder.
7
+ */
8
+ import { createMemoryVoiceProvider } from "./memory.js";
9
+ import { createOpenAiVoiceProvider } from "./openai-http.js";
10
+ import { createSenseVoiceLocalProvider } from "./sensevoice-local.js";
11
+ import { createSystemVoiceProvider } from "./system-tts.js";
12
+ import { resolveEngineId } from "./engine-ids.js";
13
+ import { voiceUnavailableMessage } from "./readiness.js";
14
+ /** First key wins; `OPENAI_API_KEY` is the conventional fallback. */
15
+ function resolveApiKey(env) {
16
+ const explicit = String(env.XRK_VOICE_OPENAI_KEY ?? "").trim();
17
+ if (explicit !== "")
18
+ return explicit;
19
+ const conventional = String(env.OPENAI_API_KEY ?? "").trim();
20
+ return conventional === "" ? undefined : conventional;
21
+ }
22
+ function openAiEngine(direction) {
23
+ return {
24
+ id: "openai",
25
+ direction,
26
+ needsKey: true,
27
+ create: (ctx) => {
28
+ const apiKey = resolveApiKey(ctx.env);
29
+ if (apiKey === undefined)
30
+ return undefined;
31
+ const baseUrl = ctx.baseUrl?.trim() || String(ctx.env.XRK_VOICE_BASE_URL ?? "").trim();
32
+ const voice = ctx.voice?.trim();
33
+ const model = ctx.model?.trim();
34
+ return createOpenAiVoiceProvider({
35
+ apiKey,
36
+ ...(baseUrl === "" ? {} : { baseUrl }),
37
+ ...(voice === undefined || voice === "" ? {} : { defaultVoice: voice }),
38
+ ...(model === undefined || model === "" ? {} : { ttsModel: model }),
39
+ ...(ctx.fetchImpl ? { fetchImpl: ctx.fetchImpl } : {}),
40
+ });
41
+ },
42
+ };
43
+ }
44
+ const ASR_ENGINES = [
45
+ {
46
+ id: "local",
47
+ direction: "asr",
48
+ needsKey: false,
49
+ create: (ctx) => createSenseVoiceLocalProvider({ env: ctx.env }),
50
+ },
51
+ openAiEngine("asr"),
52
+ // CI / demo only — reachable through `XRK_VOICE=memory`, never a card value.
53
+ {
54
+ id: "memory",
55
+ direction: "asr",
56
+ needsKey: false,
57
+ create: () => createMemoryVoiceProvider(),
58
+ },
59
+ ];
60
+ const TTS_ENGINES = [
61
+ {
62
+ id: "local",
63
+ direction: "tts",
64
+ needsKey: false,
65
+ create: (ctx) => {
66
+ const voice = ctx.voice?.trim();
67
+ return createSystemVoiceProvider({
68
+ env: ctx.env,
69
+ ...(voice === undefined || voice === "" ? {} : { defaultVoice: voice }),
70
+ });
71
+ },
72
+ },
73
+ openAiEngine("tts"),
74
+ {
75
+ id: "memory",
76
+ direction: "tts",
77
+ needsKey: false,
78
+ create: () => createMemoryVoiceProvider(),
79
+ },
80
+ ];
81
+ /**
82
+ * Every engine registered for one direction.
83
+ * @param direction - ASR or TTS.
84
+ * @returns the specs, local first.
85
+ */
86
+ export function listVoiceEngines(direction) {
87
+ return direction === "tts" ? TTS_ENGINES : ASR_ENGINES;
88
+ }
89
+ /**
90
+ * Resolve one direction's Provider from Settings + environment.
91
+ *
92
+ * Precedence: injected service → `XRK_VOICE` alias → the requested engine.
93
+ * An id that is not registered for this direction falls back to that
94
+ * direction's local engine, so a stale card value can never brick the tool.
95
+ * @param request - direction, engine id and provider options.
96
+ * @returns the Provider (when resolvable) and the honest failure copy.
97
+ */
98
+ export function createVoiceAccess(request) {
99
+ const env = request.env ?? process.env;
100
+ const table = listVoiceEngines(request.direction);
101
+ const requested = resolveEngineId(env, request.engine);
102
+ // `off` is a real answer (Settings has not enabled this direction yet), not
103
+ // an unknown id: it must not fall back to the local engine.
104
+ const spec = requested === "off"
105
+ ? undefined
106
+ : (table.find((row) => row.id === requested) ?? table[0]);
107
+ const unavailableMessage = voiceUnavailableMessage(env, {
108
+ direction: request.direction,
109
+ engine: spec?.id ?? requested,
110
+ });
111
+ if (spec === undefined) {
112
+ return { engine: "off", unavailableMessage };
113
+ }
114
+ if (request.service) {
115
+ return { service: request.service, engine: spec.id, unavailableMessage };
116
+ }
117
+ const created = spec.create({
118
+ env,
119
+ ...(request.baseUrl ? { baseUrl: request.baseUrl } : {}),
120
+ ...(request.voice ? { voice: request.voice } : {}),
121
+ ...(request.model ? { model: request.model } : {}),
122
+ ...(request.fetchImpl ? { fetchImpl: request.fetchImpl } : {}),
123
+ });
124
+ return {
125
+ ...(created === undefined ? {} : { service: created }),
126
+ engine: spec.id,
127
+ unavailableMessage,
128
+ };
129
+ }
130
+ //# sourceMappingURL=engines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engines.js","sourceRoot":"","sources":["../src/engines.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MA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AO,EAAE,CAAC;QACpB,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,kBAAkB,EAAE,CAAC;IAC3E,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,GAAG;QACH,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjE,CAAC,CAAC;IACH,OAAO;QACL,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QACtD,MAAM,EAAE,IAAI,CAAC,EAAE;QACf,kBAAkB;KACnB,CAAC;AACJ,CAAC"}
@@ -1,2 +1,15 @@
1
+ /**
2
+ * Prompt blocks for the voice tools.
3
+ *
4
+ * Split by switch so an agent never reads about a tool that is not bound:
5
+ * `tts.enabled` owns `text_to_speech`, `asr.enabled` owns transcription and
6
+ * the live session. `voicePromptText` picks the blocks that actually exist on
7
+ * the surface.
8
+ */
9
+ export declare const VOICE_TTS_PROMPT_TEXT: string;
10
+ export declare const VOICE_ASR_PROMPT_TEXT: string;
11
+ /** Both blocks — for callers that show voice as one subject. */
1
12
  export declare const VOICE_PROMPT_TEXT: string;
13
+ /** The blocks whose tools are actually on this surface; empty when none are. */
14
+ export declare function voicePromptText(has: (name: string) => boolean): string;
2
15
  //# sourceMappingURL=format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,QAMlB,CAAC"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,qBAAqB,QAEtB,CAAC;AAEb,eAAO,MAAM,qBAAqB,QAGtB,CAAC;AAEb,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,QAE7B,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAKtE"}
@@ -1,8 +1,27 @@
1
- export const VOICE_PROMPT_TEXT = [
2
- "Voice (Host):",
1
+ /**
2
+ * Prompt blocks for the voice tools.
3
+ *
4
+ * Split by switch so an agent never reads about a tool that is not bound:
5
+ * `tts.enabled` owns `text_to_speech`, `asr.enabled` owns transcription and
6
+ * the live session. `voicePromptText` picks the blocks that actually exist on
7
+ * the surface.
8
+ */
9
+ export const VOICE_TTS_PROMPT_TEXT = [
3
10
  "- `text_to_speech` speaks text via the Host TTS Provider (returns audio meta; does not play on the server).",
11
+ ].join("\n");
12
+ export const VOICE_ASR_PROMPT_TEXT = [
4
13
  "- `voice_transcribe` runs one-shot STT on base64 audio (dictation / message audio).",
5
14
  "- `voice_session` creates a realtime voice session broker (ephemeral client secret / stub SDP); mic/speaker stay on the client. Mode is Host-side, not a Face child turn.",
6
- "- Without `XRK_VOICE=1` (OpenAI key) or `XRK_VOICE=memory`, tools stay visible and fail honestly.",
7
15
  ].join("\n");
16
+ /** Both blocks — for callers that show voice as one subject. */
17
+ export const VOICE_PROMPT_TEXT = ["Voice (Host):", VOICE_TTS_PROMPT_TEXT, VOICE_ASR_PROMPT_TEXT].join("\n");
18
+ /** The blocks whose tools are actually on this surface; empty when none are. */
19
+ export function voicePromptText(has) {
20
+ const blocks = [];
21
+ if (has("text_to_speech"))
22
+ blocks.push(VOICE_TTS_PROMPT_TEXT);
23
+ if (has("voice_transcribe") || has("voice_session"))
24
+ blocks.push(VOICE_ASR_PROMPT_TEXT);
25
+ return blocks.length === 0 ? "" : ["Voice (Host):", ...blocks].join("\n");
26
+ }
8
27
  //# sourceMappingURL=format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,eAAe;IACf,6GAA6G;IAC7G,qFAAqF;IACrF,2KAA2K;IAC3K,mGAAmG;CACpG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,6GAA6G;CAC9G,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,qFAAqF;IACrF,2KAA2K;CAC5K,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,gEAAgE;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,eAAe,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,IAAI,CACnG,IAAI,CACL,CAAC;AAEF,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAAC,GAA8B;IAC5D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,GAAG,CAAC,gBAAgB,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAC9D,IAAI,GAAG,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,eAAe,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC"}