pocketstation 0.0.0-stage → 0.1.5

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 (558) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +609 -2
  3. package/THIRD_PARTY_NOTICES.md +478 -0
  4. package/bin/pocketstation-demo.mjs +357 -0
  5. package/dist/browser/index.d.ts +12 -0
  6. package/dist/browser/index.d.ts.map +1 -0
  7. package/dist/browser/index.js +11 -0
  8. package/dist/browser/index.js.map +1 -0
  9. package/dist/browser/latency-report.d.ts +2 -0
  10. package/dist/browser/latency-report.d.ts.map +1 -0
  11. package/dist/browser/latency-report.js +27 -0
  12. package/dist/browser/latency-report.js.map +1 -0
  13. package/dist/browser/operation-signal.d.ts +2 -0
  14. package/dist/browser/operation-signal.d.ts.map +1 -0
  15. package/dist/browser/operation-signal.js +31 -0
  16. package/dist/browser/operation-signal.js.map +1 -0
  17. package/dist/browser/relay-publisher.d.ts +32 -0
  18. package/dist/browser/relay-publisher.d.ts.map +1 -0
  19. package/dist/browser/relay-publisher.js +653 -0
  20. package/dist/browser/relay-publisher.js.map +1 -0
  21. package/dist/browser/relay-session.d.ts +36 -0
  22. package/dist/browser/relay-session.d.ts.map +1 -0
  23. package/dist/browser/relay-session.js +859 -0
  24. package/dist/browser/relay-session.js.map +1 -0
  25. package/dist/browser/signaling.d.ts +2 -0
  26. package/dist/browser/signaling.d.ts.map +1 -0
  27. package/dist/browser/signaling.js +253 -0
  28. package/dist/browser/signaling.js.map +1 -0
  29. package/dist/browser/types.d.ts +204 -0
  30. package/dist/browser/types.d.ts.map +1 -0
  31. package/dist/browser/types.js +2 -0
  32. package/dist/browser/types.js.map +1 -0
  33. package/dist/cjs/browser/index.d.ts +12 -0
  34. package/dist/cjs/browser/index.d.ts.map +1 -0
  35. package/dist/cjs/browser/index.js +21 -0
  36. package/dist/cjs/browser/index.js.map +1 -0
  37. package/dist/cjs/browser/latency-report.d.ts +2 -0
  38. package/dist/cjs/browser/latency-report.d.ts.map +1 -0
  39. package/dist/cjs/browser/latency-report.js +30 -0
  40. package/dist/cjs/browser/latency-report.js.map +1 -0
  41. package/dist/cjs/browser/operation-signal.d.ts +2 -0
  42. package/dist/cjs/browser/operation-signal.d.ts.map +1 -0
  43. package/dist/cjs/browser/operation-signal.js +34 -0
  44. package/dist/cjs/browser/operation-signal.js.map +1 -0
  45. package/dist/cjs/browser/relay-publisher.d.ts +32 -0
  46. package/dist/cjs/browser/relay-publisher.d.ts.map +1 -0
  47. package/dist/cjs/browser/relay-publisher.js +657 -0
  48. package/dist/cjs/browser/relay-publisher.js.map +1 -0
  49. package/dist/cjs/browser/relay-session.d.ts +36 -0
  50. package/dist/cjs/browser/relay-session.d.ts.map +1 -0
  51. package/dist/cjs/browser/relay-session.js +865 -0
  52. package/dist/cjs/browser/relay-session.js.map +1 -0
  53. package/dist/cjs/browser/signaling.d.ts +2 -0
  54. package/dist/cjs/browser/signaling.d.ts.map +1 -0
  55. package/dist/cjs/browser/signaling.js +257 -0
  56. package/dist/cjs/browser/signaling.js.map +1 -0
  57. package/dist/cjs/browser/types.d.ts +204 -0
  58. package/dist/cjs/browser/types.d.ts.map +1 -0
  59. package/dist/cjs/browser/types.js +3 -0
  60. package/dist/cjs/browser/types.js.map +1 -0
  61. package/dist/cjs/compatibility.d.ts +28 -0
  62. package/dist/cjs/compatibility.d.ts.map +1 -0
  63. package/dist/cjs/compatibility.js +41 -0
  64. package/dist/cjs/compatibility.js.map +1 -0
  65. package/dist/cjs/control/control-client.d.ts +43 -0
  66. package/dist/cjs/control/control-client.d.ts.map +1 -0
  67. package/dist/cjs/control/control-client.js +775 -0
  68. package/dist/cjs/control/control-client.js.map +1 -0
  69. package/dist/cjs/control/index.d.ts +5 -0
  70. package/dist/cjs/control/index.d.ts.map +1 -0
  71. package/dist/cjs/control/index.js +16 -0
  72. package/dist/cjs/control/index.js.map +1 -0
  73. package/dist/cjs/control/invitation-locator.d.ts +3 -0
  74. package/dist/cjs/control/invitation-locator.d.ts.map +1 -0
  75. package/dist/cjs/control/invitation-locator.js +9 -0
  76. package/dist/cjs/control/invitation-locator.js.map +1 -0
  77. package/dist/cjs/control/session-owner.d.ts +24 -0
  78. package/dist/cjs/control/session-owner.d.ts.map +1 -0
  79. package/dist/cjs/control/session-owner.js +127 -0
  80. package/dist/cjs/control/session-owner.js.map +1 -0
  81. package/dist/cjs/control/types.d.ts +158 -0
  82. package/dist/cjs/control/types.d.ts.map +1 -0
  83. package/dist/cjs/control/types.js +85 -0
  84. package/dist/cjs/control/types.js.map +1 -0
  85. package/dist/cjs/demo/audio-windows.d.ts +39 -0
  86. package/dist/cjs/demo/audio-windows.d.ts.map +1 -0
  87. package/dist/cjs/demo/audio-windows.js +242 -0
  88. package/dist/cjs/demo/audio-windows.js.map +1 -0
  89. package/dist/cjs/demo/faster-whisper.d.ts +98 -0
  90. package/dist/cjs/demo/faster-whisper.d.ts.map +1 -0
  91. package/dist/cjs/demo/faster-whisper.js +355 -0
  92. package/dist/cjs/demo/faster-whisper.js.map +1 -0
  93. package/dist/cjs/demo/index.d.ts +6 -0
  94. package/dist/cjs/demo/index.d.ts.map +1 -0
  95. package/dist/cjs/demo/index.js +23 -0
  96. package/dist/cjs/demo/index.js.map +1 -0
  97. package/dist/cjs/demo/openai-realtime.d.ts +101 -0
  98. package/dist/cjs/demo/openai-realtime.d.ts.map +1 -0
  99. package/dist/cjs/demo/openai-realtime.js +853 -0
  100. package/dist/cjs/demo/openai-realtime.js.map +1 -0
  101. package/dist/cjs/demo/transcript.d.ts +29 -0
  102. package/dist/cjs/demo/transcript.d.ts.map +1 -0
  103. package/dist/cjs/demo/transcript.js +77 -0
  104. package/dist/cjs/demo/transcript.js.map +1 -0
  105. package/dist/cjs/demo/whisper-cli-model.d.ts +20 -0
  106. package/dist/cjs/demo/whisper-cli-model.d.ts.map +1 -0
  107. package/dist/cjs/demo/whisper-cli-model.js +192 -0
  108. package/dist/cjs/demo/whisper-cli-model.js.map +1 -0
  109. package/dist/cjs/demo/window-signal.d.ts +11 -0
  110. package/dist/cjs/demo/window-signal.d.ts.map +1 -0
  111. package/dist/cjs/demo/window-signal.js +58 -0
  112. package/dist/cjs/demo/window-signal.js.map +1 -0
  113. package/dist/cjs/errors.d.ts +11 -0
  114. package/dist/cjs/errors.d.ts.map +1 -0
  115. package/dist/cjs/errors.js +18 -0
  116. package/dist/cjs/errors.js.map +1 -0
  117. package/dist/cjs/index.d.ts +14 -0
  118. package/dist/cjs/index.d.ts.map +1 -0
  119. package/dist/cjs/index.js +20 -0
  120. package/dist/cjs/index.js.map +1 -0
  121. package/dist/cjs/node/aec.d.ts +76 -0
  122. package/dist/cjs/node/aec.d.ts.map +1 -0
  123. package/dist/cjs/node/aec.js +106 -0
  124. package/dist/cjs/node/aec.js.map +1 -0
  125. package/dist/cjs/node/application-audio.d.ts +144 -0
  126. package/dist/cjs/node/application-audio.d.ts.map +1 -0
  127. package/dist/cjs/node/application-audio.js +250 -0
  128. package/dist/cjs/node/application-audio.js.map +1 -0
  129. package/dist/cjs/node/capture.d.ts +104 -0
  130. package/dist/cjs/node/capture.d.ts.map +1 -0
  131. package/dist/cjs/node/capture.js +236 -0
  132. package/dist/cjs/node/capture.js.map +1 -0
  133. package/dist/cjs/node/connector.d.ts +414 -0
  134. package/dist/cjs/node/connector.d.ts.map +1 -0
  135. package/dist/cjs/node/connector.js +756 -0
  136. package/dist/cjs/node/connector.js.map +1 -0
  137. package/dist/cjs/node/endpoint.d.ts +169 -0
  138. package/dist/cjs/node/endpoint.d.ts.map +1 -0
  139. package/dist/cjs/node/endpoint.js +581 -0
  140. package/dist/cjs/node/endpoint.js.map +1 -0
  141. package/dist/cjs/node/errors.d.ts +203 -0
  142. package/dist/cjs/node/errors.d.ts.map +1 -0
  143. package/dist/cjs/node/errors.js +477 -0
  144. package/dist/cjs/node/errors.js.map +1 -0
  145. package/dist/cjs/node/event-input.d.ts +56 -0
  146. package/dist/cjs/node/event-input.d.ts.map +1 -0
  147. package/dist/cjs/node/event-input.js +207 -0
  148. package/dist/cjs/node/event-input.js.map +1 -0
  149. package/dist/cjs/node/events.d.ts +260 -0
  150. package/dist/cjs/node/events.d.ts.map +1 -0
  151. package/dist/cjs/node/events.js +475 -0
  152. package/dist/cjs/node/events.js.map +1 -0
  153. package/dist/cjs/node/extensions.d.ts +117 -0
  154. package/dist/cjs/node/extensions.d.ts.map +1 -0
  155. package/dist/cjs/node/extensions.js +140 -0
  156. package/dist/cjs/node/extensions.js.map +1 -0
  157. package/dist/cjs/node/graph.d.ts +460 -0
  158. package/dist/cjs/node/graph.d.ts.map +1 -0
  159. package/dist/cjs/node/graph.js +920 -0
  160. package/dist/cjs/node/graph.js.map +1 -0
  161. package/dist/cjs/node/identity.d.ts +56 -0
  162. package/dist/cjs/node/identity.d.ts.map +1 -0
  163. package/dist/cjs/node/identity.js +67 -0
  164. package/dist/cjs/node/identity.js.map +1 -0
  165. package/dist/cjs/node/index.d.ts +31 -0
  166. package/dist/cjs/node/index.d.ts.map +1 -0
  167. package/dist/cjs/node/index.js +278 -0
  168. package/dist/cjs/node/index.js.map +1 -0
  169. package/dist/cjs/node/native-package.d.ts +2 -0
  170. package/dist/cjs/node/native-package.d.ts.map +1 -0
  171. package/dist/cjs/node/native-package.js +39 -0
  172. package/dist/cjs/node/native-package.js.map +1 -0
  173. package/dist/cjs/node/native.d.ts +1253 -0
  174. package/dist/cjs/node/native.d.ts.map +1 -0
  175. package/dist/cjs/node/native.js +13 -0
  176. package/dist/cjs/node/native.js.map +1 -0
  177. package/dist/cjs/node/observations.d.ts +500 -0
  178. package/dist/cjs/node/observations.d.ts.map +1 -0
  179. package/dist/cjs/node/observations.js +574 -0
  180. package/dist/cjs/node/observations.js.map +1 -0
  181. package/dist/cjs/node/operator.d.ts +117 -0
  182. package/dist/cjs/node/operator.d.ts.map +1 -0
  183. package/dist/cjs/node/operator.js +408 -0
  184. package/dist/cjs/node/operator.js.map +1 -0
  185. package/dist/cjs/node/provider.d.ts +276 -0
  186. package/dist/cjs/node/provider.d.ts.map +1 -0
  187. package/dist/cjs/node/provider.js +1088 -0
  188. package/dist/cjs/node/provider.js.map +1 -0
  189. package/dist/cjs/node/recording.d.ts +78 -0
  190. package/dist/cjs/node/recording.d.ts.map +1 -0
  191. package/dist/cjs/node/recording.js +153 -0
  192. package/dist/cjs/node/recording.js.map +1 -0
  193. package/dist/cjs/node/relay.d.ts +105 -0
  194. package/dist/cjs/node/relay.d.ts.map +1 -0
  195. package/dist/cjs/node/relay.js +398 -0
  196. package/dist/cjs/node/relay.js.map +1 -0
  197. package/dist/cjs/node/session.d.ts +412 -0
  198. package/dist/cjs/node/session.d.ts.map +1 -0
  199. package/dist/cjs/node/session.js +1204 -0
  200. package/dist/cjs/node/session.js.map +1 -0
  201. package/dist/cjs/node/sidecar.d.ts +179 -0
  202. package/dist/cjs/node/sidecar.d.ts.map +1 -0
  203. package/dist/cjs/node/sidecar.js +453 -0
  204. package/dist/cjs/node/sidecar.js.map +1 -0
  205. package/dist/cjs/node/signals.d.ts +177 -0
  206. package/dist/cjs/node/signals.d.ts.map +1 -0
  207. package/dist/cjs/node/signals.js +344 -0
  208. package/dist/cjs/node/signals.js.map +1 -0
  209. package/dist/cjs/node/source.d.ts +105 -0
  210. package/dist/cjs/node/source.d.ts.map +1 -0
  211. package/dist/cjs/node/source.js +271 -0
  212. package/dist/cjs/node/source.js.map +1 -0
  213. package/dist/cjs/node/sources.d.ts +327 -0
  214. package/dist/cjs/node/sources.d.ts.map +1 -0
  215. package/dist/cjs/node/sources.js +540 -0
  216. package/dist/cjs/node/sources.js.map +1 -0
  217. package/dist/cjs/node/streams.d.ts +163 -0
  218. package/dist/cjs/node/streams.d.ts.map +1 -0
  219. package/dist/cjs/node/streams.js +369 -0
  220. package/dist/cjs/node/streams.js.map +1 -0
  221. package/dist/cjs/package.json +1 -0
  222. package/dist/cjs/require-package.cjs +6 -0
  223. package/dist/cjs/require-package.d.cts +1 -0
  224. package/dist/cjs/voice/capabilities.d.ts +132 -0
  225. package/dist/cjs/voice/capabilities.d.ts.map +1 -0
  226. package/dist/cjs/voice/capabilities.js +207 -0
  227. package/dist/cjs/voice/capabilities.js.map +1 -0
  228. package/dist/cjs/voice/configuration.d.ts +129 -0
  229. package/dist/cjs/voice/configuration.d.ts.map +1 -0
  230. package/dist/cjs/voice/configuration.js +251 -0
  231. package/dist/cjs/voice/configuration.js.map +1 -0
  232. package/dist/cjs/voice/conversation.d.ts +220 -0
  233. package/dist/cjs/voice/conversation.d.ts.map +1 -0
  234. package/dist/cjs/voice/conversation.js +1389 -0
  235. package/dist/cjs/voice/conversation.js.map +1 -0
  236. package/dist/cjs/voice/duplex.d.ts +28 -0
  237. package/dist/cjs/voice/duplex.d.ts.map +1 -0
  238. package/dist/cjs/voice/duplex.js +19 -0
  239. package/dist/cjs/voice/duplex.js.map +1 -0
  240. package/dist/cjs/voice/errors.d.ts +44 -0
  241. package/dist/cjs/voice/errors.d.ts.map +1 -0
  242. package/dist/cjs/voice/errors.js +77 -0
  243. package/dist/cjs/voice/errors.js.map +1 -0
  244. package/dist/cjs/voice/events.d.ts +34 -0
  245. package/dist/cjs/voice/events.d.ts.map +1 -0
  246. package/dist/cjs/voice/events.js +47 -0
  247. package/dist/cjs/voice/events.js.map +1 -0
  248. package/dist/cjs/voice/index.d.ts +18 -0
  249. package/dist/cjs/voice/index.d.ts.map +1 -0
  250. package/dist/cjs/voice/index.js +55 -0
  251. package/dist/cjs/voice/index.js.map +1 -0
  252. package/dist/cjs/voice/response.d.ts +56 -0
  253. package/dist/cjs/voice/response.d.ts.map +1 -0
  254. package/dist/cjs/voice/response.js +74 -0
  255. package/dist/cjs/voice/response.js.map +1 -0
  256. package/dist/cjs/voice/speech-detection.d.ts +40 -0
  257. package/dist/cjs/voice/speech-detection.d.ts.map +1 -0
  258. package/dist/cjs/voice/speech-detection.js +43 -0
  259. package/dist/cjs/voice/speech-detection.js.map +1 -0
  260. package/dist/cjs/voice/synthesis.d.ts +47 -0
  261. package/dist/cjs/voice/synthesis.d.ts.map +1 -0
  262. package/dist/cjs/voice/synthesis.js +50 -0
  263. package/dist/cjs/voice/synthesis.js.map +1 -0
  264. package/dist/cjs/voice/transcription.d.ts +55 -0
  265. package/dist/cjs/voice/transcription.d.ts.map +1 -0
  266. package/dist/cjs/voice/transcription.js +75 -0
  267. package/dist/cjs/voice/transcription.js.map +1 -0
  268. package/dist/cjs/voice/turns.d.ts +94 -0
  269. package/dist/cjs/voice/turns.d.ts.map +1 -0
  270. package/dist/cjs/voice/turns.js +145 -0
  271. package/dist/cjs/voice/turns.js.map +1 -0
  272. package/dist/cjs/voice/validation.d.ts +17 -0
  273. package/dist/cjs/voice/validation.d.ts.map +1 -0
  274. package/dist/cjs/voice/validation.js +104 -0
  275. package/dist/cjs/voice/validation.js.map +1 -0
  276. package/dist/compatibility.d.ts +28 -0
  277. package/dist/compatibility.d.ts.map +1 -0
  278. package/dist/compatibility.js +37 -0
  279. package/dist/compatibility.js.map +1 -0
  280. package/dist/control/control-client.d.ts +43 -0
  281. package/dist/control/control-client.d.ts.map +1 -0
  282. package/dist/control/control-client.js +769 -0
  283. package/dist/control/control-client.js.map +1 -0
  284. package/dist/control/index.d.ts +5 -0
  285. package/dist/control/index.d.ts.map +1 -0
  286. package/dist/control/index.js +5 -0
  287. package/dist/control/index.js.map +1 -0
  288. package/dist/control/invitation-locator.d.ts +3 -0
  289. package/dist/control/invitation-locator.d.ts.map +1 -0
  290. package/dist/control/invitation-locator.js +6 -0
  291. package/dist/control/invitation-locator.js.map +1 -0
  292. package/dist/control/session-owner.d.ts +24 -0
  293. package/dist/control/session-owner.d.ts.map +1 -0
  294. package/dist/control/session-owner.js +123 -0
  295. package/dist/control/session-owner.js.map +1 -0
  296. package/dist/control/types.d.ts +158 -0
  297. package/dist/control/types.d.ts.map +1 -0
  298. package/dist/control/types.js +79 -0
  299. package/dist/control/types.js.map +1 -0
  300. package/dist/demo/audio-windows.d.ts +39 -0
  301. package/dist/demo/audio-windows.d.ts.map +1 -0
  302. package/dist/demo/audio-windows.js +235 -0
  303. package/dist/demo/audio-windows.js.map +1 -0
  304. package/dist/demo/faster-whisper.d.ts +98 -0
  305. package/dist/demo/faster-whisper.d.ts.map +1 -0
  306. package/dist/demo/faster-whisper.js +348 -0
  307. package/dist/demo/faster-whisper.js.map +1 -0
  308. package/dist/demo/index.d.ts +6 -0
  309. package/dist/demo/index.d.ts.map +1 -0
  310. package/dist/demo/index.js +6 -0
  311. package/dist/demo/index.js.map +1 -0
  312. package/dist/demo/openai-realtime.d.ts +101 -0
  313. package/dist/demo/openai-realtime.d.ts.map +1 -0
  314. package/dist/demo/openai-realtime.js +845 -0
  315. package/dist/demo/openai-realtime.js.map +1 -0
  316. package/dist/demo/transcript.d.ts +29 -0
  317. package/dist/demo/transcript.d.ts.map +1 -0
  318. package/dist/demo/transcript.js +73 -0
  319. package/dist/demo/transcript.js.map +1 -0
  320. package/dist/demo/whisper-cli-model.d.ts +20 -0
  321. package/dist/demo/whisper-cli-model.d.ts.map +1 -0
  322. package/dist/demo/whisper-cli-model.js +186 -0
  323. package/dist/demo/whisper-cli-model.js.map +1 -0
  324. package/dist/demo/window-signal.d.ts +11 -0
  325. package/dist/demo/window-signal.d.ts.map +1 -0
  326. package/dist/demo/window-signal.js +53 -0
  327. package/dist/demo/window-signal.js.map +1 -0
  328. package/dist/errors.d.ts +11 -0
  329. package/dist/errors.d.ts.map +1 -0
  330. package/dist/errors.js +14 -0
  331. package/dist/errors.js.map +1 -0
  332. package/dist/index.d.ts +14 -0
  333. package/dist/index.d.ts.map +1 -0
  334. package/dist/index.js +14 -0
  335. package/dist/index.js.map +1 -0
  336. package/dist/node/aec.d.ts +76 -0
  337. package/dist/node/aec.d.ts.map +1 -0
  338. package/dist/node/aec.js +99 -0
  339. package/dist/node/aec.js.map +1 -0
  340. package/dist/node/application-audio.d.ts +144 -0
  341. package/dist/node/application-audio.d.ts.map +1 -0
  342. package/dist/node/application-audio.js +233 -0
  343. package/dist/node/application-audio.js.map +1 -0
  344. package/dist/node/capture.d.ts +104 -0
  345. package/dist/node/capture.d.ts.map +1 -0
  346. package/dist/node/capture.js +231 -0
  347. package/dist/node/capture.js.map +1 -0
  348. package/dist/node/connector.d.ts +414 -0
  349. package/dist/node/connector.d.ts.map +1 -0
  350. package/dist/node/connector.js +706 -0
  351. package/dist/node/connector.js.map +1 -0
  352. package/dist/node/endpoint.d.ts +169 -0
  353. package/dist/node/endpoint.d.ts.map +1 -0
  354. package/dist/node/endpoint.js +568 -0
  355. package/dist/node/endpoint.js.map +1 -0
  356. package/dist/node/errors.d.ts +203 -0
  357. package/dist/node/errors.d.ts.map +1 -0
  358. package/dist/node/errors.js +436 -0
  359. package/dist/node/errors.js.map +1 -0
  360. package/dist/node/event-input.d.ts +56 -0
  361. package/dist/node/event-input.d.ts.map +1 -0
  362. package/dist/node/event-input.js +200 -0
  363. package/dist/node/event-input.js.map +1 -0
  364. package/dist/node/events.d.ts +260 -0
  365. package/dist/node/events.d.ts.map +1 -0
  366. package/dist/node/events.js +470 -0
  367. package/dist/node/events.js.map +1 -0
  368. package/dist/node/extensions.d.ts +117 -0
  369. package/dist/node/extensions.d.ts.map +1 -0
  370. package/dist/node/extensions.js +133 -0
  371. package/dist/node/extensions.js.map +1 -0
  372. package/dist/node/graph.d.ts +460 -0
  373. package/dist/node/graph.d.ts.map +1 -0
  374. package/dist/node/graph.js +904 -0
  375. package/dist/node/graph.js.map +1 -0
  376. package/dist/node/identity.d.ts +56 -0
  377. package/dist/node/identity.d.ts.map +1 -0
  378. package/dist/node/identity.js +54 -0
  379. package/dist/node/identity.js.map +1 -0
  380. package/dist/node/index.d.ts +31 -0
  381. package/dist/node/index.d.ts.map +1 -0
  382. package/dist/node/index.js +31 -0
  383. package/dist/node/index.js.map +1 -0
  384. package/dist/node/native-package.d.ts +2 -0
  385. package/dist/node/native-package.d.ts.map +1 -0
  386. package/dist/node/native-package.js +36 -0
  387. package/dist/node/native-package.js.map +1 -0
  388. package/dist/node/native.d.ts +1253 -0
  389. package/dist/node/native.d.ts.map +1 -0
  390. package/dist/node/native.js +10 -0
  391. package/dist/node/native.js.map +1 -0
  392. package/dist/node/observations.d.ts +500 -0
  393. package/dist/node/observations.d.ts.map +1 -0
  394. package/dist/node/observations.js +563 -0
  395. package/dist/node/observations.js.map +1 -0
  396. package/dist/node/operator.d.ts +117 -0
  397. package/dist/node/operator.d.ts.map +1 -0
  398. package/dist/node/operator.js +398 -0
  399. package/dist/node/operator.js.map +1 -0
  400. package/dist/node/provider.d.ts +276 -0
  401. package/dist/node/provider.d.ts.map +1 -0
  402. package/dist/node/provider.js +1077 -0
  403. package/dist/node/provider.js.map +1 -0
  404. package/dist/node/recording.d.ts +78 -0
  405. package/dist/node/recording.d.ts.map +1 -0
  406. package/dist/node/recording.js +147 -0
  407. package/dist/node/recording.js.map +1 -0
  408. package/dist/node/relay.d.ts +105 -0
  409. package/dist/node/relay.d.ts.map +1 -0
  410. package/dist/node/relay.js +389 -0
  411. package/dist/node/relay.js.map +1 -0
  412. package/dist/node/session.d.ts +412 -0
  413. package/dist/node/session.d.ts.map +1 -0
  414. package/dist/node/session.js +1189 -0
  415. package/dist/node/session.js.map +1 -0
  416. package/dist/node/sidecar.d.ts +179 -0
  417. package/dist/node/sidecar.d.ts.map +1 -0
  418. package/dist/node/sidecar.js +441 -0
  419. package/dist/node/sidecar.js.map +1 -0
  420. package/dist/node/signals.d.ts +177 -0
  421. package/dist/node/signals.d.ts.map +1 -0
  422. package/dist/node/signals.js +338 -0
  423. package/dist/node/signals.js.map +1 -0
  424. package/dist/node/source.d.ts +105 -0
  425. package/dist/node/source.d.ts.map +1 -0
  426. package/dist/node/source.js +260 -0
  427. package/dist/node/source.js.map +1 -0
  428. package/dist/node/sources.d.ts +327 -0
  429. package/dist/node/sources.d.ts.map +1 -0
  430. package/dist/node/sources.js +529 -0
  431. package/dist/node/sources.js.map +1 -0
  432. package/dist/node/streams.d.ts +163 -0
  433. package/dist/node/streams.d.ts.map +1 -0
  434. package/dist/node/streams.js +362 -0
  435. package/dist/node/streams.js.map +1 -0
  436. package/dist/require-package.cjs +6 -0
  437. package/dist/require-package.d.cts +1 -0
  438. package/dist/voice/capabilities.d.ts +132 -0
  439. package/dist/voice/capabilities.d.ts.map +1 -0
  440. package/dist/voice/capabilities.js +198 -0
  441. package/dist/voice/capabilities.js.map +1 -0
  442. package/dist/voice/configuration.d.ts +129 -0
  443. package/dist/voice/configuration.d.ts.map +1 -0
  444. package/dist/voice/configuration.js +244 -0
  445. package/dist/voice/configuration.js.map +1 -0
  446. package/dist/voice/conversation.d.ts +220 -0
  447. package/dist/voice/conversation.d.ts.map +1 -0
  448. package/dist/voice/conversation.js +1383 -0
  449. package/dist/voice/conversation.js.map +1 -0
  450. package/dist/voice/duplex.d.ts +28 -0
  451. package/dist/voice/duplex.d.ts.map +1 -0
  452. package/dist/voice/duplex.js +15 -0
  453. package/dist/voice/duplex.js.map +1 -0
  454. package/dist/voice/errors.d.ts +44 -0
  455. package/dist/voice/errors.d.ts.map +1 -0
  456. package/dist/voice/errors.js +67 -0
  457. package/dist/voice/errors.js.map +1 -0
  458. package/dist/voice/events.d.ts +34 -0
  459. package/dist/voice/events.d.ts.map +1 -0
  460. package/dist/voice/events.js +43 -0
  461. package/dist/voice/events.js.map +1 -0
  462. package/dist/voice/index.d.ts +18 -0
  463. package/dist/voice/index.d.ts.map +1 -0
  464. package/dist/voice/index.js +18 -0
  465. package/dist/voice/index.js.map +1 -0
  466. package/dist/voice/response.d.ts +56 -0
  467. package/dist/voice/response.d.ts.map +1 -0
  468. package/dist/voice/response.js +67 -0
  469. package/dist/voice/response.js.map +1 -0
  470. package/dist/voice/speech-detection.d.ts +40 -0
  471. package/dist/voice/speech-detection.d.ts.map +1 -0
  472. package/dist/voice/speech-detection.js +39 -0
  473. package/dist/voice/speech-detection.js.map +1 -0
  474. package/dist/voice/synthesis.d.ts +47 -0
  475. package/dist/voice/synthesis.d.ts.map +1 -0
  476. package/dist/voice/synthesis.js +45 -0
  477. package/dist/voice/synthesis.js.map +1 -0
  478. package/dist/voice/transcription.d.ts +55 -0
  479. package/dist/voice/transcription.d.ts.map +1 -0
  480. package/dist/voice/transcription.js +71 -0
  481. package/dist/voice/transcription.js.map +1 -0
  482. package/dist/voice/turns.d.ts +94 -0
  483. package/dist/voice/turns.d.ts.map +1 -0
  484. package/dist/voice/turns.js +138 -0
  485. package/dist/voice/turns.js.map +1 -0
  486. package/dist/voice/validation.d.ts +17 -0
  487. package/dist/voice/validation.d.ts.map +1 -0
  488. package/dist/voice/validation.js +86 -0
  489. package/dist/voice/validation.js.map +1 -0
  490. package/dist/wrappers/browser.mjs +8 -0
  491. package/dist/wrappers/control.mjs +9 -0
  492. package/dist/wrappers/demo.mjs +15 -0
  493. package/dist/wrappers/node.mjs +241 -0
  494. package/dist/wrappers/root.mjs +5 -0
  495. package/dist/wrappers/voice.mjs +35 -0
  496. package/package.json +177 -4
  497. package/src/browser/index.ts +33 -0
  498. package/src/browser/latency-report.ts +44 -0
  499. package/src/browser/operation-signal.ts +44 -0
  500. package/src/browser/relay-publisher.ts +856 -0
  501. package/src/browser/relay-session.ts +1121 -0
  502. package/src/browser/signaling.ts +335 -0
  503. package/src/browser/types.ts +222 -0
  504. package/src/compatibility.ts +58 -0
  505. package/src/control/control-client.ts +1058 -0
  506. package/src/control/index.ts +33 -0
  507. package/src/control/invitation-locator.ts +6 -0
  508. package/src/control/session-owner.ts +115 -0
  509. package/src/control/types.ts +257 -0
  510. package/src/demo/audio-windows.ts +344 -0
  511. package/src/demo/faster-whisper.ts +499 -0
  512. package/src/demo/index.ts +33 -0
  513. package/src/demo/openai-realtime.ts +1050 -0
  514. package/src/demo/transcript.ts +90 -0
  515. package/src/demo/whisper-cli-model.ts +190 -0
  516. package/src/demo/window-signal.ts +55 -0
  517. package/src/errors.ts +14 -0
  518. package/src/index.ts +18 -0
  519. package/src/node/aec.ts +177 -0
  520. package/src/node/application-audio.ts +422 -0
  521. package/src/node/capture.ts +336 -0
  522. package/src/node/connector.ts +633 -0
  523. package/src/node/endpoint.ts +835 -0
  524. package/src/node/errors.ts +524 -0
  525. package/src/node/event-input.ts +286 -0
  526. package/src/node/events.ts +834 -0
  527. package/src/node/extensions.ts +260 -0
  528. package/src/node/graph.ts +1295 -0
  529. package/src/node/identity.ts +110 -0
  530. package/src/node/index.ts +499 -0
  531. package/src/node/native-package.ts +47 -0
  532. package/src/node/native.ts +1524 -0
  533. package/src/node/observations.ts +1173 -0
  534. package/src/node/operator.ts +622 -0
  535. package/src/node/provider.ts +1537 -0
  536. package/src/node/recording.ts +295 -0
  537. package/src/node/relay.ts +597 -0
  538. package/src/node/session.ts +1915 -0
  539. package/src/node/sidecar.ts +598 -0
  540. package/src/node/signals.ts +590 -0
  541. package/src/node/source.ts +433 -0
  542. package/src/node/sources.ts +871 -0
  543. package/src/node/streams.ts +543 -0
  544. package/src/require-package.cjs +6 -0
  545. package/src/require-package.d.cts +1 -0
  546. package/src/voice/capabilities.ts +309 -0
  547. package/src/voice/configuration.ts +375 -0
  548. package/src/voice/conversation.ts +2227 -0
  549. package/src/voice/duplex.ts +55 -0
  550. package/src/voice/errors.ts +99 -0
  551. package/src/voice/events.ts +77 -0
  552. package/src/voice/index.ts +122 -0
  553. package/src/voice/response.ts +123 -0
  554. package/src/voice/speech-detection.ts +88 -0
  555. package/src/voice/synthesis.ts +109 -0
  556. package/src/voice/transcription.ts +133 -0
  557. package/src/voice/turns.ts +224 -0
  558. package/src/voice/validation.ts +131 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PocketStation contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,610 @@
1
- # Temporary Holding Version
1
+ # PocketStation for JavaScript
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Node API is designed to capture audio from a desktop application, the whole
4
+ computer, or a microphone on macOS, Windows, and Linux. Each source stays
5
+ separate and every frame includes its source, stream, timing, and sequence
6
+ information. The current platform evidence is listed below; it does not yet
7
+ cover all three operating systems.
8
+
9
+ The package uses the PocketStation Rust engine for capture, routing, and
10
+ shutdown. JavaScript receives audio after it leaves the realtime capture code,
11
+ so model calls and application work do not run on an audio callback.
12
+
13
+ > The Node SDK is under active development and is not published to npm yet.
14
+ > The current code has a real macOS selected-application capture proof.
15
+ > The installed macOS package also has same-host Relay receipt evidence in
16
+ > Chromium, Firefox, and WebKit. Windows and Linux packages, WAN/TURN behavior,
17
+ > and the remaining Rust/Python features still require their own proof.
18
+
19
+ ## Package installation and module modes
20
+
21
+ The root `pocketstation` archive contains JavaScript and declarations. Its exact
22
+ versioned optional native dependency supplies the Node-API addon for macOS or
23
+ Windows on arm64/x64, or glibc Linux on arm64/x64. These six package definitions
24
+ are distribution targets; each release must separately qualify its advertised
25
+ binaries. Musl Linux is unsupported and fails with `package.unsupported_target`.
26
+
27
+ Install with optional dependencies enabled. `package.native_missing` names the
28
+ missing platform package and an explicit install command; a mismatched native
29
+ version fails with `package.version_mismatch`. There is no install script,
30
+ checkout-relative binary fallback, or download at runtime.
31
+
32
+ All six public entry points support Node ESM and CommonJS. In one Node process,
33
+ `import` and `require` share classes, errors and singleton values. The root,
34
+ browser, control and voice ESM builds remain available to browser tooling;
35
+ `pocketstation/node` and `pocketstation/demo` require Node. Browser code does not
36
+ load a native addon. Optional example transport `ws` remains separately installed.
37
+
38
+
39
+ ## Capture an application
40
+
41
+ Choose the running application by its exact display name or application ID:
42
+
43
+ ```ts
44
+ import { capture } from "pocketstation/node";
45
+
46
+ const audio = await capture("Spotify");
47
+ ```
48
+
49
+ Read source-aware PCM frames. Leaving the loop finishes this concise Capture:
50
+
51
+ ```ts
52
+ for await (const frame of audio) {
53
+ console.log(frame.sourceId, frame.timestampStartNs, frame.samples);
54
+ }
55
+ ```
56
+
57
+ `frame.samples` is interleaved `Float32Array` PCM. IDs, sequence numbers, and
58
+ nanosecond timestamps are `bigint`, so JavaScript does not round native 64-bit
59
+ values.
60
+
61
+ ## Add a microphone
62
+
63
+ PocketStation never opens a microphone unless your code asks for one:
64
+
65
+ ```ts
66
+ const audio = await capture("Zoom", { microphone: true });
67
+ ```
68
+
69
+ Application and microphone frames share the iterator but keep different
70
+ `sourceId` and `stemId` values. A slow reader can therefore be diagnosed without
71
+ guessing which source produced a frame.
72
+
73
+ The concise object exposes `audio.session`, `audio.application`, and the optional
74
+ `audio.microphone` Stem. Advanced routing therefore extends the same Session;
75
+ there is no smaller second engine behind `capture()`.
76
+
77
+ To capture all desktop output instead of one application, declare it explicitly:
78
+
79
+ ```ts
80
+ import { Session, Source } from "pocketstation/node";
81
+
82
+ const session = new Session();
83
+ const desktop = session.capture(Source.systemAudio());
84
+ desktop.send(session.audio());
85
+ ```
86
+
87
+ ## Own Session lifecycle from JavaScript
88
+
89
+ Use the separate, browser-safe control entry point when trusted application
90
+ code owns Session creation and receiver authorization. It uses web-standard
91
+ `fetch`; importing it does not load the native addon or the browser WebRTC
92
+ client:
93
+
94
+ ```ts
95
+ import { ControlClient } from "pocketstation/control";
96
+
97
+ using control = new ControlClient("https://control.example");
98
+ const credentials = await control.createSession({
99
+ requiredBuses: ["application", "microphone"],
100
+ });
101
+
102
+ const snapshot = await control.session(
103
+ credentials.sessionId,
104
+ credentials.sourceToken,
105
+ );
106
+ ```
107
+
108
+ Every operation has a finite deadline and accepts an `AbortSignal`. Responses
109
+ are size-bounded and strictly decoded. `SecretToken` redacts normal string and
110
+ JSON conversion; `exposeSecret()` is the deliberate transport boundary.
111
+ Creating subscriber credentials and invitations requires the source-owner
112
+ token, so those operations belong in trusted application or server code—not an
113
+ untrusted phone or public browser bundle.
114
+
115
+ See [Control Session lifecycle](docs/reference/control-plane.md) for the full
116
+ create, inspect, subscribe, invite, delete, cancellation, and error contract.
117
+
118
+ ## Define provider-neutral voice components
119
+
120
+ Import immutable voice values and provider lifecycle interfaces without loading
121
+ the Node native addon or browser WebRTC code:
122
+
123
+ ```ts
124
+ import {
125
+ ConversationConfig,
126
+ ResponseCapabilities,
127
+ TranscriptUpdate,
128
+ TranscriptionCapabilities,
129
+ VoiceCapabilities,
130
+ } from "pocketstation/voice";
131
+
132
+ const capabilities = new VoiceCapabilities({
133
+ transcription: new TranscriptionCapabilities({ streaming: true }),
134
+ response: new ResponseCapabilities({
135
+ streaming: true,
136
+ cancellation: true,
137
+ }),
138
+ });
139
+
140
+ const config = new ConversationConfig();
141
+ const finalTranscript = new TranscriptUpdate({
142
+ utteranceId: "speech-1",
143
+ revision: 1,
144
+ text: "ship the answer",
145
+ stablePrefix: "ship the answer",
146
+ final: true,
147
+ });
148
+ ```
149
+
150
+ `pocketstation/voice` covers the provider-neutral capability, configuration,
151
+ transcript, turn, response, synthesis, speech-activity, duplex, event, failure,
152
+ and bounded conversation orchestration available in Python. Every retained
153
+ collection is copied and frozen, and every count or deadline has a finite
154
+ limit. Providers receive `AbortSignal` cancellation, while selected generated
155
+ output is cancelled without stopping capture or the owning Session.
156
+
157
+ After declaring a transcript `BusSubscription` and an `AudioInput`, compose the
158
+ workflow on the same Session:
159
+
160
+ ```ts
161
+ const conversation = session.conversation({
162
+ transcripts,
163
+ output: assistantAudio,
164
+ respond: async (update, context, signal) => answer(update, context, signal),
165
+ synthesize: (chunk, turn, signal) => speech(chunk, turn, signal),
166
+ });
167
+
168
+ await using running = await session.start();
169
+ const outcome = await conversation.run(running);
170
+ ```
171
+
172
+ Separate STT/response/synthesis/VAD providers and one stateful duplex provider
173
+ use the same finite lifecycle through `Conversation.fromComponents()` and
174
+ `Conversation.fromDuplex()`. The SDK does not bundle a model or provider.
175
+
176
+ ## Record or process the same Stem
177
+
178
+ Capture does not need to be repeated for each destination. The same Stem can be
179
+ read by Node and recorded as a separate WAV file:
180
+
181
+ ```ts
182
+ const session = new Session({ recordingRoot: "./recordings" });
183
+ const application = session.capture(Source.application("Spotify"));
184
+
185
+ application.send(session.audio());
186
+ application.record("application");
187
+ ```
188
+
189
+ Operators and custom Endpoints use open identifiers and named ports. They may
190
+ be implemented in JavaScript, a trusted native extension, or a managed process.
191
+ Core validates the complete Session before capture starts and reports the exact
192
+ Operator, node, or port when compilation fails. The JavaScript package does not
193
+ compile a second execution plan.
194
+
195
+ Read [Route, process, and record media](docs/guides/compose-a-session.md) for
196
+ named ports, generated audio, compiler diagnostics, and delivery settings.
197
+
198
+ ## Publish independent Stems to Relay
199
+
200
+ Use `RelaySession` to own the remote Session and its renewable owner credential.
201
+ The service URL can point to standalone Relay or its managed control-plane
202
+ mount; both expose the same Session API. One publisher carries the named
203
+ AudioBuses while Core keeps application and microphone Stems independent:
204
+
205
+ ```ts
206
+ import { RelaySession, Session, Source } from "pocketstation/node";
207
+
208
+ await using remote = await RelaySession.create({
209
+ controlPlaneUrl: "https://service.example",
210
+ requiredBuses: ["application", "microphone"],
211
+ });
212
+ const session = new Session();
213
+ const application = session.capture(Source.application("Zoom"));
214
+ const microphone = session.capture(Source.microphone());
215
+ const publisher = remote.publisher(session);
216
+ application.publish(publisher, "application");
217
+ microphone.publish(publisher, "microphone");
218
+
219
+ await using live = await session.start();
220
+ await remote.waitForPublisher();
221
+ const invitation = await remote.createReceiverInvitation({ busId: "application" });
222
+ // Deliberate credential disclosure: deliver only to the intended receiver.
223
+ const receiverUrl = invitation.exposeShareUrl();
224
+ // Keep this scope open while your application uses the live Session.
225
+ ```
226
+
227
+ Create a separate invitation for the microphone bus when needed. Readable words
228
+ navigate to the Session; the URL's fragment carries the existing join credential.
229
+ Normal invitation formatting redacts that credential. `session.relay()` remains
230
+ available when the caller already owns the connection and credential lifecycle.
231
+
232
+ The Node addon uses the released Rust Relay Connector for Opus, RTP, WebRTC,
233
+ and signaling. JavaScript does not encode audio or maintain another media
234
+ queue. Relay startup completes before `session.start()` returns, uses a finite
235
+ deadline, and closes with the Session.
236
+
237
+ `transport: 'webrtc'` is the default on both `RelaySession.create()` and
238
+ `session.relay()`. Ordinary native builds use the released
239
+ `pocketstation-relay 0.1.6` Connector and include WebSocket publication by default.
240
+ Check `relayWebsocketAvailable()` from `pocketstation/node` before selecting
241
+ `transport: 'websocket'`. Older addons and builds without the `relay-websocket`
242
+ feature report `false`; selection then fails with `relay.transport_unavailable`
243
+ before creating a remote Session or declaring a publisher. It never falls back
244
+ to another transport automatically.
245
+
246
+ Static WebSocket publication uses the same Connector. It ignores unused
247
+ advertised ICE metadata after bounded response validation; WebRTC still rejects
248
+ TURN and credential-bearing ICE configuration. The
249
+ [integration guide](docs/guides/integrations.md#select-a-static-relay-transport)
250
+ describes this capability boundary. Owner credential renewal does not replace a
251
+ credential already attached to a native publisher; automatic media renewal and
252
+ reconnect are separate capabilities.
253
+ Native WebSocket proxy settings do not configure JavaScript management HTTP;
254
+ an appropriate `ControlClient` fetch implementation remains application-owned.
255
+
256
+ The microphone remains opt-in. A selected application can be the only
257
+ published source when that is all the receiver needs. See the
258
+ [runnable Relay example](examples/publish-to-relay.ts) for configuration.
259
+
260
+ ## Publish caller-owned browser audio
261
+
262
+ The browser-only entry can publish one live `MediaStream` audio track to one
263
+ capability-scoped `AudioBus`. Your application obtains microphone permission
264
+ and retains track ownership:
265
+
266
+ ```ts
267
+ import { RelayPublisher } from "pocketstation/browser";
268
+
269
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
270
+ const publisher = new RelayPublisher({
271
+ signalUrl,
272
+ sessionId,
273
+ busId: "user-microphone",
274
+ publisherToken,
275
+ iceServers,
276
+ });
277
+
278
+ await publisher.publish(stream);
279
+ ```
280
+
281
+ `publish()` resolves only after browser WebRTC statistics contain an outbound
282
+ audio packet. This proves media delivery started; it does not prove speech or
283
+ non-silence. `disconnect()` closes PocketStation resources but deliberately
284
+ does not stop the caller-owned track. Mint `publisherToken` with
285
+ `ControlClient.issuePublisherCredentials()`; never hand the Session-owner token
286
+ to browser media code. Keep bearer credentials out of URLs and browser storage.
287
+ See [Publish and receive Relay audio in a browser](docs/reference/browser-relay.md).
288
+
289
+ ## Send audio to application code
290
+
291
+ Use a Connector for a socket, encoder, provider client, or another destination
292
+ that consumes source-aware PCM:
293
+
294
+ ```ts
295
+ import { Capture, connector } from "pocketstation/node";
296
+
297
+ const destination = connector((frame) => {
298
+ console.log(frame.sourceId, frame.sequenceNumber, frame.samples);
299
+ });
300
+
301
+ const declaration = new Capture({ application: "Zoom", streamAudio: false });
302
+ declaration.application.sendTo(destination);
303
+ await using live = await declaration.start();
304
+ ```
305
+
306
+ The class form adds `start()`, `send()`, and `stop()` for destinations that own
307
+ resources. Sending application and microphone Stems to the same Connector uses
308
+ one instance and preserves both Source identities.
309
+
310
+ Read [Add JavaScript Sources, Operators, and destinations](docs/guides/provider-authoring.md)
311
+ for the class form, typed Sources, Operators, and multi-input Endpoints.
312
+
313
+ ## Read an Operator result
314
+
315
+ Subscribe to a named output before starting the Session, then read it from the
316
+ running Session. Operators can come from application code, an installed
317
+ provider package, a native extension, or a managed process:
318
+
319
+ ```ts
320
+ import {
321
+ PortSpec,
322
+ Session,
323
+ SignalSpec,
324
+ Source,
325
+ defineOperator,
326
+ } from "pocketstation/node";
327
+
328
+ const audio = SignalSpec.audio();
329
+ const text = SignalSpec.text();
330
+ const levelMeter = defineOperator({
331
+ id: "com.example.operator.level-meter.v1",
332
+ inputs: [PortSpec.input("audio", audio)],
333
+ outputs: [PortSpec.output("level", text)],
334
+ create: () => ({
335
+ process(value) {
336
+ if (value.payload.kind !== "audio") return [];
337
+ const peak = value.payload.samples.reduce(
338
+ (current, sample) => Math.max(current, Math.abs(sample)),
339
+ 0,
340
+ );
341
+ return [{ output: "level", data: peak.toFixed(3) }];
342
+ },
343
+ }),
344
+ });
345
+
346
+ const session = new Session();
347
+ const application = session.capture(Source.application("Zoom"));
348
+ const meter = session.operator(levelMeter);
349
+ application.connect(meter.input("audio"));
350
+
351
+ const subscription = session.subscribe(meter.output("level"), { signal: text });
352
+
353
+ await using running = await session.start();
354
+ for await (const value of running.signals(subscription)) {
355
+ if (value.payload.kind === "text") {
356
+ console.log(value.payload.text);
357
+ }
358
+ }
359
+ ```
360
+
361
+ Each value includes the source and stream identity retained from its input.
362
+ Derived values also identify the Operator that produced them. A
363
+ subscription has one reader, can be closed without stopping the Session, and
364
+ reports its current queue depth and delivery totals through `metrics()`.
365
+
366
+ Read [Consume Operator output](docs/guides/signal-streams.md) for timeout,
367
+ end-of-stream, cancellation, queue, and payload behavior.
368
+
369
+ ## Feed audio your application already has
370
+
371
+ Use an `AudioInput` when a provider, network connection, decoder, or voice
372
+ model already gives your application PCM:
373
+
374
+ ```ts
375
+ import { Session } from "pocketstation/node";
376
+
377
+ const session = new Session({ frameDurationMs: 10 });
378
+ const input = session.audioInput("agent audio");
379
+ input.output.send(session.audio());
380
+
381
+ await session.run(async () => {
382
+ await input.write(samples);
383
+ input.close();
384
+ });
385
+ ```
386
+
387
+ `samples` is normally a `Float32Array` containing one complete interleaved
388
+ frame. A `Buffer` is also accepted when it contains little-endian IEEE 754
389
+ float32 values. PocketStation copies an accepted frame before the write
390
+ returns, so the producer can reuse its array immediately.
391
+
392
+ The default input holds at most eight frames waiting for Core. `tryWrite()`
393
+ reports `AudioInputFullError` immediately. `write()` waits up to one second and
394
+ accepts an `AbortSignal`; timing out or aborting that wait does not close the
395
+ input or stop the Session.
396
+
397
+ Read [Feed application-owned PCM](docs/guides/application-audio.md) for format,
398
+ capacity, discontinuity, selected-output cancellation, and shutdown behavior.
399
+
400
+ ## Add compiled or process-isolated implementations
401
+
402
+ Load a trusted native extension when a Source, Operator, or Endpoint is shipped
403
+ as a PocketStation ABI library:
404
+
405
+ ```ts
406
+ const session = new Session();
407
+ await session.loadNativeExtensionLibrary("/opt/acme/libacme_audio.dylib");
408
+
409
+ const source = session.source("com.acme.source.audio.v1");
410
+ source.output("audio").send(session.audio());
411
+ ```
412
+
413
+ Use a `SidecarProcess` when an implementation runs in another language or
414
+ needs process isolation. Core starts it without a shell, completes the PKSS
415
+ handshake, applies explicit message sizes and deadlines, and reaps it during
416
+ Session shutdown.
417
+
418
+ Read [Run compiled extensions and managed processes](docs/guides/extensions-and-sidecars.md)
419
+ for security, configuration, queue saturation, finite reads, process state,
420
+ and cleanup.
421
+
422
+ ## Discover sources before capture
423
+
424
+ Discovery lets an application present the real sources reported by the host
425
+ instead of asking a user to type a name:
426
+
427
+ ```ts
428
+ import { Source, discoverSources } from "pocketstation/node";
429
+
430
+ const applications = await discoverSources({
431
+ type: "kind",
432
+ kind: "application",
433
+ });
434
+
435
+ const selected = Source.fromDiscovered(applications[0]);
436
+ ```
437
+
438
+ Each result includes its display name, native application or device identity,
439
+ current state, audio format, and how long its selector may be reused. A
440
+ discovered output device is informational; application, input-device, and
441
+ system-mix results can be turned into Session Sources.
442
+
443
+ Read microphone permission without prompting:
444
+
445
+ ```ts
446
+ import { microphonePermissionObservation } from "pocketstation/node";
447
+
448
+ const permission = await microphonePermissionObservation();
449
+ ```
450
+
451
+ `not-observable` is kept distinct from `allowed` and `denied`. PocketStation
452
+ does not infer permission from a generic capture failure. The host application
453
+ remains responsible for explaining and requesting operating-system permission.
454
+
455
+ ## Observe source failure
456
+
457
+ The Session reports lifecycle and failure events separately from audio:
458
+
459
+ ```ts
460
+ for await (const event of running.events) {
461
+ if (event.type === "source-failure") {
462
+ console.error(event.failure.stableId, event.failure.operation);
463
+ }
464
+ }
465
+ ```
466
+
467
+ When an application or device disappears, the event keeps its Source and Stem
468
+ identity and states whether rediscovery and a new Session are required. It does
469
+ not silently switch to another application or microphone.
470
+
471
+ Inspect current delivery and timing without consuming the audio stream:
472
+
473
+ ```ts
474
+ const metrics = await running.metrics();
475
+
476
+ for (const route of metrics.routes) {
477
+ console.log(route.routeId, route.delivery.framesDroppedTotal);
478
+ }
479
+ ```
480
+
481
+ All counters, identities, and nanosecond values are `bigint`. The final result
482
+ retains the last metrics, the complete terminal event, and recording or trace
483
+ results when those features were enabled.
484
+
485
+ Read [Understand a running Session](docs/guides/observe-a-session.md) for queue
486
+ depth, latency percentiles, retained failures, multistem results, and trace
487
+ validation.
488
+
489
+ ## Stop or cancel
490
+
491
+ `stop()` finishes accepted work and returns the Session outcome. `cancel()` asks
492
+ the engine to stop without draining pending work. Both operations are
493
+ idempotent through the JavaScript `RunningSession` object.
494
+
495
+ ```ts
496
+ const outcome = await running.stop();
497
+
498
+ if (!outcome.success) {
499
+ console.error(outcome);
500
+ }
501
+ ```
502
+
503
+ Enable a checksummed lifecycle trace when a reproducible shutdown record is
504
+ needed:
505
+
506
+ ```ts
507
+ import { SessionTrace } from "pocketstation/node";
508
+
509
+ const session = new Session({ trace: { path: "./meeting.pkstrace" } });
510
+ // Declare Sources and destinations, then start and stop the Session.
511
+
512
+ const trace = SessionTrace.read("./meeting.pkstrace");
513
+ console.log(trace.validate());
514
+ ```
515
+
516
+ Breaking an audio loop releases that reader; it does not stop the Session.
517
+ Pass an `AbortSignal` when the reader needs its own cancellation:
518
+
519
+ ```ts
520
+ for await (const frame of running.audio.frames({ signal })) {
521
+ consume(frame);
522
+ }
523
+ ```
524
+
525
+ Direct reads distinguish a wait that expired from a stream that ended:
526
+
527
+ ```ts
528
+ import { END_OF_STREAM } from "pocketstation/node";
529
+
530
+ const value = await running.audio.read({ timeoutMs: 100 });
531
+
532
+ if (value === undefined) {
533
+ // No frame arrived within 100 ms.
534
+ } else if (value === END_OF_STREAM) {
535
+ // The Session ended and no received frames remain.
536
+ }
537
+ ```
538
+
539
+ ## Current API status
540
+
541
+ Read [platform support](docs/operations/platform-support.md) for supported
542
+ environments and limitations, and [Session lifecycle](docs/concepts/session-lifecycle.md)
543
+ for native ownership, cancellation and shutdown.
544
+
545
+ Browser Relay receiving is exposed from `pocketstation/browser`. It stays
546
+ separate so browser builds never load a native addon:
547
+
548
+ ```ts
549
+ import { RelayReceiver } from "pocketstation/browser";
550
+
551
+ const receiver = new RelayReceiver({ locator: joinCode }, { controlPlaneUrl: controlUrl });
552
+ audio.srcObject = await receiver.connect();
553
+ ```
554
+
555
+ Read [Receive Relay audio in a browser](docs/reference/browser-relay.md) for
556
+ direct subscriber access, lifecycle handling, receiver observations, and the
557
+ current proof level.
558
+
559
+ ## Develop from source
560
+
561
+ Node 20.17 or newer and the Rust toolchain are required while the npm package is
562
+ still in development.
563
+
564
+ ```bash
565
+ npm install
566
+ npm run typecheck
567
+ npm test
568
+ npm run native:check
569
+ ```
570
+
571
+ For source development, `npm run build:native` builds and stages the local
572
+ platform package under `npm/` and installs a copy in this checkout's
573
+ `node_modules`. `npm run build:typescript` builds both module forms without
574
+ loading native code. Packed-consumer gates install the root and real local
575
+ native tarballs into a separate temporary project.
576
+
577
+ After the build, run the application-capture example and enter the name of a
578
+ running application when prompted:
579
+
580
+ ```bash
581
+ npm run example:capture
582
+ ```
583
+
584
+ Add `-- --microphone` only when you also want the default microphone.
585
+
586
+ The repository uses the released `pocketstation` Rust crate in normal builds.
587
+ Local source overrides are used only for an explicitly recorded Core
588
+ qualification and are removed before packaging.
589
+
590
+ ## License
591
+
592
+ MIT
593
+
594
+ Readable Relay names may use short natural words such as `owl-sun`, `rice-river`,
595
+ `silly-mountain` or `lemon-corpus`. They are navigation, not credentials: pass
596
+ the complete generated share URL. Clients accept the retained legacy compound
597
+ syntax without duplicating Relay's vocabulary or exposing a grammar prefix.
598
+
599
+ Readable receiver names follow Relay's configured allocation policy by default.
600
+ Pass integer `wordCount: 2` through `wordCount: 15` to `createInvitation` or
601
+ `createReceiverInvitation` only when a fixed length is needed. Deprecated
602
+ `visibility` still selects formatting; it cannot be combined with `wordCount`
603
+ and never changes authorization. Names do not carry authority: both formats
604
+ require the same opaque join credential, and links remain redacted by default.
605
+
606
+ Invitation and preview results expose the actual `wordCount`. Explicit response
607
+ counts must match the name; old responses without a count remain accepted only
608
+ for their original two/three-word formats. All readable locators have at most
609
+ 134 ASCII bytes, 2–15 words and 3–24 letters per word (the latter preserves old
610
+ compound names). Vocabulary and phrase generation remain owned by Relay.