copilot-operator 0.1.11 → 0.1.12

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 (55) hide show
  1. package/dist/src/api/operator.controller.js +1 -1
  2. package/dist/src/api/operator.service.js +64 -6
  3. package/dist/src/config/schema.js +14 -3
  4. package/dist/src/context/desktopMirror.js +34 -12
  5. package/dist/src/context/projectMirror.js +69 -1
  6. package/dist/src/orchestrator/contract.js +56 -1
  7. package/dist/src/orchestrator/taskRunner.js +116 -11
  8. package/dist/src/plan/brief.js +20 -8
  9. package/dist/src/plan/systemGuide.js +42 -10
  10. package/dist/src/session/compose.js +16 -1
  11. package/dist/src/session/exportRecord.js +8 -1
  12. package/dist/src/session/handoff.js +41 -3
  13. package/dist/src/session/model.js +9 -0
  14. package/dist/src/session/store.js +11 -7
  15. package/dist/src/session/story.js +74 -18
  16. package/dist/src/transport/chatTransport.js +1 -0
  17. package/dist/src/transport/copilotTransport.js +80 -61
  18. package/dist/src/vcs/git.js +15 -0
  19. package/dist/src/vcs/taskVcs.js +29 -6
  20. package/dist/web/404.html +2 -2
  21. package/dist/web/_next/static/chunks/36-c3dd06c6a459c114.js +1 -0
  22. package/dist/web/_next/static/chunks/549-a5a59a94f92bb3eb.js +1 -0
  23. package/dist/web/_next/static/chunks/867-b64c436f5b25f39e.js +1 -0
  24. package/dist/web/_next/static/chunks/app/defaults/page-5f180a88398be4c9.js +1 -0
  25. package/dist/web/_next/static/chunks/app/history/page-854e3dde672e38a2.js +1 -0
  26. package/dist/web/_next/static/chunks/app/page-13572a726de0b7db.js +1 -0
  27. package/dist/web/_next/static/chunks/app/sessions/view/{page-d7e1f83d13c6356b.js → page-cc99401da5173b36.js} +1 -1
  28. package/dist/web/_next/static/css/{2ad2a74b7e07dcc9.css → a0642fdb8adf9edb.css} +1 -1
  29. package/dist/web/appearance.html +2 -2
  30. package/dist/web/appearance.txt +12 -12
  31. package/dist/web/defaults.html +2 -2
  32. package/dist/web/defaults.txt +12 -12
  33. package/dist/web/history.html +2 -2
  34. package/dist/web/history.txt +12 -12
  35. package/dist/web/import.html +2 -2
  36. package/dist/web/import.txt +12 -12
  37. package/dist/web/index.html +2 -2
  38. package/dist/web/index.txt +12 -12
  39. package/dist/web/level1.html +2 -2
  40. package/dist/web/level1.txt +12 -12
  41. package/dist/web/presets.html +2 -2
  42. package/dist/web/presets.txt +12 -12
  43. package/dist/web/sessions/view.html +2 -2
  44. package/dist/web/sessions/view.txt +12 -12
  45. package/dist/web/system.html +2 -2
  46. package/dist/web/system.txt +12 -12
  47. package/package.json +6 -3
  48. package/dist/web/_next/static/chunks/36-17a3bcb0c2553c7c.js +0 -1
  49. package/dist/web/_next/static/chunks/549-8f69ef8086802748.js +0 -1
  50. package/dist/web/_next/static/chunks/867-f82c74b7b2ed5c54.js +0 -1
  51. package/dist/web/_next/static/chunks/app/defaults/page-abfa73fb08822e36.js +0 -1
  52. package/dist/web/_next/static/chunks/app/history/page-a9f2060f86a4a10e.js +0 -1
  53. package/dist/web/_next/static/chunks/app/page-2ac6b67f4ddcb808.js +0 -1
  54. /package/dist/web/_next/static/{oyfXbuB_cq0sRZP7ukHlQ → bcBE4tY_aNh6kzLzN1luP}/_buildManifest.js +0 -0
  55. /package/dist/web/_next/static/{oyfXbuB_cq0sRZP7ukHlQ → bcBE4tY_aNh6kzLzN1luP}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[189],{1035:(e,l,t)=>{"use strict";t.d(l,{DialogHost:()=>c,Z:()=>d});var r=t(3365),s=t(1521),n=t(867),a=t(4969);let i=null,o=[];function d(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var r;return r={kind:"confirm",message:e,...l,resolve:t},void(i?i(r):o.push(r))})}function c(e){var l,t;let{children:d}=e,{t:c}=(0,n.kj)(),[u,m]=(0,s.useState)([]),h=(0,s.useRef)(null),p=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(i=e=>m(l=>[...l,e]),o.length>0){let e=o.splice(0,o.length);m(l=>[...l,...e])}return()=>{i=null}},[]);let x=u[0],j=(0,s.useCallback)(e=>{x&&(x.resolve(e),m(e=>e.slice(1)))},[x]);return(0,a.V)(p,!!x,h),(0,s.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),j(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,j]),(0,r.jsxs)(r.Fragment,{children:[d,x&&(0,r.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,r.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{id:"modal-title",children:null!=(l=x.title)?l:c("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,r.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,r.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,r.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:c("dialog.cancel")}),(0,r.jsx)("button",{ref:h,type:"button",className:x.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(t=x.okLabel)?t:c("dialog.ok")})]})]})})]})}},1896:(e,l,t)=>{Promise.resolve().then(t.bind(t,3197))},3197:(e,l,t)=>{"use strict";t.r(l),t.d(l,{default:()=>h});var r=t(3365),s=t(1521),n=t(2285),a=t(8197),i=t.n(a),o=t(5549),d=t(867),c=t(1035),u=t(4784),m=t(2244);function h(){let{t:e}=(0,d.kj)(),[l,t]=(0,s.useState)(null),[n,a]=(0,s.useState)(!1),[i,u]=(0,s.useState)("");(0,s.useEffect)(()=>{o.FH.models().then(t).catch(()=>void 0)},[]);let m=async()=>{if(await (0,c.Z)(e("model.refreshConfirm"))){a(!0),u(e("model.refreshing"));try{var l;let r=await o.FH.models().then(()=>o.FH.refreshModels());t(r),u(0===r.options.length?null!=(l=r.note)?l:e("model.none"):e("model.refreshed",{n:r.options.length}))}catch(e){u(e.message)}finally{a(!1)}}},h={catalogue:l,setCatalogue:t,refreshModels:m,refreshing:n,refreshMsg:i};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"panel",children:[(0,r.jsx)("h2",{children:e("def.title")}),(0,r.jsx)("p",{className:"muted small",children:e("def.intro")}),(0,r.jsx)("p",{className:"why",children:e("def.autoSave")})]}),(0,r.jsx)(f,{}),(0,r.jsx)(b,{...h}),(0,r.jsx)(w,{...h}),(0,r.jsx)(k,{})]})}function p(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:900,t=(0,s.useRef)(null),r=(0,s.useRef)(null),n=(0,s.useRef)(e);return n.current=e,(0,s.useEffect)(()=>()=>{t.current&&clearTimeout(t.current),r.current&&n.current(r.current.value)},[]),e=>{t.current&&clearTimeout(t.current),r.current={value:e},t.current=setTimeout(()=>{r.current=null,n.current(e)},l)}}function x(e){let{id:l,value:t,min:n,max:a,onChange:i,disabled:o}=e,[d,c]=(0,s.useState)(String(t));return(0,s.useEffect)(()=>c(e=>j(e)===t?e:String(t)),[t]),(0,r.jsx)("input",{id:l,type:"number",min:n,max:a,step:1,value:d,onChange:e=>{c(e.target.value);let l=j(e.target.value);null!==l&&l>=n&&l<=a&&i(l)},onBlur:()=>{let e=j(d),l=null===e?t:Math.max(n,Math.min(a,e));c(String(l)),l!==t&&i(l)},style:{width:"9ch"},disabled:o})}function j(e){if(""===e.trim())return null;let l=Number(e);return Number.isInteger(l)?l:null}function v(e){let{msg:l,onSave:t}=e,{t:s}=(0,d.kj)();return(0,r.jsxs)("div",{className:"row",style:{marginTop:6},children:[t&&(0,r.jsx)("button",{className:"quiet",onClick:t,title:s("def.saveAnywayWhy"),children:s("def.saveAnyway")}),(0,r.jsx)("span",{className:"muted small",role:"status",children:l||s("def.savedAutomatically")})]})}function f(){var e,l,t;let{t:n}=(0,d.kj)(),[a,i]=(0,s.useState)(null),[c,u]=(0,s.useState)(""),[m,h]=(0,s.useState)(""),[x,j]=(0,s.useState)(""),[f,g]=(0,s.useState)(""),[k,b]=(0,s.useState)(!1),[w,N]=(0,s.useState)(""),[S,D]=(0,s.useState)(""),C=(0,s.useCallback)(async()=>{try{let e=await o.FH.project();i(e),u(e.rootDir),h(e.name),g("")}catch(e){g(e.message)}},[]);(0,s.useEffect)(()=>{C()},[C]);let F=async(e,l)=>{b(!0),j("");try{let t=await o.FH.setProject(e);return i(t),u(t.rootDir),j(l(t)),g(""),!0}catch(e){return g(e.message),!1}finally{b(!1)}},T=e=>F({rootDir:e},e=>e.rootDir?n("proj.saved",{dir:e.rootDir}):n("proj.cleared")),M=e=>F({name:e},()=>n("proj.nameSaved")),R=p(T),E=p(M),A=async(e,l)=>{b(!0);try{var t;let r=await o.FH.browseFolder(l.trim()||void 0);r.ok?e(r.path):r.cancelled||g(null!=(t=r.reason)?t:"")}catch(e){g(e.message)}finally{b(!1)}},B=null!=(e=null==a?void 0:a.others)?e:[],I=e=>e.map(e=>({name:e.name,rootDir:e.rootDir,...e.mirror?{mirror:e.mirror}:{},...!1===e.desktop?{desktop:!1}:{}})),H=e=>e?n("proj.desktopOn"):n("proj.desktopOff"),P=async()=>{await F({others:[...I(B),{name:w.trim(),rootDir:S.trim()}]},e=>n("proj.othersSaved",{n:e.others.length}))&&(N(""),D(""))};return(0,r.jsxs)("div",{className:"panel",id:"project",children:[(0,r.jsx)("h2",{children:n("proj.title")}),(0,r.jsx)("p",{className:"muted small",children:n("proj.intro")}),f&&(0,r.jsx)("div",{className:"err",children:f}),a&&(0,r.jsxs)("div",{className:"option".concat(a.mirrorToDesktop?" warned":""),style:{marginBottom:12},children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:a.mirrorToDesktop,onChange:e=>{F({mirrorToDesktop:e.target.checked},e=>e.mirrorToDesktop?n("proj.mirrorOn",{root:e.contextRoot}):n("proj.mirrorOff"))},disabled:k}),(0,r.jsx)("span",{children:n("proj.mirrorToDesktop")})]}),(0,r.jsx)("p",{className:"why",children:n("proj.mirrorToDesktopWhy",{root:a.contextRoot})})]}),(0,r.jsx)("p",{className:"muted small",children:n("proj.listIntro")}),(0,r.jsx)(y,{name:m,dir:c,repoOk:!!(null==a?void 0:a.repoOk),repoProblem:null==a?void 0:a.repoProblem,mirror:null==a?void 0:a.mirror,isDefault:!0,busy:k,onNameInput:e=>{h(e),E(e)},onName:e=>void M(e),onDirInput:e=>{u(e),R(e)},onDir:e=>void T(e),onBrowse:()=>void A(e=>void T(e),c),onRemove:(null==a?void 0:a.rootDir)?()=>void T(""):void 0,removeLabel:n("proj.clear"),onFolders:e=>F({mirror:e},()=>n("proj.foldersSaved")),desktop:null==(l=null==a?void 0:a.desktop)||l,desktopMaster:null!=(t=null==a?void 0:a.mirrorToDesktop)&&t,onDesktop:e=>void F({desktop:e},()=>H(e))}),(0,r.jsx)(v,{msg:x}),a&&!a.rootDir&&(0,r.jsx)("p",{className:"muted small",style:{marginTop:8},children:n("proj.none")}),B.map((e,l)=>{var t;return(0,r.jsx)(y,{name:e.name,dir:e.rootDir,repoOk:e.repoOk,repoProblem:e.repoProblem,mirror:e.mirror,busy:k,onName:l=>void F({others:I(B.map(t=>t.name===e.name?{...t,name:l}:t))},()=>n("proj.nameSaved")),onDir:l=>void F({others:I(B.map(t=>t.name===e.name?{...t,rootDir:l}:t))},()=>n("proj.othersSaved",{n:B.length})),onBrowse:()=>void A(l=>void F({others:I(B.map(t=>t.name===e.name?{...t,rootDir:l}:t))},()=>n("proj.othersSaved",{n:B.length})),e.rootDir),onRemove:()=>{let l;l=e.name,F({others:I(B.filter(e=>e.name!==l))},e=>n("proj.othersSaved",{n:e.others.length}))},removeLabel:n("proj.otherRemove"),onFolders:l=>{let t;return t=e.name,F({others:I(B.map(e=>e.name===t?{...e,mirror:l}:e))},()=>n("proj.foldersSaved"))},desktop:e.desktop,desktopMaster:null!=(t=null==a?void 0:a.mirrorToDesktop)&&t,onDesktop:l=>void F({others:I(B.map(t=>t.name===e.name?{...t,desktop:l}:t))},()=>H(l))},"other-".concat(l))}),(0,r.jsx)("h3",{id:"others",children:n("proj.addTitle")}),(0,r.jsx)("p",{className:"muted small",children:n("proj.othersIntro")}),(0,r.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,r.jsx)("input",{type:"text","aria-label":n("proj.entryName"),value:w,onChange:e=>N(e.target.value),placeholder:n("proj.entryName"),disabled:k,style:{width:160}}),(0,r.jsx)("input",{type:"text",className:"grow","aria-label":n("proj.entryDir"),value:S,onChange:e=>D(e.target.value),placeholder:"C:\\Projects\\my-app-tests",disabled:k}),(0,r.jsx)("button",{onClick:()=>void A(e=>D(e),S),disabled:k,children:n("mirror.browse")}),(0,r.jsx)("button",{className:"primary",onClick:()=>void P(),disabled:k||!w.trim()||!S.trim(),children:n("proj.otherAdd")})]}),(0,r.jsx)("h3",{children:n("proj.affects")}),(0,r.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,r.jsx)("li",{children:n("proj.affectsNew")}),(0,r.jsx)("li",{children:n("proj.affectsExisting")}),(0,r.jsx)("li",{children:n("proj.affectsPlan")}),(0,r.jsx)("li",{children:n("proj.affectsNever")})]})]})}function y(e){var l;let{name:t,dir:a,repoOk:i,repoProblem:o,mirror:c,isDefault:u=!1,busy:m,onNameInput:h,onName:p,onDirInput:x,onDir:j,onBrowse:v,onRemove:f,removeLabel:y,onFolders:k,desktop:b,desktopMaster:w,onDesktop:N}=e,{t:S}=(0,d.kj)(),D=(0,s.useId)(),[C,F]=(0,s.useState)(t),[T,M]=(0,s.useState)(a);return(0,s.useEffect)(()=>F(t),[t]),(0,s.useEffect)(()=>M(a),[a]),(0,r.jsxs)("div",{className:"panel inner",style:{marginTop:10},children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{style:{width:"min(200px, 100%)"},children:[(0,r.jsx)("label",{htmlFor:"".concat(D,"-name"),children:S("proj.entryName")}),(0,r.jsx)("input",{id:"".concat(D,"-name"),type:"text",value:C,onChange:e=>{F(e.target.value),null==h||h(e.target.value)},onBlur:()=>{(C!==t||h)&&p(C)},placeholder:a?null!=(l=a.replace(/[\/]+$/,"").split(/[\/]/).pop())?l:"":S("proj.namePlaceholder")})]}),(0,r.jsxs)("div",{className:"grow",children:[(0,r.jsx)("label",{htmlFor:"".concat(D,"-dir"),children:S("proj.entryDir")}),(0,r.jsx)("input",{id:"".concat(D,"-dir"),type:"text",value:T,onChange:e=>{M(e.target.value),null==x||x(e.target.value)},onBlur:()=>{(T!==a||x)&&j(T)},placeholder:"C:\\Projects\\my-app"})]}),(0,r.jsx)("button",{onClick:v,disabled:m,children:S("mirror.browse")}),f&&(0,r.jsx)("button",{className:"quiet",onClick:f,disabled:m,children:y})]}),(0,r.jsxs)("div",{className:"row small",style:{marginTop:6},children:[u&&(0,r.jsx)("span",{className:"chip",title:S("proj.isDefaultWhy"),children:S("proj.isDefault")}),a&&(0,r.jsx)("span",{className:"badge ".concat(i?"done":""),title:i?S("proj.isRepo"):o,children:S(i?"proj.otherRepo":"proj.otherNotRepo")}),a&&!i&&(0,r.jsx)("span",{className:"muted",children:o||S("proj.notRepoWhy")})]}),a&&(0,r.jsxs)("details",{className:"small",style:{marginTop:8},children:[(0,r.jsx)("summary",{children:S("proj.folders")}),(0,r.jsx)(g,{rootDir:a,value:c,onSave:k,busy:m})]}),a&&(0,r.jsxs)("label",{className:"option-inline small",style:{marginTop:8},title:w?void 0:S("proj.desktopMasterOff"),children:[(0,r.jsx)("input",{type:"checkbox",checked:b,disabled:m||!w,onChange:e=>N(e.target.checked)})," ",S("proj.desktopThis"),!w&&(0,r.jsxs)("span",{className:"muted",children:[" — ",S("proj.desktopMasterOff")]})]}),a&&i&&(0,r.jsx)(n.b,{dir:a})]})}function g(e){var l,t,n,a;let{rootDir:i,value:o,onSave:u,busy:h}=e,{t:x}=(0,d.kj)(),j=(0,s.useId)(),[f,y]=(0,s.useState)((null!=(l=null==o?void 0:o.includeDirs)?l:[]).join("\n")),[g,k]=(0,s.useState)((null!=(t=null==o?void 0:o.excludeDirs)?t:[]).join("\n")),[b,w]=(0,s.useState)(null==(n=null==o?void 0:o.respectGitignore)||n),[N,S]=(0,s.useState)(null!=(a=null==o?void 0:o.includeEnvFiles)&&a),D=e=>e.split("\n").map(e=>e.trim()).filter(Boolean),[C,F]=(0,s.useState)(""),T=async e=>{let l={includeDirs:D(f),excludeDirs:D(g),respectGitignore:b,includeEnvFiles:N,...e};await u(l)&&F(x("proj.foldersSaved"))},M=p(T),R=async e=>{(!e||await (0,c.Z)(x("mirror.envWarn")))&&(S(e),T({includeEnvFiles:e}))};return(0,r.jsxs)("div",{style:{marginTop:8},children:[(0,r.jsx)("p",{className:"muted small",children:x("proj.foldersHint")}),(0,r.jsxs)("div",{className:"row",style:{alignItems:"flex-start"},children:[(0,r.jsxs)("div",{className:"grow",children:[(0,r.jsx)("label",{htmlFor:"".concat(j,"-include"),children:x("mirror.include")}),(0,r.jsx)("textarea",{id:"".concat(j,"-include"),value:f,onChange:e=>{y(e.target.value),M({includeDirs:D(e.target.value),excludeDirs:D(g)})},placeholder:"src\ntests",style:{minHeight:70}})]}),(0,r.jsxs)("div",{className:"grow",children:[(0,r.jsx)("label",{htmlFor:"".concat(j,"-exclude"),children:x("mirror.exclude")}),(0,r.jsx)("textarea",{id:"".concat(j,"-exclude"),value:g,onChange:e=>{k(e.target.value),M({includeDirs:D(f),excludeDirs:D(e.target.value)})},placeholder:"src/generated",style:{minHeight:70}})]})]}),(0,r.jsx)(m.k,{rootDir:i,respectGitignore:b,includeEnvFiles:N,include:D(f),exclude:D(g),onChange:(e,l)=>{y(e.join("\n")),k(l.join("\n")),M({includeDirs:e,excludeDirs:l})}}),(0,r.jsx)("div",{className:"option",children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:b,onChange:e=>{w(e.target.checked),T({respectGitignore:e.target.checked})}}),(0,r.jsx)("span",{children:x("mirror.gitignore")})]})}),(0,r.jsx)("div",{className:"option".concat(N?" warned":""),children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:N,onChange:e=>void R(e.target.checked)}),(0,r.jsx)("span",{children:x("mirror.env")})]})}),(0,r.jsx)(v,{msg:h?"":C})]})}function k(){let{t:e}=(0,d.kj)(),[l,t]=(0,s.useState)(null),n=(0,s.useRef)(null),a=(0,s.useRef)(Promise.resolve()),[i,c]=(0,s.useState)(2),[u,m]=(0,s.useState)(2),[h,j]=(0,s.useState)(60),[f,y]=(0,s.useState)(240),[g,k]=(0,s.useState)(900),[b,w]=(0,s.useState)("none"),[N,S]=(0,s.useState)("confirm"),[D,C]=(0,s.useState)("ask"),[F,T]=(0,s.useState)(""),[M,R]=(0,s.useState)("");(0,s.useEffect)(()=>{o.FH.settings().then(e=>{var l,r,s,a,i,o;n.current=e.raw,t(e.raw);let d=null!=(l=e.raw.limits)?l:{};c("number"==typeof d.retryBlockedInFreshChat?d.retryBlockedInFreshChat:2),m("number"==typeof d.minApproachesBeforeBlocked?d.minApproachesBeforeBlocked:2),j("number"==typeof d.maxIterations?d.maxIterations:60),y("number"==typeof d.maxRunMinutes?d.maxRunMinutes:240);let u=null!=(r=e.raw.copilot)?r:{};k("number"==typeof u.replyTimeoutSec?u.replyTimeoutSec:900);let h=null!=(s=e.raw.execution)?s:{};w(null!=(a=h.isolation)?a:"none"),S(null!=(i=h.mode)?i:"confirm"),C(null!=(o=h.networkFetch)?o:"ask")}).catch(e=>R(e.message))},[]);let E=(l,r,s)=>{let i=async()=>{var a;if(!n.current)return;let i=await o.FH.settings().then(e=>e.raw).catch(()=>n.current),d={...i,[l]:{...null!=(a=i[l])?a:{},[r]:s}};T("");try{await o.FH.saveSettings(d),n.current=d,t(d),T(e("exec.saved")),R("")}catch(e){R(e.message)}},d=a.current.then(i);return a.current=d.catch(()=>void 0),d},A=p(e=>E("limits","retryBlockedInFreshChat",e)),B=p(e=>E("limits","minApproachesBeforeBlocked",e)),I=p(e=>E("limits","maxIterations",e)),H=p(e=>E("limits","maxRunMinutes",e)),P=p(e=>E("copilot","replyTimeoutSec",e)),W=(e,l)=>E("execution",e,l);return(0,r.jsxs)("div",{className:"panel",id:"execution",children:[(0,r.jsx)("h2",{children:e("exec.title")}),(0,r.jsx)("p",{className:"muted small",children:e("exec.intro")}),M&&(0,r.jsx)("div",{className:"err",children:M}),(0,r.jsx)("label",{htmlFor:"min-approaches",children:e("exec.minApproaches")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(x,{id:"min-approaches",value:u,min:2,max:20,onChange:e=>{m(e),B(e)},disabled:!l}),(0,r.jsx)("span",{className:"muted small",children:e("exec.minApproachesUnit")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.minApproachesWhy")}),(0,r.jsx)("label",{htmlFor:"retry-blocked",children:e("exec.retryBlocked")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(x,{id:"retry-blocked",value:i,min:0,max:5,onChange:e=>{c(e),A(e)},disabled:!l}),(0,r.jsx)("span",{className:"muted small",children:e("exec.retryBlockedTimes")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.retryBlockedWhy")}),(0,r.jsx)("label",{htmlFor:"max-iterations",children:e("exec.maxIterations")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(x,{id:"max-iterations",value:h,min:5,max:200,onChange:e=>{j(e),I(e)},disabled:!l}),(0,r.jsx)("span",{className:"muted small",children:e("exec.maxIterationsUnit")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.maxIterationsWhy")}),(0,r.jsx)("label",{htmlFor:"max-minutes",children:e("exec.maxRunMinutes")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(x,{id:"max-minutes",value:f,min:10,max:1440,onChange:e=>{y(e),H(e)},disabled:!l}),(0,r.jsx)("span",{className:"muted small",children:e("exec.maxRunMinutesUnit")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.maxRunMinutesWhy")}),(0,r.jsx)("label",{htmlFor:"reply-timeout",children:e("exec.replyTimeout")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(x,{id:"reply-timeout",value:g,min:60,max:10800,onChange:e=>{k(e),P(e)},disabled:!l}),(0,r.jsx)("span",{className:"muted small",children:e("exec.replyTimeoutUnit")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.replyTimeoutWhy")}),(0,r.jsx)("label",{htmlFor:"isolation",children:e("exec.isolation")}),(0,r.jsxs)("select",{id:"isolation",value:b,onChange:e=>{let l=e.target.value;w(l),W("isolation",l)},disabled:!l,children:[(0,r.jsx)("option",{value:"none",children:e("exec.isolationNone")}),(0,r.jsx)("option",{value:"none-accepted",children:e("exec.isolationNoneAccepted")}),(0,r.jsx)("option",{value:"separate-account",children:e("exec.isolationAccount")}),(0,r.jsx)("option",{value:"sandbox",children:e("exec.isolationSandbox")}),(0,r.jsx)("option",{value:"vm",children:e("exec.isolationVm")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.isolationWhy")}),(0,r.jsx)("label",{htmlFor:"start-mode",children:e("exec.startMode")}),(0,r.jsxs)("select",{id:"start-mode",value:N,onChange:e=>{let l=e.target.value;S(l),W("mode",l)},disabled:!l,children:[(0,r.jsx)("option",{value:"confirm",children:e("exec.startModeAsk")}),(0,r.jsx)("option",{value:"unattended",children:e("exec.startModeAuto")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.startModeWhy")}),(0,r.jsx)("label",{htmlFor:"network-fetch",children:e("exec.networkFetch")}),(0,r.jsxs)("select",{id:"network-fetch",value:D,onChange:e=>{let l=e.target.value;C(l),W("networkFetch",l)},disabled:!l,children:[(0,r.jsx)("option",{value:"ask",children:e("exec.networkFetchAsk")}),(0,r.jsx)("option",{value:"refuse",children:e("exec.networkFetchRefuse")}),(0,r.jsx)("option",{value:"run",children:e("exec.networkFetchRun")})]}),(0,r.jsx)(v,{msg:F}),(0,r.jsx)("p",{className:"why",children:e("exec.networkFetchWhy")})]})}function b(e){var l;let{catalogue:t,setCatalogue:n,refreshModels:a,refreshing:i,refreshMsg:c}=e,{t:m}=(0,d.kj)(),h=(0,d.W3)(),[p,x]=(0,s.useState)(""),[j,f]=(0,s.useState)(""),[y,g]=(0,s.useState)(!1),k=null!=(l=null==t?void 0:t.defaultModel)?l:"",b=async e=>{g(!0),x("");try{let l=await o.FH.setDefaultModel(e);t&&n({...t,defaultModel:l.defaultModel}),x(l.defaultModel?m("def.modelSaved",{name:l.defaultModel}):m("def.modelCleared")),f("")}catch(e){f(e.message)}finally{g(!1)}};return(0,r.jsxs)("div",{className:"panel",id:"model",children:[(0,r.jsx)("h2",{children:m("def.modelTitle")}),(0,r.jsx)("p",{className:"muted small",children:m("def.modelIntro")}),j&&(0,r.jsx)("div",{className:"err",children:j}),(0,r.jsx)("label",{htmlFor:"default-model",children:m("def.modelField")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(u.Y,{id:"default-model",chosen:k,onChange:e=>void b(e),none:m("def.modelNone"),catalogue:t,disabled:y||i}),(0,r.jsx)("button",{className:"quiet",onClick:()=>void b(""),disabled:y||!k,children:m("proj.clear")}),(0,r.jsx)("button",{onClick:()=>void a(),disabled:y||i,children:m("model.refresh")})]}),(0,r.jsx)(v,{msg:p||c}),(0,r.jsx)("p",{className:"muted small",style:{marginTop:8},children:(null==t?void 0:t.readAt)?m("model.readAt",{t:h(t.readAt),n:t.options.length}):m("model.neverRead")}),(0,r.jsx)("h3",{children:m("proj.affects")}),(0,r.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,r.jsx)("li",{children:m("def.modelAffectsNew")}),(0,r.jsx)("li",{children:m("def.modelAffectsExisting")}),(0,r.jsx)("li",{children:m("def.modelAffectsBatch")})]})]})}function w(e){var l,t;let{catalogue:n,setCatalogue:a,refreshModels:c,refreshing:m,refreshMsg:h}=e,{t:p}=(0,d.kj)(),[x,j]=(0,s.useState)(""),[f,y]=(0,s.useState)(""),[g,k]=(0,s.useState)(!1),b=null!=(l=null==n?void 0:n.defaultReviewModel)?l:"",w=async e=>{k(!0),j("");try{let l=await o.FH.setDefaultReviewModel(e);n&&a({...n,defaultReviewModel:l.defaultReviewModel}),j(l.defaultReviewModel?p("def.reviewSaved",{name:l.defaultReviewModel}):p("def.reviewCleared")),y("")}catch(e){y(e.message)}finally{k(!1)}},N=""!==b&&b===(null!=(t=null==n?void 0:n.defaultModel)?t:"");return(0,r.jsxs)("div",{className:"panel",id:"review",children:[(0,r.jsx)("h2",{children:p("def.reviewTitle")}),(0,r.jsx)("p",{className:"muted small",children:p("def.reviewIntro")}),f&&(0,r.jsx)("div",{className:"err",children:f}),(0,r.jsx)("label",{htmlFor:"default-review-model",children:p("def.reviewField")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(u.Y,{id:"default-review-model",chosen:b,onChange:e=>void w(e),none:p("def.reviewNone"),catalogue:n,disabled:g||m}),(0,r.jsx)("button",{className:"quiet",onClick:()=>void w(""),disabled:g||!b,children:p("proj.clear")}),(0,r.jsx)("button",{onClick:()=>void c(),disabled:g||m,children:p("model.refresh")})]}),N&&(0,r.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:p("def.reviewSame")}),(0,r.jsx)(v,{msg:x||h}),(0,r.jsx)("h3",{children:p("proj.affects")}),(0,r.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,r.jsx)("li",{children:p("def.reviewAffectsNew")}),(0,r.jsx)("li",{children:p("def.reviewAffectsExisting")}),(0,r.jsx)("li",{children:p("def.reviewAffectsBatch")})]}),(0,r.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,r.jsx)(i(),{href:"/",className:"button-link plain",children:p("proj.toSessions")}),(0,r.jsx)(i(),{href:"/import",className:"button-link quiet",children:p("proj.toImport")})]})]})}},4969:(e,l,t)=>{"use strict";t.d(l,{V:()=>n});var r=t(1521);let s='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function n(e,l,t){(0,r.useEffect)(()=>{var r,n;if(!l)return;let a=document.activeElement instanceof HTMLElement?document.activeElement:null,i=e.current,o=null!=(n=null!=(r=null==t?void 0:t.current)?r:null==i?void 0:i.querySelector(s))?n:null;null==o||o.focus();let d=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],r=l[l.length-1],n=i.contains(document.activeElement);e.shiftKey&&(document.activeElement===t||!n)?(e.preventDefault(),r.focus()):e.shiftKey||document.activeElement!==r&&n||(e.preventDefault(),t.focus())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),a&&document.contains(a)&&a.focus()}},[e,l,t])}}},e=>{e.O(0,[197,867,549,295,347,131,358],()=>e(e.s=1896)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[810],{3256:(e,s,t)=>{Promise.resolve().then(t.bind(t,4627))},4627:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>F});var n=t(3365),a=t(1521),l=t(8197),i=t.n(l),r=t(5549),c=t(7527),d=t(4969),o=t(1366),u=t(3523),h=t(3374),m=t(867),g=t(1910),p=t(5132);function x(){let{t:e}=(0,m.kj)(),[s,t]=(0,a.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"info-dot","aria-expanded":s,"aria-label":e("row.info"),title:e("row.info"),onClick:()=>t(e=>!e),children:"i"}),s&&(0,n.jsxs)("div",{className:"notice info-panel",children:[(0,n.jsx)("strong",{children:e("row.infoTitle")}),(0,n.jsxs)("dl",{className:"small",children:[(0,n.jsx)("dt",{children:e("reg.openTask")}),(0,n.jsx)("dd",{children:e("row.infoOpenTask")}),(0,n.jsx)("dt",{children:e("save.log")}),(0,n.jsx)("dd",{children:e("save.why")}),(0,n.jsx)("dt",{children:e("home.col.chat")}),(0,n.jsx)("dd",{children:e("row.infoChat")})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:e("row.infoExports")}),(0,n.jsxs)("dl",{className:"small",children:[(0,n.jsx)("dt",{children:e("reg.exportPlan")}),(0,n.jsx)("dd",{children:e("reg.exportPlanWhy")}),(0,n.jsx)("dt",{children:e("reg.exportDomain")}),(0,n.jsx)("dd",{children:e("reg.exportDomainWhy")}),(0,n.jsx)("dt",{children:e("reg.exportBot")}),(0,n.jsx)("dd",{children:e("reg.exportBotWhy")})]}),(0,n.jsx)(p.s,{text:e("row.infoWhich"),className:"small"})]})]})}function j(e){let{onChange:s}=e,{t}=(0,m.kj)(),[l,i]=(0,a.useState)(null),[d,o]=(0,a.useState)(!1),[u,h]=(0,a.useState)(""),g=(0,a.useCallback)(async()=>{try{i(await r.FH.batch())}catch(e){}},[]);(0,c.z)(g,3e3);let p=async e=>{o(!0),h("");try{"pause"===e?await r.FH.pauseBatch():"resume"===e?await r.FH.resumeBatch():await r.FH.stopBatch(),await g(),null==s||s()}catch(e){h(e.message)}finally{o(!1)}};return(null==l?void 0:l.running)?(0,n.jsxs)("div",{className:"row",style:{marginBottom:8},children:[l.pausing?(0,n.jsx)("button",{className:"primary",disabled:d,onClick:()=>void p("resume"),title:t("batch.resumeWhy"),children:t("batch.resume")}):(0,n.jsx)("button",{disabled:d||l.stopping,onClick:()=>void p("pause"),title:t("batch.pauseWhy"),children:t("batch.pause")}),(0,n.jsx)("button",{className:"danger",disabled:d||l.stopping,onClick:()=>void p("stop"),title:t("batch.stopWhy"),children:t("batch.stop")}),l.pausing&&!l.stopping&&(0,n.jsx)("span",{className:"muted small",children:t("batch.pausing")}),l.stopping&&(0,n.jsx)("span",{className:"muted small",children:t("batch.stopping")}),u&&(0,n.jsx)("span",{className:"err small",children:u})]}):null}var v=t(3041),N=t(1035),k=t(8934),f=t(4811),b=t(2876);let w=["queued","running","waiting-approval"],y=["blocked","failed","aborted","limit-reached"],I=e=>!!e.continuable;function C(e){let{run:s}=e,{t}=(0,m.kj)(),a=s.entries.some(u.DG),l=(0,h.c)(a),i=(0,u.eZ)(s,s.entries,l);return(0,n.jsx)(n.Fragment,{children:t(i.live?"reg.runRunning":"reg.runTook",{d:(0,r.c5)(i.ms)})})}function S(e){let s=new Map,t=[];for(let n of e){if(!n.runGroup){t.push(n);continue}let e=s.get(n.runGroup.id);e?e.entries.push(n):s.set(n.runGroup.id,{...n.runGroup,entries:[n]})}let n=[...s.values()].sort((e,s)=>Date.parse(s.startedAt)-Date.parse(e.startedAt));for(let e of n)e.entries.sort((e,s)=>{var t,n;return Date.parse(null!=(t=e.startedAt)?t:e.createdAt)-Date.parse(null!=(n=s.startedAt)?n:s.createdAt)});return{runs:n,loose:t}}function F(){let{t:e}=(0,m.kj)(),s=(0,m.W3)(),[t,l]=(0,a.useState)(null),[i,d]=(0,a.useState)(""),[o,u]=(0,a.useState)(""),[h,g]=(0,a.useState)("flow"),[p,x]=(0,a.useState)(""),[v,N]=(0,a.useState)(""),[k,f]=(0,a.useState)(""),b=(0,a.useCallback)(async()=>{try{l(await r.FH.tasks()),u(new Date().toISOString()),d("")}catch(e){d(e.message)}},[]);(0,c.z)(b,6e3);let I=(0,a.useMemo)(()=>{let e=new Map;for(let s of null!=t?t:[])e.has(s.sessionId)||e.set(s.sessionId,s.sessionName);return[...e.entries()]},[t]),C=(0,a.useMemo)(()=>{let e=k.trim().toLowerCase();return(null!=t?t:[]).filter(s=>{var t,n;return(!p||s.sessionId===p)&&(!v||s.status===v)&&(!e||"".concat(s.title," ").concat(null!=(t=s.summary)?t:""," ").concat(null!=(n=s.reason)?n:""," ").concat(s.sessionName).toLowerCase().includes(e))})},[t,p,v,k]),F=(0,a.useMemo)(()=>{let e=null!=t?t:[];return{total:e.length,done:e.filter(e=>"done"===e.status).length,running:e.filter(e=>"running"===e.status||"waiting-approval"===e.status).length,open:e.filter(e=>"queued"===e.status).length,failed:e.filter(e=>y.includes(e.status)).length}},[t]),R=(0,a.useMemo)(()=>{let e=new Map;for(let n of null!=t?t:[]){var s;n.runGroup&&e.set(n.runGroup.id,(null!=(s=e.get(n.runGroup.id))?s:0)+1)}return e},[t]),q=(0,a.useMemo)(()=>S(C),[C]),E=C.filter(e=>"running"===e.status||"waiting-approval"===e.status),M=C.filter(e=>"queued"===e.status),D=[...C.filter(e=>y.includes(e.status)&&"stop"===e.sessionOnFailure&&!e.sessionRunning&&M.some(s=>s.sessionId===e.sessionId)),...M].sort((e,s)=>{var t,n;return(null!=(t=e.sessionRunOrder)?t:Number.MAX_SAFE_INTEGER)-(null!=(n=s.sessionRunOrder)?n:Number.MAX_SAFE_INTEGER)||e.position-s.position}),_=C.filter(e=>!w.includes(e.status)).sort((e,s)=>{var t,n,a,l;return Date.parse(null!=(n=null!=(t=s.finishedAt)?t:s.startedAt)?n:s.createdAt)-Date.parse(null!=(l=null!=(a=e.finishedAt)?a:e.startedAt)?l:e.createdAt)}),B=""!==p||""!==v||""!==k.trim();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:e("reg.title")}),(0,n.jsx)("span",{className:"muted small",children:o&&e("reg.updated",{t:s(o)})}),(0,n.jsx)("button",{className:"quiet",onClick:()=>void b(),children:e("reg.refresh")})]}),(0,n.jsx)("p",{className:"muted small",children:e("reg.hint")}),(0,n.jsx)(W,{sessions:I}),(0,n.jsxs)("div",{className:"counts",children:[(0,n.jsxs)("div",{className:"count",children:[(0,n.jsx)("div",{className:"n",children:F.total}),(0,n.jsx)("div",{className:"k",children:e("reg.total")})]}),(0,n.jsxs)("div",{className:"count done",children:[(0,n.jsx)("div",{className:"n",children:F.done}),(0,n.jsx)("div",{className:"k",children:e("reg.done")})]}),(0,n.jsxs)("div",{className:"count running",children:[(0,n.jsx)("div",{className:"n",children:F.running}),(0,n.jsx)("div",{className:"k",children:e("reg.runningCount")})]}),(0,n.jsxs)("div",{className:"count queued",children:[(0,n.jsx)("div",{className:"n",children:F.open}),(0,n.jsx)("div",{className:"k",children:e("reg.open")})]}),(0,n.jsxs)("div",{className:"count failed",children:[(0,n.jsx)("div",{className:"n",children:F.failed}),(0,n.jsx)("div",{className:"k",children:e("reg.failedCount")})]})]})]}),i&&(0,n.jsx)("div",{className:"panel err",children:i}),(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"toolbar",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"f-session",style:{margin:0},children:e("reg.filterSession")}),(0,n.jsxs)("select",{id:"f-session",value:p,onChange:e=>x(e.target.value),children:[(0,n.jsx)("option",{value:"",children:e("reg.allSessions")}),I.map(e=>{let[s,t]=e;return(0,n.jsx)("option",{value:s,children:t},s)})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"f-status",style:{margin:0},children:e("reg.filterStatus")}),(0,n.jsxs)("select",{id:"f-status",value:v,onChange:e=>N(e.target.value),children:[(0,n.jsx)("option",{value:"",children:e("reg.allStatuses")}),["queued","running","waiting-approval","done","blocked","failed","aborted","limit-reached"].map(s=>(0,n.jsx)("option",{value:s,children:e("status.".concat(s))},s))]})]}),(0,n.jsxs)("div",{className:"grow",children:[(0,n.jsx)("label",{htmlFor:"f-q",style:{margin:0},children:e("reg.search")}),(0,n.jsx)("input",{id:"f-q",type:"text",value:k,onChange:e=>f(e.target.value),placeholder:e("reg.searchPlaceholder")})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{margin:0},id:"view-label",children:e("reg.viewLabel")}),(0,n.jsxs)("div",{className:"segmented",role:"group","aria-labelledby":"view-label",children:[(0,n.jsx)("button",{type:"button","aria-pressed":"flow"===h,onClick:()=>g("flow"),children:e("reg.viewFlow")}),(0,n.jsx)("button",{type:"button","aria-pressed":"runs"===h,onClick:()=>g("runs"),children:e("reg.groupBy")}),(0,n.jsx)("button",{type:"button","aria-pressed":"list"===h,onClick:()=>g("list"),children:e("reg.viewList")})]})]}),B&&(0,n.jsx)("button",{className:"quiet",onClick:()=>{x(""),N(""),f("")},children:e("reg.clear")})]}),null===t&&(0,n.jsx)("div",{className:"muted",children:e("home.loading")}),null!==t&&0===t.length&&(0,n.jsx)("div",{className:"empty",children:e("reg.none")}),null!==t&&t.length>0&&0===C.length&&(0,n.jsx)("div",{className:"empty",children:e("reg.noMatch")})]}),"list"===h&&C.length>0&&(0,n.jsx)(O,{entries:[...E,...M,..._]}),"runs"===h&&C.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.runGroup")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.runGroupHint")})]}),q.runs.map(e=>(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)(H,{run:e}),(0,n.jsx)(T,{entries:e.entries,sizes:R,onChange:()=>void b()})]},e.id)),q.loose.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.notInARun")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.notInARunHint")}),(0,n.jsx)(T,{entries:q.loose,sizes:R,onChange:()=>void b()})]})]}),"flow"===h&&(0,n.jsxs)(n.Fragment,{children:[E.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.activeNow")}),(0,n.jsx)(T,{entries:E,sizes:R,onChange:()=>void b()})]}),C.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.upcoming")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.upcomingHint")}),(0,n.jsx)(j,{onChange:()=>void b()}),C.some(e=>e.interrupted&&!e.sessionRunning)&&(0,n.jsxs)("div",{className:"notice caution",role:"status",children:[(0,n.jsx)("strong",{children:e("reg.interruptedTitle")})," ",e("reg.interrupted",{n:C.filter(e=>e.interrupted&&!e.sessionRunning).length})]}),(0,n.jsx)(G,{entries:C,onChange:()=>void b()}),0===D.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noUpcoming")}):(0,n.jsx)(T,{entries:D,upcoming:!0,sizes:R,onChange:()=>void b()})]}),C.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.past")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.pastHint")}),0===_.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noPast")}):(0,n.jsx)(P,{entries:_,sizes:R,onChange:()=>void b()})]}),t&&t.length>0&&(0,n.jsx)(A,{refreshKey:o})]})]})}function A(e){let{refreshKey:s}=e,{t}=(0,m.kj)(),[l,i]=(0,a.useState)(null),[c,d]=(0,a.useState)("");if((0,a.useEffect)(()=>{r.FH.metrics().then(e=>{i(e),d("")}).catch(e=>d(e.message))},[s]),!l)return c?(0,n.jsx)("div",{className:"panel err",children:c}):null;let o=e=>0===e.of?"—":"".concat(e.n," / ").concat(e.of," (").concat(Math.round(100*e.n/e.of),"%)"),u=[["metrics.tasks",e=>"".concat(e.tasks," \xb7 ").concat(t("metrics.attemptsN",{n:e.attempts}))],["metrics.firstPass",e=>o(e.firstPass)],["metrics.doneInTheEnd",e=>o(e.doneInTheEnd)],["metrics.falseCompletion",e=>o(e.falseCompletion)],["metrics.reviewRejection",e=>o(e.reviewRejection)],["metrics.repeatedCommands",e=>o(e.repeatedCommands)],["metrics.noProgress",e=>o(e.noProgress)],["metrics.scopeViolation",e=>o(e.scopeViolation)],["metrics.unrelatedDiff",e=>o(e.unrelatedDiff)],["metrics.resumed",e=>o(e.resumed)],["metrics.freshRetries",e=>String(e.freshRetries)],["metrics.manual",e=>String(e.manualInterventions)],["metrics.ended",e=>Object.entries(e.ended).map(e=>{let[s,n]=e;return"".concat(t("status.".concat(s))," ").concat(n)}).join(", ")||"—"]],h=l.rows[0];return(0,n.jsxs)("section",{className:"panel metrics",children:[(0,n.jsx)("h2",{children:t("metrics.title")}),(0,n.jsx)("p",{className:"muted small",children:t("metrics.hint")}),h&&h.withStats<h.attempts&&(0,n.jsx)("p",{className:"muted small",children:t("metrics.olderAttempts",{n:h.attempts-h.withStats})}),(0,n.jsx)("div",{className:"table-scroll",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t("metrics.col.measure")}),l.rows.map(e=>(0,n.jsx)("th",{children:"all"===e.group?t("metrics.col.all"):e.group},e.group))]})}),(0,n.jsx)("tbody",{children:u.map(e=>{let[s,a]=e;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:t(s)}),l.rows.map(e=>(0,n.jsx)("td",{children:a(e)},e.group))]},s)})})]})})]})}function T(e){let{entries:s,upcoming:t=!1,sizes:l,onChange:c,picking:d}=e,{t:o}=(0,m.kj)(),j=(0,m.W3)(),N=(0,v.e)(null!=c?c:()=>void 0),f=(0,h.c)(s.some(u.DG)),[w,C]=(0,a.useState)(null),[S,F]=(0,a.useState)(new Set),[A,T]=(0,a.useState)(null);return(0,n.jsxs)(n.Fragment,{children:[w&&(0,n.jsx)(q,{entry:w,onClose:e=>{C(null),e&&(null==c||c())}}),(0,n.jsx)("ol",{className:"flow",children:s.map(e=>{var s,a,h,m,v,w,H,P,q,W,G,O,M,D,_,B,z,L,U,X,V,Z,K,Q,J,Y;let $=t&&1===e.queuePosition,ee=e.runGroup?null!=(P=null==l?void 0:l.get(e.runGroup.id))?P:1:0;return(0,n.jsxs)("li",{className:"".concat(e.status).concat($?" next":""),children:[(0,n.jsxs)("div",{className:"head",children:[d&&(0,n.jsx)("input",{type:"checkbox",className:"pick","aria-label":e.title,checked:d.picked.has("".concat(e.sessionId,":").concat(e.taskId)),onChange:()=>d.toggle("".concat(e.sessionId,":").concat(e.taskId))}),(0,n.jsx)("strong",{children:e.title}),(0,n.jsx)("span",{className:"badge ".concat(e.status),children:o("status.".concat(e.status))}),$&&(0,n.jsx)("span",{className:"chip",children:o("reg.next")}),e.limit&&(0,n.jsx)("span",{className:"chip",title:o("reg.limitChipWhy"),children:o("reg.limitChip",{limit:(Y=e.limit,o("limit.".concat(Y.setting),{n:Y.value}))})}),t&&y.includes(e.status)&&(0,n.jsx)("span",{className:"chip",title:o("reg.willRequeueFirstWhy"),children:o("reg.willRequeueFirst")}),e.sessionRunning&&(0,n.jsx)("span",{className:"chip",children:o("reg.sessionRunning")}),e.review&&"skipped"!==e.review.verdict&&(0,n.jsxs)("span",{className:"badge ".concat("pass"===e.review.verdict?"done":"fail"===e.review.verdict?"blocked":"waiting-approval"),title:e.review.stepsRun>0?o("review.ran",{n:e.review.stepsRun}):void 0,children:[o("review.verdict.".concat(e.review.verdict)),e.review.findings>0?" (".concat(e.review.findings,")"):""]}),(null!=(q=e.deviations)?q:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:o("reg.deviationsWhy"),children:o("reg.deviations",{n:null!=(W=e.deviations)?W:0})}),(null!=(G=e.disputes)?G:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:o("reg.disputesWhy"),children:o("reg.disputes",{n:null!=(O=e.disputes)?O:0})}),e.readOnly&&(0,n.jsx)("span",{className:"chip",title:o("reg.readOnlyWhy"),children:o("task.readOnly")}),e.stopCode&&(0,n.jsx)("span",{className:"chip",title:o("stop.why"),children:o("stop.".concat(e.stopCode))}),(null!=(M=null==(s=e.scope)?void 0:s.length)?M:0)>0&&(0,n.jsx)("span",{className:"chip",title:o("task.scopeWhy"),children:o("task.scope",{paths:(null!=(D=e.scope)?D:[]).join(", ")})}),(null!=(_=e.autoRetries)?_:0)>0&&(0,n.jsx)("span",{className:"badge ".concat("done"===e.status?"done":"blocked"),title:o("reg.retriedFreshWhy"),children:"done"===e.status?o("reg.retriedFreshDone",{n:null!=(B=e.autoRetries)?B:0}):o("reg.retriedFreshStill",{n:null!=(z=e.autoRetries)?z:0})}),e.runGroup&&(0,n.jsx)("span",{className:"chip",title:o("reg.runTitle",{t:ee,s:e.runGroup.sessions,when:j(e.runGroup.startedAt)}),children:ee>1?o("reg.runWith",{n:ee-1}):o("reg.runAlone")})]}),(0,n.jsxs)("div",{className:"when",children:[(0,n.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:e.sessionName})," \xb7 ",e.startedAt?o("task.started",{t:j(e.startedAt)}):o("task.added",{t:j(e.createdAt)}),e.finishedAt?" \xb7 ".concat(o("task.finished",{t:j(e.finishedAt)})):"",void 0!==e.durationMs?" \xb7 ".concat(o("reg.took",{d:(0,r.c5)(e.durationMs)})):"",(0,u.DG)(e)?" \xb7 ".concat(o("task.runningFor",{d:(0,r.c5)((0,u.d5)(e.startedAt,void 0,f))})):"",e.iterations>0?" \xb7 ".concat(o("reg.iterations",{n:e.iterations})):""]}),"queued"===e.status&&(0,n.jsx)("div",{className:"when",children:e.queuePosition&&e.queuePosition>1?o("reg.willFollow",{n:e.queuePosition-1}):e.sessionRunning?o("reg.queuePos",{n:null!=(L=e.queuePosition)?L:1}):o("reg.waitingRun")}),"blocked"===e.status&&(0,n.jsx)("p",{className:"what muted small",children:o("reg.blockedWhat")}),(null!=(U=null==(a=e.attempts)?void 0:a.length)?U:0)>0&&(0,n.jsxs)("details",{className:"small",style:{marginTop:6},children:[(0,n.jsx)("summary",{children:(null!=(X=null==(h=e.attempts)?void 0:h.length)?X:0)===1?o("reg.attemptsOne",{n:null!=(Z=e.attempt)?Z:(null!=(V=null==(m=e.attempts)?void 0:m.length)?V:0)+1}):o("reg.attempts",{n:null!=(Q=e.attempt)?Q:(null!=(K=null==(v=e.attempts)?void 0:v.length)?K:0)+1,m:null!=(J=null==(w=e.attempts)?void 0:w.length)?J:0})}),(0,n.jsx)("ol",{className:"attempts",children:null==(H=e.attempts)?void 0:H.map(s=>{var t;return(0,n.jsxs)("li",{children:[(0,n.jsxs)("div",{className:"head",children:[(0,n.jsx)("strong",{children:o("reg.attemptN",{n:s.attempt})}),(0,n.jsx)("span",{className:"badge ".concat(s.status),children:o("status.".concat(s.status))}),s.iterations>0&&(0,n.jsx)("span",{className:"muted",children:o("reg.iterations",{n:s.iterations})}),void 0!==s.durationMs&&(0,n.jsx)("span",{className:"muted",children:o("reg.took",{d:(0,r.c5)(s.durationMs)})}),s.runId&&(0,n.jsx)(g.u,{label:o("save.attemptLog"),save:()=>r.FH.saveTaskLog(e.sessionId,e.taskId,s.runId)}),s.runId&&(0,n.jsx)(g.H,{sessionId:e.sessionId,taskId:e.taskId,attempt:s.attempt}),s.runId&&void 0!==s.changedFiles&&(0,n.jsx)(k.C,{sessionId:e.sessionId,taskId:e.taskId,runId:s.runId,title:"".concat(e.title," — ").concat(o("reg.attemptN",{n:s.attempt})),files:s.changedFiles})]}),(0,n.jsxs)("div",{className:"when",children:[s.startedAt?o("task.started",{t:j(s.startedAt)}):"",s.finishedAt?" \xb7 ".concat(o("task.finished",{t:j(s.finishedAt)})):"",s.branch?" \xb7 ".concat(s.branch):""]}),s.reason&&(0,n.jsx)("p",{className:"what err",children:o("reg.stopped",{reason:s.reason})}),s.summary&&(0,n.jsx)(p.s,{text:s.summary,className:"what"})]},"".concat(null!=(t=s.runId)?t:s.attempt))})})]}),e.summary&&(0,n.jsx)(p.s,{text:e.summary,className:"what"}),e.reason&&(0,n.jsx)("p",{className:"what err",children:o("reg.stopped",{reason:e.reason})}),N.message&&N.messageTask===e.taskId&&(0,n.jsx)("p",{className:"what small",children:N.message}),(0,n.jsxs)("div",{className:"row small",style:{marginTop:6},children:[(0,n.jsx)(i(),{href:(0,r.aT)(e.sessionId,e.taskId),children:o("reg.openTask")}),e.runId&&(0,n.jsx)(g.u,{label:o("save.log"),save:()=>r.FH.saveTaskLog(e.sessionId,e.taskId)}),e.chatUrl&&(0,n.jsx)("a",{href:e.chatUrl,target:"_blank",rel:"noreferrer",children:o("home.col.chat")}),e.startedAt&&(0,n.jsx)(R,{where:{session:e.sessionId,task:e.taskId}}),void 0!==e.changedFiles&&(0,n.jsx)(k.C,{sessionId:e.sessionId,taskId:e.taskId,title:e.title,files:e.changedFiles}),(0,n.jsx)(x,{}),e.runId&&(0,n.jsxs)("button",{className:S.has(e.taskId)?"":"quiet","aria-expanded":S.has(e.taskId),onClick:()=>{let s;return s=e.taskId,F(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})},title:(0,u.DG)(e)?o("story.showLiveWhy"):o("story.why"),children:[(0,u.DG)(e)&&!S.has(e.taskId)&&(0,n.jsx)("span",{className:"dot","aria-hidden":"true"}),S.has(e.taskId)?o("story.hide"):(0,u.DG)(e)?o("story.showLive"):o("story.show")]}),I(e)&&!e.sessionRunning&&!e.sessionInactive&&(0,n.jsx)("button",{className:A===e.taskId?"":"primary","aria-expanded":A===e.taskId,onClick:()=>T(A===e.taskId?null:e.taskId),title:o("reg.continueHereWhy"),children:o("reg.continueHere")}),y.includes(e.status)&&!e.sessionRunning&&(0,n.jsx)("button",{className:"quiet",onClick:()=>C(e),title:o("reg.fixPromptHint"),children:o("reg.fixPrompt")}),"done"===e.status&&!e.sessionRunning&&(0,n.jsx)("button",{className:"quiet",onClick:()=>C(e),title:o("reg.newPromptHint"),children:o("reg.newPrompt")}),e.startedAt&&!e.sessionRunning&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{className:"quiet",disabled:""!==N.busy,title:o("restore.why"),onClick:()=>void N.restore({sessionId:e.sessionId,taskId:e.taskId,title:e.title}),children:"restore"===N.busy?o("restore.checking"):o("restore.button")}),(0,n.jsx)("button",{className:"quiet",disabled:""!==N.busy,title:o("restart.why"),onClick:()=>void N.restartFrom({sessionId:e.sessionId,taskId:e.taskId,title:e.title}),children:"restart"===N.busy?o("restart.checking"):o("restart.button")})]})]}),A===e.taskId&&I(e)&&!e.sessionRunning&&(0,n.jsx)(E,{entry:e,onClose:e=>{T(null),e&&(null==c||c())}}),S.has(e.taskId)&&e.runId&&(0,n.jsx)(b.P,{sessionId:e.sessionId,taskId:e.taskId,live:"running"===e.status||"waiting-approval"===e.status})]},"".concat(e.sessionId,"-").concat(e.taskId))})})]})}function R(e){let{where:s}=e,{t}=(0,m.kj)();return(0,n.jsxs)("span",{className:"exports",title:t("reg.exportTitle"),children:[(0,n.jsxs)("span",{className:"muted",children:[t("reg.exportTitle"),":"]})," ",(0,n.jsx)("a",{href:r.FH.exportUrl("plan",s),title:t("reg.exportPlanWhy"),children:t("reg.exportPlan")})," \xb7 ",(0,n.jsx)("a",{href:r.FH.exportUrl("domain",s),title:t("reg.exportDomainWhy"),children:t("reg.exportDomain")})," \xb7 ",(0,n.jsx)("a",{href:r.FH.exportUrl("bot",s),title:t("reg.exportBotWhy"),children:t("reg.exportBot")})]})}function H(e){var s;let{run:t}=e,{t:a}=(0,m.kj)(),l=(0,m.W3)(),i=null!=(s=t.entries.map(e=>{var s;return null==(s=e.runGroup)?void 0:s.name}).find(Boolean))?s:a("reg.runUnnamed"),r=t.entries.filter(e=>"done"===e.status).length,c=t.entries.filter(e=>y.includes(e.status)).length;return(0,n.jsxs)("div",{className:"run-heading",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:i}),(0,n.jsxs)("span",{className:"muted small",children:[a("reg.runOf",{t:t.entries.length,s:t.sessions})," \xb7 ",a("reg.runAt",{when:l(t.startedAt)})," \xb7 ",(0,n.jsx)(C,{run:t})]})]}),(0,n.jsxs)("div",{className:"row small",style:{marginTop:4},children:[(0,n.jsx)("span",{className:"badge ".concat(c>0?"failed":r===t.entries.length?"done":""),children:a("reg.runCounts",{done:r,failed:c})}),(0,n.jsx)(R,{where:{run:t.id}})]})]})}function P(e){let{entries:s,sizes:t,onChange:l}=e,{t:i}=(0,m.kj)(),c=(0,a.useMemo)(()=>S(s),[s]),[d,o]=(0,a.useState)(!1),[u,h]=(0,a.useState)(new Set),[g,p]=(0,a.useState)(!1),[x,j]=(0,a.useState)(""),[v,N]=(0,a.useState)(""),k=e=>"".concat(e.sessionId,":").concat(e.taskId),f=s.filter(e=>e.startedAt),b=[...u],w=async()=>{p(!0),N(""),j("");try{let e=await r.FH.downloadBundle(b.map(e=>{let[s,t]=e.split(":");return{sessionId:s,taskId:t}}));j(i("reg.bundleSaved",{name:e}))}catch(e){N(e.message)}finally{p(!1)}},y=d?{picked:u,toggle:e=>h(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})}:void 0;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row small",style:{marginBottom:8},children:[d?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{className:"quiet",onClick:()=>{o(!1),h(new Set),j(""),N("")},children:i("reg.pickDone")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>h(new Set(f.map(k))),children:i("reg.pickAll")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>h(new Set),children:i("reg.pickNone")}),(0,n.jsx)("span",{className:"muted",children:u.size>0?i("reg.pickedN",{n:u.size}):i("reg.pickedNone")}),u.size>0&&(0,n.jsx)("button",{className:"primary",disabled:g,onClick:()=>void w(),title:i("reg.bundleWhy"),children:i("reg.bundle",{n:u.size})})]}):(0,n.jsx)("button",{className:"quiet",onClick:()=>o(!0),title:i("reg.pickWhy"),children:i("reg.pick")}),x&&(0,n.jsx)("span",{className:"muted",children:x}),v&&(0,n.jsx)("span",{className:"err",children:v})]}),c.runs.map((e,s)=>(0,n.jsxs)("details",{className:"run-fold",open:0===s||d,children:[(0,n.jsx)("summary",{children:(0,n.jsx)(H,{run:e})}),(0,n.jsx)(T,{entries:e.entries,sizes:t,onChange:l,picking:y})]},e.id)),c.loose.length>0&&(0,n.jsxs)("details",{className:"run-fold",open:0===c.runs.length||d,children:[(0,n.jsx)("summary",{children:(0,n.jsxs)("div",{className:"run-heading",children:[(0,n.jsx)("h2",{style:{margin:0},children:i("reg.notInARun")}),(0,n.jsx)("p",{className:"muted small",style:{margin:"4px 0 0"},children:i("reg.notInARunHint")})]})}),(0,n.jsx)(T,{entries:c.loose,sizes:t,onChange:l,picking:y})]})]})}function q(e){let{entry:s,onClose:t}=e,{t:l}=(0,m.kj)(),[i,c]=(0,a.useState)(null),[u,h]=(0,a.useState)(""),[g,p]=(0,a.useState)(!1),[x,j]=(0,a.useState)([]),[v,N]=(0,a.useState)(new Set),[k,f]=(0,a.useState)(!1),[b,w]=(0,a.useState)(""),[y,I]=(0,a.useState)(""),C=(0,a.useRef)(null);(0,d.V)(C,!0),(0,a.useEffect)(()=>{let e=e=>{"Escape"!==e.key||g||t(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g,t]),(0,a.useEffect)(()=>{let e=!0;return r.FH.session(s.sessionId).then(t=>{var n,a,l,i;let r=t.tasks.find(e=>e.id===s.taskId);if(!e)return;c(null!=(n=null==r?void 0:r.prompt)?n:""),I(null!=(a=null==r?void 0:r.prompt)?a:"");let d=null!=(l=null==r?void 0:r.checks)?l:[];j(d),N(new Set("done"===s.status?[]:d.map((e,s)=>s))),f(!!(null==r?void 0:r.readOnly)),w((null!=(i=null==r?void 0:r.scope)?i:[]).join("\n"))}).catch(s=>{e&&h(s.message)}),()=>{e=!1}},[s.sessionId,s.taskId]);let S=async()=>{if(null!==i){p(!0),h("");try{await r.FH.rerunTask(s.sessionId,s.taskId,{prompt:i,checks:x.filter((e,s)=>v.has(s)),readOnly:k,scope:k?[]:(0,o.w)(b)},{buildOnFinished:"done"===s.status}),h(l("reg.fixPromptSaved",{title:s.title})),setTimeout(()=>t(!0),900)}catch(e){h(e.message),p(!1)}}};return(0,n.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>t(!1),children:(0,n.jsxs)("div",{ref:C,className:"modal wide",role:"dialog","aria-modal":"true","aria-labelledby":"fix-title",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"fix-title",children:l("reg.fixPromptTitle",{title:s.title})}),(0,n.jsx)("p",{className:"muted small",children:l("done"===s.status?"reg.newPromptHint":"reg.fixPromptHint")}),s.reason&&(0,n.jsx)("p",{className:"what err small",children:l("reg.stopped",{reason:s.reason})}),null===i?(0,n.jsx)("p",{className:"muted small",children:u||l("reg.fixPromptLoading")}):(0,n.jsx)("textarea",{className:"prose","aria-labelledby":"fix-title",value:i,onChange:e=>c(e.target.value),style:{minHeight:260},disabled:g}),null!==i&&x.length>0&&(0,n.jsxs)("div",{style:{marginTop:10},children:[(0,n.jsx)("strong",{className:"small",children:l("reg.keepChecks")}),(0,n.jsx)("p",{className:"why",children:l("reg.keepChecksWhy")}),x.map((e,s)=>(0,n.jsx)("div",{className:"option",style:{margin:"4px 0"},children:(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"checkbox",checked:v.has(s),onChange:e=>N(t=>{let n=new Set(t);return e.target.checked?n.add(s):n.delete(s),n})}),(0,n.jsx)("span",{children:e.name})]})},s))]}),null!==i&&i.trim()!==y.trim()&&(0,n.jsx)("p",{className:"notice caution small",children:l("task.newIntentNote")}),null!==i&&(0,n.jsx)(o.y,{readOnly:k,scope:b,onReadOnly:f,onScope:w}),(0,n.jsxs)("div",{className:"row modal-actions",children:[u&&null!==i&&(0,n.jsx)("span",{className:"small grow",children:u}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>t(!1),disabled:g,children:l("dialog.cancel")}),(0,n.jsx)("button",{type:"button",className:"primary",onClick:()=>void S(),disabled:g||null===i||!i.trim(),children:l("reg.fixPromptSave")})]})]})})}function W(e){let{sessions:s}=e,{t}=(0,m.kj)();return(0,n.jsxs)("div",{className:"row",style:{margin:"14px 0 18px"},children:[(0,n.jsx)(i(),{href:"/#new-session",className:"button-link",children:t("reg.newSession")}),s.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{htmlFor:"new-task-session",style:{margin:0},children:[t("reg.newTask")," ",t("reg.newTaskIn")]}),(0,n.jsxs)("select",{id:"new-task-session",value:"",onChange:e=>{e.target.value&&(window.location.href=(0,r.aT)(e.target.value,"new-task"))},style:{width:"auto",minWidth:200},children:[(0,n.jsx)("option",{value:"",children:t("reg.newTaskPick")}),s.map(e=>{let[s,t]=e;return(0,n.jsx)("option",{value:s,children:t},s)})]})]})]})}function E(e){let{entry:s,onClose:t}=e,{t:l}=(0,m.kj)(),i=(0,f.p)(),[c,d]=(0,a.useState)(!1),[o,u]=(0,a.useState)(""),h=s.branch?s.commit?l("reg.continueHereCommitted",{branch:s.branch,commit:s.commit.slice(0,8)}):s.vcsProblem?l("reg.continueHereNotCommitted",{branch:s.branch,problem:s.vcsProblem}):l("reg.continueHereNothingNew",{branch:s.branch}):s.vcsProblem?l("reg.continueHereVcsInactive",{problem:s.vcsProblem}):l("reg.continueHereNoVcs"),g=async e=>{if("unattended"!==e||i||await (0,N.Z)(l("batch.unattendedConfirm",{n:1}))){d(!0),u("");try{await r.FH.continueTask(s.sessionId,s.taskId);let a=await r.FH.suggestedRunName([s.sessionId]).then(e=>e.name).catch(()=>void 0),i=await r.FH.startBatch([s.sessionId],e,"stop",void 0,void 0,a,[s.taskId]);if(!i.started){var n;u(l("batch.notStarted",{reason:null!=(n=i.reason)?n:""}));return}u(l("reg.continueHereStarted",{title:s.title})),t(!0)}catch(e){u(e.message)}finally{d(!1)}}};return(0,n.jsxs)("div",{className:"notice",role:"group","aria-label":l("reg.continueHereTitle",{title:s.title}),style:{marginTop:8},children:[(0,n.jsx)("strong",{children:l("reg.continueHereTitle",{title:s.title})}),s.reason&&(0,n.jsx)("p",{className:"small",children:s.reason}),(0,n.jsxs)("ul",{className:"small",children:[(0,n.jsx)("li",{children:l("reg.continueHereChat")}),(0,n.jsx)("li",{children:h}),(0,n.jsx)("li",{children:l("reg.continueHereCount")})]}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:c,onClick:()=>void g("confirm"),title:l("reg.continueWhy"),children:l("reg.continueGo")}),(0,n.jsx)("button",{disabled:c,onClick:()=>void g("unattended"),title:l("reg.continueUnattendedWhy"),children:l("reg.continueUnattended")}),(0,n.jsx)("button",{className:"quiet",disabled:c,onClick:()=>t(!1),children:l("dialog.cancel")}),o&&(0,n.jsx)("span",{className:"small",children:o})]})]})}function G(e){let{entries:s,onChange:t}=e,{t:l}=(0,m.kj)(),[i,c]=(0,a.useState)(!1),[d,o]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[g,p]=(0,a.useState)(new Set),[x,j]=(0,a.useState)(null),v=s.filter(e=>"queued"===e.status&&!e.sessionInactive),k=s.filter(e=>y.includes(e.status)&&!e.sessionRunning&&!e.sessionInactive),b=s.some(e=>e.sessionRunning),w=k.filter(e=>"stop"===e.sessionOnFailure),C=k.filter(e=>"stop"!==e.sessionOnFailure),S=[...v,...k],F=S.filter(e=>g.has(e.taskId)),A=k.filter(e=>g.has(e.taskId)),T=v.filter(e=>g.has(e.taskId)),R=[...new Set([...F].sort((e,s)=>{var t,n;return(null!=(t=e.sessionRunOrder)?t:Number.MAX_SAFE_INTEGER)-(null!=(n=s.sessionRunOrder)?n:Number.MAX_SAFE_INTEGER)||e.position-s.position}).map(e=>e.sessionId))],H=F.filter(e=>"stop"===e.sessionOnFailure).map(e=>({e,before:S.find(s=>s.sessionId===e.sessionId&&s.position<e.position&&!g.has(s.taskId))})).filter(e=>!!e.before),[P,W]=(0,a.useState)(""),E=w.length>0?l("reg.continueWithFailed",{f:w.length,n:v.length,s:R.length}):l("reg.continue",{n:v.length,s:R.length}),G=(0,f.p)(),O=async e=>{if("unattended"!==e||G||await (0,N.Z)(l("batch.unattendedConfirm",{n:R.length}))){c(!0),o("");try{var s;for(let e of A)I(e)?await r.FH.continueTask(e.sessionId,e.taskId):await r.FH.rerunTask(e.sessionId,e.taskId);let n=await r.FH.startBatch(R,e,"stop",void 0,void 0,P.trim()||void 0,F.map(e=>e.taskId));o(n.started?l("reg.continueStarted",{n:R.length}):l("batch.notStarted",{reason:null!=(s=n.reason)?s:""})),h(!1),t()}catch(e){o(e.message)}finally{c(!1)}}};return 0===v.length&&0===k.length?null:(0,n.jsxs)("div",{style:{marginBottom:8},children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:i||b,onClick:()=>{p(new Set(S.map(e=>e.taskId))),h(!0),o("");let e=[...new Set([...S].sort((e,s)=>{var t,n;return(null!=(t=e.sessionRunOrder)?t:Number.MAX_SAFE_INTEGER)-(null!=(n=s.sessionRunOrder)?n:Number.MAX_SAFE_INTEGER)||e.position-s.position}).map(e=>e.sessionId))];r.FH.suggestedRunName(e).then(e=>W(e.name)).catch(()=>void 0)},title:l("reg.continueWhy"),children:E}),b&&(0,n.jsx)("span",{className:"muted small",children:l("reg.continueRunning")}),d&&(0,n.jsx)("span",{className:"small",children:d})]}),u&&!b&&(0,n.jsxs)("div",{className:"notice",style:{marginTop:8},children:[(0,n.jsx)("strong",{children:l("reg.continuePanelTitle")}),(0,n.jsxs)("div",{className:"row small",style:{marginTop:6},children:[(0,n.jsx)("button",{className:"quiet small",onClick:()=>p(new Set(S.map(e=>e.taskId))),children:l("reg.pickAll")}),(0,n.jsx)("button",{className:"quiet small",onClick:()=>p(new Set),children:l("reg.pickNone")})]}),[{key:"chain",entries:w,intro:l("reg.continueChain"),fix:!0},{key:"loose",entries:C,intro:l("reg.continueIndependent"),fix:!0},{key:"queued",entries:v,intro:l("reg.continueQueued"),fix:!1}].filter(e=>e.entries.length>0).map(e=>(0,n.jsxs)("div",{style:{marginTop:6},children:[(0,n.jsx)("div",{className:"small",children:e.intro}),(0,n.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:18,listStyle:"none"},children:e.entries.map(s=>(0,n.jsxs)("li",{children:[(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:g.has(s.taskId),onChange:e=>{let t,n;return t=s.taskId,n=e.target.checked,p(e=>{let s=new Set(e);return n?s.add(t):s.delete(t),s})}}),(0,n.jsx)("strong",{children:s.title})," \xb7 ",s.sessionName," \xb7 ",(0,n.jsx)("span",{className:"badge ".concat(s.status),children:l("status.".concat(s.status))}),I(s)&&(0,n.jsxs)("span",{className:"muted small",children:[" \xb7 ",l("reg.willContinue")]})]})," ",(0,n.jsx)("button",{className:"quiet small",onClick:()=>p(new Set([s.taskId])),title:l("reg.pickOnlyWhy"),children:l("reg.pickOnly")}),e.fix&&(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsx)("button",{className:"quiet small",onClick:()=>j(s),title:l("reg.fixPromptHint"),children:l("reg.fixPrompt")})]})]},s.taskId))})]},e.key)),H.length>0&&(0,n.jsx)("div",{className:"notice caution small",style:{marginTop:6},children:H.map(e=>(0,n.jsx)("div",{children:l("reg.continueGap",{task:e.e.title,before:e.before.title,session:e.e.sessionName})},e.e.taskId))}),(0,n.jsxs)("div",{style:{marginTop:8},children:[(0,n.jsx)("label",{htmlFor:"continue-run-name",children:l("batch.runName")}),(0,n.jsx)("input",{id:"continue-run-name",type:"text",value:P,onChange:e=>W(e.target.value),placeholder:l("batch.runNamePlaceholder"),disabled:i}),(0,n.jsx)("p",{className:"why",children:l("reg.continueNameWhy")})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:l("reg.continueSummary",{q:T.length,r:A.length,s:R.length})}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,n.jsx)("button",{className:"primary",disabled:i||0===R.length,onClick:()=>void O("unattended"),title:l("reg.continueUnattendedWhy"),children:l("reg.continueUnattended")}),(0,n.jsx)("button",{disabled:i||0===R.length,onClick:()=>void O("confirm"),title:l("reg.continueWhy"),children:l("reg.continueGo")}),(0,n.jsx)("button",{className:"quiet",disabled:i,onClick:()=>h(!1),children:l("dialog.cancel")})]})]}),x&&(0,n.jsx)(q,{entry:x,onClose:e=>{j(null),e&&t()}})]})}function O(e){let{entries:s}=e,{t}=(0,m.kj)(),a=(0,m.W3)();return(0,n.jsx)("div",{className:"panel",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t("reg.col.task")}),(0,n.jsx)("th",{children:t("reg.col.session")}),(0,n.jsx)("th",{children:t("reg.col.status")}),(0,n.jsx)("th",{children:t("reg.col.started")}),(0,n.jsx)("th",{children:t("reg.col.took")}),(0,n.jsx)("th",{children:t("reg.col.result")})]})}),(0,n.jsx)("tbody",{children:s.map(e=>{var s;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:(0,n.jsx)(i(),{href:(0,r.aT)(e.sessionId,e.taskId),children:e.title})}),(0,n.jsx)("td",{children:(0,n.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:e.sessionName})}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"badge ".concat(e.status),children:t("status.".concat(e.status))})}),(0,n.jsx)("td",{className:"muted small",children:e.startedAt?a(e.startedAt):"—"}),(0,n.jsx)("td",{className:"muted small",children:(0,r.c5)(e.durationMs)||"—"}),(0,n.jsx)("td",{className:"small",children:null!=(s=e.summary)?s:e.reason?(0,n.jsx)("span",{className:"err",children:e.reason}):"—"})]},"".concat(e.sessionId,"-").concat(e.taskId))})})]})})}}},e=>{e.O(0,[197,867,549,36,347,131,358],()=>e(e.s=3256)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1035:(e,t,n)=>{"use strict";n.d(t,{DialogHost:()=>o,Z:()=>d});var l=n(3365),a=n(1521),s=n(867),i=n(4969);let r=null,c=[];function d(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):c.push(l))})}function o(e){var t,n;let{children:d}=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]),c.length>0){let e=c.splice(0,c.length);m(t=>[...t,...e])}return()=>{r=null}},[]);let g=h[0],b=(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(),b(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g,b]),(0,l.jsxs)(l.Fragment,{children:[d,g&&(0,l.jsx)("div",{className:"modal-backdrop",onClick:()=>b(!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:()=>b(!1),children:o("dialog.cancel")}),(0,l.jsx)("button",{ref:u,type:"button",className:g.danger?"danger":"primary",onClick:()=>b(!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),c=n(7527),d=n(867),o=n(1035),h=n(4811),m=n(8848);function u(){let{t:e}=(0,d.kj)(),t=(0,d.W3)(),[n,s]=(0,a.useState)(null),[h,m]=(0,a.useState)(null),[u,g]=(0,a.useState)([]),[b,x]=(0,a.useState)([]),[j,v]=(0,a.useState)([]),[f,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)(""),[W,I]=(0,a.useState)(null),[T,R]=(0,a.useState)(!1),D=(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),x(t=>t.filter(t=>e.some(e=>e.id===t))),I(!0),R(!1),H("")}catch(e){R(!(0,r.AV)()),I(!1),H(e.message)}},[]);(0,c.z)(D,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&&(x(n),y("continue"===t.get("fail")?"continue":"stop"),N(!0),window.history.replaceState(null,"",window.location.pathname))},[]);let[P,U]=(0,a.useState)(!1),L=(0,a.useRef)(!1),q=async()=>{if(!L.current){L.current=!0,U(!0);try{let e=await r.FH.createSession(k||"session");S(""),window.location.href=(0,r.aT)(e.id)}catch(e){H(e.message),L.current=!1,U(!1)}}},M=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})),x(e=>e.filter(e=>e!==t.id)),await D()}catch(e){F(e.message)}},A=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("; ")})),x(e=>e.filter(e=>!t.some(t=>t.id===e))),v([]),await D()},B=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||x(e=>e.filter(e=>!l.some(t=>t.id===e))),v([]),await D()},O=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})}},_=(null!=n?n:[]).filter(e=>!e.running),K=_.filter(e=>j.includes(e.id));return(0,l.jsxs)(l.Fragment,{children:[T&&(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===W&&!T&&(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:P||!1===W,children:e("home.create")})]})]}),n&&n.length>0&&(0,l.jsx)(p,{sessions:n,selected:b,setSelected:x,onFailure:f,setOnFailure:y,fromPlan:w,batch:h,approvals:u,onChange:D,move:(e,t)=>{x(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:K.length})}),(0,l.jsx)("button",{onClick:()=>void B(!0),disabled:0===K.length,children:e("home.makeActive")}),(0,l.jsx)("button",{onClick:()=>void B(!1),disabled:0===K.length,children:e("home.makeInactive")}),(0,l.jsx)("button",{className:"danger",onClick:()=>void A(),disabled:0===K.length,children:e("home.deleteSelected",{n:K.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")}),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:_.length>0&&_.every(e=>j.includes(e.id)),onChange:e=>v(e.target.checked?_.map(e=>e.id):[]),disabled:0===_.length})}),(0,l.jsx)("th",{children:(0,l.jsx)("input",{type:"checkbox","aria-label":e("home.selectAll"),checked:n.length>0&&b.length===n.filter(e=>!1!==e.active).length,onChange:e=>x(e.target.checked?n.filter(e=>!1!==e.active).map(e=>e.id).reverse():[]),disabled:(null==h?void 0:h.running)===!0})}),(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=>{let s=a.tasks.filter(e=>"done"===e.status).length,c=a.tasks.filter(e=>"queued"===e.status).length;return(0,l.jsxs)("tr",{className:!1===a.active?"inactive":void 0,children:[(0,l.jsx)("td",{children:(0,l.jsx)("input",{type:"checkbox",checked:j.includes(a.id),onChange:()=>v(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:b.includes(a.id),onChange:()=>{var e;return e=a.id,void x(t=>{if(t.includes(e))return t.filter(t=>t!==e);let l=(null!=n?n:[]).map(e=>e.id).reverse();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.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:s,queued:c})})]}),(0,l.jsxs)("td",{children:[(0,l.jsx)("span",{className:"badge ".concat(O(a).badge),title:O(a).title,children:O(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 M(a),disabled:!!a.running,title:e("home.delete"),children:e("home.delete")})})]},a.id)})})]})]})]})}function p(e){var t,n,s,c,u,p,g;let{sessions:b,selected:x,setSelected:j,onFailure:v,setOnFailure:f,fromPlan:y,batch:w,approvals:N,onChange:k,move:S}=e,{t:C}=(0,d.kj)(),[F,E]=(0,a.useState)(""),[H,W]=(0,a.useState)(""),[I,T]=(0,a.useState)(""),[R,D]=(0,a.useState)(""),[P,U]=(0,a.useState)(""),[L,q]=(0,a.useState)(null),[M,A]=(0,a.useState)([]);(0,a.useEffect)(()=>{r.FH.models().then(e=>{q(e),T(t=>t||e.defaultModel),D(t=>t||e.defaultReviewModel)}).catch(()=>void 0)},[]);let B=x.join(",");(0,a.useEffect)(()=>{let e=!1,t=B.split(",").filter(Boolean);if(0===t.length)return void A([]);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||A(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=b.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)}},[B]);let O=new Map(b.map(e=>[e.id,e])),_=e=>e.tasks.filter(e=>"queued"===e.status).length,K=x.map(e=>O.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=b.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){W(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,v,I||void 0,R||void 0,P.trim()||Z.map(e=>e.planName).find(Boolean)||void 0);E(""),W(n.started?"":null!=(t=n.reason)?t:"")})},el=K.filter(e=>{var t;return(null!=(t=e.model)?t:"")!==I}).length,ea=K.filter(e=>{var t;return(null==(t=e.review)?void 0:t.enabled)===!1}).length,es=null!=(s=null==L?void 0:L.options)?s:[],ei=es.filter(e=>!e.group),er=new Map;for(let e of es)e.group&&er.set(e.group,[...null!=(c=er.get(e.group))?c:[],e]);let ec=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,ed=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(b.filter(e=>_(e)>0).map(e=>e.id).reverse()),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:P,onChange:e=>U(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:I,onChange:e=>T(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==L?void 0:L.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:I,onUse:e=>T(e)}),I&&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:R,onChange:e=>D(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")}),""!==R&&R===I&&(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"===v,onChange:()=>f("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"===v,onChange:()=>f("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)})]}),M.length>0&&(0,l.jsxs)("div",{className:"notice caution",children:[(0,l.jsx)("strong",{children:C("batch.vcsProblem")}),(0,l.jsx)("ul",{children:M.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:(ed?(null==(t=O.get(ed.sessionId))?void 0:t.modelInUse)||(null==(n=O.get(ed.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})}),ed&&(0,l.jsx)("span",{className:"small",children:C("batch.progress",{name:ed.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&&ec&&(0,l.jsx)("div",{className:"notice calm",style:{marginTop:12},children:(0,l.jsx)("strong",{children:C("batch.finished",ec)})}),(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,c=null!=(s=null!=(l=null==n?void 0:n.current)?l:null==r?void 0:r.querySelector(a))?s:null;null==c||c.focus();let d=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",d),()=>{document.removeEventListener("keydown",d),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:()=>d,L:()=>o,z4:()=>h});var l=n(3365),a=n(8197),s=n.n(a),i=n(1521),r=n(5549),c=n(867);function d(e){let{current:t,onUse:n}=e,{t:a}=(0,c.kj)(),[s,d]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return r.FH.project().then(t=>{e||d(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,c.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,c.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()}]);