copilot-operator 0.1.19 → 0.1.22

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 +49 -0
  2. package/dist/src/api/operator.service.js +179 -7
  3. package/dist/src/orchestrator/taskRunner.js +14 -2
  4. package/dist/src/plan/systemGuide.js +119 -15
  5. package/dist/src/session/exports.js +72 -1
  6. package/dist/src/session/runLog.js +60 -0
  7. package/dist/src/vcs/git.js +11 -1
  8. package/dist/src/vcs/inputs.js +26 -2
  9. package/dist/src/vcs/prepareFromRemote.js +263 -0
  10. package/dist/src/vcs/runPreflight.js +286 -0
  11. package/dist/src/vcs/taskVcs.js +60 -20
  12. package/dist/web/404.html +2 -2
  13. package/dist/web/_next/static/chunks/549-5f90780046c1c24f.js +1 -0
  14. package/dist/web/_next/static/chunks/867-79f07bebe3084811.js +1 -0
  15. package/dist/web/_next/static/chunks/app/defaults/page-cdc730adea753446.js +1 -0
  16. package/dist/web/_next/static/chunks/app/page-0a861b38da0a1c51.js +1 -0
  17. package/dist/web/_next/static/chunks/app/sessions/view/page-185755ada66e2930.js +1 -0
  18. package/dist/web/appearance.html +2 -2
  19. package/dist/web/appearance.txt +10 -10
  20. package/dist/web/defaults.html +2 -2
  21. package/dist/web/defaults.txt +10 -10
  22. package/dist/web/history.html +2 -2
  23. package/dist/web/history.txt +10 -10
  24. package/dist/web/import.html +2 -2
  25. package/dist/web/import.txt +10 -10
  26. package/dist/web/index.html +2 -2
  27. package/dist/web/index.txt +10 -10
  28. package/dist/web/level1.html +2 -2
  29. package/dist/web/level1.txt +10 -10
  30. package/dist/web/presets.html +2 -2
  31. package/dist/web/presets.txt +10 -10
  32. package/dist/web/sessions/view.html +2 -2
  33. package/dist/web/sessions/view.txt +10 -10
  34. package/dist/web/system.html +2 -2
  35. package/dist/web/system.txt +10 -10
  36. package/package.json +150 -147
  37. package/dist/web/_next/static/chunks/549-5d7c845fb0a27dbe.js +0 -1
  38. package/dist/web/_next/static/chunks/867-d9c54f7a2b285b3f.js +0 -1
  39. package/dist/web/_next/static/chunks/app/defaults/page-fd819bbfa7f33982.js +0 -1
  40. package/dist/web/_next/static/chunks/app/page-409e37e208dc12e5.js +0 -1
  41. package/dist/web/_next/static/chunks/app/sessions/view/page-99f9153fd75078d0.js +0 -1
  42. /package/dist/web/_next/static/{ofnRLEgWx9th5w_qtuFnB → 9Ze8aagkvT-WLfD4KCKKS}/_buildManifest.js +0 -0
  43. /package/dist/web/_next/static/{ofnRLEgWx9th5w_qtuFnB → 9Ze8aagkvT-WLfD4KCKKS}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[189],{1035:(e,l,t)=>{"use strict";t.d(l,{DialogHost:()=>d,Z:()=>c});var n=t(3365),s=t(1521),a=t(867),r=t(4969);let i=null,o=[];function c(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var n;return n={kind:"confirm",message:e,...l,resolve:t},void(i?i(n):o.push(n))})}function d(e){var l,t;let{children:c}=e,{t:d}=(0,a.kj)(),[m,u]=(0,s.useState)([]),h=(0,s.useRef)(null),x=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(i=e=>u(l=>[...l,e]),o.length>0){let e=o.splice(0,o.length);u(l=>[...l,...e])}return()=>{i=null}},[]);let p=m[0],j=(0,s.useCallback)(e=>{p&&(p.resolve(e),u(e=>e.slice(1)))},[p]);return(0,r.V)(x,!!p,h),(0,s.useEffect)(()=>{if(!p)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),j(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[p,j]),(0,n.jsxs)(n.Fragment,{children:[c,p&&(0,n.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,n.jsxs)("div",{ref:x,className:"modal".concat(p.danger?" danger":""),role:"confirm"===p.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"modal-title",children:null!=(l=p.title)?l:d("confirm"===p.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,n.jsx)("div",{id:"modal-body",className:"modal-body",children:p.message}),(0,n.jsxs)("div",{className:"row modal-actions",children:["confirm"===p.kind&&(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:d("dialog.cancel")}),(0,n.jsx)("button",{ref:h,type:"button",className:p.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(t=p.okLabel)?t:d("dialog.ok")})]})]})})]})}},1896:(e,l,t)=>{Promise.resolve().then(t.bind(t,3197))},2285:(e,l,t)=>{"use strict";t.d(l,{b:()=>i});var n=t(3365),s=t(1521),a=t(5549),r=t(867);function i(e){var l,t;let{dir:i}=e,{t:o}=(0,r.kj)(),c=(0,r.W3)(),[d,m]=(0,s.useState)(null),[u,h]=(0,s.useState)(""),[x,p]=(0,s.useState)(""),j=async()=>{h("");try{m(await a.FH.syncPlan(i))}catch(e){h(e.message)}},v=async(e,l)=>{try{await navigator.clipboard.writeText(l),p(e),window.setTimeout(()=>p(""),2500)}catch(e){h(o("plan.copyFailed"))}},f=e=>(0,n.jsxs)("ul",{style:{margin:"2px 0 6px",paddingLeft:20},children:[e.slice(0,30).map(e=>(0,n.jsx)("li",{children:(0,n.jsx)("code",{children:e})},e)),e.length>30&&(0,n.jsx)("li",{className:"muted",children:o("sync.more",{n:e.length-30})})]});return(0,n.jsxs)("div",{className:"sync-command small",style:{marginTop:8},children:[(0,n.jsx)("button",{type:"button",onClick:()=>void j(),children:o("sync.show")}),u&&(0,n.jsx)("p",{className:"err",children:u}),d&&!d.ok&&(0,n.jsx)("p",{className:"err",children:d.problem}),(null==d?void 0:d.ok)&&(0,n.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,n.jsxs)("p",{children:[o("sync.what",{branch:null!=(l=d.branch)?l:"",target:null!=(t=d.target)?t:""})," ",(0,n.jsx)("span",{className:"muted",children:d.lastFetched?o("sync.fetchedAt",{when:c(d.lastFetched)}):o("sync.neverFetched")})]}),d.willLose.commits.length+d.willLose.changed.length+d.willLose.untracked.length===0?(0,n.jsx)("p",{children:o("sync.nothingLost")}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("strong",{children:o("sync.loses")}),d.willLose.commits.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{children:o("sync.commits",{n:d.willLose.commits.length})}),f(d.willLose.commits)]}),d.willLose.changed.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{children:o("sync.changed",{n:d.willLose.changed.length})}),f(d.willLose.changed)]}),d.willLose.untracked.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{children:o("sync.untracked",{n:d.willLose.untracked.length})}),f(d.willLose.untracked)]})]}),(0,n.jsx)("p",{className:"muted",children:o("sync.keeps")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{type:"button",onClick:()=>void v("preview",d.preview),children:o("sync.copyPreview")}),"preview"===x&&(0,n.jsx)("span",{className:"badge done",children:o("plan.copied")})]}),(0,n.jsx)("pre",{className:"sync-cmd",children:d.preview}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{type:"button",className:"danger",onClick:()=>void v("command",d.command),children:o("sync.copyCommand")}),"command"===x&&(0,n.jsx)("span",{className:"badge done",children:o("plan.copied")})]}),(0,n.jsx)("pre",{className:"sync-cmd",children:d.command}),(0,n.jsx)("p",{className:"muted",children:o("sync.howToRun")})]})]})}},3197:(e,l,t)=>{"use strict";t.r(l),t.d(l,{default:()=>u});var n=t(3365),s=t(1521),a=t(2285),r=t(8197),i=t.n(r),o=t(5549),c=t(867),d=t(1035),m=t(4784);function u(){let{t:e}=(0,c.kj)(),[l,t]=(0,s.useState)(null),[a,r]=(0,s.useState)(!1),[i,m]=(0,s.useState)("");(0,s.useEffect)(()=>{o.FH.models().then(t).catch(()=>void 0)},[]);let u=async()=>{if(await (0,d.Z)(e("model.refreshConfirm"))){r(!0),m(e("model.refreshing"));try{var l;let n=await o.FH.models().then(()=>o.FH.refreshModels());t(n),m(0===n.options.length?null!=(l=n.note)?l:e("model.none"):e("model.refreshed",{n:n.options.length}))}catch(e){m(e.message)}finally{r(!1)}}},h={catalogue:l,setCatalogue:t,refreshModels:u,refreshing:a,refreshMsg:i};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:e("def.title")}),(0,n.jsx)("p",{className:"muted small",children:e("def.intro")}),(0,n.jsx)("p",{className:"why",children:e("def.autoSave")})]}),(0,n.jsx)(v,{}),(0,n.jsx)(g,{}),(0,n.jsx)(w,{...h}),(0,n.jsx)(b,{...h}),(0,n.jsx)(y,{})]})}function h(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:900,t=(0,s.useRef)(null),n=(0,s.useRef)(null),a=(0,s.useRef)(e);return a.current=e,(0,s.useEffect)(()=>()=>{t.current&&clearTimeout(t.current),n.current&&a.current(n.current.value)},[]),e=>{t.current&&clearTimeout(t.current),n.current={value:e},t.current=setTimeout(()=>{n.current=null,a.current(e)},l)}}function x(e){let{id:l,value:t,min:a,max:r,onChange:i,disabled:o}=e,[c,d]=(0,s.useState)(String(t));return(0,s.useEffect)(()=>d(e=>p(e)===t?e:String(t)),[t]),(0,n.jsx)("input",{id:l,type:"number",min:a,max:r,step:1,value:c,onChange:e=>{d(e.target.value);let l=p(e.target.value);null!==l&&l>=a&&l<=r&&i(l)},onBlur:()=>{let e=p(c),l=null===e?t:Math.max(a,Math.min(r,e));d(String(l)),l!==t&&i(l)},style:{width:"9ch"},disabled:o})}function p(e){if(""===e.trim())return null;let l=Number(e);return Number.isInteger(l)?l:null}function j(e){let{msg:l,onSave:t}=e,{t:s}=(0,c.kj)();return(0,n.jsxs)("div",{className:"row",style:{marginTop:6},children:[t&&(0,n.jsx)("button",{className:"quiet",onClick:t,title:s("def.saveAnywayWhy"),children:s("def.saveAnyway")}),(0,n.jsx)("span",{className:"muted small",role:"status",children:l||s("def.savedAutomatically")})]})}function v(){var e;let{t:l}=(0,c.kj)(),[t,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(""),[d,m]=(0,s.useState)(""),[u,x]=(0,s.useState)(""),[p,v]=(0,s.useState)(""),[y,g]=(0,s.useState)(!1),[w,b]=(0,s.useState)(""),[N,k]=(0,s.useState)(""),S=(0,s.useCallback)(async()=>{try{let e=await o.FH.project();a(e),i(e.rootDir),m(e.name),v("")}catch(e){v(e.message)}},[]);(0,s.useEffect)(()=>{S()},[S]);let F=async(e,l)=>{g(!0),x("");try{let t=await o.FH.setProject(e);return a(t),i(t.rootDir),x(l(t)),v(""),!0}catch(e){return v(e.message),!1}finally{g(!1)}},C=e=>F({rootDir:e},e=>e.rootDir?l("proj.saved",{dir:e.rootDir}):l("proj.cleared")),R=e=>F({name:e},()=>l("proj.nameSaved")),T=h(C),D=h(R),E=async(e,l)=>{g(!0);try{var t;let n=await o.FH.browseFolder(l.trim()||void 0);n.ok?e(n.path):n.cancelled||v(null!=(t=n.reason)?t:"")}catch(e){v(e.message)}finally{g(!1)}},M=null!=(e=null==t?void 0:t.others)?e:[],A=e=>e.map(e=>({name:e.name,rootDir:e.rootDir})),L=async()=>{await F({others:[...A(M),{name:w.trim(),rootDir:N.trim()}]},e=>l("proj.othersSaved",{n:e.others.length}))&&(b(""),k(""))};return(0,n.jsxs)("div",{className:"panel",id:"project",children:[(0,n.jsx)("h2",{children:l("proj.title")}),(0,n.jsx)("p",{className:"muted small",children:l("proj.intro")}),p&&(0,n.jsx)("div",{className:"err",children:p}),(0,n.jsx)("p",{className:"muted small",children:l("proj.listIntro")}),(0,n.jsx)(f,{name:d,dir:r,repoOk:!!(null==t?void 0:t.repoOk),repoProblem:null==t?void 0:t.repoProblem,isDefault:!0,busy:y,onNameInput:e=>{m(e),D(e)},onName:e=>void R(e),onDirInput:e=>{i(e),T(e)},onDir:e=>void C(e),onBrowse:()=>void E(e=>void C(e),r),onRemove:(null==t?void 0:t.rootDir)?()=>void C(""):void 0,removeLabel:l("proj.clear")}),(0,n.jsx)(j,{msg:u}),t&&!t.rootDir&&(0,n.jsx)("p",{className:"muted small",style:{marginTop:8},children:l("proj.none")}),M.map((e,t)=>(0,n.jsx)(f,{name:e.name,dir:e.rootDir,repoOk:e.repoOk,repoProblem:e.repoProblem,busy:y,onName:t=>void F({others:A(M.map(l=>l.name===e.name?{...l,name:t}:l))},()=>l("proj.nameSaved")),onDir:t=>void F({others:A(M.map(l=>l.name===e.name?{...l,rootDir:t}:l))},()=>l("proj.othersSaved",{n:M.length})),onBrowse:()=>void E(t=>void F({others:A(M.map(l=>l.name===e.name?{...l,rootDir:t}:l))},()=>l("proj.othersSaved",{n:M.length})),e.rootDir),onRemove:()=>{let t;t=e.name,F({others:A(M.filter(e=>e.name!==t))},e=>l("proj.othersSaved",{n:e.others.length}))},removeLabel:l("proj.otherRemove")},"other-".concat(t))),(0,n.jsx)("h3",{id:"others",children:l("proj.addTitle")}),(0,n.jsx)("p",{className:"muted small",children:l("proj.othersIntro")}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,n.jsx)("input",{type:"text","aria-label":l("proj.entryName"),value:w,onChange:e=>b(e.target.value),placeholder:l("proj.entryName"),disabled:y,style:{width:160}}),(0,n.jsx)("input",{type:"text",className:"grow","aria-label":l("proj.entryDir"),value:N,onChange:e=>k(e.target.value),placeholder:"C:\\Projects\\my-app-tests",disabled:y}),(0,n.jsx)("button",{onClick:()=>void E(e=>k(e),N),disabled:y,children:l("mirror.browse")}),(0,n.jsx)("button",{className:"primary",onClick:()=>void L(),disabled:y||!w.trim()||!N.trim(),children:l("proj.otherAdd")})]}),(0,n.jsx)("h3",{children:l("proj.affects")}),(0,n.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,n.jsx)("li",{children:l("proj.affectsNew")}),(0,n.jsx)("li",{children:l("proj.affectsExisting")}),(0,n.jsx)("li",{children:l("proj.affectsPlan")}),(0,n.jsx)("li",{children:l("proj.affectsNever")})]})]})}function f(e){var l;let{name:t,dir:r,repoOk:i,repoProblem:o,isDefault:d=!1,busy:m,onNameInput:u,onName:h,onDirInput:x,onDir:p,onBrowse:j,onRemove:v,removeLabel:f}=e,{t:y}=(0,c.kj)(),g=(0,s.useId)(),[w,b]=(0,s.useState)(t),[N,k]=(0,s.useState)(r);return(0,s.useEffect)(()=>b(t),[t]),(0,s.useEffect)(()=>k(r),[r]),(0,n.jsxs)("div",{className:"panel inner",style:{marginTop:10},children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsxs)("div",{style:{width:"min(200px, 100%)"},children:[(0,n.jsx)("label",{htmlFor:"".concat(g,"-name"),children:y("proj.entryName")}),(0,n.jsx)("input",{id:"".concat(g,"-name"),type:"text",value:w,onChange:e=>{b(e.target.value),null==u||u(e.target.value)},onBlur:()=>{(w!==t||u)&&h(w)},placeholder:r?null!=(l=r.replace(/[\/]+$/,"").split(/[\/]/).pop())?l:"":y("proj.namePlaceholder")})]}),(0,n.jsxs)("div",{className:"grow",children:[(0,n.jsx)("label",{htmlFor:"".concat(g,"-dir"),children:y("proj.entryDir")}),(0,n.jsx)("input",{id:"".concat(g,"-dir"),type:"text",value:N,onChange:e=>{k(e.target.value),null==x||x(e.target.value)},onBlur:()=>{(N!==r||x)&&p(N)},placeholder:"C:\\Projects\\my-app"})]}),(0,n.jsx)("button",{onClick:j,disabled:m,children:y("mirror.browse")}),v&&(0,n.jsx)("button",{className:"quiet",onClick:v,disabled:m,children:f})]}),(0,n.jsxs)("div",{className:"row small",style:{marginTop:6},children:[d&&(0,n.jsx)("span",{className:"chip",title:y("proj.isDefaultWhy"),children:y("proj.isDefault")}),r&&(0,n.jsx)("span",{className:"badge ".concat(i?"done":""),title:i?y("proj.isRepo"):o,children:y(i?"proj.otherRepo":"proj.otherNotRepo")}),r&&!i&&(0,n.jsx)("span",{className:"muted",children:o||y("proj.notRepoWhy")})]}),r&&i&&(0,n.jsx)(a.b,{dir:r})]})}function y(){let{t:e}=(0,c.kj)(),[l,t]=(0,s.useState)(null),a=(0,s.useRef)(null),r=(0,s.useRef)(Promise.resolve()),[i,d]=(0,s.useState)(2),[m,u]=(0,s.useState)(2),[p,v]=(0,s.useState)(60),[f,y]=(0,s.useState)(240),[g,w]=(0,s.useState)(900),[b,N]=(0,s.useState)("none"),[k,S]=(0,s.useState)("confirm"),[F,C]=(0,s.useState)("ask"),[R,T]=(0,s.useState)(""),[D,E]=(0,s.useState)("");(0,s.useEffect)(()=>{o.FH.settings().then(e=>{var l,n,s,r,i,o;a.current=e.raw,t(e.raw);let c=null!=(l=e.raw.limits)?l:{};d("number"==typeof c.retryBlockedInFreshChat?c.retryBlockedInFreshChat:2),u("number"==typeof c.minApproachesBeforeBlocked?c.minApproachesBeforeBlocked:2),v("number"==typeof c.maxIterations?c.maxIterations:60),y("number"==typeof c.maxRunMinutes?c.maxRunMinutes:240);let m=null!=(n=e.raw.copilot)?n:{};w("number"==typeof m.replyTimeoutSec?m.replyTimeoutSec:900);let h=null!=(s=e.raw.execution)?s:{};N(null!=(r=h.isolation)?r:"none"),S(null!=(i=h.mode)?i:"confirm"),C(null!=(o=h.networkFetch)?o:"ask")}).catch(e=>E(e.message))},[]);let M=(l,n,s)=>{let i=async()=>{var r;if(!a.current)return;let i=await o.FH.settings().then(e=>e.raw).catch(()=>a.current),c={...i,[l]:{...null!=(r=i[l])?r:{},[n]:s}};T("");try{await o.FH.saveSettings(c),a.current=c,t(c),T(e("exec.saved")),E("")}catch(e){E(e.message)}},c=r.current.then(i);return r.current=c.catch(()=>void 0),c},A=h(e=>M("limits","retryBlockedInFreshChat",e)),L=h(e=>M("limits","minApproachesBeforeBlocked",e)),B=h(e=>M("limits","maxIterations",e)),I=h(e=>M("limits","maxRunMinutes",e)),H=h(e=>M("copilot","replyTimeoutSec",e)),P=(e,l)=>M("execution",e,l);return(0,n.jsxs)("div",{className:"panel",id:"execution",children:[(0,n.jsx)("h2",{children:e("exec.title")}),(0,n.jsx)("p",{className:"muted small",children:e("exec.intro")}),D&&(0,n.jsx)("div",{className:"err",children:D}),(0,n.jsx)("label",{htmlFor:"min-approaches",children:e("exec.minApproaches")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)(x,{id:"min-approaches",value:m,min:2,max:20,onChange:e=>{u(e),L(e)},disabled:!l}),(0,n.jsx)("span",{className:"muted small",children:e("exec.minApproachesUnit")})]}),(0,n.jsx)("p",{className:"why",children:e("exec.minApproachesWhy")}),(0,n.jsx)("label",{htmlFor:"retry-blocked",children:e("exec.retryBlocked")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)(x,{id:"retry-blocked",value:i,min:0,max:5,onChange:e=>{d(e),A(e)},disabled:!l}),(0,n.jsx)("span",{className:"muted small",children:e("exec.retryBlockedTimes")})]}),(0,n.jsx)("p",{className:"why",children:e("exec.retryBlockedWhy")}),(0,n.jsx)("label",{htmlFor:"max-iterations",children:e("exec.maxIterations")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)(x,{id:"max-iterations",value:p,min:5,max:200,onChange:e=>{v(e),B(e)},disabled:!l}),(0,n.jsx)("span",{className:"muted small",children:e("exec.maxIterationsUnit")})]}),(0,n.jsx)("p",{className:"why",children:e("exec.maxIterationsWhy")}),(0,n.jsx)("label",{htmlFor:"max-minutes",children:e("exec.maxRunMinutes")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)(x,{id:"max-minutes",value:f,min:10,max:1440,onChange:e=>{y(e),I(e)},disabled:!l}),(0,n.jsx)("span",{className:"muted small",children:e("exec.maxRunMinutesUnit")})]}),(0,n.jsx)("p",{className:"why",children:e("exec.maxRunMinutesWhy")}),(0,n.jsx)("label",{htmlFor:"reply-timeout",children:e("exec.replyTimeout")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)(x,{id:"reply-timeout",value:g,min:60,max:10800,onChange:e=>{w(e),H(e)},disabled:!l}),(0,n.jsx)("span",{className:"muted small",children:e("exec.replyTimeoutUnit")})]}),(0,n.jsx)("p",{className:"why",children:e("exec.replyTimeoutWhy")}),(0,n.jsx)("label",{htmlFor:"isolation",children:e("exec.isolation")}),(0,n.jsxs)("select",{id:"isolation",value:b,onChange:e=>{let l=e.target.value;N(l),P("isolation",l)},disabled:!l,children:[(0,n.jsx)("option",{value:"none",children:e("exec.isolationNone")}),(0,n.jsx)("option",{value:"none-accepted",children:e("exec.isolationNoneAccepted")}),(0,n.jsx)("option",{value:"separate-account",children:e("exec.isolationAccount")}),(0,n.jsx)("option",{value:"sandbox",children:e("exec.isolationSandbox")}),(0,n.jsx)("option",{value:"vm",children:e("exec.isolationVm")})]}),(0,n.jsx)("p",{className:"why",children:e("exec.isolationWhy")}),(0,n.jsx)("label",{htmlFor:"start-mode",children:e("exec.startMode")}),(0,n.jsxs)("select",{id:"start-mode",value:k,onChange:e=>{let l=e.target.value;S(l),P("mode",l)},disabled:!l,children:[(0,n.jsx)("option",{value:"confirm",children:e("exec.startModeAsk")}),(0,n.jsx)("option",{value:"unattended",children:e("exec.startModeAuto")})]}),(0,n.jsx)("p",{className:"why",children:e("exec.startModeWhy")}),(0,n.jsx)("label",{htmlFor:"network-fetch",children:e("exec.networkFetch")}),(0,n.jsxs)("select",{id:"network-fetch",value:F,onChange:e=>{let l=e.target.value;C(l),P("networkFetch",l)},disabled:!l,children:[(0,n.jsx)("option",{value:"ask",children:e("exec.networkFetchAsk")}),(0,n.jsx)("option",{value:"refuse",children:e("exec.networkFetchRefuse")}),(0,n.jsx)("option",{value:"run",children:e("exec.networkFetchRun")})]}),(0,n.jsx)(j,{msg:R}),(0,n.jsx)("p",{className:"why",children:e("exec.networkFetchWhy")})]})}function g(){let{t:e}=(0,c.kj)(),[l,t]=(0,s.useState)(""),[a,r]=(0,s.useState)(!1),[i,d]=(0,s.useState)(""),[m,u]=(0,s.useState)(""),h=async()=>{r(!0),u(""),d(e("login.waiting"));try{let e=await o.FH.login(l);e.ok?d(e.message):(d(""),u(e.message))}catch(e){d(""),u(e.message)}finally{r(!1)}};return(0,n.jsxs)("div",{className:"panel",id:"login",children:[(0,n.jsx)("h2",{children:e("login.title")}),(0,n.jsx)("p",{className:"muted small",children:e("login.intro")}),m&&(0,n.jsx)("div",{className:"err",children:m}),(0,n.jsx)("label",{htmlFor:"login-account",children:e("login.account")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("input",{id:"login-account",type:"email",className:"grow",value:l,onChange:e=>t(e.target.value),placeholder:"name@company.com",disabled:a}),(0,n.jsx)("button",{className:"primary",onClick:()=>void h(),disabled:a,children:a?e("login.busy"):e("login.button")})]}),(0,n.jsx)("p",{className:"why",children:e("login.accountWhy")}),i&&(0,n.jsx)("div",{className:"small",role:"status",children:i})]})}function w(e){var l;let{catalogue:t,setCatalogue:a,refreshModels:r,refreshing:i,refreshMsg:d}=e,{t:u}=(0,c.kj)(),h=(0,c.W3)(),[x,p]=(0,s.useState)(""),[v,f]=(0,s.useState)(""),[y,g]=(0,s.useState)(!1),w=null!=(l=null==t?void 0:t.defaultModel)?l:"",b=async e=>{g(!0),p("");try{let l=await o.FH.setDefaultModel(e);t&&a({...t,defaultModel:l.defaultModel}),p(l.defaultModel?u("def.modelSaved",{name:l.defaultModel}):u("def.modelCleared")),f("")}catch(e){f(e.message)}finally{g(!1)}};return(0,n.jsxs)("div",{className:"panel",id:"model",children:[(0,n.jsx)("h2",{children:u("def.modelTitle")}),(0,n.jsx)("p",{className:"muted small",children:u("def.modelIntro")}),v&&(0,n.jsx)("div",{className:"err",children:v}),(0,n.jsx)("label",{htmlFor:"default-model",children:u("def.modelField")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)(m.Y,{id:"default-model",chosen:w,onChange:e=>void b(e),none:u("def.modelNone"),catalogue:t,disabled:y||i}),(0,n.jsx)("button",{className:"quiet",onClick:()=>void b(""),disabled:y||!w,children:u("proj.clear")}),(0,n.jsx)("button",{onClick:()=>void r(),disabled:y||i,children:u("model.refresh")})]}),(0,n.jsx)(j,{msg:x||d}),(0,n.jsx)("p",{className:"muted small",style:{marginTop:8},children:(null==t?void 0:t.readAt)?u("model.readAt",{t:h(t.readAt),n:t.options.length}):u("model.neverRead")}),(0,n.jsx)("h3",{children:u("proj.affects")}),(0,n.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,n.jsx)("li",{children:u("def.modelAffectsNew")}),(0,n.jsx)("li",{children:u("def.modelAffectsExisting")}),(0,n.jsx)("li",{children:u("def.modelAffectsBatch")})]})]})}function b(e){var l,t;let{catalogue:a,setCatalogue:r,refreshModels:d,refreshing:u,refreshMsg:h}=e,{t:x}=(0,c.kj)(),[p,v]=(0,s.useState)(""),[f,y]=(0,s.useState)(""),[g,w]=(0,s.useState)(!1),b=null!=(l=null==a?void 0:a.defaultReviewModel)?l:"",N=async e=>{w(!0),v("");try{let l=await o.FH.setDefaultReviewModel(e);a&&r({...a,defaultReviewModel:l.defaultReviewModel}),v(l.defaultReviewModel?x("def.reviewSaved",{name:l.defaultReviewModel}):x("def.reviewCleared")),y("")}catch(e){y(e.message)}finally{w(!1)}},k=""!==b&&b===(null!=(t=null==a?void 0:a.defaultModel)?t:"");return(0,n.jsxs)("div",{className:"panel",id:"review",children:[(0,n.jsx)("h2",{children:x("def.reviewTitle")}),(0,n.jsx)("p",{className:"muted small",children:x("def.reviewIntro")}),f&&(0,n.jsx)("div",{className:"err",children:f}),(0,n.jsx)("label",{htmlFor:"default-review-model",children:x("def.reviewField")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)(m.Y,{id:"default-review-model",chosen:b,onChange:e=>void N(e),none:x("def.reviewNone"),catalogue:a,disabled:g||u}),(0,n.jsx)("button",{className:"quiet",onClick:()=>void N(""),disabled:g||!b,children:x("proj.clear")}),(0,n.jsx)("button",{onClick:()=>void d(),disabled:g||u,children:x("model.refresh")})]}),k&&(0,n.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:x("def.reviewSame")}),(0,n.jsx)(j,{msg:p||h}),(0,n.jsx)("h3",{children:x("proj.affects")}),(0,n.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,n.jsx)("li",{children:x("def.reviewAffectsNew")}),(0,n.jsx)("li",{children:x("def.reviewAffectsExisting")}),(0,n.jsx)("li",{children:x("def.reviewAffectsBatch")})]}),(0,n.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,n.jsx)(i(),{href:"/",className:"button-link plain",children:x("proj.toSessions")}),(0,n.jsx)(i(),{href:"/import",className:"button-link quiet",children:x("proj.toImport")})]})]})}},4784:(e,l,t)=>{"use strict";t.d(l,{Y:()=>i});var n=t(3365),s=t(1521),a=t(5549),r=t(867);function i(e){var l,t;let{id:i,chosen:o,onChange:c,none:d,catalogue:m,disabled:u=!1,style:h}=e,{t:x}=(0,r.kj)(),p=function(e){let[l,t]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(void 0!==e)return;let l=!0;return a.FH.models().then(e=>{l&&t(e)}).catch(()=>void 0),()=>{l=!1}},[e]),void 0!==e?e:l}(m),j=null!=(l=null==p?void 0:p.options)?l:[],v=j.some(e=>e.name===o),f=j.filter(e=>!e.group),y=new Map;for(let e of j)e.group&&y.set(e.group,[...null!=(t=y.get(e.group))?t:[],e]);return(0,n.jsxs)("select",{id:i,value:o,onChange:e=>c(e.target.value),disabled:u,style:{width:"auto",minWidth:280,...h},children:[(0,n.jsx)("option",{value:"",children:d}),o&&!v&&(0,n.jsx)("option",{value:o,children:x("model.notInList",{name:o})}),f.map(e=>(0,n.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(x("model.unavailable")):""]},e.name)),[...y.entries()].map(e=>{let[l,t]=e;return(0,n.jsx)("optgroup",{label:l,children:t.map(e=>(0,n.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(x("model.unavailable")):""]},e.name))},l)})]})}},4969:(e,l,t)=>{"use strict";t.d(l,{V:()=>a});var n=t(1521);let s='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function a(e,l,t){(0,n.useEffect)(()=>{var n,a;if(!l)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i=e.current,o=null!=(a=null!=(n=null==t?void 0:t.current)?n:null==i?void 0:i.querySelector(s))?a:null;null==o||o.focus();let c=e=>{if("Tab"!==e.key||!i)return;let l=Array.from(i.querySelectorAll(s)).filter(e=>null!==e.offsetParent);if(0===l.length)return;let t=l[0],n=l[l.length-1],a=i.contains(document.activeElement);e.shiftKey&&(document.activeElement===t||!a)?(e.preventDefault(),n.focus()):e.shiftKey||document.activeElement!==n&&a||(e.preventDefault(),t.focus())};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c),r&&document.contains(r)&&r.focus()}},[e,l,t])}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=1896)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1035:(e,t,n)=>{"use strict";n.d(t,{DialogHost:()=>o,Z:()=>c});var l=n(3365),a=n(1521),s=n(867),i=n(4969);let r=null,d=[];function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(n=>{var l;return l={kind:"confirm",message:e,...t,resolve:n},void(r?r(l):d.push(l))})}function o(e){var t,n;let{children:c}=e,{t:o}=(0,s.kj)(),[h,m]=(0,a.useState)([]),u=(0,a.useRef)(null),p=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(r=e=>m(t=>[...t,e]),d.length>0){let e=d.splice(0,d.length);m(t=>[...t,...e])}return()=>{r=null}},[]);let g=h[0],x=(0,a.useCallback)(e=>{g&&(g.resolve(e),m(e=>e.slice(1)))},[g]);return(0,i.V)(p,!!g,u),(0,a.useEffect)(()=>{if(!g)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),x(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g,x]),(0,l.jsxs)(l.Fragment,{children:[c,g&&(0,l.jsx)("div",{className:"modal-backdrop",onClick:()=>x(!1),role:"presentation",children:(0,l.jsxs)("div",{ref:p,className:"modal".concat(g.danger?" danger":""),role:"confirm"===g.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=g.title)?t:o("confirm"===g.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,l.jsx)("div",{id:"modal-body",className:"modal-body",children:g.message}),(0,l.jsxs)("div",{className:"row modal-actions",children:["confirm"===g.kind&&(0,l.jsx)("button",{type:"button",className:"quiet",onClick:()=>x(!1),children:o("dialog.cancel")}),(0,l.jsx)("button",{ref:u,type:"button",className:g.danger?"danger":"primary",onClick:()=>x(!0),children:null!=(n=g.okLabel)?n:o("dialog.ok")})]})]})})]})}},2114:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>u});var l=n(3365),a=n(1521),s=n(8197),i=n.n(s),r=n(5549),d=n(7527),c=n(867),o=n(1035),h=n(4811),m=n(8848);function u(){let{t:e}=(0,c.kj)(),t=(0,c.W3)(),[n,s]=(0,a.useState)(null),[h,m]=(0,a.useState)(null),[u,g]=(0,a.useState)([]),[x,b]=(0,a.useState)([]),[j,f]=(0,a.useState)([]),[v,y]=(0,a.useState)("stop"),[w,N]=(0,a.useState)(!1),[k,S]=(0,a.useState)(""),[C,F]=(0,a.useState)(""),[E,H]=(0,a.useState)(""),[T,D]=(0,a.useState)(null),[W,I]=(0,a.useState)(!1),R=(0,a.useCallback)(async()=>{try{let[e,t,n]=await Promise.all([r.FH.sessions(),r.FH.batch().catch(()=>null),r.FH.approvals().catch(()=>[])]);s(e),m(t),g(n),b(t=>t.filter(t=>e.some(e=>e.id===t))),D(!0),I(!1),H("")}catch(e){I(!(0,r.AV)()),D(!1),H(e.message)}},[]);(0,d.z)(R,3e3),(0,a.useEffect)(()=>{var e;let t=new URLSearchParams(window.location.search),n=(null!=(e=t.get("run"))?e:"").split(",").map(e=>e.trim()).filter(Boolean);0!==n.length&&(b(n),y("continue"===t.get("fail")?"continue":"stop"),N(!0),window.history.replaceState(null,"",window.location.pathname))},[]);let[U,O]=(0,a.useState)(!1),P=(0,a.useRef)(!1),q=async()=>{if(!P.current){P.current=!0,O(!0);try{let e=await r.FH.createSession(k||"session");S(""),window.location.href=(0,r.aT)(e.id)}catch(e){H(e.message),P.current=!1,O(!1)}}},L=async t=>{if(t.running)return void F(e("home.deleteRunning"));if(await (0,o.Z)(e("home.deleteConfirm",{name:t.name,n:t.tasks.length})))try{await r.FH.deleteSession(t.id),F(e("home.deleted",{name:t.name})),b(e=>e.filter(e=>e!==t.id)),await R()}catch(e){F(e.message)}},M=async()=>{let t=(null!=n?n:[]).filter(e=>j.includes(e.id)&&!e.running);if(0===t.length)return;let l=t.map(e=>"• ".concat(e.name," (").concat(e.tasks.length,")")).join("\n");if(!await (0,o.Z)(e("home.deleteSelectedConfirm",{n:t.length,names:l})))return;let a=0,s=[];for(let e of t)try{await r.FH.deleteSession(e.id),a+=1}catch(t){s.push("".concat(e.name,": ").concat(t.message))}F(0===s.length?e("home.deletedMany",{n:a}):e("home.deleteSomeFailed",{n:a,m:s.length,why:s.join("; ")})),b(e=>e.filter(e=>!t.some(t=>t.id===e))),f([]),await R()},A=async t=>{let l=(null!=n?n:[]).filter(e=>j.includes(e.id)&&!e.running);if(0===l.length)return;let a=[];for(let e of l)try{await r.FH.updateSession(e.id,{active:t})}catch(t){a.push("".concat(e.name,": ").concat(t.message))}F(0===a.length?e(t?"home.madeActive":"home.madeInactive",{n:l.length}):e("home.statusSomeFailed",{n:l.length-a.length,m:a.length,why:a.join("; ")})),t||b(e=>e.filter(e=>!l.some(t=>t.id===e))),f([]),await R()},B=t=>{if(t.running)return{label:e("state.running"),badge:"running"};let n=t.tasks.some(e=>"queued"===e.status||"running"===e.status);if("idle"!==t.status||n||0===t.tasks.length)return{label:e("state.".concat(t.status)),badge:""};let l=t.tasks.filter(e=>"done"!==e.status).length;return 0===l?{label:e("state.completed"),badge:"done",title:e("state.completedTitle")}:{label:e("state.ended"),badge:"failed",title:e("state.endedTitle",{n:l})}},_=async e=>{if(!n)return;let t=new Map(n.map(e=>[e.id,e]));s(e.map(e=>t.get(e)).filter(e=>!!e));try{s(await r.FH.reorderSessions(e)),H("")}catch(e){H(e.message),R()}},K=(e,t)=>{let l=(null!=n?n:[]).map(e=>e.id),a=l.indexOf(e),s=a+t;a<0||s<0||s>=l.length||([l[a],l[s]]=[l[s],l[a]],_(l))},[Z,z]=(0,a.useState)(null),[V,Q]=(0,a.useState)(null),G=(null!=n?n:[]).filter(e=>!e.running),J=G.filter(e=>j.includes(e.id));return(0,l.jsxs)(l.Fragment,{children:[W&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("strong",{children:e("home.noToken")}),(0,l.jsx)("div",{className:"muted small",children:e("home.noTokenHint",{cmd:"npm start"})})]}),!1===T&&!W&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("strong",{children:e("home.apiDown")}),(0,l.jsx)("div",{className:"muted small",children:e("home.apiHint",{cmd:"npm start",url:"/api"})}),E&&(0,l.jsx)("div",{className:"err",children:E})]}),(0,l.jsxs)("div",{className:"panel",id:"new-session",children:[(0,l.jsx)("h2",{children:e("home.new")}),(0,l.jsx)("p",{className:"muted small",children:e("home.newHint")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("input",{type:"text",className:"grow","aria-label":e("home.col.name"),placeholder:e("home.namePlaceholder"),value:k,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&q()}}),(0,l.jsx)("button",{className:"primary",onClick:()=>void q(),disabled:U||!1===T,children:e("home.create")})]})]}),n&&n.length>0&&(0,l.jsx)(p,{sessions:n,selected:x,setSelected:b,onFailure:v,setOnFailure:y,fromPlan:w,batch:h,approvals:u,onChange:R,move:(e,t)=>{b(n=>{let l=n.indexOf(e),a=l+t;if(l<0||a<0||a>=n.length)return n;let s=[...n];return[s[l],s[a]]=[s[a],s[l]],s})}}),(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:e("home.sessions")}),null===n&&(0,l.jsx)("div",{className:"muted",children:e("home.loading")}),n&&0===n.length&&(0,l.jsx)("div",{className:"muted",children:e("home.none")}),n&&n.length>0&&(0,l.jsxs)("div",{className:"row",style:{marginBottom:10},children:[(0,l.jsx)("strong",{className:"small",children:e("home.managed",{n:J.length})}),(0,l.jsx)("button",{onClick:()=>void A(!0),disabled:0===J.length,children:e("home.makeActive")}),(0,l.jsx)("button",{onClick:()=>void A(!1),disabled:0===J.length,children:e("home.makeInactive")}),(0,l.jsx)("button",{className:"danger",onClick:()=>void M(),disabled:0===J.length,children:e("home.deleteSelected",{n:J.length})}),(0,l.jsx)("span",{className:"muted small",children:e("home.tickForBoth")})]}),n&&n.length>0&&(0,l.jsx)("p",{className:"muted small",children:e("home.deleteWhy")}),n&&n.length>1&&(0,l.jsx)("p",{className:"muted small",children:e("home.orderWhy")}),C&&(0,l.jsx)("div",{className:"muted small",role:"status",children:C}),n&&n.length>0&&(0,l.jsxs)("table",{children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:(0,l.jsx)("input",{type:"checkbox","aria-label":e("home.manageAll"),title:e("home.manageAll"),checked:G.length>0&&G.every(e=>j.includes(e.id)),onChange:e=>f(e.target.checked?G.map(e=>e.id):[]),disabled:0===G.length})}),(0,l.jsx)("th",{children:(0,l.jsx)("input",{type:"checkbox","aria-label":e("home.selectAll"),checked:n.length>0&&x.length===n.filter(e=>!1!==e.active).length,onChange:e=>b(e.target.checked?n.filter(e=>!1!==e.active).map(e=>e.id):[]),disabled:(null==h?void 0:h.running)===!0})}),(0,l.jsx)("th",{children:e("home.col.order")}),(0,l.jsx)("th",{children:e("home.col.name")}),(0,l.jsx)("th",{children:e("home.col.tasks")}),(0,l.jsx)("th",{children:e("home.col.state")}),(0,l.jsx)("th",{children:e("home.col.chat")}),(0,l.jsx)("th",{children:e("home.col.created")}),(0,l.jsx)("th",{children:(0,l.jsx)("span",{className:"visually-hidden",children:e("home.col.remove")})})]})}),(0,l.jsx)("tbody",{children:n.map((a,s)=>{let d=a.tasks.filter(e=>"done"===e.status).length,c=a.tasks.filter(e=>"queued"===e.status).length,o=[!1===a.active?"inactive":"",Z===a.id?"dragging":"",V===a.id&&Z!==a.id?"drop-target":""].filter(Boolean).join(" ");return(0,l.jsxs)("tr",{className:o||void 0,draggable:!0,onDragStart:e=>{e.dataTransfer.setData("text/plain",a.id),e.dataTransfer.effectAllowed="move",z(a.id)},onDragOver:e=>{Z&&(e.preventDefault(),e.dataTransfer.dropEffect="move",V!==a.id&&Q(a.id))},onDrop:e=>{e.preventDefault();let t=e.dataTransfer.getData("text/plain")||Z;z(null),Q(null),t&&((e,t)=>{let l=(null!=n?n:[]).map(e=>e.id),a=l.indexOf(e),s=l.indexOf(t);a<0||s<0||a===s||(l.splice(a,1),l.splice(s,0,e),_(l))})(t,a.id)},onDragEnd:()=>{z(null),Q(null)},children:[(0,l.jsx)("td",{children:(0,l.jsx)("input",{type:"checkbox",checked:j.includes(a.id),onChange:()=>f(e=>e.includes(a.id)?e.filter(e=>e!==a.id):[...e,a.id]),disabled:!!a.running,"aria-label":e("home.manageRow",{name:a.name}),title:a.running?e("home.manageRunning"):e("home.manageRow",{name:a.name})})}),(0,l.jsx)("td",{children:(0,l.jsx)("input",{type:"checkbox",checked:x.includes(a.id),onChange:()=>{var e;return e=a.id,void b(t=>{if(t.includes(e))return t.filter(t=>t!==e);let l=(null!=n?n:[]).map(e=>e.id);return[...t,e].sort((e,t)=>l.indexOf(e)-l.indexOf(t))})},disabled:(null==h?void 0:h.running)===!0||!1===a.active,"aria-label":a.name,title:!1===a.active?e("home.inactiveWhy"):void 0})}),(0,l.jsxs)("td",{className:"order-cell",children:[(0,l.jsx)("span",{className:"drag-handle","aria-hidden":"true",title:e("home.dragHint"),children:"⠿"}),(0,l.jsx)("button",{className:"quiet small",onClick:()=>K(a.id,-1),disabled:0===s,"aria-label":e("home.moveUp",{name:a.name}),title:e("home.moveUp",{name:a.name}),children:"↑"}),(0,l.jsx)("button",{className:"quiet small",onClick:()=>K(a.id,1),disabled:s===n.length-1,"aria-label":e("home.moveDown",{name:a.name}),title:e("home.moveDown",{name:a.name}),children:"↓"})]}),(0,l.jsx)("td",{children:(0,l.jsx)(i(),{href:(0,r.aT)(a.id),children:a.name})}),(0,l.jsxs)("td",{children:[a.tasks.length," ",(0,l.jsx)("span",{className:"muted small",children:e("home.tasksDetail",{done:d,queued:c})})]}),(0,l.jsxs)("td",{children:[(0,l.jsx)("span",{className:"badge ".concat(B(a).badge),title:B(a).title,children:B(a).label})," ",(0,l.jsx)("span",{className:"chip".concat(!1===a.active?" inactive":""),title:e(!1===a.active?"home.inactiveWhy":"home.activeWhy"),children:e(!1===a.active?"home.statusInactive":"home.statusActive")})]}),(0,l.jsx)("td",{children:a.chat?(0,l.jsx)("a",{href:a.chat.url,target:"_blank",rel:"noreferrer",children:a.chat.name}):(0,l.jsx)("span",{className:"muted",children:e("home.notOpened")})}),(0,l.jsx)("td",{className:"muted small",children:t(a.createdAt)}),(0,l.jsx)("td",{children:(0,l.jsx)("button",{className:"quiet",onClick:()=>void L(a),disabled:!!a.running,title:e("home.delete"),children:e("home.delete")})})]},a.id)})})]})]})]})}function p(e){var t,n,s,d,u,p,g;let{sessions:x,selected:b,setSelected:j,onFailure:f,setOnFailure:v,fromPlan:y,batch:w,approvals:N,onChange:k,move:S}=e,{t:C}=(0,c.kj)(),[F,E]=(0,a.useState)(""),[H,T]=(0,a.useState)(""),[D,W]=(0,a.useState)(""),[I,R]=(0,a.useState)(""),[U,O]=(0,a.useState)(""),[P,q]=(0,a.useState)(null),[L,M]=(0,a.useState)([]);(0,a.useEffect)(()=>{r.FH.models().then(e=>{q(e),W(t=>t||e.defaultModel),R(t=>t||e.defaultReviewModel)}).catch(()=>void 0)},[]);let A=b.join(",");(0,a.useEffect)(()=>{let e=!1,t=A.split(",").filter(Boolean);if(0===t.length)return void M([]);let n=async()=>{let n=await Promise.all(t.map(async e=>{let t=await r.FH.vcsStatus(e).catch(()=>null);return{id:e,status:t}}));e||M(n.filter(e=>e.status&&!e.status.ok&&"off"!==e.status.problem).map(e=>{var t,n,l,a;return{name:null!=(l=null==(t=x.find(t=>t.id===e.id))?void 0:t.name)?l:e.id,problem:null!=(a=null==(n=e.status)?void 0:n.problem)?a:""}}))};n();let l=setInterval(()=>void n(),1e4);return()=>{e=!0,clearInterval(l)}},[A]);let B=new Map(x.map(e=>[e.id,e])),_=e=>e.tasks.filter(e=>"queued"===e.status).length,K=b.map(e=>B.get(e)).filter(e=>!!e),Z=K.filter(e=>_(e)>0&&!1!==e.active),z=Z.reduce((e,t)=>e+_(t),0),V=(null==w?void 0:w.running)===!0,Q=x.some(e=>e.running),G=V||0===Z.length||Q,J=Q?{title:"batch.oneRunning",why:"batch.oneRunningWhy"}:0===K.length?{title:"batch.pickFirst",why:"batch.pickFirstWhy"}:0===Z.length?{title:"batch.nothingRunnable",why:"batch.nothingRunnableWhy"}:null,X=(0,h.p)(),[Y,$]=(0,a.useState)(!1),ee=(0,a.useRef)(!1),et=async e=>{if(!ee.current){ee.current=!0,$(!0);try{await e()}catch(e){T(e.message)}finally{ee.current=!1,$(!1),k()}}},en=async e=>{("unattended"!==e||X||await (0,o.Z)(C("batch.unattendedConfirm",{n:Z.length})))&&await et(async()=>{var t;let n=await r.FH.startBatch(Z.map(e=>e.id),e,f,D||void 0,I||void 0,U.trim()||Z.map(e=>e.planName).find(Boolean)||void 0);E(""),T(n.started?"":null!=(t=n.reason)?t:"")})},el=K.filter(e=>{var t;return(null!=(t=e.model)?t:"")!==D}).length,ea=K.filter(e=>{var t;return(null==(t=e.review)?void 0:t.enabled)===!1}).length,es=null!=(s=null==P?void 0:P.options)?s:[],ei=es.filter(e=>!e.group),er=new Map;for(let e of es)e.group&&er.set(e.group,[...null!=(d=er.get(e.group))?d:[],e]);let ed=w?{done:w.sessions.filter(e=>"done"===e.state).length,failed:w.sessions.filter(e=>"failed"===e.state).length,skipped:w.sessions.filter(e=>"skipped"===e.state||"stopped"===e.state).length}:null,ec=null==w?void 0:w.sessions.find(e=>"running"===e.state);return(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:C("batch.title")}),(0,l.jsx)("p",{className:"muted small",children:C("batch.hint")}),!V&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("strong",{className:"small",children:C("batch.selected",{n:Z.length,tasks:z})}),(0,l.jsx)("button",{className:"quiet",onClick:()=>j(x.filter(e=>_(e)>0).map(e=>e.id)),children:C("batch.selectQueued")}),(0,l.jsx)("button",{className:"quiet",onClick:()=>j([]),disabled:0===K.length,children:C("batch.selectNone")})]}),y&&(0,l.jsx)("p",{className:"muted small",children:C("batch.fromPlan")}),K.length>Z.length&&(0,l.jsx)("p",{className:"muted small",children:C("batch.notRunnable",{n:K.length-Z.length})}),Z.length>0&&(0,l.jsx)("ol",{className:"run-order",children:Z.map((e,t)=>(0,l.jsxs)("li",{children:[(0,l.jsxs)("span",{children:[e.name," ",(0,l.jsxs)("span",{className:"muted small",children:["(",_(e),")"]})]}),(0,l.jsxs)("span",{children:[(0,l.jsx)("button",{className:"quiet",onClick:()=>S(e.id,-1),disabled:0===t,"aria-label":C("batch.moveUp",{name:e.name}),children:"↑"}),(0,l.jsx)("button",{className:"quiet",onClick:()=>S(e.id,1),disabled:t===Z.length-1,"aria-label":C("batch.moveDown",{name:e.name}),children:"↓"})]})]},e.id))}),(0,l.jsx)("label",{htmlFor:"batch-run-name",children:C("batch.runName")}),(0,l.jsx)("input",{id:"batch-run-name",type:"text",value:U,onChange:e=>O(e.target.value),placeholder:null!=(u=Z.map(e=>e.planName).find(Boolean))?u:C("batch.runNamePlaceholder")}),(0,l.jsx)("p",{className:"why",children:C("batch.runNameWhy")}),(0,l.jsx)("label",{htmlFor:"batch-model",children:C("batch.model")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsxs)("select",{id:"batch-model",value:D,onChange:e=>W(e.target.value),style:{width:"auto",minWidth:260},children:[(0,l.jsx)("option",{value:"",children:C("batch.modelKeep")}),ei.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...er.entries()].map(e=>{let[t,n]=e;return(0,l.jsx)("optgroup",{label:t,children:n.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},t)})]}),(null!=(p=null==P?void 0:P.options.length)?p:0)===0&&(0,l.jsx)("span",{className:"muted small",children:C("batch.modelNone")})]}),(0,l.jsx)("p",{className:"why",children:C("batch.modelWhy")}),(0,l.jsx)(m.L,{current:D,onUse:e=>W(e)}),D&&el>0&&(0,l.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:C("batch.modelOverrides",{n:el})}),(0,l.jsx)("label",{htmlFor:"batch-review-model",children:C("batch.reviewModel")}),(0,l.jsx)("div",{className:"row",children:(0,l.jsxs)("select",{id:"batch-review-model",value:I,onChange:e=>R(e.target.value),style:{width:"auto",minWidth:260},children:[(0,l.jsx)("option",{value:"",children:C("batch.reviewModelKeep")}),ei.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...er.entries()].map(e=>{let[t,n]=e;return(0,l.jsx)("optgroup",{label:t,children:n.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},t)})]})}),(0,l.jsx)("p",{className:"why",children:C("batch.reviewModelWhy")}),""!==I&&I===D&&(0,l.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:C("batch.reviewSame")}),ea>0&&(0,l.jsx)("p",{className:"why",children:C("batch.reviewOffIn",{n:ea})}),(0,l.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,l.jsx)("legend",{className:"muted small",style:{padding:0},children:C("batch.onFailure")}),(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:"batch-fail",checked:"stop"===f,onChange:()=>v("stop")}),(0,l.jsx)("span",{children:C("batch.chain")})]}),(0,l.jsx)("p",{className:"why",children:C("batch.chainWhy")})]}),(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:"batch-fail",checked:"continue"===f,onChange:()=>v("continue")}),(0,l.jsx)("span",{children:C("batch.independent")})]}),(0,l.jsx)("p",{className:"why",children:C("batch.independentWhy")})]})]}),J&&(0,l.jsxs)("div",{className:"notice caution",children:[(0,l.jsx)("strong",{children:C(J.title)}),(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:C(J.why)})]}),L.length>0&&(0,l.jsxs)("div",{className:"notice caution",children:[(0,l.jsx)("strong",{children:C("batch.vcsProblem")}),(0,l.jsx)("ul",{children:L.map(e=>(0,l.jsx)("li",{children:C("batch.vcsProblemRow",{name:e.name,problem:e.problem})},e.name))}),(0,l.jsx)("div",{className:"muted small",children:C("batch.vcsProblemWhy")})]}),H&&(0,l.jsxs)("div",{className:"notice caution",role:"alert",children:[(0,l.jsx)("strong",{children:C("batch.notStartedTitle")}),(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:H}),/execution\.isolation/.test(H)&&(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:(0,l.jsx)(i(),{href:"/defaults",children:C("batch.notStartedIsolation")})})]}),(0,l.jsxs)("div",{className:"run-choice",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("button",{className:"primary",onClick:()=>void en("unattended"),disabled:Y||G,children:C("batch.run",{n:Z.length})}),(0,l.jsx)("p",{className:"why",children:C("batch.runWhy")})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("button",{onClick:()=>void en("confirm"),disabled:Y||G,children:C("batch.runStep")}),(0,l.jsx)("p",{className:"why",children:C("batch.runStepWhy")})]})]})]}),V&&(0,l.jsxs)("div",{className:"row",children:[(null==w?void 0:w.pausing)?(0,l.jsx)("button",{className:"primary",onClick:()=>void et(async()=>{await r.FH.resumeBatch(),E("")}),disabled:Y||(null==w?void 0:w.stopping),title:C("batch.resumeWhy"),children:C("batch.resume")}):(0,l.jsx)("button",{onClick:()=>void et(async()=>{await r.FH.pauseBatch(),E(C("batch.pausing"))}),disabled:Y||(null==w?void 0:w.stopping),title:C("batch.pauseWhy"),children:C("batch.pause")}),(0,l.jsx)("button",{onClick:()=>void et(async()=>{await r.FH.stopBatch(),E(C("batch.stopping"))}),disabled:Y||(null==w?void 0:w.stopping),title:C("batch.stopWhy"),children:C("batch.stop")}),(null==w?void 0:w.pausing)&&!(null==w?void 0:w.stopping)&&(0,l.jsx)("span",{className:"muted small",children:C("batch.pausing")}),(0,l.jsx)("span",{className:"badge",children:C("batch.modelRunning",{name:(ec?(null==(t=B.get(ec.sessionId))?void 0:t.modelInUse)||(null==(n=B.get(ec.sessionId))?void 0:n.model):"")||C("model.default")})}),N.length>0&&(0,l.jsx)("span",{className:"badge waiting-approval",children:C("batch.waiting",{n:N.length})}),ec&&(0,l.jsx)("span",{className:"small",children:C("batch.progress",{name:ec.name,done:w.sessions.filter(e=>"waiting"!==e.state&&"running"!==e.state).length,total:w.sessions.length})})]}),V&&(0,l.jsx)("p",{className:"muted small",children:C("batch.hiddenWhileRunning")}),F&&(0,l.jsx)("div",{className:"muted small",role:"status",children:F}),(K.length>0||w)&&(0,l.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,l.jsx)("a",{className:"button-link",href:r.FH.debugExportUrl(K.length>0?K.map(e=>e.id):(null!=(g=null==w?void 0:w.sessions)?g:[]).map(e=>e.sessionId)),children:C("batch.debug")}),(0,l.jsx)("span",{className:"muted small",children:K.length>0?C("batch.debugSelected",{n:K.length}):C("batch.debugLast")})]}),(K.length>0||w)&&(0,l.jsx)("p",{className:"why",children:C("batch.debugWhy")}),w&&(0,l.jsxs)(l.Fragment,{children:[!V&&ed&&(0,l.jsx)("div",{className:"notice calm",style:{marginTop:12},children:(0,l.jsx)("strong",{children:C("batch.finished",ed)})}),(0,l.jsxs)("table",{style:{marginTop:10},children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:C("batch.col.session")}),(0,l.jsx)("th",{children:C("batch.col.state")}),(0,l.jsx)("th",{children:C("batch.col.ran")}),(0,l.jsx)("th",{children:C("batch.col.why")})]})}),(0,l.jsx)("tbody",{children:w.sessions.map(e=>{var t,n;return(0,l.jsxs)("tr",{className:"batch-row ".concat(e.state),children:[(0,l.jsx)("td",{children:(0,l.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:e.name})}),(0,l.jsx)("td",{children:(0,l.jsx)("span",{className:"badge ".concat("running"===(n=e.state)?"running":"done"===n?"done":"failed"===n?"failed":"stopped"===n?"aborted":""),children:C("batch.state.".concat(e.state))})}),(0,l.jsx)("td",{className:"small",children:C("batch.ranOf",{ran:e.ran,failed:e.failed})}),(0,l.jsx)("td",{className:"muted small",children:null!=(t=e.reason)?t:""})]},e.sessionId)})})]})]})]})}},4811:(e,t,n)=>{"use strict";n.d(t,{p:()=>s});var l=n(1521),a=n(5549);function s(){let[e,t]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let e=!0;return a.FH.settings().then(n=>{var l;let a=null!=(l=n.raw.execution)?l:{};e&&t("unattended"===a.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},4969:(e,t,n)=>{"use strict";n.d(t,{V:()=>s});var l=n(1521);let a='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function s(e,t,n){(0,l.useEffect)(()=>{var l,s;if(!t)return;let i=document.activeElement instanceof HTMLElement?document.activeElement:null,r=e.current,d=null!=(s=null!=(l=null==n?void 0:n.current)?l:null==r?void 0:r.querySelector(a))?s:null;null==d||d.focus();let c=e=>{if("Tab"!==e.key||!r)return;let t=Array.from(r.querySelectorAll(a)).filter(e=>null!==e.offsetParent);if(0===t.length)return;let n=t[0],l=t[t.length-1],s=r.contains(document.activeElement);e.shiftKey&&(document.activeElement===n||!s)?(e.preventDefault(),l.focus()):e.shiftKey||document.activeElement!==l&&s||(e.preventDefault(),n.focus())};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c),i&&document.contains(i)&&i.focus()}},[e,t,n])}},5704:(e,t,n)=>{Promise.resolve().then(n.bind(n,2114))},7527:(e,t,n)=>{"use strict";n.d(t,{z:()=>a});var l=n(1521);function a(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=(0,l.useRef)(e);a.current=e,(0,l.useEffect)(()=>{let e;if(!n)return;let l=!1,s=async()=>{try{await a.current()}catch(e){}finally{l||(e=setTimeout(()=>void s(),t))}};return s(),()=>{l=!0,e&&clearTimeout(e)}},[t,n])}},8848:(e,t,n)=>{"use strict";n.d(t,{H4:()=>c,L:()=>o,z4:()=>h});var l=n(3365),a=n(8197),s=n.n(a),i=n(1521),r=n(5549),d=n(867);function c(e){let{current:t,onUse:n}=e,{t:a}=(0,d.kj)(),[s,c]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return r.FH.project().then(t=>{e||c(t)}).catch(()=>void 0),()=>{e=!0}},[]),!s)return null;let o=s.rootDir.trim(),h=t.trim().toLowerCase(),m=n?s.others.filter(e=>e.rootDir.trim().toLowerCase()!==h):[];return(0,l.jsx)(u,{label:o?a("proj.defaultIs",{dir:o}):a("proj.noneShort"),offer:o&&n&&h!==o.toLowerCase()?{text:a("proj.useIt"),onUse:()=>n(o)}:void 0,more:m.map(e=>({text:a("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==n?void 0:n(e.rootDir)})),link:o?a("proj.change"):a("proj.setIt"),anchor:"project"})}function o(e){let{current:t,onUse:n}=e,a=m(),{t:s}=(0,d.kj)();if(!a)return null;let i=a.defaultModel.trim();return(0,l.jsx)(u,{label:i?s("def.modelDefaultIs",{name:i}):s("def.modelNoneShort"),offer:i&&n&&t.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"model"})}function h(e){let{current:t,onUse:n}=e,a=m(),{t:s}=(0,d.kj)();if(!a)return null;let i=a.defaultReviewModel.trim();return(0,l.jsx)(u,{label:i?s("def.reviewDefaultIs",{name:i}):s("def.reviewNoneShort"),offer:i&&n&&t.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"review"})}function m(){let[e,t]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return r.FH.models().then(n=>{e||t(n)}).catch(()=>void 0),()=>{e=!0}},[]),e}function u(e){let{label:t,offer:n,more:a=[],link:i,anchor:r}=e;return(0,l.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[t," ",n&&(0,l.jsxs)(l.Fragment,{children:["\xb7"," ",(0,l.jsx)("button",{type:"button",className:"linkish",onClick:n.onUse,children:n.text})," "]}),a.map(e=>(0,l.jsxs)("span",{children:["\xb7"," ",(0,l.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,l.jsx)(s(),{href:"/defaults#".concat(r),children:i})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=5704)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[66],{1702:(e,s,n)=>{"use strict";var a=n(9962);n.o(a,"usePathname")&&n.d(s,{usePathname:function(){return a.usePathname}}),n.o(a,"useSearchParams")&&n.d(s,{useSearchParams:function(){return a.useSearchParams}})},1772:(e,s,n)=>{Promise.resolve().then(n.bind(n,2438))},2285:(e,s,n)=>{"use strict";n.d(s,{b:()=>r});var a=n(3365),t=n(1521),l=n(5549),i=n(867);function r(e){var s,n;let{dir:r}=e,{t:c}=(0,i.kj)(),d=(0,i.W3)(),[o,h]=(0,t.useState)(null),[u,m]=(0,t.useState)(""),[p,v]=(0,t.useState)(""),x=async()=>{m("");try{h(await l.FH.syncPlan(r))}catch(e){m(e.message)}},j=async(e,s)=>{try{await navigator.clipboard.writeText(s),v(e),window.setTimeout(()=>v(""),2500)}catch(e){m(c("plan.copyFailed"))}},g=e=>(0,a.jsxs)("ul",{style:{margin:"2px 0 6px",paddingLeft:20},children:[e.slice(0,30).map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e)),e.length>30&&(0,a.jsx)("li",{className:"muted",children:c("sync.more",{n:e.length-30})})]});return(0,a.jsxs)("div",{className:"sync-command small",style:{marginTop:8},children:[(0,a.jsx)("button",{type:"button",onClick:()=>void x(),children:c("sync.show")}),u&&(0,a.jsx)("p",{className:"err",children:u}),o&&!o.ok&&(0,a.jsx)("p",{className:"err",children:o.problem}),(null==o?void 0:o.ok)&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsxs)("p",{children:[c("sync.what",{branch:null!=(s=o.branch)?s:"",target:null!=(n=o.target)?n:""})," ",(0,a.jsx)("span",{className:"muted",children:o.lastFetched?c("sync.fetchedAt",{when:d(o.lastFetched)}):c("sync.neverFetched")})]}),o.willLose.commits.length+o.willLose.changed.length+o.willLose.untracked.length===0?(0,a.jsx)("p",{children:c("sync.nothingLost")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("strong",{children:c("sync.loses")}),o.willLose.commits.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{children:c("sync.commits",{n:o.willLose.commits.length})}),g(o.willLose.commits)]}),o.willLose.changed.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{children:c("sync.changed",{n:o.willLose.changed.length})}),g(o.willLose.changed)]}),o.willLose.untracked.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{children:c("sync.untracked",{n:o.willLose.untracked.length})}),g(o.willLose.untracked)]})]}),(0,a.jsx)("p",{className:"muted",children:c("sync.keeps")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",onClick:()=>void j("preview",o.preview),children:c("sync.copyPreview")}),"preview"===p&&(0,a.jsx)("span",{className:"badge done",children:c("plan.copied")})]}),(0,a.jsx)("pre",{className:"sync-cmd",children:o.preview}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"danger",onClick:()=>void j("command",o.command),children:c("sync.copyCommand")}),"command"===p&&(0,a.jsx)("span",{className:"badge done",children:c("plan.copied")})]}),(0,a.jsx)("pre",{className:"sync-cmd",children:o.command}),(0,a.jsx)("p",{className:"muted",children:c("sync.howToRun")})]})]})}},2438:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>S});var a=n(3365),t=n(1521),l=n(1702),i=n(8197),r=n.n(i),c=n(5549),d=n(867),o=n(1910),h=n(3523),u=n(3374),m=n(8078),p=n(8848),v=n(4784),x=n(2876),j=n(5132),g=n(1035),y=n(8934),f=n(4811),b=n(3041),k=n(7527),N=n(1366),w=n(2285);function S(){return(0,a.jsx)(t.Suspense,{fallback:null,children:(0,a.jsx)(C,{})})}function C(){var e;let{t:s}=(0,d.kj)(),n=null!=(e=(0,l.useSearchParams)().get("id"))?e:"",[i,o]=(0,t.useState)(null),[h,u]=(0,t.useState)([]),[m,p]=(0,t.useState)([]),[v,x]=(0,t.useState)(null),[j,g]=(0,t.useState)(""),[y,f]=(0,t.useState)(!1),b=(0,t.useRef)(null),N=(0,t.useRef)(0),w=(0,t.useCallback)(async()=>{if(!n)return;let e=++N.current;try{let s=await c.FH.session(n);if(e!==N.current)return;o(s),g("")}catch(s){if(e!==N.current)return;g(s.message)}},[n]),S=(0,t.useCallback)(()=>{b.current||(b.current=window.setTimeout(()=>{b.current=null,w()},400))},[w]);if((0,t.useEffect)(()=>{if(!n)return;c.FH.presets().then(p).catch(()=>void 0),c.FH.level1().then(x).catch(()=>void 0);let e=new EventSource(c.FH.streamUrl(n));return e.onopen=()=>f(!1),e.onmessage=e=>{let s;try{s=JSON.parse(e.data)}catch(e){return}"ping"!==s.type&&(u(e=>[...e.slice(-400),s]),S())},e.onerror=()=>{e.readyState===EventSource.CLOSED&&f(!0)},()=>{e.close()}},[n,S]),(0,k.z)(w,8e3,!!n),!n)return(0,a.jsx)("div",{className:"panel err",children:s("session.noId")});if(j&&!i)return(0,a.jsx)("div",{className:"panel err",children:j});if(!i)return(0,a.jsx)("div",{className:"panel muted",children:s("home.loading")});let C=i.tasks.filter(e=>"queued"===e.status).length;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"crumbs",children:[(0,a.jsx)(r(),{href:"/",children:s("session.crumb")})," / ",i.name]}),j&&(0,a.jsx)("div",{className:"panel err",role:"alert",children:s("session.stale",{err:j})}),y&&!j&&(0,a.jsx)("div",{className:"panel muted small",role:"status",children:s("session.streamClosed")}),(0,a.jsx)(F,{session:i,queued:C,onChange:w}),(0,a.jsx)(q,{tasks:i.tasks}),(0,a.jsx)(T,{session:i,onChange:w}),(0,a.jsx)(I,{level1:v,sent:i.contractSent}),(0,a.jsx)(H,{session:i,onChange:w}),(0,a.jsx)(L,{session:i,onChange:w}),(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:s("tasks.title")}),(0,a.jsx)("p",{className:"muted small",children:s("tasks.hint")}),(0,a.jsx)(M,{session:i,onChange:w}),0===i.tasks.length&&(0,a.jsx)("div",{className:"muted",children:s("tasks.none")}),i.tasks.map((e,s)=>(0,a.jsx)(D,{session:i,task:e,index:s+1,presets:m,onChange:w},e.id))]}),(0,a.jsx)(P,{session:i}),(0,a.jsx)(B,{session:i,presets:m,onAdded:w,onPresetsChanged:()=>c.FH.presets().then(p)}),(0,a.jsx)(A,{events:h})]})}function F(e){var s;let{session:n,queued:l,onChange:i}=e,{t:r}=(0,d.kj)(),[o,h]=(0,t.useState)(""),[u,m]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(e=>{var s;return m(null!=(s=e.defaultModel)?s:"")}).catch(()=>void 0)},[]);let[p,v]=(0,t.useState)(n.name),[x,j]=(0,t.useState)(null!=(s=n.conversationGroup)?s:"");(0,t.useEffect)(()=>v(n.name),[n.name]),(0,t.useEffect)(()=>{var e;return j(null!=(e=n.conversationGroup)?e:"")},[n.conversationGroup]);let y=(0,f.p)(),[b,k]=(0,t.useState)(!1),N=(0,t.useRef)(!1),w=async e=>{if(!N.current){N.current=!0,k(!0);try{await e()}catch(e){h(e.message)}finally{N.current=!1,k(!1),i()}}},S=async e=>{("unattended"!==e||y||await (0,g.Z)(r("session.unattendedConfirm")))&&await w(async()=>{var s;let a=await c.FH.start(n.id,e,n.planName);h(a.started?r("unattended"===e?"session.startedAuto":"session.startedStep"):r("session.notStarted",{reason:null!=(s=a.reason)?s:""}))})},C=async()=>{if(n.running)return void h(r("home.deleteRunning"));if(await (0,g.Z)(r("home.deleteConfirm",{name:n.name,n:n.tasks.length})))try{await c.FH.deleteSession(n.id),window.location.href="/"}catch(e){h(e.message)}},F=async()=>{var e;if(x.trim()!==(null!=(e=n.conversationGroup)?e:""))try{await c.FH.updateSession(n.id,{conversationGroup:x.trim()}),h(r("session.groupSaved")),i()}catch(e){h(e.message)}},I=n.running?r("state.running"):r("state.".concat(n.status));return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{type:"text",className:"grow","aria-label":r("home.col.name"),value:p,onChange:e=>v(e.target.value),onBlur:()=>void w(async()=>{p.trim()&&p!==n.name&&await c.FH.updateSession(n.id,{name:p})})}),(0,a.jsx)("span",{className:"badge ".concat(n.running?"running":""),children:I})]}),!n.running&&(0,a.jsxs)("div",{className:"run-choice",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void S("unattended"),disabled:b||0===l,children:r("session.run",{n:l})}),(0,a.jsx)("p",{className:"why",children:r("session.runWhy")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{onClick:()=>void S("confirm"),disabled:b||0===l,children:r("session.runStep")}),(0,a.jsx)("p",{className:"why",children:r("session.runStepWhy")})]})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[n.running&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"danger",onClick:()=>void w(async()=>{await c.FH.stop(n.id),h(r("session.stopping"))}),disabled:b,children:r("session.stop")}),"unattended"===n.runMode&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"badge waiting-approval",children:r("session.modeUnattended")}),(0,a.jsx)("button",{onClick:()=>void w(async()=>{await c.FH.setRunMode(n.id,"confirm"),h(r("session.askingAgain"))}),disabled:b,children:r("session.askAgain")})]})]}),(0,a.jsx)("span",{className:"muted small",children:o}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{className:"quiet",onClick:()=>void C(),disabled:n.running,children:r("home.delete")}),n.chat?(0,a.jsx)("a",{href:n.chat.url,target:"_blank",rel:"noreferrer",className:"small",children:r("session.openChat",{name:n.chat.name})}):(0,a.jsx)("span",{className:"muted small",children:r("session.noChat")})]}),(0,a.jsx)("label",{htmlFor:"session-group",children:r("session.group")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)("input",{id:"session-group",type:"text",className:"grow",value:x,placeholder:r("session.groupPlaceholder"),onChange:e=>j(e.target.value),onBlur:()=>void F(),disabled:n.running})}),(0,a.jsxs)("p",{className:"why",children:[r("session.groupWhy"),n.chat&&" ".concat(r("session.groupHasChat"))]}),(0,a.jsx)("div",{className:"muted small",style:{marginTop:10},children:r("session.willUseModel",{name:n.model||(u?r("model.followsDefault",{name:u}):r("model.default"))})})]})}function I(e){var s;let{level1:n,sent:t}=e,{t:l}=(0,d.kj)();return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:l("l1.title")}),(0,a.jsx)("span",{className:"badge",children:l(t?"l1.sent":"l1.notSent")}),(0,a.jsx)(r(),{href:"/level1",className:"small",children:l("l1.edit")})]}),(0,a.jsxs)("p",{className:"muted small",style:{marginBottom:6},children:[l("l1.hint"),(null==n?void 0:n.customised)?" ".concat(l("l1.customised")):""]}),(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:l("l1.show")}),(0,a.jsx)("pre",{className:"tall",children:null!=(s=null==n?void 0:n.content)?s:"…"})]})]})}function T(e){var s,n,l,i;let{session:r,onChange:o}=e,{t:h}=(0,d.kj)(),u=(0,d.W3)(),[m,v]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[y,f]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(v).catch(()=>void 0)},[]);let b=async e=>{try{await c.FH.updateSession(r.id,{model:e}),f(e?h("model.saved",{name:e}):h("model.savedDefault")),o()}catch(e){f(e.message)}},k=async()=>{try{let e=await c.FH.setDefaultModel(w);v(s=>s?{...s,defaultModel:e.defaultModel}:s),f(e.defaultModel?h("model.defaultSaved",{name:e.defaultModel}):h("model.defaultCleared"))}catch(e){f(e.message)}},N=async()=>{if(await (0,g.Z)(h("model.refreshConfirm"))){j(!0),f(h("model.refreshing"));try{var e;let s=await c.FH.refreshModels();v(s),f(0===s.options.length?null!=(e=s.note)?e:h("model.none"):h("model.refreshed",{n:s.options.length}))}catch(e){f(e.message)}finally{j(!1)}}},w=null!=(s=r.model)?s:"",S=null!=(n=null==m?void 0:m.options)?n:[],C=S.some(e=>e.name===w),F=S.filter(e=>!e.group),I=new Map;for(let e of S)e.group&&I.set(e.group,[...null!=(l=I.get(e.group))?l:[],e]);return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:h("model.title")}),r.modelInUse&&(0,a.jsx)("span",{className:"chip",children:h("model.lastUsed",{name:r.modelInUse})})]}),(0,a.jsx)("p",{className:"muted small",children:h("model.hint")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("select",{"aria-label":h("model.title"),value:w,disabled:r.running,onChange:e=>void b(e.target.value),style:{width:"auto",minWidth:260},children:[(0,a.jsx)("option",{value:"",children:(null==m?void 0:m.defaultModel)?h("model.followsDefault",{name:m.defaultModel}):h("model.default")}),w&&!C&&(0,a.jsx)("option",{value:w,children:h("model.notInList",{name:w})}),F.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(h("model.unavailable")):""]},e.name)),[...I.entries()].map(e=>{let[s,n]=e;return(0,a.jsx)("optgroup",{label:s,children:n.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(h("model.unavailable")):""]},e.name))},s)})]}),(0,a.jsx)("button",{onClick:()=>void N(),disabled:x||r.running,children:h("model.refresh")}),(0,a.jsx)("span",{className:"muted small",role:"status",children:y})]}),(0,a.jsx)(p.L,{current:w,onUse:e=>void b(e)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("span",{className:"muted small",children:(null==m?void 0:m.defaultModel)?h("model.defaultIs",{name:m.defaultModel}):h("model.defaultIsNone")}),(0,a.jsx)("button",{onClick:()=>void k(),disabled:w===(null!=(i=null==m?void 0:m.defaultModel)?i:""),children:w?h("model.makeDefault",{name:w}):h("model.clearDefault")})]}),(null==m?void 0:m.readAt)?(0,a.jsxs)("p",{className:"muted small",style:{marginTop:8},children:[h("model.readAt",{t:u(m.readAt),n:m.options.length}),m.current?" ".concat(h("model.chatWasOn",{name:m.current})):"",m.note?" ".concat(m.note):""]}):(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:h("model.neverRead")}),S.length>0&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:h("model.showDetails")}),(0,a.jsx)("pre",{className:"tall",children:S.map(e=>"".concat(e.selected?"*":" "," ").concat(e.group?"".concat(e.group," > "):"").concat(e.name)+"".concat(e.disabled?" [unavailable]":"","\n ").concat(e.raw.replace(/\n/g," | "))).join("\n")})]})]})}function L(e){var s,n;let{session:l,onChange:i}=e,{t:r}=(0,d.kj)(),o=null!=(s=l.review)?s:{enabled:!0,model:""},[h,u]=(0,t.useState)(o.enabled),[m,x]=(0,t.useState)(null!=(n=o.model)?n:""),[j,g]=(0,t.useState)(""),[y,f]=(0,t.useState)(!1),[b,k]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(e=>{var s;return k(null!=(s=e.defaultReviewModel)?s:"")}).catch(()=>void 0)},[]);let N=async()=>{f(!0),g("");try{await c.FH.updateSession(l.id,{review:{enabled:h,model:m}}),g(r("review.saved")),i()}catch(e){g(e.message)}finally{f(!1)}};return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:r("review.title")}),(0,a.jsx)("span",{className:"badge ".concat(h?"done":""),children:h?r("review.on"):r("review.off")})]}),(0,a.jsx)("p",{className:"muted small",children:r("review.hint")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:h,onChange:e=>u(e.target.checked),disabled:l.running}),(0,a.jsx)("span",{children:r("review.enable")})]}),(0,a.jsx)("p",{className:"why",children:r("review.enableWhy")})]}),(0,a.jsx)("label",{htmlFor:"review-model",children:r("review.modelField")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)(v.Y,{id:"review-model",chosen:m,onChange:x,none:b?r("model.followsDefault",{name:b}):r("review.modelSame"),disabled:l.running||!h})}),(0,a.jsx)("p",{className:"why",children:r("review.modelWhy")}),(0,a.jsx)(p.z4,{current:m,onUse:e=>x(e)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void N(),disabled:y||l.running,children:r("review.save")}),j&&(0,a.jsx)("span",{className:"muted small",children:j})]})]})}function W(e){var s;let{session:n,plan:l,onDone:i}=e,{t:r}=(0,d.kj)(),o=()=>Object.fromEntries(l.entries.filter(e=>e.choice).map(e=>[e.path,e.choice])),h=JSON.stringify(l.entries.map(e=>[e.path,e.choice])),[u,m]=(0,t.useState)(o);(0,t.useEffect)(()=>m(o()),[h]);let[p,v]=(0,t.useState)(!1),[x,j]=(0,t.useState)(""),g=l.entries.filter(e=>"include"===u[e.path]).length,y=async()=>{v(!0),j("");try{var e,s,a;let t=await c.FH.vcsSnapshot(n.id,u);j(t.ok?r("vcs.snapshotTaken",{branch:null!=(e=t.branch)?e:"",commit:(null!=(s=t.commit)?s:"").slice(0,8)}):null!=(a=t.problem)?a:""),i()}catch(e){j(e.message)}finally{v(!1)}};return(0,a.jsxs)("div",{className:"option",children:[(0,a.jsx)("p",{className:"small",children:r("vcs.snapshotList",{n:l.entries.length,branch:null!=(s=l.baselineBranch)?s:"—"})}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:l.entries.map(e=>{var s;return(0,a.jsxs)("li",{style:{marginBottom:4,overflowWrap:"anywhere"},children:[(0,a.jsx)("code",{children:e.path})," ",(0,a.jsxs)("span",{className:"muted small",children:["(",e.input?"".concat(r("vcs.snapshotInput"),", "):"",r("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,c.zi)(e.size)):"",")"]})," ",0===e.allowed.length?(0,a.jsx)("span",{className:"err small",children:r("vcs.snapshotBlocked")}):(0,a.jsx)("select",{"aria-label":e.path,value:null!=(s=u[e.path])?s:"",onChange:s=>m({...u,[e.path]:s.target.value}),disabled:p||n.running||e.allowed.length<2,children:e.allowed.map(e=>(0,a.jsx)("option",{value:e,children:r("include"===e?"vcs.snapshotInclude":"vcs.snapshotLeaveOut")},e))}),e.reason&&(0,a.jsx)("div",{className:"muted small",children:e.reason})]},e.path)})}),(0,a.jsx)("button",{className:"primary",onClick:()=>void y(),disabled:p||n.running||!l.ok||0===g,children:r("vcs.snapshotTake")}),(0,a.jsx)("p",{className:"why",children:r("vcs.snapshotCancelWhy")}),x&&(0,a.jsx)("p",{className:"small",role:"status",children:x})]})}function H(e){var s,n,l,i,r,o,h,u,m,v,x,j,g,y,f,b,k,N,S,C,F,I,T,L,H,M,R,P,O,B,D,A,E,q,U,J;let{session:z,onChange:G}=e,{t:Z}=(0,d.kj)(),K=null!=(g=z.vcs)?g:{enabled:!0,repoDir:"",branchMode:"per-task",commitOnFinish:!0,branchPrefix:"cop/"},[_,Y]=(0,t.useState)(K.repoDir),[Q,V]=(0,t.useState)(null),[X,$]=(0,t.useState)(""),[ee,es]=(0,t.useState)(!1),en=JSON.stringify(K),[ea,et]=(0,t.useState)(null),[el,ei]=(0,t.useState)(null!=(y=K.branchName)?y:"");(0,t.useEffect)(()=>{var e;return ei(null!=(e=JSON.parse(en).branchName)?e:"")},[en]);let[er,ec]=(0,t.useState)(null!=(f=K.baseBranch)?f:"");(0,t.useEffect)(()=>{var e;return ec(null!=(e=JSON.parse(en).baseBranch)?e:"")},[en]);let[ed,eo]=(0,t.useState)((null!=(b=null==(s=K.userInputs)?void 0:s.paths)?b:[]).join("\n"));(0,t.useEffect)(()=>{var e,s;return eo((null!=(s=null==(e=JSON.parse(en).userInputs)?void 0:e.paths)?s:[]).join("\n"))},[en]);let[eh,eu]=(0,t.useState)((null!=(k=null==(n=K.artifacts)?void 0:n.paths)?k:[]).join("\n"));(0,t.useEffect)(()=>{var e,s;return eu((null!=(s=null==(e=JSON.parse(en).artifacts)?void 0:e.paths)?s:[]).join("\n"))},[en]);let em=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),[ep,ev]=(0,t.useState)(null!=(N=K.existingBranch)?N:"");(0,t.useEffect)(()=>{var e;return ev(null!=(e=JSON.parse(en).existingBranch)?e:"")},[en]);let ex=null!=(S=K.startFrom)?S:"head";(0,t.useEffect)(()=>{Y(JSON.parse(en).repoDir)},[en]);let ej=JSON.parse(en).repoDir||z.projectDir||"";(0,t.useEffect)(()=>{let e=!1;return ej.trim()?(c.FH.repoCheck(ej).then(s=>{var n;e||et(s.ok?null:null!=(n=s.problem)?n:null)}).catch(()=>{e||et(null)}),()=>{e=!0}):void et(null)},[ej]);let eg=(0,t.useCallback)(()=>{c.FH.vcsStatus(z.id).then(V).catch(()=>V(null))},[z.id]);(0,t.useEffect)(eg,[eg,en]);let ey=async e=>{try{await c.FH.updateSession(z.id,{vcs:e}),$(Z("vcs.saved")),G(),eg()}catch(e){$(e.message)}},ef=async()=>{es(!0),$(Z("mirror.browsing"));try{let s=await c.FH.browseFolder(_.trim()||z.projectDir||void 0);if(s.ok)Y(s.path),await ey({repoDir:s.path});else{var e;$(s.cancelled?Z("mirror.browseCancelled"):null!=(e=s.reason)?e:"")}}catch(e){$(e.message)}finally{es(!1)}},eb=K.repoDir||z.projectDir||"",ek=""!==eb.trim()&&null===ea;return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:Z("vcs.title")}),(0,a.jsx)("span",{className:"badge ".concat(K.enabled?"done":""),children:K.enabled?Z("vcs.on"):Z("vcs.off")})]}),(0,a.jsx)("p",{className:"muted small",children:Z("vcs.hint")}),(0,a.jsx)("label",{htmlFor:"vcs-root",children:Z("vcs.repoField")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{id:"vcs-root",type:"text",className:"grow",value:_,onChange:e=>Y(e.target.value),onBlur:()=>_.trim()!==K.repoDir&&void ey({repoDir:_.trim()}),placeholder:z.projectDir||"C:\\Projects\\my-app",disabled:z.running}),(0,a.jsx)("button",{onClick:()=>void ef(),disabled:ee||z.running,children:Z("mirror.browse")})]}),(0,a.jsx)(p.H4,{current:_,onUse:e=>{Y(e),ey({repoDir:e})}}),ea&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsx)("strong",{children:Z("vcs.noRepo")}),(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:ea}),(0,a.jsx)("div",{className:"muted small",style:{marginTop:6},children:Z("vcs.noRepoHow")})]}),!ea&&""!==eb.trim()&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:4},children:Z("vcs.repoOk")}),""===eb.trim()&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:4},children:Z("vcs.pickFirst")}),(0,a.jsxs)("div",{className:"option".concat(ek||K.enabled?"":" warned"),children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:K.enabled,onChange:e=>void ey({enabled:e.target.checked}),disabled:z.running||!ek&&!K.enabled}),(0,a.jsx)("span",{children:Z("vcs.enable")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.enableWhy")})]}),K.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"muted small",style:{marginTop:4},children:eb?Z("vcs.repoIs",{dir:eb}):Z("vcs.repoNone")}),eb&&!ea&&(0,a.jsx)(w.b,{dir:eb}),(0,a.jsx)("h3",{children:Z("vcs.branches")}),"existing-branch"===ex&&(0,a.jsx)("p",{className:"muted small",children:Z("vcs.branchesExisting",{branch:K.existingBranch||"…"})}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"branchMode",checked:"per-task"===K.branchMode,onChange:()=>void ey({branchMode:"per-task"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.perTask")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.perTaskWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"branchMode",checked:"per-session"===K.branchMode,onChange:()=>void ey({branchMode:"per-session"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.perSession")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.perSessionWhy")})]}),"per-session"===K.branchMode&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-branch-name",children:Z("vcs.branchName")}),(0,a.jsx)("input",{id:"vcs-branch-name",type:"text",value:el,onChange:e=>ei(e.target.value),onBlur:()=>{var e;return el.trim()!==(null!=(e=K.branchName)?e:"")&&void ey({branchName:el.trim()})},placeholder:z.name,disabled:z.running}),(0,a.jsx)("p",{className:"why",children:Z("vcs.branchNameWhy")})]}),(0,a.jsx)("h3",{children:Z("vcs.startFrom")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"branch"===ex,onChange:()=>void ey({startFrom:"branch"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.startBranch")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.startBranchWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"previous-session"===ex,onChange:()=>void ey({startFrom:"previous-session"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.startPrevious")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.startPreviousWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"head"===ex,onChange:()=>void ey({startFrom:"head"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.startHead")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.startHeadWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"existing-branch"===ex,onChange:()=>void ey({startFrom:"existing-branch"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.startExisting")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.startExistingWhy")})]}),"existing-branch"===ex&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-existing-branch",children:Z("vcs.existingBranch")}),(0,a.jsx)("input",{id:"vcs-existing-branch",type:"text",list:"vcs-local-branches",value:ep,onChange:e=>ev(e.target.value),onBlur:()=>{var e;return ep.trim()!==(null!=(e=K.existingBranch)?e:"")&&void ey({existingBranch:ep.trim()})},disabled:z.running}),(0,a.jsx)("datalist",{id:"vcs-local-branches",children:(null!=(C=null==Q?void 0:Q.branches)?C:[]).map(e=>(0,a.jsx)("option",{value:e},e))}),(0,a.jsx)("p",{className:"why",children:Z("vcs.existingBranchWhy")}),K.existingBranch&&(null==Q?void 0:Q.branches)&&!Q.branches.includes(K.existingBranch)&&(0,a.jsx)("p",{className:"err small",children:Z("vcs.existingBranchMissing",{branch:K.existingBranch})})]}),("branch"===ex||"previous-session"===ex)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-base-branch",children:Z("vcs.baseBranch")}),(0,a.jsx)("input",{id:"vcs-base-branch",type:"text",value:er,onChange:e=>ec(e.target.value),onBlur:()=>{var e;return er.trim()!==(null!=(e=K.baseBranch)?e:"")&&void ey({baseBranch:er.trim()})},placeholder:"main",disabled:z.running}),(0,a.jsx)("p",{className:"why",children:Z("vcs.baseBranchWhy")})]}),z.vcsStart&&(0,a.jsxs)("p",{className:"muted small",children:["existing-branch"===z.vcsStart.kind?Z("vcs.startedExisting",{branch:null!=(F=z.vcsStart.branch)?F:"",commit:z.vcsStart.commit.slice(0,8)}):"previous-session"===z.vcsStart.kind?Z("vcs.startedPrevious",{name:null!=(I=null==(l=z.vcsStart.fromSession)?void 0:l.name)?I:"",branch:null!=(T=z.vcsStart.branch)?T:"",commit:z.vcsStart.commit.slice(0,8)}):"branch"===z.vcsStart.kind?Z("vcs.startedBranch",{branch:null!=(L=z.vcsStart.branch)?L:"",commit:z.vcsStart.commit.slice(0,8)}):"snapshot"===z.vcsStart.kind?Z("vcs.startedSnapshot",{branch:null!=(H=z.vcsStart.branch)?H:"",commit:z.vcsStart.commit.slice(0,8),from:null!=(M=null==(i=z.vcsStart.snapshot)?void 0:i.fromBranch)?M:"HEAD",n:null!=(R=null==(r=z.vcsStart.snapshot)?void 0:r.included.length)?R:0,out:null!=(P=null==(o=z.vcsStart.snapshot)?void 0:o.leftOut.length)?P:0}):Z("vcs.startedHead",{commit:z.vcsStart.commit.slice(0,8)}),z.vcsStart.note?" — ".concat(z.vcsStart.note):"",z.vcsStart.update&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("br",{}),"updated"===z.vcsStart.update.outcome?Z("vcs.updated",{branch:z.vcsStart.update.branch,remote:null!=(O=z.vcsStart.update.remote)?O:"",from:(null!=(B=z.vcsStart.update.from)?B:"").slice(0,8),to:(null!=(D=z.vcsStart.update.to)?D:"").slice(0,8)}):"up-to-date"===z.vcsStart.update.outcome?Z("vcs.upToDate",{branch:z.vcsStart.update.branch,remote:null!=(A=z.vcsStart.update.remote)?A:""}):Z("vcs.notUpdated",{branch:z.vcsStart.update.branch,why:null!=(E=z.vcsStart.update.detail)?E:z.vcsStart.update.outcome})]})]}),"head"!==ex&&(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:!1!==K.updateFromRemote,onChange:e=>void ey({updateFromRemote:e.target.checked}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.updateFromRemote")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.updateFromRemoteWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:K.commitOnFinish,onChange:e=>void ey({commitOnFinish:e.target.checked}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.commit")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.commitWhy")})]}),"existing-branch"!==ex&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h3",{children:Z("vcs.dirty")}),["reject","snapshot","tracked-only-snapshot"].map(e=>{var s,n;return(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"vcs-dirty-".concat(z.id),checked:(null!=(n=null==(s=K.dirtyWorktree)?void 0:s.policy)?n:"reject")===e,onChange:()=>{var s;ey({dirtyWorktree:{policy:e,requireApproval:null==(s=K.dirtyWorktree)?void 0:s.requireApproval}})},disabled:z.running}),(0,a.jsx)("span",{children:Z("reject"===e?"vcs.dirtyReject":"snapshot"===e?"vcs.dirtySnapshot":"vcs.dirtyTracked")})]}),(0,a.jsx)("p",{className:"why",children:Z("reject"===e?"vcs.dirtyRejectWhy":"snapshot"===e?"vcs.dirtySnapshotWhy":"vcs.dirtyTrackedWhy")})]},e)}),(null!=(q=null==(h=K.dirtyWorktree)?void 0:h.policy)?q:"reject")!=="reject"&&(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:(null==(u=K.dirtyWorktree)?void 0:u.requireApproval)!==!1,onChange:e=>{var s,n;ey({dirtyWorktree:{policy:null!=(n=null==(s=K.dirtyWorktree)?void 0:s.policy)?n:"snapshot",requireApproval:e.target.checked}})},disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.dirtyApproval")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.dirtyApprovalWhy")})]})]}),(0,a.jsx)("h3",{children:Z("vcs.inputs")}),(0,a.jsx)("label",{htmlFor:"vcs-inputs-".concat(z.id),children:Z("vcs.inputsField")}),(0,a.jsx)("textarea",{id:"vcs-inputs-".concat(z.id),rows:3,value:ed,onChange:e=>eo(e.target.value),onBlur:()=>{var e,s;return JSON.stringify(em(ed))!==JSON.stringify(null!=(s=null==(e=K.userInputs)?void 0:e.paths)?s:[])&&void ey({userInputs:{...K.userInputs,paths:em(ed)}})},disabled:z.running,placeholder:"rules-engine/test-data/schemas/*.yaml",spellCheck:!1}),(0,a.jsx)("p",{className:"why",children:Z("vcs.inputsWhy")}),(null!=(U=null==(m=K.userInputs)?void 0:m.paths.length)?U:0)>0&&(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:(null==(v=K.userInputs)?void 0:v.readOnly)!==!1,onChange:e=>{var s,n,a;ey({userInputs:{paths:null!=(a=null==(s=K.userInputs)?void 0:s.paths)?a:[],requireApproval:null==(n=K.userInputs)?void 0:n.requireApproval,readOnly:e.target.checked}})},disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.inputsReadOnly")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.inputsReadOnlyWhy")})]}),(null==(x=z.vcsStart)?void 0:x.inputs)&&(0,a.jsx)("p",{className:"muted small",children:z.vcsStart.inputs.carried?Z("vcs.inputsCarried",{n:z.vcsStart.inputs.files.length,branch:z.vcsStart.inputs.carried.branch,onto:z.vcsStart.inputs.carried.onto.slice(0,8)}):Z("vcs.inputsRecorded",{n:z.vcsStart.inputs.files.length,commit:z.vcsStart.commit.slice(0,8)})}),(0,a.jsx)("h3",{children:Z("vcs.artifacts")}),(0,a.jsx)("label",{htmlFor:"vcs-artifacts-".concat(z.id),children:Z("vcs.artifactsField")}),(0,a.jsx)("textarea",{id:"vcs-artifacts-".concat(z.id),rows:2,value:eh,onChange:e=>eu(e.target.value),onBlur:()=>{var e,s;return JSON.stringify(em(eh))!==JSON.stringify(null!=(s=null==(e=K.artifacts)?void 0:e.paths)?s:[])&&void ey({artifacts:{paths:em(eh)}})},disabled:z.running,placeholder:"rules-engine/test-results/**",spellCheck:!1}),(0,a.jsx)("p",{className:"why",children:Z("vcs.artifactsWhy")}),Q&&!Q.ok&&(0,a.jsxs)("div",{className:"notice caution",role:"status",children:[(0,a.jsx)("strong",{children:Z("vcs.notReady")})," ",Q.problem]}),(null==Q||null==(j=Q.snapshot)?void 0:j.needed)&&Q.snapshot.entries.length>0&&(0,a.jsx)(W,{session:z,plan:Q.snapshot,onDone:()=>{G(),eg()}}),(null==Q?void 0:Q.ok)&&(0,a.jsx)("div",{className:"muted small",children:Z("vcs.ready",{branch:null!=(J=Q.branch)?J:"—",dir:Q.repoDir})}),(null==Q?void 0:Q.ok)&&Q.work&&Q.work.branches.length>0&&(0,a.jsxs)("div",{className:"muted small",children:["per-session"===Q.work.mode&&Q.work.complete?Z("vcs.completeOn",{branch:Q.work.complete}):Z("vcs.noSingleBranch",{n:Q.work.branches.length}),"per-task"===Q.work.mode&&(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:Q.work.branches.map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.branch})," — ",e.title,e.commit?"":" (".concat(Z("vcs.taskNoFiles"),")")]},e.branch))})]}),(0,a.jsx)("p",{className:"muted small",children:Z("vcs.pushIsYours")})]}),(0,a.jsx)("div",{className:"muted small",role:"status",children:X})]})}function M(e){var s;let{session:n,onChange:l}=e,{t:i}=(0,d.kj)(),[r,o]=(0,t.useState)(""),h=null!=(s=n.onFailure)?s:"stop",u=async e=>{if(e!==h)try{await c.FH.updateSession(n.id,{onFailure:e}),o(i("stop"===e?"chain.savedStop":"chain.savedContinue")),l()}catch(e){o(e.message)}};return(0,a.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,a.jsx)("legend",{className:"muted small",style:{padding:0},children:i("chain.title")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"chain",checked:"stop"===h,onChange:()=>void u("stop"),disabled:n.running}),(0,a.jsx)("span",{children:i("chain.stop")})]}),(0,a.jsx)("p",{className:"why",children:i("chain.stopWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"chain",checked:"continue"===h,onChange:()=>void u("continue"),disabled:n.running}),(0,a.jsx)("span",{children:i("chain.continue")})]}),(0,a.jsx)("p",{className:"why",children:i("chain.continueWhy")})]}),r&&(0,a.jsx)("div",{className:"muted small",role:"status",children:r}),n.running&&(0,a.jsx)("div",{className:"muted small",children:i("chain.locked")})]})}function R(e){let{value:s,onChange:n,presets:l,onPresetsChanged:i}=e,{t:r}=(0,d.kj)(),o=(0,t.useId)(),[h,u]=(0,t.useState)(""),m=async()=>{let e=prompt(r("l2.saveAsPrompt"));if(e)try{await c.FH.savePreset(e,s),u(r("l2.savedAs",{name:e})),null==i||i()}catch(e){u(e.message)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("label",{className:"grow",style:{margin:0},htmlFor:"".concat(o,"-text"),children:r("l2.label")}),(0,a.jsxs)("select",{value:"","aria-label":r("l2.loadPreset"),onChange:e=>{let s=l.find(s=>s.name===e.target.value);s&&n(s.content)},children:[(0,a.jsx)("option",{value:"",children:r("l2.loadPreset")}),l.map(e=>(0,a.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,a.jsx)("button",{onClick:()=>void m(),disabled:!s.trim(),children:r("l2.saveAs")})]}),(0,a.jsx)("textarea",{id:"".concat(o,"-text"),className:"prose",value:s,onChange:e=>n(e.target.value),placeholder:r("l2.placeholder"),style:{minHeight:140,marginTop:10}}),h&&(0,a.jsx)("div",{className:"muted small",children:h})]})}function P(e){let{session:s}=e,{t:n}=(0,d.kj)(),l=(0,d.W3)(),i=s.tasks.filter(e=>"queued"!==e.status),[r,o]=(0,t.useState)([]),h=r.length>0?r:i.map(e=>e.id),u=e=>(0,c.ub)("".concat(c.nC,"/sessions/").concat(s.id,"/export?variant=").concat(e)+(r.length>0?"&tasks=".concat(encodeURIComponent(r.join(","))):""));return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:n("export.title")}),(0,a.jsx)("p",{className:"muted small",children:n("export.hint")}),0===i.length?(0,a.jsx)("div",{className:"empty",children:n("export.nothing")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"row",style:{marginBottom:6},children:[(0,a.jsx)("button",{className:"quiet",onClick:()=>o(i.map(e=>e.id)),children:n("export.all")}),(0,a.jsx)("button",{className:"quiet",onClick:()=>o([]),children:n("export.none")}),(0,a.jsx)("span",{className:"muted small",children:r.length>0?n("export.selected",{n:r.length}):n("export.allOf",{n:i.length})})]}),i.map(e=>{var s,t,i,c,d;return(0,a.jsx)("div",{className:"option",style:{margin:"6px 0"},children:(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:r.includes(e.id),onChange:()=>{let s;return s=e.id,o(e=>e.includes(s)?e.filter(e=>e!==s):[...e,s])}}),(0,a.jsxs)("span",{children:[e.title," ",(0,a.jsx)("span",{className:"badge ".concat(e.status),children:n("status.".concat(e.status))})," ",e.readOnly&&(0,a.jsx)("span",{className:"chip",children:n("task.readOnly")})," ",(null!=(t=null==(s=e.scope)?void 0:s.length)?t:0)>0&&(0,a.jsx)("span",{className:"chip",children:n("task.scope",{paths:(null!=(i=e.scope)?i:[]).join(", ")})})," ",(0,a.jsx)("span",{className:"muted small",children:l(null!=(d=null!=(c=e.finishedAt)?c:e.startedAt)?d:e.createdAt)})]})]})},e.id)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("a",{className:"button-link",href:u("outcome"),download:!0,children:n("export.outcome",{n:h.length})}),(0,a.jsx)("a",{className:"button-link",href:u("full"),download:!0,children:n("export.full",{n:h.length})})]}),(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:n("export.outcomeWhy")})]})]})}function O(e){let{handoff:s}=e,{t:n}=(0,d.kj)(),t=(e,s)=>(0,a.jsxs)("div",{className:"handoff-row",children:[(0,a.jsx)("strong",{children:n(e)})," ",s]}),l=e=>(0,a.jsx)("ul",{children:e.map((e,s)=>(0,a.jsx)("li",{children:e},s))}),i=s.validation.filter(e=>e.passed).length;return(0,a.jsxs)("div",{className:"summary handoff",children:[(0,a.jsx)("strong",{children:n("handoff.title")}),t("handoff.outcome",(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"badge ".concat(s.outcome.status),children:n("status.".concat(s.outcome.status))}),s.outcome.reason?" ".concat(s.outcome.reason):""]})),t("handoff.files",0===s.changedFiles.length?(0,a.jsx)("span",{className:"muted",children:n("handoff.noFiles")}):(0,a.jsx)("code",{children:s.changedFiles.map(e=>"".concat(e.path).concat(e.added>=0?" +".concat(e.added,"/-").concat(e.removed):"")).join(", ")})),s.validation.length>0&&t("handoff.validation",(0,a.jsxs)(a.Fragment,{children:[n("handoff.passed",{n:i,of:s.validation.length}),s.review?" \xb7 ".concat(n("handoff.review",{verdict:s.review.verdict,open:s.review.open})):""]})),t("handoff.issues",0===s.knownIssues.length?(0,a.jsx)("span",{className:"muted",children:n("handoff.noIssues")}):l(s.knownIssues)),s.evidence.runId&&t("handoff.evidence",(0,a.jsx)("code",{children:s.evidence.runId})),(s.vcs.branch||s.vcs.problem)&&t("handoff.vcs",(0,a.jsxs)(a.Fragment,{children:[s.vcs.branch&&(0,a.jsx)("code",{children:s.vcs.branch}),s.vcs.commit?" @ ".concat(s.vcs.commit.slice(0,8)," \xb7 ").concat(n("handoff.notPushed")):s.vcs.branch?" \xb7 ".concat(n("handoff.noCommit")):"",s.vcs.problem?" — ".concat(s.vcs.problem):""]})),s.manual.length>0&&t("handoff.manual",l(s.manual)),s.notExecuted.length>0&&t("handoff.notRun",l(s.notExecuted))]})}function B(e){var s;let{session:n,presets:l,onAdded:i,onPresetsChanged:r}=e,{t:o}=(0,d.kj)(),h=[...n.tasks].reverse()[0],[u,m]=(0,t.useState)(""),[p,v]=(0,t.useState)(null!=(s=null==h?void 0:h.level2)?s:""),[x,j]=(0,t.useState)(""),[g,y]=(0,t.useState)(""),[f,b]=(0,t.useState)(!1),k=(0,t.useRef)(!1),N=async()=>{if(!k.current){k.current=!0,b(!0);try{await c.FH.addTask(n.id,{title:u,level2:p,prompt:x}),m(""),j(""),y(o("form.queued")),i()}catch(e){y(e.message)}finally{k.current=!1,b(!1)}}};return(0,a.jsxs)("div",{className:"panel",id:"new-task",children:[(0,a.jsx)("h2",{children:o("form.title")}),(0,a.jsx)("p",{className:"muted small",children:o("form.hint")}),(0,a.jsx)("label",{htmlFor:"new-task-title",children:o("form.titleLabel")}),(0,a.jsx)("input",{id:"new-task-title",type:"text",value:u,onChange:e=>m(e.target.value),placeholder:o("form.titlePlaceholder")}),(0,a.jsx)("div",{style:{marginTop:10},children:(0,a.jsx)(R,{value:p,onChange:v,presets:l,onPresetsChanged:r})}),(0,a.jsx)("label",{htmlFor:"new-task-prompt",children:o("form.taskLabel")}),(0,a.jsx)("textarea",{id:"new-task-prompt",className:"prose",value:x,onChange:e=>j(e.target.value),placeholder:o("form.taskPlaceholder"),style:{minHeight:140}}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void N(),disabled:f||!x.trim(),children:o("form.add")}),(0,a.jsx)("span",{className:"muted small",children:g})]})]})}function D(e){var s,n,l,i,r,m,p,v,f,k,w,S,C,F,I,T,L,W,H,M,P,B,D,A,q,G,Z,K,_,Y,Q,V,X,$,ee,es,en,ea,et,el,ei,er,ec,ed,eo,eh,eu,em,ep,ev,ex,ej,eg,ey,ef,eb,ek,eN,ew,eS,eC,eF,eI,eT,eL,eW,eH,eM,eR,eP,eO,eB,eD,eA,eE,eq,eU,eJ,ez,eG,eZ,eK,e_,eY;let{session:eQ,task:eV,index:eX,presets:e$,onChange:e0}=e,{t:e1}=(0,d.kj)(),e2=(0,d.W3)(),[e8,e4]=(0,t.useState)(!1),[e6,e3]=(0,t.useState)(!1),[e5,e7]=(0,t.useState)(eV.title),[e9,se]=(0,t.useState)(eV.level2),[ss,sn]=(0,t.useState)(eV.prompt),[sa,st]=(0,t.useState)(null!=(es=null==(s=eV.vcsPlan)?void 0:s.branch)?es:""),[sl,si]=(0,t.useState)(null!=(en=null==(n=eV.vcsPlan)?void 0:n.commitMessage)?en:""),[sr,sc]=(0,t.useState)(null!=(ea=eV.checks)?ea:[]),[sd,so]=(0,t.useState)(!!eV.readOnly),[sh,su]=(0,t.useState)((null!=(et=eV.scope)?et:[]).join("\n")),sm={readOnly:sd,scope:sd?[]:(0,N.w)(sh)},sp=(0,u.c)((0,h.DG)(eV)),[sv,sx]=(0,t.useState)(null),[sj,sg]=(0,t.useState)(""),sy=async()=>{try{await c.FH.updateTask(eQ.id,eV.id,{title:e5,level2:e9,prompt:ss,vcsPlan:{branch:sa,commitMessage:sl},checks:sr,...sm}),e4(!1),e0()}catch(e){sg(e.message)}},sf="running"===eV.status||"waiting-approval"===eV.status,sb=!sf&&"queued"!==eV.status,sk=!sf&&"queued"!==eV.status,sN=!sf&&null!=(el=null==(l=eQ.vcs)?void 0:l.enabled)&&el&&(!!(null==(i=eV.vcs)?void 0:i.baseCommit)||(null!=(ei=eV.attempts)?ei:[]).some(e=>{var s;return null==(s=e.vcs)?void 0:s.baseCommit})),sw=!sf&&(0,c.Zm)(eV),sS=async()=>{if(await (0,g.Z)(e1("task.continueConfirm",{title:eV.title})))try{await c.FH.continueTask(eQ.id,eV.id),e0()}catch(e){sg(e.message)}},sC=async()=>{if(await (0,g.Z)(e1("task.rerunConfirm",{title:eV.title})))try{await c.FH.rerunTask(eQ.id,eV.id),e0()}catch(e){sg(e.message)}},sF=async()=>{if(await (0,g.Z)(e1("task.editRanConfirm",{title:eV.title})))try{await c.FH.rerunTask(eQ.id,eV.id,{title:e5,level2:e9,prompt:ss,vcsPlan:{branch:sa,commitMessage:sl},checks:sr,...sm},{buildOnFinished:"done"===eV.status}),e4(!1),e0()}catch(e){sg(e.message)}},sI=(0,b.e)(e0),sT=async()=>{let e="queued"===eV.status?"task.deleteConfirm":"task.deleteConfirmRan";if(await (0,g.Z)(e1(e,{title:eV.title})))try{await c.FH.deleteTask(eQ.id,eV.id),e0()}catch(e){sg(e.message)}},sL=async()=>{try{sx(await c.FH.taskFiles(eQ.id,eV.id))}catch(e){sg(e.message)}},sW=(e,s,n)=>n.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"muted",children:[e1(e)," "]}),n.map(e=>(0,a.jsx)("span",{style:{marginRight:10},children:(0,a.jsx)(o.u,{label:e,save:()=>c.FH.saveTaskFile(eQ.id,eV.id,s,e)})},e))]});return(0,a.jsxs)("div",{className:"task ".concat(eV.status),id:eV.id,children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("h4",{className:"grow",children:[eX,". ",eV.title]}),(0,a.jsx)("span",{className:"badge ".concat(eV.status),children:e1("status.".concat(eV.status))}),eV.limit&&(0,a.jsx)("span",{className:"chip",title:e1("reg.limitChipWhy"),children:e1("reg.limitChip",{limit:e1("limit.".concat(eV.limit.setting),{n:eV.limit.value})})}),(null!=(er=eV.attempt)?er:1)>1&&(0,a.jsx)("span",{className:"chip",children:e1("task.attemptN",{n:null!=(ec=eV.attempt)?ec:1})}),eV.iterations>0&&(0,a.jsx)("span",{className:"muted small",children:e1("task.iterations",{n:eV.iterations})}),eV.runId&&(0,a.jsxs)("button",{className:e6?"":"quiet","aria-expanded":e6,onClick:()=>e3(e=>!e),title:(0,h.DG)(eV)?e1("story.showLiveWhy"):e1("story.why"),children:[(0,h.DG)(eV)&&!e6&&(0,a.jsx)("span",{className:"dot","aria-hidden":"true"}),e6?e1("story.hide"):(0,h.DG)(eV)?e1("story.showLive"):e1("story.show")]}),!sf&&(0,a.jsx)("button",{onClick:()=>{if(!e8){var e,s,n,a,t,l;e7(eV.title),se(eV.level2),sn(eV.prompt),st(null!=(n=null==(e=eV.vcsPlan)?void 0:e.branch)?n:""),si(null!=(a=null==(s=eV.vcsPlan)?void 0:s.commitMessage)?a:""),sc(null!=(t=eV.checks)?t:[]),so(!!eV.readOnly),su((null!=(l=eV.scope)?l:[]).join("\n"))}e4(!e8)},title:e1("task.editAll"),children:e8?e1("task.cancel"):e1("task.edit")}),sw&&(0,a.jsx)("button",{className:"primary",onClick:()=>void sS(),title:e1("task.continueWhy"),children:e1("task.continue")}),sk&&(0,a.jsx)("button",{className:sw?"":"primary",onClick:()=>void sC(),title:e1("task.rerunWhy"),children:e1("task.rerun")}),sN&&(0,a.jsx)("button",{onClick:()=>void sI.restore({sessionId:eQ.id,taskId:eV.id,title:eV.title}),disabled:""!==sI.busy||eQ.running,title:e1("restore.why"),children:"restore"===sI.busy?e1("restore.checking"):e1("restore.button")}),sb&&(0,a.jsx)("button",{onClick:()=>void sI.restartFrom({sessionId:eQ.id,taskId:eV.id,title:eV.title}),disabled:""!==sI.busy||eQ.running,title:e1("restart.why"),children:"restart"===sI.busy?e1("restart.checking"):e1("restart.button")}),!sf&&(0,a.jsx)("button",{className:"danger",onClick:()=>void sT(),children:e1("task.delete")}),!e8&&(sj||sI.message)&&(0,a.jsx)("span",{className:"err",role:"alert",children:sj||sI.message})]}),(0,a.jsxs)("div",{className:"muted small",children:[eV.startedAt?e1("task.started",{t:e2(eV.startedAt)}):e1("task.added",{t:e2(eV.createdAt)}),eV.finishedAt?" \xb7 ".concat(e1("task.finished",{t:e2(eV.finishedAt)})):"",eV.startedAt&&eV.finishedAt?" \xb7 ".concat(e1("task.took",{d:(0,c.c5)((0,h.d5)(eV.startedAt,eV.finishedAt))})):"",(0,h.DG)(eV)?" \xb7 ".concat(e1("task.runningFor",{d:(0,c.c5)((0,h.d5)(eV.startedAt,void 0,sp))})):""]}),"queued"!==eV.status&&(null==(r=eQ.vcs)?void 0:r.enabled)&&eV.vcs&&(0,a.jsx)("div",{className:"muted small",children:eV.vcs.problem&&!eV.vcs.branch?(0,a.jsx)("span",{className:"reason",children:e1("vcs.taskProblem",{problem:eV.vcs.problem})}):(0,a.jsxs)(a.Fragment,{children:[eV.vcs.branch&&e1("vcs.taskBranch",{branch:eV.vcs.branch}),eV.vcs.baseCommit&&" \xb7 ".concat(e1("vcs.taskBase",{commit:eV.vcs.baseCommit.slice(0,8)})),eV.vcs.commit?" \xb7 ".concat(e1("vcs.taskCommit",{commit:eV.vcs.commit.slice(0,8)})):" \xb7 ".concat(e1("vcs.taskNoFiles")),(null!=(ed=null==(m=eV.vcs.files)?void 0:m.length)?ed:0)>0&&(0,a.jsxs)("details",{style:{display:"inline"},children:[(0,a.jsxs)("summary",{style:{display:"inline",cursor:"pointer"},children:[" \xb7 ",e1("vcs.taskFiles",{n:null!=(eo=null==(p=eV.vcs.files)?void 0:p.length)?eo:0})]}),(0,a.jsx)("ul",{style:{margin:"4px 0 4px 0",paddingLeft:20},children:(null!=(eh=eV.vcs.files)?eh:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.path})," ",e.added<0||e.removed<0?e1("vcs.taskBinary"):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{style:{color:"var(--ok)"},children:["+",e.added]})," ",(0,a.jsxs)("span",{style:{color:"var(--bad)"},children:["-",e.removed]})]})]},e.path))})]}),eV.vcs.commit&&eV.vcs.baseCommit&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",(0,a.jsx)(y.C,{sessionId:eQ.id,taskId:eV.id,title:eV.title,files:null!=(eu=null==(v=eV.vcs.files)?void 0:v.length)?eu:0})]}),(null!=(em=null==(f=eV.vcs.suspicious)?void 0:f.length)?em:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{marginTop:4},children:[e1("vcs.suspicious",{n:null!=(ep=null==(k=eV.vcs.suspicious)?void 0:k.length)?ep:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(ev=eV.vcs.suspicious)?ev:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.path})," — ",e.reason]},e.path))})]}),(null!=(ex=null==(w=eV.scopeReverted)?void 0:w.length)?ex:0)>0&&(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:e1("task.scopeReverted",{n:null!=(ej=null==(S=eV.scopeReverted)?void 0:S.length)?ej:0,paths:(null!=(eg=eV.scopeReverted)?eg:[]).join(", ")})}),(null!=(ey=null==(C=eV.inputsRestored)?void 0:C.length)?ey:0)>0&&(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:e1("task.inputsRestored",{n:null!=(ef=null==(F=eV.inputsRestored)?void 0:F.length)?ef:0,paths:(null!=(eb=eV.inputsRestored)?eb:[]).join(", ")})}),(null!=(ek=null==(I=eV.artifactsKept)?void 0:I.length)?ek:0)>0&&(0,a.jsx)("div",{className:"muted small",style:{marginTop:4,overflowWrap:"anywhere"},children:e1("task.artifactsKept",{n:null!=(eN=null==(T=eV.artifactsKept)?void 0:T.length)?eN:0,paths:(null!=(ew=eV.artifactsKept)?ew:[]).slice(0,10).map(e=>e.path).join(", ")})}),(null!=(eS=null==(L=eV.vcs.foreignCommits)?void 0:L.length)?eS:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{marginTop:4},children:[e1("vcs.foreignCommits",{n:null!=(eC=null==(W=eV.vcs.foreignCommits)?void 0:W.length)?eC:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(eF=eV.vcs.foreignCommits)?eF:[]).map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e))})]})]})}),"queued"===eV.status&&(null==(H=eQ.vcs)?void 0:H.enabled)&&((null==(M=eV.vcsPlan)?void 0:M.branch)||(null==(P=eV.vcsPlan)?void 0:P.commitMessage))&&(0,a.jsx)("div",{className:"muted small",children:eV.vcsPlan.branch&&eV.vcsPlan.commitMessage?e1("task.gitNames",{branch:eV.vcsPlan.branch,subject:eV.vcsPlan.commitMessage.split("\n")[0]}):eV.vcsPlan.branch?e1("task.gitBranchOnly",{branch:eV.vcsPlan.branch}):e1("task.gitCommitOnly",{subject:(null!=(eI=eV.vcsPlan.commitMessage)?eI:"").split("\n")[0]})}),e6&&eV.runId&&(0,a.jsx)(x.P,{sessionId:eQ.id,taskId:eV.id,live:"running"===eV.status||"waiting-approval"===eV.status}),e8?(0,a.jsxs)("div",{style:{marginTop:8},children:[(0,a.jsx)("label",{children:e1("form.titleLabel")}),(0,a.jsx)("input",{type:"text",value:e5,onChange:e=>e7(e.target.value)}),(0,a.jsx)("div",{style:{marginTop:8},children:(0,a.jsx)(R,{value:e9,onChange:se,presets:e$})}),(0,a.jsx)("label",{children:e1("form.taskLabel")}),(0,a.jsx)("textarea",{className:"prose",value:ss,onChange:e=>sn(e.target.value)}),(null==(B=eQ.vcs)?void 0:B.enabled)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"branch-".concat(eV.id),children:e1("task.branch")}),(0,a.jsx)("input",{id:"branch-".concat(eV.id),type:"text",value:sa,onChange:e=>st(e.target.value),placeholder:eQ.vcs.branchPrefix,disabled:"per-session"===eQ.vcs.branchMode}),(0,a.jsx)("p",{className:"why",children:"per-session"===eQ.vcs.branchMode?e1("task.branchIgnored"):e1("task.branchWhy")}),(0,a.jsx)("label",{htmlFor:"commit-".concat(eV.id),children:e1("task.commitMessage")}),(0,a.jsx)("textarea",{id:"commit-".concat(eV.id),value:sl,onChange:e=>si(e.target.value),style:{minHeight:70}}),(0,a.jsx)("p",{className:"why",children:e1("task.commitWhy")})]}),(0,a.jsx)(E,{checks:sr,onChange:sc}),ss.trim()!==eV.prompt.trim()&&(0,a.jsx)("p",{className:"notice caution small",children:e1("task.newIntentNote")}),(0,a.jsx)(N.y,{readOnly:sd,scope:sh,onReadOnly:so,onScope:su}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void(sb?sF():sy()),children:sb?e1("task.saveAndRerun"):e1("task.save")}),(0,a.jsx)("span",{className:"err",children:sj})]}),sb&&(0,a.jsx)("p",{className:"muted small",children:e1("task.editRanWhy")})]}):(0,a.jsxs)(a.Fragment,{children:[(null!=(eT=null==(D=eV.checks)?void 0:D.length)?eT:0)>0&&(0,a.jsxs)("details",{className:"small",style:{margin:"6px 0"},children:[(0,a.jsxs)("summary",{children:[e1("checks.title")," — ",e1("checks.n",{n:null!=(eL=null==(A=eV.checks)?void 0:A.length)?eL:0}),(null!=(eW=null==(q=eV.checkResults)?void 0:q.length)?eW:0)>0&&" \xb7 ".concat((null!=(eH=eV.checkResults)?eH:[]).filter(e=>e.passed).length,"/").concat(null==(G=eV.checkResults)?void 0:G.length," ").concat(e1("checks.passed"))]}),(0,a.jsx)("ul",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(eM=eV.checks)?eM:[]).map((e,s)=>{var n;let t=(null!=(n=eV.checkResults)?n:[]).find(s=>s.name===e.name);return(0,a.jsxs)("li",{children:[(0,a.jsx)("strong",{children:e.name}),(0,a.jsxs)("span",{className:"muted",children:[" — ",e1("checks.kind.".concat(e.expect)),e.value?' "'.concat(e.value,'"'):"",e.run?": ".concat(e.run):e.file?": ".concat(e.file):""]}),t&&(0,a.jsxs)("div",{className:t.passed?"muted":"reason",children:[t.passed?e1("checks.passed"):e1("checks.failed")," — ",t.detail]})]},"".concat(e.name,"-").concat(s))})})]}),(null!=(eR=null==(Z=eV.reviewChecks)?void 0:Z.length)?eR:0)>0&&(0,a.jsxs)("details",{className:"small",style:{margin:"6px 0"},children:[(0,a.jsx)("summary",{children:e1("checks.fromReview",{n:null!=(eP=null==(K=eV.reviewChecks)?void 0:K.length)?eP:0})}),(0,a.jsx)("p",{className:"why",children:e1("checks.fromReviewWhy")}),(0,a.jsx)("ul",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(eO=eV.reviewChecks)?eO:[]).map(e=>{var s;let n=(null!=(s=eV.checkResults)?s:[]).find(s=>s.name===e.check.name);return(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.findingId})," ",(0,a.jsx)("strong",{children:e.check.name}),"active"!==e.state&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:e1("checks.state.".concat(e.state))}),(0,a.jsx)("div",{className:"muted",children:e.what}),n&&(0,a.jsxs)("div",{className:n.passed?"muted":"reason",children:[n.passed?e1("checks.passed"):e1("checks.failed")," — ",n.detail]})]},"".concat(e.attempt,":").concat(e.findingId,":").concat(e.check.name))})})]}),(0,a.jsx)(z,{review:eV.review}),eV.stopCode&&!(0,h.DG)(eV)&&(0,a.jsx)("p",{className:"small",children:(0,a.jsx)("span",{className:"chip",title:e1("stop.why"),children:e1("stop.".concat(eV.stopCode))})}),eV.handoff&&!(0,h.DG)(eV)&&(0,a.jsx)(O,{handoff:eV.handoff}),eV.summary&&(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:e1("task.whatWasDone")}),(0,a.jsx)(j.s,{text:eV.summary})]}),(null!=(eB=null==(_=eV.deviations)?void 0:_.length)?eB:0)>0&&(0,a.jsx)(U,{items:null!=(eD=eV.deviations)?eD:[]}),(null!=(eA=null==(Y=eV.disputes)?void 0:Y.length)?eA:0)>0&&(0,a.jsx)(J,{items:null!=(eE=eV.disputes)?eE:[]}),eV.environment&&(0,a.jsx)("div",{className:"muted small",style:{margin:"4px 0"},children:e1("task.ranWith",{node:eV.environment.node,npm:null!=(eq=eV.environment.npm)?eq:"—",git:null!=(eU=eV.environment.git)?eU:"—",pwsh:null!=(ez=null!=(eJ=eV.environment.pwsh)?eJ:eV.environment.powershell)?ez:"—"})}),(null!=(eG=null==(Q=eV.leftovers)?void 0:Q.length)?eG:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{margin:"6px 0"},children:[e1("task.leftovers",{n:null!=(eZ=null==(V=eV.leftovers)?void 0:V.length)?eZ:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(eK=eV.leftovers)?eK:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.name})," pid ",e.pid,e.ports.length>0?" \xb7 ".concat(e1("task.leftoverPorts",{ports:e.ports.join(", ")})):""," \xb7 ",e.by]},"".concat(e.by,"-").concat(e.pid)))})]}),eV.reason&&(0,a.jsx)("div",{className:"reason small",style:{margin:"6px 0"},children:eV.reason}),(null!=(e_=null==(X=eV.attempts)?void 0:X.length)?e_:0)>0&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e1("task.attempts",{n:null!=(eY=null==($=eV.attempts)?void 0:$.length)?eY:0})}),null==(ee=eV.attempts)?void 0:ee.map((e,s)=>{var n,t,l,i;return(0,a.jsxs)("div",{className:"small",style:{margin:"8px 0 12px"},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("strong",{children:e1("task.attemptN",{n:s+1})}),(0,a.jsx)("span",{className:"badge ".concat(e.status),children:e1("status.".concat(e.status))}),e.iterations>0&&(0,a.jsx)("span",{className:"muted",children:e1("task.iterations",{n:e.iterations})}),e.runId&&(0,a.jsx)(o.u,{label:e1("save.attemptLog"),save:()=>c.FH.saveTaskLog(eQ.id,eV.id,e.runId)}),e.runId&&(0,a.jsx)(o.H,{sessionId:eQ.id,taskId:eV.id,attempt:s+1}),e.runId&&(null==(n=e.vcs)?void 0:n.commit)&&e.vcs.baseCommit&&(0,a.jsx)(y.C,{sessionId:eQ.id,taskId:eV.id,runId:e.runId,title:"".concat(eV.title," — ").concat(e1("task.attemptN",{n:s+1})),files:null!=(l=null==(t=e.vcs.files)?void 0:t.length)?l:0})]}),(0,a.jsxs)("div",{className:"muted",children:[e.startedAt?e1("task.started",{t:e2(e.startedAt)}):"",e.finishedAt?" \xb7 ".concat(e1("task.finished",{t:e2(e.finishedAt)})):""]}),e.summary&&(0,a.jsx)("div",{children:e.summary}),e.reason&&(0,a.jsx)("div",{className:"err",children:e.reason}),e.prompt&&e.prompt!==eV.prompt&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e1("task.attemptText")}),(0,a.jsx)("pre",{children:e.prompt})]})]},"".concat(null!=(i=e.runId)?i:s))})]}),"queued"===eV.status?(0,a.jsxs)("div",{style:{marginTop:8},children:[(0,a.jsx)("div",{className:"muted small",children:e1("task.prompt")}),(0,a.jsx)("pre",{children:eV.prompt}),eV.level2.trim()?(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e1("task.l2Show",{n:eV.level2.trim().split("\n").length})}),(0,a.jsx)("pre",{children:eV.level2})]}):(0,a.jsx)("div",{className:"muted small",children:e1("task.noL2")})]}):(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e1("task.promptAndL2")}),eV.level2.trim()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"muted small",children:e1("task.l2")}),(0,a.jsx)("pre",{children:eV.level2})]}),(0,a.jsx)("div",{className:"muted small",children:e1("task.prompt")}),(0,a.jsx)("pre",{children:eV.prompt})]}),eV.firstMessage&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e1("task.firstMessage")}),(0,a.jsx)("pre",{className:"tall",children:eV.firstMessage})]}),eV.runId&&(0,a.jsxs)("details",{onToggle:e=>e.currentTarget.open&&void sL(),children:[(0,a.jsx)("summary",{children:e1("task.files")}),(0,a.jsx)("div",{className:"row small",style:{margin:"6px 0"},children:(0,a.jsx)(o.u,{label:e1("save.log"),save:()=>c.FH.saveTaskLog(eQ.id,eV.id)})}),sv&&(0,a.jsxs)("div",{className:"small",children:[sW("task.reports","reports",sv.reports),sW("task.artifacts","artifacts",sv.artifacts),sW("task.replies","replies",sv.replies)]})]}),eV.finalReply&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e1("task.finalReply")}),(0,a.jsx)("pre",{className:"tall",children:eV.finalReply})]})]})]})}function A(e){let{events:s}=e,{t:n}=(0,d.kj)(),{appearance:l}=(0,m.KP)(),i=(0,t.useRef)(null);return(0,t.useEffect)(()=>{!l.reduceMotion&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[s.length,l.reduceMotion]),(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:n("live.title")}),(0,a.jsxs)("div",{className:"log",ref:i,children:[0===s.length&&(0,a.jsx)("div",{className:"muted",children:n("live.none")}),s.map((e,s)=>{var n;return(0,a.jsxs)("div",{className:e.level,children:[(0,a.jsx)("span",{className:"time",children:new Date(e.at).toLocaleTimeString(void 0,{hour12:!1})}),null!=(n=e.message)?n:e.type]},s)})]})]})}function E(e){let{checks:s,onChange:n}=e,{t}=(0,d.kj)(),l=(e,a)=>n(s.map((s,n)=>e===n?{...s,...a}:s));return(0,a.jsxs)("div",{style:{marginTop:12},children:[(0,a.jsx)("label",{children:t("checks.title")}),(0,a.jsx)("p",{className:"why",style:{marginTop:0},children:t("checks.why")}),0===s.length&&(0,a.jsx)("p",{className:"muted small",children:t("checks.noneWhy")}),s.map((e,i)=>{var r,d,o,h;return(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{type:"text",className:"grow",value:e.name,placeholder:t("checks.namePlaceholder"),onChange:e=>l(i,{name:e.target.value}),"aria-label":t("checks.name")}),(0,a.jsx)("select",{value:e.expect,onChange:e=>l(i,{expect:e.target.value}),"aria-label":t("checks.kind"),style:{width:"auto"},children:c.FZ.map(e=>(0,a.jsx)("option",{value:e,children:t("checks.kind.".concat(e))},e))}),(0,a.jsx)("button",{className:"quiet",onClick:()=>n(s.filter((e,s)=>s!==i)),children:t("checks.remove")})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,c.rt)(e.expect)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{type:"text",className:"grow",value:null!=(r=e.run)?r:"",placeholder:t("checks.run"),onChange:e=>l(i,{run:e.target.value}),"aria-label":t("checks.run")}),(0,a.jsx)("input",{type:"text",value:null!=(d=e.cwd)?d:"",placeholder:t("checks.cwd"),onChange:e=>l(i,{cwd:e.target.value}),"aria-label":t("checks.cwd"),style:{width:220}})]}):(0,a.jsx)("input",{type:"text",className:"grow",value:null!=(o=e.file)?o:"",placeholder:t("checks.file"),onChange:e=>l(i,{file:e.target.value}),"aria-label":t("checks.file")}),(0,c.dK)(e.expect)&&(0,a.jsx)("input",{type:"text",value:null!=(h=e.value)?h:"",placeholder:"output-matches"===e.expect?t("checks.valueRegex"):t("checks.value"),onChange:e=>l(i,{value:e.target.value}),"aria-label":t("checks.value"),style:{width:240}})]})]},i)}),(0,a.jsx)("button",{onClick:()=>n([...s,{name:"",expect:"exit-zero",run:""}]),children:t("checks.add")})]})}function q(e){let{tasks:s}=e,{t:n}=(0,d.kj)(),t=(0,h.hH)(s),l=(0,u.c)(!!t&&t.tasks.some(h.DG));if(!t)return null;let i=(0,h.eZ)(t.run,t.tasks,l);return(0,a.jsx)("p",{className:"muted small",style:{margin:"4px 0 10px"},children:n(i.live?"session.runClockLive":"session.runClock",{n:i.tasks,d:(0,c.c5)(i.ms)})})}function U(e){let{items:s}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:n("task.deviations",{n:s.length})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:s.map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:6},children:[(0,a.jsx)("div",{children:e.instruction}),(0,a.jsxs)("div",{className:"muted",children:[n("task.deviationDid"),": ",e.did]}),(0,a.jsxs)("div",{className:"muted",children:[n("task.deviationWhy"),": ",e.why]})]},s))})]})}function J(e){let{items:s}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:n("task.disputes",{n:s.length})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:s.map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:6},children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("code",{children:e.finding})," — ",e.why]}),(0,a.jsxs)("div",{className:"muted",children:[n("review.evidence"),": ",e.evidence]})]},s))})]})}function z(e){var s,n,t,l,i;let{review:r}=e,{t:c}=(0,d.kj)();if(!r)return null;if("skipped"===r.verdict)return r.skippedBecause?(0,a.jsx)("p",{className:"muted small",children:c("review.skippedWhy",{why:r.skippedBecause})}):null;let o="pass"===r.verdict?"done":"fail"===r.verdict?"blocked":"waiting-approval";return(0,a.jsxs)("div",{className:"small",style:{margin:"8px 0"},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("span",{className:"badge ".concat(o),children:c("review.verdict.".concat(r.verdict))}),r.stepsRun>0&&(0,a.jsx)("span",{className:"muted",children:c("review.ran",{n:r.stepsRun})}),r.rounds>1&&(0,a.jsx)("span",{className:"muted",children:c("review.rounds",{n:r.rounds})}),r.model&&(0,a.jsx)("span",{className:"chip",children:c("review.onModel",{model:r.model})})]}),r.problem&&(0,a.jsx)("p",{className:"reason",children:c("review.problem",{problem:r.problem})}),r.summary&&(0,a.jsx)(j.s,{text:r.summary}),(null!=(t=null==(s=r.findings)?void 0:s.length)?t:0)>0&&(0,a.jsxs)("details",{style:{marginTop:4},children:[(0,a.jsx)("summary",{children:c("review.findings",{n:null!=(l=null==(n=r.findings)?void 0:n.length)?l:0})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(i=r.findings)?i:[]).map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:8},children:[(0,a.jsxs)("div",{children:[e.id&&(0,a.jsx)("code",{style:{marginRight:6},children:e.id}),e.what,"task"===e.about&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:c("review.aboutTask")}),e.repeated&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:c("review.repeated")})]}),e.where&&(0,a.jsx)("div",{className:"muted",children:e.where}),(0,a.jsxs)("div",{className:"muted",children:[c("review.evidence"),": ",e.evidence]})]},s))})]})]})}},4784:(e,s,n)=>{"use strict";n.d(s,{Y:()=>r});var a=n(3365),t=n(1521),l=n(5549),i=n(867);function r(e){var s,n;let{id:r,chosen:c,onChange:d,none:o,catalogue:h,disabled:u=!1,style:m}=e,{t:p}=(0,i.kj)(),v=function(e){let[s,n]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(void 0!==e)return;let s=!0;return l.FH.models().then(e=>{s&&n(e)}).catch(()=>void 0),()=>{s=!1}},[e]),void 0!==e?e:s}(h),x=null!=(s=null==v?void 0:v.options)?s:[],j=x.some(e=>e.name===c),g=x.filter(e=>!e.group),y=new Map;for(let e of x)e.group&&y.set(e.group,[...null!=(n=y.get(e.group))?n:[],e]);return(0,a.jsxs)("select",{id:r,value:c,onChange:e=>d(e.target.value),disabled:u,style:{width:"auto",minWidth:280,...m},children:[(0,a.jsx)("option",{value:"",children:o}),c&&!j&&(0,a.jsx)("option",{value:c,children:p("model.notInList",{name:c})}),g.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(p("model.unavailable")):""]},e.name)),[...y.entries()].map(e=>{let[s,n]=e;return(0,a.jsx)("optgroup",{label:s,children:n.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(p("model.unavailable")):""]},e.name))},s)})]})}},8078:(e,s,n)=>{"use strict";n.d(s,{AppearanceProvider:()=>o,KP:()=>h});var a=n(3365),t=n(1521);let l="cop.appearance",i=["small","normal","large","huge","giant"];"\n(function () {\n try {\n var d = document.documentElement;\n var raw = localStorage.getItem('".concat(l,"');\n var a = raw ? JSON.parse(raw) : {};\n if (!a || typeof a !== 'object') a = {};\n d.dataset.theme = a.theme === 'dark' ? 'dark' : 'light';\n d.dataset.textsize = ").concat(JSON.stringify(i),".indexOf(a.textSize) >= 0 ? a.textSize : 'normal';\n d.dataset.contrast = a.highContrast ? 'high' : 'normal';\n d.dataset.motion = a.reduceMotion ? 'reduced' : 'normal';\n d.dataset.links = a.underlineLinks ? 'underline' : 'plain';\n d.dataset.focus = a.strongFocus ? 'strong' : 'normal';\n } catch (e) {}\n})();\n");let r={theme:"light",textSize:"normal",highContrast:!1,reduceMotion:!1,underlineLinks:!1,strongFocus:!1};function c(e){let s=document.documentElement;s.dataset.theme=e.theme,s.dataset.textsize=e.textSize,s.dataset.contrast=e.highContrast?"high":"normal",s.dataset.motion=e.reduceMotion?"reduced":"normal",s.dataset.links=e.underlineLinks?"underline":"plain",s.dataset.focus=e.strongFocus?"strong":"normal"}let d=(0,t.createContext)({appearance:r,set:()=>void 0,reset:()=>void 0,loaded:!1});function o(e){let{children:s}=e,[n,o]=(0,t.useState)(r),[h,u]=(0,t.useState)(!1);(0,t.useEffect)(()=>{let e=r;try{let s=window.localStorage.getItem(l);s?e=function(e){let s=e&&"object"==typeof e?e:{},n=(e,s)=>"boolean"==typeof e?e:s;return{theme:"dark"===s.theme?"dark":"light"===s.theme?"light":r.theme,textSize:i.includes(s.textSize)?s.textSize:r.textSize,highContrast:n(s.highContrast,r.highContrast),reduceMotion:n(s.reduceMotion,r.reduceMotion),underlineLinks:n(s.underlineLinks,r.underlineLinks),strongFocus:n(s.strongFocus,r.strongFocus)}}(JSON.parse(s)):window.matchMedia("(prefers-color-scheme: dark)").matches&&(e={...e,theme:"dark"}),window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!s&&(e={...e,reduceMotion:!0})}catch(e){}o(e),c(e),u(!0)},[]);let m=(0,t.useCallback)(e=>{o(s=>{let n={...s,...e};c(n);try{window.localStorage.setItem(l,JSON.stringify(n))}catch(e){}return n})},[]),p=(0,t.useCallback)(()=>{o(r),c(r);try{window.localStorage.removeItem(l)}catch(e){}},[]);return(0,a.jsx)(d.Provider,{value:{appearance:n,set:m,reset:p,loaded:h},children:s})}function h(){return(0,t.useContext)(d)}},8848:(e,s,n)=>{"use strict";n.d(s,{H4:()=>d,L:()=>o,z4:()=>h});var a=n(3365),t=n(8197),l=n.n(t),i=n(1521),r=n(5549),c=n(867);function d(e){let{current:s,onUse:n}=e,{t}=(0,c.kj)(),[l,d]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return r.FH.project().then(s=>{e||d(s)}).catch(()=>void 0),()=>{e=!0}},[]),!l)return null;let o=l.rootDir.trim(),h=s.trim().toLowerCase(),u=n?l.others.filter(e=>e.rootDir.trim().toLowerCase()!==h):[];return(0,a.jsx)(m,{label:o?t("proj.defaultIs",{dir:o}):t("proj.noneShort"),offer:o&&n&&h!==o.toLowerCase()?{text:t("proj.useIt"),onUse:()=>n(o)}:void 0,more:u.map(e=>({text:t("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==n?void 0:n(e.rootDir)})),link:o?t("proj.change"):t("proj.setIt"),anchor:"project"})}function o(e){let{current:s,onUse:n}=e,t=u(),{t:l}=(0,c.kj)();if(!t)return null;let i=t.defaultModel.trim();return(0,a.jsx)(m,{label:i?l("def.modelDefaultIs",{name:i}):l("def.modelNoneShort"),offer:i&&n&&s.trim()!==i?{text:l("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:l(i?"proj.change":"proj.setIt"),anchor:"model"})}function h(e){let{current:s,onUse:n}=e,t=u(),{t:l}=(0,c.kj)();if(!t)return null;let i=t.defaultReviewModel.trim();return(0,a.jsx)(m,{label:i?l("def.reviewDefaultIs",{name:i}):l("def.reviewNoneShort"),offer:i&&n&&s.trim()!==i?{text:l("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:l(i?"proj.change":"proj.setIt"),anchor:"review"})}function u(){let[e,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return r.FH.models().then(n=>{e||s(n)}).catch(()=>void 0),()=>{e=!0}},[]),e}function m(e){let{label:s,offer:n,more:t=[],link:i,anchor:r}=e;return(0,a.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[s," ",n&&(0,a.jsxs)(a.Fragment,{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:n.onUse,children:n.text})," "]}),t.map(e=>(0,a.jsxs)("span",{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,a.jsx)(l(),{href:"/defaults#".concat(r),children:i})]})}}},e=>{e.O(0,[197,867,549,36,347,131,358],()=>e(e.s=1772)),_N_E=e.O()}]);