@asgard-js/core 0.3.12 → 0.3.13
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/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -28
- package/dist/index.mjs.map +1 -1
- package/dist/lib/conversation.d.ts.map +1 -1
- package/dist/types/sse-response.d.ts +1 -0
- package/dist/types/sse-response.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Y extends Error{status;statusText;body;constructor(t,e,r){super(`HTTP ${t}: ${e}`),this.name="HttpError",this.status=t,this.statusText=e,this.body=r}}function tt(n){return n instanceof Y}var R=(n=>(n.RESET_CHANNEL="RESET_CHANNEL",n.NONE="NONE",n.RESPONSE_TOOL_CALL_CONSENT="RESPONSE_TOOL_CALL_CONSENT",n))(R||{}),d=(n=>(n.INIT="asgard.run.init",n.PROCESS="asgard.process",n.PROCESS_START="asgard.process.start",n.PROCESS_COMPLETE="asgard.process.complete",n.MESSAGE="asgard.message",n.MESSAGE_START="asgard.message.start",n.MESSAGE_DELTA="asgard.message.delta",n.MESSAGE_COMPLETE="asgard.message.complete",n.MESSAGE_USER="asgard.message.user",n.MESSAGE_THINKING_START="asgard.message.thinking.start",n.MESSAGE_THINKING_DELTA="asgard.message.thinking.delta",n.MESSAGE_THINKING_COMPLETE="asgard.message.thinking.complete",n.TOOL_CALL="asgard.tool_call",n.TOOL_CALL_START="asgard.tool_call.start",n.TOOL_CALL_COMPLETE="asgard.tool_call.complete",n.TOOL_CALL_CONSENT="asgard.tool_call.consent",n.SUBAGENT_START="asgard.subagent.start",n.SUBAGENT_COMPLETE="asgard.subagent.complete",n.CHANNEL_TITLE_UPDATE="asgard.channel.title.update",n.SANDBOX_LAUNCH="asgard.sandbox.launch",n.SANDBOX_READY="asgard.sandbox.ready",n.DONE="asgard.run.done",n.ERROR="asgard.run.error",n))(d||{}),ve=(n=>(n.ALLOW_ONCE="ALLOW_ONCE",n.ALLOW_ALWAYS="ALLOW_ALWAYS",n.DENY_ONCE="DENY_ONCE",n))(ve||{}),be=(n=>(n.TEXT="TEXT",n.HINT="HINT",n.BUTTON="BUTTON",n.IMAGE="IMAGE",n.VIDEO="VIDEO",n.AUDIO="AUDIO",n.LOCATION="LOCATION",n.CAROUSEL="CAROUSEL",n.CHART="CHART",n.TABLE="TABLE",n.ATTACHMENT="ATTACHMENT",n))(be||{}),Q=function(n,t){return Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},Q(n,t)};function w(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Q(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function nt(n,t,e,r){function s(o){return o instanceof e?o:new e(function(i){i(o)})}return new(e||(e=Promise))(function(o,i){function a(h){try{c(r.next(h))}catch(g){i(g)}}function u(h){try{c(r.throw(h))}catch(g){i(g)}}function c(h){h.done?o(h.value):s(h.value).then(a,u)}c((r=r.apply(n,t||[])).next())})}function ye(n,t){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(h){return u([c,h])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(e=0)),e;)try{if(r=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,s=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){e.label=c[1];break}if(c[0]===6&&e.label<o[1]){e.label=o[1],o=c;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(c);break}o[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(h){c=[6,h],s=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function k(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function j(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(i)throw i.error}}return o}function D(n,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||Array.prototype.slice.call(t))}function L(n){return this instanceof L?(this.v=n,this):new L(n)}function rt(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(l){return function(f){return Promise.resolve(f).then(l,g)}}function a(l,f){r[l]&&(s[l]=function(p){return new Promise(function(_,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Y extends Error{status;statusText;body;constructor(t,e,r){super(`HTTP ${t}: ${e}`),this.name="HttpError",this.status=t,this.statusText=e,this.body=r}}function tt(n){return n instanceof Y}var R=(n=>(n.RESET_CHANNEL="RESET_CHANNEL",n.NONE="NONE",n.RESPONSE_TOOL_CALL_CONSENT="RESPONSE_TOOL_CALL_CONSENT",n))(R||{}),d=(n=>(n.INIT="asgard.run.init",n.PROCESS="asgard.process",n.PROCESS_START="asgard.process.start",n.PROCESS_COMPLETE="asgard.process.complete",n.MESSAGE="asgard.message",n.MESSAGE_START="asgard.message.start",n.MESSAGE_DELTA="asgard.message.delta",n.MESSAGE_COMPLETE="asgard.message.complete",n.MESSAGE_USER="asgard.message.user",n.MESSAGE_THINKING_START="asgard.message.thinking.start",n.MESSAGE_THINKING_DELTA="asgard.message.thinking.delta",n.MESSAGE_THINKING_COMPLETE="asgard.message.thinking.complete",n.TOOL_CALL="asgard.tool_call",n.TOOL_CALL_START="asgard.tool_call.start",n.TOOL_CALL_COMPLETE="asgard.tool_call.complete",n.TOOL_CALL_CONSENT="asgard.tool_call.consent",n.SUBAGENT_START="asgard.subagent.start",n.SUBAGENT_COMPLETE="asgard.subagent.complete",n.CHANNEL_TITLE_UPDATE="asgard.channel.title.update",n.SANDBOX_LAUNCH="asgard.sandbox.launch",n.SANDBOX_READY="asgard.sandbox.ready",n.DONE="asgard.run.done",n.ERROR="asgard.run.error",n))(d||{}),ve=(n=>(n.ALLOW_ONCE="ALLOW_ONCE",n.ALLOW_ALWAYS="ALLOW_ALWAYS",n.DENY_ONCE="DENY_ONCE",n))(ve||{}),be=(n=>(n.TEXT="TEXT",n.HINT="HINT",n.BUTTON="BUTTON",n.IMAGE="IMAGE",n.VIDEO="VIDEO",n.AUDIO="AUDIO",n.LOCATION="LOCATION",n.CAROUSEL="CAROUSEL",n.CHART="CHART",n.TABLE="TABLE",n.ATTACHMENT="ATTACHMENT",n))(be||{}),Q=function(n,t){return Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},Q(n,t)};function w(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Q(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function nt(n,t,e,r){function s(o){return o instanceof e?o:new e(function(i){i(o)})}return new(e||(e=Promise))(function(o,i){function a(h){try{c(r.next(h))}catch(g){i(g)}}function u(h){try{c(r.throw(h))}catch(g){i(g)}}function c(h){h.done?o(h.value):s(h.value).then(a,u)}c((r=r.apply(n,t||[])).next())})}function ye(n,t){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(h){return u([c,h])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(e=0)),e;)try{if(r=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,s=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){e.label=c[1];break}if(c[0]===6&&e.label<o[1]){e.label=o[1],o=c;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(c);break}o[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(h){c=[6,h],s=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function k(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function j(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(i)throw i.error}}return o}function D(n,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||Array.prototype.slice.call(t))}function L(n){return this instanceof L?(this.v=n,this):new L(n)}function rt(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(l){return function(f){return Promise.resolve(f).then(l,g)}}function a(l,f){r[l]&&(s[l]=function(p){return new Promise(function(_,I){o.push([l,p,_,I])>1||u(l,p)})},f&&(s[l]=f(s[l])))}function u(l,f){try{c(r[l](f))}catch(p){b(o[0][3],p)}}function c(l){l.value instanceof L?Promise.resolve(l.value.v).then(h,g):b(o[0][2],l)}function h(l){u("next",l)}function g(l){u("throw",l)}function b(l,f){l(f),o.shift(),o.length&&u(o[0][0],o[0][1])}}function st(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof k=="function"?k(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=n[o]&&function(i){return new Promise(function(a,u){i=n[o](i),s(a,u,i.done,i.value)})}}function s(o,i,a,u){Promise.resolve(u).then(function(c){o({value:c,done:a})},i)}}function m(n){return typeof n=="function"}function Se(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var z=Se(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
2
|
`+e.map(function(r,s){return s+1+") "+r.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function K(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var U=(function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=k(i),u=a.next();!u.done;u=a.next()){var c=u.value;c.remove(this)}}catch(p){t={error:p}}finally{try{u&&!u.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else i.remove(this);var h=this.initialTeardown;if(m(h))try{h()}catch(p){o=p instanceof z?p.errors:[p]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var b=k(g),l=b.next();!l.done;l=b.next()){var f=l.value;try{ie(f)}catch(p){o=o??[],p instanceof z?o=D(D([],j(o)),j(p.errors)):o.push(p)}}}catch(p){r={error:p}}finally{try{l&&!l.done&&(s=b.return)&&s.call(b)}finally{if(r)throw r.error}}}if(o)throw new z(o)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)ie(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&K(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&K(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=(function(){var t=new n;return t.closed=!0,t})(),n})(),Ee=U.EMPTY;function Ie(n){return n instanceof U||n&&"closed"in n&&m(n.remove)&&m(n.add)&&m(n.unsubscribe)}function ie(n){m(n)?n():n.unsubscribe()}var ot={Promise:void 0},it={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,D([n,t],j(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function we(n){it.setTimeout(function(){throw n})}function Z(){}function F(n){n()}var ne=(function(n){w(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,Ie(e)&&e.add(r)):r.destination=ut,r}return t.create=function(e,r,s){return new ee(e,r,s)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(U),at=(function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){G(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){G(r)}else G(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){G(e)}},n})(),ee=(function(n){w(t,n);function t(e,r,s){var o=n.call(this)||this,i;return m(e)||!e?i={next:e??void 0,error:r??void 0,complete:s??void 0}:i=e,o.destination=new at(i),o}return t})(ne);function G(n){we(n)}function ct(n){throw n}var ut={closed:!0,next:Z,error:ct,complete:Z},re=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function V(n){return n}function lt(n){return n.length===0?V:n.length===1?n[0]:function(e){return n.reduce(function(r,s){return s(r)},e)}}var S=(function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var s=this,o=ht(t)?t:new ee(t,e,r);return F(function(){var i=s,a=i.operator,u=i.source;o.add(a?a.call(o,u):u?s._subscribe(o):s._trySubscribe(o))}),o},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=ae(e),new e(function(s,o){var i=new ee({next:function(a){try{t(a)}catch(u){o(u),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[re]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return lt(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=ae(t),new t(function(r,s){var o;e.subscribe(function(i){return o=i},function(i){return s(i)},function(){return r(o)})})},n.create=function(t){return new n(t)},n})();function ae(n){var t;return(t=n??ot.Promise)!==null&&t!==void 0?t:Promise}function dt(n){return n&&m(n.next)&&m(n.error)&&m(n.complete)}function ht(n){return n&&n instanceof ne||dt(n)&&Ie(n)}function ft(n){return m(n?.lift)}function A(n){return function(t){if(ft(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function O(n,t,e,r,s){return new pt(n,t,e,r,s)}var pt=(function(n){w(t,n);function t(e,r,s,o,i,a){var u=n.call(this,e)||this;return u.onFinalize=i,u.shouldUnsubscribe=a,u._next=r?function(c){try{r(c)}catch(h){e.error(h)}}:n.prototype._next,u._error=o?function(c){try{o(c)}catch(h){e.error(h)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=s?function(){try{s()}catch(c){e.error(c)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t})(ne),gt=Se(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),se=(function(n){w(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new ce(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new gt},t.prototype.next=function(e){var r=this;F(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=k(r.currentObservers),a=i.next();!a.done;a=i.next()){var u=a.value;u.next(e)}}catch(c){s={error:c}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(e){var r=this;F(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var s=r.observers;s.length;)s.shift().error(e)}})},t.prototype.complete=function(){var e=this;F(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var r=this,s=this,o=s.hasError,i=s.isStopped,a=s.observers;return o||i?Ee:(this.currentObservers=null,a.push(e),new U(function(){r.currentObservers=null,K(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?e.error(o):i&&e.complete()},t.prototype.asObservable=function(){var e=new S;return e.source=this,e},t.create=function(e,r){return new ce(e,r)},t})(S),ce=(function(n){w(t,n);function t(e,r){var s=n.call(this)||this;return s.destination=e,s.source=r,s}return t.prototype.next=function(e){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,e)},t.prototype.error=function(e){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,e)},t.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},t.prototype._subscribe=function(e){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&s!==void 0?s:Ee},t})(se),P=(function(n){w(t,n);function t(e){var r=n.call(this)||this;return r._value=e,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var r=n.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},t.prototype.getValue=function(){var e=this,r=e.hasError,s=e.thrownError,o=e._value;if(r)throw s;return this._throwIfClosed(),o},t.prototype.next=function(e){n.prototype.next.call(this,this._value=e)},t})(se),mt={now:function(){return Date.now()}},vt=(function(n){w(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t})(U),ue={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,D([n,t],j(e)))},clearInterval:function(n){return clearInterval(n)},delegate:void 0},bt=(function(n){w(t,n);function t(e,r){var s=n.call(this,e,r)||this;return s.scheduler=e,s.work=r,s.pending=!1,s}return t.prototype.schedule=function(e,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var o=this.id,i=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(i,o,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(e,r,s){return s===void 0&&(s=0),ue.setInterval(e.flush.bind(e,this),s)},t.prototype.recycleAsyncId=function(e,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&ue.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(e,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var s=!1,o;try{this.work(e)}catch(i){s=!0,o=i||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,s=e.scheduler,o=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,K(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t})(vt),le=(function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},n.now=mt.now,n})(),yt=(function(n){w(t,n);function t(e,r){r===void 0&&(r=le.now);var s=n.call(this,e,r)||this;return s.actions=[],s._active=!1,s}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var s;this._active=!0;do if(s=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,s){for(;e=r.shift();)e.unsubscribe();throw s}},t})(le),Te=new yt(bt),St=Te,Et=new S(function(n){return n.complete()});function Ce(n){return n&&m(n.schedule)}function Oe(n){return n[n.length-1]}function It(n){return m(Oe(n))?n.pop():void 0}function Ae(n){return Ce(Oe(n))?n.pop():void 0}var _e=(function(n){return n&&typeof n.length=="number"&&typeof n!="function"});function xe(n){return m(n?.then)}function Me(n){return m(n[re])}function Pe(n){return Symbol.asyncIterator&&m(n?.[Symbol.asyncIterator])}function Le(n){return new TypeError("You provided "+(n!==null&&typeof n=="object"?"an invalid object":"'"+n+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function wt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ke=wt();function Ne(n){return m(n?.[ke])}function Ue(n){return rt(this,arguments,function(){var e,r,s,o;return ye(this,function(i){switch(i.label){case 0:e=n.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,L(e.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,L(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,L(s)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Re(n){return m(n?.getReader)}function M(n){if(n instanceof S)return n;if(n!=null){if(Me(n))return Tt(n);if(_e(n))return Ct(n);if(xe(n))return Ot(n);if(Pe(n))return $e(n);if(Ne(n))return At(n);if(Re(n))return _t(n)}throw Le(n)}function Tt(n){return new S(function(t){var e=n[re]();if(m(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Ct(n){return new S(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function Ot(n){return new S(function(t){n.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,we)})}function At(n){return new S(function(t){var e,r;try{for(var s=k(n),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(a){e={error:a}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}t.complete()})}function $e(n){return new S(function(t){xt(n,t).catch(function(e){return t.error(e)})})}function _t(n){return $e(Ue(n))}function xt(n,t){var e,r,s,o;return nt(this,void 0,void 0,function(){var i,a;return ye(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),e=st(n),u.label=1;case 1:return[4,e.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),s={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=e.return)?[4,o.call(e)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function C(n,t,e,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){e(),s?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(o),!s)return o}function je(n,t){return t===void 0&&(t=0),A(function(e,r){e.subscribe(O(r,function(s){return C(r,n,function(){return r.next(s)},t)},function(){return C(r,n,function(){return r.complete()},t)},function(s){return C(r,n,function(){return r.error(s)},t)}))})}function De(n,t){return t===void 0&&(t=0),A(function(e,r){r.add(n.schedule(function(){return e.subscribe(r)},t))})}function Mt(n,t){return M(n).pipe(De(t),je(t))}function Pt(n,t){return M(n).pipe(De(t),je(t))}function Lt(n,t){return new S(function(e){var r=0;return t.schedule(function(){r===n.length?e.complete():(e.next(n[r++]),e.closed||this.schedule())})})}function kt(n,t){return new S(function(e){var r;return C(e,t,function(){r=n[ke](),C(e,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(a){e.error(a);return}i?e.complete():e.next(o)},0,!0)}),function(){return m(r?.return)&&r.return()}})}function He(n,t){if(!n)throw new Error("Iterable cannot be null");return new S(function(e){C(e,t,function(){var r=n[Symbol.asyncIterator]();C(e,t,function(){r.next().then(function(s){s.done?e.complete():e.next(s.value)})},0,!0)})})}function Nt(n,t){return He(Ue(n),t)}function Ut(n,t){if(n!=null){if(Me(n))return Mt(n,t);if(_e(n))return Lt(n,t);if(xe(n))return Pt(n,t);if(Pe(n))return He(n,t);if(Ne(n))return kt(n,t);if(Re(n))return Nt(n,t)}throw Le(n)}function oe(n,t){return t?Ut(n,t):M(n)}function Rt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ae(n);return oe(n,e)}function $t(n){return n instanceof Date&&!isNaN(n)}function N(n,t){return A(function(e,r){var s=0;e.subscribe(O(r,function(o){r.next(n.call(t,o,s++))}))})}var jt=Array.isArray;function Dt(n,t){return jt(t)?n.apply(void 0,D([],j(t))):n(t)}function Ht(n){return N(function(t){return Dt(n,t)})}var Gt=Array.isArray,Ft=Object.getPrototypeOf,Kt=Object.prototype,Bt=Object.keys;function qt(n){if(n.length===1){var t=n[0];if(Gt(t))return{args:t,keys:null};if(Yt(t)){var e=Bt(t);return{args:e.map(function(r){return t[r]}),keys:e}}}return{args:n,keys:null}}function Yt(n){return n&&typeof n=="object"&&Ft(n)===Kt}function Vt(n,t){return n.reduce(function(e,r,s){return e[r]=t[s],e},{})}function Xt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ae(n),r=It(n),s=qt(n),o=s.args,i=s.keys;if(o.length===0)return oe([],e);var a=new S(Wt(o,e,i?function(u){return Vt(i,u)}:V));return r?a.pipe(Ht(r)):a}function Wt(n,t,e){return e===void 0&&(e=V),function(r){de(t,function(){for(var s=n.length,o=new Array(s),i=s,a=s,u=function(h){de(t,function(){var g=oe(n[h],t),b=!1;g.subscribe(O(r,function(l){o[h]=l,b||(b=!0,a--),a||r.next(e(o.slice()))},function(){--i||r.complete()}))},r)},c=0;c<s;c++)u(c)},r)}}function de(n,t,e){n?C(e,n,t):t()}function zt(n,t,e,r,s,o,i,a){var u=[],c=0,h=0,g=!1,b=function(){g&&!u.length&&!c&&t.complete()},l=function(p){return c<r?f(p):u.push(p)},f=function(p){c++;var _=!1;M(e(p,h++)).subscribe(O(t,function(E){t.next(E)},function(){_=!0},void 0,function(){if(_)try{c--;for(var E=function(){var x=u.shift();i||f(x)};u.length&&c<r;)E();b()}catch(x){t.error(x)}}))};return n.subscribe(O(t,l,function(){g=!0,b()})),function(){}}function B(n,t,e){return e===void 0&&(e=1/0),m(t)?B(function(r,s){return N(function(o,i){return t(r,o,s,i)})(M(n(r,s)))},e):(typeof t=="number"&&(e=t),A(function(r,s){return zt(r,s,n,e)}))}function Jt(n,t,e){n===void 0&&(n=0),e===void 0&&(e=St);var r=-1;return t!=null&&(Ce(t)?e=t:r=t),new S(function(s){var o=$t(n)?+n-e.now():n;o<0&&(o=0);var i=0;return e.schedule(function(){s.closed||(s.next(i++),0<=r?this.schedule(void 0,r):s.complete())},o)})}function Qt(n,t){return m(t)?B(n,t,1):B(n,1)}function Zt(n){return n<=0?function(){return Et}:A(function(t,e){var r=0;t.subscribe(O(e,function(s){++r<=n&&(e.next(s),n<=r&&e.complete())}))})}function en(n){return N(function(){return n})}function tn(n,t){return B(function(e,r){return M(n(e,r)).pipe(Zt(1),en(e))})}function nn(n,t){t===void 0&&(t=Te);var e=Jt(n,t);return tn(function(){return e})}function q(n,t){return t===void 0&&(t=V),n=n??rn,A(function(e,r){var s,o=!0;e.subscribe(O(r,function(i){var a=t(i);(o||!n(s,a))&&(o=!1,s=a,r.next(i))}))})}function rn(n,t){return n===t}function sn(n){return A(function(t,e){try{t.subscribe(e)}finally{e.add(n)}})}function on(n){return A(function(t,e){M(n).subscribe(O(e,function(){return e.complete()},Z)),!e.closed&&t.subscribe(e)})}async function an(n,t){const e=n.getReader();let r;for(;!(r=await e.read()).done;)t(r.value)}function cn(n){let t,e,r,s=!1;return function(i){t===void 0?(t=i,e=0,r=-1):t=ln(t,i);const a=t.length;let u=0;for(;e<a;){s&&(t[e]===10&&(u=++e),s=!1);let c=-1;for(;e<a&&c===-1;++e)switch(t[e]){case 58:r===-1&&(r=e-u);break;case 13:s=!0;case 10:c=e;break}if(c===-1)break;n(t.subarray(u,c),r),u=e,r=-1}u===a?t=void 0:u!==0&&(t=t.subarray(u),e-=u)}}function un(n,t,e){let r=he();const s=new TextDecoder;return function(i,a){if(i.length===0)e?.(r),r=he();else if(a>0){const u=s.decode(i.subarray(0,a)),c=a+(i[a+1]===32?2:1),h=s.decode(i.subarray(c));switch(u){case"data":r.data=r.data?r.data+`
|
|
4
|
-
`+h:h;break;case"event":r.event=h;break;case"id":n(r.id=h);break;case"retry":const g=parseInt(h,10);isNaN(g)||t(r.retry=g);break}}}}function ln(n,t){const e=new Uint8Array(n.length+t.length);return e.set(n),e.set(t,n.length),e}function he(){return{data:"",event:"",id:"",retry:void 0}}var dn=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(e[r[s]]=n[r[s]]);return e};const te="text/event-stream",hn=1e3,fe="last-event-id";function fn(n,t){var{signal:e,headers:r,onopen:s,onmessage:o,onclose:i,onerror:a,openWhenHidden:u,fetch:c}=t,h=dn(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((g,b)=>{const l=Object.assign({},r);l.accept||(l.accept=te);let f;function p(){f.abort(),document.hidden||X()}u||document.addEventListener("visibilitychange",p);let _=hn,E=0;function x(){document.removeEventListener("visibilitychange",p),window.clearTimeout(E),f.abort()}e?.addEventListener("abort",()=>{x(),g()});const Ze=c??window.fetch,et=s??pn;async function X(){var W;f=new AbortController;try{const H=await Ze(n,Object.assign(Object.assign({},h),{headers:l,signal:f.signal}));await et(H),await an(H.body,cn(un(T=>{T?l[fe]=T:delete l[fe]},T=>{_=T},o))),i?.(),x(),g()}catch(H){if(!f.signal.aborted)try{const T=(W=a?.(H))!==null&&W!==void 0?W:_;window.clearTimeout(E),E=window.setTimeout(X,T)}catch(T){x(),b(T)}}}X()})}function pn(n){const t=n.headers.get("content-type");if(!t?.startsWith(te))throw new Error(`Expected content-type to be ${te}, Actual: ${t}`)}function pe(n){const{endpoint:t,apiKey:e,payload:r,debugMode:s,customHeaders:o}=n,i=n.method??"POST";return new S(a=>{const u=new AbortController;let c,h=!1;const g={"Content-Type":"application/json",...o};e&&(g["X-API-KEY"]=e);const b=new URL(t);return s&&b.searchParams.set("is_debug","true"),fn(b.toString(),{method:i,headers:g,body:i==="POST"&&r?JSON.stringify(r):void 0,signal:u.signal,openWhenHidden:!0,onopen:async l=>{if(l.ok)c=l.headers.get("X-Trace-Id")??void 0;else{let f;try{f=await l.json()}catch{try{f=await l.text()}catch{f=null}}a.error(new Y(l.status,l.statusText,f)),u.abort()}},onmessage:l=>{l.id&&(h=!0);const f=JSON.parse(l.data);c?f.traceId=c:f.requestId&&(f.traceId=f.requestId,c||(c=f.requestId)),a.next(f)},onclose:()=>{a.complete()},onerror:l=>{if(!h)throw a.error(l),u.abort(),l}}),()=>{u.abort()}})}class gn{listeners={};on(t,e){this.listeners=Object.assign({},this.listeners,{[t]:(this.listeners[t]??[]).concat(e)})}off(t,e){this.listeners[t]&&(this.listeners=Object.assign({},this.listeners,{[t]:(this.listeners[t]??[]).filter(r=>r!==e)}))}remove(t){delete this.listeners[t]}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(r=>r(...e))}}class mn{apiKey;endpoint;botProviderEndpoint;debugMode;destroy$=new se;closed=!1;detached=!1;detachTimer;inFlight=0;sseEmitter=new gn;transformSsePayload;customHeaders;constructor(t){if(!t.endpoint&&!t.botProviderEndpoint)throw new Error("Either endpoint or botProviderEndpoint must be provided");if(this.apiKey=t.apiKey,this.debugMode=t.debugMode,this.transformSsePayload=t.transformSsePayload,this.botProviderEndpoint=t.botProviderEndpoint,this.customHeaders={...t.customHeaders,...t.userIdentityHint?{"X-ASGARD-USER-IDENTITY-HINT":t.userIdentityHint}:{}},!t.endpoint&&t.botProviderEndpoint){const e=t.botProviderEndpoint.replace(/\/+$/,"");this.endpoint=`${e}/message/sse`}else t.endpoint&&(this.endpoint=t.endpoint,this.debugMode&&console.warn('[AsgardServiceClient] The "endpoint" option is deprecated and will be removed in the next major version. Please use "botProviderEndpoint" instead. The SSE endpoint will be automatically derived as "${botProviderEndpoint}/message/sse".'))}on(t,e){this.sseEmitter.remove(t),this.sseEmitter.on(t,e)}handleEvent(t){switch(t.eventType){case d.INIT:this.sseEmitter.emit(d.INIT,t);break;case d.PROCESS_START:case d.PROCESS_COMPLETE:this.sseEmitter.emit(d.PROCESS,t);break;case d.MESSAGE_START:case d.MESSAGE_DELTA:case d.MESSAGE_COMPLETE:this.sseEmitter.emit(d.MESSAGE,t);break;case d.TOOL_CALL_START:case d.TOOL_CALL_COMPLETE:this.sseEmitter.emit(d.TOOL_CALL,t);break;case d.TOOL_CALL_CONSENT:this.sseEmitter.emit(d.TOOL_CALL_CONSENT,t);break;case d.DONE:this.sseEmitter.emit(d.DONE,t);break;case d.ERROR:this.sseEmitter.emit(d.ERROR,t);break}}fetchSse(t,e){return e?.onSseStart?.(),this.inFlight+=1,this.runSse(pe({apiKey:this.apiKey,endpoint:this.endpoint,debugMode:this.debugMode,payload:this.transformSsePayload?.(t)??t,customHeaders:this.customHeaders}),e)}rejoinSse(t,e){e?.onSseStart?.(),this.inFlight+=1;const r=new URL(this.endpoint);return r.searchParams.set("custom_channel_id",t),this.runSse(pe({apiKey:this.apiKey,endpoint:r.toString(),debugMode:this.debugMode,method:"GET",customHeaders:this.customHeaders}),e)}deriveChannelMetadataEndpoint(){const t=this.getBaseEndpoint();return t?`${t}/channel/metadata`:null}async channelMetadata(t){const e=this.deriveChannelMetadataEndpoint();if(!e)throw new Error("Unable to derive channel metadata endpoint. Please provide botProviderEndpoint in config.");const r=new URL(e);r.searchParams.set("custom_channel_id",t);const s={...this.customHeaders};this.apiKey&&(s["X-API-KEY"]=this.apiKey);const o=await fetch(r.toString(),{method:"GET",headers:s});if(o.status===404)return null;if(!o.ok)throw new Y(o.status,o.statusText,await o.text().catch(()=>{}));const i=await o.json(),a=i.data??i;return{title:a.title??null,runState:a.runState??"IDLE",lastActivityAt:a.lastActivityAt}}runSse(t,e){return t.pipe(Qt(r=>Rt(r).pipe(nn(e?.delayTime??50))),on(this.destroy$),sn(()=>this.onRunSettled())).subscribe({next:r=>{this.detached||(e?.onSseMessage?.(r),this.handleEvent(r))},error:r=>{this.detached||e?.onSseError?.(r)},complete:()=>{this.detached||e?.onSseCompleted?.()}})}detach(t){if(!(this.detached||this.closed)){if(this.detached=!0,this.inFlight===0){this.close();return}this.detachTimer=setTimeout(()=>this.close(),t.timeoutMs)}}onRunSettled(){this.inFlight=Math.max(0,this.inFlight-1),this.detached&&this.inFlight===0&&this.close()}close(){this.closed||(this.closed=!0,this.detachTimer&&(clearTimeout(this.detachTimer),this.detachTimer=void 0),this.destroy$.next(),this.destroy$.complete())}async uploadFile(t,e){const r=this.deriveBlobEndpoint();if(!r)throw new Error("Unable to derive blob endpoint. Please provide botProviderEndpoint in config.");const s=new FormData;s.append("file",t),s.append("customChannelId",e);const o={...this.customHeaders};this.apiKey&&(o["X-API-KEY"]=this.apiKey);try{const i=await fetch(r,{method:"POST",headers:o,body:s});if(!i.ok)throw new Error(`Upload failed: ${i.status} ${i.statusText}`);const a=await i.json();return this.debugMode&&console.log("[AsgardServiceClient] File upload response:",a),a}catch(i){throw console.error("[AsgardServiceClient] File upload error:",i),i}}async downloadChannelHomeFile(t,e){const r=this.getBaseEndpoint();if(!r)throw new Error("Unable to derive channel-home download endpoint. Please provide botProviderEndpoint in config.");const s=`custom_channel_id=${encodeURIComponent(e)}&relative_path=${encodeURIComponent(t)}`,o=`${r}/channel-home/download?${s}`,i={...this.customHeaders};this.apiKey&&(i["X-API-KEY"]=this.apiKey);try{const a=await fetch(o,{method:"GET",headers:i});if(!a.ok)throw new Error(`Channel Home download failed: ${a.status} ${a.statusText}`);const u=await a.blob(),c=t.split("/").pop()||"download";return this.debugMode&&console.log("[AsgardServiceClient] Channel Home download response:",{filename:c,size:u.size}),{blob:u,filename:c}}catch(a){throw console.error("[AsgardServiceClient] Channel Home download error:",a),a}}deriveBlobEndpoint(){const t=this.getBaseEndpoint();return t?`${t}/blob`:null}getBaseEndpoint(){let t=this.botProviderEndpoint;return!t&&this.endpoint&&(t=this.endpoint.replace("/message/sse","")),t?t.replace(/\/+$/,""):null}}const y=[];for(let n=0;n<256;++n)y.push((n+256).toString(16).slice(1));function vn(n,t=0){return(y[n[t+0]]+y[n[t+1]]+y[n[t+2]]+y[n[t+3]]+"-"+y[n[t+4]]+y[n[t+5]]+"-"+y[n[t+6]]+y[n[t+7]]+"-"+y[n[t+8]]+y[n[t+9]]+"-"+y[n[t+10]]+y[n[t+11]]+y[n[t+12]]+y[n[t+13]]+y[n[t+14]]+y[n[t+15]]).toLowerCase()}let J;const bn=new Uint8Array(16);function yn(){if(!J){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");J=crypto.getRandomValues.bind(crypto)}return J(bn)}const Sn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ge={randomUUID:Sn};function En(n,t,e){n=n||{};const r=n.random??n.rng?.()??yn();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,vn(r)}function Ge(n,t,e){return ge.randomUUID&&!n?ge.randomUUID():En(n)}class v{messages=null;pendingConsent=null;constructor({messages:t,pendingConsent:e=null}){this.messages=t,this.pendingConsent=e??null}pushMessage(t){const e=new Map(this.messages);return e.set(t.messageId,t),new v({messages:e,pendingConsent:this.pendingConsent})}clearPendingConsent(){return this.pendingConsent?new v({messages:this.messages,pendingConsent:null}):this}cancelInFlightToolCalls(){if(!this.messages)return this;let t=!1;const e=new Map(this.messages);for(const[r,s]of e)s.type==="tool-call"&&!s.isComplete&&(e.set(r,{...s,isComplete:!0,isCancelled:!0}),t=!0);return t?new v({messages:e,pendingConsent:this.pendingConsent}):this}onMessage(t){switch(t.eventType){case d.MESSAGE_START:return this.onMessageStart(t);case d.MESSAGE_DELTA:return this.onMessageDelta(t);case d.MESSAGE_COMPLETE:return this.onMessageComplete(t);case d.MESSAGE_USER:return this.onMessageUser(t);case d.MESSAGE_THINKING_START:return this.onThinkingStart(t);case d.MESSAGE_THINKING_DELTA:return this.onThinkingDelta(t);case d.MESSAGE_THINKING_COMPLETE:return this.onThinkingComplete(t);case d.TOOL_CALL_START:return this.onToolCallStart(t);case d.TOOL_CALL_COMPLETE:return this.onToolCallComplete(t);case d.TOOL_CALL_CONSENT:return this.onToolCallConsent(t);case d.SUBAGENT_START:return this.onSubagentStart(t);case d.SUBAGENT_COMPLETE:return this.onSubagentComplete(t);case d.ERROR:return this.onMessageError(t);default:return this}}isTerminalBot(t){return t?.type==="bot"&&!t.isTyping}isTerminalThinking(t){return t?.type==="thinking"&&!t.isThinking}onMessageStart(t){const e=t.fact.messageStart.message;if(this.isTerminalBot(this.messages?.get(e.messageId)))return this;const r=new Map(this.messages);return r.set(e.messageId,{type:"bot",eventType:d.MESSAGE_START,isTyping:!0,typingText:"",messageId:e.messageId,message:e,time:new Date,traceId:t.traceId,raw:""}),new v({messages:r,pendingConsent:this.pendingConsent})}onMessageDelta(t){const e=t.fact.messageDelta.message,r=this.messages?.get(e.messageId);if(this.isTerminalBot(r))return this;const s=r?.type==="bot"?r:void 0,o=new Map(this.messages);return o.set(e.messageId,{type:"bot",eventType:d.MESSAGE_DELTA,isTyping:!0,typingText:`${s?.typingText??""}${e.text}`,messageId:e.messageId,message:e,time:new Date,traceId:t.traceId??s?.traceId,raw:s?.raw??""}),new v({messages:o,pendingConsent:this.pendingConsent})}onMessageComplete(t){const e=t.fact.messageComplete.message,r=new Map(this.messages),s=r.get(e.messageId);return r.set(e.messageId,{type:"bot",eventType:d.MESSAGE_COMPLETE,isTyping:!1,typingText:null,messageId:e.messageId,message:e,time:new Date,traceId:t.traceId??(s?.type==="bot"?s.traceId:void 0),raw:JSON.stringify(t)}),new v({messages:r,pendingConsent:this.pendingConsent})}onThinkingStart(t){const e=t.fact.messageThinkingStart.message;if(this.isTerminalThinking(this.messages?.get(e.messageId)))return this;const r=new Map(this.messages),s={type:"thinking",messageId:e.messageId,text:e.text,isThinking:!0,time:new Date,traceId:t.traceId};return r.set(e.messageId,s),new v({messages:r,pendingConsent:this.pendingConsent})}onThinkingDelta(t){const e=t.fact.messageThinkingDelta.message,r=this.messages?.get(e.messageId);if(this.isTerminalThinking(r))return this;const s=r?.type==="thinking"?r:void 0,o=new Map(this.messages),i={type:"thinking",messageId:e.messageId,text:`${s?.text??""}${e.text}`,isThinking:!0,time:s?.time??new Date,traceId:t.traceId??s?.traceId};return o.set(e.messageId,i),new v({messages:o,pendingConsent:this.pendingConsent})}onThinkingComplete(t){const e=t.fact.messageThinkingComplete.message,r=this.messages?.get(e.messageId),s=r?.type==="thinking"?r:void 0,o=new Map(this.messages),i={type:"thinking",messageId:e.messageId,text:e.text,isThinking:!1,time:s?.time??new Date,traceId:t.traceId??s?.traceId};return o.set(e.messageId,i),new v({messages:o,pendingConsent:this.pendingConsent})}onMessageUser(t){const e=t.fact.messageUser;if((this.messages?.get(e.messageId)??(e.customMessageId?this.messages?.get(e.customMessageId):void 0))?.type==="user")return this;const s=new Map(this.messages),o={type:"user",messageId:e.messageId,text:e.text,blobIds:e.blobIds,customMessageId:e.customMessageId,identityHint:e.identityHint,time:new Date,traceId:t.traceId};return s.set(e.messageId,o),new v({messages:s,pendingConsent:this.pendingConsent})}onMessageError(t){const e=Ge(),r=t.fact.runError.error,s=new Map(this.messages);return s.set(e,{type:"error",eventType:d.ERROR,messageId:e,error:r,time:new Date,traceId:t.traceId}),new v({messages:s,pendingConsent:this.pendingConsent})}onToolCallStart(t){const e=t.fact.toolCallStart,r=new Map(this.messages),s=`${e.processId}-${e.callSeq}`,o={type:"tool-call",eventType:d.TOOL_CALL_START,messageId:s,processId:e.processId,callSeq:e.callSeq,toolName:e.toolCall.toolName,reason:e.toolCall.reason,toolsetName:e.toolCall.toolsetName,parameter:e.toolCall.parameter,toolUseId:e.toolUseId,parentToolUseId:e.parentToolUseId,isComplete:!1,time:new Date,traceId:t.traceId};return r.set(s,o),new v({messages:r,pendingConsent:this.pendingConsent})}onToolCallComplete(t){const e=t.fact.toolCallComplete,r=new Map(this.messages),s=`${e.processId}-${e.callSeq}`,o=r.get(s);if(o?.type==="tool-call"){const i={...o,eventType:d.TOOL_CALL_COMPLETE,result:e.toolCallResult,isError:e.isError,sidecar:e.toolUseResultSidecar,isComplete:!0,traceId:t.traceId??o.traceId};r.set(s,i)}return new v({messages:r,pendingConsent:this.pendingConsent})}onToolCallConsent(t){const e=t.fact.toolCallConsent;return new v({messages:this.messages,pendingConsent:e})}onSubagentStart(t){const e=t.fact.subagentStart,r=new Map(this.messages),s=`subagent:${e.parentToolUseId}:start`,o={type:"subagent",messageId:s,kind:"start",parentToolUseId:e.parentToolUseId,agentId:e.agentId,subagentType:e.subagentType,description:e.description,time:new Date,traceId:t.traceId};return r.set(s,o),new v({messages:r,pendingConsent:this.pendingConsent})}onSubagentComplete(t){const e=t.fact.subagentComplete,r=new Map(this.messages),s=`subagent:${e.parentToolUseId}:complete`,o={type:"subagent",messageId:s,kind:"complete",parentToolUseId:e.parentToolUseId,agentId:e.agentId,subagentType:e.subagentType,status:e.status,summary:e.summary,time:new Date,traceId:t.traceId};return r.set(s,o),new v({messages:r,pendingConsent:this.pendingConsent})}}const In=new Set(["TaskCreate","TaskUpdate"]);function Fe(n){return n.toolsetName===""&&In.has(n.toolName)}function me(n){return typeof n=="object"&&n!==null?n:void 0}function I(n){return typeof n=="string"?n:void 0}function Ke(n){const t=[],e=new Map;for(const r of n){const s=r.parameter??{},o=r.sidecar??{};if(r.toolName==="TaskCreate"){const i=me(o.task),a=I(i?.id);if(!a)continue;e.has(a)||t.push(a),e.set(a,{id:a,subject:I(s.subject)||I(i?.subject)||"",activeForm:I(s.activeForm),description:I(s.description),status:e.get(a)?.status??"pending"})}else if(r.toolName==="TaskUpdate"){const i=me(o.statusChange),a=I(s.taskId)||I(o.taskId),u=I(i?.to)||I(s.status);if(!a||!u)continue;const c=e.get(a);c&&e.set(a,{...c,status:u})}}return t.map(r=>e.get(r))}function Be(n){return n.toolsetName===""&&n.toolName==="Agent"}function qe(n){return!!n}function Ye(n){const t=[],e=new Map,r=new Map,s=o=>(e.has(o)||(t.push(o),e.set(o,{status:"running"}),r.set(o,new Map)),e.get(o));for(const o of n)switch(o.kind){case"agentStart":{const i=s(o.toolUseId);o.description&&!i.description&&(i.description=o.description);break}case"subagentStart":{const i=s(o.parentToolUseId);i.agentId=o.agentId??i.agentId,i.subagentType=o.subagentType??i.subagentType,i.description=o.description??i.description;break}case"toolStart":{s(o.parentToolUseId),r.get(o.parentToolUseId).set(o.toolUseId,{toolsetName:o.toolsetName,toolName:o.toolName,parameter:o.parameter??{},reason:o.reason,status:"running"});break}case"toolComplete":{const i=r.get(o.parentToolUseId)?.get(o.toolUseId);i&&(i.status=o.isError?"error":"completed");break}case"subagentComplete":{const i=s(o.parentToolUseId);i.status=o.status,i.summary=o.summary;break}}return t.map(o=>({parentToolUseId:o,...e.get(o),tools:Array.from(r.get(o).values())}))}function wn(n){return typeof n=="string"?n:void 0}function Ve(n){const t=[];for(const e of n){if(e.type==="tool-call"&&Be(e)){t.push({kind:"agentStart",toolUseId:e.toolUseId??e.messageId,description:wn(e.parameter.description)});continue}if(e.type==="tool-call"&&qe(e.parentToolUseId)){const r=e.toolUseId??e.messageId;t.push({kind:"toolStart",parentToolUseId:e.parentToolUseId,toolUseId:r,toolsetName:e.toolsetName,toolName:e.toolName,parameter:e.parameter,reason:e.reason}),e.isComplete&&t.push({kind:"toolComplete",parentToolUseId:e.parentToolUseId,toolUseId:r,isError:e.isError});continue}if(e.type==="subagent"&&e.kind==="start"){t.push({kind:"subagentStart",parentToolUseId:e.parentToolUseId,agentId:e.agentId,subagentType:e.subagentType,description:e.description});continue}e.type==="subagent"&&e.kind==="complete"&&e.status&&t.push({kind:"subagentComplete",parentToolUseId:e.parentToolUseId,status:e.status,summary:e.summary})}return t}function Xe(n){const t=Array.from(n.messages?.values()??[]).filter(e=>e.type==="tool-call"&&e.isComplete&&Fe(e));return Ke(t)}function We(n){return Ye(Ve(Array.from(n.messages?.values()??[])))}function ze(n,t){return n===t?!0:n.length!==t.length?!1:n.every((e,r)=>{const s=t[r];return e.id===s.id&&e.status===s.status&&e.subject===s.subject&&e.activeForm===s.activeForm&&e.description===s.description})}function Tn(n,t){return n.length!==t.length?!1:n.every((e,r)=>{const s=t[r];return e.toolName===s.toolName&&e.toolsetName===s.toolsetName&&e.status===s.status&&e.reason===s.reason})}function Je(n,t){return n===t?!0:n.length!==t.length?!1:n.every((e,r)=>{const s=t[r];return e.parentToolUseId===s.parentToolUseId&&e.status===s.status&&e.subagentType===s.subagentType&&e.description===s.description&&e.summary===s.summary&&Tn(e.tools,s.tools)})}function Qe(n){const t=new P([]),e=new P([]),r=new U;return r.add(n.pipe(N(Xe),q(ze)).subscribe(t)),r.add(n.pipe(N(We),q(Je)).subscribe(e)),{tasks$:t.asObservable(),subagents$:e.asObservable(),getTasks:()=>t.value,getSubagents:()=>e.value,teardown:()=>r.unsubscribe()}}class ${client;customChannelId;customMessageId;isConnecting$;conversation$;channelTitleSubject;sandboxPhaseSubject;derivedStores;statesObserver;statesSubscription;tasks$;subagents$;channelTitle$;sandboxPhase$;currentUserMessageId;lastSentMessageId;currentRun;constructor(t){if(!t.client)throw new Error("client must be required");if(!t.customChannelId)throw new Error("customChannelId must be required");this.client=t.client,this.customChannelId=t.customChannelId,this.customMessageId=t.customMessageId,this.isConnecting$=new P(!1),this.conversation$=new P(t.conversation),this.channelTitleSubject=new P(t.channelTitle??null),this.sandboxPhaseSubject=new P("idle"),this.derivedStores=Qe(this.conversation$),this.tasks$=this.derivedStores.tasks$,this.subagents$=this.derivedStores.subagents$,this.channelTitle$=this.channelTitleSubject.pipe(q()),this.sandboxPhase$=this.sandboxPhaseSubject.pipe(q()),this.statesObserver=t.statesObserver}getTasks(){return this.derivedStores.getTasks()}getSubagents(){return this.derivedStores.getSubagents()}getChannelTitle(){return this.channelTitleSubject.value}getSandboxPhase(){return this.sandboxPhaseSubject.value}setChannelTitle(t){this.channelTitleSubject.next(t)}static create(t){const e=new $(t);return e.subscribe(),e}static async reset(t,e,r,s){const o=new $(t);try{return o.subscribe(),s?.(o),await o.resetChannel(e,r),o}catch(i){throw o.close(),i}}static async restore(t,e,r){const s=new $(t);try{return s.subscribe(),r?.(s),await s.rejoinChannel(e),s}catch(o){throw s.close(),o}}subscribe(){this.statesSubscription=Xt([this.isConnecting$,this.conversation$,this.derivedStores.tasks$,this.derivedStores.subagents$,this.channelTitle$,this.sandboxPhase$]).pipe(N(([t,e,r,s,o,i])=>({isConnecting:t,conversation:e,tasks:r,subagents:s,channelTitle:o,sandboxPhase:i}))).subscribe(this.statesObserver)}resolvePayload(t){if(typeof t=="function")try{return t()}catch(e){throw new Error(`Failed to resolve payload function: ${e instanceof Error?e.message:String(e)}`)}return t}updateSandboxPhase(t){switch(t){case d.SANDBOX_LAUNCH:this.sandboxPhaseSubject.next("launching");break;case d.SANDBOX_READY:this.sandboxPhaseSubject.next("ready");break;case d.INIT:case d.ERROR:this.sandboxPhaseSubject.next("idle");break}}buildRunHandlers(t,e,r){return{onSseStart:t?.onSseStart,onSseMessage:s=>{if(t?.onSseMessage?.(s),s.eventType===d.CHANNEL_TITLE_UPDATE&&this.channelTitleSubject.next(s.fact.channelTitleUpdate.title),this.updateSandboxPhase(s.eventType),this.currentUserMessageId&&s.traceId){const o=new Map(this.conversation$.value.messages),i=o.get(this.currentUserMessageId);i&&i.type==="user"&&(o.set(this.currentUserMessageId,{...i,traceId:s.traceId}),this.conversation$.next(new v({messages:o}))),this.currentUserMessageId=void 0}this.conversation$.next(this.conversation$.value.onMessage(s))},onSseError:s=>{t?.onSseError?.(s),this.isConnecting$.next(!1),this.currentUserMessageId=void 0,this.currentRun=void 0,r(s)},onSseCompleted:()=>{t?.onSseCompleted?.(),this.isConnecting$.next(!1),this.currentUserMessageId=void 0,this.currentRun=void 0,e()}}}fetchSse(t,e){return new Promise((r,s)=>{this.isConnecting$.next(!0),this.currentRun=this.client.fetchSse(t,this.buildRunHandlers(e,r,s))})}rejoinChannel(t){return new Promise((e,r)=>{if(!this.client.rejoinSse){e();return}this.isConnecting$.next(!0),this.currentRun=this.client.rejoinSse(this.customChannelId,this.buildRunHandlers(t,e,r))})}resetChannel(t,e){return this.fetchSse({action:R.RESET_CHANNEL,customChannelId:this.customChannelId,customMessageId:this.customMessageId,text:t?.text||"",payload:this.resolvePayload(t?.payload)},e)}sendMessage(t,e){const r=t.text.trim(),s=t.customMessageId??Ge();return this.currentUserMessageId=s,this.lastSentMessageId=s,this.conversation$.next(this.conversation$.value.pushMessage({type:"user",messageId:s,text:r,blobIds:t.blobIds,filePreviewUrls:t.filePreviewUrls,documentNames:t.documentNames,time:new Date})),this.fetchSse({action:R.NONE,customChannelId:this.customChannelId,customMessageId:s,payload:this.resolvePayload(t?.payload),text:r,blobIds:t?.blobIds},e)}replyToolCallConsents(t,e,r){return this.conversation$.next(this.conversation$.value.clearPendingConsent()),this.fetchSse({action:R.RESPONSE_TOOL_CALL_CONSENT,customChannelId:this.customChannelId,customMessageId:this.lastSentMessageId??this.customMessageId,payload:this.resolvePayload(r),text:"",toolCallConsents:t},e)}stopGeneration(){this.currentRun&&(this.currentRun.unsubscribe(),this.currentRun=void 0,this.isConnecting$.next(!1),this.currentUserMessageId=void 0,this.conversation$.next(this.conversation$.value.cancelInFlightToolCalls()))}close(){this.currentRun?.unsubscribe(),this.currentRun=void 0,this.isConnecting$.complete(),this.conversation$.complete(),this.channelTitleSubject.complete(),this.sandboxPhaseSubject.complete(),this.derivedStores.teardown(),this.statesSubscription?.unsubscribe()}}exports.AsgardServiceClient=mn;exports.Channel=$;exports.Conversation=v;exports.EventType=d;exports.FetchSseAction=R;exports.HttpError=Y;exports.MessageTemplateType=be;exports.ToolCallConsentResult=ve;exports.conversationToSubagentEvents=Ve;exports.createDerivedStores=Qe;exports.deriveSubagents=We;exports.deriveTasks=Xe;exports.isAgentTool=Be;exports.isHttpError=tt;exports.isSubagentChildTool=qe;exports.isTaskTool=Fe;exports.reduceSubagents=Ye;exports.reduceTaskEvents=Ke;exports.subagentsEqual=Je;exports.tasksEqual=ze;
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function K(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var N=(function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=k(i),u=a.next();!u.done;u=a.next()){var c=u.value;c.remove(this)}}catch(p){t={error:p}}finally{try{u&&!u.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else i.remove(this);var h=this.initialTeardown;if(m(h))try{h()}catch(p){o=p instanceof z?p.errors:[p]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var b=k(g),l=b.next();!l.done;l=b.next()){var f=l.value;try{ie(f)}catch(p){o=o??[],p instanceof z?o=D(D([],j(o)),j(p.errors)):o.push(p)}}}catch(p){r={error:p}}finally{try{l&&!l.done&&(s=b.return)&&s.call(b)}finally{if(r)throw r.error}}}if(o)throw new z(o)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)ie(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&K(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&K(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=(function(){var t=new n;return t.closed=!0,t})(),n})(),Ie=N.EMPTY;function Ee(n){return n instanceof N||n&&"closed"in n&&m(n.remove)&&m(n.add)&&m(n.unsubscribe)}function ie(n){m(n)?n():n.unsubscribe()}var ot={Promise:void 0},it={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,D([n,t],j(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function we(n){it.setTimeout(function(){throw n})}function Z(){}function F(n){n()}var ne=(function(n){w(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,Ee(e)&&e.add(r)):r.destination=ut,r}return t.create=function(e,r,s){return new ee(e,r,s)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(N),at=(function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){G(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){G(r)}else G(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){G(e)}},n})(),ee=(function(n){w(t,n);function t(e,r,s){var o=n.call(this)||this,i;return m(e)||!e?i={next:e??void 0,error:r??void 0,complete:s??void 0}:i=e,o.destination=new at(i),o}return t})(ne);function G(n){we(n)}function ct(n){throw n}var ut={closed:!0,next:Z,error:ct,complete:Z},re=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function V(n){return n}function lt(n){return n.length===0?V:n.length===1?n[0]:function(e){return n.reduce(function(r,s){return s(r)},e)}}var S=(function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var s=this,o=ht(t)?t:new ee(t,e,r);return F(function(){var i=s,a=i.operator,u=i.source;o.add(a?a.call(o,u):u?s._subscribe(o):s._trySubscribe(o))}),o},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=ae(e),new e(function(s,o){var i=new ee({next:function(a){try{t(a)}catch(u){o(u),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[re]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return lt(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=ae(t),new t(function(r,s){var o;e.subscribe(function(i){return o=i},function(i){return s(i)},function(){return r(o)})})},n.create=function(t){return new n(t)},n})();function ae(n){var t;return(t=n??ot.Promise)!==null&&t!==void 0?t:Promise}function dt(n){return n&&m(n.next)&&m(n.error)&&m(n.complete)}function ht(n){return n&&n instanceof ne||dt(n)&&Ee(n)}function ft(n){return m(n?.lift)}function A(n){return function(t){if(ft(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function O(n,t,e,r,s){return new pt(n,t,e,r,s)}var pt=(function(n){w(t,n);function t(e,r,s,o,i,a){var u=n.call(this,e)||this;return u.onFinalize=i,u.shouldUnsubscribe=a,u._next=r?function(c){try{r(c)}catch(h){e.error(h)}}:n.prototype._next,u._error=o?function(c){try{o(c)}catch(h){e.error(h)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=s?function(){try{s()}catch(c){e.error(c)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t})(ne),gt=Se(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),se=(function(n){w(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new ce(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new gt},t.prototype.next=function(e){var r=this;F(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=k(r.currentObservers),a=i.next();!a.done;a=i.next()){var u=a.value;u.next(e)}}catch(c){s={error:c}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(e){var r=this;F(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var s=r.observers;s.length;)s.shift().error(e)}})},t.prototype.complete=function(){var e=this;F(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var r=this,s=this,o=s.hasError,i=s.isStopped,a=s.observers;return o||i?Ie:(this.currentObservers=null,a.push(e),new N(function(){r.currentObservers=null,K(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?e.error(o):i&&e.complete()},t.prototype.asObservable=function(){var e=new S;return e.source=this,e},t.create=function(e,r){return new ce(e,r)},t})(S),ce=(function(n){w(t,n);function t(e,r){var s=n.call(this)||this;return s.destination=e,s.source=r,s}return t.prototype.next=function(e){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,e)},t.prototype.error=function(e){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,e)},t.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},t.prototype._subscribe=function(e){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&s!==void 0?s:Ie},t})(se),P=(function(n){w(t,n);function t(e){var r=n.call(this)||this;return r._value=e,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var r=n.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},t.prototype.getValue=function(){var e=this,r=e.hasError,s=e.thrownError,o=e._value;if(r)throw s;return this._throwIfClosed(),o},t.prototype.next=function(e){n.prototype.next.call(this,this._value=e)},t})(se),mt={now:function(){return Date.now()}},vt=(function(n){w(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t})(N),ue={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,D([n,t],j(e)))},clearInterval:function(n){return clearInterval(n)},delegate:void 0},bt=(function(n){w(t,n);function t(e,r){var s=n.call(this,e,r)||this;return s.scheduler=e,s.work=r,s.pending=!1,s}return t.prototype.schedule=function(e,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var o=this.id,i=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(i,o,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(e,r,s){return s===void 0&&(s=0),ue.setInterval(e.flush.bind(e,this),s)},t.prototype.recycleAsyncId=function(e,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&ue.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(e,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var s=!1,o;try{this.work(e)}catch(i){s=!0,o=i||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,s=e.scheduler,o=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,K(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t})(vt),le=(function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},n.now=mt.now,n})(),yt=(function(n){w(t,n);function t(e,r){r===void 0&&(r=le.now);var s=n.call(this,e,r)||this;return s.actions=[],s._active=!1,s}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var s;this._active=!0;do if(s=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,s){for(;e=r.shift();)e.unsubscribe();throw s}},t})(le),Te=new yt(bt),St=Te,It=new S(function(n){return n.complete()});function Ce(n){return n&&m(n.schedule)}function Oe(n){return n[n.length-1]}function Et(n){return m(Oe(n))?n.pop():void 0}function Ae(n){return Ce(Oe(n))?n.pop():void 0}var _e=(function(n){return n&&typeof n.length=="number"&&typeof n!="function"});function xe(n){return m(n?.then)}function Me(n){return m(n[re])}function Pe(n){return Symbol.asyncIterator&&m(n?.[Symbol.asyncIterator])}function Le(n){return new TypeError("You provided "+(n!==null&&typeof n=="object"?"an invalid object":"'"+n+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function wt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ke=wt();function Ue(n){return m(n?.[ke])}function Ne(n){return rt(this,arguments,function(){var e,r,s,o;return ye(this,function(i){switch(i.label){case 0:e=n.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,L(e.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,L(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,L(s)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Re(n){return m(n?.getReader)}function M(n){if(n instanceof S)return n;if(n!=null){if(Me(n))return Tt(n);if(_e(n))return Ct(n);if(xe(n))return Ot(n);if(Pe(n))return $e(n);if(Ue(n))return At(n);if(Re(n))return _t(n)}throw Le(n)}function Tt(n){return new S(function(t){var e=n[re]();if(m(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Ct(n){return new S(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function Ot(n){return new S(function(t){n.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,we)})}function At(n){return new S(function(t){var e,r;try{for(var s=k(n),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(a){e={error:a}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}t.complete()})}function $e(n){return new S(function(t){xt(n,t).catch(function(e){return t.error(e)})})}function _t(n){return $e(Ne(n))}function xt(n,t){var e,r,s,o;return nt(this,void 0,void 0,function(){var i,a;return ye(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),e=st(n),u.label=1;case 1:return[4,e.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),s={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=e.return)?[4,o.call(e)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function C(n,t,e,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){e(),s?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(o),!s)return o}function je(n,t){return t===void 0&&(t=0),A(function(e,r){e.subscribe(O(r,function(s){return C(r,n,function(){return r.next(s)},t)},function(){return C(r,n,function(){return r.complete()},t)},function(s){return C(r,n,function(){return r.error(s)},t)}))})}function De(n,t){return t===void 0&&(t=0),A(function(e,r){r.add(n.schedule(function(){return e.subscribe(r)},t))})}function Mt(n,t){return M(n).pipe(De(t),je(t))}function Pt(n,t){return M(n).pipe(De(t),je(t))}function Lt(n,t){return new S(function(e){var r=0;return t.schedule(function(){r===n.length?e.complete():(e.next(n[r++]),e.closed||this.schedule())})})}function kt(n,t){return new S(function(e){var r;return C(e,t,function(){r=n[ke](),C(e,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(a){e.error(a);return}i?e.complete():e.next(o)},0,!0)}),function(){return m(r?.return)&&r.return()}})}function He(n,t){if(!n)throw new Error("Iterable cannot be null");return new S(function(e){C(e,t,function(){var r=n[Symbol.asyncIterator]();C(e,t,function(){r.next().then(function(s){s.done?e.complete():e.next(s.value)})},0,!0)})})}function Ut(n,t){return He(Ne(n),t)}function Nt(n,t){if(n!=null){if(Me(n))return Mt(n,t);if(_e(n))return Lt(n,t);if(xe(n))return Pt(n,t);if(Pe(n))return He(n,t);if(Ue(n))return kt(n,t);if(Re(n))return Ut(n,t)}throw Le(n)}function oe(n,t){return t?Nt(n,t):M(n)}function Rt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ae(n);return oe(n,e)}function $t(n){return n instanceof Date&&!isNaN(n)}function U(n,t){return A(function(e,r){var s=0;e.subscribe(O(r,function(o){r.next(n.call(t,o,s++))}))})}var jt=Array.isArray;function Dt(n,t){return jt(t)?n.apply(void 0,D([],j(t))):n(t)}function Ht(n){return U(function(t){return Dt(n,t)})}var Gt=Array.isArray,Ft=Object.getPrototypeOf,Kt=Object.prototype,Bt=Object.keys;function qt(n){if(n.length===1){var t=n[0];if(Gt(t))return{args:t,keys:null};if(Yt(t)){var e=Bt(t);return{args:e.map(function(r){return t[r]}),keys:e}}}return{args:n,keys:null}}function Yt(n){return n&&typeof n=="object"&&Ft(n)===Kt}function Vt(n,t){return n.reduce(function(e,r,s){return e[r]=t[s],e},{})}function Xt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ae(n),r=Et(n),s=qt(n),o=s.args,i=s.keys;if(o.length===0)return oe([],e);var a=new S(Wt(o,e,i?function(u){return Vt(i,u)}:V));return r?a.pipe(Ht(r)):a}function Wt(n,t,e){return e===void 0&&(e=V),function(r){de(t,function(){for(var s=n.length,o=new Array(s),i=s,a=s,u=function(h){de(t,function(){var g=oe(n[h],t),b=!1;g.subscribe(O(r,function(l){o[h]=l,b||(b=!0,a--),a||r.next(e(o.slice()))},function(){--i||r.complete()}))},r)},c=0;c<s;c++)u(c)},r)}}function de(n,t,e){n?C(e,n,t):t()}function zt(n,t,e,r,s,o,i,a){var u=[],c=0,h=0,g=!1,b=function(){g&&!u.length&&!c&&t.complete()},l=function(p){return c<r?f(p):u.push(p)},f=function(p){c++;var _=!1;M(e(p,h++)).subscribe(O(t,function(I){t.next(I)},function(){_=!0},void 0,function(){if(_)try{c--;for(var I=function(){var x=u.shift();i||f(x)};u.length&&c<r;)I();b()}catch(x){t.error(x)}}))};return n.subscribe(O(t,l,function(){g=!0,b()})),function(){}}function B(n,t,e){return e===void 0&&(e=1/0),m(t)?B(function(r,s){return U(function(o,i){return t(r,o,s,i)})(M(n(r,s)))},e):(typeof t=="number"&&(e=t),A(function(r,s){return zt(r,s,n,e)}))}function Jt(n,t,e){n===void 0&&(n=0),e===void 0&&(e=St);var r=-1;return t!=null&&(Ce(t)?e=t:r=t),new S(function(s){var o=$t(n)?+n-e.now():n;o<0&&(o=0);var i=0;return e.schedule(function(){s.closed||(s.next(i++),0<=r?this.schedule(void 0,r):s.complete())},o)})}function Qt(n,t){return m(t)?B(n,t,1):B(n,1)}function Zt(n){return n<=0?function(){return It}:A(function(t,e){var r=0;t.subscribe(O(e,function(s){++r<=n&&(e.next(s),n<=r&&e.complete())}))})}function en(n){return U(function(){return n})}function tn(n,t){return B(function(e,r){return M(n(e,r)).pipe(Zt(1),en(e))})}function nn(n,t){t===void 0&&(t=Te);var e=Jt(n,t);return tn(function(){return e})}function q(n,t){return t===void 0&&(t=V),n=n??rn,A(function(e,r){var s,o=!0;e.subscribe(O(r,function(i){var a=t(i);(o||!n(s,a))&&(o=!1,s=a,r.next(i))}))})}function rn(n,t){return n===t}function sn(n){return A(function(t,e){try{t.subscribe(e)}finally{e.add(n)}})}function on(n){return A(function(t,e){M(n).subscribe(O(e,function(){return e.complete()},Z)),!e.closed&&t.subscribe(e)})}async function an(n,t){const e=n.getReader();let r;for(;!(r=await e.read()).done;)t(r.value)}function cn(n){let t,e,r,s=!1;return function(i){t===void 0?(t=i,e=0,r=-1):t=ln(t,i);const a=t.length;let u=0;for(;e<a;){s&&(t[e]===10&&(u=++e),s=!1);let c=-1;for(;e<a&&c===-1;++e)switch(t[e]){case 58:r===-1&&(r=e-u);break;case 13:s=!0;case 10:c=e;break}if(c===-1)break;n(t.subarray(u,c),r),u=e,r=-1}u===a?t=void 0:u!==0&&(t=t.subarray(u),e-=u)}}function un(n,t,e){let r=he();const s=new TextDecoder;return function(i,a){if(i.length===0)e?.(r),r=he();else if(a>0){const u=s.decode(i.subarray(0,a)),c=a+(i[a+1]===32?2:1),h=s.decode(i.subarray(c));switch(u){case"data":r.data=r.data?r.data+`
|
|
4
|
+
`+h:h;break;case"event":r.event=h;break;case"id":n(r.id=h);break;case"retry":const g=parseInt(h,10);isNaN(g)||t(r.retry=g);break}}}}function ln(n,t){const e=new Uint8Array(n.length+t.length);return e.set(n),e.set(t,n.length),e}function he(){return{data:"",event:"",id:"",retry:void 0}}var dn=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(e[r[s]]=n[r[s]]);return e};const te="text/event-stream",hn=1e3,fe="last-event-id";function fn(n,t){var{signal:e,headers:r,onopen:s,onmessage:o,onclose:i,onerror:a,openWhenHidden:u,fetch:c}=t,h=dn(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((g,b)=>{const l=Object.assign({},r);l.accept||(l.accept=te);let f;function p(){f.abort(),document.hidden||X()}u||document.addEventListener("visibilitychange",p);let _=hn,I=0;function x(){document.removeEventListener("visibilitychange",p),window.clearTimeout(I),f.abort()}e?.addEventListener("abort",()=>{x(),g()});const Ze=c??window.fetch,et=s??pn;async function X(){var W;f=new AbortController;try{const H=await Ze(n,Object.assign(Object.assign({},h),{headers:l,signal:f.signal}));await et(H),await an(H.body,cn(un(T=>{T?l[fe]=T:delete l[fe]},T=>{_=T},o))),i?.(),x(),g()}catch(H){if(!f.signal.aborted)try{const T=(W=a?.(H))!==null&&W!==void 0?W:_;window.clearTimeout(I),I=window.setTimeout(X,T)}catch(T){x(),b(T)}}}X()})}function pn(n){const t=n.headers.get("content-type");if(!t?.startsWith(te))throw new Error(`Expected content-type to be ${te}, Actual: ${t}`)}function pe(n){const{endpoint:t,apiKey:e,payload:r,debugMode:s,customHeaders:o}=n,i=n.method??"POST";return new S(a=>{const u=new AbortController;let c,h=!1;const g={"Content-Type":"application/json",...o};e&&(g["X-API-KEY"]=e);const b=new URL(t);return s&&b.searchParams.set("is_debug","true"),fn(b.toString(),{method:i,headers:g,body:i==="POST"&&r?JSON.stringify(r):void 0,signal:u.signal,openWhenHidden:!0,onopen:async l=>{if(l.ok)c=l.headers.get("X-Trace-Id")??void 0;else{let f;try{f=await l.json()}catch{try{f=await l.text()}catch{f=null}}a.error(new Y(l.status,l.statusText,f)),u.abort()}},onmessage:l=>{l.id&&(h=!0);const f=JSON.parse(l.data);c?f.traceId=c:f.requestId&&(f.traceId=f.requestId,c||(c=f.requestId)),a.next(f)},onclose:()=>{a.complete()},onerror:l=>{if(!h)throw a.error(l),u.abort(),l}}),()=>{u.abort()}})}class gn{listeners={};on(t,e){this.listeners=Object.assign({},this.listeners,{[t]:(this.listeners[t]??[]).concat(e)})}off(t,e){this.listeners[t]&&(this.listeners=Object.assign({},this.listeners,{[t]:(this.listeners[t]??[]).filter(r=>r!==e)}))}remove(t){delete this.listeners[t]}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(r=>r(...e))}}class mn{apiKey;endpoint;botProviderEndpoint;debugMode;destroy$=new se;closed=!1;detached=!1;detachTimer;inFlight=0;sseEmitter=new gn;transformSsePayload;customHeaders;constructor(t){if(!t.endpoint&&!t.botProviderEndpoint)throw new Error("Either endpoint or botProviderEndpoint must be provided");if(this.apiKey=t.apiKey,this.debugMode=t.debugMode,this.transformSsePayload=t.transformSsePayload,this.botProviderEndpoint=t.botProviderEndpoint,this.customHeaders={...t.customHeaders,...t.userIdentityHint?{"X-ASGARD-USER-IDENTITY-HINT":t.userIdentityHint}:{}},!t.endpoint&&t.botProviderEndpoint){const e=t.botProviderEndpoint.replace(/\/+$/,"");this.endpoint=`${e}/message/sse`}else t.endpoint&&(this.endpoint=t.endpoint,this.debugMode&&console.warn('[AsgardServiceClient] The "endpoint" option is deprecated and will be removed in the next major version. Please use "botProviderEndpoint" instead. The SSE endpoint will be automatically derived as "${botProviderEndpoint}/message/sse".'))}on(t,e){this.sseEmitter.remove(t),this.sseEmitter.on(t,e)}handleEvent(t){switch(t.eventType){case d.INIT:this.sseEmitter.emit(d.INIT,t);break;case d.PROCESS_START:case d.PROCESS_COMPLETE:this.sseEmitter.emit(d.PROCESS,t);break;case d.MESSAGE_START:case d.MESSAGE_DELTA:case d.MESSAGE_COMPLETE:this.sseEmitter.emit(d.MESSAGE,t);break;case d.TOOL_CALL_START:case d.TOOL_CALL_COMPLETE:this.sseEmitter.emit(d.TOOL_CALL,t);break;case d.TOOL_CALL_CONSENT:this.sseEmitter.emit(d.TOOL_CALL_CONSENT,t);break;case d.DONE:this.sseEmitter.emit(d.DONE,t);break;case d.ERROR:this.sseEmitter.emit(d.ERROR,t);break}}fetchSse(t,e){return e?.onSseStart?.(),this.inFlight+=1,this.runSse(pe({apiKey:this.apiKey,endpoint:this.endpoint,debugMode:this.debugMode,payload:this.transformSsePayload?.(t)??t,customHeaders:this.customHeaders}),e)}rejoinSse(t,e){e?.onSseStart?.(),this.inFlight+=1;const r=new URL(this.endpoint);return r.searchParams.set("custom_channel_id",t),this.runSse(pe({apiKey:this.apiKey,endpoint:r.toString(),debugMode:this.debugMode,method:"GET",customHeaders:this.customHeaders}),e)}deriveChannelMetadataEndpoint(){const t=this.getBaseEndpoint();return t?`${t}/channel/metadata`:null}async channelMetadata(t){const e=this.deriveChannelMetadataEndpoint();if(!e)throw new Error("Unable to derive channel metadata endpoint. Please provide botProviderEndpoint in config.");const r=new URL(e);r.searchParams.set("custom_channel_id",t);const s={...this.customHeaders};this.apiKey&&(s["X-API-KEY"]=this.apiKey);const o=await fetch(r.toString(),{method:"GET",headers:s});if(o.status===404)return null;if(!o.ok)throw new Y(o.status,o.statusText,await o.text().catch(()=>{}));const i=await o.json(),a=i.data??i;return{title:a.title??null,runState:a.runState??"IDLE",lastActivityAt:a.lastActivityAt}}runSse(t,e){return t.pipe(Qt(r=>Rt(r).pipe(nn(e?.delayTime??50))),on(this.destroy$),sn(()=>this.onRunSettled())).subscribe({next:r=>{this.detached||(e?.onSseMessage?.(r),this.handleEvent(r))},error:r=>{this.detached||e?.onSseError?.(r)},complete:()=>{this.detached||e?.onSseCompleted?.()}})}detach(t){if(!(this.detached||this.closed)){if(this.detached=!0,this.inFlight===0){this.close();return}this.detachTimer=setTimeout(()=>this.close(),t.timeoutMs)}}onRunSettled(){this.inFlight=Math.max(0,this.inFlight-1),this.detached&&this.inFlight===0&&this.close()}close(){this.closed||(this.closed=!0,this.detachTimer&&(clearTimeout(this.detachTimer),this.detachTimer=void 0),this.destroy$.next(),this.destroy$.complete())}async uploadFile(t,e){const r=this.deriveBlobEndpoint();if(!r)throw new Error("Unable to derive blob endpoint. Please provide botProviderEndpoint in config.");const s=new FormData;s.append("file",t),s.append("customChannelId",e);const o={...this.customHeaders};this.apiKey&&(o["X-API-KEY"]=this.apiKey);try{const i=await fetch(r,{method:"POST",headers:o,body:s});if(!i.ok)throw new Error(`Upload failed: ${i.status} ${i.statusText}`);const a=await i.json();return this.debugMode&&console.log("[AsgardServiceClient] File upload response:",a),a}catch(i){throw console.error("[AsgardServiceClient] File upload error:",i),i}}async downloadChannelHomeFile(t,e){const r=this.getBaseEndpoint();if(!r)throw new Error("Unable to derive channel-home download endpoint. Please provide botProviderEndpoint in config.");const s=`custom_channel_id=${encodeURIComponent(e)}&relative_path=${encodeURIComponent(t)}`,o=`${r}/channel-home/download?${s}`,i={...this.customHeaders};this.apiKey&&(i["X-API-KEY"]=this.apiKey);try{const a=await fetch(o,{method:"GET",headers:i});if(!a.ok)throw new Error(`Channel Home download failed: ${a.status} ${a.statusText}`);const u=await a.blob(),c=t.split("/").pop()||"download";return this.debugMode&&console.log("[AsgardServiceClient] Channel Home download response:",{filename:c,size:u.size}),{blob:u,filename:c}}catch(a){throw console.error("[AsgardServiceClient] Channel Home download error:",a),a}}deriveBlobEndpoint(){const t=this.getBaseEndpoint();return t?`${t}/blob`:null}getBaseEndpoint(){let t=this.botProviderEndpoint;return!t&&this.endpoint&&(t=this.endpoint.replace("/message/sse","")),t?t.replace(/\/+$/,""):null}}const y=[];for(let n=0;n<256;++n)y.push((n+256).toString(16).slice(1));function vn(n,t=0){return(y[n[t+0]]+y[n[t+1]]+y[n[t+2]]+y[n[t+3]]+"-"+y[n[t+4]]+y[n[t+5]]+"-"+y[n[t+6]]+y[n[t+7]]+"-"+y[n[t+8]]+y[n[t+9]]+"-"+y[n[t+10]]+y[n[t+11]]+y[n[t+12]]+y[n[t+13]]+y[n[t+14]]+y[n[t+15]]).toLowerCase()}let J;const bn=new Uint8Array(16);function yn(){if(!J){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");J=crypto.getRandomValues.bind(crypto)}return J(bn)}const Sn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ge={randomUUID:Sn};function In(n,t,e){n=n||{};const r=n.random??n.rng?.()??yn();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,vn(r)}function Ge(n,t,e){return ge.randomUUID&&!n?ge.randomUUID():In(n)}class v{messages=null;pendingConsent=null;constructor({messages:t,pendingConsent:e=null}){this.messages=t,this.pendingConsent=e??null}pushMessage(t){const e=new Map(this.messages);return e.set(t.messageId,t),new v({messages:e,pendingConsent:this.pendingConsent})}clearPendingConsent(){return this.pendingConsent?new v({messages:this.messages,pendingConsent:null}):this}cancelInFlightToolCalls(){if(!this.messages)return this;let t=!1;const e=new Map(this.messages);for(const[r,s]of e)s.type==="tool-call"&&!s.isComplete&&(e.set(r,{...s,isComplete:!0,isCancelled:!0}),t=!0);return t?new v({messages:e,pendingConsent:this.pendingConsent}):this}onMessage(t){switch(t.eventType){case d.MESSAGE_START:return this.onMessageStart(t);case d.MESSAGE_DELTA:return this.onMessageDelta(t);case d.MESSAGE_COMPLETE:return this.onMessageComplete(t);case d.MESSAGE_USER:return this.onMessageUser(t);case d.MESSAGE_THINKING_START:return this.onThinkingStart(t);case d.MESSAGE_THINKING_DELTA:return this.onThinkingDelta(t);case d.MESSAGE_THINKING_COMPLETE:return this.onThinkingComplete(t);case d.TOOL_CALL_START:return this.onToolCallStart(t);case d.TOOL_CALL_COMPLETE:return this.onToolCallComplete(t);case d.TOOL_CALL_CONSENT:return this.onToolCallConsent(t);case d.SUBAGENT_START:return this.onSubagentStart(t);case d.SUBAGENT_COMPLETE:return this.onSubagentComplete(t);case d.ERROR:return this.onMessageError(t);default:return this}}isTerminalBot(t){return t?.type==="bot"&&!t.isTyping}isTerminalThinking(t){return t?.type==="thinking"&&!t.isThinking}onMessageStart(t){const e=t.fact.messageStart.message;if(e.parentToolUseId)return this;if(this.isTerminalBot(this.messages?.get(e.messageId)))return this;const r=new Map(this.messages);return r.set(e.messageId,{type:"bot",eventType:d.MESSAGE_START,isTyping:!0,typingText:"",messageId:e.messageId,message:e,time:new Date,traceId:t.traceId,raw:""}),new v({messages:r,pendingConsent:this.pendingConsent})}onMessageDelta(t){const e=t.fact.messageDelta.message;if(e.parentToolUseId)return this;const r=this.messages?.get(e.messageId);if(this.isTerminalBot(r))return this;const s=r?.type==="bot"?r:void 0,o=new Map(this.messages);return o.set(e.messageId,{type:"bot",eventType:d.MESSAGE_DELTA,isTyping:!0,typingText:`${s?.typingText??""}${e.text}`,messageId:e.messageId,message:e,time:new Date,traceId:t.traceId??s?.traceId,raw:s?.raw??""}),new v({messages:o,pendingConsent:this.pendingConsent})}onMessageComplete(t){const e=t.fact.messageComplete.message;if(e.parentToolUseId)return this;const r=new Map(this.messages),s=r.get(e.messageId);return r.set(e.messageId,{type:"bot",eventType:d.MESSAGE_COMPLETE,isTyping:!1,typingText:null,messageId:e.messageId,message:e,time:new Date,traceId:t.traceId??(s?.type==="bot"?s.traceId:void 0),raw:JSON.stringify(t)}),new v({messages:r,pendingConsent:this.pendingConsent})}onThinkingStart(t){const e=t.fact.messageThinkingStart.message;if(e.parentToolUseId)return this;if(this.isTerminalThinking(this.messages?.get(e.messageId)))return this;const r=new Map(this.messages),s={type:"thinking",messageId:e.messageId,text:e.text,isThinking:!0,time:new Date,traceId:t.traceId};return r.set(e.messageId,s),new v({messages:r,pendingConsent:this.pendingConsent})}onThinkingDelta(t){const e=t.fact.messageThinkingDelta.message;if(e.parentToolUseId)return this;const r=this.messages?.get(e.messageId);if(this.isTerminalThinking(r))return this;const s=r?.type==="thinking"?r:void 0,o=new Map(this.messages),i={type:"thinking",messageId:e.messageId,text:`${s?.text??""}${e.text}`,isThinking:!0,time:s?.time??new Date,traceId:t.traceId??s?.traceId};return o.set(e.messageId,i),new v({messages:o,pendingConsent:this.pendingConsent})}onThinkingComplete(t){const e=t.fact.messageThinkingComplete.message;if(e.parentToolUseId)return this;const r=this.messages?.get(e.messageId),s=r?.type==="thinking"?r:void 0,o=new Map(this.messages),i={type:"thinking",messageId:e.messageId,text:e.text,isThinking:!1,time:s?.time??new Date,traceId:t.traceId??s?.traceId};return o.set(e.messageId,i),new v({messages:o,pendingConsent:this.pendingConsent})}onMessageUser(t){const e=t.fact.messageUser;if((this.messages?.get(e.messageId)??(e.customMessageId?this.messages?.get(e.customMessageId):void 0))?.type==="user")return this;const s=new Map(this.messages),o={type:"user",messageId:e.messageId,text:e.text,blobIds:e.blobIds,customMessageId:e.customMessageId,identityHint:e.identityHint,time:new Date,traceId:t.traceId};return s.set(e.messageId,o),new v({messages:s,pendingConsent:this.pendingConsent})}onMessageError(t){const e=Ge(),r=t.fact.runError.error,s=new Map(this.messages);return s.set(e,{type:"error",eventType:d.ERROR,messageId:e,error:r,time:new Date,traceId:t.traceId}),new v({messages:s,pendingConsent:this.pendingConsent})}onToolCallStart(t){const e=t.fact.toolCallStart,r=new Map(this.messages),s=`${e.processId}-${e.callSeq}`,o={type:"tool-call",eventType:d.TOOL_CALL_START,messageId:s,processId:e.processId,callSeq:e.callSeq,toolName:e.toolCall.toolName,reason:e.toolCall.reason,toolsetName:e.toolCall.toolsetName,parameter:e.toolCall.parameter,toolUseId:e.toolUseId,parentToolUseId:e.parentToolUseId,isComplete:!1,time:new Date,traceId:t.traceId};return r.set(s,o),new v({messages:r,pendingConsent:this.pendingConsent})}onToolCallComplete(t){const e=t.fact.toolCallComplete,r=new Map(this.messages),s=`${e.processId}-${e.callSeq}`,o=r.get(s);if(o?.type==="tool-call"){const i={...o,eventType:d.TOOL_CALL_COMPLETE,result:e.toolCallResult,isError:e.isError,sidecar:e.toolUseResultSidecar,isComplete:!0,traceId:t.traceId??o.traceId};r.set(s,i)}return new v({messages:r,pendingConsent:this.pendingConsent})}onToolCallConsent(t){const e=t.fact.toolCallConsent;return new v({messages:this.messages,pendingConsent:e})}onSubagentStart(t){const e=t.fact.subagentStart,r=new Map(this.messages),s=`subagent:${e.parentToolUseId}:start`,o={type:"subagent",messageId:s,kind:"start",parentToolUseId:e.parentToolUseId,agentId:e.agentId,subagentType:e.subagentType,description:e.description,time:new Date,traceId:t.traceId};return r.set(s,o),new v({messages:r,pendingConsent:this.pendingConsent})}onSubagentComplete(t){const e=t.fact.subagentComplete,r=new Map(this.messages),s=`subagent:${e.parentToolUseId}:complete`,o={type:"subagent",messageId:s,kind:"complete",parentToolUseId:e.parentToolUseId,agentId:e.agentId,subagentType:e.subagentType,status:e.status,summary:e.summary,time:new Date,traceId:t.traceId};return r.set(s,o),new v({messages:r,pendingConsent:this.pendingConsent})}}const En=new Set(["TaskCreate","TaskUpdate"]);function Fe(n){return n.toolsetName===""&&En.has(n.toolName)}function me(n){return typeof n=="object"&&n!==null?n:void 0}function E(n){return typeof n=="string"?n:void 0}function Ke(n){const t=[],e=new Map;for(const r of n){const s=r.parameter??{},o=r.sidecar??{};if(r.toolName==="TaskCreate"){const i=me(o.task),a=E(i?.id);if(!a)continue;e.has(a)||t.push(a),e.set(a,{id:a,subject:E(s.subject)||E(i?.subject)||"",activeForm:E(s.activeForm),description:E(s.description),status:e.get(a)?.status??"pending"})}else if(r.toolName==="TaskUpdate"){const i=me(o.statusChange),a=E(s.taskId)||E(o.taskId),u=E(i?.to)||E(s.status);if(!a||!u)continue;const c=e.get(a);c&&e.set(a,{...c,status:u})}}return t.map(r=>e.get(r))}function Be(n){return n.toolsetName===""&&n.toolName==="Agent"}function qe(n){return!!n}function Ye(n){const t=[],e=new Map,r=new Map,s=o=>(e.has(o)||(t.push(o),e.set(o,{status:"running"}),r.set(o,new Map)),e.get(o));for(const o of n)switch(o.kind){case"agentStart":{const i=s(o.toolUseId);o.description&&!i.description&&(i.description=o.description);break}case"subagentStart":{const i=s(o.parentToolUseId);i.agentId=o.agentId??i.agentId,i.subagentType=o.subagentType??i.subagentType,i.description=o.description??i.description;break}case"toolStart":{s(o.parentToolUseId),r.get(o.parentToolUseId).set(o.toolUseId,{toolsetName:o.toolsetName,toolName:o.toolName,parameter:o.parameter??{},reason:o.reason,status:"running"});break}case"toolComplete":{const i=r.get(o.parentToolUseId)?.get(o.toolUseId);i&&(i.status=o.isError?"error":"completed");break}case"subagentComplete":{const i=s(o.parentToolUseId);i.status=o.status,i.summary=o.summary;break}}return t.map(o=>({parentToolUseId:o,...e.get(o),tools:Array.from(r.get(o).values())}))}function wn(n){return typeof n=="string"?n:void 0}function Ve(n){const t=[];for(const e of n){if(e.type==="tool-call"&&Be(e)){t.push({kind:"agentStart",toolUseId:e.toolUseId??e.messageId,description:wn(e.parameter.description)});continue}if(e.type==="tool-call"&&qe(e.parentToolUseId)){const r=e.toolUseId??e.messageId;t.push({kind:"toolStart",parentToolUseId:e.parentToolUseId,toolUseId:r,toolsetName:e.toolsetName,toolName:e.toolName,parameter:e.parameter,reason:e.reason}),e.isComplete&&t.push({kind:"toolComplete",parentToolUseId:e.parentToolUseId,toolUseId:r,isError:e.isError});continue}if(e.type==="subagent"&&e.kind==="start"){t.push({kind:"subagentStart",parentToolUseId:e.parentToolUseId,agentId:e.agentId,subagentType:e.subagentType,description:e.description});continue}e.type==="subagent"&&e.kind==="complete"&&e.status&&t.push({kind:"subagentComplete",parentToolUseId:e.parentToolUseId,status:e.status,summary:e.summary})}return t}function Xe(n){const t=Array.from(n.messages?.values()??[]).filter(e=>e.type==="tool-call"&&e.isComplete&&Fe(e));return Ke(t)}function We(n){return Ye(Ve(Array.from(n.messages?.values()??[])))}function ze(n,t){return n===t?!0:n.length!==t.length?!1:n.every((e,r)=>{const s=t[r];return e.id===s.id&&e.status===s.status&&e.subject===s.subject&&e.activeForm===s.activeForm&&e.description===s.description})}function Tn(n,t){return n.length!==t.length?!1:n.every((e,r)=>{const s=t[r];return e.toolName===s.toolName&&e.toolsetName===s.toolsetName&&e.status===s.status&&e.reason===s.reason})}function Je(n,t){return n===t?!0:n.length!==t.length?!1:n.every((e,r)=>{const s=t[r];return e.parentToolUseId===s.parentToolUseId&&e.status===s.status&&e.subagentType===s.subagentType&&e.description===s.description&&e.summary===s.summary&&Tn(e.tools,s.tools)})}function Qe(n){const t=new P([]),e=new P([]),r=new N;return r.add(n.pipe(U(Xe),q(ze)).subscribe(t)),r.add(n.pipe(U(We),q(Je)).subscribe(e)),{tasks$:t.asObservable(),subagents$:e.asObservable(),getTasks:()=>t.value,getSubagents:()=>e.value,teardown:()=>r.unsubscribe()}}class ${client;customChannelId;customMessageId;isConnecting$;conversation$;channelTitleSubject;sandboxPhaseSubject;derivedStores;statesObserver;statesSubscription;tasks$;subagents$;channelTitle$;sandboxPhase$;currentUserMessageId;lastSentMessageId;currentRun;constructor(t){if(!t.client)throw new Error("client must be required");if(!t.customChannelId)throw new Error("customChannelId must be required");this.client=t.client,this.customChannelId=t.customChannelId,this.customMessageId=t.customMessageId,this.isConnecting$=new P(!1),this.conversation$=new P(t.conversation),this.channelTitleSubject=new P(t.channelTitle??null),this.sandboxPhaseSubject=new P("idle"),this.derivedStores=Qe(this.conversation$),this.tasks$=this.derivedStores.tasks$,this.subagents$=this.derivedStores.subagents$,this.channelTitle$=this.channelTitleSubject.pipe(q()),this.sandboxPhase$=this.sandboxPhaseSubject.pipe(q()),this.statesObserver=t.statesObserver}getTasks(){return this.derivedStores.getTasks()}getSubagents(){return this.derivedStores.getSubagents()}getChannelTitle(){return this.channelTitleSubject.value}getSandboxPhase(){return this.sandboxPhaseSubject.value}setChannelTitle(t){this.channelTitleSubject.next(t)}static create(t){const e=new $(t);return e.subscribe(),e}static async reset(t,e,r,s){const o=new $(t);try{return o.subscribe(),s?.(o),await o.resetChannel(e,r),o}catch(i){throw o.close(),i}}static async restore(t,e,r){const s=new $(t);try{return s.subscribe(),r?.(s),await s.rejoinChannel(e),s}catch(o){throw s.close(),o}}subscribe(){this.statesSubscription=Xt([this.isConnecting$,this.conversation$,this.derivedStores.tasks$,this.derivedStores.subagents$,this.channelTitle$,this.sandboxPhase$]).pipe(U(([t,e,r,s,o,i])=>({isConnecting:t,conversation:e,tasks:r,subagents:s,channelTitle:o,sandboxPhase:i}))).subscribe(this.statesObserver)}resolvePayload(t){if(typeof t=="function")try{return t()}catch(e){throw new Error(`Failed to resolve payload function: ${e instanceof Error?e.message:String(e)}`)}return t}updateSandboxPhase(t){switch(t){case d.SANDBOX_LAUNCH:this.sandboxPhaseSubject.next("launching");break;case d.SANDBOX_READY:this.sandboxPhaseSubject.next("ready");break;case d.INIT:case d.ERROR:this.sandboxPhaseSubject.next("idle");break}}buildRunHandlers(t,e,r){return{onSseStart:t?.onSseStart,onSseMessage:s=>{if(t?.onSseMessage?.(s),s.eventType===d.CHANNEL_TITLE_UPDATE&&this.channelTitleSubject.next(s.fact.channelTitleUpdate.title),this.updateSandboxPhase(s.eventType),this.currentUserMessageId&&s.traceId){const o=new Map(this.conversation$.value.messages),i=o.get(this.currentUserMessageId);i&&i.type==="user"&&(o.set(this.currentUserMessageId,{...i,traceId:s.traceId}),this.conversation$.next(new v({messages:o}))),this.currentUserMessageId=void 0}this.conversation$.next(this.conversation$.value.onMessage(s))},onSseError:s=>{t?.onSseError?.(s),this.isConnecting$.next(!1),this.currentUserMessageId=void 0,this.currentRun=void 0,r(s)},onSseCompleted:()=>{t?.onSseCompleted?.(),this.isConnecting$.next(!1),this.currentUserMessageId=void 0,this.currentRun=void 0,e()}}}fetchSse(t,e){return new Promise((r,s)=>{this.isConnecting$.next(!0),this.currentRun=this.client.fetchSse(t,this.buildRunHandlers(e,r,s))})}rejoinChannel(t){return new Promise((e,r)=>{if(!this.client.rejoinSse){e();return}this.isConnecting$.next(!0),this.currentRun=this.client.rejoinSse(this.customChannelId,this.buildRunHandlers(t,e,r))})}resetChannel(t,e){return this.fetchSse({action:R.RESET_CHANNEL,customChannelId:this.customChannelId,customMessageId:this.customMessageId,text:t?.text||"",payload:this.resolvePayload(t?.payload)},e)}sendMessage(t,e){const r=t.text.trim(),s=t.customMessageId??Ge();return this.currentUserMessageId=s,this.lastSentMessageId=s,this.conversation$.next(this.conversation$.value.pushMessage({type:"user",messageId:s,text:r,blobIds:t.blobIds,filePreviewUrls:t.filePreviewUrls,documentNames:t.documentNames,time:new Date})),this.fetchSse({action:R.NONE,customChannelId:this.customChannelId,customMessageId:s,payload:this.resolvePayload(t?.payload),text:r,blobIds:t?.blobIds},e)}replyToolCallConsents(t,e,r){return this.conversation$.next(this.conversation$.value.clearPendingConsent()),this.fetchSse({action:R.RESPONSE_TOOL_CALL_CONSENT,customChannelId:this.customChannelId,customMessageId:this.lastSentMessageId??this.customMessageId,payload:this.resolvePayload(r),text:"",toolCallConsents:t},e)}stopGeneration(){this.currentRun&&(this.currentRun.unsubscribe(),this.currentRun=void 0,this.isConnecting$.next(!1),this.currentUserMessageId=void 0,this.conversation$.next(this.conversation$.value.cancelInFlightToolCalls()))}close(){this.currentRun?.unsubscribe(),this.currentRun=void 0,this.isConnecting$.complete(),this.conversation$.complete(),this.channelTitleSubject.complete(),this.sandboxPhaseSubject.complete(),this.derivedStores.teardown(),this.statesSubscription?.unsubscribe()}}exports.AsgardServiceClient=mn;exports.Channel=$;exports.Conversation=v;exports.EventType=d;exports.FetchSseAction=R;exports.HttpError=Y;exports.MessageTemplateType=be;exports.ToolCallConsentResult=ve;exports.conversationToSubagentEvents=Ve;exports.createDerivedStores=Qe;exports.deriveSubagents=We;exports.deriveTasks=Xe;exports.isAgentTool=Be;exports.isHttpError=tt;exports.isSubagentChildTool=qe;exports.isTaskTool=Fe;exports.reduceSubagents=Ye;exports.reduceTaskEvents=Ke;exports.subagentsEqual=Je;exports.tasksEqual=ze;
|
|
5
5
|
//# sourceMappingURL=index.cjs.map
|