copilot-operator 0.1.22 → 0.1.25

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 (66) hide show
  1. package/dist/src/api/operator.controller.js +2 -2
  2. package/dist/src/api/operator.service.js +330 -35
  3. package/dist/src/exec/confinement.js +85 -7
  4. package/dist/src/exec/programs.js +12 -3
  5. package/dist/src/exec/reportFile.js +5 -3
  6. package/dist/src/exec/shells.js +13 -2
  7. package/dist/src/log/runLog.js +6 -1
  8. package/dist/src/orchestrator/contract.js +29 -7
  9. package/dist/src/orchestrator/review.js +16 -3
  10. package/dist/src/orchestrator/taskRunner.js +391 -54
  11. package/dist/src/plan/schema.js +11 -1
  12. package/dist/src/plan/systemGuide.js +36 -4
  13. package/dist/src/protocol/parser.js +33 -5
  14. package/dist/src/protocol/reporter.js +2 -0
  15. package/dist/src/session/compose.js +18 -9
  16. package/dist/src/session/exportRecord.js +12 -3
  17. package/dist/src/session/exports.js +46 -9
  18. package/dist/src/session/handoff.js +5 -2
  19. package/dist/src/session/interruption.js +3 -1
  20. package/dist/src/session/runLog.js +42 -1
  21. package/dist/src/session/runName.js +3 -1
  22. package/dist/src/session/store.js +7 -2
  23. package/dist/src/transport/copilotTransport.js +89 -62
  24. package/dist/src/transport/modelMatch.js +37 -0
  25. package/dist/src/vcs/artifacts.js +20 -7
  26. package/dist/src/vcs/commitHygiene.js +7 -2
  27. package/dist/src/vcs/contentIntegrity.js +65 -6
  28. package/dist/src/vcs/git.js +44 -7
  29. package/dist/src/vcs/prepareFromRemote.js +46 -9
  30. package/dist/src/vcs/remoteAuth.js +92 -0
  31. package/dist/src/vcs/runPreflight.js +100 -31
  32. package/dist/src/vcs/scope.js +18 -2
  33. package/dist/src/vcs/snapshot.js +61 -16
  34. package/dist/src/vcs/syncCommand.js +3 -11
  35. package/dist/src/vcs/taskVcs.js +173 -24
  36. package/dist/web/404.html +2 -2
  37. package/dist/web/_next/static/chunks/549-7e35e4fdefadb05d.js +1 -0
  38. package/dist/web/_next/static/chunks/867-52e371cb1ec49089.js +1 -0
  39. package/dist/web/_next/static/chunks/app/defaults/{page-cdc730adea753446.js → page-62c8fbe84baa436a.js} +1 -1
  40. package/dist/web/_next/static/chunks/app/page-4defcfd1eb482644.js +1 -0
  41. package/dist/web/_next/static/chunks/app/sessions/view/{page-185755ada66e2930.js → page-2d3bbc68b27fed2c.js} +1 -1
  42. package/dist/web/appearance.html +2 -2
  43. package/dist/web/appearance.txt +10 -10
  44. package/dist/web/defaults.html +2 -2
  45. package/dist/web/defaults.txt +10 -10
  46. package/dist/web/history.html +2 -2
  47. package/dist/web/history.txt +10 -10
  48. package/dist/web/import.html +2 -2
  49. package/dist/web/import.txt +10 -10
  50. package/dist/web/index.html +2 -2
  51. package/dist/web/index.txt +10 -10
  52. package/dist/web/level1.html +2 -2
  53. package/dist/web/level1.txt +10 -10
  54. package/dist/web/presets.html +2 -2
  55. package/dist/web/presets.txt +10 -10
  56. package/dist/web/sessions/view.html +2 -2
  57. package/dist/web/sessions/view.txt +10 -10
  58. package/dist/web/system.html +2 -2
  59. package/dist/web/system.txt +10 -10
  60. package/package.json +3 -2
  61. package/prompts/level1.md +10 -3
  62. package/dist/web/_next/static/chunks/549-5f90780046c1c24f.js +0 -1
  63. package/dist/web/_next/static/chunks/867-79f07bebe3084811.js +0 -1
  64. package/dist/web/_next/static/chunks/app/page-0a861b38da0a1c51.js +0 -1
  65. /package/dist/web/_next/static/{9Ze8aagkvT-WLfD4KCKKS → beP1HgHJZvBVRTsoU1sZv}/_buildManifest.js +0 -0
  66. /package/dist/web/_next/static/{9Ze8aagkvT-WLfD4KCKKS → beP1HgHJZvBVRTsoU1sZv}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1035:(e,n,t)=>{"use strict";t.d(n,{DialogHost:()=>o,Z:()=>d});var l=t(3365),a=t(1521),s=t(867),i=t(4969);let r=null,c=[];function d(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var l;return l={kind:"confirm",message:e,...n,resolve:t},void(r?r(l):c.push(l))})}function o(e){var n,t;let{children:d}=e,{t:o}=(0,s.kj)(),[h,u]=(0,a.useState)([]),m=(0,a.useRef)(null),p=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(r=e=>u(n=>[...n,e]),c.length>0){let e=c.splice(0,c.length);u(n=>[...n,...e])}return()=>{r=null}},[]);let x=h[0],j=(0,a.useCallback)(e=>{x&&(x.resolve(e),u(e=>e.slice(1)))},[x]);return(0,i.V)(p,!!x,m),(0,a.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,l.jsxs)(l.Fragment,{children:[d,x&&(0,l.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,l.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)("h2",{id:"modal-title",children:null!=(n=x.title)?n:o("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,l.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,l.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,l.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:o("dialog.cancel")}),(0,l.jsx)("button",{ref:m,type:"button",className:x.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(t=x.okLabel)?t:o("dialog.ok")})]})]})})]})}},4811:(e,n,t)=>{"use strict";t.d(n,{p:()=>s});var l=t(1521),a=t(5549);function s(){let[e,n]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let e=!0;return a.FH.settings().then(t=>{var l;let a=null!=(l=t.raw.execution)?l:{};e&&n("unattended"===a.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},4969:(e,n,t)=>{"use strict";t.d(n,{V:()=>s});var l=t(1521);let a='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function s(e,n,t){(0,l.useEffect)(()=>{var l,s;if(!n)return;let i=document.activeElement instanceof HTMLElement?document.activeElement:null,r=e.current,c=null!=(s=null!=(l=null==t?void 0:t.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 n=Array.from(r.querySelectorAll(a)).filter(e=>null!==e.offsetParent);if(0===n.length)return;let t=n[0],l=n[n.length-1],s=r.contains(document.activeElement);e.shiftKey&&(document.activeElement===t||!s)?(e.preventDefault(),l.focus()):e.shiftKey||document.activeElement!==l&&s||(e.preventDefault(),t.focus())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),i&&document.contains(i)&&i.focus()}},[e,n,t])}},5704:(e,n,t)=>{Promise.resolve().then(t.bind(t,6474))},6474:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>j});var l=t(3365),a=t(1521),s=t(8197),i=t.n(s),r=t(5549),c=t(7527),d=t(867),o=t(1035),h=t(4811),u=t(8848);let m={"review-inputs":"runvcs.review","snapshot-on-base":"runvcs.snapshotOnBase","snapshot-here":"runvcs.snapshotHere","use-current-branch":"runvcs.useCurrent","allow-snapshot":"runvcs.allowSnapshot"};function p(e){let{groups:n,sessionIds:t,onChange:a}=e,{t:s}=(0,d.kj)(),i=n.filter(e=>!e.ready);return 0===i.length?null:(0,l.jsxs)("section",{className:"notice caution","aria-labelledby":"runvcs-title",children:[(0,l.jsx)("h3",{id:"runvcs-title",style:{marginTop:0},children:s("runvcs.title")}),(0,l.jsx)("p",{className:"small",children:s("runvcs.why")}),i.map(e=>(0,l.jsx)(x,{group:e,sessionIds:t,onChange:a},e.repoDir))]})}function x(e){var n;let{group:t,sessionIds:s,onChange:i}=e,{t:c}=(0,d.kj)(),[o,h]=(0,a.useState)(!1),[u,p]=(0,a.useState)(!1),[x,j]=(0,a.useState)(!1),[g,b]=(0,a.useState)(""),v=e=>(null!=e?e:"—").slice(0,8),f=async e=>{if("review-inputs"===e)return void h(e=>!e);j(!0),b("");try{var n,l;let a="snapshot-on-base"===e?Object.fromEntries(t.inputs.map(e=>[e.path,"include"])):Object.fromEntries(t.entries.filter(e=>e.choice).map(e=>[e.path,e.choice])),c=await r.FH.runVcsPrepare(s,t.repoDir,e,a);b(c.ok?null!=(n=c.result)?n:"":null!=(l=c.problem)?l:""),i()}catch(e){b(e.message)}finally{j(!1)}};return(0,l.jsxs)("div",{className:"option",style:{overflowWrap:"anywhere"},children:[(0,l.jsx)("table",{className:"small",children:(0,l.jsxs)("tbody",{children:[(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:c("runvcs.repo")}),(0,l.jsx)("td",{children:(0,l.jsx)("code",{children:t.repoDir})})]}),(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:c("runvcs.current")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:null!=(n=t.branch)?n:"HEAD"})," @ ",(0,l.jsx)("code",{children:v(t.head)})]})]}),t.baseBranch&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:c("runvcs.base")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:t.baseBranch})," @ ",(0,l.jsx)("code",{children:v(t.baseHead)})]})]}),(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:c("runvcs.sessions")}),(0,l.jsx)("td",{children:t.sessions.map(e=>"".concat(e.name," (").concat(c("runvcs.role.".concat(e.role)),")")).join(", ")})]}),t.inputPatterns.length>0&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:c("runvcs.patterns")}),(0,l.jsx)("td",{children:t.inputPatterns.map(e=>(0,l.jsx)("code",{style:{marginRight:6},children:e},e))})]})]})}),t.problem&&(0,l.jsxs)("p",{className:"small",children:[(0,l.jsx)("strong",{children:c("runvcs.problem")})," ",t.problem]}),t.inputs.length>0&&(0,l.jsx)("p",{className:"small",children:c("runvcs.inputsCount",{n:t.inputs.length})}),o&&t.inputs.length>0&&(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:t.inputs.map(e=>(0,l.jsxs)("li",{children:[(0,l.jsx)("code",{children:e.path})," — ",c("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,r.zi)(e.size)):"",0===e.allowed.length&&e.reason?(0,l.jsxs)("span",{className:"err",children:[" — ",e.reason]}):null]},e.path))}),t.unrelated.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",children:(0,l.jsx)("strong",{children:c("runvcs.unrelated",{n:t.unrelated.length})})}),(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:t.unrelated.slice(0,30).map(e=>(0,l.jsxs)("li",{children:[(0,l.jsx)("code",{children:e.path}),e.reason?" — ".concat(e.reason):""]},e.path))})]}),u?(0,l.jsxs)("p",{className:"small muted",children:[c("runvcs.cancelled")," ",(0,l.jsx)("button",{className:"quiet",onClick:()=>p(!1),children:c("runvcs.showAgain")})]}):(0,l.jsxs)("div",{children:[t.actions.map(e=>{var n,a,s;return(0,l.jsxs)("div",{style:{marginTop:8},children:[(0,l.jsxs)("button",{className:e.recommended?"primary":void 0,onClick:()=>void f(e.id),disabled:x||!e.available,children:[c(m[e.id],{branch:null!=(n=t.baseBranch)?n:"",current:null!=(a=t.branch)?a:"HEAD"}),"review-inputs"===e.id&&o?" ✓":""]}),e.recommended&&(0,l.jsx)("span",{className:"badge done",style:{marginLeft:6},children:c("runvcs.recommended")}),(0,l.jsx)("p",{className:"why",children:e.available?e.result:"".concat(c("runvcs.notNow")," ").concat(null!=(s=e.why)?s:"")})]},e.id)}),(0,l.jsxs)("div",{style:{marginTop:8},children:[(0,l.jsx)("button",{className:"quiet",onClick:()=>p(!0),disabled:x,children:c("runvcs.cancel")}),(0,l.jsx)("p",{className:"why",children:c("runvcs.cancelWhy")})]})]}),g&&(0,l.jsx)("p",{className:"small",role:"status",children:g})]})}function j(){let{t:e}=(0,d.kj)(),n=(0,d.W3)(),[t,s]=(0,a.useState)(null),[h,u]=(0,a.useState)(null),[m,p]=(0,a.useState)([]),[x,j]=(0,a.useState)([]),[b,v]=(0,a.useState)([]),[f,y]=(0,a.useState)("stop"),[N,w]=(0,a.useState)(!1),[k,S]=(0,a.useState)(""),[C,F]=(0,a.useState)(""),[E,H]=(0,a.useState)(""),[D,T]=(0,a.useState)(null),[W,I]=(0,a.useState)(!1),R=(0,a.useCallback)(async()=>{try{let[e,n,t]=await Promise.all([r.FH.sessions(),r.FH.batch().catch(()=>null),r.FH.approvals().catch(()=>[])]);s(e),u(n),p(t),j(n=>n.filter(n=>e.some(e=>e.id===n))),T(!0),I(!1),H("")}catch(e){I(!(0,r.AV)()),T(!1),H(e.message)}},[]);(0,c.z)(R,3e3),(0,a.useEffect)(()=>{var e;let n=new URLSearchParams(window.location.search),t=(null!=(e=n.get("run"))?e:"").split(",").map(e=>e.trim()).filter(Boolean);0!==t.length&&(j(t),y("continue"===n.get("fail")?"continue":"stop"),w(!0),window.history.replaceState(null,"",window.location.pathname))},[]);let[O,U]=(0,a.useState)(!1),q=(0,a.useRef)(!1),B=async()=>{if(!q.current){q.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),q.current=!1,U(!1)}}},A=async n=>{if(n.running)return void F(e("home.deleteRunning"));if(await (0,o.Z)(e("home.deleteConfirm",{name:n.name,n:n.tasks.length})))try{await r.FH.deleteSession(n.id),F(e("home.deleted",{name:n.name})),j(e=>e.filter(e=>e!==n.id)),await R()}catch(e){F(e.message)}},L=async()=>{let n=(null!=t?t:[]).filter(e=>b.includes(e.id)&&!e.running);if(0===n.length)return;let l=n.map(e=>"• ".concat(e.name," (").concat(e.tasks.length,")")).join("\n");if(!await (0,o.Z)(e("home.deleteSelectedConfirm",{n:n.length,names:l})))return;let a=0,s=[];for(let e of n)try{await r.FH.deleteSession(e.id),a+=1}catch(n){s.push("".concat(e.name,": ").concat(n.message))}F(0===s.length?e("home.deletedMany",{n:a}):e("home.deleteSomeFailed",{n:a,m:s.length,why:s.join("; ")})),j(e=>e.filter(e=>!n.some(n=>n.id===e))),v([]),await R()},P=async n=>{let l=(null!=t?t:[]).filter(e=>b.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:n})}catch(n){a.push("".concat(e.name,": ").concat(n.message))}F(0===a.length?e(n?"home.madeActive":"home.madeInactive",{n:l.length}):e("home.statusSomeFailed",{n:l.length-a.length,m:a.length,why:a.join("; ")})),n||j(e=>e.filter(e=>!l.some(n=>n.id===e))),v([]),await R()},M=n=>{if(n.running)return{label:e("state.running"),badge:"running"};let t=n.tasks.some(e=>"queued"===e.status||"running"===e.status);if("idle"!==n.status||t||0===n.tasks.length)return{label:e("state.".concat(n.status)),badge:""};let l=n.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(!t)return;let n=new Map(t.map(e=>[e.id,e]));s(e.map(e=>n.get(e)).filter(e=>!!e));try{s(await r.FH.reorderSessions(e)),H("")}catch(e){H(e.message),R()}},z=(e,n)=>{let l=(null!=t?t:[]).map(e=>e.id),a=l.indexOf(e),s=a+n;a<0||s<0||s>=l.length||([l[a],l[s]]=[l[s],l[a]],_(l))},[K,V]=(0,a.useState)(null),[Z,Q]=(0,a.useState)(null),G=(null!=t?t:[]).filter(e=>!e.running),J=G.filter(e=>b.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===D&&!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&&B()}}),(0,l.jsx)("button",{className:"primary",onClick:()=>void B(),disabled:O||!1===D,children:e("home.create")})]})]}),t&&t.length>0&&(0,l.jsx)(g,{sessions:t,selected:x,setSelected:j,onFailure:f,setOnFailure:y,fromPlan:N,batch:h,approvals:m,onChange:R,move:(e,n)=>{j(t=>{let l=t.indexOf(e),a=l+n;if(l<0||a<0||a>=t.length)return t;let s=[...t];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===t&&(0,l.jsx)("div",{className:"muted",children:e("home.loading")}),t&&0===t.length&&(0,l.jsx)("div",{className:"muted",children:e("home.none")}),t&&t.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 P(!0),disabled:0===J.length,children:e("home.makeActive")}),(0,l.jsx)("button",{onClick:()=>void P(!1),disabled:0===J.length,children:e("home.makeInactive")}),(0,l.jsx)("button",{className:"danger",onClick:()=>void L(),disabled:0===J.length,children:e("home.deleteSelected",{n:J.length})}),(0,l.jsx)("span",{className:"muted small",children:e("home.tickForBoth")})]}),t&&t.length>0&&(0,l.jsx)("p",{className:"muted small",children:e("home.deleteWhy")}),t&&t.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}),t&&t.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=>b.includes(e.id)),onChange:e=>v(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:t.length>0&&x.length===t.filter(e=>!1!==e.active).length,onChange:e=>j(e.target.checked?t.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:t.map((a,s)=>{let c=a.tasks.filter(e=>"done"===e.status).length,d=a.tasks.filter(e=>"queued"===e.status).length,o=[!1===a.active?"inactive":"",K===a.id?"dragging":"",Z===a.id&&K!==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",V(a.id)},onDragOver:e=>{K&&(e.preventDefault(),e.dataTransfer.dropEffect="move",Z!==a.id&&Q(a.id))},onDrop:e=>{e.preventDefault();let n=e.dataTransfer.getData("text/plain")||K;V(null),Q(null),n&&((e,n)=>{let l=(null!=t?t:[]).map(e=>e.id),a=l.indexOf(e),s=l.indexOf(n);a<0||s<0||a===s||(l.splice(a,1),l.splice(s,0,e),_(l))})(n,a.id)},onDragEnd:()=>{V(null),Q(null)},children:[(0,l.jsx)("td",{children:(0,l.jsx)("input",{type:"checkbox",checked:b.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:x.includes(a.id),onChange:()=>{var e;return e=a.id,void j(n=>{if(n.includes(e))return n.filter(n=>n!==e);let l=(null!=t?t:[]).map(e=>e.id);return[...n,e].sort((e,n)=>l.indexOf(e)-l.indexOf(n))})},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:()=>z(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:()=>z(a.id,1),disabled:s===t.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:c,queued:d})})]}),(0,l.jsxs)("td",{children:[(0,l.jsx)("span",{className:"badge ".concat(M(a).badge),title:M(a).title,children:M(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:n(a.createdAt)}),(0,l.jsx)("td",{children:(0,l.jsx)("button",{className:"quiet",onClick:()=>void A(a),disabled:!!a.running,title:e("home.delete"),children:e("home.delete")})})]},a.id)})})]})]})]})}function g(e){var n,t,s,c,m,x,j;let{sessions:g,selected:b,setSelected:v,onFailure:f,setOnFailure:y,fromPlan:N,batch:w,approvals:k,onChange:S,move:C}=e,{t:F}=(0,d.kj)(),[E,H]=(0,a.useState)(""),[D,T]=(0,a.useState)(""),[W,I]=(0,a.useState)(""),[R,O]=(0,a.useState)(""),[U,q]=(0,a.useState)(""),[B,A]=(0,a.useState)(null),[L,P]=(0,a.useState)([]),[M,_]=(0,a.useState)(0);(0,a.useEffect)(()=>{r.FH.models().then(e=>{A(e),I(n=>n||e.defaultModel),O(n=>n||e.defaultReviewModel)}).catch(()=>void 0)},[]);let z=b.join(",");(0,a.useEffect)(()=>{let e=!1,n=z.split(",").filter(Boolean);if(0===n.length)return void P([]);let t=async()=>{let t=await r.FH.runVcs(n).catch(()=>[]);e||P(t)};t();let l=setInterval(()=>void t(),1e4);return()=>{e=!0,clearInterval(l)}},[z,M]);let K=new Map(g.map(e=>[e.id,e])),V=e=>e.tasks.filter(e=>"queued"===e.status).length,Z=b.map(e=>K.get(e)).filter(e=>!!e),Q=Z.filter(e=>V(e)>0&&!1!==e.active),G=Q.reduce((e,n)=>e+V(n),0),J=(null==w?void 0:w.running)===!0,X=g.some(e=>e.running),Y=L.some(e=>!e.ready),$=J||0===Q.length||X||Y,ee=X?{title:"batch.oneRunning",why:"batch.oneRunningWhy"}:0===Z.length?{title:"batch.pickFirst",why:"batch.pickFirstWhy"}:0===Q.length?{title:"batch.nothingRunnable",why:"batch.nothingRunnableWhy"}:null,en=(0,h.p)(),[et,el]=(0,a.useState)(!1),ea=(0,a.useRef)(!1),es=async e=>{if(!ea.current){ea.current=!0,el(!0);try{await e()}catch(e){T(e.message)}finally{ea.current=!1,el(!1),S()}}},ei=async e=>{("unattended"!==e||en||await (0,o.Z)(F("batch.unattendedConfirm",{n:Q.length})))&&await es(async()=>{var n;let t=await r.FH.startBatch(Q.map(e=>e.id),e,f,W||void 0,R||void 0,U.trim()||Q.map(e=>e.planName).find(Boolean)||void 0);H(""),T(t.started?"":null!=(n=t.reason)?n:"")})},er=Z.filter(e=>{var n;return(null!=(n=e.model)?n:"")!==W}).length,ec=Z.filter(e=>{var n;return(null==(n=e.review)?void 0:n.enabled)===!1}).length,ed=null!=(s=null==B?void 0:B.options)?s:[],eo=ed.filter(e=>!e.group),eh=new Map;for(let e of ed)e.group&&eh.set(e.group,[...null!=(c=eh.get(e.group))?c:[],e]);let eu=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,em=null==w?void 0:w.sessions.find(e=>"running"===e.state);return(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:F("batch.title")}),(0,l.jsx)("p",{className:"muted small",children:F("batch.hint")}),!J&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("strong",{className:"small",children:F("batch.selected",{n:Q.length,tasks:G})}),(0,l.jsx)("button",{className:"quiet",onClick:()=>v(g.filter(e=>V(e)>0).map(e=>e.id)),children:F("batch.selectQueued")}),(0,l.jsx)("button",{className:"quiet",onClick:()=>v([]),disabled:0===Z.length,children:F("batch.selectNone")})]}),N&&(0,l.jsx)("p",{className:"muted small",children:F("batch.fromPlan")}),Z.length>Q.length&&(0,l.jsx)("p",{className:"muted small",children:F("batch.notRunnable",{n:Z.length-Q.length})}),Q.length>0&&(0,l.jsx)("ol",{className:"run-order",children:Q.map((e,n)=>(0,l.jsxs)("li",{children:[(0,l.jsxs)("span",{children:[e.name," ",(0,l.jsxs)("span",{className:"muted small",children:["(",V(e),")"]})]}),(0,l.jsxs)("span",{children:[(0,l.jsx)("button",{className:"quiet",onClick:()=>C(e.id,-1),disabled:0===n,"aria-label":F("batch.moveUp",{name:e.name}),children:"↑"}),(0,l.jsx)("button",{className:"quiet",onClick:()=>C(e.id,1),disabled:n===Q.length-1,"aria-label":F("batch.moveDown",{name:e.name}),children:"↓"})]})]},e.id))}),(0,l.jsx)("label",{htmlFor:"batch-run-name",children:F("batch.runName")}),(0,l.jsx)("input",{id:"batch-run-name",type:"text",value:U,onChange:e=>q(e.target.value),placeholder:null!=(m=Q.map(e=>e.planName).find(Boolean))?m:F("batch.runNamePlaceholder")}),(0,l.jsx)("p",{className:"why",children:F("batch.runNameWhy")}),(0,l.jsx)("label",{htmlFor:"batch-model",children:F("batch.model")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsxs)("select",{id:"batch-model",value:W,onChange:e=>I(e.target.value),style:{width:"auto",minWidth:260},children:[(0,l.jsx)("option",{value:"",children:F("batch.modelKeep")}),eo.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...eh.entries()].map(e=>{let[n,t]=e;return(0,l.jsx)("optgroup",{label:n,children:t.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},n)})]}),(null!=(x=null==B?void 0:B.options.length)?x:0)===0&&(0,l.jsx)("span",{className:"muted small",children:F("batch.modelNone")})]}),(0,l.jsx)("p",{className:"why",children:F("batch.modelWhy")}),(0,l.jsx)(u.L,{current:W,onUse:e=>I(e)}),W&&er>0&&(0,l.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:F("batch.modelOverrides",{n:er})}),(0,l.jsx)("label",{htmlFor:"batch-review-model",children:F("batch.reviewModel")}),(0,l.jsx)("div",{className:"row",children:(0,l.jsxs)("select",{id:"batch-review-model",value:R,onChange:e=>O(e.target.value),style:{width:"auto",minWidth:260},children:[(0,l.jsx)("option",{value:"",children:F("batch.reviewModelKeep")}),eo.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...eh.entries()].map(e=>{let[n,t]=e;return(0,l.jsx)("optgroup",{label:n,children:t.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},n)})]})}),(0,l.jsx)("p",{className:"why",children:F("batch.reviewModelWhy")}),""!==R&&R===W&&(0,l.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:F("batch.reviewSame")}),ec>0&&(0,l.jsx)("p",{className:"why",children:F("batch.reviewOffIn",{n:ec})}),(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:F("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:()=>y("stop")}),(0,l.jsx)("span",{children:F("batch.chain")})]}),(0,l.jsx)("p",{className:"why",children:F("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:()=>y("continue")}),(0,l.jsx)("span",{children:F("batch.independent")})]}),(0,l.jsx)("p",{className:"why",children:F("batch.independentWhy")})]})]}),ee&&(0,l.jsxs)("div",{className:"notice caution",children:[(0,l.jsx)("strong",{children:F(ee.title)}),(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:F(ee.why)})]}),(0,l.jsx)(p,{groups:L,sessionIds:Q.map(e=>e.id),onChange:()=>_(e=>e+1)}),D&&(0,l.jsxs)("div",{className:"notice caution",role:"alert",children:[(0,l.jsx)("strong",{children:F("batch.notStartedTitle")}),(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:D}),/execution\.isolation/.test(D)&&(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:(0,l.jsx)(i(),{href:"/defaults",children:F("batch.notStartedIsolation")})})]}),!Y&&(0,l.jsxs)("div",{className:"run-choice",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("button",{className:"primary",onClick:()=>void ei("unattended"),disabled:et||$,children:F("batch.run",{n:Q.length})}),(0,l.jsx)("p",{className:"why",children:F("batch.runWhy")})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("button",{onClick:()=>void ei("confirm"),disabled:et||$,children:F("batch.runStep")}),(0,l.jsx)("p",{className:"why",children:F("batch.runStepWhy")})]})]})]}),J&&(0,l.jsxs)("div",{className:"row",children:[(null==w?void 0:w.pausing)?(0,l.jsx)("button",{className:"primary",onClick:()=>void es(async()=>{await r.FH.resumeBatch(),H("")}),disabled:et||(null==w?void 0:w.stopping),title:F("batch.resumeWhy"),children:F("batch.resume")}):(0,l.jsx)("button",{onClick:()=>void es(async()=>{await r.FH.pauseBatch(),H(F("batch.pausing"))}),disabled:et||(null==w?void 0:w.stopping),title:F("batch.pauseWhy"),children:F("batch.pause")}),(0,l.jsx)("button",{onClick:()=>void es(async()=>{await r.FH.stopBatch(),H(F("batch.stopping"))}),disabled:et||(null==w?void 0:w.stopping),title:F("batch.stopWhy"),children:F("batch.stop")}),(null==w?void 0:w.pausing)&&!(null==w?void 0:w.stopping)&&(0,l.jsx)("span",{className:"muted small",children:F("batch.pausing")}),(0,l.jsx)("span",{className:"badge",children:F("batch.modelRunning",{name:(em?(null==(n=K.get(em.sessionId))?void 0:n.modelInUse)||(null==(t=K.get(em.sessionId))?void 0:t.model):"")||F("model.default")})}),k.length>0&&(0,l.jsx)("span",{className:"badge waiting-approval",children:F("batch.waiting",{n:k.length})}),em&&(0,l.jsx)("span",{className:"small",children:F("batch.progress",{name:em.name,done:w.sessions.filter(e=>"waiting"!==e.state&&"running"!==e.state).length,total:w.sessions.length})})]}),J&&(0,l.jsx)("p",{className:"muted small",children:F("batch.hiddenWhileRunning")}),E&&(0,l.jsx)("div",{className:"muted small",role:"status",children:E}),(Z.length>0||w)&&(0,l.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,l.jsx)("a",{className:"button-link",href:r.FH.debugExportUrl(Z.length>0?Z.map(e=>e.id):(null!=(j=null==w?void 0:w.sessions)?j:[]).map(e=>e.sessionId)),children:F("batch.debug")}),(0,l.jsx)("span",{className:"muted small",children:Z.length>0?F("batch.debugSelected",{n:Z.length}):F("batch.debugLast")})]}),(Z.length>0||w)&&(0,l.jsx)("p",{className:"why",children:F("batch.debugWhy")}),w&&(0,l.jsxs)(l.Fragment,{children:[!J&&eu&&(0,l.jsx)("div",{className:"notice calm",style:{marginTop:12},children:(0,l.jsx)("strong",{children:F("batch.finished",eu)})}),(0,l.jsxs)("table",{style:{marginTop:10},children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:F("batch.col.session")}),(0,l.jsx)("th",{children:F("batch.col.state")}),(0,l.jsx)("th",{children:F("batch.col.ran")}),(0,l.jsx)("th",{children:F("batch.col.why")})]})}),(0,l.jsx)("tbody",{children:w.sessions.map(e=>{var n,t;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"===(t=e.state)?"running":"done"===t?"done":"failed"===t?"failed":"stopped"===t?"aborted":""),children:F("batch.state.".concat(e.state))})}),(0,l.jsx)("td",{className:"small",children:F("batch.ranOf",{ran:e.ran,failed:e.failed})}),(0,l.jsx)("td",{className:"muted small",children:null!=(n=e.reason)?n:""})]},e.sessionId)})})]})]})]})}},7527:(e,n,t)=>{"use strict";t.d(n,{z:()=>a});var l=t(1521);function a(e,n){let t=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=(0,l.useRef)(e);a.current=e,(0,l.useEffect)(()=>{let e;if(!t)return;let l=!1,s=async()=>{try{await a.current()}catch(e){}finally{l||(e=setTimeout(()=>void s(),n))}};return s(),()=>{l=!0,e&&clearTimeout(e)}},[n,t])}},8848:(e,n,t)=>{"use strict";t.d(n,{H4:()=>d,L:()=>o,z4:()=>h});var l=t(3365),a=t(8197),s=t.n(a),i=t(1521),r=t(5549),c=t(867);function d(e){let{current:n,onUse:t}=e,{t:a}=(0,c.kj)(),[s,d]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return r.FH.project().then(n=>{e||d(n)}).catch(()=>void 0),()=>{e=!0}},[]),!s)return null;let o=s.rootDir.trim(),h=n.trim().toLowerCase(),u=t?s.others.filter(e=>e.rootDir.trim().toLowerCase()!==h):[];return(0,l.jsx)(m,{label:o?a("proj.defaultIs",{dir:o}):a("proj.noneShort"),offer:o&&t&&h!==o.toLowerCase()?{text:a("proj.useIt"),onUse:()=>t(o)}:void 0,more:u.map(e=>({text:a("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==t?void 0:t(e.rootDir)})),link:o?a("proj.change"):a("proj.setIt"),anchor:"project"})}function o(e){let{current:n,onUse:t}=e,a=u(),{t:s}=(0,c.kj)();if(!a)return null;let i=a.defaultModel.trim();return(0,l.jsx)(m,{label:i?s("def.modelDefaultIs",{name:i}):s("def.modelNoneShort"),offer:i&&t&&n.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>t(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"model"})}function h(e){let{current:n,onUse:t}=e,a=u(),{t:s}=(0,c.kj)();if(!a)return null;let i=a.defaultReviewModel.trim();return(0,l.jsx)(m,{label:i?s("def.reviewDefaultIs",{name:i}):s("def.reviewNoneShort"),offer:i&&t&&n.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>t(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"review"})}function u(){let[e,n]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return r.FH.models().then(t=>{e||n(t)}).catch(()=>void 0),()=>{e=!0}},[]),e}function m(e){let{label:n,offer:t,more:a=[],link:i,anchor:r}=e;return(0,l.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[n," ",t&&(0,l.jsxs)(l.Fragment,{children:["\xb7"," ",(0,l.jsx)("button",{type:"button",className:"linkish",onClick:t.onUse,children:t.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()}]);