PageSourceSearch

https://knotie-ai.pro/_next/static/chunks/4588.ba305cd6be390158.js

js knotie-ai.pro collected 2026-10-09 22:58:43 UTC 7,929 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4588,32903],{4588:function(t,e,s){s.r(e),s.d(e,{AgentReaction:function(){return u},Medium:function(){return l},Role:function(){return c},Transcript:function(){return d},UltravoxDataMessageEvent:function(){return E},UltravoxExperimentalMessageEvent:function(){return S},UltravoxSession:function(){return T},UltravoxSessionStatus:function(){return n},UltravoxSessionStatusChangedEvent:function(){return p},UltravoxTranscriptsChangedEvent:function(){return m}});var i,a,r,o,n,c,l,u,h=s(53819);(i=n||(n={})).DISCONNECTED="disconnected",i.DISCONNECTING="disconnecting",i.CONNECTING="connecting",i.IDLE="idle",i.LISTENING="listening",i.THINKING="thinking",i.SPEAKING="speaking",(a=c||(c={})).USER="user",a.AGENT="agent",(r=l||(l={})).VOICE="voice",r.TEXT="text",(o=u||(u={})).SPEAKS="speaks",o.LISTENS="listens",o.SPEAKS_ONCE="speaks-once";class d{text;isFinal;speaker;medium;constructor(t,e,s,i){this.text=t,this.isFinal=e,this.speaker=s,this.medium=i}}class p extends Event{constructor(){super("status")}}class m extends Event{constructor(){super("transcripts")}}class S extends Event{message;constructor(t){super("experimental_message"),this.message=t}}class E extends Event{message;constructor(t){super("data_message"),this.message=t}}class T extends EventTarget{static CONNECTED_STATUSES=new Set([n.LISTENING,n.THINKING,n.SPEAKING]);_transcripts=[];_status=n.DISCONNECTED;registeredTools=new Map;socket;room;audioElement=new Audio;localAudioTrack;micSourceNode;agentSourceNode;delayedSpeakingState=!1;textDecoder=new TextDecoder;textEncoder=new TextEncoder;audioContext;experimentalMessages;_isMicMuted=!1;_isSpeakerMuted=!1;constructor({audioContext:t,experimentalMessages:e}={}){super(),this.audioContext=t||new AudioContext,this.experimentalMessages=e||new Set}get transcripts(){return[...this._transcripts.filter(t=>null!=t)]}get status(){return this._status}get isMicMuted(){return this._isMicMuted}get isSpeakerMuted(){return this._isSpeakerMuted}registerToolImplementation(t,e){this.registeredTools.set(t,e)}registerToolImplementations(t){for(let[e,s]of Object.entries(t))this.registerToolImplementation(e,s)}joinCall(t,e){if(this._status!==n.DISCONNECTED)throw Error("Cannot join a new call while already in a call");let s=new URL(t),i="web_0.3.6";e&&(i+=`:${e}`),s.searchParams.set("clientVersion",i),s.searchParams.set("apiVersion","1"),this.experimentalMessages&&s.searchParams.set("experimentalMessages",Array.from(this.experimentalMessages.values()).join(",")),t=s.toString(),this.setStatus(n.CONNECTING),this.socket=new WebSocket(t),this.socket.onmessage=t=>this.handleSocketMessage(t),this.socket.onclose=t=>this.handleSocketClose(t)}async leaveCall(){await this.disconnect()}setOutputMedium(t){if(!T.CONNECTED_STATUSES.has(this._status))throw Error(`Cannot set output medium while not connected. Current status is ${this._status}.`);this.sendData({type:"set_output_medium",medium:t})}sendText(t,e){if(!T.CONNECTED_STATUSES.has(this._status))throw Error(`Cannot send text while not connected. Current status is ${this._status}.`);this.sendData({type:"input_text_message",text:t,deferResponse:e})}sendData(t){if(void 0==t.type)throw Error("Data must have a type field");let e=JSON.stringify(t),s=this.textEncoder.encode(e);s.length>1024?this.socket?.send(e):this.room?.localParticipant.publishData(s,{reliable:!0})}muteMic(){if(!this.room?.localParticipant)throw Error("Cannot muteMic.");this._isMicMuted=!0,this.room.localParticipant.setMicrophoneEnabled(!1)}unmuteMic(){if(!this.room?.localParticipant)throw Error("Cannot unmuteMic.");this._isMicMuted=!1,this.room.localParticipant.setMicrophoneEnabled(!0)}toggleMicMute(){if(!this.room?.localParticipant)throw Error("Cannot toggle mic mute.");this.isMicMuted?this.unmuteMic():this.muteMic()}muteSpeaker(){if(!this.room?.remoteParticipants)throw Error("Cannot muteSpeaker.");
1this._isSpeakerMuted=!0,this.room.remoteParticipants.forEach(t=>{t.audioTrackPublications.forEach(t=>{t.track?.setMuted(!0)})})}unmuteSpeaker(){if(!this.room?.remoteParticipants)throw Error("Cannot unmuteSpeaker.");this._isSpeakerMuted=!1,this.room.remoteParticipants.forEach(t=>{t.audioTrackPublications.forEach(t=>{t.track?.setMuted(!1)})})}toggleSpeakerMute(){if(!this.room?.remoteParticipants)throw Error("Cannot toggle speaker mute.");this.isSpeakerMuted?this.unmuteSpeaker():this.muteSpeaker()}async handleSocketMessage(t){let e=JSON.parse(t.data);this.room=new h.du({webAudioMix:!1}),this.room.on(h.TQ.TrackSubscribed,t=>this.handleTrackSubscribed(t)),this.room.on(h.TQ.DataReceived,(t,e)=>this.handleDataReceived(t,e));let[s,i]=await Promise.all([(0,h.s1)(),this.room.connect(e.roomUrl,e.token)]);if(this.localAudioTrack=s,this.localAudioTrack.setAudioContext(this.audioContext),[n.DISCONNECTED,n.DISCONNECTING].includes(this.status)){await this.disconnect();return}this.audioContext.resume(),this.audioElement.play(),this.localAudioTrack.mediaStream&&(this.micSourceNode=this.audioContext.createMediaStreamSource(this.localAudioTrack.mediaStream));let a={name:"audio",simulcast:!1,source:h.fQ.Source.Microphone};this.room.localParticipant.publishTrack(this.localAudioTrack,a),this.setStatus(n.IDLE)}async handleSocketClose(t){await this.disconnect()}async disconnect(){this.setStatus(n.DISCONNECTING),this.localAudioTrack?.stop(),this.localAudioTrack=void 0,await this.room?.disconnect(),this.room=void 0,this.socket?.close(),this.socket=void 0,this.micSourceNode?.disconnect(),this.micSourceNode=void 0,this.agentSourceNode?.disconnect(),this.agentSourceNode=void 0,this.audioElement.pause(),this.audioElement.srcObject=null,this.setStatus(n.DISCONNECTED)}handleTrackSubscribed(t){t.attach(this.audioElement),t.mediaStream&&(this.agentSourceNode=this.audioContext.createMediaStreamSource(t.mediaStream)),this.delayedSpeakingState&&(this.delayedSpeakingState=!1,this.setStatus(n.SPEAKING))}setStatus(t){this._status!==t&&(this._status=t,this.dispatchEvent(new p))}handleDataReceived(t,e){let s=JSON.parse(this.textDecoder.decode(t));if(this.dispatchEvent(new E(s)),"state"===s.type){let t=s.state;t===n.SPEAKING&&void 0===this.agentSourceNode?this.delayedSpeakingState=!0:this.setStatus(t)}else if("transcript"===s.type){let t="voice"==s.medium?l.VOICE:l.TEXT,e="agent"==s.role?c.AGENT:c.USER,i=s.ordinal,a=s.final;s.text?this.addOrUpdateTranscript(i,t,e,a,s.text):s.delta&&this.addOrUpdateTranscript(i,t,e,a,void 0,s.delta)}else"client_tool_invocation"==s.type?this.invokeClientTool(s.toolName,s.invocationId,s.parameters):this.experimentalMessages&&this.dispatchEvent(new S(s))}addOrUpdateTranscript(t,e,s,i,a,r){for(;this._transcripts.length<t;)this._transcripts.push(null);if(this._transcripts.length==t)this._transcripts.push(new d(a||r||"",i,s,e));else{let o=this._transcripts[t]?.text||"";this._transcripts[t]=new d(a||o+(r||""),i,s,e)}this.dispatchEvent(new m)}invokeClientTool(t,e,s){let i=this.registeredTools.get(t);if(!i){this.sendData({type:"client_tool_result",invocationId:e,errorType:"undefined",errorMessage:`Client tool ${t} is not registered (TypeScript client)`});return}try{let t=i(s);t instanceof Promise?t.then(t=>this.handleClientToolResult(e,t)).catch(t=>this.handleClientToolFailure(e,t)):this.handleClientToolResult(e,t)}catch(t){this.handleClientToolFailure(e,t)}}handleClientToolResult(t,e){"string"==typeof e?this.sendData({type:"client_tool_result",invocationId:t,result:e}):"string"!=typeof e.result||"string"!=typeof e.responseType?this.sendData({type:"client_tool_result",invocationId:t,errorType:"implementation-error",errorMessage:'Client tool result must be a string or an object with string "result" and "responseType" properties.'}):this.sendData({type:"client_tool_result",invocationId:t,...e})}handleClientToolFailure(t,e){this.sendData({type:"client_tool_result",invocationId:t,errorType:"implementation-error",errorMessage:e instanceof Error?e.message:void 0})}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.