feat(voice): add authenticated Phase 2 live lifecycle
Add cookie authentication, owned conversations, durable Live reservations, tool completion/replay fencing, revocation, and startup reconciliation. Introduce forward lifecycle/owner-chain migrations and the temporary Gemini adapter while preserving the existing OpenAI Realtime adapter. Include the executable audio client, regression coverage, configuration, API/database documentation, and recorded acceptance evidence. Validation: focused review suite 82 passed; Python/TOML parsing, JavaScript syntax, and whitespace checks passed. Full PostgreSQL/provider-free results are recorded in the repair report; real-provider/browser acceptance is unrun. Follow-up work remains for configurable OpenAI/Gemini selection, transport admission, authority diagnostics, playback message bounds, and client replay identity after ambiguous creation responses.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
"""Execute the example worklet to prove consumed-sample accounting and capture bytes."""
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import pytest
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[2]
|
||||
|
||||
def test_worklet_capture_playback_and_interruption(tmp_path):
|
||||
node=shutil.which('node')
|
||||
if not node: pytest.fail('Node is required to exercise the delivered audio example')
|
||||
script=r'''
|
||||
const fs=require('fs'),vm=require('vm'),assert=require('assert');
|
||||
const processors={};
|
||||
global.AudioWorkletProcessor=class {constructor(){this.messages=[];this.port={postMessage:m=>this.messages.push(m)};}};
|
||||
global.registerProcessor=(name,processor)=>processors[name]=processor;
|
||||
vm.runInThisContext(fs.readFileSync(process.argv[2],'utf8'));
|
||||
const capture=new processors['rag-capture']();
|
||||
capture.process([[new Float32Array(240).fill(.5)]],[]);
|
||||
assert.equal(capture.messages.length,1);assert.equal(capture.messages[0].bytes.byteLength,480);
|
||||
assert.equal(new DataView(capture.messages[0].bytes).getInt16(0,true),16384);
|
||||
const playback=new processors['rag-playback']();
|
||||
const message=data=>playback.port.onmessage({data});
|
||||
message({type:'start',ref:'a'});message({type:'pcm',ref:'a',samples:new Float32Array(240).buffer});
|
||||
assert.equal(playback.messages.length,0);
|
||||
playback.process([],[[new Float32Array(120)]]);
|
||||
assert.equal(playback.messages.at(-1).played_ms,5);
|
||||
message({type:'flush',id:'flush'});
|
||||
assert.equal(playback.messages.at(-2).played_ms,5);assert.equal(playback.queue.length,0);
|
||||
assert.equal(playback.messages.at(-1).type,'flushed');
|
||||
message({type:'start',ref:'b'});message({type:'pcm',ref:'b',samples:new Float32Array(240).buffer});
|
||||
message({type:'end',ref:'b'});playback.process([],[[new Float32Array(240)]]);
|
||||
assert.equal(playback.messages.at(-1).played_ms,10);assert.equal(playback.refs.size,0);
|
||||
'''
|
||||
path=tmp_path/'worklet-test.cjs';path.write_text(script)
|
||||
subprocess.run([node,str(path),str(ROOT/'examples/voice-audio-worklet.js')],check=True,capture_output=True,timeout=10)
|
||||
|
||||
|
||||
def test_delivered_voice_client_async_ownership_errors_logout_and_close():
|
||||
node=shutil.which('node')
|
||||
if not node:pytest.fail('Node is required to exercise VoiceClient')
|
||||
result=subprocess.run([node,str(ROOT/'tests/support/voice_client_harness.mjs'),'unit'],capture_output=True,text=True,timeout=20)
|
||||
assert result.returncode==0,result.stdout+result.stderr
|
||||
Reference in New Issue
Block a user