@urun-sh/openai 0.6.33 → 0.6.34
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/chunk-2L7UL6BM.js +17 -0
- package/dist/chunk-6K7NOPD5.js +6 -0
- package/dist/chunk-7KRHHEKZ.js +1 -0
- package/dist/{chunk-GR3UAW6P.js → chunk-AVMTHHBR.js} +1 -1
- package/dist/{chunk-NL3UBLXV.js → chunk-CY4RJOTS.js} +2 -2
- package/dist/chunk-ETX6IX25.js +1 -0
- package/dist/{chunk-GL7EWL3V.js → chunk-EV4DZCHN.js} +1 -1
- package/dist/{chunk-L6HTHDVV.js → chunk-GQTWIDJ6.js} +1 -1
- package/dist/chunk-LDBKLCCU.js +2 -0
- package/dist/{composite-CwfOOT0b.d.cts → composite-DGytPb8F.d.cts} +10 -8
- package/dist/gemini-live.cjs +2 -2
- package/dist/gemini-live.d.cts +0 -26
- package/dist/gemini-live.d.ts +0 -5
- package/dist/gemini-live.js +1 -1
- package/dist/hosted/bin.cjs +44 -44
- package/dist/hosted/bin.js +1 -1
- package/dist/hosted/index.cjs +38 -38
- package/dist/hosted/index.d.cts +44 -1
- package/dist/hosted/index.d.ts +9 -1
- package/dist/hosted/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/pi-extension/index.cjs +7 -7
- package/dist/pi-extension/index.js +1 -1
- package/dist/pi-extension/standalone.cjs +40 -40
- package/dist/pooler/bin.cjs +24 -24
- package/dist/pooler/bin.js +23 -23
- package/dist/proxy/cli.cjs +37 -37
- package/dist/proxy/cli.js +1 -1
- package/dist/proxy/index.cjs +13 -13
- package/dist/proxy/index.d.cts +2 -2
- package/dist/proxy/index.d.ts +2 -2
- package/dist/proxy/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-7D2HMQFC.js +0 -2
- package/dist/chunk-NN6TQQUG.js +0 -1
- package/dist/chunk-OOCRI7ZM.js +0 -6
- package/dist/chunk-PBKCUSTI.js +0 -17
- /package/dist/{composite-D9VDruCV.d.ts → composite-D4oZXeX4.d.ts} +0 -0
package/dist/gemini-live.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _e=Object.create;var E=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Ee=(e,t)=>{for(var n in t)E(e,n,{get:t[n],enumerable:!0})},W=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ve(t))!Ae.call(e,r)&&r!==n&&E(e,r,{get:()=>t[r],enumerable:!(o=be(t,r))||o.enumerable});return e};var $=(e,t,n)=>(n=e!=null?_e(Oe(e)):{},W(t||!e||!e.__esModule?E(n,"default",{value:e,enumerable:!0}):n,e)),Se=e=>W(E({},"__esModule",{value:!0}),e);var He={};Ee(He,{AudioBridge:()=>O,CLOSE_PROTOCOL:()=>H,CLOSE_SESSION_GONE:()=>re,CLOSE_UNKNOWN_MODEL:()=>oe,CLOSE_UPSTREAM:()=>U,GEMINI_AUDIO_IN_RATE:()=>b,GEMINI_AUDIO_OUT_MIME:()=>F,GEMINI_AUDIO_OUT_RATE:()=>D,GEMINI_LIVE_PATH:()=>ne,GeminiLiveError:()=>s,NATIVE_AUDIO_SAMPLE_RATE:()=>R,OUTBOUND_AUDIO_FLUSH_B64:()=>pe,RT_VIDEO_IN_STREAM:()=>S,RT_VIDEO_OUT_STREAM:()=>_,SdkTransport:()=>P,VIDEO_FRAME_MESSAGE_BUDGET:()=>T,VIDEO_OUT_DEFAULT_CODEC:()=>I,VIDEO_OUT_FRAMING:()=>B,VIDEO_OUT_SETUP_KEY:()=>k,VIDEO_OUT_WS_FRAMING:()=>C,consumeVideoOut:()=>ee,decodeResponsesLane:()=>A,decodeVideoOutRecord:()=>x,enableSessionAudio:()=>J,enableSessionVideo:()=>Y,encodeVideoOutRecord:()=>z,goAwayMsg:()=>le,negotiateSessionVideoOutQuic:()=>X,nodeAudioBackend:()=>K,openSessionVideoOutLane:()=>Z,parseClientMessage:()=>ie,resamplePcm16:()=>j,responseCreateToEnvelope:()=>V,responsesCreateToEnvelope:()=>M,serverContentOfAudio:()=>we,serverContentOfDelta:()=>ye,sessionResumptionUpdateMsg:()=>ce,translateClientContent:()=>fe,translateRealtimeInput:()=>me,translateSetup:()=>de,translateToolResponse:()=>ge,turnEndOfCompleted:()=>he,videoOutAck:()=>ae,videoOutChunkMsg:()=>ue,weriftAudioBackend:()=>q});module.exports=Se(He);var R=24e3,G="audio",O=class{constructor(t,n){this.backend=t;this.opts=n}backend;opts;source=null;sink=null;outHandlers=new Set;async startOutbound(){return this.source=this.backend.createSource(),this.source.track}appendInputAudio(t){if(!this.source)throw new Error("startOutbound() not called");let n=Buffer.from(t,"base64"),o=Math.floor(n.byteLength/2),r=new Int16Array(o);for(let i=0;i<o;i++)r[i]=n.readInt16LE(i*2);this.source.onData(r)}async startInbound(t){if(t==null)throw new Error('startInbound: no downstream audio track \u2014 the runtime audio producer has not been consumed yet (session.stream("audio").track is null)');this.sink=this.backend.createSink(t),this.sink.onframe=n=>{let o=Buffer.from(n.samples.buffer,n.samples.byteOffset,n.samples.byteLength).toString("base64");for(let r of this.outHandlers)r(o)}}onOutputAudio(t){return this.outHandlers.add(t),()=>this.outHandlers.delete(t)}};async function J(e,t,n=1e4){let o=new O(t,{sampleRate:24e3}),r=await o.startOutbound();await e.stream(G).attach(r);let i=await Te(e,n);return await o.startInbound(i),o}function Te(e,t){let n=e.stream(G);return n.track!=null?Promise.resolve(n.track):new Promise((o,r)=>{let i,a=setTimeout(()=>{i?.(),r(new Error(`enableSessionAudio: no downstream audio track within ${t}ms (runtime produced no voice OUT / SFU audio consumer never attached)`))},t),c=u=>{u!=null&&(clearTimeout(a),i?.(),o(u))};i=n.on?.("track",c),n.track!=null&&c(n.track)})}var S="rt-video-in",T=256e3;function Y(e){let t=e.stream(S),n=t.emit;if(typeof n!="function")throw new Error(`enableSessionVideo: session.stream('${S}') has no emit() \u2014 the named-DATA stream produce seam (@urun-sh/core SessionStream.emit, contract \xA75) is required for the video frame lane`);return{sendInputFrame:async o=>{if(o.byteLength===0)throw new Error("enableSessionVideo: refusing to send an empty video frame");if(o.byteLength>T)throw new Error(`enableSessionVideo: frame is ${o.byteLength} bytes \u2014 over the ${T}-byte data-channel budget (the SFU's 262144-byte SCTP ceiling drops oversize messages SILENTLY; send smaller/lower-quality frames)`);await n.call(t,o)}}}var Re=24e3,v=480,Ie=111;async function xe(){let e=await import("opusscript"),t=e.default??e;return new t(Re,1,2048)}async function q(){let e=await import("werift"),t=await xe();return{createSource:()=>{let n=new e.MediaStreamTrack({kind:"audio"}),o=Math.random()*4294967295>>>0,r=Math.random()*65535&65535,i=Math.random()*4294967295>>>0,a=new Int16Array(0);return{track:n,onData:c=>{let u=new Int16Array(a.length+c.length);u.set(a,0),u.set(c,a.length);let d=0;for(;u.length-d>=v;){let l=u.subarray(d,d+v);d+=v;let f=Buffer.from(l.buffer,l.byteOffset,l.byteLength),p=t.encode(f,v);r=r+1&65535,i=i+v>>>0;let g=new e.RtpHeader({version:2,payloadType:Ie,sequenceNumber:r,timestamp:i,ssrc:o,marker:!1}),h=new e.RtpPacket(g,p);n.writeRtp(h)}a=u.slice(d)}}},createSink:n=>{let o={onframe:null};return n.onReceiveRtp.subscribe(i=>{let a;try{a=t.decode(i.payload)}catch{return}let c=new Int16Array(a.length/2);for(let u=0;u<c.length;u++)c[u]=a.readInt16LE(u*2);o.onframe?.({samples:c})}),o}}}async function K(){let e=await import("@roamhq/wrtc");return{createSource:()=>{let t=new e.nonstandard.RTCAudioSource;return{track:t.createTrack(),onData:o=>t.onData({samples:o,sampleRate:24e3})}},createSink:t=>{let n={onframe:null},o=new e.nonstandard.RTCAudioSink(t);return o.ondata=r=>{n.onframe?.(r)},n}}}var w=require("@urun-sh/core"),_="rt-video-out",B="urun.videoOut.v1",I="h264";function Q(e,t){if(!Number.isInteger(e.seq)||e.seq<0)throw new Error(`${t}: header seq must be a non-negative integer (got ${e.seq})`);if(!Number.isInteger(e.ptsUs))throw new Error(`${t}: header ptsUs must be an integer microsecond timestamp (got ${e.ptsUs})`);if(typeof e.codec!="string"||e.codec.length===0)throw new Error(`${t}: header codec must be a non-empty string`);if(typeof e.key!="boolean")throw new Error(`${t}: header key must be a boolean`)}function z(e,t){if(Q(e,"encodeVideoOutRecord"),t.byteLength===0)throw new Error("encodeVideoOutRecord: refusing to encode an empty access unit");let n=new TextEncoder().encode(JSON.stringify({v:1,seq:e.seq,ptsUs:e.ptsUs,codec:e.codec,key:e.key}));if(n.byteLength>65535)throw new Error(`encodeVideoOutRecord: header JSON is ${n.byteLength} bytes \u2014 over the u16 length prefix`);let o=new Uint8Array(2+n.byteLength+t.byteLength);return o[0]=n.byteLength&255,o[1]=n.byteLength>>8,o.set(n,2),o.set(t,2+n.byteLength),o}function x(e){if(e.byteLength<2)throw new Error(`decodeVideoOutRecord: truncated record (${e.byteLength} byte(s), no header length)`);let t=e[0]|e[1]<<8;if(e.byteLength<2+t)throw new Error(`decodeVideoOutRecord: truncated record (header says ${t} bytes, ${e.byteLength-2} present)`);let n;try{n=JSON.parse(new TextDecoder().decode(e.subarray(2,2+t)))}catch(a){throw new Error(`decodeVideoOutRecord: header is not valid JSON (${String(a)})`)}let o=n;if(o===null||typeof o!="object"||o.v!==1)throw new Error(`decodeVideoOutRecord: header is not spec v1 (v=${JSON.stringify(o?.v)}) \u2014 a newer producer must be met with a newer consumer, never silently misread`);let r=o;Q(r,"decodeVideoOutRecord");let i=e.subarray(2+t);if(i.byteLength===0)throw new Error("decodeVideoOutRecord: empty access unit \u2014 a record with no AU bytes is a producer bug");return{header:r,au:i.slice()}}async function X(e){let t=e.wtDataEndpoint;if(typeof t!="function")throw new Error("negotiateSessionVideoOutQuic: the core session exposes no wtDataEndpoint() \u2014 the \xA75-over-QUIC dial seam (urun-infra#1608 TransportOfferResponse.webtransport, offered with wtData: true) is required for the video OUT lane; there is no WS fallback");let n=await t.call(e),o=n.sessionId??e.sessionId;if(typeof o!="string"||o.length===0)throw new Error("negotiateSessionVideoOutQuic: no session id \u2014 the WT hello requires one and neither the negotiated endpoint nor the core session carries it");return{transport:"webtransport",url:n.url,certHashes:n.certHashes,token:n.token,sessionId:o,stream:_,codec:I,framing:B}}var C="urun.videoOut.v2-ws";function Z(e){let t=e.stream(_);if(typeof t.messages!="function")throw new Error(`openSessionVideoOutLane: session.stream('${_}') has no messages() \u2014 the named-DATA stream consume seam (@urun-sh/core SessionStream.messages, contract \xA75) is required for the video OUT lane`);let n=new Set,o=new Set,r=new Set,i=u=>{for(let d of o)d(u)},a=!1,c=async()=>{for await(let u of t.messages()){if(!(u instanceof Uint8Array)){i(new Error(`openSessionVideoOutLane: "${_}" delivered a non-BINARY \xA75 payload (${typeof u}) \u2014 spec v1 records ride BINARY envelopes only`));continue}let d;try{d=x(u)}catch(l){i(l instanceof Error?l:new Error(String(l)));continue}for(let l of n)l(d)}for(let u of r)u()};return{codec:I,onOutputFrame:u=>(n.add(u),a||(a=!0,c().catch(d=>i(d instanceof Error?d:new Error(String(d))))),()=>n.delete(u)),onLaneError:u=>(o.add(u),()=>o.delete(u)),onEnd:u=>(r.add(u),()=>r.delete(u))}}function Ce(e){if(e.length%2!==0||/[^0-9a-fA-F]/.test(e))throw new Error(`consumeVideoOut: certHashes entry is not hex sha-256 (${JSON.stringify(e)})`);let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}async function ee(e,t,n){let o=n??(typeof globalThis.WebTransport=="function"?(d,l)=>new globalThis.WebTransport(d,l):void 0);if(!o)throw new Error("consumeVideoOut: no WebTransport implementation \u2014 this platform has no globalThis.WebTransport; inject a connect factory (the third argument)");let r=o(e.url,{serverCertificateHashes:e.certHashes.map(d=>({algorithm:"sha-256",value:Ce(d)}))});await r.ready;let i=await r.createBidirectionalStream();await i.writable.getWriter().write((0,w.encodeWtControlFrame)({t:"hello",token:e.token,sessionId:e.sessionId}));let a=i.readable.getReader(),c=new w.WtControlDecoder,u=!1;for(;!u;){let{value:d,done:l}=await a.read();if(l)throw new Error("consumeVideoOut: gateway closed the control stream before hello-ack");if(d)for(let f of c.push(d)){if(f.t==="hello-ack"){u=!0;break}throw new Error(`consumeVideoOut: gateway rejected hello (got ${JSON.stringify(f.t)} before hello-ack)`)}}await(0,w.consumeWtDataStreams)(r.incomingUnidirectionalStreams,{onData:(d,l)=>{if(d===e.stream){if(l===w.STREAM_END){t.onEnd?.();return}if(!(l instanceof Uint8Array)){t.onLaneError(new Error(`consumeVideoOut: "${e.stream}" delivered a non-BINARY \xA75 payload (${typeof l}) \u2014 spec v1 records ride BINARY envelopes only`));return}try{t.onFrame(x(l))}catch(f){t.onLaneError(f instanceof Error?f:new Error(String(f)))}}},onLaneError:d=>t.onLaneError(d)})}var ne="/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent",H=1007,oe=1008,U=1011,re=1008,s=class extends Error{constructor(n,o=H){super(n);this.closeCode=o}closeCode},m=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null,L=["setup","clientContent","realtimeInput","toolResponse"];function ie(e){let t;try{t=JSON.parse(e)}catch{throw new s("client message is not valid JSON")}let n=m(t);if(!n)throw new s("client message must be a JSON object");let o=L.filter(c=>n[c]!==void 0),r=Object.keys(n).filter(c=>!L.includes(c));if(r.length>0)throw new s(`unknown client message field(s) ${JSON.stringify(r)} \u2014 expected exactly one of ${L.join(", ")}`);if(o.length!==1)throw new s(`client message must contain exactly one of ${L.join(", ")} (got ${o.length})`);let i=o[0],a=m(n[i]);if(!a)throw new s(`"${i}" must be a JSON object`);return{kind:i,[i]:a}}function se(e,t){if(typeof e=="string")return e;let n=m(e),o=n?n.parts:void 0;if(!Array.isArray(o))throw new s(`${t}: expected a Content with a parts array`);let r=[];for(let i of o){let a=m(i);if(a&&typeof a.text=="string"){r.push(a.text);continue}throw a&&(a.inlineData!==void 0||a.fileData!==void 0)?new s(`${t}: media parts (inlineData/fileData) are a declared follow-up slice (audio/video lanes over the proxy transport AudioBridge) \u2014 only text parts are supported in this slice`):a&&(a.functionCall!==void 0||a.functionResponse!==void 0)?new s(`${t}: functionCall/functionResponse parts are not valid here \u2014 the Live API exchanges tool traffic via the dedicated toolCall/toolResponse messages`):new s(`${t}: unsupported part ${JSON.stringify(i)}`)}return r.join(`
|
|
2
|
-
`)}var Le={manualActivity:!1,activityHandling:"START_OF_ACTIVITY_INTERRUPTS"},k="urun.videoOut";function ae(e){return{framing:C,codec:e}}function ue(e){let{seq:t,ptsUs:n,codec:o,key:r}=e.header;return{[k]:{v:1,seq:t,ptsUs:n,codec:o,key:r,data:Buffer.from(e.au).toString("base64")}}}var Ue={inputAudioTranscription:"setup.inputAudioTranscription is part of the declared audio follow-up slice",outputAudioTranscription:"setup.outputAudioTranscription is part of the declared audio follow-up slice"},De=["model","generationConfig","systemInstruction","tools","realtimeInputConfig","sessionResumption",k],te=["START_OF_ACTIVITY_INTERRUPTS","NO_INTERRUPTION"];function Ve(e){let t=m(e);if(!t)throw new s("setup.realtimeInputConfig must be an object");for(let r of Object.keys(t))if(!(r==="automaticActivityDetection"||r==="activityHandling"))throw new s(r==="turnCoverage"?"realtimeInputConfig.turnCoverage is part of the declared audio follow-up slice":`unsupported realtimeInputConfig field "${r}"`);let n=m(t.automaticActivityDetection);if(t.automaticActivityDetection!==void 0&&!n)throw new s("realtimeInputConfig.automaticActivityDetection must be an object");for(let r of Object.keys(n??{}))if(r!=="disabled")throw new s(`automaticActivityDetection.${r} tunes AUTOMATIC (server-side) activity detection \u2014 the declared platform follow-up (serve turn_detection events over the session stream lane); only "disabled: true" (manual activity mode) is supported in this slice`);if(n?.disabled!==!0)throw new s("automatic (server-side) activity detection is the declared platform follow-up (serve turn_detection turn_start/turn_end events over the session stream lane, not proxy DSP) \u2014 set realtimeInputConfig.automaticActivityDetection.disabled: true for manual activity mode");let o="START_OF_ACTIVITY_INTERRUPTS";if(t.activityHandling!==void 0){if(!te.includes(t.activityHandling))throw new s(`unsupported activityHandling ${JSON.stringify(t.activityHandling)} \u2014 expected one of ${te.join(", ")}`);o=t.activityHandling}return{manualActivity:!0,activityHandling:o}}var Me=["temperature","maxOutputTokens","responseModalities"];function de(e){for(let[f,p]of Object.entries(Ue))if(e[f]!==void 0)throw new s(p);for(let f of Object.keys(e))if(!De.includes(f))throw new s(`unsupported setup field "${f}"`);if(typeof e.model!="string"||e.model.length===0)throw new s('setup.model is required (format "models/{model}")');let t=e.model.replace(/^models\//,""),n,o,r=!1,i=m(e.generationConfig);if(e.generationConfig!==void 0&&!i)throw new s("setup.generationConfig must be an object");if(i){for(let f of Object.keys(i))if(!Me.includes(f))throw new s(`unsupported generationConfig field "${f}"`);if(i.temperature!==void 0){if(typeof i.temperature!="number")throw new s("generationConfig.temperature must be a number");n=i.temperature}if(i.maxOutputTokens!==void 0){if(typeof i.maxOutputTokens!="number")throw new s("generationConfig.maxOutputTokens must be a number");o=i.maxOutputTokens}if(i.responseModalities!==void 0){let f=Array.isArray(i.responseModalities)?i.responseModalities:[i.responseModalities];for(let p of f){let g=String(p).toUpperCase();if(g==="AUDIO"){r=!0;continue}if(g!=="TEXT")throw new s(`responseModalities ${JSON.stringify(p)} is not supported \u2014 this surface speaks TEXT and AUDIO (audio-out rides the native AudioBridge 'audio' lane)`)}}}let a=[];e.systemInstruction!==void 0&&a.push({role:"system",content:se(e.systemInstruction,"setup.systemInstruction")});let c;if(e.tools!==void 0){if(!Array.isArray(e.tools))throw new s("setup.tools must be an array");c=[];for(let f of e.tools){let p=m(f);if(!p)throw new s("setup.tools entries must be objects");for(let g of Object.keys(p))if(g!=="functionDeclarations")throw new s(`unsupported tool "${g}" \u2014 this slice translates functionDeclarations only (no googleSearch/codeExecution)`);if(!Array.isArray(p.functionDeclarations))throw new s("tool.functionDeclarations must be an array");for(let g of p.functionDeclarations){let h=m(g);if(!h||typeof h.name!="string")throw new s("functionDeclarations entries require a string name");c.push({type:"function",name:h.name,description:h.description,parameters:h.parameters})}}c.length===0&&(c=void 0)}let u={enabled:!1,handle:null};if(e.sessionResumption!==void 0){let f=m(e.sessionResumption);if(!f)throw new s("setup.sessionResumption must be an object (SessionResumptionConfig)");for(let p of Object.keys(f))if(p!=="handle")throw new s(`unsupported sessionResumption field "${p}" \u2014 this lane implements SessionResumptionConfig.handle only`);if(f.handle!==void 0&&(typeof f.handle!="string"||f.handle.length===0))throw new s("sessionResumption.handle must be a non-empty string when present");u={enabled:!0,handle:typeof f.handle=="string"?f.handle:null}}let d=e.realtimeInputConfig===void 0?Le:Ve(e.realtimeInputConfig),l=!1;if(e[k]!==void 0){if(!m(e[k]))throw new s(`setup["${k}"] must be an object (the v1 opt-in is {})`);l=!0}return{model:t,systemItems:a,tools:c,temperature:n,maxOutputTokens:o,audioModality:r,activity:d,sessionResumption:u,videoOut:l}}function ce(e){return{sessionResumptionUpdate:{newHandle:e,resumable:!0}}}function le(e){let t=Math.max(0,e??0)/1e3;return{goAway:{timeLeft:`${Math.round(t*1e3)/1e3}s`}}}function fe(e){for(let o of Object.keys(e))if(o!=="turns"&&o!=="turnComplete")throw new s(`unsupported clientContent field "${o}"`);let t=e.turns===void 0?[]:e.turns;if(!Array.isArray(t))throw new s("clientContent.turns must be an array");let n=[];for(let o of t){let r=m(o);if(!r)throw new s("clientContent.turns entries must be Content objects");let i=r.role===void 0?"user":String(r.role).toLowerCase();if(i!=="user"&&i!=="model")throw new s(`clientContent turn role must be "user" or "model" (got ${JSON.stringify(r.role)})`);n.push({role:i==="model"?"assistant":"user",content:se(r,"clientContent.turns")})}return{items:n,turnComplete:e.turnComplete===!0}}var b=16e3,D=24e3,F=`audio/pcm;rate=${D}`,pe=Buffer.alloc(960).toString("base64");function j(e,t,n){if(t===n)return e;let o=Math.floor(e.length*n/t),r=new Int16Array(o),i=t/n,a=e.length-1;for(let c=0;c<o;c++){let u=c*i,d=Math.floor(u);if(d>=a){r[c]=e[a];continue}let l=u-d;r[c]=Math.round(e[d]+(e[d+1]-e[d])*l)}return r}function Ne(e){let t=m(e);if(!t)throw new s("realtimeInput.video must be a Blob object {mimeType, data}");if(typeof t.mimeType!="string"||!/^image\/jpeg\s*(;|$)/.test(t.mimeType))throw new s(`realtimeInput.video.mimeType must be image/jpeg (the Live video input stream is individual JPEG frames), got ${JSON.stringify(t.mimeType)}`);if(typeof t.data!="string"||t.data.length===0)throw new s("realtimeInput.video.data must be non-empty base64");let n=Buffer.from(t.data,"base64");if(n.length<3||n[0]!==255||n[1]!==216)throw new s("realtimeInput.video.data does not decode to a JPEG frame (missing FF D8 SOI marker)");return new Uint8Array(n)}function Pe(e){let t=m(e);if(!t)throw new s("realtimeInput.audio must be a Blob object {mimeType, data}");if(typeof t.mimeType!="string"||!/^audio\/pcm\s*(;|$)/.test(t.mimeType))throw new s(`realtimeInput.audio.mimeType must be audio/pcm (16-bit LE PCM @16kHz mono per the Live spec), got ${JSON.stringify(t.mimeType)}`);let n=/;\s*rate=(\d+)/.exec(t.mimeType);if(n&&Number(n[1])!==b)throw new s(`realtimeInput.audio.mimeType declares rate=${n[1]} \u2014 the Live spec input format is ${b} Hz (audio/pcm;rate=${b})`);if(typeof t.data!="string"||t.data.length===0)throw new s("realtimeInput.audio.data must be non-empty base64");let o=Buffer.from(t.data,"base64");if(o.length===0||o.length%2!==0)throw new s(`realtimeInput.audio.data must decode to whole 16-bit samples (got ${o.length} bytes \u2014 not even)`);let r=new Int16Array(o.length/2);for(let a=0;a<r.length;a++)r[a]=o.readInt16LE(a*2);let i=j(r,b,D);return Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString("base64")}function me(e){if(e.mediaChunks!==void 0)throw new s('realtimeInput.mediaChunks is deprecated by the Live API \u2014 send the audio stream via realtimeInput.audio ({mimeType:"audio/pcm;rate=16000", data}) instead');if(e.activityStart!==void 0||e.activityEnd!==void 0){if(Object.keys(e).length!==1||e.activityStart!==void 0&&e.activityEnd!==void 0)throw new s("realtimeInput must carry exactly one field when signaling activity (activityStart XOR activityEnd, nothing else)");let r=e.activityStart!==void 0?"activityStart":"activityEnd",i=m(e[r]);if(!i||Object.keys(i).length!==0)throw new s(`realtimeInput.${r} must be an empty object (ActivityStart/ActivityEnd are bare markers)`);return{kind:r}}let t=["text","audio","audioStreamEnd","video"];for(let o of Object.keys(e))if(!t.includes(o))throw new s(`unsupported realtimeInput field "${o}"`);let n=t.filter(o=>e[o]!==void 0);if(n.length!==1)throw new s(`realtimeInput must carry exactly one of ${t.join(", ")} (got ${n.length})`);if(e.audio!==void 0)return{kind:"audio",base64Pcm24k:Pe(e.audio)};if(e.video!==void 0)return{kind:"video",jpegFrame:Ne(e.video)};if(e.audioStreamEnd!==void 0){if(e.audioStreamEnd!==!0)throw new s("realtimeInput.audioStreamEnd must be true when present");return{kind:"audioStreamEnd"}}if(typeof e.text!="string"||e.text.length===0)throw new s("realtimeInput.text must be a non-empty string");return{kind:"text",text:e.text}}function ge(e){for(let t of Object.keys(e))if(t!=="functionResponses")throw new s(`unsupported toolResponse field "${t}"`);if(!Array.isArray(e.functionResponses)||e.functionResponses.length===0)throw new s("toolResponse.functionResponses must be a non-empty array");return e.functionResponses.map(t=>{let n=m(t);if(!n||typeof n.id!="string"||n.id.length===0)throw new s("functionResponses entries require the string id matched from the toolCall");return{type:"function_call_output",call_id:n.id,output:JSON.stringify(n.response??null)}})}function ye(e){return e.type!=="response.output_text.delta"||typeof e.delta!="string"?null:{serverContent:{modelTurn:{role:"model",parts:[{text:e.delta}]}}}}function we(e){return{serverContent:{modelTurn:{role:"model",parts:[{inlineData:{mimeType:F,data:e}}]}}}}function he(e){let t=m(e)??{},n=Array.isArray(t.output)?t.output:[],o=[],r=[],i=typeof t.output_text=="string"?t.output_text:"";if(!i)for(let d of n){let l=m(d);if(!(l?.type!=="message"||!Array.isArray(l.content)))for(let f of l.content){let p=m(f);p?.type==="output_text"&&typeof p.text=="string"&&(i+=p.text)}}i&&r.push({role:"assistant",content:i});for(let d of n){let l=m(d);if(l?.type!=="function_call")continue;if(typeof l.call_id!="string"||typeof l.name!="string")throw new s(`upstream function_call item is missing call_id/name: ${JSON.stringify(d)}`,U);let f=typeof l.arguments=="string"&&l.arguments.length>0?l.arguments:"{}",p;try{p=JSON.parse(f)}catch{throw new s(`upstream function_call arguments are not valid JSON: ${f}`,U)}o.push({id:l.call_id,name:l.name,args:p}),r.push({type:"function_call",call_id:l.call_id,name:l.name,arguments:f})}let a=[];o.length>0&&a.push({toolCall:{functionCalls:o}}),a.push({serverContent:{generationComplete:!0}});let c=m(t.usage),u={serverContent:{turnComplete:!0}};if(c){let d={};typeof c.input_tokens=="number"&&(d.promptTokenCount=c.input_tokens),typeof c.output_tokens=="number"&&(d.responseTokenCount=c.output_tokens),typeof c.total_tokens=="number"&&(d.totalTokenCount=c.total_tokens),Object.keys(d).length>0&&(u.usageMetadata=d)}return a.push(u),{messages:a,assistantItems:r}}function V(e,t,n,o){let r=e.response??{},i={request_id:n,consumer_id:o,stream:!0,kind:"chat",messages:t};return typeof r.instructions=="string"&&(i.instructions=r.instructions),Array.isArray(r.modalities)&&(i.modalities=r.modalities),typeof r.temperature=="number"&&(i.temperature=r.temperature),typeof r.max_output_tokens=="number"&&(i.max_output_tokens=r.max_output_tokens),r.tools!==void 0&&(i.tools=r.tools),i}function M(e,t,n){let o={request_id:t,consumer_id:n,stream:!!e.stream,kind:"responses",input:e.input};return e.model&&(o.model=e.model),e.tools!==void 0&&(o.tools=e.tools),e.tool_choice!==void 0&&(o.tool_choice=e.tool_choice),typeof e.temperature=="number"&&(o.temperature=e.temperature),typeof e.max_output_tokens=="number"&&(o.max_output_tokens=e.max_output_tokens),typeof e.top_p=="number"&&(o.top_p=e.top_p),Array.isArray(e.stop)&&e.stop.length>0&&(o.stop=e.stop),typeof e.reasoning_effort=="string"&&(o.reasoning_effort=e.reasoning_effort),typeof e.instructions=="string"&&(o.instructions=e.instructions),e.chat_template_kwargs!==void 0&&(o.chat_template_kwargs=e.chat_template_kwargs),e.response_format!==void 0&&(o.response_format=e.response_format),typeof e.voice=="string"&&(o.voice=e.voice),typeof e.language=="string"&&(o.language=e.language),o}function ke(e){if(e instanceof Error)return{type:"error",error:{type:"urun_error",code:e.name||null,message:e.message}};if(e&&typeof e=="object"&&e.t==="error"){let t=e,n=t.body??{},o=n.error,r=o?.message??n.message??`unreadable serve error body: ${JSON.stringify(t.body??null)}`;return{type:"error",error:{type:o?.type??"urun_error",code:t.code??o?.code??null,message:r}}}return{type:"error",error:{type:"urun_error",code:null,message:String(e)}}}var $e="llm-resp";async function*Be(e,t){let n=`resp_${e}`,o=new Map;for await(let r of t){let i=r;if(i.t==="delta"){if(typeof i.delta=="string"&&(yield{type:"response.output_text.delta",item_id:n,delta:i.delta}),typeof i.reasoning=="string"&&(yield{type:"response.reasoning_text.delta",item_id:n,delta:i.reasoning}),Array.isArray(i.tool_calls))for(let a of i.tool_calls){let c=typeof a.index=="number"?a.index:0,u=o.get(c)??{};a.id&&(u.id=a.id),a.function?.name&&(u.name=a.function.name),o.set(c,u),yield{type:"response.function_call_arguments.delta",item_id:`fc_${e}_${c}`,tool_index:c,call_id:u.id,name:u.name,delta:a.function?.arguments??""}}}else if(i.t==="response"){yield{type:"response.completed",response:{id:n,status:"completed",...i.body}};return}else if(i.t==="error"){yield ke(i);return}}}async function*A(e,t){let n=`${$e}:${t}`;yield{type:"response.created",response:{id:`resp_${t}`,status:"in_progress"}};try{yield*Be(t,e.stream(n).messages())}finally{try{e.doc("llm").set({requests:{[t]:null}})}catch{}}}var P=class e{constructor(t,n=e.DEFAULT_DOC_SYNC_GATE_TIMEOUT_MS){this.session=t;this.docSyncTimeoutMs=n;this.sessionTag=t.sessionId??globalThis.crypto.randomUUID()}session;docSyncTimeoutMs;sessionTag;static DEFAULT_DOC_SYNC_GATE_TIMEOUT_MS=15e3;get consumerId(){return this.session.consumerId}async ensureDocSynced(){let t=this.session.doc("llm");if(t.synced===!0||typeof t.onSynced!="function")return;let n;await new Promise((r,i)=>{let a=t.onSynced(()=>{clearTimeout(n),r()});n=setTimeout(()=>{a(),i(new Error(`[urun] llm doc plane never synced within ${this.docSyncTimeoutMs}ms \u2014 the request envelope write is withheld rather than raced into a possibly-lost pre-sync write (resumed-attach first-write-lost, prod-usw2 2026-09-23)`))},this.docSyncTimeoutMs)})}write(t){t.session_tag=this.sessionTag,this.session.doc("llm").set({requests:{[t.request_id]:{payload:t,consumer_id:t.consumer_id,stream:t.stream}}})}sendResponses(t,n){return this.writeGated(n,()=>{let o=M(t,n,this.consumerId);return this.write(o),A(this.session,n)})}sendResponseCreate(t,n,o){return this.writeGated(o,()=>{let r=V(t,n,o,this.consumerId);return this.write(r),A(this.session,o)})}async writeGated(t,n){try{await this.ensureDocSynced()}catch(o){throw new Error(`[urun] responses dial ${t} aborted before its envelope write: ${o instanceof Error?o.message:String(o)}`)}return n()}};0&&(module.exports={AudioBridge,CLOSE_PROTOCOL,CLOSE_SESSION_GONE,CLOSE_UNKNOWN_MODEL,CLOSE_UPSTREAM,GEMINI_AUDIO_IN_RATE,GEMINI_AUDIO_OUT_MIME,GEMINI_AUDIO_OUT_RATE,GEMINI_LIVE_PATH,GeminiLiveError,NATIVE_AUDIO_SAMPLE_RATE,OUTBOUND_AUDIO_FLUSH_B64,RT_VIDEO_IN_STREAM,RT_VIDEO_OUT_STREAM,SdkTransport,VIDEO_FRAME_MESSAGE_BUDGET,VIDEO_OUT_DEFAULT_CODEC,VIDEO_OUT_FRAMING,VIDEO_OUT_SETUP_KEY,VIDEO_OUT_WS_FRAMING,consumeVideoOut,decodeResponsesLane,decodeVideoOutRecord,enableSessionAudio,enableSessionVideo,encodeVideoOutRecord,goAwayMsg,negotiateSessionVideoOutQuic,nodeAudioBackend,openSessionVideoOutLane,parseClientMessage,resamplePcm16,responseCreateToEnvelope,responsesCreateToEnvelope,serverContentOfAudio,serverContentOfDelta,sessionResumptionUpdateMsg,translateClientContent,translateRealtimeInput,translateSetup,translateToolResponse,turnEndOfCompleted,videoOutAck,videoOutChunkMsg,weriftAudioBackend});
|
|
1
|
+
"use strict";var be=Object.create;var E=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Ae=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var Se=(e,t)=>{for(var n in t)E(e,n,{get:t[n],enumerable:!0})},W=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Oe(t))!Ee.call(e,r)&&r!==n&&E(e,r,{get:()=>t[r],enumerable:!(o=ve(t,r))||o.enumerable});return e};var $=(e,t,n)=>(n=e!=null?be(Ae(e)):{},W(t||!e||!e.__esModule?E(n,"default",{value:e,enumerable:!0}):n,e)),Te=e=>W(E({},"__esModule",{value:!0}),e);var je={};Se(je,{AudioBridge:()=>O,CLOSE_PROTOCOL:()=>H,CLOSE_SESSION_GONE:()=>re,CLOSE_UNKNOWN_MODEL:()=>oe,CLOSE_UPSTREAM:()=>U,GEMINI_AUDIO_IN_RATE:()=>b,GEMINI_AUDIO_OUT_MIME:()=>F,GEMINI_AUDIO_OUT_RATE:()=>D,GEMINI_LIVE_PATH:()=>ne,GeminiLiveError:()=>s,NATIVE_AUDIO_SAMPLE_RATE:()=>R,OUTBOUND_AUDIO_FLUSH_B64:()=>pe,RT_VIDEO_IN_STREAM:()=>S,RT_VIDEO_OUT_STREAM:()=>_,SdkTransport:()=>P,VIDEO_FRAME_MESSAGE_BUDGET:()=>T,VIDEO_OUT_DEFAULT_CODEC:()=>I,VIDEO_OUT_FRAMING:()=>B,VIDEO_OUT_SETUP_KEY:()=>k,VIDEO_OUT_WS_FRAMING:()=>C,consumeVideoOut:()=>ee,decodeResponsesLane:()=>A,decodeVideoOutRecord:()=>x,enableSessionAudio:()=>J,enableSessionVideo:()=>Y,encodeVideoOutRecord:()=>z,goAwayMsg:()=>le,negotiateSessionVideoOutQuic:()=>X,nodeAudioBackend:()=>K,openSessionVideoOutLane:()=>Z,parseClientMessage:()=>ie,resamplePcm16:()=>j,responseCreateToEnvelope:()=>V,responsesCreateToEnvelope:()=>M,serverContentOfAudio:()=>we,serverContentOfDelta:()=>ye,sessionResumptionUpdateMsg:()=>ce,translateClientContent:()=>fe,translateRealtimeInput:()=>me,translateSetup:()=>de,translateToolResponse:()=>ge,turnEndOfCompleted:()=>he,videoOutAck:()=>ae,videoOutChunkMsg:()=>ue,weriftAudioBackend:()=>q});module.exports=Te(je);var R=24e3,G="audio",O=class{constructor(t,n){this.backend=t;this.opts=n}backend;opts;source=null;sink=null;outHandlers=new Set;async startOutbound(){return this.source=this.backend.createSource(),this.source.track}appendInputAudio(t){if(!this.source)throw new Error("startOutbound() not called");let n=Buffer.from(t,"base64"),o=Math.floor(n.byteLength/2),r=new Int16Array(o);for(let i=0;i<o;i++)r[i]=n.readInt16LE(i*2);this.source.onData(r)}async startInbound(t){if(t==null)throw new Error('startInbound: no downstream audio track \u2014 the runtime audio producer has not been consumed yet (session.stream("audio").track is null)');this.sink=this.backend.createSink(t),this.sink.onframe=n=>{let o=Buffer.from(n.samples.buffer,n.samples.byteOffset,n.samples.byteLength).toString("base64");for(let r of this.outHandlers)r(o)}}onOutputAudio(t){return this.outHandlers.add(t),()=>this.outHandlers.delete(t)}};async function J(e,t,n=1e4){let o=new O(t,{sampleRate:24e3}),r=await o.startOutbound();await e.stream(G).attach(r);let i=await Re(e,n);return await o.startInbound(i),o}function Re(e,t){let n=e.stream(G);return n.track!=null?Promise.resolve(n.track):new Promise((o,r)=>{let i,a=setTimeout(()=>{i?.(),r(new Error(`enableSessionAudio: no downstream audio track within ${t}ms (runtime produced no voice OUT / SFU audio consumer never attached)`))},t),c=u=>{u!=null&&(clearTimeout(a),i?.(),o(u))};i=n.on?.("track",c),n.track!=null&&c(n.track)})}var S="rt-video-in",T=256e3;function Y(e){let t=e.stream(S),n=t.emit;if(typeof n!="function")throw new Error(`enableSessionVideo: session.stream('${S}') has no emit() \u2014 the named-DATA stream produce seam (@urun-sh/core SessionStream.emit, contract \xA75) is required for the video frame lane`);return{sendInputFrame:async o=>{if(o.byteLength===0)throw new Error("enableSessionVideo: refusing to send an empty video frame");if(o.byteLength>T)throw new Error(`enableSessionVideo: frame is ${o.byteLength} bytes \u2014 over the ${T}-byte data-channel budget (the SFU's 262144-byte SCTP ceiling drops oversize messages SILENTLY; send smaller/lower-quality frames)`);await n.call(t,o)}}}var Ie=24e3,v=480,xe=111;async function Ce(){let e=await import("opusscript"),t=e.default??e;return new t(Ie,1,2048)}async function q(){let e=await import("werift"),t=await Ce();return{createSource:()=>{let n=new e.MediaStreamTrack({kind:"audio"}),o=Math.random()*4294967295>>>0,r=Math.random()*65535&65535,i=Math.random()*4294967295>>>0,a=new Int16Array(0);return{track:n,onData:c=>{let u=new Int16Array(a.length+c.length);u.set(a,0),u.set(c,a.length);let d=0;for(;u.length-d>=v;){let l=u.subarray(d,d+v);d+=v;let f=Buffer.from(l.buffer,l.byteOffset,l.byteLength),p=t.encode(f,v);r=r+1&65535,i=i+v>>>0;let g=new e.RtpHeader({version:2,payloadType:xe,sequenceNumber:r,timestamp:i,ssrc:o,marker:!1}),h=new e.RtpPacket(g,p);n.writeRtp(h)}a=u.slice(d)}}},createSink:n=>{let o={onframe:null};return n.onReceiveRtp.subscribe(i=>{let a;try{a=t.decode(i.payload)}catch{return}let c=new Int16Array(a.length/2);for(let u=0;u<c.length;u++)c[u]=a.readInt16LE(u*2);o.onframe?.({samples:c})}),o}}}async function K(){let e=await import("@roamhq/wrtc");return{createSource:()=>{let t=new e.nonstandard.RTCAudioSource;return{track:t.createTrack(),onData:o=>t.onData({samples:o,sampleRate:24e3})}},createSink:t=>{let n={onframe:null},o=new e.nonstandard.RTCAudioSink(t);return o.ondata=r=>{n.onframe?.(r)},n}}}var w=require("@urun-sh/core"),_="rt-video-out",B="urun.videoOut.v1",I="h264";function Q(e,t){if(!Number.isInteger(e.seq)||e.seq<0)throw new Error(`${t}: header seq must be a non-negative integer (got ${e.seq})`);if(!Number.isInteger(e.ptsUs))throw new Error(`${t}: header ptsUs must be an integer microsecond timestamp (got ${e.ptsUs})`);if(typeof e.codec!="string"||e.codec.length===0)throw new Error(`${t}: header codec must be a non-empty string`);if(typeof e.key!="boolean")throw new Error(`${t}: header key must be a boolean`)}function z(e,t){if(Q(e,"encodeVideoOutRecord"),t.byteLength===0)throw new Error("encodeVideoOutRecord: refusing to encode an empty access unit");let n=new TextEncoder().encode(JSON.stringify({v:1,seq:e.seq,ptsUs:e.ptsUs,codec:e.codec,key:e.key}));if(n.byteLength>65535)throw new Error(`encodeVideoOutRecord: header JSON is ${n.byteLength} bytes \u2014 over the u16 length prefix`);let o=new Uint8Array(2+n.byteLength+t.byteLength);return o[0]=n.byteLength&255,o[1]=n.byteLength>>8,o.set(n,2),o.set(t,2+n.byteLength),o}function x(e){if(e.byteLength<2)throw new Error(`decodeVideoOutRecord: truncated record (${e.byteLength} byte(s), no header length)`);let t=e[0]|e[1]<<8;if(e.byteLength<2+t)throw new Error(`decodeVideoOutRecord: truncated record (header says ${t} bytes, ${e.byteLength-2} present)`);let n;try{n=JSON.parse(new TextDecoder().decode(e.subarray(2,2+t)))}catch(a){throw new Error(`decodeVideoOutRecord: header is not valid JSON (${String(a)})`)}let o=n;if(o===null||typeof o!="object"||o.v!==1)throw new Error(`decodeVideoOutRecord: header is not spec v1 (v=${JSON.stringify(o?.v)}) \u2014 a newer producer must be met with a newer consumer, never silently misread`);let r=o;Q(r,"decodeVideoOutRecord");let i=e.subarray(2+t);if(i.byteLength===0)throw new Error("decodeVideoOutRecord: empty access unit \u2014 a record with no AU bytes is a producer bug");return{header:r,au:i.slice()}}async function X(e){let t=e.wtDataEndpoint;if(typeof t!="function")throw new Error("negotiateSessionVideoOutQuic: the core session exposes no wtDataEndpoint() \u2014 the \xA75-over-QUIC dial seam (urun-infra#1608 TransportOfferResponse.webtransport, offered with wtData: true) is required for the video OUT lane; there is no WS fallback");let n=await t.call(e),o=n.sessionId??e.sessionId;if(typeof o!="string"||o.length===0)throw new Error("negotiateSessionVideoOutQuic: no session id \u2014 the WT hello requires one and neither the negotiated endpoint nor the core session carries it");return{transport:"webtransport",url:n.url,certHashes:n.certHashes,token:n.token,sessionId:o,stream:_,codec:I,framing:B}}var C="urun.videoOut.v2-ws";function Z(e){let t=e.stream(_);if(typeof t.messages!="function")throw new Error(`openSessionVideoOutLane: session.stream('${_}') has no messages() \u2014 the named-DATA stream consume seam (@urun-sh/core SessionStream.messages, contract \xA75) is required for the video OUT lane`);let n=new Set,o=new Set,r=new Set,i=u=>{for(let d of o)d(u)},a=!1,c=async()=>{for await(let u of t.messages()){if(!(u instanceof Uint8Array)){i(new Error(`openSessionVideoOutLane: "${_}" delivered a non-BINARY \xA75 payload (${typeof u}) \u2014 spec v1 records ride BINARY envelopes only`));continue}let d;try{d=x(u)}catch(l){i(l instanceof Error?l:new Error(String(l)));continue}for(let l of n)l(d)}for(let u of r)u()};return{codec:I,onOutputFrame:u=>(n.add(u),a||(a=!0,c().catch(d=>i(d instanceof Error?d:new Error(String(d))))),()=>n.delete(u)),onLaneError:u=>(o.add(u),()=>o.delete(u)),onEnd:u=>(r.add(u),()=>r.delete(u))}}function Le(e){if(e.length%2!==0||/[^0-9a-fA-F]/.test(e))throw new Error(`consumeVideoOut: certHashes entry is not hex sha-256 (${JSON.stringify(e)})`);let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}async function ee(e,t,n){let o=n??(typeof globalThis.WebTransport=="function"?(d,l)=>new globalThis.WebTransport(d,l):void 0);if(!o)throw new Error("consumeVideoOut: no WebTransport implementation \u2014 this platform has no globalThis.WebTransport; inject a connect factory (the third argument)");let r=o(e.url,{serverCertificateHashes:e.certHashes.map(d=>({algorithm:"sha-256",value:Le(d)}))});await r.ready;let i=await r.createBidirectionalStream();await i.writable.getWriter().write((0,w.encodeWtControlFrame)({t:"hello",token:e.token,sessionId:e.sessionId}));let a=i.readable.getReader(),c=new w.WtControlDecoder,u=!1;for(;!u;){let{value:d,done:l}=await a.read();if(l)throw new Error("consumeVideoOut: gateway closed the control stream before hello-ack");if(d)for(let f of c.push(d)){if(f.t==="hello-ack"){u=!0;break}throw new Error(`consumeVideoOut: gateway rejected hello (got ${JSON.stringify(f.t)} before hello-ack)`)}}await(0,w.consumeWtDataStreams)(r.incomingUnidirectionalStreams,{onData:(d,l)=>{if(d===e.stream){if(l===w.STREAM_END){t.onEnd?.();return}if(!(l instanceof Uint8Array)){t.onLaneError(new Error(`consumeVideoOut: "${e.stream}" delivered a non-BINARY \xA75 payload (${typeof l}) \u2014 spec v1 records ride BINARY envelopes only`));return}try{t.onFrame(x(l))}catch(f){t.onLaneError(f instanceof Error?f:new Error(String(f)))}}},onLaneError:d=>t.onLaneError(d)})}var ne="/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent",H=1007,oe=1008,U=1011,re=1008,s=class extends Error{constructor(n,o=H){super(n);this.closeCode=o}closeCode},m=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null,L=["setup","clientContent","realtimeInput","toolResponse"];function ie(e){let t;try{t=JSON.parse(e)}catch{throw new s("client message is not valid JSON")}let n=m(t);if(!n)throw new s("client message must be a JSON object");let o=L.filter(c=>n[c]!==void 0),r=Object.keys(n).filter(c=>!L.includes(c));if(r.length>0)throw new s(`unknown client message field(s) ${JSON.stringify(r)} \u2014 expected exactly one of ${L.join(", ")}`);if(o.length!==1)throw new s(`client message must contain exactly one of ${L.join(", ")} (got ${o.length})`);let i=o[0],a=m(n[i]);if(!a)throw new s(`"${i}" must be a JSON object`);return{kind:i,[i]:a}}function se(e,t){if(typeof e=="string")return e;let n=m(e),o=n?n.parts:void 0;if(!Array.isArray(o))throw new s(`${t}: expected a Content with a parts array`);let r=[];for(let i of o){let a=m(i);if(a&&typeof a.text=="string"){r.push(a.text);continue}throw a&&(a.inlineData!==void 0||a.fileData!==void 0)?new s(`${t}: media parts (inlineData/fileData) are a declared follow-up slice (audio/video lanes over the proxy transport AudioBridge) \u2014 only text parts are supported in this slice`):a&&(a.functionCall!==void 0||a.functionResponse!==void 0)?new s(`${t}: functionCall/functionResponse parts are not valid here \u2014 the Live API exchanges tool traffic via the dedicated toolCall/toolResponse messages`):new s(`${t}: unsupported part ${JSON.stringify(i)}`)}return r.join(`
|
|
2
|
+
`)}var Ue={manualActivity:!1,activityHandling:"START_OF_ACTIVITY_INTERRUPTS"},k="urun.videoOut";function ae(e){return{framing:C,codec:e}}function ue(e){let{seq:t,ptsUs:n,codec:o,key:r}=e.header;return{[k]:{v:1,seq:t,ptsUs:n,codec:o,key:r,data:Buffer.from(e.au).toString("base64")}}}var De={inputAudioTranscription:"setup.inputAudioTranscription is part of the declared audio follow-up slice",outputAudioTranscription:"setup.outputAudioTranscription is part of the declared audio follow-up slice"},Ve=["model","generationConfig","systemInstruction","tools","realtimeInputConfig","sessionResumption",k],te=["START_OF_ACTIVITY_INTERRUPTS","NO_INTERRUPTION"];function Me(e){let t=m(e);if(!t)throw new s("setup.realtimeInputConfig must be an object");for(let r of Object.keys(t))if(!(r==="automaticActivityDetection"||r==="activityHandling"))throw new s(r==="turnCoverage"?"realtimeInputConfig.turnCoverage is part of the declared audio follow-up slice":`unsupported realtimeInputConfig field "${r}"`);let n=m(t.automaticActivityDetection);if(t.automaticActivityDetection!==void 0&&!n)throw new s("realtimeInputConfig.automaticActivityDetection must be an object");for(let r of Object.keys(n??{}))if(r!=="disabled")throw new s(`automaticActivityDetection.${r} tunes AUTOMATIC (server-side) activity detection \u2014 the declared platform follow-up (serve turn_detection events over the session stream lane); only "disabled: true" (manual activity mode) is supported in this slice`);if(n?.disabled!==!0)throw new s("automatic (server-side) activity detection is the declared platform follow-up (serve turn_detection turn_start/turn_end events over the session stream lane, not proxy DSP) \u2014 set realtimeInputConfig.automaticActivityDetection.disabled: true for manual activity mode");let o="START_OF_ACTIVITY_INTERRUPTS";if(t.activityHandling!==void 0){if(!te.includes(t.activityHandling))throw new s(`unsupported activityHandling ${JSON.stringify(t.activityHandling)} \u2014 expected one of ${te.join(", ")}`);o=t.activityHandling}return{manualActivity:!0,activityHandling:o}}var Ne=["temperature","maxOutputTokens","responseModalities"];function de(e){for(let[f,p]of Object.entries(De))if(e[f]!==void 0)throw new s(p);for(let f of Object.keys(e))if(!Ve.includes(f))throw new s(`unsupported setup field "${f}"`);if(typeof e.model!="string"||e.model.length===0)throw new s('setup.model is required (format "models/{model}")');let t=e.model.replace(/^models\//,""),n,o,r=!1,i=m(e.generationConfig);if(e.generationConfig!==void 0&&!i)throw new s("setup.generationConfig must be an object");if(i){for(let f of Object.keys(i))if(!Ne.includes(f))throw new s(`unsupported generationConfig field "${f}"`);if(i.temperature!==void 0){if(typeof i.temperature!="number")throw new s("generationConfig.temperature must be a number");n=i.temperature}if(i.maxOutputTokens!==void 0){if(typeof i.maxOutputTokens!="number")throw new s("generationConfig.maxOutputTokens must be a number");o=i.maxOutputTokens}if(i.responseModalities!==void 0){let f=Array.isArray(i.responseModalities)?i.responseModalities:[i.responseModalities];for(let p of f){let g=String(p).toUpperCase();if(g==="AUDIO"){r=!0;continue}if(g!=="TEXT")throw new s(`responseModalities ${JSON.stringify(p)} is not supported \u2014 this surface speaks TEXT and AUDIO (audio-out rides the native AudioBridge 'audio' lane)`)}}}let a=[];e.systemInstruction!==void 0&&a.push({role:"system",content:se(e.systemInstruction,"setup.systemInstruction")});let c;if(e.tools!==void 0){if(!Array.isArray(e.tools))throw new s("setup.tools must be an array");c=[];for(let f of e.tools){let p=m(f);if(!p)throw new s("setup.tools entries must be objects");for(let g of Object.keys(p))if(g!=="functionDeclarations")throw new s(`unsupported tool "${g}" \u2014 this slice translates functionDeclarations only (no googleSearch/codeExecution)`);if(!Array.isArray(p.functionDeclarations))throw new s("tool.functionDeclarations must be an array");for(let g of p.functionDeclarations){let h=m(g);if(!h||typeof h.name!="string")throw new s("functionDeclarations entries require a string name");c.push({type:"function",name:h.name,description:h.description,parameters:h.parameters})}}c.length===0&&(c=void 0)}let u={enabled:!1,handle:null};if(e.sessionResumption!==void 0){let f=m(e.sessionResumption);if(!f)throw new s("setup.sessionResumption must be an object (SessionResumptionConfig)");for(let p of Object.keys(f))if(p!=="handle")throw new s(`unsupported sessionResumption field "${p}" \u2014 this lane implements SessionResumptionConfig.handle only`);if(f.handle!==void 0&&(typeof f.handle!="string"||f.handle.length===0))throw new s("sessionResumption.handle must be a non-empty string when present");u={enabled:!0,handle:typeof f.handle=="string"?f.handle:null}}let d=e.realtimeInputConfig===void 0?Ue:Me(e.realtimeInputConfig),l=!1;if(e[k]!==void 0){if(!m(e[k]))throw new s(`setup["${k}"] must be an object (the v1 opt-in is {})`);l=!0}return{model:t,systemItems:a,tools:c,temperature:n,maxOutputTokens:o,audioModality:r,activity:d,sessionResumption:u,videoOut:l}}function ce(e){return{sessionResumptionUpdate:{newHandle:e,resumable:!0}}}function le(e){let t=Math.max(0,e??0)/1e3;return{goAway:{timeLeft:`${Math.round(t*1e3)/1e3}s`}}}function fe(e){for(let o of Object.keys(e))if(o!=="turns"&&o!=="turnComplete")throw new s(`unsupported clientContent field "${o}"`);let t=e.turns===void 0?[]:e.turns;if(!Array.isArray(t))throw new s("clientContent.turns must be an array");let n=[];for(let o of t){let r=m(o);if(!r)throw new s("clientContent.turns entries must be Content objects");let i=r.role===void 0?"user":String(r.role).toLowerCase();if(i!=="user"&&i!=="model")throw new s(`clientContent turn role must be "user" or "model" (got ${JSON.stringify(r.role)})`);n.push({role:i==="model"?"assistant":"user",content:se(r,"clientContent.turns")})}return{items:n,turnComplete:e.turnComplete===!0}}var b=16e3,D=24e3,F=`audio/pcm;rate=${D}`,pe=Buffer.alloc(960).toString("base64");function j(e,t,n){if(t===n)return e;let o=Math.floor(e.length*n/t),r=new Int16Array(o),i=t/n,a=e.length-1;for(let c=0;c<o;c++){let u=c*i,d=Math.floor(u);if(d>=a){r[c]=e[a];continue}let l=u-d;r[c]=Math.round(e[d]+(e[d+1]-e[d])*l)}return r}function Pe(e){let t=m(e);if(!t)throw new s("realtimeInput.video must be a Blob object {mimeType, data}");if(typeof t.mimeType!="string"||!/^image\/jpeg\s*(;|$)/.test(t.mimeType))throw new s(`realtimeInput.video.mimeType must be image/jpeg (the Live video input stream is individual JPEG frames), got ${JSON.stringify(t.mimeType)}`);if(typeof t.data!="string"||t.data.length===0)throw new s("realtimeInput.video.data must be non-empty base64");let n=Buffer.from(t.data,"base64");if(n.length<3||n[0]!==255||n[1]!==216)throw new s("realtimeInput.video.data does not decode to a JPEG frame (missing FF D8 SOI marker)");return new Uint8Array(n)}function $e(e){let t=m(e);if(!t)throw new s("realtimeInput.audio must be a Blob object {mimeType, data}");if(typeof t.mimeType!="string"||!/^audio\/pcm\s*(;|$)/.test(t.mimeType))throw new s(`realtimeInput.audio.mimeType must be audio/pcm (16-bit LE PCM @16kHz mono per the Live spec), got ${JSON.stringify(t.mimeType)}`);let n=/;\s*rate=(\d+)/.exec(t.mimeType);if(n&&Number(n[1])!==b)throw new s(`realtimeInput.audio.mimeType declares rate=${n[1]} \u2014 the Live spec input format is ${b} Hz (audio/pcm;rate=${b})`);if(typeof t.data!="string"||t.data.length===0)throw new s("realtimeInput.audio.data must be non-empty base64");let o=Buffer.from(t.data,"base64");if(o.length===0||o.length%2!==0)throw new s(`realtimeInput.audio.data must decode to whole 16-bit samples (got ${o.length} bytes \u2014 not even)`);let r=new Int16Array(o.length/2);for(let a=0;a<r.length;a++)r[a]=o.readInt16LE(a*2);let i=j(r,b,D);return Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString("base64")}function me(e){if(e.mediaChunks!==void 0)throw new s('realtimeInput.mediaChunks is deprecated by the Live API \u2014 send the audio stream via realtimeInput.audio ({mimeType:"audio/pcm;rate=16000", data}) instead');if(e.activityStart!==void 0||e.activityEnd!==void 0){if(Object.keys(e).length!==1||e.activityStart!==void 0&&e.activityEnd!==void 0)throw new s("realtimeInput must carry exactly one field when signaling activity (activityStart XOR activityEnd, nothing else)");let r=e.activityStart!==void 0?"activityStart":"activityEnd",i=m(e[r]);if(!i||Object.keys(i).length!==0)throw new s(`realtimeInput.${r} must be an empty object (ActivityStart/ActivityEnd are bare markers)`);return{kind:r}}let t=["text","audio","audioStreamEnd","video"];for(let o of Object.keys(e))if(!t.includes(o))throw new s(`unsupported realtimeInput field "${o}"`);let n=t.filter(o=>e[o]!==void 0);if(n.length!==1)throw new s(`realtimeInput must carry exactly one of ${t.join(", ")} (got ${n.length})`);if(e.audio!==void 0)return{kind:"audio",base64Pcm24k:$e(e.audio)};if(e.video!==void 0)return{kind:"video",jpegFrame:Pe(e.video)};if(e.audioStreamEnd!==void 0){if(e.audioStreamEnd!==!0)throw new s("realtimeInput.audioStreamEnd must be true when present");return{kind:"audioStreamEnd"}}if(typeof e.text!="string"||e.text.length===0)throw new s("realtimeInput.text must be a non-empty string");return{kind:"text",text:e.text}}function ge(e){for(let t of Object.keys(e))if(t!=="functionResponses")throw new s(`unsupported toolResponse field "${t}"`);if(!Array.isArray(e.functionResponses)||e.functionResponses.length===0)throw new s("toolResponse.functionResponses must be a non-empty array");return e.functionResponses.map(t=>{let n=m(t);if(!n||typeof n.id!="string"||n.id.length===0)throw new s("functionResponses entries require the string id matched from the toolCall");return{type:"function_call_output",call_id:n.id,output:JSON.stringify(n.response??null)}})}function ye(e){return e.type!=="response.output_text.delta"||typeof e.delta!="string"?null:{serverContent:{modelTurn:{role:"model",parts:[{text:e.delta}]}}}}function we(e){return{serverContent:{modelTurn:{role:"model",parts:[{inlineData:{mimeType:F,data:e}}]}}}}function he(e){let t=m(e)??{},n=Array.isArray(t.output)?t.output:[],o=[],r=[],i=typeof t.output_text=="string"?t.output_text:"";if(!i)for(let d of n){let l=m(d);if(!(l?.type!=="message"||!Array.isArray(l.content)))for(let f of l.content){let p=m(f);p?.type==="output_text"&&typeof p.text=="string"&&(i+=p.text)}}i&&r.push({role:"assistant",content:i});for(let d of n){let l=m(d);if(l?.type!=="function_call")continue;if(typeof l.call_id!="string"||typeof l.name!="string")throw new s(`upstream function_call item is missing call_id/name: ${JSON.stringify(d)}`,U);let f=typeof l.arguments=="string"&&l.arguments.length>0?l.arguments:"{}",p;try{p=JSON.parse(f)}catch{throw new s(`upstream function_call arguments are not valid JSON: ${f}`,U)}o.push({id:l.call_id,name:l.name,args:p}),r.push({type:"function_call",call_id:l.call_id,name:l.name,arguments:f})}let a=[];o.length>0&&a.push({toolCall:{functionCalls:o}}),a.push({serverContent:{generationComplete:!0}});let c=m(t.usage),u={serverContent:{turnComplete:!0}};if(c){let d={};typeof c.input_tokens=="number"&&(d.promptTokenCount=c.input_tokens),typeof c.output_tokens=="number"&&(d.responseTokenCount=c.output_tokens),typeof c.total_tokens=="number"&&(d.totalTokenCount=c.total_tokens),Object.keys(d).length>0&&(u.usageMetadata=d)}return a.push(u),{messages:a,assistantItems:r}}async function ke(e,t,n){if(e.synced===!0||typeof e.onSynced!="function")return;let o;await new Promise((r,i)=>{let a=e.onSynced(()=>{clearTimeout(o),r()});o=setTimeout(()=>{a(),i(new Error(`[urun] llm doc plane never synced within ${t}ms \u2014 ${n} is withheld rather than raced into a possibly-lost pre-sync write (resumed-attach first-write-lost, prod-usw2 2026-09-23)`))},t)})}function V(e,t,n,o){let r=e.response??{},i={request_id:n,consumer_id:o,stream:!0,kind:"chat",messages:t};return typeof r.instructions=="string"&&(i.instructions=r.instructions),Array.isArray(r.modalities)&&(i.modalities=r.modalities),typeof r.temperature=="number"&&(i.temperature=r.temperature),typeof r.max_output_tokens=="number"&&(i.max_output_tokens=r.max_output_tokens),r.tools!==void 0&&(i.tools=r.tools),i}function M(e,t,n){let o={request_id:t,consumer_id:n,stream:!!e.stream,kind:"responses",input:e.input};return e.model&&(o.model=e.model),e.tools!==void 0&&(o.tools=e.tools),e.tool_choice!==void 0&&(o.tool_choice=e.tool_choice),typeof e.temperature=="number"&&(o.temperature=e.temperature),typeof e.max_output_tokens=="number"&&(o.max_output_tokens=e.max_output_tokens),typeof e.top_p=="number"&&(o.top_p=e.top_p),Array.isArray(e.stop)&&e.stop.length>0&&(o.stop=e.stop),typeof e.reasoning_effort=="string"&&(o.reasoning_effort=e.reasoning_effort),typeof e.instructions=="string"&&(o.instructions=e.instructions),e.chat_template_kwargs!==void 0&&(o.chat_template_kwargs=e.chat_template_kwargs),e.response_format!==void 0&&(o.response_format=e.response_format),typeof e.voice=="string"&&(o.voice=e.voice),typeof e.language=="string"&&(o.language=e.language),o}function _e(e){if(e instanceof Error)return{type:"error",error:{type:"urun_error",code:e.name||null,message:e.message}};if(e&&typeof e=="object"&&e.t==="error"){let t=e,n=t.body??{},o=n.error,r=o?.message??n.message??`unreadable serve error body: ${JSON.stringify(t.body??null)}`;return{type:"error",error:{type:o?.type??"urun_error",code:t.code??o?.code??null,message:r}}}return{type:"error",error:{type:"urun_error",code:null,message:String(e)}}}var Be="llm-resp";async function*He(e,t){let n=`resp_${e}`,o=new Map;for await(let r of t){let i=r;if(i.t==="delta"){if(typeof i.delta=="string"&&(yield{type:"response.output_text.delta",item_id:n,delta:i.delta}),typeof i.reasoning=="string"&&(yield{type:"response.reasoning_text.delta",item_id:n,delta:i.reasoning}),Array.isArray(i.tool_calls))for(let a of i.tool_calls){let c=typeof a.index=="number"?a.index:0,u=o.get(c)??{};a.id&&(u.id=a.id),a.function?.name&&(u.name=a.function.name),o.set(c,u),yield{type:"response.function_call_arguments.delta",item_id:`fc_${e}_${c}`,tool_index:c,call_id:u.id,name:u.name,delta:a.function?.arguments??""}}}else if(i.t==="response"){yield{type:"response.completed",response:{id:n,status:"completed",...i.body}};return}else if(i.t==="error"){yield _e(i);return}}}async function*A(e,t){let n=`${Be}:${t}`;yield{type:"response.created",response:{id:`resp_${t}`,status:"in_progress"}};try{yield*He(t,e.stream(n).messages())}finally{try{e.doc("llm").set({requests:{[t]:null}})}catch{}}}var P=class{constructor(t,n=15e3){this.session=t;this.docSyncTimeoutMs=n;this.sessionTag=t.sessionId??globalThis.crypto.randomUUID()}session;docSyncTimeoutMs;sessionTag;get consumerId(){return this.session.consumerId}write(t){t.session_tag=this.sessionTag,this.session.doc("llm").set({requests:{[t.request_id]:{payload:t,consumer_id:t.consumer_id,stream:t.stream}}})}sendResponses(t,n){return this.writeGated(n,()=>{let o=M(t,n,this.consumerId);return this.write(o),A(this.session,n)})}sendResponseCreate(t,n,o){return this.writeGated(o,()=>{let r=V(t,n,o,this.consumerId);return this.write(r),A(this.session,o)})}async writeGated(t,n){try{await ke(this.session.doc("llm"),this.docSyncTimeoutMs,"the request envelope write")}catch(o){throw new Error(`[urun] responses dial ${t} aborted before its envelope write: ${o instanceof Error?o.message:String(o)}`)}return n()}};0&&(module.exports={AudioBridge,CLOSE_PROTOCOL,CLOSE_SESSION_GONE,CLOSE_UNKNOWN_MODEL,CLOSE_UPSTREAM,GEMINI_AUDIO_IN_RATE,GEMINI_AUDIO_OUT_MIME,GEMINI_AUDIO_OUT_RATE,GEMINI_LIVE_PATH,GeminiLiveError,NATIVE_AUDIO_SAMPLE_RATE,OUTBOUND_AUDIO_FLUSH_B64,RT_VIDEO_IN_STREAM,RT_VIDEO_OUT_STREAM,SdkTransport,VIDEO_FRAME_MESSAGE_BUDGET,VIDEO_OUT_DEFAULT_CODEC,VIDEO_OUT_FRAMING,VIDEO_OUT_SETUP_KEY,VIDEO_OUT_WS_FRAMING,consumeVideoOut,decodeResponsesLane,decodeVideoOutRecord,enableSessionAudio,enableSessionVideo,encodeVideoOutRecord,goAwayMsg,negotiateSessionVideoOutQuic,nodeAudioBackend,openSessionVideoOutLane,parseClientMessage,resamplePcm16,responseCreateToEnvelope,responsesCreateToEnvelope,serverContentOfAudio,serverContentOfDelta,sessionResumptionUpdateMsg,translateClientContent,translateRealtimeInput,translateSetup,translateToolResponse,turnEndOfCompleted,videoOutAck,videoOutChunkMsg,weriftAudioBackend});
|
package/dist/gemini-live.d.cts
CHANGED
|
@@ -114,36 +114,10 @@ declare class SdkTransport {
|
|
|
114
114
|
* persistent session, so a per-transport tag identifies the session too.
|
|
115
115
|
*/
|
|
116
116
|
private readonly sessionTag;
|
|
117
|
-
/** The shipped gate deadline — the only production value (test seam overrides it). */
|
|
118
|
-
private static readonly DEFAULT_DOC_SYNC_GATE_TIMEOUT_MS;
|
|
119
117
|
constructor(session: UrunSessionLike,
|
|
120
118
|
/** Test seam for the gate deadline; never an env knob or config surface. */
|
|
121
119
|
docSyncTimeoutMs?: number);
|
|
122
120
|
get consumerId(): string;
|
|
123
|
-
/**
|
|
124
|
-
* THE FIRST-WRITE-LOST GATE (resumed-attach, prod-usw2 2026-09-23): a turn's
|
|
125
|
-
* request envelope is the llm doc's FIRST write after a cold (re-)attach, and
|
|
126
|
-
* the dial's `whenLive` gate resolves off the SIGNALING status frame — which
|
|
127
|
-
* routinely lands while the yjs doc provider is still dialing its room. A
|
|
128
|
-
* local write applied while the provider has no socket is relayed ONLY through
|
|
129
|
-
* the initial-sync diff exchange, and on a resumed session that exchange races
|
|
130
|
-
* the session-server's S3 hydration barrier. Observed live (local proxy against
|
|
131
|
-
* prod, dial resumed the long-parked shared-org session): the 396-byte envelope
|
|
132
|
-
* applied at `wsconnected=false synced=false` NEVER reached the room — the
|
|
133
|
-
* serve runtime drained the doc for the caller's whole timeout budget and
|
|
134
|
-
* never saw the request (`drain: 2 in doc, 0 pending`, no change events), while
|
|
135
|
-
* the client's provider reported `synced`. The write is silently stranded.
|
|
136
|
-
*
|
|
137
|
-
* So every request-envelope write first holds for the doc plane's OWN
|
|
138
|
-
* readiness — `synced`, the provider's level-triggered initial-sync bar.
|
|
139
|
-
* Post-sync writes ride the connected socket directly and are delivered.
|
|
140
|
-
* Bounded and loud on deadline: the caller (rehome's one re-dial, then the
|
|
141
|
-
* lane's loud 502) owns the verdict — never a silent loss. A session double
|
|
142
|
-
* that exposes no `onSynced` surface cannot be gated and is skipped honestly
|
|
143
|
-
* (same structural-seam contract as `onConnectionState`).
|
|
144
|
-
*/
|
|
145
|
-
/** Hold until the llm doc plane has completed its first sync (bounded, loud). */
|
|
146
|
-
private ensureDocSynced;
|
|
147
121
|
private write;
|
|
148
122
|
sendResponses(params: {
|
|
149
123
|
model?: string;
|
package/dist/gemini-live.d.ts
CHANGED
|
@@ -68,15 +68,10 @@ declare class SdkTransport {
|
|
|
68
68
|
private readonly docSyncTimeoutMs;
|
|
69
69
|
|
|
70
70
|
private readonly sessionTag;
|
|
71
|
-
|
|
72
|
-
private static readonly DEFAULT_DOC_SYNC_GATE_TIMEOUT_MS;
|
|
73
71
|
constructor(session: UrunSessionLike,
|
|
74
72
|
|
|
75
73
|
docSyncTimeoutMs?: number);
|
|
76
74
|
get consumerId(): string;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
private ensureDocSynced;
|
|
80
75
|
private write;
|
|
81
76
|
sendResponses(params: {
|
|
82
77
|
model?: string;
|
package/dist/gemini-live.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c,b as C,c as L,d as M,e as R,f as D,g as f,h as N,i as v,j as g,k as x,l as k,m as y,n as G,o as B,p as F,q as P,r as H,s as W,t as b,u as w,v as K,w as h,x as Q}from"./chunk-3JWYIKHM.js";import{a as i,b as s,c as O,d,e as a,f as E,g as _,h as p,i as u,j as A,k as S,l as I,m as T,n as l,o as m,p as U,q as V}from"./chunk-6M5JK4YC.js";import{a as o,b as t,e as n,f as r}from"./chunk-
|
|
1
|
+
import{a as c,b as C,c as L,d as M,e as R,f as D,g as f,h as N,i as v,j as g,k as x,l as k,m as y,n as G,o as B,p as F,q as P,r as H,s as W,t as b,u as w,v as K,w as h,x as Q}from"./chunk-3JWYIKHM.js";import{a as i,b as s,c as O,d,e as a,f as E,g as _,h as p,i as u,j as A,k as S,l as I,m as T,n as l,o as m,p as U,q as V}from"./chunk-6M5JK4YC.js";import{a as o,b as t,e as n,f as r}from"./chunk-ETX6IX25.js";import"./chunk-7KRHHEKZ.js";import{c as e}from"./chunk-YSFSRI3D.js";e();export{s as AudioBridge,C as CLOSE_PROTOCOL,R as CLOSE_SESSION_GONE,L as CLOSE_UNKNOWN_MODEL,M as CLOSE_UPSTREAM,B as GEMINI_AUDIO_IN_RATE,P as GEMINI_AUDIO_OUT_MIME,F as GEMINI_AUDIO_OUT_RATE,c as GEMINI_LIVE_PATH,D as GeminiLiveError,i as NATIVE_AUDIO_SAMPLE_RATE,H as OUTBOUND_AUDIO_FLUSH_B64,d as RT_VIDEO_IN_STREAM,u as RT_VIDEO_OUT_STREAM,r as SdkTransport,a as VIDEO_FRAME_MESSAGE_BUDGET,S as VIDEO_OUT_DEFAULT_CODEC,A as VIDEO_OUT_FRAMING,N as VIDEO_OUT_SETUP_KEY,m as VIDEO_OUT_WS_FRAMING,V as consumeVideoOut,n as decodeResponsesLane,T as decodeVideoOutRecord,O as enableSessionAudio,E as enableSessionVideo,I as encodeVideoOutRecord,y as goAwayMsg,l as negotiateSessionVideoOutQuic,p as nodeAudioBackend,U as openSessionVideoOutLane,f as parseClientMessage,W as resamplePcm16,o as responseCreateToEnvelope,t as responsesCreateToEnvelope,h as serverContentOfAudio,K as serverContentOfDelta,k as sessionResumptionUpdateMsg,G as translateClientContent,b as translateRealtimeInput,x as translateSetup,w as translateToolResponse,Q as turnEndOfCompleted,v as videoOutAck,g as videoOutChunkMsg,_ as weriftAudioBackend};
|