@microsoft/agents-copilotstudio-client 1.1.0-alpha.2 → 1.1.0-alpha.5
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/package.json +2 -2
- package/dist/src/browser.mjs +1 -1
- package/dist/src/browser.mjs.map +1 -1
- package/package.json +2 -2
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/agents-copilotstudio-client",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.5",
|
|
4
4
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"build:browser": "esbuild --platform=browser --target=es2019 --format=esm --bundle --sourcemap --minify --outfile=dist/src/browser.mjs src/index.ts"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@microsoft/agents-activity": "1.1.0-alpha.
|
|
30
|
+
"@microsoft/agents-activity": "1.1.0-alpha.5",
|
|
31
31
|
"axios": "^1.9.0",
|
|
32
32
|
"rxjs": "7.8.2",
|
|
33
33
|
"uuid": "^11.1.0"
|
package/dist/src/browser.mjs
CHANGED
|
@@ -3,7 +3,7 @@ var Ya=Object.create;var An=Object.defineProperty;var Xa=Object.getOwnPropertyDe
|
|
|
3
3
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){let n=new this(e);return r.forEach(o=>n.set(o)),n}static accessor(e){let n=(this[Pi]=this[Pi]={accessors:{}}).accessors,o=this.prototype;function i(s){let a=Kt(s);n[a]||(ou(o,s),n[a]=!0)}return p.isArray(e)?e.forEach(i):i(e),this}};at.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);p.reduceDescriptors(at.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}});p.freezeMethods(at);var F=at;function Gt(t,e){let r=this||st,n=e||r,o=F.from(n.headers),i=n.data;return p.forEach(t,function(a){i=a.call(r,i,o.normalize(),e?e.status:void 0)}),o.normalize(),i}function Yt(t){return!!(t&&t.__CANCEL__)}function Ri(t,e,r){A.call(this,t==null?"canceled":t,A.ERR_CANCELED,e,r),this.name="CanceledError"}p.inherits(Ri,A,{__CANCEL__:!0});var de=Ri;function Xt(t,e,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new A("Request failed with status code "+r.status,[A.ERR_BAD_REQUEST,A.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function zn(t){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function iu(t,e){t=t||10;let r=new Array(t),n=new Array(t),o=0,i=0,s;return e=e!==void 0?e:1e3,function(c){let u=Date.now(),d=n[i];s||(s=u),r[o]=c,n[o]=u;let m=i,b=0;for(;m!==o;)b+=r[m++],m=m%t;if(o=(o+1)%t,o===i&&(i=(i+1)%t),u-s<e)return;let C=d&&u-d;return C?Math.round(b*1e3/C):void 0}}var ji=iu;function su(t,e){let r=0,n=1e3/e,o,i,s=(u,d=Date.now())=>{r=d,o=null,i&&(clearTimeout(i),i=null),t(...u)};return[(...u)=>{let d=Date.now(),m=d-r;m>=n?s(u,d):(o=u,i||(i=setTimeout(()=>{i=null,s(o)},n-m)))},()=>o&&s(o)]}var ki=su;var ct=(t,e,r=3)=>{let n=0,o=ji(50,250);return ki(i=>{let s=i.loaded,a=i.lengthComputable?i.total:void 0,c=s-n,u=o(c),d=s<=a;n=s;let m={loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&d?(a-s)/u:void 0,event:i,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(m)},r)},qn=(t,e)=>{let r=t!=null;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},Vn=t=>(...e)=>p.asap(()=>t(...e));var Zi=L.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,L.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(L.origin),L.navigator&&/(msie|trident)/i.test(L.navigator.userAgent)):()=>!0;var Ui=L.hasStandardBrowserEnv?{write(t,e,r,n,o,i){let s=[t+"="+encodeURIComponent(e)];p.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),p.isString(n)&&s.push("path="+n),p.isString(o)&&s.push("domain="+o),i===!0&&s.push("secure"),document.cookie=s.join("; ")},read(t){let e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function $n(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Bn(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Qt(t,e,r){let n=!$n(e);return t&&(n||r==!1)?Bn(t,e):e}var Ni=t=>t instanceof F?{...t}:t;function ae(t,e){e=e||{};let r={};function n(u,d,m,b){return p.isPlainObject(u)&&p.isPlainObject(d)?p.merge.call({caseless:b},u,d):p.isPlainObject(d)?p.merge({},d):p.isArray(d)?d.slice():d}function o(u,d,m,b){if(p.isUndefined(d)){if(!p.isUndefined(u))return n(void 0,u,m,b)}else return n(u,d,m,b)}function i(u,d){if(!p.isUndefined(d))return n(void 0,d)}function s(u,d){if(p.isUndefined(d)){if(!p.isUndefined(u))return n(void 0,u)}else return n(void 0,d)}function a(u,d,m){if(m in e)return n(u,d);if(m in t)return n(void 0,u)}let c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(u,d,m)=>o(Ni(u),Ni(d),m,!0)};return p.forEach(Object.keys({...t,...e}),function(d){let m=c[d]||o,b=m(t[d],e[d],d);p.isUndefined(b)&&m!==a||(r[d]=b)}),r}var Rr=t=>{let e=ae({},t),{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=e;e.headers=s=F.from(s),e.url=Jt(Qt(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let c;if(p.isFormData(r)){if(L.hasStandardBrowserEnv||L.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){let[u,...d]=c?c.split(";").map(m=>m.trim()).filter(Boolean):[];s.setContentType([u||"multipart/form-data",...d].join("; "))}}if(L.hasStandardBrowserEnv&&(n&&p.isFunction(n)&&(n=n(e)),n||n!==!1&&Zi(e.url))){let u=o&&i&&Ui.read(i);u&&s.set(o,u)}return e};var au=typeof XMLHttpRequest!="undefined",Di=au&&function(t){return new Promise(function(r,n){let o=Rr(t),i=o.data,s=F.from(o.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,d,m,b,C,y;function v(){C&&C(),y&&y(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let _=new XMLHttpRequest;_.open(o.method.toUpperCase(),o.url,!0),_.timeout=o.timeout;function S(){if(!_)return;let N=F.from("getAllResponseHeaders"in _&&_.getAllResponseHeaders()),D={data:!a||a==="text"||a==="json"?_.responseText:_.response,status:_.status,statusText:_.statusText,headers:N,config:t,request:_};Xt(function(ye){r(ye),v()},function(ye){n(ye),v()},D),_=null}"onloadend"in _?_.onloadend=S:_.onreadystatechange=function(){!_||_.readyState!==4||_.status===0&&!(_.responseURL&&_.responseURL.indexOf("file:")===0)||setTimeout(S)},_.onabort=function(){_&&(n(new A("Request aborted",A.ECONNABORTED,t,_)),_=null)},_.onerror=function(){n(new A("Network Error",A.ERR_NETWORK,t,_)),_=null},_.ontimeout=function(){let z=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",D=o.transitional||Or;o.timeoutErrorMessage&&(z=o.timeoutErrorMessage),n(new A(z,D.clarifyTimeoutError?A.ETIMEDOUT:A.ECONNABORTED,t,_)),_=null},i===void 0&&s.setContentType(null),"setRequestHeader"in _&&p.forEach(s.toJSON(),function(z,D){_.setRequestHeader(D,z)}),p.isUndefined(o.withCredentials)||(_.withCredentials=!!o.withCredentials),a&&a!=="json"&&(_.responseType=o.responseType),u&&([b,y]=ct(u,!0),_.addEventListener("progress",b)),c&&_.upload&&([m,C]=ct(c),_.upload.addEventListener("progress",m),_.upload.addEventListener("loadend",C)),(o.cancelToken||o.signal)&&(d=N=>{_&&(n(!N||N.type?new de(null,t,_):N),_.abort(),_=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));let R=zn(o.url);if(R&&L.protocols.indexOf(R)===-1){n(new A("Unsupported protocol "+R+":",A.ERR_BAD_REQUEST,t));return}_.send(i||null)})};var cu=(t,e)=>{let{length:r}=t=t?t.filter(Boolean):[];if(e||r){let n=new AbortController,o,i=function(u){if(!o){o=!0,a();let d=u instanceof Error?u:this.reason;n.abort(d instanceof A?d:new de(d instanceof Error?d.message:d))}},s=e&&setTimeout(()=>{s=null,i(new A(`timeout ${e} of ms exceeded`,A.ETIMEDOUT))},e),a=()=>{t&&(s&&clearTimeout(s),s=null,t.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),t=null)};t.forEach(u=>u.addEventListener("abort",i));let{signal:c}=n;return c.unsubscribe=()=>p.asap(a),c}},Li=cu;var uu=function*(t,e){let r=t.byteLength;if(!e||r<e){yield t;return}let n=0,o;for(;n<r;)o=n+e,yield t.slice(n,o),n=o},du=async function*(t,e){for await(let r of lu(t))yield*uu(r,e)},lu=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)break;yield n}}finally{await e.cancel()}},Hn=(t,e,r,n)=>{let o=du(t,e),i=0,s,a=c=>{s||(s=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:u,value:d}=await o.next();if(u){a(),c.close();return}let m=d.byteLength;if(r){let b=i+=m;r(b)}c.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})};var kr=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Fi=kr&&typeof ReadableStream=="function",fu=kr&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),zi=(t,...e)=>{try{return!!t(...e)}catch{return!1}},pu=Fi&&zi(()=>{let t=!1,e=new Request(L.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),Mi=64*1024,Wn=Fi&&zi(()=>p.isReadableStream(new Response("").body)),jr={stream:Wn&&(t=>t.body)};kr&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!jr[e]&&(jr[e]=p.isFunction(t[e])?r=>r[e]():(r,n)=>{throw new A(`Response type '${e}' is not supported`,A.ERR_NOT_SUPPORT,n)})})})(new Response);var mu=async t=>{if(t==null)return 0;if(p.isBlob(t))return t.size;if(p.isSpecCompliantForm(t))return(await new Request(L.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(p.isArrayBufferView(t)||p.isArrayBuffer(t))return t.byteLength;if(p.isURLSearchParams(t)&&(t=t+""),p.isString(t))return(await fu(t)).byteLength},hu=async(t,e)=>{let r=p.toFiniteNumber(t.getContentLength());return r==null?mu(e):r},qi=kr&&(async t=>{let{url:e,method:r,data:n,signal:o,cancelToken:i,timeout:s,onDownloadProgress:a,onUploadProgress:c,responseType:u,headers:d,withCredentials:m="same-origin",fetchOptions:b}=Rr(t);u=u?(u+"").toLowerCase():"text";let C=Li([o,i&&i.toAbortSignal()],s),y,v=C&&C.unsubscribe&&(()=>{C.unsubscribe()}),_;try{if(c&&pu&&r!=="get"&&r!=="head"&&(_=await hu(d,n))!==0){let D=new Request(e,{method:"POST",body:n,duplex:"half"}),te;if(p.isFormData(n)&&(te=D.headers.get("content-type"))&&d.setContentType(te),D.body){let[ye,je]=qn(_,ct(Vn(c)));n=Hn(D.body,Mi,ye,je)}}p.isString(m)||(m=m?"include":"omit");let S="credentials"in Request.prototype;y=new Request(e,{...b,signal:C,method:r.toUpperCase(),headers:d.normalize().toJSON(),body:n,duplex:"half",credentials:S?m:void 0});let R=await fetch(y,b),N=Wn&&(u==="stream"||u==="response");if(Wn&&(a||N&&v)){let D={};["status","statusText","headers"].forEach(_r=>{D[_r]=R[_r]});let te=p.toFiniteNumber(R.headers.get("content-length")),[ye,je]=a&&qn(te,ct(Vn(a),!0))||[];R=new Response(Hn(R.body,Mi,ye,()=>{je&&je(),v&&v()}),D)}u=u||"text";let z=await jr[p.findKey(jr,u)||"text"](R,t);return!N&&v&&v(),await new Promise((D,te)=>{Xt(D,te,{data:z,headers:F.from(R.headers),status:R.status,statusText:R.statusText,config:t,request:y})})}catch(S){throw v&&v(),S&&S.name==="TypeError"&&/Load failed|fetch/i.test(S.message)?Object.assign(new A("Network Error",A.ERR_NETWORK,t,y),{cause:S.cause||S}):A.from(S,S&&S.code,t,y)}});var Jn={http:Ir,xhr:Di,fetch:qi};p.forEach(Jn,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});var Vi=t=>`- ${t}`,yu=t=>p.isFunction(t)||t===null||t===!1,Zr={getAdapter:t=>{t=p.isArray(t)?t:[t];let{length:e}=t,r,n,o={};for(let i=0;i<e;i++){r=t[i];let s;if(n=r,!yu(r)&&(n=Jn[(s=String(r)).toLowerCase()],n===void 0))throw new A(`Unknown adapter '${s}'`);if(n)break;o[s||"#"+i]=n}if(!n){let i=Object.entries(o).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build")),s=e?i.length>1?`since :
|
|
4
4
|
`+i.map(Vi).join(`
|
|
5
5
|
`):" "+Vi(i[0]):"as no adapter specified";throw new A("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:Jn};function Kn(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new de(null,t)}function Ur(t){return Kn(t),t.headers=F.from(t.headers),t.data=Gt.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Zr.getAdapter(t.adapter||st.adapter)(t).then(function(n){return Kn(t),n.data=Gt.call(t,t.transformResponse,n),n.headers=F.from(n.headers),n},function(n){return Yt(n)||(Kn(t),n&&n.response&&(n.response.data=Gt.call(t,t.transformResponse,n.response),n.response.headers=F.from(n.response.headers))),Promise.reject(n)})}var Nr="1.11.0";var Dr={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Dr[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var $i={};Dr.transitional=function(e,r,n){function o(i,s){return"[Axios v"+Nr+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,a)=>{if(e===!1)throw new A(o(s," has been removed"+(r?" in "+r:"")),A.ERR_DEPRECATED);return r&&!$i[s]&&($i[s]=!0,console.warn(o(s," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,s,a):!0}};Dr.spelling=function(e){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function gu(t,e,r){if(typeof t!="object")throw new A("options must be an object",A.ERR_BAD_OPTION_VALUE);let n=Object.keys(t),o=n.length;for(;o-- >0;){let i=n[o],s=e[i];if(s){let a=t[i],c=a===void 0||s(a,i,t);if(c!==!0)throw new A("option "+i+" must be "+c,A.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new A("Unknown option "+i,A.ERR_BAD_OPTION)}}var er={assertOptions:gu,validators:Dr};var le=er.validators,ut=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Zn,response:new Zn}}async request(e,r){try{return await this._request(e,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;let i=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
6
|
-
`+i):n.stack=i}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=ae(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&er.assertOptions(n,{silentJSONParsing:le.transitional(le.boolean),forcedJSONParsing:le.transitional(le.boolean),clarifyTimeoutError:le.transitional(le.boolean)},!1),o!=null&&(p.isFunction(o)?r.paramsSerializer={serialize:o}:er.assertOptions(o,{encode:le.function,serialize:le.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),er.assertOptions(r,{baseUrl:le.spelling("baseURL"),withXsrfToken:le.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=i&&p.merge(i.common,i[r.method]);i&&p.forEach(["delete","get","head","post","put","patch","common"],y=>{delete i[y]}),r.headers=F.concat(s,i);let a=[],c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(r)===!1||(c=c&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});let u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,m=0,b;if(!c){let y=[Ur.bind(this),void 0];for(y.unshift(...a),y.push(...u),b=y.length,d=Promise.resolve(r);m<b;)d=d.then(y[m++],y[m++]);return d}b=a.length;let C=r;for(m=0;m<b;){let y=a[m++],v=a[m++];try{C=y(C)}catch(_){v.call(this,_);break}}try{d=Ur.call(this,C)}catch(y){return Promise.reject(y)}for(m=0,b=u.length;m<b;)d=d.then(u[m++],u[m++]);return d}getUri(e){e=ae(this.defaults,e);let r=Qt(e.baseURL,e.url,e.allowAbsoluteUrls);return Jt(r,e.params,e.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(e){ut.prototype[e]=function(r,n){return this.request(ae(n||{},{method:e,url:r,data:(n||{}).data}))}});p.forEach(["post","put","patch"],function(e){function r(n){return function(i,s,a){return this.request(ae(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}ut.prototype[e]=r(),ut.prototype[e+"Form"]=r(!0)});var tr=ut;var Gn=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(a=>{n.subscribe(a),i=a}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},e(function(i,s,a){n.reason||(n.reason=new de(i,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new t(function(o){e=o}),cancel:e}}},Bi=Gn;function Yn(t){return function(r){return t.apply(null,r)}}function Xn(t){return p.isObject(t)&&t.isAxiosError===!0}var Qn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Qn).forEach(([t,e])=>{Qn[e]=t});var Hi=Qn;function Wi(t){let e=new tr(t),r=Vt(tr.prototype.request,e);return p.extend(r,tr.prototype,e,{allOwnKeys:!0}),p.extend(r,e,null,{allOwnKeys:!0}),r.create=function(o){return Wi(ae(t,o))},r}var M=Wi(st);M.Axios=tr;M.CanceledError=de;M.CancelToken=Bi;M.isCancel=Yt;M.VERSION=Nr;M.toFormData=Ce;M.AxiosError=A;M.Cancel=M.CanceledError;M.all=function(e){return Promise.all(e)};M.spread=Yn;M.isAxiosError=Xn;M.mergeConfig=ae;M.AxiosHeaders=F;M.formToJSON=t=>Er(p.isHTMLForm(t)?new FormData(t):t);M.getAdapter=Zr.getAdapter;M.HttpStatusCode=Hi;M.default=M;var Lr=M;var{Axios:wy,AxiosError:Cy,CanceledError:Ty,isCancel:Sy,CancelToken:Iy,VERSION:Ay,all:Oy,Cancel:Ey,isAxiosError:Py,spread:Ry,toFormData:jy,AxiosHeaders:ky,HttpStatusCode:Zy,formToJSON:Uy,getAdapter:Ny,mergeConfig:Dy}=Lr;var es=xr(rr());var qr=class{constructor(e){this.API_VERSION="2022-03-01-preview";let{identifier:r,host:n}=e;this.baseURL=new URL(`/copilotstudio/prebuilt/authenticated/bots/${r}`,n),this.baseURL.searchParams.append("api-version",this.API_VERSION)}getConversationUrl(e){let r=new URL(this.baseURL.href);return r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r.href}};var Vr=class{constructor(e){this.API_VERSION="2022-03-01-preview";let{schema:r,host:n}=e;this.baseURL=new URL(`/copilotstudio/dataverse-backed/authenticated/bots/${r}`,n),this.baseURL.searchParams.append("api-version",this.API_VERSION)}getConversationUrl(e){let r=new URL(this.baseURL.href);return r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r.href}};var pt=(0,es.debug)("copilot-studio:power-platform");function Br(t,e){var a,c,u,d,m,b;if((a=t.directConnectUrl)!=null&&a.trim()){if(pt.debug(`Using direct connection: ${t.directConnectUrl}`),!nr(t.directConnectUrl))throw new Error("directConnectUrl must be a valid URL");return t.directConnectUrl.toLowerCase().includes("tenants/00000000-0000-0000-0000-000000000000")?(pt.debug(`Direct connection cannot be used, forcing default settings flow. Tenant ID is missing in the URL: ${t.directConnectUrl}`),Br({...t,directConnectUrl:""},e)):Zu(t.directConnectUrl,e).href}let r=(c=t.cloud)!=null?c:"Prod",n=(u=t.copilotAgentType)!=null?u:"Published";if(pt.debug(`Using cloud setting: ${r}`),pt.debug(`Using agent type: ${n}`),!((d=t.environmentId)!=null&&d.trim()))throw new Error("EnvironmentId must be provided");if(!((m=t.agentIdentifier)!=null&&m.trim()))throw new Error("AgentIdentifier must be provided");if(r==="Other")if((b=t.customPowerPlatformCloud)!=null&&b.trim())if(nr(t.customPowerPlatformCloud))pt.debug(`Using custom Power Platform cloud: ${t.customPowerPlatformCloud}`);else throw new Error("customPowerPlatformCloud must be a valid URL");else throw new Error("customPowerPlatformCloud must be provided when PowerPlatformCloud is Other");let o=Uu(r,t.environmentId,t.customPowerPlatformCloud),s={Published:()=>new Vr({host:o,schema:t.agentIdentifier}),Prebuilt:()=>new qr({host:o,identifier:t.agentIdentifier})}[n]().getConversationUrl(e);return pt.debug(`Generated Copilot Studio connection URL: ${s}`),s}function ts(t,e="Unknown",r="",n=""){var o,i;if(!n&&!(t!=null&&t.directConnectUrl)){if(e==="Other"&&!r)throw new Error("cloudBaseAddress must be provided when PowerPlatformCloudCategory is Other");if(!t&&e==="Unknown")throw new Error("Either settings or cloud must be provided");if(t&&t.cloud&&t.cloud!=="Unknown"&&(e=t.cloud),e==="Other")if(r&&nr(r))e="Other";else if(t!=null&&t.customPowerPlatformCloud&&nr(t.customPowerPlatformCloud))e="Other",r=t.customPowerPlatformCloud;else throw new Error("Either CustomPowerPlatformCloud or cloudBaseAddress must be provided when PowerPlatformCloudCategory is Other");return r!=null||(r="api.unknown.powerplatform.com"),`https://${$r(e,r)}/.default`}else if(n||(n=(o=t==null?void 0:t.directConnectUrl)!=null?o:""),n&&nr(n)){if(Qi(new URL(n))==="Unknown"){let s=(i=t==null?void 0:t.cloud)!=null?i:e;if(s==="Other"||s==="Unknown")throw new Error("Unable to resolve the PowerPlatform Cloud from DirectConnectUrl. The Token Audience resolver requires a specific PowerPlatformCloudCategory.");if(s!=="Unknown")return`https://${$r(s,"")}/.default`;throw new Error("Unable to resolve the PowerPlatform Cloud from DirectConnectUrl. The Token Audience resolver requires a specific PowerPlatformCloudCategory.")}return`https://${$r(Qi(new URL(n)),"")}/.default`}else throw new Error("DirectConnectUrl must be provided when DirectConnectUrl is set")}function nr(t){try{let e=t.startsWith("http")?t:`https://${t}`;return!!new URL(e)}catch{return!1}}function Zu(t,e){let r=new URL(t);return r.searchParams.has("api-version")||r.searchParams.append("api-version","2022-03-01-preview"),r.pathname.endsWith("/")&&(r.pathname=r.pathname.slice(0,-1)),r.pathname.includes("/conversations")&&(r.pathname=r.pathname.substring(0,r.pathname.indexOf("/conversations"))),r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r}function Uu(t,e,r){if(t==="Other"&&(!r||!r.trim()))throw new Error("cloudBaseAddress must be provided when PowerPlatformCloud is Other");r=r!=null?r:"api.unknown.powerplatform.com";let n=e.toLowerCase().replaceAll("-",""),o=Nu(t),i=n.substring(0,n.length-o),s=n.substring(n.length-o);return new URL(`https://${i}.${s}.environment.${$r(t,r)}`)}function $r(t,e){switch(t){case"Local":return"api.powerplatform.localhost";case"Exp":return"api.exp.powerplatform.com";case"Dev":return"api.dev.powerplatform.com";case"Prv":return"api.prv.powerplatform.com";case"Test":return"api.test.powerplatform.com";case"Preprod":return"api.preprod.powerplatform.com";case"FirstRelease":case"Prod":return"api.powerplatform.com";case"GovFR":return"api.gov.powerplatform.microsoft.us";case"Gov":return"api.gov.powerplatform.microsoft.us";case"High":return"api.high.powerplatform.microsoft.us";case"DoD":return"api.appsplatform.us";case"Mooncake":return"api.powerplatform.partner.microsoftonline.cn";case"Ex":return"api.powerplatform.eaglex.ic.gov";case"Rx":return"api.powerplatform.microsoft.scloud";case"Other":return e;default:throw new Error(`Invalid cluster category value: ${t}`)}}function Nu(t){switch(t){case"FirstRelease":case"Prod":return 2;default:return 1}}function Qi(t){switch(t.host.toLowerCase()){case"api.powerplatform.localhost":return"Local";case"api.exp.powerplatform.com":return"Exp";case"api.dev.powerplatform.com":return"Dev";case"api.prv.powerplatform.com":return"Prv";case"api.test.powerplatform.com":return"Test";case"api.preprod.powerplatform.com":return"Preprod";case"api.powerplatform.com":return"Prod";case"api.gov.powerplatform.microsoft.us":return"GovFR";case"api.high.powerplatform.microsoft.us":return"High";case"api.appsplatform.us":return"DoD";case"api.powerplatform.partner.microsoftonline.cn":return"Mooncake";default:return"Unknown"}}var gr=xr(Ra());var _n=class{constructor(e){this.activity=e}};var Za=xr(rr());var ja="1.1.0-alpha.2";var xn={};var Q=(0,Za.debug)("copilot-studio:client"),we=class we{constructor(e,r){this.conversationId="";this.settings=e,this.client=Lr.create(),this.client.defaults.headers.common.Authorization=`Bearer ${r}`,this.client.defaults.headers.common["User-Agent"]=we.getProductInfo()}async postRequestAsync(e){var m,b,C,y;let r=[];Q.debug(`>>> SEND TO ${e.url}`);let n=await this.client(e);if(this.settings.useExperimentalEndpoint&&!((m=this.settings.directConnectUrl)!=null&&m.trim())){let v=(b=n.headers)==null?void 0:b[we.islandExperimentalUrlHeaderKey];v&&(this.settings.directConnectUrl=v,Q.debug(`Island Experimental URL: ${v}`))}this.conversationId=(y=(C=n.headers)==null?void 0:C[we.conversationIdHeaderKey])!=null?y:"",this.conversationId&&Q.debug(`Conversation ID: ${this.conversationId}`);let o={...n.headers};delete o.Authorization,delete o[we.conversationIdHeaderKey],Q.debug("Headers received:",o);let s=n.data.pipeThrough(new TextDecoderStream).getReader(),a="",c=[],u=async({done:v,value:_})=>v?(Q.debug("Stream complete"),a+=_,c.push(a),c):(Q.info("Agent is typing ..."),a+=_,await u(await s.read()));return(await s.read().then(u)).forEach(v=>{v.toString().split(`
|
|
6
|
+
`+i):n.stack=i}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=ae(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&er.assertOptions(n,{silentJSONParsing:le.transitional(le.boolean),forcedJSONParsing:le.transitional(le.boolean),clarifyTimeoutError:le.transitional(le.boolean)},!1),o!=null&&(p.isFunction(o)?r.paramsSerializer={serialize:o}:er.assertOptions(o,{encode:le.function,serialize:le.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),er.assertOptions(r,{baseUrl:le.spelling("baseURL"),withXsrfToken:le.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=i&&p.merge(i.common,i[r.method]);i&&p.forEach(["delete","get","head","post","put","patch","common"],y=>{delete i[y]}),r.headers=F.concat(s,i);let a=[],c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(r)===!1||(c=c&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});let u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,m=0,b;if(!c){let y=[Ur.bind(this),void 0];for(y.unshift(...a),y.push(...u),b=y.length,d=Promise.resolve(r);m<b;)d=d.then(y[m++],y[m++]);return d}b=a.length;let C=r;for(m=0;m<b;){let y=a[m++],v=a[m++];try{C=y(C)}catch(_){v.call(this,_);break}}try{d=Ur.call(this,C)}catch(y){return Promise.reject(y)}for(m=0,b=u.length;m<b;)d=d.then(u[m++],u[m++]);return d}getUri(e){e=ae(this.defaults,e);let r=Qt(e.baseURL,e.url,e.allowAbsoluteUrls);return Jt(r,e.params,e.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(e){ut.prototype[e]=function(r,n){return this.request(ae(n||{},{method:e,url:r,data:(n||{}).data}))}});p.forEach(["post","put","patch"],function(e){function r(n){return function(i,s,a){return this.request(ae(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}ut.prototype[e]=r(),ut.prototype[e+"Form"]=r(!0)});var tr=ut;var Gn=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(a=>{n.subscribe(a),i=a}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},e(function(i,s,a){n.reason||(n.reason=new de(i,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new t(function(o){e=o}),cancel:e}}},Bi=Gn;function Yn(t){return function(r){return t.apply(null,r)}}function Xn(t){return p.isObject(t)&&t.isAxiosError===!0}var Qn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Qn).forEach(([t,e])=>{Qn[e]=t});var Hi=Qn;function Wi(t){let e=new tr(t),r=Vt(tr.prototype.request,e);return p.extend(r,tr.prototype,e,{allOwnKeys:!0}),p.extend(r,e,null,{allOwnKeys:!0}),r.create=function(o){return Wi(ae(t,o))},r}var M=Wi(st);M.Axios=tr;M.CanceledError=de;M.CancelToken=Bi;M.isCancel=Yt;M.VERSION=Nr;M.toFormData=Ce;M.AxiosError=A;M.Cancel=M.CanceledError;M.all=function(e){return Promise.all(e)};M.spread=Yn;M.isAxiosError=Xn;M.mergeConfig=ae;M.AxiosHeaders=F;M.formToJSON=t=>Er(p.isHTMLForm(t)?new FormData(t):t);M.getAdapter=Zr.getAdapter;M.HttpStatusCode=Hi;M.default=M;var Lr=M;var{Axios:wy,AxiosError:Cy,CanceledError:Ty,isCancel:Sy,CancelToken:Iy,VERSION:Ay,all:Oy,Cancel:Ey,isAxiosError:Py,spread:Ry,toFormData:jy,AxiosHeaders:ky,HttpStatusCode:Zy,formToJSON:Uy,getAdapter:Ny,mergeConfig:Dy}=Lr;var es=xr(rr());var qr=class{constructor(e){this.API_VERSION="2022-03-01-preview";let{identifier:r,host:n}=e;this.baseURL=new URL(`/copilotstudio/prebuilt/authenticated/bots/${r}`,n),this.baseURL.searchParams.append("api-version",this.API_VERSION)}getConversationUrl(e){let r=new URL(this.baseURL.href);return r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r.href}};var Vr=class{constructor(e){this.API_VERSION="2022-03-01-preview";let{schema:r,host:n}=e;this.baseURL=new URL(`/copilotstudio/dataverse-backed/authenticated/bots/${r}`,n),this.baseURL.searchParams.append("api-version",this.API_VERSION)}getConversationUrl(e){let r=new URL(this.baseURL.href);return r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r.href}};var pt=(0,es.debug)("copilot-studio:power-platform");function Br(t,e){var a,c,u,d,m,b;if((a=t.directConnectUrl)!=null&&a.trim()){if(pt.debug(`Using direct connection: ${t.directConnectUrl}`),!nr(t.directConnectUrl))throw new Error("directConnectUrl must be a valid URL");return t.directConnectUrl.toLowerCase().includes("tenants/00000000-0000-0000-0000-000000000000")?(pt.debug(`Direct connection cannot be used, forcing default settings flow. Tenant ID is missing in the URL: ${t.directConnectUrl}`),Br({...t,directConnectUrl:""},e)):Zu(t.directConnectUrl,e).href}let r=(c=t.cloud)!=null?c:"Prod",n=(u=t.copilotAgentType)!=null?u:"Published";if(pt.debug(`Using cloud setting: ${r}`),pt.debug(`Using agent type: ${n}`),!((d=t.environmentId)!=null&&d.trim()))throw new Error("EnvironmentId must be provided");if(!((m=t.agentIdentifier)!=null&&m.trim()))throw new Error("AgentIdentifier must be provided");if(r==="Other")if((b=t.customPowerPlatformCloud)!=null&&b.trim())if(nr(t.customPowerPlatformCloud))pt.debug(`Using custom Power Platform cloud: ${t.customPowerPlatformCloud}`);else throw new Error("customPowerPlatformCloud must be a valid URL");else throw new Error("customPowerPlatformCloud must be provided when PowerPlatformCloud is Other");let o=Uu(r,t.environmentId,t.customPowerPlatformCloud),s={Published:()=>new Vr({host:o,schema:t.agentIdentifier}),Prebuilt:()=>new qr({host:o,identifier:t.agentIdentifier})}[n]().getConversationUrl(e);return pt.debug(`Generated Copilot Studio connection URL: ${s}`),s}function ts(t,e="Unknown",r="",n=""){var o,i;if(!n&&!(t!=null&&t.directConnectUrl)){if(e==="Other"&&!r)throw new Error("cloudBaseAddress must be provided when PowerPlatformCloudCategory is Other");if(!t&&e==="Unknown")throw new Error("Either settings or cloud must be provided");if(t&&t.cloud&&t.cloud!=="Unknown"&&(e=t.cloud),e==="Other")if(r&&nr(r))e="Other";else if(t!=null&&t.customPowerPlatformCloud&&nr(t.customPowerPlatformCloud))e="Other",r=t.customPowerPlatformCloud;else throw new Error("Either CustomPowerPlatformCloud or cloudBaseAddress must be provided when PowerPlatformCloudCategory is Other");return r!=null||(r="api.unknown.powerplatform.com"),`https://${$r(e,r)}/.default`}else if(n||(n=(o=t==null?void 0:t.directConnectUrl)!=null?o:""),n&&nr(n)){if(Qi(new URL(n))==="Unknown"){let s=(i=t==null?void 0:t.cloud)!=null?i:e;if(s==="Other"||s==="Unknown")throw new Error("Unable to resolve the PowerPlatform Cloud from DirectConnectUrl. The Token Audience resolver requires a specific PowerPlatformCloudCategory.");if(s!=="Unknown")return`https://${$r(s,"")}/.default`;throw new Error("Unable to resolve the PowerPlatform Cloud from DirectConnectUrl. The Token Audience resolver requires a specific PowerPlatformCloudCategory.")}return`https://${$r(Qi(new URL(n)),"")}/.default`}else throw new Error("DirectConnectUrl must be provided when DirectConnectUrl is set")}function nr(t){try{let e=t.startsWith("http")?t:`https://${t}`;return!!new URL(e)}catch{return!1}}function Zu(t,e){let r=new URL(t);return r.searchParams.has("api-version")||r.searchParams.append("api-version","2022-03-01-preview"),r.pathname.endsWith("/")&&(r.pathname=r.pathname.slice(0,-1)),r.pathname.includes("/conversations")&&(r.pathname=r.pathname.substring(0,r.pathname.indexOf("/conversations"))),r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r}function Uu(t,e,r){if(t==="Other"&&(!r||!r.trim()))throw new Error("cloudBaseAddress must be provided when PowerPlatformCloud is Other");r=r!=null?r:"api.unknown.powerplatform.com";let n=e.toLowerCase().replaceAll("-",""),o=Nu(t),i=n.substring(0,n.length-o),s=n.substring(n.length-o);return new URL(`https://${i}.${s}.environment.${$r(t,r)}`)}function $r(t,e){switch(t){case"Local":return"api.powerplatform.localhost";case"Exp":return"api.exp.powerplatform.com";case"Dev":return"api.dev.powerplatform.com";case"Prv":return"api.prv.powerplatform.com";case"Test":return"api.test.powerplatform.com";case"Preprod":return"api.preprod.powerplatform.com";case"FirstRelease":case"Prod":return"api.powerplatform.com";case"GovFR":return"api.gov.powerplatform.microsoft.us";case"Gov":return"api.gov.powerplatform.microsoft.us";case"High":return"api.high.powerplatform.microsoft.us";case"DoD":return"api.appsplatform.us";case"Mooncake":return"api.powerplatform.partner.microsoftonline.cn";case"Ex":return"api.powerplatform.eaglex.ic.gov";case"Rx":return"api.powerplatform.microsoft.scloud";case"Other":return e;default:throw new Error(`Invalid cluster category value: ${t}`)}}function Nu(t){switch(t){case"FirstRelease":case"Prod":return 2;default:return 1}}function Qi(t){switch(t.host.toLowerCase()){case"api.powerplatform.localhost":return"Local";case"api.exp.powerplatform.com":return"Exp";case"api.dev.powerplatform.com":return"Dev";case"api.prv.powerplatform.com":return"Prv";case"api.test.powerplatform.com":return"Test";case"api.preprod.powerplatform.com":return"Preprod";case"api.powerplatform.com":return"Prod";case"api.gov.powerplatform.microsoft.us":return"GovFR";case"api.high.powerplatform.microsoft.us":return"High";case"api.appsplatform.us":return"DoD";case"api.powerplatform.partner.microsoftonline.cn":return"Mooncake";default:return"Unknown"}}var gr=xr(Ra());var _n=class{constructor(e){this.activity=e}};var Za=xr(rr());var ja="1.1.0-alpha.5";var xn={};var Q=(0,Za.debug)("copilot-studio:client"),we=class we{constructor(e,r){this.conversationId="";this.settings=e,this.client=Lr.create(),this.client.defaults.headers.common.Authorization=`Bearer ${r}`,this.client.defaults.headers.common["User-Agent"]=we.getProductInfo()}async postRequestAsync(e){var m,b,C,y;let r=[];Q.debug(`>>> SEND TO ${e.url}`);let n=await this.client(e);if(this.settings.useExperimentalEndpoint&&!((m=this.settings.directConnectUrl)!=null&&m.trim())){let v=(b=n.headers)==null?void 0:b[we.islandExperimentalUrlHeaderKey];v&&(this.settings.directConnectUrl=v,Q.debug(`Island Experimental URL: ${v}`))}this.conversationId=(y=(C=n.headers)==null?void 0:C[we.conversationIdHeaderKey])!=null?y:"",this.conversationId&&Q.debug(`Conversation ID: ${this.conversationId}`);let o={...n.headers};delete o.Authorization,delete o[we.conversationIdHeaderKey],Q.debug("Headers received:",o);let s=n.data.pipeThrough(new TextDecoderStream).getReader(),a="",c=[],u=async({done:v,value:_})=>v?(Q.debug("Stream complete"),a+=_,c.push(a),c):(Q.info("Agent is typing ..."),a+=_,await u(await s.read()));return(await s.read().then(u)).forEach(v=>{v.toString().split(`
|
|
7
7
|
`).filter(R=>R.substring(0,4)==="data"&&R!=="data: end\r").forEach(R=>{var N,z;try{let D=gr.Activity.fromJson(R.substring(5,R.length));D.type===gr.ActivityTypes.Message?(r.push(D),this.conversationId.trim()||(this.conversationId=(z=(N=D.conversation)==null?void 0:N.id)!=null?z:"",Q.debug(`Conversation ID: ${this.conversationId}`))):Q.debug(`Activity type: ${D.type}`)}catch(D){throw Q.error("Error: ",D),D}})}),r}static getProductInfo(){let e=`CopilotStudioClient.agents-sdk-js/${ja}`,r;return typeof window!="undefined"&&window.navigator?r=`${e} ${navigator.userAgent}`:r=`${e} nodejs/${process.version} ${xn.platform()}-${xn.arch()}/${xn.release()}`,Q.debug(`User-Agent: ${r}`),r}async startConversationAsync(e=!0){var a;let o={method:"post",url:Br(this.settings),headers:{Accept:"text/event-stream","Content-Type":"application/json"},data:{emitStartConversationEvent:e},responseType:"stream",adapter:"fetch"};Q.info("Starting conversation ...");let i=await this.postRequestAsync(o),s=i[0];return Q.info(`Conversation '${(a=s.conversation)==null?void 0:a.id}' started. Received ${i.length} activities.`,i),s}async askQuestionAsync(e,r=this.conversationId){let o={type:"message",text:e,conversation:{id:r}},i=gr.Activity.fromObject(o);return this.sendActivity(i)}async sendActivity(e,r=this.conversationId){var c,u;let n=(u=(c=e.conversation)==null?void 0:c.id)!=null?u:r,o=Br(this.settings,n),i=new _n(e),s={method:"post",url:o,headers:{Accept:"text/event-stream","Content-Type":"application/json"},data:i,responseType:"stream",adapter:"fetch"};Q.info("Sending activity...",e);let a=await this.postRequestAsync(s);return Q.info(`Received ${a.length} activities.`,a),a}};we.conversationIdHeaderKey="x-ms-conversationid",we.islandExperimentalUrlHeaderKey="x-ms-d2e-experimental",we.scopeFromSettings=ts;var ka=we;var V=[];for(let t=0;t<256;++t)V.push((t+256).toString(16).slice(1));function Ua(t,e=0){return(V[t[e+0]]+V[t[e+1]]+V[t[e+2]]+V[t[e+3]]+"-"+V[t[e+4]]+V[t[e+5]]+"-"+V[t[e+6]]+V[t[e+7]]+"-"+V[t[e+8]]+V[t[e+9]]+"-"+V[t[e+10]]+V[t[e+11]]+V[t[e+12]]+V[t[e+13]]+V[t[e+14]]+V[t[e+15]]).toLowerCase()}var Yo,ip=new Uint8Array(16);function Xo(){if(!Yo){if(typeof crypto=="undefined"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Yo=crypto.getRandomValues.bind(crypto)}return Yo(ip)}var sp=typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Qo={randomUUID:sp};function ap(t,e,r){var o,i,s;if(Qo.randomUUID&&!e&&!t)return Qo.randomUUID();t=t||{};let n=(s=(i=t.random)!=null?i:(o=t.rng)==null?void 0:o.call(t))!=null?s:Xo();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(r=r||0,r<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let a=0;a<16;++a)e[r+a]=n[a];return e}return Ua(n)}var ei=ap;var ti=function(t,e){return ti=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},ti(t,e)};function Pe(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ti(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function vr(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ut(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i}function Nt(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function ie(t){return typeof t=="function"}function wn(t){var e=function(n){Error.call(n),n.stack=new Error().stack},r=t(e);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Cn=wn(function(t){return function(r){t(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
8
8
|
`+r.map(function(n,o){return o+1+") "+n.toString()}).join(`
|
|
9
9
|
`):"",this.name="UnsubscriptionError",this.errors=r}});function br(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var Dt=(function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,r,n,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=vr(s),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(v){e={error:v}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}else s.remove(this);var d=this.initialTeardown;if(ie(d))try{d()}catch(v){i=v instanceof Cn?v.errors:[v]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var b=vr(m),C=b.next();!C.done;C=b.next()){var y=C.value;try{Na(y)}catch(v){i=i!=null?i:[],v instanceof Cn?i=Nt(Nt([],Ut(i)),Ut(v.errors)):i.push(v)}}}catch(v){n={error:v}}finally{try{C&&!C.done&&(o=b.return)&&o.call(b)}finally{if(n)throw n.error}}}if(i)throw new Cn(i)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)Na(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},t.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},t.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},t.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&br(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&br(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=(function(){var e=new t;return e.closed=!0,e})(),t})();var ri=Dt.EMPTY;function Tn(t){return t instanceof Dt||t&&"closed"in t&&ie(t.remove)&&ie(t.add)&&ie(t.unsubscribe)}function Na(t){ie(t)?t():t.unsubscribe()}var ue={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Lt={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=Lt.delegate;return o!=null&&o.setTimeout?o.setTimeout.apply(o,Nt([t,e],Ut(r))):setTimeout.apply(void 0,Nt([t,e],Ut(r)))},clearTimeout:function(t){var e=Lt.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function Da(t){Lt.setTimeout(function(){var e=ue.onUnhandledError;if(e)e(t);else throw t})}function ni(){}var La=(function(){return oi("C",void 0,void 0)})();function Ma(t){return oi("E",void 0,t)}function Fa(t){return oi("N",t,void 0)}function oi(t,e,r){return{kind:t,value:e,error:r}}var nt=null;function Mt(t){if(ue.useDeprecatedSynchronousErrorHandling){var e=!nt;if(e&&(nt={errorThrown:!1,error:null}),t(),e){var r=nt,n=r.errorThrown,o=r.error;if(nt=null,n)throw o}}else t()}function za(t){ue.useDeprecatedSynchronousErrorHandling&&nt&&(nt.errorThrown=!0,nt.error=t)}var ai=(function(t){Pe(e,t);function e(r){var n=t.call(this)||this;return n.isStopped=!1,r?(n.destination=r,Tn(r)&&r.add(n)):n.destination=lp,n}return e.create=function(r,n,o){return new In(r,n,o)},e.prototype.next=function(r){this.isStopped?si(Fa(r),this):this._next(r)},e.prototype.error=function(r){this.isStopped?si(Ma(r),this):(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped?si(La,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e})(Dt);var cp=Function.prototype.bind;function ii(t,e){return cp.call(t,e)}var up=(function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(n){Sn(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){Sn(n)}else Sn(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){Sn(r)}},t})(),In=(function(t){Pe(e,t);function e(r,n,o){var i=t.call(this)||this,s;if(ie(r)||!r)s={next:r!=null?r:void 0,error:n!=null?n:void 0,complete:o!=null?o:void 0};else{var a;i&&ue.useDeprecatedNextContext?(a=Object.create(r),a.unsubscribe=function(){return i.unsubscribe()},s={next:r.next&&ii(r.next,a),error:r.error&&ii(r.error,a),complete:r.complete&&ii(r.complete,a)}):s=r}return i.destination=new up(s),i}return e})(ai);function Sn(t){ue.useDeprecatedSynchronousErrorHandling?za(t):Da(t)}function dp(t){throw t}function si(t,e){var r=ue.onStoppedNotification;r&&Lt.setTimeout(function(){return r(t,e)})}var lp={closed:!0,next:ni,error:dp,complete:ni};var qa=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Va(t){return t}function $a(t){return t.length===0?Va:t.length===1?t[0]:function(r){return t.reduce(function(n,o){return o(n)},r)}}var Ft=(function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(e,r,n){var o=this,i=pp(e)?e:new In(e,r,n);return Mt(function(){var s=o,a=s.operator,c=s.source;i.add(a?a.call(i,c):c?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},t.prototype.forEach=function(e,r){var n=this;return r=Ba(r),new r(function(o,i){var s=new In({next:function(a){try{e(a)}catch(c){i(c),s.unsubscribe()}},error:i,complete:o});n.subscribe(s)})},t.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},t.prototype[qa]=function(){return this},t.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return $a(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=Ba(e),new e(function(n,o){var i;r.subscribe(function(s){return i=s},function(s){return o(s)},function(){return n(i)})})},t.create=function(e){return new t(e)},t})();function Ba(t){var e;return(e=t!=null?t:ue.Promise)!==null&&e!==void 0?e:Promise}function fp(t){return t&&ie(t.next)&&ie(t.error)&&ie(t.complete)}function pp(t){return t&&t instanceof ai||fp(t)&&Tn(t)}var Ha=wn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var ci=(function(t){Pe(e,t);function e(){var r=t.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return e.prototype.lift=function(r){var n=new Wa(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Ha},e.prototype.next=function(r){var n=this;Mt(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var s=vr(n.currentObservers),a=s.next();!a.done;a=s.next()){var c=a.value;c.next(r)}}catch(u){o={error:u}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},e.prototype.error=function(r){var n=this;Mt(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var o=n.observers;o.length;)o.shift().error(r)}})},e.prototype.complete=function(){var r=this;Mt(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,s=o.isStopped,a=o.observers;return i||s?ri:(this.currentObservers=null,a.push(r),new Dt(function(){n.currentObservers=null,br(a,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,s=n.isStopped;o?r.error(i):s&&r.complete()},e.prototype.asObservable=function(){var r=new Ft;return r.source=this,r},e.create=function(r,n){return new Wa(r,n)},e})(Ft);var Wa=(function(t){Pe(e,t);function e(r,n){var o=t.call(this)||this;return o.destination=r,o.source=n,o}return e.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},e.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},e.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},e.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:ri},e})(ci);var ui=(function(t){Pe(e,t);function e(r){var n=t.call(this)||this;return n._value=r,n}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(r){var n=t.prototype._subscribe.call(this,r);return!n.closed&&r.next(this._value),n},e.prototype.getValue=function(){var r=this,n=r.hasError,o=r.thrownError,i=r._value;if(n)throw o;return this._throwIfClosed(),i},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e})(ci);var Ga=xr(rr()),Re=(0,Ga.debug)("copilot-studio:webchat"),Ja=class{static createConnection(e,r){Re.info("--> Creating connection between Copilot Studio and WebChat ...");let n=0,o,i,s=new ui(0),a=Ka(async d=>{if(o=d,s.value<2){s.next(2);return}Re.debug("--> Connection established."),u();let m=await e.startConversationAsync();i=m.conversation,n=0,c(m)}),c=d=>{let m={...d,timestamp:new Date().toISOString(),channelData:{...d.channelData,"webchat:sequence-id":n++}};Re.debug(`Notify '${m.type}' activity to WebChat:`,m),o==null||o.next(m)},u=()=>{if(!(r!=null&&r.showTyping))return;let d=i?{id:i.id,name:i.name}:{id:"agent",name:"Agent"};c({type:"typing",from:d})};return{connectionStatus$:s,activity$:a,postActivity(d){if(Re.info("--> Preparing to send activity to Copilot Studio ..."),!d)throw new Error("Activity cannot be null.");if(!o)throw new Error("Activity subscriber is not initialized.");return Ka(async m=>{try{let b=ei();Re.info("--> Sending activity to Copilot Studio ..."),c({...d,id:b}),u();let C=await e.sendActivity(d);for(let y of C)c(y);m.next(b),m.complete(),Re.info("--> Activity received correctly from Copilot Studio.")}catch(b){Re.error("Error sending Activity to Copilot Studio:",b),m.error(b)}})},end(){Re.info("--> Ending connection between Copilot Studio and WebChat ..."),s.complete(),o&&(o.complete(),o=void 0)}}}};function Ka(t){return new Ft(e=>{Promise.resolve(t(e)).catch(r=>e.error(r))})}export{zt as AgentType,En as ConnectionSettings,ka as CopilotStudioClient,Ja as CopilotStudioWebChat,_n as ExecuteTurnRequest,qt as PowerPlatformCloud,Br as getCopilotStudioConnectionUrl,ts as getTokenAudience,bp as loadCopilotStudioConnectionSettingsFromEnv};
|