@keyueclaw/web-sdk 0.1.51 → 0.1.52

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.
@@ -3197,7 +3197,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
3197
3197
  `)}}async function AH(e,t){try{return await e.request(`sessions.compact`,{key:t}),{content:`Context compacted successfully.`,action:`refresh`}}catch(e){return{content:`Compaction failed: ${String(e)}`}}}async function jH(e,t,n){if(!n)try{let[n,r]=await Promise.all([e.request(`sessions.list`,{}),e.request(`models.list`,{})]),i=GH(n,t)?.model||n?.defaults?.model||`default`,a=r?.models?.map(e=>e.id)??[],o=[`**Current model:** \`${i}\``];return a.length>0&&o.push(`**Available:** ${a.slice(0,10).map(e=>`\`${e}\``).join(`, `)}${a.length>10?` +${a.length-10} more`:``}`),{content:o.join(`
3198
3198
  `)}}catch(e){return{content:`Failed to get model info: ${String(e)}`}}try{let r=await e.request(`sessions.patch`,{key:t,model:n.trim()}),i=DH(r.resolved?.model??n.trim(),r.resolved?.modelProvider);return{content:`Model set to \`${n.trim()}\`.`,action:`refresh`,sessionPatch:{modelOverride:EH(i)}}}catch(e){return{content:`Failed to set model: ${String(e)}`}}}async function MH(e,t,n){let r=n.trim();if(!r)try{let{session:n,models:r}=await KH(e,t);return{content:UH(`Current thinking level: ${qH(n,r)}.`,yH(n?.modelProvider,n?.model))}}catch(e){return{content:`Failed to get thinking level: ${String(e)}`}}let i=gH(r);if(!i)try{let n=await WH(e,t);return{content:`Unrecognized thinking level "${r}". Valid levels: ${yH(n?.modelProvider,n?.model)}.`}}catch(e){return{content:`Failed to validate thinking level: ${String(e)}`}}try{return await e.request(`sessions.patch`,{key:t,thinkingLevel:i}),{content:`Thinking level set to **${i}**.`,action:`refresh`}}catch(e){return{content:`Failed to set thinking level: ${String(e)}`}}}async function NH(e,t,n){let r=n.trim();if(!r)try{return{content:UH(`Current verbose level: ${SH((await WH(e,t))?.verboseLevel)??`off`}.`,`on, full, off`)}}catch(e){return{content:`Failed to get verbose level: ${String(e)}`}}let i=SH(r);if(!i)return{content:`Unrecognized verbose level "${r}". Valid levels: off, on, full.`};try{return await e.request(`sessions.patch`,{key:t,verboseLevel:i}),{content:`Verbose mode set to **${i}**.`,action:`refresh`}}catch(e){return{content:`Failed to set verbose mode: ${String(e)}`}}}async function PH(e,t,n){let r=n.trim().toLowerCase();if(!r||r===`status`)try{return{content:UH(`Current fast mode: ${JH(await WH(e,t))}.`,`status, on, off`)}}catch(e){return{content:`Failed to get fast mode: ${String(e)}`}}if(r!==`on`&&r!==`off`)return{content:`Unrecognized fast mode "${n.trim()}". Valid levels: status, on, off.`};try{return await e.request(`sessions.patch`,{key:t,fastMode:r===`on`}),{content:`Fast mode ${r===`on`?`enabled`:`disabled`}.`,action:`refresh`}}catch(e){return{content:`Failed to set fast mode: ${String(e)}`}}}async function FH(e,t){try{let n=GH(await e.request(`sessions.list`,{}),t);if(!n)return{content:`No active session.`};let r=n.inputTokens??0,i=n.outputTokens??0,a=n.totalTokens??r+i,o=n.contextTokens??0,s=o>0?Math.round(r/o*100):null,c=[`**Session Usage**`,`Input: **${YH(r)}** tokens`,`Output: **${YH(i)}** tokens`,`Total: **${YH(a)}** tokens`];return s!==null&&c.push(`Context: **${s}%** of ${YH(o)}`),n.model&&c.push(`Model: \`${n.model}\``),{content:c.join(`
3199
3199
  `)}}catch(e){return{content:`Failed to get usage: ${String(e)}`}}}async function IH(e){try{let t=await e.request(`agents.list`,{}),n=t?.agents??[];if(n.length===0)return{content:`No agents configured.`};let r=[`**Agents** (${n.length})\n`];for(let e of n){let n=e.id===t?.defaultId,i=e.identity?.name||e.name||e.id,a=n?` *(default)*`:``;r.push(`- \`${e.id}\` — ${i}${a}`)}return{content:r.join(`
3200
- `)}}catch(e){return{content:`Failed to list agents: ${String(e)}`}}}async function LH(e,t,n){let r=n.trim();if(!r)return{content:"Usage: `/kill <id|all>`"};try{let n=RH((await e.request(`sessions.list`,{}))?.sessions??[],t,r);if(n.length===0)return{content:r.toLowerCase()===`all`?`No active sub-agent sessions found.`:`No matching sub-agent sessions found for \`${r}\`.`};let i=await Promise.allSettled(n.map(t=>e.request(`chat.abort`,{sessionKey:t}))),a=i.filter(e=>e.status===`rejected`),o=i.filter(e=>e.status===`fulfilled`&&e.value?.aborted!==!1).length;if(o===0){if(a.length===0)return{content:r.toLowerCase()===`all`?`No active sub-agent runs to abort.`:`No active runs matched \`${r}\`.`};throw a[0]?.reason??Error(`abort failed`)}return r.toLowerCase()===`all`?{content:o===n.length?`Aborted ${o} sub-agent session${o===1?``:`s`}.`:`Aborted ${o} of ${n.length} sub-agent sessions.`}:{content:o===n.length?`Aborted ${o} matching sub-agent session${o===1?``:`s`} for \`${r}\`.`:`Aborted ${o} of ${n.length} matching sub-agent sessions for \`${r}\`.`}}catch(e){return{content:`Failed to abort: ${String(e)}`}}}function RH(e,t,n){let r=n.trim().toLowerCase();if(!r)return[];let i=new Set,a=t.trim().toLowerCase(),o=Cz(a)?.agentId??(a===`main`?`main`:void 0),s=BH(e);for(let t of e){let e=t?.key?.trim();if(!e||!wz(e))continue;let n=e.toLowerCase(),c=Cz(n),l=zH(n,a,s,o,c?.agentId);(r===`all`&&l||l&&n===r||l&&((c?.agentId??``)===r||n.endsWith(`:subagent:${r}`)||n===`subagent:${r}`))&&i.add(e)}return[...i]}function zH(e,t,n,r,i){if(!r||i!==r)return!1;let a=HH(t,r),o=new Set,s=VH(n.get(e)?.spawnedBy);for(;s&&!o.has(s);){if(a.has(s))return!0;o.add(s),s=VH(n.get(s)?.spawnedBy)}return wz(t)?e.startsWith(`${t}:subagent:`):!1}function BH(e){let t=new Map;for(let n of e){let e=VH(n?.key);e&&t.set(e,n)}return t}function VH(e){return e?.trim().toLowerCase()||void 0}function HH(e,t){let n=new Set([e]);if(t===`main`){let t=`agent:${CH}:main`;e===`main`?n.add(t):e===t&&n.add(wH)}return n}function UH(e,t){return`${e}\nOptions: ${t}.`}async function WH(e,t){return GH(await e.request(`sessions.list`,{}),t)}function GH(e,t){let n=VH(t),r=Cz(n??``)?.agentId??(n===`main`?`main`:void 0),i=n?HH(n,r):new Set;return e?.sessions?.find(e=>{let t=VH(e.key);return t?i.has(t):!1})}async function KH(e,t){let[n,r]=await Promise.all([e.request(`sessions.list`,{}),e.request(`models.list`,{})]);return{session:GH(n,t),models:r?.models??[]}}function qH(e,t){return gH(e?.thinkingLevel)||(!e?.modelProvider||!e.model?`off`:bH({provider:e.modelProvider,model:e.model,catalog:t}))}function JH(e){return e?.fastMode===!0?`on`:`off`}function YH(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:String(e)}var XH={AUTH_REQUIRED:`AUTH_REQUIRED`,AUTH_UNAUTHORIZED:`AUTH_UNAUTHORIZED`,AUTH_TOKEN_MISSING:`AUTH_TOKEN_MISSING`,AUTH_TOKEN_MISMATCH:`AUTH_TOKEN_MISMATCH`,AUTH_TOKEN_NOT_CONFIGURED:`AUTH_TOKEN_NOT_CONFIGURED`,AUTH_PASSWORD_MISSING:`AUTH_PASSWORD_MISSING`,AUTH_PASSWORD_MISMATCH:`AUTH_PASSWORD_MISMATCH`,AUTH_PASSWORD_NOT_CONFIGURED:`AUTH_PASSWORD_NOT_CONFIGURED`,AUTH_BOOTSTRAP_TOKEN_INVALID:`AUTH_BOOTSTRAP_TOKEN_INVALID`,AUTH_DEVICE_TOKEN_MISMATCH:`AUTH_DEVICE_TOKEN_MISMATCH`,AUTH_RATE_LIMITED:`AUTH_RATE_LIMITED`,AUTH_TAILSCALE_IDENTITY_MISSING:`AUTH_TAILSCALE_IDENTITY_MISSING`,AUTH_TAILSCALE_PROXY_MISSING:`AUTH_TAILSCALE_PROXY_MISSING`,AUTH_TAILSCALE_WHOIS_FAILED:`AUTH_TAILSCALE_WHOIS_FAILED`,AUTH_TAILSCALE_IDENTITY_MISMATCH:`AUTH_TAILSCALE_IDENTITY_MISMATCH`,CONTROL_UI_ORIGIN_NOT_ALLOWED:`CONTROL_UI_ORIGIN_NOT_ALLOWED`,CONTROL_UI_DEVICE_IDENTITY_REQUIRED:`CONTROL_UI_DEVICE_IDENTITY_REQUIRED`,DEVICE_IDENTITY_REQUIRED:`DEVICE_IDENTITY_REQUIRED`,DEVICE_AUTH_INVALID:`DEVICE_AUTH_INVALID`,DEVICE_AUTH_DEVICE_ID_MISMATCH:`DEVICE_AUTH_DEVICE_ID_MISMATCH`,DEVICE_AUTH_SIGNATURE_EXPIRED:`DEVICE_AUTH_SIGNATURE_EXPIRED`,DEVICE_AUTH_NONCE_REQUIRED:`DEVICE_AUTH_NONCE_REQUIRED`,DEVICE_AUTH_NONCE_MISMATCH:`DEVICE_AUTH_NONCE_MISMATCH`,DEVICE_AUTH_SIGNATURE_INVALID:`DEVICE_AUTH_SIGNATURE_INVALID`,DEVICE_AUTH_PUBLIC_KEY_INVALID:`DEVICE_AUTH_PUBLIC_KEY_INVALID`,PAIRING_REQUIRED:`PAIRING_REQUIRED`},ZH=new Set([`retry_with_device_token`,`update_auth_configuration`,`update_auth_credentials`,`wait_then_retry`,`review_auth_configuration`]);function QH(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.code;return typeof t==`string`&&t.trim().length>0?t:null}function $H(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n=typeof t.canRetryWithDeviceToken==`boolean`?t.canRetryWithDeviceToken:void 0,r=typeof t.recommendedNextStep==`string`?t.recommendedNextStep.trim():``;return{canRetryWithDeviceToken:n,recommendedNextStep:ZH.has(r)?r:void 0}}function eU(e){let t=e.scopes.join(`,`),n=e.token??``;return[`v2`,e.deviceId,e.clientId,e.clientMode,e.role,t,String(e.signedAtMs),n,e.nonce].join(`|`)}var tU={WEBCHAT_UI:`webchat-ui`,CONTROL_UI:`openclaw-control-ui`,WEBCHAT:`webchat`,CLI:`cli`,GATEWAY_CLIENT:`gateway-client`,MACOS_APP:`openclaw-macos`,IOS_APP:`openclaw-ios`,ANDROID_APP:`openclaw-android`,NODE_HOST:`node-host`,TEST:`test`,FINGERPRINT:`fingerprint`,PROBE:`openclaw-probe`},nU=tU,rU={WEBCHAT:`webchat`,CLI:`cli`,UI:`ui`,BACKEND:`backend`,NODE:`node`,PROBE:`probe`,TEST:`test`};new Set(Object.values(tU)),new Set(Object.values(rU));var iU=class extends Error{constructor(e){super(e.message),this.name=`GatewayRequestError`,this.gatewayCode=e.code,this.details=e.details}};function aU(e){return QH(e?.details)}function oU(e){if(!e)return!1;let t=aU(e);return t===XH.AUTH_TOKEN_MISSING||t===XH.AUTH_BOOTSTRAP_TOKEN_INVALID||t===XH.AUTH_PASSWORD_MISSING||t===XH.AUTH_PASSWORD_MISMATCH||t===XH.AUTH_RATE_LIMITED||t===XH.PAIRING_REQUIRED||t===XH.CONTROL_UI_DEVICE_IDENTITY_REQUIRED||t===XH.DEVICE_IDENTITY_REQUIRED}function sU(e){try{let t=new URL(e,window.location.href),n=t.hostname.trim().toLowerCase(),r=n===`localhost`||n===`::1`||n===`[::1]`||n===`127.0.0.1`,i=n.startsWith(`127.`);if(r||i)return!0;let a=new URL(window.location.href);return t.host===a.host}catch{return!1}}var cU=4008,lU=class{constructor(e){this.opts=e,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800,this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1,this.reconnectWithUpdatedConversation=!1}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.pendingConnectError=void 0,this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1,this.flushPending(Error(`gateway client stopped`))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.addEventListener(`open`,()=>{this.opts.autoConnect!==!1&&this.queueConnect()}),this.ws.addEventListener(`message`,e=>this.handleMessage(String(e.data??``))),this.ws.addEventListener(`close`,e=>{let t=String(e.reason??``),n=this.pendingConnectError;if(this.pendingConnectError=void 0,this.ws=null,this.flushPending(Error(`gateway closed (${e.code}): ${t}`)),this.opts.onClose?.({code:e.code,reason:t,error:n}),this.reconnectWithUpdatedConversation){this.reconnectWithUpdatedConversation=!1,this.closed||this.connect();return}aU(n)===XH.AUTH_TOKEN_MISMATCH&&this.deviceTokenRetryBudgetUsed&&!this.pendingDeviceTokenRetry||oU(n)||this.scheduleReconnect()}),this.ws.addEventListener(`error`,()=>{}))}scheduleReconnect(){if(this.closed)return;let e=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),e)}flushPending(e){for(let[,t]of this.pending)t.reject(e);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);let e=typeof crypto<`u`&&!!crypto.subtle,t=[`operator.admin`,`operator.approvals`,`operator.pairing`],n=`operator`,r=this.opts.token?.trim()||void 0,i=this.opts.password?.trim()||void 0,a=null,o={authToken:r,authPassword:i,canFallbackToShared:!1};e&&(a=await lV(),o=this.selectConnectAuth({role:n,deviceId:a.deviceId}),this.pendingDeviceTokenRetry&&o.authDeviceToken&&(this.pendingDeviceTokenRetry=!1));let s=o.authToken,c=o.authDeviceToken??o.resolvedDeviceToken,l=s||c||o.authPassword?{token:s,deviceToken:c,password:o.authPassword}:void 0,u;if(e&&a){let e=Date.now(),r=this.connectNonce??``,i=eU({deviceId:a.deviceId,clientId:this.opts.clientName??nU.CONTROL_UI,clientMode:this.opts.mode??rU.WEBCHAT,role:n,scopes:t,signedAtMs:e,token:s??c??null,nonce:r}),o=await uV(a.privateKey,i);u={id:a.deviceId,publicKey:a.publicKey,signature:o,signedAt:e,nonce:r}}let d={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??nU.CONTROL_UI,version:this.opts.clientVersion??`control-ui`,platform:this.opts.platform??navigator.platform??`web`,mode:this.opts.mode??rU.WEBCHAT,instanceId:this.opts.instanceId},role:n,scopes:t,device:u,caps:[`tool-events`],auth:l,userAgent:navigator.userAgent,locale:navigator.language,userPhone:this.opts.phone,keyue:this.opts.keyue};this.request(`connect`,d).then(e=>{this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1,e?.auth?.deviceToken&&a&&qz({deviceId:a.deviceId,role:e.auth.role??n,token:e.auth.deviceToken,scopes:e.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(e)}).catch(e=>{let t=e instanceof iU?aU(e):null,i=e instanceof iU?$H(e.details):{},s=i.recommendedNextStep===`retry_with_device_token`,c=i.canRetryWithDeviceToken===!0||s||t===XH.AUTH_TOKEN_MISMATCH;!this.deviceTokenRetryBudgetUsed&&!o.authDeviceToken&&r&&a&&o.storedToken&&c&&sU(this.opts.url)&&(this.pendingDeviceTokenRetry=!0,this.deviceTokenRetryBudgetUsed=!0),e instanceof iU?this.pendingConnectError={code:e.gatewayCode,message:e.message,details:e.details}:this.pendingConnectError=void 0,o.canFallbackToShared&&a&&t===XH.AUTH_DEVICE_TOKEN_MISMATCH&&Jz({deviceId:a.deviceId,role:n}),this.ws?.close(cU,`connect failed`)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}let n=t;if(n.type===`event`){let e=t;if(e.event===`connect.challenge`){let t=e.payload,n=t&&typeof t.nonce==`string`?t.nonce:null;n&&(this.connectNonce=n,this.opts.autoConnect!==!1&&this.sendConnect());return}let n=typeof e.seq==`number`?e.seq:null;n!==null&&(this.lastSeq!==null&&n>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:n}),this.lastSeq=n);try{this.opts.onEvent?.(e)}catch(e){console.error(`[gateway] event handler error:`,e)}return}if(n.type===`res`){let e=t,n=this.pending.get(e.id);if(!n)return;this.pending.delete(e.id),e.ok?n.resolve(e.payload):n.reject(new iU({code:e.error?.code??`UNAVAILABLE`,message:e.error?.message??`request failed`,details:e.error?.details}));return}}selectConnectAuth(e){let t=this.opts.token?.trim()||void 0,n=this.opts.password?.trim()||void 0,r=Kz({deviceId:e.deviceId,role:e.role})?.token;return{authToken:t,authDeviceToken:this.pendingDeviceTokenRetry&&t&&r&&sU(this.opts.url)?r??void 0:void 0,authPassword:n,resolvedDeviceToken:t||n?void 0:r??void 0,storedToken:r??void 0,canFallbackToShared:!!(r&&t)}}request(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(Error(`gateway not connected`));let n=te(),r={type:`req`,id:n,method:e,params:t},i=new Promise((e,t)=>{this.pending.set(n,{resolve:t=>e(t),reject:t})});return this.ws.send(JSON.stringify(r)),i}connectConversation(e){let t=e?.phone??this.opts.phone,n=e?.keyue??this.opts.keyue,r=t!==this.opts.phone||n?.tenantId!==this.opts.keyue?.tenantId||n?.botId!==this.opts.keyue?.botId||n?.userId!==this.opts.keyue?.userId;if(this.opts={...this.opts,autoConnect:!0,phone:t,keyue:n},!this.ws||this.ws.readyState===WebSocket.CLOSED){this.connect();return}if(r&&this.connectSent){this.reconnectWithUpdatedConversation=!0,this.ws.close();return}this.ws.readyState===WebSocket.OPEN&&this.sendConnect()}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}};function uU(e){return typeof e==`string`?e:e instanceof Error&&typeof e.message==`string`?e.message:`unknown error`}function dU(e){let t=uU(e.message);switch(aU(e)){case XH.AUTH_TOKEN_MISMATCH:return`gateway token mismatch`;case XH.AUTH_UNAUTHORIZED:return`gateway auth failed`;case XH.AUTH_RATE_LIMITED:return`too many failed authentication attempts`;case XH.PAIRING_REQUIRED:return`gateway pairing required`;case XH.CONTROL_UI_DEVICE_IDENTITY_REQUIRED:return`device identity required (use HTTPS/localhost or allow insecure auth explicitly)`;case XH.CONTROL_UI_ORIGIN_NOT_ALLOWED:return`origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins)`;case XH.AUTH_TOKEN_MISSING:return`gateway token missing`;default:break}let n=t.trim().toLowerCase();return n===`fetch failed`||n===`failed to fetch`||n===`connect failed`?`gateway connect failed`:t}function fU(e){return e&&typeof e==`object`?dU(e):uU(e)}var pU=`NO_REPLY`,mU=/^\s*NO_REPLY\s*$/,hU=/^\s*\/(?:new|reset)\s*$/i;function gU(e){let t=e.trim();if(t!==t.toUpperCase())return!1;let n=t.toUpperCase();return!n||n.length<2||/[^A-Z_]/.test(n)||!pU.startsWith(n)?!1:n.includes(`_`)||n===`NO`}function _U(e){return mU.test(e)||gU(e)}function vU(e){if(!e||typeof e!=`object`)return!1;let t=e;if((typeof t.role==`string`?t.role.toLowerCase():``)!==`assistant`)return!1;if(typeof t.text==`string`)return _U(t.text);let n=TV(e);return typeof n==`string`&&_U(n)}function yU(e){if(!e||typeof e!=`object`)return!1;let t=e;if((typeof t.role==`string`?t.role.toLowerCase():``)!==`user`)return!1;let n=TV(e);return typeof n==`string`&&hU.test(n)}function bU(e){if(!e||typeof e!=`object`)return!1;let t=e.__openclaw;return!t||typeof t!=`object`?!1:t.hideFromChatHistory===!0}function xU(e,t){t&&console.debug(`[客悦变量] 前端收到会话变量快照`,{count:Object.keys(t).length,names:Object.keys(t),sessionKey:e.sessionKey}),ke(e,t)}function SU(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(!n||typeof n!=`object`)continue;let r=n;if((typeof r.role==`string`?r.role.toLowerCase():``)!==`assistant`)continue;let i=r.__runLatency&&typeof r.__runLatency==`object`?r.__runLatency:null;return typeof i?.ttftMs==`number`||typeof i?.totalMs==`number`}return!1}function CU(e,t){if(!t)return e;for(let n=e.length-1;n>=0;--n){let r=e[n];if(!r||typeof r!=`object`)continue;let i=r;if((typeof i.role==`string`?i.role.toLowerCase():``)!==`assistant`)continue;let a=[...e];return a[n]={...i,__runLatency:{ttftMs:t.ttftMs,totalMs:t.totalMs}},a}return e}function wU(e){let t=e;t.toolStreamById instanceof Map&&Array.isArray(t.toolStreamOrder)&&Array.isArray(t.chatToolMessages)&&Array.isArray(t.chatStreamSegments)&&iH(t)}function TU(e){let t=e;Array.isArray(t.chatStreamSegments)&&(t.chatStreamSegments=[])}function EU(e,t){if(Object.is(e,t))return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function DU(e,t){let n=0;for(;n<e.length&&n<t.length&&EU(e[n],t[n]);)n++;return[...e,...t.slice(n)]}async function OU(e,t){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{let n=await e.client.request(`chat.history`,{sessionKey:e.sessionKey,limit:200,...e.keyueDeployMode===`preview`||e.keyueDeployMode===`online`?{deployMode:`online`}:{}}),r=(Array.isArray(n.messages)?n.messages:[]).filter(e=>!vU(e)&&!yU(e)&&!bU(e)),i=t?.preserveLastLatency&&!SU(r)?CU(r,e.lastLatency):r;e.chatRunId?e.chatMessages=DU(i,e.chatMessages):e.chatMessages=i,e.chatThinkingLevel=n.thinkingLevel??null,xU(e,n.variables),e.chatRunId||(wU(e),e.chatStream=null,e.chatStreamStartedAt=null),t?.preserveLastLatency&&!SU(r)||(e.lastLatency=null)}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function kU(e){let t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}function AU(e){if(!e)return;let t=e.skillId.trim(),n=e.skillName.trim();if(!t||!n)return;let r=e.tenantId?.trim(),i=e.description?.trim(),a=e.skillPath?.trim();return{...r?{tenantId:r}:{},skillId:t,skillName:n,...i?{description:i}:{},...a?{skillPath:a}:{}}}function jU(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=n.role;if(typeof r==`string`){if((t.roleCaseSensitive?r:r.toLowerCase())!==`assistant`)return null}else if(t.roleRequirement===`required`)return null;return t.requireContentArray?Array.isArray(n.content)?n:null:!(`content`in n)&&!(t.allowTextField&&`text`in n)?null:n}function MU(e){return jU(e,{roleRequirement:`required`,roleCaseSensitive:!0,requireContentArray:!0})}function NU(e){return jU(e,{roleRequirement:`optional`,allowTextField:!0})}function PU(e,t){return!t.mediaResult||typeof t.mediaResult!=`object`?e:{...e,__mediaResult:t.mediaResult}}function FU(e,t){if(!t.mediaResult||typeof t.mediaResult!=`object`)return!1;let n=e,r=n.toolStreamById,i=n.toolStreamOrder;if(!(r instanceof Map)||!Array.isArray(i))return!1;for(let e=i.length-1;e>=0;--e){let a=i[e],o=r.get(a);if(!(!o||o.name!==`keyue_uda_card_emit`))return o.message={...o.message,__mediaResult:t.mediaResult},Array.isArray(n.chatToolMessages)&&(n.chatToolMessages=n.chatToolMessages.map(e=>e&&typeof e==`object`&&e.toolCallId===a?{...e,__mediaResult:t.mediaResult}:e)),!0}let a=`keyue-uda-final:${t.runId}`,o={role:`assistant`,toolCallId:a,runId:t.runId,content:[{type:`toolresult`,name:`keyue_uda_card_emit`,text:`completed`}],timestamp:Date.now(),__mediaResult:t.mediaResult};if(Array.isArray(n.chatToolMessages)){let e=n.chatToolMessages.findIndex(e=>e&&typeof e==`object`&&e.toolCallId===a);return e>=0?n.chatToolMessages=n.chatToolMessages.map((t,n)=>n===e?o:t):n.chatToolMessages=[...n.chatToolMessages,o],!0}return!1}async function IU(e,t,n,r){if(!e.client||!e.connected)return null;let i=t.trim(),a=n&&n.length>0;if(!i&&!a)return null;let o=Date.now(),s=AU(r?.routeSkillSelection),c=[];if(i&&c.push({type:`text`,text:i}),a)for(let e of n)c.push({type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.dataUrl}});r?.optimisticUserMessage!==!1&&(e.chatMessages=[...e.chatMessages,{role:`user`,content:c,timestamp:o,...s?{__openclaw:{routeSkill:{...s.tenantId?{tenantId:s.tenantId}:{},skillId:s.skillId,skillName:s.skillName,...s.description?{description:s.description}:{},...s.skillPath?{skillPath:s.skillPath}:{}}}}:{}}]),e.chatSending=!0,e.lastError=null,e.lastLatency=null;let l=te();e.chatRunId=l,e.chatStream=``,e.chatStreamStartedAt=o;let u=a?n.map(e=>{let t=kU(e.dataUrl);return t?{type:`image`,mimeType:t.mimeType,content:t.content}:null}).filter(e=>e!==null):void 0;try{return await e.client.request(`chat.send`,{sessionKey:e.sessionKey,message:i,routeSkillIds:r?.routeSkillIds?.length?r.routeSkillIds:void 0,routeSkillSelection:s,deliver:!1,idempotencyKey:l,attachments:u,clientSentAt:o,variables:r?.variables,...e.keyueDeployMode===`preview`||e.keyueDeployMode===`online`?{deployMode:`online`}:{}}),l}catch(t){let n=fU(t);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=n,e.chatMessages=[...e.chatMessages,{role:`assistant`,content:[{type:`text`,text:`Error: `+n}],timestamp:Date.now()}],null}finally{e.chatSending=!1}}async function LU(e){if(!e.client||!e.connected)return!1;let t=e.chatRunId;try{return await e.client.request(`chat.abort`,t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(t){return e.lastError=fU(t),!1}}function RU(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId){if(t.state===`final`){xU(e,t.variables);let n=NU(t.message),r=FU(e,t),i=n?r?n:PU(n,t):null;return i&&!vU(i)?(e.chatMessages=[...e.chatMessages,i],null):`final`}return null}if(t.state===`delta`){t.retract&&(wU(e),e.chatStream=null);let n=TV(t.message);if(typeof n==`string`&&!_U(n)){let t=e.chatStream??``;(!t||n.length>=t.length)&&(e.chatStream=n)}t.firstTokenAt!=null&&e.chatStreamStartedAt!=null&&!e.lastLatency&&(e.lastLatency={ttftMs:t.firstTokenAt-e.chatStreamStartedAt,totalMs:null})}else if(t.state===`final`){xU(e,t.variables);let n=NU(t.message);FU(e,t);let r=n?PU(n,t):null,i=e.chatStreamStartedAt==null?null:{ttftMs:t.firstTokenAt==null?null:t.firstTokenAt-e.chatStreamStartedAt,totalMs:t.endedAt==null?null:t.endedAt-e.chatStreamStartedAt};if(r&&!vU(r))i&&(r.__runLatency=i),e.chatMessages=[...e.chatMessages,r];else if(e.chatStream?.trim()&&!_U(e.chatStream)){let t={role:`assistant`,content:[{type:`text`,text:e.chatStream}],timestamp:Date.now()};i&&(t.__runLatency=i),e.chatMessages=[...e.chatMessages,t]}e.lastLatency=i,TU(e),e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null}else if(t.state===`aborted`){let n=MU(t.message);if(n&&!vU(n))e.chatMessages=[...e.chatMessages,n];else{let t=e.chatStream??``;t.trim()&&!_U(t)&&(e.chatMessages=[...e.chatMessages,{role:`assistant`,content:[{type:`text`,text:t}],timestamp:Date.now()}])}e.chatStreamStartedAt!=null&&(e.lastLatency={ttftMs:e.lastLatency?.ttftMs??null,totalMs:Date.now()-e.chatStreamStartedAt}),e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null}else t.state===`error`&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??`chat error`);return t.state}async function zU(e){try{return(await e.request(`models.list`,{}))?.models??[]}catch{return[]}}var BU=`/new`,VU=new Set;function HU(e,t){console.debug(`[客悦变量] ${e}`,t??{})}function UU(e){return e.chatSending||!!e.chatRunId}function WU(e){if(!e.connected)return!1;let t=e.sessionKey.startsWith(`keyue:`);return e.tab!=null&&e.tab!==`chat`&&e.tab!==`tenantManagement`&&!(e.tab===`onlineChat`&&t)||e.chatLoading||e.chatSending||e.chatRunId||(e.chatQueue?.length??0)>0||e.chatMessages.length>0?!1:!e.chatStream?.trim()}function GU(e){let t=be(e),n=e,r=new Set((n.keyueDialogVariables??[]).map(e=>e.name.trim()).filter(Boolean)),i=n.keyueExternalVariables,a=i&&r.size>0?Object.fromEntries(Object.entries(i).filter(([e])=>r.has(e))):i,o=i&&r.size>0?Object.keys(i).filter(e=>!r.has(e)):[];if(!(!t&&!a))return o.length>0&&HU(`SDK 外部变量被前端白名单忽略`,{count:o.length,names:o}),{...t,...a}}async function KU(e){let t=e;Te(t),await Ae(t)}async function qU(e,t){e.chatLoading=!0;try{await OU(e,t)}finally{e.chatLoading=!1}let n=e;Dz(n,!n.chatHasAutoScrolled);let r=e.sessionKey;if(r){if(e.chatMessages.length>0){VU.delete(r);return}if(WU(e)&&!VU.has(r)){if(VU.add(r),!await IU(e,BU,void 0,{optimisticUserMessage:!1})){VU.delete(r);return}Oe(e),BV(e,r)}}}function JU(e){let t=e.trim();if(!t)return!1;let n=t.toLowerCase();return n===`/new`||n===`/reset`?!0:n.startsWith(`/new `)||n.startsWith(`/reset `)}function YU(e){let t=e.trim();if(!t)return!1;let n=t.toLowerCase();return n===`/new`||n===`/reset`}async function XU(e){e.connected&&(e.chatMessage=``,await LU(e))}async function ZU(e,t,n){iH(e),Oz(e);let r=JU(t),i=r?void 0:GU(e);i&&HU(`准备发送 chat.send.variables`,{count:Object.keys(i).length,names:Object.keys(i),sessionKey:e.sessionKey,message:t});let a=await IU(e,t,n?.attachments,{optimisticUserMessage:!YU(t),routeSkillIds:n?.routeSkills?.map(e=>e.skillId),routeSkillSelection:n?.routeSkills?.[0],variables:i}),o=!!a;return!o&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!o&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),!o&&n?.previousRouteSkills&&(e.chatRouteSkills=n.previousRouteSkills),o&&(r?(await KU(e),HU(`新会话已重置前端调试参数面板`,{sessionKey:e.sessionKey,message:t})):Oe(e),BV(e,e.sessionKey)),o&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),o&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),o&&n?.restoreRouteSkills&&n.previousRouteSkills?.length&&(e.chatRouteSkills=n.previousRouteSkills),Dz(e,!0),o&&!e.chatRunId&&QU(e),o&&n?.refreshSessions&&a&&e.refreshSessionsAfterChat.add(a),o}async function QU(e){if(!e.connected||UU(e))return;let[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n;let r=!1;try{t.localCommandName?(await $U(e,t.localCommandName,t.localCommandArgs??``),r=!0):r=await ZU(e,t.text,{attachments:t.attachments,routeSkills:t.routeSkills,refreshSessions:t.refreshSessions})}catch(t){e.lastError=String(t)}r?e.chatQueue.length>0&&QU(e):e.chatQueue=[t,...e.chatQueue]}async function $U(e,t,n,r){switch(t){case`stop`:await XU(e);return;case`new`:await ZU(e,`/new`,{refreshSessions:!0,previousDraft:r?.previousDraft,restoreDraft:r?.restoreDraft}),e.onNewSession?.();return;case`reset`:await ZU(e,`/reset`,{refreshSessions:!0,previousDraft:r?.previousDraft,restoreDraft:r?.restoreDraft}),e.onNewSession?.();return;case`clear`:await eW(e);return;case`focus`:e.onSlashAction?.(`toggle-focus`);return;case`export`:e.onSlashAction?.(`export`);return}if(!e.client)return;let i=e.sessionKey,a=await OH(e.client,i,t,n);a.content&&tW(e,a.content),a.sessionPatch&&`modelOverride`in a.sessionPatch&&(e.chatModelOverrides={...e.chatModelOverrides,[i]:a.sessionPatch.modelOverride??null}),a.action===`refresh`&&await nW(e),Dz(e)}async function eW(e){if(!(!e.client||!e.connected)){try{await e.client.request(`sessions.reset`,{key:e.sessionKey}),e.chatMessages=[],e.chatStream=null,e.chatRunId=null,await qU(e)}catch(t){e.lastError=String(t)}Dz(e)}}function tW(e,t){e.chatMessages=[...e.chatMessages,{role:`system`,content:t,timestamp:Date.now()}]}async function nW(e,t){await Promise.all([qU(e),fV(e,{activeMinutes:0,limit:0,includeGlobal:!0,includeUnknown:!0}),sW(e),rW(e)]),t?.scheduleScroll!==!1&&Dz(e)}async function rW(e){if(!e.client||!e.connected){e.chatModelsLoading=!1,e.chatModelCatalog=[];return}e.chatModelsLoading=!0;try{e.chatModelCatalog=await zU(e.client)}finally{e.chatModelsLoading=!1}}var iW=QU;function aW(e){let t=Cz(e.sessionKey);return t?.agentId?t.agentId:(e.hello?.snapshot)?.sessionDefaults?.defaultAgentId?.trim()||`main`}function oW(e,t){let n=zR(e),r=encodeURIComponent(t);return n?`${n}/avatar/${r}?meta=1`:`avatar/${r}?meta=1`}async function sW(e){if(!e.connected){e.chatAvatarUrl=null;return}let t=aW(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;let n=oW(e.basePath,t);try{let t=await fetch(n,{method:`GET`});if(!t.ok){e.chatAvatarUrl=null;return}let r=await t.json();e.chatAvatarUrl=(typeof r.avatarUrl==`string`?r.avatarUrl.trim():``)||null}catch{e.chatAvatarUrl=null}}function cW(e){if(!e||e.state!==`final`)return!1;if(!e.message||typeof e.message!=`object`)return!0;let t=e.message,n=typeof t.role==`string`?t.role.toLowerCase():``;return!!(n&&n!==`assistant`)}function lW(e,t){if(typeof e!=`string`)return;let n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}var uW=50,dW=200;function fW(e){let t=lW(e?.name,uW)??`Assistant`,n=lW(e?.avatar??void 0,dW)??null;return{agentId:typeof e?.agentId==`string`&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}async function pW(e,t){if(!e.client||!e.connected)return;let n=t?.sessionKey?.trim()||e.sessionKey.trim(),r=n?{sessionKey:n}:{};try{let t=await e.client.request(`agent.identity.get`,r);if(!t)return;let n=fW(t);e.assistantName=n.name,e.assistantAvatar=n.avatar,e.assistantAgentId=n.agentId??null}catch{}}function mW(e){return typeof e==`object`&&!!e}function hW(e){if(!mW(e))return null;let t=typeof e.id==`string`?e.id.trim():``,n=e.request;if(!t||!mW(n))return null;let r=typeof n.command==`string`?n.command.trim():``;if(!r)return null;let i=typeof e.createdAtMs==`number`?e.createdAtMs:0,a=typeof e.expiresAtMs==`number`?e.expiresAtMs:0;return!i||!a?null:{id:t,request:{command:r,cwd:typeof n.cwd==`string`?n.cwd:null,host:typeof n.host==`string`?n.host:null,security:typeof n.security==`string`?n.security:null,ask:typeof n.ask==`string`?n.ask:null,agentId:typeof n.agentId==`string`?n.agentId:null,resolvedPath:typeof n.resolvedPath==`string`?n.resolvedPath:null,sessionKey:typeof n.sessionKey==`string`?n.sessionKey:null},createdAtMs:i,expiresAtMs:a}}function gW(e){if(!mW(e))return null;let t=typeof e.id==`string`?e.id.trim():``;return t?{id:t,decision:typeof e.decision==`string`?e.decision:null,resolvedBy:typeof e.resolvedBy==`string`?e.resolvedBy:null,ts:typeof e.ts==`number`?e.ts:null}:null}function _W(e){let t=Date.now();return e.filter(e=>e.expiresAtMs>t)}function vW(e,t){let n=_W(e).filter(e=>e.id!==t.id);return n.push(t),n}function yW(e,t){return _W(e).filter(e=>e.id!==t)}var bW={ok:!1,ts:0,durationMs:0,heartbeatSeconds:0,defaultAgentId:``,agents:[],sessions:{path:``,count:0,recent:[]}};async function xW(e){try{return await e.request(`health`,{})??bW}catch{return bW}}async function SW(e){if(!(!e.client||!e.connected)&&!e.healthLoading){e.healthLoading=!0,e.healthError=null;try{e.healthResult=await xW(e.client)}catch(t){e.healthError=String(t)}finally{e.healthLoading=!1}}}function CW(e){return/^(?:typeerror:\s*)?(?:fetch failed|failed to fetch)$/i.test(e.trim())}function wW(e){if(e?.variables&&typeof e.variables==`object`&&!Array.isArray(e.variables))return e.variables;if(e?.stream!==`tool`)return;let t=e.data;if(!t||typeof t!=`object`||typeof t.phase==`string`&&t.phase!==`result`)return;let n=t.result;if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n.variables;if(!(!r||typeof r!=`object`||Array.isArray(r)))return r}function TW(e){let t=e.keyueSelectedTenantId?.trim(),n=e.skillAiBuilderSkillKey?.trim();return!t||!n?null:un(t,n)}function EW(e){let t=e.serverVersion?.trim();if(!t)return;let n=e.pageUrl??(typeof window>`u`?void 0:window.location.href);if(n)try{let r=new URL(n),i=new URL(e.gatewayUrl,r);return!new Set([`ws:`,`wss:`,`http:`,`https:`]).has(i.protocol)||i.host!==r.host?void 0:t}catch{return}}function DW(e,t){let n=(e??``).trim(),r=t.mainSessionKey?.trim();if(!r)return n;if(!n)return r;let i=t.mainKey?.trim()||`main`,a=t.defaultAgentId?.trim();return n===`main`||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?r:n}function OW(e,t){if(!t?.mainSessionKey||e.keyueSelectedTenantId&&e.keyueSelectedBotId&&e.keyueActivePhone||e.sessionKey.startsWith(`keyue:`))return;let n=e.userPhone&&/^\d{7,15}$/.test(e.userPhone)?`agent:phone-${e.userPhone}:webchat`:null;if(n){e.sessionKey!==n&&(e.sessionKey=n);return}let r=DW(e.sessionKey,t),i=DW(e.settings.sessionKey,t),a=DW(e.settings.lastActiveSessionKey,t),o=r||i||e.sessionKey,s={...e.settings,sessionKey:i||o,lastActiveSessionKey:a||o},c=s.sessionKey!==e.settings.sessionKey||s.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),c&&zV(e,s)}function kW(e){let t=e;t.pendingShutdownMessage=null,e.lastError=null,e.lastErrorCode=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;let n=e.client,r=e.keyueSelectedTenantId&&e.keyueSelectedBotId&&e.keyueActivePhone?{tenantId:e.keyueSelectedTenantId,botId:e.keyueSelectedBotId,userId:e.keyueActivePhone}:void 0,i=EW({gatewayUrl:e.settings.gatewayUrl,serverVersion:e.serverVersion}),a=new lU({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:`openclaw-control-ui`,clientVersion:i,mode:`webchat`,instanceId:e.clientInstanceId,phone:e.userPhone??e.keyueActivePhone??void 0,keyue:r,autoConnect:!0,onHello:n=>{e.client===a&&(t.pendingShutdownMessage=null,e.connected=!0,e.lastError=null,e.lastErrorCode=null,e.hello=n,LW(e,n),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,iH(e),pW(e),Az(e),SW(e),kz(e,{quiet:!0}),dV(e,{quiet:!0}),e.userPhone&&!r&&a.request(`user.provision`,{}).catch(()=>{}),e.onConversationReady?.())},onClose:({code:n,reason:r,error:i})=>{if(e.client===a)if(e.connected=!1,e.lastErrorCode=aU(i)??(typeof i?.code==`string`?i.code:null),n!==1012){if(i?.message){e.lastError=e.lastErrorCode&&CW(i.message)?fU({message:i.message,details:i.details,code:i.code}):i.message;return}e.lastError=t.pendingShutdownMessage??`disconnected (${n}): ${r||`no reason`}`}else e.lastError=t.pendingShutdownMessage??null,e.lastErrorCode=null},onEvent:t=>{e.client===a&&AW(e,t)},onGap:({expected:t,received:n})=>{e.client===a&&console.warn(`[gateway] event gap (expected seq ${t}, got ${n})`)}});e.client=a,n?.stop(),a.start()}function AW(e,t){try{IW(e,t)}catch(e){console.error(`[gateway] handleGatewayEvent error:`,t.event,e)}}function jW(e,t,n){if(n!==`final`&&n!==`error`&&n!==`aborted`)return!1;let r=e,i=r.toolStreamOrder.length>0;iH(r),iW(e);let a=t?.runId;return a&&e.refreshSessionsAfterChat.has(a)&&(e.refreshSessionsAfterChat.delete(a),n===`final`&&fV(e,{activeMinutes:120})),i&&n===`final`?(qU(e,{preserveLastLatency:!0}),!0):!1}function MW(e,t){if(!(t.state===`delta`&&!e.skillAiChatRunId))if(t.state===`delta`){let n=TV(t.message);typeof n==`string`&&(e.skillAiChatStream=n)}else if(t.state===`final`){if(t.runId&&t.runId!==e.skillAiChatRunId)return;let n=t.message;if(n&&typeof n==`object`){let t=n;typeof t.role==`string`&&t.role.toLowerCase()===`assistant`&&(e.skillAiChatMessages=[...e.skillAiChatMessages,t])}else e.skillAiChatStream?.trim()&&(e.skillAiChatMessages=[...e.skillAiChatMessages,{role:`assistant`,content:[{type:`text`,text:e.skillAiChatStream}],timestamp:Date.now()}]);e.skillAiChatStream=null,e.skillAiChatRunId=null,e.skillAiChatStreamStartedAt=null,e.skillAiChatSending=!1,e.skillAiBuilderBuilding=!1;let r=t.skillKey,i=t.skillId;r&&r!==e.skillAiBuilderSkillKey&&(e.skillFilesActiveKey===e.skillAiBuilderSkillKey&&(e.skillFilesActiveKey=r),e.skillAiBuilderSkillKey=r),i&&(e.skillAiBuilderSkillId=i);let a=e.skillAiBuilderSkillKey;(async()=>{await ht(e),a&&await PW(e,a)})()}else (t.state===`aborted`||t.state===`error`)&&(e.skillAiChatStream=null,e.skillAiChatRunId=null,e.skillAiChatStreamStartedAt=null,e.skillAiChatSending=!1,e.skillAiBuilderBuilding=!1)}var NW=new Set([`write`,`edit`,`apply_patch`]);async function PW(e,t){Xt(e,t);let n=e.keyueSelectedTenantId??void 0;await Zt(e,t,{force:!0,tenantId:n});let r=new Set(e.skillFilesLists[t]?.files.map(e=>e.name).filter(Boolean)??[]),i=new Set;for(let t of e.skillAiBuilderOpenTabs)r.has(t)&&i.add(t);let a=e.skillFilesActiveName?.trim();a&&r.has(a)&&i.add(a);for(let r of i)await Qt(e,t,r,{force:!0,tenantId:n})}function FW(e,t){t?.sessionKey&&BV(e,t.sessionKey);let n=e,r=n.skillAiBuilderMode?TW(n):null;if(r&&t){let e=t.sessionKey===r,i=!!n.skillAiChatRunId&&t.runId===n.skillAiChatRunId;if(e||i){MW(n,t);return}}let i=RU(e,t),a=jW(e,t,i);i===`final`&&!a&&cW(t)&&qU(e)}function IW(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),(e.tab===`debug`||e.tab===`overview`)&&(e.eventLog=e.eventLogBuffer),t.event===`agent`){if(e.onboarding)return;let n=t.payload;if(n?.stream===`tool`){let t=e,r=t.skillAiBuilderMode?TW(t):null,i=n.sessionKey,a=!!i&&!!r&&i===r,o=!!t.skillAiChatRunId&&n.runId===t.skillAiChatRunId;if(t.skillAiBuilderMode&&(a||o)){let e=n.data??{},r=typeof e.toolCallId==`string`?e.toolCallId:``,i=typeof e.name==`string`?e.name:`tool`,a=typeof e.phase==`string`?e.phase:``;if(r){let e=t.skillAiToolCalls??[];e.find(e=>e.toolCallId===r)?a===`result`&&(t.skillAiToolCalls=e.map(e=>e.toolCallId===r?{...e,phase:`done`}:e)):t.skillAiToolCalls=[...e,{toolCallId:r,name:i,phase:`pending`}]}a===`result`&&NW.has(i.trim().toLowerCase())&&t.skillAiBuilderSkillKey&&PW(t,t.skillAiBuilderSkillKey);return}}let r=wW(n);r&&ke(e,r),uH(e,n);return}if(t.event===`chat`){FW(e,t.payload);return}if(t.event===`presence`){let n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event===`shutdown`){let n=t.payload,r=n&&typeof n.reason==`string`&&n.reason.trim()?n.reason.trim():`gateway stopping`,i=typeof n?.restartExpectedMs==`number`?`Restarting: ${r}`:`Disconnected: ${r}`;e.pendingShutdownMessage=i,e.lastError=i,e.lastErrorCode=null;return}if(t.event===`cron`&&e.tab===`cron`&&UV(e),(t.event===`device.pair.requested`||t.event===`device.pair.resolved`)&&dV(e,{quiet:!0}),t.event===`exec.approval.requested`){let n=hW(t.payload);if(n){e.execApprovalQueue=vW(e.execApprovalQueue,n),e.execApprovalError=null;let t=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=yW(e.execApprovalQueue,n.id)},t)}return}if(t.event===`exec.approval.resolved`){let n=gW(t.payload);n&&(e.execApprovalQueue=yW(e.execApprovalQueue,n.id));return}t.event===`update.available`&&(e.updateAvailable=t.payload?.updateAvailable??null)}function LW(e,t){let n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health,e.healthResult=n.health),n?.sessionDefaults&&OW(e,n.sessionDefaults),e.updateAvailable=n?.updateAvailable??null}var RW=`/__openclaw/control-ui-config.json`;d(c(((e,t)=>{t.exports={}}))(),1);async function zW(e){if(typeof window>`u`||typeof fetch!=`function`)return;let t=zR(e.basePath||`/keyueclaw`),n=t?`${t}${RW}`:RW;try{let t=await fetch(n,{method:`GET`,headers:{Accept:`application/json`},credentials:`same-origin`});if(!t.ok)return;let r=await t.json(),i=fW({agentId:r.assistantAgentId??null,name:r.assistantName,avatar:r.assistantAvatar??null});e.assistantName=i.name,e.assistantAvatar=i.avatar,e.assistantAgentId=i.agentId??null,e.serverVersion=r.serverVersion??null;let a=r.gatewayToken?.trim();a&&e.settings&&!e.settings.token.trim()&&(e.settings={...e.settings,token:a})}catch{}}var BW=class extends pi{constructor(...e){super(...e),this.wsBaseUrl=``,this.httpBaseUrl=``,this.token=``,this.theme=`dash`,this.clientInstanceId=te(),this.connectGeneration=0,this.settings=pz(),this.connected=!1,this.hello=null,this.lastError=null,this.lastErrorCode=null,this.themeMode=`system`,this.themeResolved=`dash-dark`,this.themeOrder=[...HR],this.pendingGatewayUrl=null,this.systemThemeCleanup=null,this.pendingGatewayToken=null,this.basePath=``,this.client=null,this.password=``,this.serverVersion=null,this.assistantName=``,this.assistantAvatar=null,this.assistantAgentId=null,this.noUrlSync=!0,this.chatRunId=null,this.chatQueue=[],this.refreshSessionsAfterChat=new Set,this.eventLogBuffer=[],this.eventLog=[],this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.healthLoading=!1,this.healthResult=null,this.healthError=null,this.debugHealth=null,this.execApprovalQueue=[],this.execApprovalError=null,this.updateAvailable=null,this.gatewayBootstrapDone=!1}createRenderRoot(){return this}beforeGatewayConnectSetup(){}afterGatewayConnected(){}shouldReconnectOnPropChange(){return this.gatewayBootstrapDone}startEmbeddedGatewayConnection(){Sz(this),this.settings={...this.settings,theme:this.theme},this.gatewayBootstrapDone=!1,++this.connectGeneration;let e=this.connectGeneration;yz(this),zW(this).finally(()=>{this.connectGeneration===e&&(this.gatewayBootstrapDone=!0,kW(this))})}stopEmbeddedGatewayConnection(){this.connectGeneration+=1,this.client?.stop(),this.client=null,this.connected=!1,VV(this)}handleEmbeddedGatewayUpdates(e){this.shouldReconnectOnPropChange()&&(e.has(`wsBaseUrl`)||e.has(`httpBaseUrl`)||e.has(`token`))&&(Sz(this),xz(this)&&kW(this)),e.has(`theme`)&&(this.settings={...this.settings,theme:this.theme},yz(this)),e.has(`connected`)&&this.connected&&this.afterGatewayConnected()}connectedCallback(){super.connectedCallback(),this.beforeGatewayConnectSetup(),this.startEmbeddedGatewayConnection()}disconnectedCallback(){super.disconnectedCallback(),this.stopEmbeddedGatewayConnection()}updated(e){super.updated(e),this.handleEmbeddedGatewayUpdates(e)}};O([E({type:String,attribute:`ws-base-url`})],BW.prototype,`wsBaseUrl`,void 0),O([E({type:String,attribute:`http-base-url`})],BW.prototype,`httpBaseUrl`,void 0),O([E({type:String})],BW.prototype,`token`,void 0),O([E({type:String})],BW.prototype,`theme`,void 0),O([D()],BW.prototype,`settings`,void 0),O([D()],BW.prototype,`connected`,void 0),O([D()],BW.prototype,`hello`,void 0),O([D()],BW.prototype,`lastError`,void 0),O([D()],BW.prototype,`lastErrorCode`,void 0),O([D()],BW.prototype,`themeMode`,void 0),O([D()],BW.prototype,`themeResolved`,void 0),O([D()],BW.prototype,`themeOrder`,void 0),O([D()],BW.prototype,`pendingGatewayUrl`,void 0),O([D()],BW.prototype,`systemThemeCleanup`,void 0);var $=class extends BW{constructor(...e){super(...e),this.tenantId=``,this.tenantName=``,this.botId=``,this.operatorId=``,this.operatorName=``,this._sessionKey=`agent:skill-creator`,this.tab=`skills`,this.toolStreamById=new Map,this.toolStreamOrder=[],this.toolStreamSyncTimer=null,this.chatToolMessages=[],this.chatStreamSegments=[],this.applySessionKey=``,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter=``,this.skillsViewMode=`card`,this.personalSkillsPageSizeOptions=[10,20,50,100],this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillsTab=`personal`,this.skillMenuOpenKey=null,this.teamSkillsLoading=!1,this.teamSkillsReport=null,this.teamSkillsError=null,this.teamSkillsSyncBusyKey=null,this.teamSkillsSyncedKeys=[],this.teamSkillsSyncedMap=new Map,this.teamOrganizationId=null,this.teamCurrentTenantId=null,this.teamSkillsPageNum=1,this.teamSkillsPageSize=20,this.teamSkillsTotal=0,this.teamSkillsKeyword=``,this.teamApiToken=null,this.skillBoundBotsDialogKey=null,this.skillBoundBotsLoading=!1,this.skillBoundBotsItems=[],this.skillFilesLists={},this.skillFilesContents={},this.skillFilesDrafts={},this.skillFilesActiveKey=null,this.skillFilesActiveName=null,this.skillFilesActiveDir=null,this.skillFilesLoading=!1,this.skillFilesSaving=!1,this.skillFilesError=null,this.skillFilesFullscreen=!1,this.skillFilesBackConfirm=!1,this.skillFileTreeExpandedByKey={},this.skillFileTreeMenuFolder=null,this.skillFileTreeInlineMode=null,this.skillFileTreeInlineFolder=null,this.skillFileTreeInlineValue=``,this.skillRefComponentsLoading=!1,this.skillRefComponentsMap={},this.componentPickerItems=[],this.componentPickerLoading=!1,this.componentPickerTenantId=null,this.skillVersionHistoryByKey={},this.skillVersionHistoryLoading=!1,this.skillVersionPublishDialogKey=null,this.skillVersionPublishBy=``,this.skillVersionPublishNote=``,this.skillVersionPublishBusy=!1,this.skillPlatformPublishDialogKey=null,this.skillPlatformPublishVersion=``,this.skillPlatformPublishBy=``,this.skillPlatformPublishNote=``,this.skillPlatformPublishBusy=!1,this.skillCreateMode=!1,this.skillCreateName=``,this.skillCreateDesc=``,this.skillCreateBusy=!1,this.skillCreateError=null,this.skillAiDialogOpen=!1,this.skillAiFormName=``,this.skillAiFormDesc=``,this.skillAiFormTrigger=``,this.skillAiFormInstruction=``,this.skillAiFormExample=``,this.skillAiInstructionReferences=[],this.skillAiDialogFullscreenField=null,this.skillAiFormError=null,this.skillAiBuilderMode=!1,this.skillAiBuilderSkillKey=null,this.skillAiBuilderSkillId=null,this.skillAiBuilderSkillName=null,this.skillAiBuilderBuilding=!1,this.skillAiBuilderActiveTab=`chat`,this.skillAiBuilderOpenTabs=[],this.skillAiChatMessages=[],this.skillAiChatStream=null,this.skillAiChatSending=!1,this.skillAiChatRunId=null,this.skillAiChatMessage=``,this.skillAiChatReferences=[],this.skillAiReferenceMode=`hidden`,this.skillAiReferenceTargetField=`chat`,this.skillAiReferenceActiveApiId=null,this.skillAiReferenceSelectedIndex=0,this.skillAiReferenceMatchFrom=null,this.skillAiReferenceMatchTo=null,this.skillAiReferenceQuery=``,this.skillAiChatStreamStartedAt=null,this.skillAiToolCalls=[],this.skillAiBuilderExitConfirm=!1,this.skillUploadBusy=!1,this.skillUploadError=null,this.skillUploadOverwriteKey=null,this.skillUploadPendingFile=null,this.skillDeleteConfirmKey=null,this.skillExportBusyKey=null,this.apiDefinitionsItems=[],this.apiDefinitionsPath=null,this.apiDefinitionsLoading=!1,this.apiDefinitionsSaving=!1,this.apiDefinitionsExporting=!1,this.apiDefinitionsImporting=!1,this.apiDefinitionsError=null,this.apiDefinitionsHash=null,this.apiDefinitionsMode=`list`,this.apiDefinitionsEditingId=null,this.apiDefinitionsForm=st(),this.apiDefinitionsType=`platform`,this.apiDefinitionsPage=1,this.apiDefinitionsPageSize=20,this.apiDefinitionsSaveAttempted=!1,this.apiDefinitionsDeleteConfirmItem=null,this.apiDefinitionsSelectedIds=[],this.apiDefinitionsDeleteConfirmItems=null,this.apiDefinitionsToast=null,this.apiDefinitionsToastKind=`error`,this.apiDefinitionsQuery=``,this.keyueLoading=!1,this.keyueLoaded=!1,this.keyueSaving=!1,this.keyueError=null,this.keyueDialogMode=null,this.keyueTenants=[],this.keyueSelectedTenantId=null,this.keyueTenantName=``,this.keyueTenantDescription=``,this.keyueTenantType=0,this.keyueTenantPanel=`skills`,this.keyueBots=[],this.keyueSelectedBotId=null,this.keyueBotName=``,this.keyueBotDescription=``,this.keyueBotPanel=`detail`,this.keyueBotFiles={},this.keyueBotFileDrafts={},this.keyueBotFileActive=`SOUL.md`,this.keyueBotSkillBindings=[],this.keyueBotBindingVersionDrafts={},this.keyuePublishBy=``,this.keyuePublishDescription=``,this.keyuePublishTask=null,this.keyueBotSkills=[],this.keyueSkills=[],this.keyueSkillName=``,this.keyueSkillDescription=``,this.keyueSkillContent=``,this.keyueUploadBusy=!1,this.keyueUploadError=null,this.keyuePhoneInput=``,this.keyueActivePhone=null,this.keyueOperatorId=void 0,this.keyueOperatorName=void 0,this.keyueInitLoading=!1,this.keyueInitError=null,this.keyueInitReady=!1,this.navigateKeyueRoute=()=>{},this.tenantSkillsLoadKey=null,this.tenantSkillsLoadPromise=null}get sessionKey(){return this._sessionKey}set sessionKey(e){}connectedCallback(){super.connectedCallback(),this.syncTenant(),this.loadTenantSkills(),lt(this)}afterGatewayConnected(){Et(this)}updated(e){(e.has(`tenantId`)||e.has(`botId`)||e.has(`wsBaseUrl`)||e.has(`httpBaseUrl`))&&(this.syncTenant(),this.keyueSelectedTenantId&&this.loadTenantSkills()),(e.has(`operatorId`)||e.has(`operatorName`))&&(this.keyueOperatorId=this.operatorId.trim()||void 0,this.keyueOperatorName=this.operatorName.trim()||void 0),super.updated(e)}async loadTenantSkills(){let e=this.keyueSelectedTenantId;if(!e)return;let t=`${bz(this)}::${e}`;return this.tenantSkillsLoadKey===t&&this.tenantSkillsLoadPromise?this.tenantSkillsLoadPromise:(this.tenantSkillsLoadKey=t,this.tenantSkillsLoadPromise=this.loadTenantSkillsForKey(t),this.tenantSkillsLoadPromise)}async loadTenantSkillsForKey(e){this.keyueInitLoading=!0,this.keyueInitError=null,this.keyueInitReady=!1;try{await Le(this),this.keyueInitReady=!0}catch(e){this.keyueInitError=e instanceof Error?e.message:String(e)}finally{this.tenantSkillsLoadKey===e&&(this.tenantSkillsLoadPromise=null),this.keyueInitLoading=!1}}syncTenant(){let e=this.tenantId.trim()||null,t=this.botId.trim()||null;this.keyueSelectedTenantId!==e&&(this.keyueSelectedTenantId=e,this.keyueTenantPanel=`skills`,this.tenantSkillsLoadKey=null),this.keyueSelectedBotId!==t&&(this.keyueSelectedBotId=t)}render(){return this.keyueInitError?w`
3200
+ `)}}catch(e){return{content:`Failed to list agents: ${String(e)}`}}}async function LH(e,t,n){let r=n.trim();if(!r)return{content:"Usage: `/kill <id|all>`"};try{let n=RH((await e.request(`sessions.list`,{}))?.sessions??[],t,r);if(n.length===0)return{content:r.toLowerCase()===`all`?`No active sub-agent sessions found.`:`No matching sub-agent sessions found for \`${r}\`.`};let i=await Promise.allSettled(n.map(t=>e.request(`chat.abort`,{sessionKey:t}))),a=i.filter(e=>e.status===`rejected`),o=i.filter(e=>e.status===`fulfilled`&&e.value?.aborted!==!1).length;if(o===0){if(a.length===0)return{content:r.toLowerCase()===`all`?`No active sub-agent runs to abort.`:`No active runs matched \`${r}\`.`};throw a[0]?.reason??Error(`abort failed`)}return r.toLowerCase()===`all`?{content:o===n.length?`Aborted ${o} sub-agent session${o===1?``:`s`}.`:`Aborted ${o} of ${n.length} sub-agent sessions.`}:{content:o===n.length?`Aborted ${o} matching sub-agent session${o===1?``:`s`} for \`${r}\`.`:`Aborted ${o} of ${n.length} matching sub-agent sessions for \`${r}\`.`}}catch(e){return{content:`Failed to abort: ${String(e)}`}}}function RH(e,t,n){let r=n.trim().toLowerCase();if(!r)return[];let i=new Set,a=t.trim().toLowerCase(),o=Cz(a)?.agentId??(a===`main`?`main`:void 0),s=BH(e);for(let t of e){let e=t?.key?.trim();if(!e||!wz(e))continue;let n=e.toLowerCase(),c=Cz(n),l=zH(n,a,s,o,c?.agentId);(r===`all`&&l||l&&n===r||l&&((c?.agentId??``)===r||n.endsWith(`:subagent:${r}`)||n===`subagent:${r}`))&&i.add(e)}return[...i]}function zH(e,t,n,r,i){if(!r||i!==r)return!1;let a=HH(t,r),o=new Set,s=VH(n.get(e)?.spawnedBy);for(;s&&!o.has(s);){if(a.has(s))return!0;o.add(s),s=VH(n.get(s)?.spawnedBy)}return wz(t)?e.startsWith(`${t}:subagent:`):!1}function BH(e){let t=new Map;for(let n of e){let e=VH(n?.key);e&&t.set(e,n)}return t}function VH(e){return e?.trim().toLowerCase()||void 0}function HH(e,t){let n=new Set([e]);if(t===`main`){let t=`agent:${CH}:main`;e===`main`?n.add(t):e===t&&n.add(wH)}return n}function UH(e,t){return`${e}\nOptions: ${t}.`}async function WH(e,t){return GH(await e.request(`sessions.list`,{}),t)}function GH(e,t){let n=VH(t),r=Cz(n??``)?.agentId??(n===`main`?`main`:void 0),i=n?HH(n,r):new Set;return e?.sessions?.find(e=>{let t=VH(e.key);return t?i.has(t):!1})}async function KH(e,t){let[n,r]=await Promise.all([e.request(`sessions.list`,{}),e.request(`models.list`,{})]);return{session:GH(n,t),models:r?.models??[]}}function qH(e,t){return gH(e?.thinkingLevel)||(!e?.modelProvider||!e.model?`off`:bH({provider:e.modelProvider,model:e.model,catalog:t}))}function JH(e){return e?.fastMode===!0?`on`:`off`}function YH(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:String(e)}var XH={AUTH_REQUIRED:`AUTH_REQUIRED`,AUTH_UNAUTHORIZED:`AUTH_UNAUTHORIZED`,AUTH_TOKEN_MISSING:`AUTH_TOKEN_MISSING`,AUTH_TOKEN_MISMATCH:`AUTH_TOKEN_MISMATCH`,AUTH_TOKEN_NOT_CONFIGURED:`AUTH_TOKEN_NOT_CONFIGURED`,AUTH_PASSWORD_MISSING:`AUTH_PASSWORD_MISSING`,AUTH_PASSWORD_MISMATCH:`AUTH_PASSWORD_MISMATCH`,AUTH_PASSWORD_NOT_CONFIGURED:`AUTH_PASSWORD_NOT_CONFIGURED`,AUTH_BOOTSTRAP_TOKEN_INVALID:`AUTH_BOOTSTRAP_TOKEN_INVALID`,AUTH_DEVICE_TOKEN_MISMATCH:`AUTH_DEVICE_TOKEN_MISMATCH`,AUTH_RATE_LIMITED:`AUTH_RATE_LIMITED`,AUTH_TAILSCALE_IDENTITY_MISSING:`AUTH_TAILSCALE_IDENTITY_MISSING`,AUTH_TAILSCALE_PROXY_MISSING:`AUTH_TAILSCALE_PROXY_MISSING`,AUTH_TAILSCALE_WHOIS_FAILED:`AUTH_TAILSCALE_WHOIS_FAILED`,AUTH_TAILSCALE_IDENTITY_MISMATCH:`AUTH_TAILSCALE_IDENTITY_MISMATCH`,CONTROL_UI_ORIGIN_NOT_ALLOWED:`CONTROL_UI_ORIGIN_NOT_ALLOWED`,CONTROL_UI_DEVICE_IDENTITY_REQUIRED:`CONTROL_UI_DEVICE_IDENTITY_REQUIRED`,DEVICE_IDENTITY_REQUIRED:`DEVICE_IDENTITY_REQUIRED`,DEVICE_AUTH_INVALID:`DEVICE_AUTH_INVALID`,DEVICE_AUTH_DEVICE_ID_MISMATCH:`DEVICE_AUTH_DEVICE_ID_MISMATCH`,DEVICE_AUTH_SIGNATURE_EXPIRED:`DEVICE_AUTH_SIGNATURE_EXPIRED`,DEVICE_AUTH_NONCE_REQUIRED:`DEVICE_AUTH_NONCE_REQUIRED`,DEVICE_AUTH_NONCE_MISMATCH:`DEVICE_AUTH_NONCE_MISMATCH`,DEVICE_AUTH_SIGNATURE_INVALID:`DEVICE_AUTH_SIGNATURE_INVALID`,DEVICE_AUTH_PUBLIC_KEY_INVALID:`DEVICE_AUTH_PUBLIC_KEY_INVALID`,PAIRING_REQUIRED:`PAIRING_REQUIRED`},ZH=new Set([`retry_with_device_token`,`update_auth_configuration`,`update_auth_credentials`,`wait_then_retry`,`review_auth_configuration`]);function QH(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.code;return typeof t==`string`&&t.trim().length>0?t:null}function $H(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n=typeof t.canRetryWithDeviceToken==`boolean`?t.canRetryWithDeviceToken:void 0,r=typeof t.recommendedNextStep==`string`?t.recommendedNextStep.trim():``;return{canRetryWithDeviceToken:n,recommendedNextStep:ZH.has(r)?r:void 0}}function eU(e){let t=e.scopes.join(`,`),n=e.token??``;return[`v2`,e.deviceId,e.clientId,e.clientMode,e.role,t,String(e.signedAtMs),n,e.nonce].join(`|`)}var tU={WEBCHAT_UI:`webchat-ui`,CONTROL_UI:`openclaw-control-ui`,WEBCHAT:`webchat`,CLI:`cli`,GATEWAY_CLIENT:`gateway-client`,MACOS_APP:`openclaw-macos`,IOS_APP:`openclaw-ios`,ANDROID_APP:`openclaw-android`,NODE_HOST:`node-host`,TEST:`test`,FINGERPRINT:`fingerprint`,PROBE:`openclaw-probe`},nU=tU,rU={WEBCHAT:`webchat`,CLI:`cli`,UI:`ui`,BACKEND:`backend`,NODE:`node`,PROBE:`probe`,TEST:`test`};new Set(Object.values(tU)),new Set(Object.values(rU));var iU=class extends Error{constructor(e){super(e.message),this.name=`GatewayRequestError`,this.gatewayCode=e.code,this.details=e.details}};function aU(e){return QH(e?.details)}function oU(e){if(!e)return!1;let t=aU(e);return t===XH.AUTH_TOKEN_MISSING||t===XH.AUTH_BOOTSTRAP_TOKEN_INVALID||t===XH.AUTH_PASSWORD_MISSING||t===XH.AUTH_PASSWORD_MISMATCH||t===XH.AUTH_RATE_LIMITED||t===XH.PAIRING_REQUIRED||t===XH.CONTROL_UI_DEVICE_IDENTITY_REQUIRED||t===XH.DEVICE_IDENTITY_REQUIRED}function sU(e){try{let t=new URL(e,window.location.href),n=t.hostname.trim().toLowerCase(),r=n===`localhost`||n===`::1`||n===`[::1]`||n===`127.0.0.1`,i=n.startsWith(`127.`);if(r||i)return!0;let a=new URL(window.location.href);return t.host===a.host}catch{return!1}}var cU=4008,lU=class{constructor(e){this.opts=e,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800,this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1,this.reconnectWithUpdatedConversation=!1}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.pendingConnectError=void 0,this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1,this.flushPending(Error(`gateway client stopped`))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.addEventListener(`open`,()=>{this.opts.autoConnect!==!1&&this.queueConnect()}),this.ws.addEventListener(`message`,e=>this.handleMessage(String(e.data??``))),this.ws.addEventListener(`close`,e=>{let t=String(e.reason??``),n=this.pendingConnectError;if(this.pendingConnectError=void 0,this.ws=null,this.flushPending(Error(`gateway closed (${e.code}): ${t}`)),this.opts.onClose?.({code:e.code,reason:t,error:n}),this.reconnectWithUpdatedConversation){this.reconnectWithUpdatedConversation=!1,this.closed||this.connect();return}aU(n)===XH.AUTH_TOKEN_MISMATCH&&this.deviceTokenRetryBudgetUsed&&!this.pendingDeviceTokenRetry||oU(n)||this.scheduleReconnect()}),this.ws.addEventListener(`error`,()=>{}))}scheduleReconnect(){if(this.closed)return;let e=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),e)}flushPending(e){for(let[,t]of this.pending)t.reject(e);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);let e=typeof crypto<`u`&&!!crypto.subtle,t=[`operator.admin`,`operator.approvals`,`operator.pairing`],n=`operator`,r=this.opts.token?.trim()||void 0,i=this.opts.password?.trim()||void 0,a=null,o={authToken:r,authPassword:i,canFallbackToShared:!1};e&&(a=await lV(),o=this.selectConnectAuth({role:n,deviceId:a.deviceId}),this.pendingDeviceTokenRetry&&o.authDeviceToken&&(this.pendingDeviceTokenRetry=!1));let s=o.authToken,c=o.authDeviceToken??o.resolvedDeviceToken,l=s||c||o.authPassword?{token:s,deviceToken:c,password:o.authPassword}:void 0,u;if(e&&a){let e=Date.now(),r=this.connectNonce??``,i=eU({deviceId:a.deviceId,clientId:this.opts.clientName??nU.CONTROL_UI,clientMode:this.opts.mode??rU.WEBCHAT,role:n,scopes:t,signedAtMs:e,token:s??c??null,nonce:r}),o=await uV(a.privateKey,i);u={id:a.deviceId,publicKey:a.publicKey,signature:o,signedAt:e,nonce:r}}let d={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??nU.CONTROL_UI,version:this.opts.clientVersion??`control-ui`,platform:this.opts.platform??navigator.platform??`web`,mode:this.opts.mode??rU.WEBCHAT,instanceId:this.opts.instanceId},role:n,scopes:t,device:u,caps:[`tool-events`],auth:l,userAgent:navigator.userAgent,locale:navigator.language,userPhone:this.opts.phone,keyue:this.opts.keyue};this.request(`connect`,d).then(e=>{this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1,e?.auth?.deviceToken&&a&&qz({deviceId:a.deviceId,role:e.auth.role??n,token:e.auth.deviceToken,scopes:e.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(e)}).catch(e=>{let t=e instanceof iU?aU(e):null,i=e instanceof iU?$H(e.details):{},s=i.recommendedNextStep===`retry_with_device_token`,c=i.canRetryWithDeviceToken===!0||s||t===XH.AUTH_TOKEN_MISMATCH;!this.deviceTokenRetryBudgetUsed&&!o.authDeviceToken&&r&&a&&o.storedToken&&c&&sU(this.opts.url)&&(this.pendingDeviceTokenRetry=!0,this.deviceTokenRetryBudgetUsed=!0),e instanceof iU?this.pendingConnectError={code:e.gatewayCode,message:e.message,details:e.details}:this.pendingConnectError=void 0,o.canFallbackToShared&&a&&t===XH.AUTH_DEVICE_TOKEN_MISMATCH&&Jz({deviceId:a.deviceId,role:n}),this.ws?.close(cU,`connect failed`)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}let n=t;if(n.type===`event`){let e=t;if(e.event===`connect.challenge`){let t=e.payload,n=t&&typeof t.nonce==`string`?t.nonce:null;n&&(this.connectNonce=n,this.opts.autoConnect!==!1&&this.sendConnect());return}let n=typeof e.seq==`number`?e.seq:null;n!==null&&(this.lastSeq!==null&&n>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:n}),this.lastSeq=n);try{this.opts.onEvent?.(e)}catch(e){console.error(`[gateway] event handler error:`,e)}return}if(n.type===`res`){let e=t,n=this.pending.get(e.id);if(!n)return;this.pending.delete(e.id),e.ok?n.resolve(e.payload):n.reject(new iU({code:e.error?.code??`UNAVAILABLE`,message:e.error?.message??`request failed`,details:e.error?.details}));return}}selectConnectAuth(e){let t=this.opts.token?.trim()||void 0,n=this.opts.password?.trim()||void 0,r=Kz({deviceId:e.deviceId,role:e.role})?.token;return{authToken:t,authDeviceToken:this.pendingDeviceTokenRetry&&t&&r&&sU(this.opts.url)?r??void 0:void 0,authPassword:n,resolvedDeviceToken:t||n?void 0:r??void 0,storedToken:r??void 0,canFallbackToShared:!!(r&&t)}}request(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(Error(`gateway not connected`));let n=te(),r={type:`req`,id:n,method:e,params:t},i=new Promise((e,t)=>{this.pending.set(n,{resolve:t=>e(t),reject:t})});return this.ws.send(JSON.stringify(r)),i}connectConversation(e){let t=e?.phone??this.opts.phone,n=e?.keyue??this.opts.keyue,r=t!==this.opts.phone||n?.tenantId!==this.opts.keyue?.tenantId||n?.botId!==this.opts.keyue?.botId||n?.userId!==this.opts.keyue?.userId;if(this.opts={...this.opts,autoConnect:!0,phone:t,keyue:n},!this.ws||this.ws.readyState===WebSocket.CLOSED){this.connect();return}if(r&&this.connectSent){this.reconnectWithUpdatedConversation=!0,this.ws.close();return}this.ws.readyState===WebSocket.OPEN&&this.sendConnect()}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}};function uU(e){return typeof e==`string`?e:e instanceof Error&&typeof e.message==`string`?e.message:`unknown error`}function dU(e){let t=uU(e.message);switch(aU(e)){case XH.AUTH_TOKEN_MISMATCH:return`gateway token mismatch`;case XH.AUTH_UNAUTHORIZED:return`gateway auth failed`;case XH.AUTH_RATE_LIMITED:return`too many failed authentication attempts`;case XH.PAIRING_REQUIRED:return`gateway pairing required`;case XH.CONTROL_UI_DEVICE_IDENTITY_REQUIRED:return`device identity required (use HTTPS/localhost or allow insecure auth explicitly)`;case XH.CONTROL_UI_ORIGIN_NOT_ALLOWED:return`origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins)`;case XH.AUTH_TOKEN_MISSING:return`gateway token missing`;default:break}let n=t.trim().toLowerCase();return n===`fetch failed`||n===`failed to fetch`||n===`connect failed`?`gateway connect failed`:t}function fU(e){return e&&typeof e==`object`?dU(e):uU(e)}var pU=`NO_REPLY`,mU=/^\s*NO_REPLY\s*$/,hU=/^\s*\/(?:new|reset)\s*$/i;function gU(e){let t=e.trim();if(t!==t.toUpperCase())return!1;let n=t.toUpperCase();return!n||n.length<2||/[^A-Z_]/.test(n)||!pU.startsWith(n)?!1:n.includes(`_`)||n===`NO`}function _U(e){return mU.test(e)||gU(e)}function vU(e){if(!e||typeof e!=`object`)return!1;let t=e;if((typeof t.role==`string`?t.role.toLowerCase():``)!==`assistant`)return!1;if(typeof t.text==`string`)return _U(t.text);let n=TV(e);return typeof n==`string`&&_U(n)}function yU(e){if(!e||typeof e!=`object`)return!1;let t=e;if((typeof t.role==`string`?t.role.toLowerCase():``)!==`user`)return!1;let n=TV(e);return typeof n==`string`&&hU.test(n)}function bU(e){if(!e||typeof e!=`object`)return!1;let t=e.__openclaw;return!t||typeof t!=`object`?!1:t.hideFromChatHistory===!0}function xU(e,t){t&&console.debug(`[客悦变量] 前端收到会话变量快照`,{count:Object.keys(t).length,names:Object.keys(t),sessionKey:e.sessionKey}),ke(e,t)}function SU(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(!n||typeof n!=`object`)continue;let r=n;if((typeof r.role==`string`?r.role.toLowerCase():``)!==`assistant`)continue;let i=r.__runLatency&&typeof r.__runLatency==`object`?r.__runLatency:null;return typeof i?.ttftMs==`number`||typeof i?.totalMs==`number`}return!1}function CU(e,t){if(!t)return e;for(let n=e.length-1;n>=0;--n){let r=e[n];if(!r||typeof r!=`object`)continue;let i=r;if((typeof i.role==`string`?i.role.toLowerCase():``)!==`assistant`)continue;let a=[...e];return a[n]={...i,__runLatency:{ttftMs:t.ttftMs,totalMs:t.totalMs}},a}return e}function wU(e){let t=e;t.toolStreamById instanceof Map&&Array.isArray(t.toolStreamOrder)&&Array.isArray(t.chatToolMessages)&&Array.isArray(t.chatStreamSegments)&&iH(t)}function TU(e){let t=e;Array.isArray(t.chatStreamSegments)&&(t.chatStreamSegments=[])}function EU(e,t){if(Object.is(e,t))return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function DU(e,t){let n=0;for(;n<e.length&&n<t.length&&EU(e[n],t[n]);)n++;return[...e,...t.slice(n)]}async function OU(e,t){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{let n=await e.client.request(`chat.history`,{sessionKey:e.sessionKey,limit:200,...e.keyueDeployMode===`preview`||e.keyueDeployMode===`online`?{deployMode:`online`}:{}}),r=(Array.isArray(n.messages)?n.messages:[]).filter(e=>!vU(e)&&!yU(e)&&!bU(e)),i=t?.preserveLastLatency&&!SU(r)?CU(r,e.lastLatency):r;e.chatRunId?e.chatMessages=DU(i,e.chatMessages):e.chatMessages=i,e.chatThinkingLevel=n.thinkingLevel??null,xU(e,n.variables),e.chatRunId||(wU(e),e.chatStream=null,e.chatStreamStartedAt=null),t?.preserveLastLatency&&!SU(r)||(e.lastLatency=null)}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function kU(e){let t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}function AU(e){if(!e)return;let t=e.skillId.trim(),n=e.skillName.trim();if(!t||!n)return;let r=e.tenantId?.trim(),i=e.description?.trim(),a=e.skillPath?.trim();return{...r?{tenantId:r}:{},skillId:t,skillName:n,...i?{description:i}:{},...a?{skillPath:a}:{}}}function jU(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=n.role;if(typeof r==`string`){if((t.roleCaseSensitive?r:r.toLowerCase())!==`assistant`)return null}else if(t.roleRequirement===`required`)return null;return t.requireContentArray?Array.isArray(n.content)?n:null:!(`content`in n)&&!(t.allowTextField&&`text`in n)?null:n}function MU(e){return jU(e,{roleRequirement:`required`,roleCaseSensitive:!0,requireContentArray:!0})}function NU(e){return jU(e,{roleRequirement:`optional`,allowTextField:!0})}function PU(e,t){return!t.mediaResult||typeof t.mediaResult!=`object`?e:{...e,__mediaResult:t.mediaResult}}function FU(e,t){if(!t.mediaResult||typeof t.mediaResult!=`object`)return!1;let n=e,r=n.toolStreamById,i=n.toolStreamOrder;if(!(r instanceof Map)||!Array.isArray(i))return!1;for(let e=i.length-1;e>=0;--e){let a=i[e],o=r.get(a);if(!(!o||o.name!==`keyue_uda_card_emit`))return o.message={...o.message,__mediaResult:t.mediaResult},Array.isArray(n.chatToolMessages)&&(n.chatToolMessages=n.chatToolMessages.map(e=>e&&typeof e==`object`&&e.toolCallId===a?{...e,__mediaResult:t.mediaResult}:e)),!0}let a=`keyue-uda-final:${t.runId}`,o={role:`assistant`,toolCallId:a,runId:t.runId,content:[{type:`toolresult`,name:`keyue_uda_card_emit`,text:`completed`}],timestamp:Date.now(),__mediaResult:t.mediaResult};if(Array.isArray(n.chatToolMessages)){let e=n.chatToolMessages.findIndex(e=>e&&typeof e==`object`&&e.toolCallId===a);return e>=0?n.chatToolMessages=n.chatToolMessages.map((t,n)=>n===e?o:t):n.chatToolMessages=[...n.chatToolMessages,o],!0}return!1}async function IU(e,t,n,r){if(!e.client||!e.connected)return null;let i=t.trim(),a=n&&n.length>0;if(!i&&!a)return null;let o=Date.now(),s=AU(r?.routeSkillSelection),c=[];if(i&&c.push({type:`text`,text:i}),a)for(let e of n)c.push({type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.dataUrl}});r?.optimisticUserMessage!==!1&&(e.chatMessages=[...e.chatMessages,{role:`user`,content:c,timestamp:o,...s?{__openclaw:{routeSkill:{...s.tenantId?{tenantId:s.tenantId}:{},skillId:s.skillId,skillName:s.skillName,...s.description?{description:s.description}:{},...s.skillPath?{skillPath:s.skillPath}:{}}}}:{}}]),e.chatSending=!0,e.lastError=null,e.lastLatency=null;let l=te();e.chatRunId=l,e.chatStream=``,e.chatStreamStartedAt=o;let u=a?n.map(e=>{let t=kU(e.dataUrl);return t?{type:`image`,mimeType:t.mimeType,content:t.content}:null}).filter(e=>e!==null):void 0;try{return await e.client.request(`chat.send`,{sessionKey:e.sessionKey,message:i,routeSkillIds:r?.routeSkillIds?.length?r.routeSkillIds:void 0,routeSkillSelection:s,deliver:!1,idempotencyKey:l,attachments:u,clientSentAt:o,variables:r?.variables,...e.keyueDeployMode===`preview`||e.keyueDeployMode===`online`?{deployMode:`online`}:{}}),l}catch(t){let n=fU(t);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=n,e.chatMessages=[...e.chatMessages,{role:`assistant`,content:[{type:`text`,text:`Error: `+n}],timestamp:Date.now()}],null}finally{e.chatSending=!1}}async function LU(e){if(!e.client||!e.connected)return!1;let t=e.chatRunId;try{return await e.client.request(`chat.abort`,t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(t){return e.lastError=fU(t),!1}}function RU(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId){if(t.state===`final`){xU(e,t.variables);let n=NU(t.message),r=FU(e,t),i=n?r?n:PU(n,t):null;return i&&!vU(i)?(e.chatMessages=[...e.chatMessages,i],null):`final`}return null}if(t.state===`delta`){t.retract&&(wU(e),e.chatStream=null);let n=TV(t.message);if(typeof n==`string`&&!_U(n)){let t=e.chatStream??``;(!t||n.length>=t.length)&&(e.chatStream=n)}t.firstTokenAt!=null&&e.chatStreamStartedAt!=null&&!e.lastLatency&&(e.lastLatency={ttftMs:t.firstTokenAt-e.chatStreamStartedAt,totalMs:null})}else if(t.state===`final`){xU(e,t.variables);let n=NU(t.message);FU(e,t);let r=n?PU(n,t):null,i=e.chatStreamStartedAt==null?null:{ttftMs:t.firstTokenAt==null?null:t.firstTokenAt-e.chatStreamStartedAt,totalMs:t.endedAt==null?null:t.endedAt-e.chatStreamStartedAt};if(r&&!vU(r))i&&(r.__runLatency=i),e.chatMessages=[...e.chatMessages,r];else if(e.chatStream?.trim()&&!_U(e.chatStream)){let t={role:`assistant`,content:[{type:`text`,text:e.chatStream}],timestamp:Date.now()};i&&(t.__runLatency=i),e.chatMessages=[...e.chatMessages,t]}e.lastLatency=i,TU(e),e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null}else if(t.state===`aborted`){let n=MU(t.message);if(n&&!vU(n))e.chatMessages=[...e.chatMessages,n];else{let t=e.chatStream??``;t.trim()&&!_U(t)&&(e.chatMessages=[...e.chatMessages,{role:`assistant`,content:[{type:`text`,text:t}],timestamp:Date.now()}])}e.chatStreamStartedAt!=null&&(e.lastLatency={ttftMs:e.lastLatency?.ttftMs??null,totalMs:Date.now()-e.chatStreamStartedAt}),e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null}else t.state===`error`&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??`chat error`);return t.state}async function zU(e){try{return(await e.request(`models.list`,{}))?.models??[]}catch{return[]}}var BU=`/new`,VU=new Set;function HU(e,t){console.debug(`[客悦变量] ${e}`,t??{})}function UU(e){return e.chatSending||!!e.chatRunId}function WU(e){if(!e.connected)return!1;let t=e.sessionKey.startsWith(`keyue:`);return e.tab!=null&&e.tab!==`chat`&&e.tab!==`tenantManagement`&&!(e.tab===`onlineChat`&&t)||e.chatLoading||e.chatSending||e.chatRunId||(e.chatQueue?.length??0)>0||e.chatMessages.length>0?!1:!e.chatStream?.trim()}function GU(e){let t=be(e),n=e,r=new Set((n.keyueDialogVariables??[]).map(e=>e.name.trim()).filter(Boolean)),i=n.keyueExternalVariables,a=i&&r.size>0?Object.fromEntries(Object.entries(i).filter(([e])=>r.has(e))):i,o=i&&r.size>0?Object.keys(i).filter(e=>!r.has(e)):[];if(!(!t&&!a))return o.length>0&&HU(`SDK 外部变量被前端白名单忽略`,{count:o.length,names:o}),{...t,...a}}async function KU(e){let t=e;Te(t),await Ae(t)}async function qU(e,t){e.chatLoading=!0;try{await OU(e,t)}finally{e.chatLoading=!1}let n=e;Dz(n,!n.chatHasAutoScrolled);let r=e.sessionKey;if(r){if(e.chatMessages.length>0){VU.delete(r);return}if(WU(e)&&!VU.has(r)){if(VU.add(r),!await IU(e,BU,void 0,{optimisticUserMessage:!1})){VU.delete(r);return}Oe(e),BV(e,r)}}}function JU(e){let t=e.trim();if(!t)return!1;let n=t.toLowerCase();return n===`/new`||n===`/reset`?!0:n.startsWith(`/new `)||n.startsWith(`/reset `)}function YU(e){let t=e.trim();if(!t)return!1;let n=t.toLowerCase();return n===`/new`||n===`/reset`}async function XU(e){e.connected&&(e.chatMessage=``,await LU(e))}async function ZU(e,t,n){iH(e),Oz(e);let r=JU(t),i=r?void 0:GU(e);i&&HU(`准备发送 chat.send.variables`,{count:Object.keys(i).length,names:Object.keys(i),sessionKey:e.sessionKey,message:t});let a=await IU(e,t,n?.attachments,{optimisticUserMessage:!YU(t),routeSkillIds:n?.routeSkills?.map(e=>e.skillId),routeSkillSelection:n?.routeSkills?.[0],variables:i}),o=!!a;return!o&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!o&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),!o&&n?.previousRouteSkills&&(e.chatRouteSkills=n.previousRouteSkills),o&&(r?(await KU(e),HU(`新会话已重置前端调试参数面板`,{sessionKey:e.sessionKey,message:t})):Oe(e),BV(e,e.sessionKey)),o&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),o&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),o&&n?.restoreRouteSkills&&n.previousRouteSkills?.length&&(e.chatRouteSkills=n.previousRouteSkills),Dz(e,!0),o&&!e.chatRunId&&QU(e),o&&n?.refreshSessions&&a&&e.refreshSessionsAfterChat.add(a),o}async function QU(e){if(!e.connected||UU(e))return;let[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n;let r=!1;try{t.localCommandName?(await $U(e,t.localCommandName,t.localCommandArgs??``),r=!0):r=await ZU(e,t.text,{attachments:t.attachments,routeSkills:t.routeSkills,refreshSessions:t.refreshSessions})}catch(t){e.lastError=String(t)}r?e.chatQueue.length>0&&QU(e):e.chatQueue=[t,...e.chatQueue]}async function $U(e,t,n,r){switch(t){case`stop`:await XU(e);return;case`new`:await ZU(e,`/new`,{refreshSessions:!0,previousDraft:r?.previousDraft,restoreDraft:r?.restoreDraft}),e.onNewSession?.();return;case`reset`:await ZU(e,`/reset`,{refreshSessions:!0,previousDraft:r?.previousDraft,restoreDraft:r?.restoreDraft}),e.onNewSession?.();return;case`clear`:await eW(e);return;case`focus`:e.onSlashAction?.(`toggle-focus`);return;case`export`:e.onSlashAction?.(`export`);return}if(!e.client)return;let i=e.sessionKey,a=await OH(e.client,i,t,n);a.content&&tW(e,a.content),a.sessionPatch&&`modelOverride`in a.sessionPatch&&(e.chatModelOverrides={...e.chatModelOverrides,[i]:a.sessionPatch.modelOverride??null}),a.action===`refresh`&&await nW(e),Dz(e)}async function eW(e){if(!(!e.client||!e.connected)){try{await e.client.request(`sessions.reset`,{key:e.sessionKey}),e.chatMessages=[],e.chatStream=null,e.chatRunId=null,await qU(e)}catch(t){e.lastError=String(t)}Dz(e)}}function tW(e,t){e.chatMessages=[...e.chatMessages,{role:`system`,content:t,timestamp:Date.now()}]}async function nW(e,t){await Promise.all([qU(e),fV(e,{activeMinutes:0,limit:0,includeGlobal:!0,includeUnknown:!0}),sW(e),rW(e)]),t?.scheduleScroll!==!1&&Dz(e)}async function rW(e){if(!e.client||!e.connected){e.chatModelsLoading=!1,e.chatModelCatalog=[];return}e.chatModelsLoading=!0;try{e.chatModelCatalog=await zU(e.client)}finally{e.chatModelsLoading=!1}}var iW=QU;function aW(e){let t=Cz(e.sessionKey);return t?.agentId?t.agentId:(e.hello?.snapshot)?.sessionDefaults?.defaultAgentId?.trim()||`main`}function oW(e,t){let n=zR(e),r=encodeURIComponent(t);return n?`${n}/avatar/${r}?meta=1`:`avatar/${r}?meta=1`}async function sW(e){if(!e.connected){e.chatAvatarUrl=null;return}let t=aW(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;let n=oW(e.basePath,t);try{let t=await fetch(n,{method:`GET`});if(!t.ok){e.chatAvatarUrl=null;return}let r=await t.json();e.chatAvatarUrl=(typeof r.avatarUrl==`string`?r.avatarUrl.trim():``)||null}catch{e.chatAvatarUrl=null}}function cW(e){if(!e||e.state!==`final`)return!1;if(!e.message||typeof e.message!=`object`)return!0;let t=e.message,n=typeof t.role==`string`?t.role.toLowerCase():``;return!!(n&&n!==`assistant`)}function lW(e,t){if(typeof e!=`string`)return;let n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}var uW=50,dW=200;function fW(e){let t=lW(e?.name,uW)??`Assistant`,n=lW(e?.avatar??void 0,dW)??null;return{agentId:typeof e?.agentId==`string`&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}async function pW(e,t){if(!e.client||!e.connected)return;let n=t?.sessionKey?.trim()||e.sessionKey.trim(),r=n?{sessionKey:n}:{};try{let t=await e.client.request(`agent.identity.get`,r);if(!t)return;let n=fW(t);e.assistantName=n.name,e.assistantAvatar=n.avatar,e.assistantAgentId=n.agentId??null}catch{}}function mW(e){return typeof e==`object`&&!!e}function hW(e){if(!mW(e))return null;let t=typeof e.id==`string`?e.id.trim():``,n=e.request;if(!t||!mW(n))return null;let r=typeof n.command==`string`?n.command.trim():``;if(!r)return null;let i=typeof e.createdAtMs==`number`?e.createdAtMs:0,a=typeof e.expiresAtMs==`number`?e.expiresAtMs:0;return!i||!a?null:{id:t,request:{command:r,cwd:typeof n.cwd==`string`?n.cwd:null,host:typeof n.host==`string`?n.host:null,security:typeof n.security==`string`?n.security:null,ask:typeof n.ask==`string`?n.ask:null,agentId:typeof n.agentId==`string`?n.agentId:null,resolvedPath:typeof n.resolvedPath==`string`?n.resolvedPath:null,sessionKey:typeof n.sessionKey==`string`?n.sessionKey:null},createdAtMs:i,expiresAtMs:a}}function gW(e){if(!mW(e))return null;let t=typeof e.id==`string`?e.id.trim():``;return t?{id:t,decision:typeof e.decision==`string`?e.decision:null,resolvedBy:typeof e.resolvedBy==`string`?e.resolvedBy:null,ts:typeof e.ts==`number`?e.ts:null}:null}function _W(e){let t=Date.now();return e.filter(e=>e.expiresAtMs>t)}function vW(e,t){let n=_W(e).filter(e=>e.id!==t.id);return n.push(t),n}function yW(e,t){return _W(e).filter(e=>e.id!==t)}var bW={ok:!1,ts:0,durationMs:0,heartbeatSeconds:0,defaultAgentId:``,agents:[],sessions:{path:``,count:0,recent:[]}};async function xW(e){try{return await e.request(`health`,{})??bW}catch{return bW}}async function SW(e){if(!(!e.client||!e.connected)&&!e.healthLoading){e.healthLoading=!0,e.healthError=null;try{e.healthResult=await xW(e.client)}catch(t){e.healthError=String(t)}finally{e.healthLoading=!1}}}function CW(e){return/^(?:typeerror:\s*)?(?:fetch failed|failed to fetch)$/i.test(e.trim())}function wW(e){if(e?.variables&&typeof e.variables==`object`&&!Array.isArray(e.variables))return e.variables;if(e?.stream!==`tool`)return;let t=e.data;if(!t||typeof t!=`object`||typeof t.phase==`string`&&t.phase!==`result`)return;let n=t.result;if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n.variables;if(!(!r||typeof r!=`object`||Array.isArray(r)))return r}function TW(e){let t=e.keyueSelectedTenantId?.trim(),n=e.skillAiBuilderSkillKey?.trim();return!t||!n?null:un(t,n)}function EW(e){let t=e.serverVersion?.trim();if(!t)return;let n=e.pageUrl??(typeof window>`u`?void 0:window.location.href);if(n)try{let r=new URL(n),i=new URL(e.gatewayUrl,r);return!new Set([`ws:`,`wss:`,`http:`,`https:`]).has(i.protocol)||i.host!==r.host?void 0:t}catch{return}}function DW(e,t){let n=(e??``).trim(),r=t.mainSessionKey?.trim();if(!r)return n;if(!n)return r;let i=t.mainKey?.trim()||`main`,a=t.defaultAgentId?.trim();return n===`main`||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?r:n}function OW(e,t){if(!t?.mainSessionKey||e.keyueSelectedTenantId&&e.keyueSelectedBotId&&e.keyueActivePhone||e.sessionKey.startsWith(`keyue:`))return;let n=e.userPhone&&/^\d{7,15}$/.test(e.userPhone)?`agent:phone-${e.userPhone}:webchat`:null;if(n){e.sessionKey!==n&&(e.sessionKey=n);return}let r=DW(e.sessionKey,t),i=DW(e.settings.sessionKey,t),a=DW(e.settings.lastActiveSessionKey,t),o=r||i||e.sessionKey,s={...e.settings,sessionKey:i||o,lastActiveSessionKey:a||o},c=s.sessionKey!==e.settings.sessionKey||s.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),c&&zV(e,s)}function kW(e){let t=e;t.pendingShutdownMessage=null,e.lastError=null,e.lastErrorCode=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;let n=e.client,r=e.keyueSelectedTenantId&&e.keyueSelectedBotId&&e.keyueActivePhone?{tenantId:e.keyueSelectedTenantId,botId:e.keyueSelectedBotId,userId:e.keyueActivePhone}:void 0,i=EW({gatewayUrl:e.settings.gatewayUrl,serverVersion:e.serverVersion}),a=new lU({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:`openclaw-control-ui`,clientVersion:i,mode:`webchat`,instanceId:e.clientInstanceId,phone:e.userPhone??e.keyueActivePhone??void 0,keyue:r,autoConnect:!0,onHello:n=>{e.client===a&&(t.pendingShutdownMessage=null,e.connected=!0,e.lastError=null,e.lastErrorCode=null,e.hello=n,LW(e,n),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,iH(e),pW(e),Az(e),SW(e),kz(e,{quiet:!0}),dV(e,{quiet:!0}),e.userPhone&&!r&&a.request(`user.provision`,{}).catch(()=>{}),e.onConversationReady?.())},onClose:({code:n,reason:r,error:i})=>{if(e.client===a)if(e.connected=!1,e.lastErrorCode=aU(i)??(typeof i?.code==`string`?i.code:null),n!==1012){if(i?.message){e.lastError=e.lastErrorCode&&CW(i.message)?fU({message:i.message,details:i.details,code:i.code}):i.message;return}e.lastError=t.pendingShutdownMessage??`disconnected (${n}): ${r||`no reason`}`}else e.lastError=t.pendingShutdownMessage??null,e.lastErrorCode=null},onEvent:t=>{e.client===a&&AW(e,t)},onGap:({expected:t,received:n})=>{e.client===a&&console.warn(`[gateway] event gap (expected seq ${t}, got ${n})`)}});e.client=a,n?.stop(),a.start()}function AW(e,t){try{IW(e,t)}catch(e){console.error(`[gateway] handleGatewayEvent error:`,t.event,e)}}function jW(e,t,n){if(n!==`final`&&n!==`error`&&n!==`aborted`)return!1;let r=e,i=r.toolStreamOrder.length>0;iH(r),iW(e);let a=t?.runId;return a&&e.refreshSessionsAfterChat.has(a)&&(e.refreshSessionsAfterChat.delete(a),n===`final`&&fV(e,{activeMinutes:120})),i&&n===`final`?(qU(e,{preserveLastLatency:!0}),!0):!1}function MW(e,t){if(!(t.state===`delta`&&!e.skillAiChatRunId))if(t.state===`delta`){let n=TV(t.message);typeof n==`string`&&(e.skillAiChatStream=n)}else if(t.state===`final`){if(t.runId&&t.runId!==e.skillAiChatRunId)return;let n=t.message;if(n&&typeof n==`object`){let t=n;typeof t.role==`string`&&t.role.toLowerCase()===`assistant`&&(e.skillAiChatMessages=[...e.skillAiChatMessages,t])}else e.skillAiChatStream?.trim()&&(e.skillAiChatMessages=[...e.skillAiChatMessages,{role:`assistant`,content:[{type:`text`,text:e.skillAiChatStream}],timestamp:Date.now()}]);e.skillAiChatStream=null,e.skillAiChatRunId=null,e.skillAiChatStreamStartedAt=null,e.skillAiChatSending=!1,e.skillAiBuilderBuilding=!1;let r=t.skillKey,i=t.skillId;r&&r!==e.skillAiBuilderSkillKey&&(e.skillFilesActiveKey===e.skillAiBuilderSkillKey&&(e.skillFilesActiveKey=r),e.skillAiBuilderSkillKey=r),i&&(e.skillAiBuilderSkillId=i);let a=e.skillAiBuilderSkillKey;(async()=>{await ht(e),a&&await PW(e,a)})()}else (t.state===`aborted`||t.state===`error`)&&(e.skillAiChatStream=null,e.skillAiChatRunId=null,e.skillAiChatStreamStartedAt=null,e.skillAiChatSending=!1,e.skillAiBuilderBuilding=!1)}var NW=new Set([`write`,`edit`,`apply_patch`]);async function PW(e,t){Xt(e,t);let n=e.keyueSelectedTenantId??void 0;await Zt(e,t,{force:!0,tenantId:n});let r=new Set(e.skillFilesLists[t]?.files.map(e=>e.name).filter(Boolean)??[]),i=new Set;for(let t of e.skillAiBuilderOpenTabs)r.has(t)&&i.add(t);let a=e.skillFilesActiveName?.trim();a&&r.has(a)&&i.add(a);for(let r of i)await Qt(e,t,r,{force:!0,tenantId:n})}function FW(e,t){t?.sessionKey&&BV(e,t.sessionKey);let n=e,r=n.skillAiBuilderMode?TW(n):null;if(r&&t){let e=t.sessionKey===r,i=!!n.skillAiChatRunId&&t.runId===n.skillAiChatRunId;if(e||i){MW(n,t);return}}let i=RU(e,t),a=jW(e,t,i);i===`final`&&!a&&cW(t)&&qU(e)}function IW(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),(e.tab===`debug`||e.tab===`overview`)&&(e.eventLog=e.eventLogBuffer),t.event===`agent`){if(e.onboarding)return;let n=t.payload;if(n?.stream===`tool`){let t=e,r=t.skillAiBuilderMode?TW(t):null,i=n.sessionKey,a=!!i&&!!r&&i===r,o=!!t.skillAiChatRunId&&n.runId===t.skillAiChatRunId;if(t.skillAiBuilderMode&&(a||o)){let e=n.data??{},r=typeof e.toolCallId==`string`?e.toolCallId:``,i=typeof e.name==`string`?e.name:`tool`,a=typeof e.phase==`string`?e.phase:``;if(r){let e=t.skillAiToolCalls??[];e.find(e=>e.toolCallId===r)?a===`result`&&(t.skillAiToolCalls=e.map(e=>e.toolCallId===r?{...e,phase:`done`}:e)):t.skillAiToolCalls=[...e,{toolCallId:r,name:i,phase:`pending`}]}a===`result`&&NW.has(i.trim().toLowerCase())&&t.skillAiBuilderSkillKey&&PW(t,t.skillAiBuilderSkillKey);return}}let r=wW(n);r&&ke(e,r),uH(e,n);return}if(t.event===`chat`){FW(e,t.payload);return}if(t.event===`presence`){let n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event===`shutdown`){let n=t.payload,r=n&&typeof n.reason==`string`&&n.reason.trim()?n.reason.trim():`gateway stopping`,i=typeof n?.restartExpectedMs==`number`?`Restarting: ${r}`:`Disconnected: ${r}`;e.pendingShutdownMessage=i,e.lastError=i,e.lastErrorCode=null;return}if(t.event===`cron`&&e.tab===`cron`&&UV(e),(t.event===`device.pair.requested`||t.event===`device.pair.resolved`)&&dV(e,{quiet:!0}),t.event===`exec.approval.requested`){let n=hW(t.payload);if(n){e.execApprovalQueue=vW(e.execApprovalQueue,n),e.execApprovalError=null;let t=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=yW(e.execApprovalQueue,n.id)},t)}return}if(t.event===`exec.approval.resolved`){let n=gW(t.payload);n&&(e.execApprovalQueue=yW(e.execApprovalQueue,n.id));return}t.event===`update.available`&&(e.updateAvailable=t.payload?.updateAvailable??null)}function LW(e,t){let n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health,e.healthResult=n.health),n?.sessionDefaults&&OW(e,n.sessionDefaults),e.updateAvailable=n?.updateAvailable??null}var RW=`/__openclaw/control-ui-config.json`;d(c(((e,t)=>{t.exports={}}))(),1);async function zW(e){if(typeof window>`u`||typeof fetch!=`function`)return;let t=zR(e.basePath||`/keyueclaw`),n=t?`${t}${RW}`:RW;try{let t=await fetch(n,{method:`GET`,headers:{Accept:`application/json`},credentials:`same-origin`});if(!t.ok)return;let r=await t.json(),i=fW({agentId:r.assistantAgentId??null,name:r.assistantName,avatar:r.assistantAvatar??null});e.assistantName=i.name,e.assistantAvatar=i.avatar,e.assistantAgentId=i.agentId??null,e.serverVersion=r.serverVersion??null;let a=r.gatewayToken?.trim();a&&e.settings&&!e.settings.token.trim()&&(e.settings={...e.settings,token:a})}catch{}}var BW=class extends pi{constructor(...e){super(...e),this.wsBaseUrl=``,this.httpBaseUrl=``,this.token=``,this.theme=`dash`,this.clientInstanceId=te(),this.connectGeneration=0,this.settings=pz(),this.connected=!1,this.hello=null,this.lastError=null,this.lastErrorCode=null,this.themeMode=`system`,this.themeResolved=`dash-dark`,this.themeOrder=[...HR],this.pendingGatewayUrl=null,this.systemThemeCleanup=null,this.pendingGatewayToken=null,this.basePath=``,this.client=null,this.password=``,this.serverVersion=null,this.assistantName=``,this.assistantAvatar=null,this.assistantAgentId=null,this.noUrlSync=!0,this.chatRunId=null,this.chatQueue=[],this.refreshSessionsAfterChat=new Set,this.eventLogBuffer=[],this.eventLog=[],this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.healthLoading=!1,this.healthResult=null,this.healthError=null,this.debugHealth=null,this.execApprovalQueue=[],this.execApprovalError=null,this.updateAvailable=null,this.gatewayBootstrapDone=!1}createRenderRoot(){return this}beforeGatewayConnectSetup(){}afterGatewayConnected(){}shouldReconnectOnPropChange(){return this.gatewayBootstrapDone}startEmbeddedGatewayConnection(){Sz(this),this.settings={...this.settings,theme:this.theme},this.gatewayBootstrapDone=!1,++this.connectGeneration;let e=this.connectGeneration;yz(this),zW(this).finally(()=>{this.connectGeneration===e&&(this.gatewayBootstrapDone=!0,kW(this))})}stopEmbeddedGatewayConnection(){this.connectGeneration+=1,this.client?.stop(),this.client=null,this.connected=!1,VV(this)}handleEmbeddedGatewayUpdates(e){this.shouldReconnectOnPropChange()&&(e.has(`wsBaseUrl`)||e.has(`httpBaseUrl`)||e.has(`token`))&&(Sz(this),xz(this)&&kW(this)),e.has(`theme`)&&(this.settings={...this.settings,theme:this.theme},yz(this)),e.has(`connected`)&&this.connected&&this.afterGatewayConnected()}connectedCallback(){super.connectedCallback(),this.beforeGatewayConnectSetup(),this.startEmbeddedGatewayConnection()}disconnectedCallback(){super.disconnectedCallback(),this.stopEmbeddedGatewayConnection()}updated(e){super.updated(e),this.handleEmbeddedGatewayUpdates(e)}};O([E({type:String,attribute:`ws-base-url`})],BW.prototype,`wsBaseUrl`,void 0),O([E({type:String,attribute:`http-base-url`})],BW.prototype,`httpBaseUrl`,void 0),O([E({type:String})],BW.prototype,`token`,void 0),O([E({type:String})],BW.prototype,`theme`,void 0),O([D()],BW.prototype,`settings`,void 0),O([D()],BW.prototype,`connected`,void 0),O([D()],BW.prototype,`hello`,void 0),O([D()],BW.prototype,`lastError`,void 0),O([D()],BW.prototype,`lastErrorCode`,void 0),O([D()],BW.prototype,`themeMode`,void 0),O([D()],BW.prototype,`themeResolved`,void 0),O([D()],BW.prototype,`themeOrder`,void 0),O([D()],BW.prototype,`pendingGatewayUrl`,void 0),O([D()],BW.prototype,`systemThemeCleanup`,void 0);var $=class extends BW{constructor(...e){super(...e),this.tenantId=``,this.tenantName=``,this.botId=``,this.operatorId=``,this.operatorName=``,this._sessionKey=`agent:skill-creator`,this.tab=`skills`,this.toolStreamById=new Map,this.toolStreamOrder=[],this.toolStreamSyncTimer=null,this.chatToolMessages=[],this.chatStreamSegments=[],this.applySessionKey=``,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter=``,this.skillsViewMode=`card`,this.personalSkillsPageSizeOptions=[10,20,50,100],this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillsTab=`personal`,this.skillMenuOpenKey=null,this.teamSkillsLoading=!1,this.teamSkillsReport=null,this.teamSkillsError=null,this.teamSkillsSyncBusyKey=null,this.teamSkillsSyncedKeys=[],this.teamSkillsSyncedMap=new Map,this.teamOrganizationId=null,this.teamCurrentTenantId=null,this.teamSkillsPageNum=1,this.teamSkillsPageSize=20,this.teamSkillsTotal=0,this.teamSkillsKeyword=``,this.teamApiToken=null,this.skillBoundBotsDialogKey=null,this.skillBoundBotsLoading=!1,this.skillBoundBotsItems=[],this.skillFilesLists={},this.skillFilesContents={},this.skillFilesDrafts={},this.skillFilesActiveKey=null,this.skillFilesActiveName=null,this.skillFilesActiveDir=null,this.skillFilesLoading=!1,this.skillFilesSaving=!1,this.skillFilesError=null,this.skillFilesFullscreen=!1,this.skillFilesBackConfirm=!1,this.skillFileTreeExpandedByKey={},this.skillFileTreeMenuFolder=null,this.skillFileTreeInlineMode=null,this.skillFileTreeInlineFolder=null,this.skillFileTreeInlineValue=``,this.skillRefComponentsLoading=!1,this.skillRefComponentsMap={},this.componentPickerItems=[],this.componentPickerLoading=!1,this.componentPickerTenantId=null,this.variablePickerItems=[],this.variablePickerLoading=!1,this.skillVersionHistoryByKey={},this.skillVersionHistoryLoading=!1,this.skillVersionPublishDialogKey=null,this.skillVersionPublishBy=``,this.skillVersionPublishNote=``,this.skillVersionPublishBusy=!1,this.skillPlatformPublishDialogKey=null,this.skillPlatformPublishVersion=``,this.skillPlatformPublishBy=``,this.skillPlatformPublishNote=``,this.skillPlatformPublishBusy=!1,this.skillCreateMode=!1,this.skillCreateName=``,this.skillCreateDesc=``,this.skillCreateBusy=!1,this.skillCreateError=null,this.skillAiDialogOpen=!1,this.skillAiFormName=``,this.skillAiFormDesc=``,this.skillAiFormTrigger=``,this.skillAiFormInstruction=``,this.skillAiFormExample=``,this.skillAiInstructionReferences=[],this.skillAiDialogFullscreenField=null,this.skillAiFormError=null,this.skillAiBuilderMode=!1,this.skillAiBuilderSkillKey=null,this.skillAiBuilderSkillId=null,this.skillAiBuilderSkillName=null,this.skillAiBuilderBuilding=!1,this.skillAiBuilderActiveTab=`chat`,this.skillAiBuilderOpenTabs=[],this.skillAiChatMessages=[],this.skillAiChatStream=null,this.skillAiChatSending=!1,this.skillAiChatRunId=null,this.skillAiChatMessage=``,this.skillAiChatReferences=[],this.skillAiReferenceMode=`hidden`,this.skillAiReferenceTargetField=`chat`,this.skillAiReferenceActiveApiId=null,this.skillAiReferenceSelectedIndex=0,this.skillAiReferenceMatchFrom=null,this.skillAiReferenceMatchTo=null,this.skillAiReferenceQuery=``,this.skillAiChatStreamStartedAt=null,this.skillAiToolCalls=[],this.skillAiBuilderExitConfirm=!1,this.skillUploadBusy=!1,this.skillUploadError=null,this.skillUploadOverwriteKey=null,this.skillUploadPendingFile=null,this.skillDeleteConfirmKey=null,this.skillExportBusyKey=null,this.apiDefinitionsItems=[],this.apiDefinitionsPath=null,this.apiDefinitionsLoading=!1,this.apiDefinitionsSaving=!1,this.apiDefinitionsExporting=!1,this.apiDefinitionsImporting=!1,this.apiDefinitionsError=null,this.apiDefinitionsHash=null,this.apiDefinitionsMode=`list`,this.apiDefinitionsEditingId=null,this.apiDefinitionsForm=st(),this.apiDefinitionsType=`platform`,this.apiDefinitionsPage=1,this.apiDefinitionsPageSize=20,this.apiDefinitionsSaveAttempted=!1,this.apiDefinitionsDeleteConfirmItem=null,this.apiDefinitionsSelectedIds=[],this.apiDefinitionsDeleteConfirmItems=null,this.apiDefinitionsToast=null,this.apiDefinitionsToastKind=`error`,this.apiDefinitionsQuery=``,this.keyueLoading=!1,this.keyueLoaded=!1,this.keyueSaving=!1,this.keyueError=null,this.keyueDialogMode=null,this.keyueTenants=[],this.keyueSelectedTenantId=null,this.keyueTenantName=``,this.keyueTenantDescription=``,this.keyueTenantType=0,this.keyueTenantPanel=`skills`,this.keyueBots=[],this.keyueSelectedBotId=null,this.keyueBotName=``,this.keyueBotDescription=``,this.keyueBotPanel=`detail`,this.keyueBotFiles={},this.keyueBotFileDrafts={},this.keyueBotFileActive=`SOUL.md`,this.keyueBotSkillBindings=[],this.keyueBotBindingVersionDrafts={},this.keyuePublishBy=``,this.keyuePublishDescription=``,this.keyuePublishTask=null,this.keyueBotSkills=[],this.keyueSkills=[],this.keyueSkillName=``,this.keyueSkillDescription=``,this.keyueSkillContent=``,this.keyueUploadBusy=!1,this.keyueUploadError=null,this.keyuePhoneInput=``,this.keyueActivePhone=null,this.keyueOperatorId=void 0,this.keyueOperatorName=void 0,this.keyueInitLoading=!1,this.keyueInitError=null,this.keyueInitReady=!1,this.navigateKeyueRoute=()=>{},this.tenantSkillsLoadKey=null,this.tenantSkillsLoadPromise=null}get sessionKey(){return this._sessionKey}set sessionKey(e){}connectedCallback(){super.connectedCallback(),this.syncTenant(),this.loadTenantSkills(),lt(this)}afterGatewayConnected(){Et(this)}updated(e){(e.has(`tenantId`)||e.has(`botId`)||e.has(`wsBaseUrl`)||e.has(`httpBaseUrl`))&&(this.syncTenant(),this.keyueSelectedTenantId&&this.loadTenantSkills()),(e.has(`operatorId`)||e.has(`operatorName`))&&(this.keyueOperatorId=this.operatorId.trim()||void 0,this.keyueOperatorName=this.operatorName.trim()||void 0),super.updated(e)}async loadTenantSkills(){let e=this.keyueSelectedTenantId;if(!e)return;let t=`${bz(this)}::${e}`;return this.tenantSkillsLoadKey===t&&this.tenantSkillsLoadPromise?this.tenantSkillsLoadPromise:(this.tenantSkillsLoadKey=t,this.tenantSkillsLoadPromise=this.loadTenantSkillsForKey(t),this.tenantSkillsLoadPromise)}async loadTenantSkillsForKey(e){this.keyueInitLoading=!0,this.keyueInitError=null,this.keyueInitReady=!1;try{await Le(this),this.keyueInitReady=!0}catch(e){this.keyueInitError=e instanceof Error?e.message:String(e)}finally{this.tenantSkillsLoadKey===e&&(this.tenantSkillsLoadPromise=null),this.keyueInitLoading=!1}}syncTenant(){let e=this.tenantId.trim()||null,t=this.botId.trim()||null;this.keyueSelectedTenantId!==e&&(this.keyueSelectedTenantId=e,this.keyueTenantPanel=`skills`,this.tenantSkillsLoadKey=null),this.keyueSelectedBotId!==t&&(this.keyueSelectedBotId=t)}render(){return this.keyueInitError?w`
3201
3201
  <div class="keyueclaw-skills-scope" style="height:100%;display:grid;place-items:center;color:var(--keyueclaw-danger,#e55);font-size:14px;padding:24px;text-align:center;">
3202
3202
  ${this.keyueInitError}
3203
3203
  </div>
@@ -3219,5 +3219,5 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
3219
3219
  @click=${()=>{this.apiDefinitionsToast=null}}>✕</button>
3220
3220
  </div>
3221
3221
  </div>
3222
- `}};O([E({type:String,attribute:`tenant-id`})],$.prototype,`tenantId`,void 0),O([E({type:String,attribute:`tenant-name`})],$.prototype,`tenantName`,void 0),O([E({type:String,attribute:`bot-id`})],$.prototype,`botId`,void 0),O([E({type:String,attribute:`operator-id`})],$.prototype,`operatorId`,void 0),O([E({type:String,attribute:`operator-name`})],$.prototype,`operatorName`,void 0),O([D()],$.prototype,`skillsLoading`,void 0),O([D()],$.prototype,`skillsReport`,void 0),O([D()],$.prototype,`skillsError`,void 0),O([D()],$.prototype,`skillsFilter`,void 0),O([D()],$.prototype,`skillsViewMode`,void 0),O([D()],$.prototype,`personalSkillsPageSizeOptions`,void 0),O([D()],$.prototype,`skillEdits`,void 0),O([D()],$.prototype,`skillsBusyKey`,void 0),O([D()],$.prototype,`skillMessages`,void 0),O([D()],$.prototype,`skillsTab`,void 0),O([D()],$.prototype,`skillMenuOpenKey`,void 0),O([D()],$.prototype,`teamSkillsLoading`,void 0),O([D()],$.prototype,`teamSkillsReport`,void 0),O([D()],$.prototype,`teamSkillsError`,void 0),O([D()],$.prototype,`teamSkillsSyncBusyKey`,void 0),O([D()],$.prototype,`teamSkillsSyncedKeys`,void 0),O([D()],$.prototype,`teamSkillsSyncedMap`,void 0),O([D()],$.prototype,`teamOrganizationId`,void 0),O([D()],$.prototype,`teamCurrentTenantId`,void 0),O([D()],$.prototype,`teamSkillsPageNum`,void 0),O([D()],$.prototype,`teamSkillsPageSize`,void 0),O([D()],$.prototype,`teamSkillsTotal`,void 0),O([D()],$.prototype,`teamSkillsKeyword`,void 0),O([D()],$.prototype,`teamApiToken`,void 0),O([D()],$.prototype,`skillBoundBotsDialogKey`,void 0),O([D()],$.prototype,`skillBoundBotsLoading`,void 0),O([D()],$.prototype,`skillBoundBotsItems`,void 0),O([D()],$.prototype,`skillFilesLists`,void 0),O([D()],$.prototype,`skillFilesContents`,void 0),O([D()],$.prototype,`skillFilesDrafts`,void 0),O([D()],$.prototype,`skillFilesActiveKey`,void 0),O([D()],$.prototype,`skillFilesActiveName`,void 0),O([D()],$.prototype,`skillFilesActiveDir`,void 0),O([D()],$.prototype,`skillFilesLoading`,void 0),O([D()],$.prototype,`skillFilesSaving`,void 0),O([D()],$.prototype,`skillFilesError`,void 0),O([D()],$.prototype,`skillFilesFullscreen`,void 0),O([D()],$.prototype,`skillFilesBackConfirm`,void 0),O([D()],$.prototype,`skillFileTreeExpandedByKey`,void 0),O([D()],$.prototype,`skillFileTreeMenuFolder`,void 0),O([D()],$.prototype,`skillFileTreeInlineMode`,void 0),O([D()],$.prototype,`skillFileTreeInlineFolder`,void 0),O([D()],$.prototype,`skillFileTreeInlineValue`,void 0),O([D()],$.prototype,`skillRefComponentsLoading`,void 0),O([D()],$.prototype,`skillRefComponentsMap`,void 0),O([D()],$.prototype,`componentPickerItems`,void 0),O([D()],$.prototype,`componentPickerLoading`,void 0),O([D()],$.prototype,`componentPickerTenantId`,void 0),O([D()],$.prototype,`skillVersionHistoryByKey`,void 0),O([D()],$.prototype,`skillVersionHistoryLoading`,void 0),O([D()],$.prototype,`skillVersionPublishDialogKey`,void 0),O([D()],$.prototype,`skillVersionPublishBy`,void 0),O([D()],$.prototype,`skillVersionPublishNote`,void 0),O([D()],$.prototype,`skillVersionPublishBusy`,void 0),O([D()],$.prototype,`skillPlatformPublishDialogKey`,void 0),O([D()],$.prototype,`skillPlatformPublishVersion`,void 0),O([D()],$.prototype,`skillPlatformPublishBy`,void 0),O([D()],$.prototype,`skillPlatformPublishNote`,void 0),O([D()],$.prototype,`skillPlatformPublishBusy`,void 0),O([D()],$.prototype,`skillCreateMode`,void 0),O([D()],$.prototype,`skillCreateName`,void 0),O([D()],$.prototype,`skillCreateDesc`,void 0),O([D()],$.prototype,`skillCreateBusy`,void 0),O([D()],$.prototype,`skillCreateError`,void 0),O([D()],$.prototype,`skillAiDialogOpen`,void 0),O([D()],$.prototype,`skillAiFormName`,void 0),O([D()],$.prototype,`skillAiFormDesc`,void 0),O([D()],$.prototype,`skillAiFormTrigger`,void 0),O([D()],$.prototype,`skillAiFormInstruction`,void 0),O([D()],$.prototype,`skillAiFormExample`,void 0),O([D()],$.prototype,`skillAiInstructionReferences`,void 0),O([D()],$.prototype,`skillAiDialogFullscreenField`,void 0),O([D()],$.prototype,`skillAiFormError`,void 0),O([D()],$.prototype,`skillAiBuilderMode`,void 0),O([D()],$.prototype,`skillAiBuilderSkillKey`,void 0),O([D()],$.prototype,`skillAiBuilderSkillId`,void 0),O([D()],$.prototype,`skillAiBuilderSkillName`,void 0),O([D()],$.prototype,`skillAiBuilderBuilding`,void 0),O([D()],$.prototype,`skillAiBuilderActiveTab`,void 0),O([D()],$.prototype,`skillAiBuilderOpenTabs`,void 0),O([D()],$.prototype,`skillAiChatMessages`,void 0),O([D()],$.prototype,`skillAiChatStream`,void 0),O([D()],$.prototype,`skillAiChatSending`,void 0),O([D()],$.prototype,`skillAiChatMessage`,void 0),O([D()],$.prototype,`skillAiChatReferences`,void 0),O([D()],$.prototype,`skillAiReferenceMode`,void 0),O([D()],$.prototype,`skillAiReferenceTargetField`,void 0),O([D()],$.prototype,`skillAiReferenceActiveApiId`,void 0),O([D()],$.prototype,`skillAiReferenceSelectedIndex`,void 0),O([D()],$.prototype,`skillAiReferenceMatchFrom`,void 0),O([D()],$.prototype,`skillAiReferenceMatchTo`,void 0),O([D()],$.prototype,`skillAiReferenceQuery`,void 0),O([D()],$.prototype,`skillAiToolCalls`,void 0),O([D()],$.prototype,`skillAiBuilderExitConfirm`,void 0),O([D()],$.prototype,`skillUploadBusy`,void 0),O([D()],$.prototype,`skillUploadError`,void 0),O([D()],$.prototype,`skillUploadOverwriteKey`,void 0),O([D()],$.prototype,`skillUploadPendingFile`,void 0),O([D()],$.prototype,`skillDeleteConfirmKey`,void 0),O([D()],$.prototype,`skillExportBusyKey`,void 0),O([D()],$.prototype,`apiDefinitionsItems`,void 0),O([D()],$.prototype,`apiDefinitionsPath`,void 0),O([D()],$.prototype,`apiDefinitionsLoading`,void 0),O([D()],$.prototype,`apiDefinitionsSaving`,void 0),O([D()],$.prototype,`apiDefinitionsExporting`,void 0),O([D()],$.prototype,`apiDefinitionsImporting`,void 0),O([D()],$.prototype,`apiDefinitionsError`,void 0),O([D()],$.prototype,`apiDefinitionsHash`,void 0),O([D()],$.prototype,`apiDefinitionsMode`,void 0),O([D()],$.prototype,`apiDefinitionsEditingId`,void 0),O([D()],$.prototype,`apiDefinitionsForm`,void 0),O([D()],$.prototype,`apiDefinitionsType`,void 0),O([D()],$.prototype,`apiDefinitionsPage`,void 0),O([D()],$.prototype,`apiDefinitionsPageSize`,void 0),O([D()],$.prototype,`apiDefinitionsSaveAttempted`,void 0),O([D()],$.prototype,`apiDefinitionsDeleteConfirmItem`,void 0),O([D()],$.prototype,`apiDefinitionsSelectedIds`,void 0),O([D()],$.prototype,`apiDefinitionsDeleteConfirmItems`,void 0),O([D()],$.prototype,`apiDefinitionsToast`,void 0),O([D()],$.prototype,`apiDefinitionsToastKind`,void 0),O([D()],$.prototype,`keyueLoading`,void 0),O([D()],$.prototype,`keyueLoaded`,void 0),O([D()],$.prototype,`keyueSaving`,void 0),O([D()],$.prototype,`keyueError`,void 0),O([D()],$.prototype,`keyueDialogMode`,void 0),O([D()],$.prototype,`keyueTenants`,void 0),O([D()],$.prototype,`keyueSelectedTenantId`,void 0),O([D()],$.prototype,`keyueTenantName`,void 0),O([D()],$.prototype,`keyueTenantDescription`,void 0),O([D()],$.prototype,`keyueTenantType`,void 0),O([D()],$.prototype,`keyueTenantPanel`,void 0),O([D()],$.prototype,`keyueBots`,void 0),O([D()],$.prototype,`keyueSelectedBotId`,void 0),O([D()],$.prototype,`keyueBotName`,void 0),O([D()],$.prototype,`keyueBotDescription`,void 0),O([D()],$.prototype,`keyueBotPanel`,void 0),O([D()],$.prototype,`keyueBotFiles`,void 0),O([D()],$.prototype,`keyueBotFileDrafts`,void 0),O([D()],$.prototype,`keyueBotFileActive`,void 0),O([D()],$.prototype,`keyueBotSkillBindings`,void 0),O([D()],$.prototype,`keyueBotBindingVersionDrafts`,void 0),O([D()],$.prototype,`keyuePublishBy`,void 0),O([D()],$.prototype,`keyuePublishDescription`,void 0),O([D()],$.prototype,`keyuePublishTask`,void 0),O([D()],$.prototype,`keyueBotSkills`,void 0),O([D()],$.prototype,`keyueSkills`,void 0),O([D()],$.prototype,`keyueSkillName`,void 0),O([D()],$.prototype,`keyueSkillDescription`,void 0),O([D()],$.prototype,`keyueSkillContent`,void 0),O([D()],$.prototype,`keyueUploadBusy`,void 0),O([D()],$.prototype,`keyueUploadError`,void 0),O([D()],$.prototype,`keyuePhoneInput`,void 0),O([D()],$.prototype,`keyueActivePhone`,void 0),O([D()],$.prototype,`keyueOperatorId`,void 0),O([D()],$.prototype,`keyueOperatorName`,void 0),O([D()],$.prototype,`keyueInitLoading`,void 0),O([D()],$.prototype,`keyueInitError`,void 0),O([D()],$.prototype,`keyueInitReady`,void 0),$=O([Ai(`keyueclaw-skills`)],$),Object.defineProperty(e,`KeyueClawSkillsElement`,{enumerable:!0,get:function(){return $}})});
3222
+ `}};O([E({type:String,attribute:`tenant-id`})],$.prototype,`tenantId`,void 0),O([E({type:String,attribute:`tenant-name`})],$.prototype,`tenantName`,void 0),O([E({type:String,attribute:`bot-id`})],$.prototype,`botId`,void 0),O([E({type:String,attribute:`operator-id`})],$.prototype,`operatorId`,void 0),O([E({type:String,attribute:`operator-name`})],$.prototype,`operatorName`,void 0),O([D()],$.prototype,`skillsLoading`,void 0),O([D()],$.prototype,`skillsReport`,void 0),O([D()],$.prototype,`skillsError`,void 0),O([D()],$.prototype,`skillsFilter`,void 0),O([D()],$.prototype,`skillsViewMode`,void 0),O([D()],$.prototype,`personalSkillsPageSizeOptions`,void 0),O([D()],$.prototype,`skillEdits`,void 0),O([D()],$.prototype,`skillsBusyKey`,void 0),O([D()],$.prototype,`skillMessages`,void 0),O([D()],$.prototype,`skillsTab`,void 0),O([D()],$.prototype,`skillMenuOpenKey`,void 0),O([D()],$.prototype,`teamSkillsLoading`,void 0),O([D()],$.prototype,`teamSkillsReport`,void 0),O([D()],$.prototype,`teamSkillsError`,void 0),O([D()],$.prototype,`teamSkillsSyncBusyKey`,void 0),O([D()],$.prototype,`teamSkillsSyncedKeys`,void 0),O([D()],$.prototype,`teamSkillsSyncedMap`,void 0),O([D()],$.prototype,`teamOrganizationId`,void 0),O([D()],$.prototype,`teamCurrentTenantId`,void 0),O([D()],$.prototype,`teamSkillsPageNum`,void 0),O([D()],$.prototype,`teamSkillsPageSize`,void 0),O([D()],$.prototype,`teamSkillsTotal`,void 0),O([D()],$.prototype,`teamSkillsKeyword`,void 0),O([D()],$.prototype,`teamApiToken`,void 0),O([D()],$.prototype,`skillBoundBotsDialogKey`,void 0),O([D()],$.prototype,`skillBoundBotsLoading`,void 0),O([D()],$.prototype,`skillBoundBotsItems`,void 0),O([D()],$.prototype,`skillFilesLists`,void 0),O([D()],$.prototype,`skillFilesContents`,void 0),O([D()],$.prototype,`skillFilesDrafts`,void 0),O([D()],$.prototype,`skillFilesActiveKey`,void 0),O([D()],$.prototype,`skillFilesActiveName`,void 0),O([D()],$.prototype,`skillFilesActiveDir`,void 0),O([D()],$.prototype,`skillFilesLoading`,void 0),O([D()],$.prototype,`skillFilesSaving`,void 0),O([D()],$.prototype,`skillFilesError`,void 0),O([D()],$.prototype,`skillFilesFullscreen`,void 0),O([D()],$.prototype,`skillFilesBackConfirm`,void 0),O([D()],$.prototype,`skillFileTreeExpandedByKey`,void 0),O([D()],$.prototype,`skillFileTreeMenuFolder`,void 0),O([D()],$.prototype,`skillFileTreeInlineMode`,void 0),O([D()],$.prototype,`skillFileTreeInlineFolder`,void 0),O([D()],$.prototype,`skillFileTreeInlineValue`,void 0),O([D()],$.prototype,`skillRefComponentsLoading`,void 0),O([D()],$.prototype,`skillRefComponentsMap`,void 0),O([D()],$.prototype,`componentPickerItems`,void 0),O([D()],$.prototype,`componentPickerLoading`,void 0),O([D()],$.prototype,`componentPickerTenantId`,void 0),O([D()],$.prototype,`variablePickerItems`,void 0),O([D()],$.prototype,`variablePickerLoading`,void 0),O([D()],$.prototype,`skillVersionHistoryByKey`,void 0),O([D()],$.prototype,`skillVersionHistoryLoading`,void 0),O([D()],$.prototype,`skillVersionPublishDialogKey`,void 0),O([D()],$.prototype,`skillVersionPublishBy`,void 0),O([D()],$.prototype,`skillVersionPublishNote`,void 0),O([D()],$.prototype,`skillVersionPublishBusy`,void 0),O([D()],$.prototype,`skillPlatformPublishDialogKey`,void 0),O([D()],$.prototype,`skillPlatformPublishVersion`,void 0),O([D()],$.prototype,`skillPlatformPublishBy`,void 0),O([D()],$.prototype,`skillPlatformPublishNote`,void 0),O([D()],$.prototype,`skillPlatformPublishBusy`,void 0),O([D()],$.prototype,`skillCreateMode`,void 0),O([D()],$.prototype,`skillCreateName`,void 0),O([D()],$.prototype,`skillCreateDesc`,void 0),O([D()],$.prototype,`skillCreateBusy`,void 0),O([D()],$.prototype,`skillCreateError`,void 0),O([D()],$.prototype,`skillAiDialogOpen`,void 0),O([D()],$.prototype,`skillAiFormName`,void 0),O([D()],$.prototype,`skillAiFormDesc`,void 0),O([D()],$.prototype,`skillAiFormTrigger`,void 0),O([D()],$.prototype,`skillAiFormInstruction`,void 0),O([D()],$.prototype,`skillAiFormExample`,void 0),O([D()],$.prototype,`skillAiInstructionReferences`,void 0),O([D()],$.prototype,`skillAiDialogFullscreenField`,void 0),O([D()],$.prototype,`skillAiFormError`,void 0),O([D()],$.prototype,`skillAiBuilderMode`,void 0),O([D()],$.prototype,`skillAiBuilderSkillKey`,void 0),O([D()],$.prototype,`skillAiBuilderSkillId`,void 0),O([D()],$.prototype,`skillAiBuilderSkillName`,void 0),O([D()],$.prototype,`skillAiBuilderBuilding`,void 0),O([D()],$.prototype,`skillAiBuilderActiveTab`,void 0),O([D()],$.prototype,`skillAiBuilderOpenTabs`,void 0),O([D()],$.prototype,`skillAiChatMessages`,void 0),O([D()],$.prototype,`skillAiChatStream`,void 0),O([D()],$.prototype,`skillAiChatSending`,void 0),O([D()],$.prototype,`skillAiChatMessage`,void 0),O([D()],$.prototype,`skillAiChatReferences`,void 0),O([D()],$.prototype,`skillAiReferenceMode`,void 0),O([D()],$.prototype,`skillAiReferenceTargetField`,void 0),O([D()],$.prototype,`skillAiReferenceActiveApiId`,void 0),O([D()],$.prototype,`skillAiReferenceSelectedIndex`,void 0),O([D()],$.prototype,`skillAiReferenceMatchFrom`,void 0),O([D()],$.prototype,`skillAiReferenceMatchTo`,void 0),O([D()],$.prototype,`skillAiReferenceQuery`,void 0),O([D()],$.prototype,`skillAiToolCalls`,void 0),O([D()],$.prototype,`skillAiBuilderExitConfirm`,void 0),O([D()],$.prototype,`skillUploadBusy`,void 0),O([D()],$.prototype,`skillUploadError`,void 0),O([D()],$.prototype,`skillUploadOverwriteKey`,void 0),O([D()],$.prototype,`skillUploadPendingFile`,void 0),O([D()],$.prototype,`skillDeleteConfirmKey`,void 0),O([D()],$.prototype,`skillExportBusyKey`,void 0),O([D()],$.prototype,`apiDefinitionsItems`,void 0),O([D()],$.prototype,`apiDefinitionsPath`,void 0),O([D()],$.prototype,`apiDefinitionsLoading`,void 0),O([D()],$.prototype,`apiDefinitionsSaving`,void 0),O([D()],$.prototype,`apiDefinitionsExporting`,void 0),O([D()],$.prototype,`apiDefinitionsImporting`,void 0),O([D()],$.prototype,`apiDefinitionsError`,void 0),O([D()],$.prototype,`apiDefinitionsHash`,void 0),O([D()],$.prototype,`apiDefinitionsMode`,void 0),O([D()],$.prototype,`apiDefinitionsEditingId`,void 0),O([D()],$.prototype,`apiDefinitionsForm`,void 0),O([D()],$.prototype,`apiDefinitionsType`,void 0),O([D()],$.prototype,`apiDefinitionsPage`,void 0),O([D()],$.prototype,`apiDefinitionsPageSize`,void 0),O([D()],$.prototype,`apiDefinitionsSaveAttempted`,void 0),O([D()],$.prototype,`apiDefinitionsDeleteConfirmItem`,void 0),O([D()],$.prototype,`apiDefinitionsSelectedIds`,void 0),O([D()],$.prototype,`apiDefinitionsDeleteConfirmItems`,void 0),O([D()],$.prototype,`apiDefinitionsToast`,void 0),O([D()],$.prototype,`apiDefinitionsToastKind`,void 0),O([D()],$.prototype,`keyueLoading`,void 0),O([D()],$.prototype,`keyueLoaded`,void 0),O([D()],$.prototype,`keyueSaving`,void 0),O([D()],$.prototype,`keyueError`,void 0),O([D()],$.prototype,`keyueDialogMode`,void 0),O([D()],$.prototype,`keyueTenants`,void 0),O([D()],$.prototype,`keyueSelectedTenantId`,void 0),O([D()],$.prototype,`keyueTenantName`,void 0),O([D()],$.prototype,`keyueTenantDescription`,void 0),O([D()],$.prototype,`keyueTenantType`,void 0),O([D()],$.prototype,`keyueTenantPanel`,void 0),O([D()],$.prototype,`keyueBots`,void 0),O([D()],$.prototype,`keyueSelectedBotId`,void 0),O([D()],$.prototype,`keyueBotName`,void 0),O([D()],$.prototype,`keyueBotDescription`,void 0),O([D()],$.prototype,`keyueBotPanel`,void 0),O([D()],$.prototype,`keyueBotFiles`,void 0),O([D()],$.prototype,`keyueBotFileDrafts`,void 0),O([D()],$.prototype,`keyueBotFileActive`,void 0),O([D()],$.prototype,`keyueBotSkillBindings`,void 0),O([D()],$.prototype,`keyueBotBindingVersionDrafts`,void 0),O([D()],$.prototype,`keyuePublishBy`,void 0),O([D()],$.prototype,`keyuePublishDescription`,void 0),O([D()],$.prototype,`keyuePublishTask`,void 0),O([D()],$.prototype,`keyueBotSkills`,void 0),O([D()],$.prototype,`keyueSkills`,void 0),O([D()],$.prototype,`keyueSkillName`,void 0),O([D()],$.prototype,`keyueSkillDescription`,void 0),O([D()],$.prototype,`keyueSkillContent`,void 0),O([D()],$.prototype,`keyueUploadBusy`,void 0),O([D()],$.prototype,`keyueUploadError`,void 0),O([D()],$.prototype,`keyuePhoneInput`,void 0),O([D()],$.prototype,`keyueActivePhone`,void 0),O([D()],$.prototype,`keyueOperatorId`,void 0),O([D()],$.prototype,`keyueOperatorName`,void 0),O([D()],$.prototype,`keyueInitLoading`,void 0),O([D()],$.prototype,`keyueInitError`,void 0),O([D()],$.prototype,`keyueInitReady`,void 0),$=O([Ai(`keyueclaw-skills`)],$),Object.defineProperty(e,`KeyueClawSkillsElement`,{enumerable:!0,get:function(){return $}})});
3223
3223
  //# sourceMappingURL=skills.umd.cjs.map