@umage.ai/redline-agent 0.1.0 → 0.2.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/README.md +93 -48
- package/dist/index.cjs +1973 -263
- package/dist/panel.js +143 -46
- package/dist/terminal.js +18 -18
- package/package.json +2 -2
package/dist/panel.js
CHANGED
|
@@ -1,17 +1,51 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
.
|
|
4
|
-
.ag-
|
|
5
|
-
.ag-
|
|
6
|
-
.ag-
|
|
1
|
+
var yt="/__redline";async function $t(s){let i=await ze(s),r=async(n,m={})=>{let b=await fetch(`${s}${n}`,{method:"POST",headers:{"content-type":"application/json","x-agent-token":i.token},body:JSON.stringify(m)});if(!b.ok)throw new Error((await b.json().catch(()=>null))?.error??`HTTP ${b.status}`);return b.json()};return{get info(){return i},async refresh(){return i=await ze(s),i},post:r,watch(n,m,b){let w=null,E=!1,y=()=>{if(w?.close(),!E){w=new EventSource(`${s}/stream?status=1&token=${encodeURIComponent(i.token)}`);for(let T of["hello","status"])w.addEventListener(T,W=>n(JSON.parse(W.data)));w.addEventListener("clis",T=>{i.clis=JSON.parse(T.data),m?.(i.clis)}),w.onerror=async()=>{if(!(w?.readyState!==EventSource.CLOSED||E))try{i=await ze(s),b?.(i),setTimeout(y,1e3)}catch{}}}};return y(),()=>{E=!0,w?.close()}},stream(n){return new EventSource(`${s}/stream?id=${encodeURIComponent(n)}&token=${encodeURIComponent(i.token)}`)},send:(n,m={})=>r("/send",{text:n,...m}),start:(n={})=>r("/start",n),choose:(n,m,b)=>r("/choose",{id:n,index:m,...b===void 0?{}:{text:b}}),answer:(n,m)=>r("/answer",{id:n,choice:m}),input:(n,m)=>r("/input",{id:n,data:m}),resize:(n,m,b)=>r("/resize",{id:n,cols:m,rows:b}),ack:n=>r("/ack",{id:n}),mode:n=>r("/mode",{mode:n}),worktrees:n=>r("/worktrees",{on:n}),worktree:(n,m,b=!1)=>r("/worktree",{branch:n,action:m,confirm:b}),end:n=>r("/end",n?{id:n}:{})}}async function ze(s){let i=await fetch(`${s}/info`);if(!i.ok)throw new Error(`agent bridge: HTTP ${i.status}`);return i.json()}var He="redline.agent.cli",Oe="redline.agent.settings",St=()=>{try{return localStorage.getItem(He)}catch{return null}},je=s=>{try{s?localStorage.setItem(He,s):localStorage.removeItem(He)}catch{}};function Ct(){try{let s=JSON.parse(localStorage.getItem(Oe)??"{}");return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}var De=s=>{try{s&&Object.keys(s).length?localStorage.setItem(Oe,JSON.stringify(s)):localStorage.removeItem(Oe)}catch{}};function se(s,i,r){return s.find(n=>n.id===i)?.id??s.find(n=>n.id===r)?.id??s[0]?.id??""}function Be(s,i){let r=s?i[s.id]:void 0;if(!s||!r)return{};let n=r.model&&s.models?.some(b=>b.value===r.model)?r.model:void 0,m=r.effort&&s.efforts?.some(b=>b.value===r.effort)?r.effort:void 0;return{...n?{model:n}:{},...m?{effort:m}:{}}}var oe=`${yt}/agent`,en={blocked:4,working:3,error:2,done:1,idle:0};function We(s){let i,r=-1;for(let n of s){if(!n.running&&n.status.state!=="done"&&n.status.state!=="error")continue;let m=en[n.status.state]??0;m>=r&&(i=n,r=m)}return i}var It="#a3a3ad",tn="#5c5c66",nn="\x1B",Et="\x1B[D",Lt="\x1B[C",Tt="Apply notes",an=500;function Rt(s){let i=s.status;if(!s.running&&i.state!=="done"&&i.state!=="error")return null;let r=m=>`${s.command}: ${m}${i.progress!==void 0&&i.state==="working"?` ${i.progress}%`:""}${i.msg?` \xB7 ${i.msg}`:""}`,n={toolbar:"outline",launcher:"ring"};switch(i.state){case"working":return{...n,color:"#4f8cff",spin:!0,title:r(i.source==="activity"?"busy":"working")};case"blocked":return i.kind==="permission"?{...n,color:"#ff9f0a",pulse:!0,title:r("waiting for your approval")}:{...n,color:"#ffd60a",pulse:!0,title:r("waiting for your answer")};case"done":return{...n,color:"#3ecf8e",title:r("done")};case"error":return{...n,color:"#ff453a",title:r("failed")};default:return{color:It,toolbar:!1,launcher:!1,title:r("ready")}}}function Y(s){let i=s.status,r=i.msg||void 0;if(!s.running&&i.state!=="done"&&i.state!=="error")return{label:s.exitCode===void 0?"Not started":`Stopped${s.exitCode?` (exit ${s.exitCode})`:""}`,color:tn};let n=Rt(s)?.color??It;switch(i.state){case"working":return{label:i.progress!==void 0?`Working ${i.progress}%`:"Working\u2026",msg:r,color:n};case"blocked":return{label:i.kind==="permission"?"Needs your approval":"Needs your answer",msg:r,color:n};case"done":return{label:"Done",msg:r,color:n};case"error":return{label:"Failed",msg:r,color:n};default:return{label:"Ready",msg:r,color:n}}}function sn(s,i,r=qe(i)){let n=r.join(", ");return s.replace(/\{(page|url|ids)\}/g,(m,b)=>b==="page"?i.page():b==="url"?location.href:n||"none")}var qe=s=>s.notes("page").filter(i=>!i.done).map(i=>i.id);function on(s,i){let r=new Set(i.filter(n=>n.running).flatMap(n=>n.sent??[]));return qe(s).filter(n=>!r.has(n))}var Fe=s=>s.prompt.includes("{ids}"),Ke=s=>((s.body??"").trim()||(s.type==="text"?s.to??"":"")||s.type).replace(/\s+/g," ").trim(),_e=(s,i=18)=>{let r=s.replace(/\s+/g," ").trim();return r.length>i?r.slice(0,i-1).trimEnd()+"\u2026":r};function rn(s,i=""){return s.length?_e(Ke(s[0]))+(s.length>1?` +${s.length-1}`:""):i}function ln(s){let i=s.match(/\p{Lu}/gu)??[];return i.length?i.slice(0,2).join(""):s.split(/[\s._-]+/).filter(Boolean).slice(0,2).map(r=>r[0].toUpperCase()).join("")}function Ue(s){return s.running?s.status.state==="idle"?1:0:2}function dn(s,i,r=3){let n=new Set(s.filter(w=>w.id===i||w.running&&w.status.state==="blocked").map(w=>w.id)),m=[...s].reverse();for(let w of[0,1,2])for(let E of m)n.size<r&&Ue(E)===w&&n.add(E.id);let b=w=>w.map((E,y)=>({s:E,i:y})).sort((E,y)=>Ue(E.s)-Ue(y.s)||E.i-y.i).map(E=>E.s.id);return{shown:b(s.filter(w=>n.has(w.id))),hidden:b(s.filter(w=>!n.has(w.id)))}}var cn=/\.(png|jpe?g|gif|webp|avif|svg)$/i;function gn(s){try{let{hostname:i,protocol:r}=new URL(s);return/^https?:$/.test(r)&&/^(localhost|127(\.\d+){3}|\[::1\]|[^.]+\.localhost)$/i.test(i)}catch{return!1}}function pn(s){let i=s.filter(n=>n.source==="mentioned"),r=s.filter(n=>n.source!=="mentioned");return{images:r.filter(n=>n.kind==="image"||n.kind==="diff"&&n.status!=="D"&&cn.test(n.path??"")),changed:r.filter(n=>n.kind==="diff"),files:r.filter(n=>n.kind==="file"),links:r.filter(n=>n.kind==="url"),mentioned:i}}function Mt(s){let i=[s.ahead?`${s.ahead} commit${s.ahead===1?"":"s"}`:"",s.dirty?"uncommitted changes":""].filter(Boolean);return i.length?i.join(" \xB7 "):s.dirty===void 0?"checking\u2026":"no changes"}function Sn(s,i){return i.has(s.id)?s.done?"done":"sent":null}function un(s,i,r){let n=[...i].reverse().find(b=>b.sent?.includes(s.id));if(!n)return null;if(s.done)return{cls:"done",text:`\u2713 done by ${r(n)}`};let m=n.running?n.status.state:"stopped";return m==="working"?n.focus&&n.focus!==s.id?{cls:"sent",text:`\u2933 sent to ${r(n)}, next`}:{cls:"sent working",text:`${r(n)} is working on it`}:m==="blocked"?{cls:"sent asking",text:`${r(n)} needs your answer`}:{cls:"sent",text:`\u2933 sent to ${r(n)}`}}var J=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${s}</svg>`,fn={term:J('<rect x="3" y="4.5" width="18" height="15" rx="2.5"/><path d="M7.5 9.5l3 2.5-3 2.5"/><path d="M12.5 15h4"/>'),gear:J('<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>'),more:J('<circle cx="5" cy="12" r="1.4" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.4" fill="currentColor" stroke="none"/><circle cx="19" cy="12" r="1.4" fill="currentColor" stroke="none"/>'),x:J('<path d="M7 7l10 10M17 7L7 17"/>'),down:J('<path d="M7 10l5 5 5-5"/>'),clip:J('<path d="M20.5 11.5l-8.2 8.2a5 5 0 0 1-7.1-7.1l8.6-8.6a3.4 3.4 0 0 1 4.8 4.8l-8.6 8.6a1.7 1.7 0 0 1-2.4-2.4l7.9-7.9"/>'),branch:J('<circle cx="6" cy="5.5" r="2.2"/><circle cx="6" cy="18.5" r="2.2"/><circle cx="18" cy="8" r="2.2"/><path d="M6 7.7v8.6"/><path d="M18 10.2c0 4-4.5 3.8-10.4 7"/>')},V=s=>{let i=document.createElement("span");return i.className="ag-ic",i.innerHTML=fn[s],i},hn=`
|
|
2
|
+
.ag-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
3
|
+
.xbar[data-toolbar="agent"] button:focus-visible, .attach[data-toolbar="agent"] :is(button, input, select, label):focus-visible, .win-controls .ag-wend:focus-visible { outline: 2px solid var(--ink-2); outline-offset: 1px; }
|
|
4
|
+
.ag-ic { display: grid; place-items: center; width: 16px; height: 16px; flex: none; }
|
|
5
|
+
.ag-ic svg { width: 16px; height: 16px; display: block; }
|
|
6
|
+
.ag-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
|
|
7
|
+
/* the state: a fixed width, so the toolbar doesn't change size with every message (the full text is the hover) */
|
|
8
|
+
.ag-chip { display: flex; align-items: center; gap: 6px; padding: 0 8px; flex: none; width: 270px; box-sizing: border-box; color: var(--fg); white-space: nowrap; overflow: hidden; }
|
|
9
|
+
.ag-chip .ag-dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
|
|
10
|
+
.ag-chip .ag-who { flex: none; max-width: 120px; overflow: hidden; text-overflow: ellipsis; color: var(--fg-2); }
|
|
11
|
+
.ag-chip .ag-mid { flex: none; color: var(--fg-3); }
|
|
12
|
+
.ag-chip b { flex: none; font-weight: 650; }
|
|
7
13
|
.ag-chip .ag-msg { color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
|
|
8
|
-
|
|
9
|
-
.bar button.ag-
|
|
10
|
-
.bar button.ag-
|
|
14
|
+
/* the primary action, filled; long-press (or right-click, Alt+\u2193) switches the agent */
|
|
15
|
+
.bar button.ag-primary { background: var(--ink); color: #fff; font-weight: 650; padding: 6px 12px; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
|
|
16
|
+
.bar button.ag-primary:hover { background: var(--ink-2); color: #fff; }
|
|
17
|
+
.bar button.ag-primary[aria-disabled="true"] { cursor: default; background: var(--bg-3); color: var(--fg-3); }
|
|
18
|
+
.bar button.ag-primary .count { background: rgba(255,255,255,.25); color: #fff; }
|
|
19
|
+
.bar button.ag-icon { padding: 6px 7px; }
|
|
20
|
+
.bar button.ag-icon[aria-pressed="true"], .bar button.ag-icon[aria-expanded="true"] { background: var(--bg-3); color: var(--fg); }
|
|
21
|
+
.bar button.ag-term.ask { color: var(--fg); box-shadow: inset 0 0 0 1px #ff9f0a; }
|
|
22
|
+
/* session tabs: named by their notes; the dot is the state; seen and ended ones fade */
|
|
23
|
+
.ag-tabs { display: flex; align-items: center; gap: 2px; }
|
|
24
|
+
.ag-tab { display: flex; align-items: center; border-radius: 8px; transition: opacity .15s; }
|
|
25
|
+
.ag-tab:hover { background: var(--bg-2); }
|
|
26
|
+
.ag-tab.cur { background: var(--bg-3); }
|
|
27
|
+
.bar .ag-tab button { padding: 5px 2px 5px 8px; gap: 6px; background: none; }
|
|
28
|
+
.bar .ag-tab button:hover { background: none; color: var(--fg); }
|
|
29
|
+
.bar .ag-tab.cur button { color: var(--fg); }
|
|
30
|
+
.ag-tab .ag-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
|
|
31
|
+
.ag-tab[data-state="done"] .ag-name { font-weight: 700; color: var(--fg); }
|
|
32
|
+
.ag-tab:is([data-state="idle"], [data-state="seen"], [data-state="stopped"]):not(.cur):not(:hover):not(:focus-within) { opacity: .55; }
|
|
33
|
+
.ag-ini { flex: none; font-size: 10px; font-weight: 700; line-height: 1; padding: 2px 4px; border-radius: 4px; background: var(--bg-2); color: var(--fg-2); }
|
|
34
|
+
.bar .ag-tab button.ag-x { padding: 5px 7px 5px 4px; color: var(--fg-2); }
|
|
35
|
+
.ag-x .ag-ic, .ag-x .ag-ic svg { width: 12px; height: 12px; }
|
|
36
|
+
.bar .ag-tab button.ag-x:hover, .ag-row .ag-x:hover { color: var(--fg); }
|
|
37
|
+
.ag-x.armed, .bar .ag-tab button.ag-x.armed { color: #fff; background: #ff2d55; border-radius: 6px; padding: 3px 7px; margin-right: 2px; font-size: 12px; font-weight: 650; }
|
|
38
|
+
.bar button.ag-more { padding: 0 8px; height: 28px; font-variant-numeric: tabular-nums; }
|
|
39
|
+
.bar button.ag-more.lit { color: var(--fg); box-shadow: inset 0 0 0 1px var(--c); }
|
|
40
|
+
.bar .ag-phone { display: none; }
|
|
41
|
+
.bar button.ag-switch { gap: 6px; max-width: 150px; }
|
|
42
|
+
.ag-switch .ag-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
|
|
43
|
+
@keyframes ag-beat { 50% { opacity: .45; transform: scale(.75); } }
|
|
44
|
+
:is(.ag-chip, .ag-tab, .ag-switch, .ag-row, .ag-line)[data-state="working"] .ag-dot { animation: ag-beat 1.2s ease-in-out infinite; }
|
|
45
|
+
/* the notes panel: a status line and tags */
|
|
11
46
|
.ag-line { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 8px; background: var(--bg-2); color: var(--fg); text-align: left; cursor: pointer; }
|
|
12
47
|
.ag-line:hover { background: var(--bg-3); }
|
|
13
|
-
.ag-line .ag-dot { flex:
|
|
14
|
-
.ag-line span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
48
|
+
.ag-line span:not(.ag-dot) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
15
49
|
.ag-line kbd { flex: none; }
|
|
16
50
|
.ag-tag { display: inline-block; margin-top: 6px; padding: 1px 7px; border-radius: 9px; font-size: 11px; font-weight: 600; }
|
|
17
51
|
.ag-tag.sent { color: #8fb4ff; background: color-mix(in srgb, #4f8cff 18%, transparent); }
|
|
@@ -19,12 +53,10 @@ var ce="/__redline";var z=`${ce}/agent`,Ce={blocked:4,working:3,error:2,done:1,i
|
|
|
19
53
|
.ag-tag.working, .ag-tag.asking { cursor: pointer; }
|
|
20
54
|
.ag-tag.asking { color: #ffb340; background: color-mix(in srgb, #ff9f0a 18%, transparent); }
|
|
21
55
|
.ag-tag.working::before, .ag-tag.asking::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; vertical-align: 1px; animation: ag-beat 1.2s ease-in-out infinite; }
|
|
22
|
-
@
|
|
23
|
-
|
|
24
|
-
@media (prefers-reduced-motion: reduce) { .ag-tag::before, .ag-dot { animation: none !important; } }
|
|
56
|
+
@media (prefers-reduced-motion: reduce) { .ag-tag::before, .ag-dot { animation: none !important; } .ag-tab { transition: none; } }
|
|
57
|
+
/* the card: what the CLI asks */
|
|
25
58
|
.ag-card { display: grid; gap: 10px; font-size: 13px; }
|
|
26
59
|
.ag-card .ag-who { display: flex; align-items: center; gap: 7px; color: var(--fg-2); font-size: 12px; }
|
|
27
|
-
.ag-card .ag-who .ag-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
|
|
28
60
|
.ag-steps { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
|
|
29
61
|
.ag-steps button { padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--fg-2); font-size: 12px; }
|
|
30
62
|
.ag-steps button.cur { color: var(--fg); border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); }
|
|
@@ -41,43 +73,108 @@ var ce="/__redline";var z=`${ce}/agent`,Ce={blocked:4,working:3,error:2,done:1,i
|
|
|
41
73
|
.ag-opt .d { grid-column: 2; color: var(--fg-2); font-size: 12px; line-height: 1.35; }
|
|
42
74
|
.ag-input { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 5px 6px 5px 10px; border-radius: 8px; border: 1px dashed var(--line); }
|
|
43
75
|
.ag-input input { min-width: 0; background: transparent; border: 0; outline: 0; color: var(--fg); font: inherit; padding: 4px 0; }
|
|
44
|
-
.ag-input button, .ag-foot button { padding:
|
|
76
|
+
.ag-input button, .ag-foot button, .ag-set footer button { padding: 5px 10px; border-radius: 7px; background: var(--bg-3); color: var(--fg); }
|
|
77
|
+
.ag-input button:hover, .ag-foot button:hover, .ag-set footer button:hover { background: color-mix(in srgb, var(--fg) 12%, var(--bg-3)); }
|
|
78
|
+
.ag-ask { display: flex; gap: 8px; }
|
|
79
|
+
.ag-ask button { padding: 7px 14px; border-radius: 8px; background: var(--bg-3); color: var(--fg); font-weight: 600; }
|
|
80
|
+
.ag-ask button.ag-allow { background: #3ecf8e; color: #08130d; }
|
|
81
|
+
.ag-ask button.ag-allow:hover { background: #5fdca3; }
|
|
82
|
+
.ag-ask button.ag-deny:hover { background: color-mix(in srgb, #ff453a 25%, var(--bg-3)); }
|
|
45
83
|
.ag-foot { display: flex; align-items: center; gap: 8px; color: var(--fg-2); font-size: 11.5px; }
|
|
46
84
|
.ag-foot span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
47
|
-
|
|
48
|
-
.
|
|
49
|
-
.ag-
|
|
50
|
-
.ag-
|
|
51
|
-
.ag-
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
.ag-
|
|
57
|
-
.ag-
|
|
58
|
-
.ag-
|
|
85
|
+
/* menus and the session list */
|
|
86
|
+
.ag-list { display: grid; gap: 4px; font-size: 13px; min-width: min(360px, calc(100vw - 48px)); }
|
|
87
|
+
.ag-list h4, .ag-set h4 { margin: 0 0 4px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-2); }
|
|
88
|
+
.ag-mi { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg-2); color: var(--fg); text-align: left; cursor: pointer; border: 1px solid transparent; }
|
|
89
|
+
.ag-mi:hover, .ag-mi:focus-visible { background: var(--bg-3); }
|
|
90
|
+
.ag-mi b { font-weight: 650; }
|
|
91
|
+
.ag-mi span { margin-left: auto; color: var(--fg-2); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
92
|
+
.ag-mi[aria-checked]::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--fg-2); }
|
|
93
|
+
.ag-mi[aria-checked="true"] { border-color: color-mix(in srgb, var(--ink) 55%, var(--line)); }
|
|
94
|
+
.ag-mi[aria-checked="true"]::before { background: var(--ink); box-shadow: none; }
|
|
95
|
+
.ag-mi[aria-disabled="true"] { opacity: .5; cursor: default; }
|
|
96
|
+
.ag-hint { color: var(--fg-3); font-size: 11.5px; padding: 2px 2px 0; }
|
|
97
|
+
.ag-row { display: flex; align-items: center; border-radius: 8px; background: var(--bg-2); border: 1px solid transparent; }
|
|
59
98
|
.ag-row:hover { background: var(--bg-3); }
|
|
60
99
|
.ag-row.cur { border-color: color-mix(in srgb, var(--c) 60%, var(--line)); }
|
|
61
|
-
.ag-row .ag-
|
|
100
|
+
.ag-row .ag-row-main { flex: 1; min-width: 0; display: grid; grid-template-columns: 8px auto auto 1fr; gap: 8px; align-items: center; padding: 8px 4px 8px 10px; color: var(--fg); text-align: left; cursor: pointer; }
|
|
62
101
|
.ag-row .l { font-variant-numeric: tabular-nums; color: var(--fg-2); }
|
|
63
102
|
.ag-row .m { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); }
|
|
64
|
-
.ag-row .ag-x { padding:
|
|
65
|
-
.ag-row .ag-
|
|
66
|
-
|
|
67
|
-
.ag-
|
|
68
|
-
.ag-
|
|
69
|
-
.ag-
|
|
70
|
-
.ag-
|
|
71
|
-
.
|
|
72
|
-
.
|
|
73
|
-
.ag-
|
|
74
|
-
|
|
75
|
-
|
|
103
|
+
.ag-row .ag-x { flex: none; display: flex; align-items: center; padding: 8px 10px; color: var(--fg-2); }
|
|
104
|
+
.ag-row:is([data-state="idle"], [data-state="seen"], [data-state="stopped"]) .ag-row-main { opacity: .7; }
|
|
105
|
+
/* settings (\u2699) */
|
|
106
|
+
.ag-set { display: grid; gap: 14px; font-size: 13px; min-width: min(360px, calc(100vw - 48px)); }
|
|
107
|
+
.ag-set fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 4px; min-width: 0; }
|
|
108
|
+
.ag-set legend, .ag-set .ag-lbl { padding: 0; margin: 0 0 6px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-2); }
|
|
109
|
+
.ag-radio { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; background: var(--bg-2); color: var(--fg); cursor: pointer; border: 1px solid transparent; }
|
|
110
|
+
.ag-radio:hover { background: var(--bg-3); }
|
|
111
|
+
.ag-radio:has(input:checked) { border-color: color-mix(in srgb, var(--ink) 55%, var(--line)); }
|
|
112
|
+
.ag-radio input { accent-color: var(--ink); margin: 0; flex: none; }
|
|
113
|
+
.ag-radio span { min-width: 0; }
|
|
114
|
+
.ag-radio small { margin-left: auto; color: var(--fg-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
115
|
+
.ag-field { display: grid; gap: 0; }
|
|
116
|
+
.ag-field select { width: 100%; font: inherit; color: var(--fg); background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; }
|
|
117
|
+
.ag-field select:disabled { opacity: .6; }
|
|
118
|
+
.ag-set :is(.ag-note, .ag-help) { color: var(--fg-2); font-size: 12px; line-height: 1.4; }
|
|
119
|
+
.ag-set footer { display: flex; align-items: center; gap: 8px; color: var(--fg-2); font-size: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
|
|
120
|
+
.ag-set footer span { flex: 1; }
|
|
121
|
+
/* attachments (D56): the \u{1F4CE} on a tab, and the card's list */
|
|
122
|
+
.bar .ag-tab button.ag-att { padding: 5px 2px 5px 4px; gap: 2px; color: var(--fg-2); font-size: 11px; font-variant-numeric: tabular-nums; }
|
|
123
|
+
.ag-att .ag-ic, .ag-att .ag-ic svg { width: 13px; height: 13px; }
|
|
124
|
+
.bar .ag-tab button.ag-att:hover, .bar .ag-tab button.ag-att[aria-expanded="true"] { color: var(--fg); }
|
|
125
|
+
.ag-files { max-height: min(60vh, 560px); overflow: auto; }
|
|
126
|
+
.ag-round { display: grid; gap: 4px; padding: 6px 0 8px; border-top: 1px solid var(--line); }
|
|
127
|
+
.ag-round:first-of-type { border-top: 0; padding-top: 0; }
|
|
128
|
+
.ag-round-h { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
|
|
129
|
+
.ag-round-h span { color: var(--fg-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
|
130
|
+
.ag-round-h .ag-live { color: #8fb4ff; }
|
|
131
|
+
.ag-sub { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-2); }
|
|
132
|
+
.ag-num { font: 600 11.5px ui-monospace, Consolas, monospace; text-transform: none; letter-spacing: 0; }
|
|
133
|
+
.ag-num i { font-style: normal; } .ag-num .add, .ag-diff .add { color: #3ecf8e; } .ag-num .del, .ag-diff .del { color: #ff6b6b; } .ag-diff .hunk { color: #8fb4ff; }
|
|
134
|
+
.ag-frow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; background: var(--bg-2); color: var(--fg); text-align: left; text-decoration: none; min-width: 0; cursor: pointer; border: 0; font: inherit; font-size: 12.5px; }
|
|
135
|
+
.ag-frow:hover { background: var(--bg-3); }
|
|
136
|
+
.ag-frow.ag-ext, div.ag-frow { cursor: text; user-select: text; }
|
|
137
|
+
.ag-frow.dim { opacity: .75; }
|
|
138
|
+
.ag-frow .ag-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
|
|
139
|
+
.ag-frow .ag-t { color: var(--fg-2); font-size: 12px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
140
|
+
.ag-st { flex: none; width: 16px; text-align: center; font: 700 11px ui-monospace, Consolas, monospace; color: var(--fg-2); }
|
|
141
|
+
.ag-thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
142
|
+
.ag-thumb { padding: 0; border-radius: 7px; border: 1px solid var(--line); background: var(--bg-2); cursor: zoom-in; overflow: hidden; }
|
|
143
|
+
.ag-thumb img { display: block; width: 96px; height: 64px; object-fit: cover; }
|
|
144
|
+
.ag-diff { max-height: 220px; }
|
|
145
|
+
.ag-ment summary { cursor: pointer; color: var(--fg-2); font-size: 12px; padding: 4px 2px; }
|
|
146
|
+
.ag-ment { display: grid; gap: 4px; }
|
|
147
|
+
/* ended sessions' branches (D64) */
|
|
148
|
+
.ag-bc { display: flex; align-items: center; gap: 4px; }
|
|
149
|
+
.bar button.ag-branches .count { background: var(--bg-3); color: var(--fg); }
|
|
150
|
+
.ag-wt { display: grid; gap: 6px; padding: 8px 10px; border-radius: 8px; background: var(--bg-2); }
|
|
151
|
+
.ag-wt-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
|
152
|
+
.ag-wt-head b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
153
|
+
.ag-wt-head span:last-child { margin-left: auto; color: var(--fg-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
|
154
|
+
.ag-wt-sub { color: var(--fg-2); font-size: 12px; overflow-wrap: anywhere; }
|
|
155
|
+
.ag-wt-acts { display: flex; gap: 6px; flex-wrap: wrap; }
|
|
156
|
+
.ag-wt-acts button { padding: 5px 10px; border-radius: 7px; background: var(--bg-3); color: var(--fg); }
|
|
157
|
+
.ag-wt-acts button:hover:not(:disabled) { background: color-mix(in srgb, var(--fg) 12%, var(--bg-3)); }
|
|
158
|
+
.ag-wt-acts button:disabled { opacity: .5; cursor: default; }
|
|
159
|
+
.ag-wt-acts button.ag-wt-discard:hover, .ag-wt-acts button.ag-wt-discard.armed { background: #ff2d55; color: #fff; }
|
|
160
|
+
.ag-radio.off { opacity: .6; cursor: default; }
|
|
161
|
+
/* the CLI window's header */
|
|
162
|
+
.win-controls button.ag-wend { color: #ff6b85; }
|
|
163
|
+
.win-controls button.ag-wend:hover { background: color-mix(in srgb, #ff2d55 20%, var(--bg-3)); color: #fff; }
|
|
164
|
+
.win-controls button.ag-wend.armed { background: #ff2d55; color: #fff; }
|
|
165
|
+
/* phones: what fits one row. The outline says the state; the session button (its dot the state) opens
|
|
166
|
+
the list with every session and End; the prompts, >_ and \u2699 stay. */
|
|
76
167
|
@media (max-width: 560px) {
|
|
77
|
-
.ag-chip, .ag-chip + .sep { display: none; }
|
|
78
168
|
.bar .ag-desk { display: none; }
|
|
79
169
|
.bar .ag-phone { display: flex; }
|
|
80
|
-
.bar button.ag-switch { padding: 6px
|
|
81
|
-
.ag-
|
|
82
|
-
|
|
83
|
-
|
|
170
|
+
.bar button.ag-switch { padding: 6px 7px; max-width: 92px; }
|
|
171
|
+
.bar button.ag-primary { padding: 6px 10px; }
|
|
172
|
+
.bar button.ag-primary .ag-wide { display: none; }
|
|
173
|
+
.bar button.ag-icon { padding: 6px; }
|
|
174
|
+
.ag-row .ag-row-main { grid-template-columns: 8px auto auto 1fr; padding: 10px 4px 10px 8px; }
|
|
175
|
+
.ag-radio { padding: 9px 10px; }
|
|
176
|
+
}`,O=()=>Object.assign(document.createElement("style"),{textContent:hn});function t(s,i={},...r){let{class:n,data:m,attrs:b,...w}=i,E=Object.assign(document.createElement(s),w);n&&(E.className=n);for(let[y,T]of Object.entries(m??{}))E.dataset[y]=T;for(let[y,T]of Object.entries(b??{}))T!==!1&&T!==void 0&&E.setAttribute(y,T);return E.append(...r.filter(y=>!!y)),E}function mn(s,i){s.addEventListener("keydown",r=>{let n=i.indexOf(r.target);if(n<0)return;let m=r.key==="ArrowDown"?n+1:r.key==="ArrowUp"?n-1:r.key==="Home"?0:r.key==="End"?i.length-1:null;m!==null&&(r.preventDefault(),i[(m+i.length)%i.length].focus())})}async function bn(s){if(!(s.version>=5)||typeof s.addToolbar!="function")return;let i,r;try{i=await $t(oe),r=i.info}catch{return}let n=r,m=()=>r.command,b=()=>r.clis??[],w=()=>b().length>1,E=e=>b().find(a=>a.id===e),y=se(b(),St(),r.cli),T=Ct(),W=()=>E(y),F=()=>W()?.name??m(),D=e=>E(e.cli)?.name??b()[0]?.name??m(),At=()=>({id:"",label:"",running:!1,command:m(),cli:y,status:{state:"idle",source:"none"},sent:[]}),z=null,L=()=>n.sessions.find(e=>e.id===z)??n.sessions[n.sessions.length-1]??At(),Nt=()=>n.sessions.length>1,X=()=>n.mode==="fresh",P=e=>Nt()&&e.label?`${D(e)} ${e.label}`:D(e),U=e=>e.title||e.label,Ge=new Set,Ve=e=>`${e.id}:${e.status.msg??""}`,Ye=e=>e.running&&e.status.state==="done"&&Ge.has(Ve(e)),Je=e=>e.running?Ye(e)?"seen":e.status.state:"stopped",Pt=()=>new Set(n.sessions.flatMap(e=>e.sent??[])),Xe=()=>r.hotkey?r.hotkey.split("+").map(e=>e.length===1?e.toUpperCase():e[0].toUpperCase()+e.slice(1)).join("+"):"",me=e=>{let a=s.notes("all");return e.map(o=>a.find(l=>l.id===o)).filter(o=>!!o)},K=(e,a={})=>i.post(e,a),Z=(e,a={})=>K(e,{...a,...L().id?{id:L().id}:{}}),H=e=>s.toast(`Agent: ${e.message}`,!0),be=()=>on(s,n.sessions),Ze=async e=>{let a=Fe(e)?be():[];X()?s.toast(`Starting a new ${F()} session\u2026`):(!L().running||w()&&L().cli!==y)&&s.toast(`Starting ${F()}\u2026`);try{let o=await K("/send",{text:sn(e.prompt,s,a),notes:a,title:rn(me(a),e.label),task:e.label,...!X()&&L().id?{id:L().id}:{},...w()?{cli:y}:{},...Be(W(),T)});o?.id&&(z=o.id,R())}catch(o){H(o)}},Qe=e=>{Z("/answer",{choice:e}).catch(H)},ne=!1,et=async(e,a)=>{ne=!0,C?.render();try{await Z("/choose",a===void 0?{index:e}:{index:e,text:a})}catch(o){H(o)}finally{setTimeout(()=>{ne=!1,C?.render()},400)}},re=e=>{Z("/input",{data:e}).catch(H)},tt=new Set,we={id:"",asking:!1},ke=!1,k=null,I=null,ve=null,nt=null,ie=()=>ve?.getRootNode(),zt=()=>{let e=ie()?.activeElement;I||!e||!(ve?.contains(e)||nt?.contains(e))||(I=e.closest("[data-k]")?.dataset.k??null)},Ht=()=>{let e=I,a=ie();if(I=null,!e||!a||!("querySelector"in a))return;let o=a.querySelector(`[data-k="${CSS.escape(e)}"]`);o&&a.activeElement!==o&&o.focus()},_=(e,a=null)=>{k=k===e?null:e,I=k?a:I,C?.render()},Ot={list:"more",switch:"primary",cmds:"more-cmds",settings:"gear",branches:"branches",files:"att"},ae=()=>{if(!k)return!1;let e=k==="list"&&matchMedia("(max-width: 560px)").matches?"sw":Ot[k];return k=null,I=e,C?.render(),!0},B=null,xe=0,ye=e=>e.running&&(e.status.state==="working"||e.status.state==="blocked"),at=()=>{C?.render(),Re()},st=e=>{if(ye(e)&&B!==e.id){B=e.id,clearTimeout(xe),xe=window.setTimeout(()=>{B=null,at()},2500),at();return}B=null,clearTimeout(xe),K("/end",{id:e.id}).then(()=>{e.worktree&&(k="branches",I=`wt-keep:${e.worktree.branch}`,C?.render())}).catch(H)},ot=e=>B===e.id?`Press again to end ${P(e)}`:e.running?`End ${P(e)}: stop the CLI and close the session${ye(e)?" (asks first)":""}`:`Close ${P(e)} (ended)`,rt=(e,a)=>t("button",{class:"ag-x"+(B===e.id?" armed":""),title:ot(e),data:{end:e.id,k:a},attrs:{"aria-label":B===e.id?`Press again to end ${U(e)}`:`End ${U(e)}`},onclick:o=>{o.stopPropagation(),st(e)}},B===e.id?"End?":V("x")),j=null,it=e=>j?.contentWindow?.postMessage(e,location.origin),$e=()=>`${oe}/terminal${L().id?`?id=${encodeURIComponent(L().id)}`:""}`,Q=null,le=null,C=null,Se=null,Ce=new Map,Ee=t("span",{class:"ag-sr",attrs:{role:"status"}}),lt=e=>s.addButton({id:"agent",label:"Agent",key:r.key===!1?void 0:r.key||"a",title:e??`${F()}: agent toolbar${r.hotkey?` \xB7 ${Xe()} from anywhere`:""}`,onClick:()=>C?.show(),active:()=>!!C?.isOpen()});lt();let dt=e=>{let a=Y(e),o=me(e.sent??[]);return[`${e.label} \xB7 ${D(e)} \xB7 ${a.label}`,e.task&&`Prompt: ${e.task}`,o.length?`Notes: ${o.slice(0,3).map(l=>_e(Ke(l),40)).join("; ")}${o.length>3?` (+${o.length-3})`:""}`:e.sent?.length?`Notes: ${e.sent.length}`:"",[e.model&&`Model: ${e.model}`,e.effort&&`Effort: ${e.effort}`].filter(Boolean).join(" \xB7 "),e.focus&&e.running&&`On: ${(l=>l?_e(Ke(l),50):e.focus)(me([e.focus])[0])}`,e.worktree&&`Branch: ${e.worktree.branch} (${e.worktree.path})`,a.msg&&`Last: ${a.msg}`,e.status.state==="blocked"&&e.running?"Click to answer":""].filter(Boolean).join(`
|
|
177
|
+
`)},de=0,ee=!1,jt=e=>{if(!w()||e.button!==0)return;ee=!1,clearTimeout(de);let a=e.clientX,o=e.clientY,l=c=>{Math.hypot(c.clientX-a,c.clientY-o)>10&&clearTimeout(de)},f=()=>{clearTimeout(de);for(let c of["pointerup","pointercancel"])window.removeEventListener(c,f,!0);window.removeEventListener("pointermove",l,!0),ee&&setTimeout(()=>{ee=!1},50)};de=window.setTimeout(()=>{ee=!0,k=null,_("switch",`cli:${y}`)},an);for(let c of["pointerup","pointercancel"])window.addEventListener(c,f,!0);window.addEventListener("pointermove",l,!0)};function Dt(e,a){let o=Fe(e)?be().length:-1,l=o>=0?qe(s).length-o:0,f=e.label===Tt&&o>=0?t("span",{},o?`Apply ${o}`:"Apply",t("span",{class:"ag-wide"},o===1?" note":" notes")):e.label,c=o===0||a&&!X(),p="Hold, right-click or Alt+\u2193 to switch the agent",u=t("button",{class:"ag-primary",data:{k:"primary",cmd:e.label,...o>=0?{count:String(o)}:{}},title:[e.title??e.prompt,`with ${F()}`,X()&&"in a new session",l&&`${l} note${l===1?" is":"s are"} already with a session`,o===0&&"no open notes on this page",w()&&p].filter(Boolean).join(" \xB7 "),attrs:{"aria-disabled":c?"true":void 0,"aria-keyshortcuts":w()?"Alt+ArrowDown Shift+F10":void 0,"aria-description":w()?`Runs ${F()}. ${p}.`:void 0},onclick:()=>{if(ee){ee=!1;return}c||Ze(e)}},f,o>=0&&e.label!==Tt?t("span",{class:"count"},String(o)):null);return u.addEventListener("pointerdown",jt),u.addEventListener("contextmenu",d=>{w()&&(d.preventDefault(),k!=="switch"&&_("switch",`cli:${y}`))}),u.addEventListener("keydown",d=>{!w()||!(d.altKey&&d.key==="ArrowDown"||d.shiftKey&&d.key==="F10"||d.key==="ContextMenu")||(d.preventDefault(),k!=="switch"&&_("switch",`cli:${y}`))}),u}function Bt(e){zt(),ve=e;let a=L(),o=Y(a),l=a.status,f=a.running&&l.state==="blocked",c=f&&(!!a.prompt?.options.length||l.kind==="permission"&&r.approve),p=(h,te,Ne,Pe="",fe="",he={})=>t("button",{class:Pe,title:te,onclick:Ne,data:fe?{k:fe}:{},attrs:he},h),u=(h="")=>t("div",{class:`sep ${h}`});a.running&&l.state==="done"&&Ge.add(Ve(a));let d=`${D(a)} \xB7 ${o.label}`;Ee.textContent!==d&&(Ee.textContent=d);let v=t("div",{class:"ag-chip ag-desk",title:`${P(a)}: ${o.label}${o.msg?` \xB7 ${o.msg}`:""}`,data:{state:a.running?l.state:"stopped"}},t("span",{class:"ag-dot"}),t("span",{class:"ag-who"},D(a)),t("span",{class:"ag-mid",attrs:{"aria-hidden":"true"}}," \xB7 "),t("b",{},o.label),o.msg&&!c?t("span",{class:"ag-msg"},o.msg):null);v.style.setProperty("--c",o.color);let g=dn(n.sessions.map(h=>Ye(h)?{...h,status:{...h.status,state:"idle"}}:h),a.id),x=n.sessions.filter(h=>g.hidden.includes(h.id)),$=null;if(x.length){let h=We(x.filter(ye));$=p(`+${x.length}`,`${x.length} more session${x.length===1?"":"s"}: show all`,()=>_("list",`row:${x[0].id}`),"ag-more"+(h?" lit":""),"more",{"aria-haspopup":"dialog","aria-expanded":String(k==="list"),"aria-label":`${x.length} more sessions`}),h&&$.style.setProperty("--c",Y(h).color)}let S=new Set(n.sessions.map(h=>h.cli)).size>1,M=n.sessions.length?t("div",{class:"ag-tabs ag-desk",attrs:{role:"group","aria-label":"Sessions"}},...g.shown.map(h=>n.sessions.find(te=>te.id===h)).map(h=>{let te=Y(h),Ne=Je(h),Pe=t("button",{class:"ag-tab-main",title:dt(h),data:{k:`tab:${h.id}`},attrs:{"aria-current":h.id===a.id?"true":void 0,"aria-label":`${U(h)}, ${D(h)}, ${te.label}`},onclick:()=>{z=h.id,k=null,R()}},t("span",{class:"ag-dot"}),S?t("span",{class:"ag-ini",attrs:{"aria-hidden":"true"}},ln(D(h))):null,t("span",{class:"ag-name"},U(h))),fe=h.attachments?t("button",{class:"ag-att",title:`${h.attachments} attachment${h.attachments===1?"":"s"}: files changed, images, links`,data:{k:`att:${h.id}`},attrs:{"aria-label":`${h.attachments} attachment${h.attachments===1?"":"s"} of ${U(h)}`,"aria-haspopup":"dialog","aria-expanded":String(k==="files"&&h.id===a.id)},onclick:Qt=>{Qt.stopPropagation();let xt=k==="files"&&z===h.id;z=h.id,k=xt?null:"files",I=xt?`att:${h.id}`:"files-first",R()}},V("clip"),t("span",{},String(h.attachments))):null,he=t("div",{class:"ag-tab"+(h.id===a.id?" cur":""),data:{id:h.id,state:Ne}},Pe,fe,rt(h,`x:${h.id}`));return he.style.setProperty("--c",te.color),he}),$,u()):null,A=p(t("span",{class:"ag-name"},a.id?U(a):"Sessions"),"All sessions",()=>_("list",a.id?`row:${a.id}`:"list-done"),"ag-switch ag-phone","sw",{"aria-haspopup":"dialog","aria-expanded":String(k==="list"),"aria-label":`Sessions: ${a.id?`${U(a)}, ${o.label}`:"none"}`});A.prepend(t("span",{class:"ag-dot"})),A.append(V("down")),A.style.setProperty("--c",o.color),A.dataset.state=a.running?l.state:"stopped";let[N,...q]=r.commands,ue=N?[Dt(N,f)]:[];q.length&&ue.push(p(V("more"),"More prompts",()=>_("cmds","cmd:0"),"ag-icon ag-cmds","more-cmds",{"aria-label":"More prompts","aria-haspopup":"menu","aria-expanded":String(k==="cmds")}));let Ae=!!Q?.isOpen(),wt=f&&!c,kt=p(V("term"),Ae?"Hide the CLI window (the session keeps running)":wt?`${P(a)} is asking: answer in the CLI window`:`Show ${P(a)}'s CLI window`,()=>Q?.toggle(),"ag-icon ag-term"+(wt&&!Ae?" ask":""),"term",{"aria-label":"CLI window","aria-pressed":String(Ae)});kt.dataset.cli="";let Xt=w()?`set-cli:${y}`:W()?.models?.length||W()?.pending?"set-model":W()?.efforts?.length?"set-effort":`set-mode:${n.mode}`,Zt=p(V("gear"),"Agent settings: CLI, model, effort, sessions",()=>_("settings",Xt),"ag-icon ag-gear","gear",{"aria-label":"Agent settings","aria-haspopup":"dialog","aria-expanded":String(k==="settings")}),G=n.worktrees?.left??[],vt=G.length?p(t("span",{class:"ag-bc"},V("branch"),t("span",{class:"count"},String(G.length))),`${G.length} ended session${G.length===1?"":"s"}' branch${G.length===1?"":"es"}: keep, merge or discard`,()=>_("branches",`wt-keep:${G[0].branch}`),"ag-icon ag-branches","branches",{"aria-label":`${G.length} branch${G.length===1?"":"es"} to keep, merge or discard`,"aria-haspopup":"dialog","aria-expanded":String(k==="branches")}):null;e.replaceChildren(O(),Ee,v,u("ag-desk"),...M?[M]:[],A,...ue,u("ag-desk"),...vt?[vt]:[],kt,Zt),queueMicrotask(Ht)}function Wt(e){if(nt=e,k==="settings")return void e.append(O(),pt());if(k==="switch"&&w())return void e.append(O(),Ft());if(k==="cmds")return void e.append(O(),Ut());if(k==="list")return Yt(e);if(k==="branches")return void e.append(O(),Vt());if(k==="files")return void e.append(O(),Gt());let a=L(),o=a.running?a.prompt:void 0,l=Y(a),f=t("div",{class:"ag-card",data:{kind:a.status.kind??"",session:a.id},attrs:{role:"group","aria-label":`${P(a)} asks`}});if(f.style.setProperty("--c",l.color),f.append(t("div",{class:"ag-who"},t("span",{class:"ag-dot"}),`${P(a)}${a.title?` \xB7 ${a.title}`:""} \xB7 ${l.label}`)),!o?.options.length){if(!(a.running&&a.status.state==="blocked"&&a.status.kind==="permission"&&r.approve))return;l.msg&&f.append(t("div",{class:"ag-q"},l.msg)),f.append(t("div",{class:"ag-ask"},t("button",{class:"ag-allow",title:`Approve (${P(a)}'s prompt)`,data:{k:"allow"},onclick:()=>Qe("allow")},"Allow"),t("button",{class:"ag-deny",title:"Decline",data:{k:"deny"},onclick:()=>Qe("deny")},"Deny")),t("div",{class:"ag-foot"},t("span",{},"Its own prompt is in the CLI window"),t("button",{title:`Show ${P(a)}'s CLI window`,onclick:()=>Q?.show()},"Open CLI window"))),e.append(O(),f);return}if(o.steps?.length){let p=o.steps.findIndex(d=>d.current),u=d=>{p>=0&&d!==p&&re((d>p?Lt:Et).repeat(Math.abs(d-p)))};f.append(t("div",{class:"ag-steps"},t("button",{class:"nav",title:"Previous question",attrs:{"aria-label":"Previous question"},onclick:()=>re(Et)},"\u2190"),...o.steps.map((d,v)=>t("button",{class:(d.current?"cur ":"")+d.state,title:d.label,attrs:{"aria-current":d.current?"step":void 0},onclick:()=>u(v)},(d.state==="done"?"\u2612 ":d.state==="submit"?"\u2714 ":"\u2610 ")+d.label)),t("button",{class:"nav",title:"Next question",attrs:{"aria-label":"Next question"},onclick:()=>re(Lt)},"\u2192")))}o.lines.length&&f.append(t("pre",{class:"ag-ctx"},...o.lines.flatMap((p,u)=>[...u?[`
|
|
178
|
+
`]:[],...p.map(Jt)]))),o.question&&f.append(t("div",{class:"ag-q"},o.question));let c=t("div",{class:"ag-opts"});o.options.forEach((p,u)=>{let d=t("span",{class:"n",attrs:{"aria-hidden":"true"}},String(p.n??u+1));if(p.input){let v=t("input",{placeholder:p.label.replace(/\.$/,"")+"\u2026",disabled:ne,data:{k:`opt:${u}`},attrs:{"aria-label":p.label.replace(/\.$/,"")}}),g=()=>{let x=v.value.trim();x&&(v.blur(),et(u,x))};v.addEventListener("keydown",x=>{x.key==="Enter"&&(x.preventDefault(),g())}),v.addEventListener("focus",()=>{ke=!0}),v.addEventListener("blur",()=>{ke=!1}),c.append(t("div",{class:"ag-input"},d,v,t("button",{onclick:g,disabled:ne},"Send")));return}c.append(t("button",{class:"ag-opt"+(p.selected?" sel":""),disabled:ne,onclick:()=>{et(u)},title:p.selected?"Selected in the CLI":"",data:{k:`opt:${u}`}},d,t("span",{},p.label),p.description?t("span",{class:"d"},p.description):null))}),f.append(c,t("div",{class:"ag-foot"},t("span",{},o.hint??""),t("button",{title:"Esc in the CLI",onclick:()=>re(nn)},"Cancel"),t("button",{title:`Show ${P(a)}'s CLI window`,onclick:()=>Q?.show()},"Open CLI window"))),e.append(O(),f)}function ct(e,a,o){let l=t("div",{class:"ag-list ag-menu",attrs:{role:"menu","aria-label":e}},t("h4",{attrs:{"aria-hidden":"true"}},e)),f=a.some(u=>u.checked!==void 0),c=a.find(u=>u.checked)?.k??a[0]?.k,p=a.map(u=>t("button",{class:"ag-mi",title:u.title??"",data:{k:u.k},tabIndex:u.k===c?0:-1,attrs:{role:f?"menuitemradio":"menuitem","aria-checked":f?String(!!u.checked):void 0,"aria-disabled":u.disabled?"true":void 0},onclick:()=>{u.disabled||u.act()}},t("b",{},u.text),u.sub?t("span",{},u.sub):null));return mn(l,p),l.append(...p),o&&l.append(t("div",{class:"ag-hint"},o)),l}function Ft(){return ct("Run the next prompt with",b().map(e=>({k:`cli:${e.id}`,text:e.name,sub:e.name!==e.command?e.command:void 0,checked:e.id===y,title:`Run ${e.name} (${e.command}) for the next prompt${X()?"":", in place of the shared session"}`,act:()=>{gt(e.id),k=null,I="primary",s.toast(`Next prompt: ${e.name}`),R()}})),"Model and effort: \u2699")}function Ut(){return ct("Prompts",r.commands.slice(1).map((e,a)=>{let o=Fe(e)?be().length:-1;return{k:`cmd:${a}`,text:e.label,sub:o>=0?`${o} note${o===1?"":"s"}`:void 0,disabled:o===0,title:e.title??e.prompt,act:()=>{k=null,I="more-cmds",C?.render(),Ze(e)}}}),`with ${F()}${X()?", in a new session":""}`)}let gt=e=>{y=e,je(e)},Le=null;function pt(){let e=W(),a=r.defaults??{},o=Be(e,T),l=t("div",{class:"ag-set",attrs:{role:"dialog","aria-label":"Agent settings"}},t("h4",{attrs:{"aria-hidden":"true"}},"Agent settings")),f=(d,v,g,x,$)=>{let S=t("fieldset",{},t("legend",{},d));for(let M of g){let A=t("input",{type:"radio",name:v,value:M.value,checked:M.value===x,data:{k:M.k}});A.addEventListener("change",()=>{A.checked&&$(M.value)}),S.append(t("label",{class:"ag-radio"},A,t("span",{},M.label),M.sub?t("small",{},M.sub):null))}return S},c=(d,v,g,x,$,S)=>{let M=`ag-${v}`,A=t("select",{id:M,data:{k:v}},t("option",{value:""},`Default${$?` (${$})`:""}`),...g.map(N=>t("option",{value:N.value,selected:N.value===x},N.name??N.value)));return A.addEventListener("change",()=>S(A.value)),t("div",{class:"ag-field"},t("label",{class:"ag-lbl",htmlFor:M},d),A)},p=(d,v)=>{if(!e)return;let g={...T[e.id],[d]:v||void 0};g.model||delete g.model,g.effort||delete g.effort,T={...T,[e.id]:g},!g.model&&!g.effort&&delete T[e.id],De(T),ce()};w()&&l.append(f("Agent","ag-set-cli",b().map(d=>({value:d.id,label:d.name,sub:d.name!==d.command?d.command:void 0,k:`set-cli:${d.id}`})),y,d=>{gt(d),ce(),R()})),e?.pending?l.append(t("div",{class:"ag-field"},t("label",{class:"ag-lbl",htmlFor:"ag-set-model"},"Model"),t("select",{id:"ag-set-model",disabled:!0,data:{k:"set-model"}},t("option",{},`Asking ${e.name} for its models\u2026`)))):e?.models?.length&&l.append(c("Model","set-model",e.models,o.model,a.model,d=>p("model",d))),e?.efforts?.length&&l.append(c("Effort","set-effort",e.efforts,o.effort,a.effort,d=>p("effort",d))),e&&!e.pending&&!e.models?.length&&!e.efforts?.length&&l.append(t("div",{class:"ag-note"},`${e.name} offers no model or effort choice here: it uses its own config.`)),l.append(f("Sessions","ag-set-mode",[{value:"fresh",label:"New session per prompt",sub:`up to ${n.max} at once`,k:"set-mode:fresh"},{value:"shared",label:"Keep one session going",sub:"keeps its context",k:"set-mode:shared"}],n.mode,d=>{K("/mode",{mode:d}).then(v=>{n={...n,...v},R()}).catch(H)}));let u=n.worktrees;if(u){let d=!u.git,v=t("input",{type:"checkbox",checked:u.on,disabled:d,data:{k:"set-wt"},attrs:{"aria-describedby":"ag-wt-help"}});v.addEventListener("change",()=>{K("/worktrees",{on:v.checked}).then(x=>{n={...n,...x},ce(),R()}).catch(x=>{v.checked=!v.checked,H(x)})});let g=d?`Needs a git repository (${u.why??"checking\u2026"}).`:`Its own branch (redline/\u2026) and folder in .redline/worktrees, so sessions never edit the same files; when it ends: keep, merge or discard the branch.${n.mode==="shared"?" Only with a new session per prompt.":""} No node_modules there: the agent can edit and use git; running the app or tests in it needs an install.`;l.append(t("fieldset",{},t("legend",{},"Worktrees"),t("label",{class:"ag-radio"+(d?" off":"")},v,t("span",{},"Each new session in its own git worktree")),t("div",{class:"ag-help",id:"ag-wt-help"},g)))}return l.append(t("footer",{},t("span",{},"Applies to new sessions."),t("button",{data:{k:"set-reset"},title:"Forget this browser's choices: the project's CLI, model, effort and sessions",onclick:Kt},"Reset to project defaults"))),l.addEventListener("keydown",d=>{d.key==="Escape"&&/^(INPUT|SELECT)$/.test(d.target.tagName)&&(d.preventDefault(),ae())}),Le=l,l}function ce(){if(!Le?.isConnected){C?.render();return}let e=ie()?.activeElement?.closest("[data-k]")?.dataset.k,a=Le,o=pt();a.replaceWith(o),e&&o.querySelector(`[data-k="${CSS.escape(e)}"]`)?.focus(),C?.render()}async function Kt(){T={},De(null),y=se(b(),null,r.cli),je(null);let e=r.defaults?.sessions??"fresh";if(n.mode!==e)try{n={...n,...await K("/mode",{mode:e})}}catch(o){H(o)}let a=!!r.defaults?.worktrees;if(n.worktrees?.git&&n.worktrees.on!==a)try{n={...n,...await K("/worktrees",{on:a})}}catch(o){H(o)}I="set-reset",s.toast("Agent settings: back to the project's defaults"),R()}let Te=new Map,ge=new Set,Me=!1,Ie=new Map,ut=(e,a)=>`${oe}/file?id=${encodeURIComponent(e)}&path=${encodeURIComponent(a)}&token=${encodeURIComponent(i.info.token)}`;function _t(e){let a=`${e.rounds??0}:${e.attachments??0}`,o=Te.get(e.id);return o?.key===a?o.rounds:(Te.set(e.id,{key:a,rounds:o?.rounds??null}),fetch(`${oe}/attachments?id=${encodeURIComponent(e.id)}&token=${encodeURIComponent(i.info.token)}`).then(l=>l.ok?l.json():null).then(l=>{l&&(Te.set(e.id,{key:a,rounds:l.rounds}),k==="files"&&(Me&&(Me=!1,I="files-first"),C?.render()))}).catch(()=>{}),o?.rounds??null)}function qt(e,a){let o=ie();if(!o)return;let l=t("div",{class:"zoom",tabIndex:-1,attrs:{role:"dialog","aria-label":"Image, Esc to close"}},t("img",{src:e,alt:""})),f=()=>{l.remove(),a.focus()};l.addEventListener("click",f),l.addEventListener("keydown",c=>{c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),f())}),o.append(l),l.focus()}function Gt(){let e=L(),a=t("div",{class:"ag-list ag-files",attrs:{role:"dialog","aria-label":`Attachments of ${U(e)}`}},t("h4",{},`${e.label}${e.title?` \xB7 ${e.title}`:""} \xB7 attachments`)),o=e.id?_t(e):[];if(!o)return Me=!0,a.append(t("div",{class:"ag-hint",data:{k:"files-first"},tabIndex:-1},"Loading\u2026")),a;o.some(c=>c.items.length)||a.append(t("div",{class:"ag-hint"},"Nothing yet: files it changes, images and links it points at show here, per prompt."));let l=!0,f=c=>l?(l=!1,"files-first"):c;for(let c of o){if(!c.items.length)continue;let p=pn(c.items),u=t("section",{class:"ag-round",attrs:{"aria-label":`Prompt ${c.n}`}},t("div",{class:"ag-round-h"},t("b",{},`Prompt ${c.n}`),c.task?t("span",{},c.task):null,c.done?null:t("span",{class:"ag-live"},"working\u2026")));if(p.images.length&&u.append(t("div",{class:"ag-thumbs"},...p.images.map(g=>{let x=ut(e.id,g.path),$=t("button",{class:"ag-thumb",title:`${g.title?g.title+" \xB7 ":""}${g.path} (click to zoom)`,data:{k:f(`img:${g.id}`)},attrs:{"aria-label":`Zoom ${g.title??g.path}`}},t("img",{src:x,alt:g.title??g.path??"",loading:"lazy"}));return $.onclick=()=>qt(x,$),$}))),p.changed.length){let g=p.changed.reduce(($,S)=>$+(S.added??0),0),x=p.changed.reduce(($,S)=>$+(S.removed??0),0);u.append(t("div",{class:"ag-sub"},`Changed ${p.changed.length} file${p.changed.length===1?"":"s"}`,t("span",{class:"ag-num"},t("i",{class:"add"},`+${g}`)," ",t("i",{class:"del"},`\u2212${x}`))));for(let $ of p.changed){let S=`${e.id}:${c.n}:${$.path}`,M=ge.has(S),A=t("button",{class:"ag-frow",data:{k:f(`chg:${$.id}`)},attrs:{"aria-expanded":String(M)},title:M?"Hide the diff":"Show the diff",onclick:()=>{ge.has(S)?ge.delete(S):(ge.add(S),Ie.has(S)||fetch(`${oe}/diff?id=${encodeURIComponent(e.id)}&round=${c.n}&path=${encodeURIComponent($.path)}&token=${encodeURIComponent(i.info.token)}`).then(N=>N.ok?N.text():"(no diff)").then(N=>{Ie.set(S,N),C?.render()}).catch(()=>{})),I=`chg:${$.id}`,C?.render()}},t("span",{class:"ag-st",attrs:{"aria-label":{A:"added",D:"deleted",M:"modified"}[$.status??"M"]??"changed"}},$.status??"M"),t("span",{class:"ag-path"},$.path??""),t("span",{class:"ag-num"},t("i",{class:"add"},`+${$.added??0}`)," ",t("i",{class:"del"},`\u2212${$.removed??0}`)));if(u.append(A),M){let N=Ie.get(S);u.append(N===void 0?t("div",{class:"ag-hint"},"Loading the diff\u2026"):t("pre",{class:"ag-ctx ag-diff"},...N.split(`
|
|
179
|
+
`).filter(q=>!/^(diff --git|index |--- |\+\+\+ )/.test(q)).flatMap((q,ue)=>[...ue?[`
|
|
180
|
+
`]:[],t("span",{class:q.startsWith("+")?"add":q.startsWith("-")?"del":q.startsWith("@@")?"hunk":""},q)])))}}}let d=(g,x="")=>{let $=/\.(png|jpe?g|gif|webp|avif|svg|txt|md|json|csv|log|ya?ml|html?|css|[cm]?[jt]sx?|vue|svelte|astro|py|cs|razor|cshtml)$/i.test(g.path??""),S=[t("span",{class:"ag-path"},g.path??""),g.title?t("span",{class:"ag-t"},g.title):null];return $?t("a",{class:"ag-frow "+x,href:ut(e.id,g.path),target:"_blank",rel:"noopener noreferrer",title:`Open ${g.path} in a new tab`,data:{k:f(`file:${g.id}`)}},...S):t("div",{class:"ag-frow "+x,title:g.path??""},...S)},v=(g,x="")=>{let $=gn(g.url??""),S=[t("span",{class:"ag-path"},g.title??g.url??""),g.title?t("span",{class:"ag-t"},g.url??""):null];return $?t("a",{class:"ag-frow "+x,href:g.url,target:"_blank",rel:"noopener noreferrer",title:`Open ${g.url} in a new tab`,data:{k:f(`url:${g.id}`)}},...S):t("div",{class:"ag-frow ag-ext "+x,title:`${g.url} (not on this machine: copy it to open)`},...S)};p.files.length&&u.append(t("div",{class:"ag-sub"},"Files"),...p.files.map(g=>d(g))),p.links.length&&u.append(t("div",{class:"ag-sub"},"Links"),...p.links.map(g=>v(g))),p.mentioned.length&&u.append(t("details",{class:"ag-ment"},t("summary",{},`Mentioned (${p.mentioned.length})`),...p.mentioned.map(g=>g.kind==="url"?v(g,"dim"):d(g,"dim")))),a.append(u)}return a.append(t("div",{class:"ag-foot"},t("span",{},"Kept while the session runs"),t("button",{data:{k:"files-done"},onclick:()=>ae()},"Done"))),a}let pe=null,ft=0;function Vt(){let e=n.worktrees?.left??[],a=t("div",{class:"ag-list ag-wts",attrs:{role:"dialog","aria-label":"Branches of ended sessions"}},t("h4",{},e.length?"Ended sessions: their branches":"No branches left to decide on")),o=(l,f,c=!1)=>{i.worktree(l.branch,f,c).then(p=>s.toast(p.message,!p.ok)).catch(H)};for(let l of e){let f=!!(l.dirty||l.ahead),c=pe===l.branch,p=t("button",{class:"ag-wt-discard"+(c?" armed":""),data:{k:`wt-discard:${l.branch}`},title:f?`Delete the worktree and the branch, with its ${Mt(l)}`:"Delete the worktree and the branch",onclick:()=>{if(f&&!c){pe=l.branch,clearTimeout(ft),ft=window.setTimeout(()=>{pe=null,C?.render()},4e3),I=`wt-discard:${l.branch}`,C?.render();return}pe=null,o(l,"discard",f)}},c?"Discard? Work is lost":"Discard");a.append(t("div",{class:"ag-wt",data:{branch:l.branch}},t("div",{class:"ag-wt-head"},V("branch"),t("b",{},l.branch),t("span",{},[l.session,l.title].filter(Boolean).join(" \xB7 "))),t("div",{class:"ag-wt-sub"},`${Mt(l)} \xB7 from ${l.base} \xB7 ${l.path}`),t("div",{class:"ag-wt-acts"},t("button",{data:{k:`wt-keep:${l.branch}`},title:"Keep the branch (the folder too while it has uncommitted changes)",onclick:()=>o(l,"keep")},"Keep branch"),t("button",{data:{k:`wt-merge:${l.branch}`},disabled:!!l.dirty,title:l.dirty?"Commit its changes first (or ask the agent to)":`Merge into ${l.base}: only a fast-forward or a clean merge`,onclick:()=>o(l,"merge")},`Merge into ${l.base}`),p)))}return a.append(t("div",{class:"ag-foot"},t("span",{},""),t("button",{data:{k:"wt-done"},onclick:()=>ae()},"Done"))),a}function Yt(e){let a=n.sessions.filter(c=>!c.running),o=[...n.sessions].reverse().map(c=>{let p=Y(c),u=c.sent?.length??0,d=t("button",{class:"ag-row-main",title:dt(c),data:{k:`row:${c.id}`},attrs:{"aria-current":c.id===L().id?"true":void 0},onclick:()=>{z=c.id,k=null,I=matchMedia("(max-width: 560px)").matches?"sw":`tab:${c.id}`,R()}},t("span",{class:"ag-dot"}),t("span",{class:"l"},c.label),t("b",{},p.label),t("span",{class:"m"},[c.title,w()?D(c):"",c.worktree?.branch??"",u?`${u} note${u===1?"":"s"}`:"",c.attachments?`${c.attachments} attached`:"",p.msg??""].filter(Boolean).join(" \xB7 "))),v=t("div",{class:"ag-row"+(c.id===L().id?" cur":""),data:{id:c.id,state:Je(c)}},d,rt(c,`rowx:${c.id}`));return v.style.setProperty("--c",p.color),v}),l=async()=>{for(let c of a)await K("/end",{id:c.id}).catch(H)},f=n.sessions.filter(c=>c.running).length;e.append(O(),t("div",{class:"ag-list",attrs:{role:"dialog","aria-label":"Sessions"}},t("h4",{},n.sessions.length?`Sessions \xB7 ${f} running`:"No sessions yet"),...o,t("div",{class:"ag-foot"},t("span",{},""),a.length?t("button",{data:{k:"close-ended"},onclick:()=>{l()}},`Close ended (${a.length})`):null,t("button",{data:{k:"list-done"},onclick:()=>ae()},"Done"))))}let Jt=e=>{let a=t("span",{},e.t);return e.fg&&(a.style.color=e.fg),e.bg&&(a.style.background=e.bg),e.b&&(a.style.fontWeight="700"),e.dim&&(a.style.opacity=".6"),a};C=s.addToolbar({id:"agent",title:"Agent",backTitle:"Back to the Redline toolbar (Esc)",hotkey:r.hotkey||void 0,render:Bt,attached:Wt,onEscape:ae,onShow(){L().id&&Z("/ack").catch(()=>{}),R()},onHide(){k=null,R()}});let ht=()=>{let e=L();return e.id?[e.label,D(e),e.title,e.worktree?.branch].filter(Boolean).join(" \xB7 "):`${F()} \xB7 no session yet`};function Re(){if(!le)return;let e=L();if(!e.id){le.replaceChildren();return}let a=B===e.id;le.replaceChildren(O(),t("button",{class:"ag-wend"+(a?" armed":""),title:ot(e),data:{k:"wend"},onclick:()=>st(e)},a?"End? Press again":e.running?"End session":"Close session"))}Q=s.addWindow({id:"agent",title:ht(),width:680,height:440,hideAs:"minimize",render(e,a){le=a,Re(),j=document.createElement("iframe"),j.src=$e(),j.title=`${m()} terminal`,j.setAttribute("style","position:absolute;inset:0;width:100%;height:100%;border:0;background:#131316"),e.append(j)},onShow(){L().id&&Z("/ack").catch(()=>{}),it({type:"focus"}),C?.render()},onHide(){C?.render()},onResize(){it({type:"fit"})}});function mt(){if(!Se)return;let e=We(n.sessions)??L(),a=Y(e),o=s.notes("all"),l=Pt(),f=o.filter(g=>l.has(g.id)&&!g.done).length,c=o.filter(g=>l.has(g.id)&&g.done).length,p=n.sessions.filter(g=>g.running).length,u=[p>1&&`${p} sessions`,f&&`${f} sent note${f===1?"":"s"} open`,c&&`${c} done`].filter(Boolean).join(" \xB7 "),d=e.running||e.status.state==="done"||e.status.state==="error"?`${P(e)}: ${a.label}${u?` \xB7 ${u}`:a.msg?` \xB7 ${a.msg}`:""}`:`Hand these notes to ${F()}`,v=t("button",{class:"ag-line",title:"Open the agent toolbar",onclick:()=>C?.show(),data:{state:e.running?e.status.state:"stopped"}},t("span",{class:"ag-dot"}),t("span",{},d),r.hotkey?t("kbd",{},Xe()):r.key!==!1?t("kbd",{},(r.key||"a").toUpperCase()):null);v.style.setProperty("--c",a.color),Se.replaceChildren(O(),v)}function bt(e){let a=un(e.note,n.sessions,P),o=!!a&&/working|asking/.test(a.cls);e.el.replaceChildren(...a?[t("span",{class:`ag-tag ${a.cls}`,...o?{title:"Open the agent toolbar",onclick:()=>C?.show()}:{}},a.text)]:[])}s.addPanelSection({id:"agent",render(e){Se=e,mt()}}),s.addCardDecorator({id:"agent",render(e,a){let o={el:a,note:e};Ce.set(e.id,o),bt(o)}});function R(){z&&!n.sessions.some(d=>d.id===z)&&(z=null);let e=d=>d.running&&d.status.state==="blocked",a=n.sessions.filter(e).map(d=>d.id),o=a.find(d=>!tt.has(d));tt=new Set(a);let l=L(),f=we.id===l.id&&we.asking&&!e(l),c=o??(f?a[0]:void 0);c&&!ke&&!e(l)&&(z=c,k==="list"&&(k=null)),we={id:L().id,asking:e(L())},k==="files"&&e(L())&&(k=null),y=se(b(),y,r.cli);let p=We(n.sessions),u=p?Rt({...p,command:P(p)}):null;s.setStatus("agent",u?{...u,onClick:()=>C?.show()}:null),lt(u?.title),j&&!j.src.endsWith($e())&&(j.src=$e()),Q?.setTitle(ht()),Re(),C?.render(),mt();for(let d of Ce.values())d.el.isConnected?bt(d):Ce.delete(d.note.id)}i.watch(e=>{n=e,R()},e=>{r.clis=e,k==="settings"&&ce(),R()},e=>{r=e,n=r,y=se(b(),y,r.cli),R()}),window.addEventListener("message",e=>{e.origin!==location.origin||e.source!==j?.contentWindow||(e.data?.type==="ack"&&Z("/ack").catch(()=>{}),e.data?.type==="session"&&typeof e.data.id=="string"&&(z=e.data.id,R()))}),R()}export{bn as default,sn as fill,on as freeIds,pn as groupAttachments,Rt as indicatorFor,ln as initials,gn as isLocalUrl,Sn as noteTag,Ke as noteText,We as overall,se as pickCli,_e as shorten,Y as stateLabel,Ue as tabRank,rn as tabTitle,un as tagFor,dn as visibleTabs,Mt as worktreeState};
|