tmux-weblink 3.0.0 → 3.0.1
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/dist/assets/shell-client.js +51 -51
- package/dist/browser/bots-client.js +6 -6
- package/dist/lib/icons.js +1 -1
- package/dist/lib/pages/shell.js +43 -25
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{icon as D}from"../lib/icons.js";import{createMarkdownRenderer as ht}from"./markdown.js";const F=ht(document),d={catalog:null,templates:[],bots:[],approvals:[],activeId:null,items:new Map,ws:null,pollTimer:0,renderQueued:!1};let L=[],B=!0,bt=!1,it=0;function U(){try{return localStorage.getItem("tmux-web-token")||""}catch{return""}}async function b(t,e){const o=await fetch(t,{...e,headers:{"content-type":"application/json",Authorization:`Bearer ${U()}`,...e?.headers||{}}}),i=await o.text(),s=i?JSON.parse(i):null;if(!o.ok)throw new Error(s&&s.error||`HTTP ${o.status}`);return s}function n(t,e,o){const i=document.createElement(t);return e&&(i.className=e),o!==void 0&&(i.textContent=o),i}function ft(t){return t==="running"?"var(--panel-success)":t==="waiting_approval"||t==="waiting_input"?"#e0a23c":t==="failed"?"var(--panel-danger, #e5534b)":t==="completed"?"var(--panel-accent)":"var(--panel-muted)"}function N(){z||(z=requestAnimationFrame(()=>{z=0,vt()}))}let z=0,R="";function vt(){const t=document.getElementById("bots-view");if(!t)return;const e=window.visualViewport,o=window.matchMedia("(max-width: 640px)").matches,i=!document.querySelector(".sidebar")?.classList.contains("collapsed");if(d.activeId&&e&&o&&!i){const s=document.querySelector(".fixed-header"),r=s?Math.round(s.getBoundingClientRect().height):0,a=Math.round(e.offsetTop)+r,c=Math.round(e.offsetLeft),l=Math.round(e.width),u=Math.max(120,Math.round(e.height)-r),h=`fixed|${a}|${c}|${l}|${u}`;if(h===R)return;R=h,t.style.position="fixed",t.style.top=`${a}px`,t.style.left=`${c}px`,t.style.width=`${l}px`,t.style.height=`${u}px`,t.style.right="auto",t.style.bottom="auto"}else{if(R==="")return;R="",t.style.position="",t.style.top="",t.style.left="",t.style.width="",t.style.height="",t.style.right="",t.style.bottom=""}}window.visualViewport?.addEventListener("resize",N),window.visualViewport?.addEventListener("scroll",N),window.addEventListener("resize",N),document.addEventListener("click",N);const st=document.querySelector(".sidebar");st&&new MutationObserver(N).observe(st,{attributes:!0,attributeFilter:["class"]}),window.__syncBotsViewport=N;function q(){const t=d.approvals.length,e=document.getElementById("bots-inbox-badge");e&&(e.style.display=t?"inline-block":"none",e.textContent=String(t));const o=document.getElementById("bv-inbox-count");o&&(o.textContent=t?`(${t})`:""),window.__botsSnapshot=d.bots,window.__refreshSidebar?.()}function gt(){const t=document.getElementById("set-bot-templates"),e=document.getElementById("set-bot-new"),o=document.getElementById("set-bot-inbox"),i=()=>{document.getElementById("settings-popover")?.classList.remove("open"),document.getElementById("settings-backdrop")?.classList.remove("open")};t?.addEventListener("click",()=>{i(),H()}),e?.addEventListener("click",()=>{i(),Tt()}),o?.addEventListener("click",()=>{i(),ot()})}function yt(){const t=n("div","bots-view");t.id="bots-view",t.hidden=!0;const e=n("div","bots-view-head"),o=n("div","bv-title"),i=n("span","bots-dot");i.id="bv-dot";const s=n("span","bv-title-text");s.id="bv-title";const r=n("span","bv-status");r.id="bv-status",o.append(i,s,r);const a=n("div","bv-actions"),c=n("div","bv-mode"),l=n("button","bv-mode-btn");l.id="bv-mode-btn",l.type="button",l.title="\u5BA1\u6279\u6A21\u5F0F\uFF08\u70B9\u5F00\u770B\u8BF4\u660E\uFF09",l.innerHTML=`<span id="bv-mode-label"></span>${D("chevron-down",'width="12" height="12"')}`;const u=n("div","bv-mode-menu");u.id="bv-mode-menu",u.hidden=!0;for(const[m,$,v]of[["supervised","\u9ED8\u8BA4","\u53EA\u8BFB\u5DE5\u5177\uFF08read/grep/find/ls\uFF09\u76F4\u63A5\u653E\u884C\uFF1Bbash\u3001edit\u3001write\u3001\u6269\u5C55/MCP \u5DE5\u5177\u4F1A\u95EE\u4F60"],["parent-supervised","\u76D1\u7BA1","\u5176\u4F59\u5DE5\u5177\u4EA4\u7ED9\u4E0A\u7EA7 bot \u51B3\u5B9A\uFF08\u5E26\u7406\u7531\uFF09\uFF1B\u4F60\u4ECD\u7136\u80FD\u770B\u5230\u5E76\u56DE\u7B54\uFF0C\u5148\u7B54\u5148\u5F97\uFF1B\u6CA1\u6709\u4E0A\u7EA7\u65F6\u56DE\u843D\u5230\u9ED8\u8BA4"],["full-access","\u5168\u653E\u884C","\u6240\u6709\u5DE5\u5177\u76F4\u63A5\u6267\u884C\uFF0C\u4E0D\u518D\u8BE2\u95EE\u3002\u6CE8\u610F\u8FD9\u4E0D\u662F\u6C99\u7BB1"]]){const _=n("button");_.dataset.mode=m,_.innerHTML=`<b>${$}</b><span>${v}</span>`,_.onclick=()=>{u.hidden=!0,wt(m)},u.appendChild(_)}l.onclick=m=>{m.stopPropagation(),u.hidden=!u.hidden},c.append(l,u),document.addEventListener("click",m=>{c.contains(m.target)||(u.hidden=!0)});const h=n("button","btn","Allow all");h.id="bv-allow-all",h.title="Approve every pending request for this bot",h.onclick=()=>{if(!d.activeId)return;const m=d.approvals.filter($=>$.botId===d.activeId);Promise.all(m.map($=>b(`/api/bots/${$.botId}/approve`,{method:"POST",body:JSON.stringify({requestId:$.id,allow:!0})}))).finally(()=>void C(!0))};const f=n("button","btn","Needs you "),O=n("span");O.id="bv-inbox-count",f.appendChild(O),f.onclick=()=>void ot();const M=n("button","btn","Resume");M.onclick=()=>void dt(m=>b(`/api/bots/${m}/resume`,{method:"POST"}).then(()=>C(!0)));const I=n("button","btn danger","Stop");I.onclick=()=>void dt(m=>b(`/api/bots/${m}/stop`,{method:"POST"}).then(()=>C(!0)));const x=n("button","btn","Delete");x.onclick=()=>{d.activeId&&confirm("Delete this bot and its session?")&&b(`/api/bots/${d.activeId}`,{method:"DELETE"}).then(()=>{K(),C(!0)})};const E=n("button","btn");E.innerHTML=D("close",'width="14" height="14"'),E.title="Close bot view",E.onclick=()=>K(),a.append(c,h,f,M,I,x,E),e.append(o,a);const g=n("div","bots-messages");g.id="bots-messages";const y=n("button","bv-jump");y.type="button",y.id="bv-jump",y.innerHTML=`${D("chevron-down",'width="14" height="14"')}<span>Latest</span>`,y.title="Jump to the latest message",y.hidden=!0,y.onclick=()=>{B=!0,g.scrollTop=g.scrollHeight,y.hidden=!0};const j=()=>{B=g.scrollHeight-g.scrollTop-g.clientHeight<48,y.hidden=B};g.addEventListener("scroll",j,{passive:!0}),g.addEventListener("touchmove",()=>{B=!1,y.hidden=g.scrollHeight-g.clientHeight<1},{passive:!0}),g.addEventListener("wheel",()=>{B=!1},{passive:!0});const J=n("div","bots-composer-wrap"),T=n("div","bv-composer-error");T.id="bv-composer-error",T.hidden=!0;const w=n("div","bots-composer"),k=n("textarea");k.id="bots-input",k.rows=1,k.placeholder="Message the bot\u2026",k.spellcheck=!1;const p=window.matchMedia("(pointer: coarse)").matches;p||(k.enterKeyHint="send"),k.onkeydown=m=>{m.key!=="Enter"||m.shiftKey||m.isComposing||p||m.keyCode===229||(m.preventDefault(),rt())},k.oninput=()=>Q(null);const S=n("button","btn primary");S.id="bv-send",S.title="Send",S.setAttribute("aria-label","Send"),S.innerHTML='<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19V5M5 12l7-7 7 7"/></svg>',S.onclick=()=>void rt(),w.append(k,S),w.addEventListener("click",m=>{m.target?.closest("button")||document.activeElement!==k&&k.focus()}),J.append(T,w),t.append(e,g,y,J),document.querySelector(".main-area")?.appendChild(t),document.getElementById("bots-modal")||Ot()}function Q(t){const e=document.getElementById("bv-composer-error");e&&(e.textContent=t??"",e.hidden=!t)}function at(t){const e=document.getElementById("bv-send");e&&(e.disabled=t,e.setAttribute("aria-busy",t?"true":"false"),e.title=t?"Sending\u2026":"Send")}async function rt(){const t=document.getElementById("bots-input");if(!t||!d.activeId||bt||!t.value.trim())return;const e=d.activeId,o=t.value;Q(null),at(!0);try{await b(`/api/bots/${e}/input`,{method:"POST",body:JSON.stringify({text:o})}),t.value===o&&(t.value=""),B=!0}catch(i){Q(i instanceof Error?i.message:String(i))}finally{at(!1)}}function dt(t){d.activeId&&t(d.activeId).catch(e=>P({kind:"notice",level:"error",text:e instanceof Error?e.message:String(e)}))}function K(){d.activeId=null,L=[],B=!0,N();const t=document.getElementById("bots-view");t&&(t.hidden=!0);try{d.ws?.close()}catch{}d.ws=null,q();const e=document.getElementById("terminal-container"),o=document.getElementById("main-placeholder"),i=!!document.querySelector(".session-item.active:not(.bot-item)");e&&i?(e.style.display="",o&&(o.style.display="none")):o&&(o.style.display="")}async function lt(t){d.activeId=t,L=[],B=!0;const e=document.getElementById("bv-jump");e&&(e.hidden=!0),window.__collapseSidebar?.(),N(),d.items.set(t,[]);const o=document.getElementById("bots-view");o&&(o.hidden=!1);const i=document.getElementById("main-placeholder");i&&(i.style.display="none");const s=document.getElementById("terminal-container");s&&(s.style.display="none");const r=document.getElementById("file-editor");r&&(r.style.display="none"),q(),tt();try{d.ws?.close()}catch{}const a=location.protocol==="https:"?"wss:":"ws:",c=new WebSocket(`${a}//${location.host}/ws/bots/${encodeURIComponent(t)}?token=${encodeURIComponent(U())}`);d.ws=c,c.onmessage=l=>{try{pt(JSON.parse(String(l.data)))}catch{}},c.onclose=()=>{d.activeId===t&&setTimeout(()=>{d.activeId===t&&C(!0)},1500)},await C(!0)}function G(){return d.bots.find(t=>t.id===d.activeId)||null}function Y(){const t=G();if(!t)return;const e=document.getElementById("bv-title"),o=document.getElementById("bv-status"),i=document.getElementById("bv-dot");e&&(e.textContent=t.title),o&&(o.textContent=`${t.status.replace(/_/g," ")} \xB7 ${t.templateId} \xB7 ${t.projectPath}`);const s=document.getElementById("bv-mode-label");s&&t.runtimeMode&&(s.textContent=ct[t.runtimeMode]||t.runtimeMode);for(const c of document.querySelectorAll("#bv-mode-menu button"))c.classList.toggle("active",c.dataset.mode===t.runtimeMode);const r=document.getElementById("bv-allow-all"),a=d.approvals.filter(c=>c.botId===t.id).length;r&&(r.hidden=a===0,r.textContent=`Allow all (${a})`),i&&(i.style.background=ft(t.status))}const ct={supervised:"\u9ED8\u8BA4","parent-supervised":"\u76D1\u7BA1","full-access":"\u5168\u653E\u884C"};async function wt(t){if(d.activeId)try{await b(`/api/bots/${d.activeId}/mode`,{method:"POST",body:JSON.stringify({mode:t})});const e=G();e&&(e.runtimeMode=t),Y(),P({kind:"notice",level:"info",text:`\u5BA1\u6279\u6A21\u5F0F\uFF1A${ct[t]||t}`})}catch(e){P({kind:"notice",level:"error",text:e instanceof Error?e.message:String(e)})}}function P(t,e=d.activeId){if(!e)return;const o=d.items.get(e)||[];o.push(t),d.items.set(e,o),e===d.activeId&&A()}function A(){if(d.renderQueued)return;d.renderQueued=!0;const t=Math.max(0,60-(performance.now()-it));window.setTimeout(()=>{d.renderQueued=!1,it=performance.now(),tt()},t)}function X(t){switch(t.kind){case"assistant":return{text:t.text,thinking:t.thinking};case"tool":return{phase:t.phase,output:t.output,error:t.isError,durationMs:t.durationMs};case"approval":return{decided:t.decided,approvalState:t.approval.state};default:return{}}}function kt(t,e){return t.text!==e.text||t.thinking!==e.thinking||t.phase!==e.phase||t.output!==e.output||t.error!==e.error||t.durationMs!==e.durationMs||t.decided!==e.decided||t.approvalState!==e.approvalState}function Z(t){if(t.kind==="user"){const e=n("div","bv-msg bv-user");return e.appendChild(F(t.text)),e}if(t.kind==="assistant"){const e=n("div","bv-msg bv-assistant");if(t.thinking){const i=n("details","bv-thinking");i.appendChild(n("summary",void 0,"thinking")),i.appendChild(n("div",void 0,t.thinking)),e.appendChild(i)}const o=n("div","bv-text");return o.appendChild(F(t.text)),e.appendChild(o),e}return t.kind==="tool"?xt(t):t.kind==="approval"?Ct(t):n("div",`bv-notice bv-notice-${t.level}`,t.text)}function St(t,e){const o=t.querySelector("details.bv-thinking");if(e.thinking)if(o){const s=o.querySelector("div");s&&s.textContent!==e.thinking&&(s.textContent=e.thinking)}else{const s=n("details","bv-thinking");s.appendChild(n("summary",void 0,"thinking")),s.appendChild(n("div",void 0,e.thinking)),t.prepend(s)}else o&&o.remove();const i=t.querySelector(".bv-text");i&&i.replaceChildren(F(e.text))}function tt(){const t=document.getElementById("bots-messages");if(!t||!d.activeId||document.getElementById("bots-view")?.hidden)return;const e=d.items.get(d.activeId)||[],o=B;if(e.length<L.length||e.some((s,r)=>L[r]?.item!==s))t.textContent="",L=e.map(s=>{const r=Z(s);return t.appendChild(r),{item:s,snapshot:X(s),node:r}});else{for(let s=L.length;s<e.length;s++){const r=e[s],a=Z(r);t.appendChild(a),L.push({item:r,snapshot:X(r),node:a})}for(let s=0;s<e.length;s++){const r=e[s],a=L[s],c=X(r);if(kt(a.snapshot,c)){if(r.kind==="assistant")St(a.node,r);else{const l=Z(r);a.node.replaceWith(l),a.node=l}a.snapshot=c}}}o&&(t.scrollTop=t.scrollHeight)}function xt(t){const e=n("details","bv-tool");e.open=t.phase!=="end"||!!t.isError;const o=n("summary"),i=n("span","bv-tool-name",t.name);if(o.appendChild(i),t.phase!=="end"&&o.appendChild(n("span","bv-tool-phase",t.phase)),t.isError&&o.appendChild(n("span","bv-tool-error","error")),typeof t.durationMs=="number"&&o.appendChild(n("span","bv-tool-meta",`${Math.round(t.durationMs)}ms`)),e.appendChild(o),t.args!==void 0){const s=n("pre","bv-pre");s.textContent=typeof t.args=="string"?t.args:JSON.stringify(t.args,null,2),e.appendChild(s)}if(t.output){const s=n("pre","bv-pre bv-output");s.textContent=t.output,e.appendChild(s)}return e}function Ct(t){const e=n("div","bv-approval"),o=t.approval;if(e.appendChild(n("div","bv-approval-title",o.title)),o.message&&e.appendChild(n("pre","bv-pre",o.message)),t.decided)return e.appendChild(n("div","bv-approval-decided",t.decided==="allowed"?"Allowed":"Denied")),e;const i=n("input","bv-reason");i.placeholder="reason (optional)";const s=n("div","bv-approval-actions"),r=n("button","btn primary","Allow"),a=n("button","btn",o.method==="confirm"&&/^Allow (.+?)\?$/.test(o.title)?`Always allow ${/^Allow (.+?)\?$/.exec(o.title)?.[1]}`:"Always allow");a.hidden=o.method!=="confirm";const c=n("button","btn danger","Deny"),l=async(u,h=!1)=>{try{await b(`/api/bots/${o.botId}/approve`,{method:"POST",body:JSON.stringify({requestId:o.id,allow:u,always:h,reason:i.value||void 0})}),t.decided=u?"allowed":"denied",A(),C(!0)}catch(f){P({kind:"notice",level:"error",text:f instanceof Error?f.message:String(f)})}};return r.onclick=()=>void l(!0),a.onclick=()=>void l(!0,!0),c.onclick=()=>void l(!1),s.append(i,r,a,c),e.appendChild(s),e}function pt(t){const e=String(t.type||""),o=d.activeId;if(!o)return;const i=d.items.get(o)||[];if(e==="snapshot")d.items.set(o,[]);else if(e==="user")B=!0,P({kind:"user",text:String(t.text||"")});else if(e==="status"){const s=G();s&&(s.status=String(t.status||s.status)),Y(),Bt()}else if(e==="message"){const s=t.message;if(!s||String(s.role||"")!=="assistant")return;const a=It(s),c=Et(s),l=i[i.length-1];l&&l.kind==="assistant"?(l.text=a||l.text,l.thinking=c||l.thinking):i.push({kind:"assistant",text:a,thinking:c}),d.items.set(o,i),A()}else if(e==="delta"){const s=String(t.kind||""),r=String(t.delta||"");let a=i[i.length-1];(!a||a.kind!=="assistant")&&(i.push({kind:"assistant",text:"",thinking:""}),a=i[i.length-1]),a.kind==="assistant"&&(s==="text"?a.text+=r:s==="thinking"&&(a.thinking+=r)),d.items.set(o,i),A()}else if(e==="tool"){const s=String(t.callId||""),r=i.find(c=>c.kind==="tool"&&c.callId===s),a=String(t.phase||"start");r?(r.phase=a,a==="update"&&t.output&&(r.output=String(t.output)),a==="end"&&(t.output&&(r.output=String(t.output)),r.isError=t.isError===!0,typeof t.durationMs=="number"&&(r.durationMs=t.durationMs))):i.push({kind:"tool",callId:s,name:String(t.name||"tool"),args:t.args,output:t.output?String(t.output):void 0,isError:t.isError===!0,durationMs:typeof t.durationMs=="number"?t.durationMs:void 0,phase:a}),d.items.set(o,i),A()}else if(e==="approval"){const s=t.approval;if(!s)return;const r=i;for(let a=r.length-1;a>=0;a--){const c=r[a];if(c.kind==="approval"&&c.approval.id===s.id){c.approval=s,s.state!=="pending"&&(c.decided=s.state==="allowed"?"allowed":"denied"),d.items.set(o,r),A();return}}r.push({kind:"approval",approval:s}),d.items.set(o,r),A()}else e==="notice"&&P({kind:"notice",level:String(t.level||"info"),text:String(t.text||"")})}function It(t){const e=t.content;return Array.isArray(e)?e.map(o=>o&&typeof o=="object"&&o.type==="text"?String(o.text||""):"").join(""):String(t.text||"")}function Et(t){const e=t.content;return Array.isArray(e)?e.map(o=>o&&typeof o=="object"&&o.type==="thinking"?String(o.thinking||""):"").join(""):""}async function C(t=!1){try{const[e,o]=await Promise.all([b("/api/bots"),b("/api/bots/approvals")]);if(d.bots=e,d.approvals=o,q(),Y(),t&&d.activeId){const i=await b(`/api/bots/${d.activeId}/events?limit=300`);$t(i)}}catch{}}async function Bt(){try{d.bots=await b("/api/bots"),q()}catch{}}function $t(t){if(d.activeId){d.items.set(d.activeId,[]);for(const e of t)pt(e);tt()}}function Ot(){const t=n("div","bots-modal");t.id="bots-modal",t.hidden=!0;const e=n("div","bots-modal-card"),o=n("div","bots-modal-head"),i=n("span");i.id="bots-modal-title";const s=n("button","btn");s.innerHTML=D("close",'width="14" height="14"'),s.title="Close",s.onclick=()=>V(),o.append(i,s);const r=n("div","bots-modal-body");r.id="bots-modal-body",e.append(o,r),t.appendChild(e),t.onclick=a=>{a.target===t&&V()},document.body.appendChild(t)}function et(t){const e=document.getElementById("bots-modal"),o=document.getElementById("bots-modal-title"),i=document.getElementById("bots-modal-body");if(!e||!i)throw new Error("modal missing");return o&&(o.textContent=t),i.textContent="",e.hidden=!1,i}function V(){const t=document.getElementById("bots-modal");t&&(t.hidden=!0)}async function Mt(){return d.catalog||(d.catalog=await b("/api/bots/catalog")),d.catalog}async function ut(){return d.templates=await b("/api/bots/templates"),d.templates}async function H(){const t=et("Bot templates"),[e,o]=await Promise.all([Mt(),ut()]),i=n("div","bv-template-list");for(const l of o){const u=n("div","bv-template-row");u.appendChild(n("span","bv-template-name",l.manifest.name)),u.appendChild(n("span","bv-template-desc",l.manifest.description||""));const h=n("button","btn","Edit");h.onclick=()=>mt(t,e,l);const f=n("button","btn","Copy");f.title="Duplicate this template",f.onclick=()=>{const I=JSON.parse(JSON.stringify(l.manifest));I.name=`${l.manifest.name} copy`,b("/api/bots/templates",{method:"POST",body:JSON.stringify({manifest:I})}).then(()=>H()).catch(x=>alert(x instanceof Error?x.message:String(x)))};const O=n("button","btn danger","Delete");O.onclick=()=>{confirm(`Delete template ${l.manifest.name}?`)&&b(`/api/bots/templates/${l.id}`,{method:"DELETE"}).then(()=>H())};const M=n("span","bv-template-actions");M.append(h,f,O),u.appendChild(M),i.appendChild(u)}o.length===0&&i.appendChild(n("div","bots-empty","No templates yet")),t.appendChild(i);const s=n("div","bv-template-actions"),r=n("button","btn primary","New template");r.onclick=()=>mt(t,e,null);const a=n("button","btn","Export");a.title="Download templates + library as JSON",a.onclick=()=>{(async()=>{try{const l=await fetch("/api/bots/export",{headers:{Authorization:`Bearer ${U()}`}});if(!l.ok)throw new Error(`HTTP ${l.status}`);const u=await l.blob(),h=document.createElement("a");h.href=URL.createObjectURL(u),h.download=`tmux-weblink-bots-${new Date().toISOString().slice(0,10)}.json`,h.click(),setTimeout(()=>URL.revokeObjectURL(h.href),2e3)}catch(l){alert(l instanceof Error?l.message:String(l))}})()};const c=n("button","btn","Import");c.title="Restore templates from a JSON bundle",c.onclick=()=>{const l=document.createElement("input");l.type="file",l.accept="application/json,.json",l.onchange=()=>{const u=l.files?.[0];u&&(async()=>{try{const h=JSON.parse(await u.text()),f=await b("/api/bots/import",{method:"POST",body:JSON.stringify(h)});alert(`Imported ${f.templates} templates, ${f.files} library files (${f.skipped} kept)`),await H()}catch(h){alert(h instanceof Error?h.message:String(h))}})()},l.click()},s.append(r,a,c),t.appendChild(s)}function nt(t,e,o){const i=n("div","bv-field");i.appendChild(n("label","bv-label",t));const s=n("div","bv-check-grid"),r=[];for(const a of e){const c=n("label","bv-check"),l=document.createElement("input");l.type="checkbox",l.checked=o.includes(a.id),c.append(l,n("span",void 0,a.label)),a.hint&&(c.title=a.hint),s.appendChild(c),r.push({id:a.id,input:l})}return i.appendChild(s),{element:i,get:()=>r.filter(a=>a.input.checked).map(a=>a.id)}}function mt(t,e,o){t.textContent="";const i=o?JSON.parse(JSON.stringify(o.manifest)):{name:"new-bot",description:""},s=n("input","bv-input");s.value=i.name,s.placeholder="Template name";const r=n("input","bv-input");r.value=i.description||"",r.placeholder="One line description";const a=n("textarea","bv-textarea");a.rows=6,a.value=i.system||"",a.placeholder="System prompt for this bot (written to SYSTEM.md)";const c=nt("Skills",e.skills.map(p=>({id:p.id,label:p.name,hint:p.description})),i.skills||[]),l=nt("Extensions (Pi builtins + library)",e.extensions.map(p=>({id:p.id,label:`${p.name}${p.kind==="builtin"?" (builtin)":""}`,hint:p.description})),(i.extensions||[]).map(p=>p.replace(/^.*\//,"").replace(/\.(js|ts)$/,""))),u=nt("Prompt templates",e.prompts.map(p=>({id:p.id,label:p.name})),i.prompts||[]),h=n("select","bv-input");h.appendChild(new Option("none",""));for(const p of e.mcp)h.appendChild(new Option(p.name,p.id));i.mcp&&(h.value=e.mcp.find(p=>JSON.stringify(p.servers)===JSON.stringify(i.mcp?.mcpServers))?.id||"");const f=n("div","bv-field");f.appendChild(n("label","bv-label","Tools (allow list; deny always blocks)"));const O=n("div","bv-check-grid"),M=[];for(const p of e.tools){const S=n("label","bv-check"),m=document.createElement("input");m.type="checkbox",m.checked=(i.tools?.allow||[]).includes(p.name)||!i.tools?.allow?.length&&["read","grep","find","ls","edit","write","bash"].includes(p.name),S.append(m,n("span",void 0,p.name)),O.appendChild(S),M.push({name:p.name,input:m})}f.appendChild(O);const I=n("input","bv-input");I.value=(i.tools?.deny||[]).join(", "),I.placeholder="Always deny (comma separated), e.g. bash, write";const x=n("textarea","bv-textarea");x.rows=2,x.value=(i.packages||[]).join(`
|
|
2
|
-
`),x.placeholder="Pi packages, one per line (npm:@scope/pkg@1.2.3, git:..., ./path)";const
|
|
3
|
-
${p.model}`));i.model?.provider&&i.model?.id&&(
|
|
4
|
-
${i.model.id}`);const g=n("select","bv-input");for(const p of["","off","minimal","low","medium","high","xhigh","max"])g.appendChild(new Option(p||"default",p));i.model?.thinking&&(g.value=i.model.thinking);const y=n("select","bv-input");for(const p of["supervised","auto-accept-edits","full-access"])y.appendChild(new Option(p,p));y.value=i.permissions?.runtimeMode||"supervised";const
|
|
5
|
-
`),
|
|
6
|
-
`).map(v=>v.trim()).filter(Boolean),mcp:
|
|
1
|
+
import{icon as H}from"../lib/icons.js";import{createMarkdownRenderer as bt}from"./markdown.js";const F=bt(document),l={catalog:null,templates:[],bots:[],approvals:[],activeId:null,items:new Map,ws:null,pollTimer:0,renderQueued:!1};let A=[],E=!0,vt=!1,it=0;function U(){try{return localStorage.getItem("tmux-web-token")||""}catch{return""}}async function b(t,e){const o=await fetch(t,{...e,headers:{"content-type":"application/json",Authorization:`Bearer ${U()}`,...e?.headers||{}}}),i=await o.text(),s=i?JSON.parse(i):null;if(!o.ok)throw new Error(s&&s.error||`HTTP ${o.status}`);return s}function n(t,e,o){const i=document.createElement(t);return e&&(i.className=e),o!==void 0&&(i.textContent=o),i}function gt(t){return t==="running"?"var(--panel-success)":t==="waiting_approval"||t==="waiting_input"?"#e0a23c":t==="failed"?"var(--panel-danger, #e5534b)":t==="completed"?"var(--panel-accent)":"var(--panel-muted)"}function N(){z||(z=requestAnimationFrame(()=>{z=0,yt()}))}let z=0,R="";function yt(){const t=document.getElementById("bots-view");if(!t)return;const e=window.visualViewport,o=window.matchMedia("(max-width: 640px)").matches,i=!document.querySelector(".sidebar")?.classList.contains("collapsed");if(l.activeId&&e&&o&&!i){const s=document.querySelector(".fixed-header"),r=s?Math.round(s.getBoundingClientRect().height):0,a=Math.round(e.offsetTop)+r,c=Math.round(e.offsetLeft),d=Math.round(e.width),m=Math.max(120,Math.round(e.height)-r),h=`fixed|${a}|${c}|${d}|${m}`;if(h===R)return;R=h,t.style.position="fixed",t.style.top=`${a}px`,t.style.left=`${c}px`,t.style.width=`${d}px`,t.style.height=`${m}px`,t.style.right="auto",t.style.bottom="auto"}else{if(R==="")return;R="",t.style.position="",t.style.top="",t.style.left="",t.style.width="",t.style.height="",t.style.right="",t.style.bottom=""}}window.visualViewport?.addEventListener("resize",N),window.visualViewport?.addEventListener("scroll",N),window.addEventListener("resize",N),document.addEventListener("click",N);const st=document.querySelector(".sidebar");st&&new MutationObserver(N).observe(st,{attributes:!0,attributeFilter:["class"]}),window.__syncBotsViewport=N;function q(){const t=l.approvals.length,e=document.getElementById("bots-inbox-badge");e&&(e.style.display=t?"inline-block":"none",e.textContent=String(t));const o=document.getElementById("bv-inbox-count");o&&(o.textContent=t?`(${t})`:""),window.__botsSnapshot=l.bots,window.__refreshSidebar?.()}function wt(){const t=document.getElementById("set-bot-templates"),e=document.getElementById("set-bot-new"),o=document.getElementById("set-bot-inbox"),i=()=>{document.getElementById("settings-popover")?.classList.remove("open"),document.getElementById("settings-backdrop")?.classList.remove("open")};t?.addEventListener("click",()=>{i(),D()}),e?.addEventListener("click",()=>{i(),Nt()}),o?.addEventListener("click",()=>{i(),ot()})}function kt(){const t=n("div","bots-view");t.id="bots-view",t.hidden=!0;const e=n("div","bots-view-head"),o=n("div","bv-title"),i=n("span","bots-dot");i.id="bv-dot";const s=n("span","bv-title-text");s.id="bv-title";const r=n("span","bv-status");r.id="bv-status",o.append(i,s,r);const a=n("div","bv-actions"),c=n("div","bv-mode"),d=n("button","bv-mode-btn");d.id="bv-mode-btn",d.type="button",d.setAttribute("aria-haspopup","menu"),d.setAttribute("aria-expanded","false"),ut(d,"supervised");const m=n("div","bv-mode-menu");m.id="bv-mode-menu",m.setAttribute("role","menu"),m.hidden=!0;for(const[u,B,v]of[["supervised","\u9ED8\u8BA4","\u53EA\u8BFB\u5DE5\u5177\uFF08read/grep/find/ls\uFF09\u76F4\u63A5\u653E\u884C\uFF1Bbash\u3001edit\u3001write\u3001\u6269\u5C55/MCP \u5DE5\u5177\u4F1A\u95EE\u4F60"],["parent-supervised","\u76D1\u7BA1","\u5176\u4F59\u5DE5\u5177\u4EA4\u7ED9\u4E0A\u7EA7 bot \u51B3\u5B9A\uFF08\u5E26\u7406\u7531\uFF09\uFF1B\u4F60\u4ECD\u7136\u80FD\u770B\u5230\u5E76\u56DE\u7B54\uFF0C\u5148\u7B54\u5148\u5F97\uFF1B\u6CA1\u6709\u4E0A\u7EA7\u65F6\u56DE\u843D\u5230\u9ED8\u8BA4"],["full-access","\u5168\u653E\u884C","\u6240\u6709\u5DE5\u5177\u76F4\u63A5\u6267\u884C\uFF0C\u4E0D\u518D\u8BE2\u95EE\u3002\u6CE8\u610F\u8FD9\u4E0D\u662F\u6C99\u7BB1"]]){const _=n("button");_.dataset.mode=u,_.setAttribute("role","menuitemradio"),_.innerHTML=`<span class="bv-mode-row-icon">${H(pt[u],'width="14" height="14"')}</span><span class="bv-mode-row-text"><b>${B}</b><span>${v}</span></span><span class="bv-mode-row-check">${H("check",'width="13" height="13"')}</span>`,_.onclick=()=>{h(!1),St(u)},m.appendChild(_)}const h=u=>{m.hidden=!u,d.setAttribute("aria-expanded",u?"true":"false")};d.onclick=u=>{u.stopPropagation(),h(m.hidden)},c.append(d,m),document.addEventListener("click",u=>{c.contains(u.target)||h(!1)});const f=n("button","btn","Allow all");f.id="bv-allow-all",f.title="Approve every pending request for this bot",f.onclick=()=>{if(!l.activeId)return;const u=l.approvals.filter(B=>B.botId===l.activeId);Promise.all(u.map(B=>b(`/api/bots/${B.botId}/approve`,{method:"POST",body:JSON.stringify({requestId:B.id,allow:!0})}))).finally(()=>void C(!0))};const $=n("button","btn","Needs you "),O=n("span");O.id="bv-inbox-count",$.appendChild(O),$.onclick=()=>void ot();const I=n("button","btn","Resume");I.onclick=()=>void dt(u=>b(`/api/bots/${u}/resume`,{method:"POST"}).then(()=>C(!0)));const x=n("button","btn danger","Stop");x.onclick=()=>void dt(u=>b(`/api/bots/${u}/stop`,{method:"POST"}).then(()=>C(!0)));const M=n("button","btn","Delete");M.onclick=()=>{l.activeId&&confirm("Delete this bot and its session?")&&b(`/api/bots/${l.activeId}`,{method:"DELETE"}).then(()=>{K(),C(!0)})},a.append(c,f,$,I,x,M),e.append(o,a);const g=n("div","bots-messages");g.id="bots-messages";const y=n("button","bv-jump");y.type="button",y.id="bv-jump",y.innerHTML=`${H("chevron-down",'width="14" height="14"')}<span>Latest</span>`,y.title="Jump to the latest message",y.hidden=!0,y.onclick=()=>{E=!0,g.scrollTop=g.scrollHeight,y.hidden=!0};const L=()=>{E=g.scrollHeight-g.scrollTop-g.clientHeight<48,y.hidden=E};g.addEventListener("scroll",L,{passive:!0}),g.addEventListener("touchmove",()=>{E=!1,y.hidden=g.scrollHeight-g.clientHeight<1},{passive:!0}),g.addEventListener("wheel",()=>{E=!1},{passive:!0});const J=n("div","bots-composer-wrap"),T=n("div","bv-composer-error");T.id="bv-composer-error",T.hidden=!0;const w=n("div","bots-composer"),k=n("textarea");k.id="bots-input",k.rows=1,k.placeholder="Message the bot\u2026",k.spellcheck=!1;const p=window.matchMedia("(pointer: coarse)").matches;p||(k.enterKeyHint="send"),k.onkeydown=u=>{u.key!=="Enter"||u.shiftKey||u.isComposing||p||u.keyCode===229||(u.preventDefault(),rt())},k.oninput=()=>Q(null);const S=n("button","btn primary");S.id="bv-send",S.title="Send",S.setAttribute("aria-label","Send"),S.innerHTML='<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19V5M5 12l7-7 7 7"/></svg>',S.onclick=()=>void rt(),w.append(k,S),w.addEventListener("click",u=>{u.target?.closest("button")||document.activeElement!==k&&k.focus()}),J.append(T,w),t.append(e,g,y,J),document.querySelector(".main-area")?.appendChild(t),document.getElementById("bots-modal")||Tt()}function Q(t){const e=document.getElementById("bv-composer-error");e&&(e.textContent=t??"",e.hidden=!t)}function at(t){const e=document.getElementById("bv-send");e&&(e.disabled=t,e.setAttribute("aria-busy",t?"true":"false"),e.title=t?"Sending\u2026":"Send")}async function rt(){const t=document.getElementById("bots-input");if(!t||!l.activeId||vt||!t.value.trim())return;const e=l.activeId,o=t.value;Q(null),at(!0);try{await b(`/api/bots/${e}/input`,{method:"POST",body:JSON.stringify({text:o})}),t.value===o&&(t.value=""),E=!0}catch(i){Q(i instanceof Error?i.message:String(i))}finally{at(!1)}}function dt(t){l.activeId&&t(l.activeId).catch(e=>P({kind:"notice",level:"error",text:e instanceof Error?e.message:String(e)}))}function K(){l.activeId=null,A=[],E=!0,N();const t=document.getElementById("bots-view");t&&(t.hidden=!0);try{l.ws?.close()}catch{}l.ws=null,q();const e=document.getElementById("terminal-container"),o=document.getElementById("main-placeholder"),i=!!document.querySelector(".session-item.active:not(.bot-item)");e&&i?(e.style.display="",o&&(o.style.display="none")):o&&(o.style.display="")}async function lt(t){l.activeId=t,A=[],E=!0;const e=document.getElementById("bv-jump");e&&(e.hidden=!0),window.__collapseSidebar?.(),N(),l.items.set(t,[]);const o=document.getElementById("bots-view");o&&(o.hidden=!1);const i=document.getElementById("main-placeholder");i&&(i.style.display="none");const s=document.getElementById("terminal-container");s&&(s.style.display="none");const r=document.getElementById("file-editor");r&&(r.style.display="none"),q(),tt();try{l.ws?.close()}catch{}const a=location.protocol==="https:"?"wss:":"ws:",c=new WebSocket(`${a}//${location.host}/ws/bots/${encodeURIComponent(t)}?token=${encodeURIComponent(U())}`);l.ws=c,c.onmessage=d=>{try{mt(JSON.parse(String(d.data)))}catch{}},c.onclose=()=>{l.activeId===t&&setTimeout(()=>{l.activeId===t&&C(!0)},1500)},await C(!0)}function G(){return l.bots.find(t=>t.id===l.activeId)||null}function Y(){const t=G();if(!t)return;const e=document.getElementById("bv-title"),o=document.getElementById("bv-status"),i=document.getElementById("bv-dot");e&&(e.textContent=t.title),o&&(o.textContent=`${t.status.replace(/_/g," ")} \xB7 ${t.templateId} \xB7 ${t.projectPath}`);const s=document.getElementById("bv-mode-btn");s&&ut(s,t.runtimeMode||"supervised");for(const c of document.querySelectorAll("#bv-mode-menu button")){const d=c.dataset.mode===t.runtimeMode;c.classList.toggle("active",d),c.setAttribute("aria-checked",d?"true":"false")}const r=document.getElementById("bv-allow-all"),a=l.approvals.filter(c=>c.botId===t.id).length;r&&(r.hidden=a===0,r.textContent=`Allow all (${a})`),i&&(i.style.background=gt(t.status))}const ct={supervised:"\u9ED8\u8BA4","parent-supervised":"\u76D1\u7BA1","full-access":"\u5168\u653E\u884C"},pt={supervised:"shield","parent-supervised":"shield-up","full-access":"shield-alert"};function ut(t,e){const o=pt[e]??"shield";t.dataset.mode=e,t.innerHTML=H(o,'width="15" height="15"');const i=`\u5BA1\u6279\u6A21\u5F0F\uFF1A${ct[e]??e}`;t.title=`${i}\uFF08\u70B9\u5F00\u53EF\u5207\u6362\uFF09`,t.setAttribute("aria-label",i)}async function St(t){if(l.activeId)try{await b(`/api/bots/${l.activeId}/mode`,{method:"POST",body:JSON.stringify({mode:t})});const e=G();e&&(e.runtimeMode=t),Y(),P({kind:"notice",level:"info",text:`\u5BA1\u6279\u6A21\u5F0F\uFF1A${ct[t]||t}`})}catch(e){P({kind:"notice",level:"error",text:e instanceof Error?e.message:String(e)})}}function P(t,e=l.activeId){if(!e)return;const o=l.items.get(e)||[];o.push(t),l.items.set(e,o),e===l.activeId&&j()}function j(){if(l.renderQueued)return;l.renderQueued=!0;const t=Math.max(0,60-(performance.now()-it));window.setTimeout(()=>{l.renderQueued=!1,it=performance.now(),tt()},t)}function X(t){switch(t.kind){case"assistant":return{text:t.text,thinking:t.thinking};case"tool":return{phase:t.phase,output:t.output,error:t.isError,durationMs:t.durationMs};case"approval":return{decided:t.decided,approvalState:t.approval.state};default:return{}}}function xt(t,e){return t.text!==e.text||t.thinking!==e.thinking||t.phase!==e.phase||t.output!==e.output||t.error!==e.error||t.durationMs!==e.durationMs||t.decided!==e.decided||t.approvalState!==e.approvalState}function Z(t){if(t.kind==="user"){const e=n("div","bv-msg bv-user");return e.appendChild(F(t.text)),e}if(t.kind==="assistant"){const e=n("div","bv-msg bv-assistant");if(t.thinking){const i=n("details","bv-thinking");i.appendChild(n("summary",void 0,"thinking")),i.appendChild(n("div",void 0,t.thinking)),e.appendChild(i)}const o=n("div","bv-text");return o.appendChild(F(t.text)),e.appendChild(o),e}return t.kind==="tool"?It(t):t.kind==="approval"?Et(t):n("div",`bv-notice bv-notice-${t.level}`,t.text)}function Ct(t,e){const o=t.querySelector("details.bv-thinking");if(e.thinking)if(o){const s=o.querySelector("div");s&&s.textContent!==e.thinking&&(s.textContent=e.thinking)}else{const s=n("details","bv-thinking");s.appendChild(n("summary",void 0,"thinking")),s.appendChild(n("div",void 0,e.thinking)),t.prepend(s)}else o&&o.remove();const i=t.querySelector(".bv-text");i&&i.replaceChildren(F(e.text))}function tt(){const t=document.getElementById("bots-messages");if(!t||!l.activeId||document.getElementById("bots-view")?.hidden)return;const e=l.items.get(l.activeId)||[],o=E;if(e.length<A.length||e.some((s,r)=>A[r]?.item!==s))t.textContent="",A=e.map(s=>{const r=Z(s);return t.appendChild(r),{item:s,snapshot:X(s),node:r}});else{for(let s=A.length;s<e.length;s++){const r=e[s],a=Z(r);t.appendChild(a),A.push({item:r,snapshot:X(r),node:a})}for(let s=0;s<e.length;s++){const r=e[s],a=A[s],c=X(r);if(xt(a.snapshot,c)){if(r.kind==="assistant")Ct(a.node,r);else{const d=Z(r);a.node.replaceWith(d),a.node=d}a.snapshot=c}}}o&&(t.scrollTop=t.scrollHeight)}function It(t){const e=n("details","bv-tool");e.open=t.phase!=="end"||!!t.isError;const o=n("summary"),i=n("span","bv-tool-name",t.name);if(o.appendChild(i),t.phase!=="end"&&o.appendChild(n("span","bv-tool-phase",t.phase)),t.isError&&o.appendChild(n("span","bv-tool-error","error")),typeof t.durationMs=="number"&&o.appendChild(n("span","bv-tool-meta",`${Math.round(t.durationMs)}ms`)),e.appendChild(o),t.args!==void 0){const s=n("pre","bv-pre");s.textContent=typeof t.args=="string"?t.args:JSON.stringify(t.args,null,2),e.appendChild(s)}if(t.output){const s=n("pre","bv-pre bv-output");s.textContent=t.output,e.appendChild(s)}return e}function Et(t){const e=n("div","bv-approval"),o=t.approval;if(e.appendChild(n("div","bv-approval-title",o.title)),o.message&&e.appendChild(n("pre","bv-pre",o.message)),t.decided)return e.appendChild(n("div","bv-approval-decided",t.decided==="allowed"?"Allowed":"Denied")),e;const i=n("input","bv-reason");i.placeholder="reason (optional)";const s=n("div","bv-approval-actions"),r=n("button","btn primary","Allow"),a=n("button","btn",o.method==="confirm"&&/^Allow (.+?)\?$/.test(o.title)?`Always allow ${/^Allow (.+?)\?$/.exec(o.title)?.[1]}`:"Always allow");a.hidden=o.method!=="confirm";const c=n("button","btn danger","Deny"),d=async(m,h=!1)=>{try{await b(`/api/bots/${o.botId}/approve`,{method:"POST",body:JSON.stringify({requestId:o.id,allow:m,always:h,reason:i.value||void 0})}),t.decided=m?"allowed":"denied",j(),C(!0)}catch(f){P({kind:"notice",level:"error",text:f instanceof Error?f.message:String(f)})}};return r.onclick=()=>void d(!0),a.onclick=()=>void d(!0,!0),c.onclick=()=>void d(!1),s.append(i,r,a,c),e.appendChild(s),e}function mt(t){const e=String(t.type||""),o=l.activeId;if(!o)return;const i=l.items.get(o)||[];if(e==="snapshot")l.items.set(o,[]);else if(e==="user")E=!0,P({kind:"user",text:String(t.text||"")});else if(e==="status"){const s=G();s&&(s.status=String(t.status||s.status)),Y(),Ot()}else if(e==="message"){const s=t.message;if(!s||String(s.role||"")!=="assistant")return;const a=$t(s),c=Bt(s),d=i[i.length-1];d&&d.kind==="assistant"?(d.text=a||d.text,d.thinking=c||d.thinking):i.push({kind:"assistant",text:a,thinking:c}),l.items.set(o,i),j()}else if(e==="delta"){const s=String(t.kind||""),r=String(t.delta||"");let a=i[i.length-1];(!a||a.kind!=="assistant")&&(i.push({kind:"assistant",text:"",thinking:""}),a=i[i.length-1]),a.kind==="assistant"&&(s==="text"?a.text+=r:s==="thinking"&&(a.thinking+=r)),l.items.set(o,i),j()}else if(e==="tool"){const s=String(t.callId||""),r=i.find(c=>c.kind==="tool"&&c.callId===s),a=String(t.phase||"start");r?(r.phase=a,a==="update"&&t.output&&(r.output=String(t.output)),a==="end"&&(t.output&&(r.output=String(t.output)),r.isError=t.isError===!0,typeof t.durationMs=="number"&&(r.durationMs=t.durationMs))):i.push({kind:"tool",callId:s,name:String(t.name||"tool"),args:t.args,output:t.output?String(t.output):void 0,isError:t.isError===!0,durationMs:typeof t.durationMs=="number"?t.durationMs:void 0,phase:a}),l.items.set(o,i),j()}else if(e==="approval"){const s=t.approval;if(!s)return;const r=i;for(let a=r.length-1;a>=0;a--){const c=r[a];if(c.kind==="approval"&&c.approval.id===s.id){c.approval=s,s.state!=="pending"&&(c.decided=s.state==="allowed"?"allowed":"denied"),l.items.set(o,r),j();return}}r.push({kind:"approval",approval:s}),l.items.set(o,r),j()}else e==="notice"&&P({kind:"notice",level:String(t.level||"info"),text:String(t.text||"")})}function $t(t){const e=t.content;return Array.isArray(e)?e.map(o=>o&&typeof o=="object"&&o.type==="text"?String(o.text||""):"").join(""):String(t.text||"")}function Bt(t){const e=t.content;return Array.isArray(e)?e.map(o=>o&&typeof o=="object"&&o.type==="thinking"?String(o.thinking||""):"").join(""):""}async function C(t=!1){try{const[e,o]=await Promise.all([b("/api/bots"),b("/api/bots/approvals")]);if(l.bots=e,l.approvals=o,q(),Y(),t&&l.activeId){const i=await b(`/api/bots/${l.activeId}/events?limit=300`);Mt(i)}}catch{}}async function Ot(){try{l.bots=await b("/api/bots"),q()}catch{}}function Mt(t){if(l.activeId){l.items.set(l.activeId,[]);for(const e of t)mt(e);tt()}}function Tt(){const t=n("div","bots-modal");t.id="bots-modal",t.hidden=!0;const e=n("div","bots-modal-card"),o=n("div","bots-modal-head"),i=n("span");i.id="bots-modal-title";const s=n("button","btn");s.innerHTML=H("close",'width="14" height="14"'),s.title="Close",s.onclick=()=>V(),o.append(i,s);const r=n("div","bots-modal-body");r.id="bots-modal-body",e.append(o,r),t.appendChild(e),t.onclick=a=>{a.target===t&&V()},document.body.appendChild(t)}function et(t){const e=document.getElementById("bots-modal"),o=document.getElementById("bots-modal-title"),i=document.getElementById("bots-modal-body");if(!e||!i)throw new Error("modal missing");return o&&(o.textContent=t),i.textContent="",e.hidden=!1,i}function V(){const t=document.getElementById("bots-modal");t&&(t.hidden=!0)}async function At(){return l.catalog||(l.catalog=await b("/api/bots/catalog")),l.catalog}async function ht(){return l.templates=await b("/api/bots/templates"),l.templates}async function D(){const t=et("Bot templates"),[e,o]=await Promise.all([At(),ht()]),i=n("div","bv-template-list");for(const d of o){const m=n("div","bv-template-row");m.appendChild(n("span","bv-template-name",d.manifest.name)),m.appendChild(n("span","bv-template-desc",d.manifest.description||""));const h=n("button","btn","Edit");h.onclick=()=>ft(t,e,d);const f=n("button","btn","Copy");f.title="Duplicate this template",f.onclick=()=>{const I=JSON.parse(JSON.stringify(d.manifest));I.name=`${d.manifest.name} copy`,b("/api/bots/templates",{method:"POST",body:JSON.stringify({manifest:I})}).then(()=>D()).catch(x=>alert(x instanceof Error?x.message:String(x)))};const $=n("button","btn danger","Delete");$.onclick=()=>{confirm(`Delete template ${d.manifest.name}?`)&&b(`/api/bots/templates/${d.id}`,{method:"DELETE"}).then(()=>D())};const O=n("span","bv-template-actions");O.append(h,f,$),m.appendChild(O),i.appendChild(m)}o.length===0&&i.appendChild(n("div","bots-empty","No templates yet")),t.appendChild(i);const s=n("div","bv-template-actions"),r=n("button","btn primary","New template");r.onclick=()=>ft(t,e,null);const a=n("button","btn","Export");a.title="Download templates + library as JSON",a.onclick=()=>{(async()=>{try{const d=await fetch("/api/bots/export",{headers:{Authorization:`Bearer ${U()}`}});if(!d.ok)throw new Error(`HTTP ${d.status}`);const m=await d.blob(),h=document.createElement("a");h.href=URL.createObjectURL(m),h.download=`tmux-weblink-bots-${new Date().toISOString().slice(0,10)}.json`,h.click(),setTimeout(()=>URL.revokeObjectURL(h.href),2e3)}catch(d){alert(d instanceof Error?d.message:String(d))}})()};const c=n("button","btn","Import");c.title="Restore templates from a JSON bundle",c.onclick=()=>{const d=document.createElement("input");d.type="file",d.accept="application/json,.json",d.onchange=()=>{const m=d.files?.[0];m&&(async()=>{try{const h=JSON.parse(await m.text()),f=await b("/api/bots/import",{method:"POST",body:JSON.stringify(h)});alert(`Imported ${f.templates} templates, ${f.files} library files (${f.skipped} kept)`),await D()}catch(h){alert(h instanceof Error?h.message:String(h))}})()},d.click()},s.append(r,a,c),t.appendChild(s)}function nt(t,e,o){const i=n("div","bv-field");i.appendChild(n("label","bv-label",t));const s=n("div","bv-check-grid"),r=[];for(const a of e){const c=n("label","bv-check"),d=document.createElement("input");d.type="checkbox",d.checked=o.includes(a.id),c.append(d,n("span",void 0,a.label)),a.hint&&(c.title=a.hint),s.appendChild(c),r.push({id:a.id,input:d})}return i.appendChild(s),{element:i,get:()=>r.filter(a=>a.input.checked).map(a=>a.id)}}function ft(t,e,o){t.textContent="";const i=o?JSON.parse(JSON.stringify(o.manifest)):{name:"new-bot",description:""},s=n("input","bv-input");s.value=i.name,s.placeholder="Template name";const r=n("input","bv-input");r.value=i.description||"",r.placeholder="One line description";const a=n("textarea","bv-textarea");a.rows=6,a.value=i.system||"",a.placeholder="System prompt for this bot (written to SYSTEM.md)";const c=nt("Skills",e.skills.map(p=>({id:p.id,label:p.name,hint:p.description})),i.skills||[]),d=nt("Extensions (Pi builtins + library)",e.extensions.map(p=>({id:p.id,label:`${p.name}${p.kind==="builtin"?" (builtin)":""}`,hint:p.description})),(i.extensions||[]).map(p=>p.replace(/^.*\//,"").replace(/\.(js|ts)$/,""))),m=nt("Prompt templates",e.prompts.map(p=>({id:p.id,label:p.name})),i.prompts||[]),h=n("select","bv-input");h.appendChild(new Option("none",""));for(const p of e.mcp)h.appendChild(new Option(p.name,p.id));i.mcp&&(h.value=e.mcp.find(p=>JSON.stringify(p.servers)===JSON.stringify(i.mcp?.mcpServers))?.id||"");const f=n("div","bv-field");f.appendChild(n("label","bv-label","Tools (allow list; deny always blocks)"));const $=n("div","bv-check-grid"),O=[];for(const p of e.tools){const S=n("label","bv-check"),u=document.createElement("input");u.type="checkbox",u.checked=(i.tools?.allow||[]).includes(p.name)||!i.tools?.allow?.length&&["read","grep","find","ls","edit","write","bash"].includes(p.name),S.append(u,n("span",void 0,p.name)),$.appendChild(S),O.push({name:p.name,input:u})}f.appendChild($);const I=n("input","bv-input");I.value=(i.tools?.deny||[]).join(", "),I.placeholder="Always deny (comma separated), e.g. bash, write";const x=n("textarea","bv-textarea");x.rows=2,x.value=(i.packages||[]).join(`
|
|
2
|
+
`),x.placeholder="Pi packages, one per line (npm:@scope/pkg@1.2.3, git:..., ./path)";const M=n("select","bv-input");M.appendChild(new Option("default (Pi settings)",""));for(const p of e.models)M.appendChild(new Option(`${p.provider}/${p.model}`,`${p.provider}
|
|
3
|
+
${p.model}`));i.model?.provider&&i.model?.id&&(M.value=`${i.model.provider}
|
|
4
|
+
${i.model.id}`);const g=n("select","bv-input");for(const p of["","off","minimal","low","medium","high","xhigh","max"])g.appendChild(new Option(p||"default",p));i.model?.thinking&&(g.value=i.model.thinking);const y=n("select","bv-input");for(const p of["supervised","auto-accept-edits","full-access"])y.appendChild(new Option(p,p));y.value=i.permissions?.runtimeMode||"supervised";const L=n("select","bv-input");L.appendChild(new Option("ignore project .pi (recommended)","ignore")),L.appendChild(new Option("inherit project .pi (needs trust)","inherit")),L.value=i.projectResources||"ignore";const J=n("label","bv-check"),T=document.createElement("input");T.type="checkbox",T.checked=!!i.orchestrator,J.append(T,n("span",void 0,"Super bot: gets orchestration tools (create/stop/status child bots)"));const w=(p,S)=>{const u=n("div","bv-field");return u.appendChild(n("label","bv-label",p)),u.appendChild(S),u};t.append(w("Name",s),w("Description",r),w("System prompt",a),c.element,d.element,m.element,w("MCP preset",h),f,w("Always deny tools",I),w("Packages",x),w("Model",M),w("Thinking level",g),w("Approval mode",y),w("Project resources",L),J);const k=n("button","btn primary",o?"Save template":"Create template");k.onclick=async()=>{const[p,S]=M.value.split(`
|
|
5
|
+
`),u=e.mcp.find(v=>v.id===h.value),B={name:s.value.trim()||"bot",description:r.value.trim()||void 0,system:a.value.trim()||void 0,skills:c.get(),extensions:d.get().map(v=>(v.startsWith("builtin:"),v)),prompts:m.get(),packages:x.value.split(`
|
|
6
|
+
`).map(v=>v.trim()).filter(Boolean),mcp:u?{mcpServers:u.servers}:void 0,tools:{allow:O.filter(v=>v.input.checked).map(v=>v.name),deny:I.value.split(",").map(v=>v.trim()).filter(Boolean)},model:p?{provider:p,id:S,thinking:g.value||void 0}:void 0,permissions:{runtimeMode:y.value},projectResources:L.value==="inherit"?"inherit":"ignore",orchestrator:T.checked||void 0};try{await b("/api/bots/templates",{method:"POST",body:JSON.stringify({id:o?.id,manifest:B})}),V(),await D()}catch(v){alert(v instanceof Error?v.message:String(v))}},t.appendChild(k)}async function Nt(){return Lt("")}async function Lt(t){const e=et("New bot"),o=await ht();if(o.length===0){e.appendChild(n("div","bots-empty","No templates yet \u2014 create one with \u201CNew template\u201D."));return}const i=n("select","bv-input");for(const m of o)i.appendChild(new Option(m.manifest.name,m.id));const s=n("input","bv-input");s.placeholder="Title (defaults to template name)";const r=n("input","bv-input");r.placeholder="/path/to/project";const a=t||l.bots[0]?.projectPath||"";r.value=a;const c=n("select","bv-input");c.appendChild(new Option("shared \u2014 run in the project folder","shared")),c.appendChild(new Option("worktree \u2014 isolated git worktree","worktree")),e.append(W("Template",i),W("Title",s),W("Project path",r),W("Workspace",c));const d=n("button","btn primary","Create bot");d.onclick=async()=>{try{const m=await b("/api/bots",{method:"POST",body:JSON.stringify({templateId:i.value,title:s.value.trim()||void 0,projectPath:r.value.trim()||void 0,isolation:c.value})});V(),await C(!0),await lt(m.id)}catch(m){alert(m instanceof Error?m.message:String(m))}},e.appendChild(d)}function W(t,e){const o=n("div","bv-field");return o.appendChild(n("label","bv-label",t)),o.appendChild(e),o}async function ot(){const t=et("Needs you");if(l.approvals=await b("/api/bots/approvals"),l.approvals.length===0){t.appendChild(n("div","bots-empty","Nothing waiting."));return}for(const e of l.approvals){const o=n("div","bv-approval");o.appendChild(n("div","bv-approval-title",`${e.botTitle}: ${e.title}`)),e.message&&o.appendChild(n("pre","bv-pre",e.message));const i=n("input","bv-reason");i.placeholder="reason (optional)";const s=n("div","bv-approval-actions"),r=n("button","btn primary","Allow"),a=n("button","btn danger","Deny"),c=async d=>{await b(`/api/bots/${e.botId}/approve`,{method:"POST",body:JSON.stringify({requestId:e.id,allow:d,reason:i.value||void 0})}),await C(!0),await ot()};r.onclick=()=>void c(!0),a.onclick=()=>void c(!1),s.append(i,r,a),o.appendChild(s),t.appendChild(o)}}function Jt(){window.__botsInited||(window.__botsInited=!0,kt(),wt(),window.__openBot=lt,document.addEventListener("click",t=>{const e=t.target;e&&(e.closest(".session-item.bot-item")||e.closest(".session-item")&&l.activeId&&setTimeout(()=>K(),0))},!0),document.addEventListener("click",t=>{const e=t.target;!e||!l.activeId||(e.closest("#mode-files")||e.closest(".file-tree-item")||e.closest(".file-roots-list li"))&&K()}),C(!0),l.pollTimer=window.setInterval(()=>{document.hidden||C()},6e3),window.addEventListener("beforeunload",()=>window.clearInterval(l.pollTimer)))}export{Jt as initBots,Lt as openNewBotForPath};
|
package/dist/lib/icons.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a={menu:"M3 6h18v2H3V6zm0 5h18v2H3v-2zm0 5h18v2H3v-2z",close:"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7a1 1 0 1 0-1.41 1.41L10.59 12l-4.89 4.89a1 1 0 1 0 1.41 1.41L12 13.41l4.89 4.89a1 1 0 1 0 1.41-1.41L13.41 12l4.89-4.89a1 1 0 0 0 0-1.4z",search:"M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z",refresh:"M17.65 6.35A7.96 7.96 0 0 0 12 4a8 8 0 1 0 8 8h-2a6 6 0 1 1-6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z",add:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",edit:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM5.92 19H5v-.92l9.06-9.06.92.92L5.92 19zm13.66-12.83a1 1 0 0 0 0-1.41l-1.34-1.34a1 1 0 0 0-1.41 0l-1.05 1.05 2.75 2.75 1.05-1.05z",delete:"M15 4V3H9v1H4v2h1.5l.81 13.05A2 2 0 0 0 8.3 21h7.4a2 2 0 0 0 1.99-1.95L18.5 6H20V4h-5zm-5.5 2h5l-.75 12h-3.5L9.5 6z",check:"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z",sessions:"M4 6h16v2H4V6zm0 5h16v2H4v-2zm0 5h16v2H4v-2z",notes:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm-1 2 5 5h-5V4zM6 20V4h5v7h7v9H6z",schedule:"M19 4h-1V2h-2v2H8V2H6v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V10h14v10zM9 14H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2zm-8 4H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2z",agents:"M12 2a5 5 0 1 0 0 10 5 5 0 0 0 0-10zm0 8a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm-7 13v-2a5 5 0 0 1 5-5h4a5 5 0 0 1 5 5v2h2v-2a7 7 0 0 0-7-7H10a7 7 0 0 0-7 7v2h2z",history:"M13 3a9 9 0 0 0-9 9H1l4 4 4-4H6a7 7 0 1 1 7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42A8.96 8.96 0 0 0 13 21a9 9 0 0 0 0-18zm-1 5v5l4.25 2.55.75-1.23-3.5-2.08V8H12z","quick-commands":"M13 3 4 14h7l-1 7 9-11h-7l1-7z",windows:"M4 6h16v2H4V6zm0 5h10v2H4v-2zm0 5h16v2H4v-2z",terminal:"M4 17.6 6.4 20l8-8-8-8L4 6.4 11.6 12 4 17.6zM20 18h-8v2h8v-2z",microphone:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5-3c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z",keyboard:"M20 5H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-9 3h2v2h-2V8zm0 3h2v2h-2v-2zM8 8h2v2H8V8zm0 3h2v2H8v-2zm-1 2H5v-2h2v2zm0-3H5V8h2v2zm9 7H8v-2h8v2zm0-4h-2v-2h2v2zm0-3h-2V8h2v2zm3 3h-2v-2h2v2zm0-3h-2V8h2v2z",bot:"M11 2h2v3h2a3 3 0 0 1 3 3v1h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-1v1a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-1H5a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2h1V8a3 3 0 0 1 3-3h2V2zm-2 6v1h6V8H9zm-2 5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm10 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z",layers:"M12 2 2 7l10 5 10-5-10-5zm0 7.5L4.5 5.8 12 2l7.5 3.8L12 9.5zM2 12l10 5 10-5-1.9-.95L12 14.9l-8.1-3.85L2 12zm0 4.5 10 5 10-5-1.9-.95L12 19.4l-8.1-3.85-1.9.95z",inbox:"M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2zm0 16H5v-3h3.6a3.5 3.5 0 0 0 6.8 0H19v3zm0-5h-4.7a3.5 3.5 0 0 1-6.6 0H5V5h14v9z","chevron-down":"M7.4 8.6 12 13.2l4.6-4.6L18 10l-6 6-6-6 1.4-1.4z",settings:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6a3.6 3.6 0 1 1 0-7.2 3.6 3.6 0 0 1 0 7.2z",pin:"M16 12V4h1V2H7v2h1v8l-4 4v2h5.2v6h1.6v-6H20v-2l-4-4z","pin-outline":"M16 12V4h1V2H7v2h1v8l-4 4v2h5.2v6h1.6v-6H20v-2l-4-4zm-4.8 7.2V11l2-2V4h1.6v5l2 2v5.2H11.2z",folder:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z",file:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm-1 2 5 5h-5V4zM6 20V4h5v7h7v9H6z",worktree:"M6 3a3 3 0 0 0-1 5.83v6.34a3 3 0 1 0 2 0V8.83A3 3 0 0 0 6 3zm0 2a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm0 12a1 1 0 1 1 0 2 1 1 0 0 1 0-2zM18 3a3 3 0 0 0-1 5.83V9a4 4 0 0 1-4 4h-2a3 3 0 1 0 0 2h2a6 6 0 0 0 6-6v-.17A3 3 0 0 0 18 3zm0 2a1 1 0 1 1 0 2 1 1 0 0 1 0-2zM9 13a1 1 0 1 1 0 2 1 1 0 0 1 0-2z",copy:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z",export:"M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z",chevronRight:"M9.29 6.71a1 1 0 0 0 0 1.41L13.17 12l-3.88 3.88a1 1 0 1 0 1.41 1.41l4.59-4.59a1 1 0 0 0 0-1.41L10.7 6.7a1 1 0 0 0-1.41.01z",lightning:"M11 21h-1l1-7H7.5c-.58 0-.57-.32-.38-.66.19-.33.51-.89.73-1.27L13 3h1l-1 7h3.5c.49 0 .56.33.47.51l-.07.15c-.22.46-.58 1.18-.78 1.58L11 21z","git-branch":"M13.5 7a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0zm0 10a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0zM11 9.5v5.1a4.03 4.03 0 0 0-3-.1V9.4a4.03 4.03 0 0 0 3 .1z",external:"M14 3h7v7h-2V6l-9.29 9.29-1.41-1.41L17.59 4.5H14V3zm4 16H5V5h7V3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7h-2v7z",play:"M8 5v14l11-7L8 5z",stop:"M6 6h12v12H6V6z",warning:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z",info:"M11 7h2v2h-2V7zm0 4h2v6h-2v-6zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z",spinner:"M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46A7.93 7.93 0 0 0 20 12c0-4.42-3.58-8-8-8z",dots:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"};function l(h){return a[h]??a.menu}function c(h,v=""){return`<svg viewBox="0 0 24 24" fill="currentColor"${v?" "+v:""}><path d="${l(h)}"/></svg>`}function
|
|
1
|
+
const a={menu:"M3 6h18v2H3V6zm0 5h18v2H3v-2zm0 5h18v2H3v-2z",close:"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7a1 1 0 1 0-1.41 1.41L10.59 12l-4.89 4.89a1 1 0 1 0 1.41 1.41L12 13.41l4.89 4.89a1 1 0 1 0 1.41-1.41L13.41 12l4.89-4.89a1 1 0 0 0 0-1.4z",search:"M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z",refresh:"M17.65 6.35A7.96 7.96 0 0 0 12 4a8 8 0 1 0 8 8h-2a6 6 0 1 1-6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z",add:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",edit:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM5.92 19H5v-.92l9.06-9.06.92.92L5.92 19zm13.66-12.83a1 1 0 0 0 0-1.41l-1.34-1.34a1 1 0 0 0-1.41 0l-1.05 1.05 2.75 2.75 1.05-1.05z",delete:"M15 4V3H9v1H4v2h1.5l.81 13.05A2 2 0 0 0 8.3 21h7.4a2 2 0 0 0 1.99-1.95L18.5 6H20V4h-5zm-5.5 2h5l-.75 12h-3.5L9.5 6z",check:"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z",sessions:"M4 6h16v2H4V6zm0 5h16v2H4v-2zm0 5h16v2H4v-2z",notes:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm-1 2 5 5h-5V4zM6 20V4h5v7h7v9H6z",schedule:"M19 4h-1V2h-2v2H8V2H6v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V10h14v10zM9 14H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2zm-8 4H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2z",agents:"M12 2a5 5 0 1 0 0 10 5 5 0 0 0 0-10zm0 8a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm-7 13v-2a5 5 0 0 1 5-5h4a5 5 0 0 1 5 5v2h2v-2a7 7 0 0 0-7-7H10a7 7 0 0 0-7 7v2h2z",history:"M13 3a9 9 0 0 0-9 9H1l4 4 4-4H6a7 7 0 1 1 7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42A8.96 8.96 0 0 0 13 21a9 9 0 0 0 0-18zm-1 5v5l4.25 2.55.75-1.23-3.5-2.08V8H12z","quick-commands":"M13 3 4 14h7l-1 7 9-11h-7l1-7z",windows:"M4 6h16v2H4V6zm0 5h10v2H4v-2zm0 5h16v2H4v-2z",terminal:"M4 17.6 6.4 20l8-8-8-8L4 6.4 11.6 12 4 17.6zM20 18h-8v2h8v-2z",microphone:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5-3c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z",keyboard:"M20 5H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-9 3h2v2h-2V8zm0 3h2v2h-2v-2zM8 8h2v2H8V8zm0 3h2v2H8v-2zm-1 2H5v-2h2v2zm0-3H5V8h2v2zm9 7H8v-2h8v2zm0-4h-2v-2h2v2zm0-3h-2V8h2v2zm3 3h-2v-2h2v2zm0-3h-2V8h2v2z",bot:"M11 2h2v3h2a3 3 0 0 1 3 3v1h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-1v1a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-1H5a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2h1V8a3 3 0 0 1 3-3h2V2zm-2 6v1h6V8H9zm-2 5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm10 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z",layers:"M12 2 2 7l10 5 10-5-10-5zm0 7.5L4.5 5.8 12 2l7.5 3.8L12 9.5zM2 12l10 5 10-5-1.9-.95L12 14.9l-8.1-3.85L2 12zm0 4.5 10 5 10-5-1.9-.95L12 19.4l-8.1-3.85-1.9.95z",inbox:"M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2zm0 16H5v-3h3.6a3.5 3.5 0 0 0 6.8 0H19v3zm0-5h-4.7a3.5 3.5 0 0 1-6.6 0H5V5h14v9z","chevron-down":"M7.4 8.6 12 13.2l4.6-4.6L18 10l-6 6-6-6 1.4-1.4z",settings:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6a3.6 3.6 0 1 1 0-7.2 3.6 3.6 0 0 1 0 7.2z",pin:"M16 12V4h1V2H7v2h1v8l-4 4v2h5.2v6h1.6v-6H20v-2l-4-4z","pin-outline":"M16 12V4h1V2H7v2h1v8l-4 4v2h5.2v6h1.6v-6H20v-2l-4-4zm-4.8 7.2V11l2-2V4h1.6v5l2 2v5.2H11.2z",folder:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z",file:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm-1 2 5 5h-5V4zM6 20V4h5v7h7v9H6z",worktree:"M6 3a3 3 0 0 0-1 5.83v6.34a3 3 0 1 0 2 0V8.83A3 3 0 0 0 6 3zm0 2a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm0 12a1 1 0 1 1 0 2 1 1 0 0 1 0-2zM18 3a3 3 0 0 0-1 5.83V9a4 4 0 0 1-4 4h-2a3 3 0 1 0 0 2h2a6 6 0 0 0 6-6v-.17A3 3 0 0 0 18 3zm0 2a1 1 0 1 1 0 2 1 1 0 0 1 0-2zM9 13a1 1 0 1 1 0 2 1 1 0 0 1 0-2z",copy:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z",export:"M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z",chevronRight:"M9.29 6.71a1 1 0 0 0 0 1.41L13.17 12l-3.88 3.88a1 1 0 1 0 1.41 1.41l4.59-4.59a1 1 0 0 0 0-1.41L10.7 6.7a1 1 0 0 0-1.41.01z",lightning:"M11 21h-1l1-7H7.5c-.58 0-.57-.32-.38-.66.19-.33.51-.89.73-1.27L13 3h1l-1 7h3.5c.49 0 .56.33.47.51l-.07.15c-.22.46-.58 1.18-.78 1.58L11 21z","git-branch":"M13.5 7a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0zm0 10a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0zM11 9.5v5.1a4.03 4.03 0 0 0-3-.1V9.4a4.03 4.03 0 0 0 3 .1z",external:"M14 3h7v7h-2V6l-9.29 9.29-1.41-1.41L17.59 4.5H14V3zm4 16H5V5h7V3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7h-2v7z",play:"M8 5v14l11-7L8 5z",stop:"M6 6h12v12H6V6z",warning:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z",info:"M11 7h2v2h-2V7zm0 4h2v6h-2v-6zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z",shield:"M12 2 4 5v6c0 5.55 3.84 10.74 8 12 4.16-1.26 8-6.45 8-12V5l-8-3zm0 2.18 6 2.25V11c0 4.52-3.05 8.86-6 10-2.95-1.14-6-5.48-6-10V6.43l6-2.25z","shield-up":"M12 2 4 5v6c0 5.55 3.84 10.74 8 12 4.16-1.26 8-6.45 8-12V5l-8-3zm0 2.18 6 2.25V11c0 4.52-3.05 8.86-6 10-2.95-1.14-6-5.48-6-10V6.43l6-2.25zM13 8.6v4.6h2l-3 3.6-3-3.6h2V8.6h2z","shield-alert":"M12 2 4 5v6c0 5.55 3.84 10.74 8 12 4.16-1.26 8-6.45 8-12V5l-8-3zm0 2.18 6 2.25V11c0 4.52-3.05 8.86-6 10-2.95-1.14-6-5.48-6-10V6.43l6-2.25zM11 7.5h2v5h-2v-5zm0 6.5h2v2h-2v-2z",spinner:"M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46A7.93 7.93 0 0 0 20 12c0-4.42-3.58-8-8-8z",dots:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"};function l(h){return a[h]??a.menu}function c(h,v=""){return`<svg viewBox="0 0 24 24" fill="currentColor"${v?" "+v:""}><path d="${l(h)}"/></svg>`}function m(h){return`<path d="${l(h)}"/>`}const V={};function H(h,v){const z=V[h];return z?c(z):v?.trim().startsWith("<svg")?v:`<span style="font-size:18px;line-height:1">${v??""}</span>`}export{H as extIcon,c as icon,l as iconPath,m as iconPathString};
|
package/dist/lib/pages/shell.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as b,newSessionModalHTML as x,newSessionModalScript as g,reducedMotion as f}from"../shared-layout.js";import{icon as o}from"../icons.js";function m(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function a(e="var(--panel-accent)"){return`box-shadow: 0 0 0 2px ${e}; outline: none;`}function w(e){const{theme:t,fsRoots:r,terminalCfg:i,scrollback:
|
|
1
|
+
import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as b,newSessionModalHTML as x,newSessionModalScript as g,reducedMotion as f}from"../shared-layout.js";import{icon as o}from"../icons.js";function m(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function a(e="var(--panel-accent)"){return`box-shadow: 0 0 0 2px ${e}; outline: none;`}function w(e){const{theme:t,fsRoots:r,terminalCfg:i,scrollback:s,wsBase:p}=e,n=e.version?m(e.version):"",l=`
|
|
2
2
|
*, *::before, *::after { box-sizing: border-box; }
|
|
3
3
|
html, body {
|
|
4
4
|
background: var(--page-bg); color: var(--page-fg);
|
|
@@ -225,34 +225,48 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as b,newSes
|
|
|
225
225
|
}
|
|
226
226
|
.session-group-header:hover .sg-add-bot { opacity: 1; color: var(--panel-accent); border-color: var(--panel-accent); }
|
|
227
227
|
@media (hover: none) { .session-group-header .sg-add-bot { opacity: 0.85; } }
|
|
228
|
-
.bv-mode { position: relative; }
|
|
228
|
+
.bv-mode { position: relative; display: inline-flex; }
|
|
229
229
|
.bv-mode-btn {
|
|
230
|
-
display: inline-flex; align-items: center;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
231
|
+
width: 28px; height: 28px; padding: 0; flex: 0 0 auto;
|
|
232
|
+
background: var(--page-bg); color: var(--panel-muted);
|
|
233
|
+
border: 1px solid var(--panel-border); border-radius: 8px;
|
|
234
|
+
cursor: pointer; touch-action: manipulation;
|
|
235
|
+
transition: color 0.15s, border-color 0.15s, background 0.15s;
|
|
234
236
|
}
|
|
235
237
|
.bv-mode-btn:hover { border-color: var(--panel-accent); color: var(--panel-accent); }
|
|
238
|
+
.bv-mode-btn[aria-expanded="true"] { border-color: var(--panel-accent); color: var(--panel-accent); background: color-mix(in srgb, var(--panel-accent) 10%, transparent); }
|
|
239
|
+
/* The shield glyph carries the mode: plain = supervised, arrow = delegated,
|
|
240
|
+
exclamation = everyone runs unattended. */
|
|
241
|
+
.bv-mode-btn[data-mode="parent-supervised"] { color: var(--panel-accent); }
|
|
242
|
+
.bv-mode-btn[data-mode="full-access"] { color: #e0a23c; border-color: color-mix(in srgb, #e0a23c 45%, var(--panel-border)); }
|
|
236
243
|
.bv-mode-menu {
|
|
237
|
-
position: absolute; right: 0; top: calc(100% +
|
|
238
|
-
width:
|
|
239
|
-
border-radius:
|
|
244
|
+
position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
|
|
245
|
+
width: 320px; background: var(--panel-bg); border: 1px solid var(--panel-border);
|
|
246
|
+
border-radius: 10px; padding: 4px; display: flex; flex-direction: column; gap: 2px;
|
|
240
247
|
box-shadow: 0 8px 24px rgba(0,0,0,0.35);
|
|
241
248
|
}
|
|
242
249
|
.bv-mode-menu[hidden] { display: none; }
|
|
243
250
|
.bv-mode-menu button {
|
|
244
|
-
display:
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
.bv-mode-menu button
|
|
251
|
+
display: grid; grid-template-columns: 18px minmax(0, 1fr) 14px;
|
|
252
|
+
align-items: start; gap: 8px;
|
|
253
|
+
text-align: left; background: none; border: none; border-radius: 8px; padding: 8px 9px;
|
|
254
|
+
color: var(--page-fg); cursor: pointer; font: inherit; touch-action: manipulation;
|
|
255
|
+
}
|
|
256
|
+
.bv-mode-menu button:hover { background: color-mix(in srgb, var(--panel-accent) 8%, transparent); }
|
|
257
|
+
.bv-mode-menu button.active { background: color-mix(in srgb, var(--panel-accent) 12%, transparent); }
|
|
258
|
+
.bv-mode-row-icon { color: var(--panel-muted); padding-top: 1px; }
|
|
259
|
+
.bv-mode-row-icon svg { display: block; }
|
|
260
|
+
.bv-mode-menu button.active .bv-mode-row-icon { color: var(--panel-accent); }
|
|
261
|
+
.bv-mode-menu button[data-mode="full-access"] .bv-mode-row-icon { color: #e0a23c; }
|
|
262
|
+
.bv-mode-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
|
250
263
|
.bv-mode-menu b { font-size: 12px; font-weight: 600; }
|
|
251
|
-
.bv-mode-menu span { font-size: 11px; color: var(--panel-muted); line-height: 1.
|
|
252
|
-
.bv-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
264
|
+
.bv-mode-menu .bv-mode-row-text span { font-size: 11px; color: var(--panel-muted); line-height: 1.45; }
|
|
265
|
+
.bv-mode-row-check { color: var(--panel-accent); visibility: hidden; padding-top: 2px; }
|
|
266
|
+
.bv-mode-menu button.active .bv-mode-row-check { visibility: visible; }
|
|
267
|
+
.bv-actions .btn {
|
|
268
|
+
height: 28px; min-height: 28px; padding: 0 10px;
|
|
269
|
+
font-size: 11.5px; border-radius: 8px;
|
|
256
270
|
}
|
|
257
271
|
.bv-actions .btn[hidden] { display: none; }
|
|
258
272
|
|
|
@@ -754,8 +768,7 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as b,newSes
|
|
|
754
768
|
.bv-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
|
755
769
|
.bv-title-text { font-family: var(--font-mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
756
770
|
.bv-status { font-size: 11px; color: var(--panel-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
757
|
-
.bv-actions { display: flex; gap: 6px; flex-shrink: 0; }
|
|
758
|
-
.bv-actions .btn { padding: 4px 10px; font-size: 11px; }
|
|
771
|
+
.bv-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
|
|
759
772
|
|
|
760
773
|
.bots-messages {
|
|
761
774
|
flex: 1; overflow-y: auto; padding: 14px 16px;
|
|
@@ -924,8 +937,13 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as b,newSes
|
|
|
924
937
|
.bots-view-head { flex-wrap: wrap; row-gap: 6px; padding: 6px 10px; }
|
|
925
938
|
.bv-title { flex: 1 1 100%; }
|
|
926
939
|
.bv-status { display: none; }
|
|
927
|
-
.bv-actions { flex: 1 1 100%; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
|
|
928
|
-
|
|
940
|
+
.bv-actions { flex: 1 1 100%; display: flex; gap: 6px; align-items: center; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
|
|
941
|
+
/* Same height for every control in the row; the mode chip is an icon, so it
|
|
942
|
+
is a square, not a shorter box next to the text buttons. */
|
|
943
|
+
.bv-actions .btn, .bv-actions .bv-mode-btn { flex: 0 0 auto; height: 32px; min-height: 32px; }
|
|
944
|
+
.bv-actions .btn { padding: 0 11px; font-size: 11.5px; }
|
|
945
|
+
.bv-actions .bv-mode-btn { width: 32px; padding: 0; }
|
|
946
|
+
.bv-actions .bv-mode-btn svg { width: 16px; height: 16px; }
|
|
929
947
|
.bv-mode-menu { position: fixed; left: 10px; right: 10px; top: auto; bottom: 10px; width: auto; max-height: 60vh; overflow-y: auto; }
|
|
930
948
|
.bots-messages { padding: 10px; }
|
|
931
949
|
.bv-msg { max-width: 100%; }
|
|
@@ -966,7 +984,7 @@ import{cssVarsStyle as c}from"../theme.js";import{newSessionModalCSS as b,newSes
|
|
|
966
984
|
display: flex; flex-wrap: nowrap; gap: 4px;
|
|
967
985
|
overflow-x: auto; overscroll-behavior-x: contain;
|
|
968
986
|
}
|
|
969
|
-
`,v=JSON.stringify(t.terminal).replace(/</g,"\\u003c"),d=JSON.stringify({terminal:i,scrollback:
|
|
987
|
+
`,v=JSON.stringify(t.terminal).replace(/</g,"\\u003c"),d=JSON.stringify({terminal:i,scrollback:s,theme:t.terminal,fsRoots:r,wsBase:p||""}).replace(/</g,"\\u003c");return`<!DOCTYPE html>
|
|
970
988
|
<html lang="en">
|
|
971
989
|
<head>
|
|
972
990
|
<meta charset="UTF-8" />
|