dimcode 0.0.6-beta.3 → 0.0.6-beta.5
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 +2 -0
- package/assets/gui/200.html +1 -0
- package/assets/gui/404.html +1 -0
- package/assets/gui/_nuxt/BXuAKVE-.js +14 -0
- package/assets/gui/_nuxt/C3BrLUZh.js +4 -0
- package/assets/gui/_nuxt/C4uPjXVZ.js +1 -0
- package/assets/gui/_nuxt/Dj7srIE_.js +1 -0
- package/assets/gui/_nuxt/bC-S5PDW.js +1 -0
- package/assets/gui/_nuxt/builds/latest.json +1 -0
- package/assets/gui/_nuxt/builds/meta/8aea84a1-400a-4161-9967-b1a70bba680f.json +1 -0
- package/assets/gui/_nuxt/entry.tb-Qreak.css +1 -0
- package/assets/gui/_nuxt/error-404.DF6r4GP7.css +1 -0
- package/assets/gui/_nuxt/error-500.Bo5pzFPU.css +1 -0
- package/assets/gui/favicon.ico +0 -0
- package/assets/gui/index.html +1 -0
- package/assets/gui/robots.txt +2 -0
- package/assets/native/build.zig +16 -0
- package/assets/native/src/lib.zig +23 -0
- package/dist/cli.mjs +973 -822
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -119,6 +119,8 @@ Type slash commands directly in the input field:
|
|
|
119
119
|
- Drag to select text, then release to auto-copy (when enabled)
|
|
120
120
|
- In the input area, use `Shift+Option` for rectangular selection
|
|
121
121
|
- Triple-click in the input area to select all
|
|
122
|
+
- `Tab` moves focus to the next input field; `Shift+Tab` moves to the previous
|
|
123
|
+
- The CLI is mouse-friendly for selection, scrolling, and clicking buttons/controls
|
|
122
124
|
|
|
123
125
|
## ⚙️ Configuration
|
|
124
126
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>GoatChain GUI</title><link rel="stylesheet" href="/_nuxt/entry.tb-Qreak.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/_nuxt/C3BrLUZh.js"><script type="module" src="/_nuxt/C3BrLUZh.js" crossorigin></script><meta name="description" content="GoatChain GUI - shared event stream viewer and query console."><script id="unhead:payload" type="application/json">{"title":"GoatChain GUI"}</script></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/",buildId:"8aea84a1-400a-4161-9967-b1a70bba680f",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1770125706949,false]</script></body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>GoatChain GUI</title><link rel="stylesheet" href="/_nuxt/entry.tb-Qreak.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/_nuxt/C3BrLUZh.js"><script type="module" src="/_nuxt/C3BrLUZh.js" crossorigin></script><meta name="description" content="GoatChain GUI - shared event stream viewer and query console."><script id="unhead:payload" type="application/json">{"title":"GoatChain GUI"}</script></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/",buildId:"8aea84a1-400a-4161-9967-b1a70bba680f",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1770125706950,false]</script></body></html>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{c as p,d as In,o as En,e as An,I as Ue,x as l,y as r,z as o,J as $,K as J,A as f,k as E,L as B,M as V,N as Z,O as K,P as Be,Q as ht,R as fe,D as qe,S as Dn,T as Nn,U as yt}from"./C3BrLUZh.js";const On=["state.snapshot","state.patch","message.delta","tool.call","tool.output","tool.result","run.status","session.created","session.updated"];function gt(k){const i=String(k??"").trim();return i?i.replace(/\/+$/,""):""}function Ke(k,i,m){const v=gt(k),w=i.startsWith("/")?i:`/${i}`,A=`${v}${w}`;if(!m)return A;const T=A.includes("?")?"&":"?";return`${A}${T}cursor=${encodeURIComponent(m)}`}function Qe(k){const i=String(k??"").trim();if(!i)return null;try{return JSON.parse(i)}catch{return i}}function Rn(k,i){const m=Qe(k.data),v=m&&typeof m=="object"?m:null,w=i??k.type??"message",A=v?.type?String(v.type):w,T=k.lastEventId||(v?.id?String(v.id):"")||(v?.cursor?String(v.cursor):""),M=v?.ts??v?.createdAt,U=typeof v?.seq=="number"?Number(v.seq):void 0;return{id:T||void 0,type:A,ts:M?String(M):void 0,seq:U,payload:m,raw:String(k.data??""),receivedAt:new Date().toISOString()}}async function ee(k,i,m){const v=Ke(k,i),w=await fetch(v,{credentials:"same-origin",headers:{"content-type":"application/json",...m?.headers??{}},...m}),A=await w.text(),T=Qe(A);if(!w.ok){const M=typeof T=="string"?T:JSON.stringify(T);throw new Error(`Request failed (${w.status}): ${M||w.statusText}`)}return T}function we(k=""){const i=gt(k);async function m(h){return ee(i,"/status",{method:"GET",signal:h})}async function v(h,g,I){return ee(i,"/query",{method:"POST",body:JSON.stringify({query:h,input:h,attachments:g,attachmentsBase64:I})})}async function w(h,g,I,P){return ee(i,"/query",{method:"POST",body:JSON.stringify({query:h,input:h,sessionId:g,attachments:I,attachmentsBase64:P})})}async function A(){const h=await ee(i,"/sessions",{method:"GET"});return Array.isArray(h.sessions)?h.sessions:[]}async function T(h){return(await ee(i,`/sessions/${encodeURIComponent(h)}`,{method:"GET"})).session??null}async function M(){return ee(i,"/sessions",{method:"POST"})}async function U(h,g){return ee(i,`/sessions/${encodeURIComponent(h)}/rename`,{method:"POST",body:JSON.stringify({title:g})})}async function x(h){return ee(i,`/sessions/${encodeURIComponent(h)}`,{method:"DELETE"})}function N(h){const g=Ke(i,"/events",h.cursor),I=new EventSource(g),P=q=>{h.onEvent(Rn(q,q.type==="message"?void 0:q.type))};I.onopen=()=>h.onOpen?.(),I.onerror=q=>h.onError?.(q),I.onmessage=P;for(const q of On)I.addEventListener(q,P);return I}return{fetchStatus:m,runQuery:v,runQueryWithSession:w,openEvents:N,fetchSessions:A,fetchSession:T,createSession:M,renameSession:U,deleteSession:x,uploadFile:async h=>{const g=Ke(i,"/upload"),I=new FormData;I.append("file",h);const P=await fetch(g,{method:"POST",body:I,credentials:"same-origin"}),q=await P.text(),ie=Qe(q);if(!P.ok||!ie?.file)throw new Error(ie?.error||`Upload failed (${P.status})`);return ie.file}}}function Un(k={}){const i=p([]),m=p(null),v=p("idle"),w=p(null),A=p(null),T=k.maxEvents??200,M=we();let U=null;function x(g){i.value=[g,...i.value].slice(0,T),g.id&&(A.value=g.id),g.type==="state.snapshot"&&(g.payload&&typeof g.payload=="object"&&"snapshot"in g.payload?m.value=g.payload.snapshot:m.value=g.payload)}function N(g){h(),v.value="connecting",w.value=null,U=M.openEvents({cursor:g??A.value??void 0,onOpen:()=>{v.value="open"},onError:()=>{v.value="error",w.value="Event stream disconnected."},onEvent:I=>{x(I)}})}function h(){U&&(U.close(),U=null),(v.value==="connecting"||v.value==="open")&&(v.value="idle")}return{events:i,snapshot:m,state:v,error:w,lastEventId:A,start:N,stop:h}}function Mn(){const k=p(""),i=p(!1),m=p(null),v=p(null),w=p(null),A=we();async function T(U,x,N,h){const g=(U??k.value).trim(),I=Array.isArray(N)&&N.length>0;if(!g&&!I){m.value="Query cannot be empty.";return}i.value=!0,m.value=null;try{v.value=x?await A.runQueryWithSession(g,x,N,h):await A.runQuery(g,N,h),w.value=new Date().toISOString()}catch(P){m.value=P instanceof Error?P.message:String(P),v.value=null}finally{i.value=!1}}function M(U){k.value=U}return{input:k,loading:i,error:m,response:v,lastRunAt:w,run:T,setInput:M}}function Pn(){const k=p(null),i=p(!1),m=p(null),v=p(null),w=we();async function A(){i.value=!0,m.value=null;try{k.value=await w.fetchStatus(),v.value=new Date().toISOString()}catch(T){m.value=T instanceof Error?T.message:String(T)}finally{i.value=!1}}return{status:k,loading:i,error:m,lastUpdated:v,refresh:A}}function Ln(){const k=p([]),i=p(!1),m=p(null),v=we();async function w(){i.value=!0,m.value=null;try{k.value=await v.fetchSessions()}catch(x){m.value=x instanceof Error?x.message:String(x),k.value=[]}finally{i.value=!1}}async function A(){i.value=!0,m.value=null;try{const x=await v.createSession();return await w(),x}catch(x){m.value=x instanceof Error?x.message:String(x)}finally{i.value=!1}}async function T(x){i.value=!0,m.value=null;try{return await v.fetchSession(x)}catch(N){return m.value=N instanceof Error?N.message:String(N),null}finally{i.value=!1}}async function M(x,N){i.value=!0,m.value=null;try{const h=await v.renameSession(x,N);return await w(),h}catch(h){m.value=h instanceof Error?h.message:String(h)}finally{i.value=!1}}async function U(x){i.value=!0,m.value=null;try{await v.deleteSession(x),await w()}catch(N){m.value=N instanceof Error?N.message:String(N)}finally{i.value=!1}}return{sessions:k,loading:i,error:m,refresh:w,create:A,fetchSession:T,rename:M,destroy:U}}const jn={class:"layout"},Wn={class:"sidebar"},Fn={class:"sidebar-header"},zn={class:"sidebar-actions"},Jn={class:"session-list"},Bn={key:0,class:"note"},qn={key:1,class:"note"},Kn={key:2,class:"note"},Qn=["onClick","onKeydown"],Vn={class:"session-row"},Gn={class:"session-title"},Hn={key:0,class:"session-actions"},Zn=["onClick"],Yn=["onClick"],Xn=["onKeydown"],es={class:"session-edit-actions"},ts=["onClick"],ns={class:"session-meta session-meta--primary"},ss={class:"session-id"},os={class:"session-time"},as={class:"session-meta session-meta--secondary"},ls={class:"session-status"},rs={key:3,class:"note"},is={key:0,class:"command-panel"},us={class:"command-list"},cs=["onClick"],ds={class:"sidebar-footer"},fs={class:"sidebar-meta"},ps={class:"content"},vs={class:"content-header chat-header-bar"},ms={class:"header-left"},hs={class:"content-title"},ys={class:"content-subtitle"},gs={class:"header-right"},bs={class:"header-status"},_s={class:"sidebar-pill"},ks={class:"header-stats"},Ss={class:"chat-panel"},ws={class:"chat-messages"},Cs={class:"message-body"},$s={key:0,class:"part part-markdown"},xs={key:0,class:"md-text"},Ts={key:1,class:"md-code"},Is={key:1,class:"part part-thinking"},Es=["open"],As={key:2,class:"part part-tool"},Ds={open:""},Ns={key:3,class:"part part-tool"},Os=["open"],Rs={key:0},Us={key:4,class:"part part-attachments"},Ms={class:"attachment-list"},Ps=["src","alt"],Ls={class:"attachment-body"},js={key:0},Ws={key:1,class:"attachment-label"},Fs={key:2,class:"attachment-meta"},zs=["href"],Js={class:"message-meta"},Bs={key:0,class:"message assistant"},qs={key:0,class:"attachment-tray"},Ks=["src","alt"],Qs={class:"attachment-info"},Vs={class:"attachment-name"},Gs={class:"attachment-status"},Hs=["onClick"],Zs=["placeholder","onKeydown"],Ys={key:1,class:"attachment-hints"},Xs={key:0},eo={key:1},to={key:2},no={key:2,class:"attachment-controls"},so={class:"checkbox"},oo={key:0,class:"note"},ao={class:"composer-toolbar"},lo={class:"composer-left"},ro={key:0,class:"composer-menu-popover"},io=["disabled"],uo={class:"mode-label"},co={key:0,class:"mode-popover"},fo=["onClick"],po=["disabled"],vo={key:3,class:"note"},mo={key:0,class:"info-panel"},ho={class:"card status-card"},yo={key:0,class:"note"},go={key:1,class:"note"},bo={key:2},_o={class:"status-row"},ko={class:"label"},So={key:0,class:"note"},wo={key:1,class:"query-output"},Co={class:"button-row"},$o={class:"card capabilities-card"},xo={key:0,class:"note"},To={key:1,class:"capability-list"},Io={key:0,class:"card events-card"},Eo={key:0,class:"note"},Ao={key:1,class:"note"},Do={key:2,class:"event-list"},No={class:"event-header"},Oo={class:"event-type"},Ro={class:"event-time"},Uo={class:"event-body"},Mo=["onKeydown"],Po={class:"modal-body"},Lo={class:"modal-actions"},jo=["disabled"],Wo=["disabled"],zo=In({__name:"index",setup(k){const{status:i,loading:m,error:v,lastUpdated:w,refresh:A}=Pn(),{events:T,snapshot:M,state:U,error:x,start:N,stop:h}=Un({maxEvents:60}),{loading:g,error:I,response:P,run:q}=Mn(),{sessions:ie,loading:bt,error:W,refresh:ue,create:_t,fetchSession:Me,rename:kt,destroy:St}=Ln(),wt=we(),Y=p(!1),Ce=p(""),$e=p(""),L=p([{id:"welcome",role:"system",parts:[Q("Connected. Select a session and continue the conversation here.")],ts:new Date().toISOString()}]),S=p(""),xe=p([]),te=p(null),pe=p(""),ce=p(""),G=p(""),Te=p(!1),ve=p(null),X=p(!1),Ve=p(null),Ge=p(""),He=p("info"),Ie=p(!1);let ne;const de=p(null),Ze=p(null),Ee=new Map,j=p([]),se=p(""),me=p(!1),Ye=p(null),he=p(!1),Pe=p(null),ye=p(!1),Le=p(null),je=p("agent");let Ae=null;const Ct=E(()=>i.value?.serverVersion??"unknown"),$t=E(()=>Ce.value||"pending"),We=E(()=>!!i.value?.capabilities?.uploads),xt=E(()=>!!i.value?.capabilities?.images),Tt=E(()=>{const e=U.value;if(!Y.value)return e==="open"?"Connected":e==="connecting"?"Connecting":e==="error"?"Disconnected":"Offline";switch(e){case"connecting":return"Connecting to /events";case"open":return"Streaming live events";case"error":return"Stream disconnected";default:return"Idle"}}),It=E(()=>U.value==="open"?"ok":U.value==="error"?"error":""),Et=E(()=>w.value?`Updated ${De(w.value)}`:"Status pending"),At=E(()=>W.value?"Sessions offline":`${oe.value.length} sessions`),Dt=E(()=>{const e=i.value;return[{label:"Origin",value:$t.value},{label:"Protocol",value:e?.protocolVersion??"unknown"},{label:"Server",value:Ct.value},{label:"Started",value:De(e?.startedAt)},{label:"PID",value:e?.pid?String(e.pid):"unknown"},{label:"Port",value:e?.port?String(e.port):"unknown"},{label:"Cursor",value:e?.cursor?String(e.cursor):"—"}]}),Xe=E(()=>M.value?"received from event stream":i.value?.snapshot?"received from /status":""),et=E(()=>{const e=M.value??i.value?.snapshot;return e?typeof e=="string"?e:JSON.stringify(e,null,2):""}),tt=E(()=>{const e=i.value?.capabilities??{},t=Object.entries(e),n={uploads:"Uploads",images:"Image preview",tools:"Tool calls",auth:"Auth required"};return t.map(([s,a])=>({key:s,label:n[s]??s,enabled:!!a})).sort((s,a)=>s.key.localeCompare(a.key))}),oe=E(()=>W.value?xe.value.length?xe.value:[{id:"local",title:"Main Session",summary:"Local-only session",updatedAt:void 0}]:ie.value),Nt=E(()=>!W.value),Ot=E(()=>{const e=oe.value.find(n=>n.id===S.value);if(e?.title)return e.title;const t=String(te.value?.state?.title??"").trim();return t||(oe.value[0]?.title??"Main")}),nt=E(()=>{if(!(!S.value||S.value==="local"))return S.value}),Rt=E(()=>{const e=oe.value.find(t=>t.id===S.value);return e&&"summary"in e&&e.summary?e.summary:"Shared CLI session"}),Ut=E(()=>{const e=te.value,t=Number(e?.context?.messageCount??L.value.filter(d=>d.role!=="system").length)||0,n=e?.stats?.usage??{},s=Number(n.promptTokens??n.prompt_tokens??0)||0,a=Number(n.completionTokens??n.completion_tokens??0)||0,u=Number(n.totalTokens??n.total_tokens??0)||0||s+a;return[`${t} messages`,`${u} tokens`].join(" · ")}),Mt=E(()=>`Message (${je.value.toUpperCase()} mode)...`),Pt=E(()=>je.value.toUpperCase()),Lt=E(()=>["agent","plan","debug"]),jt=E(()=>de.value?"Running":g.value?"Sending":"Send"),Wt=E(()=>g.value||!!de.value),Ft=E(()=>[{label:"Start server",command:"dim server --open"},{label:"Start with token",command:"dim server --token <token> --open"},{label:"Check version",command:"dim version"},{label:"Config file",command:"cat ~/.dimcode/config.json"},{label:"Tools file",command:"cat ~/.dimcode/tools.json"}]);function zt(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search);if(!e.has("debug"))return!1;const t=String(e.get("debug")??"").trim().toLowerCase();return!t||t==="1"||t==="true"||t==="yes"}function De(e){if(!e)return"unknown";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Jt(e){if(!e.updatedAt)return"—";const t=typeof e.updatedAt=="number"?e.updatedAt:Date.parse(String(e.updatedAt));return Number.isNaN(t)?"—":new Date(t).toLocaleDateString()}function Bt(e){return"messageCount"in e&&e.messageCount!=null?`${e.messageCount} msgs`:"summary"in e&&e.summary?e.summary:"idle"}function qt(e){if(!e)return"—";const t=Number(e);return Number.isFinite(t)&&t>0?new Date(t).toLocaleString():De(e)}function Kt(e){return`${e.type}-${e.id??e.receivedAt}`}function Qt(e){return e.ts?e.ts:e.receivedAt}function Vt(e){const t=e.payload??e.raw,n=typeof t=="string"?t:JSON.stringify(t,null,2);return n?n.length>600?`${n.slice(0,600)}...`:n:"No payload"}function ae(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`msg-${Math.random().toString(36).slice(2,8)}`}function st(e){try{URL.revokeObjectURL(e)}catch{}}function ot(){Ie.value=!1,ne&&(clearTimeout(ne),ne=void 0)}function le(e,t="info",n=2200){Ge.value=e,He.value=t,Ie.value=!0,ne&&clearTimeout(ne),ne=globalThis.setTimeout(()=>{Ie.value=!1,ne=void 0},n)}function Gt(e){const t=j.value,n=t.find(s=>s.id===e);n?.localUrl&&st(n.localUrl),j.value=t.filter(s=>s.id!==e),j.value.length||(se.value="",me.value=!1)}function Ne(){for(const e of j.value)e.localUrl&&st(e.localUrl);j.value=[],se.value="",me.value=!1}async function at(e){e.status="uploading",e.error=void 0;try{const t=await wt.uploadFile(e.file);e.remote={...t,name:t.name||e.name,mime:t.mime||e.mime,size:t.size||e.size,kind:e.mime.startsWith("image/")?"image":"file"},e.status="ready"}catch(t){e.status="error",e.error=t instanceof Error?t.message:String(t)}}async function Fe(e){if(!We.value){se.value="Uploads are disabled by the server.";return}se.value="";for(const t of e){const n=ae(),s={id:n,file:t,name:t.name||`attachment-${n.slice(0,6)}`,mime:t.type||"application/octet-stream",size:t.size,localUrl:URL.createObjectURL(t),status:"pending"};j.value=[...j.value,s],s.uploadPromise=at(s),s.uploadPromise}}function Ht(e){const t=e.clipboardData?.items;if(!t||!t.length)return;const n=[];for(const s of t)if(s.kind==="file"){const a=s.getAsFile();a&&n.push(a)}n.length&&(e.clipboardData?.getData("text")||e.preventDefault(),Fe(n))}function Zt(e){const t=e.dataTransfer?.files;if(!t||!t.length)return;const n=Array.from(t);n.length&&Fe(n)}function Yt(e){const t=e.target;if(!t?.files)return;const n=Array.from(t.files);t.value="",n.length&&Fe(n)}function Xt(){Ye.value?.click()}function en(){he.value=!he.value}function tn(){ye.value=!ye.value}function nn(e){je.value=e,ye.value=!1}function sn(){he.value=!1,Xt()}async function on(){const e=j.value.filter(s=>s.status==="pending"&&!s.uploadPromise);for(const s of e)s.uploadPromise=at(s);const t=j.value.map(s=>s.uploadPromise).filter(s=>!!s);t.length&&await Promise.all(t);const n=j.value.filter(s=>s.status==="error");return n.length?(se.value=n[0]?.error??"Attachment upload failed.",[]):j.value.filter(s=>s.status==="ready"&&s.remote).map(s=>({...s.remote,name:s.remote?.name||s.name,mime:s.remote?.mime||s.mime,size:s.remote?.size||s.size,kind:s.remote?.kind||(s.mime.startsWith("image/")?"image":"file")}))}function Q(e){const t=String(e??"");return{type:"markdown",raw:t,blocks:lt(t)}}function lt(e){const t=String(e??"").replace(/\r/g,"");if(!t)return[];const n=t.split("```"),s=[];for(let a=0;a<n.length;a+=1){const c=n[a];if(a%2===1){const u=c.split(`
|
|
2
|
+
`),y=(u.shift()??"").trim(),d=u.join(`
|
|
3
|
+
`).replace(/\n$/,"");s.push({type:"code",content:d,language:y||void 0})}else c.trim()&&s.push({type:"text",content:c.trim()})}return s}function H(e,t,n,s){const a=t.length?t:[Q("")];return{id:ae(),role:e,parts:a,ts:n??new Date().toISOString(),meta:s}}function re(e,t){L.value=[...L.value,H(e,[Q(t)])]}function an(e,t){const n=[];t.length&&n.push({type:"attachments",items:t}),e.trim()&&n.push(Q(e)),L.value=[...L.value,H("user",n)]}function ge(){const e=P.value;return e?typeof e.result=="string"?e.result:e.result?JSON.stringify(e.result,null,2):e.error?String(e.error):JSON.stringify(e,null,2):"No response"}function rt(){if(!P.value)return;const e=L.value[L.value.length-1];(!e||e.role!=="assistant")&&re("assistant",ge())}function ln(e){return e&&typeof e=="object"?e:null}function rn(e){if(!e)return null;const t=e.sessionId??e.session_id;return typeof t=="string"&&t.trim()?t:null}function un(e){if(!e)return null;const t=e.runId??e.run_id;return typeof t=="string"&&t.trim()?t:null}function be(e,t){const n=Ee.get(e);if(n)return n;if(t&&S.value&&S.value!=="local"&&S.value!==t)return null;t&&(!S.value||S.value==="local")&&(S.value=t);const s=H("assistant",[Q("")],new Date().toISOString(),"streaming");L.value=[...L.value,s];const a={runId:e,sessionId:t??void 0,messageId:s.id,text:"",hasDelta:!1,toolCalls:new Map,toolResults:new Map};return Ee.set(e,a),de.value=e,_e(a),a}function _e(e){const t=e.hasDelta?e.text:"Thinking…",n=[];if(n.push({type:"markdown",raw:t,blocks:lt(t)}),Y.value){for(const[s,a]of e.toolCalls)n.push({type:"tool_call",name:a.name,args:a.args||"No arguments",callId:s});for(const[s,a]of e.toolResults)n.push({type:"tool_result",name:a.name,output:a.output||"No output",status:a.status,callId:s,structured:a.structured})}L.value=L.value.map(s=>s.id!==e.messageId?s:{...s,parts:n,meta:"streaming"})}function cn(e){const t=Ee.get(e);t&&(Ee.delete(e),de.value===e&&(de.value=null),L.value=L.value.map(n=>n.id!==t.messageId?n:{...n,meta:void 0}))}function dn(e){const t=ln(e.payload),n=un(t),s=rn(t);if(n&&!(s&&S.value&&S.value!=="local"&&S.value!==s)){if(e.type==="run.status"){const a=typeof t?.status=="string"?t.status:"";if(a==="started"||a==="running"){be(n,s);return}if(a==="completed"||a==="done"||a==="error"){cn(n);return}}if(e.type==="message.delta"){const a=typeof t?.delta=="string"?t.delta:"",c=be(n,s);if(!c)return;a&&(c.text+=a,c.hasDelta=!0,_e(c));return}if(e.type==="tool.call"){const a=be(n,s);if(!a)return;const c=typeof t?.callId=="string"?t.callId:typeof t?.tool_call_id=="string"?t.tool_call_id:"",u=typeof t?.toolName=="string"?t.toolName:"tool",y=typeof t?.argsTextDelta=="string"?t.argsTextDelta:"",d=a.toolCalls.get(c);a.toolCalls.set(c||u,{name:u,args:d?`${d.args}${y}`:y}),_e(a);return}if(e.type==="tool.output"){const a=be(n,s);if(!a)return;const c=typeof t?.tool_call_id=="string"?t.tool_call_id:"",u=typeof t?.delta=="string"?t.delta:"",y=a.toolResults.get(c);a.toolResults.set(c||"tool",{name:y?.name,output:`${y?.output??""}${u}`,status:y?.status??"success",structured:y?.structured}),_e(a);return}if(e.type==="tool.result"){const a=be(n,s);if(!a)return;const c=typeof t?.tool_call_id=="string"?t.tool_call_id:"",u=typeof t?.output=="string"?t.output:"",y=!!t?.error,d=t?.structuredContent;a.toolResults.set(c||"tool",{name:a.toolCalls.get(c||"")?.name,output:u||a.toolResults.get(c||"")?.output||"",status:y?"error":"success",structured:d?JSON.stringify(d,null,2):void 0}),_e(a)}}}async function ze(e,t){const n=t??S.value;if(!n||n==="local")return!1;const s=e===void 0?await Me(n):e;return s?(te.value=s,S.value=n,L.value=gn(s),!0):(te.value=null,L.value=[H("system",[Q("Session unavailable or empty.")])],!1)}async function it(){const e=$e.value.trim(),t=j.value.length>0;if(!e&&!t)return;const n=t?await on():[];if(t&&!n.length)return;if(t){const a=j.value.map(c=>({id:c.id,kind:c.mime.startsWith("image/")?"image":"file",label:c.name,url:c.localUrl,meta:c.status==="ready"?void 0:c.status}));an(e,a)}else re("user",e);$e.value="",await q(e,nt.value,n,me.value);const s=P.value?.sessionId;if(s&&s!==S.value&&(S.value=s),I.value){re("assistant",`Error: ${I.value}`);return}I.value||Ne(),!W.value&&s?(await ue(),await ze(void 0,s)?rt():re("assistant",ge())):re("assistant",ge())}function Oe(){L.value=[H("system",[Q("Conversation cleared. Send a new message to continue.")])],Ne()}async function fn(){if(!W.value){const n=await _t();await ue();const s=n?.session?.id??n?.id;s&&Se(String(s)),Oe();return}const e=ae(),t={id:e,title:`Local ${e.slice(0,6)}`,updatedAt:De(new Date().toISOString())};xe.value=[t,...xe.value],S.value=e,Oe()}function pn(e){W.value||(pe.value=e.id,ce.value=e.title,G.value="")}function ut(){pe.value="",ce.value=""}function vn(e){W.value||(ve.value={id:e.id,title:e.title},Te.value=!0,X.value=!1,G.value="")}function ke(){Te.value=!1,ve.value=null,X.value=!1}async function ct(e){if(W.value)return;const t=ce.value.trim();if(!t){G.value="Title cannot be empty.";return}if(await kt(e.id,t),W.value){G.value=`Rename failed: ${W.value}`;return}if(G.value=`Renamed session to: ${t}`,e.id===S.value){const n=await Me(e.id);n&&(te.value=n)}pe.value="",ce.value=""}async function dt(){if(W.value||!ve.value||X.value)return;X.value=!0;const e=ve.value;if(await St(e.id),X.value=!1,W.value){G.value=`Delete failed: ${W.value}`;return}if(G.value=`Deleted session: ${e.title}`,S.value===e.id){const t=ie.value.filter(n=>n.id!==e.id);t.length?await Se(t[0].id):(S.value="",te.value=null,Oe())}ke()}async function Se(e){if(S.value=e,G.value="",Ne(),e==="local"){te.value=null,Oe();return}await ze(await Me(e))}async function mn(){await A(),v.value||N(i.value?.cursor)}function ft(){N(i.value?.cursor)}async function pt(e){await q(e,nt.value);const t=P.value?.sessionId;if(t&&t!==S.value&&(S.value=t),I.value){le(`Quick action failed: ${I.value}`,"error",2600);return}!W.value&&t?(await ue(),await ze(void 0,t)?rt():re("assistant",ge())):re("assistant",ge()),le(`Ran quick query: ${e}`,"success")}async function hn(){if(!Ce.value)return le("Origin not available yet.","error");try{await navigator.clipboard.writeText(Ce.value),le("Origin copied to clipboard.","success")}catch{le("Clipboard unavailable. Copy manually.","error")}}async function yn(e,t){try{await navigator.clipboard.writeText(e),le(`Copied: ${t}`,"success")}catch{le("Clipboard unavailable. Copy manually.","error")}}En(async()=>{typeof window<"u"&&(Ce.value=window.location.origin),Y.value=zt(),await Promise.all([A(),ue()]),v.value||N(i.value?.cursor),Ae=e=>{const t=e.target;Pe.value&&!Pe.value.contains(t)&&(he.value=!1),Le.value&&!Le.value.contains(t)&&(ye.value=!1)},window.addEventListener("mousedown",Ae)}),An(()=>{Ae&&window.removeEventListener("mousedown",Ae),h(),Ne(),ot()}),Ue(i,e=>{e?.snapshot&&!M.value&&(M.value=e.snapshot)}),Ue(T,e=>{const t=e[0];if(!t)return;const n=t.id||`${t.type}-${t.receivedAt}`;Ze.value!==n&&(Ze.value=n,dn(t))}),Ue(Te,e=>{e&&Nn(()=>Ve.value?.focus())}),Ue(oe,e=>{if(e.length){if(!S.value){Se(e[0].id);return}e.some(t=>t.id===S.value)}},{immediate:!0});function gn(e){const t=e?.context?.messages,n=Array.isArray(t)?t:[];if(!n.length)return[H("system",[Q("Session is empty. Start chatting to add messages.")])];const s=[],a=new Map,c=new Map;for(const u of n){const y=String(u?.role??""),d=String(u?.createdAt??u?.createdAtMs??u?.created_at??"");if(y==="user"){const{text:C,attachments:O}=vt(u?.content),_=Sn(C),b=[];_.focusFiles?.length&&b.push({type:"attachments",items:_.focusFiles.map(R=>({id:ae(),kind:"path",label:R}))}),O.length&&b.push({type:"attachments",items:O}),_.content.trim()&&b.push(Q(_.content)),s.push(H("user",b,d));continue}if(y==="assistant"){const C=[],O=Je(u?.reasoning_content).trim();O&&C.push({type:"thinking",title:"Thinking",collapsed:!0,content:O});const{text:_,attachments:b}=vt(u?.content);_.trim()&&C.push(Q(_)),b.length&&C.push({type:"attachments",items:b});const R=Array.isArray(u?.tool_calls)?u.tool_calls:[];for(const D of R){const F=String(D?.id??"").trim(),z=String(D?.function?.name??"tool"),mt=wn(D?.function?.arguments);F&&(a.set(F,s.length),c.set(F,z)),C.push({type:"tool_call",name:z,args:Cn(mt),callId:F||void 0})}s.push(H("assistant",C,d));continue}if(y==="tool"){const C=String(u?.tool_call_id??"").trim(),O=C?c.get(C):void 0,_=$n(u?.content,O);let b;if(u?.structuredContent)try{b=JSON.stringify(u.structuredContent,null,2)}catch{b=String(u.structuredContent)}const R={type:"tool_result",name:O,output:_,status:u?.isError?"error":"success",callId:C||void 0,structured:b},D=C?a.get(C):void 0;if(D!=null&&s[D]){const F=s[D];s[D]={...F,parts:[...F.parts,R]}}else s.push(H("assistant",[R],d))}}return s.length?s:[H("system",[Q("Session is empty. Start chatting to add messages.")])]}function Re(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Je(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(Je).join("");if(Re(e)){const t=e.text;if(typeof t=="string")return t;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function vt(e){const t=[],n=[],s=d=>{d&&t.push(d)},a=d=>{d&&n.push(d)},c=d=>{if(d==null)return;if(typeof d=="string"){s(d);return}if(Array.isArray(d)){for(const O of d)c(O);return}if(!Re(d)){s(String(d));return}const C=String(d.type??"").toLowerCase();if(typeof d.text=="string"&&s(String(d.text)),C.includes("image")){const O=bn(d);a({id:ae(),kind:"image",label:d.name??"image",url:O??void 0,meta:O?void 0:"Image payload"});return}if(C.includes("file")){const{label:O,url:_,meta:b}=_n(d);a({id:ae(),kind:"file",label:O,url:_,meta:b});return}"text"in d||s(JSON.stringify(d))};c(e);const u=t.join(""),y=kn(u);return{text:y.text,attachments:[...n,...y.attachments]}}function bn(e){const t=e.image_url;if(typeof t=="string")return t;if(t&&typeof t=="object"&&typeof t.url=="string")return t.url;if(typeof e.url=="string")return e.url;const n=e.source;if(n&&typeof n=="object"){if(typeof n.url=="string")return n.url;if(typeof n.data=="string")return`data:${String(n.media_type??"image/png")};base64,${n.data}`}return null}function _n(e){const t=e.file,n=String(e.name??e.filename??t?.name??t?.filename??t?.id??"file"),s=typeof e.url=="string"?e.url:typeof t?.url=="string"?t.url:void 0,a=e.size??t?.size,c=e.mime_type??t?.mime_type??t?.type,u=[];return c&&u.push(String(c)),a&&u.push(`${a} bytes`),{label:n,url:s,meta:u.length?u.join(" · "):void 0}}function kn(e){let t=String(e??"");const n=[],s=/\[attachment_base64\][\s\S]*?\[\/attachment_base64\]/gi;t=t.replace(s,"").trim();const a=/\[attachments\]([\s\S]*?)\[\/attachments\]/i,c=t.match(a);if(c){const y=(c[1]??"").split(`
|
|
4
|
+
`);for(const d of y){const C=d.trim();if(!C.startsWith("-"))continue;const _=C.replace(/^-+\s*/,"").match(/^(.*?)\s*\(([^,]+),\s*([^)]+)\)\s*(.+)?$/);if(!_)continue;const b=_[1]?.trim()||"attachment",R=_[2]?.trim()||"",D=_[3]?.trim()||"",F=_[4]?.trim()||void 0,z=R.startsWith("image/")||F&&/\.(png|jpe?g|gif|webp|svg)$/i.test(F)?"image":"file";n.push({id:ae(),kind:z,label:b,url:F,meta:[R,D].filter(Boolean).join(" · ")})}t=t.replace(a,"").trim()}return{text:t,attachments:n}}function Sn(e){const t=String(e??"").replace(/\r/g,"");if(!t)return{content:""};const n=t.split(`
|
|
5
|
+
`),s=String(n[0]??"").trim();if(s!=="[focus_files]"&&s!=="[user_focus_files]"){const y=(O=>{const _=String(O??"");if(!_)return null;const b=[];let R=0;for(;R<_.length;){for(;R<_.length&&(_[R]===" "||_[R]===" "||_[R]===`
|
|
6
|
+
`);)R+=1;const F=_.slice(R).match(/^\[([^\]]*)\]\(((?:\\\)|[^)])+)\)/);if(!F)break;let z=String(F[2]??"").trim();if(z.startsWith("<")&&z.endsWith(">")&&(z=z.slice(1,-1)),z=z.replace(/\\\)/g,")").trim(),!(z.startsWith("/")||/^[A-Z]:[\\/]/i.test(z)))break;z&&b.push(z),R+=F[0].length}if(!b.length)return null;let D=_.slice(R);return D=D.replace(/^[ \t]+/g,""),D.startsWith(`
|
|
7
|
+
|
|
8
|
+
`)?D=D.slice(2):(D.startsWith(`
|
|
9
|
+
`)||D.startsWith(" "))&&(D=D.slice(1)),{content:D,focusFiles:b}})(t);if(y)return y;const d=[];let C=0;for(;C<n.length;C+=1){const O=String(n[C]??"");if(!O.trim())break;const _=O.match(/^\s*\[([^\]]*)\]\((.+)\)\s*$/);if(!_)break;let b=String(_[2]??"").trim();if(b.startsWith("<")&&b.endsWith(">")&&(b=b.slice(1,-1)),b=b.replace(/\\\)/g,")").trim(),!(b.startsWith("/")||/^[A-Z]:[\\/]/i.test(b)))break;b&&d.push(b)}if(!d.length)return{content:t};for(;C<n.length&&!String(n[C]??"").trim();)C+=1;return{content:n.slice(C).join(`
|
|
10
|
+
`),focusFiles:d}}const a=[];let c=1;for(;c<n.length;c+=1){const u=String(n[c]??"");if(!u.trim())break;const y=u.match(/^\s*-\s*\[[^\]]*\]\((.+)\)\s*$/);if(!y)break;let d=String(y[1]??"").trim();d.startsWith("<")&&d.endsWith(">")&&(d=d.slice(1,-1)),d=d.replace(/\\\)/g,")").trim(),d&&a.push(d)}if(!a.length)return{content:t};for(;c<n.length&&!String(n[c]??"").trim();)c+=1;return{content:n.slice(c).join(`
|
|
11
|
+
`),focusFiles:a}}function wn(e){if(Re(e))return e;if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const n=JSON.parse(t);return Re(n)?n:{_raw:e}}catch{return{_raw:e}}}return{}}function Cn(e){if(!e||Object.keys(e).length===0)return"No arguments";if("_raw"in e&&Object.keys(e).length===1)return String(e._raw??"");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function $n(e,t){const n=Je(e);if(!n)return"No output";const s=xn(n);return String(t??"").toLowerCase()==="read"?Tn(s,24):s}function xn(e){const t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}function Tn(e,t){const n=String(e??"").split(`
|
|
12
|
+
`);return n.length<=t?e:`${n.slice(0,t).join(`
|
|
13
|
+
`)}
|
|
14
|
+
... (${n.length-t} more lines)`}return(e,t)=>(r(),l("main",{class:Z(["page","page--chat",Y.value?"page--debug":""])},[o("div",jn,[o("aside",Wn,[o("div",Fn,[t[9]||(t[9]=o("div",{class:"sidebar-title"},[o("p",{class:"brand"},"GoatChain_CTL"),o("p",{class:"brand-sub"},"Sessions")],-1)),o("div",zn,[o("button",{class:"btn ghost",type:"button",onClick:t[0]||(t[0]=(...n)=>J(ue)&&J(ue)(...n))},"Refresh"),o("button",{class:"btn ghost",type:"button",onClick:fn},"New")])]),o("div",Jn,[J(bt)?(r(),l("p",Bn,"Loading sessions…")):J(W)?(r(),l("p",qn,"Sessions unavailable: "+f(J(W)),1)):oe.value.length?$("",!0):(r(),l("p",Kn,"No sessions yet. Create one to start.")),(r(!0),l(B,null,V(oe.value,(n,s)=>(r(),l("div",{key:n.id,class:Z(["session-item",n.id===S.value?"active":"",pe.value===n.id?"editing":""]),style:yt({"--delay":`${s*.03}s`}),role:"button",tabindex:"0",onClick:a=>Se(n.id),onKeydown:fe(K(a=>Se(n.id),["prevent"]),["enter"])},[o("div",Vn,[o("div",Gn,f(n.title),1),Nt.value?(r(),l("div",Hn,[o("button",{class:"icon-btn",type:"button",onClick:K(a=>pn(n),["stop"])},"Rename",8,Zn),o("button",{class:"icon-btn danger",type:"button",onClick:K(a=>vn(n),["stop"])},"Delete",8,Yn)])):$("",!0)]),pe.value===n.id?(r(),l("div",{key:0,class:"session-edit",onClick:t[2]||(t[2]=K(()=>{},["stop"]))},[Be(o("input",{"onUpdate:modelValue":t[1]||(t[1]=a=>ce.value=a),class:"session-input",type:"text",placeholder:"New session title",onKeydown:[fe(K(a=>ct(n),["prevent"]),["enter"]),fe(K(ut,["prevent"]),["escape"])]},null,40,Xn),[[ht,ce.value]]),o("div",es,[o("button",{class:"btn small",type:"button",onClick:a=>ct(n)},"Save",8,ts),o("button",{class:"btn ghost small",type:"button",onClick:ut},"Cancel")])])):$("",!0),o("div",ns,[o("span",ss,"ID: "+f(n.id),1),o("span",os,f(Jt(n)),1)]),o("div",as,[o("span",ls,f(Bt(n)),1)])],46,Qn))),128)),G.value?(r(),l("p",rs,f(G.value),1)):$("",!0)]),Y.value?(r(),l("div",is,[t[10]||(t[10]=o("h4",null,"Command & Config",-1)),t[11]||(t[11]=o("p",{class:"note"},"Copy common CLI commands or config paths.",-1)),o("div",us,[(r(!0),l(B,null,V(Ft.value,n=>(r(),l("button",{key:n.label,class:"command-item",type:"button",onClick:s=>yn(n.command,n.label)},[o("span",null,f(n.label),1),o("code",null,f(n.command),1)],8,cs))),128))])])):$("",!0),o("div",ds,[o("div",fs,[o("span",null,f(Et.value),1),o("span",null,f(At.value),1)])])]),o("section",ps,[o("header",vs,[o("div",ms,[t[12]||(t[12]=o("span",{class:"header-label"},"Session",-1)),o("h1",hs,f(Ot.value),1),o("p",ys,f(Rt.value),1)]),o("div",gs,[o("div",bs,[o("div",_s,[o("span",{class:Z(["indicator-dot",It.value])},null,2),o("span",null,f(Tt.value),1)]),o("div",ks,f(Ut.value),1)]),o("button",{class:"btn secondary",type:"button",onClick:ft},"Refresh")])]),o("div",{class:Z(["content-grid",Y.value?"":"content-grid--single"])},[o("section",Ss,[o("div",ws,[(r(!0),l(B,null,V(L.value,(n,s)=>(r(),l("div",{key:n.id,class:Z(["message",n.role]),style:yt({"--delay":`${s*.02}s`})},[o("div",{class:Z(["bubble",n.meta==="streaming"?"typing":""])},[o("div",Cs,[(r(!0),l(B,null,V(n.parts,(a,c)=>(r(),l(B,{key:`${n.id}-${a.type}-${c}`},[a.type==="markdown"?(r(),l("div",$s,[(r(!0),l(B,null,V(a.blocks,(u,y)=>(r(),l(B,{key:`${n.id}-${c}-${y}`},[u.type==="text"?(r(),l("p",xs,f(u.content),1)):(r(),l("pre",Ts,[o("code",null,f(u.content),1)]))],64))),128))])):a.type==="thinking"?(r(),l("div",Is,[o("details",{open:!a.collapsed},[o("summary",null,f(a.title),1),o("pre",null,f(a.content),1)],8,Es)])):a.type==="tool_call"?(r(),l("div",As,[o("details",Ds,[o("summary",null,"Tool call: "+f(a.name),1),o("pre",null,f(a.args),1)])])):a.type==="tool_result"?(r(),l("div",Ns,[o("details",{open:a.status==="error"},[o("summary",null,"Tool result: "+f(a.name||"tool")+" · "+f(a.status),1),o("pre",null,f(a.output),1),a.structured?(r(),l("pre",Rs,f(a.structured),1)):$("",!0)],8,Os)])):a.type==="attachments"?(r(),l("div",Us,[o("div",Ms,[(r(!0),l(B,null,V(a.items,(u,y)=>(r(),l("div",{key:`${n.id}-${c}-${y}`,class:Z(["attachment",`attachment--${u.kind}`])},[u.kind==="image"&&u.url?(r(),l("img",{key:0,src:u.url,alt:u.label},null,8,Ps)):$("",!0),o("div",Ls,[u.kind==="path"?(r(),l("code",js,f(u.label),1)):(r(),l("span",Ws,f(u.label),1)),u.meta?(r(),l("span",Fs,f(u.meta),1)):$("",!0),u.url&&u.kind!=="image"?(r(),l("a",{key:3,href:u.url,target:"_blank",rel:"noreferrer"},"Open",8,zs)):$("",!0)])],2))),128))])])):$("",!0)],64))),128))])],2),o("div",Js,f(qt(n.ts)),1)],6))),128)),J(g)&&!de.value?(r(),l("div",Bs,[...t[13]||(t[13]=[o("div",{class:"bubble typing"},"Thinking...",-1)])])):$("",!0)]),o("div",{class:"chat-composer",onDragover:t[6]||(t[6]=K(()=>{},["prevent"])),onDrop:K(Zt,["prevent"])},[j.value.length?(r(),l("div",qs,[(r(!0),l(B,null,V(j.value,n=>(r(),l("div",{key:n.id,class:Z(["attachment-chip",n.status])},[n.mime.startsWith("image/")?(r(),l("img",{key:0,src:n.localUrl,alt:n.name},null,8,Ks)):$("",!0),o("div",Qs,[o("span",Vs,f(n.name),1),o("span",Gs,f(n.status),1)]),o("button",{class:"icon-btn",type:"button",onClick:s=>Gt(n.id)},"Remove",8,Hs)],2))),128))])):$("",!0),Be(o("textarea",{"onUpdate:modelValue":t[3]||(t[3]=n=>$e.value=n),class:"chat-input",placeholder:Mt.value,onPaste:Ht,onKeydown:fe(K(it,["exact","prevent"]),["enter"])},null,40,Zs),[[ht,$e.value]]),j.value.length?(r(),l("div",Ys,[We.value?xt.value?(r(),l("span",eo,"Model reports image support; attachments will be sent with metadata.")):(r(),l("span",to,"Model does not support images; attachments will be summarized in text.")):(r(),l("span",Xs,"Uploads disabled by server."))])):$("",!0),j.value.length?(r(),l("div",no,[o("label",so,[Be(o("input",{"onUpdate:modelValue":t[4]||(t[4]=n=>me.value=n),type:"checkbox"},null,512),[[Dn,me.value]]),t[14]||(t[14]=qe(" Include base64 when images are unsupported (large) ",-1))]),se.value?(r(),l("span",oo,f(se.value),1)):$("",!0)])):$("",!0),o("div",ao,[o("div",lo,[o("div",{class:"composer-menu",ref_key:"composerMenuEl",ref:Pe},[o("button",{class:"plus-button",type:"button",onClick:en},"+"),he.value?(r(),l("div",ro,[o("button",{class:"menu-item",type:"button",disabled:!We.value,onClick:sn}," Add file ",8,io),Y.value?(r(),l("button",{key:0,class:"menu-item",type:"button",onClick:t[5]||(t[5]=n=>pt("Health check"))}," Health check ")):$("",!0)])):$("",!0)],512),o("div",{class:"mode-menu",ref_key:"modeMenuEl",ref:Le},[o("button",{class:"mode-button",type:"button",onClick:tn},[o("span",uo,f(Pt.value),1),t[15]||(t[15]=o("span",{class:"mode-caret"},"▾",-1))]),ye.value?(r(),l("div",co,[(r(!0),l(B,null,V(Lt.value,n=>(r(),l("button",{key:n,class:"menu-item",type:"button",onClick:s=>nn(n)},f(n),9,fo))),128))])):$("",!0)],512)]),o("button",{class:"btn send-button",type:"button",disabled:Wt.value,onClick:it},f(jt.value),9,po)]),o("input",{ref_key:"filePicker",ref:Ye,class:"file-input",type:"file",accept:"*/*",multiple:"",onChange:Yt},null,544),J(I)?(r(),l("p",vo,f(J(I)),1)):$("",!0)],32)]),Y.value?(r(),l("aside",mo,[o("article",ho,[t[16]||(t[16]=o("h3",null,"Status Snapshot",-1)),J(m)?(r(),l("p",yo,"Loading /status snapshot...")):J(v)?(r(),l("p",go,f(J(v)),1)):(r(),l("div",bo,[o("div",_o,[(r(!0),l(B,null,V(Dt.value,n=>(r(),l("div",{class:"status-pill",key:n.label},[o("span",ko,f(n.label),1),o("code",null,f(n.value),1)]))),128))]),Xe.value?(r(),l("p",So,"Snapshot: "+f(Xe.value),1)):$("",!0),et.value?(r(),l("div",wo,f(et.value),1)):$("",!0)])),o("div",Co,[o("button",{class:"btn",type:"button",onClick:mn},"Refresh"),o("button",{class:"btn secondary",type:"button",onClick:ft},"Reconnect"),o("button",{class:"btn ghost",type:"button",onClick:t[7]||(t[7]=n=>pt("List capabilities"))},"List capabilities"),o("button",{class:"btn ghost",type:"button",onClick:hn},"Copy origin")])]),o("article",$o,[t[17]||(t[17]=o("h3",null,"Capabilities",-1)),tt.value.length?(r(),l("div",To,[(r(!0),l(B,null,V(tt.value,n=>(r(),l("div",{key:n.key,class:Z(["capability",n.enabled?"on":"off"])},[o("span",null,f(n.label),1),o("strong",null,f(n.enabled?"ON":"OFF"),1)],2))),128))])):(r(),l("p",xo,"No capabilities reported yet."))])])):$("",!0)],2),Y.value?(r(),l("section",Io,[t[18]||(t[18]=o("h3",null,"Live Events",-1)),t[19]||(t[19]=o("p",{class:"note"},"Most recent events from /events (replay supported).",-1)),J(x)?(r(),l("p",Eo,f(J(x)),1)):$("",!0),J(T).length?(r(),l("div",Do,[(r(!0),l(B,null,V(J(T),n=>(r(),l("div",{key:Kt(n),class:"event-item"},[o("div",No,[o("span",Oo,f(n.type),1),o("span",Ro,f(Qt(n)),1)]),o("div",Uo,f(Vt(n)),1)]))),128))])):(r(),l("div",Ao,"No events yet. Waiting for the stream..."))])):$("",!0)])]),Ie.value?(r(),l("div",{key:0,class:Z(["toast",`toast--${He.value}`]),role:"status","aria-live":"polite"},[o("span",null,f(Ge.value),1),o("button",{class:"toast-close",type:"button","aria-label":"Close",onClick:ot},"×")],2)):$("",!0),Te.value?(r(),l("div",{key:1,class:"modal-backdrop",role:"presentation",onClick:ke},[o("div",{class:"modal",role:"dialog","aria-modal":"true",tabindex:"0",ref_key:"deleteDialogEl",ref:Ve,onClick:t[8]||(t[8]=K(()=>{},["stop"])),onKeydown:[fe(K(ke,["stop","prevent"]),["escape"]),fe(K(dt,["stop","prevent"]),["enter"])]},[o("div",{class:"modal-header"},[t[20]||(t[20]=o("h3",{class:"modal-title"},"Delete session",-1)),o("button",{class:"icon-btn",type:"button",onClick:ke},"Close")]),o("p",Po,[t[21]||(t[21]=qe(" This will permanently delete ",-1)),o("strong",null,f(ve.value?.title||"this session"),1),t[22]||(t[22]=qe(" and its history. ",-1))]),o("div",Lo,[o("button",{class:"btn secondary",type:"button",disabled:X.value,onClick:ke},"Cancel",8,jo),o("button",{class:"btn danger",type:"button",disabled:X.value,onClick:dt},f(X.value?"Deleting…":"Delete"),9,Wo)])],40,Mo)])):$("",!0)],2))}});export{zo as default};
|