toolroll 0.9.126 → 0.9.127
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/CHANGELOG.md +28 -0
- package/dist/assignment.js +14 -4
- package/dist/browser/workspace.js +1 -1
- package/dist/contracts/engine-api.js +3 -0
- package/dist/easy-start.js +1 -0
- package/dist/engine-reads.js +21 -2
- package/dist/flexible-conversation.js +79 -1
- package/dist/flexible-import.js +159 -2
- package/dist/flexible-save.js +49 -4
- package/dist/flexible-session.js +33 -7
- package/dist/flexible-start.js +2 -1
- package/dist/landed-rows.js +138 -0
- package/dist/local-landing.js +20 -2
- package/dist/merge-checklist.js +33 -8
- package/dist/operate.js +76 -16
- package/dist/result-follow-ups.js +8 -1
- package/dist/revision-catch-up.js +98 -0
- package/dist/server/engine-api.js +13 -8
- package/dist/server/pages.js +5 -2
- package/dist/server/render-results.js +4 -2
- package/dist/server/task-views.js +4 -1
- package/dist/skill-library.js +2 -12
- package/dist/task-base.js +11 -0
- package/dist/task-status.js +11 -4
- package/dist/teardown-git.js +6 -0
- package/dist/toolroll-update-cli.js +2 -1
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/unreachable.js +15 -0
- package/package.json +1 -1
|
@@ -60,7 +60,7 @@ ${o}`,Cd(n),n.focus(),!0}var QO=!1,JO=new WeakMap;function n9(){let e=document.d
|
|
|
60
60
|
`)]})]},r.key))}for(;n<a.length;n+=1)o(a[n]);return(0,Me.jsx)("ol",{className:"k-work-term","data-terminal":!0,children:t})}function dB(e,t,a){return a?"The live view waits while this page asks for your password.":e.state==="off"?`The agent's words aren't shown here: it ${t?"runs":"ran"} on another computer.`:e.state==="unavailable"||e.state==="error"?"Couldn't read the work just now. Trying again.":e.state==="loading"?"Reading the work…":t?"Nothing yet. What the agent says and does shows here as it works.":"This agent left no record of its work."}function wm({conversation:e,live:t,paused:a=!1,view:n="conversation",older:o}){let r=(0,Ya.useRef)(null),s=(0,Ya.useRef)(!0),i=(0,Ya.useRef)(null),l=()=>{let x=r.current;return x===null?null:x.scrollHeight>x.clientHeight+1?x:x.closest("[data-agent-scroll]")??x},u=()=>{let x=r.current,v=l();if(x===null||v===null)return;if(v===x){x.scrollTop=x.scrollHeight;return}let y=v.getBoundingClientRect().bottom-x.getBoundingClientRect().bottom;v.scrollTop=Math.max(0,v.scrollTop-y)},c=x=>{let v=r.current;return v===null?!0:x===v?x.scrollTop+x.clientHeight>=x.scrollHeight-24:v.getBoundingClientRect().bottom<=x.getBoundingClientRect().bottom+24},f=x=>{i.current?.(),i.current=null,r.current=x;let v=x?.closest("[data-agent-scroll]")??null;if(v===null)return;let y=()=>{l()===v&&(s.current=c(v))};v.addEventListener("scroll",y,{passive:!0}),i.current=()=>v.removeEventListener("scroll",y)};(0,Ya.useEffect)(()=>()=>i.current?.(),[]),(0,Ya.useLayoutEffect)(()=>{s.current&&t&&u()},[e.revision,n]);let d=n==="conversation"?l9(e):[],m=dB({...e,state:"error"},t,!1),h=dB(e,t,a),w=n==="conversation"?d.length===0:e.items.length===0&&e.notes.length===0;return(0,Me.jsxs)(Me.Fragment,{children:[w?(0,Me.jsx)("p",{className:"k-work-empty","data-transcript-empty":!0,children:h}):(0,Me.jsxs)("div",{ref:f,tabIndex:0,"aria-label":"The agent's work","data-agent-transcript":!0,className:"k-work-tx",onScroll:x=>{let v=x.currentTarget;l()===v&&(s.current=c(v))},children:[e.older>0&&(0,Me.jsx)("p",{className:"k-note",children:o?.(e.older)??`${e.older} earlier ${e.older===1?"note is":"notes are"} on the task page.`}),n==="terminal"?(0,Me.jsx)(c9,{conversation:e}):(0,Me.jsx)("ol",{className:"k-work-lines",children:d.map(x=>x.node)}),a&&(0,Me.jsx)("p",{className:"k-note","data-conversation-state":"paused",children:h}),!a&&e.state==="off"&&(0,Me.jsx)("p",{className:"k-note","data-conversation-state":"off",children:h}),!a&&(e.state==="error"||e.state==="unavailable")&&(0,Me.jsx)("p",{role:"status",className:"k-note","data-conversation-state":"error",children:m})]}),e.detail==="base"&&(0,Me.jsxs)("p",{className:"k-note","data-conversation-detail":"base",children:["Commands were hidden for this run. ",(0,Me.jsx)("a",{className:"k-link",href:"/settings/project",children:"Change this in project settings"})]})]})}var mB="toolroll.agent.view";function d9(){try{return window.localStorage.getItem(mB)==="terminal"?"terminal":"conversation"}catch{return"conversation"}}function hB({url:e,live:t,paused:a=!1}){let n=y1(e,t,a),[o,r]=(0,Ya.useState)(d9),s=i=>{r(i);try{window.localStorage.setItem(mB,i)}catch{}};return(0,Me.jsxs)("section",{"aria-label":"Conversation",className:"k-work-conv",children:[(0,Me.jsxs)("div",{className:"k-work-conv-h",children:[(0,Me.jsx)("h3",{className:"k-sr",children:o==="terminal"?"Terminal":"Conversation"}),(0,Me.jsx)("span",{"data-conversation-view":o,children:(0,Me.jsx)(rs,{label:"How to show it",current:o,onChange:i=>s(i==="terminal"?"terminal":"conversation"),items:[{key:"conversation",label:"Conversation"},{key:"terminal",label:"Terminal"}]})})]}),(0,Me.jsx)(wm,{conversation:n,live:t,paused:a,view:o})]})}function gB({id:e,title:t,who:a,live:n=!1,onClose:o,closeLabel:r="Close",closeData:s={},hidden:i=!1,foot:l,children:u,onClick:c,...f}){return(0,Me.jsxs)("aside",{className:"k-work",id:e,"aria-labelledby":`${e}-h`,hidden:i,onClick:c,...f,children:[(0,Me.jsxs)("header",{className:"k-work-head",children:[(0,Me.jsxs)("div",{className:"k-work-title",children:[(0,Me.jsx)("h2",{id:`${e}-h`,children:t}),a!=null&&a!==""&&(0,Me.jsxs)("p",{className:"k-work-who",children:[n&&(0,Me.jsx)("span",{className:"k-work-dot","aria-hidden":"true"}),(0,Me.jsx)("span",{children:a})]})]}),o!==void 0&&(0,Me.jsx)(de,{variant:"ghost",sm:!0,iconOnly:"x",label:r,onClick:o,...s})]}),(0,Me.jsx)("div",{className:"k-work-body","data-agent-scroll":"",children:u}),l!=null&&(0,Me.jsx)("div",{className:"k-work-foot",children:l})]})}var Ne=O(Z(),1),w1=e=>e.charAt(0).toUpperCase()+e.slice(1);async function vB(e,t,a,n){let o=new URLSearchParams({csrf:a});t==="confirm"&&n&&o.set("confirm","yes");try{let r=await fetch(`/chat/proposal/${e.id}/${t}`,{method:"POST",body:o,credentials:"same-origin",headers:yt({accept:"application/json"}),signal:AbortSignal.timeout(2e4)});if(!r.headers.get("content-type")?.includes("application/json"))return{ok:!1,said:"That didn't go through. Reload the conversation and try again."};let s=await r.json(),i=typeof s=="object"&&s!==null?s:{};return{ok:i.ok===!0,said:typeof i.said=="string"?w1(i.said):"Done."}}catch{return{ok:!1,said:"That didn't go through. Check your connection and try again."}}}function f9({card:e}){return(0,Ne.jsxs)("section",{"data-view":"chat-card","data-action-card":e.id,"data-card-kind":"data",className:"so-chat-card mt-3 overflow-hidden bg-card text-card-foreground",children:[(0,Ne.jsx)("header",{className:"px-4 pt-3 pb-1 font-semibold",children:e.label}),(0,Ne.jsx)("div",{className:"px-4 py-2",children:(0,Ne.jsx)(Ct,{html:e.body,immutable:!0,className:"so-card-body"})}),e.links.length>0&&(0,Ne.jsx)("footer",{className:"flex flex-wrap gap-2 px-4 pb-3.5 pt-1",children:e.links.map(t=>(0,Ne.jsx)(He,{variant:"ghost",sm:!0,href:t.href,label:t.label},t.href))})]})}function p9({card:e,csrf:t,onChanged:a}){if(e.data===!0)return(0,Ne.jsx)(f9,{card:e});let[n,o]=(0,Xs.useState)(null),[r,s]=(0,Xs.useState)(!1),i=(0,Xs.useId)(),l=async d=>{o(d);let m=await vB(e,d,t,r);d==="confirm"?(m.ok?om.success:om.error)(m.said):m.ok||om.error(m.said),o(null),a()},u=e.primary,c=u?.kind==="confirm"&&u.irreversible&&!r,f=e.state==="confirmed"||e.state==="refused"||e.state==="dismissed"||e.state==="expired";return(0,Ne.jsxs)("section",{"data-view":"chat-card","data-action-card":e.id,"data-card-kind":e.kind,"data-card-state":e.state,className:ye("so-chat-card mt-3 overflow-hidden bg-card text-card-foreground",f&&"opacity-90"),children:[(0,Ne.jsxs)("header",{className:"flex items-center gap-2 px-4 pt-3 pb-1 font-semibold",children:[e.state==="pending"&&u!==null&&(0,Ne.jsx)("span",{className:"so-needs-you",children:"Needs you"}),(0,Ne.jsx)("span",{className:"so-chat-card-title min-w-0 flex-1 truncate",children:e.label}),e.state==="confirmed"&&(0,Ne.jsxs)("span",{className:"inline-flex items-center gap-1 text-success",children:[(0,Ne.jsx)(Fs,{className:"size-3.5","aria-hidden":"true"}),"Done"]}),e.state==="refused"&&(0,Ne.jsxs)("span",{className:"inline-flex items-center gap-1 text-destructive",children:[(0,Ne.jsx)(no,{className:"size-3.5","aria-hidden":"true"}),"Not done"]})]}),e.body!==""&&(0,Ne.jsx)("div",{className:"px-4 py-2",children:(0,Ne.jsx)(Ct,{html:e.body,immutable:!0,className:"so-card-body"})}),(0,Ne.jsxs)("footer",{className:"flex flex-col gap-2 px-4 pb-3.5 pt-1",children:[e.said!==null&&(0,Ne.jsx)("p",{className:ye("text-body",e.state==="refused"?"text-destructive":"text-success"),children:w1(e.said)}),e.links.length>0&&(0,Ne.jsx)("div",{className:"flex flex-wrap gap-2",children:e.links.map(d=>(0,Ne.jsx)(pe,{asChild:!0,variant:"outline",size:"sm",children:(0,Ne.jsx)("a",{href:d.href,children:d.label})},d.href))}),e.note!==null&&(0,Ne.jsx)("p",{className:"text-body text-muted-foreground",children:e.note}),u?.kind==="confirm"&&u.irreversible&&(0,Ne.jsxs)("label",{htmlFor:i,className:"flex items-center gap-2 text-body",children:[(0,Ne.jsx)("input",{id:i,type:"checkbox",checked:r,onChange:d=>s(d.target.checked),className:"size-4 accent-primary"}),"I understand this cannot be undone"]}),(u!==null||e.dismissable)&&(0,Ne.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u?.kind==="link"&&(0,Ne.jsx)(pe,{asChild:!0,size:"sm",children:(0,Ne.jsx)("a",{href:u.href,children:u.label})}),u?.kind==="confirm"&&u.native&&(0,Ne.jsxs)(Fe,{action:`/chat/proposal/${e.id}/confirm`,children:[(0,Ne.jsx)("input",{type:"hidden",name:"return",value:window.location.pathname+window.location.search}),u.irreversible&&r&&(0,Ne.jsx)("input",{type:"hidden",name:"confirm",value:"yes"}),(0,Ne.jsx)(pe,{type:"submit",size:"sm",disabled:c,children:u.label})]}),u?.kind==="confirm"&&!u.native&&(0,Ne.jsx)(pe,{size:"sm",disabled:n!==null||c,onClick:()=>{l("confirm")},"data-card-confirm":!0,children:n==="confirm"?"Working…":u.label}),e.dismissable&&(0,Ne.jsx)(pe,{variant:"ghost",size:"sm",disabled:n!==null,onClick:()=>{l("dismiss")},"data-card-dismiss":!0,children:n==="dismiss"?"Dismissing…":"Dismiss"})]})]})]})}var m9={task:["Task","plus"],cancel:["Task","x"],task_action:["Task","file"],repair:["Task","file"],scope:["Scope","file"],review:["Review","file"],steer:["Guidance","file"],next:["Queue","send"],reserve:["Worker","file"],hold:["Hold","stop"],unhold:["Hold","send"],answer:["Decision","check"],agents:["Agents","file"],control:["Control","file"],action:["Action","file"]};function h9(e){switch(e.state){case"pending":return e.primary!==null||e.dismissable?{word:"Needs you",tone:"needs"}:{word:"Waiting",tone:""};case"drafting":return{word:"Drafting",tone:""};case"confirming":return{word:"Confirming",tone:"live"};case"confirmed":return{word:"Done",tone:"done"};case"refused":return{word:"Not done",tone:"failed"};case"dismissed":return{word:"Dismissed",tone:""};default:return{word:"Expired",tone:""}}}function g9({card:e,csrf:t,onChanged:a}){if(e.data===!0)return(0,Ne.jsxs)("li",{"data-view":"chat-card","data-action-card":e.id,"data-card-kind":"data",className:"lc-card lc-data",children:[(0,Ne.jsx)("p",{className:"lc-data-title",children:e.label}),(0,Ne.jsx)(Ct,{html:e.body,immutable:!0,className:"lc-card-body"}),e.links.length>0&&(0,Ne.jsx)("div",{className:"lc-card-acts",children:e.links.map(b=>(0,Ne.jsx)(He,{variant:"ghost",sm:!0,href:b.href,label:b.label},b.href))})]});let[n,o]=(0,Xs.useState)(null),[r,s]=(0,Xs.useState)(!1),[i,l]=(0,Xs.useState)(null),u=(0,Xs.useId)(),c=async b=>{o(b),l(null);let k=await vB(e,b,t,r);l({ok:k.ok,words:k.said}),o(null),a()},f=e.primary,d=f?.kind==="confirm"&&f.irreversible&&!r,m=e.state==="pending"&&(f!==null||e.dismissable),[h,w]=m9[e.kind]??["Action","file"],x=h9(e),[v,...y]=e.links,g=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)("span",{className:"lc-card-ic","aria-hidden":"true",children:(0,Ne.jsx)(at,{name:w,small:!0})}),(0,Ne.jsxs)("span",{className:"lc-card-t",children:[(0,Ne.jsx)("span",{className:"lc-card-v",children:h}),(0,Ne.jsx)("span",{className:"lc-card-n",children:e.label})]}),(0,Ne.jsx)(Oe,{word:x.word,tone:x.tone})]});return(0,Ne.jsxs)("li",{"data-view":"chat-card","data-action-card":e.id,"data-card-kind":e.kind,"data-card-state":e.state,className:ye("lc-card",m&&"open"),children:[!m&&v!==void 0?(0,Ne.jsx)("a",{className:"lc-card-row",href:v.href,title:v.label,children:g}):(0,Ne.jsx)("div",{className:"lc-card-row",children:g}),(m||e.said!==null||i!==null||e.note!==null||y.length>0)&&(0,Ne.jsxs)("div",{className:"lc-card-more",children:[m&&e.body!==""&&(0,Ne.jsx)(Ct,{html:e.body,immutable:!0,className:"lc-card-body"}),e.said!==null&&(0,Ne.jsx)("p",{className:ye("lc-card-said",e.state==="refused"&&"bad"),children:w1(e.said)}),i!==null&&(0,Ne.jsx)("p",{className:ye("lc-card-said",!i.ok&&"bad"),role:i.ok?"status":"alert",children:i.ok?i.words:`${i.words} Nothing changed.`}),e.note!==null&&(0,Ne.jsx)("p",{className:"lc-card-note",children:e.note}),f?.kind==="confirm"&&f.irreversible&&m&&(0,Ne.jsxs)("label",{htmlFor:u,className:"lc-card-arm",children:[(0,Ne.jsx)("input",{id:u,type:"checkbox",checked:r,onChange:b=>s(b.target.checked)}),"I understand this cannot be undone"]}),(m||y.length>0)&&(0,Ne.jsxs)("div",{className:"lc-card-acts",children:[m&&f?.kind==="link"&&(0,Ne.jsx)(He,{variant:"primary",sm:!0,href:f.href,label:f.label}),m&&f?.kind==="confirm"&&f.native&&(0,Ne.jsxs)(Fe,{action:`/chat/proposal/${e.id}/confirm`,children:[(0,Ne.jsx)("input",{type:"hidden",name:"return",value:window.location.pathname+window.location.search}),f.irreversible&&r&&(0,Ne.jsx)("input",{type:"hidden",name:"confirm",value:"yes"}),(0,Ne.jsx)(de,{type:"submit",variant:"primary",sm:!0,disabled:d,label:f.label})]}),m&&f?.kind==="confirm"&&!f.native&&(0,Ne.jsx)(de,{variant:"primary",sm:!0,disabled:n!==null||d,busy:n==="confirm"?"Working…":!1,onClick:()=>{c("confirm")},"data-card-confirm":!0,label:f.label}),m&&e.dismissable&&(0,Ne.jsx)(de,{variant:"ghost",sm:!0,disabled:n!==null,busy:n==="dismiss"?"Dismissing…":!1,onClick:()=>{c("dismiss")},"data-card-dismiss":!0,label:"Dismiss"}),(m?e.links:y).map(b=>(0,Ne.jsx)(He,{variant:"ghost",sm:!0,href:b.href,label:b.label},b.href))]})]})]})}function Id({cards:e,csrf:t,onChanged:a,readOnly:n=!1,look:o="card"}){let r=s=>n?{...s,primary:null,dismissable:!1}:s;return o==="row"?(0,Ne.jsx)("ul",{className:"lc-cards so-action-cards","aria-label":"What the lead proposed",children:e.map(s=>(0,Ne.jsx)(g9,{card:r(s),csrf:t,onChanged:a},`${s.id}:${s.state}`))}):(0,Ne.jsx)("div",{className:"so-action-cards",children:e.map(s=>(0,Ne.jsx)(p9,{card:r(s),csrf:t,onChanged:a},`${s.id}:${s.state}`))})}var x1={lead:[{command:"new",hint:"File a new task",text:"File a task: "},{command:"flow",hint:"Make a flow for how work moves",text:"Make a flow for "},{command:"status",hint:"What needs you right now",text:"What needs my attention right now?"},{command:"next",hint:"What to work on next",text:"What should we work on next?"}],task:[{command:"status",hint:"Where this task stands",text:"Where does this task stand?"},{command:"next",hint:"Take the next step",text:"Move this forward"},{command:"revise",hint:"Send back",text:"Send it back: "},{command:"diff",hint:"Walk through the changes",text:"Walk me through the changes file by file."},{command:"log",hint:"What the checks said",text:"What does the check log say?"},{command:"steer",hint:"Send the agent a note",text:"Note for the agent: "},{command:"stop",hint:"Stop the running attempt",text:"Stop this task."},{command:"resume",hint:"Resume a stopped attempt",text:"Resume this task."},{command:"complete",hint:"Accept the result",text:"Accept this result."}],result:[{command:"summary",hint:"What changed",text:"Summarize what changed."},{command:"diff",hint:"Walk through the changes",text:"Walk me through the changes file by file."},{command:"log",hint:"What the checks said",text:"What does the check log say?"},{command:"risks",hint:"Anything to worry about",text:"Are there any risks in this change?"},{command:"revise",hint:"Send back",text:"Send it back: "},{command:"complete",hint:"Accept the result",text:"Accept this result."}],tasks:[{command:"new",hint:"File a new task here",text:"File a task: "},{command:"flow",hint:"Make a flow for this project",text:"Make a flow for "},{command:"status",hint:"What needs you here",text:"What needs my attention here?"},{command:"next",hint:"What to build next",text:"What should we build next?"}]};var Td=O(ve(),1);var dt=O(Z(),1);function b1({command:e}){let[t,a]=(0,Td.useState)(!1);return(0,dt.jsxs)("span",{className:"so-first-run-command",children:[(0,dt.jsx)("code",{children:e}),(0,dt.jsx)(pe,{className:"max-[901px]:h-11 max-[901px]:min-h-11",variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{a(!0),window.setTimeout(()=>a(!1),1500)},()=>{})},"aria-label":`Copy ${e}`,children:t?"Copied":"Copy"})]})}function wB(e,t){return e.trim()===""?t:e.includes(t)?e:`${e.trimEnd()}
|
|
61
61
|
${t}`}function v9(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.lead==="on"||t.agent===!0}var yB=15e3,k1="so:leaving";function gy(e){window.dispatchEvent(new Event(k1)),window.location.assign(e)}function y9(e){let t=(0,Td.useContext)(yn);(0,Td.useEffect)(()=>{if(!e)return;let a=!1,n=null,o=0,r=()=>n!==null&&Date.now()-n<yB,s=d=>{window.clearTimeout(o),a||(o=window.setTimeout(()=>{i()},d))},i=async()=>{try{let d=await fetch(e,{method:"POST",headers:yt({accept:"application/json"}),body:new URLSearchParams({csrf:t}),cache:"no-store"}),m=d.ok&&v9(await d.json());if(a)return;if(m&&!r()){window.location.reload();return}if(m){s(yB-(Date.now()-n)+100);return}}catch{}s(5e3)},l=()=>{n=Date.now()},u=d=>{if(d.defaultPrevented||d.button!==0||d.metaKey||d.ctrlKey||d.shiftKey||d.altKey)return;let m=d.target instanceof Element?d.target.closest("a[href]"):null;if(m===null||(m.getAttribute("target")??"_self")!=="_self"||m.hasAttribute("download"))return;let h;try{h=new URL(m.getAttribute("href"),window.location.href)}catch{return}h.hash!==""&&h.origin===window.location.origin&&h.pathname===window.location.pathname&&h.search===window.location.search||l()},c=d=>{d.defaultPrevented||l()},f=d=>{d.persisted&&(n=null,s(3e3))};return window.addEventListener("beforeunload",l),window.addEventListener("click",u),window.addEventListener("submit",c),window.addEventListener("pageshow",f),window.addEventListener(k1,l),s(3e3),()=>{a=!0,window.clearTimeout(o),window.removeEventListener("beforeunload",l),window.removeEventListener("click",u),window.removeEventListener("submit",c),window.removeEventListener("pageshow",f),window.removeEventListener(k1,l)}},[e,t])}function vy({firstRun:e}){y9(e.recheck);let t=e.recheck!=null;return(0,dt.jsxs)("section",{className:"so-first-run","aria-labelledby":"first-run-title","data-first-run":!0,children:[(0,dt.jsx)("h2",{id:"first-run-title",children:"Get to your first result"}),(0,dt.jsx)("p",{className:"so-first-run-setup","data-first-run-setup":!0,children:(0,dt.jsx)("a",{className:"k-link",href:"/welcome",children:"Open setup"})}),(0,dt.jsx)("ol",{className:"so-first-run-steps",children:e.steps.map(a=>(0,dt.jsxs)("li",{"data-step":a.key,"data-done":a.done,children:[(0,dt.jsx)("span",{className:"so-first-run-mark","aria-hidden":"true",children:a.done?"✓":""}),(0,dt.jsxs)("span",{className:"so-first-run-title",children:[a.title,(0,dt.jsx)("span",{className:"so-sr-only",children:a.done?": done":a.checking?": checking":": not yet"})]}),a.checking&&(0,dt.jsx)("span",{className:"so-first-run-checking","aria-hidden":"true",children:"Checking…"}),a.action!==null&&(a.key==="agent"&&e.sandbox!==null?null:a.action.kind==="link"?(0,dt.jsx)(pe,{className:"max-[901px]:h-11 max-[901px]:min-h-11",asChild:!0,variant:"outline",size:"sm",children:(0,dt.jsx)("a",{href:a.action.href,children:a.action.label})}):(0,dt.jsx)(b1,{command:a.action.command})),a.key==="agent"&&!a.done&&e.sandbox!==null&&a.action?.kind==="command"&&(0,dt.jsxs)("div",{className:"so-first-run-choices","data-first-run-choices":!0,children:[(0,dt.jsxs)("div",{"data-sign-in-command":!0,children:[(0,dt.jsx)("p",{className:"so-first-run-choice-title",children:"Sign in an agent"}),(0,dt.jsx)("p",{className:"so-first-run-choice-hint",children:"Run this on this computer. Chat turns on by itself once you’re signed in."}),(0,dt.jsx)(b1,{command:a.action.command})]}),(0,dt.jsxs)("div",{children:[(0,dt.jsx)("p",{className:"so-first-run-choice-title",children:"Or try the sandbox"}),(0,dt.jsx)("p",{className:"so-first-run-choice-hint",children:"Sample tasks, no spend."}),(0,dt.jsx)(b1,{command:e.sandbox})]})]})]},a.key))}),t&&(0,dt.jsxs)("p",{className:"so-first-run-recheck",role:"status","data-first-run-recheck":!0,children:[(0,dt.jsx)("span",{className:"so-live-dot","aria-hidden":"true"}),"Checking for a signed-in agent"]})]})}function xB({firstRun:e,onDraft:t}){return(0,dt.jsxs)("div",{className:"so-first-request","data-first-request":!0,children:[e.intro&&(0,dt.jsx)("p",{className:"so-first-request-intro","data-how-it-works":!0,children:e.intro}),e.suggestions.length>0&&(0,dt.jsx)("div",{className:"lc-sugs so-first-request-suggestions","aria-label":"First tasks to try","data-first-tasks":!0,children:e.suggestions.map(a=>(0,dt.jsx)(de,{variant:"outline",sm:!0,className:"lc-sug","data-source":a.source,onClick:()=>t(a.draft),label:a.label},a.draft))}),e.lead&&(0,dt.jsxs)("p",{className:"so-first-request-lead","data-lead-line":!0,children:[e.lead.words," · ",(0,dt.jsx)("a",{href:e.lead.href,children:"Change"})]})]})}var ae=O(Z(),1),yy=()=>({text:"",requestId:crypto.randomUUID(),uncertain:!1});function w9(e){try{let t=JSON.parse(sessionStorage.getItem(e)??"null");if(t&&typeof t=="object"&&typeof t.text=="string"&&typeof t.requestId=="string")return t}catch{}return yy()}function bB(e){return{queued:"Queued",running:"Working",failed:"Could not finish",cancelled:"Stopped",uncertain:"Delivery unconfirmed",answered:null}[e.status]}function x9(e,t){return e.split(/(\/(?:t\/[^\s<>"')]+|r\/\d+(?:\?[^\s<>"')]+)?|chat\?task=[^\s<>"')]+))/g).map((a,n)=>{if(!/^\/(?:t\/|r\/|chat\?task=)/.test(a))return a;let o=a.replace(/[.,;!]+$/,""),r=t&&o.startsWith("/chat?")?o+"&conversation="+encodeURIComponent(t):o;return(0,ae.jsxs)("span",{children:[(0,ae.jsx)("a",{href:r,children:r.startsWith("/r/")||r.includes("result=")?"Open result":"Open task"}),a.slice(o.length)]},n)})}function S1({projects:e}){return(0,ae.jsxs)("fieldset",{className:"so-team-projects",children:[(0,ae.jsx)("legend",{children:"Projects"}),e.length===0?(0,ae.jsx)("p",{children:"Add a project before creating a lead."}):e.map(t=>(0,ae.jsxs)("label",{children:[(0,ae.jsx)("input",{type:"checkbox",name:"projects",value:t,defaultChecked:e.length===1}),(0,ae.jsx)("span",{title:t,children:t.split("/").pop()||t})]},t))]})}function b9({proposals:e,csrf:t,onChanged:a,readOnly:n}){return e.length?(0,ae.jsx)("div",{className:"so-team-proposals",children:e.map(o=>o.card?(0,ae.jsx)(Id,{cards:[o.card],csrf:t,onChanged:a,readOnly:n},o.id):(0,ae.jsxs)("article",{children:[(0,ae.jsx)("strong",{children:o.title}),(0,ae.jsx)(Qr,{children:o.state==="pending"?"Proposed":o.state}),(0,ae.jsx)("a",{href:o.href,children:o.state==="pending"?"Review action":"Open outcome"})]},o.id))}):null}function kB({initial:e,user:t,csrf:a,onSnapshot:n}){let[o,r]=(0,sa.useState)(e),s=o.selected,i=`standing-orders:team-draft:${t}:${s?.id??"new"}`,[l,u]=(0,sa.useState)(()=>w9(i)),[c,f]=(0,sa.useState)(""),[d,m]=(0,sa.useState)(!1),[h,w]=(0,sa.useState)(!1),[x,v]=(0,sa.useState)(!1),[y,g]=(0,sa.useState)(null),[b,k]=(0,sa.useState)(!1),[C,N]=(0,sa.useState)(!1),L=(0,sa.useRef)({snapshot:o,draft:l});L.current={snapshot:o,draft:l};let A=(0,sa.useRef)(!1),P=(0,sa.useRef)(null),F=o.leads.find(z=>z.id===s?.leadId),B=typeof window>"u"?null:new URL(window.location.href).searchParams.get("lead"),H=F?.id??o.leads.find(z=>z.id===B)?.id??o.leads[0]?.id??"",[S,I]=(0,sa.useState)(H),R=o.leads.find(z=>z.id===S);(0,sa.useEffect)(()=>{o.leads.some(z=>z.id===S)||I(H)},[o.leads,S,H]);let E=(0,sa.useCallback)(z=>{u(z),N(!1);try{sessionStorage.setItem(i,JSON.stringify(z)),k(!1)}catch{k(!0)}},[i]),q=(0,sa.useCallback)(z=>{r(z),n?.(z);let Y=L.current.draft;Y.text&&z.messages.some(me=>me.author===t&&me.requestId===Y.requestId)&&E(yy())},[E,t,n]),M=(0,sa.useCallback)(async()=>{let z=await fetch("/api/team"+(s?"?conversation="+encodeURIComponent(s.id):""),{credentials:"same-origin",cache:"no-store"}),Y=await z.json();if(z.status===401||z.status===403){v(!0),f(Y.message);return}if(!Y.ok||!Y.snapshot)throw new Error(Y.message||"Updates are unavailable.");q(Y.snapshot),m(!1)},[s?.id,q]);Dn(x?null:id("team",null,{conversation:s?.id}),z=>{z==="change"||z==="reload"?M().catch(()=>m(!0)):z==="gone"?(v(!0),f("Your access changed. Reopen Chat or sign in again.")):z==="lost"&&m(!0)}),(0,sa.useEffect)(()=>{P.current?.scrollIntoView({block:"nearest"})},[o.messages.length]);let _=o.messages.at(-1)?.id;(0,sa.useEffect)(()=>{!s||!_||x||document.hidden||fetch("/api/team",{method:"POST",credentials:"same-origin",headers:yt({"content-type":"application/json","x-csrf-token":a}),body:JSON.stringify({operation:"read",args:{conversationId:s.id,messageId:_}})}).catch(()=>{})},[s?.id,_,x,a]);async function G(z,Y){if(A.current||x)return null;A.current=!0,w(!0),f("");try{let X=await(await fetch("/api/team",{method:"POST",credentials:"same-origin",headers:yt({"content-type":"application/json","x-csrf-token":a}),body:JSON.stringify({operation:z,args:Y})})).json();return X.snapshot&&q(X.snapshot),X.ok?X:(f(X.message),X.code==="delivery-unconfirmed"&&z==="send"&&E({...L.current.draft,uncertain:!0}),null)}catch{return z==="send"&&E({...L.current.draft,uncertain:!0}),f("The response was not confirmed. Check saved messages before sending again."),null}finally{A.current=!1,w(!1)}}async function re(z){if(z.preventDefault(),!s||!l.text.trim()||l.uncertain)return;await G("send",{conversationId:s.id,text:l.text,requestId:l.requestId})&&E(yy())}async function oe(z,Y){z.preventDefault();let me=new FormData(z.currentTarget),X=me.getAll("projects");if(!X.length){f("Choose at least one project.");return}let te=await G(Y,Y==="create-lead"?{name:me.get("name"),instructions:me.get("instructions")??"",projects:X}:{leadId:S,title:me.get("title"),visibility:me.get("visibility"),projects:X}),ge=te?.result&&typeof te.result=="object"?te.result:{};te?.ok&&Y==="create-lead"&&typeof ge.leadId=="string"?gy("/chat?lead="+encodeURIComponent(ge.leadId)):te?.snapshot?.selected?gy("/chat?conversation="+encodeURIComponent(te.snapshot.selected.id)):te?.ok&&await M()}let $=(0,ae.jsxs)("form",{className:"so-team-form",onSubmit:z=>{oe(z,"create-conversation")},children:[o.leads.length>1&&(0,ae.jsxs)("label",{children:["Lead",(0,ae.jsx)("select",{name:"leadId",value:S,onChange:z=>I(z.target.value),children:o.leads.map(z=>(0,ae.jsx)("option",{value:z.id,children:z.name},z.id))})]}),(0,ae.jsxs)("label",{children:["Conversation title",(0,ae.jsx)(ze,{name:"title",required:!0,maxLength:160,placeholder:"What are we working on?"})]}),(0,ae.jsxs)("label",{children:["Audience",(0,ae.jsxs)("select",{name:"visibility",defaultValue:"team",children:[(0,ae.jsx)("option",{value:"team",children:"Team — invited people"}),(0,ae.jsx)("option",{value:"private",children:"Private — only you"})]})]}),(0,ae.jsx)(S1,{projects:R?.projects??[]},S),(0,ae.jsx)(pe,{className:"h-11 min-h-11",type:"submit",disabled:h||!R,children:"Create conversation"})]}),W="canCreateLead"in o&&o.canCreateLead===!0,Q=new Map(o.messages.filter(z=>z.role==="assistant"&&z.turnId!==null).map(z=>[z.turnId,z.id])),ne=new Map;for(let z of o.proposals??[]){if(z.state==="drafting")continue;let Y=Q.get(z.turnId)??null,me=ne.get(Y)??[];me.push(z),ne.set(Y,me)}let V=z=>(0,ae.jsx)(b9,{proposals:ne.get(z)??[],csrf:a,readOnly:x,onChanged:()=>{M().catch(()=>m(!0))}});return(0,ae.jsxs)("section",{className:"so-team-chat","aria-label":"Team conversation",children:[(0,ae.jsxs)("div",{className:"so-team-toolbar",children:[o.leads.length>1&&(0,ae.jsxs)("label",{className:"so-team-lead-select",children:[(0,ae.jsx)("span",{className:"so-sr-only",children:"Lead"}),(0,ae.jsx)("select",{"aria-label":"Lead",value:H,onChange:z=>gy("/chat?lead="+encodeURIComponent(z.target.value)),children:o.leads.map(z=>(0,ae.jsx)("option",{value:z.id,children:z.name},z.id))})]}),s?(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)("div",{className:"so-team-title",children:[(0,ae.jsx)("h2",{children:s.title}),o.leads.length===1&&(0,ae.jsx)("span",{children:F?.name??"Lead"})]}),(0,ae.jsxs)(gr,{summary:s.visibility==="team"?"Team":"Private",className:"so-team-audience",children:[(0,ae.jsx)("h3",{children:"People"}),(0,ae.jsx)("ul",{children:o.participants.filter(z=>z.active).map(z=>(0,ae.jsxs)("li",{children:[(0,ae.jsx)("span",{children:z.account}),(0,ae.jsx)("span",{children:z.role}),o.canManage&&z.account!==t&&(0,ae.jsx)(pe,{className:"h-11 min-h-11",variant:"ghost",onClick:()=>{G("member",{conversationId:s.id,account:z.account,role:z.role,active:!1,expectedRevision:s.revision})},disabled:h,children:"Remove"})]},z.account))}),o.canManage&&s.visibility==="team"&&(0,ae.jsxs)("form",{className:"so-team-form",onSubmit:z=>{z.preventDefault();let Y=new FormData(z.currentTarget);G("member",{conversationId:s.id,account:Y.get("account"),role:Y.get("role"),active:!0,expectedRevision:s.revision,joinLead:!0,expectedLeadRevision:F?.revision})},children:[(0,ae.jsxs)("label",{children:["Person",(0,ae.jsx)("select",{name:"account",required:!0,children:o.accounts.filter(z=>!o.participants.some(Y=>Y.account===z&&Y.active)).map(z=>(0,ae.jsx)("option",{children:z},z))})]}),(0,ae.jsxs)("label",{children:["Access",(0,ae.jsxs)("select",{name:"role",defaultValue:"contributor",children:[(0,ae.jsx)("option",{value:"viewer",children:"Viewer"}),(0,ae.jsx)("option",{value:"contributor",children:"Contributor"}),(0,ae.jsx)("option",{value:"manager",children:"Manager"})]})]}),(0,ae.jsxs)("p",{className:"so-team-small",children:["Adds access to this conversation and ",F?.name??"the lead"," for these projects: ",F?.projects.map(z=>z.split("/").pop()).join(", "),". Existing private conversations stay private."]}),(0,ae.jsx)(pe,{className:"h-11 min-h-11",type:"submit",disabled:h,children:"Add person"})]}),(0,ae.jsxs)("p",{className:"so-team-small",children:["Projects: ",s.projects.map(z=>z.split("/").pop()).join(", ")]})]})]}):(0,ae.jsx)("h2",{children:o.leads.length?"Start a conversation":"Your team lead"})]}),(0,ae.jsxs)("div",{className:"so-team-content",children:[(c||x)&&(0,ae.jsxs)(Mn,{tone:"error",children:[c||"Your access changed.",x&&(0,ae.jsxs)(ae.Fragment,{children:[" ",(0,ae.jsx)("a",{href:"/chat",children:"Reopen Chat"})]})]}),d&&!x&&(0,ae.jsxs)(Mn,{children:["Live updates disconnected. ",(0,ae.jsx)(pe,{className:"h-11 min-h-11",variant:"ghost",onClick:()=>{M().catch(()=>f("Updates are still unavailable. Your draft is saved."))},children:"Check messages"})]}),!s&&o.leads.length>0&&(0,ae.jsxs)(ae.Fragment,{children:[o.conversations.length>0&&(0,ae.jsx)("nav",{className:"so-team-room-list","aria-label":"Conversations",children:o.conversations.map(z=>(0,ae.jsxs)("a",{href:"/chat?conversation="+encodeURIComponent(z.id),children:[(0,ae.jsx)("strong",{children:z.title}),(0,ae.jsx)("span",{children:z.visibility==="team"?"Team":"Private"})]},z.id))}),$]}),!s&&o.leads.length===0&&(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)("p",{children:W?"Create a lead, then invite people into a conversation.":"Ask a team administrator to invite you to a conversation."}),W&&(0,ae.jsxs)("form",{className:"so-team-form",onSubmit:z=>{oe(z,"create-lead")},children:[(0,ae.jsxs)("label",{children:["Lead name",(0,ae.jsx)(ze,{name:"name",defaultValue:"Team lead",required:!0,maxLength:100})]}),(0,ae.jsx)(S1,{projects:o.projects}),(0,ae.jsx)(gr,{summary:"Working instructions",children:(0,ae.jsx)(Gt,{name:"instructions",rows:4,placeholder:"What should this lead focus on?"})}),(0,ae.jsx)(pe,{className:"h-11 min-h-11",type:"submit",disabled:h||!o.projects.length,children:"Create lead"})]})]}),s&&(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)("div",{className:"so-team-messages","aria-live":"polite","aria-relevant":"additions text",children:[o.messages.length===0&&(0,ae.jsxs)("div",{className:"so-team-empty",children:[(0,ae.jsx)("h3",{children:"What would you like to work on?"}),(0,ae.jsx)("p",{children:s.visibility==="team"?"People you invite can join this conversation.":"Only you can read this conversation."})]}),o.messages.map(z=>(0,ae.jsxs)("article",{className:"so-team-message so-team-message--"+z.role,"data-team-message":z.id,children:[(0,ae.jsxs)("div",{className:"so-team-message-meta",children:[(0,ae.jsx)("strong",{children:z.author}),bB(z)&&(0,ae.jsx)(Qr,{tone:["failed","uncertain"].includes(z.status)?"danger":"neutral",children:bB(z)})]}),y===z.id?(0,ae.jsxs)("form",{className:"so-team-form",onSubmit:Y=>{Y.preventDefault();let me=new FormData(Y.currentTarget);G("edit",{conversationId:s.id,messageId:z.id,expectedRevision:z.revision,text:me.get("text")}).then(X=>{X&&g(null)})},children:[(0,ae.jsx)(au,{className:"mb-1.5 grid gap-1.5 text-[13px] font-[550] leading-[inherit]",htmlFor:"team-edit-"+z.id,children:"Edit queued message"}),(0,ae.jsx)(Gt,{id:"team-edit-"+z.id,name:"text",defaultValue:z.text,required:!0,maxLength:2e3,rows:3}),(0,ae.jsxs)("div",{children:[(0,ae.jsx)(pe,{className:"h-11 min-h-11",type:"submit",disabled:h,children:"Save edit"}),(0,ae.jsx)(pe,{className:"h-11 min-h-11",variant:"ghost",onClick:()=>g(null),children:"Cancel"})]})]}):(0,ae.jsx)("p",{className:"so-team-message-text",children:x9(z.text,s.id)}),z.error&&(0,ae.jsx)(Mn,{tone:"error",children:z.error}),z.status==="queued"&&z.author===t&&!x&&(0,ae.jsxs)("div",{className:"so-team-message-actions",children:[(0,ae.jsx)(pe,{className:"h-11 min-h-11",variant:"ghost",onClick:()=>g(z.id),disabled:h,children:"Edit"}),(0,ae.jsx)(pe,{className:"h-11 min-h-11",variant:"ghost",onClick:()=>{G("withdraw",{conversationId:s.id,messageId:z.id,expectedRevision:z.revision})},disabled:h,children:"Withdraw"})]}),V(z.id)]},z.id))]}),o.truncated&&(0,ae.jsx)("p",{className:"so-team-small",children:"Showing the most recent messages."})]}),V(null),(0,ae.jsx)("div",{ref:P}),(0,ae.jsxs)(gr,{summary:"Conversations",className:"so-team-settings",children:[s&&(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)("nav",{className:"so-team-room-list","aria-label":"Other conversations",children:o.conversations.filter(z=>z.id!==s.id).map(z=>(0,ae.jsx)("a",{href:"/chat?conversation="+encodeURIComponent(z.id),children:z.title},z.id))}),(0,ae.jsx)("h3",{children:"New conversation"}),$]}),(0,ae.jsx)("a",{href:"/chat?private=1",children:"Previous private chat"}),o.canManage&&F&&(0,ae.jsx)(gr,{summary:"Lead settings",children:(0,ae.jsxs)("form",{className:"so-team-form",onSubmit:z=>{z.preventDefault();let Y=new FormData(z.currentTarget);G("update-lead",{leadId:F.id,expectedRevision:F.revision,name:Y.get("name"),instructions:Y.get("instructions"),status:Y.get("status")})},children:[(0,ae.jsxs)("label",{children:["Lead name",(0,ae.jsx)(ze,{name:"name",defaultValue:F.name,required:!0,maxLength:100})]}),(0,ae.jsxs)("label",{children:["Working instructions",(0,ae.jsx)(Gt,{name:"instructions",defaultValue:F.instructions,rows:4})]}),(0,ae.jsxs)("label",{children:["Status",(0,ae.jsxs)("select",{name:"status",defaultValue:F.status,children:[(0,ae.jsx)("option",{value:"active",children:"Active"}),(0,ae.jsx)("option",{value:"paused",children:"Paused"})]})]}),(0,ae.jsxs)("p",{className:"so-team-small",children:["Projects: ",F.projects.map(z=>z.split("/").pop()).join(", ")]}),(0,ae.jsx)(pe,{className:"h-11 min-h-11",type:"submit",disabled:h,children:"Save lead"})]})}),W&&o.leads.length>0&&(0,ae.jsx)(gr,{summary:"Add a lead",children:(0,ae.jsxs)("form",{className:"so-team-form",onSubmit:z=>{oe(z,"create-lead")},children:[(0,ae.jsxs)("label",{children:["Lead name",(0,ae.jsx)(ze,{name:"name",required:!0,maxLength:100})]}),(0,ae.jsx)(S1,{projects:o.projects}),(0,ae.jsxs)("label",{children:["Working instructions",(0,ae.jsx)(Gt,{name:"instructions",rows:3})]}),(0,ae.jsx)(pe,{className:"h-11 min-h-11",type:"submit",disabled:h,children:"Create lead"})]})})]})]}),s&&(0,ae.jsxs)("div",{className:"so-team-composer",children:[(0,ae.jsx)(k9,{snapshot:o,execute:G,busy:h}),o.canSend&&!x?(0,ae.jsxs)("form",{onSubmit:z=>{re(z)},children:[(0,ae.jsxs)(au,{htmlFor:"team-message",className:"so-sr-only",children:["Message ",F?.name??"the lead"]}),(0,ae.jsx)(Gt,{id:"team-message",rows:3,value:l.text,placeholder:"Message "+(F?.name??"your lead"),onChange:z=>E({text:z.target.value,requestId:l.uncertain?crypto.randomUUID():l.requestId,uncertain:!1}),disabled:h||l.uncertain,maxLength:2e3}),(0,ae.jsxs)("div",{className:"so-team-compose-actions",children:[o.messages.some(z=>z.status==="running")&&(0,ae.jsx)(pe,{className:"h-11 min-h-11",variant:"outline",onClick:()=>{G("stop",{conversationId:s.id,messageId:o.messages.find(z=>z.status==="running")?.id})},disabled:h,children:"Stop"}),l.uncertain?(0,ae.jsx)(pe,{className:"h-11 min-h-11",onClick:()=>{M().then(()=>{L.current.draft.uncertain&&(N(!0),f("This message is not in saved history. You can send the saved message with its original request identity."))}).catch(()=>f("Saved messages could not be checked. Your draft is preserved."))},children:"Check messages"}):(0,ae.jsx)(pe,{className:"h-11 min-h-11",type:"submit",disabled:h||!l.text.trim()||!o.chatAuthorization?.enabled,children:h?"Saving…":"Send"}),l.uncertain&&C&&(0,ae.jsx)(pe,{className:"h-11 min-h-11",disabled:h,onClick:()=>{G("send",{conversationId:s.id,text:l.text,requestId:l.requestId}).then(z=>{z&&E(yy())})},children:"Send saved message"})]})]}):!x&&(0,ae.jsx)("p",{className:"so-team-small",children:"You can read this conversation. Ask a manager for permission to send messages."}),b&&(0,ae.jsx)(Mn,{children:"Keep this tab open until your message is sent; draft storage is unavailable."})]})]})}function k9({snapshot:e,execute:t,busy:a}){let n=e.chatAuthorization;return!e.selected||!n||!e.canSend?null:n.waitingReason?(0,ae.jsx)(Mn,{children:n.waitingReason}):n.enabled?null:(0,ae.jsxs)("div",{className:"so-team-consent",children:[(0,ae.jsxs)("p",{children:["Enable ",n.provider," · ",n.model," for your messages in this conversation, using the installation’s configured provider account."]}),(0,ae.jsxs)("p",{children:[n.dailyTurns," turns per day",n.weeklyCeilingUsd===null?". Your provider subscription limits apply.":`, $${n.weeklyCeilingUsd} per week and $${n.conversationCeilingUsd} for this conversation.`," Execution approvals still apply."]}),(0,ae.jsx)(pe,{className:"h-11 min-h-11",disabled:a,onClick:()=>{t("authorize",{conversationId:e.selected.id,termsDigest:n.termsDigest,ceilingUsd:n.conversationCeilingUsd})},children:"Enable chat"})]})}var bu=O(ve(),1);var xm=String.raw`https?:\/\/[^\s<>()\[\]"'\`]+`,Hge=new RegExp(String.raw`\[([^\]\n]{1,120})\]\((${xm})\)`,"g"),Fge=new RegExp(String.raw`\x60\x60\x60[\s\S]*?(?:\x60\x60\x60|$)|\x60[^\x60\n]+\x60|\[[^\]\n]{1,120}\]\(${xm}\)|<${xm}>|${xm}`,"g");function LB(e){let t=[],a=new RegExp(String.raw`(\x60\x60\x60[\s\S]*?(?:\x60\x60\x60|$))|\x60([^\x60\n]+)\x60|\*\*([^*\n]+?)\*\*|\[([^\]\n]{1,120})\]\((${xm})\)`,"g"),n=0;for(let o of e.matchAll(a)){let r=o.index??0;r>n&&t.push({kind:"text",text:e.slice(n,r)}),o[1]!==void 0?t.push({kind:"text",text:o[1]}):o[2]!==void 0?t.push({kind:"code",text:o[2]}):o[3]!==void 0?t.push({kind:"bold",text:o[3]}):t.push({kind:"link",label:o[4],url:o[5]}),n=r+o[0].length}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}var SB=String.raw`(?:(?:the|a|an|your|my|this|that|these|those|both|two|three|\d+|new|latest|full|updated|requested|fresh|final)\s+){0,2}`,NB=String.raw`(?:screenshots?|screen\s?shots?|images?|pictures?|photos?|recordings?|videos?|pdfs?|zips?|attachments?|spreadsheets?|csvs?)`,S9=String.raw`(?:files?|logs?|reports?|diffs?|documents?|links?)`,CB=String.raw`(?:${NB}|${S9})`,C9=String.raw`(?:${NB}|links?|files?)`,L9=String.raw`(?:\bi(?:'ve|’ve|\s+have)\s+(?:just\s+)?(?:attached|included|shared|uploaded|sent|enclosed)|\bi(?:'m|’m|\s+am)\s+(?:now\s+)?(?:attaching|sending|sharing|uploading|enclosing)|\bi(?:'ll|’ll|\s+will)\s+(?:now\s+)?(?:attach|send|share|upload|enclose)|^\s*(?:attaching|sending|sharing|uploading|enclosing))\s+(?:you\s+)?`,qge=[new RegExp(String.raw`${L9}${SB}(${CB})\b`,"i"),new RegExp(String.raw`\b(${CB})\s+(?:(?:is|are|was|were)\s+)?(?:attached|enclosed|uploaded|included\s+below)\b`,"i"),new RegExp(String.raw`^\s*(?:here(?:'s|’s|\s+is|\s+are)|(?:attached|below)\s+(?:is|are))\s+${SB}(?:[\w-]+\s+)?(${C9})(?:\s+(?:of|for|to|from|showing)\s+[^:]+?)?[.!:]?\s*$`,"i")];var pt=O(Z(),1),C1=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function N9(e){if(!C1(e)||!Array.isArray(e.steps))return null;let t=e.steps.flatMap((n,o)=>!C1(n)||!Array.isArray(n.tools)?[]:[{tools:n.tools.flatMap((s,i)=>{if(typeof s!="string")return[];let l=Array.isArray(n.toolCalls)?n.toolCalls[i]:null;if(C1(l)&&typeof l.id=="string"&&l.label===s){if(l.state==="succeeded"||l.state==="running")return[{id:l.id,label:s,state:l.state}];if(l.state==="failed"&&typeof l.reason=="string"&&l.reason.trim()!=="")return[{id:l.id,label:s,state:"failed",reason:l.reason}]}return[{id:`unknown:${o}:${i}`,label:s,state:"unknown"}]})}]),a=e.done===!0;return{steps:t,done:a,ok:a&&e.ok===!0,status:typeof e.status=="string"?e.status:"",text:typeof e.text=="string"?e.text:""}}function wy(e,t,a){let[n,o]=(0,bu.useState)(null),r=(0,bu.useRef)(a);r.current=a;let s=(0,bu.useRef)(t);return s.current=t,(0,bu.useEffect)(()=>{o(null)},[e?.sessionId,e?.taskId,e?.project,t]),Dn(e===null?null:id("chat",null,e.taskId?{task:e.taskId}:{project:e.project??null}),(i,l)=>{if(!s.current)return;if(i==="lost"){o(c=>c===null?null:{...c,disconnected:!0}),r.current();return}if(i!=="turn")return;let u=N9(l);u!==null&&(o(c=>u.done&&u.ok&&u.text===""&&c!==null?{...u,text:c.text}:u),u.done&&r.current())}),t?n:null}function xy(){return(0,pt.jsxs)("span",{className:"lc-mark","aria-hidden":"true",children:[(0,pt.jsx)("i",{}),(0,pt.jsx)("i",{}),(0,pt.jsx)("i",{})]})}function IB({text:e,writing:t}){let a=LB(e).map((n,o)=>n.kind==="bold"?(0,pt.jsx)("strong",{children:n.text},o):n.kind==="code"?(0,pt.jsx)("code",{children:n.text},o):n.kind==="link"?(0,pt.jsx)("a",{href:n.url,rel:"noopener noreferrer",target:"_blank",children:n.label},o):n.text);return(0,pt.jsxs)("p",{className:"so-live-text","data-live-text":!0,children:[a,t&&(0,pt.jsx)("span",{className:"so-live-caret","aria-hidden":"true"})]})}function by({live:e,leadName:t,look:a="bubble"}){let n=e?.steps??[],o=!e?.done&&!e?.disconnected,r=n.flatMap(f=>f.tools),s=e?.done&&!e.ok?"":e?.text??"",i=e?.disconnected?"Connection lost — reloading":o?e?.status||"Thinking…":"",l=o&&s!==""&&i==="Writing…",u=r.length>0&&(0,pt.jsx)(un,{summary:`Steps (${r.length})`,children:(0,pt.jsx)("ul",{className:"so-live-steps","aria-label":"Tool steps",children:r.map(f=>{let d=f.state==="running"&&!o?"unknown":f.state,m=d==="succeeded"?"Done":d==="failed"?"Failed":d==="running"?"Running":"Outcome not reported";return(0,pt.jsx)("li",{"data-state":d,"data-done":d==="succeeded"?"true":"false",children:(0,pt.jsxs)("div",{children:[(0,pt.jsx)("span",{children:f.label}),(0,pt.jsxs)("span",{className:"so-tool-status",children:[" · ",m]}),f.state==="failed"&&(0,pt.jsx)("p",{className:"so-tool-reason",children:f.reason})]})},f.id)})})}),c=e?.disconnected===!0?"":void 0;if(a==="lead"){let f=i!==""&&(0,pt.jsxs)("span",{className:"so-working lc-thinking",role:"status","data-live-status":!0,children:[(0,pt.jsxs)("span",{className:"lc-dots","aria-hidden":"true",children:[(0,pt.jsx)("i",{}),(0,pt.jsx)("i",{}),(0,pt.jsx)("i",{})]}),i]}),d=r.length===0&&s==="";return(0,pt.jsxs)("article",{className:"lc-msg lc-lead lc-live so-live-reply","data-live-reply":!0,"data-live-lost":c,"aria-label":`${t} is replying`,children:[(0,pt.jsxs)("header",{className:"lc-who",children:[(0,pt.jsx)(xy,{}),(0,pt.jsx)("b",{children:t}),d&&f]}),!d&&(0,pt.jsxs)("div",{className:"lc-body",children:[s!==""&&(0,pt.jsx)(IB,{text:s,writing:l}),f,u]})]})}return(0,pt.jsxs)(xM,{from:"assistant",className:"so-live-reply","data-live-reply":!0,"data-live-lost":c,children:[(0,pt.jsx)("div",{className:"so-message-label",children:t}),(0,pt.jsxs)(Sv,{children:[s!==""&&(0,pt.jsx)(IB,{text:s,writing:l}),i!==""&&(0,pt.jsxs)("div",{className:"so-working",role:"status","data-live-status":!0,children:[(0,pt.jsx)("span",{className:"so-live-dot"}),i]}),u]})]})}var I9=["summary","changes","checks"],T9=/^[A-Za-z0-9_-][A-Za-z0-9_.:-]{0,159}$/,R9=/^[a-z][a-z-]{0,31}$/;var L1=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>0,A9=e=>e!=null&&T9.test(e)?`#${e}`:"";function sl(e){let t=`/t/${encodeURIComponent(e.task)}`,a=A9(e.anchor);if(e.record===!0){if(L1(e.run))return`/r/${e.run}?record=1${a}`;let s=new URLSearchParams;return e.revision!=null&&e.revision!==""&&s.set("version",e.revision),s.set("tab","record"),`${t}?${s.toString()}${a===""?"#record":a}`}let n=[];e.revision!=null&&e.revision!==""&&n.push(`version=${encodeURIComponent(e.revision)}`);let o=e.section!=null&&I9.includes(e.section)?e.section:null;return(L1(e.run)||o!==null||e.result===!0)&&(n.push("tab=result"),L1(e.run)&&n.push(`run=${e.run}`),o!==null&&o!=="summary"&&n.push(`section=${o}`)),e.feedback?.noted===!0&&n.push("noted=1"),e.feedback?.refused!=null&&R9.test(e.feedback.refused)&&n.push(`refused=${e.feedback.refused}`),`${t}${n.length===0?"":`?${n.join("&")}`}${a}`}var TB={task:{label:"Open task",target:"task"},approval:{label:"Review & start",target:"task"},planning:{label:"Review plan",target:"task"},recovery:{label:"Review recovery options",target:"task"},cancel:{label:"Cancel task",target:"task"},result:{label:"Open result",target:"task"},findings:{label:"Open findings",target:"task"},acceptance:{label:"Inspect result",target:"task"},publish:{label:"Review publication",target:"task"},projects:{label:"Manage projects",href:"/projects"},flows:{label:"Open flows",href:"/flows"},recipes:{label:"Browse workflows",href:"/recipes"},workers:{label:"Manage computers",href:"/settings/computers?section=builders"},slack:{label:"Manage Slack",href:"/settings/slack"},discord:{label:"Manage Discord",href:"/settings/discord"},lead:{label:"Name your lead",href:"/settings/lead"},integrations:{label:"Set up integrations",href:"/settings/integrations"},settings:{label:"Open settings",href:"/settings"},permissions:{label:"Review permissions",href:"/settings"},providers:{label:"Connect an agent",href:"/settings/agents#providers"},skills:{label:"Manage skills",href:"/settings/skills"},tools:{label:"Manage tools",href:"/settings/tools"},knowledge:{label:"Edit project knowledge",href:"/settings/knowledge"},learning:{label:"Review learning history",href:"/settings/learning"},mode:{label:"Review automatic approvals",href:"/mode"},policy:{label:"Review organisation policy",href:"/settings/policy"}};function ky(e,t,a="summary"){return sl({task:e,run:t,section:a})}function RB(e,t,a,n){let o=TB[e];if(e==="skills"||e==="tools")return TB[e].href+(typeof n=="string"&&n?"?repo="+encodeURIComponent(n):"");if("href"in o)return o.href;if(e==="acceptance")return sl({task:t,run:Number.isSafeInteger(a)&&Number(a)>0?Number(a):null,section:"checks",anchor:"result-decision"});if(e==="result"&&Number.isSafeInteger(a)&&Number(a)>0)return ky(t,Number(a));let r="/chat?task="+encodeURIComponent(t);return e==="cancel"||e==="recovery"||e==="publish"?sl({task:t}):e==="findings"?sl({task:t,anchor:"findings"}):r+(e==="approval"||e==="planning"?"#task-chat-action":"")}function E9(e){let t=e.primaryAction;if(t===null)return null;let{taskId:a,runId:n,decisionId:o}=t.target;if(t.code==="inspect-findings")return sl({task:a,anchor:"findings"});if(o!==null)return`/d/${o}`;if(t.code==="inspect-decisions")return"/";if(t.code==="sign-in")return"/settings/agents#providers";if(t.code==="answer-agent"&&n!==null)return`/agents?run=${n}`;if(t.code==="recheck-stopped")return`/t/${encodeURIComponent(e.rootId)}#recheck-stopped`;if(t.code==="open-result"&&n!==null)return ky(a,n);if(t.code==="open-pr"&&/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/\d+$/.test(e.publicationUrl??""))return e.publicationUrl;if(n!==null&&(t.code==="open-pr"||t.code==="retry-review"))return sl({task:a,run:n});if(n!==null&&(t.code==="inspect-run"||t.code==="reconcile-run"))return`/r/${n}`;if(t.code==="start-worker")return mO(a);let r=t.code==="approve-scope"?"#approve":t.code==="inspect-stop"||t.code==="resume-run"?"#task-control":t.code==="unhold"?"#task-actions":t.code==="write-scope"||t.code==="select-agent"?"#scope":t.code==="inspect-hold"?"#holds":t.code==="repair-dependency"?"#run-status":"";return`/t/${encodeURIComponent(e.rootId)}?version=${encodeURIComponent(a)}`+r}function AB(e,t){let a=o=>t&&o.startsWith("/chat?")?o+"&conversation="+encodeURIComponent(t):o,n=e.items.map(o=>{let r=o.status,s=m=>m.trim().replace(/\s+/g," ").replace(/[.!?]+$/,"").toLowerCase(),i=["Waiting","Failed","Needs you"].includes(r.label)&&s(r.detail)!==""&&s(r.detail)!==s(r.label)?r.detail:void 0,l=o.resultRunId===null||o.resultTaskId===null||o.resultOutcome!=="built"&&o.resultOutcome!=="no-change"?null:ky(o.resultTaskId,o.resultRunId),u=RB("task",o.rootId),c=o.primaryAction,f=E9(o);return{item:{id:o.rootId,title:o.title,project:o.repo,state:o.assignmentState,label:r.label,tone:r.tone,href:a(u),resultHref:l===null?null:a(l),action:c===null||f===null?null:{label:c.label,href:a(f)},updatedAt:o.updatedAt,...i===void 0?{}:{detail:i},...o.lead===void 0?{}:{lead:o.lead}},rank:r.rank}});return n.sort((o,r)=>o.rank-r.rank),{crew:n.map(o=>o.item),crewTruncated:e.nextCursor!==null}}var Sn=O(ve(),1),MB=O(_o(),1),lo=O(Z(),1),Sy={path:300,code:240,note:1500},EB=(e,t)=>{let a=e.replace(/[\u0000-\u001f\u007f]+/g," ").replace(/\s+/g," ").trim();return a.length>t?`${a.slice(0,t-1)}…`:a};function M9(e){let t=`${JSON.stringify(EB(e.path,Sy.path))}:${e.line}${e.side==="old"?" (removed line)":""}`,a=EB(e.code,Sy.code),n=e.note.trim().slice(0,Sy.note);return`On ${t} (run #${e.run}): ${n}
|
|
62
62
|
|
|
63
|
-
> ${a}`}function D9(e){let t=e?.querySelector("code");if(!t)return"";let a=t.querySelector("b");return(t.textContent??"").slice(a?.textContent?.length??0)}function DB({host:e,run:t,maxChars:a,steer:n}){let[o,r]=(0,Sn.useState)(null),[s,i]=(0,Sn.useState)(""),[l,u]=(0,Sn.useState)("editing"),[c,f]=(0,Sn.useState)(null),d=(0,Sn.useRef)(null),m=(0,Sn.useId)(),h=(0,Sn.useRef)(!1),w=k=>{h.current||(k?.slot.remove(),r(null),i(""),u("editing"),f(null),k?.pin.isConnected&&k.pin.focus())};if((0,Sn.useEffect)(()=>{let k=e.current;if(!k)return;k.setAttribute("data-line-steer","");let C=()=>k.querySelectorAll("[data-review-diff]").forEach(A=>{A.getAttribute("data-mode")!=="annotate"&&A.setAttribute("data-mode","annotate")});C();let N=new MutationObserver(C);N.observe(k,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["data-mode"]});let L=A=>{let F=(A.target instanceof Element?A.target:null)?.closest("button.pick-line");if(!F||!k.contains(F))return;let B=Number(F.dataset.line),H=F.dataset.path??"";if(!Number.isSafeInteger(B)||B<1||H==="")return;A.preventDefault(),A.stopPropagation();let S=F.closest(".diff-line");!S||h.current||(r(I=>{I?.slot.remove();let R=document.createElement("div");return R.className="diff-steer-slot",S.after(R),{slot:R,pin:F,path:H,line:B,side:F.dataset.side==="old"?"old":"new",code:D9(S)}}),i(""),u("editing"),f(null))};return k.addEventListener("click",L,!0),()=>{k.removeEventListener("click",L,!0),N.disconnect(),k.removeAttribute("data-line-steer")}},[e]),(0,Sn.useEffect)(()=>{o&&l==="editing"&&d.current?.focus()},[o,l]),(0,Sn.useLayoutEffect)(()=>{let k=d.current;if(!k)return;let C=()=>{k.style.height="0px",k.style.height=`${Math.min(88,Math.max(22,k.scrollHeight))}px`};if(C(),typeof ResizeObserver>"u")return;let N=k.clientWidth,L=new ResizeObserver(()=>{k.clientWidth!==N&&(N=k.clientWidth,C())});return L.observe(k),()=>L.disconnect()},[s,o,l]),(0,Sn.useEffect)(()=>()=>{o?.slot.remove()},[o]),o===null||!o.slot.isConnected)return null;let x=M9({run:t,path:o.path,line:o.line,side:o.side,code:o.code,note:s}),v=x.length>a,y=async()=>{if(!(s.trim()===""||v||l!=="editing"||h.current)){h.current=!0,u("sending"),f(null);try{let k=await n(x);if(k===null){let C=o.slot.contains(document.activeElement);u("sent"),C&&o.pin.isConnected&&o.pin.focus()}else u("editing"),f(k)}finally{h.current=!1}}},g=s.trim()==="";return(0,MB.createPortal)(l==="sent"?(0,lo.jsxs)("p",{className:"diff-steer-sent",role:"status","data-steer-sent":!0,children:[(0,lo.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",children:(0,lo.jsx)("path",{d:"m5 12 5 5 9-10"})}),(0,lo.jsxs)("span",{children:["Sent to the lead · ",(k=>{let C=k.replace(/\s+/g," ").trim();return C.length>60?`${C.slice(0,59)}…`:C})(s)]})]}):(0,lo.jsxs)("form",{className:"diff-steer","data-diff-steer":!0,"data-diff-file":o.path,"data-diff-line":o.line,onSubmit:k=>{k.preventDefault(),y()},onKeyDown:k=>{k.key==="Escape"&&!k.nativeEvent.isComposing&&(k.preventDefault(),w(o))},children:[(0,lo.jsxs)("label",{htmlFor:m,className:"so-sr-only",children:["Comment on line ",o.line," of ",o.path,", for the lead. Enter sends; Escape cancels."]}),(0,lo.jsxs)("div",{className:"diff-steer-row",children:[(0,lo.jsx)("textarea",{ref:d,id:m,rows:1,maxLength:Sy.note,value:s,readOnly:l==="sending",placeholder:"Comment for the lead…",onChange:k=>i(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!k.shiftKey&&!k.nativeEvent.isComposing&&(k.preventDefault(),y())}}),(0,lo.jsx)("button",{type:"submit",className:"diff-steer-send",disabled:g||v||l==="sending","aria-label":l==="sending"?"Sending to the lead":"Send to the lead",title:"Send to the lead",children:(0,lo.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,lo.jsx)("path",{d:"M12 19V5M6 11l6-6 6 6"})})})]}),(c!==null||v)&&(0,lo.jsx)("p",{className:"diff-steer-problem",role:"alert",children:v?"That's longer than one message can be. Shorten the comment.":c})]}),o.slot)}var ku=O(ve(),1);var lt=O(ve(),1);var N1=O(ve(),1);var ft=O(Z(),1),Cy=e=>`toolroll:steer-draft:${e}`;function Jo(){return{text:"",key:typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`k${Date.now().toString(36)}${Math.random().toString(36).slice(2,12)}`,submitted:!1}}function Rd(e){try{let t=JSON.parse(sessionStorage.getItem(Cy(e))??"null");return t===null||typeof t.text!="string"||typeof t.key!="string"?Jo():new URLSearchParams(location.search).get("sent")===t.key?(sessionStorage.removeItem(Cy(e)),Jo()):{text:t.text,key:t.key,submitted:t.submitted===!0}}catch{return Jo()}}function cs(e,t){try{t.text===""&&!t.submitted?sessionStorage.removeItem(Cy(e)):sessionStorage.setItem(Cy(e),JSON.stringify(t))}catch{}}function _B({controls:e,back:t}){let a=e.pause;return(0,ft.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-border pt-3 phone:px-4","data-agent-controls":e.send??"none",children:[(0,ft.jsx)("p",{className:"min-w-0 flex-1 text-caption text-muted-foreground","data-agent-capability":!0,children:e.words}),a!==null&&(a.state==="paused"?(0,ft.jsxs)(Fe,{action:a.action,"data-agent-resume":!0,children:[(0,ft.jsx)("input",{type:"hidden",name:"run",value:String(a.run)}),(0,ft.jsx)("input",{type:"hidden",name:"request",value:a.requests[2]}),(0,ft.jsx)("input",{type:"hidden",name:"mode",value:"resume"}),(0,ft.jsx)("input",{type:"hidden",name:"return",value:t}),(0,ft.jsx)(pe,{type:"submit",variant:"outline",size:"sm",className:"h-9 phone:h-11",children:"Resume"})]}):(0,ft.jsxs)(Fe,{action:a.action,"data-agent-pause":!0,children:[(0,ft.jsx)("input",{type:"hidden",name:"run",value:String(a.run)}),(0,ft.jsx)("input",{type:"hidden",name:"request",value:a.requests[0]}),(0,ft.jsx)("input",{type:"hidden",name:"return",value:t}),(0,ft.jsx)(pe,{type:"submit",variant:"outline",size:"sm",className:"h-9 phone:h-11",disabled:a.state==="pausing",children:a.state==="pausing"?"Pausing…":"Pause"})]})),e.stop!==null&&(0,ft.jsxs)(Fe,{action:e.stop.action,"data-agent-stop":e.stop.run,children:[(0,ft.jsx)("input",{type:"hidden",name:"run",value:String(e.stop.run)}),(0,ft.jsx)("input",{type:"hidden",name:"return",value:t}),(0,ft.jsx)(pe,{type:"submit",variant:"outline",size:"sm",className:"h-9 phone:h-11",children:e.stop.label})]})]})}function Ly({steer:e,controls:t,back:a,label:n="A note for the agent",note:o}){let[r,s]=(0,N1.useState)(()=>Rd(e.run)),i=c=>s(f=>{let d=f.submitted?{...Jo(),text:c}:{...f,text:c};return cs(e.run,d),d}),l=t.pause!==null&&t.pause.state===null?t.pause:null,u=r.text.trim()==="";return(0,ft.jsxs)(Fe,{action:e.action,"data-steer-note":e.run,onSubmit:c=>{if(u){c.preventDefault();return}s(f=>{let d={...f,submitted:!0};return cs(e.run,d),d})},children:[(0,ft.jsx)("input",{type:"hidden",name:"return",value:a}),(0,ft.jsx)("input",{type:"hidden",name:"run",value:String(e.run)}),(0,ft.jsx)("input",{type:"hidden",name:"key",value:r.key}),l!==null&&(0,ft.jsx)("input",{type:"hidden",name:"request",value:`steer-${r.key}`}),(0,ft.jsx)(rl,{id:`steer-note-${e.run}`,label:n,placeholder:n,name:"note",maxLength:4e3,submit:!0,value:r.text,onChange:i,onSend:()=>{},sendLabel:"Send",note:o,before:l!==null?(0,ft.jsx)(de,{sm:!0,type:"submit",formAction:l.action,label:"Pause and send",disabled:u,"data-steer-pause-send":""}):void 0})]})}function PB({runs:e,action:t,back:a}){let[n,o]=(0,N1.useState)(()=>{for(let s of e){let i=Rd(s);if(i.text.trim()!=="")return{run:s,draft:i}}return null});if(n===null)return null;let r=()=>{cs(n.run,{...Jo(),text:""}),o(null)};return(0,ft.jsxs)(Fe,{action:t,className:"flex flex-col gap-2 border-t border-border pt-3","data-steer-unsent":n.run,children:[(0,ft.jsx)("p",{className:"text-caption font-medium text-muted-foreground",children:"Your note wasn't sent: its attempt ended first."}),(0,ft.jsx)("p",{className:"rounded-md border border-border bg-muted px-3 py-2 text-body whitespace-pre-wrap break-words","data-steer-unsent-text":!0,children:n.draft.text}),(0,ft.jsx)("input",{type:"hidden",name:"note",value:n.draft.text}),(0,ft.jsx)("input",{type:"hidden",name:"after",value:String(n.run)}),(0,ft.jsx)("input",{type:"hidden",name:"key",value:n.draft.key}),(0,ft.jsx)("input",{type:"hidden",name:"return",value:a}),(0,ft.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,ft.jsx)(pe,{type:"submit",className:"h-11 w-auto",children:"Send to the next attempt"}),(0,ft.jsx)(pe,{type:"button",variant:"ghost",className:"h-11 w-auto",onClick:r,children:"Discard"})]})]})}var Ny=15e3,Iy=600,_9=/<\s*(input|form|button|select|textarea)\b/i,P9=e=>_9.test(e),O9=/^[0-9a-f]{32,64}$/,B9=/^[0-9a-f]{32}$/,z9=/^[0-9]{1,15}$/;function ds(e){let t=e?.view;return t!=null&&t.kind==="task"&&typeof t.id=="string"?t:null}function bm(e){let t=ds(e),a=t?.approve??null;if(t===null||a===null)return null;let n=a.fields.digest??"",o=a.fields.rebuild??null;if(!O9.test(n)||o!==null&&!z9.test(o)||a.action!==`/t/${encodeURIComponent(t.id)}/approve`)return null;let r=a.rememberedUntil===null?null:new Date(a.rememberedUntil).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),s={...a.facts,rememberedUntil:r},i=typeof a.sheetHtml=="string"?a.sheetHtml:null;return{taskId:t.id,action:a.action,digest:n,rebuild:o,heading:a.heading,text:a.text,termsWords:a.termsWords??gu(a.kind,s),planHtml:i!==null&&!P9(i)?i:null,kind:a.kind,facts:s}}function Ty(e,t){if(e===null||t||e.planHtml===null)return!1;let a=al(e.kind,e.facts);return a==="click"||a==="automatic"}function Ad(e,t=fetch,a){return od(e,"prefetch",t,a)}async function Ry(e,t=fetch){let a;try{a=new URL(Iv(e),window.location.origin)}catch{return null}if(a.origin!==window.location.origin)return null;a.hash="",a.searchParams.set("format","workspace"),a.searchParams.delete("request");try{let n=await t(a.pathname+a.search,{credentials:"same-origin",cache:"no-store",redirect:"manual",headers:{accept:"application/json"},signal:AbortSignal.timeout(Ny)});if(n.status!==200||n.redirected||n.type==="opaqueredirect"||!(n.headers.get("content-type")??"").includes("application/json"))return null;let o=await n.json();return nd(o)?o:null}catch{return null}}function Ay(e){let t=ds(e)?.approve?.fields.nonce??"";return B9.test(t)?t:null}var H9=["approved","vote","approved-not-rebuilt","refused"];async function Ey(e,t,a,n=fetch){let o=new URLSearchParams({csrf:t,nonce:a,digest:e.digest});e.rebuild!==null&&o.set("rebuild",e.rebuild),o.set("return","next");let r;try{r=await n(e.action,{method:"POST",credentials:"same-origin",redirect:"manual",body:o,headers:yt({"x-toolroll-act":"in-place",accept:"application/json"}),signal:AbortSignal.timeout(Ny)})}catch{return{kind:"lost"}}if(r.type==="opaqueredirect"||r.redirected||!(r.headers.get("content-type")??"").includes("application/json"))return{kind:"elsewhere"};let s;try{s=await r.json()}catch{return{kind:"lost"}}if(s===null||typeof s!="object")return{kind:"elsewhere"};let{outcome:i,words:l}=s;return typeof i!="string"||!H9.includes(i)||typeof l!="string"?{kind:"elsewhere"}:i!=="refused"&&r.status!==200?{kind:"elsewhere"}:{kind:"answer",outcome:i,words:l}}function Hn(e){let t=e.trim();if(t==="")return"";let a=t.charAt(0).toUpperCase()+t.slice(1);return/[.!?]$/.test(a)?a:`${a}.`}var il=O(ve(),1);function I1(e){let t=Math.max(0,Math.floor(e/1e3));if(t<10)return"just now";if(t<60)return`${t} s ago`;let a=Math.floor(t/60);return a<60?`${a} min ago`:`${Math.floor(a/60)} h ago`}function OB(e,t){let a=Date.parse(e.at),n=Number.isNaN(a)?0:Math.max(0,t-a);return e.worker==="offline"?{text:`Worker offline · last word ${I1(n)}`,quiet:!0,stale:!1}:n>=3e5?{text:`Last update ${I1(n)}`,quiet:!1,stale:!0}:{text:`${e.what} · ${I1(n)}`,quiet:!1,stale:!1}}var My=O(Z(),1),da="so:workspace-nudge";function ll(e=5e3){let[t,a]=(0,il.useState)(()=>Date.now());return(0,il.useEffect)(()=>{let n=window.setInterval(()=>a(Date.now()),e);return()=>window.clearInterval(n)},[e]),t}function km({activity:e,className:t}){let a=OB(e,ll());return(0,My.jsx)("span",{className:ye("block min-w-0 truncate text-body",a.quiet?"font-medium text-foreground":"font-normal text-muted-foreground",t),"data-activity":a.quiet?"quiet":a.stale?"stale":"fresh",title:a.text,children:(0,My.jsx)("time",{dateTime:e.at,children:a.text})})}function BB({people:e}){if(e.length===0)return null;let t=e.length===1?`${e[0]} is also here`:e.length===2?`${e[0]} and ${e[1]} are also here`:`${e[0]} and ${e.length-1} others are also here`;return(0,My.jsx)("span",{className:"min-w-0 truncate","data-also-viewing":e.length,role:"status",title:e.join(", "),children:t})}function zB(e){let[t,a]=(0,il.useState)([]),n=(0,il.useRef)(e?.at??null);n.current=e?.at??null;let o=e?.room??null;return(0,il.useEffect)(()=>{o===null&&a([])},[o]),Dn(o,(r,s)=>{let i=()=>window.dispatchEvent(new CustomEvent(da));if(r==="change"){let l=s.at;(typeof l!="string"||l!==n.current)&&i()}else if(r==="reload")i();else if(r==="here"){let l=s.people;Array.isArray(l)&&a(l.filter(u=>typeof u=="string"))}else(r==="gone"||r==="lost")&&a([])}),t}var F9=65,HB=1e4,q9=20,$9=2,U9=[/^\/$/,/^\/t\/[^/]+$/,/^\/projects$/,/^\/agents$/,/^\/search$/];function R1(e){return e.pathname==="/agents"&&(e.searchParams.get("view")==="live"||e.searchParams.has("run"))?!1:U9.some(t=>t.test(e.pathname))}function FB(e){let t=new URLSearchParams(e.search);for(let n of["format","request","draft"])t.delete(n);let a=t.toString();return e.pathname+(a===""?"":`?${a}`)}var fs=new Map,ul=new Map,Sm=0,T1=()=>Date.now();function V9(){return document.hidden?!1:navigator.connection?.saveData!==!0}function Dy(){Sm+=1,fs.clear();for(let e of ul.values())e.stop.abort();ul.clear()}function A1(e){if(!V9()||!R1(e)||e.origin!==window.location.origin)return;let t=FB(e),a=fs.get(t);if(a!==void 0&&T1()-a.at<HB||ul.has(t)||ul.size>=$9)return;let n=Sm,o=new AbortController,r=od(t,"prefetch",fetch,o.signal).then(s=>{if(ul.get(t)?.stop===o&&ul.delete(t),s===null||n!==Sm)return null;for(fs.delete(t),fs.set(t,{page:s,at:T1()});fs.size>q9;)fs.delete(fs.keys().next().value);return s});ul.set(t,{stop:o,done:r})}function qB(e){let t=FB(e),a=fs.get(t);if(fs.delete(t),a!==void 0&&T1()-a.at<HB)return{page:a.page};let n=ul.get(t);if(n===void 0)return null;let o=Sm;return{pending:n.done.then(r=>o!==Sm?null:(fs.delete(t),r))}}function $B(e){let t=null,a=c=>c instanceof Element?c.closest("a[href]"):null,n=c=>{if(c===null)return;let f=e(c);f!==null&&A1(f)},o=()=>{t!==null&&clearTimeout(t.timer),t=null},r=c=>{if(c.pointerType==="touch")return;let f=a(c.target);f!==t?.anchor&&(o(),f!==null&&(t={anchor:f,timer:setTimeout(()=>{t=null,n(f)},F9)}))},s=c=>{if(t===null)return;let f=c.relatedTarget;f instanceof Node&&t.anchor.contains(f)||o()},i=c=>{n(a(c.target))},l=c=>{let f=a(c.target),d=!0;try{d=f?.matches(":focus-visible")??!1}catch{}d&&n(f)},u=c=>{let f=c.detail;f?.room==="workspace"&&f.event==="change"&&Dy()};return document.addEventListener("pointerover",r,{passive:!0}),document.addEventListener("pointerout",s,{passive:!0}),document.addEventListener("touchstart",i,{passive:!0}),document.addEventListener("focusin",l),window.addEventListener(Mv,u),window.addEventListener(da,Dy),()=>{o(),Dy(),document.removeEventListener("pointerover",r),document.removeEventListener("pointerout",s),document.removeEventListener("touchstart",i),document.removeEventListener("focusin",l),window.removeEventListener(Mv,u),window.removeEventListener(da,Dy)}}function UB(e){let t;try{t=new URL(e,"http://in-place.invalid").pathname}catch{return 1}return Math.max(1,t.split("/").filter(a=>a!=="").length)}function D1(e,t){let a=UB(e),n=UB(t);return n>a?"deeper":n<a?"shallower":"same"}var E1=["so-nav","so-nav-same","so-nav-deeper","so-nav-shallower"],jB="form[data-workspace-composer], .so-home-ask",WB="so-message-box",_y=null;function _1(){try{_y?.skipTransition()}catch{}}function VB(){document.querySelector(jB)?.style.setProperty("view-transition-name",WB)}function M1(){document.querySelectorAll(jB).forEach(e=>{e.style.getPropertyValue("view-transition-name")===WB&&e.style.removeProperty("view-transition-name")})}function j9(){try{if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return!1}catch{}return!document.hidden}function P1(e,t){_1();let a=document.startViewTransition;if(t===null||typeof a!="function"||!j9())return e(),Promise.resolve();let n=document.documentElement;n.classList.remove(...E1),n.classList.add("so-nav",`so-nav-${t}`),VB();let o=!1,r=null,s,i=new Promise(f=>{s=f}),l=()=>{if(!o){o=!0,M1();try{e()}catch(f){r=f}VB(),s()}},u;try{u=a.call(document,l)}catch{return n.classList.remove(...E1),M1(),l(),r===null?i:Promise.reject(r)}_y=u;let c=()=>{_y===u&&(_y=null,n.classList.remove(...E1),M1())};return u.finished.then(c,c),u.ready.catch(()=>{}),u.updateCallbackDone.catch(()=>{}).finally(l),i.then(()=>{if(r!==null)throw r})}var W9=[/^\/$/,/^\/t\/[^/]+$/,/^\/projects$/,/^\/agents$/,/^\/search$/,/^\/settings(?:\/[a-z-]+)?$/];function V1(e){return W9.some(t=>t.test(e.pathname))&&!(e.pathname==="/agents"&&e.searchParams.get("view")==="live")}var K9=(e,t)=>{t?window.location.replace(e):window.location.assign(e)};function uo(e,t=!1){Im()||K9(e,t)}function nz(e){if(!(e instanceof HTMLAnchorElement)||e.hasAttribute("target")||e.hasAttribute("download")||e.closest("[data-full-load]")!==null)return null;let t;try{t=new URL(e.getAttribute("href")??"",window.location.href)}catch{return null}return t.origin!==window.location.origin||t.protocol!=="http:"&&t.protocol!=="https:"||t.hash!==""&&t.pathname===window.location.pathname&&t.search===window.location.search?null:t}function G9(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return null;let t=e.target,a=t instanceof Element?t.closest("a[href]"):null;return a===null?null:nz(a)}function Py(){return document.querySelector("form[data-k-gate][data-dirty]")!==null}var H1="toolroll",Y9=e=>typeof e=="object"&&e!==null&&e[H1]==="in-place",By="toolrollEntry",na=null,Tr=null,F1="",q1=0,Ed=null,Qs="",j1=!1,oz=e=>{let t=new URLSearchParams(e.search);t.delete("draft");let a=t.toString();return e.pathname+(a===""?"":`?${a}`)},Js=()=>oz(window.location),rz=1e4,Md=0,Zs=null,Nm=new Set;function Im(){return Md!==0&&Date.now()-Md<rz}function sz(e){if(!Im()){e();return}Nm.add(e)}function W1(){q1+=1,Tr?.abort(),Tr=null,Oy(!1),$1(null)}function KB(){Md=Date.now(),W1(),Zs!==null&&clearTimeout(Zs),Zs=setTimeout(iz,rz),ps&&Nm.add(()=>{ps&&Tr===null&&uo(window.location.href,!0)})}function iz(){if(Md===0)return;Md=0,Zs!==null&&clearTimeout(Zs),Zs=null;let e=[...Nm];Nm.clear();for(let t of e)t()}var O1="data-so-pressed",GB="data-so-loading",X9=150,Cm=null;function $1(e){document.querySelectorAll(`[${O1}]`).forEach(t=>{t!==e&&t.removeAttribute(O1)}),e?.setAttribute(O1,"")}function Oy(e){Cm!==null&&clearTimeout(Cm),Cm=null;let t=()=>document.querySelector(".so-main-column");if(!e){t()?.removeAttribute(GB);return}Cm=setTimeout(()=>{Cm=null,t()?.setAttribute(GB,"")},X9)}var ps=!1;function Tm(){return ps}function B1(e){ps=e;let t=document.getElementById("workspace-main"),a=[...t?.children??[],...document.querySelectorAll("[data-workspace-detail]")];for(let n of a)n.toggleAttribute("inert",e);e?t?.setAttribute("data-so-provisional",""):t?.removeAttribute("data-so-provisional")}var lz=8;function Z9(e,t){let a=[];for(let n=t;n!==null&&n!==e;n=n.parentElement){let o=n.parentElement;if(o===null)return"";a.push(Array.prototype.indexOf.call(o.children,n))}return a.reverse().join(".")}function Q9(e,t){let a=e;if(t==="")return e;for(let n of t.split("."))if(a=a?.children[Number(n)]??null,a===null)return null;return a}function Hy(){let e=document.getElementById("workspace-main"),t=[];if(e!==null){for(let a of[e,...e.querySelectorAll("*")])if((a.scrollTop>0||a.scrollLeft>0)&&t.push([Z9(e,a),a.scrollTop,a.scrollLeft]),t.length>=lz)break}return{x:window.scrollX,y:window.scrollY,parts:t}}function J9(e){if(typeof e!="object"||e===null)return null;let{x:t,y:a,parts:n}=e;return typeof t!="number"||typeof a!="number"||!Array.isArray(n)||n.length>lz?null:n.every(r=>Array.isArray(r)&&r.length===3&&typeof r[0]=="string"&&/^(\d+(\.\d+)*)?$/.test(r[0])&&typeof r[1]=="number"&&typeof r[2]=="number")?{x:t,y:a,parts:n}:null}function zy(e){let t=document.getElementById("workspace-main");if(t!==null)for(let[a,n,o]of e.parts){let r=Q9(t,a);r!==null&&(r.scrollTop=n,r.scrollLeft=o)}(e.x!==0||e.y!==0)&&window.scrollTo(e.x,e.y)}function uz(e,t){zy(e),requestAnimationFrame(()=>requestAnimationFrame(()=>{t()&&zy(e)}))}function cl(e){let t=typeof e=="object"&&e!==null?e[By]:null;return typeof t=="string"&&/^[0-9a-f]{16}$/.test(t)?t:null}function YB(){return Array.from(crypto.getRandomValues(new Uint8Array(8)),e=>e.toString(16).padStart(2,"0")).join("")}var cz="toolroll.places",dz=50,z1=null;function fz(){if(z1!==null)return z1;let e=new Map;try{let t=JSON.parse(window.sessionStorage.getItem(cz)??"[]");if(Array.isArray(t))for(let a of t.slice(-dz)){let n=Array.isArray(a)&&a.length===2?cl({[By]:a[0]}):null,o=n===null?null:J9(a[1]);n!==null&&o!==null&&e.set(n,o)}}catch{}return z1=e,e}function K1(e,t){if(e===null)return;let a=fz();for(a.delete(e),a.set(e,t);a.size>dz;)a.delete(a.keys().next().value);try{window.sessionStorage.setItem(cz,JSON.stringify([...a]))}catch{}}function eY(e){let t=cl(e);return t===null?null:fz().get(t)??null}var Lm=null;function Fy(){Lm!==null&&clearTimeout(Lm),Lm=null}function XB(){Fy();let e=Js();Lm=setTimeout(()=>{Lm=null,!(na===null||e!==Js()||e!==Qs)&&K1(cl(window.history.state),Hy())},150)}async function U1(e,t,a=null,n=null){Tr?.abort(),_1(),Fy();let o=new AbortController,r=++q1,s=()=>q1!==r;Tr=o,F1="";let i=t==="pop",l=na?.current();$1(n);let u;try{u=new URL(e,window.location.href)}catch{uo(e,i);return}if(F1=oz(u),na===null||l===void 0||l.inPlace!==!0||!V1(u)||Py()){uo(e,i);return}let c=window.location.href,f=qB(u),d=od(u.pathname+u.search,"navigate",fetch,o.signal),m=null;if(f!==null&&"page"in f?m=f.page:(Oy(!0),f!==null&&(m=await Promise.race([f.pending,d.then(()=>null)]))),s())return;let h=()=>{Tr===o&&(Tr=null),Oy(!1),$1(null)};if(m!==null&&!Py()){if(Oy(!1),!na.accept(m,e,i,"navigate")){o.abort(),h();return}let x=m;if(await P1(()=>{s()||na===null||(ZB(u,t),document.title=x.title,ps=!0,na.show(x,!0),B1(!0),a!==null&&zy(a))},D1(l.path,x.path)),s())return;QB(x.title,u.hash!=="",a);let v=await d;if(s())return;if(h(),v===null){uo(e,!0);return}if(!na.accept(v,e,!0,"confirm"))return;let y=Hy(),g=document.activeElement?.id==="workspace-main"||document.activeElement===document.body;document.title=v.title,ps=!1,na.show(v,!1),B1(!1),g&&document.getElementById("workspace-main")?.focus({preventScroll:!0}),uz(y,()=>Tr===null&&Qs===Js()),JB(c,t);return}let w=await d;if(!s()){if(h(),w===null){uo(e,i);return}if(Py()){uo(e,i);return}na.accept(w,e,i,"navigate")&&(await P1(()=>{s()||na===null||(ZB(u,t),document.title=w.title,ps=!1,na.show(w,!1),B1(!1),a!==null&&zy(a))},D1(l.path,w.path)),!s()&&(QB(w.title,u.hash!=="",a),JB(c,t)))}}function ZB(e,t){if(t==="push"){let a=window.history.state,n=cl(a)??YB(),o=YB();K1(n,Hy()),window.history.replaceState({...typeof a=="object"&&a!==null?a:{},[H1]:"in-place",[By]:n},""),window.history.pushState({[H1]:"in-place",[By]:o},"",e.pathname+e.search+e.hash),j1=!0,Ed=o}else Ed=cl(window.history.state);Qs=Js()}function QB(e,t,a){let n=document.getElementById("workspace-main");if(n?.focus({preventScroll:!0}),aY(e),a!==null){uz(a,()=>!0);return}t||(n?.scrollTo?.(0,0),document.querySelectorAll("#workspace-main .so-page-content, #workspace-main [data-kit-page]").forEach(o=>o.scrollTo?.(0,0)),window.scrollTo(0,0))}var tY=400;function JB(e,t){if(t!=="push")return;let a;try{a=new URL(e)}catch{return}R1(a)&&setTimeout(()=>{na!==null&&Tr===null&&na.current().inPlace===!0&&A1(a)},tY)}function aY(e){let t=document.getElementById("so-page-announce");t===null&&(t=document.createElement("div"),t.id="so-page-announce",t.className="so-sr-only",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),document.body.append(t)),t.textContent="";let a=t;requestAnimationFrame(()=>{a.textContent=e})}function nY(e){if(na===null||na.current().inPlace!==!0||Im())return null;let t=nz(e);return t===null||!V1(t)||t.pathname+t.search===window.location.pathname+window.location.search?null:t}function ez(e){let t=G9(e);if(t===null||na===null||na.current().inPlace!==!0||!V1(t)||Py())return;e.preventDefault();let a=e.target instanceof Element?e.target.closest("a[href]"):null;U1(t.pathname+t.search+t.hash,"push",null,a)}function tz(e){if(Fy(),na===null)return;let t=window.location.pathname+window.location.search+window.location.hash;if(Js()===Qs){Ed=cl(e.state),ps&&Tr!==null&&F1===Qs||W1(),ps&&Tr===null&&U1(t,"pop",null);return}na.current().inPlace!==!0&&!j1&&!Y9(e.state)||(K1(Ed,Hy()),U1(t,"pop",eY(e.state)))}function az(){Js()===Qs&&(Ed=cl(window.history.state))}function Rm(e){if(na!==null&&Js()!==Qs)return!1;try{window.history.replaceState(window.history.state,"",e)}catch{return!1}return na!==null&&(Qs=Js()),!0}function pz(e){na=e,Qs=Js(),Ed=cl(window.history.state),j1=!1,Md=0,Nm.clear(),ps=!1,Zs!==null&&clearTimeout(Zs),Zs=null;try{window.history.scrollRestoration="manual"}catch{}let t=()=>iz();document.addEventListener("click",ez),window.addEventListener("popstate",tz),window.addEventListener("hashchange",az),window.addEventListener("beforeunload",KB),window.addEventListener("pageshow",t),document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",t,!0),document.addEventListener("scroll",XB,{capture:!0,passive:!0});let a=$B(nY);return()=>{na===e&&(na=null),W1(),Fy(),a(),document.removeEventListener("click",ez),window.removeEventListener("popstate",tz),window.removeEventListener("hashchange",az),window.removeEventListener("beforeunload",KB),window.removeEventListener("pageshow",t),document.removeEventListener("pointerdown",t,!0),document.removeEventListener("keydown",t,!0),document.removeEventListener("scroll",XB,{capture:!0})}}var G1={goal:8e3,goalBytes:32e3,note:4e3,noteBytes:16e3,flowInstructions:8e3,flowTitle:60,flowStepId:32,flowRef:60,flowMessage:1e3,flowDecider:64,flowSubagent:40,flowRepo:1e3,flowAnswer:40,flowChoice:40,flowSortMeans:200,flowSortQuestion:300,flowSortLevel:120,flowUrl:2e3,flowHeader:500,flowBody:8e3,flowEmailTo:500,flowEmailSubject:200,flowToolServer:64,flowToolName:100,flowToolArgs:4e3,flowDuration:40,flowTimeZone:60,flowName:80,flowFileAbout:600,flowFileNeed:80,flowParameter:200,flowScriptAbout:160,flowScriptBody:2e4,flowScriptFile:200,triggerButton:40,triggerQuestion:80,triggerSchedule:80,triggerTitle:200,triggerDescription:2e3,triggerGithubRepo:140,triggerLabel:50,triggerBranch:100,triggerTeam:12,triggerState:40,triggerWebhookTitle:120,triggerWebhookField:80,triggerWebhookScope:120,triggerFolder:100,triggerSender:300,triggerSubject:100,triggerSecrets:500,flowCardTitle:200,flowCardDescription:4e3,flowScriptInline:1600,reportSummary:2500,reportPayloadBytes:98304,reportDocumentBytes:65536,reportTitleBytes:200,reportWhyBytes:1e3,reportUrlBytes:2e3,reportCaptionBytes:300,stageOutput:12e3,planPayloadBytes:65536,planDocumentBytes:16384,planApproach:2e3,planItem:600,planTouch:200,scopeTouches:50,sizeReason:300,planAmendment:1e3,acceptanceIdBytes:40,acceptanceStatementBytes:1e3,acceptanceHowBytes:500,proofPayloadBytes:65536,proofCriterionIdBytes:40,proofHowBytes:500,proofLineBytes:300,sizingReason:160,reviewPath:300,reviewNote:500,decisionRecap:2e3,decisionQuestion:2e3,decisionOptionId:40,decisionRecommendation:500,decisionLabel:120,decisionConsequence:500,decisionAssignee:120,subagentAnswer:60,subagentQuestion:600,subagentReason:400,subagentRemember:300,taskRef:64,taskTitle:200,taskTouch:200,projectPath:4096,gatewayRepo:800,contextQuery:1e3,logSearch:120,memorySearch:300,taskSearch:200,diffPath:300,proposalReason:200,answerRationale:400,answerOption:64,workerName:60,agentWhy:400,agentProvider:20,agentModel:120,checksWords:80,recapSince:30,actionSample:800,actionContent:12e3,actionTitle:120,actionName:40,actionCommand:400,actionUrl:500,actionSecret:64,actionAbout:240,subagentSection:60,subagentSchedule:80,subagentTool:40,subagentAction:64,subagentName:40,subagentSoul:12e3,subagentNote:300,subagentChoice:60,subagentText:2e3,knowledgeReference:20,promise:240,rememberText:240,rememberWhy:2e3,rememberSource:200,personName:80,ownerQuestion:200,ownerOption:40,idempotencyKey:64,leadContextBytes:8e3,leadPromise:160,leadCorrection:300,leadCorrectionInstructions:240,leadProposalAbout:120,knowledgeInstructionsBytes:4e3,knowledgeTitleBytes:120,knowledgePathBytes:300,knowledgeReferenceBytes:12e3,knowledgeContextBytes:24e3,knowledgeDecisionsBytes:1500,knowledgeRepositoryBytes:6e3,knowledgeRepositoryMinBytes:3e3,decisionClaimBytes:240,decisionWhyBytes:2e3,decisionByBytes:80,decisionSourceBytes:200,decisionRetireBytes:500,skillNameBytes:64,skillDescriptionBytes:1024,skillRequirementsBytes:500,skillSourceBytes:500,skillPath:240,skillBodyBytes:24576,skillFileBytes:262144,skillPackageBytes:1048576,skillSelectionBytes:2097152,skillSample:800,skillSampleBytes:4e3,skillFeedback:500,skillFeedbackBytes:2e3,memoryTrace:4e4,memoryEffect:300,memoryMistake:300,memoryInstruction:240,telegramCallbackDataBytes:64};function mz(e,t){return e.until===null||e.limitMs===null?"Paused.":`Paused. It can wait until ${t(e.until)} (${Math.max(1,Math.round(e.limitMs/6e4))} min) before it ends.`}var qy=O(ve(),1);var oY={claude:"Claude",codex:"Codex",antigravity:"Antigravity",shell:"terminal"};function $y(e){if(e===void 0)return null;let t=[];if(e.terminalController!==null){let a=e.terminalProgram?oY[e.terminalProgram]??e.terminalProgram:"terminal";t.push(`${e.terminalController} typing in ${a}`)}return e.viewers.length===1?t.push(`${e.viewers[0]} viewing`):e.viewers.length>1&&t.push(`${e.viewers[0]} + ${e.viewers.length-1} viewing`),t.length===0?null:t.join(" · ")}function hz(e,t,a){if(t==="everyone"||a===null)return!0;let n=a.owners[e]??null;return t==="mine"?n===a.me:t==="unassigned"?n===null:t==="team"?n!==null&&n!==a.me:!0}function Uy(){let[e,t]=(0,qy.useState)(null);return(0,qy.useEffect)(()=>{if(typeof window>"u"||typeof document>"u"||typeof fetch!="function"||!document.querySelector("[data-workspace-shell]"))return;let a=!0,n=()=>{let r=fetch("/api/presence",{credentials:"same-origin",headers:{accept:"application/json","x-toolroll-read":"prefetch"}});!r||typeof r.then!="function"||r.then(s=>s&&s.ok?s.json():null).then(s=>{if(!a||s===null||typeof s!="object")return;let i=s;i.ok!==!0||typeof i.me!="string"||t({me:i.me,tasks:i.tasks&&typeof i.tasks=="object"?i.tasks:{},owners:i.owners&&typeof i.owners=="object"?i.owners:{},accounts:Array.isArray(i.accounts)?i.accounts.filter(l=>typeof l=="string"):[]})}).catch(()=>{})};n();let o=()=>n();return window.addEventListener(da,o),()=>{a=!1,window.removeEventListener(da,o)}},[]),e}var dl=O(ve(),1);var wt=O(Z(),1);function gz({taskId:e,csrf:t,presence:a}){let[n,o]=(0,dl.useState)([]),[r,s]=(0,dl.useState)(""),[i,l]=(0,dl.useState)(null),[u,c]=(0,dl.useState)(null);(0,dl.useEffect)(()=>{if(typeof window>"u"||typeof document>"u"||typeof fetch!="function"||!document.querySelector("[data-workspace-shell]"))return;let x=!0,v=()=>{let y=fetch(`/api/handoff/task/${encodeURIComponent(e)}/candidates`,{credentials:"same-origin",headers:{accept:"application/json","x-toolroll-read":"prefetch"}});!y||typeof y.then!="function"||y.then(g=>g&&g.ok?g.json():null).then(g=>{if(!x||!g||typeof g!="object")return;let b=g;b.ok===!0&&Array.isArray(b.candidates)&&o(b.candidates)}).catch(()=>{})};return v(),window.addEventListener(da,v),()=>{x=!1,window.removeEventListener(da,v)}},[e]);let f=a?a.accounts.filter(x=>x!==a.me):[],d=a?.owners[e]??null;if((0,dl.useEffect)(()=>{r===""&&f.length>0&&s(f[0])},[f.join(",")]),f.length===0&&n.length===0)return null;let m=async()=>{if(!(i!==null||r==="")){l("handoff"),c(null);try{let x=await fetch(`/api/handoff/task/${encodeURIComponent(e)}/assign-person`,{method:"POST",credentials:"same-origin",headers:yt({"content-type":"application/json","x-csrf-token":t,accept:"application/json"}),body:JSON.stringify({person:r})}),v=await x.json().catch(()=>null);!x.ok||!v?.ok?c(v?.message??"Could not hand off this task."):(c(v.warning?`Handed off to ${r}. Note: ${v.warning}`:`Handed off to ${r}.`),window.dispatchEvent(new CustomEvent(da)))}catch{c("Could not reach Toolroll.")}finally{l(null)}}},h=async x=>{if(i===null){l(x),c(null);try{let v=await fetch(`/api/handoff/task/${encodeURIComponent(e)}/candidate/${encodeURIComponent(x)}/promote`,{method:"POST",credentials:"same-origin",headers:yt({"content-type":"application/json","x-csrf-token":t,accept:"application/json"}),body:"{}"}),y=await v.json().catch(()=>null);if(!v.ok||!y?.ok)c(y?.message??"Could not promote local candidate.");else{let g=y.runId?` → Run #${y.runId}`:"",b=y.checks?.status==="queued"?` (${y.checks.level??"full"} checks queued)`:y.checks?.status==="not-configured"?" (no project check configured)":"";c(`Promoted Candidate ${x}${g}${b}.`),window.dispatchEvent(new CustomEvent(da))}}catch{c("Could not reach Toolroll.")}finally{l(null)}}},w=async x=>{if(i===null){l(`pr:${x}`),c(null);try{let v=await fetch(`/api/handoff/task/${encodeURIComponent(e)}/candidate/${encodeURIComponent(x)}/open-pr`,{method:"POST",credentials:"same-origin",headers:yt({"content-type":"application/json","x-csrf-token":t,accept:"application/json"}),body:"{}"}),y=await v.json().catch(()=>null);if(!v.ok||!y?.ok)c(y?.message??"Could not queue pull request.");else{let g=y.publication;c(g?.prNumber?`Pull request #${g.prNumber} already open for ${x}.`:`Queued pull request for ${x} (${g?.head??"candidate"} → ${g?.base??"main"}).`),window.dispatchEvent(new CustomEvent(da))}}catch{c("Could not reach Toolroll.")}finally{l(null)}}};return(0,wt.jsxs)("div",{className:"so-task-multiplayer","data-task-multiplayer":"",style:{display:"flex",flexDirection:"column",gap:"8px",margin:"8px 0 12px"},children:[f.length>0&&(0,wt.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"8px",fontSize:"13px"},children:[(0,wt.jsxs)("span",{children:["Owner: ",(0,wt.jsx)("strong",{children:d??"Unassigned"})]}),(0,wt.jsx)("label",{htmlFor:`handoff-${e}`,style:{marginLeft:"4px"},children:"Hand off to:"}),(0,wt.jsx)("select",{id:`handoff-${e}`,value:r,onChange:x=>s(x.target.value),disabled:i!==null,style:{padding:"3px 8px",borderRadius:"6px",border:"1px solid var(--so-line)",background:"transparent",color:"inherit",fontSize:"13px"},children:f.map(x=>(0,wt.jsx)("option",{value:x,children:x},x))}),(0,wt.jsx)(de,{sm:!0,variant:"ghost",label:"Hand off",busy:i==="handoff"?"Handing off…":!1,onClick:()=>{m()}})]}),n.map(x=>(0,wt.jsxs)("div",{"data-handoff-candidate":x.id,style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"8px",padding:"8px 10px",borderRadius:"8px",border:"1px solid var(--so-line)",fontSize:"13px"},children:[(0,wt.jsx)(Oe,{word:x.promotedAt?x.liveCheckState==="passed"?"Central checks passed":x.liveCheckState==="failed"?"Central checks failed":x.liveCheckState==="running"?"Central checks running":x.liveCheckState==="waiting"||x.checkStatus==="queued"?"Central checks queued":"Promoted to central Run":x.stale?"Stale — re-pull & rebase":"Unverified Candidate",tone:x.promotedAt?x.liveCheckState==="failed"?"failed":x.liveCheckState==="passed"?"done":"live":"needs"}),(0,wt.jsxs)("span",{children:[(0,wt.jsx)("strong",{children:x.author})," submitted ",(0,wt.jsx)("code",{children:x.id})," (",x.files.length," file",x.files.length===1?"":"s",x.note?` · ${x.note}`:"",")",x.stale&&!x.promotedAt?(0,wt.jsxs)(wt.Fragment,{children:[" · run ",(0,wt.jsx)("code",{children:`toolroll handoff rebase ${e}`})]}):null,x.runId?(0,wt.jsxs)(wt.Fragment,{children:[" · ",(0,wt.jsxs)("a",{className:"k-link",href:`/r/${x.runId}`,children:["Run #",x.runId]})]}):null,x.publication?.prUrl?(0,wt.jsxs)(wt.Fragment,{children:[" · ",(0,wt.jsx)("a",{className:"k-link",href:x.publication.prUrl,target:"_blank",rel:"noreferrer",children:x.publication.prNumber?`PR #${x.publication.prNumber}`:"Open PR"})]}):x.publication?(0,wt.jsxs)(wt.Fragment,{children:[" · ",(0,wt.jsx)(Oe,{word:"PR queued",tone:"live"})]}):null]}),!x.promotedAt&&!x.stale&&(0,wt.jsx)(de,{sm:!0,variant:"primary",label:"Promote to central Run",busy:i===x.id?"Promoting…":!1,onClick:()=>{h(x.id)}}),x.promotedAt&&x.canOpenPr&&!x.publication&&(0,wt.jsx)(de,{sm:!0,variant:"primary",label:"Open PR",busy:i===`pr:${x.id}`?"Opening PR…":!1,onClick:()=>{w(x.id)}})]},x.id)),u&&(0,wt.jsx)("p",{role:"status",style:{margin:0,fontSize:"13px",opacity:.9},children:u})]})}var it=O(Z(),1),rY={neutral:"bg-muted-foreground",live:"bg-info",attention:"bg-attention",ready:"bg-transparent ring-2 ring-inset ring-success",success:"bg-success",danger:"bg-destructive"},sY={ok:(0,it.jsx)(Fs,{className:"size-3.5 text-success","aria-hidden":"true"}),running:(0,it.jsx)(Ep,{className:"size-3.5 text-info","aria-hidden":"true"}),none:(0,it.jsx)(Mp,{className:"size-3 text-muted-foreground","aria-hidden":"true"}),note:(0,it.jsx)(Pn,{className:"size-3.5 text-muted-foreground","aria-hidden":"true"}),failed:(0,it.jsx)(no,{className:"size-3.5 text-destructive","aria-hidden":"true"})};function vz({status:e,as:t="h2"}){return(0,it.jsxs)(t,{className:"flex items-center gap-2.5 text-lg font-semibold leading-snug","data-headline":e.headline,children:[(0,it.jsx)("span",{"aria-hidden":"true",className:ye("size-2.5 shrink-0 rounded-full",rY[e.tone])}),e.headline]})}var Y1="phone:-my-3 phone:inline-block phone:py-3";function iY({detail:e,runChecks:t,csrf:a}){let n=t!==null&&a!==""&&e.action?.href===t.action,o=e.href===null?e.text:(0,it.jsx)("a",{href:e.href,className:ye("underline decoration-border underline-offset-4 hover:decoration-muted-foreground",Y1),children:e.text});return(0,it.jsxs)("li",{"data-status-detail":e.key,"data-mark":e.mark,className:"grid grid-cols-[14px_7.5rem_minmax(0,1fr)] items-center gap-x-2.5 py-1.5 text-body phone:min-h-11 phone:grid-cols-[14px_6.25rem_minmax(0,1fr)] phone:py-1",children:[(0,it.jsx)("span",{className:"flex items-center justify-center",children:sY[e.mark]}),(0,it.jsx)("span",{className:"text-muted-foreground",children:e.label}),(0,it.jsxs)("span",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2.5",children:[(0,it.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:o}),e.action!==null&&(n?(0,it.jsxs)(Fe,{action:t.action,"data-run-checks":!0,className:"inline",children:[(0,it.jsx)("input",{type:"hidden",name:"level",value:t.level}),(0,it.jsx)("input",{type:"hidden",name:"return",value:t.returnTo}),(0,it.jsx)("button",{type:"submit","data-detail-action":!0,className:ye("cursor-pointer whitespace-nowrap font-medium underline-offset-4 hover:underline",Y1),children:e.action.label})]}):e.action.href===null?(0,it.jsx)("span",{className:"font-medium",children:e.action.label}):(0,it.jsx)("a",{href:e.action.href,"data-detail-action":!0,className:ye("whitespace-nowrap font-medium underline-offset-4 hover:underline",Y1),children:e.action.label}))]})]})}function yz({status:e,runChecks:t=null,csrf:a=""}){return e.details.length===0?null:(0,it.jsx)("ul",{"aria-label":"Status",className:"flex flex-col border-t border-border pt-2 phone:pt-1.5",children:e.details.map(n=>(0,it.jsx)(iY,{detail:n,runChecks:t,csrf:a},n.key))})}function Vy(e,t=[]){return[...new Set([...e.details.flatMap(a=>a.why===null?[]:[`${a.label}: ${a.why}`]),...e.why,...t])]}function wz(e){return e==="attention"?"attention":e==="problem"?"danger":e==="live"?"live":e==="ready"?"ready":e==="done"?"success":"neutral"}var X1={attention:"decide",danger:"failed",live:"building",ready:"review",success:"done",neutral:"idle"};function Z1(e){return X1[wz(e)]}function xz({label:e,tone:t,className:a,...n}){let o=wz(t);return(0,it.jsxs)("span",{...n,"data-headline":e,className:ye("inline-flex w-fit shrink-0 items-center gap-1.5 whitespace-nowrap py-px text-badge",o==="attention"?"font-medium text-foreground":"text-muted-foreground",a),children:[(0,it.jsx)(fi,{kind:X1[o]}),e]})}function bz({form:e,csrf:t,label:a="Check again"}){return(0,it.jsxs)(Fe,{action:e.action,id:"recheck-stopped","data-recheck-stopped":e.run,className:"flex flex-wrap items-center gap-2 phone:w-full",children:[(0,it.jsx)("input",{type:"hidden",name:"run",value:String(e.run)}),e.returnTo!==void 0&&(0,it.jsx)("input",{type:"hidden",name:"return",value:e.returnTo}),(0,it.jsx)(pe,{type:"submit",variant:"attention",className:"phone:w-full","data-primary-action":!0,children:a})]})}function kz({action:e,csrf:t,label:a="Retry",className:n,pins:o}){return(0,it.jsxs)(Fe,{action:e,"data-rebuild":!0,className:"phone:w-full",children:[(0,it.jsx)(Am,{pins:o}),(0,it.jsx)(pe,{type:"submit",variant:"attention",className:ye("phone:w-full",n),"data-primary-action":!0,children:a})]})}function Am({pins:e}){return e==null?null:(0,it.jsxs)(it.Fragment,{children:[(0,it.jsx)("input",{type:"hidden",name:"run",value:e.run}),(0,it.jsx)("input",{type:"hidden",name:"digest",value:e.digest})]})}var T=O(Z(),1);function Em(e,t,a=!1){let n=e===""?null:(e==="steering"?document.querySelector('[data-task-panel="activity"] #steering'):null)??document.getElementById(e);if(n===null)return!1;let o=n.closest('[data-task-panel="activity"]')!==null,r=!o&&J1();o||t({page:!0});let s=n.closest("[data-step-row]");return s!==null&&t({row:s.dataset.stepRow}),o&&t({activity:!0}),n.closest("[data-task-details]")!==null&&window.dispatchEvent(new CustomEvent("so:show-details")),requestAnimationFrame(()=>{for(let i=n;i!==null;i=i.parentElement)i instanceof HTMLDetailsElement&&(i.open=!0);n instanceof HTMLDetailsElement&&(n.open=!0),n.scrollIntoView({block:"start",behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"}),a?n.querySelector("input:not([type=hidden]), textarea, select, button")?.focus({preventScroll:!0}):r&&jy(n)}),!0}var Rz="(max-width: 1099px)",nC=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Rz).matches,J1=()=>nC()&&document.querySelector('[data-task-panel="activity"]:not([hidden])')!==null;function jy(e,t=4){if(e.closest("[inert]")!==null&&t>0){requestAnimationFrame(()=>jy(e,t-1));return}!e.hasAttribute("tabindex")&&!e.matches("a[href], button, input, select, textarea, summary")&&(e.tabIndex=-1),e.focus({preventScroll:!0})}function lY(){let[e,t]=(0,lt.useState)(nC);return(0,lt.useEffect)(()=>{if(typeof window.matchMedia!="function")return;let a=window.matchMedia(Rz),n=()=>t(a.matches);return n(),a.addEventListener?.("change",n),()=>a.removeEventListener?.("change",n)},[]),e}function uY(e,t,a,n){let o=lY(),r=(0,lt.useRef)(n);r.current=n;let s=(0,lt.useRef)(null);return(0,lt.useLayoutEffect)(()=>{let i=document.getElementById(e);if(i===null||(i.hidden=!t,!t||!o))return;let l=!1,u=i.querySelector("[data-close-activity]");u?.setAttribute("autofocus","");let c=io(i,a.current,{dim:!0,onClose:()=>{l||(l=!0,r.current())}});return u?.removeAttribute("autofocus"),s.current=c,()=>{s.current=null,l||(l=!0,c()),i.removeAttribute("role"),i.removeAttribute("aria-modal")}},[e,t,o]),()=>{let i=s.current;return i===null?!1:(i(),!0)}}function cY(e){(0,lt.useEffect)(()=>{let t=()=>{Em(decodeURIComponent(window.location.hash.slice(1)),e)};return t(),window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)},[])}function jt({html:e,className:t}){return(0,T.jsx)(Ct,{html:e,immutable:!0,...t===void 0?{}:{className:t}})}function dY(){let e=document.getElementById("cancel-task");if(!(e instanceof HTMLDetailsElement)){window.location.hash="cancel-task";return}e.open=!0,e.scrollIntoView({block:"start"}),e.querySelector("summary")?.focus()}function oC({action:e,note:t,pins:a}){let n=(t??"").trim();return(0,T.jsxs)(Fe,{action:e,"data-retry":!0,className:"k-field",children:[(0,T.jsx)(Am,{pins:a}),n!==""&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("input",{type:"hidden",name:"context",value:n}),(0,T.jsxs)("p",{className:"k-note","data-retry-suggestion":"",children:["Sent with the retry: ",n]})]}),(0,T.jsx)("label",{htmlFor:"retry-note",className:"k-label",children:"Your note for the next attempt"}),(0,T.jsx)(ld,{id:"retry-note",name:"note",maxLength:gO,rows:2,placeholder:"Optional","data-retry-note":""}),(0,T.jsx)("div",{className:"k-acts",children:(0,T.jsx)(de,{type:"submit",variant:"primary",label:"Retry","data-primary-action":"",title:"Keeps the branch and workspace"})})]})}function fY({failure:e}){return e.evidence===null&&e.link===null?null:(0,T.jsxs)("span",{className:"so-task-evidence","data-failure-evidence":!0,children:[e.evidence!==null&&(0,T.jsx)("span",{children:e.evidence}),e.link!==null&&(0,T.jsxs)(T.Fragment,{children:[e.evidence!==null&&" ",(0,T.jsx)("a",{className:"k-link",href:e.link.href,"data-failure-log":!0,children:e.link.label})]})]})}function pY({stop:e}){return(0,T.jsxs)(Fe,{action:e.action,className:"task-stop-form","data-task-control":"stop","data-control-run":e.run,children:[(0,T.jsx)("input",{type:"hidden",name:"run",value:e.run}),(0,T.jsx)("input",{type:"hidden",name:"return",value:"task"}),(0,T.jsx)(de,{type:"submit",variant:"danger",label:"Stop","data-stop-build":""})]})}function mY({pause:e}){return(0,T.jsxs)(Fe,{action:e.action,"data-task-control":"pause","data-control-run":e.run,children:[(0,T.jsx)("input",{type:"hidden",name:"run",value:e.run}),(0,T.jsx)("input",{type:"hidden",name:"request",value:e.requests[0]}),(0,T.jsx)("input",{type:"hidden",name:"return",value:"task"}),(0,T.jsx)(de,{type:"submit",label:"Pause","data-pause-build":""})]})}function hY({pause:e}){return(0,T.jsxs)(Fe,{action:e.action,"data-task-control":"resume","data-control-run":e.run,children:[(0,T.jsx)("input",{type:"hidden",name:"run",value:e.run}),(0,T.jsx)("input",{type:"hidden",name:"request",value:e.requests[2]}),(0,T.jsx)("input",{type:"hidden",name:"mode",value:"resume"}),(0,T.jsx)("input",{type:"hidden",name:"return",value:"task"}),(0,T.jsx)(de,{type:"submit",variant:"primary",label:"Resume","data-resume-build":""})]})}function gY({pause:e,onCancel:t}){let a=e.state==="paused",[n,o]=(0,lt.useState)(()=>Rd(e.run)),r=s=>o(i=>{let l=i.submitted?{...Jo(),text:s}:{...i,text:s};return cs(e.run,l),l});return(0,T.jsxs)(Fe,{action:e.action,className:"k-field","data-task-control":"pause-and-steer","data-control-run":e.run,onSubmit:()=>o(s=>{let i={...s,submitted:!0};return cs(e.run,i),i}),children:[(0,T.jsx)("input",{type:"hidden",name:"run",value:e.run}),(0,T.jsx)("input",{type:"hidden",name:"request",value:`steer-${n.key}`}),(0,T.jsx)("input",{type:"hidden",name:"key",value:n.key}),(0,T.jsx)("input",{type:"hidden",name:"return",value:"task"}),(0,T.jsx)("label",{htmlFor:"pause-steer-note",className:"k-label",children:a?"Note to continue with":"Note for the agent"}),(0,T.jsx)(ld,{id:"pause-steer-note",name:"note",required:!0,autoFocus:!0,maxLength:G1.note,rows:2,placeholder:"What should it do instead?","data-pause-steer-note":"",value:n.text,onChange:s=>r(s.target.value)}),(0,T.jsxs)("div",{className:"k-acts",children:[(0,T.jsx)(de,{type:"submit",variant:"primary",label:a?"Continue":"Pause and send","data-pause-steer-send":""}),(0,T.jsx)(de,{variant:"ghost",label:"Cancel",onClick:t})]})]})}function vY(e,t){if(e===null)return Promise.resolve("This form is no longer on the page. Nothing changed.");if(!e.checkValidity())return e.reportValidity(),Promise.resolve("Fill in what the form asks for first. Nothing changed.");let a=e.querySelector('input[name="token"]');return a!==null&&(a.value=t??""),e.requestSubmit(),new Promise(()=>{})}function yY({form:e,label:t}){return(0,T.jsxs)(Fe,{action:e.action,id:"recheck-stopped","data-recheck-stopped":e.run,className:"k-acts",children:[(0,T.jsx)("input",{type:"hidden",name:"run",value:String(e.run)}),(0,T.jsx)(de,{type:"submit",variant:"primary",label:t,"data-primary-action":""})]})}var Az=()=>document.getElementById("plan-editor")instanceof HTMLDetailsElement&&document.getElementById("plan-editor").open,Ez=()=>{if(Az())return!0;let e=document.getElementById("plan-edit");return e!==null&&[...e.querySelectorAll("textarea, input:not([type=hidden])")].some(t=>t.value!==t.defaultValue)};function wY(){let[e,t]=(0,lt.useState)(!1);return(0,lt.useEffect)(()=>{let a=()=>t(Ez());a();let n=r=>{let s=r.target?.id;(s==="plan-editor"||s==="plan-edit")&&a()},o=r=>{r.target?.closest?.("#plan-edit, #plan-editor")&&a()};return document.addEventListener("toggle",n,!0),document.addEventListener("input",o,!0),()=>{document.removeEventListener("toggle",n,!0),document.removeEventListener("input",o,!0)}},[]),e}function Sz({approve:e,latest:t,onEdit:a,reject:n=!1,inRow:o=!1,sheet:r}){let s=(0,lt.useRef)(null),i=(0,lt.useContext)(yn),l=wY(),[u,c]=(0,lt.useState)(null),f=t==null||t.fields.digest!==e.fields.digest,d=e.rememberedUntil===null?null:new Date(e.rememberedUntil).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),m={...e.facts,rememberedUntil:d},h=e.termsWords??gu(e.kind,m),w=e.action.replace(/\/approve$/,""),x=(0,lt.useRef)(!0);(0,lt.useEffect)(()=>(x.current=!0,()=>{x.current=!1}),[]);let v=async()=>{let b=e.fields.digest??"",k=e.fields.rebuild??null;if(b==="")return"This form can’t approve: reload the page to read the plan again. Nothing changed.";let C=window.location.pathname.startsWith("/t/")?`${window.location.pathname}${window.location.search}`:w,N=await Ry(C);if(!x.current)return new Promise(()=>{});let L=bm(N),A=Ay(N);if(L===null||A===null)return"Couldn’t read the plan just now. Nothing changed.";if(L.action!==e.action||L.digest!==b||L.rebuild!==k||al(L.kind,L.facts)!=="click")return c({words:"The plan changed since this page loaded. Nothing was approved: reload to read the version you would approve.",done:!1}),null;let P=await Ey({action:e.action,digest:b,rebuild:k},i,A);return x.current?P.kind==="elsewhere"?(window.location.assign(w),new Promise(()=>{})):P.kind==="lost"?(c({words:"Checking…",done:!0}),window.location.reload(),null):(P.outcome==="approved"?c({words:"Approved.",done:!0}):c({words:P.outcome==="refused"?`${Hn(P.words)} Nothing changed.`:Hn(P.words),done:!1}),window.dispatchEvent(new CustomEvent(da)),null):new Promise(()=>{})},y=b=>Ez()?Promise.resolve("Save or cancel your edit first: approving now would approve the plan as it was. Nothing changed."):b===null&&al(e.kind,m)==="click"?v():vY(s.current,b),g=!f&&!l&&u===null;return(0,T.jsxs)(Fe,{ref:s,action:e.action,className:"k-approve","data-approval-kind":e.kind,"data-task-approval":!0,"data-editing":l?"":void 0,children:[Object.entries(e.fields).map(([b,k])=>(0,T.jsx)("input",{type:"hidden",name:b,value:k},b)),(0,T.jsx)("input",{type:"hidden",name:"token",value:""}),(0,T.jsx)(To,{wait:!0,status:(0,T.jsxs)(T.Fragment,{children:[!o&&(0,T.jsx)(Oe,{word:"Needs you",tone:"needs"}),(0,T.jsx)("h2",{children:e.heading})]}),text:e.text,...r===void 0?{}:{body:(0,T.jsx)(jt,{html:r,className:"so-task-plan"})},acts:u!==null?u.done?null:(0,T.jsx)(de,{variant:"primary",label:"Reload",onClick:()=>window.location.reload()}):f?(0,T.jsx)(de,{variant:"primary",label:"Reload",onClick:()=>window.location.reload()}):l?(0,T.jsx)(de,{label:"Back to the edit",onClick:()=>{if(Az()){a?.();return}let b=document.getElementById("plan-edit");b instanceof HTMLDetailsElement&&(b.open=!0,b.scrollIntoView({block:"start"}),b.querySelector("textarea")?.focus())}}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(gm,{kind:e.kind,facts:m,label:e.label,docked:!0,terms:h,text:e.text,onApprove:y}),a!==null&&(0,T.jsx)(de,{label:"Request changes",onClick:a}),n&&(0,T.jsx)(de,{variant:"ghost",label:"Reject…",title:"Opens Cancel task, where you confirm it","data-approval-reject":"",onClick:dY})]}),terms:u!==null?u.words:f?"The plan changed since this page loaded. Reload to see the version you would approve.":l?"You have unsaved changes to the plan. Save them (it then asks for approval again) or cancel the edit to approve this version.":h}),g&&(0,T.jsx)(Qo,{children:(0,T.jsx)(gm,{kind:e.kind,facts:m,label:e.label,terms:h,text:e.text,onApprove:y})})]})}function xY({ship:e}){let t=e.state==="failed"?(0,T.jsx)(Oe,{word:"Check failed",tone:"failed"}):e.state==="running"?(0,T.jsx)(Oe,{word:"Checks running",tone:"live"}):e.state==="passed"?(0,T.jsx)(Oe,{word:"Checks passed",tone:"done"}):(0,T.jsx)(Oe,{word:"No current checks"});return(0,T.jsx)("section",{className:"k-sec","aria-label":"Ship","data-ship":e.state,children:(0,T.jsx)(c1,{label:`Pull request #${e.pr} · checks`,head:"Check",chip:t,rows:e.rows,foot:(0,T.jsxs)(T.Fragment,{children:[e.summary," on ",(0,T.jsx)("span",{className:"k-mono",children:e.head})," · read ",(0,T.jsx)("time",{dateTime:e.observedAt,title:ms(e.observedAt),children:cn(e.observedAt)})]})})})}function bY({release:e}){let t=e.state==="failed"?(0,T.jsx)(Oe,{word:"Failed",tone:"failed"}):e.state==="done"?(0,T.jsx)(Oe,{word:"Done",tone:"done"}):e.state==="waiting"?(0,T.jsx)(Oe,{word:"Needs you",tone:"needs"}):(0,T.jsx)(Oe,{word:"Running",tone:"live"});return(0,T.jsxs)("section",{className:"k-sec","aria-label":"Release","data-release":e.state,children:[(0,T.jsx)("h3",{children:e.headline}),e.stopped!==null&&(0,T.jsxs)(ln,{children:[e.stopped.step,": ",e.stopped.message," Run the same release command again to continue from there."]}),(0,T.jsx)(c1,{label:`Release ${e.version}`,chip:t,rows:e.rows,foot:(0,T.jsxs)(T.Fragment,{children:["Tag ",(0,T.jsx)("span",{className:"k-mono",children:e.tag}),e.pr!==null&&(0,T.jsxs)(T.Fragment,{children:[" · pull request #",e.pr]})," · started ",(0,T.jsx)("time",{dateTime:e.startedAt,title:ms(e.startedAt),children:cn(e.startedAt)})]})})]})}function kY({ready:e,retry:t}){let a={yes:"✓",no:"✗",waiting:"…",unknown:"?"},n=e.answer==="yes"||e.answer==="merged"?(0,T.jsx)(Oe,{word:e.answer==="merged"?"Merged":"Ready",tone:"done"}):(0,T.jsx)(Oe,{word:"Not yet"});return(0,T.jsxs)("section",{className:"k-sec so-merge-ready","aria-label":"Can I merge?","data-merge-ready":e.answer,children:[(0,T.jsxs)("div",{className:"so-merge-head",children:[n,(0,T.jsx)("h3",{children:"Can I merge?"})]}),(0,T.jsx)("p",{className:"so-merge-say",children:e.sentence}),(0,T.jsx)("ul",{className:"so-merge-rows",children:e.rows.map(o=>(0,T.jsxs)("li",{"data-merge-row":o.key,"data-mark":o.mark,children:[(0,T.jsx)("span",{className:"so-merge-mark","aria-hidden":"true",children:a[o.mark]??""}),(0,T.jsxs)("span",{children:[(0,T.jsx)("strong",{children:o.label})," ",(0,T.jsx)("span",{className:"meta",children:o.say})]}),o.act?.kind==="run-checks"&&(0,T.jsxs)(Fe,{action:o.act.action,className:"inline","data-merge-act":"run-checks",children:[(0,T.jsx)("input",{type:"hidden",name:"level",value:o.act.level}),(0,T.jsx)("input",{type:"hidden",name:"return",value:o.act.returnTo}),(0,T.jsx)(de,{type:"submit",sm:!0,label:"Run checks"})]}),o.act?.kind==="retry"&&t!=null&&(0,T.jsxs)(Fe,{action:t.action,className:"inline","data-merge-act":"retry",children:[(0,T.jsx)(Am,{pins:t.pins}),(0,T.jsx)(de,{type:"submit",sm:!0,label:"Retry"})]}),o.act?.kind==="fix"&&(0,T.jsx)(un,{summary:"Ask the agent to fix",children:(0,T.jsxs)(Fe,{action:o.act.action,className:"k-field","data-merge-act":"fix",children:[(0,T.jsx)("input",{type:"hidden",name:"intent",value:"revise"}),(0,T.jsx)("input",{type:"hidden",name:"batch",value:o.act.batch}),(0,T.jsx)("input",{type:"hidden",name:"source",value:o.act.source}),(0,T.jsx)("input",{type:"hidden",name:"request",value:o.act.request}),(0,T.jsx)("input",{type:"hidden",name:"return",value:o.act.returnTo}),o.act.note.trim()!==""&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("input",{type:"hidden",name:"context",value:o.act.note}),(0,T.jsxs)("p",{className:"k-note","data-fix-context":"",children:["Sent with it: ",o.act.note]})]}),(0,T.jsx)(ld,{name:"note",rows:3,maxLength:G1.note,placeholder:"Your note (optional)","aria-label":"Your note for the agent"}),(0,T.jsx)("div",{className:"k-acts",children:(0,T.jsx)(de,{type:"submit",label:"Ask the agent to fix",title:"Sends it back with this note, as Send back does"})})]})})]},o.key))})]})}function Cz(e){let t=e.status.need?.key??null;switch(e.status.headline){case"Needs you":return t==="approval"?"Plan ready":t==="answer"||t==="questions"?"A question for you":t==="hold"?"On hold":t==="stop-unproven"||t==="vanished"?"The build stopped":t==="sign-in"?e.status.sentence.startsWith("No coding agent")?"Sign in":"Sign in again":t==="connect-builder"?"No builder":t==="start-builder"?"Builder offline":t==="rebuild"||t==="replan"?"The plan changed":t==="plan-again"?"Plan didn't pass":t==="planning-stopped"?"Planning stopped":t==="review-result"?"Ready":"Waiting on you";case"Ready":return"Ready";case"Failed":return"A requirement was missed";case"Complete":return"Complete";case"Queued":return e.attempts.some(a=>a.runId!==null)?"Retry scheduled":"Waiting to start";default:return e.status.headline}}function Mz(e){let t=yr(e.at,new Date,No());return e.automatic?`Approved automatically by ${e.rule??"a rule"} · ${t}`:`Approved by ${e.by} · ${t}${e.how===""?"":` · ${e.how}`}`}function Lz({view:e,card:t,csrf:a,approved:n,watch:o=null,checksElsewhere:r=!1,resultHere:s=!1,unsent:i=!0,resultAct:l=null,lead:u=!1,resultWarnings:c=null}){let f=t.status.headline==="Failed",d=e.recheckStopped??null,m=e.rebuild??null,h=e.retry??null,w=e.failure??null,x=e.progress?.stuck??null,v=f&&h!=null&&a!=="",y=e.stop!=null&&a!==""?e.pause??null:null,[g,b]=(0,lt.useState)(!1),k=y?.state==null||x!==null?null:y.state==="pausing"?"Pausing…":mz({until:y.until??null,limitMs:y.limitMs??null},P=>yr(P,new Date,No(),!0)),C=t.status.headline==="Needs you"||t.status.headline==="Ready",N=d!=null&&a!==""?(0,T.jsx)(yY,{form:d,label:t.action?.label??"Check again"}):m!=null&&a!==""?(0,T.jsxs)(Fe,{action:m.action,"data-rebuild":!0,children:[(0,T.jsx)(Am,{pins:m.pins}),(0,T.jsx)(de,{type:"submit",variant:"primary",label:t.action?.label??"Retry","data-primary-action":""})]}):v?(0,T.jsx)(oC,{action:h.action,note:h.note??w?.suggestion,pins:h.pins}):(0,T.jsxs)(T.Fragment,{children:[x?.action!=null?(0,T.jsx)(He,{label:x.action.label,href:x.action.href,"data-stuck-action":""}):t.action!==null&&!(s&&(t.action.openResult||/[?&]tab=result\b/.test(t.action.href)))&&(0,T.jsx)(He,{variant:C?"primary":"outline",className:C?"k-docked":void 0,label:t.action.label,href:t.action.href,"data-primary-action":"",...t.action.openResult?{"data-open-result":""}:{}}),y!==null&&y.state===null&&(0,T.jsx)(mY,{pause:y}),y!==null&&y.state==="paused"&&(0,T.jsx)(hY,{pause:y}),y!==null&&!g&&(0,T.jsx)(de,{label:y.state==="paused"?"Continue with a note":"Pause and steer",onClick:()=>b(!0),"data-pause-steer":""}),e.stop!=null&&a!==""&&(0,T.jsx)(pY,{stop:e.stop}),o!==null&&(0,T.jsx)(de,{label:"Watch the work",onClick:o,"data-watch-work":""}),s&&C&&l!==null&&(0,T.jsx)("span",{className:"contents","data-result-status-act":"",ref:l})]}),L=f&&w!=null&&!v?(0,T.jsxs)("span",{"data-failure-suggestion":!0,children:["What to change: ",w.suggestion]}):e.record!=null?(0,T.jsx)("a",{className:"k-link",href:e.record.href,"data-build-record":!0,children:e.record.label}):n!=null?Mz(n):"",A=Vy(t.status,[...t.reasons,...t.diagnostics.map(P=>`${P.label} · ${P.detail}`),...t.notices?.lines??[]]);return(0,T.jsxs)("div",{className:"k-sec","data-task-status":!0,"data-work-status":t.token,"data-headline":t.status.headline,"aria-label":"Task status",children:[(0,T.jsx)(To,{wait:C,status:(0,T.jsxs)(T.Fragment,{children:[u&&C?(0,T.jsx)(Oe,{word:"Needs you",tone:"needs"}):Cz(t)!==t.status.headline&&(0,T.jsx)(JS,{headline:t.status.headline}),(0,T.jsx)("h2",{children:Cz(t)})]}),text:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("span",{...f?{"data-failure-reason":""}:{},...e.progress!=null?{"data-build-progress":""}:{},...x!==null?{"data-build-stuck":x.step}:{},children:k!==null?(0,T.jsx)("span",{role:"status","data-live-pause":y.state,children:k}):(0,T.jsx)(Mm,{text:t.status.sentence})}),e.activity!=null&&(0,T.jsx)(km,{activity:e.activity}),f&&w!=null&&(0,T.jsx)(fY,{failure:w}),e.planning!=null&&(0,T.jsx)("span",{"data-plan-backoff":"",children:e.planning.line})]}),...u?{body:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(eC,{card:t,runChecks:e.runChecks??null,only:r?P=>P!=="checks":null}),s&&c!==null&&(0,T.jsx)("div",{"data-result-status-warnings":"",ref:c})]})}:{},acts:N,terms:L}),y!==null&&g&&(0,T.jsx)(gY,{pause:y,onCancel:()=>b(!1)},y.run),i&&(0,T.jsx)(Pz,{view:e,csrf:a}),!u&&(0,T.jsx)(eC,{card:t,runChecks:e.runChecks??null,only:r?P=>P!=="checks":null}),e.planning?.agentSaid!=null&&(0,T.jsx)(un,{summary:"What the agent said",children:(0,T.jsx)("pre",{className:"k-mono","data-plan-agent-said":"",children:e.planning.agentSaid.join(`
|
|
63
|
+
> ${a}`}function D9(e){let t=e?.querySelector("code");if(!t)return"";let a=t.querySelector("b");return(t.textContent??"").slice(a?.textContent?.length??0)}function DB({host:e,run:t,maxChars:a,steer:n}){let[o,r]=(0,Sn.useState)(null),[s,i]=(0,Sn.useState)(""),[l,u]=(0,Sn.useState)("editing"),[c,f]=(0,Sn.useState)(null),d=(0,Sn.useRef)(null),m=(0,Sn.useId)(),h=(0,Sn.useRef)(!1),w=k=>{h.current||(k?.slot.remove(),r(null),i(""),u("editing"),f(null),k?.pin.isConnected&&k.pin.focus())};if((0,Sn.useEffect)(()=>{let k=e.current;if(!k)return;k.setAttribute("data-line-steer","");let C=()=>k.querySelectorAll("[data-review-diff]").forEach(A=>{A.getAttribute("data-mode")!=="annotate"&&A.setAttribute("data-mode","annotate")});C();let N=new MutationObserver(C);N.observe(k,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["data-mode"]});let L=A=>{let F=(A.target instanceof Element?A.target:null)?.closest("button.pick-line");if(!F||!k.contains(F))return;let B=Number(F.dataset.line),H=F.dataset.path??"";if(!Number.isSafeInteger(B)||B<1||H==="")return;A.preventDefault(),A.stopPropagation();let S=F.closest(".diff-line");!S||h.current||(r(I=>{I?.slot.remove();let R=document.createElement("div");return R.className="diff-steer-slot",S.after(R),{slot:R,pin:F,path:H,line:B,side:F.dataset.side==="old"?"old":"new",code:D9(S)}}),i(""),u("editing"),f(null))};return k.addEventListener("click",L,!0),()=>{k.removeEventListener("click",L,!0),N.disconnect(),k.removeAttribute("data-line-steer")}},[e]),(0,Sn.useEffect)(()=>{o&&l==="editing"&&d.current?.focus()},[o,l]),(0,Sn.useLayoutEffect)(()=>{let k=d.current;if(!k)return;let C=()=>{k.style.height="0px",k.style.height=`${Math.min(88,Math.max(22,k.scrollHeight))}px`};if(C(),typeof ResizeObserver>"u")return;let N=k.clientWidth,L=new ResizeObserver(()=>{k.clientWidth!==N&&(N=k.clientWidth,C())});return L.observe(k),()=>L.disconnect()},[s,o,l]),(0,Sn.useEffect)(()=>()=>{o?.slot.remove()},[o]),o===null||!o.slot.isConnected)return null;let x=M9({run:t,path:o.path,line:o.line,side:o.side,code:o.code,note:s}),v=x.length>a,y=async()=>{if(!(s.trim()===""||v||l!=="editing"||h.current)){h.current=!0,u("sending"),f(null);try{let k=await n(x);if(k===null){let C=o.slot.contains(document.activeElement);u("sent"),C&&o.pin.isConnected&&o.pin.focus()}else u("editing"),f(k)}finally{h.current=!1}}},g=s.trim()==="";return(0,MB.createPortal)(l==="sent"?(0,lo.jsxs)("p",{className:"diff-steer-sent",role:"status","data-steer-sent":!0,children:[(0,lo.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",children:(0,lo.jsx)("path",{d:"m5 12 5 5 9-10"})}),(0,lo.jsxs)("span",{children:["Sent to the lead · ",(k=>{let C=k.replace(/\s+/g," ").trim();return C.length>60?`${C.slice(0,59)}…`:C})(s)]})]}):(0,lo.jsxs)("form",{className:"diff-steer","data-diff-steer":!0,"data-diff-file":o.path,"data-diff-line":o.line,onSubmit:k=>{k.preventDefault(),y()},onKeyDown:k=>{k.key==="Escape"&&!k.nativeEvent.isComposing&&(k.preventDefault(),w(o))},children:[(0,lo.jsxs)("label",{htmlFor:m,className:"so-sr-only",children:["Comment on line ",o.line," of ",o.path,", for the lead. Enter sends; Escape cancels."]}),(0,lo.jsxs)("div",{className:"diff-steer-row",children:[(0,lo.jsx)("textarea",{ref:d,id:m,rows:1,maxLength:Sy.note,value:s,readOnly:l==="sending",placeholder:"Comment for the lead…",onChange:k=>i(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!k.shiftKey&&!k.nativeEvent.isComposing&&(k.preventDefault(),y())}}),(0,lo.jsx)("button",{type:"submit",className:"diff-steer-send",disabled:g||v||l==="sending","aria-label":l==="sending"?"Sending to the lead":"Send to the lead",title:"Send to the lead",children:(0,lo.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,lo.jsx)("path",{d:"M12 19V5M6 11l6-6 6 6"})})})]}),(c!==null||v)&&(0,lo.jsx)("p",{className:"diff-steer-problem",role:"alert",children:v?"That's longer than one message can be. Shorten the comment.":c})]}),o.slot)}var ku=O(ve(),1);var lt=O(ve(),1);var N1=O(ve(),1);var ft=O(Z(),1),Cy=e=>`toolroll:steer-draft:${e}`;function Jo(){return{text:"",key:typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`k${Date.now().toString(36)}${Math.random().toString(36).slice(2,12)}`,submitted:!1}}function Rd(e){try{let t=JSON.parse(sessionStorage.getItem(Cy(e))??"null");return t===null||typeof t.text!="string"||typeof t.key!="string"?Jo():new URLSearchParams(location.search).get("sent")===t.key?(sessionStorage.removeItem(Cy(e)),Jo()):{text:t.text,key:t.key,submitted:t.submitted===!0}}catch{return Jo()}}function cs(e,t){try{t.text===""&&!t.submitted?sessionStorage.removeItem(Cy(e)):sessionStorage.setItem(Cy(e),JSON.stringify(t))}catch{}}function _B({controls:e,back:t}){let a=e.pause;return(0,ft.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-border pt-3 phone:px-4","data-agent-controls":e.send??"none",children:[(0,ft.jsx)("p",{className:"min-w-0 flex-1 text-caption text-muted-foreground","data-agent-capability":!0,children:e.words}),a!==null&&(a.state==="paused"?(0,ft.jsxs)(Fe,{action:a.action,"data-agent-resume":!0,children:[(0,ft.jsx)("input",{type:"hidden",name:"run",value:String(a.run)}),(0,ft.jsx)("input",{type:"hidden",name:"request",value:a.requests[2]}),(0,ft.jsx)("input",{type:"hidden",name:"mode",value:"resume"}),(0,ft.jsx)("input",{type:"hidden",name:"return",value:t}),(0,ft.jsx)(pe,{type:"submit",variant:"outline",size:"sm",className:"h-9 phone:h-11",children:"Resume"})]}):(0,ft.jsxs)(Fe,{action:a.action,"data-agent-pause":!0,children:[(0,ft.jsx)("input",{type:"hidden",name:"run",value:String(a.run)}),(0,ft.jsx)("input",{type:"hidden",name:"request",value:a.requests[0]}),(0,ft.jsx)("input",{type:"hidden",name:"return",value:t}),(0,ft.jsx)(pe,{type:"submit",variant:"outline",size:"sm",className:"h-9 phone:h-11",disabled:a.state==="pausing",children:a.state==="pausing"?"Pausing…":"Pause"})]})),e.stop!==null&&(0,ft.jsxs)(Fe,{action:e.stop.action,"data-agent-stop":e.stop.run,children:[(0,ft.jsx)("input",{type:"hidden",name:"run",value:String(e.stop.run)}),(0,ft.jsx)("input",{type:"hidden",name:"return",value:t}),(0,ft.jsx)(pe,{type:"submit",variant:"outline",size:"sm",className:"h-9 phone:h-11",children:e.stop.label})]})]})}function Ly({steer:e,controls:t,back:a,label:n="A note for the agent",note:o}){let[r,s]=(0,N1.useState)(()=>Rd(e.run)),i=c=>s(f=>{let d=f.submitted?{...Jo(),text:c}:{...f,text:c};return cs(e.run,d),d}),l=t.pause!==null&&t.pause.state===null?t.pause:null,u=r.text.trim()==="";return(0,ft.jsxs)(Fe,{action:e.action,"data-steer-note":e.run,onSubmit:c=>{if(u){c.preventDefault();return}s(f=>{let d={...f,submitted:!0};return cs(e.run,d),d})},children:[(0,ft.jsx)("input",{type:"hidden",name:"return",value:a}),(0,ft.jsx)("input",{type:"hidden",name:"run",value:String(e.run)}),(0,ft.jsx)("input",{type:"hidden",name:"key",value:r.key}),l!==null&&(0,ft.jsx)("input",{type:"hidden",name:"request",value:`steer-${r.key}`}),(0,ft.jsx)(rl,{id:`steer-note-${e.run}`,label:n,placeholder:n,name:"note",maxLength:4e3,submit:!0,value:r.text,onChange:i,onSend:()=>{},sendLabel:"Send",note:o,before:l!==null?(0,ft.jsx)(de,{sm:!0,type:"submit",formAction:l.action,label:"Pause and send",disabled:u,"data-steer-pause-send":""}):void 0})]})}function PB({runs:e,action:t,back:a}){let[n,o]=(0,N1.useState)(()=>{for(let s of e){let i=Rd(s);if(i.text.trim()!=="")return{run:s,draft:i}}return null});if(n===null)return null;let r=()=>{cs(n.run,{...Jo(),text:""}),o(null)};return(0,ft.jsxs)(Fe,{action:t,className:"flex flex-col gap-2 border-t border-border pt-3","data-steer-unsent":n.run,children:[(0,ft.jsx)("p",{className:"text-caption font-medium text-muted-foreground",children:"Your note wasn't sent: its attempt ended first."}),(0,ft.jsx)("p",{className:"rounded-md border border-border bg-muted px-3 py-2 text-body whitespace-pre-wrap break-words","data-steer-unsent-text":!0,children:n.draft.text}),(0,ft.jsx)("input",{type:"hidden",name:"note",value:n.draft.text}),(0,ft.jsx)("input",{type:"hidden",name:"after",value:String(n.run)}),(0,ft.jsx)("input",{type:"hidden",name:"key",value:n.draft.key}),(0,ft.jsx)("input",{type:"hidden",name:"return",value:a}),(0,ft.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,ft.jsx)(pe,{type:"submit",className:"h-11 w-auto",children:"Send to the next attempt"}),(0,ft.jsx)(pe,{type:"button",variant:"ghost",className:"h-11 w-auto",onClick:r,children:"Discard"})]})]})}var Ny=15e3,Iy=600,_9=/<\s*(input|form|button|select|textarea)\b/i,P9=e=>_9.test(e),O9=/^[0-9a-f]{32,64}$/,B9=/^[0-9a-f]{32}$/,z9=/^[0-9]{1,15}$/;function ds(e){let t=e?.view;return t!=null&&t.kind==="task"&&typeof t.id=="string"?t:null}function bm(e){let t=ds(e),a=t?.approve??null;if(t===null||a===null)return null;let n=a.fields.digest??"",o=a.fields.rebuild??null;if(!O9.test(n)||o!==null&&!z9.test(o)||a.action!==`/t/${encodeURIComponent(t.id)}/approve`)return null;let r=a.rememberedUntil===null?null:new Date(a.rememberedUntil).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),s={...a.facts,rememberedUntil:r},i=typeof a.sheetHtml=="string"?a.sheetHtml:null;return{taskId:t.id,action:a.action,digest:n,rebuild:o,heading:a.heading,text:a.text,termsWords:a.termsWords??gu(a.kind,s),planHtml:i!==null&&!P9(i)?i:null,kind:a.kind,facts:s}}function Ty(e,t){if(e===null||t||e.planHtml===null)return!1;let a=al(e.kind,e.facts);return a==="click"||a==="automatic"}function Ad(e,t=fetch,a){return od(e,"prefetch",t,a)}async function Ry(e,t=fetch){let a;try{a=new URL(Iv(e),window.location.origin)}catch{return null}if(a.origin!==window.location.origin)return null;a.hash="",a.searchParams.set("format","workspace"),a.searchParams.delete("request");try{let n=await t(a.pathname+a.search,{credentials:"same-origin",cache:"no-store",redirect:"manual",headers:{accept:"application/json"},signal:AbortSignal.timeout(Ny)});if(n.status!==200||n.redirected||n.type==="opaqueredirect"||!(n.headers.get("content-type")??"").includes("application/json"))return null;let o=await n.json();return nd(o)?o:null}catch{return null}}function Ay(e){let t=ds(e)?.approve?.fields.nonce??"";return B9.test(t)?t:null}var H9=["approved","vote","approved-not-rebuilt","refused"];async function Ey(e,t,a,n=fetch){let o=new URLSearchParams({csrf:t,nonce:a,digest:e.digest});e.rebuild!==null&&o.set("rebuild",e.rebuild),o.set("return","next");let r;try{r=await n(e.action,{method:"POST",credentials:"same-origin",redirect:"manual",body:o,headers:yt({"x-toolroll-act":"in-place",accept:"application/json"}),signal:AbortSignal.timeout(Ny)})}catch{return{kind:"lost"}}if(r.type==="opaqueredirect"||r.redirected||!(r.headers.get("content-type")??"").includes("application/json"))return{kind:"elsewhere"};let s;try{s=await r.json()}catch{return{kind:"lost"}}if(s===null||typeof s!="object")return{kind:"elsewhere"};let{outcome:i,words:l}=s;return typeof i!="string"||!H9.includes(i)||typeof l!="string"?{kind:"elsewhere"}:i!=="refused"&&r.status!==200?{kind:"elsewhere"}:{kind:"answer",outcome:i,words:l}}function Hn(e){let t=e.trim();if(t==="")return"";let a=t.charAt(0).toUpperCase()+t.slice(1);return/[.!?]$/.test(a)?a:`${a}.`}var il=O(ve(),1);function I1(e){let t=Math.max(0,Math.floor(e/1e3));if(t<10)return"just now";if(t<60)return`${t} s ago`;let a=Math.floor(t/60);return a<60?`${a} min ago`:`${Math.floor(a/60)} h ago`}function OB(e,t){let a=Date.parse(e.at),n=Number.isNaN(a)?0:Math.max(0,t-a);return e.worker==="offline"?{text:`Worker offline · last word ${I1(n)}`,quiet:!0,stale:!1}:n>=3e5?{text:`Last update ${I1(n)}`,quiet:!1,stale:!0}:{text:`${e.what} · ${I1(n)}`,quiet:!1,stale:!1}}var My=O(Z(),1),da="so:workspace-nudge";function ll(e=5e3){let[t,a]=(0,il.useState)(()=>Date.now());return(0,il.useEffect)(()=>{let n=window.setInterval(()=>a(Date.now()),e);return()=>window.clearInterval(n)},[e]),t}function km({activity:e,className:t}){let a=OB(e,ll());return(0,My.jsx)("span",{className:ye("block min-w-0 truncate text-body",a.quiet?"font-medium text-foreground":"font-normal text-muted-foreground",t),"data-activity":a.quiet?"quiet":a.stale?"stale":"fresh",title:a.text,children:(0,My.jsx)("time",{dateTime:e.at,children:a.text})})}function BB({people:e}){if(e.length===0)return null;let t=e.length===1?`${e[0]} is also here`:e.length===2?`${e[0]} and ${e[1]} are also here`:`${e[0]} and ${e.length-1} others are also here`;return(0,My.jsx)("span",{className:"min-w-0 truncate","data-also-viewing":e.length,role:"status",title:e.join(", "),children:t})}function zB(e){let[t,a]=(0,il.useState)([]),n=(0,il.useRef)(e?.at??null);n.current=e?.at??null;let o=e?.room??null;return(0,il.useEffect)(()=>{o===null&&a([])},[o]),Dn(o,(r,s)=>{let i=()=>window.dispatchEvent(new CustomEvent(da));if(r==="change"){let l=s.at;(typeof l!="string"||l!==n.current)&&i()}else if(r==="reload")i();else if(r==="here"){let l=s.people;Array.isArray(l)&&a(l.filter(u=>typeof u=="string"))}else(r==="gone"||r==="lost")&&a([])}),t}var F9=65,HB=1e4,q9=20,$9=2,U9=[/^\/$/,/^\/t\/[^/]+$/,/^\/projects$/,/^\/agents$/,/^\/search$/];function R1(e){return e.pathname==="/agents"&&(e.searchParams.get("view")==="live"||e.searchParams.has("run"))?!1:U9.some(t=>t.test(e.pathname))}function FB(e){let t=new URLSearchParams(e.search);for(let n of["format","request","draft"])t.delete(n);let a=t.toString();return e.pathname+(a===""?"":`?${a}`)}var fs=new Map,ul=new Map,Sm=0,T1=()=>Date.now();function V9(){return document.hidden?!1:navigator.connection?.saveData!==!0}function Dy(){Sm+=1,fs.clear();for(let e of ul.values())e.stop.abort();ul.clear()}function A1(e){if(!V9()||!R1(e)||e.origin!==window.location.origin)return;let t=FB(e),a=fs.get(t);if(a!==void 0&&T1()-a.at<HB||ul.has(t)||ul.size>=$9)return;let n=Sm,o=new AbortController,r=od(t,"prefetch",fetch,o.signal).then(s=>{if(ul.get(t)?.stop===o&&ul.delete(t),s===null||n!==Sm)return null;for(fs.delete(t),fs.set(t,{page:s,at:T1()});fs.size>q9;)fs.delete(fs.keys().next().value);return s});ul.set(t,{stop:o,done:r})}function qB(e){let t=FB(e),a=fs.get(t);if(fs.delete(t),a!==void 0&&T1()-a.at<HB)return{page:a.page};let n=ul.get(t);if(n===void 0)return null;let o=Sm;return{pending:n.done.then(r=>o!==Sm?null:(fs.delete(t),r))}}function $B(e){let t=null,a=c=>c instanceof Element?c.closest("a[href]"):null,n=c=>{if(c===null)return;let f=e(c);f!==null&&A1(f)},o=()=>{t!==null&&clearTimeout(t.timer),t=null},r=c=>{if(c.pointerType==="touch")return;let f=a(c.target);f!==t?.anchor&&(o(),f!==null&&(t={anchor:f,timer:setTimeout(()=>{t=null,n(f)},F9)}))},s=c=>{if(t===null)return;let f=c.relatedTarget;f instanceof Node&&t.anchor.contains(f)||o()},i=c=>{n(a(c.target))},l=c=>{let f=a(c.target),d=!0;try{d=f?.matches(":focus-visible")??!1}catch{}d&&n(f)},u=c=>{let f=c.detail;f?.room==="workspace"&&f.event==="change"&&Dy()};return document.addEventListener("pointerover",r,{passive:!0}),document.addEventListener("pointerout",s,{passive:!0}),document.addEventListener("touchstart",i,{passive:!0}),document.addEventListener("focusin",l),window.addEventListener(Mv,u),window.addEventListener(da,Dy),()=>{o(),Dy(),document.removeEventListener("pointerover",r),document.removeEventListener("pointerout",s),document.removeEventListener("touchstart",i),document.removeEventListener("focusin",l),window.removeEventListener(Mv,u),window.removeEventListener(da,Dy)}}function UB(e){let t;try{t=new URL(e,"http://in-place.invalid").pathname}catch{return 1}return Math.max(1,t.split("/").filter(a=>a!=="").length)}function D1(e,t){let a=UB(e),n=UB(t);return n>a?"deeper":n<a?"shallower":"same"}var E1=["so-nav","so-nav-same","so-nav-deeper","so-nav-shallower"],jB="form[data-workspace-composer], .so-home-ask",WB="so-message-box",_y=null;function _1(){try{_y?.skipTransition()}catch{}}function VB(){document.querySelector(jB)?.style.setProperty("view-transition-name",WB)}function M1(){document.querySelectorAll(jB).forEach(e=>{e.style.getPropertyValue("view-transition-name")===WB&&e.style.removeProperty("view-transition-name")})}function j9(){try{if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return!1}catch{}return!document.hidden}function P1(e,t){_1();let a=document.startViewTransition;if(t===null||typeof a!="function"||!j9())return e(),Promise.resolve();let n=document.documentElement;n.classList.remove(...E1),n.classList.add("so-nav",`so-nav-${t}`),VB();let o=!1,r=null,s,i=new Promise(f=>{s=f}),l=()=>{if(!o){o=!0,M1();try{e()}catch(f){r=f}VB(),s()}},u;try{u=a.call(document,l)}catch{return n.classList.remove(...E1),M1(),l(),r===null?i:Promise.reject(r)}_y=u;let c=()=>{_y===u&&(_y=null,n.classList.remove(...E1),M1())};return u.finished.then(c,c),u.ready.catch(()=>{}),u.updateCallbackDone.catch(()=>{}).finally(l),i.then(()=>{if(r!==null)throw r})}var W9=[/^\/$/,/^\/t\/[^/]+$/,/^\/projects$/,/^\/agents$/,/^\/search$/,/^\/settings(?:\/[a-z-]+)?$/];function V1(e){return W9.some(t=>t.test(e.pathname))&&!(e.pathname==="/agents"&&e.searchParams.get("view")==="live")}var K9=(e,t)=>{t?window.location.replace(e):window.location.assign(e)};function uo(e,t=!1){Im()||K9(e,t)}function nz(e){if(!(e instanceof HTMLAnchorElement)||e.hasAttribute("target")||e.hasAttribute("download")||e.closest("[data-full-load]")!==null)return null;let t;try{t=new URL(e.getAttribute("href")??"",window.location.href)}catch{return null}return t.origin!==window.location.origin||t.protocol!=="http:"&&t.protocol!=="https:"||t.hash!==""&&t.pathname===window.location.pathname&&t.search===window.location.search?null:t}function G9(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return null;let t=e.target,a=t instanceof Element?t.closest("a[href]"):null;return a===null?null:nz(a)}function Py(){return document.querySelector("form[data-k-gate][data-dirty]")!==null}var H1="toolroll",Y9=e=>typeof e=="object"&&e!==null&&e[H1]==="in-place",By="toolrollEntry",na=null,Tr=null,F1="",q1=0,Ed=null,Qs="",j1=!1,oz=e=>{let t=new URLSearchParams(e.search);t.delete("draft");let a=t.toString();return e.pathname+(a===""?"":`?${a}`)},Js=()=>oz(window.location),rz=1e4,Md=0,Zs=null,Nm=new Set;function Im(){return Md!==0&&Date.now()-Md<rz}function sz(e){if(!Im()){e();return}Nm.add(e)}function W1(){q1+=1,Tr?.abort(),Tr=null,Oy(!1),$1(null)}function KB(){Md=Date.now(),W1(),Zs!==null&&clearTimeout(Zs),Zs=setTimeout(iz,rz),ps&&Nm.add(()=>{ps&&Tr===null&&uo(window.location.href,!0)})}function iz(){if(Md===0)return;Md=0,Zs!==null&&clearTimeout(Zs),Zs=null;let e=[...Nm];Nm.clear();for(let t of e)t()}var O1="data-so-pressed",GB="data-so-loading",X9=150,Cm=null;function $1(e){document.querySelectorAll(`[${O1}]`).forEach(t=>{t!==e&&t.removeAttribute(O1)}),e?.setAttribute(O1,"")}function Oy(e){Cm!==null&&clearTimeout(Cm),Cm=null;let t=()=>document.querySelector(".so-main-column");if(!e){t()?.removeAttribute(GB);return}Cm=setTimeout(()=>{Cm=null,t()?.setAttribute(GB,"")},X9)}var ps=!1;function Tm(){return ps}function B1(e){ps=e;let t=document.getElementById("workspace-main"),a=[...t?.children??[],...document.querySelectorAll("[data-workspace-detail]")];for(let n of a)n.toggleAttribute("inert",e);e?t?.setAttribute("data-so-provisional",""):t?.removeAttribute("data-so-provisional")}var lz=8;function Z9(e,t){let a=[];for(let n=t;n!==null&&n!==e;n=n.parentElement){let o=n.parentElement;if(o===null)return"";a.push(Array.prototype.indexOf.call(o.children,n))}return a.reverse().join(".")}function Q9(e,t){let a=e;if(t==="")return e;for(let n of t.split("."))if(a=a?.children[Number(n)]??null,a===null)return null;return a}function Hy(){let e=document.getElementById("workspace-main"),t=[];if(e!==null){for(let a of[e,...e.querySelectorAll("*")])if((a.scrollTop>0||a.scrollLeft>0)&&t.push([Z9(e,a),a.scrollTop,a.scrollLeft]),t.length>=lz)break}return{x:window.scrollX,y:window.scrollY,parts:t}}function J9(e){if(typeof e!="object"||e===null)return null;let{x:t,y:a,parts:n}=e;return typeof t!="number"||typeof a!="number"||!Array.isArray(n)||n.length>lz?null:n.every(r=>Array.isArray(r)&&r.length===3&&typeof r[0]=="string"&&/^(\d+(\.\d+)*)?$/.test(r[0])&&typeof r[1]=="number"&&typeof r[2]=="number")?{x:t,y:a,parts:n}:null}function zy(e){let t=document.getElementById("workspace-main");if(t!==null)for(let[a,n,o]of e.parts){let r=Q9(t,a);r!==null&&(r.scrollTop=n,r.scrollLeft=o)}(e.x!==0||e.y!==0)&&window.scrollTo(e.x,e.y)}function uz(e,t){zy(e),requestAnimationFrame(()=>requestAnimationFrame(()=>{t()&&zy(e)}))}function cl(e){let t=typeof e=="object"&&e!==null?e[By]:null;return typeof t=="string"&&/^[0-9a-f]{16}$/.test(t)?t:null}function YB(){return Array.from(crypto.getRandomValues(new Uint8Array(8)),e=>e.toString(16).padStart(2,"0")).join("")}var cz="toolroll.places",dz=50,z1=null;function fz(){if(z1!==null)return z1;let e=new Map;try{let t=JSON.parse(window.sessionStorage.getItem(cz)??"[]");if(Array.isArray(t))for(let a of t.slice(-dz)){let n=Array.isArray(a)&&a.length===2?cl({[By]:a[0]}):null,o=n===null?null:J9(a[1]);n!==null&&o!==null&&e.set(n,o)}}catch{}return z1=e,e}function K1(e,t){if(e===null)return;let a=fz();for(a.delete(e),a.set(e,t);a.size>dz;)a.delete(a.keys().next().value);try{window.sessionStorage.setItem(cz,JSON.stringify([...a]))}catch{}}function eY(e){let t=cl(e);return t===null?null:fz().get(t)??null}var Lm=null;function Fy(){Lm!==null&&clearTimeout(Lm),Lm=null}function XB(){Fy();let e=Js();Lm=setTimeout(()=>{Lm=null,!(na===null||e!==Js()||e!==Qs)&&K1(cl(window.history.state),Hy())},150)}async function U1(e,t,a=null,n=null){Tr?.abort(),_1(),Fy();let o=new AbortController,r=++q1,s=()=>q1!==r;Tr=o,F1="";let i=t==="pop",l=na?.current();$1(n);let u;try{u=new URL(e,window.location.href)}catch{uo(e,i);return}if(F1=oz(u),na===null||l===void 0||l.inPlace!==!0||!V1(u)||Py()){uo(e,i);return}let c=window.location.href,f=qB(u),d=od(u.pathname+u.search,"navigate",fetch,o.signal),m=null;if(f!==null&&"page"in f?m=f.page:(Oy(!0),f!==null&&(m=await Promise.race([f.pending,d.then(()=>null)]))),s())return;let h=()=>{Tr===o&&(Tr=null),Oy(!1),$1(null)};if(m!==null&&!Py()){if(Oy(!1),!na.accept(m,e,i,"navigate")){o.abort(),h();return}let x=m;if(await P1(()=>{s()||na===null||(ZB(u,t),document.title=x.title,ps=!0,na.show(x,!0),B1(!0),a!==null&&zy(a))},D1(l.path,x.path)),s())return;QB(x.title,u.hash!=="",a);let v=await d;if(s())return;if(h(),v===null){uo(e,!0);return}if(!na.accept(v,e,!0,"confirm"))return;let y=Hy(),g=document.activeElement?.id==="workspace-main"||document.activeElement===document.body;document.title=v.title,ps=!1,na.show(v,!1),B1(!1),g&&document.getElementById("workspace-main")?.focus({preventScroll:!0}),uz(y,()=>Tr===null&&Qs===Js()),JB(c,t);return}let w=await d;if(!s()){if(h(),w===null){uo(e,i);return}if(Py()){uo(e,i);return}na.accept(w,e,i,"navigate")&&(await P1(()=>{s()||na===null||(ZB(u,t),document.title=w.title,ps=!1,na.show(w,!1),B1(!1),a!==null&&zy(a))},D1(l.path,w.path)),!s()&&(QB(w.title,u.hash!=="",a),JB(c,t)))}}function ZB(e,t){if(t==="push"){let a=window.history.state,n=cl(a)??YB(),o=YB();K1(n,Hy()),window.history.replaceState({...typeof a=="object"&&a!==null?a:{},[H1]:"in-place",[By]:n},""),window.history.pushState({[H1]:"in-place",[By]:o},"",e.pathname+e.search+e.hash),j1=!0,Ed=o}else Ed=cl(window.history.state);Qs=Js()}function QB(e,t,a){let n=document.getElementById("workspace-main");if(n?.focus({preventScroll:!0}),aY(e),a!==null){uz(a,()=>!0);return}t||(n?.scrollTo?.(0,0),document.querySelectorAll("#workspace-main .so-page-content, #workspace-main [data-kit-page]").forEach(o=>o.scrollTo?.(0,0)),window.scrollTo(0,0))}var tY=400;function JB(e,t){if(t!=="push")return;let a;try{a=new URL(e)}catch{return}R1(a)&&setTimeout(()=>{na!==null&&Tr===null&&na.current().inPlace===!0&&A1(a)},tY)}function aY(e){let t=document.getElementById("so-page-announce");t===null&&(t=document.createElement("div"),t.id="so-page-announce",t.className="so-sr-only",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),document.body.append(t)),t.textContent="";let a=t;requestAnimationFrame(()=>{a.textContent=e})}function nY(e){if(na===null||na.current().inPlace!==!0||Im())return null;let t=nz(e);return t===null||!V1(t)||t.pathname+t.search===window.location.pathname+window.location.search?null:t}function ez(e){let t=G9(e);if(t===null||na===null||na.current().inPlace!==!0||!V1(t)||Py())return;e.preventDefault();let a=e.target instanceof Element?e.target.closest("a[href]"):null;U1(t.pathname+t.search+t.hash,"push",null,a)}function tz(e){if(Fy(),na===null)return;let t=window.location.pathname+window.location.search+window.location.hash;if(Js()===Qs){Ed=cl(e.state),ps&&Tr!==null&&F1===Qs||W1(),ps&&Tr===null&&U1(t,"pop",null);return}na.current().inPlace!==!0&&!j1&&!Y9(e.state)||(K1(Ed,Hy()),U1(t,"pop",eY(e.state)))}function az(){Js()===Qs&&(Ed=cl(window.history.state))}function Rm(e){if(na!==null&&Js()!==Qs)return!1;try{window.history.replaceState(window.history.state,"",e)}catch{return!1}return na!==null&&(Qs=Js()),!0}function pz(e){na=e,Qs=Js(),Ed=cl(window.history.state),j1=!1,Md=0,Nm.clear(),ps=!1,Zs!==null&&clearTimeout(Zs),Zs=null;try{window.history.scrollRestoration="manual"}catch{}let t=()=>iz();document.addEventListener("click",ez),window.addEventListener("popstate",tz),window.addEventListener("hashchange",az),window.addEventListener("beforeunload",KB),window.addEventListener("pageshow",t),document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",t,!0),document.addEventListener("scroll",XB,{capture:!0,passive:!0});let a=$B(nY);return()=>{na===e&&(na=null),W1(),Fy(),a(),document.removeEventListener("click",ez),window.removeEventListener("popstate",tz),window.removeEventListener("hashchange",az),window.removeEventListener("beforeunload",KB),window.removeEventListener("pageshow",t),document.removeEventListener("pointerdown",t,!0),document.removeEventListener("keydown",t,!0),document.removeEventListener("scroll",XB,{capture:!0})}}var G1={goal:8e3,goalBytes:32e3,note:4e3,noteBytes:16e3,flowInstructions:8e3,flowTitle:60,flowStepId:32,flowRef:60,flowMessage:1e3,flowDecider:64,flowSubagent:40,flowRepo:1e3,flowAnswer:40,flowChoice:40,flowSortMeans:200,flowSortQuestion:300,flowSortLevel:120,flowUrl:2e3,flowHeader:500,flowBody:8e3,flowEmailTo:500,flowEmailSubject:200,flowToolServer:64,flowToolName:100,flowToolArgs:4e3,flowDuration:40,flowTimeZone:60,flowName:80,flowFileAbout:600,flowFileNeed:80,flowParameter:200,flowScriptAbout:160,flowScriptBody:2e4,flowScriptFile:200,triggerButton:40,triggerQuestion:80,triggerSchedule:80,triggerTitle:200,triggerDescription:2e3,triggerGithubRepo:140,triggerLabel:50,triggerBranch:100,triggerTeam:12,triggerState:40,triggerWebhookTitle:120,triggerWebhookField:80,triggerWebhookScope:120,triggerFolder:100,triggerSender:300,triggerSubject:100,triggerSecrets:500,flowCardTitle:200,flowCardDescription:4e3,flowScriptInline:1600,reportSummary:2500,reportPayloadBytes:98304,reportDocumentBytes:65536,reportTitleBytes:200,reportWhyBytes:1e3,reportUrlBytes:2e3,reportCaptionBytes:300,stageOutput:12e3,planPayloadBytes:65536,planDocumentBytes:16384,planApproach:2e3,planItem:600,planTouch:200,scopeTouches:50,sizeReason:300,planAmendment:1e3,acceptanceIdBytes:40,acceptanceStatementBytes:1e3,acceptanceHowBytes:500,proofPayloadBytes:65536,proofCriterionIdBytes:40,proofHowBytes:500,proofLineBytes:300,sizingReason:160,reviewPath:300,reviewNote:500,decisionRecap:2e3,decisionQuestion:2e3,decisionOptionId:40,decisionRecommendation:500,decisionLabel:120,decisionConsequence:500,decisionAssignee:120,subagentAnswer:60,subagentQuestion:600,subagentReason:400,subagentRemember:300,taskRef:64,taskTitle:200,taskTouch:200,projectPath:4096,gatewayRepo:800,contextQuery:1e3,logSearch:120,memorySearch:300,taskSearch:200,diffPath:300,proposalReason:200,answerRationale:400,answerOption:64,workerName:60,agentWhy:400,agentProvider:20,agentModel:120,checksWords:80,recapSince:30,actionSample:800,actionContent:12e3,actionTitle:120,actionName:40,actionCommand:400,actionUrl:500,actionSecret:64,actionAbout:240,subagentSection:60,subagentSchedule:80,subagentTool:40,subagentAction:64,subagentName:40,subagentSoul:12e3,subagentNote:300,subagentChoice:60,subagentText:2e3,knowledgeReference:20,promise:240,rememberText:240,rememberWhy:2e3,rememberSource:200,personName:80,ownerQuestion:200,ownerOption:40,idempotencyKey:64,leadContextBytes:8e3,leadPromise:160,leadCorrection:300,leadCorrectionInstructions:240,leadProposalAbout:120,knowledgeInstructionsBytes:4e3,knowledgeTitleBytes:120,knowledgePathBytes:300,knowledgeReferenceBytes:12e3,knowledgeContextBytes:24e3,knowledgeDecisionsBytes:1500,knowledgeRepositoryBytes:6e3,knowledgeRepositoryMinBytes:3e3,decisionClaimBytes:240,decisionWhyBytes:2e3,decisionByBytes:80,decisionSourceBytes:200,decisionRetireBytes:500,skillNameBytes:64,skillDescriptionBytes:1024,skillRequirementsBytes:500,skillSourceBytes:500,skillPath:240,skillBodyBytes:24576,skillFileBytes:262144,skillPackageBytes:1048576,skillSelectionBytes:2097152,skillSample:800,skillSampleBytes:4e3,skillFeedback:500,skillFeedbackBytes:2e3,memoryTrace:4e4,memoryEffect:300,memoryMistake:300,memoryInstruction:240,telegramCallbackDataBytes:64};function mz(e,t){return e.until===null||e.limitMs===null?"Paused.":`Paused. It can wait until ${t(e.until)} (${Math.max(1,Math.round(e.limitMs/6e4))} min) before it ends.`}var qy=O(ve(),1);var oY={claude:"Claude",codex:"Codex",antigravity:"Antigravity",shell:"terminal"};function $y(e){if(e===void 0)return null;let t=[];if(e.terminalController!==null){let a=e.terminalProgram?oY[e.terminalProgram]??e.terminalProgram:"terminal";t.push(`${e.terminalController} typing in ${a}`)}return e.viewers.length===1?t.push(`${e.viewers[0]} viewing`):e.viewers.length>1&&t.push(`${e.viewers[0]} + ${e.viewers.length-1} viewing`),t.length===0?null:t.join(" · ")}function hz(e,t,a){if(t==="everyone"||a===null)return!0;let n=a.owners[e]??null;return t==="mine"?n===a.me:t==="unassigned"?n===null:t==="team"?n!==null&&n!==a.me:!0}function Uy(){let[e,t]=(0,qy.useState)(null);return(0,qy.useEffect)(()=>{if(typeof window>"u"||typeof document>"u"||typeof fetch!="function"||!document.querySelector("[data-workspace-shell]"))return;let a=!0,n=()=>{let r=fetch("/api/presence",{credentials:"same-origin",headers:{accept:"application/json","x-toolroll-read":"prefetch"}});!r||typeof r.then!="function"||r.then(s=>s&&s.ok?s.json():null).then(s=>{if(!a||s===null||typeof s!="object")return;let i=s;i.ok!==!0||typeof i.me!="string"||t({me:i.me,tasks:i.tasks&&typeof i.tasks=="object"?i.tasks:{},owners:i.owners&&typeof i.owners=="object"?i.owners:{},accounts:Array.isArray(i.accounts)?i.accounts.filter(l=>typeof l=="string"):[]})}).catch(()=>{})};n();let o=()=>n();return window.addEventListener(da,o),()=>{a=!1,window.removeEventListener(da,o)}},[]),e}var dl=O(ve(),1);var wt=O(Z(),1);function gz({taskId:e,csrf:t,presence:a}){let[n,o]=(0,dl.useState)([]),[r,s]=(0,dl.useState)(""),[i,l]=(0,dl.useState)(null),[u,c]=(0,dl.useState)(null);(0,dl.useEffect)(()=>{if(typeof window>"u"||typeof document>"u"||typeof fetch!="function"||!document.querySelector("[data-workspace-shell]"))return;let x=!0,v=()=>{let y=fetch(`/api/handoff/task/${encodeURIComponent(e)}/candidates`,{credentials:"same-origin",headers:{accept:"application/json","x-toolroll-read":"prefetch"}});!y||typeof y.then!="function"||y.then(g=>g&&g.ok?g.json():null).then(g=>{if(!x||!g||typeof g!="object")return;let b=g;b.ok===!0&&Array.isArray(b.candidates)&&o(b.candidates)}).catch(()=>{})};return v(),window.addEventListener(da,v),()=>{x=!1,window.removeEventListener(da,v)}},[e]);let f=a?a.accounts.filter(x=>x!==a.me):[],d=a?.owners[e]??null;if((0,dl.useEffect)(()=>{r===""&&f.length>0&&s(f[0])},[f.join(",")]),f.length===0&&n.length===0)return null;let m=async()=>{if(!(i!==null||r==="")){l("handoff"),c(null);try{let x=await fetch(`/api/handoff/task/${encodeURIComponent(e)}/assign-person`,{method:"POST",credentials:"same-origin",headers:yt({"content-type":"application/json","x-csrf-token":t,accept:"application/json"}),body:JSON.stringify({person:r})}),v=await x.json().catch(()=>null);!x.ok||!v?.ok?c(v?.message??"Could not hand off this task."):(c(v.warning?`Handed off to ${r}. Note: ${v.warning}`:`Handed off to ${r}.`),window.dispatchEvent(new CustomEvent(da)))}catch{c("Could not reach Toolroll.")}finally{l(null)}}},h=async x=>{if(i===null){l(x),c(null);try{let v=await fetch(`/api/handoff/task/${encodeURIComponent(e)}/candidate/${encodeURIComponent(x)}/promote`,{method:"POST",credentials:"same-origin",headers:yt({"content-type":"application/json","x-csrf-token":t,accept:"application/json"}),body:"{}"}),y=await v.json().catch(()=>null);if(!v.ok||!y?.ok)c(y?.message??"Could not promote local candidate.");else{let g=y.runId?` → Run #${y.runId}`:"",b=y.checks?.status==="queued"?` (${y.checks.level??"full"} checks queued)`:y.checks?.status==="not-configured"?" (no project check configured)":"";c(`Promoted Candidate ${x}${g}${b}.`),window.dispatchEvent(new CustomEvent(da))}}catch{c("Could not reach Toolroll.")}finally{l(null)}}},w=async x=>{if(i===null){l(`pr:${x}`),c(null);try{let v=await fetch(`/api/handoff/task/${encodeURIComponent(e)}/candidate/${encodeURIComponent(x)}/open-pr`,{method:"POST",credentials:"same-origin",headers:yt({"content-type":"application/json","x-csrf-token":t,accept:"application/json"}),body:"{}"}),y=await v.json().catch(()=>null);if(!v.ok||!y?.ok)c(y?.message??"Could not queue pull request.");else{let g=y.publication;c(g?.prNumber?`Pull request #${g.prNumber} already open for ${x}.`:`Queued pull request for ${x} (${g?.head??"candidate"} → ${g?.base??"main"}).`),window.dispatchEvent(new CustomEvent(da))}}catch{c("Could not reach Toolroll.")}finally{l(null)}}};return(0,wt.jsxs)("div",{className:"so-task-multiplayer","data-task-multiplayer":"",style:{display:"flex",flexDirection:"column",gap:"8px",margin:"8px 0 12px"},children:[f.length>0&&(0,wt.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"8px",fontSize:"13px"},children:[(0,wt.jsxs)("span",{children:["Owner: ",(0,wt.jsx)("strong",{children:d??"Unassigned"})]}),(0,wt.jsx)("label",{htmlFor:`handoff-${e}`,style:{marginLeft:"4px"},children:"Hand off to:"}),(0,wt.jsx)("select",{id:`handoff-${e}`,value:r,onChange:x=>s(x.target.value),disabled:i!==null,style:{padding:"3px 8px",borderRadius:"6px",border:"1px solid var(--so-line)",background:"transparent",color:"inherit",fontSize:"13px"},children:f.map(x=>(0,wt.jsx)("option",{value:x,children:x},x))}),(0,wt.jsx)(de,{sm:!0,variant:"ghost",label:"Hand off",busy:i==="handoff"?"Handing off…":!1,onClick:()=>{m()}})]}),n.map(x=>(0,wt.jsxs)("div",{"data-handoff-candidate":x.id,style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"8px",padding:"8px 10px",borderRadius:"8px",border:"1px solid var(--so-line)",fontSize:"13px"},children:[(0,wt.jsx)(Oe,{word:x.promotedAt?x.liveCheckState==="passed"?"Central checks passed":x.liveCheckState==="failed"?"Central checks failed":x.liveCheckState==="running"?"Central checks running":x.liveCheckState==="waiting"||x.checkStatus==="queued"?"Central checks queued":"Promoted to central Run":x.stale?"Stale — re-pull & rebase":"Unverified Candidate",tone:x.promotedAt?x.liveCheckState==="failed"?"failed":x.liveCheckState==="passed"?"done":"live":"needs"}),(0,wt.jsxs)("span",{children:[(0,wt.jsx)("strong",{children:x.author})," submitted ",(0,wt.jsx)("code",{children:x.id})," (",x.files.length," file",x.files.length===1?"":"s",x.note?` · ${x.note}`:"",")",x.stale&&!x.promotedAt?(0,wt.jsxs)(wt.Fragment,{children:[" · run ",(0,wt.jsx)("code",{children:`toolroll handoff rebase ${e}`})]}):null,x.runId?(0,wt.jsxs)(wt.Fragment,{children:[" · ",(0,wt.jsxs)("a",{className:"k-link",href:`/r/${x.runId}`,children:["Run #",x.runId]})]}):null,x.publication?.prUrl?(0,wt.jsxs)(wt.Fragment,{children:[" · ",(0,wt.jsx)("a",{className:"k-link",href:x.publication.prUrl,target:"_blank",rel:"noreferrer",children:x.publication.prNumber?`PR #${x.publication.prNumber}`:"Open PR"})]}):x.publication?(0,wt.jsxs)(wt.Fragment,{children:[" · ",(0,wt.jsx)(Oe,{word:"PR queued",tone:"live"})]}):null]}),!x.promotedAt&&!x.stale&&(0,wt.jsx)(de,{sm:!0,variant:"primary",label:"Promote to central Run",busy:i===x.id?"Promoting…":!1,onClick:()=>{h(x.id)}}),x.promotedAt&&x.canOpenPr&&!x.publication&&(0,wt.jsx)(de,{sm:!0,variant:"primary",label:"Open PR",busy:i===`pr:${x.id}`?"Opening PR…":!1,onClick:()=>{w(x.id)}})]},x.id)),u&&(0,wt.jsx)("p",{role:"status",style:{margin:0,fontSize:"13px",opacity:.9},children:u})]})}var it=O(Z(),1),rY={neutral:"bg-muted-foreground",live:"bg-info",attention:"bg-attention",ready:"bg-transparent ring-2 ring-inset ring-success",success:"bg-success",danger:"bg-destructive"},sY={ok:(0,it.jsx)(Fs,{className:"size-3.5 text-success","aria-hidden":"true"}),running:(0,it.jsx)(Ep,{className:"size-3.5 text-info","aria-hidden":"true"}),none:(0,it.jsx)(Mp,{className:"size-3 text-muted-foreground","aria-hidden":"true"}),note:(0,it.jsx)(Pn,{className:"size-3.5 text-muted-foreground","aria-hidden":"true"}),failed:(0,it.jsx)(no,{className:"size-3.5 text-destructive","aria-hidden":"true"})};function vz({status:e,as:t="h2"}){return(0,it.jsxs)(t,{className:"flex items-center gap-2.5 text-lg font-semibold leading-snug","data-headline":e.headline,children:[(0,it.jsx)("span",{"aria-hidden":"true",className:ye("size-2.5 shrink-0 rounded-full",rY[e.tone])}),e.headline]})}var Y1="phone:-my-3 phone:inline-block phone:py-3";function iY({detail:e,runChecks:t,csrf:a}){let n=t!==null&&a!==""&&e.action?.href===t.action,o=e.href===null?e.text:(0,it.jsx)("a",{href:e.href,className:ye("underline decoration-border underline-offset-4 hover:decoration-muted-foreground",Y1),children:e.text});return(0,it.jsxs)("li",{"data-status-detail":e.key,"data-mark":e.mark,className:"grid grid-cols-[14px_7.5rem_minmax(0,1fr)] items-center gap-x-2.5 py-1.5 text-body phone:min-h-11 phone:grid-cols-[14px_6.25rem_minmax(0,1fr)] phone:py-1",children:[(0,it.jsx)("span",{className:"flex items-center justify-center",children:sY[e.mark]}),(0,it.jsx)("span",{className:"text-muted-foreground",children:e.label}),(0,it.jsxs)("span",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2.5",children:[(0,it.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:o}),e.action!==null&&(n?(0,it.jsxs)(Fe,{action:t.action,"data-run-checks":!0,className:"inline",children:[(0,it.jsx)("input",{type:"hidden",name:"level",value:t.level}),(0,it.jsx)("input",{type:"hidden",name:"return",value:t.returnTo}),(0,it.jsx)("button",{type:"submit","data-detail-action":!0,className:ye("cursor-pointer whitespace-nowrap font-medium underline-offset-4 hover:underline",Y1),children:e.action.label})]}):e.action.href===null?(0,it.jsx)("span",{className:"font-medium",children:e.action.label}):(0,it.jsx)("a",{href:e.action.href,"data-detail-action":!0,className:ye("whitespace-nowrap font-medium underline-offset-4 hover:underline",Y1),children:e.action.label}))]})]})}function yz({status:e,runChecks:t=null,csrf:a=""}){return e.details.length===0?null:(0,it.jsx)("ul",{"aria-label":"Status",className:"flex flex-col border-t border-border pt-2 phone:pt-1.5",children:e.details.map(n=>(0,it.jsx)(iY,{detail:n,runChecks:t,csrf:a},n.key))})}function Vy(e,t=[]){return[...new Set([...e.details.flatMap(a=>a.why===null?[]:[`${a.label}: ${a.why}`]),...e.why,...t])]}function wz(e){return e==="attention"?"attention":e==="problem"?"danger":e==="live"?"live":e==="ready"?"ready":e==="done"?"success":"neutral"}var X1={attention:"decide",danger:"failed",live:"building",ready:"review",success:"done",neutral:"idle"};function Z1(e){return X1[wz(e)]}function xz({label:e,tone:t,className:a,...n}){let o=wz(t);return(0,it.jsxs)("span",{...n,"data-headline":e,className:ye("inline-flex w-fit shrink-0 items-center gap-1.5 whitespace-nowrap py-px text-badge",o==="attention"?"font-medium text-foreground":"text-muted-foreground",a),children:[(0,it.jsx)(fi,{kind:X1[o]}),e]})}function bz({form:e,csrf:t,label:a="Check again"}){return(0,it.jsxs)(Fe,{action:e.action,id:"recheck-stopped","data-recheck-stopped":e.run,className:"flex flex-wrap items-center gap-2 phone:w-full",children:[(0,it.jsx)("input",{type:"hidden",name:"run",value:String(e.run)}),e.returnTo!==void 0&&(0,it.jsx)("input",{type:"hidden",name:"return",value:e.returnTo}),(0,it.jsx)(pe,{type:"submit",variant:"attention",className:"phone:w-full","data-primary-action":!0,children:a})]})}function kz({action:e,csrf:t,label:a="Retry",className:n,pins:o}){return(0,it.jsxs)(Fe,{action:e,"data-rebuild":!0,className:"phone:w-full",children:[(0,it.jsx)(Am,{pins:o}),(0,it.jsx)(pe,{type:"submit",variant:"attention",className:ye("phone:w-full",n),"data-primary-action":!0,children:a})]})}function Am({pins:e}){return e==null?null:(0,it.jsxs)(it.Fragment,{children:[(0,it.jsx)("input",{type:"hidden",name:"run",value:e.run}),(0,it.jsx)("input",{type:"hidden",name:"digest",value:e.digest})]})}var T=O(Z(),1);function Em(e,t,a=!1){let n=e===""?null:(e==="steering"?document.querySelector('[data-task-panel="activity"] #steering'):null)??document.getElementById(e);if(n===null)return!1;let o=n.closest('[data-task-panel="activity"]')!==null,r=!o&&J1();o||t({page:!0});let s=n.closest("[data-step-row]");return s!==null&&t({row:s.dataset.stepRow}),o&&t({activity:!0}),n.closest("[data-task-details]")!==null&&window.dispatchEvent(new CustomEvent("so:show-details")),requestAnimationFrame(()=>{for(let i=n;i!==null;i=i.parentElement)i instanceof HTMLDetailsElement&&(i.open=!0);n instanceof HTMLDetailsElement&&(n.open=!0),n.scrollIntoView({block:"start",behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"}),a?n.querySelector("input:not([type=hidden]), textarea, select, button")?.focus({preventScroll:!0}):r&&jy(n)}),!0}var Rz="(max-width: 1099px)",nC=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Rz).matches,J1=()=>nC()&&document.querySelector('[data-task-panel="activity"]:not([hidden])')!==null;function jy(e,t=4){if(e.closest("[inert]")!==null&&t>0){requestAnimationFrame(()=>jy(e,t-1));return}!e.hasAttribute("tabindex")&&!e.matches("a[href], button, input, select, textarea, summary")&&(e.tabIndex=-1),e.focus({preventScroll:!0})}function lY(){let[e,t]=(0,lt.useState)(nC);return(0,lt.useEffect)(()=>{if(typeof window.matchMedia!="function")return;let a=window.matchMedia(Rz),n=()=>t(a.matches);return n(),a.addEventListener?.("change",n),()=>a.removeEventListener?.("change",n)},[]),e}function uY(e,t,a,n){let o=lY(),r=(0,lt.useRef)(n);r.current=n;let s=(0,lt.useRef)(null);return(0,lt.useLayoutEffect)(()=>{let i=document.getElementById(e);if(i===null||(i.hidden=!t,!t||!o))return;let l=!1,u=i.querySelector("[data-close-activity]");u?.setAttribute("autofocus","");let c=io(i,a.current,{dim:!0,onClose:()=>{l||(l=!0,r.current())}});return u?.removeAttribute("autofocus"),s.current=c,()=>{s.current=null,l||(l=!0,c()),i.removeAttribute("role"),i.removeAttribute("aria-modal")}},[e,t,o]),()=>{let i=s.current;return i===null?!1:(i(),!0)}}function cY(e){(0,lt.useEffect)(()=>{let t=()=>{Em(decodeURIComponent(window.location.hash.slice(1)),e)};return t(),window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)},[])}function jt({html:e,className:t}){return(0,T.jsx)(Ct,{html:e,immutable:!0,...t===void 0?{}:{className:t}})}function dY(){let e=document.getElementById("cancel-task");if(!(e instanceof HTMLDetailsElement)){window.location.hash="cancel-task";return}e.open=!0,e.scrollIntoView({block:"start"}),e.querySelector("summary")?.focus()}function oC({action:e,note:t,pins:a}){let n=(t??"").trim();return(0,T.jsxs)(Fe,{action:e,"data-retry":!0,className:"k-field",children:[(0,T.jsx)(Am,{pins:a}),n!==""&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("input",{type:"hidden",name:"context",value:n}),(0,T.jsxs)("p",{className:"k-note","data-retry-suggestion":"",children:["Sent with the retry: ",n]})]}),(0,T.jsx)("label",{htmlFor:"retry-note",className:"k-label",children:"Your note for the next attempt"}),(0,T.jsx)(ld,{id:"retry-note",name:"note",maxLength:gO,rows:2,placeholder:"Optional","data-retry-note":""}),(0,T.jsx)("div",{className:"k-acts",children:(0,T.jsx)(de,{type:"submit",variant:"primary",label:"Retry","data-primary-action":"",title:"Keeps the branch and workspace"})})]})}function fY({failure:e}){return e.evidence===null&&e.link===null?null:(0,T.jsxs)("span",{className:"so-task-evidence","data-failure-evidence":!0,children:[e.evidence!==null&&(0,T.jsx)("span",{children:e.evidence}),e.link!==null&&(0,T.jsxs)(T.Fragment,{children:[e.evidence!==null&&" ",(0,T.jsx)("a",{className:"k-link",href:e.link.href,"data-failure-log":!0,children:e.link.label})]})]})}function pY({stop:e}){return(0,T.jsxs)(Fe,{action:e.action,className:"task-stop-form","data-task-control":"stop","data-control-run":e.run,children:[(0,T.jsx)("input",{type:"hidden",name:"run",value:e.run}),(0,T.jsx)("input",{type:"hidden",name:"return",value:"task"}),(0,T.jsx)(de,{type:"submit",variant:"danger",label:"Stop","data-stop-build":""})]})}function mY({pause:e}){return(0,T.jsxs)(Fe,{action:e.action,"data-task-control":"pause","data-control-run":e.run,children:[(0,T.jsx)("input",{type:"hidden",name:"run",value:e.run}),(0,T.jsx)("input",{type:"hidden",name:"request",value:e.requests[0]}),(0,T.jsx)("input",{type:"hidden",name:"return",value:"task"}),(0,T.jsx)(de,{type:"submit",label:"Pause","data-pause-build":""})]})}function hY({pause:e}){return(0,T.jsxs)(Fe,{action:e.action,"data-task-control":"resume","data-control-run":e.run,children:[(0,T.jsx)("input",{type:"hidden",name:"run",value:e.run}),(0,T.jsx)("input",{type:"hidden",name:"request",value:e.requests[2]}),(0,T.jsx)("input",{type:"hidden",name:"mode",value:"resume"}),(0,T.jsx)("input",{type:"hidden",name:"return",value:"task"}),(0,T.jsx)(de,{type:"submit",variant:"primary",label:"Resume","data-resume-build":""})]})}function gY({pause:e,onCancel:t}){let a=e.state==="paused",[n,o]=(0,lt.useState)(()=>Rd(e.run)),r=s=>o(i=>{let l=i.submitted?{...Jo(),text:s}:{...i,text:s};return cs(e.run,l),l});return(0,T.jsxs)(Fe,{action:e.action,className:"k-field","data-task-control":"pause-and-steer","data-control-run":e.run,onSubmit:()=>o(s=>{let i={...s,submitted:!0};return cs(e.run,i),i}),children:[(0,T.jsx)("input",{type:"hidden",name:"run",value:e.run}),(0,T.jsx)("input",{type:"hidden",name:"request",value:`steer-${n.key}`}),(0,T.jsx)("input",{type:"hidden",name:"key",value:n.key}),(0,T.jsx)("input",{type:"hidden",name:"return",value:"task"}),(0,T.jsx)("label",{htmlFor:"pause-steer-note",className:"k-label",children:a?"Note to continue with":"Note for the agent"}),(0,T.jsx)(ld,{id:"pause-steer-note",name:"note",required:!0,autoFocus:!0,maxLength:G1.note,rows:2,placeholder:"What should it do instead?","data-pause-steer-note":"",value:n.text,onChange:s=>r(s.target.value)}),(0,T.jsxs)("div",{className:"k-acts",children:[(0,T.jsx)(de,{type:"submit",variant:"primary",label:a?"Continue":"Pause and send","data-pause-steer-send":""}),(0,T.jsx)(de,{variant:"ghost",label:"Cancel",onClick:t})]})]})}function vY(e,t){if(e===null)return Promise.resolve("This form is no longer on the page. Nothing changed.");if(!e.checkValidity())return e.reportValidity(),Promise.resolve("Fill in what the form asks for first. Nothing changed.");let a=e.querySelector('input[name="token"]');return a!==null&&(a.value=t??""),e.requestSubmit(),new Promise(()=>{})}function yY({form:e,label:t}){return(0,T.jsxs)(Fe,{action:e.action,id:"recheck-stopped","data-recheck-stopped":e.run,className:"k-acts",children:[(0,T.jsx)("input",{type:"hidden",name:"run",value:String(e.run)}),(0,T.jsx)(de,{type:"submit",variant:"primary",label:t,"data-primary-action":""})]})}var Az=()=>document.getElementById("plan-editor")instanceof HTMLDetailsElement&&document.getElementById("plan-editor").open,Ez=()=>{if(Az())return!0;let e=document.getElementById("plan-edit");return e!==null&&[...e.querySelectorAll("textarea, input:not([type=hidden])")].some(t=>t.value!==t.defaultValue)};function wY(){let[e,t]=(0,lt.useState)(!1);return(0,lt.useEffect)(()=>{let a=()=>t(Ez());a();let n=r=>{let s=r.target?.id;(s==="plan-editor"||s==="plan-edit")&&a()},o=r=>{r.target?.closest?.("#plan-edit, #plan-editor")&&a()};return document.addEventListener("toggle",n,!0),document.addEventListener("input",o,!0),()=>{document.removeEventListener("toggle",n,!0),document.removeEventListener("input",o,!0)}},[]),e}function Sz({approve:e,latest:t,onEdit:a,reject:n=!1,inRow:o=!1,sheet:r}){let s=(0,lt.useRef)(null),i=(0,lt.useContext)(yn),l=wY(),[u,c]=(0,lt.useState)(null),f=t==null||t.fields.digest!==e.fields.digest,d=e.rememberedUntil===null?null:new Date(e.rememberedUntil).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),m={...e.facts,rememberedUntil:d},h=e.termsWords??gu(e.kind,m),w=e.action.replace(/\/approve$/,""),x=(0,lt.useRef)(!0);(0,lt.useEffect)(()=>(x.current=!0,()=>{x.current=!1}),[]);let v=async()=>{let b=e.fields.digest??"",k=e.fields.rebuild??null;if(b==="")return"This form can’t approve: reload the page to read the plan again. Nothing changed.";let C=window.location.pathname.startsWith("/t/")?`${window.location.pathname}${window.location.search}`:w,N=await Ry(C);if(!x.current)return new Promise(()=>{});let L=bm(N),A=Ay(N);if(L===null||A===null)return"Couldn’t read the plan just now. Nothing changed.";if(L.action!==e.action||L.digest!==b||L.rebuild!==k||al(L.kind,L.facts)!=="click")return c({words:"The plan changed since this page loaded. Nothing was approved: reload to read the version you would approve.",done:!1}),null;let P=await Ey({action:e.action,digest:b,rebuild:k},i,A);return x.current?P.kind==="elsewhere"?(window.location.assign(w),new Promise(()=>{})):P.kind==="lost"?(c({words:"Checking…",done:!0}),window.location.reload(),null):(P.outcome==="approved"?c({words:"Approved.",done:!0}):c({words:P.outcome==="refused"?`${Hn(P.words)} Nothing changed.`:Hn(P.words),done:!1}),window.dispatchEvent(new CustomEvent(da)),null):new Promise(()=>{})},y=b=>Ez()?Promise.resolve("Save or cancel your edit first: approving now would approve the plan as it was. Nothing changed."):b===null&&al(e.kind,m)==="click"?v():vY(s.current,b),g=!f&&!l&&u===null;return(0,T.jsxs)(Fe,{ref:s,action:e.action,className:"k-approve","data-approval-kind":e.kind,"data-task-approval":!0,"data-editing":l?"":void 0,children:[Object.entries(e.fields).map(([b,k])=>(0,T.jsx)("input",{type:"hidden",name:b,value:k},b)),(0,T.jsx)("input",{type:"hidden",name:"token",value:""}),(0,T.jsx)(To,{wait:!0,status:(0,T.jsxs)(T.Fragment,{children:[!o&&(0,T.jsx)(Oe,{word:"Needs you",tone:"needs"}),(0,T.jsx)("h2",{children:e.heading})]}),text:e.text,...r===void 0?{}:{body:(0,T.jsx)(jt,{html:r,className:"so-task-plan"})},acts:u!==null?u.done?null:(0,T.jsx)(de,{variant:"primary",label:"Reload",onClick:()=>window.location.reload()}):f?(0,T.jsx)(de,{variant:"primary",label:"Reload",onClick:()=>window.location.reload()}):l?(0,T.jsx)(de,{label:"Back to the edit",onClick:()=>{if(Az()){a?.();return}let b=document.getElementById("plan-edit");b instanceof HTMLDetailsElement&&(b.open=!0,b.scrollIntoView({block:"start"}),b.querySelector("textarea")?.focus())}}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(gm,{kind:e.kind,facts:m,label:e.label,docked:!0,terms:h,text:e.text,onApprove:y}),a!==null&&(0,T.jsx)(de,{label:"Request changes",onClick:a}),n&&(0,T.jsx)(de,{variant:"ghost",label:"Reject…",title:"Opens Cancel task, where you confirm it","data-approval-reject":"",onClick:dY})]}),terms:u!==null?u.words:f?"The plan changed since this page loaded. Reload to see the version you would approve.":l?"You have unsaved changes to the plan. Save them (it then asks for approval again) or cancel the edit to approve this version.":h}),g&&(0,T.jsx)(Qo,{children:(0,T.jsx)(gm,{kind:e.kind,facts:m,label:e.label,terms:h,text:e.text,onApprove:y})})]})}function xY({ship:e}){let t=e.state==="failed"?(0,T.jsx)(Oe,{word:"Check failed",tone:"failed"}):e.state==="running"?(0,T.jsx)(Oe,{word:"Checks running",tone:"live"}):e.state==="passed"?(0,T.jsx)(Oe,{word:"Checks passed",tone:"done"}):(0,T.jsx)(Oe,{word:"No current checks"});return(0,T.jsx)("section",{className:"k-sec","aria-label":"Ship","data-ship":e.state,children:(0,T.jsx)(c1,{label:`Pull request #${e.pr} · checks`,head:"Check",chip:t,rows:e.rows,foot:(0,T.jsxs)(T.Fragment,{children:[e.summary," on ",(0,T.jsx)("span",{className:"k-mono",children:e.head})," · read ",(0,T.jsx)("time",{dateTime:e.observedAt,title:ms(e.observedAt),children:cn(e.observedAt)})]})})})}function bY({release:e}){let t=e.state==="failed"?(0,T.jsx)(Oe,{word:"Failed",tone:"failed"}):e.state==="done"?(0,T.jsx)(Oe,{word:"Done",tone:"done"}):e.state==="waiting"?(0,T.jsx)(Oe,{word:"Needs you",tone:"needs"}):(0,T.jsx)(Oe,{word:"Running",tone:"live"});return(0,T.jsxs)("section",{className:"k-sec","aria-label":"Release","data-release":e.state,children:[(0,T.jsx)("h3",{children:e.headline}),e.stopped!==null&&(0,T.jsxs)(ln,{children:[e.stopped.step,": ",e.stopped.message," Run the same release command again to continue from there."]}),(0,T.jsx)(c1,{label:`Release ${e.version}`,chip:t,rows:e.rows,foot:(0,T.jsxs)(T.Fragment,{children:["Tag ",(0,T.jsx)("span",{className:"k-mono",children:e.tag}),e.pr!==null&&(0,T.jsxs)(T.Fragment,{children:[" · pull request #",e.pr]})," · started ",(0,T.jsx)("time",{dateTime:e.startedAt,title:ms(e.startedAt),children:cn(e.startedAt)})]})})]})}function kY({ready:e,retry:t}){let a={yes:"✓",no:"✗",waiting:"…",unknown:"?",note:"–"},n=e.answer==="yes"||e.answer==="merged"?(0,T.jsx)(Oe,{word:e.answer==="merged"?"Merged":"Ready",tone:"done"}):(0,T.jsx)(Oe,{word:"Not yet"});return(0,T.jsxs)("section",{className:"k-sec so-merge-ready","aria-label":"Can I merge?","data-merge-ready":e.answer,children:[(0,T.jsxs)("div",{className:"so-merge-head",children:[n,(0,T.jsx)("h3",{children:"Can I merge?"})]}),(0,T.jsx)("p",{className:"so-merge-say",children:e.sentence}),(0,T.jsx)("ul",{className:"so-merge-rows",children:e.rows.map(o=>(0,T.jsxs)("li",{"data-merge-row":o.key,"data-mark":o.mark,children:[(0,T.jsx)("span",{className:"so-merge-mark","aria-hidden":"true",children:a[o.mark]??""}),(0,T.jsxs)("span",{children:[(0,T.jsx)("strong",{children:o.label})," ",(0,T.jsx)("span",{className:"meta",children:o.say})]}),o.act?.kind==="run-checks"&&(0,T.jsxs)(Fe,{action:o.act.action,className:"inline","data-merge-act":"run-checks",children:[(0,T.jsx)("input",{type:"hidden",name:"level",value:o.act.level}),(0,T.jsx)("input",{type:"hidden",name:"return",value:o.act.returnTo}),(0,T.jsx)(de,{type:"submit",sm:!0,label:"Run checks"})]}),o.act?.kind==="retry"&&t!=null&&(0,T.jsxs)(Fe,{action:t.action,className:"inline","data-merge-act":"retry",children:[(0,T.jsx)(Am,{pins:t.pins}),(0,T.jsx)(de,{type:"submit",sm:!0,label:"Retry"})]}),o.act?.kind==="fix"&&(0,T.jsx)(un,{summary:"Ask the agent to fix",children:(0,T.jsxs)(Fe,{action:o.act.action,className:"k-field","data-merge-act":"fix",children:[(0,T.jsx)("input",{type:"hidden",name:"intent",value:"revise"}),(0,T.jsx)("input",{type:"hidden",name:"batch",value:o.act.batch}),(0,T.jsx)("input",{type:"hidden",name:"source",value:o.act.source}),(0,T.jsx)("input",{type:"hidden",name:"request",value:o.act.request}),(0,T.jsx)("input",{type:"hidden",name:"return",value:o.act.returnTo}),o.act.note.trim()!==""&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("input",{type:"hidden",name:"context",value:o.act.note}),(0,T.jsxs)("p",{className:"k-note","data-fix-context":"",children:["Sent with it: ",o.act.note]})]}),(0,T.jsx)(ld,{name:"note",rows:3,maxLength:G1.note,placeholder:"Your note (optional)","aria-label":"Your note for the agent"}),(0,T.jsx)("div",{className:"k-acts",children:(0,T.jsx)(de,{type:"submit",label:"Ask the agent to fix",title:"Sends it back with this note, as Send back does"})})]})})]},o.key))})]})}function Cz(e){let t=e.status.need?.key??null;switch(e.status.headline){case"Needs you":return t==="approval"?"Plan ready":t==="answer"||t==="questions"?"A question for you":t==="hold"?"On hold":t==="stop-unproven"||t==="vanished"?"The build stopped":t==="sign-in"?e.status.sentence.startsWith("No coding agent")?"Sign in":"Sign in again":t==="connect-builder"?"No builder":t==="start-builder"?"Builder offline":t==="rebuild"||t==="replan"?"The plan changed":t==="plan-again"?"Plan didn't pass":t==="planning-stopped"?"Planning stopped":t==="review-result"?"Ready":"Waiting on you";case"Ready":return"Ready";case"Failed":return"A requirement was missed";case"Complete":return"Complete";case"Queued":return e.attempts.some(a=>a.runId!==null)?"Retry scheduled":"Waiting to start";default:return e.status.headline}}function Mz(e){let t=yr(e.at,new Date,No());return e.automatic?`Approved automatically by ${e.rule??"a rule"} · ${t}`:`Approved by ${e.by} · ${t}${e.how===""?"":` · ${e.how}`}`}function Lz({view:e,card:t,csrf:a,approved:n,watch:o=null,checksElsewhere:r=!1,resultHere:s=!1,unsent:i=!0,resultAct:l=null,lead:u=!1,resultWarnings:c=null}){let f=t.status.headline==="Failed",d=e.recheckStopped??null,m=e.rebuild??null,h=e.retry??null,w=e.failure??null,x=e.progress?.stuck??null,v=f&&h!=null&&a!=="",y=e.stop!=null&&a!==""?e.pause??null:null,[g,b]=(0,lt.useState)(!1),k=y?.state==null||x!==null?null:y.state==="pausing"?"Pausing…":mz({until:y.until??null,limitMs:y.limitMs??null},P=>yr(P,new Date,No(),!0)),C=t.status.headline==="Needs you"||t.status.headline==="Ready",N=d!=null&&a!==""?(0,T.jsx)(yY,{form:d,label:t.action?.label??"Check again"}):m!=null&&a!==""?(0,T.jsxs)(Fe,{action:m.action,"data-rebuild":!0,children:[(0,T.jsx)(Am,{pins:m.pins}),(0,T.jsx)(de,{type:"submit",variant:"primary",label:t.action?.label??"Retry","data-primary-action":""})]}):v?(0,T.jsx)(oC,{action:h.action,note:h.note??w?.suggestion,pins:h.pins}):(0,T.jsxs)(T.Fragment,{children:[x?.action!=null?(0,T.jsx)(He,{label:x.action.label,href:x.action.href,"data-stuck-action":""}):t.action!==null&&!(s&&(t.action.openResult||/[?&]tab=result\b/.test(t.action.href)))&&(0,T.jsx)(He,{variant:C?"primary":"outline",className:C?"k-docked":void 0,label:t.action.label,href:t.action.href,"data-primary-action":"",...t.action.openResult?{"data-open-result":""}:{}}),y!==null&&y.state===null&&(0,T.jsx)(mY,{pause:y}),y!==null&&y.state==="paused"&&(0,T.jsx)(hY,{pause:y}),y!==null&&!g&&(0,T.jsx)(de,{label:y.state==="paused"?"Continue with a note":"Pause and steer",onClick:()=>b(!0),"data-pause-steer":""}),e.stop!=null&&a!==""&&(0,T.jsx)(pY,{stop:e.stop}),o!==null&&(0,T.jsx)(de,{label:"Watch the work",onClick:o,"data-watch-work":""}),s&&C&&l!==null&&(0,T.jsx)("span",{className:"contents","data-result-status-act":"",ref:l})]}),L=f&&w!=null&&!v?(0,T.jsxs)("span",{"data-failure-suggestion":!0,children:["What to change: ",w.suggestion]}):e.record!=null?(0,T.jsx)("a",{className:"k-link",href:e.record.href,"data-build-record":!0,children:e.record.label}):n!=null?Mz(n):"",A=Vy(t.status,[...t.reasons,...t.diagnostics.map(P=>`${P.label} · ${P.detail}`),...t.notices?.lines??[]]);return(0,T.jsxs)("div",{className:"k-sec","data-task-status":!0,"data-work-status":t.token,"data-headline":t.status.headline,"aria-label":"Task status",children:[(0,T.jsx)(To,{wait:C,status:(0,T.jsxs)(T.Fragment,{children:[u&&C?(0,T.jsx)(Oe,{word:"Needs you",tone:"needs"}):Cz(t)!==t.status.headline&&(0,T.jsx)(JS,{headline:t.status.headline}),(0,T.jsx)("h2",{children:Cz(t)})]}),text:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("span",{...f?{"data-failure-reason":""}:{},...e.progress!=null?{"data-build-progress":""}:{},...x!==null?{"data-build-stuck":x.step}:{},children:k!==null?(0,T.jsx)("span",{role:"status","data-live-pause":y.state,children:k}):(0,T.jsx)(Mm,{text:t.status.sentence})}),e.activity!=null&&(0,T.jsx)(km,{activity:e.activity}),f&&w!=null&&(0,T.jsx)(fY,{failure:w}),e.planning!=null&&(0,T.jsx)("span",{"data-plan-backoff":"",children:e.planning.line})]}),...u?{body:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(eC,{card:t,runChecks:e.runChecks??null,only:r?P=>P!=="checks":null}),s&&c!==null&&(0,T.jsx)("div",{"data-result-status-warnings":"",ref:c})]})}:{},acts:N,terms:L}),y!==null&&g&&(0,T.jsx)(gY,{pause:y,onCancel:()=>b(!1)},y.run),i&&(0,T.jsx)(Pz,{view:e,csrf:a}),!u&&(0,T.jsx)(eC,{card:t,runChecks:e.runChecks??null,only:r?P=>P!=="checks":null}),e.planning?.agentSaid!=null&&(0,T.jsx)(un,{summary:"What the agent said",children:(0,T.jsx)("pre",{className:"k-mono","data-plan-agent-said":"",children:e.planning.agentSaid.join(`
|
|
64
64
|
`)})}),A.length>0&&(0,T.jsx)(un,{summary:"More",children:A.map(P=>(0,T.jsx)(ba,{children:P},P))})]})}function eC({card:e,runChecks:t,only:a=null}){let n=a===null?e.status.details:e.status.details.filter(o=>a(o.key));return n.length===0?null:(0,T.jsx)(e1,{rows:n.map(o=>{let r=t!=null&&o.action?.href===t.action,s=o.href===null?o.text:(0,T.jsx)("a",{className:"k-link",href:o.href,children:o.text}),i=o.action===null?null:r?(0,T.jsxs)(Fe,{action:t.action,"data-run-checks":!0,className:"so-inline-form",children:[(0,T.jsx)("input",{type:"hidden",name:"level",value:t.level}),(0,T.jsx)("input",{type:"hidden",name:"return",value:t.returnTo}),(0,T.jsx)(de,{type:"submit",variant:"ghost",sm:!0,label:o.action.label,"data-detail-action":""})]}):o.action.href===null?(0,T.jsx)("span",{children:o.action.label}):(0,T.jsx)("a",{className:"k-link",href:o.action.href,"data-detail-action":!0,children:o.action.label});return[o.label,(0,T.jsxs)("span",{"data-status-detail":o.key,"data-mark":o.mark,children:[s,i!==null&&(0,T.jsxs)(T.Fragment,{children:[" · ",i]})]},o.key)]})})}function SY({summary:e,flatten:t,children:a}){return(0,T.jsxs)("details",{className:"k-disclose",...t?{onToggle:n=>{n.currentTarget.open&&n.currentTarget.querySelectorAll("details").forEach(o=>{o.open=!0})}}:{},children:[(0,T.jsx)("summary",{children:e}),a]})}function Dz({fact:e}){return(0,T.jsx)(T.Fragment,{children:e.parts.map((t,a)=>typeof t=="string"?(0,T.jsx)("span",{children:t},a):"at"in t?(0,T.jsx)("time",{dateTime:t.at,title:ms(t.at),className:"k-num",children:cn(t.at)},a):"seal"in t?(0,T.jsx)("code",{className:"k-mono",children:t.seal},a):(0,T.jsx)("a",{href:t.href,children:t.label},a))})}function cn(e,t=new Date){return Number.isNaN(new Date(e).getTime())?"":yr(e,t,No())}var ms=e=>nu(e,No());function CY({item:e}){return(0,T.jsxs)("li",{"data-thread-entry":e.key,"data-thread-kind":e.kind,className:"so-thread-entry",children:[(0,T.jsxs)("p",{className:"so-thread-line",children:[(0,T.jsx)("time",{className:"k-num",dateTime:e.at,title:ms(e.at),children:cn(e.at)}),(0,T.jsxs)("span",{children:[(0,T.jsx)("b",{children:e.title}),e.author!==""&&(0,T.jsxs)(T.Fragment,{children:[" ",(0,T.jsx)("span",{className:"k-muted",children:e.author})]})]})]}),e.text!==null&&e.text.trim()!==""&&(0,T.jsx)("p",{className:e.who==="person"?"so-thread-text so-thread-quote":"so-thread-text",children:e.text}),e.link!==null&&(0,T.jsx)("p",{className:"so-thread-text",children:(0,T.jsx)("a",{className:"k-link",href:e.link.href,children:e.link.label})}),e.html!==""&&(0,T.jsx)("div",{className:"so-thread-text",children:(0,T.jsx)(jt,{html:e.html,className:"so-thread-card"})}),e.more!==null&&(0,T.jsx)("div",{className:"so-thread-text",children:(0,T.jsx)(SY,{summary:e.more.summary,flatten:!0,children:(0,T.jsx)(jt,{html:e.more.html,className:"so-thread-card"})})})]})}function LY({items:e,chat:t,chatHref:a,footer:n=!0}){let o=[...e.map(r=>({key:`item-${r.key}`,at:r.at,node:(0,T.jsx)(CY,{item:r},`item-${r.key}`)})),...t?.entries??[]].sort((r,s)=>r.at===s.at?0:r.at<s.at?-1:1);return(0,T.jsxs)("section",{"aria-label":"Activity","data-task-thread":!0,...t===null?{}:{"data-workspace-chat":""},className:"k-sec",children:[o.length===0&&(0,T.jsx)(Ia,{title:"Nothing has happened yet."}),(0,T.jsx)("ol",{className:"so-thread",children:o.map(r=>r.node)}),n&&(t!==null?t.footer:a!==null&&(0,T.jsxs)(ba,{children:[(0,T.jsx)("a",{className:"k-link",href:a,children:"Message the agent"})," from Chat."]}))]})}function NY(e){if(!e||e.length===0)return[];let t=u=>e.find(c=>c.title===u)?.facts??[],a=(u,c)=>t(u).find(f=>f.label===c),n=[],o=a("Work","Agent");o!==void 0&&n.push({label:"Agent",fact:o});let r=a("Work","Base");r!==void 0&&n.push({label:"Base",fact:r});let s=a("Links","Pull request");s!==void 0&&n.push({label:"Pull request",fact:s});let i=a("Links","Blocked by");i!==void 0&&n.push({label:"Blocked by",fact:i});let l=a("About","Usage, this attempt")??a("About","Usage, all attempts");return l!==void 0&&n.push({label:"Usage",fact:l}),n}function rC({details:e,extra:t,className:a,dataAttr:n="data-task-vitals"}){let o=NY(e),r=t??[];return o.length===0&&r.length===0?null:(0,T.jsxs)("dl",{className:Je("so-task-vitals",a),...n==="data-task-vitals"?{"data-task-vitals":""}:{"data-work-vitals":""},children:[o.map(s=>(0,T.jsxs)("div",{className:"so-task-vital","data-vital":s.label.toLowerCase().replace(/\s+/g,"-"),children:[(0,T.jsx)("dt",{children:s.label}),(0,T.jsx)("dd",{children:(0,T.jsx)(Dz,{fact:s.fact})})]},s.label)),r.map(s=>(0,T.jsxs)("div",{className:"so-task-vital","data-vital":s.label.toLowerCase().replace(/\s+/g,"-"),children:[(0,T.jsx)("dt",{children:s.label}),(0,T.jsx)("dd",{children:s.value})]},s.label))]})}function Wy({view:e}){let t=(e.details??[]).filter(a=>a.facts.length>0);return(0,T.jsx)("div",{className:"k-sec","data-task-details":!0,children:t.map(a=>(0,T.jsxs)("section",{className:"k-sec","aria-label":a.title,"data-detail-group":a.title,children:[(0,T.jsx)("h3",{children:a.title}),(0,T.jsx)(e1,{rows:a.facts.map(n=>[n.label,(0,T.jsx)("span",{"data-detail-fact":n.label,children:(0,T.jsx)(Dz,{fact:n})},n.label)])})]},a.title))})}var Nz=["scope","waits-for","holds","steering","task-diagnostics"],Iz=e=>{let t=Nz.indexOf(e);return t===-1?Nz.length:t};function IY({section:e}){return(0,T.jsxs)("section",{id:e.id,"aria-labelledby":`plan-${e.id}`,className:"k-sec so-plan-sec","data-task-section":e.id,children:[(0,T.jsxs)("h3",{id:`plan-${e.id}`,children:[e.title,e.count!==null&&e.count>0&&(0,T.jsxs)(T.Fragment,{children:[" ",(0,T.jsx)(Lt,{n:e.count})]})]}),(0,T.jsx)(jt,{html:e.html,className:"so-task-fold"})]})}function TY({view:e,approval:t}){let a=[...e.sections,...e.manage].map((n,o)=>({one:n,index:o})).sort((n,o)=>Iz(n.one.id)-Iz(o.one.id)||n.index-o.index).map(({one:n})=>n);return a.length===0&&e.cancel===null&&!t?null:(0,T.jsxs)("section",{className:"k-sec so-task-more","aria-labelledby":"task-more","data-task-more-about":"",children:[(0,T.jsx)("h2",{id:"task-more",className:"so-task-more-h",children:"More about this task"}),t&&(0,T.jsx)(jt,{html:e.approval,className:"so-task-approval"},tC(e.approval)),a.map(n=>(0,T.jsx)(IY,{section:n},n.id)),e.cancel!==null&&(0,T.jsxs)("details",{id:"cancel-task",open:e.cancel.open,className:"k-disclose so-cancel","data-task-section":"cancel",children:[(0,T.jsx)("summary",{children:"Cancel task"}),(0,T.jsx)(jt,{html:e.cancel.html,className:"so-task-cancel"})]})]})}function _z({view:e,loaded:t,csrf:a,result:n}){let o=t??null,r=e.result??null,s=r!==null&&(o===null||r.selected.build!==o.selected.build||r.revision!==o.revision),i=f=>f.selected.panel?.status?.check??null,l=!s&&r!==null&&o!==null&&i(r)!==i(o),u=(s||l)&&(0,T.jsxs)("div",{role:"status",className:"k-acts","data-result-newer":!0,children:[(0,T.jsx)(Vs,{children:l?"Its checks changed since you opened this.":o===null?"A result is ready.":r.selected.build!==o.selected.build?"A newer result is ready.":"This result was updated."}),(0,T.jsx)(de,{sm:!0,label:"Reload",onClick:()=>window.location.reload()})]});if(o===null||n===void 0)return(0,T.jsx)("div",{className:"k-sec","data-task-result":"none",children:u||(0,T.jsx)(Ia,{title:"No result yet.",text:"It shows here once a build finishes."})});let c=o.attempts.find(f=>f.current)??null;return(0,T.jsxs)("div",{className:"k-sec","data-task-result":o.selected.build??"none",children:[u,o.attempts.length>1&&(0,T.jsxs)("div",{className:"k-acts","data-result-attempts":o.attempts.length,children:[(0,T.jsx)("span",{className:"k-muted",children:o.current?"Latest result":"An earlier attempt"}),(0,T.jsx)(Lr,{sm:!0,"aria-label":"Result of attempt",value:c?.href??"",onChange:f=>{f.target.value!==""&&window.location.assign(f.target.value)},items:[...c===null?[["","Pick an attempt"]]:[],...o.attempts.map(f=>[f.href,f.label])],"data-result-attempt-picker":""})]}),n(o.selected,a,o.current)]})}function Tz({view:e}){let t=e.status,a=t?.attempts??[],n=e.earlier?.attempts??[];return a.length<=1&&n.length===0?(0,T.jsx)(Ia,{title:"One attempt so far.",text:"Each new build or revision of this task shows here."}):(0,T.jsxs)("div",{className:"k-sec","data-attempts":!0,children:[a.length>1&&(0,T.jsx)("section",{"aria-label":"Versions","data-attempt-timeline":!0,children:a.map(o=>{let r=o.label.split(" · "),s=r.at(-1)??"",i=vO.find(l=>l===s);return(0,T.jsx)(xn,{href:o.href,chip:i===void 0?(0,T.jsx)(Oe,{word:s}):(0,T.jsx)(JS,{headline:i}),title:r.length>1?r.slice(0,-1).join(" · "):o.label,desc:o.detail??"",meta:o.runId===null?void 0:(0,T.jsxs)("span",{className:"k-num",children:["Build #",o.runId]})},o.taskId)})}),n.length>0&&(0,T.jsx)("section",{"aria-label":"Earlier builds","data-earlier-attempts":n.length,children:n.map(o=>(0,T.jsx)(xn,{href:o.href,chip:(0,T.jsx)(Oe,{word:"Stopped"}),title:o.label,desc:o.text??""},o.href))}),t?.lead!=null&&(0,T.jsxs)(ba,{children:["Lead: ",t.lead.label,t.lead.active?"":" · access ended"]})]})}function RY({items:e,show:t}){let a=(0,lt.useRef)(new Map),n=Ld();if(e.length===0)return null;let o={work:0,share:1,danger:2},r=e.map((i,l)=>({item:i,index:l})).sort((i,l)=>o[i.item.group]-o[l.item.group]||i.index-l.index),s=(i,l)=>{i.kind==="post"?a.current.get(l)?.requestSubmit():i.kind==="goto"?(i.tab==="activity"&&t({activity:!0}),Em(i.target,t,!0)):i.kind==="link"?window.location.assign(i.href):navigator.clipboard?.writeText(window.location.href).catch(()=>{})};return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(de,{variant:"ghost",sm:!0,iconOnly:"more",label:"More actions","aria-haspopup":"dialog","data-task-more":"",onClick:i=>n(i.currentTarget,"More actions",r.map(({item:l,index:u})=>({label:l.label,act:()=>s(l,u)})))}),e.map((i,l)=>i.kind!=="post"?null:(0,T.jsx)(Fe,{action:i.action,hidden:!0,ref:u=>{a.current.set(l,u)},"data-more-form":i.label,children:Object.entries(i.fields).map(([u,c])=>(0,T.jsx)("input",{type:"hidden",name:u,value:c},u))},l))]})}function tC(e){let t=/^\s*<details class="task-secondary-approval"/.test(e),a=/<input type="hidden" name="digest" value="([^"]*)"/.exec(e)?.[1]??"";return`${t?"folded":"open"}:${a}`}var Q1=e=>e==="result"?"ready":e==="attempts"?"build":null;function AY({steps:e}){if(e.length===0)return null;let t={pending:"not started",current:"in progress",completed:"done",blocked:"stuck"};return(0,T.jsx)("ol",{className:"so-build-steps","aria-label":"Plan steps","data-build-steps":"",children:e.map((a,n)=>(0,T.jsxs)("li",{"data-state":a.state,"aria-current":a.state==="current"?"step":void 0,children:[(0,T.jsx)("span",{className:"so-build-step-mark","aria-hidden":"true",children:a.state==="completed"?"":n+1}),(0,T.jsxs)("span",{children:[a.title,(0,T.jsxs)("span",{className:"k-sr",children:[", ",t[a.state]]})]})]},n))})}function Pz({view:e,csrf:t}){if(t===""||(e.steerRecent?.length??0)===0)return null;let a=new Set([e.steering?.steer?.run,e.pause?.run,e.work?.live?e.work.run:void 0]);return(0,T.jsx)(PB,{runs:e.steerRecent.filter(n=>!a.has(n)),action:`/t/${encodeURIComponent(e.id)}/steer`,back:"task"},e.steerRecent.join(","))}var aC=/<(?:form|input|button|select|textarea)\b/i,Oz="toolroll.task.work";function EY(){try{return window.localStorage.getItem(Oz)==="open"&&window.matchMedia("(min-width: 1100px)").matches}catch{return!1}}function MY(e){try{window.localStorage.setItem(Oz,e?"open":"closed")}catch{}}function DY({view:e,chat:t,csrf:a,open:n,onClose:o,onClick:r}){let s=e.work??null,i=hy(),l=y1(s?.transcript??null,s?.live===!0,i||!n),u=a!==""&&s?.live===!0?e.steering??null:null,c=s?.agent??"the agent",f=new Set(l.notes.map(v=>`steer-${v.id}`)),d=(e.thread??[]).filter(v=>!f.has(v.key)).map(v=>aC.test(v.html)||aC.test(v.more?.html??"")?{...v,html:"",more:null,link:v.link??{label:"Open it on the task page",href:`/t/${encodeURIComponent(e.id)}${v.kind==="result"?"?tab=result":""}`}}:v),m=s!==null&&(s.transcript===null||l.state==="off"||l.final&&l.items.length===0),h=u?.controls.pause!=null&&u.controls.pause.state===null?u.controls.pause:null,w=u!==null?(0,T.jsx)("div",{id:"steering",className:"so-work-box","data-task-steering":"",children:u.steer===null||u.controls.send===null?(0,T.jsx)("p",{className:"k-note","data-work-no-notes":"",children:u.controls.words}):(0,T.jsx)(Ly,{steer:u.steer,controls:{...u.controls,pause:h},back:"task",label:`Message ${c}`,note:u.controls.words},u.steer.run)}):(0,T.jsx)("div",{className:"so-work-box","data-work-lead":"",children:t!==null?t.footer:e.chatHref!=null&&(0,T.jsxs)(ba,{children:[(0,T.jsx)("a",{className:"k-link",href:e.chatHref,children:"Ask about it in Chat"}),"."]})}),x=s===null?"No build yet":`${s.agent} · ${s.live?"working":"finished"}`;return(0,T.jsxs)(gB,{id:"task-activity",title:"Activity",who:x,live:s?.live===!0,onClose:o,closeLabel:"Close activity",closeData:{"data-close-activity":""},onClick:r,hidden:!n,"data-task-panel":"activity","data-work-state":s===null?"none":i?"paused":m?"off":u===null?s.live?"watching":"ended":u.controls.send??"no-notes",foot:w,children:[s!==null&&(0,T.jsxs)("section",{"aria-label":"The agent's work",className:"so-work-records","data-work-run":s.run,children:[(0,T.jsx)(wm,{conversation:l,live:s.live,paused:i,older:v=>`${v} earlier ${v===1?"note is":"notes are"} in the task's history below.`}),m&&!i&&e.activity!=null&&(0,T.jsx)(km,{activity:e.activity})]}),(0,T.jsx)(LY,{items:d,chat:t,chatHref:null,footer:!1}),n&&(0,T.jsx)(Pz,{view:e,csrf:a})]})}function Bz({view:e,chat:t=null,csrf:a="",result:n}){let[o,r]=(0,lt.useState)(null),[s,i]=(0,lt.useState)(null),l=(0,lt.useRef)(e.result??null),u=l.current!==null,c=e.steps??null,f=(0,lt.useRef)(e.approve??null);f.current===null&&e.approve!=null&&(f.current=e.approve);let d=e.approve!=null?f.current:null,[m,h]=(0,lt.useState)(()=>{let le=new Set((c??[]).filter(Ue=>Ue.open).map(Ue=>Ue.key)),$e=Q1(e.tab);return $e!==null&&c?.some(Ue=>Ue.key===$e&&Ue.opens)&&le.add($e),d!==null&&le.add("approve"),le}),w=c?.find(le=>le.key==="ready")??null,x=c!==null&&d===null&&e.status!==null&&w!==null&&(w.state==="current"||w.state==="stuck"||c.every(le=>le.state==="done"||le.state==="skipped")),[v,y]=(0,lt.useState)(()=>{let le=Q1(e.tab);return le!==null&&le!=="ready"}),[g,b]=(0,lt.useState)(()=>e.tab==="activity"||EY()),k=le=>{b(le),MY(le)},[C,N]=(0,lt.useState)(null),L=(0,lt.useRef)(null),A=c?.find(le=>le.state==="current"||le.state==="stuck")?.key??null;(0,lt.useEffect)(()=>{A!==null&&h(le=>le.has(A)?le:new Set([...le,A]))},[A]);let P=le=>{try{let $e=new URL(window.location.href);le===null?$e.searchParams.delete("tab"):$e.searchParams.set("tab",le),le!==null&&$e.searchParams.delete("section"),Rm($e.pathname+$e.search+$e.hash)}catch{}},F=(0,lt.useRef)(g);F.current=g;let B=le=>{if("activity"in le){k(!0),P("activity");return}if("page"in le){if(!F.current||!nC())return;k(!1);try{new URL(window.location.href).searchParams.get("tab")==="activity"&&P(null)}catch{}return}le.row!=="ready"&&y(!0),h($e=>$e.has(le.row)?$e:new Set([...$e,le.row]))},H=le=>h($e=>{let Ue=new Set($e);return Ue.has(le)?Ue.delete(le):Ue.add(le),Ue}),S=(0,lt.useRef)(null),I=()=>{k(!1),P(null)},R=uY("task-activity",g,S,I),E=()=>{R()||(I(),document.activeElement?.closest("[data-task-panel]")&&S.current?.focus({preventScroll:!0}))},q=()=>B({activity:!0});cY(B),(0,lt.useEffect)(()=>{let le=()=>N(L.current??document.body);return window.addEventListener("so:show-details",le),()=>window.removeEventListener("so:show-details",le)},[]);let M=zB(e.live),_=e.approval!==""&&(e.approvalPlacement??"lead")==="lead"&&d===null,G=le=>requestAnimationFrame(()=>document.querySelector(le)?.scrollIntoView({block:"start",behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"})),re=le=>{if(le.defaultPrevented||le.button!==0||le.metaKey||le.ctrlKey||le.shiftKey||le.altKey)return;let $e=le.target.closest?.("a[href]");if(!($e instanceof HTMLAnchorElement))return;let Ue=new URL($e.href,window.location.href),Zt=new URL(window.location.href),Ra=Ue.searchParams.get("tab"),rr=$e.closest("[data-task-panel]")!==null;if(rr&&Ue.origin===Zt.origin&&Ue.pathname===Zt.pathname&&Ue.hash!==""&&Ue.search===Zt.search){if(!Em(decodeURIComponent(Ue.hash.slice(1)),B))return;le.preventDefault();try{let va=new URL(window.location.href);Rm(va.pathname+va.search+Ue.hash)}catch{}return}let Un=va=>{let Aa=new URLSearchParams(va.search);return Aa.delete("tab"),Aa.sort(),Aa.toString()};if(rr&&Ue.origin===Zt.origin&&Ue.pathname===Zt.pathname&&Ue.hash===""&&Ra===null&&Un(Ue)===Un(Zt)&&J1()){le.preventDefault();let va=document.querySelector('[data-step-row][aria-current="step"], [data-step-row]')??document.querySelector("[data-task-page] .k-doc");B({page:!0}),va!==null&&requestAnimationFrame(()=>{va.scrollIntoView({block:"start"}),jy(va)});return}if(Ue.origin!==Zt.origin||Ue.pathname!==Zt.pathname||Ra!=="result"&&Ra!=="plan"&&Ra!=="activity"&&Ra!=="attempts"||(Ue.searchParams.get("version")??"")!==(Zt.searchParams.get("version")??""))return;let za=Ue.searchParams.get("run");if(Ra==="result"&&za!==null&&String(e.result?.selected.build??"")!==za||Ue.searchParams.get("section")!==null&&Ue.searchParams.get("section")!==Zt.searchParams.get("section"))return;let Eo=Ra==="plan"?x?"plan":A:Q1(Ra);if(!(Ra!=="activity"&&c!==null&&(Eo===null||!c.some(va=>va.key===Eo&&va.opens)))){if(le.preventDefault(),Ra==="activity")q();else if(Eo!==null){let va=rr&&J1();rr&&B({page:!0});let Aa=x&&Eo==="ready"?"[data-task-outcome]":`[data-step-row="${Eo}"]`;B({row:Eo}),P(Ra==="plan"?null:Ra),G(Aa);let ws=va?document.querySelector(Aa):null;ws!==null&&requestAnimationFrame(()=>jy(ws))}Ue.hash!==""&&Em(decodeURIComponent(Ue.hash.slice(1)),B)}},oe=d===null?null:()=>{B({row:"approve"}),Em("plan-editor",B,!0)},$=Uy(),W=$?.tasks[e.id]?.terminalController?$y({...$.tasks[e.id],viewers:[]}):null,Q=(0,T.jsxs)(T.Fragment,{children:[e.project!==null&&(0,T.jsxs)(T.Fragment,{children:[e.project," · "]}),(0,T.jsx)("span",{className:"k-mono so-task-id",children:e.id}),e.scout&&(0,T.jsx)(T.Fragment,{children:" · research only"}),M.length>0&&(0,T.jsxs)(T.Fragment,{children:[" · ",(0,T.jsx)(BB,{people:M})]}),W!==null&&(0,T.jsxs)(T.Fragment,{children:[" · ",(0,T.jsx)("span",{"data-terminal-presence":"",role:"status",children:W})]})]}),ne=e.audit??null,V=e.status?.status.headline==="Needs you"||e.status?.status.headline==="Ready",z=d===null&&V&&e.status?.action!=null&&e.recheckStopped==null&&e.rebuild==null&&e.retry==null&&!(c!==null&&u&&(e.status.action.openResult||/[?&]tab=result\b/.test(e.status.action.href)))?(0,T.jsx)(He,{variant:"primary",label:e.status.action.label,href:e.status.action.href}):null,Y=c?.find(le=>le.state==="stuck")?.key??A,me=e.lead.some(le=>le.key==="plan-revisions"&&aC.test(le.html)),X={problem:d!==null?"approve":Y,"pull-request":"ready","needs-scope":"approve",control:"build",attempt:"build",questions:Y,"plan-revisions":me?Y:"build"},te=le=>c===null?[]:e.lead.filter($e=>X[$e.key]===le&&c.some(Ue=>Ue.key===le&&Ue.opens)),ge=e.lead.filter(le=>le.key==="landed"),be=e.lead.filter(le=>le.key!=="landed"&&(c===null||!c.some($e=>$e.key===X[le.key]&&$e.opens))),De=le=>le.map($e=>(0,T.jsx)(jt,{html:$e.html,className:`so-task-lead so-task-lead--${$e.key}`},$e.instance===void 0?$e.key:`${$e.key}:${$e.instance}`)),ee=A??c?.find(le=>le.open)?.key??null,Te=c?.some(le=>le.key==="ready"&&le.opens)??!1,je=c?.some(le=>le.key==="checks"&&le.opens)??!1,Ye=u||e.result!=null?(0,T.jsx)(_z,{view:e,loaded:l.current,csrf:a,result:n}):null,tt=le=>(0,T.jsxs)(T.Fragment,{children:[e.release!=null&&(0,T.jsx)(bY,{release:e.release}),le&&e.mergeReady!=null&&!e.scout&&(0,T.jsx)(kY,{ready:e.mergeReady,retry:e.retry??null}),e.ship!=null&&(0,T.jsx)(xY,{ship:e.ship})]}),Xe=(le,$e=!1)=>d!==null?null:e.status!==null?(0,T.jsx)(Lz,{view:e,card:e.status,csrf:a,approved:le===null?e.approved??null:null,watch:le==="build"&&e.stop!=null?q:null,unsent:!g,checksElsewhere:!$e&&je&&le!=="checks",resultHere:le==="ready"&&Ye!==null,resultAct:r,lead:$e,resultWarnings:$e?i:null}):(0,T.jsx)(jt,{html:e.statusHtml}),Oa=le=>{if(x&&le.key==="ready")return null;let $e=le.key===ee&&!x,Ue=$e?Xe(le.key):null;switch(le.key){case"plan":return(0,T.jsxs)(T.Fragment,{children:[Ue,De(te("plan")),e.plan!=null&&e.plan.html!==""&&(0,T.jsx)(jt,{html:e.plan.html,className:"so-task-plan"},e.plan.key)]});case"approve":return d!==null?(0,T.jsxs)("div",{className:"so-approval-step","data-approval-step":"",children:[De(te("approve").filter(Zt=>Zt.key==="problem")),(0,T.jsx)(Sz,{approve:d,latest:e.approve??null,onEdit:oe,reject:e.cancel!==null,inRow:!0,sheet:d.sheetHtml}),d.sheetHtml===void 0?(0,T.jsx)("div",{className:"so-approval-sheet",children:(0,T.jsx)(jt,{html:d.planHtml,className:"so-task-plan"})}):d.editorHtml!==void 0&&(0,T.jsx)(jt,{html:d.editorHtml,className:"so-task-plan so-approval-editor"}),c!==null&&!c.some(Zt=>Zt.key==="plan")&&(0,T.jsxs)(T.Fragment,{children:[De(te("plan")),e.plan!=null&&e.plan.html!==""&&(0,T.jsx)(jt,{html:e.plan.html,className:"so-task-plan so-approval-plan"},e.plan.key)]}),De(te("approve").filter(Zt=>Zt.key!=="problem"))]},`approve:${d.fields.digest??""}`):(0,T.jsxs)(T.Fragment,{children:[Ue,le.state==="done"&&e.approved!=null&&(0,T.jsx)(Vs,{children:Mz(e.approved)}),e.approval!==""&&(0,T.jsx)(jt,{html:e.approval,className:"so-task-approval"},tC(e.approval)),De(te("approve"))]});case"build":return(0,T.jsxs)(T.Fragment,{children:[Ue,le.state==="current"&&e.progress?.steps!=null&&(0,T.jsx)(AY,{steps:e.progress.steps}),De(te("build")),(le.state==="done"||(e.status?.attempts.length??0)>1||(e.earlier?.attempts.length??0)>0)&&(0,T.jsx)(Tz,{view:e})]});case"checks":return(0,T.jsxs)(T.Fragment,{children:[Ue,!$e&&e.status!==null&&(0,T.jsx)(eC,{card:e.status,runChecks:e.runChecks??null,only:Zt=>Zt==="checks"}),De(te("checks"))]});case"ready":return(0,T.jsxs)(T.Fragment,{children:[Ue,tt(Ye!==null),Ye,De(te("ready"))]})}},Dt=(c??[]).map(le=>{let $e=le.state==="current"||le.state==="stuck";return{key:le.key,label:le.label,mark:le.mark,sentence:le.sentence,needsYou:le.needsYou,current:$e,at:le.at,when:le.at===null?"":cn(le.at),body:le.opens||$e?Oa(le):void 0,toggle:le.opens&&!$e&&!(le.key==="approve"&&d!==null),open:$e||m.has(le.key)||le.key==="approve"&&d!==null}});if(e.historical!=null)return(0,T.jsx)(_Y,{view:e,loaded:l.current,csrf:a,result:n});let Ba=e.earlier?.attempts.map(le=>/^\/r\/(\d+)\b/.exec(le.href)?.[1]).find(Boolean),pn=e.result?.selected.build??e.status?.attempts.find(le=>le.runId!==null)?.runId??(Ba?Number(Ba):null),ga=((e.details??[]).flatMap(le=>le.facts).find(le=>le.label==="Agent"||le.label==="Builder")?.parts??[]).map(le=>typeof le=="string"?le:"label"in le?le.label:"").join(" ").toLowerCase(),or=ga.includes("antigravity")||ga.includes("gemini")?"antigravity":ga.includes("codex")?"codex":"claude",Ao=pn===null?null:`/term?task=${encodeURIComponent(e.id)}&run=${pn}&program=${or}`;return(0,T.jsx)(sC.Provider,{value:o,children:(0,T.jsx)(iC.Provider,{value:x?s:null,children:(0,T.jsxs)("div",{"data-kit-page":!0,"data-task-page":e.id,className:Je("so-task-page",g&&"so-task-page--work"),children:[(0,T.jsxs)("div",{className:"k-doc",onClick:re,children:[(0,T.jsx)(dm,{back:["/","Work"],title:e.title,meta:Q,right:(0,T.jsxs)("nav",{className:"k-acts so-task-tools","aria-label":"Task tools",children:[ne!==null&&(0,T.jsx)(He,{variant:"ghost",sm:!0,className:"k-desk-only",label:ne.label,href:ne.href}),Ao!==null&&(0,T.jsx)(He,{variant:"ghost",sm:!0,className:"k-desk-only",label:"Terminal",href:Ao,"data-open-terminal":""}),(0,T.jsx)(de,{ref:S,variant:"ghost",sm:!0,label:"Activity","aria-expanded":g,"aria-controls":"task-activity",onClick:()=>g?E():q(),"data-open-activity":""}),(0,T.jsx)(de,{ref:L,variant:"ghost",sm:!0,lead:"panel",label:"Details",className:"k-desk-only","aria-haspopup":"dialog",onClick:le=>N(le.currentTarget),"data-open-details":""}),(0,T.jsx)(de,{variant:"ghost",sm:!0,iconOnly:"panel",label:"Details",className:"k-phone-only","aria-haspopup":"dialog",onClick:le=>N(le.currentTarget)}),(0,T.jsx)(RY,{items:[...e.more??[],...e.everyTime?[{group:"share",label:"Do this every time…",kind:"link",href:e.everyTime.href}]:[]],show:B})]})}),(0,T.jsx)(rC,{details:e.details}),(0,T.jsx)(gz,{taskId:e.id,csrf:a,presence:$}),e.version!==null&&(0,T.jsxs)(Vs,{children:[e.version.label," · ",(0,T.jsx)("a",{className:"k-link",href:e.version.current.href,children:e.version.current.label})]}),e.archived!=null&&(0,T.jsx)(To,{status:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(Oe,{word:"Archived"}),(0,T.jsx)("h2",{children:"Put away"})]}),text:(0,T.jsxs)(T.Fragment,{children:[e.archived.words," · ",(0,T.jsx)("time",{dateTime:e.archived.at,title:nu(e.archived.at,No()),children:yr(e.archived.at,new Date,No())})]}),acts:e.archived.restore!==null?(0,T.jsxs)(Fe,{action:e.archived.restore.action,children:[(0,T.jsx)("input",{type:"hidden",name:"return",value:e.archived.restore.returnTo}),(0,T.jsx)(de,{type:"submit",variant:"primary",label:"Restore","data-restore":""})]}):null,terms:e.archived.restore!==null?"Restoring puts it back in Work. Its history and results were kept.":"An approver can restore it."}),ge.length>0&&(0,T.jsx)("div",{className:"k-sec so-task-landed","data-task-landed":"",children:De(ge)}),x&&(0,T.jsxs)("div",{className:"k-sec so-task-outcome","data-task-outcome":"",children:[Xe("ready",!0),tt(Ye!==null),Ye,De(te("ready"))]}),c!==null?x?(0,T.jsx)("div",{className:"so-task-steps","data-task-steps":"folded",children:(0,T.jsx)(un,{summary:"Plan and steps",open:v,onToggle:y,children:(0,T.jsx)(d1,{label:"Steps",rows:Dt,onToggle:H})})}):(0,T.jsx)(d1,{label:"Steps",rows:Dt,onToggle:H}):(0,T.jsxs)(T.Fragment,{children:[d!==null&&(0,T.jsx)(Sz,{approve:d,latest:e.approve??null,onEdit:oe,reject:e.cancel!==null,sheet:d.sheetHtml}),d!==null&&(d.sheetHtml===void 0?(0,T.jsx)(jt,{html:d.planHtml,className:"so-task-plan"}):d.editorHtml!==void 0&&(0,T.jsx)(jt,{html:d.editorHtml,className:"so-task-plan so-approval-editor"})),d!==null?null:e.status!==null?(0,T.jsx)(Lz,{view:e,card:e.status,csrf:a,approved:e.approved??null,unsent:!g}):(0,T.jsx)(jt,{html:e.statusHtml}),_&&(0,T.jsx)(jt,{html:e.approval,className:"so-task-approval"},tC(e.approval)),tt(Ye!==null),Ye,e.plan!=null&&e.plan.html!==""&&(0,T.jsx)(jt,{html:e.plan.html,className:"so-task-plan"},e.plan.key)]}),c!==null&&ee===null&&!x&&Xe(null),c!==null&&!Te&&!x&&tt(!1),De(be),e.questions!==""&&(0,T.jsx)(jt,{html:e.questions,className:"so-task-questions"}),c===null&&(e.status?.attempts.length??0)+(e.earlier?.attempts.length??0)>1&&(0,T.jsx)(Tz,{view:e}),(0,T.jsx)(TY,{view:e,approval:e.approval!==""&&!_&&d===null&&!(c?.some(le=>le.key==="approve"&&(le.opens||le.state==="current"||le.state==="stuck"))??!1)})]}),(0,T.jsx)(DY,{view:e,chat:t,csrf:a,open:g,onClose:E,onClick:re}),C!==null&&(0,T.jsx)(Zo,{kind:"drawer",title:"Details",trigger:C,onClose:()=>N(null),children:(0,T.jsx)(Wy,{view:e})}),z!==null&&(0,T.jsx)(Qo,{children:z})]})})})}function _Y({view:e,loaded:t,csrf:a,result:n}){let o=e.historical,r=(0,T.jsxs)(T.Fragment,{children:[e.project!==null&&(0,T.jsxs)(T.Fragment,{children:[e.project," · "]}),(0,T.jsx)("span",{className:"k-mono",children:e.id})]});return(0,T.jsx)("div",{"data-kit-page":!0,"data-task-page":e.id,"data-task-historical":"",className:"so-task-page",children:(0,T.jsxs)("div",{className:"k-doc",children:[(0,T.jsx)(dm,{back:["/","Work"],title:e.title,meta:r}),(0,T.jsx)(To,{status:(0,T.jsx)("h2",{children:"Earlier result"}),text:o.label,acts:(0,T.jsx)(He,{variant:"primary",label:"Open current work",href:o.href,"data-open-current":""}),terms:""}),(0,T.jsx)(_z,{view:{...e,result:t??e.result??null},loaded:t??e.result??null,csrf:a,result:n===void 0?void 0:(s,i)=>n(s,i,!1)})]})})}var sC=(0,lt.createContext)(null),iC=(0,lt.createContext)(null);function Mm({text:e}){let t=e.split(/`([^`\n]+)`/);return(0,T.jsx)(T.Fragment,{children:t.map((a,n)=>n%2===1?(0,T.jsx)("code",{className:"k-mono",children:a},n):a===""?null:(0,T.jsx)("span",{children:a},n))})}var et=O(Z(),1);function PY(e){let t=cn(e);return t===""?"":/^\d/.test(t)?"Opened today":t.startsWith("Yesterday")?"Opened yesterday":`Opened ${t}`}function OY(e,t=44){let a=Array.from(e);if(t<8)return{head:e,tail:""};if(a.length<=t){let o=Math.min(a.length,Math.ceil(t*.6));return{head:a.slice(0,a.length-o).join(""),tail:a.slice(a.length-o).join("")}}let n=Math.ceil((t-1)*.6);return{head:`${a.slice(0,t-1-n).join("")}…`,tail:a.slice(a.length-n).join("")}}function BY({path:e,destination:t,label:a}){return(0,et.jsxs)(Fe,{action:"/projects/open",children:[(0,et.jsx)("input",{type:"hidden",name:"path",value:e}),(0,et.jsx)("input",{type:"hidden",name:"return",value:t}),(0,et.jsx)(de,{type:"submit",sm:!0,label:a})]})}function zz({row:e,returnTo:t,choosing:a}){let n=OY(e.shortPath,36),o=e.open?"Open now":e.openedAt===null?"":PY(e.openedAt),r=e.status===null?null:e.status==="needs"?(0,et.jsx)(Oe,{word:`${e.waiting} waiting on you`,tone:"ask"}):(0,et.jsx)(um,{status:e.status});return(0,et.jsx)(xn,{href:e.href,chip:r,title:e.name,wait:e.status==="needs",desc:(0,et.jsxs)("span",{className:"k-mono",title:e.path,children:[n.head,n.tail]}),meta:(0,et.jsxs)(et.Fragment,{children:[e.summary!==""&&(0,et.jsx)("span",{children:e.summary??"Not scanned"}),o!==""&&(0,et.jsx)("span",{children:o})]}),action:a||!e.open?(0,et.jsx)(BY,{path:e.path,destination:t,label:a?"Choose":"Open"}):(0,et.jsx)(He,{sm:!0,href:"/tasks/new",label:"New task"})})}function Hz({view:e}){let[t,a]=(0,ku.useState)(null),[n,o]=(0,ku.useState)(!1),r=(0,ku.useRef)(null),s=e.recent.length===0&&e.available.length===0,i=e.add.review===null,l=u=>{a(u.currentTarget),o(!0)};return(0,ku.useEffect)(()=>{e.add.openOnLoad&&(a(r.current?.querySelector("button")??null),o(!0))},[e.add.openOnLoad]),(0,et.jsxs)("div",{className:"w-full","data-kit-page":!0,children:[(0,et.jsx)(so,{title:e.choosing?"New task":"Projects",...e.choosing?{ctx:"Choose the project it belongs to"}:{},right:(0,et.jsx)("span",{ref:r,children:(0,et.jsx)(de,{variant:i?"primary":"outline",sm:!0,lead:"plus",label:"Add project",docked:i,"aria-haspopup":"dialog",onClick:l})}),...i?{}:{trailing:(0,et.jsx)(de,{variant:"ghost",iconOnly:"plus",label:"Add project","aria-haspopup":"dialog",onClick:l})}}),(e.problem!==null||e.said!==null)&&(0,et.jsxs)("div",{className:"px-6 pt-4 phone:px-4",children:[e.problem!==null&&(0,et.jsx)(ln,{children:e.problem}),e.said!==null&&(0,et.jsx)(Vs,{children:e.said})]}),e.add.review!==null&&(0,et.jsx)("div",{className:"k-doc",children:(0,et.jsx)(Ct,{html:e.add.review,immutable:!0})}),e.recent.length>0&&(0,et.jsxs)("section",{"aria-label":"Projects","data-project-list":"",children:[(0,et.jsx)(Io,{label:"Projects",count:(0,et.jsx)(Lt,{n:e.recent.length})}),e.recent.map(u=>(0,et.jsx)(zz,{row:u,returnTo:e.returnTo,choosing:e.choosing},u.path))]}),e.available.length>0&&(0,et.jsxs)("section",{"aria-label":"Available","data-project-list":"",children:[(0,et.jsx)(Io,{label:"Available",count:(0,et.jsx)(Lt,{n:e.available.length})}),e.available.map(u=>(0,et.jsx)(zz,{row:u,returnTo:e.returnTo,choosing:e.choosing},u.path))]}),s&&(0,et.jsx)(Ia,{title:"No projects yet.",text:"A project is a git repository your agents work in. Add one from GitHub or from a folder on this computer.",action:(0,et.jsx)(de,{sm:!0,label:"Add project",lead:"plus","aria-haspopup":"dialog",onClick:l})}),n&&(0,et.jsx)(Zo,{kind:"drawer",title:"Add project",trigger:t,onClose:()=>o(!1),children:(0,et.jsx)(Ct,{html:e.add.html,immutable:!0})}),i&&(0,et.jsx)(Qo,{children:(0,et.jsx)(de,{variant:"primary",lead:"plus",label:"Add project","aria-haspopup":"dialog",onClick:l})})]})}var Pd=O(ve(),1),dC=O(_o(),1);function Ky(e){switch(e){case"attention":return"attention";case"problem":return"danger";case"live":return"info";case"ready":case"done":return"success";default:return"neutral"}}var xt=O(Z(),1),Fz=3,Gy=2;function zY(e){return{always:[...e.notDone.map(t=>({tag:"Not done",text:t})),...e.risks.map(t=>({tag:"Risk",text:t}))],more:[...e.decisions.map(t=>({tag:"Decided",text:t})),...e.assumptions.map(t=>({tag:"Assumed",text:t}))]}}function HY(e){let t=e.decisions.length+e.assumptions.length>0,a=e.notDone.length+e.risks.length>0;return!t&&!a?"The agent didn't report decisions or risks.":a?null:"The agent didn't report risks."}function lC({line:e}){return(0,xt.jsxs)("li",{className:"so-report-line","data-agent-says":e.tag,children:[(0,xt.jsx)(Oe,{word:e.tag,dot:!1}),(0,xt.jsx)("span",{className:"so-report-text",children:e.text})]})}function qz({one:e}){return(0,xt.jsxs)("li",{className:"so-report-line","data-you-said":e.you?"you":"other",children:[(0,xt.jsx)("span",{className:"so-report-quote",children:(0,xt.jsxs)("bdi",{children:["“",e.note,"”"]})}),(0,xt.jsxs)("span",{className:"k-note",children:[e.you?"You":(0,xt.jsx)("bdi",{children:e.author})," · ",(0,xt.jsx)("time",{dateTime:e.at,title:ms(e.at),children:cn(e.at)})," · ",e.question!=null?"reply to the agent":e.kind==="sent-back"?"sent back":"note to the agent"]}),e.question!=null&&(0,xt.jsxs)("span",{className:"k-note","data-agent-question":"",children:["The agent asked: ",(0,xt.jsx)("bdi",{children:e.question})]})]})}function Yy({report:e,said:t}){if(e==null)return null;let a=t??[],{always:n,more:o}=zY(e),r=o.slice(0,Fz),s=o.slice(Fz),i=HY(e),l=n.length+o.length>0,u=a.every(c=>c.you);return(0,xt.jsxs)("section",{className:"k-sec so-report","aria-label":"Decisions, risks and notes","data-agent-report":l?"reported":"none",children:[l&&(0,xt.jsx)("h3",{children:"The agent says"}),l&&(0,xt.jsxs)("ul",{className:"so-report-lines",children:[n.map((c,f)=>(0,xt.jsx)(lC,{line:c},`a${f}`)),r.map((c,f)=>(0,xt.jsx)(lC,{line:c},`m${f}`))]}),s.length>0&&(0,xt.jsx)(un,{summary:`${s.length} more`,children:(0,xt.jsx)("ul",{className:"so-report-lines",children:s.map((c,f)=>(0,xt.jsx)(lC,{line:c},f))})}),i!==null&&(0,xt.jsx)(ba,{children:i}),a.length>0&&(0,xt.jsxs)(xt.Fragment,{children:[(0,xt.jsx)("h3",{children:u?"You said":"People said"}),(0,xt.jsx)("ul",{className:"so-report-lines","data-you-said-count":a.length,children:a.slice(0,Gy).map(c=>(0,xt.jsx)(qz,{one:c},`${c.kind}${c.at}${c.note}`))}),a.length>Gy&&(0,xt.jsx)(un,{summary:`${a.length-Gy} more`,children:(0,xt.jsx)("ul",{className:"so-report-lines",children:a.slice(Gy).map(c=>(0,xt.jsx)(qz,{one:c},`${c.kind}${c.at}${c.note}`))})})]})]})}var $z="standing-orders:review-draft:",Uz="standing-orders:result-scroll:",FY=864e5;function Vz(e,t={replaceAddress:a=>{Rm(a)},confirm:a=>window.confirm(a)}){if(e.aborted)return;let a=document.querySelector("[data-result-panel]"),n=a?.getAttribute("data-result-user")||"",o=a?.getAttribute("data-result-task")||"",r=a?.getAttribute("data-result-run")||"",s=a?.getAttribute("data-result-param")==="section"?"section":"tab",i=!0,l=X=>{try{let te=JSON.parse(sessionStorage.getItem(X)||"null");return typeof te=="object"&&te!==null?te:null}catch{return null}},u=(X,te)=>{try{te===null?sessionStorage.removeItem(X):sessionStorage.setItem(X,JSON.stringify(te))}catch{i=!1}};try{for(let X=sessionStorage.length-1;X>=0;X--){let te=sessionStorage.key(X);if(!te||!(te.startsWith($z)||te.startsWith(Uz)))continue;let ge=l(te),be=te.split(":")[2]||"";(ge===null||typeof ge.at!="number"||ge.at<Date.now()-FY||n&&be!==n)&&sessionStorage.removeItem(te)}}catch{i=!1}if(a===null)return;let c=new Set;if(e.addEventListener("abort",()=>{for(let X of c)clearTimeout(X);c.clear()},{once:!0}),n!==""&&o!==""){let X=()=>{u(`${Uz}${n}:${o}:return`,{at:Date.now()})};window.addEventListener("pagehide",X,{signal:e}),e.addEventListener("abort",X,{once:!0})}let f=X=>{let te=setTimeout(()=>{c.delete(te),e.aborted||X()},0);c.add(te)},d=(X,te)=>{let ge=X.target instanceof Element?X.target.closest(te):null;return ge!==null&&a.contains(ge)?ge:null},m=()=>typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,h=[...a.querySelectorAll("[data-result-tab]")],w=[...a.querySelectorAll("[data-result-view]")],x=X=>{let te=a.querySelector('#comment-form input[name="tab"]');te!==null&&(te.value=X);for(let ge of w)ge.hidden=ge.getAttribute("data-result-view")!==X;for(let ge of h){let be=ge.getAttribute("data-result-tab")===X;ge.setAttribute("aria-selected",be?"true":"false"),ge.tabIndex=be?0:-1}};for(let X of h)X.addEventListener("click",te=>{if(te.metaKey||te.ctrlKey||te.shiftKey||te.altKey||te.button!==0)return;te.preventDefault();let ge=X.getAttribute("data-result-tab")||"";x(ge);try{let be=new URL(window.location.href);be.searchParams.set(s,ge),be.hash="",t.replaceAddress(be.toString())}catch{}},{signal:e}),X.addEventListener("keydown",te=>{let ge=h.indexOf(X),be=te.key==="ArrowRight"?h[(ge+1)%h.length]:te.key==="ArrowLeft"?h[(ge-1+h.length)%h.length]:te.key==="Home"?h[0]:te.key==="End"?h[h.length-1]:void 0;be!==void 0&&(te.preventDefault(),be.focus(),be.click())},{signal:e});let v=document.querySelector("[data-open-evidence]"),y=a.querySelector('[data-result-tab="checks"]');v!==null&&y!==null&&v.addEventListener("click",X=>{X.preventDefault(),y.click(),a.scrollIntoView({behavior:"smooth",block:"start"})},{signal:e});let g=a.querySelector("[data-review-diff]");g!==null&&(g.setAttribute("data-mode","view"),g.addEventListener("click",X=>{let te=X.target instanceof Element?X.target.closest("button[data-diff-mode]"):null;if(te!==null){g.setAttribute("data-mode",te.getAttribute("data-diff-mode")==="annotate"?"annotate":"view");for(let ge of g.querySelectorAll("button[data-diff-mode]"))ge.setAttribute("aria-pressed",String(ge===te))}},{signal:e}));let b=a.querySelector("#comment-form"),k=b?.closest("details.result-request-open")??null,C=()=>{k!==null&&!k.open&&(k.open=!0)};if(k!==null&&window.location.hash==="#request-changes"&&C(),a.addEventListener("click",X=>{d(X,'a[href="#request-changes"]')!==null&&C()},{signal:e}),b===null)return;let N=b.querySelector("[name=note]"),L=b.querySelector("[name=path]"),A=b.querySelector("[name=line]"),P=b.querySelector("details.result-pin"),F=b.querySelector("[name=image]"),B=b.querySelector("[data-feedback-image]"),H=a.querySelector("#comment-note-limit"),S=b.querySelector("[name=request]"),I=b.querySelector("[name=context]"),R=b.querySelector("[data-request-context-line]"),E=X=>{I!==null&&(I.value=X,R!==null&&uC(R,X))},q=X=>{if(I===null||X.trim()==="")return;let te=I.value.split(`
|
|
65
65
|
`).filter(ge=>ge.trim()!=="");te.includes(X)||te.push(X),E(te.join(`
|
|
66
66
|
`))},M=()=>{if(F===null||B===null)return;B.hidden=!F.value;let X=B.querySelector("img"),te=B.querySelector("figcaption");if(X===null||te===null)return;let ge=null,be=null;for(let De of a.querySelectorAll("[data-comment-image]"))De.getAttribute("data-comment-image")===F.value&&(ge=De);if(ge!==null)try{be=JSON.parse(F.value)}catch{ge=null}X.hidden=ge===null,ge!==null&&be!==null?(X.src=`/r/${String(be.run)}/evidence/${String(be.artifact)}`,X.alt=ge.getAttribute("data-image-caption")??"",te.textContent=`${X.alt} · Screenshot ${String(be.artifact)}`):(X.removeAttribute("src"),te.textContent="This screenshot is unavailable. Restore it or remove it from your feedback.")};a.addEventListener("click",X=>{let te=d(X,"[data-comment-image],[data-remove-image]");te===null||F===null||(X.preventDefault(),F.value=te.getAttribute("data-comment-image")||"",M(),C(),Y(),N!==null&&(N.dispatchEvent(new Event("input",{bubbles:!0})),N.scrollIntoView({block:"center",behavior:"instant"}),N.focus()))},{signal:e});let _=()=>{let X=N!==null&&N.value.trim()!==""||I!==null&&I.value.trim()!=="",te=b.querySelector("[name=batch]"),ge=b.querySelector("[data-request-changes]"),be=b.querySelector("[data-save-feedback]");ge!==null&&(ge.disabled=!X&&!(te!==null&&te.value!=="")),be!==null&&(be.disabled=!X)};if(_(),N?.addEventListener("input",_,{signal:e}),N!==null&&H!==null&&N.maxLength>0){let X=()=>{H.textContent=N.value.length===0?`up to ${N.maxLength} characters`:`${N.value.length} of ${N.maxLength} characters`};X(),N.addEventListener("input",X,{signal:e})}a.addEventListener("click",X=>{let te=d(X,"button.pick-file,button.pick-line");if(te===null)return;let ge=te.getAttribute("data-review-note");if(ge!==null){let be=te.getAttribute("data-path"),De=te.getAttribute("data-line");q(`${ge.replace(/\s+/g," ")}${be?` (${be}${De?`:${De}`:""})`:""}`)}L!==null&&(L.value=te.getAttribute("data-path")||""),A!==null&&(A.value=te.getAttribute("data-line")||""),P!==null&&(P.open=!0),C(),Y(),b.scrollIntoView({behavior:m()?"instant":"smooth",block:"center"}),N!==null&&(N.dispatchEvent(new Event("input",{bubbles:!0})),N.focus())},{signal:e});let G=`${$z}${n}:${o}:${r}`,re=null,oe=null;try{let X=new URL(window.location.href);re=X.searchParams.get("noted"),oe=X.searchParams.get("conflict")}catch{}let $=l(G),W=b.querySelector("[data-recorded-requests]");$!==null&&$.request!==oe&&W!==null&&W.value.split(",").includes(String($.request))&&(u(G,null),$=null),$!==null&&re&&$.request===re&&(u(G,null),$=null);let Q=()=>{let X=new Uint8Array(16);try{crypto.getRandomValues(X)}catch{for(let te=0;te<16;te++)X[te]=Math.floor(Math.random()*256)}return[...X].map(te=>te.toString(16).padStart(2,"0")).join("")},ne=()=>JSON.stringify([N?.value??"",L?.value??"",A?.value??"",F?.value??"",...I?.value?[I.value]:[]]),V=null,z=null;if($!==null&&oe&&$.request===oe&&($={...$,request:Q(),sent:null},u(G,$)),re&&N!==null&&!N.value){C();let X=()=>f(()=>N.focus({preventScroll:!0}));document.readyState==="complete"?X():window.addEventListener("load",X,{signal:e,once:!0})}$!==null&&typeof $.note=="string"&&$.note.length<=(N!==null?N.maxLength:4e3)&&(N!==null&&!N.value&&(N.value=$.note),$.note&&C(),L!==null&&!L.value&&typeof $.path=="string"&&(L.value=$.path),A!==null&&!A.value&&typeof $.line=="string"&&(A.value=$.line),P!==null&&(L!==null&&L.value||A!==null&&A.value)&&(P.open=!0),typeof $.request=="string"&&/^[a-f0-9]{32}$/.test($.request)&&S!==null&&(S.value=$.request),typeof $.sent=="string"&&(V=$.sent),F!==null&&typeof $.image=="string"&&$.image.length<250&&(F.value=$.image),I!==null&&!I.value&&typeof $.context=="string"&&$.context.length<=4e3&&E($.context),M(),z=JSON.stringify([$.note,$.path||"",$.line||"",$.image||"",...$.context?[$.context]:[]]),N?.dispatchEvent(new Event("input")));function Y(){let X=N?.value??"",te=L?.value??"",ge=A?.value??"",be=ne();(z!==null&&be!==z||V!==null&&be!==V)&&(V=null,S!==null&&(S.value=Q())),z=be;let De=I?.value??"";if(!X&&!te&&!ge&&!De&&!(F!==null&&F.value)){u(G,null);return}u(G,{note:X,path:te,line:ge,image:F?.value??"",context:De,request:S?.value??"",sent:V,at:Date.now()}),!i&&H!==null&&(H.textContent="Draft stays on this page only. Browser storage is unavailable.")}b.addEventListener("input",Y,{signal:e});let me=document.querySelector(".composer[data-chat-session]")!==null;b.addEventListener("submit",X=>{Y(),V=ne();let te=l(G);if(te!==null&&u(G,{...te,sent:V}),!me){if(b.getAttribute("aria-busy")==="true"){X.preventDefault();return}b.setAttribute("aria-busy","true")}},{signal:e}),window.addEventListener("pageshow",()=>b.removeAttribute("aria-busy"),{signal:e})}function uC(e,t){e.replaceChildren();let a=t.split(`
|