@d-id/client-sdk 1.0.18 → 1.0.19
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/README.md +2 -0
- package/dist/index.js +409 -221
- package/dist/index.umd.cjs +1 -1
- package/dist/src/index.d.ts +8 -0
- package/dist/{apps/sdk → src}/lib/api/agents.d.ts +1 -1
- package/dist/{apps/sdk → src}/lib/api/clipStream.d.ts +1 -1
- package/dist/{apps/sdk → src}/lib/api/getClient.d.ts +1 -1
- package/dist/{apps/sdk → src}/lib/api/knowledge.d.ts +1 -1
- package/dist/{apps/sdk → src}/lib/api/ratings.d.ts +2 -4
- package/dist/{apps/sdk → src}/lib/api/talkStream.d.ts +1 -1
- package/dist/{apps/sdk → src}/lib/auth/getAuthHeader.d.ts +1 -1
- package/dist/src/lib/connectToSocket.d.ts +9 -0
- package/dist/src/lib/createAgentManager.d.ts +15 -0
- package/dist/src/lib/createStreamingManager.d.ts +27 -0
- package/dist/src/lib/environment.d.ts +7 -0
- package/dist/src/lib/utils/webrtc.d.ts +2 -0
- package/dist/{common/types/src → src/types}/StreamScript.d.ts +1 -0
- package/dist/{common/types/src → src/types}/auth.d.ts +2 -0
- package/dist/src/types/entities/agents/agent.d.ts +28 -0
- package/dist/{common/types/src → src/types}/entities/agents/chat.d.ts +1 -0
- package/dist/src/types/entities/agents/manager.d.ts +112 -0
- package/dist/{common/types/src → src/types}/index.d.ts +1 -0
- package/dist/{common/types/src → src/types}/stream/api/clip.d.ts +1 -1
- package/dist/{common/types/src → src/types}/stream/api/talk.d.ts +1 -1
- package/dist/{common/types/src → src/types}/stream/stream.d.ts +13 -1
- package/package.json +8 -12
- package/dist/apps/sdk/lib/createAgentManager.d.ts +0 -9
- package/dist/apps/sdk/lib/createStreamingManager.d.ts +0 -8
- package/dist/apps/sdk/lib/index.d.ts +0 -6
- package/dist/common/types/src/entities/agents/agent.d.ts +0 -18
- package/dist/common/types/src/entities/agents/manager.d.ts +0 -21
- /package/dist/{common/types/src → src/types}/entities/agents/index.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/entities/agents/knowledge.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/entities/agents/llm.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/entities/agents/presenter.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/entities/index.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/entities/knowledge/document.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/entities/knowledge/index.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/entities/knowledge/knowledge.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/entities/knowledge/record.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/entities/knowledge/retrival.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/entities/video.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/stream/api/index.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/stream/index.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/stream/rtc.d.ts +0 -0
- /package/dist/{common/types/src → src/types}/tts.d.ts +0 -0
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(c=typeof globalThis<"u"?globalThis:c||self,h(c.index={}))})(this,function(c){"use strict";function h(i){return i.type==="bearer"?"Bearer "+i.token:i.type==="basic"?"Basic "+btoa(`${i.username}:${i.password}`):"Client-Key "+i.clientKey}function m(i,o="https://api.d-id.com"){const n=async(e,t)=>{const r=await fetch(o+(e!=null&&e.startsWith("/")?e:`/${e}`),{...t,headers:{...t==null?void 0:t.headers,Authorization:h(i),"Content-Type":"application/json"}});if(!r.ok){let a=await r.text().catch(()=>"Failed to fetch");throw new Error(a)}return r.json()};return{get(e,t){return n(e,{...t,method:"GET"})},post(e,t,r){return n(e,{...r,body:JSON.stringify(t),method:"POST"})},delete(e,t,r){return n(e,{...r,body:JSON.stringify(t),method:"DELETE"})},patch(e,t,r){return n(e,{...r,body:JSON.stringify(t),method:"PATCH"})}}}function T(i,o="https://api.d-id.com"){const n=m(i,`${o}/agents`);return{create(e,t){return n.post("/",e,t)},getAgents(e,t){return n.get(`/${e?`?tag=${e}`:""}`,t).then(r=>r??[])},getById(e,t){return n.get(`/${e}`,t)},delete(e,t){return n.delete(`/${e}`,void 0,t)},update(e,t,r){return n.patch(`/${e}`,t,r)},newChat(e,t){return n.post(`/${e}/chat`,void 0,t)},chat(e,t,r,a){return n.post(`/${e}/chat/${t}`,r,a)}}}function O(i,o="https://api.d-id.com"){const n=m(i,`${o}/knowledge`);return{createKnowledge(e,t){return n.post("/",e,t)},getKnowledgeBase(e){return n.get("/",e)},getKnowledge(e,t){return n.get(`/${e}`,t)},deleteKnowledge(e,t){return n.delete(`/${e}`,void 0,t)},createDocument(e,t,r){return n.post(`/${e}/documents`,t,r)},deleteDocument(e,t,r){return n.delete(`/${e}/documents/${t}`,void 0,r)},getDocuments(e,t){return n.get(`/${e}/documents`,t)},getDocument(e,t,r){return n.get(`/${e}/documents/${t}`,r)},getRecords(e,t,r){return n.get(`/${e}/documents/${t}/records`,r)},query(e,t,r){return n.post(`/${e}/query`,{query:t},r)}}}function P(i,o="https://api.d-id.com"){const n=m(i,`${o}/chats/ratings`);return{create(e,t){return n.post("/",e,t)},getByKnowledge(e,t){return n.get(`/${e}`,t).then(r=>r??[])},update(e,t,r){return n.patch(`/${e}`,t,r)},delete(e,t){return n.delete(`/${e}`,t)}}}var w=(i=>(i.Start="START",i.Stop="STOP",i))(w||{}),S=(i=>(i.ChatAnswer="chat/answer",i.ChatPartial="chat/partial",i.StreamDone="stream/done",i.StreamStarted="stream/started",i))(S||{}),f=(i=>(i.Clip="clip",i.Talk="talk",i))(f||{});function R(i){return i.presenter.type===f.Clip?{videoType:f.Clip,driver_id:i.presenter.driver_id,presenter_id:i.presenter.presenter_id}:{videoType:f.Talk,source_url:i.presenter.source_url}}async function j(i,{callbacks:o,...n}){const e=new AbortController,t=T(n.auth,n.baseURL),r=await t.getById(i),a=await t.newChat(i),{terminate:$,sessionId:y,streamId:_}=await K(R(r),{...n,callbacks:{onSrcObjectReady:o.onSrcObjectReady,onVideoStateChange:o==null?void 0:o.onVideoStateChange,onConnectionStateChange:o.onConnectionStateChange}});return{agent:r,terminate(){return e.abort(),$()},chatId:a.id,chat(u){return t.chat(i,a.id,{sessionId:y,streamId:_,messages:u},{signal:e.signal})}}}function q(i,o){const n=m(i,o);return{createStream(e){return n.post("/clips/streams",{driver_id:e.driver_id,presenter_id:e.presenter_id,compatibility_mode:e.compatibility_mode})},startConnection(e,t,r){return n.post(`/clips/streams/${e}/sdp`,{session_id:r,answer:t})},addIceCandidate(e,t,r){return n.post(`/clips/streams/${e}/ice`,{session_id:r,...t})},sendStreamRequest(e,t,r){return n.post(`/clips/streams/${e}`,{session_id:t,...r})},close(e,t){return n.delete(`/clips/streams/${e}`,{session_id:t})}}}function B(i,o){const n=m(i,o);return{createStream(e,t){return n.post("/talks/streams",{source_url:e.source_url,driver_url:e.driver_url,face:e.face,config:e.config},t)},startConnection(e,t,r,a){return n.post(`/talks/streams/${e}/sdp`,{session_id:r,answer:t},a)},addIceCandidate(e,t,r,a){return n.post(`/talks/streams/${e}/ice`,{session_id:r,...t},a)},sendStreamRequest(e,t,r,a){return n.post(`/talks/streams/${e}`,{session_id:t,...r},a)},close(e,t,r){return n.delete(`/talks/streams/${e}`,{session_id:t},r)}}}let I=!1;const g=(i,o)=>I&&console.log(i,o),L=(window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection).bind(window);async function K(i,{debug:o=!1,callbacks:n,auth:e,baseURL:t="https://api.d-id.com"}){I=o;const{startConnection:r,sendStreamRequest:a,close:$,createStream:y,addIceCandidate:_}=i.videoType===f.Clip?q(e,t):B(e,t),{id:u,offer:J,ice_servers:V,session_id:C}=await y(i),s=new L({iceServers:V}),D=s.createDataChannel("JanusDataChannel");if(!C)throw new Error("Could not create session_id");s.onicecandidate=d=>{g("peerConnection.onicecandidate",d),d.candidate&&d.candidate.sdpMid&&d.candidate.sdpMLineIndex!==null&&_(u,{candidate:d.candidate.candidate,sdpMid:d.candidate.sdpMid,sdpMLineIndex:d.candidate.sdpMLineIndex},C)},s.oniceconnectionstatechange=()=>{var d;g("peerConnection.oniceconnectionstatechange => "+s.iceConnectionState),(d=n.onConnectionStateChange)==null||d.call(n,s.iceConnectionState)},s.ontrack=d=>{var p;g("peerConnection.ontrack",d),(p=n.onSrcObjectReady)==null||p.call(n,d.streams[0])},D.onmessage=d=>{var p,A,v;if(D.readyState==="open"){const[l,E]=d.data.split(":");l===S.StreamDone?(p=n.onVideoStateChange)==null||p.call(n,w.Stop):l===S.StreamStarted?(A=n.onVideoStateChange)==null||A.call(n,w.Start):(v=n.onMessage)==null||v.call(n,l,decodeURIComponent(E))}},await s.setRemoteDescription(J),g("set remote description OK");const M=await s.createAnswer();return g("create answer OK"),await s.setLocalDescription(M),g("set local description OK"),await r(u,M,C),g("start connection OK"),{speak(d){return a(u,C,d)},async terminate(){var d,p;u&&(s&&(s.close(),s.oniceconnectionstatechange=null,s.onnegotiationneeded=null,s.onicecandidate=null,s.ontrack=null),await $(u,C).catch(A=>{}),(d=n.onConnectionStateChange)==null||d.call(n,"closed"),(p=n.onVideoStateChange)==null||p.call(n,w.Stop))},sessionId:C,streamId:u}}c.createAgentManager=j,c.createAgentsApi=T,c.createClient=m,c.createKnowledgeApi=O,c.createRatingssApi=P,c.createStreamingManager=K,c.getAgentStreamArgs=R,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(c=typeof globalThis<"u"?globalThis:c||self,h(c.index={}))})(this,function(c){"use strict";const h="https://api.d-id.com",O="wss://notifications.d-id.com";function E(e){if(e.type==="bearer")return`Bearer ${e.token}`;if(e.type==="basic")return`Basic ${btoa(`${e.username}:${e.password}`)}`;if(e.type==="key")return`Client-Key ${e.clientKey}`;throw new Error(`Unknown auth type: ${e}`)}function C(e,i=h){const a=async(t,n)=>{const r=await fetch(i+(t!=null&&t.startsWith("/")?t:`/${t}`),{...n,headers:{...n==null?void 0:n.headers,Authorization:E(e),"Content-Type":"application/json"}});if(!r.ok){let d=await r.text().catch(()=>"Failed to fetch");throw new Error(d)}return r.json()};return{get(t,n){return a(t,{...n,method:"GET"})},post(t,n,r){return a(t,{...r,body:JSON.stringify(n),method:"POST"})},delete(t,n,r){return a(t,{...r,body:JSON.stringify(n),method:"DELETE"})},patch(t,n,r){return a(t,{...r,body:JSON.stringify(n),method:"PATCH"})}}}function T(e,i=h){const a=C(e,`${i}/agents`);return{create(t,n){return a.post("/",t,n)},getAgents(t,n){return a.get(`/${t?`?tag=${t}`:""}`,n).then(r=>r??[])},getById(t,n){return a.get(`/${t}`,n)},delete(t,n){return a.delete(`/${t}`,void 0,n)},update(t,n,r){return a.patch(`/${t}`,n,r)},newChat(t,n){return a.post(`/${t}/chat`,void 0,n)},chat(t,n,r,d){return a.post(`/${t}/chat/${n}`,r,d)}}}function W(e,i=h){const a=C(e,`${i}/knowledge`);return{createKnowledge(t,n){return a.post("/",t,n)},getKnowledgeBase(t){return a.get("/",t)},getKnowledge(t,n){return a.get(`/${t}`,n)},deleteKnowledge(t,n){return a.delete(`/${t}`,void 0,n)},createDocument(t,n,r){return a.post(`/${t}/documents`,n,r)},deleteDocument(t,n,r){return a.delete(`/${t}/documents/${n}`,void 0,r)},getDocuments(t,n){return a.get(`/${t}/documents`,n)},getDocument(t,n,r){return a.get(`/${t}/documents/${n}`,r)},getRecords(t,n,r){return a.get(`/${t}/documents/${n}/records`,r)},query(t,n,r){return a.post(`/${t}/query`,{query:n},r)}}}function H(e,i=h){const a=C(e,`${i}/chats/ratings`);return{create(t,n){return a.post("/",t,n)},getByKnowledge(t,n){return a.get(`/${t}`,n).then(r=>r??[])},update(t,n,r){return a.patch(`/${t}`,n,r)},delete(t,n){return a.delete(`/${t}`,n)}}}const x=e=>new Promise(i=>setTimeout(i,e));function ee(e){return new Promise((i,a)=>{const{callbacks:t,host:n,auth:r}=e,{onMessage:d=null,onOpen:l=null,onClose:p=null,onError:g=null}=t||{},u=new WebSocket(`${n}?authorization=${E(r)}`);u.onmessage=d,u.onclose=p,u.onerror=s=>{console.log(s),g==null||g(s),a(s)},u.onopen=s=>{l==null||l(s),i(u)}})}async function te(e){const{retries:i=1}=e;let a=null;for(let t=0;(a==null?void 0:a.readyState)!==WebSocket.OPEN;t++)try{a=await ee(e)}catch(n){if(t===i)throw n;await x(t*500)}return a}async function q(e,i,a=O){const t=i?[i]:[],n=await te({auth:e,host:a,callbacks:{onMessage:r=>{const d=JSON.parse(r.data);t.forEach(l=>l(d.event,d))}}});return{socket:n,terminate:()=>n.close(),subscribeToEvents:r=>t.push(r)}}var N=(e=>(e.Amazon="amazon",e.Microsoft="microsoft",e.Afflorithmics="afflorithmics",e.Elevenlabs="elevenlabs",e))(N||{}),U=(e=>(e.Public="public",e.Premium="premium",e.Private="private",e))(U||{}),M=(e=>(e.Start="START",e.Stop="STOP",e))(M||{}),k=(e=>(e.ChatAnswer="chat/answer",e.ChatPartial="chat/partial",e.StreamDone="stream/done",e.StreamStarted="stream/started",e))(k||{}),z=(e=>(e.Unrated="Unrated",e.Positive="Positive",e.Negative="Negative",e))(z||{}),I=(e=>(e.Embed="embed",e.Query="query",e.Partial="partial",e.Answer="answer",e.Complete="done",e))(I||{}),B=(e=>(e.KnowledgeProcessing="knowledge/processing",e.KnowledgeIndexing="knowledge/indexing",e.KnowledgeFailed="knowledge/error",e.KnowledgeDone="knowledge/done",e))(B||{}),J=(e=>(e.Knowledge="knowledge",e.Document="document",e.Record="record",e))(J||{}),D=(e=>(e.Pdf="pdf",e.Text="text",e.Html="html",e.Word="word",e.Json="json",e.Markdown="markdown",e.Csv="csv",e.Excel="excel",e.Powerpoint="powerpoint",e.Archive="archive",e.Image="image",e.Audio="audio",e.Video="video",e))(D||{}),$=(e=>(e.Clip="clip",e.Talk="talk",e))($||{});function F(e){return e.presenter.type===$.Clip?{videoType:$.Clip,driver_id:e.presenter.driver_id,presenter_id:e.presenter.presenter_id}:{videoType:$.Talk,source_url:e.presenter.source_url}}function V(e,i,a,t){return new Promise(async(n,r)=>{const d=await Q(F(e),{...i,callbacks:{...i.callbacks,onConnectionStateChange:async l=>{var p,g;l==="connected"?(t||(t=await a.newChat(e.id)),n({chat:t,streamingManager:d})):l==="failed"&&r(new Error("Cannot create connection")),(g=(p=i.callbacks).onConnectionStateChange)==null||g.call(p,l)},onMessage:(l,p)=>{var g,u;l===k.ChatPartial&&((u=(g=i.callbacks).onChatEvents)==null||u.call(g,I.Partial,{content:p,event:I.Partial}))}}})})}async function ne(e,i){const a=i.baseURL||h,t=new AbortController,n=T(i.auth,a),r=H(i.auth,a),d=W(i.auth,a),l=await n.getById(e),p=await q(i.auth,i.callbacks.onChatEvents);let{chat:g,streamingManager:u}=await V(l,i,n);return{agent:l,async reconnectToChat(){const{streamingManager:s}=await V(l,i,n,g);u=s},terminate(){return t.abort(),p.terminate(),u.terminate()},chatId:g.id,chat(s){return n.chat(e,g.id,{sessionId:u.sessionId,streamId:u.streamId,messages:s},{signal:t.signal})},rate(s,f){return f?r.update(f,s):r.create(s)},deleteRate(s){return r.delete(s)},speak(s){let f;return s.type==="text"?f={script:{type:"text",provider:s.provider,input:s.input,ssml:s.ssml||!1}}:s.type==="audio"&&(f={script:{type:"audio",audio_url:s.audio_url}}),u.speak(f)},getStarterMessages(){var s,f;return(s=l.knowledge)!=null&&s.id?d.getKnowledge((f=l.knowledge)==null?void 0:f.id).then(R=>(R==null?void 0:R.starter_message)||[]):Promise.resolve([])}}}function ae(e,i){const a=C(e,i);return{createStream(t){return a.post("/clips/streams",{driver_id:t.driver_id,presenter_id:t.presenter_id,compatibility_mode:t.compatibility_mode})},startConnection(t,n,r){return a.post(`/clips/streams/${t}/sdp`,{session_id:r,answer:n})},addIceCandidate(t,n,r){return a.post(`/clips/streams/${t}/ice`,{session_id:r,...n})},sendStreamRequest(t,n,r){return a.post(`/clips/streams/${t}`,{session_id:n,...r})},close(t,n){return a.delete(`/clips/streams/${t}`,{session_id:n})}}}function re(e,i){const a=C(e,i);return{createStream(t,n){return a.post("/talks/streams",{source_url:t.source_url,driver_url:t.driver_url,face:t.face,config:t.config},n)},startConnection(t,n,r,d){return a.post(`/talks/streams/${t}/sdp`,{session_id:r,answer:n},d)},addIceCandidate(t,n,r,d){return a.post(`/talks/streams/${t}/ice`,{session_id:r,...n},d)},sendStreamRequest(t,n,r,d){return a.post(`/talks/streams/${t}`,{session_id:n,...r},d)},close(t,n,r){return a.delete(`/talks/streams/${t}`,{session_id:n},r)}}}function ie(e,i){return e.map((a,t)=>t===0?i?{index:t,timestamp:a.timestamp,bytesReceived:a.bytesReceived-i.bytesReceived,packetsReceived:a.packetsReceived-i.packetsReceived,packetsLost:a.packetsLost-i.packetsLost,jitter:a.jitter,frameWidth:a.frameWidth,frameHeight:a.frameHeight,frameRate:a.frameRate}:{index:t,timestamp:a.timestamp,bytesReceived:a.bytesReceived,packetsReceived:a.packetsReceived,packetsLost:a.packetsLost,jitter:a.jitter,frameWidth:a.frameWidth,frameHeight:a.frameHeight,frameRate:a.frameRate}:{index:t,timestamp:a.timestamp,bytesReceived:a.bytesReceived-e[t-1].bytesReceived,packetsReceived:a.packetsReceived-e[t-1].packetsReceived,packetsLost:a.packetsLost-e[t-1].packetsLost,jitter:a.jitter,frameWidth:a.frameWidth,frameHeight:a.frameHeight,frameRate:a.frameRate})}let G=!1;const v=(e,i)=>G&&console.log(e,i),se=(window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection).bind(window);async function Q(e,{debug:i=!1,callbacks:a,auth:t,baseURL:n=h}){G=i;const r={...a},{startConnection:d,sendStreamRequest:l,close:p,createStream:g,addIceCandidate:u}=e.videoType===$.Clip?ae(t,n):re(t,n),{id:s,offer:f,ice_servers:R,session_id:S}=await g(e),m=new se({iceServers:R}),X=m.createDataChannel("JanusDataChannel"),y=[];let A=0,Y;if(!S)throw new Error("Could not create session_id");m.onicecandidate=o=>{v("peerConnection.onicecandidate",o),o.candidate&&o.candidate.sdpMid&&o.candidate.sdpMLineIndex!==null&&u(s,{candidate:o.candidate.candidate,sdpMid:o.candidate.sdpMid,sdpMLineIndex:o.candidate.sdpMLineIndex},S)},m.oniceconnectionstatechange=()=>{var o;v("peerConnection.oniceconnectionstatechange => "+m.iceConnectionState),(o=r.onConnectionStateChange)==null||o.call(r,m.iceConnectionState)},m.ontrack=o=>{var w;v("peerConnection.ontrack",o),(w=r.onSrcObjectReady)==null||w.call(r,o.streams[0])},X.onmessage=o=>{var w,P,j;if(X.readyState==="open"){const[b,oe]=o.data.split(":");if(b===k.StreamStarted)A=y.length,Y=setInterval(()=>{m.getStats().then(L=>{L.forEach(_=>{_.type==="inbound-rtp"&&_.kind==="video"&&y.push(_)})})},1e3),(w=r.onVideoStateChange)==null||w.call(r,M.Start);else if(b===k.StreamDone){clearInterval(Y);const K=y.slice(A);if(K){const L=A===0?void 0:y[A-1],_=ie(K,L);A=y.length,(P=r.onVideoStateChange)==null||P.call(r,M.Stop,_.sort((ce,de)=>de.packetsLost-ce.packetsLost).slice(0,5))}}else(j=r.onMessage)==null||j.call(r,b,decodeURIComponent(oe))}},await m.setRemoteDescription(f),v("set remote description OK");const Z=await m.createAnswer();return v("create answer OK"),await m.setLocalDescription(Z),v("set local description OK"),await d(s,Z,S),v("start connection OK"),{speak(o){return l(s,S,o)},async terminate(){var o,w;s&&(m&&(m.close(),m.oniceconnectionstatechange=null,m.onnegotiationneeded=null,m.onicecandidate=null,m.ontrack=null),await p(s,S).catch(P=>{}),(o=r.onConnectionStateChange)==null||o.call(r,"closed"),(w=r.onVideoStateChange)==null||w.call(r,M.Stop))},sessionId:S,streamId:s,onCallback(o,w){r[o]=w}}}c.ChatProgress=I,c.DocumentType=D,c.KnowledgeType=J,c.Providers=N,c.RateState=z,c.SocketManager=q,c.StreamEvents=k,c.Subject=B,c.VoiceAccess=U,c.createAgentManager=ne,c.createAgentsApi=T,c.createClient=C,c.createKnowledgeApi=W,c.createRatingsApi=H,c.createStreamingManager=Q,c.getAgentStreamArgs=F,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './lib/api/agents';
|
|
2
|
+
export * from './lib/api/getClient';
|
|
3
|
+
export * from './lib/api/knowledge';
|
|
4
|
+
export * from './lib/api/ratings';
|
|
5
|
+
export * from './lib/connectToSocket';
|
|
6
|
+
export * from './lib/createAgentManager';
|
|
7
|
+
export * from './lib/createStreamingManager';
|
|
8
|
+
export * from './types/index';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent, AgentPayload, Auth, Chat, ChatPayload, ChatResponse } from '
|
|
1
|
+
import { Agent, AgentPayload, Auth, Chat, ChatPayload, ChatResponse } from '../../types/index';
|
|
2
2
|
export declare function createAgentsApi(auth: Auth, host?: string): {
|
|
3
3
|
create(payload: AgentPayload, options?: RequestInit): Promise<Agent>;
|
|
4
4
|
getAgents(tag?: string, options?: RequestInit): Promise<Agent[]>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Auth, RtcApi } from '
|
|
1
|
+
import { Auth, RtcApi } from '../../types/index';
|
|
2
2
|
export declare function createApi(auth: Auth, host: string): RtcApi;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Auth } from '
|
|
1
|
+
import { Auth } from '../../types/auth';
|
|
2
2
|
export declare function createClient(auth: Auth, host?: string): {
|
|
3
3
|
get<T = any>(url: string, options?: RequestInit): Promise<T>;
|
|
4
4
|
post<T_1 = any>(url: string, body?: any, options?: RequestInit): Promise<T_1>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Auth, CreateDocumentPayload, DocumentData, KnowledgeData, KnowledgePayload, QueryResult, RecordData } from '
|
|
1
|
+
import { Auth, CreateDocumentPayload, DocumentData, KnowledgeData, KnowledgePayload, QueryResult, RecordData } from '../../types/index';
|
|
2
2
|
export declare function createKnowledgeApi(auth: Auth, host?: string): {
|
|
3
3
|
createKnowledge(payload: KnowledgePayload, options?: RequestInit): Promise<KnowledgeData>;
|
|
4
4
|
getKnowledgeBase(options?: RequestInit): Promise<KnowledgeData[]>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Auth, RatingEntity } from '
|
|
2
|
-
|
|
3
|
-
export declare function createRatingssApi(auth: Auth, host?: string): {
|
|
1
|
+
import { Auth, RatingEntity, RatingPayload } from '../../index';
|
|
2
|
+
export declare function createRatingsApi(auth: Auth, host?: string): {
|
|
4
3
|
create(payload: RatingPayload, options?: RequestInit): Promise<RatingEntity>;
|
|
5
4
|
getByKnowledge(knowledgeId?: string, options?: RequestInit): Promise<RatingEntity[]>;
|
|
6
5
|
update(id: string, payload: Partial<RatingPayload>, options?: RequestInit): Promise<RatingEntity>;
|
|
7
6
|
delete(id: string, options?: RequestInit): Promise<RatingEntity>;
|
|
8
7
|
};
|
|
9
|
-
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Auth, RtcApi } from '
|
|
1
|
+
import { Auth, RtcApi } from '../../types/index';
|
|
2
2
|
export declare function createApi(auth: Auth, host: string): RtcApi;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Auth } from '
|
|
1
|
+
import { Auth } from '../../types/auth';
|
|
2
2
|
export declare function getAuthHeader(auth: Auth): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Auth } from '../types/auth';
|
|
2
|
+
import { ChatProgressCallback } from '..';
|
|
3
|
+
interface SocketManager {
|
|
4
|
+
socket?: WebSocket;
|
|
5
|
+
terminate: () => void;
|
|
6
|
+
subscribeToEvents: (data: any) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function SocketManager(auth: Auth, onMessage?: ChatProgressCallback, host?: string): Promise<SocketManager>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Agent, AgentManager, AgentManagerOptions, CreateStreamOptions } from '../types/index';
|
|
2
|
+
export declare function getAgentStreamArgs(agent: Agent): CreateStreamOptions;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new Agent Manager instance for interacting with an agent, chat, and related connections.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} agentId - The ID of the agent to chat with.
|
|
7
|
+
* @param {AgentManagerOptions} options - Configurations for the Agent Manager API.
|
|
8
|
+
* * @returns {Promise<AgentManager>} - A promise that resolves to an instance of the AgentsAPI interface.
|
|
9
|
+
*
|
|
10
|
+
* @throws {Error} Throws an error if the agent is not initialized.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const agentManager = await createAgentManager('id-agent123', { auth: { type: 'key', clientKey: '123', externalId: '123' } });
|
|
14
|
+
*/
|
|
15
|
+
export declare function createAgentManager(agentId: string, options: AgentManagerOptions): Promise<AgentManager>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CreateStreamOptions, ManagerCallbacks, PayloadType, StreamingManagerOptions } from '../types/index';
|
|
2
|
+
export declare function createStreamingManager<T extends CreateStreamOptions>(agent: T, { debug, callbacks, auth, baseURL }: StreamingManagerOptions): Promise<{
|
|
3
|
+
/**
|
|
4
|
+
* Method to send request to server to get clip or talk depend on you payload
|
|
5
|
+
* @param payload
|
|
6
|
+
*/
|
|
7
|
+
speak(payload: PayloadType<T>): Promise<import('../types/index').SendStreamPayloadResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Method to close RTC connection
|
|
10
|
+
*/
|
|
11
|
+
terminate(): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Session identifier information, should be returned in the body of all streaming requests
|
|
14
|
+
*/
|
|
15
|
+
sessionId: string;
|
|
16
|
+
/**
|
|
17
|
+
* Id of current RTC stream
|
|
18
|
+
*/
|
|
19
|
+
streamId: string;
|
|
20
|
+
/**
|
|
21
|
+
* Method to add callback that will be trigered on supported events
|
|
22
|
+
* @param eventName
|
|
23
|
+
* @param callback
|
|
24
|
+
*/
|
|
25
|
+
onCallback<T_1 extends keyof ManagerCallbacks>(eventName: T_1, callback: ManagerCallbacks[T_1]): void;
|
|
26
|
+
}>;
|
|
27
|
+
export type StreamingManager<T extends CreateStreamOptions> = Awaited<ReturnType<typeof createStreamingManager<T>>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const nodeEnv: string;
|
|
2
|
+
export declare const didApiUrl: string;
|
|
3
|
+
export declare const didSocketApiUrl: string;
|
|
4
|
+
export declare const mixpanelKey: string;
|
|
5
|
+
export declare const clientKey: string;
|
|
6
|
+
export declare const agentId: string;
|
|
7
|
+
export declare const externalId = "temp";
|
|
@@ -10,6 +10,7 @@ export interface BasicAuth {
|
|
|
10
10
|
export interface ApiKeyAuth {
|
|
11
11
|
type: 'key';
|
|
12
12
|
clientKey: string;
|
|
13
|
+
externalId: string;
|
|
13
14
|
}
|
|
14
15
|
export type Auth = BearerToken | BasicAuth | ApiKeyAuth;
|
|
15
16
|
export interface GetAuthParams {
|
|
@@ -17,4 +18,5 @@ export interface GetAuthParams {
|
|
|
17
18
|
username?: string | null;
|
|
18
19
|
password?: string | null;
|
|
19
20
|
clientKey?: string | null;
|
|
21
|
+
externalId?: string | null;
|
|
20
22
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Chat, ChatPayload, ChatResponse } from './chat';
|
|
2
|
+
import { Knowledge } from './knowledge';
|
|
3
|
+
import { LLM } from './llm';
|
|
4
|
+
import { Presenter } from './presenter';
|
|
5
|
+
export interface Agent {
|
|
6
|
+
id: string;
|
|
7
|
+
username?: string;
|
|
8
|
+
presenter: Presenter;
|
|
9
|
+
llm?: LLM;
|
|
10
|
+
knowledge?: Knowledge;
|
|
11
|
+
use_case?: string;
|
|
12
|
+
tags?: string[];
|
|
13
|
+
chats?: number;
|
|
14
|
+
access?: 'private' | 'pending-public' | 'unlisted' | 'rejected' | 'public';
|
|
15
|
+
preview_name?: string;
|
|
16
|
+
preview_description?: string;
|
|
17
|
+
preview_thumbnail?: string;
|
|
18
|
+
}
|
|
19
|
+
export type AgentPayload = Omit<Agent, 'type' | 'created_at' | 'modified_at' | 'id' | 'owner_id' | 'idle_video_url'>;
|
|
20
|
+
export interface AgentsAPI {
|
|
21
|
+
create(payload: AgentPayload, options?: RequestInit): Promise<Agent>;
|
|
22
|
+
getAgents(tag?: string, options?: RequestInit): Promise<Agent[]>;
|
|
23
|
+
getById(id: string, options?: RequestInit): Promise<Agent>;
|
|
24
|
+
delete(id: string, options?: RequestInit): Promise<void>;
|
|
25
|
+
update(id: string, payload: AgentPayload, options?: RequestInit): Promise<Agent>;
|
|
26
|
+
newChat(agentId: string, options?: RequestInit): Promise<Chat>;
|
|
27
|
+
chat(agentId: string, chatId: string, payload: ChatPayload, options?: RequestInit): Promise<ChatResponse>;
|
|
28
|
+
}
|
|
@@ -16,6 +16,7 @@ export interface RatingEntity {
|
|
|
16
16
|
created_at: string;
|
|
17
17
|
modified_at: string;
|
|
18
18
|
}
|
|
19
|
+
export type RatingPayload = Omit<RatingEntity, 'owner_id' | 'id' | 'created_at' | 'modified_at' | 'created_by' | 'external_id'>;
|
|
19
20
|
export interface Message {
|
|
20
21
|
role: 'system' | 'assistant' | 'user' | 'function' | 'tool';
|
|
21
22
|
content: string;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { SupportedStreamScipt } from '../../../types/StreamScript';
|
|
2
|
+
import { Auth } from '../../auth';
|
|
3
|
+
import { SendStreamPayloadResponse, SlimRTCStatsReport, StreamingState } from '../../stream';
|
|
4
|
+
import { Agent } from './agent';
|
|
5
|
+
import { ChatResponse, Message, RatingEntity, RatingPayload } from './chat';
|
|
6
|
+
/**
|
|
7
|
+
* Types of events provided in Chat Progress Callback
|
|
8
|
+
*/
|
|
9
|
+
export declare enum ChatProgress {
|
|
10
|
+
/**
|
|
11
|
+
* Chat was successfully embedded
|
|
12
|
+
*/
|
|
13
|
+
Embed = "embed",
|
|
14
|
+
/**
|
|
15
|
+
* Server processing chat message
|
|
16
|
+
*/
|
|
17
|
+
Query = "query",
|
|
18
|
+
/**
|
|
19
|
+
* Server returns a part of the message
|
|
20
|
+
*/
|
|
21
|
+
Partial = "partial",
|
|
22
|
+
/**
|
|
23
|
+
* Server processed message and returned response
|
|
24
|
+
*/
|
|
25
|
+
Answer = "answer",
|
|
26
|
+
/**
|
|
27
|
+
* Chat was closed
|
|
28
|
+
*/
|
|
29
|
+
Complete = "done"
|
|
30
|
+
}
|
|
31
|
+
export type ChatProgressCallback = (progress: ChatProgress, data: string) => void;
|
|
32
|
+
export type ConnectionStateChangeCallback = (state: RTCIceConnectionState) => void;
|
|
33
|
+
export type VideoStateChangeCallback = (state: StreamingState, stats?: SlimRTCStatsReport[]) => void;
|
|
34
|
+
interface ManagerCallbacks {
|
|
35
|
+
/**
|
|
36
|
+
* Optional callback will be triggered each time the RTC connection changes state
|
|
37
|
+
* @param state
|
|
38
|
+
*/
|
|
39
|
+
onConnectionStateChange?(state: RTCIceConnectionState): void;
|
|
40
|
+
/**
|
|
41
|
+
* Optional callback function that will be triggered each time video events happen
|
|
42
|
+
* @param state
|
|
43
|
+
*/
|
|
44
|
+
onVideoStateChange?(state: StreamingState): void;
|
|
45
|
+
/**
|
|
46
|
+
* Callback function that will be triggered each time the video stream starts or stops to update html element on webpage
|
|
47
|
+
* Required callback for SDK
|
|
48
|
+
* @param srcObject
|
|
49
|
+
* @example
|
|
50
|
+
* const videoRef = useRef<HTMLVideoElement>(null);
|
|
51
|
+
* onSrcObjectReady(value) { videoRef.current.srcObject = value }
|
|
52
|
+
*/
|
|
53
|
+
onSrcObjectReady(srcObject: MediaStream): void;
|
|
54
|
+
/**
|
|
55
|
+
* Optional callback function that will be triggered each time any changes happen in the chat
|
|
56
|
+
* @param progress
|
|
57
|
+
*/
|
|
58
|
+
onChatEvents?(progress: ChatProgress, data: any): void;
|
|
59
|
+
}
|
|
60
|
+
export interface AgentManagerOptions {
|
|
61
|
+
callbacks: ManagerCallbacks;
|
|
62
|
+
baseURL?: string;
|
|
63
|
+
debug?: boolean;
|
|
64
|
+
auth: Auth;
|
|
65
|
+
}
|
|
66
|
+
export interface AgentManager {
|
|
67
|
+
/**
|
|
68
|
+
* Agent instance you are working with.
|
|
69
|
+
* To know more about agents go to https://docs.d-id.com/reference/agents
|
|
70
|
+
*/
|
|
71
|
+
agent: Agent;
|
|
72
|
+
/**
|
|
73
|
+
* Method to be reconnected to chat
|
|
74
|
+
* Since chat uses an RTC connection to communicate with the agent, it could be dropped and to continue to chat you need to reconnect
|
|
75
|
+
*/
|
|
76
|
+
reconnectToChat: () => Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Method to close all connections with agent, stream and web socket
|
|
79
|
+
*/
|
|
80
|
+
terminate: () => Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* ID of chat you are working on now
|
|
83
|
+
*/
|
|
84
|
+
chatId: string;
|
|
85
|
+
/**
|
|
86
|
+
* Method to send a chat message to existing chat with the agent
|
|
87
|
+
* @param messages
|
|
88
|
+
*/
|
|
89
|
+
chat: (messages: Message[]) => Promise<ChatResponse>;
|
|
90
|
+
/**
|
|
91
|
+
* Method to rate the answer in chat
|
|
92
|
+
* @param payload
|
|
93
|
+
* @param id - id of Rating entity. Leave it empty to create a new, one or pass it to work with the existing one
|
|
94
|
+
*/
|
|
95
|
+
rate: (payload: RatingPayload, id?: string) => Promise<RatingEntity>;
|
|
96
|
+
/**
|
|
97
|
+
* Method to delete rating from answer in chat
|
|
98
|
+
* @param id - id of Rating entity.
|
|
99
|
+
*/
|
|
100
|
+
deleteRate: (id: string) => Promise<RatingEntity>;
|
|
101
|
+
/**
|
|
102
|
+
* Method to make your agent read the text you provide or reproduce sound
|
|
103
|
+
* @param payload
|
|
104
|
+
*/
|
|
105
|
+
speak: (payload: SupportedStreamScipt) => Promise<SendStreamPayloadResponse>;
|
|
106
|
+
/**
|
|
107
|
+
* Optional callback function that will be triggered each time any changes happen in the chat
|
|
108
|
+
* @param callback
|
|
109
|
+
*/
|
|
110
|
+
getStarterMessages: () => Promise<string[]>;
|
|
111
|
+
}
|
|
112
|
+
export {};
|
|
@@ -16,9 +16,10 @@ export declare enum StreamEvents {
|
|
|
16
16
|
export interface ManagerCallbacks {
|
|
17
17
|
onMessage?: (event: string, data: string) => void;
|
|
18
18
|
onConnectionStateChange?: (state: RTCIceConnectionState) => void;
|
|
19
|
-
onVideoStateChange?: (state: StreamingState) => void;
|
|
19
|
+
onVideoStateChange?: (state: StreamingState, stats?: SlimRTCStatsReport[]) => void;
|
|
20
20
|
onSrcObjectReady?: (value: MediaStream) => void;
|
|
21
21
|
}
|
|
22
|
+
export type ManagerCallbackKeys = keyof ManagerCallbacks;
|
|
22
23
|
export interface TalkStreamOptions extends CreateTalkStreamRequest {
|
|
23
24
|
videoType: VideoType.Talk;
|
|
24
25
|
}
|
|
@@ -40,3 +41,14 @@ export interface StreamingManagerOptions {
|
|
|
40
41
|
debug?: boolean;
|
|
41
42
|
auth: Auth;
|
|
42
43
|
}
|
|
44
|
+
export interface SlimRTCStatsReport {
|
|
45
|
+
index: number;
|
|
46
|
+
timestamp: any;
|
|
47
|
+
bytesReceived: any;
|
|
48
|
+
packetsReceived: any;
|
|
49
|
+
packetsLost: any;
|
|
50
|
+
jitter: any;
|
|
51
|
+
frameWidth: any;
|
|
52
|
+
frameHeight: any;
|
|
53
|
+
frameRate: any;
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-id/client-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.19",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "d-id client sdk",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/de-id/
|
|
9
|
+
"url": "https://github.com/de-id/agents-sdk"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
12
12
|
"d-id",
|
|
@@ -20,20 +20,15 @@
|
|
|
20
20
|
],
|
|
21
21
|
"main": "./dist/index.umd.cjs",
|
|
22
22
|
"module": "./dist/index.js",
|
|
23
|
-
"types": "./dist/
|
|
24
|
-
"exports": {
|
|
25
|
-
".": {
|
|
26
|
-
"types": "./dist/apps/sdk/lib/index.d.ts",
|
|
27
|
-
"import": "./dist/index.js",
|
|
28
|
-
"require": "./dist/index.umd.cjs"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
23
|
+
"types": "./dist/src/types/index.d.ts",
|
|
31
24
|
"scripts": {
|
|
32
25
|
"dev": "vite",
|
|
33
26
|
"build": "node ./infra/build.js -m production",
|
|
34
27
|
"build:dev": "node ./infra/build.js -m development",
|
|
35
28
|
"deploy:prod": "node ./infra/deploy.js --version patch",
|
|
36
|
-
"preview": "vite preview"
|
|
29
|
+
"preview": "vite preview",
|
|
30
|
+
"test-build": "node .infra/build.js -m development",
|
|
31
|
+
"build:docs": "typedoc"
|
|
37
32
|
},
|
|
38
33
|
"devDependencies": {
|
|
39
34
|
"@preact/preset-vite": "^2.5.0",
|
|
@@ -44,9 +39,10 @@
|
|
|
44
39
|
"prettier": "^3.1.0",
|
|
45
40
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
46
41
|
"serverless": "3.32.2",
|
|
42
|
+
"typedoc": "^0.25.7",
|
|
47
43
|
"typescript": "^5.3.2",
|
|
48
44
|
"vite": "^4.4.5",
|
|
49
45
|
"vite-plugin-dts": "^3.6.0",
|
|
50
46
|
"vite-plugin-html-env": "^1.2.8"
|
|
51
47
|
}
|
|
52
|
-
}
|
|
48
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Agent, AgentManagerOptions, CreateStreamOptions, Message } from '../../../common/types/src/index';
|
|
2
|
-
export declare function getAgentStreamArgs(agent: Agent): CreateStreamOptions;
|
|
3
|
-
export declare function createAgentManager(agentId: string, { callbacks, ...options }: AgentManagerOptions): Promise<{
|
|
4
|
-
agent: Agent;
|
|
5
|
-
terminate(): Promise<void>;
|
|
6
|
-
chatId: string;
|
|
7
|
-
chat(messages: Message[]): Promise<import('../../../common/types/src/index').ChatResponse>;
|
|
8
|
-
}>;
|
|
9
|
-
export type AgentManager = Awaited<ReturnType<typeof createAgentManager>>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CreateStreamOptions, PayloadType, StreamingManagerOptions } from '../../../common/types/src/index';
|
|
2
|
-
export declare function createStreamingManager<T extends CreateStreamOptions>(agent: T, { debug, callbacks, auth, baseURL }: StreamingManagerOptions): Promise<{
|
|
3
|
-
speak(payload: PayloadType<T>): Promise<import('../../../common/types/src/index').SendStreamPayloadResponse>;
|
|
4
|
-
terminate(): Promise<void>;
|
|
5
|
-
sessionId: string;
|
|
6
|
-
streamId: string;
|
|
7
|
-
}>;
|
|
8
|
-
export type StreamingManager<T extends CreateStreamOptions> = Awaited<ReturnType<typeof createStreamingManager<T>>>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Knowledge } from './knowledge';
|
|
2
|
-
import { LLM } from './llm';
|
|
3
|
-
import { Presenter } from './presenter';
|
|
4
|
-
export interface Agent {
|
|
5
|
-
id: string;
|
|
6
|
-
username?: string;
|
|
7
|
-
presenter: Presenter;
|
|
8
|
-
llm?: LLM;
|
|
9
|
-
knowledge?: Knowledge;
|
|
10
|
-
use_case?: string;
|
|
11
|
-
tags?: string[];
|
|
12
|
-
chats?: number;
|
|
13
|
-
access?: 'private' | 'pending-public' | 'unlisted' | 'rejected' | 'public';
|
|
14
|
-
preview_name?: string;
|
|
15
|
-
preview_description?: string;
|
|
16
|
-
preview_thumbnail?: string;
|
|
17
|
-
}
|
|
18
|
-
export type AgentPayload = Omit<Agent, 'type' | 'created_at' | 'modified_at' | 'id' | 'owner_id' | 'idle_video_url'>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Auth } from '../../auth';
|
|
2
|
-
import { StreamingState } from '../../stream';
|
|
3
|
-
declare enum ChatProgress {
|
|
4
|
-
Embed = 0,
|
|
5
|
-
Query = 1,
|
|
6
|
-
Answer = 2,
|
|
7
|
-
Complete = 3
|
|
8
|
-
}
|
|
9
|
-
interface ManagerCallbacks {
|
|
10
|
-
onConnectionStateChange?(state: RTCIceConnectionState): void;
|
|
11
|
-
onVideoStateChange?(state: StreamingState): void;
|
|
12
|
-
onSrcObjectReady?(srcObject: MediaStream): void;
|
|
13
|
-
onChatEvents?(progress: ChatProgress): void;
|
|
14
|
-
}
|
|
15
|
-
export interface AgentManagerOptions {
|
|
16
|
-
callbacks: ManagerCallbacks;
|
|
17
|
-
baseURL?: string;
|
|
18
|
-
debug?: boolean;
|
|
19
|
-
auth: Auth;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|