@0xmaxma/claude-gateway 2.0.20 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/README.md +1 -0
  2. package/config.template.json +3 -2
  3. package/dist/agent/builtin-commands.d.ts +4 -0
  4. package/dist/agent/builtin-commands.d.ts.map +1 -1
  5. package/dist/agent/builtin-commands.js +11 -4
  6. package/dist/agent/builtin-commands.js.map +1 -1
  7. package/dist/agent/command-help.d.ts +11 -2
  8. package/dist/agent/command-help.d.ts.map +1 -1
  9. package/dist/agent/command-help.js +29 -8
  10. package/dist/agent/command-help.js.map +1 -1
  11. package/dist/agent/model-registry.d.ts +48 -0
  12. package/dist/agent/model-registry.d.ts.map +1 -0
  13. package/dist/agent/model-registry.js +144 -0
  14. package/dist/agent/model-registry.js.map +1 -0
  15. package/dist/agent/runner.d.ts +73 -43
  16. package/dist/agent/runner.d.ts.map +1 -1
  17. package/dist/agent/runner.js +361 -120
  18. package/dist/agent/runner.js.map +1 -1
  19. package/dist/agent/session-confirmations.d.ts +1 -1
  20. package/dist/agent/session-confirmations.d.ts.map +1 -1
  21. package/dist/agent/session-confirmations.js +5 -3
  22. package/dist/agent/session-confirmations.js.map +1 -1
  23. package/dist/agent/skill-learning/reviewer.d.ts.map +1 -1
  24. package/dist/agent/skill-learning/reviewer.js +2 -1
  25. package/dist/agent/skill-learning/reviewer.js.map +1 -1
  26. package/dist/agent/turn-stream.d.ts +2 -1
  27. package/dist/agent/turn-stream.d.ts.map +1 -1
  28. package/dist/agent/turn-stream.js.map +1 -1
  29. package/dist/api/gateway-router.d.ts.map +1 -1
  30. package/dist/api/gateway-router.js +17 -1
  31. package/dist/api/gateway-router.js.map +1 -1
  32. package/dist/api/manifest-sources.d.ts.map +1 -1
  33. package/dist/api/manifest-sources.js +3 -0
  34. package/dist/api/manifest-sources.js.map +1 -1
  35. package/dist/api/pstack-router.d.ts +14 -0
  36. package/dist/api/pstack-router.d.ts.map +1 -0
  37. package/dist/api/pstack-router.js +93 -0
  38. package/dist/api/pstack-router.js.map +1 -0
  39. package/dist/api/router.d.ts.map +1 -1
  40. package/dist/api/router.js +32 -83
  41. package/dist/api/router.js.map +1 -1
  42. package/dist/api/voice-call-router.d.ts +21 -0
  43. package/dist/api/voice-call-router.d.ts.map +1 -0
  44. package/dist/api/voice-call-router.js +119 -0
  45. package/dist/api/voice-call-router.js.map +1 -0
  46. package/dist/api/voice-router.d.ts +27 -0
  47. package/dist/api/voice-router.d.ts.map +1 -1
  48. package/dist/api/voice-router.js +126 -63
  49. package/dist/api/voice-router.js.map +1 -1
  50. package/dist/api/voice-settings-router.d.ts.map +1 -1
  51. package/dist/api/voice-settings-router.js +3 -1
  52. package/dist/api/voice-settings-router.js.map +1 -1
  53. package/dist/automation/computer-use.d.ts.map +1 -1
  54. package/dist/automation/computer-use.js +8 -1
  55. package/dist/automation/computer-use.js.map +1 -1
  56. package/dist/build-provenance.json +4 -4
  57. package/dist/cli/commands.generated.d.ts.map +1 -1
  58. package/dist/cli/commands.generated.js +36 -1
  59. package/dist/cli/commands.generated.js.map +1 -1
  60. package/dist/cli-viewer/pairing-store.d.ts +4 -0
  61. package/dist/cli-viewer/pairing-store.d.ts.map +1 -1
  62. package/dist/cli-viewer/pairing-store.js +6 -6
  63. package/dist/cli-viewer/pairing-store.js.map +1 -1
  64. package/dist/cli-viewer/telegram-initdata.d.ts +1 -1
  65. package/dist/cli-viewer/telegram-initdata.d.ts.map +1 -1
  66. package/dist/cli-viewer/telegram-initdata.js +2 -2
  67. package/dist/cli-viewer/telegram-initdata.js.map +1 -1
  68. package/dist/cli-viewer/url.d.ts +2 -0
  69. package/dist/cli-viewer/url.d.ts.map +1 -1
  70. package/dist/cli-viewer/url.js +6 -0
  71. package/dist/cli-viewer/url.js.map +1 -1
  72. package/dist/config/loader.d.ts.map +1 -1
  73. package/dist/config/loader.js +7 -0
  74. package/dist/config/loader.js.map +1 -1
  75. package/dist/config/reload-policy.js +1 -1
  76. package/dist/config/reload-policy.js.map +1 -1
  77. package/dist/config/watcher.d.ts.map +1 -1
  78. package/dist/config/watcher.js +2 -0
  79. package/dist/config/watcher.js.map +1 -1
  80. package/dist/orchestration/agent-tool-schemas.js +1 -1
  81. package/dist/orchestration/agent-tool-schemas.js.map +1 -1
  82. package/dist/orchestration/bridge.d.ts +6 -2
  83. package/dist/orchestration/bridge.d.ts.map +1 -1
  84. package/dist/orchestration/bridge.js +122 -6
  85. package/dist/orchestration/bridge.js.map +1 -1
  86. package/dist/orchestration/capabilities.d.ts.map +1 -1
  87. package/dist/orchestration/capabilities.js +10 -3
  88. package/dist/orchestration/capabilities.js.map +1 -1
  89. package/dist/orchestration/capacity.d.ts +9 -2
  90. package/dist/orchestration/capacity.d.ts.map +1 -1
  91. package/dist/orchestration/capacity.js +18 -7
  92. package/dist/orchestration/capacity.js.map +1 -1
  93. package/dist/orchestration/cli-skills.d.ts.map +1 -1
  94. package/dist/orchestration/cli-skills.js +4 -2
  95. package/dist/orchestration/cli-skills.js.map +1 -1
  96. package/dist/orchestration/config.d.ts +47 -0
  97. package/dist/orchestration/config.d.ts.map +1 -1
  98. package/dist/orchestration/config.js +25 -4
  99. package/dist/orchestration/config.js.map +1 -1
  100. package/dist/orchestration/conversation-intake.d.ts.map +1 -1
  101. package/dist/orchestration/conversation-intake.js +3 -1
  102. package/dist/orchestration/conversation-intake.js.map +1 -1
  103. package/dist/orchestration/dashboard-reader-worker.js +5 -3
  104. package/dist/orchestration/dashboard-reader-worker.js.map +1 -1
  105. package/dist/orchestration/decisions.d.ts.map +1 -1
  106. package/dist/orchestration/decisions.js +4 -2
  107. package/dist/orchestration/decisions.js.map +1 -1
  108. package/dist/orchestration/delivery.d.ts.map +1 -1
  109. package/dist/orchestration/delivery.js +1 -0
  110. package/dist/orchestration/delivery.js.map +1 -1
  111. package/dist/orchestration/display-stream.d.ts +6 -0
  112. package/dist/orchestration/display-stream.d.ts.map +1 -1
  113. package/dist/orchestration/display-stream.js +13 -8
  114. package/dist/orchestration/display-stream.js.map +1 -1
  115. package/dist/orchestration/gateway-tasks/computer.d.ts +2 -0
  116. package/dist/orchestration/gateway-tasks/computer.d.ts.map +1 -1
  117. package/dist/orchestration/gateway-tasks/computer.js +68 -28
  118. package/dist/orchestration/gateway-tasks/computer.js.map +1 -1
  119. package/dist/orchestration/gateway-tasks/controller.d.ts +6 -6
  120. package/dist/orchestration/gateway-tasks/controller.d.ts.map +1 -1
  121. package/dist/orchestration/identity.d.ts +5 -1
  122. package/dist/orchestration/identity.d.ts.map +1 -1
  123. package/dist/orchestration/identity.js +6 -0
  124. package/dist/orchestration/identity.js.map +1 -1
  125. package/dist/orchestration/input-batch.d.ts +8 -2
  126. package/dist/orchestration/input-batch.d.ts.map +1 -1
  127. package/dist/orchestration/input-batch.js +28 -8
  128. package/dist/orchestration/input-batch.js.map +1 -1
  129. package/dist/orchestration/live-voice-transcript.d.ts +13 -0
  130. package/dist/orchestration/live-voice-transcript.d.ts.map +1 -0
  131. package/dist/orchestration/live-voice-transcript.js +36 -0
  132. package/dist/orchestration/live-voice-transcript.js.map +1 -0
  133. package/dist/orchestration/mutation-recovery.js +1 -1
  134. package/dist/orchestration/mutation-recovery.js.map +1 -1
  135. package/dist/orchestration/notification-mailbox.d.ts.map +1 -1
  136. package/dist/orchestration/notification-mailbox.js +4 -2
  137. package/dist/orchestration/notification-mailbox.js.map +1 -1
  138. package/dist/orchestration/process-turn.d.ts +6 -1
  139. package/dist/orchestration/process-turn.d.ts.map +1 -1
  140. package/dist/orchestration/process-turn.js +9 -5
  141. package/dist/orchestration/process-turn.js.map +1 -1
  142. package/dist/orchestration/recovery.d.ts.map +1 -1
  143. package/dist/orchestration/recovery.js +21 -0
  144. package/dist/orchestration/recovery.js.map +1 -1
  145. package/dist/orchestration/response-errors.d.ts +5 -0
  146. package/dist/orchestration/response-errors.d.ts.map +1 -1
  147. package/dist/orchestration/response-errors.js +25 -0
  148. package/dist/orchestration/response-errors.js.map +1 -1
  149. package/dist/orchestration/runtime.d.ts +26 -2
  150. package/dist/orchestration/runtime.d.ts.map +1 -1
  151. package/dist/orchestration/runtime.js +221 -48
  152. package/dist/orchestration/runtime.js.map +1 -1
  153. package/dist/orchestration/speech.d.ts +3 -0
  154. package/dist/orchestration/speech.d.ts.map +1 -1
  155. package/dist/orchestration/speech.js +13 -5
  156. package/dist/orchestration/speech.js.map +1 -1
  157. package/dist/orchestration/store.d.ts +5 -0
  158. package/dist/orchestration/store.d.ts.map +1 -1
  159. package/dist/orchestration/store.js +13 -5
  160. package/dist/orchestration/store.js.map +1 -1
  161. package/dist/orchestration/subagent-tool-schemas.d.ts +12 -0
  162. package/dist/orchestration/subagent-tool-schemas.d.ts.map +1 -0
  163. package/dist/orchestration/subagent-tool-schemas.js +23 -0
  164. package/dist/orchestration/subagent-tool-schemas.js.map +1 -0
  165. package/dist/orchestration/task-controls.d.ts.map +1 -1
  166. package/dist/orchestration/task-controls.js +2 -1
  167. package/dist/orchestration/task-controls.js.map +1 -1
  168. package/dist/orchestration/task-questions.d.ts.map +1 -1
  169. package/dist/orchestration/task-questions.js +3 -1
  170. package/dist/orchestration/task-questions.js.map +1 -1
  171. package/dist/orchestration/tasks/automation-session.d.ts +12 -0
  172. package/dist/orchestration/tasks/automation-session.d.ts.map +1 -1
  173. package/dist/orchestration/tasks/automation-session.js +26 -1
  174. package/dist/orchestration/tasks/automation-session.js.map +1 -1
  175. package/dist/orchestration/tasks/driver.d.ts.map +1 -1
  176. package/dist/orchestration/tasks/driver.js +54 -14
  177. package/dist/orchestration/tasks/driver.js.map +1 -1
  178. package/dist/orchestration/tasks/scheduler.d.ts.map +1 -1
  179. package/dist/orchestration/tasks/scheduler.js +17 -3
  180. package/dist/orchestration/tasks/scheduler.js.map +1 -1
  181. package/dist/orchestration/tasks/service.d.ts +110 -34
  182. package/dist/orchestration/tasks/service.d.ts.map +1 -1
  183. package/dist/orchestration/tasks/service.js +234 -19
  184. package/dist/orchestration/tasks/service.js.map +1 -1
  185. package/dist/orchestration/tasks/task-directive.d.ts.map +1 -1
  186. package/dist/orchestration/tasks/task-directive.js +5 -1
  187. package/dist/orchestration/tasks/task-directive.js.map +1 -1
  188. package/dist/orchestration/telegram-tool-status.d.ts +8 -1
  189. package/dist/orchestration/telegram-tool-status.d.ts.map +1 -1
  190. package/dist/orchestration/telegram-tool-status.js +57 -6
  191. package/dist/orchestration/telegram-tool-status.js.map +1 -1
  192. package/dist/orchestration/telegram-voices.d.ts +4 -0
  193. package/dist/orchestration/telegram-voices.d.ts.map +1 -1
  194. package/dist/orchestration/telegram-voices.js +6 -2
  195. package/dist/orchestration/telegram-voices.js.map +1 -1
  196. package/dist/orchestration/token-ledger.d.ts +14 -0
  197. package/dist/orchestration/token-ledger.d.ts.map +1 -1
  198. package/dist/orchestration/token-ledger.js +28 -2
  199. package/dist/orchestration/token-ledger.js.map +1 -1
  200. package/dist/orchestration/token-usage.d.ts +14 -0
  201. package/dist/orchestration/token-usage.d.ts.map +1 -1
  202. package/dist/orchestration/token-usage.js +16 -2
  203. package/dist/orchestration/token-usage.js.map +1 -1
  204. package/dist/orchestration/tool-name.d.ts.map +1 -1
  205. package/dist/orchestration/tool-name.js +5 -1
  206. package/dist/orchestration/tool-name.js.map +1 -1
  207. package/dist/orchestration/types.d.ts +29 -0
  208. package/dist/orchestration/types.d.ts.map +1 -1
  209. package/dist/orchestration/types.js +11 -0
  210. package/dist/orchestration/types.js.map +1 -1
  211. package/dist/orchestration/worker-harness.d.ts.map +1 -1
  212. package/dist/orchestration/worker-harness.js +5 -2
  213. package/dist/orchestration/worker-harness.js.map +1 -1
  214. package/dist/pstack/config.d.ts +48 -0
  215. package/dist/pstack/config.d.ts.map +1 -0
  216. package/dist/pstack/config.js +147 -0
  217. package/dist/pstack/config.js.map +1 -0
  218. package/dist/pstack/menu.d.ts +71 -0
  219. package/dist/pstack/menu.d.ts.map +1 -0
  220. package/dist/pstack/menu.js +286 -0
  221. package/dist/pstack/menu.js.map +1 -0
  222. package/dist/pstack/overlay.d.ts +30 -0
  223. package/dist/pstack/overlay.d.ts.map +1 -0
  224. package/dist/pstack/overlay.js +121 -0
  225. package/dist/pstack/overlay.js.map +1 -0
  226. package/dist/pstack/plugin-info.d.ts +36 -0
  227. package/dist/pstack/plugin-info.d.ts.map +1 -0
  228. package/dist/pstack/plugin-info.js +51 -0
  229. package/dist/pstack/plugin-info.js.map +1 -0
  230. package/dist/pstack/reflect.d.ts +14 -0
  231. package/dist/pstack/reflect.d.ts.map +1 -0
  232. package/dist/pstack/reflect.js +49 -0
  233. package/dist/pstack/reflect.js.map +1 -0
  234. package/dist/pstack/setup.d.ts +17 -0
  235. package/dist/pstack/setup.d.ts.map +1 -0
  236. package/dist/pstack/setup.js +47 -0
  237. package/dist/pstack/setup.js.map +1 -0
  238. package/dist/pstack/sheet.d.ts +19 -0
  239. package/dist/pstack/sheet.d.ts.map +1 -0
  240. package/dist/pstack/sheet.js +44 -0
  241. package/dist/pstack/sheet.js.map +1 -0
  242. package/dist/pstack/templates.d.ts +14 -0
  243. package/dist/pstack/templates.d.ts.map +1 -0
  244. package/dist/pstack/templates.js +41 -0
  245. package/dist/pstack/templates.js.map +1 -0
  246. package/dist/session/codex-process.d.ts +0 -3
  247. package/dist/session/codex-process.d.ts.map +1 -1
  248. package/dist/session/codex-process.js +8 -3
  249. package/dist/session/codex-process.js.map +1 -1
  250. package/dist/session/compactor.d.ts.map +1 -1
  251. package/dist/session/compactor.js +2 -1
  252. package/dist/session/compactor.js.map +1 -1
  253. package/dist/session/process-diagnostics.d.ts +3 -0
  254. package/dist/session/process-diagnostics.d.ts.map +1 -1
  255. package/dist/session/process-diagnostics.js +10 -0
  256. package/dist/session/process-diagnostics.js.map +1 -1
  257. package/dist/session/process.d.ts.map +1 -1
  258. package/dist/session/process.js +9 -4
  259. package/dist/session/process.js.map +1 -1
  260. package/dist/session/provider-refusal.d.ts +36 -0
  261. package/dist/session/provider-refusal.d.ts.map +1 -0
  262. package/dist/session/provider-refusal.js +109 -0
  263. package/dist/session/provider-refusal.js.map +1 -0
  264. package/dist/session/runtime-profile.d.ts +13 -2
  265. package/dist/session/runtime-profile.d.ts.map +1 -1
  266. package/dist/session/runtime-profile.js +35 -2
  267. package/dist/session/runtime-profile.js.map +1 -1
  268. package/dist/session/worker-extensions.d.ts +5 -2
  269. package/dist/session/worker-extensions.d.ts.map +1 -1
  270. package/dist/session/worker-extensions.js +10 -5
  271. package/dist/session/worker-extensions.js.map +1 -1
  272. package/dist/telegram/access.d.ts +23 -0
  273. package/dist/telegram/access.d.ts.map +1 -0
  274. package/dist/telegram/access.js +105 -0
  275. package/dist/telegram/access.js.map +1 -0
  276. package/dist/types.d.ts +3 -0
  277. package/dist/types.d.ts.map +1 -1
  278. package/dist/ui/cli-viewer-ui.d.ts +5 -0
  279. package/dist/ui/cli-viewer-ui.d.ts.map +1 -1
  280. package/dist/ui/cli-viewer-ui.js +9 -6
  281. package/dist/ui/cli-viewer-ui.js.map +1 -1
  282. package/dist/ui/dashboard-client.d.ts.map +1 -1
  283. package/dist/ui/dashboard-client.js +14 -4
  284. package/dist/ui/dashboard-client.js.map +1 -1
  285. package/dist/ui/dashboard-presentation.d.ts +29 -0
  286. package/dist/ui/dashboard-presentation.d.ts.map +1 -1
  287. package/dist/ui/dashboard-presentation.js +26 -1
  288. package/dist/ui/dashboard-presentation.js.map +1 -1
  289. package/dist/ui/token-report.d.ts +3 -0
  290. package/dist/ui/token-report.d.ts.map +1 -1
  291. package/dist/ui/token-report.js +1 -1
  292. package/dist/ui/token-report.js.map +1 -1
  293. package/dist/ui/voice-call-client.d.ts +142 -0
  294. package/dist/ui/voice-call-client.d.ts.map +1 -0
  295. package/dist/ui/voice-call-client.js +328 -0
  296. package/dist/ui/voice-call-client.js.map +1 -0
  297. package/dist/ui/voice-call-ui.d.ts +21 -0
  298. package/dist/ui/voice-call-ui.d.ts.map +1 -0
  299. package/dist/ui/voice-call-ui.js +488 -0
  300. package/dist/ui/voice-call-ui.js.map +1 -0
  301. package/dist/voice/audio-tags.d.ts +7 -0
  302. package/dist/voice/audio-tags.d.ts.map +1 -0
  303. package/dist/voice/audio-tags.js +66 -0
  304. package/dist/voice/audio-tags.js.map +1 -0
  305. package/dist/voice/call-pairing.d.ts +76 -0
  306. package/dist/voice/call-pairing.d.ts.map +1 -0
  307. package/dist/voice/call-pairing.js +126 -0
  308. package/dist/voice/call-pairing.js.map +1 -0
  309. package/dist/voice/diagnostics.d.ts +12 -9
  310. package/dist/voice/diagnostics.d.ts.map +1 -1
  311. package/dist/voice/diagnostics.js +2 -1
  312. package/dist/voice/diagnostics.js.map +1 -1
  313. package/dist/voice/errors.d.ts +6 -1
  314. package/dist/voice/errors.d.ts.map +1 -1
  315. package/dist/voice/errors.js +12 -1
  316. package/dist/voice/errors.js.map +1 -1
  317. package/dist/voice/fast-ack.d.ts +27 -0
  318. package/dist/voice/fast-ack.d.ts.map +1 -0
  319. package/dist/voice/fast-ack.js +52 -0
  320. package/dist/voice/fast-ack.js.map +1 -0
  321. package/dist/voice/managed-quota.d.ts +29 -3
  322. package/dist/voice/managed-quota.d.ts.map +1 -1
  323. package/dist/voice/managed-quota.js +68 -23
  324. package/dist/voice/managed-quota.js.map +1 -1
  325. package/dist/voice/notes.d.ts +27 -3
  326. package/dist/voice/notes.d.ts.map +1 -1
  327. package/dist/voice/notes.js +59 -10
  328. package/dist/voice/notes.js.map +1 -1
  329. package/dist/voice/providers/elevenlabs-tts.d.ts +1 -0
  330. package/dist/voice/providers/elevenlabs-tts.d.ts.map +1 -1
  331. package/dist/voice/providers/elevenlabs-tts.js +62 -12
  332. package/dist/voice/providers/elevenlabs-tts.js.map +1 -1
  333. package/dist/voice/providers/gemini.d.ts +4 -0
  334. package/dist/voice/providers/gemini.d.ts.map +1 -1
  335. package/dist/voice/providers/gemini.js +7 -1
  336. package/dist/voice/providers/gemini.js.map +1 -1
  337. package/dist/voice/providers/registry.d.ts.map +1 -1
  338. package/dist/voice/providers/registry.js +34 -2
  339. package/dist/voice/providers/registry.js.map +1 -1
  340. package/dist/voice/scope.d.ts +13 -0
  341. package/dist/voice/scope.d.ts.map +1 -0
  342. package/dist/voice/scope.js +3 -0
  343. package/dist/voice/scope.js.map +1 -0
  344. package/dist/voice/session.d.ts +16 -1
  345. package/dist/voice/session.d.ts.map +1 -1
  346. package/dist/voice/session.js +90 -16
  347. package/dist/voice/session.js.map +1 -1
  348. package/dist/voice/telegram-avatar.d.ts +38 -0
  349. package/dist/voice/telegram-avatar.d.ts.map +1 -0
  350. package/dist/voice/telegram-avatar.js +95 -0
  351. package/dist/voice/telegram-avatar.js.map +1 -0
  352. package/mcp/lazy-tools.ts +4 -2
  353. package/mcp/server.ts +6 -2
  354. package/mcp/tools/tasks/module.ts +3 -1
  355. package/mcp/tools/telegram/pstack-menu.ts +22 -0
  356. package/mcp/tools/telegram/pure.ts +40 -0
  357. package/mcp/tools/telegram/receiver-server.ts +86 -7
  358. package/package.json +1 -1
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Pure browser logic for the Telegram `/call` page. Each function is
3
+ * self-contained so the page can embed it with `Function.toString()` (as the
4
+ * dashboard does) while tests import the same code.
5
+ */
6
+ /** Client acoustic tuning for endpointing. These are microphone-level heuristics,
7
+ * not protocol timing: the server then waits `voice.turns.silenceCommitMs`
8
+ * (0 commits at once) after `speech.ended` before it commits an utterance. Levels are RMS of
9
+ * float samples in [-1, 1]. */
10
+ export declare const VOICE_CALL_VAD: {
11
+ startMs: number;
12
+ endMs: number;
13
+ ratio: number;
14
+ minLevel: number;
15
+ initialNoise: number;
16
+ noiseAdapt: number;
17
+ bargeInRatio: number;
18
+ bargeInMs: number;
19
+ };
20
+ /**
21
+ * Streaming resampler from the AudioContext rate to 16 kHz PCM16. A one-pole
22
+ * low-pass at the output Nyquist frequency limits aliasing; linear interpolation
23
+ * carries the fractional position and last sample across chunks.
24
+ */
25
+ export declare function createResampler(inputRate: number, outputRate: number): (input: Float32Array) => Int16Array;
26
+ /** One `CGV1` microphone frame: 44-byte header, then little-endian PCM16. */
27
+ export declare function encodeVoiceCallFrame(generation: string, epoch: number, sequence: number, segmentId: string, pcm: Int16Array): ArrayBuffer;
28
+ /** RMS level of a float chunk. */
29
+ export declare function voiceCallLevel(samples: Float32Array): number;
30
+ /**
31
+ * Energy endpointing with an adaptive noise floor. Feed one level per chunk with
32
+ * its duration; it reports `start` after `startMs` above the threshold and `end`
33
+ * after `endMs` below it. The floor only learns from non-speech chunks. While the
34
+ * agent is audible, starting needs `bargeInRatio` times the level for `bargeInMs`,
35
+ * so echo the canceller leaves behind does not interrupt the reply.
36
+ */
37
+ export declare function createVoiceCallVad(options: {
38
+ startMs: number;
39
+ endMs: number;
40
+ ratio: number;
41
+ minLevel: number;
42
+ initialNoise: number;
43
+ noiseAdapt: number;
44
+ bargeInRatio: number;
45
+ bargeInMs: number;
46
+ }): (level: number, ms: number, playing?: boolean) => 'start' | 'end' | undefined;
47
+ /**
48
+ * Microphone uplink for one call. The server accepts frames only for the current
49
+ * `utterance_id`, with sequences 1, 2, 3…, and `speech.ended` must name the last
50
+ * sequence sent. After `speech.ended` the next words wait for a new `listening`
51
+ * state, so audio captured meanwhile is held (bounded) and sent first.
52
+ */
53
+ export declare function createVoiceCallUplink(io: {
54
+ json(message: Record<string, unknown>): void;
55
+ frame(utteranceId: string, sequence: number, pcm: Int16Array): void;
56
+ }, limits: {
57
+ preRollSamples: number;
58
+ maxHeldSamples: number;
59
+ maxUtteranceSamples: number;
60
+ }): {
61
+ /** The server opened a new utterance. */
62
+ listening(id: string): void;
63
+ /** The microphone is closed server-side (muted or reconnecting). */
64
+ reset(): void;
65
+ audio(pcm: Int16Array): void;
66
+ /** VAD start. A newer epoch interrupts audible playback; otherwise only defer admission. */
67
+ speechStart(playback: {
68
+ playing: boolean;
69
+ epoch: number;
70
+ }): void;
71
+ /** VAD end. True when the gateway is (or will be) told the utterance ended, so it will answer or report no speech. */
72
+ speechEnd(): boolean;
73
+ /** Words spoken after `speech.ended` wait for the next utterance before they can be sent. */
74
+ holding(): boolean;
75
+ /** `last_audio_seq` for a commit-on-mute: the utterance still open on the server, if any. */
76
+ pendingSequence(): number | undefined;
77
+ };
78
+ /**
79
+ * Played-sample accounting for one playback epoch. Audio is scheduled back to
80
+ * back; whatever is still scheduled after `now` has not been heard yet.
81
+ */
82
+ export declare function createVoiceCallPlayhead(): {
83
+ reset(): void;
84
+ /** Returns the context time at which this chunk starts. */
85
+ schedule(samples: number, sampleRate: number, now: number): number;
86
+ /** Samples heard so far, monotonic and never above what was received. */
87
+ played(sampleRate: number, now: number): number;
88
+ playing(now: number): boolean;
89
+ };
90
+ /** How the page reacts to a refused `/ticket` request. */
91
+ export interface VoiceCallTicketFailure {
92
+ message: string;
93
+ fatal: boolean;
94
+ signIn: boolean;
95
+ }
96
+ /**
97
+ * Map a refused `/ticket` response to the page's reaction. Every refusal from the
98
+ * gateway carries a JSON `error`; a 401 or 403 without one came from a proxy in
99
+ * front of it (a GetPod pod's sign-in expired, or another account is signed in).
100
+ * Only a page navigation can recover from that: the proxy answers it with the
101
+ * login redirect that brought `/cli` and `/call` here in the first place.
102
+ */
103
+ export declare function voiceCallTicketFailure(status: number, body: {
104
+ error?: unknown;
105
+ code?: unknown;
106
+ }): VoiceCallTicketFailure;
107
+ /** The page's palette: Telegram's colour scheme when Telegram supplies a theme, the
108
+ * system's otherwise. Outside Telegram, telegram-web-app.js still reports "light"
109
+ * but without any theme colours. */
110
+ export declare function voiceCallTheme(tg: {
111
+ colorScheme?: unknown;
112
+ themeParams?: {
113
+ bg_color?: unknown;
114
+ };
115
+ } | undefined, prefersLight: boolean): 'light' | 'dark';
116
+ /** Call length as a phone shows it: m:ss, then h:mm:ss. */
117
+ export declare function formatCallDuration(ms: number): string;
118
+ /**
119
+ * How the page shows a `voice.error`. `no_speech` means the recognizer heard
120
+ * sound but no words (a cough, the room, the microphone opening); the call is
121
+ * still listening, so it is not an error to the caller. The server log keeps it.
122
+ */
123
+ export declare function voiceCallErrorView(error: {
124
+ code?: unknown;
125
+ category?: unknown;
126
+ message?: unknown;
127
+ }): {
128
+ kind: 'listening';
129
+ } | {
130
+ kind: 'ended' | 'error';
131
+ message: string;
132
+ };
133
+ /**
134
+ * A reply as the call screen shows it: the chat's Markdown reduced to plain text
135
+ * (bold, italic, code, headings and quotes lose their markers, a link keeps its URL,
136
+ * a bullet becomes •), with the line breaks kept. The page sets it as text, never
137
+ * as HTML. stripMarkdownPreservingUrls (src/agent/line-pure.ts) does the same for
138
+ * LINE, but its patterns live outside the function and use lookbehind, which older
139
+ * iOS WebViews cannot parse; this one is embedded in the page whole.
140
+ */
141
+ export declare function voiceCallReplyText(text: string): string;
142
+ //# sourceMappingURL=voice-call-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-call-client.d.ts","sourceRoot":"","sources":["../../src/ui/voice-call-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;+BAG+B;AAC/B,eAAO,MAAM,cAAc;;;;;;;;;CAAkI,CAAC;AAE9J;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,UAAU,CAmB1G;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,WAAW,CAWzI;AAED,kCAAkC;AAClC,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAI5D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,U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,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,sBAAsB,CAexH;AAED;;oCAEoC;AACpC,wBAAgB,cAAc,CAAC,EAAE,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,GAAG,SAAS,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAGvJ;AAED,2DAA2D;AAC3D,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAIzK;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAevD"}
@@ -0,0 +1,328 @@
1
+ "use strict";
2
+ /**
3
+ * Pure browser logic for the Telegram `/call` page. Each function is
4
+ * self-contained so the page can embed it with `Function.toString()` (as the
5
+ * dashboard does) while tests import the same code.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.VOICE_CALL_VAD = void 0;
9
+ exports.createResampler = createResampler;
10
+ exports.encodeVoiceCallFrame = encodeVoiceCallFrame;
11
+ exports.voiceCallLevel = voiceCallLevel;
12
+ exports.createVoiceCallVad = createVoiceCallVad;
13
+ exports.createVoiceCallUplink = createVoiceCallUplink;
14
+ exports.createVoiceCallPlayhead = createVoiceCallPlayhead;
15
+ exports.voiceCallTicketFailure = voiceCallTicketFailure;
16
+ exports.voiceCallTheme = voiceCallTheme;
17
+ exports.formatCallDuration = formatCallDuration;
18
+ exports.voiceCallErrorView = voiceCallErrorView;
19
+ exports.voiceCallReplyText = voiceCallReplyText;
20
+ /** Client acoustic tuning for endpointing. These are microphone-level heuristics,
21
+ * not protocol timing: the server then waits `voice.turns.silenceCommitMs`
22
+ * (0 commits at once) after `speech.ended` before it commits an utterance. Levels are RMS of
23
+ * float samples in [-1, 1]. */
24
+ exports.VOICE_CALL_VAD = { startMs: 120, endMs: 350, ratio: 3, minLevel: 0.012, initialNoise: 0.004, noiseAdapt: 0.05, bargeInRatio: 2, bargeInMs: 250 };
25
+ /**
26
+ * Streaming resampler from the AudioContext rate to 16 kHz PCM16. A one-pole
27
+ * low-pass at the output Nyquist frequency limits aliasing; linear interpolation
28
+ * carries the fractional position and last sample across chunks.
29
+ */
30
+ function createResampler(inputRate, outputRate) {
31
+ const step = inputRate / outputRate;
32
+ const alpha = 1 - Math.exp(-2 * Math.PI * (outputRate / 2) / inputRate);
33
+ let position = 0, previous = 0, filtered = 0;
34
+ return input => {
35
+ const smooth = new Float32Array(input.length);
36
+ for (let i = 0; i < input.length; i++) {
37
+ filtered += alpha * (input[i] - filtered);
38
+ smooth[i] = filtered;
39
+ }
40
+ const out = [];
41
+ // `position` is relative to this chunk; -1 is the previous chunk's last sample.
42
+ while (position < smooth.length - 1) {
43
+ const index = Math.floor(position), fraction = position - index;
44
+ const a = index < 0 ? previous : smooth[index], b = smooth[index + 1];
45
+ const value = Math.max(-1, Math.min(1, a + (b - a) * fraction));
46
+ out.push(value < 0 ? Math.round(value * 0x8000) : Math.round(value * 0x7fff));
47
+ position += step;
48
+ }
49
+ if (smooth.length) {
50
+ position -= smooth.length;
51
+ previous = smooth[smooth.length - 1];
52
+ }
53
+ return Int16Array.from(out);
54
+ };
55
+ }
56
+ /** One `CGV1` microphone frame: 44-byte header, then little-endian PCM16. */
57
+ function encodeVoiceCallFrame(generation, epoch, sequence, segmentId, pcm) {
58
+ const buffer = new ArrayBuffer(44 + pcm.length * 2), view = new DataView(buffer);
59
+ 'CGV1'.split('').forEach((character, index) => view.setUint8(index, character.charCodeAt(0)));
60
+ const uuid = (value, offset) => {
61
+ const hex = value.replace(/-/g, '');
62
+ if (!/^[0-9a-f]{32}$/i.test(hex))
63
+ throw new Error('INVALID_FRAME_ID');
64
+ for (let i = 0; i < 16; i++)
65
+ view.setUint8(offset + i, parseInt(hex.slice(i * 2, i * 2 + 2), 16));
66
+ };
67
+ uuid(generation, 4);
68
+ view.setUint32(20, epoch >>> 0, false);
69
+ view.setUint32(24, sequence >>> 0, false);
70
+ uuid(segmentId, 28);
71
+ for (let i = 0; i < pcm.length; i++)
72
+ view.setInt16(44 + i * 2, pcm[i], true);
73
+ return buffer;
74
+ }
75
+ /** RMS level of a float chunk. */
76
+ function voiceCallLevel(samples) {
77
+ let sum = 0;
78
+ for (let i = 0; i < samples.length; i++)
79
+ sum += samples[i] * samples[i];
80
+ return samples.length ? Math.sqrt(sum / samples.length) : 0;
81
+ }
82
+ /**
83
+ * Energy endpointing with an adaptive noise floor. Feed one level per chunk with
84
+ * its duration; it reports `start` after `startMs` above the threshold and `end`
85
+ * after `endMs` below it. The floor only learns from non-speech chunks. While the
86
+ * agent is audible, starting needs `bargeInRatio` times the level for `bargeInMs`,
87
+ * so echo the canceller leaves behind does not interrupt the reply.
88
+ */
89
+ function createVoiceCallVad(options) {
90
+ let noise = options.initialNoise, speaking = false, above = 0, below = 0;
91
+ return (level, ms, playing = false) => {
92
+ const threshold = Math.max(options.minLevel, noise * options.ratio);
93
+ const loud = level > threshold;
94
+ if (!speaking) {
95
+ const start = playing ? level > threshold * options.bargeInRatio : loud;
96
+ if (start) {
97
+ above += ms;
98
+ if (above >= (playing ? options.bargeInMs : options.startMs)) {
99
+ speaking = true;
100
+ below = 0;
101
+ return 'start';
102
+ }
103
+ }
104
+ else if (loud)
105
+ above = 0;
106
+ else {
107
+ above = 0;
108
+ noise += (level - noise) * options.noiseAdapt;
109
+ }
110
+ return undefined;
111
+ }
112
+ if (loud) {
113
+ below = 0;
114
+ return undefined;
115
+ }
116
+ below += ms;
117
+ if (below >= options.endMs) {
118
+ speaking = false;
119
+ above = 0;
120
+ return 'end';
121
+ }
122
+ return undefined;
123
+ };
124
+ }
125
+ /**
126
+ * Microphone uplink for one call. The server accepts frames only for the current
127
+ * `utterance_id`, with sequences 1, 2, 3…, and `speech.ended` must name the last
128
+ * sequence sent. After `speech.ended` the next words wait for a new `listening`
129
+ * state, so audio captured meanwhile is held (bounded) and sent first.
130
+ */
131
+ function createVoiceCallUplink(io, limits) {
132
+ let utteranceId, sequence = 0, sentSamples = 0;
133
+ let state = 'waiting';
134
+ let held = [], heldSamples = 0, speechPending = false, endPending = false, endedSequence = 0;
135
+ const hold = (pcm, cap) => {
136
+ held.push(pcm);
137
+ heldSamples += pcm.length;
138
+ while (held.length > 1 && heldSamples - held[0].length >= cap)
139
+ heldSamples -= held.shift().length;
140
+ };
141
+ const send = (pcm) => {
142
+ if (!utteranceId || !pcm.length)
143
+ return;
144
+ // Stay under the utterance budget: end the turn rather than overrun it.
145
+ if (sentSamples + pcm.length > limits.maxUtteranceSamples) {
146
+ end();
147
+ return;
148
+ }
149
+ sequence++;
150
+ sentSamples += pcm.length;
151
+ io.frame(utteranceId, sequence, pcm);
152
+ };
153
+ const begin = () => {
154
+ state = 'speaking';
155
+ sequence = 0;
156
+ sentSamples = 0;
157
+ const queued = held;
158
+ held = [];
159
+ heldSamples = 0;
160
+ for (const pcm of queued)
161
+ if (state === 'speaking')
162
+ send(pcm);
163
+ };
164
+ /** True when the gateway was told the utterance ended. */
165
+ const end = () => {
166
+ if (state !== 'speaking')
167
+ return false;
168
+ if (!sequence) {
169
+ state = 'ready';
170
+ return false;
171
+ }
172
+ io.json({ type: 'speech.ended', last_audio_seq: sequence });
173
+ state = 'ended';
174
+ endedSequence = sequence;
175
+ utteranceId = undefined;
176
+ return true;
177
+ };
178
+ return {
179
+ /** The server opened a new utterance. */
180
+ listening(id) {
181
+ utteranceId = id;
182
+ state = 'ready';
183
+ endedSequence = 0;
184
+ if (speechPending) {
185
+ speechPending = false;
186
+ begin();
187
+ if (endPending) {
188
+ endPending = false;
189
+ end();
190
+ }
191
+ }
192
+ },
193
+ /** The microphone is closed server-side (muted or reconnecting). */
194
+ reset() { utteranceId = undefined; state = 'waiting'; held = []; heldSamples = 0; speechPending = false; endPending = false; endedSequence = 0; },
195
+ audio(pcm) {
196
+ if (state === 'speaking')
197
+ send(pcm);
198
+ else
199
+ hold(pcm, speechPending ? limits.maxHeldSamples : limits.preRollSamples);
200
+ },
201
+ /** VAD start. A newer epoch interrupts audible playback; otherwise only defer admission. */
202
+ speechStart(playback) {
203
+ io.json(playback.playing ? { type: 'speech.started', epoch: playback.epoch + 1 } : { type: 'speech.activity' });
204
+ if (state === 'ready')
205
+ begin();
206
+ else if (state !== 'speaking') {
207
+ speechPending = true;
208
+ endPending = false;
209
+ }
210
+ },
211
+ /** VAD end. True when the gateway is (or will be) told the utterance ended, so it will answer or report no speech. */
212
+ speechEnd() {
213
+ if (state === 'speaking')
214
+ return end();
215
+ if (speechPending)
216
+ endPending = true;
217
+ return speechPending;
218
+ },
219
+ /** Words spoken after `speech.ended` wait for the next utterance before they can be sent. */
220
+ holding() { return speechPending; },
221
+ /** `last_audio_seq` for a commit-on-mute: the utterance still open on the server, if any. */
222
+ pendingSequence() { return state === 'speaking' && sequence ? sequence : state === 'ended' ? endedSequence : undefined; },
223
+ };
224
+ }
225
+ /**
226
+ * Played-sample accounting for one playback epoch. Audio is scheduled back to
227
+ * back; whatever is still scheduled after `now` has not been heard yet.
228
+ */
229
+ function createVoiceCallPlayhead() {
230
+ let queuedSamples = 0, endTime = 0, reported = 0;
231
+ return {
232
+ reset() { queuedSamples = 0; endTime = 0; reported = 0; },
233
+ /** Returns the context time at which this chunk starts. */
234
+ schedule(samples, sampleRate, now) {
235
+ const start = Math.max(now, endTime);
236
+ endTime = start + samples / sampleRate;
237
+ queuedSamples += samples;
238
+ return start;
239
+ },
240
+ /** Samples heard so far, monotonic and never above what was received. */
241
+ played(sampleRate, now) {
242
+ const remaining = Math.max(0, Math.ceil((endTime - now) * sampleRate));
243
+ reported = Math.max(reported, Math.min(queuedSamples, queuedSamples - remaining));
244
+ return reported;
245
+ },
246
+ playing(now) { return endTime > now; },
247
+ };
248
+ }
249
+ /**
250
+ * Map a refused `/ticket` response to the page's reaction. Every refusal from the
251
+ * gateway carries a JSON `error`; a 401 or 403 without one came from a proxy in
252
+ * front of it (a GetPod pod's sign-in expired, or another account is signed in).
253
+ * Only a page navigation can recover from that: the proxy answers it with the
254
+ * login redirect that brought `/cli` and `/call` here in the first place.
255
+ */
256
+ function voiceCallTicketFailure(status, body) {
257
+ const refusal = (message, fatal = true) => ({ message, fatal, signIn: false });
258
+ if ((status === 401 || status === 403) && typeof body.error !== 'string') {
259
+ return { message: 'You need to sign in again to continue the call.', fatal: true, signIn: true };
260
+ }
261
+ if (status === 401)
262
+ return refusal('Telegram could not verify you. Reopen the call from the /call button.');
263
+ if (status === 403)
264
+ return refusal('You are not allowed to call this agent.');
265
+ if (status === 409 && body.code === 'CALL_LINK_USED')
266
+ return refusal('This call link was already used. Send /call again.');
267
+ if (status === 409 && body.code === 'VOICE_DISABLED')
268
+ return refusal('Voice calls are turned off for this agent.');
269
+ // A lease still being released can succeed on retry.
270
+ if (status === 409)
271
+ return refusal('A call is already open in this chat. Hang up there first.', Boolean(body.code));
272
+ if (status === 410 || status === 404)
273
+ return refusal('This call link has expired. Send /call again.');
274
+ if (status === 429)
275
+ return refusal('Voice credit is exhausted.');
276
+ // A busy gateway can succeed on retry.
277
+ return refusal('The call could not start right now. Please try again.', status !== 503);
278
+ }
279
+ /** The page's palette: Telegram's colour scheme when Telegram supplies a theme, the
280
+ * system's otherwise. Outside Telegram, telegram-web-app.js still reports "light"
281
+ * but without any theme colours. */
282
+ function voiceCallTheme(tg, prefersLight) {
283
+ const scheme = tg && tg.themeParams && tg.themeParams.bg_color ? tg.colorScheme : undefined;
284
+ return scheme === 'light' || scheme === 'dark' ? scheme : prefersLight ? 'light' : 'dark';
285
+ }
286
+ /** Call length as a phone shows it: m:ss, then h:mm:ss. */
287
+ function formatCallDuration(ms) {
288
+ const total = Math.max(0, Math.floor(ms / 1000)), hours = Math.floor(total / 3600), minutes = Math.floor(total / 60) % 60, seconds = total % 60;
289
+ const pad = (value) => (value < 10 ? '0' : '') + value;
290
+ return hours ? hours + ':' + pad(minutes) + ':' + pad(seconds) : minutes + ':' + pad(seconds);
291
+ }
292
+ /**
293
+ * How the page shows a `voice.error`. `no_speech` means the recognizer heard
294
+ * sound but no words (a cough, the room, the microphone opening); the call is
295
+ * still listening, so it is not an error to the caller. The server log keeps it.
296
+ */
297
+ function voiceCallErrorView(error) {
298
+ if (error.category === 'no_speech')
299
+ return { kind: 'listening' };
300
+ if (error.code === 'VOICE_SESSION_CHANGED')
301
+ return { kind: 'ended', message: 'This chat switched sessions. Send /call to talk in the new one.' };
302
+ return { kind: 'error', message: typeof error.message === 'string' && error.message ? error.message : 'Voice error' };
303
+ }
304
+ /**
305
+ * A reply as the call screen shows it: the chat's Markdown reduced to plain text
306
+ * (bold, italic, code, headings and quotes lose their markers, a link keeps its URL,
307
+ * a bullet becomes •), with the line breaks kept. The page sets it as text, never
308
+ * as HTML. stripMarkdownPreservingUrls (src/agent/line-pure.ts) does the same for
309
+ * LINE, but its patterns live outside the function and use lookbehind, which older
310
+ * iOS WebViews cannot parse; this one is embedded in the page whole.
311
+ */
312
+ function voiceCallReplyText(text) {
313
+ return text
314
+ .replace(/```[^\n`]*\n?([\s\S]*?)\n?```/g, '$1')
315
+ .replace(/`([^`\n]+)`/g, '$1')
316
+ .replace(/!?\[([^\]\n]+)\]\(([^)\s]+)\)/g, '$1 ($2)')
317
+ .replace(/(\*\*|__)(?=\S)([\s\S]*?\S)\1/g, '$2')
318
+ .replace(/~~(?=\S)([\s\S]*?\S)~~/g, '$1')
319
+ .replace(/(^|[^\w*])\*([^\s*](?:[^*\n]*?[^\s*])?)\*(?![\w*])/gm, '$1$2')
320
+ .replace(/(^|\W)_([^\s_](?:[^_\n]*?[^\s_])?)_(?!\w)/gm, '$1$2')
321
+ .replace(/^[ \t]{0,3}#{1,6}[ \t]+/gm, '')
322
+ .replace(/^[ \t]{0,3}>[ \t]?/gm, '')
323
+ .replace(/^[ \t]*(?:-{3,}|\*{3,}|_{3,})[ \t]*$/gm, '')
324
+ .replace(/^([ \t]*)[-*+][ \t]+/gm, '$1• ')
325
+ .replace(/\n{3,}/g, '\n\n')
326
+ .trim();
327
+ }
328
+ //# sourceMappingURL=voice-call-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-call-client.js","sourceRoot":"","sources":["../../src/ui/voice-call-client.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAaH,0CAmBC;AAGD,oDAWC;AAGD,wCAIC;AASD,gDAiBC;AAQD,sDAuDC;AAMD,0DAkBC;AAYD,wDAeC;AAKD,wCAGC;AAGD,gDAIC;AAOD,gDAIC;AAUD,gDAeC;AAlPD;;;+BAG+B;AAClB,QAAA,cAAc,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;AAE9J;;;;GAIG;AACH,SAAgB,eAAe,CAAC,SAAiB,EAAE,UAAkB;IACnE,MAAM,IAAI,GAAG,SAAS,GAAG,UAAU,CAAC;IACpC,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACxE,IAAI,QAAQ,GA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OAAO,CAAC,gCAAgC,EAAE,IAAI,CAAC;SAC/C,OAAO,CAAC,yBAAyB,EAAE,IAAI,CAAC;SACxC,OAAO,CAAC,sDAAsD,EAAE,MAAM,CAAC;SACvE,OAAO,CAAC,6CAA6C,EAAE,MAAM,CAAC;SAC9D,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC;SACxC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC;SACnC,OAAO,CAAC,wCAAwC,EAAE,EAAE,CAAC;SACrD,OAAO,CAAC,wBAAwB,EAAE,MAAM,CAAC;SACzC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;SAC1B,IAAI,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,21 @@
1
+ export interface VoiceCallPageOpts {
2
+ pairingId: string;
3
+ agentId: string;
4
+ basePath: string;
5
+ /** `voice.turns.maxUtteranceMs`: the client ends a turn before the server would reject it. */
6
+ maxUtteranceMs: number;
7
+ /** The bot's Telegram name; the agent id when Telegram has not answered. */
8
+ botName?: string;
9
+ /** The bot photo's Telegram `file_unique_id`; without one the page shows the name's initial. */
10
+ avatarVersion?: string;
11
+ /** The link already holds a call. Only the page holding its call token (a reload of
12
+ * that call) rejoins; any other open shows the link as used and starts nothing. */
13
+ linkUsed?: boolean;
14
+ }
15
+ /** The page's refusal for a link that was used, or that expired or never existed. */
16
+ export declare const VOICE_CALL_LINK_USED: string;
17
+ export declare const VOICE_CALL_LINK_EXPIRED: string;
18
+ export declare function generateVoiceCallPage(opts: VoiceCallPageOpts): string;
19
+ /** A link that expired or never existed: only how it ended, in the call screen's theme. */
20
+ export declare function generateVoiceCallGonePage(message: string): string;
21
+ //# sourceMappingURL=voice-call-ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-call-ui.d.ts","sourceRoot":"","sources":["../../src/ui/voice-call-ui.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,cAAc,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gGAAgG;IAChG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;uFACmF;IACnF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qFAAqF;AACrF,eAAO,MAAM,oBAAoB,QAAmG,CAAC;AACrI,eAAO,MAAM,uBAAuB,QAAsE,CAAC;AAuI3G,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CA8UrE;AAED,2FAA2F;AAC3F,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIjE"}