@next-open-ai/openclawx 0.8.22 → 0.8.26
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
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
| **功能说明** | [代理模式与多节点](docs/features/proxy-mode.md) | Coze 接入、OpenClawX 多节点协作 |
|
|
26
26
|
| | [技能系统](docs/features/skills.md) | Agent Skills 规范与扩展 |
|
|
27
27
|
| **参考** | [常见问题](docs/reference/faq.md) | 安装失败、端口占用、通道不回复等 FAQ |
|
|
28
|
+
| | [发布说明](docs/release-notes.md) | 各版本功能更新与问题修复记录 |
|
|
28
29
|
|
|
29
30
|
<details>
|
|
30
31
|
<summary><strong>📂 文档树结构</strong></summary>
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
```
|
|
33
34
|
docs/
|
|
34
35
|
├── README.md → 文档入口与导航
|
|
36
|
+
├── release-notes.md → 发布说明
|
|
35
37
|
├── guides/ → 使用指南
|
|
36
38
|
│ ├── getting-started.md 快速开始
|
|
37
39
|
│ ├── installation.md 安装与部署
|
|
@@ -52,6 +54,13 @@ docs/
|
|
|
52
54
|
|
|
53
55
|
</details>
|
|
54
56
|
|
|
57
|
+
### 常见问题(简要)
|
|
58
|
+
|
|
59
|
+
- **Windows 安装失败 / 无法运行?**
|
|
60
|
+
- **Desktop 安装包**:若安装或启动报错(如缺少运行库、闪退),请安装 [Visual C++ Redistributable](https://learn.microsoft.com/zh-cn/cpp/windows/latest-supported-vc-redist)(选 x64);若为杀毒/安全软件拦截,可尝试加入排除项或暂时关闭后重试。
|
|
61
|
+
- **npm 全局安装**:Windows 上若因 `node-llama-cpp` 等原生依赖安装失败,可使用 `npm install -g @next-open-ai/openclawx --ignore-scripts` 跳过可选原生模块,对 CLI/Gateway/Desktop 常规使用无影响;长记忆需单独配置在线 RAG 或本地环境。
|
|
62
|
+
- 更多问题(macOS 安装包「已损坏」、端口占用、通道不回复等)见 **[常见问题](docs/reference/faq.md)**;版本变更见 **[发布说明](docs/release-notes.md)**。
|
|
63
|
+
|
|
55
64
|
---
|
|
56
65
|
|
|
57
66
|
## 特性概览
|
|
@@ -168,6 +177,13 @@ npm -v # 能正常输出版本号
|
|
|
168
177
|
# 全局安装(测试过 node 版本:20/22;24 太新,部分库需本地编译环境)
|
|
169
178
|
npm install -g @next-open-ai/openclawx
|
|
170
179
|
```
|
|
180
|
+
#### ***如果是在windows上安装最新版本(v0.8.0以上版本),可能会因为node-llama-cpp无法安装,可以采用如下安装命令跳过它的安装,对当前系统使用无影响***
|
|
181
|
+
```bash
|
|
182
|
+
# 跳过预下载脚本
|
|
183
|
+
npm install -g @next-open-ai/openclawx --ignore-scripts
|
|
184
|
+
# 尝试手工安装跳过的预下载(这一步失败了也不影响正常使用)
|
|
185
|
+
npm run postinstall --if-present
|
|
186
|
+
```
|
|
171
187
|
|
|
172
188
|
安装后可直接使用 `openbot` 命令(见下方「使用方式」)。若需从源码构建再安装:
|
|
173
189
|
|
|
@@ -31,7 +31,7 @@ var Wb=Object.defineProperty;var P_=n=>{throw TypeError(n)};var Kb=(n,e,o)=>e in
|
|
|
31
31
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...o){const t=new this(e);return o.forEach(a=>t.set(a)),t}static accessor(e){const t=(this[Xu]=this[Xu]={accessors:{}}).accessors,a=this.prototype;function s(l){const r=aa(l);t[r]||(IR(a,l),t[r]=!0)}return $.isArray(e)?e.forEach(s):s(e),this}};Vt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);$.reduceDescriptors(Vt.prototype,({value:n},e)=>{let o=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(t){this[o]=t}}});$.freezeMethods(Vt);function vi(n,e){const o=this||Pa,t=e||o,a=Vt.from(t.headers);let s=t.data;return $.forEach(n,function(r){s=r.call(o,s,a.normalize(),e?e.status:void 0)}),a.normalize(),s}function ib(n){return!!(n&&n.__CANCEL__)}let Ua=class extends qe{constructor(e,o,t){super(e??"canceled",qe.ERR_CANCELED,o,t),this.name="CanceledError",this.__CANCEL__=!0}};function sb(n,e,o){const t=o.config.validateStatus;!o.status||!t||t(o.status)?n(o):e(new qe("Request failed with status code "+o.status,[qe.ERR_BAD_REQUEST,qe.ERR_BAD_RESPONSE][Math.floor(o.status/100)-4],o.config,o.request,o))}function DR(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function wR(n,e){n=n||10;const o=new Array(n),t=new Array(n);let a=0,s=0,l;return e=e!==void 0?e:1e3,function(c){const _=Date.now(),d=t[s];l||(l=_),o[a]=c,t[a]=_;let m=s,p=0;for(;m!==a;)p+=o[m++],m=m%n;if(a=(a+1)%n,a===s&&(s=(s+1)%n),_-l<e)return;const E=d&&_-d;return E?Math.round(p*1e3/E):void 0}}function kR(n,e){let o=0,t=1e3/e,a,s;const l=(_,d=Date.now())=>{o=d,a=null,s&&(clearTimeout(s),s=null),n(..._)};return[(..._)=>{const d=Date.now(),m=d-o;m>=t?l(_,d):(a=_,s||(s=setTimeout(()=>{s=null,l(a)},t-m)))},()=>a&&l(a)]}const Rr=(n,e,o=3)=>{let t=0;const a=wR(50,250);return kR(s=>{const l=s.loaded,r=s.lengthComputable?s.total:void 0,c=l-t,_=a(c),d=l<=r;t=l;const m={loaded:l,total:r,progress:r?l/r:void 0,bytes:c,rate:_||void 0,estimated:_&&r&&d?(r-l)/_:void 0,event:s,lengthComputable:r!=null,[e?"download":"upload"]:!0};n(m)},o)},Zu=(n,e)=>{const o=n!=null;return[t=>e[0]({lengthComputable:o,total:n,loaded:t}),e[1]]},Ju=n=>(...e)=>$.asap(()=>n(...e)),MR=xt.hasStandardBrowserEnv?((n,e)=>o=>(o=new URL(o,xt.origin),n.protocol===o.protocol&&n.host===o.host&&(e||n.port===o.port)))(new URL(xt.origin),xt.navigator&&/(msie|trident)/i.test(xt.navigator.userAgent)):()=>!0,xR=xt.hasStandardBrowserEnv?{write(n,e,o,t,a,s,l){if(typeof document>"u")return;const r=[`${n}=${encodeURIComponent(e)}`];$.isNumber(o)&&r.push(`expires=${new Date(o).toUTCString()}`),$.isString(t)&&r.push(`path=${t}`),$.isString(a)&&r.push(`domain=${a}`),s===!0&&r.push("secure"),$.isString(l)&&r.push(`SameSite=${l}`),document.cookie=r.join("; ")},read(n){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+n+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(n){this.write(n,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function LR(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function PR(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function lb(n,e,o){let t=!LR(e);return n&&(t||o==!1)?PR(n,e):e}const ju=n=>n instanceof Vt?{...n}:n;function ho(n,e){e=e||{};const o={};function t(_,d,m,p){return $.isPlainObject(_)&&$.isPlainObject(d)?$.merge.call({caseless:p},_,d):$.isPlainObject(d)?$.merge({},d):$.isArray(d)?d.slice():d}function a(_,d,m,p){if($.isUndefined(d)){if(!$.isUndefined(_))return t(void 0,_,m,p)}else return t(_,d,m,p)}function s(_,d){if(!$.isUndefined(d))return t(void 0,d)}function l(_,d){if($.isUndefined(d)){if(!$.isUndefined(_))return t(void 0,_)}else return t(void 0,d)}function r(_,d,m){if(m in e)return t(_,d);if(m in n)return t(void 0,_)}const c={url:s,method:s,data:s,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,withXSRFToken:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,beforeRedirect:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:r,headers:(_,d,m)=>a(ju(_),ju(d),m,!0)};return $.forEach(Object.keys({...n,...e}),function(d){const m=c[d]||a,p=m(n[d],e[d],d);$.isUndefined(p)&&m!==r||(o[d]=p)}),o}const cb=n=>{const e=ho({},n);let{data:o,withXSRFToken:t,xsrfHeaderName:a,xsrfCookieName:s,headers:l,auth:r}=e;if(e.headers=l=Vt.from(l),e.url=ob(lb(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),r&&l.set("Authorization","Basic "+btoa((r.username||"")+":"+(r.password?unescape(encodeURIComponent(r.password)):""))),$.isFormData(o)){if(xt.hasStandardBrowserEnv||xt.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if($.isFunction(o.getHeaders)){const c=o.getHeaders(),_=["content-type","content-length"];Object.entries(c).forEach(([d,m])=>{_.includes(d.toLowerCase())&&l.set(d,m)})}}if(xt.hasStandardBrowserEnv&&(t&&$.isFunction(t)&&(t=t(e)),t||t!==!1&&MR(e.url))){const c=a&&s&&xR.read(s);c&&l.set(a,c)}return e},UR=typeof XMLHttpRequest<"u",FR=UR&&function(n){return new Promise(function(o,t){const a=cb(n);let s=a.data;const l=Vt.from(a.headers).normalize();let{responseType:r,onUploadProgress:c,onDownloadProgress:_}=a,d,m,p,E,S;function T(){E&&E(),S&&S(),a.cancelToken&&a.cancelToken.unsubscribe(d),a.signal&&a.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(a.method.toUpperCase(),a.url,!0),g.timeout=a.timeout;function v(){if(!g)return;const N=Vt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),k={data:!r||r==="text"||r==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:N,config:n,request:g};sb(function(L){o(L),T()},function(L){t(L),T()},k),g=null}"onloadend"in g?g.onloadend=v:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(v)},g.onabort=function(){g&&(t(new qe("Request aborted",qe.ECONNABORTED,n,g)),g=null)},g.onerror=function(O){const k=O&&O.message?O.message:"Network Error",A=new qe(k,qe.ERR_NETWORK,n,g);A.event=O||null,t(A),g=null},g.ontimeout=function(){let O=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const k=a.transitional||ab;a.timeoutErrorMessage&&(O=a.timeoutErrorMessage),t(new qe(O,k.clarifyTimeoutError?qe.ETIMEDOUT:qe.ECONNABORTED,n,g)),g=null},s===void 0&&l.setContentType(null),"setRequestHeader"in g&&$.forEach(l.toJSON(),function(O,k){g.setRequestHeader(k,O)}),$.isUndefined(a.withCredentials)||(g.withCredentials=!!a.withCredentials),r&&r!=="json"&&(g.responseType=a.responseType),_&&([p,S]=Rr(_,!0),g.addEventListener("progress",p)),c&&g.upload&&([m,E]=Rr(c),g.upload.addEventListener("progress",m),g.upload.addEventListener("loadend",E)),(a.cancelToken||a.signal)&&(d=N=>{g&&(t(!N||N.type?new Ua(null,n,g):N),g.abort(),g=null)},a.cancelToken&&a.cancelToken.subscribe(d),a.signal&&(a.signal.aborted?d():a.signal.addEventListener("abort",d)));const R=DR(a.url);if(R&&xt.protocols.indexOf(R)===-1){t(new qe("Unsupported protocol "+R+":",qe.ERR_BAD_REQUEST,n));return}g.send(s||null)})},BR=(n,e)=>{const{length:o}=n=n?n.filter(Boolean):[];if(e||o){let t=new AbortController,a;const s=function(_){if(!a){a=!0,r();const d=_ instanceof Error?_:this.reason;t.abort(d instanceof qe?d:new Ua(d instanceof Error?d.message:d))}};let l=e&&setTimeout(()=>{l=null,s(new qe(`timeout of ${e}ms exceeded`,qe.ETIMEDOUT))},e);const r=()=>{n&&(l&&clearTimeout(l),l=null,n.forEach(_=>{_.unsubscribe?_.unsubscribe(s):_.removeEventListener("abort",s)}),n=null)};n.forEach(_=>_.addEventListener("abort",s));const{signal:c}=t;return c.unsubscribe=()=>$.asap(r),c}},GR=function*(n,e){let o=n.byteLength;if(o<e){yield n;return}let t=0,a;for(;t<o;)a=t+e,yield n.slice(t,a),t=a},YR=async function*(n,e){for await(const o of HR(n))yield*GR(o,e)},HR=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:o,value:t}=await e.read();if(o)break;yield t}}finally{await e.cancel()}},em=(n,e,o,t)=>{const a=YR(n,e);let s=0,l,r=c=>{l||(l=!0,t&&t(c))};return new ReadableStream({async pull(c){try{const{done:_,value:d}=await a.next();if(_){r(),c.close();return}let m=d.byteLength;if(o){let p=s+=m;o(p)}c.enqueue(new Uint8Array(d))}catch(_){throw r(_),_}},cancel(c){return r(c),a.return()}},{highWaterMark:2})},tm=64*1024,{isFunction:tr}=$,qR=(({Request:n,Response:e})=>({Request:n,Response:e}))($.global),{ReadableStream:nm,TextEncoder:om}=$.global,am=(n,...e)=>{try{return!!n(...e)}catch{return!1}},VR=n=>{n=$.merge.call({skipUndefined:!0},qR,n);const{fetch:e,Request:o,Response:t}=n,a=e?tr(e):typeof fetch=="function",s=tr(o),l=tr(t);if(!a)return!1;const r=a&&tr(nm),c=a&&(typeof om=="function"?(S=>T=>S.encode(T))(new om):async S=>new Uint8Array(await new o(S).arrayBuffer())),_=s&&r&&am(()=>{let S=!1;const T=new o(xt.origin,{body:new nm,method:"POST",get duplex(){return S=!0,"half"}}).headers.has("Content-Type");return S&&!T}),d=l&&r&&am(()=>$.isReadableStream(new t("").body)),m={stream:d&&(S=>S.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(S=>{!m[S]&&(m[S]=(T,g)=>{let v=T&&T[S];if(v)return v.call(T);throw new qe(`Response type '${S}' is not supported`,qe.ERR_NOT_SUPPORT,g)})});const p=async S=>{if(S==null)return 0;if($.isBlob(S))return S.size;if($.isSpecCompliantForm(S))return(await new o(xt.origin,{method:"POST",body:S}).arrayBuffer()).byteLength;if($.isArrayBufferView(S)||$.isArrayBuffer(S))return S.byteLength;if($.isURLSearchParams(S)&&(S=S+""),$.isString(S))return(await c(S)).byteLength},E=async(S,T)=>{const g=$.toFiniteNumber(S.getContentLength());return g??p(T)};return async S=>{let{url:T,method:g,data:v,signal:R,cancelToken:N,timeout:O,onDownloadProgress:k,onUploadProgress:A,responseType:L,headers:B,withCredentials:Y="same-origin",fetchOptions:ge}=cb(S),ce=e||fetch;L=L?(L+"").toLowerCase():"text";let ne=BR([R,N&&N.toAbortSignal()],O),Ce=null;const te=ne&&ne.unsubscribe&&(()=>{ne.unsubscribe()});let W;try{if(A&&_&&g!=="get"&&g!=="head"&&(W=await E(B,v))!==0){let H=new o(T,{method:"POST",body:v,duplex:"half"}),pe;if($.isFormData(v)&&(pe=H.headers.get("content-type"))&&B.setContentType(pe),H.body){const[oe,ie]=Zu(W,Rr(Ju(A)));v=em(H.body,tm,oe,ie)}}$.isString(Y)||(Y=Y?"include":"omit");const I=s&&"credentials"in o.prototype,U={...ge,signal:ne,method:g.toUpperCase(),headers:B.normalize().toJSON(),body:v,duplex:"half",credentials:I?Y:void 0};Ce=s&&new o(T,U);let ae=await(s?ce(Ce,ge):ce(T,U));const we=d&&(L==="stream"||L==="response");if(d&&(k||we&&te)){const H={};["status","statusText","headers"].forEach(fe=>{H[fe]=ae[fe]});const pe=$.toFiniteNumber(ae.headers.get("content-length")),[oe,ie]=k&&Zu(pe,Rr(Ju(k),!0))||[];ae=new t(em(ae.body,tm,oe,()=>{ie&&ie(),te&&te()}),H)}L=L||"text";let G=await m[$.findKey(m,L)||"text"](ae,S);return!we&&te&&te(),await new Promise((H,pe)=>{sb(H,pe,{data:G,headers:Vt.from(ae.headers),status:ae.status,statusText:ae.statusText,config:S,request:Ce})})}catch(I){throw te&&te(),I&&I.name==="TypeError"&&/Load failed|fetch/i.test(I.message)?Object.assign(new qe("Network Error",qe.ERR_NETWORK,S,Ce),{cause:I.cause||I}):qe.from(I,I&&I.code,S,Ce)}}},zR=new Map,db=n=>{let e=n&&n.env||{};const{fetch:o,Request:t,Response:a}=e,s=[t,a,o];let l=s.length,r=l,c,_,d=zR;for(;r--;)c=s[r],_=d.get(c),_===void 0&&d.set(c,_=r?new Map:VR(e)),d=_;return _};db();const Jd={http:lR,xhr:FR,fetch:{get:db}};$.forEach(Jd,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const rm=n=>`- ${n}`,WR=n=>$.isFunction(n)||n===null||n===!1;function KR(n,e){n=$.isArray(n)?n:[n];const{length:o}=n;let t,a;const s={};for(let l=0;l<o;l++){t=n[l];let r;if(a=t,!WR(t)&&(a=Jd[(r=String(t)).toLowerCase()],a===void 0))throw new qe(`Unknown adapter '${r}'`);if(a&&($.isFunction(a)||(a=a.get(e))))break;s[r||"#"+l]=a}if(!a){const l=Object.entries(s).map(([c,_])=>`adapter ${c} `+(_===!1?"is not supported by the environment":"is not available in the build"));let r=o?l.length>1?`since :
|
|
32
32
|
`+l.map(rm).join(`
|
|
33
33
|
`):" "+rm(l[0]):"as no adapter specified";throw new qe("There is no suitable adapter to dispatch the request "+r,"ERR_NOT_SUPPORT")}return a}const _b={getAdapter:KR,adapters:Jd};function Ci(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Ua(null,n)}function im(n){return Ci(n),n.headers=Vt.from(n.headers),n.data=vi.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),_b.getAdapter(n.adapter||Pa.adapter,n)(n).then(function(t){return Ci(n),t.data=vi.call(n,n.transformResponse,t),t.headers=Vt.from(t.headers),t},function(t){return ib(t)||(Ci(n),t&&t.response&&(t.response.data=vi.call(n,n.transformResponse,t.response),t.response.headers=Vt.from(t.response.headers))),Promise.reject(t)})}const ub="1.13.4",jr={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{jr[n]=function(t){return typeof t===n||"a"+(e<1?"n ":" ")+n}});const sm={};jr.transitional=function(e,o,t){function a(s,l){return"[Axios v"+ub+"] Transitional option '"+s+"'"+l+(t?". "+t:"")}return(s,l,r)=>{if(e===!1)throw new qe(a(l," has been removed"+(o?" in "+o:"")),qe.ERR_DEPRECATED);return o&&!sm[l]&&(sm[l]=!0,console.warn(a(l," has been deprecated since v"+o+" and will be removed in the near future"))),e?e(s,l,r):!0}};jr.spelling=function(e){return(o,t)=>(console.warn(`${t} is likely a misspelling of ${e}`),!0)};function QR(n,e,o){if(typeof n!="object")throw new qe("options must be an object",qe.ERR_BAD_OPTION_VALUE);const t=Object.keys(n);let a=t.length;for(;a-- >0;){const s=t[a],l=e[s];if(l){const r=n[s],c=r===void 0||l(r,s,n);if(c!==!0)throw new qe("option "+s+" must be "+c,qe.ERR_BAD_OPTION_VALUE);continue}if(o!==!0)throw new qe("Unknown option "+s,qe.ERR_BAD_OPTION)}}const ur={assertOptions:QR,validators:jr},gn=ur.validators;let So=class{constructor(e){this.defaults=e||{},this.interceptors={request:new $u,response:new $u}}async request(e,o){try{return await this._request(e,o)}catch(t){if(t instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const s=a.stack?a.stack.replace(/^.+\n/,""):"";try{t.stack?s&&!String(t.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(t.stack+=`
|
|
34
|
-
`+s):t.stack=s}catch{}}throw t}}_request(e,o){typeof e=="string"?(o=o||{},o.url=e):o=e||{},o=ho(this.defaults,o);const{transitional:t,paramsSerializer:a,headers:s}=o;t!==void 0&&ur.assertOptions(t,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),a!=null&&($.isFunction(a)?o.paramsSerializer={serialize:a}:ur.assertOptions(a,{encode:gn.function,serialize:gn.function},!0)),o.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?o.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:o.allowAbsoluteUrls=!0),ur.assertOptions(o,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),o.method=(o.method||this.defaults.method||"get").toLowerCase();let l=s&&$.merge(s.common,s[o.method]);s&&$.forEach(["delete","get","head","post","put","patch","common"],S=>{delete s[S]}),o.headers=Vt.concat(l,s);const r=[];let c=!0;this.interceptors.request.forEach(function(T){typeof T.runWhen=="function"&&T.runWhen(o)===!1||(c=c&&T.synchronous,r.unshift(T.fulfilled,T.rejected))});const _=[];this.interceptors.response.forEach(function(T){_.push(T.fulfilled,T.rejected)});let d,m=0,p;if(!c){const S=[im.bind(this),void 0];for(S.unshift(...r),S.push(..._),p=S.length,d=Promise.resolve(o);m<p;)d=d.then(S[m++],S[m++]);return d}p=r.length;let E=o;for(;m<p;){const S=r[m++],T=r[m++];try{E=S(E)}catch(g){T.call(this,g);break}}try{d=im.call(this,E)}catch(S){return Promise.reject(S)}for(m=0,p=_.length;m<p;)d=d.then(_[m++],_[m++]);return d}getUri(e){e=ho(this.defaults,e);const o=lb(e.baseURL,e.url,e.allowAbsoluteUrls);return ob(o,e.params,e.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(e){So.prototype[e]=function(o,t){return this.request(ho(t||{},{method:e,url:o,data:(t||{}).data}))}});$.forEach(["post","put","patch"],function(e){function o(t){return function(s,l,r){return this.request(ho(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:s,data:l}))}}So.prototype[e]=o(),So.prototype[e+"Form"]=o(!0)});let $R=class mb{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let o;this.promise=new Promise(function(s){o=s});const t=this;this.promise.then(a=>{if(!t._listeners)return;let s=t._listeners.length;for(;s-- >0;)t._listeners[s](a);t._listeners=null}),this.promise.then=a=>{let s;const l=new Promise(r=>{t.subscribe(r),s=r}).then(a);return l.cancel=function(){t.unsubscribe(s)},l},e(function(s,l,r){t.reason||(t.reason=new Ua(s,l,r),o(t.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const o=this._listeners.indexOf(e);o!==-1&&this._listeners.splice(o,1)}toAbortSignal(){const e=new AbortController,o=t=>{e.abort(t)};return this.subscribe(o),e.signal.unsubscribe=()=>this.unsubscribe(o),e.signal}static source(){let e;return{token:new mb(function(a){e=a}),cancel:e}}};function XR(n){return function(o){return n.apply(null,o)}}function ZR(n){return $.isObject(n)&&n.isAxiosError===!0}const Rd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Rd).forEach(([n,e])=>{Rd[e]=n});function pb(n){const e=new So(n),o=WS(So.prototype.request,e);return $.extend(o,So.prototype,e,{allOwnKeys:!0}),$.extend(o,e,null,{allOwnKeys:!0}),o.create=function(a){return pb(ho(n,a))},o}const ht=pb(Pa);ht.Axios=So;ht.CanceledError=Ua;ht.CancelToken=$R;ht.isCancel=ib;ht.VERSION=ub;ht.toFormData=Jr;ht.AxiosError=qe;ht.Cancel=ht.CanceledError;ht.all=function(e){return Promise.all(e)};ht.spread=XR;ht.isAxiosError=ZR;ht.mergeConfig=ho;ht.AxiosHeaders=Vt;ht.formToJSON=n=>rb($.isHTMLForm(n)?new FormData(n):n);ht.getAdapter=_b.getAdapter;ht.HttpStatusCode=Rd;ht.default=ht;const{Axios:XQ,AxiosError:ZQ,CanceledError:JQ,isCancel:jQ,CancelToken:e4,VERSION:t4,all:n4,Cancel:o4,isAxiosError:a4,spread:r4,toFormData:i4,AxiosHeaders:s4,HttpStatusCode:l4,formToJSON:c4,getAdapter:d4,mergeConfig:_4}=ht,JR="/server-api",Me=ht.create({baseURL:JR,headers:{"Content-Type":"application/json"}}),tn={createSession:n=>Me.post("/agents/sessions",n),getSessions:()=>Me.get("/agents/sessions"),getSession:n=>Me.get(`/agents/sessions/${n}`),updateSessionAgentId:(n,e)=>Me.patch(`/agents/sessions/${n}`,{agentId:e}),deleteSession:n=>Me.delete(`/agents/sessions/${n}`),getHistory:n=>Me.get(`/agents/sessions/${n}/history`),clearSessionMessages:n=>Me.delete(`/agents/sessions/${n}/messages`),appendMessage:(n,e,o,t={})=>Me.post(`/agents/sessions/${n}/messages`,{role:e,content:o,...t})},rn={listAgents:()=>Me.get("/agent-config"),getAgent:n=>Me.get(`/agent-config/${n}`),createAgent:n=>Me.post("/agent-config",n),updateAgent:(n,e)=>Me.put(`/agent-config/${n}`,e),deleteAgent:(n,e)=>Me.delete(`/agent-config/${n}`,{params:e||{}})},$t={getSkills:(n,e)=>Me.get("/skills",{params:e?{scope:e}:n?{workspace:n}:{}}),getSkill:n=>Me.get(`/skills/${n}`),getSkillContent:(n,e)=>Me.get(`/skills/${n}/content`,e?{params:{workspace:e}}:{}),addSkill:n=>Me.post("/skills",n),deleteSkill:(n,e,o)=>Me.delete(`/skills/${encodeURIComponent(e)}`,{params:o?{scope:o}:{workspace:n}}),installSkill:(n,e)=>Me.post("/skills/install",{url:n,scope:e==null?void 0:e.scope,workspace:e==null?void 0:e.workspace}),installSkillFromPath:(n,e)=>Me.post("/skills/install-from-path",{path:n,scope:e==null?void 0:e.scope,workspace:e==null?void 0:e.workspace}),installSkillFromUpload:(n,e)=>{const o=new FormData;return o.append("file",n),o.append("scope",(e==null?void 0:e.scope)??"global"),o.append("workspace",(e==null?void 0:e.workspace)??"default"),Me.post("/skills/install-from-upload",o,{headers:{"Content-Type":void 0}})}},Zn={getConfig:()=>Me.get("/config"),updateConfig:n=>Me.put("/config",n),getProviders:()=>Me.get("/config/providers"),getProviderSupport:()=>Me.get("/config/provider-support"),getModels:(n,e)=>Me.get(`/config/providers/${encodeURIComponent(n)}/models`,{params:e?{type:e}:{}}),getOpencodeFreeModels:()=>Me.get("/config/opencode-free-models")},jR={login:(n,e)=>Me.post("/auth/login",{username:n,password:e})},ko={list:()=>Me.get("/users"),create:(n,e)=>Me.post("/users",{username:n,password:e}),update:(n,e)=>Me.put(`/users/${n}`,e),delete:n=>Me.delete(`/users/${n}`)},qn={list:()=>Me.get("/tasks"),get:n=>Me.get(`/tasks/${n}`),create:n=>Me.post("/tasks",n),update:(n,e)=>Me.put(`/tasks/${n}`,e),delete:n=>Me.delete(`/tasks/${n}`),listExecutions:n=>Me.get(`/tasks/${n}/executions`),getExecution:n=>Me.get(`/tasks/executions/${n}`),clearExecutions:n=>Me.delete(`/tasks/${n}/executions`)},lm={getTotal:()=>Me.get("/usage/total"),record:n=>Me.post("/usage",n)},sa={list:()=>Me.get("/tags"),get:n=>Me.get(`/tags/${n}`),create:n=>Me.post("/tags",n),update:(n,e)=>Me.put(`/tags/${n}`,e),delete:n=>Me.delete(`/tags/${n}`)},yi={list:n=>Me.get("/saved-items",{params:n||{}}),get:n=>Me.get(`/saved-items/${n}`),create:n=>Me.post("/saved-items",n),delete:n=>Me.delete(`/saved-items/${n}`),downloadToWorkspace:(n,e={})=>Me.post(`/saved-items/${n}/download-to-workspace`,e)},Jn={listWorkspaces:()=>Me.get("/workspace"),getCurrentWorkspace:()=>Me.get("/workspace/current"),listDocuments:(n,e="")=>Me.get("/workspace/documents",{params:{workspace:n,path:e}}),fileServeUrl:(n,e,o=!1)=>{const t=Me.defaults.baseURL||"/server-api",a=new URLSearchParams({workspace:n,path:e});return o&&a.set("download","1"),`${t}/workspace/files/serve?${a.toString()}`},deleteDocument:(n,e)=>Me.delete("/workspace/files",{params:{workspace:n,path:e}})};function eN(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const n=new Uint8Array(16);crypto.getRandomValues(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;const e=[...n].map(o=>o.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}class tN{constructor(){this.socket=null,this.listeners=new Map,this.currentSessionId=null,this.currentAgentId=null,this.currentSessionType=null,this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.pendingRequests=new Map}call(e,o,t=1e4){return new Promise((a,s)=>{var c;if(((c=this.socket)==null?void 0:c.readyState)!==WebSocket.OPEN){s(new Error("WebSocket not connected"));return}const l=eN(),r={type:"request",id:l,method:e,params:o};this.pendingRequests.set(l,{resolve:a,reject:s});try{this.socket.send(JSON.stringify(r));const _=setTimeout(()=>{this.pendingRequests.has(l)&&(this.pendingRequests.delete(l),s(new Error("Request timeout")))},t);this.pendingRequests.get(l).timer=_}catch(_){this.pendingRequests.delete(l),s(_)}})}handleMessage(e){if(e.type==="response"&&e.id){const o=this.pendingRequests.get(e.id);o&&(this.pendingRequests.delete(e.id),o.timer&&clearTimeout(o.timer),e.error?o.reject(new Error(e.error.message||"Request failed")):o.resolve(e.result));return}if(e.type==="event"){const{event:o,payload:t}=e,s={"agent.chunk":"agent_chunk","agent.tool":"agent_tool",message_complete:"message_complete",conversation_end:"conversation_end",turn_end:"turn_end",agent_end:"agent_end"}[o]||o;this.emit(s,t)}}async connectToSession(e,o,t){var a;if(this.currentSessionId=e,this.currentAgentId=o!==void 0?o:this.currentAgentId??"default",this.currentSessionType=t!==void 0?t:this.currentSessionType??"chat",await this.whenReady(),((a=this.socket)==null?void 0:a.readyState)!==WebSocket.OPEN)throw new Error("WebSocket not connected");await this.call("connect",{sessionId:e,agentId:this.currentAgentId,sessionType:this.currentSessionType}),await this.call("subscribe_session",{sessionId:e})}async sendMessage(e,o,t,a,s){const l={sessionId:e,message:o,agentId:a??this.currentAgentId,sessionType:s??this.currentSessionType};return t!=null&&(l.targetAgentId=t),this.call("agent.chat",l,12e4)}async cancelAgent(e,o){const t={sessionId:e};return o&&(t.agentId=o),this.call("agent.cancel",t,1e4)}async unsubscribeFromSession(){var e;((e=this.socket)==null?void 0:e.readyState)===WebSocket.OPEN&&await this.call("unsubscribe_session"),this.currentSessionId=null,this.currentAgentId=null,this.currentSessionType=null}whenReady(){var e;return((e=this.socket)==null?void 0:e.readyState)===WebSocket.OPEN?Promise.resolve():new Promise(o=>{const t=()=>{var a,s,l;if(((a=this.socket)==null?void 0:a.readyState)===WebSocket.OPEN){o();return}if(((s=this.socket)==null?void 0:s.readyState)===WebSocket.CLOSED||((l=this.socket)==null?void 0:l.readyState)===WebSocket.CLOSING){o();return}setTimeout(t,50)};t()})}connect(){var s;if(((s=this.socket)==null?void 0:s.readyState)===WebSocket.OPEN)return;const e=window.location.protocol==="https:"?"wss:":"ws:";let o=window.location.host;window.location.port==="5173"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1")&&(o=window.location.hostname+":38080");const a=`${e}//${o}`.replace(/\/$/,"")+"/ws";console.log("Connecting to Gateway WebSocket:",a);try{this.socket=new WebSocket(a),this.socket.onopen=()=>{console.log("✅ Connected to Gateway"),this.reconnectAttempts=0,this.currentSessionId&&this.connectToSession(this.currentSessionId).catch(l=>console.warn("Re-subscribe after reconnect failed",l))},this.socket.onclose=()=>{console.log("❌ Disconnected from Gateway"),this.scheduleReconnect()},this.socket.onerror=l=>{console.error("WebSocket error:",l)},this.socket.onmessage=l=>{try{const r=JSON.parse(l.data);this.handleMessage(r)}catch(r){console.error("Failed to parse WebSocket message:",r)}}}catch(l){console.error("Failed to create WebSocket:",l),this.scheduleReconnect()}}scheduleReconnect(){this.reconnectAttempts<this.maxReconnectAttempts&&(this.reconnectAttempts++,setTimeout(()=>this.connect(),1e3*this.reconnectAttempts))}disconnect(){this.socket&&(this.socket.close(),this.socket=null,this.currentSessionId=null,this.currentAgentId=null,this.currentSessionType=null),this.pendingRequests.forEach(e=>{e.timer&&clearTimeout(e.timer),e.reject(new Error("Disconnected"))}),this.pendingRequests.clear()}on(e,o){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(o),()=>{const t=this.listeners.get(e);t&&t.delete(o)}}emit(e,o){const t=this.listeners.get(e);t&&t.forEach(a=>a(o))}}const Bt=new tN,Un=Ko("agent",{state:()=>({sessions:[],currentSession:null,messages:[],currentMessage:"",currentStreamParts:[],isStreaming:!1,toolExecutions:[],totalTokens:0,skipRedirectToRecentOnce:!1,agentListRefreshTrigger:0}),getters:{activeSessions:n=>n.sessions.filter(e=>e.status!=="error"),sessionById:n=>e=>n.sessions.find(o=>o.id===e),isDesktopSession:()=>n=>(n==null?void 0:n.id)!=null&&!String(n.id).startsWith("channel:"),desktopSessions:n=>n.sessions.filter(e=>(e==null?void 0:e.id)!=null&&!String(e.id).startsWith("channel:"))},actions:{async fetchSessions(){var n;try{const e=await tn.getSessions(),o=((n=e==null?void 0:e.data)==null?void 0:n.data)??(e==null?void 0:e.data);this.sessions=Array.isArray(o)?o:[]}catch(e){console.error("Failed to fetch sessions:",e),this.sessions=[]}},async createSession(n={}){try{const e={agentId:"default",workspace:"default",...n},t=(await tn.createSession(e)).data.data;return this.sessions.find(a=>a.id===t.id)||this.sessions.push(t),t}catch(e){throw console.error("Failed to create session:",e),e}},async updateSessionAgentId(n,e){var a;await tn.updateSessionAgentId(n,e);const o=e??"default";((a=this.currentSession)==null?void 0:a.id)===n&&(this.currentSession={...this.currentSession,agentId:o},await Bt.connectToSession(n,o,this.currentSession.type));const t=this.sessions.findIndex(s=>s.id===n);t>=0&&(this.sessions=this.sessions.map((s,l)=>l===t?{...s,agentId:o}:s))},async deleteSession(n){var e,o;try{await tn.deleteSession(n)}catch(t){if(((e=t==null?void 0:t.response)==null?void 0:e.status)!==404)throw console.error("Failed to delete session:",t),t}this.sessions=this.sessions.filter(t=>t.id!==n),((o=this.currentSession)==null?void 0:o.id)===n&&(this.currentSession=null,this.messages=[])},async selectSession(n){var o,t;const e=this.sessions.find(a=>a.id===n);try{const a=await tn.getSession(n),s=((o=a==null?void 0:a.data)==null?void 0:o.data)??(a==null?void 0:a.data);if(s)this.currentSession=s;else if(e)this.currentSession=e;else throw new Error("Session not found");const l=await tn.getHistory(n),r=((t=l==null?void 0:l.data)==null?void 0:t.data)??(l==null?void 0:l.data);this.messages=Array.isArray(r)?r:[],await Bt.connectToSession(n,s.agentId,s.type)}catch(a){if(console.error("Failed to select session:",a),e)this.currentSession=e,this.messages=[],await Bt.connectToSession(n,e.agentId,e.type);else throw a}},clearCurrentSession(){this.currentSession=null,this.messages=[]},async clearCurrentSessionMessages(){var e;const n=(e=this.currentSession)==null?void 0:e.id;if(n)try{await tn.clearSessionMessages(n),this.messages=[],this.currentMessage="",this.currentStreamParts=[],this.toolExecutions=[],this.isStreaming=!1}catch(o){throw console.error("Failed to clear session messages:",o),o}},async cancelCurrentTurn(){var n;if(!(!((n=this.currentSession)!=null&&n.id)||!this.isStreaming))try{await Bt.cancelAgent(this.currentSession.id,this.currentSession.agentId)}catch(e){console.error("Failed to cancel agent turn:",e)}finally{this.isStreaming=!1}},async sendMessage(n,e={}){var o,t;if(n.trim()){if(((o=this.currentSession)==null?void 0:o.id)!=null&&String(this.currentSession.id).startsWith("channel:")&&(this.currentSession=null),!this.currentSession)try{const a=n.trim().substring(0,50),s=(e==null?void 0:e.agentId)??"default",l=await this.createSession({agentId:s,title:a});this.currentSession=l,await Bt.connectToSession(l.id,l.agentId,l.type)}catch(a){console.error("Failed to create lazy session:",a);return}try{const a=(e==null?void 0:e.agentId)??((t=this.currentSession)==null?void 0:t.agentId)??"default";this.currentSession&&a!==this.currentSession.agentId&&await this.updateSessionAgentId(this.currentSession.id,a),this.currentSession&&Bt.currentSessionId!==this.currentSession.id&&await Bt.connectToSession(this.currentSession.id,this.currentSession.agentId,this.currentSession.type);const s={id:Date.now().toString(),role:"user",content:n,timestamp:Date.now()};this.messages.push(s),this.currentMessage="",this.currentStreamParts=[],this.isStreaming=!0,this.toolExecutions=[],tn.appendMessage(this.currentSession.id,"user",n).catch(()=>{});const l=(e==null?void 0:e.targetAgentId)??a;await Bt.sendMessage(this.currentSession.id,n,l,a,this.currentSession.type)}catch(a){console.error("Failed to send message:",a),this.isStreaming=!1}return this.currentSession}},handleAgentChunk(n){var a;if(!this.currentSession||(n==null?void 0:n.sessionId)!=null&&n.sessionId!==((a=this.currentSession)==null?void 0:a.id))return;this.isStreaming||(this.isStreaming=!0,this.currentMessage="",this.currentStreamParts=[],this.toolExecutions=[]);const e=n.text||"";if(!e)return;this.currentMessage+=e;const o=this.currentStreamParts,t=o[o.length-1];t&&t.type==="text"?this.currentStreamParts=[...o.slice(0,-1),{type:"text",content:(t.content||"")+e}]:this.currentStreamParts=[...o,{type:"text",content:e}]},handleToolExecution(n){if(n.type==="start"){if(this.isStreaming||(this.isStreaming=!0,this.currentMessage="",this.currentStreamParts=[],this.toolExecutions=[]),this.toolExecutions.some(o=>o.id===n.toolCallId))return;const e={id:n.toolCallId,name:n.toolName,args:n.args,status:"running",startTime:Date.now()};this.toolExecutions=[...this.toolExecutions,e],this.currentStreamParts=[...this.currentStreamParts,{type:"tool",toolId:n.toolCallId}]}else if(n.type==="end"){const e=this.toolExecutions.find(o=>o.id===n.toolCallId);e&&(e.status=n.isError?"error":"completed",e.result=n.result,e.endTime=Date.now(),this.toolExecutions=[...this.toolExecutions])}},async fetchUsageTotal(){var n,e;try{const o=await lm.getTotal();(n=o==null?void 0:o.data)!=null&&n.success&&((e=o==null?void 0:o.data)!=null&&e.data)&&(this.totalTokens=o.data.data.totalTokens??0)}catch(o){console.warn("Failed to fetch token usage:",o)}},handleMessageComplete(n){n!=null&&n.usage&&(n.usage.promptTokens>0||n.usage.completionTokens>0)&&n.sessionId&&lm.record({sessionId:n.sessionId,source:"chat",promptTokens:n.usage.promptTokens??0,completionTokens:n.usage.completionTokens??0}).then(()=>this.fetchUsageTotal()).catch(e=>console.warn("Record usage failed:",e))},handleConversationEnd(n){var t,a;if((n==null?void 0:n.sessionId)!==((t=this.currentSession)==null?void 0:t.id))return;const e=this.currentMessage||n.content||"";if(e||this.toolExecutions.length>0){const s={id:Date.now().toString(),role:"assistant",content:e,timestamp:Date.now(),toolCalls:[...this.toolExecutions],contentParts:[...this.currentStreamParts]};this.messages.push(s),tn.appendMessage(this.currentSession.id,"assistant",e,{toolCalls:s.toolCalls,contentParts:s.contentParts}).catch(()=>{})}this.currentMessage="",this.currentStreamParts=[],this.isStreaming=!1,this.toolExecutions=[];const o=(a=this.currentSession)==null?void 0:a.id;o&&tn.getSession(o).then(s=>{var r,c;const l=((r=s==null?void 0:s.data)==null?void 0:r.data)??(s==null?void 0:s.data);if(l&&((c=this.currentSession)==null?void 0:c.id)===o){this.currentSession=l;const _=this.sessions.findIndex(d=>d.id===o);_>=0&&(this.sessions=this.sessions.map((d,m)=>m===_?{...d,...l}:d)),Bt.currentSessionId===o&&l.agentId!==void 0&&Bt.connectToSession(o,l.agentId,l.type??"chat").catch(()=>{})}}).catch(()=>{}),this.agentListRefreshTrigger+=1}}}),Fa=Ko("settings",{state:()=>({config:{gatewayUrl:"ws://localhost:38080",defaultProvider:"deepseek",defaultModel:"deepseek-chat",defaultAgentId:"default",theme:"dark",maxAgentSessions:5,loginUsername:"",loginPasswordSet:!1,providers:{}},providers:[],providerSupport:{},models:{}}),actions:{async loadConfig(){var n,e,o;try{const t=await Zn.getConfig(),a=(n=t==null?void 0:t.data)==null?void 0:n.data;a&&typeof a=="object"&&(this.config={...this.config,...a}),this.applyTheme((e=this.config)==null?void 0:e.theme)}catch(t){console.error("Failed to load config:",t),this.applyTheme((o=this.config)==null?void 0:o.theme)}},async updateConfig(n){var e;try{const o=await Zn.updateConfig(n),t=(e=o==null?void 0:o.data)==null?void 0:e.data;this.config=t&&typeof t=="object"?{...this.config,...t}:this.config,n!=null&&n.theme&&this.applyTheme(n.theme)}catch(o){console.error("Failed to update config:",o)}},async loadProviderSupport(){var n;try{const e=await Zn.getProviderSupport();this.providerSupport=((n=e.data)==null?void 0:n.data)??{},this.providers=Object.keys(this.providerSupport)}catch(e){console.error("Failed to load provider support:",e),this.providerSupport={},this.providers=[]}},async loadProviders(){await this.loadProviderSupport()},async loadModels(n,e){var o;if(n)try{const a=((o=(await Zn.getModels(n,e)).data)==null?void 0:o.data)??[],s=e?`${n}:${e}`:n;this.models={...this.models,[s]:a}}catch(t){console.error("Failed to load models:",t)}},applyTheme(n){document.documentElement.setAttribute("data-theme",n||"dark")},async setTheme(n){if(["light","dark","cosmic","neon"].includes(n)){this.applyTheme(n);try{await this.updateConfig({theme:n})}catch(o){console.error("Failed to save theme",o)}}},toggleTheme(){const n=["cosmic","light","neon","dark"],e=this.config.theme||"dark",o=(n.indexOf(e)+1)%n.length;this.updateConfig({theme:n[o]})}}}),nN={name:"ThemeToggle",setup(){const n=Fa();return{themeIcon:le(()=>{const t=n.config.theme;return t==="light"?"☀️":t==="cosmic"?"🪐":t==="neon"?"✨":"🌙"}),toggleTheme:()=>{n.toggleTheme()}}}},oN={class:"theme-icon"};function aN(n,e,o,t,a,s){return f(),b("button",{onClick:e[0]||(e[0]=(...l)=>t.toggleTheme&&t.toggleTheme(...l)),class:"theme-toggle btn-ghost",title:"Toggle theme"},[i("span",oN,u(t.themeIcon),1)])}const rN=ot(nN,[["render",aN],["__scopeId","data-v-c877b613"]]),iN={name:"Header",components:{ThemeToggle:rN},setup(){const n=Wo(),e=Pn(),o=zS(),t=Un(),{t:a}=Ct(),s=le(()=>n.name==="AgentChat"),l=le(()=>o.sessionsPanelVisible),r=()=>o.toggleSessionsPanel(),c=le(()=>t.currentSession&&t.currentSession.type!=="system"),_=M(!1),d=async()=>{var p;if((p=t.currentSession)!=null&&p.id&&confirm(a("sessions.clearHistoryConfirm"))){_.value=!0;try{await t.clearCurrentSessionMessages()}catch(E){console.error("Clear conversation failed",E)}finally{_.value=!1}}};return{pageTitle:le(()=>{const p=n.name,S={Dashboard:()=>a("nav.dashboard"),AgentChat:()=>a("nav.agentChat"),Root:()=>a("nav.agentChat"),Sessions:()=>a("nav.sessions"),Agents:()=>a("nav.agents"),AgentDetail:()=>a("nav.agents"),Tasks:()=>a("nav.tasks"),Workspace:()=>a("nav.workspace"),WorkResults:()=>a("nav.workResults"),Settings:()=>a("nav.settings")}[p];return S?S():n.path.startsWith("/chat")?a("nav.agentChat"):n.path.startsWith("/agents")?a("nav.agents"):n.path==="/settings"||n.path.startsWith("/settings")?a("nav.settings"):a("app.name")}),isChatRoute:s,hasCurrentChatSession:c,clearMessagesLoading:_,onClearConversation:d,sessionsPanelVisible:l,toggleSessionsPanel:r,router:e,t:a}}},sN={class:"header draggable"},lN={class:"header-left"},cN=["title"],dN=["title","disabled"],_N={class:"page-title"},uN={class:"header-right"},mN={class:"header-actions"};function pN(n,e,o,t,a,s){const l=ct("router-link"),r=ct("ThemeToggle");return f(),b("header",sN,[i("div",lN,[t.isChatRoute?(f(),b("button",{key:0,type:"button",class:"header-btn-sessions",title:t.sessionsPanelVisible?t.t("chat.hideSessions"):t.t("chat.showSessions"),onClick:e[0]||(e[0]=(...c)=>t.toggleSessionsPanel&&t.toggleSessionsPanel(...c))},u(t.sessionsPanelVisible?"‹":"›"),9,cN)):K("",!0),t.isChatRoute&&t.hasCurrentChatSession?(f(),b("button",{key:1,type:"button",class:"header-btn clear-conversation-btn",title:t.t("sessions.clearConversation"),disabled:t.clearMessagesLoading,onClick:e[1]||(e[1]=(...c)=>t.onClearConversation&&t.onClearConversation(...c))},[...e[3]||(e[3]=[i("span",{class:"clear-conversation-icon","aria-hidden":"true"},[i("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round"},[i("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6h14Z"}),i("path",{d:"M10 11v6M14 11v6"})])],-1)])],8,dN)):K("",!0),K("",!0),i("h1",_N,u(t.pageTitle),1)]),i("div",uN,[i("div",mN,[Oe(l,{to:"/dashboard",class:"header-btn dashboard-btn",title:t.t("nav.dashboard"),"active-class":"active"},{default:Ge(()=>[...e[4]||(e[4]=[i("span",{class:"btn-icon"},"📊",-1)])]),_:1},8,["title"]),Oe(r)])])])}const gN=ot(iN,[["render",pN],["__scopeId","data-v-33e6bd62"]]),Nd="openbot_logged_in",mr="openbot_current_user";function cm(){try{return sessionStorage.getItem(Nd)==="1"}catch{return!1}}function dm(){try{const n=sessionStorage.getItem(mr);if(!n)return null;const e=JSON.parse(n);return e&&e.id&&e.username?e:null}catch{return null}}const jd=Ko("auth",{state:()=>({isLoggedIn:cm(),currentUser:dm()}),actions:{initFromStorage(){this.isLoggedIn=cm(),this.currentUser=dm()},async login(n,e){var a;const o=await jR.login(n||"",e||"");this.isLoggedIn=!0;const t=((a=o.data)==null?void 0:a.user)??null;this.currentUser=t;try{sessionStorage.setItem(Nd,"1"),t?sessionStorage.setItem(mr,JSON.stringify(t)):sessionStorage.removeItem(mr)}catch{}},logout(){this.isLoggedIn=!1,this.currentUser=null;try{sessionStorage.removeItem(Nd),sessionStorage.removeItem(mr)}catch{}}}}),EN={name:"Login",setup(){const{t:n}=Ct(),e=jd(),o=M("admin"),t=M("123456"),a=M(""),s=M(!1);async function l(){var r,c;a.value="",s.value=!0;try{await e.login(o.value,t.value)}catch(_){const d=((c=(r=_.response)==null?void 0:r.data)==null?void 0:c.message)??_.message??n("login.invalidCredentials");a.value=d}finally{s.value=!1}}return{t:n,username:o,password:t,error:a,loading:s,submit:l}}},fN={class:"login-view"},SN={class:"login-card"},bN={class:"login-header"},TN={class:"login-logo-wrap"},hN=["alt"],vN={class:"login-title"},CN={class:"login-subtitle"},yN={class:"form-group"},RN={for:"login-username"},NN=["placeholder"],ON={class:"form-group"},AN={for:"login-password"},IN=["placeholder"],DN={key:0,class:"form-error",role:"alert"},wN=["disabled"],kN={class:"login-footer"},MN={class:"login-default-credential"},xN={class:"label"},LN={class:"label"},PN={class:"login-hint"};function UN(n,e,o,t,a,s){return f(),b("div",fN,[e[5]||(e[5]=i("div",{class:"login-bg","aria-hidden":"true"},null,-1)),i("div",SN,[i("header",bN,[i("div",TN,[i("img",{src:Qd,alt:t.t("app.name"),class:"login-logo"},null,8,hN)]),i("h1",vN,u(t.t("login.title")),1),i("p",CN,u(t.t("login.subtitle")),1)]),i("form",{class:"login-form",onSubmit:e[2]||(e[2]=Pe((...l)=>t.submit&&t.submit(...l),["prevent"]))},[i("div",yN,[i("label",RN,u(t.t("login.username")),1),X(i("input",{id:"login-username","onUpdate:modelValue":e[0]||(e[0]=l=>t.username=l),type:"text",class:"form-input",placeholder:t.t("login.usernamePlaceholder"),autocomplete:"username"},null,8,NN),[[Ne,t.username]])]),i("div",ON,[i("label",AN,u(t.t("login.password")),1),X(i("input",{id:"login-password","onUpdate:modelValue":e[1]||(e[1]=l=>t.password=l),type:"password",class:"form-input",placeholder:t.t("login.passwordPlaceholder"),autocomplete:"current-password"},null,8,IN),[[Ne,t.password]])]),t.error?(f(),b("p",DN,u(t.error),1)):K("",!0),i("button",{type:"submit",class:"btn-login",disabled:t.loading},u(t.loading?t.t("common.loading"):t.t("login.submit")),9,wN)],32),i("footer",kN,[i("p",MN,[i("span",xN,u(t.t("login.defaultUser"))+":",1),e[3]||(e[3]=Ve(" admin ",-1)),i("span",LN,u(t.t("login.defaultPassword"))+":",1),e[4]||(e[4]=Ve(" 123456 ",-1))]),i("p",PN,u(t.t("login.defaultHint")),1)])])])}const FN=ot(EN,[["render",UN],["__scopeId","data-v-831995a4"]]);async function BN(n,e){await n.loadConfig(),await n.loadProviders(),await e.fetchSessions()}function GN(n){if(!n||typeof n!="object")return!0;const e=n.providers||{},o=Object.values(e).some(a=>a&&typeof a.apiKey=="string"&&String(a.apiKey).trim()!==""),t=n.defaultProvider&&n.defaultModel||n.defaultModelItemCode&&Array.isArray(n.configuredModels)&&n.configuredModels.length>0;return!o||!t}const YN={name:"App",components:{Sidebar:Ty,Header:gN,Login:FN},errorCaptured(n,e,o){return console.error("[App] errorCaptured",n,o),!0},setup(){const n=Wo(),e=Pn(),{t:o}=Ct(),t=Fa(),a=Un(),s=jd(),l=M(!1),r=M(!1),c=le(()=>n.name==="AgentChat"||n.path==="/");function _(){r.value||GN(t.config)&&(l.value=!0,r.value=!0)}function d(){l.value=!1,e.push({path:"/settings",query:{tab:"models"}})}function m(){l.value=!1,r.value=!0}async function p(){await BN(t,a),await sn(),_()}return zt(()=>{s.initFromStorage(),s.isLoggedIn&&p()}),Ze(()=>s.isLoggedIn,E=>{E&&p()}),{route:n,isChatRoute:c,authStore:s,showConfigPromptDialog:l,t:o,goToConfig:d,dismissConfigPrompt:m}}},HN={id:"app",class:"app-container"},qN={class:"main-content"},VN={key:1,class:"view-fallback"},zN={class:"config-prompt-card"},WN={class:"config-prompt-title"},KN={class:"config-prompt-desc"},QN={class:"config-prompt-actions"};function $N(n,e,o,t,a,s){const l=ct("Login"),r=ct("Sidebar"),c=ct("Header"),_=ct("router-view");return f(),b("div",HN,[t.authStore.isLoggedIn?(f(),b(me,{key:1},[Oe(r),i("div",qN,[Oe(c),i("div",{class:De(["content-area",{"chat-full-height":t.isChatRoute}])},[Oe(_,null,{default:Ge(({Component:d})=>[Oe(Qe,{name:"fade",mode:"out-in"},{default:Ge(()=>[d?(f(),Lt(jf(d),{key:t.route.fullPath})):(f(),b("div",VN,"加载中…"))]),_:2},1024)]),_:1})],2)]),t.showConfigPromptDialog?(f(),b("div",{key:0,class:"config-prompt-backdrop",onClick:e[2]||(e[2]=Pe((...d)=>t.dismissConfigPrompt&&t.dismissConfigPrompt(...d),["self"]))},[i("div",zN,[i("h3",WN,u(t.t("app.configPromptTitle")),1),i("p",KN,u(t.t("app.configPromptDesc")),1),i("div",QN,[i("button",{type:"button",class:"btn-primary",onClick:e[0]||(e[0]=(...d)=>t.goToConfig&&t.goToConfig(...d))},u(t.t("app.configPromptConfirm")),1),i("button",{type:"button",class:"btn-secondary",onClick:e[1]||(e[1]=(...d)=>t.dismissConfigPrompt&&t.dismissConfigPrompt(...d))},u(t.t("app.configPromptSkip")),1)])])])):K("",!0)],64)):(f(),Lt(l,{key:0}))])}const XN=ot(YN,[["render",$N],["__scopeId","data-v-1790072c"]]),gb=Ko("skill",{state:()=>({skills:[],selectedSkill:null,skillContent:null,loading:!1}),getters:{skillsByCategory:n=>{const e={};return n.skills.forEach(o=>{const t=o.category||"Uncategorized";e[t]||(e[t]=[]),e[t].push(o)}),e}},actions:{async fetchSkills(){this.loading=!0;try{const n=await $t.getSkills();this.skills=n.data.data}catch(n){console.error("Failed to fetch skills:",n)}finally{this.loading=!1}},async selectSkill(n){this.loading=!0;try{const[e,o]=await Promise.all([$t.getSkill(n),$t.getSkillContent(n)]);this.selectedSkill=e.data.data,this.skillContent=o.data.data.content}catch(e){console.error("Failed to load skill:",e)}finally{this.loading=!1}},clearSelection(){this.selectedSkill=null,this.skillContent=null}}}),ZN={name:"Dashboard",setup(){const n=Pn(),e=Un(),o=gb(),{t}=Ct(),a=le(()=>e.totalTokens),s=le(()=>e.sessions),l=le(()=>e.activeSessions.length),r=le(()=>o.skills.length),c=le(()=>s.value.slice(0,5)),_=E=>new Date(E).toLocaleString(),d=E=>E==null||E===0?"0":Number(E).toLocaleString(),m=()=>{const E=e.currentSession;E!=null&&E.id?n.push(`/chat/${E.id}`):n.push("/chat")},p=E=>{n.push(`/chat/${E}`)};return zt(()=>{o.fetchSkills(),e.fetchUsageTotal()}),{sessions:s,activeSessions:l,totalSkills:r,recentSessions:c,totalTokens:a,formatDate:_,formatTokens:d,goToChat:m,openSession:p,t}}},JN={class:"dashboard"},jN={class:"welcome-header"},eO={class:"welcome-content"},tO={class:"welcome-title"},nO={class:"welcome-text"},oO={class:"quick-stats-row"},aO={class:"stat-item"},rO={class:"stat-val"},iO={class:"stat-lbl"},sO={class:"stat-item"},lO={class:"stat-val"},cO={class:"stat-lbl"},dO={class:"stat-item"},_O={class:"stat-val"},uO={class:"stat-lbl"},mO={class:"dashboard-grid"},pO={class:"main-column"},gO={class:"section-card card-glass"},EO={class:"section-title"},fO={class:"actions-grid"},SO={class:"action-details"},bO={class:"action-name"},TO={class:"action-desc"},hO={class:"action-details"},vO={class:"action-name"},CO={class:"action-desc"},yO={class:"action-details"},RO={class:"action-name"},NO={class:"action-desc"},OO={class:"section-card card-glass"},AO={class:"section-header"},IO={class:"section-title"},DO={key:0,class:"empty-state"},wO={class:"text-muted"},kO={key:1,class:"sessions-list"},MO=["onClick"],xO={class:"session-info"},LO={class:"session-id"},PO={class:"session-date"},UO={class:"side-column"},FO={class:"section-card card-glass"},BO={class:"section-title"},GO={class:"token-chart"},YO={class:"token-stats"},HO={class:"token-stat"},qO={class:"token-label"},VO={class:"token-value"},zO={class:"token-stat"},WO={class:"token-label"},KO={class:"section-card card-glass"},QO={class:"section-title"};function $O(n,e,o,t,a,s){const l=ct("router-link");return f(),b("div",JN,[i("div",jN,[i("div",eO,[i("h2",tO,u(t.t("dashboard.welcome")),1),i("p",nO,u(t.t("dashboard.welcomeDesc")),1)]),i("div",oO,[i("div",aO,[i("span",rO,u(t.activeSessions),1),i("span",iO,u(t.t("dashboard.activeSessions")),1)]),e[1]||(e[1]=i("div",{class:"stat-divider"},null,-1)),i("div",sO,[i("span",lO,u(t.totalSkills),1),i("span",cO,u(t.t("dashboard.totalSkills")),1)]),e[2]||(e[2]=i("div",{class:"stat-divider"},null,-1)),i("div",dO,[i("span",_O,u(t.formatTokens(t.totalTokens)),1),i("span",uO,u(t.t("dashboard.tokensUsed")),1)])])]),i("div",mO,[i("div",pO,[i("div",gO,[i("h3",EO,u(t.t("dashboard.quickActions")),1),i("div",fO,[i("button",{onClick:e[0]||(e[0]=(...r)=>t.goToChat&&t.goToChat(...r)),class:"action-card btn-glass"},[e[3]||(e[3]=i("span",{class:"action-icon"},"💬",-1)),i("div",SO,[i("span",bO,u(t.t("dashboard.startChat")),1),i("span",TO,u(t.t("dashboard.startChatDesc")),1)])]),Oe(l,{to:"/skills",class:"action-card btn-glass"},{default:Ge(()=>[e[4]||(e[4]=i("span",{class:"action-icon"},"🎯",-1)),i("div",hO,[i("span",vO,u(t.t("nav.skills")),1),i("span",CO,u(t.t("dashboard.browseSkillsDesc")),1)])]),_:1}),Oe(l,{to:"/agents",class:"action-card btn-glass"},{default:Ge(()=>[e[5]||(e[5]=i("span",{class:"action-icon"},"⚙️",-1)),i("div",yO,[i("span",RO,u(t.t("settings.agentConfig")),1),i("span",NO,u(t.t("dashboard.configureAgentDesc")),1)])]),_:1})])]),i("div",OO,[i("div",AO,[i("h3",IO,u(t.t("dashboard.recentSessions")),1),Oe(l,{to:"/sessions",class:"more-link"},{default:Ge(()=>[Ve(u(t.t("common.viewAll"))+" →",1)]),_:1})]),t.recentSessions.length===0?(f(),b("div",DO,[i("p",wO,u(t.t("dashboard.noSessions")),1)])):(f(),b("div",kO,[(f(!0),b(me,null,Ue(t.recentSessions,r=>(f(),b("div",{key:r.id,class:"session-row",onClick:c=>t.openSession(r.id)},[e[6]||(e[6]=i("div",{class:"session-icon"},"💬",-1)),i("div",xO,[i("span",LO,u(r.title||r.id.substring(0,8)),1),i("span",PO,u(t.formatDate(r.createdAt)),1)]),i("span",{class:De(["badge",`badge-${r.status}`])},u(r.status),3)],8,MO))),128))]))])]),i("div",UO,[i("div",FO,[i("h3",BO,u(t.t("dashboard.tokenUsage")),1),i("div",GO,[e[8]||(e[8]=vr('<div class="chart-bars" data-v-04d1de47><div class="chart-bar" style="height:40%;" data-v-04d1de47></div><div class="chart-bar" style="height:65%;" data-v-04d1de47></div><div class="chart-bar" style="height:30%;" data-v-04d1de47></div><div class="chart-bar active" style="height:85%;" data-v-04d1de47></div><div class="chart-bar" style="height:50%;" data-v-04d1de47></div><div class="chart-bar" style="height:60%;" data-v-04d1de47></div><div class="chart-bar" style="height:45%;" data-v-04d1de47></div></div>',1)),i("div",YO,[i("div",HO,[i("span",qO,u(t.t("dashboard.totalTokens")),1),i("span",VO,u(t.formatTokens(t.totalTokens)),1)]),i("div",zO,[i("span",WO,u(t.t("dashboard.cost")),1),e[7]||(e[7]=i("span",{class:"token-value"},"—",-1))])])])]),i("div",KO,[i("h3",QO,u(t.t("dashboard.followedInfo")),1),e[9]||(e[9]=vr('<div class="info-list" data-v-04d1de47><div class="info-item" data-v-04d1de47><span class="info-tag badge-info" data-v-04d1de47>Update</span><span class="info-text" data-v-04d1de47>OpenBot v1.2 is now available with new skills.</span></div><div class="info-item" data-v-04d1de47><span class="info-tag badge-success" data-v-04d1de47>Tip</span><span class="info-text" data-v-04d1de47>Try using 'Research' skill for better results.</span></div><div class="info-item" data-v-04d1de47><span class="info-tag badge-warning" data-v-04d1de47>Alert</span><span class="info-text" data-v-04d1de47>High traffic on DeepSeek API today.</span></div></div>',1))])])])])}const XO=ot(ZN,[["render",$O],["__scopeId","data-v-04d1de47"]]);function e_(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let yo=e_();function Eb(n){yo=n}const fb=/[&<>"']/,ZO=new RegExp(fb.source,"g"),Sb=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,JO=new RegExp(Sb.source,"g"),jO={"&":"&","<":"<",">":">",'"':""","'":"'"},_m=n=>jO[n];function Qt(n,e){if(e){if(fb.test(n))return n.replace(ZO,_m)}else if(Sb.test(n))return n.replace(JO,_m);return n}const eA=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function tA(n){return n.replace(eA,(e,o)=>(o=o.toLowerCase(),o==="colon"?":":o.charAt(0)==="#"?o.charAt(1)==="x"?String.fromCharCode(parseInt(o.substring(2),16)):String.fromCharCode(+o.substring(1)):""))}const nA=/(^|[^\[])\^/g;function rt(n,e){let o=typeof n=="string"?n:n.source;e=e||"";const t={replace:(a,s)=>{let l=typeof s=="string"?s:s.source;return l=l.replace(nA,"$1"),o=o.replace(a,l),t},getRegex:()=>new RegExp(o,e)};return t}function um(n){try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const fa={exec:()=>null};function mm(n,e){const o=n.replace(/\|/g,(s,l,r)=>{let c=!1,_=l;for(;--_>=0&&r[_]==="\\";)c=!c;return c?"|":" |"}),t=o.split(/ \|/);let a=0;if(t[0].trim()||t.shift(),t.length>0&&!t[t.length-1].trim()&&t.pop(),e)if(t.length>e)t.splice(e);else for(;t.length<e;)t.push("");for(;a<t.length;a++)t[a]=t[a].trim().replace(/\\\|/g,"|");return t}function nr(n,e,o){const t=n.length;if(t===0)return"";let a=0;for(;a<t&&n.charAt(t-a-1)===e;)a++;return n.slice(0,t-a)}function oA(n,e){if(n.indexOf(e[1])===-1)return-1;let o=0;for(let t=0;t<n.length;t++)if(n[t]==="\\")t++;else if(n[t]===e[0])o++;else if(n[t]===e[1]&&(o--,o<0))return t;return-1}function pm(n,e,o,t){const a=e.href,s=e.title?Qt(e.title):null,l=n[1].replace(/\\([\[\]])/g,"$1");if(n[0].charAt(0)!=="!"){t.state.inLink=!0;const r={type:"link",raw:o,href:a,title:s,text:l,tokens:t.inlineTokens(l)};return t.state.inLink=!1,r}return{type:"image",raw:o,href:a,title:s,text:Qt(l)}}function aA(n,e){const o=n.match(/^(\s+)(?:```)/);if(o===null)return e;const t=o[1];return e.split(`
|
|
34
|
+
`+s):t.stack=s}catch{}}throw t}}_request(e,o){typeof e=="string"?(o=o||{},o.url=e):o=e||{},o=ho(this.defaults,o);const{transitional:t,paramsSerializer:a,headers:s}=o;t!==void 0&&ur.assertOptions(t,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),a!=null&&($.isFunction(a)?o.paramsSerializer={serialize:a}:ur.assertOptions(a,{encode:gn.function,serialize:gn.function},!0)),o.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?o.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:o.allowAbsoluteUrls=!0),ur.assertOptions(o,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),o.method=(o.method||this.defaults.method||"get").toLowerCase();let l=s&&$.merge(s.common,s[o.method]);s&&$.forEach(["delete","get","head","post","put","patch","common"],S=>{delete s[S]}),o.headers=Vt.concat(l,s);const r=[];let c=!0;this.interceptors.request.forEach(function(T){typeof T.runWhen=="function"&&T.runWhen(o)===!1||(c=c&&T.synchronous,r.unshift(T.fulfilled,T.rejected))});const _=[];this.interceptors.response.forEach(function(T){_.push(T.fulfilled,T.rejected)});let d,m=0,p;if(!c){const S=[im.bind(this),void 0];for(S.unshift(...r),S.push(..._),p=S.length,d=Promise.resolve(o);m<p;)d=d.then(S[m++],S[m++]);return d}p=r.length;let E=o;for(;m<p;){const S=r[m++],T=r[m++];try{E=S(E)}catch(g){T.call(this,g);break}}try{d=im.call(this,E)}catch(S){return Promise.reject(S)}for(m=0,p=_.length;m<p;)d=d.then(_[m++],_[m++]);return d}getUri(e){e=ho(this.defaults,e);const o=lb(e.baseURL,e.url,e.allowAbsoluteUrls);return ob(o,e.params,e.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(e){So.prototype[e]=function(o,t){return this.request(ho(t||{},{method:e,url:o,data:(t||{}).data}))}});$.forEach(["post","put","patch"],function(e){function o(t){return function(s,l,r){return this.request(ho(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:s,data:l}))}}So.prototype[e]=o(),So.prototype[e+"Form"]=o(!0)});let $R=class mb{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let o;this.promise=new Promise(function(s){o=s});const t=this;this.promise.then(a=>{if(!t._listeners)return;let s=t._listeners.length;for(;s-- >0;)t._listeners[s](a);t._listeners=null}),this.promise.then=a=>{let s;const l=new Promise(r=>{t.subscribe(r),s=r}).then(a);return l.cancel=function(){t.unsubscribe(s)},l},e(function(s,l,r){t.reason||(t.reason=new Ua(s,l,r),o(t.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const o=this._listeners.indexOf(e);o!==-1&&this._listeners.splice(o,1)}toAbortSignal(){const e=new AbortController,o=t=>{e.abort(t)};return this.subscribe(o),e.signal.unsubscribe=()=>this.unsubscribe(o),e.signal}static source(){let e;return{token:new mb(function(a){e=a}),cancel:e}}};function XR(n){return function(o){return n.apply(null,o)}}function ZR(n){return $.isObject(n)&&n.isAxiosError===!0}const Rd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Rd).forEach(([n,e])=>{Rd[e]=n});function pb(n){const e=new So(n),o=WS(So.prototype.request,e);return $.extend(o,So.prototype,e,{allOwnKeys:!0}),$.extend(o,e,null,{allOwnKeys:!0}),o.create=function(a){return pb(ho(n,a))},o}const ht=pb(Pa);ht.Axios=So;ht.CanceledError=Ua;ht.CancelToken=$R;ht.isCancel=ib;ht.VERSION=ub;ht.toFormData=Jr;ht.AxiosError=qe;ht.Cancel=ht.CanceledError;ht.all=function(e){return Promise.all(e)};ht.spread=XR;ht.isAxiosError=ZR;ht.mergeConfig=ho;ht.AxiosHeaders=Vt;ht.formToJSON=n=>rb($.isHTMLForm(n)?new FormData(n):n);ht.getAdapter=_b.getAdapter;ht.HttpStatusCode=Rd;ht.default=ht;const{Axios:XQ,AxiosError:ZQ,CanceledError:JQ,isCancel:jQ,CancelToken:e4,VERSION:t4,all:n4,Cancel:o4,isAxiosError:a4,spread:r4,toFormData:i4,AxiosHeaders:s4,HttpStatusCode:l4,formToJSON:c4,getAdapter:d4,mergeConfig:_4}=ht,JR="/server-api",Me=ht.create({baseURL:JR,headers:{"Content-Type":"application/json"}}),tn={createSession:n=>Me.post("/agents/sessions",n),getSessions:()=>Me.get("/agents/sessions"),getSession:n=>Me.get(`/agents/sessions/${n}`),updateSessionAgentId:(n,e)=>Me.patch(`/agents/sessions/${n}`,{agentId:e}),deleteSession:n=>Me.delete(`/agents/sessions/${n}`),getHistory:n=>Me.get(`/agents/sessions/${n}/history`),clearSessionMessages:n=>Me.delete(`/agents/sessions/${n}/messages`),appendMessage:(n,e,o,t={})=>Me.post(`/agents/sessions/${n}/messages`,{role:e,content:o,...t})},rn={listAgents:()=>Me.get("/agent-config"),getAgent:n=>Me.get(`/agent-config/${n}`),createAgent:n=>Me.post("/agent-config",n),updateAgent:(n,e)=>Me.put(`/agent-config/${n}`,e),deleteAgent:(n,e)=>Me.delete(`/agent-config/${n}`,{params:e||{}})},$t={getSkills:(n,e)=>Me.get("/skills",{params:e?{scope:e}:n?{workspace:n}:{}}),getSkill:n=>Me.get(`/skills/${n}`),getSkillContent:(n,e)=>Me.get(`/skills/${n}/content`,e?{params:{workspace:e}}:{}),addSkill:n=>Me.post("/skills",n),deleteSkill:(n,e,o)=>Me.delete(`/skills/${encodeURIComponent(e)}`,{params:o?{scope:o}:{workspace:n}}),installSkill:(n,e)=>Me.post("/skills/install",{url:n,scope:e==null?void 0:e.scope,workspace:e==null?void 0:e.workspace}),installSkillFromPath:(n,e)=>Me.post("/skills/install-from-path",{path:n,scope:e==null?void 0:e.scope,workspace:e==null?void 0:e.workspace}),installSkillFromUpload:(n,e)=>{const o=new FormData;return o.append("file",n),o.append("scope",(e==null?void 0:e.scope)??"global"),o.append("workspace",(e==null?void 0:e.workspace)??"default"),Me.post("/skills/install-from-upload",o,{headers:{"Content-Type":void 0}})}},Zn={getConfig:()=>Me.get("/config"),updateConfig:n=>Me.put("/config",n),getProviders:()=>Me.get("/config/providers"),getProviderSupport:()=>Me.get("/config/provider-support"),getModels:(n,e)=>Me.get(`/config/providers/${encodeURIComponent(n)}/models`,{params:e?{type:e}:{}}),getOpencodeFreeModels:()=>Me.get("/config/opencode-free-models")},jR={login:(n,e)=>Me.post("/auth/login",{username:n,password:e})},ko={list:()=>Me.get("/users"),create:(n,e)=>Me.post("/users",{username:n,password:e}),update:(n,e)=>Me.put(`/users/${n}`,e),delete:n=>Me.delete(`/users/${n}`)},qn={list:()=>Me.get("/tasks"),get:n=>Me.get(`/tasks/${n}`),create:n=>Me.post("/tasks",n),update:(n,e)=>Me.put(`/tasks/${n}`,e),delete:n=>Me.delete(`/tasks/${n}`),listExecutions:n=>Me.get(`/tasks/${n}/executions`),getExecution:n=>Me.get(`/tasks/executions/${n}`),clearExecutions:n=>Me.delete(`/tasks/${n}/executions`)},lm={getTotal:()=>Me.get("/usage/total"),record:n=>Me.post("/usage",n)},sa={list:()=>Me.get("/tags"),get:n=>Me.get(`/tags/${n}`),create:n=>Me.post("/tags",n),update:(n,e)=>Me.put(`/tags/${n}`,e),delete:n=>Me.delete(`/tags/${n}`)},yi={list:n=>Me.get("/saved-items",{params:n||{}}),get:n=>Me.get(`/saved-items/${n}`),create:n=>Me.post("/saved-items",n),delete:n=>Me.delete(`/saved-items/${n}`),downloadToWorkspace:(n,e={})=>Me.post(`/saved-items/${n}/download-to-workspace`,e)},Jn={listWorkspaces:()=>Me.get("/workspace"),getCurrentWorkspace:()=>Me.get("/workspace/current"),listDocuments:(n,e="")=>Me.get("/workspace/documents",{params:{workspace:n,path:e}}),fileServeUrl:(n,e,o=!1)=>{const t=Me.defaults.baseURL||"/server-api",a=new URLSearchParams({workspace:n,path:e});return o&&a.set("download","1"),`${t}/workspace/files/serve?${a.toString()}`},deleteDocument:(n,e)=>Me.delete("/workspace/files",{params:{workspace:n,path:e}})};function eN(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const n=new Uint8Array(16);crypto.getRandomValues(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;const e=[...n].map(o=>o.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}class tN{constructor(){this.socket=null,this.listeners=new Map,this.currentSessionId=null,this.currentAgentId=null,this.currentSessionType=null,this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.pendingRequests=new Map}call(e,o,t=1e4){return new Promise((a,s)=>{var c;if(((c=this.socket)==null?void 0:c.readyState)!==WebSocket.OPEN){s(new Error("WebSocket not connected"));return}const l=eN(),r={type:"request",id:l,method:e,params:o};this.pendingRequests.set(l,{resolve:a,reject:s});try{this.socket.send(JSON.stringify(r));const _=setTimeout(()=>{this.pendingRequests.has(l)&&(this.pendingRequests.delete(l),s(new Error("Request timeout")))},t);this.pendingRequests.get(l).timer=_}catch(_){this.pendingRequests.delete(l),s(_)}})}handleMessage(e){if(e.type==="response"&&e.id){const o=this.pendingRequests.get(e.id);o&&(this.pendingRequests.delete(e.id),o.timer&&clearTimeout(o.timer),e.error?o.reject(new Error(e.error.message||"Request failed")):o.resolve(e.result));return}if(e.type==="event"){const{event:o,payload:t}=e,s={"agent.chunk":"agent_chunk","agent.tool":"agent_tool",message_complete:"message_complete",conversation_end:"conversation_end",turn_end:"turn_end",agent_end:"agent_end"}[o]||o;this.emit(s,t)}}async connectToSession(e,o,t){var a;if(this.currentSessionId=e,this.currentAgentId=o!==void 0?o:this.currentAgentId??"default",this.currentSessionType=t!==void 0?t:this.currentSessionType??"chat",await this.whenReady(),((a=this.socket)==null?void 0:a.readyState)!==WebSocket.OPEN)throw new Error("WebSocket not connected");await this.call("connect",{sessionId:e,agentId:this.currentAgentId,sessionType:this.currentSessionType}),await this.call("subscribe_session",{sessionId:e})}async sendMessage(e,o,t,a,s){const l={sessionId:e,message:o,agentId:a??this.currentAgentId,sessionType:s??this.currentSessionType};return t!=null&&(l.targetAgentId=t),this.call("agent.chat",l,12e4)}async cancelAgent(e,o){const t={sessionId:e};return o&&(t.agentId=o),this.call("agent.cancel",t,1e4)}async unsubscribeFromSession(){var e;((e=this.socket)==null?void 0:e.readyState)===WebSocket.OPEN&&await this.call("unsubscribe_session"),this.currentSessionId=null,this.currentAgentId=null,this.currentSessionType=null}whenReady(){var e;return((e=this.socket)==null?void 0:e.readyState)===WebSocket.OPEN?Promise.resolve():new Promise(o=>{const t=()=>{var a,s,l;if(((a=this.socket)==null?void 0:a.readyState)===WebSocket.OPEN){o();return}if(((s=this.socket)==null?void 0:s.readyState)===WebSocket.CLOSED||((l=this.socket)==null?void 0:l.readyState)===WebSocket.CLOSING){o();return}setTimeout(t,50)};t()})}connect(){var s;if(((s=this.socket)==null?void 0:s.readyState)===WebSocket.OPEN)return;const e=window.location.protocol==="https:"?"wss:":"ws:";let o=window.location.host;window.location.port==="5173"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1")&&(o=window.location.hostname+":38080");const a=`${e}//${o}`.replace(/\/$/,"")+"/ws";console.log("Connecting to Gateway WebSocket:",a);try{this.socket=new WebSocket(a),this.socket.onopen=()=>{console.log("✅ Connected to Gateway"),this.reconnectAttempts=0,this.currentSessionId&&this.connectToSession(this.currentSessionId).catch(l=>console.warn("Re-subscribe after reconnect failed",l))},this.socket.onclose=()=>{console.log("❌ Disconnected from Gateway"),this.scheduleReconnect()},this.socket.onerror=l=>{console.error("WebSocket error:",l)},this.socket.onmessage=l=>{try{const r=JSON.parse(l.data);this.handleMessage(r)}catch(r){console.error("Failed to parse WebSocket message:",r)}}}catch(l){console.error("Failed to create WebSocket:",l),this.scheduleReconnect()}}scheduleReconnect(){this.reconnectAttempts<this.maxReconnectAttempts&&(this.reconnectAttempts++,setTimeout(()=>this.connect(),1e3*this.reconnectAttempts))}disconnect(){this.socket&&(this.socket.close(),this.socket=null,this.currentSessionId=null,this.currentAgentId=null,this.currentSessionType=null),this.pendingRequests.forEach(e=>{e.timer&&clearTimeout(e.timer),e.reject(new Error("Disconnected"))}),this.pendingRequests.clear()}on(e,o){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(o),()=>{const t=this.listeners.get(e);t&&t.delete(o)}}emit(e,o){const t=this.listeners.get(e);t&&t.forEach(a=>a(o))}}const Bt=new tN,Un=Ko("agent",{state:()=>({sessions:[],currentSession:null,messages:[],currentMessage:"",currentStreamParts:[],isStreaming:!1,toolExecutions:[],totalTokens:0,skipRedirectToRecentOnce:!1,agentListRefreshTrigger:0}),getters:{activeSessions:n=>n.sessions.filter(e=>e.status!=="error"),sessionById:n=>e=>n.sessions.find(o=>o.id===e),isDesktopSession:()=>n=>(n==null?void 0:n.id)!=null&&!String(n.id).startsWith("channel:"),desktopSessions:n=>n.sessions.filter(e=>(e==null?void 0:e.id)!=null&&!String(e.id).startsWith("channel:"))},actions:{async fetchSessions(){var n;try{const e=await tn.getSessions(),o=((n=e==null?void 0:e.data)==null?void 0:n.data)??(e==null?void 0:e.data);this.sessions=Array.isArray(o)?o:[]}catch(e){console.error("Failed to fetch sessions:",e),this.sessions=[]}},async createSession(n={}){try{const e={agentId:"default",workspace:"default",...n},t=(await tn.createSession(e)).data.data;return this.sessions.find(a=>a.id===t.id)||this.sessions.push(t),t}catch(e){throw console.error("Failed to create session:",e),e}},async updateSessionAgentId(n,e){var a;await tn.updateSessionAgentId(n,e);const o=e??"default";((a=this.currentSession)==null?void 0:a.id)===n&&(this.currentSession={...this.currentSession,agentId:o},await Bt.connectToSession(n,o,this.currentSession.type));const t=this.sessions.findIndex(s=>s.id===n);t>=0&&(this.sessions=this.sessions.map((s,l)=>l===t?{...s,agentId:o}:s))},async deleteSession(n){var e,o;try{await tn.deleteSession(n)}catch(t){if(((e=t==null?void 0:t.response)==null?void 0:e.status)!==404)throw console.error("Failed to delete session:",t),t}this.sessions=this.sessions.filter(t=>t.id!==n),((o=this.currentSession)==null?void 0:o.id)===n&&(this.currentSession=null,this.messages=[])},async selectSession(n){var o,t;const e=this.sessions.find(a=>a.id===n);try{const a=await tn.getSession(n),s=((o=a==null?void 0:a.data)==null?void 0:o.data)??(a==null?void 0:a.data);if(s)this.currentSession=s;else if(e)this.currentSession=e;else throw new Error("Session not found");const l=await tn.getHistory(n),r=((t=l==null?void 0:l.data)==null?void 0:t.data)??(l==null?void 0:l.data);this.messages=Array.isArray(r)?r:[],await Bt.connectToSession(n,s.agentId,s.type)}catch(a){if(console.error("Failed to select session:",a),e)this.currentSession=e,this.messages=[],await Bt.connectToSession(n,e.agentId,e.type);else throw a}},clearCurrentSession(){this.currentSession=null,this.messages=[]},async clearCurrentSessionMessages(){var e;const n=(e=this.currentSession)==null?void 0:e.id;if(n)try{await tn.clearSessionMessages(n),this.messages=[],this.currentMessage="",this.currentStreamParts=[],this.toolExecutions=[],this.isStreaming=!1}catch(o){throw console.error("Failed to clear session messages:",o),o}},async cancelCurrentTurn(){var n;if(!(!((n=this.currentSession)!=null&&n.id)||!this.isStreaming))try{await Bt.cancelAgent(this.currentSession.id,this.currentSession.agentId)}catch(e){console.error("Failed to cancel agent turn:",e)}finally{this.isStreaming=!1}},async sendMessage(n,e={}){var o,t;if(n.trim()){if(((o=this.currentSession)==null?void 0:o.id)!=null&&String(this.currentSession.id).startsWith("channel:")&&(this.currentSession=null),!this.currentSession)try{const a=n.trim().substring(0,50),s=(e==null?void 0:e.agentId)??"default",l=await this.createSession({agentId:s,title:a});this.currentSession=l,await Bt.connectToSession(l.id,l.agentId,l.type)}catch(a){console.error("Failed to create lazy session:",a);return}try{const a=(e==null?void 0:e.agentId)??((t=this.currentSession)==null?void 0:t.agentId)??"default";this.currentSession&&a!==this.currentSession.agentId&&await this.updateSessionAgentId(this.currentSession.id,a),this.currentSession&&Bt.currentSessionId!==this.currentSession.id&&await Bt.connectToSession(this.currentSession.id,this.currentSession.agentId,this.currentSession.type);const s={id:Date.now().toString(),role:"user",content:n,timestamp:Date.now()};this.messages.push(s),this.currentMessage="",this.currentStreamParts=[],this.isStreaming=!0,this.toolExecutions=[],tn.appendMessage(this.currentSession.id,"user",n).catch(()=>{});const l=(e==null?void 0:e.targetAgentId)??a;await Bt.sendMessage(this.currentSession.id,n,l,a,this.currentSession.type)}catch(a){console.error("Failed to send message:",a),this.isStreaming=!1}return this.currentSession}},handleAgentChunk(n){var a;if(!this.currentSession||(n==null?void 0:n.sessionId)!=null&&n.sessionId!==((a=this.currentSession)==null?void 0:a.id))return;this.isStreaming||(this.isStreaming=!0,this.currentMessage="",this.currentStreamParts=[],this.toolExecutions=[]);const e=n.text||"";if(!e||this.currentMessage.length>0&&e===this.currentMessage)return;this.currentMessage+=e;const o=this.currentStreamParts,t=o[o.length-1];t&&t.type==="text"?this.currentStreamParts=[...o.slice(0,-1),{type:"text",content:(t.content||"")+e}]:this.currentStreamParts=[...o,{type:"text",content:e}]},handleToolExecution(n){if(n.type==="start"){if(this.isStreaming||(this.isStreaming=!0,this.currentMessage="",this.currentStreamParts=[],this.toolExecutions=[]),this.toolExecutions.some(o=>o.id===n.toolCallId))return;const e={id:n.toolCallId,name:n.toolName,args:n.args,status:"running",startTime:Date.now()};this.toolExecutions=[...this.toolExecutions,e],this.currentStreamParts=[...this.currentStreamParts,{type:"tool",toolId:n.toolCallId}]}else if(n.type==="end"){const e=this.toolExecutions.find(o=>o.id===n.toolCallId);e&&(e.status=n.isError?"error":"completed",e.result=n.result,e.endTime=Date.now(),this.toolExecutions=[...this.toolExecutions])}},async fetchUsageTotal(){var n,e;try{const o=await lm.getTotal();(n=o==null?void 0:o.data)!=null&&n.success&&((e=o==null?void 0:o.data)!=null&&e.data)&&(this.totalTokens=o.data.data.totalTokens??0)}catch(o){console.warn("Failed to fetch token usage:",o)}},handleMessageComplete(n){n!=null&&n.usage&&(n.usage.promptTokens>0||n.usage.completionTokens>0)&&n.sessionId&&lm.record({sessionId:n.sessionId,source:"chat",promptTokens:n.usage.promptTokens??0,completionTokens:n.usage.completionTokens??0}).then(()=>this.fetchUsageTotal()).catch(e=>console.warn("Record usage failed:",e))},handleConversationEnd(n){var t,a;if((n==null?void 0:n.sessionId)!==((t=this.currentSession)==null?void 0:t.id))return;const e=this.currentMessage||n.content||"";if(e||this.toolExecutions.length>0){const s={id:Date.now().toString(),role:"assistant",content:e,timestamp:Date.now(),toolCalls:[...this.toolExecutions],contentParts:[...this.currentStreamParts]};this.messages.push(s),tn.appendMessage(this.currentSession.id,"assistant",e,{toolCalls:s.toolCalls,contentParts:s.contentParts}).catch(()=>{})}this.currentMessage="",this.currentStreamParts=[],this.isStreaming=!1,this.toolExecutions=[];const o=(a=this.currentSession)==null?void 0:a.id;o&&tn.getSession(o).then(s=>{var r,c;const l=((r=s==null?void 0:s.data)==null?void 0:r.data)??(s==null?void 0:s.data);if(l&&((c=this.currentSession)==null?void 0:c.id)===o){this.currentSession=l;const _=this.sessions.findIndex(d=>d.id===o);_>=0&&(this.sessions=this.sessions.map((d,m)=>m===_?{...d,...l}:d)),Bt.currentSessionId===o&&l.agentId!==void 0&&Bt.connectToSession(o,l.agentId,l.type??"chat").catch(()=>{})}}).catch(()=>{}),this.agentListRefreshTrigger+=1}}}),Fa=Ko("settings",{state:()=>({config:{gatewayUrl:"ws://localhost:38080",defaultProvider:"deepseek",defaultModel:"deepseek-chat",defaultAgentId:"default",theme:"dark",maxAgentSessions:5,loginUsername:"",loginPasswordSet:!1,providers:{}},providers:[],providerSupport:{},models:{}}),actions:{async loadConfig(){var n,e,o;try{const t=await Zn.getConfig(),a=(n=t==null?void 0:t.data)==null?void 0:n.data;a&&typeof a=="object"&&(this.config={...this.config,...a}),this.applyTheme((e=this.config)==null?void 0:e.theme)}catch(t){console.error("Failed to load config:",t),this.applyTheme((o=this.config)==null?void 0:o.theme)}},async updateConfig(n){var e;try{const o=await Zn.updateConfig(n),t=(e=o==null?void 0:o.data)==null?void 0:e.data;this.config=t&&typeof t=="object"?{...this.config,...t}:this.config,n!=null&&n.theme&&this.applyTheme(n.theme)}catch(o){console.error("Failed to update config:",o)}},async loadProviderSupport(){var n;try{const e=await Zn.getProviderSupport();this.providerSupport=((n=e.data)==null?void 0:n.data)??{},this.providers=Object.keys(this.providerSupport)}catch(e){console.error("Failed to load provider support:",e),this.providerSupport={},this.providers=[]}},async loadProviders(){await this.loadProviderSupport()},async loadModels(n,e){var o;if(n)try{const a=((o=(await Zn.getModels(n,e)).data)==null?void 0:o.data)??[],s=e?`${n}:${e}`:n;this.models={...this.models,[s]:a}}catch(t){console.error("Failed to load models:",t)}},applyTheme(n){document.documentElement.setAttribute("data-theme",n||"dark")},async setTheme(n){if(["light","dark","cosmic","neon"].includes(n)){this.applyTheme(n);try{await this.updateConfig({theme:n})}catch(o){console.error("Failed to save theme",o)}}},toggleTheme(){const n=["cosmic","light","neon","dark"],e=this.config.theme||"dark",o=(n.indexOf(e)+1)%n.length;this.updateConfig({theme:n[o]})}}}),nN={name:"ThemeToggle",setup(){const n=Fa();return{themeIcon:le(()=>{const t=n.config.theme;return t==="light"?"☀️":t==="cosmic"?"🪐":t==="neon"?"✨":"🌙"}),toggleTheme:()=>{n.toggleTheme()}}}},oN={class:"theme-icon"};function aN(n,e,o,t,a,s){return f(),b("button",{onClick:e[0]||(e[0]=(...l)=>t.toggleTheme&&t.toggleTheme(...l)),class:"theme-toggle btn-ghost",title:"Toggle theme"},[i("span",oN,u(t.themeIcon),1)])}const rN=ot(nN,[["render",aN],["__scopeId","data-v-c877b613"]]),iN={name:"Header",components:{ThemeToggle:rN},setup(){const n=Wo(),e=Pn(),o=zS(),t=Un(),{t:a}=Ct(),s=le(()=>n.name==="AgentChat"),l=le(()=>o.sessionsPanelVisible),r=()=>o.toggleSessionsPanel(),c=le(()=>t.currentSession&&t.currentSession.type!=="system"),_=M(!1),d=async()=>{var p;if((p=t.currentSession)!=null&&p.id&&confirm(a("sessions.clearHistoryConfirm"))){_.value=!0;try{await t.clearCurrentSessionMessages()}catch(E){console.error("Clear conversation failed",E)}finally{_.value=!1}}};return{pageTitle:le(()=>{const p=n.name,S={Dashboard:()=>a("nav.dashboard"),AgentChat:()=>a("nav.agentChat"),Root:()=>a("nav.agentChat"),Sessions:()=>a("nav.sessions"),Agents:()=>a("nav.agents"),AgentDetail:()=>a("nav.agents"),Tasks:()=>a("nav.tasks"),Workspace:()=>a("nav.workspace"),WorkResults:()=>a("nav.workResults"),Settings:()=>a("nav.settings")}[p];return S?S():n.path.startsWith("/chat")?a("nav.agentChat"):n.path.startsWith("/agents")?a("nav.agents"):n.path==="/settings"||n.path.startsWith("/settings")?a("nav.settings"):a("app.name")}),isChatRoute:s,hasCurrentChatSession:c,clearMessagesLoading:_,onClearConversation:d,sessionsPanelVisible:l,toggleSessionsPanel:r,router:e,t:a}}},sN={class:"header draggable"},lN={class:"header-left"},cN=["title"],dN=["title","disabled"],_N={class:"page-title"},uN={class:"header-right"},mN={class:"header-actions"};function pN(n,e,o,t,a,s){const l=ct("router-link"),r=ct("ThemeToggle");return f(),b("header",sN,[i("div",lN,[t.isChatRoute?(f(),b("button",{key:0,type:"button",class:"header-btn-sessions",title:t.sessionsPanelVisible?t.t("chat.hideSessions"):t.t("chat.showSessions"),onClick:e[0]||(e[0]=(...c)=>t.toggleSessionsPanel&&t.toggleSessionsPanel(...c))},u(t.sessionsPanelVisible?"‹":"›"),9,cN)):K("",!0),t.isChatRoute&&t.hasCurrentChatSession?(f(),b("button",{key:1,type:"button",class:"header-btn clear-conversation-btn",title:t.t("sessions.clearConversation"),disabled:t.clearMessagesLoading,onClick:e[1]||(e[1]=(...c)=>t.onClearConversation&&t.onClearConversation(...c))},[...e[3]||(e[3]=[i("span",{class:"clear-conversation-icon","aria-hidden":"true"},[i("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round"},[i("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6h14Z"}),i("path",{d:"M10 11v6M14 11v6"})])],-1)])],8,dN)):K("",!0),K("",!0),i("h1",_N,u(t.pageTitle),1)]),i("div",uN,[i("div",mN,[Oe(l,{to:"/dashboard",class:"header-btn dashboard-btn",title:t.t("nav.dashboard"),"active-class":"active"},{default:Ge(()=>[...e[4]||(e[4]=[i("span",{class:"btn-icon"},"📊",-1)])]),_:1},8,["title"]),Oe(r)])])])}const gN=ot(iN,[["render",pN],["__scopeId","data-v-33e6bd62"]]),Nd="openbot_logged_in",mr="openbot_current_user";function cm(){try{return sessionStorage.getItem(Nd)==="1"}catch{return!1}}function dm(){try{const n=sessionStorage.getItem(mr);if(!n)return null;const e=JSON.parse(n);return e&&e.id&&e.username?e:null}catch{return null}}const jd=Ko("auth",{state:()=>({isLoggedIn:cm(),currentUser:dm()}),actions:{initFromStorage(){this.isLoggedIn=cm(),this.currentUser=dm()},async login(n,e){var a;const o=await jR.login(n||"",e||"");this.isLoggedIn=!0;const t=((a=o.data)==null?void 0:a.user)??null;this.currentUser=t;try{sessionStorage.setItem(Nd,"1"),t?sessionStorage.setItem(mr,JSON.stringify(t)):sessionStorage.removeItem(mr)}catch{}},logout(){this.isLoggedIn=!1,this.currentUser=null;try{sessionStorage.removeItem(Nd),sessionStorage.removeItem(mr)}catch{}}}}),EN={name:"Login",setup(){const{t:n}=Ct(),e=jd(),o=M("admin"),t=M("123456"),a=M(""),s=M(!1);async function l(){var r,c;a.value="",s.value=!0;try{await e.login(o.value,t.value)}catch(_){const d=((c=(r=_.response)==null?void 0:r.data)==null?void 0:c.message)??_.message??n("login.invalidCredentials");a.value=d}finally{s.value=!1}}return{t:n,username:o,password:t,error:a,loading:s,submit:l}}},fN={class:"login-view"},SN={class:"login-card"},bN={class:"login-header"},TN={class:"login-logo-wrap"},hN=["alt"],vN={class:"login-title"},CN={class:"login-subtitle"},yN={class:"form-group"},RN={for:"login-username"},NN=["placeholder"],ON={class:"form-group"},AN={for:"login-password"},IN=["placeholder"],DN={key:0,class:"form-error",role:"alert"},wN=["disabled"],kN={class:"login-footer"},MN={class:"login-default-credential"},xN={class:"label"},LN={class:"label"},PN={class:"login-hint"};function UN(n,e,o,t,a,s){return f(),b("div",fN,[e[5]||(e[5]=i("div",{class:"login-bg","aria-hidden":"true"},null,-1)),i("div",SN,[i("header",bN,[i("div",TN,[i("img",{src:Qd,alt:t.t("app.name"),class:"login-logo"},null,8,hN)]),i("h1",vN,u(t.t("login.title")),1),i("p",CN,u(t.t("login.subtitle")),1)]),i("form",{class:"login-form",onSubmit:e[2]||(e[2]=Pe((...l)=>t.submit&&t.submit(...l),["prevent"]))},[i("div",yN,[i("label",RN,u(t.t("login.username")),1),X(i("input",{id:"login-username","onUpdate:modelValue":e[0]||(e[0]=l=>t.username=l),type:"text",class:"form-input",placeholder:t.t("login.usernamePlaceholder"),autocomplete:"username"},null,8,NN),[[Ne,t.username]])]),i("div",ON,[i("label",AN,u(t.t("login.password")),1),X(i("input",{id:"login-password","onUpdate:modelValue":e[1]||(e[1]=l=>t.password=l),type:"password",class:"form-input",placeholder:t.t("login.passwordPlaceholder"),autocomplete:"current-password"},null,8,IN),[[Ne,t.password]])]),t.error?(f(),b("p",DN,u(t.error),1)):K("",!0),i("button",{type:"submit",class:"btn-login",disabled:t.loading},u(t.loading?t.t("common.loading"):t.t("login.submit")),9,wN)],32),i("footer",kN,[i("p",MN,[i("span",xN,u(t.t("login.defaultUser"))+":",1),e[3]||(e[3]=Ve(" admin ",-1)),i("span",LN,u(t.t("login.defaultPassword"))+":",1),e[4]||(e[4]=Ve(" 123456 ",-1))]),i("p",PN,u(t.t("login.defaultHint")),1)])])])}const FN=ot(EN,[["render",UN],["__scopeId","data-v-831995a4"]]);async function BN(n,e){await n.loadConfig(),await n.loadProviders(),await e.fetchSessions()}function GN(n){if(!n||typeof n!="object")return!0;const e=n.providers||{},o=Object.values(e).some(a=>a&&typeof a.apiKey=="string"&&String(a.apiKey).trim()!==""),t=n.defaultProvider&&n.defaultModel||n.defaultModelItemCode&&Array.isArray(n.configuredModels)&&n.configuredModels.length>0;return!o||!t}const YN={name:"App",components:{Sidebar:Ty,Header:gN,Login:FN},errorCaptured(n,e,o){return console.error("[App] errorCaptured",n,o),!0},setup(){const n=Wo(),e=Pn(),{t:o}=Ct(),t=Fa(),a=Un(),s=jd(),l=M(!1),r=M(!1),c=le(()=>n.name==="AgentChat"||n.path==="/");function _(){r.value||GN(t.config)&&(l.value=!0,r.value=!0)}function d(){l.value=!1,e.push({path:"/settings",query:{tab:"models"}})}function m(){l.value=!1,r.value=!0}async function p(){await BN(t,a),await sn(),_()}return zt(()=>{s.initFromStorage(),s.isLoggedIn&&p()}),Ze(()=>s.isLoggedIn,E=>{E&&p()}),{route:n,isChatRoute:c,authStore:s,showConfigPromptDialog:l,t:o,goToConfig:d,dismissConfigPrompt:m}}},HN={id:"app",class:"app-container"},qN={class:"main-content"},VN={key:1,class:"view-fallback"},zN={class:"config-prompt-card"},WN={class:"config-prompt-title"},KN={class:"config-prompt-desc"},QN={class:"config-prompt-actions"};function $N(n,e,o,t,a,s){const l=ct("Login"),r=ct("Sidebar"),c=ct("Header"),_=ct("router-view");return f(),b("div",HN,[t.authStore.isLoggedIn?(f(),b(me,{key:1},[Oe(r),i("div",qN,[Oe(c),i("div",{class:De(["content-area",{"chat-full-height":t.isChatRoute}])},[Oe(_,null,{default:Ge(({Component:d})=>[Oe(Qe,{name:"fade",mode:"out-in"},{default:Ge(()=>[d?(f(),Lt(jf(d),{key:t.route.fullPath})):(f(),b("div",VN,"加载中…"))]),_:2},1024)]),_:1})],2)]),t.showConfigPromptDialog?(f(),b("div",{key:0,class:"config-prompt-backdrop",onClick:e[2]||(e[2]=Pe((...d)=>t.dismissConfigPrompt&&t.dismissConfigPrompt(...d),["self"]))},[i("div",zN,[i("h3",WN,u(t.t("app.configPromptTitle")),1),i("p",KN,u(t.t("app.configPromptDesc")),1),i("div",QN,[i("button",{type:"button",class:"btn-primary",onClick:e[0]||(e[0]=(...d)=>t.goToConfig&&t.goToConfig(...d))},u(t.t("app.configPromptConfirm")),1),i("button",{type:"button",class:"btn-secondary",onClick:e[1]||(e[1]=(...d)=>t.dismissConfigPrompt&&t.dismissConfigPrompt(...d))},u(t.t("app.configPromptSkip")),1)])])])):K("",!0)],64)):(f(),Lt(l,{key:0}))])}const XN=ot(YN,[["render",$N],["__scopeId","data-v-1790072c"]]),gb=Ko("skill",{state:()=>({skills:[],selectedSkill:null,skillContent:null,loading:!1}),getters:{skillsByCategory:n=>{const e={};return n.skills.forEach(o=>{const t=o.category||"Uncategorized";e[t]||(e[t]=[]),e[t].push(o)}),e}},actions:{async fetchSkills(){this.loading=!0;try{const n=await $t.getSkills();this.skills=n.data.data}catch(n){console.error("Failed to fetch skills:",n)}finally{this.loading=!1}},async selectSkill(n){this.loading=!0;try{const[e,o]=await Promise.all([$t.getSkill(n),$t.getSkillContent(n)]);this.selectedSkill=e.data.data,this.skillContent=o.data.data.content}catch(e){console.error("Failed to load skill:",e)}finally{this.loading=!1}},clearSelection(){this.selectedSkill=null,this.skillContent=null}}}),ZN={name:"Dashboard",setup(){const n=Pn(),e=Un(),o=gb(),{t}=Ct(),a=le(()=>e.totalTokens),s=le(()=>e.sessions),l=le(()=>e.activeSessions.length),r=le(()=>o.skills.length),c=le(()=>s.value.slice(0,5)),_=E=>new Date(E).toLocaleString(),d=E=>E==null||E===0?"0":Number(E).toLocaleString(),m=()=>{const E=e.currentSession;E!=null&&E.id?n.push(`/chat/${E.id}`):n.push("/chat")},p=E=>{n.push(`/chat/${E}`)};return zt(()=>{o.fetchSkills(),e.fetchUsageTotal()}),{sessions:s,activeSessions:l,totalSkills:r,recentSessions:c,totalTokens:a,formatDate:_,formatTokens:d,goToChat:m,openSession:p,t}}},JN={class:"dashboard"},jN={class:"welcome-header"},eO={class:"welcome-content"},tO={class:"welcome-title"},nO={class:"welcome-text"},oO={class:"quick-stats-row"},aO={class:"stat-item"},rO={class:"stat-val"},iO={class:"stat-lbl"},sO={class:"stat-item"},lO={class:"stat-val"},cO={class:"stat-lbl"},dO={class:"stat-item"},_O={class:"stat-val"},uO={class:"stat-lbl"},mO={class:"dashboard-grid"},pO={class:"main-column"},gO={class:"section-card card-glass"},EO={class:"section-title"},fO={class:"actions-grid"},SO={class:"action-details"},bO={class:"action-name"},TO={class:"action-desc"},hO={class:"action-details"},vO={class:"action-name"},CO={class:"action-desc"},yO={class:"action-details"},RO={class:"action-name"},NO={class:"action-desc"},OO={class:"section-card card-glass"},AO={class:"section-header"},IO={class:"section-title"},DO={key:0,class:"empty-state"},wO={class:"text-muted"},kO={key:1,class:"sessions-list"},MO=["onClick"],xO={class:"session-info"},LO={class:"session-id"},PO={class:"session-date"},UO={class:"side-column"},FO={class:"section-card card-glass"},BO={class:"section-title"},GO={class:"token-chart"},YO={class:"token-stats"},HO={class:"token-stat"},qO={class:"token-label"},VO={class:"token-value"},zO={class:"token-stat"},WO={class:"token-label"},KO={class:"section-card card-glass"},QO={class:"section-title"};function $O(n,e,o,t,a,s){const l=ct("router-link");return f(),b("div",JN,[i("div",jN,[i("div",eO,[i("h2",tO,u(t.t("dashboard.welcome")),1),i("p",nO,u(t.t("dashboard.welcomeDesc")),1)]),i("div",oO,[i("div",aO,[i("span",rO,u(t.activeSessions),1),i("span",iO,u(t.t("dashboard.activeSessions")),1)]),e[1]||(e[1]=i("div",{class:"stat-divider"},null,-1)),i("div",sO,[i("span",lO,u(t.totalSkills),1),i("span",cO,u(t.t("dashboard.totalSkills")),1)]),e[2]||(e[2]=i("div",{class:"stat-divider"},null,-1)),i("div",dO,[i("span",_O,u(t.formatTokens(t.totalTokens)),1),i("span",uO,u(t.t("dashboard.tokensUsed")),1)])])]),i("div",mO,[i("div",pO,[i("div",gO,[i("h3",EO,u(t.t("dashboard.quickActions")),1),i("div",fO,[i("button",{onClick:e[0]||(e[0]=(...r)=>t.goToChat&&t.goToChat(...r)),class:"action-card btn-glass"},[e[3]||(e[3]=i("span",{class:"action-icon"},"💬",-1)),i("div",SO,[i("span",bO,u(t.t("dashboard.startChat")),1),i("span",TO,u(t.t("dashboard.startChatDesc")),1)])]),Oe(l,{to:"/skills",class:"action-card btn-glass"},{default:Ge(()=>[e[4]||(e[4]=i("span",{class:"action-icon"},"🎯",-1)),i("div",hO,[i("span",vO,u(t.t("nav.skills")),1),i("span",CO,u(t.t("dashboard.browseSkillsDesc")),1)])]),_:1}),Oe(l,{to:"/agents",class:"action-card btn-glass"},{default:Ge(()=>[e[5]||(e[5]=i("span",{class:"action-icon"},"⚙️",-1)),i("div",yO,[i("span",RO,u(t.t("settings.agentConfig")),1),i("span",NO,u(t.t("dashboard.configureAgentDesc")),1)])]),_:1})])]),i("div",OO,[i("div",AO,[i("h3",IO,u(t.t("dashboard.recentSessions")),1),Oe(l,{to:"/sessions",class:"more-link"},{default:Ge(()=>[Ve(u(t.t("common.viewAll"))+" →",1)]),_:1})]),t.recentSessions.length===0?(f(),b("div",DO,[i("p",wO,u(t.t("dashboard.noSessions")),1)])):(f(),b("div",kO,[(f(!0),b(me,null,Ue(t.recentSessions,r=>(f(),b("div",{key:r.id,class:"session-row",onClick:c=>t.openSession(r.id)},[e[6]||(e[6]=i("div",{class:"session-icon"},"💬",-1)),i("div",xO,[i("span",LO,u(r.title||r.id.substring(0,8)),1),i("span",PO,u(t.formatDate(r.createdAt)),1)]),i("span",{class:De(["badge",`badge-${r.status}`])},u(r.status),3)],8,MO))),128))]))])]),i("div",UO,[i("div",FO,[i("h3",BO,u(t.t("dashboard.tokenUsage")),1),i("div",GO,[e[8]||(e[8]=vr('<div class="chart-bars" data-v-04d1de47><div class="chart-bar" style="height:40%;" data-v-04d1de47></div><div class="chart-bar" style="height:65%;" data-v-04d1de47></div><div class="chart-bar" style="height:30%;" data-v-04d1de47></div><div class="chart-bar active" style="height:85%;" data-v-04d1de47></div><div class="chart-bar" style="height:50%;" data-v-04d1de47></div><div class="chart-bar" style="height:60%;" data-v-04d1de47></div><div class="chart-bar" style="height:45%;" data-v-04d1de47></div></div>',1)),i("div",YO,[i("div",HO,[i("span",qO,u(t.t("dashboard.totalTokens")),1),i("span",VO,u(t.formatTokens(t.totalTokens)),1)]),i("div",zO,[i("span",WO,u(t.t("dashboard.cost")),1),e[7]||(e[7]=i("span",{class:"token-value"},"—",-1))])])])]),i("div",KO,[i("h3",QO,u(t.t("dashboard.followedInfo")),1),e[9]||(e[9]=vr('<div class="info-list" data-v-04d1de47><div class="info-item" data-v-04d1de47><span class="info-tag badge-info" data-v-04d1de47>Update</span><span class="info-text" data-v-04d1de47>OpenBot v1.2 is now available with new skills.</span></div><div class="info-item" data-v-04d1de47><span class="info-tag badge-success" data-v-04d1de47>Tip</span><span class="info-text" data-v-04d1de47>Try using 'Research' skill for better results.</span></div><div class="info-item" data-v-04d1de47><span class="info-tag badge-warning" data-v-04d1de47>Alert</span><span class="info-text" data-v-04d1de47>High traffic on DeepSeek API today.</span></div></div>',1))])])])])}const XO=ot(ZN,[["render",$O],["__scopeId","data-v-04d1de47"]]);function e_(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let yo=e_();function Eb(n){yo=n}const fb=/[&<>"']/,ZO=new RegExp(fb.source,"g"),Sb=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,JO=new RegExp(Sb.source,"g"),jO={"&":"&","<":"<",">":">",'"':""","'":"'"},_m=n=>jO[n];function Qt(n,e){if(e){if(fb.test(n))return n.replace(ZO,_m)}else if(Sb.test(n))return n.replace(JO,_m);return n}const eA=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function tA(n){return n.replace(eA,(e,o)=>(o=o.toLowerCase(),o==="colon"?":":o.charAt(0)==="#"?o.charAt(1)==="x"?String.fromCharCode(parseInt(o.substring(2),16)):String.fromCharCode(+o.substring(1)):""))}const nA=/(^|[^\[])\^/g;function rt(n,e){let o=typeof n=="string"?n:n.source;e=e||"";const t={replace:(a,s)=>{let l=typeof s=="string"?s:s.source;return l=l.replace(nA,"$1"),o=o.replace(a,l),t},getRegex:()=>new RegExp(o,e)};return t}function um(n){try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const fa={exec:()=>null};function mm(n,e){const o=n.replace(/\|/g,(s,l,r)=>{let c=!1,_=l;for(;--_>=0&&r[_]==="\\";)c=!c;return c?"|":" |"}),t=o.split(/ \|/);let a=0;if(t[0].trim()||t.shift(),t.length>0&&!t[t.length-1].trim()&&t.pop(),e)if(t.length>e)t.splice(e);else for(;t.length<e;)t.push("");for(;a<t.length;a++)t[a]=t[a].trim().replace(/\\\|/g,"|");return t}function nr(n,e,o){const t=n.length;if(t===0)return"";let a=0;for(;a<t&&n.charAt(t-a-1)===e;)a++;return n.slice(0,t-a)}function oA(n,e){if(n.indexOf(e[1])===-1)return-1;let o=0;for(let t=0;t<n.length;t++)if(n[t]==="\\")t++;else if(n[t]===e[0])o++;else if(n[t]===e[1]&&(o--,o<0))return t;return-1}function pm(n,e,o,t){const a=e.href,s=e.title?Qt(e.title):null,l=n[1].replace(/\\([\[\]])/g,"$1");if(n[0].charAt(0)!=="!"){t.state.inLink=!0;const r={type:"link",raw:o,href:a,title:s,text:l,tokens:t.inlineTokens(l)};return t.state.inLink=!1,r}return{type:"image",raw:o,href:a,title:s,text:Qt(l)}}function aA(n,e){const o=n.match(/^(\s+)(?:```)/);if(o===null)return e;const t=o[1];return e.split(`
|
|
35
35
|
`).map(a=>{const s=a.match(/^\s+/);if(s===null)return a;const[l]=s;return l.length>=t.length?a.slice(t.length):a}).join(`
|
|
36
36
|
`)}class Nr{constructor(e){dt(this,"options");dt(this,"rules");dt(this,"lexer");this.options=e||yo}space(e){const o=this.rules.block.newline.exec(e);if(o&&o[0].length>0)return{type:"space",raw:o[0]}}code(e){const o=this.rules.block.code.exec(e);if(o){const t=o[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:o[0],codeBlockStyle:"indented",text:this.options.pedantic?t:nr(t,`
|
|
37
37
|
`)}}}fences(e){const o=this.rules.block.fences.exec(e);if(o){const t=o[0],a=aA(t,o[3]||"");return{type:"code",raw:t,lang:o[2]?o[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):o[2],text:a}}}heading(e){const o=this.rules.block.heading.exec(e);if(o){let t=o[2].trim();if(/#$/.test(t)){const a=nr(t,"#");(this.options.pedantic||!a||/ $/.test(a))&&(t=a.trim())}return{type:"heading",raw:o[0],depth:o[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(e){const o=this.rules.block.hr.exec(e);if(o)return{type:"hr",raw:o[0]}}blockquote(e){const o=this.rules.block.blockquote.exec(e);if(o){const t=nr(o[0].replace(/^ *>[ \t]?/gm,""),`
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<link
|
|
12
12
|
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap"
|
|
13
13
|
rel="stylesheet">
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-B8jRTtME.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/index-B0_RWD2F.css">
|
|
16
16
|
</head>
|
|
17
17
|
|
|
@@ -186,14 +186,17 @@ async function handleAgentChatInner(client, targetSessionId, message, params) {
|
|
|
186
186
|
}
|
|
187
187
|
else if (event.type === "message_end") {
|
|
188
188
|
const msg = event.message;
|
|
189
|
+
// 仅当未收到过任何 text_delta 时才发整段内容,避免与前面已推送的 delta 重复导致前端显示两遍
|
|
189
190
|
if (msg?.role === "assistant" && msg?.content && Array.isArray(msg.content)) {
|
|
190
191
|
const text = msg.content
|
|
191
192
|
.filter((c) => c?.type === "text" && typeof c.text === "string")
|
|
192
193
|
.map((c) => c.text)
|
|
193
194
|
.join("");
|
|
194
195
|
if (text) {
|
|
196
|
+
if (!hasReceivedAnyChunk) {
|
|
197
|
+
broadcastToSession(targetSessionId, createEvent("agent.chunk", { text }));
|
|
198
|
+
}
|
|
195
199
|
hasReceivedAnyChunk = true;
|
|
196
|
-
broadcastToSession(targetSessionId, createEvent("agent.chunk", { text }));
|
|
197
200
|
}
|
|
198
201
|
}
|
|
199
202
|
if (msg?.errorMessage) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.8.
|
|
6
|
+
"version": "0.8.26",
|
|
7
7
|
"description": "OpenClawX - A professional desktop application for managing and executing AI agents with real-time chat, session management, and skills browsing.",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "dist/index.js",
|