@coze/cli 0.1.8-alpha.618a4c → 0.2.0-alpha.094e22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +344 -25
- package/lib/cli.js +3 -3
- package/lib/fetch-client-DC0c3ox3.js +1 -0
- package/lib/index-CkTEdvpA.js +1 -0
- package/lib/send-message.worker.js +1 -1
- package/lib/session-task-refresh.worker.js +1 -1
- package/lib/{task-worker-CxZeBKqU.js → task-worker-C2ZfSQY6.js} +1 -1
- package/package.json +6 -1
- package/skills/manifest.json +25 -0
- package/skills/using-coze-cli/SKILL.md +448 -0
- package/skills/using-coze-cli/coze-claw/MODULE.md +189 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-agent-routing.md +45 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-artifacts.md +52 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-async-followup.md +266 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-message.md +176 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-podcast.md +73 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-ppt.md +78 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-progress.md +112 -0
- package/skills/using-coze-cli/coze-claw/references/coze-claw-session.md +144 -0
- package/skills/using-coze-cli/coze-code/MODULE.md +252 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-db.md +537 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-deploy.md +258 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-domain.md +73 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-env.md +82 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-git.md +181 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-message.md +240 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-model.md +51 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-preview.md +33 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-project.md +176 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-repo.md +285 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-skill.md +117 -0
- package/skills/using-coze-cli/coze-code/references/coze-code-tools.md +47 -0
- package/skills/using-coze-cli/coze-file/MODULE.md +46 -0
- package/skills/using-coze-cli/coze-file/references/coze-file-upload.md +59 -0
- package/skills/using-coze-cli/coze-generate/MODULE.md +84 -0
- package/skills/using-coze-cli/coze-generate/references/coze-generate-audio.md +105 -0
- package/skills/using-coze-cli/coze-generate/references/coze-generate-image.md +80 -0
- package/skills/using-coze-cli/coze-generate/references/coze-generate-video.md +125 -0
- package/lib/fetch-client-CWYDGe9Z.js +0 -1
- package/lib/index-BC9PFu7i.js +0 -1
package/lib/index-BC9PFu7i.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("mitt"),t=require("crypto"),s=require("./fetch-client-CWYDGe9Z.js"),i=require("path"),r=require("fs"),n=require("form-data"),a=require("fs/promises"),o=require("lodash");var c;!function(e){e.SendMessage="sendMessage";e.ResumeMessage="resumeMessage";e.GetMessage="getMessage";e.ClearHistory="clearHistory";e.ClearMessageContext="clearMessageContext";e.DeleteMessage="deleteMessage";e.BreakMessage="breakMessage";e.ReportMessage="reportMessage";e.ChatASR="chatASR";e.ChatReconnect="chatReconnect";e.ChatRetrieve="chatRetrieve"}(c||(c={}));let _,l,h=(e=21)=>{var s;s=e-=0,!_||_.length<s?(_=Buffer.allocUnsafe(128*s),t.randomFillSync(_),l=0):l+s>_.length&&(t.randomFillSync(_),l=0),l+=s;let i="";for(let t=l-e;t<l;t++)i+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&_[t]];return i};function u(e){return e}function d(){}var p=Date.now;var g,T,E,m=s.defineProperty?function(e,t){return s.defineProperty(e,"toString",{configurable:!0,enumerable:!1,value:(i=t,function(){return i}),writable:!0});var i}:u,f=(g=m,T=0,E=0,function(){var e=p(),t=16-(e-E);if(E=e,t>0){if(++T>=800)return arguments[0]}else T=0;return g.apply(void 0,arguments)});var L=Math.max;function A(e,t){return f(function(e,t,s){return t=L(void 0===t?e.length-1:t,0),function(){for(var i=arguments,r=-1,n=L(i.length-t,0),a=Array(n);++r<n;)a[r]=i[t+r];r=-1;for(var o=Array(t+1);++r<t;)o[r]=i[r];return o[t]=s(a),function(e,t,s){switch(s.length){case 0:return e.call(t);case 1:return e.call(t,s[0]);case 2:return e.call(t,s[0],s[1]);case 3:return e.call(t,s[0],s[1],s[2])}return e.apply(t,s)}(e,this,o)}}(e,t,u),e+"")}function S(e){return A((function(t,i){var r=-1,n=i.length,a=n>1?i[n-1]:void 0,o=n>2?i[2]:void 0;for(a=e.length>3&&"function"==typeof a?(n--,a):void 0,o&&function(e,t,i){if(!s.isObject(i))return!1;var r=typeof t;return!!("number"==r?s.isArrayLike(i)&&s.isIndex(t,i.length):"string"==r&&t in i)&&s.eq(i[t],e)}(i[0],i[1],o)&&(a=n<3?void 0:a,n=1),t=Object(t);++r<n;){var c=i[r];c&&e(t,c,r,a)}return t}))}var R=Object.prototype.hasOwnProperty;function C(e){if(!s.isObject(e))return function(e){var t=[];if(null!=e)for(var s in Object(e))t.push(s);return t}(e);var t=s.isPrototype(e),i=[];for(var r in e)("constructor"!=r||!t&&R.call(e,r))&&i.push(r);return i}function v(e){return s.isArrayLike(e)?s.arrayLikeKeys(e,!0):C(e)}var I=Function.prototype,y=Object.prototype,M=I.toString,b=y.hasOwnProperty,N=M.call(Object);var U=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)s.arrayPush(t,s.getSymbols(e)),e=s.getPrototype(e);return t}:s.stubArray;function P(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new s.MapCache;++t<i;)this.add(e[t])}function O(e,t){for(var s=-1,i=null==e?0:e.length;++s<i;)if(t(e[s],s,e))return!0;return!1}P.prototype.add=P.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},P.prototype.has=function(e){return this.__data__.has(e)};function k(e,t,s,i,r,n){var a=1&s,o=e.length,c=t.length;if(o!=c&&!(a&&c>o))return!1;var _=n.get(e),l=n.get(t);if(_&&l)return _==t&&l==e;var h=-1,u=!0,d=2&s?new P:void 0;for(n.set(e,t),n.set(t,e);++h<o;){var p=e[h],g=t[h];if(i)var T=a?i(g,p,h,t,e,n):i(p,g,h,e,t,n);if(void 0!==T){if(T)continue;u=!1;break}if(d){if(!O(t,(function(e,t){if(a=t,!d.has(a)&&(p===e||r(p,e,s,i,n)))return d.push(t);var a}))){u=!1;break}}else if(p!==g&&!r(p,g,s,i,n)){u=!1;break}}return n.delete(e),n.delete(t),u}function B(e){var t=-1,s=Array(e.size);return e.forEach((function(e,i){s[++t]=[i,e]})),s}function j(e){var t=-1,s=Array(e.size);return e.forEach((function(e){s[++t]=e})),s}var D=s.Symbol?s.Symbol.prototype:void 0,G=D?D.valueOf:void 0;var q=Object.prototype.hasOwnProperty;var w="[object Arguments]",F="[object Array]",x="[object Object]",W=Object.prototype.hasOwnProperty;function H(e,t,i,r,n,a){var o=s.isArray(e),c=s.isArray(t),_=o?F:s.getTag(e),l=c?F:s.getTag(t),h=(_=_==w?x:_)==x,u=(l=l==w?x:l)==x,d=_==l;if(d&&s.isBuffer(e)){if(!s.isBuffer(t))return!1;o=!0,h=!1}if(d&&!h)return a||(a=new s.Stack),o||s.isTypedArray(e)?k(e,t,i,r,n,a):function(e,t,i,r,n,a,o){switch(i){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!a(new s.Uint8Array(e),new s.Uint8Array(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return s.eq(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var c=B;case"[object Set]":var _=1&r;if(c||(c=j),e.size!=t.size&&!_)return!1;var l=o.get(e);if(l)return l==t;r|=2,o.set(e,t);var h=k(c(e),c(t),r,n,a,o);return o.delete(e),h;case"[object Symbol]":if(G)return G.call(e)==G.call(t)}return!1}(e,t,_,i,r,n,a);if(!(1&i)){var p=h&&W.call(e,"__wrapped__"),g=u&&W.call(t,"__wrapped__");if(p||g){var T=p?e.value():e,E=g?t.value():t;return a||(a=new s.Stack),n(T,E,i,r,a)}}return!!d&&(a||(a=new s.Stack),function(e,t,i,r,n,a){var o=1&i,c=s.getAllKeys(e),_=c.length;if(_!=s.getAllKeys(t).length&&!o)return!1;for(var l=_;l--;){var h=c[l];if(!(o?h in t:q.call(t,h)))return!1}var u=a.get(e),d=a.get(t);if(u&&d)return u==t&&d==e;var p=!0;a.set(e,t),a.set(t,e);for(var g=o;++l<_;){var T=e[h=c[l]],E=t[h];if(r)var m=o?r(E,T,h,t,e,a):r(T,E,h,e,t,a);if(!(void 0===m?T===E||n(T,E,i,r,a):m)){p=!1;break}g||(g="constructor"==h)}if(p&&!g){var f=e.constructor,L=t.constructor;f==L||!("constructor"in e)||!("constructor"in t)||"function"==typeof f&&f instanceof f&&"function"==typeof L&&L instanceof L||(p=!1)}return a.delete(e),a.delete(t),p}(e,t,i,r,n,a))}function K(e,t,i,r,n){return e===t||(null==e||null==t||!s.isObjectLike(e)&&!s.isObjectLike(t)?e!=e&&t!=t:H(e,t,i,r,K,n))}function V(e){return e==e&&!s.isObject(e)}function $(e,t){return function(s){return null!=s&&(s[e]===t&&(void 0!==t||e in Object(s)))}}function z(e){var t=function(e){for(var t=s.keys(e),i=t.length;i--;){var r=t[i],n=e[r];t[i]=[r,n,V(n)]}return t}(e);return 1==t.length&&t[0][2]?$(t[0][0],t[0][1]):function(i){return i===e||function(e,t,i,r){var n=i.length,a=n;if(null==e)return!a;for(e=Object(e);n--;){var o=i[n];if(o[2]?o[1]!==e[o[0]]:!(o[0]in e))return!1}for(;++n<a;){var c=(o=i[n])[0],_=e[c],l=o[1];if(o[2]){if(void 0===_&&!(c in e))return!1}else if(!K(l,_,3,r,new s.Stack))return!1}return!0}(i,0,t)}}function Q(e,t){return null!=e&&t in Object(e)}function J(e,t){return null!=e&&function(e,t,i){for(var r=-1,n=(t=s.castPath(t,e)).length,a=!1;++r<n;){var o=s.toKey(t[r]);if(!(a=null!=e&&i(e,o)))break;e=e[o]}return a||++r!=n?a:!!(n=null==e?0:e.length)&&s.isLength(n)&&s.isIndex(o,n)&&(s.isArray(e)||s.isArguments(e))}(e,t,Q)}function Y(e){return s.isKey(e)?(t=s.toKey(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return s.baseGet(t,e)}}(e);var t}function Z(e){return"function"==typeof e?e:null==e?u:"object"==typeof e?s.isArray(e)?function(e,t){return s.isKey(e)&&V(t)?$(s.toKey(e),t):function(i){var r=s.get(i,e);return void 0===r&&r===t?J(i,e):K(t,r,3)}}(e[0],e[1]):z(e):Y(e)}var X=function(e,t,s){for(var i=-1,r=Object(e),n=s(e),a=n.length;a--;){var o=n[++i];if(!1===t(r[o],o,r))break}return e};function ee(e,t,i){(void 0!==i&&!s.eq(e[t],i)||void 0===i&&!(t in e))&&s.baseAssignValue(e,t,i)}function te(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function se(e){return function(e,t,i){var r=!i;i||(i={});for(var n=-1,a=t.length;++n<a;){var o=t[n],c=void 0;void 0===c&&(c=e[o]),r?s.baseAssignValue(i,o,c):s.assignValue(i,o,c)}return i}(e,v(e))}function ie(e,t,i,r,n,a,o){var c=te(e,i),_=te(t,i),l=o.get(_);if(l)ee(e,i,l);else{var h,u=a?a(c,_,i+"",e,t,o):void 0,d=void 0===u;if(d){var p=s.isArray(_),g=!p&&s.isBuffer(_),T=!p&&!g&&s.isTypedArray(_);u=_,p||g||T?s.isArray(c)?u=c:(h=c,s.isObjectLike(h)&&s.isArrayLike(h)?u=function(e,t){var s=-1,i=e.length;for(t||(t=Array(i));++s<i;)t[s]=e[s];return t}(c):g?(d=!1,u=s.cloneBuffer(_,!0)):T?(d=!1,u=s.cloneTypedArray(_,!0)):u=[]):function(e){if(!s.isObjectLike(e)||"[object Object]"!=s.baseGetTag(e))return!1;var t=s.getPrototype(e);if(null===t)return!0;var i=b.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&M.call(i)==N}(_)||s.isArguments(_)?(u=c,s.isArguments(c)?u=se(c):s.isObject(c)&&!s.isFunction(c)||(u=s.initCloneObject(_))):d=!1}d&&(o.set(_,u),n(u,_,r,a,o),o.delete(_)),ee(e,i,u)}}function re(e,t,i,r,n){e!==t&&X(t,(function(a,o){if(n||(n=new s.Stack),s.isObject(a))ie(e,t,o,i,re,r,n);else{var c=r?r(te(e,o),a,o+"",e,t,n):void 0;void 0===c&&(c=a),ee(e,o,c)}}),v)}var ne=S((function(e,t,s,i){re(e,t,s,i)}));function ae(e){return void 0===e}var oe=S((function(e,t,s){re(e,t,s)}));function ce(e,t){if(null==e)return{};var i=s.arrayMap(function(e){return s.baseGetAllKeys(e,v,U)}(e),(function(e){return[e]}));return t=Z(t),function(e,t,i){for(var r=-1,n=t.length,a={};++r<n;){var o=t[r],c=s.baseGet(e,o);i(c,o)&&s.baseSet(a,s.castPath(o,e),c)}return a}(e,i,(function(e,s){return t(e,s[0])}))}function _e(e,t,i){return null==e?e:function(e,t,i){return s.baseSet(e,t,i(s.baseGet(e,t)))}(e,t,"function"==typeof(r=i)?r:u);var r}class le{createQueryMessage(e,t){return{content:e,session_id:t.session_id,type:"query",project_id:t.project_id,conversation_id:t.conversation_id,context:t.context,local_msg_id:h()}}createRetryMessage(e,t){return{content:e,session_id:t.session_id,type:"retry",project_id:t.project_id,conversation_id:t.conversation_id,context:t.context,local_msg_id:h()}}createEditMessage(e,t){const s=h();return{content:oe(e,{edit:{local_msg_id:s}}),session_id:t.session_id,type:"edit",project_id:t.project_id,conversation_id:t.conversation_id,context:t.context,local_msg_id:s}}createInputMessage(e,t){return{content:e,session_id:t.session_id,type:"input",project_id:t.project_id,conversation_id:t.conversation_id,context:t.context,local_msg_id:h()}}createCancelMessage(e,t){return{content:e,session_id:t.session_id,type:"cancel",project_id:t.project_id,conversation_id:t.conversation_id,context:t.context,local_msg_id:h()}}}const he=(...e)=>ne(...e,((e,t)=>{if(s.isArray(e))return e.concat(t)}));var ue,de,pe,ge,Te,Ee,me,fe,Le,Ae,Se,Re,Ce,ve,Ie,ye,Me,be,Ne,Ue,Pe;function Oe(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}!function(e){e[e.OpenClawChannelTypeLark=1]="OpenClawChannelTypeLark";e[e.OpenClawChannelTypeWeixin=2]="OpenClawChannelTypeWeixin";e[e.OpenClawChannelTypeWeCom=3]="OpenClawChannelTypeWeCom"}(ue||(ue={})),function(e){e[e.OpenClawLarkAuthStatusAuthorized=1]="OpenClawLarkAuthStatusAuthorized";e[e.OpenClawLarkAuthStatusUnauthorized=2]="OpenClawLarkAuthStatusUnauthorized"}(de||(de={})),function(e){e[e.OpenClawLarkConfigStatusNotCreated=1]="OpenClawLarkConfigStatusNotCreated";e[e.OpenClawLarkConfigStatusCreated=2]="OpenClawLarkConfigStatusCreated";e[e.OpenClawLarkConfigStatusConfigured=3]="OpenClawLarkConfigStatusConfigured"}(pe||(pe={})),function(e){e[e.OpenClawUpdateStatusNoUpdate=1]="OpenClawUpdateStatusNoUpdate";e[e.OpenClawUpdateStatusPending=2]="OpenClawUpdateStatusPending";e[e.OpenClawUpdateStatusUpdating=3]="OpenClawUpdateStatusUpdating"}(ge||(ge={})),function(e){e[e.OpenClawVersionTypeFull=1]="OpenClawVersionTypeFull";e[e.OpenClawVersionTypeLite=2]="OpenClawVersionTypeLite"}(Te||(Te={})),function(e){e[e.RequirementsNotMet=1]="RequirementsNotMet";e[e.FunctionDefect=2]="FunctionDefect";e[e.PoorDesign=3]="PoorDesign";e[e.InteractionIssue=4]="InteractionIssue";e[e.LongTimeWait=5]="LongTimeWait";e[e.RequirementsMisunderstood=6]="RequirementsMisunderstood";e[e.BadPlanning=7]="BadPlanning";e[e.ExecutionFailed=8]="ExecutionFailed";e[e.UnstableExecution=9]="UnstableExecution"}(Ee||(Ee={})),function(e){e[e.Unknown=0]="Unknown";e[e.Like=1]="Like";e[e.Dislike=2]="Dislike"}(me||(me={})),function(e){e[e.Unknown=0]="Unknown";e[e.CollaboratorChanged=1]="CollaboratorChanged";e[e.ProjectInvitation=2]="ProjectInvitation";e[e.ProjectChange=3]="ProjectChange"}(fe||(fe={})),function(e){e[e.Wait=0]="Wait";e[e.Done=1]="Done"}(Le||(Le={})),function(e){e[e.RoleTypeUnknown=0]="RoleTypeUnknown";e[e.RoleTypeUser=1]="RoleTypeUser";e[e.RoleTypeAssistant=2]="RoleTypeAssistant"}(Ae||(Ae={})),function(e){e[e.Agent=0]="Agent";e[e.Ask=1]="Ask";e[e.DangerousConfirm=2]="DangerousConfirm";e[e.Plan=4]="Plan"}(Se||(Se={})),function(e){e[e.Idle=0]="Idle";e[e.Running=1]="Running";e[e.Interrupted=2]="Interrupted"}(Re||(Re={})),function(e){e[e.AddAttributes=1]="AddAttributes";e[e.RemoveAttributes=2]="RemoveAttributes"}(Ce||(Ce={})),function(e){e[e.CloseConnection=1]="CloseConnection"}(ve||(ve={})),function(e){e[e.ON_LINE=0]="ON_LINE";e[e.OFF_LINE=1]="OFF_LINE";e[e.TOUCH=2]="TOUCH"}(Ie||(Ie={})),function(e){e[e.AddGroups=1]="AddGroups";e[e.RemoveGroups=2]="RemoveGroups";e[e.ReplaceWithGroups=3]="ReplaceWithGroups"}(ye||(ye={})),function(e){e[e.App=0]="App";e[e.Service=1]="Service";e[e.Method=2]="Method"}(Me||(Me={})),function(e){e[e.Unknown=0]="Unknown";e[e.DeploySuccess=1]="DeploySuccess";e[e.DeployFailed=2]="DeployFailed";e[e.AuditFailed=3]="AuditFailed";e[e.MiniAuditPending=4]="MiniAuditPending";e[e.MiniAuditFailed=5]="MiniAuditFailed";e[e.MiniPublished=6]="MiniPublished";e[e.MiniPublishFailed=7]="MiniPublishFailed"}(be||(be={})),function(e){e[e.ApiKey=1]="ApiKey";e[e.WechatOfficialAccount=2]="WechatOfficialAccount";e[e.OAuth=3]="OAuth"}(Ne||(Ne={})),function(e){e[e.PROJECT_COPY=1]="PROJECT_COPY";e[e.SKILL_STORE=2]="SKILL_STORE"}(Ue||(Ue={})),function(e){e[e.PENDING=1]="PENDING";e[e.SUCCESS=2]="SUCCESS";e[e.FAILED=3]="FAILED"}(Pe||(Pe={}));class ke{__init(){this.request=s.request}__init2(){this.baseURL=""}constructor(e){ke.prototype.__init.call(this),ke.prototype.__init2.call(this),this.request=Oe([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=Oe([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}GetHistory(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/history`),r={before:s.before,limit:s.limit,after:s.after,conversation_id:s.conversation_id};return this.request({url:i,method:"GET",params:r},t)}ReplyFeedback(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/feedback`),r={reply_id:s.reply_id,type:s.type,session_id:s.session_id,feedback_detail:s.feedback_detail};return this.request({url:i,method:"POST",data:r},t)}TestChat(e,t){const s=e,i=this.genBaseURL("/v1/api/project/:project_id/chat/mock"),r={msg:s.msg};return this.request({url:i,method:"POST",data:r},t)}GetCanvasInfo(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/agent/canvas`),r={space_id:s.space_id,commit_id:s.commit_id};return this.request({url:i,method:"POST",data:r},t)}ExplainNode(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/agent/explain_node`),r={node_ids:s.node_ids,schema:s.schema};return this.request({url:i,method:"POST",data:r},t)}GetInOutSchema(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/agent/inout_schema`),r={space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}GetSkillMeta(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/skill/meta`);return this.request({url:i,method:"POST"},t)}ListSpans(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/list_spans`),r={workspace_id:s.workspace_id,start_time:s.start_time,end_time:s.end_time,filters:s.filters,page_size:s.page_size,order_bys:s.order_bys,page_token:s.page_token,platform_type:s.platform_type,span_list_type:s.span_list_type};return this.request({url:i,method:"POST",data:r},t)}GetModelList(e,t){const s=e||{},i=this.genBaseURL("/v1/api/project/model_list"),r={project_id:s.project_id,project_type:s.project_type,space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}GetCommercialInfo(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/commercial_info`),r={reply_id_list:s.reply_id_list};return this.request({url:i,method:"POST",data:r},t)}PackSkill(e,t){const s=e,i=this.genBaseURL("/v1/api/project/:project_id/skill/pack"),r={project_id:s.project_id};return this.request({url:i,method:"POST",data:r},t)}GetSkillOAuthUrl(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/skill/oauth_url`),r={checkpoint_id:s.checkpoint_id,credential_name:s.credential_name,platform_oauth_info:s.platform_oauth_info,custom_oauth_info:s.custom_oauth_info,credential_tips:s.credential_tips};return this.request({url:i,method:"POST",data:r},t)}GetTools(e,t){const s=this.genBaseURL("/v1/api/project/tools");return this.request({url:s,method:"GET"},t)}CanvasSubmit(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/agent/canvas_submit`),r={after_canvas:s.after_canvas};return this.request({url:i,method:"POST",data:r},t)}UpdateOpenClawSettings(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/update_setting`),r={selected_model_id:s.selected_model_id,version:s.version,channels:s.channels};return this.request({url:i,method:"POST",data:r},t)}CreateOpenClawLarkApp(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/create_lark_app`),r={app_name:s.app_name,recreate:s.recreate};return this.request({url:i,method:"POST",data:r},t)}GetOpenClawSettings(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/settings`);return this.request({url:i,method:"GET"},t)}CancelChatCLIMessage(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/message/cancel`),r={conversation_id:s.conversation_id};return this.request({url:i,method:"POST",data:r},t)}GetChatCLIMessageStatus(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/message/status`),r={conversation_id:s.conversation_id};return this.request({url:i,method:"GET",params:r},t)}ChatCLISendMessage(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/message/send`),r={message:s.message,device_id:s.device_id};return this.request({url:i,method:"POST",data:r},t)}GetChatCLIMessageResultContent(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/message/result`),r={conversation_id:s.conversation_id};return this.request({url:i,method:"GET",params:r},t)}CreateOpenClawWeixinQRCode(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/create_weixin_qrcode`);return this.request({url:i,method:"POST"},t)}GetOpenClawUpdateStatus(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/update_status`);return this.request({url:i,method:"GET"},t)}TriggerOpenClawUpdate(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/trigger_update`);return this.request({url:i,method:"POST"},t)}ConnectOpenClawFeishu(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/connect_feishu`),r={app_name:s.app_name,recreate:s.recreate,avatar_url:s.avatar_url};return this.request({url:i,method:"POST",data:r},t)}ConnectOpenClawWeChat(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/connect_wechat`);return this.request({url:i,method:"POST"},t)}GetProjectQueue(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/queue`),r={conversation_id:s.conversation_id};return this.request({url:i,method:"GET",params:r},t)}ReorderProjectQueue(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/queue/reorder`),r={ordered_message_ids:s.ordered_message_ids,conversation_id:s.conversation_id};return this.request({url:i,method:"POST",data:r},t)}EnqueueMessage(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/queue/enqueue`),r={message:s.message,device_id:s.device_id,conversation_id:s.conversation_id};return this.request({url:i,method:"POST",data:r},t)}PauseProjectQueue(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/queue/pause`),r={conversation_id:s.conversation_id};return this.request({url:i,method:"POST",data:r},t)}EditQueueMessage(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/queue/edit`),r={message_id:s.message_id,message:s.message,conversation_id:s.conversation_id};return this.request({url:i,method:"POST",data:r},t)}ResumeProjectQueue(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/queue/resume`),r={conversation_id:s.conversation_id};return this.request({url:i,method:"POST",data:r},t)}DeleteQueueMessage(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/queue/delete`),r={message_id:s.message_id,conversation_id:s.conversation_id};return this.request({url:i,method:"POST",data:r},t)}ClearProjectQueue(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/queue/clear`),r={conversation_id:s.conversation_id};return this.request({url:i,method:"POST",data:r},t)}GetConversation(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/conversation/${s.conversation_id}`);return this.request({url:i,method:"GET"},t)}CreateConversation(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/conversation/create`),r={title:s.title,new_worktree:s.new_worktree,source_conversation_id:s.source_conversation_id,source_message_id:s.source_message_id};return this.request({url:i,method:"POST",data:r},t)}UpdateConversationSetting(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/conversation/${s.conversation_id}/update_setting`),r={model_setting:s.model_setting,skill_setting:s.skill_setting,mode:s.mode,wizards:s.wizards,agent_tools:s.agent_tools};return this.request({url:i,method:"POST",data:r},t)}DeleteConversation(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/conversation/${s.conversation_id}/delete`);return this.request({url:i,method:"POST"},t)}UpdateConversation(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/conversation/${s.conversation_id}/update`),r={title:s.title,is_pinned:s.is_pinned,ack_sequence_id:s.ack_sequence_id};return this.request({url:i,method:"POST",data:r},t)}ListConversations(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/conversation/list`),r={before:s.before,after:s.after,limit:s.limit};return this.request({url:i,method:"GET",params:r},t)}ConnectOpenClawWeCom(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/connect_wecom`),r={bot_id:s.bot_id,secret:s.secret};return this.request({url:i,method:"POST",data:r},t)}ExtractStyle(e,t){const s=e,i=this.genBaseURL("/v1/api/project/style/extract"),r={url:s.url};return this.request({url:i,method:"POST",data:r},t)}BatchGetStyleDetail(e,t){const s=e,i=this.genBaseURL("/v1/api/project/style/detail"),r={style_ids:s.style_ids};return this.request({url:i,method:"POST",data:r},t)}ListRecommendStyles(e,t){const s=this.genBaseURL("/v1/api/project/style/list");return this.request({url:s,method:"GET"},t)}GetFrontierConnectionParams(e,t){const s=e||{},i=this.genBaseURL("/v1/api/project/frontier/connection-params"),r={device_id:s.device_id},n={Host:s.Host};return this.request({url:i,method:"GET",params:r,headers:n},t)}GetProjectDefaultConversation(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/conversation/default`);return this.request({url:i,method:"GET"},t)}}ke.prototype.GetProjectQueue=function(e,t){const s=e,i=this.genBaseURL(`/v1/api/project/${s.project_id}/queue`),r={conversation_id:s.conversation_id};return this.request({url:i,method:"GET",params:r},t)};const Be=new ke({});class je{constructor({options:e,reportLog:t}){this.mergedBaseOptions=he({scenes:{[c.GetMessage]:async(...e)=>await Be.GetHistory(...e)}},e),this.reportLog=t,this.reportLogWithScope=this.reportLog.createLoggerWith({scope:"RequestManager"}),this.reportLogWithScope.info({message:"RequestManager is initialized",meta:{...this.mergedBaseOptions}})}appendRequestOptions(e){this.mergedBaseOptions=he(this.mergedBaseOptions,e)}getSceneConfig(e){const{scenes:t}=this.mergedBaseOptions;return t[e]}}class De{constructor(){De.prototype.__init.call(this)}__init(){this.preSendLocalMessageEvents=e()}on(e,t){this.preSendLocalMessageEvents.on(e,t)}off(e,t){this.preSendLocalMessageEvents.off(e,t)}once(e,t){const s=i=>{t(i),this.preSendLocalMessageEvents.off(e,s)};this.preSendLocalMessageEvents.on(e,s)}emit(e,t){this.preSendLocalMessageEvents.emit(e,t)}destroy(){this.preSendLocalMessageEvents.all.clear()}}class Ge{getSendChatMessageStructure(e,t){const s=oe(e,function(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}([t,"optionalAccess",e=>e.extendFields]));return ce(s,(e=>null!=e&&""!==e))}}function qe(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}const we=["console","file","text"],Fe="generate_image";function xe(e,t){return null!=e?e:t()}function We(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}const He=(e,t)=>{const i=t.at(0);if(!i)return e;if("message_start"===i.type||"message_end"===i.type)return s.cloneDeep(i);const r=e?s.cloneDeep(e):s.cloneDeep(i),n=e?t:t.slice(1);if(0===n.length)return r;const a=n.filter((e=>e.type===r.type));if("answer"===r.type){const e=a.map((e=>xe(e.content.answer,(()=>""))));r.content.answer=xe(r.content.answer,(()=>""))+e.join("")}else if("thinking"===r.type){const e=a.map((e=>xe(e.content.thinking,(()=>""))));r.content.thinking=xe(r.content.thinking,(()=>""))+e.join("")}else if("tool_request"===r.type&&r.content.tool_request){const e=a.map((e=>xe(We([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters]),(()=>""))));r.content.tool_request.stream_parameters=xe(r.content.tool_request.stream_parameters,(()=>""))+e.join("")}else if("tool_process"===r.type){const e=a.map((e=>We([e,"access",e=>e.content,"access",e=>e.tool_process,"optionalAccess",e=>e.data,"access",e=>e.content]))),t=function(e,t){const s={};let i=!1;const r=t.map((e=>qe([e,"optionalAccess",e=>e[Fe],"optionalAccess",e=>e.images])||[])).flat();return(r.length>0||!ae(qe([e,"optionalAccess",e=>e[Fe]])))&&(s[Fe]={images:(qe([e,"optionalAccess",e=>e[Fe],"optionalAccess",e=>e.images])||[]).concat(r)},i=!0),we.forEach((r=>{const n=t.filter((e=>!ae(qe([e,"optionalAccess",e=>e[r]])))).map((e=>qe([e,"optionalAccess",e=>e[r]])||""));(n.length>0||!ae(qe([e,"optionalAccess",e=>e[r]])))&&(s[r]=(qe([e,"optionalAccess",e=>e[r]])||"")+n.join(""),i=!0)})),i?s:e||{}}(We([r,"access",e=>e.content,"access",e=>e.tool_process,"optionalAccess",e=>e.data,"access",e=>e.content]),e);r.content.tool_process&&(r.content.tool_process.data.content=t)}const o=t.at(-1);return o&&(r.sequence_id=o.sequence_id,r.finish=o.finish),r};function Ke(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}class Ve{__init(){this.streamBufferSnapshot=null}constructor(e){Ve.prototype.__init.call(this),Ve.prototype.__init2.call(this),Ve.prototype.__init3.call(this),this.key=e.key}__init2(){this.getBufferMeta=e=>{return{query_msg_id:(t=Ke([e,"access",e=>e.at,"call",e=>e(0),"optionalAccess",e=>e.query_msg_id]),s=()=>"",null!=t?t:s()),timestamp:Date.now(),key:this.key};var t,s}}__init3(){this.recordStreamBuffer=e=>{const{streamMessageBuffer:t,streamChunkBuffer:s}=e;this.streamBufferSnapshot={streamMessageBuffer:[...t],streamChunkBuffer:[...s],...this.getBufferMeta(t)}}}getStreamBufferSnapshot(){return this.streamBufferSnapshot}clear(){this.streamBufferSnapshot=null}}class $e{__init(){this.timeoutMs=3e4}__init2(){this.debugLogTimer=null}__init3(){this.debugTimeoutTimer=null}__init4(){this.currentQueryMsgId=""}__init5(){this.logInterval=3e3}get isDebugging(){return null!==this.debugLogTimer||null!==this.debugTimeoutTimer}constructor(e){$e.prototype.__init.call(this),$e.prototype.__init2.call(this),$e.prototype.__init3.call(this),$e.prototype.__init4.call(this),$e.prototype.__init5.call(this),this.reportLogWithScope=e.reportLogWithScope,this.getEnableDebug=e.getEnableDebug,this.getLogPayload=e.getLogPayload,this.mark=e.mark}startDebugLog(e){this.getEnableDebug()&&this.currentQueryMsgId!==e&&(this.clearAllTimers(),this.currentQueryMsgId=e,this.debugLogTimer=setInterval((()=>{this.clearTimeoutTimer(),this.reportLogWithScope.info({message:`${this.mark} Debug - Pulling`,meta:{query_msg_id:this.currentQueryMsgId,payload:this.getLogPayload()}}),this.startTimeout(e)}),this.logInterval))}stopDebugLog(){this.getEnableDebug()&&(this.debugLogTimer||this.debugTimeoutTimer)&&(this.clearAllTimers(),this.reportLogWithScope.info({message:`${this.mark} Debug - Final`,meta:{query_msg_id:this.currentQueryMsgId,payload:this.getLogPayload()}}))}destroy(){this.clearAllTimers(),this.currentQueryMsgId=""}clearAllTimers(){this.debugLogTimer&&(clearInterval(this.debugLogTimer),this.debugLogTimer=null),this.clearTimeoutTimer()}startTimeout(e){this.debugTimeoutTimer=setTimeout((()=>{this.reportLogWithScope.info({message:`${this.mark} Debug - Timeout兜底触发`,meta:{query_msg_id:e,payload:this.getLogPayload(),timeoutMs:this.timeoutMs}}),this.clearAllTimers(),this.currentQueryMsgId=""}),this.timeoutMs)}clearTimeoutTimer(){this.debugTimeoutTimer&&(clearTimeout(this.debugTimeoutTimer),this.debugTimeoutTimer=null)}}var ze;!function(e){e[e.BACKSPACE=8]="BACKSPACE",e[e.FORM_FEED=12]="FORM_FEED",e[e.NEWLINE=10]="NEWLINE",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.TAB=9]="TAB",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.NUMBER_SIGN=35]="NUMBER_SIGN",e[e.DOLLAR_SIGN=36]="DOLLAR_SIGN",e[e.PERCENT_SIGN=37]="PERCENT_SIGN",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.LEFT_PARENTHESIS=40]="LEFT_PARENTHESIS",e[e.RIGHT_PARENTHESIS=41]="RIGHT_PARENTHESIS",e[e.ASTERISK=42]="ASTERISK",e[e.PLUS_SIGN=43]="PLUS_SIGN",e[e.COMMA=44]="COMMA",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.FULL_STOP=46]="FULL_STOP",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_ZERO=48]="DIGIT_ZERO",e[e.DIGIT_ONE=49]="DIGIT_ONE",e[e.DIGIT_TWO=50]="DIGIT_TWO",e[e.DIGIT_THREE=51]="DIGIT_THREE",e[e.DIGIT_FOUR=52]="DIGIT_FOUR",e[e.DIGIT_FIVE=53]="DIGIT_FIVE",e[e.DIGIT_SIX=54]="DIGIT_SIX",e[e.DIGIT_SEVEN=55]="DIGIT_SEVEN",e[e.DIGIT_EIGHT=56]="DIGIT_EIGHT",e[e.DIGIT_NINE=57]="DIGIT_NINE",e[e.COLON=58]="COLON",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.COMMERCIAL_AT=64]="COMMERCIAL_AT",e[e.LATIN_CAPITAL_LETTER_A=65]="LATIN_CAPITAL_LETTER_A",e[e.LATIN_CAPITAL_LETTER_B=66]="LATIN_CAPITAL_LETTER_B",e[e.LATIN_CAPITAL_LETTER_C=67]="LATIN_CAPITAL_LETTER_C",e[e.LATIN_CAPITAL_LETTER_D=68]="LATIN_CAPITAL_LETTER_D",e[e.LATIN_CAPITAL_LETTER_E=69]="LATIN_CAPITAL_LETTER_E",e[e.LATIN_CAPITAL_LETTER_F=70]="LATIN_CAPITAL_LETTER_F",e[e.LATIN_CAPITAL_LETTER_G=71]="LATIN_CAPITAL_LETTER_G",e[e.LATIN_CAPITAL_LETTER_H=72]="LATIN_CAPITAL_LETTER_H",e[e.LATIN_CAPITAL_LETTER_I=73]="LATIN_CAPITAL_LETTER_I",e[e.LATIN_CAPITAL_LETTER_J=74]="LATIN_CAPITAL_LETTER_J",e[e.LATIN_CAPITAL_LETTER_K=75]="LATIN_CAPITAL_LETTER_K",e[e.LATIN_CAPITAL_LETTER_L=76]="LATIN_CAPITAL_LETTER_L",e[e.LATIN_CAPITAL_LETTER_M=77]="LATIN_CAPITAL_LETTER_M",e[e.LATIN_CAPITAL_LETTER_N=78]="LATIN_CAPITAL_LETTER_N",e[e.LATIN_CAPITAL_LETTER_O=79]="LATIN_CAPITAL_LETTER_O",e[e.LATIN_CAPITAL_LETTER_P=80]="LATIN_CAPITAL_LETTER_P",e[e.LATIN_CAPITAL_LETTER_Q=81]="LATIN_CAPITAL_LETTER_Q",e[e.LATIN_CAPITAL_LETTER_R=82]="LATIN_CAPITAL_LETTER_R",e[e.LATIN_CAPITAL_LETTER_S=83]="LATIN_CAPITAL_LETTER_S",e[e.LATIN_CAPITAL_LETTER_T=84]="LATIN_CAPITAL_LETTER_T",e[e.LATIN_CAPITAL_LETTER_U=85]="LATIN_CAPITAL_LETTER_U",e[e.LATIN_CAPITAL_LETTER_V=86]="LATIN_CAPITAL_LETTER_V",e[e.LATIN_CAPITAL_LETTER_W=87]="LATIN_CAPITAL_LETTER_W",e[e.LATIN_CAPITAL_LETTER_X=88]="LATIN_CAPITAL_LETTER_X",e[e.LATIN_CAPITAL_LETTER_Y=89]="LATIN_CAPITAL_LETTER_Y",e[e.LATIN_CAPITAL_LETTER_Z=90]="LATIN_CAPITAL_LETTER_Z",e[e.LEFT_SQUARE_BRACKET=91]="LEFT_SQUARE_BRACKET",e[e.REVERSE_SOLIDUS=92]="REVERSE_SOLIDUS",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.CIRCUMFLEX_ACCENT=94]="CIRCUMFLEX_ACCENT",e[e.LOW_LINE=95]="LOW_LINE",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_LETTER_A=97]="LATIN_SMALL_LETTER_A",e[e.LATIN_SMALL_LETTER_B=98]="LATIN_SMALL_LETTER_B",e[e.LATIN_SMALL_LETTER_C=99]="LATIN_SMALL_LETTER_C",e[e.LATIN_SMALL_LETTER_D=100]="LATIN_SMALL_LETTER_D",e[e.LATIN_SMALL_LETTER_E=101]="LATIN_SMALL_LETTER_E",e[e.LATIN_SMALL_LETTER_F=102]="LATIN_SMALL_LETTER_F",e[e.LATIN_SMALL_LETTER_G=103]="LATIN_SMALL_LETTER_G",e[e.LATIN_SMALL_LETTER_H=104]="LATIN_SMALL_LETTER_H",e[e.LATIN_SMALL_LETTER_I=105]="LATIN_SMALL_LETTER_I",e[e.LATIN_SMALL_LETTER_J=106]="LATIN_SMALL_LETTER_J",e[e.LATIN_SMALL_LETTER_K=107]="LATIN_SMALL_LETTER_K",e[e.LATIN_SMALL_LETTER_L=108]="LATIN_SMALL_LETTER_L",e[e.LATIN_SMALL_LETTER_M=109]="LATIN_SMALL_LETTER_M",e[e.LATIN_SMALL_LETTER_N=110]="LATIN_SMALL_LETTER_N",e[e.LATIN_SMALL_LETTER_O=111]="LATIN_SMALL_LETTER_O",e[e.LATIN_SMALL_LETTER_P=112]="LATIN_SMALL_LETTER_P",e[e.LATIN_SMALL_LETTER_Q=113]="LATIN_SMALL_LETTER_Q",e[e.LATIN_SMALL_LETTER_R=114]="LATIN_SMALL_LETTER_R",e[e.LATIN_SMALL_LETTER_S=115]="LATIN_SMALL_LETTER_S",e[e.LATIN_SMALL_LETTER_T=116]="LATIN_SMALL_LETTER_T",e[e.LATIN_SMALL_LETTER_U=117]="LATIN_SMALL_LETTER_U",e[e.LATIN_SMALL_LETTER_V=118]="LATIN_SMALL_LETTER_V",e[e.LATIN_SMALL_LETTER_W=119]="LATIN_SMALL_LETTER_W",e[e.LATIN_SMALL_LETTER_X=120]="LATIN_SMALL_LETTER_X",e[e.LATIN_SMALL_LETTER_Y=121]="LATIN_SMALL_LETTER_Y",e[e.LATIN_SMALL_LETTER_Z=122]="LATIN_SMALL_LETTER_Z",e[e.LEFT_CURLY_BRACKET=123]="LEFT_CURLY_BRACKET",e[e.VERTICAL_LINE=124]="VERTICAL_LINE",e[e.RIGHT_CURLY_BRACKET=125]="RIGHT_CURLY_BRACKET",e[e.TILDE=126]="TILDE"}(ze||(ze={}));const Qe={[ze.QUOTATION_MARK]:ze.QUOTATION_MARK,[ze.REVERSE_SOLIDUS]:ze.REVERSE_SOLIDUS,[ze.SOLIDUS]:ze.SOLIDUS,[ze.LATIN_SMALL_LETTER_B]:ze.BACKSPACE,[ze.LATIN_SMALL_LETTER_F]:ze.FORM_FEED,[ze.LATIN_SMALL_LETTER_N]:ze.NEWLINE,[ze.LATIN_SMALL_LETTER_R]:ze.CARRIAGE_RETURN,[ze.LATIN_SMALL_LETTER_T]:ze.TAB};class Je{constructor(){this.decoder=new TextDecoder("utf-8"),this.strings=[],this.byteLength=0}appendChar(e){this.strings.push(String.fromCharCode(e)),this.byteLength+=1}appendBuf(e,t=0,s=e.length){this.strings.push(this.decoder.decode(e.subarray(t,s))),this.byteLength+=s-t}reset(){this.strings=[],this.byteLength=0}toString(){return this.strings.join("")}}class Ye{constructor(e){this.decoder=new TextDecoder("utf-8"),this.bufferOffset=0,this.string="",this.byteLength=0,this.buffer=new Uint8Array(e)}appendChar(e){this.bufferOffset>=this.buffer.length&&this.flushStringBuffer(),this.buffer[this.bufferOffset++]=e,this.byteLength+=1}appendBuf(e,t=0,s=e.length){const i=s-t;this.bufferOffset+i>this.buffer.length&&this.flushStringBuffer(),this.buffer.set(e.subarray(t,s),this.bufferOffset),this.bufferOffset+=i,this.byteLength+=i}flushStringBuffer(){this.string+=this.decoder.decode(this.buffer.subarray(0,this.bufferOffset)),this.bufferOffset=0}reset(){this.string="",this.bufferOffset=0,this.byteLength=0}toString(){return this.flushStringBuffer(),this.string}}var Ze,Xe;function et(e){return["START","ENDED","ERROR","TRUE1","TRUE2","TRUE3","FALSE1","FALSE2","FALSE3","FALSE4","NULL1","NULL2","NULL3","STRING_DEFAULT","STRING_AFTER_BACKSLASH","STRING_UNICODE_DIGIT_1","STRING_UNICODE_DIGIT_2","STRING_UNICODE_DIGIT_3","STRING_UNICODE_DIGIT_4","STRING_INCOMPLETE_CHAR","NUMBER_AFTER_INITIAL_MINUS","NUMBER_AFTER_INITIAL_ZERO","NUMBER_AFTER_INITIAL_NON_ZERO","NUMBER_AFTER_FULL_STOP","NUMBER_AFTER_DECIMAL","NUMBER_AFTER_E","NUMBER_AFTER_E_AND_SIGN","NUMBER_AFTER_E_AND_DIGIT","SEPARATOR","BOM_OR_START","BOM"][e]}!function(e){e[e.LEFT_BRACE=0]="LEFT_BRACE",e[e.RIGHT_BRACE=1]="RIGHT_BRACE",e[e.LEFT_BRACKET=2]="LEFT_BRACKET",e[e.RIGHT_BRACKET=3]="RIGHT_BRACKET",e[e.COLON=4]="COLON",e[e.COMMA=5]="COMMA",e[e.TRUE=6]="TRUE",e[e.FALSE=7]="FALSE",e[e.NULL=8]="NULL",e[e.STRING=9]="STRING",e[e.NUMBER=10]="NUMBER",e[e.SEPARATOR=11]="SEPARATOR"}(Ze||(Ze={})),function(e){e[e.START=0]="START",e[e.ENDED=1]="ENDED",e[e.ERROR=2]="ERROR",e[e.TRUE1=3]="TRUE1",e[e.TRUE2=4]="TRUE2",e[e.TRUE3=5]="TRUE3",e[e.FALSE1=6]="FALSE1",e[e.FALSE2=7]="FALSE2",e[e.FALSE3=8]="FALSE3",e[e.FALSE4=9]="FALSE4",e[e.NULL1=10]="NULL1",e[e.NULL2=11]="NULL2",e[e.NULL3=12]="NULL3",e[e.STRING_DEFAULT=13]="STRING_DEFAULT",e[e.STRING_AFTER_BACKSLASH=14]="STRING_AFTER_BACKSLASH",e[e.STRING_UNICODE_DIGIT_1=15]="STRING_UNICODE_DIGIT_1",e[e.STRING_UNICODE_DIGIT_2=16]="STRING_UNICODE_DIGIT_2",e[e.STRING_UNICODE_DIGIT_3=17]="STRING_UNICODE_DIGIT_3",e[e.STRING_UNICODE_DIGIT_4=18]="STRING_UNICODE_DIGIT_4",e[e.STRING_INCOMPLETE_CHAR=19]="STRING_INCOMPLETE_CHAR",e[e.NUMBER_AFTER_INITIAL_MINUS=20]="NUMBER_AFTER_INITIAL_MINUS",e[e.NUMBER_AFTER_INITIAL_ZERO=21]="NUMBER_AFTER_INITIAL_ZERO",e[e.NUMBER_AFTER_INITIAL_NON_ZERO=22]="NUMBER_AFTER_INITIAL_NON_ZERO",e[e.NUMBER_AFTER_FULL_STOP=23]="NUMBER_AFTER_FULL_STOP",e[e.NUMBER_AFTER_DECIMAL=24]="NUMBER_AFTER_DECIMAL",e[e.NUMBER_AFTER_E=25]="NUMBER_AFTER_E",e[e.NUMBER_AFTER_E_AND_SIGN=26]="NUMBER_AFTER_E_AND_SIGN",e[e.NUMBER_AFTER_E_AND_DIGIT=27]="NUMBER_AFTER_E_AND_DIGIT",e[e.SEPARATOR=28]="SEPARATOR",e[e.BOM_OR_START=29]="BOM_OR_START",e[e.BOM=30]="BOM"}(Xe||(Xe={}));const tt={stringBufferSize:0,numberBufferSize:0,separator:void 0,emitPartialTokens:!1};class st extends Error{constructor(e){super(e),Object.setPrototypeOf(this,st.prototype)}}class it{constructor(e){this.state=Xe.BOM_OR_START,this.bomIndex=0,this.separatorIndex=0,this.escapedCharsByteLength=0,this.bytes_remaining=0,this.bytes_in_sequence=0,this.char_split_buffer=new Uint8Array(4),this.encoder=new TextEncoder,this.offset=-1,e=Object.assign(Object.assign({},tt),e),this.emitPartialTokens=!0===e.emitPartialTokens,this.bufferedString=e.stringBufferSize&&e.stringBufferSize>4?new Ye(e.stringBufferSize):new Je,this.bufferedNumber=e.numberBufferSize&&e.numberBufferSize>0?new Ye(e.numberBufferSize):new Je,this.separator=e.separator,this.separatorBytes=e.separator?this.encoder.encode(e.separator):void 0}get isEnded(){return this.state===Xe.ENDED}write(e){try{let t;if(e instanceof Uint8Array)t=e;else if("string"==typeof e)t=this.encoder.encode(e);else if(Array.isArray(e))t=Uint8Array.from(e);else{if(!ArrayBuffer.isView(e))throw new TypeError("Unexpected type. The `write` function only accepts Arrays, TypedArrays and Strings.");t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}for(let s=0;s<t.length;s+=1){const i=t[s];switch(this.state){case Xe.BOM_OR_START:if(e instanceof Uint8Array&&239===i){this.bom=[239,187,191],this.bomIndex+=1,this.state=Xe.BOM;continue}if(e instanceof Uint16Array){if(254===i){this.bom=[254,255],this.bomIndex+=1,this.state=Xe.BOM;continue}if(255===i){this.bom=[255,254],this.bomIndex+=1,this.state=Xe.BOM;continue}}if(e instanceof Uint32Array){if(0===i){this.bom=[0,0,254,255],this.bomIndex+=1,this.state=Xe.BOM;continue}if(255===i){this.bom=[255,254,0,0],this.bomIndex+=1,this.state=Xe.BOM;continue}}case Xe.START:if(this.offset+=1,this.separatorBytes&&i===this.separatorBytes[0]){if(1===this.separatorBytes.length){this.state=Xe.START,this.onToken({token:Ze.SEPARATOR,value:this.separator,offset:this.offset+this.separatorBytes.length-1});continue}this.state=Xe.SEPARATOR;continue}if(i===ze.SPACE||i===ze.NEWLINE||i===ze.CARRIAGE_RETURN||i===ze.TAB)continue;if(i===ze.LEFT_CURLY_BRACKET){this.onToken({token:Ze.LEFT_BRACE,value:"{",offset:this.offset});continue}if(i===ze.RIGHT_CURLY_BRACKET){this.onToken({token:Ze.RIGHT_BRACE,value:"}",offset:this.offset});continue}if(i===ze.LEFT_SQUARE_BRACKET){this.onToken({token:Ze.LEFT_BRACKET,value:"[",offset:this.offset});continue}if(i===ze.RIGHT_SQUARE_BRACKET){this.onToken({token:Ze.RIGHT_BRACKET,value:"]",offset:this.offset});continue}if(i===ze.COLON){this.onToken({token:Ze.COLON,value:":",offset:this.offset});continue}if(i===ze.COMMA){this.onToken({token:Ze.COMMA,value:",",offset:this.offset});continue}if(i===ze.LATIN_SMALL_LETTER_T){this.state=Xe.TRUE1;continue}if(i===ze.LATIN_SMALL_LETTER_F){this.state=Xe.FALSE1;continue}if(i===ze.LATIN_SMALL_LETTER_N){this.state=Xe.NULL1;continue}if(i===ze.QUOTATION_MARK){this.bufferedString.reset(),this.escapedCharsByteLength=0,this.state=Xe.STRING_DEFAULT;continue}if(i>=ze.DIGIT_ONE&&i<=ze.DIGIT_NINE){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_INITIAL_NON_ZERO;continue}if(i===ze.DIGIT_ZERO){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_INITIAL_ZERO;continue}if(i===ze.HYPHEN_MINUS){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_INITIAL_MINUS;continue}break;case Xe.STRING_DEFAULT:if(i===ze.QUOTATION_MARK){const e=this.bufferedString.toString();this.state=Xe.START,this.onToken({token:Ze.STRING,value:e,offset:this.offset}),this.offset+=this.escapedCharsByteLength+this.bufferedString.byteLength+1;continue}if(i===ze.REVERSE_SOLIDUS){this.state=Xe.STRING_AFTER_BACKSLASH;continue}if(i>=128){if(this.bytes_in_sequence=i>=194&&i<=223?2:i<=239?3:4,this.bytes_in_sequence<=t.length-s){this.bufferedString.appendBuf(t,s,s+this.bytes_in_sequence),s+=this.bytes_in_sequence-1;continue}this.bytes_remaining=s+this.bytes_in_sequence-t.length,this.char_split_buffer.set(t.subarray(s)),s=t.length-1,this.state=Xe.STRING_INCOMPLETE_CHAR;continue}if(i>=ze.SPACE){this.bufferedString.appendChar(i);continue}break;case Xe.STRING_INCOMPLETE_CHAR:this.char_split_buffer.set(t.subarray(s,s+this.bytes_remaining),this.bytes_in_sequence-this.bytes_remaining),this.bufferedString.appendBuf(this.char_split_buffer,0,this.bytes_in_sequence),s=this.bytes_remaining-1,this.state=Xe.STRING_DEFAULT;continue;case Xe.STRING_AFTER_BACKSLASH:const r=Qe[i];if(r){this.bufferedString.appendChar(r),this.escapedCharsByteLength+=1,this.state=Xe.STRING_DEFAULT;continue}if(i===ze.LATIN_SMALL_LETTER_U){this.unicode="",this.state=Xe.STRING_UNICODE_DIGIT_1;continue}break;case Xe.STRING_UNICODE_DIGIT_1:case Xe.STRING_UNICODE_DIGIT_2:case Xe.STRING_UNICODE_DIGIT_3:if(i>=ze.DIGIT_ZERO&&i<=ze.DIGIT_NINE||i>=ze.LATIN_CAPITAL_LETTER_A&&i<=ze.LATIN_CAPITAL_LETTER_F||i>=ze.LATIN_SMALL_LETTER_A&&i<=ze.LATIN_SMALL_LETTER_F){this.unicode+=String.fromCharCode(i),this.state+=1;continue}break;case Xe.STRING_UNICODE_DIGIT_4:if(i>=ze.DIGIT_ZERO&&i<=ze.DIGIT_NINE||i>=ze.LATIN_CAPITAL_LETTER_A&&i<=ze.LATIN_CAPITAL_LETTER_F||i>=ze.LATIN_SMALL_LETTER_A&&i<=ze.LATIN_SMALL_LETTER_F){const e=parseInt(this.unicode+String.fromCharCode(i),16);let t;if(void 0===this.highSurrogate){if(e>=55296&&e<=56319){this.highSurrogate=e,this.state=Xe.STRING_DEFAULT;continue}t=String.fromCharCode(e)}else t=e>=56320&&e<=57343?String.fromCharCode(this.highSurrogate,e):String.fromCharCode(this.highSurrogate),this.highSurrogate=void 0;const s=this.encoder.encode(t);this.bufferedString.appendBuf(s),this.escapedCharsByteLength+=6-s.byteLength,this.state=Xe.STRING_DEFAULT;continue}break;case Xe.NUMBER_AFTER_INITIAL_MINUS:if(i===ze.DIGIT_ZERO){this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_INITIAL_ZERO;continue}if(i>=ze.DIGIT_ONE&&i<=ze.DIGIT_NINE){this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_INITIAL_NON_ZERO;continue}break;case Xe.NUMBER_AFTER_INITIAL_ZERO:if(i===ze.FULL_STOP){this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_FULL_STOP;continue}if(i===ze.LATIN_SMALL_LETTER_E||i===ze.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_E;continue}s-=1,this.state=Xe.START,this.emitNumber();continue;case Xe.NUMBER_AFTER_INITIAL_NON_ZERO:if(i>=ze.DIGIT_ZERO&&i<=ze.DIGIT_NINE){this.bufferedNumber.appendChar(i);continue}if(i===ze.FULL_STOP){this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_FULL_STOP;continue}if(i===ze.LATIN_SMALL_LETTER_E||i===ze.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_E;continue}s-=1,this.state=Xe.START,this.emitNumber();continue;case Xe.NUMBER_AFTER_FULL_STOP:if(i>=ze.DIGIT_ZERO&&i<=ze.DIGIT_NINE){this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_DECIMAL;continue}break;case Xe.NUMBER_AFTER_DECIMAL:if(i>=ze.DIGIT_ZERO&&i<=ze.DIGIT_NINE){this.bufferedNumber.appendChar(i);continue}if(i===ze.LATIN_SMALL_LETTER_E||i===ze.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_E;continue}s-=1,this.state=Xe.START,this.emitNumber();continue;case Xe.NUMBER_AFTER_E:if(i===ze.PLUS_SIGN||i===ze.HYPHEN_MINUS){this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_E_AND_SIGN;continue}case Xe.NUMBER_AFTER_E_AND_SIGN:if(i>=ze.DIGIT_ZERO&&i<=ze.DIGIT_NINE){this.bufferedNumber.appendChar(i),this.state=Xe.NUMBER_AFTER_E_AND_DIGIT;continue}break;case Xe.NUMBER_AFTER_E_AND_DIGIT:if(i>=ze.DIGIT_ZERO&&i<=ze.DIGIT_NINE){this.bufferedNumber.appendChar(i);continue}s-=1,this.state=Xe.START,this.emitNumber();continue;case Xe.TRUE1:if(i===ze.LATIN_SMALL_LETTER_R){this.state=Xe.TRUE2;continue}break;case Xe.TRUE2:if(i===ze.LATIN_SMALL_LETTER_U){this.state=Xe.TRUE3;continue}break;case Xe.TRUE3:if(i===ze.LATIN_SMALL_LETTER_E){this.state=Xe.START,this.onToken({token:Ze.TRUE,value:!0,offset:this.offset}),this.offset+=3;continue}break;case Xe.FALSE1:if(i===ze.LATIN_SMALL_LETTER_A){this.state=Xe.FALSE2;continue}break;case Xe.FALSE2:if(i===ze.LATIN_SMALL_LETTER_L){this.state=Xe.FALSE3;continue}break;case Xe.FALSE3:if(i===ze.LATIN_SMALL_LETTER_S){this.state=Xe.FALSE4;continue}break;case Xe.FALSE4:if(i===ze.LATIN_SMALL_LETTER_E){this.state=Xe.START,this.onToken({token:Ze.FALSE,value:!1,offset:this.offset}),this.offset+=4;continue}break;case Xe.NULL1:if(i===ze.LATIN_SMALL_LETTER_U){this.state=Xe.NULL2;continue}break;case Xe.NULL2:if(i===ze.LATIN_SMALL_LETTER_L){this.state=Xe.NULL3;continue}break;case Xe.NULL3:if(i===ze.LATIN_SMALL_LETTER_L){this.state=Xe.START,this.onToken({token:Ze.NULL,value:null,offset:this.offset}),this.offset+=3;continue}break;case Xe.SEPARATOR:if(this.separatorIndex+=1,!this.separatorBytes||i!==this.separatorBytes[this.separatorIndex])break;this.separatorIndex===this.separatorBytes.length-1&&(this.state=Xe.START,this.onToken({token:Ze.SEPARATOR,value:this.separator,offset:this.offset+this.separatorIndex}),this.separatorIndex=0);continue;case Xe.BOM:if(i===this.bom[this.bomIndex]){if(this.bomIndex===this.bom.length-1){this.state=Xe.START,this.bom=void 0,this.bomIndex=0;continue}this.bomIndex+=1;continue}break;case Xe.ENDED:if(i===ze.SPACE||i===ze.NEWLINE||i===ze.CARRIAGE_RETURN||i===ze.TAB)continue}throw new st(`Unexpected "${String.fromCharCode(i)}" at position "${s}" in state ${et(this.state)}`)}if(this.emitPartialTokens)switch(this.state){case Xe.TRUE1:case Xe.TRUE2:case Xe.TRUE3:this.onToken({token:Ze.TRUE,value:!0,offset:this.offset,partial:!0});break;case Xe.FALSE1:case Xe.FALSE2:case Xe.FALSE3:case Xe.FALSE4:this.onToken({token:Ze.FALSE,value:!1,offset:this.offset,partial:!0});break;case Xe.NULL1:case Xe.NULL2:case Xe.NULL3:this.onToken({token:Ze.NULL,value:null,offset:this.offset,partial:!0});break;case Xe.STRING_DEFAULT:{const e=this.bufferedString.toString();this.onToken({token:Ze.STRING,value:e,offset:this.offset,partial:!0});break}case Xe.NUMBER_AFTER_INITIAL_ZERO:case Xe.NUMBER_AFTER_INITIAL_NON_ZERO:case Xe.NUMBER_AFTER_DECIMAL:case Xe.NUMBER_AFTER_E_AND_DIGIT:try{this.onToken({token:Ze.NUMBER,value:this.parseNumber(this.bufferedNumber.toString()),offset:this.offset,partial:!0})}catch(e){}}}catch(e){this.error(e)}}emitNumber(){this.onToken({token:Ze.NUMBER,value:this.parseNumber(this.bufferedNumber.toString()),offset:this.offset}),this.offset+=this.bufferedNumber.byteLength-1}parseNumber(e){return Number(e)}error(e){this.state!==Xe.ENDED&&(this.state=Xe.ERROR),this.onError(e)}end(){switch(this.state){case Xe.NUMBER_AFTER_INITIAL_ZERO:case Xe.NUMBER_AFTER_INITIAL_NON_ZERO:case Xe.NUMBER_AFTER_DECIMAL:case Xe.NUMBER_AFTER_E_AND_DIGIT:this.state=Xe.ENDED,this.emitNumber(),this.onEnd();break;case Xe.BOM_OR_START:case Xe.START:case Xe.ERROR:case Xe.SEPARATOR:this.state=Xe.ENDED,this.onEnd();break;default:this.error(new st(`Tokenizer ended in the middle of a token (state: ${et(this.state)}). Either not all the data was received or the data was invalid.`))}}onToken(e){throw new st('Can\'t emit tokens before the "onToken" callback has been set up.')}onError(e){throw e}onEnd(){}}var rt,nt;function at(e){return["VALUE","KEY","COLON","COMMA","ENDED","ERROR","SEPARATOR"][e]}!function(e){e[e.OBJECT=0]="OBJECT",e[e.ARRAY=1]="ARRAY"}(rt||(rt={})),function(e){e[e.VALUE=0]="VALUE",e[e.KEY=1]="KEY",e[e.COLON=2]="COLON",e[e.COMMA=3]="COMMA",e[e.ENDED=4]="ENDED",e[e.ERROR=5]="ERROR",e[e.SEPARATOR=6]="SEPARATOR"}(nt||(nt={}));const ot={paths:void 0,keepStack:!0,separator:void 0,emitPartialValues:!1};class ct extends Error{constructor(e){super(e),Object.setPrototypeOf(this,ct.prototype)}}class _t{constructor(e){this.state=nt.VALUE,this.mode=void 0,this.key=void 0,this.value=void 0,this.stack=[],(e=Object.assign(Object.assign({},ot),e)).paths&&(this.paths=e.paths.map((e=>{if(void 0===e||"$*"===e)return;if(!e.startsWith("$"))throw new ct(`Invalid selector "${e}". Should start with "$".`);const t=e.split(".").slice(1);if(t.includes(""))throw new ct(`Invalid selector "${e}". ".." syntax not supported.`);return t}))),this.keepStack=e.keepStack||!1,this.separator=e.separator,e.emitPartialValues||(this.emitPartial=()=>{})}shouldEmit(){return!this.paths||this.paths.some((e=>{var t;if(void 0===e)return!0;if(e.length!==this.stack.length)return!1;for(let t=0;t<e.length-1;t++){const s=e[t],i=this.stack[t+1].key;if("*"!==s&&s!==(null==i?void 0:i.toString()))return!1}const s=e[e.length-1];return"*"===s||s===(null===(t=this.key)||void 0===t?void 0:t.toString())}))}push(){this.stack.push({key:this.key,value:this.value,mode:this.mode,emit:this.shouldEmit()})}pop(){const e=this.value;let t;({key:this.key,value:this.value,mode:this.mode,emit:t}=this.stack.pop()),this.state=void 0!==this.mode?nt.COMMA:nt.VALUE,this.emit(e,t)}emit(e,t){!this.keepStack&&this.value&&this.stack.every((e=>!e.emit))&&delete this.value[this.key],t&&this.onValue({value:e,key:this.key,parent:this.value,stack:this.stack}),0===this.stack.length&&(this.separator?this.state=nt.SEPARATOR:void 0===this.separator&&this.end())}emitPartial(e){this.shouldEmit()&&(this.state!==nt.KEY?this.onValue({value:e,key:this.key,parent:this.value,stack:this.stack,partial:!0}):this.onValue({value:void 0,key:e,parent:this.value,stack:this.stack,partial:!0}))}get isEnded(){return this.state===nt.ENDED}write({token:e,value:t,partial:s}){try{if(s)return void this.emitPartial(t);if(this.state===nt.VALUE){if(e===Ze.STRING||e===Ze.NUMBER||e===Ze.TRUE||e===Ze.FALSE||e===Ze.NULL)return this.mode===rt.OBJECT?(this.value[this.key]=t,this.state=nt.COMMA):this.mode===rt.ARRAY&&(this.value.push(t),this.state=nt.COMMA),void this.emit(t,this.shouldEmit());if(e===Ze.LEFT_BRACE){if(this.push(),this.mode===rt.OBJECT)this.value=this.value[this.key]={};else if(this.mode===rt.ARRAY){const e={};this.value.push(e),this.value=e}else this.value={};return this.mode=rt.OBJECT,this.state=nt.KEY,this.key=void 0,void this.emitPartial()}if(e===Ze.LEFT_BRACKET){if(this.push(),this.mode===rt.OBJECT)this.value=this.value[this.key]=[];else if(this.mode===rt.ARRAY){const e=[];this.value.push(e),this.value=e}else this.value=[];return this.mode=rt.ARRAY,this.state=nt.VALUE,this.key=0,void this.emitPartial()}if(this.mode===rt.ARRAY&&e===Ze.RIGHT_BRACKET&&0===this.value.length)return void this.pop()}if(this.state===nt.KEY){if(e===Ze.STRING)return this.key=t,this.state=nt.COLON,void this.emitPartial();if(e===Ze.RIGHT_BRACE&&0===Object.keys(this.value).length)return void this.pop()}if(this.state===nt.COLON&&e===Ze.COLON)return void(this.state=nt.VALUE);if(this.state===nt.COMMA){if(e===Ze.COMMA){if(this.mode===rt.ARRAY)return this.state=nt.VALUE,void(this.key+=1);if(this.mode===rt.OBJECT)return void(this.state=nt.KEY)}if(e===Ze.RIGHT_BRACE&&this.mode===rt.OBJECT||e===Ze.RIGHT_BRACKET&&this.mode===rt.ARRAY)return void this.pop()}if(this.state===nt.SEPARATOR&&e===Ze.SEPARATOR&&t===this.separator)return void(this.state=nt.VALUE);if(e===Ze.SEPARATOR&&this.state!==nt.SEPARATOR&&Array.from(t).map((e=>e.charCodeAt(0))).every((e=>e===ze.SPACE||e===ze.NEWLINE||e===ze.CARRIAGE_RETURN||e===ze.TAB)))return;throw new ct(`Unexpected ${Ze[e]} (${JSON.stringify(t)}) in state ${at(this.state)}`)}catch(e){this.error(e)}}error(e){this.state!==nt.ENDED&&(this.state=nt.ERROR),this.onError(e)}end(){this.state!==nt.VALUE&&this.state!==nt.SEPARATOR||this.stack.length>0?this.error(new Error(`Parser ended in mid-parsing (state: ${at(this.state)}). Either not all the data was received or the data was invalid.`)):(this.state=nt.ENDED,this.onEnd())}onValue(e){throw new ct('Can\'t emit data before the "onValue" callback has been set up.')}onError(e){throw e}onEnd(){}}class lt{constructor(e={}){this.tokenizer=new it(e),this.tokenParser=new _t(e),this.tokenizer.onToken=this.tokenParser.write.bind(this.tokenParser),this.tokenizer.onEnd=()=>{this.tokenParser.isEnded||this.tokenParser.end()},this.tokenParser.onError=this.tokenizer.error.bind(this.tokenizer),this.tokenParser.onEnd=()=>{this.tokenizer.isEnded||this.tokenizer.end()}}get isEnded(){return this.tokenizer.isEnded&&this.tokenParser.isEnded}write(e){this.tokenizer.write(e)}end(){this.tokenizer.end()}set onToken(e){this.tokenizer.onToken=t=>{e(t),this.tokenParser.write(t)}}set onValue(e){this.tokenParser.onValue=e}set onError(e){this.tokenizer.onError=e}set onEnd(e){this.tokenParser.onEnd=()=>{this.tokenizer.isEnded||this.tokenizer.end(),e.call(this.tokenParser)}}}var ht;function ut(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}(ht||(ht={})).STREAM_PARSER_JSON_ERROR="chat_sdk_pull_stream_parser_error";class dt{__init(){this.parserOptions={emitPartialValues:!0,emitPartialTokens:!0,keepStack:!0}}__init2(){this.jsonParserMap={}}__init3(){this.jsonParserMetaMap={}}constructor(e){dt.prototype.__init.call(this),dt.prototype.__init2.call(this),dt.prototype.__init3.call(this),dt.prototype.__init4.call(this),dt.prototype.__init5.call(this),dt.prototype.__init6.call(this),dt.prototype.__init7.call(this),dt.prototype.__init8.call(this);const{reportLogWithScope:t}=e;this.reportLogWithScope=t}__init4(){this.getJsonParser=e=>{if(this.jsonParserMap[e])return this.jsonParserMap[e];const t=new lt(this.parserOptions);return this.jsonParserMap[e]=t,this.jsonParserMetaMap[e]={isError:!1},this.jsonParserMap[e]}}__init5(){this.updateJsonParserMeta=(e,t)=>{_e(this.jsonParserMetaMap,e,t)}}__init6(){this.write=(e,t,{onValue:s,onError:i,onEnd:r,onToken:n})=>{const a=this.getJsonParser(e);ut([this,"access",e=>e.jsonParserMetaMap,"access",t=>t[e],"optionalAccess",e=>e.isError])||a.isEnded||(a.onValue=s,a.onError=t=>{this.updateJsonParserMeta(e,(e=>({...e,isError:!0}))),ut([i,"optionalCall",e=>e(t)]),this.reportLogWithScope.slardarErrorEvent({error:t,eventName:ht.STREAM_PARSER_JSON_ERROR,meta:{msgId:e}})},a.onEnd=()=>{this.clearByMsgId(e),ut([r,"optionalCall",e=>e()])},n&&(a.onToken=n),a.write(t))}}__init7(){this.clearParserCallback=e=>{e.onValue=d,e.onError=d,e.onEnd=d,e.onToken=d}}__init8(){this.clearByMsgId=e=>{const t=this.jsonParserMap[e];t&&this.clearParserCallback(t),delete this.jsonParserMap[e],delete this.jsonParserMetaMap[e]}}destroy(){Object.values(this.jsonParserMap).forEach(this.clearParserCallback),this.jsonParserMap={},this.jsonParserMetaMap={}}}const pt={toolRequestStreamingParameters:!1},gt={v1:{toolRequestStreamingParameters:!0}},Tt=e=>{return"tool_request"===e.type&&(t=e.version,t&>[t]||pt).toolRequestStreamingParameters;var t};function Et(e,t){return null!=e?e:t()}function mt(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}class ft{constructor(e){const{initMessageBuffer:t=[],reportLogWithScope:i}=e;this.streamMessageBuffer=s.cloneDeep(t),this.streamChunkBuffer=s.cloneDeep(t),this.streamParserJson=new dt({reportLogWithScope:i}),this.streamMessageBuffer.forEach((e=>{Tt(e)&&this.streamParserJson.write(e.msg_id,mt([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters])||"",{onValue:d})}))}pushChunk(e){this.streamChunkBuffer.push(e)}clearMessageBuffer(){this.streamMessageBuffer=[],this.streamChunkBuffer=[],this.streamParserJson.destroy()}getChunkByMessageId(e){return this.streamChunkBuffer.filter((t=>t.msg_id===e))}concatBatchAndUpdateMessage(e){const{msgId:t,chunks:i}=e;if(0===i.length)return;i.forEach((e=>{this.streamChunkBuffer.push(e)}));const r=i.at(0),n=this.streamMessageBuffer.findIndex((e=>r?""!==t?e.msg_id===t:""===e.msg_id&&e.type===r.type&&e.query_msg_id===r.query_msg_id:e.msg_id===t)),a=-1!==n?this.streamMessageBuffer[n]:void 0,o=He(a,i);if(!o)return;const c=Tt(o);return c&&i.forEach((e=>{this.streamParserJson.write(e.msg_id,mt([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters])||"",{onValue:(...e)=>{const t=(e=>{const{key:t,value:i,stack:r,partial:n,parent:a}=e,o=r.slice(1),c=o.at(0);if(ae(t)||ae(i))return;const _=s.cloneDeep(a),l=s.cloneDeep(i);if(!c){if(!n)return _||l;if(!_)return;return _[t]=l,_}const h=s.cloneDeep(c.value);return n?(_e(h,o.map((e=>e.key)).filter((e=>!ae(e))).concat(t),(()=>l)),h):h})(...e);t&&(o.streamParametersContent=t)}})})),!o.streamParametersContent&&c&&a&&(o.streamParametersContent=a.streamParametersContent),-1===n?this.streamMessageBuffer.push(o):this.streamMessageBuffer.splice(n,1,o),o}}const Lt=1073741823;class At{__init(){this.shallowCloneStreamBuffer=()=>({streamMessageBuffer:[...this.streamBuffer.streamMessageBuffer],streamChunkBuffer:[...this.streamBuffer.streamChunkBuffer]})}__init2(){this.getStreamBuffer=()=>this.shallowCloneStreamBuffer()}__init3(){this.getStreamBufferWithMeta=()=>{const e=this.shallowCloneStreamBuffer();return{...e,...this.simpleMessageDump.getBufferMeta(e.streamMessageBuffer)}}}__init4(){this.getStreamBufferSnapshot=()=>this.simpleMessageDump.getStreamBufferSnapshot()}constructor(e){At.prototype.__init.call(this),At.prototype.__init2.call(this),At.prototype.__init3.call(this),At.prototype.__init4.call(this),At.prototype.__init5.call(this),At.prototype.__init6.call(this),At.prototype.__init7.call(this),At.prototype.__init8.call(this);const{getEnableDebug:t,key:s,reportLogWithScope:i,initMaxSequenceId:r}=e;this.getEnableDebug=t,this.maxSequenceId=Et(r,(()=>0)),this.enableChunkProcessedCheck=Et(e.enableChunkProcessedCheck,(()=>!1)),this.streamBuffer=new ft(e),this.debugLogger=new $e({reportLogWithScope:i,getEnableDebug:t,getLogPayload:()=>this.getStreamBuffer(),mark:"ChunkProcessor"}),this.simpleMessageDump=new Ve({key:s})}__init5(){this.startDebugLog=e=>{this.debugLogger.isDebugging||this.debugLogger.startDebugLog(e)}}__init6(){this.stopDebugLog=()=>{this.debugLogger.stopDebugLog()}}isStreamBufferEmpty(){return 0===this.streamBuffer.streamChunkBuffer.length&&0===this.streamBuffer.streamMessageBuffer.length}__init7(){this.clearMessageBuffer=()=>{this.stopDebugLog(),this.simpleMessageDump.recordStreamBuffer(this.shallowCloneStreamBuffer()),this.streamBuffer.clearMessageBuffer()}}addBatchAndProcess(e){const t=e.chunks.at(0);if(t)return this.startDebugLog(t.query_msg_id),this.streamBuffer.concatBatchAndUpdateMessage(e)}checkInBufferProcessed(e){return""===e.msg_id?this.streamBuffer.streamMessageBuffer.some((t=>""===t.msg_id&&t.type===e.type&&t.query_msg_id===e.query_msg_id&&t.sequence_id>=e.sequence_id)):this.streamBuffer.streamMessageBuffer.some((t=>t.msg_id===e.msg_id&&t.sequence_id>=e.sequence_id))}checkMessageHasProcessed(e){if(this.checkInBufferProcessed(e))return!0;if(!this.enableChunkProcessedCheck)return!1;if(0===this.maxSequenceId)return this.maxSequenceId=e.sequence_id,!1;const t=this.maxSequenceId,s=e.sequence_id,i=t>Lt,r=s>Lt;return i&&!r?(this.maxSequenceId=s,!1):!(i||!r)||(!(s>=t)||(this.maxSequenceId=s,!1))}getProcessedMessageByChunk(e){return this.streamBuffer.streamMessageBuffer.find((t=>t.msg_id===e.msg_id))}getProcessedMessageByMessageId(e){return this.streamBuffer.streamMessageBuffer.find((t=>t.msg_id===e))}getAckMessageByLocalMessageId(e){return this.streamBuffer.streamMessageBuffer.find((t=>mt([t,"access",e=>e.content,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id])===e&&"message_start"===t.type))}getFirstReplyMessageByChunk(e){if(this.streamBuffer.streamMessageBuffer.some((t=>"message_start"===t.type&&t.query_msg_id===e.query_msg_id)))return this.streamBuffer.streamMessageBuffer.find((t=>"message_start"!==t.type&&t.query_msg_id===e.query_msg_id))}getAckMessage(){return this.streamBuffer.streamMessageBuffer.find((e=>"message_start"===e.type))}isFirstReplyMessage(e){return!!this.getAckMessage()&&!this.getFirstReplyMessageByChunk(e)}getReplyMessagesByQueryMsgId(e){return this.streamBuffer.streamMessageBuffer.filter((t=>"message_start"!==t.type&&t.query_msg_id===e))}__init8(){this.destroy=()=>{this.debugLogger.destroy(),this.clearMessageBuffer(),this.simpleMessageDump.clear()}}}var St,Rt,Ct;!function(e){e.MESSAGE_RECEIVED_AND_UPDATE="message_received_and_update";e.MESSAGE_PULLING_STATUS="message_pulling_status";e.SEND_MESSAGE_ERROR="send_message_error";e.CHANNEL_STATUS="channel_status";e.CONTEXT_CHANGE="context_change";e.SESSION_CHANGED="session_changed"}(St||(St={})),function(e){e[e.Unknown=0]="Unknown";e[e.Prev=1]="Prev";e[e.Next=2]="Next"}(Rt||(Rt={}));class vt{__init(){this.timer=null}__init2(){this.timeoutMs=12e4}constructor(e){vt.prototype.__init.call(this),vt.prototype.__init2.call(this),this.reportLogWithScope=e.reportLogWithScope,e.timeoutMs&&(this.timeoutMs=e.timeoutMs),this.getChannelOptions=e.getChannelOptions}flushMessage(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout((()=>{this.reportLogWithScope.slardarErrorEvent({eventName:`${this.getChannelOptions().channelName}_OnMessageTimeout`,error:new Error("OnMessageTimeout - 超时未收到消息"),meta:{...this.getChannelOptions(),log_id:e.log_id,query_msg_id:e.query_msg_id,lastMessage:e}}),this.timer=null}),this.timeoutMs)}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}}!function(e){e.MESSAGE_END="message_end";e.MESSAGE_SEND_SUCCESS="message_send_success";e.MESSAGE_SEND_AND_RECEIVE_ERROR="message_send_and_receive_error";e.MESSAGE_SEND_TIMEOUT="message_send_timeout"}(Ct||(Ct={}));class It{__init(){this.state="pending"}constructor(){It.prototype.__init.call(this),this.promise=new Promise(((e,t)=>{this.resolve=(...t)=>{this.state="fulfilled",e(...t)},this.reject=(...e)=>{this.state="rejected",t(...e)}})),this.then=this.promise.then.bind(this.promise)}}function yt(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}const Mt={message_start:!0,answer:!0,thinking:!0,tool_request:!0,tool_process:!0,tool_response:!0,message_end:!0,deploy:!0,version:!0,context:!0,session_changed:!0,error:!0,message_enqueued:!0,ack:!0,conversation_changed:!0,setting_changed:!0,queue_changed:!0,collaborator_changed:!0,project_invitation:!0,project_change:!0},bt=e=>{const{type:t}=e;return(e=>e in Mt)(t)?Tt({type:t,version:e.version})?{...e,role:"assistant",type:t,streamParametersContent:(n=yt([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters]),a=()=>"",i=null!=n?n:a(),s.safeJsonParse(i,void 0,{onError:r}))}:{...e,role:"assistant",type:t}:((e=>{throw new Error(`[chat-area] ${e}`)})(`invalid server message type: ${t}`),{...e,role:"assistant"});var i,r,n,a};class Nt extends Error{constructor(e,t){super(e),Nt.prototype.__init.call(this),this.name="chatCoreError",this.ext=t||{}}__init(){this.flatten=()=>{const{message:e,ext:t}=this;return{message:e,...t}}}}function Ut(e,t){return null!=e?e:t()}function Pt(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}const Ot=e=>{const{content:t,type:s}=e;switch(s){case"answer":return Ut(Pt([t,"access",e=>e.answer,"optionalAccess",e=>e.length]),(()=>0));case"thinking":return Ut(Pt([t,"access",e=>e.thinking,"optionalAccess",e=>e.length]),(()=>0));case"tool_request":return Ut(Pt([t,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters,"optionalAccess",e=>e.length]),(()=>0));case"tool_process":return(e=>{const t=Pt([e,"access",e=>e.content,"access",e=>e.tool_process,"optionalAccess",e=>e.data,"access",e=>e.content]);return we.reduce(((e,s)=>{const i=Pt([t,"optionalAccess",e=>e[s]]);return"string"!=typeof i?e:e+i.length}),0)})(e);case"tool_response":return Ut(Pt([t,"access",e=>e.tool_response,"optionalAccess",e=>e.result,"access",e=>e.length]),(()=>0));default:return 0}};class kt{__init(){this.bufferMap=new Map}constructor(e,t){kt.prototype.__init.call(this),kt.prototype.__init2.call(this),kt.prototype.__init3.call(this),kt.prototype.__init4.call(this),kt.prototype.__init5.call(this),kt.prototype.__init6.call(this),kt.prototype.__init7.call(this),kt.prototype.__init8.call(this),kt.prototype.__init9.call(this),kt.prototype.__init10.call(this),this.onFlush=e,this.config={lengthThreshold:Ut(Pt([t,"optionalAccess",e=>e.lengthThreshold]),(()=>4096)),maxWaitMs:Ut(Pt([t,"optionalAccess",e=>e.maxWaitMs]),(()=>500))}}__init2(){this.createEntry=(e,t)=>({msgId:e,chunks:[],totalLength:0,startSeq:t.sequence_id,maxWaitTimerId:null,hasFirstFlushed:!1})}__init3(){this.enqueue=e=>{const{msg_id:t}=e;let s=this.bufferMap.get(t);if(!s)return s=this.createEntry(t,e),this.bufferMap.set(t,s),this.onFlush({msgId:t,chunks:[e],startSeq:e.sequence_id,reason:"firstChunk"}),void(s.hasFirstFlushed=!0);0===s.chunks.length&&(s.startSeq=e.sequence_id),s.chunks.push(e),s.totalLength+=Ot(e),s.totalLength>=this.config.lengthThreshold?this.flush(t,"length"):e.finish?this.flush(t,"finish"):this.armMaxWaitTimer(t)}}__init4(){this.flush=(e,t)=>{const s=this.bufferMap.get(e);if(!s||0===s.chunks.length)return;this.cancelMaxWaitTimer(e);const i=this.buildBatch(s,t);this.onFlush(i),s.chunks=[],s.totalLength=0}}__init5(){this.buildBatch=(e,t)=>({msgId:e.msgId,chunks:[...e.chunks],startSeq:e.startSeq,reason:t})}__init6(){this.armMaxWaitTimer=e=>{const t=this.bufferMap.get(e);t&&(t.maxWaitTimerId||(t.maxWaitTimerId=setTimeout((()=>{this.flush(e,"maxWait")}),this.config.maxWaitMs)))}}__init7(){this.cancelMaxWaitTimer=e=>{const t=this.bufferMap.get(e);Pt([t,"optionalAccess",e=>e.maxWaitTimerId])&&(clearTimeout(t.maxWaitTimerId),t.maxWaitTimerId=null)}}__init8(){this.forceFlush=e=>{this.flush(e,"force"),this.bufferMap.delete(e)}}__init9(){this.forceFlushAll=()=>{Array.from(this.bufferMap.keys()).forEach((e=>this.forceFlush(e)))}}__init10(){this.destroy=()=>{this.bufferMap.forEach(((e,t)=>{this.cancelMaxWaitTimer(t)})),this.bufferMap.clear()}}}function Bt(e,t){return null!=e?e:t()}function jt(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}class Dt{__init(){this.bufferManager=null}constructor({channel:e,reportLogWithScope:t,chunkProcessor:s,preSendLocalMessageEventsManager:i,chatSdkEventEmit:r,chatSdkEventBus:n,reportEventsTracer:a,manualInitChannel:o,enableBuffer:c=!1}){Dt.prototype.__init.call(this),Dt.prototype.__init2.call(this),Dt.prototype.__init3.call(this),Dt.prototype.__init4.call(this),Dt.prototype.__init5.call(this),Dt.prototype.__init6.call(this),Dt.prototype.__init7.call(this),Dt.prototype.__init8.call(this),Dt.prototype.__init9.call(this),Dt.prototype.__init10.call(this),Dt.prototype.__init11.call(this),Dt.prototype.__init12.call(this),Dt.prototype.__init13.call(this),Dt.prototype.__init14.call(this),Dt.prototype.__init15.call(this),Dt.prototype.__init16.call(this),this.channel=e,this.reportLogWithScope=t,this.chunkProcessor=s,this.preSendLocalMessageEventsManager=i,this.chatSdkEventEmit=r,this.reportEventsTracer=a,this.chatSdkEventBus=n,this.enableBuffer=c,this.onMessageMonitor=new vt({reportLogWithScope:t,getChannelOptions:()=>({...Bt(jt([this,"access",e=>e.channel,"access",e=>e.getChannelOptions,"optionalCall",e=>e()]),(()=>({}))),channelName:this.channel.channelName}),timeoutMs:12e4}),c&&(this.bufferManager=new kt(this.processChunkBatchAndEmit,void 0)),o||this.initChannel()}onChannelEvents(){this.channel.addEventListener("onmessage",this.handleChannelMessage),this.channel.addEventListener("onerror",this.handleWebSocketChannelError),this.channel.addEventListener("onopen",this.handleChannelOpen),this.channel.addEventListener("onclose",this.handleChannelClose)}offChannelEvents(){this.channel.removeEventListener("onmessage",this.handleChannelMessage),this.channel.removeEventListener("onerror",this.handleWebSocketChannelError),this.channel.removeEventListener("onopen",this.handleChannelOpen),this.channel.removeEventListener("onclose",this.handleChannelClose)}__init2(){this.handleChannelMessage=e=>{const t=bt(e);this.onMessageMonitor.flushMessage(t);const{type:s}=t;return"context"===s&&t.content.context?this.handleContextChange(t.content.context):"session_changed"===s&&t.content.session_changed?this.handleSessionChange(t.content.session_changed):this.handleChatMessage(t)}}__init3(){this.handleContextChange=e=>{this.reportLogWithScope.info({message:"context 更新",meta:{context:e}}),this.chatSdkEventEmit(St.CONTEXT_CHANGE,{name:St.CONTEXT_CHANGE,data:e})}}__init4(){this.handleSessionChange=e=>{this.reportLogWithScope.info({message:"session 更新",meta:{session:e}}),this.chatSdkEventEmit(St.SESSION_CHANGED,{name:St.SESSION_CHANGED,data:e})}}__init5(){this.handleChatFinish=()=>{jt([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.forceFlushAll,"call",e=>e()]),this.chunkProcessor.clearMessageBuffer(),this.onMessageMonitor.destroy()}}__init6(){this.createSingleChunkBatch=e=>({msgId:e.msg_id,chunks:[e],startSeq:e.sequence_id,reason:"force"})}__init7(){this.processChunkBatchAndEmit=e=>{const{chunks:t}=e;if(0===t.length)return;const s=t.at(0);if(!s)return;const{query_msg_id:i,log_id:r,content:n}=s,a=Bt(jt([n,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),(()=>""));this.chunkProcessor.isFirstReplyMessage(s)&&jt([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.pullStreamTracer,"optionalAccess",e=>e.receiveFirstAnsChunk,"call",e=>e(a,{log_id:r})]);const o=this.chunkProcessor.addBatchAndProcess(e);if(!o)throw new Nt("processedMessage is undefined",{local_msg_id:a});this.chatSdkEventEmit(St.MESSAGE_PULLING_STATUS,{name:St.MESSAGE_PULLING_STATUS,data:{pullingStatus:"pulling",local_msg_id:a,query_msg_id:i,conversation_id:s.conversation_id,project_id:s.project_id}}),this.chatSdkEventEmit(St.MESSAGE_RECEIVED_AND_UPDATE,{name:St.MESSAGE_RECEIVED_AND_UPDATE,data:[o]})}}__init8(){this.handleChatMessage=e=>{const{content:t,type:s}=e,i=Bt(jt([t,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),(()=>""));if(!this.chunkProcessor.checkMessageHasProcessed(e))if("message_end"!==s)if("message_start"!==s)if("message_enqueued"!==s)if("error"!==s)this.enableBuffer&&this.bufferManager?this.bufferManager.enqueue(e):this.processChunkBatchAndEmit(this.createSingleChunkBatch(e));else{jt([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.forceFlushAll,"call",e=>e()]);const t=this.chunkProcessor.addBatchAndProcess(this.createSingleChunkBatch(e));if(!t)throw new Nt("processedMessage is undefined",{local_msg_id:i});this.handleMessageError(t)}else this.handleMessageEnqueued(e);else{const t=this.chunkProcessor.addBatchAndProcess(this.createSingleChunkBatch(e));if(!t)throw new Nt("processedMessage is undefined",{local_msg_id:i});this.handleMessageStart(t)}else{jt([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.forceFlushAll,"call",e=>e()]);const t=this.chunkProcessor.addBatchAndProcess(this.createSingleChunkBatch(e));if(!t)throw new Nt("processedMessage is undefined",{local_msg_id:i});this.handleMessageEnd(t)}}}__init9(){this.handleWebSocketChannelError=e=>{!e.ext.willClose&&e.ext.isQosError||(this.onMessageMonitor.destroy(),this.reportLogWithScope.error({message:"信道异常",error:e}),this.chatSdkEventEmit(St.MESSAGE_PULLING_STATUS,{name:St.MESSAGE_PULLING_STATUS,data:{pullingStatus:"channel_error",wsError:e}}),this.chatSdkEventEmit(St.CHANNEL_STATUS,{name:St.CHANNEL_STATUS,data:{channelStatus:"disconnected",message:e.message}}),this.handleChatFinish())}}__init10(){this.handleMessageEnd=e=>{const{query_msg_id:t,reply_id:s,content:i}=e,r=this.chunkProcessor.getReplyMessagesByQueryMsgId(t);jt([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.pullStreamTracer,"optionalAccess",e=>e.success,"call",e=>e(t,{replyMessageCount:r})]),this.reportLogWithScope.info({message:"拉取回复完成",meta:{query_msg_id:t,message:e}});const n=i.message_end;switch(jt([n,"optionalAccess",e=>e.code])){case"0":this.chatSdkEventEmit(St.MESSAGE_PULLING_STATUS,{name:St.MESSAGE_PULLING_STATUS,data:{pullingStatus:"success",query_msg_id:t,reply_id:s,messageEndDetail:i.message_end,conversation_id:e.conversation_id,project_id:e.project_id}});break;case"1":this.chatSdkEventEmit(St.MESSAGE_PULLING_STATUS,{name:St.MESSAGE_PULLING_STATUS,data:{pullingStatus:"cancel",query_msg_id:t,messageEndDetail:i.message_end,reply_id:s,conversation_id:e.conversation_id,project_id:e.project_id}});break;default:this.chatSdkEventEmit(St.MESSAGE_PULLING_STATUS,{name:St.MESSAGE_PULLING_STATUS,data:{pullingStatus:"error",query_msg_id:t,messageEndDetail:i.message_end,reply_id:s,code:jt([n,"optionalAccess",e=>e.code]),message:jt([n,"optionalAccess",e=>e.message]),conversation_id:e.conversation_id,project_id:e.project_id}})}this.preSendLocalMessageEventsManager.emit(Ct.MESSAGE_END,e),this.handleChatFinish()}}__init11(){this.handleMessageError=e=>{const{query_msg_id:t,content:s}=e,i=jt([s,"access",e=>e.error,"optionalAccess",e=>e.local_msg_id]),r=Bt(jt([s,"access",e=>e.error,"optionalAccess",e=>e.error_msg]),(()=>"")),n=new Nt(r,{query_msg_id:t,local_msg_id:i,code:jt([s,"access",e=>e.error,"optionalAccess",e=>e.code])});jt([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.pullStreamTracer,"optionalAccess",e=>e.error,"call",e=>e(n)]),this.reportLogWithScope.error({error:n,message:"收到错误消息",meta:{query_msg_id:t,local_msg_id:i,errorMessage:r}}),this.preSendLocalMessageEventsManager.emit(Ct.MESSAGE_SEND_AND_RECEIVE_ERROR,n),this.chatSdkEventEmit(St.SEND_MESSAGE_ERROR,{name:St.SEND_MESSAGE_ERROR,data:{error:n}}),this.handleChatFinish()}}__init12(){this.handleMessageStart=e=>{const{content:t,query_msg_id:s,log_id:i}=e,r=t.message_start,n=jt([r,"optionalAccess",e=>e.local_msg_id]);jt([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.pullStreamTracer,"optionalAccess",e=>e.start,"call",e=>e(s,{logId:i})]),this.reportLogWithScope.info({message:"开始拉取回复",meta:{local_msg_id:n,query_msg_id:s,log_id:i}}),this.preSendLocalMessageEventsManager.emit(Ct.MESSAGE_SEND_SUCCESS,e),this.chatSdkEventEmit(St.MESSAGE_PULLING_STATUS,{name:St.MESSAGE_PULLING_STATUS,data:{pullingStatus:"start",local_msg_id:n,query_msg_id:s,startDetail:r,conversation_id:e.conversation_id,project_id:e.project_id}})}}__init13(){this.handleMessageEnqueued=e=>{const{content:t,log_id:s}=e,i=jt([t.message_enqueued,"optionalAccess",e=>e.local_msg_id]);this.reportLogWithScope.info({message:"消息已入队",meta:{local_msg_id:i,log_id:s}}),this.preSendLocalMessageEventsManager.emit(Ct.MESSAGE_SEND_SUCCESS,e)}}__init14(){this.handleChannelOpen=()=>{this.reportLogWithScope.info({message:"信道连接成功"}),this.chatSdkEventEmit(St.CHANNEL_STATUS,{name:St.CHANNEL_STATUS,data:{channelStatus:"connected"}})}}__init15(){this.handleChannelClose=({code:e,reason:t})=>{this.onMessageMonitor.destroy(),this.reportLogWithScope.info({message:"信道关闭",meta:{code:e,reason:t}}),this.chatSdkEventEmit(St.CHANNEL_STATUS,{name:St.CHANNEL_STATUS,data:{channelStatus:"disconnected",message:t}})}}__init16(){this.initChannel=async()=>{this.channel.isChannelOpen()||await this.channel.connect()}}destroy(){jt([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.destroy,"call",e=>e()]),this.offChannelEvents(),this.chatSdkEventBus.all.clear()}}function Gt(e,t){return null!=e?e:t()}function qt(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}class wt{constructor({preSendLocalMessageFactory:e,channel:t,preSendLocalMessageEventsManager:s,reportLogWithScope:i,reportEventsTracer:r,chatSdkEventEmit:n}){wt.prototype.__init.call(this),this.preSendLocalMessageFactory=e,this.channel=t,this.preSendLocalMessageEventsManager=s,this.reportLogWithScope=i,this.reportEventsTracer=r,this.chatSdkEventEmit=n}createChannelErrorHandler(e){return()=>{const t=new Nt("Error: during send message channel onerror",{local_msg_id:e});throw qt([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.error,"call",e=>e(t)]),t}}__init(){this.createAckErrorHandler=e=>t=>{if("0"===t.code)return;const s=new Nt(t.msg,{local_msg_id:e});throw this.chatSdkEventEmit(St.SEND_MESSAGE_ERROR,{name:St.SEND_MESSAGE_ERROR,data:{error:s}}),qt([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.error,"call",e=>e(s)]),s}}startMessageTracing(e,t){qt([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.start,"call",s=>s(e,{local_msg_id:e,...t})])}completeMessageTracing(e,t){qt([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.success,"call",s=>s(e,t)])}traceMessageError(e,t){qt([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.error,"call",e=>e(t)])}async sendCommandMessage(e){this.reportLogWithScope.info({message:"开始发送命令消息",meta:{message:e}}),await this.executeCommandMessage(e)}async executeCommandMessage(e){const{local_msg_id:t,type:s}=e;return this.startMessageTracing(t),new Promise(((i,r)=>{const n=this.createCommandContext(e,i,r);this.setupCommandEventListeners(n),this.sendMessageWithChannel(e,t).then((()=>this.handleCommandSendSuccess(s,t,n.promiseHandlers.resolve))).catch((e=>this.handleCommandSendError(e,t,n.promiseHandlers.reject)))}))}createCommandContext(e,t,s){const i={resolve:()=>{o(),t()},reject:e=>{o(),s(e)}},{local_msg_id:r,type:n}=e,a=[],o=()=>{a.forEach((e=>e()))};return{localMsgId:r,type:n,eventCleanup:a,cleanup:o,handleMessageEnd:e=>{"cancel"===n&&(this.completeMessageTracing(r,{logId:e.log_id}),i.resolve())},promiseHandlers:i}}setupCommandEventListeners(e){const{localMsgId:t,type:s,eventCleanup:i,handleMessageEnd:r}=e,n=this.createChannelErrorHandler(t),a=this.createAckErrorHandler(t),o=()=>{try{n()}catch(t){e.promiseHandlers.reject(t)}},c=t=>{try{a(t)}catch(t){e.promiseHandlers.reject(t)}};this.channel.addEventListener("onerror",o),this.channel.addEventListener("onack",c),i.push((()=>this.channel.removeEventListener("onerror",o))),i.push((()=>this.channel.removeEventListener("onack",c))),"cancel"===s&&(this.preSendLocalMessageEventsManager.on(Ct.MESSAGE_END,r),i.push((()=>this.preSendLocalMessageEventsManager.off(Ct.MESSAGE_END,r))))}handleCommandSendSuccess(e,t,s){"input"===e&&(this.completeMessageTracing(t),s())}handleCommandSendError(e,t,s){const i=new Nt(`Error: channel send command message error: ${String(e)}`,{local_msg_id:t});this.traceMessageError(t,i),s(i)}async sendChatMessage(e,t){this.reportLogWithScope.info({message:"开始发送聊天消息",meta:{message:e}});const s=this.preSendLocalMessageFactory.getSendChatMessageStructure(e,t);return await this.executeChatMessage(s,t)}executeChatMessage(e,t){const{local_msg_id:s}=e,i=Gt(qt([t,"optionalAccess",e=>e.sendTimeout]),(()=>6e4));return new Promise(((t,r)=>{const n=this.createChatContext(e,t,r);this.setupChatEventListeners(n,i),this.startMessageTracing(s),this.sendMessageWithChannel(e,s).catch((e=>this.handleChatSendError(e,s,n.promiseHandlers.reject)))}))}createChatContext(e,t,s){const i={resolve:e=>{a(),t(e)},reject:e=>{a(),s(e)}},{local_msg_id:r}=e,n=[],a=()=>{n.forEach((e=>e()))};return{localMsgId:r,message:e,eventCleanup:n,cleanup:a,promiseHandlers:i}}setupChatEventListeners(e,t){const{localMsgId:s,eventCleanup:i,promiseHandlers:r}=e,n=this.setupTimeoutHandler(s,t,r.reject);i.push((()=>clearTimeout(n)));const a=this.createChannelErrorHandler(s),o=this.createAckErrorHandler(s),c=()=>{try{a()}catch(e){r.reject(e)}},_=e=>{try{o(e)}catch(e){r.reject(e)}};this.channel.addEventListener("onerror",c),this.channel.addEventListener("onack",_),i.push((()=>this.channel.removeEventListener("onerror",c))),i.push((()=>this.channel.removeEventListener("onack",_)));const l=this.createMessageSuccessHandler(e);this.preSendLocalMessageEventsManager.on(Ct.MESSAGE_SEND_SUCCESS,l),i.push((()=>this.preSendLocalMessageEventsManager.off(Ct.MESSAGE_SEND_SUCCESS,l)));const h=this.createMessageFailedHandler(s,r.reject);this.preSendLocalMessageEventsManager.on(Ct.MESSAGE_SEND_AND_RECEIVE_ERROR,h),i.push((()=>this.preSendLocalMessageEventsManager.off(Ct.MESSAGE_SEND_AND_RECEIVE_ERROR,h)))}setupTimeoutHandler(e,t,s){return setTimeout((()=>{qt([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.timeout,"call",t=>t(e)]);const t=new Nt("send chat message timeout",{local_msg_id:e});this.preSendLocalMessageEventsManager.emit(Ct.MESSAGE_SEND_TIMEOUT,t),s(t)}),t)}createMessageSuccessHandler(e){const{localMsgId:t,message:s,promiseHandlers:i}=e;return e=>{const r=Gt(qt([e,"access",e=>e.content,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),(()=>qt([e,"access",e=>e.content,"access",e=>e.message_enqueued,"optionalAccess",e=>e.local_msg_id]))),n=Gt(qt([e,"access",e=>e.content,"access",e=>e.message_start,"optionalAccess",e=>e.msg_id]),(()=>qt([e,"access",e=>e.content,"access",e=>e.message_enqueued,"optionalAccess",e=>e.msg_id])));if(r!==t)return;this.completeMessageTracing(t,{logId:e.log_id});const a={...s,msg_id:Gt(n,(()=>"")),role:"user"},o="message_enqueued"===e.type?"message_enqueued":"message_start";i.resolve({message:a,status:o})}}createMessageFailedHandler(e,t){return s=>{s.ext.local_msg_id===e&&(this.traceMessageError(e,s),t(s))}}handleChatSendError(e,t,s){const i=new Nt(`Error: channel send chat message error: ${String(e)}`,{local_msg_id:t});this.traceMessageError(t,i),s(e)}async sendMessageWithChannel(e,t){try{await this.ensureChannelReadyAndSend(e)}catch(e){const s=new Nt((e=>e instanceof Error?e.message:"object"==typeof e?JSON.stringify(e):String(e))(e),{local_msg_id:t});throw this.traceMessageError(t,s),s}}async ensureChannelReadyAndSend(e){return this.channel.isChannelOpenPromise?await this.channel.isChannelOpenPromise:this.channel.isChannelOpen()||await this.channel.connect(),await this.channel.send(e)}}function Ft(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}var xt,Wt,Ht,Kt,Vt,$t,zt,Qt,Jt,Yt,Zt,Xt,es,ts,ss,is,rs,ns,as,os,cs,_s,ls,hs,us,ds,ps,gs,Ts,Es,ms,fs,Ls,As,Ss,Rs,Cs,vs;!function(e){e.SDK_INIT="chat_sdk_init";e.SDK_MESSAGE_UPLOAD_FAIL="chat_sdk_message_upload_fail";e.SDK_BREAK_MESSAGE="chat_sdk_break_message";e.SDK_MESSAGE_SEND_TRACER="chat_sdk_message_send_tracer";e.SDK_PULL_STREAM_TRACER="chat_sdk_pull_stream_tracer"}(xt||(xt={}));class Is{__init(){this.eventTracers=new Map}constructor(e){Is.prototype.__init.call(this),Is.prototype.__init2.call(this),Is.prototype.__init3.call(this),this.reporter=e}__init2(){this.sendMessageTracer={start:(e,t)=>{const{trace:s}=this.createTracer(xt.SDK_MESSAGE_SEND_TRACER);this.setTracer(e,xt.SDK_MESSAGE_SEND_TRACER,{trace:s}),Ft([s,"optionalCall",e=>e("start",{meta:t})])},success:(e,t)=>{const{trace:s}=this.getTracer(e,xt.SDK_MESSAGE_SEND_TRACER);Ft([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,xt.SDK_MESSAGE_SEND_TRACER),this.pullStreamTracer.start(e,t)},inqueue:(e,t)=>{const{trace:s}=this.getTracer(e,xt.SDK_MESSAGE_SEND_TRACER);Ft([s,"optionalCall",e=>e("inqueue",{meta:t})]),this.deleteTracer(e,xt.SDK_MESSAGE_SEND_TRACER)},error:e=>{const{local_msg_id:t}=e.ext;if(!t)return;const{trace:s}=this.getTracer(t,xt.SDK_MESSAGE_SEND_TRACER);Ft([s,"optionalCall",t=>t("error",{meta:e.flatten(),error:e})]),this.deleteTracer(t,xt.SDK_MESSAGE_SEND_TRACER)},timeout:e=>{const{trace:t}=this.getTracer(e,xt.SDK_MESSAGE_SEND_TRACER);Ft([t,"optionalCall",e=>e("timeout")]),this.deleteTracer(e,xt.SDK_MESSAGE_SEND_TRACER)}}}__init3(){this.pullStreamTracer={start:(e,t)=>{const{trace:s}=this.createTracer(xt.SDK_PULL_STREAM_TRACER);this.setTracer(e,xt.SDK_PULL_STREAM_TRACER,{trace:s,meta:t}),Ft([s,"optionalCall",e=>e("start",{meta:t})])},success:(e,t)=>{const{trace:s}=this.getTracer(e,xt.SDK_PULL_STREAM_TRACER);Ft([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,xt.SDK_PULL_STREAM_TRACER)},break:(e,t)=>{const{trace:s}=this.getTracer(e,xt.SDK_PULL_STREAM_TRACER);Ft([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,xt.SDK_PULL_STREAM_TRACER)},error:(e,t)=>{const{query_msg_id:s}=e.ext;if(!s)return;const{trace:i}=this.getTracer(s,xt.SDK_PULL_STREAM_TRACER);Ft([i,"optionalCall",s=>s("error",{meta:{...e.flatten(),...t},error:e})]),this.deleteTracer(s,xt.SDK_PULL_STREAM_TRACER)},timeout:e=>{const{query_msg_id:t}=e.ext;if(!t)return;const{trace:s}=this.getTracer(t,xt.SDK_PULL_STREAM_TRACER);Ft([s,"optionalCall",t=>t("timeout",{meta:e.flatten(),error:e})]),this.deleteTracer(t,xt.SDK_PULL_STREAM_TRACER)},receiveFirstAnsChunk:(e,t)=>{const{trace:s}=this.getTracer(e,xt.SDK_PULL_STREAM_TRACER);Ft([s,"optionalCall",e=>e("first_ans_chunk",{meta:t})])}}}static getUniqueKey(e,t){return`${e}_${t}`}getTracer(e,t){return this.eventTracers.get(Is.getUniqueKey(e,t))||{trace:void 0}}setTracer(e,t,s){const{trace:i,meta:r}=s;this.eventTracers.set(Is.getUniqueKey(e,t),{trace:i,meta:r})}deleteTracer(e,t){this.eventTracers.delete(Is.getUniqueKey(e,t))}createTracer(e){return this.reporter.slardarTracer({eventName:e})}}class ys{static __initStatic(){this.instances=new Map}static __initStatic2(){this.EVENTS=St}__init(){this.enableDebug=!1}__init2(){this.eventBus=e()}constructor(e){ys.prototype.__init.call(this),ys.prototype.__init2.call(this),ys.prototype.__init3.call(this),ys.prototype.__init4.call(this),ys.prototype.__init5.call(this),ys.prototype.__init6.call(this),ys.prototype.__init7.call(this),ys.prototype.__init8.call(this),ys.prototype.__init9.call(this),ys.prototype.__init10.call(this);const{enableDebug:t,logLevel:s,env:i,key:r}=e;this.key=r,this.enableDebug=Boolean(t),this.logLevel=s||"error",this.env=i,this.reportLog=e.reportLog,this.reportLog.init(),this.reportLogWithScope=this.reportLog.createLoggerWith({scope:"chat-sdk",meta:{key:r}}),this.reportEventsTracer=new Is(this.reportLogWithScope),this.requestManager=new je({options:e.requestManagerOptions,reportLog:this.reportLog}),this.preSendLocalMessageEventsManager=new De,this.preSendLocalMessageFactory=new Ge,this.chunkProcessor=new At({getEnableDebug:()=>this.enableDebug,initMessageBuffer:e.initMessageBuffer,initMaxSequenceId:e.initMaxSequenceId,enableChunkProcessedCheck:e.enableChunkProcessedCheck,reportLogWithScope:this.reportLogWithScope,key:r}),this.channel=e.channel,this.createMessageService=new le,this.sendMessageService=new wt({preSendLocalMessageFactory:this.preSendLocalMessageFactory,channel:this.channel,preSendLocalMessageEventsManager:this.preSendLocalMessageEventsManager,reportLogWithScope:this.reportLogWithScope,reportEventsTracer:this.reportEventsTracer,chatSdkEventEmit:this.emit}),this.websocketService=new Dt({channel:this.channel,reportLogWithScope:this.reportLogWithScope,chunkProcessor:this.chunkProcessor,preSendLocalMessageEventsManager:this.preSendLocalMessageEventsManager,chatSdkEventEmit:this.emit,chatSdkEventBus:this.eventBus,reportEventsTracer:this.reportEventsTracer,manualInitChannel:Boolean(e.manualInitChannel),enableBuffer:Boolean(e.enableBuffer)}),this.onEvents(),this.reportLogWithScope.slardarEvent({eventName:xt.SDK_INIT,meta:{...e}}),this.reportLogWithScope.info({message:"SDK 初始化完成"})}static create(e){const{key:t}=e;if(ys.instances.has(t))return console.error("duplicate chat core instance error"),ys.instances.get(t);const s=new ys(e);return ys.instances.set(t,s),s}onEvents(){this.websocketService.onChannelEvents()}destroy(){this.websocketService.destroy(),this.eventBus.all.clear(),this.chunkProcessor.destroy(),ys.instances.delete(this.key),this.preSendLocalMessageEventsManager.destroy(),this.reportLogWithScope.info({message:"SDK销毁"})}__init3(){this.on=(e,t,s)=>(this.eventBus.all.has(e)&&!s&&this.reportLogWithScope.slardarError({message:"重复监听事件",error:new Error("重复监听"),meta:{event:e}}),this.eventBus.on(e,t),()=>{this.eventBus.off(e,t)})}__init4(){this.off=(e,t)=>{this.eventBus.off(e,t)}}__init5(){this.emit=(e,t)=>{this.eventBus.emit(e,t)}}createQueryMessage(...e){return this.createMessageService.createQueryMessage(...e)}createRetryMessage(...e){return this.createMessageService.createRetryMessage(...e)}createEditMessage(...e){return this.createMessageService.createEditMessage(...e)}createInterruptMessage(...e){return this.createMessageService.createInputMessage(...e)}createCancelMessage(...e){return this.createMessageService.createCancelMessage(...e)}sendChatMessage(e,t){return this.sendMessageService.sendChatMessage(e,t)}sendCommandMessage(e){return this.sendMessageService.sendCommandMessage(e)}__init6(){this.getHistoryMessage=(...e)=>this.requestManager.getSceneConfig(c.GetMessage)(...e)}__init7(){this.isChannelOpen=()=>this.channel.isChannelOpenPromise?"connecting":this.channel.isChannelOpen()?"connected":"disconnected"}__init8(){this.initChannel=()=>this.websocketService.initChannel()}__init9(){this.captureStreamBuffer=()=>this.chunkProcessor.getStreamBufferWithMeta()}__init10(){this.captureStreamBufferSnapshot=()=>this.chunkProcessor.getStreamBufferSnapshot()}}function Ms(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}ys.__initStatic(),ys.__initStatic2(),function(e){e.ASRMessageTypeAudio="audio";e.ASRMessageTypeConfig="config";e.ASRMessageTypeStop="stop"}(Wt||(Wt={})),function(e){e[e.Unknown=0]="Unknown";e[e.Organization=1]="Organization";e[e.Personal=2]="Personal"}(Ht||(Ht={})),function(e){e.ASRServerMessageTypeError="asr_error";e.ASRServerMessageTypeResult="asr_result"}(Kt||(Kt={})),function(e){e[e.develop=0]="develop";e[e.product=1]="product"}(Vt||(Vt={})),function(e){e[e.Agent=1]="Agent";e[e.Automation=2]="Automation";e[e.WebApp=3]="WebApp";e[e.App=4]="App";e[e.Skill=5]="Skill";e[e.GeneralWeb=6]="GeneralWeb";e[e.WechatMiniProgram=7]="WechatMiniProgram";e[e.AssistantAgent=8]="AssistantAgent"}($t||($t={})),function(e){e[e.restoring=0]="restoring";e[e.success=1]="success";e[e.failed=2]="failed"}(zt||(zt={})),function(e){e[e.active=0]="active";e[e.creating=1]="creating"}(Qt||(Qt={})),function(e){e[e.postgre=0]="postgre";e[e.supabase=1]="supabase"}(Jt||(Jt={})),function(e){e[e.SQL=1]="SQL";e[e.REPORT=2]="REPORT";e[e.LOG_SQL=3]="LOG_SQL"}(Yt||(Yt={})),function(e){e[e.NAME=1]="NAME";e[e.INSERTED_AT=2]="INSERTED_AT"}(Zt||(Zt={})),function(e){e[e.ASC=1]="ASC";e[e.DESC=2]="DESC"}(Xt||(Xt={})),function(e){e[e.USER=1]="USER";e[e.PROJECT=2]="PROJECT";e[e.ORG=3]="ORG";e[e.PUBLIC=4]="PUBLIC"}(es||(es={})),function(e){e[e.AddAttributes=1]="AddAttributes";e[e.RemoveAttributes=2]="RemoveAttributes"}(ts||(ts={})),function(e){e[e.CloseConnection=1]="CloseConnection"}(ss||(ss={})),function(e){e[e.ON_LINE=0]="ON_LINE";e[e.OFF_LINE=1]="OFF_LINE";e[e.TOUCH=2]="TOUCH"}(is||(is={})),function(e){e[e.AddGroups=1]="AddGroups";e[e.RemoveGroups=2]="RemoveGroups";e[e.ReplaceWithGroups=3]="ReplaceWithGroups"}(rs||(rs={})),function(e){e[e.App=0]="App";e[e.Service=1]="Service";e[e.Method=2]="Method"}(ns||(ns={})),function(e){e.FileBatchDelete="file.batch_delete";e.FileBatchMove="file.batch_move";e.FileChanged="file.changed";e.FileCreate="file.create";e.FileDelete="file.delete";e.FileExist="file.exist";e.FileGrep="file.grep";e.FileList="file.list";e.FileMove="file.move";e.FilePack="file.pack";e.FilePatch="file.patch";e.FileRead="file.read";e.FileReplace="file.replace";e.FileSearch="file.search";e.FileStat="file.stat";e.FileWrite="file.write";e.GetAppLog="log.get_app_log";e.GetCurrentCanvas="canvas.get_current";e.GetExecuteLog="test.get_execute_log";e.GetInOutSchema="canvas.get_inout_schema";e.GetSourceCode="canvas.get_source_code";e.LspCompletion="lsp.completion";e.LspCompletionItemResolve="lsp.completionItemResolve";e.LspDefinition="lsp.definition";e.LspDidChange="lsp.didChange";e.LspDidClose="lsp.didClose";e.LspDidOpen="lsp.didOpen";e.LspGetDiagnosticsCli="lsp.getDiagnosticsCli";e.LspHover="lsp.hover";e.LspOnNotification="lsp.onNotification";e.LspReferences="lsp.references";e.LspRestart="lsp.restart";e.LspSignatureHelp="lsp.signatureHelp";e.NodeDebug="node.debug";e.PageRouterGetPage="page_router.get_routes";e.PreviewReload="preview.reload";e.RepoCommitCreate="repo_version.commit.create";e.RepoCommitFileDiff="repo_version.commit.file.diff";e.RepoCommitFileRead="repo_version.commit.file.read";e.RepoCommitList="repo_version.commit.list";e.RepoCommitRetrieve="repo_version.commit.retrieve";e.RepoCommitSearch="repo_version.commit.search";e.RepoCommitStatus="repo_version.commit.status";e.RepoCommitVersionDiff="repo_version.commit.diff";e.RepoCommitVersions="repo_version.commit.versions";e.RepoVersionCodeStage="repo_version.commit.stage";e.RepoVersionCodeUnstage="repo_version.commit.restore";e.RepoVersionConflictResolve="repo_version.conflict.resolve";e.RepoVersionEvent="repo_version.event";e.RepoVersionFileRead="repo_version.file.read";e.RepoVersionLatest="repo_version.commit.version.latest";e.RepoVersionNotify="repo_version.notify";e.RepoVersionRemoteAdd="repo_version.remote.add";e.RepoVersionRemoteFetch="repo_version.remote.fetch";e.RepoVersionRemoteOutgoingCommits="repo_version.remote.outgoing_commits";e.RepoVersionRemotePull="repo_version.remote.pull";e.RepoVersionRemotePush="repo_version.remote.push";e.RepoVersionRemoteRemove="repo_version.remote.remove";e.SandboxBroadcast="sandbox.broadcast";e.SandboxPing="sandbox.ping";e.SandboxProjectStatus="sandbox.project_status";e.SandboxProjectStatusNotify="sandbox.project_status_notify";e.SandboxVersion="sandbox.version";e.ShellClose="shell.close";e.ShellCreate="shell.create";e.ShellExecute="shell.execute";e.ShellExited="shell.exited";e.ShellInput="shell.input";e.ShellOutput="shell.output";e.ShellResize="shell.resize";e.TestRun="test.run";e.TestValidate="test.validate";e.WebIsServerStart="web.is_server_start";e.WebStartServer="web.start_server"}(as||(as={})),function(e){e[e.text=0]="text";e[e.url=1]="url";e[e.uri=2]="uri"}(os||(os={})),(cs||(cs={})).PdfTargetFileType="pdf",function(e){e.TabAuthentication="Authentication"}(_s||(_s={})),function(e){e.FeatureApp="app";e.FeatureAssistantAgent="assistantagent";e.FeatureGeneral="general";e.FeatureSkill="skill";e.FeatureWechatMiniProgram="wechatminiprogram"}(ls||(ls={})),function(e){e.ScenePredefinedQuery="PredefinedQuery";e.SceneRecommendProjectCases="RecommendProjectCases";e.SceneSubmitWorkPoint="SubmitWorkPoint"}(hs||(hs={})),function(e){e[e.CozeSpace=1]="CozeSpace";e[e.Ark=2]="Ark"}(us||(us={})),function(e){e[e.LocalFile=1]="LocalFile";e[e.GithubRepo=2]="GithubRepo"}(ds||(ds={})),function(e){e.ProjectTypeAgent="Agent";e.ProjectTypeApp="App";e.ProjectTypeAssistantAgent="AssistantAgent";e.ProjectTypeAutomation="Automation";e.ProjectTypeGeneral="General";e.ProjectTypeGeneralWeb="GeneralWeb";e.ProjectTypeSkill="Skill";e.ProjectTypeWechatMiniProgram="WechatMiniProgram"}(ps||(ps={})),function(e){e[e.Confirming=1]="Confirming";e[e.Joined=2]="Joined";e[e.Rejected=3]="Rejected";e[e.Expired=4]="Expired"}(gs||(gs={})),function(e){e[e.Agent=0]="Agent";e[e.Ask=1]="Ask";e[e.DangerousConfirm=2]="DangerousConfirm";e[e.Plan=4]="Plan"}(Ts||(Ts={})),function(e){e.ProjectSymbolVersion3="v3"}(Es||(Es={})),function(e){e[e.Web=1]="Web";e[e.Mobile=2]="Mobile"}(ms||(ms={})),function(e){e[e.Creator=0]="Creator";e[e.Collaborator=1]="Collaborator"}(fs||(fs={})),exports.VibeProjectType=void 0,function(e){e[e.Agent=1]="Agent";e[e.Automation=2]="Automation";e[e.WebApp=3]="WebApp";e[e.App=4]="App";e[e.Skill=5]="Skill";e[e.GeneralWeb=6]="GeneralWeb";e[e.WechatMiniProgram=7]="WechatMiniProgram";e[e.AssistantAgent=8]="AssistantAgent";e[e.General=9]="General";e[e.CLIBilling=101]="CLIBilling"}(exports.VibeProjectType||(exports.VibeProjectType={})),function(e){e[e.UnAuth=1]="UnAuth";e[e.AuthButNoBind=2]="AuthButNoBind";e[e.AuthAndBind=3]="AuthAndBind"}(Ls||(Ls={})),function(e){e[e.Inactive=1]="Inactive";e[e.Active=2]="Active"}(As||(As={})),function(e){e[e.Unknown=0]="Unknown";e[e.String=1]="String";e[e.Boolean=2]="Boolean";e[e.StringList=11]="StringList";e[e.BooleanList=12]="BooleanList"}(Ss||(Ss={})),function(e){e[e.Account=1]="Account";e[e.Workspace=2]="Workspace";e[e.VibeProject=38]="VibeProject";e[e.PostgresDatabase=39]="PostgresDatabase";e[e.Storage=40]="Storage"}(Rs||(Rs={})),function(e){e.PdfTargetFileType="pdf";e.XlsxTargetFileType="xlsx"}(Cs||(Cs={})),function(e){e[e.move=0]="move";e[e.copy=1]="copy"}(vs||(vs={}));class bs{__init(){this.request=s.request}__init2(){this.baseURL=""}constructor(e){bs.prototype.__init.call(this),bs.prototype.__init2.call(this),this.request=Ms([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=Ms([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}GetVibeGlobalSettings(e,t){const s=this.genBaseURL("/api/ideserver_api/project/get_vibe_global_settings");return this.request({url:s,method:"POST"},t)}UpdateVibeGlobalSettings(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/update_vibe_global_settings"),r={global_settings:s.global_settings};return this.request({url:i,method:"POST",data:r},t)}GetVibeProjectCases(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/get_vibe_project_cases"),r={project_type:s.project_type};return this.request({url:i,method:"POST",data:r},t)}UpdateVibeProject(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/update_vibe_project"),r={project_id:s.project_id,name:s.name,description:s.description,icon_uri:s.icon_uri,project_settings:s.project_settings};return this.request({url:i,method:"POST",data:r},t)}CopyVibeProject(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/copy_vibe_project"),r={project_id:s.project_id,name:s.name,description:s.description,icon_uri:s.icon_uri,icon_url:s.icon_url,target_space_id:s.target_space_id};return this.request({url:i,method:"POST",data:r},t)}ChatCreateVibeProject(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/create_vibe_project"),r={space_id:s.space_id,user_query:s.user_query,project_type:s.project_type,agent_tools:s.agent_tools,project_settings:s.project_settings};return this.request({url:i,method:"POST",data:r},t)}UploadFile(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/upload_file"),r={data:s.data},n={"Content-Type":s["Content-Type"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}GetVibeProject(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/get_vibe_project"),r={project_id:s.project_id,project_symbol:s.project_symbol};return this.request({url:i,method:"POST",data:r},t)}CreatePostgresqlDatabase(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/postgresql"),r={project_id:s.project_id,user_id:s.user_id,space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}CreateStorageBucket(e,t){const s=e,i=this.genBaseURL("/api/memory/storage/create"),r={project_id:s.project_id,user_id:s.user_id,bucket_name:s.bucket_name,space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}ListStorageBucket(e,t){const s=e||{},i=this.genBaseURL("/api/memory/storage/list"),r={project_id:s.project_id,bucket_ids:s.bucket_ids,env:s.env};return this.request({url:i,method:"POST",data:r},t)}ListPostgresqlDatabase(e,t){const s=e||{},i=this.genBaseURL("/api/memory/databases/postgresql/list"),r={project_id:s.project_id,database_ids:s.database_ids,env:s.env};return this.request({url:i,method:"POST",data:r},t)}RestorePostgresqlDatabase(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/postgresql/restore"),r={project_id:s.project_id,database_ids:s.database_ids,env:s.env,timestamp:s.timestamp};return this.request({url:i,method:"POST",data:r},t)}DeleteStorageBucket(e,t){const s=e||{},i=this.genBaseURL("/api/memory/storage/delete"),r={project_id:s.project_id,bucket_ids:s.bucket_ids};return this.request({url:i,method:"POST",data:r},t)}DeletePostgresqlDatabase(e,t){const s=e||{},i=this.genBaseURL("/api/memory/databases/postgresql/delete"),r={project_id:s.project_id,database_ids:s.database_ids};return this.request({url:i,method:"POST",data:r},t)}CheckRestorePossibility(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/postgresql/restore/check"),r={project_id:s.project_id,database_ids:s.database_ids,env:s.env,timestamp:s.timestamp};return this.request({url:i,method:"POST",data:r},t)}CreateStorageFolder(e,t){const s=e,i=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/folder/create`),r={folder_name:s.folder_name};return this.request({url:i,method:"POST",data:r},t)}GetFileURL(e,t){const s=e,i=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/get_url`),r={uri_list:s.uri_list,expired_time:s.expired_time};return this.request({url:i,method:"POST",data:r},t)}StorageFileMigrate(e,t){const s=e,i=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/migrate`),r={folder_name_list:s.folder_name_list,obj_name_list:s.obj_name_list,target_folder:s.target_folder,action:s.action};return this.request({url:i,method:"POST",data:r},t)}UploadStorageFile(e,t){const s=e,i=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/upload`),r={body:s.body},n={"Content-Type":s["Content-Type"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}StorageFileRename(e,t){const s=e,i=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/rename`),r={rename_list:s.rename_list};return this.request({url:i,method:"POST",data:r},t)}DeleteStorageFile(e,t){const s=e,i=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/delete`),r={folder_name_list:s.folder_name_list,obj_name_list:s.obj_name_list};return this.request({url:i,method:"POST",data:r},t)}ListStorageObjects(e,t){const s=e,i=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/list`),r={prefix:s.prefix,page_size:s.page_size,page_token:s.page_token,search_key:s.search_key};return this.request({url:i,method:"POST",data:r},t)}CreateContent(e,t){const s=e||{},i=this.genBaseURL(`/api/memory/databases/${s.database_id}/content`),r={id:s.id,name:s.name,type:s.type,visibility:s.visibility,description:s.description,favorite:s.favorite,folder_id:s.folder_id,owner_id:s.owner_id,content_json:s.content_json};return this.request({url:i,method:"POST",data:r},t)}UpdateWholeContent(e,t){const s=e||{},i=this.genBaseURL(`/api/memory/databases/${s.database_id}/content`),r={id:s.id,name:s.name,type:s.type,visibility:s.visibility,description:s.description,favorite:s.favorite,folder_id:s.folder_id,owner_id:s.owner_id,content_json:s.content_json};return this.request({url:i,method:"PUT",data:r},t)}DeleteContents(e,t){const s=e||{},i=this.genBaseURL(`/api/memory/databases/${s.database_id}/content`),r={ids:s.ids};return this.request({url:i,method:"DELETE",data:r},t)}GetContentById(e,t){const s=e||{},i=this.genBaseURL(`/api/memory/databases/${s.database_id}/content/${s.item_id}`);return this.request({url:i,method:"GET"},t)}GetContent(e,t){const s=e||{},i=this.genBaseURL(`/api/memory/databases/${s.database_id}/content`),r={cursor:s.cursor,favorite:s.favorite,limit:s.limit,name:s.name,sort_by:s.sort_by,sort_order:s.sort_order,type:s.type,visibility:s.visibility};return this.request({url:i,method:"GET",params:r},t)}UploadProjectFile(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/sandbox/file/upload"),r={body:s.body},n={"Content-Type":s["Content-Type"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}InitSandbox(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/sandbox/init_sandbox"),r={project_id:s.project_id,source:s.source},n={"x-devbox-cli-env":s["x-devbox-cli-env"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}GetProjectFileUrl(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/sandbox/file/get_url"),r={file_path:s.file_path,project_id:s.project_id};return this.request({url:i,method:"GET",params:r},t)}UpdateRestoreRetention(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/postgresql/restore/retention"),r={database_id:s.database_id,retention_hours:s.retention_hours};return this.request({url:i,method:"POST",data:r},t)}RestoreRepoVersion(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/repository/restore"),r={ProjectID:s.ProjectID,CommitID:s.CommitID,NoConfirm:s.NoConfirm,ConfirmInfos:s.ConfirmInfos,ConversationID:s.ConversationID};return this.request({url:i,method:"POST",data:r},t)}RefreshVibeProjectCases(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/refresh_vibe_project_cases"),r={refresh_token:s.refresh_token};return this.request({url:i,method:"POST",data:r},t)}GetUserQueryForCreate(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/get_user_query_for_create"),r={query_id:s.query_id,scene:s.scene},n={Cookie:s.Cookie};return this.request({url:i,method:"POST",data:r,headers:n},t)}DeleteVibeProject(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/delete_vibe_project"),r={project_id:s.project_id};return this.request({url:i,method:"POST",data:r},t)}CheckUserFeature(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/check_user_feature"),r={feature_keys:s.feature_keys};return this.request({url:i,method:"POST",data:r},t)}UpsertVibeProjectShare(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/upsert_share_info"),r={project_id:s.project_id,is_public_share:s.is_public_share,relative_expired_time:s.relative_expired_time};return this.request({url:i,method:"POST",data:r},t)}GetVibeProjectShare(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/get_share_info"),r={project_id:s.project_id};return this.request({url:i,method:"POST",data:r},t)}GetProtectSchemaList(e,t){const s=this.genBaseURL("/api/memory/databases/postgresql/get_protect_schema");return this.request({url:s,method:"POST"},t)}BatchImportData(e,t){const s=e,i=this.genBaseURL("/v1/knowledge_base/batch_import"),r={dataset:s.dataset,data:s.data,chunk_config:s.chunk_config},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}GetSchemaTables(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/postgresql/get_schema_tables"),r={project_id:s.project_id,database_env:s.database_env,schema:s.schema};return this.request({url:i,method:"POST",data:r},t)}ConvertFile(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/sandbox/file/convert"),r={file_path:s.file_path,project_id:s.project_id,target_file_type:s.target_file_type};return this.request({url:i,method:"GET",params:r},t)}GetDatabaseSupportVector(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/postgresql/get_support_vector"),r={database_id:s.database_id};return this.request({url:i,method:"POST",data:r},t)}RecallData(e,t){const s=e,i=this.genBaseURL("/v1/knowledge_base/recall"),r={dataset:s.dataset,query:s.query,top_k:s.top_k,min_score:s.min_score},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}GetFileInterfaceConfig(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/sandbox/file/get_interface_config"),r={project_id:s.project_id};return this.request({url:i,method:"GET",params:r},t)}UpsertProjectCopyType(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/upsert_copy_type"),r={project_id:s.project_id,enable_cross_space_copy:s.enable_cross_space_copy};return this.request({url:i,method:"POST",data:r},t)}OpenGetVibeProjectInfo(e,t){const s=e||{},i=this.genBaseURL(`/v1/vibe_projects/${s.project_id}`);return this.request({url:i,method:"GET"},t)}ImportSpaceDevAgent(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/import_space_dev_agent"),r={task_id:s.task_id,space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}CreateCommit(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/repository/create_commit"),r={ProjectID:s.ProjectID,message:s.message};return this.request({url:i,method:"POST",data:r},t)}ListBuckets(e,t){const s=e,i=this.genBaseURL("/v1/supabase/buckets/list"),r={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",headers:r},t)}DeleteBucket(e,t){const s=e,i=this.genBaseURL("/v1/supabase/buckets/delete"),r={bucket_id:s.bucket_id},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}GetEdgeFunction(e,t){const s=e,i=this.genBaseURL("/v1/supabase/functions/get"),r={slug:s.slug},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}DeleteEdgeFunction(e,t){const s=e,i=this.genBaseURL("/v1/supabase/functions/delete"),r={slug:s.slug},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}ListEdgeFunctions(e,t){const s=e,i=this.genBaseURL("/v1/supabase/functions/list"),r={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",headers:r},t)}UpdateAuthConfig(e,t){const s=e,i=this.genBaseURL("/v1/supabase/auth/config/update"),r={config:s.config},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}GetBucket(e,t){const s=e,i=this.genBaseURL("/v1/supabase/buckets/get"),r={bucket_id:s.bucket_id},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}GetAuthConfig(e,t){const s=e,i=this.genBaseURL("/v1/supabase/auth/config/get"),r={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",headers:r},t)}UpdateBucket(e,t){const s=e,i=this.genBaseURL("/v1/supabase/buckets/update"),r={bucket_id:s.bucket_id,public:s.public,file_size_limit:s.file_size_limit,allowed_mime_types:s.allowed_mime_types},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}DeployEdgeFunction(e,t){const s=e,i=this.genBaseURL("/v1/supabase/functions/deploy"),r={slug:s.slug,code:s.code,files:s.files,name:s.name,entrypoint:s.entrypoint,verify_jwt:s.verify_jwt},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}CreateBucket(e,t){const s=e,i=this.genBaseURL("/v1/supabase/buckets/create"),r={bucket_id:s.bucket_id,name:s.name,public:s.public,file_size_limit:s.file_size_limit,allowed_mime_types:s.allowed_mime_types},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}OpenConvertFile(e,t){const s=e||{},i=this.genBaseURL("/v1/vibe_projects/files/convert"),r={project_id:s.project_id,file_url:s.file_url,target_file_type:s.target_file_type};return this.request({url:i,method:"POST",data:r},t)}OpenUploadFile(e,t){const s=e||{},i=this.genBaseURL("/v1/vibe_projects/files/upload"),r={body:s.body},n={"Content-Type":s["Content-Type"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}GetUserAssistantAttrs(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/get_user_assistant_attrs"),r={space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}GetProjectArtifactShare(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/get_artifact_share"),r={project_id:s.project_id};return this.request({url:i,method:"POST",data:r},t)}UpsertProjectArtifactShare(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/upsert_artifact_share"),r={project_id:s.project_id,is_artifact_share:s.is_artifact_share,relative_expired_time:s.relative_expired_time};return this.request({url:i,method:"POST",data:r},t)}GetUserProjectNum(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/get_user_project_num"),r={enterprise_id:s.enterprise_id,organization_id:s.organization_id};return this.request({url:i,method:"POST",data:r},t)}GetLarkTableContent(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/get_content"),r={scene:s.scene};return this.request({url:i,method:"POST",data:r},t)}GetProjectStatus(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/sandbox/project_status"),r={project_id:s.project_id};return this.request({url:i,method:"GET",params:r},t)}UpdateProjectSkillSetting(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/update_project_skill_setting"),r={project_id:s.project_id,add_skills:s.add_skills,remove_skills:s.remove_skills};return this.request({url:i,method:"POST",data:r},t)}ProxySandboxMessage(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/repository/proxy_sandbox_message"),r={ProjectID:s.ProjectID,Method:s.Method,Params:s.Params};return this.request({url:i,method:"POST",data:r},t)}GetOauthStatus(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/repository/integration/oauth/status"),r={integration_id:s.integration_id,space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}SearchRepo(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/repository/integration/search_repo"),r={space_id:s.space_id,name_search:s.name_search,per_page:s.per_page,page:s.page};return this.request({url:i,method:"POST",data:r},t)}AddRemote(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/repository/integration/add_remote"),r={project_id:s.project_id,integration_id:s.integration_id,repo_full_name:s.repo_full_name,has_add_in_devbox:s.has_add_in_devbox};return this.request({url:i,method:"POST",data:r},t)}RemoveRemote(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/repository/integration/remove_remote"),r={project_id:s.project_id};return this.request({url:i,method:"POST",data:r},t)}ListIntegration(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/repository/integration/list"),r={space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}CreateRepo(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/repository/integration/create_repo"),r={space_id:s.space_id,name:s.name,private:s.private};return this.request({url:i,method:"POST",data:r},t)}CancelOauth(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/repository/integration/oauth/cancel"),r={integration_id:s.integration_id,space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}GetOauthConfig(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/repository/integration/oauth/oauth_config"),r={integration_id:s.integration_id,space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}ListDatabaseRestoreHistory(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/postgresql/restore/history"),r={project_id:s.project_id,commit_id:s.commit_id,env:s.env,limit:s.limit,cursor:s.cursor};return this.request({url:i,method:"POST",data:r},t)}ImportProject(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/import_project"),r={space_id:s.space_id,import_source:s.import_source,data:s.data,git_url:s.git_url,git_repo_name:s.git_repo_name,project_symbol:s.project_symbol},n={"Content-Type":s["Content-Type"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}GetUser(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/repository/integration/user"),r={space_id:s.space_id,integration_id:s.integration_id};return this.request({url:i,method:"POST",data:r},t)}GetRemote(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/repository/integration/get_remote"),r={project_id:s.project_id};return this.request({url:i,method:"POST",data:r},t)}DiagnoseDatabaseHTTP(e,t){const s=e,i=this.genBaseURL("/v1/supabase/database/diagnose"),r={env:s.env},n={"x-coze-token":s["x-coze-token"]};return this.request({url:i,method:"POST",data:r,headers:n},t)}GetProjectDisplayTabInfo(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/get_display_tab_info"),r={project_id:s.project_id};return this.request({url:i,method:"POST",data:r},t)}GetOrCreateBillingProject(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/get_or_create_billing_project"),r={space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}UpdatePermissionSetting(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/update_permission_setting"),r={project_id:s.project_id,add_commands:s.add_commands,remove_commands:s.remove_commands};return this.request({url:i,method:"POST",data:r},t)}OptimizeQuery(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/optimize_query"),r={query:s.query,project_type:s.project_type};return this.request({url:i,method:"POST",data:r},t)}CreateSpaceDatabase(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/space/create"),r={space_id:s.space_id};return this.request({url:i,method:"POST",data:r},t)}GetSpaceDatabase(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/space/get"),r={space_id:s.space_id,database_id:s.database_id};return this.request({url:i,method:"POST",data:r},t)}ListSpaceDatabase(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/space/list"),r={space_id:s.space_id,cursor_id:s.cursor_id,limit:s.limit};return this.request({url:i,method:"POST",data:r},t)}GetSpaceDatabaseStatus(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/space/status"),r={space_id:s.space_id,database_id:s.database_id};return this.request({url:i,method:"POST",data:r},t)}DeleteSpaceDatabase(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/space/delete"),r={space_id:s.space_id,database_id:s.database_id};return this.request({url:i,method:"POST",data:r},t)}RollbackSpaceDatabase(e,t){const s=e,i=this.genBaseURL("/api/memory/databases/space/rollback"),r={space_id:s.space_id,database_id:s.database_id,timestamp:s.timestamp};return this.request({url:i,method:"POST",data:r},t)}GetVibeProjectMembers(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/get_members"),r={project_id:s.project_id,include_creator:s.include_creator};return this.request({url:i,method:"POST",data:r},t)}SendNotice(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/send_notice"),r={project_id:s.project_id,notice_type:s.notice_type,uids:s.uids,variables:s.variables};return this.request({url:i,method:"POST",data:r},t)}UpdateProjectPinStatus(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/update_project_pin_status"),r={project_id:s.project_id,is_pin:s.is_pin};return this.request({url:i,method:"POST",data:r},t)}ImportProjectToSpace(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/import_project_to_space"),r={project_id:s.project_id};return this.request({url:i,method:"POST",data:r},t)}GetProjectListForSpace(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/get_project_list_for_space"),r={user_client:s.user_client,enterprise_id:s.enterprise_id,organization_id:s.organization_id,page_size:s.page_size,cursor:s.cursor,is_pinned:s.is_pinned,name:s.name,is_trigger_onboarding:s.is_trigger_onboarding};return this.request({url:i,method:"POST",data:r},t)}GetCommitScreenshot(e,t){const s=e,i=this.genBaseURL("/api/ideserver_api/project/get_screenshot"),r={project_id:s.project_id,commit_id:s.commit_id};return this.request({url:i,method:"POST",data:r},t)}}bs.prototype.UploadProjectFile=function(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/sandbox/file/upload"),r=s.body;return this.request({url:i,method:"POST",data:r},t)},bs.prototype.UploadFile=function(e,t){const s=e||{},i=this.genBaseURL("/api/ideserver_api/project/upload_file"),r=s.data;return this.request({url:i,method:"POST",data:r},t)};const Ns=new bs({});function Us(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}const Ps=/(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g;class Os{constructor(){Os.prototype.__init.call(this),Os.prototype.__init2.call(this),Os.prototype.__init3.call(this),Os.prototype.__init4.call(this),Os.prototype.__init5.call(this),Os.prototype.__init6.call(this),Os.prototype.__init7.call(this),Os.prototype.__init8.call(this),Os.prototype.__init9.call(this),Os.prototype.__init10.call(this),Os.prototype.__init11.call(this),Os.prototype.__init12.call(this)}__init(){this.ctx={options:{},get:()=>({})}}__init2(){this.init=o.noop}__init3(){this.createLoggerWith=()=>new Os}__init4(){this.info=o.noop}__init5(){this.error=o.noop}__init6(){this.slardarInfo=o.noop}__init7(){this.slardarSuccess=o.noop}__init8(){this.slardarError=o.noop}__init9(){this.slardarEvent=o.noop}__init10(){this.slardarSuccessEvent=o.noop}__init11(){this.slardarErrorEvent=o.noop}__init12(){this.slardarTracer=()=>({trace:o.noop})}}function ks(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}const Bs=e=>{const{onData:t}=e,s=e.buffered.split(/\n\n/),i=(r=s.pop(),n=()=>"",null!=r?r:n());var r,n;for(const e of s){const s=e.split(/\r?\n/),i=[];for(const e of s)e.startsWith("data:")&&i.push(e.slice(5).trimStart());if(0===i.length)continue;const r=i.join("\n").trim();r&&"[DONE]"!==r&&t(r)}return{buffered:i}},js=async e=>{const{apiBaseUrl:t,request:i,onStart:r,onMessage:n,signal:a,totalTimeoutMs:o,onTotalTimeout:c,betweenChunkTimeoutMs:_,onBetweenChunkTimeout:l}=e,h=new AbortController;((e,t)=>{t&&(t.aborted?e.abort():t.addEventListener("abort",(()=>e.abort()),{once:!0}))})(h,a);const u=(e=>{const{controller:t,timeoutMs:s,onTimeout:i}=e;if(!s||s<=0)return()=>{};const r=setTimeout((()=>{ks([i,"optionalCall",e=>e()]),t.abort()}),s);return()=>clearTimeout(r)})({controller:h,timeoutMs:o,onTimeout:c}),d=(e=>{const{controller:t,timeoutMs:s,onTimeout:i}=e;if(!s||s<=0)return{refresh:()=>{},clear:()=>{}};let r=null;const n=()=>{r&&(clearTimeout(r),r=null)};return{refresh:()=>{n(),r=setTimeout((()=>{ks([i,"optionalCall",e=>e()]),t.abort()}),s)},clear:n}})({controller:h,timeoutMs:_,onTimeout:l});try{const e=new URL(`/v1/api/project/${i.project_id}/chat/message/send`,t),a=await s.customFetch.fetch(e.toString(),{method:"POST",signal:h.signal,body:JSON.stringify({message:i.message,device_id:i.device_id,project_id:i.project_id})});if(!a.ok)throw new Error(`ChatCLISendMessage failed: ${a.status} ${a.statusText}`);if(!a.body)throw new Error("ChatCLISendMessage response body is empty");await ks([r,"optionalCall",e=>e(a)]);const o=new TextDecoder("utf-8"),c=a.body.getReader();let _="";for(d.refresh();;){const{done:e,value:t}=await c.read();if(e)break;d.refresh(),_+=o.decode(t,{stream:!0});_=Bs({buffered:_,onData:e=>{const t=JSON.parse(e);n(t)}}).buffered}_+=o.decode(),Bs({buffered:_,onData:e=>{const t=JSON.parse(e);n(t)}})}catch(e){if((e=>!(!e||"object"!=typeof e)&&"AbortError"===e.name)(e))return;throw e}finally{u(),d.clear()}};function Ds(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}class Gs extends Error{constructor(e,t){super(e),Gs.prototype.__init.call(this),this.name="ChatCLIChannelError",this.ext=t}__init(){this.flatten=()=>{const{message:e,ext:t}=this;return{message:e,...t}}}}const qs=e=>!(!e||"object"!=typeof e)&&"AbortError"===e.name;class ws{__init2(){this.channelName="ChatCLI"}__init3(){this.isChannelOpenPromise=null}__init4(){this.opened=!1}__init5(){this.destroyed=!1}__init6(){this.abortController=null}__init7(){this.eventBus=e()}constructor(e){ws.prototype.__init2.call(this),ws.prototype.__init3.call(this),ws.prototype.__init4.call(this),ws.prototype.__init5.call(this),ws.prototype.__init6.call(this),ws.prototype.__init7.call(this),ws.prototype.__init8.call(this),ws.prototype.__init9.call(this),ws.prototype.__init10.call(this),ws.prototype.__init11.call(this),ws.prototype.__init12.call(this),ws.prototype.__init13.call(this),ws.prototype.__init14.call(this),ws.prototype.__init15.call(this),ws.prototype.__init16.call(this),this.apiBaseUrl=e.apiBaseUrl,this.deviceId=e.deviceId,this.totalTimeoutMs=e.totalTimeoutMs,this.betweenChunkTimeoutMs=e.betweenChunkTimeoutMs}__init8(){this.getChannelOptions=()=>({apiBaseUrl:this.apiBaseUrl})}__init9(){this.connect=async()=>{this.destroyed||(this.opened=!0,this.isChannelOpenPromise=Promise.resolve(),this.eventBus.emit("onopen",void 0))}}__init10(){this.reconnect=async()=>{await this.connect()}}__init11(){this.isChannelOpen=()=>this.opened}__init12(){this.addEventListener=(e,t)=>{this.eventBus.on(e,t)}}__init13(){this.removeEventListener=(e,t)=>{this.eventBus.off(e,t)}}__init14(){this.send=async e=>{if(this.destroyed)throw new Error("ChatCLIChannel is destroyed");this.opened||await this.connect(),Ds([this,"access",e=>e.abortController,"optionalAccess",e=>e.abort,"call",e=>e()]);const t=new AbortController;this.abortController=t;const s=e,i={project_id:s.project_id,message:s,device_id:(r=this.deviceId,n=()=>{},null!=r?r:n())};var r,n;let a=!1,o=null;const c=new Promise((e=>{js({apiBaseUrl:this.apiBaseUrl,request:i,signal:t.signal,totalTimeoutMs:this.totalTimeoutMs,betweenChunkTimeoutMs:this.betweenChunkTimeoutMs,onTotalTimeout:()=>{this.eventBus.emit("onerror",new Gs("ChatCLISendMessage total timeout",{willClose:!0}))},onBetweenChunkTimeout:()=>{this.eventBus.emit("onerror",new Gs("ChatCLISendMessage between-chunk timeout",{willClose:!0}))},onStart:()=>{a=!0,this.eventBus.emit("onack",{code:"0",msg:""}),e()},onMessage:e=>{this.eventBus.emit("onmessage",e)}}).then((()=>{this.eventBus.emit("onclose",{code:0,reason:"eof"})})).catch((t=>{if(!a)return o=t,void e();qs(t)?this.eventBus.emit("onclose",{code:1e3,reason:"aborted"}):(this.eventBus.emit("onerror",new Gs(`ChatCLISendMessage stream error: ${String(t)}`,{willClose:!0,rawError:t})),this.eventBus.emit("onclose",{code:1,reason:String(t)}))})).finally((()=>{this.abortController===t&&(this.abortController=null)}))}));if(await c,o){if(qs(o))return;throw this.eventBus.emit("onerror",new Gs(`ChatCLISendMessage request error: ${String(o)}`,{willClose:!0,rawError:o})),o}}}__init15(){this.close=()=>{Ds([this,"access",e=>e.abortController,"optionalAccess",e=>e.abort,"call",e=>e()]),this.abortController=null,this.opened=!1}}__init16(){this.destroy=()=>{this.destroyed||(this.destroyed=!0,this.close(),this.eventBus.all.clear())}}}function Fs(e){let t,s=e[0],i=1;for(;i<e.length;){const r=e[i],n=e[i+1];if(i+=2,("optionalAccess"===r||"optionalCall"===r)&&null==s)return;"access"===r||"optionalAccess"===r?(t=s,s=n(s)):"call"!==r&&"optionalCall"!==r||(s=n(((...e)=>s.call(t,...e))),t=void 0)}return s}const xs=e=>{const{key:t,apiBaseUrl:s,totalTimeoutMs:i,betweenChunkTimeoutMs:r}=e,n=new ws({apiBaseUrl:s,totalTimeoutMs:i,betweenChunkTimeoutMs:r});return new ys({key:t,env:"production",logLevel:"error",channel:n,reportLog:new Os})};exports.BuildAgentApi=Be,exports.ChatCoreError=Nt,exports.IdeApi=Ns,exports.createChatCore=xs,exports.sendProjectChatMessage=async e=>{const{projectId:t,prompt:o,apiBaseUrl:c,sessionId:_="",key:l=`coze-coding-cli:chat:${t}`,totalTimeoutMs:h,betweenChunkTimeoutMs:u,onMessageItem:d,onWarn:p,waitForResponse:g=!0}=e,T=xs({key:l,apiBaseUrl:c,totalTimeoutMs:h,betweenChunkTimeoutMs:u}),E=new It;let m=!1;const f=e=>{m||(m=!0,e())};let L;const A=T.on(St.MESSAGE_RECEIVED_AND_UPDATE,(({data:e})=>{for(const t of e)if(Fs([d,"optionalCall",e=>e(t)]),"answer"===t.type&&t.content.answer&&(L=t),"message_end"===t.type&&t.finish){const e=Fs([t,"access",e=>e.content,"access",e=>e.message_end,"optionalAccess",e=>e.code]);if(e&&"0"!==e){f((()=>{E.reject(new s.CozeError(s.ErrorCode.E5002,`Conversation ended with error code: ${e}`,{message_end:t.content.message_end}))}));continue}f((()=>{E.resolve()}))}}),!0),S=T.on(St.SEND_MESSAGE_ERROR,(e=>{f((()=>{E.reject(e.data.error)}))}),!0),R=T.on(St.MESSAGE_PULLING_STATUS,(({data:e,error:t})=>{const s=e.pullingStatus;"error"!==s&&"channel_error"!==s||f((()=>{E.reject(t)})),("success"===s||"cancel"===s||!g&&"start"===s)&&f((()=>{E.resolve()}))}),!0);try{const e=await(async(e,t,s,r)=>{const n=[],o=[...e.matchAll(Ps)];if(0===o.length)return[{type:"text",content:{text:e}}];let c=0;for(const _ of o){const o=_.index,l=_[0],h=_[1];o>c&&n.push({type:"text",content:{text:e.slice(c,o)}});const u=i.resolve(t,h);let d=!1;if(u.startsWith(i.resolve(t)))try{(await a.stat(u)).isFile()?d=!0:Us([r,"optionalCall",e=>e(`Uploading directories is not supported: ${h}`)])}catch(e){Us([r,"optionalCall",e=>e(`File not found: ${h}`)])}if(d)try{const e=await s(u);n.push({type:"upload_file",content:{upload_file:e}})}catch(e){Us([r,"optionalCall",t=>t(`Failed to upload file: ${h}, ${String(e)}`)]),n.push({type:"text",content:{text:l}})}else n.push({type:"text",content:{text:l}});c=o+l.length}return c<e.length&&n.push({type:"text",content:{text:e.slice(c)}}),n})(o,process.cwd(),(e=>async t=>{const s=i.basename(t),a=new n;a.append("project_id",e),a.append("file_name",s),a.append("file_content",r.createReadStream(t));const o=await Ns.UploadProjectFile({body:a},{headers:{...a.getHeaders()}});if(!o.file)throw new Error(`Upload failed for file: ${t}`);return{file_name:o.file.name,file_path:o.file.file_path,url:o.file.url}})(t),p),s=T.createQueryMessage({query:{prompt:e}},{session_id:_,project_id:t,conversation_id:void 0});return await T.sendChatMessage(s),await E.promise,{lastAnswerMessage:L}}finally{A(),S(),R(),T.destroy()}};
|