copilot-operator 0.1.48 → 0.1.50

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 (43) hide show
  1. package/dist/src/api/operator.controller.js +41 -0
  2. package/dist/src/api/operator.service.js +20 -0
  3. package/dist/src/plan/systemGuide.js +82 -10
  4. package/dist/src/session/workspaceGit.js +212 -0
  5. package/dist/src/transport/chatSession.js +28 -4
  6. package/dist/web/404.html +2 -2
  7. package/dist/web/_next/static/chunks/534-56c68930a1a3c10f.js +1 -0
  8. package/dist/web/_next/static/chunks/549-c32dd718a1809d4d.js +1 -0
  9. package/dist/web/_next/static/chunks/867-0e5d0d5472bf185f.js +1 -0
  10. package/dist/web/_next/static/chunks/app/history/page-95bab4c1b1ff9339.js +1 -0
  11. package/dist/web/_next/static/chunks/app/layout-a1314921eeba8ad5.js +1 -0
  12. package/dist/web/_next/static/chunks/app/page-4d8f0851fe672925.js +1 -0
  13. package/dist/web/_next/static/chunks/app/sessions/view/{page-835d3533fdc63082.js → page-adb64f8ba3d8c06e.js} +1 -1
  14. package/dist/web/_next/static/css/{ddb518572ea43e30.css → 4335e4ce269ba1ea.css} +1 -1
  15. package/dist/web/appearance.html +2 -2
  16. package/dist/web/appearance.txt +10 -10
  17. package/dist/web/defaults.html +2 -2
  18. package/dist/web/defaults.txt +10 -10
  19. package/dist/web/history.html +2 -2
  20. package/dist/web/history.txt +10 -10
  21. package/dist/web/import.html +2 -2
  22. package/dist/web/import.txt +10 -10
  23. package/dist/web/index.html +2 -2
  24. package/dist/web/index.txt +10 -10
  25. package/dist/web/level1.html +2 -2
  26. package/dist/web/level1.txt +10 -10
  27. package/dist/web/presets.html +2 -2
  28. package/dist/web/presets.txt +10 -10
  29. package/dist/web/sessions/view.html +2 -2
  30. package/dist/web/sessions/view.txt +10 -10
  31. package/dist/web/sessions.html +2 -2
  32. package/dist/web/sessions.txt +10 -10
  33. package/dist/web/system.html +2 -2
  34. package/dist/web/system.txt +10 -10
  35. package/package.json +3 -2
  36. package/dist/web/_next/static/chunks/549-a4473e9519a97026.js +0 -1
  37. package/dist/web/_next/static/chunks/867-b159f25612da5cbc.js +0 -1
  38. package/dist/web/_next/static/chunks/897-5a34109533c3da50.js +0 -1
  39. package/dist/web/_next/static/chunks/app/history/page-0bb537407fed5944.js +0 -1
  40. package/dist/web/_next/static/chunks/app/layout-485ce9395cb17998.js +0 -1
  41. package/dist/web/_next/static/chunks/app/page-3caf0b02046754a1.js +0 -1
  42. /package/dist/web/_next/static/{nLLy7-v8M5YRGIMtuTvMJ → z74_FBfnnXW5IJCHTgTH2}/_buildManifest.js +0 -0
  43. /package/dist/web/_next/static/{nLLy7-v8M5YRGIMtuTvMJ → z74_FBfnnXW5IJCHTgTH2}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[534],{287:(e,t,s)=>{s.d(t,{y:()=>h,f:()=>u});var n=s(3365),l=s(1521),a=s(5549),i=s(867),r=s(7527),c=s(1035),d=s(1701),o=s(4811);function u(e){var t,s,u;let{target:f,intro:m,initial:p="one",focusFirst:x=!1,checkContract:g=!0,onClose:j}=e,{t:y}=(0,i.kj)(),k=(0,o.p)(),[v,N]=(0,l.useState)(null),[b,w]=(0,l.useState)(p),[S,C]=(0,l.useState)(!1),[q,I]=(0,l.useState)(""),[F,R]=(0,l.useState)(!1),E=(0,l.useRef)(null),L=(0,l.useRef)(null),T=(0,l.useRef)(null),M=(0,l.useId)(),H=()=>a.FH.session(f.sessionId).then(N).catch(e=>I(e.message));(0,l.useEffect)(()=>{H(),g&&a.FH.contractCheck(f.sessionId,f.taskId).then(e=>R(e.conflicts.length>0)).catch(()=>void 0)},[f.sessionId,f.taskId]),(0,r.z)(H,3e3,!!(null==v?void 0:v.running));let O=null!==v;if((0,l.useEffect)(()=>{var e,t,s;if(!O||(null==(t=E.current)||null==(e=t.scrollIntoView)||e.call(t,{block:"nearest"}),!x))return;let n=L.current;n&&!n.disabled?n.focus():null==(s=T.current)||s.focus()},[O,x]),!v)return(0,n.jsx)("div",{className:"notice calm",style:{marginTop:8},children:(0,n.jsx)("span",{className:"small",children:q||y("runq.loading")})});let D=function(e,t){let s=e.tasks.findIndex(e=>e.id===t),n=s>=0?e.tasks[s]:void 0,l=s>=0?e.tasks.slice(0,s):[],a=s>=0?e.tasks.slice(s+1):[],i="continue"!==e.onFailure,r=-1;return a.forEach((e,t)=>{"queued"===e.status&&(r=t)}),{task:n,followingQueued:a.filter(e=>"queued"===e.status),laterRan:a.filter(e=>"queued"!==e.status),earlierRan:l.filter(e=>"queued"!==e.status),chain:i,chainGap:i?l.find(e=>"done"!==e.status):void 0,chainGapLater:i&&r>0?a.slice(0,r).find(e=>"queued"!==e.status&&"done"!==e.status):void 0}}(v,f.taskId),W=(null==(t=D.task)?void 0:t.status)==="queued",G="following"===b?[D.task,...D.followingQueued]:D.task?[D.task]:[],Q=v.running?y("runq.sessionRunning"):!1===v.active?y("runq.sessionInactive"):"",P=async e=>{if("unattended"!==e||k||await (0,c.Z)(y("batch.unattendedConfirm",{n:1}))){C(!0),I(""),R(!1);try{var t,s;let n=await a.FH.suggestedRunName([f.sessionId]).then(e=>e.name).catch(()=>void 0),l=await (0,d.L)({sessionIds:[f.sessionId],mode:e,start:t=>a.FH.startBatch([f.sessionId],e,"stop",void 0,void 0,n,G.map(e=>e.id),t)});if(!l.started&&!l.reply)return;let i=null!=(t=l.reply)?t:{started:!0};if(!l.started){I(y("batch.notStarted",{reason:null!=(s=i.reason)?s:""}));let e=await a.FH.contractCheck(f.sessionId,f.taskId).catch(()=>({conflicts:[]}));R(e.conflicts.length>0);return}I(y("runq.started",{n:G.length})),j(!0)}catch(e){I(e.message)}finally{C(!1)}}},V=y("runq.title",{title:f.title});return(0,n.jsxs)("div",{ref:E,className:"notice calm",role:"group","aria-label":V,style:{marginTop:8},children:[m&&(0,n.jsx)("p",{className:"small",style:{marginTop:0},children:m}),(0,n.jsx)("strong",{children:V}),W?(0,n.jsxs)(n.Fragment,{children:[D.followingQueued.length>0&&(0,n.jsxs)("div",{className:"small",role:"radiogroup","aria-label":V,style:{marginTop:6},children:[(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"radio",name:"runq-".concat(M),checked:"one"===b,onChange:()=>w("one"),disabled:S}),y("runq.onlyThis")]}),(0,n.jsxs)("label",{className:"option-inline",title:y("runq.followingWhy"),children:[(0,n.jsx)("input",{type:"radio",name:"runq-".concat(M),checked:"following"===b,onChange:()=>w("following"),disabled:S}),y("runq.following",{n:D.followingQueued.length,session:v.name})]})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:y("runq.willRun")}),(0,n.jsx)("ol",{className:"small",style:{margin:"4px 0",paddingLeft:22},children:G.map(e=>(0,n.jsx)("li",{children:e.title},e.id))}),(0,n.jsxs)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:18},children:[D.chain&&G.length>1&&(0,n.jsx)("li",{children:y("runq.chainStops")}),D.earlierRan.length>0&&(0,n.jsx)("li",{children:y("runq.untouched",{n:D.earlierRan.length})}),D.laterRan.length>0&&(0,n.jsx)("li",{children:y("runq.laterRan",{list:D.laterRan.map(e=>'"'.concat(e.title,'"')).join(", ")})}),"one"===b&&D.followingQueued.length>0&&(0,n.jsx)("li",{children:y("runq.restWait",{n:D.followingQueued.length})})]}),D.chainGap&&(0,n.jsx)("div",{className:"notice caution small",style:{marginTop:6},children:y("runq.chainGap",{before:D.chainGap.title,status:y("status.".concat(D.chainGap.status))})}),"following"===b&&D.chainGapLater&&(0,n.jsx)("div",{className:"notice caution small",style:{marginTop:6},children:y("runq.chainGapLater",{between:D.chainGapLater.title,status:y("status.".concat(D.chainGapLater.status))})}),Q&&(0,n.jsx)("p",{className:"small",children:Q})]}):(0,n.jsx)("p",{className:"small",children:y("runq.notQueued",{status:y("status.".concat(null!=(u=null==(s=D.task)?void 0:s.status)?u:"queued"))})}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[W&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{ref:L,className:"primary",disabled:S||!!Q,onClick:()=>void P("confirm"),title:y("runq.goWhy"),children:y("runq.go")}),(0,n.jsx)("button",{disabled:S||!!Q,onClick:()=>void P("unattended"),title:y("runq.unattendedWhy"),children:y("runq.unattended")})]}),(0,n.jsx)("button",{ref:T,className:"quiet",disabled:S,onClick:()=>j(!1),children:m?y("runq.later"):y("dialog.cancel")}),q&&(0,n.jsx)("span",{className:"small",role:"status",children:q})]}),F&&(0,n.jsx)(h,{target:f,onApplied:(e,t)=>{H(),0===e&&(R(!1),I(t))}})]})}function h(e){let{target:t,onApplied:s}=e,{t:r}=(0,i.kj)(),[c,d]=(0,l.useState)(null),[o,u]=(0,l.useState)([]),[h,f]=(0,l.useState)(!1),[m,p]=(0,l.useState)(""),[x,g]=(0,l.useState)(null),[j,y]=(0,l.useState)(null),k=(0,l.useId)();(0,l.useEffect)(()=>{d(null),Promise.all([a.FH.contractCheck(t.sessionId,t.taskId),a.FH.session(t.sessionId)]).then(e=>{var s;let[n,l]=e,a=l.tasks.find(e=>e.id===t.taskId);d(n.conflicts),u(n.conflicts.map(e=>e.fixes.length>0?0:-1)),g(null!=(s=null==a?void 0:a.status)?s:null),y(a?{readOnly:a.readOnly,scope:a.scope,checks:a.checks}:null)}).catch(e=>p(e.message))},[t.sessionId,t.taskId]);let v=async()=>{if(c){f(!0),p("");try{let e=await a.FH.applyContractFix(t.sessionId,t.taskId,o,c.map(e=>e.text)),n=r("cfix.applied",{list:(j?function(e,t,s){var n,l,a,i;let r=[];!!t.readOnly!=!!s.readOnly&&r.push(e(s.readOnly?"cfix.chReadOnlyOn":"cfix.chReadOnlyOff"));let c=(null!=(n=t.scope)?n:[]).join(", "),d=(null!=(l=s.scope)?l:[]).join(", ");c!==d&&r.push(d?e("cfix.chScope",{paths:d}):e("cfix.chScopeRemoved"));let o=new Set((null!=(a=s.checks)?a:[]).map(e=>e.name));for(let s of null!=(i=t.checks)?i:[])o.has(s.name)||r.push(e("cfix.chDropped",{check:s.name}));return r.join("; ")}(r,j,e.task):e.applied.join("; "))||r("cfix.chNothing")});p(n+(e.remaining.length>0?" ".concat(r("cfix.remaining",{n:e.remaining.length})):"")),d(e.remaining),u(e.remaining.map(e=>e.fixes.length>0?0:-1)),g("queued"),y({readOnly:e.task.readOnly,scope:e.task.scope,checks:e.task.checks}),s(e.remaining.length,n)}catch(e){p(e.message)}finally{f(!1)}}},N=r("cfix.title",{title:t.title});return(0,n.jsxs)("div",{className:"notice caution",role:"group","aria-label":N,style:{marginTop:8},children:[(0,n.jsx)("strong",{children:N}),(0,n.jsx)("p",{className:"why",children:r("cfix.why")}),null===c?(0,n.jsx)("p",{className:"small",children:m||r("cfix.loading")}):0===c.length?(0,n.jsx)("p",{className:"small",role:"status",children:m||r("cfix.none")}):(0,n.jsxs)(n.Fragment,{children:[c.map((e,t)=>(0,n.jsxs)("fieldset",{className:"small",style:{margin:"8px 0",border:0,padding:0},children:[(0,n.jsx)("legend",{style:{fontWeight:600},children:e.text}),e.fixes.map((e,s)=>(0,n.jsxs)("label",{className:"option-inline",style:{display:"block"},children:[(0,n.jsx)("input",{type:"radio",name:"cfix-".concat(k,"-").concat(t),checked:o[t]===s,onChange:()=>u(e=>e.map((e,n)=>n===t?s:e)),disabled:h}),"add-to-scope"===e.kind?r("cfix.addToScope",{path:e.path}):"not-read-only"===e.kind?e.scope.length>0?r("cfix.notReadOnly",{paths:e.scope.join(", ")}):r("cfix.notReadOnlyAll"):"drop-scope"===e.kind?r("cfix.dropScope"):r("cfix.dropCheck",{check:e.check}),0===s&&(0,n.jsxs)("span",{className:"muted",children:[" ",r("cfix.minimal")]})]},s)),(0,n.jsxs)("label",{className:"option-inline",style:{display:"block"},children:[(0,n.jsx)("input",{type:"radio",name:"cfix-".concat(k,"-").concat(t),checked:-1===o[t],onChange:()=>u(e=>e.map((e,s)=>s===t?-1:e)),disabled:h}),e.fixes.length>0?r("cfix.leave"):r("cfix.noFix")]})]},t)),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:h||o.every(e=>-1===e),onClick:()=>void v(),children:"queued"===x?r("cfix.applyQueued"):r("cfix.apply")}),m&&(0,n.jsx)("span",{className:"small",role:"status",children:m})]})]})]})}},853:(e,t,s)=>{function n(e){if(null===e||""===e)return[];let t=e.split(/\r?\n/);return""===t[t.length-1]&&t.pop(),t}function l(e,t){let s=function(e,t){let s=0;for(;s<e.length&&s<t.length&&e[s]===t[s];)s+=1;let n=e.length,l=t.length;for(;n>s&&l>s&&e[n-1]===t[l-1];)n-=1,l-=1;let a=[];for(let e=0;e<s;e+=1)a.push({kind:"same",a:e,b:e});for(let i of function(e,t){let s=e.length,n=t.length;if(0===s)return t.map((e,t)=>({kind:"add",b:t}));if(0===n)return e.map((e,t)=>({kind:"del",a:t}));let l=s+n,a=l+1,i=new Int32Array(2*l+3),r=[];for(let c=0;c<=Math.min(l,2e3);c+=1){r.push(i.slice(a-c-1,a+c+2));for(let l=-c;l<=c;l+=2){let d=l===-c||l!==c&&i[a+l-1]<i[a+l+1]?i[a+l+1]:i[a+l-1]+1,o=d-l;for(;d<s&&o<n&&e[d]===t[o];)d+=1,o+=1;if(i[a+l]=d,d>=s&&o>=n)return function(e,t,s,n){let l=[],a=t.length,i=s.length;for(let t=n;t>0;t-=1){let s=e[t],n=e=>s[e+t+1],r=a-i,c=r===-t||r!==t&&n(r-1)<n(r+1)?r+1:r-1,d=n(c),o=d-c;for(;a>d&&i>o;)a-=1,i-=1,l.push({kind:"same",a:a,b:i});a===d?l.push({kind:"add",b:o}):l.push({kind:"del",a:d}),a=d,i=o}for(;a>0&&i>0;)a-=1,i-=1,l.push({kind:"same",a:a,b:i});return l.reverse()}(r,e,t,c)}}return[...e.map((e,t)=>({kind:"del",a:t})),...t.map((e,t)=>({kind:"add",b:t}))]}(e.slice(s,n),t.slice(s,l)))a.push({kind:i.kind,...void 0!==i.a?{a:i.a+s}:{},...void 0!==i.b?{b:i.b+s}:{}});for(let t=0;n+t<e.length;t+=1)a.push({kind:"same",a:n+t,b:l+t});return a}(e,t),n=[];for(let l=0;l<s.length;){let a=s[l];if("same"===a.kind){n.push({kind:"same",left:{no:a.a+1,text:e[a.a]},right:{no:a.b+1,text:t[a.b]}}),l+=1;continue}let i=[],r=[];for(;l<s.length&&"same"!==s[l].kind;){let e=s[l];"del"===e.kind?i.push(e.a):r.push(e.b),l+=1}let c=Math.max(i.length,r.length);for(let s=0;s<c;s+=1){let l=i[s],a=r[s];n.push({kind:void 0!==l&&void 0!==a?"change":void 0!==l?"del":"add",...void 0!==l?{left:{no:l+1,text:e[l]}}:{},...void 0!==a?{right:{no:a+1,text:t[a]}}:{}})}}return n}function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(n)return e.map((e,t)=>({type:"row",row:e,index:t}));let l=[];for(let n=0;n<e.length;){if("same"!==e[n].kind){l.push({type:"row",row:e[n],index:n}),n+=1;continue}let a=n;for(;a<e.length&&"same"===e[a].kind;)a+=1;let i=0===n?0:t,r=a===e.length?0:t,c=a-n-i-r;if(c>1&&!s.has(n+i)){for(let t=n;t<n+i;t+=1)l.push({type:"row",row:e[t],index:t});l.push({type:"gap",from:n+i,count:c});for(let t=a-r;t<a;t+=1)l.push({type:"row",row:e[t],index:t})}else for(let t=n;t<a;t+=1)l.push({type:"row",row:e[t],index:t});n=a}return l}function i(e,t){let s=0;for(;s<e.length&&s<t.length&&e[s]===t[s];)s+=1;let n=e.length,l=t.length;for(;n>s&&l>s&&e[n-1]===t[l-1];)n-=1,l-=1;return{start:s,leftEnd:n,rightEnd:l}}s.d(t,{$8:()=>a,Dx:()=>n,Nj:()=>i,Qp:()=>l})},3374:(e,t,s)=>{s.d(t,{c:()=>l});var n=s(1521);function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,[s,l]=(0,n.useState)(()=>Date.now());return(0,n.useEffect)(()=>{if(!e)return;l(Date.now());let s=window.setInterval(()=>l(Date.now()),t);return()=>window.clearInterval(s)},[e,t]),s}},4811:(e,t,s)=>{s.d(t,{p:()=>a});var n=s(1521),l=s(5549);function a(){let[e,t]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let e=!0;return l.FH.settings().then(s=>{var n;let l=null!=(n=s.raw.execution)?n:{};e&&t("unattended"===l.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},5132:(e,t,s)=>{s.d(t,{s:()=>r});var n=s(3365),l=s(1521);function a(e,t){let s,l=[],a=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*)/g,i=0,r=0;for(;null!==(s=a.exec(e));){s.index>i&&l.push(e.slice(i,s.index));let a=s[0],c="".concat(t,"-i").concat(r+=1);a.startsWith("`")?l.push((0,n.jsx)("code",{children:a.slice(1,-1)},c)):a.startsWith("**")?l.push((0,n.jsx)("strong",{children:a.slice(2,-2)},c)):l.push((0,n.jsx)("em",{children:a.slice(1,-1)},c)),i=s.index+a.length}return i<e.length&&l.push(e.slice(i)),l}function i(e){let t=/^\s*[-*•]\s+(.*)$/.exec(e);if(t)return t[1];let s=/^\s*\d+[.)]\s+(.*)$/.exec(e);return s?s[1]:null}function r(e){let{text:t,className:s}=e,r=[],c=t.replace(/\r\n/g,"\n").split("\n"),d=0,o=0;for(;d<c.length;){let e=c[d];if(e.trim().startsWith("```")){let e=[];for(d+=1;d<c.length&&!c[d].trim().startsWith("```");)e.push(c[d++]);d+=1,e.length>0&&r.push((0,n.jsx)("pre",{children:e.join("\n")},"b".concat(o+=1)));continue}if(null!==i(e)){let e=[];for(;d<c.length&&null!==i(c[d]);)e.push(i(c[d++]));r.push((0,n.jsx)("ul",{children:e.map((e,t)=>(0,n.jsx)("li",{children:a(e,"b".concat(o,"-").concat(t))},t))},"b".concat(o+=1)));continue}if(""===e.trim()){d+=1;continue}let t=[];for(;d<c.length&&""!==c[d].trim()&&null===i(c[d])&&!c[d].trim().startsWith("```");)t.push(c[d++]);let s=o+=1;r.push((0,n.jsx)("p",{children:t.map((e,t)=>(0,n.jsxs)(l.Fragment,{children:[t>0&&(0,n.jsx)("br",{}),a(e,"b".concat(s,"-").concat(t))]},t))},"b".concat(s)))}return(0,n.jsx)("div",{className:"rich ".concat(null!=s?s:""),children:r})}},6481:(e,t,s)=>{s.d(t,{CV:()=>d,Q1:()=>u});var n=s(3365),l=s(1521),a=s(5549),i=s(4969),r=s(867),c=s(853);function d(e){let{sessionId:t,taskId:s,runId:a,title:i,files:c}=e,{t:d}=(0,r.kj)(),[u,h]=(0,l.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"linkish",onClick:()=>h(!0),title:d("diff.openWhy"),children:d("diff.open",{n:c})}),u&&(0,n.jsx)(o,{sessionId:t,taskId:s,runId:a,title:i,onClose:()=>h(!1)})]})}function o(e){var t,s,d,o,h,f,m;let{sessionId:p,taskId:x,runId:g,title:j,onClose:y}=e,{t:k}=(0,r.kj)(),[v,N]=(0,l.useState)(null),[b,w]=(0,l.useState)(""),[S,C]=(0,l.useState)(0),[q,I]=(0,l.useState)(new Map),[F,R]=(0,l.useState)(!1),[E,L]=(0,l.useState)(!0),[T,M]=(0,l.useState)(new Map),[H,O]=(0,l.useState)(-1),D=(0,l.useRef)(null),W=(0,l.useRef)(null),G=(0,l.useRef)(null);(0,i.V)(W,!0,G),(0,l.useEffect)(()=>{a.FH.taskChanges(p,x,g).then(N).catch(e=>w(e.message))},[p,x,g]);let Q=null!=(d=null==v?void 0:v.files)?d:[],P=Q[S];(0,l.useEffect)(()=>{!P||q.has(P.path)||a.FH.taskChangeFile(p,x,P.path,g).then(e=>I(t=>new Map(t).set(P.path,e))).catch(e=>I(t=>new Map(t).set(P.path,e.message)))},[P,q,p,x,g]);let V=P?q.get(P.path):void 0,A=(0,l.useMemo)(()=>!V||"string"==typeof V||V.binary||V.tooLarge?[]:(0,c.Qp)((0,c.Dx)(V.before),(0,c.Dx)(V.after)),[V]),B=P&&T.get(P.path)||new Set,$=(0,l.useMemo)(()=>(0,c.$8)(A,3,B,F),[A,B,F]),_=(0,l.useMemo)(()=>A.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===A[t-1].kind)?[t]:[]),[A]);(0,l.useEffect)(()=>{O(-1),D.current&&(D.current.scrollTop=0)},[S]);let K=(0,l.useCallback)(e=>{var t;if(0===_.length)return;let s=H<0?1===e?0:_.length-1:Math.min(_.length-1,Math.max(0,H+e));O(s);let n=null==(t=D.current)?void 0:t.querySelector('[data-row="'.concat(_[s],'"]'));null==n||n.scrollIntoView({block:"center"})},[H,_]),U=(0,l.useCallback)(e=>C(t=>Math.min(Math.max(0,t+e),Math.max(0,Q.length-1))),[Q.length]);(0,l.useEffect)(()=>{let e=e=>{if(!e.ctrlKey&&!e.metaKey&&!e.altKey){if("Escape"===e.key)y();else if("n"===e.key)K(1);else if("p"===e.key)K(-1);else if("]"===e.key)U(1);else{if("["!==e.key)return;U(-1)}e.preventDefault()}};window.addEventListener("keydown",e);let t=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",e),document.body.style.overflow=t}},[K,U,y]);let z=Q.reduce((e,t)=>({added:e.added+Math.max(0,t.added),removed:e.removed+Math.max(0,t.removed)}),{added:0,removed:0});return(0,n.jsxs)("div",{ref:W,className:"diff-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"diff-title",children:[(0,n.jsxs)("div",{className:"diff-head",children:[(0,n.jsx)("h2",{id:"diff-title",children:k("diff.title",{title:j})}),(null==v?void 0:v.ok)&&(0,n.jsxs)("span",{className:"muted small",children:[v.branch?"".concat(v.branch," \xb7 "):"",null==(t=v.base)?void 0:t.slice(0,8)," → ",null==(s=v.commit)?void 0:s.slice(0,8)," \xb7 ",k("diff.summary",{n:Q.length,a:z.added,r:z.removed})]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("span",{className:"muted small",children:k("diff.keys")}),(0,n.jsx)("button",{ref:G,type:"button",onClick:y,children:k("diff.close")})]}),b&&(0,n.jsx)("div",{className:"err",style:{padding:12},children:b}),!v&&!b&&(0,n.jsx)("div",{className:"muted",style:{padding:12},children:k("diff.loading")}),v&&!v.ok&&(0,n.jsx)("div",{className:"notice caution",style:{margin:12},children:v.problem}),(null==v?void 0:v.ok)&&0===Q.length&&(0,n.jsx)("div",{className:"notice",style:{margin:12},children:k("diff.nothing")}),(null==v?void 0:v.ok)&&Q.length>0&&(0,n.jsxs)("div",{className:"diff-body",children:[(0,n.jsx)("nav",{className:"diff-files","aria-label":k("diff.files"),children:Q.map((e,t)=>{let s=e.path.lastIndexOf("/");return(0,n.jsxs)("button",{type:"button",className:"diff-file".concat(t===S?" on":""),onClick:()=>C(t),title:e.oldPath?"".concat(e.oldPath," → ").concat(e.path):e.path,children:[(0,n.jsx)("span",{className:"diff-status s-".concat(e.status),children:e.status}),(0,n.jsxs)("span",{className:"diff-path",children:[s>=0&&(0,n.jsx)("span",{className:"muted",children:e.path.slice(0,s+1)}),(0,n.jsx)("strong",{children:e.path.slice(s+1)})]}),(0,n.jsx)("span",{className:"diff-counts",children:e.added<0?k("diff.binaryShort"):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"plus",children:["+",e.added]})," ",(0,n.jsxs)("span",{className:"minus",children:["−",e.removed]})]})})]},e.path)})}),(0,n.jsxs)("div",{className:"diff-main",children:[P&&(0,n.jsxs)("div",{className:"diff-toolbar",children:[(0,n.jsx)("strong",{className:"diff-name",children:P.oldPath?"".concat(P.oldPath," → ").concat(P.path):P.path}),(0,n.jsx)("span",{className:"muted small",children:"A"===P.status?k("diff.added"):"D"===P.status?k("diff.deleted"):"R"===P.status?k("diff.renamed"):""}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>K(-1),disabled:0===_.length,children:k("diff.prevChange")}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>K(1),disabled:0===_.length,children:k("diff.nextChange")}),(0,n.jsx)("span",{className:"muted small",children:_.length>0?k("diff.changeN",{i:H<0?"–":H+1,n:_.length}):""}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>U(-1),disabled:0===S,children:k("diff.prevFile")}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>U(1),disabled:S>=Q.length-1,children:k("diff.nextFile")}),(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:F,onChange:e=>R(e.target.checked)})," ",k("diff.whole")]}),(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:E,onChange:e=>L(e.target.checked)})," ",k("diff.wrap")]})]}),(0,n.jsxs)("div",{className:"diff-scroll",ref:D,children:[void 0===V&&(0,n.jsx)("div",{className:"muted",style:{padding:12},children:k("diff.loading")}),"string"==typeof V&&(0,n.jsx)("div",{className:"err",style:{padding:12},children:V}),V&&"string"!=typeof V&&V.binary&&(0,n.jsx)("div",{className:"notice",style:{margin:12},children:k("diff.binary")}),V&&"string"!=typeof V&&V.tooLarge&&(0,n.jsx)("div",{className:"notice",style:{margin:12},children:k("diff.tooLarge")}),V&&"string"!=typeof V&&!V.binary&&!V.tooLarge&&(0,n.jsxs)(n.Fragment,{children:[(null!=(o=V.before)?o:"").includes("\r\n")!==(null!=(h=V.after)?h:"").includes("\r\n")&&null!==V.before&&null!==V.after&&(0,n.jsx)("div",{className:"notice small",style:{margin:8},children:k("diff.eol",{from:(null!=(f=V.before)?f:"").includes("\r\n")?"CRLF":"LF",to:(null!=(m=V.after)?m:"").includes("\r\n")?"CRLF":"LF"})}),A.length>0&&0===_.length&&(0,n.jsx)("div",{className:"notice small",style:{margin:8},children:k("diff.sameText")}),(0,n.jsxs)("table",{className:"diff-table".concat(E?"":" nowrap"),children:[(0,n.jsxs)("colgroup",{children:[(0,n.jsx)("col",{className:"num"}),(0,n.jsx)("col",{}),(0,n.jsx)("col",{className:"num"}),(0,n.jsx)("col",{})]}),(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{colSpan:2,children:k("diff.before")}),(0,n.jsx)("th",{colSpan:2,children:k("diff.after")})]})}),(0,n.jsx)("tbody",{children:$.map(e=>"gap"===e.type?(0,n.jsx)("tr",{className:"diff-gap",children:(0,n.jsx)("td",{colSpan:4,children:(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>{var t;return t=e.from,void(P&&M(e=>{var s;return new Map(e).set(P.path,new Set([...null!=(s=e.get(P.path))?s:[],t]))}))},children:k("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,n.jsx)(u,{row:e.row,index:e.index,current:H>=0&&_[H]===e.index},e.index))})]})]})]})]})]})]})}function u(e){var t,s,a,i;let{row:r,index:d,current:o}=e,u="change"===r.kind?(0,c.Nj)(r.left.text,r.right.text):null,h=e=>{let t=r[e];if(!t)return null;if(!u)return t.text;let s="left"===e?u.leftEnd:u.rightEnd;return(0,n.jsxs)(l.Fragment,{children:[t.text.slice(0,u.start),(0,n.jsx)("mark",{children:t.text.slice(u.start,s)}),t.text.slice(s)]})};return(0,n.jsxs)("tr",{className:"diff-row ".concat(r.kind).concat(o?" current":""),"data-row":d,children:[(0,n.jsx)("td",{className:"num",children:null!=(a=null==(t=r.left)?void 0:t.no)?a:""}),(0,n.jsx)("td",{className:"code l".concat(r.left?"":" empty"),children:h("left")}),(0,n.jsx)("td",{className:"num",children:null!=(i=null==(s=r.right)?void 0:s.no)?i:""}),(0,n.jsx)("td",{className:"code r".concat(r.right?"":" empty"),children:h("right")})]})}},7619:(e,t,s)=>{s.d(t,{P:()=>o});var n=s(3365),l=s(1521),a=s(5549),i=s(867),r=s(7908),c=s(5132);function d(e){let{text:t,follow:s}=e,{ref:l}=(0,r.U)(s,t);return(0,n.jsx)("pre",{ref:l,className:"story-out".concat(s?" terminal":""),children:t})}function o(e){let{sessionId:t,taskId:s,runId:o,live:h}=e,{t:f}=(0,i.kj)(),[m,p]=(0,l.useState)(null),[x,g]=(0,l.useState)(""),[j,y]=(0,l.useState)(!0),[k,v]=(0,l.useState)(!0),[N,b]=(0,l.useState)(new Set),[w,S]=(0,l.useState)(new Set),[C,q]=(0,l.useState)(new Set),I=!!(null==m?void 0:m.live),F=(0,l.useRef)(0);F.current+=1;let R=(0,r.U)(I,F.current),E=(0,l.useRef)(null),L=(0,l.useRef)(!1);if((0,l.useEffect)(()=>{if(!m)return;let e=[],t=(s,n)=>s.forEach((s,l)=>{let a="".concat(n).concat(l);"review"===s.kind?t(s.entries,"".concat(a,"-")):"step"!==s.kind||s.outcome||e.push(a)});t(m.entries,"e"),e.some(e=>!w.has(e))&&S(t=>new Set([...t,...e])),m.live&&!L.current&&E.current&&(L.current=!0,E.current.scrollIntoView({block:"nearest",behavior:"smooth"}))},[m,w]),(0,l.useEffect)(()=>{let e,n=!0,l=async()=>{try{let i=await a.FH.taskStory(t,s,o);if(!n)return;p(i),g(""),(i.live||h)&&(e=setTimeout(l,2e3))}catch(t){if(!n)return;g(t.message),h&&(e=setTimeout(l,2e3))}};return l(),()=>{n=!1,e&&clearTimeout(e)}},[t,s,o,h]),x&&!m)return(0,n.jsx)("div",{className:"err small",children:x});if(!m)return(0,n.jsx)("div",{className:"muted small",children:f("story.loading")});let T=e=>N.has(e)||w.has(e)&&!C.has(e),M=e=>{let t=T(e);b(s=>{let n=new Set(s);return t?n.delete(e):n.add(e),n}),q(s=>{let n=new Set(s);return t?n.add(e):n.delete(e),n})},H=(e,t)=>{if(!("review"===e.kind?j||k:"step"===e.kind?k:j))return null;if("review"===e.kind)return(0,n.jsxs)("li",{className:"story-review",children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)(u,{at:e.at}),(0,n.jsx)("span",{className:"chip",children:f("story.review",{n:e.round})})]}),(0,n.jsx)("ol",{className:"story",children:e.entries.map((e,s)=>H(e,"".concat(t,"-").concat(s)))})]},t);if("step"===e.kind){let s=T(t),l=!e.outcome&&m.live;return(0,n.jsxs)("li",{className:"story-step".concat(e.failed?" failed":""),children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)(u,{at:e.at}),(0,n.jsx)("span",{className:"chip",children:f("story.step",{it:e.iteration,id:e.id})}),e.outcome&&(0,n.jsxs)("span",{className:"badge ".concat(e.failed?"failed":"done"),children:[e.outcome,void 0!==e.exitCode?" \xb7 exit ".concat(e.exitCode):"",void 0!==e.durationMs?" \xb7 ".concat((0,a.c5)(e.durationMs)):""]}),!e.outcome&&(0,n.jsx)("span",{className:"badge running",children:f("story.running")}),e.failed&&(0,n.jsx)("span",{className:"badge failed",children:f("story.failedHere")})]}),(0,n.jsx)("pre",{className:"story-cmd",children:e.command}),e.output&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>M(t),children:s?f("story.hideOutput"):f("story.showOutput",{n:e.output.length})}),s&&(0,n.jsx)(d,{text:e.output,follow:l})]})]},t)}let s=N.has(t),l="sent"===e.kind?f("story.bot"):f("story.chat"),i="reply"===e.kind&&("blocked"===e.status||"failed"===e.status);return(0,n.jsxs)("li",{className:"story-msg ".concat(e.kind).concat(i?" failed":""),children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)(u,{at:e.at}),(0,n.jsx)("strong",{children:l}),(0,n.jsx)("span",{className:"muted small",children:e.label}),"reply"===e.kind&&e.status&&(0,n.jsx)("span",{className:"badge ".concat(i?"failed":"done"===e.status?"done":""),children:e.status})]}),"reply"===e.kind&&e.notes&&(0,n.jsx)("p",{className:"story-notes",children:e.notes}),(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>M(t),children:s?f("story.hideText"):f("story.showText",{n:e.text.length})}),s&&(0,n.jsx)("pre",{className:"story-out",children:e.text})]},t)},O=m.close,D=O&&"done"!==O.status;return(0,n.jsxs)("div",{className:"story-box",ref:E,children:[(0,n.jsxs)("div",{className:"row small",style:{marginBottom:6},children:[(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:j,onChange:e=>y(e.target.checked)})," ",f("story.showChat")]}),(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:k,onChange:e=>v(e.target.checked)})," ",f("story.showCommands")]}),m.live&&(0,n.jsxs)("span",{className:"live",children:[(0,n.jsx)("span",{className:"dot","aria-hidden":"true"})," ",f("story.live")]}),m.live&&!R.following&&(0,n.jsx)("button",{type:"button",className:"quiet small",onClick:R.follow,title:f("story.followWhy"),children:f("story.follow")}),x&&(0,n.jsx)("span",{className:"err",children:x})]}),(0,n.jsxs)("div",{className:"story-fixed",children:[(0,n.jsx)("strong",{children:f("story.prompt")}),(0,n.jsx)("pre",{className:"story-out always",children:m.prompt})]}),(0,n.jsx)("div",{ref:R.ref,className:"story-scroll".concat(m.live?" live":""),children:(0,n.jsx)("ol",{className:"story",children:m.entries.map((e,t)=>H(e,"e".concat(t)))})}),O?(0,n.jsxs)("div",{className:"story-fixed close".concat(D?" failed":""),children:[(0,n.jsx)("strong",{children:D?f("story.endedBadly",{status:O.status}):f("story.ended")}),O.reason&&(0,n.jsx)("p",{className:"err small",children:O.reason}),O.summary&&(0,n.jsx)(c.s,{text:O.summary,className:"what"}),O.checks&&O.checks.length>0&&(0,n.jsx)("ul",{className:"small",style:{margin:"6px 0 0",paddingLeft:18},children:O.checks.map((e,t)=>(0,n.jsxs)("li",{className:e.passed?"":"err",children:[e.passed?"✓":"✗"," ",e.name,!e.passed&&e.detail?" — ".concat(e.detail):""]},t))})]}):(0,n.jsx)("div",{className:"story-fixed muted small",children:f("story.notEnded")})]})}function u(e){let{at:t}=e,s=(0,i.W3)(),{locale:l}=(0,i.kj)();if(!t)return null;let a=new Date(t),r="bg"===l?"bg-BG":void 0,c=a.toLocaleTimeString(r,{hour12:!1}),d=new Date().toDateString()===a.toDateString();return(0,n.jsx)("time",{className:"story-when",dateTime:t,title:s(t),children:d?c:"".concat(a.toLocaleDateString(r)," ").concat(c)})}},7908:(e,t,s)=>{s.d(t,{U:()=>l});var n=s(1521);function l(e,t){let[s,l]=(0,n.useState)(null),a=(0,n.useRef)(!0),[i,r]=(0,n.useState)(!0),c=(0,n.useCallback)(e=>l(e),[]);return(0,n.useLayoutEffect)(()=>{if(!s)return;let e=()=>{let e=s.scrollHeight-s.scrollTop-s.clientHeight<=24;a.current=e,r(e)};return s.addEventListener("scroll",e,{passive:!0}),()=>s.removeEventListener("scroll",e)},[s]),(0,n.useLayoutEffect)(()=>{s&&e&&a.current&&(s.scrollTop=s.scrollHeight)},[s,e,t]),{ref:c,following:i,follow:(0,n.useCallback)(()=>{a.current=!0,r(!0),s&&(s.scrollTop=s.scrollHeight)},[s])}}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[549],{5549:(t,o,e)=>{e.d(o,{AV:()=>a,Dh:()=>h,FH:()=>u,FZ:()=>r,Zm:()=>p,aT:()=>s,c5:()=>f,dK:()=>l,nC:()=>n,rt:()=>d,ub:()=>i,zi:()=>y});let n="/api";function s(t,o){return"/sessions/view?id=".concat(encodeURIComponent(t)).concat(o?"#".concat(o):"")}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 o=a();return o?"".concat(t).concat(t.includes("?")?"&":"?","token=").concat(encodeURIComponent(o)):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 p(t){return"limit-reached"===t.status||"aborted"===t.status||!!t.limit&&("failed"===t.status||"blocked"===t.status)}function h(t){return("failed"===t.status||"blocked"===t.status)&&"contract-conflict"!==t.stopCode}async function m(t,o){let e,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=void 0===s.timeoutMs?3e4:s.timeoutMs;try{var i;e=await fetch("".concat(n).concat(t),{...o,...null!==c&&!(null==o?void 0:o.signal)?{signal:AbortSignal.timeout(c)}:{},headers:{"content-type":"application/json",...a()?{"x-cop-token":a()}:{},...null!=(i=null==o?void 0:o.headers)?i:{}}})}catch(o){if("TimeoutError"===o.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 o}if(!e.ok){let t="".concat(e.status," ").concat(e.statusText);try{let o=await e.json();(null==o?void 0:o.message)&&(t=Array.isArray(o.message)?o.message.join("; "):o.message)}catch(t){}throw Error(t)}let r=await e.text();return r?JSON.parse(r):void 0}let u={health:()=>m("/health"),doctor:()=>m("/doctor"),settings:()=>m("/settings"),saveSettings:t=>m("/settings",{method:"PUT",body:JSON.stringify(t)}),level1:()=>m("/level1"),setLevel1:t=>m("/level1",{method:"PUT",body:JSON.stringify({content:t})}),resetLevel1:()=>m("/level1",{method:"DELETE"}),presets:()=>m("/presets"),savePreset:(t,o)=>m("/presets/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:o})}),deletePreset:t=>m("/presets/".concat(encodeURIComponent(t)),{method:"DELETE"}),personas:()=>m("/personas"),savePersona:(t,o)=>m("/personas/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:o})}),deletePersona:t=>m("/personas/".concat(encodeURIComponent(t)),{method:"DELETE"}),sessions:()=>m("/sessions"),reorderSessions:t=>m("/sessions-order",{method:"PUT",body:JSON.stringify({ids:t})}),metrics:()=>m("/metrics"),preparePreview:function(t){let o=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return m("/repo/prepare/preview",{method:"POST",body:JSON.stringify({dir:t,fetch:o})},{timeoutMs:33e4})},prepareProject:function(t,o){let e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return m("/repo/prepare",{method:"POST",body:JSON.stringify({dir:t,fingerprint:o,...e})})},session:t=>m("/sessions/".concat(t)),createSession:(t,o)=>m("/sessions",{method:"POST",body:JSON.stringify({name:t,projectDir:o})}),updateSession:(t,o)=>m("/sessions/".concat(t),{method:"PUT",body:JSON.stringify(o)}),deleteSession:t=>m("/sessions/".concat(t),{method:"DELETE"}),addTask:(t,o)=>m("/sessions/".concat(t,"/tasks"),{method:"POST",body:JSON.stringify(o)}),updateTask:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o),{method:"PUT",body:JSON.stringify(e)}),deleteTask:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o),{method:"DELETE"}),continueTask:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/continue"),{method:"POST",body:JSON.stringify((null==e?void 0:e.trim())?{instruction:e}:{})}),rerunTask:function(t,o){let e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return m("/sessions/".concat(t,"/tasks/").concat(o,"/rerun"),{method:"POST",body:JSON.stringify({...e,...n.buildOnFinished?{buildOnFinished:!0}:{}})})},taskChanges:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/changes").concat(e?"?run=".concat(encodeURIComponent(e)):"")),taskChangeFile:(t,o,e,n)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/changes/file?path=").concat(encodeURIComponent(e)).concat(n?"&run=".concat(encodeURIComponent(n)):"")),taskStory:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/story").concat(e?"?run=".concat(encodeURIComponent(e)):"")),taskFiles:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/files").concat(e?"?run=".concat(encodeURIComponent(e)):"")),taskLogUrl:(t,o,e)=>"".concat(n,"/sessions/").concat(t,"/tasks/").concat(o,"/log").concat(e?"?run=".concat(encodeURIComponent(e)):""),taskFileUrl:(t,o,e,s,c)=>"".concat(n,"/sessions/").concat(t,"/tasks/").concat(o,"/files/").concat(e,"/").concat(encodeURIComponent(s)).concat(c?"?run=".concat(encodeURIComponent(c)):""),saveTaskLog:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/log").concat(e?"?run=".concat(encodeURIComponent(e)):""),{method:"POST",body:"{}"}),saveTaskFile:(t,o,e,n,s)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/files/").concat(e,"/").concat(encodeURIComponent(n)).concat(s?"?run=".concat(encodeURIComponent(s)):""),{method:"POST",body:"{}"}),start:(t,o,e,n)=>m("/sessions/".concat(t,"/start"),{method:"POST",body:JSON.stringify({mode:o,name:e,starts:n})},{timeoutMs:12e4}),startOptions:t=>m("/start/options?sessions=".concat(encodeURIComponent(t.join(",")))),startFetch:(t,o,e)=>m("/start/fetch",{method:"POST",body:JSON.stringify({dir:t,remote:o,...e?{branches:e}:{}})},{timeoutMs:33e4}),startFailures:function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return m("/start/failures".concat(t?"?unanswered=1":""))},startFailureUrl:t=>i("".concat(n,"/start/failures/").concat(encodeURIComponent(t),"/report")),terminalUrl:()=>i("".concat(n,"/terminal")),stop:t=>m("/sessions/".concat(t,"/stop"),{method:"POST",body:"{}"}),approvals:t=>m("/approvals".concat(t?"?session=".concat(encodeURIComponent(t)):"")),undoPreview:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/undo")),undoTask:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/undo"),{method:"POST",body:JSON.stringify({how:e})}),acceptTask:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/accept"),{method:"POST",body:JSON.stringify((null==e?void 0:e.trim())?{note:e}:{})}),addTaskNote:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/notes"),{method:"POST",body:JSON.stringify({text:e})}),kerriganReport:t=>m("/kerrigan/report",{method:"POST",body:JSON.stringify(t)}),checkChanges:t=>m("/changes/check",{method:"POST",body:JSON.stringify({text:t})}),applyChanges:t=>m("/changes/apply",{method:"POST",body:JSON.stringify({text:t})}),workspace:()=>m("/workspace"),workspaceFiles:()=>m("/workspace/files"),workspaceFile:t=>m("/workspace/file?path=".concat(encodeURIComponent(t))),workspaceGit:()=>m("/workspace/git"),workspaceCommit:t=>m("/workspace/git/commit?sha=".concat(encodeURIComponent(t))),workspaceGitFile:(t,o,e)=>m("/workspace/git/file?area=".concat(t,"&path=").concat(encodeURIComponent(o)).concat(e?"&commit=".concat(encodeURIComponent(e)):"")),chatThreads:()=>m("/chat/threads"),chatSend:(t,o,e,n)=>m("/chat",{method:"POST",body:JSON.stringify({text:t,...o?{threadId:o}:{},...e?{model:e}:{},...n?{manualModel:!0}:{}})}),chatRewind:(t,o)=>m("/chat/".concat(t,"/rewind"),{method:"POST",body:JSON.stringify({taskId:o})}),repoTree:function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",e=arguments.length>2?arguments[2]:void 0;return m("/sessions/".concat(t,"/repo/tree?path=").concat(encodeURIComponent(o)).concat(e?"&task=".concat(encodeURIComponent(e)):""))},repoFile:(t,o,e)=>m("/sessions/".concat(t,"/repo/file?path=").concat(encodeURIComponent(o)).concat(e?"&task=".concat(encodeURIComponent(e)):"")),repoLog:t=>m("/sessions/".concat(t,"/repo/log")),sessionEvents:t=>m("/sessions/".concat(t,"/events")),decidePlan:(t,o,e)=>m("/approvals/".concat(t,"/plan"),{method:"POST",body:JSON.stringify({action:o,...(null==e?void 0:e.trim())?{note:e}:{}})}),decide:(t,o)=>m("/approvals/".concat(t),{method:"POST",body:JSON.stringify({action:o})}),setRunMode:(t,o)=>m("/sessions/".concat(t,"/mode"),{method:"POST",body:JSON.stringify({mode:o})}),streamUrl:t=>i("".concat(n,"/sessions/").concat(t,"/stream")),batch:()=>m("/batch").then(t=>null!=t?t:null),startBatch:(t,o,e,n,s,c,a,i)=>m("/batch/start",{method:"POST",body:JSON.stringify({sessionIds:t,mode:o,onFailure:e,model:n,reviewModel:s,name:c,taskIds:a,starts:i})},{timeoutMs:12e4}),suggestedRunName:t=>m("/batch/name?sessions=".concat(encodeURIComponent(t.join(",")))),stopBatch:()=>m("/batch/stop",{method:"POST",body:"{}"}),pauseBatch:()=>m("/batch/pause",{method:"POST",body:"{}"}),resumeBatch:()=>m("/batch/resume",{method:"POST",body:"{}"}),planBrief:t=>m("/plan/brief?lang=".concat(encodeURIComponent(t))),context:(t,o)=>m("/context/".concat(t,"?lang=").concat(encodeURIComponent(o))),setContext:(t,o)=>m("/context/".concat(t),{method:"PUT",body:JSON.stringify({content:o})}),resetContext:(t,o)=>m("/context/".concat(t,"?lang=").concat(encodeURIComponent(o)),{method:"DELETE"}),checkPlan:t=>m("/plan/check",{method:"POST",body:JSON.stringify({text:t})}),importPlan:t=>m("/plan/import",{method:"POST",body:JSON.stringify({text:t})}),browseFolder:t=>m("/browse-folder",{method:"POST",body:JSON.stringify({start:t})},{timeoutMs:null}),tasks:()=>m("/tasks"),activity:()=>m("/activity"),downloadBundle:async t=>{var o,e,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==(o=/filename\*=UTF-8''([^;]+)/i.exec(i))?void 0:o[1],d=null==(e=/filename="([^"]+)"/i.exec(i))?void 0:e[1],l=null!=d?d:"copilot-operator-bundle.json";if(r)try{l=decodeURIComponent(r)}catch(t){}let p=URL.createObjectURL(await c.blob()),h=document.createElement("a");return h.href=p,h.download=l,document.body.appendChild(h),h.click(),h.remove(),setTimeout(()=>URL.revokeObjectURL(p),1e4),l},exportUrl:(t,o)=>{let e=new URLSearchParams;return o.run&&e.set("run",o.run),o.session&&e.set("session",o.session),o.task&&e.set("task",o.task),i("".concat(n,"/export/").concat(t,"?").concat(e.toString()))},taskExchangeUrl:(t,o)=>i("".concat(n,"/sessions/").concat(encodeURIComponent(t),"/tasks/").concat(encodeURIComponent(o),"/exchange")),debugExportUrl:t=>i("".concat(n,"/debug/export").concat(t.length>0?"?sessions=".concat(encodeURIComponent(t.join(","))):"")),vcsStatus:t=>m("/sessions/".concat(t,"/vcs")),runVcs:t=>m("/batch/vcs?ids=".concat(encodeURIComponent(t.join(",")))),runVcsPrepare:function(t,o,e){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return m("/batch/vcs/prepare",{method:"POST",body:JSON.stringify({sessionIds:t,repoDir:o,action:e,choices:n})})},vcsSnapshot:(t,o)=>m("/sessions/".concat(t,"/vcs/snapshot"),{method:"POST",body:JSON.stringify({choices:o})}),restorePreview:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/restore")),restore:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/restore"),{method:"POST",body:"{}"}),contractCheck:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/contract")),applyContractFix:(t,o,e,n)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/contract-fix"),{method:"POST",body:JSON.stringify({choices:e,expect:n})}),restartPlan:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/restart")),restartFrom:function(t,o){let e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return m("/sessions/".concat(t,"/tasks/").concat(o,"/restart"),{method:"POST",body:JSON.stringify(e)})},repoCheck:t=>m("/repo?dir=".concat(encodeURIComponent(t))),project:()=>m("/project"),setProject:t=>m("/project",{method:"PUT",body:JSON.stringify(t)}),models:()=>m("/models"),setDefaultModel:t=>m("/models/default",{method:"PUT",body:JSON.stringify({model:t})}),setDefaultReviewModel:t=>m("/models/review-default",{method:"PUT",body:JSON.stringify({model:t})}),refreshModels:()=>m("/models/refresh",{method:"POST",body:"{}"},{timeoutMs:null}),login:t=>m("/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 o=Math.round(t/1e3);if(o<60)return"".concat(o,"s");let e=Math.floor(o/60);return e<60?"".concat(e,"m ").concat(o%60,"s"):"".concat(Math.floor(e/60),"h ").concat(e%60,"m")}}}]);