copilot-operator 0.1.40 → 0.1.42

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.
Files changed (58) hide show
  1. package/dist/src/api/operator.controller.js +28 -6
  2. package/dist/src/api/operator.service.js +82 -7
  3. package/dist/src/config/schema.js +7 -0
  4. package/dist/src/orchestrator/planMode.js +102 -0
  5. package/dist/src/orchestrator/review.js +8 -4
  6. package/dist/src/orchestrator/taskRunner.js +137 -2
  7. package/dist/src/plan/brief.js +12 -0
  8. package/dist/src/plan/importPlan.js +2 -0
  9. package/dist/src/plan/schema.js +10 -0
  10. package/dist/src/plan/systemGuide.js +193 -2
  11. package/dist/src/protocol/parser.js +26 -2
  12. package/dist/src/protocol/replySchema.js +28 -4
  13. package/dist/src/session/compose.js +62 -7
  14. package/dist/src/session/exports.js +1 -0
  15. package/dist/src/session/model.js +38 -0
  16. package/dist/src/session/store.js +30 -3
  17. package/dist/src/transport/copilotTransport.js +28 -10
  18. package/dist/src/transport/locators.js +7 -1
  19. package/dist/src/vcs/startChoice.js +80 -8
  20. package/dist/src/vcs/taskVcs.js +16 -7
  21. package/dist/web/404.html +2 -2
  22. package/dist/web/_next/static/chunks/{584-578be94a0786334b.js → 204-db82ca47ff211e21.js} +1 -1
  23. package/dist/web/_next/static/chunks/499-39b2c00bda3656f0.js +1 -0
  24. package/dist/web/_next/static/chunks/549-348b0a1404407e5a.js +1 -0
  25. package/dist/web/_next/static/chunks/867-7d86a692260006f1.js +1 -0
  26. package/dist/web/_next/static/chunks/app/defaults/page-a25c40436fc312db.js +1 -0
  27. package/dist/web/_next/static/chunks/app/history/page-47973539ceff81d6.js +1 -0
  28. package/dist/web/_next/static/chunks/app/layout-6ee612d25e78b246.js +1 -0
  29. package/dist/web/_next/static/chunks/app/sessions/view/page-872d8b9fe8eedbbf.js +1 -0
  30. package/dist/web/_next/static/css/{cea7913ba416dbb7.css → 0e55721108c300f2.css} +1 -1
  31. package/dist/web/appearance.html +2 -2
  32. package/dist/web/appearance.txt +13 -13
  33. package/dist/web/defaults.html +2 -2
  34. package/dist/web/defaults.txt +13 -13
  35. package/dist/web/history.html +2 -2
  36. package/dist/web/history.txt +13 -13
  37. package/dist/web/import.html +2 -2
  38. package/dist/web/import.txt +13 -13
  39. package/dist/web/index.html +2 -2
  40. package/dist/web/index.txt +13 -13
  41. package/dist/web/level1.html +2 -2
  42. package/dist/web/level1.txt +13 -13
  43. package/dist/web/presets.html +2 -2
  44. package/dist/web/presets.txt +13 -13
  45. package/dist/web/sessions/view.html +2 -2
  46. package/dist/web/sessions/view.txt +13 -13
  47. package/dist/web/system.html +2 -2
  48. package/dist/web/system.txt +13 -13
  49. package/package.json +159 -158
  50. package/dist/web/_next/static/chunks/499-28e118e33ce07935.js +0 -1
  51. package/dist/web/_next/static/chunks/549-f295c8429e83b25b.js +0 -1
  52. package/dist/web/_next/static/chunks/867-8dc5bbb092ca2c5c.js +0 -1
  53. package/dist/web/_next/static/chunks/app/defaults/page-879158e9e550eea7.js +0 -1
  54. package/dist/web/_next/static/chunks/app/history/page-9f69ccde726c9be2.js +0 -1
  55. package/dist/web/_next/static/chunks/app/layout-73f28bc065a46ed3.js +0 -1
  56. package/dist/web/_next/static/chunks/app/sessions/view/page-0485ee7f781156ec.js +0 -1
  57. /package/dist/web/_next/static/{Y9tuV5LV-O0XyCREkeGc5 → lDmqS7pWU_B_Ac5idPvdS}/_buildManifest.js +0 -0
  58. /package/dist/web/_next/static/{Y9tuV5LV-O0XyCREkeGc5 → lDmqS7pWU_B_Ac5idPvdS}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[499],{1035:(e,t,r)=>{r.d(t,{DialogHost:()=>d,Z:()=>o});var l=r(3365),n=r(1521),s=r(867),a=r(4969);let c=null,i=[];function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(r=>{var l;return l={kind:"confirm",message:e,...t,resolve:r},void(c?c(l):i.push(l))})}function d(e){var t,r;let{children:o}=e,{t:d}=(0,s.kj)(),[h,m]=(0,n.useState)([]),u=(0,n.useRef)(null),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(c=e=>m(t=>[...t,e]),i.length>0){let e=i.splice(0,i.length);m(t=>[...t,...e])}return()=>{c=null}},[]);let x=h[0],g=(0,n.useCallback)(e=>{x&&(x.resolve(e),m(e=>e.slice(1)))},[x]);return(0,a.V)(p,!!x,u),(0,n.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),g(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,g]),(0,l.jsxs)(l.Fragment,{children:[o,x&&(0,l.jsx)("div",{className:"modal-backdrop",onClick:()=>g(!1),role:"presentation",children:(0,l.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)("h2",{id:"modal-title",children:null!=(t=x.title)?t:d("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,l.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,l.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,l.jsx)("button",{type:"button",className:"quiet",onClick:()=>g(!1),children:d("dialog.cancel")}),(0,l.jsx)("button",{ref:u,type:"button",className:x.danger?"danger":"primary",onClick:()=>g(!0),children:null!=(r=x.okLabel)?r:d("dialog.ok")})]})]})})]})}},1701:(e,t,r)=>{r.d(t,{L:()=>u,StartDialogHost:()=>p});var l=r(3365),n=r(1521),s=r(5549),a=r(867),c=r(4969),i=r(3486),o=r(3069);let d=null,h=[],m=1;function u(e){return new Promise(t=>{let r={...e,id:m++,resolve:t};d?d(r):h.push(r)})}function p(){let[e,t]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(d=e=>t(t=>[...t,e]),h.length>0){let e=h.splice(0,h.length);t(t=>[...t,...e])}return()=>{d=null}},[]);let r=e[0];return r?(0,l.jsx)(g,{req:r,onDone:e=>{r.resolve(e),t(e=>e.slice(1))}},r.id):null}let x=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase();function g(e){var t,r,d,h,m,u;let{req:p,onDone:g}=e,{t:f}=(0,a.kj)(),j=(0,a.W3)(),v=(0,n.useId)(),b=(0,n.useRef)(null),y=(0,n.useRef)(null),[k,w]=(0,n.useState)(null),[N,F]=(0,n.useState)(""),[B,C]=(0,n.useState)({}),[S,D]=(0,n.useState)({}),[E,T]=(0,n.useState)({kind:"choose"}),[H,O]=(0,n.useState)(""),[W,I]=(0,n.useState)(""),[L,R]=(0,n.useState)({}),[A,q]=(0,n.useState)([]),[P,z]=(0,n.useState)(!1),U=(0,n.useRef)(new Set),V=(0,n.useRef)(void 0),K=e=>g({started:e,...V.current?{reply:V.current}:{}}),_="fetching"===E.kind||"starting"===E.kind||""!==W,X=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return s.FH.startOptions(p.sessionIds).then(t=>{w(t);let r={};for(let e of t.repos)r[x(e.repoDir)]=e;C(r);let l={};for(let e of t.sessions){if(!e.vcs||!e.repoDir||e.fixed&&!e.choice)continue;let t=function(e,t){var r,l,n,s,a,c,i;let o=null!=(a=null!=(s=null==t||null==(r=t.remotes.find(e=>"origin"===e.name))?void 0:r.name)?s:null==t||null==(l=t.remotes[0])?void 0:l.name)?a:"",d=null!=(i=null!=(c=null==t?void 0:t.current)?c:null==t||null==(n=t.local[0])?void 0:n.name)?i:"main";return e?"previous-session"===e.from?{from:"previous-session",local:d,remote:o,remoteBranch:d,onBranch:!1}:"local"===e.from?{from:"local",local:e.branch,remote:o,remoteBranch:e.branch,onBranch:!!e.onBranch}:{from:"remote",local:(null==t?void 0:t.local.some(t=>t.name===e.branch))?e.branch:d,remote:e.remote,remoteBranch:e.branch,onBranch:!!e.onBranch}:{from:"local",local:d,remote:o,remoteBranch:"main",onBranch:!1}}(e.choice,r[x(e.repoDir)]);l[e.id]=e.prepared||e.fixed?{...t,from:"keep"}:t}D(t=>e?{...l,...Object.fromEntries(Object.entries(t).filter(e=>{let[t]=e;return t in l}))}:l)}).catch(e=>F(e.message))};(0,n.useEffect)(()=>{X()},[p.sessionIds]),(0,c.V)(b,!0,y),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&!e.defaultPrevented&&(e.preventDefault(),_||K(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[_,K]);let J=e=>e?B[x(e)]:void 0,M=(e,t)=>D(r=>({...r,[e]:{...r[e],...t}})),G=e=>{e&&C(t=>({...t,[x(e.repoDir)]:e}))},Z=()=>{s.FH.runVcs(p.sessionIds).then(q).catch(()=>q([]))},$=()=>{U.current.clear(),T({kind:"choose"})},Q=async function(){var e;let t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O("");let l=(()=>{var e,t;let r={},l=new Map;for(let n of null!=(e=null==k?void 0:k.sessions)?e:[]){let e=S[n.id],s=J(n.repoDir);if(!e||!n.repoDir||!s||s.problem||"keep"===e.from)continue;let a=n.fixed?{rechoose:!0}:{};if("previous-session"===e.from)r[n.id]={from:"previous-session",...a};else if("current"===e.from){if(!s.current)return{problem:f("startdlg.needBranch",{name:n.name})};r[n.id]={from:"local",branch:s.current,...e.onBranch?{onBranch:!0}:{},...a}}else if("local"===e.from){if(!e.local||!s.local.some(t=>t.name===e.local))return{problem:f("startdlg.needBranch",{name:n.name})};r[n.id]={from:"local",branch:e.local,...e.onBranch?{onBranch:!0}:{},...a}}else{let c=e.remoteBranch.trim();if(!e.remote||!c)return{problem:f("startdlg.needBranch",{name:n.name})};r[n.id]={from:"remote",remote:e.remote,branch:c,...e.onBranch?{onBranch:!0}:{},...a};let i="".concat(x(n.repoDir),"|").concat(e.remote),o=null!=(t=l.get(i))?t:{key:i,dir:s.repoDir,remote:e.remote,branches:[]};o.branches.includes(c)||o.branches.push(c),l.set(i,o)}}return{starts:r,groups:[...l.values()].map(e=>({...e,key:"".concat(e.key,"|").concat([...e.branches].sort().join(","))}))}})();if("problem"in l)return void O(l.problem);if(!r.skipFetch)for(let e of l.groups){if(U.current.has(e.key))continue;T({kind:"fetching",what:e.branches.map(t=>"".concat(e.remote,"/").concat(t)).join(", ")});let t=await s.FH.startFetch(e.dir,e.remote,e.branches).catch(e=>({ok:!1,problem:e.message,missing:[]}));if(G(t.repo),!t.ok)return void T({kind:"fetchFailed",group:e,result:t})}T({kind:"starting"});try{t=await p.start(l.starts)}catch(e){t={started:!1,reason:e.message}}if(V.current=t,t.started)return void K(!0);T({kind:"failed",reply:t}),(null==(e=t.failure)?void 0:e.stage)==="preflight"&&Z()},Y=async(e,t)=>{I("".concat(x(e),"|").concat(t)),R(r=>({...r,[x(e)]:f("startdlg.fetching",{what:t})}));try{let r=await s.FH.startFetch(e,t);G(r.repo),R(l=>{var n,s,a,c;return{...l,[x(e)]:r.ok?"":"".concat(f("startdlg.fetchFailed",{what:t})," ").concat(null!=(c=null!=(a=r.problem)?a:null==(n=r.fetched)?void 0:n.detail)?c:"").concat((null==(s=r.fetched)?void 0:s.auth)?" ".concat(f("prep.fetchAuth")):"")}})}catch(t){R(r=>({...r,[x(e)]:t.message}))}finally{I("")}},ee=async e=>{try{await navigator.clipboard.writeText(e),z(!0),window.setTimeout(()=>z(!1),2500)}catch(e){O(f("plan.copyFailed"))}},et=Object.values(S).some(e=>"remote"===e.from),er=(null!=(h=null==k?void 0:k.sessions)?h:[]).filter(e=>e.vcs),el=1===er.length?(e=>{var t,r,l;let n=S[e.id],s=J(e.repoDir);if(!n||!s)return;let a=e=>e?" @ ".concat(e.slice(0,8)):"";return"keep"===n.from?e.fixed&&(null==(t=e.started)?void 0:t.branch)?"".concat(e.started.branch).concat(a(null!=(l=e.started.tipNow)?l:e.started.recorded)):void 0:"current"===n.from?s.current?"".concat(s.current).concat(a(s.head)):void 0:"local"===n.from?"".concat(n.local).concat(a(null==(r=s.local.find(e=>e.name===n.local))?void 0:r.commit)):"remote"===n.from&&n.remoteBranch.trim()?"".concat(n.remote,"/").concat(n.remoteBranch.trim()):void 0})(er[0]):void 0,en=el?f("unattended"===p.mode?"startdlg.goUnattendedOn":"startdlg.goStepOn",{where:el}):"unattended"===p.mode?f("startdlg.goUnattended"):f("startdlg.goStep");return(0,l.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>!_&&K(!1),children:(0,l.jsxs)("div",{ref:b,className:"modal wide start-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"".concat(v,"-title"),onClick:e=>e.stopPropagation(),style:{overflowWrap:"anywhere"},children:[(0,l.jsx)("h2",{id:"".concat(v,"-title"),children:f("startdlg.title")}),(0,l.jsxs)("p",{className:"small muted",style:{marginTop:0},children:[f("startdlg.intro")," ",k&&"choose"===E.kind&&(0,l.jsx)("button",{type:"button",className:"quiet",onClick:()=>void X(!0),disabled:_,children:f("startdlg.refresh")})]}),N&&(0,l.jsx)(o.X,{reason:N}),!k&&!N&&(0,l.jsx)("p",{className:"small",role:"status",children:f("startdlg.loading")}),k&&("choose"===E.kind||"fetching"===E.kind||"starting"===E.kind)&&k.sessions.map(e=>{var t,r,n,s,a,c,i,o,d,h,m,u;let p=J(e.repoDir),g=S[e.id],b="start-".concat(v,"-").concat(e.id),y=null!=(c=null==p||null==(t=p.remotes.find(e=>e.name===(null==g?void 0:g.remote)))?void 0:t.branches)?c:[];return(0,l.jsxs)("fieldset",{className:"option",style:{border:"1px solid var(--line)",borderRadius:"var(--radius)",padding:"8px 12px",margin:"10px 0"},children:[(0,l.jsx)("legend",{style:{padding:"0 4px"},children:(0,l.jsx)("strong",{children:e.name})}),e.repoDir&&(0,l.jsx)("p",{className:"muted small",style:{margin:"2px 0 6px"},children:f("startdlg.repoOn",{repo:e.repoDir,branch:null!=(i=null==p?void 0:p.current)?i:"HEAD"})}),e.vcs?p&&!p.problem&&g?e.fixed&&e.rechooseBlocked?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",children:f("startdlg.fixed",{start:e.fixed})}),(0,l.jsx)("p",{className:"muted small",children:f("startdlg.rechooseBlocked",{tasks:e.rechooseBlocked})})]}):(0,l.jsxs)(l.Fragment,{children:[e.fixed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",style:{margin:"2px 0"},children:f("startdlg.fixed",{start:e.fixed})}),(null==(r=e.started)?void 0:r.branch)&&(0,l.jsxs)("p",{className:"small",style:{margin:"2px 0"},children:[e.started.tipNow?f("startdlg.branchNow",{branch:e.started.branch,now:e.started.tipNow.slice(0,8),recorded:(null!=(d=e.started.recorded)?d:"").slice(0,8)}):f("startdlg.branchGone",{branch:e.started.branch,recorded:(null!=(h=e.started.recorded)?h:"").slice(0,8)}),e.started.remote?" ".concat(f("startdlg.branchRemote",{name:e.started.remote.name,commit:e.started.remote.commit.slice(0,8)})):""]}),p.current&&(null==(n=e.started)?void 0:n.branch)&&p.current!==e.started.branch&&"per-task"!==e.started.mode&&(0,l.jsx)("p",{className:"notice caution small",style:{margin:"4px 0"},children:f("startdlg.differs",{current:p.current,head:(null!=(m=p.head)?m:"").slice(0,8),branch:e.started.branch})}),(0,l.jsx)("div",{className:"option",children:(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:b,checked:"keep"===g.from,onChange:()=>M(e.id,{from:"keep"}),disabled:_}),(0,l.jsx)("span",{children:(null==(s=e.started)?void 0:s.branch)?f("startdlg.keepStarted",{branch:e.started.branch}):f("startdlg.keepStartedNoBranch")})]})}),p.current&&p.current!==(null==(a=e.started)?void 0:a.branch)&&(0,l.jsx)("div",{className:"option",children:(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:b,checked:"current"===g.from,onChange:()=>M(e.id,{from:"current"}),disabled:_}),(0,l.jsx)("span",{children:f("startdlg.useCurrent",{branch:p.current,commit:(null!=(u=p.head)?u:"").slice(0,8)})})]})})]}),e.prepared&&(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:b,checked:"keep"===g.from,onChange:()=>M(e.id,{from:"keep"}),disabled:_}),(0,l.jsx)("span",{children:f("startdlg.keep")})]}),(0,l.jsx)("p",{className:"why",children:f("startdlg.prepared",{start:e.prepared})})]}),(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:b,checked:"local"===g.from,onChange:()=>M(e.id,{from:"local"}),disabled:_}),(0,l.jsx)("span",{children:f("startdlg.local")})]}),(0,l.jsx)("div",{className:"row",style:{marginTop:4},children:(0,l.jsxs)("select",{"aria-label":f("startdlg.localBranch"),value:g.local,onChange:t=>M(e.id,{from:"local",local:t.target.value}),disabled:_,style:{width:"auto",minWidth:240,maxWidth:"100%"},children:[!p.local.some(e=>e.name===g.local)&&(0,l.jsx)("option",{value:g.local,children:g.local}),p.local.map(e=>(0,l.jsxs)("option",{value:e.name,children:[e.name," \xb7 ",e.commit.slice(0,8)]},e.name))]})}),(0,l.jsx)("p",{className:"why",children:f("startdlg.localWhy")})]}),(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:b,checked:"remote"===g.from,onChange:()=>M(e.id,{from:"remote"}),disabled:_||0===p.remotes.length}),(0,l.jsx)("span",{children:f("startdlg.remote")})]}),0===p.remotes.length?(0,l.jsx)("p",{className:"muted small",children:f("startdlg.noRemote")}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"row",style:{marginTop:4},children:[p.remotes.length>1&&(0,l.jsx)("select",{"aria-label":f("startdlg.remoteName"),value:g.remote,onChange:t=>M(e.id,{from:"remote",remote:t.target.value}),disabled:_,style:{width:"auto"},children:p.remotes.map(e=>(0,l.jsx)("option",{value:e.name,children:e.name},e.name))}),1===p.remotes.length&&(0,l.jsxs)("code",{children:[g.remote,"/"]}),(0,l.jsx)("input",{type:"text","aria-label":f("startdlg.remoteBranch"),list:"".concat(b,"-remote"),value:g.remoteBranch,onChange:t=>M(e.id,{from:"remote",remoteBranch:t.target.value}),onFocus:()=>"remote"!==g.from&&M(e.id,{from:"remote"}),disabled:_,style:{width:"auto",minWidth:240,flex:"1 1 240px"},placeholder:"main"}),(0,l.jsx)("datalist",{id:"".concat(b,"-remote"),children:y.map(e=>(0,l.jsx)("option",{value:e.name},e.name))}),(0,l.jsx)("button",{type:"button",onClick:()=>void Y(p.repoDir,g.remote),disabled:_||!g.remote,children:f("startdlg.refreshRemote")})]}),(0,l.jsx)("p",{className:"why",children:f("startdlg.remoteWhy")}),(0,l.jsx)("p",{className:"muted small",style:{margin:"2px 0"},children:p.lastFetched?f("startdlg.lastFetched",{when:j(p.lastFetched)}):y.length>0?f("startdlg.lastFetchedUnknown"):f("startdlg.neverFetched")}),L[x(p.repoDir)]&&(0,l.jsx)("p",{className:"small",role:"status",children:L[x(p.repoDir)]})]})]}),e.previousOffered&&(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:b,checked:"previous-session"===g.from,onChange:()=>M(e.id,{from:"previous-session"}),disabled:_}),(0,l.jsx)("span",{children:f("startdlg.previous")})]}),(0,l.jsx)("p",{className:"why",children:f("startdlg.previousWhy")})]}),(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"checkbox",checked:g.onBranch&&("local"===g.from||"remote"===g.from||"current"===g.from),onChange:t=>M(e.id,{onBranch:t.target.checked}),disabled:_||"local"!==g.from&&"remote"!==g.from&&"current"!==g.from}),(0,l.jsx)("span",{children:f("startdlg.onBranch")})]}),(0,l.jsx)("p",{className:"why",children:f("startdlg.onBranchWhy")})]}),e.fixed&&"keep"!==g.from&&(0,l.jsx)("p",{className:"notice caution small",children:f("startdlg.rechooseNote")})]}):e.fixed?(0,l.jsx)("p",{className:"small",children:f("startdlg.fixed",{start:e.fixed})}):(0,l.jsx)("p",{className:"err small",children:f("startdlg.repoProblem",{problem:null!=(o=null==p?void 0:p.problem)?o:""})}):(0,l.jsx)("p",{className:"small",children:f("startdlg.vcsOff")})]},e.id)}),"fetching"===E.kind&&(0,l.jsx)("p",{className:"notice small",role:"status",children:f("startdlg.fetching",{what:E.what})}),"starting"===E.kind&&(0,l.jsx)("p",{className:"notice small",role:"status",children:f("startdlg.starting")}),"fetchFailed"===E.kind&&(0,l.jsxs)("div",{className:"notice caution",role:"alert",children:[(0,l.jsxs)("p",{style:{marginTop:0},children:[(0,l.jsx)("strong",{children:f("startdlg.fetchFailed",{what:E.group.branches.map(e=>"".concat(E.group.remote,"/").concat(e)).join(", ")})})," ",(0,l.jsx)("code",{children:null!=(u=null!=(m=E.result.problem)?m:null==(t=E.result.fetched)?void 0:t.detail)?u:""})]}),E.result.missing.length>0&&(0,l.jsx)("p",{className:"small",children:f("startdlg.missing",{names:E.result.missing.join(", ")})}),(null==(r=E.result.fetched)?void 0:r.auth)&&(0,l.jsx)("p",{className:"small",children:f("prep.fetchAuth")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("button",{type:"button",className:"primary",onClick:()=>void Q(),children:f("startdlg.retryFetch")}),(()=>{var e,t;let r=J(E.group.dir),n=null!=(t=null==r||null==(e=r.remotes.find(e=>e.name===E.group.remote))?void 0:e.branches)?t:[];return E.group.branches.every(e=>n.some(t=>t.name===e))?(0,l.jsx)("button",{type:"button",onClick:()=>{U.current.add(E.group.key),Q()},children:f("startdlg.useFetched")}):null})(),(0,l.jsx)("button",{type:"button",className:"quiet",onClick:$,children:f("startdlg.back")})]}),(()=>{var e,t;let r=J(E.group.dir),n=null!=(t=null==r||null==(e=r.remotes.find(e=>e.name===E.group.remote))?void 0:e.branches)?t:[],s=E.group.branches.filter(e=>!n.some(t=>t.name===e));return s.length>0?(0,l.jsx)("p",{className:"muted small",children:f("startdlg.useFetchedNo",{what:s.map(e=>"".concat(E.group.remote,"/").concat(e)).join(", ")})}):E.result.lastFetched?(0,l.jsx)("p",{className:"muted small",children:f("prep.lastFetched",{when:j(E.result.lastFetched)})}):null})(),E.result.fetchCommand&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",style:{marginTop:8},children:f("prep.ownTerminal")}),(0,l.jsx)("pre",{className:"sync-cmd",children:E.result.fetchCommand}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("button",{type:"button",onClick:()=>{var e;ee(null!=(e=E.result.fetchCommand)?e:"")},children:f("prep.copyFetch")}),P&&(0,l.jsx)("span",{className:"badge done",children:f("prep.copied")})]})]})]}),"failed"===E.kind&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.X,{failure:E.reply.failure,reason:E.reply.reason}),(null==(d=E.reply.failure)?void 0:d.stage)==="preflight"&&A.some(e=>!e.ready)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",children:f("startdlg.vcsFix")}),(0,l.jsx)(i.w,{groups:A,sessionIds:p.sessionIds,onChange:()=>{Z(),X()}})]})]}),H&&(0,l.jsx)("p",{className:"err small",role:"alert",children:H}),"choose"===E.kind&&et&&(0,l.jsx)("p",{className:"why",children:f("prep.password")}),(0,l.jsxs)("div",{className:"row modal-actions",children:[(0,l.jsx)("button",{type:"button",className:"quiet",onClick:()=>K(!1),disabled:_,children:f("dialog.cancel")}),"failed"===E.kind?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{type:"button",onClick:$,children:f("startdlg.back")}),(0,l.jsx)("button",{type:"button",className:"primary",onClick:()=>void Q({skipFetch:!0}),children:f("startdlg.tryAgain")})]}):"fetchFailed"!==E.kind&&(0,l.jsx)("button",{ref:y,type:"button",className:"primary",onClick:()=>void Q(),disabled:_||!k,children:en})]})]})})}},3069:(e,t,r)=>{r.d(t,{StartFailureBanner:()=>h,X:()=>i});var l=r(3365),n=r(1521),s=r(5549),a=r(867),c=r(7527);function i(e){var t,r;let{failure:n,reason:c,onDismiss:i,intro:o,children:d}=e,{t:h}=(0,a.kj)(),m=(0,a.W3)(),u=null!=(r=null!=(t=null==n?void 0:n.message)?t:c)?r:"";return(0,l.jsxs)("div",{className:"notice caution start-failure",role:"alert",style:{overflowWrap:"anywhere"},children:[o&&(0,l.jsx)("p",{className:"small",style:{marginTop:0},children:o}),(0,l.jsx)("strong",{children:h("startfail.title")}),n&&(0,l.jsx)("p",{className:"small",style:{margin:"4px 0"},children:h("startfail.where",{stage:h("startfail.stage.".concat(n.stage))})}),(0,l.jsx)("pre",{className:"sync-cmd small",style:{margin:"6px 0"},children:u}),d,n&&(0,l.jsxs)("p",{className:"muted small",style:{margin:"4px 0"},children:[n.runId?h("startfail.when",{when:m(n.at),run:n.runId}):h("startfail.whenNoRun",{when:m(n.at)}),n.sessions.length>0?" \xb7 ".concat(n.sessions.map(e=>'"'.concat(e,'"')).join(", ")):""]}),(0,l.jsxs)("div",{className:"row",style:{marginTop:6},children:[n&&(0,l.jsx)("a",{className:"button-link",href:s.FH.startFailureUrl(n.id),download:!0,children:h("startfail.download")}),(0,l.jsx)("a",{className:n?"button-link":"button-link plain",href:s.FH.terminalUrl(),download:!0,children:h("startfail.terminal")}),i&&(0,l.jsx)("button",{type:"button",className:"quiet",onClick:i,children:h("startfail.dismiss")})]}),(0,l.jsx)("p",{className:"why",children:h("startfail.downloadWhy")})]})}let o="cop.startFailure.dismissed";function d(){try{var e;let t=JSON.parse(null!=(e=window.localStorage.getItem(o))?e:"[]");return Array.isArray(t)?t.filter(e=>"string"==typeof e):[]}catch(e){return[]}}function h(){let{t:e}=(0,a.kj)(),[t,r]=(0,n.useState)([]),[h,m]=(0,n.useState)([]);(0,c.z)(()=>s.FH.startFailures(!0).then(e=>{r(e),m(d())}).catch(()=>void 0),5e3);let u=t.find(e=>!h.includes(e.id));return u?(0,l.jsx)("div",{style:{marginBottom:12},children:(0,l.jsx)(i,{failure:u,intro:e("at-turn"===u.stage?"startfail.laterSession":"startfail.later"),onDismiss:()=>{let e=[...new Set([...d(),u.id])].slice(-50);try{window.localStorage.setItem(o,JSON.stringify(e))}catch(e){}m(e)}})}):null}},3486:(e,t,r)=>{r.d(t,{w:()=>i});var l=r(3365),n=r(1521),s=r(5549),a=r(867);let c={"review-inputs":"runvcs.review","snapshot-on-base":"runvcs.snapshotOnBase","snapshot-here":"runvcs.snapshotHere","use-current-branch":"runvcs.useCurrent","allow-snapshot":"runvcs.allowSnapshot"};function i(e){let{groups:t,sessionIds:r,onChange:s}=e,{t:c}=(0,a.kj)(),[i,d]=(0,n.useState)(""),h=t.filter(e=>!e.ready);return 0===h.length?i?(0,l.jsxs)("p",{className:"notice small",role:"status",children:[(0,l.jsx)("strong",{children:c("runvcs.ready")})," ",i]}):null:(0,l.jsxs)("section",{className:"notice caution","aria-labelledby":"runvcs-title",children:[(0,l.jsx)("h3",{id:"runvcs-title",style:{marginTop:0},children:c("runvcs.title")}),(0,l.jsx)("p",{className:"small",children:c("runvcs.why")}),h.map(e=>(0,l.jsx)(o,{group:e,sessionIds:r,onChange:s,onDone:d},e.repoDir))]})}function o(e){var t;let{group:r,sessionIds:i,onChange:o,onDone:d}=e,{t:h}=(0,a.kj)(),[m,u]=(0,n.useState)(!1),[p,x]=(0,n.useState)(!1),[g,f]=(0,n.useState)(!1),[j,v]=(0,n.useState)(""),[b,y]=(0,n.useState)({}),k=(e,t)=>{var r,l;return null!=(l=null!=(r=b[e])?r:t)?l:void 0},w=r.actions.find(e=>"snapshot-here"===e.id&&e.available),N=e=>(null!=e?e:"—").slice(0,8),F=async e=>{if("review-inputs"===e)return void u(e=>!e);f(!0),v("");try{var t,l,n;let a="snapshot-on-base"===e?Object.fromEntries(r.inputs.map(e=>[e.path,"include"])):Object.fromEntries(r.entries.filter(e=>k(e.path,e.choice)).map(e=>[e.path,k(e.path,e.choice)])),c=await s.FH.runVcsPrepare(i,r.repoDir,e,a);v(c.ok?null!=(t=c.result)?t:"":null!=(l=c.problem)?l:""),c.ok&&d("".concat(r.repoDir,": ").concat(null!=(n=c.result)?n:"")),o()}catch(e){v(e.message)}finally{f(!1)}};return(0,l.jsxs)("div",{className:"option",style:{overflowWrap:"anywhere"},children:[(0,l.jsx)("table",{className:"small",children:(0,l.jsxs)("tbody",{children:[(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:h("runvcs.repo")}),(0,l.jsx)("td",{children:(0,l.jsx)("code",{children:r.repoDir})})]}),(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:h("runvcs.current")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:null!=(t=r.branch)?t:"HEAD"})," @ ",(0,l.jsx)("code",{children:N(r.head)})]})]}),r.workBranch&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:h("runvcs.workBranch")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:r.workBranch.name})," @ ",(0,l.jsx)("code",{children:N(r.workBranch.head)})]})]}),r.baseBranch&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:h("runvcs.base")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:r.baseBranch})," @ ",(0,l.jsx)("code",{children:N(r.baseHead)})]})]}),(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:h("runvcs.sessions")}),(0,l.jsx)("td",{children:r.sessions.map(e=>"".concat(e.name," (").concat(h("runvcs.role.".concat(e.role)),")")).join(", ")})]}),r.inputPatterns.length>0&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:h("runvcs.patterns")}),(0,l.jsx)("td",{children:r.inputPatterns.map(e=>(0,l.jsx)("code",{style:{marginRight:6},children:e},e))})]})]})}),r.problem&&(0,l.jsxs)("p",{className:"small",children:[(0,l.jsx)("strong",{children:h("runvcs.problem")})," ",r.problem]}),r.inputs.length>0&&(0,l.jsx)("p",{className:"small",children:h("runvcs.inputsCount",{n:r.inputs.length})}),m&&r.inputs.length>0&&(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:r.inputs.map(e=>(0,l.jsxs)("li",{children:[(0,l.jsx)("code",{children:e.path})," — ",h("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,s.zi)(e.size)):"",0===e.allowed.length&&e.reason?(0,l.jsxs)("span",{className:"err",children:[" — ",e.reason]}):null]},e.path))}),r.unrelated.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",children:(0,l.jsx)("strong",{children:h("runvcs.unrelated",{n:r.unrelated.length})})}),(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:r.unrelated.slice(0,30).map(e=>(0,l.jsxs)("li",{children:[(0,l.jsx)("code",{children:e.path}),e.reason?" — ".concat(e.reason):""]},e.path))})]}),w&&r.entries.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",children:(0,l.jsx)("strong",{children:h("runvcs.choose",{n:r.entries.length})})}),(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:r.entries.map(e=>{var t;return(0,l.jsxs)("li",{style:{marginBottom:4},children:[(0,l.jsx)("code",{children:e.path})," ",(0,l.jsxs)("span",{className:"muted",children:["(",e.input?"".concat(h("vcs.snapshotInput"),", "):"",h("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,s.zi)(e.size)):"",")"]})," ",0===e.allowed.length?(0,l.jsx)("span",{className:"err",children:h("vcs.snapshotBlocked")}):(0,l.jsx)("select",{"aria-label":e.path,value:null!=(t=k(e.path,e.choice))?t:"",onChange:t=>y({...b,[e.path]:t.target.value}),disabled:g||e.allowed.length<2,children:e.allowed.map(e=>(0,l.jsx)("option",{value:e,children:h("include"===e?"vcs.snapshotInclude":"vcs.snapshotLeaveOut")},e))}),e.reason&&(0,l.jsx)("div",{className:"muted",children:e.reason})]},e.path)})})]}),p?(0,l.jsxs)("p",{className:"small muted",children:[h("runvcs.cancelled")," ",(0,l.jsx)("button",{className:"quiet",onClick:()=>x(!1),children:h("runvcs.showAgain")})]}):(0,l.jsxs)("div",{children:[r.actions.map(e=>{var t,n,s;return(0,l.jsxs)("div",{style:{marginTop:8},children:[(0,l.jsxs)("button",{className:e.recommended?"primary":void 0,onClick:()=>void F(e.id),disabled:g||!e.available,children:[h(c[e.id],{branch:null!=(t=r.baseBranch)?t:"",current:null!=(n=r.branch)?n:"HEAD"}),"review-inputs"===e.id&&m?" ✓":""]}),e.recommended&&(0,l.jsx)("span",{className:"badge done",style:{marginLeft:6},children:h("runvcs.recommended")}),(0,l.jsx)("p",{className:"why",children:e.available?e.result:"".concat(h("runvcs.notNow")," ").concat(null!=(s=e.why)?s:"")})]},e.id)}),(0,l.jsxs)("div",{style:{marginTop:8},children:[(0,l.jsx)("button",{className:"quiet",onClick:()=>x(!0),disabled:g,children:h("runvcs.cancel")}),(0,l.jsx)("p",{className:"why",children:h("runvcs.cancelWhy")})]})]}),j&&(0,l.jsx)("p",{className:"small",role:"status",children:j})]})}},4969:(e,t,r)=>{r.d(t,{V:()=>s});var l=r(1521);let n='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function s(e,t,r){(0,l.useEffect)(()=>{var l,s;if(!t)return;let a=document.activeElement instanceof HTMLElement?document.activeElement:null,c=e.current,i=null!=(s=null!=(l=null==r?void 0:r.current)?l:null==c?void 0:c.querySelector(n))?s:null;null==i||i.focus();let o=e=>{if("Tab"!==e.key||!c)return;let t=Array.from(c.querySelectorAll(n)).filter(e=>null!==e.offsetParent);if(0===t.length)return;let r=t[0],l=t[t.length-1],s=c.contains(document.activeElement);e.shiftKey&&(document.activeElement===r||!s)?(e.preventDefault(),l.focus()):e.shiftKey||document.activeElement!==l&&s||(e.preventDefault(),r.focus())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o),a&&document.contains(a)&&a.focus()}},[e,t,r])}},7527:(e,t,r)=>{r.d(t,{z:()=>n});var l=r(1521);function n(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2],n=(0,l.useRef)(e);n.current=e,(0,l.useEffect)(()=>{let e;if(!r)return;let l=!1,s=async()=>{try{await n.current()}catch(e){}finally{l||(e=setTimeout(()=>void s(),t))}};return s(),()=>{l=!0,e&&clearTimeout(e)}},[t,r])}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[549],{5549:(t,e,o)=>{o.d(e,{AV:()=>a,Dh:()=>m,FH:()=>p,FZ:()=>r,Zm:()=>u,aT:()=>s,c5:()=>f,dK:()=>l,nC:()=>n,rt:()=>d,ub:()=>i,zi:()=>y});let n="/api";function s(t,e){return"/sessions/view?id=".concat(encodeURIComponent(t)).concat(e?"#".concat(e):"")}let c="cop-api-token";function a(){try{let t=/(?:^#|&)token=([0-9a-f]{16,})/i.exec(window.location.hash);if(t)return window.localStorage.setItem(c,t[1]),window.history.replaceState(null,"",window.location.pathname+window.location.search),t[1];return window.localStorage.getItem(c)||""}catch(t){return""}}function i(t){let e=a();return e?"".concat(t).concat(t.includes("?")?"&":"?","token=").concat(encodeURIComponent(e)):t}let r=["exit-zero","exit-nonzero","output-contains","output-omits","output-matches","file-exists","file-missing","file-contains"];function d(t){return t.startsWith("exit-")||t.startsWith("output-")}function l(t){return"output-contains"===t||"output-omits"===t||"output-matches"===t||"file-contains"===t}function u(t){return"limit-reached"===t.status||"aborted"===t.status||!!t.limit&&("failed"===t.status||"blocked"===t.status)}function m(t){return("failed"===t.status||"blocked"===t.status)&&"contract-conflict"!==t.stopCode}async function h(t,e){let o,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=void 0===s.timeoutMs?3e4:s.timeoutMs;try{var i;o=await fetch("".concat(n).concat(t),{...e,...null!==c&&!(null==e?void 0:e.signal)?{signal:AbortSignal.timeout(c)}:{},headers:{"content-type":"application/json",...a()?{"x-cop-token":a()}:{},...null!=(i=null==e?void 0:e.headers)?i:{}}})}catch(e){if("TimeoutError"===e.name)throw Error("The API did not answer within ".concat(Math.round((null!=c?c:0)/1e3)," s (").concat(t.split("?")[0],"). It may be busy; try again."));throw e}if(!o.ok){let t="".concat(o.status," ").concat(o.statusText);try{let e=await o.json();(null==e?void 0:e.message)&&(t=Array.isArray(e.message)?e.message.join("; "):e.message)}catch(t){}throw Error(t)}let r=await o.text();return r?JSON.parse(r):void 0}let p={health:()=>h("/health"),doctor:()=>h("/doctor"),settings:()=>h("/settings"),saveSettings:t=>h("/settings",{method:"PUT",body:JSON.stringify(t)}),level1:()=>h("/level1"),setLevel1:t=>h("/level1",{method:"PUT",body:JSON.stringify({content:t})}),resetLevel1:()=>h("/level1",{method:"DELETE"}),presets:()=>h("/presets"),savePreset:(t,e)=>h("/presets/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:e})}),deletePreset:t=>h("/presets/".concat(encodeURIComponent(t)),{method:"DELETE"}),personas:()=>h("/personas"),savePersona:(t,e)=>h("/personas/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:e})}),deletePersona:t=>h("/personas/".concat(encodeURIComponent(t)),{method:"DELETE"}),sessions:()=>h("/sessions"),reorderSessions:t=>h("/sessions-order",{method:"PUT",body:JSON.stringify({ids:t})}),metrics:()=>h("/metrics"),preparePreview:function(t){let e=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return h("/repo/prepare/preview",{method:"POST",body:JSON.stringify({dir:t,fetch:e})},{timeoutMs:33e4})},prepareProject:function(t,e){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return h("/repo/prepare",{method:"POST",body:JSON.stringify({dir:t,fingerprint:e,...o})})},session:t=>h("/sessions/".concat(t)),createSession:(t,e)=>h("/sessions",{method:"POST",body:JSON.stringify({name:t,projectDir:e})}),updateSession:(t,e)=>h("/sessions/".concat(t),{method:"PUT",body:JSON.stringify(e)}),deleteSession:t=>h("/sessions/".concat(t),{method:"DELETE"}),addTask:(t,e)=>h("/sessions/".concat(t,"/tasks"),{method:"POST",body:JSON.stringify(e)}),updateTask:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e),{method:"PUT",body:JSON.stringify(o)}),deleteTask:(t,e)=>h("/sessions/".concat(t,"/tasks/").concat(e),{method:"DELETE"}),continueTask:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/continue"),{method:"POST",body:JSON.stringify((null==o?void 0:o.trim())?{instruction:o}:{})}),rerunTask:function(t,e){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return h("/sessions/".concat(t,"/tasks/").concat(e,"/rerun"),{method:"POST",body:JSON.stringify({...o,...n.buildOnFinished?{buildOnFinished:!0}:{}})})},taskChanges:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/changes").concat(o?"?run=".concat(encodeURIComponent(o)):"")),taskChangeFile:(t,e,o,n)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/changes/file?path=").concat(encodeURIComponent(o)).concat(n?"&run=".concat(encodeURIComponent(n)):"")),taskStory:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/story").concat(o?"?run=".concat(encodeURIComponent(o)):"")),taskFiles:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/files").concat(o?"?run=".concat(encodeURIComponent(o)):"")),taskLogUrl:(t,e,o)=>"".concat(n,"/sessions/").concat(t,"/tasks/").concat(e,"/log").concat(o?"?run=".concat(encodeURIComponent(o)):""),taskFileUrl:(t,e,o,s,c)=>"".concat(n,"/sessions/").concat(t,"/tasks/").concat(e,"/files/").concat(o,"/").concat(encodeURIComponent(s)).concat(c?"?run=".concat(encodeURIComponent(c)):""),saveTaskLog:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/log").concat(o?"?run=".concat(encodeURIComponent(o)):""),{method:"POST",body:"{}"}),saveTaskFile:(t,e,o,n,s)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/files/").concat(o,"/").concat(encodeURIComponent(n)).concat(s?"?run=".concat(encodeURIComponent(s)):""),{method:"POST",body:"{}"}),start:(t,e,o,n)=>h("/sessions/".concat(t,"/start"),{method:"POST",body:JSON.stringify({mode:e,name:o,starts:n})},{timeoutMs:12e4}),startOptions:t=>h("/start/options?sessions=".concat(encodeURIComponent(t.join(",")))),startFetch:(t,e,o)=>h("/start/fetch",{method:"POST",body:JSON.stringify({dir:t,remote:e,...o?{branches:o}:{}})},{timeoutMs:33e4}),startFailures:function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return h("/start/failures".concat(t?"?unanswered=1":""))},startFailureUrl:t=>i("".concat(n,"/start/failures/").concat(encodeURIComponent(t),"/report")),terminalUrl:()=>i("".concat(n,"/terminal")),stop:t=>h("/sessions/".concat(t,"/stop"),{method:"POST",body:"{}"}),approvals:t=>h("/approvals".concat(t?"?session=".concat(encodeURIComponent(t)):"")),decidePlan:(t,e,o)=>h("/approvals/".concat(t,"/plan"),{method:"POST",body:JSON.stringify({action:e,...(null==o?void 0:o.trim())?{note:o}:{}})}),decide:(t,e)=>h("/approvals/".concat(t),{method:"POST",body:JSON.stringify({action:e})}),setRunMode:(t,e)=>h("/sessions/".concat(t,"/mode"),{method:"POST",body:JSON.stringify({mode:e})}),streamUrl:t=>i("".concat(n,"/sessions/").concat(t,"/stream")),batch:()=>h("/batch").then(t=>null!=t?t:null),startBatch:(t,e,o,n,s,c,a,i)=>h("/batch/start",{method:"POST",body:JSON.stringify({sessionIds:t,mode:e,onFailure:o,model:n,reviewModel:s,name:c,taskIds:a,starts:i})},{timeoutMs:12e4}),suggestedRunName:t=>h("/batch/name?sessions=".concat(encodeURIComponent(t.join(",")))),stopBatch:()=>h("/batch/stop",{method:"POST",body:"{}"}),pauseBatch:()=>h("/batch/pause",{method:"POST",body:"{}"}),resumeBatch:()=>h("/batch/resume",{method:"POST",body:"{}"}),planBrief:t=>h("/plan/brief?lang=".concat(encodeURIComponent(t))),context:(t,e)=>h("/context/".concat(t,"?lang=").concat(encodeURIComponent(e))),setContext:(t,e)=>h("/context/".concat(t),{method:"PUT",body:JSON.stringify({content:e})}),resetContext:(t,e)=>h("/context/".concat(t,"?lang=").concat(encodeURIComponent(e)),{method:"DELETE"}),checkPlan:t=>h("/plan/check",{method:"POST",body:JSON.stringify({text:t})}),importPlan:t=>h("/plan/import",{method:"POST",body:JSON.stringify({text:t})}),browseFolder:t=>h("/browse-folder",{method:"POST",body:JSON.stringify({start:t})},{timeoutMs:null}),tasks:()=>h("/tasks"),activity:()=>h("/activity"),downloadBundle:async t=>{var e,o,s;let c=await fetch("".concat(n,"/export/bundle"),{method:"POST",headers:{"content-type":"application/json",...a()?{"x-cop-token":a()}:{}},body:JSON.stringify({tasks:t})});if(!c.ok)throw Error(await c.text()||"".concat(c.status," ").concat(c.statusText));let i=null!=(s=c.headers.get("content-disposition"))?s:"",r=null==(e=/filename\*=UTF-8''([^;]+)/i.exec(i))?void 0:e[1],d=null==(o=/filename="([^"]+)"/i.exec(i))?void 0:o[1],l=null!=d?d:"copilot-operator-bundle.json";if(r)try{l=decodeURIComponent(r)}catch(t){}let u=URL.createObjectURL(await c.blob()),m=document.createElement("a");return m.href=u,m.download=l,document.body.appendChild(m),m.click(),m.remove(),setTimeout(()=>URL.revokeObjectURL(u),1e4),l},exportUrl:(t,e)=>{let o=new URLSearchParams;return e.run&&o.set("run",e.run),e.session&&o.set("session",e.session),e.task&&o.set("task",e.task),i("".concat(n,"/export/").concat(t,"?").concat(o.toString()))},debugExportUrl:t=>i("".concat(n,"/debug/export").concat(t.length>0?"?sessions=".concat(encodeURIComponent(t.join(","))):"")),vcsStatus:t=>h("/sessions/".concat(t,"/vcs")),runVcs:t=>h("/batch/vcs?ids=".concat(encodeURIComponent(t.join(",")))),runVcsPrepare:function(t,e,o){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return h("/batch/vcs/prepare",{method:"POST",body:JSON.stringify({sessionIds:t,repoDir:e,action:o,choices:n})})},vcsSnapshot:(t,e)=>h("/sessions/".concat(t,"/vcs/snapshot"),{method:"POST",body:JSON.stringify({choices:e})}),restorePreview:(t,e)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/restore")),restore:(t,e)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/restore"),{method:"POST",body:"{}"}),contractCheck:(t,e)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/contract")),applyContractFix:(t,e,o,n)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/contract-fix"),{method:"POST",body:JSON.stringify({choices:o,expect:n})}),restartPlan:(t,e)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/restart")),restartFrom:function(t,e){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return h("/sessions/".concat(t,"/tasks/").concat(e,"/restart"),{method:"POST",body:JSON.stringify(o)})},repoCheck:t=>h("/repo?dir=".concat(encodeURIComponent(t))),project:()=>h("/project"),setProject:t=>h("/project",{method:"PUT",body:JSON.stringify(t)}),models:()=>h("/models"),setDefaultModel:t=>h("/models/default",{method:"PUT",body:JSON.stringify({model:t})}),setDefaultReviewModel:t=>h("/models/review-default",{method:"PUT",body:JSON.stringify({model:t})}),refreshModels:()=>h("/models/refresh",{method:"POST",body:"{}"},{timeoutMs:null}),login:t=>h("/login",{method:"POST",body:JSON.stringify({account:(null==t?void 0:t.trim())||void 0})},{timeoutMs:null})};function y(t){return t<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," KB"):"".concat((t/1048576).toFixed(1)," MB")}function f(t){if(void 0===t)return"";let e=Math.round(t/1e3);if(e<60)return"".concat(e,"s");let o=Math.floor(e/60);return o<60?"".concat(o,"m ").concat(e%60,"s"):"".concat(Math.floor(o/60),"h ").concat(o%60,"m")}}}]);