@0xmaxma/claude-gateway 2.0.21 → 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.
- package/dist/agent/command-help.d.ts.map +1 -1
- package/dist/agent/command-help.js +2 -0
- package/dist/agent/command-help.js.map +1 -1
- package/dist/agent/runner.d.ts +13 -1
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +57 -7
- package/dist/agent/runner.js.map +1 -1
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +13 -1
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +3 -59
- package/dist/api/router.js.map +1 -1
- package/dist/api/voice-call-router.d.ts +21 -0
- package/dist/api/voice-call-router.d.ts.map +1 -0
- package/dist/api/voice-call-router.js +119 -0
- package/dist/api/voice-call-router.js.map +1 -0
- package/dist/api/voice-router.d.ts +27 -0
- package/dist/api/voice-router.d.ts.map +1 -1
- package/dist/api/voice-router.js +126 -63
- package/dist/api/voice-router.js.map +1 -1
- package/dist/api/voice-settings-router.d.ts.map +1 -1
- package/dist/api/voice-settings-router.js +3 -1
- package/dist/api/voice-settings-router.js.map +1 -1
- package/dist/build-provenance.json +4 -4
- package/dist/cli-viewer/pairing-store.d.ts +4 -0
- package/dist/cli-viewer/pairing-store.d.ts.map +1 -1
- package/dist/cli-viewer/pairing-store.js +6 -6
- package/dist/cli-viewer/pairing-store.js.map +1 -1
- package/dist/cli-viewer/telegram-initdata.d.ts +1 -1
- package/dist/cli-viewer/telegram-initdata.d.ts.map +1 -1
- package/dist/cli-viewer/telegram-initdata.js +2 -2
- package/dist/cli-viewer/telegram-initdata.js.map +1 -1
- package/dist/cli-viewer/url.d.ts +2 -0
- package/dist/cli-viewer/url.d.ts.map +1 -1
- package/dist/cli-viewer/url.js +6 -0
- package/dist/cli-viewer/url.js.map +1 -1
- package/dist/orchestration/bridge.d.ts.map +1 -1
- package/dist/orchestration/bridge.js +2 -1
- package/dist/orchestration/bridge.js.map +1 -1
- package/dist/orchestration/config.d.ts +30 -0
- package/dist/orchestration/config.d.ts.map +1 -1
- package/dist/orchestration/config.js +4 -3
- package/dist/orchestration/config.js.map +1 -1
- package/dist/orchestration/conversation-intake.d.ts.map +1 -1
- package/dist/orchestration/conversation-intake.js +3 -1
- package/dist/orchestration/conversation-intake.js.map +1 -1
- package/dist/orchestration/display-stream.d.ts +6 -0
- package/dist/orchestration/display-stream.d.ts.map +1 -1
- package/dist/orchestration/display-stream.js +13 -8
- package/dist/orchestration/display-stream.js.map +1 -1
- package/dist/orchestration/identity.d.ts +5 -1
- package/dist/orchestration/identity.d.ts.map +1 -1
- package/dist/orchestration/identity.js +6 -0
- package/dist/orchestration/identity.js.map +1 -1
- package/dist/orchestration/live-voice-transcript.d.ts +13 -0
- package/dist/orchestration/live-voice-transcript.d.ts.map +1 -0
- package/dist/orchestration/live-voice-transcript.js +36 -0
- package/dist/orchestration/live-voice-transcript.js.map +1 -0
- package/dist/orchestration/runtime.d.ts +11 -1
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +74 -20
- package/dist/orchestration/runtime.js.map +1 -1
- package/dist/orchestration/speech.d.ts.map +1 -1
- package/dist/orchestration/speech.js +9 -4
- package/dist/orchestration/speech.js.map +1 -1
- package/dist/orchestration/telegram-voices.d.ts +4 -0
- package/dist/orchestration/telegram-voices.d.ts.map +1 -1
- package/dist/orchestration/telegram-voices.js +6 -2
- package/dist/orchestration/telegram-voices.js.map +1 -1
- package/dist/telegram/access.d.ts +23 -0
- package/dist/telegram/access.d.ts.map +1 -0
- package/dist/telegram/access.js +105 -0
- package/dist/telegram/access.js.map +1 -0
- package/dist/ui/cli-viewer-ui.d.ts +5 -0
- package/dist/ui/cli-viewer-ui.d.ts.map +1 -1
- package/dist/ui/cli-viewer-ui.js +9 -6
- package/dist/ui/cli-viewer-ui.js.map +1 -1
- package/dist/ui/voice-call-client.d.ts +142 -0
- package/dist/ui/voice-call-client.d.ts.map +1 -0
- package/dist/ui/voice-call-client.js +328 -0
- package/dist/ui/voice-call-client.js.map +1 -0
- package/dist/ui/voice-call-ui.d.ts +21 -0
- package/dist/ui/voice-call-ui.d.ts.map +1 -0
- package/dist/ui/voice-call-ui.js +488 -0
- package/dist/ui/voice-call-ui.js.map +1 -0
- package/dist/voice/audio-tags.d.ts +7 -0
- package/dist/voice/audio-tags.d.ts.map +1 -0
- package/dist/voice/audio-tags.js +66 -0
- package/dist/voice/audio-tags.js.map +1 -0
- package/dist/voice/call-pairing.d.ts +76 -0
- package/dist/voice/call-pairing.d.ts.map +1 -0
- package/dist/voice/call-pairing.js +126 -0
- package/dist/voice/call-pairing.js.map +1 -0
- package/dist/voice/diagnostics.d.ts +12 -9
- package/dist/voice/diagnostics.d.ts.map +1 -1
- package/dist/voice/diagnostics.js +2 -1
- package/dist/voice/diagnostics.js.map +1 -1
- package/dist/voice/errors.d.ts +1 -1
- package/dist/voice/errors.d.ts.map +1 -1
- package/dist/voice/errors.js +4 -0
- package/dist/voice/errors.js.map +1 -1
- package/dist/voice/fast-ack.d.ts +27 -0
- package/dist/voice/fast-ack.d.ts.map +1 -0
- package/dist/voice/fast-ack.js +52 -0
- package/dist/voice/fast-ack.js.map +1 -0
- package/dist/voice/providers/elevenlabs-tts.d.ts +1 -0
- package/dist/voice/providers/elevenlabs-tts.d.ts.map +1 -1
- package/dist/voice/providers/elevenlabs-tts.js +62 -12
- package/dist/voice/providers/elevenlabs-tts.js.map +1 -1
- package/dist/voice/providers/gemini.d.ts +4 -0
- package/dist/voice/providers/gemini.d.ts.map +1 -1
- package/dist/voice/providers/gemini.js +7 -1
- package/dist/voice/providers/gemini.js.map +1 -1
- package/dist/voice/providers/registry.d.ts.map +1 -1
- package/dist/voice/providers/registry.js +34 -2
- package/dist/voice/providers/registry.js.map +1 -1
- package/dist/voice/scope.d.ts +13 -0
- package/dist/voice/scope.d.ts.map +1 -0
- package/dist/voice/scope.js +3 -0
- package/dist/voice/scope.js.map +1 -0
- package/dist/voice/session.d.ts +16 -1
- package/dist/voice/session.d.ts.map +1 -1
- package/dist/voice/session.js +90 -16
- package/dist/voice/session.js.map +1 -1
- package/dist/voice/telegram-avatar.d.ts +38 -0
- package/dist/voice/telegram-avatar.d.ts.map +1 -0
- package/dist/voice/telegram-avatar.js +95 -0
- package/dist/voice/telegram-avatar.js.map +1 -0
- package/mcp/tools/telegram/pure.ts +1 -1
- package/mcp/tools/telegram/receiver-server.ts +23 -1
- package/package.json +1 -1
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VOICE_CALL_LINK_EXPIRED = exports.VOICE_CALL_LINK_USED = void 0;
|
|
4
|
+
exports.generateVoiceCallPage = generateVoiceCallPage;
|
|
5
|
+
exports.generateVoiceCallGonePage = generateVoiceCallGonePage;
|
|
6
|
+
/**
|
|
7
|
+
* Telegram `/call` Mini App: a live voice call with one agent, bound to the DM
|
|
8
|
+
* the button was sent in. The page proves the Telegram user with signed initData
|
|
9
|
+
* on every ticket request, then speaks the documented voice WebSocket protocol
|
|
10
|
+
* (see website/api/voice.md). All URLs derive from `basePath`, the path of
|
|
11
|
+
* `gateway.publicUrl`, and the WebSocket path comes from the ticket response.
|
|
12
|
+
*/
|
|
13
|
+
const cli_viewer_ui_1 = require("./cli-viewer-ui");
|
|
14
|
+
const voice_call_client_1 = require("./voice-call-client");
|
|
15
|
+
/** The page's refusal for a link that was used, or that expired or never existed. */
|
|
16
|
+
exports.VOICE_CALL_LINK_USED = (0, voice_call_client_1.voiceCallTicketFailure)(409, { error: 'Call link already used', code: 'CALL_LINK_USED' }).message;
|
|
17
|
+
exports.VOICE_CALL_LINK_EXPIRED = (0, voice_call_client_1.voiceCallTicketFailure)(410, { error: 'Call link expired' }).message;
|
|
18
|
+
/** Collects ~40 ms of microphone samples per message at the context rate. */
|
|
19
|
+
const CAPTURE_WORKLET = `class VoiceCallCapture extends AudioWorkletProcessor {
|
|
20
|
+
constructor(){ super(); this.size = Math.round(sampleRate * 0.04); this.buffer = new Float32Array(this.size); this.used = 0; }
|
|
21
|
+
process(inputs){
|
|
22
|
+
const input = inputs[0] && inputs[0][0];
|
|
23
|
+
if (!input) return true;
|
|
24
|
+
let offset = 0;
|
|
25
|
+
while (offset < input.length) {
|
|
26
|
+
const count = Math.min(this.size - this.used, input.length - offset);
|
|
27
|
+
this.buffer.set(input.subarray(offset, offset + count), this.used);
|
|
28
|
+
this.used += count; offset += count;
|
|
29
|
+
if (this.used === this.size) { this.port.postMessage(this.buffer.slice(0)); this.used = 0; }
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
registerProcessor('voice-call-capture', VoiceCallCapture);`;
|
|
35
|
+
/**
|
|
36
|
+
* Light and dark palettes. Telegram's theme colours lead where it gives them (it
|
|
37
|
+
* sets `--tg-theme-*` on the page); the fallbacks serve a page outside Telegram.
|
|
38
|
+
* The semantic colours keep their meaning in both: red ends or mutes, blue
|
|
39
|
+
* listens, a brighter blue with a pulsing dot thinks, orange speaks.
|
|
40
|
+
*/
|
|
41
|
+
const STYLE = `${cli_viewer_ui_1.BASE_STYLE}
|
|
42
|
+
:root { color-scheme: dark;
|
|
43
|
+
--vc-bg: var(--tg-theme-bg-color, #0b0e14); --vc-text: var(--tg-theme-text-color, #e4e9ff); --vc-hint: var(--tg-theme-hint-color, #8f9bb3);
|
|
44
|
+
--vc-surface: var(--tg-theme-secondary-bg-color, #232a3b); --vc-pressed: #e4e9ff; --vc-on-pressed: #0b0e14;
|
|
45
|
+
--vc-button: #c3e88d; --vc-on-button: #0b0e14;
|
|
46
|
+
--vc-listen: #82aaff; --vc-listen-ring: rgba(130,170,255,.35); --vc-listen-glow: rgba(130,170,255,.08); --vc-think: #4ade80;
|
|
47
|
+
--vc-speak: #ffa94d; --vc-speak-ring: rgba(255,169,77,.75); --vc-speak-glow: rgba(255,169,77,.14); --vc-speak-halo: rgba(255,169,77,.06);
|
|
48
|
+
--vc-muted: #ff8d95; --vc-end: #ff5c67; --vc-err: #ff757f; }
|
|
49
|
+
:root[data-theme="light"] { color-scheme: light;
|
|
50
|
+
--vc-bg: var(--tg-theme-bg-color, #ffffff); --vc-text: var(--tg-theme-text-color, #1c2333); --vc-hint: var(--tg-theme-hint-color, #6b7486);
|
|
51
|
+
--vc-surface: var(--tg-theme-secondary-bg-color, #eef0f5); --vc-pressed: #1c2333; --vc-on-pressed: #ffffff;
|
|
52
|
+
--vc-button: #23863f; --vc-on-button: #ffffff;
|
|
53
|
+
--vc-listen: #2560c8; --vc-listen-ring: rgba(37,96,200,.45); --vc-listen-glow: rgba(37,96,200,.10); --vc-think: #13773a;
|
|
54
|
+
--vc-speak: #a84b06; --vc-speak-ring: rgba(240,128,30,.80); --vc-speak-glow: rgba(240,128,30,.18); --vc-speak-halo: rgba(240,128,30,.07);
|
|
55
|
+
--vc-muted: #c22631; --vc-end: #e5484d; --vc-err: #c4202b; }
|
|
56
|
+
/* The call fills the Mini App and never grows past it: the transcript scrolls between a
|
|
57
|
+
* fixed header and fixed controls. Telegram keeps --tg-viewport-stable-height current. */
|
|
58
|
+
body { background: var(--vc-bg); color: var(--vc-text); overflow: hidden;
|
|
59
|
+
height: 100vh; height: 100dvh; height: var(--tg-viewport-stable-height, 100dvh); }
|
|
60
|
+
.muted { color: var(--vc-hint); }
|
|
61
|
+
.err { color: var(--vc-err); }
|
|
62
|
+
.call { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center;
|
|
63
|
+
padding: calc(48px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom)); }
|
|
64
|
+
.head, .foot { flex: none; width: 100%; display: flex; flex-direction: column; align-items: center; }
|
|
65
|
+
.call.gone { justify-content: center; }
|
|
66
|
+
.avatar-wrap { position: relative; width: 132px; height: 132px; display: grid; place-items: center; }
|
|
67
|
+
.ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; transition: border-color .2s, box-shadow .2s; }
|
|
68
|
+
.avatar { width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; font-size: 46px; font-weight: 600; color: #fff;
|
|
69
|
+
position: relative; background: linear-gradient(135deg, #8ea2ff 0%, #6b7cff 55%, #5a5fd8 100%); box-shadow: 0 8px 30px rgba(107,124,255,.25); }
|
|
70
|
+
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
|
|
71
|
+
.name { margin-top: 20px; font-size: 24px; font-weight: 600; color: var(--vc-text); word-break: break-word; }
|
|
72
|
+
.timer { min-height: 22px; margin-top: 6px; font-size: 17px; color: var(--vc-hint); font-variant-numeric: tabular-nums; letter-spacing: .5px; }
|
|
73
|
+
.chip { margin-top: 18px; max-width: 100%; display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 16px; background: var(--vc-surface); color: var(--vc-hint); }
|
|
74
|
+
.chip .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
|
|
75
|
+
.chip .bars { display: none; gap: 3px; align-items: center; height: 14px; }
|
|
76
|
+
.chip .bars b { width: 3px; height: 14px; border-radius: 2px; background: currentColor; transform: scaleY(calc(var(--h) * (0.3 + 0.7 * var(--level, 0)))); transition: transform .1s linear; }
|
|
77
|
+
.chip:has(.state.err) .dot { display: none; }
|
|
78
|
+
.state { font-size: 14px; font-weight: 600; }
|
|
79
|
+
.call.listening .ring { border-color: var(--vc-listen-ring); box-shadow: 0 0 0 8px var(--vc-listen-glow); }
|
|
80
|
+
.call.listening .chip { color: var(--vc-listen); }
|
|
81
|
+
.call.speaking .ring { border-color: var(--vc-speak-ring); box-shadow: 0 0 0 9px var(--vc-speak-glow), 0 0 0 20px var(--vc-speak-halo); }
|
|
82
|
+
.call.speaking .chip { color: var(--vc-speak); }
|
|
83
|
+
.call.speaking .dot { display: none; }
|
|
84
|
+
.call.speaking .bars { display: inline-flex; }
|
|
85
|
+
.call.thinking .chip { color: var(--vc-think); }
|
|
86
|
+
.call.thinking .dot { animation: think 1s ease-in-out infinite alternate; }
|
|
87
|
+
@keyframes think { from { opacity: .25; transform: scale(.7); } }
|
|
88
|
+
.call.muted .chip { color: var(--vc-muted); }
|
|
89
|
+
.lines { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; position: relative;
|
|
90
|
+
margin: 28px 0 8px; padding-bottom: 20px; width: 100%; max-width: 340px;
|
|
91
|
+
-webkit-mask-image: linear-gradient(#000 calc(100% - 20px), transparent); mask-image: linear-gradient(#000 calc(100% - 20px), transparent); }
|
|
92
|
+
.line { min-height: 20px; font-size: 15px; line-height: 1.5; color: var(--vc-text); word-break: break-word; white-space: pre-line; }
|
|
93
|
+
.you { color: var(--vc-listen); }
|
|
94
|
+
.hint { margin: 12px 0 0; }
|
|
95
|
+
.hint[hidden] { display: none; }
|
|
96
|
+
button { font: inherit; font-size: 15px; border: 0; border-radius: 22px; padding: 11px 20px; cursor: pointer; color: var(--vc-on-button); background: var(--vc-button); }
|
|
97
|
+
button:focus-visible { outline: 2px solid var(--vc-listen); outline-offset: 3px; }
|
|
98
|
+
button[hidden], .controls[hidden] { display: none; }
|
|
99
|
+
#start { margin-top: 14px; }
|
|
100
|
+
.controls { margin-top: 22px; display: flex; gap: 30px; justify-content: center; }
|
|
101
|
+
.ctl { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; color: var(--vc-hint); }
|
|
102
|
+
button.round { width: 66px; height: 66px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: var(--vc-surface); color: var(--vc-text); }
|
|
103
|
+
button.round svg { width: 28px; height: 28px; pointer-events: none; }
|
|
104
|
+
button.round[aria-pressed="true"] { background: var(--vc-pressed); color: var(--vc-on-pressed); }
|
|
105
|
+
button.round.end { background: var(--vc-end); color: #fff; }
|
|
106
|
+
button.round .off { display: none; }
|
|
107
|
+
/* Short screens (Telegram Desktop, small phones): a smaller header leaves the transcript room. */
|
|
108
|
+
@media (max-height: 720px) {
|
|
109
|
+
.call { padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
|
|
110
|
+
.avatar-wrap { width: 96px; height: 96px; }
|
|
111
|
+
.avatar { width: 80px; height: 80px; font-size: 34px; }
|
|
112
|
+
.name { margin-top: 12px; font-size: 20px; }
|
|
113
|
+
.chip { margin-top: 10px; }
|
|
114
|
+
.lines { margin-top: 16px; }
|
|
115
|
+
.controls { margin-top: 14px; }
|
|
116
|
+
button.round { width: 60px; height: 60px; }
|
|
117
|
+
}
|
|
118
|
+
#speaker[aria-pressed="false"] .on, #mute[aria-pressed="true"] .on { display: none; }
|
|
119
|
+
#speaker[aria-pressed="false"] .off, #mute[aria-pressed="true"] .off { display: block; }
|
|
120
|
+
`;
|
|
121
|
+
/** Sets the palette before the page paints and follows Telegram's (or the system's)
|
|
122
|
+
* theme changes. Telegram's header and the area around the page take the page background. */
|
|
123
|
+
const THEME_SCRIPT = `<script>
|
|
124
|
+
(function(){
|
|
125
|
+
${voice_call_client_1.voiceCallTheme.toString()};
|
|
126
|
+
var tg = window.Telegram && window.Telegram.WebApp, root = document.documentElement;
|
|
127
|
+
var system = window.matchMedia && window.matchMedia('(prefers-color-scheme: light)');
|
|
128
|
+
function apply(){
|
|
129
|
+
var theme = voiceCallTheme(tg, Boolean(system && system.matches));
|
|
130
|
+
root.setAttribute('data-theme', theme); root.style.colorScheme = theme;
|
|
131
|
+
if (tg) { try { if (tg.setHeaderColor) tg.setHeaderColor('bg_color'); if (tg.setBackgroundColor) tg.setBackgroundColor('bg_color'); } catch (e) {} }
|
|
132
|
+
}
|
|
133
|
+
apply();
|
|
134
|
+
if (tg && tg.onEvent) tg.onEvent('themeChanged', apply);
|
|
135
|
+
if (system && system.addEventListener) system.addEventListener('change', apply);
|
|
136
|
+
})();
|
|
137
|
+
</script>`;
|
|
138
|
+
const icon = (cls, paths) => `<svg class="${cls}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${paths}</svg>`;
|
|
139
|
+
const SPEAKER = '<path d="M11 5L6 9H3v6h3l5 4V5z"/>';
|
|
140
|
+
const ICONS = {
|
|
141
|
+
speakerOn: icon('on', `${SPEAKER}<path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M18.5 5.5a9 9 0 0 1 0 13"/>`),
|
|
142
|
+
speakerOff: icon('off', `${SPEAKER}<path d="M16 9l5 6M21 9l-5 6"/>`),
|
|
143
|
+
mic: icon('on', '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 18v3"/>'),
|
|
144
|
+
micOff: icon('off', '<path d="M3 3l18 18"/><path d="M9 9v2a3 3 0 0 0 5.1 2.1"/><path d="M15 9.3V6a3 3 0 0 0-5.7-1.3"/><path d="M5 11a7 7 0 0 0 11.4 5.4"/><path d="M19 11a7 7 0 0 1-.4 2.3"/><path d="M12 18v3"/>'),
|
|
145
|
+
end: '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" style="transform: rotate(135deg)"><path d="M6.6 10.8a15.1 15.1 0 0 0 6.6 6.6l2.2-2.2a1 1 0 0 1 1-.25 11.4 11.4 0 0 0 3.6.57 1 1 0 0 1 1 1V20a1 1 0 0 1-1 1A17 17 0 0 1 3 4a1 1 0 0 1 1-1h3.5a1 1 0 0 1 1 1c0 1.25.2 2.45.57 3.57a1 1 0 0 1-.25 1z"/></svg>',
|
|
146
|
+
};
|
|
147
|
+
function generateVoiceCallPage(opts) {
|
|
148
|
+
const cfg = JSON.stringify({ pairingId: opts.pairingId, basePath: opts.basePath, maxUtteranceMs: opts.maxUtteranceMs, vad: voice_call_client_1.VOICE_CALL_VAD, linkUsed: Boolean(opts.linkUsed) }).replace(/</g, '\\u003c');
|
|
149
|
+
const client = [voice_call_client_1.createResampler, voice_call_client_1.encodeVoiceCallFrame, voice_call_client_1.voiceCallLevel, voice_call_client_1.createVoiceCallVad, voice_call_client_1.createVoiceCallUplink, voice_call_client_1.createVoiceCallPlayhead, voice_call_client_1.voiceCallTicketFailure, voice_call_client_1.formatCallDuration, voice_call_client_1.voiceCallErrorView, voice_call_client_1.voiceCallReplyText].map(fn => fn.toString()).join(';\n');
|
|
150
|
+
const name = opts.botName ?? opts.agentId;
|
|
151
|
+
const initial = Array.from(name.trim())[0]?.toUpperCase() ?? '?';
|
|
152
|
+
const photo = opts.avatarVersion ? `${opts.basePath}/voice-call/${encodeURIComponent(opts.pairingId)}/avatar?v=${encodeURIComponent(opts.avatarVersion)}` : '';
|
|
153
|
+
const used = Boolean(opts.linkUsed);
|
|
154
|
+
const body = `${THEME_SCRIPT}
|
|
155
|
+
<div class="call" id="call">
|
|
156
|
+
<div class="head">
|
|
157
|
+
<div class="avatar-wrap"><div class="ring"></div><div class="avatar" id="avatar" aria-hidden="true">${(0, cli_viewer_ui_1.htmlEscape)(initial)}${photo ? `<img id="photo" alt="" src="${(0, cli_viewer_ui_1.htmlEscape)(photo)}">` : ''}</div></div>
|
|
158
|
+
<div class="name">${(0, cli_viewer_ui_1.htmlEscape)(name)}</div>
|
|
159
|
+
<div class="timer" id="timer"></div>
|
|
160
|
+
<div class="chip" role="status"><span class="dot"></span><span class="bars"><b style="--h:.45"></b><b style="--h:.85"></b><b style="--h:.65"></b><b style="--h:1"></b><b style="--h:.5"></b></span>${used ? `<span class="state err" id="state">${(0, cli_viewer_ui_1.htmlEscape)(exports.VOICE_CALL_LINK_USED)}</span>` : '<span class="state" id="state">Starting…</span>'}</div>
|
|
161
|
+
</div>
|
|
162
|
+
<div class="lines" id="lines"><div class="line you" id="you"></div><div class="line" id="reply"></div></div>
|
|
163
|
+
<div class="foot">
|
|
164
|
+
<p class="muted hint" id="hint"${used ? ' hidden' : ''}>Your words and the replies also appear in the chat.</p>
|
|
165
|
+
<button type="button" id="start" hidden>Start call</button>
|
|
166
|
+
<div class="controls" id="controls" hidden>
|
|
167
|
+
<div class="ctl"><button type="button" class="round" id="speaker" aria-label="Speaker" aria-pressed="true">${ICONS.speakerOn}${ICONS.speakerOff}</button><span aria-hidden="true">speaker</span></div>
|
|
168
|
+
<div class="ctl"><button type="button" class="round end" id="hangup" aria-label="End call">${ICONS.end}</button><span aria-hidden="true">end</span></div>
|
|
169
|
+
<div class="ctl"><button type="button" class="round" id="mute" aria-label="Mute" aria-pressed="false">${ICONS.mic}${ICONS.micOff}</button><span aria-hidden="true">mute</span></div>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
<script>
|
|
174
|
+
(function(){
|
|
175
|
+
'use strict';
|
|
176
|
+
var CFG = ${cfg};
|
|
177
|
+
var WORKLET = ${JSON.stringify(CAPTURE_WORKLET).replace(/</g, '\\u003c')};
|
|
178
|
+
${client};
|
|
179
|
+
var tg = window.Telegram && window.Telegram.WebApp;
|
|
180
|
+
var $ = function(id){ return document.getElementById(id); };
|
|
181
|
+
var ctx, media, capture, ws, uplink, vad, resample, progressTimer, level, levelSamples, speaker;
|
|
182
|
+
var playhead = createVoiceCallPlayhead(), sources = [];
|
|
183
|
+
var callToken, generation, epoch = 0, reportedPlayed = 0;
|
|
184
|
+
var muted = false, paused = false, ended = false, attempts = 0, speakerOn = true, shownLevel, muteOnListening = false;
|
|
185
|
+
// One connect at a time: a hide, show, hang-up or newer connect discards the pending one and its reconnect timer.
|
|
186
|
+
var connecting = 0, reconnectTimer;
|
|
187
|
+
// The user stopped speaking: show Thinking at once, through the gateway's commit and
|
|
188
|
+
// merge window and the agent's turn, until it answers, reports no speech, or the user speaks again.
|
|
189
|
+
var awaitingReply = false;
|
|
190
|
+
// The call clock: set when a socket first listens, from the server's elapsed time
|
|
191
|
+
// on a rejoin, so it keeps counting across reconnects like a phone call.
|
|
192
|
+
var callStart, offeredElapsed = 0, joined = false;
|
|
193
|
+
// The ring and chip follow the call: listening, thinking, the agent speaking, or muted.
|
|
194
|
+
var SCENES = { Listening: 'listening', Thinking: 'thinking', Speaking: 'speaking', Muted: 'muted' };
|
|
195
|
+
var scene;
|
|
196
|
+
function state(text, tone){
|
|
197
|
+
var s = $('state'); s.textContent = text; s.className = 'state' + (tone ? ' ' + tone : '');
|
|
198
|
+
scene = !tone && SCENES[text] ? text : undefined;
|
|
199
|
+
$('call').className = 'call' + (scene ? ' ' + SCENES[scene] : '');
|
|
200
|
+
}
|
|
201
|
+
// Speaking ends when the reply has played out and stayed quiet for QUIET_MS, longer than
|
|
202
|
+
// the pause between its sentences. After an acknowledgement the answer is still coming.
|
|
203
|
+
var QUIET_MS = 1000, playbackPhase, audioHeard = false, quietSince;
|
|
204
|
+
function settlePlayback(){
|
|
205
|
+
if (scene !== 'Speaking' || !audioHeard || playhead.playing(ctx.currentTime)) { quietSince = undefined; return; }
|
|
206
|
+
if (quietSince === undefined) quietSince = Date.now();
|
|
207
|
+
if (Date.now() - quietSince >= QUIET_MS) state(muted ? 'Muted' : awaitingReply || playbackPhase === 'acknowledgement' ? 'Thinking' : 'Listening');
|
|
208
|
+
}
|
|
209
|
+
// The transcript follows new text unless the caller scrolled up to read; scrolling
|
|
210
|
+
// back down to where it was follows again. A reply opens at its first line, as it is
|
|
211
|
+
// spoken; the caller's words show their latest.
|
|
212
|
+
var follow = true, followTop = 0, lines = $('lines');
|
|
213
|
+
lines.onscroll = function(){ if (lines.scrollTop < followTop - 2) follow = false; else { follow = true; followTop = lines.scrollTop; } };
|
|
214
|
+
function show(id, text){
|
|
215
|
+
var line = $(id); line.textContent = text;
|
|
216
|
+
if (!follow) return;
|
|
217
|
+
lines.scrollTop = id === 'reply' ? line.offsetTop : Math.max(0, line.offsetTop + line.offsetHeight - lines.clientHeight);
|
|
218
|
+
followTop = lines.scrollTop;
|
|
219
|
+
}
|
|
220
|
+
function api(path){ return CFG.basePath + '/voice-call/' + CFG.pairingId + path; }
|
|
221
|
+
function send(message){ if (ws && ws.readyState === 1) ws.send(JSON.stringify(message)); }
|
|
222
|
+
async function ticket(){
|
|
223
|
+
var response = await fetch(api('/ticket'), { method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'same-origin',
|
|
224
|
+
body: JSON.stringify({ initData: tg.initData, call_token: callToken }) })
|
|
225
|
+
.catch(function(){ var offline = new Error('The network is unavailable.'); offline.fatal = false; throw offline; });
|
|
226
|
+
var body = await response.json().catch(function(){ return {}; });
|
|
227
|
+
if (body.call_token) callToken = body.call_token;
|
|
228
|
+
if (!response.ok) {
|
|
229
|
+
var failure = voiceCallTicketFailure(response.status, body), error = new Error(failure.message);
|
|
230
|
+
error.fatal = failure.fatal; error.signIn = failure.signIn;
|
|
231
|
+
throw error;
|
|
232
|
+
}
|
|
233
|
+
return body;
|
|
234
|
+
}
|
|
235
|
+
function flushPlayback(){ sources.forEach(function(node){ try { node.stop(); } catch (e) {} }); sources = []; playhead.reset(); reportedPlayed = 0; }
|
|
236
|
+
function playAudio(data){
|
|
237
|
+
var view = new DataView(data);
|
|
238
|
+
if (data.byteLength <= 44 || view.getUint32(20) !== epoch) return;
|
|
239
|
+
var count = (data.byteLength - 44) / 2, buffer = ctx.createBuffer(1, count, 16000), channel = buffer.getChannelData(0);
|
|
240
|
+
for (var i = 0; i < count; i++) channel[i] = view.getInt16(44 + i * 2, true) / 32768;
|
|
241
|
+
var node = ctx.createBufferSource(); node.buffer = buffer; node.connect(level);
|
|
242
|
+
node.onended = function(){ sources = sources.filter(function(item){ return item !== node; }); };
|
|
243
|
+
node.start(playhead.schedule(count, 16000, ctx.currentTime)); sources.push(node);
|
|
244
|
+
// More of the reply after a pause that looked like its end.
|
|
245
|
+
audioHeard = true; if (scene === 'Listening' || scene === 'Thinking') state('Speaking');
|
|
246
|
+
}
|
|
247
|
+
function reportProgress(){
|
|
248
|
+
if (!ctx || !ws || ws.readyState !== 1) return;
|
|
249
|
+
var played = playhead.played(16000, ctx.currentTime);
|
|
250
|
+
if (played > reportedPlayed) { reportedPlayed = played; send({ type: 'playback.progress', epoch: epoch, sample_offset: played }); }
|
|
251
|
+
}
|
|
252
|
+
function control(message){
|
|
253
|
+
switch (message.type) {
|
|
254
|
+
case 'voice.state':
|
|
255
|
+
if (message.generation) generation = message.generation;
|
|
256
|
+
if ((message.state === 'listening' || message.state === 'muted') && !joined) { joined = true; callStart = Date.now() - offeredElapsed; showDuration(); }
|
|
257
|
+
if (message.state === 'listening') {
|
|
258
|
+
attempts = 0; if (message.utterance_id) uplink.listening(message.utterance_id);
|
|
259
|
+
// Words held for this utterance are sent now; muting then commits them.
|
|
260
|
+
if (muteOnListening) { muteOnListening = false; sendMute(true); }
|
|
261
|
+
if (!sources.length && !awaitingReply) state(muted ? 'Muted' : 'Listening');
|
|
262
|
+
}
|
|
263
|
+
if (message.state === 'muted') { uplink.reset(); awaitingReply = false; state('Muted'); }
|
|
264
|
+
break;
|
|
265
|
+
case 'stt.partial': case 'stt.segment': show('you', message.pending_text || message.text || ''); break;
|
|
266
|
+
case 'stt.final': show('you', message.text); awaitingReply = true; state('Thinking'); break;
|
|
267
|
+
case 'utterance.accepted': state('Thinking'); break;
|
|
268
|
+
case 'response.text': if (message.text) show('reply', voiceCallReplyText(message.text)); break;
|
|
269
|
+
case 'playback.start': epoch = message.epoch; flushPlayback(); awaitingReply = false; playbackPhase = message.phase; audioHeard = false; state('Speaking'); break;
|
|
270
|
+
case 'playback.end': break;
|
|
271
|
+
case 'playback.clear': epoch = message.epoch; flushPlayback(); send({ type: 'playback.clear.ack', epoch: epoch }); if (!awaitingReply) state(muted ? 'Muted' : 'Listening'); break;
|
|
272
|
+
case 'voice.notice': if (message.reconnect) state('Reconnecting…'); break;
|
|
273
|
+
case 'voice.error': {
|
|
274
|
+
var view = voiceCallErrorView(message);
|
|
275
|
+
awaitingReply = false;
|
|
276
|
+
if (view.kind === 'ended') fail(new Error(view.message));
|
|
277
|
+
else if (view.kind === 'listening') { show('you', ''); if (!sources.length) state(muted ? 'Muted' : 'Listening'); }
|
|
278
|
+
else state(view.message, 'err');
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
async function connect(){
|
|
284
|
+
var mine = ++connecting, issued;
|
|
285
|
+
// A discarded connect neither opens a socket nor reports its failure.
|
|
286
|
+
try { issued = await ticket(); } catch (error) { if (mine !== connecting) return; throw error; }
|
|
287
|
+
if (mine !== connecting || ended || paused) return;
|
|
288
|
+
offeredElapsed = typeof issued.call_elapsed_ms === 'number' ? issued.call_elapsed_ms : 0;
|
|
289
|
+
var scheme = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
290
|
+
var socket = new WebSocket(scheme + '//' + location.host + CFG.basePath + issued.stream_path + '?ticket=' + encodeURIComponent(issued.ticket));
|
|
291
|
+
// A new socket starts with the page's mute state; nothing waits on the old utterance.
|
|
292
|
+
ws = socket; joined = false; muteOnListening = false; awaitingReply = false;
|
|
293
|
+
socket.binaryType = 'arraybuffer';
|
|
294
|
+
socket.onopen = function(){ send({ type: 'voice.start', muted: muted }); };
|
|
295
|
+
socket.onmessage = function(event){ if (socket !== ws) return; if (typeof event.data === 'string') control(JSON.parse(event.data)); else playAudio(event.data); };
|
|
296
|
+
socket.onclose = function(event){
|
|
297
|
+
// A socket replaced by a reconnect no longer owns the call state.
|
|
298
|
+
if (socket !== ws) return;
|
|
299
|
+
uplink.reset(); flushPlayback();
|
|
300
|
+
if (ended || paused) return;
|
|
301
|
+
// 1012: the recognizer restarted; 1006: the network dropped. Take a fresh ticket.
|
|
302
|
+
if (event.code === 1012 || event.code === 1006) { reconnect(); return; }
|
|
303
|
+
if (event.code === 1008) fail(new Error('Access changed. Send /call again.'));
|
|
304
|
+
else { var lost = new Error('The call was disconnected.'); lost.fatal = false; fail(lost); }
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
// A dropped socket's lease can take a moment to clear: retry transient ticket errors with backoff.
|
|
308
|
+
function reconnect(){
|
|
309
|
+
if (ended || paused) return;
|
|
310
|
+
if (attempts >= 5) { var lost = new Error('The call was disconnected.'); lost.fatal = false; fail(lost); return; }
|
|
311
|
+
attempts++; state('Reconnecting…');
|
|
312
|
+
reconnectTimer = setTimeout(function(){ reconnectTimer = undefined; connect().catch(function(error){ if (error.fatal === false) reconnect(); else fail(error); }); }, 500 * attempts);
|
|
313
|
+
}
|
|
314
|
+
function cancelConnect(){ clearTimeout(reconnectTimer); reconnectTimer = undefined; connecting++; }
|
|
315
|
+
function fail(error){
|
|
316
|
+
state(error.message || 'The call could not continue.', 'err');
|
|
317
|
+
if (error.signIn) {
|
|
318
|
+
// Reloading lets the proxy redirect to its login page and back to this URL,
|
|
319
|
+
// as the first open did; the fragment keeps Telegram's initData.
|
|
320
|
+
hangup(true);
|
|
321
|
+
var signIn = $('start'); signIn.textContent = 'Sign in again'; signIn.hidden = false;
|
|
322
|
+
signIn.onclick = function(){ location.reload(); };
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (error.fatal !== false) { hangup(true); return; }
|
|
326
|
+
// Keep the microphone grant; retry with the same call token.
|
|
327
|
+
var retry = $('start'); retry.textContent = 'Retry'; retry.hidden = false;
|
|
328
|
+
retry.onclick = function(){ retry.hidden = true; attempts = 0; state('Reconnecting…'); connect().catch(fail); };
|
|
329
|
+
}
|
|
330
|
+
// The speaking bars follow the agent's actual output level.
|
|
331
|
+
function showLevel(){
|
|
332
|
+
if (!level) return;
|
|
333
|
+
level.getFloatTimeDomainData(levelSamples);
|
|
334
|
+
var text = (sources.length ? Math.min(1, voiceCallLevel(levelSamples) * 5) : 0).toFixed(1);
|
|
335
|
+
if (text !== shownLevel) { shownLevel = text; $('call').style.setProperty('--level', text); }
|
|
336
|
+
}
|
|
337
|
+
// A web page cannot choose the earpiece or the loudspeaker; Speaker turns the agent's voice on or off.
|
|
338
|
+
function setSpeaker(on){
|
|
339
|
+
speakerOn = on;
|
|
340
|
+
if (speaker) speaker.gain.value = on ? 1 : 0;
|
|
341
|
+
$('speaker').setAttribute('aria-pressed', String(on));
|
|
342
|
+
}
|
|
343
|
+
function showDuration(){
|
|
344
|
+
if (callStart === undefined) return;
|
|
345
|
+
var text = formatCallDuration(Date.now() - callStart), timer = $('timer');
|
|
346
|
+
if (timer.textContent !== text) timer.textContent = text;
|
|
347
|
+
}
|
|
348
|
+
// Mute sends what was said: the open utterance is committed now and the agent answers it.
|
|
349
|
+
function sendMute(value){
|
|
350
|
+
var sequence = uplink.pendingSequence();
|
|
351
|
+
send({ type: 'voice.mute', muted: value, policy: 'commit', last_audio_seq: value && sequence ? sequence : 0 });
|
|
352
|
+
if (value) uplink.reset();
|
|
353
|
+
}
|
|
354
|
+
function setMuted(value){
|
|
355
|
+
if (muted === value) return;
|
|
356
|
+
muted = value; awaitingReply = false;
|
|
357
|
+
// Words spoken while the last utterance commits are held for the next one: mute once they are sent.
|
|
358
|
+
if (value && uplink.holding()) muteOnListening = true;
|
|
359
|
+
else if (!value && muteOnListening) muteOnListening = false;
|
|
360
|
+
else sendMute(value);
|
|
361
|
+
if (!value) vad = createVoiceCallVad(CFG.vad);
|
|
362
|
+
media.getAudioTracks().forEach(function(track){ track.enabled = !value; });
|
|
363
|
+
$('mute').setAttribute('aria-pressed', String(value));
|
|
364
|
+
state(value ? 'Muted' : 'Listening');
|
|
365
|
+
}
|
|
366
|
+
// A hidden Mini App cannot hear or be heard reliably (iOS cuts the mic). Leave the
|
|
367
|
+
// call while hidden, so replies reach the chat as they would without a call, and
|
|
368
|
+
// rejoin with the call token on return. Before the call is set up (the page waits
|
|
369
|
+
// for the Start call tap) there is nothing to leave.
|
|
370
|
+
function suspend(){
|
|
371
|
+
if (!uplink || ended || paused) return;
|
|
372
|
+
paused = true; cancelConnect(); uplink.reset(); flushPlayback();
|
|
373
|
+
media.getAudioTracks().forEach(function(track){ track.enabled = false; });
|
|
374
|
+
if (ws) { send({ type: 'voice.stop' }); ws.close(); }
|
|
375
|
+
state('Paused');
|
|
376
|
+
}
|
|
377
|
+
function resume(){
|
|
378
|
+
if (!paused || ended || document.visibilityState !== 'visible') return;
|
|
379
|
+
paused = false; cancelConnect(); attempts = 0; vad = createVoiceCallVad(CFG.vad);
|
|
380
|
+
media.getAudioTracks().forEach(function(track){ track.enabled = !muted; });
|
|
381
|
+
state('Reconnecting…'); connect().catch(fail);
|
|
382
|
+
}
|
|
383
|
+
function hangup(silent){
|
|
384
|
+
if (ended) return;
|
|
385
|
+
showDuration(); ended = true; cancelConnect(); clearInterval(progressTimer);
|
|
386
|
+
// hangup ends the call for the server too; a plain stop (the app hidden) may rejoin.
|
|
387
|
+
send({ type: 'voice.stop', hangup: true }); if (ws) ws.close();
|
|
388
|
+
if (media) media.getTracks().forEach(function(track){ track.stop(); });
|
|
389
|
+
if (ctx) ctx.close().catch(function(){});
|
|
390
|
+
if (tg && tg.disableClosingConfirmation) tg.disableClosingConfirmation();
|
|
391
|
+
$('controls').hidden = true;
|
|
392
|
+
if (!silent) { state('Call ended'); if (tg && tg.close) setTimeout(function(){ tg.close(); }, 600); }
|
|
393
|
+
}
|
|
394
|
+
// Telegram's Android WebView needs a tap before audio can play or be captured
|
|
395
|
+
// (setMediaPlaybackRequiresUserGesture until the first touch); iOS does not.
|
|
396
|
+
function askTap(){
|
|
397
|
+
state('Tap Start call to begin.');
|
|
398
|
+
var button = $('start'); button.textContent = 'Start call'; button.hidden = false;
|
|
399
|
+
button.onclick = function(){ if (ctx) ctx.resume().catch(function(){}); start(true); };
|
|
400
|
+
}
|
|
401
|
+
// AudioContext.resume() stays pending while audio is blocked.
|
|
402
|
+
function audioRunning(){
|
|
403
|
+
return Promise.race([ctx.resume().catch(function(){}), new Promise(function(resolve){ setTimeout(resolve, 800); })])
|
|
404
|
+
.then(function(){ return ctx.state === 'running'; });
|
|
405
|
+
}
|
|
406
|
+
// The page starts the call as it opens; gesture is a retry from the Start button.
|
|
407
|
+
async function start(gesture){
|
|
408
|
+
$('start').hidden = true;
|
|
409
|
+
if (!tg || !tg.initData) { state('Open this page from the /call button in Telegram.', 'err'); return; }
|
|
410
|
+
if (!window.isSecureContext || !navigator.mediaDevices || !navigator.mediaDevices.getUserMedia || !window.AudioWorkletNode) {
|
|
411
|
+
state('This Telegram app cannot use the microphone here. Update Telegram or try another device.', 'err'); return;
|
|
412
|
+
}
|
|
413
|
+
state('Starting…');
|
|
414
|
+
// The page proposes its call token, so a ticket response lost on the network can be retried.
|
|
415
|
+
// It survives the reload of Sign in again, which would otherwise find its own link already used.
|
|
416
|
+
var key = 'voice-call:' + CFG.pairingId;
|
|
417
|
+
try { callToken = callToken || sessionStorage.getItem(key) || undefined; } catch (e) {}
|
|
418
|
+
if (!callToken) callToken = Array.prototype.map.call(crypto.getRandomValues(new Uint8Array(32)), function(byte){ return ('0' + byte.toString(16)).slice(-2); }).join('');
|
|
419
|
+
try { sessionStorage.setItem(key, callToken); } catch (e) {}
|
|
420
|
+
try {
|
|
421
|
+
if (!ctx) ctx = new AudioContext();
|
|
422
|
+
// One microphone request per call: some Telegram clients prompt on every getUserMedia.
|
|
423
|
+
if (!media) media = await navigator.mediaDevices.getUserMedia({ audio: { channelCount: 1, echoCancellation: true, noiseSuppression: true, autoGainControl: true } });
|
|
424
|
+
} catch (error) {
|
|
425
|
+
if (!gesture) { askTap(); return; }
|
|
426
|
+
state('Microphone access was denied.', 'err'); hangup(true); return;
|
|
427
|
+
}
|
|
428
|
+
if (!(await audioRunning())) { askTap(); return; }
|
|
429
|
+
try { await ctx.audioWorklet.addModule(URL.createObjectURL(new Blob([WORKLET], { type: 'application/javascript' }))); }
|
|
430
|
+
catch (error) { state('This Telegram app cannot use the microphone here. Update Telegram or try another device.', 'err'); hangup(true); return; }
|
|
431
|
+
resample = createResampler(ctx.sampleRate, 16000);
|
|
432
|
+
vad = createVoiceCallVad(CFG.vad);
|
|
433
|
+
var utteranceSamples = Math.floor(CFG.maxUtteranceMs * 16);
|
|
434
|
+
uplink = createVoiceCallUplink({
|
|
435
|
+
json: send,
|
|
436
|
+
frame: function(utteranceId, sequence, pcm){ if (ws && ws.readyState === 1 && generation) ws.send(encodeVoiceCallFrame(generation, epoch, sequence, utteranceId, pcm)); },
|
|
437
|
+
}, { preRollSamples: Math.ceil((CFG.vad.startMs + CFG.vad.endMs) * 16), maxHeldSamples: utteranceSamples, maxUtteranceSamples: utteranceSamples });
|
|
438
|
+
capture = new AudioWorkletNode(ctx, 'voice-call-capture');
|
|
439
|
+
var sink = ctx.createGain(); sink.gain.value = 0;
|
|
440
|
+
ctx.createMediaStreamSource(media).connect(capture); capture.connect(sink); sink.connect(ctx.destination);
|
|
441
|
+
capture.port.onmessage = function(event){
|
|
442
|
+
if (muted || paused || ended) return;
|
|
443
|
+
// Audible reply audio raises the bar for speech, so speaker echo does not interrupt it.
|
|
444
|
+
var playing = playhead.playing(ctx.currentTime);
|
|
445
|
+
var samples = event.data, edge = vad(voiceCallLevel(samples), samples.length / ctx.sampleRate * 1000, playing), pcm = resample(samples);
|
|
446
|
+
if (edge === 'start') {
|
|
447
|
+
uplink.speechStart({ playing: playing, epoch: epoch });
|
|
448
|
+
if (awaitingReply) { awaitingReply = false; if (!sources.length) state('Listening'); }
|
|
449
|
+
}
|
|
450
|
+
uplink.audio(pcm);
|
|
451
|
+
if (edge === 'end' && uplink.speechEnd() && !sources.length) { awaitingReply = true; state('Thinking'); }
|
|
452
|
+
};
|
|
453
|
+
if (!speaker) {
|
|
454
|
+
level = ctx.createAnalyser(); level.fftSize = 512; levelSamples = new Float32Array(level.fftSize);
|
|
455
|
+
speaker = ctx.createGain(); speaker.gain.value = speakerOn ? 1 : 0;
|
|
456
|
+
level.connect(speaker); speaker.connect(ctx.destination);
|
|
457
|
+
}
|
|
458
|
+
progressTimer = setInterval(function(){ reportProgress(); showDuration(); showLevel(); settlePlayback(); }, 100);
|
|
459
|
+
if (tg.enableClosingConfirmation) tg.enableClosingConfirmation();
|
|
460
|
+
$('controls').hidden = false;
|
|
461
|
+
try { await connect(); } catch (error) { fail(error); }
|
|
462
|
+
}
|
|
463
|
+
if (tg) { try { tg.ready(); tg.expand(); if (tg.disableVerticalSwipes) tg.disableVerticalSwipes(); tg.onEvent && tg.onEvent('deactivated', suspend); tg.onEvent && tg.onEvent('activated', resume); } catch (e) {} }
|
|
464
|
+
document.addEventListener('visibilitychange', function(){ if (document.visibilityState === 'hidden') suspend(); else if (!tg || tg.isActive !== false) resume(); });
|
|
465
|
+
$('mute').onclick = function(){ setMuted(!muted); };
|
|
466
|
+
$('speaker').onclick = function(){ setSpeaker(!speakerOn); };
|
|
467
|
+
$('hangup').onclick = function(){ hangup(false); };
|
|
468
|
+
// A used link opened from an old /call button stays as rendered: nothing starts.
|
|
469
|
+
// The page holding its call token is a reload of that call, and rejoins it.
|
|
470
|
+
var stored; try { stored = sessionStorage.getItem('voice-call:' + CFG.pairingId); } catch (e) {}
|
|
471
|
+
if (CFG.linkUsed && !stored) {
|
|
472
|
+
state(voiceCallTicketFailure(409, { error: 'Call link already used', code: 'CALL_LINK_USED' }).message, 'err');
|
|
473
|
+
$('controls').hidden = true; $('start').hidden = true; $('hint').hidden = true;
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
$('hint').hidden = false;
|
|
477
|
+
start(false);
|
|
478
|
+
})();
|
|
479
|
+
</script>`;
|
|
480
|
+
return (0, cli_viewer_ui_1.page)('Voice call', STYLE, body, `<script src="${cli_viewer_ui_1.TG_WEBAPP_JS}"></script>`);
|
|
481
|
+
}
|
|
482
|
+
/** A link that expired or never existed: only how it ended, in the call screen's theme. */
|
|
483
|
+
function generateVoiceCallGonePage(message) {
|
|
484
|
+
const body = `${THEME_SCRIPT}
|
|
485
|
+
<div class="call gone"><div class="chip" role="status"><span class="state err">${(0, cli_viewer_ui_1.htmlEscape)(message)}</span></div></div>`;
|
|
486
|
+
return (0, cli_viewer_ui_1.page)('Voice call', STYLE, body, `<script src="${cli_viewer_ui_1.TG_WEBAPP_JS}"></script>`);
|
|
487
|
+
}
|
|
488
|
+
//# sourceMappingURL=voice-call-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voice-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0,0 +1,7 @@
|
|
|
1
|
+
export declare const stripAudioTags: (text: string) => string;
|
|
2
|
+
/** The part of a partial chat text that can be shown without tags. Each longer prefix of the
|
|
3
|
+
* same text extends the previous result, so a stream of it never has to take text back. */
|
|
4
|
+
export declare const audioTagFreePrefix: (text: string) => string;
|
|
5
|
+
/** Streaming form: holds back a trailing tag until the text after it shows how to join it. */
|
|
6
|
+
export declare function withoutAudioTags(text: AsyncIterable<string>): AsyncIterable<string>;
|
|
7
|
+
//# sourceMappingURL=audio-tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-tags.d.ts","sourceRoot":"","sources":["../../src/voice/audio-tags.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MAAgD,CAAC;AAa/F;2FAC2F;AAC3F,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,MAA4D,CAAC;AAE/G,8FAA8F;AAC9F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAUnF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.audioTagFreePrefix = exports.stripAudioTags = void 0;
|
|
4
|
+
exports.withoutAudioTags = withoutAudioTags;
|
|
5
|
+
// ElevenLabs v3/v4 audio tags. Only the ElevenLabs dialogue models and Gemini 3.1 Flash TTS perform
|
|
6
|
+
// them; any other TTS model would read the word aloud, so known tags are stripped for those models.
|
|
7
|
+
// A bracket followed by `(` is markdown link text, not a tag.
|
|
8
|
+
const AUDIO_TAG = /[ \t]*\[(?:laughs?|laughing|chuckles|giggles|sighs?|whispers?|gasps?|sarcastic|excited|curious|crying|happy|sad|angry|surprised|nervous|exhales|inhales|clears throat|pause|short pause|long pause)\](?!\()[ \t]*/gi;
|
|
9
|
+
// Longest known tag plus slack; a longer unclosed bracket is not a tag split across chunks.
|
|
10
|
+
const MAX_TAG_LENGTH = 24;
|
|
11
|
+
// Keep a word break between two words, but none before punctuation, at a line start or inside unspaced text.
|
|
12
|
+
const joinAroundTag = (tag, offset, text) => {
|
|
13
|
+
const before = text[offset - 1], after = text[offset + tag.length];
|
|
14
|
+
return before && after && !/\s/.test(before) && /^\s|\s$/.test(tag) && !/[\s.,!?;:)\]}]/.test(after) ? ' ' : '';
|
|
15
|
+
};
|
|
16
|
+
const stripAudioTags = (text) => text.replace(AUDIO_TAG, joinAroundTag);
|
|
17
|
+
exports.stripAudioTags = stripAudioTags;
|
|
18
|
+
/** Where text that is still arriving can be cut: before a trailing tag (open, or closed with nothing
|
|
19
|
+
* after it yet to decide the join or a link) and before trailing spaces a tag may absorb. */
|
|
20
|
+
function settledLength(text) {
|
|
21
|
+
const open = text.lastIndexOf('[');
|
|
22
|
+
const close = open < 0 ? -1 : text.indexOf(']', open);
|
|
23
|
+
let cut = text.length;
|
|
24
|
+
if (open >= 0 && (close < 0 ? text.length - open <= MAX_TAG_LENGTH : !text.slice(close + 1).trim()))
|
|
25
|
+
cut = open;
|
|
26
|
+
while (cut > 0 && /[ \t]/.test(text[cut - 1]))
|
|
27
|
+
cut--;
|
|
28
|
+
return cut;
|
|
29
|
+
}
|
|
30
|
+
/** The part of a partial chat text that can be shown without tags. Each longer prefix of the
|
|
31
|
+
* same text extends the previous result, so a stream of it never has to take text back. */
|
|
32
|
+
const audioTagFreePrefix = (text) => (0, exports.stripAudioTags)(text.slice(0, settledLength(text)));
|
|
33
|
+
exports.audioTagFreePrefix = audioTagFreePrefix;
|
|
34
|
+
/** Streaming form: holds back a trailing tag until the text after it shows how to join it. */
|
|
35
|
+
function withoutAudioTags(text) {
|
|
36
|
+
const source = text[Symbol.asyncIterator]();
|
|
37
|
+
let closed = false;
|
|
38
|
+
const stripped = strippedChunks({ [Symbol.asyncIterator]: () => source }, () => closed);
|
|
39
|
+
// An async generator queues return() behind a pending next(), so a stalled source would never
|
|
40
|
+
// hear it. Forward it directly, as the TTS providers' teardown expects, and stop reading.
|
|
41
|
+
return { [Symbol.asyncIterator]: () => ({
|
|
42
|
+
next: () => stripped.next(),
|
|
43
|
+
return: async () => { closed = true; await source.return?.(); return { done: true, value: undefined }; },
|
|
44
|
+
}) };
|
|
45
|
+
}
|
|
46
|
+
async function* strippedChunks(text, closed) {
|
|
47
|
+
let pending = '', previous = '';
|
|
48
|
+
// The last character already sent decides whether a tag at the start of this text sat between words.
|
|
49
|
+
const strip = (segment) => (0, exports.stripAudioTags)(previous + segment).slice(previous.length);
|
|
50
|
+
for await (const chunk of text) {
|
|
51
|
+
if (closed())
|
|
52
|
+
return;
|
|
53
|
+
pending += chunk;
|
|
54
|
+
const cut = settledLength(pending);
|
|
55
|
+
const ready = strip(pending.slice(0, cut));
|
|
56
|
+
if (!ready)
|
|
57
|
+
continue;
|
|
58
|
+
pending = pending.slice(cut);
|
|
59
|
+
previous = /\S/.test(ready.slice(-1)) ? ready.slice(-1) : '';
|
|
60
|
+
yield ready;
|
|
61
|
+
}
|
|
62
|
+
const rest = strip(pending);
|
|
63
|
+
if (rest.trim())
|
|
64
|
+
yield rest;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=audio-tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-tags.js","sourceRoot":"","sources":["../../src/voice/audio-tags.ts"],"names":[],"mappings":";;;AA8BA,4CAUC;AAxCD,oGAAoG;AACpG,oGAAoG;AACpG,8DAA8D;AAC9D,MAAM,SAAS,GAAG,qNAAqN,CAAC;AACxO,4FAA4F;AAC5F,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,6GAA6G;AAC7G,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,MAAc,EAAE,IAAY,EAAU,EAAE;IAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,C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