@staff0rd/assist 0.1007.1 → 0.1008.0
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/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +343 -65
- package/package.json +1 -1
|
@@ -4019,7 +4019,7 @@ ${f.join(`
|
|
|
4019
4019
|
`,d0o=wi`
|
|
4020
4020
|
0%, 100% { transform: scale(1); }
|
|
4021
4021
|
50% { transform: scale(1.08); }
|
|
4022
|
-
`,iAr={content:'""',position:"absolute",borderRadius:"inherit",background:"conic-gradient(from calc(var(--rainbow-pill-h) * 1deg) in oklch longer hue, oklch(66% 0.21 0), oklch(66% 0.21 0))",animation:`${f0o} 1.8s linear infinite`},p0o={display:"inline-flex",alignItems:"center",px:1.5,py:"3px",borderRadius:999,position:"relative",isolation:"isolate",fontWeight:700,animation:`${d0o} 1.6s ease-in-out infinite`,"&::before":{...iAr,inset:0,zIndex:-1},"&::after":{...iAr,inset:"-5px",zIndex:-2,filter:"blur(9px)",opacity:.85},"& span":{color:kl.rainbowPill.text,textShadow:kl.rainbowPill.shadow},"@media (prefers-reduced-motion: reduce)":{animation:"none","&::before, &::after":{animation:"none"}}};function aAr({children:e}){return(0,TL.jsxs)(TL.Fragment,{children:[(0,TL.jsx)(E4,{styles:u0o}),(0,TL.jsx)(V,{component:"span","data-testid":"rainbow-pill",sx:p0o,children:e})]})}function sAr({pct:e,timeLabel:t}){return[Math.round(e),...(t.match(/\d+/g)??[]).map(Number)].join(",")}function lAr(e){if(e.length!==2)return!1;let[t,r]=e;return sAr(t)===sAr(r)}var GT=k(I(),1);function uAr({rateLimits:e}){let t=Ug(3e4),r=[{window:e.five_hour,windowSeconds:18e3,fallbackLabel:"5h"},{window:e.seven_day,windowSeconds:604800,fallbackLabel:"7d"}].filter(i=>i.window?.used_percentage!=null),n=lAr(r.map(i=>({pct:i.window?.used_percentage??0,timeLabel:QSe(i.window?.resets_at,i.fallbackLabel,t)}))),o=r.map((i,a)=>(0,GT.jsxs)(cAr.Fragment,{children:[a>0?(0,GT.jsx)(V,{component:"span",sx:{color:kU,mr:.5},children:","}):null,(0,GT.jsx)(oAr,{window:i.window,windowSeconds:i.windowSeconds,fallbackLabel:i.fallbackLabel,now:t})]},i.fallbackLabel));return n?(0,GT.jsx)(aAr,{children:o}):(0,GT.jsx)(GT.Fragment,{children:o})}var L5=k(I(),1);function dAr({groups:e}){return(0,L5.jsx)(L5.Fragment,{children:e.map((t,r)=>(0,L5.jsxs)(fAr.Fragment,{children:[(0,L5.jsx)(V,{component:"span",sx:{color:kU,ml:r>0?1:0,mr:.5},children:vc(t.harness)}),(0,L5.jsx)(uAr,{rateLimits:t.rateLimits})]},t.harness))})}var pAr={root:{fontFamily:"fontFamilyMono",fontSize:12,display:"grid",gap:1},group:{display:"grid",gap:"2px"},heading:{color:e=>e.tokens.color.onAppBar.secondary},foot:{pt:.75,opacity:.6,borderTop:"1px solid color-mix(in srgb, currentColor 18%, transparent)"}};function h0o(e){if(e==="over")return{level:"warn",boundary:100};if(e==="warn")return{level:"ok",boundary:75}}function m0o(e){if(e==="ok")return{level:"warn",boundary:75};if(e==="warn")return{level:"over",boundary:100}}function g0o(e,t,r,n){if(e>=t)return;let o=e/t;return Math.round(r-n*(1-o))}function gAr(e,t,r,n){if(t==null)return{kind:"unprojectable"};let o=DKe(t,r,n);if(o==null)return{kind:"unprojectable"};let i=Cb(e,t,r,n),a=h0o(i),s=m0o(i);return{kind:"projected",recovery:a&&{level:a.level,pct:a.boundary*o,at:g0o(e,a.boundary,t,r)},worse:s&&{level:s.level,pct:s.boundary*o}}}function JSe(e){return t=>t.tokens.color.onAppBar.level[e]}function yAr(e,t){return e.at==null?"not before reset":`${e.level==="ok"?"green":"under"} in ${tU(e.at,t)}`}var I5=k(I(),1),vAr={display:"contents"};function tXe({direction:e,threshold:t}){let r=e==="back";if(!t)return(0,I5.jsxs)(V,{component:"span",sx:vAr,children:[(0,I5.jsx)("span",{}),(0,I5.jsx)("span",{})]});let n=(0,I5.jsx)(V,{component:"span",sx:{opacity:.6},children:r?"\u2190":"\u2192"}),o=(0,I5.jsxs)(V,{component:"span",sx:{color:JSe(t.level),textAlign:"right"},children:[Math.round(t.pct),"%"]});return(0,I5.jsxs)(V,{component:"span",sx:vAr,children:[r?o:n,r?n:o]})}var bAr={row:{display:"grid",gridTemplateColumns:"2.5ch 4ch 1ch 4ch 1ch 4ch auto",alignItems:"baseline",gap:.75,fontVariantNumeric:"tabular-nums"},pctWeight:500,note:{pl:.75,color:e=>e.tokens.color.onAppBar.secondary}};var M5=k(I(),1);function xAr({label:e,pct:t,resetsAt:r,windowSeconds:n,now:o}){let i=bAr,a=Cb(t,r,n,o),s=gAr(t,r,n,o),l=s.kind==="projected"?s:void 0;return(0,M5.jsxs)(V,{sx:i.row,children:[(0,M5.jsx)(V,{component:"span",sx:{minWidth:"2ch"},children:e}),(0,M5.jsx)(tXe,{direction:"back",threshold:l?.recovery}),(0,M5.jsxs)(V,{component:"span",sx:{minWidth:"4ch",textAlign:"right",fontWeight:i.pctWeight,color:JSe(a)},children:[Math.round(t),"%"]}),(0,M5.jsx)(tXe,{direction:"forward",threshold:l?.worse}),(0,M5.jsx)(V,{component:"span",sx:i.note,children:l?l.recovery&&yAr(l.recovery,o):"no projection yet"})]})}function eTe(e){return[{label:"5h",window:e.five_hour,windowSeconds:18e3},{label:"7d",window:e.seven_day,windowSeconds:604800}].flatMap(t=>t.window?.used_percentage==null?[]:[{label:t.label,pct:t.window.used_percentage,resetsAt:t.window.resets_at,windowSeconds:t.windowSeconds}])}var TAr=k(I(),1);function SAr({rateLimits:e,now:t}){return eTe(e).map(r=>(0,TAr.jsx)(xAr,{label:r.label,pct:r.pct,resetsAt:r.resetsAt,windowSeconds:r.windowSeconds,now:t},r.label))}var CL=k(I(),1);function CAr({groups:e}){let t=Ug(3e4),r=pAr;return(0,CL.jsxs)(V,{sx:r.root,children:[e.map(n=>(0,CL.jsxs)(V,{sx:r.group,children:[(0,CL.jsx)(V,{sx:r.heading,children:vc(n.harness)}),(0,CL.jsx)(SAr,{rateLimits:n.rateLimits,now:t})]},n.harness)),(0,CL.jsx)(V,{sx:r.foot,children:"Account usage per harness \u2014 view history"})]})}var rXe=k(I(),1),y0o="Claude account usage (5h / 7d windows) \u2014 view history";function wAr(e){return e.length===0?{title:y0o,content:"Usage"}:{title:(0,rXe.jsx)(CAr,{groups:e}),content:(0,rXe.jsx)(dAr,{groups:e})}}var kAr={display:"flex",alignItems:"center",height:22,px:1,borderRadius:1,fontSize:"inherit","&:hover, &:focus-visible":{bgcolor:e=>e.tokens.color.statusBar.hover,color:e=>e.tokens.color.statusBar.hoverText}},_Ar={tooltip:{sx:{p:"10px 12px",minWidth:300,maxWidth:"none"}}};var nXe=k(I(),1),v0o={};function EAr({rateLimits:e,harnessRateLimits:t=v0o}){let{title:r,content:n}=wAr(XSe(e,t));return(0,nXe.jsx)(rr,{title:r,placement:"top-start",slotProps:_Ar,children:(0,nXe.jsx)(Ur,{component:Ki,to:"/usage",underline:"none",color:"inherit",sx:kAr,children:n})})}var PAr=k(oe(),1);var Op="0.1007.1";var tTe=k(oe(),1),oXe=(0,tTe.createContext)(null);function rTe(){return(0,tTe.useContext)(oXe)}var iXe=k(I(),1);function RAr(){let e=rTe();return!e||e===Op?null:(0,iXe.jsx)(rr,{title:`Daemon is running v${e}, but this page was served by v${Op}. Restart the daemon to match.`,children:(0,iXe.jsx)(FSe,{fontSize:"small",color:"warning","aria-label":"Version mismatch"})})}var AAr=e=>({display:"inline-flex",alignItems:"center",gap:.75,px:1,py:0,height:22,borderRadius:1,fontSize:"inherit",lineHeight:1.5,color:"inherit",opacity:1,bgcolor:t=>e?Ob(t).active:"transparent",transition:"opacity .2s ease, background-color .2s ease, color .2s ease","&:hover, &:focus-visible":{bgcolor:t=>Ob(t).hover,color:t=>Ob(t).hoverText},"& .ready-dot":{width:6,height:6,borderRadius:"50%",bgcolor:t=>Ob(t).dot,boxShadow:t=>`0 0 0 3px ${Ob(t).dotRing}`},"& .ready-count":{fontWeight:500,color:t=>Ob(t).readyText}});var qg=k(I(),1);function LAr(){let{entries:e}=u5(),t=Kr(),r=(0,PAr.useCallback)(()=>t("/updates"),[t]),{matches:n,chords:o}=to("openUpdates");if(Bi(n,r),!Op)return null;let i=e.filter(p5).length;return(0,qg.jsxs)(qg.Fragment,{children:[(0,qg.jsx)(rr,{describeChild:!0,placement:"top-end",title:(0,qg.jsx)(of,{label:"Updates",chords:o}),children:(0,qg.jsxs)(ir,{component:Ki,to:"/updates","aria-label":i?`Updates: ${i} node${i>1?"s have":" has"} an update ready`:"Updates",sx:AAr(i>0),children:[i>0&&(0,qg.jsx)("span",{className:"ready-dot","aria-hidden":!0}),(0,qg.jsxs)("span",{children:["v",Op]}),i>0&&(0,qg.jsxs)("span",{className:"ready-count",children:[i," ready"]})]})}),(0,qg.jsx)(RAr,{})]})}var VT=k(I(),1);function IAr({socket:e}){return(0,VT.jsx)(GRr,{start:(0,VT.jsx)(EAr,{rateLimits:e.rateLimits,harnessRateLimits:e.harnessRateLimits}),end:(0,VT.jsxs)(VT.Fragment,{children:[(0,VT.jsx)(tAr,{}),(0,VT.jsx)(LAr,{})]})})}var MAr=k(oe(),1);var qT=k(I(),1),b0o=2e4;function DAr(){let{entries:e,refresh:t}=u5(),[r,n]=(0,MAr.useState)(),o=e.find(l=>l.local)?.status?.extension,i=o?.behind&&o.updateLink&&o.latest?o:void 0,a=i!==void 0&&r!==i.latest,s=()=>n(i?.latest);return(0,qT.jsx)(hu,{open:a,children:(0,qT.jsxs)(jn,{severity:"info",variant:"filled",action:(0,qT.jsxs)(qT.Fragment,{children:[(0,qT.jsx)(Tt,{color:"inherit",size:"small",href:i?.updateLink,onClick:()=>setTimeout(t,b0o),children:"Install"}),(0,qT.jsx)(Tt,{color:"inherit",size:"small",onClick:s,children:"Dismiss"})]}),children:["assist extension v",i?.connected," \u2192 v",i?.latest]})})}var sTe=k(oe(),1);var aTe=k(oe(),1);function NAr(e,t,r){if(!e)return"Select a repo to search files.";if(r.error)return"Couldn't search files in this repo.";if(!(r.files.length>0||r.loading))return t?"No matching files.":"No files in this repo."}var D5=k(I(),1),x0o={display:"flex",gap:1,alignItems:"center",minWidth:0},S0o={display:"flex",gap:1,alignItems:"baseline",minWidth:0,overflow:"hidden"},T0o={fontFamily:"fontFamilyMono",fontSize:13,whiteSpace:"nowrap"},C0o={fontFamily:"fontFamilyMono",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function w0o(e){let t=e.lastIndexOf("/");return t===-1?{dir:"",basename:e}:{dir:e.slice(0,t),basename:e.slice(t+1)}}function OAr({files:e,highlight:t,onHighlight:r,onSelect:n}){return(0,D5.jsx)(Sm,{dense:!0,sx:{py:0},children:e.map((o,i)=>{let{dir:a,basename:s}=w0o(o);return(0,D5.jsxs)(un,{selected:i===t,onMouseEnter:()=>r(i),onClick:()=>n(o),sx:x0o,children:[(0,D5.jsx)(_ve,{path:o}),(0,D5.jsxs)(V,{sx:S0o,children:[(0,D5.jsx)(Ee,{component:"span",sx:T0o,children:s}),(0,D5.jsx)(Ee,{component:"span",color:"text.secondary",sx:C0o,children:a})]})]},o)})})}var nTe=k(I(),1),k0o={maxHeight:420,overflowY:"auto"},_0o={px:2,py:2,fontSize:13};function BAr({message:e,files:t,highlight:r,onHighlight:n,onSelect:o}){return(0,nTe.jsx)(V,{sx:k0o,children:e?(0,nTe.jsx)(Ee,{color:"text.secondary",sx:_0o,children:e}):(0,nTe.jsx)(OAr,{files:t,highlight:r,onHighlight:n,onSelect:o})})}var FAr=k(I(),1),E0o={mt:6,alignSelf:"flex-start"};function oTe({onClose:e,onEntered:t,centered:r=!1,children:n}){return(0,FAr.jsx)(pc,{open:!0,onClose:e,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:r?void 0:E0o},transition:{onEntered:t}},children:n})}var iTe=k(oe(),1);var $Ar={files:[],loading:!1,error:!1};function zAr(e,t){let[r,n]=(0,iTe.useState)($Ar),o=pr();return(0,iTe.useEffect)(()=>{if(!e){n($Ar);return}let i=!1;return n(s=>({...s,loading:!0})),(async()=>{try{let s=await Jt(Vr(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`,o));if(!s.ok)throw new Error(`HTTP ${s.status}`);let l=await s.json();if(i)return;n({files:Array.isArray(l.files)?l.files:[],loading:!1,error:!1})}catch(s){Cr(s,"file search"),i||n({files:[],loading:!1,error:!0})}})(),()=>{i=!0}},[e,t,o]),r}var wL=k(I(),1);function R0o(e,t,r){let n=new URLSearchParams({path:e});return t&&n.set("cwd",t),t&&r&&n.set("node",r),`/file?${n}`}function HAr({onClose:e}){let{worktreeNode:t}=Vn();return(0,wL.jsx)(Fl.Provider,{value:t,children:(0,wL.jsx)(A0o,{onClose:e})})}function A0o({onClose:e}){let{worktreeCwd:t,worktreeNode:r}=Vn(),[n,o]=(0,aTe.useState)(""),i=zAr(t,n),a=Kr(),s=(0,aTe.useRef)(null),l=h=>a(R0o(h,t,r)),{highlight:u,setHighlight:f,onKeyDown:d}=T5(i.files,n,l,e),p=h=>{l(h),e()};return(0,wL.jsxs)(oTe,{onClose:e,onEntered:()=>s.current?.focus(),children:[(0,wL.jsx)(Sw,{autoFocus:!0,inputRef:s,value:n,onChange:o,onKeyDown:d,placeholder:"Search files by name..."}),(0,wL.jsx)(BAr,{message:NAr(t,n,i),files:i.files,highlight:u,onHighlight:f,onSelect:p})]})}function UAr(e){Bi(to("quickOpen").matches,e)}var GAr=k(I(),1);function WAr(){let[e,t]=(0,sTe.useState)(!1);return UAr((0,sTe.useCallback)(()=>t(!0),[])),e?(0,GAr.jsx)(HAr,{onClose:()=>t(!1)}):null}var lTe=k(I(),1);function VAr({notice:e,onClose:t,onView:r}){let n=e?.sessionId??null;return(0,lTe.jsx)(hu,{open:e!==null,autoHideDuration:6e3,onClose:t,children:(0,lTe.jsx)(jn,{severity:"success",variant:"filled",onClose:t,action:n!==null?(0,lTe.jsx)(Tt,{color:"inherit",size:"small",onClick:()=>r(n),children:"View"}):void 0,children:e?.message})})}var Iee=k(oe(),1);function _U(e){let t=["claude"];return e.exposeCodexActions&&t.push("codex"),e.exposePiActions&&t.push("pi"),t}var oPr=k(oe(),1);var qAr=k(I(),1),jAr=nt((0,qAr.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle");var P0o={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function YAr(e){return e?P0o[e]:"success.main"}function KAr(e){return e.split("-")[0].split(".").map(Number)}function XAr(e,t){if(!e||!t||e===t)return;let r=KAr(e),n=KAr(t);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]??0)-(n[o]??0);if(Number.isNaN(i))return;if(i!==0)return i<0?"behind":"ahead"}}var kL=k(I(),1),L0o={height:16,fontSize:10},I0o={opacity:.6,fontSize:"0.85em"};function M0o(e,t){if(t===e.local)return"this machine";let r=e.links.find(n=>n.name===t);return r?r.error?`${r.state}: ${r.error}`:r.state:""}function Pee({nodes:e,name:t,showVersion:r=!1}){let n=rTe()??Op,o=e.links.find(a=>a.name===t),i=XAr(o?.peerVersion,n);return(0,kL.jsx)(rr,{title:M0o(e,t),placement:"right",children:(0,kL.jsxs)(V,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,kL.jsx)(jAr,{sx:{fontSize:8,color:YAr(o?.state)}}),t,r&&o?.peerVersion&&(0,kL.jsxs)(V,{component:"span",sx:I0o,children:["v",o.peerVersion]}),i&&(0,kL.jsx)(Yn,{label:i,size:"small",color:i==="behind"?"warning":"info",sx:L0o})]})})}var _L=k(I(),1),D0o={opacity:.6},N0o={display:"inline-flex",alignItems:"center",gap:.5,px:.5,border:1,borderStyle:"dashed",borderRadius:1};function QAr({nodes:e,name:t,clone:r}){let n=(0,_L.jsx)(Pee,{nodes:e,name:t});return r.kind==="cloned"?n:r.kind==="unavailable"?(0,_L.jsx)(V,{component:"span",sx:D0o,children:n}):(0,_L.jsx)(rr,{title:lU(t,r.cloneTarget),children:(0,_L.jsxs)(V,{component:"span",sx:N0o,children:[(0,_L.jsx)(sU,{sx:{fontSize:14}}),n]})})}var JAr=k(I(),1),O0o={px:1.5,borderRadius:.75,fontSize:12,fontWeight:600,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:"action.hover"},"&[aria-checked='true']":{color:"primary.main",bgcolor:"action.selected"},"&.Mui-focusVisible":{outline:2,outlineColor:"primary.main"}};function ZAr({value:e,label:t,checked:r,autoFocus:n,onSelect:o}){return(0,JAr.jsx)(ir,{role:"radio","aria-checked":r,"data-value":e,tabIndex:r?0:-1,autoFocus:n&&r,onClick:o,sx:O0o,children:t})}var ePr={ArrowRight:1,ArrowLeft:-1};function B0o(e,t,r){if(e.key==="Tab"){let n=t+(e.shiftKey?-1:1);return n>=0&&n<r?n:void 0}return(t+ePr[e.key]+r)%r}function tPr(e,t,r,n){return o=>{if(o.key==="ArrowUp"||o.key==="ArrowDown"){if(!n)return;o.preventDefault(),n();return}if(o.key!=="Tab"&&!ePr[o.key]){oT(o);return}let i=B0o(o,e.indexOf(t),e.length);i!==void 0&&(o.preventDefault(),r(e[i]),o.currentTarget.querySelector(`[data-value="${e[i]}"]`)?.focus())}}var rPr=k(oe(),1);function EU(e){return e?.querySelector('[aria-checked="true"]')}function nPr(e,t){(0,rPr.useEffect)(()=>{let r=e.current;if(!r?.contains(document.activeElement))return;let n=EU(r);n&&n!==document.activeElement&&n.focus()},[e,t])}var aXe=k(I(),1),F0o={border:1,borderColor:"divider",borderRadius:1,height:40,p:"2px",flexShrink:0};function cTe({label:e,options:t,value:r,onChange:n,optionLabel:o=u=>u,groupRef:i,autoFocus:a,onTrack:s,onToggleRow:l}){return nPr(i,r),(0,aXe.jsx)(_t,{ref:i,direction:"row",role:"radiogroup","aria-label":e,spacing:"2px",onFocus:s,onKeyDown:tPr(t,r,n,l),sx:F0o,children:t.map(u=>(0,aXe.jsx)(ZAr,{value:u,label:o(u),checked:u===r,autoFocus:a,onSelect:()=>n(u)},u))})}var sXe=k(I(),1);function iPr({value:e,onChange:t,cloneState:r}){let{nodes:n,names:o,visible:i}=il(),a=(0,oPr.useRef)(null);return!i||!n||!e?null:(0,sXe.jsx)(cTe,{label:"Machine",options:o,value:e,onChange:t,optionLabel:s=>(0,sXe.jsx)(QAr,{nodes:n,name:s,clone:r(s)}),groupRef:a,autoFocus:!1,onTrack:()=>{}})}var uTe=k(I(),1);function aPr({prompt:e,children:t}){return(0,uTe.jsxs)(_t,{children:[e,(0,uTe.jsx)(_t,{spacing:1,sx:{px:1.5,pb:1.5},children:t})]})}var lPr=k(I(),1),$0o=".MuiOutlinedInput-notchedOutline",z0o={"& .MuiOutlinedInput-root":{px:"18px",py:2,minHeight:92,alignItems:"flex-start",bgcolor:"transparent",borderRadius:0,fontSize:15},[`&&& ${$0o}`]:{border:0},"& textarea::placeholder":{color:"text.disabled",opacity:1}};function sPr({value:e,onChange:t,placeholder:r,inputRef:n,autoFocus:o,onTrack:i}){return(0,lPr.jsx)(Un,{sx:z0o,value:e,onChange:a=>t(a.target.value),onKeyDown:oT,onFocus:i,onSelect:i,inputRef:n,placeholder:r,autoFocus:o,fullWidth:!0,multiline:!0,minRows:3,maxRows:12,slotProps:{htmlInput:{"aria-label":"Prompt"}}})}var dPr=k(oe(),1);var Ey={draft:{placeholder:"Describe the backlog item to draft...",submitLabel:"Start draft",sessionMode:"assist-draft"},bug:{placeholder:"Describe the bug: what happened, what you expected...",submitLabel:"File bug",sessionMode:"assist-bug"},prompt:{placeholder:Ebe,submitLabel:"Start session"},design:{placeholder:"Describe the design task...",submitLabel:"Start design"}},cPr=Object.keys(Ey);var lXe=k(I(),1);function uPr({anchor:e,harness:t,harnesses:r,onPick:n,onClose:o}){return(0,lXe.jsx)(Js,{open:e!==null,anchorEl:e,onClose:o,slotProps:{list:{dense:!0,"aria-label":"Harness"}},children:r.map(i=>(0,lXe.jsx)(un,{role:"menuitemradio","aria-checked":i===t,selected:i===t,onClick:()=>{n(i),o()},sx:{fontSize:13},children:vc(i)},i))})}var EL=k(I(),1);function fPr(e){return t=>t==="prompt"&&e?(0,EL.jsxs)(EL.Fragment,{children:["prompt",(0,EL.jsx)(V,{component:"span",sx:{fontWeight:400,whiteSpace:"pre"},children:` \xB7 ${vc(e)}`}),(0,EL.jsx)(jd,{sx:{fontSize:18,mr:-.75}})]}):t}var RL=k(I(),1);function pPr({draft:e,harness:t,harnesses:r,focus:n}){let[o,i]=(0,dPr.useState)(null),a=e.mode==="prompt"&&r.length>1,s=()=>i(EU(n.modeRef.current)??null),l=u=>{a&&u==="prompt"?s():e.setMode(u)};return(0,RL.jsxs)(RL.Fragment,{children:[(0,RL.jsx)(cTe,{label:"Mode",options:cPr,value:e.mode,onChange:l,optionLabel:fPr(r.length>1?t:void 0),groupRef:n.modeRef,autoFocus:n.autoFocus==="mode",onTrack:n.trackMode,onToggleRow:a?s:void 0}),(0,RL.jsx)(uPr,{anchor:o,harness:t,harnesses:r,onPick:e.setHarness,onClose:()=>i(null)})]})}var kPr=k(oe(),1);var cXe=k(I(),1),H0o={zIndex:e=>e.zIndex.modal+1};function hPr({open:e,anchor:t,children:r}){return(0,cXe.jsx)(r7,{open:e,anchorEl:t,placement:"bottom-start",sx:H0o,children:(0,cXe.jsx)(rn,{sx:{maxHeight:240,overflowY:"auto",width:t?.clientWidth},onMouseDown:n=>n.preventDefault(),children:r})})}var mPr=k(I(),1),gPr=nt((0,mPr.jsx)("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"}),"KeyboardArrowDown");var uXe=k(I(),1),U0o={fontSize:13,height:36,pr:1,cursor:"pointer","& input":{cursor:"text"}},W0o={fontSize:16,color:"text.disabled"};function yPr(e){return{htmlInput:{role:"combobox","aria-label":"Repo","aria-expanded":e},input:{sx:U0o,endAdornment:(0,uXe.jsx)($ke,{position:"end",children:(0,uXe.jsx)(gPr,{sx:W0o})})}}}var vPr=k(HI(),1);function bPr({open:e,highlighted:t,accept:r,close:n,navigate:o,openList:i}){return a=>{if(!e){if(a.key==="ArrowDown"){a.preventDefault(),i();return}oT(a);return}if(a.key!=="Escape"){if(a.key==="Enter"){if(a.preventDefault(),t===void 0)return;(0,vPr.flushSync)(()=>{r(t),n()}),oT(a);return}if(a.key!=="Tab"){o(a);return}t!==void 0&&r(t),n()}}}function fTe(e,t){let r=t.trim().toLowerCase();return r?e.filter(n=>Eb(n).toLowerCase().includes(r)):e}var fXe=k(oe(),1);function xPr(){let[e,t]=(0,fXe.useState)(!1),[r,n]=(0,fXe.useState)("");return{open:e,query:r,show:()=>t(!0),filterBy:o=>{n(o),t(!0)},close:()=>{t(!1),n("")}}}var TPr=k(oe(),1);var SPr=e=>e?Eb(e):"";function CPr(e){let[t,r]=(0,TPr.useState)(()=>SPr(e));return{text:t,setText:r,showRepo:n=>r(SPr(n))}}function wPr(e,t,r){let n=xPr(),o=CPr(t),i=fTe(e,n.query),a=f=>{r(f),o.showRepo(f)},s=T5(i,n.query,a,n.close),l=()=>s.setHighlight(Math.max(e.indexOf(t),0)),u=()=>{l(),n.show()};return{open:n.open,text:o.text,filtered:i,highlight:s.highlight,setHighlight:s.setHighlight,onKeyDown:bPr({open:n.open,highlighted:i[s.highlight],accept:a,close:n.close,navigate:s.onKeyDown,openList:u}),onClick:()=>{n.open||u()},onType:f=>{o.setText(f),n.filterBy(f)},onFocus:l,onBlur:()=>{n.close(),o.showRepo(t)},pick:f=>{a(f),n.close()}}}var RU=k(I(),1);function _Pr({repos:e,value:t,onChange:r,inputRef:n,autoFocus:o,onTrack:i}){let a=wPr(e,t,r),s=(0,kPr.useRef)(null);return(0,RU.jsxs)(V,{ref:s,sx:{flex:1,minWidth:0},children:[(0,RU.jsx)(Un,{value:a.text,onChange:l=>a.onType(l.target.value),onFocus:l=>{l.target.select(),a.onFocus(),i()},inputRef:n,autoFocus:o,onClick:a.onClick,onBlur:a.onBlur,onKeyDown:a.onKeyDown,placeholder:"Repo",size:"small",fullWidth:!0,slotProps:yPr(a.open)}),(0,RU.jsx)(hPr,{open:a.open,anchor:s.current,children:(0,RU.jsx)(ISe,{repos:a.filtered,selected:t,highlight:a.highlight,onHighlight:a.setHighlight,onSelect:a.pick})})]})}var N5=k(I(),1);function EPr({cloneState:e,...t}){let{draft:r,focus:n}=t,{repos:o}=Vn();return(0,N5.jsxs)(aPr,{prompt:(0,N5.jsx)(sPr,{value:r.prompt,onChange:r.setPrompt,placeholder:Ey[r.mode].placeholder,inputRef:n.promptRef,autoFocus:n.autoFocus==="prompt",onTrack:n.trackPrompt}),children:[(0,N5.jsxs)(_t,{direction:"row",spacing:1,sx:{alignItems:"flex-start"},children:[(0,N5.jsx)(_Pr,{repos:o,value:r.cwd,onChange:r.setCwd,inputRef:n.repoRef,autoFocus:n.autoFocus==="repo",onTrack:n.trackRepo}),(0,N5.jsx)(pPr,{...t})]}),(0,N5.jsx)(iPr,{value:r.node,onChange:r.setNode,cloneState:e})]})}var PPr=k(I(),1),RPr=[["Enter","start"],["Shift+Enter","newline"],["Esc","close"]];function APr({submitLabel:e,disabled:t=!1,loading:r=!1}){return(0,PPr.jsx)(Tt,{type:"submit",variant:"contained",disabled:t,loading:r,children:e})}var AL=k(I(),1),G0o=e=>({alignItems:"center",flexWrap:"wrap",gap:"14px",py:"10px",pl:"18px",pr:1.5,borderTop:1,borderColor:e.tokens.color.lineSoft,bgcolor:"background.default",fontSize:12,color:"text.secondary"}),V0o=e=>({mr:.5,px:"5px",border:1,borderColor:"divider",borderRadius:"4px",fontFamily:e.typography.fontFamilyMono,fontSize:10.5,color:"text.primary"});function LPr(e){return(0,AL.jsxs)(_t,{direction:"row",sx:G0o,children:[RPr.map(([t,r])=>(0,AL.jsxs)("span",{children:[(0,AL.jsx)(V,{component:"kbd",sx:V0o,children:t}),r]},t)),(0,AL.jsx)(V,{sx:{flex:1}}),(0,AL.jsx)(APr,{...e})]})}var PL=k(oe(),1);function IPr(e,t){let r=(0,PL.useRef)(e),n=(0,PL.useRef)(null),o=(0,PL.useRef)(null),i=(0,PL.useRef)(null),a=(0,PL.useCallback)(u=>{n.current=u;let{field:f,selectionStart:d,selectionEnd:p}=r.current;u&&f==="prompt"&&u.setSelectionRange(d,p)},[]),s=u=>{let f=u.target;t({field:"prompt",selectionStart:f.selectionStart,selectionEnd:f.selectionEnd})},l=()=>{if(i.current?.closest("form")?.contains(document.activeElement))return;let{field:u}=r.current;({repo:o.current,mode:EU(i.current),prompt:n.current}[u]??n.current)?.focus()};return{autoFocus:e.field,promptRef:a,repoRef:o,modeRef:i,trackPrompt:s,trackRepo:()=>t({...e,field:"repo"}),trackMode:()=>t({...e,field:"mode"}),restore:l}}function q0o(e,t,r){return e?r.kind==="cloned"?{kind:"launch",cwd:r.cwd}:r.kind==="clonable"?{kind:"clone",prompt:DSe(r,t)}:{kind:"blocked"}:{kind:"launch",cwd:e}}function MPr(e,t){let{names:r,visible:n}=il(),o=ASe(t,n?r:[void 0]);return{cloneState:o,target:q0o(t,e,o(e))}}function dTe({mode:e,harness:t,prompt:r,cwd:n,node:o},i){let a=n||void 0,s=o?[o]:[];if(e==="prompt"){t==="claude"?i.onCreate(r,a,...s):i.onCreateHarness(t,r,a,...s);return}if(e==="design"){i.onCreateDesign(r,a,...s);return}let l=o?[{node:o}]:[];a1r(Ey[e].sessionMode,n,(u,f)=>i.onCreateAssist(u,f,...l),()=>{},r)}function DPr(e,t,r,n){return r.kind==="blocked"||e.modePending?!1:r.kind==="clone"?(SSe(r.prompt,n.onCreateAssist),!0):(dTe({mode:e.mode,harness:t,prompt:e.prompt,cwd:r.cwd,node:e.node},n),e.clear(),!0)}var pTe=k(oe(),1);function NPr(e,t){let[r,n]=(0,pTe.useState)(!1);return(0,pTe.useEffect)(()=>{!r||e.modePending||(n(!1),e.modeError||t())},[r,e.modePending,e.modeError,t]),()=>{e.modePending?n(!0):t()}}function OPr(e,t,r,n,o){let i=NPr(e,()=>{DPr(e,t,r,n)&&o()});return a=>{a.preventDefault(),i()}}var Lee=k(oe(),1);function BPr(e,t){let r=(0,Lee.useRef)(e),n=(0,Lee.useRef)(null);return(0,Lee.useEffect)(()=>{if(r.current&&!e){let o=n.current;o?.isConnected?o.focus():t()}r.current=e},[e,t]),o=>{n.current=o.target}}var $Pr=k(I(),1),j0o={border:0,margin:0,padding:0,minWidth:0};function FPr({loading:e,restoreFocus:t,children:r}){let n=BPr(e,t);return(0,$Pr.jsx)("fieldset",{disabled:e,style:j0o,onFocus:n,children:r})}var mTe=k(I(),1);function hTe({error:e,onRetry:t}){return e?(0,mTe.jsxs)(jn,{severity:"error",sx:{mx:2,my:1},action:t&&(0,mTe.jsx)(Tt,{color:"inherit",size:"small",onClick:t,children:"Retry"}),children:["Couldn't load this repo's default mode (",e,"). Pick a mode or retry."]}):null}var O5=k(I(),1);function zPr({draft:e,launchers:t,onClose:r}){let n=IPr(e.focus,e.setFocus),o=_U(Wg()),i=o.includes(e.harness)?e.harness:"claude",{target:a,cloneState:s}=MPr(e.node,e.cwd),l=OPr(e,i,a,t,r);return(0,O5.jsx)(oTe,{onClose:r,onEntered:n.restore,centered:!0,children:(0,O5.jsx)("form",{onSubmit:l,children:(0,O5.jsxs)(FPr,{loading:e.modePending,restoreFocus:n.restore,children:[(0,O5.jsx)(EPr,{draft:e,harness:i,harnesses:o,focus:n,cloneState:s}),(0,O5.jsx)(hTe,{error:e.modeError,onRetry:e.retryMode}),(0,O5.jsx)(LPr,{submitLabel:a.kind==="clone"?"Clone":Ey[e.mode].submitLabel,disabled:a.kind==="blocked",loading:e.modePending})]})})})}var LL=k(oe(),1);async function Y0o(e){try{let t=e?`?cwd=${encodeURIComponent(e)}`:"",r=await Jt(`/api/new-session-defaults${t}`);if(!r.ok)return{error:`HTTP ${r.status}`};let n=await r.json();if(Object.hasOwn(Ey,n?.mode))return{mode:n.mode};throw new Error(`unknown mode ${JSON.stringify(n?.mode)}`)}catch(t){return Cr(t,"new-session defaults"),{error:t instanceof Error?t.message:String(t)}}}function gTe(e,t=0){let[r,n]=(0,LL.useState)(0),[o,i]=(0,LL.useState)(null),a=(0,LL.useCallback)(()=>n(l=>l+1),[]);if((0,LL.useEffect)(()=>{let l=!1;return Y0o(e).then(u=>{l||i({cwd:e,opens:t,attempt:r,outcome:u})}),()=>{l=!0}},[e,t,r]),!o)return null;let{outcome:s}=o;return{mode:"mode"in s?s.mode:"prompt",pending:o.cwd!==e||o.opens!==t||o.attempt!==r,error:"error"in s?s.error:void 0,retry:a}}function yTe(e,t){if(!(e!==void 0||!t||t.pending))return t.error}function HPr(e,{visible:t,names:r,selected:n}){if(t)return e&&r.includes(e)?e:n}var jT=k(oe(),1),UPr={field:"prompt",selectionStart:0,selectionEnd:0};function WPr(){let[e,t]=(0,jT.useState)(""),[r,n]=(0,jT.useState)(),[o,i]=(0,jT.useState)(),[a,s]=(0,jT.useState)("claude"),[l,u]=(0,jT.useState)(),[f,d]=(0,jT.useState)(UPr),p=(0,jT.useCallback)(()=>{t(""),n(void 0),i(void 0),u(void 0),d(UPr)},[]);return{prompt:e,cwd:r,mode:o,harness:a,node:l,focus:f,setPrompt:t,setNode:u,setCwd:n,setMode:i,setHarness:s,setFocus:d,clear:p}}function GPr(e,t=gTe){let{selectedCwd:r}=Vn(),n=il(),o=WPr(),i=o.cwd??r,a=t(i,e);return a?{...o,cwd:i,mode:o.mode??a.mode,modePending:o.mode===void 0&&a.pending,modeError:yTe(o.mode,a),retryMode:a.retry,node:HPr(o.node,n)}:null}function VPr(e){Bi(to("newSession").matches,e)}var qPr=k(oe(),1);function jPr(e,t){let{selectedCwd:r}=Vn(),[n,o]=$s(),i=n.get("new"),a=n.get("newCwd")??r,{setPrompt:s,setCwd:l,setFocus:u}=e??{};(0,qPr.useEffect)(()=>{i===null||!s||!l||!u||(i&&(s(i),l(a),u({field:"prompt",selectionStart:i.length,selectionEnd:i.length})),t(),o(f=>(f.delete("new"),f.delete("newCwd"),f),{replace:!0}))},[i,a,s,l,u,t,o])}var KPr=k(I(),1);function YPr({launchers:e}){let[t,r]=(0,Iee.useState)(!1),[n,o]=(0,Iee.useState)(0),i=GPr(n),a=(0,Iee.useCallback)(()=>{r(!0),o(s=>s+1)},[]);return VPr(a),jPr(i,a),!t||!i?null:(0,KPr.jsx)(zPr,{draft:i,launchers:e,onClose:()=>r(!1)})}var vTe=k(I(),1);function XPr({reconnecting:e}){return(0,vTe.jsx)(hu,{open:e,children:(0,vTe.jsx)(jn,{severity:"info",variant:"filled",icon:(0,vTe.jsx)(bo,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var Ry=k(I(),1);function QPr({socket:e,onViewLaunchedSession:t}){return(0,Ry.jsxs)(Ry.Fragment,{children:[(0,Ry.jsx)(WAr,{}),(0,Ry.jsx)(YPr,{launchers:{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateHarness:e.createHarnessSession,onCreateAssist:e.createAssistSession}}),(0,Ry.jsx)(XPr,{reconnecting:e.reconnecting}),(0,Ry.jsx)(DAr,{}),(0,Ry.jsx)(sl,{error:e.error,onClose:e.clearError}),(0,Ry.jsx)(VAr,{notice:e.success,onClose:e.clearSuccess,onView:t})]})}var Bb=k(oe(),1);var K0o=6e4;function X0o(e,t,r){return t.map(n=>e.find(o=>o.name===n)??{name:n,local:n===r,loading:!0})}function bTe(e){let t=e.nodes?.local,r=e.names.join(`
|
|
4022
|
+
`,iAr={content:'""',position:"absolute",borderRadius:"inherit",background:"conic-gradient(from calc(var(--rainbow-pill-h) * 1deg) in oklch longer hue, oklch(66% 0.21 0), oklch(66% 0.21 0))",animation:`${f0o} 1.8s linear infinite`},p0o={display:"inline-flex",alignItems:"center",px:1.5,py:"3px",borderRadius:999,position:"relative",isolation:"isolate",fontWeight:700,animation:`${d0o} 1.6s ease-in-out infinite`,"&::before":{...iAr,inset:0,zIndex:-1},"&::after":{...iAr,inset:"-5px",zIndex:-2,filter:"blur(9px)",opacity:.85},"& span":{color:kl.rainbowPill.text,textShadow:kl.rainbowPill.shadow},"@media (prefers-reduced-motion: reduce)":{animation:"none","&::before, &::after":{animation:"none"}}};function aAr({children:e}){return(0,TL.jsxs)(TL.Fragment,{children:[(0,TL.jsx)(E4,{styles:u0o}),(0,TL.jsx)(V,{component:"span","data-testid":"rainbow-pill",sx:p0o,children:e})]})}function sAr({pct:e,timeLabel:t}){return[Math.round(e),...(t.match(/\d+/g)??[]).map(Number)].join(",")}function lAr(e){if(e.length!==2)return!1;let[t,r]=e;return sAr(t)===sAr(r)}var GT=k(I(),1);function uAr({rateLimits:e}){let t=Ug(3e4),r=[{window:e.five_hour,windowSeconds:18e3,fallbackLabel:"5h"},{window:e.seven_day,windowSeconds:604800,fallbackLabel:"7d"}].filter(i=>i.window?.used_percentage!=null),n=lAr(r.map(i=>({pct:i.window?.used_percentage??0,timeLabel:QSe(i.window?.resets_at,i.fallbackLabel,t)}))),o=r.map((i,a)=>(0,GT.jsxs)(cAr.Fragment,{children:[a>0?(0,GT.jsx)(V,{component:"span",sx:{color:kU,mr:.5},children:","}):null,(0,GT.jsx)(oAr,{window:i.window,windowSeconds:i.windowSeconds,fallbackLabel:i.fallbackLabel,now:t})]},i.fallbackLabel));return n?(0,GT.jsx)(aAr,{children:o}):(0,GT.jsx)(GT.Fragment,{children:o})}var L5=k(I(),1);function dAr({groups:e}){return(0,L5.jsx)(L5.Fragment,{children:e.map((t,r)=>(0,L5.jsxs)(fAr.Fragment,{children:[(0,L5.jsx)(V,{component:"span",sx:{color:kU,ml:r>0?1:0,mr:.5},children:vc(t.harness)}),(0,L5.jsx)(uAr,{rateLimits:t.rateLimits})]},t.harness))})}var pAr={root:{fontFamily:"fontFamilyMono",fontSize:12,display:"grid",gap:1},group:{display:"grid",gap:"2px"},heading:{color:e=>e.tokens.color.onAppBar.secondary},foot:{pt:.75,opacity:.6,borderTop:"1px solid color-mix(in srgb, currentColor 18%, transparent)"}};function h0o(e){if(e==="over")return{level:"warn",boundary:100};if(e==="warn")return{level:"ok",boundary:75}}function m0o(e){if(e==="ok")return{level:"warn",boundary:75};if(e==="warn")return{level:"over",boundary:100}}function g0o(e,t,r,n){if(e>=t)return;let o=e/t;return Math.round(r-n*(1-o))}function gAr(e,t,r,n){if(t==null)return{kind:"unprojectable"};let o=DKe(t,r,n);if(o==null)return{kind:"unprojectable"};let i=Cb(e,t,r,n),a=h0o(i),s=m0o(i);return{kind:"projected",recovery:a&&{level:a.level,pct:a.boundary*o,at:g0o(e,a.boundary,t,r)},worse:s&&{level:s.level,pct:s.boundary*o}}}function JSe(e){return t=>t.tokens.color.onAppBar.level[e]}function yAr(e,t){return e.at==null?"not before reset":`${e.level==="ok"?"green":"under"} in ${tU(e.at,t)}`}var I5=k(I(),1),vAr={display:"contents"};function tXe({direction:e,threshold:t}){let r=e==="back";if(!t)return(0,I5.jsxs)(V,{component:"span",sx:vAr,children:[(0,I5.jsx)("span",{}),(0,I5.jsx)("span",{})]});let n=(0,I5.jsx)(V,{component:"span",sx:{opacity:.6},children:r?"\u2190":"\u2192"}),o=(0,I5.jsxs)(V,{component:"span",sx:{color:JSe(t.level),textAlign:"right"},children:[Math.round(t.pct),"%"]});return(0,I5.jsxs)(V,{component:"span",sx:vAr,children:[r?o:n,r?n:o]})}var bAr={row:{display:"grid",gridTemplateColumns:"2.5ch 4ch 1ch 4ch 1ch 4ch auto",alignItems:"baseline",gap:.75,fontVariantNumeric:"tabular-nums"},pctWeight:500,note:{pl:.75,color:e=>e.tokens.color.onAppBar.secondary}};var M5=k(I(),1);function xAr({label:e,pct:t,resetsAt:r,windowSeconds:n,now:o}){let i=bAr,a=Cb(t,r,n,o),s=gAr(t,r,n,o),l=s.kind==="projected"?s:void 0;return(0,M5.jsxs)(V,{sx:i.row,children:[(0,M5.jsx)(V,{component:"span",sx:{minWidth:"2ch"},children:e}),(0,M5.jsx)(tXe,{direction:"back",threshold:l?.recovery}),(0,M5.jsxs)(V,{component:"span",sx:{minWidth:"4ch",textAlign:"right",fontWeight:i.pctWeight,color:JSe(a)},children:[Math.round(t),"%"]}),(0,M5.jsx)(tXe,{direction:"forward",threshold:l?.worse}),(0,M5.jsx)(V,{component:"span",sx:i.note,children:l?l.recovery&&yAr(l.recovery,o):"no projection yet"})]})}function eTe(e){return[{label:"5h",window:e.five_hour,windowSeconds:18e3},{label:"7d",window:e.seven_day,windowSeconds:604800}].flatMap(t=>t.window?.used_percentage==null?[]:[{label:t.label,pct:t.window.used_percentage,resetsAt:t.window.resets_at,windowSeconds:t.windowSeconds}])}var TAr=k(I(),1);function SAr({rateLimits:e,now:t}){return eTe(e).map(r=>(0,TAr.jsx)(xAr,{label:r.label,pct:r.pct,resetsAt:r.resetsAt,windowSeconds:r.windowSeconds,now:t},r.label))}var CL=k(I(),1);function CAr({groups:e}){let t=Ug(3e4),r=pAr;return(0,CL.jsxs)(V,{sx:r.root,children:[e.map(n=>(0,CL.jsxs)(V,{sx:r.group,children:[(0,CL.jsx)(V,{sx:r.heading,children:vc(n.harness)}),(0,CL.jsx)(SAr,{rateLimits:n.rateLimits,now:t})]},n.harness)),(0,CL.jsx)(V,{sx:r.foot,children:"Account usage per harness \u2014 view history"})]})}var rXe=k(I(),1),y0o="Claude account usage (5h / 7d windows) \u2014 view history";function wAr(e){return e.length===0?{title:y0o,content:"Usage"}:{title:(0,rXe.jsx)(CAr,{groups:e}),content:(0,rXe.jsx)(dAr,{groups:e})}}var kAr={display:"flex",alignItems:"center",height:22,px:1,borderRadius:1,fontSize:"inherit","&:hover, &:focus-visible":{bgcolor:e=>e.tokens.color.statusBar.hover,color:e=>e.tokens.color.statusBar.hoverText}},_Ar={tooltip:{sx:{p:"10px 12px",minWidth:300,maxWidth:"none"}}};var nXe=k(I(),1),v0o={};function EAr({rateLimits:e,harnessRateLimits:t=v0o}){let{title:r,content:n}=wAr(XSe(e,t));return(0,nXe.jsx)(rr,{title:r,placement:"top-start",slotProps:_Ar,children:(0,nXe.jsx)(Ur,{component:Ki,to:"/usage",underline:"none",color:"inherit",sx:kAr,children:n})})}var PAr=k(oe(),1);var Op="0.1008.0";var tTe=k(oe(),1),oXe=(0,tTe.createContext)(null);function rTe(){return(0,tTe.useContext)(oXe)}var iXe=k(I(),1);function RAr(){let e=rTe();return!e||e===Op?null:(0,iXe.jsx)(rr,{title:`Daemon is running v${e}, but this page was served by v${Op}. Restart the daemon to match.`,children:(0,iXe.jsx)(FSe,{fontSize:"small",color:"warning","aria-label":"Version mismatch"})})}var AAr=e=>({display:"inline-flex",alignItems:"center",gap:.75,px:1,py:0,height:22,borderRadius:1,fontSize:"inherit",lineHeight:1.5,color:"inherit",opacity:1,bgcolor:t=>e?Ob(t).active:"transparent",transition:"opacity .2s ease, background-color .2s ease, color .2s ease","&:hover, &:focus-visible":{bgcolor:t=>Ob(t).hover,color:t=>Ob(t).hoverText},"& .ready-dot":{width:6,height:6,borderRadius:"50%",bgcolor:t=>Ob(t).dot,boxShadow:t=>`0 0 0 3px ${Ob(t).dotRing}`},"& .ready-count":{fontWeight:500,color:t=>Ob(t).readyText}});var qg=k(I(),1);function LAr(){let{entries:e}=u5(),t=Kr(),r=(0,PAr.useCallback)(()=>t("/updates"),[t]),{matches:n,chords:o}=to("openUpdates");if(Bi(n,r),!Op)return null;let i=e.filter(p5).length;return(0,qg.jsxs)(qg.Fragment,{children:[(0,qg.jsx)(rr,{describeChild:!0,placement:"top-end",title:(0,qg.jsx)(of,{label:"Updates",chords:o}),children:(0,qg.jsxs)(ir,{component:Ki,to:"/updates","aria-label":i?`Updates: ${i} node${i>1?"s have":" has"} an update ready`:"Updates",sx:AAr(i>0),children:[i>0&&(0,qg.jsx)("span",{className:"ready-dot","aria-hidden":!0}),(0,qg.jsxs)("span",{children:["v",Op]}),i>0&&(0,qg.jsxs)("span",{className:"ready-count",children:[i," ready"]})]})}),(0,qg.jsx)(RAr,{})]})}var VT=k(I(),1);function IAr({socket:e}){return(0,VT.jsx)(GRr,{start:(0,VT.jsx)(EAr,{rateLimits:e.rateLimits,harnessRateLimits:e.harnessRateLimits}),end:(0,VT.jsxs)(VT.Fragment,{children:[(0,VT.jsx)(tAr,{}),(0,VT.jsx)(LAr,{})]})})}var MAr=k(oe(),1);var qT=k(I(),1),b0o=2e4;function DAr(){let{entries:e,refresh:t}=u5(),[r,n]=(0,MAr.useState)(),o=e.find(l=>l.local)?.status?.extension,i=o?.behind&&o.updateLink&&o.latest?o:void 0,a=i!==void 0&&r!==i.latest,s=()=>n(i?.latest);return(0,qT.jsx)(hu,{open:a,children:(0,qT.jsxs)(jn,{severity:"info",variant:"filled",action:(0,qT.jsxs)(qT.Fragment,{children:[(0,qT.jsx)(Tt,{color:"inherit",size:"small",href:i?.updateLink,onClick:()=>setTimeout(t,b0o),children:"Install"}),(0,qT.jsx)(Tt,{color:"inherit",size:"small",onClick:s,children:"Dismiss"})]}),children:["assist extension v",i?.connected," \u2192 v",i?.latest]})})}var sTe=k(oe(),1);var aTe=k(oe(),1);function NAr(e,t,r){if(!e)return"Select a repo to search files.";if(r.error)return"Couldn't search files in this repo.";if(!(r.files.length>0||r.loading))return t?"No matching files.":"No files in this repo."}var D5=k(I(),1),x0o={display:"flex",gap:1,alignItems:"center",minWidth:0},S0o={display:"flex",gap:1,alignItems:"baseline",minWidth:0,overflow:"hidden"},T0o={fontFamily:"fontFamilyMono",fontSize:13,whiteSpace:"nowrap"},C0o={fontFamily:"fontFamilyMono",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function w0o(e){let t=e.lastIndexOf("/");return t===-1?{dir:"",basename:e}:{dir:e.slice(0,t),basename:e.slice(t+1)}}function OAr({files:e,highlight:t,onHighlight:r,onSelect:n}){return(0,D5.jsx)(Sm,{dense:!0,sx:{py:0},children:e.map((o,i)=>{let{dir:a,basename:s}=w0o(o);return(0,D5.jsxs)(un,{selected:i===t,onMouseEnter:()=>r(i),onClick:()=>n(o),sx:x0o,children:[(0,D5.jsx)(_ve,{path:o}),(0,D5.jsxs)(V,{sx:S0o,children:[(0,D5.jsx)(Ee,{component:"span",sx:T0o,children:s}),(0,D5.jsx)(Ee,{component:"span",color:"text.secondary",sx:C0o,children:a})]})]},o)})})}var nTe=k(I(),1),k0o={maxHeight:420,overflowY:"auto"},_0o={px:2,py:2,fontSize:13};function BAr({message:e,files:t,highlight:r,onHighlight:n,onSelect:o}){return(0,nTe.jsx)(V,{sx:k0o,children:e?(0,nTe.jsx)(Ee,{color:"text.secondary",sx:_0o,children:e}):(0,nTe.jsx)(OAr,{files:t,highlight:r,onHighlight:n,onSelect:o})})}var FAr=k(I(),1),E0o={mt:6,alignSelf:"flex-start"};function oTe({onClose:e,onEntered:t,centered:r=!1,children:n}){return(0,FAr.jsx)(pc,{open:!0,onClose:e,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:r?void 0:E0o},transition:{onEntered:t}},children:n})}var iTe=k(oe(),1);var $Ar={files:[],loading:!1,error:!1};function zAr(e,t){let[r,n]=(0,iTe.useState)($Ar),o=pr();return(0,iTe.useEffect)(()=>{if(!e){n($Ar);return}let i=!1;return n(s=>({...s,loading:!0})),(async()=>{try{let s=await Jt(Vr(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`,o));if(!s.ok)throw new Error(`HTTP ${s.status}`);let l=await s.json();if(i)return;n({files:Array.isArray(l.files)?l.files:[],loading:!1,error:!1})}catch(s){Cr(s,"file search"),i||n({files:[],loading:!1,error:!0})}})(),()=>{i=!0}},[e,t,o]),r}var wL=k(I(),1);function R0o(e,t,r){let n=new URLSearchParams({path:e});return t&&n.set("cwd",t),t&&r&&n.set("node",r),`/file?${n}`}function HAr({onClose:e}){let{worktreeNode:t}=Vn();return(0,wL.jsx)(Fl.Provider,{value:t,children:(0,wL.jsx)(A0o,{onClose:e})})}function A0o({onClose:e}){let{worktreeCwd:t,worktreeNode:r}=Vn(),[n,o]=(0,aTe.useState)(""),i=zAr(t,n),a=Kr(),s=(0,aTe.useRef)(null),l=h=>a(R0o(h,t,r)),{highlight:u,setHighlight:f,onKeyDown:d}=T5(i.files,n,l,e),p=h=>{l(h),e()};return(0,wL.jsxs)(oTe,{onClose:e,onEntered:()=>s.current?.focus(),children:[(0,wL.jsx)(Sw,{autoFocus:!0,inputRef:s,value:n,onChange:o,onKeyDown:d,placeholder:"Search files by name..."}),(0,wL.jsx)(BAr,{message:NAr(t,n,i),files:i.files,highlight:u,onHighlight:f,onSelect:p})]})}function UAr(e){Bi(to("quickOpen").matches,e)}var GAr=k(I(),1);function WAr(){let[e,t]=(0,sTe.useState)(!1);return UAr((0,sTe.useCallback)(()=>t(!0),[])),e?(0,GAr.jsx)(HAr,{onClose:()=>t(!1)}):null}var lTe=k(I(),1);function VAr({notice:e,onClose:t,onView:r}){let n=e?.sessionId??null;return(0,lTe.jsx)(hu,{open:e!==null,autoHideDuration:6e3,onClose:t,children:(0,lTe.jsx)(jn,{severity:"success",variant:"filled",onClose:t,action:n!==null?(0,lTe.jsx)(Tt,{color:"inherit",size:"small",onClick:()=>r(n),children:"View"}):void 0,children:e?.message})})}var Iee=k(oe(),1);function _U(e){let t=["claude"];return e.exposeCodexActions&&t.push("codex"),e.exposePiActions&&t.push("pi"),t}var oPr=k(oe(),1);var qAr=k(I(),1),jAr=nt((0,qAr.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle");var P0o={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function YAr(e){return e?P0o[e]:"success.main"}function KAr(e){return e.split("-")[0].split(".").map(Number)}function XAr(e,t){if(!e||!t||e===t)return;let r=KAr(e),n=KAr(t);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]??0)-(n[o]??0);if(Number.isNaN(i))return;if(i!==0)return i<0?"behind":"ahead"}}var kL=k(I(),1),L0o={height:16,fontSize:10},I0o={opacity:.6,fontSize:"0.85em"};function M0o(e,t){if(t===e.local)return"this machine";let r=e.links.find(n=>n.name===t);return r?r.error?`${r.state}: ${r.error}`:r.state:""}function Pee({nodes:e,name:t,showVersion:r=!1}){let n=rTe()??Op,o=e.links.find(a=>a.name===t),i=XAr(o?.peerVersion,n);return(0,kL.jsx)(rr,{title:M0o(e,t),placement:"right",children:(0,kL.jsxs)(V,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,kL.jsx)(jAr,{sx:{fontSize:8,color:YAr(o?.state)}}),t,r&&o?.peerVersion&&(0,kL.jsxs)(V,{component:"span",sx:I0o,children:["v",o.peerVersion]}),i&&(0,kL.jsx)(Yn,{label:i,size:"small",color:i==="behind"?"warning":"info",sx:L0o})]})})}var _L=k(I(),1),D0o={opacity:.6},N0o={display:"inline-flex",alignItems:"center",gap:.5,px:.5,border:1,borderStyle:"dashed",borderRadius:1};function QAr({nodes:e,name:t,clone:r}){let n=(0,_L.jsx)(Pee,{nodes:e,name:t});return r.kind==="cloned"?n:r.kind==="unavailable"?(0,_L.jsx)(V,{component:"span",sx:D0o,children:n}):(0,_L.jsx)(rr,{title:lU(t,r.cloneTarget),children:(0,_L.jsxs)(V,{component:"span",sx:N0o,children:[(0,_L.jsx)(sU,{sx:{fontSize:14}}),n]})})}var JAr=k(I(),1),O0o={px:1.5,borderRadius:.75,fontSize:12,fontWeight:600,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:"action.hover"},"&[aria-checked='true']":{color:"primary.main",bgcolor:"action.selected"},"&.Mui-focusVisible":{outline:2,outlineColor:"primary.main"}};function ZAr({value:e,label:t,checked:r,autoFocus:n,onSelect:o}){return(0,JAr.jsx)(ir,{role:"radio","aria-checked":r,"data-value":e,tabIndex:r?0:-1,autoFocus:n&&r,onClick:o,sx:O0o,children:t})}var ePr={ArrowRight:1,ArrowLeft:-1};function B0o(e,t,r){if(e.key==="Tab"){let n=t+(e.shiftKey?-1:1);return n>=0&&n<r?n:void 0}return(t+ePr[e.key]+r)%r}function tPr(e,t,r,n){return o=>{if(o.key==="ArrowUp"||o.key==="ArrowDown"){if(!n)return;o.preventDefault(),n();return}if(o.key!=="Tab"&&!ePr[o.key]){oT(o);return}let i=B0o(o,e.indexOf(t),e.length);i!==void 0&&(o.preventDefault(),r(e[i]),o.currentTarget.querySelector(`[data-value="${e[i]}"]`)?.focus())}}var rPr=k(oe(),1);function EU(e){return e?.querySelector('[aria-checked="true"]')}function nPr(e,t){(0,rPr.useEffect)(()=>{let r=e.current;if(!r?.contains(document.activeElement))return;let n=EU(r);n&&n!==document.activeElement&&n.focus()},[e,t])}var aXe=k(I(),1),F0o={border:1,borderColor:"divider",borderRadius:1,height:40,p:"2px",flexShrink:0};function cTe({label:e,options:t,value:r,onChange:n,optionLabel:o=u=>u,groupRef:i,autoFocus:a,onTrack:s,onToggleRow:l}){return nPr(i,r),(0,aXe.jsx)(_t,{ref:i,direction:"row",role:"radiogroup","aria-label":e,spacing:"2px",onFocus:s,onKeyDown:tPr(t,r,n,l),sx:F0o,children:t.map(u=>(0,aXe.jsx)(ZAr,{value:u,label:o(u),checked:u===r,autoFocus:a,onSelect:()=>n(u)},u))})}var sXe=k(I(),1);function iPr({value:e,onChange:t,cloneState:r}){let{nodes:n,names:o,visible:i}=il(),a=(0,oPr.useRef)(null);return!i||!n||!e?null:(0,sXe.jsx)(cTe,{label:"Machine",options:o,value:e,onChange:t,optionLabel:s=>(0,sXe.jsx)(QAr,{nodes:n,name:s,clone:r(s)}),groupRef:a,autoFocus:!1,onTrack:()=>{}})}var uTe=k(I(),1);function aPr({prompt:e,children:t}){return(0,uTe.jsxs)(_t,{children:[e,(0,uTe.jsx)(_t,{spacing:1,sx:{px:1.5,pb:1.5},children:t})]})}var lPr=k(I(),1),$0o=".MuiOutlinedInput-notchedOutline",z0o={"& .MuiOutlinedInput-root":{px:"18px",py:2,minHeight:92,alignItems:"flex-start",bgcolor:"transparent",borderRadius:0,fontSize:15},[`&&& ${$0o}`]:{border:0},"& textarea::placeholder":{color:"text.disabled",opacity:1}};function sPr({value:e,onChange:t,placeholder:r,inputRef:n,autoFocus:o,onTrack:i}){return(0,lPr.jsx)(Un,{sx:z0o,value:e,onChange:a=>t(a.target.value),onKeyDown:oT,onFocus:i,onSelect:i,inputRef:n,placeholder:r,autoFocus:o,fullWidth:!0,multiline:!0,minRows:3,maxRows:12,slotProps:{htmlInput:{"aria-label":"Prompt"}}})}var dPr=k(oe(),1);var Ey={draft:{placeholder:"Describe the backlog item to draft...",submitLabel:"Start draft",sessionMode:"assist-draft"},bug:{placeholder:"Describe the bug: what happened, what you expected...",submitLabel:"File bug",sessionMode:"assist-bug"},prompt:{placeholder:Ebe,submitLabel:"Start session"},design:{placeholder:"Describe the design task...",submitLabel:"Start design"}},cPr=Object.keys(Ey);var lXe=k(I(),1);function uPr({anchor:e,harness:t,harnesses:r,onPick:n,onClose:o}){return(0,lXe.jsx)(Js,{open:e!==null,anchorEl:e,onClose:o,slotProps:{list:{dense:!0,"aria-label":"Harness"}},children:r.map(i=>(0,lXe.jsx)(un,{role:"menuitemradio","aria-checked":i===t,selected:i===t,onClick:()=>{n(i),o()},sx:{fontSize:13},children:vc(i)},i))})}var EL=k(I(),1);function fPr(e){return t=>t==="prompt"&&e?(0,EL.jsxs)(EL.Fragment,{children:["prompt",(0,EL.jsx)(V,{component:"span",sx:{fontWeight:400,whiteSpace:"pre"},children:` \xB7 ${vc(e)}`}),(0,EL.jsx)(jd,{sx:{fontSize:18,mr:-.75}})]}):t}var RL=k(I(),1);function pPr({draft:e,harness:t,harnesses:r,focus:n}){let[o,i]=(0,dPr.useState)(null),a=e.mode==="prompt"&&r.length>1,s=()=>i(EU(n.modeRef.current)??null),l=u=>{a&&u==="prompt"?s():e.setMode(u)};return(0,RL.jsxs)(RL.Fragment,{children:[(0,RL.jsx)(cTe,{label:"Mode",options:cPr,value:e.mode,onChange:l,optionLabel:fPr(r.length>1?t:void 0),groupRef:n.modeRef,autoFocus:n.autoFocus==="mode",onTrack:n.trackMode,onToggleRow:a?s:void 0}),(0,RL.jsx)(uPr,{anchor:o,harness:t,harnesses:r,onPick:e.setHarness,onClose:()=>i(null)})]})}var kPr=k(oe(),1);var cXe=k(I(),1),H0o={zIndex:e=>e.zIndex.modal+1};function hPr({open:e,anchor:t,children:r}){return(0,cXe.jsx)(r7,{open:e,anchorEl:t,placement:"bottom-start",sx:H0o,children:(0,cXe.jsx)(rn,{sx:{maxHeight:240,overflowY:"auto",width:t?.clientWidth},onMouseDown:n=>n.preventDefault(),children:r})})}var mPr=k(I(),1),gPr=nt((0,mPr.jsx)("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"}),"KeyboardArrowDown");var uXe=k(I(),1),U0o={fontSize:13,height:36,pr:1,cursor:"pointer","& input":{cursor:"text"}},W0o={fontSize:16,color:"text.disabled"};function yPr(e){return{htmlInput:{role:"combobox","aria-label":"Repo","aria-expanded":e},input:{sx:U0o,endAdornment:(0,uXe.jsx)($ke,{position:"end",children:(0,uXe.jsx)(gPr,{sx:W0o})})}}}var vPr=k(HI(),1);function bPr({open:e,highlighted:t,accept:r,close:n,navigate:o,openList:i}){return a=>{if(!e){if(a.key==="ArrowDown"){a.preventDefault(),i();return}oT(a);return}if(a.key!=="Escape"){if(a.key==="Enter"){if(a.preventDefault(),t===void 0)return;(0,vPr.flushSync)(()=>{r(t),n()}),oT(a);return}if(a.key!=="Tab"){o(a);return}t!==void 0&&r(t),n()}}}function fTe(e,t){let r=t.trim().toLowerCase();return r?e.filter(n=>Eb(n).toLowerCase().includes(r)):e}var fXe=k(oe(),1);function xPr(){let[e,t]=(0,fXe.useState)(!1),[r,n]=(0,fXe.useState)("");return{open:e,query:r,show:()=>t(!0),filterBy:o=>{n(o),t(!0)},close:()=>{t(!1),n("")}}}var TPr=k(oe(),1);var SPr=e=>e?Eb(e):"";function CPr(e){let[t,r]=(0,TPr.useState)(()=>SPr(e));return{text:t,setText:r,showRepo:n=>r(SPr(n))}}function wPr(e,t,r){let n=xPr(),o=CPr(t),i=fTe(e,n.query),a=f=>{r(f),o.showRepo(f)},s=T5(i,n.query,a,n.close),l=()=>s.setHighlight(Math.max(e.indexOf(t),0)),u=()=>{l(),n.show()};return{open:n.open,text:o.text,filtered:i,highlight:s.highlight,setHighlight:s.setHighlight,onKeyDown:bPr({open:n.open,highlighted:i[s.highlight],accept:a,close:n.close,navigate:s.onKeyDown,openList:u}),onClick:()=>{n.open||u()},onType:f=>{o.setText(f),n.filterBy(f)},onFocus:l,onBlur:()=>{n.close(),o.showRepo(t)},pick:f=>{a(f),n.close()}}}var RU=k(I(),1);function _Pr({repos:e,value:t,onChange:r,inputRef:n,autoFocus:o,onTrack:i}){let a=wPr(e,t,r),s=(0,kPr.useRef)(null);return(0,RU.jsxs)(V,{ref:s,sx:{flex:1,minWidth:0},children:[(0,RU.jsx)(Un,{value:a.text,onChange:l=>a.onType(l.target.value),onFocus:l=>{l.target.select(),a.onFocus(),i()},inputRef:n,autoFocus:o,onClick:a.onClick,onBlur:a.onBlur,onKeyDown:a.onKeyDown,placeholder:"Repo",size:"small",fullWidth:!0,slotProps:yPr(a.open)}),(0,RU.jsx)(hPr,{open:a.open,anchor:s.current,children:(0,RU.jsx)(ISe,{repos:a.filtered,selected:t,highlight:a.highlight,onHighlight:a.setHighlight,onSelect:a.pick})})]})}var N5=k(I(),1);function EPr({cloneState:e,...t}){let{draft:r,focus:n}=t,{repos:o}=Vn();return(0,N5.jsxs)(aPr,{prompt:(0,N5.jsx)(sPr,{value:r.prompt,onChange:r.setPrompt,placeholder:Ey[r.mode].placeholder,inputRef:n.promptRef,autoFocus:n.autoFocus==="prompt",onTrack:n.trackPrompt}),children:[(0,N5.jsxs)(_t,{direction:"row",spacing:1,sx:{alignItems:"flex-start"},children:[(0,N5.jsx)(_Pr,{repos:o,value:r.cwd,onChange:r.setCwd,inputRef:n.repoRef,autoFocus:n.autoFocus==="repo",onTrack:n.trackRepo}),(0,N5.jsx)(pPr,{...t})]}),(0,N5.jsx)(iPr,{value:r.node,onChange:r.setNode,cloneState:e})]})}var PPr=k(I(),1),RPr=[["Enter","start"],["Shift+Enter","newline"],["Esc","close"]];function APr({submitLabel:e,disabled:t=!1,loading:r=!1}){return(0,PPr.jsx)(Tt,{type:"submit",variant:"contained",disabled:t,loading:r,children:e})}var AL=k(I(),1),G0o=e=>({alignItems:"center",flexWrap:"wrap",gap:"14px",py:"10px",pl:"18px",pr:1.5,borderTop:1,borderColor:e.tokens.color.lineSoft,bgcolor:"background.default",fontSize:12,color:"text.secondary"}),V0o=e=>({mr:.5,px:"5px",border:1,borderColor:"divider",borderRadius:"4px",fontFamily:e.typography.fontFamilyMono,fontSize:10.5,color:"text.primary"});function LPr(e){return(0,AL.jsxs)(_t,{direction:"row",sx:G0o,children:[RPr.map(([t,r])=>(0,AL.jsxs)("span",{children:[(0,AL.jsx)(V,{component:"kbd",sx:V0o,children:t}),r]},t)),(0,AL.jsx)(V,{sx:{flex:1}}),(0,AL.jsx)(APr,{...e})]})}var PL=k(oe(),1);function IPr(e,t){let r=(0,PL.useRef)(e),n=(0,PL.useRef)(null),o=(0,PL.useRef)(null),i=(0,PL.useRef)(null),a=(0,PL.useCallback)(u=>{n.current=u;let{field:f,selectionStart:d,selectionEnd:p}=r.current;u&&f==="prompt"&&u.setSelectionRange(d,p)},[]),s=u=>{let f=u.target;t({field:"prompt",selectionStart:f.selectionStart,selectionEnd:f.selectionEnd})},l=()=>{if(i.current?.closest("form")?.contains(document.activeElement))return;let{field:u}=r.current;({repo:o.current,mode:EU(i.current),prompt:n.current}[u]??n.current)?.focus()};return{autoFocus:e.field,promptRef:a,repoRef:o,modeRef:i,trackPrompt:s,trackRepo:()=>t({...e,field:"repo"}),trackMode:()=>t({...e,field:"mode"}),restore:l}}function q0o(e,t,r){return e?r.kind==="cloned"?{kind:"launch",cwd:r.cwd}:r.kind==="clonable"?{kind:"clone",prompt:DSe(r,t)}:{kind:"blocked"}:{kind:"launch",cwd:e}}function MPr(e,t){let{names:r,visible:n}=il(),o=ASe(t,n?r:[void 0]);return{cloneState:o,target:q0o(t,e,o(e))}}function dTe({mode:e,harness:t,prompt:r,cwd:n,node:o},i){let a=n||void 0,s=o?[o]:[];if(e==="prompt"){t==="claude"?i.onCreate(r,a,...s):i.onCreateHarness(t,r,a,...s);return}if(e==="design"){i.onCreateDesign(r,a,...s);return}let l=o?[{node:o}]:[];a1r(Ey[e].sessionMode,n,(u,f)=>i.onCreateAssist(u,f,...l),()=>{},r)}function DPr(e,t,r,n){return r.kind==="blocked"||e.modePending?!1:r.kind==="clone"?(SSe(r.prompt,n.onCreateAssist),!0):(dTe({mode:e.mode,harness:t,prompt:e.prompt,cwd:r.cwd,node:e.node},n),e.clear(),!0)}var pTe=k(oe(),1);function NPr(e,t){let[r,n]=(0,pTe.useState)(!1);return(0,pTe.useEffect)(()=>{!r||e.modePending||(n(!1),e.modeError||t())},[r,e.modePending,e.modeError,t]),()=>{e.modePending?n(!0):t()}}function OPr(e,t,r,n,o){let i=NPr(e,()=>{DPr(e,t,r,n)&&o()});return a=>{a.preventDefault(),i()}}var Lee=k(oe(),1);function BPr(e,t){let r=(0,Lee.useRef)(e),n=(0,Lee.useRef)(null);return(0,Lee.useEffect)(()=>{if(r.current&&!e){let o=n.current;o?.isConnected?o.focus():t()}r.current=e},[e,t]),o=>{n.current=o.target}}var $Pr=k(I(),1),j0o={border:0,margin:0,padding:0,minWidth:0};function FPr({loading:e,restoreFocus:t,children:r}){let n=BPr(e,t);return(0,$Pr.jsx)("fieldset",{disabled:e,style:j0o,onFocus:n,children:r})}var mTe=k(I(),1);function hTe({error:e,onRetry:t}){return e?(0,mTe.jsxs)(jn,{severity:"error",sx:{mx:2,my:1},action:t&&(0,mTe.jsx)(Tt,{color:"inherit",size:"small",onClick:t,children:"Retry"}),children:["Couldn't load this repo's default mode (",e,"). Pick a mode or retry."]}):null}var O5=k(I(),1);function zPr({draft:e,launchers:t,onClose:r}){let n=IPr(e.focus,e.setFocus),o=_U(Wg()),i=o.includes(e.harness)?e.harness:"claude",{target:a,cloneState:s}=MPr(e.node,e.cwd),l=OPr(e,i,a,t,r);return(0,O5.jsx)(oTe,{onClose:r,onEntered:n.restore,centered:!0,children:(0,O5.jsx)("form",{onSubmit:l,children:(0,O5.jsxs)(FPr,{loading:e.modePending,restoreFocus:n.restore,children:[(0,O5.jsx)(EPr,{draft:e,harness:i,harnesses:o,focus:n,cloneState:s}),(0,O5.jsx)(hTe,{error:e.modeError,onRetry:e.retryMode}),(0,O5.jsx)(LPr,{submitLabel:a.kind==="clone"?"Clone":Ey[e.mode].submitLabel,disabled:a.kind==="blocked",loading:e.modePending})]})})})}var LL=k(oe(),1);async function Y0o(e){try{let t=e?`?cwd=${encodeURIComponent(e)}`:"",r=await Jt(`/api/new-session-defaults${t}`);if(!r.ok)return{error:`HTTP ${r.status}`};let n=await r.json();if(Object.hasOwn(Ey,n?.mode))return{mode:n.mode};throw new Error(`unknown mode ${JSON.stringify(n?.mode)}`)}catch(t){return Cr(t,"new-session defaults"),{error:t instanceof Error?t.message:String(t)}}}function gTe(e,t=0){let[r,n]=(0,LL.useState)(0),[o,i]=(0,LL.useState)(null),a=(0,LL.useCallback)(()=>n(l=>l+1),[]);if((0,LL.useEffect)(()=>{let l=!1;return Y0o(e).then(u=>{l||i({cwd:e,opens:t,attempt:r,outcome:u})}),()=>{l=!0}},[e,t,r]),!o)return null;let{outcome:s}=o;return{mode:"mode"in s?s.mode:"prompt",pending:o.cwd!==e||o.opens!==t||o.attempt!==r,error:"error"in s?s.error:void 0,retry:a}}function yTe(e,t){if(!(e!==void 0||!t||t.pending))return t.error}function HPr(e,{visible:t,names:r,selected:n}){if(t)return e&&r.includes(e)?e:n}var jT=k(oe(),1),UPr={field:"prompt",selectionStart:0,selectionEnd:0};function WPr(){let[e,t]=(0,jT.useState)(""),[r,n]=(0,jT.useState)(),[o,i]=(0,jT.useState)(),[a,s]=(0,jT.useState)("claude"),[l,u]=(0,jT.useState)(),[f,d]=(0,jT.useState)(UPr),p=(0,jT.useCallback)(()=>{t(""),n(void 0),i(void 0),u(void 0),d(UPr)},[]);return{prompt:e,cwd:r,mode:o,harness:a,node:l,focus:f,setPrompt:t,setNode:u,setCwd:n,setMode:i,setHarness:s,setFocus:d,clear:p}}function GPr(e,t=gTe){let{selectedCwd:r}=Vn(),n=il(),o=WPr(),i=o.cwd??r,a=t(i,e);return a?{...o,cwd:i,mode:o.mode??a.mode,modePending:o.mode===void 0&&a.pending,modeError:yTe(o.mode,a),retryMode:a.retry,node:HPr(o.node,n)}:null}function VPr(e){Bi(to("newSession").matches,e)}var qPr=k(oe(),1);function jPr(e,t){let{selectedCwd:r}=Vn(),[n,o]=$s(),i=n.get("new"),a=n.get("newCwd")??r,{setPrompt:s,setCwd:l,setFocus:u}=e??{};(0,qPr.useEffect)(()=>{i===null||!s||!l||!u||(i&&(s(i),l(a),u({field:"prompt",selectionStart:i.length,selectionEnd:i.length})),t(),o(f=>(f.delete("new"),f.delete("newCwd"),f),{replace:!0}))},[i,a,s,l,u,t,o])}var KPr=k(I(),1);function YPr({launchers:e}){let[t,r]=(0,Iee.useState)(!1),[n,o]=(0,Iee.useState)(0),i=GPr(n),a=(0,Iee.useCallback)(()=>{r(!0),o(s=>s+1)},[]);return VPr(a),jPr(i,a),!t||!i?null:(0,KPr.jsx)(zPr,{draft:i,launchers:e,onClose:()=>r(!1)})}var vTe=k(I(),1);function XPr({reconnecting:e}){return(0,vTe.jsx)(hu,{open:e,children:(0,vTe.jsx)(jn,{severity:"info",variant:"filled",icon:(0,vTe.jsx)(bo,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var Ry=k(I(),1);function QPr({socket:e,onViewLaunchedSession:t}){return(0,Ry.jsxs)(Ry.Fragment,{children:[(0,Ry.jsx)(WAr,{}),(0,Ry.jsx)(YPr,{launchers:{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateHarness:e.createHarnessSession,onCreateAssist:e.createAssistSession}}),(0,Ry.jsx)(XPr,{reconnecting:e.reconnecting}),(0,Ry.jsx)(DAr,{}),(0,Ry.jsx)(sl,{error:e.error,onClose:e.clearError}),(0,Ry.jsx)(VAr,{notice:e.success,onClose:e.clearSuccess,onView:t})]})}var Bb=k(oe(),1);var K0o=6e4;function X0o(e,t,r){return t.map(n=>e.find(o=>o.name===n)??{name:n,local:n===r,loading:!0})}function bTe(e){let t=e.nodes?.local,r=e.names.join(`
|
|
4023
4023
|
`),[n,o]=(0,Bb.useState)([]),i=(0,Bb.useRef)(0),a=(0,Bb.useCallback)(()=>{let l=r?r.split(`
|
|
4024
4024
|
`):[];if(l.length===0)return;let u=++i.current;o(f=>X0o(f,l,t));for(let f of l)X2e(f,f===t).then(d=>{u===i.current&&o(p=>p.map(h=>h.name===f?d:h))})},[r,t]);(0,Bb.useEffect)(()=>{a();let l=setInterval(a,K0o);return()=>clearInterval(l)},[a]);let s=n.length===0;return(0,Bb.useMemo)(()=>({entries:n,loading:s,refresh:a}),[n,s,a])}var B5=k(I(),1);function ZPr({shell:e,children:t}){let{socket:r,selection:n,launch:o,sidebarCollapse:i}=e,a=bTe(r.nodeSelection);return(0,B5.jsx)(kKe.Provider,{value:a,children:(0,B5.jsx)(y3e.Provider,{value:i,children:(0,B5.jsx)(aq.Provider,{value:n,children:(0,B5.jsx)(K4e.Provider,{value:r.nodeSelection,children:(0,B5.jsx)(Fl.Provider,{value:n.selectedNode,children:(0,B5.jsx)(uqe.Provider,{value:o,children:(0,B5.jsx)(dft,{children:t})})})})})})})}var JPr=k(I(),1),e6r=nt((0,JPr.jsx)("path",{d:"M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2zM4 6h16v10H4z"}),"Computer");var t6r=k(oe(),1);var Ay=k(I(),1),Q0o={ml:1,textTransform:"none",fontSize:12};function r6r(){let{nodes:e,names:t,visible:r,selected:n,select:o}=il(),[i,a]=(0,t6r.useState)(null);return!r||!e||!n?null:(0,Ay.jsxs)(Ay.Fragment,{children:[(0,Ay.jsx)(Tt,{size:"small",color:"inherit",startIcon:(0,Ay.jsx)(e6r,{fontSize:"small"}),"aria-label":"Machine","aria-haspopup":"menu",onClick:s=>a(s.currentTarget),sx:Q0o,children:(0,Ay.jsx)(Pee,{nodes:e,name:n})}),(0,Ay.jsx)(Js,{anchorEl:i,open:!!i,onClose:()=>a(null),children:t.map(s=>(0,Ay.jsx)(un,{selected:s===n,onClick:()=>{o(s),a(null)},sx:{fontSize:13},children:(0,Ay.jsx)(Pee,{nodes:e,name:s,showVersion:!0})},s))})]})}var Mee=k(oe(),1);function n6r(e,t){return[...e[0].slice(0,-1),String(t+1)]}var IL=k(I(),1),Z0o=[Oi("secondary"),{ml:.75}];function o6r({index:e,label:t,count:r,...n}){let{chords:o}=to("navTab");return(0,IL.jsx)(rr,{describeChild:!0,title:(0,IL.jsx)(of,{label:t,chords:[n6r(o,e)]}),children:(0,IL.jsx)(Tx,{label:r?(0,IL.jsxs)("span",{children:[t,(0,IL.jsx)(V,{component:"span",sx:Z0o,children:r})]}):t,...n})})}var i6r=k(oe(),1);var J0o=6e4;function a6r(){let e=Fve();return(0,i6r.useEffect)(()=>{Es.refresh();let t=setInterval(()=>{Es.refresh()},J0o);return()=>clearInterval(t)},[]),e?.length??0}var dXe=k(oe(),1);function s6r(e,t){let{bound:r}=to("navTab"),n=e.length,o=(0,dXe.useCallback)(a=>(gq(a,r)??n)<n,[r,n]),i=(0,dXe.useCallback)(a=>{let s=e[gq(a,r)??-1];s&&t(s)},[e,t,r]);Bi(o,i)}var xTe=k(oe(),1);function l6r(){let[e,t]=(0,xTe.useState)(!1);return(0,xTe.useEffect)(()=>{let r=!1;return(async()=>{try{let o=await(await Jt("/api/news/nav")).json();r||t(o?.showInNav===!0)}catch(n){Cr(n,"news nav"),r||t(!1)}})(),()=>{r=!0}},[]),e}var STe=k(oe(),1);async function eyo(e,t){let r=await Jt(Vr(`/api/releases/configured?cwd=${encodeURIComponent(e)}`,t));return r.ok?(await r.json())?.configured===!0:void 0}function c6r(e){let[t,r]=(0,STe.useState)(null),n=pr(),o=`${n??""}\0${e}`;return(0,STe.useEffect)(()=>{if(!e)return;let i=!1;return eyo(e,n).catch(a=>{Cr(a,"releases configured")}).then(a=>{i||r({key:o,configured:a})}),()=>{i=!0}},[e,n,o]),t?.key===o?t.configured:void 0}var u6r=k(oe(),1);function f6r(e){let{pathname:t}=ii(),r=Kr(),n=t==="/releases"||t.startsWith("/releases/");(0,u6r.useEffect)(()=>{e===!1&&n&&r("/sessions",{replace:!0})},[e,n,r])}var tyo={path:"/sessions",label:"Sessions"},ryo={path:"/backlog",label:"Backlog"},nyo={path:"/next",label:"Next"},oyo={path:"/releases",label:"Releases"},iyo={path:"/news",label:"News"},ayo={path:"/inbox",label:"Inbox"};function d6r(e,t){return[tyo,ryo,nyo,...e?[oyo]:[],...t?[iyo]:[],ayo]}var pXe=k(I(),1),syo={mx:"6px"};function p6r({cwd:e}){let t=ii(),r=Kr(),n=c6r(e),o=l6r(),i=a6r();f6r(n);let a=n===!0,s=(0,Mee.useMemo)(()=>d6r(a,o),[a,o]),l=(0,Mee.useMemo)(()=>s.map(d=>d.path),[s]),u=s.findIndex(d=>t.pathname.startsWith(d.path)),f=(0,Mee.useCallback)(d=>{t.pathname!==d&&r(d)},[t.pathname,r]);return s6r(l,f),(0,pXe.jsx)(o3,{sx:syo,value:u===-1?!1:u,textColor:"inherit",indicatorColor:"secondary",children:s.map((d,p)=>(0,pXe.jsx)(o6r,{index:p,label:d.label,count:d.path==="/inbox"?i:void 0,onClick:()=>f(d.path)},d.path))})}var Dee=k(I(),1),h6r=(e,t)=>({bgcolor:e,color:t,"& .MuiSvgIcon-root":{color:t},transition:"filter 0.2s ease, transform 0.2s ease","&:hover":{bgcolor:e,color:t,filter:"brightness(1.08)"},"&:active":{transform:"translateY(1px)"}}),lyo=e=>({ml:.75,...e.tokens.color.appBar?h6r("primary.main","primary.contrastText"):h6r("primary.contrastText","primary.main")});function m6r(){let[,e]=$s(),{label:t,chords:r}=to("newSession");return(0,Dee.jsx)(rr,{title:(0,Dee.jsx)(of,{label:t,chords:r}),children:(0,Dee.jsx)(Vt,{sx:lyo,"aria-label":"New session",onClick:()=>e(o=>(o.set("new",""),o),{replace:!0}),children:(0,Dee.jsx)(qd,{})})})}var TTe=k(oe(),1);var Nee=k(I(),1),cyo={strokeWidth:2};function g6r(e){return(0,Nee.jsxs)(Pbe,{viewBox:"0 0 24 24",sx:cyo,...e,children:[(0,Nee.jsx)("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 3.5c-.3 1.15-.3 2.35 0 3.5A5.4 5.4 0 0 0 4 10.5c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),(0,Nee.jsx)("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}var Oee=k(I(),1);function y6r({cwd:e}){let[t,r]=(0,TTe.useState)(null),n=pr();return(0,TTe.useEffect)(()=>{if(!e){r(null);return}let o=!1;return(async()=>{try{let a=await(await Jt(Vr(`/api/github-url?cwd=${encodeURIComponent(e)}`,n))).json();o||r(a?.url??null)}catch(i){Cr(i,"GitHub URL"),o||r(null)}})(),()=>{o=!0}},[e,n]),t?(0,Oee.jsx)(rr,{title:"Open in GitHub",children:(0,Oee.jsx)(V,{component:"span",sx:Lbe,children:(0,Oee.jsx)(Vt,{onClick:()=>window.open(t,"_blank"),children:(0,Oee.jsx)(g6r,{})})})}):null}var Py=k(I(),1),uyo={color:"inherit",mr:1.5};function v6r({reconnecting:e}){let{pending:t,error:r,clearError:n,restart:o}=g5("webserver",e);return(0,Py.jsxs)(Py.Fragment,{children:[(0,Py.jsx)(rr,{title:"Restart web server",children:(0,Py.jsx)("span",{children:(0,Py.jsx)(Vt,{sx:uyo,disabled:t,onClick:o,children:t?(0,Py.jsx)(bo,{size:24}):(0,Py.jsx)(Lz,{})})})}),(0,Py.jsx)(sl,{error:r,onClose:n})]})}var S6r=k(oe(),1);var b6r=k(oe(),1);function x6r(e){let t=Sn().palette.primary.main;Bi(to("focusRepoPicker").matches,(0,b6r.useCallback)(()=>bc({locate:()=>e.current?.querySelector("button")??null,focus:r=>r.focus()},t),[e,t]))}var Bee=k(I(),1),fyo={width:240,ml:2};function T6r({repos:e,selected:t,onSelect:r}){let n=(0,S6r.useRef)(null);x6r(n);let{chords:o}=to("focusRepoPicker");return(0,Bee.jsx)(V,{ref:n,sx:fyo,children:(0,Bee.jsx)(Rbe,{label:t?Eb(t):"Select repo...",tooltip:(0,Bee.jsx)(of,{label:"Repo",chords:o}),typeToOpen:!0,children:(i,a)=>(0,Bee.jsx)(R4r,{repos:e,selected:t,onSelect:r,close:i,initialFilter:a})})})}var I6r=k(oe(),1);var Fee=k(oe(),1);function CTe(e){let[t,r]=(0,Fee.useState)([]),[n,o]=(0,Fee.useState)(!0),i=pr();return(0,Fee.useEffect)(()=>{if(!e){r([]),o(!1);return}let a=!1;return o(!0),Jt(Vr(`/api/pr-list?cwd=${encodeURIComponent(e)}`,i)).then(s=>s.json()).then(s=>{a||(r(Array.isArray(s?.prs)?s.prs:[]),o(!1))}).catch(s=>{Cr(s,"open PRs"),!a&&(r([]),o(!1))}),()=>{a=!0}},[e,i]),{prs:t,loading:n}}var hXe=k(I(),1);function mXe({text:e}){return(0,hXe.jsx)(V,{sx:{p:1.5},children:(0,hXe.jsx)(Ee,{sx:{fontSize:13,color:"text.secondary"},children:e})})}var ML=k(I(),1);function C6r({pr:e,highlighted:t,onHover:r,onPick:n}){let o=LSe(t);return(0,ML.jsx)(un,{ref:o,selected:t,onMouseDown:i=>i.preventDefault(),onMouseEnter:r,onClick:()=>n(e),sx:{alignItems:"flex-start",py:.75,whiteSpace:"normal"},children:(0,ML.jsxs)(_t,{spacing:.25,sx:{minWidth:0},children:[(0,ML.jsxs)(Ee,{sx:{fontSize:13,lineHeight:1.3,fontWeight:500},children:[e.title,e.isDraft&&(0,ML.jsx)(Yn,{label:"Draft",size:"small",variant:"outlined",sx:{ml:.75,height:18,fontSize:10,verticalAlign:"middle"}})]}),(0,ML.jsxs)(Ee,{sx:{fontSize:11,color:"text.secondary"},children:["#",e.number," \xB7 ",e.author," \xB7 ",Po(e.createdAt)]})]})})}var gXe=k(I(),1);function w6r({prs:e,highlight:t,onHighlight:r,onPick:n}){return(0,gXe.jsx)(Sm,{dense:!0,disablePadding:!0,sx:{maxHeight:200,overflowY:"auto"},children:e.map((o,i)=>(0,gXe.jsx)(C6r,{pr:o,highlighted:i===t,onHover:()=>r(i),onPick:n},o.number))})}var _6r=k(oe(),1);function k6r(e,t){let r=t.trim().toLowerCase();if(!r)return e;let n=r.replace(/^#/,"");return e.filter(o=>o.title.toLowerCase().includes(r)||o.author.toLowerCase().includes(r)||n!==""&&String(o.number).includes(n))}function E6r(e,t,r){let[n,o]=(0,_6r.useState)(""),i=k6r(e,n),{highlight:a,setHighlight:s,onKeyDown:l}=T5(i,n,t,r);return{filter:n,setFilter:o,filtered:i,highlight:a,setHighlight:s,onKeyDown:l,select:f=>{t(f),r()}}}var F5=k(I(),1),R6r={...Jz,left:"auto",width:320,maxHeight:"none",overflowY:"visible"};function A6r({cwd:e,onPick:t,close:r}){let{prs:n,loading:o}=CTe(e),i=E6r(n,t,r);return o||n.length===0?(0,F5.jsx)(rn,{elevation:4,sx:R6r,children:(0,F5.jsx)(mXe,{text:o?"Loading open PRs\u2026":"No open PRs"})}):(0,F5.jsxs)(rn,{elevation:4,sx:R6r,children:[(0,F5.jsx)(Sw,{autoFocus:!0,value:i.filter,onChange:i.setFilter,onKeyDown:i.onKeyDown,placeholder:"Filter PRs..."}),i.filtered.length===0?(0,F5.jsx)(mXe,{text:"No PRs match"}):(0,F5.jsx)(w6r,{prs:i.filtered,highlight:i.highlight,onHighlight:i.setHighlight,onPick:i.select})]})}var L6r=k(I(),1);function P6r({cwd:e,onPick:t,close:r}){return(0,L6r.jsx)(A6r,{cwd:e,onPick:t,close:r})}var $5=k(I(),1);function M6r({cwd:e,disabled:t,onSelect:r}){let{prs:n,loading:o}=CTe(e),[i,a]=(0,I6r.useState)(null);return o||n.length===0?null:(0,$5.jsxs)($5.Fragment,{children:[(0,$5.jsx)(Rbe,{label:"prs",disabled:t,children:s=>(0,$5.jsx)(P6r,{cwd:e,onPick:a,close:s})}),i&&(0,$5.jsx)(abe,{pr:i,onSelect:s=>{r(i,s),a(null)},onCancel:()=>a(null)})]})}var N6r=k(I(),1);function D6r({onStartRun:e,cwd:t}){let r=kbe(t);return!t||r.length===0?null:(0,N6r.jsx)(Cbe,{runs:r,onSelect:n=>e(n,t)})}var $ee=k(I(),1);function O6r({onCreateAssist:e,onStartRun:t}){let{selectedCwd:r,selectedNode:n}=Vn();return(0,$ee.jsxs)(_t,{direction:"row",spacing:.5,sx:{alignItems:"center","&:not(:empty)":{ml:1.5}},children:[(0,$ee.jsx)(M6r,{cwd:r,disabled:!r,onSelect:(o,i)=>e([...i,String(o.number)],r,{...bE(o),node:n})}),(0,$ee.jsx)(D6r,{onStartRun:(o,i)=>t(o,i,void 0,void 0,n),cwd:r})]})}var tm=k(I(),1),dyo={minHeight:48,pl:1,pr:14};function B6r({socket:e,selection:t}){let{collapsed:r,onToggleCollapsed:n}=Lw();return(0,tm.jsxs)(n3,{variant:"dense",disableGutters:!0,sx:dyo,children:[r&&(0,tm.jsx)(nse,{collapsed:r,onToggleCollapsed:n}),(0,tm.jsx)(v6r,{reconnecting:e.reconnecting}),(0,tm.jsx)(p6r,{cwd:t.selectedCwd}),(0,tm.jsx)(r6r,{}),(0,tm.jsx)(T6r,{repos:t.repos,selected:t.selectedCwd,onSelect:t.setSelectedCwd}),(0,tm.jsxs)(V,{sx:{display:"flex",alignItems:"center",ml:1},children:[(0,tm.jsx)(Ibe,{cwd:t.selectedCwd}),(0,tm.jsx)(y6r,{cwd:t.selectedCwd}),(0,tm.jsx)(m6r,{})]}),(0,tm.jsx)(O6r,{onCreateAssist:e.createAssistSession,onStartRun:e.startRun})]})}var wTe=k(oe(),1);function F6r(){let[e,t]=(0,wTe.useState)(null);return(0,wTe.useEffect)(()=>{let r=!1;return(async()=>{try{let o=await(await Jt("/api/health")).json();!r&&typeof o?.nodeName=="string"&&t(o.nodeName)}catch(n){Cr(n,"node name")}})(),()=>{r=!0}},[]),e}var z6r=k(I(),1),pyo={lineHeight:"32px",bgcolor:"transparent"};function $6r(){let e=F6r();return e?(0,z6r.jsx)(gke,{sx:pyo,children:e}):null}var H6r=k(I(),1),U6r=nt((0,H6r.jsx)("path",{d:"M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m-9 3h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-1 2H5v-2h2zm0-3H5V8h2zm9 7H8v-2h8zm0-4h-2v-2h2zm0-3h-2V8h2zm3 3h-2v-2h2zm0-3h-2V8h2z"}),"Keyboard");var W6r=k(I(),1),G6r=nt((0,W6r.jsx)("path",{d:"m12 16.5 4-4h-3v-9h-2v9H8zm9-13h-6v1.99h6v14.03H3V5.49h6V3.5H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-14c0-1.1-.9-2-2-2"}),"SystemUpdateAlt");var V6r=k(I(),1),q6r=nt((0,V6r.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6"}),"Brightness4");var j6r=k(I(),1),Y6r=nt((0,j6r.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6m0-10c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4"}),"Brightness7");var yXe=k(I(),1);function K6r({mode:e}){return e==="dark"?(0,yXe.jsx)(Y6r,{fontSize:"small"}):(0,yXe.jsx)(q6r,{fontSize:"small"})}var X6r=k(I(),1),Q6r=nt((0,X6r.jsx)("path",{d:"M15.5 1h-8C6.12 1 5 2.12 5 3.5v17C5 21.88 6.12 23 7.5 23h8c1.38 0 2.5-1.12 2.5-2.5v-17C18 2.12 16.88 1 15.5 1m-4 21c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m4.5-4H7V4h9z"}),"PhoneIphone");var AU=k(I(),1);function Z6r({onClose:e}){let t=Kr();return(0,AU.jsxs)(un,{onClick:()=>{e(),t("/connect-mobile")},children:[(0,AU.jsx)(t1,{children:(0,AU.jsx)(Q6r,{fontSize:"small"})}),(0,AU.jsx)(Dd,{children:"Connect mobile"})]})}var J6r=k(I(),1),eLr=nt((0,J6r.jsx)("path",{d:"m20.38 8.57-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83"}),"Speed");var PU=k(I(),1);function tLr(){let e=hbe();return(0,PU.jsxs)(un,{onClick:()=>a2t(!e),children:[(0,PU.jsx)(t1,{children:(0,PU.jsx)(eLr,{fontSize:"small"})}),(0,PU.jsx)(Dd,{children:e?"Hide render HUD":"Show render HUD"})]})}var Ys=k(I(),1);function rLr({mode:e,restartLabel:t,updateLabel:r,onToggleColorMode:n,onShowShortcuts:o,onConnectMobile:i,onRestart:a,onUpdate:s}){return[(0,Ys.jsxs)(un,{onClick:n,children:[(0,Ys.jsx)(t1,{children:(0,Ys.jsx)(K6r,{mode:e})}),(0,Ys.jsx)(Dd,{children:"Toggle dark mode"})]},"color-mode"),(0,Ys.jsx)(tLr,{},"render-hud"),(0,Ys.jsxs)(un,{onClick:o,children:[(0,Ys.jsx)(t1,{children:(0,Ys.jsx)(U6r,{fontSize:"small"})}),(0,Ys.jsx)(Dd,{children:"Keyboard shortcuts"})]},"shortcuts"),(0,Ys.jsx)(Z6r,{onClose:i},"connect-mobile"),(0,Ys.jsx)(lo,{},"restart-divider"),(0,Ys.jsxs)(un,{onClick:a,children:[(0,Ys.jsx)(t1,{children:(0,Ys.jsx)(eM,{fontSize:"small"})}),(0,Ys.jsx)(Dd,{children:t})]},"restart"),(0,Ys.jsxs)(un,{onClick:s,children:[(0,Ys.jsx)(t1,{children:(0,Ys.jsx)(G6r,{fontSize:"small"})}),(0,Ys.jsx)(Dd,{children:r})]},"update")]}var nLr=k(oe(),1);var iLr=k(I(),1);function oLr({peer:e,onRestart:t,onClose:r}){let[n,o]=(0,nLr.useState)(!1);return(0,iLr.jsx)(Io,{title:`Restart ${e}?`,message:`Restarts the sessions daemon and web server on ${e}. Its sessions resume when the daemon is back. This page stays open.`,confirmLabel:"Restart",busy:n,autoFocusConfirm:!0,onConfirm:()=>{o(!0),t(e).finally(r)},onCancel:r})}function aLr(e){let t=new Map;for(let r of e){let n=t.get(r.group)??[];n.push(r),t.set(r.group,n)}return[...t].map(([r,n])=>({name:r,shortcuts:n}))}var hyo=Object.keys(j8);function sLr(){let e=Y8();return aLr(hyo.map(t=>_w(t,e)))}var rm=k(I(),1),myo={display:"flex",alignItems:"center",justifyContent:"space-between",pr:1},gyo={display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,py:.5};function lLr({onClose:e}){let t=sLr();return(0,rm.jsxs)(pc,{open:!0,onClose:e,maxWidth:"xs",fullWidth:!0,"aria-labelledby":"shortcuts-dialog-title",children:[(0,rm.jsxs)(Xu,{id:"shortcuts-dialog-title",sx:myo,children:["Keyboard shortcuts",(0,rm.jsx)(Vt,{size:"small","aria-label":"Close",onClick:e,children:(0,rm.jsx)(Lo,{fontSize:"small"})})]}),(0,rm.jsx)(Ku,{dividers:!0,children:t.map(r=>(0,rm.jsxs)(V,{component:"section",sx:{mb:1.5},children:[(0,rm.jsx)(Ee,{variant:"overline",color:"text.secondary",children:r.name}),r.shortcuts.map(n=>(0,rm.jsxs)(V,{sx:gyo,children:[(0,rm.jsx)(Ee,{variant:"body2",children:n.label}),(0,rm.jsx)(_t,{direction:"row",spacing:.5,children:(0,rm.jsx)(Oae,{chords:n.chords})})]},n.label))]},r.name))})]})}var DL=k(I(),1);function cLr({reconnecting:e,onClose:t}){let{pending:r,error:n,clearError:o,restart:i}=g5(XH.target,e);return(0,DL.jsxs)(DL.Fragment,{children:[(0,DL.jsx)(Io,{title:XH.label,message:XH.message,confirmLabel:"Restart",busy:r,autoFocusConfirm:!0,onConfirm:()=>{i()},onCancel:t}),(0,DL.jsx)(sl,{error:n,onClose:o})]})}var fLr=k(I(),1);function yyo(e){return e?{title:`Update assist on ${e}?`,message:`This runs 'assist update' on ${e} as a new session, then restarts its web server. This page stays open.`}:{title:"Update assist",message:"This starts a new session running 'assist update'. Its output will appear in the terminal."}}function uLr({peer:e,onConfirm:t,onClose:r}){return(0,fLr.jsx)(Io,{...yyo(e),confirmLabel:"Update",onConfirm:()=>{t(),r()},onCancel:r})}var Ly=k(oe(),1);async function vyo(e){try{let t=await Jt(`/api/node-doctor?link=${encodeURIComponent(e)}`);return t.ok?(await t.json()).hop:null}catch(t){return Cr(t,"node doctor"),null}}async function dLr(e,t){let r=await vyo(e);if(!r)return t;let n=r.remediation?` \u2014 ${r.remediation}`:"";return`${t}: ${r.hop} hop failed: ${r.error}${n}`}var YT=k(oe(),1);function pLr(e){let{nodes:t}=il(),[r,n]=(0,YT.useState)(null),o=(0,YT.useRef)(!1),i=r?t?.links.find(l=>l.name===r.peer):void 0;(0,YT.useEffect)(()=>{if(!(!r||!i)){if(i.state!=="connected"){o.current=!0;return}o.current&&(n(null),e(r.describe(r.peer,i.peerVersion)))}},[r,i,e]);let a=(0,YT.useCallback)((l,u)=>{o.current=!1,n({peer:l,describe:u})},[]),s=(0,YT.useCallback)(()=>n(null),[]);return{watch:a,stop:s}}var byo=9e4;function kTe(){let[e,t]=(0,Ly.useState)(null),[r,n]=(0,Ly.useState)(null),o=(0,Ly.useRef)(void 0),i=(0,Ly.useCallback)(f=>{clearTimeout(o.current),t(f)},[]),{watch:a,stop:s}=pLr(i);(0,Ly.useEffect)(()=>()=>clearTimeout(o.current),[]);let l=(0,Ly.useCallback)(async(f,d)=>{n(await dLr(f,d))},[]);return{requestThenAwait:(0,Ly.useCallback)(async(f,d,p,h)=>{let m;try{m=await p()}catch(g){Cr(g,`${d} ${f}`)}return m?.ok?(a(f,h),clearTimeout(o.current),o.current=setTimeout(()=>{s(),l(f,`${f} did not come back`)},byo),!0):(await l(f,`${d} failed (${await h5(m)})`),!1)},[l,a,s]),back:e,clearBack:()=>t(null),error:r,clearError:()=>n(null)}}var xyo=(e,t)=>t?`${e} is back (v${t})`:`${e} is back`;function hLr(){let{requestThenAwait:e,...t}=kTe();return{restart:n=>e(n,`Restart ${n}`,()=>m5("both",n),xyo),...t}}var zee=k(oe(),1);function _Te(e){return Jt(Vr("/api/self-update",e),{method:"POST",timeoutMs:66e4})}var Iy=k(oe(),1);function mLr(e){return e.commandType==="assist"&&e.assistArgs?.[0]==="update"&&e.status==="done"}function ETe(e,t,r){let[n,o]=(0,Iy.useState)(!1),[i,a]=(0,Iy.useState)(!1),s=(0,Iy.useRef)(!1),l=(0,Iy.useRef)(e);l.current=e;let u=(0,Iy.useRef)(new Set),f=(0,Iy.useCallback)(()=>{s.current=!1,a(!1),u.current=new Set(l.current.filter(mLr).map(d=>d.id)),o(!0)},[]);return(0,Iy.useEffect)(()=>{if(!n||i)return;if(t){s.current=!0;return}if(!s.current)return;e.some(p=>mLr(p)&&p.node===r&&!u.current.has(p.id))&&a(!0)},[n,i,t,e,r]),{arm:f,completed:i}}var gLr=(e,t)=>t?`${e} updated to v${t}`:`${e} updated`;function yLr(e){let{nodes:t}=il(),{launchAssist:r}=_l(),{requestThenAwait:n,...o}=kTe(),[i,a]=(0,zee.useState)(null),[s,l]=(0,zee.useState)(),u=m=>t?.links.find(g=>g.name===m)?.state,{arm:f,completed:d}=ETe(e,u(s)!=="connected",s);(0,zee.useEffect)(()=>{!d||!s||(l(void 0),n(s,`Restart ${s}'s web server`,()=>m5("webserver",s),gLr))},[d,s,n]);let p=async m=>{a(`Updating assist on ${m}\u2026`),await n(m,`Update ${m}`,()=>_Te(m),gLr),a(null)};return{update:m=>{if(u(m)!=="connected"){p(m);return}l(m),f(),r(["update"],void 0,{node:m})},progress:i,...o}}var My=k(I(),1);function vLr({dialog:e,peer:t,sessions:r,reconnecting:n,onClose:o}){let{launchAssist:i,armUpdateReload:a}=_l(),s=hLr(),l=yLr(r);return(0,My.jsxs)(My.Fragment,{children:[e==="shortcuts"&&(0,My.jsx)(lLr,{onClose:o}),e==="restart"&&t&&(0,My.jsx)(oLr,{peer:t,onRestart:s.restart,onClose:o}),e==="restart"&&!t&&(0,My.jsx)(cLr,{reconnecting:n,onClose:o}),e==="update"&&(0,My.jsx)(uLr,{peer:t,onConfirm:()=>{if(t){l.update(t);return}a(),i(["update"])},onClose:o}),(0,My.jsx)(QJ,{notices:s}),(0,My.jsx)(QJ,{notices:l})]})}var bLr=k(I(),1),xLr=nt((0,bLr.jsx)("path",{d:"M11 18h2v-2h-2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4"}),"HelpOutlineOutlined");var RTe=k(I(),1),Syo="https://staffordwilliams.com/assist";function SLr(){return(0,RTe.jsx)(rr,{title:"Help",children:(0,RTe.jsx)(Vt,{component:"a",href:Syo,target:"_blank",rel:"noopener noreferrer","aria-label":"Help",size:"small",sx:{color:"inherit"},children:(0,RTe.jsx)(xLr,{fontSize:"small"})})})}var TLr=k(I(),1),CLr=nt((0,TLr.jsx)("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.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.58c-.18.14-.23.41-.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-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");var wLr=k(oe(),1);var Hee=k(I(),1);function kLr(){let e=Kr(),t=(0,wLr.useCallback)(()=>e("/config"),[e]),{matches:r,chords:n}=to("openConfig");return Bi(r,t),(0,Hee.jsx)(rr,{describeChild:!0,title:(0,Hee.jsx)(of,{label:"Config",chords:n}),children:(0,Hee.jsx)(Vt,{size:"small",sx:{color:"inherit"},"aria-label":"Config",onClick:t,children:(0,Hee.jsx)(CLr,{fontSize:"small"})})})}var _Lr=k(I(),1),ELr=nt((0,_Lr.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");var ATe=k(oe(),1);var Uee=k(I(),1);function RLr({open:e,onOpen:t}){let r=(0,ATe.useRef)(null),{matches:n,chords:o}=to("openMenu");return Bi(n,(0,ATe.useCallback)(()=>{r.current&&t(r.current)},[t])),(0,Uee.jsx)(rr,{describeChild:!0,title:(0,Uee.jsx)(of,{label:"Menu",chords:o}),children:(0,Uee.jsx)(Vt,{ref:r,onClick:i=>t(i.currentTarget),size:"small",sx:{color:"inherit"},"aria-label":"Open menu","aria-haspopup":"true","aria-expanded":e?"true":void 0,children:(0,Uee.jsx)(ELr,{fontSize:"small"})})})}var LU=k(I(),1);function ALr({open:e,onOpen:t}){return(0,LU.jsxs)(V,{sx:{position:"fixed",top:8,right:16,zIndex:r=>r.zIndex.drawer+2,display:"flex",alignItems:"center",gap:.5,color:r=>r.tokens.color.appBar?.text??r.palette.primary.contrastText},children:[(0,LU.jsx)(SLr,{}),(0,LU.jsx)(kLr,{}),(0,LU.jsx)(RLr,{open:e,onOpen:t})]})}var NL=k(oe(),1);var LLr=k(oe(),1);var PLr=!0,Tyo=new Set(["openMenu","cycleCards"]),Cyo=Object.keys(j8).filter(e=>!Tyo.has(e));function ILr(e,t){let r=Y8();(0,LLr.useEffect)(()=>{if(!e)return;let n=o=>{Cyo.some(i=>_w(i,r).matches(o))&&t()};return globalThis.addEventListener("keydown",n,PLr),()=>globalThis.removeEventListener("keydown",n,PLr)},[e,t,r])}function MLr(){let[e,t]=(0,NL.useState)(null),[r,n]=(0,NL.useState)(!0),o=!!e,i=(0,NL.useCallback)(()=>t(null),[]),a=(0,NL.useCallback)(s=>{n(!0),t(s)},[]);return ILr(o,(0,NL.useCallback)(()=>{n(!1),t(null)},[])),{anchorEl:e,open:o,close:i,openAt:a,restoreFocus:r}}var Wee=k(oe(),1);function DLr(e){Bi(to("shortcutsSheet").matches,e)}function NLr(){let[e,t]=(0,Wee.useState)(null);DLr((0,Wee.useCallback)(()=>t("shortcuts"),[]));let r=(0,Wee.useCallback)(()=>t(null),[]);return{dialog:e,showDialog:t,closeDialog:r}}function OLr(){let{nodes:e,selected:t}=il();return e&&t&&t!==e.local?t:void 0}function BLr(e){return{restartLabel:e?`Restart ${e}`:XH.label,updateLabel:e?`Update assist on ${e}`:"Update assist"}}var KT=k(I(),1);function FLr({mode:e,toggle:t,sessions:r,reconnecting:n}){let{anchorEl:o,open:i,close:a,openAt:s,restoreFocus:l}=MLr(),{dialog:u,showDialog:f,closeDialog:d}=NLr(),p=OLr(),h=m=>()=>{a(),f(m)};return(0,KT.jsxs)(KT.Fragment,{children:[(0,KT.jsx)(ALr,{open:i,onOpen:s}),(0,KT.jsxs)(Js,{anchorEl:o,open:i,onClose:a,disableRestoreFocus:!l,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,KT.jsx)($6r,{}),rLr({mode:e,...BLr(p),onToggleColorMode:()=>{t(),a()},onShowShortcuts:h("shortcuts"),onConnectMobile:a,onRestart:h("restart"),onUpdate:h("update")})]}),(0,KT.jsx)(vLr,{dialog:u,peer:p,sessions:r,reconnecting:n,onClose:d})]})}var HLr=k(oe(),1);var zLr=k(I(),1);function $Lr({conflict:e,onConfirm:t,onCancel:r}){let{name:n,cwd:o,port:i,group:a}=e.existing,s=Da(o),l=i?` on port ${i}`:"",u=s?` in ${s}`:"",f=a?`, holding the ${a} server slot`:"";return(0,zLr.jsx)(Io,{title:a?`Replace the ${a} server?`:"Replace running server?",message:`"${n}" is already serving${l}${u}${f}. Replace it \u2014 stop the running server and start this one?`,confirmLabel:"Replace",confirmColor:"error",onConfirm:t,onCancel:r})}var PTe=k(I(),1);function ULr({socket:e,children:t}){let{serverConflict:r,clearServerConflict:n,retrySession:o,stopSession:i,startRun:a,discardSession:s}=e,l=(0,HLr.useMemo)(()=>({onStop:i,onStart:a,onDiscard:s}),[i,a,s]),u=()=>{r&&(r.runName?a(r.runName,r.cwd,!0,r.launchedFrom,r.node):r.sessionId&&o(r.sessionId,!0),n())};return(0,PTe.jsxs)(c3e.Provider,{value:l,children:[t,r&&(0,PTe.jsx)($Lr,{conflict:r,onConfirm:u,onCancel:n})]})}var WLr=new Map;function GLr(e,t){if(!Ule())return;let r=WLr.get(e);if(WLr.set(e,t),!!r)for(let[n,o]of Object.entries(t))Object.is(o,r[n])||_1(`\u0394 ${e}.${n}`)}var ITe=k(oe(),1);function VLr(e,t,r){if(!t)return null;let n=e[t];if(!n)return null;let o=r.find(i=>i.id===n);return!o||ol(o)!==t?null:n}function Fb(e,t,r){if(e)return t.find(n=>n.id===e)??r.find(n=>n.sessionId===e)}function LTe(){let{pathname:e}=ii();return e.startsWith("/backlog")||e.startsWith("/usage")}function qLr({selectedCwd:e,selectedCardId:t,sessions:r,history:n,activeByRepo:o,onSelect:i}){let a=Fb(t,r,n),s=a&&ol(a),l=!!(s&&s===e),u=VLr(o,e,r),f=(0,ITe.useRef)(t),d=LTe();(0,ITe.useEffect)(()=>{let p=f.current!==t&&!!s;f.current=t,!(d||p||l||!u)&&i(u)},[t,s,l,u,i,d])}var NTe=k(oe(),1);function jLr(e,t,r,n){return Fb(e,t,r)?.cwd||n}function YLr(e,t,r,n){let o=jLr(e,t,r,n.cwd),i=Fb(e,t,r);return{cwd:o,node:i?.cwd?i.node:n.node}}var vXe=k(oe(),1);function KLr(e,t,r){let{cwd:n,node:o,origin:i}=r,a=(0,vXe.useCallback)((l,u)=>{let f=Dp(u,t),d=See(e,l);return d?d.clones[f]:f===(l===n?o:Rd)?l:void 0},[e,t,n,o]),s=(0,vXe.useCallback)(l=>See(e,l)?.origin??(l===n?i:void 0),[e,n,i]);return{cloneOn:a,originOf:s}}var MTe=k(oe(),1);function XLr(e,t,r,n){let o=(0,MTe.useRef)(e);(0,MTe.useEffect)(()=>{if(o.current===e)return;o.current=e;let i=See(t,r)?.clones[e];i&&n(i,e)},[e,t,r,n])}var IU=k(oe(),1);function QLr(e,t,r){if(t.node!==void 0)return t.node;let n=new Set(e.flatMap(o=>Object.entries(o.clones).filter(([,i])=>i===t.cwd).map(([i])=>i)));return n.has(r)?r:n.size===0||n.has(Rd)?Rd:[...n][0]}function ZLr(e,t,r,n){let[o,i]=(0,IU.useState)({cwd:e}),a=(0,IU.useCallback)((l,u,f)=>i({cwd:l,node:u,origin:f}),[]);(0,IU.useEffect)(()=>{e&&!o.cwd&&i({cwd:e})},[e,o.cwd]);let s=QLr(t,{cwd:o.cwd,node:o.node===void 0?void 0:Dp(o.node,n)},r);return{selectedCwd:o.cwd,selectedNode:s||void 0,selectedPick:{cwd:o.cwd,node:s,origin:o.origin},setSelectedCwd:a}}var JLr=k(oe(),1);function DTe(e,t,r){let n=Fb(e,t,r);return n&&ol(n)}function eIr(e,t,r,n){let o=DTe(e,t,r),i=Fb(e,t,r),a=i?.node??Rd,s=i?.repoGroup?.origin;(0,JLr.useEffect)(()=>{o&&n(o,a,s)},[o,a,s,n])}function tIr(e,t,r,n,o){let i=o.nodes?.local,a=Dp(o.selected,i),s=(0,NTe.useMemo)(()=>w5(e,t),[e,t]),{selectedCwd:l,selectedNode:u,selectedPick:f,setSelectedCwd:d}=ZLr(e,s,a,i);eIr(r,n,t,d),XLr(a,s,l,d);let{cloneOn:p,originOf:h}=KLr(s,i,f),m=(0,NTe.useMemo)(()=>s.map(v=>c3r(v,a)),[s,a]),{cwd:g,node:y}=YLr(r,n,t,{cwd:l,node:u});return(0,NTe.useMemo)(()=>({repos:m,selectedCwd:l,selectedNode:u,worktreeCwd:g,worktreeNode:y,setSelectedCwd:d,cloneOn:p,originOf:h}),[m,l,u,g,y,d,p,h])}var BTe=k(oe(),1);var z5=k(oe(),1);var rIr=k(oe(),1),OTe="assist:reloaded-after-update";function nIr(e){(0,rIr.useEffect)(()=>{globalThis.sessionStorage?.getItem(OTe)&&(globalThis.sessionStorage.removeItem(OTe),e({message:"Reloaded after updating assist",sessionId:null}))},[e])}function oIr(e,t,r,n){let{arm:o,completed:i}=ETe(e,t),a=(0,z5.useRef)(!1),s=(0,z5.useCallback)(()=>{globalThis.sessionStorage?.setItem(OTe,"1")},[]),{error:l,restart:u}=g5("webserver",t,s);return nIr(r),(0,z5.useEffect)(()=>{l&&n(l)},[l,n]),(0,z5.useEffect)(()=>{!i||a.current||(a.current=!0,u())},[i,u]),{armUpdateReload:(0,z5.useCallback)(()=>{a.current=!1,o()},[o])}}function iIr(e){let{armUpdateReload:t}=oIr(e.sessions,e.reconnecting,e.setSuccess,e.setError),r=v1(e.selectSession),n=(0,BTe.useMemo)(()=>({launchAssist:e.createAssistSession,launchAgentInStream:e.createSessionInStream,resumeSession:e.resumeSession,armUpdateReload:t,activateSession:r,sendInput:e.sendInput}),[e.createAssistSession,e.createSessionInStream,e.resumeSession,t,r,e.sendInput]),o=Kr(),i=(0,BTe.useCallback)(a=>{e.selectSession(a),o("/sessions"),e.clearSuccess()},[o,e.selectSession,e.clearSuccess]);return{launch:n,viewLaunchedSession:i}}var aIr=k(oe(),1);function sIr(e,t,r,n){let o=DTe(e,t,r);(0,aIr.useEffect)(()=>{e&&o&&n({type:"set-active",cwd:o,sessionId:e})},[e,o,n])}var FTe=k(oe(),1);function lIr(e,t){let r=(0,FTe.useRef)(new Map);(0,FTe.useEffect)(()=>{let n=new Set;for(let{id:o,status:i}of e)n.add(o),r.current.get(o)!==i&&(r.current.set(o,i),console.debug(`[sessions] render session ${o} status=${i}`),t({type:"ui-status",sessionId:o,status:i}));for(let o of r.current.keys())n.has(o)||r.current.delete(o)},[e,t])}var MU=k(oe(),1),cIr="assist.sessions.node";function wyo(){try{return localStorage.getItem(cIr)}catch{return null}}function kyo(e){try{localStorage.setItem(cIr,e)}catch{}}function uIr(e){let[t,r]=(0,MU.useState)(wyo),n=(0,MU.useCallback)(o=>{r(o),kyo(o)},[]);return(0,MU.useMemo)(()=>{let o=e?[e.local,...e.links.map(i=>i.name)]:[];return{nodes:e,names:o,visible:o.length>1,selected:t&&o.includes(t)?t:e?.local,select:n}},[e,t,n])}var dIr=k(oe(),1);function fIr(e){let t=e;if(t.type==="create")return{cwd:t.cwd,title:t.prompt?.trim()||(t.design?"New design session":"New session"),node:t.node};if(t.type==="create-assist"){let r=t.title?.trim();return{cwd:t.cwd,title:r||"New session",named:!!r,node:t.node}}return null}function pIr(e,t){return(0,dIr.useCallback)(r=>{let n=e.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify(r));let o=fIr(r);o&&t(o)},[e,t])}var $b=k(oe(),1);function $Te(e,t,r,n,o){e({type:"create",prompt:r||void 0,cwd:n,...t,...o?{node:o}:{}})}function hIr(e){return(t,r,n)=>$Te(e,{design:!0},t,r,n)}function mIr(e){return(t,r,n,o)=>$Te(e,{harness:t},r,n,o)}function gIr(e){return(t,r,n)=>$Te(e,{auto:!0},t,r,n)}function yIr(e){return(t,r,n)=>e({type:"create-assist",assistArgs:t,cwd:r,...n})}function vIr(e){return(t,r,n,o,i)=>e({type:"resume",sessionId:t,cwd:r,name:n,harness:o,node:i})}function bIr(e,t){return(r,n)=>{t.delete(r),e({type:"retry",sessionId:r,replace:n})}}function xIr(e,t){return r=>{t.delete(r),e({type:"restart",sessionId:r})}}function SIr(e,t){return r=>{e({type:"dismiss",sessionId:r}),t.delete(r)}}function TIr(e,t){return r=>{e({type:"discard",sessionId:r}),t.delete(r)}}function CIr(e){return t=>e({type:"stop",sessionId:t})}function wIr(e){return(t,r,n,o,i)=>e({type:"create-run",runName:t,cwd:r,replace:n,launchedFrom:o,node:i})}function kIr(e){return(t,r)=>e({type:"set-autoapprove",sessionId:t,enabled:r})}function _Ir(e){return(t,r)=>e({type:"set-autoadvance",sessionId:t,enabled:r})}function EIr(e){return(t,r)=>e({type:"set-starred",sessionId:t,starred:r})}function RIr(e){return(t,r)=>e({type:"input",sessionId:t,data:r,viewerId:iL})}function AIr(e){return(t,r,n,o)=>e({type:"resize",sessionId:t,cols:r,rows:n,viewerId:iL,claim:o==="claim",refresh:o==="refresh"})}function PIr(e){return(t,r,n,o)=>e({type:"pr-decision",sessionId:t,requestId:r,decision:n,...o})}var OL=k(oe(),1);function LIr(e){return(t,r,n)=>e({type:"create",prompt:r||void 0,cwd:n,joinSessionId:t,auto:!0})}function IIr(e){return{createSession:(0,OL.useMemo)(()=>gIr(e),[e]),createSessionInStream:(0,OL.useMemo)(()=>LIr(e),[e]),createDesignSession:(0,OL.useMemo)(()=>hIr(e),[e]),createHarnessSession:(0,OL.useMemo)(()=>mIr(e),[e]),createAssistSession:(0,OL.useMemo)(()=>yIr(e),[e]),resumeSession:(0,OL.useMemo)(()=>vIr(e),[e])}}var Gee=k(oe(),1);function MIr(e,t){let r=(0,Gee.useCallback)((a,s)=>{bIr(e,t.current)(a,s)},[e,t]),n=(0,Gee.useCallback)(a=>{xIr(e,t.current)(a)},[e,t]),o=(0,Gee.useCallback)(a=>{SIr(e,t.current)(a)},[e,t]),i=(0,Gee.useCallback)(a=>{TIr(e,t.current)(a)},[e,t]);return{retrySession:r,restartSession:n,dismissSession:o,discardSession:i}}function DIr(e,t,r){return(n,o)=>{let i=t.get(n);return i&&(o(i),e({type:"snapshot",sessionId:n})),r.set(n,o),()=>r.delete(n)}}function NIr(e,t,r){let n={...IIr(e),sendInput:(0,$b.useMemo)(()=>RIr(e),[e]),sendResize:(0,$b.useMemo)(()=>AIr(e),[e]),sendPrDecision:(0,$b.useMemo)(()=>PIr(e),[e]),setAutoApprove:(0,$b.useMemo)(()=>kIr(e),[e]),setAutoAdvance:(0,$b.useMemo)(()=>_Ir(e),[e]),setStarred:(0,$b.useMemo)(()=>EIr(e),[e]),stopSession:(0,$b.useMemo)(()=>CIr(e),[e]),startRun:(0,$b.useMemo)(()=>wIr(e),[e])},o=(0,$b.useMemo)(()=>DIr(e,t.current,r.current),[e,t,r]);return{...n,...MIr(e,t),onOutput:o}}var Vee=k(oe(),1);function OIr(e,t,r){let n=(0,Vee.useCallback)(s=>{r(s),e({type:"fetch-transcript",sessionId:s})},[e,r]),o=(0,Vee.useCallback)(s=>e({type:"fetch-user-messages",sessionId:s}),[e]),i=(0,Vee.useCallback)(()=>{r(null)},[r]),a=(0,Vee.useCallback)(s=>{r(null),t(s)},[t,r]);return{viewTranscript:n,fetchUserMessages:o,clearTranscript:i,selectSession:a}}var WTe=k(oe(),1);function BIr(e,t){let r=new Set(t.map(o=>o.id)),n=null;for(let o of Object.values(e))r.has(o)&&(n=o);return n}var DU=k(oe(),1);function FIr(){let[e,t]=(0,DU.useState)(null),r=(0,DU.useRef)(e);r.current=e;let n=(0,DU.useCallback)(()=>r.current,[]);return{activeId:e,setActiveId:t,getActiveId:n}}var zIr=k(oe(),1);function $Ir(e,t,r=null){return t!==null?e.some(n=>n.id===t)?t:e[0]?.id??null:r&&e.some(n=>n.id===r)?r:e[0]?.id??null}function HIr(e,t,r){let n=LTe();(0,zIr.useEffect)(()=>{if(n){t(null);return}t(o=>$Ir(e,o,r))},[e,t,r,n])}var zTe=k(oe(),1);function UIr(){let[e,t]=(0,zTe.useState)({}),[r,n]=(0,zTe.useState)(null),[o,i]=(0,zTe.useState)(null);return{activeByRepo:e,setActiveByRepo:t,daemonVersion:r,setDaemonVersion:n,nodes:o,setNodes:i}}var Dy=k(oe(),1);function WIr(e,t){for(let r of t)clearTimeout(e.get(r)),e.delete(r)}function GIr(e,t){let r=new Set(t.map(n=>n.id));return[...e.keys()].filter(n=>!r.has(n))}function VIr(e,t){if(!t.some(n=>e.has(n)))return e;let r=new Set(e);for(let n of t)r.delete(n);return r}function qIr(e,t){let r=[];for(let n of t){let o=e.get(n.id);o!==void 0&&o!==n.startedAt&&r.push(n.id)}return r}function jIr(e,t){return t.filter(r=>r.commandType==="run"&&e.get(r.id)!==r.startedAt).map(r=>r.id)}var _yo=1500;function YIr(){let[e,t]=(0,Dy.useState)(new Set),r=(0,Dy.useRef)(new Map),n=(0,Dy.useRef)(new Map),o=(0,Dy.useCallback)(s=>{t(l=>l.has(s)?l:new Set(l).add(s))},[]),i=(0,Dy.useCallback)(s=>{let l=n.current;for(let u of s)clearTimeout(l.get(u)),l.set(u,setTimeout(()=>{l.delete(u),o(u)},_yo))},[o]);(0,Dy.useEffect)(()=>{let s=n.current;return()=>{for(let l of s.values())clearTimeout(l)}},[]);let a=(0,Dy.useCallback)(s=>{let l=GIr(r.current,s),u=[...qIr(r.current,s),...l],f=jIr(r.current,s);r.current=new Map(s.map(d=>[d.id,d.startedAt])),WIr(n.current,l),u.length&&t(d=>VIr(d,u)),i(f)},[i]);return{initialized:e,markInitialized:o,syncSessions:a}}var H5=k(oe(),1);function KIr(){let[e,t]=(0,H5.useState)(null),[r,n]=(0,H5.useState)(null),[o,i]=(0,H5.useState)(null),a=(0,H5.useCallback)(()=>t(null),[]),s=(0,H5.useCallback)(()=>n(null),[]),l=(0,H5.useCallback)(()=>i(null),[]);return{error:e,setError:t,clearError:a,success:r,setSuccess:n,clearSuccess:s,serverConflict:o,setServerConflict:i,clearServerConflict:l}}var zb=k(oe(),1);function XIr(e,t){return[...e,{...t,status:"launching"}]}function HTe(e){return e.find(t=>t.status==="launching")}function QIr(e){let t=HTe(e);return t?e.filter(r=>r.id!==t.id):e}function ZIr(e,t){let r=HTe(e);return r?bXe(e,r.id,t):e}function bXe(e,t,r){return e.map(n=>n.id===t&&n.status==="launching"?{...n,status:"error",error:r}:n)}function JIr(e,t){return e.filter(r=>r.id!==t)}var e7r=k(oe(),1);var Eyo=6e4,Ryo="Launch timed out \u2014 the session did not start.";function t7r(e,t){(0,e7r.useEffect)(()=>{let r=e.filter(o=>o.status==="launching");if(r.length===0)return;let n=r.map(o=>setTimeout(()=>t(i=>bXe(i,o.id,Ryo)),Math.max(0,Eyo-(Date.now()-o.startedAt))));return()=>n.forEach(clearTimeout)},[e,t])}function r7r(){let[e,t]=(0,zb.useState)([]),r=(0,zb.useRef)([]),n=(0,zb.useCallback)(l=>{r.current=l(r.current),t(r.current)},[]),o=(0,zb.useCallback)(l=>{n(u=>XIr(u,{id:crypto.randomUUID(),startedAt:Date.now(),...l}))},[n]),i=(0,zb.useCallback)(()=>{let l=HTe(r.current);return n(QIr),l?.named?l.title:void 0},[n]),a=(0,zb.useCallback)(l=>n(u=>ZIr(u,l)),[n]),s=(0,zb.useCallback)(l=>n(u=>JIr(u,l)),[n]);return t7r(e,n),{pendingLaunches:e,addPendingLaunch:o,resolvePendingLaunch:i,failPendingLaunch:a,dismissPendingLaunch:s}}var qee=k(oe(),1);function n7r(){let[e,t]=(0,qee.useState)(null),[r,n]=(0,qee.useState)({}),o=(0,qee.useCallback)((i,a)=>{i!=="claude"&&n(s=>({...s,[i]:a}))},[]);return{rateLimits:e,setRateLimits:t,harnessRateLimits:r,setHarnessRateLimits:o}}var o7r=k(oe(),1);function i7r(e,t){return(0,o7r.useCallback)(r=>{e(r),t(r)},[e,t])}var xXe=k(oe(),1);function a7r(){let e=(0,xXe.useRef)(new Map),t=(0,xXe.useRef)(new Map);return{buffers:e,handlers:t}}var UTe=k(oe(),1);function s7r(){let[e,t]=(0,UTe.useState)(null),[r,n]=(0,UTe.useState)(null),[o,i]=(0,UTe.useState)(null);return{transcript:e,setTranscript:t,viewingTranscriptSessionId:r,setViewingTranscriptSessionId:n,userMessages:o,setUserMessages:i}}var U5=k(oe(),1);function l7r(e,t){let r=e.sessionId;t.buffers.current?.delete(r),t.handlers.current?.get(r)?.("\x1Bc")}function c7r(e,t){let r=e.sessionId,n=t.resolvePendingLaunch();e.isNew&&t.getActiveId()!==null||(t.setViewingTranscriptSessionId(null),t.setActiveId(r)),e.isNew&&t.setSuccess({message:n?`Started ${n}`:"New session started",sessionId:r})}function u7r(e,t){let r=e.message;t.setError(r),t.failPendingLaunch(r)}function f7r(e,t){let r=e.rateLimits,n=e.harness;!n||n==="claude"?t.setRateLimits(r):t.setHarnessRateLimits?.(n,r)}function d7r(e,t){t.setNodes({local:e.local,links:e.links??[]})}function p7r(e,t){t.setSuccess({message:e.message,sessionId:null})}function h7r(e,t){let r=e.sessionId,n=t.buffers.current?.get(r)??"";t.buffers.current?.set(r,n+e.data),t.handlers.current?.get(r)?.(e.data),t.markInitialized(r)}function m7r(e,t){t.setServerConflict({existing:e.existing,runName:e.runName,cwd:e.cwd,sessionId:e.sessionId,launchedFrom:e.launchedFrom,node:e.node})}function g7r(e,t){let r=e.sessions;t.setSessions(r),e.cwd&&t.setCurrentCwd(e.cwd),t.setActiveByRepo(e.active??{})}function y7r(e,t){let r=e.sessionId,n=e.data;t.buffers.current?.set(r,n),t.handlers.current?.get(r)?.(`\x1Bc${n}`)}var Ayo={sessions:g7r,created:c7r,history:(e,t)=>t.setHistory(e.sessions),transcript:(e,t)=>t.setTranscript({sessionId:e.sessionId,messages:e.messages}),"user-messages":(e,t)=>t.setUserMessages({sessionId:e.sessionId,messages:e.messages}),hello:(e,t)=>t.setDaemonVersion(e.version),nodes:d7r,error:u7r,notice:p7r,inbox:()=>{Es.refresh(),Es.refreshStatus()},"inbox-activity":()=>{Es.refreshStatus()},"run-conflict":m7r,limits:f7r,clear:l7r,output:h7r,snapshot:y7r};function v7r(e,t){Ayo[e.type]?.(e,t)}function b7r(e,t={}){let r=new WebSocket(Mft("/ws"));return r.onopen=()=>{t.onOpen?.(),r.send(JSON.stringify({type:"hello"})),r.send(JSON.stringify({type:"history"}))},r.onmessage=n=>{v7r(JSON.parse(n.data),e)},r.onclose=()=>t.onClose?.(),r}function x7r(e,t,r,n){let o=!1,i,a=0,s=!1,l=()=>{o||t(b7r(e,{onOpen:()=>{s&&r(),s=!1,n(!1),a=0},onClose:()=>{if(o)return;s=!0,n(!0);let u=Math.min(300*2**a,2e3);a+=1,i=setTimeout(l,u)}}))};return l(),()=>{o=!0,i&&clearTimeout(i)}}function S7r(e){let t=(0,U5.useRef)(null),[r,n]=(0,U5.useState)(!1),{handleSessions:o,markInitialized:i,buffers:a,handlers:s}=e;(0,U5.useEffect)(()=>{let u=()=>{a.current?.clear();let d=s.current;if(d)for(let p of d.values())p("\x1Bc")},f=x7r({...e,setSessions:o},d=>{t.current=d},u,n);return()=>{f(),t.current?.close()}},[o,i,a,s]);let l=(0,U5.useCallback)(()=>{let u=t.current;u?.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"history"}))},[]);return{wsRef:t,requestHistory:l,reconnecting:r}}function T7r(){let[e,t]=(0,WTe.useState)([]),[r,n]=(0,WTe.useState)([]),{activeId:o,setActiveId:i,getActiveId:a}=FIr(),s=UIr(),l=s7r(),[u,f]=(0,WTe.useState)(""),d=KIr(),p=r7r(),h=n7r(),{initialized:m,markInitialized:g,syncSessions:y}=YIr(),v=a7r(),b=i7r(y,t),{wsRef:x,requestHistory:T,reconnecting:C}=S7r({handleSessions:b,setHistory:n,getActiveId:a,setActiveId:i,...s,...l,setCurrentCwd:f,...d,...p,...h,markInitialized:g,...v});return HIr(e,i,BIr(s.activeByRepo,e)),{sessions:e,history:r,activeId:o,setActiveId:i,...s,...l,currentCwd:u,...d,...p,...h,initialized:m,wsRef:x,...v,requestHistory:T,reconnecting:C}}function GTe(){let e=T7r(),{wsRef:t,buffers:r,handlers:n,addPendingLaunch:o,activeId:i,sessions:a}=e,s=uIr(e.nodes),l=pIr(t,o),u=NIr(l,r,n);sIr(i,a,e.history,l),lIr(a,l);let f=OIr(l,e.setActiveId,e.setViewingTranscriptSessionId);return{...e,...u,...f,nodeSelection:s}}var NU=k(oe(),1);var C7r="assist:sidebar-collapsed";function w7r(){let[e,t]=(0,NU.useState)(()=>Tf(C7r).length>0),r=(0,NU.useCallback)(()=>{t(n=>{let o=!n;return Cf(C7r,o?[!0]:[]),o})},[]);return(0,NU.useMemo)(()=>({collapsed:e,onToggleCollapsed:r}),[e,r])}var k7r=k(oe(),1);function _7r(){(0,k7r.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await Jt("/api/hotkeys");if(!t.ok)return;let r=await t.json();e||D3.set(r)}catch(t){Cr(t,"hotkey bindings")}})(),()=>{e=!0}},[])}function E7r(){let e=GTe(),t=yve(e),r=tIr(e.currentCwd,e.history,t,e.sessions,e.nodeSelection);qLr({selectedCwd:r.selectedCwd,selectedCardId:t,sessions:e.sessions,history:e.history,activeByRepo:e.activeByRepo,onSelect:e.selectSession});let{launch:n,viewLaunchedSession:o}=iIr(e);_7r();let i=w7r();return GLr("shell",{...e,selection:r,launch:n,sidebarCollapse:i}),{socket:e,selection:r,launch:n,viewLaunchedSession:o,sidebarCollapse:i}}var jg=k(I(),1),Pyo={zIndex:e=>e.zIndex.drawer+1},Lyo={minHeight:48};function R7r({mode:e,toggle:t}){let r=E7r(),{socket:n,selection:o,viewLaunchedSession:i}=r;return(0,jg.jsx)(ZPr,{shell:r,children:(0,jg.jsxs)(oXe.Provider,{value:n.daemonVersion,children:[(0,jg.jsx)(FLr,{mode:e,toggle:t,sessions:n.sessions,reconnecting:n.reconnecting}),(0,jg.jsx)(eke,{position:"fixed",sx:Pyo,"data-testid":"toolbar",children:(0,jg.jsx)(B6r,{socket:n,selection:o})}),(0,jg.jsx)(n3,{variant:"dense",sx:Lyo}),(0,jg.jsx)(ULr,{socket:n,children:(0,jg.jsx)(HRr,{socket:n})}),(0,jg.jsx)(IAr,{socket:n}),(0,jg.jsx)(QPr,{socket:n,onViewLaunchedSession:i})]})})}function L7r(e){return e instanceof Error?e.message:String(e)}function Iyo(e){return e.filename?` (${e.filename}:${e.lineno}:${e.colno})`:""}function A7r(e){rq(e.error)||(P3(e.error),nq("error",`${e.message||L7r(e.error)}${Iyo(e)}`))}function P7r(e){rq(e.reason)||(P3(e.reason),nq("rejection",L7r(e.reason)))}function I7r(){return globalThis.addEventListener("error",A7r),globalThis.addEventListener("unhandledrejection",P7r),()=>{globalThis.removeEventListener("error",A7r),globalThis.removeEventListener("unhandledrejection",P7r)}}var M7r=k(oe(),1);function D7r(){let[e,t]=(0,M7r.useState)(()=>{try{return localStorage.getItem("theme-mode")??"dark"}catch{return"dark"}});return{mode:e,toggle:()=>t(n=>{let o=n==="dark"?"light":"dark";try{localStorage.setItem("theme-mode",o)}catch{}return o})}}function N7r({color:e,radius:t}){return{MuiMenu:{styleOverrides:{paper:{borderRadius:t.md},list:{padding:4}}},MuiMenuItem:{styleOverrides:{root:{minHeight:30,padding:"5px 10px",borderRadius:4,fontSize:13,"&:hover":{backgroundColor:e.raised},"& .MuiListItemIcon-root":{minWidth:28},"& .MuiSvgIcon-root":{fontSize:16},"& .MuiListItemText-primary":{fontSize:13}}}}}}function O7r(e){let{color:t,radius:r,elevation:n,type:o}=e,i={border:`1px solid ${t.line}`};return{...N7r(e),MuiTooltip:{styleOverrides:{tooltip:{...i,backgroundColor:t.overlay.background,color:t.overlay.text,borderRadius:r.md,boxShadow:n.overlay,fontSize:`${o.scale.caption/16}rem`,padding:"6px 10px"},arrow:{color:t.overlay.background}}},MuiPopover:{styleOverrides:{paper:{...i,boxShadow:n.overlay}}},MuiBackdrop:{styleOverrides:{root:{"&:not(.MuiBackdrop-invisible)":{backgroundColor:t.scrim,backdropFilter:"blur(2px)"}}}},MuiDialog:{styleOverrides:{paper:{...i,backgroundColor:t.surface,borderRadius:r.md+4,boxShadow:n.dialog}}}}}var B7r=({variant:e})=>e==="outlined"||e==="tonal",F7r=[{props:{size:"small"},style:{minHeight:26,padding:"4px 9px",fontSize:12}},{props:B7r,style:{padding:"5px 11px"}},{props:e=>B7r(e)&&e.size==="small",style:{padding:"3px 8px"}}];var VTe=["primary","secondary","success","warning","error","info"];function jee(e,t){return{backgroundColor:Dr(e,t),borderColor:Dr(e,.35),color:e}}function $7r({color:e}){return[{props:{variant:"tonal"},style:{backgroundColor:e.raised,border:`1px solid ${e.line}`,color:e.text.primary,"&:hover":{backgroundColor:e.raised,borderColor:e.text.disabled}}},...VTe.filter(t=>t!=="primary").map(t=>({props:{variant:"tonal",color:t},style:{...jee(e[t].main,.16),"&:hover":jee(e[t].main,.24)}}))]}var z7r={"& > *:nth-of-type(1)":{fontSize:16}};function H7r(e){let{color:t,radius:r,density:n}=e,{minHeight:o,fontSize:i,paddingX:a}=n.button;return{MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:o,padding:`6px ${a}px`,borderRadius:r.sm,fontSize:i,fontWeight:600,lineHeight:"18px"},startIcon:{marginLeft:-2,marginRight:6,...z7r},endIcon:{marginLeft:6,marginRight:-2,...z7r}},variants:[...F7r,{props:{variant:"text",color:"primary"},style:{color:t.text.secondary,"&:hover":{backgroundColor:t.raised,color:t.text.primary}}},...$7r(e),{props:{variant:"outlined",color:"error"},style:{borderColor:Dr(t.error.main,.35),"&:hover":{borderColor:t.error.main,backgroundColor:Dr(t.error.main,.1)}}}]}}}function SXe({color:e},t){return[{props:{variant:t,color:"default"},style:{backgroundColor:"transparent",border:`1px solid ${e.line}`,color:e.text.secondary,"&.MuiChip-clickable:hover":{backgroundColor:e.raised}}},...VTe.map(r=>({props:{variant:t,color:r},style:{...jee(e[r].main,.14),borderColor:"transparent","& .MuiChip-deleteIcon":{color:Dr(e[r].main,.7),"&:hover, &:active":{color:e[r].main}},"&.MuiChip-clickable:hover":{backgroundColor:Dr(e[r].main,.22)}}}))]}function U7r(e){return{MuiChip:{styleOverrides:{root:{height:20,fontSize:11,fontWeight:600,borderRadius:999},sizeSmall:{height:20,"& .MuiChip-label":{padding:"0 7px"}},label:{padding:"0 8px"},icon:{fontSize:14,marginLeft:6,marginRight:-2},deleteIcon:{fontSize:14,marginLeft:-2,marginRight:4},outlined:{borderColor:e.color.line}},variants:[...SXe(e,"tonal"),...SXe(e,"filled")]}}}function W7r(e){return{...H7r(e),MuiButtonGroup:{defaultProps:{disableElevation:!0},variants:[{props:{variant:"tonal"},style:{"& .MuiButtonGroup-middleButton, & .MuiButtonGroup-lastButton":{marginLeft:-1}}}]},...U7r(e)}}var TXe=e=>`color-mix(in srgb, currentColor ${e}%, transparent)`,Myo={".MuiAppBar-root &":{color:"inherit","&:hover":{backgroundColor:TXe(8)},"&.Mui-selected":{color:"inherit",backgroundColor:TXe(12),boxShadow:`inset 0 0 0 1px ${TXe(18)}`}}};function G7r({color:e,radius:t}){return{MuiTabs:{styleOverrides:{root:{minHeight:40,alignItems:"center"},list:{gap:2},indicator:{display:"none"}}},MuiTab:{styleOverrides:{root:{minHeight:30,padding:"6px 10px",borderRadius:t.sm,textTransform:"none",fontSize:13,fontWeight:500,opacity:1,color:e.text.secondary,"&:hover":{backgroundColor:e.raised,color:e.text.primary},"&.Mui-selected":{color:e.text.primary,backgroundColor:e.raised,boxShadow:`inset 0 0 0 1px ${e.line}`},...!e.appBar&&Myo}}}}}var V7r=(e,t)=>({width:e,height:e,"& .MuiSvgIcon-root":{fontSize:t}});function q7r({color:e,radius:t,density:r}){let{side:n,icon:o,smallSide:i,smallIcon:a}=r.iconButton;return{MuiIconButton:{styleOverrides:{root:{...V7r(n,o),padding:0,borderRadius:t.sm,"&:hover":{backgroundColor:e.raised}}},variants:[{props:{size:"small"},style:V7r(i,a)},{props:{color:"default"},style:{color:e.text.secondary,"&:hover":{color:e.text.primary},...!e.appBar&&{".MuiAppBar-root &, .MuiAppBar-root &:hover":{color:"inherit"}}}}]}}}function j7r({color:e,radius:t}){return{MuiToggleButtonGroup:{styleOverrides:{root:{padding:2,gap:2,border:`1px solid ${e.line}`,borderRadius:t.sm,backgroundColor:e.background},grouped:{margin:0,border:0,borderRadius:4}}},MuiToggleButton:{styleOverrides:{root:{padding:"3px 8px",border:0,borderRadius:4,fontSize:13,fontWeight:500,lineHeight:"18px",textTransform:"none",color:e.text.secondary,"& .MuiSvgIcon-root":{fontSize:16},"&:hover":{backgroundColor:"transparent",color:e.text.primary},"&.Mui-selected, &.Mui-selected:hover":{backgroundColor:e.raised,color:e.text.primary}}}}}}var qTe=".MuiOutlinedInput-notchedOutline";function Y7r({color:e,radius:t,density:r}){let n=r.inputFontSize;return{MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:e.background,borderRadius:t.sm,fontSize:n,color:e.text.primary,[`& ${qTe}`]:{borderColor:e.line},[`&:hover ${qTe}`]:{borderColor:e.text.disabled},[`&.Mui-focused ${qTe}`]:{borderColor:e.primary.main,borderWidth:1},[`&.Mui-error ${qTe}`]:{borderColor:e.error.main}}}},MuiInputLabel:{styleOverrides:{root:{fontSize:n,color:e.text.secondary,"&.Mui-focused":{color:e.primary.main}}}},MuiSelect:{styleOverrides:{icon:{color:e.text.disabled}}}}}function K7r({color:e,density:t}){let{width:r,height:n,thumb:o}=t.switch;return{MuiSwitch:{styleOverrides:{root:{width:r,height:n,padding:0,"& .MuiSwitch-switchBase":{padding:2,color:e.text.secondary,"&.Mui-checked":{transform:`translateX(${r-n}px)`,color:e.primary.contrastText},"&.Mui-checked + .MuiSwitch-track":{backgroundColor:e.primary.main,opacity:1}},"& .MuiSwitch-thumb":{width:o,height:o,boxShadow:"none"},"& .MuiSwitch-track":{borderRadius:n/2,backgroundColor:e.line,opacity:1}}}},MuiFormControlLabel:{styleOverrides:{root:{"&:has(.MuiSwitch-root)":{marginLeft:0,gap:8}}}}}}function X7r(e){let{appBar:t}=e.color;return{...O7r(e),...W7r(e),...q7r(e),...j7r(e),...Y7r(e),...K7r(e),...G7r(e),MuiPaper:{styleOverrides:{root:{backgroundImage:"none"},outlined:{borderColor:e.color.line}}},MuiAppBar:{defaultProps:{elevation:e.elevation.appBar},styleOverrides:{root:t&&{backgroundColor:t.background,color:t.text,borderBottom:`1px solid ${e.color.line}`}}}}}var Hb="#0e1116",CXe="#141820",jTe="#1b202a",YTe="#e3e7ee",wXe="#8a93a3",Yee="#8b9cff",KTe="#5fd0a0",XTe="#f2b45a",QTe="#f27a7a",Q7r={secondary:"rgba(255, 255, 255, 0.7)",hover:"rgba(255, 255, 255, 0.12)",active:"rgba(255, 255, 255, 0.16)",dot:"#ffb74d",dotRing:"rgba(0, 0, 0, 0.15)"},ZTe={dark:{color:{background:Hb,surface:CXe,raised:jTe,line:"#262c37",lineSoft:"#1d222b",text:{primary:YTe,secondary:wXe,disabled:"#5c6473"},selected:"rgba(139, 156, 255, 0.14)",wash:{warning:"rgba(242, 180, 90, 0.09)",error:"rgba(242, 122, 122, 0.09)"},well:Hb,stripe:jTe,codeWash:"rgba(255, 255, 255, 0.08)",overlay:{background:jTe,text:YTe},scrim:"rgba(0, 0, 0, 0.5)",appBar:{background:CXe,text:YTe},onAppBar:{...Q7r,secondary:wXe,level:{ok:KTe,warn:XTe,over:QTe}},statusBar:{background:CXe,text:wXe,hoverText:YTe,secondary:"#5c6473",hover:jTe,active:"transparent",dot:Yee,dotRing:"rgba(139, 156, 255, 0.14)",readyText:Yee,level:{ok:KTe,warn:XTe,over:QTe}},primary:{main:Yee,contrastText:Hb},secondary:{main:"#c99bff",contrastText:Hb},success:{main:KTe,contrastText:Hb},warning:{main:XTe,contrastText:Hb},error:{main:QTe,contrastText:Hb},info:{main:"#6cb6ff",contrastText:Hb}},terminal:{background:Hb,foreground:"#d6dbe4",cursor:Yee,cursorAccent:Hb,selectionBackground:"rgba(139, 156, 255, 0.28)",black:"#1b2029",red:QTe,green:KTe,yellow:XTe,blue:Yee,magenta:"#c99bff",cyan:"#6cc8d8",white:"#c3c9d4",brightBlack:"#5c6473",brightRed:"#ff9a9a",brightGreen:"#82e0b6",brightYellow:"#ffc97a",brightBlue:"#a9b6ff",brightMagenta:"#dcb8ff",brightCyan:"#8fdbe8",brightWhite:"#eef1f6"},elevation:{appBar:0,overlay:"0 14px 34px rgba(0, 0, 0, 0.45)",dialog:"0 30px 60px rgba(0, 0, 0, 0.5)",stuckHeader:"0 8px 8px -9px rgba(0, 0, 0, 0.8)"}},light:{color:{background:"#fff",surface:"#fff",raised:"rgba(0, 0, 0, 0.04)",line:"rgba(0, 0, 0, 0.12)",lineSoft:"rgba(0, 0, 0, 0.12)",text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},selected:"rgba(0, 0, 0, 0.08)",wash:{warning:"rgba(255, 167, 38, 0.09)",error:"rgba(244, 67, 54, 0.09)"},well:"#f3f4f6",stripe:"rgba(0, 0, 0, 0.1)",codeWash:"rgba(0, 0, 0, 0.06)",overlay:{background:"rgba(97, 97, 97, 0.92)",text:"#fff"},onAppBar:{...Q7r,level:{ok:"#b9f6ca",warn:"#ffe57f",over:"#ffcdd2"}},primary:{main:"#1976d2",light:"#42a5f5",dark:"#1565c0",contrastText:"#fff"},secondary:{main:"#9c27b0",light:"#ba68c8",dark:"#7b1fa2",contrastText:"#fff"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20",contrastText:"#fff"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100",contrastText:"#fff"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828",contrastText:"#fff"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b",contrastText:"#fff"},scrim:"rgba(15, 23, 42, 0.32)",statusBar:{background:"#f3f4f6",text:"rgba(0, 0, 0, 0.6)",hoverText:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.38)",hover:"rgba(0, 0, 0, 0.06)",active:"transparent",dot:"#1976d2",dotRing:"rgba(25, 118, 210, 0.16)",readyText:"#1976d2",level:{ok:"#2e7d32",warn:"#ed6c02",over:"#d32f2f"}}},terminal:{background:"#ffffff",foreground:"#333333",cursor:"#333333",cursorAccent:"#ffffff",selectionBackground:"#add6ff",black:"#000000",red:"#cd3131",green:"#107c10",yellow:"#949800",blue:"#0451a5",magenta:"#bc05bc",cyan:"#0598bc",white:"#555555",brightBlack:"#666666",brightRed:"#cd3131",brightGreen:"#14ce14",brightYellow:"#b5ba00",brightBlue:"#0451a5",brightMagenta:"#bc05bc",brightCyan:"#0598bc",brightWhite:"#a5a5a5"},elevation:{appBar:0,overlay:"0 8px 24px rgba(15, 23, 42, 0.12)",dialog:"0 24px 48px rgba(15, 23, 42, 0.18)",stuckHeader:"0 6px 6px -7px rgba(0, 0, 0, 0.2)"}},font:{ui:'"Geist Variable", "Segoe UI", system-ui, sans-serif',mono:'"Geist Mono Variable", ui-monospace, Menlo, Consolas, monospace',terminal:'"Geist Mono Variable", ui-monospace, Menlo, Consolas, monospace'},type:{fontSize:14,terminalFontSize:13,scale:{caption:12,body2:14,body1:15,subtitle2:14,subtitle1:15,h6:16,h5:18,h4:24,button:14},button:{textTransform:"none",fontWeight:600}},radius:{sm:6,md:8},spacing:8,densities:{desktop:{target:30,bar:40,iconButton:{side:30,icon:18,smallSide:26,smallIcon:16},button:{minHeight:30,fontSize:13,paddingX:12},switch:{width:34,height:20,thumb:16},inputFontSize:13,tabBar:{height:44,icon:20,label:10,badge:16,insetTrim:0}},touch:{target:48,bar:60,iconButton:{side:48,icon:30,smallSide:40,smallIcon:24},button:{minHeight:48,fontSize:17,paddingX:20},switch:{width:51,height:31,thumb:27},inputFontSize:16,tabBar:{height:49,icon:26,label:11,badge:18,insetTrim:12}}}};var XT=e=>`${e/16}rem`;function Z7r({font:e,type:t}){let{scale:r}=t;return{fontFamily:e.ui,fontFamilyMono:e.mono,fontSize:t.fontSize,button:{...t.button,fontSize:XT(r.button)},caption:{fontSize:XT(r.caption)},body2:{fontSize:XT(r.body2)},body1:{fontSize:XT(r.body1)},subtitle2:{fontSize:XT(r.subtitle2)},subtitle1:{fontSize:XT(r.subtitle1)},h6:{fontSize:XT(r.h6)},h5:{fontSize:XT(r.h5)},h4:{fontSize:XT(r.h4)}}}function J7r(e){return{MuiButtonBase:{styleOverrides:{root:{cursor:"pointer","&.Mui-disabled":{cursor:"default"}}}},MuiLink:{styleOverrides:{root:{cursor:"pointer"}}},MuiAppBar:{defaultProps:{elevation:e.elevation.appBar}}}}function Dyo(e,t){let{dark:r,light:n,densities:o,...i}=ZTe;return{...i,...e==="dark"?r:n,mode:e,density:o[t]}}function e8r(e,t="desktop"){let r=Dyo(e,t),{color:n}=r;return Xy({tokens:r,palette:{mode:e,background:{default:n.background,paper:n.surface},primary:n.primary,secondary:n.secondary,success:n.success,warning:n.warning,error:n.error,info:n.info,text:n.text,divider:n.line,action:{hover:n.raised,selected:n.selected}},typography:Z7r(r),shape:{borderRadius:r.radius.sm},spacing:r.spacing,components:{...J7r(r),...X7r(r)}})}function t8r(){if(typeof document>"u"||!document.fonts)return Promise.resolve();let{font:e,type:t}=ZTe;return Promise.allSettled([document.fonts.load(`${t.fontSize}px ${e.ui}`),document.fonts.load(`${t.terminalFontSize}px ${e.terminal}`)])}var vMr=k(oe(),1);var W5=k(I(),1);function r8r({status:e,onClose:t}){return(0,W5.jsxs)(W5.Fragment,{children:[(0,W5.jsx)(hu,{open:e.kind==="probing",children:(0,W5.jsx)(jn,{severity:"info",variant:"filled",children:e.kind==="probing"?`Connecting to ${e.name}\u2026`:""})}),(0,W5.jsx)(sl,{error:e.kind==="error"?e.message:null,onClose:t})]})}var eCe=k(oe(),1);var Nyo=/^\d+(\.\d+){3}$/;function BL(e){try{let{hostname:t}=new URL(e);return Nyo.test(t)?t:t.split(".")[0]}catch{return""}}var Oyo=/^[a-z]+:[/]{2}/i;function JTe(e){let t=e.trim(),r=Oyo.test(t)?t:`https://${t}`;try{let n=new URL(r);return n.protocol!=="https:"&&n.protocol!=="http:"?void 0:n.origin}catch{return}}function Byo(e){try{return new URL(e)}catch{return}}function Fyo(e){return e.protocol==="assist:"&&e.hostname==="add-node"&&(e.pathname===""||e.pathname==="/")}function n8r(e){let t=Byo(e);if(!t||!Fyo(t))return{ok:!1,error:`Not an assist add-node link: ${e}`};let r=t.searchParams.get("url"),n=r?JTe(r):void 0;return n?{ok:!0,node:{name:t.searchParams.get("name")?.trim()||BL(n),url:n}}:{ok:!1,error:`The link has no valid node URL: ${r??"(missing)"}`}}var o8r=5e3,i8r="/api/health";async function $yo(e){let t=new AbortController,r=setTimeout(()=>t.abort(),o8r);try{let n=await fetch(`${e}${i8r}`,{signal:t.signal,cache:"no-store"});return n.ok?{ok:!0,health:await n.json()}:{ok:!1,error:`HTTP ${n.status}`,status:n.status}}catch(n){return t.signal.aborted?{ok:!1,error:`timed out after ${o8r/1e3}s`}:{ok:!1,error:n instanceof Error?n.message:String(n)}}finally{clearTimeout(r)}}async function G5(e){let t=Date.now(),r=await $yo(e);return r.ok||B8({at:new Date(t).toISOString(),method:"GET",path:i8r,base:e,status:r.status,error:r.status===void 0?r.error:void 0,durationMs:Date.now()-t}),r}async function a8r(e,t){let r=n8r(e);if(!r.ok)return r;let{node:n}=r;t(n);let o=await G5(n.url);return o.ok?{ok:!0,node:n,health:o.health}:{ok:!1,error:`Can't reach ${n.name} at ${n.url}: ${o.error}`}}FL();var AXe=ZT("App",{web:()=>Promise.resolve().then(()=>(d8r(),f8r)).then(e=>new e.AppWeb)});var BU=k(oe(),1);var jyo=5e3;function p8r(e){let t=(0,BU.useRef)(e),r=(0,BU.useRef)(void 0);(0,BU.useEffect)(()=>{t.current=e},[e]),(0,BU.useEffect)(()=>{let n=i=>{let a=Date.now(),s=r.current?.url===i&&a-r.current.at<jyo;r.current={url:i,at:a},s||t.current(i)},o=AXe.addListener("appUrlOpen",({url:i})=>n(i));return AXe.getLaunchUrl().then(i=>{i?.url&&n(i.url)}).catch(i=>Cr(i,"launch url")),()=>{o.then(i=>i.remove())}},[])}function h8r(e){let[t,r]=(0,eCe.useState)({kind:"idle"});p8r(async o=>{let i=await a8r(o,a=>r({kind:"probing",name:a.name}));if(!i.ok){r({kind:"error",message:i.error});return}e(i.node,i.health),r({kind:"idle"})});let n=(0,eCe.useCallback)(()=>r({kind:"idle"}),[]);return{status:t,dismiss:n}}var Qee=k(I(),1);function m8r({name:e}){return(0,Qee.jsxs)(V,{sx:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,bgcolor:"background.default"},children:[(0,Qee.jsx)(bo,{size:28}),(0,Qee.jsxs)(Ee,{variant:"body2",color:"text.secondary",children:["Connecting to ",e??"home node","\u2026"]})]})}var tCe=k(oe(),1),PXe=(0,tCe.createContext)(null);function V5(){return(0,tCe.useContext)(PXe)}var Ks={top:"env(safe-area-inset-top, 0px)",bottom:"env(safe-area-inset-bottom, 0px)"};var y8r=k(I(),1);function g8r({value:e,error:t,onChange:r}){return(0,y8r.jsx)(Un,{autoFocus:!0,label:"Web server URL",placeholder:"https://mac.tail1234.ts.net:3100",value:e,onChange:n=>r(n.target.value),error:!!t,helperText:t??"The address where you open the sessions page in a browser.",slotProps:{htmlInput:{autoCapitalize:"none",autoCorrect:"off",inputMode:"url"}}})}var Zee=k(oe(),1);function v8r(e,t){let[r,n]=(0,Zee.useState)(e?.url??""),[o,i]=(0,Zee.useState)(e?.name),[a,s]=(0,Zee.useState)(),[l,u]=(0,Zee.useState)(!1),f=JTe(r),d=o??(f?BL(f):"");return{url:r,changeUrl:m=>{n(m),s(void 0)},name:d,setName:i,error:a,busy:l,submit:async m=>{if(m.preventDefault(),!f){s("Enter an http(s) URL, e.g. https://mac.tail1234.ts.net:3100");return}u(!0);let g=await t({name:d.trim()||BL(f),url:f});u(!1),s(g)}}}var FU=k(I(),1);function rCe({initial:e,submitLabel:t,onSubmit:r,children:n}){let o=v8r(e,r);return(0,FU.jsxs)(_t,{component:"form",spacing:2,onSubmit:o.submit,children:[(0,FU.jsx)(g8r,{value:o.url,error:o.error,onChange:o.changeUrl}),(0,FU.jsx)(Un,{label:"Name",value:o.name,onChange:i=>o.setName(i.target.value),helperText:"Filled in from the host name. Shown on the node chip.",slotProps:{htmlInput:{autoCapitalize:"none",autoCorrect:"off"}}}),(0,FU.jsx)(Tt,{type:"submit",variant:"contained",size:"large",disabled:!o.url.trim()||o.busy,children:o.busy?"Checking\u2026":t}),n]})}var JT=k(I(),1),Yyo={height:"100%",boxSizing:"border-box",overflowY:"auto",display:"flex",justifyContent:"center",pt:`calc(${Ks.top} + 28px)`,pb:`calc(${Ks.bottom} + 24px)`,px:2.5,bgcolor:"background.default"},Kyo={width:56,height:56,borderRadius:"14px",bgcolor:"action.hover",border:1,borderColor:"divider",display:"grid",placeItems:"center",fontFamily:"fontFamilyMono",fontSize:22,fontWeight:600,color:"primary.main"};function b8r({onConnect:e}){return(0,JT.jsx)(V,{sx:Yyo,children:(0,JT.jsxs)(_t,{spacing:2.5,sx:{width:"100%",maxWidth:420},children:[(0,JT.jsx)(V,{sx:Kyo,children:">_"}),(0,JT.jsx)(Ee,{variant:"h5",sx:{fontWeight:700},children:"Connect to a home node"}),(0,JT.jsxs)(Ee,{variant:"body2",color:"text.secondary",children:["The phone connects to one assist web server over Tailscale. You'll see its sessions and the sessions of every node it links to. Make sure Tailscale is connected on this phone and"," ",(0,JT.jsx)("code",{children:"assist sessions web"})," is running on that machine."]}),(0,JT.jsx)(rCe,{submitLabel:"Connect",onSubmit:async r=>{let n=await G5(r.url);if(!n.ok)return`Can't reach ${r.url}: ${n.error}`;e(r,n.health)}})]})})}var oMr=k(oe(),1);var Ny=k(I(),1),Xyo={flex:"none",pt:Ks.top,bgcolor:"background.default"},Qyo={height:e=>e.tokens.density.bar,display:"grid",gridTemplateColumns:"minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr)",columnGap:1,alignItems:"center",px:1.5},Zyo={height:e=>e.tokens.density.bar,display:"flex",alignItems:"center",gap:.5,px:.5},Jyo={textAlign:"center",minWidth:0,maxWidth:220,fontSize:15,fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},e1o={flex:1,minWidth:0,fontSize:15,fontWeight:600,lineHeight:1.25,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",overflowWrap:"anywhere"};function Zc({left:e,title:t,right:r,leadingTitle:n}){return(0,Ny.jsx)(V,{component:"header",sx:Xyo,children:n?(0,Ny.jsxs)(V,{sx:Zyo,children:[(0,Ny.jsx)(V,{sx:{flex:"none"},children:e}),(0,Ny.jsx)(V,{component:"h1",sx:[e1o,{m:0}],children:t}),(0,Ny.jsx)(V,{sx:{flex:"none",display:"flex"},children:r})]}):(0,Ny.jsxs)(V,{sx:Qyo,children:[(0,Ny.jsx)(V,{sx:{justifySelf:"start",minWidth:0},children:e}),(0,Ny.jsx)(V,{sx:Jyo,children:t}),(0,Ny.jsx)(V,{sx:{justifySelf:"end",display:"flex",gap:.25},children:r})]})})}var Ub=e=>e.tokens.color.raised;var x8r=k(I(),1),t1o={ok:e=>e.palette.success.main,warn:e=>e.palette.warning.main,error:e=>e.palette.error.main,off:e=>e.palette.text.disabled};function Yg({tone:e}){return(0,x8r.jsx)(V,{component:"span",sx:{width:8,height:8,flex:"none",borderRadius:"50%",bgcolor:t1o[e]}})}var ic=e=>e.tokens.density.target;var $U=k(I(),1),r1o={display:"inline-flex",alignItems:"center",gap:.75,height:ic,pl:1.125,pr:.75,borderRadius:"24px",border:1,borderColor:"divider",bgcolor:Ub,color:"text.primary",fontFamily:"fontFamilyMono",fontSize:13,maxWidth:140,justifyContent:"flex-start"},n1o={minWidth:0,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"};function nCe({name:e,tone:t,onClick:r}){return(0,$U.jsxs)(ir,{sx:r1o,onClick:r,disabled:!r,"aria-label":"Nodes","data-testid":"phone-node-chip",children:[(0,$U.jsx)(Yg,{tone:t}),(0,$U.jsx)(V,{component:"span",sx:n1o,children:e??"\u2026"}),r&&(0,$U.jsx)(ea,{sx:{fontSize:16,flex:"none"}})]})}var Z8r=k(oe(),1);var oCe=k(I(),1);function S8r({homeNode:e,node:t,onDone:r}){let n=!!t&&t.url===e.home?.url;return(0,oCe.jsx)(V,{sx:{px:2.5,pt:1},children:(0,oCe.jsx)(rCe,{initial:t,submitLabel:t?"Save":"Add node",onSubmit:async i=>{if(e.nodes.some(s=>s.url===i.url&&s.url!==t?.url))return"That URL is already saved";e.saveNode(t?.url??i.url,i),r()},children:t&&(0,oCe.jsx)(Tt,{color:"error",size:"large",disabled:n,onClick:()=>{e.removeNode(t.url),r()},children:n?"Switch home node to delete this one":"Delete node"})})})}var T8r=k(I(),1),o1o={width:36,height:5,borderRadius:"3px",bgcolor:"text.disabled",opacity:.5,mx:"auto",mb:.75};function zU(){return(0,T8r.jsx)(V,{sx:o1o})}var eC=k(I(),1),i1o={display:"flex",justifyContent:"space-between",alignItems:"center",gap:1,px:2,pt:.75,pb:1.25},a1o={color:"primary.main",fontSize:16,minHeight:ic,px:.5,borderRadius:1};function HU({title:e,actionLabel:t,onAction:r}){return(0,eC.jsxs)(eC.Fragment,{children:[(0,eC.jsx)(zU,{}),(0,eC.jsxs)(V,{sx:i1o,children:[(0,eC.jsx)(V,{component:"b",sx:{fontSize:17,fontWeight:600},children:e}),(0,eC.jsx)(ir,{sx:a1o,onClick:r,children:t})]})]})}var $L=k(I(),1);function C8r({homeNode:e,node:t,onDone:r}){return(0,$L.jsxs)($L.Fragment,{children:[(0,$L.jsx)(HU,{title:t?"Edit node":"Add node",actionLabel:"Cancel",onAction:r}),(0,$L.jsx)(S8r,{homeNode:e,node:t,onDone:r},t?.url??"add")]})}var Ar={group:{flexShrink:0,mx:2,my:.75,borderRadius:"12px",bgcolor:"background.default",border:1,borderColor:"divider",overflow:"hidden","& > *:not(:last-child)":{borderBottom:1,borderColor:e=>e.tokens.color.lineSoft}},item:{width:"100%",minHeight:ic,display:"flex",alignItems:"center",justifyContent:"flex-start",gap:1.5,px:1.75,py:1,textAlign:"left",fontSize:16},grow:{flex:1,minWidth:0},detail:{display:"block",fontSize:13,color:"text.secondary",fontFamily:"fontFamilyMono",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},end:{display:"flex",alignItems:"center",gap:.75,color:"text.secondary",fontSize:14},label:{px:4,pt:1.75,pb:.25,fontSize:13,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"text.secondary"}};function w8r(e,t){return e.replace(/\/+$/,"")===t.replace(/\/+$/,"")}function UU(e,t){let r=e.split(".").map(Number),n=t.split(".").map(Number);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]||0)-(n[o]||0);if(i!==0)return Math.sign(i)}return 0}function k8r(e,t,r){let n=t.filter(a=>a.node===e.name).length,o=[e.state,`${n} session${n===1?"":"s"}`,e.peerVersion&&`v${e.peerVersion}`,e.state!=="connected"&&e.error],i=e.peerVersion&&r?UU(e.peerVersion,r):0;return{text:o.filter(Boolean).join(" \xB7 "),drift:i<0?"behind":i>0?"ahead":void 0}}var iCe={connected:"ok",connecting:"warn",disconnected:"error","version-blocked":"error"};var LXe=k(I(),1);function _8r({name:e,onSave:t}){return(0,LXe.jsx)(Vt,{"aria-label":`Save ${e} as a home node`,onClick:t,sx:{color:"primary.main",borderRadius:0},children:(0,LXe.jsx)(qd,{fontSize:"small"})})}var tC=k(I(),1),s1o={fontFamily:"fontFamilyMono",fontSize:12,px:.75,border:1,borderColor:"currentColor",borderRadius:"4px",color:"warning.main"};function E8r({links:e,sessions:t,homeVersion:r,isSaved:n,onSave:o}){return(0,tC.jsx)(V,{sx:Ar.group,children:e.map(i=>{let{text:a,drift:s}=k8r(i,t,r);return(0,tC.jsxs)(V,{sx:[Ar.item,{pr:0}],children:[(0,tC.jsx)(Yg,{tone:iCe[i.state]}),(0,tC.jsxs)(V,{component:"span",sx:Ar.grow,children:[i.name,(0,tC.jsx)(V,{component:"span",sx:Ar.detail,children:a})]}),s&&(0,tC.jsx)(V,{component:"span",sx:s1o,children:s}),!n(i.url)&&(0,tC.jsx)(_8r,{name:i.name,onSave:()=>o(i)})]},i.name)})})}var Wb=k(I(),1);function WU({title:e,rows:t}){return(0,Wb.jsxs)(Wb.Fragment,{children:[(0,Wb.jsx)(V,{sx:Ar.label,children:e}),(0,Wb.jsx)(V,{sx:Ar.group,children:t.map(r=>(0,Wb.jsxs)(V,{sx:Ar.item,children:[(0,Wb.jsx)(V,{component:"span",sx:Ar.grow,children:r.label}),(0,Wb.jsx)(V,{component:"span",sx:[Ar.end,{fontFamily:"fontFamilyMono"},r.color?{color:r.color}:{}],children:r.value})]},r.key))})]})}var A8r=k(I(),1);function R8r({rateLimits:e,harnessRateLimits:t}){let r=Ug(3e4),n=XSe(e,t).flatMap(o=>eTe(o.rateLimits).map(i=>({key:`${o.harness}-${i.label}`,label:`${vc(o.harness)} \xB7 ${i.label}`,value:i.resetsAt!=null?`${Math.round(i.pct)}% \xB7 ${tU(i.resetsAt,r)}`:`${Math.round(i.pct)}%`,color:sSe(Cb(i.pct,i.resetsAt,i.windowSeconds,r))})));return n.length===0?null:(0,A8r.jsx)(WU,{title:"Rate limits",rows:n})}var Gb=k(I(),1);function P8r({status:e,homeVersion:t,homeNode:r}){let n=e.nodes?.links??[];return(0,Gb.jsxs)(Gb.Fragment,{children:[n.length>0&&(0,Gb.jsxs)(Gb.Fragment,{children:[(0,Gb.jsxs)(V,{sx:Ar.label,children:["Linked through ",e.nodes?.local]}),(0,Gb.jsx)(E8r,{links:n,sessions:e.sessions,homeVersion:t,isSaved:o=>r.nodes.some(i=>w8r(i.url,o)),onSave:({name:o,url:i})=>r.saveNode("",{name:o,url:i})})]}),(0,Gb.jsx)(R8r,{rateLimits:e.rateLimits,harnessRateLimits:e.harnessRateLimits})]})}var l1o={ok:"ok",ready:"warn",diverged:"warn",retrying:"warn",paused:"off",off:"off",loading:"off",unavailable:"error"};function aCe(e,t){let r=zg(e),{status:n}=e,o=!!n&&!!t&&UU(t,n.built)>0,i=p5(e),a=n&&(n.running===n.built?`v${n.running}`:`v${n.running} \u2192 v${n.built}`),s=o?`v${t} available`:i?"restart pending":r.label.toLowerCase();return{tone:o?"warn":l1o[r.kind],detail:[a,s].filter(Boolean).join(" \xB7 "),updateAvailable:o,restartPending:i}}var nm=k(I(),1);function L8r({updates:e,onOpen:t}){let{entries:r,latest:n,notices:o}=e;return r.length===0?null:(0,nm.jsxs)(nm.Fragment,{children:[(0,nm.jsx)(V,{sx:Ar.label,children:"Updates"}),(0,nm.jsx)(V,{sx:Ar.group,children:r.map(i=>{let a=aCe(i,n),s=o.busy[i.name];return(0,nm.jsxs)(ir,{sx:Ar.item,onClick:()=>t(i.name),"data-testid":`phone-update-row-${i.name}`,children:[(0,nm.jsx)(Yg,{tone:a.tone}),(0,nm.jsxs)(V,{component:"span",sx:Ar.grow,children:[i.name,(0,nm.jsx)(V,{component:"span",sx:Ar.detail,children:a.detail})]}),(0,nm.jsxs)(V,{component:"span",sx:Ar.end,children:[s&&`${s}\u2026`,(0,nm.jsx)(qo,{})]})]},i.name)})})]})}var Jee=k(I(),1);function sCe({onAdd:e}){return(0,Jee.jsxs)(ir,{sx:Ar.item,onClick:e,children:[(0,Jee.jsx)(qd,{sx:{color:"primary.main"}}),(0,Jee.jsx)(V,{component:"span",sx:{color:"primary.main"},children:"Add node URL"})]})}function Vb(e){try{return new URL(e).host}catch{return e}}function lCe(e){if(!e)return{tone:"off",text:"checking\u2026"};if(!e.ok)return{tone:"error",text:"unreachable"};let t=e.health.version;return{tone:"ok",text:t?`reachable \xB7 v${t}`:"reachable"}}var cCe=k(oe(),1);var c1o=15e3;function uCe(e){let[t,r]=(0,cCe.useState)({}),n=e.join(`
|
|
4025
4025
|
`);return(0,cCe.useEffect)(()=>{if(!n)return;let o=!1,i=()=>{for(let s of n.split(`
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.1008.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -25753,9 +25753,25 @@ function registerDevlog(program) {
|
|
|
25753
25753
|
}
|
|
25754
25754
|
|
|
25755
25755
|
// src/commands/docs/docsConfirm.ts
|
|
25756
|
-
import { unlinkSync as unlinkSync10 } from "fs";
|
|
25757
25756
|
import chalk165 from "chalk";
|
|
25758
25757
|
|
|
25758
|
+
// src/commands/notify/forwardPinConfirm.ts
|
|
25759
|
+
import { randomUUID as randomUUID11 } from "crypto";
|
|
25760
|
+
var CONFIRM_TIMEOUT_MS = 15e3;
|
|
25761
|
+
async function forwardPinConfirm(area, pin2) {
|
|
25762
|
+
const requestId = randomUUID11();
|
|
25763
|
+
const reply2 = await requestDaemonReply(
|
|
25764
|
+
{ type: "confirm-pin", requestId, area, pin: pin2 },
|
|
25765
|
+
"confirm-pin-result",
|
|
25766
|
+
CONFIRM_TIMEOUT_MS
|
|
25767
|
+
);
|
|
25768
|
+
if (!reply2?.found || reply2.requestId !== requestId) return void 0;
|
|
25769
|
+
return { ok: reply2.ok === true, message: reply2.message ?? "" };
|
|
25770
|
+
}
|
|
25771
|
+
|
|
25772
|
+
// src/commands/docs/approveDocsUnlock.ts
|
|
25773
|
+
import { unlinkSync as unlinkSync10 } from "fs";
|
|
25774
|
+
|
|
25759
25775
|
// src/commands/docs/getDocsUnlockPinPath.ts
|
|
25760
25776
|
import { join as join69 } from "path";
|
|
25761
25777
|
function getDocsUnlockPinPath(pin2) {
|
|
@@ -25795,43 +25811,75 @@ async function recordDocsUnlock(orm, itemId2, phase) {
|
|
|
25795
25811
|
});
|
|
25796
25812
|
}
|
|
25797
25813
|
|
|
25798
|
-
// src/commands/docs/
|
|
25799
|
-
async function
|
|
25814
|
+
// src/commands/docs/approveDocsUnlock.ts
|
|
25815
|
+
async function approveDocsUnlock(pin2) {
|
|
25800
25816
|
sweepRestrictedDir();
|
|
25801
25817
|
const state = readDocsUnlockPinState(pin2);
|
|
25802
|
-
if (!state)
|
|
25803
|
-
console.error(chalk165.red(`No pending docs unlock for pin: ${pin2}`));
|
|
25804
|
-
process.exitCode = 1;
|
|
25805
|
-
return;
|
|
25806
|
-
}
|
|
25818
|
+
if (!state) return void 0;
|
|
25807
25819
|
unlinkSync10(getDocsUnlockPinPath(pin2));
|
|
25808
25820
|
const found = await findOneItem(String(state.itemId));
|
|
25809
|
-
if (!found)
|
|
25821
|
+
if (!found)
|
|
25822
|
+
return {
|
|
25823
|
+
ok: false,
|
|
25824
|
+
message: `Item ${formatItemId(state.itemId)} not found; nothing was approved.`
|
|
25825
|
+
};
|
|
25826
|
+
const label = `${formatItemId(state.itemId)} ${found.item.name}`;
|
|
25827
|
+
if ((found.item.currentPhase ?? 1) !== state.phase)
|
|
25828
|
+
return {
|
|
25829
|
+
ok: false,
|
|
25830
|
+
message: `${label} has moved on from phase ${state.phase} since the unlock was requested. Nothing was approved; request a new unlock from the current phase.`
|
|
25831
|
+
};
|
|
25832
|
+
await recordDocsUnlock(found.orm, state.itemId, state.phase);
|
|
25833
|
+
return {
|
|
25834
|
+
ok: true,
|
|
25835
|
+
message: `Approved docs changes for phase ${state.phase} of ${label}. Its sessions may edit and commit docs pages and screenshots until the item moves on from that phase or is done or won't-do.`
|
|
25836
|
+
};
|
|
25837
|
+
}
|
|
25838
|
+
|
|
25839
|
+
// src/commands/docs/docsConfirm.ts
|
|
25840
|
+
async function docsConfirm(pin2) {
|
|
25841
|
+
const result = await approveDocsUnlock(pin2) ?? await forwardPinConfirm("docs", pin2);
|
|
25842
|
+
if (!result) {
|
|
25843
|
+
console.error(chalk165.red(`No pending docs unlock for pin: ${pin2}`));
|
|
25810
25844
|
process.exitCode = 1;
|
|
25811
25845
|
return;
|
|
25812
25846
|
}
|
|
25813
|
-
|
|
25814
|
-
|
|
25815
|
-
console.error(
|
|
25816
|
-
chalk165.red(
|
|
25817
|
-
`${label} has moved on from phase ${state.phase} since the unlock was requested. Nothing was approved; request a new unlock from the current phase.`
|
|
25818
|
-
)
|
|
25819
|
-
);
|
|
25820
|
-
process.exitCode = 1;
|
|
25847
|
+
if (result.ok) {
|
|
25848
|
+
console.log(chalk165.green(result.message));
|
|
25821
25849
|
return;
|
|
25822
25850
|
}
|
|
25823
|
-
|
|
25824
|
-
|
|
25825
|
-
chalk165.green(
|
|
25826
|
-
`Approved docs changes for phase ${state.phase} of ${label}. Its sessions may edit and commit docs pages and screenshots until the item moves on from that phase or is done or won't-do.`
|
|
25827
|
-
)
|
|
25828
|
-
);
|
|
25851
|
+
console.error(chalk165.red(result.message));
|
|
25852
|
+
process.exitCode = 1;
|
|
25829
25853
|
}
|
|
25830
25854
|
|
|
25831
25855
|
// src/commands/docs/docsUnlock.ts
|
|
25832
25856
|
import { randomInt as randomInt3 } from "crypto";
|
|
25833
25857
|
import { mkdirSync as mkdirSync20, unlinkSync as unlinkSync11, writeFileSync as writeFileSync33 } from "fs";
|
|
25834
25858
|
import chalk166 from "chalk";
|
|
25859
|
+
|
|
25860
|
+
// src/commands/notify/deliverPinNotification.ts
|
|
25861
|
+
import { randomUUID as randomUUID12 } from "crypto";
|
|
25862
|
+
var ROUTE_TIMEOUT_MS = 1e4;
|
|
25863
|
+
async function relayToViewerNode(notification) {
|
|
25864
|
+
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
25865
|
+
if (!sessionId) return void 0;
|
|
25866
|
+
const requestId = randomUUID12();
|
|
25867
|
+
const reply2 = await requestDaemonReply(
|
|
25868
|
+
{ type: "notify-pin", sessionId, requestId, ...notification },
|
|
25869
|
+
"notify-pin-result",
|
|
25870
|
+
ROUTE_TIMEOUT_MS
|
|
25871
|
+
);
|
|
25872
|
+
if (reply2?.requestId !== requestId) return void 0;
|
|
25873
|
+
return reply2.node;
|
|
25874
|
+
}
|
|
25875
|
+
async function deliverPinNotification(notification) {
|
|
25876
|
+
const node = await relayToViewerNode(notification);
|
|
25877
|
+
if (node) return { delivered: true, node };
|
|
25878
|
+
const { title, message: message3 } = notification;
|
|
25879
|
+
return { delivered: showNotification({ title, message: message3 }) };
|
|
25880
|
+
}
|
|
25881
|
+
|
|
25882
|
+
// src/commands/docs/docsUnlock.ts
|
|
25835
25883
|
function fail7(message3) {
|
|
25836
25884
|
console.error(chalk166.red(message3));
|
|
25837
25885
|
process.exitCode = 1;
|
|
@@ -25856,7 +25904,9 @@ async function docsUnlock() {
|
|
|
25856
25904
|
sweepRestrictedDir();
|
|
25857
25905
|
const pinPath = getDocsUnlockPinPath(pin2);
|
|
25858
25906
|
writeFileSync33(pinPath, JSON.stringify({ pin: pin2, itemId: itemId2, phase }));
|
|
25859
|
-
const delivered =
|
|
25907
|
+
const { delivered, node } = await deliverPinNotification({
|
|
25908
|
+
area: "docs",
|
|
25909
|
+
pin: pin2,
|
|
25860
25910
|
title: `assist docs unlock: ${label}`,
|
|
25861
25911
|
message: `Pin ${pin2} \u2014 run: assist docs confirm ${pin2}`
|
|
25862
25912
|
});
|
|
@@ -25868,8 +25918,8 @@ async function docsUnlock() {
|
|
|
25868
25918
|
return;
|
|
25869
25919
|
}
|
|
25870
25920
|
console.log(
|
|
25871
|
-
`A confirmation pin was sent to the user's desktop notifications.
|
|
25872
|
-
To let this phase of ${label} edit docs pages and screenshots, the user runs:
|
|
25921
|
+
`A confirmation pin was sent to the user's desktop notifications${node ? ` on ${node}, the node controlling this session` : ""}.
|
|
25922
|
+
To let this phase of ${label} edit docs pages and screenshots, the user runs${node ? ` on ${node}` : ""}:
|
|
25873
25923
|
${chalk166.cyan(" assist docs confirm <PIN>")}
|
|
25874
25924
|
Wait for the user to confirm before editing docs.`
|
|
25875
25925
|
);
|
|
@@ -28034,13 +28084,13 @@ function validateProposedContent(labels, title, body) {
|
|
|
28034
28084
|
}
|
|
28035
28085
|
|
|
28036
28086
|
// src/commands/github/issue/reviewProposedIssueComment.ts
|
|
28037
|
-
import { randomUUID as
|
|
28087
|
+
import { randomUUID as randomUUID13 } from "crypto";
|
|
28038
28088
|
async function reviewProposedIssueComment(title, body) {
|
|
28039
28089
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
28040
28090
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
28041
28091
|
await awaitPreviewApproval("GitHub issue comment preview", {
|
|
28042
28092
|
sessionId,
|
|
28043
|
-
requestId:
|
|
28093
|
+
requestId: randomUUID13(),
|
|
28044
28094
|
title,
|
|
28045
28095
|
body,
|
|
28046
28096
|
prNumber: null,
|
|
@@ -28558,13 +28608,13 @@ function resolveCreateIssueMetadata(options2) {
|
|
|
28558
28608
|
}
|
|
28559
28609
|
|
|
28560
28610
|
// src/commands/github/issue/reviewProposedIssue.ts
|
|
28561
|
-
import { randomUUID as
|
|
28611
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
28562
28612
|
async function reviewProposedIssue(title, body, metadata2 = []) {
|
|
28563
28613
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
28564
28614
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return void 0;
|
|
28565
28615
|
return await awaitPreviewApproval("GitHub issue preview", {
|
|
28566
28616
|
sessionId,
|
|
28567
|
-
requestId:
|
|
28617
|
+
requestId: randomUUID14(),
|
|
28568
28618
|
title,
|
|
28569
28619
|
body,
|
|
28570
28620
|
prNumber: null,
|
|
@@ -28864,7 +28914,7 @@ function pushUnchangedIssue(number, repo, target, fetchedAt, bodyPath) {
|
|
|
28864
28914
|
}
|
|
28865
28915
|
|
|
28866
28916
|
// src/commands/github/issue/reviewProposedIssueEdit.ts
|
|
28867
|
-
import { randomUUID as
|
|
28917
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
28868
28918
|
async function reviewProposedIssueEdit(title, body, working) {
|
|
28869
28919
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
28870
28920
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return body;
|
|
@@ -28872,7 +28922,7 @@ async function reviewProposedIssueEdit(title, body, working) {
|
|
|
28872
28922
|
"GitHub issue edit preview",
|
|
28873
28923
|
{
|
|
28874
28924
|
sessionId,
|
|
28875
|
-
requestId:
|
|
28925
|
+
requestId: randomUUID15(),
|
|
28876
28926
|
title,
|
|
28877
28927
|
body,
|
|
28878
28928
|
prNumber: null,
|
|
@@ -29885,7 +29935,7 @@ function registerRefineLaunch(program, resumeFlag) {
|
|
|
29885
29935
|
}
|
|
29886
29936
|
|
|
29887
29937
|
// src/commands/fixConflict.ts
|
|
29888
|
-
import { randomUUID as
|
|
29938
|
+
import { randomUUID as randomUUID16 } from "crypto";
|
|
29889
29939
|
|
|
29890
29940
|
// src/commands/review/checkoutPr.ts
|
|
29891
29941
|
import { execFileSync as execFileSync18 } from "child_process";
|
|
@@ -30670,7 +30720,7 @@ function buildPrompt2(rebase) {
|
|
|
30670
30720
|
async function fixConflict(number, options2 = {}) {
|
|
30671
30721
|
const { resumeSessionId } = options2;
|
|
30672
30722
|
if (number && !resumeSessionId) await checkoutPr(number);
|
|
30673
|
-
const claudeSessionId = resumeSessionId ??
|
|
30723
|
+
const claudeSessionId = resumeSessionId ?? randomUUID16();
|
|
30674
30724
|
emitActivity({
|
|
30675
30725
|
kind: "command",
|
|
30676
30726
|
name: "fix-conflict",
|
|
@@ -30698,7 +30748,7 @@ function registerFixConflict(program, resumeFlag) {
|
|
|
30698
30748
|
}
|
|
30699
30749
|
|
|
30700
30750
|
// src/commands/reviewPrComments.ts
|
|
30701
|
-
import { randomUUID as
|
|
30751
|
+
import { randomUUID as randomUUID17 } from "crypto";
|
|
30702
30752
|
function buildPrompt3(number, announce, options2) {
|
|
30703
30753
|
const args = [
|
|
30704
30754
|
"/review-pr-comments",
|
|
@@ -30724,7 +30774,7 @@ async function reviewPrComments(number, options2 = {}) {
|
|
|
30724
30774
|
validateAnnounce(number, announce);
|
|
30725
30775
|
validateMode(options2);
|
|
30726
30776
|
if (number && !resumeSessionId) await checkoutPr(number);
|
|
30727
|
-
const claudeSessionId = resumeSessionId ??
|
|
30777
|
+
const claudeSessionId = resumeSessionId ?? randomUUID17();
|
|
30728
30778
|
emitActivity({
|
|
30729
30779
|
kind: "command",
|
|
30730
30780
|
name: "review-pr-comments",
|
|
@@ -31266,7 +31316,7 @@ async function offerSaveExtract(extract2, options2, paths = {}) {
|
|
|
31266
31316
|
}
|
|
31267
31317
|
|
|
31268
31318
|
// src/commands/miro/pickAnchors.ts
|
|
31269
|
-
import { randomUUID as
|
|
31319
|
+
import { randomUUID as randomUUID18 } from "crypto";
|
|
31270
31320
|
|
|
31271
31321
|
// src/commands/miro/isBox.ts
|
|
31272
31322
|
var boxTypes = /* @__PURE__ */ new Set(["shape", "sticky_note"]);
|
|
@@ -31287,7 +31337,7 @@ async function pickAnchors(sessionId, items2) {
|
|
|
31287
31337
|
"Miro anchor selection",
|
|
31288
31338
|
{
|
|
31289
31339
|
sessionId,
|
|
31290
|
-
requestId:
|
|
31340
|
+
requestId: randomUUID18(),
|
|
31291
31341
|
title: "Pick the top-left then the bottom-right box",
|
|
31292
31342
|
body: encodeMiroBoardPreview(items2),
|
|
31293
31343
|
prNumber: null,
|
|
@@ -32518,13 +32568,13 @@ function postReviewComment(vars) {
|
|
|
32518
32568
|
}
|
|
32519
32569
|
|
|
32520
32570
|
// src/commands/prs/reviewProposedPrComment.ts
|
|
32521
|
-
import { randomUUID as
|
|
32571
|
+
import { randomUUID as randomUUID19 } from "crypto";
|
|
32522
32572
|
async function reviewProposedPrComment(title, body, prNumber) {
|
|
32523
32573
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
32524
32574
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
32525
32575
|
await awaitPreviewApproval("PR comment preview", {
|
|
32526
32576
|
sessionId,
|
|
32527
|
-
requestId:
|
|
32577
|
+
requestId: randomUUID19(),
|
|
32528
32578
|
title,
|
|
32529
32579
|
body,
|
|
32530
32580
|
prNumber,
|
|
@@ -33559,7 +33609,7 @@ function parseScreenshotSpecs(specs) {
|
|
|
33559
33609
|
}
|
|
33560
33610
|
|
|
33561
33611
|
// src/commands/prs/previewAndApplyEdit.ts
|
|
33562
|
-
import { randomUUID as
|
|
33612
|
+
import { randomUUID as randomUUID20 } from "crypto";
|
|
33563
33613
|
|
|
33564
33614
|
// src/commands/prs/stageScreenshots.ts
|
|
33565
33615
|
import { readFile as readFile8 } from "fs/promises";
|
|
@@ -33581,7 +33631,7 @@ function stageScreenshots(screenshots = []) {
|
|
|
33581
33631
|
async function previewAndApplyEdit(args) {
|
|
33582
33632
|
const decision = await awaitPreviewApproval("PR preview", {
|
|
33583
33633
|
sessionId: args.sessionId,
|
|
33584
|
-
requestId:
|
|
33634
|
+
requestId: randomUUID20(),
|
|
33585
33635
|
title: args.title ?? args.currentTitle,
|
|
33586
33636
|
body: args.body,
|
|
33587
33637
|
prNumber: args.number,
|
|
@@ -33916,7 +33966,7 @@ async function placePr(prNumber, title, body, options2, attachments = []) {
|
|
|
33916
33966
|
}
|
|
33917
33967
|
|
|
33918
33968
|
// src/commands/prs/previewAndPlace.ts
|
|
33919
|
-
import { randomUUID as
|
|
33969
|
+
import { randomUUID as randomUUID21 } from "crypto";
|
|
33920
33970
|
|
|
33921
33971
|
// src/commands/review/announcePr.ts
|
|
33922
33972
|
function announcePr(prNumber) {
|
|
@@ -33992,7 +34042,7 @@ function enableAutoMerge() {
|
|
|
33992
34042
|
async function previewAndPlace(args) {
|
|
33993
34043
|
const decision = await awaitPreviewApproval("PR preview", {
|
|
33994
34044
|
sessionId: args.sessionId,
|
|
33995
|
-
requestId:
|
|
34045
|
+
requestId: randomUUID21(),
|
|
33996
34046
|
title: args.title,
|
|
33997
34047
|
body: args.body,
|
|
33998
34048
|
prNumber: args.prNumber,
|
|
@@ -38519,10 +38569,10 @@ function registerRefactor(program) {
|
|
|
38519
38569
|
}
|
|
38520
38570
|
|
|
38521
38571
|
// src/commands/review/checkoutPrSession.ts
|
|
38522
|
-
import { randomUUID as
|
|
38572
|
+
import { randomUUID as randomUUID22 } from "crypto";
|
|
38523
38573
|
async function checkoutPrSession(number, prompt = "") {
|
|
38524
38574
|
await checkoutPr(number);
|
|
38525
|
-
const claudeSessionId =
|
|
38575
|
+
const claudeSessionId = randomUUID22();
|
|
38526
38576
|
emitActivity({ kind: "command", name: "review", claudeSessionId });
|
|
38527
38577
|
const { done: done2 } = spawnClaude(prompt, {
|
|
38528
38578
|
permissionMode: "auto",
|
|
@@ -39629,7 +39679,7 @@ function gatherHighLevelSubject(prNumber, force) {
|
|
|
39629
39679
|
}
|
|
39630
39680
|
|
|
39631
39681
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
39632
|
-
import { randomUUID as
|
|
39682
|
+
import { randomUUID as randomUUID24 } from "crypto";
|
|
39633
39683
|
|
|
39634
39684
|
// src/commands/review/highLevel/highLevelProgress.ts
|
|
39635
39685
|
function toItem2(check2, decision) {
|
|
@@ -39888,7 +39938,7 @@ function splitQueuedComments(record) {
|
|
|
39888
39938
|
}
|
|
39889
39939
|
|
|
39890
39940
|
// src/commands/review/highLevel/previewHighLevelReview.ts
|
|
39891
|
-
import { randomUUID as
|
|
39941
|
+
import { randomUUID as randomUUID23 } from "crypto";
|
|
39892
39942
|
|
|
39893
39943
|
// src/commands/review/highLevel/formatHighLevelReviewPreview.ts
|
|
39894
39944
|
function formatHighLevelReviewPreview(lineLevel, body) {
|
|
@@ -39915,7 +39965,7 @@ async function previewHighLevelReview(sessionId, record, submission) {
|
|
|
39915
39965
|
"Review",
|
|
39916
39966
|
{
|
|
39917
39967
|
sessionId,
|
|
39918
|
-
requestId:
|
|
39968
|
+
requestId: randomUUID23(),
|
|
39919
39969
|
title: `${LABELS[submission.event]} ${record.repo}#${record.prNumber}`,
|
|
39920
39970
|
body: formatHighLevelReviewPreview(submission.comments, submission.body),
|
|
39921
39971
|
prNumber: record.prNumber,
|
|
@@ -39966,7 +40016,7 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
39966
40016
|
"High-level review",
|
|
39967
40017
|
{
|
|
39968
40018
|
sessionId,
|
|
39969
|
-
requestId:
|
|
40019
|
+
requestId: randomUUID24(),
|
|
39970
40020
|
title: `${subject.repo}#${subject.prNumber} \u2014 ${subject.title}`,
|
|
39971
40021
|
body: JSON.stringify(highLevelPreviewPayload(subject)),
|
|
39972
40022
|
prNumber: subject.prNumber,
|
|
@@ -43205,7 +43255,7 @@ function registerSeq(program) {
|
|
|
43205
43255
|
}
|
|
43206
43256
|
|
|
43207
43257
|
// src/commands/show.ts
|
|
43208
|
-
import { randomUUID as
|
|
43258
|
+
import { randomUUID as randomUUID25 } from "crypto";
|
|
43209
43259
|
|
|
43210
43260
|
// src/commands/sessions/shared/sendShowPreview.ts
|
|
43211
43261
|
async function sendShowPreview(request) {
|
|
@@ -43257,7 +43307,7 @@ async function show3(options2) {
|
|
|
43257
43307
|
try {
|
|
43258
43308
|
await sendShowPreview({
|
|
43259
43309
|
sessionId,
|
|
43260
|
-
requestId:
|
|
43310
|
+
requestId: randomUUID25(),
|
|
43261
43311
|
title: options2.title ?? "Show",
|
|
43262
43312
|
body
|
|
43263
43313
|
});
|
|
@@ -43341,7 +43391,7 @@ function readSlackParts(files) {
|
|
|
43341
43391
|
}
|
|
43342
43392
|
|
|
43343
43393
|
// src/commands/slack/reviewProposedSlackMessage.ts
|
|
43344
|
-
import { randomUUID as
|
|
43394
|
+
import { randomUUID as randomUUID26 } from "crypto";
|
|
43345
43395
|
async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
43346
43396
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
43347
43397
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
@@ -43351,7 +43401,7 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
43351
43401
|
part ? `Slack message ${part.index} of ${part.total}` : "Slack message preview",
|
|
43352
43402
|
{
|
|
43353
43403
|
sessionId,
|
|
43354
|
-
requestId:
|
|
43404
|
+
requestId: randomUUID26(),
|
|
43355
43405
|
title: part ? `${destination} (${part.index}/${part.total})` : destination,
|
|
43356
43406
|
body,
|
|
43357
43407
|
prNumber: null,
|
|
@@ -48359,7 +48409,7 @@ var ClientHub = class extends Set {
|
|
|
48359
48409
|
harnessLimits = /* @__PURE__ */ new Map();
|
|
48360
48410
|
// why: log delivery is opt-in so browser tabs aren't spammed; only connections that ask via subscribe-logs receive daemonLog lines.
|
|
48361
48411
|
logSubscribers = /* @__PURE__ */ new Set();
|
|
48362
|
-
peers = /* @__PURE__ */ new
|
|
48412
|
+
peers = /* @__PURE__ */ new Map();
|
|
48363
48413
|
updateLimits(rateLimits) {
|
|
48364
48414
|
this.latestLimits = rateLimits;
|
|
48365
48415
|
broadcast(this, { type: "limits", rateLimits });
|
|
@@ -48386,12 +48436,20 @@ var ClientHub = class extends Set {
|
|
|
48386
48436
|
for (const [harness, rateLimits] of this.harnessLimits)
|
|
48387
48437
|
sendTo(client, { type: "limits", harness, rateLimits });
|
|
48388
48438
|
}
|
|
48389
|
-
markPeer(client) {
|
|
48390
|
-
this.peers.
|
|
48439
|
+
markPeer(client, node) {
|
|
48440
|
+
this.peers.set(client, node);
|
|
48391
48441
|
}
|
|
48392
48442
|
isPeer(client) {
|
|
48393
48443
|
return this.peers.has(client);
|
|
48394
48444
|
}
|
|
48445
|
+
peerNode(client) {
|
|
48446
|
+
return this.peers.get(client);
|
|
48447
|
+
}
|
|
48448
|
+
peerFor(node) {
|
|
48449
|
+
let latest2;
|
|
48450
|
+
for (const [client, name] of this.peers) if (name === node) latest2 = client;
|
|
48451
|
+
return latest2;
|
|
48452
|
+
}
|
|
48395
48453
|
viewers() {
|
|
48396
48454
|
return new Set([...this].filter((client) => !this.peers.has(client)));
|
|
48397
48455
|
}
|
|
@@ -48417,7 +48475,7 @@ var ClientHub = class extends Set {
|
|
|
48417
48475
|
};
|
|
48418
48476
|
|
|
48419
48477
|
// src/commands/sessions/daemon/createSession.ts
|
|
48420
|
-
import { randomUUID as
|
|
48478
|
+
import { randomUUID as randomUUID27 } from "crypto";
|
|
48421
48479
|
|
|
48422
48480
|
// src/commands/sessions/daemon/sessionBase.ts
|
|
48423
48481
|
function sessionBase(id, status2) {
|
|
@@ -48640,7 +48698,7 @@ function spawnRun(opts) {
|
|
|
48640
48698
|
function createSession(id, { prompt, cwd, design, auto, harness, holdPty } = {}) {
|
|
48641
48699
|
if (harness && harness !== "claude")
|
|
48642
48700
|
return createHarnessSession(id, harness, prompt, cwd, holdPty);
|
|
48643
|
-
const claudeSessionId =
|
|
48701
|
+
const claudeSessionId = randomUUID27();
|
|
48644
48702
|
return {
|
|
48645
48703
|
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
48646
48704
|
name: `Session ${id}`,
|
|
@@ -51546,7 +51604,7 @@ function codexRespawnPlan(session) {
|
|
|
51546
51604
|
}
|
|
51547
51605
|
|
|
51548
51606
|
// src/commands/sessions/daemon/interactiveRespawnPlan.ts
|
|
51549
|
-
import { randomUUID as
|
|
51607
|
+
import { randomUUID as randomUUID28 } from "crypto";
|
|
51550
51608
|
|
|
51551
51609
|
// src/commands/sessions/daemon/hasTranscriptOnDisk.ts
|
|
51552
51610
|
function hasTranscriptOnDisk(session) {
|
|
@@ -51573,7 +51631,7 @@ function interactiveRespawnPlan(session, resumes) {
|
|
|
51573
51631
|
return null;
|
|
51574
51632
|
}
|
|
51575
51633
|
function freshClaudePlan(session, prompt, cwd) {
|
|
51576
|
-
const claudeSessionId =
|
|
51634
|
+
const claudeSessionId = randomUUID28();
|
|
51577
51635
|
return {
|
|
51578
51636
|
spawn: () => {
|
|
51579
51637
|
session.claudeSessionId = claudeSessionId;
|
|
@@ -52977,6 +53035,66 @@ async function collectHistory(linked) {
|
|
|
52977
53035
|
return withRepoGroups(local).concat(remote);
|
|
52978
53036
|
}
|
|
52979
53037
|
|
|
53038
|
+
// src/commands/sessions/daemon/pins/PinRelay.ts
|
|
53039
|
+
var ORIGIN_TTL_MS = 30 * 60 * 1e3;
|
|
53040
|
+
var PinRelay = class {
|
|
53041
|
+
constructor(now = Date.now) {
|
|
53042
|
+
this.now = now;
|
|
53043
|
+
}
|
|
53044
|
+
origins = /* @__PURE__ */ new Map();
|
|
53045
|
+
deliveries = /* @__PURE__ */ new Map();
|
|
53046
|
+
confirms = /* @__PURE__ */ new Map();
|
|
53047
|
+
rememberOrigin(area, pin2, node) {
|
|
53048
|
+
this.origins.set(`${area}:${pin2}`, { node, at: this.now() });
|
|
53049
|
+
}
|
|
53050
|
+
takeOrigin(area, pin2) {
|
|
53051
|
+
const key = `${area}:${pin2}`;
|
|
53052
|
+
const origin = this.origins.get(key);
|
|
53053
|
+
this.origins.delete(key);
|
|
53054
|
+
if (!origin || this.now() - origin.at > ORIGIN_TTL_MS) return void 0;
|
|
53055
|
+
return origin.node;
|
|
53056
|
+
}
|
|
53057
|
+
awaitDelivery(requestId, timeoutMs, settle) {
|
|
53058
|
+
addWaiter(this.deliveries, requestId, timeoutMs, false, settle);
|
|
53059
|
+
}
|
|
53060
|
+
settleDelivery(requestId, delivered) {
|
|
53061
|
+
settleWaiter(this.deliveries, requestId, delivered);
|
|
53062
|
+
}
|
|
53063
|
+
awaitConfirm(requestId, client, timeoutMs, node) {
|
|
53064
|
+
addWaiter(
|
|
53065
|
+
this.confirms,
|
|
53066
|
+
requestId,
|
|
53067
|
+
timeoutMs,
|
|
53068
|
+
{ ok: false, message: `${node} did not answer the confirmation.` },
|
|
53069
|
+
(result) => sendTo(client, {
|
|
53070
|
+
type: "confirm-pin-result",
|
|
53071
|
+
requestId,
|
|
53072
|
+
found: true,
|
|
53073
|
+
...result
|
|
53074
|
+
})
|
|
53075
|
+
);
|
|
53076
|
+
}
|
|
53077
|
+
settleConfirm(requestId, result) {
|
|
53078
|
+
settleWaiter(this.confirms, requestId, result);
|
|
53079
|
+
}
|
|
53080
|
+
};
|
|
53081
|
+
function addWaiter(waiters, requestId, timeoutMs, onTimeout, settle) {
|
|
53082
|
+
const timer = setTimeout(
|
|
53083
|
+
() => settleWaiter(waiters, requestId, onTimeout),
|
|
53084
|
+
timeoutMs
|
|
53085
|
+
);
|
|
53086
|
+
timer.unref?.();
|
|
53087
|
+
waiters.set(requestId, { settle, timer });
|
|
53088
|
+
}
|
|
53089
|
+
function settleWaiter(waiters, requestId, value) {
|
|
53090
|
+
if (typeof requestId !== "string") return;
|
|
53091
|
+
const waiter = waiters.get(requestId);
|
|
53092
|
+
if (!waiter) return;
|
|
53093
|
+
waiters.delete(requestId);
|
|
53094
|
+
clearTimeout(waiter.timer);
|
|
53095
|
+
waiter.settle(value);
|
|
53096
|
+
}
|
|
53097
|
+
|
|
52980
53098
|
// src/commands/sessions/daemon/links/guardLinkCallback.ts
|
|
52981
53099
|
function guardLinkCallback(label, callback) {
|
|
52982
53100
|
return (...args) => {
|
|
@@ -53006,6 +53124,7 @@ function linkDeps(options2, callbacks) {
|
|
|
53006
53124
|
"links: history-changed handler",
|
|
53007
53125
|
callbacks.onHistoryChanged
|
|
53008
53126
|
),
|
|
53127
|
+
pins: callbacks.pins,
|
|
53009
53128
|
transport: options2.transport ?? connectLinkWebSocket,
|
|
53010
53129
|
reconnectMs: options2.reconnectMs ?? 3e3,
|
|
53011
53130
|
blockedRetryMs: options2.blockedRetryMs ?? 6e4,
|
|
@@ -53354,6 +53473,31 @@ function relayLinkMessage(state, msg) {
|
|
|
53354
53473
|
);
|
|
53355
53474
|
}
|
|
53356
53475
|
|
|
53476
|
+
// src/commands/sessions/daemon/links/showRelayedPin.ts
|
|
53477
|
+
function tryShow(title, message3) {
|
|
53478
|
+
if (typeof title !== "string" || typeof message3 !== "string") return false;
|
|
53479
|
+
try {
|
|
53480
|
+
return showNotification({ title, message: message3 });
|
|
53481
|
+
} catch {
|
|
53482
|
+
return false;
|
|
53483
|
+
}
|
|
53484
|
+
}
|
|
53485
|
+
function showRelayedPin(ctx, msg) {
|
|
53486
|
+
const node = ctx.spec.name;
|
|
53487
|
+
const { area, pin: pin2 } = msg;
|
|
53488
|
+
const valid = typeof area === "string" && typeof pin2 === "string";
|
|
53489
|
+
const delivered = valid && tryShow(msg.title, msg.message);
|
|
53490
|
+
if (delivered) ctx.deps.pins.rememberOrigin(area, pin2, node);
|
|
53491
|
+
daemonLog(
|
|
53492
|
+
`link ${node} ws: ${valid ? area : "malformed"} PIN notification for a session on ${node} ${delivered ? "shown" : "not shown"}`
|
|
53493
|
+
);
|
|
53494
|
+
sendToLink(ctx, {
|
|
53495
|
+
type: "notify-pin-result",
|
|
53496
|
+
requestId: msg.requestId,
|
|
53497
|
+
delivered
|
|
53498
|
+
});
|
|
53499
|
+
}
|
|
53500
|
+
|
|
53357
53501
|
// src/commands/sessions/daemon/links/scheduleReconnect.ts
|
|
53358
53502
|
function armReconnect(ctx, delay2) {
|
|
53359
53503
|
clearTimeout(ctx.reconnectTimer);
|
|
@@ -53435,7 +53579,20 @@ function onLinkLine(ctx, line) {
|
|
|
53435
53579
|
return;
|
|
53436
53580
|
}
|
|
53437
53581
|
if (msg.type === "hello") return onHello(ctx, msg);
|
|
53438
|
-
if (ctx.greeted)
|
|
53582
|
+
if (!ctx.greeted) return;
|
|
53583
|
+
if (msg.type === "notify-pin") return showRelayedPin(ctx, msg);
|
|
53584
|
+
if (msg.type === "confirm-pin-result") return settleRelayedConfirm(ctx, msg);
|
|
53585
|
+
relayLinkMessage(ctx.relay, msg);
|
|
53586
|
+
}
|
|
53587
|
+
function settleRelayedConfirm(ctx, msg) {
|
|
53588
|
+
const ok = msg.ok === true;
|
|
53589
|
+
daemonLog(
|
|
53590
|
+
`link ${ctx.spec.name} ws: PIN confirmation ${ok ? "approved" : "rejected"} by ${ctx.spec.name}`
|
|
53591
|
+
);
|
|
53592
|
+
ctx.deps.pins.settleConfirm(msg.requestId, {
|
|
53593
|
+
ok,
|
|
53594
|
+
message: typeof msg.message === "string" ? msg.message : ""
|
|
53595
|
+
});
|
|
53439
53596
|
}
|
|
53440
53597
|
|
|
53441
53598
|
// src/commands/sessions/daemon/links/openLink.ts
|
|
@@ -53574,6 +53731,7 @@ var NodeLinks = class {
|
|
|
53574
53731
|
}
|
|
53575
53732
|
links = /* @__PURE__ */ new Map();
|
|
53576
53733
|
options = {};
|
|
53734
|
+
pins = new PinRelay();
|
|
53577
53735
|
configure(options2) {
|
|
53578
53736
|
this.options = options2;
|
|
53579
53737
|
}
|
|
@@ -53583,7 +53741,8 @@ var NodeLinks = class {
|
|
|
53583
53741
|
viewers: () => this.clients.viewers(),
|
|
53584
53742
|
onSessionsChanged: this.onSessionsChanged,
|
|
53585
53743
|
onStateChanged: () => broadcast(this.clients.viewers(), this.nodes()),
|
|
53586
|
-
onHistoryChanged: () => void this.broadcastHistory()
|
|
53744
|
+
onHistoryChanged: () => void this.broadcastHistory(),
|
|
53745
|
+
pins: this.pins
|
|
53587
53746
|
});
|
|
53588
53747
|
reconcileLinks(this.links, specs, (spec) => new NodeLink(spec, deps2));
|
|
53589
53748
|
this.onSessionsChanged();
|
|
@@ -54135,7 +54294,10 @@ var handleHelloRequest = (client, m, d) => {
|
|
|
54135
54294
|
daemonLog(
|
|
54136
54295
|
`peer link from ${d.nodeName ?? "unknown node"} (${d.version ?? "unknown version"}); exporting local sessions only`
|
|
54137
54296
|
);
|
|
54138
|
-
m.clients.markPeer(
|
|
54297
|
+
m.clients.markPeer(
|
|
54298
|
+
client,
|
|
54299
|
+
typeof d.nodeName === "string" ? d.nodeName : void 0
|
|
54300
|
+
);
|
|
54139
54301
|
sendTo(client, { type: "sessions", sessions: m.localSessions(), active: {} });
|
|
54140
54302
|
m.replayLocal(client);
|
|
54141
54303
|
};
|
|
@@ -54708,6 +54870,121 @@ var lifecycleHandlers = {
|
|
|
54708
54870
|
shutdown: handleShutdown
|
|
54709
54871
|
};
|
|
54710
54872
|
|
|
54873
|
+
// src/commands/sessions/daemon/pins/pinConfirmers.ts
|
|
54874
|
+
var pinConfirmers = {
|
|
54875
|
+
docs: approveDocsUnlock
|
|
54876
|
+
};
|
|
54877
|
+
|
|
54878
|
+
// src/commands/sessions/daemon/pins/confirmPinLocally.ts
|
|
54879
|
+
async function confirmPinLocally(area, pin2) {
|
|
54880
|
+
const confirm = pinConfirmers[area];
|
|
54881
|
+
if (!confirm)
|
|
54882
|
+
return { ok: false, message: `Unknown confirmation area ${area}.` };
|
|
54883
|
+
try {
|
|
54884
|
+
return await confirm(pin2) ?? {
|
|
54885
|
+
ok: false,
|
|
54886
|
+
message: `No pending ${area} confirmation for that pin.`
|
|
54887
|
+
};
|
|
54888
|
+
} catch (error) {
|
|
54889
|
+
return {
|
|
54890
|
+
ok: false,
|
|
54891
|
+
message: error instanceof Error ? error.message : String(error)
|
|
54892
|
+
};
|
|
54893
|
+
}
|
|
54894
|
+
}
|
|
54895
|
+
|
|
54896
|
+
// src/commands/sessions/daemon/pins/handleConfirmPin.ts
|
|
54897
|
+
var CONFIRM_TIMEOUT_MS2 = 1e4;
|
|
54898
|
+
var handlePeerConfirm = (client, m, d) => {
|
|
54899
|
+
const area = String(d.area);
|
|
54900
|
+
const from = m.clients.peerNode(client) ?? "unknown node";
|
|
54901
|
+
void confirmPinLocally(area, String(d.pin)).then((result) => {
|
|
54902
|
+
daemonLog(
|
|
54903
|
+
`confirm-pin: ${area} confirmation relayed from ${from} ${result.ok ? "approved" : "rejected"}`
|
|
54904
|
+
);
|
|
54905
|
+
sendTo(client, {
|
|
54906
|
+
type: "confirm-pin-result",
|
|
54907
|
+
requestId: d.requestId,
|
|
54908
|
+
...result
|
|
54909
|
+
});
|
|
54910
|
+
});
|
|
54911
|
+
};
|
|
54912
|
+
var handleConfirmPin = (client, m, d) => {
|
|
54913
|
+
if (m.clients.isPeer(client)) return handlePeerConfirm(client, m, d);
|
|
54914
|
+
const area = String(d.area);
|
|
54915
|
+
const requestId = String(d.requestId);
|
|
54916
|
+
const node = m.links.pins.takeOrigin(area, String(d.pin));
|
|
54917
|
+
if (!node) {
|
|
54918
|
+
daemonLog(`confirm-pin: no relayed ${area} PIN matches; nothing forwarded`);
|
|
54919
|
+
sendTo(client, { type: "confirm-pin-result", requestId, found: false });
|
|
54920
|
+
return;
|
|
54921
|
+
}
|
|
54922
|
+
daemonLog(`confirm-pin: forwarding ${area} confirmation to ${node}`);
|
|
54923
|
+
m.links.pins.awaitConfirm(requestId, client, CONFIRM_TIMEOUT_MS2, node);
|
|
54924
|
+
m.links.route(client, { ...d, node });
|
|
54925
|
+
};
|
|
54926
|
+
|
|
54927
|
+
// src/commands/sessions/daemon/pins/pinNotificationTarget.ts
|
|
54928
|
+
function pinNotificationTarget(viewerNode, localNode, peerFor) {
|
|
54929
|
+
if (!viewerNode) return { kind: "local", reason: "has no active viewer" };
|
|
54930
|
+
if (viewerNode === localNode)
|
|
54931
|
+
return { kind: "local", reason: "is controlled from this node" };
|
|
54932
|
+
const peer = peerFor(viewerNode);
|
|
54933
|
+
if (!peer)
|
|
54934
|
+
return {
|
|
54935
|
+
kind: "local",
|
|
54936
|
+
reason: `is controlled from ${viewerNode}, which has no peer link here`
|
|
54937
|
+
};
|
|
54938
|
+
return { kind: "peer", node: viewerNode, peer };
|
|
54939
|
+
}
|
|
54940
|
+
|
|
54941
|
+
// src/commands/sessions/daemon/pins/handleNotifyPin.ts
|
|
54942
|
+
var DELIVERY_TIMEOUT_MS = 5e3;
|
|
54943
|
+
var handleNotifyPin = (client, m, d) => {
|
|
54944
|
+
const { sessionId, requestId, area } = d;
|
|
54945
|
+
const reply2 = (node) => sendTo(client, { type: "notify-pin-result", requestId, node });
|
|
54946
|
+
const target = pinNotificationTarget(
|
|
54947
|
+
m.localSessions().find((s) => s.id === sessionId)?.activeViewerNode,
|
|
54948
|
+
m.links.localNode(),
|
|
54949
|
+
(node) => m.clients.peerFor(node)
|
|
54950
|
+
);
|
|
54951
|
+
if (target.kind === "local") {
|
|
54952
|
+
daemonLog(
|
|
54953
|
+
`notify-pin: session ${sessionId} ${target.reason}; ${area} PIN notifies locally`
|
|
54954
|
+
);
|
|
54955
|
+
return reply2();
|
|
54956
|
+
}
|
|
54957
|
+
daemonLog(
|
|
54958
|
+
`notify-pin: session ${sessionId} relaying ${area} PIN notification to ${target.node}`
|
|
54959
|
+
);
|
|
54960
|
+
m.links.pins.awaitDelivery(
|
|
54961
|
+
String(requestId),
|
|
54962
|
+
DELIVERY_TIMEOUT_MS,
|
|
54963
|
+
(delivered) => {
|
|
54964
|
+
daemonLog(
|
|
54965
|
+
`notify-pin: session ${sessionId} ${area} PIN ${delivered ? `shown on ${target.node}` : `not shown on ${target.node}; notifying locally`}`
|
|
54966
|
+
);
|
|
54967
|
+
reply2(delivered ? target.node : void 0);
|
|
54968
|
+
}
|
|
54969
|
+
);
|
|
54970
|
+
const { title, message: message3, pin: pin2 } = d;
|
|
54971
|
+
sendTo(target.peer, {
|
|
54972
|
+
type: "notify-pin",
|
|
54973
|
+
requestId,
|
|
54974
|
+
area,
|
|
54975
|
+
pin: pin2,
|
|
54976
|
+
title,
|
|
54977
|
+
message: message3
|
|
54978
|
+
});
|
|
54979
|
+
};
|
|
54980
|
+
|
|
54981
|
+
// src/commands/sessions/daemon/pins/pinHandlers.ts
|
|
54982
|
+
var pinHandlers = {
|
|
54983
|
+
"notify-pin": handleNotifyPin,
|
|
54984
|
+
"notify-pin-result": (_client, m, d) => m.links.pins.settleDelivery(d.requestId, d.delivered === true),
|
|
54985
|
+
"confirm-pin": handleConfirmPin
|
|
54986
|
+
};
|
|
54987
|
+
|
|
54711
54988
|
// src/commands/sessions/daemon/handleSnapshotRequest.ts
|
|
54712
54989
|
var handleSnapshotRequest = (client, m, d) => {
|
|
54713
54990
|
const sessionId = d.sessionId;
|
|
@@ -54946,6 +55223,7 @@ var messageHandlers = {
|
|
|
54946
55223
|
),
|
|
54947
55224
|
"codex-usage": handleCodexUsage,
|
|
54948
55225
|
...viewerHandlers,
|
|
55226
|
+
...pinHandlers,
|
|
54949
55227
|
"type-prompt": handleTypePrompt,
|
|
54950
55228
|
"type-prompt-to-writer": handleTypePromptToWriter,
|
|
54951
55229
|
retry: routed((client, m, d) => {
|