@futurx/openclaw-operator-ui 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ http://localhost:18789/operator
|
|
|
58
58
|
|
|
59
59
|
### Client ID
|
|
60
60
|
|
|
61
|
-
This plugin connects to the Gateway using `
|
|
61
|
+
This plugin connects to the Gateway using `webchat-ui` as its client ID for maximum compatibility — it works on any OpenClaw instance without requiring device identity or secure context. A dedicated `openclaw-operator-ui` ID has been proposed upstream ([PR #29359](https://github.com/openclaw/openclaw/pull/29359)) and will be adopted in a future release once merged.
|
|
62
62
|
|
|
63
63
|
## Development
|
|
64
64
|
|
|
@@ -292,4 +292,4 @@ Please change the parent <Route path="${H}"> to <Route path="${H==="/"?"*":`${H}
|
|
|
292
292
|
*
|
|
293
293
|
* This source code is licensed under the ISC license.
|
|
294
294
|
* See the LICENSE file in the root directory of this source tree.
|
|
295
|
-
*/const tv=le("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);let lv=0;function Yh(){return`op-${++lv}-${Date.now().toString(36)}`}const av="openclaw-control-ui";class nv{constructor(f,o){Dt(this,"ws",null);Dt(this,"pending",new Map);Dt(this,"eventHandlers",new Map);Dt(this,"closed",!1);Dt(this,"connectSent",!1);Dt(this,"connectTimer",null);Dt(this,"_connected",!1);Dt(this,"_snapshot",null);Dt(this,"reconnectTimer",null);Dt(this,"onConnectedChange");Dt(this,"onConnectError");this.url=f,this.password=o}get connected(){return this._connected}get snapshot(){return this._snapshot}setCallbacks(f){this.onConnectedChange=f.onConnectedChange,this.onConnectError=f.onConnectError}start(){this.closed=!1,this.doConnect()}stop(){var f;this.closed=!0,this._connected=!1,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null),(f=this.ws)==null||f.close(),this.ws=null;for(const[,o]of this.pending)o.reject(new Error("client stopped"));this.pending.clear()}on(f,o){let r=this.eventHandlers.get(f);return r||(r=new Set,this.eventHandlers.set(f,r)),r.add(o),()=>r.delete(o)}async request(f,o){if(!this.ws||this.ws.readyState!==WebSocket.OPEN||!this._connected)throw new Error("gateway not connected");const r=Yh(),h={type:"req",id:r,method:f,params:o};return new Promise((m,g)=>{this.pending.set(r,{resolve:x=>m(x),reject:g}),this.ws.send(JSON.stringify(h))})}doConnect(){if(this.closed)return;const f=new WebSocket(this.url);this.ws=f,this.connectSent=!1,f.addEventListener("open",()=>{this.ws===f&&this.scheduleConnect()}),f.addEventListener("message",o=>{this.ws===f&&this.handleMessage(String(o.data??""))}),f.addEventListener("close",o=>{var h;if(this.ws!==f)return;this.ws=null;const r=this._connected;this._connected=!1,r&&((h=this.onConnectedChange)==null||h.call(this,!1));for(const[,m]of this.pending)m.reject(new Error(`closed: ${o.code}`));this.pending.clear(),this.closed||(this.reconnectTimer=window.setTimeout(()=>this.doConnect(),2e3))}),f.addEventListener("error",()=>{})}scheduleConnect(){this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},100)}async sendConnect(){var o,r,h;if(this.connectSent||!this.ws||this.ws.readyState!==WebSocket.OPEN)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const f={minProtocol:3,maxProtocol:3,client:{id:av,version:"0.1.0",platform:navigator.platform??"web",mode:"ui"},role:"operator",scopes:["operator.admin","operator.approvals","operator.pairing"],caps:[],auth:{password:this.password},userAgent:navigator.userAgent,locale:navigator.language};try{const m=await this.request_internal("connect",f);this._connected=!0,this._snapshot=(m==null?void 0:m.snapshot)??null,(o=this.onConnectedChange)==null||o.call(this,!0)}catch(m){const g=m instanceof Error?m.message:"connect failed";(r=this.onConnectError)==null||r.call(this,g),(h=this.ws)==null||h.close(4008,"connect failed")}}async request_internal(f,o){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("gateway not connected");const r=Yh(),h={type:"req",id:r,method:f,params:o};return new Promise((m,g)=>{this.pending.set(r,{resolve:x=>m(x),reject:g}),this.ws.send(JSON.stringify(h))})}handleMessage(f){var h;let o;try{o=JSON.parse(f)}catch{return}const r=o;if(r.type==="event"){const m=o;if(m.event==="connect.challenge"){const v=m.payload;v!=null&&v.nonce&&(this.connectSent=!1,this.sendConnect());return}const g=this.eventHandlers.get(m.event);if(g)for(const v of g)try{v(m.payload)}catch{}const x=this.eventHandlers.get("*");if(x)for(const v of x)try{v(m)}catch{}return}if(r.type==="res"){const m=o,g=this.pending.get(m.id);if(!g)return;this.pending.delete(m.id),m.ok?g.resolve(m.payload):g.reject(new Error(((h=m.error)==null?void 0:h.message)??"request failed"))}}}const mm=S.createContext({authenticated:!1,connected:!1,connecting:!1,error:null,gateway:null,login:()=>{},logout:()=>{}});function Be(){return S.useContext(mm)}function uv(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}`}const mi="operator-ui-auth";function iv({children:i}){const[f,o]=S.useState(!1),[r,h]=S.useState(!1),[m,g]=S.useState(!1),[x,v]=S.useState(null),y=S.useRef(null),j=S.useRef(null);S.useEffect(()=>{const R=sessionStorage.getItem(mi);return R&&b(R),()=>{var z;(z=y.current)==null||z.stop()}},[]);const b=S.useCallback(R=>{var B;(B=y.current)==null||B.stop(),g(!0),v(null),j.current=R;const z=new nv(uv(),R);y.current=z,z.setCallbacks({onConnectedChange:Y=>{g(!1),h(Y),Y&&(o(!0),v(null),sessionStorage.setItem(mi,R))},onConnectError:Y=>{g(!1),h(!1),(Y.includes("unauthorized")||Y.includes("password"))&&(o(!1),sessionStorage.removeItem(mi)),v(Y)}}),z.start()},[]),T=S.useCallback(()=>{var R;(R=y.current)==null||R.stop(),y.current=null,j.current=null,o(!1),h(!1),v(null),sessionStorage.removeItem(mi)},[]);return s.jsx(mm.Provider,{value:{authenticated:f,connected:r,connecting:m,error:x,gateway:y.current,login:b,logout:T},children:i})}function ym(i){var f,o,r="";if(typeof i=="string"||typeof i=="number")r+=i;else if(typeof i=="object")if(Array.isArray(i)){var h=i.length;for(f=0;f<h;f++)i[f]&&(o=ym(i[f]))&&(r&&(r+=" "),r+=o)}else for(o in i)i[o]&&(r&&(r+=" "),r+=o);return r}function wt(){for(var i,f,o=0,r="",h=arguments.length;o<h;o++)(i=arguments[o])&&(f=ym(i))&&(r&&(r+=" "),r+=f);return r}const sv=[{to:"/",icon:Q1,label:"Dashboard",end:!0},{to:"/agents",icon:ua,label:"Agents"},{to:"/channels",icon:ia,label:"Channels"},{to:"/groups",icon:Ti,label:"Groups"},{to:"/skills",icon:Ai,label:"Skills"},{to:"/sessions",icon:Ei,label:"Sessions"},{to:"/cron",icon:nr,label:"Cron"},{to:"/settings",icon:hr,label:"Settings"}];function cv(){return s.jsxs("aside",{className:"flex w-60 shrink-0 flex-col border-r border-surface-200 bg-white",children:[s.jsxs("div",{className:"flex h-14 items-center gap-2.5 border-b border-surface-200 px-5",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary-600",children:s.jsx("span",{className:"text-sm font-bold text-white",children:"O"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-semibold text-surface-900",children:"Operator"}),s.jsx("p",{className:"text-[10px] font-medium text-surface-400",children:"OpenClaw"})]})]}),s.jsx("nav",{className:"flex-1 space-y-0.5 p-3",children:sv.map(({to:i,icon:f,label:o,...r})=>s.jsxs(nm,{to:i,end:"end"in r,className:({isActive:h})=>wt("flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors",h?"bg-primary-50 text-primary-700":"text-surface-600 hover:bg-surface-50 hover:text-surface-900"),children:[s.jsx(f,{className:"h-4 w-4"}),o]},i))}),s.jsx("div",{className:"border-t border-surface-200 p-3",children:s.jsx("p",{className:"px-3 text-[10px] text-surface-400",children:"v0.1.0 · OpenClaw Operator"})})]})}function rv(){const{logout:i,connected:f}=Be();return s.jsxs("div",{className:"flex h-screen overflow-hidden bg-surface-50",children:[s.jsx(cv,{}),s.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[s.jsxs("header",{className:"flex h-14 shrink-0 items-center justify-end gap-3 border-b border-surface-200 bg-white px-6",children:[s.jsx("div",{className:"flex items-center gap-2 text-xs",children:f?s.jsxs("span",{className:"badge-green",children:[s.jsx(hm,{className:"mr-1 h-3 w-3"}),"Connected"]}):s.jsxs("span",{className:"badge-red",children:[s.jsx(dm,{className:"mr-1 h-3 w-3"}),"Reconnecting…"]})}),s.jsx("button",{onClick:i,className:"btn-ghost !px-2 !py-1.5 text-surface-500 hover:text-surface-700",children:s.jsx(rm,{className:"h-4 w-4"})})]}),s.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:s.jsx(Ig,{})})]})]})}function hl({title:i,description:f,actions:o}){return s.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold text-surface-900",children:i}),f&&s.jsx("p",{className:"mt-1 text-sm text-surface-500",children:f})]}),o&&s.jsx("div",{className:"flex items-center gap-2",children:o})]})}function fv(){const{gateway:i}=Be(),f=Si(),[o,r]=S.useState(!1),[h,m]=S.useState(null),[g,x]=S.useState({name:"",identity:"",emoji:""});function v(j,b){x(T=>({...T,[j]:b}))}async function y(j){if(j.preventDefault(),!!i){if(!g.name.trim()){m("Agent name is required");return}r(!0),m(null);try{const b=await i.request("agents.create",{name:g.name.trim(),workspace:g.name.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),emoji:g.emoji.trim()||void 0}),T=b==null?void 0:b.agentId;T&&g.identity.trim()&&await i.request("agents.files.set",{agentId:T,name:"AGENTS.md",content:g.identity.trim()}),f(`/agents/${T??""}`)}catch(b){m(b instanceof Error?b.message:"Failed to create agent"),r(!1)}}}return s.jsxs("div",{className:"mx-auto max-w-2xl",children:[s.jsx(hl,{title:"Create Agent",description:"Set up a new AI agent"}),s.jsxs("form",{onSubmit:y,className:"card space-y-5",children:[s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Agent Name *"}),s.jsx("input",{className:"input",placeholder:"e.g. Support Assistant",value:g.name,onChange:j=>v("name",j.target.value)}),s.jsx("p",{className:"mt-1 text-xs text-surface-400",children:"The display name for this agent"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Emoji"}),s.jsx("input",{className:"input",placeholder:"e.g. 🤖",value:g.emoji,onChange:j=>v("emoji",j.target.value)}),s.jsx("p",{className:"mt-1 text-xs text-surface-400",children:"Optional icon for the agent"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Identity / System Prompt"}),s.jsx("textarea",{className:"input min-h-[120px] resize-y",placeholder:"Describe the agent's personality, role, and behavior...",value:g.identity,onChange:j=>v("identity",j.target.value)}),s.jsx("p",{className:"mt-1 text-xs text-surface-400",children:"This will be saved as the agent's AGENTS.md file"})]}),h&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-red-50 p-3 text-sm text-red-700",children:[s.jsx(Ni,{className:"mt-0.5 h-4 w-4 shrink-0"}),s.jsx("span",{children:h})]}),s.jsxs("div",{className:"flex justify-end gap-3 border-t border-surface-100 pt-5",children:[s.jsx("button",{type:"button",onClick:()=>f("/agents"),className:"btn-secondary",children:"Cancel"}),s.jsxs("button",{type:"submit",disabled:o,className:"btn-primary",children:[o?s.jsx(Yt,{className:"h-4 w-4 animate-spin"}):null,"Create Agent"]})]})]})]})}function lt({className:i}){return s.jsx("div",{className:wt("flex items-center justify-center py-12",i),children:s.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-surface-200 border-t-primary-600"})})}const gm=["settings","channels","groups","tools","skills","sessions","usage","chat"],ov={settings:{label:"Settings",icon:hr},channels:{label:"Channels",icon:ia},groups:{label:"Groups",icon:Ti},tools:{label:"Tools",icon:tv},skills:{label:"Skills",icon:Ai},sessions:{label:"Sessions",icon:Ei},usage:{label:"Usage",icon:sm},chat:{label:"Test Chat",icon:V1}},Ll=[{name:"IDENTITY.md",label:"Identity",description:"Agent name, style, emoji and persona basics",core:!0},{name:"SOUL.md",label:"Soul / Personality",description:"Character boundaries, tone, voice and behavioral rules",core:!0},{name:"AGENTS.md",label:"Instructions",description:"Operating instructions, memory usage guidelines and core directives",core:!0},{name:"TOOLS.md",label:"Tool Guidelines",description:"Custom tool usage conventions and constraints"},{name:"USER.md",label:"User Profile",description:"User preferences, preferred name and context"},{name:"MEMORY.md",label:"Long-term Memory",description:"Curated persistent memory across sessions"},{name:"HEARTBEAT.md",label:"Heartbeat Checklist",description:"Optional checklist for periodic heartbeat runs"},{name:"BOOTSTRAP.md",label:"Bootstrap (One-time)",description:"First-run ceremony script, deleted after initial setup"}];function dv({agentId:i,meta:f,initialContent:o,initialMissing:r}){const{gateway:h}=Be(),[m,g]=S.useState(o),[x,v]=S.useState(!1),[y,j]=S.useState("idle"),[b,T]=S.useState(!1);async function R(){if(h){v(!0),j("idle");try{await h.request("agents.files.set",{agentId:i,name:f.name,content:m}),j("saved"),T(!1),setTimeout(()=>j("idle"),2500)}catch{j("error")}v(!1)}}return s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"mb-3 flex items-center justify-between",children:s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-surface-900",children:f.label}),s.jsx("code",{className:"rounded bg-surface-100 px-1.5 py-0.5 text-[10px] font-mono text-surface-500",children:f.name}),r&&!b&&s.jsx("span",{className:"rounded bg-surface-100 px-1.5 py-0.5 text-[10px] text-surface-400",children:"Not created"}),b&&s.jsx("span",{className:"rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-600",children:"Unsaved"})]}),s.jsx("p",{className:"mt-0.5 text-xs text-surface-400",children:f.description})]})}),s.jsx("textarea",{className:"input min-h-[160px] resize-y font-mono text-xs leading-relaxed",value:m,onChange:z=>{g(z.target.value),T(!0),j("idle")},placeholder:`Write ${f.label.toLowerCase()} content here...`,spellCheck:!1}),s.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[s.jsxs("button",{onClick:R,disabled:x||!b,className:"btn-primary !py-1.5 !text-xs",children:[x?s.jsx(Yt,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(fm,{className:"h-3.5 w-3.5"}),"Save"]}),y==="saved"&&s.jsx("span",{className:"text-xs text-emerald-600",children:"Saved"}),y==="error"&&s.jsx("span",{className:"text-xs text-red-600",children:"Save failed"})]})]})}function hv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState(new Map),[m,g]=S.useState(!0),[x,v]=S.useState(!1);if(S.useEffect(()=>{if(!f||!o)return;const R=new Map;f.request("agents.files.list",{agentId:i}).then(async z=>{const B=Array.isArray(z==null?void 0:z.files)?z.files:[];for(const G of B)R.set(G.name,G);const H=Ll.map(G=>G.name).filter(G=>!R.has(G)||R.get(G).content===void 0),V=await Promise.allSettled(H.map(G=>f.request("agents.files.get",{agentId:i,name:G}).then(k=>({name:G,file:k==null?void 0:k.file}))));for(const G of V)G.status==="fulfilled"&&G.value.file&&R.set(G.value.name,G.value.file);for(const G of Ll)R.has(G.name)||R.set(G.name,{name:G.name,missing:!0,content:""});h(R)}).catch(()=>{}).finally(()=>g(!1))},[f,o,i]),m)return s.jsx(lt,{});const y=Ll.filter(R=>R.core),b=x?Ll:y,T={total:Ll.length,created:Ll.filter(R=>{const z=r.get(R.name);return z&&!z.missing}).length};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("p",{className:"text-sm text-surface-500",children:x?"All workspace files":"Core configuration files"}),s.jsxs("span",{className:"text-xs text-surface-400",children:[T.created," / ",T.total," files active"]})]}),s.jsxs("button",{onClick:()=>v(!x),className:wt("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",x?"bg-primary-50 text-primary-700 hover:bg-primary-100":"bg-surface-100 text-surface-600 hover:bg-surface-200"),children:[s.jsx(hr,{className:"h-3.5 w-3.5"}),x?"Advanced Mode":"Basic Mode"]})]}),!x&&s.jsxs("div",{className:"rounded-lg bg-surface-50 border border-surface-200 p-3 text-xs text-surface-500",children:["Showing the 3 core files that define your agent's behavior. Switch to"," ",s.jsx("strong",{children:"Advanced Mode"})," to edit all ",Ll.length," workspace files including tools, memory, heartbeat, and bootstrap."]}),s.jsx("div",{className:"space-y-4",children:b.map(R=>{const z=r.get(R.name);return s.jsx(dv,{agentId:i,meta:R,initialContent:(z==null?void 0:z.content)??"",initialMissing:(z==null?void 0:z.missing)??!0},R.name)})}),x&&s.jsxs("div",{className:"rounded-lg bg-surface-50 border border-surface-200 p-3",children:[s.jsx("h4",{className:"text-xs font-semibold text-surface-700 mb-2",children:"File Reference"}),s.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2 text-[11px] text-surface-500",children:Ll.map(R=>{const z=r.get(R.name),B=z&&!z.missing;return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:wt("h-1.5 w-1.5 rounded-full",B?"bg-emerald-500":"bg-surface-300")}),s.jsx("span",{className:"font-mono",children:R.name}),B&&(z==null?void 0:z.size)!=null&&s.jsxs("span",{className:"text-surface-400",children:["(",z.size,"B)"]})]},R.name)})})]})]})}function mv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState([]),[m,g]=S.useState([]),[x,v]=S.useState(!0);if(S.useEffect(()=>{!f||!o||Promise.all([f.request("config.get").then(j=>{var T;const b=(T=j==null?void 0:j.config)==null?void 0:T.bindings;return Array.isArray(b)?b:[]}),f.request("channels.status",{}).then(j=>{const b=j==null?void 0:j.channels;return b&&typeof b=="object"?Object.keys(b):[]})]).then(([j,b])=>{h(j),g(b),v(!1)}).catch(()=>v(!1))},[f,o]),x)return s.jsx(lt,{});const y=r.filter(j=>j.agentId===i);return s.jsxs("div",{children:[s.jsx("div",{className:"mb-4 flex items-center justify-between",children:s.jsxs("p",{className:"text-sm text-surface-500",children:["Channels bound to this agent via"," ",s.jsx("code",{className:"rounded bg-surface-100 px-1 font-mono text-xs",children:"bindings"})]})}),y.length===0?s.jsx("div",{className:"rounded-lg border-2 border-dashed border-surface-200 py-8 text-center text-sm text-surface-400",children:"No channel bindings for this agent. Configure bindings in Settings → Config."}):s.jsx("div",{className:"space-y-2",children:y.map((j,b)=>s.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-surface-200 p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ia,{className:"h-4 w-4 text-surface-500"}),s.jsx("span",{className:"text-sm font-medium",children:j.match.channel})]}),j.match.peer&&s.jsxs("span",{className:"badge-gray",children:[j.match.peer.kind,": ",j.match.peer.id]})]},b))}),s.jsxs("div",{className:"mt-4 rounded-lg bg-surface-50 p-3 text-xs text-surface-500",children:["Available channels: ",m.join(", ")||"None"]})]})}function yv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState(null),[m,g]=S.useState(!0);if(S.useEffect(()=>{!f||!o||f.request("config.get").then(j=>h((j==null?void 0:j.config)??null)).catch(()=>{}).finally(()=>g(!1))},[f,o]),m)return s.jsx(lt,{});const x=r==null?void 0:r.bindings,y=(Array.isArray(x)?x:[]).filter(j=>{var b;return j.agentId===i&&((b=j.match.peer)==null?void 0:b.kind)==="group"});return s.jsxs("div",{children:[s.jsx("p",{className:"mb-4 text-sm text-surface-500",children:"Groups routed to this agent"}),y.length===0?s.jsx("div",{className:"rounded-lg border-2 border-dashed border-surface-200 py-8 text-center text-sm text-surface-400",children:"No group bindings for this agent"}):s.jsx("div",{className:"space-y-2",children:y.map((j,b)=>s.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-surface-200 p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ti,{className:"h-4 w-4 text-surface-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:j.match.peer.id}),s.jsx("p",{className:"text-xs text-surface-400",children:j.match.channel})]})]}),s.jsx("span",{className:"badge-primary",children:"Group"})]},b))})]})}function gv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState([]),[m,g]=S.useState(!0);return S.useEffect(()=>{!f||!o||f.request("tools.catalog",{agentId:i}).then(x=>{const y=(Array.isArray(x==null?void 0:x.groups)?x.groups:[]).flatMap(j=>Array.isArray(j.tools)?j.tools:[]);h(y)}).catch(()=>{}).finally(()=>g(!1))},[f,o,i]),m?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsxs("p",{className:"mb-4 text-sm text-surface-500",children:["Tools available to this agent (",r.length,")"]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[r.map(x=>s.jsxs("div",{className:"rounded-lg border border-surface-200 p-3",children:[s.jsx("p",{className:"text-sm font-medium text-surface-900",children:x.label||x.id}),x.description&&s.jsx("p",{className:"mt-0.5 text-xs text-surface-400 line-clamp-2",children:x.description}),x.pluginId&&s.jsxs("p",{className:"mt-1 text-[10px] text-surface-400",children:["Plugin: ",x.pluginId]})]},x.id)),r.length===0&&s.jsx("p",{className:"col-span-2 py-8 text-center text-sm text-surface-400",children:"No tools data available"})]})]})}function vv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState([]),[m,g]=S.useState(!0);return S.useEffect(()=>{!f||!o||f.request("skills.status",{agentId:i}).then(x=>h(Array.isArray(x==null?void 0:x.skills)?x.skills:[])).catch(()=>{}).finally(()=>g(!1))},[f,o,i]),m?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsxs("p",{className:"mb-4 text-sm text-surface-500",children:["Skills for this agent (",r.length,")"]}),s.jsxs("div",{className:"space-y-2",children:[r.map(x=>{const v=x.eligible&&!x.disabled&&!x.blockedByAllowlist;return s.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-surface-200 p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[x.emoji?s.jsx("span",{className:"text-lg",children:x.emoji}):s.jsx(Ai,{className:"h-4 w-4 text-surface-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:x.name}),x.description&&s.jsx("p",{className:"text-xs text-surface-400 line-clamp-1",children:x.description}),s.jsxs("p",{className:"text-[10px] text-surface-400 font-mono",children:[x.skillKey," · ",x.source]})]})]}),v?s.jsx("span",{className:"badge-green",children:"Enabled"}):x.disabled?s.jsx("span",{className:"badge-gray",children:"Disabled"}):x.blockedByAllowlist?s.jsx("span",{className:"rounded bg-amber-50 px-2 py-0.5 text-xs text-amber-600",children:"Blocked"}):s.jsx("span",{className:"badge-gray",children:"Ineligible"})]},x.skillKey)}),r.length===0&&s.jsx("p",{className:"py-8 text-center text-sm text-surface-400",children:"No skills data available"})]})]})}function pv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState([]),[m,g]=S.useState(!0);return S.useEffect(()=>{!f||!o||f.request("sessions.list",{agentId:i}).then(x=>h(Array.isArray(x==null?void 0:x.sessions)?x.sessions:[])).catch(()=>{}).finally(()=>g(!1))},[f,o,i]),m?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsx("p",{className:"mb-4 text-sm text-surface-500",children:"Active sessions for this agent"}),s.jsxs("div",{className:"space-y-2",children:[r.map(x=>s.jsxs("div",{className:"rounded-lg border border-surface-200 p-3",children:[s.jsx("p",{className:"text-sm font-mono text-surface-700",children:x.key}),s.jsxs("div",{className:"mt-1 flex items-center gap-4 text-xs text-surface-400",children:[x.messageCount!=null&&s.jsxs("span",{children:[x.messageCount," messages"]}),x.lastActiveAt&&s.jsxs("span",{children:["Last active: ",x.lastActiveAt]})]})]},x.key)),r.length===0&&s.jsx("p",{className:"py-8 text-center text-sm text-surface-400",children:"No active sessions"})]})]})}function xv(){return s.jsxs("div",{className:"rounded-lg border-2 border-dashed border-surface-200 py-12 text-center",children:[s.jsx(sm,{className:"mx-auto h-8 w-8 text-surface-300"}),s.jsx("p",{className:"mt-2 text-sm text-surface-500",children:"Usage statistics coming soon"})]})}function Vn(i){if(!i)return"";if(typeof i=="string")return i;if(Array.isArray(i))return i.map(o=>{if(typeof o=="string")return o;if(o&&typeof o=="object"){const r=o;if(typeof r.text=="string")return r.text;if(typeof r.content=="string")return r.content}return""}).filter(Boolean).join("");const f=i;return typeof f.text=="string"?f.text:typeof f.content=="string"?f.content:Array.isArray(f.content)?Vn(f.content):""}function bv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState(""),[m,g]=S.useState([]),[x,v]=S.useState(!1),[y,j]=S.useState(""),b=`agent:${i}:operator-ui-test`,T=S.useRef(null),R=S.useRef(null),z=S.useRef("");S.useEffect(()=>{!f||!o||f.request("chat.history",{sessionKey:b,limit:50}).then(H=>{if(!Array.isArray(H==null?void 0:H.messages))return;const V=[];for(const G of H.messages){const k=G,ee=k.role==="user"?"user":k.role==="assistant"?"assistant":null;if(!ee)continue;const ie=Vn(k.content??k.text??k.message??"");ie&&V.push({role:ee,content:ie})}V.length>0&&g(V)}).catch(()=>{})},[f,o,i]),S.useEffect(()=>f?f.on("chat",V=>{const G=V;if(!(!G.runId||G.runId!==T.current))if(G.state==="delta"){const k=Vn(G.message);k&&(z.current+=k,j(z.current))}else if(G.state==="final"){const k=Vn(G.message)||z.current;T.current=null,z.current="",j(""),v(!1),k&&g(ee=>[...ee,{role:"assistant",content:k}])}else G.state==="error"?(T.current=null,z.current="",j(""),v(!1),g(k=>[...k,{role:"error",content:G.errorMessage??"Agent error"}])):G.state==="aborted"&&(T.current=null,z.current="",j(""),v(!1),g(k=>[...k,{role:"system",content:"Run was aborted"}]))}):void 0,[f]),S.useEffect(()=>{var H;(H=R.current)==null||H.scrollTo({top:R.current.scrollHeight,behavior:"smooth"})},[m,y]);async function B(){if(!r.trim()||x||!f)return;const H=r.trim();h(""),g(G=>[...G,{role:"user",content:H}]),v(!0),z.current="",j("");const V=`op-chat-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{const G=await f.request("chat.send",{sessionKey:b,message:H,idempotencyKey:V});if((G==null?void 0:G.status)==="error"){v(!1),g(k=>[...k,{role:"error",content:G.summary??"Failed to start"}]);return}T.current=(G==null?void 0:G.runId)??V,setTimeout(()=>{T.current&&f.request("chat.history",{sessionKey:b,limit:5}).then(k=>{if(!T.current||!Array.isArray(k==null?void 0:k.messages))return;const ee=k.messages[k.messages.length-1];if((ee==null?void 0:ee.role)==="assistant"){const ie=Vn(ee.content??ee.text??"");ie&&(T.current=null,z.current="",j(""),v(!1),g(F=>[...F,{role:"assistant",content:ie}]))}}).catch(()=>{})},15e3)}catch(G){v(!1),g(k=>[...k,{role:"error",content:G instanceof Error?G.message:"Failed"}])}}function Y(){f&&(f.request("sessions.reset",{key:b}).catch(()=>{}),g([]),j(""))}return s.jsxs("div",{className:"flex h-[500px] flex-col rounded-xl border border-surface-200",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-surface-100 px-4 py-2",children:[s.jsx("p",{className:"text-xs text-surface-400 font-mono",children:b}),s.jsx("button",{onClick:Y,className:"text-xs text-surface-400 hover:text-red-600 transition-colors",children:"Clear history"})]}),s.jsxs("div",{ref:R,className:"flex-1 overflow-y-auto p-4 space-y-3",children:[m.length===0&&!y&&s.jsx("p",{className:"py-12 text-center text-sm text-surface-400",children:"Send a message to test this agent"}),m.map((H,V)=>s.jsx("div",{className:wt("max-w-[80%] rounded-lg px-4 py-2.5 text-sm whitespace-pre-wrap",H.role==="user"?"ml-auto bg-primary-600 text-white":H.role==="error"?"bg-red-50 text-red-700":H.role==="system"?"mx-auto bg-surface-50 text-surface-500 text-center text-xs":"bg-surface-100 text-surface-900"),children:H.content},V)),y&&s.jsxs("div",{className:"max-w-[80%] rounded-lg px-4 py-2.5 text-sm bg-surface-100 text-surface-900 whitespace-pre-wrap",children:[y,s.jsx("span",{className:"inline-block w-1.5 h-4 bg-primary-500 animate-pulse ml-0.5 align-text-bottom"})]}),x&&!y&&s.jsxs("div",{className:"max-w-[80%] rounded-lg px-4 py-2.5 text-sm bg-surface-100 text-surface-400 flex items-center gap-2",children:[s.jsx(Yt,{className:"h-3.5 w-3.5 animate-spin"}),"Thinking..."]})]}),s.jsxs("div",{className:"border-t border-surface-200 p-3 flex gap-2",children:[s.jsx("input",{className:"input flex-1",placeholder:"Type a message...",value:r,onChange:H=>h(H.target.value),onKeyDown:H=>H.key==="Enter"&&!H.shiftKey&&B(),disabled:x}),s.jsx("button",{onClick:B,disabled:x||!r.trim(),className:"btn-primary",children:x?s.jsx(Yt,{className:"h-4 w-4 animate-spin"}):"Send"})]})]})}function Sv(i,f){const o=`/agents/${f}`,r=i.startsWith(o)?i.slice(o.length).replace(/^\//,""):"";return r&&gm.includes(r)?r:"settings"}function jv({tab:i,agentId:f}){switch(i){case"settings":return s.jsx(hv,{agentId:f});case"channels":return s.jsx(mv,{agentId:f});case"groups":return s.jsx(yv,{agentId:f});case"tools":return s.jsx(gv,{agentId:f});case"skills":return s.jsx(vv,{agentId:f});case"sessions":return s.jsx(pv,{agentId:f});case"usage":return s.jsx(xv,{});case"chat":return s.jsx(bv,{agentId:f})}}function Gh(){var B;const{agentId:i}=qg(),f=kt(),o=Si(),{gateway:r,connected:h}=Be(),[m,g]=S.useState(null),[x,v]=S.useState(!0),[y,j]=S.useState(!1),b=Sv(f.pathname,i??""),T=S.useCallback(()=>{!r||!h||r.request("agents.list",{}).then(Y=>{const V=(Array.isArray(Y==null?void 0:Y.agents)?Y.agents:[]).find(G=>G.id===i);g(V??null)}).catch(()=>{}).finally(()=>v(!1))},[r,h,i]);if(S.useEffect(()=>{T()},[T]),x)return s.jsx(lt,{});if(!m)return s.jsxs("div",{className:"flex flex-col items-center py-20",children:[s.jsx(Ni,{className:"h-8 w-8 text-surface-300"}),s.jsxs("p",{className:"mt-2 text-sm text-surface-500",children:['Agent "',i,'" not found']})]});async function R(){if(!(!r||!confirm(`Delete agent "${i}"? This cannot be undone.`))){j(!0);try{await r.request("agents.delete",{id:i}),o("/agents",{replace:!0})}catch{j(!1)}}}function z(Y){const H=`/agents/${i}`;o(Y==="settings"?H:`${H}/${Y}`)}return s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-primary-100",children:s.jsx(ua,{className:"h-6 w-6 text-primary-600"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-semibold text-surface-900",children:((B=m.identity)==null?void 0:B.name)||m.name||m.id}),s.jsxs("p",{className:"text-sm text-surface-400",children:["ID: ",s.jsx("code",{className:"font-mono",children:m.id}),m.model&&s.jsxs(s.Fragment,{children:[" · Model: ",m.model]})]})]})]}),s.jsxs("button",{onClick:R,disabled:y,className:"btn-ghost text-red-600 hover:text-red-700 hover:bg-red-50",children:[s.jsx(mr,{className:"h-4 w-4"}),"Delete"]})]}),s.jsx("div",{className:"mb-6 flex gap-1 overflow-x-auto border-b border-surface-200",children:gm.map(Y=>{const{label:H,icon:V}=ov[Y],G=Y===b;return s.jsxs("button",{onClick:()=>z(Y),className:wt("flex items-center gap-2 whitespace-nowrap border-b-2 px-4 py-2.5 text-sm font-medium transition-colors",G?"border-primary-600 text-primary-600":"border-transparent text-surface-500 hover:text-surface-700"),children:[s.jsx(V,{className:"h-4 w-4"}),H]},Y)})}),s.jsx(jv,{tab:b,agentId:i})]})}function yr({icon:i,title:f,description:o,action:r}){return s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-surface-200 py-16",children:[s.jsx("div",{className:"mb-4 text-surface-300",children:i}),s.jsx("h3",{className:"text-sm font-semibold text-surface-900",children:f}),s.jsx("p",{className:"mt-1 text-sm text-surface-500",children:o}),r&&s.jsx("div",{className:"mt-4",children:r})]})}function Nv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState(""),[g,x]=S.useState(!0);return S.useEffect(()=>{!i||!f||i.request("agents.list",{}).then(v=>{r(Array.isArray(v==null?void 0:v.agents)?v.agents:[]),m((v==null?void 0:v.defaultId)??"")}).catch(()=>{}).finally(()=>x(!1))},[i,f]),g?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsx(hl,{title:"Agents",description:"Create and manage your AI agents",actions:s.jsxs(Vt,{to:"/agents/new",className:"btn-primary",children:[s.jsx(Lh,{className:"h-4 w-4"}),"New Agent"]})}),o.length===0?s.jsx(yr,{icon:s.jsx(ua,{className:"h-12 w-12"}),title:"No agents yet",description:"Create your first AI agent to get started",action:s.jsxs(Vt,{to:"/agents/new",className:"btn-primary",children:[s.jsx(Lh,{className:"h-4 w-4"}),"Create Agent"]})}):s.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:o.map(v=>{var y;return s.jsxs(Vt,{to:`/agents/${v.id}`,className:"card group flex flex-col transition-all hover:border-primary-200 hover:shadow-sm",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary-100",children:s.jsx(ua,{className:"h-5 w-5 text-primary-600"})}),s.jsx(cm,{className:"h-4 w-4 text-surface-300 transition-colors group-hover:text-primary-500"})]}),s.jsxs("div",{className:"mt-3 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-surface-900",children:((y=v.identity)==null?void 0:y.name)||v.name||v.id}),v.id===h&&s.jsx(F1,{className:"h-3.5 w-3.5 fill-amber-400 text-amber-400"})]}),s.jsxs("p",{className:"mt-0.5 text-xs text-surface-400",children:["ID: ",s.jsx("code",{className:"font-mono",children:v.id})]})]}),v.model&&s.jsx("div",{className:"mt-3 border-t border-surface-100 pt-3",children:s.jsxs("p",{className:"text-xs text-surface-500",children:["Model: ",s.jsx("span",{className:"font-medium text-surface-700",children:v.model})]})})]},v.id)})})]})}const Ev={whatsapp:"💬",telegram:"✈️",discord:"🎮",slack:"💼",signal:"🔒",imessage:"💬",bluebubbles:"💬",googlechat:"💬",msteams:"🏢",feishu:"🐦",matrix:"🔗",webchat:"🌐"};function Av(i){if(!i||typeof i!="object")return[];const f=i,o=f.channels??{},r=f.channelAccounts??{},h=[];for(const m of Object.keys(o)){const g=o[m],x=r[m]??{},v=Object.entries(x).map(([y,j])=>({id:y,status:String((j==null?void 0:j.status)??"unknown"),label:j==null?void 0:j.label,phone:j==null?void 0:j.phone}));h.push({id:m,configured:(g==null?void 0:g.configured)??!1,accounts:v})}return h}function Tv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState(!0),[g,x]=S.useState(null);function v(){!i||!f||(m(!0),i.request("channels.status",{}).then(j=>r(Av(j))).catch(()=>{}).finally(()=>m(!1)))}S.useEffect(()=>{v()},[i,f]);async function y(j,b){if(!(!i||!confirm(`Logout from ${j} account ${b}?`))){x(`${j}:${b}`);try{await i.request("channels.logout",{channel:j,accountId:b}),v()}catch{}x(null)}}return h?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsx(hl,{title:"Channels",description:"Monitor and manage your messaging channels",actions:s.jsxs("button",{onClick:v,className:"btn-secondary",children:[s.jsx(dr,{className:"h-4 w-4"}),"Refresh"]})}),s.jsxs("div",{className:"space-y-3",children:[o.map(j=>{const b=j.accounts.some(R=>R.status==="online"),T=Ev[j.id]??"📡";return s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-2xl",children:T}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-surface-900",children:j.id}),s.jsx("p",{className:"text-xs text-surface-400",children:j.accounts.length>0?`${j.accounts.length} account(s)`:j.configured?"Configured":"Not configured"})]})]}),s.jsx("div",{className:"flex items-center gap-2",children:b?s.jsxs("span",{className:"badge-green",children:[s.jsx(hm,{className:"mr-1 h-3 w-3"}),"Online"]}):j.configured?s.jsxs("span",{className:"badge-gray",children:[s.jsx(dm,{className:"mr-1 h-3 w-3"}),"Offline"]}):s.jsx("span",{className:"badge-gray",children:"Not Configured"})})]}),j.accounts.length>0&&s.jsx("div",{className:"mt-3 space-y-2 border-t border-surface-100 pt-3",children:j.accounts.map(R=>s.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-surface-50 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`h-2 w-2 rounded-full ${R.status==="online"?"bg-emerald-500":"bg-surface-300"}`}),s.jsx("span",{className:"text-sm text-surface-700",children:R.label||R.id}),R.phone&&s.jsx("span",{className:"text-xs text-surface-400",children:R.phone})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-surface-400",children:R.status}),R.status==="online"&&s.jsx("button",{onClick:()=>y(j.id,R.id),disabled:g===`${j.id}:${R.id}`,className:"btn-ghost !px-2 !py-1 text-xs text-surface-500",children:g===`${j.id}:${R.id}`?s.jsx(Yt,{className:"h-3 w-3 animate-spin"}):s.jsx(rm,{className:"h-3 w-3"})})]})]},R.id))})]},j.id)}),o.length===0&&s.jsxs("div",{className:"card py-12 text-center",children:[s.jsx(ia,{className:"mx-auto h-8 w-8 text-surface-300"}),s.jsx("p",{className:"mt-2 text-sm text-surface-500",children:"No channels configured. Add channels in your openclaw.json configuration."})]})]})]})}function zv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState(!0),[g,x]=S.useState(null);function v(){!i||!f||i.request("cron.list",{}).then(T=>r(Array.isArray(T==null?void 0:T.jobs)?T.jobs:[])).catch(()=>r([])).finally(()=>m(!1))}S.useEffect(()=>{v()},[i,f]);async function y(T,R){if(i){x(T);try{await i.request("cron.update",{id:T,enabled:!R}),r(z=>z.map(B=>B.id===T?{...B,enabled:!R}:B))}catch{}x(null)}}async function j(T){if(i){x(T);try{await i.request("cron.run",{id:T})}catch{}x(null)}}async function b(T){if(!(!i||!confirm("Remove this cron job?"))){x(T);try{await i.request("cron.remove",{id:T}),r(R=>R.filter(z=>z.id!==T))}catch{}x(null)}}return h?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsx(hl,{title:"Cron Jobs",description:"Manage scheduled tasks"}),o.length===0?s.jsx(yr,{icon:s.jsx(nr,{className:"h-12 w-12"}),title:"No cron jobs",description:"Scheduled tasks will appear here. Create them via the agent chat."}):s.jsx("div",{className:"space-y-2",children:o.map(T=>s.jsxs("div",{className:"card flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-amber-50",children:s.jsx(nr,{className:"h-4 w-4 text-amber-600"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-surface-900",children:T.message||T.id}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-surface-400",children:[s.jsx("code",{className:"font-mono",children:T.schedule}),T.agentId&&s.jsxs("span",{children:["Agent: ",T.agentId]}),T.nextRunAt&&s.jsxs("span",{children:["Next: ",T.nextRunAt]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>j(T.id),disabled:g===T.id,className:"btn-ghost !px-2 !py-1.5 text-surface-400 hover:text-emerald-600",title:"Run now",children:g===T.id?s.jsx(Yt,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(Bh,{className:"h-3.5 w-3.5"})}),s.jsx("button",{onClick:()=>y(T.id,T.enabled),className:"btn-ghost !px-2 !py-1.5 text-surface-400 hover:text-amber-600",title:T.enabled?"Pause":"Resume",children:T.enabled?s.jsx(J1,{className:"h-3.5 w-3.5"}):s.jsx(Bh,{className:"h-3.5 w-3.5"})}),s.jsx("button",{onClick:()=>b(T.id),className:"btn-ghost !px-2 !py-1.5 text-surface-400 hover:text-red-600",title:"Remove",children:s.jsx(mr,{className:"h-3.5 w-3.5"})})]})]},T.id))})]})}function Cv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState(!0),[h,m]=S.useState([]),[g,x]=S.useState(""),[v,y]=S.useState([]),[j,b]=S.useState(0);if(S.useEffect(()=>{if(!i||!f)return;let z=!1;return r(!0),Promise.all([i.request("agents.list",{}).catch(()=>null),i.request("channels.status",{}).catch(()=>null),i.request("sessions.list",{}).catch(()=>null)]).then(([B,Y,H])=>{if(z)return;const V=Array.isArray(B==null?void 0:B.agents)?B.agents:[];m(V),x((B==null?void 0:B.defaultId)??"");const G=[];if(Y!=null&&Y.channels&&typeof Y.channels=="object"){const k=Y.channelAccounts??{};for(const[ee,ie]of Object.entries(Y.channels)){const F=k[ee];let X=!1;F&&typeof F=="object"&&(X=Object.values(F).some(se=>se&&typeof se=="object"&&se.status==="online")),G.push({id:ee,configured:(ie==null?void 0:ie.configured)??!1,online:X,label:ee})}}y(G),b(typeof(H==null?void 0:H.count)=="number"?H.count:Array.isArray(H==null?void 0:H.sessions)?H.sessions.length:0),r(!1)}),()=>{z=!0}},[i,f]),o)return s.jsx(lt,{});const T=v.filter(z=>z.online),R=[{label:"Active Agents",value:h.length,icon:ua,color:"bg-primary-50 text-primary-600",to:"/agents"},{label:"Channels Online",value:`${T.length} / ${v.length}`,icon:ia,color:"bg-emerald-50 text-emerald-600",to:"/channels"},{label:"Active Sessions",value:j,icon:Ei,color:"bg-blue-50 text-blue-600",to:"/sessions"},{label:"System Health",value:"OK",icon:H1,color:"bg-amber-50 text-amber-600",to:"/settings"}];return s.jsxs("div",{children:[s.jsx(hl,{title:"Dashboard",description:"Overview of your AI assistant system"}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:R.map(z=>s.jsxs(Vt,{to:z.to,className:"card group hover:border-primary-200 transition-colors",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${z.color}`,children:s.jsx(z.icon,{className:"h-5 w-5"})}),s.jsx(q1,{className:"h-4 w-4 text-surface-300 transition-colors group-hover:text-primary-500"})]}),s.jsx("p",{className:"mt-3 text-2xl font-semibold text-surface-900",children:z.value}),s.jsx("p",{className:"text-sm text-surface-500",children:z.label})]},z.label))}),s.jsxs("div",{className:"mt-8 grid gap-6 lg:grid-cols-2",children:[s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-semibold text-surface-900",children:"Agents"}),s.jsx(Vt,{to:"/agents",className:"text-xs font-medium text-primary-600 hover:text-primary-700",children:"View all →"})]}),s.jsx("div",{className:"space-y-2",children:h.length===0?s.jsx("p",{className:"py-4 text-center text-sm text-surface-400",children:"No agents configured"}):h.slice(0,5).map(z=>{var B;return s.jsxs(Vt,{to:`/agents/${z.id}`,className:"flex items-center justify-between rounded-lg p-3 transition-colors hover:bg-surface-50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary-100 text-primary-700",children:s.jsx(ua,{className:"h-4 w-4"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-surface-900",children:((B=z.identity)==null?void 0:B.name)||z.name||z.id}),s.jsxs("p",{className:"text-xs text-surface-400",children:["ID: ",z.id]})]})]}),z.id===g&&s.jsx("span",{className:"badge-primary",children:"Default"})]},z.id)})})]}),s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-semibold text-surface-900",children:"Channels"}),s.jsx(Vt,{to:"/channels",className:"text-xs font-medium text-primary-600 hover:text-primary-700",children:"View all →"})]}),s.jsx("div",{className:"space-y-2",children:v.length===0?s.jsx("p",{className:"py-4 text-center text-sm text-surface-400",children:"No channels configured"}):v.slice(0,6).map(z=>s.jsxs("div",{className:"flex items-center justify-between rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-surface-100",children:s.jsx(ia,{className:"h-4 w-4 text-surface-600"})}),s.jsx("p",{className:"text-sm font-medium text-surface-900",children:z.label})]}),z.online?s.jsx("span",{className:"badge-green",children:"Online"}):z.configured?s.jsx("span",{className:"badge-gray",children:"Offline"}):s.jsx("span",{className:"badge-gray",children:"Not Configured"})]},z.id))})]})]})]})}function Mv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState([]),[g,x]=S.useState(!0);if(S.useEffect(()=>{!i||!f||Promise.all([i.request("config.get"),i.request("agents.list",{})]).then(([b,T])=>{var z;const R=(z=b==null?void 0:b.config)==null?void 0:z.bindings;r(Array.isArray(R)?R:[]),m(Array.isArray(T==null?void 0:T.agents)?T.agents:[]),x(!1)}).catch(()=>x(!1))},[i,f]),g)return s.jsx(lt,{});const v=o.filter(b=>{var T;return((T=b.match.peer)==null?void 0:T.kind)==="group"||b.match.guildId}).map(b=>{var T;return{...b,_displayName:((T=b.match.peer)==null?void 0:T.id)??b.match.guildId??"Unknown group"}}),y=new Map(h.map(b=>[b.id,b.name||b.id])),j=v.reduce((b,T)=>{const R=T.match.channel;return b[R]||(b[R]=[]),b[R].push(T),b},{});return s.jsxs("div",{children:[s.jsx(hl,{title:"Groups",description:"View and manage group-to-agent bindings across all channels"}),v.length===0?s.jsx(yr,{icon:s.jsx(Ti,{className:"h-12 w-12"}),title:"No group bindings",description:"Group bindings route specific groups to specific agents. Configure them in Settings → Config under 'bindings'."}):s.jsx("div",{className:"space-y-6",children:Object.entries(j).map(([b,T])=>s.jsxs("div",{children:[s.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[s.jsx(ia,{className:"h-4 w-4 text-surface-500"}),s.jsx("h2",{className:"text-sm font-semibold text-surface-700 uppercase tracking-wide",children:b}),s.jsx("span",{className:"badge-gray",children:T.length})]}),s.jsx("div",{className:"space-y-2",children:T.map((R,z)=>s.jsxs("div",{className:"card flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-surface-100",children:s.jsx(k1,{className:"h-5 w-5 text-surface-600"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-surface-900",children:R._displayName}),R.comment&&s.jsx("p",{className:"text-xs text-surface-400",children:R.comment})]})]}),s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs(Vt,{to:`/agents/${R.agentId}`,className:"flex items-center gap-1.5 rounded-lg bg-primary-50 px-2.5 py-1 text-xs font-medium text-primary-700 hover:bg-primary-100 transition-colors",children:[s.jsx(ua,{className:"h-3 w-3"}),y.get(R.agentId)??R.agentId]})})]},z))})]},b))}),s.jsxs("div",{className:"mt-8 card bg-surface-50 border-surface-200",children:[s.jsx("h3",{className:"text-sm font-semibold text-surface-700 mb-2",children:"Group Behavior Reference"}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 text-xs text-surface-500",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(B1,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-surface-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-surface-700",children:"Mention Mode"}),s.jsx("p",{children:"Bot only responds when @mentioned in the group"})]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(K1,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-surface-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-surface-700",children:"Always Mode"}),s.jsx("p",{children:"Bot responds to all messages in the group"})]})]})]})]})]})}function Ov(){const{login:i,connecting:f,error:o}=Be(),[r,h]=S.useState("");function m(g){g.preventDefault(),r.trim()&&i(r)}return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white",children:s.jsxs("div",{className:"w-full max-w-sm",children:[s.jsxs("div",{className:"mb-8 text-center",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-primary-600",children:s.jsx("span",{className:"text-2xl font-bold text-white",children:"O"})}),s.jsx("h1",{className:"text-2xl font-semibold text-surface-900",children:"Operator"}),s.jsx("p",{className:"mt-1 text-sm text-surface-500",children:"Sign in to manage your AI agents"})]}),s.jsxs("form",{onSubmit:m,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"label",children:"Password"}),s.jsxs("div",{className:"relative",children:[s.jsx(Z1,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400"}),s.jsx("input",{id:"password",type:"password",value:r,onChange:g=>h(g.target.value),className:"input !pl-10",placeholder:"Enter operator password",autoFocus:!0,disabled:f})]})]}),o&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-red-50 p-3 text-sm text-red-700",children:[s.jsx(Ni,{className:"mt-0.5 h-4 w-4 shrink-0"}),s.jsx("span",{children:o})]}),s.jsx("button",{type:"submit",disabled:f||!r.trim(),className:"btn-primary w-full",children:f?s.jsxs(s.Fragment,{children:[s.jsx(Yt,{className:"h-4 w-4 animate-spin"}),"Connecting..."]}):"Sign In"})]}),s.jsxs("p",{className:"mt-6 text-center text-xs text-surface-400",children:["Configure password in"," ",s.jsx("code",{className:"rounded bg-surface-100 px-1 py-0.5 font-mono text-[10px]",children:"openclaw.json"})]})]})})}function _v(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState(!0),[g,x]=S.useState(""),[v,y]=S.useState(null);function j(){!i||!f||(m(!0),i.request("sessions.list",{}).then(z=>r(Array.isArray(z==null?void 0:z.sessions)?z.sessions:[])).catch(()=>{}).finally(()=>m(!1)))}S.useEffect(()=>{j()},[i,f]);async function b(z){if(!(!i||!confirm(`Reset session "${z}"? This will clear its history.`))){y(z);try{await i.request("sessions.reset",{key:z}),j()}catch{}y(null)}}async function T(z){if(!(!i||!confirm(`Delete session "${z}"? This cannot be undone.`))){y(z);try{await i.request("sessions.delete",{key:z}),r(B=>B.filter(Y=>Y.key!==z))}catch{}y(null)}}if(h)return s.jsx(lt,{});const R=o.filter(z=>!g||z.key.toLowerCase().includes(g.toLowerCase()));return s.jsxs("div",{children:[s.jsx(hl,{title:"Sessions",description:"View and manage active conversations",actions:s.jsxs("button",{onClick:j,className:"btn-secondary",children:[s.jsx(dr,{className:"h-4 w-4"}),"Refresh"]})}),s.jsxs("div",{className:"relative mb-4",children:[s.jsx(om,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400"}),s.jsx("input",{className:"input !pl-10",placeholder:"Search sessions...",value:g,onChange:z=>x(z.target.value)})]}),s.jsx("div",{className:"space-y-2",children:R.map(z=>s.jsxs("div",{className:"card flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-blue-50",children:s.jsx(Ei,{className:"h-4 w-4 text-blue-600"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm font-mono text-surface-900 truncate",children:z.key}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-surface-400",children:[z.agentId&&s.jsxs("span",{children:["Agent: ",z.agentId]}),z.channel&&s.jsxs("span",{children:["Channel: ",z.channel]}),z.messageCount!=null&&s.jsxs("span",{children:[z.messageCount," msgs"]})]})]})]}),s.jsxs("div",{className:"ml-3 flex shrink-0 items-center gap-1",children:[s.jsx("button",{onClick:()=>b(z.key),disabled:v===z.key,className:"btn-ghost !px-2 !py-1.5 text-surface-400 hover:text-amber-600",title:"Reset session",children:v===z.key?s.jsx(Yt,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx($1,{className:"h-3.5 w-3.5"})}),s.jsx("button",{onClick:()=>T(z.key),disabled:v===z.key,className:"btn-ghost !px-2 !py-1.5 text-surface-400 hover:text-red-600",title:"Delete session",children:s.jsx(mr,{className:"h-3.5 w-3.5"})})]})]},z.key))}),R.length===0&&s.jsx("div",{className:"py-12 text-center text-sm text-surface-400",children:g?"No sessions match your search":"No active sessions"})]})}function Rv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState(""),[h,m]=S.useState(!0),[g,x]=S.useState(!1),[v,y]=S.useState(null),[j,b]=S.useState(null),[T,R]=S.useState([]);S.useEffect(()=>{!i||!f||Promise.all([i.request("config.get"),i.request("health").catch(()=>null),i.request("models.list").catch(()=>({models:[]}))]).then(([B,Y,H])=>{r(JSON.stringify((B==null?void 0:B.config)??{},null,2)),b(Y),R(Array.isArray(H==null?void 0:H.models)?H.models:[]),m(!1)})},[i,f]);async function z(){if(i){x(!0),y(null);try{const B=JSON.parse(o);await i.request("config.set",{config:B}),y({ok:!0,msg:"Configuration saved. Some changes may require a restart."})}catch(B){y({ok:!1,msg:B instanceof Error?B.message:"Failed to save"})}x(!1)}}return h?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsx(hl,{title:"Settings",description:"System configuration and health"}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[s.jsx("div",{className:"lg:col-span-2 space-y-6",children:s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-semibold text-surface-900",children:"Configuration"}),s.jsx("p",{className:"text-xs text-surface-400",children:"openclaw.json"})]}),s.jsx("textarea",{className:"input min-h-[400px] resize-y font-mono text-xs leading-relaxed",value:o,onChange:B=>{r(B.target.value),y(null)},spellCheck:!1}),v&&s.jsxs("div",{className:`mt-3 flex items-start gap-2 rounded-lg p-3 text-sm ${v.ok?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-700"}`,children:[v.ok?s.jsx(ar,{className:"mt-0.5 h-4 w-4 shrink-0"}):s.jsx(Ni,{className:"mt-0.5 h-4 w-4 shrink-0"}),s.jsx("span",{children:v.msg})]}),s.jsx("div",{className:"mt-3 flex gap-3",children:s.jsxs("button",{onClick:z,disabled:g,className:"btn-primary",children:[g?s.jsx(Yt,{className:"h-4 w-4 animate-spin"}):s.jsx(fm,{className:"h-4 w-4"}),"Save Configuration"]})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"mb-3 text-sm font-semibold text-surface-900",children:"System Health"}),j?s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Y1,{className:"h-4 w-4 text-surface-400"}),s.jsx("span",{className:"text-surface-600",children:"Status:"}),s.jsx("span",{className:"badge-green",children:"Healthy"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(G1,{className:"h-4 w-4 text-surface-400"}),s.jsx("span",{className:"text-surface-600",children:"Version:"}),s.jsx("span",{className:"text-surface-900 font-mono text-xs",children:j.version??"unknown"})]})]}):s.jsx("p",{className:"text-sm text-surface-400",children:"Health data unavailable"})]}),s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"mb-3 text-sm font-semibold text-surface-900",children:"Available Models"}),s.jsxs("div",{className:"space-y-1",children:[T.length>0?T.slice(0,10).map(B=>s.jsxs("div",{className:"rounded px-2 py-1.5 text-xs",children:[s.jsx("p",{className:"font-mono text-surface-700",children:B.id}),B.provider&&s.jsx("p",{className:"text-surface-400",children:B.provider})]},B.id)):s.jsx("p",{className:"text-sm text-surface-400",children:"No models configured"}),T.length>10&&s.jsxs("p",{className:"text-xs text-surface-400",children:["+",T.length-10," more"]})]})]})]})]})]})}function yi(i){const f=vm(i.missing);return i.disabled?"disabled":i.blockedByAllowlist&&f?"both":i.blockedByAllowlist?"blocked":f?"missing":"enabled"}const er={enabled:{label:"Enabled",cls:"bg-emerald-50 text-emerald-700"},disabled:{label:"Disabled",cls:"bg-surface-100 text-surface-500"},blocked:{label:"Blocked by Allowlist",cls:"bg-amber-50 text-amber-700"},missing:{label:"Missing Requirements",cls:"bg-red-50 text-red-700"},both:{label:"Blocked + Missing Reqs",cls:"bg-red-50 text-red-700"}};function vm(i){return i.bins.length>0||i.anyBins.length>0||i.env.length>0||i.config.length>0||i.os.length>0}function Dv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState(!0),[g,x]=S.useState(""),[v,y]=S.useState(null),[j,b]=S.useState(null),[T,R]=S.useState(null),[z,B]=S.useState(new Set),[Y,H]=S.useState("all");function V(){!i||!f||(m(!0),i.request("skills.status",{}).then(X=>r(Array.isArray(X==null?void 0:X.skills)?X.skills:[])).catch(()=>{}).finally(()=>m(!1)))}S.useEffect(()=>{V()},[i,f]);async function G(X){if(!i)return;const Te=yi(X)!=="enabled";y(X.skillKey);try{await i.request("skills.update",{skillKey:X.skillKey,enabled:Te}),V()}catch{}y(null)}async function k(X,se){if(!i)return;const Te=`${X}:${se}`;b(Te),R(null);try{const ze=await i.request("skills.install",{name:X,installId:se,timeoutMs:12e4});ze!=null&&ze.ok?(R({key:X,ok:!0,msg:"Installed successfully"}),V()):R({key:X,ok:!1,msg:(ze==null?void 0:ze.message)??"Install failed"})}catch(ze){R({key:X,ok:!1,msg:ze instanceof Error?ze.message:"Install failed"})}b(null)}function ee(X){B(se=>{const Te=new Set(se);return Te.has(X)?Te.delete(X):Te.add(X),Te})}if(h)return s.jsx(lt,{});const ie=o.filter(X=>{var Te;if(Y!=="all"&&yi(X)!==Y)return!1;if(!g)return!0;const se=g.toLowerCase();return X.skillKey.toLowerCase().includes(se)||X.name.toLowerCase().includes(se)||((Te=X.description)==null?void 0:Te.toLowerCase().includes(se))}),F={enabled:0,disabled:0,blocked:0,missing:0,both:0};for(const X of o)F[yi(X)]++;return s.jsxs("div",{children:[s.jsx(hl,{title:"Skills",description:"Browse and manage agent skills",actions:s.jsxs("button",{onClick:V,className:"btn-secondary",children:[s.jsx(dr,{className:"h-4 w-4"}),"Refresh"]})}),s.jsxs("div",{className:"mb-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(om,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400"}),s.jsx("input",{className:"input !pl-10",placeholder:"Search skills...",value:g,onChange:X=>x(X.target.value)})]}),s.jsxs("span",{className:"text-xs text-surface-500",children:[ie.length," / ",o.length]})]}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[s.jsxs("button",{onClick:()=>H("all"),className:wt("rounded-full px-3 py-1 text-xs font-medium transition-colors",Y==="all"?"bg-surface-900 text-white":"bg-surface-100 text-surface-600 hover:bg-surface-200"),children:["All (",o.length,")"]}),["enabled","blocked","missing","disabled"].map(X=>F[X]>0&&s.jsxs("button",{onClick:()=>H(Y===X?"all":X),className:wt("rounded-full px-3 py-1 text-xs font-medium transition-colors",Y===X?"bg-surface-900 text-white":`${er[X].cls} hover:opacity-80`),children:[er[X].label," (",F[X],")"]},X))]})]}),s.jsx("div",{className:"space-y-2",children:ie.map(X=>{const se=yi(X),Te=er[se],ze=z.has(X.skillKey),Qe=vm(X.missing);return s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[s.jsx("button",{onClick:()=>ee(X.skillKey),className:"shrink-0 text-surface-400 hover:text-surface-600",children:ze?s.jsx(L1,{className:"h-4 w-4"}):s.jsx(cm,{className:"h-4 w-4"})}),s.jsx("div",{className:wt("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg",se==="enabled"?"bg-primary-100":"bg-surface-100"),children:X.emoji?s.jsx("span",{className:"text-lg",children:X.emoji}):s.jsx(Ai,{className:wt("h-4 w-4",se==="enabled"?"text-primary-600":"text-surface-400")})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("p",{className:"text-sm font-medium text-surface-900",children:X.name}),s.jsx("span",{className:wt("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",Te.cls),children:Te.label})]}),X.description&&s.jsx("p",{className:"text-xs text-surface-400 truncate",children:X.description})]})]}),s.jsx("button",{onClick:()=>G(X),disabled:v===X.skillKey,className:"ml-3 shrink-0",title:se==="enabled"?"Disable this skill":"Enable this skill",children:v===X.skillKey?s.jsx(Yt,{className:"h-5 w-5 animate-spin text-surface-400"}):se==="enabled"?s.jsx(P1,{className:"h-6 w-6 text-primary-600"}):s.jsx(I1,{className:"h-6 w-6 text-surface-300"})})]}),ze&&s.jsxs("div",{className:"mt-3 border-t border-surface-100 pt-3 space-y-2.5",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 text-xs",children:[s.jsxs("div",{className:"flex items-center gap-2 text-surface-500",children:[s.jsx("span",{className:"font-medium text-surface-700",children:"Key:"}),s.jsx("code",{className:"font-mono",children:X.skillKey})]}),s.jsxs("div",{className:"flex items-center gap-2 text-surface-500",children:[s.jsx("span",{className:"font-medium text-surface-700",children:"Source:"}),s.jsx("span",{children:X.source})]}),X.primaryEnv&&s.jsxs("div",{className:"flex items-center gap-2 text-surface-500",children:[s.jsx(X1,{className:"h-3 w-3"}),s.jsx("span",{className:"font-medium text-surface-700",children:"API Key env:"}),s.jsx("code",{className:"font-mono",children:X.primaryEnv})]}),X.homepage&&s.jsxs("div",{className:"flex items-center gap-2 text-surface-500",children:[s.jsx("span",{className:"font-medium text-surface-700",children:"Homepage:"}),s.jsx("a",{href:X.homepage,target:"_blank",rel:"noreferrer",className:"text-primary-600 hover:underline truncate",children:X.homepage})]})]}),X.blockedByAllowlist&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-amber-50 p-2.5 text-xs text-amber-800",children:[s.jsx(W1,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Blocked by allowlist"}),s.jsxs("p",{className:"text-amber-600",children:["This bundled skill is not in"," ",s.jsx("code",{className:"font-mono",children:"skills.allowBundled"}),". Add"," ",s.jsxs("code",{className:"font-mono",children:['"',X.skillKey,'"']})," to the allowlist in Settings to unblock."]})]})]}),Qe&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-red-50 p-2.5 text-xs text-red-800",children:[s.jsx(ev,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Missing requirements"}),s.jsxs("ul",{className:"mt-1 space-y-0.5 text-red-700",children:[X.missing.bins.length>0&&s.jsxs("li",{children:["Commands not found:"," ",s.jsx("code",{className:"font-mono",children:X.missing.bins.join(", ")})]}),X.missing.anyBins.length>0&&s.jsxs("li",{children:["Need one of:"," ",s.jsx("code",{className:"font-mono",children:X.missing.anyBins.join(", ")})]}),X.missing.env.length>0&&s.jsxs("li",{children:["Missing env vars:"," ",s.jsx("code",{className:"font-mono",children:X.missing.env.join(", ")})]}),X.missing.config.length>0&&s.jsxs("li",{children:["Missing config:"," ",s.jsx("code",{className:"font-mono",children:X.missing.config.join(", ")})]}),X.missing.os.length>0&&s.jsxs("li",{children:["Requires OS:"," ",s.jsx("code",{className:"font-mono",children:X.missing.os.join(", ")})]})]})]})]}),Array.isArray(X.install)&&X.install.length>0&&Qe&&s.jsxs("div",{className:"rounded-lg bg-blue-50 p-2.5",children:[s.jsxs("p",{className:"text-xs font-medium text-blue-800 mb-2",children:[s.jsx(qh,{className:"inline h-3 w-3 mr-1"}),"Install missing dependencies"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:X.install.map(ke=>{const at=`${X.name}:${ke.id}`,Re=j===at;return s.jsxs("button",{onClick:()=>k(X.name,ke.id),disabled:Re||j!==null,className:"flex items-center gap-1.5 rounded-lg bg-white border border-blue-200 px-3 py-1.5 text-xs font-medium text-blue-700 hover:bg-blue-100 transition-colors disabled:opacity-50",children:[Re?s.jsx(Yt,{className:"h-3 w-3 animate-spin"}):s.jsx(qh,{className:"h-3 w-3"}),ke.label,ke.bins.length>0&&s.jsxs("span",{className:"text-blue-400 font-mono",children:["(",ke.bins.join(", "),")"]})]},ke.id)})}),(T==null?void 0:T.key)===X.name&&s.jsxs("div",{className:wt("mt-2 text-xs",T.ok?"text-emerald-700":"text-red-700"),children:[T.ok?s.jsx(ar,{className:"inline h-3 w-3 mr-1"}):s.jsx(Hh,{className:"inline h-3 w-3 mr-1"}),T.msg]})]}),se==="enabled"&&s.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-emerald-50 p-2.5 text-xs text-emerald-700",children:[s.jsx(ar,{className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{children:"All requirements met. Skill is active."})]}),X.disabled&&s.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-surface-100 p-2.5 text-xs text-surface-600",children:[s.jsx(Hh,{className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{children:"Explicitly disabled in config. Click the toggle to re-enable."})]})]})]},X.skillKey)})}),ie.length===0&&s.jsx("div",{className:"py-12 text-center text-sm text-surface-400",children:g||Y!=="all"?"No skills match your filter":"No skills available"})]})}function wv(){return s.jsx(e1,{children:s.jsxs(ot,{element:s.jsx(rv,{}),children:[s.jsx(ot,{index:!0,element:s.jsx(Cv,{})}),s.jsx(ot,{path:"agents",element:s.jsx(Nv,{})}),s.jsx(ot,{path:"agents/new",element:s.jsx(fv,{})}),s.jsx(ot,{path:"agents/:agentId",element:s.jsx(Gh,{})}),s.jsx(ot,{path:"agents/:agentId/:tab",element:s.jsx(Gh,{})}),s.jsx(ot,{path:"channels",element:s.jsx(Tv,{})}),s.jsx(ot,{path:"groups",element:s.jsx(Mv,{})}),s.jsx(ot,{path:"skills",element:s.jsx(Dv,{})}),s.jsx(ot,{path:"sessions",element:s.jsx(_v,{})}),s.jsx(ot,{path:"cron",element:s.jsx(zv,{})}),s.jsx(ot,{path:"settings",element:s.jsx(Rv,{})}),s.jsx(ot,{path:"*",element:s.jsx(Fg,{to:"/",replace:!0})})]})})}function Uv(){const{authenticated:i}=Be();return i?s.jsx(wv,{}):s.jsx(Ov,{})}Iy.createRoot(document.getElementById("root")).render(s.jsx(S.StrictMode,{children:s.jsx(E1,{basename:"/operator",children:s.jsx(iv,{children:s.jsx(Uv,{})})})}));
|
|
295
|
+
*/const tv=le("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);let lv=0;function Yh(){return`op-${++lv}-${Date.now().toString(36)}`}const av="webchat-ui";class nv{constructor(f,o){Dt(this,"ws",null);Dt(this,"pending",new Map);Dt(this,"eventHandlers",new Map);Dt(this,"closed",!1);Dt(this,"connectSent",!1);Dt(this,"connectTimer",null);Dt(this,"_connected",!1);Dt(this,"_snapshot",null);Dt(this,"reconnectTimer",null);Dt(this,"onConnectedChange");Dt(this,"onConnectError");this.url=f,this.password=o}get connected(){return this._connected}get snapshot(){return this._snapshot}setCallbacks(f){this.onConnectedChange=f.onConnectedChange,this.onConnectError=f.onConnectError}start(){this.closed=!1,this.doConnect()}stop(){var f;this.closed=!0,this._connected=!1,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null),(f=this.ws)==null||f.close(),this.ws=null;for(const[,o]of this.pending)o.reject(new Error("client stopped"));this.pending.clear()}on(f,o){let r=this.eventHandlers.get(f);return r||(r=new Set,this.eventHandlers.set(f,r)),r.add(o),()=>r.delete(o)}async request(f,o){if(!this.ws||this.ws.readyState!==WebSocket.OPEN||!this._connected)throw new Error("gateway not connected");const r=Yh(),h={type:"req",id:r,method:f,params:o};return new Promise((m,g)=>{this.pending.set(r,{resolve:x=>m(x),reject:g}),this.ws.send(JSON.stringify(h))})}doConnect(){if(this.closed)return;const f=new WebSocket(this.url);this.ws=f,this.connectSent=!1,f.addEventListener("open",()=>{this.ws===f&&this.scheduleConnect()}),f.addEventListener("message",o=>{this.ws===f&&this.handleMessage(String(o.data??""))}),f.addEventListener("close",o=>{var h;if(this.ws!==f)return;this.ws=null;const r=this._connected;this._connected=!1,r&&((h=this.onConnectedChange)==null||h.call(this,!1));for(const[,m]of this.pending)m.reject(new Error(`closed: ${o.code}`));this.pending.clear(),this.closed||(this.reconnectTimer=window.setTimeout(()=>this.doConnect(),2e3))}),f.addEventListener("error",()=>{})}scheduleConnect(){this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},100)}async sendConnect(){var o,r,h;if(this.connectSent||!this.ws||this.ws.readyState!==WebSocket.OPEN)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const f={minProtocol:3,maxProtocol:3,client:{id:av,version:"0.1.0",platform:navigator.platform??"web",mode:"ui"},role:"operator",scopes:["operator.admin","operator.approvals","operator.pairing"],caps:[],auth:{password:this.password},userAgent:navigator.userAgent,locale:navigator.language};try{const m=await this.request_internal("connect",f);this._connected=!0,this._snapshot=(m==null?void 0:m.snapshot)??null,(o=this.onConnectedChange)==null||o.call(this,!0)}catch(m){const g=m instanceof Error?m.message:"connect failed";(r=this.onConnectError)==null||r.call(this,g),(h=this.ws)==null||h.close(4008,"connect failed")}}async request_internal(f,o){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("gateway not connected");const r=Yh(),h={type:"req",id:r,method:f,params:o};return new Promise((m,g)=>{this.pending.set(r,{resolve:x=>m(x),reject:g}),this.ws.send(JSON.stringify(h))})}handleMessage(f){var h;let o;try{o=JSON.parse(f)}catch{return}const r=o;if(r.type==="event"){const m=o;if(m.event==="connect.challenge"){const v=m.payload;v!=null&&v.nonce&&(this.connectSent=!1,this.sendConnect());return}const g=this.eventHandlers.get(m.event);if(g)for(const v of g)try{v(m.payload)}catch{}const x=this.eventHandlers.get("*");if(x)for(const v of x)try{v(m)}catch{}return}if(r.type==="res"){const m=o,g=this.pending.get(m.id);if(!g)return;this.pending.delete(m.id),m.ok?g.resolve(m.payload):g.reject(new Error(((h=m.error)==null?void 0:h.message)??"request failed"))}}}const mm=S.createContext({authenticated:!1,connected:!1,connecting:!1,error:null,gateway:null,login:()=>{},logout:()=>{}});function Be(){return S.useContext(mm)}function uv(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}`}const mi="operator-ui-auth";function iv({children:i}){const[f,o]=S.useState(!1),[r,h]=S.useState(!1),[m,g]=S.useState(!1),[x,v]=S.useState(null),y=S.useRef(null),j=S.useRef(null);S.useEffect(()=>{const R=sessionStorage.getItem(mi);return R&&b(R),()=>{var z;(z=y.current)==null||z.stop()}},[]);const b=S.useCallback(R=>{var B;(B=y.current)==null||B.stop(),g(!0),v(null),j.current=R;const z=new nv(uv(),R);y.current=z,z.setCallbacks({onConnectedChange:Y=>{g(!1),h(Y),Y&&(o(!0),v(null),sessionStorage.setItem(mi,R))},onConnectError:Y=>{g(!1),h(!1),(Y.includes("unauthorized")||Y.includes("password"))&&(o(!1),sessionStorage.removeItem(mi)),v(Y)}}),z.start()},[]),T=S.useCallback(()=>{var R;(R=y.current)==null||R.stop(),y.current=null,j.current=null,o(!1),h(!1),v(null),sessionStorage.removeItem(mi)},[]);return s.jsx(mm.Provider,{value:{authenticated:f,connected:r,connecting:m,error:x,gateway:y.current,login:b,logout:T},children:i})}function ym(i){var f,o,r="";if(typeof i=="string"||typeof i=="number")r+=i;else if(typeof i=="object")if(Array.isArray(i)){var h=i.length;for(f=0;f<h;f++)i[f]&&(o=ym(i[f]))&&(r&&(r+=" "),r+=o)}else for(o in i)i[o]&&(r&&(r+=" "),r+=o);return r}function wt(){for(var i,f,o=0,r="",h=arguments.length;o<h;o++)(i=arguments[o])&&(f=ym(i))&&(r&&(r+=" "),r+=f);return r}const sv=[{to:"/",icon:Q1,label:"Dashboard",end:!0},{to:"/agents",icon:ua,label:"Agents"},{to:"/channels",icon:ia,label:"Channels"},{to:"/groups",icon:Ti,label:"Groups"},{to:"/skills",icon:Ai,label:"Skills"},{to:"/sessions",icon:Ei,label:"Sessions"},{to:"/cron",icon:nr,label:"Cron"},{to:"/settings",icon:hr,label:"Settings"}];function cv(){return s.jsxs("aside",{className:"flex w-60 shrink-0 flex-col border-r border-surface-200 bg-white",children:[s.jsxs("div",{className:"flex h-14 items-center gap-2.5 border-b border-surface-200 px-5",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary-600",children:s.jsx("span",{className:"text-sm font-bold text-white",children:"O"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-semibold text-surface-900",children:"Operator"}),s.jsx("p",{className:"text-[10px] font-medium text-surface-400",children:"OpenClaw"})]})]}),s.jsx("nav",{className:"flex-1 space-y-0.5 p-3",children:sv.map(({to:i,icon:f,label:o,...r})=>s.jsxs(nm,{to:i,end:"end"in r,className:({isActive:h})=>wt("flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors",h?"bg-primary-50 text-primary-700":"text-surface-600 hover:bg-surface-50 hover:text-surface-900"),children:[s.jsx(f,{className:"h-4 w-4"}),o]},i))}),s.jsx("div",{className:"border-t border-surface-200 p-3",children:s.jsx("p",{className:"px-3 text-[10px] text-surface-400",children:"v0.1.0 · OpenClaw Operator"})})]})}function rv(){const{logout:i,connected:f}=Be();return s.jsxs("div",{className:"flex h-screen overflow-hidden bg-surface-50",children:[s.jsx(cv,{}),s.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[s.jsxs("header",{className:"flex h-14 shrink-0 items-center justify-end gap-3 border-b border-surface-200 bg-white px-6",children:[s.jsx("div",{className:"flex items-center gap-2 text-xs",children:f?s.jsxs("span",{className:"badge-green",children:[s.jsx(hm,{className:"mr-1 h-3 w-3"}),"Connected"]}):s.jsxs("span",{className:"badge-red",children:[s.jsx(dm,{className:"mr-1 h-3 w-3"}),"Reconnecting…"]})}),s.jsx("button",{onClick:i,className:"btn-ghost !px-2 !py-1.5 text-surface-500 hover:text-surface-700",children:s.jsx(rm,{className:"h-4 w-4"})})]}),s.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:s.jsx(Ig,{})})]})]})}function hl({title:i,description:f,actions:o}){return s.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold text-surface-900",children:i}),f&&s.jsx("p",{className:"mt-1 text-sm text-surface-500",children:f})]}),o&&s.jsx("div",{className:"flex items-center gap-2",children:o})]})}function fv(){const{gateway:i}=Be(),f=Si(),[o,r]=S.useState(!1),[h,m]=S.useState(null),[g,x]=S.useState({name:"",identity:"",emoji:""});function v(j,b){x(T=>({...T,[j]:b}))}async function y(j){if(j.preventDefault(),!!i){if(!g.name.trim()){m("Agent name is required");return}r(!0),m(null);try{const b=await i.request("agents.create",{name:g.name.trim(),workspace:g.name.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),emoji:g.emoji.trim()||void 0}),T=b==null?void 0:b.agentId;T&&g.identity.trim()&&await i.request("agents.files.set",{agentId:T,name:"AGENTS.md",content:g.identity.trim()}),f(`/agents/${T??""}`)}catch(b){m(b instanceof Error?b.message:"Failed to create agent"),r(!1)}}}return s.jsxs("div",{className:"mx-auto max-w-2xl",children:[s.jsx(hl,{title:"Create Agent",description:"Set up a new AI agent"}),s.jsxs("form",{onSubmit:y,className:"card space-y-5",children:[s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Agent Name *"}),s.jsx("input",{className:"input",placeholder:"e.g. Support Assistant",value:g.name,onChange:j=>v("name",j.target.value)}),s.jsx("p",{className:"mt-1 text-xs text-surface-400",children:"The display name for this agent"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Emoji"}),s.jsx("input",{className:"input",placeholder:"e.g. 🤖",value:g.emoji,onChange:j=>v("emoji",j.target.value)}),s.jsx("p",{className:"mt-1 text-xs text-surface-400",children:"Optional icon for the agent"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Identity / System Prompt"}),s.jsx("textarea",{className:"input min-h-[120px] resize-y",placeholder:"Describe the agent's personality, role, and behavior...",value:g.identity,onChange:j=>v("identity",j.target.value)}),s.jsx("p",{className:"mt-1 text-xs text-surface-400",children:"This will be saved as the agent's AGENTS.md file"})]}),h&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-red-50 p-3 text-sm text-red-700",children:[s.jsx(Ni,{className:"mt-0.5 h-4 w-4 shrink-0"}),s.jsx("span",{children:h})]}),s.jsxs("div",{className:"flex justify-end gap-3 border-t border-surface-100 pt-5",children:[s.jsx("button",{type:"button",onClick:()=>f("/agents"),className:"btn-secondary",children:"Cancel"}),s.jsxs("button",{type:"submit",disabled:o,className:"btn-primary",children:[o?s.jsx(Yt,{className:"h-4 w-4 animate-spin"}):null,"Create Agent"]})]})]})]})}function lt({className:i}){return s.jsx("div",{className:wt("flex items-center justify-center py-12",i),children:s.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-surface-200 border-t-primary-600"})})}const gm=["settings","channels","groups","tools","skills","sessions","usage","chat"],ov={settings:{label:"Settings",icon:hr},channels:{label:"Channels",icon:ia},groups:{label:"Groups",icon:Ti},tools:{label:"Tools",icon:tv},skills:{label:"Skills",icon:Ai},sessions:{label:"Sessions",icon:Ei},usage:{label:"Usage",icon:sm},chat:{label:"Test Chat",icon:V1}},Ll=[{name:"IDENTITY.md",label:"Identity",description:"Agent name, style, emoji and persona basics",core:!0},{name:"SOUL.md",label:"Soul / Personality",description:"Character boundaries, tone, voice and behavioral rules",core:!0},{name:"AGENTS.md",label:"Instructions",description:"Operating instructions, memory usage guidelines and core directives",core:!0},{name:"TOOLS.md",label:"Tool Guidelines",description:"Custom tool usage conventions and constraints"},{name:"USER.md",label:"User Profile",description:"User preferences, preferred name and context"},{name:"MEMORY.md",label:"Long-term Memory",description:"Curated persistent memory across sessions"},{name:"HEARTBEAT.md",label:"Heartbeat Checklist",description:"Optional checklist for periodic heartbeat runs"},{name:"BOOTSTRAP.md",label:"Bootstrap (One-time)",description:"First-run ceremony script, deleted after initial setup"}];function dv({agentId:i,meta:f,initialContent:o,initialMissing:r}){const{gateway:h}=Be(),[m,g]=S.useState(o),[x,v]=S.useState(!1),[y,j]=S.useState("idle"),[b,T]=S.useState(!1);async function R(){if(h){v(!0),j("idle");try{await h.request("agents.files.set",{agentId:i,name:f.name,content:m}),j("saved"),T(!1),setTimeout(()=>j("idle"),2500)}catch{j("error")}v(!1)}}return s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"mb-3 flex items-center justify-between",children:s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-surface-900",children:f.label}),s.jsx("code",{className:"rounded bg-surface-100 px-1.5 py-0.5 text-[10px] font-mono text-surface-500",children:f.name}),r&&!b&&s.jsx("span",{className:"rounded bg-surface-100 px-1.5 py-0.5 text-[10px] text-surface-400",children:"Not created"}),b&&s.jsx("span",{className:"rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-600",children:"Unsaved"})]}),s.jsx("p",{className:"mt-0.5 text-xs text-surface-400",children:f.description})]})}),s.jsx("textarea",{className:"input min-h-[160px] resize-y font-mono text-xs leading-relaxed",value:m,onChange:z=>{g(z.target.value),T(!0),j("idle")},placeholder:`Write ${f.label.toLowerCase()} content here...`,spellCheck:!1}),s.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[s.jsxs("button",{onClick:R,disabled:x||!b,className:"btn-primary !py-1.5 !text-xs",children:[x?s.jsx(Yt,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(fm,{className:"h-3.5 w-3.5"}),"Save"]}),y==="saved"&&s.jsx("span",{className:"text-xs text-emerald-600",children:"Saved"}),y==="error"&&s.jsx("span",{className:"text-xs text-red-600",children:"Save failed"})]})]})}function hv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState(new Map),[m,g]=S.useState(!0),[x,v]=S.useState(!1);if(S.useEffect(()=>{if(!f||!o)return;const R=new Map;f.request("agents.files.list",{agentId:i}).then(async z=>{const B=Array.isArray(z==null?void 0:z.files)?z.files:[];for(const G of B)R.set(G.name,G);const H=Ll.map(G=>G.name).filter(G=>!R.has(G)||R.get(G).content===void 0),V=await Promise.allSettled(H.map(G=>f.request("agents.files.get",{agentId:i,name:G}).then(k=>({name:G,file:k==null?void 0:k.file}))));for(const G of V)G.status==="fulfilled"&&G.value.file&&R.set(G.value.name,G.value.file);for(const G of Ll)R.has(G.name)||R.set(G.name,{name:G.name,missing:!0,content:""});h(R)}).catch(()=>{}).finally(()=>g(!1))},[f,o,i]),m)return s.jsx(lt,{});const y=Ll.filter(R=>R.core),b=x?Ll:y,T={total:Ll.length,created:Ll.filter(R=>{const z=r.get(R.name);return z&&!z.missing}).length};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("p",{className:"text-sm text-surface-500",children:x?"All workspace files":"Core configuration files"}),s.jsxs("span",{className:"text-xs text-surface-400",children:[T.created," / ",T.total," files active"]})]}),s.jsxs("button",{onClick:()=>v(!x),className:wt("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",x?"bg-primary-50 text-primary-700 hover:bg-primary-100":"bg-surface-100 text-surface-600 hover:bg-surface-200"),children:[s.jsx(hr,{className:"h-3.5 w-3.5"}),x?"Advanced Mode":"Basic Mode"]})]}),!x&&s.jsxs("div",{className:"rounded-lg bg-surface-50 border border-surface-200 p-3 text-xs text-surface-500",children:["Showing the 3 core files that define your agent's behavior. Switch to"," ",s.jsx("strong",{children:"Advanced Mode"})," to edit all ",Ll.length," workspace files including tools, memory, heartbeat, and bootstrap."]}),s.jsx("div",{className:"space-y-4",children:b.map(R=>{const z=r.get(R.name);return s.jsx(dv,{agentId:i,meta:R,initialContent:(z==null?void 0:z.content)??"",initialMissing:(z==null?void 0:z.missing)??!0},R.name)})}),x&&s.jsxs("div",{className:"rounded-lg bg-surface-50 border border-surface-200 p-3",children:[s.jsx("h4",{className:"text-xs font-semibold text-surface-700 mb-2",children:"File Reference"}),s.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2 text-[11px] text-surface-500",children:Ll.map(R=>{const z=r.get(R.name),B=z&&!z.missing;return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:wt("h-1.5 w-1.5 rounded-full",B?"bg-emerald-500":"bg-surface-300")}),s.jsx("span",{className:"font-mono",children:R.name}),B&&(z==null?void 0:z.size)!=null&&s.jsxs("span",{className:"text-surface-400",children:["(",z.size,"B)"]})]},R.name)})})]})]})}function mv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState([]),[m,g]=S.useState([]),[x,v]=S.useState(!0);if(S.useEffect(()=>{!f||!o||Promise.all([f.request("config.get").then(j=>{var T;const b=(T=j==null?void 0:j.config)==null?void 0:T.bindings;return Array.isArray(b)?b:[]}),f.request("channels.status",{}).then(j=>{const b=j==null?void 0:j.channels;return b&&typeof b=="object"?Object.keys(b):[]})]).then(([j,b])=>{h(j),g(b),v(!1)}).catch(()=>v(!1))},[f,o]),x)return s.jsx(lt,{});const y=r.filter(j=>j.agentId===i);return s.jsxs("div",{children:[s.jsx("div",{className:"mb-4 flex items-center justify-between",children:s.jsxs("p",{className:"text-sm text-surface-500",children:["Channels bound to this agent via"," ",s.jsx("code",{className:"rounded bg-surface-100 px-1 font-mono text-xs",children:"bindings"})]})}),y.length===0?s.jsx("div",{className:"rounded-lg border-2 border-dashed border-surface-200 py-8 text-center text-sm text-surface-400",children:"No channel bindings for this agent. Configure bindings in Settings → Config."}):s.jsx("div",{className:"space-y-2",children:y.map((j,b)=>s.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-surface-200 p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ia,{className:"h-4 w-4 text-surface-500"}),s.jsx("span",{className:"text-sm font-medium",children:j.match.channel})]}),j.match.peer&&s.jsxs("span",{className:"badge-gray",children:[j.match.peer.kind,": ",j.match.peer.id]})]},b))}),s.jsxs("div",{className:"mt-4 rounded-lg bg-surface-50 p-3 text-xs text-surface-500",children:["Available channels: ",m.join(", ")||"None"]})]})}function yv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState(null),[m,g]=S.useState(!0);if(S.useEffect(()=>{!f||!o||f.request("config.get").then(j=>h((j==null?void 0:j.config)??null)).catch(()=>{}).finally(()=>g(!1))},[f,o]),m)return s.jsx(lt,{});const x=r==null?void 0:r.bindings,y=(Array.isArray(x)?x:[]).filter(j=>{var b;return j.agentId===i&&((b=j.match.peer)==null?void 0:b.kind)==="group"});return s.jsxs("div",{children:[s.jsx("p",{className:"mb-4 text-sm text-surface-500",children:"Groups routed to this agent"}),y.length===0?s.jsx("div",{className:"rounded-lg border-2 border-dashed border-surface-200 py-8 text-center text-sm text-surface-400",children:"No group bindings for this agent"}):s.jsx("div",{className:"space-y-2",children:y.map((j,b)=>s.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-surface-200 p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ti,{className:"h-4 w-4 text-surface-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:j.match.peer.id}),s.jsx("p",{className:"text-xs text-surface-400",children:j.match.channel})]})]}),s.jsx("span",{className:"badge-primary",children:"Group"})]},b))})]})}function gv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState([]),[m,g]=S.useState(!0);return S.useEffect(()=>{!f||!o||f.request("tools.catalog",{agentId:i}).then(x=>{const y=(Array.isArray(x==null?void 0:x.groups)?x.groups:[]).flatMap(j=>Array.isArray(j.tools)?j.tools:[]);h(y)}).catch(()=>{}).finally(()=>g(!1))},[f,o,i]),m?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsxs("p",{className:"mb-4 text-sm text-surface-500",children:["Tools available to this agent (",r.length,")"]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[r.map(x=>s.jsxs("div",{className:"rounded-lg border border-surface-200 p-3",children:[s.jsx("p",{className:"text-sm font-medium text-surface-900",children:x.label||x.id}),x.description&&s.jsx("p",{className:"mt-0.5 text-xs text-surface-400 line-clamp-2",children:x.description}),x.pluginId&&s.jsxs("p",{className:"mt-1 text-[10px] text-surface-400",children:["Plugin: ",x.pluginId]})]},x.id)),r.length===0&&s.jsx("p",{className:"col-span-2 py-8 text-center text-sm text-surface-400",children:"No tools data available"})]})]})}function vv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState([]),[m,g]=S.useState(!0);return S.useEffect(()=>{!f||!o||f.request("skills.status",{agentId:i}).then(x=>h(Array.isArray(x==null?void 0:x.skills)?x.skills:[])).catch(()=>{}).finally(()=>g(!1))},[f,o,i]),m?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsxs("p",{className:"mb-4 text-sm text-surface-500",children:["Skills for this agent (",r.length,")"]}),s.jsxs("div",{className:"space-y-2",children:[r.map(x=>{const v=x.eligible&&!x.disabled&&!x.blockedByAllowlist;return s.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-surface-200 p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[x.emoji?s.jsx("span",{className:"text-lg",children:x.emoji}):s.jsx(Ai,{className:"h-4 w-4 text-surface-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:x.name}),x.description&&s.jsx("p",{className:"text-xs text-surface-400 line-clamp-1",children:x.description}),s.jsxs("p",{className:"text-[10px] text-surface-400 font-mono",children:[x.skillKey," · ",x.source]})]})]}),v?s.jsx("span",{className:"badge-green",children:"Enabled"}):x.disabled?s.jsx("span",{className:"badge-gray",children:"Disabled"}):x.blockedByAllowlist?s.jsx("span",{className:"rounded bg-amber-50 px-2 py-0.5 text-xs text-amber-600",children:"Blocked"}):s.jsx("span",{className:"badge-gray",children:"Ineligible"})]},x.skillKey)}),r.length===0&&s.jsx("p",{className:"py-8 text-center text-sm text-surface-400",children:"No skills data available"})]})]})}function pv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState([]),[m,g]=S.useState(!0);return S.useEffect(()=>{!f||!o||f.request("sessions.list",{agentId:i}).then(x=>h(Array.isArray(x==null?void 0:x.sessions)?x.sessions:[])).catch(()=>{}).finally(()=>g(!1))},[f,o,i]),m?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsx("p",{className:"mb-4 text-sm text-surface-500",children:"Active sessions for this agent"}),s.jsxs("div",{className:"space-y-2",children:[r.map(x=>s.jsxs("div",{className:"rounded-lg border border-surface-200 p-3",children:[s.jsx("p",{className:"text-sm font-mono text-surface-700",children:x.key}),s.jsxs("div",{className:"mt-1 flex items-center gap-4 text-xs text-surface-400",children:[x.messageCount!=null&&s.jsxs("span",{children:[x.messageCount," messages"]}),x.lastActiveAt&&s.jsxs("span",{children:["Last active: ",x.lastActiveAt]})]})]},x.key)),r.length===0&&s.jsx("p",{className:"py-8 text-center text-sm text-surface-400",children:"No active sessions"})]})]})}function xv(){return s.jsxs("div",{className:"rounded-lg border-2 border-dashed border-surface-200 py-12 text-center",children:[s.jsx(sm,{className:"mx-auto h-8 w-8 text-surface-300"}),s.jsx("p",{className:"mt-2 text-sm text-surface-500",children:"Usage statistics coming soon"})]})}function Vn(i){if(!i)return"";if(typeof i=="string")return i;if(Array.isArray(i))return i.map(o=>{if(typeof o=="string")return o;if(o&&typeof o=="object"){const r=o;if(typeof r.text=="string")return r.text;if(typeof r.content=="string")return r.content}return""}).filter(Boolean).join("");const f=i;return typeof f.text=="string"?f.text:typeof f.content=="string"?f.content:Array.isArray(f.content)?Vn(f.content):""}function bv({agentId:i}){const{gateway:f,connected:o}=Be(),[r,h]=S.useState(""),[m,g]=S.useState([]),[x,v]=S.useState(!1),[y,j]=S.useState(""),b=`agent:${i}:operator-ui-test`,T=S.useRef(null),R=S.useRef(null),z=S.useRef("");S.useEffect(()=>{!f||!o||f.request("chat.history",{sessionKey:b,limit:50}).then(H=>{if(!Array.isArray(H==null?void 0:H.messages))return;const V=[];for(const G of H.messages){const k=G,ee=k.role==="user"?"user":k.role==="assistant"?"assistant":null;if(!ee)continue;const ie=Vn(k.content??k.text??k.message??"");ie&&V.push({role:ee,content:ie})}V.length>0&&g(V)}).catch(()=>{})},[f,o,i]),S.useEffect(()=>f?f.on("chat",V=>{const G=V;if(!(!G.runId||G.runId!==T.current))if(G.state==="delta"){const k=Vn(G.message);k&&(z.current+=k,j(z.current))}else if(G.state==="final"){const k=Vn(G.message)||z.current;T.current=null,z.current="",j(""),v(!1),k&&g(ee=>[...ee,{role:"assistant",content:k}])}else G.state==="error"?(T.current=null,z.current="",j(""),v(!1),g(k=>[...k,{role:"error",content:G.errorMessage??"Agent error"}])):G.state==="aborted"&&(T.current=null,z.current="",j(""),v(!1),g(k=>[...k,{role:"system",content:"Run was aborted"}]))}):void 0,[f]),S.useEffect(()=>{var H;(H=R.current)==null||H.scrollTo({top:R.current.scrollHeight,behavior:"smooth"})},[m,y]);async function B(){if(!r.trim()||x||!f)return;const H=r.trim();h(""),g(G=>[...G,{role:"user",content:H}]),v(!0),z.current="",j("");const V=`op-chat-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{const G=await f.request("chat.send",{sessionKey:b,message:H,idempotencyKey:V});if((G==null?void 0:G.status)==="error"){v(!1),g(k=>[...k,{role:"error",content:G.summary??"Failed to start"}]);return}T.current=(G==null?void 0:G.runId)??V,setTimeout(()=>{T.current&&f.request("chat.history",{sessionKey:b,limit:5}).then(k=>{if(!T.current||!Array.isArray(k==null?void 0:k.messages))return;const ee=k.messages[k.messages.length-1];if((ee==null?void 0:ee.role)==="assistant"){const ie=Vn(ee.content??ee.text??"");ie&&(T.current=null,z.current="",j(""),v(!1),g(F=>[...F,{role:"assistant",content:ie}]))}}).catch(()=>{})},15e3)}catch(G){v(!1),g(k=>[...k,{role:"error",content:G instanceof Error?G.message:"Failed"}])}}function Y(){f&&(f.request("sessions.reset",{key:b}).catch(()=>{}),g([]),j(""))}return s.jsxs("div",{className:"flex h-[500px] flex-col rounded-xl border border-surface-200",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-surface-100 px-4 py-2",children:[s.jsx("p",{className:"text-xs text-surface-400 font-mono",children:b}),s.jsx("button",{onClick:Y,className:"text-xs text-surface-400 hover:text-red-600 transition-colors",children:"Clear history"})]}),s.jsxs("div",{ref:R,className:"flex-1 overflow-y-auto p-4 space-y-3",children:[m.length===0&&!y&&s.jsx("p",{className:"py-12 text-center text-sm text-surface-400",children:"Send a message to test this agent"}),m.map((H,V)=>s.jsx("div",{className:wt("max-w-[80%] rounded-lg px-4 py-2.5 text-sm whitespace-pre-wrap",H.role==="user"?"ml-auto bg-primary-600 text-white":H.role==="error"?"bg-red-50 text-red-700":H.role==="system"?"mx-auto bg-surface-50 text-surface-500 text-center text-xs":"bg-surface-100 text-surface-900"),children:H.content},V)),y&&s.jsxs("div",{className:"max-w-[80%] rounded-lg px-4 py-2.5 text-sm bg-surface-100 text-surface-900 whitespace-pre-wrap",children:[y,s.jsx("span",{className:"inline-block w-1.5 h-4 bg-primary-500 animate-pulse ml-0.5 align-text-bottom"})]}),x&&!y&&s.jsxs("div",{className:"max-w-[80%] rounded-lg px-4 py-2.5 text-sm bg-surface-100 text-surface-400 flex items-center gap-2",children:[s.jsx(Yt,{className:"h-3.5 w-3.5 animate-spin"}),"Thinking..."]})]}),s.jsxs("div",{className:"border-t border-surface-200 p-3 flex gap-2",children:[s.jsx("input",{className:"input flex-1",placeholder:"Type a message...",value:r,onChange:H=>h(H.target.value),onKeyDown:H=>H.key==="Enter"&&!H.shiftKey&&B(),disabled:x}),s.jsx("button",{onClick:B,disabled:x||!r.trim(),className:"btn-primary",children:x?s.jsx(Yt,{className:"h-4 w-4 animate-spin"}):"Send"})]})]})}function Sv(i,f){const o=`/agents/${f}`,r=i.startsWith(o)?i.slice(o.length).replace(/^\//,""):"";return r&&gm.includes(r)?r:"settings"}function jv({tab:i,agentId:f}){switch(i){case"settings":return s.jsx(hv,{agentId:f});case"channels":return s.jsx(mv,{agentId:f});case"groups":return s.jsx(yv,{agentId:f});case"tools":return s.jsx(gv,{agentId:f});case"skills":return s.jsx(vv,{agentId:f});case"sessions":return s.jsx(pv,{agentId:f});case"usage":return s.jsx(xv,{});case"chat":return s.jsx(bv,{agentId:f})}}function Gh(){var B;const{agentId:i}=qg(),f=kt(),o=Si(),{gateway:r,connected:h}=Be(),[m,g]=S.useState(null),[x,v]=S.useState(!0),[y,j]=S.useState(!1),b=Sv(f.pathname,i??""),T=S.useCallback(()=>{!r||!h||r.request("agents.list",{}).then(Y=>{const V=(Array.isArray(Y==null?void 0:Y.agents)?Y.agents:[]).find(G=>G.id===i);g(V??null)}).catch(()=>{}).finally(()=>v(!1))},[r,h,i]);if(S.useEffect(()=>{T()},[T]),x)return s.jsx(lt,{});if(!m)return s.jsxs("div",{className:"flex flex-col items-center py-20",children:[s.jsx(Ni,{className:"h-8 w-8 text-surface-300"}),s.jsxs("p",{className:"mt-2 text-sm text-surface-500",children:['Agent "',i,'" not found']})]});async function R(){if(!(!r||!confirm(`Delete agent "${i}"? This cannot be undone.`))){j(!0);try{await r.request("agents.delete",{id:i}),o("/agents",{replace:!0})}catch{j(!1)}}}function z(Y){const H=`/agents/${i}`;o(Y==="settings"?H:`${H}/${Y}`)}return s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-primary-100",children:s.jsx(ua,{className:"h-6 w-6 text-primary-600"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-semibold text-surface-900",children:((B=m.identity)==null?void 0:B.name)||m.name||m.id}),s.jsxs("p",{className:"text-sm text-surface-400",children:["ID: ",s.jsx("code",{className:"font-mono",children:m.id}),m.model&&s.jsxs(s.Fragment,{children:[" · Model: ",m.model]})]})]})]}),s.jsxs("button",{onClick:R,disabled:y,className:"btn-ghost text-red-600 hover:text-red-700 hover:bg-red-50",children:[s.jsx(mr,{className:"h-4 w-4"}),"Delete"]})]}),s.jsx("div",{className:"mb-6 flex gap-1 overflow-x-auto border-b border-surface-200",children:gm.map(Y=>{const{label:H,icon:V}=ov[Y],G=Y===b;return s.jsxs("button",{onClick:()=>z(Y),className:wt("flex items-center gap-2 whitespace-nowrap border-b-2 px-4 py-2.5 text-sm font-medium transition-colors",G?"border-primary-600 text-primary-600":"border-transparent text-surface-500 hover:text-surface-700"),children:[s.jsx(V,{className:"h-4 w-4"}),H]},Y)})}),s.jsx(jv,{tab:b,agentId:i})]})}function yr({icon:i,title:f,description:o,action:r}){return s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-surface-200 py-16",children:[s.jsx("div",{className:"mb-4 text-surface-300",children:i}),s.jsx("h3",{className:"text-sm font-semibold text-surface-900",children:f}),s.jsx("p",{className:"mt-1 text-sm text-surface-500",children:o}),r&&s.jsx("div",{className:"mt-4",children:r})]})}function Nv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState(""),[g,x]=S.useState(!0);return S.useEffect(()=>{!i||!f||i.request("agents.list",{}).then(v=>{r(Array.isArray(v==null?void 0:v.agents)?v.agents:[]),m((v==null?void 0:v.defaultId)??"")}).catch(()=>{}).finally(()=>x(!1))},[i,f]),g?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsx(hl,{title:"Agents",description:"Create and manage your AI agents",actions:s.jsxs(Vt,{to:"/agents/new",className:"btn-primary",children:[s.jsx(Lh,{className:"h-4 w-4"}),"New Agent"]})}),o.length===0?s.jsx(yr,{icon:s.jsx(ua,{className:"h-12 w-12"}),title:"No agents yet",description:"Create your first AI agent to get started",action:s.jsxs(Vt,{to:"/agents/new",className:"btn-primary",children:[s.jsx(Lh,{className:"h-4 w-4"}),"Create Agent"]})}):s.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:o.map(v=>{var y;return s.jsxs(Vt,{to:`/agents/${v.id}`,className:"card group flex flex-col transition-all hover:border-primary-200 hover:shadow-sm",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary-100",children:s.jsx(ua,{className:"h-5 w-5 text-primary-600"})}),s.jsx(cm,{className:"h-4 w-4 text-surface-300 transition-colors group-hover:text-primary-500"})]}),s.jsxs("div",{className:"mt-3 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-surface-900",children:((y=v.identity)==null?void 0:y.name)||v.name||v.id}),v.id===h&&s.jsx(F1,{className:"h-3.5 w-3.5 fill-amber-400 text-amber-400"})]}),s.jsxs("p",{className:"mt-0.5 text-xs text-surface-400",children:["ID: ",s.jsx("code",{className:"font-mono",children:v.id})]})]}),v.model&&s.jsx("div",{className:"mt-3 border-t border-surface-100 pt-3",children:s.jsxs("p",{className:"text-xs text-surface-500",children:["Model: ",s.jsx("span",{className:"font-medium text-surface-700",children:v.model})]})})]},v.id)})})]})}const Ev={whatsapp:"💬",telegram:"✈️",discord:"🎮",slack:"💼",signal:"🔒",imessage:"💬",bluebubbles:"💬",googlechat:"💬",msteams:"🏢",feishu:"🐦",matrix:"🔗",webchat:"🌐"};function Av(i){if(!i||typeof i!="object")return[];const f=i,o=f.channels??{},r=f.channelAccounts??{},h=[];for(const m of Object.keys(o)){const g=o[m],x=r[m]??{},v=Object.entries(x).map(([y,j])=>({id:y,status:String((j==null?void 0:j.status)??"unknown"),label:j==null?void 0:j.label,phone:j==null?void 0:j.phone}));h.push({id:m,configured:(g==null?void 0:g.configured)??!1,accounts:v})}return h}function Tv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState(!0),[g,x]=S.useState(null);function v(){!i||!f||(m(!0),i.request("channels.status",{}).then(j=>r(Av(j))).catch(()=>{}).finally(()=>m(!1)))}S.useEffect(()=>{v()},[i,f]);async function y(j,b){if(!(!i||!confirm(`Logout from ${j} account ${b}?`))){x(`${j}:${b}`);try{await i.request("channels.logout",{channel:j,accountId:b}),v()}catch{}x(null)}}return h?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsx(hl,{title:"Channels",description:"Monitor and manage your messaging channels",actions:s.jsxs("button",{onClick:v,className:"btn-secondary",children:[s.jsx(dr,{className:"h-4 w-4"}),"Refresh"]})}),s.jsxs("div",{className:"space-y-3",children:[o.map(j=>{const b=j.accounts.some(R=>R.status==="online"),T=Ev[j.id]??"📡";return s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-2xl",children:T}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-surface-900",children:j.id}),s.jsx("p",{className:"text-xs text-surface-400",children:j.accounts.length>0?`${j.accounts.length} account(s)`:j.configured?"Configured":"Not configured"})]})]}),s.jsx("div",{className:"flex items-center gap-2",children:b?s.jsxs("span",{className:"badge-green",children:[s.jsx(hm,{className:"mr-1 h-3 w-3"}),"Online"]}):j.configured?s.jsxs("span",{className:"badge-gray",children:[s.jsx(dm,{className:"mr-1 h-3 w-3"}),"Offline"]}):s.jsx("span",{className:"badge-gray",children:"Not Configured"})})]}),j.accounts.length>0&&s.jsx("div",{className:"mt-3 space-y-2 border-t border-surface-100 pt-3",children:j.accounts.map(R=>s.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-surface-50 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`h-2 w-2 rounded-full ${R.status==="online"?"bg-emerald-500":"bg-surface-300"}`}),s.jsx("span",{className:"text-sm text-surface-700",children:R.label||R.id}),R.phone&&s.jsx("span",{className:"text-xs text-surface-400",children:R.phone})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-surface-400",children:R.status}),R.status==="online"&&s.jsx("button",{onClick:()=>y(j.id,R.id),disabled:g===`${j.id}:${R.id}`,className:"btn-ghost !px-2 !py-1 text-xs text-surface-500",children:g===`${j.id}:${R.id}`?s.jsx(Yt,{className:"h-3 w-3 animate-spin"}):s.jsx(rm,{className:"h-3 w-3"})})]})]},R.id))})]},j.id)}),o.length===0&&s.jsxs("div",{className:"card py-12 text-center",children:[s.jsx(ia,{className:"mx-auto h-8 w-8 text-surface-300"}),s.jsx("p",{className:"mt-2 text-sm text-surface-500",children:"No channels configured. Add channels in your openclaw.json configuration."})]})]})]})}function zv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState(!0),[g,x]=S.useState(null);function v(){!i||!f||i.request("cron.list",{}).then(T=>r(Array.isArray(T==null?void 0:T.jobs)?T.jobs:[])).catch(()=>r([])).finally(()=>m(!1))}S.useEffect(()=>{v()},[i,f]);async function y(T,R){if(i){x(T);try{await i.request("cron.update",{id:T,enabled:!R}),r(z=>z.map(B=>B.id===T?{...B,enabled:!R}:B))}catch{}x(null)}}async function j(T){if(i){x(T);try{await i.request("cron.run",{id:T})}catch{}x(null)}}async function b(T){if(!(!i||!confirm("Remove this cron job?"))){x(T);try{await i.request("cron.remove",{id:T}),r(R=>R.filter(z=>z.id!==T))}catch{}x(null)}}return h?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsx(hl,{title:"Cron Jobs",description:"Manage scheduled tasks"}),o.length===0?s.jsx(yr,{icon:s.jsx(nr,{className:"h-12 w-12"}),title:"No cron jobs",description:"Scheduled tasks will appear here. Create them via the agent chat."}):s.jsx("div",{className:"space-y-2",children:o.map(T=>s.jsxs("div",{className:"card flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-amber-50",children:s.jsx(nr,{className:"h-4 w-4 text-amber-600"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-surface-900",children:T.message||T.id}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-surface-400",children:[s.jsx("code",{className:"font-mono",children:T.schedule}),T.agentId&&s.jsxs("span",{children:["Agent: ",T.agentId]}),T.nextRunAt&&s.jsxs("span",{children:["Next: ",T.nextRunAt]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>j(T.id),disabled:g===T.id,className:"btn-ghost !px-2 !py-1.5 text-surface-400 hover:text-emerald-600",title:"Run now",children:g===T.id?s.jsx(Yt,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(Bh,{className:"h-3.5 w-3.5"})}),s.jsx("button",{onClick:()=>y(T.id,T.enabled),className:"btn-ghost !px-2 !py-1.5 text-surface-400 hover:text-amber-600",title:T.enabled?"Pause":"Resume",children:T.enabled?s.jsx(J1,{className:"h-3.5 w-3.5"}):s.jsx(Bh,{className:"h-3.5 w-3.5"})}),s.jsx("button",{onClick:()=>b(T.id),className:"btn-ghost !px-2 !py-1.5 text-surface-400 hover:text-red-600",title:"Remove",children:s.jsx(mr,{className:"h-3.5 w-3.5"})})]})]},T.id))})]})}function Cv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState(!0),[h,m]=S.useState([]),[g,x]=S.useState(""),[v,y]=S.useState([]),[j,b]=S.useState(0);if(S.useEffect(()=>{if(!i||!f)return;let z=!1;return r(!0),Promise.all([i.request("agents.list",{}).catch(()=>null),i.request("channels.status",{}).catch(()=>null),i.request("sessions.list",{}).catch(()=>null)]).then(([B,Y,H])=>{if(z)return;const V=Array.isArray(B==null?void 0:B.agents)?B.agents:[];m(V),x((B==null?void 0:B.defaultId)??"");const G=[];if(Y!=null&&Y.channels&&typeof Y.channels=="object"){const k=Y.channelAccounts??{};for(const[ee,ie]of Object.entries(Y.channels)){const F=k[ee];let X=!1;F&&typeof F=="object"&&(X=Object.values(F).some(se=>se&&typeof se=="object"&&se.status==="online")),G.push({id:ee,configured:(ie==null?void 0:ie.configured)??!1,online:X,label:ee})}}y(G),b(typeof(H==null?void 0:H.count)=="number"?H.count:Array.isArray(H==null?void 0:H.sessions)?H.sessions.length:0),r(!1)}),()=>{z=!0}},[i,f]),o)return s.jsx(lt,{});const T=v.filter(z=>z.online),R=[{label:"Active Agents",value:h.length,icon:ua,color:"bg-primary-50 text-primary-600",to:"/agents"},{label:"Channels Online",value:`${T.length} / ${v.length}`,icon:ia,color:"bg-emerald-50 text-emerald-600",to:"/channels"},{label:"Active Sessions",value:j,icon:Ei,color:"bg-blue-50 text-blue-600",to:"/sessions"},{label:"System Health",value:"OK",icon:H1,color:"bg-amber-50 text-amber-600",to:"/settings"}];return s.jsxs("div",{children:[s.jsx(hl,{title:"Dashboard",description:"Overview of your AI assistant system"}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:R.map(z=>s.jsxs(Vt,{to:z.to,className:"card group hover:border-primary-200 transition-colors",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${z.color}`,children:s.jsx(z.icon,{className:"h-5 w-5"})}),s.jsx(q1,{className:"h-4 w-4 text-surface-300 transition-colors group-hover:text-primary-500"})]}),s.jsx("p",{className:"mt-3 text-2xl font-semibold text-surface-900",children:z.value}),s.jsx("p",{className:"text-sm text-surface-500",children:z.label})]},z.label))}),s.jsxs("div",{className:"mt-8 grid gap-6 lg:grid-cols-2",children:[s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-semibold text-surface-900",children:"Agents"}),s.jsx(Vt,{to:"/agents",className:"text-xs font-medium text-primary-600 hover:text-primary-700",children:"View all →"})]}),s.jsx("div",{className:"space-y-2",children:h.length===0?s.jsx("p",{className:"py-4 text-center text-sm text-surface-400",children:"No agents configured"}):h.slice(0,5).map(z=>{var B;return s.jsxs(Vt,{to:`/agents/${z.id}`,className:"flex items-center justify-between rounded-lg p-3 transition-colors hover:bg-surface-50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary-100 text-primary-700",children:s.jsx(ua,{className:"h-4 w-4"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-surface-900",children:((B=z.identity)==null?void 0:B.name)||z.name||z.id}),s.jsxs("p",{className:"text-xs text-surface-400",children:["ID: ",z.id]})]})]}),z.id===g&&s.jsx("span",{className:"badge-primary",children:"Default"})]},z.id)})})]}),s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-semibold text-surface-900",children:"Channels"}),s.jsx(Vt,{to:"/channels",className:"text-xs font-medium text-primary-600 hover:text-primary-700",children:"View all →"})]}),s.jsx("div",{className:"space-y-2",children:v.length===0?s.jsx("p",{className:"py-4 text-center text-sm text-surface-400",children:"No channels configured"}):v.slice(0,6).map(z=>s.jsxs("div",{className:"flex items-center justify-between rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-surface-100",children:s.jsx(ia,{className:"h-4 w-4 text-surface-600"})}),s.jsx("p",{className:"text-sm font-medium text-surface-900",children:z.label})]}),z.online?s.jsx("span",{className:"badge-green",children:"Online"}):z.configured?s.jsx("span",{className:"badge-gray",children:"Offline"}):s.jsx("span",{className:"badge-gray",children:"Not Configured"})]},z.id))})]})]})]})}function Mv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState([]),[g,x]=S.useState(!0);if(S.useEffect(()=>{!i||!f||Promise.all([i.request("config.get"),i.request("agents.list",{})]).then(([b,T])=>{var z;const R=(z=b==null?void 0:b.config)==null?void 0:z.bindings;r(Array.isArray(R)?R:[]),m(Array.isArray(T==null?void 0:T.agents)?T.agents:[]),x(!1)}).catch(()=>x(!1))},[i,f]),g)return s.jsx(lt,{});const v=o.filter(b=>{var T;return((T=b.match.peer)==null?void 0:T.kind)==="group"||b.match.guildId}).map(b=>{var T;return{...b,_displayName:((T=b.match.peer)==null?void 0:T.id)??b.match.guildId??"Unknown group"}}),y=new Map(h.map(b=>[b.id,b.name||b.id])),j=v.reduce((b,T)=>{const R=T.match.channel;return b[R]||(b[R]=[]),b[R].push(T),b},{});return s.jsxs("div",{children:[s.jsx(hl,{title:"Groups",description:"View and manage group-to-agent bindings across all channels"}),v.length===0?s.jsx(yr,{icon:s.jsx(Ti,{className:"h-12 w-12"}),title:"No group bindings",description:"Group bindings route specific groups to specific agents. Configure them in Settings → Config under 'bindings'."}):s.jsx("div",{className:"space-y-6",children:Object.entries(j).map(([b,T])=>s.jsxs("div",{children:[s.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[s.jsx(ia,{className:"h-4 w-4 text-surface-500"}),s.jsx("h2",{className:"text-sm font-semibold text-surface-700 uppercase tracking-wide",children:b}),s.jsx("span",{className:"badge-gray",children:T.length})]}),s.jsx("div",{className:"space-y-2",children:T.map((R,z)=>s.jsxs("div",{className:"card flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-surface-100",children:s.jsx(k1,{className:"h-5 w-5 text-surface-600"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-surface-900",children:R._displayName}),R.comment&&s.jsx("p",{className:"text-xs text-surface-400",children:R.comment})]})]}),s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs(Vt,{to:`/agents/${R.agentId}`,className:"flex items-center gap-1.5 rounded-lg bg-primary-50 px-2.5 py-1 text-xs font-medium text-primary-700 hover:bg-primary-100 transition-colors",children:[s.jsx(ua,{className:"h-3 w-3"}),y.get(R.agentId)??R.agentId]})})]},z))})]},b))}),s.jsxs("div",{className:"mt-8 card bg-surface-50 border-surface-200",children:[s.jsx("h3",{className:"text-sm font-semibold text-surface-700 mb-2",children:"Group Behavior Reference"}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 text-xs text-surface-500",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(B1,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-surface-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-surface-700",children:"Mention Mode"}),s.jsx("p",{children:"Bot only responds when @mentioned in the group"})]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(K1,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-surface-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-surface-700",children:"Always Mode"}),s.jsx("p",{children:"Bot responds to all messages in the group"})]})]})]})]})]})}function Ov(){const{login:i,connecting:f,error:o}=Be(),[r,h]=S.useState("");function m(g){g.preventDefault(),r.trim()&&i(r)}return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white",children:s.jsxs("div",{className:"w-full max-w-sm",children:[s.jsxs("div",{className:"mb-8 text-center",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-primary-600",children:s.jsx("span",{className:"text-2xl font-bold text-white",children:"O"})}),s.jsx("h1",{className:"text-2xl font-semibold text-surface-900",children:"Operator"}),s.jsx("p",{className:"mt-1 text-sm text-surface-500",children:"Sign in to manage your AI agents"})]}),s.jsxs("form",{onSubmit:m,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"label",children:"Password"}),s.jsxs("div",{className:"relative",children:[s.jsx(Z1,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400"}),s.jsx("input",{id:"password",type:"password",value:r,onChange:g=>h(g.target.value),className:"input !pl-10",placeholder:"Enter operator password",autoFocus:!0,disabled:f})]})]}),o&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-red-50 p-3 text-sm text-red-700",children:[s.jsx(Ni,{className:"mt-0.5 h-4 w-4 shrink-0"}),s.jsx("span",{children:o})]}),s.jsx("button",{type:"submit",disabled:f||!r.trim(),className:"btn-primary w-full",children:f?s.jsxs(s.Fragment,{children:[s.jsx(Yt,{className:"h-4 w-4 animate-spin"}),"Connecting..."]}):"Sign In"})]}),s.jsxs("p",{className:"mt-6 text-center text-xs text-surface-400",children:["Configure password in"," ",s.jsx("code",{className:"rounded bg-surface-100 px-1 py-0.5 font-mono text-[10px]",children:"openclaw.json"})]})]})})}function _v(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState(!0),[g,x]=S.useState(""),[v,y]=S.useState(null);function j(){!i||!f||(m(!0),i.request("sessions.list",{}).then(z=>r(Array.isArray(z==null?void 0:z.sessions)?z.sessions:[])).catch(()=>{}).finally(()=>m(!1)))}S.useEffect(()=>{j()},[i,f]);async function b(z){if(!(!i||!confirm(`Reset session "${z}"? This will clear its history.`))){y(z);try{await i.request("sessions.reset",{key:z}),j()}catch{}y(null)}}async function T(z){if(!(!i||!confirm(`Delete session "${z}"? This cannot be undone.`))){y(z);try{await i.request("sessions.delete",{key:z}),r(B=>B.filter(Y=>Y.key!==z))}catch{}y(null)}}if(h)return s.jsx(lt,{});const R=o.filter(z=>!g||z.key.toLowerCase().includes(g.toLowerCase()));return s.jsxs("div",{children:[s.jsx(hl,{title:"Sessions",description:"View and manage active conversations",actions:s.jsxs("button",{onClick:j,className:"btn-secondary",children:[s.jsx(dr,{className:"h-4 w-4"}),"Refresh"]})}),s.jsxs("div",{className:"relative mb-4",children:[s.jsx(om,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400"}),s.jsx("input",{className:"input !pl-10",placeholder:"Search sessions...",value:g,onChange:z=>x(z.target.value)})]}),s.jsx("div",{className:"space-y-2",children:R.map(z=>s.jsxs("div",{className:"card flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-blue-50",children:s.jsx(Ei,{className:"h-4 w-4 text-blue-600"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm font-mono text-surface-900 truncate",children:z.key}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-surface-400",children:[z.agentId&&s.jsxs("span",{children:["Agent: ",z.agentId]}),z.channel&&s.jsxs("span",{children:["Channel: ",z.channel]}),z.messageCount!=null&&s.jsxs("span",{children:[z.messageCount," msgs"]})]})]})]}),s.jsxs("div",{className:"ml-3 flex shrink-0 items-center gap-1",children:[s.jsx("button",{onClick:()=>b(z.key),disabled:v===z.key,className:"btn-ghost !px-2 !py-1.5 text-surface-400 hover:text-amber-600",title:"Reset session",children:v===z.key?s.jsx(Yt,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx($1,{className:"h-3.5 w-3.5"})}),s.jsx("button",{onClick:()=>T(z.key),disabled:v===z.key,className:"btn-ghost !px-2 !py-1.5 text-surface-400 hover:text-red-600",title:"Delete session",children:s.jsx(mr,{className:"h-3.5 w-3.5"})})]})]},z.key))}),R.length===0&&s.jsx("div",{className:"py-12 text-center text-sm text-surface-400",children:g?"No sessions match your search":"No active sessions"})]})}function Rv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState(""),[h,m]=S.useState(!0),[g,x]=S.useState(!1),[v,y]=S.useState(null),[j,b]=S.useState(null),[T,R]=S.useState([]);S.useEffect(()=>{!i||!f||Promise.all([i.request("config.get"),i.request("health").catch(()=>null),i.request("models.list").catch(()=>({models:[]}))]).then(([B,Y,H])=>{r(JSON.stringify((B==null?void 0:B.config)??{},null,2)),b(Y),R(Array.isArray(H==null?void 0:H.models)?H.models:[]),m(!1)})},[i,f]);async function z(){if(i){x(!0),y(null);try{const B=JSON.parse(o);await i.request("config.set",{config:B}),y({ok:!0,msg:"Configuration saved. Some changes may require a restart."})}catch(B){y({ok:!1,msg:B instanceof Error?B.message:"Failed to save"})}x(!1)}}return h?s.jsx(lt,{}):s.jsxs("div",{children:[s.jsx(hl,{title:"Settings",description:"System configuration and health"}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[s.jsx("div",{className:"lg:col-span-2 space-y-6",children:s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-semibold text-surface-900",children:"Configuration"}),s.jsx("p",{className:"text-xs text-surface-400",children:"openclaw.json"})]}),s.jsx("textarea",{className:"input min-h-[400px] resize-y font-mono text-xs leading-relaxed",value:o,onChange:B=>{r(B.target.value),y(null)},spellCheck:!1}),v&&s.jsxs("div",{className:`mt-3 flex items-start gap-2 rounded-lg p-3 text-sm ${v.ok?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-700"}`,children:[v.ok?s.jsx(ar,{className:"mt-0.5 h-4 w-4 shrink-0"}):s.jsx(Ni,{className:"mt-0.5 h-4 w-4 shrink-0"}),s.jsx("span",{children:v.msg})]}),s.jsx("div",{className:"mt-3 flex gap-3",children:s.jsxs("button",{onClick:z,disabled:g,className:"btn-primary",children:[g?s.jsx(Yt,{className:"h-4 w-4 animate-spin"}):s.jsx(fm,{className:"h-4 w-4"}),"Save Configuration"]})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"mb-3 text-sm font-semibold text-surface-900",children:"System Health"}),j?s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Y1,{className:"h-4 w-4 text-surface-400"}),s.jsx("span",{className:"text-surface-600",children:"Status:"}),s.jsx("span",{className:"badge-green",children:"Healthy"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(G1,{className:"h-4 w-4 text-surface-400"}),s.jsx("span",{className:"text-surface-600",children:"Version:"}),s.jsx("span",{className:"text-surface-900 font-mono text-xs",children:j.version??"unknown"})]})]}):s.jsx("p",{className:"text-sm text-surface-400",children:"Health data unavailable"})]}),s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"mb-3 text-sm font-semibold text-surface-900",children:"Available Models"}),s.jsxs("div",{className:"space-y-1",children:[T.length>0?T.slice(0,10).map(B=>s.jsxs("div",{className:"rounded px-2 py-1.5 text-xs",children:[s.jsx("p",{className:"font-mono text-surface-700",children:B.id}),B.provider&&s.jsx("p",{className:"text-surface-400",children:B.provider})]},B.id)):s.jsx("p",{className:"text-sm text-surface-400",children:"No models configured"}),T.length>10&&s.jsxs("p",{className:"text-xs text-surface-400",children:["+",T.length-10," more"]})]})]})]})]})]})}function yi(i){const f=vm(i.missing);return i.disabled?"disabled":i.blockedByAllowlist&&f?"both":i.blockedByAllowlist?"blocked":f?"missing":"enabled"}const er={enabled:{label:"Enabled",cls:"bg-emerald-50 text-emerald-700"},disabled:{label:"Disabled",cls:"bg-surface-100 text-surface-500"},blocked:{label:"Blocked by Allowlist",cls:"bg-amber-50 text-amber-700"},missing:{label:"Missing Requirements",cls:"bg-red-50 text-red-700"},both:{label:"Blocked + Missing Reqs",cls:"bg-red-50 text-red-700"}};function vm(i){return i.bins.length>0||i.anyBins.length>0||i.env.length>0||i.config.length>0||i.os.length>0}function Dv(){const{gateway:i,connected:f}=Be(),[o,r]=S.useState([]),[h,m]=S.useState(!0),[g,x]=S.useState(""),[v,y]=S.useState(null),[j,b]=S.useState(null),[T,R]=S.useState(null),[z,B]=S.useState(new Set),[Y,H]=S.useState("all");function V(){!i||!f||(m(!0),i.request("skills.status",{}).then(X=>r(Array.isArray(X==null?void 0:X.skills)?X.skills:[])).catch(()=>{}).finally(()=>m(!1)))}S.useEffect(()=>{V()},[i,f]);async function G(X){if(!i)return;const Te=yi(X)!=="enabled";y(X.skillKey);try{await i.request("skills.update",{skillKey:X.skillKey,enabled:Te}),V()}catch{}y(null)}async function k(X,se){if(!i)return;const Te=`${X}:${se}`;b(Te),R(null);try{const ze=await i.request("skills.install",{name:X,installId:se,timeoutMs:12e4});ze!=null&&ze.ok?(R({key:X,ok:!0,msg:"Installed successfully"}),V()):R({key:X,ok:!1,msg:(ze==null?void 0:ze.message)??"Install failed"})}catch(ze){R({key:X,ok:!1,msg:ze instanceof Error?ze.message:"Install failed"})}b(null)}function ee(X){B(se=>{const Te=new Set(se);return Te.has(X)?Te.delete(X):Te.add(X),Te})}if(h)return s.jsx(lt,{});const ie=o.filter(X=>{var Te;if(Y!=="all"&&yi(X)!==Y)return!1;if(!g)return!0;const se=g.toLowerCase();return X.skillKey.toLowerCase().includes(se)||X.name.toLowerCase().includes(se)||((Te=X.description)==null?void 0:Te.toLowerCase().includes(se))}),F={enabled:0,disabled:0,blocked:0,missing:0,both:0};for(const X of o)F[yi(X)]++;return s.jsxs("div",{children:[s.jsx(hl,{title:"Skills",description:"Browse and manage agent skills",actions:s.jsxs("button",{onClick:V,className:"btn-secondary",children:[s.jsx(dr,{className:"h-4 w-4"}),"Refresh"]})}),s.jsxs("div",{className:"mb-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(om,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400"}),s.jsx("input",{className:"input !pl-10",placeholder:"Search skills...",value:g,onChange:X=>x(X.target.value)})]}),s.jsxs("span",{className:"text-xs text-surface-500",children:[ie.length," / ",o.length]})]}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[s.jsxs("button",{onClick:()=>H("all"),className:wt("rounded-full px-3 py-1 text-xs font-medium transition-colors",Y==="all"?"bg-surface-900 text-white":"bg-surface-100 text-surface-600 hover:bg-surface-200"),children:["All (",o.length,")"]}),["enabled","blocked","missing","disabled"].map(X=>F[X]>0&&s.jsxs("button",{onClick:()=>H(Y===X?"all":X),className:wt("rounded-full px-3 py-1 text-xs font-medium transition-colors",Y===X?"bg-surface-900 text-white":`${er[X].cls} hover:opacity-80`),children:[er[X].label," (",F[X],")"]},X))]})]}),s.jsx("div",{className:"space-y-2",children:ie.map(X=>{const se=yi(X),Te=er[se],ze=z.has(X.skillKey),Qe=vm(X.missing);return s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[s.jsx("button",{onClick:()=>ee(X.skillKey),className:"shrink-0 text-surface-400 hover:text-surface-600",children:ze?s.jsx(L1,{className:"h-4 w-4"}):s.jsx(cm,{className:"h-4 w-4"})}),s.jsx("div",{className:wt("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg",se==="enabled"?"bg-primary-100":"bg-surface-100"),children:X.emoji?s.jsx("span",{className:"text-lg",children:X.emoji}):s.jsx(Ai,{className:wt("h-4 w-4",se==="enabled"?"text-primary-600":"text-surface-400")})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("p",{className:"text-sm font-medium text-surface-900",children:X.name}),s.jsx("span",{className:wt("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",Te.cls),children:Te.label})]}),X.description&&s.jsx("p",{className:"text-xs text-surface-400 truncate",children:X.description})]})]}),s.jsx("button",{onClick:()=>G(X),disabled:v===X.skillKey,className:"ml-3 shrink-0",title:se==="enabled"?"Disable this skill":"Enable this skill",children:v===X.skillKey?s.jsx(Yt,{className:"h-5 w-5 animate-spin text-surface-400"}):se==="enabled"?s.jsx(P1,{className:"h-6 w-6 text-primary-600"}):s.jsx(I1,{className:"h-6 w-6 text-surface-300"})})]}),ze&&s.jsxs("div",{className:"mt-3 border-t border-surface-100 pt-3 space-y-2.5",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 text-xs",children:[s.jsxs("div",{className:"flex items-center gap-2 text-surface-500",children:[s.jsx("span",{className:"font-medium text-surface-700",children:"Key:"}),s.jsx("code",{className:"font-mono",children:X.skillKey})]}),s.jsxs("div",{className:"flex items-center gap-2 text-surface-500",children:[s.jsx("span",{className:"font-medium text-surface-700",children:"Source:"}),s.jsx("span",{children:X.source})]}),X.primaryEnv&&s.jsxs("div",{className:"flex items-center gap-2 text-surface-500",children:[s.jsx(X1,{className:"h-3 w-3"}),s.jsx("span",{className:"font-medium text-surface-700",children:"API Key env:"}),s.jsx("code",{className:"font-mono",children:X.primaryEnv})]}),X.homepage&&s.jsxs("div",{className:"flex items-center gap-2 text-surface-500",children:[s.jsx("span",{className:"font-medium text-surface-700",children:"Homepage:"}),s.jsx("a",{href:X.homepage,target:"_blank",rel:"noreferrer",className:"text-primary-600 hover:underline truncate",children:X.homepage})]})]}),X.blockedByAllowlist&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-amber-50 p-2.5 text-xs text-amber-800",children:[s.jsx(W1,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Blocked by allowlist"}),s.jsxs("p",{className:"text-amber-600",children:["This bundled skill is not in"," ",s.jsx("code",{className:"font-mono",children:"skills.allowBundled"}),". Add"," ",s.jsxs("code",{className:"font-mono",children:['"',X.skillKey,'"']})," to the allowlist in Settings to unblock."]})]})]}),Qe&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-red-50 p-2.5 text-xs text-red-800",children:[s.jsx(ev,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Missing requirements"}),s.jsxs("ul",{className:"mt-1 space-y-0.5 text-red-700",children:[X.missing.bins.length>0&&s.jsxs("li",{children:["Commands not found:"," ",s.jsx("code",{className:"font-mono",children:X.missing.bins.join(", ")})]}),X.missing.anyBins.length>0&&s.jsxs("li",{children:["Need one of:"," ",s.jsx("code",{className:"font-mono",children:X.missing.anyBins.join(", ")})]}),X.missing.env.length>0&&s.jsxs("li",{children:["Missing env vars:"," ",s.jsx("code",{className:"font-mono",children:X.missing.env.join(", ")})]}),X.missing.config.length>0&&s.jsxs("li",{children:["Missing config:"," ",s.jsx("code",{className:"font-mono",children:X.missing.config.join(", ")})]}),X.missing.os.length>0&&s.jsxs("li",{children:["Requires OS:"," ",s.jsx("code",{className:"font-mono",children:X.missing.os.join(", ")})]})]})]})]}),Array.isArray(X.install)&&X.install.length>0&&Qe&&s.jsxs("div",{className:"rounded-lg bg-blue-50 p-2.5",children:[s.jsxs("p",{className:"text-xs font-medium text-blue-800 mb-2",children:[s.jsx(qh,{className:"inline h-3 w-3 mr-1"}),"Install missing dependencies"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:X.install.map(ke=>{const at=`${X.name}:${ke.id}`,Re=j===at;return s.jsxs("button",{onClick:()=>k(X.name,ke.id),disabled:Re||j!==null,className:"flex items-center gap-1.5 rounded-lg bg-white border border-blue-200 px-3 py-1.5 text-xs font-medium text-blue-700 hover:bg-blue-100 transition-colors disabled:opacity-50",children:[Re?s.jsx(Yt,{className:"h-3 w-3 animate-spin"}):s.jsx(qh,{className:"h-3 w-3"}),ke.label,ke.bins.length>0&&s.jsxs("span",{className:"text-blue-400 font-mono",children:["(",ke.bins.join(", "),")"]})]},ke.id)})}),(T==null?void 0:T.key)===X.name&&s.jsxs("div",{className:wt("mt-2 text-xs",T.ok?"text-emerald-700":"text-red-700"),children:[T.ok?s.jsx(ar,{className:"inline h-3 w-3 mr-1"}):s.jsx(Hh,{className:"inline h-3 w-3 mr-1"}),T.msg]})]}),se==="enabled"&&s.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-emerald-50 p-2.5 text-xs text-emerald-700",children:[s.jsx(ar,{className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{children:"All requirements met. Skill is active."})]}),X.disabled&&s.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-surface-100 p-2.5 text-xs text-surface-600",children:[s.jsx(Hh,{className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{children:"Explicitly disabled in config. Click the toggle to re-enable."})]})]})]},X.skillKey)})}),ie.length===0&&s.jsx("div",{className:"py-12 text-center text-sm text-surface-400",children:g||Y!=="all"?"No skills match your filter":"No skills available"})]})}function wv(){return s.jsx(e1,{children:s.jsxs(ot,{element:s.jsx(rv,{}),children:[s.jsx(ot,{index:!0,element:s.jsx(Cv,{})}),s.jsx(ot,{path:"agents",element:s.jsx(Nv,{})}),s.jsx(ot,{path:"agents/new",element:s.jsx(fv,{})}),s.jsx(ot,{path:"agents/:agentId",element:s.jsx(Gh,{})}),s.jsx(ot,{path:"agents/:agentId/:tab",element:s.jsx(Gh,{})}),s.jsx(ot,{path:"channels",element:s.jsx(Tv,{})}),s.jsx(ot,{path:"groups",element:s.jsx(Mv,{})}),s.jsx(ot,{path:"skills",element:s.jsx(Dv,{})}),s.jsx(ot,{path:"sessions",element:s.jsx(_v,{})}),s.jsx(ot,{path:"cron",element:s.jsx(zv,{})}),s.jsx(ot,{path:"settings",element:s.jsx(Rv,{})}),s.jsx(ot,{path:"*",element:s.jsx(Fg,{to:"/",replace:!0})})]})})}function Uv(){const{authenticated:i}=Be();return i?s.jsx(wv,{}):s.jsx(Ov,{})}Iy.createRoot(document.getElementById("root")).render(s.jsx(S.StrictMode,{children:s.jsx(E1,{basename:"/operator",children:s.jsx(iv,{children:s.jsx(Uv,{})})})}));
|
package/dist/web/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
|
|
11
11
|
rel="stylesheet"
|
|
12
12
|
/>
|
|
13
|
-
<script type="module" crossorigin src="/operator/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/operator/assets/index-Dx8NPNp3.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/operator/assets/index-Djm6GUQb.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body class="bg-white text-surface-900 antialiased">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futurx/openclaw-operator-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Operator management UI plugin for OpenClaw — a web-based control panel for non-technical users to manage agents, channels, groups, skills, sessions and more.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|