@kuralle-syrinx/browser-client 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/LICENSE +22 -0
- package/dist/assets/index-Dz6IE6vJ.js +10 -0
- package/dist/index.html +429 -0
- package/index.html +1073 -0
- package/package.json +25 -0
- package/src/audio.test.ts +130 -0
- package/src/audio.ts +308 -0
- package/src/browser-opus.ts +118 -0
- package/src/index.test.ts +785 -0
- package/src/index.ts +864 -0
- package/src/jitter-buffer.test.ts +252 -0
- package/src/studio-page.test.ts +69 -0
- package/src/transport.test.ts +233 -0
- package/src/transport.ts +18 -0
- package/src/websocket-transport.ts +101 -0
- package/tsconfig.json +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kuralle
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const s of r.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&o(s)}).observe(document,{childList:!0,subtree:!0});function e(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(i){if(i.ep)return;i.ep=!0;const r=e(i);fetch(i.href,r)}})();const B=document.getElementById("wsUrl"),V=document.getElementById("status"),X=document.getElementById("statusText"),A=document.getElementById("connectBtn"),Y=document.getElementById("clearBtn"),m=document.getElementById("talkBtn"),Z=document.getElementById("resumeAudioBtn"),C=document.getElementById("micSelect"),_=document.getElementById("inputRate"),W=document.getElementById("outputRate"),O=document.getElementById("timeline"),U=document.getElementById("events"),x=document.getElementById("meter"),w=x.getContext("2d"),tt=location.protocol==="https:"?"wss:":"ws:";B.value=location.host?`${tt}//${location.host}/ws`:"ws://127.0.0.1:4173/ws";const N=new URLSearchParams(location.search).get("ws");N&&(B.value=N);let c=null,v=null,u=null,S=null,f=null,d=null,b=0;const R=new Set,P=[];let g=!1,a=null,et=0,l=new Int16Array(0),p=new Int16Array(0),L=0;const I=new Map,nt=.012,ot=400;window.__syrinxReviewState={sentFrames:0,sentBytes:0,contextIds:[],startedTurns:0,audioContextSampleRateHz:0,targetSampleRateHz:0};function $(t,n){V.className=`status ${t}`,X.textContent=n}function y(t,n=""){const e=document.createElement("div");e.className=`event ${n}`,e.textContent=`${new Date().toLocaleTimeString()} ${t}`,U.prepend(e)}function it(){const t=O.querySelector(".empty");t&&t.remove()}function D(t){if(I.has(t))return I.get(t);it();const n=document.createElement("article");n.className="turn",n.innerHTML=`
|
|
2
|
+
<div class="turn-head"><span>${t}</span><span data-role="state">listening</span></div>
|
|
3
|
+
<div class="turn-body">
|
|
4
|
+
<div class="bubble user" data-role="user">Waiting for transcript...</div>
|
|
5
|
+
<div class="bubble tool" data-role="tools">No tool calls yet.</div>
|
|
6
|
+
<div class="bubble agent" data-role="agent">Waiting for assistant...</div>
|
|
7
|
+
</div>
|
|
8
|
+
`,O.prepend(n);const e={id:t,root:n,user:n.querySelector('[data-role="user"]'),tools:n.querySelector('[data-role="tools"]'),agent:n.querySelector('[data-role="agent"]'),state:n.querySelector('[data-role="state"]'),agentText:"",toolText:"",audioEndedAt:0,sttFinalAt:0,firstAgentAt:0,firstAudioAt:0};return I.set(t,e),e}function E(t){t.audioEndedAt&&t.sttFinalAt&&(document.getElementById("latStt").textContent=`${t.sttFinalAt-t.audioEndedAt}ms`),t.sttFinalAt&&t.firstAgentAt&&(document.getElementById("latLlm").textContent=`${t.firstAgentAt-t.sttFinalAt}ms`),t.firstAgentAt&&t.firstAudioAt&&(document.getElementById("latTts").textContent=`${t.firstAudioAt-t.firstAgentAt}ms`),t.audioEndedAt&&t.firstAudioAt&&(document.getElementById("latE2e").textContent=`${t.firstAudioAt-t.audioEndedAt}ms`)}A.addEventListener("click",()=>{if(c&&c.readyState===WebSocket.OPEN){c.close();return}at()});Y.addEventListener("click",()=>{I.clear(),O.innerHTML='<div class="empty">Connect, start listening, then speak naturally.</div>',U.innerHTML=""});m.addEventListener("click",async()=>{if(g){await Q();return}await J()});m.addEventListener("keydown",async t=>{if(t.code==="Space"||t.code==="Enter"){if(t.preventDefault(),g){await Q();return}await J()}});Z.addEventListener("click",async()=>{await H(),y("audio output enabled")});function at(){$("connecting","Connecting"),A.disabled=!0,c=new WebSocket(B.value),c.binaryType="arraybuffer",c.addEventListener("open",()=>{$("connected","Online"),A.disabled=!1,A.textContent="Disconnect",m.disabled=!1,y(`connected ${B.value}`)}),c.addEventListener("close",()=>{$("","Offline"),A.disabled=!1,A.textContent="Connect",m.disabled=!0,y("socket closed")}),c.addEventListener("error",()=>{y("websocket error","error")}),c.addEventListener("message",t=>{if(typeof t.data=="string"){rt(JSON.parse(t.data));return}dt(t.data)})}function rt(t){var o,i;if(t.type==="ready"){y(`session ready ${t.sessionId||""}`.trim()),(o=t.audio)!=null&&o.inputSampleRateHz&&(_.value=String(t.audio.inputSampleRateHz)),(i=t.audio)!=null&&i.outputSampleRateHz&&(W.value=String(t.audio.outputSampleRateHz));return}if(t.type==="error"){y(`${t.component||"error"}: ${t.message}`,"error");return}const n=t.turnId||(a==null?void 0:a.id)||"unknown-turn",e=D(n);t.type==="speech_started"?(e.audioEndedAt=0,e.state.textContent="listening"):t.type==="speech_ended"?((a==null?void 0:a.id)===e.id&&(G(e.id),a=null),e.audioEndedAt||(e.audioEndedAt=Date.now()),e.state.textContent="finalizing",E(e)):t.type==="audio_clear"?(k(),e.state.textContent="interrupted",y(`cleared assistant audio for ${n}`)):t.type==="agent_interrupted"?e.state.textContent="interrupted":t.type==="stt_chunk"?(e.user.textContent=t.transcript||"",e.state.textContent="transcribing"):t.type==="stt_output"?(e.sttFinalAt=Date.now(),e.user.textContent=t.transcript||"",e.state.textContent="agent",E(e)):t.type==="agent_tool_call"?(e.toolText+=`${t.name||"tool"} ${JSON.stringify(t.args||{})}
|
|
9
|
+
`,e.tools.textContent=e.toolText.trim()):t.type==="agent_tool_result"?(e.toolText+=`result ${t.id||""}
|
|
10
|
+
`,e.tools.textContent=e.toolText.trim()):t.type==="agent_chunk"?(e.firstAgentAt||(e.firstAgentAt=Date.now()),e.agentText+=t.text||"",e.agent.textContent=e.agentText,e.state.textContent="speaking",E(e)):t.type==="agent_end"?e.state.textContent="tts":t.type==="tts_chunk"?P.push(t):t.type==="tts_end"&&(e.state.textContent="done",E(e),g&&(a==null?void 0:a.id)===e.id&&(a=null))}async function J(){if(g||!c||c.readyState!==WebSocket.OPEN)return;await H(),k();const t=M(_.value,16e3);a=null,l=new Int16Array(0),p=new Int16Array(0),v=await navigator.mediaDevices.getUserMedia({audio:{deviceId:C.value?{exact:C.value}:void 0,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),u=new AudioContext,window.__syrinxReviewState.audioContextSampleRateHz=u.sampleRate,window.__syrinxReviewState.targetSampleRateHz=t,S=u.createMediaStreamSource(v),f=u.createScriptProcessor(2048,1,1),f.onaudioprocess=n=>{const e=n.inputBuffer.getChannelData(0),o=mt(e);L=Math.max(L*.82,o);const i=pt(e,u.sampleRate,t),r=ft(i);if(!a){if(ct(r,t),o<nt)return;k(),a=st(),a.state.textContent="listening",z(p,t,a.id),p=new Int16Array(0);return}z(r,t,a.id)},S.connect(f),f.connect(u.destination),g=!0,m.classList.add("recording"),m.textContent="Stop Listening",y("microphone listening")}async function Q(){g&&(g=!1,f==null||f.disconnect(),S==null||S.disconnect(),v==null||v.getTracks().forEach(t=>t.stop()),await(u==null?void 0:u.close()),f=null,S=null,v=null,u=null,p=new Int16Array(0),a&&(G(a.id),a.audioEndedAt=Date.now(),lt(a.id,M(_.value,16e3),1200),a.state.textContent="finalizing",E(a)),m.classList.remove("recording"),m.textContent="Start Listening")}function st(){return window.__syrinxReviewState.startedTurns+=1,D(`review-${Date.now().toString(36)}`)}function ct(t,n){const e=new Int16Array(p.length+t.length);e.set(p),e.set(t,p.length);const o=Math.round(n*ot/1e3);p=e.length>o?e.slice(e.length-o):e}function z(t,n,e){const o=new Int16Array(l.length+t.length);o.set(l),o.set(t,l.length),l=o;const i=Math.round(n*.02);for(;l.length>=i;)F(e,l.subarray(0,i)),l=l.slice(i)}function G(t){l.length!==0&&(F(t,l),l=new Int16Array(0))}function lt(t,n,e){const o=Math.round(n*.02),i=Math.ceil(e/20),r=new Int16Array(o);for(let s=0;s<i;s+=1)F(t,r)}function F(t,n){if(!c||c.readyState!==WebSocket.OPEN)return;const e=n.byteLength;window.__syrinxReviewState.sentFrames+=1,window.__syrinxReviewState.sentBytes+=e,window.__syrinxReviewState.contextIds.includes(t)||window.__syrinxReviewState.contextIds.push(t),c.send(JSON.stringify({type:"audio",contextId:t,sampleRateHz:M(_.value,16e3),sequence:++et,audio:yt(new Uint8Array(n.buffer,n.byteOffset,n.byteLength))}))}async function dt(t){const n=t instanceof Blob?await t.arrayBuffer():t,e=P.shift(),o=e!=null&&e.turnId?D(e.turnId):a;o&&!o.firstAudioAt&&(o.firstAudioAt=Date.now(),E(o)),await ut(n,(e==null?void 0:e.sampleRateHz)||M(W.value,16e3))}async function H(){(!d||d.state==="closed")&&(d=new AudioContext,b=d.currentTime),d.state==="suspended"&&await d.resume()}async function ut(t,n){await H();const e=new Uint8Array(t),o=new Int16Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/2)),i=d.createBuffer(1,o.length,n),r=i.getChannelData(0);for(let h=0;h<o.length;h+=1)r[h]=o[h]/32768;const s=d.createBufferSource();s.buffer=i,s.connect(d.destination),s.addEventListener("ended",()=>{R.delete(s)}),R.add(s),b=Math.max(b,d.currentTime+.02),s.start(b),b+=i.duration}function k(){for(const t of R)try{t.stop()}catch{}R.clear(),P.length=0,d&&(b=d.currentTime)}function ft(t){const n=new Int16Array(t.length);for(let e=0;e<t.length;e+=1){const o=Math.max(-1,Math.min(1,t[e]));n[e]=o<0?o*32768:o*32767}return n}function pt(t,n,e){if(n===e)return t;const o=Math.max(1,Math.round(t.length*e/n)),i=new Float32Array(o),r=n/e;for(let s=0;s<o;s+=1){const h=s*r,T=Math.floor(h),j=Math.min(t.length-1,T+1),q=h-T;i[s]=t[T]*(1-q)+t[j]*q}return i}function yt(t){let n="";for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}function M(t,n){const e=Number.parseInt(t,10);return Number.isFinite(e)&&e>0?e:n}function mt(t){let n=0;for(let e=0;e<t.length;e+=1)n+=t[e]*t[e];return Math.sqrt(n/Math.max(1,t.length))}function K(){const t=x.clientWidth*window.devicePixelRatio,n=x.clientHeight*window.devicePixelRatio;(x.width!==t||x.height!==n)&&(x.width=t,x.height=n),w.clearRect(0,0,t,n),w.fillStyle="#fffefa",w.fillRect(0,0,t,n),w.fillStyle=g?"#b13a2e":"#1f7a4d",w.fillRect(0,0,Math.min(t,t*L*5),n),w.strokeStyle="#aaa291",w.strokeRect(.5,.5,t-1,n-1),L*=.94,requestAnimationFrame(K)}async function gt(){var e;if(!((e=navigator.mediaDevices)!=null&&e.enumerateDevices))return;const n=(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="audioinput");C.innerHTML='<option value="">Default input</option>';for(const o of n){const i=document.createElement("option");i.value=o.deviceId,i.textContent=o.label||`Input ${C.length}`,C.append(i)}}gt();requestAnimationFrame(K);
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Syrinx University Review Studio</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
color-scheme: light;
|
|
10
|
+
--paper: #f7f5ef;
|
|
11
|
+
--panel: #fffdf8;
|
|
12
|
+
--ink: #171714;
|
|
13
|
+
--muted: #6c695f;
|
|
14
|
+
--line: #d9d4c7;
|
|
15
|
+
--line-strong: #aaa291;
|
|
16
|
+
--green: #1f7a4d;
|
|
17
|
+
--green-soft: #e6f1ea;
|
|
18
|
+
--blue: #1e5b8f;
|
|
19
|
+
--blue-soft: #e6eef6;
|
|
20
|
+
--amber: #a05f00;
|
|
21
|
+
--amber-soft: #f6ecd8;
|
|
22
|
+
--red: #b13a2e;
|
|
23
|
+
--red-soft: #f7e4e1;
|
|
24
|
+
--shadow: 0 18px 50px rgba(31, 29, 24, 0.12);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
* {
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
body {
|
|
32
|
+
margin: 0;
|
|
33
|
+
min-height: 100vh;
|
|
34
|
+
background: var(--paper);
|
|
35
|
+
color: var(--ink);
|
|
36
|
+
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
button,
|
|
40
|
+
input,
|
|
41
|
+
select {
|
|
42
|
+
font: inherit;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
button {
|
|
46
|
+
border: 1px solid var(--ink);
|
|
47
|
+
background: var(--ink);
|
|
48
|
+
color: #fffdf8;
|
|
49
|
+
border-radius: 7px;
|
|
50
|
+
padding: 10px 13px;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
font-weight: 700;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
button:hover:not(:disabled) {
|
|
56
|
+
transform: translateY(-1px);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
button:disabled {
|
|
60
|
+
border-color: var(--line-strong);
|
|
61
|
+
background: var(--line);
|
|
62
|
+
color: var(--muted);
|
|
63
|
+
cursor: not-allowed;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
button.secondary {
|
|
67
|
+
background: transparent;
|
|
68
|
+
color: var(--ink);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
button.recording {
|
|
72
|
+
border-color: var(--red);
|
|
73
|
+
background: var(--red);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
input,
|
|
77
|
+
select {
|
|
78
|
+
width: 100%;
|
|
79
|
+
border: 1px solid var(--line-strong);
|
|
80
|
+
background: #fffefa;
|
|
81
|
+
color: var(--ink);
|
|
82
|
+
border-radius: 7px;
|
|
83
|
+
padding: 9px 10px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
label {
|
|
87
|
+
display: block;
|
|
88
|
+
margin-bottom: 6px;
|
|
89
|
+
color: var(--muted);
|
|
90
|
+
font-size: 12px;
|
|
91
|
+
font-weight: 800;
|
|
92
|
+
letter-spacing: 0.05em;
|
|
93
|
+
text-transform: uppercase;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.shell {
|
|
97
|
+
display: grid;
|
|
98
|
+
grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
|
|
99
|
+
min-height: 100vh;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.rail {
|
|
103
|
+
border-right: 1px solid var(--line);
|
|
104
|
+
background: #ebe6d9;
|
|
105
|
+
padding: 22px;
|
|
106
|
+
overflow: auto;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.brand {
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
justify-content: space-between;
|
|
113
|
+
gap: 16px;
|
|
114
|
+
margin-bottom: 22px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.brand h1 {
|
|
118
|
+
margin: 0;
|
|
119
|
+
font-size: 19px;
|
|
120
|
+
line-height: 1.05;
|
|
121
|
+
letter-spacing: 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.status {
|
|
125
|
+
display: inline-flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
gap: 7px;
|
|
128
|
+
border: 1px solid var(--line-strong);
|
|
129
|
+
border-radius: 999px;
|
|
130
|
+
padding: 6px 9px;
|
|
131
|
+
background: var(--panel);
|
|
132
|
+
color: var(--muted);
|
|
133
|
+
font-size: 12px;
|
|
134
|
+
font-weight: 800;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.dot {
|
|
138
|
+
width: 8px;
|
|
139
|
+
height: 8px;
|
|
140
|
+
border-radius: 99px;
|
|
141
|
+
background: var(--line-strong);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.status.connected .dot {
|
|
145
|
+
background: var(--green);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.status.connecting .dot {
|
|
149
|
+
background: var(--amber);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.section {
|
|
153
|
+
border-top: 1px solid var(--line);
|
|
154
|
+
padding: 18px 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.section:first-of-type {
|
|
158
|
+
border-top: 0;
|
|
159
|
+
padding-top: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.stack {
|
|
163
|
+
display: grid;
|
|
164
|
+
gap: 10px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.inline {
|
|
168
|
+
display: grid;
|
|
169
|
+
grid-template-columns: 1fr auto;
|
|
170
|
+
gap: 8px;
|
|
171
|
+
align-items: end;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.button-row {
|
|
175
|
+
display: grid;
|
|
176
|
+
grid-template-columns: 1fr 1fr;
|
|
177
|
+
gap: 8px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.meter {
|
|
181
|
+
height: 58px;
|
|
182
|
+
border: 1px solid var(--line-strong);
|
|
183
|
+
border-radius: 7px;
|
|
184
|
+
background: #fffefa;
|
|
185
|
+
overflow: hidden;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.meter canvas {
|
|
189
|
+
display: block;
|
|
190
|
+
width: 100%;
|
|
191
|
+
height: 100%;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.kv {
|
|
195
|
+
display: grid;
|
|
196
|
+
gap: 6px;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.kv div {
|
|
200
|
+
display: flex;
|
|
201
|
+
justify-content: space-between;
|
|
202
|
+
gap: 16px;
|
|
203
|
+
border-bottom: 1px solid rgba(170, 162, 145, 0.45);
|
|
204
|
+
padding-bottom: 6px;
|
|
205
|
+
color: var(--muted);
|
|
206
|
+
font-size: 13px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.kv strong {
|
|
210
|
+
color: var(--ink);
|
|
211
|
+
font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
|
|
212
|
+
font-size: 12px;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.main {
|
|
216
|
+
display: grid;
|
|
217
|
+
grid-template-rows: auto minmax(0, 1fr);
|
|
218
|
+
min-width: 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.topbar {
|
|
222
|
+
display: flex;
|
|
223
|
+
justify-content: space-between;
|
|
224
|
+
align-items: center;
|
|
225
|
+
gap: 18px;
|
|
226
|
+
border-bottom: 1px solid var(--line);
|
|
227
|
+
padding: 18px 24px;
|
|
228
|
+
background: var(--panel);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.topbar h2 {
|
|
232
|
+
margin: 0;
|
|
233
|
+
font-size: 17px;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.topbar p {
|
|
237
|
+
margin: 4px 0 0;
|
|
238
|
+
color: var(--muted);
|
|
239
|
+
font-size: 13px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.content {
|
|
243
|
+
display: grid;
|
|
244
|
+
grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
|
|
245
|
+
gap: 18px;
|
|
246
|
+
padding: 18px;
|
|
247
|
+
overflow: hidden;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.timeline,
|
|
251
|
+
.sidefeed {
|
|
252
|
+
min-height: 0;
|
|
253
|
+
overflow: auto;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.timeline {
|
|
257
|
+
display: grid;
|
|
258
|
+
align-content: start;
|
|
259
|
+
gap: 12px;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.turn {
|
|
263
|
+
border: 1px solid var(--line);
|
|
264
|
+
border-radius: 8px;
|
|
265
|
+
background: var(--panel);
|
|
266
|
+
box-shadow: var(--shadow);
|
|
267
|
+
overflow: hidden;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.turn-head {
|
|
271
|
+
display: flex;
|
|
272
|
+
justify-content: space-between;
|
|
273
|
+
align-items: center;
|
|
274
|
+
gap: 10px;
|
|
275
|
+
border-bottom: 1px solid var(--line);
|
|
276
|
+
padding: 10px 12px;
|
|
277
|
+
color: var(--muted);
|
|
278
|
+
font-size: 12px;
|
|
279
|
+
font-weight: 800;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.turn-body {
|
|
283
|
+
display: grid;
|
|
284
|
+
gap: 10px;
|
|
285
|
+
padding: 12px;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.bubble {
|
|
289
|
+
border-left: 4px solid var(--line-strong);
|
|
290
|
+
border-radius: 5px;
|
|
291
|
+
padding: 9px 10px;
|
|
292
|
+
background: #fffefa;
|
|
293
|
+
line-height: 1.45;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.bubble.user {
|
|
297
|
+
border-color: var(--blue);
|
|
298
|
+
background: var(--blue-soft);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.bubble.agent {
|
|
302
|
+
border-color: var(--green);
|
|
303
|
+
background: var(--green-soft);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.bubble.tool {
|
|
307
|
+
border-color: var(--amber);
|
|
308
|
+
background: var(--amber-soft);
|
|
309
|
+
font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
|
|
310
|
+
font-size: 12px;
|
|
311
|
+
white-space: pre-wrap;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.event {
|
|
315
|
+
border-bottom: 1px solid var(--line);
|
|
316
|
+
padding: 10px 0;
|
|
317
|
+
color: var(--muted);
|
|
318
|
+
font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
|
|
319
|
+
font-size: 12px;
|
|
320
|
+
line-height: 1.45;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.event.error {
|
|
324
|
+
color: var(--red);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.empty {
|
|
328
|
+
border: 1px dashed var(--line-strong);
|
|
329
|
+
border-radius: 8px;
|
|
330
|
+
padding: 32px;
|
|
331
|
+
color: var(--muted);
|
|
332
|
+
background: rgba(255, 253, 248, 0.65);
|
|
333
|
+
text-align: center;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
@media (max-width: 920px) {
|
|
337
|
+
.shell,
|
|
338
|
+
.content {
|
|
339
|
+
grid-template-columns: 1fr;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.rail {
|
|
343
|
+
border-right: 0;
|
|
344
|
+
border-bottom: 1px solid var(--line);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.content {
|
|
348
|
+
overflow: visible;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
</style>
|
|
352
|
+
<script type="module" crossorigin src="/assets/index-Dz6IE6vJ.js"></script>
|
|
353
|
+
</head>
|
|
354
|
+
<body>
|
|
355
|
+
<div class="shell">
|
|
356
|
+
<aside class="rail">
|
|
357
|
+
<div class="brand">
|
|
358
|
+
<h1>Syrinx University Review</h1>
|
|
359
|
+
<div id="status" class="status"><span class="dot"></span><span id="statusText">Offline</span></div>
|
|
360
|
+
</div>
|
|
361
|
+
|
|
362
|
+
<section class="section stack">
|
|
363
|
+
<div>
|
|
364
|
+
<label for="wsUrl">WebSocket</label>
|
|
365
|
+
<input id="wsUrl" autocomplete="off" />
|
|
366
|
+
</div>
|
|
367
|
+
<div class="button-row">
|
|
368
|
+
<button id="connectBtn">Connect</button>
|
|
369
|
+
<button id="clearBtn" class="secondary">Clear</button>
|
|
370
|
+
</div>
|
|
371
|
+
</section>
|
|
372
|
+
|
|
373
|
+
<section class="section stack">
|
|
374
|
+
<div>
|
|
375
|
+
<label for="micSelect">Microphone</label>
|
|
376
|
+
<select id="micSelect"><option value="">Default input</option></select>
|
|
377
|
+
</div>
|
|
378
|
+
<button id="talkBtn" disabled>Start Listening</button>
|
|
379
|
+
<div class="meter"><canvas id="meter"></canvas></div>
|
|
380
|
+
</section>
|
|
381
|
+
|
|
382
|
+
<section class="section stack">
|
|
383
|
+
<div class="inline">
|
|
384
|
+
<div>
|
|
385
|
+
<label for="inputRate">Input PCM Hz</label>
|
|
386
|
+
<input id="inputRate" value="16000" inputmode="numeric" />
|
|
387
|
+
</div>
|
|
388
|
+
<div>
|
|
389
|
+
<label for="outputRate">Output PCM Hz</label>
|
|
390
|
+
<input id="outputRate" value="16000" inputmode="numeric" />
|
|
391
|
+
</div>
|
|
392
|
+
</div>
|
|
393
|
+
<div class="kv">
|
|
394
|
+
<div><span>Profile</span><strong>interactive</strong></div>
|
|
395
|
+
<div><span>STT</span><strong>Deepgram</strong></div>
|
|
396
|
+
<div><span>LLM</span><strong>Gemini via AI SDK</strong></div>
|
|
397
|
+
<div><span>TTS</span><strong>Cartesia or Gemini</strong></div>
|
|
398
|
+
</div>
|
|
399
|
+
</section>
|
|
400
|
+
|
|
401
|
+
<section class="section">
|
|
402
|
+
<div class="kv">
|
|
403
|
+
<div><span>STT final</span><strong id="latStt">--</strong></div>
|
|
404
|
+
<div><span>LLM first text</span><strong id="latLlm">--</strong></div>
|
|
405
|
+
<div><span>TTS first audio</span><strong id="latTts">--</strong></div>
|
|
406
|
+
<div><span>Speech to audio</span><strong id="latE2e">--</strong></div>
|
|
407
|
+
</div>
|
|
408
|
+
</section>
|
|
409
|
+
</aside>
|
|
410
|
+
|
|
411
|
+
<main class="main">
|
|
412
|
+
<header class="topbar">
|
|
413
|
+
<div>
|
|
414
|
+
<h2>Live Student Relations Agent</h2>
|
|
415
|
+
<p>Always-on listening streams PCM16 frames; VAD and endpointing decide turn boundaries.</p>
|
|
416
|
+
</div>
|
|
417
|
+
<button id="resumeAudioBtn" class="secondary">Enable Audio</button>
|
|
418
|
+
</header>
|
|
419
|
+
<div class="content">
|
|
420
|
+
<section id="timeline" class="timeline">
|
|
421
|
+
<div class="empty">Connect, start listening, then speak naturally.</div>
|
|
422
|
+
</section>
|
|
423
|
+
<aside id="events" class="sidefeed"></aside>
|
|
424
|
+
</div>
|
|
425
|
+
</main>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
</body>
|
|
429
|
+
</html>
|